diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..f14f78b --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": false, + "es6": true, + "node": true, + "mocha": true + }, + "extends": "standard", + "overrides": [ + ], + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "indent": ["error", 4], + "semi": ["error", "always"], + "space-before-function-paren": ["error", "never"] + }, + "globals": { + "chai": "readonly" + } +} diff --git a/dist/divi.min.js b/dist/divi.min.js index b54aacb..4aad887 100644 --- a/dist/divi.min.js +++ b/dist/divi.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).divi={})}(this,(function(t){"use strict";const e=Math.PI,n=2*e,i=1e-6,r=n-i;function s(t){this._+=t[0];for(let e=1,n=t.length;e=0))throw new Error(`invalid digits: ${t}`);if(e>15)return s;const n=10**e;return function(t){this._+=t[0];for(let e=1,i=t.length;ei)if(Math.abs(p*l-u*h)>i&&a){let f=r-o,m=s-c,y=l*l+u*u,g=f*f+m*m,b=Math.sqrt(y),v=Math.sqrt(d),_=a*Math.tan((e-Math.acos((y+d-g)/(2*b*v)))/2),x=_/v,w=_/b;Math.abs(x-1)>i&&this._append`L${t+x*h},${n+x*p}`,this._append`A${a},${a},0,0,${+(p*f>h*m)},${this._x1=t+w*l},${this._y1=n+w*u}`}else this._append`L${this._x1=t},${this._y1=n}`;else;}arc(t,s,a,o,c,l){if(t=+t,s=+s,l=!!l,(a=+a)<0)throw new Error(`negative radius: ${a}`);let u=a*Math.cos(o),h=a*Math.sin(o),p=t+u,d=s+h,f=1^l,m=l?o-c:c-o;null===this._x1?this._append`M${p},${d}`:(Math.abs(this._x1-p)>i||Math.abs(this._y1-d)>i)&&this._append`L${p},${d}`,a&&(m<0&&(m=m%n+n),m>r?this._append`A${a},${a},0,1,${f},${t-u},${s-h}A${a},${a},0,1,${f},${this._x1=p},${this._y1=d}`:m>i&&this._append`A${a},${a},0,${+(m>=e)},${f},${this._x1=t+a*Math.cos(c)},${this._y1=s+a*Math.sin(c)}`)}rect(t,e,n,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+i}h${-n}Z`}toString(){return this._}};function o(){return new a}o.prototype=a.prototype;var c="http://www.w3.org/1999/xhtml",l={svg:"http://www.w3.org/2000/svg",xhtml:c,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function u(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),l.hasOwnProperty(e)?{space:l[e],local:t}:t}function h(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===c&&e.documentElement.namespaceURI===c?e.createElement(t):e.createElementNS(n,t)}}function p(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function d(t){var e=u(t);return(e.local?p:h)(e)}function f(){}function m(t){return null==t?f:function(){return this.querySelector(t)}}function y(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function g(){return[]}function b(t){return function(e){return e.matches(t)}}var v=Array.prototype.find;function _(){return this.firstElementChild}var x=Array.prototype.filter;function w(){return Array.from(this.children)}function S(t){return new Array(t.length)}function I(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function A(t,e,n,i,r,s){for(var a,o=0,c=e.length,l=s.length;oe?1:t>=e?0:NaN}function C(t){return function(){this.removeAttribute(t)}}function N(t){return function(){this.removeAttributeNS(t.space,t.local)}}function O(t,e){return function(){this.setAttribute(t,e)}}function L(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function B(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function D(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function F(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function V(t){return function(){this.style.removeProperty(t)}}function U(t,e,n){return function(){this.style.setProperty(t,e,n)}}function P(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function R(t){return function(){delete this[t]}}function j(t,e){return function(){this[t]=e}}function $(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function z(t){return t.trim().split(/^|\s+/)}function H(t){return t.classList||new q(t)}function q(t){this._node=t,this._names=z(t.getAttribute("class")||"")}function Y(t,e){for(var n=H(t),i=-1,r=e.length;++i=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ft=[null];function mt(t,e){this._groups=t,this._parents=e}function yt(t){return"string"==typeof t?new mt([[document.querySelector(t)]],[document.documentElement]):new mt([[t]],ft)}function gt(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=t.clientX,i.y=t.clientY,[(i=i.matrixTransform(e.getScreenCTM().inverse())).x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}function bt(t){return"string"==typeof t?new mt([document.querySelectorAll(t)],[document.documentElement]):new mt([y(t)],ft)}mt.prototype={constructor:mt,select:function(t){"function"!=typeof t&&(t=m(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r=x&&(x=_+1);!(v=g[x])&&++x=0;)(i=r[s])&&(a&&4^i.compareDocumentPosition(a)&&a.parentNode.insertBefore(i,a),a=i);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=E);for(var n=this._groups,i=n.length,r=new Array(i),s=0;s1?this.each((null==e?V:"function"==typeof e?P:U)(t,e,null==n?"":n)):function(t,e){return t.style.getPropertyValue(e)||F(t).getComputedStyle(t,null).getPropertyValue(e)}(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?R:"function"==typeof e?$:j)(t,e)):this.node()[t]},classed:function(t,e){var n=z(t+"");if(arguments.length<2){for(var i=H(this.node()),r=-1,s=n.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}(t+""),a=s.length;if(!(arguments.length<2)){for(o=e?ut:lt,i=0;i=0;t=r.next(t+1))n[++s]=t;else for(let t=0;tt(n,i,e)))}return!t&&i||(this._index=n),n}partitions(t=!0){if(this._partitions)return this._partitions;if(!this.isGrouped())return[this.indices(t)];const{keys:e,size:n}=this._group,i=Tt(n,(()=>[])),r=this._index,s=this.mask(),a=this.numRows();if(r&&this.isOrdered())for(let t,n=0;n=0;t=s.next(t+1))i[e[t]].push(t);else for(let t=0;tt(n,i,e)))}return!t&&this.isOrdered()||(this._partitions=i),i}scan(t,e,n=1/0,i=0){const r=this._mask,s=this._nrows,a=this._data;let o=i||0;if(o>s)return;const c=Math.min(s,o+n),l=()=>o=this._total;if(e&&this.isOrdered()||r&&this._index){const e=this.indices(),n=this._data;for(;o-1;o=r.next(o+1))t(o,a,l)}else for(;on.push(t)),!0,e-t,t),this.reify(n)}reduce(t){return this.__reduce(this,t)}},Mt=class{constructor(t){this.data=t}get length(){return this.data.length}get(t){return this.data[t]}[Symbol.iterator](){return this.data[Symbol.iterator]()}},Et=function(t){return t&&At(t.get)?t:new Mt(t)};function Ct(t){return t instanceof Date}function Nt(t){return t===Object(t)}function Ot(t){return t instanceof RegExp}function Lt(t){return"string"==typeof t}function Bt(t,e){const n=e=>St(`Illegal argument type: ${e||typeof t}`);return t instanceof Map?Dt(t.entries(),e):Ct(t)?n("Date"):Ot(t)?n("RegExp"):Lt(t)?n():vt(t)?function(t,e){const n=t.length,i={},r=t=>i[t]=Array(n);if(n){const i=(e=e||Object.keys(t[0])).map(r),s=i.length;for(let r=0;rn[t]=[];let r,s;for(const n of t){r||(r=(e=e||Object.keys(n)).map(i),s=r.length);for(let t=0;tzt(t)||Lt(t);var Yt={compact:t=>zt(t)?t.filter((t=>Ht(t))):t,concat:(...t)=>[].concat(...t),includes:(t,e,n)=>!!qt(t)&&t.includes(e,n),indexof:(t,e)=>qt(t)?t.indexOf(e):-1,join:(t,e)=>zt(t)?t.join(e):Rt,lastindexof:(t,e)=>qt(t)?t.lastIndexOf(e):-1,length:t=>qt(t)?t.length:0,pluck:(t,e)=>zt(t)?t.map((t=>Ht(t)?t[e]:Rt)):Rt,reverse:t=>zt(t)?t.slice().reverse():Lt(t)?t.split("").reverse().join(""):Rt,slice:(t,e,n)=>qt(t)?t.slice(e,n):Rt};function Wt(t,e,n="0"){const i=t+"",r=i.length;return r(t<10?"0":"")+t,Kt=t=>t<0?"-"+Wt(-t,6):t>9999?"+"+Wt(t,6):Wt(t,4);function Qt(t,e,n,i,r,s,a,o,c){const l=o?"Z":"";return Kt(t)+"-"+Gt(e+1)+"-"+Gt(n)+(!c||a?"T"+Gt(i)+":"+Gt(r)+":"+Gt(s)+"."+Wt(a,3)+l:s?"T"+Gt(i)+":"+Gt(r)+":"+Gt(s)+l:r||i||!o?"T"+Gt(i)+":"+Gt(r)+l:"")}function Jt(t,e){return isNaN(t)?"Invalid Date":Qt(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds(),!1,e)}function Zt(t,e){return isNaN(t)?"Invalid Date":Qt(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds(),!0,e)}const Xt=/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/;function te(t){return t.match(Xt)}const ee=864e5,ne=6048e5,ie=new Date,re=new Date,se=t=>(ie.setTime("string"==typeof t?function(t,e=Date.parse){return te(t)?e(t):t}(t):t),ie);var ae={format_date:(t,e)=>Jt(se(t),!e),format_utcdate:(t,e)=>Zt(se(t),!e),timestamp:t=>+se(t),year:t=>se(t).getFullYear(),quarter:t=>Math.floor(se(t).getMonth()/3),month:t=>se(t).getMonth(),date:t=>se(t).getDate(),dayofweek:t=>se(t).getDay(),hours:t=>se(t).getHours(),minutes:t=>se(t).getMinutes(),seconds:t=>se(t).getSeconds(),milliseconds:t=>se(t).getMilliseconds(),utcyear:t=>se(t).getUTCFullYear(),utcquarter:t=>Math.floor(se(t).getUTCMonth()/3),utcmonth:t=>se(t).getUTCMonth(),utcdate:t=>se(t).getUTCDate(),utcdayofweek:t=>se(t).getUTCDay(),utchours:t=>se(t).getUTCHours(),utcminutes:t=>se(t).getUTCMinutes(),utcseconds:t=>se(t).getUTCSeconds(),utcmilliseconds:t=>se(t).getUTCMilliseconds(),datetime:function(t,e,n,i,r,s,a){return arguments.length?new Date(t,e||0,null==n?1:n,i||0,r||0,s||0,a||0):new Date(Date.now())},dayofyear:function(t){re.setTime(+t),re.setHours(0,0,0,0),ie.setTime(+re),ie.setMonth(0),ie.setDate(1);const e=6e4*(re.getTimezoneOffset()-ie.getTimezoneOffset());return Math.floor(1+(re-ie-e)/ee)},week:function(t,e){const n=e||0;re.setTime(+t),re.setDate(re.getDate()-(re.getDay()+7-n)%7),re.setHours(0,0,0,0),ie.setTime(+t),ie.setMonth(0),ie.setDate(1),ie.setDate(1-(ie.getDay()+7-n)%7),ie.setHours(0,0,0,0);const i=6e4*(re.getTimezoneOffset()-ie.getTimezoneOffset());return Math.floor((re-ie+1-i)/ne)},utcdatetime:function(t,e,n,i,r,s,a){return arguments.length?new Date(Date.UTC(t,e||0,null==n?1:n,i||0,r||0,s||0,a||0)):new Date(Date.now())},utcdayofyear:function(t){re.setTime(+t),re.setUTCHours(0,0,0,0);const e=Date.UTC(re.getUTCFullYear(),0,1);return Math.floor(1+(re-e)/ee)},utcweek:function(t,e){const n=e||0;return re.setTime(+t),re.setUTCDate(re.getUTCDate()-(re.getUTCDay()+7-n)%7),re.setUTCHours(0,0,0,0),ie.setTime(+t),ie.setUTCMonth(0),ie.setUTCDate(1),ie.setUTCDate(1-(ie.getUTCDay()+7-n)%7),ie.setUTCHours(0,0,0,0),Math.floor((re-ie+1)/ne)},now:Date.now};function oe(t,e){return null!=t&&null!=e&&t==t&&e==e&&(t===e||(Ct(t)||Ct(e)?+t==+e:Ot(t)&&Ot(e)?t+""==e+"":!(!Nt(t)||!Nt(e))&&function(t,e){if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;if(t.length||e.length)return ce(t,e);const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;if(n.sort(),i.sort(),!ce(n,i,((t,e)=>t===e)))return!1;const r=n.length;for(let i=0;iJSON.parse(t),to_json:t=>JSON.stringify(t)};let ue=Math.random;function he(){return ue()}function pe(t){return t instanceof Map}function de(t){return pe(t)||function(t){return t instanceof Set}(t)}function fe(t){return Array.from(t)}var me={has:(t,e)=>de(t)?t.has(e):null!=t&&Vt(t,e),keys:t=>pe(t)?fe(t.keys()):null!=t?Object.keys(t):[],values:t=>de(t)?fe(t.values()):null!=t?Object.values(t):[],entries:t=>de(t)?fe(t.entries()):null!=t?Object.entries(t):[],object:t=>t?Object.fromEntries(t):Rt};var ye={bin:function(t,e,n,i,r){return null==t?null:tn?1/0:(t=Math.max(e,Math.min(t,n)),e+i*Math.floor(1e-14+(t-e)/i+(r||0)))},equal:oe,recode:function(t,e,n){if(e instanceof Map){if(e.has(t))return e.get(t)}else if(Vt(e,t))return e[t];return void 0!==n?n:t},sequence:function(t,e,n){let i=arguments.length;t=+t,e=+e,n=i<2?(e=t,t=0,1):i<3?1:+n,i=0|Math.max(0,Math.ceil((e-t)/n));const r=new Array(i);for(let e=0;e180*t/Math.PI,radians:t=>Math.PI*t/180,acos:Math.acos,acosh:Math.acosh,asin:Math.asin,asinh:Math.asinh,atan:Math.atan,atan2:Math.atan2,atanh:Math.atanh,cos:Math.cos,cosh:Math.cosh,sin:Math.sin,sinh:Math.sinh,tan:Math.tan,tanh:Math.tanh},...me,...{parse_date:t=>null==t?t:new Date(t),parse_float:t=>null==t?t:Number.parseFloat(t),parse_int:(t,e)=>null==t?t:Number.parseInt(t,e),endswith:(t,e,n)=>null!=t&&String(t).endsWith(e,n),match:(t,e,n)=>{const i=null==t?t:String(t).match(e);return null==n||null==i?i:"number"==typeof n?i[n]:i.groups?i.groups[n]:null},normalize:(t,e)=>null==t?t:String(t).normalize(e),padend:(t,e,n)=>null==t?t:String(t).padEnd(e,n),padstart:(t,e,n)=>null==t?t:String(t).padStart(e,n),upper:t=>null==t?t:String(t).toUpperCase(),lower:t=>null==t?t:String(t).toLowerCase(),repeat:(t,e)=>null==t?t:String(t).repeat(e),replace:(t,e,n)=>null==t?t:String(t).replace(e,String(n)),substring:(t,e,n)=>null==t?t:String(t).substring(e,n),split:(t,e,n)=>null==t?[]:String(t).split(e,n),startswith:(t,e,n)=>null!=t&&String(t).startsWith(e,n),trim:t=>null==t?t:String(t).trim()}};function ge(t){return"bigint"==typeof t}function be(t){return void 0===t?t+"":ge(t)?t+"n":JSON.stringify(t)}function ve(t,e=[],n=[]){return new _e(t,_t(e),_t(n))}let _e=class{constructor(t,e,n){this.name=t,this.fields=e,this.params=n}toString(){const t=[...this.fields.map((t=>`d[${be(t)}]`)),...this.params.map(be)];return`d => op.${this.name}(${t})`}toObject(){return{expr:this.toString(),func:!0}}};const xe=t=>ve("any",t),we=()=>ve("count"),Se=t=>ve("array_agg",t),Ie=t=>ve("array_agg_distinct",t),Ae=(t,e)=>ve("map_agg",[t,e]),Te=(t,e)=>ve("object_agg",[t,e]),ke=(t,e)=>ve("entries_agg",[t,e]);var Me={...ye,row_object:(...t)=>ve("row_object",null,t.flat()),count:we,any:xe,array_agg:Se,array_agg_distinct:Ie,object_agg:Te,map_agg:Ae,entries_agg:ke,valid:t=>ve("valid",t),invalid:t=>ve("invalid",t),distinct:t=>ve("distinct",t),mode:t=>ve("mode",t),sum:t=>ve("sum",t),product:t=>ve("product",t),mean:t=>ve("mean",t),average:t=>ve("average",t),variance:t=>ve("variance",t),variancep:t=>ve("variancep",t),stdev:t=>ve("stdev",t),stdevp:t=>ve("stdevp",t),min:t=>ve("min",t),max:t=>ve("max",t),quantile:(t,e)=>ve("quantile",t,e),median:t=>ve("median",t),covariance:(t,e)=>ve("covariance",[t,e]),covariancep:(t,e)=>ve("covariancep",[t,e]),corr:(t,e)=>ve("corr",[t,e]),bins:(t,e,n,i)=>ve("bins",t,[e,n,i]),row_number:()=>ve("row_number"),rank:()=>ve("rank"),avg_rank:()=>ve("avg_rank"),dense_rank:()=>ve("dense_rank"),percent_rank:()=>ve("percent_rank"),cume_dist:()=>ve("cume_dist"),ntile:t=>ve("ntile",null,t),lag:(t,e,n)=>ve("lag",t,[e,n]),lead:(t,e,n)=>ve("lead",t,[e,n]),first_value:t=>ve("first_value",t),last_value:t=>ve("last_value",t),nth_value:(t,e)=>ve("nth_value",t,e),fill_down:(t,e)=>ve("fill_down",t,e),fill_up:(t,e)=>ve("fill_up",t,e)};function Ee(t,e,n,i){const r="map"===i||!0===i?Ae:"entries"===i?ke:"object"===i?Te:St('groups option must be "map", "entries", or "object".'),{names:s}=t.groups(),a=function(t,e){t=de(t)?t:new Set(t);let n=e,i=0;for(;t.has(n);)n=e+ ++i;return n}(t.columnNames(),"_");let o=t.select().reify(e).create({data:{[a]:n}}).rollup({[a]:Se(a)});for(let t=s.length;--t>=0;)o=o.groupby(s.slice(0,t)).rollup({[a]:r(s[t],a)});return o.get(a)}const Ce="ArrowFunctionExpression",Ne="FunctionExpression",Oe="Identifier",Le="Literal",Be="MemberExpression",De="ObjectExpression",Fe="ObjectPattern",Ve="Property",Ue="Column",Pe="Constant",Re="Dictionary",je="Parameter",$e=(t,e)=>{const n=Ke[t.type];return n?n(t,e):St(`Unsupported expression construct: ${t.type}`)},ze=(t,e)=>"("+$e(t.left,e)+" "+t.operator+" "+$e(t.right,e)+")",He=(t,e)=>"("+Ye(t.params,e)+")=>"+$e(t.body,e),qe=(t,e)=>$e(t.callee,e)+"("+Ye(t.arguments,e)+")",Ye=(t,e,n=",")=>t.map((t=>$e(t,e))).join(n),We=t=>t.computed?`[${be(t.name)}]`:`.${t.name}`,Ge=(t,e,n)=>{const i=t.table||"";return`data${i}${We(t)}.${n}(${e.index}${i})`},Ke={Constant:t=>t.raw,Column:(t,e)=>Ge(t,e,"get"),Dictionary:(t,e)=>Ge(t,e,"key"),Function:t=>`fn.${t.name}`,Parameter:t=>`$${We(t)}`,Op:(t,e)=>`op(${be(t.name)},${e.op||e.index})`,Literal:t=>t.raw,Identifier:t=>t.name,TemplateLiteral:(t,e)=>{const{quasis:n,expressions:i}=t,r=i.length;let s=n[0].value.raw;for(let t=0;t{const n=!t.computed,i=$e(t.object,e),r=$e(t.property,e);return i+(n?"."+r:"["+r+"]")},CallExpression:qe,NewExpression:(t,e)=>"new "+qe(t,e),ArrayExpression:(t,e)=>"["+Ye(t.elements,e)+"]",AssignmentExpression:ze,BinaryExpression:ze,LogicalExpression:ze,UnaryExpression:(t,e)=>"("+t.operator+$e(t.argument,e)+")",ConditionalExpression:(t,e)=>"("+$e(t.test,e)+"?"+$e(t.consequent,e)+":"+$e(t.alternate,e)+")",ObjectExpression:(t,e)=>"({"+Ye(t.properties,e)+"})",Property:(t,e)=>{const n=$e(t.key,e);return(t.computed?`[${n}]`:n)+":"+$e(t.value,e)},ArrowFunctionExpression:He,FunctionExpression:He,FunctionDeclaration:He,ArrayPattern:(t,e)=>"["+Ye(t.elements,e)+"]",ObjectPattern:(t,e)=>"{"+Ye(t.properties,e)+"}",VariableDeclaration:(t,e)=>t.kind+" "+Ye(t.declarations,e,","),VariableDeclarator:(t,e)=>$e(t.id,e)+"="+$e(t.init,e),SpreadElement:(t,e)=>"..."+$e(t.argument,e),BlockStatement:(t,e)=>"{"+Ye(t.body,e,";")+";}",BreakStatement:()=>"break",ExpressionStatement:(t,e)=>$e(t.expression,e),IfStatement:(t,e)=>"if ("+$e(t.test,e)+")"+$e(t.consequent,e)+(t.alternate?" else "+$e(t.alternate,e):""),SwitchStatement:(t,e)=>"switch ("+$e(t.discriminant,e)+") {"+Ye(t.cases,e,"")+"}",SwitchCase:(t,e)=>(t.test?"case "+$e(t.test,e):"default")+": "+Ye(t.consequent,e,";")+";",ReturnStatement:(t,e)=>"return "+$e(t.argument,e),Program:(t,e)=>$e(t.body[0],e)};function Qe(t,e={index:"row"}){return $e(t,e)}function Je(t){const e=typeof t;return"string"===e?`"${t}"`:"object"===e&&t?Ct(t)?+t:vt(t)||$t(t)?`[${t.map(Je)}]`:Ot(t)?t+"":function(t){let e="{",n=-1;for(const i in t)++n>0&&(e+=","),e+=`"${i}":${Je(t[i])}`;return e+="}",e}(t):t}function Ze(t,e){const n=t.length;return 1===n?(e,n)=>Je(t[0](e,n)):(i,r)=>{let s="";for(let a=0;a0&&(s+="|");const n=t[a](i,r);if(e&&(null==n||n!=n))return null;s+=Je(n)}return s}}function Xe(){}function tn(t){return t.init=t.init||Xe,t.add=t.add||Xe,t.rem=t.rem||Xe,t}function en(t,e){return t.product_v=!1,t.product=e}var nn={count:{create:()=>tn({value:t=>t.count}),param:[]},array_agg:{create:()=>tn({init:t=>t.values=!0,value:t=>t.list.values(t.stream)}),param:[1]},object_agg:{create:()=>tn({init:t=>t.values=!0,value:t=>Object.fromEntries(t.list.values())}),param:[2]},map_agg:{create:()=>tn({init:t=>t.values=!0,value:t=>new Map(t.list.values())}),param:[2]},entries_agg:{create:()=>tn({init:t=>t.values=!0,value:t=>t.list.values(t.stream)}),param:[2]},any:{create:()=>tn({add:(t,e)=>{null==t.any&&(t.any=e)},value:t=>t.valid?t.any:Rt}),param:[1]},valid:{create:()=>tn({value:t=>t.valid}),param:[1]},invalid:{create:()=>tn({value:t=>t.count-t.valid}),param:[1]},distinct:{create:()=>({init:t=>t.distinct=function(){const t=new Map;return{count:()=>t.size,values:()=>Array.from(t.values(),(t=>t.v)),increment(e){const n=Je(e),i=t.get(n);i?++i.n:t.set(n,{v:e,n:1})},decrement(e){const n=Je(e),i=t.get(n);1===i.n?t.delete(n):--i.n},forEach(e){t.forEach((({v:t,n})=>e(t,n)))}}}(),value:t=>t.distinct.count()+(t.valid===t.count?0:1),add:(t,e)=>t.distinct.increment(e),rem:(t,e)=>t.distinct.decrement(e)}),param:[1]},array_agg_distinct:{create:()=>tn({value:t=>t.distinct.values()}),param:[1],req:["distinct"]},mode:{create:()=>tn({value:t=>{let e=Rt,n=0;return t.distinct.forEach(((t,i)=>{i>n&&(n=i,e=t)})),e}}),param:[1],req:["distinct"]},sum:{create:()=>({init:t=>t.sum=0,value:t=>t.valid?t.sum:Rt,add:(t,e)=>ge(e)?0===t.sum?t.sum=e:t.sum+=e:t.sum+=+e,rem:(t,e)=>t.sum-=e}),param:[1]},product:{create:()=>({init:t=>en(t,1),value:t=>t.valid?t.product_v?en(t,function(t,e=0,n=t.length){let i=t[e++];for(let r=e;rge(e)&&1===t.product?t.product=e:t.product*=e,rem:(t,e)=>0==e||e===1/0||e===-1/0?t.product_v=!0:t.product/=e}),param:[1],stream:["array_agg"]},mean:{create:()=>({init:t=>t.mean=0,value:t=>t.valid?t.mean:Rt,add:(t,e)=>{t.mean_d=e-t.mean,t.mean+=t.mean_d/t.valid},rem:(t,e)=>{t.mean_d=e-t.mean,t.mean-=t.valid?t.mean_d/t.valid:t.mean}}),param:[1]},average:{create:()=>tn({value:t=>t.valid?t.mean:Rt}),param:[1],req:["mean"]},variance:{create:()=>({init:t=>t.dev=0,value:t=>t.valid>1?t.dev/(t.valid-1):Rt,add:(t,e)=>t.dev+=t.mean_d*(e-t.mean),rem:(t,e)=>t.dev-=t.mean_d*(e-t.mean)}),param:[1],req:["mean"]},variancep:{create:()=>tn({value:t=>t.valid>1?t.dev/t.valid:Rt}),param:[1],req:["variance"]},stdev:{create:()=>tn({value:t=>t.valid>1?Math.sqrt(t.dev/(t.valid-1)):Rt}),param:[1],req:["variance"]},stdevp:{create:()=>tn({value:t=>t.valid>1?Math.sqrt(t.dev/t.valid):Rt}),param:[1],req:["variance"]},min:{create:()=>({init:t=>t.min=Rt,value:t=>t.min=Number.isNaN(t.min)?t.list.min():t.min,add:(t,e)=>{(e{e<=t.min&&(t.min=NaN)}}),param:[1],stream:["array_agg"]},max:{create:()=>({init:t=>t.max=Rt,value:t=>t.max=Number.isNaN(t.max)?t.list.max():t.max,add:(t,e)=>{(e>t.max||t.max===Rt)&&(t.max=e)},rem:(t,e)=>{e>=t.max&&(t.max=NaN)}}),param:[1],stream:["array_agg"]},quantile:{create:t=>tn({value:e=>e.list.quantile(t)}),param:[1,1],req:["array_agg"]},median:{create:()=>tn({value:t=>t.list.quantile(.5)}),param:[1],req:["array_agg"]},covariance:{create:()=>({init:t=>{t.cov=t.mean_x=t.mean_y=t.dev_x=t.dev_y=0},value:t=>t.valid>1?t.cov/(t.valid-1):Rt,add:(t,e,n)=>{const i=e-t.mean_x,r=n-t.mean_y;t.mean_x+=i/t.valid,t.mean_y+=r/t.valid;const s=n-t.mean_y;t.dev_x+=i*(e-t.mean_x),t.dev_y+=r*s,t.cov+=i*s},rem:(t,e,n)=>{const i=e-t.mean_x,r=n-t.mean_y;t.mean_x-=t.valid?i/t.valid:t.mean_x,t.mean_y-=t.valid?r/t.valid:t.mean_y;const s=n-t.mean_y;t.dev_x-=i*(e-t.mean_x),t.dev_y-=r*s,t.cov-=i*s}}),param:[2]},covariancep:{create:()=>tn({value:t=>t.valid>1?t.cov/t.valid:Rt}),param:[2],req:["covariance"]},corr:{create:()=>tn({value:t=>t.valid>1?t.cov/(Math.sqrt(t.dev_x)*Math.sqrt(t.dev_y)):Rt}),param:[2],req:["covariance"]},bins:{create:(t,e,n,i)=>tn({value:r=>function(t,e,n=15,i=!0,r=0,s){const a=Math.LN10;if(null==s){const i=Math.ceil(Math.log(n)/a),o=e-t||Math.abs(t)||1,c=[5,2];for(s=Math.max(r,Math.pow(10,Math.round(Math.log(o)/a)-i));Math.ceil(o/s)>n;)s*=10;const l=c.length;for(let t=0;t=r&&o/e<=n&&(s=e)}}if(i){let n=Math.log(s);const i=n>=0?0:1+~~(-n/a),r=Math.pow(10,-i-1);n=Math.floor(t/s+r)*s,t=tt=1,value:e=>{const n=e.index;return n&&!e.peer(n)?t=n+1:t}}},param:[]},sn={create(){let t;return{init:()=>t=0,value:e=>{const{index:n,peer:i,size:r}=e;let s=n;if(t({init:Xe,value:t=>t.index+1}),param:[]},rank:rn,avg_rank:{create(){let t,e;return{init:()=>(t=-1,e=1),value:n=>{const i=n.index;if(i>=t){for(e=t=i+1;n.peer(t);e+=++t);e/=t-i}return e}}},param:[]},dense_rank:{create(){let t;return{init:()=>t=1,value:e=>{const n=e.index;return n&&!e.peer(n)?++t:t}}},param:[]},percent_rank:{create(){const{init:t,value:e}=rn.create();return{init:t,value:t=>(e(t)-1)/(t.size-1)}},param:[]},cume_dist:sn,ntile:{create(t){(t=+t)>0||St("ntile num must be greater than zero.");const{init:e,value:n}=sn.create();return{init:e,value:e=>Math.ceil(t*n(e))}},param:[0,1]},lag:{create:(t,e=Rt)=>(t=+t||1,{init:Xe,value:(n,i)=>{const r=n.index-t;return r>=0?n.value(r,i):e}}),param:[1,2]},lead:{create:(t,e=Rt)=>(t=+t||1,{init:Xe,value:(n,i)=>{const r=n.index+t;return r({init:Xe,value:(t,e)=>t.value(t.i0,e)}),param:[1]},last_value:{create:()=>({init:Xe,value:(t,e)=>t.value(t.i1-1,e)}),param:[1]},nth_value:{create:t=>((t=+t)>0||St("nth_value nth must be greater than zero."),{init:Xe,value:(e,n)=>{const i=e.i0+(t-1);return ie=t,value:(t,n)=>{const i=t.value(t.index,n);return Ht(i)?e=i:e}}},param:[1,1]},fill_up:{create(t=Rt){let e,n;return{init:()=>(e=t,n=-1),value:(i,r)=>i.index<=n?e:(n=function(t,e,n){for(const i=t.size;n=0?e=i.value(n,r):(n=i.size,e=t)}},param:[1,1]}};function on(t){return Vt(nn,t)}function cn(t){return Vt(an,t)}function ln(t){return Vt(ye,t)||"row_object"===t}function un(t){return on(t)&&nn[t]}function hn(t){return cn(t)&&an[t]}function pn(t,e,n){return t=`"use strict"; return ${t};`,Function("fn","$",t)(e,n)}var dn={escape:(t,e,n)=>pn(t,e,n),expr:(t,e)=>pn(`(row,data,op)=>${t}`,ye,e),expr2:(t,e)=>pn(`(row0,data0,row,data)=>${t}`,ye,e),join:(t,e)=>pn(`(row1,data1,row2,data2)=>${t}`,ye,e),param:(t,e)=>pn(t,ye,e)};const fn={"==":1,"!=":1,"===":1,"!==":1};function mn(t,e,n=0,i,r){if(t.type=Ue,t.name=e,t.table=n,r&&i&&At(i.keyFor)){const e=fn[r.operator]?r.left===t?r.right:r.left:r.callee&&"equal"===r.callee.name?r.arguments[r.arguments[0]===t?1:0]:null;e&&e.type===Le&&function(t,e,n,i){i<0?(t.type=Le,t.value=!1,t.raw="false"):(e.type=Re,n.value=i,n.raw=i+"")}(r,t,e,i.keyFor(e.value))}return t}function yn(t){return vt(t)?t:pe(t)?t.entries():t?Object.entries(t):[]}const gn="row_object";function bn(t,e){t.type=De;const n=t.properties=[];for(const t of yn(e)){const[e,i]=vt(t)?t:[t,t];n.push({type:Ve,key:{type:Le,raw:be(i)},value:mn({computed:!0},e)})}return t}function vn(t){return Qe(bn({},t))}function _n(t){return dn.expr(vn(t))}function xn(t,e,n,i){return new(n||(n=Promise))((function(r,s){function a(t){try{c(i.next(t))}catch(t){s(t)}}function o(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}c((i=i.apply(t,e||[])).next())}))}function wn(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Sn(t){return this instanceof Sn?(this.v=t,this):new Sn(t)}function In(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(t,e||[]),s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(t){r[t]&&(i[t]=function(e){return new Promise((function(n,i){s.push([t,e,n,i])>1||o(t,e)}))})}function o(t,e){try{(n=r[t](e)).value instanceof Sn?Promise.resolve(n.value.v).then(c,l):u(s[0][2],n)}catch(t){u(s[0][3],t)}var n}function c(t){o("next",t)}function l(t){o("throw",t)}function u(t,e){t(e),s.shift(),s.length&&o(s[0][0],s[0][1])}}function An(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:Sn(t[i](e)),done:!1}:r?r(e):e}:r}}function Tn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=wn(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}const kn=new TextDecoder("utf-8"),Mn=t=>kn.decode(t),En=new TextEncoder,Cn=t=>En.encode(t),[Nn,On]=(()=>{const t=()=>{throw new Error("BigInt is not available in this environment")};function e(){throw t()}return e.asIntN=()=>{throw t()},e.asUintN=()=>{throw t()},"undefined"!=typeof BigInt?[BigInt,!0]:[e,!1]})(),[Ln,Bn]=(()=>{const t=()=>{throw new Error("BigInt64Array is not available in this environment")};return"undefined"!=typeof BigInt64Array?[BigInt64Array,!0]:[class{static get BYTES_PER_ELEMENT(){return 8}static of(){throw t()}static from(){throw t()}constructor(){throw t()}},!1]})(),[Dn,Fn]=(()=>{const t=()=>{throw new Error("BigUint64Array is not available in this environment")};return"undefined"!=typeof BigUint64Array?[BigUint64Array,!0]:[class{static get BYTES_PER_ELEMENT(){return 8}static of(){throw t()}static from(){throw t()}constructor(){throw t()}},!1]})(),Vn=t=>"function"==typeof t,Un=t=>null!=t&&Object(t)===t,Pn=t=>Un(t)&&Vn(t.then),Rn=t=>Un(t)&&Vn(t[Symbol.iterator]),jn=t=>Un(t)&&Vn(t[Symbol.asyncIterator]),$n=t=>Un(t)&&"done"in t&&"value"in t,zn=t=>"_getDOMStream"in t&&"_getNodeStream"in t,Hn=t=>Un(t)&&Vn(t.clear)&&Vn(t.bytes)&&Vn(t.position)&&Vn(t.setPosition)&&Vn(t.capacity)&&Vn(t.getBufferIdentifier)&&Vn(t.createLong),qn="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;function Yn(t,e,n=0,i=e.byteLength){const r=t.byteLength,s=new Uint8Array(t.buffer,t.byteOffset,r),a=new Uint8Array(e.buffer,e.byteOffset,Math.min(i,r));return s.set(a,n),t}function Wn(t,e){const n=function(t){const e=t[0]?[t[0]]:[];let n,i,r,s;for(let a,o,c=0,l=0,u=t.length;++ct+e.byteLength),0);let r,s,a,o=0,c=-1;const l=Math.min(e||Number.POSITIVE_INFINITY,i);for(const t=n.length;++cGn(Int32Array,t),Qn=t=>Gn(Uint8Array,t),Jn=t=>(t.next(),t);const Zn=t=>function*(t,e){const n=function*(t){yield t},i="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof qn?n(e):Rn(e)?e:n(e);return yield*Jn(function*(e){let n=null;do{n=e.next(yield Gn(t,n))}while(!n.done)}(i[Symbol.iterator]())),new t}(Uint8Array,t);function Xn(t,e){return In(this,arguments,(function*(){if(Pn(e))return yield Sn(yield Sn(yield*An(Tn(Xn(t,yield Sn(e))))));const n=function(t){return In(this,arguments,(function*(){yield yield Sn(yield Sn(t))}))},i="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof qn?n(e):Rn(e)?function(t){return In(this,arguments,(function*(){yield Sn(yield*An(Tn(Jn(function*(t){let e=null;do{e=t.next(yield null==e?void 0:e.value)}while(!e.done)}(t[Symbol.iterator]())))))}))}(e):jn(e)?e:n(e);return yield Sn(yield*An(Tn(Jn(function(e){return In(this,arguments,(function*(){let n=null;do{n=yield Sn(e.next(yield yield Sn(Gn(t,n))))}while(!n.done)}))}(i[Symbol.asyncIterator]()))))),yield Sn(new t)}))}const ti=t=>Xn(Uint8Array,t);function ei(t,e,n){if(0!==t){n=n.slice(0,e+1);for(let i=-1;++i<=e;)n[i]+=t}return n}var ni={fromIterable:t=>ii(function*(t){let e,n,i,r,s=!1,a=[],o=0;function c(){return"peek"===i?Wn(a,r)[0]:([n,a,o]=Wn(a,r),n)}({cmd:i,size:r}=yield null);const l=Zn(t)[Symbol.iterator]();try{do{if(({done:e,value:n}=Number.isNaN(r-o)?l.next():l.next(r-o)),!e&&n.byteLength>0&&(a.push(n),o+=n.byteLength),e||r<=o)do{({cmd:i,size:r}=yield c())}while(rii(function(t){return In(this,arguments,(function*(){let e,n,i,r,s=!1,a=[],o=0;function c(){return"peek"===i?Wn(a,r)[0]:([n,a,o]=Wn(a,r),n)}({cmd:i,size:r}=yield yield Sn(null));const l=ti(t)[Symbol.asyncIterator]();try{do{if(({done:e,value:n}=Number.isNaN(r-o)?yield Sn(l.next()):yield Sn(l.next(r-o))),!e&&n.byteLength>0&&(a.push(n),o+=n.byteLength),e||r<=o)do{({cmd:i,size:r}=yield yield Sn(c()))}while(rii(function(t){return In(this,arguments,(function*(){let e,n,i,r=!1,s=!1,a=[],o=0;function c(){return"peek"===n?Wn(a,i)[0]:([e,a,o]=Wn(a,i),e)}({cmd:n,size:i}=yield yield Sn(null));const l=new ri(t);try{do{if(({done:r,value:e}=Number.isNaN(i-o)?yield Sn(l.read()):yield Sn(l.read(i-o))),!r&&e.byteLength>0&&(a.push(Qn(e)),o+=e.byteLength),r||i<=o)do{({cmd:n,size:i}=yield yield Sn(c()))}while(iii(function(t){return In(this,arguments,(function*(){const e=[];let n,i,r,s="error",a=!1,o=null,c=0,l=[];function u(){return"peek"===n?Wn(l,i)[0]:([r,l,c]=Wn(l,i),r)}if(({cmd:n,size:i}=yield yield Sn(null)),t.isTTY)return yield yield Sn(new Uint8Array(0)),yield Sn(null);try{e[0]=si(t,"end"),e[1]=si(t,"error");do{if(e[2]=si(t,"readable"),[s,o]=yield Sn(Promise.race(e.map((t=>t[2])))),"error"===s)break;if((a="end"===s)||(Number.isFinite(i-c)?(r=Qn(t.read(i-c)),r.byteLength0&&(l.push(r),c+=r.byteLength)),a||i<=c)do{({cmd:n,size:i}=yield yield Sn(u()))}while(i{for(const[n,i]of e)t.off(n,i);try{const e=t.destroy;e&&e.call(t,n),n=void 0}catch(t){n=t||n}finally{null!=n?r(n):i()}}))}}))}(t)),toDOMStream(t,e){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(t,e){throw new Error('"toNodeStream" not available in this environment')}};const ii=t=>(t.next(),t);class ri{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch((()=>{}))}get closed(){return this.reader?this.reader.closed.catch((()=>{})):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return xn(this,void 0,void 0,(function*(){const{reader:e,source:n}=this;e&&(yield e.cancel(t).catch((()=>{}))),n&&n.locked&&this.releaseLock()}))}read(t){return xn(this,void 0,void 0,(function*(){if(0===t)return{done:null==this.reader,value:new Uint8Array(0)};const e=yield this.reader.read();return!e.done&&(e.value=Qn(e)),e}))}}const si=(t,e)=>{const n=t=>i([e,t]);let i;return[e,n,new Promise((r=>(i=r)&&t.once(e,n)))]};var ai,oi,ci,li,ui,hi,pi,di,fi;!function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"}(ai||(ai={})),function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"}(oi||(oi={})),function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"}(ci||(ci={})),function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"}(li||(li={})),function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"}(ui||(ui={})),function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"}(hi||(hi={})),function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"}(pi||(pi={})),function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth"}(di||(di={})),function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"}(fi||(fi={}));const mi=void 0;function yi(t){if(null===t)return"null";if(t===mi)return"undefined";switch(typeof t){case"number":case"bigint":return`${t}`;case"string":return`"${t}"`}return"function"==typeof t[Symbol.toPrimitive]?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof Ln||t instanceof Dn?`[${[...t].map((t=>yi(t)))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,((t,e)=>"bigint"==typeof e?`${e}`:e))}const gi=Symbol.for("isArrowBigNum");function bi(t,...e){return 0===e.length?Object.setPrototypeOf(Gn(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}function vi(...t){return bi.apply(this,t)}function _i(...t){return bi.apply(this,t)}function xi(...t){return bi.apply(this,t)}function wi(t){const{buffer:e,byteOffset:n,length:i,signed:r}=t,s=new Dn(e,n,i),a=r&&s[s.length-1]&BigInt(1)<8===t.byteLength?new t.BigIntArray(t.buffer,t.byteOffset,1)[0]:Ai(t),Si=t=>8===t.byteLength?`${new t.BigIntArray(t.buffer,t.byteOffset,1)[0]}`:Ai(t)):(Si=Ai,Ii=Si);class Ti{static new(t,e){switch(e){case!0:return new vi(t);case!1:return new _i(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case Ln:return new vi(t)}return 16===t.byteLength?new xi(t):new _i(t)}static signed(t){return new vi(t)}static unsigned(t){return new _i(t)}static decimal(t){return new xi(t)}constructor(t,e){return Ti.new(t,e)}}var ki,Mi,Ei,Ci,Ni,Oi,Li,Bi,Di,Fi,Vi,Ui,Pi,Ri,ji,$i,zi,Hi,qi,Yi;class Wi{static isNull(t){return(null==t?void 0:t.typeId)===di.Null}static isInt(t){return(null==t?void 0:t.typeId)===di.Int}static isFloat(t){return(null==t?void 0:t.typeId)===di.Float}static isBinary(t){return(null==t?void 0:t.typeId)===di.Binary}static isUtf8(t){return(null==t?void 0:t.typeId)===di.Utf8}static isBool(t){return(null==t?void 0:t.typeId)===di.Bool}static isDecimal(t){return(null==t?void 0:t.typeId)===di.Decimal}static isDate(t){return(null==t?void 0:t.typeId)===di.Date}static isTime(t){return(null==t?void 0:t.typeId)===di.Time}static isTimestamp(t){return(null==t?void 0:t.typeId)===di.Timestamp}static isInterval(t){return(null==t?void 0:t.typeId)===di.Interval}static isList(t){return(null==t?void 0:t.typeId)===di.List}static isStruct(t){return(null==t?void 0:t.typeId)===di.Struct}static isUnion(t){return(null==t?void 0:t.typeId)===di.Union}static isFixedSizeBinary(t){return(null==t?void 0:t.typeId)===di.FixedSizeBinary}static isFixedSizeList(t){return(null==t?void 0:t.typeId)===di.FixedSizeList}static isMap(t){return(null==t?void 0:t.typeId)===di.Map}static isDictionary(t){return(null==t?void 0:t.typeId)===di.Dictionary}static isDenseUnion(t){return Wi.isUnion(t)&&t.mode===oi.Dense}static isSparseUnion(t){return Wi.isUnion(t)&&t.mode===oi.Sparse}get typeId(){return di.NONE}}ki=Symbol.toStringTag,Wi[ki]=((Yi=Wi.prototype).children=null,Yi.ArrayType=Array,Yi[Symbol.toStringTag]="DataType");let Gi=class extends Wi{toString(){return"Null"}get typeId(){return di.Null}};Mi=Symbol.toStringTag,Gi[Mi]=(t=>t[Symbol.toStringTag]="Null")(Gi.prototype);class Ki extends Wi{constructor(t,e){super(),this.isSigned=t,this.bitWidth=e}get typeId(){return di.Int}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?Ln:Dn}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Ei=Symbol.toStringTag,Ki[Ei]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Ki.prototype);class Qi extends Ki{constructor(){super(!0,8)}get ArrayType(){return Int8Array}}class Ji extends Ki{constructor(){super(!0,16)}get ArrayType(){return Int16Array}}class Zi extends Ki{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}class Xi extends Ki{constructor(){super(!0,64)}get ArrayType(){return Ln}}class tr extends Ki{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}}class er extends Ki{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}}class nr extends Ki{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}}class ir extends Ki{constructor(){super(!1,64)}get ArrayType(){return Dn}}Object.defineProperty(Qi.prototype,"ArrayType",{value:Int8Array}),Object.defineProperty(Ji.prototype,"ArrayType",{value:Int16Array}),Object.defineProperty(Zi.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(Xi.prototype,"ArrayType",{value:Ln}),Object.defineProperty(tr.prototype,"ArrayType",{value:Uint8Array}),Object.defineProperty(er.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(nr.prototype,"ArrayType",{value:Uint32Array}),Object.defineProperty(ir.prototype,"ArrayType",{value:Dn});class rr extends Wi{constructor(t){super(),this.precision=t}get typeId(){return di.Float}get ArrayType(){switch(this.precision){case ci.HALF:return Uint16Array;case ci.SINGLE:return Float32Array;case ci.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Ci=Symbol.toStringTag,rr[Ci]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(rr.prototype);class sr extends rr{constructor(){super(ci.HALF)}}class ar extends rr{constructor(){super(ci.SINGLE)}}class or extends rr{constructor(){super(ci.DOUBLE)}}Object.defineProperty(sr.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(ar.prototype,"ArrayType",{value:Float32Array}),Object.defineProperty(or.prototype,"ArrayType",{value:Float64Array});let cr=class extends Wi{constructor(){super()}get typeId(){return di.Binary}toString(){return"Binary"}};Ni=Symbol.toStringTag,cr[Ni]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(cr.prototype);let lr=class extends Wi{constructor(){super()}get typeId(){return di.Utf8}toString(){return"Utf8"}};Oi=Symbol.toStringTag,lr[Oi]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(lr.prototype);let ur=class extends Wi{constructor(){super()}get typeId(){return di.Bool}toString(){return"Bool"}};Li=Symbol.toStringTag,ur[Li]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(ur.prototype);let hr=class extends Wi{constructor(t,e,n=128){super(),this.scale=t,this.precision=e,this.bitWidth=n}get typeId(){return di.Decimal}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};Bi=Symbol.toStringTag,hr[Bi]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(hr.prototype);class pr extends Wi{constructor(t){super(),this.unit=t}get typeId(){return di.Date}toString(){return`Date${32*(this.unit+1)}<${li[this.unit]}>`}}Di=Symbol.toStringTag,pr[Di]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"))(pr.prototype);class dr extends pr{constructor(){super(li.DAY)}}class fr extends pr{constructor(){super(li.MILLISECOND)}}class mr extends Wi{constructor(t,e){super(),this.unit=t,this.bitWidth=e}get typeId(){return di.Time}toString(){return`Time${this.bitWidth}<${ui[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return Ln}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Fi=Symbol.toStringTag,mr[Fi]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(mr.prototype);class yr extends mr{constructor(){super(ui.SECOND,32)}}class gr extends mr{constructor(){super(ui.MILLISECOND,32)}}class br extends mr{constructor(){super(ui.MICROSECOND,64)}}class vr extends mr{constructor(){super(ui.NANOSECOND,64)}}class _r extends Wi{constructor(t,e){super(),this.unit=t,this.timezone=e}get typeId(){return di.Timestamp}toString(){return`Timestamp<${ui[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Vi=Symbol.toStringTag,_r[Vi]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"))(_r.prototype);class xr extends Wi{constructor(t){super(),this.unit=t}get typeId(){return di.Interval}toString(){return`Interval<${hi[this.unit]}>`}}Ui=Symbol.toStringTag,xr[Ui]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(xr.prototype);class wr extends xr{constructor(){super(hi.DAY_TIME)}}class Sr extends xr{constructor(){super(hi.YEAR_MONTH)}}let Ir=class extends Wi{constructor(t){super(),this.children=[t]}get typeId(){return di.List}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};Pi=Symbol.toStringTag,Ir[Pi]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(Ir.prototype);class Ar extends Wi{constructor(t){super(),this.children=t}get typeId(){return di.Struct}toString(){return`Struct<{${this.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}Ri=Symbol.toStringTag,Ar[Ri]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(Ar.prototype);class Tr extends Wi{constructor(t,e,n){super(),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce(((t,e,n)=>(t[e]=n)&&t||t),Object.create(null))}get typeId(){return di.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map((t=>`${t.type}`)).join(" | ")}>`}}ji=Symbol.toStringTag,Tr[ji]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(Tr.prototype);let kr=class extends Wi{constructor(t){super(),this.byteWidth=t}get typeId(){return di.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};$i=Symbol.toStringTag,kr[$i]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(kr.prototype);let Mr=class extends Wi{constructor(t,e){super(),this.listSize=t,this.children=[e]}get typeId(){return di.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};zi=Symbol.toStringTag,Mr[zi]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(Mr.prototype);class Er extends Wi{constructor(t,e=!1){super(),this.children=[t],this.keysSorted=e}get typeId(){return di.Map}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}Hi=Symbol.toStringTag,Er[Hi]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(Er.prototype);const Cr=(Nr=-1,()=>++Nr);var Nr;class Or extends Wi{constructor(t,e,n,i){super(),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=null==n?Cr():"number"==typeof n?n:n.low}get typeId(){return di.Dictionary}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}function Lr(t){const e=t;switch(t.typeId){case di.Decimal:return t.bitWidth/32;case di.Timestamp:return 2;case di.Date:case di.Interval:return 1+e.unit;case di.FixedSizeList:return e.listSize;case di.FixedSizeBinary:return e.byteWidth;default:return 1}}qi=Symbol.toStringTag,Or[qi]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(Or.prototype);class Br{visitMany(t,...e){return t.map(((t,n)=>this.visit(t,...e.map((t=>t[n])))))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return function(t,e,n=!0){if("number"==typeof e)return Dr(t,e,n);if("string"==typeof e&&e in di)return Dr(t,di[e],n);if(e&&e instanceof Wi)return Dr(t,Fr(e),n);if((null==e?void 0:e.type)&&e.type instanceof Wi)return Dr(t,Fr(e.type),n);return Dr(t,di.NONE,n)}(this,t,e)}getVisitFnByTypeId(t,e=!0){return Dr(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}}function Dr(t,e,n=!0){let i=null;switch(e){case di.Null:i=t.visitNull;break;case di.Bool:i=t.visitBool;break;case di.Int:i=t.visitInt;break;case di.Int8:i=t.visitInt8||t.visitInt;break;case di.Int16:i=t.visitInt16||t.visitInt;break;case di.Int32:i=t.visitInt32||t.visitInt;break;case di.Int64:i=t.visitInt64||t.visitInt;break;case di.Uint8:i=t.visitUint8||t.visitInt;break;case di.Uint16:i=t.visitUint16||t.visitInt;break;case di.Uint32:i=t.visitUint32||t.visitInt;break;case di.Uint64:i=t.visitUint64||t.visitInt;break;case di.Float:i=t.visitFloat;break;case di.Float16:i=t.visitFloat16||t.visitFloat;break;case di.Float32:i=t.visitFloat32||t.visitFloat;break;case di.Float64:i=t.visitFloat64||t.visitFloat;break;case di.Utf8:i=t.visitUtf8;break;case di.Binary:i=t.visitBinary;break;case di.FixedSizeBinary:i=t.visitFixedSizeBinary;break;case di.Date:i=t.visitDate;break;case di.DateDay:i=t.visitDateDay||t.visitDate;break;case di.DateMillisecond:i=t.visitDateMillisecond||t.visitDate;break;case di.Timestamp:i=t.visitTimestamp;break;case di.TimestampSecond:i=t.visitTimestampSecond||t.visitTimestamp;break;case di.TimestampMillisecond:i=t.visitTimestampMillisecond||t.visitTimestamp;break;case di.TimestampMicrosecond:i=t.visitTimestampMicrosecond||t.visitTimestamp;break;case di.TimestampNanosecond:i=t.visitTimestampNanosecond||t.visitTimestamp;break;case di.Time:i=t.visitTime;break;case di.TimeSecond:i=t.visitTimeSecond||t.visitTime;break;case di.TimeMillisecond:i=t.visitTimeMillisecond||t.visitTime;break;case di.TimeMicrosecond:i=t.visitTimeMicrosecond||t.visitTime;break;case di.TimeNanosecond:i=t.visitTimeNanosecond||t.visitTime;break;case di.Decimal:i=t.visitDecimal;break;case di.List:i=t.visitList;break;case di.Struct:i=t.visitStruct;break;case di.Union:i=t.visitUnion;break;case di.DenseUnion:i=t.visitDenseUnion||t.visitUnion;break;case di.SparseUnion:i=t.visitSparseUnion||t.visitUnion;break;case di.Dictionary:i=t.visitDictionary;break;case di.Interval:i=t.visitInterval;break;case di.IntervalDayTime:i=t.visitIntervalDayTime||t.visitInterval;break;case di.IntervalYearMonth:i=t.visitIntervalYearMonth||t.visitInterval;break;case di.FixedSizeList:i=t.visitFixedSizeList;break;case di.Map:i=t.visitMap}if("function"==typeof i)return i;if(!n)return()=>null;throw new Error(`Unrecognized type '${di[e]}'`)}function Fr(t){switch(t.typeId){case di.Null:return di.Null;case di.Int:{const{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?di.Int8:di.Uint8;case 16:return n?di.Int16:di.Uint16;case 32:return n?di.Int32:di.Uint32;case 64:return n?di.Int64:di.Uint64}return di.Int}case di.Float:switch(t.precision){case ci.HALF:return di.Float16;case ci.SINGLE:return di.Float32;case ci.DOUBLE:return di.Float64}return di.Float;case di.Binary:return di.Binary;case di.Utf8:return di.Utf8;case di.Bool:return di.Bool;case di.Decimal:return di.Decimal;case di.Time:switch(t.unit){case ui.SECOND:return di.TimeSecond;case ui.MILLISECOND:return di.TimeMillisecond;case ui.MICROSECOND:return di.TimeMicrosecond;case ui.NANOSECOND:return di.TimeNanosecond}return di.Time;case di.Timestamp:switch(t.unit){case ui.SECOND:return di.TimestampSecond;case ui.MILLISECOND:return di.TimestampMillisecond;case ui.MICROSECOND:return di.TimestampMicrosecond;case ui.NANOSECOND:return di.TimestampNanosecond}return di.Timestamp;case di.Date:switch(t.unit){case li.DAY:return di.DateDay;case li.MILLISECOND:return di.DateMillisecond}return di.Date;case di.Interval:switch(t.unit){case hi.DAY_TIME:return di.IntervalDayTime;case hi.YEAR_MONTH:return di.IntervalYearMonth}return di.Interval;case di.Map:return di.Map;case di.List:return di.List;case di.Struct:return di.Struct;case di.Union:switch(t.mode){case oi.Dense:return di.DenseUnion;case oi.Sparse:return di.SparseUnion}return di.Union;case di.FixedSizeBinary:return di.FixedSizeBinary;case di.FixedSizeList:return di.FixedSizeList;case di.Dictionary:return di.Dictionary}throw new Error(`Unrecognized type '${di[t.typeId]}'`)}Br.prototype.visitInt8=null,Br.prototype.visitInt16=null,Br.prototype.visitInt32=null,Br.prototype.visitInt64=null,Br.prototype.visitUint8=null,Br.prototype.visitUint16=null,Br.prototype.visitUint32=null,Br.prototype.visitUint64=null,Br.prototype.visitFloat16=null,Br.prototype.visitFloat32=null,Br.prototype.visitFloat64=null,Br.prototype.visitDateDay=null,Br.prototype.visitDateMillisecond=null,Br.prototype.visitTimestampSecond=null,Br.prototype.visitTimestampMillisecond=null,Br.prototype.visitTimestampMicrosecond=null,Br.prototype.visitTimestampNanosecond=null,Br.prototype.visitTimeSecond=null,Br.prototype.visitTimeMillisecond=null,Br.prototype.visitTimeMicrosecond=null,Br.prototype.visitTimeNanosecond=null,Br.prototype.visitDenseUnion=null,Br.prototype.visitSparseUnion=null,Br.prototype.visitIntervalDayTime=null,Br.prototype.visitIntervalYearMonth=null;const Vr=new Float64Array(1),Ur=new Uint32Array(Vr.buffer);function Pr(t){const e=(31744&t)>>10,n=(1023&t)/1024,i=Math.pow(-1,(32768&t)>>15);switch(e){case 31:return i*(n?Number.NaN:1/0);case 0:return i*(n?6103515625e-14*n:0)}return i*Math.pow(2,e-15)*(1+n)}function Rr(t){if(t!=t)return 32256;Vr[0]=t;const e=(2147483648&Ur[1])>>16&65535;let n=2146435072&Ur[1],i=0;return n>=1089470464?Ur[0]>0?n=31744:(n=(2080374784&n)>>16,i=(1048575&Ur[1])>>10):n<=1056964608?(i=1048576+(1048575&Ur[1]),i=1048576+(i<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,i=512+(1048575&Ur[1])>>10),e|n|65535&i}class jr extends Br{}function $r(t){return(e,n,i)=>{if(e.setValid(n,null!=i))return t(e,n,i)}}const zr=(t,e,n)=>{t[e]=Math.trunc(n%4294967296),t[e+1]=Math.trunc(n/4294967296)},Hr=(t,e,n,i)=>{if(n+1{t[e]=n},Yr=({values:t},e,n)=>{t[e]=n},Wr=({values:t},e,n)=>{t[e]=Rr(n)},Gr=({values:t},e,n)=>{((t,e,n)=>{t[e]=Math.trunc(n/864e5)})(t,e,n.valueOf())},Kr=({values:t},e,n)=>{zr(t,2*e,n.valueOf())},Qr=({stride:t,values:e},n,i)=>{e.set(i.subarray(0,t),t*n)},Jr=(t,e,n)=>{t.type.unit===li.DAY?Gr(t,e,n):Kr(t,e,n)},Zr=({values:t},e,n)=>zr(t,2*e,n/1e3),Xr=({values:t},e,n)=>zr(t,2*e,n),ts=({values:t},e,n)=>((t,e,n)=>{t[e]=Math.trunc(1e3*n%4294967296),t[e+1]=Math.trunc(1e3*n/4294967296)})(t,2*e,n),es=({values:t},e,n)=>((t,e,n)=>{t[e]=Math.trunc(1e6*n%4294967296),t[e+1]=Math.trunc(1e6*n/4294967296)})(t,2*e,n),ns=(t,e,n)=>{switch(t.type.unit){case ui.SECOND:return Zr(t,e,n);case ui.MILLISECOND:return Xr(t,e,n);case ui.MICROSECOND:return ts(t,e,n);case ui.NANOSECOND:return es(t,e,n)}},is=({values:t},e,n)=>{t[e]=n},rs=({values:t},e,n)=>{t[e]=n},ss=({values:t},e,n)=>{t[e]=n},as=({values:t},e,n)=>{t[e]=n},os=(t,e,n)=>{switch(t.type.unit){case ui.SECOND:return is(t,e,n);case ui.MILLISECOND:return rs(t,e,n);case ui.MICROSECOND:return ss(t,e,n);case ui.NANOSECOND:return as(t,e,n)}},cs=({values:t,stride:e},n,i)=>{t.set(i.subarray(0,e),e*n)},ls=(t,e,n)=>{const i=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[i];fs.visit(r,t.valueOffsets[e],n)},us=(t,e,n)=>{const i=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[i];fs.visit(r,e,n)},hs=(t,e,n)=>{t.type.unit===hi.DAY_TIME?ps(t,e,n):ds(t,e,n)},ps=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},ds=({values:t},e,n)=>{t[e]=12*n[0]+n[1]%12};jr.prototype.visitBool=$r((({offset:t,values:e},n,i)=>{const r=t+n;i?e[r>>3]|=1<>3]&=~(1<{switch(t.type.precision){case ci.HALF:return Wr(t,e,n);case ci.SINGLE:case ci.DOUBLE:return Yr(t,e,n)}})),jr.prototype.visitFloat16=$r(Wr),jr.prototype.visitFloat32=$r(Yr),jr.prototype.visitFloat64=$r(Yr),jr.prototype.visitUtf8=$r((({values:t,valueOffsets:e},n,i)=>{Hr(t,e,n,Cn(i))})),jr.prototype.visitBinary=$r((({values:t,valueOffsets:e},n,i)=>Hr(t,e,n,i))),jr.prototype.visitFixedSizeBinary=$r(Qr),jr.prototype.visitDate=$r(Jr),jr.prototype.visitDateDay=$r(Gr),jr.prototype.visitDateMillisecond=$r(Kr),jr.prototype.visitTimestamp=$r(ns),jr.prototype.visitTimestampSecond=$r(Zr),jr.prototype.visitTimestampMillisecond=$r(Xr),jr.prototype.visitTimestampMicrosecond=$r(ts),jr.prototype.visitTimestampNanosecond=$r(es),jr.prototype.visitTime=$r(os),jr.prototype.visitTimeSecond=$r(is),jr.prototype.visitTimeMillisecond=$r(rs),jr.prototype.visitTimeMicrosecond=$r(ss),jr.prototype.visitTimeNanosecond=$r(as),jr.prototype.visitDecimal=$r(cs),jr.prototype.visitList=$r(((t,e,n)=>{const i=t.children[0],r=t.valueOffsets,s=fs.getVisitFn(i);if(Array.isArray(n))for(let t=-1,a=r[e],o=r[e+1];a{const i=t.type.children.map((t=>fs.getVisitFn(t.type))),r=n instanceof Map?(s=e,a=n,(t,e,n,i)=>e&&t(e,s,a.get(n.name))):n instanceof Ba?((t,e)=>(n,i,r,s)=>i&&n(i,t,e.get(s)))(e,n):Array.isArray(n)?((t,e)=>(n,i,r,s)=>i&&n(i,t,e[s]))(e,n):((t,e)=>(n,i,r,s)=>i&&n(i,t,e[r.name]))(e,n);var s,a;t.type.children.forEach(((e,n)=>r(i[n],t.children[n],e,n)))})),jr.prototype.visitUnion=$r(((t,e,n)=>{t.type.mode===oi.Dense?ls(t,e,n):us(t,e,n)})),jr.prototype.visitDenseUnion=$r(ls),jr.prototype.visitSparseUnion=$r(us),jr.prototype.visitDictionary=$r(((t,e,n)=>{var i;null===(i=t.dictionary)||void 0===i||i.set(t.values[e],n)})),jr.prototype.visitInterval=$r(hs),jr.prototype.visitIntervalDayTime=$r(ps),jr.prototype.visitIntervalYearMonth=$r(ds),jr.prototype.visitFixedSizeList=$r(((t,e,n)=>{const{stride:i}=t,r=t.children[0],s=fs.getVisitFn(r);if(Array.isArray(n))for(let t=-1,a=e*i;++t{const i=t.children[0],{valueOffsets:r}=t,s=fs.getVisitFn(i);let{[e]:a,[e+1]:o}=r;const c=n instanceof Map?n.entries():Object.entries(n);for(const t of c)if(s(i,a,t),++a>=o)break}));const fs=new jr,ms=Symbol.for("parent"),ys=Symbol.for("rowIndex");class gs{constructor(t,e){return this[ms]=t,this[ys]=e,new Proxy(this,new vs)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[ys],e=this[ms],n=e.type.children,i={};for(let r=-1,s=n.length;++r`${yi(t)}: ${yi(e)}`)).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new bs(this[ms],this[ys])}}class bs{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return tt.name))}has(t,e){return-1!==t[ms].type.children.findIndex((t=>t.name===e))}getOwnPropertyDescriptor(t,e){if(-1!==t[ms].type.children.findIndex((t=>t.name===e)))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[ms].type.children.findIndex((t=>t.name===e));if(-1!==n){const i=js.visit(t[ms].children[n],t[ys]);return Reflect.set(t,e,i),i}}set(t,e,n){const i=t[ms].type.children.findIndex((t=>t.name===e));return-1!==i?(fs.visit(t[ms].children[i],t[ys],n),Reflect.set(t,e,n)):!(!Reflect.has(t,e)&&"symbol"!=typeof e)&&Reflect.set(t,e,n)}}class _s extends Br{}function xs(t){return(e,n)=>e.getValid(n)?t(e,n):null}const ws=(t,e)=>4294967296*t[e+1]+(t[e]>>>0),Ss=t=>new Date(t),Is=(t,e,n)=>{if(n+1>=e.length)return null;const i=e[n],r=e[n+1];return t.subarray(i,r)},As=({values:t},e)=>((t,e)=>Ss(((t,e)=>864e5*t[e])(t,e)))(t,e),Ts=({values:t},e)=>((t,e)=>Ss(ws(t,e)))(t,2*e),ks=({stride:t,values:e},n)=>e[t*n],Ms=({values:t},e)=>t[e],Es=({values:t},e)=>1e3*ws(t,2*e),Cs=({values:t},e)=>ws(t,2*e),Ns=({values:t},e)=>((t,e)=>t[e+1]/1e3*4294967296+(t[e]>>>0)/1e3)(t,2*e),Os=({values:t},e)=>((t,e)=>t[e+1]/1e6*4294967296+(t[e]>>>0)/1e6)(t,2*e),Ls=({values:t},e)=>t[e],Bs=({values:t},e)=>t[e],Ds=({values:t},e)=>t[e],Fs=({values:t},e)=>t[e],Vs=(t,e)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[n];return js.visit(i,t.valueOffsets[e])},Us=(t,e)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[n];return js.visit(i,e)},Ps=({values:t},e)=>t.subarray(2*e,2*(e+1)),Rs=({values:t},e)=>{const n=t[e],i=new Int32Array(2);return i[0]=Math.trunc(n/12),i[1]=Math.trunc(n%12),i};_s.prototype.visitNull=xs(((t,e)=>null)),_s.prototype.visitBool=xs((({offset:t,values:e},n)=>{const i=t+n;return 0!=(e[i>>3]&1<t[e])),_s.prototype.visitInt8=xs(ks),_s.prototype.visitInt16=xs(ks),_s.prototype.visitInt32=xs(ks),_s.prototype.visitInt64=xs(Ms),_s.prototype.visitUint8=xs(ks),_s.prototype.visitUint16=xs(ks),_s.prototype.visitUint32=xs(ks),_s.prototype.visitUint64=xs(Ms),_s.prototype.visitFloat=xs((({type:t,values:e},n)=>t.precision!==ci.HALF?e[n]:Pr(e[n]))),_s.prototype.visitFloat16=xs((({stride:t,values:e},n)=>Pr(e[t*n]))),_s.prototype.visitFloat32=xs(ks),_s.prototype.visitFloat64=xs(ks),_s.prototype.visitUtf8=xs((({values:t,valueOffsets:e},n)=>{const i=Is(t,e,n);return null!==i?Mn(i):null})),_s.prototype.visitBinary=xs((({values:t,valueOffsets:e},n)=>Is(t,e,n))),_s.prototype.visitFixedSizeBinary=xs((({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)))),_s.prototype.visitDate=xs(((t,e)=>t.type.unit===li.DAY?As(t,e):Ts(t,e))),_s.prototype.visitDateDay=xs(As),_s.prototype.visitDateMillisecond=xs(Ts),_s.prototype.visitTimestamp=xs(((t,e)=>{switch(t.type.unit){case ui.SECOND:return Es(t,e);case ui.MILLISECOND:return Cs(t,e);case ui.MICROSECOND:return Ns(t,e);case ui.NANOSECOND:return Os(t,e)}})),_s.prototype.visitTimestampSecond=xs(Es),_s.prototype.visitTimestampMillisecond=xs(Cs),_s.prototype.visitTimestampMicrosecond=xs(Ns),_s.prototype.visitTimestampNanosecond=xs(Os),_s.prototype.visitTime=xs(((t,e)=>{switch(t.type.unit){case ui.SECOND:return Ls(t,e);case ui.MILLISECOND:return Bs(t,e);case ui.MICROSECOND:return Ds(t,e);case ui.NANOSECOND:return Fs(t,e)}})),_s.prototype.visitTimeSecond=xs(Ls),_s.prototype.visitTimeMillisecond=xs(Bs),_s.prototype.visitTimeMicrosecond=xs(Ds),_s.prototype.visitTimeNanosecond=xs(Fs),_s.prototype.visitDecimal=xs((({values:t,stride:e},n)=>Ti.decimal(t.subarray(e*n,e*(n+1))))),_s.prototype.visitList=xs(((t,e)=>{const{valueOffsets:n,stride:i,children:r}=t,{[e*i]:s,[e*i+1]:a}=n,o=r[0].slice(s,a-s);return new Ba([o])})),_s.prototype.visitStruct=xs(((t,e)=>new gs(t,e))),_s.prototype.visitUnion=xs(((t,e)=>t.type.mode===oi.Dense?Vs(t,e):Us(t,e))),_s.prototype.visitDenseUnion=xs(Vs),_s.prototype.visitSparseUnion=xs(Us),_s.prototype.visitDictionary=xs(((t,e)=>{var n;return null===(n=t.dictionary)||void 0===n?void 0:n.get(t.values[e])})),_s.prototype.visitInterval=xs(((t,e)=>t.type.unit===hi.DAY_TIME?Ps(t,e):Rs(t,e))),_s.prototype.visitIntervalDayTime=xs(Ps),_s.prototype.visitIntervalYearMonth=xs(Rs),_s.prototype.visitFixedSizeList=xs(((t,e)=>{const{stride:n,children:i}=t,r=i[0].slice(e*n,n);return new Ba([r])})),_s.prototype.visitMap=xs(((t,e)=>{const{valueOffsets:n,children:i}=t,{[e]:r,[e+1]:s}=n,a=i[0];return new Hs(a.slice(r,s-r))}));const js=new _s,$s=Symbol.for("keys"),zs=Symbol.for("vals");class Hs{constructor(t){return this[$s]=new Ba([t.children[0]]).memoize(),this[zs]=t.children[1],new Proxy(this,new Ys)}[Symbol.iterator](){return new qs(this[$s],this[zs])}get size(){return this[$s].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[$s],e=this[zs],n={};for(let i=-1,r=t.length;++i`${yi(t)}: ${yi(e)}`)).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class qs{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),js.visit(this.vals,t)]})}}class Ys{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[$s].toArray().map(String)}has(t,e){return t[$s].includes(e)}getOwnPropertyDescriptor(t,e){if(-1!==t[$s].indexOf(e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[$s].indexOf(e);if(-1!==n){const i=js.visit(Reflect.get(t,zs),n);return Reflect.set(t,e,i),i}}set(t,e,n){const i=t[$s].indexOf(e);return-1!==i?(fs.visit(Reflect.get(t,zs),i,n),Reflect.set(t,e,n)):!!Reflect.has(t,e)&&Reflect.set(t,e,n)}}let Ws;function Gs(t,e,n,i){const{length:r=0}=t;let s="number"!=typeof e?0:e,a="number"!=typeof n?r:n;return s<0&&(s=(s%r+r)%r),a<0&&(a=(a%r+r)%r),ar&&(a=r),i?i(t,s,a):[s,a]}Object.defineProperties(Hs.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[$s]:{writable:!0,enumerable:!1,configurable:!1,value:null},[zs]:{writable:!0,enumerable:!1,configurable:!1,value:null}});const Ks=t=>t!=t;function Qs(t){if("object"!==typeof t||null===t)return Ks(t)?Ks:e=>e===t;if(t instanceof Date){const e=t.valueOf();return t=>t instanceof Date&&t.valueOf()===e}return ArrayBuffer.isView(t)?e=>!!e&&function(t,e){let n=0;const i=t.length;if(i!==e.length)return!1;if(i>0)do{if(t[n]!==e[n])return!1}while(++n!1;const i=[];for(let e=-1,r=n.length;++e{if(!n||"object"!=typeof n)return!1;switch(n.constructor){case Array:return function(t,e){const n=t.length;if(e.length!==n)return!1;for(let i=-1;++i>i}function ea(t,e,n){const i=n.byteLength+7&-8;if(t>0||n.byteLength>3):na(new ia(n,t,e,null,Xs)).subarray(0,i)),r}return n}function na(t){const e=[];let n=0,i=0,r=0;for(const s of t)s&&(r|=1<0)&&(e[n++]=r);const s=new Uint8Array(e.length+7&-8);return s.set(e),s}class ia{constructor(t,e,n,i,r){this.bytes=t,this.length=n,this.context=i,this.get=r,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,r=e+(e%8==0?0:8-e%8);return ra(t,e,r)+ra(t,i,n)+function(t,e,n){let i=0,r=Math.trunc(e);const s=new DataView(t.buffer,t.byteOffset,t.byteLength),a=void 0===n?t.byteLength:r+n;for(;a-r>=4;)i+=sa(s.getUint32(r)),r+=4;for(;a-r>=2;)i+=sa(s.getUint16(r)),r+=2;for(;a-r>=1;)i+=sa(s.getUint8(r)),r+=1;return i}(t,r>>3,i-r>>3)}function sa(t){let e=Math.trunc(t);return e-=e>>>1&1431655765,e=(858993459&e)+(e>>>2&858993459),16843009*(e+(e>>>4)&252645135)>>>24}class aa{constructor(t,e,n,i,r,s=[],a){let o;this.type=t,this.children=s,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1)),r instanceof aa?(this.stride=r.stride,this.values=r.values,this.typeIds=r.typeIds,this.nullBitmap=r.nullBitmap,this.valueOffsets=r.valueOffsets):(this.stride=Lr(t),r&&((o=r[0])&&(this.valueOffsets=o),(o=r[1])&&(this.values=o),(o=r[2])&&(this.nullBitmap=o),(o=r[3])&&(this.typeIds=o))),this.nullable=0!==this._nullCount&&this.nullBitmap&&this.nullBitmap.byteLength>0}get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get byteLength(){let t=0;const{valueOffsets:e,values:n,nullBitmap:i,typeIds:r}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),r&&(t+=r.byteLength),this.children.reduce(((t,e)=>t+e.byteLength),t)}get nullCount(){let t,e=this._nullCount;return e<=-1&&(t=this.nullBitmap)&&(this._nullCount=e=this.length-ra(t,this.offset,this.offset+this.length)),e}getValid(t){if(this.nullable&&this.nullCount>0){const e=this.offset+t;return 0!=(this.nullBitmap[e>>3]&1<>3){const{nullBitmap:t}=this._changeLengthAndBackfillNullBitmap(this.length);Object.assign(this,{nullBitmap:t,_nullCount:0})}const{nullBitmap:n,offset:i}=this,r=i+t>>3,s=(i+t)%8,a=n[r]>>s&1;return e?0===a&&(n[r]|=1<>3).fill(255,0,e>>3);i[e>>3]=(1<0&&i.set(ea(this.offset,e,this.nullBitmap),0);const r=this.buffers;return r[fi.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),r)}_sliceBuffers(t,e,n,i){let r;const{buffers:s}=this;return(r=s[fi.TYPE])&&(s[fi.TYPE]=r.subarray(t,t+e)),(r=s[fi.OFFSET])&&(s[fi.OFFSET]=r.subarray(t,t+e+1))||(r=s[fi.DATA])&&(s[fi.DATA]=6===i?r:r.subarray(n*t,n*(t+e))),s}_sliceChildren(t,e,n){return t.map((t=>t.slice(e,n)))}}aa.prototype.children=Object.freeze([]);class oa extends Br{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{type:e,offset:n=0,length:i=0}=t;return new aa(e,n,i,0)}visitBool(t){const{type:e,offset:n=0}=t,i=Qn(t.nullBitmap),r=Gn(e.ArrayType,t.data),{length:s=r.length>>3,nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,r,i])}visitInt(t){const{type:e,offset:n=0}=t,i=Qn(t.nullBitmap),r=Gn(e.ArrayType,t.data),{length:s=r.length,nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,r,i])}visitFloat(t){const{type:e,offset:n=0}=t,i=Qn(t.nullBitmap),r=Gn(e.ArrayType,t.data),{length:s=r.length,nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,r,i])}visitUtf8(t){const{type:e,offset:n=0}=t,i=Qn(t.data),r=Qn(t.nullBitmap),s=Kn(t.valueOffsets),{length:a=s.length-1,nullCount:o=(t.nullBitmap?-1:0)}=t;return new aa(e,n,a,o,[s,i,r])}visitBinary(t){const{type:e,offset:n=0}=t,i=Qn(t.data),r=Qn(t.nullBitmap),s=Kn(t.valueOffsets),{length:a=s.length-1,nullCount:o=(t.nullBitmap?-1:0)}=t;return new aa(e,n,a,o,[s,i,r])}visitFixedSizeBinary(t){const{type:e,offset:n=0}=t,i=Qn(t.nullBitmap),r=Gn(e.ArrayType,t.data),{length:s=r.length/Lr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,r,i])}visitDate(t){const{type:e,offset:n=0}=t,i=Qn(t.nullBitmap),r=Gn(e.ArrayType,t.data),{length:s=r.length/Lr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,r,i])}visitTimestamp(t){const{type:e,offset:n=0}=t,i=Qn(t.nullBitmap),r=Gn(e.ArrayType,t.data),{length:s=r.length/Lr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,r,i])}visitTime(t){const{type:e,offset:n=0}=t,i=Qn(t.nullBitmap),r=Gn(e.ArrayType,t.data),{length:s=r.length/Lr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,r,i])}visitDecimal(t){const{type:e,offset:n=0}=t,i=Qn(t.nullBitmap),r=Gn(e.ArrayType,t.data),{length:s=r.length/Lr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,r,i])}visitList(t){const{type:e,offset:n=0,child:i}=t,r=Qn(t.nullBitmap),s=Kn(t.valueOffsets),{length:a=s.length-1,nullCount:o=(t.nullBitmap?-1:0)}=t;return new aa(e,n,a,o,[s,void 0,r],[i])}visitStruct(t){const{type:e,offset:n=0,children:i=[]}=t,r=Qn(t.nullBitmap),{length:s=i.reduce(((t,{length:e})=>Math.max(t,e)),0),nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,void 0,r],i)}visitUnion(t){const{type:e,offset:n=0,children:i=[]}=t,r=Qn(t.nullBitmap),s=Gn(e.ArrayType,t.typeIds),{length:a=s.length,nullCount:o=(t.nullBitmap?-1:0)}=t;if(Wi.isSparseUnion(e))return new aa(e,n,a,o,[void 0,void 0,r,s],i);const c=Kn(t.valueOffsets);return new aa(e,n,a,o,[c,void 0,r,s],i)}visitDictionary(t){const{type:e,offset:n=0}=t,i=Qn(t.nullBitmap),r=Gn(e.indices.ArrayType,t.data),{dictionary:s=new Ba([(new oa).visit({type:e.dictionary})])}=t,{length:a=r.length,nullCount:o=(t.nullBitmap?-1:0)}=t;return new aa(e,n,a,o,[void 0,r,i],[],s)}visitInterval(t){const{type:e,offset:n=0}=t,i=Qn(t.nullBitmap),r=Gn(e.ArrayType,t.data),{length:s=r.length/Lr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,r,i])}visitFixedSizeList(t){const{type:e,offset:n=0,child:i=(new oa).visit({type:e.valueType})}=t,r=Qn(t.nullBitmap),{length:s=i.length/Lr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new aa(e,n,s,a,[void 0,void 0,r],[i])}visitMap(t){const{type:e,offset:n=0,child:i=(new oa).visit({type:e.childType})}=t,r=Qn(t.nullBitmap),s=Kn(t.valueOffsets),{length:a=s.length-1,nullCount:o=(t.nullBitmap?-1:0)}=t;return new aa(e,n,a,o,[s,void 0,r],[i])}}function ca(t){return(new oa).visit(t)}class la{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext+e.nullCount),0)}function ha(t){return t.reduce(((t,e,n)=>(t[n+1]=t[n]+e.length,t)),new Uint32Array(t.length+1))}function pa(t,e,n,i){const r=[];for(let s=-1,a=t.length;++s=i)break;if(n>=o+c)continue;if(o>=n&&o+c<=i){r.push(a);continue}const l=Math.max(0,n-o),u=Math.min(i-o,c);r.push(a.slice(l,u-l))}return 0===r.length&&r.push(t[0].slice(0,0)),r}function da(t,e,n,i){let r=0,s=0,a=e.length-1;do{if(r>=a-1)return n0?0:-1},ba.prototype.visitBool=va,ba.prototype.visitInt=va,ba.prototype.visitInt8=va,ba.prototype.visitInt16=va,ba.prototype.visitInt32=va,ba.prototype.visitInt64=va,ba.prototype.visitUint8=va,ba.prototype.visitUint16=va,ba.prototype.visitUint32=va,ba.prototype.visitUint64=va,ba.prototype.visitFloat=va,ba.prototype.visitFloat16=va,ba.prototype.visitFloat32=va,ba.prototype.visitFloat64=va,ba.prototype.visitUtf8=va,ba.prototype.visitBinary=va,ba.prototype.visitFixedSizeBinary=va,ba.prototype.visitDate=va,ba.prototype.visitDateDay=va,ba.prototype.visitDateMillisecond=va,ba.prototype.visitTimestamp=va,ba.prototype.visitTimestampSecond=va,ba.prototype.visitTimestampMillisecond=va,ba.prototype.visitTimestampMicrosecond=va,ba.prototype.visitTimestampNanosecond=va,ba.prototype.visitTime=va,ba.prototype.visitTimeSecond=va,ba.prototype.visitTimeMillisecond=va,ba.prototype.visitTimeMicrosecond=va,ba.prototype.visitTimeNanosecond=va,ba.prototype.visitDecimal=va,ba.prototype.visitList=va,ba.prototype.visitStruct=va,ba.prototype.visitUnion=va,ba.prototype.visitDenseUnion=_a,ba.prototype.visitSparseUnion=_a,ba.prototype.visitDictionary=va,ba.prototype.visitInterval=va,ba.prototype.visitIntervalDayTime=va,ba.prototype.visitIntervalYearMonth=va,ba.prototype.visitFixedSizeList=va,ba.prototype.visitMap=va;const xa=new ba;class wa extends Br{}function Sa(t){const{type:e}=t;if(0===t.nullCount&&1===t.stride&&(e.typeId===di.Timestamp||e instanceof Ki&&64!==e.bitWidth||e instanceof mr&&64!==e.bitWidth||e instanceof rr&&e.precision!==ci.HALF))return new la(t.data.length,(e=>{const n=t.data[e];return n.values.subarray(0,n.length)[Symbol.iterator]()}));let n=0;return new la(t.data.length,(e=>{const i=t.data[e].length,r=t.slice(n,n+i);return n+=i,new Ia(r)}))}class Ia{constructor(t){this.vector=t,this.index=0}next(){return this.indext+e;class ka extends Br{visitNull(t,e){return 0}visitInt(t,e){return t.type.bitWidth/8}visitFloat(t,e){return t.type.ArrayType.BYTES_PER_ELEMENT}visitBool(t,e){return 1/8}visitDecimal(t,e){return t.type.bitWidth/8}visitDate(t,e){return 4*(t.type.unit+1)}visitTime(t,e){return t.type.bitWidth/8}visitTimestamp(t,e){return t.type.unit===ui.SECOND?4:8}visitInterval(t,e){return 4*(t.type.unit+1)}visitStruct(t,e){return t.children.reduce(((t,n)=>t+Ca.visit(n,e)),0)}visitFixedSizeBinary(t,e){return t.type.byteWidth}visitMap(t,e){return 8+t.children.reduce(((t,n)=>t+Ca.visit(n,e)),0)}visitDictionary(t,e){var n;return t.type.indices.bitWidth/8+((null===(n=t.dictionary)||void 0===n?void 0:n.getByteLength(t.values[e]))||0)}}const Ma=({type:t,children:e,typeIds:n,valueOffsets:i},r)=>{const s=t.typeIdToChildIndex[n[r]];return 8+Ca.visit(e[s],i[r])},Ea=({children:t},e)=>4+Ca.visitMany(t,t.map((()=>e))).reduce(Ta,0);ka.prototype.visitUtf8=({valueOffsets:t},e)=>t[e+1]-t[e]+8,ka.prototype.visitBinary=({valueOffsets:t},e)=>t[e+1]-t[e]+8,ka.prototype.visitList=({valueOffsets:t,stride:e,children:n},i)=>{const r=n[0],{[i*e]:s}=t,{[i*e+1]:a}=t,o=Ca.getVisitFn(r.type),c=r.slice(s,a-s);let l=8;for(let t=-1,e=a-s;++t{const i=e[0],r=i.slice(n*t,t),s=Ca.getVisitFn(i.type);let a=0;for(let t=-1,e=r.length;++tt.type.mode===oi.Dense?Ma(t,e):Ea(t,e),ka.prototype.visitDenseUnion=Ma,ka.prototype.visitSparseUnion=Ea;const Ca=new ka;var Na;const Oa={},La={};class Ba{constructor(t){var e,n,i;const r=t[0]instanceof Ba?t.flatMap((t=>t.data)):t;if(0===r.length||r.some((t=>!(t instanceof aa))))throw new TypeError("Vector constructor expects an Array of Data instances.");const s=null===(e=r[0])||void 0===e?void 0:e.type;switch(r.length){case 0:this._offsets=[0];break;case 1:{const{get:t,set:e,indexOf:n,byteLength:i}=Oa[s.typeId],a=r[0];this.isValid=t=>fa(a,t),this.get=e=>t(a,e),this.set=(t,n)=>e(a,t,n),this.indexOf=t=>n(a,t),this.getByteLength=t=>i(a,t),this._offsets=[0,a.length];break}default:Object.setPrototypeOf(this,La[s.typeId]),this._offsets=ha(r)}this.data=r,this.type=s,this.stride=Lr(s),this.numChildren=null!==(i=null===(n=s.children)||void 0===n?void 0:n.length)&&void 0!==i?i:0,this.length=this._offsets[this._offsets.length-1]}get byteLength(){return-1===this._byteLength&&(this._byteLength=this.data.reduce(((t,e)=>t+e.byteLength),0)),this._byteLength}get nullCount(){return-1===this._nullCount&&(this._nullCount=ua(this.data)),this._nullCount}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${di[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>0}getByteLength(t){return 0}[Symbol.iterator](){return Aa.visit(this)}concat(...t){return new Ba(this.data.concat(t.flatMap((t=>t.data)).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new Ba(Gs(this,t,e,(({data:t,_offsets:e},n,i)=>pa(t,e,n,i))))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:n,stride:i,ArrayType:r}=this;switch(t.typeId){case di.Int:case di.Float:case di.Decimal:case di.Time:case di.Timestamp:switch(e.length){case 0:return new r;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce(((t,{values:e,length:n})=>(t.array.set(e.subarray(0,n*i),t.offset),t.offset+=n*i,t)),{array:new r(n*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt(null===(e=this.type.children)||void 0===e?void 0:e.findIndex((e=>e.name===t)))}getChildAt(t){return t>-1&&te[t]))):null}get isMemoized(){return!!Wi.isDictionary(this.type)&&this.data[0].dictionary.isMemoized}memoize(){if(Wi.isDictionary(this.type)){const t=new Da(this.data[0].dictionary),e=this.data.map((e=>{const n=e.clone();return n.dictionary=t,n}));return new Ba(e)}return new Da(this)}unmemoize(){if(Wi.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map((e=>{const n=e.clone();return n.dictionary=t,n}));return new Ba(e)}return this}}Na=Symbol.toStringTag,Ba[Na]=(t=>{t.type=Wi.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._nullCount=-1,t._byteLength=-1,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;const e=Object.keys(di).map((t=>di[t])).filter((t=>"number"==typeof t&&t!==di.NONE));for(const n of e){const e=js.getVisitFnByTypeId(n),i=fs.getVisitFnByTypeId(n),r=xa.getVisitFnByTypeId(n),s=Ca.getVisitFnByTypeId(n);Oa[n]={get:e,set:i,indexOf:r,byteLength:s},La[n]=Object.create(t,{isValid:{value:ma(fa)},get:{value:ma(js.getVisitFnByTypeId(n))},set:{value:ya(fs.getVisitFnByTypeId(n))},indexOf:{value:ga(xa.getVisitFnByTypeId(n))},getByteLength:{value:ma(Ca.getVisitFnByTypeId(n))}})}return"Vector"})(Ba.prototype);class Da extends Ba{constructor(t){super(t.data);const e=this.get,n=this.set,i=this.slice,r=new Array(this.length);Object.defineProperty(this,"get",{value(t){const n=r[t];if(void 0!==n)return n;const i=e.call(this,t);return r[t]=i,i}}),Object.defineProperty(this,"set",{value(t,e){n.call(this,t,e),r[t]=e}}),Object.defineProperty(this,"slice",{value:(t,e)=>new Da(i.call(this,t,e))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Ba(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}function Fa(t){if(!t||t.length<=0)return function(t){return!0};let e="";const n=t.filter((t=>t==t));return n.length>0&&(e=`\n switch (x) {${n.map((t=>`\n case ${function(t){if("bigint"!=typeof t)return yi(t);if(On)return`${yi(t)}n`;return`"${yi(t)}"`}(t)}:`)).join("")}\n return false;\n }`),t.length!==n.length&&(e=`if (x !== x) return false;\n${e}`),new Function("x",`${e}\nreturn true;`)}const Va=(t,e)=>(Math.ceil(t)*e+63&-64||64)/e;class Ua{constructor(t,e=1){this.buffer=t,this.stride=e,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t.constructor,this._resize(this.length=Math.ceil(t.length/e))}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;const e=this.stride,n=this.length*e,i=this.buffer.length;n>=i&&this._resize(Va(0===i?1*n:2*n,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Va(t*this.stride,this.BYTES_PER_ELEMENT);const e=((t,e=0)=>t.length>=e?t.subarray(0,e):Yn(new t.constructor(e),t,0))(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this._resize(0),this}_resize(t){return this.buffer=Yn(new this.ArrayType(t),this.buffer)}}Ua.prototype.offset=0;class Pa extends Ua{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}}class Ra extends Pa{constructor(t=new Uint8Array(0)){super(t,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){const{buffer:n}=this.reserve(t-this.length+1),i=t>>3,r=t%8,s=n[i]>>r&1;return e?0===s&&(n[i]|=1<this.length&&this.set(t-1,0),super.flush(t+1)}}let $a=class{constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=Lr(t),this._nulls=new Ra,e&&e.length>0&&(this._isValid=Fa(e))}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}toVector(){return new Ba([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0;const{_offsets:e,_values:n,_nulls:i,_typeIds:r,children:s}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),r&&(t+=r.byteLength),s.reduce(((t,e)=>t+e.byteLength),t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce(((t,e)=>t+e.reservedByteLength),t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,i;const{type:r,length:s,nullCount:a,_typeIds:o,_offsets:c,_values:l,_nulls:u}=this;(e=null==o?void 0:o.flush(s))?i=null==c?void 0:c.flush(s):t=(i=null==c?void 0:c.flush(s))?null==l?void 0:l.flush(c.last()):null==l?void 0:l.flush(s),a>0&&(n=null==u?void 0:u.flush(s));const h=this.children.map((t=>t.flush()));return this.clear(),ca({type:r,length:s,nullCount:a,children:h,child:h[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:i})}finish(){this.finished=!0;for(const t of this.children)t.finish();return this}clear(){var t,e,n,i;this.length=0,null===(t=this._nulls)||void 0===t||t.clear(),null===(e=this._values)||void 0===e||e.clear(),null===(n=this._offsets)||void 0===n||n.clear(),null===(i=this._typeIds)||void 0===i||i.clear();for(const t of this.children)t.clear();return this}};$a.prototype.length=1,$a.prototype.stride=1,$a.prototype.children=null,$a.prototype.finished=!1,$a.prototype.nullValues=null,$a.prototype._isValid=()=>!0;class za extends $a{constructor(t){super(t),this._values=new Pa(new this.ArrayType(0),this.stride)}setValue(t,e){const n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}}class Ha extends $a{constructor(t){super(t),this._pendingLength=0,this._offsets=new ja}setValue(t,e){const n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e instanceof Hs?e[$s].length:e.length,n.set(t,e)}setValid(t,e){return!!super.setValid(t,e)||((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){const t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}}class qa{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,n,i){return t.prep(8,24),t.writeInt64(i),t.pad(4),t.writeInt32(n),t.writeInt64(e),t.offset()}}const Ya=new Int32Array(2),Wa=new Float32Array(Ya.buffer),Ga=new Float64Array(Ya.buffer),Ka=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];let Qa=class t{constructor(t,e){this.low=0|t,this.high=0|e}static create(e,n){return 0==e&&0==n?t.ZERO:new t(e,n)}toFloat64(){return(this.low>>>0)+4294967296*this.high}equals(t){return this.low==t.low&&this.high==t.high}};var Ja;Qa.ZERO=new Qa(0,0),function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(Ja||(Ja={}));let Za=class t{constructor(t){this.bytes_=t,this.position_=0}static allocate(e){return new t(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new Qa(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new Qa(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return Ya[0]=this.readInt32(t),Wa[0]}readFloat64(t){return Ya[Ka?0:1]=this.readInt32(t),Ya[Ka?1:0]=this.readInt32(t+4),Ga[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){Wa[0]=e,this.writeInt32(t,Ya[0])}writeFloat64(t,e){Ga[0]=e,this.writeInt32(t,Ya[Ka?0:1]),this.writeInt32(t+4,Ya[Ka?1:0])}getBufferIdentifier(){if(this.bytes_.length>10),56320+(1023&e)))}return i}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createLong(t,e){return Qa.create(t,e)}createScalarList(t,e){const n=[];for(let i=0;ithis.minalign&&(this.minalign=e);const i=1+~(this.bb.capacity()-this.space+n)&e-1;for(;this.space=0&&0==this.vtable[e];e--);const n=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const i=2*(n+2);this.addInt16(i);let r=0;const s=this.space;t:for(e=0;e=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(0!=this.bb.readInt16(i+e)))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(n,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let n=0;for(;n=56320)i=r;else{i=(r<<10)+t.charCodeAt(n++)+-56613888}i<128?e.push(i):(i<2048?e.push(i>>6&31|192):(i<65536?e.push(i>>12&15|224):e.push(i>>18&7|240,i>>12&63|128),e.push(i>>6&63|128)),e.push(63&i|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let t=0,n=this.space,i=this.bb.bytes();t=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return ko.startUnion(t),ko.addMode(t,e),ko.addTypeIds(t,n),ko.endUnion(t)}}class Mo{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new Mo).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new Mo).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Mo.startUtf8(t),Mo.endUtf8(t)}}!function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList"}(To||(To={}));let Eo=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):To.NONE}type(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){const e=this.bb.__offset(this.bb_pos,12);return e?(t||new ao).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(e,n){const i=this.bb.__offset(this.bb_pos,14);return i?(n||new t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*e),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,16);return n?(e||new to).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,To.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}},Co=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):no.Little}fields(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Eo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new to).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,no.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(e,n,i,r,s){return t.startSchema(e),t.addEndianness(e,n),t.addFields(e,i),t.addCustomMetadata(e,r),t.addFeatures(e,s),t.endSchema(e)}};class No{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new No).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new No).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):eo.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Co).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new qa).__init(this.bb.__vector(this.bb_pos+n)+24*t,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){const n=this.bb.__offset(this.bb_pos,10);return n?(e||new qa).__init(this.bb.__vector(this.bb_pos+n)+24*t,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new to).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,eo.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}}class Oo{constructor(t=[],e,n){this.fields=t||[],this.metadata=e||new Map,n||(n=Do(t)),this.dictionaries=n}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map((t=>t.name))}toString(){return`Schema<{ ${this.fields.map(((t,e)=>`${e}: ${t}`)).join(", ")} }>`}select(t){const e=new Set(t),n=this.fields.filter((t=>e.has(t.name)));return new Oo(n,this.metadata)}selectAt(t){const e=t.map((t=>this.fields[t])).filter(Boolean);return new Oo(e,this.metadata)}assign(...t){const e=t[0]instanceof Oo?t[0]:Array.isArray(t[0])?new Oo(t[0]):new Oo(t),n=[...this.fields],i=Bo(Bo(new Map,this.metadata),e.metadata),r=e.fields.filter((t=>{const e=n.findIndex((e=>e.name===t.name));return!~e||(n[e]=t.clone({metadata:Bo(Bo(new Map,n[e].metadata),t.metadata)}))&&!1})),s=Do(r,new Map);return new Oo([...n,...r],i,new Map([...this.dictionaries,...s]))}}Oo.prototype.fields=null,Oo.prototype.metadata=null,Oo.prototype.dictionaries=null;class Lo{constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}static new(...t){let[e,n,i,r]=t;return t[0]&&"object"==typeof t[0]&&(({name:e}=t[0]),void 0===n&&(n=t[0].type),void 0===i&&(i=t[0].nullable),void 0===r&&(r=t[0].metadata)),new Lo(`${e}`,n,i,r)}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,i,r]=t;return t[0]&&"object"==typeof t[0]?({name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:r=this.metadata}=t[0]):[e=this.name,n=this.type,i=this.nullable,r=this.metadata]=t,Lo.new(e,n,i,r)}}function Bo(t,e){return new Map([...t||new Map,...e||new Map])}function Do(t,e=new Map){for(let n=-1,i=t.length;++n0&&Do(i.children,e)}return e}Lo.prototype.type=null,Lo.prototype.name=null,Lo.prototype.nullable=null,Lo.prototype.metadata=null;var Fo=Qa,Vo=Xa,Uo=Za;class Po{constructor(t,e=ai.V4,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}static decode(t){t=new Uo(Qn(t));const e=No.getRootAsFooter(t),n=Oo.decode(e.schema());return new Ro(n,e)}static encode(t){const e=new Vo,n=Oo.encode(e,t.schema);No.startRecordBatchesVector(e,t.numRecordBatches);for(const n of[...t.recordBatches()].slice().reverse())jo.encode(e,n);const i=e.endVector();No.startDictionariesVector(e,t.numDictionaries);for(const n of[...t.dictionaryBatches()].slice().reverse())jo.encode(e,n);const r=e.endVector();return No.startFooter(e),No.addSchema(e,n),No.addVersion(e,ai.V4),No.addRecordBatches(e,i),No.addDictionaries(e,r),No.finishFooterBuffer(e,No.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e=0&&t=0&&t=0&&t=0&&tthis._closedPromiseResolve=t))}get closed(){return this._closedPromise}cancel(t){return xn(this,void 0,void 0,(function*(){yield this.return(t)}))}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve($o);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return ni.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return ni.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return xn(this,void 0,void 0,(function*(){return yield this.abort(t),$o}))}return(t){return xn(this,void 0,void 0,(function*(){return yield this.close(),$o}))}read(t){return xn(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return xn(this,void 0,void 0,(function*(){return(yield this.next(t,"peek")).value}))}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise(((t,e)=>{this.resolvers.push({resolve:t,reject:e})})):Promise.resolve($o)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class qo extends Ho{write(t){if((t=Qn(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Mn(this.toUint8Array(!0)):this.toUint8Array(!1).then(Mn)}toUint8Array(t=!1){return t?Wn(this._values)[0]:(()=>xn(this,void 0,void 0,(function*(){var t,e;const n=[];let i=0;try{for(var r,s=Tn(this);!(r=yield s.next()).done;){const t=r.value;n.push(t),i+=t.byteLength}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=s.return)&&(yield e.call(s))}finally{if(t)throw t.error}}return Wn(n,i)[0]})))()}}class Yo extends Ha{constructor(t){super(t),this._values=new Ua(new Uint8Array(0))}get byteLength(){let t=this._pendingLength+4*this.length;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Qn(e))}_flushPending(t,e){const n=this._offsets,i=this._values.reserve(e).buffer;let r=0;for(const[e,s]of t)if(void 0===s)n.set(e,0);else{const t=s.length;i.set(s,r),n.set(e,t),r+=t}}}class Wo extends $a{constructor(t){super(t),this._values=new Ra}setValue(t,e){this._values.set(t,+e)}}class Go extends za{}Go.prototype._setValue=Jr;class Ko extends Go{}Ko.prototype._setValue=Gr;class Qo extends Go{}Qo.prototype._setValue=Kr;class Jo extends za{}Jo.prototype._setValue=cs;class Zo extends $a{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Or(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=Gc({type:this.type.indices,nullValues:e}),this.dictionary=Gc({type:this.type.dictionary,nullValues:null}),"function"==typeof n&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){const n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){const n=this._keysToIndices,i=this.valueToKey(e);let r=n[i];return void 0===r&&(n[i]=r=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,r)}flush(){const t=this.type,e=this._dictionary,n=this.dictionary.toVector(),i=this.indices.flush().clone(t);return i.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return"string"==typeof t?t:`${t}`}}class Xo extends za{}Xo.prototype._setValue=Qr;class tc extends $a{setValue(t,e){const[n]=this.children,i=t*this.stride;for(let t=-1,r=e.length;++t0)throw new Error("FixedSizeListBuilder can only have one child.");const n=this.children.push(t);return this.type=new Mr(this.type.listSize,new Lo(e,t.type,!0)),n}}class ec extends za{setValue(t,e){this._values.set(t,e)}}class nc extends ec{setValue(t,e){super.setValue(t,Rr(e))}}class ic extends ec{}class rc extends ec{}class sc extends za{}sc.prototype._setValue=hs;class ac extends sc{}ac.prototype._setValue=ps;class oc extends sc{}oc.prototype._setValue=ds;class cc extends za{setValue(t,e){this._values.set(t,e)}}class lc extends cc{}class uc extends cc{}class hc extends cc{}class pc extends cc{}class dc extends cc{}class fc extends cc{}class mc extends cc{}class yc extends cc{}class gc extends Ha{constructor(t){super(t),this._offsets=new ja}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Ir(new Lo(e,t.type,!0)),this.numChildren-1}_flushPending(t){const e=this._offsets,[n]=this.children;for(const[i,r]of t)if(void 0===r)e.set(i,0);else{const t=r.length,s=e.set(i,t).buffer[i];for(let e=-1;++e0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Er(new Lo(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){const e=this._offsets,[n]=this.children;for(const[i,r]of t)if(void 0===r)e.set(i,0);else{let{[i]:t,[i+1]:s}=e.set(i,r.size).buffer;for(const e of r.entries())if(n.set(t,e),++t>=s)break}}}class vc extends $a{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}}class _c extends $a{setValue(t,e){const{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach(((i,r)=>n[r].set(t,e[r])));case Map:return i.children.forEach(((i,r)=>n[r].set(t,e.get(i.name))));default:return i.children.forEach(((i,r)=>n[r].set(t,e[i.name])))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach((n=>n.setValid(t,e))),e}addChild(t,e=`${this.numChildren}`){const n=this.children.push(t);return this.type=new Ar([...this.type.children,new Lo(e,t.type,!0)]),n}}class xc extends za{}xc.prototype._setValue=ns;class wc extends xc{}wc.prototype._setValue=Zr;class Sc extends xc{}Sc.prototype._setValue=Xr;class Ic extends xc{}Ic.prototype._setValue=ts;class Ac extends xc{}Ac.prototype._setValue=es;class Tc extends za{}Tc.prototype._setValue=os;class kc extends Tc{}kc.prototype._setValue=is;class Mc extends Tc{}Mc.prototype._setValue=rs;class Ec extends Tc{}Ec.prototype._setValue=ss;class Cc extends Tc{}Cc.prototype._setValue=as;class Nc extends $a{constructor(t){super(t),this._typeIds=new Pa(new Int8Array(0),1),"function"==typeof t.valueToChildTypeId&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return void 0===n&&(n=this._valueToChildTypeId(this,e,t)),this.setValid(t,this.isValid(e))&&this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);const i=this.type.typeIdToChildIndex[n],r=this.children[i];null==r||r.set(t,e)}addChild(t,e=`${this.children.length}`){const n=this.children.push(t),{type:{children:i,mode:r,typeIds:s}}=this,a=[...i,new Lo(e,t.type)];return this.type=new Tr(r,[...s,n],a),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}}class Oc extends Nc{}class Lc extends Nc{constructor(t){super(t),this._offsets=new Pa(new Int32Array(0))}setValue(t,e,n){const i=this._typeIds.set(t,n).buffer[t],r=this.getChildAt(this.type.typeIdToChildIndex[i]),s=this._offsets.set(t,r.length).buffer[t];null==r||r.set(s,e)}}class Bc extends Ha{constructor(t){super(t),this._values=new Ua(new Uint8Array(0))}get byteLength(){let t=this._pendingLength+4*this.length;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Cn(e))}_flushPending(t,e){}}Bc.prototype._flushPending=Yo.prototype._flushPending;const Dc=new class extends Br{visitNull(){return vc}visitBool(){return Wo}visitInt(){return cc}visitInt8(){return lc}visitInt16(){return uc}visitInt32(){return hc}visitInt64(){return pc}visitUint8(){return dc}visitUint16(){return fc}visitUint32(){return mc}visitUint64(){return yc}visitFloat(){return ec}visitFloat16(){return nc}visitFloat32(){return ic}visitFloat64(){return rc}visitUtf8(){return Bc}visitBinary(){return Yo}visitFixedSizeBinary(){return Xo}visitDate(){return Go}visitDateDay(){return Ko}visitDateMillisecond(){return Qo}visitTimestamp(){return xc}visitTimestampSecond(){return wc}visitTimestampMillisecond(){return Sc}visitTimestampMicrosecond(){return Ic}visitTimestampNanosecond(){return Ac}visitTime(){return Tc}visitTimeSecond(){return kc}visitTimeMillisecond(){return Mc}visitTimeMicrosecond(){return Ec}visitTimeNanosecond(){return Cc}visitDecimal(){return Jo}visitList(){return gc}visitStruct(){return _c}visitUnion(){return Nc}visitDenseUnion(){return Lc}visitSparseUnion(){return Oc}visitDictionary(){return Zo}visitInterval(){return sc}visitIntervalDayTime(){return ac}visitIntervalYearMonth(){return oc}visitFixedSizeList(){return tc}visitMap(){return bc}};class Fc extends Br{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every(((t,n)=>this.compareFields(t,e[n])))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}}function Vc(t,e){return e instanceof t.constructor}function Uc(t,e){return t===e||Vc(t,e)}function Pc(t,e){return t===e||Vc(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function Rc(t,e){return t===e||Vc(t,e)&&t.precision===e.precision}function jc(t,e){return t===e||Vc(t,e)&&t.unit===e.unit}function $c(t,e){return t===e||Vc(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function zc(t,e){return t===e||Vc(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function Hc(t,e){return t===e||Vc(t,e)&&t.mode===e.mode&&t.typeIds.every(((t,n)=>t===e.typeIds[n]))&&Yc.compareManyFields(t.children,e.children)}function qc(t,e){return t===e||Vc(t,e)&&t.unit===e.unit}Fc.prototype.visitNull=Uc,Fc.prototype.visitBool=Uc,Fc.prototype.visitInt=Pc,Fc.prototype.visitInt8=Pc,Fc.prototype.visitInt16=Pc,Fc.prototype.visitInt32=Pc,Fc.prototype.visitInt64=Pc,Fc.prototype.visitUint8=Pc,Fc.prototype.visitUint16=Pc,Fc.prototype.visitUint32=Pc,Fc.prototype.visitUint64=Pc,Fc.prototype.visitFloat=Rc,Fc.prototype.visitFloat16=Rc,Fc.prototype.visitFloat32=Rc,Fc.prototype.visitFloat64=Rc,Fc.prototype.visitUtf8=Uc,Fc.prototype.visitBinary=Uc,Fc.prototype.visitFixedSizeBinary=function(t,e){return t===e||Vc(t,e)&&t.byteWidth===e.byteWidth},Fc.prototype.visitDate=jc,Fc.prototype.visitDateDay=jc,Fc.prototype.visitDateMillisecond=jc,Fc.prototype.visitTimestamp=$c,Fc.prototype.visitTimestampSecond=$c,Fc.prototype.visitTimestampMillisecond=$c,Fc.prototype.visitTimestampMicrosecond=$c,Fc.prototype.visitTimestampNanosecond=$c,Fc.prototype.visitTime=zc,Fc.prototype.visitTimeSecond=zc,Fc.prototype.visitTimeMillisecond=zc,Fc.prototype.visitTimeMicrosecond=zc,Fc.prototype.visitTimeNanosecond=zc,Fc.prototype.visitDecimal=Uc,Fc.prototype.visitList=function(t,e){return t===e||Vc(t,e)&&t.children.length===e.children.length&&Yc.compareManyFields(t.children,e.children)},Fc.prototype.visitStruct=function(t,e){return t===e||Vc(t,e)&&t.children.length===e.children.length&&Yc.compareManyFields(t.children,e.children)},Fc.prototype.visitUnion=Hc,Fc.prototype.visitDenseUnion=Hc,Fc.prototype.visitSparseUnion=Hc,Fc.prototype.visitDictionary=function(t,e){return t===e||Vc(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&Yc.visit(t.indices,e.indices)&&Yc.visit(t.dictionary,e.dictionary)},Fc.prototype.visitInterval=qc,Fc.prototype.visitIntervalDayTime=qc,Fc.prototype.visitIntervalYearMonth=qc,Fc.prototype.visitFixedSizeList=function(t,e){return t===e||Vc(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&Yc.compareManyFields(t.children,e.children)},Fc.prototype.visitMap=function(t,e){return t===e||Vc(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&Yc.compareManyFields(t.children,e.children)};const Yc=new Fc;function Wc(t,e){return Yc.compareSchemas(t,e)}function Gc(t){const e=t.type,n=new(Dc.getVisitFn(e)())(t);if(e.children&&e.children.length>0){const i=t.children||[],r={nullValues:t.nullValues},s=Array.isArray(i)?(t,e)=>i[e]||r:({name:t})=>i[t]||r;for(const[t,i]of e.children.entries()){const{type:e}=i,r=s(i,t);n.children.push(Gc(Object.assign(Object.assign({},r),{type:e})))}}return n}function Kc(t,e){return function(t,e){const n=[...t.fields],i=[],r={numBatches:e.reduce(((t,e)=>Math.max(t,e.length)),0)};let s=0,a=0,o=-1;const c=e.length;let l,u=[];for(;r.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o0&&(i[s++]=ca({type:new Ar(n),length:a,nullCount:0,children:u.slice()})))}return[t=t.assign(n),i.map((e=>new tl(t,e)))]}(t,e.map((t=>t.data.concat())))}function Qc(t,e,n,i,r){var s;const a=(e+63&-64)>>3;for(let o=-1,c=i.length;++o=e)l===e?n[o]=c:(n[o]=c.slice(0,e),r.numBatches=Math.max(r.numBatches,i[o].unshift(c.slice(e,l-e))));else{const i=t[o];t[o]=i.clone({nullable:!0}),n[o]=null!==(s=null==c?void 0:c._changeLengthAndBackfillNullBitmap(e))&&void 0!==s?s:ca({type:i.type,length:e,nullCount:e,nullBitmap:new Uint8Array(a)})}}return n}var Jc,Zc;class Xc{constructor(...t){var e,n;if(0===t.length)return this.batches=[],this.schema=new Oo([]),this._offsets=[0],this;let i,r;t[0]instanceof Oo&&(i=t.shift()),t[t.length-1]instanceof Uint32Array&&(r=t.pop());const s=t=>{if(t){if(t instanceof tl)return[t];if(t instanceof Xc)return t.batches;if(t instanceof aa){if(t.type instanceof Ar)return[new tl(new Oo(t.type.children),t)]}else{if(Array.isArray(t))return t.flatMap((t=>s(t)));if("function"==typeof t[Symbol.iterator])return[...t].flatMap((t=>s(t)));if("object"==typeof t){const e=Object.keys(t),n=e.map((e=>new Ba([t[e]]))),i=new Oo(e.map(((t,e)=>new Lo(String(t),n[e].type)))),[,r]=Kc(i,n);return 0===r.length?[new tl(t)]:r}}}return[]},a=t.flatMap((t=>s(t)));if(i=null!==(n=null!=i?i:null===(e=a[0])||void 0===e?void 0:e.schema)&&void 0!==n?n:new Oo([]),!(i instanceof Oo))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const t of a){if(!(t instanceof tl))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Wc(i,t.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=null!=r?r:ha(this.data)}get data(){return this.batches.map((({data:t})=>t))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce(((t,e)=>t+e.length),0)}get nullCount(){return-1===this._nullCount&&(this._nullCount=ua(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}getByteLength(t){return 0}[Symbol.iterator](){return this.batches.length>0?Aa.visit(new Ba(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(",\n ")}\n]`}concat(...t){const e=this.schema,n=this.data.concat(t.flatMap((({data:t})=>t)));return new Xc(e,n.map((t=>new tl(e,t))))}slice(t,e){const n=this.schema;[t,e]=Gs({length:this.numRows},t,e);const i=pa(this.data,this._offsets,t,e);return new Xc(n,i.map((t=>new tl(n,t))))}getChild(t){return this.getChildAt(this.schema.fields.findIndex((e=>e.name===t)))}getChildAt(t){if(t>-1&&te.children[t]));if(0===e.length){const{type:n}=this.schema.fields[t],i=ca({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new Ba(e)}return null}setChild(t,e){var n;return this.setChildAt(null===(n=this.schema.fields)||void 0===n?void 0:n.findIndex((e=>e.name===t)),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&tthis.getChildAt(e)));[r[t],a[t]]=[s,e],[n,i]=Kc(n,a)}return new Xc(n,i)}select(t){const e=this.schema.fields.reduce(((t,e,n)=>t.set(e.name,n)),new Map);return this.selectAt(t.map((t=>e.get(t))).filter((t=>t>-1)))}selectAt(t){const e=this.schema.selectAt(t),n=this.batches.map((e=>e.selectAt(t)));return new Xc(e,n)}assign(t){const e=this.schema.fields,[n,i]=t.schema.fields.reduce(((t,n,i)=>{const[r,s]=t,a=e.findIndex((t=>t.name===n.name));return~a?s[a]=i:r.push(i),t}),[[],[]]),r=this.schema.assign(t.schema),s=[...e.map(((t,e)=>[e,i[e]])).map((([e,n])=>void 0===n?this.getChildAt(e):t.getChildAt(n))),...n.map((e=>t.getChildAt(e)))].filter(Boolean);return new Xc(...Kc(r,s))}}Jc=Symbol.toStringTag,Xc[Jc]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=ma(fa),t.get=ma(js.getVisitFn(di.Struct)),t.set=ya(fs.getVisitFn(di.Struct)),t.indexOf=ga(xa.getVisitFn(di.Struct)),t.getByteLength=ma(Ca.getVisitFn(di.Struct)),"Table"))(Xc.prototype);let tl=class t{constructor(...t){switch(t.length){case 2:if([this.schema]=t,!(this.schema instanceof Oo))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=ca({nullCount:0,type:new Ar(this.schema.fields),children:this.schema.fields.map((t=>ca({type:t.type,nullCount:0})))})]=t,!(this.data instanceof aa))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=el(this.schema,this.data.children);break;case 1:{const[e]=t,{fields:n,children:i,length:r}=Object.keys(e).reduce(((t,n,i)=>(t.children[i]=e[n],t.length=Math.max(t.length,e[n].length),t.fields[i]=Lo.new({name:n,type:e[n].type,nullable:!0}),t)),{length:0,fields:new Array,children:new Array}),s=new Oo(n),a=ca({type:new Ar(n),length:r,children:i,nullCount:0});[this.schema,this.data]=el(s,a.children,r);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=nl(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return js.visit(this.data,t)}set(t,e){return fs.visit(this.data,t,e)}indexOf(t,e){return xa.visit(this.data,t,e)}getByteLength(t){return Ca.visit(this.data,t)}[Symbol.iterator](){return Aa.visit(new Ba([this.data]))}toArray(){return[...this]}concat(...t){return new Xc(this.schema,[this,...t])}slice(e,n){const[i]=new Ba([this.data]).slice(e,n).data;return new t(this.schema,i)}getChild(t){var e;return this.getChildAt(null===(e=this.schema.fields)||void 0===e?void 0:e.findIndex((e=>e.name===t)))}getChildAt(t){return t>-1&&te.name===t)),e)}setChildAt(e,n){let i=this.schema,r=this.data;if(e>-1&&ee.name===t));~e&&(r[e]=this.data.children[e])}return new t(n,ca({type:i,length:this.numRows,children:r}))}selectAt(e){const n=this.schema.selectAt(e),i=e.map((t=>this.data.children[t])).filter(Boolean),r=ca({type:new Ar(n.fields),length:this.numRows,children:i});return new t(n,r)}};function el(t,e,n=e.reduce(((t,e)=>Math.max(t,e.length)),0)){var i;const r=[...t.fields],s=[...e],a=(n+63&-64)>>3;for(const[o,c]of t.fields.entries()){const t=e[o];t&&t.length===n||(r[o]=c.clone({nullable:!0}),s[o]=null!==(i=null==t?void 0:t._changeLengthAndBackfillNullBitmap(n))&&void 0!==i?i:ca({type:c.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[t.assign(r),ca({type:new Ar(r),length:n,children:s})]}function nl(t,e,n=new Map){for(let i=-1,r=t.length;++i0&&nl(r.children,s.children,n)}return n}Zc=Symbol.toStringTag,tl[Zc]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(tl.prototype);class il extends tl{constructor(t){const e=t.fields.map((t=>ca({type:t.type})));super(t,ca({type:new Ar(t.fields),nullCount:0,children:e}))}}var rl,sl;!function(t){t[t.BUFFER=0]="BUFFER"}(rl||(rl={})),function(t){t[t.LZ4_FRAME=0]="LZ4_FRAME",t[t.ZSTD=1]="ZSTD"}(sl||(sl={}));class al{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new al).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new al).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):sl.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):rl.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,sl.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,rl.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return al.startBodyCompression(t),al.addCodec(t,e),al.addMethod(t,n),al.endBodyCompression(t)}}class ol{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(n),t.writeInt64(e),t.offset()}}let cl=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(n),t.writeInt64(e),t.offset()}},ll=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsRecordBatch(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}nodes(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new cl).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new ol).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const e=this.bb.__offset(this.bb_pos,10);return e?(t||new al).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,t.createLong(0,0))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}},ul=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDictionaryBatch(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}data(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new ll).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,t.createLong(0,0))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var hl;!function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"}(hl||(hl={}));let pl=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):eo.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):hl.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new to).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,eo.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,hl.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,t.createLong(0,0))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(e,n,i,r,s,a){return t.startMessage(e),t.addVersion(e,n),t.addHeaderType(e,i),t.addHeader(e,r),t.addBodyLength(e,s),t.addCustomMetadata(e,a),t.endMessage(e)}};var dl=Qa;const fl=new class extends Br{visit(t,e){return null==t||null==e?void 0:super.visit(t,e)}visitNull(t,e){return xo.startNull(e),xo.endNull(e)}visitInt(t,e){return so.startInt(e),so.addBitWidth(e,t.bitWidth),so.addIsSigned(e,t.isSigned),so.endInt(e)}visitFloat(t,e){return go.startFloatingPoint(e),go.addPrecision(e,t.precision),go.endFloatingPoint(e)}visitBinary(t,e){return oo.startBinary(e),oo.endBinary(e)}visitBool(t,e){return co.startBool(e),co.endBool(e)}visitUtf8(t,e){return Mo.startUtf8(e),Mo.endUtf8(e)}visitDecimal(t,e){return uo.startDecimal(e),uo.addScale(e,t.scale),uo.addPrecision(e,t.precision),uo.addBitWidth(e,t.bitWidth),uo.endDecimal(e)}visitDate(t,e){return lo.startDate(e),lo.addUnit(e,t.unit),lo.endDate(e)}visitTime(t,e){return So.startTime(e),So.addUnit(e,t.unit),So.addBitWidth(e,t.bitWidth),So.endTime(e)}visitTimestamp(t,e){const n=t.timezone&&e.createString(t.timezone)||void 0;return Io.startTimestamp(e),Io.addUnit(e,t.unit),void 0!==n&&Io.addTimezone(e,n),Io.endTimestamp(e)}visitInterval(t,e){return bo.startInterval(e),bo.addUnit(e,t.unit),bo.endInterval(e)}visitList(t,e){return vo.startList(e),vo.endList(e)}visitStruct(t,e){return wo.startStruct_(e),wo.endStruct_(e)}visitUnion(t,e){ko.startTypeIdsVector(e,t.typeIds.length);const n=ko.createTypeIdsVector(e,t.typeIds);return ko.startUnion(e),ko.addMode(e,t.mode),ko.addTypeIds(e,n),ko.endUnion(e)}visitDictionary(t,e){const n=this.visit(t.indices,e);return ao.startDictionaryEncoding(e),ao.addId(e,new dl(t.id,0)),ao.addIsOrdered(e,t.isOrdered),void 0!==n&&ao.addIndexType(e,n),ao.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return mo.startFixedSizeBinary(e),mo.addByteWidth(e,t.byteWidth),mo.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return yo.startFixedSizeList(e),yo.addListSize(e,t.listSize),yo.endFixedSizeList(e)}visitMap(t,e){return _o.startMap(e),_o.addKeysSorted(e,t.keysSorted),_o.endMap(e)}};function ml(t){return new Tl(t.count,gl(t.columns),bl(t.columns))}function yl(t,e){return(t.children||[]).filter(Boolean).map((t=>Lo.fromJSON(t,e)))}function gl(t){return(t||[]).reduce(((t,e)=>{return[...t,new El(e.count,(n=e.VALIDITY,(n||[]).reduce(((t,e)=>t+ +(0===e)),0))),...gl(e.children)];var n}),[])}function bl(t,e=[]){for(let n=-1,i=(t||[]).length;++ni),this._bodyLength="number"==typeof t?t:t.low}static fromJSON(t,e){const n=new Al(0,ai.V4,e);return n._createHeader=function(t,e){return()=>{switch(e){case pi.Schema:return Oo.fromJSON(t);case pi.RecordBatch:return Tl.fromJSON(t);case pi.DictionaryBatch:return kl.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${pi[e]}, type: ${e} }`)}}(t,e),n}static decode(t){t=new Il(Qn(t));const e=pl.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),r=e.headerType(),s=new Al(n,i,r);return s._createHeader=function(t,e){return()=>{switch(e){case pi.Schema:return Oo.decode(t.header(new Co));case pi.RecordBatch:return Tl.decode(t.header(new ll),t.version());case pi.DictionaryBatch:return kl.decode(t.header(new ul),t.version())}throw new Error(`Unrecognized Message type: { name: ${pi[e]}, type: ${e} }`)}}(e,r),s}static encode(t){const e=new Sl;let n=-1;return t.isSchema()?n=Oo.encode(e,t.header()):t.isRecordBatch()?n=Tl.encode(e,t.header()):t.isDictionaryBatch()&&(n=kl.encode(e,t.header())),pl.startMessage(e),pl.addVersion(e,ai.V4),pl.addHeader(e,n),pl.addHeaderType(e,t.headerType),pl.addBodyLength(e,new wl(t.bodyLength,0)),pl.finishMessageBuffer(e,pl.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Oo)return new Al(0,ai.V4,pi.Schema,t);if(t instanceof Tl)return new Al(e,ai.V4,pi.RecordBatch,t);if(t instanceof kl)return new Al(e,ai.V4,pi.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===pi.Schema}isRecordBatch(){return this.headerType===pi.RecordBatch}isDictionaryBatch(){return this.headerType===pi.DictionaryBatch}}class Tl{constructor(t,e,n){this._nodes=e,this._buffers=n,this._length="number"==typeof t?t:t.low}get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}}class kl{constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id="number"==typeof e?e:e.low}get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}}class Ml{constructor(t,e){this.offset="number"==typeof t?t:t.low,this.length="number"==typeof e?e:e.low}}class El{constructor(t,e){this.length="number"==typeof t?t:t.low,this.nullCount="number"==typeof e?e:e.low}}function Cl(t,e){const n=[];for(let i,r=-1,s=-1,a=t.childrenLength();++rLo.encode(t,e))),c=Eo.createChildrenVector(t,o),l=e.metadata&&e.metadata.size>0?Eo.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const i=t.createString(`${e}`),r=t.createString(`${n}`);return to.startKeyValue(t),to.addKey(t,i),to.addValue(t,r),to.endKeyValue(t)}))):-1;e.name&&(n=t.createString(e.name));Eo.startField(t),Eo.addType(t,i),Eo.addTypeType(t,a),Eo.addChildren(t,c),Eo.addNullable(t,!!e.nullable),-1!==n&&Eo.addName(t,n);-1!==r&&Eo.addDictionary(t,r);-1!==l&&Eo.addCustomMetadata(t,l);return Eo.endField(t)},Lo.decode=function(t,e){let n,i,r,s,a,o;e&&(o=t.dictionary())?e.has(n=o.id().low)?(s=(s=o.indexType())?Ol(s):new Zi,a=new Or(e.get(n),s,n,o.isOrdered()),i=new Lo(t.name(),a,t.nullable(),Nl(t))):(s=(s=o.indexType())?Ol(s):new Zi,e.set(n,r=Ll(t,Cl(t,e))),a=new Or(r,s,n,o.isOrdered()),i=new Lo(t.name(),a,t.nullable(),Nl(t))):(r=Ll(t,Cl(t,e)),i=new Lo(t.name(),r,t.nullable(),Nl(t)));return i||null},Lo.fromJSON=function(t,e){let n,i,r,s,a,o;return e&&(s=t.dictionary)?e.has(n=s.id)?(i=(i=s.indexType)?_l(i):new Zi,o=new Or(e.get(n),i,n,s.isOrdered),r=new Lo(t.name,o,t.nullable,vl(t.customMetadata))):(i=(i=s.indexType)?_l(i):new Zi,e.set(n,a=xl(t,yl(t,e))),o=new Or(a,i,n,s.isOrdered),r=new Lo(t.name,o,t.nullable,vl(t.customMetadata))):(a=xl(t,yl(t,e)),r=new Lo(t.name,a,t.nullable,vl(t.customMetadata))),r||null},Oo.encode=function(t,e){const n=e.fields.map((e=>Lo.encode(t,e)));Co.startFieldsVector(t,n.length);const i=Co.createFieldsVector(t,n),r=e.metadata&&e.metadata.size>0?Co.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const i=t.createString(`${e}`),r=t.createString(`${n}`);return to.startKeyValue(t),to.addKey(t,i),to.addValue(t,r),to.endKeyValue(t)}))):-1;Co.startSchema(t),Co.addFields(t,i),Co.addEndianness(t,Bl?no.Little:no.Big),-1!==r&&Co.addCustomMetadata(t,r);return Co.endSchema(t)},Oo.decode=function(t,e=new Map){const n=function(t,e){const n=[];for(let i,r=-1,s=-1,a=t.fieldsLength();++rLo.fromJSON(t,e)))}(t,e),vl(t.customMetadata),e)},Tl.encode=function(t,e){const n=e.nodes||[],i=e.buffers||[];ll.startNodesVector(t,n.length);for(const e of n.slice().reverse())El.encode(t,e);const r=t.endVector();ll.startBuffersVector(t,i.length);for(const e of i.slice().reverse())Ml.encode(t,e);const s=t.endVector();return ll.startRecordBatch(t),ll.addLength(t,new wl(e.length,0)),ll.addNodes(t,r),ll.addBuffers(t,s),ll.endRecordBatch(t)},Tl.decode=function(t,e=ai.V4){if(null!==t.compression())throw new Error("Record batch compression not implemented");return new Tl(t.length(),function(t){const e=[];for(let n,i=-1,r=-1,s=t.nodesLength();++i{const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),256===new Int16Array(t)[0]})(),Dl="ARROW1",Fl=new Uint8Array(6);for(let t=0;t<6;t+=1)Fl[t]=Dl.codePointAt(t);Fl.length;class Vl extends Br{constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}static assemble(...t){const e=t=>t.flatMap((t=>Array.isArray(t)?e(t):t instanceof tl?t.data.children:t.data)),n=new Vl;return n.visitMany(e(t)),n}visit(t){if(t instanceof Ba)return this.visitMany(t.data),this;const{type:e}=t;if(!Wi.isDictionary(e)){const{length:n,nullCount:i}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");Wi.isNull(e)||Ul.call(this,i<=0?new Uint8Array(0):ea(t.offset,n,t.nullBitmap)),this.nodes.push(new El(n,i))}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function Ul(t){const e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new Ml(this._byteLength,e)),this._byteLength+=e,this}function Pl(t){return Ul.call(this,t.values.subarray(0,t.length*t.stride))}function Rl(t){const{length:e,values:n,valueOffsets:i}=t,r=i[0],s=i[e],a=Math.min(s-r,n.byteLength-r);return Ul.call(this,ei(-i[0],e,i)),Ul.call(this,n.subarray(r,r+a)),this}function jl(t){const{length:e,valueOffsets:n}=t;return n&&Ul.call(this,ei(n[0],e,n)),this.visit(t.children[0])}function $l(t){return this.visitMany(t.type.children.map(((e,n)=>t.children[n])).filter(Boolean))[0]}Vl.prototype.visitBool=function(t){let e;return t.nullCount>=t.length?Ul.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?Ul.call(this,ea(t.offset,t.length,e)):Ul.call(this,na(t.values))},Vl.prototype.visitInt=Pl,Vl.prototype.visitFloat=Pl,Vl.prototype.visitUtf8=Rl,Vl.prototype.visitBinary=Rl,Vl.prototype.visitFixedSizeBinary=Pl,Vl.prototype.visitDate=Pl,Vl.prototype.visitTimestamp=Pl,Vl.prototype.visitTime=Pl,Vl.prototype.visitDecimal=Pl,Vl.prototype.visitList=jl,Vl.prototype.visitStruct=$l,Vl.prototype.visitUnion=function(t){const{type:e,length:n,typeIds:i,valueOffsets:r}=t;if(Ul.call(this,i),e.mode===oi.Sparse)return $l.call(this,t);if(e.mode===oi.Dense){if(t.offset<=0)return Ul.call(this,r),$l.call(this,t);{const s=i.reduce(((t,e)=>Math.max(t,e)),i[0]),a=new Int32Array(s+1),o=new Int32Array(s+1).fill(-1),c=new Int32Array(n),l=ei(-r[0],n,r);for(let t,e,r=-1;++rthis.writeAll(t))):jn(t)?Wl(this,t):Yl(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){var n;return t===this._sink||t instanceof qo?this._sink=t:(this._sink=new qo,t&&(Un(n=t)&&Vn(n.abort)&&Vn(n.getWriter)&&!zn(n))?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&(t=>Un(t)&&Vn(t.end)&&Vn(t.write)&&(t=>"boolean"==typeof t)(t.writable)&&!zn(t))(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,e&&Wc(e,this._schema)||(null==e?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(!this._sink)throw new Error("RecordBatchWriter is closed");if(null==t)return this.finish()&&void 0;if(t instanceof Xc&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof tl&&!(e=t.schema))return this.finish()&&void 0;if(e&&!Wc(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof tl?t instanceof il||this._writeRecordBatch(t):t instanceof Xc?this.writeAll(t.batches):Rn(t)&&this.writeAll(t)}_writeMessage(t,e=8){const n=e-1,i=Al.encode(t),r=i.byteLength,s=this._writeLegacyIpcFormat?4:8,a=r+s+n&~n,o=a-r-s;return t.headerType===pi.RecordBatch?this._recordBatchBlocks.push(new jo(a,t.bodyLength,this._position)):t.headerType===pi.DictionaryBatch&&this._dictionaryBlocks.push(new jo(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-s)),r>0&&this._write(i),this._writePadding(o)}_write(t){if(this._started){const e=Qn(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(Al.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Fl)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:e,nodes:n,bufferRegions:i,buffers:r}=Vl.assemble(t),s=new Tl(t.numRows,n,i),a=Al.from(s,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(r)}_writeDictionaryBatch(t,e,n=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));const{byteLength:i,nodes:r,bufferRegions:s,buffers:a}=Vl.assemble(new Ba([t])),o=new Tl(t.length,r,s),c=new kl(o,e,n),l=Al.from(c,i);return this._writeMessage(l)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,n,i;for(let r=-1,s=t.length;++r0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){for(let[e,n]of t.dictionaries){let t=this._dictionaryDeltaOffsets.get(e)||0;if(0===t||(n=null==n?void 0:n.slice(t)).length>0)for(const i of n.data)this._writeDictionaryBatch(i,e,t>0),t+=i.length}return this}}class Hl extends zl{static writeAll(t,e){const n=new Hl(e);return Pn(t)?t.then((t=>n.writeAll(t))):jn(t)?Wl(n,t):Yl(n,t)}}class ql extends zl{static writeAll(t){const e=new ql;return Pn(t)?t.then((t=>e.writeAll(t))):jn(t)?Wl(e,t):Yl(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){const e=Po.encode(new Po(t,ai.V4,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}}function Yl(t,e){let n=e;e instanceof Xc&&(n=e.batches,t.reset(void 0,e.schema));for(const e of n)t.write(e);return t.finish()}function Wl(t,e){var n,i,r,s;return xn(this,void 0,void 0,(function*(){try{for(n=Tn(e);!(i=yield n.next()).done;){const e=i.value;t.write(e)}}catch(t){r={error:t}}finally{try{i&&!i.done&&(s=n.return)&&(yield s.call(n))}finally{if(r)throw r.error}}return t.finish()}))}function Gl(t,e=1){return(t*e+63&-64||64)/e}function Kl(t,e,n=t.BYTES_PER_ELEMENT){return new t(Gl(e,n))}function Ql(t){return t instanceof aa?t:new aa(t.type,0,t.length,t.nulls,t.buffers,null,t.dict)}const Jl=new TextEncoder;const Zl=Jl.encodeInto?function(t,e,n){return Jl.encodeInto(n,t.subarray(e)).written}:function(t,e,n){const i=Jl.encode(n);return t.set(i,e),i.length};function Xl(t,e){const n=Kl(t.ArrayType,e);return{set(t,e){n[e]=t},data:()=>({type:t,length:e,buffers:[null,n]})}}function tu(t,e){const n=Kl(t.ArrayType,e/8);return{set(t,e){t&&(n[e>>3]|=1<({type:t,length:e,buffers:[null,n]})}}function eu(t,e){const n=Kl(t.ArrayType,e);return{set(t,e){n[e]=t/864e5|0},data:()=>({type:t,length:e,buffers:[null,n]})}}function nu(t,e){const n=Kl(t.ArrayType,e<<1);return{set(t,e){const i=e<<1;n[i]=t%4294967296|0,n[i+1]=t/4294967296|0},data:()=>({type:t,length:e,buffers:[null,n]})}}function iu(t,e){const n=[],i=Kl(t.indices.ArrayType,e),r=Object.create(null);let s=-1,a=0;return{set(t,e){const o=String(t);let c=r[o];void 0===c&&(a+=o.length,r[o]=c=++s,n.push(o)),i[e]=c},data:()=>({type:t,length:e,buffers:[null,i],dict:ru(t.dictionary,n,a)})}}function ru(t,e,n){const i=function(t,e,n){const i=Kl(Int32Array,e+1),r=Kl(Uint8Array,3*n);let s=0;return{set(t,e){s+=Zl(r,s,t),i[e+1]=s},data:()=>{const n=Gl(s),a=r.length>n?r.subarray(0,n):r;return{type:t,length:e,buffers:[i,a]}}}}(t,e.length,n);return e.forEach(i.set),function(t){return new Ba([Ql(t)])}(i.data())}function su(t,e,n=!0){let i;switch(t.typeId){case di.Int:i=t.bitWidth<64?Xl:null;break;case di.Float:i=t.precision>0?Xl:null;break;case di.Dictionary:i=t.dictionary.typeId===di.Utf8&&t.indices.typeId===di.Int&&t.indices.bitWidth<64?iu:null;break;case di.Bool:i=tu;break;case di.Date:i=t.unit?nu:eu}return null==i?function(t){const e=Gc({type:t,nullValues:[null,void 0]});return{set(t,n){e.set(n,t)},data:()=>e.finish().flush()}}(t):n?function(t,e){const n=Kl(Uint8Array,e/8);let i=0;return{set(e,r){null==e?++i:(t.set(e,r),n[r>>3]|=1<{const e=t.data();return i&&(e.nulls=i,e.buffers[2]=n),e}}}(i(t,e),e):i(t,e)}function au(t,e,n,i,r=!0){const s=su(i,t,r);return e(n,s.set),Ql(s.data())}function ou(t){if(t instanceof Wi||null==t)return t;switch(t){case di.Binary:return new cr;case di.Bool:return new ur;case di.DateDay:return new dr;case di.DateMillisecond:case di.Date:return new fr;case di.Dictionary:return new Or(new lr,new Zi);case di.Float16:return new sr;case di.Float32:return new ar;case di.Float64:case di.Float:return new or;case di.Int8:return new Qi;case di.Int16:return new Ji;case di.Int32:case di.Int:return new Zi;case di.Int64:return new Xi;case di.IntervalDayTime:return new wr;case di.Interval:case di.IntervalYearMonth:return new Sr;case di.Null:return new Gi;case di.TimeMicrosecond:return new br;case di.TimeMillisecond:case di.Time:return new gr;case di.TimeNanosecond:return new vr;case di.TimeSecond:return new yr;case di.Uint8:return new tr;case di.Uint16:return new er;case di.Uint32:return new nr;case di.Uint64:return new ir;case di.Utf8:return new lr;default:St(`Unsupported type code: ${be(t)}. Use a data type constructor instead?`)}}function cu(t,e){const n=lu();return t(e,n.add),n}function lu(){const t={count:0,nulls:0,bools:0,nums:0,ints:0,bigints:0,min:1/0,max:-1/0,digits:0,dates:0,utcdays:0,strings:0,strlen:0,arrays:0,minlen:1/0,maxlen:0,structs:0,add(e){if(++t.count,null==e)return void++t.nulls;const n=typeof e;if("string"===n)++t.strings;else if("number"===n)++t.nums,et.max&&(t.max=e),Number.isInteger(e)&&++t.ints;else if("boolean"===n)++t.bools;else if("object"===n)if(Ct(e))++t.dates,0===(i=e).getUTCHours()&&0===i.getUTCMinutes()&&0===i.getUTCSeconds()&&0===i.getUTCMilliseconds()&&++t.utcdays;else if(zt(e)){++t.arrays,e.lengtht.maxlen&&(t.maxlen=e.length);const n=t.array_prof||(t.array_prof=lu());e.forEach(n.add)}else{++t.structs;const n=t.struct_prof||(t.struct_prof={});for(const t in e){(n[t]||(n[t]=lu())).add(e[t])}}else"bigint"===n&&(++t.bigints,et.max&&(t.max=e));var i},type:()=>ou(function(t){const e=t.count-t.nulls;if(0===e)return di.Null;if(t.ints===e){const e=Math.max(Math.abs(t.min)-1,t.max);return t.min<0?e>=2**31?di.Float64:e<128?di.Int8:e<32768?di.Int16:di.Int32:e>=2**32?di.Float64:e<256?di.Uint8:e<65536?di.Uint16:di.Uint32}if(t.nums===e)return di.Float64;if(t.bigints===e){const e=-t.min>t.max?-t.min-1n:t.max;return t.min<0?e<2**63?di.Int64:St(`BigInt exceeds 64 bits: ${e}`):t.max<2**64?di.Uint64:St(`BigInt exceeds 64 bits: ${t.max}`)}if(t.bools===e)return di.Bool;if(t.utcdays===e)return di.DateDay;if(t.dates===e)return di.DateMillisecond;if(t.arrays===e){const e=Lo.new("value",t.array_prof.type(),!0);return t.minlen===t.maxlen?new Mr(t.minlen,e):new Ir(e)}if(t.structs===e){const e=t.struct_prof;return new Ar(Object.keys(e).map((t=>Lo.new(t,e[t].type(),!0))))}if(t.strings>0)return di.Dictionary;St("Type inference failure")}(t))};return t}function uu(t,e,n,i,r,s=!0){if(!(r=ou(r))){const t=cu(i,e);s=t.nulls>0,r=t.type()}return au(n,i,e,r,s)}function hu(t,e,n,i,r,s=!0){r=ou(r);const a=t.column(e),o=!(t.isFiltered()||t.isOrdered()),c=(l=a)instanceof Ba?l:l.vector instanceof Ba?l.vector:null;var l;if(c&&o&&pu(c.type,r))return c;const u=a.data;if($t(u)){const t=function(t){const e={Float32Array:ar,Float64Array:or,Int8Array:Qi,Int16Array:Ji,Int32Array:Zi,Uint8Array:tr,Uint16Array:er,Uint32Array:nr,BigInt64Array:Xi,BigUint64Array:ir},n=e[t.constructor.name];return n?new n:null}(u);if(o&&t&&pu(t,r))return function(t,e){const n=t.length,i=Gl(n,t.BYTES_PER_ELEMENT);let r=t;return n!==i&&(r=new t.constructor(i),r.set(t)),Ql({type:e,length:n,buffers:[null,r]})}(u,t);r=r||t,s=!1}if(!r){const t=cu(i,a);s=t.nulls>0,r=t.type()}return au(n,i,a,r,s)}function pu(t,e){return!t||!e||t.compareTo(e)}function du(t,e,n){const i=Math.min(t.length,n+e);return(e,r)=>{for(let s=n;s{let a=-1;i&&zt(r.data)?r.data.forEach(s):t.scan((t=>s(r.get(t),++a)),!0,e,n)}}const mu=()=>St("Apache Arrow not imported, see https://github.com/uwdata/arquero#usage");function yu(t,e={}){const{types:n={}}=e,{dataFrom:i,names:r,nrows:s,scan:a}=function(t,e){const{columns:n,limit:i=1/0,offset:r=0}=e,s=At(n)?n(t):vt(n)?n:null;if(vt(t))return{dataFrom:uu,names:s||Object.keys(t[0]),nrows:Math.min(i,t.length-r),scan:du(t,i,r)};if(function(t){return t&&At(t.reify)}(t))return{dataFrom:hu,names:s||t.columnNames(),nrows:Math.min(i,t.numRows()-r),scan:fu(t,i,r)};St("Unsupported input data type")}(t,e),o={};r.forEach((e=>{const r=i(t,e,s,a,n[e]);r.length!==s&&St("Column length mismatch"),o[e]=r}));return new(function(){try{return Xc}catch(t){mu()}}())(o)}function gu(t,e={}){const{format:n,...i}=e;if(!["stream","file"].includes(n||"stream"))throw Error("Unrecognised output format");return function(t,e="stream"){return("stream"===e?Hl:ql).writeAll(t).toUint8Array(!0)}(yu(t,i),n)}function bu(t,e){return At(e)?e(t):e||t.columnNames()}function vu(t,e,n){const i=n.format||{},r=n.align||{},s={},a={};return e.forEach((e=>{const o=function(t,e={}){let n=0,i=0,r=0,s=0,a=0,o=0;return t((t=>{if(++n,null==t)return void++i;const e=typeof t;if("object"===e&&Ct(t))++r,0===(c=t).getUTCHours()&&0===c.getUTCMinutes()&&0===c.getUTCSeconds()&&0===c.getUTCMilliseconds()&&++s;else if("number"===e&&(++a,t==t&&(0|t)!==t)){const e=t+"",n=e.indexOf(".");if(n>=0){const t=e.indexOf("e"),i=t>0?t:e.length;o=Math.max(o,i-n-1)}}var c})),{align:(i+a+r)/n>.5?"r":"l",format:{utc:r===s,digits:Math.min(o,e.maxdigits||6)}}}(function(t,e){const n=t.column(e);return e=>t.scan((t=>e(n.get(t))))}(t,e),n);a[e]=r[e]||o.align,s[e]=i[e]||o.format})),{align:a,format:s}}function _u(t,e,n=100,i,r){const s=t.data(),a=e.length;t.scan((t=>{r.row(t);for(let n=0;n$t(e)?Array.from(e):e)),i=e.maxlen||30;return n.length>i?n.slice(0,28)+"…"+("["===n[0]?"]":"}"):n}}if("number"===n){const n=e.digits||0;let i;return 0!==t&&((i=Math.abs(t))>=1e18||iAt(t)?t:()=>t))}(e),a=e.null,o=(t,e)=>xu(t,e).replace(/&/g,"&").replace(//g,">"),c=a?(t,e)=>null==t?a(t):o(t,e):o;let l=-1,u=-1;const h=(t,e,n)=>{const r=n?(t=>"c"===t?"center":"r"===t?"right":"left")(i[e]):"",a=s[t]&&s[t](e,u,l)||"",o=(r?`text-align: ${r};`+(a?" ":""):"")+a;return`<${t}${o?` style="${o}"`:""}>`};let p=h("table")+h("thead")+h("tr",l)+n.map((t=>`${h("th",t,1)}${t}`)).join("")+""+h("tbody");return _u(t,n,e.limit,e.offset,{row(t){l=t,p+=(++u?"":"")+h("tr")},cell(t,e){p+=h("td",e,1)+c(t,r[e])+""}}),p+""}function Iu(t,e=!0,n=!1){return void 0===t||t?e:n}const Au=t=>Ct(t)?Zt(t,!0):t;function Tu(t,e){for(const[n,i]of yn(e))t.set(n,i);return t}function ku(t,e,n=new Map){return Lt(e=It(e)?t.columnName(e):e)?n.set(e,e):vt(e)?e.forEach((e=>ku(t,e,n))):At(e)?ku(t,e(t),n):Nt(e)?Tu(n,e):St(`Invalid column selection: ${be(e)}`),n}function Mu(t,e){return t.toObject=e,t}function Eu(t){return vt(t)?t.map(Eu):t&&t.toObject?t.toObject():t}function Cu(){return Mu((t=>t.columnNames()),(()=>({all:[]})))}function Nu(...t){return t=t.flat(),Mu((e=>{const n=ku(e,t);return e.columnNames((t=>!n.has(t)))}),(()=>({not:Eu(t)})))}class Ou extends kt{static from(t,e){return new Ou(Bt(t,e),e)}static new(t,e){if(t instanceof Ou)return t;const n={},i=[];for(const[e,r]of yn(t))n[e]=r,i.push(e);return new Ou(n,e||i)}constructor(t,e,n,i,r,s){wu(t,Et,t);super(e=e||Object.keys(t),e.length?t[e[0]].length:0,t,n,i,r,s)}create({data:t,names:e,filter:n,groups:i,order:r}){const s=void 0!==n?n:this.mask();return new Ou(t||this._data,e||(t?null:this._names),s,void 0!==i?i:function(t,e){if(!t||!e)return t;const{keys:n,rows:i,size:r}=t,s=new Int32Array(r);e.scan((t=>s[n[t]]=1));const a=s.reduce(((t,e)=>t+e),0);if(a===r)return t;const o=Array(a);let c=0;for(let t=0;tl[t]=s[n[t]])),{...t,keys:l,rows:o,size:c}}(this._group,n&&s),void 0!==r?r:this._order,this._params)}assign(...t){const e=this.numRows(),n=this.reify(),i=Ut(n).groupby(n.groups());return t.forEach((t=>{(t=Ou.new(t)).numRows()!==e&&St("Assign row counts do not match"),(t=t.reify()).columnNames((e=>i.add(e,t.column(e))))})),this.create(i.new())}columns(){return this._data}column(t){return this._data[t]}columnAt(t){return this._data[this._names[t]]}array(t,e=Array){const n=this.column(t),i=new e(this.numRows());let r=-1;return this.scan((t=>i[++r]=n.get(t)),!0),i}get(t,e=0){const n=this.column(t);return this.isFiltered()||this.isOrdered()?n.get(this.indices()[e]):n.get(e)}getter(t){const e=this.column(t),n=this.isFiltered()||this.isOrdered()?this.indices():null;return n?t=>e.get(n[t]):e?t=>e.get(t):St(`Unrecognized column: ${t}`)}object(t=0){return Lu(this)(t)}objects(t={}){const{grouped:e,limit:n,offset:i}=t,r=_n(ku(this,t.columns||Cu())),s=[];if(this.scan(((t,e)=>s.push(r(t,e))),!0,n,i),e&&this.isGrouped()){const t=[];return this.scan((e=>t.push(e)),!0,n,i),Ee(this,t,s,e)}return s}*[Symbol.iterator](){const t=Lu(this),e=this.numRows();for(let n=0;nt.forEach(e):t=>this.scan(t,!0),o=n.length;i={};for(let t=0;tc[++l]=o.get(t)))}this.isGrouped()&&(r=function(t,e,n,i){const{keys:r,rows:s,size:a}=t;let o=s,c=a,l=null;if(n){l=new Int32Array(a),e((t=>l[r[t]]=1));const t=l.reduce(((t,e)=>t+e),0);if(t!==a){o=Array(t),c=0;for(let t=0;th[++u]=l[r[t]]:t=>h[++u]=r[t]),{...t,keys:h,rows:o,size:c}}(this.groups(),a,!!t,e))}var s;return this.create({data:i,names:n,groups:r,filter:null,order:null})}transform(...t){return t.flat().reduce(((t,e)=>e(t)),this)}toArrow(t){return yu(this,t)}toArrowBuffer(t){return gu(this,t)}toCSV(t){return function(t,e={}){const n=bu(t,e.columns),i=e.format||{},r=e.delimiter||",",s=new RegExp(`["${r}\n\r]`),a=t=>null==t?"":Ct(t)?Zt(t,!0):s.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t,o=n.map(a);let c="";return _u(t,n,e.limit||1/0,e.offset,{row(){c+=o.join(r)+"\n"},cell(t,e,n){o[n]=a(i[e]?i[e](t):t)}}),c+o.join(r)}(this,t)}toHTML(t){return Su(this,t)}toJSON(t){return function(t,e={}){const n=Iu(e.schema),i=e.format||{},r=bu(t,e.columns);let s="{";return n&&(s+='"schema":{"fields":'+JSON.stringify(r.map((t=>({name:t}))))+'},"data":{'),r.forEach(((n,r)=>{s+=(r?",":"")+JSON.stringify(n)+":[";const a=t.column(n),o=i[n]||Au;let c=-1;t.scan((t=>{const e=a.get(t);s+=(++c?",":"")+JSON.stringify(o(e))}),!0,e.limit,e.offset),s+="]"})),s+"}"+(n?"}":"")}(this,t)}toMarkdown(t){return function(t,e={}){const n=bu(t,e.columns),{align:i,format:r}=vu(t,n,e),s=t=>t.replace(/\|/g,"\\|");let a="|"+n.map(s).join("|")+"|\n|"+n.map((t=>{return"c"===(e=i[t])?":-:":"r"===e?"-:":":-";var e})).join("|")+"|";return _u(t,n,e.limit,e.offset,{row(){a+="\n|"},cell(t,e){a+=s(xu(t,r[e]))+"|"}}),a+"\n"}(this,t)}}function Lu(t){let e=t._builder;if(!e){const n=_n(t.columnNames()),i=t.data();if(t.isOrdered()||t.isFiltered()){const r=t.indices();e=t=>n(r[t],i)}else e=t=>n(t,i);t._builder=e}return e}class Bu{constructor(t){this._outputs=t}size(){return this._outputs.length}outputs(){return this._outputs}init(){return{}}add(){}rem(){}write(){}}function Du(t,e,n,i){const r=n[t.type]||n.Default;if(r&&!1===r(t,e,i))return;const s=$u[t.type];s&&s(t,e,n)}const Fu=(t,e,n)=>{Du(t.argument,e,n,t)},Vu=(t,e,n)=>{Du(t.left,e,n,t),Du(t.right,e,n,t)},Uu=(t,e,n)=>{Du(t.test,e,n,t),Du(t.consequent,e,n,t),t.alternate&&Du(t.alternate,e,n,t)},Pu=(t,e,n)=>{ju(t.params,e,n,t),Du(t.body,e,n,t)},Ru=(t,e,n)=>{Du(t.callee,e,n,t),ju(t.arguments,e,n,t)},ju=(t,e,n,i)=>{t.forEach((t=>Du(t,e,n,i)))},$u={TemplateLiteral:(t,e,n)=>{ju(t.expressions,e,n,t),ju(t.quasis,e,n,t)},MemberExpression:(t,e,n)=>{Du(t.object,e,n,t),Du(t.property,e,n,t)},CallExpression:Ru,NewExpression:Ru,ArrayExpression:(t,e,n)=>{ju(t.elements,e,n,t)},AssignmentExpression:Vu,AwaitExpression:Fu,BinaryExpression:Vu,LogicalExpression:Vu,UnaryExpression:Fu,UpdateExpression:Fu,ConditionalExpression:Uu,ObjectExpression:(t,e,n)=>{ju(t.properties,e,n,t)},Property:(t,e,n)=>{Du(t.key,e,n,t),Du(t.value,e,n,t)},ArrowFunctionExpression:Pu,FunctionExpression:Pu,FunctionDeclaration:Pu,VariableDeclaration:(t,e,n)=>{ju(t.declarations,e,n,t)},VariableDeclarator:(t,e,n)=>{Du(t.id,e,n,t),Du(t.init,e,n,t)},SpreadElement:(t,e,n)=>{Du(t.argument,e,n,t)},BlockStatement:(t,e,n)=>{ju(t.body,e,n,t)},ExpressionStatement:(t,e,n)=>{Du(t.expression,e,n,t)},IfStatement:Uu,ForStatement:(t,e,n)=>{Du(t.init,e,n,t),Du(t.test,e,n,t),Du(t.update,e,n,t),Du(t.body,e,n,t)},WhileStatement:(t,e,n)=>{Du(t.test,e,n,t),Du(t.body,e,n,t)},DoWhileStatement:(t,e,n)=>{Du(t.body,e,n,t),Du(t.test,e,n,t)},SwitchStatement:(t,e,n)=>{Du(t.discriminant,e,n,t),ju(t.cases,e,n,t)},SwitchCase:(t,e,n)=>{t.test&&Du(t.test,e,n,t),ju(t.consequent,e,n,t)},ReturnStatement:Fu,Program:(t,e,n)=>{Du(t.body[0],e,n,t)}};function zu(t){delete t.start,delete t.end,delete t.optional}function Hu(t){zu(t),delete t.object,delete t.property,delete t.computed,t.table||delete t.table}function qu(t,e){return e&&e.type===t}const Yu="Escaped functions are not valid as rollup or pivot values.";function Wu(t,e,n){t.aggronly&&St(Yu);const i="(row,data)=>fn("+vn(t.table.columnNames())+",$)";return{escape:dn.escape(i,(r=e.expr,At(r)?r:()=>r),n)};var r}var Gu=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,81,2,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,9,5351,0,7,14,13835,9,87,9,39,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,4706,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,983,6,110,6,6,9,4759,9,787719,239],Ku=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,68,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,4026,582,8634,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,757,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,3104,541,1507,4938,6,4191],Qu="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟊꟐꟑꟓꟕ-ꟙꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Ju={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},Zu="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",Xu={5:Zu,"5module":Zu+" export import",6:Zu+" const class extends export import super"},th=/^in(stanceof)?$/,eh=new RegExp("["+Qu+"]"),nh=new RegExp("["+Qu+"‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࢘-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_]");function ih(t,e){for(var n=65536,i=0;it)return!1;if((n+=e[i+1])>=t)return!0}return!1}function rh(t,e){return t<65?36===t:t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&eh.test(String.fromCharCode(t)):!1!==e&&ih(t,Ku)))}function sh(t,e){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&nh.test(String.fromCharCode(t)):!1!==e&&(ih(t,Ku)||ih(t,Gu)))))}var ah=function(t,e){void 0===e&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null};function oh(t,e){return new ah(t,{beforeExpr:!0,binop:e})}var ch={beforeExpr:!0},lh={startsExpr:!0},uh={};function hh(t,e){return void 0===e&&(e={}),e.keyword=t,uh[t]=new ah(t,e)}var ph={num:new ah("num",lh),regexp:new ah("regexp",lh),string:new ah("string",lh),name:new ah("name",lh),privateId:new ah("privateId",lh),eof:new ah("eof"),bracketL:new ah("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new ah("]"),braceL:new ah("{",{beforeExpr:!0,startsExpr:!0}),braceR:new ah("}"),parenL:new ah("(",{beforeExpr:!0,startsExpr:!0}),parenR:new ah(")"),comma:new ah(",",ch),semi:new ah(";",ch),colon:new ah(":",ch),dot:new ah("."),question:new ah("?",ch),questionDot:new ah("?."),arrow:new ah("=>",ch),template:new ah("template"),invalidTemplate:new ah("invalidTemplate"),ellipsis:new ah("...",ch),backQuote:new ah("`",lh),dollarBraceL:new ah("${",{beforeExpr:!0,startsExpr:!0}),eq:new ah("=",{beforeExpr:!0,isAssign:!0}),assign:new ah("_=",{beforeExpr:!0,isAssign:!0}),incDec:new ah("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new ah("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:oh("||",1),logicalAND:oh("&&",2),bitwiseOR:oh("|",3),bitwiseXOR:oh("^",4),bitwiseAND:oh("&",5),equality:oh("==/!=/===/!==",6),relational:oh("/<=/>=",7),bitShift:oh("<>/>>>",8),plusMin:new ah("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:oh("%",10),star:oh("*",10),slash:oh("/",10),starstar:new ah("**",{beforeExpr:!0}),coalesce:oh("??",1),_break:hh("break"),_case:hh("case",ch),_catch:hh("catch"),_continue:hh("continue"),_debugger:hh("debugger"),_default:hh("default",ch),_do:hh("do",{isLoop:!0,beforeExpr:!0}),_else:hh("else",ch),_finally:hh("finally"),_for:hh("for",{isLoop:!0}),_function:hh("function",lh),_if:hh("if"),_return:hh("return",ch),_switch:hh("switch"),_throw:hh("throw",ch),_try:hh("try"),_var:hh("var"),_const:hh("const"),_while:hh("while",{isLoop:!0}),_with:hh("with"),_new:hh("new",{beforeExpr:!0,startsExpr:!0}),_this:hh("this",lh),_super:hh("super",lh),_class:hh("class",lh),_extends:hh("extends",ch),_export:hh("export"),_import:hh("import",lh),_null:hh("null",lh),_true:hh("true",lh),_false:hh("false",lh),_in:hh("in",{beforeExpr:!0,binop:7}),_instanceof:hh("instanceof",{beforeExpr:!0,binop:7}),_typeof:hh("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:hh("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:hh("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},dh=/\r\n?|\n|\u2028|\u2029/,fh=new RegExp(dh.source,"g");function mh(t){return 10===t||13===t||8232===t||8233===t}function yh(t,e,n){void 0===n&&(n=t.length);for(var i=e;i>10),56320+(1023&t)))}var Th=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,kh=function(t,e){this.line=t,this.column=e};kh.prototype.offset=function(t){return new kh(this.line,this.column+t)};var Mh=function(t,e,n){this.start=e,this.end=n,null!==t.sourceFile&&(this.source=t.sourceFile)};function Eh(t,e){for(var n=1,i=0;;){var r=yh(t,i,e);if(r<0)return new kh(n,e-i);++n,i=r}}var Ch={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Nh=!1;function Oh(t){var e={};for(var n in Ch)e[n]=t&&wh(t,n)?t[n]:Ch[n];if("latest"===e.ecmaVersion?e.ecmaVersion=1e8:null==e.ecmaVersion?(!Nh&&"object"==typeof console&&console.warn&&(Nh=!0,console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.")),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),null==e.allowReserved&&(e.allowReserved=e.ecmaVersion<5),t&&null!=t.allowHashBang||(e.allowHashBang=e.ecmaVersion>=14),Sh(e.onToken)){var i=e.onToken;e.onToken=function(t){return i.push(t)}}return Sh(e.onComment)&&(e.onComment=function(t,e){return function(n,i,r,s,a,o){var c={type:n?"Block":"Line",value:i,start:r,end:s};t.locations&&(c.loc=new Mh(this,a,o)),t.ranges&&(c.range=[r,s]),e.push(c)}}(e,e.onComment)),e}var Lh=256;function Bh(t,e){return 2|(t?4:0)|(e?8:0)}var Dh=function(t,e,n){this.options=t=Oh(t),this.sourceFile=t.sourceFile,this.keywords=Ih(Xu[t.ecmaVersion>=6?6:"module"===t.sourceType?"5module":5]);var i="";!0!==t.allowReserved&&(i=Ju[t.ecmaVersion>=6?6:5===t.ecmaVersion?5:3],"module"===t.sourceType&&(i+=" await")),this.reservedWords=Ih(i);var r=(i?i+" ":"")+Ju.strict;this.reservedWordsStrict=Ih(r),this.reservedWordsStrictBind=Ih(r+" "+Ju.strictBind),this.input=String(e),this.containsEsc=!1,n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(dh).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=ph.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===t.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),0===this.pos&&t.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(1),this.regexpState=null,this.privateNameStack=[]},Fh={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};Dh.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)},Fh.inFunction.get=function(){return(2&this.currentVarScope().flags)>0},Fh.inGenerator.get=function(){return(8&this.currentVarScope().flags)>0&&!this.currentVarScope().inClassFieldInit},Fh.inAsync.get=function(){return(4&this.currentVarScope().flags)>0&&!this.currentVarScope().inClassFieldInit},Fh.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t];if(e.inClassFieldInit||e.flags&Lh)return!1;if(2&e.flags)return(4&e.flags)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Fh.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags,n=t.inClassFieldInit;return(64&e)>0||n||this.options.allowSuperOutsideMethod},Fh.allowDirectSuper.get=function(){return(128&this.currentThisScope().flags)>0},Fh.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Fh.allowNewDotTarget.get=function(){var t=this.currentThisScope(),e=t.flags,n=t.inClassFieldInit;return(258&e)>0||n},Fh.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Lh)>0},Dh.extend=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var n=this,i=0;i=,?^&]/.test(r)||"!"===r&&"="===this.input.charAt(i+1))}t+=e[0].length,bh.lastIndex=t,t+=bh.exec(this.input)[0].length,";"===this.input[t]&&t++}},Vh.eat=function(t){return this.type===t&&(this.next(),!0)},Vh.isContextual=function(t){return this.type===ph.name&&this.value===t&&!this.containsEsc},Vh.eatContextual=function(t){return!!this.isContextual(t)&&(this.next(),!0)},Vh.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},Vh.canInsertSemicolon=function(){return this.type===ph.eof||this.type===ph.braceR||dh.test(this.input.slice(this.lastTokEnd,this.start))},Vh.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Vh.semicolon=function(){this.eat(ph.semi)||this.insertSemicolon()||this.unexpected()},Vh.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0},Vh.expect=function(t){this.eat(t)||this.unexpected()},Vh.unexpected=function(t){this.raise(null!=t?t:this.start,"Unexpected token")};var Ph=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Vh.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var n=e?t.parenthesizedAssign:t.parenthesizedBind;n>-1&&this.raiseRecoverable(n,e?"Assigning to rvalue":"Parenthesized pattern")}},Vh.checkExpressionErrors=function(t,e){if(!t)return!1;var n=t.shorthandAssign,i=t.doubleProto;if(!e)return n>=0||i>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),i>=0&&this.raiseRecoverable(i,"Redefinition of __proto__ property")},Vh.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos55295&&i<56320)return!0;if(rh(i,!0)){for(var r=n+1;sh(i=this.input.charCodeAt(r),!0);)++r;if(92===i||i>55295&&i<56320)return!0;var s=this.input.slice(n,r);if(!th.test(s))return!0}return!1},Rh.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;bh.lastIndex=this.pos;var t,e=bh.exec(this.input),n=this.pos+e[0].length;return!(dh.test(this.input.slice(this.pos,n))||"function"!==this.input.slice(n,n+8)||n+8!==this.input.length&&(sh(t=this.input.charCodeAt(n+8))||t>55295&&t<56320))},Rh.parseStatement=function(t,e,n){var i,r=this.type,s=this.startNode();switch(this.isLet(t)&&(r=ph._var,i="let"),r){case ph._break:case ph._continue:return this.parseBreakContinueStatement(s,r.keyword);case ph._debugger:return this.parseDebuggerStatement(s);case ph._do:return this.parseDoStatement(s);case ph._for:return this.parseForStatement(s);case ph._function:return t&&(this.strict||"if"!==t&&"label"!==t)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!t);case ph._class:return t&&this.unexpected(),this.parseClass(s,!0);case ph._if:return this.parseIfStatement(s);case ph._return:return this.parseReturnStatement(s);case ph._switch:return this.parseSwitchStatement(s);case ph._throw:return this.parseThrowStatement(s);case ph._try:return this.parseTryStatement(s);case ph._const:case ph._var:return i=i||this.value,t&&"var"!==i&&this.unexpected(),this.parseVarStatement(s,i);case ph._while:return this.parseWhileStatement(s);case ph._with:return this.parseWithStatement(s);case ph.braceL:return this.parseBlock(!0,s);case ph.semi:return this.parseEmptyStatement(s);case ph._export:case ph._import:if(this.options.ecmaVersion>10&&r===ph._import){bh.lastIndex=this.pos;var a=bh.exec(this.input),o=this.pos+a[0].length,c=this.input.charCodeAt(o);if(40===c||46===c)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===ph._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!t);var l=this.value,u=this.parseExpression();return r===ph.name&&"Identifier"===u.type&&this.eat(ph.colon)?this.parseLabeledStatement(s,l,u,t):this.parseExpressionStatement(s,u)}},Rh.parseBreakContinueStatement=function(t,e){var n="break"===e;this.next(),this.eat(ph.semi)||this.insertSemicolon()?t.label=null:this.type!==ph.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var i=0;i=6?this.eat(ph.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")},Rh.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(jh),this.enterScope(0),this.expect(ph.parenL),this.type===ph.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var n=this.isLet();if(this.type===ph._var||this.type===ph._const||n){var i=this.startNode(),r=n?"let":this.value;return this.next(),this.parseVar(i,!0,r),this.finishNode(i,"VariableDeclaration"),(this.type===ph._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===i.declarations.length?(this.options.ecmaVersion>=9&&(this.type===ph._in?e>-1&&this.unexpected(e):t.await=e>-1),this.parseForIn(t,i)):(e>-1&&this.unexpected(e),this.parseFor(t,i))}var s=this.isContextual("let"),a=!1,o=new Ph,c=this.parseExpression(!(e>-1)||"await",o);return this.type===ph._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(this.options.ecmaVersion>=9&&(this.type===ph._in?e>-1&&this.unexpected(e):t.await=e>-1),s&&a&&this.raise(c.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(c,!1,o),this.checkLValPattern(c),this.parseForIn(t,c)):(this.checkExpressionErrors(o,!0),e>-1&&this.unexpected(e),this.parseFor(t,c))},Rh.parseFunctionStatement=function(t,e,n){return this.next(),this.parseFunction(t,Hh|(n?0:qh),!1,e)},Rh.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement("if"),t.alternate=this.eat(ph._else)?this.parseStatement("if"):null,this.finishNode(t,"IfStatement")},Rh.parseReturnStatement=function(t){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(ph.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")},Rh.parseSwitchStatement=function(t){var e;this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(ph.braceL),this.labels.push($h),this.enterScope(0);for(var n=!1;this.type!==ph.braceR;)if(this.type===ph._case||this.type===ph._default){var i=this.type===ph._case;e&&this.finishNode(e,"SwitchCase"),t.cases.push(e=this.startNode()),e.consequent=[],this.next(),i?e.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,e.test=null),this.expect(ph.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")},Rh.parseThrowStatement=function(t){return this.next(),dh.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var zh=[];Rh.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===ph._catch){var e=this.startNode();if(this.next(),this.eat(ph.parenL)){e.param=this.parseBindingAtom();var n="Identifier"===e.param.type;this.enterScope(n?32:0),this.checkLValPattern(e.param,n?4:2),this.expect(ph.parenR)}else this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0);e.body=this.parseBlock(!1),this.exitScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(ph._finally)?this.parseBlock():null,t.handler||t.finalizer||this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")},Rh.parseVarStatement=function(t,e){return this.next(),this.parseVar(t,!1,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")},Rh.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(jh),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")},Rh.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement("with"),this.finishNode(t,"WithStatement")},Rh.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")},Rh.parseLabeledStatement=function(t,e,n,i){for(var r=0,s=this.labels;r=0;o--){var c=this.labels[o];if(c.statementStart!==t.start)break;c.statementStart=this.start,c.kind=a}return this.labels.push({name:e,kind:a,statementStart:this.start}),t.body=this.parseStatement(i?-1===i.indexOf("label")?i+"label":i:"label"),this.labels.pop(),t.label=n,this.finishNode(t,"LabeledStatement")},Rh.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")},Rh.parseBlock=function(t,e,n){for(void 0===t&&(t=!0),void 0===e&&(e=this.startNode()),e.body=[],this.expect(ph.braceL),t&&this.enterScope(0);this.type!==ph.braceR;){var i=this.parseStatement(null);e.body.push(i)}return n&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(e,"BlockStatement")},Rh.parseFor=function(t,e){return t.init=e,this.expect(ph.semi),t.test=this.type===ph.semi?null:this.parseExpression(),this.expect(ph.semi),t.update=this.type===ph.parenR?null:this.parseExpression(),this.expect(ph.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,"ForStatement")},Rh.parseForIn=function(t,e){var n=this.type===ph._in;return this.next(),"VariableDeclaration"===e.type&&null!=e.declarations[0].init&&(!n||this.options.ecmaVersion<8||this.strict||"var"!==e.kind||"Identifier"!==e.declarations[0].id.type)&&this.raise(e.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),t.left=e,t.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(ph.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,n?"ForInStatement":"ForOfStatement")},Rh.parseVar=function(t,e,n){for(t.declarations=[],t.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(ph.eq)?i.init=this.parseMaybeAssign(e):"const"!==n||this.type===ph._in||this.options.ecmaVersion>=6&&this.isContextual("of")?"Identifier"===i.id.type||e&&(this.type===ph._in||this.isContextual("of"))?i.init=null:this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):this.unexpected(),t.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(ph.comma))break}return t},Rh.parseVarId=function(t,e){t.id=this.parseBindingAtom(),this.checkLValPattern(t.id,"var"===e?1:2,!1)};var Hh=1,qh=2;function Yh(t,e){var n=e.key.name,i=t[n],r="true";return"MethodDefinition"!==e.type||"get"!==e.kind&&"set"!==e.kind||(r=(e.static?"s":"i")+e.kind),"iget"===i&&"iset"===r||"iset"===i&&"iget"===r||"sget"===i&&"sset"===r||"sset"===i&&"sget"===r?(t[n]="true",!1):!!i||(t[n]=r,!1)}function Wh(t,e){var n=t.computed,i=t.key;return!n&&("Identifier"===i.type&&i.name===e||"Literal"===i.type&&i.value===e)}Rh.parseFunction=function(t,e,n,i,r){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!i)&&(this.type===ph.star&&e&qh&&this.unexpected(),t.generator=this.eat(ph.star)),this.options.ecmaVersion>=8&&(t.async=!!i),e&Hh&&(t.id=4&e&&this.type!==ph.name?null:this.parseIdent(),!t.id||e&qh||this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?1:2:3));var s=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Bh(t.async,t.generator)),e&Hh||(t.id=this.type===ph.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,n,!1,r),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(t,e&Hh?"FunctionDeclaration":"FunctionExpression")},Rh.parseFunctionParams=function(t){this.expect(ph.parenL),t.params=this.parseBindingList(ph.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},Rh.parseClass=function(t,e){this.next();var n=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var i=this.enterClassBody(),r=this.startNode(),s=!1;for(r.body=[],this.expect(ph.braceL);this.type!==ph.braceR;){var a=this.parseClassElement(null!==t.superClass);a&&(r.body.push(a),"MethodDefinition"===a.type&&"constructor"===a.kind?(s&&this.raise(a.start,"Duplicate constructor in the same class"),s=!0):a.key&&"PrivateIdentifier"===a.key.type&&Yh(i,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=n,this.next(),t.body=this.finishNode(r,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")},Rh.parseClassElement=function(t){if(this.eat(ph.semi))return null;var e=this.options.ecmaVersion,n=this.startNode(),i="",r=!1,s=!1,a="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(ph.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===ph.star?o=!0:i="static"}if(n.static=o,!i&&e>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==ph.star||this.canInsertSemicolon()?i="async":s=!0),!i&&(e>=9||!s)&&this.eat(ph.star)&&(r=!0),!i&&!s&&!r){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=c:i=c)}if(i?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=i,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),e<13||this.type===ph.parenL||"method"!==a||r||s){var l=!n.static&&Wh(n,"constructor"),u=l&&t;l&&"method"!==a&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=l?"constructor":a,this.parseClassMethod(n,r,s,u)}else this.parseClassField(n);return n},Rh.isClassElementNameStart=function(){return this.type===ph.name||this.type===ph.privateId||this.type===ph.num||this.type===ph.string||this.type===ph.bracketL||this.type.keyword},Rh.parseClassElementName=function(t){this.type===ph.privateId?("constructor"===this.value&&this.raise(this.start,"Classes can't have an element named '#constructor'"),t.computed=!1,t.key=this.parsePrivateIdent()):this.parsePropertyName(t)},Rh.parseClassMethod=function(t,e,n,i){var r=t.key;"constructor"===t.kind?(e&&this.raise(r.start,"Constructor can't be a generator"),n&&this.raise(r.start,"Constructor can't be an async method")):t.static&&Wh(t,"prototype")&&this.raise(r.start,"Classes may not have a static property named prototype");var s=t.value=this.parseMethod(e,n,i);return"get"===t.kind&&0!==s.params.length&&this.raiseRecoverable(s.start,"getter should have no params"),"set"===t.kind&&1!==s.params.length&&this.raiseRecoverable(s.start,"setter should have exactly one param"),"set"===t.kind&&"RestElement"===s.params[0].type&&this.raiseRecoverable(s.params[0].start,"Setter cannot use rest params"),this.finishNode(t,"MethodDefinition")},Rh.parseClassField=function(t){if(Wh(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&&Wh(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(ph.eq)){var e=this.currentThisScope(),n=e.inClassFieldInit;e.inClassFieldInit=!0,t.value=this.parseMaybeAssign(),e.inClassFieldInit=n}else t.value=null;return this.semicolon(),this.finishNode(t,"PropertyDefinition")},Rh.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(320);this.type!==ph.braceR;){var n=this.parseStatement(null);t.body.push(n)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(t,"StaticBlock")},Rh.parseClassId=function(t,e){this.type===ph.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,2,!1)):(!0===e&&this.unexpected(),t.id=null)},Rh.parseClassSuper=function(t){t.superClass=this.eat(ph._extends)?this.parseExprSubscripts(null,!1):null},Rh.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared},Rh.exitClassBody=function(){for(var t=this.privateNameStack.pop(),e=t.declared,n=t.used,i=this.privateNameStack.length,r=0===i?null:this.privateNameStack[i-1],s=0;s=11&&(this.eatContextual("as")?(t.exported=this.parseModuleExportName(),this.checkExport(e,t.exported,this.lastTokStart)):t.exported=null),this.expectContextual("from"),this.type!==ph.string&&this.unexpected(),t.source=this.parseExprAtom(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration");if(this.eat(ph._default)){var n;if(this.checkExport(e,"default",this.lastTokStart),this.type===ph._function||(n=this.isAsyncFunction())){var i=this.startNode();this.next(),n&&this.next(),t.declaration=this.parseFunction(i,4|Hh,!1,n)}else if(this.type===ph._class){var r=this.startNode();t.declaration=this.parseClass(r,"nullableID")}else t.declaration=this.parseMaybeAssign(),this.semicolon();return this.finishNode(t,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())t.declaration=this.parseStatement(null),"VariableDeclaration"===t.declaration.type?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==ph.string&&this.unexpected(),t.source=this.parseExprAtom();else{for(var s=0,a=t.specifiers;s=13&&this.type===ph.string){var t=this.parseLiteral(this.value);return Th.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)},Rh.adaptDirectivePrologue=function(t){for(var e=0;e=5&&"ExpressionStatement"===t.type&&"Literal"===t.expression.type&&"string"==typeof t.expression.value&&('"'===this.input[t.start]||"'"===this.input[t.start])};var Gh=Dh.prototype;Gh.toAssignable=function(t,e,n){if(this.options.ecmaVersion>=6&&t)switch(t.type){case"Identifier":this.inAsync&&"await"===t.name&&this.raise(t.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var i=0,r=t.properties;i=8&&!a&&"async"===o.name&&!this.canInsertSemicolon()&&this.eat(ph._function))return this.overrideContext(Qh.f_expr),this.parseFunction(this.startNodeAt(r,s),0,!1,!0,e);if(i&&!this.canInsertSemicolon()){if(this.eat(ph.arrow))return this.parseArrowExpression(this.startNodeAt(r,s),[o],!1,e);if(this.options.ecmaVersion>=8&&"async"===o.name&&this.type===ph.name&&!a&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return o=this.parseIdent(!1),!this.canInsertSemicolon()&&this.eat(ph.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,s),[o],!0,e)}return o;case ph.regexp:var c=this.value;return(n=this.parseLiteral(c.value)).regex={pattern:c.pattern,flags:c.flags},n;case ph.num:case ph.string:return this.parseLiteral(this.value);case ph._null:case ph._true:case ph._false:return(n=this.startNode()).value=this.type===ph._null?null:this.type===ph._true,n.raw=this.type.keyword,this.next(),this.finishNode(n,"Literal");case ph.parenL:var l=this.start,u=this.parseParenAndDistinguishExpression(i,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(u)&&(t.parenthesizedAssign=l),t.parenthesizedBind<0&&(t.parenthesizedBind=l)),u;case ph.bracketL:return n=this.startNode(),this.next(),n.elements=this.parseExprList(ph.bracketR,!0,!0,t),this.finishNode(n,"ArrayExpression");case ph.braceL:return this.overrideContext(Qh.b_expr),this.parseObj(!1,t);case ph._function:return n=this.startNode(),this.next(),this.parseFunction(n,0);case ph._class:return this.parseClass(this.startNode(),!1);case ph._new:return this.parseNew();case ph.backQuote:return this.parseTemplate();case ph._import:return this.options.ecmaVersion>=11?this.parseExprImport():this.unexpected();default:this.unexpected()}},Zh.parseExprImport=function(){var t=this.startNode();this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import");var e=this.parseIdent(!0);switch(this.type){case ph.parenL:return this.parseDynamicImport(t);case ph.dot:return t.meta=e,this.parseImportMeta(t);default:this.unexpected()}},Zh.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),!this.eat(ph.parenR)){var e=this.start;this.eat(ph.comma)&&this.eat(ph.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(t,"ImportExpression")},Zh.parseImportMeta=function(t){this.next();var e=this.containsEsc;return t.property=this.parseIdent(!0),"meta"!==t.property.name&&this.raiseRecoverable(t.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(t.start,"'import.meta' must not contain escaped characters"),"module"===this.options.sourceType||this.options.allowImportExportEverywhere||this.raiseRecoverable(t.start,"Cannot use 'import.meta' outside a module"),this.finishNode(t,"MetaProperty")},Zh.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),110===e.raw.charCodeAt(e.raw.length-1)&&(e.bigint=e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")},Zh.parseParenExpression=function(){this.expect(ph.parenL);var t=this.parseExpression();return this.expect(ph.parenR),t},Zh.parseParenAndDistinguishExpression=function(t,e){var n,i=this.start,r=this.startLoc,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,c=this.startLoc,l=[],u=!0,h=!1,p=new Ph,d=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==ph.parenR;){if(u?u=!1:this.expect(ph.comma),s&&this.afterTrailingComma(ph.parenR,!0)){h=!0;break}if(this.type===ph.ellipsis){a=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===ph.comma&&this.raise(this.start,"Comma is not permitted after the rest element");break}l.push(this.parseMaybeAssign(!1,p,this.parseParenItem))}var m=this.lastTokEnd,y=this.lastTokEndLoc;if(this.expect(ph.parenR),t&&!this.canInsertSemicolon()&&this.eat(ph.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=d,this.awaitPos=f,this.parseParenArrowList(i,r,l,e);l.length&&!h||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(p,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?((n=this.startNodeAt(o,c)).expressions=l,this.finishNodeAt(n,"SequenceExpression",m,y)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var g=this.startNodeAt(i,r);return g.expression=n,this.finishNode(g,"ParenthesizedExpression")}return n},Zh.parseParenItem=function(t){return t},Zh.parseParenArrowList=function(t,e,n,i){return this.parseArrowExpression(this.startNodeAt(t,e),n,!1,i)};var tp=[];Zh.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var t=this.startNode(),e=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(ph.dot)){t.meta=e;var n=this.containsEsc;return t.property=this.parseIdent(!0),"target"!==t.property.name&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(t.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(t.start,"'new.target' can only be used in functions and class static block"),this.finishNode(t,"MetaProperty")}var i=this.start,r=this.startLoc,s=this.type===ph._import;return t.callee=this.parseSubscripts(this.parseExprAtom(),i,r,!0,!1),s&&"ImportExpression"===t.callee.type&&this.raise(i,"Cannot use new with import()"),this.eat(ph.parenL)?t.arguments=this.parseExprList(ph.parenR,this.options.ecmaVersion>=8,!1):t.arguments=tp,this.finishNode(t,"NewExpression")},Zh.parseTemplateElement=function(t){var e=t.isTagged,n=this.startNode();return this.type===ph.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value,cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===ph.backQuote,this.finishNode(n,"TemplateElement")},Zh.parseTemplate=function(t){void 0===t&&(t={});var e=t.isTagged;void 0===e&&(e=!1);var n=this.startNode();this.next(),n.expressions=[];var i=this.parseTemplateElement({isTagged:e});for(n.quasis=[i];!i.tail;)this.type===ph.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(ph.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(ph.braceR),n.quasis.push(i=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(n,"TemplateLiteral")},Zh.isAsyncProp=function(t){return!t.computed&&"Identifier"===t.key.type&&"async"===t.key.name&&(this.type===ph.name||this.type===ph.num||this.type===ph.string||this.type===ph.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===ph.star)&&!dh.test(this.input.slice(this.lastTokEnd,this.start))},Zh.parseObj=function(t,e){var n=this.startNode(),i=!0,r={};for(n.properties=[],this.next();!this.eat(ph.braceR);){if(i)i=!1;else if(this.expect(ph.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(ph.braceR))break;var s=this.parseProperty(t,e);t||this.checkPropClash(s,r,e),n.properties.push(s)}return this.finishNode(n,t?"ObjectPattern":"ObjectExpression")},Zh.parseProperty=function(t,e){var n,i,r,s,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(ph.ellipsis))return t?(a.argument=this.parseIdent(!1),this.type===ph.comma&&this.raise(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(a.argument=this.parseMaybeAssign(!1,e),this.type===ph.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(t||e)&&(r=this.start,s=this.startLoc),t||(n=this.eat(ph.star)));var o=this.containsEsc;return this.parsePropertyName(a),!t&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(i=!0,n=this.options.ecmaVersion>=9&&this.eat(ph.star),this.parsePropertyName(a)):i=!1,this.parsePropertyValue(a,t,n,i,r,s,e,o),this.finishNode(a,"Property")},Zh.parsePropertyValue=function(t,e,n,i,r,s,a,o){if((n||i)&&this.type===ph.colon&&this.unexpected(),this.eat(ph.colon))t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init";else if(this.options.ecmaVersion>=6&&this.type===ph.parenL)e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(n,i);else if(e||o||!(this.options.ecmaVersion>=5)||t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||this.type===ph.comma||this.type===ph.braceR||this.type===ph.eq)this.options.ecmaVersion>=6&&!t.computed&&"Identifier"===t.key.type?((n||i)&&this.unexpected(),this.checkUnreserved(t.key),"await"!==t.key.name||this.awaitIdentPos||(this.awaitIdentPos=r),t.kind="init",e?t.value=this.parseMaybeDefault(r,s,this.copyNode(t.key)):this.type===ph.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(r,s,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.shorthand=!0):this.unexpected();else{(n||i)&&this.unexpected(),t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var c="get"===t.kind?0:1;if(t.value.params.length!==c){var l=t.value.start;"get"===t.kind?this.raiseRecoverable(l,"getter should have no params"):this.raiseRecoverable(l,"setter should have exactly one param")}else"set"===t.kind&&"RestElement"===t.value.params[0].type&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")}},Zh.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(ph.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(ph.bracketR),t.key;t.computed=!1}return t.key=this.type===ph.num||this.type===ph.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},Zh.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},Zh.parseMethod=function(t,e,n){var i=this.startNode(),r=this.yieldPos,s=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(i),this.options.ecmaVersion>=6&&(i.generator=t),this.options.ecmaVersion>=8&&(i.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(64|Bh(e,i.generator)|(n?128:0)),this.expect(ph.parenL),i.params=this.parseBindingList(ph.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(i,!1,!0,!1),this.yieldPos=r,this.awaitPos=s,this.awaitIdentPos=a,this.finishNode(i,"FunctionExpression")},Zh.parseArrowExpression=function(t,e,n,i){var r=this.yieldPos,s=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(16|Bh(n,!1)),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0,!1,i),this.yieldPos=r,this.awaitPos=s,this.awaitIdentPos=a,this.finishNode(t,"ArrowFunctionExpression")},Zh.parseFunctionBody=function(t,e,n,i){var r=e&&this.type!==ph.braceL,s=this.strict,a=!1;if(r)t.body=this.parseMaybeAssign(i),t.expression=!0,this.checkParams(t,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);s&&!o||(a=this.strictDirective(this.end))&&o&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list");var c=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(t,!s&&!a&&!e&&!n&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,5),t.body=this.parseBlock(!1,void 0,a&&!s),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=c}this.exitScope()},Zh.isSimpleParamList=function(t){for(var e=0,n=t;e-1||r.functions.indexOf(t)>-1||r.var.indexOf(t)>-1,r.lexical.push(t),this.inModule&&1&r.flags&&delete this.undefinedExports[t]}else if(4===e){this.currentScope().lexical.push(t)}else if(3===e){var s=this.currentScope();i=this.treatFunctionsAsVar?s.lexical.indexOf(t)>-1:s.lexical.indexOf(t)>-1||s.var.indexOf(t)>-1,s.functions.push(t)}else for(var a=this.scopeStack.length-1;a>=0;--a){var o=this.scopeStack[a];if(o.lexical.indexOf(t)>-1&&!(32&o.flags&&o.lexical[0]===t)||!this.treatFunctionsAsVarInScope(o)&&o.functions.indexOf(t)>-1){i=!0;break}if(o.var.push(t),this.inModule&&1&o.flags&&delete this.undefinedExports[t],259&o.flags)break}i&&this.raiseRecoverable(n,"Identifier '"+t+"' has already been declared")},np.checkLocalExport=function(t){-1===this.scopeStack[0].lexical.indexOf(t.name)&&-1===this.scopeStack[0].var.indexOf(t.name)&&(this.undefinedExports[t.name]=t)},np.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},np.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(259&e.flags)return e}},np.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(259&e.flags&&!(16&e.flags))return e}};var rp=function(t,e,n){this.type="",this.start=e,this.end=0,t.options.locations&&(this.loc=new Mh(t,n)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[e,0])},sp=Dh.prototype;function ap(t,e,n,i){return t.type=e,t.end=n,this.options.locations&&(t.loc.end=i),this.options.ranges&&(t.range[1]=n),t}sp.startNode=function(){return new rp(this,this.start,this.startLoc)},sp.startNodeAt=function(t,e){return new rp(this,t,e)},sp.finishNode=function(t,e){return ap.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)},sp.finishNodeAt=function(t,e,n,i){return ap.call(this,t,e,n,i)},sp.copyNode=function(t){var e=new rp(this,t.start,this.startLoc);for(var n in t)e[n]=t[n];return e};var op="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",cp=op+" Extended_Pictographic",lp=cp+" EBase EComp EMod EPres ExtPict",up={9:op,10:cp,11:cp,12:lp,13:lp,14:lp},hp="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",pp="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",dp=pp+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",fp=dp+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",mp=fp+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",yp=mp+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",gp={9:pp,10:dp,11:fp,12:mp,13:yp,14:yp+" Kawi Nag_Mundari Nagm"},bp={};function vp(t){var e=bp[t]={binary:Ih(up[t]+" "+hp),nonBinary:{General_Category:Ih(hp),Script:Ih(gp[t])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var _p=0,xp=[9,10,11,12,13,14];_p=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":""),this.unicodeProperties=bp[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=[],this.backReferenceNames=[]};function Ip(t){return 36===t||t>=40&&t<=43||46===t||63===t||t>=91&&t<=94||t>=123&&t<=125}function Ap(t){return t>=65&&t<=90||t>=97&&t<=122}function Tp(t){return Ap(t)||95===t}function kp(t){return Tp(t)||Mp(t)}function Mp(t){return t>=48&&t<=57}function Ep(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function Cp(t){return t>=65&&t<=70?t-65+10:t>=97&&t<=102?t-97+10:t-48}function Np(t){return t>=48&&t<=55}Sp.prototype.reset=function(t,e,n){var i=-1!==n.indexOf("u");this.start=0|t,this.source=e+"",this.flags=n,this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchN=i&&this.parser.options.ecmaVersion>=9},Sp.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)},Sp.prototype.at=function(t,e){void 0===e&&(e=!1);var n=this.source,i=n.length;if(t>=i)return-1;var r=n.charCodeAt(t);if(!e&&!this.switchU||r<=55295||r>=57344||t+1>=i)return r;var s=n.charCodeAt(t+1);return s>=56320&&s<=57343?(r<<10)+s-56613888:r},Sp.prototype.nextIndex=function(t,e){void 0===e&&(e=!1);var n=this.source,i=n.length;if(t>=i)return i;var r,s=n.charCodeAt(t);return!e&&!this.switchU||s<=55295||s>=57344||t+1>=i||(r=n.charCodeAt(t+1))<56320||r>57343?t+1:t+2},Sp.prototype.current=function(t){return void 0===t&&(t=!1),this.at(this.pos,t)},Sp.prototype.lookahead=function(t){return void 0===t&&(t=!1),this.at(this.nextIndex(this.pos,t),t)},Sp.prototype.advance=function(t){void 0===t&&(t=!1),this.pos=this.nextIndex(this.pos,t)},Sp.prototype.eat=function(t,e){return void 0===e&&(e=!1),this.current(e)===t&&(this.advance(e),!0)},wp.validateRegExpFlags=function(t){for(var e=t.validFlags,n=t.flags,i=0;i-1&&this.raise(t.start,"Duplicate regular expression flag")}},wp.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&t.groupNames.length>0&&(t.switchN=!0,this.regexp_pattern(t))},wp.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames.length=0,t.backReferenceNames.length=0,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,n=t.backReferenceNames;e=9&&(n=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!n,!0}return t.pos=e,!1},wp.regexp_eatQuantifier=function(t,e){return void 0===e&&(e=!1),!!this.regexp_eatQuantifierPrefix(t,e)&&(t.eat(63),!0)},wp.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)},wp.regexp_eatBracedQuantifier=function(t,e){var n=t.pos;if(t.eat(123)){var i=0,r=-1;if(this.regexp_eatDecimalDigits(t)&&(i=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue),t.eat(125)))return-1!==r&&r=9?this.regexp_groupSpecifier(t):63===t.current()&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1},wp.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)},wp.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1},wp.regexp_eatSyntaxCharacter=function(t){var e=t.current();return!!Ip(e)&&(t.lastIntValue=e,t.advance(),!0)},wp.regexp_eatPatternCharacters=function(t){for(var e=t.pos,n=0;-1!==(n=t.current())&&!Ip(n);)t.advance();return t.pos!==e},wp.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return!(-1===e||36===e||e>=40&&e<=43||46===e||63===e||91===e||94===e||124===e)&&(t.advance(),!0)},wp.regexp_groupSpecifier=function(t){if(t.eat(63)){if(this.regexp_eatGroupName(t))return-1!==t.groupNames.indexOf(t.lastStringValue)&&t.raise("Duplicate capture group name"),void t.groupNames.push(t.lastStringValue);t.raise("Invalid group")}},wp.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1},wp.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=Ah(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=Ah(t.lastIntValue);return!0}return!1},wp.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,n=this.options.ecmaVersion>=11,i=t.current(n);return t.advance(n),92===i&&this.regexp_eatRegExpUnicodeEscapeSequence(t,n)&&(i=t.lastIntValue),function(t){return rh(t,!0)||36===t||95===t}(i)?(t.lastIntValue=i,!0):(t.pos=e,!1)},wp.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,n=this.options.ecmaVersion>=11,i=t.current(n);return t.advance(n),92===i&&this.regexp_eatRegExpUnicodeEscapeSequence(t,n)&&(i=t.lastIntValue),function(t){return sh(t,!0)||36===t||95===t||8204===t||8205===t}(i)?(t.lastIntValue=i,!0):(t.pos=e,!1)},wp.regexp_eatAtomEscape=function(t){return!!(this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t))||(t.switchU&&(99===t.current()&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)},wp.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var n=t.lastIntValue;if(t.switchU)return n>t.maxBackReference&&(t.maxBackReference=n),!0;if(n<=t.numCapturingParens)return!0;t.pos=e}return!1},wp.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1},wp.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t,!1)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)},wp.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1},wp.regexp_eatZero=function(t){return 48===t.current()&&!Mp(t.lookahead())&&(t.lastIntValue=0,t.advance(),!0)},wp.regexp_eatControlEscape=function(t){var e=t.current();return 116===e?(t.lastIntValue=9,t.advance(),!0):110===e?(t.lastIntValue=10,t.advance(),!0):118===e?(t.lastIntValue=11,t.advance(),!0):102===e?(t.lastIntValue=12,t.advance(),!0):114===e&&(t.lastIntValue=13,t.advance(),!0)},wp.regexp_eatControlLetter=function(t){var e=t.current();return!!Ap(e)&&(t.lastIntValue=e%32,t.advance(),!0)},wp.regexp_eatRegExpUnicodeEscapeSequence=function(t,e){void 0===e&&(e=!1);var n,i=t.pos,r=e||t.switchU;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var s=t.lastIntValue;if(r&&s>=55296&&s<=56319){var a=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var o=t.lastIntValue;if(o>=56320&&o<=57343)return t.lastIntValue=1024*(s-55296)+(o-56320)+65536,!0}t.pos=a,t.lastIntValue=s}return!0}if(r&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&((n=t.lastIntValue)>=0&&n<=1114111))return!0;r&&t.raise("Invalid unicode escape"),t.pos=i}return!1},wp.regexp_eatIdentityEscape=function(t){if(t.switchU)return!!this.regexp_eatSyntaxCharacter(t)||!!t.eat(47)&&(t.lastIntValue=47,!0);var e=t.current();return!(99===e||t.switchN&&107===e)&&(t.lastIntValue=e,t.advance(),!0)},wp.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do{t.lastIntValue=10*t.lastIntValue+(e-48),t.advance()}while((e=t.current())>=48&&e<=57);return!0}return!1},wp.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(function(t){return 100===t||68===t||115===t||83===t||119===t||87===t}(e))return t.lastIntValue=-1,t.advance(),!0;if(t.switchU&&this.options.ecmaVersion>=9&&(80===e||112===e)){if(t.lastIntValue=-1,t.advance(),t.eat(123)&&this.regexp_eatUnicodePropertyValueExpression(t)&&t.eat(125))return!0;t.raise("Invalid property name")}return!1},wp.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var n=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var i=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,n,i),!0}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,r),!0}return!1},wp.regexp_validateUnicodePropertyNameAndValue=function(t,e,n){wh(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(n)||t.raise("Invalid property value")},wp.regexp_validateUnicodePropertyNameOrValue=function(t,e){t.unicodeProperties.binary.test(e)||t.raise("Invalid property name")},wp.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";Tp(e=t.current());)t.lastStringValue+=Ah(e),t.advance();return""!==t.lastStringValue},wp.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";kp(e=t.current());)t.lastStringValue+=Ah(e),t.advance();return""!==t.lastStringValue},wp.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)},wp.regexp_eatCharacterClass=function(t){if(t.eat(91)){if(t.eat(94),this.regexp_classRanges(t),t.eat(93))return!0;t.raise("Unterminated character class")}return!1},wp.regexp_classRanges=function(t){for(;this.regexp_eatClassAtom(t);){var e=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassAtom(t)){var n=t.lastIntValue;!t.switchU||-1!==e&&-1!==n||t.raise("Invalid character class"),-1!==e&&-1!==n&&e>n&&t.raise("Range out of order in character class")}}},wp.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var n=t.current();(99===n||Np(n))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var i=t.current();return 93!==i&&(t.lastIntValue=i,t.advance(),!0)},wp.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)},wp.regexp_eatClassControlLetter=function(t){var e=t.current();return!(!Mp(e)&&95!==e)&&(t.lastIntValue=e%32,t.advance(),!0)},wp.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1},wp.regexp_eatDecimalDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;Mp(n=t.current());)t.lastIntValue=10*t.lastIntValue+(n-48),t.advance();return t.pos!==e},wp.regexp_eatHexDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;Ep(n=t.current());)t.lastIntValue=16*t.lastIntValue+Cp(n),t.advance();return t.pos!==e},wp.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var n=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=64*e+8*n+t.lastIntValue:t.lastIntValue=8*e+n}else t.lastIntValue=e;return!0}return!1},wp.regexp_eatOctalDigit=function(t){var e=t.current();return Np(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)},wp.regexp_eatFixedHexDigits=function(t,e){var n=t.pos;t.lastIntValue=0;for(var i=0;i=this.input.length?this.finishToken(ph.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},Lp.readToken=function(t){return rh(t,this.options.ecmaVersion>=6)||92===t?this.readWord():this.getTokenFromCode(t)},Lp.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);if(t<=55295||t>=56320)return t;var e=this.input.charCodeAt(this.pos+1);return e<=56319||e>=57344?t:(t<<10)+e-56613888},Lp.skipBlockComment=function(){var t=this.options.onComment&&this.curPosition(),e=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(-1===n&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var i=void 0,r=e;(i=yh(this.input,r,this.pos))>-1;)++this.curLine,r=this.lineStart=i;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,n),e,this.pos,t,this.curPosition())},Lp.skipLineComment=function(t){for(var e=this.pos,n=this.options.onComment&&this.curPosition(),i=this.input.charCodeAt(this.pos+=t);this.pos8&&t<14||t>=5760&&gh.test(String.fromCharCode(t))))break t;++this.pos}}},Lp.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=t,this.value=e,this.updateContext(n)},Lp.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===t&&46===e?(this.pos+=3,this.finishToken(ph.ellipsis)):(++this.pos,this.finishToken(ph.dot))},Lp.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===t?this.finishOp(ph.assign,2):this.finishOp(ph.slash,1)},Lp.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),n=1,i=42===t?ph.star:ph.modulo;return this.options.ecmaVersion>=7&&42===t&&42===e&&(++n,i=ph.starstar,e=this.input.charCodeAt(this.pos+2)),61===e?this.finishOp(ph.assign,n+1):this.finishOp(i,n)},Lp.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);if(e===t){if(this.options.ecmaVersion>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(ph.assign,3);return this.finishOp(124===t?ph.logicalOR:ph.logicalAND,2)}return 61===e?this.finishOp(ph.assign,2):this.finishOp(124===t?ph.bitwiseOR:ph.bitwiseAND,1)},Lp.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(ph.assign,2):this.finishOp(ph.bitwiseXOR,1)},Lp.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?45!==e||this.inModule||62!==this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!dh.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(ph.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===e?this.finishOp(ph.assign,2):this.finishOp(ph.plusMin,1)},Lp.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),n=1;return e===t?(n=62===t&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(ph.assign,n+1):this.finishOp(ph.bitShift,n)):33!==e||60!==t||this.inModule||45!==this.input.charCodeAt(this.pos+2)||45!==this.input.charCodeAt(this.pos+3)?(61===e&&(n=2),this.finishOp(ph.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},Lp.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(ph.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===t&&62===e&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(ph.arrow)):this.finishOp(61===t?ph.eq:ph.prefix,1)},Lp.readToken_question=function(){var t=this.options.ecmaVersion;if(t>=11){var e=this.input.charCodeAt(this.pos+1);if(46===e){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(ph.questionDot,2)}if(63===e){if(t>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(ph.assign,3);return this.finishOp(ph.coalesce,2)}}return this.finishOp(ph.question,1)},Lp.readToken_numberSign=function(){var t=35;if(this.options.ecmaVersion>=13&&(++this.pos,rh(t=this.fullCharCodeAtPos(),!0)||92===t))return this.finishToken(ph.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Ah(t)+"'")},Lp.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(ph.parenL);case 41:return++this.pos,this.finishToken(ph.parenR);case 59:return++this.pos,this.finishToken(ph.semi);case 44:return++this.pos,this.finishToken(ph.comma);case 91:return++this.pos,this.finishToken(ph.bracketL);case 93:return++this.pos,this.finishToken(ph.bracketR);case 123:return++this.pos,this.finishToken(ph.braceL);case 125:return++this.pos,this.finishToken(ph.braceR);case 58:return++this.pos,this.finishToken(ph.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(ph.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(120===e||88===e)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===e||79===e)return this.readRadixNumber(8);if(98===e||66===e)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 63:return this.readToken_question();case 126:return this.finishOp(ph.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Ah(t)+"'")},Lp.finishOp=function(t,e){var n=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,n)},Lp.readRegexp=function(){for(var t,e,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var i=this.input.charAt(this.pos);if(dh.test(i)&&this.raise(n,"Unterminated regular expression"),t)t=!1;else{if("["===i)e=!0;else if("]"===i&&e)e=!1;else if("/"===i&&!e)break;t="\\"===i}++this.pos}var r=this.input.slice(n,this.pos);++this.pos;var s=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(s);var o=this.regexpState||(this.regexpState=new Sp(this));o.reset(n,r,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(r,a)}catch(t){}return this.finishToken(ph.regexp,{pattern:r,flags:a,value:c})},Lp.readInt=function(t,e,n){for(var i=this.options.ecmaVersion>=12&&void 0===e,r=n&&48===this.input.charCodeAt(this.pos),s=this.pos,a=0,o=0,c=0,l=null==e?1/0:e;c=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0)>=t)break;o=u,a=a*t+h}}return i&&95===o&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===s||null!=e&&this.pos-s!==e?null:a},Lp.readRadixNumber=function(t){var e=this.pos;this.pos+=2;var n=this.readInt(t);return null==n&&this.raise(this.start+2,"Expected number in radix "+t),this.options.ecmaVersion>=11&&110===this.input.charCodeAt(this.pos)?(n=Bp(this.input.slice(e,this.pos)),++this.pos):rh(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(ph.num,n)},Lp.readNumber=function(t){var e=this.pos;t||null!==this.readInt(10,void 0,!0)||this.raise(e,"Invalid number");var n=this.pos-e>=2&&48===this.input.charCodeAt(e);n&&this.strict&&this.raise(e,"Invalid number");var i=this.input.charCodeAt(this.pos);if(!n&&!t&&this.options.ecmaVersion>=11&&110===i){var r=Bp(this.input.slice(e,this.pos));return++this.pos,rh(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(ph.num,r)}n&&/[89]/.test(this.input.slice(e,this.pos))&&(n=!1),46!==i||n||(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),69!==i&&101!==i||n||(43!==(i=this.input.charCodeAt(++this.pos))&&45!==i||++this.pos,null===this.readInt(10)&&this.raise(e,"Invalid number")),rh(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s,a=(s=this.input.slice(e,this.pos),n?parseInt(s,8):parseFloat(s.replace(/_/g,"")));return this.finishToken(ph.num,a)},Lp.readCodePoint=function(){var t;if(123===this.input.charCodeAt(this.pos)){this.options.ecmaVersion<6&&this.unexpected();var e=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(e,"Code point out of bounds")}else t=this.readHexChar(4);return t},Lp.readString=function(t){for(var e="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var i=this.input.charCodeAt(this.pos);if(i===t)break;92===i?(e+=this.input.slice(n,this.pos),e+=this.readEscapedChar(!1),n=this.pos):8232===i||8233===i?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(mh(i)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(n,this.pos++),this.finishToken(ph.string,e)};var Dp={};Lp.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t!==Dp)throw t;this.readInvalidTemplateToken()}this.inTemplateElement=!1},Lp.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Dp;this.raise(t,e)},Lp.readTmplToken=function(){for(var t="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(96===n||36===n&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==ph.template&&this.type!==ph.invalidTemplate?(t+=this.input.slice(e,this.pos),this.finishToken(ph.template,t)):36===n?(this.pos+=2,this.finishToken(ph.dollarBraceL)):(++this.pos,this.finishToken(ph.backQuote));if(92===n)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(mh(n)){switch(t+=this.input.slice(e,this.pos),++this.pos,n){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:t+="\n";break;default:t+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}},Lp.readInvalidTemplateToken=function(){for(;this.pos=48&&e<=55){var i=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(i,8);return r>255&&(i=i.slice(0,-1),r=parseInt(i,8)),this.pos+=i.length-1,e=this.input.charCodeAt(this.pos),"0"===i&&56!==e&&57!==e||!this.strict&&!t||this.invalidStringToken(this.pos-1-i.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(r)}return mh(e)?"":String.fromCharCode(e)}},Lp.readHexChar=function(t){var e=this.pos,n=this.readInt(16,t);return null===n&&this.invalidStringToken(e,"Bad character escape sequence"),n},Lp.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,n=this.pos,i=this.options.ecmaVersion>=6;this.pos(e,n)=>n.error(e,t+" not allowed"),zp=$p("Aggregate function"),Hp=$p("Window function"),qp="Invalid argument",Yp="Invalid column reference",Wp=Yp+" (must be input to an aggregate function)",Gp="Invalid function call",Kp="Invalid operator parameter",Qp="Unsupported destructuring pattern",Jp="Table expressions do not support closures",Zp="Use aq.escape(fn) to use a function as-is (including closures)",Xp=`\nNote: ${Jp}. ${Zp}, or use table.params({ name: value }) to define dynamic parameters.`,td=`\nNote: ${Jp}. ${Zp}, or use aq.addFunction(name, fn) to add new op functions.`,ed=`The ${gn} method is not valid in multi-table expressions.`;function nd(t,e){const n=function(t){try{const i=t.field?function(t){const e=JSON.stringify(t+"");return t.table?`(a,b)=>b[${e}]`:`d=>d[${e}]`}(t):vt(t)?be(t):t;return(e=`expr=(${i})`,n=Vp,Dh.parse(e,n)).body[0].expression.right}catch(e){St("Expression parse error: "+(t+""))}var e,n}(e);let i=t.root=n;return t.spec=e,t.tuple=null,t.tuple1=null,t.tuple2=null,t.$param=null,t.$op=0,t.scope=new Set,t.paramsRef=new Map,t.columnRef=new Map,!function(t){return qu(Ne,t)||qu(Ce,t)}(i)?t.join?(t.scope.add(t.tuple1=Rp),t.scope.add(t.tuple2=jp),t.scope.add(t.$param=Up)):(t.scope.add(t.tuple=Pp),t.scope.add(t.$param=Up)):(!function(t,e){t.generator&&$p("Generator functions")(t,e);t.async&&$p("Async functions")(t,e);const{params:n}=t,i=n.length,r=t=>(n,i)=>e.columnRef.set(n,[i,t]),s=(t,n)=>e.paramsRef.set(t,n);i&&(e.join?(ad(e,n[0],"tuple1",r(1)),i>1&&ad(e,n[1],"tuple2",r(2)),i>2&&ad(e,n[2],"$param",s)):(ad(e,n[0],"tuple",r(0)),i>1&&ad(e,n[1],"$param",s)));e.root=t.body}(i,t),i=i.body),Du(i,t,id),t.root}const id={FunctionDeclaration:$p("Function definitions"),ForStatement:$p("For loops"),ForOfStatement:$p("For-of loops"),ForInStatement:$p("For-in loops"),WhileStatement:$p("While loops"),DoWhileStatement:$p("Do-while loops"),AwaitExpression:$p("Await expressions"),ArrowFunctionExpression:$p("Function definitions"),AssignmentExpression:$p("Assignments"),FunctionExpression:$p("Function definitions"),NewExpression:$p('Use of "new"'),UpdateExpression:$p("Update expressions"),VariableDeclarator(t,e){yd(t.id,e)},Identifier(t,e,n){ld(t,e,n)&&!e.scope.has(t.name)&&e.error(t,"Invalid variable reference",Xp)},CallExpression(t,e){const n=od(t.callee),i=un(n)||hn(n);if(i){if((e.join||!1===e.aggregate)&&on(n)&&zp(t,e),(e.join||!1===e.window)&&cn(n)&&Hp(t,e),e.$op=1,e.ast)md(t,n,e),t.arguments.forEach((t=>Du(t,e,sd)));else{const r=e.op(function(t,e,n,i){const r=[],s=[],a=e.param[0]||0,o=a+(e.param[1]||0);return i.forEach(((e,n)=>{n=0?rd(t,a,e,ud,n):s===e.$param?rd(t,a,e,pd):void(e.paramsRef.has(s)?dd(t,e.paramsRef.get(s)):e.columnRef.has(s)?hd(i,s,e,t):Vt(e.params,s)&&dd(i,s))}};function rd(t,e,n,i,r){const{property:s,computed:a}=t;let o;if(a)if(qu(Le,s))o=s.value;else try{Du(s,n,id,t),o=n.param(s)}catch(e){n.error(t,"Invalid member expression")}else o=s.name;return i(t,o,e,n,r),!1}const sd={...id,VariableDeclarator:$p("Variable declaration in operator call"),Identifier(t,e,n){ld(t,e,n)&&e.error(t,"Variable not accessible in operator call")},CallExpression(t,e){const n=od(t.callee);ln(n)?md(t,n,e):e.error(t,Gp,td)}};function ad(t,e,n,i){qu(Oe,e)?(t.scope.add(e.name),t[n]=e.name):qu(Fe,e)&&e.properties.forEach((e=>{const n=qu(Oe,e.key)?e.key.name:qu(Le,e.key)?e.key.value:t.error(e,qp);qu(Oe,e.value)||t.error(e.value,Qp),i(e.value.name,n)}))}function od(t){return qu(Oe,t)?t.name:qu(Be,t)?cd(t)?function(t){return"max"===t?"greatest":"min"===t?"least":t}(t.property.name):t.property.name:null}function cd(t){return qu(Oe,t.object)&&"Math"===t.object.name}function ld(t,e,n){const{name:i}=t;if(qu(Be,n)&&n.property===t);else if(qu(Ve,n)&&n.key===t);else if(e.paramsRef.has(i))dd(t,e.paramsRef.get(i));else if(e.columnRef.has(i))hd(t,i,e,n);else if(Vt(e.params,i))dd(t,i);else{if(!Vt(Fp,i))return!0;fd(t,i)}}function ud(t,e,n,i,r){const s=0===n?i.table:n>0?i.join[n-1]:null,a=s&&s.column(e);s&&!a&&i.error(t,Yp),i.aggronly&&!i.$op&&i.error(t,Wp),mn(t,e,n,a,r)}function hd(t,e,n,i){const[r,s]=n.columnRef.get(e);ud(t,r,s,n,i)}function pd(t,e,n,i){i.params&&!Vt(i.params,e)&&i.error(t,"Invalid param reference"),dd(t,e)}function dd(t,e){t.type=je,t.name=e}function fd(t,e){t.type=Pe,t.name=e,t.raw=Fp[e]}function md(t,e,n){if(e===gn){const e=n.table;e||n.error(t,ed),bn(t,t.arguments.length?t.arguments.map((t=>{const i=n.param(t),r=It(i)?e.columnName(i):i;return e.column(r)||n.error(t,Yp),r})):e.columnNames())}else t.callee={type:"Function",name:e}}function yd(t,e){qu(Oe,t)?e.scope.add(t.name):qu("ArrayPattern",t)?t.elements.forEach((t=>yd(t,e))):qu(Fe,t)?t.properties.forEach((t=>yd(t.value,e))):e.error(t.id,"Unsupported variable declaration")}const gd={[Ue]:1,Op:1};function bd(t,e={}){const n=e.generate||Qe,i=e.compiler||dn,r=function(t){return(t.table?vd(t.table):t.join?{...vd(t.join[1]),...vd(t.join[0])}:{})||{}}(e),s={},a={},o=[],c=[];let l=0,u=-1;const h=e.join?i.join:1==e.index?i.expr2:i.expr,p={op(t){const e=function(t){let e=`${t.name}(${t.fields.concat(t.params).join(",")})`;if(t.frame){e+=`[${t.frame.map((t=>Number.isFinite(t)?Math.abs(t):-1))},${!!t.peers}]`}return e}(t);return a[e]||(t.id=++u,a[e]=t)},field(t){const e=n(t);return s[e]||(s[e]=++l)},param:t=>qu(Le,t)?t.value:i.param(n(t),r),value(t,i){o.push(t);const s=i.escape||(e.ast?function(t){return Du(t,null,{Column:Hu,Constant:Hu,Default:zu}),t}(i):h(n(i),r));c.push(s),gd[i.type]&&s!==i&&Nt(s)&&(s.field=i.name)},error(t,e,n=""){const i=t.start-6,r=t.end-6;St(`${e}: "${String(p.spec).slice(i,r)}"${n}`)}};Object.assign(p,e,{params:r});for(const[e,n]of yn(t))p.value(e+"",n.escape?Wu(p,n,r):nd(p,n));if(e.ast)return{names:o,exprs:c};const d=[];for(const t in s)d[s[t]]=i.expr(t,r);const f=Object.values(a);return f.forEach((t=>t.fields=t.fields.map((t=>d[t])))),{names:o,exprs:c,ops:f}}function vd(t){return t&&At(t.params)?t.params():{}}const _d="Expr",xd="ExprList",wd="ExprNumber",Sd="ExprObject",Id="JoinKeys",Ad="JoinValues",Td="Options",kd="OrderKeys",Md="SelectionList",Ed="TableRef",Cd="TableRefList",Nd="Descending",Od="Selection",Ld="Window";function Bd(t,e){return t&&t.expr?new Dd({...t,...e}):new Dd(e,t)}class Dd{constructor(t,e){this.expr=e,Object.assign(this,t)}toString(){return String(this.expr)}toObject(){return{...this,expr:this.toString(),...At(this.expr)?{func:!0}:{}}}}function Fd(t,e,n=0){const i=n?{field:!0,table:n}:{field:!0};return Bd(t,e?{expr:e,...i}:i)}function Vd(t,e){return(e=e&&At(e.query)?e.query():e)&&At(e.evaluate)?e.evaluate(null,t):t(e)}function Ud(t){return Nt(t)&&(vt(t.all)||vt(t.matches)||vt(t.not)||vt(t.range))}function Pd(t){return t&&At(t.toObject)?t.toObject():At(t)?{expr:String(t),func:!0}:vt(t)?t.map(Pd):Nt(t)?wu(t,(t=>Pd(t))):t}function Rd(t){return vt(t)?t.map(Rd):Nt(t)?vt(t.verbs)?rf.from(t):vt(t.all)?Cu():vt(t.range)?function(t,e){return Mu((n=>{let i=It(t)?t:n.columnIndex(t),r=It(e)?e:n.columnIndex(e);if(r({range:[t,e]})))}(...t.range):vt(t.match)?(Lt(e=RegExp(...t.match))&&(e=RegExp(e.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&"))),Mu((t=>t.columnNames((t=>e.test(t)))),(()=>({matches:[e.source,e.flags]})))):vt(t.not)?Nu(t.not.map(Pd)):function(t){let e=t,n=t.expr;if(null!=n){if(!0===t.field?e=n=Fd(n):!0===t.func&&(e=n=function(t){const e=t=>t;return e.toString=()=>t,e}(n)),Nt(t.window)){const{frame:i,peers:r}=t.window;e=n=function(t,e,n){return Bd(t,{window:{frame:e||[-1/0,0],peers:!!n}})}(n,i,r)}!0===t.desc&&(e=function(t){return Bd(t,{desc:!0})}(n))}return t===e?wu(t,(t=>Rd(t))):e}(t):t;var e}function jd(t){const e=[];return _t(t).forEach((t=>{It(t)?e.push(t):Lt(t)?e.push(Fd(t,null)):Nt(t)&&t.expr||At(t)?e.push(t):St("Invalid key value: "+(t+""))})),e}function $d(t,e){return e<2?_t(t):t}const zd={[_d]:Qd,[xd]:Jd,[wd]:function(t){return It(t)?t:Wd(t)},[Sd]:Wd,[Id]:function(t){return vt(t)?t.map(Jd):Wd(t,{join:!0})},[Ad]:function(t){return vt(t)?t.map(((t,e)=>e<2?Jd(t):Wd(t,{join:!0}))):Wd(t,{join:!0})},[kd]:Jd,[Md]:function(t){return _t(t).map(Kd).flat()}};function Hd(t,e,n){return e===Td?t?function(t,e={}){const n={};for(const i in t){const r=t[i];n[i]=e[i]?Hd(r,e[i]):r}return n}(t,n):t:zd[e](t)}function qd(t){return{type:Ue,name:t}}function Yd(t){return{type:Ue,index:t}}function Wd(t,e){if(Lt(t))return function(t,e){return bd({expr:t},{...e,ast:!0}).exprs[0]}(t,e);if(t.expr){let n;if(!0===t.field?n=qd(t.expr):!0===t.func&&(n=Wd(t.expr,e)),n)return t.desc&&(n={type:Nd,expr:n}),t.window&&(n={type:Ld,expr:n,...t.window}),n}return Object.keys(t).map((n=>({...Wd(t[n],e),as:n})))}function Gd(t){const e=Od;return t.all?{type:e,operator:"all"}:t.not?{type:e,operator:"not",arguments:Jd(t.not)}:t.range?{type:e,operator:"range",arguments:Jd(t.range)}:t.matches?{type:e,operator:"matches",arguments:t.matches}:St("Invalid input")}function Kd(t){return Ud(t)?Gd(t):It(t)?Yd(t):Lt(t)?qd(t):Nt(t)?Object.keys(t).map((e=>({type:Ue,name:e,as:t[e]}))):St("Invalid input")}function Qd(t){return Ud(t)?Gd(t):It(t)?Yd(t):Lt(t)?qd(t):Nt(t)?Wd(t):St("Invalid input")}function Jd(t){return _t(t).map(Qd).flat()}function Zd(t){return t&&At(t.toAST)?t.toAST():t}class Xd{constructor(t,e=[],n=[]){this.verb=t,this.schema=e,e.forEach(((t,e)=>{const i=t.type,r=n[e],s=i===Id?vt(a=r)?a.map(jd):a:i===Ad?function(t){return vt(t)?t.map($d):t}(r):i===kd?function(t){const e=[];return t.forEach((t=>{const n=null!=t.expr?t.expr:t;if(Nt(n)&&!At(n))for(const t in n)e.push(n[t]);else t=It(n)?n:Lt(n)?Fd(t):At(n)?t:St("Invalid orderby field: "+t),e.push(t)})),e}(r):r;var a;this[t.name]=void 0!==s?s:t.default}))}static from(t){const e=ef[t.verb],n=(e.schema||[]).map((({name:e})=>Rd(t[e])));return e(...n)}evaluate(t,e){const n=this.schema.map((({name:t,type:n})=>{const i=this[t];return n===Ed?Vd(e,i):n===Cd?i.map((t=>Vd(e,t))):i}));return t[this.verb](...n)}toObject(){const t={verb:this.verb};return this.schema.forEach((({name:e})=>{t[e]=Pd(this[e])})),t}toAST(){const t={type:"Verb",verb:this.verb};return this.schema.forEach((({name:e,type:n,props:i})=>{t[e]=function(t,e,n){return e===Ed?Zd(t):e===Cd?t.map(Zd):Hd(Pd(t),e,n)}(this[e],n,i)})),t}}function tf(t,e){return Object.assign(((...n)=>new Xd(t,e,n)),{schema:e})}const ef={count:tf("count",[{name:"options",type:Td}]),derive:tf("derive",[{name:"values",type:Sd},{name:"options",type:Td,props:{before:Md,after:Md}}]),filter:tf("filter",[{name:"criteria",type:Sd}]),groupby:tf("groupby",[{name:"keys",type:xd}]),orderby:tf("orderby",[{name:"keys",type:kd}]),relocate:tf("relocate",[{name:"columns",type:Md},{name:"options",type:Td,props:{before:Md,after:Md}}]),rename:tf("rename",[{name:"columns",type:Md}]),rollup:tf("rollup",[{name:"values",type:Sd}]),sample:tf("sample",[{name:"size",type:wd},{name:"options",type:Td,props:{weight:_d}}]),select:tf("select",[{name:"columns",type:Md}]),ungroup:tf("ungroup"),unorder:tf("unorder"),reify:tf("reify"),dedupe:tf("dedupe",[{name:"keys",type:xd,default:[]}]),impute:tf("impute",[{name:"values",type:Sd},{name:"options",type:Td,props:{expand:xd}}]),fold:tf("fold",[{name:"values",type:xd},{name:"options",type:Td}]),pivot:tf("pivot",[{name:"keys",type:xd},{name:"values",type:xd},{name:"options",type:Td}]),spread:tf("spread",[{name:"values",type:xd},{name:"options",type:Td}]),unroll:tf("unroll",[{name:"values",type:xd},{name:"options",type:Td,props:{drop:xd}}]),lookup:tf("lookup",[{name:"table",type:Ed},{name:"on",type:Id},{name:"values",type:xd}]),join:tf("join",[{name:"table",type:Ed},{name:"on",type:Id},{name:"values",type:Ad},{name:"options",type:Td}]),cross:tf("cross",[{name:"table",type:Ed},{name:"values",type:Ad},{name:"options",type:Td}]),semijoin:tf("semijoin",[{name:"table",type:Ed},{name:"on",type:Id}]),antijoin:tf("antijoin",[{name:"table",type:Ed},{name:"on",type:Id}]),concat:tf("concat",[{name:"tables",type:Cd}]),union:tf("union",[{name:"tables",type:Cd}]),intersect:tf("intersect",[{name:"tables",type:Cd}]),except:tf("except",[{name:"tables",type:Cd}])};function nf(t){return new rf(null,null,t)}class rf extends wt{constructor(t,e,n){super(e),this._verbs=t||[],this._table=n}static from({verbs:t,table:e,params:n}){return new rf(t.map(Xd.from),n,e)}get[Symbol.toStringTag](){if(!this._verbs)return"Object";return`Query: ${this._verbs.length} verbs`+(this._table?` on '${this._table}'`:"")}get length(){return this._verbs.length}get tableName(){return this._table}params(t){return arguments.length?(this._params={...this._params,...t},this):this._params}evaluate(t,e){t=t||e(this._table);for(const n of this._verbs)t=n.evaluate(t.params(this._params),e);return t}toObject(){return sf(this,"toObject")}toJSON(){return this.toObject()}toAST(){return sf(this,"toAST",{type:"Query"})}}function sf(t,e,n){return{...n,verbs:t._verbs.map((t=>t[e]())),...t._params?{params:t._params}:null,...t._table?{table:t._table}:null}}function af(t,e){return new rf(t._verbs.concat(e),t._params,t._table)}for(const t in ef){const e=ef[t];rf.prototype["__"+t]=function(t,...n){return af(t,e(...n))}}function of(t,e,...n){const i=["_","$"],r=i.slice(0,n.length);return r.push('"use strict"; const '+n.map(((t,e)=>t.map(((t,n)=>`${i[e]}${n} = ${i[e]}[${n}]`)).join(", "))).join(", ")+`; return (${t}) => ${e};`),Function(...r)(...n)}var cf=t=>t;const lf=[t=>"true"===t||"false"===t,t=>"false"!==t],uf=[t=>"NaN"===t||(t=+t)===t,t=>+t],hf=[te,t=>new Date(Date.parse(t))];function pf(t){const{decimal:e}=t;return e&&"."!==e?uf.map((t=>n=>t(n&&n.replace(e,".")))):uf}function df(t,e){const n=t.length;for(let i=0;i`col${t+e+1}`))}function mf(t,e,n){let i=t();const r=i.length,s=+n.autoMax||1e3,a=Tt(r,(()=>[]));e=e?e.lengthAt(i[t])?i[t]:r?cf:function(t,e){const n=[lf,pf(e),hf],i=n.length;for(let e=0;e{if(t===cf)return;const n=a[e];for(let e=0;el[t]=a[e])),new Ou(l,e)}const yf={},gf={},bf=34,vf=10,_f=13;function xf(t,e={}){const n=function(t,{delimiter:e=",",skip:n,comment:i}){1!==e.length&&St(`Text "delimiter" should be a single character, found "${e}"`);const r=e.charCodeAt(0);let s,a=t.length,o=0,c=a<=0,l=!1;function u(){if(c)return gf;if(l)return l=!1,yf;const e=o;let n,i;if(t.charCodeAt(e)===bf){for(;o++=a?c=!0:(i=t.charCodeAt(o++))===vf?l=!0:i===_f&&(l=!0,t.charCodeAt(o)===vf&&++o),t.slice(e+1,n-1).replace(/""/g,'"')}for(;o=0;)t();return n?()=>{let e;for(;!e;){if(!n(e=t()))return e;e=null}}:t}((function(){if((s=u())!==gf){const t=[];for(;s!==yf&&s!==gf;)t.push(s),s=u();return t}}),n,i&&(t=>(t&&t[0]||"").startsWith(i)))}(t,e);return mf(n,!1!==e.header?n():e.names,e)}function wf(t){const e=t.length;for(let n=0;n57)return!1}return!0}function Sf(t,e){const n=Ut();return e.forEach(((e,i)=>{const r=Lt(e)?e:i;if(r){const e=t.column(i)||St(`Unrecognized column: ${i}`);n.add(r,e)}})),t.create(n)}function If(t,e,{before:n,after:i}={}){const r=null!=n,s=null!=i;r||s||St("relocate requires a before or after option."),r&&s&&St("relocate accepts only one of the before or after options."),e=ku(t,e);const a=[...ku(t,r?n:i).keys()],o=r?a[0]:a.pop(),c=new Map;return t.columnNames().forEach((t=>{const n=!e.has(t);if(t===o){s&&n&&c.set(t,t);for(const[t,n]of e)c.set(t,n);if(s)return}n&&c.set(t,t)})),Sf(t,c)}function Af(t,e=(t=>t),n=""){const i=t.length;if(!i)return"";let r=e(t[0],0);for(let s=1;se?1:t>=e?0:NaN}function kf(t){return ge(t)?t:+t}class Mf{constructor(t){this._values=t||[],this._sorted=null,this._start=0}values(t){return this._start&&(this._values=this._values.slice(this._start),this._start=0),t?this._values.slice():this._values}add(t){this._values.push(t),this._sorted=null}rem(){this._start+=1,this._sorted=null}min(){return this._sorted&&this._sorted.length?this._sorted[0]:function(t,e=0,n=t.length){let i=n?t[e++]:Rt;for(let r=e;rt[r]&&(i=t[r]);return i}(this._values,this._start)}max(){return this._sorted&&this._sorted.length?this._sorted[this._sorted.length-1]:function(t,e=0,n=t.length){let i=n?t[e++]:Rt;for(let r=e;r=1)return kf(t[n-1]);const i=(n-1)*e,r=Math.floor(i),s=kf(t[r]);return ge(s)?s:s+(kf(t[r+1])-s)*(i-r)}(this._sorted,t)}}const Ef=(t,e,n)=>of(e,"{"+Af(t,((t,i)=>`_${i}.${n}(${e});`))+"}",t);function Cf(t,e){const{ops:n,output:i}=function(t,e){const n={},i=[];function r(t,s=[]){const a=t+":"+s;if(n[a])return n[a];const o=un(t),c=o.create(...s);return e<0&&o.stream&&o.stream.forEach((t=>r(t,[]))),o.req&&o.req.forEach((t=>r(t,[]))),n[a]=c,i.push(c),c}const s=t.map((t=>{const e=r(t.name,t.params);return e.output=t.id,e}));return{ops:i,output:s}}(t,e),r=t[0].fields,s=r.length;return new(0===s?Nf:1===s?Of:2===s?Lf:St("Unsupported field count: "+s))(r,n,i,e)}class Nf extends Bu{constructor(t,e,n,i){super(n),this._op=e,this._fields=t,this._stream=!!i}init(){const t={count:0,valid:0,stream:this._stream};return this._op.forEach((e=>e.init(t))),t.values&&(t.list=new Mf),t}write(t,e,n){const i=this._outputs,r=i.length;for(let s=0;ss[t][r[e]]:t=>s[t][0];n=n.map((t=>e=>t(e,i,a)))}return n}function Df(t,e,n){if(!e.length)return n;const i=Ff(e),r=t.groups(),s=r?r.size:1;return n=n||Tt(e.length,(()=>Array(s))),s>1?i.forEach((e=>{const i=Uf(t,e,r);for(let t=0;t{const i=Vf(t,e);e.write(i,n,0)})),n}function Ff(t,e){const n=[],i={};for(const e of t){const t=e.fields.map((t=>t+"")).join(",");(i[t]||(i[t]=[])).push(e)}for(const t in i)n.push(Cf(i[t],e));return n}function Vf(t,e){const n=e.init(),i=t.totalRows(),r=t.data(),s=t.mask();if(t.isOrdered()){const s=t.indices();for(let t=0;t=0;t=s.next(t+1))e.add(n,t,r);else for(let t=0;te.init())),a=t.data();if(t.isOrdered()){const n=t.indices(),r=n.length;for(let t=0;t=0;t=n.next(t+1))e.add(s[i[t]],t,a)}else{const n=t.totalRows();for(let t=0;t>>1;t(e[s],n)<0?i=s+1:r=s}return i},right(e,n,i,r){for(null==i&&(i=0),null==r&&(r=e.length);i>>1;t(e[s],n)>0?r=s:i=s+1}return i}}}const jf=Rf(Tf);const $f=t=>(t.frame||[null,null]).map((t=>Number.isFinite(t)?Math.abs(t):null)),zf=t=>!!t.peers;function Hf(t,e,n,i={},r){const s=t.data(),a=function(t,e){const n={};return t.forEach((t=>{const e=$f(t),i=zf(t),r=`${e},${i}`,{aggOps:s,winOps:a}=n[r]||(n[r]={frame:e,peers:i,aggOps:[],winOps:[]});on(t.name)?s.push(t):a.push(function(t){const{id:e,name:n,fields:i=[],params:r=[]}=t,s=hn(n).create(...r);return i.length&&(s.get=i[0]),s.id=e,s}(t))})),Object.values(n).map((t=>function(t,e,n,i,r){let s,a,o,c,l;const u=t=>a[t-1]===a[t],h=i.length,p=r.length,d=i.length?of(["w","r","k"],"{"+Af(i,((t,e)=>`r[_${e}.id][k]=_${e}.value(w,_${e}.get);`))+"}",i):()=>{},f={i0:0,i1:0,index:0,size:0,peer:u,init(t,e,n,u){f.index=f.i0=f.i1=0,f.size=e.length,s=t,a=e,c=n,l=u,o=r?r.map((t=>t.init())):null;for(let t=0;tn(s[e],t),step(i){const[h,m]=e,y=f.size,g=f.i0,b=f.i1;f.i0=null!=h?Math.max(0,i-Math.abs(h)):0,f.i1=null!=m?Math.min(y,i+Math.abs(m)+1):y,f.index=i,n&&(f.i0>0&&u(f.i0)&&(f.i0=jf.left(a,a[f.i0])),f.i1`_${e}[r] = $${e}(r, d, op);`))+"}",e,n);t.partitions().forEach(((e,n)=>{const r=e.length,l=function(t,e){if(t.isOrdered()){const n=t.comparator(),i=t.data(),r=e.length,s=new Uint32Array(r);for(let t=1,a=0;ti[t][n];for(let t=0;ta.add(t,Array(s)))),[c,l]=function(t){const e=[],n=[],i=t.length;for(let r=0;rArray(u))));return l.length?Hf(t,o,n,h,l):function(t,e,n,i){const r=t.mask(),s=t.data(),{keys:a}=t.groups()||{},o=a?(t,e)=>i[t][a[e]]:t=>i[t][0],c=e.length;for(let i=0;i=0;t=r.next(t+1))c[t]=a(t,s,o);else{const e=t.totalRows();for(let t=0;t>5]&Wf>>>t}set(t){this._bits[t>>5]|=Wf>>>t}clear(t){this._bits[t>>5]&=~(Wf>>>t)}scan(t){for(let e=this.next(0);e>=0;e=this.next(e+1))t(e)}next(t){const e=this._bits,n=e.length;let i=t>>5,r=e[i]&4294967295>>>t;for(;i=0;)e=this.next(e+1);return e}not(){const t=this._bits,e=t.length;for(let n=0;n>n-1),this}and(t){if(t){const e=this._bits,n=t._bits,i=e.length;for(let t=0;t0?+r.limit:1/0,a=r.index?!0===r.index?"index":r.index+"":null,o=new Set(r.drop),c=Bf(t,i,n),l=Ut(),u=new Set(e),h=[],p=[],d=[];t.columnNames().forEach((e=>{if(!o.has(e)){const n=l.add(e,[]);u.has(e)||(h.push(t.column(e)),p.push(n))}})),e.forEach((t=>{o.has(t)||(l.has(t)||l.add(t,[]),d.push(l.data[t]))}));const f=a?l.add(a,[]):null;let m=0;const y=h.length,g=d.length,b=(t,e)=>{for(let n=0;n{for(let n=0;n{};if(1===g){const e=c[0],n=d[0];t.scan(((t,i)=>{const r=_t(e(t,i)),a=Math.min(r.length,s);b(t,a);for(let t=0;t{let n=0;const i=c.map((i=>{const r=_t(i(t,e));return n=Math.min(Math.max(n,r.length),s),r}));b(t,n);for(let t=0;t{Lt(n=It(n)?e.columnName(n):n)?r.set(n,Fd(n)):At(n)?ku(e,n).forEach(s):Nt(n)?Tu(r,n):St(`Invalid ${t} value: ${n+""}`)};return _t(n).forEach(s),i.preparse&&i.preparse(r),bd(r,{table:e,...i})}function Jf(t,e,n,i){const r=n&&n.length;return function(t,{names:e,exprs:n,ops:i},r){const s=Bf(t,i,n),a=r?null:Ut(t),o=t.totalRows();return e.forEach(((e,n)=>{const i=t.column(e),c=r?i.data:a.add(e,Array(o)),l=s[n];t.scan((t=>{const e=i.get(t);c[t]=Ht(e)?e:l(t)}))})),r?t:t.create(a)}(r?function(t,e,n){const i=t.groups(),r=t.data(),s=(i?i.names:[]).concat(e),a=(i?i.get:[]).concat(e.map((e=>t.getter(e)))),o=new Set,c=Ze(a);t.scan(((t,e)=>o.add(c(t,e))));const l=t.columnNames(),u=Ut(),h=l.map((t=>u.add(t,[])));l.forEach(((e,n)=>{const i=r[e],s=h[n];t.scan((t=>s.push(i.get(t))))}));const p=Ze(a.map(((t,e)=>t=>t[e]))),d=of("v","{"+h.map(((t,e)=>`_${e}.push(v[$${e}]);`)).join("")+"}",h,l.map((t=>s.indexOf(t))));if(i){let t=i.keys.length;const e=n.reduce(((t,e)=>t*e.length),i.size),r=new Uint32Array(e+(t-o.size));r.set(i.keys),Zf(i,n,((e,n)=>{o.has(p(e))||(d(e),r[t++]=n[0])})),u.groupby({...i,keys:r})}else Zf(i,n,(t=>{o.has(p(t))||d(t)}));return t.create(u.new())}(t,n,i):t,e,r)}function Zf(t,e,n){const i=t?t.get.length:0,r=t?1:0,s=r+e.length,a=new Int32Array(s),o=new Int32Array(s),c=[];if(t){const{get:e,rows:n,size:r}=t;a[0]=r,c.push(((t,r)=>{const s=n[r];for(let n=0;n{const n=e+i;a[e+r]=t.length,c.push(((e,i)=>e[n]=t[i]))}));const l=Array(i+e.length);for(let t=0;t=0;){const e=++o[t];ei[t][e],o=t.length;for(let n=0;n1){const e=r.add(t[n],Array(s));for(let t=0;te.field?t.set(n,Ie(e+"")):0))}function em(t,e){const n=new Map;return t.scan(((t,i)=>{const r=e(t,i);null!=r&&r==r&&n.set(r,t)})),n}function nm(t,e,n,{names:i,exprs:r},s={}){const a=t.data(),o=t.indices(!1),c=o.length,l=new Int32Array(c),u=e.data(),h=e.indices(!1),p=h.length,d=new Int32Array(p),f=i.length,m=Ut(),y=Array(f),g=Array(f);for(let t=0;t`_${e}.push($${e}(${n}));`))+"}",t,e)}(y,g);if((vt(n)?rm:im)(b,n,a,u,o,h,l,d,c,p),s.left)for(let t=0;t=u?(h=i,p=e,d=o,f=s,m=r,y=n,g=c,b=a):(h=r,p=n,d=c,f=a,m=i,y=e,g=o,b=s,v=(e,n,i,r)=>t(i,r,e,n));const _=function(t,e,n){const i=new Map,r=t.length;for(let s=0;s{Lt(n=It(n)?e.columnName(n):n)?i.set(r,Fd(n)):At(n)||Nt(n)&&n.expr?i.set(r,n):St(`Invalid ${t} key value: ${n+""}`)}));return Ze(bd(i,{table:e,aggregate:!1,window:!1}).exprs,!0)}function am(t,e,n){if(n)Lt(n)?n=[n,n]:vt(n)&&1===n.length&&(n=[n[0],n[0]]);else{const i=function(t,e){const n=new Set(e);return t.filter((t=>n.has(t)))}(t.columnNames(),e.columnNames());i.length||St("Natural join requires shared column names."),n=[i,i]}return n}function om(t,e,n,i){return n.length!==i.length&&St("Mismatched number of join keys"),[sm("join",t,n),sm("join",e,i)]}const cm={aggregate:!1,window:!1,index:1};function lm(t,e,n,i,r={}){n=am(t,e,n);const s={join:[t,e]};let a;if(vt(n)){const[s,o]=n.map(_t);a=om(t,e,s,o),i||(i=function(t,e,n,i){const r=[];e.forEach(((t,e)=>Lt(t)&&t===n[e]?r.push(t):0));const s=Nu(r);if(i.left&&i.right){const e=new Set(r);return[t.columnNames().map((t=>{const n=`[${be(t)}]`;return e.has(t)?{[t]:`(a, b) => a${n} == null ? b${n} : a${n}`}:t})),s]}return i.right?[s,Cu()]:[Cu(),s]}(t,s,o,r))}else a=bd({on:n},s).exprs[0],i||(i=[Cu(),Cu()]);return nm(t,e,a,function(t,e,n,i,r=[]){if(vt(n)){let s,a,o,c=n.length;s=a=o={names:[],exprs:[]},c--&&(s=Qf("join",t,n[0],i)),c--&&(a=Qf("join",e,n[1],cm)),c--&&(o=bd(n[2],i));const l=new Set,u=new Set(s.names);return a.names.forEach((t=>{u.has(t)&&l.add(t)})),l.size&&(um(s.names,l,r[0]||"_1"),um(a.names,l,r[1]||"_2")),{names:s.names.concat(a.names,o.names),exprs:s.exprs.concat(a.exprs,o.exprs)}}return bd(n,i)}(t,e,i,s,r&&r.suffix),r)}function um(t,e,n){t.forEach(((i,r)=>e.has(i)?t[r]=i+n:0))}function hm(t,e,n,[i,r]){const s=em(n,r);e.scan(((e,n)=>{s.get(i(e,n))>=0&&t.set(e)}))}function pm(t,e,n,i){const r=e.numRows(),s=n.numRows(),a=e.data(),o=n.data();if(e.isFiltered()||n.isFiltered()){const c=e.indices(!1),l=n.indices(!1);for(let e=0;enull!=t?t:e;function mm(t,e,n,i={}){const{keys:r,keyColumn:s}=function(t,e,n){const i=n.limit>0?+n.limit:1/0,r=fm(n.sort,!0),s=fm(n.keySeparator,"_"),a=Bf(t,e.ops,e.exprs),o=1===a.length?a[0]:(t,e)=>a.map((n=>n(t,e))).join(s),c=Array(t.totalRows());t.scan(((t,e)=>c[t]=o(t,e)));const l=Df(t.ungroup(),[{id:0,name:"array_agg_distinct",fields:[t=>c[t]],params:[]}])[0][0],u=r?l.sort():l;return{keys:Number.isFinite(i)?u.slice(0,i):u,keyColumn:c}}(t,e,i),a=fm(i.valueSeparator,"_"),o=n.names.length>1?(t,e)=>e+a+r[t]:t=>r[t],c=r.map((e=>Df(t,n.ops.map((t=>{if("count"===t.name){const n=t=>e===s[t]?1:NaN;return n.toString=()=>e+":1",{...t,name:"sum",fields:[n]}}const n=t.fields.map((t=>{const n=(n,i)=>e===s[n]?t(n,i):NaN;return n.toString=()=>e+":"+t,n}));return{...t,fields:n}})))));return t.create(function({names:t,exprs:e},n,i,r){const s=i?i.size:1,a=Ut(),o=r.length,c=t.length;let l;const u=(t,e)=>l[t][e];i&&Pf(a,i);for(let i=0;i1)for(let e=0;ee.field?t.set(n,xe(e+"")):0))}function gm(t,e){return Xf(t,bd(e,{table:t,aggronly:!0,window:!1}))}function bm(t,e,n,i){return(e?i?_m:vm:i?wm:xm)(t.length,t,n,i)}function vm(t,e,n){const i=n.length;for(let r=0;r=i)return n;for(let i=0;i=r)return n;const s=new Float32Array(r),a=new Uint32Array(r);for(let t=0;ts[t]-s[e]));for(let i=0;i{let i=e(n);return o+=i=r?i:Math.min(t.length,i),i}));const c=new Uint32Array(o);let l=0;return a.forEach(((t,i)=>{const s=e[i],a=c.subarray(l,l+=s);r||s!==t.length?bm(a,r,t,n):a.set(t)})),!1!==s&&(a.length>1||!r)&&function(t,e=0,n=t.length){let i=n-(e=+e);for(;i;){const n=he()*i--|0,r=t[i+e];t[i+e]=t[n+e],t[n+e]=r}}(c),t.reify(c)}const Im=t=>e=>t.get(e)||0;function Am(t,{names:e,exprs:n,ops:i=[]},r={}){if(0===e.length)return t;const s=1===e.length&&r.as||[],a=null==r.drop||!!r.drop,o=null==r.limit?s.length||1/0:Math.max(1,+r.limit||1),c=Bf(t,i,n),l=Ut(),u=e.reduce(((t,e,n)=>t.set(e,n)),new Map),h=(e,n)=>{const i=function(t,e,n){const i=t.totalRows(),r=[];return t.scan(((t,s)=>{const a=_t(e(t,s)),o=Math.min(a.length,n);for(;r.length{u.has(e)?(a||l.add(e,t.column(e)),h(u.get(e),e),u.delete(e)):l.add(e,t.column(e))})),u.forEach(h),t.create(l)}function Tm(t,{names:e=[],exprs:n=[],ops:i=[]}){const r=e.length;if(0===r)return null;if(1===r&&!t.isFiltered()&&n[0].field){const i=t.column(n[0].field);if(i.groups)return i.groups(e)}let s=Bf(t,i,n);const a=Ze(s),o=t.totalRows(),c=new Uint32Array(o),l={},u=[],h=t.data(),p=t.mask();if(p)for(let t=p.next(0);t>=0;t=p.next(t+1)){const e=a(t,h)+"",n=l[e];c[t]=null!=n?n:l[e]=u.push(t)-1}else for(let t=0;te=>t(e,h)))),{keys:c,get:s,names:e,rows:u,size:u.length}}const km=(t,e,n,i)=>`((u = ${t}) < (v = ${e}) || u == null) && v != null ? ${n}\n : (u > v || v == null) && u != null ? ${i}\n : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ${n}\n : v !== v && u === u ? ${i} : `;var Mm={__antijoin:(t,e,n)=>dm(t,e,n,{anti:!0}),__count:(t,e={})=>gm(t,{[e.as||"count"]:we()}),__cross:(t,e,n,i)=>lm(t,e,(()=>!0),n,{...i,left:!0,right:!0}),__concat:function(t,e){const n=t.numRows(),i=n+e.reduce(((t,e)=>t+e.numRows()),0);if(n===i)return t;const r=[t,...e],s=Ut();return t.columnNames().forEach((t=>{const e=Array(i);let n=0;r.forEach((i=>{const r=i.column(t)||{get:()=>Rt};i.scan((t=>e[n++]=r.get(t)))})),s.add(t,e)})),t.create(s.new())},__dedupe:function(t,e=[]){return t.groupby(e.length?e:t.columnNames()).filter("row_number() === 1").ungroup().reify()},__derive:function(t,e,n={}){const i=Yf(t,bd(e,{table:t}),n);return n.drop||null==n.before&&null==n.after?i:If(i,Object.keys(e).filter((e=>!t.column(e))),n)},__except:function(t,e){if(0===e.length)return t;const n=t.columnNames();return e.reduce(((t,e)=>t.antijoin(e.select(n))),t).dedupe()},__filter:function(t,e){const n=bd({p:e},{table:t});let i=n.exprs[0];if(n.ops.length){const{data:e}=Yf(t,n,{drop:!0}).column("p");i=t=>e[t]}return function(t,e){const n=t.totalRows(),i=t.mask(),r=t.data(),s=new Gf(n);if(i)for(let t=i.next(0);t>=0;t=i.next(t+1))e(t,r)&&s.set(t);else for(let t=0;te,(t,e)=>o.map((n=>n(t,e)))]},{...r,drop:e})}(t,Qf("fold",t,e),n)},__impute:function(t,e,n={}){if((e=bd(e,{table:t})).names.forEach((e=>t.column(e)?0:St(`Invalid impute column ${be(e)}`))),n.expand){const i={preparse:tm,aggronly:!0},r=Qf("impute",t,n.expand,i),s=Xf(t.ungroup(),r);return Jf(t,e,r.names,r.names.map((t=>s.get(t,0))))}return Jf(t,e)},__intersect:function(t,e){const n=t.columnNames();return e.length?e.reduce(((t,e)=>t.semijoin(e.select(n))),t).dedupe():t.reify([])},__join:lm,__lookup:function(t,e,n,i){return function(t,e,[n,i],{names:r,exprs:s,ops:a}){const o=Ut(t),c=t.totalRows();r.forEach((t=>o.add(t,Array(c).fill(Rt))));const l=em(e,i),u=of(["lr","rr","data"],"{"+Af(r,((t,e)=>`_[${e}][lr] = $[${e}](rr, data);`))+"}",r.map((t=>o.data[t])),Bf(e,a,s)),h=e.data();return t.scan(((t,e)=>{const i=l.get(n(t,e));i>=0&&u(t,i,h)})),t.create(o)}(t,e,[sm("lookup",t,(n=am(t,e,n))[0]),sm("lookup",e,n[1])],Qf("lookup",e,i))},__pivot:function(t,e,n,i){return mm(t,Qf("fold",t,e),Qf("fold",t,n,{preparse:ym,aggronly:!0}),i)},__relocate:If,__rename:function(t,e){const n=new Map;return t.columnNames((t=>(n.set(t,t),0))),Sf(t,ku(t,e,n))},__rollup:gm,__sample:function(t,e,n={}){return Sm(t,function(t,e){return It(e)?()=>e:Im(Xf(t,bd({size:e},{table:t,window:!1})).column("size"))}(t,e),function(t,e){return null==e?null:(e=It(e)?t.columnName(e):e,Im(Lt(e)?t.column(e):Yf(t,bd({w:e},{table:t}),{drop:!0}).column("w")))}(t,n.weight),n)},__select:function(t,e){return Sf(t,ku(t,e))},__semijoin:dm,__spread:function(t,e,n){return Am(t,Qf("spread",t,e),n)},__union:function(t,e){return t.concat(e).dedupe()},__unroll:function(t,e,n){return Kf(t,Qf("unroll",t,e),n&&n.drop?{...n,drop:Qf("unroll",t,n.drop).names}:n)},__groupby:function(t,e){return function(t,e){return t.create({groups:Tm(t,e)})}(t,Qf("groupby",t,e))},__orderby:function(t,e){return function(t,e){return t.create({order:e})}(t,function(t,e){let n=-1;const i=new Map,r=t=>i.set(++n+"",t);return e.forEach((e=>{const n=null!=e.expr?e.expr:e;if(Nt(n)&&!At(n))for(const t in n)r(n[t]);else r(It(n)?Fd(e,t.columnName(n)):Lt(n)?Fd(e):At(n)?e:St("Invalid orderby field: "+(e+"")))})),function(t,e){const n=[],i=[],r=[];let s=null,a="0",o="0";t.isGrouped()&&(s=t.groups().keys,a="ka",o="kb");const{ops:c}=bd(e,{table:t,value:(t,e)=>{if(n.push(t),e.escape){const t=t=>`fn[${r.length}](${t}, data)`;i.push([t("a"),t("b")]),r.push(e.escape)}else i.push([Qe(e,{index:"a",op:a}),Qe(e,{index:"b",op:o})])},window:!1}),l=Df(t,c),u=(t,e)=>l[t][e],h=n.length;let p="return (a, b) => {"+(u&&t.isGrouped()?"const ka = keys[a], kb = keys[b];":"")+"let u, v; return ";for(let t=0;tn.add(t,null)));const l=i?Uf(t,e,i):[Vf(t,e)];e.outputs().map((t=>n.add(t,[])));const u=c.length-1;let h=0;for(let t=0;t{const s=n.data[t]=Array(h),l=r[i];for(let t=0,n=0;tt[e.as||"text"]())).then((t=>n(t,e)))}function Nm(t,e){return vt(t)?function(t,e){return Ou.from(t,e)}(t):function(t,e={}){const n=Iu(e.autoType);Lt(t)&&(t=JSON.parse(t));let i,r=t.data;if(Nt(r)&&!zt(r)?t.schema&&t.schema.fields&&(i=t.schema.fields.map((t=>t.name))):r=t,n||e.parse){const t=e.parse||{};for(const e in r){const i=r[e],s=i.length;if(t[e])for(let n=0;ne?1:t>=e?0:NaN}function Bm(t,e){return null==t||null==e?NaN:et?1:e>=t?0:NaN}function Dm(t){let e,n,i;function r(t,i,r=0,s=t.length){if(r>>1;n(t[e],i)<0?r=e+1:s=e}while(rLm(t(e),n),i=(e,n)=>t(e)-n):(e=t===Lm||t===Bm?t:Fm,n=t,i=t),{left:r,center:function(t,e,n=0,s=t.length){const a=r(t,e,n,s-1);return a>n&&i(t[a-1],e)>-i(t[a],e)?a-1:a},right:function(t,i,r=0,s=t.length){if(r>>1;n(t[e],i)<=0?r=e+1:s=e}while(r=$m?10:s>=zm?5:s>=Hm?2:1;let o,c,l;return r<0?(l=Math.pow(10,-r)/a,o=Math.round(t*l),c=Math.round(e*l),o/le&&--c,l=-l):(l=Math.pow(10,r)*a,o=Math.round(t/l),c=Math.round(e/l),o*le&&--c),c=e)&&(n=e);else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(n=r)&&(n=r)}return n}function Km(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n>e||void 0===n&&e>=e)&&(n=e);else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(n>r||void 0===n&&r>=r)&&(n=r)}return n}function Qm(t,e){let n=0,i=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(++n,i+=e);else{let r=-1;for(let s of t)null!=(s=e(s,++r,t))&&(s=+s)>=s&&(++n,i+=s)}if(n)return i/n}function Jm(t,e,n){t=+t,e=+e,n=(r=arguments.length)<2?(e=t,t=0,1):r<3?1:+n;for(var i=-1,r=0|Math.max(0,Math.ceil((e-t)/n)),s=new Array(r);++i>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?wy(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?wy(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=hy.exec(t))?new Iy(e[1],e[2],e[3],1):(e=py.exec(t))?new Iy(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=dy.exec(t))?wy(e[1],e[2],e[3],e[4]):(e=fy.exec(t))?wy(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=my.exec(t))?Cy(e[1],e[2]/100,e[3]/100,1):(e=yy.exec(t))?Cy(e[1],e[2]/100,e[3]/100,e[4]):gy.hasOwnProperty(t)?xy(gy[t]):"transparent"===t?new Iy(NaN,NaN,NaN,0):null}function xy(t){return new Iy(t>>16&255,t>>8&255,255&t,1)}function wy(t,e,n,i){return i<=0&&(t=e=n=NaN),new Iy(t,e,n,i)}function Sy(t,e,n,i){return 1===arguments.length?((r=t)instanceof ry||(r=_y(r)),r?new Iy((r=r.rgb()).r,r.g,r.b,r.opacity):new Iy):new Iy(t,e,n,null==i?1:i);var r}function Iy(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}function Ay(){return`#${Ey(this.r)}${Ey(this.g)}${Ey(this.b)}`}function Ty(){const t=ky(this.opacity);return`${1===t?"rgb(":"rgba("}${My(this.r)}, ${My(this.g)}, ${My(this.b)}${1===t?")":`, ${t})`}`}function ky(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function My(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Ey(t){return((t=My(t))<16?"0":"")+t.toString(16)}function Cy(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Oy(t,e,n,i)}function Ny(t){if(t instanceof Oy)return new Oy(t.h,t.s,t.l,t.opacity);if(t instanceof ry||(t=_y(t)),!t)return new Oy;if(t instanceof Oy)return t;var e=(t=t.rgb()).r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),s=Math.max(e,n,i),a=NaN,o=s-r,c=(s+r)/2;return o?(a=e===s?(n-i)/o+6*(n0&&c<1?0:a,new Oy(a,o,c,t.opacity)}function Oy(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function Ly(t){return(t=(t||0)%360)<0?t+360:t}function By(t){return Math.max(0,Math.min(1,t||0))}function Dy(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}ny(ry,_y,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:by,formatHex:by,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Ny(this).formatHsl()},formatRgb:vy,toString:vy}),ny(Iy,Sy,iy(ry,{brighter(t){return t=null==t?ay:Math.pow(ay,t),new Iy(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?sy:Math.pow(sy,t),new Iy(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Iy(My(this.r),My(this.g),My(this.b),ky(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Ay,formatHex:Ay,formatHex8:function(){return`#${Ey(this.r)}${Ey(this.g)}${Ey(this.b)}${Ey(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Ty,toString:Ty})),ny(Oy,(function(t,e,n,i){return 1===arguments.length?Ny(t):new Oy(t,e,n,null==i?1:i)}),iy(ry,{brighter(t){return t=null==t?ay:Math.pow(ay,t),new Oy(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?sy:Math.pow(sy,t),new Oy(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new Iy(Dy(t>=240?t-240:t+120,r,i),Dy(t,r,i),Dy(t<120?t+240:t-120,r,i),this.opacity)},clamp(){return new Oy(Ly(this.h),By(this.s),By(this.l),ky(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=ky(this.opacity);return`${1===t?"hsl(":"hsla("}${Ly(this.h)}, ${100*By(this.s)}%, ${100*By(this.l)}%${1===t?")":`, ${t})`}`}}));var Fy=t=>()=>t;function Vy(t){return 1==(t=+t)?Uy:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}(e,n,t):Fy(isNaN(e)?n:e)}}function Uy(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Fy(isNaN(t)?e:t)}var Py=function t(e){var n=Vy(e);function i(t,e){var i=n((t=Sy(t)).r,(e=Sy(e)).r),r=n(t.g,e.g),s=n(t.b,e.b),a=Uy(t.opacity,e.opacity);return function(e){return t.r=i(e),t.g=r(e),t.b=s(e),t.opacity=a(e),t+""}}return i.gamma=t,i}(1);function Ry(t,e){e||(e=[]);var n,i=t?Math.min(e.length,t.length):0,r=e.slice();return function(s){for(n=0;ns&&(r=e.slice(s,r),o[a]?o[a]+=r:o[++a]=r),(n=n[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,c.push({i:a,x:zy(n,i)})),s=Yy.lastIndex;return se&&(n=t,t=e,e=n),function(n){return Math.max(t,Math.min(e,n))}}(a[0],a[t-1])),i=t>2?eg:tg,r=s=null,h}function h(e){return null==e||isNaN(e=+e)?n:(r||(r=i(a.map(t),o,c)))(t(l(e)))}return h.invert=function(n){return l(e((s||(s=i(o,a.map(t),zy)))(n)))},h.domain=function(t){return arguments.length?(a=Array.from(t,Qy),u()):a.slice()},h.range=function(t){return arguments.length?(o=Array.from(t),u()):o.slice()},h.rangeRound=function(t){return o=Array.from(t),c=Ky,u()},h.clamp=function(t){return arguments.length?(l=!!t||Zy,u()):l!==Zy},h.interpolate=function(t){return arguments.length?(c=t,u()):c},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,i){return t=n,e=i,u()}}function rg(){return ig()(Zy,Zy)}function sg(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,i=t.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+t.slice(n+1)]}function ag(t){return(t=sg(Math.abs(t)))?t[1]:NaN}var og,cg=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function lg(t){if(!(e=cg.exec(t)))throw new Error("invalid format: "+t);var e;return new ug({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function ug(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function hg(t,e){var n=sg(t,e);if(!n)return t+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}lg.prototype=ug.prototype,ug.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var pg={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>hg(100*t,e),r:hg,s:function(t,e){var n=sg(t,e);if(!n)return t+"";var i=n[0],r=n[1],s=r-(og=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,a=i.length;return s===a?i:s>a?i+new Array(s-a+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+sg(t,Math.max(0,e+s-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function dg(t){return t}var fg,mg,yg,gg=Array.prototype.map,bg=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function vg(t){var e,n,i=void 0===t.grouping||void 0===t.thousands?dg:(e=gg.call(t.grouping,Number),n=t.thousands+"",function(t,i){for(var r=t.length,s=[],a=0,o=e[0],c=0;r>0&&o>0&&(c+o+1>i&&(o=Math.max(1,i-c)),s.push(t.substring(r-=o,r+o)),!((c+=o+1)>i));)o=e[a=(a+1)%e.length];return s.reverse().join(n)}),r=void 0===t.currency?"":t.currency[0]+"",s=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",o=void 0===t.numerals?dg:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(gg.call(t.numerals,String)),c=void 0===t.percent?"%":t.percent+"",l=void 0===t.minus?"−":t.minus+"",u=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=lg(t)).fill,n=t.align,h=t.sign,p=t.symbol,d=t.zero,f=t.width,m=t.comma,y=t.precision,g=t.trim,b=t.type;"n"===b?(m=!0,b="g"):pg[b]||(void 0===y&&(y=12),g=!0,b="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var v="$"===p?r:"#"===p&&/[boxX]/.test(b)?"0"+b.toLowerCase():"",_="$"===p?s:/[%p]/.test(b)?c:"",x=pg[b],w=/[defgprs%]/.test(b);function S(t){var r,s,c,p=v,S=_;if("c"===b)S=x(t)+S,t="";else{var I=(t=+t)<0||1/t<0;if(t=isNaN(t)?u:x(Math.abs(t),y),g&&(t=function(t){t:for(var e,n=t.length,i=1,r=-1;i0&&(r=0)}return r>0?t.slice(0,r)+t.slice(e+1):t}(t)),I&&0==+t&&"+"!==h&&(I=!1),p=(I?"("===h?h:l:"-"===h||"("===h?"":h)+p,S=("s"===b?bg[8+og/3]:"")+S+(I&&"("===h?")":""),w)for(r=-1,s=t.length;++r(c=t.charCodeAt(r))||c>57){S=(46===c?a+t.slice(r+1):t.slice(r))+S,t=t.slice(0,r);break}}m&&!d&&(t=i(t,1/0));var A=p.length+t.length+S.length,T=A>1)+p+t+S+T.slice(A);break;default:t=T+p+t+S}return o(t)}return y=void 0===y?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y)),S.toString=function(){return t+""},S}return{format:h,formatPrefix:function(t,e){var n=h(((t=lg(t)).type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor(ag(e)/3))),r=Math.pow(10,-i),s=bg[8+i/3];return function(t){return n(r*t)+s}}}}function _g(t,e,n,i){var r,s=Wm(t,e,n);switch((i=lg(null==i?",f":i)).type){case"s":var a=Math.max(Math.abs(t),Math.abs(e));return null!=i.precision||isNaN(r=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(ag(e)/3)))-ag(Math.abs(t)))}(s,a))||(i.precision=r),yg(i,a);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(r=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,ag(e)-ag(t))+1}(s,Math.max(Math.abs(t),Math.abs(e))))||(i.precision=r-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(r=function(t){return Math.max(0,-ag(Math.abs(t)))}(s))||(i.precision=r-2*("%"===i.type))}return mg(i)}function xg(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){if(!((n=+n)>0))return[];if((t=+t)==(e=+e))return[t];const i=e=r))return[];const o=s-r+1,c=new Array(o);if(i)if(a<0)for(let t=0;t0;){if((r=Ym(c,l,n))===i)return s[a]=c,s[o]=l,e(s);if(r>0)c=Math.floor(c/r)*r,l=Math.ceil(l/r)*r;else{if(!(r<0))break;c=Math.ceil(c*r)/r,l=Math.floor(l*r)/r}i=r}return t},t}function wg(){var t=rg();return t.copy=function(){return ng(t,wg())},Zm.apply(t,arguments),xg(t)}fg=vg({thousands:",",grouping:[3],currency:["$",""]}),mg=fg.format,yg=fg.formatPrefix;const Sg=new Date,Ig=new Date;function Ag(t,e,n,i){function r(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return r.floor=e=>(t(e=new Date(+e)),e),r.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),r.round=t=>{const e=r(t),n=r.ceil(t);return t-e(e(t=new Date(+t),null==n?1:Math.floor(n)),t),r.range=(n,i,s)=>{const a=[];if(n=r.ceil(n),s=null==s?1:Math.floor(s),!(n0))return a;let o;do{a.push(o=new Date(+n)),e(n,s),t(n)}while(oAg((e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)}),((t,i)=>{if(t>=t)if(i<0)for(;++i<=0;)for(;e(t,-1),!n(t););else for(;--i>=0;)for(;e(t,1),!n(t););})),n&&(r.count=(e,i)=>(Sg.setTime(+e),Ig.setTime(+i),t(Sg),t(Ig),Math.floor(n(Sg,Ig))),r.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?r.filter(i?e=>i(e)%t==0:e=>r.count(0,e)%t==0):r:null)),r}const Tg=Ag((()=>{}),((t,e)=>{t.setTime(+t+e)}),((t,e)=>e-t));Tg.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?Ag((e=>{e.setTime(Math.floor(e/t)*t)}),((e,n)=>{e.setTime(+e+n*t)}),((e,n)=>(n-e)/t)):Tg:null),Tg.range;const kg=1e3,Mg=6e4,Eg=36e5,Cg=864e5,Ng=6048e5,Og=2592e6,Lg=31536e6,Bg=Ag((t=>{t.setTime(t-t.getMilliseconds())}),((t,e)=>{t.setTime(+t+e*kg)}),((t,e)=>(e-t)/kg),(t=>t.getUTCSeconds()));Bg.range;const Dg=Ag((t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*kg)}),((t,e)=>{t.setTime(+t+e*Mg)}),((t,e)=>(e-t)/Mg),(t=>t.getMinutes()));Dg.range;const Fg=Ag((t=>{t.setUTCSeconds(0,0)}),((t,e)=>{t.setTime(+t+e*Mg)}),((t,e)=>(e-t)/Mg),(t=>t.getUTCMinutes()));Fg.range;const Vg=Ag((t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*kg-t.getMinutes()*Mg)}),((t,e)=>{t.setTime(+t+e*Eg)}),((t,e)=>(e-t)/Eg),(t=>t.getHours()));Vg.range;const Ug=Ag((t=>{t.setUTCMinutes(0,0,0)}),((t,e)=>{t.setTime(+t+e*Eg)}),((t,e)=>(e-t)/Eg),(t=>t.getUTCHours()));Ug.range;const Pg=Ag((t=>t.setHours(0,0,0,0)),((t,e)=>t.setDate(t.getDate()+e)),((t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Mg)/Cg),(t=>t.getDate()-1));Pg.range;const Rg=Ag((t=>{t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+e)}),((t,e)=>(e-t)/Cg),(t=>t.getUTCDate()-1));Rg.range;const jg=Ag((t=>{t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+e)}),((t,e)=>(e-t)/Cg),(t=>Math.floor(t/Cg)));function $g(t){return Ag((e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)}),((t,e)=>{t.setDate(t.getDate()+7*e)}),((t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Mg)/Ng))}jg.range;const zg=$g(0),Hg=$g(1),qg=$g(2),Yg=$g(3),Wg=$g(4),Gg=$g(5),Kg=$g(6);function Qg(t){return Ag((e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)}),((t,e)=>(e-t)/Ng))}zg.range,Hg.range,qg.range,Yg.range,Wg.range,Gg.range,Kg.range;const Jg=Qg(0),Zg=Qg(1),Xg=Qg(2),tb=Qg(3),eb=Qg(4),nb=Qg(5),ib=Qg(6);Jg.range,Zg.range,Xg.range,tb.range,eb.range,nb.range,ib.range;const rb=Ag((t=>{t.setDate(1),t.setHours(0,0,0,0)}),((t,e)=>{t.setMonth(t.getMonth()+e)}),((t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear())),(t=>t.getMonth()));rb.range;const sb=Ag((t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)}),((t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear())),(t=>t.getUTCMonth()));sb.range;const ab=Ag((t=>{t.setMonth(0,1),t.setHours(0,0,0,0)}),((t,e)=>{t.setFullYear(t.getFullYear()+e)}),((t,e)=>e.getFullYear()-t.getFullYear()),(t=>t.getFullYear()));ab.every=t=>isFinite(t=Math.floor(t))&&t>0?Ag((e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)}),((e,n)=>{e.setFullYear(e.getFullYear()+n*t)})):null,ab.range;const ob=Ag((t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)}),((t,e)=>e.getUTCFullYear()-t.getUTCFullYear()),(t=>t.getUTCFullYear()));ob.every=t=>isFinite(t=Math.floor(t))&&t>0?Ag((e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),((e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)})):null,ob.range;const[cb,lb]=function(t,e,n,i,r,s){const a=[[Bg,1,kg],[Bg,5,5e3],[Bg,15,15e3],[Bg,30,3e4],[s,1,Mg],[s,5,3e5],[s,15,9e5],[s,30,18e5],[r,1,Eg],[r,3,108e5],[r,6,216e5],[r,12,432e5],[i,1,Cg],[i,2,1728e5],[n,1,Ng],[e,1,Og],[e,3,7776e6],[t,1,Lg]];function o(e,n,i){const r=Math.abs(n-e)/i,s=Dm((([,,t])=>t)).right(a,r);if(s===a.length)return t.every(Wm(e/Lg,n/Lg,i));if(0===s)return Tg.every(Math.max(Wm(e,n,i),1));const[o,c]=a[r/a[s-1][2][t.toLowerCase(),e])))}function Ib(t,e,n){var i=gb.exec(e.slice(n,n+1));return i?(t.w=+i[0],n+i[0].length):-1}function Ab(t,e,n){var i=gb.exec(e.slice(n,n+1));return i?(t.u=+i[0],n+i[0].length):-1}function Tb(t,e,n){var i=gb.exec(e.slice(n,n+2));return i?(t.U=+i[0],n+i[0].length):-1}function kb(t,e,n){var i=gb.exec(e.slice(n,n+2));return i?(t.V=+i[0],n+i[0].length):-1}function Mb(t,e,n){var i=gb.exec(e.slice(n,n+2));return i?(t.W=+i[0],n+i[0].length):-1}function Eb(t,e,n){var i=gb.exec(e.slice(n,n+4));return i?(t.y=+i[0],n+i[0].length):-1}function Cb(t,e,n){var i=gb.exec(e.slice(n,n+2));return i?(t.y=+i[0]+(+i[0]>68?1900:2e3),n+i[0].length):-1}function Nb(t,e,n){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return i?(t.Z=i[1]?0:-(i[2]+(i[3]||"00")),n+i[0].length):-1}function Ob(t,e,n){var i=gb.exec(e.slice(n,n+1));return i?(t.q=3*i[0]-3,n+i[0].length):-1}function Lb(t,e,n){var i=gb.exec(e.slice(n,n+2));return i?(t.m=i[0]-1,n+i[0].length):-1}function Bb(t,e,n){var i=gb.exec(e.slice(n,n+2));return i?(t.d=+i[0],n+i[0].length):-1}function Db(t,e,n){var i=gb.exec(e.slice(n,n+3));return i?(t.m=0,t.d=+i[0],n+i[0].length):-1}function Fb(t,e,n){var i=gb.exec(e.slice(n,n+2));return i?(t.H=+i[0],n+i[0].length):-1}function Vb(t,e,n){var i=gb.exec(e.slice(n,n+2));return i?(t.M=+i[0],n+i[0].length):-1}function Ub(t,e,n){var i=gb.exec(e.slice(n,n+2));return i?(t.S=+i[0],n+i[0].length):-1}function Pb(t,e,n){var i=gb.exec(e.slice(n,n+3));return i?(t.L=+i[0],n+i[0].length):-1}function Rb(t,e,n){var i=gb.exec(e.slice(n,n+6));return i?(t.L=Math.floor(i[0]/1e3),n+i[0].length):-1}function jb(t,e,n){var i=bb.exec(e.slice(n,n+1));return i?n+i[0].length:-1}function $b(t,e,n){var i=gb.exec(e.slice(n));return i?(t.Q=+i[0],n+i[0].length):-1}function zb(t,e,n){var i=gb.exec(e.slice(n));return i?(t.s=+i[0],n+i[0].length):-1}function Hb(t,e){return _b(t.getDate(),e,2)}function qb(t,e){return _b(t.getHours(),e,2)}function Yb(t,e){return _b(t.getHours()%12||12,e,2)}function Wb(t,e){return _b(1+Pg.count(ab(t),t),e,3)}function Gb(t,e){return _b(t.getMilliseconds(),e,3)}function Kb(t,e){return Gb(t,e)+"000"}function Qb(t,e){return _b(t.getMonth()+1,e,2)}function Jb(t,e){return _b(t.getMinutes(),e,2)}function Zb(t,e){return _b(t.getSeconds(),e,2)}function Xb(t){var e=t.getDay();return 0===e?7:e}function tv(t,e){return _b(zg.count(ab(t)-1,t),e,2)}function ev(t){var e=t.getDay();return e>=4||0===e?Wg(t):Wg.ceil(t)}function nv(t,e){return t=ev(t),_b(Wg.count(ab(t),t)+(4===ab(t).getDay()),e,2)}function iv(t){return t.getDay()}function rv(t,e){return _b(Hg.count(ab(t)-1,t),e,2)}function sv(t,e){return _b(t.getFullYear()%100,e,2)}function av(t,e){return _b((t=ev(t)).getFullYear()%100,e,2)}function ov(t,e){return _b(t.getFullYear()%1e4,e,4)}function cv(t,e){var n=t.getDay();return _b((t=n>=4||0===n?Wg(t):Wg.ceil(t)).getFullYear()%1e4,e,4)}function lv(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+_b(e/60|0,"0",2)+_b(e%60,"0",2)}function uv(t,e){return _b(t.getUTCDate(),e,2)}function hv(t,e){return _b(t.getUTCHours(),e,2)}function pv(t,e){return _b(t.getUTCHours()%12||12,e,2)}function dv(t,e){return _b(1+Rg.count(ob(t),t),e,3)}function fv(t,e){return _b(t.getUTCMilliseconds(),e,3)}function mv(t,e){return fv(t,e)+"000"}function yv(t,e){return _b(t.getUTCMonth()+1,e,2)}function gv(t,e){return _b(t.getUTCMinutes(),e,2)}function bv(t,e){return _b(t.getUTCSeconds(),e,2)}function vv(t){var e=t.getUTCDay();return 0===e?7:e}function _v(t,e){return _b(Jg.count(ob(t)-1,t),e,2)}function xv(t){var e=t.getUTCDay();return e>=4||0===e?eb(t):eb.ceil(t)}function wv(t,e){return t=xv(t),_b(eb.count(ob(t),t)+(4===ob(t).getUTCDay()),e,2)}function Sv(t){return t.getUTCDay()}function Iv(t,e){return _b(Zg.count(ob(t)-1,t),e,2)}function Av(t,e){return _b(t.getUTCFullYear()%100,e,2)}function Tv(t,e){return _b((t=xv(t)).getUTCFullYear()%100,e,2)}function kv(t,e){return _b(t.getUTCFullYear()%1e4,e,4)}function Mv(t,e){var n=t.getUTCDay();return _b((t=n>=4||0===n?eb(t):eb.ceil(t)).getUTCFullYear()%1e4,e,4)}function Ev(){return"+0000"}function Cv(){return"%"}function Nv(t){return+t}function Ov(t){return Math.floor(+t/1e3)}function Lv(t){return new Date(t)}function Bv(t){return t instanceof Date?+t:+new Date(+t)}function Dv(t,e,n,i,r,s,a,o,c,l){var u=rg(),h=u.invert,p=u.domain,d=l(".%L"),f=l(":%S"),m=l("%I:%M"),y=l("%I %p"),g=l("%a %d"),b=l("%b %d"),v=l("%B"),_=l("%Y");function x(t){return(c(t)=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Nv,s:Ov,S:Zb,u:Xb,U:tv,V:nv,w:iv,W:rv,x:null,X:null,y:sv,Y:ov,Z:lv,"%":Cv},_={a:function(t){return a[t.getUTCDay()]},A:function(t){return s[t.getUTCDay()]},b:function(t){return c[t.getUTCMonth()]},B:function(t){return o[t.getUTCMonth()]},c:null,d:uv,e:uv,f:mv,g:Tv,G:Mv,H:hv,I:pv,j:dv,L:fv,m:yv,M:gv,p:function(t){return r[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Nv,s:Ov,S:bv,u:vv,U:_v,V:wv,w:Sv,W:Iv,x:null,X:null,y:Av,Y:kv,Z:Ev,"%":Cv},x={a:function(t,e,n){var i=d.exec(e.slice(n));return i?(t.w=f.get(i[0].toLowerCase()),n+i[0].length):-1},A:function(t,e,n){var i=h.exec(e.slice(n));return i?(t.w=p.get(i[0].toLowerCase()),n+i[0].length):-1},b:function(t,e,n){var i=g.exec(e.slice(n));return i?(t.m=b.get(i[0].toLowerCase()),n+i[0].length):-1},B:function(t,e,n){var i=m.exec(e.slice(n));return i?(t.m=y.get(i[0].toLowerCase()),n+i[0].length):-1},c:function(t,n,i){return I(t,e,n,i)},d:Bb,e:Bb,f:Rb,g:Cb,G:Eb,H:Fb,I:Fb,j:Db,L:Pb,m:Lb,M:Vb,p:function(t,e,n){var i=l.exec(e.slice(n));return i?(t.p=u.get(i[0].toLowerCase()),n+i[0].length):-1},q:Ob,Q:$b,s:zb,S:Ub,u:Ab,U:Tb,V:kb,w:Ib,W:Mb,x:function(t,e,i){return I(t,n,e,i)},X:function(t,e,n){return I(t,i,e,n)},y:Cb,Y:Eb,Z:Nb,"%":jb};function w(t,e){return function(n){var i,r,s,a=[],o=-1,c=0,l=t.length;for(n instanceof Date||(n=new Date(+n));++o53)return null;"w"in s||(s.w=1),"Z"in s?(r=(i=hb(pb(s.y,0,1))).getUTCDay(),i=r>4||0===r?Zg.ceil(i):Zg(i),i=Rg.offset(i,7*(s.V-1)),s.y=i.getUTCFullYear(),s.m=i.getUTCMonth(),s.d=i.getUTCDate()+(s.w+6)%7):(r=(i=ub(pb(s.y,0,1))).getDay(),i=r>4||0===r?Hg.ceil(i):Hg(i),i=Pg.offset(i,7*(s.V-1)),s.y=i.getFullYear(),s.m=i.getMonth(),s.d=i.getDate()+(s.w+6)%7)}else("W"in s||"U"in s)&&("w"in s||(s.w="u"in s?s.u%7:"W"in s?1:0),r="Z"in s?hb(pb(s.y,0,1)).getUTCDay():ub(pb(s.y,0,1)).getDay(),s.m=0,s.d="W"in s?(s.w+6)%7+7*s.W-(r+5)%7:s.w+7*s.U-(r+6)%7);return"Z"in s?(s.H+=s.Z/100|0,s.M+=s.Z%100,hb(s)):ub(s)}}function I(t,e,n,i){for(var r,s,a=0,o=e.length,c=n.length;a=c)return-1;if(37===(r=e.charCodeAt(a++))){if(r=e.charAt(a++),!(s=x[r in yb?e.charAt(a++):r])||(i=s(t,n,i))<0)return-1}else if(r!=n.charCodeAt(i++))return-1}return i}return v.x=w(n,v),v.X=w(i,v),v.c=w(e,v),_.x=w(n,_),_.X=w(i,_),_.c=w(e,_),{format:function(t){var e=w(t+="",v);return e.toString=function(){return t},e},parse:function(t){var e=S(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=w(t+="",_);return e.toString=function(){return t},e},utcParse:function(t){var e=S(t+="",!0);return e.toString=function(){return t},e}}}(t),fb=db.format,mb=db.parse,db.utcFormat,db.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}(Vv,Error),Vv.buildMessage=function(t,e){var n={literal:function(t){return'"'+r(t.text)+'"'},class:function(t){var e,n="";for(e=0;e0){for(e=1,i=1;eat&&(at=rt,ot=[]),ot.push(t))}function dt(){var t,e,n,r,s;for(t=rt,e=[],n=Ot();n!==i;)e.push(n),n=Ot();if(e!==i)if(n=function(){var t,e,n,r,s,a;if(t=rt,e=ft(),e!==i){for(n=[],r=rt,s=[],a=Ot();a!==i;)s.push(a),a=Ot();for(s!==i&&(a=ft())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;){for(n.push(r),r=rt,s=[],a=Ot();a!==i;)s.push(a),a=Ot();s!==i&&(a=ft())!==i?r=s=[s,a]:(rt=r,r=i)}n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),n===i&&(n=null),n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i?t=e=a(n):(rt=t,t=i)}else rt=t,t=i;else rt=t,t=i;return t}function ft(){var e,n,r,s,a,h;if(e=rt,n=function(){var e,n,r,s,a,o,h;e=rt,c.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(l));if(n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i&&(s=wt())!==i?(a=rt,(o=Tt())===i&&(o=null),o!==i&&(h=yt())!==i?a=o=[o,h]:(rt=a,a=i),a===i&&(a=null),a!==i?e=n=u(n,s,a):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}(),n!==i){for(r=[],s=rt,a=[],h=Ot();h!==i;)a.push(h),h=Ot();for(a!==i&&(h=mt())!==i?s=a=[a,h]:(rt=s,s=i);s!==i;){for(r.push(s),s=rt,a=[],h=Ot();h!==i;)a.push(h),h=Ot();a!==i&&(h=mt())!==i?s=a=[a,h]:(rt=s,s=i)}r!==i?e=n=o(n,r):(rt=e,e=i)}else rt=e,e=i;return e}function mt(){var e;return(e=function(){var e,n;e=rt,h.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(p));n!==i&&(n=d());return e=n,e}())===i&&(e=function(){var e,n,r,s;e=rt,f.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(m));if(n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i&&(s=yt())!==i?e=n=y(n,s):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,g.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(b));if(n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i&&(s=gt())!==i?e=n=v(n,s):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,_.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(x));if(n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i&&(s=gt())!==i?e=n=w(n,s):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,S.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(I));if(n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i?(s=function(){var t,e,n,r,s,a;if(t=rt,e=bt(),e!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=bt())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=bt())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),s!==i?e=n=y(n,s):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,T.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(k));if(n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i?(s=function(){var t,e,n,r,s,a;if(t=rt,e=vt(),e!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=vt())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=vt())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),s!==i?e=n=y(n,s):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,E.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(C));if(n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i?(s=function(){var t,e,n,r,s,a;if(t=rt,e=_t(),e!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=_t())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=_t())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),s!==i?e=n=y(n,s):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,O.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(L));if(n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i?(s=function(){var t,e,n,r,s,a;if(t=rt,e=wt(),e!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=wt())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=wt())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),s!==i?e=n=y(n,s):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,B.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(D));if(n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i?(s=function(){var t,e,n,r,s,a;if(t=rt,e=xt(),e!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=xt())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=xt())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),s!==i?e=n=y(n,s):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}()),e}function yt(){var t,e,n,r,s,a;if(t=rt,(e=wt())!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=wt())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=wt())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}function gt(){var t,e,n,r,s,a;if(t=rt,(e=It())!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=It())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=It())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}function bt(){var t,e,n,r,s,a;return t=rt,(e=wt())!==i?((n=Tt())===i&&(n=null),n!==i&&(r=wt())!==i?((s=Tt())===i&&(s=null),s!==i&&(a=wt())!==i?t=e=A(e,r,a):(rt=t,t=i)):(rt=t,t=i)):(rt=t,t=i),t}function vt(){var t,e,n,r;return t=rt,(e=wt())!==i?((n=Tt())===i&&(n=null),n!==i&&(r=wt())!==i?t=e=M(e,r):(rt=t,t=i)):(rt=t,t=i),t}function _t(){var t,e,n,r;return t=rt,(e=wt())!==i?((n=Tt())===i&&(n=null),n!==i&&(r=wt())!==i?t=e=N(e,r):(rt=t,t=i)):(rt=t,t=i),t}function xt(){var t,e,n,r,s,a,o,c,l,u,h;return t=rt,(e=St())!==i?((n=Tt())===i&&(n=null),n!==i&&(r=St())!==i?((s=Tt())===i&&(s=null),s!==i&&(a=It())!==i&&Tt()!==i&&(o=At())!==i?((c=Tt())===i&&(c=null),c!==i&&(l=At())!==i?((u=Tt())===i&&(u=null),u!==i&&(h=wt())!==i?t=e=F(e,r,a,o,l,h):(rt=t,t=i)):(rt=t,t=i)):(rt=t,t=i)):(rt=t,t=i)):(rt=t,t=i),t}function wt(){var t,e,n,r;return t=rt,(e=It())!==i?((n=Tt())===i&&(n=null),n!==i&&(r=It())!==i?t=e=V(e,r):(rt=t,t=i)):(rt=t,t=i),t}function St(){var t;return rt,(t=Mt())===i&&(t=Nt()),t!==i&&(t=U(t)),t}function It(){var t,e,n;return rt,t=rt,(e=Ct())===i&&(e=null),e!==i&&(n=Mt())!==i?t=e=[e,n]:(rt=t,t=i),t===i&&(t=rt,(e=Ct())===i&&(e=null),e!==i&&(n=Nt())!==i?t=e=[e,n]:(rt=t,t=i)),t!==i&&(t=P(t)),t}function At(){var e;return rt,R.test(t.charAt(rt))?(e=t.charAt(rt),rt++):(e=i,pt(j)),e!==i&&(e=$(e)),e}function Tt(){var t,e,n,r,s;if(t=rt,e=[],(n=Ot())!==i)for(;n!==i;)e.push(n),n=Ot();else e=i;if(e!==i)if((n=kt())===i&&(n=null),n!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i?t=e=[e,n,r]:(rt=t,t=i)}else rt=t,t=i;else rt=t,t=i;if(t===i){if(t=rt,e=rt,(n=kt())!==i){for(r=[],s=Ot();s!==i;)r.push(s),s=Ot();r!==i?e=n=[n,r]:(rt=e,e=i)}else rt=e,e=i;e!==i&&(e=z()),t=e}return t}function kt(){var e;return 44===t.charCodeAt(rt)?(e=H,rt++):(e=i,pt(q)),e}function Mt(){var e,n,r;return rt,e=rt,n=function(){var e,n,r,s,a;e=rt,n=rt,r=Nt(),r===i&&(r=null);r!==i?(46===t.charCodeAt(rt)?(s=W,rt++):(s=i,pt(G)),s!==i&&(a=Nt())!==i?n=r=[r,s,a]:(rt=n,n=i)):(rt=n,n=i);n===i&&(n=rt,(r=Nt())!==i?(46===t.charCodeAt(rt)?(s=W,rt++):(s=i,pt(G)),s!==i?n=r=[r,s]:(rt=n,n=i)):(rt=n,n=i));n!==i&&(n=Y(n));return e=n,e}(),n!==i?((r=Et())===i&&(r=null),r!==i?e=n=[n,r]:(rt=e,e=i)):(rt=e,e=i),e===i&&(e=rt,(n=Nt())!==i&&(r=Et())!==i?e=n=[n,r]:(rt=e,e=i)),e!==i&&(e=Y(e)),e}function Et(){var e,n,r,s;return rt,e=rt,K.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(Q)),n!==i?((r=Ct())===i&&(r=null),r!==i&&(s=Nt())!==i?e=n=[n,r,s]:(rt=e,e=i)):(rt=e,e=i),e!==i&&(e=Y(e)),e}function Ct(){var e;return J.test(t.charAt(rt))?(e=t.charAt(rt),rt++):(e=i,pt(Z)),e}function Nt(){var e,n;if(rt,e=[],X.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(tt)),n!==i)for(;n!==i;)e.push(n),X.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(tt));else e=i;return e!==i&&(e=et(e)),e}function Ot(){var e;return rt,nt.test(t.charAt(rt))?(e=t.charAt(rt),rt++):(e=i,pt(it)),e!==i&&(e=z()),e}var Lt,Bt,Dt,Ft={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var Vt in Ft)Ft[Vt.toUpperCase()]=Ft[Vt];function Ut(t,e){e||(e=[{}]);for(var n=e.length;n--;){var i={code:t,command:Ft[t]};for(var r in t==t.toLowerCase()&&(i.relative=!0),e[n])i[r]=e[n][r];e[n]=i}return e}if((n=s())!==i&&rt===t.length)return n;throw n!==i&&rte[t]===i))).reify():s===jv.RANGE&&(a=nf().filter(Om((e=>">="===r?e[t]>=i:e[t]<=i))).reify()),e.push(a)}return e}function zv(t,e,n){if(n===jv.POINT)return[{[t]:{value:e[t],type:n}}];console.log("TODO")}const Hv=1,qv=.1,Yv="__opacity__",Wv="tick",Gv="background",Kv="foreground",Qv="svgPlot",Jv="svg",Zv="g",Xv="ellipse",t_="line",e_="polygon",n_="polyline",i_="rect",r_="path",s_="text",a_="#text",o_="style",c_="left",l_="right",u_="top",h_="bottom",p_="centerX",d_="centerY",f_="width",m_="height",y_="size",g_="colorCat",b_="fill",v_="color",__="stroke",x_="__inferred__data__",w_="__role__",S_="legend",I_="axis-domain",A_="title",T_="orphan-tick",k_="viewport",M_="mark",E_="_mark_",C_="_I_",N_="_gI_",O_=2,L_={COUNT:"count",MIN:"min",MAX:"max",MEAN:"mean",SUM:"sum",STDEV:"stdev",MEDIAN:"median"},B_={NONE:0,DIRECT:1,SUBSET:2,AGGREGATE:3};function D_(t,e,n=O_){return"string"==typeof t&&"string"==typeof e?t.toLowerCase()===e.toLowerCase():Math.abs(t-e)<=n}function F_(t,e,n,i=O_){const r=[],s=[];let a=0,o=0;for(;a!n.includes(t)))}function U_(t,e,n,i,r=!0){function s(){}function a(t,e,n,i){const r=t.orderby(n).array(C_),s=e.orderby(i).array(C_),a=Object.fromEntries(r.map(((t,e)=>[t,s[e]]))),o=Object.fromEntries(s.map(((t,e)=>[t,r[e]]))),c=V_(t).filter((t=>!n.includes(t)));let l;if(c.length){const r=t.orderby(n).select(c);l=e.orderby(i).assign(r).orderby(C_).reify()}return{map:{fromToMap:a,toFromMap:o,mergedTable:l}}}function o(t,e,n){return{fromToQuery:nf().groupby([...t,C_]).rollup(n),toFromQuery:nf().groupby(t).derive(n),assignTable:Em({[N_]:e})}}function c(t,e,n=!1){const r=V_(t),s=V_(e);if(!r.length||!s.length||e.numRows()>t.numRows())return null;2===r.length&&r.includes("precipitation")&&r.includes("MEAN-maximum daily temperature (c)")&&2===s.length&&s.includes("precipitation (binned)")&&s.includes("mean of temp_max");const o={},c=[],l=[],u=[];for(let n=0;n=m.length){t=t.filter(Om((t=>f.includes(t[C_])))).reify(),o[r[a]]=s[n],c.push(a),l.push(r[a]),u.push(s[n]);break}}}const h=Object.keys(o).length,p=Object.keys(o).length!==s.length;return h&&t.numRows()>e.numRows()&&(t=t.slice(0,e.numRows())),n&&h||!n&&h&&!p?{fields:o,...a(t,e,l,u)}:{}}function l(t,e,i,r){const s=V_(t),a=V_(e);if(s.length2)return null;for(let a=0;aString(Me.bin(e[s[a]],...t)+t[2]/2)))}}));for(const n of h){const o=l(t,e,[...i,n],[...r,s[a]]);if(o)return o}}}return s.exists=function(t){return t&&Object.keys(t).length},s.direct=function(){const n=c(t,e,!1);return{link:n,type:s.exists(n)?B_.DIRECT:B_.NONE}},s.subset=function(){const n=c(t,e,!0);return{link:n,type:s.exists(n)?B_.SUBSET:B_.NONE}},s.aggregate=function(){const n=l(t,e,[],[]);return{link:n,type:s.exists(n)?B_.AGGREGATE:B_.NONE}},s.getLink=function(){const t=s.direct();if(t.type===B_.DIRECT)return t;if(r){const t=s.aggregate();if(t.type===B_.AGGREGATE)return t}const e=s.subset();return e.type===B_.SUBSET?e:{type:B_.NONE}},s}function P_(t){const{yAxis:e}=t,{scale:n,ticks:i,ordinal:r}=e,s=r.length?[]:function(t,e){const n=t.domain(),i=Math.abs(n[0]-n[1])/(e.length-1);return[...n,i]}(n,i);return[s]}function R_(t){const e={},n=.01,{xAxis:i,yAxis:r,legends:s}=t,{domain:a}=i,{domain:o}=r;i.ordinal.length||(e[i.title.innerHTML.toLowerCase()]=Math.abs(a[1]-a[0])*n),r.ordinal.length||(e[r.title.innerHTML.toLowerCase()]=Math.abs(o[1]-o[0])*n);for(const t of s)if(t.type===y_){const{scale:i}=t,r=i.domain();e[t.title.innerHTML.toLowerCase()]=Math.abs(r[0]-r[r.length-1])*n}return e}function j_(t,e,n,i,r=!1){const{aggregation:s,fields:a,map:o}=e,{fromToMap:c,toFromMap:l,mergedTable:u}=o;let h,p,d;s&&({fromToQuery:h,toFromQuery:p,assignTable:d}=s);const f={type:t,next:n,map:c,fields:a},m={type:t,next:i,map:l,fields:z_(a)};t===B_.DIRECT||t===B_.SUBSET?(i.children.push(f),n.children.push(m),r&&t===B_.SUBSET&&(n.table=u)):(i.children.push({...f,aggregation:{query:h,assignTable:d}}),n.parents.push({...m,aggregation:{query:p,assignTable:d}}))}function $_(t,e){const n=new Map;!function(t,e,n){const{table:i}=e;if(!i)return;const r=new Map;for(const n of t){const{data:t}=n;if(!t.table)continue;const s=U_(i,t.table,null,R_(n)),{type:a,link:o}=s.direct(),c=[];if(a===B_.DIRECT){if(!o.map.mergedTable)return;r.set(n,!0),c.push([a,o,t])}c.forEach((t=>j_(...t,e)))}for(const s of t){const{data:t}=s;if(r.has(s))continue;if(!t.table)continue;const{type:a,link:o}=U_(i,t.table,P_(s),R_(s),!0).aggregate();a===B_.AGGREGATE&&(j_(a,o,t,e),n.set(s,!0))}}(t,e,n),function(t,e){for(let n=0;n[t[e],e])))}function H_(t,e){return e.map((e=>t[e]))}function q_(t,e){return Object.fromEntries(Object.keys(t).filter((t=>t in e)).map((n=>[e[n],t[n]])))}function Y_(t,e){return Object.fromEntries(Object.keys(t).map((n=>n in e?[n,e[n]]:[n,t[n]])))}function W_(t,e){let{table:n}=t;for(const[t,i]of e){const{query:e}=t;n=e.evaluate(n);const r=H_(z_(i),Array.from(n._group.keys)).map((t=>Number(t)));n=n.assign(Em({[N_]:r}))}return n.ungroup()}function G_(t,e,n){const i=t.array(C_).map((t=>n[t]));return[t.assign({[C_]:i}),e.filter(Om((t=>i.includes(t[C_])))).reify()].map((t=>t.filter(Om((t=>null!=t[C_])))))}function K_(t,e,n=!1){const i=new Map;function r(t,e){if(i.has(t))return;i.set(t,!0);const{active:n,table:s}=t;n.selected=e;const{children:a}=t;for(const t of a){const{next:n,map:i,aggregation:a,fields:o,type:c}=t;let l,u=n.table;if(n.active.type=c,a){const{query:t,assignTable:n}=a,r=Object.fromEntries(s.array(C_).map((t=>[t,t])));[,l]=G_(e,s.assign(n),r),l=t.evaluate(l.rename({[N_]:C_})),[l,u]=G_(l,u,i),u=u.orderby(C_).assign(l.rename(o).orderby(C_)).unorder()}else[,u]=G_(e,u,i);r(n,u)}}function s(t){if(i.has(t))return;i.set(t,!0);const{active:e,children:n}=t;e.selected=e.table;for(const t of n){const{next:e}=t;e.active.type=B_.NONE,s(e)}}for(const i of t){const[t,a,o]=i,{active:c}=t;if(e){e=e.map((t=>(t=q_(t,o),V_(a,!0).includes(N_)&&C_ in t&&(t[N_]=t[C_],delete t[C_]),t)));let i=c.selected.numRows(){i=t.evaluate(i||a)})),n&&(i=t.active.selected.concat(i)),r(t,i)}else s(t)}}function Q_(t,e){!function(t,e){bt(t).attr("opacity",e)}(t,e)}function J_(t){Q_(t,t[0][Yv]||Hv)}function Z_(t,e){!function(t){Q_(t,qv)}(t),Q_(e,Hv)}function X_(t,e){for(const n of t){if(!n.title)continue;const t=n.title.innerHTML.toLowerCase(),i=e.array(t);if("precipitation"===t)continue;const r=n.marks.filter((e=>i.includes(e.mark[x_][t]))).map((t=>t.mark));Z_(n.marks.map((t=>t.mark)),r)}}function tx(t,e,n){const i=e.array(E_);bt("."+t+".AGGREGATE_LAYER").remove();const r=[];for(let s=0;s(i,r)=>null==t?i._getBBox()[e]-r._getBBox()[e]:n?i[t]-r[t]:(i[t]?i[t]:i.marks[0])._getBBox()[e]-(r[t]?r[t]:r.marks[0])._getBBox()[e];e.sort(i(p_)),e.sort(i(d_))}class lx{constructor(...t){if(t[0]instanceof lx){const[e]=t;this.translate={...e.translate},this.scale={...e.scale},this.rotate=e.rotate}else{const[e,n,i,r,s]=t;this.translate={x:e||0,y:n||0},this.scale={x:i||1,y:r||1},this.rotate=s||0}}addTransform(t){return this.translate.x+=t.translate.x,this.translate.y+=t.translate.y,this.scale.x*=t.scale.x,this.scale.y*=t.scale.y,this.rotate+=t.rotate,this}getTransform(t=new lx){return"translate("+(this.translate.x+t.translate.x)+","+(this.translate.y+t.translate.y)+") scale("+this.scale.x*t.scale.x+","+this.scale.y*t.scale.y+") rotate("+(this.rotate+t.rotate)+")"}}const ux=1,hx=2,px=3,dx=4;function fx(t){return e=>+t(e)}function mx(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function yx(t,e,n){let i=[],r=null,s=null,a=6,o=6,c=3,l="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5;const u=t===ux||t===px?n.xAxis:n.yAxis,h=u.ticks;function p(){let n=null==r?e.ticks?e.ticks.apply(e,i):e.domain():r;const a=null==s?e.tickFormat?e.tickFormat.apply(e,i):nx:s,o=(e.bandwidth?mx:fx)(e.copy(),l);function c(e,n){e.value=n;const i=e.label,r=e.marks;i.innerHTML=u.ordinal.length||i.value===a(n)?i.value:a(n);const s=i.globalPosition.translate.x,c=i.globalPosition.translate.y,l=t===px?o(n)-s:0,h=t===dx?o(n)-c:0;i.setAttribute("transform",i.localTransform.getTransform(new lx(l,h)));for(const e of r){const i=e.globalPosition.translate.x,r=e.globalPosition.translate.y,s=t===px?o(n)-i:0,a=t===dx?o(n)-r:0;e.setAttribute("transform",e.localTransform.getTransform(new lx(s,a)))}}let p;for(n=t===dx||t===hx?n.reverse():n,p=0;prx(t))),value:0};c(t,n[p]),h[0].label.parentElement.appendChild(t.label),h[0].marks.forEach(((e,n)=>e.parentElement.insertBefore(t.marks[n],e))),h.push(t)}const d=h.length;for(;pt.remove())),h.pop()}}return p.applyTransform=function(t){return arguments.length?(scale_transform=t,p):p},p.scale=function(t){return arguments.length?(e=t,p):e},p.ticks=function(){return i=Array.from(arguments),p},p.tickArguments=function(t){return arguments.length?(i=null==t?[]:Array.from(t),p):i.slice()},p.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),p):r&&r.slice()},p.tickFormat=function(t){return arguments.length?(s=t,p):s},p.tickSize=function(t){return arguments.length?(a=o=+t,p):a},p.tickSizeInner=function(t){return arguments.length?(a=+t,p):a},p.tickSizeOuter=function(t){return arguments.length?(o=+t,p):o},p.tickPadding=function(t){return arguments.length?(c=+t,p):c},p.offset=function(t){return arguments.length?(l=+t,p):l},p}function gx(t,e){const n=t.step(),i=t(t.domain()[0])+t.paddingOuter()*n,r=t.bandwidth();let s=Math.round(Math.abs(e-i-r/2)/n);return s=Gm([0,Km([t.domain().length-1,s])]),t.domain()[t.domain().length-1-s]}function bx(t,e){return t.domain()[t.range().indexOf(e)]}function vx(t,e=new lx){if(!t.transform)return;const n=t.transform.baseVal;for(let t=0;t{const n=e._getBBox(),i=window.getComputedStyle(e),s=[n.width,n.height,i.fill,i.color,i.stroke].join(",");s in r?r[s].push([t,e]):r[s]=[[t,e]]})),Object.values(r).forEach((t=>n.push([i,a(t)])))}}else for(const[e,i]of Object.entries(t))n.push([e,a(i)]);return n}function r(t,e){const n=new Map,i=new Map;for(const[t,r]of e)for(const e of r)for(const r of e){const s=n.get(r);(!s||e.length>s.length)&&(n.set(r,e),i.set(e,t))}const r=[];for(let e=0;e({alignment:i.get(t),marks:t})))}const s=r(t,i(n(t,!1))),o=n(e),c=r(e,i(o,!0)),l=i(o).map((([t,e])=>e.map((e=>({alignment:t,marks:e}))))).flat();return[s,c,l]}(t.textMarks,t.svgMarks),r=o(e,n);r=r.sort(((t,e)=>t.text[0]._getBBox()[p_]-e.text[0]._getBBox()[d_])),r.length>=2&&(r=[r[0],r[1]],function(e){const n=new Map,i=[];function r(e,n,i){n===u_||n===h_?t.xAxis.ticks.push({label:e,marks:i}):t.yAxis.ticks.push({label:e,marks:i}),i.forEach((t=>{t[w_]=e?Wv:T_}))}for(const{alignment:t,group:r}of e)for(const e of r){const[r,s]=e,a=new Map;for(const[e,i]of r)a.set(i,!0),n.has(e)?n.get(e).ticks.push(i):n.set(e,{alignment:t,ticks:[i]});s.filter((t=>!a.has(t))).forEach((e=>{i.push({alignment:t,tick:e})}))}for(const[t,{alignment:e,ticks:i}]of n)r(t,e,i);for(const{alignment:t,tick:e}of i)r(null,t,[e]);[t.xAxis,t.yAxis].forEach((t=>cx("label",t.ticks)))}(r),e=e.filter((t=>!r.map((t=>t.text)).includes(t.marks))));const s=o(e,i,!1).filter((t=>t.dist<5*wx));function a(t){t.sort(((t,e)=>t[0]-e[0]));const e=[[t[0][0],[t[0][1]]]];for(let n=1;nt[1]))}function o(t,e,n=!0){function i(t,e){e.sort(((e,n)=>{const i=e._getBBox(),r=n._getBBox();return c.includes(t)?i[p_]-r[p_]:i[d_]-r[d_]}))}function r(t,e,n){const i=[0,0,0],r=[0,0,0];function s(t,e,i){const r=e._getBBox(),s=o.includes(n)?o:c;for(let e=0;es(i,e,t.length))),e.forEach((t=>s(r,t,e.length))),Km([Km(i)-Km(r),Km(i)-Gm(r),Gm(i)-Km(r),Gm(i)-Gm(r)].map((t=>Math.abs(t))))}function s(t,e,n){let i=0,r=0;const s=new Map;for(const a of e){const e=a._getBBox();let o=Number.MAX_SAFE_INTEGER;if(i===n.length)return[Number.MAX_SAFE_INTEGER,null];for(;i<=n.length;){const l=n[Km([i,n.length-1])]._getBBox(),u=c.includes(t)?p_:d_,h=Math.abs(l[u]-e[u]);if(h>=o){s.set(a,n[i-1]),r+=o;break}o=h,++i}}return[r/e.length,s]}const a=[],o=[c_,l_,p_],c=[u_,h_,d_];for(const{alignment:l,marks:u}of t){if(1===u.length)continue;let t={dist:Number.MAX_SAFE_INTEGER,group:null};i(l,u);for(const{alignment:a,marks:h}of e){if(h.lengthwx)continue;i(l,h);const[e,p]=s(l,u,h);if(e===Number.MAX_SAFE_INTEGER)continue;const d=Math.abs(e-t.dist)t.dist-e.dist)),a}s.length&&(!function(t,e){let n;function i(t){if(t.type===g_){const e=t.marks.map((t=>t.label.innerHTML)),i=t.marks.map((e=>window.getComputedStyle(e.mark)[t.matchingAttr]));n=ty().domain(e).range(i)}else{const e=t.marks.map((t=>+t.label.innerHTML)),i=t.marks.map((t=>t.mark._getBBox().width**2));n=wg().domain(e).range(i)}t.scale=n}function r(t){return{title:null,marks:Array.from(t.group[0][0]).map((([t,e])=>({label:t,mark:e})))}}for(let n of e){n=r(n);const s=window.getComputedStyle(n.marks[0].mark),a=window.getComputedStyle(n.marks[1].mark);let o=null;if(s.stroke!==a.stroke?o=__:s.color!==a.color?o=v_:s.fill!==a.fill&&(o=b_),o)n.type=g_,n.matchingAttr=o;else{const t=[],i=[];for(let e=1;e2||Qm(i)>2))return void e.splice(e.indexOf(n),1);n.type=y_}for(const{label:t,mark:e}of n.marks)t[w_]=e[w_]=S_,e.style["pointer-events"]="fill",e.legend=n,e[Yv]=e.hasAttribute("opacity")?+e.getAttribute("opacity"):window.getComputedStyle(e).opacity||Hv;i(n),cx("label",n.marks,n.type===y_),t.legends.push(n)}}(t,s),e=e.filter((t=>!s.map((t=>t.text)).includes(t.marks)))),function(e){const n=new Map;function i(t){const e=t._getBBox();return[e.centerX,e.centerY]}function r(t,n){let r={title:null,dist:Number.MAX_SAFE_INTEGER};for(const s of e){const[e,a]=i(s),o=Math.abs(e-t)+Math.abs(a-n);ot.label)).map((t=>i(t.label))),s=r(Qm(e.map((t=>t[0]))),Qm(e.map((t=>t[1])))),{title:a,dist:o}=s;a&&((!n.has(a)||o!t[w_]))[0]}(e.map((t=>t.marks)).flat()),t.legends.forEach((t=>function(t){const{scale:e,title:n,type:i,matchingAttr:r}=t;for(const{mark:s}of t.marks){const t=bx(e,i===g_?window.getComputedStyle(s)[r]:s._getBBox().width**2);s[x_]={[n?n.innerHTML.toLowerCase():"legend-0"]:t}}}(t)))}function Ix(t){for(const e of t.svgMarks){const n=e._getBBox();if(n.width>=t.xAxis.range[1]-t.xAxis.range[0]&&n.height>=t.yAxis.range[0]-t.yAxis.range[1]){e[w_]=k_;continue}const i=t.svg._getBBox(),[r,s]=t.xAxis.range,[a,o]=t.yAxis.range.map((t=>t+i.top));(n.top<=o&&n.bottom>=a&&n.left<=r||n.top<=o&&n.bottom>=a&&n.right>=s||!(n.right>=r&&n.left<=s&&n.bottom>=o&&n.top<=a))&&(e[w_]=I_);for(const e of t.legends)for(const{mark:t}of e.marks)t[w_]=S_}t.svgMarks=t.svgMarks.filter((t=>!t[w_])),t.svgMarks.forEach((t=>{t[w_]=M_})),cx(null,t.svgMarks,!1)}function Ax(t){let e=!0;for(const[,n]of Object.entries(t.ticks))if(null!=n.label&&"[object Date]"!==Object.prototype.toString.call(_x(n.label,!0).value)){e=!1;break}for(const[,n]of Object.entries(t.ticks)){if(!n.label)continue;let i=_x(n.label,e);i.value&&(t.formatter={format:i.format},i=i.value),n.value=i,"string"==typeof i?t.ordinal.push(i):(t.domain[0]=null===t.domain[0]?i:Km([t.domain[0],i]),t.domain[1]=null===t.domain[1]?i:Gm([t.domain[1],i]))}}function Tx(t){wx=.1*Gm([t.svg._getBBox().width,t.svg._getBBox().height]),Sx(t),Ax(t.xAxis),Ax(t.yAxis);let e=+ax(t.svg.getAttribute("width")),n=+ax(t.svg.getAttribute("height"));e||(e=t.svg._getBBox().width),n||(n=t.svg._getBBox().height);const i=t.svg._getBBox();if(!t.xAxis.ticks.length&&!t.yAxis.ticks.length)return t.xAxis.range=[0,e],t.yAxis.range=[n,0],void Ix(t);const r=t.yAxis.ticks[0].marks[0]._getBBox(),s=t.xAxis.ticks[0].marks[0]._getBBox(),a=[r.left,r.left+r.width],o=[s.top+s.height,s.top],c=Gm([(r.width<10?a[1]:a[0])-i.left,0]),l=Gm([Km([a[1]-i.left,e]),t.xAxis.ticks[t.xAxis.ticks.length-1].marks[0]._getBBox().right-i.left]),u=Gm([(s.height<10?t.yAxis.ticks[t.yAxis.ticks.length-1].marks[0]._getBBox().top:o[1])-i.top,0]),h=Km([o[0]-i.top,n]);var p,d;t.xAxis.range=[c,l],t.yAxis.range=[h,u],t.xAxis.scale=(t.xAxis.domain[0]instanceof Date?Fv():t.xAxis.ordinal.length?ey():wg()).domain(t.xAxis.ordinal.length?t.xAxis.ordinal:t.xAxis.domain).range(t.xAxis.range),t.xAxis.axis=(p=t.xAxis.scale,d=t,yx(px,p,d)).ticks(t.xAxis.ticks.length),t.xAxis.domain[0]instanceof Date&&(t.xAxis.axis=t.xAxis.axis.tickFormat(t.xAxis.formatter.format)),t.yAxis.scale=(t.yAxis.domain[0]instanceof Date?Fv():t.yAxis.ordinal.length?ey():wg()).domain(t.yAxis.ordinal.length?t.yAxis.ordinal:t.yAxis.domain).range(t.yAxis.range),t.yAxis.axis=function(t,e){return yx(dx,t,e)}(t.yAxis.scale,t).ticks(t.yAxis.ticks.length),function(t){const e=t.svg._getBBox();if(t.xAxis.scale&&!t.xAxis.ordinal.length){const n=[sx(t.xAxis.ticks.filter((e=>e.value===t.xAxis.domain[0]))[0].marks[0],c_),sx(t.xAxis.ticks.filter((e=>e.value===t.xAxis.domain[1]))[0].marks[0],c_)].map((t=>t-e.left)),i=t.xAxis.range.map(t.xAxis.scale.copy().range(n).invert,t.xAxis.scale);t.xAxis.scale.domain(i)}if(t.yAxis.scale&&!t.yAxis.ordinal.length){const n=[sx(t.yAxis.ticks.filter((e=>e.value===t.yAxis.domain[0]))[0].marks[0],u_),sx(t.yAxis.ticks.filter((e=>e.value===t.yAxis.domain[1]))[0].marks[0],u_)].map((t=>t-e.top)),i=t.yAxis.range.map(t.yAxis.scale.copy().range(n).invert,t.yAxis.scale);t.yAxis.scale.domain(i)}}(t),Ix(t)}class kx{constructor(t){this.table=t,this.active={table:t,selected:t,filtered:null,type:B_.NONE},this.children=[],this.parents=[]}}async function Mx(t){if(!t||!Object.keys(t).length)return{};const{url:e}=t,n=e.split(".").pop(),i=await("json"===n?function(t,e){return Cm(t,{...e,as:"json",using:Nm})}(e):function(t,e){return Cm(t,{...e,as:"text",using:xf})}(e));return new kx(i.assign(Em({[C_]:Jm(i.numRows())})))}function Ex(t){const e={};let n=t.map((t=>t[x_]));n=n.flat();const i=Object.keys(n[0]);return t.forEach(((t,e)=>{t[C_]=e})),i.forEach((t=>{e[t.toLowerCase()]=function(t,e){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");if("function"!=typeof e)throw new TypeError("mapper is not a function");return Array.from(t,((n,i)=>e(n,i,t)))}(n,(e=>e[t.toLowerCase()]))})),e[E_]=t,e[C_]=Jm(t.length),new kx(Em(e))}class Cx{constructor(){this.hasDomain=!1,this.svg=null,this.svgMarks=[],this.textMarks=[],this.data=null,this.xAxis={domain:[null,null],ordinal:[],range:[null,null],ticks:[],scale:null,axis:null,title:null},this.yAxis={domain:[null,null],ordinal:[],range:[null,null],ticks:[],scale:null,axis:null,title:null},this.legends=[],this.title=null,this.interactions={selection:!0,brush:!0,navigate:!1,filter:!1,sort:!1,annotate:!1}}}const Nx=["circle",Xv,t_,e_,n_,i_,r_,"use"];let Ox,Lx=1;function Bx(t,e,n,i=!1){e._getBBox=i?function(){return this.getBoundingClientRect()}:function(){const e=this.getBoundingClientRect(),n=this.getBBox?this.getBBox():e,i=this.getBBox?ox(t,this,n.x,n.y):{x:n.x,y:n.y},r=this.getBBox?ox(t,this,n.x+n.width,n.y+n.height):{x:n.x+n.width,y:n.y+n.height},s=Math.abs(i.x-r.x),a=Math.abs(i.y-r.y),o=e.left+e.width/2-s/2,c=e.top+e.height/2-a/2;return{[f_]:s,[m_]:a,[c_]:o,[l_]:o+s,[u_]:c,[h_]:c+a,[p_]:o+s/2,[d_]:c+a/2}},e.globalPosition=new lx(e._getBBox()[p_]-t._getBBox()[c_],e._getBBox()[d_]-t._getBBox()[u_]),e.localTransform=vx(e)}function Dx(t,e,n,i=!1){if(t&&t.nodeName.toLowerCase()!==o_&&(!t.className||t.className.baseVal!==Gv&&t.className.baseVal!==Kv)){if(i||t.nodeName===Jv)e.svg=t,Bx(e.svg,t,0,i),t.id||(t.id=Qv+"-"+Lx++);else if(t.nodeName===Zv)vx(t,n);else if(t.nodeName===a_&&""!==t.textContent.trim()){let n=t.parentElement;n.nodeName!==s_&&(n=yt(n).append("text").html(t.textContent).node(),yt(t).remove()),Bx(e.svg,n),n.removeAttribute("textLength"),e.textMarks.push(n),n.style["pointer-events"]="none",n.style["user-select"]="none"}else if(Nx.includes(t.nodeName)){const i=t.nodeName;i===r_?(!function(t,e,n){const i=Rv.parseSVG(t.getAttribute("d"));if(!i.length)return;t.contour=i;const r=i[i.length-1],s=["v","h"],a=function(t){if(t.length<=2||t.length%2!=0)return[];const e=[];for(let n=0;n{const s=window.getComputedStyle(t);Dx(i.append("path").attr("d",r).style("fill",s.fill).style("color",s.color).style("stroke",s.stroke).style("stroke-width",s.strokeWidth).attr("id","test").node(),e,n)})),yt(t).remove()}else"Z"!==r.code?t.type=t_:5===i.length&&s.includes(i[1].code)&&s.includes(i[2].code)&&s.includes(i[3].code)?t.type=i_:t.type=e_}(t,e,n),t.setAttribute("vector-effect","non-scaling-stroke")):i!==n_&&i!==e_&&i!==t_||(t.type=i,t.setAttribute("vector-effect","non-scaling-stroke")),Bx(e.svg,t),t.setAttribute(M_,"true"),e.svgMarks.includes(t)||e.svgMarks.push(t)}for(const i of t.childNodes)Dx(i,e,new lx(n))}}function Fx(t,e){var n;n=t.svg,Ox=yt(n).append("rect").attr("opacity",.35).attr("x",0).attr("y",0).attr("width",0).attr("height",0).attr("id",n.id+"-brush-rect").style("fill","gray").style("stroke","#fff");const[i,r]=gt(e,t.svg);Ox.attr("x",i).attr("y",r)}function Vx(t,e){const n=t.map((t=>{return e=function(t){const e=new Cx;return Dx(t,e,new lx,!0),e.svg=t,console.log(e),e}(t),e.svg.style.cursor="crosshair",Tx(e),function(t){t.svgMarks=t.svgMarks.filter((t=>t.type!==t_));for(let e=0;et.split(",").map((t=>Number(t)))));n[x_]=[];for(const s of e){let[e,a]=s;e-=i.left,a-=i.top;const o={};o[t.xAxis.title?t.xAxis.title.innerHTML.toLowerCase():"x"]=t.xAxis.scale.invert(e),o[t.yAxis.title?t.yAxis.title.innerHTML.toLowerCase():"y"]=t.yAxis.scale.invert(a);for(let e=0;efunction(t){const{data:e}=t,i=function(t){const e=new Map,n=function t(n,i,r){if(e.has(n))return[];e.set(n,!0);const{parents:s}=n;if(!s.length)return[[n,i,r]];let a=[];for(const e of s){const{next:n,aggregation:s,map:o,fields:c}=e;a=[...a,...t(n,[...i,[s,o]],Y_(r,c))]}return a}(t,[],Object.fromEntries(V_(t.table,!0).map((t=>[t,t]))));return n.map((([t,e,n])=>[t,W_(t,e),n]))}(e);let r=!1;function s(e){if(r)return;const{target:s}=e;K_(i,function(t,e){return e[w_]===M_?zv(C_,e,jv.POINT):e[w_]===S_?zv(Object.keys(e[x_])[0],e[x_],jv.POINT):(J_(t.svgMarks),t.legends.forEach((t=>J_(t.marks.map((t=>t.mark))))),null)}(t,s),ix(e)),ex(n)}function a(e){let s,a,o,c;function l(e){e.stopPropagation(),e.preventDefault();const n=gt(e);if(Math.hypot(h[0]-n[0],h[1]-n[1])<5)return;r=!0;const[i,l,u,p]=function(t,e){e.preventDefault();const[n,i]=gt(e,t.svg),r=+Ox.node().getAttribute("x"),s=+Ox.node().getAttribute("y"),a=n-r,o=i-s,c=a<0?a:0,l=o<0?o:0;return Ox.attr("width",Math.abs(a)).attr("height",Math.abs(o)).attr("transform","translate("+c+","+l+")"),[r,s,a,o]}(t,e);s=t.xAxis.scale.invert(i),a=t.xAxis.scale.invert(i+u),o=t.yAxis.scale.invert(l),c=t.yAxis.scale.invert(l+p)}function u(e){if(Ox.remove(),r){const r=(h=t.xAxis.title.innerHTML.toLowerCase(),p=t.yAxis.title.innerHTML.toLowerCase(),f=[o,c],[{[h]:{value:(d=[s,a])[0],cond:">=",type:jv.RANGE}},{[h]:{value:d[1],cond:"<=",type:jv.RANGE}},{[p]:{value:f[0],cond:"<=",type:jv.RANGE}},{[p]:{value:f[1],cond:">=",type:jv.RANGE}}]);K_(i,r,ix(e)),ex(n)}var h,p,d,f;t.svg.removeEventListener("mousemove",l),t.svg.removeEventListener("mouseup",u)}r=!1;const h=gt(e);t.interactions.brush&&(Fx(t,e),t.svg.addEventListener("mousemove",l),t.svg.addEventListener("mouseup",u))}t.svg.addEventListener("click",s),t.svg.addEventListener("mousedown",a)}(t))),console.log(e),n}t.hydrate=async function(t,e={}){return async function(t,e={}){if(console.log("here!"),t)return Array.isArray(t)||(t=[t]),Vx(t=t.map((t=>"string"==typeof t?document.querySelector(t):t)),await Mx(e))}(t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).divi={})}(this,(function(t){"use strict";const e=Math.PI,n=2*e,i=1e-6,r=n-i;function s(t){this._+=t[0];for(let e=1,n=t.length;e=0))throw new Error(`invalid digits: ${t}`);if(e>15)return s;const n=10**e;return function(t){this._+=t[0];for(let e=1,i=t.length;ei)if(Math.abs(p*u-l*h)>i&&a){let f=r-o,m=s-c,y=u*u+l*l,g=f*f+m*m,b=Math.sqrt(y),v=Math.sqrt(d),_=a*Math.tan((e-Math.acos((y+d-g)/(2*b*v)))/2),x=_/v,w=_/b;Math.abs(x-1)>i&&this._append`L${t+x*h},${n+x*p}`,this._append`A${a},${a},0,0,${+(p*f>h*m)},${this._x1=t+w*u},${this._y1=n+w*l}`}else this._append`L${this._x1=t},${this._y1=n}`;else;}arc(t,s,a,o,c,u){if(t=+t,s=+s,u=!!u,(a=+a)<0)throw new Error(`negative radius: ${a}`);let l=a*Math.cos(o),h=a*Math.sin(o),p=t+l,d=s+h,f=1^u,m=u?o-c:c-o;null===this._x1?this._append`M${p},${d}`:(Math.abs(this._x1-p)>i||Math.abs(this._y1-d)>i)&&this._append`L${p},${d}`,a&&(m<0&&(m=m%n+n),m>r?this._append`A${a},${a},0,1,${f},${t-l},${s-h}A${a},${a},0,1,${f},${this._x1=p},${this._y1=d}`:m>i&&this._append`A${a},${a},0,${+(m>=e)},${f},${this._x1=t+a*Math.cos(c)},${this._y1=s+a*Math.sin(c)}`)}rect(t,e,n,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+i}h${-n}Z`}toString(){return this._}};function o(){return new a}o.prototype=a.prototype;var c="http://www.w3.org/1999/xhtml",u={svg:"http://www.w3.org/2000/svg",xhtml:c,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function l(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),u.hasOwnProperty(e)?{space:u[e],local:t}:t}function h(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===c&&e.documentElement.namespaceURI===c?e.createElement(t):e.createElementNS(n,t)}}function p(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function d(t){var e=l(t);return(e.local?p:h)(e)}function f(){}function m(t){return null==t?f:function(){return this.querySelector(t)}}function y(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function g(){return[]}function b(t){return function(e){return e.matches(t)}}var v=Array.prototype.find;function _(){return this.firstElementChild}var x=Array.prototype.filter;function w(){return Array.from(this.children)}function S(t){return new Array(t.length)}function I(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function A(t,e,n,i,r,s){for(var a,o=0,c=e.length,u=s.length;oe?1:t>=e?0:NaN}function E(t){return function(){this.removeAttribute(t)}}function N(t){return function(){this.removeAttributeNS(t.space,t.local)}}function D(t,e){return function(){this.setAttribute(t,e)}}function O(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function B(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function L(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function F(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function V(t){return function(){this.style.removeProperty(t)}}function U(t,e,n){return function(){this.style.setProperty(t,e,n)}}function P(t,e,n){return function(){var i=e.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}function R(t){return function(){delete this[t]}}function j(t,e){return function(){this[t]=e}}function $(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function z(t){return t.trim().split(/^|\s+/)}function H(t){return t.classList||new q(t)}function q(t){this._node=t,this._names=z(t.getAttribute("class")||"")}function Y(t,e){for(var n=H(t),i=-1,r=e.length;++i=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ft=[null];function mt(t,e){this._groups=t,this._parents=e}function yt(t){return"string"==typeof t?new mt([[document.querySelector(t)]],[document.documentElement]):new mt([[t]],ft)}function gt(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=t.clientX,i.y=t.clientY,[(i=i.matrixTransform(e.getScreenCTM().inverse())).x,i.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}function bt(t){return"string"==typeof t?new mt([document.querySelectorAll(t)],[document.documentElement]):new mt([y(t)],ft)}mt.prototype={constructor:mt,select:function(t){"function"!=typeof t&&(t=m(t));for(var e=this._groups,n=e.length,i=new Array(n),r=0;r=x&&(x=_+1);!(v=g[x])&&++x=0;)(i=r[s])&&(a&&4^i.compareDocumentPosition(a)&&a.parentNode.insertBefore(i,a),a=i);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=M);for(var n=this._groups,i=n.length,r=new Array(i),s=0;s1?this.each((null==e?V:"function"==typeof e?P:U)(t,e,null==n?"":n)):function(t,e){return t.style.getPropertyValue(e)||F(t).getComputedStyle(t,null).getPropertyValue(e)}(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?R:"function"==typeof e?$:j)(t,e)):this.node()[t]},classed:function(t,e){var n=z(t+"");if(arguments.length<2){for(var i=H(this.node()),r=-1,s=n.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}(t+""),a=s.length;if(!(arguments.length<2)){for(o=e?lt:ut,i=0;i=0;t=r.next(t+1))n[++s]=t;else for(let t=0;tt(n,i,e)))}return!t&&i||(this._index=n),n}partitions(t=!0){if(this._partitions)return this._partitions;if(!this.isGrouped())return[this.indices(t)];const{keys:e,size:n}=this._group,i=Tt(n,(()=>[])),r=this._index,s=this.mask(),a=this.numRows();if(r&&this.isOrdered())for(let t,n=0;n=0;t=s.next(t+1))i[e[t]].push(t);else for(let t=0;tt(n,i,e)))}return!t&&this.isOrdered()||(this._partitions=i),i}scan(t,e,n=1/0,i=0){const r=this._mask,s=this._nrows,a=this._data;let o=i||0;if(o>s)return;const c=Math.min(s,o+n),u=()=>o=this._total;if(e&&this.isOrdered()||r&&this._index){const e=this.indices(),n=this._data;for(;o-1;o=r.next(o+1))t(o,a,u)}else for(;on.push(t)),!0,e-t,t),this.reify(n)}reduce(t){return this.__reduce(this,t)}},Ct=class{constructor(t){this.data=t}get length(){return this.data.length}get(t){return this.data[t]}[Symbol.iterator](){return this.data[Symbol.iterator]()}},Mt=function(t){return t&&At(t.get)?t:new Ct(t)};function Et(t){return t instanceof Date}function Nt(t){return t===Object(t)}function Dt(t){return t instanceof RegExp}function Ot(t){return"string"==typeof t}function Bt(t,e){const n=e=>St(`Illegal argument type: ${e||typeof t}`);return t instanceof Map?Lt(t.entries(),e):Et(t)?n("Date"):Dt(t)?n("RegExp"):Ot(t)?n():vt(t)?function(t,e){const n=t.length,i={},r=t=>i[t]=Array(n);if(n){const i=(e=e||Object.keys(t[0])).map(r),s=i.length;for(let r=0;rn[t]=[];let r,s;for(const n of t){r||(r=(e=e||Object.keys(n)).map(i),s=r.length);for(let t=0;tzt(t)||Ot(t);var Yt={compact:t=>zt(t)?t.filter((t=>Ht(t))):t,concat:(...t)=>[].concat(...t),includes:(t,e,n)=>!!qt(t)&&t.includes(e,n),indexof:(t,e)=>qt(t)?t.indexOf(e):-1,join:(t,e)=>zt(t)?t.join(e):Rt,lastindexof:(t,e)=>qt(t)?t.lastIndexOf(e):-1,length:t=>qt(t)?t.length:0,pluck:(t,e)=>zt(t)?t.map((t=>Ht(t)?t[e]:Rt)):Rt,reverse:t=>zt(t)?t.slice().reverse():Ot(t)?t.split("").reverse().join(""):Rt,slice:(t,e,n)=>qt(t)?t.slice(e,n):Rt};function Gt(t,e,n="0"){const i=t+"",r=i.length;return r(t<10?"0":"")+t,Kt=t=>t<0?"-"+Gt(-t,6):t>9999?"+"+Gt(t,6):Gt(t,4);function Qt(t,e,n,i,r,s,a,o,c){const u=o?"Z":"";return Kt(t)+"-"+Wt(e+1)+"-"+Wt(n)+(!c||a?"T"+Wt(i)+":"+Wt(r)+":"+Wt(s)+"."+Gt(a,3)+u:s?"T"+Wt(i)+":"+Wt(r)+":"+Wt(s)+u:r||i||!o?"T"+Wt(i)+":"+Wt(r)+u:"")}function Jt(t,e){return isNaN(t)?"Invalid Date":Qt(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds(),!1,e)}function Zt(t,e){return isNaN(t)?"Invalid Date":Qt(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds(),!0,e)}const Xt=/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/;function te(t){return t.match(Xt)&&!isNaN(Date.parse(t))}const ee=864e5,ne=6048e5,ie=new Date,re=new Date,se=t=>(ie.setTime("string"==typeof t?function(t,e=Date.parse){return te(t)?e(t):t}(t):t),ie);var ae={format_date:(t,e)=>Jt(se(t),!e),format_utcdate:(t,e)=>Zt(se(t),!e),timestamp:t=>+se(t),year:t=>se(t).getFullYear(),quarter:t=>Math.floor(se(t).getMonth()/3),month:t=>se(t).getMonth(),date:t=>se(t).getDate(),dayofweek:t=>se(t).getDay(),hours:t=>se(t).getHours(),minutes:t=>se(t).getMinutes(),seconds:t=>se(t).getSeconds(),milliseconds:t=>se(t).getMilliseconds(),utcyear:t=>se(t).getUTCFullYear(),utcquarter:t=>Math.floor(se(t).getUTCMonth()/3),utcmonth:t=>se(t).getUTCMonth(),utcdate:t=>se(t).getUTCDate(),utcdayofweek:t=>se(t).getUTCDay(),utchours:t=>se(t).getUTCHours(),utcminutes:t=>se(t).getUTCMinutes(),utcseconds:t=>se(t).getUTCSeconds(),utcmilliseconds:t=>se(t).getUTCMilliseconds(),datetime:function(t,e,n,i,r,s,a){return arguments.length?new Date(t,e||0,null==n?1:n,i||0,r||0,s||0,a||0):new Date(Date.now())},dayofyear:function(t){re.setTime(+t),re.setHours(0,0,0,0),ie.setTime(+re),ie.setMonth(0),ie.setDate(1);const e=6e4*(re.getTimezoneOffset()-ie.getTimezoneOffset());return Math.floor(1+(re-ie-e)/ee)},week:function(t,e){const n=e||0;re.setTime(+t),re.setDate(re.getDate()-(re.getDay()+7-n)%7),re.setHours(0,0,0,0),ie.setTime(+t),ie.setMonth(0),ie.setDate(1),ie.setDate(1-(ie.getDay()+7-n)%7),ie.setHours(0,0,0,0);const i=6e4*(re.getTimezoneOffset()-ie.getTimezoneOffset());return Math.floor((re-ie+1-i)/ne)},utcdatetime:function(t,e,n,i,r,s,a){return arguments.length?new Date(Date.UTC(t,e||0,null==n?1:n,i||0,r||0,s||0,a||0)):new Date(Date.now())},utcdayofyear:function(t){re.setTime(+t),re.setUTCHours(0,0,0,0);const e=Date.UTC(re.getUTCFullYear(),0,1);return Math.floor(1+(re-e)/ee)},utcweek:function(t,e){const n=e||0;return re.setTime(+t),re.setUTCDate(re.getUTCDate()-(re.getUTCDay()+7-n)%7),re.setUTCHours(0,0,0,0),ie.setTime(+t),ie.setUTCMonth(0),ie.setUTCDate(1),ie.setUTCDate(1-(ie.getUTCDay()+7-n)%7),ie.setUTCHours(0,0,0,0),Math.floor((re-ie+1)/ne)},now:Date.now};function oe(t,e){return null!=t&&null!=e&&t==t&&e==e&&(t===e||(Et(t)||Et(e)?+t==+e:Dt(t)&&Dt(e)?t+""==e+"":!(!Nt(t)||!Nt(e))&&function(t,e){if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;if(t.length||e.length)return ce(t,e);const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;if(n.sort(),i.sort(),!ce(n,i,((t,e)=>t===e)))return!1;const r=n.length;for(let i=0;iJSON.parse(t),to_json:t=>JSON.stringify(t)};let le=Math.random;function he(){return le()}function pe(t){return t instanceof Map}function de(t){return pe(t)||function(t){return t instanceof Set}(t)}function fe(t){return Array.from(t)}var me={has:(t,e)=>de(t)?t.has(e):null!=t&&Vt(t,e),keys:t=>pe(t)?fe(t.keys()):null!=t?Object.keys(t):[],values:t=>de(t)?fe(t.values()):null!=t?Object.values(t):[],entries:t=>de(t)?fe(t.entries()):null!=t?Object.entries(t):[],object:t=>t?Object.fromEntries(t):Rt};var ye={bin:function(t,e,n,i,r){return null==t?null:tn?1/0:(t=Math.max(e,Math.min(t,n)),e+i*Math.floor(1e-14+(t-e)/i+(r||0)))},equal:oe,recode:function(t,e,n){if(e instanceof Map){if(e.has(t))return e.get(t)}else if(Vt(e,t))return e[t];return void 0!==n?n:t},sequence:function(t,e,n){let i=arguments.length;t=+t,e=+e,n=i<2?(e=t,t=0,1):i<3?1:+n,i=0|Math.max(0,Math.ceil((e-t)/n));const r=new Array(i);for(let e=0;e180*t/Math.PI,radians:t=>Math.PI*t/180,acos:Math.acos,acosh:Math.acosh,asin:Math.asin,asinh:Math.asinh,atan:Math.atan,atan2:Math.atan2,atanh:Math.atanh,cos:Math.cos,cosh:Math.cosh,sin:Math.sin,sinh:Math.sinh,tan:Math.tan,tanh:Math.tanh},...me,...{parse_date:t=>null==t?t:new Date(t),parse_float:t=>null==t?t:Number.parseFloat(t),parse_int:(t,e)=>null==t?t:Number.parseInt(t,e),endswith:(t,e,n)=>null!=t&&String(t).endsWith(e,n),match:(t,e,n)=>{const i=null==t?t:String(t).match(e);return null==n||null==i?i:"number"==typeof n?i[n]:i.groups?i.groups[n]:null},normalize:(t,e)=>null==t?t:String(t).normalize(e),padend:(t,e,n)=>null==t?t:String(t).padEnd(e,n),padstart:(t,e,n)=>null==t?t:String(t).padStart(e,n),upper:t=>null==t?t:String(t).toUpperCase(),lower:t=>null==t?t:String(t).toLowerCase(),repeat:(t,e)=>null==t?t:String(t).repeat(e),replace:(t,e,n)=>null==t?t:String(t).replace(e,String(n)),substring:(t,e,n)=>null==t?t:String(t).substring(e,n),split:(t,e,n)=>null==t?[]:String(t).split(e,n),startswith:(t,e,n)=>null!=t&&String(t).startsWith(e,n),trim:t=>null==t?t:String(t).trim()}};function ge(t){return"bigint"==typeof t}function be(t){return void 0===t?t+"":ge(t)?t+"n":JSON.stringify(t)}function ve(t,e=[],n=[]){return new _e(t,_t(e),_t(n))}let _e=class{constructor(t,e,n){this.name=t,this.fields=e,this.params=n}toString(){const t=[...this.fields.map((t=>`d[${be(t)}]`)),...this.params.map(be)];return`d => op.${this.name}(${t})`}toObject(){return{expr:this.toString(),func:!0}}};const xe=t=>ve("any",t),we=()=>ve("count"),Se=t=>ve("array_agg",t),Ie=t=>ve("array_agg_distinct",t),Ae=(t,e)=>ve("map_agg",[t,e]),Te=(t,e)=>ve("object_agg",[t,e]),ke=(t,e)=>ve("entries_agg",[t,e]);var Ce={...ye,row_object:(...t)=>ve("row_object",null,t.flat()),count:we,any:xe,array_agg:Se,array_agg_distinct:Ie,object_agg:Te,map_agg:Ae,entries_agg:ke,valid:t=>ve("valid",t),invalid:t=>ve("invalid",t),distinct:t=>ve("distinct",t),mode:t=>ve("mode",t),sum:t=>ve("sum",t),product:t=>ve("product",t),mean:t=>ve("mean",t),average:t=>ve("average",t),variance:t=>ve("variance",t),variancep:t=>ve("variancep",t),stdev:t=>ve("stdev",t),stdevp:t=>ve("stdevp",t),min:t=>ve("min",t),max:t=>ve("max",t),quantile:(t,e)=>ve("quantile",t,e),median:t=>ve("median",t),covariance:(t,e)=>ve("covariance",[t,e]),covariancep:(t,e)=>ve("covariancep",[t,e]),corr:(t,e)=>ve("corr",[t,e]),bins:(t,e,n,i)=>ve("bins",t,[e,n,i]),row_number:()=>ve("row_number"),rank:()=>ve("rank"),avg_rank:()=>ve("avg_rank"),dense_rank:()=>ve("dense_rank"),percent_rank:()=>ve("percent_rank"),cume_dist:()=>ve("cume_dist"),ntile:t=>ve("ntile",null,t),lag:(t,e,n)=>ve("lag",t,[e,n]),lead:(t,e,n)=>ve("lead",t,[e,n]),first_value:t=>ve("first_value",t),last_value:t=>ve("last_value",t),nth_value:(t,e)=>ve("nth_value",t,e),fill_down:(t,e)=>ve("fill_down",t,e),fill_up:(t,e)=>ve("fill_up",t,e)};function Me(t,e,n,i){const r="map"===i||!0===i?Ae:"entries"===i?ke:"object"===i?Te:St('groups option must be "map", "entries", or "object".'),{names:s}=t.groups(),a=function(t,e){t=de(t)?t:new Set(t);let n=e,i=0;for(;t.has(n);)n=e+ ++i;return n}(t.columnNames(),"_");let o=t.select().reify(e).create({data:{[a]:n}}).rollup({[a]:Se(a)});for(let t=s.length;--t>=0;)o=o.groupby(s.slice(0,t)).rollup({[a]:r(s[t],a)});return o.get(a)}const Ee="ArrowFunctionExpression",Ne="FunctionExpression",De="Identifier",Oe="Literal",Be="MemberExpression",Le="ObjectExpression",Fe="ObjectPattern",Ve="Property",Ue="Column",Pe="Constant",Re="Dictionary",je="Parameter",$e="Op",ze=(t,e)=>{const n=Qe[t.type];return n?n(t,e):St(`Unsupported expression construct: ${t.type}`)},He=(t,e)=>"("+ze(t.left,e)+" "+t.operator+" "+ze(t.right,e)+")",qe=(t,e)=>"("+Ge(t.params,e)+")=>"+ze(t.body,e),Ye=(t,e)=>ze(t.callee,e)+"("+Ge(t.arguments,e)+")",Ge=(t,e,n=",")=>t.map((t=>ze(t,e))).join(n),We=t=>t.computed?`[${be(t.name)}]`:`.${t.name}`,Ke=(t,e,n)=>{const i=t.table||"";return`data${i}${We(t)}.${n}(${e.index}${i})`},Qe={Constant:t=>t.raw,Column:(t,e)=>Ke(t,e,"get"),Dictionary:(t,e)=>Ke(t,e,"key"),Function:t=>`fn.${t.name}`,Parameter:t=>`$${We(t)}`,Op:(t,e)=>`op(${be(t.name)},${e.op||e.index})`,Literal:t=>t.raw,Identifier:t=>t.name,TemplateLiteral:(t,e)=>{const{quasis:n,expressions:i}=t,r=i.length;let s=n[0].value.raw;for(let t=0;t{const n=!t.computed,i=ze(t.object,e),r=ze(t.property,e);return i+(n?"."+r:"["+r+"]")},CallExpression:Ye,NewExpression:(t,e)=>"new "+Ye(t,e),ArrayExpression:(t,e)=>"["+Ge(t.elements,e)+"]",AssignmentExpression:He,BinaryExpression:He,LogicalExpression:He,UnaryExpression:(t,e)=>"("+t.operator+ze(t.argument,e)+")",ConditionalExpression:(t,e)=>"("+ze(t.test,e)+"?"+ze(t.consequent,e)+":"+ze(t.alternate,e)+")",ObjectExpression:(t,e)=>"({"+Ge(t.properties,e)+"})",Property:(t,e)=>{const n=ze(t.key,e);return(t.computed?`[${n}]`:n)+":"+ze(t.value,e)},ArrowFunctionExpression:qe,FunctionExpression:qe,FunctionDeclaration:qe,ArrayPattern:(t,e)=>"["+Ge(t.elements,e)+"]",ObjectPattern:(t,e)=>"{"+Ge(t.properties,e)+"}",VariableDeclaration:(t,e)=>t.kind+" "+Ge(t.declarations,e,","),VariableDeclarator:(t,e)=>ze(t.id,e)+"="+ze(t.init,e),SpreadElement:(t,e)=>"..."+ze(t.argument,e),BlockStatement:(t,e)=>"{"+Ge(t.body,e,";")+";}",BreakStatement:()=>"break",ExpressionStatement:(t,e)=>ze(t.expression,e),IfStatement:(t,e)=>"if ("+ze(t.test,e)+")"+ze(t.consequent,e)+(t.alternate?" else "+ze(t.alternate,e):""),SwitchStatement:(t,e)=>"switch ("+ze(t.discriminant,e)+") {"+Ge(t.cases,e,"")+"}",SwitchCase:(t,e)=>(t.test?"case "+ze(t.test,e):"default")+": "+Ge(t.consequent,e,";")+";",ReturnStatement:(t,e)=>"return "+ze(t.argument,e),Program:(t,e)=>ze(t.body[0],e)};function Je(t,e={index:"row"}){return ze(t,e)}function Ze(t){const e=typeof t;return"string"===e?`"${t}"`:"object"===e&&t?Et(t)?+t:vt(t)||$t(t)?`[${t.map(Ze)}]`:Dt(t)?t+"":function(t){let e="{",n=-1;for(const i in t)++n>0&&(e+=","),e+=`"${i}":${Ze(t[i])}`;return e+="}",e}(t):t}function Xe(t,e){const n=t.length;return 1===n?(e,n)=>Ze(t[0](e,n)):(i,r)=>{let s="";for(let a=0;a0&&(s+="|");const n=t[a](i,r);if(e&&(null==n||n!=n))return null;s+=Ze(n)}return s}}function tn(){}function en(t){return t.init=t.init||tn,t.add=t.add||tn,t.rem=t.rem||tn,t}function nn(t,e){return t.product_v=!1,t.product=e}var rn={count:{create:()=>en({value:t=>t.count}),param:[]},array_agg:{create:()=>en({init:t=>t.values=!0,value:t=>t.list.values(t.stream)}),param:[1]},object_agg:{create:()=>en({init:t=>t.values=!0,value:t=>Object.fromEntries(t.list.values())}),param:[2]},map_agg:{create:()=>en({init:t=>t.values=!0,value:t=>new Map(t.list.values())}),param:[2]},entries_agg:{create:()=>en({init:t=>t.values=!0,value:t=>t.list.values(t.stream)}),param:[2]},any:{create:()=>en({add:(t,e)=>{null==t.any&&(t.any=e)},value:t=>t.valid?t.any:Rt}),param:[1]},valid:{create:()=>en({value:t=>t.valid}),param:[1]},invalid:{create:()=>en({value:t=>t.count-t.valid}),param:[1]},distinct:{create:()=>({init:t=>t.distinct=function(){const t=new Map;return{count:()=>t.size,values:()=>Array.from(t.values(),(t=>t.v)),increment(e){const n=Ze(e),i=t.get(n);i?++i.n:t.set(n,{v:e,n:1})},decrement(e){const n=Ze(e),i=t.get(n);1===i.n?t.delete(n):--i.n},forEach(e){t.forEach((({v:t,n})=>e(t,n)))}}}(),value:t=>t.distinct.count()+(t.valid===t.count?0:1),add:(t,e)=>t.distinct.increment(e),rem:(t,e)=>t.distinct.decrement(e)}),param:[1]},array_agg_distinct:{create:()=>en({value:t=>t.distinct.values()}),param:[1],req:["distinct"]},mode:{create:()=>en({value:t=>{let e=Rt,n=0;return t.distinct.forEach(((t,i)=>{i>n&&(n=i,e=t)})),e}}),param:[1],req:["distinct"]},sum:{create:()=>({init:t=>t.sum=0,value:t=>t.valid?t.sum:Rt,add:(t,e)=>ge(e)?0===t.sum?t.sum=e:t.sum+=e:t.sum+=+e,rem:(t,e)=>t.sum-=e}),param:[1]},product:{create:()=>({init:t=>nn(t,1),value:t=>t.valid?t.product_v?nn(t,function(t,e=0,n=t.length){let i=t[e++];for(let r=e;rge(e)&&1===t.product?t.product=e:t.product*=e,rem:(t,e)=>0==e||e===1/0||e===-1/0?t.product_v=!0:t.product/=e}),param:[1],stream:["array_agg"]},mean:{create:()=>({init:t=>t.mean=0,value:t=>t.valid?t.mean:Rt,add:(t,e)=>{t.mean_d=e-t.mean,t.mean+=t.mean_d/t.valid},rem:(t,e)=>{t.mean_d=e-t.mean,t.mean-=t.valid?t.mean_d/t.valid:t.mean}}),param:[1]},average:{create:()=>en({value:t=>t.valid?t.mean:Rt}),param:[1],req:["mean"]},variance:{create:()=>({init:t=>t.dev=0,value:t=>t.valid>1?t.dev/(t.valid-1):Rt,add:(t,e)=>t.dev+=t.mean_d*(e-t.mean),rem:(t,e)=>t.dev-=t.mean_d*(e-t.mean)}),param:[1],req:["mean"]},variancep:{create:()=>en({value:t=>t.valid>1?t.dev/t.valid:Rt}),param:[1],req:["variance"]},stdev:{create:()=>en({value:t=>t.valid>1?Math.sqrt(t.dev/(t.valid-1)):Rt}),param:[1],req:["variance"]},stdevp:{create:()=>en({value:t=>t.valid>1?Math.sqrt(t.dev/t.valid):Rt}),param:[1],req:["variance"]},min:{create:()=>({init:t=>t.min=Rt,value:t=>t.min=Number.isNaN(t.min)?t.list.min():t.min,add:(t,e)=>{(e{e<=t.min&&(t.min=NaN)}}),param:[1],stream:["array_agg"]},max:{create:()=>({init:t=>t.max=Rt,value:t=>t.max=Number.isNaN(t.max)?t.list.max():t.max,add:(t,e)=>{(e>t.max||t.max===Rt)&&(t.max=e)},rem:(t,e)=>{e>=t.max&&(t.max=NaN)}}),param:[1],stream:["array_agg"]},quantile:{create:t=>en({value:e=>e.list.quantile(t)}),param:[1,1],req:["array_agg"]},median:{create:()=>en({value:t=>t.list.quantile(.5)}),param:[1],req:["array_agg"]},covariance:{create:()=>({init:t=>{t.cov=t.mean_x=t.mean_y=t.dev_x=t.dev_y=0},value:t=>t.valid>1?t.cov/(t.valid-1):Rt,add:(t,e,n)=>{const i=e-t.mean_x,r=n-t.mean_y;t.mean_x+=i/t.valid,t.mean_y+=r/t.valid;const s=n-t.mean_y;t.dev_x+=i*(e-t.mean_x),t.dev_y+=r*s,t.cov+=i*s},rem:(t,e,n)=>{const i=e-t.mean_x,r=n-t.mean_y;t.mean_x-=t.valid?i/t.valid:t.mean_x,t.mean_y-=t.valid?r/t.valid:t.mean_y;const s=n-t.mean_y;t.dev_x-=i*(e-t.mean_x),t.dev_y-=r*s,t.cov-=i*s}}),param:[2]},covariancep:{create:()=>en({value:t=>t.valid>1?t.cov/t.valid:Rt}),param:[2],req:["covariance"]},corr:{create:()=>en({value:t=>t.valid>1?t.cov/(Math.sqrt(t.dev_x)*Math.sqrt(t.dev_y)):Rt}),param:[2],req:["covariance"]},bins:{create:(t,e,n,i)=>en({value:r=>function(t,e,n=15,i=!0,r=0,s){const a=Math.LN10;if(null==s){const i=Math.ceil(Math.log(n)/a),o=e-t||Math.abs(t)||1,c=[5,2];for(s=Math.max(r,Math.pow(10,Math.round(Math.log(o)/a)-i));Math.ceil(o/s)>n;)s*=10;const u=c.length;for(let t=0;t=r&&o/e<=n&&(s=e)}}if(i){let n=Math.log(s);const i=n>=0?0:1+~~(-n/a),r=Math.pow(10,-i-1);n=Math.floor(t/s+r)*s,t=tt=1,value:e=>{const n=e.index;return n&&!e.peer(n)?t=n+1:t}}},param:[]},an={create(){let t;return{init:()=>t=0,value:e=>{const{index:n,peer:i,size:r}=e;let s=n;if(t({init:tn,value:t=>t.index+1}),param:[]},rank:sn,avg_rank:{create(){let t,e;return{init:()=>(t=-1,e=1),value:n=>{const i=n.index;if(i>=t){for(e=t=i+1;n.peer(t);e+=++t);e/=t-i}return e}}},param:[]},dense_rank:{create(){let t;return{init:()=>t=1,value:e=>{const n=e.index;return n&&!e.peer(n)?++t:t}}},param:[]},percent_rank:{create(){const{init:t,value:e}=sn.create();return{init:t,value:t=>(e(t)-1)/(t.size-1)}},param:[]},cume_dist:an,ntile:{create(t){(t=+t)>0||St("ntile num must be greater than zero.");const{init:e,value:n}=an.create();return{init:e,value:e=>Math.ceil(t*n(e))}},param:[0,1]},lag:{create:(t,e=Rt)=>(t=+t||1,{init:tn,value:(n,i)=>{const r=n.index-t;return r>=0?n.value(r,i):e}}),param:[1,2]},lead:{create:(t,e=Rt)=>(t=+t||1,{init:tn,value:(n,i)=>{const r=n.index+t;return r({init:tn,value:(t,e)=>t.value(t.i0,e)}),param:[1]},last_value:{create:()=>({init:tn,value:(t,e)=>t.value(t.i1-1,e)}),param:[1]},nth_value:{create:t=>((t=+t)>0||St("nth_value nth must be greater than zero."),{init:tn,value:(e,n)=>{const i=e.i0+(t-1);return ie=t,value:(t,n)=>{const i=t.value(t.index,n);return Ht(i)?e=i:e}}},param:[1,1]},fill_up:{create(t=Rt){let e,n;return{init:()=>(e=t,n=-1),value:(i,r)=>i.index<=n?e:(n=function(t,e,n){for(const i=t.size;n=0?e=i.value(n,r):(n=i.size,e=t)}},param:[1,1]}};function cn(t){return Vt(rn,t)}function un(t){return Vt(on,t)}function ln(t){return Vt(ye,t)||"row_object"===t}function hn(t){return cn(t)&&rn[t]}function pn(t){return un(t)&&on[t]}function dn(t,e,n){return t=`"use strict"; return ${t};`,Function("fn","$",t)(e,n)}var fn={escape:(t,e,n)=>dn(t,e,n),expr:(t,e)=>dn(`(row,data,op)=>${t}`,ye,e),expr2:(t,e)=>dn(`(row0,data0,row,data)=>${t}`,ye,e),join:(t,e)=>dn(`(row1,data1,row2,data2)=>${t}`,ye,e),param:(t,e)=>dn(t,ye,e)};const mn={"==":1,"!=":1,"===":1,"!==":1};function yn(t,e,n=0,i,r){if(t.type=Ue,t.name=e,t.table=n,r&&i&&At(i.keyFor)){const e=mn[r.operator]?r.left===t?r.right:r.left:r.callee&&"equal"===r.callee.name?r.arguments[r.arguments[0]===t?1:0]:null;e&&e.type===Oe&&function(t,e,n,i){i<0?(t.type=Oe,t.value=!1,t.raw="false"):(e.type=Re,n.value=i,n.raw=i+"")}(r,t,e,i.keyFor(e.value))}return t}function gn(t){return vt(t)?t:pe(t)?t.entries():t?Object.entries(t):[]}const bn="row_object";function vn(t,e){t.type=Le;const n=t.properties=[];for(const t of gn(e)){const[e,i]=vt(t)?t:[t,t];n.push({type:Ve,key:{type:Oe,raw:be(i)},value:yn({computed:!0},e)})}return t}function _n(t){return Je(vn({},t))}function xn(t){return fn.expr(_n(t))}function wn(t,e,n,i){return new(n||(n=Promise))((function(r,s){function a(t){try{c(i.next(t))}catch(t){s(t)}}function o(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}c((i=i.apply(t,e||[])).next())}))}function Sn(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function In(t){return this instanceof In?(this.v=t,this):new In(t)}function An(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(t,e||[]),s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(t){r[t]&&(i[t]=function(e){return new Promise((function(n,i){s.push([t,e,n,i])>1||o(t,e)}))})}function o(t,e){try{(n=r[t](e)).value instanceof In?Promise.resolve(n.value.v).then(c,u):l(s[0][2],n)}catch(t){l(s[0][3],t)}var n}function c(t){o("next",t)}function u(t){o("throw",t)}function l(t,e){t(e),s.shift(),s.length&&o(s[0][0],s[0][1])}}function Tn(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:In(t[i](e)),done:!1}:r?r(e):e}:r}}function kn(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=Sn(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;const Cn=new TextDecoder("utf-8"),Mn=t=>Cn.decode(t),En=new TextEncoder,Nn=t=>En.encode(t),Dn=t=>"function"==typeof t,On=t=>null!=t&&Object(t)===t,Bn=t=>On(t)&&Dn(t.then),Ln=t=>On(t)&&Dn(t[Symbol.iterator]),Fn=t=>On(t)&&Dn(t[Symbol.asyncIterator]),Vn=t=>On(t)&&"done"in t&&"value"in t,Un=t=>"_getDOMStream"in t&&"_getNodeStream"in t,Pn=t=>On(t)&&Dn(t.clear)&&Dn(t.bytes)&&Dn(t.position)&&Dn(t.setPosition)&&Dn(t.capacity)&&Dn(t.getBufferIdentifier)&&Dn(t.createLong),Rn="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;function jn(t,e,n=0,i=e.byteLength){const r=t.byteLength,s=new Uint8Array(t.buffer,t.byteOffset,r),a=new Uint8Array(e.buffer,e.byteOffset,Math.min(i,r));return s.set(a,n),t}function $n(t,e){const n=function(t){const e=t[0]?[t[0]]:[];let n,i,r,s;for(let a,o,c=0,u=0,l=t.length;++ct+e.byteLength),0);let r,s,a,o=0,c=-1;const u=Math.min(e||Number.POSITIVE_INFINITY,i);for(const t=n.length;++czn(Int32Array,t),qn=t=>zn(Uint8Array,t),Yn=t=>(t.next(),t);const Gn=t=>function*(t,e){const n=function*(t){yield t},i="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Rn?n(e):Ln(e)?e:n(e);return yield*Yn(function*(e){let n=null;do{n=e.next(yield zn(t,n))}while(!n.done)}(i[Symbol.iterator]())),new t}(Uint8Array,t);function Wn(t,e){return An(this,arguments,(function*(){if(Bn(e))return yield In(yield In(yield*Tn(kn(Wn(t,yield In(e))))));const n=function(t){return An(this,arguments,(function*(){yield yield In(yield In(t))}))},i="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof Rn?n(e):Ln(e)?function(t){return An(this,arguments,(function*(){yield In(yield*Tn(kn(Yn(function*(t){let e=null;do{e=t.next(yield null==e?void 0:e.value)}while(!e.done)}(t[Symbol.iterator]())))))}))}(e):Fn(e)?e:n(e);return yield In(yield*Tn(kn(Yn(function(e){return An(this,arguments,(function*(){let n=null;do{n=yield In(e.next(yield yield In(zn(t,n))))}while(!n.done)}))}(i[Symbol.asyncIterator]()))))),yield In(new t)}))}const Kn=t=>Wn(Uint8Array,t);function Qn(t,e,n){if(0!==t)for(let i=-1,r=(n=n.slice(0,e)).length;++iZn(function*(t){let e,n,i,r,s=!1,a=[],o=0;function c(){return"peek"===i?$n(a,r)[0]:([n,a,o]=$n(a,r),n)}({cmd:i,size:r}=yield null);const u=Gn(t)[Symbol.iterator]();try{do{if(({done:e,value:n}=Number.isNaN(r-o)?u.next():u.next(r-o)),!e&&n.byteLength>0&&(a.push(n),o+=n.byteLength),e||r<=o)do{({cmd:i,size:r}=yield c())}while(rZn(function(t){return An(this,arguments,(function*(){let e,n,i,r,s=!1,a=[],o=0;function c(){return"peek"===i?$n(a,r)[0]:([n,a,o]=$n(a,r),n)}({cmd:i,size:r}=yield yield In(null));const u=Kn(t)[Symbol.asyncIterator]();try{do{if(({done:e,value:n}=Number.isNaN(r-o)?yield In(u.next()):yield In(u.next(r-o))),!e&&n.byteLength>0&&(a.push(n),o+=n.byteLength),e||r<=o)do{({cmd:i,size:r}=yield yield In(c()))}while(rZn(function(t){return An(this,arguments,(function*(){let e,n,i,r=!1,s=!1,a=[],o=0;function c(){return"peek"===n?$n(a,i)[0]:([e,a,o]=$n(a,i),e)}({cmd:n,size:i}=yield yield In(null));const u=new Xn(t);try{do{if(({done:r,value:e}=Number.isNaN(i-o)?yield In(u.read()):yield In(u.read(i-o))),!r&&e.byteLength>0&&(a.push(qn(e)),o+=e.byteLength),r||i<=o)do{({cmd:n,size:i}=yield yield In(c()))}while(iZn(function(t){return An(this,arguments,(function*(){const e=[];let n,i,r,s="error",a=!1,o=null,c=0,u=[];function l(){return"peek"===n?$n(u,i)[0]:([r,u,c]=$n(u,i),r)}if(({cmd:n,size:i}=yield yield In(null)),t.isTTY)return yield yield In(new Uint8Array(0)),yield In(null);try{e[0]=ti(t,"end"),e[1]=ti(t,"error");do{if(e[2]=ti(t,"readable"),[s,o]=yield In(Promise.race(e.map((t=>t[2])))),"error"===s)break;if((a="end"===s)||(Number.isFinite(i-c)?(r=qn(t.read(i-c)),r.byteLength0&&(u.push(r),c+=r.byteLength)),a||i<=c)do{({cmd:n,size:i}=yield yield In(l()))}while(i{for(const[n,i]of e)t.off(n,i);try{const e=t.destroy;e&&e.call(t,n),n=void 0}catch(t){n=t||n}finally{null!=n?r(n):i()}}))}}))}(t)),toDOMStream(t,e){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(t,e){throw new Error('"toNodeStream" not available in this environment')}};const Zn=t=>(t.next(),t);class Xn{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch((()=>{}))}get closed(){return this.reader?this.reader.closed.catch((()=>{})):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return wn(this,void 0,void 0,(function*(){const{reader:e,source:n}=this;e&&(yield e.cancel(t).catch((()=>{}))),n&&n.locked&&this.releaseLock()}))}read(t){return wn(this,void 0,void 0,(function*(){if(0===t)return{done:null==this.reader,value:new Uint8Array(0)};const e=yield this.reader.read();return!e.done&&(e.value=qn(e)),e}))}}const ti=(t,e)=>{const n=t=>i([e,t]);let i;return[e,n,new Promise((r=>(i=r)&&t.once(e,n)))]};var ei,ni,ii,ri,si,ai,oi,ci,ui;!function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"}(ei||(ei={})),function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"}(ni||(ni={})),function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"}(ii||(ii={})),function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"}(ri||(ri={})),function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"}(si||(si={})),function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"}(ai||(ai={})),function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"}(oi||(oi={})),function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth",t[t.DurationSecond=-27]="DurationSecond",t[t.DurationMillisecond=-28]="DurationMillisecond",t[t.DurationMicrosecond=-29]="DurationMicrosecond",t[t.DurationNanosecond=-30]="DurationNanosecond"}(ci||(ci={})),function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"}(ui||(ui={}));const li=void 0;function hi(t){if(null===t)return"null";if(t===li)return"undefined";switch(typeof t){case"number":case"bigint":return`${t}`;case"string":return`"${t}"`}return"function"==typeof t[Symbol.toPrimitive]?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof BigInt64Array||t instanceof BigUint64Array?`[${[...t].map((t=>hi(t)))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,((t,e)=>"bigint"==typeof e?`${e}`:e))}const pi=Symbol.for("isArrowBigNum");function di(t,...e){return 0===e.length?Object.setPrototypeOf(zn(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}function fi(...t){return di.apply(this,t)}function mi(...t){return di.apply(this,t)}function yi(...t){return di.apply(this,t)}function gi(t){const{buffer:e,byteOffset:n,length:i,signed:r}=t,s=new BigUint64Array(e,n,i),a=r&&s.at(-1)&BigInt(1)<{if(8===t.byteLength){return`${new t.BigIntArray(t.buffer,t.byteOffset,1)[0]}`}if(!t.signed)return _i(t);let e=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2);if(new Int16Array([e.at(-1)])[0]>=0)return _i(t);e=e.slice();let n=1;for(let t=0;t{if(8===t.byteLength){return new t.BigIntArray(t.buffer,t.byteOffset,1)[0]}return bi(t)};function _i(t){let e="";const n=new Uint32Array(2);let i=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2);const r=new Uint32Array((i=new Uint16Array(i).reverse()).buffer);let s=-1;const a=i.length-1;do{for(n[0]=i[s=0];sNumber.MAX_SAFE_INTEGER))throw new TypeError(`${t} is not safe to convert to a number.`);return Number(t)}var Si,Ii,Ai,Ti,ki,Ci,Mi,Ei,Ni,Di,Oi,Bi,Li,Fi,Vi,Ui,Pi,Ri,ji,$i,zi;class Hi{static isNull(t){return(null==t?void 0:t.typeId)===ci.Null}static isInt(t){return(null==t?void 0:t.typeId)===ci.Int}static isFloat(t){return(null==t?void 0:t.typeId)===ci.Float}static isBinary(t){return(null==t?void 0:t.typeId)===ci.Binary}static isUtf8(t){return(null==t?void 0:t.typeId)===ci.Utf8}static isBool(t){return(null==t?void 0:t.typeId)===ci.Bool}static isDecimal(t){return(null==t?void 0:t.typeId)===ci.Decimal}static isDate(t){return(null==t?void 0:t.typeId)===ci.Date}static isTime(t){return(null==t?void 0:t.typeId)===ci.Time}static isTimestamp(t){return(null==t?void 0:t.typeId)===ci.Timestamp}static isInterval(t){return(null==t?void 0:t.typeId)===ci.Interval}static isDuration(t){return(null==t?void 0:t.typeId)===ci.Duration}static isList(t){return(null==t?void 0:t.typeId)===ci.List}static isStruct(t){return(null==t?void 0:t.typeId)===ci.Struct}static isUnion(t){return(null==t?void 0:t.typeId)===ci.Union}static isFixedSizeBinary(t){return(null==t?void 0:t.typeId)===ci.FixedSizeBinary}static isFixedSizeList(t){return(null==t?void 0:t.typeId)===ci.FixedSizeList}static isMap(t){return(null==t?void 0:t.typeId)===ci.Map}static isDictionary(t){return(null==t?void 0:t.typeId)===ci.Dictionary}static isDenseUnion(t){return Hi.isUnion(t)&&t.mode===ni.Dense}static isSparseUnion(t){return Hi.isUnion(t)&&t.mode===ni.Sparse}get typeId(){return ci.NONE}}Si=Symbol.toStringTag,Hi[Si]=((zi=Hi.prototype).children=null,zi.ArrayType=Array,zi[Symbol.toStringTag]="DataType");let qi=class extends Hi{toString(){return"Null"}get typeId(){return ci.Null}};Ii=Symbol.toStringTag,qi[Ii]=(t=>t[Symbol.toStringTag]="Null")(qi.prototype);class Yi extends Hi{constructor(t,e){super(),this.isSigned=t,this.bitWidth=e}get typeId(){return ci.Int}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Ai=Symbol.toStringTag,Yi[Ai]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Yi.prototype);class Gi extends Yi{constructor(){super(!0,8)}get ArrayType(){return Int8Array}}class Wi extends Yi{constructor(){super(!0,16)}get ArrayType(){return Int16Array}}class Ki extends Yi{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}class Qi extends Yi{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}}class Ji extends Yi{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}}class Zi extends Yi{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}}class Xi extends Yi{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}}class tr extends Yi{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}}Object.defineProperty(Gi.prototype,"ArrayType",{value:Int8Array}),Object.defineProperty(Wi.prototype,"ArrayType",{value:Int16Array}),Object.defineProperty(Ki.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(Qi.prototype,"ArrayType",{value:BigInt64Array}),Object.defineProperty(Ji.prototype,"ArrayType",{value:Uint8Array}),Object.defineProperty(Zi.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(Xi.prototype,"ArrayType",{value:Uint32Array}),Object.defineProperty(tr.prototype,"ArrayType",{value:BigUint64Array});class er extends Hi{constructor(t){super(),this.precision=t}get typeId(){return ci.Float}get ArrayType(){switch(this.precision){case ii.HALF:return Uint16Array;case ii.SINGLE:return Float32Array;case ii.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Ti=Symbol.toStringTag,er[Ti]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(er.prototype);class nr extends er{constructor(){super(ii.HALF)}}class ir extends er{constructor(){super(ii.SINGLE)}}class rr extends er{constructor(){super(ii.DOUBLE)}}Object.defineProperty(nr.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(ir.prototype,"ArrayType",{value:Float32Array}),Object.defineProperty(rr.prototype,"ArrayType",{value:Float64Array});let sr=class extends Hi{constructor(){super()}get typeId(){return ci.Binary}toString(){return"Binary"}};ki=Symbol.toStringTag,sr[ki]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(sr.prototype);let ar=class extends Hi{constructor(){super()}get typeId(){return ci.Utf8}toString(){return"Utf8"}};Ci=Symbol.toStringTag,ar[Ci]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(ar.prototype);let or=class extends Hi{constructor(){super()}get typeId(){return ci.Bool}toString(){return"Bool"}};Mi=Symbol.toStringTag,or[Mi]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(or.prototype);let cr=class extends Hi{constructor(t,e,n=128){super(),this.scale=t,this.precision=e,this.bitWidth=n}get typeId(){return ci.Decimal}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};Ei=Symbol.toStringTag,cr[Ei]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(cr.prototype);class ur extends Hi{constructor(t){super(),this.unit=t}get typeId(){return ci.Date}toString(){return`Date${32*(this.unit+1)}<${ri[this.unit]}>`}}Ni=Symbol.toStringTag,ur[Ni]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"))(ur.prototype);class lr extends ur{constructor(){super(ri.DAY)}}class hr extends ur{constructor(){super(ri.MILLISECOND)}}class pr extends Hi{constructor(t,e){super(),this.unit=t,this.bitWidth=e}get typeId(){return ci.Time}toString(){return`Time${this.bitWidth}<${si[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Di=Symbol.toStringTag,pr[Di]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(pr.prototype);class dr extends pr{constructor(){super(si.SECOND,32)}}class fr extends pr{constructor(){super(si.MILLISECOND,32)}}class mr extends pr{constructor(){super(si.MICROSECOND,64)}}class yr extends pr{constructor(){super(si.NANOSECOND,64)}}class gr extends Hi{constructor(t,e){super(),this.unit=t,this.timezone=e}get typeId(){return ci.Timestamp}toString(){return`Timestamp<${si[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Oi=Symbol.toStringTag,gr[Oi]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"))(gr.prototype);class br extends Hi{constructor(t){super(),this.unit=t}get typeId(){return ci.Interval}toString(){return`Interval<${ai[this.unit]}>`}}Bi=Symbol.toStringTag,br[Bi]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(br.prototype);class vr extends br{constructor(){super(ai.DAY_TIME)}}class _r extends br{constructor(){super(ai.YEAR_MONTH)}}let xr=class extends Hi{constructor(t){super(),this.unit=t}get typeId(){return ci.Duration}toString(){return`Duration<${si[this.unit]}>`}};Li=Symbol.toStringTag,xr[Li]=(t=>(t.unit=null,t.ArrayType=BigInt64Array,t[Symbol.toStringTag]="Duration"))(xr.prototype);let wr=class extends Hi{constructor(t){super(),this.children=[t]}get typeId(){return ci.List}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};Fi=Symbol.toStringTag,wr[Fi]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(wr.prototype);class Sr extends Hi{constructor(t){super(),this.children=t}get typeId(){return ci.Struct}toString(){return`Struct<{${this.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}Vi=Symbol.toStringTag,Sr[Vi]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(Sr.prototype);class Ir extends Hi{constructor(t,e,n){super(),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce(((t,e,n)=>(t[e]=n)&&t||t),Object.create(null))}get typeId(){return ci.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map((t=>`${t.type}`)).join(" | ")}>`}}Ui=Symbol.toStringTag,Ir[Ui]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(Ir.prototype);let Ar=class extends Hi{constructor(t){super(),this.byteWidth=t}get typeId(){return ci.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};Pi=Symbol.toStringTag,Ar[Pi]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(Ar.prototype);let Tr=class extends Hi{constructor(t,e){super(),this.listSize=t,this.children=[e]}get typeId(){return ci.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};Ri=Symbol.toStringTag,Tr[Ri]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(Tr.prototype);class kr extends Hi{constructor(t,e=!1){var n,i,r;if(super(),this.children=[t],this.keysSorted=e,t&&(t.name="entries",null===(n=null==t?void 0:t.type)||void 0===n?void 0:n.children)){const e=null===(i=null==t?void 0:t.type)||void 0===i?void 0:i.children[0];e&&(e.name="key");const n=null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.children[1];n&&(n.name="value")}}get typeId(){return ci.Map}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}ji=Symbol.toStringTag,kr[ji]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(kr.prototype);const Cr=(Mr=-1,()=>++Mr);var Mr;class Er extends Hi{constructor(t,e,n,i){super(),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=null==n?Cr():wi(n)}get typeId(){return ci.Dictionary}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}function Nr(t){const e=t;switch(t.typeId){case ci.Decimal:return t.bitWidth/32;case ci.Timestamp:return 2;case ci.Date:case ci.Interval:return 1+e.unit;case ci.FixedSizeList:return e.listSize;case ci.FixedSizeBinary:return e.byteWidth;default:return 1}}$i=Symbol.toStringTag,Er[$i]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(Er.prototype);class Dr{visitMany(t,...e){return t.map(((t,n)=>this.visit(t,...e.map((t=>t[n])))))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return function(t,e,n=!0){if("number"==typeof e)return Or(t,e,n);if("string"==typeof e&&e in ci)return Or(t,ci[e],n);if(e&&e instanceof Hi)return Or(t,Br(e),n);if((null==e?void 0:e.type)&&e.type instanceof Hi)return Or(t,Br(e.type),n);return Or(t,ci.NONE,n)}(this,t,e)}getVisitFnByTypeId(t,e=!0){return Or(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}}function Or(t,e,n=!0){let i=null;switch(e){case ci.Null:i=t.visitNull;break;case ci.Bool:i=t.visitBool;break;case ci.Int:i=t.visitInt;break;case ci.Int8:i=t.visitInt8||t.visitInt;break;case ci.Int16:i=t.visitInt16||t.visitInt;break;case ci.Int32:i=t.visitInt32||t.visitInt;break;case ci.Int64:i=t.visitInt64||t.visitInt;break;case ci.Uint8:i=t.visitUint8||t.visitInt;break;case ci.Uint16:i=t.visitUint16||t.visitInt;break;case ci.Uint32:i=t.visitUint32||t.visitInt;break;case ci.Uint64:i=t.visitUint64||t.visitInt;break;case ci.Float:i=t.visitFloat;break;case ci.Float16:i=t.visitFloat16||t.visitFloat;break;case ci.Float32:i=t.visitFloat32||t.visitFloat;break;case ci.Float64:i=t.visitFloat64||t.visitFloat;break;case ci.Utf8:i=t.visitUtf8;break;case ci.Binary:i=t.visitBinary;break;case ci.FixedSizeBinary:i=t.visitFixedSizeBinary;break;case ci.Date:i=t.visitDate;break;case ci.DateDay:i=t.visitDateDay||t.visitDate;break;case ci.DateMillisecond:i=t.visitDateMillisecond||t.visitDate;break;case ci.Timestamp:i=t.visitTimestamp;break;case ci.TimestampSecond:i=t.visitTimestampSecond||t.visitTimestamp;break;case ci.TimestampMillisecond:i=t.visitTimestampMillisecond||t.visitTimestamp;break;case ci.TimestampMicrosecond:i=t.visitTimestampMicrosecond||t.visitTimestamp;break;case ci.TimestampNanosecond:i=t.visitTimestampNanosecond||t.visitTimestamp;break;case ci.Time:i=t.visitTime;break;case ci.TimeSecond:i=t.visitTimeSecond||t.visitTime;break;case ci.TimeMillisecond:i=t.visitTimeMillisecond||t.visitTime;break;case ci.TimeMicrosecond:i=t.visitTimeMicrosecond||t.visitTime;break;case ci.TimeNanosecond:i=t.visitTimeNanosecond||t.visitTime;break;case ci.Decimal:i=t.visitDecimal;break;case ci.List:i=t.visitList;break;case ci.Struct:i=t.visitStruct;break;case ci.Union:i=t.visitUnion;break;case ci.DenseUnion:i=t.visitDenseUnion||t.visitUnion;break;case ci.SparseUnion:i=t.visitSparseUnion||t.visitUnion;break;case ci.Dictionary:i=t.visitDictionary;break;case ci.Interval:i=t.visitInterval;break;case ci.IntervalDayTime:i=t.visitIntervalDayTime||t.visitInterval;break;case ci.IntervalYearMonth:i=t.visitIntervalYearMonth||t.visitInterval;break;case ci.Duration:i=t.visitDuration;break;case ci.DurationSecond:i=t.visitDurationSecond||t.visitDuration;break;case ci.DurationMillisecond:i=t.visitDurationMillisecond||t.visitDuration;break;case ci.DurationMicrosecond:i=t.visitDurationMicrosecond||t.visitDuration;break;case ci.DurationNanosecond:i=t.visitDurationNanosecond||t.visitDuration;break;case ci.FixedSizeList:i=t.visitFixedSizeList;break;case ci.Map:i=t.visitMap}if("function"==typeof i)return i;if(!n)return()=>null;throw new Error(`Unrecognized type '${ci[e]}'`)}function Br(t){switch(t.typeId){case ci.Null:return ci.Null;case ci.Int:{const{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?ci.Int8:ci.Uint8;case 16:return n?ci.Int16:ci.Uint16;case 32:return n?ci.Int32:ci.Uint32;case 64:return n?ci.Int64:ci.Uint64}return ci.Int}case ci.Float:switch(t.precision){case ii.HALF:return ci.Float16;case ii.SINGLE:return ci.Float32;case ii.DOUBLE:return ci.Float64}return ci.Float;case ci.Binary:return ci.Binary;case ci.Utf8:return ci.Utf8;case ci.Bool:return ci.Bool;case ci.Decimal:return ci.Decimal;case ci.Time:switch(t.unit){case si.SECOND:return ci.TimeSecond;case si.MILLISECOND:return ci.TimeMillisecond;case si.MICROSECOND:return ci.TimeMicrosecond;case si.NANOSECOND:return ci.TimeNanosecond}return ci.Time;case ci.Timestamp:switch(t.unit){case si.SECOND:return ci.TimestampSecond;case si.MILLISECOND:return ci.TimestampMillisecond;case si.MICROSECOND:return ci.TimestampMicrosecond;case si.NANOSECOND:return ci.TimestampNanosecond}return ci.Timestamp;case ci.Date:switch(t.unit){case ri.DAY:return ci.DateDay;case ri.MILLISECOND:return ci.DateMillisecond}return ci.Date;case ci.Interval:switch(t.unit){case ai.DAY_TIME:return ci.IntervalDayTime;case ai.YEAR_MONTH:return ci.IntervalYearMonth}return ci.Interval;case ci.Duration:switch(t.unit){case si.SECOND:return ci.DurationSecond;case si.MILLISECOND:return ci.DurationMillisecond;case si.MICROSECOND:return ci.DurationMicrosecond;case si.NANOSECOND:return ci.DurationNanosecond}return ci.Duration;case ci.Map:return ci.Map;case ci.List:return ci.List;case ci.Struct:return ci.Struct;case ci.Union:switch(t.mode){case ni.Dense:return ci.DenseUnion;case ni.Sparse:return ci.SparseUnion}return ci.Union;case ci.FixedSizeBinary:return ci.FixedSizeBinary;case ci.FixedSizeList:return ci.FixedSizeList;case ci.Dictionary:return ci.Dictionary}throw new Error(`Unrecognized type '${ci[t.typeId]}'`)}Dr.prototype.visitInt8=null,Dr.prototype.visitInt16=null,Dr.prototype.visitInt32=null,Dr.prototype.visitInt64=null,Dr.prototype.visitUint8=null,Dr.prototype.visitUint16=null,Dr.prototype.visitUint32=null,Dr.prototype.visitUint64=null,Dr.prototype.visitFloat16=null,Dr.prototype.visitFloat32=null,Dr.prototype.visitFloat64=null,Dr.prototype.visitDateDay=null,Dr.prototype.visitDateMillisecond=null,Dr.prototype.visitTimestampSecond=null,Dr.prototype.visitTimestampMillisecond=null,Dr.prototype.visitTimestampMicrosecond=null,Dr.prototype.visitTimestampNanosecond=null,Dr.prototype.visitTimeSecond=null,Dr.prototype.visitTimeMillisecond=null,Dr.prototype.visitTimeMicrosecond=null,Dr.prototype.visitTimeNanosecond=null,Dr.prototype.visitDenseUnion=null,Dr.prototype.visitSparseUnion=null,Dr.prototype.visitIntervalDayTime=null,Dr.prototype.visitIntervalYearMonth=null,Dr.prototype.visitDuration=null,Dr.prototype.visitDurationSecond=null,Dr.prototype.visitDurationMillisecond=null,Dr.prototype.visitDurationMicrosecond=null,Dr.prototype.visitDurationNanosecond=null;const Lr=new Float64Array(1),Fr=new Uint32Array(Lr.buffer);function Vr(t){const e=(31744&t)>>10,n=(1023&t)/1024,i=Math.pow(-1,(32768&t)>>15);switch(e){case 31:return i*(n?Number.NaN:1/0);case 0:return i*(n?6103515625e-14*n:0)}return i*Math.pow(2,e-15)*(1+n)}function Ur(t){if(t!=t)return 32256;Lr[0]=t;const e=(2147483648&Fr[1])>>16&65535;let n=2146435072&Fr[1],i=0;return n>=1089470464?Fr[0]>0?n=31744:(n=(2080374784&n)>>16,i=(1048575&Fr[1])>>10):n<=1056964608?(i=1048576+(1048575&Fr[1]),i=1048576+(i<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,i=512+(1048575&Fr[1])>>10),e|n|65535&i}class Pr extends Dr{}function Rr(t){return(e,n,i)=>{if(e.setValid(n,null!=i))return t(e,n,i)}}const jr=(t,e,n)=>{t[e]=Math.trunc(n%4294967296),t[e+1]=Math.trunc(n/4294967296)},$r=(t,e,n,i)=>{if(n+1{t[e]=n},Hr=({values:t},e,n)=>{t[e]=n},qr=({values:t},e,n)=>{t[e]=Ur(n)},Yr=({values:t},e,n)=>{((t,e,n)=>{t[e]=Math.trunc(n/864e5)})(t,e,n.valueOf())},Gr=({values:t},e,n)=>{jr(t,2*e,n.valueOf())},Wr=({stride:t,values:e},n,i)=>{e.set(i.subarray(0,t),t*n)},Kr=(t,e,n)=>{t.type.unit===ri.DAY?Yr(t,e,n):Gr(t,e,n)},Qr=({values:t},e,n)=>jr(t,2*e,n/1e3),Jr=({values:t},e,n)=>jr(t,2*e,n),Zr=({values:t},e,n)=>((t,e,n)=>{t[e]=Math.trunc(1e3*n%4294967296),t[e+1]=Math.trunc(1e3*n/4294967296)})(t,2*e,n),Xr=({values:t},e,n)=>((t,e,n)=>{t[e]=Math.trunc(1e6*n%4294967296),t[e+1]=Math.trunc(1e6*n/4294967296)})(t,2*e,n),ts=(t,e,n)=>{switch(t.type.unit){case si.SECOND:return Qr(t,e,n);case si.MILLISECOND:return Jr(t,e,n);case si.MICROSECOND:return Zr(t,e,n);case si.NANOSECOND:return Xr(t,e,n)}},es=({values:t},e,n)=>{t[e]=n},ns=({values:t},e,n)=>{t[e]=n},is=({values:t},e,n)=>{t[e]=n},rs=({values:t},e,n)=>{t[e]=n},ss=(t,e,n)=>{switch(t.type.unit){case si.SECOND:return es(t,e,n);case si.MILLISECOND:return ns(t,e,n);case si.MICROSECOND:return is(t,e,n);case si.NANOSECOND:return rs(t,e,n)}},as=({values:t,stride:e},n,i)=>{t.set(i.subarray(0,e),e*n)},os=(t,e,n)=>{const i=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[i];gs.visit(r,t.valueOffsets[e],n)},cs=(t,e,n)=>{const i=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[i];gs.visit(r,e,n)},us=(t,e,n)=>{t.type.unit===ai.DAY_TIME?ls(t,e,n):hs(t,e,n)},ls=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},hs=({values:t},e,n)=>{t[e]=12*n[0]+n[1]%12},ps=({values:t},e,n)=>{t[e]=n},ds=({values:t},e,n)=>{t[e]=n},fs=({values:t},e,n)=>{t[e]=n},ms=({values:t},e,n)=>{t[e]=n},ys=(t,e,n)=>{switch(t.type.unit){case si.SECOND:return ps(t,e,n);case si.MILLISECOND:return ds(t,e,n);case si.MICROSECOND:return fs(t,e,n);case si.NANOSECOND:return ms(t,e,n)}};Pr.prototype.visitBool=Rr((({offset:t,values:e},n,i)=>{const r=t+n;i?e[r>>3]|=1<>3]&=~(1<{switch(t.type.precision){case ii.HALF:return qr(t,e,n);case ii.SINGLE:case ii.DOUBLE:return Hr(t,e,n)}})),Pr.prototype.visitFloat16=Rr(qr),Pr.prototype.visitFloat32=Rr(Hr),Pr.prototype.visitFloat64=Rr(Hr),Pr.prototype.visitUtf8=Rr((({values:t,valueOffsets:e},n,i)=>{$r(t,e,n,Nn(i))})),Pr.prototype.visitBinary=Rr((({values:t,valueOffsets:e},n,i)=>$r(t,e,n,i))),Pr.prototype.visitFixedSizeBinary=Rr(Wr),Pr.prototype.visitDate=Rr(Kr),Pr.prototype.visitDateDay=Rr(Yr),Pr.prototype.visitDateMillisecond=Rr(Gr),Pr.prototype.visitTimestamp=Rr(ts),Pr.prototype.visitTimestampSecond=Rr(Qr),Pr.prototype.visitTimestampMillisecond=Rr(Jr),Pr.prototype.visitTimestampMicrosecond=Rr(Zr),Pr.prototype.visitTimestampNanosecond=Rr(Xr),Pr.prototype.visitTime=Rr(ss),Pr.prototype.visitTimeSecond=Rr(es),Pr.prototype.visitTimeMillisecond=Rr(ns),Pr.prototype.visitTimeMicrosecond=Rr(is),Pr.prototype.visitTimeNanosecond=Rr(rs),Pr.prototype.visitDecimal=Rr(as),Pr.prototype.visitList=Rr(((t,e,n)=>{const i=t.children[0],r=t.valueOffsets,s=gs.getVisitFn(i);if(Array.isArray(n))for(let t=-1,a=r[e],o=r[e+1];a{const i=t.type.children.map((t=>gs.getVisitFn(t.type))),r=n instanceof Map?(s=e,a=n,(t,e,n,i)=>e&&t(e,s,a.get(n.name))):n instanceof $a?((t,e)=>(n,i,r,s)=>i&&n(i,t,e.get(s)))(e,n):Array.isArray(n)?((t,e)=>(n,i,r,s)=>i&&n(i,t,e[s]))(e,n):((t,e)=>(n,i,r,s)=>i&&n(i,t,e[r.name]))(e,n);var s,a;t.type.children.forEach(((e,n)=>r(i[n],t.children[n],e,n)))})),Pr.prototype.visitUnion=Rr(((t,e,n)=>{t.type.mode===ni.Dense?os(t,e,n):cs(t,e,n)})),Pr.prototype.visitDenseUnion=Rr(os),Pr.prototype.visitSparseUnion=Rr(cs),Pr.prototype.visitDictionary=Rr(((t,e,n)=>{var i;null===(i=t.dictionary)||void 0===i||i.set(t.values[e],n)})),Pr.prototype.visitInterval=Rr(us),Pr.prototype.visitIntervalDayTime=Rr(ls),Pr.prototype.visitIntervalYearMonth=Rr(hs),Pr.prototype.visitDuration=Rr(ys),Pr.prototype.visitDurationSecond=Rr(ps),Pr.prototype.visitDurationMillisecond=Rr(ds),Pr.prototype.visitDurationMicrosecond=Rr(fs),Pr.prototype.visitDurationNanosecond=Rr(ms),Pr.prototype.visitFixedSizeList=Rr(((t,e,n)=>{const{stride:i}=t,r=t.children[0],s=gs.getVisitFn(r);if(Array.isArray(n))for(let t=-1,a=e*i;++t{const i=t.children[0],{valueOffsets:r}=t,s=gs.getVisitFn(i);let{[e]:a,[e+1]:o}=r;const c=n instanceof Map?n.entries():Object.entries(n);for(const t of c)if(s(i,a,t),++a>=o)break}));const gs=new Pr,bs=Symbol.for("parent"),vs=Symbol.for("rowIndex");class _s{constructor(t,e){return this[bs]=t,this[vs]=e,new Proxy(this,new ws)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[vs],e=this[bs],n=e.type.children,i={};for(let r=-1,s=n.length;++r`${hi(t)}: ${hi(e)}`)).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new xs(this[bs],this[vs])}}class xs{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return tt.name))}has(t,e){return-1!==t[bs].type.children.findIndex((t=>t.name===e))}getOwnPropertyDescriptor(t,e){if(-1!==t[bs].type.children.findIndex((t=>t.name===e)))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[bs].type.children.findIndex((t=>t.name===e));if(-1!==n){const i=Ws.visit(t[bs].children[n],t[vs]);return Reflect.set(t,e,i),i}}set(t,e,n){const i=t[bs].type.children.findIndex((t=>t.name===e));return-1!==i?(gs.visit(t[bs].children[i],t[vs],n),Reflect.set(t,e,n)):!(!Reflect.has(t,e)&&"symbol"!=typeof e)&&Reflect.set(t,e,n)}}class Ss extends Dr{}function Is(t){return(e,n)=>e.getValid(n)?t(e,n):null}const As=(t,e)=>4294967296*t[e+1]+(t[e]>>>0),Ts=t=>new Date(t),ks=(t,e,n)=>{if(n+1>=e.length)return null;const i=e[n],r=e[n+1];return t.subarray(i,r)},Cs=({values:t},e)=>((t,e)=>Ts(((t,e)=>864e5*t[e])(t,e)))(t,e),Ms=({values:t},e)=>((t,e)=>Ts(As(t,e)))(t,2*e),Es=({stride:t,values:e},n)=>e[t*n],Ns=({values:t},e)=>t[e],Ds=({values:t},e)=>1e3*As(t,2*e),Os=({values:t},e)=>As(t,2*e),Bs=({values:t},e)=>((t,e)=>t[e+1]/1e3*4294967296+(t[e]>>>0)/1e3)(t,2*e),Ls=({values:t},e)=>((t,e)=>t[e+1]/1e6*4294967296+(t[e]>>>0)/1e6)(t,2*e),Fs=({values:t},e)=>t[e],Vs=({values:t},e)=>t[e],Us=({values:t},e)=>t[e],Ps=({values:t},e)=>t[e],Rs=(t,e)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[n];return Ws.visit(i,t.valueOffsets[e])},js=(t,e)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[n];return Ws.visit(i,e)},$s=({values:t},e)=>t.subarray(2*e,2*(e+1)),zs=({values:t},e)=>{const n=t[e],i=new Int32Array(2);return i[0]=Math.trunc(n/12),i[1]=Math.trunc(n%12),i},Hs=({values:t},e)=>t[e],qs=({values:t},e)=>t[e],Ys=({values:t},e)=>t[e],Gs=({values:t},e)=>t[e];Ss.prototype.visitNull=Is(((t,e)=>null)),Ss.prototype.visitBool=Is((({offset:t,values:e},n)=>{const i=t+n;return!!(e[i>>3]&1<t[e])),Ss.prototype.visitInt8=Is(Es),Ss.prototype.visitInt16=Is(Es),Ss.prototype.visitInt32=Is(Es),Ss.prototype.visitInt64=Is(Ns),Ss.prototype.visitUint8=Is(Es),Ss.prototype.visitUint16=Is(Es),Ss.prototype.visitUint32=Is(Es),Ss.prototype.visitUint64=Is(Ns),Ss.prototype.visitFloat=Is((({type:t,values:e},n)=>t.precision!==ii.HALF?e[n]:Vr(e[n]))),Ss.prototype.visitFloat16=Is((({stride:t,values:e},n)=>Vr(e[t*n]))),Ss.prototype.visitFloat32=Is(Es),Ss.prototype.visitFloat64=Is(Es),Ss.prototype.visitUtf8=Is((({values:t,valueOffsets:e},n)=>{const i=ks(t,e,n);return null!==i?Mn(i):null})),Ss.prototype.visitBinary=Is((({values:t,valueOffsets:e},n)=>ks(t,e,n))),Ss.prototype.visitFixedSizeBinary=Is((({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)))),Ss.prototype.visitDate=Is(((t,e)=>t.type.unit===ri.DAY?Cs(t,e):Ms(t,e))),Ss.prototype.visitDateDay=Is(Cs),Ss.prototype.visitDateMillisecond=Is(Ms),Ss.prototype.visitTimestamp=Is(((t,e)=>{switch(t.type.unit){case si.SECOND:return Ds(t,e);case si.MILLISECOND:return Os(t,e);case si.MICROSECOND:return Bs(t,e);case si.NANOSECOND:return Ls(t,e)}})),Ss.prototype.visitTimestampSecond=Is(Ds),Ss.prototype.visitTimestampMillisecond=Is(Os),Ss.prototype.visitTimestampMicrosecond=Is(Bs),Ss.prototype.visitTimestampNanosecond=Is(Ls),Ss.prototype.visitTime=Is(((t,e)=>{switch(t.type.unit){case si.SECOND:return Fs(t,e);case si.MILLISECOND:return Vs(t,e);case si.MICROSECOND:return Us(t,e);case si.NANOSECOND:return Ps(t,e)}})),Ss.prototype.visitTimeSecond=Is(Fs),Ss.prototype.visitTimeMillisecond=Is(Vs),Ss.prototype.visitTimeMicrosecond=Is(Us),Ss.prototype.visitTimeNanosecond=Is(Ps),Ss.prototype.visitDecimal=Is((({values:t,stride:e},n)=>xi.decimal(t.subarray(e*n,e*(n+1))))),Ss.prototype.visitList=Is(((t,e)=>{const{valueOffsets:n,stride:i,children:r}=t,{[e*i]:s,[e*i+1]:a}=n,o=r[0].slice(s,a-s);return new $a([o])})),Ss.prototype.visitStruct=Is(((t,e)=>new _s(t,e))),Ss.prototype.visitUnion=Is(((t,e)=>t.type.mode===ni.Dense?Rs(t,e):js(t,e))),Ss.prototype.visitDenseUnion=Is(Rs),Ss.prototype.visitSparseUnion=Is(js),Ss.prototype.visitDictionary=Is(((t,e)=>{var n;return null===(n=t.dictionary)||void 0===n?void 0:n.get(t.values[e])})),Ss.prototype.visitInterval=Is(((t,e)=>t.type.unit===ai.DAY_TIME?$s(t,e):zs(t,e))),Ss.prototype.visitIntervalDayTime=Is($s),Ss.prototype.visitIntervalYearMonth=Is(zs),Ss.prototype.visitDuration=Is(((t,e)=>{switch(t.type.unit){case si.SECOND:return Hs(t,e);case si.MILLISECOND:return qs(t,e);case si.MICROSECOND:return Ys(t,e);case si.NANOSECOND:return Gs(t,e)}})),Ss.prototype.visitDurationSecond=Is(Hs),Ss.prototype.visitDurationMillisecond=Is(qs),Ss.prototype.visitDurationMicrosecond=Is(Ys),Ss.prototype.visitDurationNanosecond=Is(Gs),Ss.prototype.visitFixedSizeList=Is(((t,e)=>{const{stride:n,children:i}=t,r=i[0].slice(e*n,n);return new $a([r])})),Ss.prototype.visitMap=Is(((t,e)=>{const{valueOffsets:n,children:i}=t,{[e]:r,[e+1]:s}=n,a=i[0];return new Js(a.slice(r,s-r))}));const Ws=new Ss,Ks=Symbol.for("keys"),Qs=Symbol.for("vals");class Js{constructor(t){return this[Ks]=new $a([t.children[0]]).memoize(),this[Qs]=t.children[1],new Proxy(this,new Xs)}[Symbol.iterator](){return new Zs(this[Ks],this[Qs])}get size(){return this[Ks].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Ks],e=this[Qs],n={};for(let i=-1,r=t.length;++i`${hi(t)}: ${hi(e)}`)).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Zs{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Ws.visit(this.vals,t)]})}}class Xs{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Ks].toArray().map(String)}has(t,e){return t[Ks].includes(e)}getOwnPropertyDescriptor(t,e){if(-1!==t[Ks].indexOf(e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const n=t[Ks].indexOf(e);if(-1!==n){const i=Ws.visit(Reflect.get(t,Qs),n);return Reflect.set(t,e,i),i}}set(t,e,n){const i=t[Ks].indexOf(e);return-1!==i?(gs.visit(Reflect.get(t,Qs),i,n),Reflect.set(t,e,n)):!!Reflect.has(t,e)&&Reflect.set(t,e,n)}}let ta;function ea(t,e,n,i){const{length:r=0}=t;let s="number"!=typeof e?0:e,a="number"!=typeof n?r:n;return s<0&&(s=(s%r+r)%r),a<0&&(a=(a%r+r)%r),ar&&(a=r),i?i(t,s,a):[s,a]}Object.defineProperties(Js.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Ks]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Qs]:{writable:!0,enumerable:!1,configurable:!1,value:null}});const na=t=>t!=t;function ia(t){if("object"!==typeof t||null===t)return na(t)?na:e=>e===t;if(t instanceof Date){const e=t.valueOf();return t=>t instanceof Date&&t.valueOf()===e}return ArrayBuffer.isView(t)?e=>!!e&&function(t,e){let n=0;const i=t.length;if(i!==e.length)return!1;if(i>0)do{if(t[n]!==e[n])return!1}while(++n!1;const i=[];for(let e=-1,r=n.length;++e{if(!n||"object"!=typeof n)return!1;switch(n.constructor){case Array:return function(t,e){const n=t.length;if(e.length!==n)return!1;for(let i=-1;++i>i}function ca(t,e,n){const i=n.byteLength+7&-8;if(t>0||n.byteLength>3):ua(new la(n,t,e,null,aa)).subarray(0,i)),r}return n}function ua(t){const e=[];let n=0,i=0,r=0;for(const s of t)s&&(r|=1<0)&&(e[n++]=r);const s=new Uint8Array(e.length+7&-8);return s.set(e),s}class la{constructor(t,e,n,i,r){this.bytes=t,this.length=n,this.context=i,this.get=r,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,r=e+(e%8==0?0:8-e%8);return ha(t,e,r)+ha(t,i,n)+function(t,e,n){let i=0,r=Math.trunc(e);const s=new DataView(t.buffer,t.byteOffset,t.byteLength),a=void 0===n?t.byteLength:r+n;for(;a-r>=4;)i+=pa(s.getUint32(r)),r+=4;for(;a-r>=2;)i+=pa(s.getUint16(r)),r+=2;for(;a-r>=1;)i+=pa(s.getUint8(r)),r+=1;return i}(t,r>>3,i-r>>3)}function pa(t){let e=Math.trunc(t);return e-=e>>>1&1431655765,e=(858993459&e)+(e>>>2&858993459),16843009*(e+(e>>>4)&252645135)>>>24}class da{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(0!==this._nullCount){const{type:t}=this;return Hi.isSparseUnion(t)||Hi.isDenseUnion(t)?this.children.some((t=>t.nullable)):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:e,values:n,nullBitmap:i,typeIds:r}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),r&&(t+=r.byteLength),this.children.reduce(((t,e)=>t+e.byteLength),t)}get nullCount(){if(Hi.isUnion(this.type))return this.children.reduce(((t,e)=>t+e.nullCount),0);let t,e=this._nullCount;return e<=-1&&(t=this.nullBitmap)&&(this._nullCount=e=this.length-ha(t,this.offset,this.offset+this.length)),e}constructor(t,e,n,i,r,s=[],a){let o;this.type=t,this.children=s,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1)),r instanceof da?(this.stride=r.stride,this.values=r.values,this.typeIds=r.typeIds,this.nullBitmap=r.nullBitmap,this.valueOffsets=r.valueOffsets):(this.stride=Nr(t),r&&((o=r[0])&&(this.valueOffsets=o),(o=r[1])&&(this.values=o),(o=r[2])&&(this.nullBitmap=o),(o=r[3])&&(this.typeIds=o)))}getValid(t){const{type:e}=this;if(Hi.isUnion(e)){const n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],r=n.mode===ni.Dense?this.valueOffsets[t]:t;return i.getValid(r)}if(this.nullable&&this.nullCount>0){const e=this.offset+t;return!!(this.nullBitmap[e>>3]&1<>3;(!i||i.byteLength<=c)&&(i=new Uint8Array((r+s+63&-64)>>3).fill(255),this.nullCount>0&&i.set(ca(r,s,this.nullBitmap),0),Object.assign(this,{nullBitmap:i,_nullCount:-1}));const u=i[c];n=!!(u&o),i[c]=e?u|o:u&~o}return n!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,n=this.length,i=this._nullCount,r=this,s=this.children){return new da(t,e,n,i,r,s,this.dictionary)}slice(t,e){const{stride:n,typeId:i,children:r}=this,s=+(0===this._nullCount)-1,a=16===i?n:1,o=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,s,o,0===r.length||this.valueOffsets?r:this._sliceChildren(r,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===ci.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:n}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<0&&i.set(ca(this.offset,e,this.nullBitmap),0);const r=this.buffers;return r[ui.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),r)}_sliceBuffers(t,e,n,i){let r;const{buffers:s}=this;return(r=s[ui.TYPE])&&(s[ui.TYPE]=r.subarray(t,t+e)),(r=s[ui.OFFSET])&&(s[ui.OFFSET]=r.subarray(t,t+e+1))||(r=s[ui.DATA])&&(s[ui.DATA]=6===i?r:r.subarray(n*t,n*(t+e))),s}_sliceChildren(t,e,n){return t.map((t=>t.slice(e,n)))}}da.prototype.children=Object.freeze([]);class fa extends Dr{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{type:e,offset:n=0,length:i=0}=t;return new da(e,n,i,i)}visitBool(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.ArrayType,t.data),{length:s=r.length>>3,nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,r,i])}visitInt(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.ArrayType,t.data),{length:s=r.length,nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,r,i])}visitFloat(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.ArrayType,t.data),{length:s=r.length,nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,r,i])}visitUtf8(t){const{type:e,offset:n=0}=t,i=qn(t.data),r=qn(t.nullBitmap),s=Hn(t.valueOffsets),{length:a=s.length-1,nullCount:o=(t.nullBitmap?-1:0)}=t;return new da(e,n,a,o,[s,i,r])}visitBinary(t){const{type:e,offset:n=0}=t,i=qn(t.data),r=qn(t.nullBitmap),s=Hn(t.valueOffsets),{length:a=s.length-1,nullCount:o=(t.nullBitmap?-1:0)}=t;return new da(e,n,a,o,[s,i,r])}visitFixedSizeBinary(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.ArrayType,t.data),{length:s=r.length/Nr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,r,i])}visitDate(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.ArrayType,t.data),{length:s=r.length/Nr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,r,i])}visitTimestamp(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.ArrayType,t.data),{length:s=r.length/Nr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,r,i])}visitTime(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.ArrayType,t.data),{length:s=r.length/Nr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,r,i])}visitDecimal(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.ArrayType,t.data),{length:s=r.length/Nr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,r,i])}visitList(t){const{type:e,offset:n=0,child:i}=t,r=qn(t.nullBitmap),s=Hn(t.valueOffsets),{length:a=s.length-1,nullCount:o=(t.nullBitmap?-1:0)}=t;return new da(e,n,a,o,[s,void 0,r],[i])}visitStruct(t){const{type:e,offset:n=0,children:i=[]}=t,r=qn(t.nullBitmap),{length:s=i.reduce(((t,{length:e})=>Math.max(t,e)),0),nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,void 0,r],i)}visitUnion(t){const{type:e,offset:n=0,children:i=[]}=t,r=zn(e.ArrayType,t.typeIds),{length:s=r.length,nullCount:a=-1}=t;if(Hi.isSparseUnion(e))return new da(e,n,s,a,[void 0,void 0,void 0,r],i);const o=Hn(t.valueOffsets);return new da(e,n,s,a,[o,void 0,void 0,r],i)}visitDictionary(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.indices.ArrayType,t.data),{dictionary:s=new $a([(new fa).visit({type:e.dictionary})])}=t,{length:a=r.length,nullCount:o=(t.nullBitmap?-1:0)}=t;return new da(e,n,a,o,[void 0,r,i],[],s)}visitInterval(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.ArrayType,t.data),{length:s=r.length/Nr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,r,i])}visitDuration(t){const{type:e,offset:n=0}=t,i=qn(t.nullBitmap),r=zn(e.ArrayType,t.data),{length:s=r.length,nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,r,i])}visitFixedSizeList(t){const{type:e,offset:n=0,child:i=(new fa).visit({type:e.valueType})}=t,r=qn(t.nullBitmap),{length:s=i.length/Nr(e),nullCount:a=(t.nullBitmap?-1:0)}=t;return new da(e,n,s,a,[void 0,void 0,r],[i])}visitMap(t){const{type:e,offset:n=0,child:i=(new fa).visit({type:e.childType})}=t,r=qn(t.nullBitmap),s=Hn(t.valueOffsets),{length:a=s.length-1,nullCount:o=(t.nullBitmap?-1:0)}=t;return new da(e,n,a,o,[s,void 0,r],[i])}}const ma=new fa;function ya(t){return ma.visit(t)}class ga{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext+e.nullCount),0)}function va(t){return t.reduce(((t,e,n)=>(t[n+1]=t[n]+e.length,t)),new Uint32Array(t.length+1))}function _a(t,e,n,i){const r=[];for(let s=-1,a=t.length;++s=i)break;if(n>=o+c)continue;if(o>=n&&o+c<=i){r.push(a);continue}const u=Math.max(0,n-o),l=Math.min(i-o,c);r.push(a.slice(u,l-u))}return 0===r.length&&r.push(t[0].slice(0,0)),r}function xa(t,e,n,i){let r=0,s=0,a=e.length-1;do{if(r>=a-1)return n0?0:-1},Ta.prototype.visitBool=ka,Ta.prototype.visitInt=ka,Ta.prototype.visitInt8=ka,Ta.prototype.visitInt16=ka,Ta.prototype.visitInt32=ka,Ta.prototype.visitInt64=ka,Ta.prototype.visitUint8=ka,Ta.prototype.visitUint16=ka,Ta.prototype.visitUint32=ka,Ta.prototype.visitUint64=ka,Ta.prototype.visitFloat=ka,Ta.prototype.visitFloat16=ka,Ta.prototype.visitFloat32=ka,Ta.prototype.visitFloat64=ka,Ta.prototype.visitUtf8=ka,Ta.prototype.visitBinary=ka,Ta.prototype.visitFixedSizeBinary=ka,Ta.prototype.visitDate=ka,Ta.prototype.visitDateDay=ka,Ta.prototype.visitDateMillisecond=ka,Ta.prototype.visitTimestamp=ka,Ta.prototype.visitTimestampSecond=ka,Ta.prototype.visitTimestampMillisecond=ka,Ta.prototype.visitTimestampMicrosecond=ka,Ta.prototype.visitTimestampNanosecond=ka,Ta.prototype.visitTime=ka,Ta.prototype.visitTimeSecond=ka,Ta.prototype.visitTimeMillisecond=ka,Ta.prototype.visitTimeMicrosecond=ka,Ta.prototype.visitTimeNanosecond=ka,Ta.prototype.visitDecimal=ka,Ta.prototype.visitList=ka,Ta.prototype.visitStruct=ka,Ta.prototype.visitUnion=ka,Ta.prototype.visitDenseUnion=Ca,Ta.prototype.visitSparseUnion=Ca,Ta.prototype.visitDictionary=ka,Ta.prototype.visitInterval=ka,Ta.prototype.visitIntervalDayTime=ka,Ta.prototype.visitIntervalYearMonth=ka,Ta.prototype.visitDuration=ka,Ta.prototype.visitDurationSecond=ka,Ta.prototype.visitDurationMillisecond=ka,Ta.prototype.visitDurationMicrosecond=ka,Ta.prototype.visitDurationNanosecond=ka,Ta.prototype.visitFixedSizeList=ka,Ta.prototype.visitMap=ka;const Ma=new Ta;class Ea extends Dr{}function Na(t){const{type:e}=t;if(0===t.nullCount&&1===t.stride&&(e.typeId===ci.Timestamp||e instanceof Yi&&64!==e.bitWidth||e instanceof pr&&64!==e.bitWidth||e instanceof er&&e.precision!==ii.HALF))return new ga(t.data.length,(e=>{const n=t.data[e];return n.values.subarray(0,n.length)[Symbol.iterator]()}));let n=0;return new ga(t.data.length,(e=>{const i=t.data[e].length,r=t.slice(n,n+i);return n+=i,new Da(r)}))}class Da{constructor(t){this.vector=t,this.index=0}next(){return this.indext+e;class La extends Dr{visitNull(t,e){return 0}visitInt(t,e){return t.type.bitWidth/8}visitFloat(t,e){return t.type.ArrayType.BYTES_PER_ELEMENT}visitBool(t,e){return 1/8}visitDecimal(t,e){return t.type.bitWidth/8}visitDate(t,e){return 4*(t.type.unit+1)}visitTime(t,e){return t.type.bitWidth/8}visitTimestamp(t,e){return t.type.unit===si.SECOND?4:8}visitInterval(t,e){return 4*(t.type.unit+1)}visitDuration(t,e){return 8}visitStruct(t,e){return t.children.reduce(((t,n)=>t+Ua.visit(n,e)),0)}visitFixedSizeBinary(t,e){return t.type.byteWidth}visitMap(t,e){return 8+t.children.reduce(((t,n)=>t+Ua.visit(n,e)),0)}visitDictionary(t,e){var n;return t.type.indices.bitWidth/8+((null===(n=t.dictionary)||void 0===n?void 0:n.getByteLength(t.values[e]))||0)}}const Fa=({type:t,children:e,typeIds:n,valueOffsets:i},r)=>{const s=t.typeIdToChildIndex[n[r]];return 8+Ua.visit(e[s],i[r])},Va=({children:t},e)=>4+Ua.visitMany(t,t.map((()=>e))).reduce(Ba,0);La.prototype.visitUtf8=({valueOffsets:t},e)=>t[e+1]-t[e]+8,La.prototype.visitBinary=({valueOffsets:t},e)=>t[e+1]-t[e]+8,La.prototype.visitList=({valueOffsets:t,stride:e,children:n},i)=>{const r=n[0],{[i*e]:s}=t,{[i*e+1]:a}=t,o=Ua.getVisitFn(r.type),c=r.slice(s,a-s);let u=8;for(let t=-1,e=a-s;++t{const i=e[0],r=i.slice(n*t,t),s=Ua.getVisitFn(i.type);let a=0;for(let t=-1,e=r.length;++tt.type.mode===ni.Dense?Fa(t,e):Va(t,e),La.prototype.visitDenseUnion=Fa,La.prototype.visitSparseUnion=Va;const Ua=new La;var Pa;const Ra={},ja={};class $a{constructor(t){var e,n,i;const r=t[0]instanceof $a?t.flatMap((t=>t.data)):t;if(0===r.length||r.some((t=>!(t instanceof da))))throw new TypeError("Vector constructor expects an Array of Data instances.");const s=null===(e=r[0])||void 0===e?void 0:e.type;switch(r.length){case 0:this._offsets=[0];break;case 1:{const{get:t,set:e,indexOf:n,byteLength:i}=Ra[s.typeId],a=r[0];this.isValid=t=>wa(a,t),this.get=e=>t(a,e),this.set=(t,n)=>e(a,t,n),this.indexOf=t=>n(a,t),this.getByteLength=t=>i(a,t),this._offsets=[0,a.length];break}default:Object.setPrototypeOf(this,ja[s.typeId]),this._offsets=va(r)}this.data=r,this.type=s,this.stride=Nr(s),this.numChildren=null!==(i=null===(n=s.children)||void 0===n?void 0:n.length)&&void 0!==i?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce(((t,e)=>t+e.byteLength),0)}get nullCount(){return ba(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${ci[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}getByteLength(t){return 0}[Symbol.iterator](){return Oa.visit(this)}concat(...t){return new $a(this.data.concat(t.flatMap((t=>t.data)).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new $a(ea(this,t,e,(({data:t,_offsets:e},n,i)=>_a(t,e,n,i))))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:n,stride:i,ArrayType:r}=this;switch(t.typeId){case ci.Int:case ci.Float:case ci.Decimal:case ci.Time:case ci.Timestamp:switch(e.length){case 0:return new r;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce(((t,{values:e,length:n})=>(t.array.set(e.subarray(0,n*i),t.offset),t.offset+=n*i,t)),{array:new r(n*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt(null===(e=this.type.children)||void 0===e?void 0:e.findIndex((e=>e.name===t)))}getChildAt(t){return t>-1&&te[t]))):null}get isMemoized(){return!!Hi.isDictionary(this.type)&&this.data[0].dictionary.isMemoized}memoize(){if(Hi.isDictionary(this.type)){const t=new za(this.data[0].dictionary),e=this.data.map((e=>{const n=e.clone();return n.dictionary=t,n}));return new $a(e)}return new za(this)}unmemoize(){if(Hi.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map((e=>{const n=e.clone();return n.dictionary=t,n}));return new $a(e)}return this}}Pa=Symbol.toStringTag,$a[Pa]=(t=>{t.type=Hi.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;const e=Object.keys(ci).map((t=>ci[t])).filter((t=>"number"==typeof t&&t!==ci.NONE));for(const n of e){const e=Ws.getVisitFnByTypeId(n),i=gs.getVisitFnByTypeId(n),r=Ma.getVisitFnByTypeId(n),s=Ua.getVisitFnByTypeId(n);Ra[n]={get:e,set:i,indexOf:r,byteLength:s},ja[n]=Object.create(t,{isValid:{value:Sa(wa)},get:{value:Sa(Ws.getVisitFnByTypeId(n))},set:{value:Ia(gs.getVisitFnByTypeId(n))},indexOf:{value:Aa(Ma.getVisitFnByTypeId(n))},getByteLength:{value:Sa(Ua.getVisitFnByTypeId(n))}})}return"Vector"})($a.prototype);class za extends $a{constructor(t){super(t.data);const e=this.get,n=this.set,i=this.slice,r=new Array(this.length);Object.defineProperty(this,"get",{value(t){const n=r[t];if(void 0!==n)return n;const i=e.call(this,t);return r[t]=i,i}}),Object.defineProperty(this,"set",{value(t,e){n.call(this,t,e),r[t]=e}}),Object.defineProperty(this,"slice",{value:(t,e)=>new za(i.call(this,t,e))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new $a(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}function Ha(t){if(!t||t.length<=0)return function(t){return!0};let e="";const n=t.filter((t=>t==t));return n.length>0&&(e=`\n switch (x) {${n.map((t=>`\n case ${function(t){if("bigint"!=typeof t)return hi(t);return`${hi(t)}n`}(t)}:`)).join("")}\n return false;\n }`),t.length!==n.length&&(e=`if (x !== x) return false;\n${e}`),new Function("x",`${e}\nreturn true;`)}const qa=(t,e)=>(Math.ceil(t)*e+63&-64||64)/e;class Ya{constructor(t,e=1){this.buffer=t,this.stride=e,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t.constructor,this._resize(this.length=Math.ceil(t.length/e))}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;const e=this.stride,n=this.length*e,i=this.buffer.length;n>=i&&this._resize(qa(0===i?1*n:2*n,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=qa(t*this.stride,this.BYTES_PER_ELEMENT);const e=((t,e=0)=>t.length>=e?t.subarray(0,e):jn(new t.constructor(e),t,0))(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this._resize(0),this}_resize(t){return this.buffer=jn(new this.ArrayType(t),this.buffer)}}Ya.prototype.offset=0;class Ga extends Ya{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}}class Wa extends Ga{constructor(t=new Uint8Array(0)){super(t,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){const{buffer:n}=this.reserve(t-this.length+1),i=t>>3,r=t%8,s=n[i]>>r&1;return e?0===s&&(n[i]|=1<this.length&&this.set(t-1,0),super.flush(t+1)}}let Qa=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=Nr(t),this._nulls=new Wa,e&&e.length>0&&(this._isValid=Ha(e))}toVector(){return new $a([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0;const{_offsets:e,_values:n,_nulls:i,_typeIds:r,children:s}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),r&&(t+=r.byteLength),s.reduce(((t,e)=>t+e.byteLength),t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce(((t,e)=>t+e.reservedByteLength),t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,i;const{type:r,length:s,nullCount:a,_typeIds:o,_offsets:c,_values:u,_nulls:l}=this;(e=null==o?void 0:o.flush(s))?i=null==c?void 0:c.flush(s):t=(i=null==c?void 0:c.flush(s))?null==u?void 0:u.flush(c.last()):null==u?void 0:u.flush(s),a>0&&(n=null==l?void 0:l.flush(s));const h=this.children.map((t=>t.flush()));return this.clear(),ya({type:r,length:s,nullCount:a,children:h,child:h[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:i})}finish(){this.finished=!0;for(const t of this.children)t.finish();return this}clear(){var t,e,n,i;this.length=0,null===(t=this._nulls)||void 0===t||t.clear(),null===(e=this._values)||void 0===e||e.clear(),null===(n=this._offsets)||void 0===n||n.clear(),null===(i=this._typeIds)||void 0===i||i.clear();for(const t of this.children)t.clear();return this}};Qa.prototype.length=1,Qa.prototype.stride=1,Qa.prototype.children=null,Qa.prototype.finished=!1,Qa.prototype.nullValues=null,Qa.prototype._isValid=()=>!0;class Ja extends Qa{constructor(t){super(t),this._values=new Ga(new this.ArrayType(0),this.stride)}setValue(t,e){const n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}}class Za extends Qa{constructor(t){super(t),this._pendingLength=0,this._offsets=new Ka}setValue(t,e){const n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e instanceof Js?e[Ks].length:e.length,n.set(t,e)}setValid(t,e){return!!super.setValid(t,e)||((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){const t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}}class Xa{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,n,i){return t.prep(8,24),t.writeInt64(BigInt(null!=i?i:0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(null!=e?e:0)),t.offset()}}const to=new Int32Array(2),eo=new Float32Array(to.buffer),no=new Float64Array(to.buffer),io=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];var ro;!function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(ro||(ro={}));let so=class t{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(e){return new t(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){eo[0]=e,this.writeInt32(t,to[0])}writeFloat64(t,e){no[0]=e,this.writeInt32(t,to[io?0:1]),this.writeInt32(t+4,to[io?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=e);const i=1+~(this.bb.capacity()-this.space+n)&e-1;for(;this.space=0&&0==this.vtable[e];e--);const n=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const i=2*(n+2);this.addInt16(i);let r=0;const s=this.space;t:for(e=0;e=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(e=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return Lo.startUnion(t),Lo.addMode(t,e),Lo.addTypeIds(t,n),Lo.endUnion(t)}}class Fo{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new Fo).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new Fo).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Fo.startUtf8(t),Fo.endUtf8(t)}}!function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList",t[t.RunEndEncoded=22]="RunEndEncoded"}(Bo||(Bo={}));let Vo=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Bo.NONE}type(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){const e=this.bb.__offset(this.bb_pos,12);return e?(t||new fo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(e,n){const i=this.bb.__offset(this.bb_pos,14);return i?(n||new t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*e),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,16);return n?(e||new oo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,Bo.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}},Uo=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):uo.Little}fields(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Vo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new oo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,uo.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(e,n,i,r,s){return t.startSchema(e),t.addEndianness(e,n),t.addFields(e,i),t.addCustomMetadata(e,r),t.addFeatures(e,s),t.endSchema(e)}};class Po{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new Po).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new Po).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):co.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Uo).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new Xa).__init(this.bb.__vector(this.bb_pos+n)+24*t,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){const n=this.bb.__offset(this.bb_pos,10);return n?(e||new Xa).__init(this.bb.__vector(this.bb_pos+n)+24*t,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new oo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,co.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}}class Ro{constructor(t=[],e,n,i=ei.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=zo(t)),this.dictionaries=n,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map((t=>t.name))}toString(){return`Schema<{ ${this.fields.map(((t,e)=>`${e}: ${t}`)).join(", ")} }>`}select(t){const e=new Set(t),n=this.fields.filter((t=>e.has(t.name)));return new Ro(n,this.metadata)}selectAt(t){const e=t.map((t=>this.fields[t])).filter(Boolean);return new Ro(e,this.metadata)}assign(...t){const e=t[0]instanceof Ro?t[0]:Array.isArray(t[0])?new Ro(t[0]):new Ro(t),n=[...this.fields],i=$o($o(new Map,this.metadata),e.metadata),r=e.fields.filter((t=>{const e=n.findIndex((e=>e.name===t.name));return!~e||(n[e]=t.clone({metadata:$o($o(new Map,n[e].metadata),t.metadata)}))&&!1})),s=zo(r,new Map);return new Ro([...n,...r],i,new Map([...this.dictionaries,...s]))}}Ro.prototype.fields=null,Ro.prototype.metadata=null,Ro.prototype.dictionaries=null;class jo{static new(...t){let[e,n,i,r]=t;return t[0]&&"object"==typeof t[0]&&(({name:e}=t[0]),void 0===n&&(n=t[0].type),void 0===i&&(i=t[0].nullable),void 0===r&&(r=t[0].metadata)),new jo(`${e}`,n,i,r)}constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,i,r]=t;return t[0]&&"object"==typeof t[0]?({name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:r=this.metadata}=t[0]):[e=this.name,n=this.type,i=this.nullable,r=this.metadata]=t,jo.new(e,n,i,r)}}function $o(t,e){return new Map([...t||new Map,...e||new Map])}function zo(t,e=new Map){for(let n=-1,i=t.length;++n0&&zo(i.children,e)}return e}jo.prototype.type=null,jo.prototype.name=null,jo.prototype.nullable=null,jo.prototype.metadata=null;var Ho=ao,qo=so;class Yo{static decode(t){t=new qo(qn(t));const e=Po.getRootAsFooter(t),n=Ro.decode(e.schema(),new Map,e.version());return new Go(n,e)}static encode(t){const e=new Ho,n=Ro.encode(e,t.schema);Po.startRecordBatchesVector(e,t.numRecordBatches);for(const n of[...t.recordBatches()].slice().reverse())Wo.encode(e,n);const i=e.endVector();Po.startDictionariesVector(e,t.numDictionaries);for(const n of[...t.dictionaryBatches()].slice().reverse())Wo.encode(e,n);const r=e.endVector();return Po.startFooter(e),Po.addSchema(e,n),Po.addVersion(e,ei.V5),Po.addRecordBatches(e,i),Po.addDictionaries(e,r),Po.finishFooterBuffer(e,Po.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=ei.V5,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e=0&&t=0&&t=0&&t=0&&tthis._closedPromiseResolve=t))}get closed(){return this._closedPromise}cancel(t){return wn(this,void 0,void 0,(function*(){yield this.return(t)}))}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Ko);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Jn.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Jn.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return wn(this,void 0,void 0,(function*(){return yield this.abort(t),Ko}))}return(t){return wn(this,void 0,void 0,(function*(){return yield this.close(),Ko}))}read(t){return wn(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return wn(this,void 0,void 0,(function*(){return(yield this.next(t,"peek")).value}))}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise(((t,e)=>{this.resolvers.push({resolve:t,reject:e})})):Promise.resolve(Ko)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Zo extends Jo{write(t){if((t=qn(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Mn(this.toUint8Array(!0)):this.toUint8Array(!1).then(Mn)}toUint8Array(t=!1){return t?$n(this._values)[0]:(()=>wn(this,void 0,void 0,(function*(){var t,e,n,i;const r=[];let s=0;try{for(var a,o=!0,c=kn(this);!(t=(a=yield c.next()).done);o=!0){i=a.value,o=!1;const t=i;r.push(t),s+=t.byteLength}}catch(t){e={error:t}}finally{try{o||t||!(n=c.return)||(yield n.call(c))}finally{if(e)throw e.error}}return $n(r,s)[0]})))()}}class Xo extends Za{constructor(t){super(t),this._values=new Ya(new Uint8Array(0))}get byteLength(){let t=this._pendingLength+4*this.length;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,qn(e))}_flushPending(t,e){const n=this._offsets,i=this._values.reserve(e).buffer;let r=0;for(const[e,s]of t)if(void 0===s)n.set(e,0);else{const t=s.length;i.set(s,r),n.set(e,t),r+=t}}}class tc extends Qa{constructor(t){super(t),this._values=new Wa}setValue(t,e){this._values.set(t,+e)}}class ec extends Ja{}ec.prototype._setValue=Kr;class nc extends ec{}nc.prototype._setValue=Yr;class ic extends ec{}ic.prototype._setValue=Gr;class rc extends Ja{}rc.prototype._setValue=as;class sc extends Qa{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Er(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=ou({type:this.type.indices,nullValues:e}),this.dictionary=ou({type:this.type.dictionary,nullValues:null}),"function"==typeof n&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){const n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){const n=this._keysToIndices,i=this.valueToKey(e);let r=n[i];return void 0===r&&(n[i]=r=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,r)}flush(){const t=this.type,e=this._dictionary,n=this.dictionary.toVector(),i=this.indices.flush().clone(t);return i.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return"string"==typeof t?t:`${t}`}}class ac extends Ja{}ac.prototype._setValue=Wr;class oc extends Qa{setValue(t,e){const[n]=this.children,i=t*this.stride;for(let t=-1,r=e.length;++t0)throw new Error("FixedSizeListBuilder can only have one child.");const n=this.children.push(t);return this.type=new Tr(this.type.listSize,new jo(e,t.type,!0)),n}}class cc extends Ja{setValue(t,e){this._values.set(t,e)}}class uc extends cc{setValue(t,e){super.setValue(t,Ur(e))}}class lc extends cc{}class hc extends cc{}class pc extends Ja{}pc.prototype._setValue=us;class dc extends pc{}dc.prototype._setValue=ls;class fc extends pc{}fc.prototype._setValue=hs;class mc extends Ja{}mc.prototype._setValue=ys;class yc extends mc{}yc.prototype._setValue=ps;class gc extends mc{}gc.prototype._setValue=ds;class bc extends mc{}bc.prototype._setValue=fs;class vc extends mc{}vc.prototype._setValue=ms;class _c extends Ja{setValue(t,e){this._values.set(t,e)}}class xc extends _c{}class wc extends _c{}class Sc extends _c{}class Ic extends _c{}class Ac extends _c{}class Tc extends _c{}class kc extends _c{}class Cc extends _c{}class Mc extends Za{constructor(t){super(t),this._offsets=new Ka}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new wr(new jo(e,t.type,!0)),this.numChildren-1}_flushPending(t){const e=this._offsets,[n]=this.children;for(const[i,r]of t)if(void 0===r)e.set(i,0);else{const t=r,s=t.length,a=e.set(i,s).buffer[i];for(let e=-1;++e0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new kr(new jo(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){const e=this._offsets,[n]=this.children;for(const[i,r]of t)if(void 0===r)e.set(i,0);else{let{[i]:t,[i+1]:s}=e.set(i,r.size).buffer;for(const e of r.entries())if(n.set(t,e),++t>=s)break}}}class Nc extends Qa{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}}class Dc extends Qa{setValue(t,e){const{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach(((i,r)=>n[r].set(t,e[r])));case Map:return i.children.forEach(((i,r)=>n[r].set(t,e.get(i.name))));default:return i.children.forEach(((i,r)=>n[r].set(t,e[i.name])))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach((n=>n.setValid(t,e))),e}addChild(t,e=`${this.numChildren}`){const n=this.children.push(t);return this.type=new Sr([...this.type.children,new jo(e,t.type,!0)]),n}}class Oc extends Ja{}Oc.prototype._setValue=ts;class Bc extends Oc{}Bc.prototype._setValue=Qr;class Lc extends Oc{}Lc.prototype._setValue=Jr;class Fc extends Oc{}Fc.prototype._setValue=Zr;class Vc extends Oc{}Vc.prototype._setValue=Xr;class Uc extends Ja{}Uc.prototype._setValue=ss;class Pc extends Uc{}Pc.prototype._setValue=es;class Rc extends Uc{}Rc.prototype._setValue=ns;class jc extends Uc{}jc.prototype._setValue=is;class $c extends Uc{}$c.prototype._setValue=rs;class zc extends Qa{constructor(t){super(t),this._typeIds=new Ga(new Int8Array(0),1),"function"==typeof t.valueToChildTypeId&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return void 0===n&&(n=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);const i=this.type.typeIdToChildIndex[n],r=this.children[i];null==r||r.set(t,e)}addChild(t,e=`${this.children.length}`){const n=this.children.push(t),{type:{children:i,mode:r,typeIds:s}}=this,a=[...i,new jo(e,t.type)];return this.type=new Ir(r,[...s,n],a),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}}class Hc extends zc{}class qc extends zc{constructor(t){super(t),this._offsets=new Ga(new Int32Array(0))}setValue(t,e,n){const i=this._typeIds.set(t,n).buffer[t],r=this.getChildAt(this.type.typeIdToChildIndex[i]),s=this._offsets.set(t,r.length).buffer[t];null==r||r.set(s,e)}}class Yc extends Za{constructor(t){super(t),this._values=new Ya(new Uint8Array(0))}get byteLength(){let t=this._pendingLength+4*this.length;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Nn(e))}_flushPending(t,e){}}Yc.prototype._flushPending=Xo.prototype._flushPending;const Gc=new class extends Dr{visitNull(){return Nc}visitBool(){return tc}visitInt(){return _c}visitInt8(){return xc}visitInt16(){return wc}visitInt32(){return Sc}visitInt64(){return Ic}visitUint8(){return Ac}visitUint16(){return Tc}visitUint32(){return kc}visitUint64(){return Cc}visitFloat(){return cc}visitFloat16(){return uc}visitFloat32(){return lc}visitFloat64(){return hc}visitUtf8(){return Yc}visitBinary(){return Xo}visitFixedSizeBinary(){return ac}visitDate(){return ec}visitDateDay(){return nc}visitDateMillisecond(){return ic}visitTimestamp(){return Oc}visitTimestampSecond(){return Bc}visitTimestampMillisecond(){return Lc}visitTimestampMicrosecond(){return Fc}visitTimestampNanosecond(){return Vc}visitTime(){return Uc}visitTimeSecond(){return Pc}visitTimeMillisecond(){return Rc}visitTimeMicrosecond(){return jc}visitTimeNanosecond(){return $c}visitDecimal(){return rc}visitList(){return Mc}visitStruct(){return Dc}visitUnion(){return zc}visitDenseUnion(){return qc}visitSparseUnion(){return Hc}visitDictionary(){return sc}visitInterval(){return pc}visitIntervalDayTime(){return dc}visitIntervalYearMonth(){return fc}visitDuration(){return mc}visitDurationSecond(){return yc}visitDurationMillisecond(){return gc}visitDurationMicrosecond(){return bc}visistDurationNanosecond(){return vc}visitFixedSizeList(){return oc}visitMap(){return Ec}};class Wc extends Dr{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every(((t,n)=>this.compareFields(t,e[n])))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}}function Kc(t,e){return e instanceof t.constructor}function Qc(t,e){return t===e||Kc(t,e)}function Jc(t,e){return t===e||Kc(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function Zc(t,e){return t===e||Kc(t,e)&&t.precision===e.precision}function Xc(t,e){return t===e||Kc(t,e)&&t.unit===e.unit}function tu(t,e){return t===e||Kc(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function eu(t,e){return t===e||Kc(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function nu(t,e){return t===e||Kc(t,e)&&t.mode===e.mode&&t.typeIds.every(((t,n)=>t===e.typeIds[n]))&&su.compareManyFields(t.children,e.children)}function iu(t,e){return t===e||Kc(t,e)&&t.unit===e.unit}function ru(t,e){return t===e||Kc(t,e)&&t.unit===e.unit}Wc.prototype.visitNull=Qc,Wc.prototype.visitBool=Qc,Wc.prototype.visitInt=Jc,Wc.prototype.visitInt8=Jc,Wc.prototype.visitInt16=Jc,Wc.prototype.visitInt32=Jc,Wc.prototype.visitInt64=Jc,Wc.prototype.visitUint8=Jc,Wc.prototype.visitUint16=Jc,Wc.prototype.visitUint32=Jc,Wc.prototype.visitUint64=Jc,Wc.prototype.visitFloat=Zc,Wc.prototype.visitFloat16=Zc,Wc.prototype.visitFloat32=Zc,Wc.prototype.visitFloat64=Zc,Wc.prototype.visitUtf8=Qc,Wc.prototype.visitBinary=Qc,Wc.prototype.visitFixedSizeBinary=function(t,e){return t===e||Kc(t,e)&&t.byteWidth===e.byteWidth},Wc.prototype.visitDate=Xc,Wc.prototype.visitDateDay=Xc,Wc.prototype.visitDateMillisecond=Xc,Wc.prototype.visitTimestamp=tu,Wc.prototype.visitTimestampSecond=tu,Wc.prototype.visitTimestampMillisecond=tu,Wc.prototype.visitTimestampMicrosecond=tu,Wc.prototype.visitTimestampNanosecond=tu,Wc.prototype.visitTime=eu,Wc.prototype.visitTimeSecond=eu,Wc.prototype.visitTimeMillisecond=eu,Wc.prototype.visitTimeMicrosecond=eu,Wc.prototype.visitTimeNanosecond=eu,Wc.prototype.visitDecimal=Qc,Wc.prototype.visitList=function(t,e){return t===e||Kc(t,e)&&t.children.length===e.children.length&&su.compareManyFields(t.children,e.children)},Wc.prototype.visitStruct=function(t,e){return t===e||Kc(t,e)&&t.children.length===e.children.length&&su.compareManyFields(t.children,e.children)},Wc.prototype.visitUnion=nu,Wc.prototype.visitDenseUnion=nu,Wc.prototype.visitSparseUnion=nu,Wc.prototype.visitDictionary=function(t,e){return t===e||Kc(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&su.visit(t.indices,e.indices)&&su.visit(t.dictionary,e.dictionary)},Wc.prototype.visitInterval=iu,Wc.prototype.visitIntervalDayTime=iu,Wc.prototype.visitIntervalYearMonth=iu,Wc.prototype.visitDuration=ru,Wc.prototype.visitDurationSecond=ru,Wc.prototype.visitDurationMillisecond=ru,Wc.prototype.visitDurationMicrosecond=ru,Wc.prototype.visitDurationNanosecond=ru,Wc.prototype.visitFixedSizeList=function(t,e){return t===e||Kc(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&su.compareManyFields(t.children,e.children)},Wc.prototype.visitMap=function(t,e){return t===e||Kc(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&su.compareManyFields(t.children,e.children)};const su=new Wc;function au(t,e){return su.compareSchemas(t,e)}function ou(t){const e=t.type,n=new(Gc.getVisitFn(e)())(t);if(e.children&&e.children.length>0){const i=t.children||[],r={nullValues:t.nullValues},s=Array.isArray(i)?(t,e)=>i[e]||r:({name:t})=>i[t]||r;for(const[t,i]of e.children.entries()){const{type:e}=i,r=s(i,t);n.children.push(ou(Object.assign(Object.assign({},r),{type:e})))}}return n}function cu(t,e){return function(t,e){const n=[...t.fields],i=[],r={numBatches:e.reduce(((t,e)=>Math.max(t,e.length)),0)};let s=0,a=0,o=-1;const c=e.length;let u,l=[];for(;r.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o0&&(i[s++]=ya({type:new Sr(n),length:a,nullCount:0,children:l.slice()})))}return[t=t.assign(n),i.map((e=>new du(t,e)))]}(t,e.map((t=>t.data.concat())))}function uu(t,e,n,i,r){var s;const a=(e+63&-64)>>3;for(let o=-1,c=i.length;++o=e)u===e?n[o]=c:(n[o]=c.slice(0,e),r.numBatches=Math.max(r.numBatches,i[o].unshift(c.slice(e,u-e))));else{const i=t[o];t[o]=i.clone({nullable:!0}),n[o]=null!==(s=null==c?void 0:c._changeLengthAndBackfillNullBitmap(e))&&void 0!==s?s:ya({type:i.type,length:e,nullCount:e,nullBitmap:new Uint8Array(a)})}}return n}var lu,hu;class pu{constructor(...t){var e,n;if(0===t.length)return this.batches=[],this.schema=new Ro([]),this._offsets=[0],this;let i,r;t[0]instanceof Ro&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(r=t.pop());const s=t=>{if(t){if(t instanceof du)return[t];if(t instanceof pu)return t.batches;if(t instanceof da){if(t.type instanceof Sr)return[new du(new Ro(t.type.children),t)]}else{if(Array.isArray(t))return t.flatMap((t=>s(t)));if("function"==typeof t[Symbol.iterator])return[...t].flatMap((t=>s(t)));if("object"==typeof t){const e=Object.keys(t),n=e.map((e=>new $a([t[e]]))),i=new Ro(e.map(((t,e)=>new jo(String(t),n[e].type)))),[,r]=cu(i,n);return 0===r.length?[new du(t)]:r}}}return[]},a=t.flatMap((t=>s(t)));if(i=null!==(n=null!=i?i:null===(e=a[0])||void 0===e?void 0:e.schema)&&void 0!==n?n:new Ro([]),!(i instanceof Ro))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const t of a){if(!(t instanceof du))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!au(i,t.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=null!=r?r:va(this.data)}get data(){return this.batches.map((({data:t})=>t))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce(((t,e)=>t+e.length),0)}get nullCount(){return-1===this._nullCount&&(this._nullCount=ba(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}getByteLength(t){return 0}[Symbol.iterator](){return this.batches.length>0?Oa.visit(new $a(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(",\n ")}\n]`}concat(...t){const e=this.schema,n=this.data.concat(t.flatMap((({data:t})=>t)));return new pu(e,n.map((t=>new du(e,t))))}slice(t,e){const n=this.schema;[t,e]=ea({length:this.numRows},t,e);const i=_a(this.data,this._offsets,t,e);return new pu(n,i.map((t=>new du(n,t))))}getChild(t){return this.getChildAt(this.schema.fields.findIndex((e=>e.name===t)))}getChildAt(t){if(t>-1&&te.children[t]));if(0===e.length){const{type:n}=this.schema.fields[t],i=ya({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new $a(e)}return null}setChild(t,e){var n;return this.setChildAt(null===(n=this.schema.fields)||void 0===n?void 0:n.findIndex((e=>e.name===t)),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&tthis.getChildAt(e)));[r[t],a[t]]=[s,e],[n,i]=cu(n,a)}return new pu(n,i)}select(t){const e=this.schema.fields.reduce(((t,e,n)=>t.set(e.name,n)),new Map);return this.selectAt(t.map((t=>e.get(t))).filter((t=>t>-1)))}selectAt(t){const e=this.schema.selectAt(t),n=this.batches.map((e=>e.selectAt(t)));return new pu(e,n)}assign(t){const e=this.schema.fields,[n,i]=t.schema.fields.reduce(((t,n,i)=>{const[r,s]=t,a=e.findIndex((t=>t.name===n.name));return~a?s[a]=i:r.push(i),t}),[[],[]]),r=this.schema.assign(t.schema),s=[...e.map(((t,e)=>[e,i[e]])).map((([e,n])=>void 0===n?this.getChildAt(e):t.getChildAt(n))),...n.map((e=>t.getChildAt(e)))].filter(Boolean);return new pu(...cu(r,s))}}lu=Symbol.toStringTag,pu[lu]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=Sa(wa),t.get=Sa(Ws.getVisitFn(ci.Struct)),t.set=Ia(gs.getVisitFn(ci.Struct)),t.indexOf=Aa(Ma.getVisitFn(ci.Struct)),t.getByteLength=Sa(Ua.getVisitFn(ci.Struct)),"Table"))(pu.prototype);let du=class t{constructor(...t){switch(t.length){case 2:if([this.schema]=t,!(this.schema instanceof Ro))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=ya({nullCount:0,type:new Sr(this.schema.fields),children:this.schema.fields.map((t=>ya({type:t.type,nullCount:0})))})]=t,!(this.data instanceof da))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=fu(this.schema,this.data.children);break;case 1:{const[e]=t,{fields:n,children:i,length:r}=Object.keys(e).reduce(((t,n,i)=>(t.children[i]=e[n],t.length=Math.max(t.length,e[n].length),t.fields[i]=jo.new({name:n,type:e[n].type,nullable:!0}),t)),{length:0,fields:new Array,children:new Array}),s=new Ro(n),a=ya({type:new Sr(n),length:r,children:i,nullCount:0});[this.schema,this.data]=fu(s,a.children,r);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=mu(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return Ws.visit(this.data,t)}set(t,e){return gs.visit(this.data,t,e)}indexOf(t,e){return Ma.visit(this.data,t,e)}getByteLength(t){return Ua.visit(this.data,t)}[Symbol.iterator](){return Oa.visit(new $a([this.data]))}toArray(){return[...this]}concat(...t){return new pu(this.schema,[this,...t])}slice(e,n){const[i]=new $a([this.data]).slice(e,n).data;return new t(this.schema,i)}getChild(t){var e;return this.getChildAt(null===(e=this.schema.fields)||void 0===e?void 0:e.findIndex((e=>e.name===t)))}getChildAt(t){return t>-1&&te.name===t)),e)}setChildAt(e,n){let i=this.schema,r=this.data;if(e>-1&&ee.name===t));~e&&(r[e]=this.data.children[e])}return new t(n,ya({type:i,length:this.numRows,children:r}))}selectAt(e){const n=this.schema.selectAt(e),i=e.map((t=>this.data.children[t])).filter(Boolean),r=ya({type:new Sr(n.fields),length:this.numRows,children:i});return new t(n,r)}};function fu(t,e,n=e.reduce(((t,e)=>Math.max(t,e.length)),0)){var i;const r=[...t.fields],s=[...e],a=(n+63&-64)>>3;for(const[o,c]of t.fields.entries()){const t=e[o];t&&t.length===n||(r[o]=c.clone({nullable:!0}),s[o]=null!==(i=null==t?void 0:t._changeLengthAndBackfillNullBitmap(n))&&void 0!==i?i:ya({type:c.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[t.assign(r),ya({type:new Sr(r),length:n,children:s})]}function mu(t,e,n=new Map){var i,r;if((null!==(i=null==t?void 0:t.length)&&void 0!==i?i:0)>0&&(null==t?void 0:t.length)===(null==e?void 0:e.length))for(let i=-1,s=t.length;++i(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(du.prototype);class yu extends du{constructor(t){const e=t.fields.map((t=>ya({type:t.type})));super(t,ya({type:new Sr(t.fields),nullCount:0,children:e}))}}var gu,bu;!function(t){t[t.BUFFER=0]="BUFFER"}(gu||(gu={})),function(t){t[t.LZ4_FRAME=0]="LZ4_FRAME",t[t.ZSTD=1]="ZSTD"}(bu||(bu={}));class vu{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new vu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new vu).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):bu.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):gu.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,bu.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,gu.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return vu.startBodyCompression(t),vu.addCodec(t,e),vu.addMethod(t,n),vu.endBodyCompression(t)}}class _u{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(null!=n?n:0)),t.writeInt64(BigInt(null!=e?e:0)),t.offset()}}let xu=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(null!=n?n:0)),t.writeInt64(BigInt(null!=e?e:0)),t.offset()}},wu=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsRecordBatch(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new xu).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){const n=this.bb.__offset(this.bb_pos,8);return n?(e||new _u).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const e=this.bb.__offset(this.bb_pos,10);return e?(t||new vu).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}},Su=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDictionaryBatch(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new wu).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var Iu;!function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"}(Iu||(Iu={}));let Au=class t{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):co.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):Iu.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new oo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,co.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,Iu.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(e,n,i,r,s,a){return t.startMessage(e),t.addVersion(e,n),t.addHeaderType(e,i),t.addHeader(e,r),t.addBodyLength(e,s),t.addCustomMetadata(e,a),t.endMessage(e)}};const Tu=new class extends Dr{visit(t,e){return null==t||null==e?void 0:super.visit(t,e)}visitNull(t,e){return Mo.startNull(e),Mo.endNull(e)}visitInt(t,e){return po.startInt(e),po.addBitWidth(e,t.bitWidth),po.addIsSigned(e,t.isSigned),po.endInt(e)}visitFloat(t,e){return Ao.startFloatingPoint(e),Ao.addPrecision(e,t.precision),Ao.endFloatingPoint(e)}visitBinary(t,e){return mo.startBinary(e),mo.endBinary(e)}visitBool(t,e){return yo.startBool(e),yo.endBool(e)}visitUtf8(t,e){return Fo.startUtf8(e),Fo.endUtf8(e)}visitDecimal(t,e){return bo.startDecimal(e),bo.addScale(e,t.scale),bo.addPrecision(e,t.precision),bo.addBitWidth(e,t.bitWidth),bo.endDecimal(e)}visitDate(t,e){return go.startDate(e),go.addUnit(e,t.unit),go.endDate(e)}visitTime(t,e){return No.startTime(e),No.addUnit(e,t.unit),No.addBitWidth(e,t.bitWidth),No.endTime(e)}visitTimestamp(t,e){const n=t.timezone&&e.createString(t.timezone)||void 0;return Do.startTimestamp(e),Do.addUnit(e,t.unit),void 0!==n&&Do.addTimezone(e,n),Do.endTimestamp(e)}visitInterval(t,e){return To.startInterval(e),To.addUnit(e,t.unit),To.endInterval(e)}visitDuration(t,e){return wo.startDuration(e),wo.addUnit(e,t.unit),wo.endDuration(e)}visitList(t,e){return ko.startList(e),ko.endList(e)}visitStruct(t,e){return Eo.startStruct_(e),Eo.endStruct_(e)}visitUnion(t,e){Lo.startTypeIdsVector(e,t.typeIds.length);const n=Lo.createTypeIdsVector(e,t.typeIds);return Lo.startUnion(e),Lo.addMode(e,t.mode),Lo.addTypeIds(e,n),Lo.endUnion(e)}visitDictionary(t,e){const n=this.visit(t.indices,e);return fo.startDictionaryEncoding(e),fo.addId(e,BigInt(t.id)),fo.addIsOrdered(e,t.isOrdered),void 0!==n&&fo.addIndexType(e,n),fo.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return So.startFixedSizeBinary(e),So.addByteWidth(e,t.byteWidth),So.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Io.startFixedSizeList(e),Io.addListSize(e,t.listSize),Io.endFixedSizeList(e)}visitMap(t,e){return Co.startMap(e),Co.addKeysSorted(e,t.keysSorted),Co.endMap(e)}};function ku(t){return new Vu(t.count,Mu(t.columns),Eu(t.columns))}function Cu(t,e){return(t.children||[]).filter(Boolean).map((t=>jo.fromJSON(t,e)))}function Mu(t){return(t||[]).reduce(((t,e)=>{return[...t,new Ru(e.count,(n=e.VALIDITY,(n||[]).reduce(((t,e)=>t+ +(0===e)),0))),...Mu(e.children)];var n}),[])}function Eu(t,e=[]){for(let n=-1,i=(t||[]).length;++n[t,e])))}function Du(t){return new Yi(t.isSigned,t.bitWidth)}function Ou(t,e){const n=t.type.name;switch(n){case"NONE":case"null":return new qi;case"binary":return new sr;case"utf8":return new ar;case"bool":return new or;case"list":return new wr((e||[])[0]);case"struct":case"struct_":return new Sr(e||[])}switch(n){case"int":{const e=t.type;return new Yi(e.isSigned,e.bitWidth)}case"floatingpoint":{const e=t.type;return new er(ii[e.precision])}case"decimal":{const e=t.type;return new cr(e.scale,e.precision,e.bitWidth)}case"date":{const e=t.type;return new ur(ri[e.unit])}case"time":{const e=t.type;return new pr(si[e.unit],e.bitWidth)}case"timestamp":{const e=t.type;return new gr(si[e.unit],e.timezone)}case"interval":{const e=t.type;return new br(ai[e.unit])}case"duration":{const e=t.type;return new xr(si[e.unit])}case"union":{const n=t.type,[i,...r]=(n.mode+"").toLowerCase(),s=i.toUpperCase()+r.join("");return new Ir(ni[s],n.typeIds||[],e||[])}case"fixedsizebinary":{const e=t.type;return new Ar(e.byteWidth)}case"fixedsizelist":{const n=t.type;return new Tr(n.listSize,(e||[])[0])}case"map":{const n=t.type;return new kr((e||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var Bu=ao,Lu=so;class Fu{static fromJSON(t,e){const n=new Fu(0,ei.V5,e);return n._createHeader=function(t,e){return()=>{switch(e){case oi.Schema:return Ro.fromJSON(t);case oi.RecordBatch:return Vu.fromJSON(t);case oi.DictionaryBatch:return Uu.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${oi[e]}, type: ${e} }`)}}(t,e),n}static decode(t){t=new Lu(qn(t));const e=Au.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),r=e.headerType(),s=new Fu(n,i,r);return s._createHeader=function(t,e){return()=>{switch(e){case oi.Schema:return Ro.decode(t.header(new Uo),new Map,t.version());case oi.RecordBatch:return Vu.decode(t.header(new wu),t.version());case oi.DictionaryBatch:return Uu.decode(t.header(new Su),t.version())}throw new Error(`Unrecognized Message type: { name: ${oi[e]}, type: ${e} }`)}}(e,r),s}static encode(t){const e=new Bu;let n=-1;return t.isSchema()?n=Ro.encode(e,t.header()):t.isRecordBatch()?n=Vu.encode(e,t.header()):t.isDictionaryBatch()&&(n=Uu.encode(e,t.header())),Au.startMessage(e),Au.addVersion(e,ei.V5),Au.addHeader(e,n),Au.addHeaderType(e,t.headerType),Au.addBodyLength(e,BigInt(t.bodyLength)),Au.finishMessageBuffer(e,Au.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Ro)return new Fu(0,ei.V5,oi.Schema,t);if(t instanceof Vu)return new Fu(e,ei.V5,oi.RecordBatch,t);if(t instanceof Uu)return new Fu(e,ei.V5,oi.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===oi.Schema}isRecordBatch(){return this.headerType===oi.RecordBatch}isDictionaryBatch(){return this.headerType===oi.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=wi(t)}}class Vu{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=wi(t)}}class Uu{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id=wi(e)}}class Pu{constructor(t,e){this.offset=wi(t),this.length=wi(e)}}class Ru{constructor(t,e){this.length=wi(t),this.nullCount=wi(e)}}function ju(t,e){const n=[];for(let i,r=-1,s=-1,a=t.childrenLength();++rjo.encode(t,e))),c=Vo.createChildrenVector(t,o),u=e.metadata&&e.metadata.size>0?Vo.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const i=t.createString(`${e}`),r=t.createString(`${n}`);return oo.startKeyValue(t),oo.addKey(t,i),oo.addValue(t,r),oo.endKeyValue(t)}))):-1;e.name&&(n=t.createString(e.name));Vo.startField(t),Vo.addType(t,i),Vo.addTypeType(t,a),Vo.addChildren(t,c),Vo.addNullable(t,!!e.nullable),-1!==n&&Vo.addName(t,n);-1!==r&&Vo.addDictionary(t,r);-1!==u&&Vo.addCustomMetadata(t,u);return Vo.endField(t)},jo.decode=function(t,e){let n,i,r,s,a,o;e&&(o=t.dictionary())?e.has(n=wi(o.id()))?(s=(s=o.indexType())?zu(s):new Ki,a=new Er(e.get(n),s,n,o.isOrdered()),i=new jo(t.name(),a,t.nullable(),$u(t))):(s=(s=o.indexType())?zu(s):new Ki,e.set(n,r=Hu(t,ju(t,e))),a=new Er(r,s,n,o.isOrdered()),i=new jo(t.name(),a,t.nullable(),$u(t))):(r=Hu(t,ju(t,e)),i=new jo(t.name(),r,t.nullable(),$u(t)));return i||null},jo.fromJSON=function(t,e){let n,i,r,s,a,o;return e&&(s=t.dictionary)?e.has(n=s.id)?(i=(i=s.indexType)?Du(i):new Ki,o=new Er(e.get(n),i,n,s.isOrdered),r=new jo(t.name,o,t.nullable,Nu(t.metadata))):(i=(i=s.indexType)?Du(i):new Ki,e.set(n,a=Ou(t,Cu(t,e))),o=new Er(a,i,n,s.isOrdered),r=new jo(t.name,o,t.nullable,Nu(t.metadata))):(a=Ou(t,Cu(t,e)),r=new jo(t.name,a,t.nullable,Nu(t.metadata))),r||null},Ro.encode=function(t,e){const n=e.fields.map((e=>jo.encode(t,e)));Uo.startFieldsVector(t,n.length);const i=Uo.createFieldsVector(t,n),r=e.metadata&&e.metadata.size>0?Uo.createCustomMetadataVector(t,[...e.metadata].map((([e,n])=>{const i=t.createString(`${e}`),r=t.createString(`${n}`);return oo.startKeyValue(t),oo.addKey(t,i),oo.addValue(t,r),oo.endKeyValue(t)}))):-1;Uo.startSchema(t),Uo.addFields(t,i),Uo.addEndianness(t,qu?uo.Little:uo.Big),-1!==r&&Uo.addCustomMetadata(t,r);return Uo.endSchema(t)},Ro.decode=function(t,e=new Map,n=ei.V5){const i=function(t,e){const n=[];for(let i,r=-1,s=-1,a=t.fieldsLength();++rjo.fromJSON(t,e)))}(t,e),Nu(t.metadata),e)},Vu.encode=function(t,e){const n=e.nodes||[],i=e.buffers||[];wu.startNodesVector(t,n.length);for(const e of n.slice().reverse())Ru.encode(t,e);const r=t.endVector();wu.startBuffersVector(t,i.length);for(const e of i.slice().reverse())Pu.encode(t,e);const s=t.endVector();return wu.startRecordBatch(t),wu.addLength(t,BigInt(e.length)),wu.addNodes(t,r),wu.addBuffers(t,s),wu.endRecordBatch(t)},Vu.decode=function(t,e=ei.V5){if(null!==t.compression())throw new Error("Record batch compression not implemented");return new Vu(t.length(),function(t){const e=[];for(let n,i=-1,r=-1,s=t.nodesLength();++i{const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),256===new Int16Array(t)[0]})(),Yu="ARROW1",Gu=new Uint8Array(6);for(let t=0;t<6;t+=1)Gu[t]=Yu.codePointAt(t);Gu.length;class Wu extends Dr{static assemble(...t){const e=t=>t.flatMap((t=>Array.isArray(t)?e(t):t instanceof du?t.data.children:t.data)),n=new Wu;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof $a)return this.visitMany(t.data),this;const{type:e}=t;if(!Hi.isDictionary(e)){const{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(Hi.isUnion(e))this.nodes.push(new Ru(n,0));else{const{nullCount:i}=t;Hi.isNull(e)||Ku.call(this,i<=0?new Uint8Array(0):ca(t.offset,n,t.nullBitmap)),this.nodes.push(new Ru(n,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function Ku(t){const e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new Pu(this._byteLength,e)),this._byteLength+=e,this}function Qu(t){return Ku.call(this,t.values.subarray(0,t.length*t.stride))}function Ju(t){const{length:e,values:n,valueOffsets:i}=t,{0:r,[e]:s}=i,a=Math.min(s-r,n.byteLength-r);return Ku.call(this,Qn(-r,e+1,i)),Ku.call(this,n.subarray(r,r+a)),this}function Zu(t){const{length:e,valueOffsets:n}=t;if(n){const{0:i,[e]:r}=n;return Ku.call(this,Qn(-i,e+1,n)),this.visit(t.children[0].slice(i,r-i))}return this.visit(t.children[0])}function Xu(t){return this.visitMany(t.type.children.map(((e,n)=>t.children[n])).filter(Boolean))[0]}Wu.prototype.visitBool=function(t){let e;return t.nullCount>=t.length?Ku.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?Ku.call(this,ca(t.offset,t.length,e)):Ku.call(this,ua(t.values))},Wu.prototype.visitInt=Qu,Wu.prototype.visitFloat=Qu,Wu.prototype.visitUtf8=Ju,Wu.prototype.visitBinary=Ju,Wu.prototype.visitFixedSizeBinary=Qu,Wu.prototype.visitDate=Qu,Wu.prototype.visitTimestamp=Qu,Wu.prototype.visitTime=Qu,Wu.prototype.visitDecimal=Qu,Wu.prototype.visitList=Zu,Wu.prototype.visitStruct=Xu,Wu.prototype.visitUnion=function(t){var e;const{type:n,length:i,typeIds:r,valueOffsets:s}=t;if(Ku.call(this,r),n.mode===ni.Sparse)return Xu.call(this,t);if(n.mode===ni.Dense){if(t.offset<=0)return Ku.call(this,s),Xu.call(this,t);{const a=new Int32Array(i),o=Object.create(null),c=Object.create(null);for(let t,n,u=-1;++u{const r=n.typeIds[e],s=o[r],a=c[r];return t.slice(s,Math.min(i,a))})))}}return this},Wu.prototype.visitInterval=Qu,Wu.prototype.visitDuration=Qu,Wu.prototype.visitFixedSizeList=Zu,Wu.prototype.visitMap=Zu;class tl extends Qo{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new Zo,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,On(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy="boolean"!=typeof t.autoDestroy||t.autoDestroy,this._writeLegacyIpcFormat="boolean"==typeof t.writeLegacyIpcFormat&&t.writeLegacyIpcFormat}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return Bn(t)?t.then((t=>this.writeAll(t))):Fn(t)?rl(this,t):il(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){var n;return t===this._sink||t instanceof Zo?this._sink=t:(this._sink=new Zo,t&&(On(n=t)&&Dn(n.abort)&&Dn(n.getWriter)&&!Un(n))?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&(t=>On(t)&&Dn(t.end)&&Dn(t.write)&&(t=>"boolean"==typeof t)(t.writable)&&!Un(t))(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,e&&au(e,this._schema)||(null==e?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(!this._sink)throw new Error("RecordBatchWriter is closed");if(null==t)return this.finish()&&void 0;if(t instanceof pu&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof du&&!(e=t.schema))return this.finish()&&void 0;if(e&&!au(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof du?t instanceof yu||this._writeRecordBatch(t):t instanceof pu?this.writeAll(t.batches):Ln(t)&&this.writeAll(t)}_writeMessage(t,e=8){const n=e-1,i=Fu.encode(t),r=i.byteLength,s=this._writeLegacyIpcFormat?4:8,a=r+s+n&~n,o=a-r-s;return t.headerType===oi.RecordBatch?this._recordBatchBlocks.push(new Wo(a,t.bodyLength,this._position)):t.headerType===oi.DictionaryBatch&&this._dictionaryBlocks.push(new Wo(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-s)),r>0&&this._write(i),this._writePadding(o)}_write(t){if(this._started){const e=qn(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(Fu.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Gu)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:e,nodes:n,bufferRegions:i,buffers:r}=Wu.assemble(t),s=new Vu(t.numRows,n,i),a=Fu.from(s,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(r)}_writeDictionaryBatch(t,e,n=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));const{byteLength:i,nodes:r,bufferRegions:s,buffers:a}=Wu.assemble(new $a([t])),o=new Vu(t.length,r,s),c=new Uu(o,e,n),u=Fu.from(c,i);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,n,i;for(let r=-1,s=t.length;++r0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){for(let[e,n]of t.dictionaries){let t=this._dictionaryDeltaOffsets.get(e)||0;if(0===t||(n=null==n?void 0:n.slice(t)).length>0)for(const i of n.data)this._writeDictionaryBatch(i,e,t>0),t+=i.length}return this}}class el extends tl{static writeAll(t,e){const n=new el(e);return Bn(t)?t.then((t=>n.writeAll(t))):Fn(t)?rl(n,t):il(n,t)}}class nl extends tl{static writeAll(t){const e=new nl;return Bn(t)?t.then((t=>e.writeAll(t))):Fn(t)?rl(e,t):il(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){const e=Yo.encode(new Yo(t,ei.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}}function il(t,e){let n=e;e instanceof pu&&(n=e.batches,t.reset(void 0,e.schema));for(const e of n)t.write(e);return t.finish()}function rl(t,e){var n,i,r,s,a,o,c;return wn(this,void 0,void 0,(function*(){try{for(n=!0,i=kn(e);r=yield i.next(),!(s=r.done);n=!0){c=r.value,n=!1;const e=c;t.write(e)}}catch(t){a={error:t}}finally{try{n||s||!(o=i.return)||(yield o.call(i))}finally{if(a)throw a.error}}return t.finish()}))}function sl(t,e=1){return(t*e+63&-64||64)/e}function al(t,e,n=t.BYTES_PER_ELEMENT){return new t(sl(e,n))}function ol(t){return t instanceof da?t:new da(t.type,0,t.length,t.nulls,t.buffers,null,t.dict)}const cl=new TextEncoder;const ul=cl.encodeInto?function(t,e,n){return cl.encodeInto(n,t.subarray(e)).written}:function(t,e,n){const i=cl.encode(n);return t.set(i,e),i.length};function ll(t,e){const n=al(t.ArrayType,e);return{set(t,e){n[e]=t},data:()=>({type:t,length:e,buffers:[null,n]})}}function hl(t,e){const n=al(t.ArrayType,e/8);return{set(t,e){t&&(n[e>>3]|=1<({type:t,length:e,buffers:[null,n]})}}function pl(t,e){const n=al(t.ArrayType,e);return{set(t,e){n[e]=t/864e5|0},data:()=>({type:t,length:e,buffers:[null,n]})}}function dl(t,e){const n=al(t.ArrayType,e<<1);return{set(t,e){const i=e<<1;n[i]=t%4294967296|0,n[i+1]=t/4294967296|0},data:()=>({type:t,length:e,buffers:[null,n]})}}function fl(t,e){const n=[],i=al(t.indices.ArrayType,e),r=Object.create(null);let s=-1,a=0;return{set(t,e){const o=String(t);let c=r[o];void 0===c&&(a+=o.length,r[o]=c=++s,n.push(o)),i[e]=c},data:()=>({type:t,length:e,buffers:[null,i],dict:ml(t.dictionary,n,a)})}}function ml(t,e,n){const i=function(t,e,n){const i=al(Int32Array,e+1),r=al(Uint8Array,3*n);let s=0;return{set(t,e){s+=ul(r,s,t),i[e+1]=s},data:()=>{const n=sl(s),a=r.length>n?r.subarray(0,n):r;return{type:t,length:e,buffers:[i,a]}}}}(t,e.length,n);return e.forEach(i.set),function(t){return new $a([ol(t)])}(i.data())}function yl(t,e,n=!0){let i;switch(t.typeId){case ci.Int:i=t.bitWidth<64?ll:null;break;case ci.Float:i=t.precision>0?ll:null;break;case ci.Dictionary:i=t.dictionary.typeId===ci.Utf8&&t.indices.typeId===ci.Int&&t.indices.bitWidth<64?fl:null;break;case ci.Bool:i=hl;break;case ci.Date:i=t.unit?dl:pl}return null==i?function(t){const e=ou({type:t,nullValues:[null,void 0]});return{set(t,n){e.set(n,t)},data:()=>e.finish().flush()}}(t):n?function(t,e){const n=al(Uint8Array,e/8);let i=0;return{set(e,r){null==e?++i:(t.set(e,r),n[r>>3]|=1<{const e=t.data();return i&&(e.nulls=i,e.buffers[2]=n),e}}}(i(t,e),e):i(t,e)}function gl(t,e,n,i,r=!0){const s=yl(i,t,r);return e(n,s.set),ol(s.data())}function bl(t){if(t instanceof Hi||null==t)return t;switch(t){case ci.Binary:return new sr;case ci.Bool:return new or;case ci.DateDay:return new lr;case ci.DateMillisecond:case ci.Date:return new hr;case ci.Dictionary:return new Er(new ar,new Ki);case ci.Float16:return new nr;case ci.Float32:return new ir;case ci.Float64:case ci.Float:return new rr;case ci.Int8:return new Gi;case ci.Int16:return new Wi;case ci.Int32:case ci.Int:return new Ki;case ci.Int64:return new Qi;case ci.IntervalDayTime:return new vr;case ci.Interval:case ci.IntervalYearMonth:return new _r;case ci.Null:return new qi;case ci.TimeMicrosecond:return new mr;case ci.TimeMillisecond:case ci.Time:return new fr;case ci.TimeNanosecond:return new yr;case ci.TimeSecond:return new dr;case ci.Uint8:return new Ji;case ci.Uint16:return new Zi;case ci.Uint32:return new Xi;case ci.Uint64:return new tr;case ci.Utf8:return new ar;default:St(`Unsupported type code: ${be(t)}. Use a data type constructor instead?`)}}function vl(t,e){const n=_l();return t(e,n.add),n}function _l(){const t={count:0,nulls:0,bools:0,nums:0,ints:0,bigints:0,min:1/0,max:-1/0,digits:0,dates:0,utcdays:0,strings:0,strlen:0,arrays:0,minlen:1/0,maxlen:0,structs:0,add(e){if(++t.count,null==e)return void++t.nulls;const n=typeof e;if("string"===n)++t.strings;else if("number"===n)++t.nums,et.max&&(t.max=e),Number.isInteger(e)&&++t.ints;else if("boolean"===n)++t.bools;else if("object"===n)if(Et(e))++t.dates,0===(i=e).getUTCHours()&&0===i.getUTCMinutes()&&0===i.getUTCSeconds()&&0===i.getUTCMilliseconds()&&++t.utcdays;else if(zt(e)){++t.arrays,e.lengtht.maxlen&&(t.maxlen=e.length);const n=t.array_prof||(t.array_prof=_l());e.forEach(n.add)}else{++t.structs;const n=t.struct_prof||(t.struct_prof={});for(const t in e){(n[t]||(n[t]=_l())).add(e[t])}}else"bigint"===n&&(++t.bigints,et.max&&(t.max=e));var i},type:()=>bl(function(t){const e=t.count-t.nulls;if(0===e)return ci.Null;if(t.ints===e){const e=Math.max(Math.abs(t.min)-1,t.max);return t.min<0?e>=2**31?ci.Float64:e<128?ci.Int8:e<32768?ci.Int16:ci.Int32:e>=2**32?ci.Float64:e<256?ci.Uint8:e<65536?ci.Uint16:ci.Uint32}if(t.nums===e)return ci.Float64;if(t.bigints===e){const e=-t.min>t.max?-t.min-1n:t.max;return t.min<0?e<2**63?ci.Int64:St(`BigInt exceeds 64 bits: ${e}`):t.max<2**64?ci.Uint64:St(`BigInt exceeds 64 bits: ${t.max}`)}if(t.bools===e)return ci.Bool;if(t.utcdays===e)return ci.DateDay;if(t.dates===e)return ci.DateMillisecond;if(t.arrays===e){const e=jo.new("value",t.array_prof.type(),!0);return t.minlen===t.maxlen?new Tr(t.minlen,e):new wr(e)}if(t.structs===e){const e=t.struct_prof;return new Sr(Object.keys(e).map((t=>jo.new(t,e[t].type(),!0))))}if(t.strings>0)return ci.Dictionary;St("Type inference failure")}(t))};return t}function xl(t,e,n,i,r,s=!0){if(!(r=bl(r))){const t=vl(i,e);s=t.nulls>0,r=t.type()}return gl(n,i,e,r,s)}function wl(t,e,n,i,r,s=!0){r=bl(r);const a=t.column(e),o=!(t.isFiltered()||t.isOrdered()),c=(u=a)instanceof $a?u:u.vector instanceof $a?u.vector:null;var u;if(c&&o&&Sl(c.type,r))return c;const l=a.data;if($t(l)){const t=function(t){const e={Float32Array:ir,Float64Array:rr,Int8Array:Gi,Int16Array:Wi,Int32Array:Ki,Uint8Array:Ji,Uint16Array:Zi,Uint32Array:Xi,BigInt64Array:Qi,BigUint64Array:tr},n=e[t.constructor.name];return n?new n:null}(l);if(o&&t&&Sl(t,r))return function(t,e){const n=t.length,i=sl(n,t.BYTES_PER_ELEMENT);let r=t;return n!==i&&(r=new t.constructor(i),r.set(t)),ol({type:e,length:n,buffers:[null,r]})}(l,t);r=r||t,s=!1}if(!r){const t=vl(i,a);s=t.nulls>0,r=t.type()}return gl(n,i,a,r,s)}function Sl(t,e){return!t||!e||t.compareTo(e)}function Il(t,e,n){const i=Math.min(t.length,n+e);return(e,r)=>{for(let s=n;s{let a=-1;i&&zt(r.data)?r.data.forEach(s):t.scan((t=>s(r.get(t),++a)),!0,e,n)}}const Tl=()=>St("Apache Arrow not imported, see https://github.com/uwdata/arquero#usage");function kl(t,e={}){const{types:n={}}=e,{dataFrom:i,names:r,nrows:s,scan:a}=function(t,e){const{columns:n,limit:i=1/0,offset:r=0}=e,s=At(n)?n(t):vt(n)?n:null;if(vt(t))return{dataFrom:xl,names:s||Object.keys(t[0]),nrows:Math.min(i,t.length-r),scan:Il(t,i,r)};if(function(t){return t&&At(t.reify)}(t))return{dataFrom:wl,names:s||t.columnNames(),nrows:Math.min(i,t.numRows()-r),scan:Al(t,i,r)};St("Unsupported input data type")}(t,e),o={};r.forEach((e=>{const r=i(t,e,s,a,n[e]);r.length!==s&&St("Column length mismatch"),o[e]=r}));return new(function(){try{return pu}catch(t){Tl()}}())(o)}function Cl(t,e={}){const{format:n,...i}=e;if(!["stream","file"].includes(n||"stream"))throw Error("Unrecognised output format");return function(t,e="stream"){return("stream"===e?el:nl).writeAll(t).toUint8Array(!0)}(kl(t,i),n)}function Ml(t,e){return At(e)?e(t):e||t.columnNames()}function El(t,e,n){const i=n.format||{},r=n.align||{},s={},a={};return e.forEach((e=>{const o=function(t,e={}){let n=0,i=0,r=0,s=0,a=0,o=0;return t((t=>{if(++n,null==t)return void++i;const e=typeof t;if("object"===e&&Et(t))++r,0===(c=t).getUTCHours()&&0===c.getUTCMinutes()&&0===c.getUTCSeconds()&&0===c.getUTCMilliseconds()&&++s;else if("number"===e&&(++a,t==t&&(0|t)!==t)){const e=t+"",n=e.indexOf(".");if(n>=0){const t=e.indexOf("e"),i=t>0?t:e.length;o=Math.max(o,i-n-1)}}var c})),{align:(i+a+r)/n>.5?"r":"l",format:{utc:r===s,digits:Math.min(o,e.maxdigits||6)}}}(function(t,e){const n=t.column(e);return e=>t.scan((t=>e(n.get(t))))}(t,e),n);a[e]=r[e]||o.align,s[e]=i[e]||o.format})),{align:a,format:s}}function Nl(t,e,n=100,i,r){const s=t.data(),a=e.length;t.scan((t=>{r.row(t);for(let n=0;n$t(e)?Array.from(e):e)),i=e.maxlen||30;return n.length>i?n.slice(0,28)+"…"+("["===n[0]?"]":"}"):n}}if("number"===n){const n=e.digits||0;let i;return 0!==t&&((i=Math.abs(t))>=1e18||iAt(t)?t:()=>t))}(e),a=e.null,o=(t,e)=>Dl(t,e).replace(/&/g,"&").replace(//g,">"),c=a?(t,e)=>null==t?a(t):o(t,e):o;let u=-1,l=-1;const h=(t,e,n)=>{const r=n?(t=>"c"===t?"center":"r"===t?"right":"left")(i[e]):"",a=s[t]&&s[t](e,l,u)||"",o=(r?`text-align: ${r};`+(a?" ":""):"")+a;return`<${t}${o?` style="${o}"`:""}>`};let p=h("table")+h("thead")+h("tr",u)+n.map((t=>`${h("th",t,1)}${t}`)).join("")+""+h("tbody");return Nl(t,n,e.limit,e.offset,{row(t){u=t,p+=(++l?"":"")+h("tr")},cell(t,e){p+=h("td",e,1)+c(t,r[e])+""}}),p+""}function Ll(t,e=!0,n=!1){return void 0===t||t?e:n}const Fl=t=>Et(t)?Zt(t,!0):t;function Vl(t,e){for(const[n,i]of gn(e))t.set(n,i);return t}function Ul(t,e,n=new Map){return Ot(e=It(e)?t.columnName(e):e)?n.set(e,e):vt(e)?e.forEach((e=>Ul(t,e,n))):At(e)?Ul(t,e(t),n):Nt(e)?Vl(n,e):St(`Invalid column selection: ${be(e)}`),n}function Pl(t,e){return t.toObject=e,t}function Rl(t){return vt(t)?t.map(Rl):t&&t.toObject?t.toObject():t}function jl(){return Pl((t=>t.columnNames()),(()=>({all:[]})))}function $l(...t){return t=t.flat(),Pl((e=>{const n=Ul(e,t);return e.columnNames((t=>!n.has(t)))}),(()=>({not:Rl(t)})))}class zl extends kt{static from(t,e){return new zl(Bt(t,e),e)}static new(t,e){if(t instanceof zl)return t;const n={},i=[];for(const[e,r]of gn(t))n[e]=r,i.push(e);return new zl(n,e||i)}constructor(t,e,n,i,r,s){Ol(t,Mt,t);super(e=e||Object.keys(t),e.length?t[e[0]].length:0,t,n,i,r,s)}create({data:t,names:e,filter:n,groups:i,order:r}){const s=void 0!==n?n:this.mask();return new zl(t||this._data,e||(t?null:this._names),s,void 0!==i?i:function(t,e){if(!t||!e)return t;const{keys:n,rows:i,size:r}=t,s=new Int32Array(r);e.scan((t=>s[n[t]]=1));const a=s.reduce(((t,e)=>t+e),0);if(a===r)return t;const o=Array(a);let c=0;for(let t=0;tu[t]=s[n[t]])),{...t,keys:u,rows:o,size:c}}(this._group,n&&s),void 0!==r?r:this._order,this._params)}assign(...t){const e=this.numRows(),n=this.reify(),i=Ut(n).groupby(n.groups());return t.forEach((t=>{(t=zl.new(t)).numRows()!==e&&St("Assign row counts do not match"),(t=t.reify()).columnNames((e=>i.add(e,t.column(e))))})),this.create(i.new())}columns(){return this._data}column(t){return this._data[t]}columnAt(t){return this._data[this._names[t]]}array(t,e=Array){const n=this.column(t),i=new e(this.numRows());let r=-1;return this.scan((t=>i[++r]=n.get(t)),!0),i}get(t,e=0){const n=this.column(t);return this.isFiltered()||this.isOrdered()?n.get(this.indices()[e]):n.get(e)}getter(t){const e=this.column(t),n=this.isFiltered()||this.isOrdered()?this.indices():null;return n?t=>e.get(n[t]):e?t=>e.get(t):St(`Unrecognized column: ${t}`)}object(t=0){return Hl(this)(t)}objects(t={}){const{grouped:e,limit:n,offset:i}=t,r=xn(Ul(this,t.columns||jl())),s=[];if(this.scan(((t,e)=>s.push(r(t,e))),!0,n,i),e&&this.isGrouped()){const t=[];return this.scan((e=>t.push(e)),!0,n,i),Me(this,t,s,e)}return s}*[Symbol.iterator](){const t=Hl(this),e=this.numRows();for(let n=0;nt.forEach(e):t=>this.scan(t,!0),o=n.length;i={};for(let t=0;tc[++u]=o.get(t)))}this.isGrouped()&&(r=function(t,e,n,i){const{keys:r,rows:s,size:a}=t;let o=s,c=a,u=null;if(n){u=new Int32Array(a),e((t=>u[r[t]]=1));const t=u.reduce(((t,e)=>t+e),0);if(t!==a){o=Array(t),c=0;for(let t=0;th[++l]=u[r[t]]:t=>h[++l]=r[t]),{...t,keys:h,rows:o,size:c}}(this.groups(),a,!!t,e))}var s;return this.create({data:i,names:n,groups:r,filter:null,order:null})}transform(...t){return t.flat().reduce(((t,e)=>e(t)),this)}toArrow(t){return kl(this,t)}toArrowBuffer(t){return Cl(this,t)}toCSV(t){return function(t,e={}){const n=Ml(t,e.columns),i=e.format||{},r=e.delimiter||",",s=new RegExp(`["${r}\n\r]`),a=t=>null==t?"":Et(t)?Zt(t,!0):s.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t,o=n.map(a);let c="";return Nl(t,n,e.limit||1/0,e.offset,{row(){c+=o.join(r)+"\n"},cell(t,e,n){o[n]=a(i[e]?i[e](t):t)}}),c+o.join(r)}(this,t)}toHTML(t){return Bl(this,t)}toJSON(t){return function(t,e={}){const n=Ll(e.schema),i=e.format||{},r=Ml(t,e.columns);let s="{";return n&&(s+='"schema":{"fields":'+JSON.stringify(r.map((t=>({name:t}))))+'},"data":{'),r.forEach(((n,r)=>{s+=(r?",":"")+JSON.stringify(n)+":[";const a=t.column(n),o=i[n]||Fl;let c=-1;t.scan((t=>{const e=a.get(t);s+=(++c?",":"")+JSON.stringify(o(e))}),!0,e.limit,e.offset),s+="]"})),s+"}"+(n?"}":"")}(this,t)}toMarkdown(t){return function(t,e={}){const n=Ml(t,e.columns),{align:i,format:r}=El(t,n,e),s=t=>t.replace(/\|/g,"\\|");let a="|"+n.map(s).join("|")+"|\n|"+n.map((t=>{return"c"===(e=i[t])?":-:":"r"===e?"-:":":-";var e})).join("|")+"|";return Nl(t,n,e.limit,e.offset,{row(){a+="\n|"},cell(t,e){a+=s(Dl(t,r[e]))+"|"}}),a+"\n"}(this,t)}}function Hl(t){let e=t._builder;if(!e){const n=xn(t.columnNames()),i=t.data();if(t.isOrdered()||t.isFiltered()){const r=t.indices();e=t=>n(r[t],i)}else e=t=>n(t,i);t._builder=e}return e}class ql{constructor(t){this._outputs=t}size(){return this._outputs.length}outputs(){return this._outputs}init(){return{}}add(){}rem(){}write(){}}function Yl(t,e,n,i){const r=n[t.type]||n.Default;if(r&&!1===r(t,e,i))return;const s=Xl[t.type];s&&s(t,e,n)}const Gl=(t,e,n)=>{Yl(t.argument,e,n,t)},Wl=(t,e,n)=>{Yl(t.left,e,n,t),Yl(t.right,e,n,t)},Kl=(t,e,n)=>{Yl(t.test,e,n,t),Yl(t.consequent,e,n,t),t.alternate&&Yl(t.alternate,e,n,t)},Ql=(t,e,n)=>{Zl(t.params,e,n,t),Yl(t.body,e,n,t)},Jl=(t,e,n)=>{Yl(t.callee,e,n,t),Zl(t.arguments,e,n,t)},Zl=(t,e,n,i)=>{t.forEach((t=>Yl(t,e,n,i)))},Xl={TemplateLiteral:(t,e,n)=>{Zl(t.expressions,e,n,t),Zl(t.quasis,e,n,t)},MemberExpression:(t,e,n)=>{Yl(t.object,e,n,t),Yl(t.property,e,n,t)},CallExpression:Jl,NewExpression:Jl,ArrayExpression:(t,e,n)=>{Zl(t.elements,e,n,t)},AssignmentExpression:Wl,AwaitExpression:Gl,BinaryExpression:Wl,LogicalExpression:Wl,UnaryExpression:Gl,UpdateExpression:Gl,ConditionalExpression:Kl,ObjectExpression:(t,e,n)=>{Zl(t.properties,e,n,t)},Property:(t,e,n)=>{Yl(t.key,e,n,t),Yl(t.value,e,n,t)},ArrowFunctionExpression:Ql,FunctionExpression:Ql,FunctionDeclaration:Ql,VariableDeclaration:(t,e,n)=>{Zl(t.declarations,e,n,t)},VariableDeclarator:(t,e,n)=>{Yl(t.id,e,n,t),Yl(t.init,e,n,t)},SpreadElement:(t,e,n)=>{Yl(t.argument,e,n,t)},BlockStatement:(t,e,n)=>{Zl(t.body,e,n,t)},ExpressionStatement:(t,e,n)=>{Yl(t.expression,e,n,t)},IfStatement:Kl,ForStatement:(t,e,n)=>{Yl(t.init,e,n,t),Yl(t.test,e,n,t),Yl(t.update,e,n,t),Yl(t.body,e,n,t)},WhileStatement:(t,e,n)=>{Yl(t.test,e,n,t),Yl(t.body,e,n,t)},DoWhileStatement:(t,e,n)=>{Yl(t.body,e,n,t),Yl(t.test,e,n,t)},SwitchStatement:(t,e,n)=>{Yl(t.discriminant,e,n,t),Zl(t.cases,e,n,t)},SwitchCase:(t,e,n)=>{t.test&&Yl(t.test,e,n,t),Zl(t.consequent,e,n,t)},ReturnStatement:Gl,Program:(t,e,n)=>{Yl(t.body[0],e,n,t)}};function th(t){delete t.start,delete t.end,delete t.optional}function eh(t){th(t),delete t.object,delete t.property,delete t.computed,t.table||delete t.table}function nh(t,e){return e&&e.type===t}const ih="Escaped functions are not valid as rollup or pivot values.";function rh(t,e,n){t.aggronly&&St(ih);const i="(row,data)=>fn("+_n(t.table.columnNames())+",$)";return{escape:fn.escape(i,(r=e.expr,At(r)?r:()=>r),n)};var r}var sh=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,81,2,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,9,5351,0,7,14,13835,9,87,9,39,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,4706,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,983,6,110,6,6,9,4759,9,787719,239],ah=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,68,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,4026,582,8634,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,757,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],oh="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟊꟐꟑꟓꟕ-ꟙꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",ch={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},uh="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",lh={5:uh,"5module":uh+" export import",6:uh+" const class extends export import super"},hh=/^in(stanceof)?$/,ph=new RegExp("["+oh+"]"),dh=new RegExp("["+oh+"‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࢘-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・]");function fh(t,e){for(var n=65536,i=0;it)return!1;if((n+=e[i+1])>=t)return!0}return!1}function mh(t,e){return t<65?36===t:t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&ph.test(String.fromCharCode(t)):!1!==e&&fh(t,ah)))}function yh(t,e){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&dh.test(String.fromCharCode(t)):!1!==e&&(fh(t,ah)||fh(t,sh)))))}var gh=function(t,e){void 0===e&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null};function bh(t,e){return new gh(t,{beforeExpr:!0,binop:e})}var vh={beforeExpr:!0},_h={startsExpr:!0},xh={};function wh(t,e){return void 0===e&&(e={}),e.keyword=t,xh[t]=new gh(t,e)}var Sh={num:new gh("num",_h),regexp:new gh("regexp",_h),string:new gh("string",_h),name:new gh("name",_h),privateId:new gh("privateId",_h),eof:new gh("eof"),bracketL:new gh("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new gh("]"),braceL:new gh("{",{beforeExpr:!0,startsExpr:!0}),braceR:new gh("}"),parenL:new gh("(",{beforeExpr:!0,startsExpr:!0}),parenR:new gh(")"),comma:new gh(",",vh),semi:new gh(";",vh),colon:new gh(":",vh),dot:new gh("."),question:new gh("?",vh),questionDot:new gh("?."),arrow:new gh("=>",vh),template:new gh("template"),invalidTemplate:new gh("invalidTemplate"),ellipsis:new gh("...",vh),backQuote:new gh("`",_h),dollarBraceL:new gh("${",{beforeExpr:!0,startsExpr:!0}),eq:new gh("=",{beforeExpr:!0,isAssign:!0}),assign:new gh("_=",{beforeExpr:!0,isAssign:!0}),incDec:new gh("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new gh("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:bh("||",1),logicalAND:bh("&&",2),bitwiseOR:bh("|",3),bitwiseXOR:bh("^",4),bitwiseAND:bh("&",5),equality:bh("==/!=/===/!==",6),relational:bh("/<=/>=",7),bitShift:bh("<>/>>>",8),plusMin:new gh("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:bh("%",10),star:bh("*",10),slash:bh("/",10),starstar:new gh("**",{beforeExpr:!0}),coalesce:bh("??",1),_break:wh("break"),_case:wh("case",vh),_catch:wh("catch"),_continue:wh("continue"),_debugger:wh("debugger"),_default:wh("default",vh),_do:wh("do",{isLoop:!0,beforeExpr:!0}),_else:wh("else",vh),_finally:wh("finally"),_for:wh("for",{isLoop:!0}),_function:wh("function",_h),_if:wh("if"),_return:wh("return",vh),_switch:wh("switch"),_throw:wh("throw",vh),_try:wh("try"),_var:wh("var"),_const:wh("const"),_while:wh("while",{isLoop:!0}),_with:wh("with"),_new:wh("new",{beforeExpr:!0,startsExpr:!0}),_this:wh("this",_h),_super:wh("super",_h),_class:wh("class",_h),_extends:wh("extends",vh),_export:wh("export"),_import:wh("import",_h),_null:wh("null",_h),_true:wh("true",_h),_false:wh("false",_h),_in:wh("in",{beforeExpr:!0,binop:7}),_instanceof:wh("instanceof",{beforeExpr:!0,binop:7}),_typeof:wh("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:wh("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:wh("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},Ih=/\r\n?|\n|\u2028|\u2029/,Ah=new RegExp(Ih.source,"g");function Th(t){return 10===t||13===t||8232===t||8233===t}function kh(t,e,n){void 0===n&&(n=t.length);for(var i=e;i>10),56320+(1023&t)))}var Uh=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Ph=function(t,e){this.line=t,this.column=e};Ph.prototype.offset=function(t){return new Ph(this.line,this.column+t)};var Rh=function(t,e,n){this.start=e,this.end=n,null!==t.sourceFile&&(this.source=t.sourceFile)};function jh(t,e){for(var n=1,i=0;;){var r=kh(t,i,e);if(r<0)return new Ph(n,e-i);++n,i=r}}var $h={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},zh=!1;function Hh(t){var e={};for(var n in $h)e[n]=t&&Oh(t,n)?t[n]:$h[n];if("latest"===e.ecmaVersion?e.ecmaVersion=1e8:null==e.ecmaVersion?(!zh&&"object"==typeof console&&console.warn&&(zh=!0,console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.")),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),null==e.allowReserved&&(e.allowReserved=e.ecmaVersion<5),t&&null!=t.allowHashBang||(e.allowHashBang=e.ecmaVersion>=14),Bh(e.onToken)){var i=e.onToken;e.onToken=function(t){return i.push(t)}}return Bh(e.onComment)&&(e.onComment=function(t,e){return function(n,i,r,s,a,o){var c={type:n?"Block":"Line",value:i,start:r,end:s};t.locations&&(c.loc=new Rh(this,a,o)),t.ranges&&(c.range=[r,s]),e.push(c)}}(e,e.onComment)),e}var qh=256;function Yh(t,e){return 2|(t?4:0)|(e?8:0)}var Gh=function(t,e,n){this.options=t=Hh(t),this.sourceFile=t.sourceFile,this.keywords=Fh(lh[t.ecmaVersion>=6?6:"module"===t.sourceType?"5module":5]);var i="";!0!==t.allowReserved&&(i=ch[t.ecmaVersion>=6?6:5===t.ecmaVersion?5:3],"module"===t.sourceType&&(i+=" await")),this.reservedWords=Fh(i);var r=(i?i+" ":"")+ch.strict;this.reservedWordsStrict=Fh(r),this.reservedWordsStrictBind=Fh(r+" "+ch.strictBind),this.input=String(e),this.containsEsc=!1,n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(Ih).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=Sh.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===t.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),0===this.pos&&t.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(1),this.regexpState=null,this.privateNameStack=[]},Wh={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};Gh.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)},Wh.inFunction.get=function(){return(2&this.currentVarScope().flags)>0},Wh.inGenerator.get=function(){return(8&this.currentVarScope().flags)>0&&!this.currentVarScope().inClassFieldInit},Wh.inAsync.get=function(){return(4&this.currentVarScope().flags)>0&&!this.currentVarScope().inClassFieldInit},Wh.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t];if(e.inClassFieldInit||e.flags&qh)return!1;if(2&e.flags)return(4&e.flags)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Wh.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags,n=t.inClassFieldInit;return(64&e)>0||n||this.options.allowSuperOutsideMethod},Wh.allowDirectSuper.get=function(){return(128&this.currentThisScope().flags)>0},Wh.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Wh.allowNewDotTarget.get=function(){var t=this.currentThisScope(),e=t.flags,n=t.inClassFieldInit;return(258&e)>0||n},Wh.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&qh)>0},Gh.extend=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var n=this,i=0;i=,?^&]/.test(r)||"!"===r&&"="===this.input.charAt(i+1))}t+=e[0].length,Mh.lastIndex=t,t+=Mh.exec(this.input)[0].length,";"===this.input[t]&&t++}},Kh.eat=function(t){return this.type===t&&(this.next(),!0)},Kh.isContextual=function(t){return this.type===Sh.name&&this.value===t&&!this.containsEsc},Kh.eatContextual=function(t){return!!this.isContextual(t)&&(this.next(),!0)},Kh.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},Kh.canInsertSemicolon=function(){return this.type===Sh.eof||this.type===Sh.braceR||Ih.test(this.input.slice(this.lastTokEnd,this.start))},Kh.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Kh.semicolon=function(){this.eat(Sh.semi)||this.insertSemicolon()||this.unexpected()},Kh.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0},Kh.expect=function(t){this.eat(t)||this.unexpected()},Kh.unexpected=function(t){this.raise(null!=t?t:this.start,"Unexpected token")};var Jh=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Kh.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var n=e?t.parenthesizedAssign:t.parenthesizedBind;n>-1&&this.raiseRecoverable(n,e?"Assigning to rvalue":"Parenthesized pattern")}},Kh.checkExpressionErrors=function(t,e){if(!t)return!1;var n=t.shorthandAssign,i=t.doubleProto;if(!e)return n>=0||i>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),i>=0&&this.raiseRecoverable(i,"Redefinition of __proto__ property")},Kh.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos55295&&i<56320)return!0;if(mh(i,!0)){for(var r=n+1;yh(i=this.input.charCodeAt(r),!0);)++r;if(92===i||i>55295&&i<56320)return!0;var s=this.input.slice(n,r);if(!hh.test(s))return!0}return!1},Zh.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;Mh.lastIndex=this.pos;var t,e=Mh.exec(this.input),n=this.pos+e[0].length;return!(Ih.test(this.input.slice(this.pos,n))||"function"!==this.input.slice(n,n+8)||n+8!==this.input.length&&(yh(t=this.input.charCodeAt(n+8))||t>55295&&t<56320))},Zh.parseStatement=function(t,e,n){var i,r=this.type,s=this.startNode();switch(this.isLet(t)&&(r=Sh._var,i="let"),r){case Sh._break:case Sh._continue:return this.parseBreakContinueStatement(s,r.keyword);case Sh._debugger:return this.parseDebuggerStatement(s);case Sh._do:return this.parseDoStatement(s);case Sh._for:return this.parseForStatement(s);case Sh._function:return t&&(this.strict||"if"!==t&&"label"!==t)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!t);case Sh._class:return t&&this.unexpected(),this.parseClass(s,!0);case Sh._if:return this.parseIfStatement(s);case Sh._return:return this.parseReturnStatement(s);case Sh._switch:return this.parseSwitchStatement(s);case Sh._throw:return this.parseThrowStatement(s);case Sh._try:return this.parseTryStatement(s);case Sh._const:case Sh._var:return i=i||this.value,t&&"var"!==i&&this.unexpected(),this.parseVarStatement(s,i);case Sh._while:return this.parseWhileStatement(s);case Sh._with:return this.parseWithStatement(s);case Sh.braceL:return this.parseBlock(!0,s);case Sh.semi:return this.parseEmptyStatement(s);case Sh._export:case Sh._import:if(this.options.ecmaVersion>10&&r===Sh._import){Mh.lastIndex=this.pos;var a=Mh.exec(this.input),o=this.pos+a[0].length,c=this.input.charCodeAt(o);if(40===c||46===c)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===Sh._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!t);var u=this.value,l=this.parseExpression();return r===Sh.name&&"Identifier"===l.type&&this.eat(Sh.colon)?this.parseLabeledStatement(s,u,l,t):this.parseExpressionStatement(s,l)}},Zh.parseBreakContinueStatement=function(t,e){var n="break"===e;this.next(),this.eat(Sh.semi)||this.insertSemicolon()?t.label=null:this.type!==Sh.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var i=0;i=6?this.eat(Sh.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")},Zh.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Xh),this.enterScope(0),this.expect(Sh.parenL),this.type===Sh.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var n=this.isLet();if(this.type===Sh._var||this.type===Sh._const||n){var i=this.startNode(),r=n?"let":this.value;return this.next(),this.parseVar(i,!0,r),this.finishNode(i,"VariableDeclaration"),(this.type===Sh._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===i.declarations.length?(this.options.ecmaVersion>=9&&(this.type===Sh._in?e>-1&&this.unexpected(e):t.await=e>-1),this.parseForIn(t,i)):(e>-1&&this.unexpected(e),this.parseFor(t,i))}var s=this.isContextual("let"),a=!1,o=new Jh,c=this.parseExpression(!(e>-1)||"await",o);return this.type===Sh._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(this.options.ecmaVersion>=9&&(this.type===Sh._in?e>-1&&this.unexpected(e):t.await=e>-1),s&&a&&this.raise(c.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(c,!1,o),this.checkLValPattern(c),this.parseForIn(t,c)):(this.checkExpressionErrors(o,!0),e>-1&&this.unexpected(e),this.parseFor(t,c))},Zh.parseFunctionStatement=function(t,e,n){return this.next(),this.parseFunction(t,np|(n?0:ip),!1,e)},Zh.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement("if"),t.alternate=this.eat(Sh._else)?this.parseStatement("if"):null,this.finishNode(t,"IfStatement")},Zh.parseReturnStatement=function(t){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(Sh.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")},Zh.parseSwitchStatement=function(t){var e;this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(Sh.braceL),this.labels.push(tp),this.enterScope(0);for(var n=!1;this.type!==Sh.braceR;)if(this.type===Sh._case||this.type===Sh._default){var i=this.type===Sh._case;e&&this.finishNode(e,"SwitchCase"),t.cases.push(e=this.startNode()),e.consequent=[],this.next(),i?e.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,e.test=null),this.expect(Sh.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")},Zh.parseThrowStatement=function(t){return this.next(),Ih.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var ep=[];Zh.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e="Identifier"===t.type;return this.enterScope(e?32:0),this.checkLValPattern(t,e?4:2),this.expect(Sh.parenR),t},Zh.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===Sh._catch){var e=this.startNode();this.next(),this.eat(Sh.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(Sh._finally)?this.parseBlock():null,t.handler||t.finalizer||this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")},Zh.parseVarStatement=function(t,e,n){return this.next(),this.parseVar(t,!1,e,n),this.semicolon(),this.finishNode(t,"VariableDeclaration")},Zh.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(Xh),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")},Zh.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement("with"),this.finishNode(t,"WithStatement")},Zh.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")},Zh.parseLabeledStatement=function(t,e,n,i){for(var r=0,s=this.labels;r=0;o--){var c=this.labels[o];if(c.statementStart!==t.start)break;c.statementStart=this.start,c.kind=a}return this.labels.push({name:e,kind:a,statementStart:this.start}),t.body=this.parseStatement(i?-1===i.indexOf("label")?i+"label":i:"label"),this.labels.pop(),t.label=n,this.finishNode(t,"LabeledStatement")},Zh.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")},Zh.parseBlock=function(t,e,n){for(void 0===t&&(t=!0),void 0===e&&(e=this.startNode()),e.body=[],this.expect(Sh.braceL),t&&this.enterScope(0);this.type!==Sh.braceR;){var i=this.parseStatement(null);e.body.push(i)}return n&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(e,"BlockStatement")},Zh.parseFor=function(t,e){return t.init=e,this.expect(Sh.semi),t.test=this.type===Sh.semi?null:this.parseExpression(),this.expect(Sh.semi),t.update=this.type===Sh.parenR?null:this.parseExpression(),this.expect(Sh.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,"ForStatement")},Zh.parseForIn=function(t,e){var n=this.type===Sh._in;return this.next(),"VariableDeclaration"===e.type&&null!=e.declarations[0].init&&(!n||this.options.ecmaVersion<8||this.strict||"var"!==e.kind||"Identifier"!==e.declarations[0].id.type)&&this.raise(e.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),t.left=e,t.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(Sh.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,n?"ForInStatement":"ForOfStatement")},Zh.parseVar=function(t,e,n,i){for(t.declarations=[],t.kind=n;;){var r=this.startNode();if(this.parseVarId(r,n),this.eat(Sh.eq)?r.init=this.parseMaybeAssign(e):i||"const"!==n||this.type===Sh._in||this.options.ecmaVersion>=6&&this.isContextual("of")?i||"Identifier"===r.id.type||e&&(this.type===Sh._in||this.isContextual("of"))?r.init=null:this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):this.unexpected(),t.declarations.push(this.finishNode(r,"VariableDeclarator")),!this.eat(Sh.comma))break}return t},Zh.parseVarId=function(t,e){t.id=this.parseBindingAtom(),this.checkLValPattern(t.id,"var"===e?1:2,!1)};var np=1,ip=2;function rp(t,e){var n=e.key.name,i=t[n],r="true";return"MethodDefinition"!==e.type||"get"!==e.kind&&"set"!==e.kind||(r=(e.static?"s":"i")+e.kind),"iget"===i&&"iset"===r||"iset"===i&&"iget"===r||"sget"===i&&"sset"===r||"sset"===i&&"sget"===r?(t[n]="true",!1):!!i||(t[n]=r,!1)}function sp(t,e){var n=t.computed,i=t.key;return!n&&("Identifier"===i.type&&i.name===e||"Literal"===i.type&&i.value===e)}Zh.parseFunction=function(t,e,n,i,r){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!i)&&(this.type===Sh.star&&e&ip&&this.unexpected(),t.generator=this.eat(Sh.star)),this.options.ecmaVersion>=8&&(t.async=!!i),e&np&&(t.id=4&e&&this.type!==Sh.name?null:this.parseIdent(),!t.id||e&ip||this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?1:2:3));var s=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Yh(t.async,t.generator)),e&np||(t.id=this.type===Sh.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,n,!1,r),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(t,e&np?"FunctionDeclaration":"FunctionExpression")},Zh.parseFunctionParams=function(t){this.expect(Sh.parenL),t.params=this.parseBindingList(Sh.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},Zh.parseClass=function(t,e){this.next();var n=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var i=this.enterClassBody(),r=this.startNode(),s=!1;for(r.body=[],this.expect(Sh.braceL);this.type!==Sh.braceR;){var a=this.parseClassElement(null!==t.superClass);a&&(r.body.push(a),"MethodDefinition"===a.type&&"constructor"===a.kind?(s&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),s=!0):a.key&&"PrivateIdentifier"===a.key.type&&rp(i,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=n,this.next(),t.body=this.finishNode(r,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")},Zh.parseClassElement=function(t){if(this.eat(Sh.semi))return null;var e=this.options.ecmaVersion,n=this.startNode(),i="",r=!1,s=!1,a="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(Sh.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===Sh.star?o=!0:i="static"}if(n.static=o,!i&&e>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==Sh.star||this.canInsertSemicolon()?i="async":s=!0),!i&&(e>=9||!s)&&this.eat(Sh.star)&&(r=!0),!i&&!s&&!r){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=c:i=c)}if(i?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=i,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),e<13||this.type===Sh.parenL||"method"!==a||r||s){var u=!n.static&&sp(n,"constructor"),l=u&&t;u&&"method"!==a&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=u?"constructor":a,this.parseClassMethod(n,r,s,l)}else this.parseClassField(n);return n},Zh.isClassElementNameStart=function(){return this.type===Sh.name||this.type===Sh.privateId||this.type===Sh.num||this.type===Sh.string||this.type===Sh.bracketL||this.type.keyword},Zh.parseClassElementName=function(t){this.type===Sh.privateId?("constructor"===this.value&&this.raise(this.start,"Classes can't have an element named '#constructor'"),t.computed=!1,t.key=this.parsePrivateIdent()):this.parsePropertyName(t)},Zh.parseClassMethod=function(t,e,n,i){var r=t.key;"constructor"===t.kind?(e&&this.raise(r.start,"Constructor can't be a generator"),n&&this.raise(r.start,"Constructor can't be an async method")):t.static&&sp(t,"prototype")&&this.raise(r.start,"Classes may not have a static property named prototype");var s=t.value=this.parseMethod(e,n,i);return"get"===t.kind&&0!==s.params.length&&this.raiseRecoverable(s.start,"getter should have no params"),"set"===t.kind&&1!==s.params.length&&this.raiseRecoverable(s.start,"setter should have exactly one param"),"set"===t.kind&&"RestElement"===s.params[0].type&&this.raiseRecoverable(s.params[0].start,"Setter cannot use rest params"),this.finishNode(t,"MethodDefinition")},Zh.parseClassField=function(t){if(sp(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&&sp(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(Sh.eq)){var e=this.currentThisScope(),n=e.inClassFieldInit;e.inClassFieldInit=!0,t.value=this.parseMaybeAssign(),e.inClassFieldInit=n}else t.value=null;return this.semicolon(),this.finishNode(t,"PropertyDefinition")},Zh.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(320);this.type!==Sh.braceR;){var n=this.parseStatement(null);t.body.push(n)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(t,"StaticBlock")},Zh.parseClassId=function(t,e){this.type===Sh.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,2,!1)):(!0===e&&this.unexpected(),t.id=null)},Zh.parseClassSuper=function(t){t.superClass=this.eat(Sh._extends)?this.parseExprSubscripts(null,!1):null},Zh.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared},Zh.exitClassBody=function(){var t=this.privateNameStack.pop(),e=t.declared,n=t.used;if(this.options.checkPrivateFields)for(var i=this.privateNameStack.length,r=0===i?null:this.privateNameStack[i-1],s=0;s=11&&(this.eatContextual("as")?(t.exported=this.parseModuleExportName(),this.checkExport(e,t.exported,this.lastTokStart)):t.exported=null),this.expectContextual("from"),this.type!==Sh.string&&this.unexpected(),t.source=this.parseExprAtom(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")},Zh.parseExport=function(t,e){if(this.next(),this.eat(Sh.star))return this.parseExportAllDeclaration(t,e);if(this.eat(Sh._default))return this.checkExport(e,"default",this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())t.declaration=this.parseExportDeclaration(t),"VariableDeclaration"===t.declaration.type?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==Sh.string&&this.unexpected(),t.source=this.parseExprAtom();else{for(var n=0,i=t.specifiers;n=13&&this.type===Sh.string){var t=this.parseLiteral(this.value);return Uh.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)},Zh.adaptDirectivePrologue=function(t){for(var e=0;e=5&&"ExpressionStatement"===t.type&&"Literal"===t.expression.type&&"string"==typeof t.expression.value&&('"'===this.input[t.start]||"'"===this.input[t.start])};var ap=Gh.prototype;ap.toAssignable=function(t,e,n){if(this.options.ecmaVersion>=6&&t)switch(t.type){case"Identifier":this.inAsync&&"await"===t.name&&this.raise(t.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var i=0,r=t.properties;i=8&&!o&&"async"===c.name&&!this.canInsertSemicolon()&&this.eat(Sh._function))return this.overrideContext(cp.f_expr),this.parseFunction(this.startNodeAt(s,a),0,!1,!0,e);if(r&&!this.canInsertSemicolon()){if(this.eat(Sh.arrow))return this.parseArrowExpression(this.startNodeAt(s,a),[c],!1,e);if(this.options.ecmaVersion>=8&&"async"===c.name&&this.type===Sh.name&&!o&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return c=this.parseIdent(!1),!this.canInsertSemicolon()&&this.eat(Sh.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(s,a),[c],!0,e)}return c;case Sh.regexp:var u=this.value;return(i=this.parseLiteral(u.value)).regex={pattern:u.pattern,flags:u.flags},i;case Sh.num:case Sh.string:return this.parseLiteral(this.value);case Sh._null:case Sh._true:case Sh._false:return(i=this.startNode()).value=this.type===Sh._null?null:this.type===Sh._true,i.raw=this.type.keyword,this.next(),this.finishNode(i,"Literal");case Sh.parenL:var l=this.start,h=this.parseParenAndDistinguishExpression(r,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(t.parenthesizedAssign=l),t.parenthesizedBind<0&&(t.parenthesizedBind=l)),h;case Sh.bracketL:return i=this.startNode(),this.next(),i.elements=this.parseExprList(Sh.bracketR,!0,!0,t),this.finishNode(i,"ArrayExpression");case Sh.braceL:return this.overrideContext(cp.b_expr),this.parseObj(!1,t);case Sh._function:return i=this.startNode(),this.next(),this.parseFunction(i,0);case Sh._class:return this.parseClass(this.startNode(),!1);case Sh._new:return this.parseNew();case Sh.backQuote:return this.parseTemplate();case Sh._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},lp.parseExprAtomDefault=function(){this.unexpected()},lp.parseExprImport=function(t){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===Sh.parenL&&!t)return this.parseDynamicImport(e);if(this.type===Sh.dot){var n=this.startNodeAt(e.start,e.loc&&e.loc.start);return n.name="import",e.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(e)}this.unexpected()},lp.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),!this.eat(Sh.parenR)){var e=this.start;this.eat(Sh.comma)&&this.eat(Sh.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(t,"ImportExpression")},lp.parseImportMeta=function(t){this.next();var e=this.containsEsc;return t.property=this.parseIdent(!0),"meta"!==t.property.name&&this.raiseRecoverable(t.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(t.start,"'import.meta' must not contain escaped characters"),"module"===this.options.sourceType||this.options.allowImportExportEverywhere||this.raiseRecoverable(t.start,"Cannot use 'import.meta' outside a module"),this.finishNode(t,"MetaProperty")},lp.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),110===e.raw.charCodeAt(e.raw.length-1)&&(e.bigint=e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")},lp.parseParenExpression=function(){this.expect(Sh.parenL);var t=this.parseExpression();return this.expect(Sh.parenR),t},lp.shouldParseArrow=function(t){return!this.canInsertSemicolon()},lp.parseParenAndDistinguishExpression=function(t,e){var n,i=this.start,r=this.startLoc,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,c=this.startLoc,u=[],l=!0,h=!1,p=new Jh,d=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==Sh.parenR;){if(l?l=!1:this.expect(Sh.comma),s&&this.afterTrailingComma(Sh.parenR,!0)){h=!0;break}if(this.type===Sh.ellipsis){a=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===Sh.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}u.push(this.parseMaybeAssign(!1,p,this.parseParenItem))}var m=this.lastTokEnd,y=this.lastTokEndLoc;if(this.expect(Sh.parenR),t&&this.shouldParseArrow(u)&&this.eat(Sh.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=d,this.awaitPos=f,this.parseParenArrowList(i,r,u,e);u.length&&!h||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(p,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=f||this.awaitPos,u.length>1?((n=this.startNodeAt(o,c)).expressions=u,this.finishNodeAt(n,"SequenceExpression",m,y)):n=u[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var g=this.startNodeAt(i,r);return g.expression=n,this.finishNode(g,"ParenthesizedExpression")}return n},lp.parseParenItem=function(t){return t},lp.parseParenArrowList=function(t,e,n,i){return this.parseArrowExpression(this.startNodeAt(t,e),n,!1,i)};var pp=[];lp.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var t=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===Sh.dot){var e=this.startNodeAt(t.start,t.loc&&t.loc.start);e.name="new",t.meta=this.finishNode(e,"Identifier"),this.next();var n=this.containsEsc;return t.property=this.parseIdent(!0),"target"!==t.property.name&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(t.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(t.start,"'new.target' can only be used in functions and class static block"),this.finishNode(t,"MetaProperty")}var i=this.start,r=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),i,r,!0,!1),this.eat(Sh.parenL)?t.arguments=this.parseExprList(Sh.parenR,this.options.ecmaVersion>=8,!1):t.arguments=pp,this.finishNode(t,"NewExpression")},lp.parseTemplateElement=function(t){var e=t.isTagged,n=this.startNode();return this.type===Sh.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value,cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===Sh.backQuote,this.finishNode(n,"TemplateElement")},lp.parseTemplate=function(t){void 0===t&&(t={});var e=t.isTagged;void 0===e&&(e=!1);var n=this.startNode();this.next(),n.expressions=[];var i=this.parseTemplateElement({isTagged:e});for(n.quasis=[i];!i.tail;)this.type===Sh.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(Sh.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(Sh.braceR),n.quasis.push(i=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(n,"TemplateLiteral")},lp.isAsyncProp=function(t){return!t.computed&&"Identifier"===t.key.type&&"async"===t.key.name&&(this.type===Sh.name||this.type===Sh.num||this.type===Sh.string||this.type===Sh.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===Sh.star)&&!Ih.test(this.input.slice(this.lastTokEnd,this.start))},lp.parseObj=function(t,e){var n=this.startNode(),i=!0,r={};for(n.properties=[],this.next();!this.eat(Sh.braceR);){if(i)i=!1;else if(this.expect(Sh.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(Sh.braceR))break;var s=this.parseProperty(t,e);t||this.checkPropClash(s,r,e),n.properties.push(s)}return this.finishNode(n,t?"ObjectPattern":"ObjectExpression")},lp.parseProperty=function(t,e){var n,i,r,s,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(Sh.ellipsis))return t?(a.argument=this.parseIdent(!1),this.type===Sh.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(a.argument=this.parseMaybeAssign(!1,e),this.type===Sh.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(t||e)&&(r=this.start,s=this.startLoc),t||(n=this.eat(Sh.star)));var o=this.containsEsc;return this.parsePropertyName(a),!t&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(i=!0,n=this.options.ecmaVersion>=9&&this.eat(Sh.star),this.parsePropertyName(a)):i=!1,this.parsePropertyValue(a,t,n,i,r,s,e,o),this.finishNode(a,"Property")},lp.parseGetterSetter=function(t){t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var e="get"===t.kind?0:1;if(t.value.params.length!==e){var n=t.value.start;"get"===t.kind?this.raiseRecoverable(n,"getter should have no params"):this.raiseRecoverable(n,"setter should have exactly one param")}else"set"===t.kind&&"RestElement"===t.value.params[0].type&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")},lp.parsePropertyValue=function(t,e,n,i,r,s,a,o){(n||i)&&this.type===Sh.colon&&this.unexpected(),this.eat(Sh.colon)?(t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init"):this.options.ecmaVersion>=6&&this.type===Sh.parenL?(e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(n,i)):e||o||!(this.options.ecmaVersion>=5)||t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||this.type===Sh.comma||this.type===Sh.braceR||this.type===Sh.eq?this.options.ecmaVersion>=6&&!t.computed&&"Identifier"===t.key.type?((n||i)&&this.unexpected(),this.checkUnreserved(t.key),"await"!==t.key.name||this.awaitIdentPos||(this.awaitIdentPos=r),t.kind="init",e?t.value=this.parseMaybeDefault(r,s,this.copyNode(t.key)):this.type===Sh.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(r,s,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.shorthand=!0):this.unexpected():((n||i)&&this.unexpected(),this.parseGetterSetter(t))},lp.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(Sh.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(Sh.bracketR),t.key;t.computed=!1}return t.key=this.type===Sh.num||this.type===Sh.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},lp.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},lp.parseMethod=function(t,e,n){var i=this.startNode(),r=this.yieldPos,s=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(i),this.options.ecmaVersion>=6&&(i.generator=t),this.options.ecmaVersion>=8&&(i.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(64|Yh(e,i.generator)|(n?128:0)),this.expect(Sh.parenL),i.params=this.parseBindingList(Sh.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(i,!1,!0,!1),this.yieldPos=r,this.awaitPos=s,this.awaitIdentPos=a,this.finishNode(i,"FunctionExpression")},lp.parseArrowExpression=function(t,e,n,i){var r=this.yieldPos,s=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(16|Yh(n,!1)),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0,!1,i),this.yieldPos=r,this.awaitPos=s,this.awaitIdentPos=a,this.finishNode(t,"ArrowFunctionExpression")},lp.parseFunctionBody=function(t,e,n,i){var r=e&&this.type!==Sh.braceL,s=this.strict,a=!1;if(r)t.body=this.parseMaybeAssign(i),t.expression=!0,this.checkParams(t,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);s&&!o||(a=this.strictDirective(this.end))&&o&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list");var c=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(t,!s&&!a&&!e&&!n&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,5),t.body=this.parseBlock(!1,void 0,a&&!s),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=c}this.exitScope()},lp.isSimpleParamList=function(t){for(var e=0,n=t;e-1||r.functions.indexOf(t)>-1||r.var.indexOf(t)>-1,r.lexical.push(t),this.inModule&&1&r.flags&&delete this.undefinedExports[t]}else if(4===e){this.currentScope().lexical.push(t)}else if(3===e){var s=this.currentScope();i=this.treatFunctionsAsVar?s.lexical.indexOf(t)>-1:s.lexical.indexOf(t)>-1||s.var.indexOf(t)>-1,s.functions.push(t)}else for(var a=this.scopeStack.length-1;a>=0;--a){var o=this.scopeStack[a];if(o.lexical.indexOf(t)>-1&&!(32&o.flags&&o.lexical[0]===t)||!this.treatFunctionsAsVarInScope(o)&&o.functions.indexOf(t)>-1){i=!0;break}if(o.var.push(t),this.inModule&&1&o.flags&&delete this.undefinedExports[t],259&o.flags)break}i&&this.raiseRecoverable(n,"Identifier '"+t+"' has already been declared")},fp.checkLocalExport=function(t){-1===this.scopeStack[0].lexical.indexOf(t.name)&&-1===this.scopeStack[0].var.indexOf(t.name)&&(this.undefinedExports[t.name]=t)},fp.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},fp.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(259&e.flags)return e}},fp.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(259&e.flags&&!(16&e.flags))return e}};var yp=function(t,e,n){this.type="",this.start=e,this.end=0,t.options.locations&&(this.loc=new Rh(t,n)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[e,0])},gp=Gh.prototype;function bp(t,e,n,i){return t.type=e,t.end=n,this.options.locations&&(t.loc.end=i),this.options.ranges&&(t.range[1]=n),t}gp.startNode=function(){return new yp(this,this.start,this.startLoc)},gp.startNodeAt=function(t,e){return new yp(this,t,e)},gp.finishNode=function(t,e){return bp.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)},gp.finishNodeAt=function(t,e,n,i){return bp.call(this,t,e,n,i)},gp.copyNode=function(t){var e=new yp(this,t.start,this.startLoc);for(var n in t)e[n]=t[n];return e};var vp="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",_p=vp+" Extended_Pictographic",xp=_p+" EBase EComp EMod EPres ExtPict",wp={9:vp,10:_p,11:_p,12:xp,13:xp,14:xp},Sp={9:"",10:"",11:"",12:"",13:"",14:"Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji"},Ip="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",Ap="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Tp=Ap+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",kp=Tp+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Cp=kp+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Mp=Cp+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Ep={9:Ap,10:Tp,11:kp,12:Cp,13:Mp,14:Mp+" Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz"},Np={};function Dp(t){var e=Np[t]={binary:Fh(wp[t]+" "+Ip),binaryOfStrings:Fh(Sp[t]),nonBinary:{General_Category:Fh(Ip),Script:Fh(Ep[t])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var Op=0,Bp=[9,10,11,12,13,14];Op=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Np[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=[],this.backReferenceNames=[]};function Vp(t){return 36===t||t>=40&&t<=43||46===t||63===t||t>=91&&t<=94||t>=123&&t<=125}function Up(t){return t>=65&&t<=90||t>=97&&t<=122}Fp.prototype.reset=function(t,e,n){var i=-1!==n.indexOf("v"),r=-1!==n.indexOf("u");this.start=0|t,this.source=e+"",this.flags=n,i&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=r&&this.parser.options.ecmaVersion>=9)},Fp.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)},Fp.prototype.at=function(t,e){void 0===e&&(e=!1);var n=this.source,i=n.length;if(t>=i)return-1;var r=n.charCodeAt(t);if(!e&&!this.switchU||r<=55295||r>=57344||t+1>=i)return r;var s=n.charCodeAt(t+1);return s>=56320&&s<=57343?(r<<10)+s-56613888:r},Fp.prototype.nextIndex=function(t,e){void 0===e&&(e=!1);var n=this.source,i=n.length;if(t>=i)return i;var r,s=n.charCodeAt(t);return!e&&!this.switchU||s<=55295||s>=57344||t+1>=i||(r=n.charCodeAt(t+1))<56320||r>57343?t+1:t+2},Fp.prototype.current=function(t){return void 0===t&&(t=!1),this.at(this.pos,t)},Fp.prototype.lookahead=function(t){return void 0===t&&(t=!1),this.at(this.nextIndex(this.pos,t),t)},Fp.prototype.advance=function(t){void 0===t&&(t=!1),this.pos=this.nextIndex(this.pos,t)},Fp.prototype.eat=function(t,e){return void 0===e&&(e=!1),this.current(e)===t&&(this.advance(e),!0)},Fp.prototype.eatChars=function(t,e){void 0===e&&(e=!1);for(var n=this.pos,i=0,r=t;i-1&&this.raise(t.start,"Duplicate regular expression flag"),"u"===a&&(i=!0),"v"===a&&(r=!0)}this.options.ecmaVersion>=15&&i&&r&&this.raise(t.start,"Invalid regular expression flag")},Lp.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&t.groupNames.length>0&&(t.switchN=!0,this.regexp_pattern(t))},Lp.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames.length=0,t.backReferenceNames.length=0,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,n=t.backReferenceNames;e=9&&(n=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!n,!0}return t.pos=e,!1},Lp.regexp_eatQuantifier=function(t,e){return void 0===e&&(e=!1),!!this.regexp_eatQuantifierPrefix(t,e)&&(t.eat(63),!0)},Lp.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)},Lp.regexp_eatBracedQuantifier=function(t,e){var n=t.pos;if(t.eat(123)){var i=0,r=-1;if(this.regexp_eatDecimalDigits(t)&&(i=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue),t.eat(125)))return-1!==r&&r=9?this.regexp_groupSpecifier(t):63===t.current()&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1},Lp.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)},Lp.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1},Lp.regexp_eatSyntaxCharacter=function(t){var e=t.current();return!!Vp(e)&&(t.lastIntValue=e,t.advance(),!0)},Lp.regexp_eatPatternCharacters=function(t){for(var e=t.pos,n=0;-1!==(n=t.current())&&!Vp(n);)t.advance();return t.pos!==e},Lp.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return!(-1===e||36===e||e>=40&&e<=43||46===e||63===e||91===e||94===e||124===e)&&(t.advance(),!0)},Lp.regexp_groupSpecifier=function(t){if(t.eat(63)){if(this.regexp_eatGroupName(t))return-1!==t.groupNames.indexOf(t.lastStringValue)&&t.raise("Duplicate capture group name"),void t.groupNames.push(t.lastStringValue);t.raise("Invalid group")}},Lp.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1},Lp.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=Vh(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=Vh(t.lastIntValue);return!0}return!1},Lp.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,n=this.options.ecmaVersion>=11,i=t.current(n);return t.advance(n),92===i&&this.regexp_eatRegExpUnicodeEscapeSequence(t,n)&&(i=t.lastIntValue),function(t){return mh(t,!0)||36===t||95===t}(i)?(t.lastIntValue=i,!0):(t.pos=e,!1)},Lp.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,n=this.options.ecmaVersion>=11,i=t.current(n);return t.advance(n),92===i&&this.regexp_eatRegExpUnicodeEscapeSequence(t,n)&&(i=t.lastIntValue),function(t){return yh(t,!0)||36===t||95===t||8204===t||8205===t}(i)?(t.lastIntValue=i,!0):(t.pos=e,!1)},Lp.regexp_eatAtomEscape=function(t){return!!(this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t))||(t.switchU&&(99===t.current()&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)},Lp.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var n=t.lastIntValue;if(t.switchU)return n>t.maxBackReference&&(t.maxBackReference=n),!0;if(n<=t.numCapturingParens)return!0;t.pos=e}return!1},Lp.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1},Lp.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t,!1)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)},Lp.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1},Lp.regexp_eatZero=function(t){return 48===t.current()&&!jp(t.lookahead())&&(t.lastIntValue=0,t.advance(),!0)},Lp.regexp_eatControlEscape=function(t){var e=t.current();return 116===e?(t.lastIntValue=9,t.advance(),!0):110===e?(t.lastIntValue=10,t.advance(),!0):118===e?(t.lastIntValue=11,t.advance(),!0):102===e?(t.lastIntValue=12,t.advance(),!0):114===e&&(t.lastIntValue=13,t.advance(),!0)},Lp.regexp_eatControlLetter=function(t){var e=t.current();return!!Up(e)&&(t.lastIntValue=e%32,t.advance(),!0)},Lp.regexp_eatRegExpUnicodeEscapeSequence=function(t,e){void 0===e&&(e=!1);var n,i=t.pos,r=e||t.switchU;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var s=t.lastIntValue;if(r&&s>=55296&&s<=56319){var a=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var o=t.lastIntValue;if(o>=56320&&o<=57343)return t.lastIntValue=1024*(s-55296)+(o-56320)+65536,!0}t.pos=a,t.lastIntValue=s}return!0}if(r&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&((n=t.lastIntValue)>=0&&n<=1114111))return!0;r&&t.raise("Invalid unicode escape"),t.pos=i}return!1},Lp.regexp_eatIdentityEscape=function(t){if(t.switchU)return!!this.regexp_eatSyntaxCharacter(t)||!!t.eat(47)&&(t.lastIntValue=47,!0);var e=t.current();return!(99===e||t.switchN&&107===e)&&(t.lastIntValue=e,t.advance(),!0)},Lp.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do{t.lastIntValue=10*t.lastIntValue+(e-48),t.advance()}while((e=t.current())>=48&&e<=57);return!0}return!1};function Pp(t){return Up(t)||95===t}function Rp(t){return Pp(t)||jp(t)}function jp(t){return t>=48&&t<=57}function $p(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function zp(t){return t>=65&&t<=70?t-65+10:t>=97&&t<=102?t-97+10:t-48}function Hp(t){return t>=48&&t<=55}Lp.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(function(t){return 100===t||68===t||115===t||83===t||119===t||87===t}(e))return t.lastIntValue=-1,t.advance(),1;var n=!1;if(t.switchU&&this.options.ecmaVersion>=9&&((n=80===e)||112===e)){var i;if(t.lastIntValue=-1,t.advance(),t.eat(123)&&(i=this.regexp_eatUnicodePropertyValueExpression(t))&&t.eat(125))return n&&2===i&&t.raise("Invalid property name"),i;t.raise("Invalid property name")}return 0},Lp.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var n=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var i=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,n,i),1}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,r)}return 0},Lp.regexp_validateUnicodePropertyNameAndValue=function(t,e,n){Oh(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(n)||t.raise("Invalid property value")},Lp.regexp_validateUnicodePropertyNameOrValue=function(t,e){return t.unicodeProperties.binary.test(e)?1:t.switchV&&t.unicodeProperties.binaryOfStrings.test(e)?2:void t.raise("Invalid property name")},Lp.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";Pp(e=t.current());)t.lastStringValue+=Vh(e),t.advance();return""!==t.lastStringValue},Lp.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";Rp(e=t.current());)t.lastStringValue+=Vh(e),t.advance();return""!==t.lastStringValue},Lp.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)},Lp.regexp_eatCharacterClass=function(t){if(t.eat(91)){var e=t.eat(94),n=this.regexp_classContents(t);return t.eat(93)||t.raise("Unterminated character class"),e&&2===n&&t.raise("Negated character class may contain strings"),!0}return!1},Lp.regexp_classContents=function(t){return 93===t.current()?1:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),1)},Lp.regexp_nonEmptyClassRanges=function(t){for(;this.regexp_eatClassAtom(t);){var e=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassAtom(t)){var n=t.lastIntValue;!t.switchU||-1!==e&&-1!==n||t.raise("Invalid character class"),-1!==e&&-1!==n&&e>n&&t.raise("Range out of order in character class")}}},Lp.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var n=t.current();(99===n||Hp(n))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var i=t.current();return 93!==i&&(t.lastIntValue=i,t.advance(),!0)},Lp.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)},Lp.regexp_classSetExpression=function(t){var e,n=1;if(this.regexp_eatClassSetRange(t));else if(e=this.regexp_eatClassSetOperand(t)){2===e&&(n=2);for(var i=t.pos;t.eatChars([38,38]);)38!==t.current()&&(e=this.regexp_eatClassSetOperand(t))?2!==e&&(n=1):t.raise("Invalid character in character class");if(i!==t.pos)return n;for(;t.eatChars([45,45]);)this.regexp_eatClassSetOperand(t)||t.raise("Invalid character in character class");if(i!==t.pos)return n}else t.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(t)){if(!(e=this.regexp_eatClassSetOperand(t)))return n;2===e&&(n=2)}},Lp.regexp_eatClassSetRange=function(t){var e=t.pos;if(this.regexp_eatClassSetCharacter(t)){var n=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassSetCharacter(t)){var i=t.lastIntValue;return-1!==n&&-1!==i&&n>i&&t.raise("Range out of order in character class"),!0}t.pos=e}return!1},Lp.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?1:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)},Lp.regexp_eatNestedClass=function(t){var e=t.pos;if(t.eat(91)){var n=t.eat(94),i=this.regexp_classContents(t);if(t.eat(93))return n&&2===i&&t.raise("Negated character class may contain strings"),i;t.pos=e}if(t.eat(92)){var r=this.regexp_eatCharacterClassEscape(t);if(r)return r;t.pos=e}return null},Lp.regexp_eatClassStringDisjunction=function(t){var e=t.pos;if(t.eatChars([92,113])){if(t.eat(123)){var n=this.regexp_classStringDisjunctionContents(t);if(t.eat(125))return n}else t.raise("Invalid escape");t.pos=e}return null},Lp.regexp_classStringDisjunctionContents=function(t){for(var e=this.regexp_classString(t);t.eat(124);)2===this.regexp_classString(t)&&(e=2);return e},Lp.regexp_classString=function(t){for(var e=0;this.regexp_eatClassSetCharacter(t);)e++;return 1===e?1:2},Lp.regexp_eatClassSetCharacter=function(t){var e=t.pos;if(t.eat(92))return!(!this.regexp_eatCharacterEscape(t)&&!this.regexp_eatClassSetReservedPunctuator(t))||(t.eat(98)?(t.lastIntValue=8,!0):(t.pos=e,!1));var n=t.current();return!(n<0||n===t.lookahead()&&function(t){return 33===t||t>=35&&t<=38||t>=42&&t<=44||46===t||t>=58&&t<=64||94===t||96===t||126===t}(n))&&(!function(t){return 40===t||41===t||45===t||47===t||t>=91&&t<=93||t>=123&&t<=125}(n)&&(t.advance(),t.lastIntValue=n,!0))},Lp.regexp_eatClassSetReservedPunctuator=function(t){var e=t.current();return!!function(t){return 33===t||35===t||37===t||38===t||44===t||45===t||t>=58&&t<=62||64===t||96===t||126===t}(e)&&(t.lastIntValue=e,t.advance(),!0)},Lp.regexp_eatClassControlLetter=function(t){var e=t.current();return!(!jp(e)&&95!==e)&&(t.lastIntValue=e%32,t.advance(),!0)},Lp.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1},Lp.regexp_eatDecimalDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;jp(n=t.current());)t.lastIntValue=10*t.lastIntValue+(n-48),t.advance();return t.pos!==e},Lp.regexp_eatHexDigits=function(t){var e=t.pos,n=0;for(t.lastIntValue=0;$p(n=t.current());)t.lastIntValue=16*t.lastIntValue+zp(n),t.advance();return t.pos!==e},Lp.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var n=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=64*e+8*n+t.lastIntValue:t.lastIntValue=8*e+n}else t.lastIntValue=e;return!0}return!1},Lp.regexp_eatOctalDigit=function(t){var e=t.current();return Hp(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)},Lp.regexp_eatFixedHexDigits=function(t,e){var n=t.pos;t.lastIntValue=0;for(var i=0;i=this.input.length?this.finishToken(Sh.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},Yp.readToken=function(t){return mh(t,this.options.ecmaVersion>=6)||92===t?this.readWord():this.getTokenFromCode(t)},Yp.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);if(t<=55295||t>=56320)return t;var e=this.input.charCodeAt(this.pos+1);return e<=56319||e>=57344?t:(t<<10)+e-56613888},Yp.skipBlockComment=function(){var t=this.options.onComment&&this.curPosition(),e=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(-1===n&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var i=void 0,r=e;(i=kh(this.input,r,this.pos))>-1;)++this.curLine,r=this.lineStart=i;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,n),e,this.pos,t,this.curPosition())},Yp.skipLineComment=function(t){for(var e=this.pos,n=this.options.onComment&&this.curPosition(),i=this.input.charCodeAt(this.pos+=t);this.pos8&&t<14||t>=5760&&Ch.test(String.fromCharCode(t))))break t;++this.pos}}},Yp.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=t,this.value=e,this.updateContext(n)},Yp.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===t&&46===e?(this.pos+=3,this.finishToken(Sh.ellipsis)):(++this.pos,this.finishToken(Sh.dot))},Yp.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===t?this.finishOp(Sh.assign,2):this.finishOp(Sh.slash,1)},Yp.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),n=1,i=42===t?Sh.star:Sh.modulo;return this.options.ecmaVersion>=7&&42===t&&42===e&&(++n,i=Sh.starstar,e=this.input.charCodeAt(this.pos+2)),61===e?this.finishOp(Sh.assign,n+1):this.finishOp(i,n)},Yp.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);if(e===t){if(this.options.ecmaVersion>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(Sh.assign,3);return this.finishOp(124===t?Sh.logicalOR:Sh.logicalAND,2)}return 61===e?this.finishOp(Sh.assign,2):this.finishOp(124===t?Sh.bitwiseOR:Sh.bitwiseAND,1)},Yp.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(Sh.assign,2):this.finishOp(Sh.bitwiseXOR,1)},Yp.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?45!==e||this.inModule||62!==this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!Ih.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(Sh.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===e?this.finishOp(Sh.assign,2):this.finishOp(Sh.plusMin,1)},Yp.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),n=1;return e===t?(n=62===t&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(Sh.assign,n+1):this.finishOp(Sh.bitShift,n)):33!==e||60!==t||this.inModule||45!==this.input.charCodeAt(this.pos+2)||45!==this.input.charCodeAt(this.pos+3)?(61===e&&(n=2),this.finishOp(Sh.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},Yp.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(Sh.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===t&&62===e&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(Sh.arrow)):this.finishOp(61===t?Sh.eq:Sh.prefix,1)},Yp.readToken_question=function(){var t=this.options.ecmaVersion;if(t>=11){var e=this.input.charCodeAt(this.pos+1);if(46===e){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(Sh.questionDot,2)}if(63===e){if(t>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(Sh.assign,3);return this.finishOp(Sh.coalesce,2)}}return this.finishOp(Sh.question,1)},Yp.readToken_numberSign=function(){var t=35;if(this.options.ecmaVersion>=13&&(++this.pos,mh(t=this.fullCharCodeAtPos(),!0)||92===t))return this.finishToken(Sh.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Vh(t)+"'")},Yp.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(Sh.parenL);case 41:return++this.pos,this.finishToken(Sh.parenR);case 59:return++this.pos,this.finishToken(Sh.semi);case 44:return++this.pos,this.finishToken(Sh.comma);case 91:return++this.pos,this.finishToken(Sh.bracketL);case 93:return++this.pos,this.finishToken(Sh.bracketR);case 123:return++this.pos,this.finishToken(Sh.braceL);case 125:return++this.pos,this.finishToken(Sh.braceR);case 58:return++this.pos,this.finishToken(Sh.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(Sh.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(120===e||88===e)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===e||79===e)return this.readRadixNumber(8);if(98===e||66===e)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 63:return this.readToken_question();case 126:return this.finishOp(Sh.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Vh(t)+"'")},Yp.finishOp=function(t,e){var n=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,n)},Yp.readRegexp=function(){for(var t,e,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var i=this.input.charAt(this.pos);if(Ih.test(i)&&this.raise(n,"Unterminated regular expression"),t)t=!1;else{if("["===i)e=!0;else if("]"===i&&e)e=!1;else if("/"===i&&!e)break;t="\\"===i}++this.pos}var r=this.input.slice(n,this.pos);++this.pos;var s=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(s);var o=this.regexpState||(this.regexpState=new Fp(this));o.reset(n,r,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(r,a)}catch(t){}return this.finishToken(Sh.regexp,{pattern:r,flags:a,value:c})},Yp.readInt=function(t,e,n){for(var i=this.options.ecmaVersion>=12&&void 0===e,r=n&&48===this.input.charCodeAt(this.pos),s=this.pos,a=0,o=0,c=0,u=null==e?1/0:e;c=97?l-97+10:l>=65?l-65+10:l>=48&&l<=57?l-48:1/0)>=t)break;o=l,a=a*t+h}}return i&&95===o&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===s||null!=e&&this.pos-s!==e?null:a},Yp.readRadixNumber=function(t){var e=this.pos;this.pos+=2;var n=this.readInt(t);return null==n&&this.raise(this.start+2,"Expected number in radix "+t),this.options.ecmaVersion>=11&&110===this.input.charCodeAt(this.pos)?(n=Gp(this.input.slice(e,this.pos)),++this.pos):mh(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(Sh.num,n)},Yp.readNumber=function(t){var e=this.pos;t||null!==this.readInt(10,void 0,!0)||this.raise(e,"Invalid number");var n=this.pos-e>=2&&48===this.input.charCodeAt(e);n&&this.strict&&this.raise(e,"Invalid number");var i=this.input.charCodeAt(this.pos);if(!n&&!t&&this.options.ecmaVersion>=11&&110===i){var r=Gp(this.input.slice(e,this.pos));return++this.pos,mh(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(Sh.num,r)}n&&/[89]/.test(this.input.slice(e,this.pos))&&(n=!1),46!==i||n||(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),69!==i&&101!==i||n||(43!==(i=this.input.charCodeAt(++this.pos))&&45!==i||++this.pos,null===this.readInt(10)&&this.raise(e,"Invalid number")),mh(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s,a=(s=this.input.slice(e,this.pos),n?parseInt(s,8):parseFloat(s.replace(/_/g,"")));return this.finishToken(Sh.num,a)},Yp.readCodePoint=function(){var t;if(123===this.input.charCodeAt(this.pos)){this.options.ecmaVersion<6&&this.unexpected();var e=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(e,"Code point out of bounds")}else t=this.readHexChar(4);return t},Yp.readString=function(t){for(var e="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var i=this.input.charCodeAt(this.pos);if(i===t)break;92===i?(e+=this.input.slice(n,this.pos),e+=this.readEscapedChar(!1),n=this.pos):8232===i||8233===i?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Th(i)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(n,this.pos++),this.finishToken(Sh.string,e)};var Wp={};Yp.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t!==Wp)throw t;this.readInvalidTemplateToken()}this.inTemplateElement=!1},Yp.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Wp;this.raise(t,e)},Yp.readTmplToken=function(){for(var t="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(96===n||36===n&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==Sh.template&&this.type!==Sh.invalidTemplate?(t+=this.input.slice(e,this.pos),this.finishToken(Sh.template,t)):36===n?(this.pos+=2,this.finishToken(Sh.dollarBraceL)):(++this.pos,this.finishToken(Sh.backQuote));if(92===n)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(Th(n)){switch(t+=this.input.slice(e,this.pos),++this.pos,n){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:t+="\n";break;default:t+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}},Yp.readInvalidTemplateToken=function(){for(;this.pos=48&&e<=55){var i=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(i,8);return r>255&&(i=i.slice(0,-1),r=parseInt(i,8)),this.pos+=i.length-1,e=this.input.charCodeAt(this.pos),"0"===i&&56!==e&&57!==e||!this.strict&&!t||this.invalidStringToken(this.pos-1-i.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(r)}return Th(e)?"":String.fromCharCode(e)}},Yp.readHexChar=function(t){var e=this.pos,n=this.readInt(16,t);return null===n&&this.invalidStringToken(e,"Bad character escape sequence"),n},Yp.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,n=this.pos,i=this.options.ecmaVersion>=6;this.pos(e,n)=>n.error(e,t+" not allowed"),nd=ed("Aggregate function"),id=ed("Window function"),rd="Invalid argument",sd="Invalid column reference",ad=sd+" (must be input to an aggregate function)",od="Invalid function call",cd="Invalid operator parameter",ud="Unsupported destructuring pattern",ld="Table expressions do not support closures",hd="Use aq.escape(fn) to use a function as-is (including closures)",pd=`\nNote: ${ld}. ${hd}, or use table.params({ name: value }) to define dynamic parameters.`,dd=`\nNote: ${ld}. ${hd}, or use aq.addFunction(name, fn) to add new op functions.`,fd=`The ${bn} method is not valid in multi-table expressions.`;function md(t,e){const n=function(t){try{const i=t.field?function(t){const e=JSON.stringify(t+"");return t.table?`(a,b)=>b[${e}]`:`d=>d[${e}]`}(t):vt(t)?be(t):t;return(e=`expr=(${i})`,n=Qp,Gh.parse(e,n)).body[0].expression.right}catch(e){St("Expression parse error: "+(t+""))}var e,n}(e);let i=t.root=n;return t.spec=e,t.tuple=null,t.tuple1=null,t.tuple2=null,t.$param=null,t.$op=0,t.scope=new Set,t.paramsRef=new Map,t.columnRef=new Map,!function(t){return nh(Ne,t)||nh(Ee,t)}(i)?t.join?(t.scope.add(t.tuple1=Xp),t.scope.add(t.tuple2=td),t.scope.add(t.$param=Jp)):(t.scope.add(t.tuple=Zp),t.scope.add(t.$param=Jp)):(!function(t,e){t.generator&&ed("Generator functions")(t,e);t.async&&ed("Async functions")(t,e);const{params:n}=t,i=n.length,r=t=>(n,i)=>e.columnRef.set(n,[i,t]),s=(t,n)=>e.paramsRef.set(t,n);i&&(e.join?(vd(e,n[0],"tuple1",r(1)),i>1&&vd(e,n[1],"tuple2",r(2)),i>2&&vd(e,n[2],"$param",s)):(vd(e,n[0],"tuple",r(0)),i>1&&vd(e,n[1],"$param",s)));e.root=t.body}(i,t),i=i.body),Yl(i,t,yd),t.root}const yd={FunctionDeclaration:ed("Function definitions"),ForStatement:ed("For loops"),ForOfStatement:ed("For-of loops"),ForInStatement:ed("For-in loops"),WhileStatement:ed("While loops"),DoWhileStatement:ed("Do-while loops"),AwaitExpression:ed("Await expressions"),ArrowFunctionExpression:ed("Function definitions"),AssignmentExpression:ed("Assignments"),FunctionExpression:ed("Function definitions"),NewExpression:ed('Use of "new"'),UpdateExpression:ed("Update expressions"),VariableDeclarator(t,e){Md(t.id,e)},Identifier(t,e,n){wd(t,e,n)&&!e.scope.has(t.name)&&e.error(t,"Invalid variable reference",pd)},CallExpression(t,e){const n=_d(t.callee),i=hn(n)||pn(n);if(i){if((e.join||!1===e.aggregate)&&cn(n)&&nd(t,e),(e.join||!1===e.window)&&un(n)&&id(t,e),e.$op=1,e.ast)Cd(t,n,e),t.arguments.forEach((t=>Yl(t,e,bd)));else{const r=e.op(function(t,e,n,i){const r=[],s=[],a=e.param[0]||0,o=a+(e.param[1]||0);return i.forEach(((e,n)=>{n=0?gd(t,a,e,Sd,n):s===e.$param?gd(t,a,e,Ad):void(e.paramsRef.has(s)?Td(t,e.paramsRef.get(s)):e.columnRef.has(s)?Id(i,s,e,t):Vt(e.params,s)&&Td(i,s))}};function gd(t,e,n,i,r){const{property:s,computed:a}=t;let o;if(a)if(nh(Oe,s))o=s.value;else try{Yl(s,n,yd,t),o=n.param(s)}catch(e){n.error(t,"Invalid member expression")}else o=s.name;return i(t,o,e,n,r),!1}const bd={...yd,VariableDeclarator:ed("Variable declaration in operator call"),Identifier(t,e,n){wd(t,e,n)&&e.error(t,"Variable not accessible in operator call")},CallExpression(t,e){const n=_d(t.callee);ln(n)?Cd(t,n,e):e.error(t,od,dd)}};function vd(t,e,n,i){nh(De,e)?(t.scope.add(e.name),t[n]=e.name):nh(Fe,e)&&e.properties.forEach((e=>{const n=nh(De,e.key)?e.key.name:nh(Oe,e.key)?e.key.value:t.error(e,rd);nh(De,e.value)||t.error(e.value,ud),i(e.value.name,n)}))}function _d(t){return nh(De,t)?t.name:nh(Be,t)?xd(t)?function(t){return"max"===t?"greatest":"min"===t?"least":t}(t.property.name):t.property.name:null}function xd(t){return nh(De,t.object)&&"Math"===t.object.name}function wd(t,e,n){const{name:i}=t;if(nh(Be,n)&&n.property===t);else if(nh(Ve,n)&&n.key===t);else if(e.paramsRef.has(i))Td(t,e.paramsRef.get(i));else if(e.columnRef.has(i))Id(t,i,e,n);else if(Vt(e.params,i))Td(t,i);else{if(!Vt(Kp,i))return!0;kd(t,i)}}function Sd(t,e,n,i,r){const s=0===n?i.table:n>0?i.join[n-1]:null,a=s&&s.column(e);s&&!a&&i.error(t,sd),i.aggronly&&!i.$op&&i.error(t,ad),yn(t,e,n,a,r)}function Id(t,e,n,i){const[r,s]=n.columnRef.get(e);Sd(t,r,s,n,i)}function Ad(t,e,n,i){i.params&&!Vt(i.params,e)&&i.error(t,"Invalid param reference"),Td(t,e)}function Td(t,e){t.type=je,t.name=e}function kd(t,e){t.type=Pe,t.name=e,t.raw=Kp[e]}function Cd(t,e,n){if(e===bn){const e=n.table;e||n.error(t,fd),vn(t,t.arguments.length?t.arguments.map((t=>{const i=n.param(t),r=It(i)?e.columnName(i):i;return e.column(r)||n.error(t,sd),r})):e.columnNames())}else t.callee={type:"Function",name:e}}function Md(t,e){nh(De,t)?e.scope.add(t.name):nh("ArrayPattern",t)?t.elements.forEach((t=>Md(t,e))):nh(Fe,t)?t.properties.forEach((t=>Md(t.value,e))):e.error(t.id,"Unsupported variable declaration")}const Ed={[Ue]:1,[$e]:1};function Nd(t,e={}){const n=e.generate||Je,i=e.compiler||fn,r=function(t){return(t.table?Dd(t.table):t.join?{...Dd(t.join[1]),...Dd(t.join[0])}:{})||{}}(e),s={},a={},o=[],c=[];let u=0,l=-1;const h=e.join?i.join:1==e.index?i.expr2:i.expr,p={op(t){const e=function(t){let e=`${t.name}(${t.fields.concat(t.params).join(",")})`;if(t.frame){e+=`[${t.frame.map((t=>Number.isFinite(t)?Math.abs(t):-1))},${!!t.peers}]`}return e}(t);return a[e]||(t.id=++l,a[e]=t)},field(t){const e=n(t);return s[e]||(s[e]=++u)},param:t=>nh(Oe,t)?t.value:i.param(n(t),r),value(t,i){o.push(t);const s=i.escape||(e.ast?function(t){return Yl(t,null,{Column:eh,Constant:eh,Default:th}),t}(i):h(n(i),r));c.push(s),Ed[i.type]&&s!==i&&Nt(s)&&(s.field=i.name)},error(t,e,n=""){const i=t.start-6,r=t.end-6;St(`${e}: "${String(p.spec).slice(i,r)}"${n}`)}};Object.assign(p,e,{params:r});for(const[e,n]of gn(t))p.value(e+"",n.escape?rh(p,n,r):md(p,n));if(e.ast)return{names:o,exprs:c};const d=[];for(const t in s)d[s[t]]=i.expr(t,r);const f=Object.values(a);return f.forEach((t=>t.fields=t.fields.map((t=>d[t])))),{names:o,exprs:c,ops:f}}function Dd(t){return t&&At(t.params)?t.params():{}}const Od="Expr",Bd="ExprList",Ld="ExprNumber",Fd="ExprObject",Vd="JoinKeys",Ud="JoinValues",Pd="Options",Rd="OrderKeys",jd="SelectionList",$d="TableRef",zd="TableRefList",Hd="Descending",qd="Selection",Yd="Window";function Gd(t,e){return t&&t.expr?new Wd({...t,...e}):new Wd(e,t)}class Wd{constructor(t,e){this.expr=e,Object.assign(this,t)}toString(){return String(this.expr)}toObject(){return{...this,expr:this.toString(),...At(this.expr)?{func:!0}:{}}}}function Kd(t,e,n=0){const i=n?{field:!0,table:n}:{field:!0};return Gd(t,e?{expr:e,...i}:i)}function Qd(t,e){return(e=e&&At(e.query)?e.query():e)&&At(e.evaluate)?e.evaluate(null,t):t(e)}function Jd(t){return Nt(t)&&(vt(t.all)||vt(t.matches)||vt(t.not)||vt(t.range))}function Zd(t){return t&&At(t.toObject)?t.toObject():At(t)?{expr:String(t),func:!0}:vt(t)?t.map(Zd):Nt(t)?Ol(t,(t=>Zd(t))):t}function Xd(t){return vt(t)?t.map(Xd):Nt(t)?vt(t.verbs)?gf.from(t):vt(t.all)?jl():vt(t.range)?function(t,e){return Pl((n=>{let i=It(t)?t:n.columnIndex(t),r=It(e)?e:n.columnIndex(e);if(r({range:[t,e]})))}(...t.range):vt(t.match)?(Ot(e=RegExp(...t.match))&&(e=RegExp(e.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&"))),Pl((t=>t.columnNames((t=>e.test(t)))),(()=>({matches:[e.source,e.flags]})))):vt(t.not)?$l(t.not.map(Zd)):function(t){let e=t,n=t.expr;if(null!=n){if(!0===t.field?e=n=Kd(n):!0===t.func&&(e=n=function(t){const e=t=>t;return e.toString=()=>t,e}(n)),Nt(t.window)){const{frame:i,peers:r}=t.window;e=n=function(t,e,n){return Gd(t,{window:{frame:e||[-1/0,0],peers:!!n}})}(n,i,r)}!0===t.desc&&(e=function(t){return Gd(t,{desc:!0})}(n))}return t===e?Ol(t,(t=>Xd(t))):e}(t):t;var e}function tf(t){const e=[];return _t(t).forEach((t=>{It(t)?e.push(t):Ot(t)?e.push(Kd(t,null)):Nt(t)&&t.expr||At(t)?e.push(t):St("Invalid key value: "+(t+""))})),e}function ef(t,e){return e<2?_t(t):t}const nf={[Od]:lf,[Bd]:hf,[Ld]:function(t){return It(t)?t:of(t)},[Fd]:of,[Vd]:function(t){return vt(t)?t.map(hf):of(t,{join:!0})},[Ud]:function(t){return vt(t)?t.map(((t,e)=>e<2?hf(t):of(t,{join:!0}))):of(t,{join:!0})},[Rd]:hf,[jd]:function(t){return _t(t).map(uf).flat()}};function rf(t,e,n){return e===Pd?t?function(t,e={}){const n={};for(const i in t){const r=t[i];n[i]=e[i]?rf(r,e[i]):r}return n}(t,n):t:nf[e](t)}function sf(t){return{type:Ue,name:t}}function af(t){return{type:Ue,index:t}}function of(t,e){if(Ot(t))return function(t,e){return Nd({expr:t},{...e,ast:!0}).exprs[0]}(t,e);if(t.expr){let n;if(!0===t.field?n=sf(t.expr):!0===t.func&&(n=of(t.expr,e)),n)return t.desc&&(n={type:Hd,expr:n}),t.window&&(n={type:Yd,expr:n,...t.window}),n}return Object.keys(t).map((n=>({...of(t[n],e),as:n})))}function cf(t){const e=qd;return t.all?{type:e,operator:"all"}:t.not?{type:e,operator:"not",arguments:hf(t.not)}:t.range?{type:e,operator:"range",arguments:hf(t.range)}:t.matches?{type:e,operator:"matches",arguments:t.matches}:St("Invalid input")}function uf(t){return Jd(t)?cf(t):It(t)?af(t):Ot(t)?sf(t):Nt(t)?Object.keys(t).map((e=>({type:Ue,name:e,as:t[e]}))):St("Invalid input")}function lf(t){return Jd(t)?cf(t):It(t)?af(t):Ot(t)?sf(t):Nt(t)?of(t):St("Invalid input")}function hf(t){return _t(t).map(lf).flat()}function pf(t){return t&&At(t.toAST)?t.toAST():t}class df{constructor(t,e=[],n=[]){this.verb=t,this.schema=e,e.forEach(((t,e)=>{const i=t.type,r=n[e],s=i===Vd?vt(a=r)?a.map(tf):a:i===Ud?function(t){return vt(t)?t.map(ef):t}(r):i===Rd?function(t){const e=[];return t.forEach((t=>{const n=null!=t.expr?t.expr:t;if(Nt(n)&&!At(n))for(const t in n)e.push(n[t]);else t=It(n)?n:Ot(n)?Kd(t):At(n)?t:St("Invalid orderby field: "+t),e.push(t)})),e}(r):r;var a;this[t.name]=void 0!==s?s:t.default}))}static from(t){const e=mf[t.verb],n=(e.schema||[]).map((({name:e})=>Xd(t[e])));return e(...n)}evaluate(t,e){const n=this.schema.map((({name:t,type:n})=>{const i=this[t];return n===$d?Qd(e,i):n===zd?i.map((t=>Qd(e,t))):i}));return t[this.verb](...n)}toObject(){const t={verb:this.verb};return this.schema.forEach((({name:e})=>{t[e]=Zd(this[e])})),t}toAST(){const t={type:"Verb",verb:this.verb};return this.schema.forEach((({name:e,type:n,props:i})=>{t[e]=function(t,e,n){return e===$d?pf(t):e===zd?t.map(pf):rf(Zd(t),e,n)}(this[e],n,i)})),t}}function ff(t,e){return Object.assign(((...n)=>new df(t,e,n)),{schema:e})}const mf={count:ff("count",[{name:"options",type:Pd}]),derive:ff("derive",[{name:"values",type:Fd},{name:"options",type:Pd,props:{before:jd,after:jd}}]),filter:ff("filter",[{name:"criteria",type:Fd}]),groupby:ff("groupby",[{name:"keys",type:Bd}]),orderby:ff("orderby",[{name:"keys",type:Rd}]),relocate:ff("relocate",[{name:"columns",type:jd},{name:"options",type:Pd,props:{before:jd,after:jd}}]),rename:ff("rename",[{name:"columns",type:jd}]),rollup:ff("rollup",[{name:"values",type:Fd}]),sample:ff("sample",[{name:"size",type:Ld},{name:"options",type:Pd,props:{weight:Od}}]),select:ff("select",[{name:"columns",type:jd}]),ungroup:ff("ungroup"),unorder:ff("unorder"),reify:ff("reify"),dedupe:ff("dedupe",[{name:"keys",type:Bd,default:[]}]),impute:ff("impute",[{name:"values",type:Fd},{name:"options",type:Pd,props:{expand:Bd}}]),fold:ff("fold",[{name:"values",type:Bd},{name:"options",type:Pd}]),pivot:ff("pivot",[{name:"keys",type:Bd},{name:"values",type:Bd},{name:"options",type:Pd}]),spread:ff("spread",[{name:"values",type:Bd},{name:"options",type:Pd}]),unroll:ff("unroll",[{name:"values",type:Bd},{name:"options",type:Pd,props:{drop:Bd}}]),lookup:ff("lookup",[{name:"table",type:$d},{name:"on",type:Vd},{name:"values",type:Bd}]),join:ff("join",[{name:"table",type:$d},{name:"on",type:Vd},{name:"values",type:Ud},{name:"options",type:Pd}]),cross:ff("cross",[{name:"table",type:$d},{name:"values",type:Ud},{name:"options",type:Pd}]),semijoin:ff("semijoin",[{name:"table",type:$d},{name:"on",type:Vd}]),antijoin:ff("antijoin",[{name:"table",type:$d},{name:"on",type:Vd}]),concat:ff("concat",[{name:"tables",type:zd}]),union:ff("union",[{name:"tables",type:zd}]),intersect:ff("intersect",[{name:"tables",type:zd}]),except:ff("except",[{name:"tables",type:zd}])};function yf(t){return new gf(null,null,t)}class gf extends wt{constructor(t,e,n){super(e),this._verbs=t||[],this._table=n}static from({verbs:t,table:e,params:n}){return new gf(t.map(df.from),n,e)}get[Symbol.toStringTag](){if(!this._verbs)return"Object";return`Query: ${this._verbs.length} verbs`+(this._table?` on '${this._table}'`:"")}get length(){return this._verbs.length}get tableName(){return this._table}params(t){return arguments.length?(this._params={...this._params,...t},this):this._params}evaluate(t,e){t=t||e(this._table);for(const n of this._verbs)t=n.evaluate(t.params(this._params),e);return t}toObject(){return bf(this,"toObject")}toJSON(){return this.toObject()}toAST(){return bf(this,"toAST",{type:"Query"})}}function bf(t,e,n){return{...n,verbs:t._verbs.map((t=>t[e]())),...t._params?{params:t._params}:null,...t._table?{table:t._table}:null}}function vf(t,e){return new gf(t._verbs.concat(e),t._params,t._table)}for(const t in mf){const e=mf[t];gf.prototype["__"+t]=function(t,...n){return vf(t,e(...n))}}function _f(t,e,...n){const i=["_","$"],r=i.slice(0,n.length);return r.push('"use strict"; const '+n.map(((t,e)=>t.map(((t,n)=>`${i[e]}${n} = ${i[e]}[${n}]`)).join(", "))).join(", ")+`; return (${t}) => ${e};`),Function(...r)(...n)}var xf=t=>t;const wf=[t=>"true"===t||"false"===t,t=>"false"!==t],Sf=[t=>"NaN"===t||(t=+t)===t,t=>+t],If=[te,t=>new Date(Date.parse(t))];function Af(t){const{decimal:e}=t;return e&&"."!==e?Sf.map((t=>n=>t(n&&n.replace(e,".")))):Sf}function Tf(t,e){const n=t.length;for(let i=0;i`col${t+e+1}`))}function Cf(t,e,n){let i=t();const r=i.length,s=+n.autoMax||1e3,a=Tt(r,(()=>[]));e=e?e.lengthAt(i[t])?i[t]:r?xf:function(t,e){const n=[wf,Af(e),If],i=n.length;for(let e=0;e{if(t===xf)return;const n=a[e];for(let e=0;eu[t]=a[e])),new zl(u,e)}const Mf={},Ef={},Nf=34,Df=10,Of=13;function Bf(t,e={}){const n=function(t,{delimiter:e=",",skip:n,comment:i}){1!==e.length&&St(`Text "delimiter" should be a single character, found "${e}"`);const r=e.charCodeAt(0);let s,a=t.length,o=0,c=a<=0,u=!1;function l(){if(c)return Ef;if(u)return u=!1,Mf;const e=o;let n,i;if(t.charCodeAt(e)===Nf){for(;o++=a?c=!0:(i=t.charCodeAt(o++))===Df?u=!0:i===Of&&(u=!0,t.charCodeAt(o)===Df&&++o),t.slice(e+1,n-1).replace(/""/g,'"')}for(;o=0;)t();return n?()=>{let e;for(;!e;){if(!n(e=t()))return e;e=null}}:t}((function(){if((s=l())!==Ef){const t=[];for(;s!==Mf&&s!==Ef;)t.push(s),s=l();return t}}),n,i&&(t=>(t&&t[0]||"").startsWith(i)))}(t,e);return Cf(n,!1!==e.header?n():e.names,e)}function Lf(t){const e=t.length;for(let n=0;n57)return!1}return!0}function Ff(t,e){const n=Ut();return e.forEach(((e,i)=>{const r=Ot(e)?e:i;if(r){const e=t.column(i)||St(`Unrecognized column: ${i}`);n.add(r,e)}})),t.create(n)}function Vf(t,e,{before:n,after:i}={}){const r=null!=n,s=null!=i;r||s||St("relocate requires a before or after option."),r&&s&&St("relocate accepts only one of the before or after options."),e=Ul(t,e);const a=[...Ul(t,r?n:i).keys()],o=r?a[0]:a.pop(),c=new Map;return t.columnNames().forEach((t=>{const n=!e.has(t);if(t===o){s&&n&&c.set(t,t);for(const[t,n]of e)c.set(t,n);if(s)return}n&&c.set(t,t)})),Ff(t,c)}function Uf(t,e=(t=>t),n=""){const i=t.length;if(!i)return"";let r=e(t[0],0);for(let s=1;se?1:t>=e?0:NaN}function Rf(t){return ge(t)?t:+t}class jf{constructor(t){this._values=t||[],this._sorted=null,this._start=0}values(t){return this._start&&(this._values=this._values.slice(this._start),this._start=0),t?this._values.slice():this._values}add(t){this._values.push(t),this._sorted=null}rem(){this._start+=1,this._sorted=null}min(){return this._sorted&&this._sorted.length?this._sorted[0]:function(t,e=0,n=t.length){let i=n?t[e++]:Rt;for(let r=e;rt[r]&&(i=t[r]);return i}(this._values,this._start)}max(){return this._sorted&&this._sorted.length?this._sorted[this._sorted.length-1]:function(t,e=0,n=t.length){let i=n?t[e++]:Rt;for(let r=e;r=1)return Rf(t[n-1]);const i=(n-1)*e,r=Math.floor(i),s=Rf(t[r]);return ge(s)?s:s+(Rf(t[r+1])-s)*(i-r)}(this._sorted,t)}}const $f=(t,e,n)=>_f(e,"{"+Uf(t,((t,i)=>`_${i}.${n}(${e});`))+"}",t);function zf(t,e){const{ops:n,output:i}=function(t,e){const n={},i=[];function r(t,s=[]){const a=t+":"+s;if(n[a])return n[a];const o=hn(t),c=o.create(...s);return e<0&&o.stream&&o.stream.forEach((t=>r(t,[]))),o.req&&o.req.forEach((t=>r(t,[]))),n[a]=c,i.push(c),c}const s=t.map((t=>{const e=r(t.name,t.params);return e.output=t.id,e}));return{ops:i,output:s}}(t,e),r=t[0].fields,s=r.length;return new(0===s?Hf:1===s?qf:2===s?Yf:St("Unsupported field count: "+s))(r,n,i,e)}class Hf extends ql{constructor(t,e,n,i){super(n),this._op=e,this._fields=t,this._stream=!!i}init(){const t={count:0,valid:0,stream:this._stream};return this._op.forEach((e=>e.init(t))),t.values&&(t.list=new jf),t}write(t,e,n){const i=this._outputs,r=i.length;for(let s=0;ss[t][r[e]]:t=>s[t][0];n=n.map((t=>e=>t(e,i,a)))}return n}function Wf(t,e,n){if(!e.length)return n;const i=Kf(e),r=t.groups(),s=r?r.size:1;return n=n||Tt(e.length,(()=>Array(s))),s>1?i.forEach((e=>{const i=Jf(t,e,r);for(let t=0;t{const i=Qf(t,e);e.write(i,n,0)})),n}function Kf(t,e){const n=[],i={};for(const e of t){const t=e.fields.map((t=>t+"")).join(",");(i[t]||(i[t]=[])).push(e)}for(const t in i)n.push(zf(i[t],e));return n}function Qf(t,e){const n=e.init(),i=t.totalRows(),r=t.data(),s=t.mask();if(t.isOrdered()){const s=t.indices();for(let t=0;t=0;t=s.next(t+1))e.add(n,t,r);else for(let t=0;te.init())),a=t.data();if(t.isOrdered()){const n=t.indices(),r=n.length;for(let t=0;t=0;t=n.next(t+1))e.add(s[i[t]],t,a)}else{const n=t.totalRows();for(let t=0;t>>1;t(e[s],n)<0?i=s+1:r=s}return i},right(e,n,i,r){for(null==i&&(i=0),null==r&&(r=e.length);i>>1;t(e[s],n)>0?r=s:i=s+1}return i}}}const tm=Xf(Pf);const em=t=>(t.frame||[null,null]).map((t=>Number.isFinite(t)?Math.abs(t):null)),nm=t=>!!t.peers;function im(t,e,n,i={},r){const s=t.data(),a=function(t,e){const n={};return t.forEach((t=>{const e=em(t),i=nm(t),r=`${e},${i}`,{aggOps:s,winOps:a}=n[r]||(n[r]={frame:e,peers:i,aggOps:[],winOps:[]});cn(t.name)?s.push(t):a.push(function(t){const{id:e,name:n,fields:i=[],params:r=[]}=t,s=pn(n).create(...r);return i.length&&(s.get=i[0]),s.id=e,s}(t))})),Object.values(n).map((t=>function(t,e,n,i,r){let s,a,o,c,u;const l=t=>a[t-1]===a[t],h=i.length,p=r.length,d=i.length?_f(["w","r","k"],"{"+Uf(i,((t,e)=>`r[_${e}.id][k]=_${e}.value(w,_${e}.get);`))+"}",i):()=>{},f={i0:0,i1:0,index:0,size:0,peer:l,init(t,e,n,l){f.index=f.i0=f.i1=0,f.size=e.length,s=t,a=e,c=n,u=l,o=r?r.map((t=>t.init())):null;for(let t=0;tn(s[e],t),step(i){const[h,m]=e,y=f.size,g=f.i0,b=f.i1;f.i0=null!=h?Math.max(0,i-Math.abs(h)):0,f.i1=null!=m?Math.min(y,i+Math.abs(m)+1):y,f.index=i,n&&(f.i0>0&&l(f.i0)&&(f.i0=tm.left(a,a[f.i0])),f.i1`_${e}[r] = $${e}(r, d, op);`))+"}",e,n);t.partitions().forEach(((e,n)=>{const r=e.length,u=function(t,e){if(t.isOrdered()){const n=t.comparator(),i=t.data(),r=e.length,s=new Uint32Array(r);for(let t=1,a=0;ti[t][n];for(let t=0;ta.add(t,Array(s)))),[c,u]=function(t){const e=[],n=[],i=t.length;for(let r=0;rArray(l))));return u.length?im(t,o,n,h,u):function(t,e,n,i){const r=t.mask(),s=t.data(),{keys:a}=t.groups()||{},o=a?(t,e)=>i[t][a[e]]:t=>i[t][0],c=e.length;for(let i=0;i=0;t=r.next(t+1))c[t]=a(t,s,o);else{const e=t.totalRows();for(let t=0;t>5]&am>>>t}set(t){this._bits[t>>5]|=am>>>t}clear(t){this._bits[t>>5]&=~(am>>>t)}scan(t){for(let e=this.next(0);e>=0;e=this.next(e+1))t(e)}next(t){const e=this._bits,n=e.length;let i=t>>5,r=e[i]&4294967295>>>t;for(;i=0;)e=this.next(e+1);return e}not(){const t=this._bits,e=t.length;for(let n=0;n>n-1),this}and(t){if(t){const e=this._bits,n=t._bits,i=e.length;for(let t=0;t0?+r.limit:1/0,a=r.index?!0===r.index?"index":r.index+"":null,o=new Set(r.drop),c=Gf(t,i,n),u=Ut(),l=new Set(e),h=[],p=[],d=[];t.columnNames().forEach((e=>{if(!o.has(e)){const n=u.add(e,[]);l.has(e)||(h.push(t.column(e)),p.push(n))}})),e.forEach((t=>{o.has(t)||(u.has(t)||u.add(t,[]),d.push(u.data[t]))}));const f=a?u.add(a,[]):null;let m=0;const y=h.length,g=d.length,b=(t,e)=>{for(let n=0;n{for(let n=0;n{};if(1===g){const e=c[0],n=d[0];t.scan(((t,i)=>{const r=_t(e(t,i)),a=Math.min(r.length,s);b(t,a);for(let t=0;t{let n=0;const i=c.map((i=>{const r=_t(i(t,e));return n=Math.min(Math.max(n,r.length),s),r}));b(t,n);for(let t=0;t{Ot(n=It(n)?e.columnName(n):n)?r.set(n,Kd(n)):At(n)?Ul(e,n).forEach(s):Nt(n)?Vl(r,n):St(`Invalid ${t} value: ${n+""}`)};return _t(n).forEach(s),i.preparse&&i.preparse(r),Nd(r,{table:e,...i})}function lm(t,e,n,i){const r=n&&n.length;return function(t,{names:e,exprs:n,ops:i},r){const s=Gf(t,i,n),a=r?null:Ut(t),o=t.totalRows();return e.forEach(((e,n)=>{const i=t.column(e),c=r?i.data:a.add(e,Array(o)),u=s[n];t.scan((t=>{const e=i.get(t);c[t]=Ht(e)?e:u(t)}))})),r?t:t.create(a)}(r?function(t,e,n){const i=t.groups(),r=t.data(),s=(i?i.names:[]).concat(e),a=(i?i.get:[]).concat(e.map((e=>t.getter(e)))),o=new Set,c=Xe(a);t.scan(((t,e)=>o.add(c(t,e))));const u=t.columnNames(),l=Ut(),h=u.map((t=>l.add(t,[])));u.forEach(((e,n)=>{const i=r[e],s=h[n];t.scan((t=>s.push(i.get(t))))}));const p=Xe(a.map(((t,e)=>t=>t[e]))),d=_f("v","{"+h.map(((t,e)=>`_${e}.push(v[$${e}]);`)).join("")+"}",h,u.map((t=>s.indexOf(t))));if(i){let t=i.keys.length;const e=n.reduce(((t,e)=>t*e.length),i.size),r=new Uint32Array(e+(t-o.size));r.set(i.keys),hm(i,n,((e,n)=>{o.has(p(e))||(d(e),r[t++]=n[0])})),l.groupby({...i,keys:r})}else hm(i,n,(t=>{o.has(p(t))||d(t)}));return t.create(l.new())}(t,n,i):t,e,r)}function hm(t,e,n){const i=t?t.get.length:0,r=t?1:0,s=r+e.length,a=new Int32Array(s),o=new Int32Array(s),c=[];if(t){const{get:e,rows:n,size:r}=t;a[0]=r,c.push(((t,r)=>{const s=n[r];for(let n=0;n{const n=e+i;a[e+r]=t.length,c.push(((e,i)=>e[n]=t[i]))}));const u=Array(i+e.length);for(let t=0;t=0;){const e=++o[t];ei[t][e],o=t.length;for(let n=0;n1){const e=r.add(t[n],Array(s));for(let t=0;te.field?t.set(n,Ie(e+"")):0))}function fm(t,e){const n=new Map;return t.scan(((t,i)=>{const r=e(t,i);null!=r&&r==r&&n.set(r,t)})),n}function mm(t,e,n,{names:i,exprs:r},s={}){const a=t.data(),o=t.indices(!1),c=o.length,u=new Int32Array(c),l=e.data(),h=e.indices(!1),p=h.length,d=new Int32Array(p),f=i.length,m=Ut(),y=Array(f),g=Array(f);for(let t=0;t`_${e}.push($${e}(${n}));`))+"}",t,e)}(y,g);if((vt(n)?gm:ym)(b,n,a,l,o,h,u,d,c,p),s.left)for(let t=0;t=l?(h=i,p=e,d=o,f=s,m=r,y=n,g=c,b=a):(h=r,p=n,d=c,f=a,m=i,y=e,g=o,b=s,v=(e,n,i,r)=>t(i,r,e,n));const _=function(t,e,n){const i=new Map,r=t.length;for(let s=0;s{Ot(n=It(n)?e.columnName(n):n)?i.set(r,Kd(n)):At(n)||Nt(n)&&n.expr?i.set(r,n):St(`Invalid ${t} key value: ${n+""}`)}));return Xe(Nd(i,{table:e,aggregate:!1,window:!1}).exprs,!0)}function vm(t,e,n){if(n)Ot(n)?n=[n,n]:vt(n)&&1===n.length&&(n=[n[0],n[0]]);else{const i=function(t,e){const n=new Set(e);return t.filter((t=>n.has(t)))}(t.columnNames(),e.columnNames());i.length||St("Natural join requires shared column names."),n=[i,i]}return n}function _m(t,e,n,i){return n.length!==i.length&&St("Mismatched number of join keys"),[bm("join",t,n),bm("join",e,i)]}const xm={aggregate:!1,window:!1,index:1};function wm(t,e,n,i,r={}){n=vm(t,e,n);const s={join:[t,e]};let a;if(vt(n)){const[s,o]=n.map(_t);a=_m(t,e,s,o),i||(i=function(t,e,n,i){const r=[];e.forEach(((t,e)=>Ot(t)&&t===n[e]?r.push(t):0));const s=$l(r);if(i.left&&i.right){const e=new Set(r);return[t.columnNames().map((t=>{const n=`[${be(t)}]`;return e.has(t)?{[t]:`(a, b) => a${n} == null ? b${n} : a${n}`}:t})),s]}return i.right?[s,jl()]:[jl(),s]}(t,s,o,r))}else a=Nd({on:n},s).exprs[0],i||(i=[jl(),jl()]);return mm(t,e,a,function(t,e,n,i,r=[]){if(vt(n)){let s,a,o,c=n.length;s=a=o={names:[],exprs:[]},c--&&(s=um("join",t,n[0],i)),c--&&(a=um("join",e,n[1],xm)),c--&&(o=Nd(n[2],i));const u=new Set,l=new Set(s.names);return a.names.forEach((t=>{l.has(t)&&u.add(t)})),u.size&&(""!==r[0]&&Sm(s.names,u,r[0]||"_1"),""!==r[1]&&Sm(a.names,u,r[1]||"_2")),{names:s.names.concat(a.names,o.names),exprs:s.exprs.concat(a.exprs,o.exprs)}}return Nd(n,i)}(t,e,i,s,r&&r.suffix),r)}function Sm(t,e,n){t.forEach(((i,r)=>e.has(i)?t[r]=i+n:0))}function Im(t,e,n,[i,r]){const s=fm(n,r);e.scan(((e,n)=>{s.get(i(e,n))>=0&&t.set(e)}))}function Am(t,e,n,i){const r=e.numRows(),s=n.numRows(),a=e.data(),o=n.data();if(e.isFiltered()||n.isFiltered()){const c=e.indices(!1),u=n.indices(!1);for(let e=0;enull!=t?t:e;function Cm(t,e,n,i={}){const{keys:r,keyColumn:s}=function(t,e,n){const i=n.limit>0?+n.limit:1/0,r=km(n.sort,!0),s=km(n.keySeparator,"_"),a=Gf(t,e.ops,e.exprs),o=1===a.length?a[0]:(t,e)=>a.map((n=>n(t,e))).join(s),c=Array(t.totalRows());t.scan(((t,e)=>c[t]=o(t,e)));const u=Wf(t.ungroup(),[{id:0,name:"array_agg_distinct",fields:[t=>c[t]],params:[]}])[0][0],l=r?u.sort():u;return{keys:Number.isFinite(i)?l.slice(0,i):l,keyColumn:c}}(t,e,i),a=km(i.valueSeparator,"_"),o=n.names.length>1?(t,e)=>e+a+r[t]:t=>r[t],c=r.map((e=>Wf(t,n.ops.map((t=>{if("count"===t.name){const n=t=>e===s[t]?1:NaN;return n.toString=()=>e+":1",{...t,name:"sum",fields:[n]}}const n=t.fields.map((t=>{const n=(n,i)=>e===s[n]?t(n,i):NaN;return n.toString=()=>e+":"+t,n}));return{...t,fields:n}})))));return t.create(function({names:t,exprs:e},n,i,r){const s=i?i.size:1,a=Ut(),o=r.length,c=t.length;let u;const l=(t,e)=>u[t][e];i&&Zf(a,i);for(let i=0;i1)for(let e=0;ee.field?t.set(n,xe(e+"")):0))}function Em(t,e){return pm(t,Nd(e,{table:t,aggronly:!0,window:!1}))}function Nm(t,e,n,i){return(e?i?Om:Dm:i?Lm:Bm)(t.length,t,n,i)}function Dm(t,e,n){const i=n.length;for(let r=0;r=i)return n;for(let i=0;i=r)return n;const s=new Float32Array(r),a=new Uint32Array(r);for(let t=0;ts[t]-s[e]));for(let i=0;i{let i=e(n);return o+=i=r?i:Math.min(t.length,i),i}));const c=new Uint32Array(o);let u=0;return a.forEach(((t,i)=>{const s=e[i],a=c.subarray(u,u+=s);r||s!==t.length?Nm(a,r,t,n):a.set(t)})),!1!==s&&(a.length>1||!r)&&function(t,e=0,n=t.length){let i=n-(e=+e);for(;i;){const n=he()*i--|0,r=t[i+e];t[i+e]=t[n+e],t[n+e]=r}}(c),t.reify(c)}const Vm=t=>e=>t.get(e)||0;function Um(t,{names:e,exprs:n,ops:i=[]},r={}){if(0===e.length)return t;const s=1===e.length&&r.as||[],a=null==r.drop||!!r.drop,o=null==r.limit?s.length||1/0:Math.max(1,+r.limit||1),c=Gf(t,i,n),u=Ut(),l=e.reduce(((t,e,n)=>t.set(e,n)),new Map),h=(e,n)=>{const i=function(t,e,n){const i=t.totalRows(),r=[];return t.scan(((t,s)=>{const a=_t(e(t,s)),o=Math.min(a.length,n);for(;r.length{l.has(e)?(a||u.add(e,t.column(e)),h(l.get(e),e),l.delete(e)):u.add(e,t.column(e))})),l.forEach(h),t.create(u)}function Pm(t,{names:e=[],exprs:n=[],ops:i=[]}){const r=e.length;if(0===r)return null;if(1===r&&!t.isFiltered()&&n[0].field){const i=t.column(n[0].field);if(i.groups)return i.groups(e)}let s=Gf(t,i,n);const a=Xe(s),o=t.totalRows(),c=new Uint32Array(o),u={},l=[],h=t.data(),p=t.mask();if(p)for(let t=p.next(0);t>=0;t=p.next(t+1)){const e=a(t,h)+"",n=u[e];c[t]=null!=n?n:u[e]=l.push(t)-1}else for(let t=0;te=>t(e,h)))),{keys:c,get:s,names:e,rows:l,size:l.length}}const Rm=(t,e,n,i)=>`((u = ${t}) < (v = ${e}) || u == null) && v != null ? ${n}\n : (u > v || v == null) && u != null ? ${i}\n : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ${n}\n : v !== v && u === u ? ${i} : `;var jm={__antijoin:(t,e,n)=>Tm(t,e,n,{anti:!0}),__count:(t,e={})=>Em(t,{[e.as||"count"]:we()}),__cross:(t,e,n,i)=>wm(t,e,(()=>!0),n,{...i,left:!0,right:!0}),__concat:function(t,e){const n=t.numRows(),i=n+e.reduce(((t,e)=>t+e.numRows()),0);if(n===i)return t;const r=[t,...e],s=Ut();return t.columnNames().forEach((t=>{const e=Array(i);let n=0;r.forEach((i=>{const r=i.column(t)||{get:()=>Rt};i.scan((t=>e[n++]=r.get(t)))})),s.add(t,e)})),t.create(s.new())},__dedupe:function(t,e=[]){return t.groupby(e.length?e:t.columnNames()).filter("row_number() === 1").ungroup().reify()},__derive:function(t,e,n={}){const i=sm(t,Nd(e,{table:t}),n);return n.drop||null==n.before&&null==n.after?i:Vf(i,Object.keys(e).filter((e=>!t.column(e))),n)},__except:function(t,e){if(0===e.length)return t;const n=t.columnNames();return e.reduce(((t,e)=>t.antijoin(e.select(n))),t).dedupe()},__filter:function(t,e){const n=Nd({p:e},{table:t});let i=n.exprs[0];if(n.ops.length){const{data:e}=sm(t,n,{drop:!0}).column("p");i=t=>e[t]}return function(t,e){const n=t.totalRows(),i=t.mask(),r=t.data(),s=new om(n);if(i)for(let t=i.next(0);t>=0;t=i.next(t+1))e(t,r)&&s.set(t);else for(let t=0;te,(t,e)=>o.map((n=>n(t,e)))]},{...r,drop:e})}(t,um("fold",t,e),n)},__impute:function(t,e,n={}){if((e=Nd(e,{table:t})).names.forEach((e=>t.column(e)?0:St(`Invalid impute column ${be(e)}`))),n.expand){const i={preparse:dm,aggronly:!0},r=um("impute",t,n.expand,i),s=pm(t.ungroup(),r);return lm(t,e,r.names,r.names.map((t=>s.get(t,0))))}return lm(t,e)},__intersect:function(t,e){const n=t.columnNames();return e.length?e.reduce(((t,e)=>t.semijoin(e.select(n))),t).dedupe():t.reify([])},__join:wm,__lookup:function(t,e,n,i){return function(t,e,[n,i],{names:r,exprs:s,ops:a}){const o=Ut(t),c=t.totalRows();r.forEach((t=>o.add(t,Array(c).fill(Rt))));const u=fm(e,i),l=_f(["lr","rr","data"],"{"+Uf(r,((t,e)=>`_[${e}][lr] = $[${e}](rr, data);`))+"}",r.map((t=>o.data[t])),Gf(e,a,s)),h=e.data();return t.scan(((t,e)=>{const i=u.get(n(t,e));i>=0&&l(t,i,h)})),t.create(o)}(t,e,[bm("lookup",t,(n=vm(t,e,n))[0]),bm("lookup",e,n[1])],um("lookup",e,i))},__pivot:function(t,e,n,i){return Cm(t,um("fold",t,e),um("fold",t,n,{preparse:Mm,aggronly:!0}),i)},__relocate:Vf,__rename:function(t,e){const n=new Map;return t.columnNames((t=>(n.set(t,t),0))),Ff(t,Ul(t,e,n))},__rollup:Em,__sample:function(t,e,n={}){return Fm(t,function(t,e){return It(e)?()=>e:Vm(pm(t,Nd({size:e},{table:t,window:!1})).column("size"))}(t,e),function(t,e){return null==e?null:(e=It(e)?t.columnName(e):e,Vm(Ot(e)?t.column(e):sm(t,Nd({w:e},{table:t}),{drop:!0}).column("w")))}(t,n.weight),n)},__select:function(t,e){return Ff(t,Ul(t,e))},__semijoin:Tm,__spread:function(t,e,n){return Um(t,um("spread",t,e),n)},__union:function(t,e){return t.concat(e).dedupe()},__unroll:function(t,e,n){return cm(t,um("unroll",t,e),n&&n.drop?{...n,drop:um("unroll",t,n.drop).names}:n)},__groupby:function(t,e){return function(t,e){return t.create({groups:Pm(t,e)})}(t,um("groupby",t,e))},__orderby:function(t,e){return function(t,e){return t.create({order:e})}(t,function(t,e){let n=-1;const i=new Map,r=t=>i.set(++n+"",t);return e.forEach((e=>{const n=null!=e.expr?e.expr:e;if(Nt(n)&&!At(n))for(const t in n)r(n[t]);else r(It(n)?Kd(e,t.columnName(n)):Ot(n)?Kd(e):At(n)?e:St("Invalid orderby field: "+(e+"")))})),function(t,e){const n=[],i=[],r=[];let s=null,a="0",o="0";t.isGrouped()&&(s=t.groups().keys,a="ka",o="kb");const{ops:c}=Nd(e,{table:t,value:(t,e)=>{if(n.push(t),e.escape){const t=t=>`fn[${r.length}](${t}, data)`;i.push([t("a"),t("b")]),r.push(e.escape)}else i.push([Je(e,{index:"a",op:a}),Je(e,{index:"b",op:o})])},window:!1}),u=Wf(t,c),l=(t,e)=>u[t][e],h=n.length;let p="return (a, b) => {"+(l&&t.isGrouped()?"const ka = keys[a], kb = keys[b];":"")+"let u, v; return ";for(let t=0;tn.add(t,null)));const u=i?Jf(t,e,i):[Qf(t,e)];e.outputs().map((t=>n.add(t,[])));const l=c.length-1;let h=0;for(let t=0;t{const s=n.data[t]=Array(h),u=r[i];for(let t=0,n=0;tt[e.as||"text"]())).then((t=>n(t,e)))}function Hm(t,e){return vt(t)?function(t,e){return zl.from(t,e)}(t):function(t,e={}){const n=Ll(e.autoType);Ot(t)&&(t=JSON.parse(t));let i,r=t.data;if(Nt(r)&&!zt(r)?t.schema&&t.schema.fields&&(i=t.schema.fields.map((t=>t.name))):r=t,n||e.parse){const t=e.parse||{};for(const e in r){const i=r[e],s=i.length;if(t[e])for(let n=0;ne?1:t>=e?0:NaN}function Gm(t,e){return null==t||null==e?NaN:et?1:e>=t?0:NaN}function Wm(t){let e,n,i;function r(t,i,r=0,s=t.length){if(r>>1;n(t[e],i)<0?r=e+1:s=e}while(rYm(t(e),n),i=(e,n)=>t(e)-n):(e=t===Ym||t===Gm?t:Km,n=t,i=t),{left:r,center:function(t,e,n=0,s=t.length){const a=r(t,e,n,s-1);return a>n&&i(t[a-1],e)>-i(t[a],e)?a-1:a},right:function(t,i,r=0,s=t.length){if(r>>1;n(t[e],i)<=0?r=e+1:s=e}while(r=ty?10:s>=ey?5:s>=ny?2:1;let o,c,u;return r<0?(u=Math.pow(10,-r)/a,o=Math.round(t*u),c=Math.round(e*u),o/ue&&--c,u=-u):(u=Math.pow(10,r)*a,o=Math.round(t/u),c=Math.round(e/u),o*ue&&--c),c=e)&&(n=e);else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(n=r)&&(n=r)}return n}function oy(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n>e||void 0===n&&e>=e)&&(n=e);else{let i=-1;for(let r of t)null!=(r=e(r,++i,t))&&(n>r||void 0===n&&r>=r)&&(n=r)}return n}function cy(t,e){let n=0,i=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(++n,i+=e);else{let r=-1;for(let s of t)null!=(s=e(s,++r,t))&&(s=+s)>=s&&(++n,i+=s)}if(n)return i/n}function uy(t,e,n){t=+t,e=+e,n=(r=arguments.length)<2?(e=t,t=0,1):r<3?1:+n;for(var i=-1,r=0|Math.max(0,Math.ceil((e-t)/n)),s=new Array(r);++ie[t]===i))).reify():s===ly.RANGE&&(a=yf().filter(qm((e=>">="===r?e[t]>=i:e[t]<=i))).reify()),e.push(a)}return e}function py(t,e,n){if(n===ly.POINT)return[{[t]:{value:e[t],type:n}}];console.log("TODO")}const dy=1,fy=.1,my="__opacity__",yy="tick",gy="background",by="foreground",vy="svgPlot",_y="svg",xy="g",wy="ellipse",Sy="line",Iy="polygon",Ay="polyline",Ty="rect",ky="path",Cy="text",My="#text",Ey="style",Ny="left",Dy="right",Oy="top",By="bottom",Ly="centerX",Fy="centerY",Vy="width",Uy="height",Py="size",Ry="colorCat",jy="fill",$y="color",zy="stroke",Hy="__inferred__data__",qy="__role__",Yy="legend",Gy="axis-domain",Wy="title",Ky="orphan-tick",Qy="viewport",Jy="mark",Zy="_mark_",Xy="_I_",tg="_gI_",eg=2,ng={COUNT:"count",MIN:"min",MAX:"max",MEAN:"mean",SUM:"sum",STDEV:"stdev",MEDIAN:"median"},ig={NONE:0,DIRECT:1,SUBSET:2,AGGREGATE:3};function rg(t,e,n=eg){return"string"==typeof t&&"string"==typeof e?t.toLowerCase()===e.toLowerCase():Math.abs(t-e)<=n}function sg(t,e,n,i=eg){const r=[],s=[];let a=0,o=0;for(;a!n.includes(t)))}function og(t,e,n,i,r=!0){function s(){}function a(t,e,n,i){const r=t.orderby(n).array(Xy),s=e.orderby(i).array(Xy),a=Object.fromEntries(r.map(((t,e)=>[t,s[e]]))),o=Object.fromEntries(s.map(((t,e)=>[t,r[e]]))),c=ag(t).filter((t=>!n.includes(t)));let u;if(c.length){const r=t.orderby(n).select(c);u=e.orderby(i).assign(r).orderby(Xy).reify()}return{map:{fromToMap:a,toFromMap:o,mergedTable:u}}}function o(t,e,n){return{fromToQuery:yf().groupby([...t,Xy]).rollup(n),toFromQuery:yf().groupby(t).derive(n),assignTable:$m({[tg]:e})}}function c(t,e,n=!1){const r=ag(t),s=ag(e);if(!r.length||!s.length||e.numRows()>t.numRows())return null;2===r.length&&r.includes("precipitation")&&r.includes("MEAN-maximum daily temperature (c)")&&2===s.length&&s.includes("precipitation (binned)")&&s.includes("mean of temp_max");const o={},c=[],u=[],l=[];for(let n=0;n=m.length){t=t.filter(qm((t=>f.includes(t[Xy])))).reify(),o[r[a]]=s[n],c.push(a),u.push(r[a]),l.push(s[n]);break}}}const h=Object.keys(o).length,p=Object.keys(o).length!==s.length;return h&&t.numRows()>e.numRows()&&(t=t.slice(0,e.numRows())),n&&h||!n&&h&&!p?{fields:o,...a(t,e,u,l)}:{}}function u(t,e,i,r){const s=ag(t),a=ag(e);if(s.length2)return null;for(let a=0;aString(Ce.bin(e[s[a]],...t)+t[2]/2)))}}));for(const n of h){const o=u(t,e,[...i,n],[...r,s[a]]);if(o)return o}}}return s.exists=function(t){return t&&Object.keys(t).length},s.direct=function(){const n=c(t,e,!1);return{link:n,type:s.exists(n)?ig.DIRECT:ig.NONE}},s.subset=function(){const n=c(t,e,!0);return{link:n,type:s.exists(n)?ig.SUBSET:ig.NONE}},s.aggregate=function(){const n=u(t,e,[],[]);return{link:n,type:s.exists(n)?ig.AGGREGATE:ig.NONE}},s.getLink=function(){const t=s.direct();if(t.type===ig.DIRECT)return t;if(r){const t=s.aggregate();if(t.type===ig.AGGREGATE)return t}const e=s.subset();return e.type===ig.SUBSET?e:{type:ig.NONE}},s}function cg(t){const{yAxis:e}=t,{scale:n,ticks:i,ordinal:r}=e,s=r.length?[]:function(t,e){const n=t.domain(),i=Math.abs(n[0]-n[1])/(e.length-1);return[...n,i]}(n,i);return[s]}function ug(t){const e={},n=.01,{xAxis:i,yAxis:r,legends:s}=t,{domain:a}=i,{domain:o}=r;i.ordinal.length||(e[i.title.innerHTML.toLowerCase()]=Math.abs(a[1]-a[0])*n),r.ordinal.length||(e[r.title.innerHTML.toLowerCase()]=Math.abs(o[1]-o[0])*n);for(const t of s)if(t.type===Py){const{scale:i}=t,r=i.domain();e[t.title.innerHTML.toLowerCase()]=Math.abs(r[0]-r[r.length-1])*n}return e}function lg(t,e,n,i,r=!1){const{aggregation:s,fields:a,map:o}=e,{fromToMap:c,toFromMap:u,mergedTable:l}=o;let h,p,d;s&&({fromToQuery:h,toFromQuery:p,assignTable:d}=s);const f={type:t,next:n,map:c,fields:a},m={type:t,next:i,map:u,fields:pg(a)};t===ig.DIRECT||t===ig.SUBSET?(i.children.push(f),n.children.push(m),r&&t===ig.SUBSET&&(n.table=l)):(i.children.push({...f,aggregation:{query:h,assignTable:d}}),n.parents.push({...m,aggregation:{query:p,assignTable:d}}))}function hg(t,e){const n=new Map;!function(t,e,n){const{table:i}=e;if(!i)return;const r=new Map;for(const n of t){const{data:t}=n;if(!t.table)continue;const s=og(i,t.table,null,ug(n)),{type:a,link:o}=s.direct(),c=[];if(a===ig.DIRECT){if(!o.map.mergedTable)return;r.set(n,!0),c.push([a,o,t])}c.forEach((t=>lg(...t,e)))}for(const s of t){const{data:t}=s;if(r.has(s))continue;if(!t.table)continue;const{type:a,link:o}=og(i,t.table,cg(s),ug(s),!0).aggregate();a===ig.AGGREGATE&&(lg(a,o,t,e),n.set(s,!0))}}(t,e,n),function(t,e){for(let n=0;n[t[e],e])))}function dg(t,e){return e.map((e=>t[e]))}function fg(t,e){return Object.fromEntries(Object.keys(t).filter((t=>t in e)).map((n=>[e[n],t[n]])))}function mg(t,e){return Object.fromEntries(Object.keys(t).map((n=>n in e?[n,e[n]]:[n,t[n]])))}function yg(t,e){let{table:n}=t;for(const[t,i]of e){const{query:e}=t;n=e.evaluate(n);const r=dg(pg(i),Array.from(n._group.keys)).map((t=>Number(t)));n=n.assign($m({[tg]:r}))}return n.ungroup()}function gg(t,e,n){const i=t.array(Xy).map((t=>n[t]));return[t.assign({[Xy]:i}),e.filter(qm((t=>i.includes(t[Xy])))).reify()].map((t=>t.filter(qm((t=>null!=t[Xy])))))}function bg(t,e,n=!1){const i=new Map;function r(t,e){if(i.has(t))return;i.set(t,!0);const{active:n,table:s}=t;n.selected=e;const{children:a}=t;for(const t of a){const{next:n,map:i,aggregation:a,fields:o,type:c}=t;let u,l=n.table;if(n.active.type=c,a){const{query:t,assignTable:n}=a,r=Object.fromEntries(s.array(Xy).map((t=>[t,t])));[,u]=gg(e,s.assign(n),r),u=t.evaluate(u.rename({[tg]:Xy})),[u,l]=gg(u,l,i),l=l.orderby(Xy).assign(u.rename(o).orderby(Xy)).unorder()}else[,l]=gg(e,l,i);r(n,l)}}function s(t){if(i.has(t))return;i.set(t,!0);const{active:e,children:n}=t;e.selected=e.table;for(const t of n){const{next:e}=t;e.active.type=ig.NONE,s(e)}}for(const i of t){const[t,a,o]=i,{active:c}=t;if(e){e=e.map((t=>(t=fg(t,o),ag(a,!0).includes(tg)&&Xy in t&&(t[tg]=t[Xy],delete t[Xy]),t)));let i=c.selected.numRows(){i=t.evaluate(i||a)})),n&&(i=t.active.selected.concat(i)),r(t,i)}else s(t)}}function vg(t,e){!function(t,e){bt(t).attr("opacity",e)}(t,e)}function _g(t){vg(t,t[0][my]||dy)}function xg(t,e){!function(t){vg(t,fy)}(t),vg(e,dy)}function wg(t,e){for(const n of t){if(!n.title)continue;const t=n.title.innerHTML.toLowerCase(),i=e.array(t);if("precipitation"===t)continue;const r=n.marks.filter((e=>i.includes(e.mark[Hy][t]))).map((t=>t.mark));xg(n.marks.map((t=>t.mark)),r)}}function Sg(t,e,n){const i=e.array(Zy);bt("."+t+".AGGREGATE_LAYER").remove();const r=[];for(let s=0;s>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?Kg(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?Kg(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=Ug.exec(t))?new Jg(e[1],e[2],e[3],1):(e=Pg.exec(t))?new Jg(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=Rg.exec(t))?Kg(e[1],e[2],e[3],e[4]):(e=jg.exec(t))?Kg(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=$g.exec(t))?ib(e[1],e[2]/100,e[3]/100,1):(e=zg.exec(t))?ib(e[1],e[2]/100,e[3]/100,e[4]):Hg.hasOwnProperty(t)?Wg(Hg[t]):"transparent"===t?new Jg(NaN,NaN,NaN,0):null}function Wg(t){return new Jg(t>>16&255,t>>8&255,255&t,1)}function Kg(t,e,n,i){return i<=0&&(t=e=n=NaN),new Jg(t,e,n,i)}function Qg(t,e,n,i){return 1===arguments.length?((r=t)instanceof Ng||(r=Gg(r)),r?new Jg((r=r.rgb()).r,r.g,r.b,r.opacity):new Jg):new Jg(t,e,n,null==i?1:i);var r}function Jg(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}function Zg(){return`#${nb(this.r)}${nb(this.g)}${nb(this.b)}`}function Xg(){const t=tb(this.opacity);return`${1===t?"rgb(":"rgba("}${eb(this.r)}, ${eb(this.g)}, ${eb(this.b)}${1===t?")":`, ${t})`}`}function tb(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function eb(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function nb(t){return((t=eb(t))<16?"0":"")+t.toString(16)}function ib(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new sb(t,e,n,i)}function rb(t){if(t instanceof sb)return new sb(t.h,t.s,t.l,t.opacity);if(t instanceof Ng||(t=Gg(t)),!t)return new sb;if(t instanceof sb)return t;var e=(t=t.rgb()).r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),s=Math.max(e,n,i),a=NaN,o=s-r,c=(s+r)/2;return o?(a=e===s?(n-i)/o+6*(n0&&c<1?0:a,new sb(a,o,c,t.opacity)}function sb(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function ab(t){return(t=(t||0)%360)<0?t+360:t}function ob(t){return Math.max(0,Math.min(1,t||0))}function cb(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Mg(Ng,Gg,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:qg,formatHex:qg,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return rb(this).formatHsl()},formatRgb:Yg,toString:Yg}),Mg(Jg,Qg,Eg(Ng,{brighter(t){return t=null==t?Og:Math.pow(Og,t),new Jg(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Dg:Math.pow(Dg,t),new Jg(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Jg(eb(this.r),eb(this.g),eb(this.b),tb(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Zg,formatHex:Zg,formatHex8:function(){return`#${nb(this.r)}${nb(this.g)}${nb(this.b)}${nb(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Xg,toString:Xg})),Mg(sb,(function(t,e,n,i){return 1===arguments.length?rb(t):new sb(t,e,n,null==i?1:i)}),Eg(Ng,{brighter(t){return t=null==t?Og:Math.pow(Og,t),new sb(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Dg:Math.pow(Dg,t),new sb(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new Jg(cb(t>=240?t-240:t+120,r,i),cb(t,r,i),cb(t<120?t+240:t-120,r,i),this.opacity)},clamp(){return new sb(ab(this.h),ob(this.s),ob(this.l),tb(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=tb(this.opacity);return`${1===t?"hsl(":"hsla("}${ab(this.h)}, ${100*ob(this.s)}%, ${100*ob(this.l)}%${1===t?")":`, ${t})`}`}}));var ub=t=>()=>t;function lb(t){return 1==(t=+t)?hb:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}(e,n,t):ub(isNaN(e)?n:e)}}function hb(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):ub(isNaN(t)?e:t)}var pb=function t(e){var n=lb(e);function i(t,e){var i=n((t=Qg(t)).r,(e=Qg(e)).r),r=n(t.g,e.g),s=n(t.b,e.b),a=hb(t.opacity,e.opacity);return function(e){return t.r=i(e),t.g=r(e),t.b=s(e),t.opacity=a(e),t+""}}return i.gamma=t,i}(1);function db(t,e){e||(e=[]);var n,i=t?Math.min(e.length,t.length):0,r=e.slice();return function(s){for(n=0;ns&&(r=e.slice(s,r),o[a]?o[a]+=r:o[++a]=r),(n=n[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,c.push({i:a,x:yb(n,i)})),s=vb.lastIndex;return se&&(n=t,t=e,e=n),function(n){return Math.max(t,Math.min(e,n))}}(a[0],a[t-1])),i=t>2?Cb:kb,r=s=null,h}function h(e){return null==e||isNaN(e=+e)?n:(r||(r=i(a.map(t),o,c)))(t(u(e)))}return h.invert=function(n){return u(e((s||(s=i(o,a.map(t),yb)))(n)))},h.domain=function(t){return arguments.length?(a=Array.from(t,Sb),l()):a.slice()},h.range=function(t){return arguments.length?(o=Array.from(t),l()):o.slice()},h.rangeRound=function(t){return o=Array.from(t),c=wb,l()},h.clamp=function(t){return arguments.length?(u=!!t||Ab,l()):u!==Ab},h.interpolate=function(t){return arguments.length?(c=t,l()):c},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,i){return t=n,e=i,l()}}function Nb(){return Eb()(Ab,Ab)}function Db(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,i=t.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+t.slice(n+1)]}function Ob(t){return(t=Db(Math.abs(t)))?t[1]:NaN}var Bb,Lb=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Fb(t){if(!(e=Lb.exec(t)))throw new Error("invalid format: "+t);var e;return new Vb({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function Vb(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Ub(t,e){var n=Db(t,e);if(!n)return t+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}Fb.prototype=Vb.prototype,Vb.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Pb={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Ub(100*t,e),r:Ub,s:function(t,e){var n=Db(t,e);if(!n)return t+"";var i=n[0],r=n[1],s=r-(Bb=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,a=i.length;return s===a?i:s>a?i+new Array(s-a+1).join("0"):s>0?i.slice(0,s)+"."+i.slice(s):"0."+new Array(1-s).join("0")+Db(t,Math.max(0,e+s-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Rb(t){return t}var jb,$b,zb,Hb=Array.prototype.map,qb=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Yb(t){var e,n,i=void 0===t.grouping||void 0===t.thousands?Rb:(e=Hb.call(t.grouping,Number),n=t.thousands+"",function(t,i){for(var r=t.length,s=[],a=0,o=e[0],c=0;r>0&&o>0&&(c+o+1>i&&(o=Math.max(1,i-c)),s.push(t.substring(r-=o,r+o)),!((c+=o+1)>i));)o=e[a=(a+1)%e.length];return s.reverse().join(n)}),r=void 0===t.currency?"":t.currency[0]+"",s=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",o=void 0===t.numerals?Rb:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(Hb.call(t.numerals,String)),c=void 0===t.percent?"%":t.percent+"",u=void 0===t.minus?"−":t.minus+"",l=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=Fb(t)).fill,n=t.align,h=t.sign,p=t.symbol,d=t.zero,f=t.width,m=t.comma,y=t.precision,g=t.trim,b=t.type;"n"===b?(m=!0,b="g"):Pb[b]||(void 0===y&&(y=12),g=!0,b="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var v="$"===p?r:"#"===p&&/[boxX]/.test(b)?"0"+b.toLowerCase():"",_="$"===p?s:/[%p]/.test(b)?c:"",x=Pb[b],w=/[defgprs%]/.test(b);function S(t){var r,s,c,p=v,S=_;if("c"===b)S=x(t)+S,t="";else{var I=(t=+t)<0||1/t<0;if(t=isNaN(t)?l:x(Math.abs(t),y),g&&(t=function(t){t:for(var e,n=t.length,i=1,r=-1;i0&&(r=0)}return r>0?t.slice(0,r)+t.slice(e+1):t}(t)),I&&0==+t&&"+"!==h&&(I=!1),p=(I?"("===h?h:u:"-"===h||"("===h?"":h)+p,S=("s"===b?qb[8+Bb/3]:"")+S+(I&&"("===h?")":""),w)for(r=-1,s=t.length;++r(c=t.charCodeAt(r))||c>57){S=(46===c?a+t.slice(r+1):t.slice(r))+S,t=t.slice(0,r);break}}m&&!d&&(t=i(t,1/0));var A=p.length+t.length+S.length,T=A>1)+p+t+S+T.slice(A);break;default:t=T+p+t+S}return o(t)}return y=void 0===y?6:/[gprs]/.test(b)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y)),S.toString=function(){return t+""},S}return{format:h,formatPrefix:function(t,e){var n=h(((t=Fb(t)).type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor(Ob(e)/3))),r=Math.pow(10,-i),s=qb[8+i/3];return function(t){return n(r*t)+s}}}}function Gb(t,e,n,i){var r,s=sy(t,e,n);switch((i=Fb(null==i?",f":i)).type){case"s":var a=Math.max(Math.abs(t),Math.abs(e));return null!=i.precision||isNaN(r=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Ob(e)/3)))-Ob(Math.abs(t)))}(s,a))||(i.precision=r),zb(i,a);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(r=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Ob(e)-Ob(t))+1}(s,Math.max(Math.abs(t),Math.abs(e))))||(i.precision=r-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(r=function(t){return Math.max(0,-Ob(Math.abs(t)))}(s))||(i.precision=r-2*("%"===i.type))}return $b(i)}function Wb(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){if(!((n=+n)>0))return[];if((t=+t)==(e=+e))return[t];const i=e=r))return[];const o=s-r+1,c=new Array(o);if(i)if(a<0)for(let t=0;t0;){if((r=ry(c,u,n))===i)return s[a]=c,s[o]=u,e(s);if(r>0)c=Math.floor(c/r)*r,u=Math.ceil(u/r)*r;else{if(!(r<0))break;c=Math.ceil(c*r)/r,u=Math.floor(u*r)/r}i=r}return t},t}function Kb(){var t=Nb();return t.copy=function(){return Mb(t,Kb())},Ag.apply(t,arguments),Wb(t)}jb=Yb({thousands:",",grouping:[3],currency:["$",""]}),$b=jb.format,zb=jb.formatPrefix;const Qb=new Date,Jb=new Date;function Zb(t,e,n,i){function r(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return r.floor=e=>(t(e=new Date(+e)),e),r.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),r.round=t=>{const e=r(t),n=r.ceil(t);return t-e(e(t=new Date(+t),null==n?1:Math.floor(n)),t),r.range=(n,i,s)=>{const a=[];if(n=r.ceil(n),s=null==s?1:Math.floor(s),!(n0))return a;let o;do{a.push(o=new Date(+n)),e(n,s),t(n)}while(oZb((e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)}),((t,i)=>{if(t>=t)if(i<0)for(;++i<=0;)for(;e(t,-1),!n(t););else for(;--i>=0;)for(;e(t,1),!n(t););})),n&&(r.count=(e,i)=>(Qb.setTime(+e),Jb.setTime(+i),t(Qb),t(Jb),Math.floor(n(Qb,Jb))),r.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?r.filter(i?e=>i(e)%t==0:e=>r.count(0,e)%t==0):r:null)),r}const Xb=Zb((()=>{}),((t,e)=>{t.setTime(+t+e)}),((t,e)=>e-t));Xb.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?Zb((e=>{e.setTime(Math.floor(e/t)*t)}),((e,n)=>{e.setTime(+e+n*t)}),((e,n)=>(n-e)/t)):Xb:null),Xb.range;const tv=1e3,ev=6e4,nv=36e5,iv=864e5,rv=6048e5,sv=2592e6,av=31536e6,ov=Zb((t=>{t.setTime(t-t.getMilliseconds())}),((t,e)=>{t.setTime(+t+e*tv)}),((t,e)=>(e-t)/tv),(t=>t.getUTCSeconds()));ov.range;const cv=Zb((t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*tv)}),((t,e)=>{t.setTime(+t+e*ev)}),((t,e)=>(e-t)/ev),(t=>t.getMinutes()));cv.range;const uv=Zb((t=>{t.setUTCSeconds(0,0)}),((t,e)=>{t.setTime(+t+e*ev)}),((t,e)=>(e-t)/ev),(t=>t.getUTCMinutes()));uv.range;const lv=Zb((t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*tv-t.getMinutes()*ev)}),((t,e)=>{t.setTime(+t+e*nv)}),((t,e)=>(e-t)/nv),(t=>t.getHours()));lv.range;const hv=Zb((t=>{t.setUTCMinutes(0,0,0)}),((t,e)=>{t.setTime(+t+e*nv)}),((t,e)=>(e-t)/nv),(t=>t.getUTCHours()));hv.range;const pv=Zb((t=>t.setHours(0,0,0,0)),((t,e)=>t.setDate(t.getDate()+e)),((t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ev)/iv),(t=>t.getDate()-1));pv.range;const dv=Zb((t=>{t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+e)}),((t,e)=>(e-t)/iv),(t=>t.getUTCDate()-1));dv.range;const fv=Zb((t=>{t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+e)}),((t,e)=>(e-t)/iv),(t=>Math.floor(t/iv)));function mv(t){return Zb((e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)}),((t,e)=>{t.setDate(t.getDate()+7*e)}),((t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ev)/rv))}fv.range;const yv=mv(0),gv=mv(1),bv=mv(2),vv=mv(3),_v=mv(4),xv=mv(5),wv=mv(6);function Sv(t){return Zb((e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)}),((t,e)=>(e-t)/rv))}yv.range,gv.range,bv.range,vv.range,_v.range,xv.range,wv.range;const Iv=Sv(0),Av=Sv(1),Tv=Sv(2),kv=Sv(3),Cv=Sv(4),Mv=Sv(5),Ev=Sv(6);Iv.range,Av.range,Tv.range,kv.range,Cv.range,Mv.range,Ev.range;const Nv=Zb((t=>{t.setDate(1),t.setHours(0,0,0,0)}),((t,e)=>{t.setMonth(t.getMonth()+e)}),((t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear())),(t=>t.getMonth()));Nv.range;const Dv=Zb((t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)}),((t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear())),(t=>t.getUTCMonth()));Dv.range;const Ov=Zb((t=>{t.setMonth(0,1),t.setHours(0,0,0,0)}),((t,e)=>{t.setFullYear(t.getFullYear()+e)}),((t,e)=>e.getFullYear()-t.getFullYear()),(t=>t.getFullYear()));Ov.every=t=>isFinite(t=Math.floor(t))&&t>0?Zb((e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)}),((e,n)=>{e.setFullYear(e.getFullYear()+n*t)})):null,Ov.range;const Bv=Zb((t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)}),((t,e)=>e.getUTCFullYear()-t.getUTCFullYear()),(t=>t.getUTCFullYear()));Bv.every=t=>isFinite(t=Math.floor(t))&&t>0?Zb((e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),((e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)})):null,Bv.range;const[Lv,Fv]=function(t,e,n,i,r,s){const a=[[ov,1,tv],[ov,5,5e3],[ov,15,15e3],[ov,30,3e4],[s,1,ev],[s,5,3e5],[s,15,9e5],[s,30,18e5],[r,1,nv],[r,3,108e5],[r,6,216e5],[r,12,432e5],[i,1,iv],[i,2,1728e5],[n,1,rv],[e,1,sv],[e,3,7776e6],[t,1,av]];function o(e,n,i){const r=Math.abs(n-e)/i,s=Wm((([,,t])=>t)).right(a,r);if(s===a.length)return t.every(sy(e/av,n/av,i));if(0===s)return Xb.every(Math.max(sy(e,n,i),1));const[o,c]=a[r/a[s-1][2][t.toLowerCase(),e])))}function Jv(t,e,n){var i=Hv.exec(e.slice(n,n+1));return i?(t.w=+i[0],n+i[0].length):-1}function Zv(t,e,n){var i=Hv.exec(e.slice(n,n+1));return i?(t.u=+i[0],n+i[0].length):-1}function Xv(t,e,n){var i=Hv.exec(e.slice(n,n+2));return i?(t.U=+i[0],n+i[0].length):-1}function t_(t,e,n){var i=Hv.exec(e.slice(n,n+2));return i?(t.V=+i[0],n+i[0].length):-1}function e_(t,e,n){var i=Hv.exec(e.slice(n,n+2));return i?(t.W=+i[0],n+i[0].length):-1}function n_(t,e,n){var i=Hv.exec(e.slice(n,n+4));return i?(t.y=+i[0],n+i[0].length):-1}function i_(t,e,n){var i=Hv.exec(e.slice(n,n+2));return i?(t.y=+i[0]+(+i[0]>68?1900:2e3),n+i[0].length):-1}function r_(t,e,n){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return i?(t.Z=i[1]?0:-(i[2]+(i[3]||"00")),n+i[0].length):-1}function s_(t,e,n){var i=Hv.exec(e.slice(n,n+1));return i?(t.q=3*i[0]-3,n+i[0].length):-1}function a_(t,e,n){var i=Hv.exec(e.slice(n,n+2));return i?(t.m=i[0]-1,n+i[0].length):-1}function o_(t,e,n){var i=Hv.exec(e.slice(n,n+2));return i?(t.d=+i[0],n+i[0].length):-1}function c_(t,e,n){var i=Hv.exec(e.slice(n,n+3));return i?(t.m=0,t.d=+i[0],n+i[0].length):-1}function u_(t,e,n){var i=Hv.exec(e.slice(n,n+2));return i?(t.H=+i[0],n+i[0].length):-1}function l_(t,e,n){var i=Hv.exec(e.slice(n,n+2));return i?(t.M=+i[0],n+i[0].length):-1}function h_(t,e,n){var i=Hv.exec(e.slice(n,n+2));return i?(t.S=+i[0],n+i[0].length):-1}function p_(t,e,n){var i=Hv.exec(e.slice(n,n+3));return i?(t.L=+i[0],n+i[0].length):-1}function d_(t,e,n){var i=Hv.exec(e.slice(n,n+6));return i?(t.L=Math.floor(i[0]/1e3),n+i[0].length):-1}function f_(t,e,n){var i=qv.exec(e.slice(n,n+1));return i?n+i[0].length:-1}function m_(t,e,n){var i=Hv.exec(e.slice(n));return i?(t.Q=+i[0],n+i[0].length):-1}function y_(t,e,n){var i=Hv.exec(e.slice(n));return i?(t.s=+i[0],n+i[0].length):-1}function g_(t,e){return Gv(t.getDate(),e,2)}function b_(t,e){return Gv(t.getHours(),e,2)}function v_(t,e){return Gv(t.getHours()%12||12,e,2)}function __(t,e){return Gv(1+pv.count(Ov(t),t),e,3)}function x_(t,e){return Gv(t.getMilliseconds(),e,3)}function w_(t,e){return x_(t,e)+"000"}function S_(t,e){return Gv(t.getMonth()+1,e,2)}function I_(t,e){return Gv(t.getMinutes(),e,2)}function A_(t,e){return Gv(t.getSeconds(),e,2)}function T_(t){var e=t.getDay();return 0===e?7:e}function k_(t,e){return Gv(yv.count(Ov(t)-1,t),e,2)}function C_(t){var e=t.getDay();return e>=4||0===e?_v(t):_v.ceil(t)}function M_(t,e){return t=C_(t),Gv(_v.count(Ov(t),t)+(4===Ov(t).getDay()),e,2)}function E_(t){return t.getDay()}function N_(t,e){return Gv(gv.count(Ov(t)-1,t),e,2)}function D_(t,e){return Gv(t.getFullYear()%100,e,2)}function O_(t,e){return Gv((t=C_(t)).getFullYear()%100,e,2)}function B_(t,e){return Gv(t.getFullYear()%1e4,e,4)}function L_(t,e){var n=t.getDay();return Gv((t=n>=4||0===n?_v(t):_v.ceil(t)).getFullYear()%1e4,e,4)}function F_(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Gv(e/60|0,"0",2)+Gv(e%60,"0",2)}function V_(t,e){return Gv(t.getUTCDate(),e,2)}function U_(t,e){return Gv(t.getUTCHours(),e,2)}function P_(t,e){return Gv(t.getUTCHours()%12||12,e,2)}function R_(t,e){return Gv(1+dv.count(Bv(t),t),e,3)}function j_(t,e){return Gv(t.getUTCMilliseconds(),e,3)}function $_(t,e){return j_(t,e)+"000"}function z_(t,e){return Gv(t.getUTCMonth()+1,e,2)}function H_(t,e){return Gv(t.getUTCMinutes(),e,2)}function q_(t,e){return Gv(t.getUTCSeconds(),e,2)}function Y_(t){var e=t.getUTCDay();return 0===e?7:e}function G_(t,e){return Gv(Iv.count(Bv(t)-1,t),e,2)}function W_(t){var e=t.getUTCDay();return e>=4||0===e?Cv(t):Cv.ceil(t)}function K_(t,e){return t=W_(t),Gv(Cv.count(Bv(t),t)+(4===Bv(t).getUTCDay()),e,2)}function Q_(t){return t.getUTCDay()}function J_(t,e){return Gv(Av.count(Bv(t)-1,t),e,2)}function Z_(t,e){return Gv(t.getUTCFullYear()%100,e,2)}function X_(t,e){return Gv((t=W_(t)).getUTCFullYear()%100,e,2)}function tx(t,e){return Gv(t.getUTCFullYear()%1e4,e,4)}function ex(t,e){var n=t.getUTCDay();return Gv((t=n>=4||0===n?Cv(t):Cv.ceil(t)).getUTCFullYear()%1e4,e,4)}function nx(){return"+0000"}function ix(){return"%"}function rx(t){return+t}function sx(t){return Math.floor(+t/1e3)}function ax(t){return new Date(t)}function ox(t){return t instanceof Date?+t:+new Date(+t)}function cx(t,e,n,i,r,s,a,o,c,u){var l=Nb(),h=l.invert,p=l.domain,d=u(".%L"),f=u(":%S"),m=u("%I:%M"),y=u("%I %p"),g=u("%a %d"),b=u("%b %d"),v=u("%B"),_=u("%Y");function x(t){return(c(t)(i,r)=>null==t?i._getBBox()[e]-r._getBBox()[e]:n?i[t]-r[t]:(i[t]?i[t]:i.marks[0])._getBBox()[e]-(r[t]?r[t]:r.marks[0])._getBBox()[e];e.sort(i(Ly)),e.sort(i(Fy))}!function(t){Rv=function(t){var e=t.dateTime,n=t.date,i=t.time,r=t.periods,s=t.days,a=t.shortDays,o=t.months,c=t.shortMonths,u=Kv(r),l=Qv(r),h=Kv(s),p=Qv(s),d=Kv(a),f=Qv(a),m=Kv(o),y=Qv(o),g=Kv(c),b=Qv(c),v={a:function(t){return a[t.getDay()]},A:function(t){return s[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return o[t.getMonth()]},c:null,d:g_,e:g_,f:w_,g:O_,G:L_,H:b_,I:v_,j:__,L:x_,m:S_,M:I_,p:function(t){return r[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:rx,s:sx,S:A_,u:T_,U:k_,V:M_,w:E_,W:N_,x:null,X:null,y:D_,Y:B_,Z:F_,"%":ix},_={a:function(t){return a[t.getUTCDay()]},A:function(t){return s[t.getUTCDay()]},b:function(t){return c[t.getUTCMonth()]},B:function(t){return o[t.getUTCMonth()]},c:null,d:V_,e:V_,f:$_,g:X_,G:ex,H:U_,I:P_,j:R_,L:j_,m:z_,M:H_,p:function(t){return r[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:rx,s:sx,S:q_,u:Y_,U:G_,V:K_,w:Q_,W:J_,x:null,X:null,y:Z_,Y:tx,Z:nx,"%":ix},x={a:function(t,e,n){var i=d.exec(e.slice(n));return i?(t.w=f.get(i[0].toLowerCase()),n+i[0].length):-1},A:function(t,e,n){var i=h.exec(e.slice(n));return i?(t.w=p.get(i[0].toLowerCase()),n+i[0].length):-1},b:function(t,e,n){var i=g.exec(e.slice(n));return i?(t.m=b.get(i[0].toLowerCase()),n+i[0].length):-1},B:function(t,e,n){var i=m.exec(e.slice(n));return i?(t.m=y.get(i[0].toLowerCase()),n+i[0].length):-1},c:function(t,n,i){return I(t,e,n,i)},d:o_,e:o_,f:d_,g:i_,G:n_,H:u_,I:u_,j:c_,L:p_,m:a_,M:l_,p:function(t,e,n){var i=u.exec(e.slice(n));return i?(t.p=l.get(i[0].toLowerCase()),n+i[0].length):-1},q:s_,Q:m_,s:y_,S:h_,u:Zv,U:Xv,V:t_,w:Jv,W:e_,x:function(t,e,i){return I(t,n,e,i)},X:function(t,e,n){return I(t,i,e,n)},y:i_,Y:n_,Z:r_,"%":f_};function w(t,e){return function(n){var i,r,s,a=[],o=-1,c=0,u=t.length;for(n instanceof Date||(n=new Date(+n));++o53)return null;"w"in s||(s.w=1),"Z"in s?(r=(i=Uv(Pv(s.y,0,1))).getUTCDay(),i=r>4||0===r?Av.ceil(i):Av(i),i=dv.offset(i,7*(s.V-1)),s.y=i.getUTCFullYear(),s.m=i.getUTCMonth(),s.d=i.getUTCDate()+(s.w+6)%7):(r=(i=Vv(Pv(s.y,0,1))).getDay(),i=r>4||0===r?gv.ceil(i):gv(i),i=pv.offset(i,7*(s.V-1)),s.y=i.getFullYear(),s.m=i.getMonth(),s.d=i.getDate()+(s.w+6)%7)}else("W"in s||"U"in s)&&("w"in s||(s.w="u"in s?s.u%7:"W"in s?1:0),r="Z"in s?Uv(Pv(s.y,0,1)).getUTCDay():Vv(Pv(s.y,0,1)).getDay(),s.m=0,s.d="W"in s?(s.w+6)%7+7*s.W-(r+5)%7:s.w+7*s.U-(r+6)%7);return"Z"in s?(s.H+=s.Z/100|0,s.M+=s.Z%100,Uv(s)):Vv(s)}}function I(t,e,n,i){for(var r,s,a=0,o=e.length,c=n.length;a=c)return-1;if(37===(r=e.charCodeAt(a++))){if(r=e.charAt(a++),!(s=x[r in zv?e.charAt(a++):r])||(i=s(t,n,i))<0)return-1}else if(r!=n.charCodeAt(i++))return-1}return i}return v.x=w(n,v),v.X=w(i,v),v.c=w(e,v),_.x=w(n,_),_.X=w(i,_),_.c=w(e,_),{format:function(t){var e=w(t+="",v);return e.toString=function(){return t},e},parse:function(t){var e=S(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=w(t+="",_);return e.toString=function(){return t},e},utcParse:function(t){var e=S(t+="",!0);return e.toString=function(){return t},e}}}(t),jv=Rv.format,$v=Rv.parse,Rv.utcFormat,Rv.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});class gx{constructor(...t){if(t[0]instanceof gx){const[e]=t;this.translate={...e.translate},this.scale={...e.scale},this.rotate=e.rotate}else{const[e,n,i,r,s]=t;this.translate={x:e||0,y:n||0},this.scale={x:i||1,y:r||1},this.rotate=s||0}}addTransform(t){return this.translate.x+=t.translate.x,this.translate.y+=t.translate.y,this.scale.x*=t.scale.x,this.scale.y*=t.scale.y,this.rotate+=t.rotate,this}getTransform(t=new gx){return"translate("+(this.translate.x+t.translate.x)+","+(this.translate.y+t.translate.y)+") scale("+this.scale.x*t.scale.x+","+this.scale.y*t.scale.y+") rotate("+(this.rotate+t.rotate)+")"}}const bx=1,vx=2,_x=3,xx=4;function wx(t){return e=>+t(e)}function Sx(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function Ix(t,e,n){let i=[],r=null,s=null,a=6,o=6,c=3,u="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5;const l=t===bx||t===_x?n.xAxis:n.yAxis,h=l.ticks;function p(){let n=null==r?e.ticks?e.ticks.apply(e,i):e.domain():r;const a=null==s?e.tickFormat?e.tickFormat.apply(e,i):lx:s,o=(e.bandwidth?Sx:wx)(e.copy(),u);function c(e,n){e.value=n;const i=e.label,r=e.marks;i.innerHTML=l.ordinal.length||i.value===a(n)?i.value:a(n);const s=i.globalPosition.translate.x,c=i.globalPosition.translate.y,u=t===_x?o(n)-s:0,h=t===xx?o(n)-c:0;i.setAttribute("transform",i.localTransform.getTransform(new gx(u,h)));for(const e of r){const i=e.globalPosition.translate.x,r=e.globalPosition.translate.y,s=t===_x?o(n)-i:0,a=t===xx?o(n)-r:0;e.setAttribute("transform",e.localTransform.getTransform(new gx(s,a)))}}let p;for(n=t===xx||t===vx?n.reverse():n,p=0;ppx(t))),value:0};c(t,n[p]),h[0].label.parentElement.appendChild(t.label),h[0].marks.forEach(((e,n)=>e.parentElement.insertBefore(t.marks[n],e))),h.push(t)}const d=h.length;for(;pt.remove())),h.pop()}}return p.applyTransform=function(t){return arguments.length?(scale_transform=t,p):p},p.scale=function(t){return arguments.length?(e=t,p):e},p.ticks=function(){return i=Array.from(arguments),p},p.tickArguments=function(t){return arguments.length?(i=null==t?[]:Array.from(t),p):i.slice()},p.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),p):r&&r.slice()},p.tickFormat=function(t){return arguments.length?(s=t,p):s},p.tickSize=function(t){return arguments.length?(a=o=+t,p):a},p.tickSizeInner=function(t){return arguments.length?(a=+t,p):a},p.tickSizeOuter=function(t){return arguments.length?(o=+t,p):o},p.tickPadding=function(t){return arguments.length?(c=+t,p):c},p.offset=function(t){return arguments.length?(u=+t,p):u},p}function Ax(t,e){const n=t.step(),i=t(t.domain()[0])+t.paddingOuter()*n,r=t.bandwidth();let s=Math.round(Math.abs(e-i-r/2)/n);return s=ay([0,oy([t.domain().length-1,s])]),t.domain()[t.domain().length-1-s]}function Tx(t,e){return t.domain()[t.range().indexOf(e)]}function kx(t,e=new gx){if(!t.transform)return;const n=t.transform.baseVal;for(let t=0;t{const n=e._getBBox(),i=window.getComputedStyle(e),s=[n.width,n.height,i.fill,i.color,i.stroke].join(",");s in r?r[s].push([t,e]):r[s]=[[t,e]]})),Object.values(r).forEach((t=>n.push([i,a(t)])))}}else for(const[e,i]of Object.entries(t))n.push([e,a(i)]);return n}function r(t,e){const n=new Map,i=new Map;for(const[t,r]of e)for(const e of r)for(const r of e){const s=n.get(r);(!s||e.length>s.length)&&(n.set(r,e),i.set(e,t))}const r=[];for(let e=0;e({alignment:i.get(t),marks:t})))}const s=r(t,i(n(t,!1))),o=n(e),c=r(e,i(o,!0)),u=i(o).map((([t,e])=>e.map((e=>({alignment:t,marks:e}))))).flat();return[s,c,u]}(t.textMarks,t.svgMarks),r=o(e,n);r=r.sort(((t,e)=>t.text[0]._getBBox()[Ly]-e.text[0]._getBBox()[Fy])),r.length>=2&&(r=[r[0],r[1]],function(e){const n=new Map,i=[];function r(e,n,i){n===Oy||n===By?t.xAxis.ticks.push({label:e,marks:i}):t.yAxis.ticks.push({label:e,marks:i}),i.forEach((t=>{t[qy]=e?yy:Ky}))}for(const{alignment:t,group:r}of e)for(const e of r){const[r,s]=e,a=new Map;for(const[e,i]of r)a.set(i,!0),n.has(e)?n.get(e).ticks.push(i):n.set(e,{alignment:t,ticks:[i]});s.filter((t=>!a.has(t))).forEach((e=>{i.push({alignment:t,tick:e})}))}for(const[t,{alignment:e,ticks:i}]of n)r(t,e,i);for(const{alignment:t,tick:e}of i)r(null,t,[e]);[t.xAxis,t.yAxis].forEach((t=>yx("label",t.ticks)))}(r),e=e.filter((t=>!r.map((t=>t.text)).includes(t.marks))));const s=o(e,i,!1).filter((t=>t.dist<5*Ex));function a(t){t.sort(((t,e)=>t[0]-e[0]));const e=[[t[0][0],[t[0][1]]]];for(let n=1;nt[1]))}function o(t,e,n=!0){function i(t,e){e.sort(((e,n)=>{const i=e._getBBox(),r=n._getBBox();return c.includes(t)?i[Ly]-r[Ly]:i[Fy]-r[Fy]}))}function r(t,e,n){const i=[0,0,0],r=[0,0,0];function s(t,e,i){const r=e._getBBox(),s=o.includes(n)?o:c;for(let e=0;es(i,e,t.length))),e.forEach((t=>s(r,t,e.length))),oy([oy(i)-oy(r),oy(i)-ay(r),ay(i)-oy(r),ay(i)-ay(r)].map((t=>Math.abs(t))))}function s(t,e,n){let i=0,r=0;const s=new Map;for(const a of e){const e=a._getBBox();let o=Number.MAX_SAFE_INTEGER;if(i===n.length)return[Number.MAX_SAFE_INTEGER,null];for(;i<=n.length;){const u=n[oy([i,n.length-1])]._getBBox(),l=c.includes(t)?Ly:Fy,h=Math.abs(u[l]-e[l]);if(h>=o){s.set(a,n[i-1]),r+=o;break}o=h,++i}}return[r/e.length,s]}const a=[],o=[Ny,Dy,Ly],c=[Oy,By,Fy];for(const{alignment:u,marks:l}of t){if(1===l.length)continue;let t={dist:Number.MAX_SAFE_INTEGER,group:null};i(u,l);for(const{alignment:a,marks:h}of e){if(h.lengthEx)continue;i(u,h);const[e,p]=s(u,l,h);if(e===Number.MAX_SAFE_INTEGER)continue;const d=Math.abs(e-t.dist)t.dist-e.dist)),a}s.length&&(!function(t,e){let n;function i(t){if(t.type===Ry){const e=t.marks.map((t=>t.label.innerHTML)),i=t.marks.map((e=>window.getComputedStyle(e.mark)[t.matchingAttr]));n=kg().domain(e).range(i)}else{const e=t.marks.map((t=>+t.label.innerHTML)),i=t.marks.map((t=>t.mark._getBBox().width**2));n=Kb().domain(e).range(i)}t.scale=n}function r(t){return{title:null,marks:Array.from(t.group[0][0]).map((([t,e])=>({label:t,mark:e})))}}for(let n of e){n=r(n);const s=window.getComputedStyle(n.marks[0].mark),a=window.getComputedStyle(n.marks[1].mark);let o=null;if(s.stroke!==a.stroke?o=zy:s.color!==a.color?o=$y:s.fill!==a.fill&&(o=jy),o)n.type=Ry,n.matchingAttr=o;else{const t=[],i=[];for(let e=1;e2||cy(i)>2))return void e.splice(e.indexOf(n),1);n.type=Py}for(const{label:t,mark:e}of n.marks)t[qy]=e[qy]=Yy,e.style["pointer-events"]="fill",e.legend=n,e[my]=e.hasAttribute("opacity")?+e.getAttribute("opacity"):window.getComputedStyle(e).opacity||dy;i(n),yx("label",n.marks,n.type===Py),t.legends.push(n)}}(t,s),e=e.filter((t=>!s.map((t=>t.text)).includes(t.marks)))),function(e){const n=new Map;function i(t){const e=t._getBBox();return[e.centerX,e.centerY]}function r(t,n){let r={title:null,dist:Number.MAX_SAFE_INTEGER};for(const s of e){const[e,a]=i(s),o=Math.abs(e-t)+Math.abs(a-n);ot.label)).map((t=>i(t.label))),s=r(cy(e.map((t=>t[0]))),cy(e.map((t=>t[1])))),{title:a,dist:o}=s;a&&((!n.has(a)||o!t[qy]))[0]}(e.map((t=>t.marks)).flat()),t.legends.forEach((t=>function(t){const{scale:e,title:n,type:i,matchingAttr:r}=t;for(const{mark:s}of t.marks){const t=Tx(e,i===Ry?window.getComputedStyle(s)[r]:s._getBBox().width**2);s[Hy]={[n?n.innerHTML.toLowerCase():"legend-0"]:t}}}(t)))}function Dx(t){for(const e of t.svgMarks){const n=e._getBBox();if(n.width>=t.xAxis.range[1]-t.xAxis.range[0]&&n.height>=t.yAxis.range[0]-t.yAxis.range[1]){e[qy]=Qy;continue}const i=t.svg._getBBox(),[r,s]=t.xAxis.range,[a,o]=t.yAxis.range.map((t=>t+i.top));(n.top<=o&&n.bottom>=a&&n.left<=r||n.top<=o&&n.bottom>=a&&n.right>=s||!(n.right>=r&&n.left<=s&&n.bottom>=o&&n.top<=a))&&(e[qy]=Gy);for(const e of t.legends)for(const{mark:t}of e.marks)t[qy]=Yy}t.svgMarks=t.svgMarks.filter((t=>!t[qy])),t.svgMarks.forEach((t=>{t[qy]=Jy})),yx(null,t.svgMarks,!1)}function Ox(t){let e=!0;for(const[,n]of Object.entries(t.ticks))if(null!=n.label&&"[object Date]"!==Object.prototype.toString.call(Cx(n.label,!0).value)){e=!1;break}for(const[,n]of Object.entries(t.ticks)){if(!n.label)continue;let i=Cx(n.label,e);i.value&&(t.formatter={format:i.format},i=i.value),n.value=i,"string"==typeof i?t.ordinal.push(i):(t.domain[0]=null===t.domain[0]?i:oy([t.domain[0],i]),t.domain[1]=null===t.domain[1]?i:ay([t.domain[1],i]))}}function Bx(t){Ex=.1*ay([t.svg._getBBox().width,t.svg._getBBox().height]),Nx(t),Ox(t.xAxis),Ox(t.yAxis);let e=+fx(t.svg.getAttribute("width")),n=+fx(t.svg.getAttribute("height"));e||(e=t.svg._getBBox().width),n||(n=t.svg._getBBox().height);const i=t.svg._getBBox();if(!t.xAxis.ticks.length&&!t.yAxis.ticks.length)return t.xAxis.range=[0,e],t.yAxis.range=[n,0],void Dx(t);const r=t.yAxis.ticks[0].marks[0]._getBBox(),s=t.xAxis.ticks[0].marks[0]._getBBox(),a=[r.left,r.left+r.width],o=[s.top+s.height,s.top],c=ay([(r.width<10?a[1]:a[0])-i.left,0]),u=ay([oy([a[1]-i.left,e]),t.xAxis.ticks[t.xAxis.ticks.length-1].marks[0]._getBBox().right-i.left]),l=ay([(s.height<10?t.yAxis.ticks[t.yAxis.ticks.length-1].marks[0]._getBBox().top:o[1])-i.top,0]),h=oy([o[0]-i.top,n]);var p,d;t.xAxis.range=[c,u],t.yAxis.range=[h,l],t.xAxis.scale=(t.xAxis.domain[0]instanceof Date?ux():t.xAxis.ordinal.length?Cg():Kb()).domain(t.xAxis.ordinal.length?t.xAxis.ordinal:t.xAxis.domain).range(t.xAxis.range),t.xAxis.axis=(p=t.xAxis.scale,d=t,Ix(_x,p,d)).ticks(t.xAxis.ticks.length),t.xAxis.domain[0]instanceof Date&&(t.xAxis.axis=t.xAxis.axis.tickFormat(t.xAxis.formatter.format)),t.yAxis.scale=(t.yAxis.domain[0]instanceof Date?ux():t.yAxis.ordinal.length?Cg():Kb()).domain(t.yAxis.ordinal.length?t.yAxis.ordinal:t.yAxis.domain).range(t.yAxis.range),t.yAxis.axis=function(t,e){return Ix(xx,t,e)}(t.yAxis.scale,t).ticks(t.yAxis.ticks.length),function(t){const e=t.svg._getBBox();if(t.xAxis.scale&&!t.xAxis.ordinal.length){const n=[dx(t.xAxis.ticks.filter((e=>e.value===t.xAxis.domain[0]))[0].marks[0],Ny),dx(t.xAxis.ticks.filter((e=>e.value===t.xAxis.domain[1]))[0].marks[0],Ny)].map((t=>t-e.left)),i=t.xAxis.range.map(t.xAxis.scale.copy().range(n).invert,t.xAxis.scale);t.xAxis.scale.domain(i)}if(t.yAxis.scale&&!t.yAxis.ordinal.length){const n=[dx(t.yAxis.ticks.filter((e=>e.value===t.yAxis.domain[0]))[0].marks[0],Oy),dx(t.yAxis.ticks.filter((e=>e.value===t.yAxis.domain[1]))[0].marks[0],Oy)].map((t=>t-e.top)),i=t.yAxis.range.map(t.yAxis.scale.copy().range(n).invert,t.yAxis.scale);t.yAxis.scale.domain(i)}}(t),Dx(t)}class Lx{constructor(t){this.table=t,this.active={table:t,selected:t,filtered:null,type:ig.NONE},this.children=[],this.parents=[]}}async function Fx(t){if(!t||!Object.keys(t).length)return{};const{url:e}=t,n=e.split(".").pop(),i=await("json"===n?function(t,e){return zm(t,{...e,as:"json",using:Hm})}(e):function(t,e){return zm(t,{...e,as:"text",using:Bf})}(e));return new Lx(i.assign($m({[Xy]:uy(i.numRows())})))}class Vx{constructor(){this.hasDomain=!1,this.svg=null,this.svgMarks=[],this.textMarks=[],this.data=null,this.xAxis={domain:[null,null],ordinal:[],range:[null,null],ticks:[],scale:null,axis:null,title:null},this.yAxis={domain:[null,null],ordinal:[],range:[null,null],ticks:[],scale:null,axis:null,title:null},this.legends=[],this.title=null,this.interactions={selection:!0,brush:!0,navigate:!1,filter:!1,sort:!1,annotate:!1}}}function Ux(t,e,n,i){this.message=t,this.expected=e,this.found=n,this.location=i,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Ux)}!function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}(Ux,Error),Ux.buildMessage=function(t,e){var n={literal:function(t){return'"'+r(t.text)+'"'},class:function(t){var e,n="";for(e=0;e0){for(e=1,i=1;eat&&(at=rt,ot=[]),ot.push(t))}function dt(){var t,e,n,r,s;for(t=rt,e=[],n=Dt();n!==i;)e.push(n),n=Dt();if(e!==i)if(n=function(){var t,e,n,r,s,a;if(t=rt,e=ft(),e!==i){for(n=[],r=rt,s=[],a=Dt();a!==i;)s.push(a),a=Dt();for(s!==i&&(a=ft())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;){for(n.push(r),r=rt,s=[],a=Dt();a!==i;)s.push(a),a=Dt();s!==i&&(a=ft())!==i?r=s=[s,a]:(rt=r,r=i)}n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),n===i&&(n=null),n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i?t=e=a(n):(rt=t,t=i)}else rt=t,t=i;else rt=t,t=i;return t}function ft(){var e,n,r,s,a,h;if(e=rt,n=function(){var e,n,r,s,a,o,h;e=rt,c.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(u));if(n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i&&(s=wt())!==i?(a=rt,(o=Tt())===i&&(o=null),o!==i&&(h=yt())!==i?a=o=[o,h]:(rt=a,a=i),a===i&&(a=null),a!==i?e=n=l(n,s,a):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}(),n!==i){for(r=[],s=rt,a=[],h=Dt();h!==i;)a.push(h),h=Dt();for(a!==i&&(h=mt())!==i?s=a=[a,h]:(rt=s,s=i);s!==i;){for(r.push(s),s=rt,a=[],h=Dt();h!==i;)a.push(h),h=Dt();a!==i&&(h=mt())!==i?s=a=[a,h]:(rt=s,s=i)}r!==i?e=n=o(n,r):(rt=e,e=i)}else rt=e,e=i;return e}function mt(){var e;return(e=function(){var e,n;e=rt,h.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(p));n!==i&&(n=d());return e=n,e}())===i&&(e=function(){var e,n,r,s;e=rt,f.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(m));if(n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i&&(s=yt())!==i?e=n=y(n,s):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,g.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(b));if(n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i&&(s=gt())!==i?e=n=v(n,s):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,_.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(x));if(n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i&&(s=gt())!==i?e=n=w(n,s):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,S.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(I));if(n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i?(s=function(){var t,e,n,r,s,a;if(t=rt,e=bt(),e!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=bt())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=bt())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),s!==i?e=n=y(n,s):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,T.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(k));if(n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i?(s=function(){var t,e,n,r,s,a;if(t=rt,e=vt(),e!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=vt())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=vt())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),s!==i?e=n=y(n,s):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,M.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(E));if(n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i?(s=function(){var t,e,n,r,s,a;if(t=rt,e=_t(),e!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=_t())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=_t())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),s!==i?e=n=y(n,s):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,D.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(O));if(n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i?(s=function(){var t,e,n,r,s,a;if(t=rt,e=wt(),e!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=wt())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=wt())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),s!==i?e=n=y(n,s):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}())===i&&(e=function(){var e,n,r,s;e=rt,B.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(L));if(n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i?(s=function(){var t,e,n,r,s,a;if(t=rt,e=xt(),e!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=xt())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=xt())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}(),s!==i?e=n=y(n,s):(rt=e,e=i)):(rt=e,e=i)}else rt=e,e=i;return e}()),e}function yt(){var t,e,n,r,s,a;if(t=rt,(e=wt())!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=wt())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=wt())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}function gt(){var t,e,n,r,s,a;if(t=rt,(e=It())!==i){for(n=[],r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=It())!==i?r=s=[s,a]:(rt=r,r=i);r!==i;)n.push(r),r=rt,(s=Tt())===i&&(s=null),s!==i&&(a=It())!==i?r=s=[s,a]:(rt=r,r=i);n!==i?t=e=o(e,n):(rt=t,t=i)}else rt=t,t=i;return t}function bt(){var t,e,n,r,s,a;return t=rt,(e=wt())!==i?((n=Tt())===i&&(n=null),n!==i&&(r=wt())!==i?((s=Tt())===i&&(s=null),s!==i&&(a=wt())!==i?t=e=A(e,r,a):(rt=t,t=i)):(rt=t,t=i)):(rt=t,t=i),t}function vt(){var t,e,n,r;return t=rt,(e=wt())!==i?((n=Tt())===i&&(n=null),n!==i&&(r=wt())!==i?t=e=C(e,r):(rt=t,t=i)):(rt=t,t=i),t}function _t(){var t,e,n,r;return t=rt,(e=wt())!==i?((n=Tt())===i&&(n=null),n!==i&&(r=wt())!==i?t=e=N(e,r):(rt=t,t=i)):(rt=t,t=i),t}function xt(){var t,e,n,r,s,a,o,c,u,l,h;return t=rt,(e=St())!==i?((n=Tt())===i&&(n=null),n!==i&&(r=St())!==i?((s=Tt())===i&&(s=null),s!==i&&(a=It())!==i&&Tt()!==i&&(o=At())!==i?((c=Tt())===i&&(c=null),c!==i&&(u=At())!==i?((l=Tt())===i&&(l=null),l!==i&&(h=wt())!==i?t=e=F(e,r,a,o,u,h):(rt=t,t=i)):(rt=t,t=i)):(rt=t,t=i)):(rt=t,t=i)):(rt=t,t=i),t}function wt(){var t,e,n,r;return t=rt,(e=It())!==i?((n=Tt())===i&&(n=null),n!==i&&(r=It())!==i?t=e=V(e,r):(rt=t,t=i)):(rt=t,t=i),t}function St(){var t;return rt,(t=Ct())===i&&(t=Nt()),t!==i&&(t=U(t)),t}function It(){var t,e,n;return rt,t=rt,(e=Et())===i&&(e=null),e!==i&&(n=Ct())!==i?t=e=[e,n]:(rt=t,t=i),t===i&&(t=rt,(e=Et())===i&&(e=null),e!==i&&(n=Nt())!==i?t=e=[e,n]:(rt=t,t=i)),t!==i&&(t=P(t)),t}function At(){var e;return rt,R.test(t.charAt(rt))?(e=t.charAt(rt),rt++):(e=i,pt(j)),e!==i&&(e=$(e)),e}function Tt(){var t,e,n,r,s;if(t=rt,e=[],(n=Dt())!==i)for(;n!==i;)e.push(n),n=Dt();else e=i;if(e!==i)if((n=kt())===i&&(n=null),n!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i?t=e=[e,n,r]:(rt=t,t=i)}else rt=t,t=i;else rt=t,t=i;if(t===i){if(t=rt,e=rt,(n=kt())!==i){for(r=[],s=Dt();s!==i;)r.push(s),s=Dt();r!==i?e=n=[n,r]:(rt=e,e=i)}else rt=e,e=i;e!==i&&(e=z()),t=e}return t}function kt(){var e;return 44===t.charCodeAt(rt)?(e=H,rt++):(e=i,pt(q)),e}function Ct(){var e,n,r;return rt,e=rt,n=function(){var e,n,r,s,a;e=rt,n=rt,r=Nt(),r===i&&(r=null);r!==i?(46===t.charCodeAt(rt)?(s=G,rt++):(s=i,pt(W)),s!==i&&(a=Nt())!==i?n=r=[r,s,a]:(rt=n,n=i)):(rt=n,n=i);n===i&&(n=rt,(r=Nt())!==i?(46===t.charCodeAt(rt)?(s=G,rt++):(s=i,pt(W)),s!==i?n=r=[r,s]:(rt=n,n=i)):(rt=n,n=i));n!==i&&(n=Y(n));return e=n,e}(),n!==i?((r=Mt())===i&&(r=null),r!==i?e=n=[n,r]:(rt=e,e=i)):(rt=e,e=i),e===i&&(e=rt,(n=Nt())!==i&&(r=Mt())!==i?e=n=[n,r]:(rt=e,e=i)),e!==i&&(e=Y(e)),e}function Mt(){var e,n,r,s;return rt,e=rt,K.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(Q)),n!==i?((r=Et())===i&&(r=null),r!==i&&(s=Nt())!==i?e=n=[n,r,s]:(rt=e,e=i)):(rt=e,e=i),e!==i&&(e=Y(e)),e}function Et(){var e;return J.test(t.charAt(rt))?(e=t.charAt(rt),rt++):(e=i,pt(Z)),e}function Nt(){var e,n;if(rt,e=[],X.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(tt)),n!==i)for(;n!==i;)e.push(n),X.test(t.charAt(rt))?(n=t.charAt(rt),rt++):(n=i,pt(tt));else e=i;return e!==i&&(e=et(e)),e}function Dt(){var e;return rt,nt.test(t.charAt(rt))?(e=t.charAt(rt),rt++):(e=i,pt(it)),e!==i&&(e=z()),e}var Ot,Bt,Lt,Ft={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var Vt in Ft)Ft[Vt.toUpperCase()]=Ft[Vt];function Ut(t,e){e||(e=[{}]);for(var n=e.length;n--;){var i={code:t,command:Ft[t]};for(var r in t==t.toLowerCase()&&(i.relative=!0),e[n])i[r]=e[n][r];e[n]=i}return e}if((n=s())!==i&&rt===t.length)return n;throw n!==i&&rt{const s=window.getComputedStyle(t);Yx(i.append("path").attr("d",r).style("fill",s.fill).style("color",s.color).style("stroke",s.stroke).style("stroke-width",s.strokeWidth).attr("id","test").node(),e,n)})),yt(t).remove()}else"Z"!==r.code?t.type=Sy:5===i.length&&s.includes(i[1].code)&&s.includes(i[2].code)&&s.includes(i[3].code)?t.type=Ty:t.type=Iy}(t,e,n),t.setAttribute("vector-effect","non-scaling-stroke")):i!==Ay&&i!==Iy&&i!==Sy||(t.type=i,t.setAttribute("vector-effect","non-scaling-stroke")),qx(e.svg,t),t.setAttribute(Jy,"true"),e.svgMarks.includes(t)||e.svgMarks.push(t)}for(const i of t.childNodes)Yx(i,e,new gx(n))}}function Gx(t,e){var n;n=t.svg,zx=yt(n).append("rect").attr("opacity",.35).attr("x",0).attr("y",0).attr("width",0).attr("height",0).attr("id",n.id+"-brush-rect").style("fill","gray").style("stroke","#fff");const[i,r]=gt(e,t.svg);zx.attr("x",i).attr("y",r)}function Wx(t,e){const n=t.map((t=>{return e=function(t){const e=new Vx;return Yx(t,e,new gx,!0),e.svg=t,console.log(e),e}(t),e.svg.style.cursor="crosshair",Bx(e),function(t){t.svgMarks=t.svgMarks.filter((t=>t.type!==Sy));for(let e=0;et.split(",").map((t=>Number(t)))));n[Hy]=[];for(const s of e){let[e,a]=s;e-=i.left,a-=i.top;const o={};o[t.xAxis.title?t.xAxis.title.innerHTML.toLowerCase():"x"]=t.xAxis.scale.invert(e),o[t.yAxis.title?t.yAxis.title.innerHTML.toLowerCase():"y"]=t.yAxis.scale.invert(a);for(let e=0;efunction(t){const{data:e}=t,i=function(t){const e=new Map,n=function t(n,i,r){if(e.has(n))return[];e.set(n,!0);const{parents:s}=n;if(!s.length)return[[n,i,r]];let a=[];for(const e of s){const{next:n,aggregation:s,map:o,fields:c}=e;a=[...a,...t(n,[...i,[s,o]],mg(r,c))]}return a}(t,[],Object.fromEntries(ag(t.table,!0).map((t=>[t,t]))));return n.map((([t,e,n])=>[t,yg(t,e),n]))}(e);let r=!1;function s(e){if(r)return;const{target:s}=e;bg(i,function(t,e){return e[qy]===Jy?py(Xy,e,ly.POINT):e[qy]===Yy?py(Object.keys(e[Hy])[0],e[Hy],ly.POINT):(_g(t.svgMarks),t.legends.forEach((t=>_g(t.marks.map((t=>t.mark))))),null)}(t,s),hx(e)),Ig(n)}function a(e){let s,a,o,c;function u(e){e.stopPropagation(),e.preventDefault();const n=gt(e);if(Math.hypot(h[0]-n[0],h[1]-n[1])<5)return;r=!0;const[i,u,l,p]=function(t,e){e.preventDefault();const[n,i]=gt(e,t.svg),r=+zx.node().getAttribute("x"),s=+zx.node().getAttribute("y"),a=n-r,o=i-s,c=a<0?a:0,u=o<0?o:0;return zx.attr("width",Math.abs(a)).attr("height",Math.abs(o)).attr("transform","translate("+c+","+u+")"),[r,s,a,o]}(t,e);s=t.xAxis.scale.invert(i),a=t.xAxis.scale.invert(i+l),o=t.yAxis.scale.invert(u),c=t.yAxis.scale.invert(u+p)}function l(e){if(zx.remove(),r){const r=(h=t.xAxis.title.innerHTML.toLowerCase(),p=t.yAxis.title.innerHTML.toLowerCase(),d=[s,a],f=[o,c],[{[h]:{value:d[0],cond:">=",type:ly.RANGE}},{[h]:{value:d[1],cond:"<=",type:ly.RANGE}},{[p]:{value:f[0],cond:"<=",type:ly.RANGE}},{[p]:{value:f[1],cond:">=",type:ly.RANGE}}]);bg(i,r,hx(e)),Ig(n)}var h,p,d,f;t.svg.removeEventListener("mousemove",u),t.svg.removeEventListener("mouseup",l)}r=!1;const h=gt(e);t.interactions.brush&&(Gx(t,e),t.svg.addEventListener("mousemove",u),t.svg.addEventListener("mouseup",l))}t.svg.addEventListener("click",s),t.svg.addEventListener("mousedown",a)}(t))),console.log(e),n}t.hydrate=async function(t,e={}){if(t)return Array.isArray(t)||(t=[t]),Wx(t=t.map((t=>"string"==typeof t?document.querySelector(t):t)),await Fx(e))}})); //# sourceMappingURL=divi.min.js.map diff --git a/dist/divi.min.js.map b/dist/divi.min.js.map index 0a3f5a7..b6f33dd 100644 --- a/dist/divi.min.js.map +++ b/dist/divi.min.js.map @@ -1 +1 @@ -{"version":3,"file":"divi.min.js","sources":["../node_modules/d3-path/src/path.js","../node_modules/d3-selection/src/namespaces.js","../node_modules/d3-selection/src/namespace.js","../node_modules/d3-selection/src/creator.js","../node_modules/d3-selection/src/selector.js","../node_modules/d3-selection/src/array.js","../node_modules/d3-selection/src/selectorAll.js","../node_modules/d3-selection/src/matcher.js","../node_modules/d3-selection/src/selection/selectChild.js","../node_modules/d3-selection/src/selection/selectChildren.js","../node_modules/d3-selection/src/selection/sparse.js","../node_modules/d3-selection/src/selection/enter.js","../node_modules/d3-selection/src/selection/data.js","../node_modules/d3-selection/src/selection/sort.js","../node_modules/d3-selection/src/selection/attr.js","../node_modules/d3-selection/src/window.js","../node_modules/d3-selection/src/selection/style.js","../node_modules/d3-selection/src/selection/property.js","../node_modules/d3-selection/src/selection/classed.js","../node_modules/d3-selection/src/selection/text.js","../node_modules/d3-selection/src/selection/html.js","../node_modules/d3-selection/src/selection/raise.js","../node_modules/d3-selection/src/selection/lower.js","../node_modules/d3-selection/src/selection/insert.js","../node_modules/d3-selection/src/selection/remove.js","../node_modules/d3-selection/src/selection/clone.js","../node_modules/d3-selection/src/selection/on.js","../node_modules/d3-selection/src/selection/dispatch.js","../node_modules/d3-selection/src/selection/index.js","../node_modules/d3-selection/src/select.js","../node_modules/d3-selection/src/pointer.js","../node_modules/d3-selection/src/sourceEvent.js","../node_modules/d3-selection/src/selectAll.js","../node_modules/d3-selection/src/selection/select.js","../node_modules/d3-selection/src/selection/selectAll.js","../node_modules/d3-selection/src/selection/filter.js","../node_modules/d3-selection/src/constant.js","../node_modules/d3-selection/src/selection/exit.js","../node_modules/d3-selection/src/selection/join.js","../node_modules/d3-selection/src/selection/merge.js","../node_modules/d3-selection/src/selection/order.js","../node_modules/d3-selection/src/selection/call.js","../node_modules/d3-selection/src/selection/nodes.js","../node_modules/d3-selection/src/selection/node.js","../node_modules/d3-selection/src/selection/size.js","../node_modules/d3-selection/src/selection/empty.js","../node_modules/d3-selection/src/selection/each.js","../node_modules/d3-selection/src/selection/append.js","../node_modules/d3-selection/src/selection/datum.js","../node_modules/d3-selection/src/selection/iterator.js","../node_modules/arquero/src/util/is-array.js","../node_modules/arquero/src/util/to-array.js","../node_modules/arquero/src/helpers/slice.js","../node_modules/arquero/src/table/transformable.js","../node_modules/arquero/src/util/error.js","../node_modules/arquero/src/util/is-number.js","../node_modules/arquero/src/util/is-function.js","../node_modules/arquero/src/util/repeat.js","../node_modules/arquero/src/table/table.js","../node_modules/arquero/src/table/column.js","../node_modules/arquero/src/util/is-date.js","../node_modules/arquero/src/util/is-object.js","../node_modules/arquero/src/util/is-regexp.js","../node_modules/arquero/src/util/is-string.js","../node_modules/arquero/src/table/columns-from.js","../node_modules/arquero/src/util/has.js","../node_modules/arquero/src/table/column-set.js","../node_modules/arquero/src/util/null.js","../node_modules/arquero/src/util/is-typed-array.js","../node_modules/arquero/src/util/is-array-type.js","../node_modules/arquero/src/util/is-valid.js","../node_modules/arquero/src/op/functions/array.js","../node_modules/arquero/src/util/pad.js","../node_modules/arquero/src/util/format-date.js","../node_modules/arquero/src/util/is-iso-date-string.js","../node_modules/arquero/src/op/functions/date.js","../node_modules/arquero/src/util/parse-iso-date.js","../node_modules/arquero/src/op/functions/equal.js","../node_modules/arquero/src/op/functions/json.js","../node_modules/arquero/src/util/random.js","../node_modules/arquero/src/util/is-map.js","../node_modules/arquero/src/util/is-map-or-set.js","../node_modules/arquero/src/util/is-set.js","../node_modules/arquero/src/op/functions/object.js","../node_modules/arquero/src/op/functions/string.js","../node_modules/arquero/src/op/functions/index.js","../node_modules/arquero/src/op/functions/bin.js","../node_modules/arquero/src/op/functions/recode.js","../node_modules/arquero/src/op/functions/sequence.js","../node_modules/arquero/src/op/functions/math.js","../node_modules/arquero/src/util/is-bigint.js","../node_modules/arquero/src/util/to-string.js","../node_modules/arquero/src/op/op.js","../node_modules/arquero/src/op/op-api.js","../node_modules/arquero/src/table/regroup.js","../node_modules/arquero/src/util/unique-name.js","../node_modules/arquero/src/expression/ast/constants.js","../node_modules/arquero/src/expression/codegen.js","../node_modules/arquero/src/util/key-function.js","../node_modules/arquero/src/util/no-op.js","../node_modules/arquero/src/op/aggregate-functions.js","../node_modules/arquero/src/util/distinct-map.js","../node_modules/arquero/src/util/product.js","../node_modules/arquero/src/util/bins.js","../node_modules/arquero/src/op/window-functions.js","../node_modules/arquero/src/op/index.js","../node_modules/arquero/src/expression/compile.js","../node_modules/arquero/src/expression/rewrite.js","../node_modules/arquero/src/util/entries.js","../node_modules/arquero/src/expression/row-object.js","../node_modules/tslib/tslib.es6.js","../node_modules/apache-arrow/util/utf8.mjs","../node_modules/apache-arrow/util/compat.mjs","../node_modules/apache-arrow/util/buffer.mjs","../node_modules/apache-arrow/io/adapters.mjs","../node_modules/apache-arrow/enum.mjs","../node_modules/apache-arrow/util/pretty.mjs","../node_modules/apache-arrow/util/bn.mjs","../node_modules/apache-arrow/type.mjs","../node_modules/apache-arrow/visitor.mjs","../node_modules/apache-arrow/util/math.mjs","../node_modules/apache-arrow/visitor/set.mjs","../node_modules/apache-arrow/row/struct.mjs","../node_modules/apache-arrow/visitor/get.mjs","../node_modules/apache-arrow/row/map.mjs","../node_modules/apache-arrow/util/vector.mjs","../node_modules/apache-arrow/util/bit.mjs","../node_modules/apache-arrow/data.mjs","../node_modules/apache-arrow/util/chunk.mjs","../node_modules/apache-arrow/visitor/indexof.mjs","../node_modules/apache-arrow/visitor/iterator.mjs","../node_modules/apache-arrow/visitor/bytelength.mjs","../node_modules/apache-arrow/vector.mjs","../node_modules/apache-arrow/builder/valid.mjs","../node_modules/apache-arrow/builder/buffer.mjs","../node_modules/apache-arrow/builder.mjs","../node_modules/apache-arrow/fb/block.mjs","../node_modules/flatbuffers/mjs/constants.js","../node_modules/flatbuffers/mjs/utils.js","../node_modules/flatbuffers/mjs/long.js","../node_modules/flatbuffers/mjs/encoding.js","../node_modules/flatbuffers/mjs/byte-buffer.js","../node_modules/flatbuffers/mjs/builder.js","../node_modules/apache-arrow/fb/key-value.mjs","../node_modules/apache-arrow/fb/metadata-version.mjs","../node_modules/apache-arrow/fb/endianness.mjs","../node_modules/apache-arrow/fb/dictionary-kind.mjs","../node_modules/apache-arrow/fb/date-unit.mjs","../node_modules/apache-arrow/fb/int.mjs","../node_modules/apache-arrow/fb/dictionary-encoding.mjs","../node_modules/apache-arrow/fb/binary.mjs","../node_modules/apache-arrow/fb/bool.mjs","../node_modules/apache-arrow/fb/date.mjs","../node_modules/apache-arrow/fb/decimal.mjs","../node_modules/apache-arrow/fb/time-unit.mjs","../node_modules/apache-arrow/fb/precision.mjs","../node_modules/apache-arrow/fb/interval-unit.mjs","../node_modules/apache-arrow/fb/fixed-size-binary.mjs","../node_modules/apache-arrow/fb/fixed-size-list.mjs","../node_modules/apache-arrow/fb/floating-point.mjs","../node_modules/apache-arrow/fb/interval.mjs","../node_modules/apache-arrow/fb/list.mjs","../node_modules/apache-arrow/fb/map.mjs","../node_modules/apache-arrow/fb/null.mjs","../node_modules/apache-arrow/fb/struct_.mjs","../node_modules/apache-arrow/fb/time.mjs","../node_modules/apache-arrow/fb/timestamp.mjs","../node_modules/apache-arrow/fb/union-mode.mjs","../node_modules/apache-arrow/fb/type.mjs","../node_modules/apache-arrow/fb/union.mjs","../node_modules/apache-arrow/fb/utf8.mjs","../node_modules/apache-arrow/fb/field.mjs","../node_modules/apache-arrow/fb/schema.mjs","../node_modules/apache-arrow/fb/footer.mjs","../node_modules/apache-arrow/schema.mjs","../node_modules/apache-arrow/ipc/metadata/file.mjs","../node_modules/apache-arrow/io/interfaces.mjs","../node_modules/apache-arrow/io/stream.mjs","../node_modules/apache-arrow/builder/binary.mjs","../node_modules/apache-arrow/builder/bool.mjs","../node_modules/apache-arrow/builder/date.mjs","../node_modules/apache-arrow/builder/decimal.mjs","../node_modules/apache-arrow/builder/dictionary.mjs","../node_modules/apache-arrow/builder/fixedsizebinary.mjs","../node_modules/apache-arrow/builder/fixedsizelist.mjs","../node_modules/apache-arrow/builder/float.mjs","../node_modules/apache-arrow/builder/interval.mjs","../node_modules/apache-arrow/builder/int.mjs","../node_modules/apache-arrow/builder/list.mjs","../node_modules/apache-arrow/builder/map.mjs","../node_modules/apache-arrow/builder/null.mjs","../node_modules/apache-arrow/builder/struct.mjs","../node_modules/apache-arrow/builder/timestamp.mjs","../node_modules/apache-arrow/builder/time.mjs","../node_modules/apache-arrow/builder/union.mjs","../node_modules/apache-arrow/builder/utf8.mjs","../node_modules/apache-arrow/visitor/builderctor.mjs","../node_modules/apache-arrow/visitor/typecomparator.mjs","../node_modules/apache-arrow/factories.mjs","../node_modules/apache-arrow/util/recordbatch.mjs","../node_modules/apache-arrow/table.mjs","../node_modules/apache-arrow/recordbatch.mjs","../node_modules/apache-arrow/fb/body-compression-method.mjs","../node_modules/apache-arrow/fb/compression-type.mjs","../node_modules/apache-arrow/fb/body-compression.mjs","../node_modules/apache-arrow/fb/buffer.mjs","../node_modules/apache-arrow/fb/field-node.mjs","../node_modules/apache-arrow/fb/record-batch.mjs","../node_modules/apache-arrow/fb/dictionary-batch.mjs","../node_modules/apache-arrow/fb/message-header.mjs","../node_modules/apache-arrow/fb/message.mjs","../node_modules/apache-arrow/visitor/typeassembler.mjs","../node_modules/apache-arrow/ipc/metadata/json.mjs","../node_modules/apache-arrow/ipc/metadata/message.mjs","../node_modules/apache-arrow/ipc/message.mjs","../node_modules/apache-arrow/visitor/vectorassembler.mjs","../node_modules/apache-arrow/ipc/writer.mjs","../node_modules/arquero/src/arrow/builder/util.js","../node_modules/arquero/src/arrow/builder/array-builder.js","../node_modules/arquero/src/arrow/builder/bool-builder.js","../node_modules/arquero/src/arrow/builder/date-day-builder.js","../node_modules/arquero/src/arrow/builder/date-millis-builder.js","../node_modules/arquero/src/arrow/builder/dictionary-builder.js","../node_modules/arquero/src/arrow/builder/utf8-builder.js","../node_modules/arquero/src/arrow/builder/index.js","../node_modules/arquero/src/arrow/builder/default-builder.js","../node_modules/arquero/src/arrow/builder/valid-builder.js","../node_modules/arquero/src/arrow/encode/data-from.js","../node_modules/arquero/src/arrow/builder/resolve-type.js","../node_modules/arquero/src/arrow/encode/profiler.js","../node_modules/arquero/src/util/is-exact-utc-date.js","../node_modules/arquero/src/arrow/encode/data-from-objects.js","../node_modules/arquero/src/arrow/encode/data-from-table.js","../node_modules/arquero/src/arrow/encode/scan.js","../node_modules/arquero/src/arrow/arrow-table.js","../node_modules/arquero/src/arrow/encode/index.js","../node_modules/arquero/src/format/to-arrow.js","../node_modules/apache-arrow/ipc/serialization.mjs","../node_modules/arquero/src/format/util.js","../node_modules/arquero/src/format/infer.js","../node_modules/arquero/src/format/value.js","../node_modules/arquero/src/util/map-object.js","../node_modules/arquero/src/format/to-html.js","../node_modules/arquero/src/util/default-true.js","../node_modules/arquero/src/format/to-json.js","../node_modules/arquero/src/util/assign.js","../node_modules/arquero/src/helpers/selection.js","../node_modules/arquero/src/table/column-table.js","../node_modules/arquero/src/util/array-type.js","../node_modules/arquero/src/format/to-csv.js","../node_modules/arquero/src/format/to-markdown.js","../node_modules/arquero/src/engine/reduce/reducer.js","../node_modules/arquero/src/expression/ast/walk.js","../node_modules/arquero/src/expression/ast/clean.js","../node_modules/arquero/src/expression/ast/util.js","../node_modules/arquero/src/expression/parse-escape.js","../node_modules/arquero/src/util/to-function.js","../node_modules/acorn/dist/acorn.mjs","../node_modules/arquero/src/expression/constants.js","../node_modules/arquero/src/expression/parse-expression.js","../node_modules/arquero/src/expression/parse.js","../node_modules/arquero/src/query/constants.js","../node_modules/arquero/src/helpers/wrap.js","../node_modules/arquero/src/helpers/field.js","../node_modules/arquero/src/query/util.js","../node_modules/arquero/src/util/escape-regexp.js","../node_modules/arquero/src/helpers/rolling.js","../node_modules/arquero/src/helpers/desc.js","../node_modules/arquero/src/query/to-ast.js","../node_modules/arquero/src/query/verb.js","../node_modules/arquero/src/query/query.js","../node_modules/arquero/src/util/unroll.js","../node_modules/arquero/src/util/identity.js","../node_modules/arquero/src/util/parse-values.js","../node_modules/arquero/src/format/from-text-rows.js","../node_modules/arquero/src/format/parse/constants.js","../node_modules/arquero/src/format/from-csv.js","../node_modules/arquero/src/format/parse/parse-delimited.js","../node_modules/arquero/src/format/parse/text-filter.js","../node_modules/arquero/src/util/is-digit-string.js","../node_modules/arquero/src/engine/select.js","../node_modules/arquero/src/verbs/relocate.js","../node_modules/arquero/src/util/concat.js","../node_modules/arquero/src/util/ascending.js","../node_modules/arquero/src/util/to-numeric.js","../node_modules/arquero/src/util/value-list.js","../node_modules/arquero/src/util/min.js","../node_modules/arquero/src/util/max.js","../node_modules/arquero/src/util/quantile.js","../node_modules/arquero/src/engine/reduce/field-reducer.js","../node_modules/arquero/src/engine/reduce/util.js","../node_modules/arquero/src/util/bisector.js","../node_modules/arquero/src/engine/window/window-state.js","../node_modules/arquero/src/engine/window/window.js","../node_modules/arquero/src/engine/derive.js","../node_modules/arquero/src/table/bit-set.js","../node_modules/arquero/src/engine/unroll.js","../node_modules/arquero/src/verbs/util/parse.js","../node_modules/arquero/src/engine/impute.js","../node_modules/arquero/src/engine/rollup.js","../node_modules/arquero/src/verbs/impute.js","../node_modules/arquero/src/engine/join/lookup.js","../node_modules/arquero/src/engine/join.js","../node_modules/arquero/src/verbs/util/parse-key.js","../node_modules/arquero/src/verbs/util/join-keys.js","../node_modules/arquero/src/util/intersect.js","../node_modules/arquero/src/verbs/join.js","../node_modules/arquero/src/engine/join-filter.js","../node_modules/arquero/src/verbs/join-filter.js","../node_modules/arquero/src/engine/pivot.js","../node_modules/arquero/src/verbs/pivot.js","../node_modules/arquero/src/verbs/rollup.js","../node_modules/arquero/src/util/sample.js","../node_modules/arquero/src/engine/sample.js","../node_modules/arquero/src/util/shuffle.js","../node_modules/arquero/src/verbs/sample.js","../node_modules/arquero/src/engine/spread.js","../node_modules/arquero/src/engine/groupby.js","../node_modules/arquero/src/expression/compare.js","../node_modules/arquero/src/verbs/index.js","../node_modules/arquero/src/engine/concat.js","../node_modules/arquero/src/verbs/dedupe.js","../node_modules/arquero/src/verbs/derive.js","../node_modules/arquero/src/verbs/except.js","../node_modules/arquero/src/verbs/filter.js","../node_modules/arquero/src/engine/filter.js","../node_modules/arquero/src/verbs/fold.js","../node_modules/arquero/src/engine/fold.js","../node_modules/arquero/src/verbs/intersect.js","../node_modules/arquero/src/verbs/lookup.js","../node_modules/arquero/src/engine/lookup.js","../node_modules/arquero/src/verbs/rename.js","../node_modules/arquero/src/verbs/select.js","../node_modules/arquero/src/verbs/spread.js","../node_modules/arquero/src/verbs/union.js","../node_modules/arquero/src/verbs/unroll.js","../node_modules/arquero/src/verbs/groupby.js","../node_modules/arquero/src/verbs/orderby.js","../node_modules/arquero/src/engine/orderby.js","../node_modules/arquero/src/engine/ungroup.js","../node_modules/arquero/src/engine/unorder.js","../node_modules/arquero/src/engine/reduce.js","../node_modules/arquero/src/table/index.js","../node_modules/arquero/src/format/load-url.js","../node_modules/arquero/src/format/from-json.js","../node_modules/arquero/src/helpers/escape.js","../node_modules/d3-array/src/ascending.js","../node_modules/d3-array/src/descending.js","../node_modules/d3-array/src/bisector.js","../node_modules/arquero/src/register.js","../node_modules/d3-array/src/bisect.js","../node_modules/d3-array/src/number.js","../node_modules/internmap/src/index.js","../node_modules/d3-array/src/ticks.js","../node_modules/d3-array/src/max.js","../node_modules/d3-array/src/min.js","../node_modules/d3-array/src/mean.js","../node_modules/d3-array/src/range.js","../node_modules/d3-scale/src/init.js","../node_modules/d3-scale/src/ordinal.js","../node_modules/d3-scale/src/band.js","../node_modules/d3-color/src/define.js","../node_modules/d3-color/src/color.js","../node_modules/d3-interpolate/src/constant.js","../node_modules/d3-interpolate/src/color.js","../node_modules/d3-interpolate/src/rgb.js","../node_modules/d3-interpolate/src/numberArray.js","../node_modules/d3-interpolate/src/array.js","../node_modules/d3-interpolate/src/date.js","../node_modules/d3-interpolate/src/number.js","../node_modules/d3-interpolate/src/object.js","../node_modules/d3-interpolate/src/string.js","../node_modules/d3-interpolate/src/value.js","../node_modules/d3-interpolate/src/round.js","../node_modules/d3-scale/src/number.js","../node_modules/d3-scale/src/continuous.js","../node_modules/d3-scale/src/constant.js","../node_modules/d3-format/src/formatDecimal.js","../node_modules/d3-format/src/exponent.js","../node_modules/d3-format/src/formatSpecifier.js","../node_modules/d3-format/src/formatPrefixAuto.js","../node_modules/d3-format/src/formatRounded.js","../node_modules/d3-format/src/formatTypes.js","../node_modules/d3-format/src/identity.js","../node_modules/d3-format/src/locale.js","../node_modules/d3-format/src/defaultLocale.js","../node_modules/d3-format/src/formatGroup.js","../node_modules/d3-format/src/formatNumerals.js","../node_modules/d3-format/src/formatTrim.js","../node_modules/d3-scale/src/tickFormat.js","../node_modules/d3-format/src/precisionPrefix.js","../node_modules/d3-format/src/precisionRound.js","../node_modules/d3-format/src/precisionFixed.js","../node_modules/d3-scale/src/linear.js","../node_modules/d3-time/src/interval.js","../node_modules/d3-time/src/millisecond.js","../node_modules/d3-time/src/duration.js","../node_modules/d3-time/src/second.js","../node_modules/d3-time/src/minute.js","../node_modules/d3-time/src/hour.js","../node_modules/d3-time/src/day.js","../node_modules/d3-time/src/week.js","../node_modules/d3-time/src/month.js","../node_modules/d3-time/src/year.js","../node_modules/d3-time/src/ticks.js","../node_modules/d3-time-format/src/locale.js","../node_modules/d3-time-format/src/defaultLocale.js","../node_modules/d3-scale/src/time.js","../node_modules/d3-scale/src/nice.js","../node_modules/svg-path-parser/parser.js","../node_modules/svg-path-parser/index.js","../node_modules/uwdata-divi/src/handlers/query.js","../node_modules/uwdata-divi/src/state/constants.js","../node_modules/uwdata-divi/src/orchestration/link.js","../node_modules/uwdata-divi/src/handlers/select.js","../node_modules/uwdata-divi/src/_d3/identity.js","../node_modules/uwdata-divi/src/util/util.js","../node_modules/uwdata-divi/src/util/transform.js","../node_modules/uwdata-divi/src/_d3/axis.js","../node_modules/uwdata-divi/src/parsers/legend-parsers.js","../node_modules/uwdata-divi/src/parsers/attribute-parsers.js","../node_modules/uwdata-divi/src/parsers/view-parsers.js","../node_modules/uwdata-divi/src/state/data-state.js","../node_modules/uwdata-divi/src/parsers/dataset-parser.js","../node_modules/d3-array/src/map.js","../node_modules/uwdata-divi/src/state/view-state.js","../node_modules/uwdata-divi/src/orchestration/inspect.js","../node_modules/uwdata-divi/src/handlers/brush.js","../node_modules/uwdata-divi/src/orchestration/orchestrate.js","../src/hydrate.js","../node_modules/uwdata-divi/src/hydrate.js"],"sourcesContent":["const pi = Math.PI,\n tau = 2 * pi,\n epsilon = 1e-6,\n tauEpsilon = tau - epsilon;\n\nfunction append(strings) {\n this._ += strings[0];\n for (let i = 1, n = strings.length; i < n; ++i) {\n this._ += arguments[i] + strings[i];\n }\n}\n\nfunction appendRound(digits) {\n let d = Math.floor(digits);\n if (!(d >= 0)) throw new Error(`invalid digits: ${digits}`);\n if (d > 15) return append;\n const k = 10 ** d;\n return function(strings) {\n this._ += strings[0];\n for (let i = 1, n = strings.length; i < n; ++i) {\n this._ += Math.round(arguments[i] * k) / k + strings[i];\n }\n };\n}\n\nexport class Path {\n constructor(digits) {\n this._x0 = this._y0 = // start of current subpath\n this._x1 = this._y1 = null; // end of current subpath\n this._ = \"\";\n this._append = digits == null ? append : appendRound(digits);\n }\n moveTo(x, y) {\n this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}`;\n }\n closePath() {\n if (this._x1 !== null) {\n this._x1 = this._x0, this._y1 = this._y0;\n this._append`Z`;\n }\n }\n lineTo(x, y) {\n this._append`L${this._x1 = +x},${this._y1 = +y}`;\n }\n quadraticCurveTo(x1, y1, x, y) {\n this._append`Q${+x1},${+y1},${this._x1 = +x},${this._y1 = +y}`;\n }\n bezierCurveTo(x1, y1, x2, y2, x, y) {\n this._append`C${+x1},${+y1},${+x2},${+y2},${this._x1 = +x},${this._y1 = +y}`;\n }\n arcTo(x1, y1, x2, y2, r) {\n x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;\n\n // Is the radius negative? Error.\n if (r < 0) throw new Error(`negative radius: ${r}`);\n\n let x0 = this._x1,\n y0 = this._y1,\n x21 = x2 - x1,\n y21 = y2 - y1,\n x01 = x0 - x1,\n y01 = y0 - y1,\n l01_2 = x01 * x01 + y01 * y01;\n\n // Is this path empty? Move to (x1,y1).\n if (this._x1 === null) {\n this._append`M${this._x1 = x1},${this._y1 = y1}`;\n }\n\n // Or, is (x1,y1) coincident with (x0,y0)? Do nothing.\n else if (!(l01_2 > epsilon));\n\n // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear?\n // Equivalently, is (x1,y1) coincident with (x2,y2)?\n // Or, is the radius zero? Line to (x1,y1).\n else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {\n this._append`L${this._x1 = x1},${this._y1 = y1}`;\n }\n\n // Otherwise, draw an arc!\n else {\n let x20 = x2 - x0,\n y20 = y2 - y0,\n l21_2 = x21 * x21 + y21 * y21,\n l20_2 = x20 * x20 + y20 * y20,\n l21 = Math.sqrt(l21_2),\n l01 = Math.sqrt(l01_2),\n l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2),\n t01 = l / l01,\n t21 = l / l21;\n\n // If the start tangent is not coincident with (x0,y0), line to.\n if (Math.abs(t01 - 1) > epsilon) {\n this._append`L${x1 + t01 * x01},${y1 + t01 * y01}`;\n }\n\n this._append`A${r},${r},0,0,${+(y01 * x20 > x01 * y20)},${this._x1 = x1 + t21 * x21},${this._y1 = y1 + t21 * y21}`;\n }\n }\n arc(x, y, r, a0, a1, ccw) {\n x = +x, y = +y, r = +r, ccw = !!ccw;\n\n // Is the radius negative? Error.\n if (r < 0) throw new Error(`negative radius: ${r}`);\n\n let dx = r * Math.cos(a0),\n dy = r * Math.sin(a0),\n x0 = x + dx,\n y0 = y + dy,\n cw = 1 ^ ccw,\n da = ccw ? a0 - a1 : a1 - a0;\n\n // Is this path empty? Move to (x0,y0).\n if (this._x1 === null) {\n this._append`M${x0},${y0}`;\n }\n\n // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0).\n else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) {\n this._append`L${x0},${y0}`;\n }\n\n // Is this arc empty? We’re done.\n if (!r) return;\n\n // Does the angle go the wrong way? Flip the direction.\n if (da < 0) da = da % tau + tau;\n\n // Is this a complete circle? Draw two arcs to complete the circle.\n if (da > tauEpsilon) {\n this._append`A${r},${r},0,1,${cw},${x - dx},${y - dy}A${r},${r},0,1,${cw},${this._x1 = x0},${this._y1 = y0}`;\n }\n\n // Is this arc non-empty? Draw an arc!\n else if (da > epsilon) {\n this._append`A${r},${r},0,${+(da >= pi)},${cw},${this._x1 = x + r * Math.cos(a1)},${this._y1 = y + r * Math.sin(a1)}`;\n }\n }\n rect(x, y, w, h) {\n this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}h${w = +w}v${+h}h${-w}Z`;\n }\n toString() {\n return this._;\n }\n}\n\nexport function path() {\n return new Path;\n}\n\n// Allow instanceof d3.path\npath.prototype = Path.prototype;\n\nexport function pathRound(digits = 3) {\n return new Path(+digits);\n}\n","export var xhtml = \"http://www.w3.org/1999/xhtml\";\n\nexport default {\n svg: \"http://www.w3.org/2000/svg\",\n xhtml: xhtml,\n xlink: \"http://www.w3.org/1999/xlink\",\n xml: \"http://www.w3.org/XML/1998/namespace\",\n xmlns: \"http://www.w3.org/2000/xmlns/\"\n};\n","import namespaces from \"./namespaces.js\";\n\nexport default function(name) {\n var prefix = name += \"\", i = prefix.indexOf(\":\");\n if (i >= 0 && (prefix = name.slice(0, i)) !== \"xmlns\") name = name.slice(i + 1);\n return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name; // eslint-disable-line no-prototype-builtins\n}\n","import namespace from \"./namespace.js\";\nimport {xhtml} from \"./namespaces.js\";\n\nfunction creatorInherit(name) {\n return function() {\n var document = this.ownerDocument,\n uri = this.namespaceURI;\n return uri === xhtml && document.documentElement.namespaceURI === xhtml\n ? document.createElement(name)\n : document.createElementNS(uri, name);\n };\n}\n\nfunction creatorFixed(fullname) {\n return function() {\n return this.ownerDocument.createElementNS(fullname.space, fullname.local);\n };\n}\n\nexport default function(name) {\n var fullname = namespace(name);\n return (fullname.local\n ? creatorFixed\n : creatorInherit)(fullname);\n}\n","function none() {}\n\nexport default function(selector) {\n return selector == null ? none : function() {\n return this.querySelector(selector);\n };\n}\n","// Given something array like (or null), returns something that is strictly an\n// array. This is used to ensure that array-like objects passed to d3.selectAll\n// or selection.selectAll are converted into proper arrays when creating a\n// selection; we don’t ever want to create a selection backed by a live\n// HTMLCollection or NodeList. However, note that selection.selectAll will use a\n// static NodeList as a group, since it safely derived from querySelectorAll.\nexport default function array(x) {\n return x == null ? [] : Array.isArray(x) ? x : Array.from(x);\n}\n","function empty() {\n return [];\n}\n\nexport default function(selector) {\n return selector == null ? empty : function() {\n return this.querySelectorAll(selector);\n };\n}\n","export default function(selector) {\n return function() {\n return this.matches(selector);\n };\n}\n\nexport function childMatcher(selector) {\n return function(node) {\n return node.matches(selector);\n };\n}\n\n","import {childMatcher} from \"../matcher.js\";\n\nvar find = Array.prototype.find;\n\nfunction childFind(match) {\n return function() {\n return find.call(this.children, match);\n };\n}\n\nfunction childFirst() {\n return this.firstElementChild;\n}\n\nexport default function(match) {\n return this.select(match == null ? childFirst\n : childFind(typeof match === \"function\" ? match : childMatcher(match)));\n}\n","import {childMatcher} from \"../matcher.js\";\n\nvar filter = Array.prototype.filter;\n\nfunction children() {\n return Array.from(this.children);\n}\n\nfunction childrenFilter(match) {\n return function() {\n return filter.call(this.children, match);\n };\n}\n\nexport default function(match) {\n return this.selectAll(match == null ? children\n : childrenFilter(typeof match === \"function\" ? match : childMatcher(match)));\n}\n","export default function(update) {\n return new Array(update.length);\n}\n","import sparse from \"./sparse.js\";\nimport {Selection} from \"./index.js\";\n\nexport default function() {\n return new Selection(this._enter || this._groups.map(sparse), this._parents);\n}\n\nexport function EnterNode(parent, datum) {\n this.ownerDocument = parent.ownerDocument;\n this.namespaceURI = parent.namespaceURI;\n this._next = null;\n this._parent = parent;\n this.__data__ = datum;\n}\n\nEnterNode.prototype = {\n constructor: EnterNode,\n appendChild: function(child) { return this._parent.insertBefore(child, this._next); },\n insertBefore: function(child, next) { return this._parent.insertBefore(child, next); },\n querySelector: function(selector) { return this._parent.querySelector(selector); },\n querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); }\n};\n","import {Selection} from \"./index.js\";\nimport {EnterNode} from \"./enter.js\";\nimport constant from \"../constant.js\";\n\nfunction bindIndex(parent, group, enter, update, exit, data) {\n var i = 0,\n node,\n groupLength = group.length,\n dataLength = data.length;\n\n // Put any non-null nodes that fit into update.\n // Put any null nodes into enter.\n // Put any remaining data into enter.\n for (; i < dataLength; ++i) {\n if (node = group[i]) {\n node.__data__ = data[i];\n update[i] = node;\n } else {\n enter[i] = new EnterNode(parent, data[i]);\n }\n }\n\n // Put any non-null nodes that don’t fit into exit.\n for (; i < groupLength; ++i) {\n if (node = group[i]) {\n exit[i] = node;\n }\n }\n}\n\nfunction bindKey(parent, group, enter, update, exit, data, key) {\n var i,\n node,\n nodeByKeyValue = new Map,\n groupLength = group.length,\n dataLength = data.length,\n keyValues = new Array(groupLength),\n keyValue;\n\n // Compute the key for each node.\n // If multiple nodes have the same key, the duplicates are added to exit.\n for (i = 0; i < groupLength; ++i) {\n if (node = group[i]) {\n keyValues[i] = keyValue = key.call(node, node.__data__, i, group) + \"\";\n if (nodeByKeyValue.has(keyValue)) {\n exit[i] = node;\n } else {\n nodeByKeyValue.set(keyValue, node);\n }\n }\n }\n\n // Compute the key for each datum.\n // If there a node associated with this key, join and add it to update.\n // If there is not (or the key is a duplicate), add it to enter.\n for (i = 0; i < dataLength; ++i) {\n keyValue = key.call(parent, data[i], i, data) + \"\";\n if (node = nodeByKeyValue.get(keyValue)) {\n update[i] = node;\n node.__data__ = data[i];\n nodeByKeyValue.delete(keyValue);\n } else {\n enter[i] = new EnterNode(parent, data[i]);\n }\n }\n\n // Add any remaining nodes that were not bound to data to exit.\n for (i = 0; i < groupLength; ++i) {\n if ((node = group[i]) && (nodeByKeyValue.get(keyValues[i]) === node)) {\n exit[i] = node;\n }\n }\n}\n\nfunction datum(node) {\n return node.__data__;\n}\n\nexport default function(value, key) {\n if (!arguments.length) return Array.from(this, datum);\n\n var bind = key ? bindKey : bindIndex,\n parents = this._parents,\n groups = this._groups;\n\n if (typeof value !== \"function\") value = constant(value);\n\n for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) {\n var parent = parents[j],\n group = groups[j],\n groupLength = group.length,\n data = arraylike(value.call(parent, parent && parent.__data__, j, parents)),\n dataLength = data.length,\n enterGroup = enter[j] = new Array(dataLength),\n updateGroup = update[j] = new Array(dataLength),\n exitGroup = exit[j] = new Array(groupLength);\n\n bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);\n\n // Now connect the enter nodes to their following update node, such that\n // appendChild can insert the materialized enter node before this node,\n // rather than at the end of the parent node.\n for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {\n if (previous = enterGroup[i0]) {\n if (i0 >= i1) i1 = i0 + 1;\n while (!(next = updateGroup[i1]) && ++i1 < dataLength);\n previous._next = next || null;\n }\n }\n }\n\n update = new Selection(update, parents);\n update._enter = enter;\n update._exit = exit;\n return update;\n}\n\n// Given some data, this returns an array-like view of it: an object that\n// exposes a length property and allows numeric indexing. Note that unlike\n// selectAll, this isn’t worried about “live” collections because the resulting\n// array will only be used briefly while data is being bound. (It is possible to\n// cause the data to change while iterating by using a key function, but please\n// don’t; we’d rather avoid a gratuitous copy.)\nfunction arraylike(data) {\n return typeof data === \"object\" && \"length\" in data\n ? data // Array, TypedArray, NodeList, array-like\n : Array.from(data); // Map, Set, iterable, string, or anything else\n}\n","import {Selection} from \"./index.js\";\n\nexport default function(compare) {\n if (!compare) compare = ascending;\n\n function compareNode(a, b) {\n return a && b ? compare(a.__data__, b.__data__) : !a - !b;\n }\n\n for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) {\n for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) {\n if (node = group[i]) {\n sortgroup[i] = node;\n }\n }\n sortgroup.sort(compareNode);\n }\n\n return new Selection(sortgroups, this._parents).order();\n}\n\nfunction ascending(a, b) {\n return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;\n}\n","import namespace from \"../namespace.js\";\n\nfunction attrRemove(name) {\n return function() {\n this.removeAttribute(name);\n };\n}\n\nfunction attrRemoveNS(fullname) {\n return function() {\n this.removeAttributeNS(fullname.space, fullname.local);\n };\n}\n\nfunction attrConstant(name, value) {\n return function() {\n this.setAttribute(name, value);\n };\n}\n\nfunction attrConstantNS(fullname, value) {\n return function() {\n this.setAttributeNS(fullname.space, fullname.local, value);\n };\n}\n\nfunction attrFunction(name, value) {\n return function() {\n var v = value.apply(this, arguments);\n if (v == null) this.removeAttribute(name);\n else this.setAttribute(name, v);\n };\n}\n\nfunction attrFunctionNS(fullname, value) {\n return function() {\n var v = value.apply(this, arguments);\n if (v == null) this.removeAttributeNS(fullname.space, fullname.local);\n else this.setAttributeNS(fullname.space, fullname.local, v);\n };\n}\n\nexport default function(name, value) {\n var fullname = namespace(name);\n\n if (arguments.length < 2) {\n var node = this.node();\n return fullname.local\n ? node.getAttributeNS(fullname.space, fullname.local)\n : node.getAttribute(fullname);\n }\n\n return this.each((value == null\n ? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === \"function\"\n ? (fullname.local ? attrFunctionNS : attrFunction)\n : (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));\n}\n","export default function(node) {\n return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node\n || (node.document && node) // node is a Window\n || node.defaultView; // node is a Document\n}\n","import defaultView from \"../window.js\";\n\nfunction styleRemove(name) {\n return function() {\n this.style.removeProperty(name);\n };\n}\n\nfunction styleConstant(name, value, priority) {\n return function() {\n this.style.setProperty(name, value, priority);\n };\n}\n\nfunction styleFunction(name, value, priority) {\n return function() {\n var v = value.apply(this, arguments);\n if (v == null) this.style.removeProperty(name);\n else this.style.setProperty(name, v, priority);\n };\n}\n\nexport default function(name, value, priority) {\n return arguments.length > 1\n ? this.each((value == null\n ? styleRemove : typeof value === \"function\"\n ? styleFunction\n : styleConstant)(name, value, priority == null ? \"\" : priority))\n : styleValue(this.node(), name);\n}\n\nexport function styleValue(node, name) {\n return node.style.getPropertyValue(name)\n || defaultView(node).getComputedStyle(node, null).getPropertyValue(name);\n}\n","function propertyRemove(name) {\n return function() {\n delete this[name];\n };\n}\n\nfunction propertyConstant(name, value) {\n return function() {\n this[name] = value;\n };\n}\n\nfunction propertyFunction(name, value) {\n return function() {\n var v = value.apply(this, arguments);\n if (v == null) delete this[name];\n else this[name] = v;\n };\n}\n\nexport default function(name, value) {\n return arguments.length > 1\n ? this.each((value == null\n ? propertyRemove : typeof value === \"function\"\n ? propertyFunction\n : propertyConstant)(name, value))\n : this.node()[name];\n}\n","function classArray(string) {\n return string.trim().split(/^|\\s+/);\n}\n\nfunction classList(node) {\n return node.classList || new ClassList(node);\n}\n\nfunction ClassList(node) {\n this._node = node;\n this._names = classArray(node.getAttribute(\"class\") || \"\");\n}\n\nClassList.prototype = {\n add: function(name) {\n var i = this._names.indexOf(name);\n if (i < 0) {\n this._names.push(name);\n this._node.setAttribute(\"class\", this._names.join(\" \"));\n }\n },\n remove: function(name) {\n var i = this._names.indexOf(name);\n if (i >= 0) {\n this._names.splice(i, 1);\n this._node.setAttribute(\"class\", this._names.join(\" \"));\n }\n },\n contains: function(name) {\n return this._names.indexOf(name) >= 0;\n }\n};\n\nfunction classedAdd(node, names) {\n var list = classList(node), i = -1, n = names.length;\n while (++i < n) list.add(names[i]);\n}\n\nfunction classedRemove(node, names) {\n var list = classList(node), i = -1, n = names.length;\n while (++i < n) list.remove(names[i]);\n}\n\nfunction classedTrue(names) {\n return function() {\n classedAdd(this, names);\n };\n}\n\nfunction classedFalse(names) {\n return function() {\n classedRemove(this, names);\n };\n}\n\nfunction classedFunction(names, value) {\n return function() {\n (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);\n };\n}\n\nexport default function(name, value) {\n var names = classArray(name + \"\");\n\n if (arguments.length < 2) {\n var list = classList(this.node()), i = -1, n = names.length;\n while (++i < n) if (!list.contains(names[i])) return false;\n return true;\n }\n\n return this.each((typeof value === \"function\"\n ? classedFunction : value\n ? classedTrue\n : classedFalse)(names, value));\n}\n","function textRemove() {\n this.textContent = \"\";\n}\n\nfunction textConstant(value) {\n return function() {\n this.textContent = value;\n };\n}\n\nfunction textFunction(value) {\n return function() {\n var v = value.apply(this, arguments);\n this.textContent = v == null ? \"\" : v;\n };\n}\n\nexport default function(value) {\n return arguments.length\n ? this.each(value == null\n ? textRemove : (typeof value === \"function\"\n ? textFunction\n : textConstant)(value))\n : this.node().textContent;\n}\n","function htmlRemove() {\n this.innerHTML = \"\";\n}\n\nfunction htmlConstant(value) {\n return function() {\n this.innerHTML = value;\n };\n}\n\nfunction htmlFunction(value) {\n return function() {\n var v = value.apply(this, arguments);\n this.innerHTML = v == null ? \"\" : v;\n };\n}\n\nexport default function(value) {\n return arguments.length\n ? this.each(value == null\n ? htmlRemove : (typeof value === \"function\"\n ? htmlFunction\n : htmlConstant)(value))\n : this.node().innerHTML;\n}\n","function raise() {\n if (this.nextSibling) this.parentNode.appendChild(this);\n}\n\nexport default function() {\n return this.each(raise);\n}\n","function lower() {\n if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild);\n}\n\nexport default function() {\n return this.each(lower);\n}\n","import creator from \"../creator.js\";\nimport selector from \"../selector.js\";\n\nfunction constantNull() {\n return null;\n}\n\nexport default function(name, before) {\n var create = typeof name === \"function\" ? name : creator(name),\n select = before == null ? constantNull : typeof before === \"function\" ? before : selector(before);\n return this.select(function() {\n return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);\n });\n}\n","function remove() {\n var parent = this.parentNode;\n if (parent) parent.removeChild(this);\n}\n\nexport default function() {\n return this.each(remove);\n}\n","function selection_cloneShallow() {\n var clone = this.cloneNode(false), parent = this.parentNode;\n return parent ? parent.insertBefore(clone, this.nextSibling) : clone;\n}\n\nfunction selection_cloneDeep() {\n var clone = this.cloneNode(true), parent = this.parentNode;\n return parent ? parent.insertBefore(clone, this.nextSibling) : clone;\n}\n\nexport default function(deep) {\n return this.select(deep ? selection_cloneDeep : selection_cloneShallow);\n}\n","function contextListener(listener) {\n return function(event) {\n listener.call(this, event, this.__data__);\n };\n}\n\nfunction parseTypenames(typenames) {\n return typenames.trim().split(/^|\\s+/).map(function(t) {\n var name = \"\", i = t.indexOf(\".\");\n if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);\n return {type: t, name: name};\n });\n}\n\nfunction onRemove(typename) {\n return function() {\n var on = this.__on;\n if (!on) return;\n for (var j = 0, i = -1, m = on.length, o; j < m; ++j) {\n if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) {\n this.removeEventListener(o.type, o.listener, o.options);\n } else {\n on[++i] = o;\n }\n }\n if (++i) on.length = i;\n else delete this.__on;\n };\n}\n\nfunction onAdd(typename, value, options) {\n return function() {\n var on = this.__on, o, listener = contextListener(value);\n if (on) for (var j = 0, m = on.length; j < m; ++j) {\n if ((o = on[j]).type === typename.type && o.name === typename.name) {\n this.removeEventListener(o.type, o.listener, o.options);\n this.addEventListener(o.type, o.listener = listener, o.options = options);\n o.value = value;\n return;\n }\n }\n this.addEventListener(typename.type, listener, options);\n o = {type: typename.type, name: typename.name, value: value, listener: listener, options: options};\n if (!on) this.__on = [o];\n else on.push(o);\n };\n}\n\nexport default function(typename, value, options) {\n var typenames = parseTypenames(typename + \"\"), i, n = typenames.length, t;\n\n if (arguments.length < 2) {\n var on = this.node().__on;\n if (on) for (var j = 0, m = on.length, o; j < m; ++j) {\n for (i = 0, o = on[j]; i < n; ++i) {\n if ((t = typenames[i]).type === o.type && t.name === o.name) {\n return o.value;\n }\n }\n }\n return;\n }\n\n on = value ? onAdd : onRemove;\n for (i = 0; i < n; ++i) this.each(on(typenames[i], value, options));\n return this;\n}\n","import defaultView from \"../window.js\";\n\nfunction dispatchEvent(node, type, params) {\n var window = defaultView(node),\n event = window.CustomEvent;\n\n if (typeof event === \"function\") {\n event = new event(type, params);\n } else {\n event = window.document.createEvent(\"Event\");\n if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;\n else event.initEvent(type, false, false);\n }\n\n node.dispatchEvent(event);\n}\n\nfunction dispatchConstant(type, params) {\n return function() {\n return dispatchEvent(this, type, params);\n };\n}\n\nfunction dispatchFunction(type, params) {\n return function() {\n return dispatchEvent(this, type, params.apply(this, arguments));\n };\n}\n\nexport default function(type, params) {\n return this.each((typeof params === \"function\"\n ? dispatchFunction\n : dispatchConstant)(type, params));\n}\n","import selection_select from \"./select.js\";\nimport selection_selectAll from \"./selectAll.js\";\nimport selection_selectChild from \"./selectChild.js\";\nimport selection_selectChildren from \"./selectChildren.js\";\nimport selection_filter from \"./filter.js\";\nimport selection_data from \"./data.js\";\nimport selection_enter from \"./enter.js\";\nimport selection_exit from \"./exit.js\";\nimport selection_join from \"./join.js\";\nimport selection_merge from \"./merge.js\";\nimport selection_order from \"./order.js\";\nimport selection_sort from \"./sort.js\";\nimport selection_call from \"./call.js\";\nimport selection_nodes from \"./nodes.js\";\nimport selection_node from \"./node.js\";\nimport selection_size from \"./size.js\";\nimport selection_empty from \"./empty.js\";\nimport selection_each from \"./each.js\";\nimport selection_attr from \"./attr.js\";\nimport selection_style from \"./style.js\";\nimport selection_property from \"./property.js\";\nimport selection_classed from \"./classed.js\";\nimport selection_text from \"./text.js\";\nimport selection_html from \"./html.js\";\nimport selection_raise from \"./raise.js\";\nimport selection_lower from \"./lower.js\";\nimport selection_append from \"./append.js\";\nimport selection_insert from \"./insert.js\";\nimport selection_remove from \"./remove.js\";\nimport selection_clone from \"./clone.js\";\nimport selection_datum from \"./datum.js\";\nimport selection_on from \"./on.js\";\nimport selection_dispatch from \"./dispatch.js\";\nimport selection_iterator from \"./iterator.js\";\n\nexport var root = [null];\n\nexport function Selection(groups, parents) {\n this._groups = groups;\n this._parents = parents;\n}\n\nfunction selection() {\n return new Selection([[document.documentElement]], root);\n}\n\nfunction selection_selection() {\n return this;\n}\n\nSelection.prototype = selection.prototype = {\n constructor: Selection,\n select: selection_select,\n selectAll: selection_selectAll,\n selectChild: selection_selectChild,\n selectChildren: selection_selectChildren,\n filter: selection_filter,\n data: selection_data,\n enter: selection_enter,\n exit: selection_exit,\n join: selection_join,\n merge: selection_merge,\n selection: selection_selection,\n order: selection_order,\n sort: selection_sort,\n call: selection_call,\n nodes: selection_nodes,\n node: selection_node,\n size: selection_size,\n empty: selection_empty,\n each: selection_each,\n attr: selection_attr,\n style: selection_style,\n property: selection_property,\n classed: selection_classed,\n text: selection_text,\n html: selection_html,\n raise: selection_raise,\n lower: selection_lower,\n append: selection_append,\n insert: selection_insert,\n remove: selection_remove,\n clone: selection_clone,\n datum: selection_datum,\n on: selection_on,\n dispatch: selection_dispatch,\n [Symbol.iterator]: selection_iterator\n};\n\nexport default selection;\n","import {Selection, root} from \"./selection/index.js\";\n\nexport default function(selector) {\n return typeof selector === \"string\"\n ? new Selection([[document.querySelector(selector)]], [document.documentElement])\n : new Selection([[selector]], root);\n}\n","import sourceEvent from \"./sourceEvent.js\";\n\nexport default function(event, node) {\n event = sourceEvent(event);\n if (node === undefined) node = event.currentTarget;\n if (node) {\n var svg = node.ownerSVGElement || node;\n if (svg.createSVGPoint) {\n var point = svg.createSVGPoint();\n point.x = event.clientX, point.y = event.clientY;\n point = point.matrixTransform(node.getScreenCTM().inverse());\n return [point.x, point.y];\n }\n if (node.getBoundingClientRect) {\n var rect = node.getBoundingClientRect();\n return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];\n }\n }\n return [event.pageX, event.pageY];\n}\n","export default function(event) {\n let sourceEvent;\n while (sourceEvent = event.sourceEvent) event = sourceEvent;\n return event;\n}\n","import array from \"./array.js\";\nimport {Selection, root} from \"./selection/index.js\";\n\nexport default function(selector) {\n return typeof selector === \"string\"\n ? new Selection([document.querySelectorAll(selector)], [document.documentElement])\n : new Selection([array(selector)], root);\n}\n","import {Selection} from \"./index.js\";\nimport selector from \"../selector.js\";\n\nexport default function(select) {\n if (typeof select !== \"function\") select = selector(select);\n\n for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {\n for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {\n if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {\n if (\"__data__\" in node) subnode.__data__ = node.__data__;\n subgroup[i] = subnode;\n }\n }\n }\n\n return new Selection(subgroups, this._parents);\n}\n","import {Selection} from \"./index.js\";\nimport array from \"../array.js\";\nimport selectorAll from \"../selectorAll.js\";\n\nfunction arrayAll(select) {\n return function() {\n return array(select.apply(this, arguments));\n };\n}\n\nexport default function(select) {\n if (typeof select === \"function\") select = arrayAll(select);\n else select = selectorAll(select);\n\n for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {\n for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {\n if (node = group[i]) {\n subgroups.push(select.call(node, node.__data__, i, group));\n parents.push(node);\n }\n }\n }\n\n return new Selection(subgroups, parents);\n}\n","import {Selection} from \"./index.js\";\nimport matcher from \"../matcher.js\";\n\nexport default function(match) {\n if (typeof match !== \"function\") match = matcher(match);\n\n for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {\n for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {\n if ((node = group[i]) && match.call(node, node.__data__, i, group)) {\n subgroup.push(node);\n }\n }\n }\n\n return new Selection(subgroups, this._parents);\n}\n","export default function(x) {\n return function() {\n return x;\n };\n}\n","import sparse from \"./sparse.js\";\nimport {Selection} from \"./index.js\";\n\nexport default function() {\n return new Selection(this._exit || this._groups.map(sparse), this._parents);\n}\n","export default function(onenter, onupdate, onexit) {\n var enter = this.enter(), update = this, exit = this.exit();\n if (typeof onenter === \"function\") {\n enter = onenter(enter);\n if (enter) enter = enter.selection();\n } else {\n enter = enter.append(onenter + \"\");\n }\n if (onupdate != null) {\n update = onupdate(update);\n if (update) update = update.selection();\n }\n if (onexit == null) exit.remove(); else onexit(exit);\n return enter && update ? enter.merge(update).order() : update;\n}\n","import {Selection} from \"./index.js\";\n\nexport default function(context) {\n var selection = context.selection ? context.selection() : context;\n\n for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {\n for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {\n if (node = group0[i] || group1[i]) {\n merge[i] = node;\n }\n }\n }\n\n for (; j < m0; ++j) {\n merges[j] = groups0[j];\n }\n\n return new Selection(merges, this._parents);\n}\n","export default function() {\n\n for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) {\n for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) {\n if (node = group[i]) {\n if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next);\n next = node;\n }\n }\n }\n\n return this;\n}\n","export default function() {\n var callback = arguments[0];\n arguments[0] = this;\n callback.apply(null, arguments);\n return this;\n}\n","export default function() {\n return Array.from(this);\n}\n","export default function() {\n\n for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {\n for (var group = groups[j], i = 0, n = group.length; i < n; ++i) {\n var node = group[i];\n if (node) return node;\n }\n }\n\n return null;\n}\n","export default function() {\n let size = 0;\n for (const node of this) ++size; // eslint-disable-line no-unused-vars\n return size;\n}\n","export default function() {\n return !this.node();\n}\n","export default function(callback) {\n\n for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {\n for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {\n if (node = group[i]) callback.call(node, node.__data__, i, group);\n }\n }\n\n return this;\n}\n","import creator from \"../creator.js\";\n\nexport default function(name) {\n var create = typeof name === \"function\" ? name : creator(name);\n return this.select(function() {\n return this.appendChild(create.apply(this, arguments));\n });\n}\n","export default function(value) {\n return arguments.length\n ? this.property(\"__data__\", value)\n : this.node().__data__;\n}\n","export default function*() {\n for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {\n for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {\n if (node = group[i]) yield node;\n }\n }\n}\n","export default Array.isArray;\n","import isArray from './is-array';\n\nexport default function(value) {\n return value != null\n ? (isArray(value) ? value : [value])\n : [];\n}","/**\n * Generate a table expression that filters a table based on ordered row\n * indices from start to end (end not included), where start and end\n * represent per-group ordered row numbers in the table. The resulting\n * string can be used as the input to the filter verb.\n * @param {number} [start] Zero-based index at which to start extraction.\n * A negative index indicates an offset from the end of the group.\n * If start is undefined, slice starts from the index 0.\n * @param {number} [end] Zero-based index before which to end extraction.\n * A negative index indicates an offset from the end of the group.\n * If end is omitted, slice extracts through the end of the group.\n * @return {string} A table expression string for slicing values.\n * @example slice(1, -1)\n */\nexport default function(start = 0, end = Infinity) {\n return `${prep(start)} < row_number() && row_number() <= ${prep(end)}`;\n}\n\nfunction prep(index) {\n return index < 0 ? `count() + ${index}` : index;\n}","import toArray from '../util/to-array';\nimport slice from '../helpers/slice';\n\n/**\n * Abstract base class for transforming data.\n */\nexport default class Transformable {\n\n /**\n * Instantiate a new Transformable instance.\n * @param {Params} [params] The parameter values.\n */\n constructor(params) {\n if (params) this._params = params;\n }\n\n /**\n * Get or set table expression parameter values.\n * If called with no arguments, returns the current parameter values\n * as an object. Otherwise, adds the provided parameters to this\n * table's parameter set and returns the table. Any prior parameters\n * with names matching the input parameters are overridden.\n * @param {Params} [values] The parameter values.\n * @return {this|Params} The current parameters values (if called with\n * no arguments) or this table.\n */\n params(values) {\n if (arguments.length) {\n if (values) {\n this._params = { ...this._params, ...values };\n }\n return this;\n } else {\n return this._params;\n }\n }\n\n /**\n * Create a new fully-materialized instance of this table.\n * All filter and orderby settings are removed from the new table.\n * Instead, the backing data itself is filtered and ordered as needed.\n * @param {number[]} [indices] Ordered row indices to materialize.\n * If unspecified, all rows passing the table filter are used.\n * @return {this} A reified table.\n */\n reify(indices) {\n return this.__reify(this, indices);\n }\n\n // -- Transformation Verbs ------------------------------------------------\n\n /**\n * Count the number of values in a group. This method is a shorthand\n * for {@link Transformable#rollup} with a count aggregate function.\n * @param {CountOptions} [options] Options for the count.\n * @return {this} A new table with groupby and count columns.\n * @example table.groupby('colA').count()\n * @example table.groupby('colA').count({ as: 'num' })\n */\n count(options) {\n return this.__count(this, options);\n }\n\n /**\n * Derive new column values based on the provided expressions. By default,\n * new columns are added after (higher indices than) existing columns. Use\n * the before or after options to place new columns elsewhere.\n * @param {ExprObject} values Object of name-value pairs defining the\n * columns to derive. The input object should have output column\n * names for keys and table expressions for values.\n * @param {DeriveOptions} [options] Options for dropping or relocating\n * derived columns. Use either a before or after property to indicate\n * where to place derived columns. Specifying both before and after is an\n * error. Unlike the relocate verb, this option affects only new columns;\n * updated columns with existing names are excluded from relocation.\n * @return {this} A new table with derived columns added.\n * @example table.derive({ sumXY: d => d.x + d.y })\n * @example table.derive({ z: d => d.x * d.y }, { before: 'x' })\n */\n derive(values, options) {\n return this.__derive(this, values, options);\n }\n\n /**\n * Filter a table to a subset of rows based on the input criteria.\n * The resulting table provides a filtered view over the original data; no\n * data copy is made. To create a table that copies only filtered data to\n * new data structures, call {@link Transformable#reify} on the output table.\n * @param {TableExpr} criteria Filter criteria as a table expression.\n * Both aggregate and window functions are permitted, taking into account\n * {@link Transformable#groupby} or {@link Transformable#orderby} settings.\n * @return {this} A new table with filtered rows.\n * @example table.filter(d => abs(d.value) < 5)\n */\n filter(criteria) {\n return this.__filter(this, criteria);\n }\n\n /**\n * Extract rows with indices from start to end (end not included), where\n * start and end represent per-group ordered row numbers in the table.\n * @param {number} [start] Zero-based index at which to start extraction.\n * A negative index indicates an offset from the end of the group.\n * If start is undefined, slice starts from the index 0.\n * @param {number} [end] Zero-based index before which to end extraction.\n * A negative index indicates an offset from the end of the group.\n * If end is omitted, slice extracts through the end of the group.\n * @return {this} A new table with sliced rows.\n * @example table.slice(1, -1)\n */\n slice(start, end) {\n return this.filter(slice(start, end)).reify();\n }\n\n /**\n * Group table rows based on a set of column values.\n * Subsequent operations that are sensitive to grouping (such as\n * aggregate functions) will operate over the grouped rows.\n * To undo grouping, use {@link Transformable#ungroup}.\n * @param {...ExprList} keys Key column values to group by.\n * The keys may be specified using column name strings, column index\n * numbers, value objects with output column names for keys and table\n * expressions for values, or selection helper functions.\n * @return {this} A new table with grouped rows.\n * @example table.groupby('colA', 'colB')\n * @example table.groupby({ key: d => d.colA + d.colB })\n */\n groupby(...keys) {\n return this.__groupby(this, keys.flat());\n }\n\n /**\n * Order table rows based on a set of column values.\n * Subsequent operations sensitive to ordering (such as window functions)\n * will operate over sorted values.\n * The resulting table provides an view over the original data, without\n * any copying. To create a table with sorted data copied to new data\n * strucures, call {@link Transformable#reify} on the result of this method.\n * To undo ordering, use {@link Transformable#unorder}.\n * @param {...OrderKeys} keys Key values to sort by, in precedence order.\n * By default, sorting is done in ascending order.\n * To sort in descending order, wrap values using {@link desc}.\n * If a string, order by the column with that name.\n * If a number, order by the column with that index.\n * If a function, must be a valid table expression; aggregate functions\n * are permitted, but window functions are not.\n * If an object, object values must be valid values parameters\n * with output column names for keys and table expressions\n * for values (the output names will be ignored).\n * If an array, array values must be valid key parameters.\n * @return {this} A new ordered table.\n * @example table.orderby('a', desc('b'))\n * @example table.orderby({ a: 'a', b: desc('b') )})\n * @example table.orderby(desc(d => d.a))\n */\n orderby(...keys) {\n return this.__orderby(this, keys.flat());\n }\n\n /**\n * Relocate a subset of columns to change their positions, also\n * potentially renaming them.\n * @param {Selection} columns An ordered selection of columns to relocate.\n * The input may consist of column name strings, column integer indices,\n * rename objects with current column names as keys and new column names\n * as values, or functions that take a table as input and returns a valid\n * selection parameter (typically the output of selection helper functions\n * such as {@link all}, {@link not}, or {@link range}).\n * @param {RelocateOptions} options Options for relocating. Must include\n * either the before or after property to indicate where to place the\n * relocated columns. Specifying both before and after is an error.\n * @return {this} A new table with relocated columns.\n * @example table.relocate(['colY', 'colZ'], { after: 'colX' })\n * @example table.relocate(not('colB', 'colC'), { before: 'colA' })\n * @example table.relocate({ colA: 'newA', colB: 'newB' }, { after: 'colC' })\n */\n relocate(columns, options) {\n return this.__relocate(this, toArray(columns), options);\n }\n\n /**\n * Rename one or more columns, preserving column order.\n * @param {...Select} columns One or more rename objects with current\n * column names as keys and new column names as values.\n * @return {this} A new table with renamed columns.\n * @example table.rename({ oldName: 'newName' })\n * @example table.rename({ a: 'a2', b: 'b2' })\n */\n rename(...columns) {\n return this.__rename(this, columns.flat());\n }\n\n /**\n * Rollup a table to produce an aggregate summary.\n * Often used in conjunction with {@link Transformable#groupby}.\n * To produce counts only, {@link Transformable#count} is a shortcut.\n * @param {ExprObject} [values] Object of name-value pairs defining aggregate\n * output columns. The input object should have output column names for\n * keys and table expressions for values. The expressions must be valid\n * aggregate expressions: window functions are not allowed and column\n * references must be arguments to aggregate functions.\n * @return {this} A new table of aggregate summary values.\n * @example table.groupby('colA').rollup({ mean: d => mean(d.colB) })\n * @example table.groupby('colA').rollup({ mean: op.median('colB') })\n */\n rollup(values) {\n return this.__rollup(this, values);\n }\n\n /**\n * Generate a table from a random sample of rows.\n * If the table is grouped, performs a stratified sample by\n * sampling from each group separately.\n * @param {number|TableExpr} size The number of samples to draw per group.\n * If number-valued, the same sample size is used for each group.\n * If function-valued, the input should be an aggregate table\n * expression compatible with {@link Transformable#rollup}.\n * @param {SampleOptions} [options] Options for sampling.\n * @return {this} A new table with sampled rows.\n * @example table.sample(50)\n * @example table.sample(100, { replace: true })\n * @example table.groupby('colA').sample(() => op.floor(0.5 * op.count()))\n */\n sample(size, options) {\n return this.__sample(this, size, options);\n }\n\n /**\n * Select a subset of columns into a new table, potentially renaming them.\n * @param {...Select} columns An ordered selection of columns.\n * The input may consist of column name strings, column integer indices,\n * rename objects with current column names as keys and new column names\n * as values, or functions that take a table as input and returns a valid\n * selection parameter (typically the output of selection helper functions\n * such as {@link all}, {@link not}, or {@link range}).\n * @return {this} A new table of selected columns.\n * @example table.select('colA', 'colB')\n * @example table.select(not('colB', 'colC'))\n * @example table.select({ colA: 'newA', colB: 'newB' })\n */\n select(...columns) {\n return this.__select(this, columns.flat());\n }\n\n /**\n * Ungroup a table, removing any grouping criteria.\n * Undoes the effects of {@link Transformable#groupby}.\n * @return {this} A new ungrouped table, or this table if not grouped.\n * @example table.ungroup()\n */\n ungroup() {\n return this.__ungroup(this);\n }\n\n /**\n * Unorder a table, removing any sorting criteria.\n * Undoes the effects of {@link Transformable#orderby}.\n * @return {this} A new unordered table, or this table if not ordered.\n * @example table.unorder()\n */\n unorder() {\n return this.__unorder(this);\n }\n\n // -- Cleaning Verbs ------------------------------------------------------\n\n /**\n * De-duplicate table rows by removing repeated row values.\n * @param {...ExprList} keys Key columns to check for duplicates.\n * Two rows are considered duplicates if they have matching values for\n * all keys. If keys are unspecified, all columns are used.\n * The keys may be specified using column name strings, column index\n * numbers, value objects with output column names for keys and table\n * expressions for values, or selection helper functions.\n * @return {this} A new de-duplicated table.\n * @example table.dedupe()\n * @example table.dedupe('a', 'b')\n * @example table.dedupe({ abs: d => op.abs(d.a) })\n */\n dedupe(...keys) {\n return this.__dedupe(this, keys.flat());\n }\n\n /**\n * Impute missing values or rows. Accepts a set of column-expression pairs\n * and evaluates the expressions to replace any missing (null, undefined,\n * or NaN) values in the original column.\n * If the expand option is specified, imputes new rows for missing\n * combinations of values. All combinations of key values (a full cross\n * product) are considered for each level of grouping (specified by\n * {@link Transformable#groupby}). New rows will be added for any combination\n * of key and groupby values not already contained in the table. For all\n * non-key and non-group columns the new rows are populated with imputation\n * values (first argument) if specified, otherwise undefined.\n * If the expand option is specified, any filter or orderby settings are\n * removed from the output table, but groupby settings persist.\n * @param {ExprObject} values Object of name-value pairs for the column values\n * to impute. The input object should have existing column names for keys\n * and table expressions for values. The expressions will be evaluated to\n * determine replacements for any missing values.\n * @param {ImputeOptions} [options] Imputation options. The expand\n * property specifies a set of column values to consider for imputing\n * missing rows. All combinations of expanded values are considered, and\n * new rows are added for each combination that does not appear in the\n * input table.\n * @return {this} A new table with imputed values and/or rows.\n * @example table.impute({ v: () => 0 })\n * @example table.impute({ v: d => op.mean(d.v) })\n * @example table.impute({ v: () => 0 }, { expand: ['x', 'y'] })\n */\n impute(values, options) {\n return this.__impute(this, values, options);\n }\n\n // -- Reshaping Verbs -----------------------------------------------------\n\n /**\n * Fold one or more columns into two key-value pair columns.\n * The fold transform is an inverse of the {@link Transformable#pivot} transform.\n * The resulting table has two new columns, one containing the column\n * names (named \"key\") and the other the column values (named \"value\").\n * The number of output rows equals the original row count multiplied\n * by the number of folded columns.\n * @param {ExprList} values The columns to fold.\n * The columns may be specified using column name strings, column index\n * numbers, value objects with output column names for keys and table\n * expressions for values, or selection helper functions.\n * @param {FoldOptions} [options] Options for folding.\n * @return {this} A new folded table.\n * @example table.fold('colA')\n * @example table.fold(['colA', 'colB'])\n * @example table.fold(range(5, 8))\n */\n fold(values, options) {\n return this.__fold(this, values, options);\n }\n\n /**\n * Pivot columns into a cross-tabulation.\n * The pivot transform is an inverse of the {@link Transformable#fold} transform.\n * The resulting table has new columns for each unique combination\n * of the provided *keys*, populated with the provided *values*.\n * The provided *values* must be aggregates, as a single set of keys may\n * include more than one row. If string-valued, the *any* aggregate is used.\n * If only one *values* column is defined, the new pivoted columns will\n * be named using key values directly. Otherwise, input value column names\n * will be included as a component of the output column names.\n * @param {ExprList} keys Key values to map to new column names.\n * The keys may be specified using column name strings, column index\n * numbers, value objects with output column names for keys and table\n * expressions for values, or selection helper functions.\n * @param {ExprList} values Output values for pivoted columns.\n * Column references will be wrapped in an *any* aggregate.\n * If object-valued, the input object should have output value\n * names for keys and aggregate table expressions for values.\n * @param {PivotOptions} [options] Options for pivoting.\n * @return {this} A new pivoted table.\n * @example table.pivot('key', 'value')\n * @example table.pivot(['keyA', 'keyB'], ['valueA', 'valueB'])\n * @example table.pivot({ key: d => d.key }, { value: d => sum(d.value) })\n */\n pivot(keys, values, options) {\n return this.__pivot(this, keys, values, options);\n }\n\n /**\n * Spread array elements into a set of new columns.\n * Output columns are named based on the value key and array index.\n * @param {ExprList} values The column values to spread.\n * The values may be specified using column name strings, column index\n * numbers, value objects with output column names for keys and table\n * expressions for values, or selection helper functions.\n * @param {SpreadOptions} [options] Options for spreading.\n * @return {this} A new table with the spread columns added.\n * @example table.spread({ a: split(d.text, '') })\n * @example table.spread('arrayCol', { limit: 100 })\n */\n spread(values, options) {\n return this.__spread(this, values, options);\n }\n\n /**\n * Unroll one or more array-valued columns into new rows.\n * If more than one array value is used, the number of new rows\n * is the smaller of the limit and the largest length.\n * Values for all other columns are copied over.\n * @param {ExprList} values The column values to unroll.\n * The values may be specified using column name strings, column index\n * numbers, value objects with output column names for keys and table\n * expressions for values, or selection helper functions.\n * @param {UnrollOptions} [options] Options for unrolling.\n * @return {this} A new unrolled table.\n * @example table.unroll('colA', { limit: 1000 })\n */\n unroll(values, options) {\n return this.__unroll(this, values, options);\n }\n\n // -- Joins ---------------------------------------------------------------\n\n /**\n * Lookup values from a secondary table and add them as new columns.\n * A lookup occurs upon matching key values for rows in both tables.\n * If the secondary table has multiple rows with the same key, only\n * the last observed instance will be considered in the lookup.\n * Lookup is similar to {@link Transformable#join_left}, but with a simpler\n * syntax and the added constraint of allowing at most one match only.\n * @param {TableRef} other The secondary table to look up values from.\n * @param {JoinKeys} [on] Lookup keys (column name strings or table\n * expressions) for this table and the secondary table, respectively.\n * @param {...ExprList} values The column values to add from the\n * secondary table. Can be column name strings or objects with column\n * names as keys and table expressions as values.\n * @return {this} A new table with lookup values added.\n * @example table.lookup(other, ['key1', 'key2'], 'value1', 'value2')\n */\n lookup(other, on, ...values) {\n return this.__lookup(this, other, on, values.flat());\n }\n\n /**\n * Join two tables, extending the columns of one table with\n * values from the other table. The current table is considered\n * the \"left\" table in the join, and the new table input is\n * considered the \"right\" table in the join. By default an inner\n * join is performed, removing all rows that do not match the\n * join criteria. To perform left, right, or full outer joins, use\n * the {@link Transformable#join_left}, {@link Transformable#join_right}, or\n * {@link Transformable#join_full} methods, or provide an options argument.\n * @param {TableRef} other The other (right) table to join with.\n * @param {JoinPredicate} [on] The join criteria for matching table rows.\n * If unspecified, the values of all columns with matching names\n * are compared.\n * If array-valued, a two-element array should be provided, containing\n * the columns to compare for the left and right tables, respectively.\n * If a one-element array or a string value is provided, the same\n * column names will be drawn from both tables.\n * If function-valued, should be a two-table table expression that\n * returns a boolean value. When providing a custom predicate, note that\n * join key values can be arrays or objects, and that normal join\n * semantics do not consider null or undefined values to be equal (that is,\n * null !== null). Use the op.equal function to handle these cases.\n * @param {JoinValues} [values] The columns to include in the join output.\n * If unspecified, all columns from both tables are included; paired\n * join keys sharing the same column name are included only once.\n * If array-valued, a two element array should be provided, containing\n * the columns to include for the left and right tables, respectively.\n * Array input may consist of column name strings, objects with output\n * names as keys and single-table table expressions as values, or the\n * selection helper functions {@link all}, {@link not}, or {@link range}.\n * If object-valued, specifies the key-value pairs for each output,\n * defined using two-table table expressions.\n * @param {JoinOptions} [options] Options for the join.\n * @return {this} A new joined table.\n * @example table.join(other, ['keyL', 'keyR'])\n * @example table.join(other, (a, b) => equal(a.keyL, b.keyR))\n */\n join(other, on, values, options) {\n return this.__join(this, other, on, values, options);\n }\n\n /**\n * Perform a left outer join on two tables. Rows in the left table\n * that do not match a row in the right table will be preserved.\n * This is a convenience method with fixed options for {@link Transformable#join}.\n * @param {TableRef} other The other (right) table to join with.\n * @param {JoinPredicate} [on] The join criteria for matching table rows.\n * If unspecified, the values of all columns with matching names\n * are compared.\n * If array-valued, a two-element array should be provided, containing\n * the columns to compare for the left and right tables, respectively.\n * If a one-element array or a string value is provided, the same\n * column names will be drawn from both tables.\n * If function-valued, should be a two-table table expression that\n * returns a boolean value. When providing a custom predicate, note that\n * join key values can be arrays or objects, and that normal join\n * semantics do not consider null or undefined values to be equal (that is,\n * null !== null). Use the op.equal function to handle these cases.\n * @param {JoinValues} [values] The columns to include in the join output.\n * If unspecified, all columns from both tables are included; paired\n * join keys sharing the same column name are included only once.\n * If array-valued, a two element array should be provided, containing\n * the columns to include for the left and right tables, respectively.\n * Array input may consist of column name strings, objects with output\n * names as keys and single-table table expressions as values, or the\n * selection helper functions {@link all}, {@link not}, or {@link range}.\n * If object-valued, specifies the key-value pairs for each output,\n * defined using two-table table expressions.\n * @param {JoinOptions} [options] Options for the join. With this method,\n * any options will be overridden with {left: true, right: false}.\n * @return {this} A new joined table.\n * @example table.join_left(other, ['keyL', 'keyR'])\n * @example table.join_left(other, (a, b) => equal(a.keyL, b.keyR))\n */\n join_left(other, on, values, options) {\n const opt = { ...options, left: true, right: false };\n return this.__join(this, other, on, values, opt);\n }\n\n /**\n * Perform a right outer join on two tables. Rows in the right table\n * that do not match a row in the left table will be preserved.\n * This is a convenience method with fixed options for {@link Transformable#join}.\n * @param {TableRef} other The other (right) table to join with.\n * @param {JoinPredicate} [on] The join criteria for matching table rows.\n * If unspecified, the values of all columns with matching names\n * are compared.\n * If array-valued, a two-element array should be provided, containing\n * the columns to compare for the left and right tables, respectively.\n * If a one-element array or a string value is provided, the same\n * column names will be drawn from both tables.\n * If function-valued, should be a two-table table expression that\n * returns a boolean value. When providing a custom predicate, note that\n * join key values can be arrays or objects, and that normal join\n * semantics do not consider null or undefined values to be equal (that is,\n * null !== null). Use the op.equal function to handle these cases.\n * @param {JoinValues} [values] The columns to include in the join output.\n * If unspecified, all columns from both tables are included; paired\n * join keys sharing the same column name are included only once.\n * If array-valued, a two element array should be provided, containing\n * the columns to include for the left and right tables, respectively.\n * Array input may consist of column name strings, objects with output\n * names as keys and single-table table expressions as values, or the\n * selection helper functions {@link all}, {@link not}, or {@link range}.\n * If object-valued, specifies the key-value pairs for each output,\n * defined using two-table table expressions.\n * @param {JoinOptions} [options] Options for the join. With this method,\n * any options will be overridden with {left: false, right: true}.\n * @return {this} A new joined table.\n * @example table.join_right(other, ['keyL', 'keyR'])\n * @example table.join_right(other, (a, b) => equal(a.keyL, b.keyR))\n */\n join_right(other, on, values, options) {\n const opt = { ...options, left: false, right: true };\n return this.__join(this, other, on, values, opt);\n }\n\n /**\n * Perform a full outer join on two tables. Rows in either the left or\n * right table that do not match a row in the other will be preserved.\n * This is a convenience method with fixed options for {@link Transformable#join}.\n * @param {TableRef} other The other (right) table to join with.\n * @param {JoinPredicate} [on] The join criteria for matching table rows.\n * If unspecified, the values of all columns with matching names\n * are compared.\n * If array-valued, a two-element array should be provided, containing\n * the columns to compare for the left and right tables, respectively.\n * If a one-element array or a string value is provided, the same\n * column names will be drawn from both tables.\n * If function-valued, should be a two-table table expression that\n * returns a boolean value. When providing a custom predicate, note that\n * join key values can be arrays or objects, and that normal join\n * semantics do not consider null or undefined values to be equal (that is,\n * null !== null). Use the op.equal function to handle these cases.\n * @param {JoinValues} [values] The columns to include in the join output.\n * If unspecified, all columns from both tables are included; paired\n * join keys sharing the same column name are included only once.\n * If array-valued, a two element array should be provided, containing\n * the columns to include for the left and right tables, respectively.\n * Array input may consist of column name strings, objects with output\n * names as keys and single-table table expressions as values, or the\n * selection helper functions {@link all}, {@link not}, or {@link range}.\n * If object-valued, specifies the key-value pairs for each output,\n * defined using two-table table expressions.\n * @param {JoinOptions} [options] Options for the join. With this method,\n * any options will be overridden with {left: true, right: true}.\n * @return {this} A new joined table.\n * @example table.join_full(other, ['keyL', 'keyR'])\n * @example table.join_full(other, (a, b) => equal(a.keyL, b.keyR))\n */\n join_full(other, on, values, options) {\n const opt = { ...options, left: true, right: true };\n return this.__join(this, other, on, values, opt);\n }\n\n /**\n * Produce the Cartesian cross product of two tables. The output table\n * has one row for every pair of input table rows. Beware that outputs\n * may be quite large, as the number of output rows is the product of\n * the input row counts.\n * This is a convenience method for {@link Transformable#join} in which the\n * join criteria is always true.\n * @param {TableRef} other The other (right) table to join with.\n * @param {JoinValues} [values] The columns to include in the output.\n * If unspecified, all columns from both tables are included.\n * If array-valued, a two element array should be provided, containing\n * the columns to include for the left and right tables, respectively.\n * Array input may consist of column name strings, objects with output\n * names as keys and single-table table expressions as values, or the\n * selection helper functions {@link all}, {@link not}, or {@link range}.\n * If object-valued, specifies the key-value pairs for each output,\n * defined using two-table table expressions.\n * @param {JoinOptions} [options] Options for the join.\n * @return {this} A new joined table.\n * @example table.cross(other)\n * @example table.cross(other, [['leftKey', 'leftVal'], ['rightVal']])\n */\n cross(other, values, options) {\n return this.__cross(this, other, values, options);\n }\n\n /**\n * Perform a semi-join, filtering the left table to only rows that\n * match a row in the right table.\n * @param {TableRef} other The other (right) table to join with.\n * @param {JoinPredicate} [on] The join criteria for matching table rows.\n * If unspecified, the values of all columns with matching names\n * are compared.\n * If array-valued, a two-element array should be provided, containing\n * the columns to compare for the left and right tables, respectively.\n * If a one-element array or a string value is provided, the same\n * column names will be drawn from both tables.\n * If function-valued, should be a two-table table expression that\n * returns a boolean value. When providing a custom predicate, note that\n * join key values can be arrays or objects, and that normal join\n * semantics do not consider null or undefined values to be equal (that is,\n * null !== null). Use the op.equal function to handle these cases.\n * @return {this} A new filtered table.\n * @example table.semijoin(other)\n * @example table.semijoin(other, ['keyL', 'keyR'])\n * @example table.semijoin(other, (a, b) => equal(a.keyL, b.keyR))\n */\n semijoin(other, on) {\n return this.__semijoin(this, other, on);\n }\n\n /**\n * Perform an anti-join, filtering the left table to only rows that\n * do *not* match a row in the right table.\n * @param {TableRef} other The other (right) table to join with.\n * @param {JoinPredicate} [on] The join criteria for matching table rows.\n * If unspecified, the values of all columns with matching names\n * are compared.\n * If array-valued, a two-element array should be provided, containing\n * the columns to compare for the left and right tables, respectively.\n * If a one-element array or a string value is provided, the same\n * column names will be drawn from both tables.\n * If function-valued, should be a two-table table expression that\n * returns a boolean value. When providing a custom predicate, note that\n * join key values can be arrays or objects, and that normal join\n * semantics do not consider null or undefined values to be equal (that is,\n * null !== null). Use the op.equal function to handle these cases.\n * @return {this} A new filtered table.\n * @example table.antijoin(other)\n * @example table.antijoin(other, ['keyL', 'keyR'])\n * @example table.antijoin(other, (a, b) => equal(a.keyL, b.keyR))\n */\n antijoin(other, on) {\n return this.__antijoin(this, other, on);\n }\n\n // -- Set Operations ------------------------------------------------------\n\n /**\n * Concatenate multiple tables into a single table, preserving all rows.\n * This transformation mirrors the UNION_ALL operation in SQL.\n * Only named columns in this table are included in the output.\n * @see Transformable#union\n * @param {...TableRef} tables A list of tables to concatenate.\n * @return {this} A new concatenated table.\n * @example table.concat(other)\n * @example table.concat(other1, other2)\n * @example table.concat([other1, other2])\n */\n concat(...tables) {\n return this.__concat(this, tables.flat());\n }\n\n /**\n * Union multiple tables into a single table, deduplicating all rows.\n * This transformation mirrors the UNION operation in SQL. It is\n * similar to {@link Transformable#concat} but suppresses duplicate rows with\n * values identical to another row.\n * Only named columns in this table are included in the output.\n * @see Transformable#concat\n * @param {...TableRef} tables A list of tables to union.\n * @return {this} A new unioned table.\n * @example table.union(other)\n * @example table.union(other1, other2)\n * @example table.union([other1, other2])\n */\n union(...tables) {\n return this.__union(this, tables.flat());\n }\n\n /**\n * Intersect multiple tables, keeping only rows whose with identical\n * values for all columns in all tables, and deduplicates the rows.\n * This transformation is similar to a series of {@link Transformable#semijoin}\n * calls, but additionally suppresses duplicate rows.\n * @see Transformable#semijoin\n * @param {...TableRef} tables A list of tables to intersect.\n * @return {this} A new filtered table.\n * @example table.intersect(other)\n * @example table.intersect(other1, other2)\n * @example table.intersect([other1, other2])\n */\n intersect(...tables) {\n return this.__intersect(this, tables.flat());\n }\n\n /**\n * Compute the set difference with multiple tables, keeping only rows in\n * this table that whose values do not occur in the other tables.\n * This transformation is similar to a series of {@link Transformable#antijoin}\n * calls, but additionally suppresses duplicate rows.\n * @see Transformable#antijoin\n * @param {...TableRef} tables A list of tables to difference.\n * @return {this} A new filtered table.\n * @example table.except(other)\n * @example table.except(other1, other2)\n * @example table.except([other1, other2])\n */\n except(...tables) {\n return this.__except(this, tables.flat());\n }\n}\n\n// -- Parameter Types -------------------------------------------------------\n\n/**\n * Table expression parameters.\n * @typedef {Object.} Params\n */\n\n/**\n * A reference to a column by string name or integer index.\n * @typedef {string|number} ColumnRef\n */\n\n/**\n * A value that can be coerced to a string.\n * @typedef {object} Stringable\n * @property {() => string} toString String coercion method.\n */\n\n/**\n * A table expression provided as a string or string-coercible value.\n * @typedef {string|Stringable} TableExprString\n */\n\n/**\n * A struct object with arbitraty named properties.\n * @typedef {Object.} Struct\n */\n\n/**\n * A function defined over a table row.\n * @typedef {(d?: Struct, $?: Params) => any} TableExprFunc\n */\n\n/**\n * A table expression defined over a single table.\n * @typedef {TableExprFunc|TableExprString} TableExpr\n */\n\n/**\n * A function defined over rows from two tables.\n * @typedef {(a?: Struct, b?: Struct, $?: Params) => any} TableFunc2\n */\n\n/**\n * A table expression defined over two tables.\n * @typedef {TableExprFunc2|TableExprString} TableExpr2\n */\n\n/**\n * An object that maps current column names to new column names.\n * @typedef {{ [name: string]: string }} RenameMap\n */\n\n/**\n * A selection helper function.\n * @typedef {(table: any) => string[]} SelectHelper\n */\n\n/**\n * One or more column selections, potentially with renaming.\n * The input may consist of a column name string, column integer index, a\n * rename map object with current column names as keys and new column names\n * as values, or a select helper function that takes a table as input and\n * returns a valid selection parameter.\n * @typedef {ColumnRef|RenameMap|SelectHelper} SelectEntry\n */\n\n/**\n * An ordered set of column selections, potentially with renaming.\n * @typedef {SelectEntry|SelectEntry[]} Select\n */\n\n/**\n * An object of column name / table expression pairs.\n * @typedef {{ [name: string]: TableExpr }} ExprObject\n */\n\n/**\n * An object of column name / two-table expression pairs.\n * @typedef {{ [name: string]: TableExpr2 }} Expr2Object\n */\n\n/**\n * An ordered set of one or more column values.\n * @typedef {ColumnRef|SelectHelper|ExprObject} ListEntry\n */\n\n/**\n * An ordered set of column values.\n * Entries may be column name strings, column index numbers, value objects\n * with output column names for keys and table expressions for values,\n * or a selection helper function.\n * @typedef {ListEntry|ListEntry[]} ExprList\n */\n\n/**\n * A reference to a data table or transformable instance.\n * @typedef {Transformable|string} TableRef\n */\n\n/**\n * One or more orderby sort criteria.\n * If a string, order by the column with that name.\n * If a number, order by the column with that index.\n * If a function, must be a valid table expression; aggregate functions\n * are permitted, but window functions are not.\n * If an object, object values must be valid values parameters\n * with output column names for keys and table expressions\n * for values. The output name keys will subsequently be ignored.\n * @typedef {ColumnRef|TableExpr|ExprObject} OrderKey\n */\n\n/**\n * An ordered set of orderby sort criteria, in precedence order.\n * @typedef {OrderKey|OrderKey[]} OrderKeys\n */\n\n/**\n * Column values to use as a join key.\n * @typedef {ColumnRef|TableExprFunc} JoinKey\n */\n\n/**\n * An ordered set of join keys.\n * @typedef {JoinKey|[JoinKey[]]|[JoinKey[], JoinKey[]]} JoinKeys\n */\n\n/**\n * A predicate specification for joining two tables.\n * @typedef {JoinKeys|TableExprFunc2|null} JoinPredicate\n */\n\n/**\n * An array of per-table join values to extract.\n * @typedef {[ExprList]|[ExprList, ExprList]|[ExprList, ExprList, Expr2Object]} JoinList\n */\n\n/**\n * A specification of join values to extract.\n * @typedef {JoinList|Expr2Object} JoinValues\n */\n\n// -- Transform Options -----------------------------------------------------\n\n/**\n * Options for count transformations.\n * @typedef {object} CountOptions\n * @property {string} [as='count'] The name of the output count column.\n */\n\n/**\n * Options for derive transformations.\n * @typedef {object} DeriveOptions\n * @property {boolean} [drop=false] A flag indicating if the original\n * columns should be dropped, leaving only the derived columns. If true,\n * the before and after options are ignored.\n * @property {Select} [before]\n * An anchor column that relocated columns should be placed before.\n * The value can be any legal column selection. If multiple columns are\n * selected, only the first column will be used as an anchor.\n * It is an error to specify both before and after options.\n * @property {Select} [after]\n * An anchor column that relocated columns should be placed after.\n * The value can be any legal column selection. If multiple columns are\n * selected, only the last column will be used as an anchor.\n * It is an error to specify both before and after options.\n */\n\n/**\n * Options for relocate transformations.\n * @typedef {object} RelocateOptions\n * @property {Selection} [before]\n * An anchor column that relocated columns should be placed before.\n * The value can be any legal column selection. If multiple columns are\n * selected, only the first column will be used as an anchor.\n * It is an error to specify both before and after options.\n * @property {Selection} [after]\n * An anchor column that relocated columns should be placed after.\n * The value can be any legal column selection. If multiple columns are\n * selected, only the last column will be used as an anchor.\n * It is an error to specify both before and after options.\n */\n\n/**\n * Options for sample transformations.\n * @typedef {object} SampleOptions\n * @property {boolean} [replace=false] Flag for sampling with replacement.\n * @property {boolean} [shuffle=true] Flag to ensure randomly ordered rows.\n * @property {string|TableExprFunc} [weight] Column values to use as weights\n * for sampling. Rows will be sampled with probability proportional to\n * their relative weight. The input should be a column name string or\n * a table expression compatible with {@link Transformable#derive}.\n */\n\n/**\n * Options for impute transformations.\n * @typedef {object} ImputeOptions\n * @property {ExprList} [expand] Column values to combine to impute missing\n * rows. For column names and indices, all unique column values are\n * considered. Otherwise, each entry should be an object of name-expresion\n * pairs, with valid table expressions for {@link Transformable#rollup}.\n * All combinations of values are checked for each set of unique groupby\n * values.\n */\n\n/**\n * Options for fold transformations.\n * @typedef {object} FoldOptions\n * @property {string[]} [as=['key', 'value']] An array indicating the\n * output column names to use for the key and value columns, respectively.\n */\n\n/**\n * Options for pivot transformations.\n * @typedef {object} PivotOptions\n * @property {number} [limit=Infinity] The maximum number of new columns to generate.\n * @property {string} [keySeparator='_'] A string to place between multiple key names.\n * @property {string} [valueSeparator='_'] A string to place between key and value names.\n * @property {boolean} [sort=true] Flag for alphabetical sorting of new column names.\n */\n\n/**\n * Options for spread transformations.\n * @typedef {object} SpreadOptions\n * @property {boolean} [drop=true] Flag indicating if input columns to the\n * spread operation should be dropped in the output table.\n * @property {number} [limit=Infinity] The maximum number of new columns to\n * generate.\n * @property {string[]} [as] Output column names to use. This option only\n * applies when a single column is spread. If the given array of names is\n * shorter than the number of generated columns and no limit option is\n * specified, the additional generated columns will be dropped.\n */\n\n/**\n * Options for unroll transformations.\n * @typedef {object} UnrollOptions\n * @property {number} [limit=Infinity] The maximum number of new rows\n * to generate per array value.\n * @property {boolean|string} [index=false] Flag or column name for adding\n * zero-based array index values as an output column. If true, a new column\n * named \"index\" will be included. If string-valued, a new column with\n * the given name will be added.\n * @property {Select} [drop] Columns to drop from the output. The input may\n * consist of column name strings, column integer indices, objects with\n * column names as keys, or functions that take a table as input and\n * return a valid selection parameter (typically the output of selection\n * helper functions such as {@link all}, {@link not}, or {@link range}).\n */\n\n/**\n * Options for join transformations.\n * @typedef {object} JoinOptions\n * @property {boolean} [left=false] Flag indicating a left outer join.\n * If both the *left* and *right* are true, indicates a full outer join.\n * @property {boolean} [right=false] Flag indicating a right outer join.\n * If both the *left* and *right* are true, indicates a full outer join.\n * @property {string[]} [suffix=['_1', '_2']] Column name suffixes to\n * append if two columns with the same name are produced by the join.\n */","export default function(message) {\n throw Error(message);\n}","export default function(value) {\n return typeof value === 'number';\n}","export default function(value) {\n return typeof value === 'function';\n}","import isFunction from './is-function';\n\nexport default function(reps, value) {\n const result = Array(reps);\n if (isFunction(value)) {\n for (let i = 0; i < reps; ++i) {\n result[i] = value(i);\n }\n } else {\n result.fill(value);\n }\n return result;\n}","import Transformable from './transformable';\nimport error from '../util/error';\nimport isNumber from '../util/is-number';\nimport repeat from '../util/repeat';\n\n/**\n * Abstract class representing a data table.\n */\nexport default class Table extends Transformable {\n\n /**\n * Instantiate a new Table instance.\n * @param {string[]} names An ordered list of column names.\n * @param {number} nrows The number of rows.\n * @param {TableData} data The backing data, which can vary by implementation.\n * @param {BitSet} [filter] A bit mask for which rows to include.\n * @param {GroupBySpec} [groups] A groupby specification for grouping ows.\n * @param {RowComparator} [order] A comparator function for sorting rows.\n * @param {Params} [params] Parameter values for table expressions.\n */\n constructor(names, nrows, data, filter, groups, order, params) {\n super(params);\n this._names = Object.freeze(names);\n this._data = data;\n this._total = nrows;\n this._nrows = filter ? filter.count() : nrows;\n this._mask = (nrows !== this._nrows && filter) || null;\n this._group = groups || null;\n this._order = order || null;\n }\n\n /**\n * Create a new table with the same type as this table.\n * The new table may have different data, filter, grouping, or ordering\n * based on the values of the optional configuration argument. If a\n * setting is not specified, it is inherited from the current table.\n * @param {CreateOptions} [options] Creation options for the new table.\n * @return {this} A newly created table.\n */\n create(options) { // eslint-disable-line no-unused-vars\n error('Not implemented');\n }\n\n /**\n * Provide an informative object string tag.\n */\n get [Symbol.toStringTag]() {\n if (!this._names) return 'Object'; // bail if called on prototype\n const nr = this.numRows() + ' row' + (this.numRows() !== 1 ? 's' : '');\n const nc = this.numCols() + ' col' + (this.numCols() !== 1 ? 's' : '');\n return `Table: ${nc} x ${nr}`\n + (this.isFiltered() ? ` (${this.totalRows()} backing)` : '')\n + (this.isGrouped() ? `, ${this._group.size} groups` : '')\n + (this.isOrdered() ? ', ordered' : '');\n }\n\n /**\n * Indicates if the table has a filter applied.\n * @return {boolean} True if filtered, false otherwise.\n */\n isFiltered() {\n return !!this._mask;\n }\n\n /**\n * Indicates if the table has a groupby specification.\n * @return {boolean} True if grouped, false otherwise.\n */\n isGrouped() {\n return !!this._group;\n }\n\n /**\n * Indicates if the table has a row order comparator.\n * @return {boolean} True if ordered, false otherwise.\n */\n isOrdered() {\n return !!this._order;\n }\n\n /**\n * Returns the internal table storage data structure.\n * @return {TableData} The backing table storage data structure.\n */\n data() {\n return this._data;\n }\n\n /**\n * Returns the filter bitset mask, if defined.\n * @return {BitSet} The filter bitset mask.\n */\n mask() {\n return this._mask;\n }\n\n /**\n * Returns the groupby specification, if defined.\n * @return {GroupBySpec} The groupby specification.\n */\n groups() {\n return this._group;\n }\n\n /**\n * Returns the row order comparator function, if specified.\n * @return {RowComparator} The row order comparator function.\n */\n comparator() {\n return this._order;\n }\n\n /**\n * The total number of rows in this table, counting both\n * filtered and unfiltered rows.\n * @return {number} The number of total rows.\n */\n totalRows() {\n return this._total;\n }\n\n /**\n * The number of active rows in this table. This number may be\n * less than the total rows if the table has been filtered.\n * @see Table.totalRows\n * @return {number} The number of rows.\n */\n numRows() {\n return this._nrows;\n }\n\n /**\n * The number of active rows in this table. This number may be\n * less than the total rows if the table has been filtered.\n * @see Table.totalRows\n * @return {number} The number of rows.\n */\n get size() {\n return this._nrows;\n }\n\n /**\n * The number of columns in this table.\n * @return {number} The number of columns.\n */\n numCols() {\n return this._names.length;\n }\n\n /**\n * Filter function invoked for each column name.\n * @callback NameFilter\n * @param {string} name The column name.\n * @param {number} index The column index.\n * @param {string[]} array The array of names.\n * @return {boolean} Returns true to retain the column name.\n */\n\n /**\n * The table column names, optionally filtered.\n * @param {NameFilter} [filter] An optional filter function.\n * If unspecified, all column names are returned.\n * @return {string[]} An array of matching column names.\n */\n columnNames(filter) {\n return filter ? this._names.filter(filter) : this._names.slice();\n }\n\n /**\n * The column name at the given index.\n * @param {number} index The column index.\n * @return {string} The column name,\n * or undefined if the index is out of range.\n */\n columnName(index) {\n return this._names[index];\n }\n\n /**\n * The column index for the given name.\n * @param {string} name The column name.\n * @return {number} The column index, or -1 if the name is not found.\n */\n columnIndex(name) {\n return this._names.indexOf(name);\n }\n\n /**\n * Deprecated alias for the table array() method: use table.array()\n * instead. Get an array of values contained in a column. The resulting\n * array respects any table filter or orderby criteria.\n * @param {string} name The column name.\n * @param {ArrayConstructor|TypedArrayConstructor} [constructor=Array]\n * The array constructor for instantiating the output array.\n * @return {DataValue[]|TypedArray} The array of column values.\n */\n columnArray(name, constructor) {\n return this.array(name, constructor);\n }\n\n /**\n * Get an array of values contained in a column. The resulting array\n * respects any table filter or orderby criteria.\n * @param {string} name The column name.\n * @param {ArrayConstructor|TypedArrayConstructor} [constructor=Array]\n * The array constructor for instantiating the output array.\n * @return {DataValue[]|TypedArray} The array of column values.\n */\n array(name, constructor) { // eslint-disable-line no-unused-vars\n error('Not implemented');\n }\n\n /**\n * Returns an iterator over column values.\n * @return {Iterator} An iterator over row objects.\n */\n *values(name) {\n const get = this.getter(name);\n const n = this.numRows();\n for (let i = 0; i < n; ++i) {\n yield get(i);\n }\n }\n\n /**\n * Get the value for the given column and row.\n * @param {string} name The column name.\n * @param {number} [row=0] The row index, defaults to zero if not specified.\n * @return {DataValue} The data value at (column, row).\n */\n get(name, row = 0) { // eslint-disable-line no-unused-vars\n error('Not implemented');\n }\n\n /**\n * Returns an accessor (\"getter\") function for a column. The returned\n * function takes a row index as its single argument and returns the\n * corresponding column value.\n * @param {string} name The column name.\n * @return {ColumnGetter} The column getter function.\n */\n getter(name) { // eslint-disable-line no-unused-vars\n error('Not implemented');\n }\n\n /**\n * Returns an array of objects representing table rows.\n * @param {ObjectsOptions} [options] The options for row object generation.\n * @return {RowObject[]} An array of row objects.\n */\n objects(options) { // eslint-disable-line no-unused-vars\n error('Not implemented');\n }\n\n /**\n * Returns an object representing a table row.\n * @param {number} [row=0] The row index, defaults to zero if not specified.\n * @return {object} A row object with named properties for each column.\n */\n object(row) { // eslint-disable-line no-unused-vars\n error('Not implemented');\n }\n\n /**\n * Returns an iterator over objects representing table rows.\n * @return {Iterator} An iterator over row objects.\n */\n [Symbol.iterator]() {\n error('Not implemented');\n }\n\n /**\n * Print the contents of this table using the console.table() method.\n * @param {PrintOptions|number} options The options for row object\n * generation, determining which rows and columns are printed. If\n * number-valued, specifies the row limit.\n * @return {this} The table instance.\n */\n print(options = {}) {\n if (isNumber(options)) {\n options = { limit: options };\n } else if (options.limit == null) {\n options.limit = 10;\n }\n\n const obj = this.objects({ ...options, grouped: false });\n const msg = `${this[Symbol.toStringTag]}. Showing ${obj.length} rows.`;\n\n console.log(msg); // eslint-disable-line no-console\n console.table(obj); // eslint-disable-line no-console\n return this;\n }\n\n /**\n * Returns an array of indices for all rows passing the table filter.\n * @param {boolean} [order=true] A flag indicating if the returned\n * indices should be sorted if this table is ordered. If false, the\n * returned indices may or may not be sorted.\n * @return {Uint32Array} An array of row indices.\n */\n indices(order = true) {\n if (this._index) return this._index;\n\n const n = this.numRows();\n const index = new Uint32Array(n);\n const ordered = this.isOrdered();\n const bits = this.mask();\n let row = -1;\n\n // inline the following for performance:\n // this.scan(row => index[++i] = row);\n if (bits) {\n for (let i = bits.next(0); i >= 0; i = bits.next(i + 1)) {\n index[++row] = i;\n }\n } else {\n for (let i = 0; i < n; ++i) {\n index[++row] = i;\n }\n }\n\n // sort index vector\n if (order && ordered) {\n const compare = this._order;\n const data = this._data;\n index.sort((a, b) => compare(a, b, data));\n }\n\n // save indices if they reflect table metadata\n if (order || !ordered) {\n this._index = index;\n }\n\n return index;\n }\n\n /**\n * Returns an array of indices for each group in the table.\n * If the table is not grouped, the result is the same as\n * {@link indices}, but wrapped within an array.\n * @param {boolean} [order=true] A flag indicating if the returned\n * indices should be sorted if this table is ordered. If false, the\n * returned indices may or may not be sorted.\n * @return {number[][]} An array of row index arrays, one per group.\n * The indices will be filtered if the table is filtered.\n */\n partitions(order = true) {\n // return partitions if already generated\n if (this._partitions) {\n return this._partitions;\n }\n\n // if not grouped, return a single partition\n if (!this.isGrouped()) {\n return [ this.indices(order) ];\n }\n\n // generate partitions\n const { keys, size } = this._group;\n const part = repeat(size, () => []);\n\n // populate partitions, don't sort if indices don't exist\n // inline the following for performance:\n // this.scan(row => part[keys[row]].push(row), sort);\n const sort = this._index;\n const bits = this.mask();\n const n = this.numRows();\n if (sort && this.isOrdered()) {\n for (let i = 0, r; i < n; ++i) {\n r = sort[i];\n part[keys[r]].push(r);\n }\n } else if (bits) {\n for (let i = bits.next(0); i >= 0; i = bits.next(i + 1)) {\n part[keys[i]].push(i);\n }\n } else {\n for (let i = 0; i < n; ++i) {\n part[keys[i]].push(i);\n }\n }\n\n // if ordered but not yet sorted, sort partitions directly\n if (order && !sort && this.isOrdered()) {\n const compare = this._order;\n const data = this._data;\n for (let i = 0; i < size; ++i) {\n part[i].sort((a, b) => compare(a, b, data));\n }\n }\n\n // save partitions if they reflect table metadata\n if (order || !this.isOrdered()) {\n this._partitions = part;\n }\n\n return part;\n }\n\n /**\n * Callback function to cancel a table scan.\n * @callback ScanStop\n * @return {void}\n */\n\n /**\n * Callback function invoked for each row of a table scan.\n * @callback ScanVisitor\n * @param {number} [row] The table row index.\n * @param {TableData} [data] The backing table data store.\n * @param {ScanStop} [stop] Function to stop the scan early.\n * Callees can invoke this function to prevent future calls.\n * @return {void}\n */\n\n /**\n * Perform a table scan, visiting each row of the table.\n * If this table is filtered, only rows passing the filter are visited.\n * @param {ScanVisitor} fn Callback invoked for each row of the table.\n * @param {boolean} [order=false] Indicates if the table should be\n * scanned in the order determined by {@link Table#orderby}. This\n * argument has no effect if the table is unordered.\n * @property {number} [limit=Infinity] The maximum number of objects to create.\n * @property {number} [offset=0] The row offset indicating how many initial rows to skip.\n */\n scan(fn, order, limit = Infinity, offset = 0) {\n const filter = this._mask;\n const nrows = this._nrows;\n const data = this._data;\n\n let i = offset || 0;\n if (i > nrows) return;\n\n const n = Math.min(nrows, i + limit);\n const stop = () => i = this._total;\n\n if (order && this.isOrdered() || filter && this._index) {\n const index = this.indices();\n const data = this._data;\n for (; i < n; ++i) {\n fn(index[i], data, stop);\n }\n } else if (filter) {\n let c = n - i + 1;\n for (i = filter.nth(i); --c && i > -1; i = filter.next(i + 1)) {\n fn(i, data, stop);\n }\n } else {\n for (; i < n; ++i) {\n fn(i, data, stop);\n }\n }\n }\n\n /**\n * Extract rows with indices from start to end (end not included), where\n * start and end represent per-group ordered row numbers in the table.\n * @param {number} [start] Zero-based index at which to start extraction.\n * A negative index indicates an offset from the end of the group.\n * If start is undefined, slice starts from the index 0.\n * @param {number} [end] Zero-based index before which to end extraction.\n * A negative index indicates an offset from the end of the group.\n * If end is omitted, slice extracts through the end of the group.\n * @return {this} A new table with sliced rows.\n * @example table.slice(1, -1)\n */\n slice(start = 0, end = Infinity) {\n if (this.isGrouped()) return super.slice(start, end);\n\n // if not grouped, scan table directly\n const indices = [];\n const nrows = this.numRows();\n start = Math.max(0, start + (start < 0 ? nrows : 0));\n end = Math.min(nrows, Math.max(0, end + (end < 0 ? nrows : 0)));\n this.scan(row => indices.push(row), true, end - start, start);\n return this.reify(indices);\n }\n\n /**\n * Reduce a table, processing all rows to produce a new table.\n * To produce standard aggregate summaries, use {@link rollup}.\n * This method allows the use of custom reducer implementations,\n * for example to produce multiple rows for an aggregate.\n * @param {Reducer} reducer The reducer to apply.\n * @return {Table} A new table of reducer outputs.\n */\n reduce(reducer) {\n return this.__reduce(this, reducer);\n }\n}\n\n/**\n * A typed array constructor.\n * @typedef {Uint8ArrayConstructor|Uint16ArrayConstructor|Uint32ArrayConstructor|BigUint64ArrayConstructor|Int8ArrayConstructor|Int16ArrayConstructor|Int32ArrayConstructor|BigInt64ArrayConstructor|Float32ArrayConstructor|Float64ArrayConstructor} TypedArrayConstructor\n */\n\n/**\n * A typed array instance.\n * @typedef {Uint8Array|Uint16Array|Uint32Array|BigUint64Array|Int8Array|Int16Array|Int32Array|BigInt64Array|Float32Array|Float64Array} TypedArray\n */\n\n/**\n * Backing table data.\n * @typedef {object|Array} TableData\n */\n\n/**\n * Table value.\n * @typedef {*} DataValue\n */\n\n/**\n * Table row object.\n * @typedef {Object.} RowObject\n */\n\n/**\n * Table expression parameters.\n * @typedef {import('./transformable').Params} Params\n */\n\n/**\n * Proxy type for BitSet class.\n * @typedef {import('./bit-set').default} BitSet\n */\n\n/**\n * A table groupby specification.\n * @typedef {object} GroupBySpec\n * @property {number} size The number of groups.\n * @property {string[]} names Column names for each group.\n * @property {RowExpression[]} get Value accessor functions for each group.\n * @property {number[]} rows Indices of an example table row for each group.\n * @property {number[]} keys Per-row group indices, length is total rows of table.\n */\n\n/**\n * Column value accessor.\n * @callback ColumnGetter\n * @param {number} [row] The table row.\n * @return {DataValue}\n */\n\n/**\n * An expression evaluated over a table row.\n * @callback RowExpression\n * @param {number} [row] The table row.\n * @param {TableData} [data] The backing table data store.\n * @return {DataValue}\n */\n\n/**\n * Comparator function for sorting table rows.\n * @callback RowComparator\n * @param {number} rowA The table row index for the first row.\n * @param {number} rowB The table row index for the second row.\n * @param {TableData} data The backing table data store.\n * @return {number} Negative if rowA < rowB, positive if\n * rowA > rowB, otherwise zero.\n */\n\n/**\n * Options for derived table creation.\n * @typedef {object} CreateOptions\n * @property {TableData} [data] The backing column data.\n * @property {string[]} [names] An ordered list of column names.\n * @property {BitSet} [filter] An additional filter BitSet to apply.\n * @property {GroupBySpec} [groups] The groupby specification to use, or null for no groups.\n * @property {RowComparator} [order] The orderby comparator function to use, or null for no order.\n */\n\n/**\n * Options for generating row objects.\n * @typedef {object} PrintOptions\n * @property {number} [limit=Infinity] The maximum number of objects to create.\n * @property {number} [offset=0] The row offset indicating how many initial rows to skip.\n * @property {import('../table/transformable').Select} [columns]\n * An ordered set of columns to include. The input may consist of column name\n * strings, column integer indices, objects with current column names as keys\n * and new column names as values (for renaming), or selection helper\n * functions such as {@link all}, {@link not}, or {@link range}.\n */\n\n/**\n * Options for generating row objects.\n * @typedef {object} ObjectsOptions\n * @property {number} [limit=Infinity] The maximum number of objects to create.\n * @property {number} [offset=0] The row offset indicating how many initial rows to skip.\n * @property {import('../table/transformable').Select} [columns]\n * An ordered set of columns to include. The input may consist of column name\n * strings, column integer indices, objects with current column names as keys\n * and new column names as values (for renaming), or selection helper\n * functions such as {@link all}, {@link not}, or {@link range}.\n * @property {'map'|'entries'|'object'|boolean} [grouped=false]\n * The export format for groups of rows. The default (false) is to ignore\n * groups, returning a flat array of objects. The valid values are 'map' or\n * true (for Map instances), 'object' (for standard objects), or 'entries'\n * (for arrays in the style of Object.entries). For the 'object' format,\n * groupby keys are coerced to strings to use as object property names; note\n * that this can lead to undesirable behavior if the groupby keys are object\n * values. The 'map' and 'entries' options preserve the groupby key values.\n */\n","import isFunction from '../util/is-function';\n\n/**\n * Class representing an array-backed data column.\n */\nexport default class Column {\n /**\n * Create a new column instance.\n * @param {Array} data The backing array (or array-like object)\n * containing the column data.\n */\n constructor(data) {\n this.data = data;\n }\n\n /**\n * Get the length (number of rows) of the column.\n * @return {number} The length of the column array.\n */\n get length() {\n return this.data.length;\n }\n\n /**\n * Get the column value at the given row index.\n * @param {number} row The row index of the value to retrieve.\n * @return {import('./table').DataValue} The column value.\n */\n get(row) {\n return this.data[row];\n }\n\n /**\n * Returns an iterator over the column values.\n * @return {Iterator} An iterator over column values.\n */\n [Symbol.iterator]() {\n return this.data[Symbol.iterator]();\n }\n}\n\n/**\n * Column interface. Any object that adheres to this interface\n * can be used as a data column within a {@link ColumnTable}.\n * @typedef {object} ColumnType\n * @property {number} length\n * The length (number of rows) of the column.\n * @property {import('./table').ColumnGetter} get\n * Column value getter.\n */\n\n/**\n * Column factory function interface.\n * @callback ColumnFactory\n * @param {*} data The input column data.\n * @return {ColumnType} A column instance.\n */\n\n/**\n * Create a new column from the given input data.\n * @param {any} data The backing column data. If the value conforms to\n * the Column interface it is returned directly. If the value is an\n * array, it will be wrapped in a new Column instance.\n * @return {ColumnType} A compatible column instance.\n */\nexport let defaultColumnFactory = function(data) {\n return data && isFunction(data.get) ? data : new Column(data);\n};\n\n/**\n * Get or set the default factory function for instantiating table columns.\n * @param {ColumnFactory} [factory] The new default factory.\n * @return {ColumnFactory} The current default column factory.\n */\nexport function columnFactory(factory) {\n return arguments.length\n ? (defaultColumnFactory = factory)\n : defaultColumnFactory;\n}","export default function(value) {\n return value instanceof Date;\n}","export default function(value) {\n return value === Object(value);\n}","export default function(value) {\n return value instanceof RegExp;\n}","export default function(value) {\n return typeof value === 'string';\n}\n","import error from '../util/error';\nimport isArray from '../util/is-array';\nimport isDate from '../util/is-date';\nimport isFunction from '../util/is-function';\nimport isObject from '../util/is-object';\nimport isRegExp from '../util/is-regexp';\nimport isString from '../util/is-string';\n\nexport default function(values, names) {\n const raise = type => error(`Illegal argument type: ${type || typeof values}`);\n return values instanceof Map ? fromKeyValuePairs(values.entries(), names)\n : isDate(values) ? raise('Date')\n : isRegExp(values) ? raise('RegExp')\n : isString(values) ? raise()\n : isArray(values) ? fromArray(values, names)\n : isFunction(values[Symbol.iterator]) ? fromIterable(values, names)\n : isObject(values) ? fromKeyValuePairs(Object.entries(values), names)\n : raise();\n}\n\nfunction fromKeyValuePairs(entries, names = ['key', 'value']) {\n const keys = [];\n const vals = [];\n\n for (const [key, val] of entries) {\n keys.push(key);\n vals.push(val);\n }\n\n const columns = {};\n if (names[0]) columns[names[0]] = keys;\n if (names[1]) columns[names[1]] = vals;\n return columns;\n}\n\nfunction fromArray(values, names) {\n const len = values.length;\n const columns = {};\n const add = name => columns[name] = Array(len);\n\n if (len) {\n names = names || Object.keys(values[0]);\n const cols = names.map(add);\n const n = cols.length;\n for (let idx = 0; idx < len; ++idx) {\n const row = values[idx];\n for (let i = 0; i < n; ++i) {\n cols[i][idx] = row[names[i]];\n }\n }\n } else if (names) {\n names.forEach(add);\n }\n\n return columns;\n}\n\nfunction fromIterable(values, names) {\n const columns = {};\n const add = name => columns[name] = [];\n\n let cols;\n let n;\n for (const row of values) {\n if (!cols) {\n names = names || Object.keys(row);\n cols = names.map(add);\n n = cols.length;\n }\n for (let i = 0; i < n; ++i) {\n cols[i].push(row[names[i]]);\n }\n }\n\n if (!cols && names) {\n names.forEach(add);\n }\n\n return columns;\n}","const { hasOwnProperty } = Object.prototype;\n\nexport default function(object, property) {\n return hasOwnProperty.call(object, property);\n}","import has from '../util/has';\n\nexport default function(table) {\n return table\n ? new ColumnSet({ ...table.data() }, table.columnNames())\n : new ColumnSet();\n}\n\nclass ColumnSet {\n constructor(data, names) {\n this.data = data || {};\n this.names = names || [];\n }\n\n add(name, values) {\n if (!this.has(name)) this.names.push(name + '');\n return this.data[name] = values;\n }\n\n has(name) {\n return has(this.data, name);\n }\n\n new() {\n this.filter = null;\n this.groups = this.groups || null;\n this.order = null;\n return this;\n }\n\n groupby(groups) {\n this.groups = groups;\n return this;\n }\n}","/**\n * Default NULL (missing) value to use.\n */\nexport default undefined;","const TypedArray = Object.getPrototypeOf(Int8Array);\n\nexport default function(value) {\n return value instanceof TypedArray;\n}","import isArray from './is-array';\nimport isTypedArray from './is-typed-array';\n\nexport default function isArrayType(value) {\n return isArray(value) || isTypedArray(value);\n}","export default function(value) {\n return value != null && value === value;\n}\n","import NULL from '../../util/null';\nimport isArrayType from '../../util/is-array-type';\nimport isString from '../../util/is-string';\nimport isValid from '../../util/is-valid';\n\nconst isSeq = (seq) => isArrayType(seq) || isString(seq);\n\nexport default {\n compact: (arr) => isArrayType(arr) ? arr.filter(v => isValid(v)) : arr,\n concat: (...values) => [].concat(...values),\n includes: (seq, value, index) => isSeq(seq)\n ? seq.includes(value, index)\n : false,\n indexof: (seq, value) => isSeq(seq) ? seq.indexOf(value) : -1,\n join: (arr, delim) => isArrayType(arr) ? arr.join(delim) : NULL,\n lastindexof: (seq, value) => isSeq(seq) ? seq.lastIndexOf(value) : -1,\n length: (seq) => isSeq(seq) ? seq.length : 0,\n pluck: (arr, prop) => isArrayType(arr)\n ? arr.map(v => isValid(v) ? v[prop] : NULL)\n : NULL,\n reverse: (seq) => isArrayType(seq) ? seq.slice().reverse()\n : isString(seq) ? seq.split('').reverse().join('')\n : NULL,\n slice: (seq, start, end) => isSeq(seq) ? seq.slice(start, end) : NULL\n};\n","export default function(value, width, char = '0') {\n const s = value + '';\n const len = s.length;\n return len < width ? Array(width - len + 1).join(char) + s : s;\n}","import pad from './pad';\n\nconst pad2 = v => (v < 10 ? '0' : '') + v;\n\nconst formatYear = year => year < 0 ? '-' + pad(-year, 6)\n : year > 9999 ? '+' + pad(year, 6)\n : pad(year, 4);\n\nexport function formatISO(year, month, date, hours, min, sec, ms, utc, short) {\n const suffix = utc ? 'Z' : '';\n return formatYear(year) + '-' + pad2(month + 1) + '-' + pad2(date) + (\n !short || ms ? 'T' + pad2(hours) + ':' + pad2(min) + ':' + pad2(sec) + '.' + pad(ms, 3) + suffix\n : sec ? 'T' + pad2(hours) + ':' + pad2(min) + ':' + pad2(sec) + suffix\n : min || hours || !utc ? 'T' + pad2(hours) + ':' + pad2(min) + suffix\n : ''\n );\n}\n\nexport function formatDate(d, short) {\n return isNaN(d)\n ? 'Invalid Date'\n : formatISO(\n d.getFullYear(),\n d.getMonth(),\n d.getDate(),\n d.getHours(),\n d.getMinutes(),\n d.getSeconds(),\n d.getMilliseconds(),\n false, short\n );\n}\n\nexport function formatUTCDate(d, short) {\n return isNaN(d)\n ? 'Invalid Date'\n : formatISO(\n d.getUTCFullYear(),\n d.getUTCMonth(),\n d.getUTCDate(),\n d.getUTCHours(),\n d.getUTCMinutes(),\n d.getUTCSeconds(),\n d.getUTCMilliseconds(),\n true, short\n );\n}","const iso_re = /^([-+]\\d{2})?\\d{4}(-\\d{2}(-\\d{2})?)?(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{3})?)?(Z|[-+]\\d{2}:\\d{2})?)?$/;\n\nexport default function(value) {\n return value.match(iso_re);\n}","import { formatDate, formatUTCDate } from '../../util/format-date';\nimport parseIsoDate from '../../util/parse-iso-date';\n\nconst msMinute = 6e4;\nconst msDay = 864e5;\nconst msWeek = 6048e5;\n\nconst t0 = new Date();\nconst t1 = new Date();\nconst t = d => (\n t0.setTime(typeof d === 'string' ? parseIsoDate(d) : d),\n t0\n);\n\n/**\n * Function to create a new Date value.\n * If no arguments are provided, the current time is used.\n * @param {number} [year] The year.\n * @param {number} [month=0] The (zero-based) month.\n * @param {number} [date=1] The date within the month.\n * @param {number} [hours=0] The hour within the day.\n * @param {number} [minutes=0] The minute within the hour.\n * @param {number} [seconds=0] The second within the minute.\n * @param {number} [milliseconds=0] The milliseconds within the second.\n * @return {date} The resuting Date value.\n */\nfunction datetime(year, month, date, hours, minutes, seconds, milliseconds) {\n return !arguments.length\n ? new Date(Date.now())\n : new Date(\n year,\n month || 0,\n date == null ? 1 : date,\n hours || 0,\n minutes || 0,\n seconds || 0,\n milliseconds || 0\n );\n}\n\n/**\n * Function to create a new Date value according to UTC time.\n * If no arguments are provided, the current time is used.\n * @param {number} [year] The year.\n * @param {number} [month=0] The (zero-based) month.\n * @param {number} [date=1] The date within the month.\n * @param {number} [hours=0] The hour within the day.\n * @param {number} [minutes=0] The minute within the hour.\n * @param {number} [seconds=0] The second within the minute.\n * @param {number} [milliseconds=0] The milliseconds within the second.\n * @return {date} The resuting Date value.\n */\nfunction utcdatetime(year, month, date, hours, minutes, seconds, milliseconds) {\n return !arguments.length\n ? new Date(Date.now())\n : new Date(Date.UTC(\n year,\n month || 0,\n date == null ? 1 : date,\n hours || 0,\n minutes || 0,\n seconds || 0,\n milliseconds || 0\n ));\n}\n\nfunction dayofyear(date) {\n t1.setTime(+date);\n t1.setHours(0, 0, 0, 0);\n t0.setTime(+t1);\n t0.setMonth(0);\n t0.setDate(1);\n const tz = (t1.getTimezoneOffset() - t0.getTimezoneOffset()) * msMinute;\n return Math.floor(1 + ((t1 - t0) - tz) / msDay);\n}\n\nfunction utcdayofyear(date) {\n t1.setTime(+date);\n t1.setUTCHours(0, 0, 0, 0);\n const t0 = Date.UTC(t1.getUTCFullYear(), 0, 1);\n return Math.floor(1 + (t1 - t0) / msDay);\n}\n\nfunction week(date, firstday) {\n const i = firstday || 0;\n t1.setTime(+date);\n t1.setDate(t1.getDate() - (t1.getDay() + 7 - i) % 7);\n t1.setHours(0, 0, 0, 0);\n t0.setTime(+date);\n t0.setMonth(0);\n t0.setDate(1);\n t0.setDate(1 - (t0.getDay() + 7 - i) % 7);\n t0.setHours(0, 0, 0, 0);\n const tz = (t1.getTimezoneOffset() - t0.getTimezoneOffset()) * msMinute;\n return Math.floor((1 + (t1 - t0) - tz) / msWeek);\n}\n\nfunction utcweek(date, firstday) {\n const i = firstday || 0;\n t1.setTime(+date);\n t1.setUTCDate(t1.getUTCDate() - (t1.getUTCDay() + 7 - i) % 7);\n t1.setUTCHours(0, 0, 0, 0);\n t0.setTime(+date);\n t0.setUTCMonth(0);\n t0.setUTCDate(1);\n t0.setUTCDate(1 - (t0.getUTCDay() + 7 - i) % 7);\n t0.setUTCHours(0, 0, 0, 0);\n return Math.floor((1 + (t1 - t0)) / msWeek);\n}\n\nexport default {\n format_date: (date, shorten) => formatDate(t(date), !shorten),\n format_utcdate: (date, shorten) => formatUTCDate(t(date), !shorten),\n timestamp: (date) => +t(date),\n year: (date) => t(date).getFullYear(),\n quarter: (date) => Math.floor(t(date).getMonth() / 3),\n month: (date) => t(date).getMonth(),\n date: (date) => t(date).getDate(),\n dayofweek: (date) => t(date).getDay(),\n hours: (date) => t(date).getHours(),\n minutes: (date) => t(date).getMinutes(),\n seconds: (date) => t(date).getSeconds(),\n milliseconds: (date) => t(date).getMilliseconds(),\n utcyear: (date) => t(date).getUTCFullYear(),\n utcquarter: (date) => Math.floor(t(date).getUTCMonth() / 3),\n utcmonth: (date) => t(date).getUTCMonth(),\n utcdate: (date) => t(date).getUTCDate(),\n utcdayofweek: (date) => t(date).getUTCDay(),\n utchours: (date) => t(date).getUTCHours(),\n utcminutes: (date) => t(date).getUTCMinutes(),\n utcseconds: (date) => t(date).getUTCSeconds(),\n utcmilliseconds: (date) => t(date).getUTCMilliseconds(),\n datetime,\n dayofyear,\n week,\n utcdatetime,\n utcdayofyear,\n utcweek,\n now: Date.now\n};","import isISODateString from './is-iso-date-string';\n\nexport default function(value, parse = Date.parse) {\n return isISODateString(value) ? parse(value) : value;\n}","import isDate from '../../util/is-date';\nimport isRegExp from '../../util/is-regexp';\nimport isObject from '../../util/is-object';\n\n/**\n * Compare two values for equality, using join semantics in which null\n * !== null. If the inputs are object-valued, a deep equality check\n * of array entries or object key-value pairs is performed.\n * @param {*} a The first input.\n * @param {*} b The second input.\n * @return {boolean} True if equal, false if not.\n */\nexport default function equal(a, b) {\n return (a == null || b == null || a !== a || b !== b) ? false\n : a === b ? true\n : (isDate(a) || isDate(b)) ? +a === +b\n : (isRegExp(a) && isRegExp(b)) ? a + '' === b + ''\n : (isObject(a) && isObject(b)) ? deepEqual(a, b)\n : false;\n}\n\nfunction deepEqual(a, b) {\n if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) {\n return false;\n }\n\n if (a.length || b.length) {\n return arrayEqual(a, b);\n }\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) {\n return false;\n }\n keysA.sort();\n keysB.sort();\n\n if (!arrayEqual(keysA, keysB, (a, b) => a === b)) {\n return false;\n }\n\n const n = keysA.length;\n for (let i = 0; i < n; ++i) {\n const k = keysA[i];\n if (!equal(a[k], b[k])) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction arrayEqual(a, b, test = equal) {\n const n = a.length;\n if (n !== b.length) return false;\n\n for (let i = 0; i < n; ++i) {\n if (!test(a[i], b[i])) {\n return false;\n }\n }\n\n return true;\n}","export default {\n parse_json: (str) => JSON.parse(str),\n to_json: (val) => JSON.stringify(val)\n};","import isValid from './is-valid';\n\nlet source = Math.random;\n\nexport function random() {\n return source();\n}\n\n/**\n * Set a seed value for random number generation.\n * If the seed is a valid number, a 32-bit linear congruential generator\n * with the given seed will be used to generate random values.\n * If the seed is null, undefined, or not a valid number, the random\n * number generator will revert to Math.random.\n * @param {number} seed The random seed value. Should either be an\n * integer or a fraction between 0 and 1.\n */\nexport function seed(seed) {\n source = isValid(seed) && isFinite(seed = +seed) ? lcg(seed) : Math.random;\n}\n\nfunction lcg(seed) {\n const a = 0x19660D;\n const c = 0x3C6EF35F;\n const m = 1 / 0x100000000;\n seed = (0 <= seed && seed < 1 ? seed / m : Math.abs(seed)) | 0;\n\n // Random numbers using a Linear Congruential Generator with seed value\n // https://en.wikipedia.org/wiki/Linear_congruential_generator\n return () => (seed = a * seed + c | 0, m * (seed >>> 0));\n}","export default function(value) {\n return value instanceof Map;\n}","import isMap from './is-map';\nimport isSet from './is-set';\n\nexport default function(value) {\n return isMap(value) || isSet(value);\n}","export default function(value) {\n return value instanceof Set;\n}","import NULL from '../../util/null';\nimport has from '../../util/has';\nimport isMap from '../../util/is-map';\nimport isMapOrSet from '../../util/is-map-or-set';\n\nfunction array(iter) {\n return Array.from(iter);\n}\n\nexport default {\n has: (obj, key) => isMapOrSet(obj) ? obj.has(key)\n : obj != null ? has(obj, key)\n : false,\n keys: (obj) => isMap(obj) ? array(obj.keys())\n : obj != null ? Object.keys(obj)\n : [],\n values: (obj) => isMapOrSet(obj) ? array(obj.values())\n : obj != null ? Object.values(obj)\n : [],\n entries: (obj) => isMapOrSet(obj) ? array(obj.entries())\n : obj != null ? Object.entries(obj)\n : [],\n object: (entries) => entries ? Object.fromEntries(entries) : NULL\n};","export default {\n parse_date: (str) => str == null ? str : new Date(str),\n parse_float: (str) => str == null ? str : Number.parseFloat(str),\n parse_int: (str, radix) => str == null ? str : Number.parseInt(str, radix),\n endswith: (str, search, length) => str == null ? false\n : String(str).endsWith(search, length),\n match: (str, regexp, index) => {\n const m = str == null ? str : String(str).match(regexp);\n return index == null || m == null ? m\n : typeof index === 'number' ? m[index]\n : m.groups ? m.groups[index]\n : null;\n },\n normalize: (str, form) => str == null ? str\n : String(str).normalize(form),\n padend: (str, len, fill) => str == null ? str\n : String(str).padEnd(len, fill),\n padstart: (str, len, fill) => str == null ? str\n : String(str).padStart(len, fill),\n upper: (str) => str == null ? str\n : String(str).toUpperCase(),\n lower: (str) => str == null ? str\n : String(str).toLowerCase(),\n repeat: (str, num) => str == null ? str\n : String(str).repeat(num),\n replace: (str, pattern, replacement) => str == null ? str\n : String(str).replace(pattern, String(replacement)),\n substring: (str, start, end) => str == null ? str\n : String(str).substring(start, end),\n split: (str, separator, limit) => str == null ? []\n : String(str).split(separator, limit),\n startswith: (str, search, length) => str == null ? false\n : String(str).startsWith(search, length),\n trim: (str) => str == null ? str\n : String(str).trim()\n};","import array from './array';\nimport bin from './bin';\nimport date from './date';\nimport equal from './equal';\nimport json from './json';\nimport math from './math';\nimport object from './object';\nimport recode from './recode';\nimport sequence from './sequence';\nimport string from './string';\n\nexport default {\n bin,\n equal,\n recode,\n sequence,\n ...array,\n ...date,\n ...json,\n ...math,\n ...object,\n ...string\n};","/**\n * Truncate a value to a bin boundary.\n * Useful for creating equal-width histograms.\n * Values outside the [min, max] range will be mapped to\n * -Infinity (< min) or +Infinity (> max).\n * @param {number} value - The value to bin.\n * @param {number} min - The minimum bin boundary.\n * @param {number} max - The maximum bin boundary.\n * @param {number} step - The step size between bin boundaries.\n * @param {number} [offset=0] - Offset in steps by which to adjust\n * the bin value. An offset of 1 will return the next boundary.\n */\nexport default function(value, min, max, step, offset) {\n return value == null ? null\n : value < min ? -Infinity\n : value > max ? +Infinity\n : (\n value = Math.max(min, Math.min(value, max)),\n min + step * Math.floor(1e-14 + (value - min) / step + (offset || 0))\n );\n}","import has from '../../util/has';\n\n/**\n * Recodes an input value to an alternative value, based on a provided\n * value map. If a fallback value is specified, it will be returned when\n * a matching value is not found in the map; otherwise, the input value\n * is returned unchanged.\n * @param {*} value The value to recode. The value must be safely\n * coercible to a string for lookup against the value map.\n * @param {object|Map} map An object or Map with input values for keys and\n * output recoded values as values. If a non-Map object, only the object's\n * own properties will be considered.\n * @param {*} [fallback] A default fallback value to use if the input\n * value is not found in the value map.\n * @return {*} The recoded value.\n */\nexport default function(value, map, fallback) {\n if (map instanceof Map) {\n if (map.has(value)) return map.get(value);\n } else if (has(map, value)) {\n return map[value];\n }\n return fallback !== undefined ? fallback : value;\n}","/**\n * Returns an array containing an arithmetic sequence from the start value\n * to the stop value, in step increments. If step is positive, the last\n * element is the largest start + i * step less than stop; if step is\n * negative, the last element is the smallest start + i * step greater\n * than stop. If the returned array would contain an infinite number of\n * values, an empty range is returned.\n * @param {number} [start=0] The starting value of the sequence.\n * @param {number} [stop] The stopping value of the sequence.\n * The stop value is exclusive; it is not included in the result.\n * @param {number} [step=1] The step increment between sequence values.\n * @return {number[]} The generated sequence.\n */\nexport default function(start, stop, step) {\n let n = arguments.length;\n start = +start;\n stop = +stop;\n step = n < 2\n ? (stop = start, start = 0, 1)\n : n < 3 ? 1 : +step;\n\n n = Math.max(0, Math.ceil((stop - start) / step)) | 0;\n const seq = new Array(n);\n\n for (let i = 0; i < n; ++i) {\n seq[i] = start + i * step;\n }\n\n return seq;\n}","import { random } from '../../util/random';\n\nexport default {\n random,\n is_nan: Number.isNaN,\n is_finite: Number.isFinite,\n\n abs: Math.abs,\n cbrt: Math.cbrt,\n ceil: Math.ceil,\n clz32: Math.clz32,\n exp: Math.exp,\n expm1: Math.expm1,\n floor: Math.floor,\n fround: Math.fround,\n greatest: Math.max,\n least: Math.min,\n log: Math.log,\n log10: Math.log10,\n log1p: Math.log1p,\n log2: Math.log2,\n pow: Math.pow,\n round: Math.round,\n sign: Math.sign,\n sqrt: Math.sqrt,\n trunc: Math.trunc,\n\n degrees: (rad) => 180 * rad / Math.PI,\n radians: (deg) => Math.PI * deg / 180,\n acos: Math.acos,\n acosh: Math.acosh,\n asin: Math.asin,\n asinh: Math.asinh,\n atan: Math.atan,\n atan2: Math.atan2,\n atanh: Math.atanh,\n cos: Math.cos,\n cosh: Math.cosh,\n sin: Math.sin,\n sinh: Math.sinh,\n tan: Math.tan,\n tanh: Math.tanh\n};","export default function(value) {\n return typeof value === 'bigint';\n}","import isBigInt from './is-bigint';\n\nexport default function(v) {\n return v === undefined ? v + ''\n : isBigInt(v) ? v + 'n'\n : JSON.stringify(v);\n}","import toArray from '../util/to-array';\nimport toString from '../util/to-string';\n\nexport default function(name, fields = [], params = []) {\n return new Op(name, toArray(fields), toArray(params));\n}\n\nexport class Op {\n constructor(name, fields, params) {\n this.name = name;\n this.fields = fields;\n this.params = params;\n }\n toString() {\n const args = [\n ...this.fields.map(f => `d[${toString(f)}]`),\n ...this.params.map(toString)\n ];\n return `d => op.${this.name}(${args})`;\n }\n toObject() {\n return { expr: this.toString(), func: true };\n }\n}","import functions from './functions';\nimport op from './op';\n\nexport const any = (field) => op('any', field);\nexport const count = () => op('count');\nexport const array_agg = (field) => op('array_agg', field);\nexport const array_agg_distinct = (field) => op('array_agg_distinct', field);\nexport const map_agg = (key, value) => op('map_agg', [key, value]);\nexport const object_agg = (key, value) => op('object_agg', [key, value]);\nexport const entries_agg = (key, value) => op('entries_agg', [key, value]);\n\n/**\n * @typedef {import('../table/transformable').Struct} Struct\n */\n\n/**\n * All table expression operations including normal functions,\n * aggregate functions, and window functions.\n */\nexport default {\n ...functions,\n\n /**\n * Generate an object representing the current table row.\n * @param {...string} names The column names to include in the object.\n * If unspecified, all columns are included.\n * @return {Struct} The generated row object.\n */\n row_object: (...names) => op('row_object', null, names.flat()),\n\n /**\n * Aggregate function to count the number of records (rows).\n * @returns {number} The count of records.\n */\n count,\n\n /**\n * Aggregate function returning an arbitrary observed value.\n * @param {*} field The data field.\n * @return {*} An arbitrary observed value.\n */\n any,\n\n /**\n * Aggregate function to collect an array of values.\n * @param {*} field The data field.\n * @return {Array} A list of values.\n */\n array_agg,\n\n /**\n * Aggregate function to collect an array of distinct (unique) values.\n * @param {*} field The data field.\n * @return {Array} An array of unique values.\n */\n array_agg_distinct,\n\n /**\n * Aggregate function to create an object given input key and value fields.\n * @param {*} key The object key field.\n * @param {*} value The object value field.\n * @return {Struct} An object of key-value pairs.\n */\n object_agg,\n\n /**\n * Aggregate function to create a Map given input key and value fields.\n * @param {*} key The object key field.\n * @param {*} value The object value field.\n * @return {Map} A Map of key-value pairs.\n */\n map_agg,\n\n /**\n * Aggregate function to create an array in the style of Object.entries()\n * given input key and value fields.\n * @param {*} key The object key field.\n * @param {*} value The object value field.\n * @return {[[any, any]]} An array of [key, value] arrays.\n */\n entries_agg,\n\n /**\n * Aggregate function to count the number of valid values.\n * Invalid values are null, undefined, or NaN.\n * @param {*} field The data field.\n * @return {number} The count of valid values.\n */\n valid: (field) => op('valid', field),\n\n /**\n * Aggregate function to count the number of invalid values.\n * Invalid values are null, undefined, or NaN.\n * @param {*} field The data field.\n * @return {number} The count of invalid values.\n */\n invalid: (field) => op('invalid', field),\n\n /**\n * Aggregate function to count the number of distinct values.\n * @param {*} field The data field.\n * @return {number} The count of distinct values.\n */\n distinct: (field) => op('distinct', field),\n\n /**\n * Aggregate function to determine the mode (most frequent) value.\n * @param {*} field The data field.\n * @return {number} The mode value.\n */\n mode: (field) => op('mode', field),\n\n /**\n * Aggregate function to sum values.\n * @param {string} field The data field.\n * @return {number} The sum of the values.\n */\n sum: (field) => op('sum', field),\n\n /**\n * Aggregate function to multiply values.\n * @param {*} field The data field.\n * @return {number} The product of the values.\n */\n product: (field) => op('product', field),\n\n /**\n * Aggregate function for the mean (average) value.\n * @param {*} field The data field.\n * @return {number} The mean (average) of the values.\n */\n mean: (field) => op('mean', field),\n\n /**\n * Aggregate function for the average (mean) value.\n * @param {*} field The data field.\n * @return {number} The average (mean) of the values.\n */\n average: (field) => op('average', field),\n\n /**\n * Aggregate function for the sample variance.\n * @param {*} field The data field.\n * @return {number} The sample variance of the values.\n */\n variance: (field) => op('variance', field),\n\n /**\n * Aggregate function for the population variance.\n * @param {*} field The data field.\n * @return {number} The population variance of the values.\n */\n variancep: (field) => op('variancep', field),\n\n /**\n * Aggregate function for the sample standard deviation.\n * @param {*} field The data field.\n * @return {number} The sample standard deviation of the values.\n */\n stdev: (field) => op('stdev', field),\n\n /**\n * Aggregate function for the population standard deviation.\n * @param {*} field The data field.\n * @return {number} The population standard deviation of the values.\n */\n stdevp: (field) => op('stdevp', field),\n\n /**\n * Aggregate function for the minimum value.\n * @param {*} field The data field.\n * @return {number} The minimum value.\n */\n min: (field) => op('min', field),\n\n /**\n * Aggregate function for the maximum value.\n * @param {*} field The data field.\n * @return {number} The maximum value.\n */\n max: (field) => op('max', field),\n\n /**\n * Aggregate function to compute the quantile boundary\n * of a data field for a probability threshold.\n * @param {*} field The data field.\n * @param {number} p The probability threshold.\n * @return {number} The quantile value.\n */\n quantile: (field, p) => op('quantile', field, p),\n\n /**\n * Aggregate function for the median value.\n * This is a shorthand for the 0.5 quantile value.\n * @param {*} field The data field.\n * @return {number} The median value.\n */\n median: (field) => op('median', field),\n\n /**\n * Aggregate function for the sample covariance between two variables.\n * @param {*} field1 The first data field.\n * @param {*} field2 The second data field.\n * @return {number} The sample covariance of the values.\n */\n covariance: (field1, field2) => op('covariance', [field1, field2]),\n\n /**\n * Aggregate function for the population covariance between two variables.\n * @param {*} field1 The first data field.\n * @param {*} field2 The second data field.\n * @return {number} The population covariance of the values.\n */\n covariancep: (field1, field2) => op('covariancep', [field1, field2]),\n\n /**\n * Aggregate function for the product-moment correlation between two variables.\n * To instead compute a rank correlation, compute the average ranks for each\n * variable and then apply this function to the result.\n * @param {*} field1 The first data field.\n * @param {*} field2 The second data field.\n * @return {number} The correlation between the field values.\n */\n corr: (field1, field2) => op('corr', [field1, field2]),\n\n /**\n * Aggregate function for calculating a binning scheme in terms of\n * the minimum bin boundary, maximum bin boundary, and step size.\n * @param {*} field The data field.\n * @param {number} [maxbins=15] The maximum number of allowed bins.\n * @param {boolean} [nice=true] Flag indicating if the bin min and max\n * should snap to \"nice\" human-friendly values.\n * @param {number} [minstep] The minimum allowed step size between bins.\n * @param {number} [step] The exact step size to use between bins.\n * If specified, the maxbins and minstep arguments are ignored.\n * @return {[number, number, number]} The bin [min, max, and step] values.\n */\n bins: (field, maxbins, nice, minstep) =>\n op('bins', field, [maxbins, nice, minstep]),\n\n /**\n * Window function to assign consecutive row numbers, starting from 1.\n * @return {number} The row number value.\n */\n row_number: () => op('row_number'),\n\n /**\n * Window function to assign a rank to each value in a group, starting\n * from 1. Peer values are assigned the same rank. Subsequent ranks\n * reflect the number of prior values: if the first two values tie for\n * rank 1, the third value is assigned rank 3.\n * @return {number} The rank value.\n */\n rank: () => op('rank'),\n\n /**\n * Window function to assign a fractional (average) rank to each value in\n * a group, starting from 1. Peer values are assigned the average of their\n * indices: if the first two values tie, both will be assigned rank 1.5.\n * @return {number} The peer-averaged rank value.\n */\n avg_rank: () => op('avg_rank'),\n\n /**\n * Window function to assign a dense rank to each value in a group,\n * starting from 1. Peer values are assigned the same rank. Subsequent\n * ranks do not reflect the number of prior values: if the first two\n * values tie for rank 1, the third value is assigned rank 2.\n * @return {number} The dense rank value.\n */\n dense_rank: () => op('dense_rank'),\n\n /**\n * Window function to assign a percentage rank to each value in a group.\n * The percent is calculated as (rank - 1) / (group_size - 1).\n * @return {number} The percentage rank value.\n */\n percent_rank: () => op('percent_rank'),\n\n /**\n * Window function to assign a cumulative distribution value between 0 and 1\n * to each value in a group.\n * @return {number} The cumulative distribution value.\n */\n cume_dist: () => op('cume_dist'),\n\n /**\n * Window function to assign a quantile (e.g., percentile) value to each\n * value in a group. Accepts an integer parameter indicating the number of\n * buckets to use (e.g., 100 for percentiles, 5 for quintiles).\n * @param {number} num The number of buckets for ntile calculation.\n * @return {number} The quantile value.\n */\n ntile: (num) => op('ntile', null, num),\n\n /**\n * Window function to assign a value that precedes the current value by\n * a specified number of positions. If no such value exists, returns a\n * default value instead.\n * @param {*} field The data field.\n * @param {number} [offset=1] The lag offset from the current value.\n * @param {*} [defaultValue=undefined] The default value.\n * @return {*} The lagging value.\n */\n lag: (field, offset, defaultValue) => op('lag', field, [offset, defaultValue]),\n\n /**\n * Window function to assign a value that follows the current value by\n * a specified number of positions. If no such value exists, returns a\n * default value instead.\n * @param {*} field The data field.\n * @param {number} [offset=1] The lead offset from the current value.\n * @param {*} [defaultValue=undefined] The default value.\n * @return {*} The leading value.\n */\n lead: (field, offset, defaultValue) => op('lead', field, [offset, defaultValue]),\n\n /**\n * Window function to assign the first value in a sliding window frame.\n * @param {*} field The data field.\n * @return {*} The first value in the current frame.\n */\n first_value: (field) => op('first_value', field),\n\n /**\n * Window function to assign the last value in a sliding window frame.\n * @param {*} field The data field.\n * @return {*} The last value in the current frame.\n */\n last_value: (field) => op('last_value', field),\n\n /**\n * Window function to assign the nth value in a sliding window frame\n * (counting from 1), or undefined if no such value exists.\n * @param {*} field The data field.\n * @param {number} nth The nth position, starting from 1.\n * @return {*} The nth value in the current frame.\n */\n nth_value: (field, nth) => op('nth_value', field, nth),\n\n /**\n * Window function to fill in missing values with preceding values.\n * @param {*} field The data field.\n * @param {*} [defaultValue=undefined] The default value.\n * @return {*} The current value if valid, otherwise the first preceding\n * valid value. If no such value exists, returns the default value.\n */\n fill_down: (field, defaultValue) => op('fill_down', field, defaultValue),\n\n /**\n * Window function to fill in missing values with subsequent values.\n * @param {*} field The data field.\n * @param {*} [defaultValue=undefined] The default value.\n * @return {*} The current value if valid, otherwise the first subsequent\n * valid value. If no such value exists, returns the default value.\n */\n fill_up: (field, defaultValue) => op('fill_up', field, defaultValue)\n};","import { array_agg, entries_agg, map_agg, object_agg } from '../op/op-api';\nimport error from '../util/error';\nimport uniqueName from '../util/unique-name';\n\n/**\n * Regroup table rows in response to a BitSet filter.\n * @param {GroupBySpec} groups The current groupby specification.\n * @param {BitSet} filter The filter to apply.\n */\nexport function regroup(groups, filter) {\n if (!groups || !filter) return groups;\n\n // check for presence of rows for each group\n const { keys, rows, size } = groups;\n const map = new Int32Array(size);\n filter.scan(row => map[keys[row]] = 1);\n\n // check sum, exit early if all groups occur\n const sum = map.reduce((sum, val) => sum + val, 0);\n if (sum === size) return groups;\n\n // create group index map, filter exemplar rows\n const _rows = Array(sum);\n let _size = 0;\n for (let i = 0; i < size; ++i) {\n if (map[i]) _rows[map[i] = _size++] = rows[i];\n }\n\n // re-index the group keys\n const _keys = new Uint32Array(keys.length);\n filter.scan(row => _keys[row] = map[keys[row]]);\n\n return { ...groups, keys: _keys, rows: _rows, size: _size };\n}\n\n/**\n * Regroup table rows in response to a re-indexing.\n * This operation may or may not involve filtering of rows.\n * @param {GroupBySpec} groups The current groupby specification.\n * @param {Function} scan Function to scan new row indices.\n * @param {boolean} filter Flag indicating if filtering may occur.\n * @param {number} nrows The number of rows in the new table.\n */\nexport function reindex(groups, scan, filter, nrows) {\n const { keys, rows, size } = groups;\n let _rows = rows;\n let _size = size;\n let map = null;\n\n if (filter) {\n // check for presence of rows for each group\n map = new Int32Array(size);\n scan(row => map[keys[row]] = 1);\n\n // check sum, regroup if not all groups occur\n const sum = map.reduce((sum, val) => sum + val, 0);\n if (sum !== size) {\n // create group index map, filter exemplar rows\n _rows = Array(sum);\n _size = 0;\n for (let i = 0; i < size; ++i) {\n if (map[i]) _rows[map[i] = _size++] = rows[i];\n }\n }\n }\n\n // re-index the group keys\n let r = -1;\n const _keys = new Uint32Array(nrows);\n const fn = _size !== size\n ? row => _keys[++r] = map[keys[row]]\n : row => _keys[++r] = keys[row];\n scan(fn);\n\n return { ...groups, keys: _keys, rows: _rows, size: _size };\n}\n\nexport function nest(table, idx, obj, type) {\n const agg = type === 'map' || type === true ? map_agg\n : type === 'entries' ? entries_agg\n : type === 'object' ? object_agg\n : error('groups option must be \"map\", \"entries\", or \"object\".');\n\n const { names } = table.groups();\n const col = uniqueName(table.columnNames(), '_');\n\n // create table with one column of row objects\n // then aggregate into per-group arrays\n let t = table\n .select()\n .reify(idx)\n .create({ data: { [col]: obj } })\n .rollup({ [col]: array_agg(col) });\n\n // create nested structures for each level of grouping\n for (let i = names.length; --i >= 0;) {\n t = t\n .groupby(names.slice(0, i))\n .rollup({ [col]: agg(names[i], col) });\n }\n\n // return the final aggregated structure\n return t.get(col);\n}","import isMapOrSet from './is-map-or-set';\n\nexport default function(names, name) {\n names = isMapOrSet(names) ? names : new Set(names);\n let uname = name;\n let index = 0;\n\n while (names.has(uname)) {\n uname = name + ++index;\n }\n\n return uname;\n}","export const ArrayPattern = 'ArrayPattern';\nexport const ArrowFunctionExpression = 'ArrowFunctionExpression';\nexport const FunctionExpression = 'FunctionExpression';\nexport const Identifier = 'Identifier';\nexport const Literal = 'Literal';\nexport const MemberExpression = 'MemberExpression';\nexport const ObjectExpression = 'ObjectExpression';\nexport const ObjectPattern = 'ObjectPattern';\nexport const Property = 'Property';\n\nexport const Column = 'Column';\nexport const Constant = 'Constant';\nexport const Dictionary = 'Dictionary';\nexport const Function = 'Function';\nexport const Parameter = 'Parameter';\nexport const Op = 'Op';","import error from '../util/error';\nimport toString from '../util/to-string';\n\nconst visit = (node, opt) => {\n const f = visitors[node.type];\n return f\n ? f(node, opt)\n : error(`Unsupported expression construct: ${node.type}`);\n};\n\nconst binary = (node, opt) => {\n return '(' + visit(node.left, opt) + ' ' + node.operator + ' ' + visit(node.right, opt) + ')';\n};\n\nconst func = (node, opt) => {\n return '(' + list(node.params, opt) + ')=>' + visit(node.body, opt);\n};\n\nconst call = (node, opt) => {\n return visit(node.callee, opt) + '(' + list(node.arguments, opt) + ')';\n};\n\nconst list = (array, opt, delim = ',') => {\n return array.map(node => visit(node, opt)).join(delim);\n};\n\nconst name = node => node.computed\n ? `[${toString(node.name)}]`\n : `.${node.name}`;\n\nconst ref = (node, opt, method) => {\n const table = node.table || '';\n return `data${table}${name(node)}.${method}(${opt.index}${table})`;\n};\n\nconst visitors = {\n Constant: node => node.raw,\n Column: (node, opt) => ref(node, opt, 'get'),\n Dictionary: (node, opt) => ref(node, opt, 'key'),\n Function: node => `fn.${node.name}`,\n Parameter: node => `$${name(node)}`,\n Op: (node, opt) => `op(${toString(node.name)},${opt.op || opt.index})`,\n Literal: node => node.raw,\n Identifier: node => node.name,\n TemplateLiteral: (node, opt) => {\n const { quasis, expressions } = node;\n const n = expressions.length;\n let t = quasis[0].value.raw;\n for (let i = 0; i < n;) {\n t += '${' + visit(expressions[i], opt) + '}' + quasis[++i].value.raw;\n }\n return '`' + t + '`';\n },\n MemberExpression: (node, opt) => {\n const d = !node.computed;\n const o = visit(node.object, opt);\n const p = visit(node.property, opt);\n return o + (d ? '.' + p : '[' + p + ']');\n },\n CallExpression: call,\n NewExpression: (node, opt) => {\n return 'new ' + call(node, opt);\n },\n ArrayExpression: (node, opt) => {\n return '[' + list(node.elements, opt) + ']';\n },\n AssignmentExpression: binary,\n BinaryExpression: binary,\n LogicalExpression: binary,\n UnaryExpression: (node, opt) => {\n return '(' + node.operator + visit(node.argument, opt) + ')';\n },\n ConditionalExpression: (node, opt) => {\n return '(' + visit(node.test, opt) +\n '?' + visit(node.consequent, opt) +\n ':' + visit(node.alternate, opt) + ')';\n },\n ObjectExpression: (node, opt) => {\n return '({' + list(node.properties, opt) + '})';\n },\n Property: (node, opt) => {\n const key = visit(node.key, opt);\n return (node.computed ? `[${key}]` : key) + ':' + visit(node.value, opt);\n },\n\n ArrowFunctionExpression: func,\n FunctionExpression: func,\n FunctionDeclaration: func,\n\n ArrayPattern: (node, opt) => {\n return '[' + list(node.elements, opt) + ']';\n },\n ObjectPattern: (node, opt) => {\n return '{' + list(node.properties, opt) + '}';\n },\n VariableDeclaration: (node, opt) => {\n return node.kind + ' ' + list(node.declarations, opt, ',');\n },\n VariableDeclarator: (node, opt) => {\n return visit(node.id, opt) + '=' + visit(node.init, opt);\n },\n SpreadElement: (node, opt) => {\n return '...' + visit(node.argument, opt);\n },\n\n BlockStatement: (node, opt) => {\n return '{' + list(node.body, opt, ';') + ';}';\n },\n BreakStatement: () => {\n return 'break';\n },\n ExpressionStatement: (node, opt) => {\n return visit(node.expression, opt);\n },\n IfStatement: (node, opt) => {\n return 'if (' + visit(node.test, opt) + ')'\n + visit(node.consequent, opt)\n + (node.alternate ? ' else ' + visit(node.alternate, opt) : '');\n },\n SwitchStatement: (node, opt) => {\n return 'switch (' + visit(node.discriminant, opt) + ') {'\n + list(node.cases, opt, '')\n + '}';\n },\n SwitchCase: (node, opt) => {\n return (node.test ? 'case ' + visit(node.test, opt) : 'default')\n + ': '\n + list(node.consequent, opt, ';') + ';';\n },\n ReturnStatement: (node, opt) => {\n return 'return ' + visit(node.argument, opt);\n },\n Program: (node, opt) => visit(node.body[0], opt)\n};\n\nexport default function(node, opt = { index: 'row' }) {\n return visit(node, opt);\n}","import isArray from './is-array';\nimport isDate from './is-date';\nimport isRegExp from './is-regexp';\nimport isTypedArray from './is-typed-array';\n\nexport function key(value) {\n const type = typeof value;\n return type === 'string' ? `\"${value}\"`\n : type !== 'object' || !value ? value\n : isDate(value) ? +value\n : isArray(value) || isTypedArray(value) ? `[${value.map(key)}]`\n : isRegExp(value) ? value + ''\n : objectKey(value);\n}\n\nfunction objectKey(value) {\n let s = '{';\n let i = -1;\n for (const k in value) {\n if (++i > 0) s += ',';\n s += `\"${k}\":${key(value[k])}`;\n }\n s += '}';\n return s;\n}\n\nexport default function(get, nulls) {\n const n = get.length;\n return n === 1\n ? (row, data) => key(get[0](row, data))\n : (row, data) => {\n let s = '';\n for (let i = 0; i < n; ++i) {\n if (i > 0) s += '|';\n const v = get[i](row, data);\n if (nulls && (v == null || v !== v)) return null;\n s += key(v);\n }\n return s;\n };\n}","export default function() {}","import bins from '../util/bins';\nimport distinctMap from '../util/distinct-map';\nimport isBigInt from '../util/is-bigint';\nimport noop from '../util/no-op';\nimport NULL from '../util/null';\nimport product from '../util/product';\n\n/**\n * Initialize an aggregate operator.\n */\nfunction initOp(op) {\n op.init = op.init || noop;\n op.add = op.add || noop;\n op.rem = op.rem || noop;\n return op;\n}\n\nfunction initProduct(s, value) {\n s.product_v = false;\n return s.product = value;\n}\n\n/**\n * Initialize an aggregate operator.\n * @callback AggregateInit\n * @param {object} state The aggregate state object.\n * @return {void}\n */\n\n/**\n * Add a value to an aggregate operator.\n * @callback AggregateAdd\n * @param {object} state The aggregate state object.\n * @param {*} value The value to add.\n * @return {void}\n */\n\n/**\n * Remove a value from an aggregate operator.\n * @callback AggregateRem\n * @param {object} state The aggregate state object.\n * @param {*} value The value to remove.\n * @return {void}\n */\n\n/**\n * Retrive an output value from an aggregate operator.\n * @callback AggregateValue\n * @param {object} state The aggregate state object.\n * @return {*} The output value.\n */\n\n/**\n * An operator instance for an aggregate function.\n * @typedef {object} AggregateOperator\n * @property {AggregateInit} init Initialize the operator.\n * @property {AggregateAdd} add Add a value to the operator state.\n * @property {AggregateRem} rem Remove a value from the operator state.\n * @property {AggregateValue} value Retrieve an output value.\n */\n\n/**\n * Create a new aggregate operator instance.\n * @callback AggregateCreate\n * @param {...any} params The aggregate operator parameters.\n * @return {AggregateOperator} The instantiated aggregate operator.\n */\n\n/**\n * An operator definition for an aggregate function.\n * @typedef {object} AggregateDef\n * @property {AggregateCreate} create Create a new operator instance.\n * @property {number[]} param Two-element array containing the\n * counts of input fields and additional parameters.\n * @property {string[]} [req] Names of operators required by this one.\n * @property {string[]} [stream] Names of operators required by this one\n * for streaming operations (value removes).\n */\n\n/**\n * Aggregate operator definitions.\n */\nexport default {\n /** @type {AggregateDef} */\n count: {\n create: () => initOp({\n value: s => s.count\n }),\n param: []\n },\n\n /** @type {AggregateDef} */\n array_agg: {\n create: () => initOp({\n init: s => s.values = true,\n value: s => s.list.values(s.stream)\n }),\n param: [1]\n },\n\n /** @type {AggregateDef} */\n object_agg: {\n create: () => initOp({\n init: s => s.values = true,\n value: s => Object.fromEntries(s.list.values())\n }),\n param: [2]\n },\n\n /** @type {AggregateDef} */\n map_agg: {\n create: () => initOp({\n init: s => s.values = true,\n value: s => new Map(s.list.values())\n }),\n param: [2]\n },\n\n /** @type {AggregateDef} */\n entries_agg: {\n create: () => initOp({\n init: s => s.values = true,\n value: s => s.list.values(s.stream)\n }),\n param: [2]\n },\n\n /** @type {AggregateDef} */\n any: {\n create: () => initOp({\n add: (s, v) => { if (s.any == null) s.any = v; },\n value: s => s.valid ? s.any : NULL\n }),\n param: [1]\n },\n\n /** @type {AggregateDef} */\n valid: {\n create: () => initOp({\n value: s => s.valid\n }),\n param: [1]\n },\n\n /** @type {AggregateDef} */\n invalid: {\n create: () => initOp({\n value: s => s.count - s.valid\n }),\n param: [1]\n },\n\n /** @type {AggregateDef} */\n distinct: {\n create: () => ({\n init: s => s.distinct = distinctMap(),\n value: s => s.distinct.count() + (s.valid === s.count ? 0 : 1),\n add: (s, v) => s.distinct.increment(v),\n rem: (s, v) => s.distinct.decrement(v)\n }),\n param: [1]\n },\n\n /** @type {AggregateDef} */\n array_agg_distinct: {\n create: () => initOp({\n value: s => s.distinct.values()\n }),\n param: [1],\n req: ['distinct']\n },\n\n /** @type {AggregateDef} */\n mode: {\n create: () => initOp({\n value: s => {\n let mode = NULL;\n let max = 0;\n s.distinct.forEach((value, count) => {\n if (count > max) {\n max = count;\n mode = value;\n }\n });\n return mode;\n }\n }),\n param: [1],\n req: ['distinct']\n },\n\n /** @type {AggregateDef} */\n sum: {\n create: () => ({\n init: s => s.sum = 0,\n value: s => s.valid ? s.sum : NULL,\n add: (s, v) => isBigInt(v)\n ? (s.sum === 0 ? s.sum = v : s.sum += v)\n : s.sum += +v,\n rem: (s, v) => s.sum -= v\n }),\n param: [1]\n },\n\n /** @type {AggregateDef} */\n product: {\n create: () => ({\n init: s => initProduct(s, 1),\n value: s => s.valid\n ? (\n s.product_v\n ? initProduct(s, product(s.list.values()))\n : s.product\n )\n : undefined,\n add: (s, v) => isBigInt(v)\n ? (s.product === 1 ? s.product = v : s.product *= v)\n : s.product *= v,\n rem: (s, v) => (v == 0 || v === Infinity || v === -Infinity)\n ? s.product_v = true\n : s.product /= v\n }),\n param: [1],\n stream: ['array_agg']\n },\n\n /** @type {AggregateDef} */\n mean: {\n create: () => ({\n init: s => s.mean = 0,\n value: s => s.valid ? s.mean : NULL,\n add: (s, v) => {\n s.mean_d = v - s.mean;\n s.mean += s.mean_d / s.valid;\n },\n rem: (s, v) => {\n s.mean_d = v - s.mean;\n s.mean -= s.valid ? s.mean_d / s.valid : s.mean;\n }\n }),\n param: [1]\n },\n\n /** @type {AggregateDef} */\n average: {\n create: () => initOp({\n value: s => s.valid ? s.mean : NULL\n }),\n param: [1],\n req: ['mean']\n },\n\n /** @type {AggregateDef} */\n variance: {\n create: () => ({\n init: s => s.dev = 0,\n value: s => s.valid > 1 ? s.dev / (s.valid - 1) : NULL,\n add: (s, v) => s.dev += s.mean_d * (v - s.mean),\n rem: (s, v) => s.dev -= s.mean_d * (v - s.mean)\n }),\n param: [1],\n req: ['mean']\n },\n\n /** @type {AggregateDef} */\n variancep: {\n create: () => initOp({\n value: s => s.valid > 1 ? s.dev / s.valid : NULL\n }),\n param: [1],\n req: ['variance']\n },\n\n /** @type {AggregateDef} */\n stdev: {\n create: () => initOp({\n value: s => s.valid > 1 ? Math.sqrt(s.dev / (s.valid - 1)) : NULL\n }),\n param: [1],\n req: ['variance']\n },\n\n /** @type {AggregateDef} */\n stdevp: {\n create: () => initOp({\n value: s => s.valid > 1 ? Math.sqrt(s.dev / s.valid) : NULL\n }),\n param: [1],\n req: ['variance']\n },\n\n /** @type {AggregateDef} */\n min: {\n create: () => ({\n init: s => s.min = NULL,\n value: s => s.min = (Number.isNaN(s.min) ? s.list.min() : s.min),\n add: (s, v) => { if (v < s.min || s.min === NULL) s.min = v; },\n rem: (s, v) => { if (v <= s.min) s.min = NaN; }\n }),\n param: [1],\n stream: ['array_agg']\n },\n\n /** @type {AggregateDef} */\n max: {\n create: () => ({\n init: s => s.max = NULL,\n value: s => s.max = (Number.isNaN(s.max) ? s.list.max() : s.max),\n add: (s, v) => { if (v > s.max || s.max === NULL) s.max = v; },\n rem: (s, v) => { if (v >= s.max) s.max = NaN; }\n }),\n param: [1],\n stream: ['array_agg']\n },\n\n /** @type {AggregateDef} */\n quantile: {\n create: (p) => initOp({\n value: s => s.list.quantile(p)\n }),\n param: [1, 1],\n req: ['array_agg']\n },\n\n /** @type {AggregateDef} */\n median: {\n create: () => initOp({\n value: s => s.list.quantile(0.5)\n }),\n param: [1],\n req: ['array_agg']\n },\n\n /** @type {AggregateDef} */\n covariance: {\n create: () => ({\n init: s => {\n s.cov = s.mean_x = s.mean_y = s.dev_x = s.dev_y = 0;\n },\n value: s => s.valid > 1 ? s.cov / (s.valid - 1) : NULL,\n add: (s, x, y) => {\n const dx = x - s.mean_x;\n const dy = y - s.mean_y;\n s.mean_x += dx / s.valid;\n s.mean_y += dy / s.valid;\n const dy2 = y - s.mean_y;\n s.dev_x += dx * (x - s.mean_x);\n s.dev_y += dy * dy2;\n s.cov += dx * dy2;\n },\n rem: (s, x, y) => {\n const dx = x - s.mean_x;\n const dy = y - s.mean_y;\n s.mean_x -= s.valid ? dx / s.valid : s.mean_x;\n s.mean_y -= s.valid ? dy / s.valid : s.mean_y;\n const dy2 = y - s.mean_y;\n s.dev_x -= dx * (x - s.mean_x);\n s.dev_y -= dy * dy2;\n s.cov -= dx * dy2;\n }\n }),\n param: [2]\n },\n\n /** @type {AggregateDef} */\n covariancep: {\n create: () => initOp({\n value: s => s.valid > 1 ? s.cov / s.valid : NULL\n }),\n param: [2],\n req: ['covariance']\n },\n\n /** @type {AggregateDef} */\n corr: {\n create: () => initOp({\n value: s => s.valid > 1\n ? s.cov / (Math.sqrt(s.dev_x) * Math.sqrt(s.dev_y))\n : NULL\n }),\n param: [2],\n req: ['covariance']\n },\n\n /** @type {AggregateDef} */\n bins: {\n create: (maxbins, nice, minstep, step) => initOp({\n value: s => bins(s.min, s.max, maxbins, nice, minstep, step)\n }),\n param: [1, 4],\n req: ['min', 'max']\n }\n};","import { key } from './key-function';\n\nexport default function() {\n const map = new Map();\n return {\n count() {\n return map.size;\n },\n values() {\n return Array.from(map.values(), _ => _.v);\n },\n increment(v) {\n const k = key(v);\n const e = map.get(k);\n e ? ++e.n : map.set(k, { v, n: 1 });\n },\n decrement(v) {\n const k = key(v);\n const e = map.get(k);\n e.n === 1 ? map.delete(k) : --e.n;\n },\n forEach(fn) {\n map.forEach(({ v, n }) => fn(v, n));\n }\n };\n}","export default function(values, start = 0, stop = values.length) {\n let prod = values[start++];\n\n for (let i = start; i < stop; ++i) {\n prod *= values[i];\n }\n\n return prod;\n}","export default function(min, max, maxbins = 15, nice = true, minstep = 0, step) {\n const base = 10;\n const logb = Math.LN10;\n\n if (step == null) {\n const level = Math.ceil(Math.log(maxbins) / logb);\n const span = (max - min) || Math.abs(min) || 1;\n const div = [5, 2];\n\n step = Math.max(\n minstep,\n Math.pow(base, Math.round(Math.log(span) / logb) - level)\n );\n\n // increase step size if too many bins\n while (Math.ceil(span / step) > maxbins) {\n step *= base;\n }\n\n // decrease step size if it stays within maxbins\n const n = div.length;\n for (let i = 0; i < n; ++i) {\n const v = step / div[i];\n if (v >= minstep && span / v <= maxbins) {\n step = v;\n }\n }\n }\n\n // snap to \"nice\" boundaries\n if (nice) {\n let v = Math.log(step);\n const precision = v >= 0 ? 0 : ~~(-v / logb) + 1;\n const eps = Math.pow(base, -precision - 1);\n v = Math.floor(min / step + eps) * step;\n min = min < v ? v - step : v;\n max = Math.ceil(max / step) * step;\n }\n\n return [\n min,\n max === min ? min + step : max,\n step\n ];\n}","import error from '../util/error';\nimport isValid from '../util/is-valid';\nimport noop from '../util/no-op';\nimport NULL from '../util/null';\n\n/**\n * Initialize a window operator.\n * @callback WindowInit\n * @return {void}\n */\n\n/**\n * Retrieve an output value from a window operator.\n * @callback WindowValue\n * @param {WindowState} state The window state object.\n * @return {*} The output value.\n */\n\n/**\n * An operator instance for a window function.\n * @typedef {object} WindowOperator\n * @property {AggregateInit} init Initialize the operator.\n * @property {AggregateValue} value Retrieve an output value.\n */\n\n/**\n * Create a new window operator instance.\n * @callback WindowCreate\n * @param {...any} params The aggregate operator parameters.\n * @return {WindowOperator} The instantiated window operator.\n */\n\n/**\n * An operator definition for a window function.\n * @typedef {object} WindowDef\n * @property {AggregateCreate} create Create a new operator instance.\n * @property {number[]} param Two-element array containing the\n * counts of input fields and additional parameters.\n */\n\nconst rank = {\n create() {\n let rank;\n return {\n init: () => rank = 1,\n value: w => {\n const i = w.index;\n return (i && !w.peer(i)) ? (rank = i + 1) : rank;\n }\n };\n },\n param: []\n};\n\nconst cume_dist = {\n create() {\n let cume;\n return {\n init: () => cume = 0,\n value: w => {\n const { index, peer, size } = w;\n let i = index;\n if (cume < i) {\n while (i + 1 < size && peer(i + 1)) ++i;\n cume = i;\n }\n return (1 + cume) / size;\n }\n };\n },\n param: []\n};\n\n/**\n * Window operator definitions.\n */\nexport default {\n /** @type {WindowDef} */\n row_number: {\n create() {\n return {\n init: noop,\n value: w => w.index + 1\n };\n },\n param: []\n },\n\n /** @type {WindowDef} */\n rank,\n\n /** @type {WindowDef} */\n avg_rank: {\n create() {\n let j, rank;\n return {\n init: () => (j = -1, rank = 1),\n value: w => {\n const i = w.index;\n if (i >= j) {\n for (rank = j = i + 1; w.peer(j); rank += ++j);\n rank /= (j - i);\n }\n return rank;\n }\n };\n },\n param: []\n },\n\n /** @type {WindowDef} */\n dense_rank: {\n create() {\n let drank;\n return {\n init: () => drank = 1,\n value: w => {\n const i = w.index;\n return (i && !w.peer(i)) ? ++drank : drank;\n }\n };\n },\n param: []\n },\n\n /** @type {WindowDef} */\n percent_rank: {\n create() {\n const { init, value } = rank.create();\n return {\n init,\n value: w => (value(w) - 1) / (w.size - 1)\n };\n },\n param: []\n },\n\n /** @type {WindowDef} */\n cume_dist,\n\n /** @type {WindowDef} */\n ntile: {\n create(num) {\n num = +num;\n if (!(num > 0)) error('ntile num must be greater than zero.');\n const { init, value } = cume_dist.create();\n return {\n init,\n value: w => Math.ceil(num * value(w))\n };\n },\n param: [0, 1]\n },\n\n /** @type {WindowDef} */\n lag: {\n create(offset, defaultValue = NULL) {\n offset = +offset || 1;\n return {\n init: noop,\n value: (w, f) => {\n const i = w.index - offset;\n return i >= 0 ? w.value(i, f) : defaultValue;\n }\n };\n },\n param: [1, 2]\n },\n\n /** @type {WindowDef} */\n lead: {\n create(offset, defaultValue = NULL) {\n offset = +offset || 1;\n return {\n init: noop,\n value: (w, f) => {\n const i = w.index + offset;\n return i < w.size ? w.value(i, f) : defaultValue;\n }\n };\n },\n param: [1, 2]\n },\n\n /** @type {WindowDef} */\n first_value: {\n create() {\n return {\n init: noop,\n value: (w, f) => w.value(w.i0, f)\n };\n },\n param: [1]\n },\n\n /** @type {WindowDef} */\n last_value: {\n create() {\n return {\n init: noop,\n value: (w, f) => w.value(w.i1 - 1, f)\n };\n },\n param: [1]\n },\n\n /** @type {WindowDef} */\n nth_value: {\n create(nth) {\n nth = +nth;\n if (!(nth > 0)) error('nth_value nth must be greater than zero.');\n return {\n init: noop,\n value: (w, f) => {\n const i = w.i0 + (nth - 1);\n return i < w.i1 ? w.value(i, f) : NULL;\n }\n };\n },\n param: [1, 1]\n },\n\n /** @type {WindowDef} */\n fill_down: {\n create(defaultValue = NULL) {\n let value;\n return {\n init: () => value = defaultValue,\n value: (w, f) => {\n const v = w.value(w.index, f);\n return isValid(v) ? (value = v) : value;\n }\n };\n },\n param: [1, 1]\n },\n\n /** @type {WindowDef} */\n fill_up: {\n create(defaultValue = NULL) {\n let value, idx;\n return {\n init: () => (value = defaultValue, idx = -1),\n value: (w, f) => w.index <= idx ? value\n : (idx = find(w, f, w.index)) >= 0 ? (value = w.value(idx, f))\n : (idx = w.size, value = defaultValue)\n };\n },\n param: [1, 1]\n }\n};\n\nfunction find(w, f, i) {\n for (const n = w.size; i < n; ++i) {\n if (isValid(w.value(i, f))) return i;\n }\n return -1;\n}\n","import aggregateFunctions from './aggregate-functions';\nimport windowFunctions from './window-functions';\nimport functions from './functions';\nimport has from '../util/has';\n\nexport {\n functions,\n aggregateFunctions,\n windowFunctions\n};\n\n/**\n * Check if an aggregate function with the given name exists.\n * @param {string} name The name of the aggregate function.\n * @return {boolean} True if found, false otherwise.\n */\nexport function hasAggregate(name) {\n return has(aggregateFunctions, name);\n}\n\n/**\n * Check if a window function with the given name exists.\n * @param {string} name The name of the window function.\n * @return {boolean} True if found, false otherwise.\n */\nexport function hasWindow(name) {\n return has(windowFunctions, name);\n}\n\n/**\n * Check if an expression function with the given name exists.\n * @param {string} name The name of the function.\n * @return {boolean} True if found, false otherwise.\n */\n export function hasFunction(name) {\n return has(functions, name) || name === 'row_object';\n}\n\n/**\n * Get an aggregate function definition.\n * @param {string} name The name of the aggregate function.\n * @return {AggregateDef} The aggregate function definition,\n * or undefined if not found.\n */\nexport function getAggregate(name) {\n return hasAggregate(name) && aggregateFunctions[name];\n}\n\n/**\n * Get a window function definition.\n * @param {string} name The name of the window function.\n * @return {WindowDef} The window function definition,\n * or undefined if not found.\n */\nexport function getWindow(name) {\n return hasWindow(name) && windowFunctions[name];\n}\n\n/**\n * Get an expression function definition.\n * @param {string} name The name of the function.\n * @return {Function} The function instance, or undefined if not found.\n */\nexport function getFunction(name) {\n return hasFunction(name) && functions[name];\n}","import { functions as fn } from '../op';\n\nfunction compile(code, fn, params) {\n code = `\"use strict\"; return ${code};`;\n return (Function('fn', '$', code))(fn, params);\n}\n\nexport default {\n escape: (code, func, params) => compile(code, func, params),\n expr: (code, params) => compile(`(row,data,op)=>${code}`, fn, params),\n expr2: (code, params) => compile(`(row0,data0,row,data)=>${code}`, fn, params),\n join: (code, params) => compile(`(row1,data1,row2,data2)=>${code}`, fn, params),\n param: (code, params) => compile(code, fn, params)\n};","import { Column, Dictionary, Literal } from './ast/constants';\nimport isFunction from '../util/is-function';\n\nconst dictOps = {\n '==': 1,\n '!=': 1,\n '===': 1,\n '!==': 1\n};\n\n/**\n * Rewrite AST node to be a table column reference.\n * Additionally optimizes dictionary column operations.\n * @param {object} ref AST node to rewrite to a column reference.\n * @param {string} name The name of the column.\n * @param {number} index The table index of the column.\n * @param {object} col The actual table column instance.\n * @param {object} op Parent AST node operating on the column reference.\n */\nexport default function(ref, name, index = 0, col, op) {\n ref.type = Column;\n ref.name = name;\n ref.table = index;\n\n // proceed only if has parent op and is a dictionary column\n if (op && col && isFunction(col.keyFor)) {\n // get other arg if op is an optimizeable operation\n const lit = dictOps[op.operator]\n ? op.left === ref ? op.right : op.left\n : op.callee && op.callee.name === 'equal'\n ? op.arguments[op.arguments[0] === ref ? 1 : 0]\n : null;\n\n // rewrite as dictionary lookup if other arg is a literal\n if (lit && lit.type === Literal) {\n rewriteDictionary(op, ref, lit, col.keyFor(lit.value));\n }\n }\n\n return ref;\n}\n\nfunction rewriteDictionary(op, ref, lit, key) {\n if (key < 0) {\n // value not in dictionary, rewrite op as false literal\n op.type = Literal;\n op.value = false;\n op.raw = 'false';\n } else {\n // rewrite ref as dict key access\n ref.type = Dictionary;\n\n // rewrite literal as target dict key\n lit.value = key;\n lit.raw = key + '';\n }\n\n return true;\n}","import isArray from './is-array';\nimport isMap from './is-map';\n\nexport default function(value) {\n return isArray(value) ? value\n : isMap(value) ? value.entries()\n : value ? Object.entries(value)\n : [];\n}","import { Literal, ObjectExpression, Property } from './ast/constants';\nimport codegen from './codegen';\nimport compile from './compile';\nimport rewrite from './rewrite';\nimport entries from '../util/entries';\nimport isArray from '../util/is-array';\nimport toString from '../util/to-string';\n\nexport const ROW_OBJECT = 'row_object';\n\nexport function rowObjectExpression(node, props) {\n node.type = ObjectExpression;\n\n const p = node.properties = [];\n for (const prop of entries(props)) {\n const [name, key] = isArray(prop) ? prop : [prop, prop];\n p.push({\n type: Property,\n key: { type: Literal, raw: toString(key) },\n value: rewrite({ computed: true }, name)\n });\n }\n\n return node;\n}\n\nexport function rowObjectCode(props) {\n return codegen(rowObjectExpression({}, props));\n}\n\nexport function rowObjectBuilder(props) {\n return compile.expr(rowObjectCode(props));\n}","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport default {\r\n __extends,\r\n __assign,\r\n __rest,\r\n __decorate,\r\n __param,\r\n __metadata,\r\n __awaiter,\r\n __generator,\r\n __createBinding,\r\n __exportStar,\r\n __values,\r\n __read,\r\n __spread,\r\n __spreadArrays,\r\n __spreadArray,\r\n __await,\r\n __asyncGenerator,\r\n __asyncDelegator,\r\n __asyncValues,\r\n __makeTemplateObject,\r\n __importStar,\r\n __importDefault,\r\n __classPrivateFieldGet,\r\n __classPrivateFieldSet,\r\n __classPrivateFieldIn,\r\n};\r\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nconst decoder = new TextDecoder('utf-8');\n/** @ignore */\nexport const decodeUtf8 = (buffer) => decoder.decode(buffer);\nconst encoder = new TextEncoder();\n/** @ignore */\nexport const encodeUtf8 = (value) => encoder.encode(value);\n\n//# sourceMappingURL=utf8.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\n/** @ignore */\nconst [BigIntCtor, BigIntAvailable] = (() => {\n const BigIntUnavailableError = () => { throw new Error('BigInt is not available in this environment'); };\n function BigIntUnavailable() { throw BigIntUnavailableError(); }\n BigIntUnavailable.asIntN = () => { throw BigIntUnavailableError(); };\n BigIntUnavailable.asUintN = () => { throw BigIntUnavailableError(); };\n return typeof BigInt !== 'undefined' ? [BigInt, true] : [BigIntUnavailable, false];\n})();\n/** @ignore */\nconst [BigInt64ArrayCtor, BigInt64ArrayAvailable] = (() => {\n const BigInt64ArrayUnavailableError = () => { throw new Error('BigInt64Array is not available in this environment'); };\n class BigInt64ArrayUnavailable {\n static get BYTES_PER_ELEMENT() { return 8; }\n static of() { throw BigInt64ArrayUnavailableError(); }\n static from() { throw BigInt64ArrayUnavailableError(); }\n constructor() { throw BigInt64ArrayUnavailableError(); }\n }\n return typeof BigInt64Array !== 'undefined' ? [BigInt64Array, true] : [BigInt64ArrayUnavailable, false];\n})();\n/** @ignore */\nconst [BigUint64ArrayCtor, BigUint64ArrayAvailable] = (() => {\n const BigUint64ArrayUnavailableError = () => { throw new Error('BigUint64Array is not available in this environment'); };\n class BigUint64ArrayUnavailable {\n static get BYTES_PER_ELEMENT() { return 8; }\n static of() { throw BigUint64ArrayUnavailableError(); }\n static from() { throw BigUint64ArrayUnavailableError(); }\n constructor() { throw BigUint64ArrayUnavailableError(); }\n }\n return typeof BigUint64Array !== 'undefined' ? [BigUint64Array, true] : [BigUint64ArrayUnavailable, false];\n})();\nexport { BigIntCtor as BigInt, BigIntAvailable };\nexport { BigInt64ArrayCtor as BigInt64Array, BigInt64ArrayAvailable };\nexport { BigUint64ArrayCtor as BigUint64Array, BigUint64ArrayAvailable };\n/** @ignore */ const isNumber = (x) => typeof x === 'number';\n/** @ignore */ const isBoolean = (x) => typeof x === 'boolean';\n/** @ignore */ const isFunction = (x) => typeof x === 'function';\n/** @ignore */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isObject = (x) => x != null && Object(x) === x;\n/** @ignore */\nexport const isPromise = (x) => {\n return isObject(x) && isFunction(x.then);\n};\n/** @ignore */\nexport const isObservable = (x) => {\n return isObject(x) && isFunction(x.subscribe);\n};\n/** @ignore */\nexport const isIterable = (x) => {\n return isObject(x) && isFunction(x[Symbol.iterator]);\n};\n/** @ignore */\nexport const isAsyncIterable = (x) => {\n return isObject(x) && isFunction(x[Symbol.asyncIterator]);\n};\n/** @ignore */\nexport const isArrowJSON = (x) => {\n return isObject(x) && isObject(x['schema']);\n};\n/** @ignore */\nexport const isArrayLike = (x) => {\n return isObject(x) && isNumber(x['length']);\n};\n/** @ignore */\nexport const isIteratorResult = (x) => {\n return isObject(x) && ('done' in x) && ('value' in x);\n};\n/** @ignore */\nexport const isUnderlyingSink = (x) => {\n return isObject(x) &&\n isFunction(x['abort']) &&\n isFunction(x['close']) &&\n isFunction(x['start']) &&\n isFunction(x['write']);\n};\n/** @ignore */\nexport const isFileHandle = (x) => {\n return isObject(x) && isFunction(x['stat']) && isNumber(x['fd']);\n};\n/** @ignore */\nexport const isFSReadStream = (x) => {\n return isReadableNodeStream(x) && isNumber(x['bytesRead']);\n};\n/** @ignore */\nexport const isFetchResponse = (x) => {\n return isObject(x) && isReadableDOMStream(x['body']);\n};\nconst isReadableInterop = (x) => ('_getDOMStream' in x && '_getNodeStream' in x);\n/** @ignore */\nexport const isWritableDOMStream = (x) => {\n return isObject(x) &&\n isFunction(x['abort']) &&\n isFunction(x['getWriter']) &&\n !isReadableInterop(x);\n};\n/** @ignore */\nexport const isReadableDOMStream = (x) => {\n return isObject(x) &&\n isFunction(x['cancel']) &&\n isFunction(x['getReader']) &&\n !isReadableInterop(x);\n};\n/** @ignore */\nexport const isWritableNodeStream = (x) => {\n return isObject(x) &&\n isFunction(x['end']) &&\n isFunction(x['write']) &&\n isBoolean(x['writable']) &&\n !isReadableInterop(x);\n};\n/** @ignore */\nexport const isReadableNodeStream = (x) => {\n return isObject(x) &&\n isFunction(x['read']) &&\n isFunction(x['pipe']) &&\n isBoolean(x['readable']) &&\n !isReadableInterop(x);\n};\n/** @ignore */\nexport const isFlatbuffersByteBuffer = (x) => {\n return isObject(x) &&\n isFunction(x['clear']) &&\n isFunction(x['bytes']) &&\n isFunction(x['position']) &&\n isFunction(x['setPosition']) &&\n isFunction(x['capacity']) &&\n isFunction(x['getBufferIdentifier']) &&\n isFunction(x['createLong']);\n};\n\n//# sourceMappingURL=compat.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from \"tslib\";\nimport { encodeUtf8 } from '../util/utf8.mjs';\nimport { isPromise, isIterable, isAsyncIterable, isIteratorResult, isFlatbuffersByteBuffer, BigInt64Array, BigUint64Array } from './compat.mjs';\n/** @ignore */\nconst SharedArrayBuf = (typeof SharedArrayBuffer !== 'undefined' ? SharedArrayBuffer : ArrayBuffer);\n/** @ignore */\nfunction collapseContiguousByteRanges(chunks) {\n const result = chunks[0] ? [chunks[0]] : [];\n let xOffset, yOffset, xLen, yLen;\n for (let x, y, i = 0, j = 0, n = chunks.length; ++i < n;) {\n x = result[j];\n y = chunks[i];\n // continue if x and y don't share the same underlying ArrayBuffer, or if x isn't before y\n if (!x || !y || x.buffer !== y.buffer || y.byteOffset < x.byteOffset) {\n y && (result[++j] = y);\n continue;\n }\n ({ byteOffset: xOffset, byteLength: xLen } = x);\n ({ byteOffset: yOffset, byteLength: yLen } = y);\n // continue if the byte ranges of x and y aren't contiguous\n if ((xOffset + xLen) < yOffset || (yOffset + yLen) < xOffset) {\n y && (result[++j] = y);\n continue;\n }\n result[j] = new Uint8Array(x.buffer, xOffset, yOffset - xOffset + yLen);\n }\n return result;\n}\n/** @ignore */\nexport function memcpy(target, source, targetByteOffset = 0, sourceByteLength = source.byteLength) {\n const targetByteLength = target.byteLength;\n const dst = new Uint8Array(target.buffer, target.byteOffset, targetByteLength);\n const src = new Uint8Array(source.buffer, source.byteOffset, Math.min(sourceByteLength, targetByteLength));\n dst.set(src, targetByteOffset);\n return target;\n}\n/** @ignore */\nexport function joinUint8Arrays(chunks, size) {\n // collapse chunks that share the same underlying ArrayBuffer and whose byte ranges overlap,\n // to avoid unnecessarily copying the bytes to do this buffer join. This is a common case during\n // streaming, where we may be reading partial byte ranges out of the same underlying ArrayBuffer\n const result = collapseContiguousByteRanges(chunks);\n const byteLength = result.reduce((x, b) => x + b.byteLength, 0);\n let source, sliced, buffer;\n let offset = 0, index = -1;\n const length = Math.min(size || Number.POSITIVE_INFINITY, byteLength);\n for (const n = result.length; ++index < n;) {\n source = result[index];\n sliced = source.subarray(0, Math.min(source.length, length - offset));\n if (length <= (offset + sliced.length)) {\n if (sliced.length < source.length) {\n result[index] = source.subarray(sliced.length);\n }\n else if (sliced.length === source.length) {\n index++;\n }\n buffer ? memcpy(buffer, sliced, offset) : (buffer = sliced);\n break;\n }\n memcpy(buffer || (buffer = new Uint8Array(length)), sliced, offset);\n offset += sliced.length;\n }\n return [buffer || new Uint8Array(0), result.slice(index), byteLength - (buffer ? buffer.byteLength : 0)];\n}\n/** @ignore */\nexport function toArrayBufferView(ArrayBufferViewCtor, input) {\n let value = isIteratorResult(input) ? input.value : input;\n if (value instanceof ArrayBufferViewCtor) {\n if (ArrayBufferViewCtor === Uint8Array) {\n // Node's `Buffer` class passes the `instanceof Uint8Array` check, but we need\n // a real Uint8Array, since Buffer#slice isn't the same as Uint8Array#slice :/\n return new ArrayBufferViewCtor(value.buffer, value.byteOffset, value.byteLength);\n }\n return value;\n }\n if (!value) {\n return new ArrayBufferViewCtor(0);\n }\n if (typeof value === 'string') {\n value = encodeUtf8(value);\n }\n if (value instanceof ArrayBuffer) {\n return new ArrayBufferViewCtor(value);\n }\n if (value instanceof SharedArrayBuf) {\n return new ArrayBufferViewCtor(value);\n }\n if (isFlatbuffersByteBuffer(value)) {\n return toArrayBufferView(ArrayBufferViewCtor, value.bytes());\n }\n return !ArrayBuffer.isView(value) ? ArrayBufferViewCtor.from(value) : (value.byteLength <= 0 ? new ArrayBufferViewCtor(0)\n : new ArrayBufferViewCtor(value.buffer, value.byteOffset, value.byteLength / ArrayBufferViewCtor.BYTES_PER_ELEMENT));\n}\n/** @ignore */ export const toInt8Array = (input) => toArrayBufferView(Int8Array, input);\n/** @ignore */ export const toInt16Array = (input) => toArrayBufferView(Int16Array, input);\n/** @ignore */ export const toInt32Array = (input) => toArrayBufferView(Int32Array, input);\n/** @ignore */ export const toBigInt64Array = (input) => toArrayBufferView(BigInt64Array, input);\n/** @ignore */ export const toUint8Array = (input) => toArrayBufferView(Uint8Array, input);\n/** @ignore */ export const toUint16Array = (input) => toArrayBufferView(Uint16Array, input);\n/** @ignore */ export const toUint32Array = (input) => toArrayBufferView(Uint32Array, input);\n/** @ignore */ export const toBigUint64Array = (input) => toArrayBufferView(BigUint64Array, input);\n/** @ignore */ export const toFloat32Array = (input) => toArrayBufferView(Float32Array, input);\n/** @ignore */ export const toFloat64Array = (input) => toArrayBufferView(Float64Array, input);\n/** @ignore */ export const toUint8ClampedArray = (input) => toArrayBufferView(Uint8ClampedArray, input);\n/** @ignore */\nconst pump = (iterator) => { iterator.next(); return iterator; };\n/** @ignore */\nexport function* toArrayBufferViewIterator(ArrayCtor, source) {\n const wrap = function* (x) { yield x; };\n const buffers = (typeof source === 'string') ? wrap(source)\n : (ArrayBuffer.isView(source)) ? wrap(source)\n : (source instanceof ArrayBuffer) ? wrap(source)\n : (source instanceof SharedArrayBuf) ? wrap(source)\n : !isIterable(source) ? wrap(source) : source;\n yield* pump((function* (it) {\n let r = null;\n do {\n r = it.next(yield toArrayBufferView(ArrayCtor, r));\n } while (!r.done);\n })(buffers[Symbol.iterator]()));\n return new ArrayCtor();\n}\n/** @ignore */ export const toInt8ArrayIterator = (input) => toArrayBufferViewIterator(Int8Array, input);\n/** @ignore */ export const toInt16ArrayIterator = (input) => toArrayBufferViewIterator(Int16Array, input);\n/** @ignore */ export const toInt32ArrayIterator = (input) => toArrayBufferViewIterator(Int32Array, input);\n/** @ignore */ export const toUint8ArrayIterator = (input) => toArrayBufferViewIterator(Uint8Array, input);\n/** @ignore */ export const toUint16ArrayIterator = (input) => toArrayBufferViewIterator(Uint16Array, input);\n/** @ignore */ export const toUint32ArrayIterator = (input) => toArrayBufferViewIterator(Uint32Array, input);\n/** @ignore */ export const toFloat32ArrayIterator = (input) => toArrayBufferViewIterator(Float32Array, input);\n/** @ignore */ export const toFloat64ArrayIterator = (input) => toArrayBufferViewIterator(Float64Array, input);\n/** @ignore */ export const toUint8ClampedArrayIterator = (input) => toArrayBufferViewIterator(Uint8ClampedArray, input);\n/** @ignore */\nexport function toArrayBufferViewAsyncIterator(ArrayCtor, source) {\n return __asyncGenerator(this, arguments, function* toArrayBufferViewAsyncIterator_1() {\n // if a Promise, unwrap the Promise and iterate the resolved value\n if (isPromise(source)) {\n return yield __await(yield __await(yield* __asyncDelegator(__asyncValues(toArrayBufferViewAsyncIterator(ArrayCtor, yield __await(source))))));\n }\n const wrap = function (x) { return __asyncGenerator(this, arguments, function* () { yield yield __await(yield __await(x)); }); };\n const emit = function (source) {\n return __asyncGenerator(this, arguments, function* () {\n yield __await(yield* __asyncDelegator(__asyncValues(pump((function* (it) {\n let r = null;\n do {\n r = it.next(yield r === null || r === void 0 ? void 0 : r.value);\n } while (!r.done);\n })(source[Symbol.iterator]())))));\n });\n };\n const buffers = (typeof source === 'string') ? wrap(source) // if string, wrap in an AsyncIterableIterator\n : (ArrayBuffer.isView(source)) ? wrap(source) // if TypedArray, wrap in an AsyncIterableIterator\n : (source instanceof ArrayBuffer) ? wrap(source) // if ArrayBuffer, wrap in an AsyncIterableIterator\n : (source instanceof SharedArrayBuf) ? wrap(source) // if SharedArrayBuffer, wrap in an AsyncIterableIterator\n : isIterable(source) ? emit(source) // If Iterable, wrap in an AsyncIterableIterator and compose the `next` values\n : !isAsyncIterable(source) ? wrap(source) // If not an AsyncIterable, treat as a sentinel and wrap in an AsyncIterableIterator\n : source; // otherwise if AsyncIterable, use it\n yield __await(// otherwise if AsyncIterable, use it\n yield* __asyncDelegator(__asyncValues(pump((function (it) {\n return __asyncGenerator(this, arguments, function* () {\n let r = null;\n do {\n r = yield __await(it.next(yield yield __await(toArrayBufferView(ArrayCtor, r))));\n } while (!r.done);\n });\n })(buffers[Symbol.asyncIterator]())))));\n return yield __await(new ArrayCtor());\n });\n}\n/** @ignore */ export const toInt8ArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Int8Array, input);\n/** @ignore */ export const toInt16ArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Int16Array, input);\n/** @ignore */ export const toInt32ArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Int32Array, input);\n/** @ignore */ export const toUint8ArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Uint8Array, input);\n/** @ignore */ export const toUint16ArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Uint16Array, input);\n/** @ignore */ export const toUint32ArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Uint32Array, input);\n/** @ignore */ export const toFloat32ArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Float32Array, input);\n/** @ignore */ export const toFloat64ArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Float64Array, input);\n/** @ignore */ export const toUint8ClampedArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Uint8ClampedArray, input);\n/** @ignore */\nexport function rebaseValueOffsets(offset, length, valueOffsets) {\n // If we have a non-zero offset, create a new offsets array with the values\n // shifted by the start offset, such that the new start offset is 0\n if (offset !== 0) {\n valueOffsets = valueOffsets.slice(0, length + 1);\n for (let i = -1; ++i <= length;) {\n valueOffsets[i] += offset;\n }\n }\n return valueOffsets;\n}\n/** @ignore */\nexport function compareArrayLike(a, b) {\n let i = 0;\n const n = a.length;\n if (n !== b.length) {\n return false;\n }\n if (n > 0) {\n do {\n if (a[i] !== b[i]) {\n return false;\n }\n } while (++i < n);\n }\n return true;\n}\n\n//# sourceMappingURL=buffer.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { __asyncGenerator, __await, __awaiter } from \"tslib\";\nimport { toUint8Array, joinUint8Arrays, toUint8ArrayIterator, toUint8ArrayAsyncIterator } from '../util/buffer.mjs';\n/** @ignore */\nexport default {\n fromIterable(source) {\n return pump(fromIterable(source));\n },\n fromAsyncIterable(source) {\n return pump(fromAsyncIterable(source));\n },\n fromDOMStream(source) {\n return pump(fromDOMStream(source));\n },\n fromNodeStream(stream) {\n return pump(fromNodeStream(stream));\n },\n // @ts-ignore\n toDOMStream(source, options) {\n throw new Error(`\"toDOMStream\" not available in this environment`);\n },\n // @ts-ignore\n toNodeStream(source, options) {\n throw new Error(`\"toNodeStream\" not available in this environment`);\n },\n};\n/** @ignore */\nconst pump = (iterator) => { iterator.next(); return iterator; };\n/** @ignore */\nfunction* fromIterable(source) {\n let done, threw = false;\n let buffers = [], buffer;\n let cmd, size, bufferLength = 0;\n function byteRange() {\n if (cmd === 'peek') {\n return joinUint8Arrays(buffers, size)[0];\n }\n [buffer, buffers, bufferLength] = joinUint8Arrays(buffers, size);\n return buffer;\n }\n // Yield so the caller can inject the read command before creating the source Iterator\n ({ cmd, size } = yield null);\n // initialize the iterator\n const it = toUint8ArrayIterator(source)[Symbol.iterator]();\n try {\n do {\n // read the next value\n ({ done, value: buffer } = Number.isNaN(size - bufferLength) ?\n it.next() : it.next(size - bufferLength));\n // if chunk is not null or empty, push it onto the queue\n if (!done && buffer.byteLength > 0) {\n buffers.push(buffer);\n bufferLength += buffer.byteLength;\n }\n // If we have enough bytes in our buffer, yield chunks until we don't\n if (done || size <= bufferLength) {\n do {\n ({ cmd, size } = yield byteRange());\n } while (size < bufferLength);\n }\n } while (!done);\n }\n catch (e) {\n (threw = true) && (typeof it.throw === 'function') && (it.throw(e));\n }\n finally {\n (threw === false) && (typeof it.return === 'function') && (it.return(null));\n }\n return null;\n}\n/** @ignore */\nfunction fromAsyncIterable(source) {\n return __asyncGenerator(this, arguments, function* fromAsyncIterable_1() {\n let done, threw = false;\n let buffers = [], buffer;\n let cmd, size, bufferLength = 0;\n function byteRange() {\n if (cmd === 'peek') {\n return joinUint8Arrays(buffers, size)[0];\n }\n [buffer, buffers, bufferLength] = joinUint8Arrays(buffers, size);\n return buffer;\n }\n // Yield so the caller can inject the read command before creating the source AsyncIterator\n ({ cmd, size } = (yield yield __await(null)));\n // initialize the iterator\n const it = toUint8ArrayAsyncIterator(source)[Symbol.asyncIterator]();\n try {\n do {\n // read the next value\n ({ done, value: buffer } = Number.isNaN(size - bufferLength)\n ? yield __await(it.next())\n : yield __await(it.next(size - bufferLength)));\n // if chunk is not null or empty, push it onto the queue\n if (!done && buffer.byteLength > 0) {\n buffers.push(buffer);\n bufferLength += buffer.byteLength;\n }\n // If we have enough bytes in our buffer, yield chunks until we don't\n if (done || size <= bufferLength) {\n do {\n ({ cmd, size } = yield yield __await(byteRange()));\n } while (size < bufferLength);\n }\n } while (!done);\n }\n catch (e) {\n (threw = true) && (typeof it.throw === 'function') && (yield __await(it.throw(e)));\n }\n finally {\n (threw === false) && (typeof it.return === 'function') && (yield __await(it.return(new Uint8Array(0))));\n }\n return yield __await(null);\n });\n}\n// All this manual Uint8Array chunk management can be avoided if/when engines\n// add support for ArrayBuffer.transfer() or ArrayBuffer.prototype.realloc():\n// https://github.com/domenic/proposal-arraybuffer-transfer\n/** @ignore */\nfunction fromDOMStream(source) {\n return __asyncGenerator(this, arguments, function* fromDOMStream_1() {\n let done = false, threw = false;\n let buffers = [], buffer;\n let cmd, size, bufferLength = 0;\n function byteRange() {\n if (cmd === 'peek') {\n return joinUint8Arrays(buffers, size)[0];\n }\n [buffer, buffers, bufferLength] = joinUint8Arrays(buffers, size);\n return buffer;\n }\n // Yield so the caller can inject the read command before we establish the ReadableStream lock\n ({ cmd, size } = yield yield __await(null));\n // initialize the reader and lock the stream\n const it = new AdaptiveByteReader(source);\n try {\n do {\n // read the next value\n ({ done, value: buffer } = Number.isNaN(size - bufferLength)\n ? yield __await(it['read']())\n : yield __await(it['read'](size - bufferLength)));\n // if chunk is not null or empty, push it onto the queue\n if (!done && buffer.byteLength > 0) {\n buffers.push(toUint8Array(buffer));\n bufferLength += buffer.byteLength;\n }\n // If we have enough bytes in our buffer, yield chunks until we don't\n if (done || size <= bufferLength) {\n do {\n ({ cmd, size } = yield yield __await(byteRange()));\n } while (size < bufferLength);\n }\n } while (!done);\n }\n catch (e) {\n (threw = true) && (yield __await(it['cancel'](e)));\n }\n finally {\n (threw === false) ? (yield __await(it['cancel']()))\n : source['locked'] && it.releaseLock();\n }\n return yield __await(null);\n });\n}\n/** @ignore */\nclass AdaptiveByteReader {\n constructor(source) {\n this.source = source;\n this.reader = null;\n this.reader = this.source['getReader']();\n // We have to catch and swallow errors here to avoid uncaught promise rejection exceptions\n // that seem to be raised when we call `releaseLock()` on this reader. I'm still mystified\n // about why these errors are raised, but I'm sure there's some important spec reason that\n // I haven't considered. I hate to employ such an anti-pattern here, but it seems like the\n // only solution in this case :/\n this.reader['closed'].catch(() => { });\n }\n get closed() {\n return this.reader ? this.reader['closed'].catch(() => { }) : Promise.resolve();\n }\n releaseLock() {\n if (this.reader) {\n this.reader.releaseLock();\n }\n this.reader = null;\n }\n cancel(reason) {\n return __awaiter(this, void 0, void 0, function* () {\n const { reader, source } = this;\n reader && (yield reader['cancel'](reason).catch(() => { }));\n source && (source['locked'] && this.releaseLock());\n });\n }\n read(size) {\n return __awaiter(this, void 0, void 0, function* () {\n if (size === 0) {\n return { done: this.reader == null, value: new Uint8Array(0) };\n }\n const result = yield this.reader.read();\n !result.done && (result.value = toUint8Array(result));\n return result;\n });\n }\n}\n/** @ignore */\nconst onEvent = (stream, event) => {\n const handler = (_) => resolve([event, _]);\n let resolve;\n return [event, handler, new Promise((r) => (resolve = r) && stream['once'](event, handler))];\n};\n/** @ignore */\nfunction fromNodeStream(stream) {\n return __asyncGenerator(this, arguments, function* fromNodeStream_1() {\n const events = [];\n let event = 'error';\n let done = false, err = null;\n let cmd, size, bufferLength = 0;\n let buffers = [], buffer;\n function byteRange() {\n if (cmd === 'peek') {\n return joinUint8Arrays(buffers, size)[0];\n }\n [buffer, buffers, bufferLength] = joinUint8Arrays(buffers, size);\n return buffer;\n }\n // Yield so the caller can inject the read command before we\n // add the listener for the source stream's 'readable' event.\n ({ cmd, size } = yield yield __await(null));\n // ignore stdin if it's a TTY\n if (stream['isTTY']) {\n yield yield __await(new Uint8Array(0));\n return yield __await(null);\n }\n try {\n // initialize the stream event handlers\n events[0] = onEvent(stream, 'end');\n events[1] = onEvent(stream, 'error');\n do {\n events[2] = onEvent(stream, 'readable');\n // wait on the first message event from the stream\n [event, err] = yield __await(Promise.race(events.map((x) => x[2])));\n // if the stream emitted an Error, rethrow it\n if (event === 'error') {\n break;\n }\n if (!(done = event === 'end')) {\n // If the size is NaN, request to read everything in the stream's internal buffer\n if (!Number.isFinite(size - bufferLength)) {\n buffer = toUint8Array(stream['read']());\n }\n else {\n buffer = toUint8Array(stream['read'](size - bufferLength));\n // If the byteLength is 0, then the requested amount is more than the stream has\n // in its internal buffer. In this case the stream needs a \"kick\" to tell it to\n // continue emitting readable events, so request to read everything the stream\n // has in its internal buffer right now.\n if (buffer.byteLength < (size - bufferLength)) {\n buffer = toUint8Array(stream['read']());\n }\n }\n // if chunk is not null or empty, push it onto the queue\n if (buffer.byteLength > 0) {\n buffers.push(buffer);\n bufferLength += buffer.byteLength;\n }\n }\n // If we have enough bytes in our buffer, yield chunks until we don't\n if (done || size <= bufferLength) {\n do {\n ({ cmd, size } = yield yield __await(byteRange()));\n } while (size < bufferLength);\n }\n } while (!done);\n }\n finally {\n yield __await(cleanup(events, event === 'error' ? err : null));\n }\n return yield __await(null);\n function cleanup(events, err) {\n buffer = buffers = null;\n return new Promise((resolve, reject) => {\n for (const [evt, fn] of events) {\n stream['off'](evt, fn);\n }\n try {\n // Some stream implementations don't call the destroy callback,\n // because it's really a node-internal API. Just calling `destroy`\n // here should be enough to conform to the ReadableStream contract\n const destroy = stream['destroy'];\n destroy && destroy.call(stream, err);\n err = undefined;\n }\n catch (e) {\n err = e || err;\n }\n finally {\n err != null ? reject(err) : resolve();\n }\n });\n }\n });\n}\n\n//# sourceMappingURL=adapters.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\n////\n//\n// A few enums copied from `fb/Schema.ts` and `fb/Message.ts` because Webpack\n// v4 doesn't seem to be able to tree-shake the rest of those exports.\n//\n// We will have to keep these enums in sync when we re-generate the flatbuffers\n// code from the shchemas. See js/DEVELOP.md for info on how to run flatbuffers\n// code generation.\n//\n////\n/**\n * Logical types, vector layouts, and schemas\n *\n * @enum {number}\n */\nexport var MetadataVersion;\n(function (MetadataVersion) {\n /**\n * 0.1.0 (October 2016).\n */\n MetadataVersion[MetadataVersion[\"V1\"] = 0] = \"V1\";\n /**\n * 0.2.0 (February 2017). Non-backwards compatible with V1.\n */\n MetadataVersion[MetadataVersion[\"V2\"] = 1] = \"V2\";\n /**\n * 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2.\n */\n MetadataVersion[MetadataVersion[\"V3\"] = 2] = \"V3\";\n /**\n * >= 0.8.0 (December 2017). Non-backwards compatible with V3.\n */\n MetadataVersion[MetadataVersion[\"V4\"] = 3] = \"V4\";\n /**\n * >= 1.0.0 (July 2020. Backwards compatible with V4 (V5 readers can read V4\n * metadata and IPC messages). Implementations are recommended to provide a\n * V4 compatibility mode with V5 format changes disabled.\n *\n * Incompatible changes between V4 and V5:\n * - Union buffer layout has changed. In V5, Unions don't have a validity\n * bitmap buffer.\n */\n MetadataVersion[MetadataVersion[\"V5\"] = 4] = \"V5\";\n})(MetadataVersion || (MetadataVersion = {}));\n/**\n * @enum {number}\n */\nexport var UnionMode;\n(function (UnionMode) {\n UnionMode[UnionMode[\"Sparse\"] = 0] = \"Sparse\";\n UnionMode[UnionMode[\"Dense\"] = 1] = \"Dense\";\n})(UnionMode || (UnionMode = {}));\n/**\n * @enum {number}\n */\nexport var Precision;\n(function (Precision) {\n Precision[Precision[\"HALF\"] = 0] = \"HALF\";\n Precision[Precision[\"SINGLE\"] = 1] = \"SINGLE\";\n Precision[Precision[\"DOUBLE\"] = 2] = \"DOUBLE\";\n})(Precision || (Precision = {}));\n/**\n * @enum {number}\n */\nexport var DateUnit;\n(function (DateUnit) {\n DateUnit[DateUnit[\"DAY\"] = 0] = \"DAY\";\n DateUnit[DateUnit[\"MILLISECOND\"] = 1] = \"MILLISECOND\";\n})(DateUnit || (DateUnit = {}));\n/**\n * @enum {number}\n */\nexport var TimeUnit;\n(function (TimeUnit) {\n TimeUnit[TimeUnit[\"SECOND\"] = 0] = \"SECOND\";\n TimeUnit[TimeUnit[\"MILLISECOND\"] = 1] = \"MILLISECOND\";\n TimeUnit[TimeUnit[\"MICROSECOND\"] = 2] = \"MICROSECOND\";\n TimeUnit[TimeUnit[\"NANOSECOND\"] = 3] = \"NANOSECOND\";\n})(TimeUnit || (TimeUnit = {}));\n/**\n * @enum {number}\n */\nexport var IntervalUnit;\n(function (IntervalUnit) {\n IntervalUnit[IntervalUnit[\"YEAR_MONTH\"] = 0] = \"YEAR_MONTH\";\n IntervalUnit[IntervalUnit[\"DAY_TIME\"] = 1] = \"DAY_TIME\";\n IntervalUnit[IntervalUnit[\"MONTH_DAY_NANO\"] = 2] = \"MONTH_DAY_NANO\";\n})(IntervalUnit || (IntervalUnit = {}));\n/**\n * ----------------------------------------------------------------------\n * The root Message type\n * This union enables us to easily send different message types without\n * redundant storage, and in the future we can easily add new message types.\n *\n * Arrow implementations do not need to implement all of the message types,\n * which may include experimental metadata types. For maximum compatibility,\n * it is best to send data using RecordBatch\n *\n * @enum {number}\n */\nexport var MessageHeader;\n(function (MessageHeader) {\n MessageHeader[MessageHeader[\"NONE\"] = 0] = \"NONE\";\n MessageHeader[MessageHeader[\"Schema\"] = 1] = \"Schema\";\n MessageHeader[MessageHeader[\"DictionaryBatch\"] = 2] = \"DictionaryBatch\";\n MessageHeader[MessageHeader[\"RecordBatch\"] = 3] = \"RecordBatch\";\n MessageHeader[MessageHeader[\"Tensor\"] = 4] = \"Tensor\";\n MessageHeader[MessageHeader[\"SparseTensor\"] = 5] = \"SparseTensor\";\n})(MessageHeader || (MessageHeader = {}));\n/**\n * Main data type enumeration.\n *\n * Data types in this library are all *logical*. They can be expressed as\n * either a primitive physical type (bytes or bits of some fixed size), a\n * nested type consisting of other data types, or another data type (e.g. a\n * timestamp encoded as an int64).\n *\n * **Note**: Only enum values 0-17 (NONE through Map) are written to an Arrow\n * IPC payload.\n *\n * The rest of the values are specified here so TypeScript can narrow the type\n * signatures further beyond the base Arrow Types. The Arrow DataTypes include\n * metadata like `bitWidth` that impact the type signatures of the values we\n * accept and return.\n *\n * For example, the `Int8Vector` reads 1-byte numbers from an `Int8Array`, an\n * `Int32Vector` reads a 4-byte number from an `Int32Array`, and an `Int64Vector`\n * reads a pair of 4-byte lo, hi 32-bit integers as a zero-copy slice from the\n * underlying `Int32Array`.\n *\n * Library consumers benefit by knowing the narrowest type, since we can ensure\n * the types across all public methods are propagated, and never bail to `any`.\n * These values are _never_ used at runtime, and they will _never_ be written\n * to the flatbuffers metadata of serialized Arrow IPC payloads.\n */\nexport var Type;\n(function (Type) {\n Type[Type[\"NONE\"] = 0] = \"NONE\";\n Type[Type[\"Null\"] = 1] = \"Null\";\n Type[Type[\"Int\"] = 2] = \"Int\";\n Type[Type[\"Float\"] = 3] = \"Float\";\n Type[Type[\"Binary\"] = 4] = \"Binary\";\n Type[Type[\"Utf8\"] = 5] = \"Utf8\";\n Type[Type[\"Bool\"] = 6] = \"Bool\";\n Type[Type[\"Decimal\"] = 7] = \"Decimal\";\n Type[Type[\"Date\"] = 8] = \"Date\";\n Type[Type[\"Time\"] = 9] = \"Time\";\n Type[Type[\"Timestamp\"] = 10] = \"Timestamp\";\n Type[Type[\"Interval\"] = 11] = \"Interval\";\n Type[Type[\"List\"] = 12] = \"List\";\n Type[Type[\"Struct\"] = 13] = \"Struct\";\n Type[Type[\"Union\"] = 14] = \"Union\";\n Type[Type[\"FixedSizeBinary\"] = 15] = \"FixedSizeBinary\";\n Type[Type[\"FixedSizeList\"] = 16] = \"FixedSizeList\";\n Type[Type[\"Map\"] = 17] = \"Map\";\n Type[Type[\"Dictionary\"] = -1] = \"Dictionary\";\n Type[Type[\"Int8\"] = -2] = \"Int8\";\n Type[Type[\"Int16\"] = -3] = \"Int16\";\n Type[Type[\"Int32\"] = -4] = \"Int32\";\n Type[Type[\"Int64\"] = -5] = \"Int64\";\n Type[Type[\"Uint8\"] = -6] = \"Uint8\";\n Type[Type[\"Uint16\"] = -7] = \"Uint16\";\n Type[Type[\"Uint32\"] = -8] = \"Uint32\";\n Type[Type[\"Uint64\"] = -9] = \"Uint64\";\n Type[Type[\"Float16\"] = -10] = \"Float16\";\n Type[Type[\"Float32\"] = -11] = \"Float32\";\n Type[Type[\"Float64\"] = -12] = \"Float64\";\n Type[Type[\"DateDay\"] = -13] = \"DateDay\";\n Type[Type[\"DateMillisecond\"] = -14] = \"DateMillisecond\";\n Type[Type[\"TimestampSecond\"] = -15] = \"TimestampSecond\";\n Type[Type[\"TimestampMillisecond\"] = -16] = \"TimestampMillisecond\";\n Type[Type[\"TimestampMicrosecond\"] = -17] = \"TimestampMicrosecond\";\n Type[Type[\"TimestampNanosecond\"] = -18] = \"TimestampNanosecond\";\n Type[Type[\"TimeSecond\"] = -19] = \"TimeSecond\";\n Type[Type[\"TimeMillisecond\"] = -20] = \"TimeMillisecond\";\n Type[Type[\"TimeMicrosecond\"] = -21] = \"TimeMicrosecond\";\n Type[Type[\"TimeNanosecond\"] = -22] = \"TimeNanosecond\";\n Type[Type[\"DenseUnion\"] = -23] = \"DenseUnion\";\n Type[Type[\"SparseUnion\"] = -24] = \"SparseUnion\";\n Type[Type[\"IntervalDayTime\"] = -25] = \"IntervalDayTime\";\n Type[Type[\"IntervalYearMonth\"] = -26] = \"IntervalYearMonth\";\n})(Type || (Type = {}));\nexport var BufferType;\n(function (BufferType) {\n /**\n * used in List type, Dense Union and variable length primitive types (String, Binary)\n */\n BufferType[BufferType[\"OFFSET\"] = 0] = \"OFFSET\";\n /**\n * actual data, either wixed width primitive types in slots or variable width delimited by an OFFSET vector\n */\n BufferType[BufferType[\"DATA\"] = 1] = \"DATA\";\n /**\n * Bit vector indicating if each value is null\n */\n BufferType[BufferType[\"VALIDITY\"] = 2] = \"VALIDITY\";\n /**\n * Type vector used in Union type\n */\n BufferType[BufferType[\"TYPE\"] = 3] = \"TYPE\";\n})(BufferType || (BufferType = {}));\n\n//# sourceMappingURL=enum.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { BigInt64Array, BigUint64Array } from './compat.mjs';\n/** @ignore */ const undf = void (0);\n/** @ignore */\nexport function valueToString(x) {\n if (x === null) {\n return 'null';\n }\n if (x === undf) {\n return 'undefined';\n }\n switch (typeof x) {\n case 'number': return `${x}`;\n case 'bigint': return `${x}`;\n case 'string': return `\"${x}\"`;\n }\n // If [Symbol.toPrimitive] is implemented (like in BN)\n // use it instead of JSON.stringify(). This ensures we\n // print BigInts, Decimals, and Binary in their native\n // representation\n if (typeof x[Symbol.toPrimitive] === 'function') {\n return x[Symbol.toPrimitive]('string');\n }\n if (ArrayBuffer.isView(x)) {\n if (x instanceof BigInt64Array || x instanceof BigUint64Array) {\n return `[${[...x].map(x => valueToString(x))}]`;\n }\n return `[${x}]`;\n }\n return ArrayBuffer.isView(x) ? `[${x}]` : JSON.stringify(x, (_, y) => typeof y === 'bigint' ? `${y}` : y);\n}\n\n//# sourceMappingURL=pretty.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { toArrayBufferView } from './buffer.mjs';\nimport { BigIntAvailable, BigInt64Array, BigUint64Array } from './compat.mjs';\n/** @ignore */\nexport const isArrowBigNumSymbol = Symbol.for('isArrowBigNum');\n/** @ignore */\nfunction BigNum(x, ...xs) {\n if (xs.length === 0) {\n return Object.setPrototypeOf(toArrayBufferView(this['TypedArray'], x), this.constructor.prototype);\n }\n return Object.setPrototypeOf(new this['TypedArray'](x, ...xs), this.constructor.prototype);\n}\nBigNum.prototype[isArrowBigNumSymbol] = true;\nBigNum.prototype.toJSON = function () { return `\"${bignumToString(this)}\"`; };\nBigNum.prototype.valueOf = function () { return bignumToNumber(this); };\nBigNum.prototype.toString = function () { return bignumToString(this); };\nBigNum.prototype[Symbol.toPrimitive] = function (hint = 'default') {\n switch (hint) {\n case 'number': return bignumToNumber(this);\n case 'string': return bignumToString(this);\n case 'default': return bignumToBigInt(this);\n }\n // @ts-ignore\n return bignumToString(this);\n};\n/** @ignore */\nfunction SignedBigNum(...args) { return BigNum.apply(this, args); }\n/** @ignore */\nfunction UnsignedBigNum(...args) { return BigNum.apply(this, args); }\n/** @ignore */\nfunction DecimalBigNum(...args) { return BigNum.apply(this, args); }\nObject.setPrototypeOf(SignedBigNum.prototype, Object.create(Int32Array.prototype));\nObject.setPrototypeOf(UnsignedBigNum.prototype, Object.create(Uint32Array.prototype));\nObject.setPrototypeOf(DecimalBigNum.prototype, Object.create(Uint32Array.prototype));\nObject.assign(SignedBigNum.prototype, BigNum.prototype, { 'constructor': SignedBigNum, 'signed': true, 'TypedArray': Int32Array, 'BigIntArray': BigInt64Array });\nObject.assign(UnsignedBigNum.prototype, BigNum.prototype, { 'constructor': UnsignedBigNum, 'signed': false, 'TypedArray': Uint32Array, 'BigIntArray': BigUint64Array });\nObject.assign(DecimalBigNum.prototype, BigNum.prototype, { 'constructor': DecimalBigNum, 'signed': true, 'TypedArray': Uint32Array, 'BigIntArray': BigUint64Array });\n/** @ignore */\nfunction bignumToNumber(bn) {\n const { buffer, byteOffset, length, 'signed': signed } = bn;\n const words = new BigUint64Array(buffer, byteOffset, length);\n const negative = signed && words[words.length - 1] & (BigInt(1) << BigInt(63));\n let number = negative ? BigInt(1) : BigInt(0);\n let i = BigInt(0);\n if (!negative) {\n for (const word of words) {\n number += word * (BigInt(1) << (BigInt(32) * i++));\n }\n }\n else {\n for (const word of words) {\n number += ~word * (BigInt(1) << (BigInt(32) * i++));\n }\n number *= BigInt(-1);\n }\n return number;\n}\n/** @ignore */\nexport let bignumToString;\n/** @ignore */\nexport let bignumToBigInt;\nif (!BigIntAvailable) {\n bignumToString = decimalToString;\n bignumToBigInt = bignumToString;\n}\nelse {\n bignumToBigInt = ((a) => a.byteLength === 8 ? new a['BigIntArray'](a.buffer, a.byteOffset, 1)[0] : decimalToString(a));\n bignumToString = ((a) => a.byteLength === 8 ? `${new a['BigIntArray'](a.buffer, a.byteOffset, 1)[0]}` : decimalToString(a));\n}\n/** @ignore */\nfunction decimalToString(a) {\n let digits = '';\n const base64 = new Uint32Array(2);\n let base32 = new Uint16Array(a.buffer, a.byteOffset, a.byteLength / 2);\n const checks = new Uint32Array((base32 = new Uint16Array(base32).reverse()).buffer);\n let i = -1;\n const n = base32.length - 1;\n do {\n for (base64[0] = base32[i = 0]; i < n;) {\n base32[i++] = base64[1] = base64[0] / 10;\n base64[0] = ((base64[0] - base64[1] * 10) << 16) + base32[i];\n }\n base32[i] = base64[1] = base64[0] / 10;\n base64[0] = base64[0] - base64[1] * 10;\n digits = `${base64[0]}${digits}`;\n } while (checks[0] || checks[1] || checks[2] || checks[3]);\n return digits !== null && digits !== void 0 ? digits : `0`;\n}\n/** @ignore */\nexport class BN {\n /** @nocollapse */\n static new(num, isSigned) {\n switch (isSigned) {\n case true: return new SignedBigNum(num);\n case false: return new UnsignedBigNum(num);\n }\n switch (num.constructor) {\n case Int8Array:\n case Int16Array:\n case Int32Array:\n case BigInt64Array:\n return new SignedBigNum(num);\n }\n if (num.byteLength === 16) {\n return new DecimalBigNum(num);\n }\n return new UnsignedBigNum(num);\n }\n /** @nocollapse */\n static signed(num) {\n return new SignedBigNum(num);\n }\n /** @nocollapse */\n static unsigned(num) {\n return new UnsignedBigNum(num);\n }\n /** @nocollapse */\n static decimal(num) {\n return new DecimalBigNum(num);\n }\n constructor(num, isSigned) {\n return BN.new(num, isSigned);\n }\n}\n\n//# sourceMappingURL=bn.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nvar _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;\nimport { BigInt64Array, BigUint64Array } from './util/compat.mjs';\nimport { Type, Precision, UnionMode, DateUnit, TimeUnit, IntervalUnit } from './enum.mjs';\n/**\n * An abstract base class for classes that encapsulate metadata about each of\n * the logical types that Arrow can represent.\n */\nexport class DataType {\n /** @nocollapse */ static isNull(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Null; }\n /** @nocollapse */ static isInt(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Int; }\n /** @nocollapse */ static isFloat(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Float; }\n /** @nocollapse */ static isBinary(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Binary; }\n /** @nocollapse */ static isUtf8(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Utf8; }\n /** @nocollapse */ static isBool(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Bool; }\n /** @nocollapse */ static isDecimal(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Decimal; }\n /** @nocollapse */ static isDate(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Date; }\n /** @nocollapse */ static isTime(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Time; }\n /** @nocollapse */ static isTimestamp(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Timestamp; }\n /** @nocollapse */ static isInterval(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Interval; }\n /** @nocollapse */ static isList(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.List; }\n /** @nocollapse */ static isStruct(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Struct; }\n /** @nocollapse */ static isUnion(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Union; }\n /** @nocollapse */ static isFixedSizeBinary(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.FixedSizeBinary; }\n /** @nocollapse */ static isFixedSizeList(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.FixedSizeList; }\n /** @nocollapse */ static isMap(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Map; }\n /** @nocollapse */ static isDictionary(x) { return (x === null || x === void 0 ? void 0 : x.typeId) === Type.Dictionary; }\n /** @nocollapse */ static isDenseUnion(x) { return DataType.isUnion(x) && x.mode === UnionMode.Dense; }\n /** @nocollapse */ static isSparseUnion(x) { return DataType.isUnion(x) && x.mode === UnionMode.Sparse; }\n get typeId() { return Type.NONE; }\n}\n_a = Symbol.toStringTag;\nDataType[_a] = ((proto) => {\n proto.children = null;\n proto.ArrayType = Array;\n return proto[Symbol.toStringTag] = 'DataType';\n})(DataType.prototype);\n/** @ignore */\nexport class Null extends DataType {\n toString() { return `Null`; }\n get typeId() { return Type.Null; }\n}\n_b = Symbol.toStringTag;\nNull[_b] = ((proto) => proto[Symbol.toStringTag] = 'Null')(Null.prototype);\n/** @ignore */\nclass Int_ extends DataType {\n constructor(isSigned, bitWidth) {\n super();\n this.isSigned = isSigned;\n this.bitWidth = bitWidth;\n }\n get typeId() { return Type.Int; }\n get ArrayType() {\n switch (this.bitWidth) {\n case 8: return this.isSigned ? Int8Array : Uint8Array;\n case 16: return this.isSigned ? Int16Array : Uint16Array;\n case 32: return this.isSigned ? Int32Array : Uint32Array;\n case 64: return this.isSigned ? BigInt64Array : BigUint64Array;\n }\n throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);\n }\n toString() { return `${this.isSigned ? `I` : `Ui`}nt${this.bitWidth}`; }\n}\n_c = Symbol.toStringTag;\nInt_[_c] = ((proto) => {\n proto.isSigned = null;\n proto.bitWidth = null;\n return proto[Symbol.toStringTag] = 'Int';\n})(Int_.prototype);\nexport { Int_ as Int };\n/** @ignore */\nexport class Int8 extends Int_ {\n constructor() { super(true, 8); }\n get ArrayType() { return Int8Array; }\n}\n/** @ignore */\nexport class Int16 extends Int_ {\n constructor() { super(true, 16); }\n get ArrayType() { return Int16Array; }\n}\n/** @ignore */\nexport class Int32 extends Int_ {\n constructor() { super(true, 32); }\n get ArrayType() { return Int32Array; }\n}\n/** @ignore */\nexport class Int64 extends Int_ {\n constructor() { super(true, 64); }\n get ArrayType() { return BigInt64Array; }\n}\n/** @ignore */\nexport class Uint8 extends Int_ {\n constructor() { super(false, 8); }\n get ArrayType() { return Uint8Array; }\n}\n/** @ignore */\nexport class Uint16 extends Int_ {\n constructor() { super(false, 16); }\n get ArrayType() { return Uint16Array; }\n}\n/** @ignore */\nexport class Uint32 extends Int_ {\n constructor() { super(false, 32); }\n get ArrayType() { return Uint32Array; }\n}\n/** @ignore */\nexport class Uint64 extends Int_ {\n constructor() { super(false, 64); }\n get ArrayType() { return BigUint64Array; }\n}\nObject.defineProperty(Int8.prototype, 'ArrayType', { value: Int8Array });\nObject.defineProperty(Int16.prototype, 'ArrayType', { value: Int16Array });\nObject.defineProperty(Int32.prototype, 'ArrayType', { value: Int32Array });\nObject.defineProperty(Int64.prototype, 'ArrayType', { value: BigInt64Array });\nObject.defineProperty(Uint8.prototype, 'ArrayType', { value: Uint8Array });\nObject.defineProperty(Uint16.prototype, 'ArrayType', { value: Uint16Array });\nObject.defineProperty(Uint32.prototype, 'ArrayType', { value: Uint32Array });\nObject.defineProperty(Uint64.prototype, 'ArrayType', { value: BigUint64Array });\n/** @ignore */\nexport class Float extends DataType {\n constructor(precision) {\n super();\n this.precision = precision;\n }\n get typeId() { return Type.Float; }\n get ArrayType() {\n switch (this.precision) {\n case Precision.HALF: return Uint16Array;\n case Precision.SINGLE: return Float32Array;\n case Precision.DOUBLE: return Float64Array;\n }\n // @ts-ignore\n throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);\n }\n toString() { return `Float${(this.precision << 5) || 16}`; }\n}\n_d = Symbol.toStringTag;\nFloat[_d] = ((proto) => {\n proto.precision = null;\n return proto[Symbol.toStringTag] = 'Float';\n})(Float.prototype);\n/** @ignore */\nexport class Float16 extends Float {\n constructor() { super(Precision.HALF); }\n}\n/** @ignore */\nexport class Float32 extends Float {\n constructor() { super(Precision.SINGLE); }\n}\n/** @ignore */\nexport class Float64 extends Float {\n constructor() { super(Precision.DOUBLE); }\n}\nObject.defineProperty(Float16.prototype, 'ArrayType', { value: Uint16Array });\nObject.defineProperty(Float32.prototype, 'ArrayType', { value: Float32Array });\nObject.defineProperty(Float64.prototype, 'ArrayType', { value: Float64Array });\n/** @ignore */\nexport class Binary extends DataType {\n constructor() {\n super();\n }\n get typeId() { return Type.Binary; }\n toString() { return `Binary`; }\n}\n_e = Symbol.toStringTag;\nBinary[_e] = ((proto) => {\n proto.ArrayType = Uint8Array;\n return proto[Symbol.toStringTag] = 'Binary';\n})(Binary.prototype);\n/** @ignore */\nexport class Utf8 extends DataType {\n constructor() {\n super();\n }\n get typeId() { return Type.Utf8; }\n toString() { return `Utf8`; }\n}\n_f = Symbol.toStringTag;\nUtf8[_f] = ((proto) => {\n proto.ArrayType = Uint8Array;\n return proto[Symbol.toStringTag] = 'Utf8';\n})(Utf8.prototype);\n/** @ignore */\nexport class Bool extends DataType {\n constructor() {\n super();\n }\n get typeId() { return Type.Bool; }\n toString() { return `Bool`; }\n}\n_g = Symbol.toStringTag;\nBool[_g] = ((proto) => {\n proto.ArrayType = Uint8Array;\n return proto[Symbol.toStringTag] = 'Bool';\n})(Bool.prototype);\n/** @ignore */\nexport class Decimal extends DataType {\n constructor(scale, precision, bitWidth = 128) {\n super();\n this.scale = scale;\n this.precision = precision;\n this.bitWidth = bitWidth;\n }\n get typeId() { return Type.Decimal; }\n toString() { return `Decimal[${this.precision}e${this.scale > 0 ? `+` : ``}${this.scale}]`; }\n}\n_h = Symbol.toStringTag;\nDecimal[_h] = ((proto) => {\n proto.scale = null;\n proto.precision = null;\n proto.ArrayType = Uint32Array;\n return proto[Symbol.toStringTag] = 'Decimal';\n})(Decimal.prototype);\n/** @ignore */\nexport class Date_ extends DataType {\n constructor(unit) {\n super();\n this.unit = unit;\n }\n get typeId() { return Type.Date; }\n toString() { return `Date${(this.unit + 1) * 32}<${DateUnit[this.unit]}>`; }\n}\n_j = Symbol.toStringTag;\nDate_[_j] = ((proto) => {\n proto.unit = null;\n proto.ArrayType = Int32Array;\n return proto[Symbol.toStringTag] = 'Date';\n})(Date_.prototype);\n/** @ignore */\nexport class DateDay extends Date_ {\n constructor() { super(DateUnit.DAY); }\n}\n/** @ignore */\nexport class DateMillisecond extends Date_ {\n constructor() { super(DateUnit.MILLISECOND); }\n}\n/** @ignore */\nclass Time_ extends DataType {\n constructor(unit, bitWidth) {\n super();\n this.unit = unit;\n this.bitWidth = bitWidth;\n }\n get typeId() { return Type.Time; }\n toString() { return `Time${this.bitWidth}<${TimeUnit[this.unit]}>`; }\n get ArrayType() {\n switch (this.bitWidth) {\n case 32: return Int32Array;\n case 64: return BigInt64Array;\n }\n // @ts-ignore\n throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);\n }\n}\n_k = Symbol.toStringTag;\nTime_[_k] = ((proto) => {\n proto.unit = null;\n proto.bitWidth = null;\n return proto[Symbol.toStringTag] = 'Time';\n})(Time_.prototype);\nexport { Time_ as Time };\n/** @ignore */\nexport class TimeSecond extends Time_ {\n constructor() { super(TimeUnit.SECOND, 32); }\n}\n/** @ignore */\nexport class TimeMillisecond extends Time_ {\n constructor() { super(TimeUnit.MILLISECOND, 32); }\n}\n/** @ignore */\nexport class TimeMicrosecond extends Time_ {\n constructor() { super(TimeUnit.MICROSECOND, 64); }\n}\n/** @ignore */\nexport class TimeNanosecond extends Time_ {\n constructor() { super(TimeUnit.NANOSECOND, 64); }\n}\n/** @ignore */\nclass Timestamp_ extends DataType {\n constructor(unit, timezone) {\n super();\n this.unit = unit;\n this.timezone = timezone;\n }\n get typeId() { return Type.Timestamp; }\n toString() { return `Timestamp<${TimeUnit[this.unit]}${this.timezone ? `, ${this.timezone}` : ``}>`; }\n}\n_l = Symbol.toStringTag;\nTimestamp_[_l] = ((proto) => {\n proto.unit = null;\n proto.timezone = null;\n proto.ArrayType = Int32Array;\n return proto[Symbol.toStringTag] = 'Timestamp';\n})(Timestamp_.prototype);\nexport { Timestamp_ as Timestamp };\n/** @ignore */\nexport class TimestampSecond extends Timestamp_ {\n constructor(timezone) { super(TimeUnit.SECOND, timezone); }\n}\n/** @ignore */\nexport class TimestampMillisecond extends Timestamp_ {\n constructor(timezone) { super(TimeUnit.MILLISECOND, timezone); }\n}\n/** @ignore */\nexport class TimestampMicrosecond extends Timestamp_ {\n constructor(timezone) { super(TimeUnit.MICROSECOND, timezone); }\n}\n/** @ignore */\nexport class TimestampNanosecond extends Timestamp_ {\n constructor(timezone) { super(TimeUnit.NANOSECOND, timezone); }\n}\n/** @ignore */\nclass Interval_ extends DataType {\n constructor(unit) {\n super();\n this.unit = unit;\n }\n get typeId() { return Type.Interval; }\n toString() { return `Interval<${IntervalUnit[this.unit]}>`; }\n}\n_m = Symbol.toStringTag;\nInterval_[_m] = ((proto) => {\n proto.unit = null;\n proto.ArrayType = Int32Array;\n return proto[Symbol.toStringTag] = 'Interval';\n})(Interval_.prototype);\nexport { Interval_ as Interval };\n/** @ignore */\nexport class IntervalDayTime extends Interval_ {\n constructor() { super(IntervalUnit.DAY_TIME); }\n}\n/** @ignore */\nexport class IntervalYearMonth extends Interval_ {\n constructor() { super(IntervalUnit.YEAR_MONTH); }\n}\n/** @ignore */\nexport class List extends DataType {\n constructor(child) {\n super();\n this.children = [child];\n }\n get typeId() { return Type.List; }\n toString() { return `List<${this.valueType}>`; }\n get valueType() { return this.children[0].type; }\n get valueField() { return this.children[0]; }\n get ArrayType() { return this.valueType.ArrayType; }\n}\n_o = Symbol.toStringTag;\nList[_o] = ((proto) => {\n proto.children = null;\n return proto[Symbol.toStringTag] = 'List';\n})(List.prototype);\n/** @ignore */\nexport class Struct extends DataType {\n constructor(children) {\n super();\n this.children = children;\n }\n get typeId() { return Type.Struct; }\n toString() { return `Struct<{${this.children.map((f) => `${f.name}:${f.type}`).join(`, `)}}>`; }\n}\n_p = Symbol.toStringTag;\nStruct[_p] = ((proto) => {\n proto.children = null;\n return proto[Symbol.toStringTag] = 'Struct';\n})(Struct.prototype);\n/** @ignore */\nclass Union_ extends DataType {\n constructor(mode, typeIds, children) {\n super();\n this.mode = mode;\n this.children = children;\n this.typeIds = typeIds = Int32Array.from(typeIds);\n this.typeIdToChildIndex = typeIds.reduce((typeIdToChildIndex, typeId, idx) => (typeIdToChildIndex[typeId] = idx) && typeIdToChildIndex || typeIdToChildIndex, Object.create(null));\n }\n get typeId() { return Type.Union; }\n toString() {\n return `${this[Symbol.toStringTag]}<${this.children.map((x) => `${x.type}`).join(` | `)}>`;\n }\n}\n_q = Symbol.toStringTag;\nUnion_[_q] = ((proto) => {\n proto.mode = null;\n proto.typeIds = null;\n proto.children = null;\n proto.typeIdToChildIndex = null;\n proto.ArrayType = Int8Array;\n return proto[Symbol.toStringTag] = 'Union';\n})(Union_.prototype);\nexport { Union_ as Union };\n/** @ignore */\nexport class DenseUnion extends Union_ {\n constructor(typeIds, children) {\n super(UnionMode.Dense, typeIds, children);\n }\n}\n/** @ignore */\nexport class SparseUnion extends Union_ {\n constructor(typeIds, children) {\n super(UnionMode.Sparse, typeIds, children);\n }\n}\n/** @ignore */\nexport class FixedSizeBinary extends DataType {\n constructor(byteWidth) {\n super();\n this.byteWidth = byteWidth;\n }\n get typeId() { return Type.FixedSizeBinary; }\n toString() { return `FixedSizeBinary[${this.byteWidth}]`; }\n}\n_r = Symbol.toStringTag;\nFixedSizeBinary[_r] = ((proto) => {\n proto.byteWidth = null;\n proto.ArrayType = Uint8Array;\n return proto[Symbol.toStringTag] = 'FixedSizeBinary';\n})(FixedSizeBinary.prototype);\n/** @ignore */\nexport class FixedSizeList extends DataType {\n constructor(listSize, child) {\n super();\n this.listSize = listSize;\n this.children = [child];\n }\n get typeId() { return Type.FixedSizeList; }\n get valueType() { return this.children[0].type; }\n get valueField() { return this.children[0]; }\n get ArrayType() { return this.valueType.ArrayType; }\n toString() { return `FixedSizeList[${this.listSize}]<${this.valueType}>`; }\n}\n_s = Symbol.toStringTag;\nFixedSizeList[_s] = ((proto) => {\n proto.children = null;\n proto.listSize = null;\n return proto[Symbol.toStringTag] = 'FixedSizeList';\n})(FixedSizeList.prototype);\n/** @ignore */\nexport class Map_ extends DataType {\n constructor(child, keysSorted = false) {\n super();\n this.children = [child];\n this.keysSorted = keysSorted;\n }\n get typeId() { return Type.Map; }\n get keyType() { return this.children[0].type.children[0].type; }\n get valueType() { return this.children[0].type.children[1].type; }\n get childType() { return this.children[0].type; }\n toString() { return `Map<{${this.children[0].type.children.map((f) => `${f.name}:${f.type}`).join(`, `)}}>`; }\n}\n_t = Symbol.toStringTag;\nMap_[_t] = ((proto) => {\n proto.children = null;\n proto.keysSorted = null;\n return proto[Symbol.toStringTag] = 'Map_';\n})(Map_.prototype);\n/** @ignore */\nconst getId = ((atomicDictionaryId) => () => ++atomicDictionaryId)(-1);\n/** @ignore */\nexport class Dictionary extends DataType {\n constructor(dictionary, indices, id, isOrdered) {\n super();\n this.indices = indices;\n this.dictionary = dictionary;\n this.isOrdered = isOrdered || false;\n this.id = id == null ? getId() : (typeof id === 'number' ? id : id.low);\n }\n get typeId() { return Type.Dictionary; }\n get children() { return this.dictionary.children; }\n get valueType() { return this.dictionary; }\n get ArrayType() { return this.dictionary.ArrayType; }\n toString() { return `Dictionary<${this.indices}, ${this.dictionary}>`; }\n}\n_u = Symbol.toStringTag;\nDictionary[_u] = ((proto) => {\n proto.id = null;\n proto.indices = null;\n proto.isOrdered = null;\n proto.dictionary = null;\n return proto[Symbol.toStringTag] = 'Dictionary';\n})(Dictionary.prototype);\n/** @ignore */\nexport function strideForType(type) {\n const t = type;\n switch (type.typeId) {\n case Type.Decimal: return type.bitWidth / 32;\n case Type.Timestamp: return 2;\n case Type.Date: return 1 + t.unit;\n case Type.Interval: return 1 + t.unit;\n // case Type.Int: return 1 + +((t as Int_).bitWidth > 32);\n // case Type.Time: return 1 + +((t as Time_).bitWidth > 32);\n case Type.FixedSizeList: return t.listSize;\n case Type.FixedSizeBinary: return t.byteWidth;\n default: return 1;\n }\n}\n\n//# sourceMappingURL=type.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Type, Precision, DateUnit, TimeUnit, IntervalUnit, UnionMode } from './enum.mjs';\nimport { DataType, } from './type.mjs';\nexport class Visitor {\n visitMany(nodes, ...args) {\n return nodes.map((node, i) => this.visit(node, ...args.map((x) => x[i])));\n }\n visit(...args) {\n return this.getVisitFn(args[0], false).apply(this, args);\n }\n getVisitFn(node, throwIfNotFound = true) {\n return getVisitFn(this, node, throwIfNotFound);\n }\n getVisitFnByTypeId(typeId, throwIfNotFound = true) {\n return getVisitFnByTypeId(this, typeId, throwIfNotFound);\n }\n visitNull(_node, ..._args) { return null; }\n visitBool(_node, ..._args) { return null; }\n visitInt(_node, ..._args) { return null; }\n visitFloat(_node, ..._args) { return null; }\n visitUtf8(_node, ..._args) { return null; }\n visitBinary(_node, ..._args) { return null; }\n visitFixedSizeBinary(_node, ..._args) { return null; }\n visitDate(_node, ..._args) { return null; }\n visitTimestamp(_node, ..._args) { return null; }\n visitTime(_node, ..._args) { return null; }\n visitDecimal(_node, ..._args) { return null; }\n visitList(_node, ..._args) { return null; }\n visitStruct(_node, ..._args) { return null; }\n visitUnion(_node, ..._args) { return null; }\n visitDictionary(_node, ..._args) { return null; }\n visitInterval(_node, ..._args) { return null; }\n visitFixedSizeList(_node, ..._args) { return null; }\n visitMap(_node, ..._args) { return null; }\n}\n/** @ignore */\nfunction getVisitFn(visitor, node, throwIfNotFound = true) {\n if (typeof node === 'number') {\n return getVisitFnByTypeId(visitor, node, throwIfNotFound);\n }\n if (typeof node === 'string' && (node in Type)) {\n return getVisitFnByTypeId(visitor, Type[node], throwIfNotFound);\n }\n if (node && (node instanceof DataType)) {\n return getVisitFnByTypeId(visitor, inferDType(node), throwIfNotFound);\n }\n if ((node === null || node === void 0 ? void 0 : node.type) && (node.type instanceof DataType)) {\n return getVisitFnByTypeId(visitor, inferDType(node.type), throwIfNotFound);\n }\n return getVisitFnByTypeId(visitor, Type.NONE, throwIfNotFound);\n}\n/** @ignore */\nfunction getVisitFnByTypeId(visitor, dtype, throwIfNotFound = true) {\n let fn = null;\n switch (dtype) {\n case Type.Null:\n fn = visitor.visitNull;\n break;\n case Type.Bool:\n fn = visitor.visitBool;\n break;\n case Type.Int:\n fn = visitor.visitInt;\n break;\n case Type.Int8:\n fn = visitor.visitInt8 || visitor.visitInt;\n break;\n case Type.Int16:\n fn = visitor.visitInt16 || visitor.visitInt;\n break;\n case Type.Int32:\n fn = visitor.visitInt32 || visitor.visitInt;\n break;\n case Type.Int64:\n fn = visitor.visitInt64 || visitor.visitInt;\n break;\n case Type.Uint8:\n fn = visitor.visitUint8 || visitor.visitInt;\n break;\n case Type.Uint16:\n fn = visitor.visitUint16 || visitor.visitInt;\n break;\n case Type.Uint32:\n fn = visitor.visitUint32 || visitor.visitInt;\n break;\n case Type.Uint64:\n fn = visitor.visitUint64 || visitor.visitInt;\n break;\n case Type.Float:\n fn = visitor.visitFloat;\n break;\n case Type.Float16:\n fn = visitor.visitFloat16 || visitor.visitFloat;\n break;\n case Type.Float32:\n fn = visitor.visitFloat32 || visitor.visitFloat;\n break;\n case Type.Float64:\n fn = visitor.visitFloat64 || visitor.visitFloat;\n break;\n case Type.Utf8:\n fn = visitor.visitUtf8;\n break;\n case Type.Binary:\n fn = visitor.visitBinary;\n break;\n case Type.FixedSizeBinary:\n fn = visitor.visitFixedSizeBinary;\n break;\n case Type.Date:\n fn = visitor.visitDate;\n break;\n case Type.DateDay:\n fn = visitor.visitDateDay || visitor.visitDate;\n break;\n case Type.DateMillisecond:\n fn = visitor.visitDateMillisecond || visitor.visitDate;\n break;\n case Type.Timestamp:\n fn = visitor.visitTimestamp;\n break;\n case Type.TimestampSecond:\n fn = visitor.visitTimestampSecond || visitor.visitTimestamp;\n break;\n case Type.TimestampMillisecond:\n fn = visitor.visitTimestampMillisecond || visitor.visitTimestamp;\n break;\n case Type.TimestampMicrosecond:\n fn = visitor.visitTimestampMicrosecond || visitor.visitTimestamp;\n break;\n case Type.TimestampNanosecond:\n fn = visitor.visitTimestampNanosecond || visitor.visitTimestamp;\n break;\n case Type.Time:\n fn = visitor.visitTime;\n break;\n case Type.TimeSecond:\n fn = visitor.visitTimeSecond || visitor.visitTime;\n break;\n case Type.TimeMillisecond:\n fn = visitor.visitTimeMillisecond || visitor.visitTime;\n break;\n case Type.TimeMicrosecond:\n fn = visitor.visitTimeMicrosecond || visitor.visitTime;\n break;\n case Type.TimeNanosecond:\n fn = visitor.visitTimeNanosecond || visitor.visitTime;\n break;\n case Type.Decimal:\n fn = visitor.visitDecimal;\n break;\n case Type.List:\n fn = visitor.visitList;\n break;\n case Type.Struct:\n fn = visitor.visitStruct;\n break;\n case Type.Union:\n fn = visitor.visitUnion;\n break;\n case Type.DenseUnion:\n fn = visitor.visitDenseUnion || visitor.visitUnion;\n break;\n case Type.SparseUnion:\n fn = visitor.visitSparseUnion || visitor.visitUnion;\n break;\n case Type.Dictionary:\n fn = visitor.visitDictionary;\n break;\n case Type.Interval:\n fn = visitor.visitInterval;\n break;\n case Type.IntervalDayTime:\n fn = visitor.visitIntervalDayTime || visitor.visitInterval;\n break;\n case Type.IntervalYearMonth:\n fn = visitor.visitIntervalYearMonth || visitor.visitInterval;\n break;\n case Type.FixedSizeList:\n fn = visitor.visitFixedSizeList;\n break;\n case Type.Map:\n fn = visitor.visitMap;\n break;\n }\n if (typeof fn === 'function')\n return fn;\n if (!throwIfNotFound)\n return () => null;\n throw new Error(`Unrecognized type '${Type[dtype]}'`);\n}\n/** @ignore */\nfunction inferDType(type) {\n switch (type.typeId) {\n case Type.Null: return Type.Null;\n case Type.Int: {\n const { bitWidth, isSigned } = type;\n switch (bitWidth) {\n case 8: return isSigned ? Type.Int8 : Type.Uint8;\n case 16: return isSigned ? Type.Int16 : Type.Uint16;\n case 32: return isSigned ? Type.Int32 : Type.Uint32;\n case 64: return isSigned ? Type.Int64 : Type.Uint64;\n }\n // @ts-ignore\n return Type.Int;\n }\n case Type.Float:\n switch (type.precision) {\n case Precision.HALF: return Type.Float16;\n case Precision.SINGLE: return Type.Float32;\n case Precision.DOUBLE: return Type.Float64;\n }\n // @ts-ignore\n return Type.Float;\n case Type.Binary: return Type.Binary;\n case Type.Utf8: return Type.Utf8;\n case Type.Bool: return Type.Bool;\n case Type.Decimal: return Type.Decimal;\n case Type.Time:\n switch (type.unit) {\n case TimeUnit.SECOND: return Type.TimeSecond;\n case TimeUnit.MILLISECOND: return Type.TimeMillisecond;\n case TimeUnit.MICROSECOND: return Type.TimeMicrosecond;\n case TimeUnit.NANOSECOND: return Type.TimeNanosecond;\n }\n // @ts-ignore\n return Type.Time;\n case Type.Timestamp:\n switch (type.unit) {\n case TimeUnit.SECOND: return Type.TimestampSecond;\n case TimeUnit.MILLISECOND: return Type.TimestampMillisecond;\n case TimeUnit.MICROSECOND: return Type.TimestampMicrosecond;\n case TimeUnit.NANOSECOND: return Type.TimestampNanosecond;\n }\n // @ts-ignore\n return Type.Timestamp;\n case Type.Date:\n switch (type.unit) {\n case DateUnit.DAY: return Type.DateDay;\n case DateUnit.MILLISECOND: return Type.DateMillisecond;\n }\n // @ts-ignore\n return Type.Date;\n case Type.Interval:\n switch (type.unit) {\n case IntervalUnit.DAY_TIME: return Type.IntervalDayTime;\n case IntervalUnit.YEAR_MONTH: return Type.IntervalYearMonth;\n }\n // @ts-ignore\n return Type.Interval;\n case Type.Map: return Type.Map;\n case Type.List: return Type.List;\n case Type.Struct: return Type.Struct;\n case Type.Union:\n switch (type.mode) {\n case UnionMode.Dense: return Type.DenseUnion;\n case UnionMode.Sparse: return Type.SparseUnion;\n }\n // @ts-ignore\n return Type.Union;\n case Type.FixedSizeBinary: return Type.FixedSizeBinary;\n case Type.FixedSizeList: return Type.FixedSizeList;\n case Type.Dictionary: return Type.Dictionary;\n }\n throw new Error(`Unrecognized type '${Type[type.typeId]}'`);\n}\n// Add these here so they're picked up by the externs creator\n// in the build, and closure-compiler doesn't minify them away\nVisitor.prototype.visitInt8 = null;\nVisitor.prototype.visitInt16 = null;\nVisitor.prototype.visitInt32 = null;\nVisitor.prototype.visitInt64 = null;\nVisitor.prototype.visitUint8 = null;\nVisitor.prototype.visitUint16 = null;\nVisitor.prototype.visitUint32 = null;\nVisitor.prototype.visitUint64 = null;\nVisitor.prototype.visitFloat16 = null;\nVisitor.prototype.visitFloat32 = null;\nVisitor.prototype.visitFloat64 = null;\nVisitor.prototype.visitDateDay = null;\nVisitor.prototype.visitDateMillisecond = null;\nVisitor.prototype.visitTimestampSecond = null;\nVisitor.prototype.visitTimestampMillisecond = null;\nVisitor.prototype.visitTimestampMicrosecond = null;\nVisitor.prototype.visitTimestampNanosecond = null;\nVisitor.prototype.visitTimeSecond = null;\nVisitor.prototype.visitTimeMillisecond = null;\nVisitor.prototype.visitTimeMicrosecond = null;\nVisitor.prototype.visitTimeNanosecond = null;\nVisitor.prototype.visitDenseUnion = null;\nVisitor.prototype.visitSparseUnion = null;\nVisitor.prototype.visitIntervalDayTime = null;\nVisitor.prototype.visitIntervalYearMonth = null;\n\n//# sourceMappingURL=visitor.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nconst f64 = new Float64Array(1);\nconst u32 = new Uint32Array(f64.buffer);\n/**\n * Convert uint16 (logically a float16) to a JS float64. Inspired by numpy's `npy_half_to_double`:\n * https://github.com/numpy/numpy/blob/5a5987291dc95376bb098be8d8e5391e89e77a2c/numpy/core/src/npymath/halffloat.c#L29\n * @param h {number} the uint16 to convert\n * @private\n * @ignore\n */\nexport function uint16ToFloat64(h) {\n const expo = (h & 0x7C00) >> 10;\n const sigf = (h & 0x03FF) / 1024;\n const sign = Math.pow((-1), ((h & 0x8000) >> 15));\n switch (expo) {\n case 0x1F: return sign * (sigf ? Number.NaN : 1 / 0);\n case 0x00: return sign * (sigf ? 6.103515625e-5 * sigf : 0);\n }\n return sign * (Math.pow(2, (expo - 15))) * (1 + sigf);\n}\n/**\n * Convert a float64 to uint16 (assuming the float64 is logically a float16). Inspired by numpy's `npy_double_to_half`:\n * https://github.com/numpy/numpy/blob/5a5987291dc95376bb098be8d8e5391e89e77a2c/numpy/core/src/npymath/halffloat.c#L43\n * @param d {number} The float64 to convert\n * @private\n * @ignore\n */\nexport function float64ToUint16(d) {\n if (d !== d) {\n return 0x7E00;\n } // NaN\n f64[0] = d;\n // Magic numbers:\n // 0x80000000 = 10000000 00000000 00000000 00000000 -- masks the 32nd bit\n // 0x7ff00000 = 01111111 11110000 00000000 00000000 -- masks the 21st-31st bits\n // 0x000fffff = 00000000 00001111 11111111 11111111 -- masks the 1st-20th bit\n const sign = (u32[1] & 0x80000000) >> 16 & 0xFFFF;\n let expo = (u32[1] & 0x7FF00000), sigf = 0x0000;\n if (expo >= 0x40F00000) {\n //\n // If exponent overflowed, the float16 is either NaN or Infinity.\n // Rules to propagate the sign bit: mantissa > 0 ? NaN : +/-Infinity\n //\n // Magic numbers:\n // 0x40F00000 = 01000000 11110000 00000000 00000000 -- 6-bit exponent overflow\n // 0x7C000000 = 01111100 00000000 00000000 00000000 -- masks the 27th-31st bits\n //\n // returns:\n // qNaN, aka 32256 decimal, 0x7E00 hex, or 01111110 00000000 binary\n // sNaN, aka 32000 decimal, 0x7D00 hex, or 01111101 00000000 binary\n // +inf, aka 31744 decimal, 0x7C00 hex, or 01111100 00000000 binary\n // -inf, aka 64512 decimal, 0xFC00 hex, or 11111100 00000000 binary\n //\n // If mantissa is greater than 23 bits, set to +Infinity like numpy\n if (u32[0] > 0) {\n expo = 0x7C00;\n }\n else {\n expo = (expo & 0x7C000000) >> 16;\n sigf = (u32[1] & 0x000FFFFF) >> 10;\n }\n }\n else if (expo <= 0x3F000000) {\n //\n // If exponent underflowed, the float is either signed zero or subnormal.\n //\n // Magic numbers:\n // 0x3F000000 = 00111111 00000000 00000000 00000000 -- 6-bit exponent underflow\n //\n sigf = 0x100000 + (u32[1] & 0x000FFFFF);\n sigf = 0x100000 + (sigf << ((expo >> 20) - 998)) >> 21;\n expo = 0;\n }\n else {\n //\n // No overflow or underflow, rebase the exponent and round the mantissa\n // Magic numbers:\n // 0x200 = 00000010 00000000 -- masks off the 10th bit\n //\n // Ensure the first mantissa bit (the 10th one) is 1 and round\n expo = (expo - 0x3F000000) >> 10;\n sigf = ((u32[1] & 0x000FFFFF) + 0x200) >> 10;\n }\n return sign | expo | sigf & 0xFFFF;\n}\n\n//# sourceMappingURL=math.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Vector } from '../vector.mjs';\nimport { Visitor } from '../visitor.mjs';\nimport { encodeUtf8 } from '../util/utf8.mjs';\nimport { float64ToUint16 } from '../util/math.mjs';\nimport { UnionMode, Precision, DateUnit, TimeUnit, IntervalUnit } from '../enum.mjs';\n/** @ignore */\nexport class SetVisitor extends Visitor {\n}\n/** @ignore */\nfunction wrapSet(fn) {\n return (data, _1, _2) => {\n if (data.setValid(_1, _2 != null)) {\n return fn(data, _1, _2);\n }\n };\n}\n/** @ignore */\nexport const setEpochMsToDays = (data, index, epochMs) => { data[index] = Math.trunc(epochMs / 86400000); };\n/** @ignore */\nexport const setEpochMsToMillisecondsLong = (data, index, epochMs) => {\n data[index] = Math.trunc(epochMs % 4294967296);\n data[index + 1] = Math.trunc(epochMs / 4294967296);\n};\n/** @ignore */\nexport const setEpochMsToMicrosecondsLong = (data, index, epochMs) => {\n data[index] = Math.trunc((epochMs * 1000) % 4294967296);\n data[index + 1] = Math.trunc((epochMs * 1000) / 4294967296);\n};\n/** @ignore */\nexport const setEpochMsToNanosecondsLong = (data, index, epochMs) => {\n data[index] = Math.trunc((epochMs * 1000000) % 4294967296);\n data[index + 1] = Math.trunc((epochMs * 1000000) / 4294967296);\n};\n/** @ignore */\nexport const setVariableWidthBytes = (values, valueOffsets, index, value) => {\n if (index + 1 < valueOffsets.length) {\n const { [index]: x, [index + 1]: y } = valueOffsets;\n values.set(value.subarray(0, y - x), x);\n }\n};\n/** @ignore */\nconst setBool = ({ offset, values }, index, val) => {\n const idx = offset + index;\n val ? (values[idx >> 3] |= (1 << (idx % 8))) // true\n : (values[idx >> 3] &= ~(1 << (idx % 8))); // false\n};\n/** @ignore */\nexport const setInt = ({ values }, index, value) => { values[index] = value; };\n/** @ignore */\nexport const setFloat = ({ values }, index, value) => { values[index] = value; };\n/** @ignore */\nexport const setFloat16 = ({ values }, index, value) => { values[index] = float64ToUint16(value); };\n/* istanbul ignore next */\n/** @ignore */\nexport const setAnyFloat = (data, index, value) => {\n switch (data.type.precision) {\n case Precision.HALF:\n return setFloat16(data, index, value);\n case Precision.SINGLE:\n case Precision.DOUBLE:\n return setFloat(data, index, value);\n }\n};\n/** @ignore */\nexport const setDateDay = ({ values }, index, value) => { setEpochMsToDays(values, index, value.valueOf()); };\n/** @ignore */\nexport const setDateMillisecond = ({ values }, index, value) => { setEpochMsToMillisecondsLong(values, index * 2, value.valueOf()); };\n/** @ignore */\nexport const setFixedSizeBinary = ({ stride, values }, index, value) => { values.set(value.subarray(0, stride), stride * index); };\n/** @ignore */\nconst setBinary = ({ values, valueOffsets }, index, value) => setVariableWidthBytes(values, valueOffsets, index, value);\n/** @ignore */\nconst setUtf8 = ({ values, valueOffsets }, index, value) => {\n setVariableWidthBytes(values, valueOffsets, index, encodeUtf8(value));\n};\n/* istanbul ignore next */\nexport const setDate = (data, index, value) => {\n data.type.unit === DateUnit.DAY\n ? setDateDay(data, index, value)\n : setDateMillisecond(data, index, value);\n};\n/** @ignore */\nexport const setTimestampSecond = ({ values }, index, value) => setEpochMsToMillisecondsLong(values, index * 2, value / 1000);\n/** @ignore */\nexport const setTimestampMillisecond = ({ values }, index, value) => setEpochMsToMillisecondsLong(values, index * 2, value);\n/** @ignore */\nexport const setTimestampMicrosecond = ({ values }, index, value) => setEpochMsToMicrosecondsLong(values, index * 2, value);\n/** @ignore */\nexport const setTimestampNanosecond = ({ values }, index, value) => setEpochMsToNanosecondsLong(values, index * 2, value);\n/* istanbul ignore next */\n/** @ignore */\nexport const setTimestamp = (data, index, value) => {\n switch (data.type.unit) {\n case TimeUnit.SECOND: return setTimestampSecond(data, index, value);\n case TimeUnit.MILLISECOND: return setTimestampMillisecond(data, index, value);\n case TimeUnit.MICROSECOND: return setTimestampMicrosecond(data, index, value);\n case TimeUnit.NANOSECOND: return setTimestampNanosecond(data, index, value);\n }\n};\n/** @ignore */\nexport const setTimeSecond = ({ values }, index, value) => { values[index] = value; };\n/** @ignore */\nexport const setTimeMillisecond = ({ values }, index, value) => { values[index] = value; };\n/** @ignore */\nexport const setTimeMicrosecond = ({ values }, index, value) => { values[index] = value; };\n/** @ignore */\nexport const setTimeNanosecond = ({ values }, index, value) => { values[index] = value; };\n/* istanbul ignore next */\n/** @ignore */\nexport const setTime = (data, index, value) => {\n switch (data.type.unit) {\n case TimeUnit.SECOND: return setTimeSecond(data, index, value);\n case TimeUnit.MILLISECOND: return setTimeMillisecond(data, index, value);\n case TimeUnit.MICROSECOND: return setTimeMicrosecond(data, index, value);\n case TimeUnit.NANOSECOND: return setTimeNanosecond(data, index, value);\n }\n};\n/** @ignore */\nexport const setDecimal = ({ values, stride }, index, value) => { values.set(value.subarray(0, stride), stride * index); };\n/** @ignore */\nconst setList = (data, index, value) => {\n const values = data.children[0];\n const valueOffsets = data.valueOffsets;\n const set = instance.getVisitFn(values);\n if (Array.isArray(value)) {\n for (let idx = -1, itr = valueOffsets[index], end = valueOffsets[index + 1]; itr < end;) {\n set(values, itr++, value[++idx]);\n }\n }\n else {\n for (let idx = -1, itr = valueOffsets[index], end = valueOffsets[index + 1]; itr < end;) {\n set(values, itr++, value.get(++idx));\n }\n }\n};\n/** @ignore */\nconst setMap = (data, index, value) => {\n const values = data.children[0];\n const { valueOffsets } = data;\n const set = instance.getVisitFn(values);\n let { [index]: idx, [index + 1]: end } = valueOffsets;\n const entries = value instanceof Map ? value.entries() : Object.entries(value);\n for (const val of entries) {\n set(values, idx, val);\n if (++idx >= end)\n break;\n }\n};\n/** @ignore */ const _setStructArrayValue = (o, v) => (set, c, _, i) => c && set(c, o, v[i]);\n/** @ignore */ const _setStructVectorValue = (o, v) => (set, c, _, i) => c && set(c, o, v.get(i));\n/** @ignore */ const _setStructMapValue = (o, v) => (set, c, f, _) => c && set(c, o, v.get(f.name));\n/** @ignore */ const _setStructObjectValue = (o, v) => (set, c, f, _) => c && set(c, o, v[f.name]);\n/** @ignore */\nconst setStruct = (data, index, value) => {\n const childSetters = data.type.children.map((f) => instance.getVisitFn(f.type));\n const set = value instanceof Map ? _setStructMapValue(index, value) :\n value instanceof Vector ? _setStructVectorValue(index, value) :\n Array.isArray(value) ? _setStructArrayValue(index, value) :\n _setStructObjectValue(index, value);\n // eslint-disable-next-line unicorn/no-array-for-each\n data.type.children.forEach((f, i) => set(childSetters[i], data.children[i], f, i));\n};\n/* istanbul ignore next */\n/** @ignore */\nconst setUnion = (data, index, value) => {\n data.type.mode === UnionMode.Dense ?\n setDenseUnion(data, index, value) :\n setSparseUnion(data, index, value);\n};\n/** @ignore */\nconst setDenseUnion = (data, index, value) => {\n const childIndex = data.type.typeIdToChildIndex[data.typeIds[index]];\n const child = data.children[childIndex];\n instance.visit(child, data.valueOffsets[index], value);\n};\n/** @ignore */\nconst setSparseUnion = (data, index, value) => {\n const childIndex = data.type.typeIdToChildIndex[data.typeIds[index]];\n const child = data.children[childIndex];\n instance.visit(child, index, value);\n};\n/** @ignore */\nconst setDictionary = (data, index, value) => {\n var _a;\n (_a = data.dictionary) === null || _a === void 0 ? void 0 : _a.set(data.values[index], value);\n};\n/* istanbul ignore next */\n/** @ignore */\nexport const setIntervalValue = (data, index, value) => {\n (data.type.unit === IntervalUnit.DAY_TIME)\n ? setIntervalDayTime(data, index, value)\n : setIntervalYearMonth(data, index, value);\n};\n/** @ignore */\nexport const setIntervalDayTime = ({ values }, index, value) => { values.set(value.subarray(0, 2), 2 * index); };\n/** @ignore */\nexport const setIntervalYearMonth = ({ values }, index, value) => { values[index] = (value[0] * 12) + (value[1] % 12); };\n/** @ignore */\nconst setFixedSizeList = (data, index, value) => {\n const { stride } = data;\n const child = data.children[0];\n const set = instance.getVisitFn(child);\n if (Array.isArray(value)) {\n for (let idx = -1, offset = index * stride; ++idx < stride;) {\n set(child, offset + idx, value[idx]);\n }\n }\n else {\n for (let idx = -1, offset = index * stride; ++idx < stride;) {\n set(child, offset + idx, value.get(idx));\n }\n }\n};\nSetVisitor.prototype.visitBool = wrapSet(setBool);\nSetVisitor.prototype.visitInt = wrapSet(setInt);\nSetVisitor.prototype.visitInt8 = wrapSet(setInt);\nSetVisitor.prototype.visitInt16 = wrapSet(setInt);\nSetVisitor.prototype.visitInt32 = wrapSet(setInt);\nSetVisitor.prototype.visitInt64 = wrapSet(setInt);\nSetVisitor.prototype.visitUint8 = wrapSet(setInt);\nSetVisitor.prototype.visitUint16 = wrapSet(setInt);\nSetVisitor.prototype.visitUint32 = wrapSet(setInt);\nSetVisitor.prototype.visitUint64 = wrapSet(setInt);\nSetVisitor.prototype.visitFloat = wrapSet(setAnyFloat);\nSetVisitor.prototype.visitFloat16 = wrapSet(setFloat16);\nSetVisitor.prototype.visitFloat32 = wrapSet(setFloat);\nSetVisitor.prototype.visitFloat64 = wrapSet(setFloat);\nSetVisitor.prototype.visitUtf8 = wrapSet(setUtf8);\nSetVisitor.prototype.visitBinary = wrapSet(setBinary);\nSetVisitor.prototype.visitFixedSizeBinary = wrapSet(setFixedSizeBinary);\nSetVisitor.prototype.visitDate = wrapSet(setDate);\nSetVisitor.prototype.visitDateDay = wrapSet(setDateDay);\nSetVisitor.prototype.visitDateMillisecond = wrapSet(setDateMillisecond);\nSetVisitor.prototype.visitTimestamp = wrapSet(setTimestamp);\nSetVisitor.prototype.visitTimestampSecond = wrapSet(setTimestampSecond);\nSetVisitor.prototype.visitTimestampMillisecond = wrapSet(setTimestampMillisecond);\nSetVisitor.prototype.visitTimestampMicrosecond = wrapSet(setTimestampMicrosecond);\nSetVisitor.prototype.visitTimestampNanosecond = wrapSet(setTimestampNanosecond);\nSetVisitor.prototype.visitTime = wrapSet(setTime);\nSetVisitor.prototype.visitTimeSecond = wrapSet(setTimeSecond);\nSetVisitor.prototype.visitTimeMillisecond = wrapSet(setTimeMillisecond);\nSetVisitor.prototype.visitTimeMicrosecond = wrapSet(setTimeMicrosecond);\nSetVisitor.prototype.visitTimeNanosecond = wrapSet(setTimeNanosecond);\nSetVisitor.prototype.visitDecimal = wrapSet(setDecimal);\nSetVisitor.prototype.visitList = wrapSet(setList);\nSetVisitor.prototype.visitStruct = wrapSet(setStruct);\nSetVisitor.prototype.visitUnion = wrapSet(setUnion);\nSetVisitor.prototype.visitDenseUnion = wrapSet(setDenseUnion);\nSetVisitor.prototype.visitSparseUnion = wrapSet(setSparseUnion);\nSetVisitor.prototype.visitDictionary = wrapSet(setDictionary);\nSetVisitor.prototype.visitInterval = wrapSet(setIntervalValue);\nSetVisitor.prototype.visitIntervalDayTime = wrapSet(setIntervalDayTime);\nSetVisitor.prototype.visitIntervalYearMonth = wrapSet(setIntervalYearMonth);\nSetVisitor.prototype.visitFixedSizeList = wrapSet(setFixedSizeList);\nSetVisitor.prototype.visitMap = wrapSet(setMap);\n/** @ignore */\nexport const instance = new SetVisitor();\n\n//# sourceMappingURL=set.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { valueToString } from '../util/pretty.mjs';\nimport { instance as getVisitor } from '../visitor/get.mjs';\nimport { instance as setVisitor } from '../visitor/set.mjs';\n/** @ignore */ const kParent = Symbol.for('parent');\n/** @ignore */ const kRowIndex = Symbol.for('rowIndex');\nexport class StructRow {\n constructor(parent, rowIndex) {\n this[kParent] = parent;\n this[kRowIndex] = rowIndex;\n return new Proxy(this, new StructRowProxyHandler());\n }\n toArray() { return Object.values(this.toJSON()); }\n toJSON() {\n const i = this[kRowIndex];\n const parent = this[kParent];\n const keys = parent.type.children;\n const json = {};\n for (let j = -1, n = keys.length; ++j < n;) {\n json[keys[j].name] = getVisitor.visit(parent.children[j], i);\n }\n return json;\n }\n toString() {\n return `{${[...this].map(([key, val]) => `${valueToString(key)}: ${valueToString(val)}`).join(', ')}}`;\n }\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return this.toString();\n }\n [Symbol.iterator]() {\n return new StructRowIterator(this[kParent], this[kRowIndex]);\n }\n}\nclass StructRowIterator {\n constructor(data, rowIndex) {\n this.childIndex = 0;\n this.children = data.children;\n this.rowIndex = rowIndex;\n this.childFields = data.type.children;\n this.numChildren = this.childFields.length;\n }\n [Symbol.iterator]() { return this; }\n next() {\n const i = this.childIndex;\n if (i < this.numChildren) {\n this.childIndex = i + 1;\n return {\n done: false,\n value: [\n this.childFields[i].name,\n getVisitor.visit(this.children[i], this.rowIndex)\n ]\n };\n }\n return { done: true, value: null };\n }\n}\nObject.defineProperties(StructRow.prototype, {\n [Symbol.toStringTag]: { enumerable: false, configurable: false, value: 'Row' },\n [kParent]: { writable: true, enumerable: false, configurable: false, value: null },\n [kRowIndex]: { writable: true, enumerable: false, configurable: false, value: -1 },\n});\nclass StructRowProxyHandler {\n isExtensible() { return false; }\n deleteProperty() { return false; }\n preventExtensions() { return true; }\n ownKeys(row) {\n return row[kParent].type.children.map((f) => f.name);\n }\n has(row, key) {\n return row[kParent].type.children.findIndex((f) => f.name === key) !== -1;\n }\n getOwnPropertyDescriptor(row, key) {\n if (row[kParent].type.children.findIndex((f) => f.name === key) !== -1) {\n return { writable: true, enumerable: true, configurable: true };\n }\n return;\n }\n get(row, key) {\n // Look up key in row first\n if (Reflect.has(row, key)) {\n return row[key];\n }\n const idx = row[kParent].type.children.findIndex((f) => f.name === key);\n if (idx !== -1) {\n const val = getVisitor.visit(row[kParent].children[idx], row[kRowIndex]);\n // Cache key/val lookups\n Reflect.set(row, key, val);\n return val;\n }\n }\n set(row, key, val) {\n const idx = row[kParent].type.children.findIndex((f) => f.name === key);\n if (idx !== -1) {\n setVisitor.visit(row[kParent].children[idx], row[kRowIndex], val);\n // Cache key/val lookups\n return Reflect.set(row, key, val);\n }\n else if (Reflect.has(row, key) || typeof key === 'symbol') {\n return Reflect.set(row, key, val);\n }\n return false;\n }\n}\n\n//# sourceMappingURL=struct.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { BN } from '../util/bn.mjs';\nimport { Vector } from '../vector.mjs';\nimport { Visitor } from '../visitor.mjs';\nimport { MapRow } from '../row/map.mjs';\nimport { StructRow } from '../row/struct.mjs';\nimport { decodeUtf8 } from '../util/utf8.mjs';\nimport { uint16ToFloat64 } from '../util/math.mjs';\nimport { UnionMode, Precision, DateUnit, TimeUnit, IntervalUnit } from '../enum.mjs';\n/** @ignore */\nexport class GetVisitor extends Visitor {\n}\n/** @ignore */\nfunction wrapGet(fn) {\n return (data, _1) => data.getValid(_1) ? fn(data, _1) : null;\n}\n/** @ignore */ const epochDaysToMs = (data, index) => 86400000 * data[index];\n/** @ignore */ const epochMillisecondsLongToMs = (data, index) => 4294967296 * (data[index + 1]) + (data[index] >>> 0);\n/** @ignore */ const epochMicrosecondsLongToMs = (data, index) => 4294967296 * (data[index + 1] / 1000) + ((data[index] >>> 0) / 1000);\n/** @ignore */ const epochNanosecondsLongToMs = (data, index) => 4294967296 * (data[index + 1] / 1000000) + ((data[index] >>> 0) / 1000000);\n/** @ignore */ const epochMillisecondsToDate = (epochMs) => new Date(epochMs);\n/** @ignore */ const epochDaysToDate = (data, index) => epochMillisecondsToDate(epochDaysToMs(data, index));\n/** @ignore */ const epochMillisecondsLongToDate = (data, index) => epochMillisecondsToDate(epochMillisecondsLongToMs(data, index));\n/** @ignore */\nconst getNull = (_data, _index) => null;\n/** @ignore */\nconst getVariableWidthBytes = (values, valueOffsets, index) => {\n if (index + 1 >= valueOffsets.length) {\n return null;\n }\n const x = valueOffsets[index];\n const y = valueOffsets[index + 1];\n return values.subarray(x, y);\n};\n/** @ignore */\nconst getBool = ({ offset, values }, index) => {\n const idx = offset + index;\n const byte = values[idx >> 3];\n return (byte & 1 << (idx % 8)) !== 0;\n};\n/** @ignore */\nconst getDateDay = ({ values }, index) => epochDaysToDate(values, index);\n/** @ignore */\nconst getDateMillisecond = ({ values }, index) => epochMillisecondsLongToDate(values, index * 2);\n/** @ignore */\nconst getNumeric = ({ stride, values }, index) => values[stride * index];\n/** @ignore */\nconst getFloat16 = ({ stride, values }, index) => uint16ToFloat64(values[stride * index]);\n/** @ignore */\nconst getBigInts = ({ values }, index) => values[index];\n/** @ignore */\nconst getFixedSizeBinary = ({ stride, values }, index) => values.subarray(stride * index, stride * (index + 1));\n/** @ignore */\nconst getBinary = ({ values, valueOffsets }, index) => getVariableWidthBytes(values, valueOffsets, index);\n/** @ignore */\nconst getUtf8 = ({ values, valueOffsets }, index) => {\n const bytes = getVariableWidthBytes(values, valueOffsets, index);\n return bytes !== null ? decodeUtf8(bytes) : null;\n};\n/* istanbul ignore next */\n/** @ignore */\nconst getInt = ({ values }, index) => values[index];\n/* istanbul ignore next */\n/** @ignore */\nconst getFloat = ({ type, values }, index) => (type.precision !== Precision.HALF ? values[index] : uint16ToFloat64(values[index]));\n/* istanbul ignore next */\n/** @ignore */\nconst getDate = (data, index) => (data.type.unit === DateUnit.DAY\n ? getDateDay(data, index)\n : getDateMillisecond(data, index));\n/** @ignore */\nconst getTimestampSecond = ({ values }, index) => 1000 * epochMillisecondsLongToMs(values, index * 2);\n/** @ignore */\nconst getTimestampMillisecond = ({ values }, index) => epochMillisecondsLongToMs(values, index * 2);\n/** @ignore */\nconst getTimestampMicrosecond = ({ values }, index) => epochMicrosecondsLongToMs(values, index * 2);\n/** @ignore */\nconst getTimestampNanosecond = ({ values }, index) => epochNanosecondsLongToMs(values, index * 2);\n/* istanbul ignore next */\n/** @ignore */\nconst getTimestamp = (data, index) => {\n switch (data.type.unit) {\n case TimeUnit.SECOND: return getTimestampSecond(data, index);\n case TimeUnit.MILLISECOND: return getTimestampMillisecond(data, index);\n case TimeUnit.MICROSECOND: return getTimestampMicrosecond(data, index);\n case TimeUnit.NANOSECOND: return getTimestampNanosecond(data, index);\n }\n};\n/** @ignore */\nconst getTimeSecond = ({ values }, index) => values[index];\n/** @ignore */\nconst getTimeMillisecond = ({ values }, index) => values[index];\n/** @ignore */\nconst getTimeMicrosecond = ({ values }, index) => values[index];\n/** @ignore */\nconst getTimeNanosecond = ({ values }, index) => values[index];\n/* istanbul ignore next */\n/** @ignore */\nconst getTime = (data, index) => {\n switch (data.type.unit) {\n case TimeUnit.SECOND: return getTimeSecond(data, index);\n case TimeUnit.MILLISECOND: return getTimeMillisecond(data, index);\n case TimeUnit.MICROSECOND: return getTimeMicrosecond(data, index);\n case TimeUnit.NANOSECOND: return getTimeNanosecond(data, index);\n }\n};\n/** @ignore */\nconst getDecimal = ({ values, stride }, index) => BN.decimal(values.subarray(stride * index, stride * (index + 1)));\n/** @ignore */\nconst getList = (data, index) => {\n const { valueOffsets, stride, children } = data;\n const { [index * stride]: begin, [index * stride + 1]: end } = valueOffsets;\n const child = children[0];\n const slice = child.slice(begin, end - begin);\n return new Vector([slice]);\n};\n/** @ignore */\nconst getMap = (data, index) => {\n const { valueOffsets, children } = data;\n const { [index]: begin, [index + 1]: end } = valueOffsets;\n const child = children[0];\n return new MapRow(child.slice(begin, end - begin));\n};\n/** @ignore */\nconst getStruct = (data, index) => {\n return new StructRow(data, index);\n};\n/* istanbul ignore next */\n/** @ignore */\nconst getUnion = (data, index) => {\n return data.type.mode === UnionMode.Dense ?\n getDenseUnion(data, index) :\n getSparseUnion(data, index);\n};\n/** @ignore */\nconst getDenseUnion = (data, index) => {\n const childIndex = data.type.typeIdToChildIndex[data.typeIds[index]];\n const child = data.children[childIndex];\n return instance.visit(child, data.valueOffsets[index]);\n};\n/** @ignore */\nconst getSparseUnion = (data, index) => {\n const childIndex = data.type.typeIdToChildIndex[data.typeIds[index]];\n const child = data.children[childIndex];\n return instance.visit(child, index);\n};\n/** @ignore */\nconst getDictionary = (data, index) => {\n var _a;\n return (_a = data.dictionary) === null || _a === void 0 ? void 0 : _a.get(data.values[index]);\n};\n/* istanbul ignore next */\n/** @ignore */\nconst getInterval = (data, index) => (data.type.unit === IntervalUnit.DAY_TIME)\n ? getIntervalDayTime(data, index)\n : getIntervalYearMonth(data, index);\n/** @ignore */\nconst getIntervalDayTime = ({ values }, index) => values.subarray(2 * index, 2 * (index + 1));\n/** @ignore */\nconst getIntervalYearMonth = ({ values }, index) => {\n const interval = values[index];\n const int32s = new Int32Array(2);\n int32s[0] = Math.trunc(interval / 12); /* years */\n int32s[1] = Math.trunc(interval % 12); /* months */\n return int32s;\n};\n/** @ignore */\nconst getFixedSizeList = (data, index) => {\n const { stride, children } = data;\n const child = children[0];\n const slice = child.slice(index * stride, stride);\n return new Vector([slice]);\n};\nGetVisitor.prototype.visitNull = wrapGet(getNull);\nGetVisitor.prototype.visitBool = wrapGet(getBool);\nGetVisitor.prototype.visitInt = wrapGet(getInt);\nGetVisitor.prototype.visitInt8 = wrapGet(getNumeric);\nGetVisitor.prototype.visitInt16 = wrapGet(getNumeric);\nGetVisitor.prototype.visitInt32 = wrapGet(getNumeric);\nGetVisitor.prototype.visitInt64 = wrapGet(getBigInts);\nGetVisitor.prototype.visitUint8 = wrapGet(getNumeric);\nGetVisitor.prototype.visitUint16 = wrapGet(getNumeric);\nGetVisitor.prototype.visitUint32 = wrapGet(getNumeric);\nGetVisitor.prototype.visitUint64 = wrapGet(getBigInts);\nGetVisitor.prototype.visitFloat = wrapGet(getFloat);\nGetVisitor.prototype.visitFloat16 = wrapGet(getFloat16);\nGetVisitor.prototype.visitFloat32 = wrapGet(getNumeric);\nGetVisitor.prototype.visitFloat64 = wrapGet(getNumeric);\nGetVisitor.prototype.visitUtf8 = wrapGet(getUtf8);\nGetVisitor.prototype.visitBinary = wrapGet(getBinary);\nGetVisitor.prototype.visitFixedSizeBinary = wrapGet(getFixedSizeBinary);\nGetVisitor.prototype.visitDate = wrapGet(getDate);\nGetVisitor.prototype.visitDateDay = wrapGet(getDateDay);\nGetVisitor.prototype.visitDateMillisecond = wrapGet(getDateMillisecond);\nGetVisitor.prototype.visitTimestamp = wrapGet(getTimestamp);\nGetVisitor.prototype.visitTimestampSecond = wrapGet(getTimestampSecond);\nGetVisitor.prototype.visitTimestampMillisecond = wrapGet(getTimestampMillisecond);\nGetVisitor.prototype.visitTimestampMicrosecond = wrapGet(getTimestampMicrosecond);\nGetVisitor.prototype.visitTimestampNanosecond = wrapGet(getTimestampNanosecond);\nGetVisitor.prototype.visitTime = wrapGet(getTime);\nGetVisitor.prototype.visitTimeSecond = wrapGet(getTimeSecond);\nGetVisitor.prototype.visitTimeMillisecond = wrapGet(getTimeMillisecond);\nGetVisitor.prototype.visitTimeMicrosecond = wrapGet(getTimeMicrosecond);\nGetVisitor.prototype.visitTimeNanosecond = wrapGet(getTimeNanosecond);\nGetVisitor.prototype.visitDecimal = wrapGet(getDecimal);\nGetVisitor.prototype.visitList = wrapGet(getList);\nGetVisitor.prototype.visitStruct = wrapGet(getStruct);\nGetVisitor.prototype.visitUnion = wrapGet(getUnion);\nGetVisitor.prototype.visitDenseUnion = wrapGet(getDenseUnion);\nGetVisitor.prototype.visitSparseUnion = wrapGet(getSparseUnion);\nGetVisitor.prototype.visitDictionary = wrapGet(getDictionary);\nGetVisitor.prototype.visitInterval = wrapGet(getInterval);\nGetVisitor.prototype.visitIntervalDayTime = wrapGet(getIntervalDayTime);\nGetVisitor.prototype.visitIntervalYearMonth = wrapGet(getIntervalYearMonth);\nGetVisitor.prototype.visitFixedSizeList = wrapGet(getFixedSizeList);\nGetVisitor.prototype.visitMap = wrapGet(getMap);\n/** @ignore */\nexport const instance = new GetVisitor();\n\n//# sourceMappingURL=get.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Vector } from '../vector.mjs';\nimport { valueToString } from '../util/pretty.mjs';\nimport { instance as getVisitor } from '../visitor/get.mjs';\nimport { instance as setVisitor } from '../visitor/set.mjs';\n/** @ignore */ export const kKeys = Symbol.for('keys');\n/** @ignore */ export const kVals = Symbol.for('vals');\nexport class MapRow {\n constructor(slice) {\n this[kKeys] = new Vector([slice.children[0]]).memoize();\n this[kVals] = slice.children[1];\n return new Proxy(this, new MapRowProxyHandler());\n }\n [Symbol.iterator]() {\n return new MapRowIterator(this[kKeys], this[kVals]);\n }\n get size() { return this[kKeys].length; }\n toArray() { return Object.values(this.toJSON()); }\n toJSON() {\n const keys = this[kKeys];\n const vals = this[kVals];\n const json = {};\n for (let i = -1, n = keys.length; ++i < n;) {\n json[keys.get(i)] = getVisitor.visit(vals, i);\n }\n return json;\n }\n toString() {\n return `{${[...this].map(([key, val]) => `${valueToString(key)}: ${valueToString(val)}`).join(', ')}}`;\n }\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return this.toString();\n }\n}\nclass MapRowIterator {\n constructor(keys, vals) {\n this.keys = keys;\n this.vals = vals;\n this.keyIndex = 0;\n this.numKeys = keys.length;\n }\n [Symbol.iterator]() { return this; }\n next() {\n const i = this.keyIndex;\n if (i === this.numKeys) {\n return { done: true, value: null };\n }\n this.keyIndex++;\n return {\n done: false,\n value: [\n this.keys.get(i),\n getVisitor.visit(this.vals, i),\n ]\n };\n }\n}\n/** @ignore */\nclass MapRowProxyHandler {\n isExtensible() { return false; }\n deleteProperty() { return false; }\n preventExtensions() { return true; }\n ownKeys(row) {\n return row[kKeys].toArray().map(String);\n }\n has(row, key) {\n return row[kKeys].includes(key);\n }\n getOwnPropertyDescriptor(row, key) {\n const idx = row[kKeys].indexOf(key);\n if (idx !== -1) {\n return { writable: true, enumerable: true, configurable: true };\n }\n return;\n }\n get(row, key) {\n // Look up key in row first\n if (Reflect.has(row, key)) {\n return row[key];\n }\n const idx = row[kKeys].indexOf(key);\n if (idx !== -1) {\n const val = getVisitor.visit(Reflect.get(row, kVals), idx);\n // Cache key/val lookups\n Reflect.set(row, key, val);\n return val;\n }\n }\n set(row, key, val) {\n const idx = row[kKeys].indexOf(key);\n if (idx !== -1) {\n setVisitor.visit(Reflect.get(row, kVals), idx, val);\n // Cache key/val lookups\n return Reflect.set(row, key, val);\n }\n else if (Reflect.has(row, key)) {\n return Reflect.set(row, key, val);\n }\n return false;\n }\n}\nObject.defineProperties(MapRow.prototype, {\n [Symbol.toStringTag]: { enumerable: false, configurable: false, value: 'Row' },\n [kKeys]: { writable: true, enumerable: false, configurable: false, value: null },\n [kVals]: { writable: true, enumerable: false, configurable: false, value: null },\n});\n\n//# sourceMappingURL=map.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Vector } from '../vector.mjs';\nimport { MapRow } from '../row/map.mjs';\nimport { StructRow } from '../row/struct.mjs';\nimport { compareArrayLike } from '../util/buffer.mjs';\n/** @ignore */\nexport function clampIndex(source, index, then) {\n const length = source.length;\n const adjust = index > -1 ? index : (length + (index % length));\n return then ? then(source, adjust) : adjust;\n}\n/** @ignore */\nlet tmp;\n/** @ignore */\nexport function clampRange(source, begin, end, then) {\n // Adjust args similar to Array.prototype.slice. Normalize begin/end to\n // clamp between 0 and length, and wrap around on negative indices, e.g.\n // slice(-1, 5) or slice(5, -1)\n const { length: len = 0 } = source;\n let lhs = typeof begin !== 'number' ? 0 : begin;\n let rhs = typeof end !== 'number' ? len : end;\n // wrap around on negative start/end positions\n (lhs < 0) && (lhs = ((lhs % len) + len) % len);\n (rhs < 0) && (rhs = ((rhs % len) + len) % len);\n // ensure lhs <= rhs\n (rhs < lhs) && (tmp = lhs, lhs = rhs, rhs = tmp);\n // ensure rhs <= length\n (rhs > len) && (rhs = len);\n return then ? then(source, lhs, rhs) : [lhs, rhs];\n}\nconst isNaNFast = (value) => value !== value;\n/** @ignore */\nexport function createElementComparator(search) {\n const typeofSearch = typeof search;\n // Compare primitives\n if (typeofSearch !== 'object' || search === null) {\n // Compare NaN\n if (isNaNFast(search)) {\n return isNaNFast;\n }\n return (value) => value === search;\n }\n // Compare Dates\n if (search instanceof Date) {\n const valueOfSearch = search.valueOf();\n return (value) => value instanceof Date ? (value.valueOf() === valueOfSearch) : false;\n }\n // Compare TypedArrays\n if (ArrayBuffer.isView(search)) {\n return (value) => value ? compareArrayLike(search, value) : false;\n }\n // Compare Maps and Rows\n if (search instanceof Map) {\n return createMapComparator(search);\n }\n // Compare Array-likes\n if (Array.isArray(search)) {\n return createArrayLikeComparator(search);\n }\n // Compare Vectors\n if (search instanceof Vector) {\n return createVectorComparator(search);\n }\n return createObjectComparator(search, true);\n // Compare non-empty Objects\n // return createObjectComparator(search, search instanceof Proxy);\n}\n/** @ignore */\nfunction createArrayLikeComparator(lhs) {\n const comparators = [];\n for (let i = -1, n = lhs.length; ++i < n;) {\n comparators[i] = createElementComparator(lhs[i]);\n }\n return createSubElementsComparator(comparators);\n}\n/** @ignore */\nfunction createMapComparator(lhs) {\n let i = -1;\n const comparators = [];\n for (const v of lhs.values())\n comparators[++i] = createElementComparator(v);\n return createSubElementsComparator(comparators);\n}\n/** @ignore */\nfunction createVectorComparator(lhs) {\n const comparators = [];\n for (let i = -1, n = lhs.length; ++i < n;) {\n comparators[i] = createElementComparator(lhs.get(i));\n }\n return createSubElementsComparator(comparators);\n}\n/** @ignore */\nfunction createObjectComparator(lhs, allowEmpty = false) {\n const keys = Object.keys(lhs);\n // Only compare non-empty Objects\n if (!allowEmpty && keys.length === 0) {\n return () => false;\n }\n const comparators = [];\n for (let i = -1, n = keys.length; ++i < n;) {\n comparators[i] = createElementComparator(lhs[keys[i]]);\n }\n return createSubElementsComparator(comparators, keys);\n}\nfunction createSubElementsComparator(comparators, keys) {\n return (rhs) => {\n if (!rhs || typeof rhs !== 'object') {\n return false;\n }\n switch (rhs.constructor) {\n case Array: return compareArray(comparators, rhs);\n case Map:\n return compareObject(comparators, rhs, rhs.keys());\n case MapRow:\n case StructRow:\n case Object:\n case undefined: // support `Object.create(null)` objects\n return compareObject(comparators, rhs, keys || Object.keys(rhs));\n }\n return rhs instanceof Vector ? compareVector(comparators, rhs) : false;\n };\n}\nfunction compareArray(comparators, arr) {\n const n = comparators.length;\n if (arr.length !== n) {\n return false;\n }\n for (let i = -1; ++i < n;) {\n if (!(comparators[i](arr[i]))) {\n return false;\n }\n }\n return true;\n}\nfunction compareVector(comparators, vec) {\n const n = comparators.length;\n if (vec.length !== n) {\n return false;\n }\n for (let i = -1; ++i < n;) {\n if (!(comparators[i](vec.get(i)))) {\n return false;\n }\n }\n return true;\n}\nfunction compareObject(comparators, obj, keys) {\n const lKeyItr = keys[Symbol.iterator]();\n const rKeyItr = obj instanceof Map ? obj.keys() : Object.keys(obj)[Symbol.iterator]();\n const rValItr = obj instanceof Map ? obj.values() : Object.values(obj)[Symbol.iterator]();\n let i = 0;\n const n = comparators.length;\n let rVal = rValItr.next();\n let lKey = lKeyItr.next();\n let rKey = rKeyItr.next();\n for (; i < n && !lKey.done && !rKey.done && !rVal.done; ++i, lKey = lKeyItr.next(), rKey = rKeyItr.next(), rVal = rValItr.next()) {\n if (lKey.value !== rKey.value || !comparators[i](rVal.value)) {\n break;\n }\n }\n if (i === n && lKey.done && rKey.done && rVal.done) {\n return true;\n }\n lKeyItr.return && lKeyItr.return();\n rKeyItr.return && rKeyItr.return();\n rValItr.return && rValItr.return();\n return false;\n}\n\n//# sourceMappingURL=vector.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\n/** @ignore */\nexport function getBool(_data, _index, byte, bit) {\n return (byte & 1 << bit) !== 0;\n}\n/** @ignore */\nexport function getBit(_data, _index, byte, bit) {\n return (byte & 1 << bit) >> bit;\n}\n/** @ignore */\nexport function setBool(bytes, index, value) {\n return value ?\n !!(bytes[index >> 3] |= (1 << (index % 8))) || true :\n !(bytes[index >> 3] &= ~(1 << (index % 8))) && false;\n}\n/** @ignore */\nexport function truncateBitmap(offset, length, bitmap) {\n const alignedSize = (bitmap.byteLength + 7) & ~7;\n if (offset > 0 || bitmap.byteLength < alignedSize) {\n const bytes = new Uint8Array(alignedSize);\n // If the offset is a multiple of 8 bits, it's safe to slice the bitmap\n bytes.set(offset % 8 === 0 ? bitmap.subarray(offset >> 3) :\n // Otherwise iterate each bit from the offset and return a new one\n packBools(new BitIterator(bitmap, offset, length, null, getBool)).subarray(0, alignedSize));\n return bytes;\n }\n return bitmap;\n}\n/** @ignore */\nexport function packBools(values) {\n const xs = [];\n let i = 0, bit = 0, byte = 0;\n for (const value of values) {\n value && (byte |= 1 << bit);\n if (++bit === 8) {\n xs[i++] = byte;\n byte = bit = 0;\n }\n }\n if (i === 0 || bit > 0) {\n xs[i++] = byte;\n }\n const b = new Uint8Array((xs.length + 7) & ~7);\n b.set(xs);\n return b;\n}\n/** @ignore */\nexport class BitIterator {\n constructor(bytes, begin, length, context, get) {\n this.bytes = bytes;\n this.length = length;\n this.context = context;\n this.get = get;\n this.bit = begin % 8;\n this.byteIndex = begin >> 3;\n this.byte = bytes[this.byteIndex++];\n this.index = 0;\n }\n next() {\n if (this.index < this.length) {\n if (this.bit === 8) {\n this.bit = 0;\n this.byte = this.bytes[this.byteIndex++];\n }\n return {\n value: this.get(this.context, this.index++, this.byte, this.bit++)\n };\n }\n return { done: true, value: null };\n }\n [Symbol.iterator]() {\n return this;\n }\n}\n/**\n * Compute the population count (the number of bits set to 1) for a range of bits in a Uint8Array.\n * @param vector The Uint8Array of bits for which to compute the population count.\n * @param lhs The range's left-hand side (or start) bit\n * @param rhs The range's right-hand side (or end) bit\n */\n/** @ignore */\nexport function popcnt_bit_range(data, lhs, rhs) {\n if (rhs - lhs <= 0) {\n return 0;\n }\n // If the bit range is less than one byte, sum the 1 bits in the bit range\n if (rhs - lhs < 8) {\n let sum = 0;\n for (const bit of new BitIterator(data, lhs, rhs - lhs, data, getBit)) {\n sum += bit;\n }\n return sum;\n }\n // Get the next lowest multiple of 8 from the right hand side\n const rhsInside = rhs >> 3 << 3;\n // Get the next highest multiple of 8 from the left hand side\n const lhsInside = lhs + (lhs % 8 === 0 ? 0 : 8 - lhs % 8);\n return (\n // Get the popcnt of bits between the left hand side, and the next highest multiple of 8\n popcnt_bit_range(data, lhs, lhsInside) +\n // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8\n popcnt_bit_range(data, rhsInside, rhs) +\n // Get the popcnt of all bits between the left and right hand sides' multiples of 8\n popcnt_array(data, lhsInside >> 3, (rhsInside - lhsInside) >> 3));\n}\n/** @ignore */\nexport function popcnt_array(arr, byteOffset, byteLength) {\n let cnt = 0, pos = Math.trunc(byteOffset);\n const view = new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n const len = byteLength === void 0 ? arr.byteLength : pos + byteLength;\n while (len - pos >= 4) {\n cnt += popcnt_uint32(view.getUint32(pos));\n pos += 4;\n }\n while (len - pos >= 2) {\n cnt += popcnt_uint32(view.getUint16(pos));\n pos += 2;\n }\n while (len - pos >= 1) {\n cnt += popcnt_uint32(view.getUint8(pos));\n pos += 1;\n }\n return cnt;\n}\n/** @ignore */\nexport function popcnt_uint32(uint32) {\n let i = Math.trunc(uint32);\n i = i - ((i >>> 1) & 0x55555555);\n i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);\n return (((i + (i >>> 4)) & 0x0F0F0F0F) * 0x01010101) >>> 24;\n}\n\n//# sourceMappingURL=bit.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Vector } from './vector.mjs';\nimport { BufferType, Type } from './enum.mjs';\nimport { DataType, strideForType } from './type.mjs';\nimport { popcnt_bit_range, truncateBitmap } from './util/bit.mjs';\n/** @ignore */ export const kUnknownNullCount = -1;\n/**\n * Data structure underlying {@link Vector}s. Use the convenience method {@link makeData}.\n */\nexport class Data {\n constructor(type, offset, length, nullCount, buffers, children = [], dictionary) {\n this.type = type;\n this.children = children;\n this.dictionary = dictionary;\n this.offset = Math.floor(Math.max(offset || 0, 0));\n this.length = Math.floor(Math.max(length || 0, 0));\n this._nullCount = Math.floor(Math.max(nullCount || 0, -1));\n let buffer;\n if (buffers instanceof Data) {\n this.stride = buffers.stride;\n this.values = buffers.values;\n this.typeIds = buffers.typeIds;\n this.nullBitmap = buffers.nullBitmap;\n this.valueOffsets = buffers.valueOffsets;\n }\n else {\n this.stride = strideForType(type);\n if (buffers) {\n (buffer = buffers[0]) && (this.valueOffsets = buffer);\n (buffer = buffers[1]) && (this.values = buffer);\n (buffer = buffers[2]) && (this.nullBitmap = buffer);\n (buffer = buffers[3]) && (this.typeIds = buffer);\n }\n }\n this.nullable = this._nullCount !== 0 && this.nullBitmap && this.nullBitmap.byteLength > 0;\n }\n get typeId() { return this.type.typeId; }\n get ArrayType() { return this.type.ArrayType; }\n get buffers() {\n return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];\n }\n get byteLength() {\n let byteLength = 0;\n const { valueOffsets, values, nullBitmap, typeIds } = this;\n valueOffsets && (byteLength += valueOffsets.byteLength);\n values && (byteLength += values.byteLength);\n nullBitmap && (byteLength += nullBitmap.byteLength);\n typeIds && (byteLength += typeIds.byteLength);\n return this.children.reduce((byteLength, child) => byteLength + child.byteLength, byteLength);\n }\n get nullCount() {\n let nullCount = this._nullCount;\n let nullBitmap;\n if (nullCount <= kUnknownNullCount && (nullBitmap = this.nullBitmap)) {\n this._nullCount = nullCount = this.length - popcnt_bit_range(nullBitmap, this.offset, this.offset + this.length);\n }\n return nullCount;\n }\n getValid(index) {\n if (this.nullable && this.nullCount > 0) {\n const pos = this.offset + index;\n const val = this.nullBitmap[pos >> 3];\n return (val & (1 << (pos % 8))) !== 0;\n }\n return true;\n }\n setValid(index, value) {\n // Don't interact w/ nullBitmap if not nullable\n if (!this.nullable) {\n return value;\n }\n // If no null bitmap, initialize one on the fly\n if (!this.nullBitmap || this.nullBitmap.byteLength <= (index >> 3)) {\n const { nullBitmap } = this._changeLengthAndBackfillNullBitmap(this.length);\n Object.assign(this, { nullBitmap, _nullCount: 0 });\n }\n const { nullBitmap, offset } = this;\n const pos = (offset + index) >> 3;\n const bit = (offset + index) % 8;\n const val = (nullBitmap[pos] >> bit) & 1;\n // If `val` is truthy and the current bit is 0, flip it to 1 and increment `_nullCount`.\n // If `val` is falsey and the current bit is 1, flip it to 0 and decrement `_nullCount`.\n value ? val === 0 && ((nullBitmap[pos] |= (1 << bit)), (this._nullCount = this.nullCount + 1))\n : val === 1 && ((nullBitmap[pos] &= ~(1 << bit)), (this._nullCount = this.nullCount - 1));\n return value;\n }\n clone(type = this.type, offset = this.offset, length = this.length, nullCount = this._nullCount, buffers = this, children = this.children) {\n return new Data(type, offset, length, nullCount, buffers, children, this.dictionary);\n }\n slice(offset, length) {\n const { stride, typeId, children } = this;\n // +true === 1, +false === 0, so this means\n // we keep nullCount at 0 if it's already 0,\n // otherwise set to the invalidated flag -1\n const nullCount = +(this._nullCount === 0) - 1;\n const childStride = typeId === 16 /* FixedSizeList */ ? stride : 1;\n const buffers = this._sliceBuffers(offset, length, stride, typeId);\n return this.clone(this.type, this.offset + offset, length, nullCount, buffers, \n // Don't slice children if we have value offsets (the variable-width types)\n (children.length === 0 || this.valueOffsets) ? children : this._sliceChildren(children, childStride * offset, childStride * length));\n }\n _changeLengthAndBackfillNullBitmap(newLength) {\n if (this.typeId === Type.Null) {\n return this.clone(this.type, 0, newLength, 0);\n }\n const { length, nullCount } = this;\n // start initialized with 0s (nulls), then fill from 0 to length with 1s (not null)\n const bitmap = new Uint8Array(((newLength + 63) & ~63) >> 3).fill(255, 0, length >> 3);\n // set all the bits in the last byte (up to bit `length - length % 8`) to 1 (not null)\n bitmap[length >> 3] = (1 << (length - (length & ~7))) - 1;\n // if we have a nullBitmap, truncate + slice and set it over the pre-filled 1s\n if (nullCount > 0) {\n bitmap.set(truncateBitmap(this.offset, length, this.nullBitmap), 0);\n }\n const buffers = this.buffers;\n buffers[BufferType.VALIDITY] = bitmap;\n return this.clone(this.type, 0, newLength, nullCount + (newLength - length), buffers);\n }\n _sliceBuffers(offset, length, stride, typeId) {\n let arr;\n const { buffers } = this;\n // If typeIds exist, slice the typeIds buffer\n (arr = buffers[BufferType.TYPE]) && (buffers[BufferType.TYPE] = arr.subarray(offset, offset + length));\n // If offsets exist, only slice the offsets buffer\n (arr = buffers[BufferType.OFFSET]) && (buffers[BufferType.OFFSET] = arr.subarray(offset, offset + length + 1)) ||\n // Otherwise if no offsets, slice the data buffer. Don't slice the data vector for Booleans, since the offset goes by bits not bytes\n (arr = buffers[BufferType.DATA]) && (buffers[BufferType.DATA] = typeId === 6 ? arr : arr.subarray(stride * offset, stride * (offset + length)));\n return buffers;\n }\n _sliceChildren(children, offset, length) {\n return children.map((child) => child.slice(offset, length));\n }\n}\nData.prototype.children = Object.freeze([]);\nimport { Visitor } from './visitor.mjs';\nimport { toArrayBufferView, toInt32Array, toUint8Array } from './util/buffer.mjs';\nclass MakeDataVisitor extends Visitor {\n visit(props) {\n return this.getVisitFn(props['type']).call(this, props);\n }\n visitNull(props) {\n const { ['type']: type, ['offset']: offset = 0, ['length']: length = 0, } = props;\n return new Data(type, offset, length, 0);\n }\n visitBool(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const data = toArrayBufferView(type.ArrayType, props['data']);\n const { ['length']: length = data.length >> 3, ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n return new Data(type, offset, length, nullCount, [undefined, data, nullBitmap]);\n }\n visitInt(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const data = toArrayBufferView(type.ArrayType, props['data']);\n const { ['length']: length = data.length, ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n return new Data(type, offset, length, nullCount, [undefined, data, nullBitmap]);\n }\n visitFloat(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const data = toArrayBufferView(type.ArrayType, props['data']);\n const { ['length']: length = data.length, ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n return new Data(type, offset, length, nullCount, [undefined, data, nullBitmap]);\n }\n visitUtf8(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const data = toUint8Array(props['data']);\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const valueOffsets = toInt32Array(props['valueOffsets']);\n const { ['length']: length = valueOffsets.length - 1, ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0 } = props;\n return new Data(type, offset, length, nullCount, [valueOffsets, data, nullBitmap]);\n }\n visitBinary(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const data = toUint8Array(props['data']);\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const valueOffsets = toInt32Array(props['valueOffsets']);\n const { ['length']: length = valueOffsets.length - 1, ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0 } = props;\n return new Data(type, offset, length, nullCount, [valueOffsets, data, nullBitmap]);\n }\n visitFixedSizeBinary(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const data = toArrayBufferView(type.ArrayType, props['data']);\n const { ['length']: length = data.length / strideForType(type), ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n return new Data(type, offset, length, nullCount, [undefined, data, nullBitmap]);\n }\n visitDate(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const data = toArrayBufferView(type.ArrayType, props['data']);\n const { ['length']: length = data.length / strideForType(type), ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n return new Data(type, offset, length, nullCount, [undefined, data, nullBitmap]);\n }\n visitTimestamp(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const data = toArrayBufferView(type.ArrayType, props['data']);\n const { ['length']: length = data.length / strideForType(type), ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n return new Data(type, offset, length, nullCount, [undefined, data, nullBitmap]);\n }\n visitTime(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const data = toArrayBufferView(type.ArrayType, props['data']);\n const { ['length']: length = data.length / strideForType(type), ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n return new Data(type, offset, length, nullCount, [undefined, data, nullBitmap]);\n }\n visitDecimal(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const data = toArrayBufferView(type.ArrayType, props['data']);\n const { ['length']: length = data.length / strideForType(type), ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n return new Data(type, offset, length, nullCount, [undefined, data, nullBitmap]);\n }\n visitList(props) {\n const { ['type']: type, ['offset']: offset = 0, ['child']: child } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const valueOffsets = toInt32Array(props['valueOffsets']);\n const { ['length']: length = valueOffsets.length - 1, ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0 } = props;\n return new Data(type, offset, length, nullCount, [valueOffsets, undefined, nullBitmap], [child]);\n }\n visitStruct(props) {\n const { ['type']: type, ['offset']: offset = 0, ['children']: children = [] } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const { length = children.reduce((len, { length }) => Math.max(len, length), 0), nullCount = props['nullBitmap'] ? -1 : 0 } = props;\n return new Data(type, offset, length, nullCount, [undefined, undefined, nullBitmap], children);\n }\n visitUnion(props) {\n const { ['type']: type, ['offset']: offset = 0, ['children']: children = [] } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const typeIds = toArrayBufferView(type.ArrayType, props['typeIds']);\n const { ['length']: length = typeIds.length, ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n if (DataType.isSparseUnion(type)) {\n return new Data(type, offset, length, nullCount, [undefined, undefined, nullBitmap, typeIds], children);\n }\n const valueOffsets = toInt32Array(props['valueOffsets']);\n return new Data(type, offset, length, nullCount, [valueOffsets, undefined, nullBitmap, typeIds], children);\n }\n visitDictionary(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const data = toArrayBufferView(type.indices.ArrayType, props['data']);\n const { ['dictionary']: dictionary = new Vector([new MakeDataVisitor().visit({ type: type.dictionary })]) } = props;\n const { ['length']: length = data.length, ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0 } = props;\n return new Data(type, offset, length, nullCount, [undefined, data, nullBitmap], [], dictionary);\n }\n visitInterval(props) {\n const { ['type']: type, ['offset']: offset = 0 } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const data = toArrayBufferView(type.ArrayType, props['data']);\n const { ['length']: length = data.length / strideForType(type), ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n return new Data(type, offset, length, nullCount, [undefined, data, nullBitmap]);\n }\n visitFixedSizeList(props) {\n const { ['type']: type, ['offset']: offset = 0, ['child']: child = new MakeDataVisitor().visit({ type: type.valueType }) } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const { ['length']: length = child.length / strideForType(type), ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0 } = props;\n return new Data(type, offset, length, nullCount, [undefined, undefined, nullBitmap], [child]);\n }\n visitMap(props) {\n const { ['type']: type, ['offset']: offset = 0, ['child']: child = new MakeDataVisitor().visit({ type: type.childType }) } = props;\n const nullBitmap = toUint8Array(props['nullBitmap']);\n const valueOffsets = toInt32Array(props['valueOffsets']);\n const { ['length']: length = valueOffsets.length - 1, ['nullCount']: nullCount = props['nullBitmap'] ? -1 : 0, } = props;\n return new Data(type, offset, length, nullCount, [valueOffsets, undefined, nullBitmap], [child]);\n }\n}\nexport function makeData(props) {\n return new MakeDataVisitor().visit(props);\n}\n\n//# sourceMappingURL=data.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\n/** @ignore */\nexport class ChunkedIterator {\n constructor(numChunks = 0, getChunkIterator) {\n this.numChunks = numChunks;\n this.getChunkIterator = getChunkIterator;\n this.chunkIndex = 0;\n this.chunkIterator = this.getChunkIterator(0);\n }\n next() {\n while (this.chunkIndex < this.numChunks) {\n const next = this.chunkIterator.next();\n if (!next.done) {\n return next;\n }\n if (++this.chunkIndex < this.numChunks) {\n this.chunkIterator = this.getChunkIterator(this.chunkIndex);\n }\n }\n return { done: true, value: null };\n }\n [Symbol.iterator]() {\n return this;\n }\n}\n/** @ignore */\nexport function computeChunkNullCounts(chunks) {\n return chunks.reduce((nullCount, chunk) => nullCount + chunk.nullCount, 0);\n}\n/** @ignore */\nexport function computeChunkOffsets(chunks) {\n return chunks.reduce((offsets, chunk, index) => {\n offsets[index + 1] = offsets[index] + chunk.length;\n return offsets;\n }, new Uint32Array(chunks.length + 1));\n}\n/** @ignore */\nexport function sliceChunks(chunks, offsets, begin, end) {\n const slices = [];\n for (let i = -1, n = chunks.length; ++i < n;) {\n const chunk = chunks[i];\n const offset = offsets[i];\n const { length } = chunk;\n // Stop if the child is to the right of the slice boundary\n if (offset >= end) {\n break;\n }\n // Exclude children to the left of of the slice boundary\n if (begin >= offset + length) {\n continue;\n }\n // Include entire child if between both left and right boundaries\n if (offset >= begin && (offset + length) <= end) {\n slices.push(chunk);\n continue;\n }\n // Include the child slice that overlaps one of the slice boundaries\n const from = Math.max(0, begin - offset);\n const to = Math.min(end - offset, length);\n slices.push(chunk.slice(from, to - from));\n }\n if (slices.length === 0) {\n slices.push(chunks[0].slice(0, 0));\n }\n return slices;\n}\n/** @ignore */\nexport function binarySearch(chunks, offsets, idx, fn) {\n let lhs = 0, mid = 0, rhs = offsets.length - 1;\n do {\n if (lhs >= rhs - 1) {\n return (idx < offsets[rhs]) ? fn(chunks, lhs, idx - offsets[lhs]) : null;\n }\n mid = lhs + (Math.trunc((rhs - lhs) * .5));\n idx < offsets[mid] ? (rhs = mid) : (lhs = mid);\n } while (lhs < rhs);\n}\n/** @ignore */\nexport function isChunkedValid(data, index) {\n return data.getValid(index);\n}\n/** @ignore */\nexport function wrapChunkedCall1(fn) {\n function chunkedFn(chunks, i, j) { return fn(chunks[i], j); }\n return function (index) {\n const data = this.data;\n return binarySearch(data, this._offsets, index, chunkedFn);\n };\n}\n/** @ignore */\nexport function wrapChunkedCall2(fn) {\n let _2;\n function chunkedFn(chunks, i, j) { return fn(chunks[i], j, _2); }\n return function (index, value) {\n const data = this.data;\n _2 = value;\n const result = binarySearch(data, this._offsets, index, chunkedFn);\n _2 = undefined;\n return result;\n };\n}\n/** @ignore */\nexport function wrapChunkedIndexOf(indexOf) {\n let _1;\n function chunkedIndexOf(data, chunkIndex, fromIndex) {\n let begin = fromIndex, index = 0, total = 0;\n for (let i = chunkIndex - 1, n = data.length; ++i < n;) {\n const chunk = data[i];\n if (~(index = indexOf(chunk, _1, begin))) {\n return total + index;\n }\n begin = 0;\n total += chunk.length;\n }\n return -1;\n }\n return function (element, offset) {\n _1 = element;\n const data = this.data;\n const result = typeof offset !== 'number'\n ? chunkedIndexOf(data, 0, 0)\n : binarySearch(data, this._offsets, offset, chunkedIndexOf);\n _1 = undefined;\n return result;\n };\n}\n\n//# sourceMappingURL=chunk.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Visitor } from '../visitor.mjs';\nimport { instance as getVisitor } from './get.mjs';\nimport { getBool, BitIterator } from '../util/bit.mjs';\nimport { createElementComparator } from '../util/vector.mjs';\n/** @ignore */\nexport class IndexOfVisitor extends Visitor {\n}\n/** @ignore */\nfunction nullIndexOf(data, searchElement) {\n // if you're looking for nulls and the vector isn't empty, we've got 'em!\n return searchElement === null && data.length > 0 ? 0 : -1;\n}\n/** @ignore */\nfunction indexOfNull(data, fromIndex) {\n const { nullBitmap } = data;\n if (!nullBitmap || data.nullCount <= 0) {\n return -1;\n }\n let i = 0;\n for (const isValid of new BitIterator(nullBitmap, data.offset + (fromIndex || 0), data.length, nullBitmap, getBool)) {\n if (!isValid) {\n return i;\n }\n ++i;\n }\n return -1;\n}\n/** @ignore */\nfunction indexOfValue(data, searchElement, fromIndex) {\n if (searchElement === undefined) {\n return -1;\n }\n if (searchElement === null) {\n return indexOfNull(data, fromIndex);\n }\n const get = getVisitor.getVisitFn(data);\n const compare = createElementComparator(searchElement);\n for (let i = (fromIndex || 0) - 1, n = data.length; ++i < n;) {\n if (compare(get(data, i))) {\n return i;\n }\n }\n return -1;\n}\n/** @ignore */\nfunction indexOfUnion(data, searchElement, fromIndex) {\n // Unions are special -- they do have a nullBitmap, but so can their children.\n // If the searchElement is null, we don't know whether it came from the Union's\n // bitmap or one of its childrens'. So we don't interrogate the Union's bitmap,\n // since that will report the wrong index if a child has a null before the Union.\n const get = getVisitor.getVisitFn(data);\n const compare = createElementComparator(searchElement);\n for (let i = (fromIndex || 0) - 1, n = data.length; ++i < n;) {\n if (compare(get(data, i))) {\n return i;\n }\n }\n return -1;\n}\nIndexOfVisitor.prototype.visitNull = nullIndexOf;\nIndexOfVisitor.prototype.visitBool = indexOfValue;\nIndexOfVisitor.prototype.visitInt = indexOfValue;\nIndexOfVisitor.prototype.visitInt8 = indexOfValue;\nIndexOfVisitor.prototype.visitInt16 = indexOfValue;\nIndexOfVisitor.prototype.visitInt32 = indexOfValue;\nIndexOfVisitor.prototype.visitInt64 = indexOfValue;\nIndexOfVisitor.prototype.visitUint8 = indexOfValue;\nIndexOfVisitor.prototype.visitUint16 = indexOfValue;\nIndexOfVisitor.prototype.visitUint32 = indexOfValue;\nIndexOfVisitor.prototype.visitUint64 = indexOfValue;\nIndexOfVisitor.prototype.visitFloat = indexOfValue;\nIndexOfVisitor.prototype.visitFloat16 = indexOfValue;\nIndexOfVisitor.prototype.visitFloat32 = indexOfValue;\nIndexOfVisitor.prototype.visitFloat64 = indexOfValue;\nIndexOfVisitor.prototype.visitUtf8 = indexOfValue;\nIndexOfVisitor.prototype.visitBinary = indexOfValue;\nIndexOfVisitor.prototype.visitFixedSizeBinary = indexOfValue;\nIndexOfVisitor.prototype.visitDate = indexOfValue;\nIndexOfVisitor.prototype.visitDateDay = indexOfValue;\nIndexOfVisitor.prototype.visitDateMillisecond = indexOfValue;\nIndexOfVisitor.prototype.visitTimestamp = indexOfValue;\nIndexOfVisitor.prototype.visitTimestampSecond = indexOfValue;\nIndexOfVisitor.prototype.visitTimestampMillisecond = indexOfValue;\nIndexOfVisitor.prototype.visitTimestampMicrosecond = indexOfValue;\nIndexOfVisitor.prototype.visitTimestampNanosecond = indexOfValue;\nIndexOfVisitor.prototype.visitTime = indexOfValue;\nIndexOfVisitor.prototype.visitTimeSecond = indexOfValue;\nIndexOfVisitor.prototype.visitTimeMillisecond = indexOfValue;\nIndexOfVisitor.prototype.visitTimeMicrosecond = indexOfValue;\nIndexOfVisitor.prototype.visitTimeNanosecond = indexOfValue;\nIndexOfVisitor.prototype.visitDecimal = indexOfValue;\nIndexOfVisitor.prototype.visitList = indexOfValue;\nIndexOfVisitor.prototype.visitStruct = indexOfValue;\nIndexOfVisitor.prototype.visitUnion = indexOfValue;\nIndexOfVisitor.prototype.visitDenseUnion = indexOfUnion;\nIndexOfVisitor.prototype.visitSparseUnion = indexOfUnion;\nIndexOfVisitor.prototype.visitDictionary = indexOfValue;\nIndexOfVisitor.prototype.visitInterval = indexOfValue;\nIndexOfVisitor.prototype.visitIntervalDayTime = indexOfValue;\nIndexOfVisitor.prototype.visitIntervalYearMonth = indexOfValue;\nIndexOfVisitor.prototype.visitFixedSizeList = indexOfValue;\nIndexOfVisitor.prototype.visitMap = indexOfValue;\n/** @ignore */\nexport const instance = new IndexOfVisitor();\n\n//# sourceMappingURL=indexof.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Visitor } from '../visitor.mjs';\nimport { Type, Precision } from '../enum.mjs';\nimport { Float, Int, Time, } from '../type.mjs';\nimport { ChunkedIterator } from '../util/chunk.mjs';\n/** @ignore */\nexport class IteratorVisitor extends Visitor {\n}\n/** @ignore */\nfunction vectorIterator(vector) {\n const { type } = vector;\n // Fast case, defer to native iterators if possible\n if (vector.nullCount === 0 && vector.stride === 1 && ((type.typeId === Type.Timestamp) ||\n (type instanceof Int && type.bitWidth !== 64) ||\n (type instanceof Time && type.bitWidth !== 64) ||\n (type instanceof Float && type.precision !== Precision.HALF))) {\n return new ChunkedIterator(vector.data.length, (chunkIndex) => {\n const data = vector.data[chunkIndex];\n return data.values.subarray(0, data.length)[Symbol.iterator]();\n });\n }\n // Otherwise, iterate manually\n let offset = 0;\n return new ChunkedIterator(vector.data.length, (chunkIndex) => {\n const data = vector.data[chunkIndex];\n const length = data.length;\n const inner = vector.slice(offset, offset + length);\n offset += length;\n return new VectorIterator(inner);\n });\n}\n/** @ignore */\nclass VectorIterator {\n constructor(vector) {\n this.vector = vector;\n this.index = 0;\n }\n next() {\n if (this.index < this.vector.length) {\n return {\n value: this.vector.get(this.index++)\n };\n }\n return { done: true, value: null };\n }\n [Symbol.iterator]() {\n return this;\n }\n}\nIteratorVisitor.prototype.visitNull = vectorIterator;\nIteratorVisitor.prototype.visitBool = vectorIterator;\nIteratorVisitor.prototype.visitInt = vectorIterator;\nIteratorVisitor.prototype.visitInt8 = vectorIterator;\nIteratorVisitor.prototype.visitInt16 = vectorIterator;\nIteratorVisitor.prototype.visitInt32 = vectorIterator;\nIteratorVisitor.prototype.visitInt64 = vectorIterator;\nIteratorVisitor.prototype.visitUint8 = vectorIterator;\nIteratorVisitor.prototype.visitUint16 = vectorIterator;\nIteratorVisitor.prototype.visitUint32 = vectorIterator;\nIteratorVisitor.prototype.visitUint64 = vectorIterator;\nIteratorVisitor.prototype.visitFloat = vectorIterator;\nIteratorVisitor.prototype.visitFloat16 = vectorIterator;\nIteratorVisitor.prototype.visitFloat32 = vectorIterator;\nIteratorVisitor.prototype.visitFloat64 = vectorIterator;\nIteratorVisitor.prototype.visitUtf8 = vectorIterator;\nIteratorVisitor.prototype.visitBinary = vectorIterator;\nIteratorVisitor.prototype.visitFixedSizeBinary = vectorIterator;\nIteratorVisitor.prototype.visitDate = vectorIterator;\nIteratorVisitor.prototype.visitDateDay = vectorIterator;\nIteratorVisitor.prototype.visitDateMillisecond = vectorIterator;\nIteratorVisitor.prototype.visitTimestamp = vectorIterator;\nIteratorVisitor.prototype.visitTimestampSecond = vectorIterator;\nIteratorVisitor.prototype.visitTimestampMillisecond = vectorIterator;\nIteratorVisitor.prototype.visitTimestampMicrosecond = vectorIterator;\nIteratorVisitor.prototype.visitTimestampNanosecond = vectorIterator;\nIteratorVisitor.prototype.visitTime = vectorIterator;\nIteratorVisitor.prototype.visitTimeSecond = vectorIterator;\nIteratorVisitor.prototype.visitTimeMillisecond = vectorIterator;\nIteratorVisitor.prototype.visitTimeMicrosecond = vectorIterator;\nIteratorVisitor.prototype.visitTimeNanosecond = vectorIterator;\nIteratorVisitor.prototype.visitDecimal = vectorIterator;\nIteratorVisitor.prototype.visitList = vectorIterator;\nIteratorVisitor.prototype.visitStruct = vectorIterator;\nIteratorVisitor.prototype.visitUnion = vectorIterator;\nIteratorVisitor.prototype.visitDenseUnion = vectorIterator;\nIteratorVisitor.prototype.visitSparseUnion = vectorIterator;\nIteratorVisitor.prototype.visitDictionary = vectorIterator;\nIteratorVisitor.prototype.visitInterval = vectorIterator;\nIteratorVisitor.prototype.visitIntervalDayTime = vectorIterator;\nIteratorVisitor.prototype.visitIntervalYearMonth = vectorIterator;\nIteratorVisitor.prototype.visitFixedSizeList = vectorIterator;\nIteratorVisitor.prototype.visitMap = vectorIterator;\n/** @ignore */\nexport const instance = new IteratorVisitor();\n\n//# sourceMappingURL=iterator.mjs.map\n","/* istanbul ignore file */\nimport { Visitor } from '../visitor.mjs';\nimport { TimeUnit, UnionMode } from '../enum.mjs';\n/** @ignore */ const sum = (x, y) => x + y;\n/** @ignore */\nexport class GetByteLengthVisitor extends Visitor {\n visitNull(____, _) {\n return 0;\n }\n visitInt(data, _) {\n return data.type.bitWidth / 8;\n }\n visitFloat(data, _) {\n return data.type.ArrayType.BYTES_PER_ELEMENT;\n }\n visitBool(____, _) {\n return 1 / 8;\n }\n visitDecimal(data, _) {\n return data.type.bitWidth / 8;\n }\n visitDate(data, _) {\n return (data.type.unit + 1) * 4;\n }\n visitTime(data, _) {\n return data.type.bitWidth / 8;\n }\n visitTimestamp(data, _) {\n return data.type.unit === TimeUnit.SECOND ? 4 : 8;\n }\n visitInterval(data, _) {\n return (data.type.unit + 1) * 4;\n }\n visitStruct(data, i) {\n return data.children.reduce((total, child) => total + instance.visit(child, i), 0);\n }\n visitFixedSizeBinary(data, _) {\n return data.type.byteWidth;\n }\n visitMap(data, i) {\n // 4 + 4 for the indices\n return 8 + data.children.reduce((total, child) => total + instance.visit(child, i), 0);\n }\n visitDictionary(data, i) {\n var _a;\n return (data.type.indices.bitWidth / 8) + (((_a = data.dictionary) === null || _a === void 0 ? void 0 : _a.getByteLength(data.values[i])) || 0);\n }\n}\n/** @ignore */\nconst getUtf8ByteLength = ({ valueOffsets }, index) => {\n // 4 + 4 for the indices, `end - start` for the data bytes\n return 8 + (valueOffsets[index + 1] - valueOffsets[index]);\n};\n/** @ignore */\nconst getBinaryByteLength = ({ valueOffsets }, index) => {\n // 4 + 4 for the indices, `end - start` for the data bytes\n return 8 + (valueOffsets[index + 1] - valueOffsets[index]);\n};\n/** @ignore */\nconst getListByteLength = ({ valueOffsets, stride, children }, index) => {\n const child = children[0];\n const { [index * stride]: start } = valueOffsets;\n const { [index * stride + 1]: end } = valueOffsets;\n const visit = instance.getVisitFn(child.type);\n const slice = child.slice(start, end - start);\n let size = 8; // 4 + 4 for the indices\n for (let idx = -1, len = end - start; ++idx < len;) {\n size += visit(slice, idx);\n }\n return size;\n};\n/** @ignore */\nconst getFixedSizeListByteLength = ({ stride, children }, index) => {\n const child = children[0];\n const slice = child.slice(index * stride, stride);\n const visit = instance.getVisitFn(child.type);\n let size = 0;\n for (let idx = -1, len = slice.length; ++idx < len;) {\n size += visit(slice, idx);\n }\n return size;\n};\n/* istanbul ignore next */\n/** @ignore */\nconst getUnionByteLength = (data, index) => {\n return data.type.mode === UnionMode.Dense ?\n getDenseUnionByteLength(data, index) :\n getSparseUnionByteLength(data, index);\n};\n/** @ignore */\nconst getDenseUnionByteLength = ({ type, children, typeIds, valueOffsets }, index) => {\n const childIndex = type.typeIdToChildIndex[typeIds[index]];\n // 4 for the typeId, 4 for the valueOffsets, then the child at the offset\n return 8 + instance.visit(children[childIndex], valueOffsets[index]);\n};\n/** @ignore */\nconst getSparseUnionByteLength = ({ children }, index) => {\n // 4 for the typeId, then once each for the children at this index\n return 4 + instance.visitMany(children, children.map(() => index)).reduce(sum, 0);\n};\nGetByteLengthVisitor.prototype.visitUtf8 = getUtf8ByteLength;\nGetByteLengthVisitor.prototype.visitBinary = getBinaryByteLength;\nGetByteLengthVisitor.prototype.visitList = getListByteLength;\nGetByteLengthVisitor.prototype.visitFixedSizeList = getFixedSizeListByteLength;\nGetByteLengthVisitor.prototype.visitUnion = getUnionByteLength;\nGetByteLengthVisitor.prototype.visitDenseUnion = getDenseUnionByteLength;\nGetByteLengthVisitor.prototype.visitSparseUnion = getSparseUnionByteLength;\n/** @ignore */\nexport const instance = new GetByteLengthVisitor();\n\n//# sourceMappingURL=bytelength.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nvar _a;\nimport { Type } from './enum.mjs';\nimport { clampRange } from './util/vector.mjs';\nimport { DataType, strideForType } from './type.mjs';\nimport { Data, makeData } from './data.mjs';\nimport { isChunkedValid, computeChunkOffsets, computeChunkNullCounts, sliceChunks, wrapChunkedCall1, wrapChunkedCall2, wrapChunkedIndexOf, } from './util/chunk.mjs';\nimport { BigInt64Array, BigUint64Array } from './util/compat.mjs';\nimport { instance as getVisitor } from './visitor/get.mjs';\nimport { instance as setVisitor } from './visitor/set.mjs';\nimport { instance as indexOfVisitor } from './visitor/indexof.mjs';\nimport { instance as iteratorVisitor } from './visitor/iterator.mjs';\nimport { instance as byteLengthVisitor } from './visitor/bytelength.mjs';\nconst visitorsByTypeId = {};\nconst vectorPrototypesByTypeId = {};\n/**\n * Array-like data structure. Use the convenience method {@link makeVector} and {@link vectorFromArray} to create vectors.\n */\nexport class Vector {\n constructor(input) {\n var _b, _c, _d;\n const data = input[0] instanceof Vector\n ? input.flatMap(x => x.data)\n : input;\n if (data.length === 0 || data.some((x) => !(x instanceof Data))) {\n throw new TypeError('Vector constructor expects an Array of Data instances.');\n }\n const type = (_b = data[0]) === null || _b === void 0 ? void 0 : _b.type;\n switch (data.length) {\n case 0:\n this._offsets = [0];\n break;\n case 1: {\n // special case for unchunked vectors\n const { get, set, indexOf, byteLength } = visitorsByTypeId[type.typeId];\n const unchunkedData = data[0];\n this.isValid = (index) => isChunkedValid(unchunkedData, index);\n this.get = (index) => get(unchunkedData, index);\n this.set = (index, value) => set(unchunkedData, index, value);\n this.indexOf = (index) => indexOf(unchunkedData, index);\n this.getByteLength = (index) => byteLength(unchunkedData, index);\n this._offsets = [0, unchunkedData.length];\n break;\n }\n default:\n Object.setPrototypeOf(this, vectorPrototypesByTypeId[type.typeId]);\n this._offsets = computeChunkOffsets(data);\n break;\n }\n this.data = data;\n this.type = type;\n this.stride = strideForType(type);\n this.numChildren = (_d = (_c = type.children) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;\n this.length = this._offsets[this._offsets.length - 1];\n }\n /**\n * The aggregate size (in bytes) of this Vector's buffers and/or child Vectors.\n */\n get byteLength() {\n if (this._byteLength === -1) {\n this._byteLength = this.data.reduce((byteLength, data) => byteLength + data.byteLength, 0);\n }\n return this._byteLength;\n }\n /**\n * The number of null elements in this Vector.\n */\n get nullCount() {\n if (this._nullCount === -1) {\n this._nullCount = computeChunkNullCounts(this.data);\n }\n return this._nullCount;\n }\n /**\n * The Array or TypedAray constructor used for the JS representation\n * of the element's values in {@link Vector.prototype.toArray `toArray()`}.\n */\n get ArrayType() { return this.type.ArrayType; }\n /**\n * The name that should be printed when the Vector is logged in a message.\n */\n get [Symbol.toStringTag]() {\n return `${this.VectorName}<${this.type[Symbol.toStringTag]}>`;\n }\n /**\n * The name of this Vector.\n */\n get VectorName() { return `${Type[this.type.typeId]}Vector`; }\n /**\n * Check whether an element is null.\n * @param index The index at which to read the validity bitmap.\n */\n // @ts-ignore\n isValid(index) { return false; }\n /**\n * Get an element value by position.\n * @param index The index of the element to read.\n */\n // @ts-ignore\n get(index) { return null; }\n /**\n * Set an element value by position.\n * @param index The index of the element to write.\n * @param value The value to set.\n */\n // @ts-ignore\n set(index, value) { return; }\n /**\n * Retrieve the index of the first occurrence of a value in an Vector.\n * @param element The value to locate in the Vector.\n * @param offset The index at which to begin the search. If offset is omitted, the search starts at index 0.\n */\n // @ts-ignore\n indexOf(element, offset) { return -1; }\n includes(element, offset) { return this.indexOf(element, offset) > 0; }\n /**\n * Get the size in bytes of an element by index.\n * @param index The index at which to get the byteLength.\n */\n // @ts-ignore\n getByteLength(index) { return 0; }\n /**\n * Iterator for the Vector's elements.\n */\n [Symbol.iterator]() {\n return iteratorVisitor.visit(this);\n }\n /**\n * Combines two or more Vectors of the same type.\n * @param others Additional Vectors to add to the end of this Vector.\n */\n concat(...others) {\n return new Vector(this.data.concat(others.flatMap((x) => x.data).flat(Number.POSITIVE_INFINITY)));\n }\n /**\n * Return a zero-copy sub-section of this Vector.\n * @param start The beginning of the specified portion of the Vector.\n * @param end The end of the specified portion of the Vector. This is exclusive of the element at the index 'end'.\n */\n slice(begin, end) {\n return new Vector(clampRange(this, begin, end, ({ data, _offsets }, begin, end) => sliceChunks(data, _offsets, begin, end)));\n }\n toJSON() { return [...this]; }\n /**\n * Return a JavaScript Array or TypedArray of the Vector's elements.\n *\n * @note If this Vector contains a single Data chunk and the Vector's type is a\n * primitive numeric type corresponding to one of the JavaScript TypedArrays, this\n * method returns a zero-copy slice of the underlying TypedArray values. If there's\n * more than one chunk, the resulting TypedArray will be a copy of the data from each\n * chunk's underlying TypedArray values.\n *\n * @returns An Array or TypedArray of the Vector's elements, based on the Vector's DataType.\n */\n toArray() {\n const { type, data, length, stride, ArrayType } = this;\n // Fast case, return subarray if possible\n switch (type.typeId) {\n case Type.Int:\n case Type.Float:\n case Type.Decimal:\n case Type.Time:\n case Type.Timestamp:\n switch (data.length) {\n case 0: return new ArrayType();\n case 1: return data[0].values.subarray(0, length * stride);\n default: return data.reduce((memo, { values, length: chunk_length }) => {\n memo.array.set(values.subarray(0, chunk_length * stride), memo.offset);\n memo.offset += chunk_length * stride;\n return memo;\n }, { array: new ArrayType(length * stride), offset: 0 }).array;\n }\n }\n // Otherwise if not primitive, slow copy\n return [...this];\n }\n /**\n * Returns a string representation of the Vector.\n *\n * @returns A string representation of the Vector.\n */\n toString() {\n return `[${[...this].join(',')}]`;\n }\n /**\n * Returns a child Vector by name, or null if this Vector has no child with the given name.\n * @param name The name of the child to retrieve.\n */\n getChild(name) {\n var _b;\n return this.getChildAt((_b = this.type.children) === null || _b === void 0 ? void 0 : _b.findIndex((f) => f.name === name));\n }\n /**\n * Returns a child Vector by index, or null if this Vector has no child at the supplied index.\n * @param index The index of the child to retrieve.\n */\n getChildAt(index) {\n if (index > -1 && index < this.numChildren) {\n return new Vector(this.data.map(({ children }) => children[index]));\n }\n return null;\n }\n get isMemoized() {\n if (DataType.isDictionary(this.type)) {\n return this.data[0].dictionary.isMemoized;\n }\n return false;\n }\n /**\n * Adds memoization to the Vector's {@link get} method. For dictionary\n * vectors, this method return a vector that memoizes only the dictionary\n * values.\n *\n * Memoization is very useful when decoding a value is expensive such as\n * Uft8. The memoization creates a cache of the size of the Vector and\n * therfore increases memory usage.\n *\n * @returns A new vector that memoizes calls to {@link get}.\n */\n memoize() {\n if (DataType.isDictionary(this.type)) {\n const dictionary = new MemoizedVector(this.data[0].dictionary);\n const newData = this.data.map((data) => {\n const cloned = data.clone();\n cloned.dictionary = dictionary;\n return cloned;\n });\n return new Vector(newData);\n }\n return new MemoizedVector(this);\n }\n /**\n * Returns a vector without memoization of the {@link get} method. If this\n * vector is not memoized, this method returns this vector.\n *\n * @returns A a vector without memoization.\n */\n unmemoize() {\n if (DataType.isDictionary(this.type) && this.isMemoized) {\n const dictionary = this.data[0].dictionary.unmemoize();\n const newData = this.data.map((data) => {\n const newData = data.clone();\n newData.dictionary = dictionary;\n return newData;\n });\n return new Vector(newData);\n }\n return this;\n }\n}\n_a = Symbol.toStringTag;\n// Initialize this static property via an IIFE so bundlers don't tree-shake\n// out this logic, but also so we're still compliant with `\"sideEffects\": false`\nVector[_a] = ((proto) => {\n proto.type = DataType.prototype;\n proto.data = [];\n proto.length = 0;\n proto.stride = 1;\n proto.numChildren = 0;\n proto._nullCount = -1;\n proto._byteLength = -1;\n proto._offsets = new Uint32Array([0]);\n proto[Symbol.isConcatSpreadable] = true;\n const typeIds = Object.keys(Type)\n .map((T) => Type[T])\n .filter((T) => typeof T === 'number' && T !== Type.NONE);\n for (const typeId of typeIds) {\n const get = getVisitor.getVisitFnByTypeId(typeId);\n const set = setVisitor.getVisitFnByTypeId(typeId);\n const indexOf = indexOfVisitor.getVisitFnByTypeId(typeId);\n const byteLength = byteLengthVisitor.getVisitFnByTypeId(typeId);\n visitorsByTypeId[typeId] = { get, set, indexOf, byteLength };\n vectorPrototypesByTypeId[typeId] = Object.create(proto, {\n ['isValid']: { value: wrapChunkedCall1(isChunkedValid) },\n ['get']: { value: wrapChunkedCall1(getVisitor.getVisitFnByTypeId(typeId)) },\n ['set']: { value: wrapChunkedCall2(setVisitor.getVisitFnByTypeId(typeId)) },\n ['indexOf']: { value: wrapChunkedIndexOf(indexOfVisitor.getVisitFnByTypeId(typeId)) },\n ['getByteLength']: { value: wrapChunkedCall1(byteLengthVisitor.getVisitFnByTypeId(typeId)) },\n });\n }\n return 'Vector';\n})(Vector.prototype);\nclass MemoizedVector extends Vector {\n constructor(vector) {\n super(vector.data);\n const get = this.get;\n const set = this.set;\n const slice = this.slice;\n const cache = new Array(this.length);\n Object.defineProperty(this, 'get', {\n value(index) {\n const cachedValue = cache[index];\n if (cachedValue !== undefined) {\n return cachedValue;\n }\n const value = get.call(this, index);\n cache[index] = value;\n return value;\n }\n });\n Object.defineProperty(this, 'set', {\n value(index, value) {\n set.call(this, index, value);\n cache[index] = value;\n }\n });\n Object.defineProperty(this, 'slice', {\n value: (begin, end) => new MemoizedVector(slice.call(this, begin, end))\n });\n Object.defineProperty(this, 'isMemoized', { value: true });\n Object.defineProperty(this, 'unmemoize', {\n value: () => new Vector(this.data)\n });\n Object.defineProperty(this, 'memoize', {\n value: () => this\n });\n }\n}\nimport * as dtypes from './type.mjs';\nexport function makeVector(init) {\n if (init) {\n if (init instanceof Data) {\n return new Vector([init]);\n }\n if (init instanceof Vector) {\n return new Vector(init.data);\n }\n if (init.type instanceof DataType) {\n return new Vector([makeData(init)]);\n }\n if (Array.isArray(init)) {\n return new Vector(init.flatMap(v => unwrapInputs(v)));\n }\n if (ArrayBuffer.isView(init)) {\n if (init instanceof DataView) {\n init = new Uint8Array(init.buffer);\n }\n const props = { offset: 0, length: init.length, nullCount: 0, data: init };\n if (init instanceof Int8Array) {\n return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new dtypes.Int8 }))]);\n }\n if (init instanceof Int16Array) {\n return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new dtypes.Int16 }))]);\n }\n if (init instanceof Int32Array) {\n return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new dtypes.Int32 }))]);\n }\n if (init instanceof BigInt64Array) {\n return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new dtypes.Int64 }))]);\n }\n if (init instanceof Uint8Array || init instanceof Uint8ClampedArray) {\n return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new dtypes.Uint8 }))]);\n }\n if (init instanceof Uint16Array) {\n return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new dtypes.Uint16 }))]);\n }\n if (init instanceof Uint32Array) {\n return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new dtypes.Uint32 }))]);\n }\n if (init instanceof BigUint64Array) {\n return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new dtypes.Uint64 }))]);\n }\n if (init instanceof Float32Array) {\n return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new dtypes.Float32 }))]);\n }\n if (init instanceof Float64Array) {\n return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new dtypes.Float64 }))]);\n }\n throw new Error('Unrecognized input');\n }\n }\n throw new Error('Unrecognized input');\n}\nfunction unwrapInputs(x) {\n return x instanceof Data ? [x] : (x instanceof Vector ? x.data : makeVector(x).data);\n}\n\n//# sourceMappingURL=vector.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { valueToString } from '../util/pretty.mjs';\nimport { BigIntAvailable } from '../util/compat.mjs';\n/**\n * Dynamically compile the null values into an `isValid()` function whose\n * implementation is a switch statement. Microbenchmarks in v8 indicate\n * this approach is 25% faster than using an ES6 Map.\n *\n * @example\n * console.log(createIsValidFunction([null, 'N/A', NaN]));\n * `function (x) {\n * if (x !== x) return false;\n * switch (x) {\n * case null:\n * case \"N/A\":\n * return false;\n * }\n * return true;\n * }`\n *\n * @ignore\n * @param nullValues\n */\nexport function createIsValidFunction(nullValues) {\n if (!nullValues || nullValues.length <= 0) {\n // @ts-ignore\n return function isValid(value) { return true; };\n }\n let fnBody = '';\n const noNaNs = nullValues.filter((x) => x === x);\n if (noNaNs.length > 0) {\n fnBody = `\n switch (x) {${noNaNs.map((x) => `\n case ${valueToCase(x)}:`).join('')}\n return false;\n }`;\n }\n // NaN doesn't equal anything including itself, so it doesn't work as a\n // switch case. Instead we must explicitly check for NaN before the switch.\n if (nullValues.length !== noNaNs.length) {\n fnBody = `if (x !== x) return false;\\n${fnBody}`;\n }\n return new Function(`x`, `${fnBody}\\nreturn true;`);\n}\n/** @ignore */\nfunction valueToCase(x) {\n if (typeof x !== 'bigint') {\n return valueToString(x);\n }\n else if (BigIntAvailable) {\n return `${valueToString(x)}n`;\n }\n return `\"${valueToString(x)}\"`;\n}\n\n//# sourceMappingURL=valid.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { memcpy } from '../util/buffer.mjs';\n/** @ignore */\nconst roundLengthUpToNearest64Bytes = (len, BPE) => ((((Math.ceil(len) * BPE) + 63) & ~63) || 64) / BPE;\n/** @ignore */\nconst sliceOrExtendArray = (arr, len = 0) => (arr.length >= len ? arr.subarray(0, len) : memcpy(new arr.constructor(len), arr, 0));\n/** @ignore */\nexport class BufferBuilder {\n constructor(buffer, stride = 1) {\n this.buffer = buffer;\n this.stride = stride;\n this.BYTES_PER_ELEMENT = buffer.BYTES_PER_ELEMENT;\n this.ArrayType = buffer.constructor;\n this._resize(this.length = Math.ceil(buffer.length / stride));\n }\n get byteLength() {\n return Math.ceil(this.length * this.stride) * this.BYTES_PER_ELEMENT;\n }\n get reservedLength() { return this.buffer.length / this.stride; }\n get reservedByteLength() { return this.buffer.byteLength; }\n // @ts-ignore\n set(index, value) { return this; }\n append(value) { return this.set(this.length, value); }\n reserve(extra) {\n if (extra > 0) {\n this.length += extra;\n const stride = this.stride;\n const length = this.length * stride;\n const reserved = this.buffer.length;\n if (length >= reserved) {\n this._resize(reserved === 0\n ? roundLengthUpToNearest64Bytes(length * 1, this.BYTES_PER_ELEMENT)\n : roundLengthUpToNearest64Bytes(length * 2, this.BYTES_PER_ELEMENT));\n }\n }\n return this;\n }\n flush(length = this.length) {\n length = roundLengthUpToNearest64Bytes(length * this.stride, this.BYTES_PER_ELEMENT);\n const array = sliceOrExtendArray(this.buffer, length);\n this.clear();\n return array;\n }\n clear() {\n this.length = 0;\n this._resize(0);\n return this;\n }\n _resize(newLength) {\n return this.buffer = memcpy(new this.ArrayType(newLength), this.buffer);\n }\n}\nBufferBuilder.prototype.offset = 0;\n/** @ignore */\nexport class DataBufferBuilder extends BufferBuilder {\n last() { return this.get(this.length - 1); }\n get(index) { return this.buffer[index]; }\n set(index, value) {\n this.reserve(index - this.length + 1);\n this.buffer[index * this.stride] = value;\n return this;\n }\n}\n/** @ignore */\nexport class BitmapBufferBuilder extends DataBufferBuilder {\n constructor(data = new Uint8Array(0)) {\n super(data, 1 / 8);\n this.numValid = 0;\n }\n get numInvalid() { return this.length - this.numValid; }\n get(idx) { return this.buffer[idx >> 3] >> idx % 8 & 1; }\n set(idx, val) {\n const { buffer } = this.reserve(idx - this.length + 1);\n const byte = idx >> 3, bit = idx % 8, cur = buffer[byte] >> bit & 1;\n // If `val` is truthy and the current bit is 0, flip it to 1 and increment `numValid`.\n // If `val` is falsey and the current bit is 1, flip it to 0 and decrement `numValid`.\n val ? cur === 0 && ((buffer[byte] |= (1 << bit)), ++this.numValid)\n : cur === 1 && ((buffer[byte] &= ~(1 << bit)), --this.numValid);\n return this;\n }\n clear() {\n this.numValid = 0;\n return super.clear();\n }\n}\n/** @ignore */\nexport class OffsetsBufferBuilder extends DataBufferBuilder {\n constructor(data = new Int32Array(1)) { super(data, 1); }\n append(value) {\n return this.set(this.length - 1, value);\n }\n set(index, value) {\n const offset = this.length - 1;\n const buffer = this.reserve(index - offset + 1).buffer;\n if (offset < index++) {\n buffer.fill(buffer[offset], offset, index);\n }\n buffer[index] = buffer[index - 1] + value;\n return this;\n }\n flush(length = this.length - 1) {\n if (length > this.length) {\n this.set(length - 1, 0);\n }\n return super.flush(length + 1);\n }\n}\n\n//# sourceMappingURL=buffer.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Vector } from './vector.mjs';\nimport { makeData } from './data.mjs';\nimport { MapRow, kKeys } from './row/map.mjs';\nimport { strideForType, } from './type.mjs';\nimport { createIsValidFunction } from './builder/valid.mjs';\nimport { BitmapBufferBuilder, DataBufferBuilder, OffsetsBufferBuilder } from './builder/buffer.mjs';\n/**\n * An abstract base class for types that construct Arrow Vectors from arbitrary JavaScript values.\n *\n * A `Builder` is responsible for writing arbitrary JavaScript values\n * to ArrayBuffers and/or child Builders according to the Arrow specification\n * for each DataType, creating or resizing the underlying ArrayBuffers as necessary.\n *\n * The `Builder` for each Arrow `DataType` handles converting and appending\n * values for a given `DataType`. The high-level {@link makeBuilder `makeBuilder()`} convenience\n * method creates the specific `Builder` subclass for the supplied `DataType`.\n *\n * Once created, `Builder` instances support both appending values to the end\n * of the `Builder`, and random-access writes to specific indices\n * (`Builder.prototype.append(value)` is a convenience method for\n * `builder.set(builder.length, value)`). Appending or setting values beyond the\n * Builder's current length may cause the builder to grow its underlying buffers\n * or child Builders (if applicable) to accommodate the new values.\n *\n * After enough values have been written to a `Builder`, `Builder.prototype.flush()`\n * will commit the values to the underlying ArrayBuffers (or child Builders). The\n * internal Builder state will be reset, and an instance of `Data` is returned.\n * Alternatively, `Builder.prototype.toVector()` will flush the `Builder` and return\n * an instance of `Vector` instead.\n *\n * When there are no more values to write, use `Builder.prototype.finish()` to\n * finalize the `Builder`. This does not reset the internal state, so it is\n * necessary to call `Builder.prototype.flush()` or `toVector()` one last time\n * if there are still values queued to be flushed.\n *\n * Note: calling `Builder.prototype.finish()` is required when using a `DictionaryBuilder`,\n * because this is when it flushes the values that have been enqueued in its internal\n * dictionary's `Builder`, and creates the `dictionaryVector` for the `Dictionary` `DataType`.\n *\n * @example\n * ```ts\n * import { Builder, Utf8 } from 'apache-arrow';\n *\n * const utf8Builder = makeBuilder({\n * type: new Utf8(),\n * nullValues: [null, 'n/a']\n * });\n *\n * utf8Builder\n * .append('hello')\n * .append('n/a')\n * .append('world')\n * .append(null);\n *\n * const utf8Vector = utf8Builder.finish().toVector();\n *\n * console.log(utf8Vector.toJSON());\n * // > [\"hello\", null, \"world\", null]\n * ```\n *\n * @typeparam T The `DataType` of this `Builder`.\n * @typeparam TNull The type(s) of values which will be considered null-value sentinels.\n */\nexport class Builder {\n /**\n * Construct a builder with the given Arrow DataType with optional null values,\n * which will be interpreted as \"null\" when set or appended to the `Builder`.\n * @param {{ type: T, nullValues?: any[] }} options A `BuilderOptions` object used to create this `Builder`.\n */\n constructor({ 'type': type, 'nullValues': nulls }) {\n /**\n * The number of values written to the `Builder` that haven't been flushed yet.\n * @readonly\n */\n this.length = 0;\n /**\n * A boolean indicating whether `Builder.prototype.finish()` has been called on this `Builder`.\n * @readonly\n */\n this.finished = false;\n this.type = type;\n this.children = [];\n this.nullValues = nulls;\n this.stride = strideForType(type);\n this._nulls = new BitmapBufferBuilder();\n if (nulls && nulls.length > 0) {\n this._isValid = createIsValidFunction(nulls);\n }\n }\n /** @nocollapse */\n // @ts-ignore\n static throughNode(options) {\n throw new Error(`\"throughNode\" not available in this environment`);\n }\n /** @nocollapse */\n // @ts-ignore\n static throughDOM(options) {\n throw new Error(`\"throughDOM\" not available in this environment`);\n }\n /**\n * Flush the `Builder` and return a `Vector`.\n * @returns {Vector} A `Vector` of the flushed values.\n */\n toVector() { return new Vector([this.flush()]); }\n get ArrayType() { return this.type.ArrayType; }\n get nullCount() { return this._nulls.numInvalid; }\n get numChildren() { return this.children.length; }\n /**\n * @returns The aggregate length (in bytes) of the values that have been written.\n */\n get byteLength() {\n let size = 0;\n const { _offsets, _values, _nulls, _typeIds, children } = this;\n _offsets && (size += _offsets.byteLength);\n _values && (size += _values.byteLength);\n _nulls && (size += _nulls.byteLength);\n _typeIds && (size += _typeIds.byteLength);\n return children.reduce((size, child) => size + child.byteLength, size);\n }\n /**\n * @returns The aggregate number of rows that have been reserved to write new values.\n */\n get reservedLength() {\n return this._nulls.reservedLength;\n }\n /**\n * @returns The aggregate length (in bytes) that has been reserved to write new values.\n */\n get reservedByteLength() {\n let size = 0;\n this._offsets && (size += this._offsets.reservedByteLength);\n this._values && (size += this._values.reservedByteLength);\n this._nulls && (size += this._nulls.reservedByteLength);\n this._typeIds && (size += this._typeIds.reservedByteLength);\n return this.children.reduce((size, child) => size + child.reservedByteLength, size);\n }\n get valueOffsets() { return this._offsets ? this._offsets.buffer : null; }\n get values() { return this._values ? this._values.buffer : null; }\n get nullBitmap() { return this._nulls ? this._nulls.buffer : null; }\n get typeIds() { return this._typeIds ? this._typeIds.buffer : null; }\n /**\n * Appends a value (or null) to this `Builder`.\n * This is equivalent to `builder.set(builder.length, value)`.\n * @param {T['TValue'] | TNull } value The value to append.\n */\n append(value) { return this.set(this.length, value); }\n /**\n * Validates whether a value is valid (true), or null (false)\n * @param {T['TValue'] | TNull } value The value to compare against null the value representations\n */\n isValid(value) { return this._isValid(value); }\n /**\n * Write a value (or null-value sentinel) at the supplied index.\n * If the value matches one of the null-value representations, a 1-bit is\n * written to the null `BitmapBufferBuilder`. Otherwise, a 0 is written to\n * the null `BitmapBufferBuilder`, and the value is passed to\n * `Builder.prototype.setValue()`.\n * @param {number} index The index of the value to write.\n * @param {T['TValue'] | TNull } value The value to write at the supplied index.\n * @returns {this} The updated `Builder` instance.\n */\n set(index, value) {\n if (this.setValid(index, this.isValid(value))) {\n this.setValue(index, value);\n }\n return this;\n }\n /**\n * Write a value to the underlying buffers at the supplied index, bypassing\n * the null-value check. This is a low-level method that\n * @param {number} index\n * @param {T['TValue'] | TNull } value\n */\n setValue(index, value) { this._setValue(this, index, value); }\n setValid(index, valid) {\n this.length = this._nulls.set(index, +valid).length;\n return valid;\n }\n // @ts-ignore\n addChild(child, name = `${this.numChildren}`) {\n throw new Error(`Cannot append children to non-nested type \"${this.type}\"`);\n }\n /**\n * Retrieve the child `Builder` at the supplied `index`, or null if no child\n * exists at that index.\n * @param {number} index The index of the child `Builder` to retrieve.\n * @returns {Builder | null} The child Builder at the supplied index or null.\n */\n getChildAt(index) {\n return this.children[index] || null;\n }\n /**\n * Commit all the values that have been written to their underlying\n * ArrayBuffers, including any child Builders if applicable, and reset\n * the internal `Builder` state.\n * @returns A `Data` of the buffers and children representing the values written.\n */\n flush() {\n let data;\n let typeIds;\n let nullBitmap;\n let valueOffsets;\n const { type, length, nullCount, _typeIds, _offsets, _values, _nulls } = this;\n if (typeIds = _typeIds === null || _typeIds === void 0 ? void 0 : _typeIds.flush(length)) { // Unions\n // DenseUnions\n valueOffsets = _offsets === null || _offsets === void 0 ? void 0 : _offsets.flush(length);\n }\n else if (valueOffsets = _offsets === null || _offsets === void 0 ? void 0 : _offsets.flush(length)) { // Variable-width primitives (Binary, Utf8), and Lists\n // Binary, Utf8\n data = _values === null || _values === void 0 ? void 0 : _values.flush(_offsets.last());\n }\n else { // Fixed-width primitives (Int, Float, Decimal, Time, Timestamp, and Interval)\n data = _values === null || _values === void 0 ? void 0 : _values.flush(length);\n }\n if (nullCount > 0) {\n nullBitmap = _nulls === null || _nulls === void 0 ? void 0 : _nulls.flush(length);\n }\n const children = this.children.map((child) => child.flush());\n this.clear();\n return makeData({\n type, length, nullCount,\n children, 'child': children[0],\n data, typeIds, nullBitmap, valueOffsets,\n });\n }\n /**\n * Finalize this `Builder`, and child builders if applicable.\n * @returns {this} The finalized `Builder` instance.\n */\n finish() {\n this.finished = true;\n for (const child of this.children)\n child.finish();\n return this;\n }\n /**\n * Clear this Builder's internal state, including child Builders if applicable, and reset the length to 0.\n * @returns {this} The cleared `Builder` instance.\n */\n clear() {\n var _a, _b, _c, _d;\n this.length = 0;\n (_a = this._nulls) === null || _a === void 0 ? void 0 : _a.clear();\n (_b = this._values) === null || _b === void 0 ? void 0 : _b.clear();\n (_c = this._offsets) === null || _c === void 0 ? void 0 : _c.clear();\n (_d = this._typeIds) === null || _d === void 0 ? void 0 : _d.clear();\n for (const child of this.children)\n child.clear();\n return this;\n }\n}\nBuilder.prototype.length = 1;\nBuilder.prototype.stride = 1;\nBuilder.prototype.children = null;\nBuilder.prototype.finished = false;\nBuilder.prototype.nullValues = null;\nBuilder.prototype._isValid = () => true;\n/** @ignore */\nexport class FixedWidthBuilder extends Builder {\n constructor(opts) {\n super(opts);\n this._values = new DataBufferBuilder(new this.ArrayType(0), this.stride);\n }\n setValue(index, value) {\n const values = this._values;\n values.reserve(index - values.length + 1);\n return super.setValue(index, value);\n }\n}\n/** @ignore */\nexport class VariableWidthBuilder extends Builder {\n constructor(opts) {\n super(opts);\n this._pendingLength = 0;\n this._offsets = new OffsetsBufferBuilder();\n }\n setValue(index, value) {\n const pending = this._pending || (this._pending = new Map());\n const current = pending.get(index);\n current && (this._pendingLength -= current.length);\n this._pendingLength += (value instanceof MapRow) ? value[kKeys].length : value.length;\n pending.set(index, value);\n }\n setValid(index, isValid) {\n if (!super.setValid(index, isValid)) {\n (this._pending || (this._pending = new Map())).set(index, undefined);\n return false;\n }\n return true;\n }\n clear() {\n this._pendingLength = 0;\n this._pending = undefined;\n return super.clear();\n }\n flush() {\n this._flush();\n return super.flush();\n }\n finish() {\n this._flush();\n return super.finish();\n }\n _flush() {\n const pending = this._pending;\n const pendingLength = this._pendingLength;\n this._pendingLength = 0;\n this._pending = undefined;\n if (pending && pending.size > 0) {\n this._flushPending(pending, pendingLength);\n }\n return this;\n }\n}\n\n//# sourceMappingURL=builder.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nexport class Block {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n /**\n * Index to the start of the RecordBlock (note this is past the Message header)\n */\n offset() {\n return this.bb.readInt64(this.bb_pos);\n }\n /**\n * Length of the metadata\n */\n metaDataLength() {\n return this.bb.readInt32(this.bb_pos + 8);\n }\n /**\n * Length of the data (this is aligned so there can be a gap between this and\n * the metadata).\n */\n bodyLength() {\n return this.bb.readInt64(this.bb_pos + 16);\n }\n static sizeOf() {\n return 24;\n }\n static createBlock(builder, offset, metaDataLength, bodyLength) {\n builder.prep(8, 24);\n builder.writeInt64(bodyLength);\n builder.pad(4);\n builder.writeInt32(metaDataLength);\n builder.writeInt64(offset);\n return builder.offset();\n }\n}\n\n//# sourceMappingURL=block.mjs.map\n","export const SIZEOF_SHORT = 2;\r\nexport const SIZEOF_INT = 4;\r\nexport const FILE_IDENTIFIER_LENGTH = 4;\r\nexport const SIZE_PREFIX_LENGTH = 4;\r\n","export const int32 = new Int32Array(2);\r\nexport const float32 = new Float32Array(int32.buffer);\r\nexport const float64 = new Float64Array(int32.buffer);\r\nexport const isLittleEndian = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;\r\n","export function createLong(low, high) {\r\n return Long.create(low, high);\r\n}\r\nexport class Long {\r\n constructor(low, high) {\r\n this.low = low | 0;\r\n this.high = high | 0;\r\n }\r\n static create(low, high) {\r\n // Special-case zero to avoid GC overhead for default values\r\n return low == 0 && high == 0 ? Long.ZERO : new Long(low, high);\r\n }\r\n toFloat64() {\r\n return (this.low >>> 0) + this.high * 0x100000000;\r\n }\r\n equals(other) {\r\n return this.low == other.low && this.high == other.high;\r\n }\r\n}\r\nLong.ZERO = new Long(0, 0);\r\n","export var Encoding;\r\n(function (Encoding) {\r\n Encoding[Encoding[\"UTF8_BYTES\"] = 1] = \"UTF8_BYTES\";\r\n Encoding[Encoding[\"UTF16_STRING\"] = 2] = \"UTF16_STRING\";\r\n})(Encoding || (Encoding = {}));\r\n","import { FILE_IDENTIFIER_LENGTH, SIZEOF_INT } from \"./constants\";\r\nimport { Long } from \"./long\";\r\nimport { int32, isLittleEndian, float32, float64 } from \"./utils\";\r\nimport { Encoding } from \"./encoding\";\r\nexport class ByteBuffer {\r\n /**\r\n * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)\r\n */\r\n constructor(bytes_) {\r\n this.bytes_ = bytes_;\r\n this.position_ = 0;\r\n }\r\n /**\r\n * Create and allocate a new ByteBuffer with a given size.\r\n */\r\n static allocate(byte_size) {\r\n return new ByteBuffer(new Uint8Array(byte_size));\r\n }\r\n clear() {\r\n this.position_ = 0;\r\n }\r\n /**\r\n * Get the underlying `Uint8Array`.\r\n */\r\n bytes() {\r\n return this.bytes_;\r\n }\r\n /**\r\n * Get the buffer's position.\r\n */\r\n position() {\r\n return this.position_;\r\n }\r\n /**\r\n * Set the buffer's position.\r\n */\r\n setPosition(position) {\r\n this.position_ = position;\r\n }\r\n /**\r\n * Get the buffer's capacity.\r\n */\r\n capacity() {\r\n return this.bytes_.length;\r\n }\r\n readInt8(offset) {\r\n return this.readUint8(offset) << 24 >> 24;\r\n }\r\n readUint8(offset) {\r\n return this.bytes_[offset];\r\n }\r\n readInt16(offset) {\r\n return this.readUint16(offset) << 16 >> 16;\r\n }\r\n readUint16(offset) {\r\n return this.bytes_[offset] | this.bytes_[offset + 1] << 8;\r\n }\r\n readInt32(offset) {\r\n return this.bytes_[offset] | this.bytes_[offset + 1] << 8 | this.bytes_[offset + 2] << 16 | this.bytes_[offset + 3] << 24;\r\n }\r\n readUint32(offset) {\r\n return this.readInt32(offset) >>> 0;\r\n }\r\n readInt64(offset) {\r\n return new Long(this.readInt32(offset), this.readInt32(offset + 4));\r\n }\r\n readUint64(offset) {\r\n return new Long(this.readUint32(offset), this.readUint32(offset + 4));\r\n }\r\n readFloat32(offset) {\r\n int32[0] = this.readInt32(offset);\r\n return float32[0];\r\n }\r\n readFloat64(offset) {\r\n int32[isLittleEndian ? 0 : 1] = this.readInt32(offset);\r\n int32[isLittleEndian ? 1 : 0] = this.readInt32(offset + 4);\r\n return float64[0];\r\n }\r\n writeInt8(offset, value) {\r\n this.bytes_[offset] = value;\r\n }\r\n writeUint8(offset, value) {\r\n this.bytes_[offset] = value;\r\n }\r\n writeInt16(offset, value) {\r\n this.bytes_[offset] = value;\r\n this.bytes_[offset + 1] = value >> 8;\r\n }\r\n writeUint16(offset, value) {\r\n this.bytes_[offset] = value;\r\n this.bytes_[offset + 1] = value >> 8;\r\n }\r\n writeInt32(offset, value) {\r\n this.bytes_[offset] = value;\r\n this.bytes_[offset + 1] = value >> 8;\r\n this.bytes_[offset + 2] = value >> 16;\r\n this.bytes_[offset + 3] = value >> 24;\r\n }\r\n writeUint32(offset, value) {\r\n this.bytes_[offset] = value;\r\n this.bytes_[offset + 1] = value >> 8;\r\n this.bytes_[offset + 2] = value >> 16;\r\n this.bytes_[offset + 3] = value >> 24;\r\n }\r\n writeInt64(offset, value) {\r\n this.writeInt32(offset, value.low);\r\n this.writeInt32(offset + 4, value.high);\r\n }\r\n writeUint64(offset, value) {\r\n this.writeUint32(offset, value.low);\r\n this.writeUint32(offset + 4, value.high);\r\n }\r\n writeFloat32(offset, value) {\r\n float32[0] = value;\r\n this.writeInt32(offset, int32[0]);\r\n }\r\n writeFloat64(offset, value) {\r\n float64[0] = value;\r\n this.writeInt32(offset, int32[isLittleEndian ? 0 : 1]);\r\n this.writeInt32(offset + 4, int32[isLittleEndian ? 1 : 0]);\r\n }\r\n /**\r\n * Return the file identifier. Behavior is undefined for FlatBuffers whose\r\n * schema does not include a file_identifier (likely points at padding or the\r\n * start of a the root vtable).\r\n */\r\n getBufferIdentifier() {\r\n if (this.bytes_.length < this.position_ + SIZEOF_INT +\r\n FILE_IDENTIFIER_LENGTH) {\r\n throw new Error('FlatBuffers: ByteBuffer is too short to contain an identifier.');\r\n }\r\n let result = \"\";\r\n for (let i = 0; i < FILE_IDENTIFIER_LENGTH; i++) {\r\n result += String.fromCharCode(this.readInt8(this.position_ + SIZEOF_INT + i));\r\n }\r\n return result;\r\n }\r\n /**\r\n * Look up a field in the vtable, return an offset into the object, or 0 if the\r\n * field is not present.\r\n */\r\n __offset(bb_pos, vtable_offset) {\r\n const vtable = bb_pos - this.readInt32(bb_pos);\r\n return vtable_offset < this.readInt16(vtable) ? this.readInt16(vtable + vtable_offset) : 0;\r\n }\r\n /**\r\n * Initialize any Table-derived type to point to the union at the given offset.\r\n */\r\n __union(t, offset) {\r\n t.bb_pos = offset + this.readInt32(offset);\r\n t.bb = this;\r\n return t;\r\n }\r\n /**\r\n * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer.\r\n * This allocates a new string and converts to wide chars upon each access.\r\n *\r\n * To avoid the conversion to UTF-16, pass Encoding.UTF8_BYTES as\r\n * the \"optionalEncoding\" argument. This is useful for avoiding conversion to\r\n * and from UTF-16 when the data will just be packaged back up in another\r\n * FlatBuffer later on.\r\n *\r\n * @param offset\r\n * @param opt_encoding Defaults to UTF16_STRING\r\n */\r\n __string(offset, opt_encoding) {\r\n offset += this.readInt32(offset);\r\n const length = this.readInt32(offset);\r\n let result = '';\r\n let i = 0;\r\n offset += SIZEOF_INT;\r\n if (opt_encoding === Encoding.UTF8_BYTES) {\r\n return this.bytes_.subarray(offset, offset + length);\r\n }\r\n while (i < length) {\r\n let codePoint;\r\n // Decode UTF-8\r\n const a = this.readUint8(offset + i++);\r\n if (a < 0xC0) {\r\n codePoint = a;\r\n }\r\n else {\r\n const b = this.readUint8(offset + i++);\r\n if (a < 0xE0) {\r\n codePoint =\r\n ((a & 0x1F) << 6) |\r\n (b & 0x3F);\r\n }\r\n else {\r\n const c = this.readUint8(offset + i++);\r\n if (a < 0xF0) {\r\n codePoint =\r\n ((a & 0x0F) << 12) |\r\n ((b & 0x3F) << 6) |\r\n (c & 0x3F);\r\n }\r\n else {\r\n const d = this.readUint8(offset + i++);\r\n codePoint =\r\n ((a & 0x07) << 18) |\r\n ((b & 0x3F) << 12) |\r\n ((c & 0x3F) << 6) |\r\n (d & 0x3F);\r\n }\r\n }\r\n }\r\n // Encode UTF-16\r\n if (codePoint < 0x10000) {\r\n result += String.fromCharCode(codePoint);\r\n }\r\n else {\r\n codePoint -= 0x10000;\r\n result += String.fromCharCode((codePoint >> 10) + 0xD800, (codePoint & ((1 << 10) - 1)) + 0xDC00);\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * Handle unions that can contain string as its member, if a Table-derived type then initialize it,\r\n * if a string then return a new one\r\n *\r\n * WARNING: strings are immutable in JS so we can't change the string that the user gave us, this\r\n * makes the behaviour of __union_with_string different compared to __union\r\n */\r\n __union_with_string(o, offset) {\r\n if (typeof o === 'string') {\r\n return this.__string(offset);\r\n }\r\n return this.__union(o, offset);\r\n }\r\n /**\r\n * Retrieve the relative offset stored at \"offset\"\r\n */\r\n __indirect(offset) {\r\n return offset + this.readInt32(offset);\r\n }\r\n /**\r\n * Get the start of data of a vector whose offset is stored at \"offset\" in this object.\r\n */\r\n __vector(offset) {\r\n return offset + this.readInt32(offset) + SIZEOF_INT; // data starts after the length\r\n }\r\n /**\r\n * Get the length of a vector whose offset is stored at \"offset\" in this object.\r\n */\r\n __vector_len(offset) {\r\n return this.readInt32(offset + this.readInt32(offset));\r\n }\r\n __has_identifier(ident) {\r\n if (ident.length != FILE_IDENTIFIER_LENGTH) {\r\n throw new Error('FlatBuffers: file identifier must be length ' +\r\n FILE_IDENTIFIER_LENGTH);\r\n }\r\n for (let i = 0; i < FILE_IDENTIFIER_LENGTH; i++) {\r\n if (ident.charCodeAt(i) != this.readInt8(this.position() + SIZEOF_INT + i)) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n /**\r\n * A helper function to avoid generated code depending on this file directly.\r\n */\r\n createLong(low, high) {\r\n return Long.create(low, high);\r\n }\r\n /**\r\n * A helper function for generating list for obj api\r\n */\r\n createScalarList(listAccessor, listLength) {\r\n const ret = [];\r\n for (let i = 0; i < listLength; ++i) {\r\n if (listAccessor(i) !== null) {\r\n ret.push(listAccessor(i));\r\n }\r\n }\r\n return ret;\r\n }\r\n /**\r\n * A helper function for generating list for obj api\r\n * @param listAccessor function that accepts an index and return data at that index\r\n * @param listLength listLength\r\n * @param res result list\r\n */\r\n createObjList(listAccessor, listLength) {\r\n const ret = [];\r\n for (let i = 0; i < listLength; ++i) {\r\n const val = listAccessor(i);\r\n if (val !== null) {\r\n ret.push(val.unpack());\r\n }\r\n }\r\n return ret;\r\n }\r\n}\r\n","import { ByteBuffer } from \"./byte-buffer\";\r\nimport { SIZEOF_SHORT, SIZE_PREFIX_LENGTH, SIZEOF_INT, FILE_IDENTIFIER_LENGTH } from \"./constants\";\r\nimport { Long } from \"./long\";\r\nexport class Builder {\r\n /**\r\n * Create a FlatBufferBuilder.\r\n */\r\n constructor(opt_initial_size) {\r\n /** Minimum alignment encountered so far. */\r\n this.minalign = 1;\r\n /** The vtable for the current table. */\r\n this.vtable = null;\r\n /** The amount of fields we're actually using. */\r\n this.vtable_in_use = 0;\r\n /** Whether we are currently serializing a table. */\r\n this.isNested = false;\r\n /** Starting offset of the current struct/table. */\r\n this.object_start = 0;\r\n /** List of offsets of all vtables. */\r\n this.vtables = [];\r\n /** For the current vector being built. */\r\n this.vector_num_elems = 0;\r\n /** False omits default values from the serialized data */\r\n this.force_defaults = false;\r\n this.string_maps = null;\r\n let initial_size;\r\n if (!opt_initial_size) {\r\n initial_size = 1024;\r\n }\r\n else {\r\n initial_size = opt_initial_size;\r\n }\r\n /**\r\n * @type {ByteBuffer}\r\n * @private\r\n */\r\n this.bb = ByteBuffer.allocate(initial_size);\r\n this.space = initial_size;\r\n }\r\n clear() {\r\n this.bb.clear();\r\n this.space = this.bb.capacity();\r\n this.minalign = 1;\r\n this.vtable = null;\r\n this.vtable_in_use = 0;\r\n this.isNested = false;\r\n this.object_start = 0;\r\n this.vtables = [];\r\n this.vector_num_elems = 0;\r\n this.force_defaults = false;\r\n this.string_maps = null;\r\n }\r\n /**\r\n * In order to save space, fields that are set to their default value\r\n * don't get serialized into the buffer. Forcing defaults provides a\r\n * way to manually disable this optimization.\r\n *\r\n * @param forceDefaults true always serializes default values\r\n */\r\n forceDefaults(forceDefaults) {\r\n this.force_defaults = forceDefaults;\r\n }\r\n /**\r\n * Get the ByteBuffer representing the FlatBuffer. Only call this after you've\r\n * called finish(). The actual data starts at the ByteBuffer's current position,\r\n * not necessarily at 0.\r\n */\r\n dataBuffer() {\r\n return this.bb;\r\n }\r\n /**\r\n * Get the bytes representing the FlatBuffer. Only call this after you've\r\n * called finish().\r\n */\r\n asUint8Array() {\r\n return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset());\r\n }\r\n /**\r\n * Prepare to write an element of `size` after `additional_bytes` have been\r\n * written, e.g. if you write a string, you need to align such the int length\r\n * field is aligned to 4 bytes, and the string data follows it directly. If all\r\n * you need to do is alignment, `additional_bytes` will be 0.\r\n *\r\n * @param size This is the of the new element to write\r\n * @param additional_bytes The padding size\r\n */\r\n prep(size, additional_bytes) {\r\n // Track the biggest thing we've ever aligned to.\r\n if (size > this.minalign) {\r\n this.minalign = size;\r\n }\r\n // Find the amount of alignment needed such that `size` is properly\r\n // aligned after `additional_bytes`\r\n const align_size = ((~(this.bb.capacity() - this.space + additional_bytes)) + 1) & (size - 1);\r\n // Reallocate the buffer if needed.\r\n while (this.space < align_size + size + additional_bytes) {\r\n const old_buf_size = this.bb.capacity();\r\n this.bb = Builder.growByteBuffer(this.bb);\r\n this.space += this.bb.capacity() - old_buf_size;\r\n }\r\n this.pad(align_size);\r\n }\r\n pad(byte_size) {\r\n for (let i = 0; i < byte_size; i++) {\r\n this.bb.writeInt8(--this.space, 0);\r\n }\r\n }\r\n writeInt8(value) {\r\n this.bb.writeInt8(this.space -= 1, value);\r\n }\r\n writeInt16(value) {\r\n this.bb.writeInt16(this.space -= 2, value);\r\n }\r\n writeInt32(value) {\r\n this.bb.writeInt32(this.space -= 4, value);\r\n }\r\n writeInt64(value) {\r\n this.bb.writeInt64(this.space -= 8, value);\r\n }\r\n writeFloat32(value) {\r\n this.bb.writeFloat32(this.space -= 4, value);\r\n }\r\n writeFloat64(value) {\r\n this.bb.writeFloat64(this.space -= 8, value);\r\n }\r\n /**\r\n * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).\r\n * @param value The `int8` to add the the buffer.\r\n */\r\n addInt8(value) {\r\n this.prep(1, 0);\r\n this.writeInt8(value);\r\n }\r\n /**\r\n * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).\r\n * @param value The `int16` to add the the buffer.\r\n */\r\n addInt16(value) {\r\n this.prep(2, 0);\r\n this.writeInt16(value);\r\n }\r\n /**\r\n * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).\r\n * @param value The `int32` to add the the buffer.\r\n */\r\n addInt32(value) {\r\n this.prep(4, 0);\r\n this.writeInt32(value);\r\n }\r\n /**\r\n * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).\r\n * @param value The `int64` to add the the buffer.\r\n */\r\n addInt64(value) {\r\n this.prep(8, 0);\r\n this.writeInt64(value);\r\n }\r\n /**\r\n * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).\r\n * @param value The `float32` to add the the buffer.\r\n */\r\n addFloat32(value) {\r\n this.prep(4, 0);\r\n this.writeFloat32(value);\r\n }\r\n /**\r\n * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).\r\n * @param value The `float64` to add the the buffer.\r\n */\r\n addFloat64(value) {\r\n this.prep(8, 0);\r\n this.writeFloat64(value);\r\n }\r\n addFieldInt8(voffset, value, defaultValue) {\r\n if (this.force_defaults || value != defaultValue) {\r\n this.addInt8(value);\r\n this.slot(voffset);\r\n }\r\n }\r\n addFieldInt16(voffset, value, defaultValue) {\r\n if (this.force_defaults || value != defaultValue) {\r\n this.addInt16(value);\r\n this.slot(voffset);\r\n }\r\n }\r\n addFieldInt32(voffset, value, defaultValue) {\r\n if (this.force_defaults || value != defaultValue) {\r\n this.addInt32(value);\r\n this.slot(voffset);\r\n }\r\n }\r\n addFieldInt64(voffset, value, defaultValue) {\r\n if (this.force_defaults || !value.equals(defaultValue)) {\r\n this.addInt64(value);\r\n this.slot(voffset);\r\n }\r\n }\r\n addFieldFloat32(voffset, value, defaultValue) {\r\n if (this.force_defaults || value != defaultValue) {\r\n this.addFloat32(value);\r\n this.slot(voffset);\r\n }\r\n }\r\n addFieldFloat64(voffset, value, defaultValue) {\r\n if (this.force_defaults || value != defaultValue) {\r\n this.addFloat64(value);\r\n this.slot(voffset);\r\n }\r\n }\r\n addFieldOffset(voffset, value, defaultValue) {\r\n if (this.force_defaults || value != defaultValue) {\r\n this.addOffset(value);\r\n this.slot(voffset);\r\n }\r\n }\r\n /**\r\n * Structs are stored inline, so nothing additional is being added. `d` is always 0.\r\n */\r\n addFieldStruct(voffset, value, defaultValue) {\r\n if (value != defaultValue) {\r\n this.nested(value);\r\n this.slot(voffset);\r\n }\r\n }\r\n /**\r\n * Structures are always stored inline, they need to be created right\r\n * where they're used. You'll get this assertion failure if you\r\n * created it elsewhere.\r\n */\r\n nested(obj) {\r\n if (obj != this.offset()) {\r\n throw new Error('FlatBuffers: struct must be serialized inline.');\r\n }\r\n }\r\n /**\r\n * Should not be creating any other object, string or vector\r\n * while an object is being constructed\r\n */\r\n notNested() {\r\n if (this.isNested) {\r\n throw new Error('FlatBuffers: object serialization must not be nested.');\r\n }\r\n }\r\n /**\r\n * Set the current vtable at `voffset` to the current location in the buffer.\r\n */\r\n slot(voffset) {\r\n if (this.vtable !== null)\r\n this.vtable[voffset] = this.offset();\r\n }\r\n /**\r\n * @returns Offset relative to the end of the buffer.\r\n */\r\n offset() {\r\n return this.bb.capacity() - this.space;\r\n }\r\n /**\r\n * Doubles the size of the backing ByteBuffer and copies the old data towards\r\n * the end of the new buffer (since we build the buffer backwards).\r\n *\r\n * @param bb The current buffer with the existing data\r\n * @returns A new byte buffer with the old data copied\r\n * to it. The data is located at the end of the buffer.\r\n *\r\n * uint8Array.set() formally takes {Array|ArrayBufferView}, so to pass\r\n * it a uint8Array we need to suppress the type check:\r\n * @suppress {checkTypes}\r\n */\r\n static growByteBuffer(bb) {\r\n const old_buf_size = bb.capacity();\r\n // Ensure we don't grow beyond what fits in an int.\r\n if (old_buf_size & 0xC0000000) {\r\n throw new Error('FlatBuffers: cannot grow buffer beyond 2 gigabytes.');\r\n }\r\n const new_buf_size = old_buf_size << 1;\r\n const nbb = ByteBuffer.allocate(new_buf_size);\r\n nbb.setPosition(new_buf_size - old_buf_size);\r\n nbb.bytes().set(bb.bytes(), new_buf_size - old_buf_size);\r\n return nbb;\r\n }\r\n /**\r\n * Adds on offset, relative to where it will be written.\r\n *\r\n * @param offset The offset to add.\r\n */\r\n addOffset(offset) {\r\n this.prep(SIZEOF_INT, 0); // Ensure alignment is already done.\r\n this.writeInt32(this.offset() - offset + SIZEOF_INT);\r\n }\r\n /**\r\n * Start encoding a new object in the buffer. Users will not usually need to\r\n * call this directly. The FlatBuffers compiler will generate helper methods\r\n * that call this method internally.\r\n */\r\n startObject(numfields) {\r\n this.notNested();\r\n if (this.vtable == null) {\r\n this.vtable = [];\r\n }\r\n this.vtable_in_use = numfields;\r\n for (let i = 0; i < numfields; i++) {\r\n this.vtable[i] = 0; // This will push additional elements as needed\r\n }\r\n this.isNested = true;\r\n this.object_start = this.offset();\r\n }\r\n /**\r\n * Finish off writing the object that is under construction.\r\n *\r\n * @returns The offset to the object inside `dataBuffer`\r\n */\r\n endObject() {\r\n if (this.vtable == null || !this.isNested) {\r\n throw new Error('FlatBuffers: endObject called without startObject');\r\n }\r\n this.addInt32(0);\r\n const vtableloc = this.offset();\r\n // Trim trailing zeroes.\r\n let i = this.vtable_in_use - 1;\r\n // eslint-disable-next-line no-empty\r\n for (; i >= 0 && this.vtable[i] == 0; i--) { }\r\n const trimmed_size = i + 1;\r\n // Write out the current vtable.\r\n for (; i >= 0; i--) {\r\n // Offset relative to the start of the table.\r\n this.addInt16(this.vtable[i] != 0 ? vtableloc - this.vtable[i] : 0);\r\n }\r\n const standard_fields = 2; // The fields below:\r\n this.addInt16(vtableloc - this.object_start);\r\n const len = (trimmed_size + standard_fields) * SIZEOF_SHORT;\r\n this.addInt16(len);\r\n // Search for an existing vtable that matches the current one.\r\n let existing_vtable = 0;\r\n const vt1 = this.space;\r\n outer_loop: for (i = 0; i < this.vtables.length; i++) {\r\n const vt2 = this.bb.capacity() - this.vtables[i];\r\n if (len == this.bb.readInt16(vt2)) {\r\n for (let j = SIZEOF_SHORT; j < len; j += SIZEOF_SHORT) {\r\n if (this.bb.readInt16(vt1 + j) != this.bb.readInt16(vt2 + j)) {\r\n continue outer_loop;\r\n }\r\n }\r\n existing_vtable = this.vtables[i];\r\n break;\r\n }\r\n }\r\n if (existing_vtable) {\r\n // Found a match:\r\n // Remove the current vtable.\r\n this.space = this.bb.capacity() - vtableloc;\r\n // Point table to existing vtable.\r\n this.bb.writeInt32(this.space, existing_vtable - vtableloc);\r\n }\r\n else {\r\n // No match:\r\n // Add the location of the current vtable to the list of vtables.\r\n this.vtables.push(this.offset());\r\n // Point table to current vtable.\r\n this.bb.writeInt32(this.bb.capacity() - vtableloc, this.offset() - vtableloc);\r\n }\r\n this.isNested = false;\r\n return vtableloc;\r\n }\r\n /**\r\n * Finalize a buffer, poiting to the given `root_table`.\r\n */\r\n finish(root_table, opt_file_identifier, opt_size_prefix) {\r\n const size_prefix = opt_size_prefix ? SIZE_PREFIX_LENGTH : 0;\r\n if (opt_file_identifier) {\r\n const file_identifier = opt_file_identifier;\r\n this.prep(this.minalign, SIZEOF_INT +\r\n FILE_IDENTIFIER_LENGTH + size_prefix);\r\n if (file_identifier.length != FILE_IDENTIFIER_LENGTH) {\r\n throw new Error('FlatBuffers: file identifier must be length ' +\r\n FILE_IDENTIFIER_LENGTH);\r\n }\r\n for (let i = FILE_IDENTIFIER_LENGTH - 1; i >= 0; i--) {\r\n this.writeInt8(file_identifier.charCodeAt(i));\r\n }\r\n }\r\n this.prep(this.minalign, SIZEOF_INT + size_prefix);\r\n this.addOffset(root_table);\r\n if (size_prefix) {\r\n this.addInt32(this.bb.capacity() - this.space);\r\n }\r\n this.bb.setPosition(this.space);\r\n }\r\n /**\r\n * Finalize a size prefixed buffer, pointing to the given `root_table`.\r\n */\r\n finishSizePrefixed(root_table, opt_file_identifier) {\r\n this.finish(root_table, opt_file_identifier, true);\r\n }\r\n /**\r\n * This checks a required field has been set in a given table that has\r\n * just been constructed.\r\n */\r\n requiredField(table, field) {\r\n const table_start = this.bb.capacity() - table;\r\n const vtable_start = table_start - this.bb.readInt32(table_start);\r\n const ok = this.bb.readInt16(vtable_start + field) != 0;\r\n // If this fails, the caller will show what field needs to be set.\r\n if (!ok) {\r\n throw new Error('FlatBuffers: field ' + field + ' must be set');\r\n }\r\n }\r\n /**\r\n * Start a new array/vector of objects. Users usually will not call\r\n * this directly. The FlatBuffers compiler will create a start/end\r\n * method for vector types in generated code.\r\n *\r\n * @param elem_size The size of each element in the array\r\n * @param num_elems The number of elements in the array\r\n * @param alignment The alignment of the array\r\n */\r\n startVector(elem_size, num_elems, alignment) {\r\n this.notNested();\r\n this.vector_num_elems = num_elems;\r\n this.prep(SIZEOF_INT, elem_size * num_elems);\r\n this.prep(alignment, elem_size * num_elems); // Just in case alignment > int.\r\n }\r\n /**\r\n * Finish off the creation of an array and all its elements. The array must be\r\n * created with `startVector`.\r\n *\r\n * @returns The offset at which the newly created array\r\n * starts.\r\n */\r\n endVector() {\r\n this.writeInt32(this.vector_num_elems);\r\n return this.offset();\r\n }\r\n /**\r\n * Encode the string `s` in the buffer using UTF-8. If the string passed has\r\n * already been seen, we return the offset of the already written string\r\n *\r\n * @param s The string to encode\r\n * @return The offset in the buffer where the encoded string starts\r\n */\r\n createSharedString(s) {\r\n if (!s) {\r\n return 0;\r\n }\r\n if (!this.string_maps) {\r\n this.string_maps = new Map();\r\n }\r\n if (this.string_maps.has(s)) {\r\n return this.string_maps.get(s);\r\n }\r\n const offset = this.createString(s);\r\n this.string_maps.set(s, offset);\r\n return offset;\r\n }\r\n /**\r\n * Encode the string `s` in the buffer using UTF-8. If a Uint8Array is passed\r\n * instead of a string, it is assumed to contain valid UTF-8 encoded data.\r\n *\r\n * @param s The string to encode\r\n * @return The offset in the buffer where the encoded string starts\r\n */\r\n createString(s) {\r\n if (!s) {\r\n return 0;\r\n }\r\n let utf8;\r\n if (s instanceof Uint8Array) {\r\n utf8 = s;\r\n }\r\n else {\r\n utf8 = [];\r\n let i = 0;\r\n while (i < s.length) {\r\n let codePoint;\r\n // Decode UTF-16\r\n const a = s.charCodeAt(i++);\r\n if (a < 0xD800 || a >= 0xDC00) {\r\n codePoint = a;\r\n }\r\n else {\r\n const b = s.charCodeAt(i++);\r\n codePoint = (a << 10) + b + (0x10000 - (0xD800 << 10) - 0xDC00);\r\n }\r\n // Encode UTF-8\r\n if (codePoint < 0x80) {\r\n utf8.push(codePoint);\r\n }\r\n else {\r\n if (codePoint < 0x800) {\r\n utf8.push(((codePoint >> 6) & 0x1F) | 0xC0);\r\n }\r\n else {\r\n if (codePoint < 0x10000) {\r\n utf8.push(((codePoint >> 12) & 0x0F) | 0xE0);\r\n }\r\n else {\r\n utf8.push(((codePoint >> 18) & 0x07) | 0xF0, ((codePoint >> 12) & 0x3F) | 0x80);\r\n }\r\n utf8.push(((codePoint >> 6) & 0x3F) | 0x80);\r\n }\r\n utf8.push((codePoint & 0x3F) | 0x80);\r\n }\r\n }\r\n }\r\n this.addInt8(0);\r\n this.startVector(1, utf8.length, 1);\r\n this.bb.setPosition(this.space -= utf8.length);\r\n for (let i = 0, offset = this.space, bytes = this.bb.bytes(); i < utf8.length; i++) {\r\n bytes[offset++] = utf8[i];\r\n }\r\n return this.endVector();\r\n }\r\n /**\r\n * A helper function to avoid generated code depending on this file directly.\r\n */\r\n createLong(low, high) {\r\n return Long.create(low, high);\r\n }\r\n /**\r\n * A helper function to pack an object\r\n *\r\n * @returns offset of obj\r\n */\r\n createObjectOffset(obj) {\r\n if (obj === null) {\r\n return 0;\r\n }\r\n if (typeof obj === 'string') {\r\n return this.createString(obj);\r\n }\r\n else {\r\n return obj.pack(this);\r\n }\r\n }\r\n /**\r\n * A helper function to pack a list of object\r\n *\r\n * @returns list of offsets of each non null object\r\n */\r\n createObjectOffsetList(list) {\r\n const ret = [];\r\n for (let i = 0; i < list.length; ++i) {\r\n const val = list[i];\r\n if (val !== null) {\r\n ret.push(this.createObjectOffset(val));\r\n }\r\n else {\r\n throw new Error('FlatBuffers: Argument for createObjectOffsetList cannot contain null.');\r\n }\r\n }\r\n return ret;\r\n }\r\n createStructOffsetList(list, startFunc) {\r\n startFunc(this, list.length);\r\n this.createObjectOffsetList(list);\r\n return this.endVector();\r\n }\r\n}\r\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\n/**\n * ----------------------------------------------------------------------\n * user defined key value pairs to add custom metadata to arrow\n * key namespacing is the responsibility of the user\n */\nexport class KeyValue {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsKeyValue(bb, obj) {\n return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsKeyValue(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n key(optionalEncoding) {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;\n }\n value(optionalEncoding) {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;\n }\n static startKeyValue(builder) {\n builder.startObject(2);\n }\n static addKey(builder, keyOffset) {\n builder.addFieldOffset(0, keyOffset, 0);\n }\n static addValue(builder, valueOffset) {\n builder.addFieldOffset(1, valueOffset, 0);\n }\n static endKeyValue(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createKeyValue(builder, keyOffset, valueOffset) {\n KeyValue.startKeyValue(builder);\n KeyValue.addKey(builder, keyOffset);\n KeyValue.addValue(builder, valueOffset);\n return KeyValue.endKeyValue(builder);\n }\n}\n\n//# sourceMappingURL=key-value.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\n/**\n * Logical types, vector layouts, and schemas\n * Format Version History.\n * Version 1.0 - Forward and backwards compatibility guaranteed.\n * Version 1.1 - Add Decimal256 (No format release).\n * Version 1.2 (Pending)- Add Interval MONTH_DAY_NANO\n */\nexport var MetadataVersion;\n(function (MetadataVersion) {\n /**\n * 0.1.0 (October 2016).\n */\n MetadataVersion[MetadataVersion[\"V1\"] = 0] = \"V1\";\n /**\n * 0.2.0 (February 2017). Non-backwards compatible with V1.\n */\n MetadataVersion[MetadataVersion[\"V2\"] = 1] = \"V2\";\n /**\n * 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2.\n */\n MetadataVersion[MetadataVersion[\"V3\"] = 2] = \"V3\";\n /**\n * >= 0.8.0 (December 2017). Non-backwards compatible with V3.\n */\n MetadataVersion[MetadataVersion[\"V4\"] = 3] = \"V4\";\n /**\n * >= 1.0.0 (July 2020. Backwards compatible with V4 (V5 readers can read V4\n * metadata and IPC messages). Implementations are recommended to provide a\n * V4 compatibility mode with V5 format changes disabled.\n *\n * Incompatible changes between V4 and V5:\n * - Union buffer layout has changed. In V5, Unions don't have a validity\n * bitmap buffer.\n */\n MetadataVersion[MetadataVersion[\"V5\"] = 4] = \"V5\";\n})(MetadataVersion || (MetadataVersion = {}));\n\n//# sourceMappingURL=metadata-version.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\n/**\n * ----------------------------------------------------------------------\n * Endianness of the platform producing the data\n */\nexport var Endianness;\n(function (Endianness) {\n Endianness[Endianness[\"Little\"] = 0] = \"Little\";\n Endianness[Endianness[\"Big\"] = 1] = \"Big\";\n})(Endianness || (Endianness = {}));\n\n//# sourceMappingURL=endianness.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\n/**\n * ----------------------------------------------------------------------\n * Dictionary encoding metadata\n * Maintained for forwards compatibility, in the future\n * Dictionaries might be explicit maps between integers and values\n * allowing for non-contiguous index values\n */\nexport var DictionaryKind;\n(function (DictionaryKind) {\n DictionaryKind[DictionaryKind[\"DenseArray\"] = 0] = \"DenseArray\";\n})(DictionaryKind || (DictionaryKind = {}));\n\n//# sourceMappingURL=dictionary-kind.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nexport var DateUnit;\n(function (DateUnit) {\n DateUnit[DateUnit[\"DAY\"] = 0] = \"DAY\";\n DateUnit[DateUnit[\"MILLISECOND\"] = 1] = \"MILLISECOND\";\n})(DateUnit || (DateUnit = {}));\n\n//# sourceMappingURL=date-unit.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nexport class Int {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsInt(bb, obj) {\n return (obj || new Int()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsInt(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Int()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n bitWidth() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;\n }\n isSigned() {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;\n }\n static startInt(builder) {\n builder.startObject(2);\n }\n static addBitWidth(builder, bitWidth) {\n builder.addFieldInt32(0, bitWidth, 0);\n }\n static addIsSigned(builder, isSigned) {\n builder.addFieldInt8(1, +isSigned, +false);\n }\n static endInt(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createInt(builder, bitWidth, isSigned) {\n Int.startInt(builder);\n Int.addBitWidth(builder, bitWidth);\n Int.addIsSigned(builder, isSigned);\n return Int.endInt(builder);\n }\n}\n\n//# sourceMappingURL=int.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { DictionaryKind } from './dictionary-kind.mjs';\nimport { Int } from './int.mjs';\nexport class DictionaryEncoding {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsDictionaryEncoding(bb, obj) {\n return (obj || new DictionaryEncoding()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsDictionaryEncoding(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new DictionaryEncoding()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n /**\n * The known dictionary id in the application where this data is used. In\n * the file or streaming formats, the dictionary ids are found in the\n * DictionaryBatch messages\n */\n id() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);\n }\n /**\n * The dictionary indices are constrained to be non-negative integers. If\n * this field is null, the indices must be signed int32. To maximize\n * cross-language compatibility and performance, implementations are\n * recommended to prefer signed integer types over unsigned integer types\n * and to avoid uint64 indices unless they are required by an application.\n */\n indexType(obj) {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? (obj || new Int()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;\n }\n /**\n * By default, dictionaries are not ordered, or the order does not have\n * semantic meaning. In some statistical, applications, dictionary-encoding\n * is used to represent ordered categorical data, and we provide a way to\n * preserve that metadata here\n */\n isOrdered() {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;\n }\n dictionaryKind() {\n const offset = this.bb.__offset(this.bb_pos, 10);\n return offset ? this.bb.readInt16(this.bb_pos + offset) : DictionaryKind.DenseArray;\n }\n static startDictionaryEncoding(builder) {\n builder.startObject(4);\n }\n static addId(builder, id) {\n builder.addFieldInt64(0, id, builder.createLong(0, 0));\n }\n static addIndexType(builder, indexTypeOffset) {\n builder.addFieldOffset(1, indexTypeOffset, 0);\n }\n static addIsOrdered(builder, isOrdered) {\n builder.addFieldInt8(2, +isOrdered, +false);\n }\n static addDictionaryKind(builder, dictionaryKind) {\n builder.addFieldInt16(3, dictionaryKind, DictionaryKind.DenseArray);\n }\n static endDictionaryEncoding(builder) {\n const offset = builder.endObject();\n return offset;\n }\n}\n\n//# sourceMappingURL=dictionary-encoding.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\n/**\n * Opaque binary data\n */\nexport class Binary {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsBinary(bb, obj) {\n return (obj || new Binary()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsBinary(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Binary()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static startBinary(builder) {\n builder.startObject(0);\n }\n static endBinary(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createBinary(builder) {\n Binary.startBinary(builder);\n return Binary.endBinary(builder);\n }\n}\n\n//# sourceMappingURL=binary.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nexport class Bool {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsBool(bb, obj) {\n return (obj || new Bool()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsBool(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Bool()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static startBool(builder) {\n builder.startObject(0);\n }\n static endBool(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createBool(builder) {\n Bool.startBool(builder);\n return Bool.endBool(builder);\n }\n}\n\n//# sourceMappingURL=bool.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { DateUnit } from './date-unit.mjs';\n/**\n * Date is either a 32-bit or 64-bit signed integer type representing an\n * elapsed time since UNIX epoch (1970-01-01), stored in either of two units:\n *\n * * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no\n * leap seconds), where the values are evenly divisible by 86400000\n * * Days (32 bits) since the UNIX epoch\n */\nexport class Date {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsDate(bb, obj) {\n return (obj || new Date()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsDate(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Date()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n unit() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt16(this.bb_pos + offset) : DateUnit.MILLISECOND;\n }\n static startDate(builder) {\n builder.startObject(1);\n }\n static addUnit(builder, unit) {\n builder.addFieldInt16(0, unit, DateUnit.MILLISECOND);\n }\n static endDate(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createDate(builder, unit) {\n Date.startDate(builder);\n Date.addUnit(builder, unit);\n return Date.endDate(builder);\n }\n}\n\n//# sourceMappingURL=date.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\n/**\n * Exact decimal value represented as an integer value in two's\n * complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers\n * are used. The representation uses the endianness indicated\n * in the Schema.\n */\nexport class Decimal {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsDecimal(bb, obj) {\n return (obj || new Decimal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsDecimal(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Decimal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n /**\n * Total number of decimal digits\n */\n precision() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;\n }\n /**\n * Number of digits after the decimal point \".\"\n */\n scale() {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;\n }\n /**\n * Number of bits per value. The only accepted widths are 128 and 256.\n * We use bitWidth for consistency with Int::bitWidth.\n */\n bitWidth() {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? this.bb.readInt32(this.bb_pos + offset) : 128;\n }\n static startDecimal(builder) {\n builder.startObject(3);\n }\n static addPrecision(builder, precision) {\n builder.addFieldInt32(0, precision, 0);\n }\n static addScale(builder, scale) {\n builder.addFieldInt32(1, scale, 0);\n }\n static addBitWidth(builder, bitWidth) {\n builder.addFieldInt32(2, bitWidth, 128);\n }\n static endDecimal(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createDecimal(builder, precision, scale, bitWidth) {\n Decimal.startDecimal(builder);\n Decimal.addPrecision(builder, precision);\n Decimal.addScale(builder, scale);\n Decimal.addBitWidth(builder, bitWidth);\n return Decimal.endDecimal(builder);\n }\n}\n\n//# sourceMappingURL=decimal.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nexport var TimeUnit;\n(function (TimeUnit) {\n TimeUnit[TimeUnit[\"SECOND\"] = 0] = \"SECOND\";\n TimeUnit[TimeUnit[\"MILLISECOND\"] = 1] = \"MILLISECOND\";\n TimeUnit[TimeUnit[\"MICROSECOND\"] = 2] = \"MICROSECOND\";\n TimeUnit[TimeUnit[\"NANOSECOND\"] = 3] = \"NANOSECOND\";\n})(TimeUnit || (TimeUnit = {}));\n\n//# sourceMappingURL=time-unit.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nexport var Precision;\n(function (Precision) {\n Precision[Precision[\"HALF\"] = 0] = \"HALF\";\n Precision[Precision[\"SINGLE\"] = 1] = \"SINGLE\";\n Precision[Precision[\"DOUBLE\"] = 2] = \"DOUBLE\";\n})(Precision || (Precision = {}));\n\n//# sourceMappingURL=precision.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nexport var IntervalUnit;\n(function (IntervalUnit) {\n IntervalUnit[IntervalUnit[\"YEAR_MONTH\"] = 0] = \"YEAR_MONTH\";\n IntervalUnit[IntervalUnit[\"DAY_TIME\"] = 1] = \"DAY_TIME\";\n IntervalUnit[IntervalUnit[\"MONTH_DAY_NANO\"] = 2] = \"MONTH_DAY_NANO\";\n})(IntervalUnit || (IntervalUnit = {}));\n\n//# sourceMappingURL=interval-unit.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nexport class FixedSizeBinary {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsFixedSizeBinary(bb, obj) {\n return (obj || new FixedSizeBinary()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsFixedSizeBinary(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new FixedSizeBinary()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n /**\n * Number of bytes per value\n */\n byteWidth() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;\n }\n static startFixedSizeBinary(builder) {\n builder.startObject(1);\n }\n static addByteWidth(builder, byteWidth) {\n builder.addFieldInt32(0, byteWidth, 0);\n }\n static endFixedSizeBinary(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createFixedSizeBinary(builder, byteWidth) {\n FixedSizeBinary.startFixedSizeBinary(builder);\n FixedSizeBinary.addByteWidth(builder, byteWidth);\n return FixedSizeBinary.endFixedSizeBinary(builder);\n }\n}\n\n//# sourceMappingURL=fixed-size-binary.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nexport class FixedSizeList {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsFixedSizeList(bb, obj) {\n return (obj || new FixedSizeList()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsFixedSizeList(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new FixedSizeList()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n /**\n * Number of list items per value\n */\n listSize() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;\n }\n static startFixedSizeList(builder) {\n builder.startObject(1);\n }\n static addListSize(builder, listSize) {\n builder.addFieldInt32(0, listSize, 0);\n }\n static endFixedSizeList(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createFixedSizeList(builder, listSize) {\n FixedSizeList.startFixedSizeList(builder);\n FixedSizeList.addListSize(builder, listSize);\n return FixedSizeList.endFixedSizeList(builder);\n }\n}\n\n//# sourceMappingURL=fixed-size-list.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { Precision } from './precision.mjs';\nexport class FloatingPoint {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsFloatingPoint(bb, obj) {\n return (obj || new FloatingPoint()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsFloatingPoint(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new FloatingPoint()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n precision() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt16(this.bb_pos + offset) : Precision.HALF;\n }\n static startFloatingPoint(builder) {\n builder.startObject(1);\n }\n static addPrecision(builder, precision) {\n builder.addFieldInt16(0, precision, Precision.HALF);\n }\n static endFloatingPoint(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createFloatingPoint(builder, precision) {\n FloatingPoint.startFloatingPoint(builder);\n FloatingPoint.addPrecision(builder, precision);\n return FloatingPoint.endFloatingPoint(builder);\n }\n}\n\n//# sourceMappingURL=floating-point.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { IntervalUnit } from './interval-unit.mjs';\nexport class Interval {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsInterval(bb, obj) {\n return (obj || new Interval()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsInterval(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Interval()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n unit() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt16(this.bb_pos + offset) : IntervalUnit.YEAR_MONTH;\n }\n static startInterval(builder) {\n builder.startObject(1);\n }\n static addUnit(builder, unit) {\n builder.addFieldInt16(0, unit, IntervalUnit.YEAR_MONTH);\n }\n static endInterval(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createInterval(builder, unit) {\n Interval.startInterval(builder);\n Interval.addUnit(builder, unit);\n return Interval.endInterval(builder);\n }\n}\n\n//# sourceMappingURL=interval.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nexport class List {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsList(bb, obj) {\n return (obj || new List()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsList(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new List()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static startList(builder) {\n builder.startObject(0);\n }\n static endList(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createList(builder) {\n List.startList(builder);\n return List.endList(builder);\n }\n}\n\n//# sourceMappingURL=list.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\n/**\n * A Map is a logical nested type that is represented as\n *\n * List>\n *\n * In this layout, the keys and values are each respectively contiguous. We do\n * not constrain the key and value types, so the application is responsible\n * for ensuring that the keys are hashable and unique. Whether the keys are sorted\n * may be set in the metadata for this field.\n *\n * In a field with Map type, the field has a child Struct field, which then\n * has two children: key type and the second the value type. The names of the\n * child fields may be respectively \"entries\", \"key\", and \"value\", but this is\n * not enforced.\n *\n * Map\n * ```text\n * - child[0] entries: Struct\n * - child[0] key: K\n * - child[1] value: V\n * ```\n * Neither the \"entries\" field nor the \"key\" field may be nullable.\n *\n * The metadata is structured so that Arrow systems without special handling\n * for Map can make Map an alias for List. The \"layout\" attribute for the Map\n * field must have the same contents as a List.\n */\nexport class Map {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsMap(bb, obj) {\n return (obj || new Map()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsMap(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Map()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n /**\n * Set to true if the keys within each value are sorted\n */\n keysSorted() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;\n }\n static startMap(builder) {\n builder.startObject(1);\n }\n static addKeysSorted(builder, keysSorted) {\n builder.addFieldInt8(0, +keysSorted, +false);\n }\n static endMap(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createMap(builder, keysSorted) {\n Map.startMap(builder);\n Map.addKeysSorted(builder, keysSorted);\n return Map.endMap(builder);\n }\n}\n\n//# sourceMappingURL=map.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\n/**\n * These are stored in the flatbuffer in the Type union below\n */\nexport class Null {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsNull(bb, obj) {\n return (obj || new Null()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsNull(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Null()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static startNull(builder) {\n builder.startObject(0);\n }\n static endNull(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createNull(builder) {\n Null.startNull(builder);\n return Null.endNull(builder);\n }\n}\n\n//# sourceMappingURL=null.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\n/**\n * A Struct_ in the flatbuffer metadata is the same as an Arrow Struct\n * (according to the physical memory layout). We used Struct_ here as\n * Struct is a reserved word in Flatbuffers\n */\nexport class Struct_ {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsStruct_(bb, obj) {\n return (obj || new Struct_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsStruct_(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Struct_()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static startStruct_(builder) {\n builder.startObject(0);\n }\n static endStruct_(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createStruct_(builder) {\n Struct_.startStruct_(builder);\n return Struct_.endStruct_(builder);\n }\n}\n\n//# sourceMappingURL=struct_.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { TimeUnit } from './time-unit.mjs';\n/**\n * Time is either a 32-bit or 64-bit signed integer type representing an\n * elapsed time since midnight, stored in either of four units: seconds,\n * milliseconds, microseconds or nanoseconds.\n *\n * The integer `bitWidth` depends on the `unit` and must be one of the following:\n * * SECOND and MILLISECOND: 32 bits\n * * MICROSECOND and NANOSECOND: 64 bits\n *\n * The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds\n * (exclusive), adjusted for the time unit (for example, up to 86400000\n * exclusive for the MILLISECOND unit).\n * This definition doesn't allow for leap seconds. Time values from\n * measurements with leap seconds will need to be corrected when ingesting\n * into Arrow (for example by replacing the value 86400 with 86399).\n */\nexport class Time {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsTime(bb, obj) {\n return (obj || new Time()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsTime(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Time()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n unit() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt16(this.bb_pos + offset) : TimeUnit.MILLISECOND;\n }\n bitWidth() {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? this.bb.readInt32(this.bb_pos + offset) : 32;\n }\n static startTime(builder) {\n builder.startObject(2);\n }\n static addUnit(builder, unit) {\n builder.addFieldInt16(0, unit, TimeUnit.MILLISECOND);\n }\n static addBitWidth(builder, bitWidth) {\n builder.addFieldInt32(1, bitWidth, 32);\n }\n static endTime(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createTime(builder, unit, bitWidth) {\n Time.startTime(builder);\n Time.addUnit(builder, unit);\n Time.addBitWidth(builder, bitWidth);\n return Time.endTime(builder);\n }\n}\n\n//# sourceMappingURL=time.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { TimeUnit } from './time-unit.mjs';\n/**\n * Timestamp is a 64-bit signed integer representing an elapsed time since a\n * fixed epoch, stored in either of four units: seconds, milliseconds,\n * microseconds or nanoseconds, and is optionally annotated with a timezone.\n *\n * Timestamp values do not include any leap seconds (in other words, all\n * days are considered 86400 seconds long).\n *\n * Timestamps with a non-empty timezone\n * ------------------------------------\n *\n * If a Timestamp column has a non-empty timezone value, its epoch is\n * 1970-01-01 00:00:00 (January 1st 1970, midnight) in the *UTC* timezone\n * (the Unix epoch), regardless of the Timestamp's own timezone.\n *\n * Therefore, timestamp values with a non-empty timezone correspond to\n * physical points in time together with some additional information about\n * how the data was obtained and/or how to display it (the timezone).\n *\n * For example, the timestamp value 0 with the timezone string \"Europe/Paris\"\n * corresponds to \"January 1st 1970, 00h00\" in the UTC timezone, but the\n * application may prefer to display it as \"January 1st 1970, 01h00\" in\n * the Europe/Paris timezone (which is the same physical point in time).\n *\n * One consequence is that timestamp values with a non-empty timezone\n * can be compared and ordered directly, since they all share the same\n * well-known point of reference (the Unix epoch).\n *\n * Timestamps with an unset / empty timezone\n * -----------------------------------------\n *\n * If a Timestamp column has no timezone value, its epoch is\n * 1970-01-01 00:00:00 (January 1st 1970, midnight) in an *unknown* timezone.\n *\n * Therefore, timestamp values without a timezone cannot be meaningfully\n * interpreted as physical points in time, but only as calendar / clock\n * indications (\"wall clock time\") in an unspecified timezone.\n *\n * For example, the timestamp value 0 with an empty timezone string\n * corresponds to \"January 1st 1970, 00h00\" in an unknown timezone: there\n * is not enough information to interpret it as a well-defined physical\n * point in time.\n *\n * One consequence is that timestamp values without a timezone cannot\n * be reliably compared or ordered, since they may have different points of\n * reference. In particular, it is *not* possible to interpret an unset\n * or empty timezone as the same as \"UTC\".\n *\n * Conversion between timezones\n * ----------------------------\n *\n * If a Timestamp column has a non-empty timezone, changing the timezone\n * to a different non-empty value is a metadata-only operation:\n * the timestamp values need not change as their point of reference remains\n * the same (the Unix epoch).\n *\n * However, if a Timestamp column has no timezone value, changing it to a\n * non-empty value requires to think about the desired semantics.\n * One possibility is to assume that the original timestamp values are\n * relative to the epoch of the timezone being set; timestamp values should\n * then adjusted to the Unix epoch (for example, changing the timezone from\n * empty to \"Europe/Paris\" would require converting the timestamp values\n * from \"Europe/Paris\" to \"UTC\", which seems counter-intuitive but is\n * nevertheless correct).\n *\n * Guidelines for encoding data from external libraries\n * ----------------------------------------------------\n *\n * Date & time libraries often have multiple different data types for temporal\n * data. In order to ease interoperability between different implementations the\n * Arrow project has some recommendations for encoding these types into a Timestamp\n * column.\n *\n * An \"instant\" represents a physical point in time that has no relevant timezone\n * (for example, astronomical data). To encode an instant, use a Timestamp with\n * the timezone string set to \"UTC\", and make sure the Timestamp values\n * are relative to the UTC epoch (January 1st 1970, midnight).\n *\n * A \"zoned date-time\" represents a physical point in time annotated with an\n * informative timezone (for example, the timezone in which the data was\n * recorded). To encode a zoned date-time, use a Timestamp with the timezone\n * string set to the name of the timezone, and make sure the Timestamp values\n * are relative to the UTC epoch (January 1st 1970, midnight).\n *\n * (There is some ambiguity between an instant and a zoned date-time with the\n * UTC timezone. Both of these are stored the same in Arrow. Typically,\n * this distinction does not matter. If it does, then an application should\n * use custom metadata or an extension type to distinguish between the two cases.)\n *\n * An \"offset date-time\" represents a physical point in time combined with an\n * explicit offset from UTC. To encode an offset date-time, use a Timestamp\n * with the timezone string set to the numeric timezone offset string\n * (e.g. \"+03:00\"), and make sure the Timestamp values are relative to\n * the UTC epoch (January 1st 1970, midnight).\n *\n * A \"naive date-time\" (also called \"local date-time\" in some libraries)\n * represents a wall clock time combined with a calendar date, but with\n * no indication of how to map this information to a physical point in time.\n * Naive date-times must be handled with care because of this missing\n * information, and also because daylight saving time (DST) may make\n * some values ambiguous or non-existent. A naive date-time may be\n * stored as a struct with Date and Time fields. However, it may also be\n * encoded into a Timestamp column with an empty timezone. The timestamp\n * values should be computed \"as if\" the timezone of the date-time values\n * was UTC; for example, the naive date-time \"January 1st 1970, 00h00\" would\n * be encoded as timestamp value 0.\n */\nexport class Timestamp {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsTimestamp(bb, obj) {\n return (obj || new Timestamp()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsTimestamp(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Timestamp()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n unit() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt16(this.bb_pos + offset) : TimeUnit.SECOND;\n }\n timezone(optionalEncoding) {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;\n }\n static startTimestamp(builder) {\n builder.startObject(2);\n }\n static addUnit(builder, unit) {\n builder.addFieldInt16(0, unit, TimeUnit.SECOND);\n }\n static addTimezone(builder, timezoneOffset) {\n builder.addFieldOffset(1, timezoneOffset, 0);\n }\n static endTimestamp(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createTimestamp(builder, unit, timezoneOffset) {\n Timestamp.startTimestamp(builder);\n Timestamp.addUnit(builder, unit);\n Timestamp.addTimezone(builder, timezoneOffset);\n return Timestamp.endTimestamp(builder);\n }\n}\n\n//# sourceMappingURL=timestamp.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nexport var UnionMode;\n(function (UnionMode) {\n UnionMode[UnionMode[\"Sparse\"] = 0] = \"Sparse\";\n UnionMode[UnionMode[\"Dense\"] = 1] = \"Dense\";\n})(UnionMode || (UnionMode = {}));\n\n//# sourceMappingURL=union-mode.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport { Binary } from './binary.mjs';\nimport { Bool } from './bool.mjs';\nimport { Date } from './date.mjs';\nimport { Decimal } from './decimal.mjs';\nimport { Duration } from './duration.mjs';\nimport { FixedSizeBinary } from './fixed-size-binary.mjs';\nimport { FixedSizeList } from './fixed-size-list.mjs';\nimport { FloatingPoint } from './floating-point.mjs';\nimport { Int } from './int.mjs';\nimport { Interval } from './interval.mjs';\nimport { LargeBinary } from './large-binary.mjs';\nimport { LargeList } from './large-list.mjs';\nimport { LargeUtf8 } from './large-utf8.mjs';\nimport { List } from './list.mjs';\nimport { Map } from './map.mjs';\nimport { Null } from './null.mjs';\nimport { Struct_ } from './struct_.mjs';\nimport { Time } from './time.mjs';\nimport { Timestamp } from './timestamp.mjs';\nimport { Union } from './union.mjs';\nimport { Utf8 } from './utf8.mjs';\n/**\n * ----------------------------------------------------------------------\n * Top-level Type value, enabling extensible type-specific metadata. We can\n * add new logical types to Type without breaking backwards compatibility\n */\nexport var Type;\n(function (Type) {\n Type[Type[\"NONE\"] = 0] = \"NONE\";\n Type[Type[\"Null\"] = 1] = \"Null\";\n Type[Type[\"Int\"] = 2] = \"Int\";\n Type[Type[\"FloatingPoint\"] = 3] = \"FloatingPoint\";\n Type[Type[\"Binary\"] = 4] = \"Binary\";\n Type[Type[\"Utf8\"] = 5] = \"Utf8\";\n Type[Type[\"Bool\"] = 6] = \"Bool\";\n Type[Type[\"Decimal\"] = 7] = \"Decimal\";\n Type[Type[\"Date\"] = 8] = \"Date\";\n Type[Type[\"Time\"] = 9] = \"Time\";\n Type[Type[\"Timestamp\"] = 10] = \"Timestamp\";\n Type[Type[\"Interval\"] = 11] = \"Interval\";\n Type[Type[\"List\"] = 12] = \"List\";\n Type[Type[\"Struct_\"] = 13] = \"Struct_\";\n Type[Type[\"Union\"] = 14] = \"Union\";\n Type[Type[\"FixedSizeBinary\"] = 15] = \"FixedSizeBinary\";\n Type[Type[\"FixedSizeList\"] = 16] = \"FixedSizeList\";\n Type[Type[\"Map\"] = 17] = \"Map\";\n Type[Type[\"Duration\"] = 18] = \"Duration\";\n Type[Type[\"LargeBinary\"] = 19] = \"LargeBinary\";\n Type[Type[\"LargeUtf8\"] = 20] = \"LargeUtf8\";\n Type[Type[\"LargeList\"] = 21] = \"LargeList\";\n})(Type || (Type = {}));\nexport function unionToType(type, accessor) {\n switch (Type[type]) {\n case 'NONE': return null;\n case 'Null': return accessor(new Null());\n case 'Int': return accessor(new Int());\n case 'FloatingPoint': return accessor(new FloatingPoint());\n case 'Binary': return accessor(new Binary());\n case 'Utf8': return accessor(new Utf8());\n case 'Bool': return accessor(new Bool());\n case 'Decimal': return accessor(new Decimal());\n case 'Date': return accessor(new Date());\n case 'Time': return accessor(new Time());\n case 'Timestamp': return accessor(new Timestamp());\n case 'Interval': return accessor(new Interval());\n case 'List': return accessor(new List());\n case 'Struct_': return accessor(new Struct_());\n case 'Union': return accessor(new Union());\n case 'FixedSizeBinary': return accessor(new FixedSizeBinary());\n case 'FixedSizeList': return accessor(new FixedSizeList());\n case 'Map': return accessor(new Map());\n case 'Duration': return accessor(new Duration());\n case 'LargeBinary': return accessor(new LargeBinary());\n case 'LargeUtf8': return accessor(new LargeUtf8());\n case 'LargeList': return accessor(new LargeList());\n default: return null;\n }\n}\nexport function unionListToType(type, accessor, index) {\n switch (Type[type]) {\n case 'NONE': return null;\n case 'Null': return accessor(index, new Null());\n case 'Int': return accessor(index, new Int());\n case 'FloatingPoint': return accessor(index, new FloatingPoint());\n case 'Binary': return accessor(index, new Binary());\n case 'Utf8': return accessor(index, new Utf8());\n case 'Bool': return accessor(index, new Bool());\n case 'Decimal': return accessor(index, new Decimal());\n case 'Date': return accessor(index, new Date());\n case 'Time': return accessor(index, new Time());\n case 'Timestamp': return accessor(index, new Timestamp());\n case 'Interval': return accessor(index, new Interval());\n case 'List': return accessor(index, new List());\n case 'Struct_': return accessor(index, new Struct_());\n case 'Union': return accessor(index, new Union());\n case 'FixedSizeBinary': return accessor(index, new FixedSizeBinary());\n case 'FixedSizeList': return accessor(index, new FixedSizeList());\n case 'Map': return accessor(index, new Map());\n case 'Duration': return accessor(index, new Duration());\n case 'LargeBinary': return accessor(index, new LargeBinary());\n case 'LargeUtf8': return accessor(index, new LargeUtf8());\n case 'LargeList': return accessor(index, new LargeList());\n default: return null;\n }\n}\n\n//# sourceMappingURL=type.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { UnionMode } from './union-mode.mjs';\n/**\n * A union is a complex type with children in Field\n * By default ids in the type vector refer to the offsets in the children\n * optionally typeIds provides an indirection between the child offset and the type id\n * for each child `typeIds[offset]` is the id used in the type vector\n */\nexport class Union {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsUnion(bb, obj) {\n return (obj || new Union()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsUnion(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Union()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n mode() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt16(this.bb_pos + offset) : UnionMode.Sparse;\n }\n typeIds(index) {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? this.bb.readInt32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0;\n }\n typeIdsLength() {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n typeIdsArray() {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? new Int32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;\n }\n static startUnion(builder) {\n builder.startObject(2);\n }\n static addMode(builder, mode) {\n builder.addFieldInt16(0, mode, UnionMode.Sparse);\n }\n static addTypeIds(builder, typeIdsOffset) {\n builder.addFieldOffset(1, typeIdsOffset, 0);\n }\n static createTypeIdsVector(builder, data) {\n builder.startVector(4, data.length, 4);\n for (let i = data.length - 1; i >= 0; i--) {\n builder.addInt32(data[i]);\n }\n return builder.endVector();\n }\n static startTypeIdsVector(builder, numElems) {\n builder.startVector(4, numElems, 4);\n }\n static endUnion(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createUnion(builder, mode, typeIdsOffset) {\n Union.startUnion(builder);\n Union.addMode(builder, mode);\n Union.addTypeIds(builder, typeIdsOffset);\n return Union.endUnion(builder);\n }\n}\n\n//# sourceMappingURL=union.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\n/**\n * Unicode with UTF-8 encoding\n */\nexport class Utf8 {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsUtf8(bb, obj) {\n return (obj || new Utf8()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsUtf8(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Utf8()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static startUtf8(builder) {\n builder.startObject(0);\n }\n static endUtf8(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createUtf8(builder) {\n Utf8.startUtf8(builder);\n return Utf8.endUtf8(builder);\n }\n}\n\n//# sourceMappingURL=utf8.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { DictionaryEncoding } from './dictionary-encoding.mjs';\nimport { KeyValue } from './key-value.mjs';\nimport { Type } from './type.mjs';\n/**\n * ----------------------------------------------------------------------\n * A field represents a named column in a record / row batch or child of a\n * nested type.\n */\nexport class Field {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsField(bb, obj) {\n return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsField(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n name(optionalEncoding) {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;\n }\n /**\n * Whether or not this field can contain nulls. Should be true in general.\n */\n nullable() {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;\n }\n typeType() {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? this.bb.readUint8(this.bb_pos + offset) : Type.NONE;\n }\n /**\n * This is the type of the decoded value if the field is dictionary encoded.\n */\n // @ts-ignore\n type(obj) {\n const offset = this.bb.__offset(this.bb_pos, 10);\n return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;\n }\n /**\n * Present only if the field is dictionary encoded.\n */\n dictionary(obj) {\n const offset = this.bb.__offset(this.bb_pos, 12);\n return offset ? (obj || new DictionaryEncoding()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;\n }\n /**\n * children apply only to nested data types like Struct, List and Union. For\n * primitive types children will have length 0.\n */\n children(index, obj) {\n const offset = this.bb.__offset(this.bb_pos, 14);\n return offset ? (obj || new Field()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;\n }\n childrenLength() {\n const offset = this.bb.__offset(this.bb_pos, 14);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n /**\n * User-defined metadata\n */\n customMetadata(index, obj) {\n const offset = this.bb.__offset(this.bb_pos, 16);\n return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;\n }\n customMetadataLength() {\n const offset = this.bb.__offset(this.bb_pos, 16);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n static startField(builder) {\n builder.startObject(7);\n }\n static addName(builder, nameOffset) {\n builder.addFieldOffset(0, nameOffset, 0);\n }\n static addNullable(builder, nullable) {\n builder.addFieldInt8(1, +nullable, +false);\n }\n static addTypeType(builder, typeType) {\n builder.addFieldInt8(2, typeType, Type.NONE);\n }\n static addType(builder, typeOffset) {\n builder.addFieldOffset(3, typeOffset, 0);\n }\n static addDictionary(builder, dictionaryOffset) {\n builder.addFieldOffset(4, dictionaryOffset, 0);\n }\n static addChildren(builder, childrenOffset) {\n builder.addFieldOffset(5, childrenOffset, 0);\n }\n static createChildrenVector(builder, data) {\n builder.startVector(4, data.length, 4);\n for (let i = data.length - 1; i >= 0; i--) {\n builder.addOffset(data[i]);\n }\n return builder.endVector();\n }\n static startChildrenVector(builder, numElems) {\n builder.startVector(4, numElems, 4);\n }\n static addCustomMetadata(builder, customMetadataOffset) {\n builder.addFieldOffset(6, customMetadataOffset, 0);\n }\n static createCustomMetadataVector(builder, data) {\n builder.startVector(4, data.length, 4);\n for (let i = data.length - 1; i >= 0; i--) {\n builder.addOffset(data[i]);\n }\n return builder.endVector();\n }\n static startCustomMetadataVector(builder, numElems) {\n builder.startVector(4, numElems, 4);\n }\n static endField(builder) {\n const offset = builder.endObject();\n return offset;\n }\n}\n\n//# sourceMappingURL=field.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { Endianness } from './endianness.mjs';\nimport { Field } from './field.mjs';\nimport { KeyValue } from './key-value.mjs';\n/**\n * ----------------------------------------------------------------------\n * A Schema describes the columns in a row batch\n */\nexport class Schema {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsSchema(bb, obj) {\n return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsSchema(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n /**\n * endianness of the buffer\n * it is Little Endian by default\n * if endianness doesn't match the underlying system then the vectors need to be converted\n */\n endianness() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt16(this.bb_pos + offset) : Endianness.Little;\n }\n fields(index, obj) {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? (obj || new Field()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;\n }\n fieldsLength() {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n customMetadata(index, obj) {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;\n }\n customMetadataLength() {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n /**\n * Features used in the stream/file.\n */\n features(index) {\n const offset = this.bb.__offset(this.bb_pos, 10);\n return offset ? this.bb.readInt64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0);\n }\n featuresLength() {\n const offset = this.bb.__offset(this.bb_pos, 10);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n static startSchema(builder) {\n builder.startObject(4);\n }\n static addEndianness(builder, endianness) {\n builder.addFieldInt16(0, endianness, Endianness.Little);\n }\n static addFields(builder, fieldsOffset) {\n builder.addFieldOffset(1, fieldsOffset, 0);\n }\n static createFieldsVector(builder, data) {\n builder.startVector(4, data.length, 4);\n for (let i = data.length - 1; i >= 0; i--) {\n builder.addOffset(data[i]);\n }\n return builder.endVector();\n }\n static startFieldsVector(builder, numElems) {\n builder.startVector(4, numElems, 4);\n }\n static addCustomMetadata(builder, customMetadataOffset) {\n builder.addFieldOffset(2, customMetadataOffset, 0);\n }\n static createCustomMetadataVector(builder, data) {\n builder.startVector(4, data.length, 4);\n for (let i = data.length - 1; i >= 0; i--) {\n builder.addOffset(data[i]);\n }\n return builder.endVector();\n }\n static startCustomMetadataVector(builder, numElems) {\n builder.startVector(4, numElems, 4);\n }\n static addFeatures(builder, featuresOffset) {\n builder.addFieldOffset(3, featuresOffset, 0);\n }\n static createFeaturesVector(builder, data) {\n builder.startVector(8, data.length, 8);\n for (let i = data.length - 1; i >= 0; i--) {\n builder.addInt64(data[i]);\n }\n return builder.endVector();\n }\n static startFeaturesVector(builder, numElems) {\n builder.startVector(8, numElems, 8);\n }\n static endSchema(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static finishSchemaBuffer(builder, offset) {\n builder.finish(offset);\n }\n static finishSizePrefixedSchemaBuffer(builder, offset) {\n builder.finish(offset, undefined, true);\n }\n static createSchema(builder, endianness, fieldsOffset, customMetadataOffset, featuresOffset) {\n Schema.startSchema(builder);\n Schema.addEndianness(builder, endianness);\n Schema.addFields(builder, fieldsOffset);\n Schema.addCustomMetadata(builder, customMetadataOffset);\n Schema.addFeatures(builder, featuresOffset);\n return Schema.endSchema(builder);\n }\n}\n\n//# sourceMappingURL=schema.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { Block } from './block.mjs';\nimport { KeyValue } from './key-value.mjs';\nimport { MetadataVersion } from './metadata-version.mjs';\nimport { Schema } from './schema.mjs';\n/**\n * ----------------------------------------------------------------------\n * Arrow File metadata\n *\n */\nexport class Footer {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsFooter(bb, obj) {\n return (obj || new Footer()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsFooter(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Footer()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n version() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt16(this.bb_pos + offset) : MetadataVersion.V1;\n }\n schema(obj) {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? (obj || new Schema()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;\n }\n dictionaries(index, obj) {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? (obj || new Block()).__init(this.bb.__vector(this.bb_pos + offset) + index * 24, this.bb) : null;\n }\n dictionariesLength() {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n recordBatches(index, obj) {\n const offset = this.bb.__offset(this.bb_pos, 10);\n return offset ? (obj || new Block()).__init(this.bb.__vector(this.bb_pos + offset) + index * 24, this.bb) : null;\n }\n recordBatchesLength() {\n const offset = this.bb.__offset(this.bb_pos, 10);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n /**\n * User-defined metadata\n */\n customMetadata(index, obj) {\n const offset = this.bb.__offset(this.bb_pos, 12);\n return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;\n }\n customMetadataLength() {\n const offset = this.bb.__offset(this.bb_pos, 12);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n static startFooter(builder) {\n builder.startObject(5);\n }\n static addVersion(builder, version) {\n builder.addFieldInt16(0, version, MetadataVersion.V1);\n }\n static addSchema(builder, schemaOffset) {\n builder.addFieldOffset(1, schemaOffset, 0);\n }\n static addDictionaries(builder, dictionariesOffset) {\n builder.addFieldOffset(2, dictionariesOffset, 0);\n }\n static startDictionariesVector(builder, numElems) {\n builder.startVector(24, numElems, 8);\n }\n static addRecordBatches(builder, recordBatchesOffset) {\n builder.addFieldOffset(3, recordBatchesOffset, 0);\n }\n static startRecordBatchesVector(builder, numElems) {\n builder.startVector(24, numElems, 8);\n }\n static addCustomMetadata(builder, customMetadataOffset) {\n builder.addFieldOffset(4, customMetadataOffset, 0);\n }\n static createCustomMetadataVector(builder, data) {\n builder.startVector(4, data.length, 4);\n for (let i = data.length - 1; i >= 0; i--) {\n builder.addOffset(data[i]);\n }\n return builder.endVector();\n }\n static startCustomMetadataVector(builder, numElems) {\n builder.startVector(4, numElems, 4);\n }\n static endFooter(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static finishFooterBuffer(builder, offset) {\n builder.finish(offset);\n }\n static finishSizePrefixedFooterBuffer(builder, offset) {\n builder.finish(offset, undefined, true);\n }\n}\n\n//# sourceMappingURL=footer.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { DataType } from './type.mjs';\nexport class Schema {\n constructor(fields = [], metadata, dictionaries) {\n this.fields = (fields || []);\n this.metadata = metadata || new Map();\n if (!dictionaries) {\n dictionaries = generateDictionaryMap(fields);\n }\n this.dictionaries = dictionaries;\n }\n get [Symbol.toStringTag]() { return 'Schema'; }\n get names() { return this.fields.map((f) => f.name); }\n toString() {\n return `Schema<{ ${this.fields.map((f, i) => `${i}: ${f}`).join(', ')} }>`;\n }\n /**\n * Construct a new Schema containing only specified fields.\n *\n * @param fieldNames Names of fields to keep.\n * @returns A new Schema of fields matching the specified names.\n */\n select(fieldNames) {\n const names = new Set(fieldNames);\n const fields = this.fields.filter((f) => names.has(f.name));\n return new Schema(fields, this.metadata);\n }\n /**\n * Construct a new Schema containing only fields at the specified indices.\n *\n * @param fieldIndices Indices of fields to keep.\n * @returns A new Schema of fields at the specified indices.\n */\n selectAt(fieldIndices) {\n const fields = fieldIndices.map((i) => this.fields[i]).filter(Boolean);\n return new Schema(fields, this.metadata);\n }\n assign(...args) {\n const other = (args[0] instanceof Schema\n ? args[0]\n : Array.isArray(args[0])\n ? new Schema(args[0])\n : new Schema(args));\n const curFields = [...this.fields];\n const metadata = mergeMaps(mergeMaps(new Map(), this.metadata), other.metadata);\n const newFields = other.fields.filter((f2) => {\n const i = curFields.findIndex((f) => f.name === f2.name);\n return ~i ? (curFields[i] = f2.clone({\n metadata: mergeMaps(mergeMaps(new Map(), curFields[i].metadata), f2.metadata)\n })) && false : true;\n });\n const newDictionaries = generateDictionaryMap(newFields, new Map());\n return new Schema([...curFields, ...newFields], metadata, new Map([...this.dictionaries, ...newDictionaries]));\n }\n}\n// Add these here so they're picked up by the externs creator\n// in the build, and closure-compiler doesn't minify them away\nSchema.prototype.fields = null;\nSchema.prototype.metadata = null;\nSchema.prototype.dictionaries = null;\nexport class Field {\n constructor(name, type, nullable = false, metadata) {\n this.name = name;\n this.type = type;\n this.nullable = nullable;\n this.metadata = metadata || new Map();\n }\n /** @nocollapse */\n static new(...args) {\n let [name, type, nullable, metadata] = args;\n if (args[0] && typeof args[0] === 'object') {\n ({ name } = args[0]);\n (type === undefined) && (type = args[0].type);\n (nullable === undefined) && (nullable = args[0].nullable);\n (metadata === undefined) && (metadata = args[0].metadata);\n }\n return new Field(`${name}`, type, nullable, metadata);\n }\n get typeId() { return this.type.typeId; }\n get [Symbol.toStringTag]() { return 'Field'; }\n toString() { return `${this.name}: ${this.type}`; }\n clone(...args) {\n let [name, type, nullable, metadata] = args;\n (!args[0] || typeof args[0] !== 'object')\n ? ([name = this.name, type = this.type, nullable = this.nullable, metadata = this.metadata] = args)\n : ({ name = this.name, type = this.type, nullable = this.nullable, metadata = this.metadata } = args[0]);\n return Field.new(name, type, nullable, metadata);\n }\n}\n// Add these here so they're picked up by the externs creator\n// in the build, and closure-compiler doesn't minify them away\nField.prototype.type = null;\nField.prototype.name = null;\nField.prototype.nullable = null;\nField.prototype.metadata = null;\n/** @ignore */\nfunction mergeMaps(m1, m2) {\n return new Map([...(m1 || new Map()), ...(m2 || new Map())]);\n}\n/** @ignore */\nfunction generateDictionaryMap(fields, dictionaries = new Map()) {\n for (let i = -1, n = fields.length; ++i < n;) {\n const field = fields[i];\n const type = field.type;\n if (DataType.isDictionary(type)) {\n if (!dictionaries.has(type.id)) {\n dictionaries.set(type.id, type.dictionary);\n }\n else if (dictionaries.get(type.id) !== type.dictionary) {\n throw new Error(`Cannot create Schema containing two different dictionaries with the same Id`);\n }\n }\n if (type.children && type.children.length > 0) {\n generateDictionaryMap(type.children, dictionaries);\n }\n }\n return dictionaries;\n}\n\n//# sourceMappingURL=schema.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { Block as _Block } from '../../fb/block.mjs';\nimport { Footer as _Footer } from '../../fb/footer.mjs';\nimport * as flatbuffers from 'flatbuffers';\nvar Long = flatbuffers.Long;\nvar Builder = flatbuffers.Builder;\nvar ByteBuffer = flatbuffers.ByteBuffer;\nimport { Schema } from '../../schema.mjs';\nimport { MetadataVersion } from '../../enum.mjs';\nimport { toUint8Array } from '../../util/buffer.mjs';\n/** @ignore */\nclass Footer_ {\n constructor(schema, version = MetadataVersion.V4, recordBatches, dictionaryBatches) {\n this.schema = schema;\n this.version = version;\n recordBatches && (this._recordBatches = recordBatches);\n dictionaryBatches && (this._dictionaryBatches = dictionaryBatches);\n }\n /** @nocollapse */\n static decode(buf) {\n buf = new ByteBuffer(toUint8Array(buf));\n const footer = _Footer.getRootAsFooter(buf);\n const schema = Schema.decode(footer.schema());\n return new OffHeapFooter(schema, footer);\n }\n /** @nocollapse */\n static encode(footer) {\n const b = new Builder();\n const schemaOffset = Schema.encode(b, footer.schema);\n _Footer.startRecordBatchesVector(b, footer.numRecordBatches);\n for (const rb of [...footer.recordBatches()].slice().reverse()) {\n FileBlock.encode(b, rb);\n }\n const recordBatchesOffset = b.endVector();\n _Footer.startDictionariesVector(b, footer.numDictionaries);\n for (const db of [...footer.dictionaryBatches()].slice().reverse()) {\n FileBlock.encode(b, db);\n }\n const dictionaryBatchesOffset = b.endVector();\n _Footer.startFooter(b);\n _Footer.addSchema(b, schemaOffset);\n _Footer.addVersion(b, MetadataVersion.V4);\n _Footer.addRecordBatches(b, recordBatchesOffset);\n _Footer.addDictionaries(b, dictionaryBatchesOffset);\n _Footer.finishFooterBuffer(b, _Footer.endFooter(b));\n return b.asUint8Array();\n }\n get numRecordBatches() { return this._recordBatches.length; }\n get numDictionaries() { return this._dictionaryBatches.length; }\n *recordBatches() {\n for (let block, i = -1, n = this.numRecordBatches; ++i < n;) {\n if (block = this.getRecordBatch(i)) {\n yield block;\n }\n }\n }\n *dictionaryBatches() {\n for (let block, i = -1, n = this.numDictionaries; ++i < n;) {\n if (block = this.getDictionaryBatch(i)) {\n yield block;\n }\n }\n }\n getRecordBatch(index) {\n return index >= 0\n && index < this.numRecordBatches\n && this._recordBatches[index] || null;\n }\n getDictionaryBatch(index) {\n return index >= 0\n && index < this.numDictionaries\n && this._dictionaryBatches[index] || null;\n }\n}\nexport { Footer_ as Footer };\n/** @ignore */\nclass OffHeapFooter extends Footer_ {\n constructor(schema, _footer) {\n super(schema, _footer.version());\n this._footer = _footer;\n }\n get numRecordBatches() { return this._footer.recordBatchesLength(); }\n get numDictionaries() { return this._footer.dictionariesLength(); }\n getRecordBatch(index) {\n if (index >= 0 && index < this.numRecordBatches) {\n const fileBlock = this._footer.recordBatches(index);\n if (fileBlock) {\n return FileBlock.decode(fileBlock);\n }\n }\n return null;\n }\n getDictionaryBatch(index) {\n if (index >= 0 && index < this.numDictionaries) {\n const fileBlock = this._footer.dictionaries(index);\n if (fileBlock) {\n return FileBlock.decode(fileBlock);\n }\n }\n return null;\n }\n}\n/** @ignore */\nexport class FileBlock {\n constructor(metaDataLength, bodyLength, offset) {\n this.metaDataLength = metaDataLength;\n this.offset = typeof offset === 'number' ? offset : offset.low;\n this.bodyLength = typeof bodyLength === 'number' ? bodyLength : bodyLength.low;\n }\n /** @nocollapse */\n static decode(block) {\n return new FileBlock(block.metaDataLength(), block.bodyLength(), block.offset());\n }\n /** @nocollapse */\n static encode(b, fileBlock) {\n const { metaDataLength } = fileBlock;\n const offset = new Long(fileBlock.offset, 0);\n const bodyLength = new Long(fileBlock.bodyLength, 0);\n return _Block.createBlock(b, offset, metaDataLength, bodyLength);\n }\n}\n\n//# sourceMappingURL=file.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { __awaiter } from \"tslib\";\nimport streamAdapters from './adapters.mjs';\n/** @ignore */\nexport const ITERATOR_DONE = Object.freeze({ done: true, value: void (0) });\n/** @ignore */\nexport class ArrowJSON {\n constructor(_json) {\n this._json = _json;\n }\n get schema() { return this._json['schema']; }\n get batches() { return (this._json['batches'] || []); }\n get dictionaries() { return (this._json['dictionaries'] || []); }\n}\n/** @ignore */\nexport class ReadableInterop {\n tee() {\n return this._getDOMStream().tee();\n }\n pipe(writable, options) {\n return this._getNodeStream().pipe(writable, options);\n }\n pipeTo(writable, options) { return this._getDOMStream().pipeTo(writable, options); }\n pipeThrough(duplex, options) {\n return this._getDOMStream().pipeThrough(duplex, options);\n }\n _getDOMStream() {\n return this._DOMStream || (this._DOMStream = this.toDOMStream());\n }\n _getNodeStream() {\n return this._nodeStream || (this._nodeStream = this.toNodeStream());\n }\n}\n/** @ignore */\nexport class AsyncQueue extends ReadableInterop {\n constructor() {\n super();\n this._values = [];\n this.resolvers = [];\n this._closedPromise = new Promise((r) => this._closedPromiseResolve = r);\n }\n get closed() { return this._closedPromise; }\n cancel(reason) {\n return __awaiter(this, void 0, void 0, function* () { yield this.return(reason); });\n }\n write(value) {\n if (this._ensureOpen()) {\n this.resolvers.length <= 0\n ? (this._values.push(value))\n : (this.resolvers.shift().resolve({ done: false, value }));\n }\n }\n abort(value) {\n if (this._closedPromiseResolve) {\n this.resolvers.length <= 0\n ? (this._error = { error: value })\n : (this.resolvers.shift().reject({ done: true, value }));\n }\n }\n close() {\n if (this._closedPromiseResolve) {\n const { resolvers } = this;\n while (resolvers.length > 0) {\n resolvers.shift().resolve(ITERATOR_DONE);\n }\n this._closedPromiseResolve();\n this._closedPromiseResolve = undefined;\n }\n }\n [Symbol.asyncIterator]() { return this; }\n toDOMStream(options) {\n return streamAdapters.toDOMStream((this._closedPromiseResolve || this._error)\n ? this\n : this._values, options);\n }\n toNodeStream(options) {\n return streamAdapters.toNodeStream((this._closedPromiseResolve || this._error)\n ? this\n : this._values, options);\n }\n throw(_) {\n return __awaiter(this, void 0, void 0, function* () { yield this.abort(_); return ITERATOR_DONE; });\n }\n return(_) {\n return __awaiter(this, void 0, void 0, function* () { yield this.close(); return ITERATOR_DONE; });\n }\n read(size) {\n return __awaiter(this, void 0, void 0, function* () { return (yield this.next(size, 'read')).value; });\n }\n peek(size) {\n return __awaiter(this, void 0, void 0, function* () { return (yield this.next(size, 'peek')).value; });\n }\n next(..._args) {\n if (this._values.length > 0) {\n return Promise.resolve({ done: false, value: this._values.shift() });\n }\n else if (this._error) {\n return Promise.reject({ done: true, value: this._error.error });\n }\n else if (!this._closedPromiseResolve) {\n return Promise.resolve(ITERATOR_DONE);\n }\n else {\n return new Promise((resolve, reject) => {\n this.resolvers.push({ resolve, reject });\n });\n }\n }\n _ensureOpen() {\n if (this._closedPromiseResolve) {\n return true;\n }\n throw new Error(`AsyncQueue is closed`);\n }\n}\n\n//# sourceMappingURL=interfaces.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { __asyncValues, __awaiter } from \"tslib\";\nimport streamAdapters from './adapters.mjs';\nimport { decodeUtf8 } from '../util/utf8.mjs';\nimport { ITERATOR_DONE, AsyncQueue } from './interfaces.mjs';\nimport { toUint8Array, joinUint8Arrays } from '../util/buffer.mjs';\nimport { isPromise, isFetchResponse, isIterable, isAsyncIterable, isReadableDOMStream, isReadableNodeStream } from '../util/compat.mjs';\n/** @ignore */\nexport class AsyncByteQueue extends AsyncQueue {\n write(value) {\n if ((value = toUint8Array(value)).byteLength > 0) {\n return super.write(value);\n }\n }\n toString(sync = false) {\n return sync\n ? decodeUtf8(this.toUint8Array(true))\n : this.toUint8Array(false).then(decodeUtf8);\n }\n toUint8Array(sync = false) {\n return sync ? joinUint8Arrays(this._values)[0] : (() => __awaiter(this, void 0, void 0, function* () {\n var e_1, _a;\n const buffers = [];\n let byteLength = 0;\n try {\n for (var _b = __asyncValues(this), _c; _c = yield _b.next(), !_c.done;) {\n const chunk = _c.value;\n buffers.push(chunk);\n byteLength += chunk.byteLength;\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);\n }\n finally { if (e_1) throw e_1.error; }\n }\n return joinUint8Arrays(buffers, byteLength)[0];\n }))();\n }\n}\n/** @ignore */\nexport class ByteStream {\n constructor(source) {\n if (source) {\n this.source = new ByteStreamSource(streamAdapters.fromIterable(source));\n }\n }\n [Symbol.iterator]() { return this; }\n next(value) { return this.source.next(value); }\n throw(value) { return this.source.throw(value); }\n return(value) { return this.source.return(value); }\n peek(size) { return this.source.peek(size); }\n read(size) { return this.source.read(size); }\n}\n/** @ignore */\nexport class AsyncByteStream {\n constructor(source) {\n if (source instanceof AsyncByteStream) {\n this.source = source.source;\n }\n else if (source instanceof AsyncByteQueue) {\n this.source = new AsyncByteStreamSource(streamAdapters.fromAsyncIterable(source));\n }\n else if (isReadableNodeStream(source)) {\n this.source = new AsyncByteStreamSource(streamAdapters.fromNodeStream(source));\n }\n else if (isReadableDOMStream(source)) {\n this.source = new AsyncByteStreamSource(streamAdapters.fromDOMStream(source));\n }\n else if (isFetchResponse(source)) {\n this.source = new AsyncByteStreamSource(streamAdapters.fromDOMStream(source.body));\n }\n else if (isIterable(source)) {\n this.source = new AsyncByteStreamSource(streamAdapters.fromIterable(source));\n }\n else if (isPromise(source)) {\n this.source = new AsyncByteStreamSource(streamAdapters.fromAsyncIterable(source));\n }\n else if (isAsyncIterable(source)) {\n this.source = new AsyncByteStreamSource(streamAdapters.fromAsyncIterable(source));\n }\n }\n [Symbol.asyncIterator]() { return this; }\n next(value) { return this.source.next(value); }\n throw(value) { return this.source.throw(value); }\n return(value) { return this.source.return(value); }\n get closed() { return this.source.closed; }\n cancel(reason) { return this.source.cancel(reason); }\n peek(size) { return this.source.peek(size); }\n read(size) { return this.source.read(size); }\n}\n/** @ignore */\nclass ByteStreamSource {\n constructor(source) {\n this.source = source;\n }\n cancel(reason) { this.return(reason); }\n peek(size) { return this.next(size, 'peek').value; }\n read(size) { return this.next(size, 'read').value; }\n next(size, cmd = 'read') { return this.source.next({ cmd, size }); }\n throw(value) { return Object.create((this.source.throw && this.source.throw(value)) || ITERATOR_DONE); }\n return(value) { return Object.create((this.source.return && this.source.return(value)) || ITERATOR_DONE); }\n}\n/** @ignore */\nclass AsyncByteStreamSource {\n constructor(source) {\n this.source = source;\n this._closedPromise = new Promise((r) => this._closedPromiseResolve = r);\n }\n cancel(reason) {\n return __awaiter(this, void 0, void 0, function* () { yield this.return(reason); });\n }\n get closed() { return this._closedPromise; }\n read(size) {\n return __awaiter(this, void 0, void 0, function* () { return (yield this.next(size, 'read')).value; });\n }\n peek(size) {\n return __awaiter(this, void 0, void 0, function* () { return (yield this.next(size, 'peek')).value; });\n }\n next(size, cmd = 'read') {\n return __awaiter(this, void 0, void 0, function* () { return (yield this.source.next({ cmd, size })); });\n }\n throw(value) {\n return __awaiter(this, void 0, void 0, function* () {\n const result = (this.source.throw && (yield this.source.throw(value))) || ITERATOR_DONE;\n this._closedPromiseResolve && this._closedPromiseResolve();\n this._closedPromiseResolve = undefined;\n return Object.create(result);\n });\n }\n return(value) {\n return __awaiter(this, void 0, void 0, function* () {\n const result = (this.source.return && (yield this.source.return(value))) || ITERATOR_DONE;\n this._closedPromiseResolve && this._closedPromiseResolve();\n this._closedPromiseResolve = undefined;\n return Object.create(result);\n });\n }\n}\n\n//# sourceMappingURL=stream.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { toUint8Array } from '../util/buffer.mjs';\nimport { BufferBuilder } from './buffer.mjs';\nimport { VariableWidthBuilder } from '../builder.mjs';\n/** @ignore */\nexport class BinaryBuilder extends VariableWidthBuilder {\n constructor(opts) {\n super(opts);\n this._values = new BufferBuilder(new Uint8Array(0));\n }\n get byteLength() {\n let size = this._pendingLength + (this.length * 4);\n this._offsets && (size += this._offsets.byteLength);\n this._values && (size += this._values.byteLength);\n this._nulls && (size += this._nulls.byteLength);\n return size;\n }\n setValue(index, value) {\n return super.setValue(index, toUint8Array(value));\n }\n _flushPending(pending, pendingLength) {\n const offsets = this._offsets;\n const data = this._values.reserve(pendingLength).buffer;\n let offset = 0;\n for (const [index, value] of pending) {\n if (value === undefined) {\n offsets.set(index, 0);\n }\n else {\n const length = value.length;\n data.set(value, offset);\n offsets.set(index, length);\n offset += length;\n }\n }\n }\n}\n\n//# sourceMappingURL=binary.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { BitmapBufferBuilder } from './buffer.mjs';\nimport { Builder } from '../builder.mjs';\n/** @ignore */\nexport class BoolBuilder extends Builder {\n constructor(options) {\n super(options);\n this._values = new BitmapBufferBuilder();\n }\n setValue(index, value) {\n this._values.set(index, +value);\n }\n}\n\n//# sourceMappingURL=bool.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { FixedWidthBuilder } from '../builder.mjs';\nimport { setDate, setDateDay, setDateMillisecond } from '../visitor/set.mjs';\n/** @ignore */\nexport class DateBuilder extends FixedWidthBuilder {\n}\nDateBuilder.prototype._setValue = setDate;\n/** @ignore */\nexport class DateDayBuilder extends DateBuilder {\n}\nDateDayBuilder.prototype._setValue = setDateDay;\n/** @ignore */\nexport class DateMillisecondBuilder extends DateBuilder {\n}\nDateMillisecondBuilder.prototype._setValue = setDateMillisecond;\n\n//# sourceMappingURL=date.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { FixedWidthBuilder } from '../builder.mjs';\nimport { setDecimal } from '../visitor/set.mjs';\n/** @ignore */\nexport class DecimalBuilder extends FixedWidthBuilder {\n}\nDecimalBuilder.prototype._setValue = setDecimal;\n\n//# sourceMappingURL=decimal.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Dictionary } from '../type.mjs';\nimport { Builder } from '../builder.mjs';\nimport { makeBuilder } from '../factories.mjs';\n/** @ignore */\nexport class DictionaryBuilder extends Builder {\n constructor({ 'type': type, 'nullValues': nulls, 'dictionaryHashFunction': hashFn }) {\n super({ type: new Dictionary(type.dictionary, type.indices, type.id, type.isOrdered) });\n this._nulls = null;\n this._dictionaryOffset = 0;\n this._keysToIndices = Object.create(null);\n this.indices = makeBuilder({ 'type': this.type.indices, 'nullValues': nulls });\n this.dictionary = makeBuilder({ 'type': this.type.dictionary, 'nullValues': null });\n if (typeof hashFn === 'function') {\n this.valueToKey = hashFn;\n }\n }\n get values() { return this.indices.values; }\n get nullCount() { return this.indices.nullCount; }\n get nullBitmap() { return this.indices.nullBitmap; }\n get byteLength() { return this.indices.byteLength + this.dictionary.byteLength; }\n get reservedLength() { return this.indices.reservedLength + this.dictionary.reservedLength; }\n get reservedByteLength() { return this.indices.reservedByteLength + this.dictionary.reservedByteLength; }\n isValid(value) { return this.indices.isValid(value); }\n setValid(index, valid) {\n const indices = this.indices;\n valid = indices.setValid(index, valid);\n this.length = indices.length;\n return valid;\n }\n setValue(index, value) {\n const keysToIndices = this._keysToIndices;\n const key = this.valueToKey(value);\n let idx = keysToIndices[key];\n if (idx === undefined) {\n keysToIndices[key] = idx = this._dictionaryOffset + this.dictionary.append(value).length - 1;\n }\n return this.indices.setValue(index, idx);\n }\n flush() {\n const type = this.type;\n const prev = this._dictionary;\n const curr = this.dictionary.toVector();\n const data = this.indices.flush().clone(type);\n data.dictionary = prev ? prev.concat(curr) : curr;\n this.finished || (this._dictionaryOffset += curr.length);\n this._dictionary = data.dictionary;\n this.clear();\n return data;\n }\n finish() {\n this.indices.finish();\n this.dictionary.finish();\n this._dictionaryOffset = 0;\n this._keysToIndices = Object.create(null);\n return super.finish();\n }\n clear() {\n this.indices.clear();\n this.dictionary.clear();\n return super.clear();\n }\n valueToKey(val) {\n return typeof val === 'string' ? val : `${val}`;\n }\n}\n\n//# sourceMappingURL=dictionary.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { FixedWidthBuilder } from '../builder.mjs';\nimport { setFixedSizeBinary } from '../visitor/set.mjs';\n/** @ignore */\nexport class FixedSizeBinaryBuilder extends FixedWidthBuilder {\n}\nFixedSizeBinaryBuilder.prototype._setValue = setFixedSizeBinary;\n\n//# sourceMappingURL=fixedsizebinary.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Field } from '../schema.mjs';\nimport { Builder } from '../builder.mjs';\nimport { FixedSizeList } from '../type.mjs';\n/** @ignore */\nexport class FixedSizeListBuilder extends Builder {\n setValue(index, value) {\n const [child] = this.children;\n const start = index * this.stride;\n for (let i = -1, n = value.length; ++i < n;) {\n child.set(start + i, value[i]);\n }\n }\n addChild(child, name = '0') {\n if (this.numChildren > 0) {\n throw new Error('FixedSizeListBuilder can only have one child.');\n }\n const childIndex = this.children.push(child);\n this.type = new FixedSizeList(this.type.listSize, new Field(name, child.type, true));\n return childIndex;\n }\n}\n\n//# sourceMappingURL=fixedsizelist.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { float64ToUint16 } from '../util/math.mjs';\nimport { FixedWidthBuilder } from '../builder.mjs';\n/** @ignore */\nexport class FloatBuilder extends FixedWidthBuilder {\n setValue(index, value) {\n this._values.set(index, value);\n }\n}\n/** @ignore */\nexport class Float16Builder extends FloatBuilder {\n setValue(index, value) {\n // convert JS float64 to a uint16\n super.setValue(index, float64ToUint16(value));\n }\n}\n/** @ignore */\nexport class Float32Builder extends FloatBuilder {\n}\n/** @ignore */\nexport class Float64Builder extends FloatBuilder {\n}\n\n//# sourceMappingURL=float.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { FixedWidthBuilder } from '../builder.mjs';\nimport { setIntervalValue, setIntervalDayTime, setIntervalYearMonth } from '../visitor/set.mjs';\n/** @ignore */\nexport class IntervalBuilder extends FixedWidthBuilder {\n}\nIntervalBuilder.prototype._setValue = setIntervalValue;\n/** @ignore */\nexport class IntervalDayTimeBuilder extends IntervalBuilder {\n}\nIntervalDayTimeBuilder.prototype._setValue = setIntervalDayTime;\n/** @ignore */\nexport class IntervalYearMonthBuilder extends IntervalBuilder {\n}\nIntervalYearMonthBuilder.prototype._setValue = setIntervalYearMonth;\n\n//# sourceMappingURL=interval.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { FixedWidthBuilder } from '../builder.mjs';\n/** @ignore */\nexport class IntBuilder extends FixedWidthBuilder {\n setValue(index, value) {\n this._values.set(index, value);\n }\n}\n/** @ignore */\nexport class Int8Builder extends IntBuilder {\n}\n/** @ignore */\nexport class Int16Builder extends IntBuilder {\n}\n/** @ignore */\nexport class Int32Builder extends IntBuilder {\n}\n/** @ignore */\nexport class Int64Builder extends IntBuilder {\n}\n/** @ignore */\nexport class Uint8Builder extends IntBuilder {\n}\n/** @ignore */\nexport class Uint16Builder extends IntBuilder {\n}\n/** @ignore */\nexport class Uint32Builder extends IntBuilder {\n}\n/** @ignore */\nexport class Uint64Builder extends IntBuilder {\n}\n\n//# sourceMappingURL=int.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Field } from '../schema.mjs';\nimport { List } from '../type.mjs';\nimport { OffsetsBufferBuilder } from './buffer.mjs';\nimport { VariableWidthBuilder } from '../builder.mjs';\n/** @ignore */\nexport class ListBuilder extends VariableWidthBuilder {\n constructor(opts) {\n super(opts);\n this._offsets = new OffsetsBufferBuilder();\n }\n addChild(child, name = '0') {\n if (this.numChildren > 0) {\n throw new Error('ListBuilder can only have one child.');\n }\n this.children[this.numChildren] = child;\n this.type = new List(new Field(name, child.type, true));\n return this.numChildren - 1;\n }\n _flushPending(pending) {\n const offsets = this._offsets;\n const [child] = this.children;\n for (const [index, value] of pending) {\n if (typeof value === 'undefined') {\n offsets.set(index, 0);\n }\n else {\n const n = value.length;\n const start = offsets.set(index, n).buffer[index];\n for (let i = -1; ++i < n;) {\n child.set(start + i, value[i]);\n }\n }\n }\n }\n}\n\n//# sourceMappingURL=list.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Field } from '../schema.mjs';\nimport { Map_ } from '../type.mjs';\nimport { VariableWidthBuilder } from '../builder.mjs';\n/** @ignore */\nexport class MapBuilder extends VariableWidthBuilder {\n set(index, value) {\n return super.set(index, value);\n }\n setValue(index, value) {\n const row = (value instanceof Map ? value : new Map(Object.entries(value)));\n const pending = this._pending || (this._pending = new Map());\n const current = pending.get(index);\n current && (this._pendingLength -= current.size);\n this._pendingLength += row.size;\n pending.set(index, row);\n }\n addChild(child, name = `${this.numChildren}`) {\n if (this.numChildren > 0) {\n throw new Error('ListBuilder can only have one child.');\n }\n this.children[this.numChildren] = child;\n this.type = new Map_(new Field(name, child.type, true), this.type.keysSorted);\n return this.numChildren - 1;\n }\n _flushPending(pending) {\n const offsets = this._offsets;\n const [child] = this.children;\n for (const [index, value] of pending) {\n if (value === undefined) {\n offsets.set(index, 0);\n }\n else {\n let { [index]: idx, [index + 1]: end } = offsets.set(index, value.size).buffer;\n for (const val of value.entries()) {\n child.set(idx, val);\n if (++idx >= end)\n break;\n }\n }\n }\n }\n}\n\n//# sourceMappingURL=map.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Builder } from '../builder.mjs';\n/** @ignore */\nexport class NullBuilder extends Builder {\n // @ts-ignore\n setValue(index, value) { }\n setValid(index, valid) {\n this.length = Math.max(index + 1, this.length);\n return valid;\n }\n}\n\n//# sourceMappingURL=null.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\n/* eslint-disable unicorn/no-array-for-each */\nimport { Field } from '../schema.mjs';\nimport { Builder } from '../builder.mjs';\nimport { Struct } from '../type.mjs';\n/** @ignore */\nexport class StructBuilder extends Builder {\n setValue(index, value) {\n const { children, type } = this;\n switch (Array.isArray(value) || value.constructor) {\n case true: return type.children.forEach((_, i) => children[i].set(index, value[i]));\n case Map: return type.children.forEach((f, i) => children[i].set(index, value.get(f.name)));\n default: return type.children.forEach((f, i) => children[i].set(index, value[f.name]));\n }\n }\n /** @inheritdoc */\n setValid(index, valid) {\n if (!super.setValid(index, valid)) {\n this.children.forEach((child) => child.setValid(index, valid));\n }\n return valid;\n }\n addChild(child, name = `${this.numChildren}`) {\n const childIndex = this.children.push(child);\n this.type = new Struct([...this.type.children, new Field(name, child.type, true)]);\n return childIndex;\n }\n}\n\n//# sourceMappingURL=struct.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { FixedWidthBuilder } from '../builder.mjs';\nimport { setTimestamp, setTimestampSecond, setTimestampMillisecond, setTimestampMicrosecond, setTimestampNanosecond } from '../visitor/set.mjs';\n/** @ignore */\nexport class TimestampBuilder extends FixedWidthBuilder {\n}\nTimestampBuilder.prototype._setValue = setTimestamp;\n/** @ignore */\nexport class TimestampSecondBuilder extends TimestampBuilder {\n}\nTimestampSecondBuilder.prototype._setValue = setTimestampSecond;\n/** @ignore */\nexport class TimestampMillisecondBuilder extends TimestampBuilder {\n}\nTimestampMillisecondBuilder.prototype._setValue = setTimestampMillisecond;\n/** @ignore */\nexport class TimestampMicrosecondBuilder extends TimestampBuilder {\n}\nTimestampMicrosecondBuilder.prototype._setValue = setTimestampMicrosecond;\n/** @ignore */\nexport class TimestampNanosecondBuilder extends TimestampBuilder {\n}\nTimestampNanosecondBuilder.prototype._setValue = setTimestampNanosecond;\n\n//# sourceMappingURL=timestamp.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { FixedWidthBuilder } from '../builder.mjs';\nimport { setTime, setTimeSecond, setTimeMillisecond, setTimeMicrosecond, setTimeNanosecond } from '../visitor/set.mjs';\n/** @ignore */\nexport class TimeBuilder extends FixedWidthBuilder {\n}\nTimeBuilder.prototype._setValue = setTime;\n/** @ignore */\nexport class TimeSecondBuilder extends TimeBuilder {\n}\nTimeSecondBuilder.prototype._setValue = setTimeSecond;\n/** @ignore */\nexport class TimeMillisecondBuilder extends TimeBuilder {\n}\nTimeMillisecondBuilder.prototype._setValue = setTimeMillisecond;\n/** @ignore */\nexport class TimeMicrosecondBuilder extends TimeBuilder {\n}\nTimeMicrosecondBuilder.prototype._setValue = setTimeMicrosecond;\n/** @ignore */\nexport class TimeNanosecondBuilder extends TimeBuilder {\n}\nTimeNanosecondBuilder.prototype._setValue = setTimeNanosecond;\n\n//# sourceMappingURL=time.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Field } from '../schema.mjs';\nimport { DataBufferBuilder } from './buffer.mjs';\nimport { Builder } from '../builder.mjs';\nimport { Union } from '../type.mjs';\n/** @ignore */\nexport class UnionBuilder extends Builder {\n constructor(options) {\n super(options);\n this._typeIds = new DataBufferBuilder(new Int8Array(0), 1);\n if (typeof options['valueToChildTypeId'] === 'function') {\n this._valueToChildTypeId = options['valueToChildTypeId'];\n }\n }\n get typeIdToChildIndex() { return this.type.typeIdToChildIndex; }\n append(value, childTypeId) {\n return this.set(this.length, value, childTypeId);\n }\n set(index, value, childTypeId) {\n if (childTypeId === undefined) {\n childTypeId = this._valueToChildTypeId(this, value, index);\n }\n if (this.setValid(index, this.isValid(value))) {\n this.setValue(index, value, childTypeId);\n }\n return this;\n }\n setValue(index, value, childTypeId) {\n this._typeIds.set(index, childTypeId);\n const childIndex = this.type.typeIdToChildIndex[childTypeId];\n const child = this.children[childIndex];\n child === null || child === void 0 ? void 0 : child.set(index, value);\n }\n addChild(child, name = `${this.children.length}`) {\n const childTypeId = this.children.push(child);\n const { type: { children, mode, typeIds } } = this;\n const fields = [...children, new Field(name, child.type)];\n this.type = new Union(mode, [...typeIds, childTypeId], fields);\n return childTypeId;\n }\n /** @ignore */\n // @ts-ignore\n _valueToChildTypeId(builder, value, offset) {\n throw new Error(`Cannot map UnionBuilder value to child typeId. \\\nPass the \\`childTypeId\\` as the second argument to unionBuilder.append(), \\\nor supply a \\`valueToChildTypeId\\` function as part of the UnionBuilder constructor options.`);\n }\n}\n/** @ignore */\nexport class SparseUnionBuilder extends UnionBuilder {\n}\n/** @ignore */\nexport class DenseUnionBuilder extends UnionBuilder {\n constructor(options) {\n super(options);\n this._offsets = new DataBufferBuilder(new Int32Array(0));\n }\n /** @ignore */\n setValue(index, value, childTypeId) {\n const id = this._typeIds.set(index, childTypeId).buffer[index];\n const child = this.getChildAt(this.type.typeIdToChildIndex[id]);\n const denseIndex = this._offsets.set(index, child.length).buffer[index];\n child === null || child === void 0 ? void 0 : child.set(denseIndex, value);\n }\n}\n\n//# sourceMappingURL=union.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { encodeUtf8 } from '../util/utf8.mjs';\nimport { BinaryBuilder } from './binary.mjs';\nimport { BufferBuilder } from './buffer.mjs';\nimport { VariableWidthBuilder } from '../builder.mjs';\n/** @ignore */\nexport class Utf8Builder extends VariableWidthBuilder {\n constructor(opts) {\n super(opts);\n this._values = new BufferBuilder(new Uint8Array(0));\n }\n get byteLength() {\n let size = this._pendingLength + (this.length * 4);\n this._offsets && (size += this._offsets.byteLength);\n this._values && (size += this._values.byteLength);\n this._nulls && (size += this._nulls.byteLength);\n return size;\n }\n setValue(index, value) {\n return super.setValue(index, encodeUtf8(value));\n }\n // @ts-ignore\n _flushPending(pending, pendingLength) { }\n}\nUtf8Builder.prototype._flushPending = BinaryBuilder.prototype._flushPending;\n\n//# sourceMappingURL=utf8.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Visitor } from '../visitor.mjs';\nimport { BinaryBuilder } from '../builder/binary.mjs';\nimport { BoolBuilder } from '../builder/bool.mjs';\nimport { DateBuilder, DateDayBuilder, DateMillisecondBuilder } from '../builder/date.mjs';\nimport { DecimalBuilder } from '../builder/decimal.mjs';\nimport { DictionaryBuilder } from '../builder/dictionary.mjs';\nimport { FixedSizeBinaryBuilder } from '../builder/fixedsizebinary.mjs';\nimport { FixedSizeListBuilder } from '../builder/fixedsizelist.mjs';\nimport { FloatBuilder, Float16Builder, Float32Builder, Float64Builder } from '../builder/float.mjs';\nimport { IntervalBuilder, IntervalDayTimeBuilder, IntervalYearMonthBuilder } from '../builder/interval.mjs';\nimport { IntBuilder, Int8Builder, Int16Builder, Int32Builder, Int64Builder, Uint8Builder, Uint16Builder, Uint32Builder, Uint64Builder } from '../builder/int.mjs';\nimport { ListBuilder } from '../builder/list.mjs';\nimport { MapBuilder } from '../builder/map.mjs';\nimport { NullBuilder } from '../builder/null.mjs';\nimport { StructBuilder } from '../builder/struct.mjs';\nimport { TimestampBuilder, TimestampSecondBuilder, TimestampMillisecondBuilder, TimestampMicrosecondBuilder, TimestampNanosecondBuilder } from '../builder/timestamp.mjs';\nimport { TimeBuilder, TimeSecondBuilder, TimeMillisecondBuilder, TimeMicrosecondBuilder, TimeNanosecondBuilder } from '../builder/time.mjs';\nimport { UnionBuilder, DenseUnionBuilder, SparseUnionBuilder } from '../builder/union.mjs';\nimport { Utf8Builder } from '../builder/utf8.mjs';\n/** @ignore */\nexport class GetBuilderCtor extends Visitor {\n visitNull() { return NullBuilder; }\n visitBool() { return BoolBuilder; }\n visitInt() { return IntBuilder; }\n visitInt8() { return Int8Builder; }\n visitInt16() { return Int16Builder; }\n visitInt32() { return Int32Builder; }\n visitInt64() { return Int64Builder; }\n visitUint8() { return Uint8Builder; }\n visitUint16() { return Uint16Builder; }\n visitUint32() { return Uint32Builder; }\n visitUint64() { return Uint64Builder; }\n visitFloat() { return FloatBuilder; }\n visitFloat16() { return Float16Builder; }\n visitFloat32() { return Float32Builder; }\n visitFloat64() { return Float64Builder; }\n visitUtf8() { return Utf8Builder; }\n visitBinary() { return BinaryBuilder; }\n visitFixedSizeBinary() { return FixedSizeBinaryBuilder; }\n visitDate() { return DateBuilder; }\n visitDateDay() { return DateDayBuilder; }\n visitDateMillisecond() { return DateMillisecondBuilder; }\n visitTimestamp() { return TimestampBuilder; }\n visitTimestampSecond() { return TimestampSecondBuilder; }\n visitTimestampMillisecond() { return TimestampMillisecondBuilder; }\n visitTimestampMicrosecond() { return TimestampMicrosecondBuilder; }\n visitTimestampNanosecond() { return TimestampNanosecondBuilder; }\n visitTime() { return TimeBuilder; }\n visitTimeSecond() { return TimeSecondBuilder; }\n visitTimeMillisecond() { return TimeMillisecondBuilder; }\n visitTimeMicrosecond() { return TimeMicrosecondBuilder; }\n visitTimeNanosecond() { return TimeNanosecondBuilder; }\n visitDecimal() { return DecimalBuilder; }\n visitList() { return ListBuilder; }\n visitStruct() { return StructBuilder; }\n visitUnion() { return UnionBuilder; }\n visitDenseUnion() { return DenseUnionBuilder; }\n visitSparseUnion() { return SparseUnionBuilder; }\n visitDictionary() { return DictionaryBuilder; }\n visitInterval() { return IntervalBuilder; }\n visitIntervalDayTime() { return IntervalDayTimeBuilder; }\n visitIntervalYearMonth() { return IntervalYearMonthBuilder; }\n visitFixedSizeList() { return FixedSizeListBuilder; }\n visitMap() { return MapBuilder; }\n}\n/** @ignore */\nexport const instance = new GetBuilderCtor();\n\n//# sourceMappingURL=builderctor.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Visitor } from '../visitor.mjs';\n/** @ignore */\nexport class TypeComparator extends Visitor {\n compareSchemas(schema, other) {\n return (schema === other) || (other instanceof schema.constructor &&\n this.compareManyFields(schema.fields, other.fields));\n }\n compareManyFields(fields, others) {\n return (fields === others) || (Array.isArray(fields) &&\n Array.isArray(others) &&\n fields.length === others.length &&\n fields.every((f, i) => this.compareFields(f, others[i])));\n }\n compareFields(field, other) {\n return (field === other) || (other instanceof field.constructor &&\n field.name === other.name &&\n field.nullable === other.nullable &&\n this.visit(field.type, other.type));\n }\n}\nfunction compareConstructor(type, other) {\n return other instanceof type.constructor;\n}\nfunction compareAny(type, other) {\n return (type === other) || compareConstructor(type, other);\n}\nfunction compareInt(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.bitWidth === other.bitWidth &&\n type.isSigned === other.isSigned);\n}\nfunction compareFloat(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.precision === other.precision);\n}\nfunction compareFixedSizeBinary(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.byteWidth === other.byteWidth);\n}\nfunction compareDate(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.unit === other.unit);\n}\nfunction compareTimestamp(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.unit === other.unit &&\n type.timezone === other.timezone);\n}\nfunction compareTime(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.unit === other.unit &&\n type.bitWidth === other.bitWidth);\n}\nfunction compareList(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.children.length === other.children.length &&\n instance.compareManyFields(type.children, other.children));\n}\nfunction compareStruct(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.children.length === other.children.length &&\n instance.compareManyFields(type.children, other.children));\n}\nfunction compareUnion(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.mode === other.mode &&\n type.typeIds.every((x, i) => x === other.typeIds[i]) &&\n instance.compareManyFields(type.children, other.children));\n}\nfunction compareDictionary(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.id === other.id &&\n type.isOrdered === other.isOrdered &&\n instance.visit(type.indices, other.indices) &&\n instance.visit(type.dictionary, other.dictionary));\n}\nfunction compareInterval(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.unit === other.unit);\n}\nfunction compareFixedSizeList(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.listSize === other.listSize &&\n type.children.length === other.children.length &&\n instance.compareManyFields(type.children, other.children));\n}\nfunction compareMap(type, other) {\n return (type === other) || (compareConstructor(type, other) &&\n type.keysSorted === other.keysSorted &&\n type.children.length === other.children.length &&\n instance.compareManyFields(type.children, other.children));\n}\nTypeComparator.prototype.visitNull = compareAny;\nTypeComparator.prototype.visitBool = compareAny;\nTypeComparator.prototype.visitInt = compareInt;\nTypeComparator.prototype.visitInt8 = compareInt;\nTypeComparator.prototype.visitInt16 = compareInt;\nTypeComparator.prototype.visitInt32 = compareInt;\nTypeComparator.prototype.visitInt64 = compareInt;\nTypeComparator.prototype.visitUint8 = compareInt;\nTypeComparator.prototype.visitUint16 = compareInt;\nTypeComparator.prototype.visitUint32 = compareInt;\nTypeComparator.prototype.visitUint64 = compareInt;\nTypeComparator.prototype.visitFloat = compareFloat;\nTypeComparator.prototype.visitFloat16 = compareFloat;\nTypeComparator.prototype.visitFloat32 = compareFloat;\nTypeComparator.prototype.visitFloat64 = compareFloat;\nTypeComparator.prototype.visitUtf8 = compareAny;\nTypeComparator.prototype.visitBinary = compareAny;\nTypeComparator.prototype.visitFixedSizeBinary = compareFixedSizeBinary;\nTypeComparator.prototype.visitDate = compareDate;\nTypeComparator.prototype.visitDateDay = compareDate;\nTypeComparator.prototype.visitDateMillisecond = compareDate;\nTypeComparator.prototype.visitTimestamp = compareTimestamp;\nTypeComparator.prototype.visitTimestampSecond = compareTimestamp;\nTypeComparator.prototype.visitTimestampMillisecond = compareTimestamp;\nTypeComparator.prototype.visitTimestampMicrosecond = compareTimestamp;\nTypeComparator.prototype.visitTimestampNanosecond = compareTimestamp;\nTypeComparator.prototype.visitTime = compareTime;\nTypeComparator.prototype.visitTimeSecond = compareTime;\nTypeComparator.prototype.visitTimeMillisecond = compareTime;\nTypeComparator.prototype.visitTimeMicrosecond = compareTime;\nTypeComparator.prototype.visitTimeNanosecond = compareTime;\nTypeComparator.prototype.visitDecimal = compareAny;\nTypeComparator.prototype.visitList = compareList;\nTypeComparator.prototype.visitStruct = compareStruct;\nTypeComparator.prototype.visitUnion = compareUnion;\nTypeComparator.prototype.visitDenseUnion = compareUnion;\nTypeComparator.prototype.visitSparseUnion = compareUnion;\nTypeComparator.prototype.visitDictionary = compareDictionary;\nTypeComparator.prototype.visitInterval = compareInterval;\nTypeComparator.prototype.visitIntervalDayTime = compareInterval;\nTypeComparator.prototype.visitIntervalYearMonth = compareInterval;\nTypeComparator.prototype.visitFixedSizeList = compareFixedSizeList;\nTypeComparator.prototype.visitMap = compareMap;\n/** @ignore */\nexport const instance = new TypeComparator();\nexport function compareSchemas(schema, other) {\n return instance.compareSchemas(schema, other);\n}\nexport function compareFields(field, other) {\n return instance.compareFields(field, other);\n}\nexport function compareTypes(type, other) {\n return instance.visit(type, other);\n}\n\n//# sourceMappingURL=typecomparator.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { __asyncGenerator, __asyncValues, __await } from \"tslib\";\nimport { Field, Schema } from './schema.mjs';\nimport * as dtypes from './type.mjs';\nimport { Data } from './data.mjs';\nimport { Vector, makeVector } from './vector.mjs';\nimport { instance as getBuilderConstructor } from './visitor/builderctor.mjs';\nimport { Table } from './table.mjs';\nimport { RecordBatch } from './recordbatch.mjs';\nimport { compareTypes } from './visitor/typecomparator.mjs';\nexport function makeBuilder(options) {\n const type = options.type;\n const builder = new (getBuilderConstructor.getVisitFn(type)())(options);\n if (type.children && type.children.length > 0) {\n const children = options['children'] || [];\n const defaultOptions = { 'nullValues': options['nullValues'] };\n const getChildOptions = Array.isArray(children)\n ? ((_, i) => children[i] || defaultOptions)\n : (({ name }) => children[name] || defaultOptions);\n for (const [index, field] of type.children.entries()) {\n const { type } = field;\n const opts = getChildOptions(field, index);\n builder.children.push(makeBuilder(Object.assign(Object.assign({}, opts), { type })));\n }\n }\n return builder;\n}\nexport function vectorFromArray(init, type) {\n if (init instanceof Data || init instanceof Vector || init.type instanceof dtypes.DataType || ArrayBuffer.isView(init)) {\n return makeVector(init);\n }\n const options = { type: type !== null && type !== void 0 ? type : inferType(init), nullValues: [null] };\n const chunks = [...builderThroughIterable(options)(init)];\n const vector = chunks.length === 1 ? chunks[0] : chunks.reduce((a, b) => a.concat(b));\n if (dtypes.DataType.isDictionary(vector.type)) {\n return vector.memoize();\n }\n return vector;\n}\n/**\n * Creates a {@link Table} from an array of objects.\n *\n * @param array A table of objects.\n */\nexport function tableFromJSON(array) {\n const vector = vectorFromArray(array);\n const batch = new RecordBatch(new Schema(vector.type.children), vector.data[0]);\n return new Table(batch);\n}\nfunction inferType(value) {\n if (value.length === 0) {\n return new dtypes.Null;\n }\n let nullsCount = 0;\n let arraysCount = 0;\n let objectsCount = 0;\n let numbersCount = 0;\n let stringsCount = 0;\n let bigintsCount = 0;\n let booleansCount = 0;\n let datesCount = 0;\n for (const val of value) {\n if (val == null) {\n ++nullsCount;\n continue;\n }\n switch (typeof val) {\n case 'bigint':\n ++bigintsCount;\n continue;\n case 'boolean':\n ++booleansCount;\n continue;\n case 'number':\n ++numbersCount;\n continue;\n case 'string':\n ++stringsCount;\n continue;\n case 'object':\n if (Array.isArray(val)) {\n ++arraysCount;\n }\n else if (Object.prototype.toString.call(val) === '[object Date]') {\n ++datesCount;\n }\n else {\n ++objectsCount;\n }\n continue;\n }\n throw new TypeError('Unable to infer Vector type from input values, explicit type declaration expected');\n }\n if (numbersCount + nullsCount === value.length) {\n return new dtypes.Float64;\n }\n else if (stringsCount + nullsCount === value.length) {\n return new dtypes.Dictionary(new dtypes.Utf8, new dtypes.Int32);\n }\n else if (bigintsCount + nullsCount === value.length) {\n return new dtypes.Int64;\n }\n else if (booleansCount + nullsCount === value.length) {\n return new dtypes.Bool;\n }\n else if (datesCount + nullsCount === value.length) {\n return new dtypes.DateMillisecond;\n }\n else if (arraysCount + nullsCount === value.length) {\n const array = value;\n const childType = inferType(array[array.findIndex((ary) => ary != null)]);\n if (array.every((ary) => ary == null || compareTypes(childType, inferType(ary)))) {\n return new dtypes.List(new Field('', childType, true));\n }\n }\n else if (objectsCount + nullsCount === value.length) {\n const fields = new Map();\n for (const row of value) {\n for (const key of Object.keys(row)) {\n if (!fields.has(key) && row[key] != null) {\n // use the type inferred for the first instance of a found key\n fields.set(key, new Field(key, inferType([row[key]]), true));\n }\n }\n }\n return new dtypes.Struct([...fields.values()]);\n }\n throw new TypeError('Unable to infer Vector type from input values, explicit type declaration expected');\n}\n/**\n * Transform a synchronous `Iterable` of arbitrary JavaScript values into a\n * sequence of Arrow Vector following the chunking semantics defined in\n * the supplied `options` argument.\n *\n * This function returns a function that accepts an `Iterable` of values to\n * transform. When called, this function returns an Iterator of `Vector`.\n *\n * The resulting `Iterator>` yields Vectors based on the\n * `queueingStrategy` and `highWaterMark` specified in the `options` argument.\n *\n * * If `queueingStrategy` is `\"count\"` (or omitted), The `Iterator>`\n * will flush the underlying `Builder` (and yield a new `Vector`) once the\n * Builder's `length` reaches or exceeds the supplied `highWaterMark`.\n * * If `queueingStrategy` is `\"bytes\"`, the `Iterator>` will flush\n * the underlying `Builder` (and yield a new `Vector`) once its `byteLength`\n * reaches or exceeds the supplied `highWaterMark`.\n *\n * @param {IterableBuilderOptions} options An object of properties which determine the `Builder` to create and the chunking semantics to use.\n * @returns A function which accepts a JavaScript `Iterable` of values to\n * write, and returns an `Iterator` that yields Vectors according\n * to the chunking semantics defined in the `options` argument.\n * @nocollapse\n */\nexport function builderThroughIterable(options) {\n const { ['queueingStrategy']: queueingStrategy = 'count' } = options;\n const { ['highWaterMark']: highWaterMark = queueingStrategy !== 'bytes' ? Number.POSITIVE_INFINITY : Math.pow(2, 14) } = options;\n const sizeProperty = queueingStrategy !== 'bytes' ? 'length' : 'byteLength';\n return function* (source) {\n let numChunks = 0;\n const builder = makeBuilder(options);\n for (const value of source) {\n if (builder.append(value)[sizeProperty] >= highWaterMark) {\n ++numChunks && (yield builder.toVector());\n }\n }\n if (builder.finish().length > 0 || numChunks === 0) {\n yield builder.toVector();\n }\n };\n}\n/**\n * Transform an `AsyncIterable` of arbitrary JavaScript values into a\n * sequence of Arrow Vector following the chunking semantics defined in\n * the supplied `options` argument.\n *\n * This function returns a function that accepts an `AsyncIterable` of values to\n * transform. When called, this function returns an AsyncIterator of `Vector`.\n *\n * The resulting `AsyncIterator>` yields Vectors based on the\n * `queueingStrategy` and `highWaterMark` specified in the `options` argument.\n *\n * * If `queueingStrategy` is `\"count\"` (or omitted), The `AsyncIterator>`\n * will flush the underlying `Builder` (and yield a new `Vector`) once the\n * Builder's `length` reaches or exceeds the supplied `highWaterMark`.\n * * If `queueingStrategy` is `\"bytes\"`, the `AsyncIterator>` will flush\n * the underlying `Builder` (and yield a new `Vector`) once its `byteLength`\n * reaches or exceeds the supplied `highWaterMark`.\n *\n * @param {IterableBuilderOptions} options An object of properties which determine the `Builder` to create and the chunking semantics to use.\n * @returns A function which accepts a JavaScript `AsyncIterable` of values\n * to write, and returns an `AsyncIterator` that yields Vectors\n * according to the chunking semantics defined in the `options`\n * argument.\n * @nocollapse\n */\nexport function builderThroughAsyncIterable(options) {\n const { ['queueingStrategy']: queueingStrategy = 'count' } = options;\n const { ['highWaterMark']: highWaterMark = queueingStrategy !== 'bytes' ? Number.POSITIVE_INFINITY : Math.pow(2, 14) } = options;\n const sizeProperty = queueingStrategy !== 'bytes' ? 'length' : 'byteLength';\n return function (source) {\n return __asyncGenerator(this, arguments, function* () {\n var e_1, _a;\n let numChunks = 0;\n const builder = makeBuilder(options);\n try {\n for (var source_1 = __asyncValues(source), source_1_1; source_1_1 = yield __await(source_1.next()), !source_1_1.done;) {\n const value = source_1_1.value;\n if (builder.append(value)[sizeProperty] >= highWaterMark) {\n ++numChunks && (yield yield __await(builder.toVector()));\n }\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (source_1_1 && !source_1_1.done && (_a = source_1.return)) yield __await(_a.call(source_1));\n }\n finally { if (e_1) throw e_1.error; }\n }\n if (builder.finish().length > 0 || numChunks === 0) {\n yield yield __await(builder.toVector());\n }\n });\n };\n}\n\n//# sourceMappingURL=factories.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { makeData } from '../data.mjs';\nimport { Struct } from '../type.mjs';\nimport { RecordBatch } from '../recordbatch.mjs';\n/** @ignore */\nexport function distributeVectorsIntoRecordBatches(schema, vecs) {\n return uniformlyDistributeChunksAcrossRecordBatches(schema, vecs.map((v) => v.data.concat()));\n}\n/** @ignore */\nfunction uniformlyDistributeChunksAcrossRecordBatches(schema, cols) {\n const fields = [...schema.fields];\n const batches = [];\n const memo = { numBatches: cols.reduce((n, c) => Math.max(n, c.length), 0) };\n let numBatches = 0, batchLength = 0;\n let i = -1;\n const numColumns = cols.length;\n let child, children = [];\n while (memo.numBatches-- > 0) {\n for (batchLength = Number.POSITIVE_INFINITY, i = -1; ++i < numColumns;) {\n children[i] = child = cols[i].shift();\n batchLength = Math.min(batchLength, child ? child.length : batchLength);\n }\n if (Number.isFinite(batchLength)) {\n children = distributeChildren(fields, batchLength, children, cols, memo);\n if (batchLength > 0) {\n batches[numBatches++] = makeData({\n type: new Struct(fields),\n length: batchLength,\n nullCount: 0,\n children: children.slice()\n });\n }\n }\n }\n return [\n schema = schema.assign(fields),\n batches.map((data) => new RecordBatch(schema, data))\n ];\n}\n/** @ignore */\nfunction distributeChildren(fields, batchLength, children, columns, memo) {\n var _a;\n const nullBitmapSize = ((batchLength + 63) & ~63) >> 3;\n for (let i = -1, n = columns.length; ++i < n;) {\n const child = children[i];\n const length = child === null || child === void 0 ? void 0 : child.length;\n if (length >= batchLength) {\n if (length === batchLength) {\n children[i] = child;\n }\n else {\n children[i] = child.slice(0, batchLength);\n memo.numBatches = Math.max(memo.numBatches, columns[i].unshift(child.slice(batchLength, length - batchLength)));\n }\n }\n else {\n const field = fields[i];\n fields[i] = field.clone({ nullable: true });\n children[i] = (_a = child === null || child === void 0 ? void 0 : child._changeLengthAndBackfillNullBitmap(batchLength)) !== null && _a !== void 0 ? _a : makeData({\n type: field.type,\n length: batchLength,\n nullCount: batchLength,\n nullBitmap: new Uint8Array(nullBitmapSize)\n });\n }\n }\n return children;\n}\n\n//# sourceMappingURL=recordbatch.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nvar _a;\nimport { Type } from './enum.mjs';\nimport { Data, makeData } from './data.mjs';\nimport { vectorFromArray } from './factories.mjs';\nimport { makeVector, Vector } from './vector.mjs';\nimport { Field, Schema } from './schema.mjs';\nimport { Null, Struct } from './type.mjs';\nimport { compareSchemas } from './visitor/typecomparator.mjs';\nimport { distributeVectorsIntoRecordBatches } from './util/recordbatch.mjs';\nimport { isChunkedValid, computeChunkOffsets, computeChunkNullCounts, wrapChunkedCall1, wrapChunkedCall2, wrapChunkedIndexOf, sliceChunks, } from './util/chunk.mjs';\nimport { instance as getVisitor } from './visitor/get.mjs';\nimport { instance as setVisitor } from './visitor/set.mjs';\nimport { instance as indexOfVisitor } from './visitor/indexof.mjs';\nimport { instance as iteratorVisitor } from './visitor/iterator.mjs';\nimport { instance as byteLengthVisitor } from './visitor/bytelength.mjs';\nimport { clampRange } from './util/vector.mjs';\nimport { RecordBatch } from './recordbatch.mjs';\n/**\n * Tables are collections of {@link Vector}s and have a {@link Schema}. Use the convenience methods {@link makeTable}\n * or {@link tableFromArrays} to create a table in JavaScript. To create a table from the IPC format, use\n * {@link tableFromIPC}.\n */\nexport class Table {\n constructor(...args) {\n var _b, _c;\n if (args.length === 0) {\n this.batches = [];\n this.schema = new Schema([]);\n this._offsets = [0];\n return this;\n }\n let schema;\n let offsets;\n if (args[0] instanceof Schema) {\n schema = args.shift();\n }\n if (args[args.length - 1] instanceof Uint32Array) {\n offsets = args.pop();\n }\n const unwrap = (x) => {\n if (x) {\n if (x instanceof RecordBatch) {\n return [x];\n }\n else if (x instanceof Table) {\n return x.batches;\n }\n else if (x instanceof Data) {\n if (x.type instanceof Struct) {\n return [new RecordBatch(new Schema(x.type.children), x)];\n }\n }\n else if (Array.isArray(x)) {\n return x.flatMap(v => unwrap(v));\n }\n else if (typeof x[Symbol.iterator] === 'function') {\n return [...x].flatMap(v => unwrap(v));\n }\n else if (typeof x === 'object') {\n const keys = Object.keys(x);\n const vecs = keys.map((k) => new Vector([x[k]]));\n const schema = new Schema(keys.map((k, i) => new Field(String(k), vecs[i].type)));\n const [, batches] = distributeVectorsIntoRecordBatches(schema, vecs);\n return batches.length === 0 ? [new RecordBatch(x)] : batches;\n }\n }\n return [];\n };\n const batches = args.flatMap(v => unwrap(v));\n schema = (_c = schema !== null && schema !== void 0 ? schema : (_b = batches[0]) === null || _b === void 0 ? void 0 : _b.schema) !== null && _c !== void 0 ? _c : new Schema([]);\n if (!(schema instanceof Schema)) {\n throw new TypeError('Table constructor expects a [Schema, RecordBatch[]] pair.');\n }\n for (const batch of batches) {\n if (!(batch instanceof RecordBatch)) {\n throw new TypeError('Table constructor expects a [Schema, RecordBatch[]] pair.');\n }\n if (!compareSchemas(schema, batch.schema)) {\n throw new TypeError('Table and inner RecordBatch schemas must be equivalent.');\n }\n }\n this.schema = schema;\n this.batches = batches;\n this._offsets = offsets !== null && offsets !== void 0 ? offsets : computeChunkOffsets(this.data);\n }\n /**\n * The contiguous {@link RecordBatch `RecordBatch`} chunks of the Table rows.\n */\n get data() { return this.batches.map(({ data }) => data); }\n /**\n * The number of columns in this Table.\n */\n get numCols() { return this.schema.fields.length; }\n /**\n * The number of rows in this Table.\n */\n get numRows() {\n return this.data.reduce((numRows, data) => numRows + data.length, 0);\n }\n /**\n * The number of null rows in this Table.\n */\n get nullCount() {\n if (this._nullCount === -1) {\n this._nullCount = computeChunkNullCounts(this.data);\n }\n return this._nullCount;\n }\n /**\n * Check whether an element is null.\n *\n * @param index The index at which to read the validity bitmap.\n */\n // @ts-ignore\n isValid(index) { return false; }\n /**\n * Get an element value by position.\n *\n * @param index The index of the element to read.\n */\n // @ts-ignore\n get(index) { return null; }\n /**\n * Set an element value by position.\n *\n * @param index The index of the element to write.\n * @param value The value to set.\n */\n // @ts-ignore\n set(index, value) { return; }\n /**\n * Retrieve the index of the first occurrence of a value in an Vector.\n *\n * @param element The value to locate in the Vector.\n * @param offset The index at which to begin the search. If offset is omitted, the search starts at index 0.\n */\n // @ts-ignore\n indexOf(element, offset) { return -1; }\n /**\n * Get the size in bytes of an element by index.\n * @param index The index at which to get the byteLength.\n */\n // @ts-ignore\n getByteLength(index) { return 0; }\n /**\n * Iterator for rows in this Table.\n */\n [Symbol.iterator]() {\n if (this.batches.length > 0) {\n return iteratorVisitor.visit(new Vector(this.data));\n }\n return (new Array(0))[Symbol.iterator]();\n }\n /**\n * Return a JavaScript Array of the Table rows.\n *\n * @returns An Array of Table rows.\n */\n toArray() {\n return [...this];\n }\n /**\n * Returns a string representation of the Table rows.\n *\n * @returns A string representation of the Table rows.\n */\n toString() {\n return `[\\n ${this.toArray().join(',\\n ')}\\n]`;\n }\n /**\n * Combines two or more Tables of the same schema.\n *\n * @param others Additional Tables to add to the end of this Tables.\n */\n concat(...others) {\n const schema = this.schema;\n const data = this.data.concat(others.flatMap(({ data }) => data));\n return new Table(schema, data.map((data) => new RecordBatch(schema, data)));\n }\n /**\n * Return a zero-copy sub-section of this Table.\n *\n * @param begin The beginning of the specified portion of the Table.\n * @param end The end of the specified portion of the Table. This is exclusive of the element at the index 'end'.\n */\n slice(begin, end) {\n const schema = this.schema;\n [begin, end] = clampRange({ length: this.numRows }, begin, end);\n const data = sliceChunks(this.data, this._offsets, begin, end);\n return new Table(schema, data.map((chunk) => new RecordBatch(schema, chunk)));\n }\n /**\n * Returns a child Vector by name, or null if this Vector has no child with the given name.\n *\n * @param name The name of the child to retrieve.\n */\n getChild(name) {\n return this.getChildAt(this.schema.fields.findIndex((f) => f.name === name));\n }\n /**\n * Returns a child Vector by index, or null if this Vector has no child at the supplied index.\n *\n * @param index The index of the child to retrieve.\n */\n getChildAt(index) {\n if (index > -1 && index < this.schema.fields.length) {\n const data = this.data.map((data) => data.children[index]);\n if (data.length === 0) {\n const { type } = this.schema.fields[index];\n const empty = makeData({ type, length: 0, nullCount: 0 });\n data.push(empty._changeLengthAndBackfillNullBitmap(this.numRows));\n }\n return new Vector(data);\n }\n return null;\n }\n /**\n * Sets a child Vector by name.\n *\n * @param name The name of the child to overwrite.\n * @returns A new Table with the supplied child for the specified name.\n */\n setChild(name, child) {\n var _b;\n return this.setChildAt((_b = this.schema.fields) === null || _b === void 0 ? void 0 : _b.findIndex((f) => f.name === name), child);\n }\n setChildAt(index, child) {\n let schema = this.schema;\n let batches = [...this.batches];\n if (index > -1 && index < this.numCols) {\n if (!child) {\n child = new Vector([makeData({ type: new Null, length: this.numRows })]);\n }\n const fields = schema.fields.slice();\n const field = fields[index].clone({ type: child.type });\n const children = this.schema.fields.map((_, i) => this.getChildAt(i));\n [fields[index], children[index]] = [field, child];\n [schema, batches] = distributeVectorsIntoRecordBatches(schema, children);\n }\n return new Table(schema, batches);\n }\n /**\n * Construct a new Table containing only specified columns.\n *\n * @param columnNames Names of columns to keep.\n * @returns A new Table of columns matching the specified names.\n */\n select(columnNames) {\n const nameToIndex = this.schema.fields.reduce((m, f, i) => m.set(f.name, i), new Map());\n return this.selectAt(columnNames.map((columnName) => nameToIndex.get(columnName)).filter((x) => x > -1));\n }\n /**\n * Construct a new Table containing only columns at the specified indices.\n *\n * @param columnIndices Indices of columns to keep.\n * @returns A new Table of columns at the specified indices.\n */\n selectAt(columnIndices) {\n const schema = this.schema.selectAt(columnIndices);\n const data = this.batches.map((batch) => batch.selectAt(columnIndices));\n return new Table(schema, data);\n }\n assign(other) {\n const fields = this.schema.fields;\n const [indices, oldToNew] = other.schema.fields.reduce((memo, f2, newIdx) => {\n const [indices, oldToNew] = memo;\n const i = fields.findIndex((f) => f.name === f2.name);\n ~i ? (oldToNew[i] = newIdx) : indices.push(newIdx);\n return memo;\n }, [[], []]);\n const schema = this.schema.assign(other.schema);\n const columns = [\n ...fields.map((_, i) => [i, oldToNew[i]]).map(([i, j]) => (j === undefined ? this.getChildAt(i) : other.getChildAt(j))),\n ...indices.map((i) => other.getChildAt(i))\n ].filter(Boolean);\n return new Table(...distributeVectorsIntoRecordBatches(schema, columns));\n }\n}\n_a = Symbol.toStringTag;\n// Initialize this static property via an IIFE so bundlers don't tree-shake\n// out this logic, but also so we're still compliant with `\"sideEffects\": false`\nTable[_a] = ((proto) => {\n proto.schema = null;\n proto.batches = [];\n proto._offsets = new Uint32Array([0]);\n proto._nullCount = -1;\n proto[Symbol.isConcatSpreadable] = true;\n proto['isValid'] = wrapChunkedCall1(isChunkedValid);\n proto['get'] = wrapChunkedCall1(getVisitor.getVisitFn(Type.Struct));\n proto['set'] = wrapChunkedCall2(setVisitor.getVisitFn(Type.Struct));\n proto['indexOf'] = wrapChunkedIndexOf(indexOfVisitor.getVisitFn(Type.Struct));\n proto['getByteLength'] = wrapChunkedCall1(byteLengthVisitor.getVisitFn(Type.Struct));\n return 'Table';\n})(Table.prototype);\n/**\n * Creates a new Table from an object of typed arrays.\n *\n* @example\n * ```ts\n * const table = makeTable({\n * a: new Int8Array([1, 2, 3]),\n * })\n * ```\n *\n * @param input Input an object of typed arrays.\n * @returns A new Table.\n */\nexport function makeTable(input) {\n const vecs = {};\n const inputs = Object.entries(input);\n for (const [key, col] of inputs) {\n vecs[key] = makeVector(col);\n }\n return new Table(vecs);\n}\n/**\n * Creates a new Table from an object of typed arrays or JavaScript arrays.\n *\n * @example\n * ```ts\n * const table = tableFromArrays({\n * a: [1, 2, 3],\n * b: new Int8Array([1, 2, 3]),\n * })\n * ```\n *\n * @param input Input an object of typed arrays or JavaScript arrays.\n * @returns A new Table.\n */\nexport function tableFromArrays(input) {\n const vecs = {};\n const inputs = Object.entries(input);\n for (const [key, col] of inputs) {\n vecs[key] = vectorFromArray(col);\n }\n return new Table(vecs);\n}\n\n//# sourceMappingURL=table.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nvar _a;\nimport { Data, makeData } from './data.mjs';\nimport { Table } from './table.mjs';\nimport { Vector } from './vector.mjs';\nimport { Schema, Field } from './schema.mjs';\nimport { DataType, Struct, Null } from './type.mjs';\nimport { instance as getVisitor } from './visitor/get.mjs';\nimport { instance as setVisitor } from './visitor/set.mjs';\nimport { instance as indexOfVisitor } from './visitor/indexof.mjs';\nimport { instance as iteratorVisitor } from './visitor/iterator.mjs';\nimport { instance as byteLengthVisitor } from './visitor/bytelength.mjs';\n/** @ignore */\nexport class RecordBatch {\n constructor(...args) {\n switch (args.length) {\n case 2: {\n [this.schema] = args;\n if (!(this.schema instanceof Schema)) {\n throw new TypeError('RecordBatch constructor expects a [Schema, Data] pair.');\n }\n [,\n this.data = makeData({\n nullCount: 0,\n type: new Struct(this.schema.fields),\n children: this.schema.fields.map((f) => makeData({ type: f.type, nullCount: 0 }))\n })\n ] = args;\n if (!(this.data instanceof Data)) {\n throw new TypeError('RecordBatch constructor expects a [Schema, Data] pair.');\n }\n [this.schema, this.data] = ensureSameLengthData(this.schema, this.data.children);\n break;\n }\n case 1: {\n const [obj] = args;\n const { fields, children, length } = Object.keys(obj).reduce((memo, name, i) => {\n memo.children[i] = obj[name];\n memo.length = Math.max(memo.length, obj[name].length);\n memo.fields[i] = Field.new({ name, type: obj[name].type, nullable: true });\n return memo;\n }, {\n length: 0,\n fields: new Array(),\n children: new Array(),\n });\n const schema = new Schema(fields);\n const data = makeData({ type: new Struct(fields), length, children, nullCount: 0 });\n [this.schema, this.data] = ensureSameLengthData(schema, data.children, length);\n break;\n }\n default: throw new TypeError('RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.');\n }\n }\n get dictionaries() {\n return this._dictionaries || (this._dictionaries = collectDictionaries(this.schema.fields, this.data.children));\n }\n /**\n * The number of columns in this RecordBatch.\n */\n get numCols() { return this.schema.fields.length; }\n /**\n * The number of rows in this RecordBatch.\n */\n get numRows() { return this.data.length; }\n /**\n * The number of null rows in this RecordBatch.\n */\n get nullCount() {\n return this.data.nullCount;\n }\n /**\n * Check whether an element is null.\n * @param index The index at which to read the validity bitmap.\n */\n isValid(index) {\n return this.data.getValid(index);\n }\n /**\n * Get a row by position.\n * @param index The index of the element to read.\n */\n get(index) {\n return getVisitor.visit(this.data, index);\n }\n /**\n * Set a row by position.\n * @param index The index of the element to write.\n * @param value The value to set.\n */\n set(index, value) {\n return setVisitor.visit(this.data, index, value);\n }\n /**\n * Retrieve the index of the first occurrence of a row in an RecordBatch.\n * @param element The row to locate in the RecordBatch.\n * @param offset The index at which to begin the search. If offset is omitted, the search starts at index 0.\n */\n indexOf(element, offset) {\n return indexOfVisitor.visit(this.data, element, offset);\n }\n /**\n * Get the size (in bytes) of a row by index.\n * @param index The row index for which to compute the byteLength.\n */\n getByteLength(index) {\n return byteLengthVisitor.visit(this.data, index);\n }\n /**\n * Iterator for rows in this RecordBatch.\n */\n [Symbol.iterator]() {\n return iteratorVisitor.visit(new Vector([this.data]));\n }\n /**\n * Return a JavaScript Array of the RecordBatch rows.\n * @returns An Array of RecordBatch rows.\n */\n toArray() {\n return [...this];\n }\n /**\n * Combines two or more RecordBatch of the same schema.\n * @param others Additional RecordBatch to add to the end of this RecordBatch.\n */\n concat(...others) {\n return new Table(this.schema, [this, ...others]);\n }\n /**\n * Return a zero-copy sub-section of this RecordBatch.\n * @param start The beginning of the specified portion of the RecordBatch.\n * @param end The end of the specified portion of the RecordBatch. This is exclusive of the element at the index 'end'.\n */\n slice(begin, end) {\n const [slice] = new Vector([this.data]).slice(begin, end).data;\n return new RecordBatch(this.schema, slice);\n }\n /**\n * Returns a child Vector by name, or null if this Vector has no child with the given name.\n * @param name The name of the child to retrieve.\n */\n getChild(name) {\n var _b;\n return this.getChildAt((_b = this.schema.fields) === null || _b === void 0 ? void 0 : _b.findIndex((f) => f.name === name));\n }\n /**\n * Returns a child Vector by index, or null if this Vector has no child at the supplied index.\n * @param index The index of the child to retrieve.\n */\n getChildAt(index) {\n if (index > -1 && index < this.schema.fields.length) {\n return new Vector([this.data.children[index]]);\n }\n return null;\n }\n /**\n * Sets a child Vector by name.\n * @param name The name of the child to overwrite.\n * @returns A new RecordBatch with the new child for the specified name.\n */\n setChild(name, child) {\n var _b;\n return this.setChildAt((_b = this.schema.fields) === null || _b === void 0 ? void 0 : _b.findIndex((f) => f.name === name), child);\n }\n setChildAt(index, child) {\n let schema = this.schema;\n let data = this.data;\n if (index > -1 && index < this.numCols) {\n if (!child) {\n child = new Vector([makeData({ type: new Null, length: this.numRows })]);\n }\n const fields = schema.fields.slice();\n const children = data.children.slice();\n const field = fields[index].clone({ type: child.type });\n [fields[index], children[index]] = [field, child.data[0]];\n schema = new Schema(fields, new Map(this.schema.metadata));\n data = makeData({ type: new Struct(fields), children });\n }\n return new RecordBatch(schema, data);\n }\n /**\n * Construct a new RecordBatch containing only specified columns.\n *\n * @param columnNames Names of columns to keep.\n * @returns A new RecordBatch of columns matching the specified names.\n */\n select(columnNames) {\n const schema = this.schema.select(columnNames);\n const type = new Struct(schema.fields);\n const children = [];\n for (const name of columnNames) {\n const index = this.schema.fields.findIndex((f) => f.name === name);\n if (~index) {\n children[index] = this.data.children[index];\n }\n }\n return new RecordBatch(schema, makeData({ type, length: this.numRows, children }));\n }\n /**\n * Construct a new RecordBatch containing only columns at the specified indices.\n *\n * @param columnIndices Indices of columns to keep.\n * @returns A new RecordBatch of columns matching at the specified indices.\n */\n selectAt(columnIndices) {\n const schema = this.schema.selectAt(columnIndices);\n const children = columnIndices.map((i) => this.data.children[i]).filter(Boolean);\n const subset = makeData({ type: new Struct(schema.fields), length: this.numRows, children });\n return new RecordBatch(schema, subset);\n }\n}\n_a = Symbol.toStringTag;\n// Initialize this static property via an IIFE so bundlers don't tree-shake\n// out this logic, but also so we're still compliant with `\"sideEffects\": false`\nRecordBatch[_a] = ((proto) => {\n proto._nullCount = -1;\n proto[Symbol.isConcatSpreadable] = true;\n return 'RecordBatch';\n})(RecordBatch.prototype);\n/** @ignore */\nfunction ensureSameLengthData(schema, chunks, maxLength = chunks.reduce((max, col) => Math.max(max, col.length), 0)) {\n var _b;\n const fields = [...schema.fields];\n const children = [...chunks];\n const nullBitmapSize = ((maxLength + 63) & ~63) >> 3;\n for (const [idx, field] of schema.fields.entries()) {\n const chunk = chunks[idx];\n if (!chunk || chunk.length !== maxLength) {\n fields[idx] = field.clone({ nullable: true });\n children[idx] = (_b = chunk === null || chunk === void 0 ? void 0 : chunk._changeLengthAndBackfillNullBitmap(maxLength)) !== null && _b !== void 0 ? _b : makeData({\n type: field.type,\n length: maxLength,\n nullCount: maxLength,\n nullBitmap: new Uint8Array(nullBitmapSize)\n });\n }\n }\n return [\n schema.assign(fields),\n makeData({ type: new Struct(fields), length: maxLength, children })\n ];\n}\n/** @ignore */\nfunction collectDictionaries(fields, children, dictionaries = new Map()) {\n for (let i = -1, n = fields.length; ++i < n;) {\n const field = fields[i];\n const type = field.type;\n const data = children[i];\n if (DataType.isDictionary(type)) {\n if (!dictionaries.has(type.id)) {\n if (data.dictionary) {\n dictionaries.set(type.id, data.dictionary);\n }\n }\n else if (dictionaries.get(type.id) !== data.dictionary) {\n throw new Error(`Cannot create Schema containing two different dictionaries with the same Id`);\n }\n }\n if (type.children && type.children.length > 0) {\n collectDictionaries(type.children, data.children, dictionaries);\n }\n }\n return dictionaries;\n}\n/**\n * An internal class used by the `RecordBatchReader` and `RecordBatchWriter`\n * implementations to differentiate between a stream with valid zero-length\n * RecordBatches, and a stream with a Schema message, but no RecordBatches.\n * @see https://github.com/apache/arrow/pull/4373\n * @ignore\n * @private\n */\nexport class _InternalEmptyPlaceholderRecordBatch extends RecordBatch {\n constructor(schema) {\n const children = schema.fields.map((f) => makeData({ type: f.type }));\n const data = makeData({ type: new Struct(schema.fields), nullCount: 0, children });\n super(schema, data);\n }\n}\n\n//# sourceMappingURL=recordbatch.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\n/**\n * Provided for forward compatibility in case we need to support different\n * strategies for compressing the IPC message body (like whole-body\n * compression rather than buffer-level) in the future\n */\nexport var BodyCompressionMethod;\n(function (BodyCompressionMethod) {\n /**\n * Each constituent buffer is first compressed with the indicated\n * compressor, and then written with the uncompressed length in the first 8\n * bytes as a 64-bit little-endian signed integer followed by the compressed\n * buffer bytes (and then padding as required by the protocol). The\n * uncompressed length may be set to -1 to indicate that the data that\n * follows is not compressed, which can be useful for cases where\n * compression does not yield appreciable savings.\n */\n BodyCompressionMethod[BodyCompressionMethod[\"BUFFER\"] = 0] = \"BUFFER\";\n})(BodyCompressionMethod || (BodyCompressionMethod = {}));\n\n//# sourceMappingURL=body-compression-method.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nexport var CompressionType;\n(function (CompressionType) {\n CompressionType[CompressionType[\"LZ4_FRAME\"] = 0] = \"LZ4_FRAME\";\n CompressionType[CompressionType[\"ZSTD\"] = 1] = \"ZSTD\";\n})(CompressionType || (CompressionType = {}));\n\n//# sourceMappingURL=compression-type.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { BodyCompressionMethod } from './body-compression-method.mjs';\nimport { CompressionType } from './compression-type.mjs';\n/**\n * Optional compression for the memory buffers constituting IPC message\n * bodies. Intended for use with RecordBatch but could be used for other\n * message types\n */\nexport class BodyCompression {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsBodyCompression(bb, obj) {\n return (obj || new BodyCompression()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsBodyCompression(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new BodyCompression()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n /**\n * Compressor library.\n * For LZ4_FRAME, each compressed buffer must consist of a single frame.\n */\n codec() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt8(this.bb_pos + offset) : CompressionType.LZ4_FRAME;\n }\n /**\n * Indicates the way the record batch body was compressed\n */\n method() {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? this.bb.readInt8(this.bb_pos + offset) : BodyCompressionMethod.BUFFER;\n }\n static startBodyCompression(builder) {\n builder.startObject(2);\n }\n static addCodec(builder, codec) {\n builder.addFieldInt8(0, codec, CompressionType.LZ4_FRAME);\n }\n static addMethod(builder, method) {\n builder.addFieldInt8(1, method, BodyCompressionMethod.BUFFER);\n }\n static endBodyCompression(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static createBodyCompression(builder, codec, method) {\n BodyCompression.startBodyCompression(builder);\n BodyCompression.addCodec(builder, codec);\n BodyCompression.addMethod(builder, method);\n return BodyCompression.endBodyCompression(builder);\n }\n}\n\n//# sourceMappingURL=body-compression.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\n/**\n * ----------------------------------------------------------------------\n * A Buffer represents a single contiguous memory segment\n */\nexport class Buffer {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n /**\n * The relative offset into the shared memory page where the bytes for this\n * buffer starts\n */\n offset() {\n return this.bb.readInt64(this.bb_pos);\n }\n /**\n * The absolute length (in bytes) of the memory buffer. The memory is found\n * from offset (inclusive) to offset + length (non-inclusive). When building\n * messages using the encapsulated IPC message, padding bytes may be written\n * after a buffer, but such padding bytes do not need to be accounted for in\n * the size here.\n */\n length() {\n return this.bb.readInt64(this.bb_pos + 8);\n }\n static sizeOf() {\n return 16;\n }\n static createBuffer(builder, offset, length) {\n builder.prep(8, 16);\n builder.writeInt64(length);\n builder.writeInt64(offset);\n return builder.offset();\n }\n}\n\n//# sourceMappingURL=buffer.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\n/**\n * ----------------------------------------------------------------------\n * Data structures for describing a table row batch (a collection of\n * equal-length Arrow arrays)\n * Metadata about a field at some level of a nested type tree (but not\n * its children).\n *\n * For example, a List with values `[[1, 2, 3], null, [4], [5, 6], null]`\n * would have {length: 5, null_count: 2} for its List node, and {length: 6,\n * null_count: 0} for its Int16 node, as separate FieldNode structs\n */\nexport class FieldNode {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n /**\n * The number of value slots in the Arrow array at this level of a nested\n * tree\n */\n length() {\n return this.bb.readInt64(this.bb_pos);\n }\n /**\n * The number of observed nulls. Fields with null_count == 0 may choose not\n * to write their physical validity bitmap out as a materialized buffer,\n * instead setting the length of the bitmap buffer to 0.\n */\n nullCount() {\n return this.bb.readInt64(this.bb_pos + 8);\n }\n static sizeOf() {\n return 16;\n }\n static createFieldNode(builder, length, null_count) {\n builder.prep(8, 16);\n builder.writeInt64(null_count);\n builder.writeInt64(length);\n return builder.offset();\n }\n}\n\n//# sourceMappingURL=field-node.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { BodyCompression } from './body-compression.mjs';\nimport { Buffer } from './buffer.mjs';\nimport { FieldNode } from './field-node.mjs';\n/**\n * A data header describing the shared memory layout of a \"record\" or \"row\"\n * batch. Some systems call this a \"row batch\" internally and others a \"record\n * batch\".\n */\nexport class RecordBatch {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsRecordBatch(bb, obj) {\n return (obj || new RecordBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsRecordBatch(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new RecordBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n /**\n * number of records / rows. The arrays in the batch should all have this\n * length\n */\n length() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);\n }\n /**\n * Nodes correspond to the pre-ordered flattened logical schema\n */\n nodes(index, obj) {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? (obj || new FieldNode()).__init(this.bb.__vector(this.bb_pos + offset) + index * 16, this.bb) : null;\n }\n nodesLength() {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n /**\n * Buffers correspond to the pre-ordered flattened buffer tree\n *\n * The number of buffers appended to this list depends on the schema. For\n * example, most primitive arrays will have 2 buffers, 1 for the validity\n * bitmap and 1 for the values. For struct arrays, there will only be a\n * single buffer for the validity (nulls) bitmap\n */\n buffers(index, obj) {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? (obj || new Buffer()).__init(this.bb.__vector(this.bb_pos + offset) + index * 16, this.bb) : null;\n }\n buffersLength() {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n /**\n * Optional compression of the message body\n */\n compression(obj) {\n const offset = this.bb.__offset(this.bb_pos, 10);\n return offset ? (obj || new BodyCompression()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;\n }\n static startRecordBatch(builder) {\n builder.startObject(4);\n }\n static addLength(builder, length) {\n builder.addFieldInt64(0, length, builder.createLong(0, 0));\n }\n static addNodes(builder, nodesOffset) {\n builder.addFieldOffset(1, nodesOffset, 0);\n }\n static startNodesVector(builder, numElems) {\n builder.startVector(16, numElems, 8);\n }\n static addBuffers(builder, buffersOffset) {\n builder.addFieldOffset(2, buffersOffset, 0);\n }\n static startBuffersVector(builder, numElems) {\n builder.startVector(16, numElems, 8);\n }\n static addCompression(builder, compressionOffset) {\n builder.addFieldOffset(3, compressionOffset, 0);\n }\n static endRecordBatch(builder) {\n const offset = builder.endObject();\n return offset;\n }\n}\n\n//# sourceMappingURL=record-batch.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { RecordBatch } from './record-batch.mjs';\n/**\n * For sending dictionary encoding information. Any Field can be\n * dictionary-encoded, but in this case none of its children may be\n * dictionary-encoded.\n * There is one vector / column per dictionary, but that vector / column\n * may be spread across multiple dictionary batches by using the isDelta\n * flag\n */\nexport class DictionaryBatch {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsDictionaryBatch(bb, obj) {\n return (obj || new DictionaryBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsDictionaryBatch(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new DictionaryBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n id() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);\n }\n data(obj) {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? (obj || new RecordBatch()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;\n }\n /**\n * If isDelta is true the values in the dictionary are to be appended to a\n * dictionary with the indicated id. If isDelta is false this dictionary\n * should replace the existing dictionary.\n */\n isDelta() {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;\n }\n static startDictionaryBatch(builder) {\n builder.startObject(3);\n }\n static addId(builder, id) {\n builder.addFieldInt64(0, id, builder.createLong(0, 0));\n }\n static addData(builder, dataOffset) {\n builder.addFieldOffset(1, dataOffset, 0);\n }\n static addIsDelta(builder, isDelta) {\n builder.addFieldInt8(2, +isDelta, +false);\n }\n static endDictionaryBatch(builder) {\n const offset = builder.endObject();\n return offset;\n }\n}\n\n//# sourceMappingURL=dictionary-batch.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport { DictionaryBatch } from './dictionary-batch.mjs';\nimport { RecordBatch } from './record-batch.mjs';\nimport { Schema } from './schema.mjs';\nimport { SparseTensor } from './sparse-tensor.mjs';\nimport { Tensor } from './tensor.mjs';\n/**\n * ----------------------------------------------------------------------\n * The root Message type\n * This union enables us to easily send different message types without\n * redundant storage, and in the future we can easily add new message types.\n *\n * Arrow implementations do not need to implement all of the message types,\n * which may include experimental metadata types. For maximum compatibility,\n * it is best to send data using RecordBatch\n */\nexport var MessageHeader;\n(function (MessageHeader) {\n MessageHeader[MessageHeader[\"NONE\"] = 0] = \"NONE\";\n MessageHeader[MessageHeader[\"Schema\"] = 1] = \"Schema\";\n MessageHeader[MessageHeader[\"DictionaryBatch\"] = 2] = \"DictionaryBatch\";\n MessageHeader[MessageHeader[\"RecordBatch\"] = 3] = \"RecordBatch\";\n MessageHeader[MessageHeader[\"Tensor\"] = 4] = \"Tensor\";\n MessageHeader[MessageHeader[\"SparseTensor\"] = 5] = \"SparseTensor\";\n})(MessageHeader || (MessageHeader = {}));\nexport function unionToMessageHeader(type, accessor) {\n switch (MessageHeader[type]) {\n case 'NONE': return null;\n case 'Schema': return accessor(new Schema());\n case 'DictionaryBatch': return accessor(new DictionaryBatch());\n case 'RecordBatch': return accessor(new RecordBatch());\n case 'Tensor': return accessor(new Tensor());\n case 'SparseTensor': return accessor(new SparseTensor());\n default: return null;\n }\n}\nexport function unionListToMessageHeader(type, accessor, index) {\n switch (MessageHeader[type]) {\n case 'NONE': return null;\n case 'Schema': return accessor(index, new Schema());\n case 'DictionaryBatch': return accessor(index, new DictionaryBatch());\n case 'RecordBatch': return accessor(index, new RecordBatch());\n case 'Tensor': return accessor(index, new Tensor());\n case 'SparseTensor': return accessor(index, new SparseTensor());\n default: return null;\n }\n}\n\n//# sourceMappingURL=message-header.mjs.map\n","// automatically generated by the FlatBuffers compiler, do not modify\nimport * as flatbuffers from 'flatbuffers';\nimport { KeyValue } from './key-value.mjs';\nimport { MessageHeader } from './message-header.mjs';\nimport { MetadataVersion } from './metadata-version.mjs';\nexport class Message {\n constructor() {\n this.bb = null;\n this.bb_pos = 0;\n }\n __init(i, bb) {\n this.bb_pos = i;\n this.bb = bb;\n return this;\n }\n static getRootAsMessage(bb, obj) {\n return (obj || new Message()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n static getSizePrefixedRootAsMessage(bb, obj) {\n bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);\n return (obj || new Message()).__init(bb.readInt32(bb.position()) + bb.position(), bb);\n }\n version() {\n const offset = this.bb.__offset(this.bb_pos, 4);\n return offset ? this.bb.readInt16(this.bb_pos + offset) : MetadataVersion.V1;\n }\n headerType() {\n const offset = this.bb.__offset(this.bb_pos, 6);\n return offset ? this.bb.readUint8(this.bb_pos + offset) : MessageHeader.NONE;\n }\n // @ts-ignore\n header(obj) {\n const offset = this.bb.__offset(this.bb_pos, 8);\n return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;\n }\n bodyLength() {\n const offset = this.bb.__offset(this.bb_pos, 10);\n return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);\n }\n customMetadata(index, obj) {\n const offset = this.bb.__offset(this.bb_pos, 12);\n return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;\n }\n customMetadataLength() {\n const offset = this.bb.__offset(this.bb_pos, 12);\n return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;\n }\n static startMessage(builder) {\n builder.startObject(5);\n }\n static addVersion(builder, version) {\n builder.addFieldInt16(0, version, MetadataVersion.V1);\n }\n static addHeaderType(builder, headerType) {\n builder.addFieldInt8(1, headerType, MessageHeader.NONE);\n }\n static addHeader(builder, headerOffset) {\n builder.addFieldOffset(2, headerOffset, 0);\n }\n static addBodyLength(builder, bodyLength) {\n builder.addFieldInt64(3, bodyLength, builder.createLong(0, 0));\n }\n static addCustomMetadata(builder, customMetadataOffset) {\n builder.addFieldOffset(4, customMetadataOffset, 0);\n }\n static createCustomMetadataVector(builder, data) {\n builder.startVector(4, data.length, 4);\n for (let i = data.length - 1; i >= 0; i--) {\n builder.addOffset(data[i]);\n }\n return builder.endVector();\n }\n static startCustomMetadataVector(builder, numElems) {\n builder.startVector(4, numElems, 4);\n }\n static endMessage(builder) {\n const offset = builder.endObject();\n return offset;\n }\n static finishMessageBuffer(builder, offset) {\n builder.finish(offset);\n }\n static finishSizePrefixedMessageBuffer(builder, offset) {\n builder.finish(offset, undefined, true);\n }\n static createMessage(builder, version, headerType, headerOffset, bodyLength, customMetadataOffset) {\n Message.startMessage(builder);\n Message.addVersion(builder, version);\n Message.addHeaderType(builder, headerType);\n Message.addHeader(builder, headerOffset);\n Message.addBodyLength(builder, bodyLength);\n Message.addCustomMetadata(builder, customMetadataOffset);\n return Message.endMessage(builder);\n }\n}\n\n//# sourceMappingURL=message.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport * as flatbuffers from 'flatbuffers';\nvar Long = flatbuffers.Long;\nimport { Visitor } from '../visitor.mjs';\nimport { Null } from '../fb/null.mjs';\nimport { Int } from '../fb/int.mjs';\nimport { FloatingPoint } from '../fb/floating-point.mjs';\nimport { Binary } from '../fb/binary.mjs';\nimport { Bool } from '../fb/bool.mjs';\nimport { Utf8 } from '../fb/utf8.mjs';\nimport { Decimal } from '../fb/decimal.mjs';\nimport { Date } from '../fb/date.mjs';\nimport { Time } from '../fb/time.mjs';\nimport { Timestamp } from '../fb/timestamp.mjs';\nimport { Interval } from '../fb/interval.mjs';\nimport { List } from '../fb/list.mjs';\nimport { Struct_ as Struct } from '../fb/struct_.mjs';\nimport { Union } from '../fb/union.mjs';\nimport { DictionaryEncoding } from '../fb/dictionary-encoding.mjs';\nimport { FixedSizeBinary } from '../fb/fixed-size-binary.mjs';\nimport { FixedSizeList } from '../fb/fixed-size-list.mjs';\nimport { Map as Map_ } from '../fb/map.mjs';\n/** @ignore */\nexport class TypeAssembler extends Visitor {\n visit(node, builder) {\n return (node == null || builder == null) ? undefined : super.visit(node, builder);\n }\n visitNull(_node, b) {\n Null.startNull(b);\n return Null.endNull(b);\n }\n visitInt(node, b) {\n Int.startInt(b);\n Int.addBitWidth(b, node.bitWidth);\n Int.addIsSigned(b, node.isSigned);\n return Int.endInt(b);\n }\n visitFloat(node, b) {\n FloatingPoint.startFloatingPoint(b);\n FloatingPoint.addPrecision(b, node.precision);\n return FloatingPoint.endFloatingPoint(b);\n }\n visitBinary(_node, b) {\n Binary.startBinary(b);\n return Binary.endBinary(b);\n }\n visitBool(_node, b) {\n Bool.startBool(b);\n return Bool.endBool(b);\n }\n visitUtf8(_node, b) {\n Utf8.startUtf8(b);\n return Utf8.endUtf8(b);\n }\n visitDecimal(node, b) {\n Decimal.startDecimal(b);\n Decimal.addScale(b, node.scale);\n Decimal.addPrecision(b, node.precision);\n Decimal.addBitWidth(b, node.bitWidth);\n return Decimal.endDecimal(b);\n }\n visitDate(node, b) {\n Date.startDate(b);\n Date.addUnit(b, node.unit);\n return Date.endDate(b);\n }\n visitTime(node, b) {\n Time.startTime(b);\n Time.addUnit(b, node.unit);\n Time.addBitWidth(b, node.bitWidth);\n return Time.endTime(b);\n }\n visitTimestamp(node, b) {\n const timezone = (node.timezone && b.createString(node.timezone)) || undefined;\n Timestamp.startTimestamp(b);\n Timestamp.addUnit(b, node.unit);\n if (timezone !== undefined) {\n Timestamp.addTimezone(b, timezone);\n }\n return Timestamp.endTimestamp(b);\n }\n visitInterval(node, b) {\n Interval.startInterval(b);\n Interval.addUnit(b, node.unit);\n return Interval.endInterval(b);\n }\n visitList(_node, b) {\n List.startList(b);\n return List.endList(b);\n }\n visitStruct(_node, b) {\n Struct.startStruct_(b);\n return Struct.endStruct_(b);\n }\n visitUnion(node, b) {\n Union.startTypeIdsVector(b, node.typeIds.length);\n const typeIds = Union.createTypeIdsVector(b, node.typeIds);\n Union.startUnion(b);\n Union.addMode(b, node.mode);\n Union.addTypeIds(b, typeIds);\n return Union.endUnion(b);\n }\n visitDictionary(node, b) {\n const indexType = this.visit(node.indices, b);\n DictionaryEncoding.startDictionaryEncoding(b);\n DictionaryEncoding.addId(b, new Long(node.id, 0));\n DictionaryEncoding.addIsOrdered(b, node.isOrdered);\n if (indexType !== undefined) {\n DictionaryEncoding.addIndexType(b, indexType);\n }\n return DictionaryEncoding.endDictionaryEncoding(b);\n }\n visitFixedSizeBinary(node, b) {\n FixedSizeBinary.startFixedSizeBinary(b);\n FixedSizeBinary.addByteWidth(b, node.byteWidth);\n return FixedSizeBinary.endFixedSizeBinary(b);\n }\n visitFixedSizeList(node, b) {\n FixedSizeList.startFixedSizeList(b);\n FixedSizeList.addListSize(b, node.listSize);\n return FixedSizeList.endFixedSizeList(b);\n }\n visitMap(node, b) {\n Map_.startMap(b);\n Map_.addKeysSorted(b, node.keysSorted);\n return Map_.endMap(b);\n }\n}\n/** @ignore */\nexport const instance = new TypeAssembler();\n\n//# sourceMappingURL=typeassembler.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\n/* eslint-disable brace-style */\nimport { Schema, Field } from '../../schema.mjs';\nimport { Dictionary, Utf8, Binary, Decimal, FixedSizeBinary, List, FixedSizeList, Map_, Struct, Union, Bool, Null, Int, Float, Date_, Time, Interval, Timestamp, Int32, } from '../../type.mjs';\nimport { DictionaryBatch, RecordBatch, FieldNode, BufferRegion } from './message.mjs';\nimport { TimeUnit, Precision, IntervalUnit, UnionMode, DateUnit } from '../../enum.mjs';\n/** @ignore */\nexport function schemaFromJSON(_schema, dictionaries = new Map()) {\n return new Schema(schemaFieldsFromJSON(_schema, dictionaries), customMetadataFromJSON(_schema['customMetadata']), dictionaries);\n}\n/** @ignore */\nexport function recordBatchFromJSON(b) {\n return new RecordBatch(b['count'], fieldNodesFromJSON(b['columns']), buffersFromJSON(b['columns']));\n}\n/** @ignore */\nexport function dictionaryBatchFromJSON(b) {\n return new DictionaryBatch(recordBatchFromJSON(b['data']), b['id'], b['isDelta']);\n}\n/** @ignore */\nfunction schemaFieldsFromJSON(_schema, dictionaries) {\n return (_schema['fields'] || []).filter(Boolean).map((f) => Field.fromJSON(f, dictionaries));\n}\n/** @ignore */\nfunction fieldChildrenFromJSON(_field, dictionaries) {\n return (_field['children'] || []).filter(Boolean).map((f) => Field.fromJSON(f, dictionaries));\n}\n/** @ignore */\nfunction fieldNodesFromJSON(xs) {\n return (xs || []).reduce((fieldNodes, column) => [\n ...fieldNodes,\n new FieldNode(column['count'], nullCountFromJSON(column['VALIDITY'])),\n ...fieldNodesFromJSON(column['children'])\n ], []);\n}\n/** @ignore */\nfunction buffersFromJSON(xs, buffers = []) {\n for (let i = -1, n = (xs || []).length; ++i < n;) {\n const column = xs[i];\n column['VALIDITY'] && buffers.push(new BufferRegion(buffers.length, column['VALIDITY'].length));\n column['TYPE'] && buffers.push(new BufferRegion(buffers.length, column['TYPE'].length));\n column['OFFSET'] && buffers.push(new BufferRegion(buffers.length, column['OFFSET'].length));\n column['DATA'] && buffers.push(new BufferRegion(buffers.length, column['DATA'].length));\n buffers = buffersFromJSON(column['children'], buffers);\n }\n return buffers;\n}\n/** @ignore */\nfunction nullCountFromJSON(validity) {\n return (validity || []).reduce((sum, val) => sum + +(val === 0), 0);\n}\n/** @ignore */\nexport function fieldFromJSON(_field, dictionaries) {\n let id;\n let keys;\n let field;\n let dictMeta;\n let type;\n let dictType;\n // If no dictionary encoding\n if (!dictionaries || !(dictMeta = _field['dictionary'])) {\n type = typeFromJSON(_field, fieldChildrenFromJSON(_field, dictionaries));\n field = new Field(_field['name'], type, _field['nullable'], customMetadataFromJSON(_field['customMetadata']));\n }\n // If dictionary encoded and the first time we've seen this dictionary id, decode\n // the data type and child fields, then wrap in a Dictionary type and insert the\n // data type into the dictionary types map.\n else if (!dictionaries.has(id = dictMeta['id'])) {\n // a dictionary index defaults to signed 32 bit int if unspecified\n keys = (keys = dictMeta['indexType']) ? indexTypeFromJSON(keys) : new Int32();\n dictionaries.set(id, type = typeFromJSON(_field, fieldChildrenFromJSON(_field, dictionaries)));\n dictType = new Dictionary(type, keys, id, dictMeta['isOrdered']);\n field = new Field(_field['name'], dictType, _field['nullable'], customMetadataFromJSON(_field['customMetadata']));\n }\n // If dictionary encoded, and have already seen this dictionary Id in the schema, then reuse the\n // data type and wrap in a new Dictionary type and field.\n else {\n // a dictionary index defaults to signed 32 bit int if unspecified\n keys = (keys = dictMeta['indexType']) ? indexTypeFromJSON(keys) : new Int32();\n dictType = new Dictionary(dictionaries.get(id), keys, id, dictMeta['isOrdered']);\n field = new Field(_field['name'], dictType, _field['nullable'], customMetadataFromJSON(_field['customMetadata']));\n }\n return field || null;\n}\n/** @ignore */\nfunction customMetadataFromJSON(_metadata) {\n return new Map(Object.entries(_metadata || {}));\n}\n/** @ignore */\nfunction indexTypeFromJSON(_type) {\n return new Int(_type['isSigned'], _type['bitWidth']);\n}\n/** @ignore */\nfunction typeFromJSON(f, children) {\n const typeId = f['type']['name'];\n switch (typeId) {\n case 'NONE': return new Null();\n case 'null': return new Null();\n case 'binary': return new Binary();\n case 'utf8': return new Utf8();\n case 'bool': return new Bool();\n case 'list': return new List((children || [])[0]);\n case 'struct': return new Struct(children || []);\n case 'struct_': return new Struct(children || []);\n }\n switch (typeId) {\n case 'int': {\n const t = f['type'];\n return new Int(t['isSigned'], t['bitWidth']);\n }\n case 'floatingpoint': {\n const t = f['type'];\n return new Float(Precision[t['precision']]);\n }\n case 'decimal': {\n const t = f['type'];\n return new Decimal(t['scale'], t['precision'], t['bitWidth']);\n }\n case 'date': {\n const t = f['type'];\n return new Date_(DateUnit[t['unit']]);\n }\n case 'time': {\n const t = f['type'];\n return new Time(TimeUnit[t['unit']], t['bitWidth']);\n }\n case 'timestamp': {\n const t = f['type'];\n return new Timestamp(TimeUnit[t['unit']], t['timezone']);\n }\n case 'interval': {\n const t = f['type'];\n return new Interval(IntervalUnit[t['unit']]);\n }\n case 'union': {\n const t = f['type'];\n return new Union(UnionMode[t['mode']], (t['typeIds'] || []), children || []);\n }\n case 'fixedsizebinary': {\n const t = f['type'];\n return new FixedSizeBinary(t['byteWidth']);\n }\n case 'fixedsizelist': {\n const t = f['type'];\n return new FixedSizeList(t['listSize'], (children || [])[0]);\n }\n case 'map': {\n const t = f['type'];\n return new Map_((children || [])[0], t['keysSorted']);\n }\n }\n throw new Error(`Unrecognized type: \"${typeId}\"`);\n}\n\n//# sourceMappingURL=json.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\n/* eslint-disable brace-style */\nimport * as flatbuffers from 'flatbuffers';\nimport { Schema as _Schema } from '../../fb/schema.mjs';\nimport { Int as _Int } from '../../fb/int.mjs';\nimport { RecordBatch as _RecordBatch } from '../../fb/record-batch.mjs';\nimport { DictionaryBatch as _DictionaryBatch } from '../../fb/dictionary-batch.mjs';\nimport { Buffer as _Buffer } from '../../fb/buffer.mjs';\nimport { Field as _Field } from '../../fb/field.mjs';\nimport { FieldNode as _FieldNode } from '../../fb/field-node.mjs';\nimport { Type } from '../../fb/type.mjs';\nimport { KeyValue as _KeyValue } from '../../fb/key-value.mjs';\nimport { Endianness as _Endianness } from '../../fb/endianness.mjs';\nimport { FloatingPoint as _FloatingPoint } from '../../fb/floating-point.mjs';\nimport { Decimal as _Decimal } from '../../fb/decimal.mjs';\nimport { Date as _Date } from '../../fb/date.mjs';\nimport { Time as _Time } from '../../fb/time.mjs';\nimport { Timestamp as _Timestamp } from '../../fb/timestamp.mjs';\nimport { Interval as _Interval } from '../../fb/interval.mjs';\nimport { Union as _Union } from '../../fb/union.mjs';\nimport { FixedSizeBinary as _FixedSizeBinary } from '../../fb/fixed-size-binary.mjs';\nimport { FixedSizeList as _FixedSizeList } from '../../fb/fixed-size-list.mjs';\nimport { Map as _Map } from '../../fb/map.mjs';\nimport { Message as _Message } from '../../fb/message.mjs';\nimport { Schema, Field } from '../../schema.mjs';\nimport { toUint8Array } from '../../util/buffer.mjs';\nimport { MessageHeader, MetadataVersion } from '../../enum.mjs';\nimport { instance as typeAssembler } from '../../visitor/typeassembler.mjs';\nimport { fieldFromJSON, schemaFromJSON, recordBatchFromJSON, dictionaryBatchFromJSON } from './json.mjs';\nvar Long = flatbuffers.Long;\nvar Builder = flatbuffers.Builder;\nvar ByteBuffer = flatbuffers.ByteBuffer;\nimport { DataType, Dictionary, Utf8, Binary, Decimal, FixedSizeBinary, List, FixedSizeList, Map_, Struct, Union, Bool, Null, Int, Float, Date_, Time, Interval, Timestamp, Int32, } from '../../type.mjs';\n/**\n * @ignore\n * @private\n **/\nexport class Message {\n constructor(bodyLength, version, headerType, header) {\n this._version = version;\n this._headerType = headerType;\n this.body = new Uint8Array(0);\n header && (this._createHeader = () => header);\n this._bodyLength = typeof bodyLength === 'number' ? bodyLength : bodyLength.low;\n }\n /** @nocollapse */\n static fromJSON(msg, headerType) {\n const message = new Message(0, MetadataVersion.V4, headerType);\n message._createHeader = messageHeaderFromJSON(msg, headerType);\n return message;\n }\n /** @nocollapse */\n static decode(buf) {\n buf = new ByteBuffer(toUint8Array(buf));\n const _message = _Message.getRootAsMessage(buf);\n const bodyLength = _message.bodyLength();\n const version = _message.version();\n const headerType = _message.headerType();\n const message = new Message(bodyLength, version, headerType);\n message._createHeader = decodeMessageHeader(_message, headerType);\n return message;\n }\n /** @nocollapse */\n static encode(message) {\n const b = new Builder();\n let headerOffset = -1;\n if (message.isSchema()) {\n headerOffset = Schema.encode(b, message.header());\n }\n else if (message.isRecordBatch()) {\n headerOffset = RecordBatch.encode(b, message.header());\n }\n else if (message.isDictionaryBatch()) {\n headerOffset = DictionaryBatch.encode(b, message.header());\n }\n _Message.startMessage(b);\n _Message.addVersion(b, MetadataVersion.V4);\n _Message.addHeader(b, headerOffset);\n _Message.addHeaderType(b, message.headerType);\n _Message.addBodyLength(b, new Long(message.bodyLength, 0));\n _Message.finishMessageBuffer(b, _Message.endMessage(b));\n return b.asUint8Array();\n }\n /** @nocollapse */\n static from(header, bodyLength = 0) {\n if (header instanceof Schema) {\n return new Message(0, MetadataVersion.V4, MessageHeader.Schema, header);\n }\n if (header instanceof RecordBatch) {\n return new Message(bodyLength, MetadataVersion.V4, MessageHeader.RecordBatch, header);\n }\n if (header instanceof DictionaryBatch) {\n return new Message(bodyLength, MetadataVersion.V4, MessageHeader.DictionaryBatch, header);\n }\n throw new Error(`Unrecognized Message header: ${header}`);\n }\n get type() { return this.headerType; }\n get version() { return this._version; }\n get headerType() { return this._headerType; }\n get bodyLength() { return this._bodyLength; }\n header() { return this._createHeader(); }\n isSchema() { return this.headerType === MessageHeader.Schema; }\n isRecordBatch() { return this.headerType === MessageHeader.RecordBatch; }\n isDictionaryBatch() { return this.headerType === MessageHeader.DictionaryBatch; }\n}\n/**\n * @ignore\n * @private\n **/\nexport class RecordBatch {\n constructor(length, nodes, buffers) {\n this._nodes = nodes;\n this._buffers = buffers;\n this._length = typeof length === 'number' ? length : length.low;\n }\n get nodes() { return this._nodes; }\n get length() { return this._length; }\n get buffers() { return this._buffers; }\n}\n/**\n * @ignore\n * @private\n **/\nexport class DictionaryBatch {\n constructor(data, id, isDelta = false) {\n this._data = data;\n this._isDelta = isDelta;\n this._id = typeof id === 'number' ? id : id.low;\n }\n get id() { return this._id; }\n get data() { return this._data; }\n get isDelta() { return this._isDelta; }\n get length() { return this.data.length; }\n get nodes() { return this.data.nodes; }\n get buffers() { return this.data.buffers; }\n}\n/**\n * @ignore\n * @private\n **/\nexport class BufferRegion {\n constructor(offset, length) {\n this.offset = typeof offset === 'number' ? offset : offset.low;\n this.length = typeof length === 'number' ? length : length.low;\n }\n}\n/**\n * @ignore\n * @private\n **/\nexport class FieldNode {\n constructor(length, nullCount) {\n this.length = typeof length === 'number' ? length : length.low;\n this.nullCount = typeof nullCount === 'number' ? nullCount : nullCount.low;\n }\n}\n/** @ignore */\nfunction messageHeaderFromJSON(message, type) {\n return (() => {\n switch (type) {\n case MessageHeader.Schema: return Schema.fromJSON(message);\n case MessageHeader.RecordBatch: return RecordBatch.fromJSON(message);\n case MessageHeader.DictionaryBatch: return DictionaryBatch.fromJSON(message);\n }\n throw new Error(`Unrecognized Message type: { name: ${MessageHeader[type]}, type: ${type} }`);\n });\n}\n/** @ignore */\nfunction decodeMessageHeader(message, type) {\n return (() => {\n switch (type) {\n case MessageHeader.Schema: return Schema.decode(message.header(new _Schema()));\n case MessageHeader.RecordBatch: return RecordBatch.decode(message.header(new _RecordBatch()), message.version());\n case MessageHeader.DictionaryBatch: return DictionaryBatch.decode(message.header(new _DictionaryBatch()), message.version());\n }\n throw new Error(`Unrecognized Message type: { name: ${MessageHeader[type]}, type: ${type} }`);\n });\n}\nField['encode'] = encodeField;\nField['decode'] = decodeField;\nField['fromJSON'] = fieldFromJSON;\nSchema['encode'] = encodeSchema;\nSchema['decode'] = decodeSchema;\nSchema['fromJSON'] = schemaFromJSON;\nRecordBatch['encode'] = encodeRecordBatch;\nRecordBatch['decode'] = decodeRecordBatch;\nRecordBatch['fromJSON'] = recordBatchFromJSON;\nDictionaryBatch['encode'] = encodeDictionaryBatch;\nDictionaryBatch['decode'] = decodeDictionaryBatch;\nDictionaryBatch['fromJSON'] = dictionaryBatchFromJSON;\nFieldNode['encode'] = encodeFieldNode;\nFieldNode['decode'] = decodeFieldNode;\nBufferRegion['encode'] = encodeBufferRegion;\nBufferRegion['decode'] = decodeBufferRegion;\n/** @ignore */\nfunction decodeSchema(_schema, dictionaries = new Map()) {\n const fields = decodeSchemaFields(_schema, dictionaries);\n return new Schema(fields, decodeCustomMetadata(_schema), dictionaries);\n}\n/** @ignore */\nfunction decodeRecordBatch(batch, version = MetadataVersion.V4) {\n if (batch.compression() !== null) {\n throw new Error('Record batch compression not implemented');\n }\n return new RecordBatch(batch.length(), decodeFieldNodes(batch), decodeBuffers(batch, version));\n}\n/** @ignore */\nfunction decodeDictionaryBatch(batch, version = MetadataVersion.V4) {\n return new DictionaryBatch(RecordBatch.decode(batch.data(), version), batch.id(), batch.isDelta());\n}\n/** @ignore */\nfunction decodeBufferRegion(b) {\n return new BufferRegion(b.offset(), b.length());\n}\n/** @ignore */\nfunction decodeFieldNode(f) {\n return new FieldNode(f.length(), f.nullCount());\n}\n/** @ignore */\nfunction decodeFieldNodes(batch) {\n const nodes = [];\n for (let f, i = -1, j = -1, n = batch.nodesLength(); ++i < n;) {\n if (f = batch.nodes(i)) {\n nodes[++j] = FieldNode.decode(f);\n }\n }\n return nodes;\n}\n/** @ignore */\nfunction decodeBuffers(batch, version) {\n const bufferRegions = [];\n for (let b, i = -1, j = -1, n = batch.buffersLength(); ++i < n;) {\n if (b = batch.buffers(i)) {\n // If this Arrow buffer was written before version 4,\n // advance the buffer's bb_pos 8 bytes to skip past\n // the now-removed page_id field\n if (version < MetadataVersion.V4) {\n b.bb_pos += (8 * (i + 1));\n }\n bufferRegions[++j] = BufferRegion.decode(b);\n }\n }\n return bufferRegions;\n}\n/** @ignore */\nfunction decodeSchemaFields(schema, dictionaries) {\n const fields = [];\n for (let f, i = -1, j = -1, n = schema.fieldsLength(); ++i < n;) {\n if (f = schema.fields(i)) {\n fields[++j] = Field.decode(f, dictionaries);\n }\n }\n return fields;\n}\n/** @ignore */\nfunction decodeFieldChildren(field, dictionaries) {\n const children = [];\n for (let f, i = -1, j = -1, n = field.childrenLength(); ++i < n;) {\n if (f = field.children(i)) {\n children[++j] = Field.decode(f, dictionaries);\n }\n }\n return children;\n}\n/** @ignore */\nfunction decodeField(f, dictionaries) {\n let id;\n let field;\n let type;\n let keys;\n let dictType;\n let dictMeta;\n // If no dictionary encoding\n if (!dictionaries || !(dictMeta = f.dictionary())) {\n type = decodeFieldType(f, decodeFieldChildren(f, dictionaries));\n field = new Field(f.name(), type, f.nullable(), decodeCustomMetadata(f));\n }\n // If dictionary encoded and the first time we've seen this dictionary id, decode\n // the data type and child fields, then wrap in a Dictionary type and insert the\n // data type into the dictionary types map.\n else if (!dictionaries.has(id = dictMeta.id().low)) {\n // a dictionary index defaults to signed 32 bit int if unspecified\n keys = (keys = dictMeta.indexType()) ? decodeIndexType(keys) : new Int32();\n dictionaries.set(id, type = decodeFieldType(f, decodeFieldChildren(f, dictionaries)));\n dictType = new Dictionary(type, keys, id, dictMeta.isOrdered());\n field = new Field(f.name(), dictType, f.nullable(), decodeCustomMetadata(f));\n }\n // If dictionary encoded, and have already seen this dictionary Id in the schema, then reuse the\n // data type and wrap in a new Dictionary type and field.\n else {\n // a dictionary index defaults to signed 32 bit int if unspecified\n keys = (keys = dictMeta.indexType()) ? decodeIndexType(keys) : new Int32();\n dictType = new Dictionary(dictionaries.get(id), keys, id, dictMeta.isOrdered());\n field = new Field(f.name(), dictType, f.nullable(), decodeCustomMetadata(f));\n }\n return field || null;\n}\n/** @ignore */\nfunction decodeCustomMetadata(parent) {\n const data = new Map();\n if (parent) {\n for (let entry, key, i = -1, n = Math.trunc(parent.customMetadataLength()); ++i < n;) {\n if ((entry = parent.customMetadata(i)) && (key = entry.key()) != null) {\n data.set(key, entry.value());\n }\n }\n }\n return data;\n}\n/** @ignore */\nfunction decodeIndexType(_type) {\n return new Int(_type.isSigned(), _type.bitWidth());\n}\n/** @ignore */\nfunction decodeFieldType(f, children) {\n const typeId = f.typeType();\n switch (typeId) {\n case Type['NONE']: return new Null();\n case Type['Null']: return new Null();\n case Type['Binary']: return new Binary();\n case Type['Utf8']: return new Utf8();\n case Type['Bool']: return new Bool();\n case Type['List']: return new List((children || [])[0]);\n case Type['Struct_']: return new Struct(children || []);\n }\n switch (typeId) {\n case Type['Int']: {\n const t = f.type(new _Int());\n return new Int(t.isSigned(), t.bitWidth());\n }\n case Type['FloatingPoint']: {\n const t = f.type(new _FloatingPoint());\n return new Float(t.precision());\n }\n case Type['Decimal']: {\n const t = f.type(new _Decimal());\n return new Decimal(t.scale(), t.precision(), t.bitWidth());\n }\n case Type['Date']: {\n const t = f.type(new _Date());\n return new Date_(t.unit());\n }\n case Type['Time']: {\n const t = f.type(new _Time());\n return new Time(t.unit(), t.bitWidth());\n }\n case Type['Timestamp']: {\n const t = f.type(new _Timestamp());\n return new Timestamp(t.unit(), t.timezone());\n }\n case Type['Interval']: {\n const t = f.type(new _Interval());\n return new Interval(t.unit());\n }\n case Type['Union']: {\n const t = f.type(new _Union());\n return new Union(t.mode(), t.typeIdsArray() || [], children || []);\n }\n case Type['FixedSizeBinary']: {\n const t = f.type(new _FixedSizeBinary());\n return new FixedSizeBinary(t.byteWidth());\n }\n case Type['FixedSizeList']: {\n const t = f.type(new _FixedSizeList());\n return new FixedSizeList(t.listSize(), (children || [])[0]);\n }\n case Type['Map']: {\n const t = f.type(new _Map());\n return new Map_((children || [])[0], t.keysSorted());\n }\n }\n throw new Error(`Unrecognized type: \"${Type[typeId]}\" (${typeId})`);\n}\n/** @ignore */\nfunction encodeSchema(b, schema) {\n const fieldOffsets = schema.fields.map((f) => Field.encode(b, f));\n _Schema.startFieldsVector(b, fieldOffsets.length);\n const fieldsVectorOffset = _Schema.createFieldsVector(b, fieldOffsets);\n const metadataOffset = !(schema.metadata && schema.metadata.size > 0) ? -1 :\n _Schema.createCustomMetadataVector(b, [...schema.metadata].map(([k, v]) => {\n const key = b.createString(`${k}`);\n const val = b.createString(`${v}`);\n _KeyValue.startKeyValue(b);\n _KeyValue.addKey(b, key);\n _KeyValue.addValue(b, val);\n return _KeyValue.endKeyValue(b);\n }));\n _Schema.startSchema(b);\n _Schema.addFields(b, fieldsVectorOffset);\n _Schema.addEndianness(b, platformIsLittleEndian ? _Endianness.Little : _Endianness.Big);\n if (metadataOffset !== -1) {\n _Schema.addCustomMetadata(b, metadataOffset);\n }\n return _Schema.endSchema(b);\n}\n/** @ignore */\nfunction encodeField(b, field) {\n let nameOffset = -1;\n let typeOffset = -1;\n let dictionaryOffset = -1;\n const type = field.type;\n let typeId = field.typeId;\n if (!DataType.isDictionary(type)) {\n typeOffset = typeAssembler.visit(type, b);\n }\n else {\n typeId = type.dictionary.typeId;\n dictionaryOffset = typeAssembler.visit(type, b);\n typeOffset = typeAssembler.visit(type.dictionary, b);\n }\n const childOffsets = (type.children || []).map((f) => Field.encode(b, f));\n const childrenVectorOffset = _Field.createChildrenVector(b, childOffsets);\n const metadataOffset = !(field.metadata && field.metadata.size > 0) ? -1 :\n _Field.createCustomMetadataVector(b, [...field.metadata].map(([k, v]) => {\n const key = b.createString(`${k}`);\n const val = b.createString(`${v}`);\n _KeyValue.startKeyValue(b);\n _KeyValue.addKey(b, key);\n _KeyValue.addValue(b, val);\n return _KeyValue.endKeyValue(b);\n }));\n if (field.name) {\n nameOffset = b.createString(field.name);\n }\n _Field.startField(b);\n _Field.addType(b, typeOffset);\n _Field.addTypeType(b, typeId);\n _Field.addChildren(b, childrenVectorOffset);\n _Field.addNullable(b, !!field.nullable);\n if (nameOffset !== -1) {\n _Field.addName(b, nameOffset);\n }\n if (dictionaryOffset !== -1) {\n _Field.addDictionary(b, dictionaryOffset);\n }\n if (metadataOffset !== -1) {\n _Field.addCustomMetadata(b, metadataOffset);\n }\n return _Field.endField(b);\n}\n/** @ignore */\nfunction encodeRecordBatch(b, recordBatch) {\n const nodes = recordBatch.nodes || [];\n const buffers = recordBatch.buffers || [];\n _RecordBatch.startNodesVector(b, nodes.length);\n for (const n of nodes.slice().reverse())\n FieldNode.encode(b, n);\n const nodesVectorOffset = b.endVector();\n _RecordBatch.startBuffersVector(b, buffers.length);\n for (const b_ of buffers.slice().reverse())\n BufferRegion.encode(b, b_);\n const buffersVectorOffset = b.endVector();\n _RecordBatch.startRecordBatch(b);\n _RecordBatch.addLength(b, new Long(recordBatch.length, 0));\n _RecordBatch.addNodes(b, nodesVectorOffset);\n _RecordBatch.addBuffers(b, buffersVectorOffset);\n return _RecordBatch.endRecordBatch(b);\n}\n/** @ignore */\nfunction encodeDictionaryBatch(b, dictionaryBatch) {\n const dataOffset = RecordBatch.encode(b, dictionaryBatch.data);\n _DictionaryBatch.startDictionaryBatch(b);\n _DictionaryBatch.addId(b, new Long(dictionaryBatch.id, 0));\n _DictionaryBatch.addIsDelta(b, dictionaryBatch.isDelta);\n _DictionaryBatch.addData(b, dataOffset);\n return _DictionaryBatch.endDictionaryBatch(b);\n}\n/** @ignore */\nfunction encodeFieldNode(b, node) {\n return _FieldNode.createFieldNode(b, new Long(node.length, 0), new Long(node.nullCount, 0));\n}\n/** @ignore */\nfunction encodeBufferRegion(b, node) {\n return _Buffer.createBuffer(b, new Long(node.offset, 0), new Long(node.length, 0));\n}\n/** @ignore */\nconst platformIsLittleEndian = (() => {\n const buffer = new ArrayBuffer(2);\n new DataView(buffer).setInt16(0, 256, true /* littleEndian */);\n // Int16Array uses the platform's endianness.\n return new Int16Array(buffer)[0] === 256;\n})();\n\n//# sourceMappingURL=message.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { __awaiter } from \"tslib\";\nimport { MessageHeader } from '../enum.mjs';\nimport { ByteBuffer } from 'flatbuffers';\nimport { Message } from './metadata/message.mjs';\nimport { isFileHandle } from '../util/compat.mjs';\nimport { AsyncRandomAccessFile } from '../io/file.mjs';\nimport { toUint8Array } from '../util/buffer.mjs';\nimport { ByteStream, AsyncByteStream } from '../io/stream.mjs';\nimport { ArrowJSON, ITERATOR_DONE } from '../io/interfaces.mjs';\n/** @ignore */ const invalidMessageType = (type) => `Expected ${MessageHeader[type]} Message in stream, but was null or length 0.`;\n/** @ignore */ const nullMessage = (type) => `Header pointer of flatbuffer-encoded ${MessageHeader[type]} Message is null or length 0.`;\n/** @ignore */ const invalidMessageMetadata = (expected, actual) => `Expected to read ${expected} metadata bytes, but only read ${actual}.`;\n/** @ignore */ const invalidMessageBodyLength = (expected, actual) => `Expected to read ${expected} bytes for message body, but only read ${actual}.`;\n/** @ignore */\nexport class MessageReader {\n constructor(source) {\n this.source = source instanceof ByteStream ? source : new ByteStream(source);\n }\n [Symbol.iterator]() { return this; }\n next() {\n let r;\n if ((r = this.readMetadataLength()).done) {\n return ITERATOR_DONE;\n }\n // ARROW-6313: If the first 4 bytes are continuation indicator (-1), read\n // the next 4 for the 32-bit metadata length. Otherwise, assume this is a\n // pre-v0.15 message, where the first 4 bytes are the metadata length.\n if ((r.value === -1) &&\n (r = this.readMetadataLength()).done) {\n return ITERATOR_DONE;\n }\n if ((r = this.readMetadata(r.value)).done) {\n return ITERATOR_DONE;\n }\n return r;\n }\n throw(value) { return this.source.throw(value); }\n return(value) { return this.source.return(value); }\n readMessage(type) {\n let r;\n if ((r = this.next()).done) {\n return null;\n }\n if ((type != null) && r.value.headerType !== type) {\n throw new Error(invalidMessageType(type));\n }\n return r.value;\n }\n readMessageBody(bodyLength) {\n if (bodyLength <= 0) {\n return new Uint8Array(0);\n }\n const buf = toUint8Array(this.source.read(bodyLength));\n if (buf.byteLength < bodyLength) {\n throw new Error(invalidMessageBodyLength(bodyLength, buf.byteLength));\n }\n // 1. Work around bugs in fs.ReadStream's internal Buffer pooling, see: https://github.com/nodejs/node/issues/24817\n // 2. Work around https://github.com/whatwg/streams/blob/0ebe4b042e467d9876d80ae045de3843092ad797/reference-implementation/lib/helpers.js#L126\n return /* 1. */ (buf.byteOffset % 8 === 0) &&\n /* 2. */ (buf.byteOffset + buf.byteLength) <= buf.buffer.byteLength ? buf : buf.slice();\n }\n readSchema(throwIfNull = false) {\n const type = MessageHeader.Schema;\n const message = this.readMessage(type);\n const schema = message === null || message === void 0 ? void 0 : message.header();\n if (throwIfNull && !schema) {\n throw new Error(nullMessage(type));\n }\n return schema;\n }\n readMetadataLength() {\n const buf = this.source.read(PADDING);\n const bb = buf && new ByteBuffer(buf);\n const len = (bb === null || bb === void 0 ? void 0 : bb.readInt32(0)) || 0;\n return { done: len === 0, value: len };\n }\n readMetadata(metadataLength) {\n const buf = this.source.read(metadataLength);\n if (!buf) {\n return ITERATOR_DONE;\n }\n if (buf.byteLength < metadataLength) {\n throw new Error(invalidMessageMetadata(metadataLength, buf.byteLength));\n }\n return { done: false, value: Message.decode(buf) };\n }\n}\n/** @ignore */\nexport class AsyncMessageReader {\n constructor(source, byteLength) {\n this.source = source instanceof AsyncByteStream ? source\n : isFileHandle(source)\n ? new AsyncRandomAccessFile(source, byteLength)\n : new AsyncByteStream(source);\n }\n [Symbol.asyncIterator]() { return this; }\n next() {\n return __awaiter(this, void 0, void 0, function* () {\n let r;\n if ((r = yield this.readMetadataLength()).done) {\n return ITERATOR_DONE;\n }\n // ARROW-6313: If the first 4 bytes are continuation indicator (-1), read\n // the next 4 for the 32-bit metadata length. Otherwise, assume this is a\n // pre-v0.15 message, where the first 4 bytes are the metadata length.\n if ((r.value === -1) &&\n (r = yield this.readMetadataLength()).done) {\n return ITERATOR_DONE;\n }\n if ((r = yield this.readMetadata(r.value)).done) {\n return ITERATOR_DONE;\n }\n return r;\n });\n }\n throw(value) {\n return __awaiter(this, void 0, void 0, function* () { return yield this.source.throw(value); });\n }\n return(value) {\n return __awaiter(this, void 0, void 0, function* () { return yield this.source.return(value); });\n }\n readMessage(type) {\n return __awaiter(this, void 0, void 0, function* () {\n let r;\n if ((r = yield this.next()).done) {\n return null;\n }\n if ((type != null) && r.value.headerType !== type) {\n throw new Error(invalidMessageType(type));\n }\n return r.value;\n });\n }\n readMessageBody(bodyLength) {\n return __awaiter(this, void 0, void 0, function* () {\n if (bodyLength <= 0) {\n return new Uint8Array(0);\n }\n const buf = toUint8Array(yield this.source.read(bodyLength));\n if (buf.byteLength < bodyLength) {\n throw new Error(invalidMessageBodyLength(bodyLength, buf.byteLength));\n }\n // 1. Work around bugs in fs.ReadStream's internal Buffer pooling, see: https://github.com/nodejs/node/issues/24817\n // 2. Work around https://github.com/whatwg/streams/blob/0ebe4b042e467d9876d80ae045de3843092ad797/reference-implementation/lib/helpers.js#L126\n return /* 1. */ (buf.byteOffset % 8 === 0) &&\n /* 2. */ (buf.byteOffset + buf.byteLength) <= buf.buffer.byteLength ? buf : buf.slice();\n });\n }\n readSchema(throwIfNull = false) {\n return __awaiter(this, void 0, void 0, function* () {\n const type = MessageHeader.Schema;\n const message = yield this.readMessage(type);\n const schema = message === null || message === void 0 ? void 0 : message.header();\n if (throwIfNull && !schema) {\n throw new Error(nullMessage(type));\n }\n return schema;\n });\n }\n readMetadataLength() {\n return __awaiter(this, void 0, void 0, function* () {\n const buf = yield this.source.read(PADDING);\n const bb = buf && new ByteBuffer(buf);\n const len = (bb === null || bb === void 0 ? void 0 : bb.readInt32(0)) || 0;\n return { done: len === 0, value: len };\n });\n }\n readMetadata(metadataLength) {\n return __awaiter(this, void 0, void 0, function* () {\n const buf = yield this.source.read(metadataLength);\n if (!buf) {\n return ITERATOR_DONE;\n }\n if (buf.byteLength < metadataLength) {\n throw new Error(invalidMessageMetadata(metadataLength, buf.byteLength));\n }\n return { done: false, value: Message.decode(buf) };\n });\n }\n}\n/** @ignore */\nexport class JSONMessageReader extends MessageReader {\n constructor(source) {\n super(new Uint8Array(0));\n this._schema = false;\n this._body = [];\n this._batchIndex = 0;\n this._dictionaryIndex = 0;\n this._json = source instanceof ArrowJSON ? source : new ArrowJSON(source);\n }\n next() {\n const { _json } = this;\n if (!this._schema) {\n this._schema = true;\n const message = Message.fromJSON(_json.schema, MessageHeader.Schema);\n return { done: false, value: message };\n }\n if (this._dictionaryIndex < _json.dictionaries.length) {\n const batch = _json.dictionaries[this._dictionaryIndex++];\n this._body = batch['data']['columns'];\n const message = Message.fromJSON(batch, MessageHeader.DictionaryBatch);\n return { done: false, value: message };\n }\n if (this._batchIndex < _json.batches.length) {\n const batch = _json.batches[this._batchIndex++];\n this._body = batch['columns'];\n const message = Message.fromJSON(batch, MessageHeader.RecordBatch);\n return { done: false, value: message };\n }\n this._body = [];\n return ITERATOR_DONE;\n }\n readMessageBody(_bodyLength) {\n return flattenDataSources(this._body);\n function flattenDataSources(xs) {\n return (xs || []).reduce((buffers, column) => [\n ...buffers,\n ...(column['VALIDITY'] && [column['VALIDITY']] || []),\n ...(column['TYPE'] && [column['TYPE']] || []),\n ...(column['OFFSET'] && [column['OFFSET']] || []),\n ...(column['DATA'] && [column['DATA']] || []),\n ...flattenDataSources(column['children'])\n ], []);\n }\n }\n readMessage(type) {\n let r;\n if ((r = this.next()).done) {\n return null;\n }\n if ((type != null) && r.value.headerType !== type) {\n throw new Error(invalidMessageType(type));\n }\n return r.value;\n }\n readSchema() {\n const type = MessageHeader.Schema;\n const message = this.readMessage(type);\n const schema = message === null || message === void 0 ? void 0 : message.header();\n if (!message || !schema) {\n throw new Error(nullMessage(type));\n }\n return schema;\n }\n}\n/** @ignore */\nexport const PADDING = 4;\n/** @ignore */\nexport const MAGIC_STR = 'ARROW1';\n/** @ignore */\nexport const MAGIC = new Uint8Array(MAGIC_STR.length);\nfor (let i = 0; i < MAGIC_STR.length; i += 1) {\n MAGIC[i] = MAGIC_STR.codePointAt(i);\n}\n/** @ignore */\nexport function checkForMagicArrowString(buffer, index = 0) {\n for (let i = -1, n = MAGIC.length; ++i < n;) {\n if (MAGIC[i] !== buffer[index + i]) {\n return false;\n }\n }\n return true;\n}\n/** @ignore */\nexport const magicLength = MAGIC.length;\n/** @ignore */\nexport const magicAndPadding = magicLength + PADDING;\n/** @ignore */\nexport const magicX2AndPadding = magicLength * 2 + PADDING;\n\n//# sourceMappingURL=message.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Vector } from '../vector.mjs';\nimport { Visitor } from '../visitor.mjs';\nimport { UnionMode } from '../enum.mjs';\nimport { RecordBatch } from '../recordbatch.mjs';\nimport { rebaseValueOffsets } from '../util/buffer.mjs';\nimport { packBools, truncateBitmap } from '../util/bit.mjs';\nimport { BufferRegion, FieldNode } from '../ipc/metadata/message.mjs';\nimport { DataType, } from '../type.mjs';\n/** @ignore */\nexport class VectorAssembler extends Visitor {\n constructor() {\n super();\n this._byteLength = 0;\n this._nodes = [];\n this._buffers = [];\n this._bufferRegions = [];\n }\n /** @nocollapse */\n static assemble(...args) {\n const unwrap = (nodes) => nodes.flatMap((node) => Array.isArray(node) ? unwrap(node) :\n (node instanceof RecordBatch) ? node.data.children : node.data);\n const assembler = new VectorAssembler();\n assembler.visitMany(unwrap(args));\n return assembler;\n }\n visit(data) {\n if (data instanceof Vector) {\n this.visitMany(data.data);\n return this;\n }\n const { type } = data;\n if (!DataType.isDictionary(type)) {\n const { length, nullCount } = data;\n if (length > 2147483647) {\n /* istanbul ignore next */\n throw new RangeError('Cannot write arrays larger than 2^31 - 1 in length');\n }\n if (!DataType.isNull(type)) {\n addBuffer.call(this, nullCount <= 0\n ? new Uint8Array(0) // placeholder validity buffer\n : truncateBitmap(data.offset, length, data.nullBitmap));\n }\n this.nodes.push(new FieldNode(length, nullCount));\n }\n return super.visit(data);\n }\n visitNull(_null) {\n return this;\n }\n visitDictionary(data) {\n // Assemble the indices here, Dictionary assembled separately.\n return this.visit(data.clone(data.type.indices));\n }\n get nodes() { return this._nodes; }\n get buffers() { return this._buffers; }\n get byteLength() { return this._byteLength; }\n get bufferRegions() { return this._bufferRegions; }\n}\n/** @ignore */\nfunction addBuffer(values) {\n const byteLength = (values.byteLength + 7) & ~7; // Round up to a multiple of 8\n this.buffers.push(values);\n this.bufferRegions.push(new BufferRegion(this._byteLength, byteLength));\n this._byteLength += byteLength;\n return this;\n}\n/** @ignore */\nfunction assembleUnion(data) {\n const { type, length, typeIds, valueOffsets } = data;\n // All Union Vectors have a typeIds buffer\n addBuffer.call(this, typeIds);\n // If this is a Sparse Union, treat it like all other Nested types\n if (type.mode === UnionMode.Sparse) {\n return assembleNestedVector.call(this, data);\n }\n else if (type.mode === UnionMode.Dense) {\n // If this is a Dense Union, add the valueOffsets buffer and potentially slice the children\n if (data.offset <= 0) {\n // If the Vector hasn't been sliced, write the existing valueOffsets\n addBuffer.call(this, valueOffsets);\n // We can treat this like all other Nested types\n return assembleNestedVector.call(this, data);\n }\n else {\n // A sliced Dense Union is an unpleasant case. Because the offsets are different for\n // each child vector, we need to \"rebase\" the valueOffsets for each child\n // Union typeIds are not necessary 0-indexed\n const maxChildTypeId = typeIds.reduce((x, y) => Math.max(x, y), typeIds[0]);\n const childLengths = new Int32Array(maxChildTypeId + 1);\n // Set all to -1 to indicate that we haven't observed a first occurrence of a particular child yet\n const childOffsets = new Int32Array(maxChildTypeId + 1).fill(-1);\n const shiftedOffsets = new Int32Array(length);\n // If we have a non-zero offset, then the value offsets do not start at\n // zero. We must a) create a new offsets array with shifted offsets and\n // b) slice the values array accordingly\n const unshiftedOffsets = rebaseValueOffsets(-valueOffsets[0], length, valueOffsets);\n for (let typeId, shift, index = -1; ++index < length;) {\n if ((shift = childOffsets[typeId = typeIds[index]]) === -1) {\n shift = childOffsets[typeId] = unshiftedOffsets[typeId];\n }\n shiftedOffsets[index] = unshiftedOffsets[index] - shift;\n ++childLengths[typeId];\n }\n addBuffer.call(this, shiftedOffsets);\n // Slice and visit children accordingly\n for (let child, childIndex = -1, numChildren = type.children.length; ++childIndex < numChildren;) {\n if (child = data.children[childIndex]) {\n const typeId = type.typeIds[childIndex];\n const childLength = Math.min(length, childLengths[typeId]);\n this.visit(child.slice(childOffsets[typeId], childLength));\n }\n }\n }\n }\n return this;\n}\n/** @ignore */\nfunction assembleBoolVector(data) {\n // Bool vector is a special case of FlatVector, as its data buffer needs to stay packed\n let values;\n if (data.nullCount >= data.length) {\n // If all values are null, just insert a placeholder empty data buffer (fastest path)\n return addBuffer.call(this, new Uint8Array(0));\n }\n else if ((values = data.values) instanceof Uint8Array) {\n // If values is already a Uint8Array, slice the bitmap (fast path)\n return addBuffer.call(this, truncateBitmap(data.offset, data.length, values));\n }\n // Otherwise if the underlying data *isn't* a Uint8Array, enumerate the\n // values as bools and re-pack them into a Uint8Array. This code isn't\n // reachable unless you're trying to manipulate the Data internals,\n // we're only doing this for safety.\n /* istanbul ignore next */\n return addBuffer.call(this, packBools(data.values));\n}\n/** @ignore */\nfunction assembleFlatVector(data) {\n return addBuffer.call(this, data.values.subarray(0, data.length * data.stride));\n}\n/** @ignore */\nfunction assembleFlatListVector(data) {\n const { length, values, valueOffsets } = data;\n const firstOffset = valueOffsets[0];\n const lastOffset = valueOffsets[length];\n const byteLength = Math.min(lastOffset - firstOffset, values.byteLength - firstOffset);\n // Push in the order FlatList types read their buffers\n addBuffer.call(this, rebaseValueOffsets(-valueOffsets[0], length, valueOffsets)); // valueOffsets buffer first\n addBuffer.call(this, values.subarray(firstOffset, firstOffset + byteLength)); // sliced values buffer second\n return this;\n}\n/** @ignore */\nfunction assembleListVector(data) {\n const { length, valueOffsets } = data;\n // If we have valueOffsets (MapVector, ListVector), push that buffer first\n if (valueOffsets) {\n addBuffer.call(this, rebaseValueOffsets(valueOffsets[0], length, valueOffsets));\n }\n // Then insert the List's values child\n return this.visit(data.children[0]);\n}\n/** @ignore */\nfunction assembleNestedVector(data) {\n return this.visitMany(data.type.children.map((_, i) => data.children[i]).filter(Boolean))[0];\n}\nVectorAssembler.prototype.visitBool = assembleBoolVector;\nVectorAssembler.prototype.visitInt = assembleFlatVector;\nVectorAssembler.prototype.visitFloat = assembleFlatVector;\nVectorAssembler.prototype.visitUtf8 = assembleFlatListVector;\nVectorAssembler.prototype.visitBinary = assembleFlatListVector;\nVectorAssembler.prototype.visitFixedSizeBinary = assembleFlatVector;\nVectorAssembler.prototype.visitDate = assembleFlatVector;\nVectorAssembler.prototype.visitTimestamp = assembleFlatVector;\nVectorAssembler.prototype.visitTime = assembleFlatVector;\nVectorAssembler.prototype.visitDecimal = assembleFlatVector;\nVectorAssembler.prototype.visitList = assembleListVector;\nVectorAssembler.prototype.visitStruct = assembleNestedVector;\nVectorAssembler.prototype.visitUnion = assembleUnion;\nVectorAssembler.prototype.visitInterval = assembleFlatVector;\nVectorAssembler.prototype.visitFixedSizeList = assembleListVector;\nVectorAssembler.prototype.visitMap = assembleListVector;\n\n//# sourceMappingURL=vectorassembler.mjs.map\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { __asyncValues, __awaiter } from \"tslib\";\nimport { Table } from '../table.mjs';\nimport { MAGIC } from './message.mjs';\nimport { Vector } from '../vector.mjs';\nimport { DataType } from '../type.mjs';\nimport { Message } from './metadata/message.mjs';\nimport * as metadata from './metadata/message.mjs';\nimport { FileBlock, Footer } from './metadata/file.mjs';\nimport { MessageHeader, MetadataVersion } from '../enum.mjs';\nimport { compareSchemas } from '../visitor/typecomparator.mjs';\nimport { AsyncByteQueue } from '../io/stream.mjs';\nimport { VectorAssembler } from '../visitor/vectorassembler.mjs';\nimport { JSONTypeAssembler } from '../visitor/jsontypeassembler.mjs';\nimport { JSONVectorAssembler } from '../visitor/jsonvectorassembler.mjs';\nimport { toUint8Array } from '../util/buffer.mjs';\nimport { RecordBatch, _InternalEmptyPlaceholderRecordBatch } from '../recordbatch.mjs';\nimport { ReadableInterop } from '../io/interfaces.mjs';\nimport { isPromise, isAsyncIterable, isWritableDOMStream, isWritableNodeStream, isIterable, isObject } from '../util/compat.mjs';\nexport class RecordBatchWriter extends ReadableInterop {\n constructor(options) {\n super();\n this._position = 0;\n this._started = false;\n // @ts-ignore\n this._sink = new AsyncByteQueue();\n this._schema = null;\n this._dictionaryBlocks = [];\n this._recordBatchBlocks = [];\n this._dictionaryDeltaOffsets = new Map();\n isObject(options) || (options = { autoDestroy: true, writeLegacyIpcFormat: false });\n this._autoDestroy = (typeof options.autoDestroy === 'boolean') ? options.autoDestroy : true;\n this._writeLegacyIpcFormat = (typeof options.writeLegacyIpcFormat === 'boolean') ? options.writeLegacyIpcFormat : false;\n }\n /** @nocollapse */\n // @ts-ignore\n static throughNode(options) {\n throw new Error(`\"throughNode\" not available in this environment`);\n }\n /** @nocollapse */\n static throughDOM(\n // @ts-ignore\n writableStrategy, \n // @ts-ignore\n readableStrategy) {\n throw new Error(`\"throughDOM\" not available in this environment`);\n }\n toString(sync = false) {\n return this._sink.toString(sync);\n }\n toUint8Array(sync = false) {\n return this._sink.toUint8Array(sync);\n }\n writeAll(input) {\n if (isPromise(input)) {\n return input.then((x) => this.writeAll(x));\n }\n else if (isAsyncIterable(input)) {\n return writeAllAsync(this, input);\n }\n return writeAll(this, input);\n }\n get closed() { return this._sink.closed; }\n [Symbol.asyncIterator]() { return this._sink[Symbol.asyncIterator](); }\n toDOMStream(options) { return this._sink.toDOMStream(options); }\n toNodeStream(options) { return this._sink.toNodeStream(options); }\n close() {\n return this.reset()._sink.close();\n }\n abort(reason) {\n return this.reset()._sink.abort(reason);\n }\n finish() {\n this._autoDestroy ? this.close() : this.reset(this._sink, this._schema);\n return this;\n }\n reset(sink = this._sink, schema = null) {\n if ((sink === this._sink) || (sink instanceof AsyncByteQueue)) {\n this._sink = sink;\n }\n else {\n this._sink = new AsyncByteQueue();\n if (sink && isWritableDOMStream(sink)) {\n this.toDOMStream({ type: 'bytes' }).pipeTo(sink);\n }\n else if (sink && isWritableNodeStream(sink)) {\n this.toNodeStream({ objectMode: false }).pipe(sink);\n }\n }\n if (this._started && this._schema) {\n this._writeFooter(this._schema);\n }\n this._started = false;\n this._dictionaryBlocks = [];\n this._recordBatchBlocks = [];\n this._dictionaryDeltaOffsets = new Map();\n if (!schema || !(compareSchemas(schema, this._schema))) {\n if (schema == null) {\n this._position = 0;\n this._schema = null;\n }\n else {\n this._started = true;\n this._schema = schema;\n this._writeSchema(schema);\n }\n }\n return this;\n }\n write(payload) {\n let schema = null;\n if (!this._sink) {\n throw new Error(`RecordBatchWriter is closed`);\n }\n else if (payload == null) {\n return this.finish() && undefined;\n }\n else if (payload instanceof Table && !(schema = payload.schema)) {\n return this.finish() && undefined;\n }\n else if (payload instanceof RecordBatch && !(schema = payload.schema)) {\n return this.finish() && undefined;\n }\n if (schema && !compareSchemas(schema, this._schema)) {\n if (this._started && this._autoDestroy) {\n return this.close();\n }\n this.reset(this._sink, schema);\n }\n if (payload instanceof RecordBatch) {\n if (!(payload instanceof _InternalEmptyPlaceholderRecordBatch)) {\n this._writeRecordBatch(payload);\n }\n }\n else if (payload instanceof Table) {\n this.writeAll(payload.batches);\n }\n else if (isIterable(payload)) {\n this.writeAll(payload);\n }\n }\n _writeMessage(message, alignment = 8) {\n const a = alignment - 1;\n const buffer = Message.encode(message);\n const flatbufferSize = buffer.byteLength;\n const prefixSize = !this._writeLegacyIpcFormat ? 8 : 4;\n const alignedSize = (flatbufferSize + prefixSize + a) & ~a;\n const nPaddingBytes = alignedSize - flatbufferSize - prefixSize;\n if (message.headerType === MessageHeader.RecordBatch) {\n this._recordBatchBlocks.push(new FileBlock(alignedSize, message.bodyLength, this._position));\n }\n else if (message.headerType === MessageHeader.DictionaryBatch) {\n this._dictionaryBlocks.push(new FileBlock(alignedSize, message.bodyLength, this._position));\n }\n // If not in legacy pre-0.15.0 mode, write the stream continuation indicator\n if (!this._writeLegacyIpcFormat) {\n this._write(Int32Array.of(-1));\n }\n // Write the flatbuffer size prefix including padding\n this._write(Int32Array.of(alignedSize - prefixSize));\n // Write the flatbuffer\n if (flatbufferSize > 0) {\n this._write(buffer);\n }\n // Write any padding\n return this._writePadding(nPaddingBytes);\n }\n _write(chunk) {\n if (this._started) {\n const buffer = toUint8Array(chunk);\n if (buffer && buffer.byteLength > 0) {\n this._sink.write(buffer);\n this._position += buffer.byteLength;\n }\n }\n return this;\n }\n _writeSchema(schema) {\n return this._writeMessage(Message.from(schema));\n }\n // @ts-ignore\n _writeFooter(schema) {\n // eos bytes\n return this._writeLegacyIpcFormat\n ? this._write(Int32Array.of(0))\n : this._write(Int32Array.of(-1, 0));\n }\n _writeMagic() {\n return this._write(MAGIC);\n }\n _writePadding(nBytes) {\n return nBytes > 0 ? this._write(new Uint8Array(nBytes)) : this;\n }\n _writeRecordBatch(batch) {\n const { byteLength, nodes, bufferRegions, buffers } = VectorAssembler.assemble(batch);\n const recordBatch = new metadata.RecordBatch(batch.numRows, nodes, bufferRegions);\n const message = Message.from(recordBatch, byteLength);\n return this\n ._writeDictionaries(batch)\n ._writeMessage(message)\n ._writeBodyBuffers(buffers);\n }\n _writeDictionaryBatch(dictionary, id, isDelta = false) {\n this._dictionaryDeltaOffsets.set(id, dictionary.length + (this._dictionaryDeltaOffsets.get(id) || 0));\n const { byteLength, nodes, bufferRegions, buffers } = VectorAssembler.assemble(new Vector([dictionary]));\n const recordBatch = new metadata.RecordBatch(dictionary.length, nodes, bufferRegions);\n const dictionaryBatch = new metadata.DictionaryBatch(recordBatch, id, isDelta);\n const message = Message.from(dictionaryBatch, byteLength);\n return this\n ._writeMessage(message)\n ._writeBodyBuffers(buffers);\n }\n _writeBodyBuffers(buffers) {\n let buffer;\n let size, padding;\n for (let i = -1, n = buffers.length; ++i < n;) {\n if ((buffer = buffers[i]) && (size = buffer.byteLength) > 0) {\n this._write(buffer);\n if ((padding = ((size + 7) & ~7) - size) > 0) {\n this._writePadding(padding);\n }\n }\n }\n return this;\n }\n _writeDictionaries(batch) {\n for (let [id, dictionary] of batch.dictionaries) {\n let offset = this._dictionaryDeltaOffsets.get(id) || 0;\n if (offset === 0 || (dictionary = dictionary === null || dictionary === void 0 ? void 0 : dictionary.slice(offset)).length > 0) {\n for (const data of dictionary.data) {\n this._writeDictionaryBatch(data, id, offset > 0);\n offset += data.length;\n }\n }\n }\n return this;\n }\n}\n/** @ignore */\nexport class RecordBatchStreamWriter extends RecordBatchWriter {\n /** @nocollapse */\n static writeAll(input, options) {\n const writer = new RecordBatchStreamWriter(options);\n if (isPromise(input)) {\n return input.then((x) => writer.writeAll(x));\n }\n else if (isAsyncIterable(input)) {\n return writeAllAsync(writer, input);\n }\n return writeAll(writer, input);\n }\n}\n/** @ignore */\nexport class RecordBatchFileWriter extends RecordBatchWriter {\n /** @nocollapse */\n static writeAll(input) {\n const writer = new RecordBatchFileWriter();\n if (isPromise(input)) {\n return input.then((x) => writer.writeAll(x));\n }\n else if (isAsyncIterable(input)) {\n return writeAllAsync(writer, input);\n }\n return writeAll(writer, input);\n }\n constructor() {\n super();\n this._autoDestroy = true;\n }\n // @ts-ignore\n _writeSchema(schema) {\n return this._writeMagic()._writePadding(2);\n }\n _writeFooter(schema) {\n const buffer = Footer.encode(new Footer(schema, MetadataVersion.V4, this._recordBatchBlocks, this._dictionaryBlocks));\n return super\n ._writeFooter(schema) // EOS bytes for sequential readers\n ._write(buffer) // Write the flatbuffer\n ._write(Int32Array.of(buffer.byteLength)) // then the footer size suffix\n ._writeMagic(); // then the magic suffix\n }\n}\n/** @ignore */\nexport class RecordBatchJSONWriter extends RecordBatchWriter {\n constructor() {\n super();\n this._autoDestroy = true;\n this._recordBatches = [];\n this._dictionaries = [];\n }\n /** @nocollapse */\n static writeAll(input) {\n return new RecordBatchJSONWriter().writeAll(input);\n }\n _writeMessage() { return this; }\n // @ts-ignore\n _writeFooter(schema) { return this; }\n _writeSchema(schema) {\n return this._write(`{\\n \"schema\": ${JSON.stringify({ fields: schema.fields.map(field => fieldToJSON(field)) }, null, 2)}`);\n }\n _writeDictionaries(batch) {\n if (batch.dictionaries.size > 0) {\n this._dictionaries.push(batch);\n }\n return this;\n }\n _writeDictionaryBatch(dictionary, id, isDelta = false) {\n this._dictionaryDeltaOffsets.set(id, dictionary.length + (this._dictionaryDeltaOffsets.get(id) || 0));\n this._write(this._dictionaryBlocks.length === 0 ? ` ` : `,\\n `);\n this._write(`${dictionaryBatchToJSON(dictionary, id, isDelta)}`);\n this._dictionaryBlocks.push(new FileBlock(0, 0, 0));\n return this;\n }\n _writeRecordBatch(batch) {\n this._writeDictionaries(batch);\n this._recordBatches.push(batch);\n return this;\n }\n close() {\n if (this._dictionaries.length > 0) {\n this._write(`,\\n \"dictionaries\": [\\n`);\n for (const batch of this._dictionaries) {\n super._writeDictionaries(batch);\n }\n this._write(`\\n ]`);\n }\n if (this._recordBatches.length > 0) {\n for (let i = -1, n = this._recordBatches.length; ++i < n;) {\n this._write(i === 0 ? `,\\n \"batches\": [\\n ` : `,\\n `);\n this._write(`${recordBatchToJSON(this._recordBatches[i])}`);\n this._recordBatchBlocks.push(new FileBlock(0, 0, 0));\n }\n this._write(`\\n ]`);\n }\n if (this._schema) {\n this._write(`\\n}`);\n }\n this._dictionaries = [];\n this._recordBatches = [];\n return super.close();\n }\n}\n/** @ignore */\nfunction writeAll(writer, input) {\n let chunks = input;\n if (input instanceof Table) {\n chunks = input.batches;\n writer.reset(undefined, input.schema);\n }\n for (const batch of chunks) {\n writer.write(batch);\n }\n return writer.finish();\n}\n/** @ignore */\nfunction writeAllAsync(writer, batches) {\n var batches_1, batches_1_1;\n var e_1, _a;\n return __awaiter(this, void 0, void 0, function* () {\n try {\n for (batches_1 = __asyncValues(batches); batches_1_1 = yield batches_1.next(), !batches_1_1.done;) {\n const batch = batches_1_1.value;\n writer.write(batch);\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (batches_1_1 && !batches_1_1.done && (_a = batches_1.return)) yield _a.call(batches_1);\n }\n finally { if (e_1) throw e_1.error; }\n }\n return writer.finish();\n });\n}\n/** @ignore */\nfunction fieldToJSON({ name, type, nullable }) {\n const assembler = new JSONTypeAssembler();\n return {\n 'name': name, 'nullable': nullable,\n 'type': assembler.visit(type),\n 'children': (type.children || []).map((field) => fieldToJSON(field)),\n 'dictionary': !DataType.isDictionary(type) ? undefined : {\n 'id': type.id,\n 'isOrdered': type.isOrdered,\n 'indexType': assembler.visit(type.indices)\n }\n };\n}\n/** @ignore */\nfunction dictionaryBatchToJSON(dictionary, id, isDelta = false) {\n const [columns] = JSONVectorAssembler.assemble(new RecordBatch({ [id]: dictionary }));\n return JSON.stringify({\n 'id': id,\n 'isDelta': isDelta,\n 'data': {\n 'count': dictionary.length,\n 'columns': columns\n }\n }, null, 2);\n}\n/** @ignore */\nfunction recordBatchToJSON(records) {\n const [columns] = JSONVectorAssembler.assemble(records);\n return JSON.stringify({\n 'count': records.numRows,\n 'columns': columns\n }, null, 2);\n}\n\n//# sourceMappingURL=writer.mjs.map\n","import { Data, Vector } from 'apache-arrow';\n\nexport function ceil64Bytes(length, bpe = 1) {\n return ((((length * bpe) + 63) & ~63) || 64) / bpe;\n}\n\nexport function array(Type, length, bpe = Type.BYTES_PER_ELEMENT) {\n return new Type(ceil64Bytes(length, bpe));\n}\n\nexport function arrowData(d) {\n return d instanceof Data\n ? d\n : new Data(d.type, 0, d.length, d.nulls, d.buffers, null, d.dict);\n}\n\nexport function arrowVector(data) {\n return new Vector([arrowData(data)]);\n}\n\nexport const encoder = new TextEncoder();\n\nexport function encode(data, idx, str) {\n const bytes = encoder.encode(str);\n data.set(bytes, idx);\n return bytes.length;\n}\n\nexport function encodeInto(data, idx, str) {\n return encoder.encodeInto(str, data.subarray(idx)).written;\n}\n\nexport const writeUtf8 = encoder.encodeInto ? encodeInto : encode;","import { array } from './util';\n\nexport default function(type, length) {\n const data = array(type.ArrayType, length);\n return {\n set(value, index) { data[index] = value; },\n data: () => ({ type, length, buffers: [null, data] })\n };\n}","import { array } from './util';\n\nexport default function(type, length) {\n const data = array(type.ArrayType, length / 8);\n return {\n set(value, index) {\n if (value) data[index >> 3] |= (1 << (index % 8));\n },\n data: () => ({ type, length, buffers: [null, data] })\n };\n}","import { array } from './util';\n\nexport default function(type, length) {\n const data = array(type.ArrayType, length);\n return {\n set(value, index) { data[index] = (value / 86400000) | 0; },\n data: () => ({ type, length, buffers: [null, data] })\n };\n}","import { array } from './util';\n\nexport default function(type, length) {\n const data = array(type.ArrayType, length << 1);\n return {\n set(value, index) {\n const i = index << 1;\n data[ i] = (value % 4294967296) | 0;\n data[i+1] = (value / 4294967296) | 0;\n },\n data: () => ({ type, length, buffers: [null, data] })\n };\n}","import utf8Builder from './utf8-builder';\nimport { array, arrowVector } from './util';\n\nexport default function(type, length) {\n const values = [];\n const data = array(type.indices.ArrayType, length);\n const keys = Object.create(null);\n\n let next = -1;\n let strlen = 0;\n\n return {\n set(value, index) {\n const v = String(value);\n let k = keys[v];\n if (k === undefined) {\n strlen += v.length;\n keys[v] = k = ++next;\n values.push(v);\n }\n data[index] = k;\n },\n data: () => ({\n type,\n length,\n buffers: [null, data],\n dict: dictionary(type.dictionary, values, strlen)\n })\n };\n}\n\nfunction dictionary(type, values, strlen) {\n const b = utf8Builder(type, values.length, strlen);\n values.forEach(b.set);\n return arrowVector(b.data());\n}","import { array, ceil64Bytes, writeUtf8 } from './util';\n\nexport default function(type, length, strlen) {\n const offset = array(Int32Array, length + 1);\n const buf = array(Uint8Array, 3 * strlen);\n\n let idx = 0;\n\n return {\n set(value, index) {\n idx += writeUtf8(buf, idx, value);\n offset[index + 1] = idx;\n },\n data: () => {\n // slice utf buffer if over-allocated\n const dlen = ceil64Bytes(idx);\n const data = buf.length > dlen ? buf.subarray(0, dlen) : buf;\n return { type, length, buffers: [offset, data] };\n }\n };\n}","import { Type } from 'apache-arrow';\nimport arrayBuilder from './array-builder';\nimport boolBuilder from './bool-builder';\nimport dateDayBuilder from './date-day-builder';\nimport dateMillisBuilder from './date-millis-builder';\nimport defaultBuilder from './default-builder';\nimport dictionaryBuilder from './dictionary-builder';\nimport validBuilder from './valid-builder';\n\nexport default function(type, nrows, nullable = true) {\n let method;\n\n switch (type.typeId) {\n case Type.Int:\n method = type.bitWidth < 64 ? arrayBuilder : null;\n break;\n case Type.Float:\n method = type.precision > 0 ? arrayBuilder : null;\n break;\n case Type.Dictionary:\n // check sub-types against builder assumptions\n // if check fails, fallback to default builder\n method = (\n type.dictionary.typeId === Type.Utf8 &&\n type.indices.typeId === Type.Int &&\n type.indices.bitWidth < 64\n ) ? dictionaryBuilder : null;\n break;\n case Type.Bool:\n method = boolBuilder;\n break;\n case Type.Date:\n method = type.unit ? dateMillisBuilder : dateDayBuilder;\n break;\n }\n\n return method == null ? defaultBuilder(type)\n : nullable ? validBuilder(method(type, nrows), nrows)\n : method(type, nrows);\n}","import { makeBuilder } from 'apache-arrow';\n\nexport default function(type) {\n const b = makeBuilder({\n type,\n nullValues: [null, undefined]\n });\n return {\n set(value, index) { b.set(index, value); },\n data: () => b.finish().flush()\n };\n}","import { array } from './util';\n\nexport default function(builder, length) {\n const valid = array(Uint8Array, length / 8);\n let nulls = 0;\n\n return {\n set(value, index) {\n if (value == null) {\n ++nulls;\n } else {\n builder.set(value, index);\n valid[index >> 3] |= (1 << (index % 8));\n }\n },\n data: () => {\n const d = builder.data();\n if (nulls) {\n d.nulls = nulls;\n d.buffers[2] = valid;\n }\n return d;\n }\n };\n}","import builder from '../builder';\nimport { arrowData, ceil64Bytes } from '../builder/util';\n\nexport function dataFromArray(array, type) {\n const length = array.length;\n const size = ceil64Bytes(length, array.BYTES_PER_ELEMENT);\n\n let data = array;\n if (length !== size) {\n data = new array.constructor(size);\n data.set(array);\n }\n\n return arrowData({ type, length, buffers: [null, data] });\n}\n\nexport function dataFromScan(nrows, scan, column, type, nullable = true) {\n const b = builder(type, nrows, nullable);\n scan(column, b.set);\n return arrowData(b.data());\n}","import {\n Binary,\n Bool,\n DataType,\n DateDay,\n DateMillisecond,\n Dictionary,\n Float16,\n Float32,\n Float64,\n Int16,\n Int32,\n Int64,\n Int8,\n IntervalDayTime,\n IntervalYearMonth,\n Null,\n TimeMicrosecond,\n TimeMillisecond,\n TimeNanosecond,\n TimeSecond,\n Type,\n Uint16,\n Uint32,\n Uint64,\n Uint8,\n Utf8\n} from 'apache-arrow';\nimport error from '../../util/error';\nimport toString from '../../util/to-string';\n\nexport default function(type) {\n if (type instanceof DataType || type == null) {\n return type;\n }\n\n switch (type) {\n case Type.Binary:\n return new Binary();\n case Type.Bool:\n return new Bool();\n case Type.DateDay:\n return new DateDay();\n case Type.DateMillisecond:\n case Type.Date:\n return new DateMillisecond();\n case Type.Dictionary:\n return new Dictionary(new Utf8(), new Int32());\n case Type.Float16:\n return new Float16();\n case Type.Float32:\n return new Float32();\n case Type.Float64:\n case Type.Float:\n return new Float64();\n case Type.Int8:\n return new Int8();\n case Type.Int16:\n return new Int16();\n case Type.Int32:\n case Type.Int:\n return new Int32();\n case Type.Int64:\n return new Int64();\n case Type.IntervalDayTime:\n return new IntervalDayTime();\n case Type.Interval:\n case Type.IntervalYearMonth:\n return new IntervalYearMonth();\n case Type.Null:\n return new Null();\n case Type.TimeMicrosecond:\n return new TimeMicrosecond();\n case Type.TimeMillisecond:\n case Type.Time:\n return new TimeMillisecond();\n case Type.TimeNanosecond:\n return new TimeNanosecond();\n case Type.TimeSecond:\n return new TimeSecond();\n case Type.Uint8:\n return new Uint8();\n case Type.Uint16:\n return new Uint16();\n case Type.Uint32:\n return new Uint32();\n case Type.Uint64:\n return new Uint64();\n case Type.Utf8:\n return new Utf8();\n default:\n error(\n `Unsupported type code: ${toString(type)}. ` +\n 'Use a data type constructor instead?'\n );\n }\n}","import { Field, FixedSizeList, List, Struct, Type } from 'apache-arrow';\nimport resolveType from '../builder/resolve-type';\nimport error from '../../util/error';\nimport isArrayType from '../../util/is-array-type';\nimport isDate from '../../util/is-date';\nimport isExactUTCDate from '../../util/is-exact-utc-date';\n\nexport function profile(scan, column) {\n const p = profiler();\n scan(column, p.add);\n return p;\n}\n\nexport function profiler() {\n const p = {\n count: 0,\n nulls: 0,\n bools: 0,\n nums: 0,\n ints: 0,\n bigints: 0,\n min: Infinity,\n max: -Infinity,\n digits: 0,\n dates: 0,\n utcdays: 0,\n strings: 0,\n strlen: 0,\n arrays: 0,\n minlen: Infinity,\n maxlen: 0,\n structs: 0,\n\n add(value) {\n ++p.count;\n if (value == null) {\n ++p.nulls;\n return;\n }\n\n const type = typeof value;\n if (type === 'string') {\n ++p.strings;\n } else if (type === 'number') {\n ++p.nums;\n if (value < p.min) p.min = value;\n if (value > p.max) p.max = value;\n if (Number.isInteger(value)) ++p.ints;\n } else if (type === 'boolean') {\n ++p.bools;\n } else if (type === 'object') {\n if (isDate(value)) {\n ++p.dates;\n if (isExactUTCDate(value)) {\n ++p.utcdays;\n }\n } else if (isArrayType(value)) {\n ++p.arrays;\n if (value.length < p.minlen) p.minlen = value.length;\n if (value.length > p.maxlen) p.maxlen = value.length;\n const ap = p.array_prof || (p.array_prof = profiler());\n value.forEach(ap.add);\n } else {\n ++p.structs;\n const sp = p.struct_prof || (p.struct_prof = {});\n for (const key in value) {\n const fp = sp[key] || (sp[key] = profiler());\n fp.add(value[key]);\n }\n }\n } else if (type === 'bigint') {\n ++p.bigints;\n if (value < p.min) p.min = value;\n if (value > p.max) p.max = value;\n }\n },\n type() {\n return resolveType(infer(p));\n }\n };\n\n return p;\n}\n\nfunction infer(p) {\n const valid = p.count - p.nulls;\n\n if (valid === 0) {\n return Type.Null;\n }\n else if (p.ints === valid) {\n const v = Math.max(Math.abs(p.min) - 1, p.max);\n return p.min < 0\n ? v >= 2 ** 31 ? Type.Float64\n : v < (1 << 7) ? Type.Int8 : v < (1 << 15) ? Type.Int16 : Type.Int32\n : v >= 2 ** 32 ? Type.Float64\n : v < (1 << 8) ? Type.Uint8 : v < (1 << 16) ? Type.Uint16 : Type.Uint32;\n }\n else if (p.nums === valid) {\n return Type.Float64;\n }\n else if (p.bigints === valid) {\n const v = -p.min > p.max ? -p.min - 1n : p.max;\n return p.min < 0\n ? v < 2 ** 63 ? Type.Int64\n : error(`BigInt exceeds 64 bits: ${v}`)\n : p.max < 2 ** 64 ? Type.Uint64\n : error(`BigInt exceeds 64 bits: ${p.max}`);\n }\n else if (p.bools === valid) {\n return Type.Bool;\n }\n else if (p.utcdays === valid) {\n return Type.DateDay;\n }\n else if (p.dates === valid) {\n return Type.DateMillisecond;\n }\n else if (p.arrays === valid) {\n const type = Field.new('value', p.array_prof.type(), true);\n return p.minlen === p.maxlen\n ? new FixedSizeList(p.minlen, type)\n : new List(type);\n }\n else if (p.structs === valid) {\n const sp = p.struct_prof;\n return new Struct(\n Object.keys(sp).map(name => Field.new(name, sp[name].type(), true))\n );\n }\n else if (p.strings > 0) {\n return Type.Dictionary;\n }\n else {\n error('Type inference failure');\n }\n}","export default function(d) {\n return d.getUTCHours() === 0\n && d.getUTCMinutes() === 0\n && d.getUTCSeconds() === 0\n && d.getUTCMilliseconds() === 0;\n}","import { dataFromScan } from './data-from';\nimport { profile } from './profiler';\nimport resolveType from '../builder/resolve-type';\n\nexport default function(data, name, nrows, scan, type, nullable = true) {\n type = resolveType(type);\n\n // perform type inference if needed\n if (!type) {\n const p = profile(scan, name);\n nullable = p.nulls > 0;\n type = p.type();\n }\n\n return dataFromScan(nrows, scan, name, type, nullable);\n}","import {\n Float32, Float64,\n Int16, Int32, Int64, Int8,\n Uint16, Uint32, Uint64, Uint8, Vector\n} from 'apache-arrow';\nimport { dataFromArray, dataFromScan } from './data-from';\nimport { profile } from './profiler';\nimport resolveType from '../builder/resolve-type';\nimport isTypedArray from '../../util/is-typed-array';\n\nexport default function(table, name, nrows, scan, type, nullable = true) {\n type = resolveType(type);\n const column = table.column(name);\n const reified = !(table.isFiltered() || table.isOrdered());\n\n // use existing arrow data if types match\n const vec = arrowVector(column);\n if (vec && reified && typeCompatible(vec.type, type)) {\n return vec;\n }\n\n // if backing data is a typed array, leverage that\n const data = column.data;\n if (isTypedArray(data)) {\n const dtype = typeFromArray(data);\n if (reified && dtype && typeCompatible(dtype, type)) {\n return dataFromArray(data, dtype);\n } else {\n type = type || dtype;\n nullable = false;\n }\n }\n\n // perform type inference if needed\n if (!type) {\n const p = profile(scan, column);\n nullable = p.nulls > 0;\n type = p.type();\n }\n\n return dataFromScan(nrows, scan, column, type, nullable);\n}\n\nfunction arrowVector(value) {\n return value instanceof Vector ? value\n : value.vector instanceof Vector ? value.vector\n : null;\n}\n\nfunction typeFromArray(data) {\n const types = {\n Float32Array: Float32,\n Float64Array: Float64,\n Int8Array: Int8,\n Int16Array: Int16,\n Int32Array: Int32,\n Uint8Array: Uint8,\n Uint16Array: Uint16,\n Uint32Array: Uint32,\n BigInt64Array: Int64,\n BigUint64Array: Uint64\n };\n const Type = types[data.constructor.name];\n return Type ? new Type() : null;\n}\n\nfunction typeCompatible(a, b) {\n return !a || !b ? true : a.compareTo(b);\n}","import isArrayType from '../../util/is-array-type';\n\nexport function scanArray(data, limit, offset) {\n const n = Math.min(data.length, offset + limit);\n return (name, visit) => {\n for (let i = offset; i < n; ++i) {\n visit(data[i][name], i);\n }\n };\n}\n\nexport function scanTable(table, limit, offset) {\n const scanAll = offset === 0 && table.numRows() <= limit\n && !table.isFiltered() && !table.isOrdered();\n\n return (column, visit) => {\n let i = -1;\n scanAll && isArrayType(column.data)\n ? column.data.forEach(visit)\n : table.scan(\n row => visit(column.get(row), ++i),\n true, limit, offset\n );\n };\n}","import { Table, tableFromIPC } from 'apache-arrow';\nimport error from '../util/error';\n\nconst fail = () => error(\n 'Apache Arrow not imported, ' +\n 'see https://github.com/uwdata/arquero#usage'\n);\n\nexport function table() {\n // trap access to provide a helpful message\n // when Apache Arrow has not been imported\n try {\n return Table;\n } catch (err) {\n fail();\n }\n}\n\nexport function fromIPC() {\n // trap access to provide a helpful message\n // when Apache Arrow has not been imported\n try {\n return tableFromIPC;\n } catch (err) {\n fail();\n }\n}","import { Table } from 'apache-arrow'; // eslint-disable-line no-unused-vars\n\nimport dataFromObjects from './data-from-objects';\nimport dataFromTable from './data-from-table';\nimport { scanArray, scanTable } from './scan';\nimport { table } from '../arrow-table';\nimport error from '../../util/error';\nimport isArray from '../../util/is-array';\nimport isFunction from '../../util/is-function';\n\n/**\n * Options for Arrow encoding.\n * @typedef {object} ArrowFormatOptions\n * @property {number} [limit=Infinity] The maximum number of rows to include.\n * @property {number} [offset=0] The row offset indicating how many initial\n * rows to skip.\n * @property {string[]|(data: object) => string[]} [columns] Ordered list of\n * column names to include. If function-valued, the function should accept\n * a dataset as input and return an array of column name strings.\n * @property {object} [types] The Arrow data types to use. If specified,\n * the input should be an object with column names for keys and Arrow data\n * types for values. If a column type is not explicitly provided, type\n * inference will be performed to guess an appropriate type.\n */\n\n/**\n * Create an Apache Arrow table for an input dataset.\n * @param {Array|object} data An input dataset to convert to Arrow format.\n * If array-valued, the data should consist of an array of objects where\n * each entry represents a row and named properties represent columns.\n * Otherwise, the input data should be an Arquero table.\n * @param {ArrowFormatOptions} [options] Encoding options, including\n * column data types.\n * @return {Table} An Apache Arrow Table instance.\n */\nexport default function(data, options = {}) {\n const { types = {} } = options;\n const { dataFrom, names, nrows, scan } = init(data, options);\n const cols = {};\n names.forEach(name => {\n const col = dataFrom(data, name, nrows, scan, types[name]);\n if (col.length !== nrows) {\n error('Column length mismatch');\n }\n cols[name] = col;\n });\n const T = table();\n return new T(cols);\n}\n\nfunction init(data, options) {\n const { columns, limit = Infinity, offset = 0 } = options;\n const names = isFunction(columns) ? columns(data)\n : isArray(columns) ? columns\n : null;\n if (isArray(data)) {\n return {\n dataFrom: dataFromObjects,\n names: names || Object.keys(data[0]),\n nrows: Math.min(limit, data.length - offset),\n scan: scanArray(data, limit, offset)\n };\n } else if (isTable(data)) {\n return {\n dataFrom: dataFromTable,\n names: names || data.columnNames(),\n nrows: Math.min(limit, data.numRows() - offset),\n scan: scanTable(data, limit, offset)\n };\n } else {\n error('Unsupported input data type');\n }\n}\n\nfunction isTable(data) {\n return data && isFunction(data.reify);\n}","import toArrow from '../arrow/encode';\nimport { tableToIPC } from 'apache-arrow';\n\nexport default toArrow;\n\nexport function toArrowIPC(table, options = {}) {\n const { format: format, ...toArrowOptions } = options;\n const outputFormat = format ? format : 'stream';\n if (!['stream', 'file'].includes(outputFormat)) {\n throw Error('Unrecognised output format');\n }\n return tableToIPC(toArrow(table, toArrowOptions), format);\n}\n","// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\nimport { Table } from '../table.mjs';\nimport { isPromise } from '../util/compat.mjs';\nimport { RecordBatchReader } from './reader.mjs';\nimport { RecordBatchFileWriter, RecordBatchStreamWriter } from './writer.mjs';\nexport function tableFromIPC(input) {\n const reader = RecordBatchReader.from(input);\n if (isPromise(reader)) {\n return reader.then((reader) => tableFromIPC(reader));\n }\n if (reader.isAsync()) {\n return reader.readAll().then((xs) => new Table(xs));\n }\n return new Table(reader.readAll());\n}\n/**\n * Serialize a {@link Table} to the IPC format. This function is a convenience\n * wrapper for {@link RecordBatchStreamWriter} and {@link RecordBatchFileWriter}.\n * Opposite of {@link tableFromIPC}.\n *\n * @param table The Table to serialize.\n * @param type Whether to serialize the Table as a file or a stream.\n */\nexport function tableToIPC(table, type = 'stream') {\n return (type === 'stream' ? RecordBatchStreamWriter : RecordBatchFileWriter)\n .writeAll(table)\n .toUint8Array(true);\n}\n\n//# sourceMappingURL=serialization.mjs.map\n","import Table from '../table/table'; // eslint-disable-line no-unused-vars\n\nimport inferFormat from './infer';\nimport isFunction from '../util/is-function';\n\n/**\n * Column selection function.\n * @typedef {(table: Table) => string[]} ColumnSelectFunction\n */\n\n/**\n * Column selection options.\n * @typedef {string[]|ColumnSelectFunction} ColumnSelectOptions\n */\n\n/**\n * Column format options. The object keys should be column names.\n * The object values should be formatting functions or objects.\n * If specified, these override any automatically inferred options.\n * @typedef {Object.} ColumnAlignOptions\n */\n\nexport function columns(table, names) {\n return isFunction(names)\n ? names(table)\n : names || table.columnNames();\n}\n\nexport function formats(table, names, options) {\n const formatOpt = options.format || {};\n const alignOpt = options.align || {};\n const format = {};\n const align = {};\n\n names.forEach(name => {\n const auto = inferFormat(values(table, name), options);\n align[name] = alignOpt[name] || auto.align;\n format[name] = formatOpt[name] || auto.format;\n });\n\n return { align, format };\n}\n\nfunction values(table, columnName) {\n const column = table.column(columnName);\n return fn => table.scan(row => fn(column.get(row)));\n}\n\nexport function scan(table, names, limit = 100, offset, ctx) {\n const data = table.data();\n const n = names.length;\n table.scan(row => {\n ctx.row(row);\n for (let i = 0; i < n; ++i) {\n const name = names[i];\n ctx.cell(data[names[i]].get(row), name, i);\n }\n }, true, limit, offset);\n}","import isDate from '../util/is-date';\n\nfunction isExactDateUTC(d) {\n return d.getUTCHours() === 0\n && d.getUTCMinutes() === 0\n && d.getUTCSeconds() === 0\n && d.getUTCMilliseconds() === 0;\n}\n\nexport default function(scan, options = {}) {\n let count = 0;\n let nulls = 0;\n let dates = 0;\n let dutcs = 0;\n let nums = 0;\n let digits = 0;\n\n scan(value => {\n ++count;\n if (value == null) {\n ++nulls;\n return;\n }\n\n const type = typeof value;\n if (type === 'object' && isDate(value)) {\n ++dates;\n if (isExactDateUTC(value)) ++dutcs;\n } else if (type === 'number') {\n ++nums;\n if (value === value && (value | 0) !== value) {\n const s = value + '';\n const p = s.indexOf('.');\n if (p >= 0) {\n const e = s.indexOf('e');\n const l = e > 0 ? e : s.length;\n digits = Math.max(digits, l - p - 1);\n }\n }\n }\n });\n\n return {\n align: (nulls + nums + dates) / count > 0.5 ? 'r' : 'l',\n format: {\n utc: dates === dutcs,\n digits: Math.min(digits, options.maxdigits || 6)\n }\n };\n}","import { formatDate, formatUTCDate } from '../util/format-date';\nimport isDate from '../util/is-date';\nimport isFunction from '../util/is-function';\nimport isTypedArray from '../util/is-typed-array';\n\n/**\n * Column format object.\n * @typedef {object} ValueFormatObject\n * @property {boolean} [utc=false] If true, format dates in UTC time.\n * @property {number} [digits=0] The number of fractional digits to include\n * when formatting numbers.\n * @property {number} [maxlen=30] The maximum string length for formatting\n * nested object or array values.\n */\n\n/**\n * @callback ValueFormatFunction\n * @param {*} value The value to format.\n * @return {*} A string-coercible or JSON-compatible formatted value.\n */\n\n/**\n * Value format options.\n * @typedef {ValueFormatObject|ValueFormatFunction} ValueFormatOptions\n */\n\n/**\n * Format a value as a string.\n * @param {*} v The value to format.\n * @param {ValueFormatOptions} options Formatting options.\n * @return {string} The formatted string.\n */\nexport default function(v, options = {}) {\n if (isFunction(options)) {\n return options(v) + '';\n }\n\n const type = typeof v;\n\n if (type === 'object') {\n if (isDate(v)) {\n return options.utc ? formatUTCDate(v) : formatDate(v);\n } else {\n const s = JSON.stringify(\n v,\n (k, v) => isTypedArray(v) ? Array.from(v) : v\n );\n const maxlen = options.maxlen || 30;\n return s.length > maxlen\n ? s.slice(0, 28) + '\\u2026' + (s[0] === '[' ? ']' : '}')\n : s;\n }\n } else if (type === 'number') {\n const digits = options.digits || 0;\n let a;\n return v !== 0 && ((a = Math.abs(v)) >= 1e18 || a < Math.pow(10, -digits))\n ? v.toExponential(digits)\n : v.toFixed(digits);\n } else {\n return v + '';\n }\n}","export default function(obj, fn, output = {}) {\n for (const key in obj) {\n output[key] = fn(obj[key], key);\n }\n return output;\n}","import ColumnTable from '../table/column-table'; // eslint-disable-line no-unused-vars\n\nimport formatValue from './value';\nimport { columns, formats, scan } from './util';\nimport isFunction from '../util/is-function';\nimport mapObject from '../util/map-object';\n\n/**\n * Null format function.\n * @callback NullFormat\n * @param {null|undefined} [value] The value to format.\n * @return {string} The formatted HTML string.\n */\n\n/**\n * CSS style function.\n * @callback StyleFunction\n * @param {string} name The column name.\n * @param {number} row The table row index.\n * @return {string} A CSS style string.\n */\n\n/**\n * CSS style options.\n * @typedef {Object.} StyleOptions\n */\n\n/**\n * Options for HTML formatting.\n * @typedef {object} HTMLFormatOptions\n * @property {number} [limit=Infinity] The maximum number of rows to print.\n * @property {number} [offset=0] The row offset indicating how many initial rows to skip.\n * @property {import('./util').ColumnSelectOptions} [columns] Ordered list\n * of column names to include. If function-valued, the function should\n * accept a table as input and return an array of column name strings.\n * @property {import('./util').ColumnAlignOptions} [align] Object of column\n * alignment options. The object keys should be column names. The object\n * values should be aligment strings, one of 'l' (left), 'c' (center), or\n * 'r' (right). If specified, these override automatically inferred options.\n * @property {import('./util').ColumnFormatOptions} [format] Object of column\n * format options. The object keys should be column names. The object values\n * should be formatting functions or specification objects. If specified,\n * these override automatically inferred options.\n * @property {NullFormat} [null] Format function for null or undefined values.\n * If specified, this function will be invoked with the null or undefined\n * value as the sole input, and the return value will be used as the HTML\n * output for the value.\n * @property {StyleOptions} [style] CSS styles to include in HTML output.\n * The object keys should be HTML table tag names: 'table', 'thead',\n * 'tbody', 'tr', 'th', or 'td'. The object values should be strings of\n * valid CSS style directives (such as \"font-weight: bold;\") or functions\n * that take a column name and row as inputs and return a CSS string.\n * @property {number} [maxdigits=6] The maximum number of fractional digits\n * to include when formatting numbers. This option is passed to the format\n * inference method and is overridden by any explicit format options.\n */\n\n/**\n * Format a table as an HTML table string.\n * @param {ColumnTable} table The table to format.\n * @param {HTMLFormatOptions} options The formatting options.\n * @return {string} An HTML table string.\n */\nexport default function(table, options = {}) {\n const names = columns(table, options.columns);\n const { align, format } = formats(table, names, options);\n const style = styles(options);\n const nullish = options.null;\n\n const alignValue = a => a === 'c' ? 'center' : a === 'r' ? 'right' : 'left';\n const escape = s => s.replace(/&/g, '&')\n .replace(//g, '>');\n const baseFormat = (value, opt) => escape(formatValue(value, opt));\n const formatter = nullish\n ? (value, opt) => value == null ? nullish(value) : baseFormat(value, opt)\n : baseFormat;\n\n let r = -1;\n let idx = -1;\n\n const tag = (tag, name, shouldAlign) => {\n const a = shouldAlign ? alignValue(align[name]) : '';\n const s = style[tag] ? (style[tag](name, idx, r) || '') : '';\n const css = (a ? (`text-align: ${a};` + (s ? ' ' : '')) : '') + s;\n return `<${tag}${css ? ` style=\"${css}\"` : ''}>`;\n };\n\n let text = tag('table')\n + tag('thead')\n + tag('tr', r)\n + names.map(name => `${tag('th', name, 1)}${name}`).join('')\n + ''\n + tag('tbody');\n\n scan(table, names, options.limit, options.offset, {\n row(row) {\n r = row;\n text += (++idx ? '' : '') + tag('tr');\n },\n cell(value, name) {\n text += tag('td', name, 1)\n + formatter(value, format[name])\n + '';\n }\n });\n\n return text + '';\n}\n\nfunction styles(options) {\n return mapObject(\n options.style,\n value => isFunction(value) ? value : () => value\n );\n}","export default function(value, trueValue = true, falseValue = false) {\n return (value === undefined || value) ? trueValue : falseValue;\n}","import ColumnTable from '../table/column-table'; // eslint-disable-line no-unused-vars\n\nimport { columns } from './util';\nimport { formatUTCDate } from '../util/format-date';\nimport defaultTrue from '../util/default-true';\nimport isDate from '../util/is-date';\n\n/**\n * Options for JSON formatting.\n * @typedef {object} JSONFormatOptions\n * @property {number} [limit=Infinity] The maximum number of rows to print.\n * @property {number} [offset=0] The row offset indicating how many initial\n * rows to skip.\n * @property {boolean} [schema=true] Flag indicating if table schema metadata\n * should be included in the JSON output. If false, only the data payload\n * is included.\n * @property {import('./util').ColumnSelectOptions} [columns] Ordered list\n * of column names to include. If function-valued, the function should\n * accept a table as input and return an array of column name strings.\n * @property {Object. any>} [format] Object of column\n * format options. The object keys should be column names. The object values\n * should be formatting functions to invoke to transform column values prior\n * to output. If specified, these override automatically inferred options.\n */\n\nconst defaultFormatter = value => isDate(value)\n ? formatUTCDate(value, true)\n : value;\n\n/**\n * Format a table as a JavaScript Object Notation (JSON) string.\n * @param {ColumnTable} table The table to format.\n * @param {JSONFormatOptions} options The formatting options.\n * @return {string} A JSON string.\n */\nexport default function(table, options = {}) {\n const schema = defaultTrue(options.schema);\n const format = options.format || {};\n const names = columns(table, options.columns);\n let text = '{';\n\n if (schema) {\n text += '\"schema\":{\"fields\":'\n + JSON.stringify(names.map(name => ({ name })))\n + '},\"data\":{';\n }\n\n names.forEach((name, i) => {\n text += (i ? ',' : '') + JSON.stringify(name) + ':[';\n\n const column = table.column(name);\n const formatter = format[name] || defaultFormatter;\n let r = -1;\n table.scan(row => {\n const value = column.get(row);\n text += (++r ? ',' : '') + JSON.stringify(formatter(value));\n }, true, options.limit, options.offset);\n\n text += ']';\n });\n\n return text + '}' + (schema ? '}' : '');\n}","import entries from './entries';\n\nexport default function(map, pairs) {\n for (const [key, value] of entries(pairs)) {\n map.set(key, value);\n }\n return map;\n}","import assign from '../util/assign';\nimport error from '../util/error';\nimport escapeRegExp from '../util/escape-regexp';\nimport isArray from '../util/is-array';\nimport isFunction from '../util/is-function';\nimport isNumber from '../util/is-number';\nimport isObject from '../util/is-object';\nimport isString from '../util/is-string';\nimport toString from '../util/to-string';\n\nexport default function resolve(table, sel, map = new Map()) {\n sel = isNumber(sel) ? table.columnName(sel) : sel;\n\n if (isString(sel)) {\n map.set(sel, sel);\n } else if (isArray(sel)) {\n sel.forEach(r => resolve(table, r, map));\n } else if (isFunction(sel)) {\n resolve(table, sel(table), map);\n } else if (isObject(sel)) {\n assign(map, sel);\n } else {\n error(`Invalid column selection: ${toString(sel)}`);\n }\n\n return map;\n}\n\nfunction decorate(value, toObject) {\n value.toObject = toObject;\n return value;\n}\n\nfunction toObject(value) {\n return isArray(value) ? value.map(toObject)\n : value && value.toObject ? value.toObject()\n : value;\n}\n\n/**\n * Proxy type for SelectHelper function.\n * @typedef {import('../table/transformable').SelectHelper} SelectHelper\n */\n\n/**\n * Select all columns in a table.\n * Returns a function-valued selection compatible with {@link Table#select}.\n * @return {SelectHelper} Selection function compatible with select().\n */\nexport function all() {\n return decorate(\n table => table.columnNames(),\n () => ({ all: [] })\n );\n}\n\n/**\n * Negate a column selection, selecting all other columns in a table.\n * Returns a function-valued selection compatible with {@link Table#select}.\n * @param {...any} selection The selection to negate. May be a column name,\n * column index, array of either, or a selection function (e.g., from range).\n * @return {SelectHelper} Selection function compatible with select().\n */\nexport function not(...selection) {\n selection = selection.flat();\n return decorate(\n table => {\n const drop = resolve(table, selection);\n return table.columnNames(name => !drop.has(name));\n },\n () => ({ not: toObject(selection) })\n );\n}\n\n/**\n * Select a contiguous range of columns.\n * @param {string|number} start The name/index of the first selected column.\n * @param {string|number} end The name/index of the last selected column.\n * @return {SelectHelper} Selection function compatible with select().\n */\nexport function range(start, end) {\n return decorate(\n table => {\n let i = isNumber(start) ? start : table.columnIndex(start);\n let j = isNumber(end) ? end : table.columnIndex(end);\n if (j < i) { const t = j; j = i; i = t; }\n return table.columnNames().slice(i, j + 1);\n },\n () => ({ range: [start, end] })\n );\n}\n\n/**\n * Select all columns whose names match a pattern.\n * @param {string|RegExp} pattern A string or regular expression pattern to match.\n * @return {SelectHelper} Selection function compatible with select().\n */\nexport function matches(pattern) {\n if (isString(pattern)) pattern = RegExp(escapeRegExp(pattern));\n return decorate(\n table => table.columnNames(name => pattern.test(name)),\n () => ({ matches: [pattern.source, pattern.flags] })\n );\n}\n\n/**\n * Select all columns whose names start with a string.\n * @param {string} string The string to match at the start of the column name.\n * @return {SelectHelper} Selection function compatible with select().\n */\nexport function startswith(string) {\n return matches(RegExp('^' + escapeRegExp(string)));\n}\n\n/**\n * Select all columns whose names end with a string.\n * @param {string} string The string to match at the end of the column name.\n * @return {SelectHelper} Selection function compatible with select().\n */\nexport function endswith(string) {\n return matches(RegExp(escapeRegExp(string) + '$'));\n}","import { defaultColumnFactory } from './column';\nimport columnsFrom from './columns-from';\nimport columnSet from './column-set';\nimport Table from './table';\nimport { nest, regroup, reindex } from './regroup';\nimport { rowObjectBuilder } from '../expression/row-object';\nimport { default as toArrow, toArrowIPC } from '../format/to-arrow';\nimport toCSV from '../format/to-csv';\nimport toHTML from '../format/to-html';\nimport toJSON from '../format/to-json';\nimport toMarkdown from '../format/to-markdown';\nimport resolve, { all } from '../helpers/selection';\nimport arrayType from '../util/array-type';\nimport entries from '../util/entries';\nimport error from '../util/error';\nimport mapObject from '../util/map-object';\n\n/**\n * Class representing a table backed by a named set of columns.\n */\nexport default class ColumnTable extends Table {\n\n /**\n * Create a new ColumnTable from existing input data.\n * @param {object[]|Iterable|object|Map} values The backing table data values.\n * If array-valued, should be a list of JavaScript objects with\n * key-value properties for each column value.\n * If object- or Map-valued, a table with two columns (one for keys,\n * one for values) will be created.\n * @param {string[]} [names] The named columns to include.\n * @return {ColumnTable} A new ColumnTable instance.\n */\n static from(values, names) {\n return new ColumnTable(columnsFrom(values, names), names);\n }\n\n /**\n * Create a new table for a set of named columns.\n * @param {object|Map} columns\n * The set of named column arrays. Keys are column names.\n * The enumeration order of the keys determines the column indices,\n * unless the names parameter is specified.\n * Values must be arrays (or array-like values) of identical length.\n * @param {string[]} [names] Ordered list of column names. If specified,\n * this array determines the column indices. If not specified, the\n * key enumeration order of the columns object is used.\n * @return {ColumnTable} the instantiated ColumnTable instance.\n */\n static new(columns, names) {\n if (columns instanceof ColumnTable) return columns;\n const data = {};\n const keys = [];\n for (const [key, value] of entries(columns)) {\n data[key] = value;\n keys.push(key);\n }\n return new ColumnTable(data, names || keys);\n }\n\n /**\n * Instantiate a new ColumnTable instance.\n * @param {object} columns An object mapping column names to values.\n * @param {string[]} [names] An ordered list of column names.\n * @param {BitSet} [filter] A filtering BitSet.\n * @param {GroupBySpec} [group] A groupby specification.\n * @param {RowComparator} [order] A row comparator function.\n * @param {Params} [params] An object mapping parameter names to values.\n */\n constructor(columns, names, filter, group, order, params) {\n mapObject(columns, defaultColumnFactory, columns);\n names = names || Object.keys(columns);\n const nrows = names.length ? columns[names[0]].length : 0;\n super(names, nrows, columns, filter, group, order, params);\n }\n\n /**\n * Create a new table with the same type as this table.\n * The new table may have different data, filter, grouping, or ordering\n * based on the values of the optional configuration argument. If a\n * setting is not specified, it is inherited from the current table.\n * @param {CreateOptions} [options] Creation options for the new table.\n * @return {ColumnTable} A newly created table.\n */\n create({ data, names, filter, groups, order }) {\n const f = filter !== undefined ? filter : this.mask();\n\n return new ColumnTable(\n data || this._data,\n names || (!data ? this._names : null),\n f,\n groups !== undefined ? groups : regroup(this._group, filter && f),\n order !== undefined ? order : this._order,\n this._params\n );\n }\n\n /**\n * Create a new table with additional columns drawn from one or more input\n * tables. All tables must have the same numer of rows and are reified\n * prior to assignment. In the case of repeated column names, input table\n * columns overwrite existing columns.\n * @param {...ColumnTable} tables The tables to merge with this table.\n * @return {ColumnTable} A new table with merged columns.\n * @example table.assign(table1, table2)\n */\n assign(...tables) {\n const nrows = this.numRows();\n const base = this.reify();\n const cset = columnSet(base).groupby(base.groups());\n tables.forEach(input => {\n input = ColumnTable.new(input);\n if (input.numRows() !== nrows) error('Assign row counts do not match');\n input = input.reify();\n input.columnNames(name => cset.add(name, input.column(name)));\n });\n return this.create(cset.new());\n }\n\n /**\n * Get the backing set of columns for this table.\n * @return {ColumnData} Object of named column instances.\n */\n columns() {\n return this._data;\n }\n\n /**\n * Get the column instance with the given name.\n * @param {string} name The column name.\n * @return {ColumnType | undefined} The named column, or undefined if it does not exist.\n */\n column(name) {\n return this._data[name];\n }\n\n /**\n * Get the column instance at the given index position.\n * @param {number} index The zero-based column index.\n * @return {ColumnType | undefined} The column, or undefined if it does not exist.\n */\n columnAt(index) {\n return this._data[this._names[index]];\n }\n\n /**\n * Get an array of values contained in a column. The resulting array\n * respects any table filter or orderby criteria.\n * @param {string} name The column name.\n * @param {ArrayConstructor|import('./table').TypedArrayConstructor} [constructor=Array]\n * The array constructor for instantiating the output array.\n * @return {import('./table').DataValue[]|import('./table).TypedArray} The array of column values.\n */\n array(name, constructor = Array) {\n const column = this.column(name);\n const array = new constructor(this.numRows());\n let idx = -1;\n this.scan(row => array[++idx] = column.get(row), true);\n return array;\n }\n\n /**\n * Get the value for the given column and row.\n * @param {string} name The column name.\n * @param {number} [row=0] The row index, defaults to zero if not specified.\n * @return {import('./table').DataValue} The table value at (column, row).\n */\n get(name, row = 0) {\n const column = this.column(name);\n return this.isFiltered() || this.isOrdered()\n ? column.get(this.indices()[row])\n : column.get(row);\n }\n\n /**\n * Returns an accessor (\"getter\") function for a column. The returned\n * function takes a row index as its single argument and returns the\n * corresponding column value.\n * @param {string} name The column name.\n * @return {import('./table').ColumnGetter} The column getter function.\n */\n getter(name) {\n const column = this.column(name);\n const indices = this.isFiltered() || this.isOrdered() ? this.indices() : null;\n return indices ? row => column.get(indices[row])\n : column ? row => column.get(row)\n : error(`Unrecognized column: ${name}`);\n }\n\n /**\n * Returns an object representing a table row.\n * @param {number} [row=0] The row index, defaults to zero if not specified.\n * @return {object} A row object with named properties for each column.\n */\n object(row = 0) {\n return objectBuilder(this)(row);\n }\n\n /**\n * Returns an array of objects representing table rows.\n * @param {ObjectsOptions} [options] The options for row object generation.\n * @return {object[]} An array of row objects.\n */\n objects(options = {}) {\n const { grouped, limit, offset } = options;\n\n // generate array of row objects\n const names = resolve(this, options.columns || all());\n const create = rowObjectBuilder(names);\n const obj = [];\n this.scan(\n (row, data) => obj.push(create(row, data)),\n true, limit, offset\n );\n\n // produce nested output as requested\n if (grouped && this.isGrouped()) {\n const idx = [];\n this.scan(row => idx.push(row), true, limit, offset);\n return nest(this, idx, obj, grouped);\n }\n\n return obj;\n }\n\n /**\n * Returns an iterator over objects representing table rows.\n * @return {Iterator} An iterator over row objects.\n */\n *[Symbol.iterator]() {\n const create = objectBuilder(this);\n const n = this.numRows();\n for (let i = 0; i < n; ++i) {\n yield create(i);\n }\n }\n\n /**\n * Create a new fully-materialized instance of this table.\n * All filter and orderby settings are removed from the new table.\n * Instead, the backing data itself is filtered and ordered as needed.\n * @param {number[]} [indices] Ordered row indices to materialize.\n * If unspecified, all rows passing the table filter are used.\n * @return {ColumnTable} A reified table.\n */\n reify(indices) {\n const nrows = indices ? indices.length : this.numRows();\n const names = this._names;\n let data, groups;\n\n if (!indices && !this.isOrdered()) {\n if (!this.isFiltered()) {\n return this; // data already reified\n } else if (nrows === this.totalRows()) {\n data = this.data(); // all rows pass filter, skip copy\n }\n }\n\n if (!data) {\n const scan = indices ? f => indices.forEach(f) : f => this.scan(f, true);\n const ncols = names.length;\n data = {};\n\n for (let i = 0; i < ncols; ++i) {\n const name = names[i];\n const prev = this.column(name);\n const curr = data[name] = new (arrayType(prev))(nrows);\n let r = -1;\n scan(row => curr[++r] = prev.get(row));\n }\n\n if (this.isGrouped()) {\n groups = reindex(this.groups(), scan, !!indices, nrows);\n }\n }\n\n return this.create({ data, names, groups, filter: null, order: null });\n }\n\n /**\n * Apply a sequence of transformations to this table. The output\n * of each transform is passed as input to the next transform, and\n * the output of the last transform is then returned.\n * @param {...(Transform|Transform[])} transforms Transformation\n * functions to apply to the table in sequence. Each function should\n * take a single table as input and return a table as output.\n * @return {ColumnTable} The output of the last transform.\n */\n transform(...transforms) {\n return transforms.flat().reduce((t, f) => f(t), this);\n }\n\n /**\n * Format this table as an Apache Arrow table.\n * @param {ArrowFormatOptions} [options] The formatting options.\n * @return {import('apache-arrow').Table} An Apache Arrow table.\n */\n toArrow(options) {\n return toArrow(this, options);\n }\n\n /**\n * Format this table as binary data in the Apache Arrow IPC format.\n * @param {ArrowFormatOptions} [options] The formatting options. Set {format: 'stream'} \n * or {format:\"file\"} for specific IPC format\n * @return {Uint8Array} A new Uint8Array of Arrow-encoded binary data.\n */\n toArrowBuffer(options) {\n return toArrowIPC(this, options);\n }\n\n /**\n * Format this table as a comma-separated values (CSV) string. Other\n * delimiters, such as tabs or pipes ('|'), can be specified using\n * the options argument.\n * @param {CSVFormatOptions} [options] The formatting options.\n * @return {string} A delimited value string.\n */\n toCSV(options) {\n return toCSV(this, options);\n }\n\n /**\n * Format this table as an HTML table string.\n * @param {HTMLFormatOptions} [options] The formatting options.\n * @return {string} An HTML table string.\n */\n toHTML(options) {\n return toHTML(this, options);\n }\n\n /**\n * Format this table as a JavaScript Object Notation (JSON) string.\n * @param {JSONFormatOptions} [options] The formatting options.\n * @return {string} A JSON string.\n */\n toJSON(options) {\n return toJSON(this, options);\n }\n\n /**\n * Format this table as a GitHub-Flavored Markdown table string.\n * @param {MarkdownFormatOptions} [options] The formatting options.\n * @return {string} A GitHub-Flavored Markdown table string.\n */\n toMarkdown(options) {\n return toMarkdown(this, options);\n }\n}\n\nfunction objectBuilder(table) {\n let b = table._builder;\n\n if (!b) {\n const create = rowObjectBuilder(table.columnNames());\n const data = table.data();\n if (table.isOrdered() || table.isFiltered()) {\n const indices = table.indices();\n b = row => create(indices[row], data);\n } else {\n b = row => create(row, data);\n }\n table._builder = b;\n }\n\n return b;\n}\n\n/**\n * A table transformation.\n * @typedef {(table: ColumnTable) => ColumnTable} Transform\n */\n\n/**\n * Proxy type for BitSet class.\n * @typedef {import('./table').BitSet} BitSet\n */\n\n/**\n * Proxy type for ColumnType interface.\n * @typedef {import('./column').ColumnType} ColumnType\n */\n\n/**\n * A named collection of columns.\n * @typedef {{[key: string]: ColumnType}} ColumnData\n */\n\n/**\n * Proxy type for GroupBySpec.\n * @typedef {import('./table').GroupBySpec} GroupBySpec\n */\n\n/**\n * Proxy type for RowComparator.\n * @typedef {import('./table').RowComparator} RowComparator\n */\n\n/**\n * Proxy type for Params.\n * @typedef {import('./table').Params} Params\n */\n\n/**\n * Options for Arrow formatting.\n * @typedef {import('../arrow/encode').ArrowFormatOptions} ArrowFormatOptions\n */\n\n/**\n * Options for CSV formatting.\n * @typedef {import('../format/to-csv').CSVFormatOptions} CSVFormatOptions\n */\n\n/**\n * Options for HTML formatting.\n * @typedef {import('../format/to-html').HTMLFormatOptions} HTMLFormatOptions\n */\n\n/**\n * Options for JSON formatting.\n * @typedef {import('../format/to-json').JSONFormatOptions} JSONFormatOptions\n */\n\n/**\n * Options for Markdown formatting.\n * @typedef {import('../format/to-markdown').MarkdownFormatOptions} MarkdownFormatOptions\n */\n","import isTypedArray from './is-typed-array';\n\nexport default function(column) {\n return isTypedArray(column.data) ? column.data.constructor : Array;\n}","import ColumnTable from '../table/column-table'; // eslint-disable-line no-unused-vars\n\nimport { columns, scan } from './util';\nimport { formatUTCDate } from '../util/format-date';\nimport isDate from '../util/is-date';\n\n/**\n * Options for CSV formatting.\n * @typedef {object} CSVFormatOptions\n * @property {string} [delimiter=','] The delimiter between values.\n * @property {number} [limit=Infinity] The maximum number of rows to print.\n * @property {number} [offset=0] The row offset indicating how many initial rows to skip.\n * @property {import('./util').ColumnSelectOptions} [columns] Ordered list\n * of column names to include. If function-valued, the function should\n * accept a table as input and return an array of column name strings.\n * @property {Object. any>} [format] Object of column\n * format options. The object keys should be column names. The object values\n * should be formatting functions to invoke to transform column values prior\n * to output. If specified, these override automatically inferred options.\n */\n\n/**\n * Format a table as a comma-separated values (CSV) string. Other\n * delimiters, such as tabs or pipes ('|'), can be specified using\n * the options argument.\n * @param {ColumnTable} table The table to format.\n * @param {CSVFormatOptions} options The formatting options.\n * @return {string} A delimited-value format string.\n */\nexport default function(table, options = {}) {\n const names = columns(table, options.columns);\n const format = options.format || {};\n const delim = options.delimiter || ',';\n const reFormat = new RegExp(`[\"${delim}\\n\\r]`);\n\n const formatValue = value => value == null ? ''\n : isDate(value) ? formatUTCDate(value, true)\n : reFormat.test(value += '') ? '\"' + value.replace(/\"/g, '\"\"') + '\"'\n : value;\n\n const vals = names.map(formatValue);\n let text = '';\n\n scan(table, names, options.limit || Infinity, options.offset, {\n row() {\n text += vals.join(delim) + '\\n';\n },\n cell(value, name, index) {\n vals[index] = formatValue(format[name] ? format[name](value) : value);\n }\n });\n\n return text + vals.join(delim);\n}","import ColumnTable from '../table/column-table'; // eslint-disable-line no-unused-vars\n\nimport formatValue from './value';\nimport { columns, formats, scan } from './util';\n\n/**\n * Options for Markdown formatting.\n * @typedef {object} MarkdownFormatOptions\n * @property {number} [limit=Infinity] The maximum number of rows to print.\n * @property {number} [offset=0] The row offset indicating how many initial rows to skip.\n * @property {import('./util').ColumnSelectOptions} [columns] Ordered list\n * of column names to include. If function-valued, the function should\n * accept a table as input and return an array of column name strings.\n * @property {import('./util').ColumnAlignOptions} [align] Object of column\n * alignment options. The object keys should be column names. The object\n * values should be aligment strings, one of 'l' (left), 'c' (center), or\n * 'r' (right). If specified, these override automatically inferred options.\n * @property {import('./util').ColumnFormatOptions} [format] Object of column\n * format options. The object keys should be column names. The object values\n * should be formatting functions or specification objects. If specified,\n * these override automatically inferred options.\n * @property {number} [maxdigits=6] The maximum number of fractional digits\n * to include when formatting numbers. This option is passed to the format\n * inference method and is overridden by any explicit format options.\n */\n\n/**\n * Format a table as a GitHub-Flavored Markdown table string.\n * @param {ColumnTable} table The table to format.\n * @param {MarkdownFormatOptions} options The formatting options.\n * @return {string} A GitHub-Flavored Markdown table string.\n */\nexport default function(table, options = {}) {\n const names = columns(table, options.columns);\n const { align, format } = formats(table, names, options);\n\n const alignValue = a => a === 'c' ? ':-:' : a === 'r' ? '-:' : ':-';\n const escape = s => s.replace(/\\|/g, '\\\\|');\n\n let text = '|'\n + names.map(escape).join('|')\n + '|\\n|'\n + names.map(name => alignValue(align[name])).join('|')\n + '|';\n\n scan(table, names, options.limit, options.offset, {\n row() {\n text += '\\n|';\n },\n cell(value, name) {\n text += escape(formatValue(value, format[name])) + '|';\n }\n });\n\n return text + '\\n';\n}","/**\n * Abstract class for custom aggregation operations.\n */\nexport default class Reducer {\n constructor(outputs) {\n this._outputs = outputs;\n }\n\n size() {\n return this._outputs.length;\n }\n\n outputs() {\n return this._outputs;\n }\n\n init(/* columns */) {\n return {};\n }\n\n add(/* state, row, data */) {\n // no-op, subclasses should override\n }\n\n rem(/* state, row, data */) {\n // no-op, subclasses should override\n }\n\n write(/* state, values, index */) {\n }\n}","export default function walk(node, ctx, visitors, parent) {\n const visit = visitors[node.type] || visitors['Default'];\n if (visit && visit(node, ctx, parent) === false) return;\n\n const walker = walkers[node.type];\n if (walker) walker(node, ctx, visitors);\n}\n\nconst unary = (node, ctx, visitors) => {\n walk(node.argument, ctx, visitors, node);\n};\n\nconst binary = (node, ctx, visitors) => {\n walk(node.left, ctx, visitors, node);\n walk(node.right, ctx, visitors, node);\n};\n\nconst ternary = (node, ctx, visitors) => {\n walk(node.test, ctx, visitors, node);\n walk(node.consequent, ctx, visitors, node);\n if (node.alternate) walk(node.alternate, ctx, visitors, node);\n};\n\nconst func = (node, ctx, visitors) => {\n list(node.params, ctx, visitors, node);\n walk(node.body, ctx, visitors, node);\n};\n\nconst call = (node, ctx, visitors) => {\n walk(node.callee, ctx, visitors, node);\n list(node.arguments, ctx, visitors, node);\n};\n\nconst list = (nodes, ctx, visitors, node) => {\n nodes.forEach(item => walk(item, ctx, visitors, node));\n};\n\nconst walkers = {\n TemplateLiteral: (node, ctx, visitors) => {\n list(node.expressions, ctx, visitors, node);\n list(node.quasis, ctx, visitors, node);\n },\n MemberExpression: (node, ctx, visitors) => {\n walk(node.object, ctx, visitors, node);\n walk(node.property, ctx, visitors, node);\n },\n CallExpression: call,\n NewExpression: call,\n ArrayExpression: (node, ctx, visitors) => {\n list(node.elements, ctx, visitors, node);\n },\n AssignmentExpression: binary,\n AwaitExpression: unary,\n BinaryExpression: binary,\n LogicalExpression: binary,\n UnaryExpression: unary,\n UpdateExpression: unary,\n ConditionalExpression: ternary,\n ObjectExpression: (node, ctx, visitors) => {\n list(node.properties, ctx, visitors, node);\n },\n Property: (node, ctx, visitors) => {\n walk(node.key, ctx, visitors, node);\n walk(node.value, ctx, visitors, node);\n },\n\n ArrowFunctionExpression: func,\n FunctionExpression: func,\n FunctionDeclaration: func,\n\n VariableDeclaration: (node, ctx, visitors) => {\n list(node.declarations, ctx, visitors, node);\n },\n VariableDeclarator: (node, ctx, visitors) => {\n walk(node.id, ctx, visitors, node);\n walk(node.init, ctx, visitors, node);\n },\n SpreadElement: (node, ctx, visitors) => {\n walk(node.argument, ctx, visitors, node);\n },\n\n BlockStatement: (node, ctx, visitors) => {\n list(node.body, ctx, visitors, node);\n },\n ExpressionStatement: (node, ctx, visitors) => {\n walk(node.expression, ctx, visitors, node);\n },\n IfStatement: ternary,\n ForStatement: (node, ctx, visitors) => {\n walk(node.init, ctx, visitors, node);\n walk(node.test, ctx, visitors, node);\n walk(node.update, ctx, visitors, node);\n walk(node.body, ctx, visitors, node);\n },\n WhileStatement: (node, ctx, visitors) => {\n walk(node.test, ctx, visitors, node);\n walk(node.body, ctx, visitors, node);\n },\n DoWhileStatement: (node, ctx, visitors) => {\n walk(node.body, ctx, visitors, node);\n walk(node.test, ctx, visitors, node);\n },\n SwitchStatement: (node, ctx, visitors) => {\n walk(node.discriminant, ctx, visitors, node);\n list(node.cases, ctx, visitors, node);\n },\n SwitchCase: (node, ctx, visitors) => {\n if (node.test) walk(node.test, ctx, visitors, node);\n list(node.consequent, ctx, visitors, node);\n },\n ReturnStatement: unary,\n\n Program: (node, ctx, visitors) => {\n walk(node.body[0], ctx, visitors, node);\n }\n};","import walk from './walk';\n\nfunction strip(node) {\n delete node.start;\n delete node.end;\n delete node.optional;\n}\n\nfunction stripMember(node) {\n strip(node);\n delete node.object;\n delete node.property;\n delete node.computed;\n if (!node.table) delete node.table;\n}\n\nexport default function(ast) {\n walk(ast, null, {\n Column: stripMember,\n Constant: stripMember,\n Default: strip\n });\n return ast;\n}","import { ArrowFunctionExpression, FunctionExpression } from './constants';\n\nexport function is(type, node) {\n return node && node.type === type;\n}\n\nexport function isFunctionExpression(node) {\n return is(FunctionExpression, node)\n || is(ArrowFunctionExpression, node);\n}","import compile from './compile';\nimport { rowObjectCode } from './row-object';\nimport error from '../util/error';\nimport toFunction from '../util/to-function';\n\nconst ERROR_ESC_AGGRONLY = 'Escaped functions are not valid as rollup or pivot values.';\n\nexport default function(ctx, spec, params) {\n if (ctx.aggronly) error(ERROR_ESC_AGGRONLY);\n\n // generate escaped function invocation code\n const code = '(row,data)=>fn('\n + rowObjectCode(ctx.table.columnNames())\n + ',$)';\n\n return { escape: compile.escape(code, toFunction(spec.expr), params) };\n}","import isFunction from './is-function';\n\nexport default function(value) {\n return isFunction(value) ? value : () => value;\n}","// This file was generated. Do not modify manually!\nvar astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];\n\n// This file was generated. Do not modify manually!\nvar astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938, 6, 4191];\n\n// This file was generated. Do not modify manually!\nvar nonASCIIidentifierChars = \"\\u200c\\u200d\\xb7\\u0300-\\u036f\\u0387\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u064b-\\u0669\\u0670\\u06d6-\\u06dc\\u06df-\\u06e4\\u06e7\\u06e8\\u06ea-\\u06ed\\u06f0-\\u06f9\\u0711\\u0730-\\u074a\\u07a6-\\u07b0\\u07c0-\\u07c9\\u07eb-\\u07f3\\u07fd\\u0816-\\u0819\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0859-\\u085b\\u0898-\\u089f\\u08ca-\\u08e1\\u08e3-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09cb-\\u09cd\\u09d7\\u09e2\\u09e3\\u09e6-\\u09ef\\u09fe\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2\\u0ae3\\u0ae6-\\u0aef\\u0afa-\\u0aff\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b55-\\u0b57\\u0b62\\u0b63\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c00-\\u0c04\\u0c3c\\u0c3e-\\u0c44\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62\\u0c63\\u0c66-\\u0c6f\\u0c81-\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2\\u0ce3\\u0ce6-\\u0cef\\u0cf3\\u0d00-\\u0d03\\u0d3b\\u0d3c\\u0d3e-\\u0d44\\u0d46-\\u0d48\\u0d4a-\\u0d4d\\u0d57\\u0d62\\u0d63\\u0d66-\\u0d6f\\u0d81-\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0de6-\\u0def\\u0df2\\u0df3\\u0e31\\u0e34-\\u0e3a\\u0e47-\\u0e4e\\u0e50-\\u0e59\\u0eb1\\u0eb4-\\u0ebc\\u0ec8-\\u0ece\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f3e\\u0f3f\\u0f71-\\u0f84\\u0f86\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u102b-\\u103e\\u1040-\\u1049\\u1056-\\u1059\\u105e-\\u1060\\u1062-\\u1064\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u1369-\\u1371\\u1712-\\u1715\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17b4-\\u17d3\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u180f-\\u1819\\u18a9\\u1920-\\u192b\\u1930-\\u193b\\u1946-\\u194f\\u19d0-\\u19da\\u1a17-\\u1a1b\\u1a55-\\u1a5e\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1ab0-\\u1abd\\u1abf-\\u1ace\\u1b00-\\u1b04\\u1b34-\\u1b44\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1b80-\\u1b82\\u1ba1-\\u1bad\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c24-\\u1c37\\u1c40-\\u1c49\\u1c50-\\u1c59\\u1cd0-\\u1cd2\\u1cd4-\\u1ce8\\u1ced\\u1cf4\\u1cf7-\\u1cf9\\u1dc0-\\u1dff\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2cef-\\u2cf1\\u2d7f\\u2de0-\\u2dff\\u302a-\\u302f\\u3099\\u309a\\ua620-\\ua629\\ua66f\\ua674-\\ua67d\\ua69e\\ua69f\\ua6f0\\ua6f1\\ua802\\ua806\\ua80b\\ua823-\\ua827\\ua82c\\ua880\\ua881\\ua8b4-\\ua8c5\\ua8d0-\\ua8d9\\ua8e0-\\ua8f1\\ua8ff-\\ua909\\ua926-\\ua92d\\ua947-\\ua953\\ua980-\\ua983\\ua9b3-\\ua9c0\\ua9d0-\\ua9d9\\ua9e5\\ua9f0-\\ua9f9\\uaa29-\\uaa36\\uaa43\\uaa4c\\uaa4d\\uaa50-\\uaa59\\uaa7b-\\uaa7d\\uaab0\\uaab2-\\uaab4\\uaab7\\uaab8\\uaabe\\uaabf\\uaac1\\uaaeb-\\uaaef\\uaaf5\\uaaf6\\uabe3-\\uabea\\uabec\\uabed\\uabf0-\\uabf9\\ufb1e\\ufe00-\\ufe0f\\ufe20-\\ufe2f\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f\";\n\n// This file was generated. Do not modify manually!\nvar nonASCIIidentifierStartChars = \"\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u037f\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u052f\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05d0-\\u05ea\\u05ef-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086a\\u0870-\\u0887\\u0889-\\u088e\\u08a0-\\u08c9\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u09fc\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0af9\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c39\\u0c3d\\u0c58-\\u0c5a\\u0c5d\\u0c60\\u0c61\\u0c80\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cdd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d04-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d54-\\u0d56\\u0d5f-\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e86-\\u0e8a\\u0e8c-\\u0ea3\\u0ea5\\u0ea7-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f5\\u13f8-\\u13fd\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f8\\u1700-\\u1711\\u171f-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1878\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191e\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19b0-\\u19c9\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4c\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1c80-\\u1c88\\u1c90-\\u1cba\\u1cbd-\\u1cbf\\u1ce9-\\u1cec\\u1cee-\\u1cf3\\u1cf5\\u1cf6\\u1cfa\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2118-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309b-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u31a0-\\u31bf\\u31f0-\\u31ff\\u3400-\\u4dbf\\u4e00-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua69d\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua7ca\\ua7d0\\ua7d1\\ua7d3\\ua7d5-\\ua7d9\\ua7f2-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua8fd\\ua8fe\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\ua9e0-\\ua9e4\\ua9e6-\\ua9ef\\ua9fa-\\ua9fe\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa7e-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uab30-\\uab5a\\uab5c-\\uab69\\uab70-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc\";\n\n// These are a run-length and offset encoded representation of the\n\n// Reserved word lists for various dialects of the language\n\nvar reservedWords = {\n 3: \"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile\",\n 5: \"class enum extends super const export import\",\n 6: \"enum\",\n strict: \"implements interface let package private protected public static yield\",\n strictBind: \"eval arguments\"\n};\n\n// And the keywords\n\nvar ecma5AndLessKeywords = \"break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this\";\n\nvar keywords$1 = {\n 5: ecma5AndLessKeywords,\n \"5module\": ecma5AndLessKeywords + \" export import\",\n 6: ecma5AndLessKeywords + \" const class extends export import super\"\n};\n\nvar keywordRelationalOperator = /^in(stanceof)?$/;\n\n// ## Character categories\n\nvar nonASCIIidentifierStart = new RegExp(\"[\" + nonASCIIidentifierStartChars + \"]\");\nvar nonASCIIidentifier = new RegExp(\"[\" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + \"]\");\n\n// This has a complexity linear to the value of the code. The\n// assumption is that looking up astral identifier characters is\n// rare.\nfunction isInAstralSet(code, set) {\n var pos = 0x10000;\n for (var i = 0; i < set.length; i += 2) {\n pos += set[i];\n if (pos > code) { return false }\n pos += set[i + 1];\n if (pos >= code) { return true }\n }\n return false\n}\n\n// Test whether a given character code starts an identifier.\n\nfunction isIdentifierStart(code, astral) {\n if (code < 65) { return code === 36 }\n if (code < 91) { return true }\n if (code < 97) { return code === 95 }\n if (code < 123) { return true }\n if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) }\n if (astral === false) { return false }\n return isInAstralSet(code, astralIdentifierStartCodes)\n}\n\n// Test whether a given character is part of an identifier.\n\nfunction isIdentifierChar(code, astral) {\n if (code < 48) { return code === 36 }\n if (code < 58) { return true }\n if (code < 65) { return false }\n if (code < 91) { return true }\n if (code < 97) { return code === 95 }\n if (code < 123) { return true }\n if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) }\n if (astral === false) { return false }\n return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)\n}\n\n// ## Token types\n\n// The assignment of fine-grained, information-carrying type objects\n// allows the tokenizer to store the information it has about a\n// token in a way that is very cheap for the parser to look up.\n\n// All token type variables start with an underscore, to make them\n// easy to recognize.\n\n// The `beforeExpr` property is used to disambiguate between regular\n// expressions and divisions. It is set on all token types that can\n// be followed by an expression (thus, a slash after them would be a\n// regular expression).\n//\n// The `startsExpr` property is used to check if the token ends a\n// `yield` expression. It is set on all token types that either can\n// directly start an expression (like a quotation mark) or can\n// continue an expression (like the body of a string).\n//\n// `isLoop` marks a keyword as starting a loop, which is important\n// to know when parsing a label, in order to allow or disallow\n// continue jumps to that label.\n\nvar TokenType = function TokenType(label, conf) {\n if ( conf === void 0 ) conf = {};\n\n this.label = label;\n this.keyword = conf.keyword;\n this.beforeExpr = !!conf.beforeExpr;\n this.startsExpr = !!conf.startsExpr;\n this.isLoop = !!conf.isLoop;\n this.isAssign = !!conf.isAssign;\n this.prefix = !!conf.prefix;\n this.postfix = !!conf.postfix;\n this.binop = conf.binop || null;\n this.updateContext = null;\n};\n\nfunction binop(name, prec) {\n return new TokenType(name, {beforeExpr: true, binop: prec})\n}\nvar beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true};\n\n// Map keyword names to token types.\n\nvar keywords = {};\n\n// Succinct definitions of keyword token types\nfunction kw(name, options) {\n if ( options === void 0 ) options = {};\n\n options.keyword = name;\n return keywords[name] = new TokenType(name, options)\n}\n\nvar types$1 = {\n num: new TokenType(\"num\", startsExpr),\n regexp: new TokenType(\"regexp\", startsExpr),\n string: new TokenType(\"string\", startsExpr),\n name: new TokenType(\"name\", startsExpr),\n privateId: new TokenType(\"privateId\", startsExpr),\n eof: new TokenType(\"eof\"),\n\n // Punctuation token types.\n bracketL: new TokenType(\"[\", {beforeExpr: true, startsExpr: true}),\n bracketR: new TokenType(\"]\"),\n braceL: new TokenType(\"{\", {beforeExpr: true, startsExpr: true}),\n braceR: new TokenType(\"}\"),\n parenL: new TokenType(\"(\", {beforeExpr: true, startsExpr: true}),\n parenR: new TokenType(\")\"),\n comma: new TokenType(\",\", beforeExpr),\n semi: new TokenType(\";\", beforeExpr),\n colon: new TokenType(\":\", beforeExpr),\n dot: new TokenType(\".\"),\n question: new TokenType(\"?\", beforeExpr),\n questionDot: new TokenType(\"?.\"),\n arrow: new TokenType(\"=>\", beforeExpr),\n template: new TokenType(\"template\"),\n invalidTemplate: new TokenType(\"invalidTemplate\"),\n ellipsis: new TokenType(\"...\", beforeExpr),\n backQuote: new TokenType(\"`\", startsExpr),\n dollarBraceL: new TokenType(\"${\", {beforeExpr: true, startsExpr: true}),\n\n // Operators. These carry several kinds of properties to help the\n // parser use them properly (the presence of these properties is\n // what categorizes them as operators).\n //\n // `binop`, when present, specifies that this operator is a binary\n // operator, and will refer to its precedence.\n //\n // `prefix` and `postfix` mark the operator as a prefix or postfix\n // unary operator.\n //\n // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as\n // binary operators with a very low precedence, that should result\n // in AssignmentExpression nodes.\n\n eq: new TokenType(\"=\", {beforeExpr: true, isAssign: true}),\n assign: new TokenType(\"_=\", {beforeExpr: true, isAssign: true}),\n incDec: new TokenType(\"++/--\", {prefix: true, postfix: true, startsExpr: true}),\n prefix: new TokenType(\"!/~\", {beforeExpr: true, prefix: true, startsExpr: true}),\n logicalOR: binop(\"||\", 1),\n logicalAND: binop(\"&&\", 2),\n bitwiseOR: binop(\"|\", 3),\n bitwiseXOR: binop(\"^\", 4),\n bitwiseAND: binop(\"&\", 5),\n equality: binop(\"==/!=/===/!==\", 6),\n relational: binop(\"/<=/>=\", 7),\n bitShift: binop(\"<>/>>>\", 8),\n plusMin: new TokenType(\"+/-\", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),\n modulo: binop(\"%\", 10),\n star: binop(\"*\", 10),\n slash: binop(\"/\", 10),\n starstar: new TokenType(\"**\", {beforeExpr: true}),\n coalesce: binop(\"??\", 1),\n\n // Keyword token types.\n _break: kw(\"break\"),\n _case: kw(\"case\", beforeExpr),\n _catch: kw(\"catch\"),\n _continue: kw(\"continue\"),\n _debugger: kw(\"debugger\"),\n _default: kw(\"default\", beforeExpr),\n _do: kw(\"do\", {isLoop: true, beforeExpr: true}),\n _else: kw(\"else\", beforeExpr),\n _finally: kw(\"finally\"),\n _for: kw(\"for\", {isLoop: true}),\n _function: kw(\"function\", startsExpr),\n _if: kw(\"if\"),\n _return: kw(\"return\", beforeExpr),\n _switch: kw(\"switch\"),\n _throw: kw(\"throw\", beforeExpr),\n _try: kw(\"try\"),\n _var: kw(\"var\"),\n _const: kw(\"const\"),\n _while: kw(\"while\", {isLoop: true}),\n _with: kw(\"with\"),\n _new: kw(\"new\", {beforeExpr: true, startsExpr: true}),\n _this: kw(\"this\", startsExpr),\n _super: kw(\"super\", startsExpr),\n _class: kw(\"class\", startsExpr),\n _extends: kw(\"extends\", beforeExpr),\n _export: kw(\"export\"),\n _import: kw(\"import\", startsExpr),\n _null: kw(\"null\", startsExpr),\n _true: kw(\"true\", startsExpr),\n _false: kw(\"false\", startsExpr),\n _in: kw(\"in\", {beforeExpr: true, binop: 7}),\n _instanceof: kw(\"instanceof\", {beforeExpr: true, binop: 7}),\n _typeof: kw(\"typeof\", {beforeExpr: true, prefix: true, startsExpr: true}),\n _void: kw(\"void\", {beforeExpr: true, prefix: true, startsExpr: true}),\n _delete: kw(\"delete\", {beforeExpr: true, prefix: true, startsExpr: true})\n};\n\n// Matches a whole line break (where CRLF is considered a single\n// line break). Used to count lines.\n\nvar lineBreak = /\\r\\n?|\\n|\\u2028|\\u2029/;\nvar lineBreakG = new RegExp(lineBreak.source, \"g\");\n\nfunction isNewLine(code) {\n return code === 10 || code === 13 || code === 0x2028 || code === 0x2029\n}\n\nfunction nextLineBreak(code, from, end) {\n if ( end === void 0 ) end = code.length;\n\n for (var i = from; i < end; i++) {\n var next = code.charCodeAt(i);\n if (isNewLine(next))\n { return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10 ? i + 2 : i + 1 }\n }\n return -1\n}\n\nvar nonASCIIwhitespace = /[\\u1680\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/;\n\nvar skipWhiteSpace = /(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g;\n\nvar ref = Object.prototype;\nvar hasOwnProperty = ref.hasOwnProperty;\nvar toString = ref.toString;\n\nvar hasOwn = Object.hasOwn || (function (obj, propName) { return (\n hasOwnProperty.call(obj, propName)\n); });\n\nvar isArray = Array.isArray || (function (obj) { return (\n toString.call(obj) === \"[object Array]\"\n); });\n\nfunction wordsRegexp(words) {\n return new RegExp(\"^(?:\" + words.replace(/ /g, \"|\") + \")$\")\n}\n\nfunction codePointToString(code) {\n // UTF-16 Decoding\n if (code <= 0xFFFF) { return String.fromCharCode(code) }\n code -= 0x10000;\n return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00)\n}\n\nvar loneSurrogate = /(?:[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/;\n\n// These are used when `options.locations` is on, for the\n// `startLoc` and `endLoc` properties.\n\nvar Position = function Position(line, col) {\n this.line = line;\n this.column = col;\n};\n\nPosition.prototype.offset = function offset (n) {\n return new Position(this.line, this.column + n)\n};\n\nvar SourceLocation = function SourceLocation(p, start, end) {\n this.start = start;\n this.end = end;\n if (p.sourceFile !== null) { this.source = p.sourceFile; }\n};\n\n// The `getLineInfo` function is mostly useful when the\n// `locations` option is off (for performance reasons) and you\n// want to find the line/column position for a given character\n// offset. `input` should be the code string that the offset refers\n// into.\n\nfunction getLineInfo(input, offset) {\n for (var line = 1, cur = 0;;) {\n var nextBreak = nextLineBreak(input, cur, offset);\n if (nextBreak < 0) { return new Position(line, offset - cur) }\n ++line;\n cur = nextBreak;\n }\n}\n\n// A second argument must be given to configure the parser process.\n// These options are recognized (only `ecmaVersion` is required):\n\nvar defaultOptions = {\n // `ecmaVersion` indicates the ECMAScript version to parse. Must be\n // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10\n // (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `\"latest\"`\n // (the latest version the library supports). This influences\n // support for strict mode, the set of reserved words, and support\n // for new syntax features.\n ecmaVersion: null,\n // `sourceType` indicates the mode the code should be parsed in.\n // Can be either `\"script\"` or `\"module\"`. This influences global\n // strict mode and parsing of `import` and `export` declarations.\n sourceType: \"script\",\n // `onInsertedSemicolon` can be a callback that will be called\n // when a semicolon is automatically inserted. It will be passed\n // the position of the comma as an offset, and if `locations` is\n // enabled, it is given the location as a `{line, column}` object\n // as second argument.\n onInsertedSemicolon: null,\n // `onTrailingComma` is similar to `onInsertedSemicolon`, but for\n // trailing commas.\n onTrailingComma: null,\n // By default, reserved words are only enforced if ecmaVersion >= 5.\n // Set `allowReserved` to a boolean value to explicitly turn this on\n // an off. When this option has the value \"never\", reserved words\n // and keywords can also not be used as property names.\n allowReserved: null,\n // When enabled, a return at the top level is not considered an\n // error.\n allowReturnOutsideFunction: false,\n // When enabled, import/export statements are not constrained to\n // appearing at the top of the program, and an import.meta expression\n // in a script isn't considered an error.\n allowImportExportEverywhere: false,\n // By default, await identifiers are allowed to appear at the top-level scope only if ecmaVersion >= 2022.\n // When enabled, await identifiers are allowed to appear at the top-level scope,\n // but they are still not allowed in non-async functions.\n allowAwaitOutsideFunction: null,\n // When enabled, super identifiers are not constrained to\n // appearing in methods and do not raise an error when they appear elsewhere.\n allowSuperOutsideMethod: null,\n // When enabled, hashbang directive in the beginning of file is\n // allowed and treated as a line comment. Enabled by default when\n // `ecmaVersion` >= 2023.\n allowHashBang: false,\n // When `locations` is on, `loc` properties holding objects with\n // `start` and `end` properties in `{line, column}` form (with\n // line being 1-based and column 0-based) will be attached to the\n // nodes.\n locations: false,\n // A function can be passed as `onToken` option, which will\n // cause Acorn to call that function with object in the same\n // format as tokens returned from `tokenizer().getToken()`. Note\n // that you are not allowed to call the parser from the\n // callback—that will corrupt its internal state.\n onToken: null,\n // A function can be passed as `onComment` option, which will\n // cause Acorn to call that function with `(block, text, start,\n // end)` parameters whenever a comment is skipped. `block` is a\n // boolean indicating whether this is a block (`/* */`) comment,\n // `text` is the content of the comment, and `start` and `end` are\n // character offsets that denote the start and end of the comment.\n // When the `locations` option is on, two more parameters are\n // passed, the full `{line, column}` locations of the start and\n // end of the comments. Note that you are not allowed to call the\n // parser from the callback—that will corrupt its internal state.\n onComment: null,\n // Nodes have their start and end characters offsets recorded in\n // `start` and `end` properties (directly on the node, rather than\n // the `loc` object, which holds line/column data. To also add a\n // [semi-standardized][range] `range` property holding a `[start,\n // end]` array with the same numbers, set the `ranges` option to\n // `true`.\n //\n // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678\n ranges: false,\n // It is possible to parse multiple files into a single AST by\n // passing the tree produced by parsing the first file as\n // `program` option in subsequent parses. This will add the\n // toplevel forms of the parsed file to the `Program` (top) node\n // of an existing parse tree.\n program: null,\n // When `locations` is on, you can pass this to record the source\n // file in every node's `loc` object.\n sourceFile: null,\n // This value, if given, is stored in every node, whether\n // `locations` is on or off.\n directSourceFile: null,\n // When enabled, parenthesized expressions are represented by\n // (non-standard) ParenthesizedExpression nodes\n preserveParens: false\n};\n\n// Interpret and default an options object\n\nvar warnedAboutEcmaVersion = false;\n\nfunction getOptions(opts) {\n var options = {};\n\n for (var opt in defaultOptions)\n { options[opt] = opts && hasOwn(opts, opt) ? opts[opt] : defaultOptions[opt]; }\n\n if (options.ecmaVersion === \"latest\") {\n options.ecmaVersion = 1e8;\n } else if (options.ecmaVersion == null) {\n if (!warnedAboutEcmaVersion && typeof console === \"object\" && console.warn) {\n warnedAboutEcmaVersion = true;\n console.warn(\"Since Acorn 8.0.0, options.ecmaVersion is required.\\nDefaulting to 2020, but this will stop working in the future.\");\n }\n options.ecmaVersion = 11;\n } else if (options.ecmaVersion >= 2015) {\n options.ecmaVersion -= 2009;\n }\n\n if (options.allowReserved == null)\n { options.allowReserved = options.ecmaVersion < 5; }\n\n if (!opts || opts.allowHashBang == null)\n { options.allowHashBang = options.ecmaVersion >= 14; }\n\n if (isArray(options.onToken)) {\n var tokens = options.onToken;\n options.onToken = function (token) { return tokens.push(token); };\n }\n if (isArray(options.onComment))\n { options.onComment = pushComment(options, options.onComment); }\n\n return options\n}\n\nfunction pushComment(options, array) {\n return function(block, text, start, end, startLoc, endLoc) {\n var comment = {\n type: block ? \"Block\" : \"Line\",\n value: text,\n start: start,\n end: end\n };\n if (options.locations)\n { comment.loc = new SourceLocation(this, startLoc, endLoc); }\n if (options.ranges)\n { comment.range = [start, end]; }\n array.push(comment);\n }\n}\n\n// Each scope gets a bitset that may contain these flags\nvar\n SCOPE_TOP = 1,\n SCOPE_FUNCTION = 2,\n SCOPE_ASYNC = 4,\n SCOPE_GENERATOR = 8,\n SCOPE_ARROW = 16,\n SCOPE_SIMPLE_CATCH = 32,\n SCOPE_SUPER = 64,\n SCOPE_DIRECT_SUPER = 128,\n SCOPE_CLASS_STATIC_BLOCK = 256,\n SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;\n\nfunction functionFlags(async, generator) {\n return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0)\n}\n\n// Used in checkLVal* and declareName to determine the type of a binding\nvar\n BIND_NONE = 0, // Not a binding\n BIND_VAR = 1, // Var-style binding\n BIND_LEXICAL = 2, // Let- or const-style binding\n BIND_FUNCTION = 3, // Function declaration\n BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding\n BIND_OUTSIDE = 5; // Special case for function names as bound inside the function\n\nvar Parser = function Parser(options, input, startPos) {\n this.options = options = getOptions(options);\n this.sourceFile = options.sourceFile;\n this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === \"module\" ? \"5module\" : 5]);\n var reserved = \"\";\n if (options.allowReserved !== true) {\n reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3];\n if (options.sourceType === \"module\") { reserved += \" await\"; }\n }\n this.reservedWords = wordsRegexp(reserved);\n var reservedStrict = (reserved ? reserved + \" \" : \"\") + reservedWords.strict;\n this.reservedWordsStrict = wordsRegexp(reservedStrict);\n this.reservedWordsStrictBind = wordsRegexp(reservedStrict + \" \" + reservedWords.strictBind);\n this.input = String(input);\n\n // Used to signal to callers of `readWord1` whether the word\n // contained any escape sequences. This is needed because words with\n // escape sequences must not be interpreted as keywords.\n this.containsEsc = false;\n\n // Set up token state\n\n // The current position of the tokenizer in the input.\n if (startPos) {\n this.pos = startPos;\n this.lineStart = this.input.lastIndexOf(\"\\n\", startPos - 1) + 1;\n this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;\n } else {\n this.pos = this.lineStart = 0;\n this.curLine = 1;\n }\n\n // Properties of the current token:\n // Its type\n this.type = types$1.eof;\n // For tokens that include more information than their type, the value\n this.value = null;\n // Its start and end offset\n this.start = this.end = this.pos;\n // And, if locations are used, the {line, column} object\n // corresponding to those offsets\n this.startLoc = this.endLoc = this.curPosition();\n\n // Position information for the previous token\n this.lastTokEndLoc = this.lastTokStartLoc = null;\n this.lastTokStart = this.lastTokEnd = this.pos;\n\n // The context stack is used to superficially track syntactic\n // context to predict whether a regular expression is allowed in a\n // given position.\n this.context = this.initialContext();\n this.exprAllowed = true;\n\n // Figure out if it's a module code.\n this.inModule = options.sourceType === \"module\";\n this.strict = this.inModule || this.strictDirective(this.pos);\n\n // Used to signify the start of a potential arrow function\n this.potentialArrowAt = -1;\n this.potentialArrowInForAwait = false;\n\n // Positions to delayed-check that yield/await does not exist in default parameters.\n this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;\n // Labels in scope.\n this.labels = [];\n // Thus-far undefined exports.\n this.undefinedExports = Object.create(null);\n\n // If enabled, skip leading hashbang line.\n if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === \"#!\")\n { this.skipLineComment(2); }\n\n // Scope tracking for duplicate variable names (see scope.js)\n this.scopeStack = [];\n this.enterScope(SCOPE_TOP);\n\n // For RegExp validation\n this.regexpState = null;\n\n // The stack of private names.\n // Each element has two properties: 'declared' and 'used'.\n // When it exited from the outermost class definition, all used private names must be declared.\n this.privateNameStack = [];\n};\n\nvar prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },inClassStaticBlock: { configurable: true } };\n\nParser.prototype.parse = function parse () {\n var node = this.options.program || this.startNode();\n this.nextToken();\n return this.parseTopLevel(node)\n};\n\nprototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };\n\nprototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit };\n\nprototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit };\n\nprototypeAccessors.canAwait.get = function () {\n for (var i = this.scopeStack.length - 1; i >= 0; i--) {\n var scope = this.scopeStack[i];\n if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false }\n if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 }\n }\n return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction\n};\n\nprototypeAccessors.allowSuper.get = function () {\n var ref = this.currentThisScope();\n var flags = ref.flags;\n var inClassFieldInit = ref.inClassFieldInit;\n return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod\n};\n\nprototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 };\n\nprototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) };\n\nprototypeAccessors.allowNewDotTarget.get = function () {\n var ref = this.currentThisScope();\n var flags = ref.flags;\n var inClassFieldInit = ref.inClassFieldInit;\n return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit\n};\n\nprototypeAccessors.inClassStaticBlock.get = function () {\n return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0\n};\n\nParser.extend = function extend () {\n var plugins = [], len = arguments.length;\n while ( len-- ) plugins[ len ] = arguments[ len ];\n\n var cls = this;\n for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); }\n return cls\n};\n\nParser.parse = function parse (input, options) {\n return new this(options, input).parse()\n};\n\nParser.parseExpressionAt = function parseExpressionAt (input, pos, options) {\n var parser = new this(options, input, pos);\n parser.nextToken();\n return parser.parseExpression()\n};\n\nParser.tokenizer = function tokenizer (input, options) {\n return new this(options, input)\n};\n\nObject.defineProperties( Parser.prototype, prototypeAccessors );\n\nvar pp$9 = Parser.prototype;\n\n// ## Parser utilities\n\nvar literal = /^(?:'((?:\\\\.|[^'\\\\])*?)'|\"((?:\\\\.|[^\"\\\\])*?)\")/;\npp$9.strictDirective = function(start) {\n if (this.options.ecmaVersion < 5) { return false }\n for (;;) {\n // Try to find string literal.\n skipWhiteSpace.lastIndex = start;\n start += skipWhiteSpace.exec(this.input)[0].length;\n var match = literal.exec(this.input.slice(start));\n if (!match) { return false }\n if ((match[1] || match[2]) === \"use strict\") {\n skipWhiteSpace.lastIndex = start + match[0].length;\n var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;\n var next = this.input.charAt(end);\n return next === \";\" || next === \"}\" ||\n (lineBreak.test(spaceAfter[0]) &&\n !(/[(`.[+\\-/*%<>=,?^&]/.test(next) || next === \"!\" && this.input.charAt(end + 1) === \"=\"))\n }\n start += match[0].length;\n\n // Skip semicolon, if any.\n skipWhiteSpace.lastIndex = start;\n start += skipWhiteSpace.exec(this.input)[0].length;\n if (this.input[start] === \";\")\n { start++; }\n }\n};\n\n// Predicate that tests whether the next token is of the given\n// type, and if yes, consumes it as a side effect.\n\npp$9.eat = function(type) {\n if (this.type === type) {\n this.next();\n return true\n } else {\n return false\n }\n};\n\n// Tests whether parsed token is a contextual keyword.\n\npp$9.isContextual = function(name) {\n return this.type === types$1.name && this.value === name && !this.containsEsc\n};\n\n// Consumes contextual keyword if possible.\n\npp$9.eatContextual = function(name) {\n if (!this.isContextual(name)) { return false }\n this.next();\n return true\n};\n\n// Asserts that following token is given contextual keyword.\n\npp$9.expectContextual = function(name) {\n if (!this.eatContextual(name)) { this.unexpected(); }\n};\n\n// Test whether a semicolon can be inserted at the current position.\n\npp$9.canInsertSemicolon = function() {\n return this.type === types$1.eof ||\n this.type === types$1.braceR ||\n lineBreak.test(this.input.slice(this.lastTokEnd, this.start))\n};\n\npp$9.insertSemicolon = function() {\n if (this.canInsertSemicolon()) {\n if (this.options.onInsertedSemicolon)\n { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); }\n return true\n }\n};\n\n// Consume a semicolon, or, failing that, see if we are allowed to\n// pretend that there is a semicolon at this position.\n\npp$9.semicolon = function() {\n if (!this.eat(types$1.semi) && !this.insertSemicolon()) { this.unexpected(); }\n};\n\npp$9.afterTrailingComma = function(tokType, notNext) {\n if (this.type === tokType) {\n if (this.options.onTrailingComma)\n { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); }\n if (!notNext)\n { this.next(); }\n return true\n }\n};\n\n// Expect a token of a given type. If found, consume it, otherwise,\n// raise an unexpected token error.\n\npp$9.expect = function(type) {\n this.eat(type) || this.unexpected();\n};\n\n// Raise an unexpected token error.\n\npp$9.unexpected = function(pos) {\n this.raise(pos != null ? pos : this.start, \"Unexpected token\");\n};\n\nvar DestructuringErrors = function DestructuringErrors() {\n this.shorthandAssign =\n this.trailingComma =\n this.parenthesizedAssign =\n this.parenthesizedBind =\n this.doubleProto =\n -1;\n};\n\npp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {\n if (!refDestructuringErrors) { return }\n if (refDestructuringErrors.trailingComma > -1)\n { this.raiseRecoverable(refDestructuringErrors.trailingComma, \"Comma is not permitted after the rest element\"); }\n var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;\n if (parens > -1) { this.raiseRecoverable(parens, isAssign ? \"Assigning to rvalue\" : \"Parenthesized pattern\"); }\n};\n\npp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {\n if (!refDestructuringErrors) { return false }\n var shorthandAssign = refDestructuringErrors.shorthandAssign;\n var doubleProto = refDestructuringErrors.doubleProto;\n if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 }\n if (shorthandAssign >= 0)\n { this.raise(shorthandAssign, \"Shorthand property assignments are valid only in destructuring patterns\"); }\n if (doubleProto >= 0)\n { this.raiseRecoverable(doubleProto, \"Redefinition of __proto__ property\"); }\n};\n\npp$9.checkYieldAwaitInDefaultParams = function() {\n if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))\n { this.raise(this.yieldPos, \"Yield expression cannot be a default value\"); }\n if (this.awaitPos)\n { this.raise(this.awaitPos, \"Await expression cannot be a default value\"); }\n};\n\npp$9.isSimpleAssignTarget = function(expr) {\n if (expr.type === \"ParenthesizedExpression\")\n { return this.isSimpleAssignTarget(expr.expression) }\n return expr.type === \"Identifier\" || expr.type === \"MemberExpression\"\n};\n\nvar pp$8 = Parser.prototype;\n\n// ### Statement parsing\n\n// Parse a program. Initializes the parser, reads any number of\n// statements, and wraps them in a Program node. Optionally takes a\n// `program` argument. If present, the statements will be appended\n// to its body instead of creating a new node.\n\npp$8.parseTopLevel = function(node) {\n var exports = Object.create(null);\n if (!node.body) { node.body = []; }\n while (this.type !== types$1.eof) {\n var stmt = this.parseStatement(null, true, exports);\n node.body.push(stmt);\n }\n if (this.inModule)\n { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1)\n {\n var name = list[i];\n\n this.raiseRecoverable(this.undefinedExports[name].start, (\"Export '\" + name + \"' is not defined\"));\n } }\n this.adaptDirectivePrologue(node.body);\n this.next();\n node.sourceType = this.options.sourceType;\n return this.finishNode(node, \"Program\")\n};\n\nvar loopLabel = {kind: \"loop\"}, switchLabel = {kind: \"switch\"};\n\npp$8.isLet = function(context) {\n if (this.options.ecmaVersion < 6 || !this.isContextual(\"let\")) { return false }\n skipWhiteSpace.lastIndex = this.pos;\n var skip = skipWhiteSpace.exec(this.input);\n var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);\n // For ambiguous cases, determine if a LexicalDeclaration (or only a\n // Statement) is allowed here. If context is not empty then only a Statement\n // is allowed. However, `let [` is an explicit negative lookahead for\n // ExpressionStatement, so special-case it first.\n if (nextCh === 91 || nextCh === 92) { return true } // '[', '/'\n if (context) { return false }\n\n if (nextCh === 123 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral\n if (isIdentifierStart(nextCh, true)) {\n var pos = next + 1;\n while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; }\n if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true }\n var ident = this.input.slice(next, pos);\n if (!keywordRelationalOperator.test(ident)) { return true }\n }\n return false\n};\n\n// check 'async [no LineTerminator here] function'\n// - 'async /*foo*/ function' is OK.\n// - 'async /*\\n*/ function' is invalid.\npp$8.isAsyncFunction = function() {\n if (this.options.ecmaVersion < 8 || !this.isContextual(\"async\"))\n { return false }\n\n skipWhiteSpace.lastIndex = this.pos;\n var skip = skipWhiteSpace.exec(this.input);\n var next = this.pos + skip[0].length, after;\n return !lineBreak.test(this.input.slice(this.pos, next)) &&\n this.input.slice(next, next + 8) === \"function\" &&\n (next + 8 === this.input.length ||\n !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))\n};\n\n// Parse a single statement.\n//\n// If expecting a statement and finding a slash operator, parse a\n// regular expression literal. This is to handle cases like\n// `if (foo) /blah/.exec(foo)`, where looking at the previous token\n// does not help.\n\npp$8.parseStatement = function(context, topLevel, exports) {\n var starttype = this.type, node = this.startNode(), kind;\n\n if (this.isLet(context)) {\n starttype = types$1._var;\n kind = \"let\";\n }\n\n // Most types of statements are recognized by the keyword they\n // start with. Many are trivial to parse, some require a bit of\n // complexity.\n\n switch (starttype) {\n case types$1._break: case types$1._continue: return this.parseBreakContinueStatement(node, starttype.keyword)\n case types$1._debugger: return this.parseDebuggerStatement(node)\n case types$1._do: return this.parseDoStatement(node)\n case types$1._for: return this.parseForStatement(node)\n case types$1._function:\n // Function as sole body of either an if statement or a labeled statement\n // works, but not when it is part of a labeled statement that is the sole\n // body of an if statement.\n if ((context && (this.strict || context !== \"if\" && context !== \"label\")) && this.options.ecmaVersion >= 6) { this.unexpected(); }\n return this.parseFunctionStatement(node, false, !context)\n case types$1._class:\n if (context) { this.unexpected(); }\n return this.parseClass(node, true)\n case types$1._if: return this.parseIfStatement(node)\n case types$1._return: return this.parseReturnStatement(node)\n case types$1._switch: return this.parseSwitchStatement(node)\n case types$1._throw: return this.parseThrowStatement(node)\n case types$1._try: return this.parseTryStatement(node)\n case types$1._const: case types$1._var:\n kind = kind || this.value;\n if (context && kind !== \"var\") { this.unexpected(); }\n return this.parseVarStatement(node, kind)\n case types$1._while: return this.parseWhileStatement(node)\n case types$1._with: return this.parseWithStatement(node)\n case types$1.braceL: return this.parseBlock(true, node)\n case types$1.semi: return this.parseEmptyStatement(node)\n case types$1._export:\n case types$1._import:\n if (this.options.ecmaVersion > 10 && starttype === types$1._import) {\n skipWhiteSpace.lastIndex = this.pos;\n var skip = skipWhiteSpace.exec(this.input);\n var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);\n if (nextCh === 40 || nextCh === 46) // '(' or '.'\n { return this.parseExpressionStatement(node, this.parseExpression()) }\n }\n\n if (!this.options.allowImportExportEverywhere) {\n if (!topLevel)\n { this.raise(this.start, \"'import' and 'export' may only appear at the top level\"); }\n if (!this.inModule)\n { this.raise(this.start, \"'import' and 'export' may appear only with 'sourceType: module'\"); }\n }\n return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)\n\n // If the statement does not start with a statement keyword or a\n // brace, it's an ExpressionStatement or LabeledStatement. We\n // simply start parsing an expression, and afterwards, if the\n // next token is a colon and the expression was a simple\n // Identifier node, we switch to interpreting it as a label.\n default:\n if (this.isAsyncFunction()) {\n if (context) { this.unexpected(); }\n this.next();\n return this.parseFunctionStatement(node, true, !context)\n }\n\n var maybeName = this.value, expr = this.parseExpression();\n if (starttype === types$1.name && expr.type === \"Identifier\" && this.eat(types$1.colon))\n { return this.parseLabeledStatement(node, maybeName, expr, context) }\n else { return this.parseExpressionStatement(node, expr) }\n }\n};\n\npp$8.parseBreakContinueStatement = function(node, keyword) {\n var isBreak = keyword === \"break\";\n this.next();\n if (this.eat(types$1.semi) || this.insertSemicolon()) { node.label = null; }\n else if (this.type !== types$1.name) { this.unexpected(); }\n else {\n node.label = this.parseIdent();\n this.semicolon();\n }\n\n // Verify that there is an actual destination to break or\n // continue to.\n var i = 0;\n for (; i < this.labels.length; ++i) {\n var lab = this.labels[i];\n if (node.label == null || lab.name === node.label.name) {\n if (lab.kind != null && (isBreak || lab.kind === \"loop\")) { break }\n if (node.label && isBreak) { break }\n }\n }\n if (i === this.labels.length) { this.raise(node.start, \"Unsyntactic \" + keyword); }\n return this.finishNode(node, isBreak ? \"BreakStatement\" : \"ContinueStatement\")\n};\n\npp$8.parseDebuggerStatement = function(node) {\n this.next();\n this.semicolon();\n return this.finishNode(node, \"DebuggerStatement\")\n};\n\npp$8.parseDoStatement = function(node) {\n this.next();\n this.labels.push(loopLabel);\n node.body = this.parseStatement(\"do\");\n this.labels.pop();\n this.expect(types$1._while);\n node.test = this.parseParenExpression();\n if (this.options.ecmaVersion >= 6)\n { this.eat(types$1.semi); }\n else\n { this.semicolon(); }\n return this.finishNode(node, \"DoWhileStatement\")\n};\n\n// Disambiguating between a `for` and a `for`/`in` or `for`/`of`\n// loop is non-trivial. Basically, we have to parse the init `var`\n// statement or expression, disallowing the `in` operator (see\n// the second parameter to `parseExpression`), and then check\n// whether the next token is `in` or `of`. When there is no init\n// part (semicolon immediately after the opening parenthesis), it\n// is a regular `for` loop.\n\npp$8.parseForStatement = function(node) {\n this.next();\n var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual(\"await\")) ? this.lastTokStart : -1;\n this.labels.push(loopLabel);\n this.enterScope(0);\n this.expect(types$1.parenL);\n if (this.type === types$1.semi) {\n if (awaitAt > -1) { this.unexpected(awaitAt); }\n return this.parseFor(node, null)\n }\n var isLet = this.isLet();\n if (this.type === types$1._var || this.type === types$1._const || isLet) {\n var init$1 = this.startNode(), kind = isLet ? \"let\" : this.value;\n this.next();\n this.parseVar(init$1, true, kind);\n this.finishNode(init$1, \"VariableDeclaration\");\n if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual(\"of\"))) && init$1.declarations.length === 1) {\n if (this.options.ecmaVersion >= 9) {\n if (this.type === types$1._in) {\n if (awaitAt > -1) { this.unexpected(awaitAt); }\n } else { node.await = awaitAt > -1; }\n }\n return this.parseForIn(node, init$1)\n }\n if (awaitAt > -1) { this.unexpected(awaitAt); }\n return this.parseFor(node, init$1)\n }\n var startsWithLet = this.isContextual(\"let\"), isForOf = false;\n var refDestructuringErrors = new DestructuringErrors;\n var init = this.parseExpression(awaitAt > -1 ? \"await\" : true, refDestructuringErrors);\n if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual(\"of\"))) {\n if (this.options.ecmaVersion >= 9) {\n if (this.type === types$1._in) {\n if (awaitAt > -1) { this.unexpected(awaitAt); }\n } else { node.await = awaitAt > -1; }\n }\n if (startsWithLet && isForOf) { this.raise(init.start, \"The left-hand side of a for-of loop may not start with 'let'.\"); }\n this.toAssignable(init, false, refDestructuringErrors);\n this.checkLValPattern(init);\n return this.parseForIn(node, init)\n } else {\n this.checkExpressionErrors(refDestructuringErrors, true);\n }\n if (awaitAt > -1) { this.unexpected(awaitAt); }\n return this.parseFor(node, init)\n};\n\npp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {\n this.next();\n return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)\n};\n\npp$8.parseIfStatement = function(node) {\n this.next();\n node.test = this.parseParenExpression();\n // allow function declarations in branches, but only in non-strict mode\n node.consequent = this.parseStatement(\"if\");\n node.alternate = this.eat(types$1._else) ? this.parseStatement(\"if\") : null;\n return this.finishNode(node, \"IfStatement\")\n};\n\npp$8.parseReturnStatement = function(node) {\n if (!this.inFunction && !this.options.allowReturnOutsideFunction)\n { this.raise(this.start, \"'return' outside of function\"); }\n this.next();\n\n // In `return` (and `break`/`continue`), the keywords with\n // optional arguments, we eagerly look for a semicolon or the\n // possibility to insert one.\n\n if (this.eat(types$1.semi) || this.insertSemicolon()) { node.argument = null; }\n else { node.argument = this.parseExpression(); this.semicolon(); }\n return this.finishNode(node, \"ReturnStatement\")\n};\n\npp$8.parseSwitchStatement = function(node) {\n this.next();\n node.discriminant = this.parseParenExpression();\n node.cases = [];\n this.expect(types$1.braceL);\n this.labels.push(switchLabel);\n this.enterScope(0);\n\n // Statements under must be grouped (by label) in SwitchCase\n // nodes. `cur` is used to keep the node that we are currently\n // adding statements to.\n\n var cur;\n for (var sawDefault = false; this.type !== types$1.braceR;) {\n if (this.type === types$1._case || this.type === types$1._default) {\n var isCase = this.type === types$1._case;\n if (cur) { this.finishNode(cur, \"SwitchCase\"); }\n node.cases.push(cur = this.startNode());\n cur.consequent = [];\n this.next();\n if (isCase) {\n cur.test = this.parseExpression();\n } else {\n if (sawDefault) { this.raiseRecoverable(this.lastTokStart, \"Multiple default clauses\"); }\n sawDefault = true;\n cur.test = null;\n }\n this.expect(types$1.colon);\n } else {\n if (!cur) { this.unexpected(); }\n cur.consequent.push(this.parseStatement(null));\n }\n }\n this.exitScope();\n if (cur) { this.finishNode(cur, \"SwitchCase\"); }\n this.next(); // Closing brace\n this.labels.pop();\n return this.finishNode(node, \"SwitchStatement\")\n};\n\npp$8.parseThrowStatement = function(node) {\n this.next();\n if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))\n { this.raise(this.lastTokEnd, \"Illegal newline after throw\"); }\n node.argument = this.parseExpression();\n this.semicolon();\n return this.finishNode(node, \"ThrowStatement\")\n};\n\n// Reused empty array added for node fields that are always empty.\n\nvar empty$1 = [];\n\npp$8.parseTryStatement = function(node) {\n this.next();\n node.block = this.parseBlock();\n node.handler = null;\n if (this.type === types$1._catch) {\n var clause = this.startNode();\n this.next();\n if (this.eat(types$1.parenL)) {\n clause.param = this.parseBindingAtom();\n var simple = clause.param.type === \"Identifier\";\n this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);\n this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);\n this.expect(types$1.parenR);\n } else {\n if (this.options.ecmaVersion < 10) { this.unexpected(); }\n clause.param = null;\n this.enterScope(0);\n }\n clause.body = this.parseBlock(false);\n this.exitScope();\n node.handler = this.finishNode(clause, \"CatchClause\");\n }\n node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null;\n if (!node.handler && !node.finalizer)\n { this.raise(node.start, \"Missing catch or finally clause\"); }\n return this.finishNode(node, \"TryStatement\")\n};\n\npp$8.parseVarStatement = function(node, kind) {\n this.next();\n this.parseVar(node, false, kind);\n this.semicolon();\n return this.finishNode(node, \"VariableDeclaration\")\n};\n\npp$8.parseWhileStatement = function(node) {\n this.next();\n node.test = this.parseParenExpression();\n this.labels.push(loopLabel);\n node.body = this.parseStatement(\"while\");\n this.labels.pop();\n return this.finishNode(node, \"WhileStatement\")\n};\n\npp$8.parseWithStatement = function(node) {\n if (this.strict) { this.raise(this.start, \"'with' in strict mode\"); }\n this.next();\n node.object = this.parseParenExpression();\n node.body = this.parseStatement(\"with\");\n return this.finishNode(node, \"WithStatement\")\n};\n\npp$8.parseEmptyStatement = function(node) {\n this.next();\n return this.finishNode(node, \"EmptyStatement\")\n};\n\npp$8.parseLabeledStatement = function(node, maybeName, expr, context) {\n for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1)\n {\n var label = list[i$1];\n\n if (label.name === maybeName)\n { this.raise(expr.start, \"Label '\" + maybeName + \"' is already declared\");\n } }\n var kind = this.type.isLoop ? \"loop\" : this.type === types$1._switch ? \"switch\" : null;\n for (var i = this.labels.length - 1; i >= 0; i--) {\n var label$1 = this.labels[i];\n if (label$1.statementStart === node.start) {\n // Update information about previous labels on this node\n label$1.statementStart = this.start;\n label$1.kind = kind;\n } else { break }\n }\n this.labels.push({name: maybeName, kind: kind, statementStart: this.start});\n node.body = this.parseStatement(context ? context.indexOf(\"label\") === -1 ? context + \"label\" : context : \"label\");\n this.labels.pop();\n node.label = expr;\n return this.finishNode(node, \"LabeledStatement\")\n};\n\npp$8.parseExpressionStatement = function(node, expr) {\n node.expression = expr;\n this.semicolon();\n return this.finishNode(node, \"ExpressionStatement\")\n};\n\n// Parse a semicolon-enclosed block of statements, handling `\"use\n// strict\"` declarations when `allowStrict` is true (used for\n// function bodies).\n\npp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) {\n if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;\n if ( node === void 0 ) node = this.startNode();\n\n node.body = [];\n this.expect(types$1.braceL);\n if (createNewLexicalScope) { this.enterScope(0); }\n while (this.type !== types$1.braceR) {\n var stmt = this.parseStatement(null);\n node.body.push(stmt);\n }\n if (exitStrict) { this.strict = false; }\n this.next();\n if (createNewLexicalScope) { this.exitScope(); }\n return this.finishNode(node, \"BlockStatement\")\n};\n\n// Parse a regular `for` loop. The disambiguation code in\n// `parseStatement` will already have parsed the init statement or\n// expression.\n\npp$8.parseFor = function(node, init) {\n node.init = init;\n this.expect(types$1.semi);\n node.test = this.type === types$1.semi ? null : this.parseExpression();\n this.expect(types$1.semi);\n node.update = this.type === types$1.parenR ? null : this.parseExpression();\n this.expect(types$1.parenR);\n node.body = this.parseStatement(\"for\");\n this.exitScope();\n this.labels.pop();\n return this.finishNode(node, \"ForStatement\")\n};\n\n// Parse a `for`/`in` and `for`/`of` loop, which are almost\n// same from parser's perspective.\n\npp$8.parseForIn = function(node, init) {\n var isForIn = this.type === types$1._in;\n this.next();\n\n if (\n init.type === \"VariableDeclaration\" &&\n init.declarations[0].init != null &&\n (\n !isForIn ||\n this.options.ecmaVersion < 8 ||\n this.strict ||\n init.kind !== \"var\" ||\n init.declarations[0].id.type !== \"Identifier\"\n )\n ) {\n this.raise(\n init.start,\n ((isForIn ? \"for-in\" : \"for-of\") + \" loop variable declaration may not have an initializer\")\n );\n }\n node.left = init;\n node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();\n this.expect(types$1.parenR);\n node.body = this.parseStatement(\"for\");\n this.exitScope();\n this.labels.pop();\n return this.finishNode(node, isForIn ? \"ForInStatement\" : \"ForOfStatement\")\n};\n\n// Parse a list of variable declarations.\n\npp$8.parseVar = function(node, isFor, kind) {\n node.declarations = [];\n node.kind = kind;\n for (;;) {\n var decl = this.startNode();\n this.parseVarId(decl, kind);\n if (this.eat(types$1.eq)) {\n decl.init = this.parseMaybeAssign(isFor);\n } else if (kind === \"const\" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual(\"of\")))) {\n this.unexpected();\n } else if (decl.id.type !== \"Identifier\" && !(isFor && (this.type === types$1._in || this.isContextual(\"of\")))) {\n this.raise(this.lastTokEnd, \"Complex binding patterns require an initialization value\");\n } else {\n decl.init = null;\n }\n node.declarations.push(this.finishNode(decl, \"VariableDeclarator\"));\n if (!this.eat(types$1.comma)) { break }\n }\n return node\n};\n\npp$8.parseVarId = function(decl, kind) {\n decl.id = this.parseBindingAtom();\n this.checkLValPattern(decl.id, kind === \"var\" ? BIND_VAR : BIND_LEXICAL, false);\n};\n\nvar FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;\n\n// Parse a function declaration or literal (depending on the\n// `statement & FUNC_STATEMENT`).\n\n// Remove `allowExpressionBody` for 7.0.0, as it is only called with false\npp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {\n this.initFunction(node);\n if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {\n if (this.type === types$1.star && (statement & FUNC_HANGING_STATEMENT))\n { this.unexpected(); }\n node.generator = this.eat(types$1.star);\n }\n if (this.options.ecmaVersion >= 8)\n { node.async = !!isAsync; }\n\n if (statement & FUNC_STATEMENT) {\n node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent();\n if (node.id && !(statement & FUNC_HANGING_STATEMENT))\n // If it is a regular function declaration in sloppy mode, then it is\n // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding\n // mode depends on properties of the current scope (see\n // treatFunctionsAsVar).\n { this.checkLValSimple(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); }\n }\n\n var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;\n this.yieldPos = 0;\n this.awaitPos = 0;\n this.awaitIdentPos = 0;\n this.enterScope(functionFlags(node.async, node.generator));\n\n if (!(statement & FUNC_STATEMENT))\n { node.id = this.type === types$1.name ? this.parseIdent() : null; }\n\n this.parseFunctionParams(node);\n this.parseFunctionBody(node, allowExpressionBody, false, forInit);\n\n this.yieldPos = oldYieldPos;\n this.awaitPos = oldAwaitPos;\n this.awaitIdentPos = oldAwaitIdentPos;\n return this.finishNode(node, (statement & FUNC_STATEMENT) ? \"FunctionDeclaration\" : \"FunctionExpression\")\n};\n\npp$8.parseFunctionParams = function(node) {\n this.expect(types$1.parenL);\n node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);\n this.checkYieldAwaitInDefaultParams();\n};\n\n// Parse a class declaration or literal (depending on the\n// `isStatement` parameter).\n\npp$8.parseClass = function(node, isStatement) {\n this.next();\n\n // ecma-262 14.6 Class Definitions\n // A class definition is always strict mode code.\n var oldStrict = this.strict;\n this.strict = true;\n\n this.parseClassId(node, isStatement);\n this.parseClassSuper(node);\n var privateNameMap = this.enterClassBody();\n var classBody = this.startNode();\n var hadConstructor = false;\n classBody.body = [];\n this.expect(types$1.braceL);\n while (this.type !== types$1.braceR) {\n var element = this.parseClassElement(node.superClass !== null);\n if (element) {\n classBody.body.push(element);\n if (element.type === \"MethodDefinition\" && element.kind === \"constructor\") {\n if (hadConstructor) { this.raise(element.start, \"Duplicate constructor in the same class\"); }\n hadConstructor = true;\n } else if (element.key && element.key.type === \"PrivateIdentifier\" && isPrivateNameConflicted(privateNameMap, element)) {\n this.raiseRecoverable(element.key.start, (\"Identifier '#\" + (element.key.name) + \"' has already been declared\"));\n }\n }\n }\n this.strict = oldStrict;\n this.next();\n node.body = this.finishNode(classBody, \"ClassBody\");\n this.exitClassBody();\n return this.finishNode(node, isStatement ? \"ClassDeclaration\" : \"ClassExpression\")\n};\n\npp$8.parseClassElement = function(constructorAllowsSuper) {\n if (this.eat(types$1.semi)) { return null }\n\n var ecmaVersion = this.options.ecmaVersion;\n var node = this.startNode();\n var keyName = \"\";\n var isGenerator = false;\n var isAsync = false;\n var kind = \"method\";\n var isStatic = false;\n\n if (this.eatContextual(\"static\")) {\n // Parse static init block\n if (ecmaVersion >= 13 && this.eat(types$1.braceL)) {\n this.parseClassStaticBlock(node);\n return node\n }\n if (this.isClassElementNameStart() || this.type === types$1.star) {\n isStatic = true;\n } else {\n keyName = \"static\";\n }\n }\n node.static = isStatic;\n if (!keyName && ecmaVersion >= 8 && this.eatContextual(\"async\")) {\n if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) {\n isAsync = true;\n } else {\n keyName = \"async\";\n }\n }\n if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) {\n isGenerator = true;\n }\n if (!keyName && !isAsync && !isGenerator) {\n var lastValue = this.value;\n if (this.eatContextual(\"get\") || this.eatContextual(\"set\")) {\n if (this.isClassElementNameStart()) {\n kind = lastValue;\n } else {\n keyName = lastValue;\n }\n }\n }\n\n // Parse element name\n if (keyName) {\n // 'async', 'get', 'set', or 'static' were not a keyword contextually.\n // The last token is any of those. Make it the element name.\n node.computed = false;\n node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);\n node.key.name = keyName;\n this.finishNode(node.key, \"Identifier\");\n } else {\n this.parseClassElementName(node);\n }\n\n // Parse element value\n if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== \"method\" || isGenerator || isAsync) {\n var isConstructor = !node.static && checkKeyName(node, \"constructor\");\n var allowsDirectSuper = isConstructor && constructorAllowsSuper;\n // Couldn't move this check into the 'parseClassMethod' method for backward compatibility.\n if (isConstructor && kind !== \"method\") { this.raise(node.key.start, \"Constructor can't have get/set modifier\"); }\n node.kind = isConstructor ? \"constructor\" : kind;\n this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);\n } else {\n this.parseClassField(node);\n }\n\n return node\n};\n\npp$8.isClassElementNameStart = function() {\n return (\n this.type === types$1.name ||\n this.type === types$1.privateId ||\n this.type === types$1.num ||\n this.type === types$1.string ||\n this.type === types$1.bracketL ||\n this.type.keyword\n )\n};\n\npp$8.parseClassElementName = function(element) {\n if (this.type === types$1.privateId) {\n if (this.value === \"constructor\") {\n this.raise(this.start, \"Classes can't have an element named '#constructor'\");\n }\n element.computed = false;\n element.key = this.parsePrivateIdent();\n } else {\n this.parsePropertyName(element);\n }\n};\n\npp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {\n // Check key and flags\n var key = method.key;\n if (method.kind === \"constructor\") {\n if (isGenerator) { this.raise(key.start, \"Constructor can't be a generator\"); }\n if (isAsync) { this.raise(key.start, \"Constructor can't be an async method\"); }\n } else if (method.static && checkKeyName(method, \"prototype\")) {\n this.raise(key.start, \"Classes may not have a static property named prototype\");\n }\n\n // Parse value\n var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);\n\n // Check value\n if (method.kind === \"get\" && value.params.length !== 0)\n { this.raiseRecoverable(value.start, \"getter should have no params\"); }\n if (method.kind === \"set\" && value.params.length !== 1)\n { this.raiseRecoverable(value.start, \"setter should have exactly one param\"); }\n if (method.kind === \"set\" && value.params[0].type === \"RestElement\")\n { this.raiseRecoverable(value.params[0].start, \"Setter cannot use rest params\"); }\n\n return this.finishNode(method, \"MethodDefinition\")\n};\n\npp$8.parseClassField = function(field) {\n if (checkKeyName(field, \"constructor\")) {\n this.raise(field.key.start, \"Classes can't have a field named 'constructor'\");\n } else if (field.static && checkKeyName(field, \"prototype\")) {\n this.raise(field.key.start, \"Classes can't have a static field named 'prototype'\");\n }\n\n if (this.eat(types$1.eq)) {\n // To raise SyntaxError if 'arguments' exists in the initializer.\n var scope = this.currentThisScope();\n var inClassFieldInit = scope.inClassFieldInit;\n scope.inClassFieldInit = true;\n field.value = this.parseMaybeAssign();\n scope.inClassFieldInit = inClassFieldInit;\n } else {\n field.value = null;\n }\n this.semicolon();\n\n return this.finishNode(field, \"PropertyDefinition\")\n};\n\npp$8.parseClassStaticBlock = function(node) {\n node.body = [];\n\n var oldLabels = this.labels;\n this.labels = [];\n this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER);\n while (this.type !== types$1.braceR) {\n var stmt = this.parseStatement(null);\n node.body.push(stmt);\n }\n this.next();\n this.exitScope();\n this.labels = oldLabels;\n\n return this.finishNode(node, \"StaticBlock\")\n};\n\npp$8.parseClassId = function(node, isStatement) {\n if (this.type === types$1.name) {\n node.id = this.parseIdent();\n if (isStatement)\n { this.checkLValSimple(node.id, BIND_LEXICAL, false); }\n } else {\n if (isStatement === true)\n { this.unexpected(); }\n node.id = null;\n }\n};\n\npp$8.parseClassSuper = function(node) {\n node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(null, false) : null;\n};\n\npp$8.enterClassBody = function() {\n var element = {declared: Object.create(null), used: []};\n this.privateNameStack.push(element);\n return element.declared\n};\n\npp$8.exitClassBody = function() {\n var ref = this.privateNameStack.pop();\n var declared = ref.declared;\n var used = ref.used;\n var len = this.privateNameStack.length;\n var parent = len === 0 ? null : this.privateNameStack[len - 1];\n for (var i = 0; i < used.length; ++i) {\n var id = used[i];\n if (!hasOwn(declared, id.name)) {\n if (parent) {\n parent.used.push(id);\n } else {\n this.raiseRecoverable(id.start, (\"Private field '#\" + (id.name) + \"' must be declared in an enclosing class\"));\n }\n }\n }\n};\n\nfunction isPrivateNameConflicted(privateNameMap, element) {\n var name = element.key.name;\n var curr = privateNameMap[name];\n\n var next = \"true\";\n if (element.type === \"MethodDefinition\" && (element.kind === \"get\" || element.kind === \"set\")) {\n next = (element.static ? \"s\" : \"i\") + element.kind;\n }\n\n // `class { get #a(){}; static set #a(_){} }` is also conflict.\n if (\n curr === \"iget\" && next === \"iset\" ||\n curr === \"iset\" && next === \"iget\" ||\n curr === \"sget\" && next === \"sset\" ||\n curr === \"sset\" && next === \"sget\"\n ) {\n privateNameMap[name] = \"true\";\n return false\n } else if (!curr) {\n privateNameMap[name] = next;\n return false\n } else {\n return true\n }\n}\n\nfunction checkKeyName(node, name) {\n var computed = node.computed;\n var key = node.key;\n return !computed && (\n key.type === \"Identifier\" && key.name === name ||\n key.type === \"Literal\" && key.value === name\n )\n}\n\n// Parses module export declaration.\n\npp$8.parseExport = function(node, exports) {\n this.next();\n // export * from '...'\n if (this.eat(types$1.star)) {\n if (this.options.ecmaVersion >= 11) {\n if (this.eatContextual(\"as\")) {\n node.exported = this.parseModuleExportName();\n this.checkExport(exports, node.exported, this.lastTokStart);\n } else {\n node.exported = null;\n }\n }\n this.expectContextual(\"from\");\n if (this.type !== types$1.string) { this.unexpected(); }\n node.source = this.parseExprAtom();\n this.semicolon();\n return this.finishNode(node, \"ExportAllDeclaration\")\n }\n if (this.eat(types$1._default)) { // export default ...\n this.checkExport(exports, \"default\", this.lastTokStart);\n var isAsync;\n if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {\n var fNode = this.startNode();\n this.next();\n if (isAsync) { this.next(); }\n node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);\n } else if (this.type === types$1._class) {\n var cNode = this.startNode();\n node.declaration = this.parseClass(cNode, \"nullableID\");\n } else {\n node.declaration = this.parseMaybeAssign();\n this.semicolon();\n }\n return this.finishNode(node, \"ExportDefaultDeclaration\")\n }\n // export var|const|let|function|class ...\n if (this.shouldParseExportStatement()) {\n node.declaration = this.parseStatement(null);\n if (node.declaration.type === \"VariableDeclaration\")\n { this.checkVariableExport(exports, node.declaration.declarations); }\n else\n { this.checkExport(exports, node.declaration.id, node.declaration.id.start); }\n node.specifiers = [];\n node.source = null;\n } else { // export { x, y as z } [from '...']\n node.declaration = null;\n node.specifiers = this.parseExportSpecifiers(exports);\n if (this.eatContextual(\"from\")) {\n if (this.type !== types$1.string) { this.unexpected(); }\n node.source = this.parseExprAtom();\n } else {\n for (var i = 0, list = node.specifiers; i < list.length; i += 1) {\n // check for keywords used as local names\n var spec = list[i];\n\n this.checkUnreserved(spec.local);\n // check if export is defined\n this.checkLocalExport(spec.local);\n\n if (spec.local.type === \"Literal\") {\n this.raise(spec.local.start, \"A string literal cannot be used as an exported binding without `from`.\");\n }\n }\n\n node.source = null;\n }\n this.semicolon();\n }\n return this.finishNode(node, \"ExportNamedDeclaration\")\n};\n\npp$8.checkExport = function(exports, name, pos) {\n if (!exports) { return }\n if (typeof name !== \"string\")\n { name = name.type === \"Identifier\" ? name.name : name.value; }\n if (hasOwn(exports, name))\n { this.raiseRecoverable(pos, \"Duplicate export '\" + name + \"'\"); }\n exports[name] = true;\n};\n\npp$8.checkPatternExport = function(exports, pat) {\n var type = pat.type;\n if (type === \"Identifier\")\n { this.checkExport(exports, pat, pat.start); }\n else if (type === \"ObjectPattern\")\n { for (var i = 0, list = pat.properties; i < list.length; i += 1)\n {\n var prop = list[i];\n\n this.checkPatternExport(exports, prop);\n } }\n else if (type === \"ArrayPattern\")\n { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {\n var elt = list$1[i$1];\n\n if (elt) { this.checkPatternExport(exports, elt); }\n } }\n else if (type === \"Property\")\n { this.checkPatternExport(exports, pat.value); }\n else if (type === \"AssignmentPattern\")\n { this.checkPatternExport(exports, pat.left); }\n else if (type === \"RestElement\")\n { this.checkPatternExport(exports, pat.argument); }\n else if (type === \"ParenthesizedExpression\")\n { this.checkPatternExport(exports, pat.expression); }\n};\n\npp$8.checkVariableExport = function(exports, decls) {\n if (!exports) { return }\n for (var i = 0, list = decls; i < list.length; i += 1)\n {\n var decl = list[i];\n\n this.checkPatternExport(exports, decl.id);\n }\n};\n\npp$8.shouldParseExportStatement = function() {\n return this.type.keyword === \"var\" ||\n this.type.keyword === \"const\" ||\n this.type.keyword === \"class\" ||\n this.type.keyword === \"function\" ||\n this.isLet() ||\n this.isAsyncFunction()\n};\n\n// Parses a comma-separated list of module exports.\n\npp$8.parseExportSpecifiers = function(exports) {\n var nodes = [], first = true;\n // export { x, y as z } [from '...']\n this.expect(types$1.braceL);\n while (!this.eat(types$1.braceR)) {\n if (!first) {\n this.expect(types$1.comma);\n if (this.afterTrailingComma(types$1.braceR)) { break }\n } else { first = false; }\n\n var node = this.startNode();\n node.local = this.parseModuleExportName();\n node.exported = this.eatContextual(\"as\") ? this.parseModuleExportName() : node.local;\n this.checkExport(\n exports,\n node.exported,\n node.exported.start\n );\n nodes.push(this.finishNode(node, \"ExportSpecifier\"));\n }\n return nodes\n};\n\n// Parses import declaration.\n\npp$8.parseImport = function(node) {\n this.next();\n // import '...'\n if (this.type === types$1.string) {\n node.specifiers = empty$1;\n node.source = this.parseExprAtom();\n } else {\n node.specifiers = this.parseImportSpecifiers();\n this.expectContextual(\"from\");\n node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();\n }\n this.semicolon();\n return this.finishNode(node, \"ImportDeclaration\")\n};\n\n// Parses a comma-separated list of module imports.\n\npp$8.parseImportSpecifiers = function() {\n var nodes = [], first = true;\n if (this.type === types$1.name) {\n // import defaultObj, { x, y as z } from '...'\n var node = this.startNode();\n node.local = this.parseIdent();\n this.checkLValSimple(node.local, BIND_LEXICAL);\n nodes.push(this.finishNode(node, \"ImportDefaultSpecifier\"));\n if (!this.eat(types$1.comma)) { return nodes }\n }\n if (this.type === types$1.star) {\n var node$1 = this.startNode();\n this.next();\n this.expectContextual(\"as\");\n node$1.local = this.parseIdent();\n this.checkLValSimple(node$1.local, BIND_LEXICAL);\n nodes.push(this.finishNode(node$1, \"ImportNamespaceSpecifier\"));\n return nodes\n }\n this.expect(types$1.braceL);\n while (!this.eat(types$1.braceR)) {\n if (!first) {\n this.expect(types$1.comma);\n if (this.afterTrailingComma(types$1.braceR)) { break }\n } else { first = false; }\n\n var node$2 = this.startNode();\n node$2.imported = this.parseModuleExportName();\n if (this.eatContextual(\"as\")) {\n node$2.local = this.parseIdent();\n } else {\n this.checkUnreserved(node$2.imported);\n node$2.local = node$2.imported;\n }\n this.checkLValSimple(node$2.local, BIND_LEXICAL);\n nodes.push(this.finishNode(node$2, \"ImportSpecifier\"));\n }\n return nodes\n};\n\npp$8.parseModuleExportName = function() {\n if (this.options.ecmaVersion >= 13 && this.type === types$1.string) {\n var stringLiteral = this.parseLiteral(this.value);\n if (loneSurrogate.test(stringLiteral.value)) {\n this.raise(stringLiteral.start, \"An export name cannot include a lone surrogate.\");\n }\n return stringLiteral\n }\n return this.parseIdent(true)\n};\n\n// Set `ExpressionStatement#directive` property for directive prologues.\npp$8.adaptDirectivePrologue = function(statements) {\n for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {\n statements[i].directive = statements[i].expression.raw.slice(1, -1);\n }\n};\npp$8.isDirectiveCandidate = function(statement) {\n return (\n this.options.ecmaVersion >= 5 &&\n statement.type === \"ExpressionStatement\" &&\n statement.expression.type === \"Literal\" &&\n typeof statement.expression.value === \"string\" &&\n // Reject parenthesized strings.\n (this.input[statement.start] === \"\\\"\" || this.input[statement.start] === \"'\")\n )\n};\n\nvar pp$7 = Parser.prototype;\n\n// Convert existing expression atom to assignable pattern\n// if possible.\n\npp$7.toAssignable = function(node, isBinding, refDestructuringErrors) {\n if (this.options.ecmaVersion >= 6 && node) {\n switch (node.type) {\n case \"Identifier\":\n if (this.inAsync && node.name === \"await\")\n { this.raise(node.start, \"Cannot use 'await' as identifier inside an async function\"); }\n break\n\n case \"ObjectPattern\":\n case \"ArrayPattern\":\n case \"AssignmentPattern\":\n case \"RestElement\":\n break\n\n case \"ObjectExpression\":\n node.type = \"ObjectPattern\";\n if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }\n for (var i = 0, list = node.properties; i < list.length; i += 1) {\n var prop = list[i];\n\n this.toAssignable(prop, isBinding);\n // Early error:\n // AssignmentRestProperty[Yield, Await] :\n // `...` DestructuringAssignmentTarget[Yield, Await]\n //\n // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.\n if (\n prop.type === \"RestElement\" &&\n (prop.argument.type === \"ArrayPattern\" || prop.argument.type === \"ObjectPattern\")\n ) {\n this.raise(prop.argument.start, \"Unexpected token\");\n }\n }\n break\n\n case \"Property\":\n // AssignmentProperty has type === \"Property\"\n if (node.kind !== \"init\") { this.raise(node.key.start, \"Object pattern can't contain getter or setter\"); }\n this.toAssignable(node.value, isBinding);\n break\n\n case \"ArrayExpression\":\n node.type = \"ArrayPattern\";\n if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }\n this.toAssignableList(node.elements, isBinding);\n break\n\n case \"SpreadElement\":\n node.type = \"RestElement\";\n this.toAssignable(node.argument, isBinding);\n if (node.argument.type === \"AssignmentPattern\")\n { this.raise(node.argument.start, \"Rest elements cannot have a default value\"); }\n break\n\n case \"AssignmentExpression\":\n if (node.operator !== \"=\") { this.raise(node.left.end, \"Only '=' operator can be used for specifying default value.\"); }\n node.type = \"AssignmentPattern\";\n delete node.operator;\n this.toAssignable(node.left, isBinding);\n break\n\n case \"ParenthesizedExpression\":\n this.toAssignable(node.expression, isBinding, refDestructuringErrors);\n break\n\n case \"ChainExpression\":\n this.raiseRecoverable(node.start, \"Optional chaining cannot appear in left-hand side\");\n break\n\n case \"MemberExpression\":\n if (!isBinding) { break }\n\n default:\n this.raise(node.start, \"Assigning to rvalue\");\n }\n } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }\n return node\n};\n\n// Convert list of expression atoms to binding list.\n\npp$7.toAssignableList = function(exprList, isBinding) {\n var end = exprList.length;\n for (var i = 0; i < end; i++) {\n var elt = exprList[i];\n if (elt) { this.toAssignable(elt, isBinding); }\n }\n if (end) {\n var last = exprList[end - 1];\n if (this.options.ecmaVersion === 6 && isBinding && last && last.type === \"RestElement\" && last.argument.type !== \"Identifier\")\n { this.unexpected(last.argument.start); }\n }\n return exprList\n};\n\n// Parses spread element.\n\npp$7.parseSpread = function(refDestructuringErrors) {\n var node = this.startNode();\n this.next();\n node.argument = this.parseMaybeAssign(false, refDestructuringErrors);\n return this.finishNode(node, \"SpreadElement\")\n};\n\npp$7.parseRestBinding = function() {\n var node = this.startNode();\n this.next();\n\n // RestElement inside of a function parameter must be an identifier\n if (this.options.ecmaVersion === 6 && this.type !== types$1.name)\n { this.unexpected(); }\n\n node.argument = this.parseBindingAtom();\n\n return this.finishNode(node, \"RestElement\")\n};\n\n// Parses lvalue (assignable) atom.\n\npp$7.parseBindingAtom = function() {\n if (this.options.ecmaVersion >= 6) {\n switch (this.type) {\n case types$1.bracketL:\n var node = this.startNode();\n this.next();\n node.elements = this.parseBindingList(types$1.bracketR, true, true);\n return this.finishNode(node, \"ArrayPattern\")\n\n case types$1.braceL:\n return this.parseObj(true)\n }\n }\n return this.parseIdent()\n};\n\npp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {\n var elts = [], first = true;\n while (!this.eat(close)) {\n if (first) { first = false; }\n else { this.expect(types$1.comma); }\n if (allowEmpty && this.type === types$1.comma) {\n elts.push(null);\n } else if (allowTrailingComma && this.afterTrailingComma(close)) {\n break\n } else if (this.type === types$1.ellipsis) {\n var rest = this.parseRestBinding();\n this.parseBindingListItem(rest);\n elts.push(rest);\n if (this.type === types$1.comma) { this.raise(this.start, \"Comma is not permitted after the rest element\"); }\n this.expect(close);\n break\n } else {\n var elem = this.parseMaybeDefault(this.start, this.startLoc);\n this.parseBindingListItem(elem);\n elts.push(elem);\n }\n }\n return elts\n};\n\npp$7.parseBindingListItem = function(param) {\n return param\n};\n\n// Parses assignment pattern around given atom if possible.\n\npp$7.parseMaybeDefault = function(startPos, startLoc, left) {\n left = left || this.parseBindingAtom();\n if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) { return left }\n var node = this.startNodeAt(startPos, startLoc);\n node.left = left;\n node.right = this.parseMaybeAssign();\n return this.finishNode(node, \"AssignmentPattern\")\n};\n\n// The following three functions all verify that a node is an lvalue —\n// something that can be bound, or assigned to. In order to do so, they perform\n// a variety of checks:\n//\n// - Check that none of the bound/assigned-to identifiers are reserved words.\n// - Record name declarations for bindings in the appropriate scope.\n// - Check duplicate argument names, if checkClashes is set.\n//\n// If a complex binding pattern is encountered (e.g., object and array\n// destructuring), the entire pattern is recursively checked.\n//\n// There are three versions of checkLVal*() appropriate for different\n// circumstances:\n//\n// - checkLValSimple() shall be used if the syntactic construct supports\n// nothing other than identifiers and member expressions. Parenthesized\n// expressions are also correctly handled. This is generally appropriate for\n// constructs for which the spec says\n//\n// > It is a Syntax Error if AssignmentTargetType of [the production] is not\n// > simple.\n//\n// It is also appropriate for checking if an identifier is valid and not\n// defined elsewhere, like import declarations or function/class identifiers.\n//\n// Examples where this is used include:\n// a += …;\n// import a from '…';\n// where a is the node to be checked.\n//\n// - checkLValPattern() shall be used if the syntactic construct supports\n// anything checkLValSimple() supports, as well as object and array\n// destructuring patterns. This is generally appropriate for constructs for\n// which the spec says\n//\n// > It is a Syntax Error if [the production] is neither an ObjectLiteral nor\n// > an ArrayLiteral and AssignmentTargetType of [the production] is not\n// > simple.\n//\n// Examples where this is used include:\n// (a = …);\n// const a = …;\n// try { … } catch (a) { … }\n// where a is the node to be checked.\n//\n// - checkLValInnerPattern() shall be used if the syntactic construct supports\n// anything checkLValPattern() supports, as well as default assignment\n// patterns, rest elements, and other constructs that may appear within an\n// object or array destructuring pattern.\n//\n// As a special case, function parameters also use checkLValInnerPattern(),\n// as they also support defaults and rest constructs.\n//\n// These functions deliberately support both assignment and binding constructs,\n// as the logic for both is exceedingly similar. If the node is the target of\n// an assignment, then bindingType should be set to BIND_NONE. Otherwise, it\n// should be set to the appropriate BIND_* constant, like BIND_VAR or\n// BIND_LEXICAL.\n//\n// If the function is called with a non-BIND_NONE bindingType, then\n// additionally a checkClashes object may be specified to allow checking for\n// duplicate argument names. checkClashes is ignored if the provided construct\n// is an assignment (i.e., bindingType is BIND_NONE).\n\npp$7.checkLValSimple = function(expr, bindingType, checkClashes) {\n if ( bindingType === void 0 ) bindingType = BIND_NONE;\n\n var isBind = bindingType !== BIND_NONE;\n\n switch (expr.type) {\n case \"Identifier\":\n if (this.strict && this.reservedWordsStrictBind.test(expr.name))\n { this.raiseRecoverable(expr.start, (isBind ? \"Binding \" : \"Assigning to \") + expr.name + \" in strict mode\"); }\n if (isBind) {\n if (bindingType === BIND_LEXICAL && expr.name === \"let\")\n { this.raiseRecoverable(expr.start, \"let is disallowed as a lexically bound name\"); }\n if (checkClashes) {\n if (hasOwn(checkClashes, expr.name))\n { this.raiseRecoverable(expr.start, \"Argument name clash\"); }\n checkClashes[expr.name] = true;\n }\n if (bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); }\n }\n break\n\n case \"ChainExpression\":\n this.raiseRecoverable(expr.start, \"Optional chaining cannot appear in left-hand side\");\n break\n\n case \"MemberExpression\":\n if (isBind) { this.raiseRecoverable(expr.start, \"Binding member expression\"); }\n break\n\n case \"ParenthesizedExpression\":\n if (isBind) { this.raiseRecoverable(expr.start, \"Binding parenthesized expression\"); }\n return this.checkLValSimple(expr.expression, bindingType, checkClashes)\n\n default:\n this.raise(expr.start, (isBind ? \"Binding\" : \"Assigning to\") + \" rvalue\");\n }\n};\n\npp$7.checkLValPattern = function(expr, bindingType, checkClashes) {\n if ( bindingType === void 0 ) bindingType = BIND_NONE;\n\n switch (expr.type) {\n case \"ObjectPattern\":\n for (var i = 0, list = expr.properties; i < list.length; i += 1) {\n var prop = list[i];\n\n this.checkLValInnerPattern(prop, bindingType, checkClashes);\n }\n break\n\n case \"ArrayPattern\":\n for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {\n var elem = list$1[i$1];\n\n if (elem) { this.checkLValInnerPattern(elem, bindingType, checkClashes); }\n }\n break\n\n default:\n this.checkLValSimple(expr, bindingType, checkClashes);\n }\n};\n\npp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) {\n if ( bindingType === void 0 ) bindingType = BIND_NONE;\n\n switch (expr.type) {\n case \"Property\":\n // AssignmentProperty has type === \"Property\"\n this.checkLValInnerPattern(expr.value, bindingType, checkClashes);\n break\n\n case \"AssignmentPattern\":\n this.checkLValPattern(expr.left, bindingType, checkClashes);\n break\n\n case \"RestElement\":\n this.checkLValPattern(expr.argument, bindingType, checkClashes);\n break\n\n default:\n this.checkLValPattern(expr, bindingType, checkClashes);\n }\n};\n\n// The algorithm used to determine whether a regexp can appear at a\n\nvar TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {\n this.token = token;\n this.isExpr = !!isExpr;\n this.preserveSpace = !!preserveSpace;\n this.override = override;\n this.generator = !!generator;\n};\n\nvar types = {\n b_stat: new TokContext(\"{\", false),\n b_expr: new TokContext(\"{\", true),\n b_tmpl: new TokContext(\"${\", false),\n p_stat: new TokContext(\"(\", false),\n p_expr: new TokContext(\"(\", true),\n q_tmpl: new TokContext(\"`\", true, true, function (p) { return p.tryReadTemplateToken(); }),\n f_stat: new TokContext(\"function\", false),\n f_expr: new TokContext(\"function\", true),\n f_expr_gen: new TokContext(\"function\", true, false, null, true),\n f_gen: new TokContext(\"function\", false, false, null, true)\n};\n\nvar pp$6 = Parser.prototype;\n\npp$6.initialContext = function() {\n return [types.b_stat]\n};\n\npp$6.curContext = function() {\n return this.context[this.context.length - 1]\n};\n\npp$6.braceIsBlock = function(prevType) {\n var parent = this.curContext();\n if (parent === types.f_expr || parent === types.f_stat)\n { return true }\n if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr))\n { return !parent.isExpr }\n\n // The check for `tt.name && exprAllowed` detects whether we are\n // after a `yield` or `of` construct. See the `updateContext` for\n // `tt.name`.\n if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed)\n { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }\n if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow)\n { return true }\n if (prevType === types$1.braceL)\n { return parent === types.b_stat }\n if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name)\n { return false }\n return !this.exprAllowed\n};\n\npp$6.inGeneratorContext = function() {\n for (var i = this.context.length - 1; i >= 1; i--) {\n var context = this.context[i];\n if (context.token === \"function\")\n { return context.generator }\n }\n return false\n};\n\npp$6.updateContext = function(prevType) {\n var update, type = this.type;\n if (type.keyword && prevType === types$1.dot)\n { this.exprAllowed = false; }\n else if (update = type.updateContext)\n { update.call(this, prevType); }\n else\n { this.exprAllowed = type.beforeExpr; }\n};\n\n// Used to handle egde cases when token context could not be inferred correctly during tokenization phase\n\npp$6.overrideContext = function(tokenCtx) {\n if (this.curContext() !== tokenCtx) {\n this.context[this.context.length - 1] = tokenCtx;\n }\n};\n\n// Token-specific context update code\n\ntypes$1.parenR.updateContext = types$1.braceR.updateContext = function() {\n if (this.context.length === 1) {\n this.exprAllowed = true;\n return\n }\n var out = this.context.pop();\n if (out === types.b_stat && this.curContext().token === \"function\") {\n out = this.context.pop();\n }\n this.exprAllowed = !out.isExpr;\n};\n\ntypes$1.braceL.updateContext = function(prevType) {\n this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);\n this.exprAllowed = true;\n};\n\ntypes$1.dollarBraceL.updateContext = function() {\n this.context.push(types.b_tmpl);\n this.exprAllowed = true;\n};\n\ntypes$1.parenL.updateContext = function(prevType) {\n var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while;\n this.context.push(statementParens ? types.p_stat : types.p_expr);\n this.exprAllowed = true;\n};\n\ntypes$1.incDec.updateContext = function() {\n // tokExprAllowed stays unchanged\n};\n\ntypes$1._function.updateContext = types$1._class.updateContext = function(prevType) {\n if (prevType.beforeExpr && prevType !== types$1._else &&\n !(prevType === types$1.semi && this.curContext() !== types.p_stat) &&\n !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&\n !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat))\n { this.context.push(types.f_expr); }\n else\n { this.context.push(types.f_stat); }\n this.exprAllowed = false;\n};\n\ntypes$1.backQuote.updateContext = function() {\n if (this.curContext() === types.q_tmpl)\n { this.context.pop(); }\n else\n { this.context.push(types.q_tmpl); }\n this.exprAllowed = false;\n};\n\ntypes$1.star.updateContext = function(prevType) {\n if (prevType === types$1._function) {\n var index = this.context.length - 1;\n if (this.context[index] === types.f_expr)\n { this.context[index] = types.f_expr_gen; }\n else\n { this.context[index] = types.f_gen; }\n }\n this.exprAllowed = true;\n};\n\ntypes$1.name.updateContext = function(prevType) {\n var allowed = false;\n if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) {\n if (this.value === \"of\" && !this.exprAllowed ||\n this.value === \"yield\" && this.inGeneratorContext())\n { allowed = true; }\n }\n this.exprAllowed = allowed;\n};\n\n// A recursive descent parser operates by defining functions for all\n\nvar pp$5 = Parser.prototype;\n\n// Check if property name clashes with already added.\n// Object/class getters and setters are not allowed to clash —\n// either with each other or with an init property — and in\n// strict mode, init properties are also not allowed to be repeated.\n\npp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {\n if (this.options.ecmaVersion >= 9 && prop.type === \"SpreadElement\")\n { return }\n if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))\n { return }\n var key = prop.key;\n var name;\n switch (key.type) {\n case \"Identifier\": name = key.name; break\n case \"Literal\": name = String(key.value); break\n default: return\n }\n var kind = prop.kind;\n if (this.options.ecmaVersion >= 6) {\n if (name === \"__proto__\" && kind === \"init\") {\n if (propHash.proto) {\n if (refDestructuringErrors) {\n if (refDestructuringErrors.doubleProto < 0) {\n refDestructuringErrors.doubleProto = key.start;\n }\n } else {\n this.raiseRecoverable(key.start, \"Redefinition of __proto__ property\");\n }\n }\n propHash.proto = true;\n }\n return\n }\n name = \"$\" + name;\n var other = propHash[name];\n if (other) {\n var redefinition;\n if (kind === \"init\") {\n redefinition = this.strict && other.init || other.get || other.set;\n } else {\n redefinition = other.init || other[kind];\n }\n if (redefinition)\n { this.raiseRecoverable(key.start, \"Redefinition of property\"); }\n } else {\n other = propHash[name] = {\n init: false,\n get: false,\n set: false\n };\n }\n other[kind] = true;\n};\n\n// ### Expression parsing\n\n// These nest, from the most general expression type at the top to\n// 'atomic', nondivisible expression types at the bottom. Most of\n// the functions will simply let the function(s) below them parse,\n// and, *if* the syntactic construct they handle is present, wrap\n// the AST node that the inner parser gave them in another node.\n\n// Parse a full expression. The optional arguments are used to\n// forbid the `in` operator (in for loops initalization expressions)\n// and provide reference for storing '=' operator inside shorthand\n// property assignment in contexts where both object expression\n// and object pattern might appear (so it's possible to raise\n// delayed syntax error at correct position).\n\npp$5.parseExpression = function(forInit, refDestructuringErrors) {\n var startPos = this.start, startLoc = this.startLoc;\n var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);\n if (this.type === types$1.comma) {\n var node = this.startNodeAt(startPos, startLoc);\n node.expressions = [expr];\n while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }\n return this.finishNode(node, \"SequenceExpression\")\n }\n return expr\n};\n\n// Parse an assignment expression. This includes applications of\n// operators like `+=`.\n\npp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {\n if (this.isContextual(\"yield\")) {\n if (this.inGenerator) { return this.parseYield(forInit) }\n // The tokenizer will assume an expression is allowed after\n // `yield`, but this isn't that kind of yield\n else { this.exprAllowed = false; }\n }\n\n var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1;\n if (refDestructuringErrors) {\n oldParenAssign = refDestructuringErrors.parenthesizedAssign;\n oldTrailingComma = refDestructuringErrors.trailingComma;\n oldDoubleProto = refDestructuringErrors.doubleProto;\n refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;\n } else {\n refDestructuringErrors = new DestructuringErrors;\n ownDestructuringErrors = true;\n }\n\n var startPos = this.start, startLoc = this.startLoc;\n if (this.type === types$1.parenL || this.type === types$1.name) {\n this.potentialArrowAt = this.start;\n this.potentialArrowInForAwait = forInit === \"await\";\n }\n var left = this.parseMaybeConditional(forInit, refDestructuringErrors);\n if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); }\n if (this.type.isAssign) {\n var node = this.startNodeAt(startPos, startLoc);\n node.operator = this.value;\n if (this.type === types$1.eq)\n { left = this.toAssignable(left, false, refDestructuringErrors); }\n if (!ownDestructuringErrors) {\n refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;\n }\n if (refDestructuringErrors.shorthandAssign >= left.start)\n { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly\n if (this.type === types$1.eq)\n { this.checkLValPattern(left); }\n else\n { this.checkLValSimple(left); }\n node.left = left;\n this.next();\n node.right = this.parseMaybeAssign(forInit);\n if (oldDoubleProto > -1) { refDestructuringErrors.doubleProto = oldDoubleProto; }\n return this.finishNode(node, \"AssignmentExpression\")\n } else {\n if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }\n }\n if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }\n if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }\n return left\n};\n\n// Parse a ternary conditional (`?:`) operator.\n\npp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {\n var startPos = this.start, startLoc = this.startLoc;\n var expr = this.parseExprOps(forInit, refDestructuringErrors);\n if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }\n if (this.eat(types$1.question)) {\n var node = this.startNodeAt(startPos, startLoc);\n node.test = expr;\n node.consequent = this.parseMaybeAssign();\n this.expect(types$1.colon);\n node.alternate = this.parseMaybeAssign(forInit);\n return this.finishNode(node, \"ConditionalExpression\")\n }\n return expr\n};\n\n// Start the precedence parser.\n\npp$5.parseExprOps = function(forInit, refDestructuringErrors) {\n var startPos = this.start, startLoc = this.startLoc;\n var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit);\n if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }\n return expr.start === startPos && expr.type === \"ArrowFunctionExpression\" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit)\n};\n\n// Parse binary operators with the operator precedence parsing\n// algorithm. `left` is the left-hand side of the operator.\n// `minPrec` provides context that allows the function to stop and\n// defer further parser to one of its callers when it encounters an\n// operator that has a lower precedence than the set it is parsing.\n\npp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {\n var prec = this.type.binop;\n if (prec != null && (!forInit || this.type !== types$1._in)) {\n if (prec > minPrec) {\n var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND;\n var coalesce = this.type === types$1.coalesce;\n if (coalesce) {\n // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.\n // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.\n prec = types$1.logicalAND.binop;\n }\n var op = this.value;\n this.next();\n var startPos = this.start, startLoc = this.startLoc;\n var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit);\n var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);\n if ((logical && this.type === types$1.coalesce) || (coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND))) {\n this.raiseRecoverable(this.start, \"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses\");\n }\n return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit)\n }\n }\n return left\n};\n\npp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) {\n if (right.type === \"PrivateIdentifier\") { this.raise(right.start, \"Private identifier can only be left side of binary expression\"); }\n var node = this.startNodeAt(startPos, startLoc);\n node.left = left;\n node.operator = op;\n node.right = right;\n return this.finishNode(node, logical ? \"LogicalExpression\" : \"BinaryExpression\")\n};\n\n// Parse unary operators, both prefix and postfix.\n\npp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) {\n var startPos = this.start, startLoc = this.startLoc, expr;\n if (this.isContextual(\"await\") && this.canAwait) {\n expr = this.parseAwait(forInit);\n sawUnary = true;\n } else if (this.type.prefix) {\n var node = this.startNode(), update = this.type === types$1.incDec;\n node.operator = this.value;\n node.prefix = true;\n this.next();\n node.argument = this.parseMaybeUnary(null, true, update, forInit);\n this.checkExpressionErrors(refDestructuringErrors, true);\n if (update) { this.checkLValSimple(node.argument); }\n else if (this.strict && node.operator === \"delete\" &&\n node.argument.type === \"Identifier\")\n { this.raiseRecoverable(node.start, \"Deleting local variable in strict mode\"); }\n else if (node.operator === \"delete\" && isPrivateFieldAccess(node.argument))\n { this.raiseRecoverable(node.start, \"Private fields can not be deleted\"); }\n else { sawUnary = true; }\n expr = this.finishNode(node, update ? \"UpdateExpression\" : \"UnaryExpression\");\n } else if (!sawUnary && this.type === types$1.privateId) {\n if (forInit || this.privateNameStack.length === 0) { this.unexpected(); }\n expr = this.parsePrivateIdent();\n // only could be private fields in 'in', such as #x in obj\n if (this.type !== types$1._in) { this.unexpected(); }\n } else {\n expr = this.parseExprSubscripts(refDestructuringErrors, forInit);\n if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }\n while (this.type.postfix && !this.canInsertSemicolon()) {\n var node$1 = this.startNodeAt(startPos, startLoc);\n node$1.operator = this.value;\n node$1.prefix = false;\n node$1.argument = expr;\n this.checkLValSimple(expr);\n this.next();\n expr = this.finishNode(node$1, \"UpdateExpression\");\n }\n }\n\n if (!incDec && this.eat(types$1.starstar)) {\n if (sawUnary)\n { this.unexpected(this.lastTokStart); }\n else\n { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), \"**\", false) }\n } else {\n return expr\n }\n};\n\nfunction isPrivateFieldAccess(node) {\n return (\n node.type === \"MemberExpression\" && node.property.type === \"PrivateIdentifier\" ||\n node.type === \"ChainExpression\" && isPrivateFieldAccess(node.expression)\n )\n}\n\n// Parse call, dot, and `[]`-subscript expressions.\n\npp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) {\n var startPos = this.start, startLoc = this.startLoc;\n var expr = this.parseExprAtom(refDestructuringErrors, forInit);\n if (expr.type === \"ArrowFunctionExpression\" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== \")\")\n { return expr }\n var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit);\n if (refDestructuringErrors && result.type === \"MemberExpression\") {\n if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }\n if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }\n if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; }\n }\n return result\n};\n\npp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {\n var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === \"Identifier\" && base.name === \"async\" &&\n this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&\n this.potentialArrowAt === base.start;\n var optionalChained = false;\n\n while (true) {\n var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit);\n\n if (element.optional) { optionalChained = true; }\n if (element === base || element.type === \"ArrowFunctionExpression\") {\n if (optionalChained) {\n var chainNode = this.startNodeAt(startPos, startLoc);\n chainNode.expression = element;\n element = this.finishNode(chainNode, \"ChainExpression\");\n }\n return element\n }\n\n base = element;\n }\n};\n\npp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {\n var optionalSupported = this.options.ecmaVersion >= 11;\n var optional = optionalSupported && this.eat(types$1.questionDot);\n if (noCalls && optional) { this.raise(this.lastTokStart, \"Optional chaining cannot appear in the callee of new expressions\"); }\n\n var computed = this.eat(types$1.bracketL);\n if (computed || (optional && this.type !== types$1.parenL && this.type !== types$1.backQuote) || this.eat(types$1.dot)) {\n var node = this.startNodeAt(startPos, startLoc);\n node.object = base;\n if (computed) {\n node.property = this.parseExpression();\n this.expect(types$1.bracketR);\n } else if (this.type === types$1.privateId && base.type !== \"Super\") {\n node.property = this.parsePrivateIdent();\n } else {\n node.property = this.parseIdent(this.options.allowReserved !== \"never\");\n }\n node.computed = !!computed;\n if (optionalSupported) {\n node.optional = optional;\n }\n base = this.finishNode(node, \"MemberExpression\");\n } else if (!noCalls && this.eat(types$1.parenL)) {\n var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;\n this.yieldPos = 0;\n this.awaitPos = 0;\n this.awaitIdentPos = 0;\n var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);\n if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {\n this.checkPatternErrors(refDestructuringErrors, false);\n this.checkYieldAwaitInDefaultParams();\n if (this.awaitIdentPos > 0)\n { this.raise(this.awaitIdentPos, \"Cannot use 'await' as identifier inside an async function\"); }\n this.yieldPos = oldYieldPos;\n this.awaitPos = oldAwaitPos;\n this.awaitIdentPos = oldAwaitIdentPos;\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit)\n }\n this.checkExpressionErrors(refDestructuringErrors, true);\n this.yieldPos = oldYieldPos || this.yieldPos;\n this.awaitPos = oldAwaitPos || this.awaitPos;\n this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;\n var node$1 = this.startNodeAt(startPos, startLoc);\n node$1.callee = base;\n node$1.arguments = exprList;\n if (optionalSupported) {\n node$1.optional = optional;\n }\n base = this.finishNode(node$1, \"CallExpression\");\n } else if (this.type === types$1.backQuote) {\n if (optional || optionalChained) {\n this.raise(this.start, \"Optional chaining cannot appear in the tag of tagged template expressions\");\n }\n var node$2 = this.startNodeAt(startPos, startLoc);\n node$2.tag = base;\n node$2.quasi = this.parseTemplate({isTagged: true});\n base = this.finishNode(node$2, \"TaggedTemplateExpression\");\n }\n return base\n};\n\n// Parse an atomic expression — either a single token that is an\n// expression, an expression started by a keyword like `function` or\n// `new`, or an expression wrapped in punctuation like `()`, `[]`,\n// or `{}`.\n\npp$5.parseExprAtom = function(refDestructuringErrors, forInit) {\n // If a division operator appears in an expression position, the\n // tokenizer got confused, and we force it to read a regexp instead.\n if (this.type === types$1.slash) { this.readRegexp(); }\n\n var node, canBeArrow = this.potentialArrowAt === this.start;\n switch (this.type) {\n case types$1._super:\n if (!this.allowSuper)\n { this.raise(this.start, \"'super' keyword outside a method\"); }\n node = this.startNode();\n this.next();\n if (this.type === types$1.parenL && !this.allowDirectSuper)\n { this.raise(node.start, \"super() call outside constructor of a subclass\"); }\n // The `super` keyword can appear at below:\n // SuperProperty:\n // super [ Expression ]\n // super . IdentifierName\n // SuperCall:\n // super ( Arguments )\n if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL)\n { this.unexpected(); }\n return this.finishNode(node, \"Super\")\n\n case types$1._this:\n node = this.startNode();\n this.next();\n return this.finishNode(node, \"ThisExpression\")\n\n case types$1.name:\n var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;\n var id = this.parseIdent(false);\n if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === \"async\" && !this.canInsertSemicolon() && this.eat(types$1._function)) {\n this.overrideContext(types.f_expr);\n return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit)\n }\n if (canBeArrow && !this.canInsertSemicolon()) {\n if (this.eat(types$1.arrow))\n { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit) }\n if (this.options.ecmaVersion >= 8 && id.name === \"async\" && this.type === types$1.name && !containsEsc &&\n (!this.potentialArrowInForAwait || this.value !== \"of\" || this.containsEsc)) {\n id = this.parseIdent(false);\n if (this.canInsertSemicolon() || !this.eat(types$1.arrow))\n { this.unexpected(); }\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit)\n }\n }\n return id\n\n case types$1.regexp:\n var value = this.value;\n node = this.parseLiteral(value.value);\n node.regex = {pattern: value.pattern, flags: value.flags};\n return node\n\n case types$1.num: case types$1.string:\n return this.parseLiteral(this.value)\n\n case types$1._null: case types$1._true: case types$1._false:\n node = this.startNode();\n node.value = this.type === types$1._null ? null : this.type === types$1._true;\n node.raw = this.type.keyword;\n this.next();\n return this.finishNode(node, \"Literal\")\n\n case types$1.parenL:\n var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);\n if (refDestructuringErrors) {\n if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))\n { refDestructuringErrors.parenthesizedAssign = start; }\n if (refDestructuringErrors.parenthesizedBind < 0)\n { refDestructuringErrors.parenthesizedBind = start; }\n }\n return expr\n\n case types$1.bracketL:\n node = this.startNode();\n this.next();\n node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors);\n return this.finishNode(node, \"ArrayExpression\")\n\n case types$1.braceL:\n this.overrideContext(types.b_expr);\n return this.parseObj(false, refDestructuringErrors)\n\n case types$1._function:\n node = this.startNode();\n this.next();\n return this.parseFunction(node, 0)\n\n case types$1._class:\n return this.parseClass(this.startNode(), false)\n\n case types$1._new:\n return this.parseNew()\n\n case types$1.backQuote:\n return this.parseTemplate()\n\n case types$1._import:\n if (this.options.ecmaVersion >= 11) {\n return this.parseExprImport()\n } else {\n return this.unexpected()\n }\n\n default:\n this.unexpected();\n }\n};\n\npp$5.parseExprImport = function() {\n var node = this.startNode();\n\n // Consume `import` as an identifier for `import.meta`.\n // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.\n if (this.containsEsc) { this.raiseRecoverable(this.start, \"Escape sequence in keyword import\"); }\n var meta = this.parseIdent(true);\n\n switch (this.type) {\n case types$1.parenL:\n return this.parseDynamicImport(node)\n case types$1.dot:\n node.meta = meta;\n return this.parseImportMeta(node)\n default:\n this.unexpected();\n }\n};\n\npp$5.parseDynamicImport = function(node) {\n this.next(); // skip `(`\n\n // Parse node.source.\n node.source = this.parseMaybeAssign();\n\n // Verify ending.\n if (!this.eat(types$1.parenR)) {\n var errorPos = this.start;\n if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {\n this.raiseRecoverable(errorPos, \"Trailing comma is not allowed in import()\");\n } else {\n this.unexpected(errorPos);\n }\n }\n\n return this.finishNode(node, \"ImportExpression\")\n};\n\npp$5.parseImportMeta = function(node) {\n this.next(); // skip `.`\n\n var containsEsc = this.containsEsc;\n node.property = this.parseIdent(true);\n\n if (node.property.name !== \"meta\")\n { this.raiseRecoverable(node.property.start, \"The only valid meta property for import is 'import.meta'\"); }\n if (containsEsc)\n { this.raiseRecoverable(node.start, \"'import.meta' must not contain escaped characters\"); }\n if (this.options.sourceType !== \"module\" && !this.options.allowImportExportEverywhere)\n { this.raiseRecoverable(node.start, \"Cannot use 'import.meta' outside a module\"); }\n\n return this.finishNode(node, \"MetaProperty\")\n};\n\npp$5.parseLiteral = function(value) {\n var node = this.startNode();\n node.value = value;\n node.raw = this.input.slice(this.start, this.end);\n if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, \"\"); }\n this.next();\n return this.finishNode(node, \"Literal\")\n};\n\npp$5.parseParenExpression = function() {\n this.expect(types$1.parenL);\n var val = this.parseExpression();\n this.expect(types$1.parenR);\n return val\n};\n\npp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {\n var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;\n if (this.options.ecmaVersion >= 6) {\n this.next();\n\n var innerStartPos = this.start, innerStartLoc = this.startLoc;\n var exprList = [], first = true, lastIsComma = false;\n var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;\n this.yieldPos = 0;\n this.awaitPos = 0;\n // Do not save awaitIdentPos to allow checking awaits nested in parameters\n while (this.type !== types$1.parenR) {\n first ? first = false : this.expect(types$1.comma);\n if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) {\n lastIsComma = true;\n break\n } else if (this.type === types$1.ellipsis) {\n spreadStart = this.start;\n exprList.push(this.parseParenItem(this.parseRestBinding()));\n if (this.type === types$1.comma) { this.raise(this.start, \"Comma is not permitted after the rest element\"); }\n break\n } else {\n exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));\n }\n }\n var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;\n this.expect(types$1.parenR);\n\n if (canBeArrow && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {\n this.checkPatternErrors(refDestructuringErrors, false);\n this.checkYieldAwaitInDefaultParams();\n this.yieldPos = oldYieldPos;\n this.awaitPos = oldAwaitPos;\n return this.parseParenArrowList(startPos, startLoc, exprList, forInit)\n }\n\n if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); }\n if (spreadStart) { this.unexpected(spreadStart); }\n this.checkExpressionErrors(refDestructuringErrors, true);\n this.yieldPos = oldYieldPos || this.yieldPos;\n this.awaitPos = oldAwaitPos || this.awaitPos;\n\n if (exprList.length > 1) {\n val = this.startNodeAt(innerStartPos, innerStartLoc);\n val.expressions = exprList;\n this.finishNodeAt(val, \"SequenceExpression\", innerEndPos, innerEndLoc);\n } else {\n val = exprList[0];\n }\n } else {\n val = this.parseParenExpression();\n }\n\n if (this.options.preserveParens) {\n var par = this.startNodeAt(startPos, startLoc);\n par.expression = val;\n return this.finishNode(par, \"ParenthesizedExpression\")\n } else {\n return val\n }\n};\n\npp$5.parseParenItem = function(item) {\n return item\n};\n\npp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) {\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit)\n};\n\n// New's precedence is slightly tricky. It must allow its argument to\n// be a `[]` or dot subscript expression, but not a call — at least,\n// not without wrapping it in parentheses. Thus, it uses the noCalls\n// argument to parseSubscripts to prevent it from consuming the\n// argument list.\n\nvar empty = [];\n\npp$5.parseNew = function() {\n if (this.containsEsc) { this.raiseRecoverable(this.start, \"Escape sequence in keyword new\"); }\n var node = this.startNode();\n var meta = this.parseIdent(true);\n if (this.options.ecmaVersion >= 6 && this.eat(types$1.dot)) {\n node.meta = meta;\n var containsEsc = this.containsEsc;\n node.property = this.parseIdent(true);\n if (node.property.name !== \"target\")\n { this.raiseRecoverable(node.property.start, \"The only valid meta property for new is 'new.target'\"); }\n if (containsEsc)\n { this.raiseRecoverable(node.start, \"'new.target' must not contain escaped characters\"); }\n if (!this.allowNewDotTarget)\n { this.raiseRecoverable(node.start, \"'new.target' can only be used in functions and class static block\"); }\n return this.finishNode(node, \"MetaProperty\")\n }\n var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types$1._import;\n node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true, false);\n if (isImport && node.callee.type === \"ImportExpression\") {\n this.raise(startPos, \"Cannot use new with import()\");\n }\n if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }\n else { node.arguments = empty; }\n return this.finishNode(node, \"NewExpression\")\n};\n\n// Parse template expression.\n\npp$5.parseTemplateElement = function(ref) {\n var isTagged = ref.isTagged;\n\n var elem = this.startNode();\n if (this.type === types$1.invalidTemplate) {\n if (!isTagged) {\n this.raiseRecoverable(this.start, \"Bad escape sequence in untagged template literal\");\n }\n elem.value = {\n raw: this.value,\n cooked: null\n };\n } else {\n elem.value = {\n raw: this.input.slice(this.start, this.end).replace(/\\r\\n?/g, \"\\n\"),\n cooked: this.value\n };\n }\n this.next();\n elem.tail = this.type === types$1.backQuote;\n return this.finishNode(elem, \"TemplateElement\")\n};\n\npp$5.parseTemplate = function(ref) {\n if ( ref === void 0 ) ref = {};\n var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false;\n\n var node = this.startNode();\n this.next();\n node.expressions = [];\n var curElt = this.parseTemplateElement({isTagged: isTagged});\n node.quasis = [curElt];\n while (!curElt.tail) {\n if (this.type === types$1.eof) { this.raise(this.pos, \"Unterminated template literal\"); }\n this.expect(types$1.dollarBraceL);\n node.expressions.push(this.parseExpression());\n this.expect(types$1.braceR);\n node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged}));\n }\n this.next();\n return this.finishNode(node, \"TemplateLiteral\")\n};\n\npp$5.isAsyncProp = function(prop) {\n return !prop.computed && prop.key.type === \"Identifier\" && prop.key.name === \"async\" &&\n (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types$1.star)) &&\n !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))\n};\n\n// Parse an object literal or binding pattern.\n\npp$5.parseObj = function(isPattern, refDestructuringErrors) {\n var node = this.startNode(), first = true, propHash = {};\n node.properties = [];\n this.next();\n while (!this.eat(types$1.braceR)) {\n if (!first) {\n this.expect(types$1.comma);\n if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) { break }\n } else { first = false; }\n\n var prop = this.parseProperty(isPattern, refDestructuringErrors);\n if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); }\n node.properties.push(prop);\n }\n return this.finishNode(node, isPattern ? \"ObjectPattern\" : \"ObjectExpression\")\n};\n\npp$5.parseProperty = function(isPattern, refDestructuringErrors) {\n var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;\n if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) {\n if (isPattern) {\n prop.argument = this.parseIdent(false);\n if (this.type === types$1.comma) {\n this.raise(this.start, \"Comma is not permitted after the rest element\");\n }\n return this.finishNode(prop, \"RestElement\")\n }\n // Parse argument.\n prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);\n // To disallow trailing comma via `this.toAssignable()`.\n if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {\n refDestructuringErrors.trailingComma = this.start;\n }\n // Finish\n return this.finishNode(prop, \"SpreadElement\")\n }\n if (this.options.ecmaVersion >= 6) {\n prop.method = false;\n prop.shorthand = false;\n if (isPattern || refDestructuringErrors) {\n startPos = this.start;\n startLoc = this.startLoc;\n }\n if (!isPattern)\n { isGenerator = this.eat(types$1.star); }\n }\n var containsEsc = this.containsEsc;\n this.parsePropertyName(prop);\n if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {\n isAsync = true;\n isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star);\n this.parsePropertyName(prop);\n } else {\n isAsync = false;\n }\n this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);\n return this.finishNode(prop, \"Property\")\n};\n\npp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {\n if ((isGenerator || isAsync) && this.type === types$1.colon)\n { this.unexpected(); }\n\n if (this.eat(types$1.colon)) {\n prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);\n prop.kind = \"init\";\n } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) {\n if (isPattern) { this.unexpected(); }\n prop.kind = \"init\";\n prop.method = true;\n prop.value = this.parseMethod(isGenerator, isAsync);\n } else if (!isPattern && !containsEsc &&\n this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === \"Identifier\" &&\n (prop.key.name === \"get\" || prop.key.name === \"set\") &&\n (this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) {\n if (isGenerator || isAsync) { this.unexpected(); }\n prop.kind = prop.key.name;\n this.parsePropertyName(prop);\n prop.value = this.parseMethod(false);\n var paramCount = prop.kind === \"get\" ? 0 : 1;\n if (prop.value.params.length !== paramCount) {\n var start = prop.value.start;\n if (prop.kind === \"get\")\n { this.raiseRecoverable(start, \"getter should have no params\"); }\n else\n { this.raiseRecoverable(start, \"setter should have exactly one param\"); }\n } else {\n if (prop.kind === \"set\" && prop.value.params[0].type === \"RestElement\")\n { this.raiseRecoverable(prop.value.params[0].start, \"Setter cannot use rest params\"); }\n }\n } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === \"Identifier\") {\n if (isGenerator || isAsync) { this.unexpected(); }\n this.checkUnreserved(prop.key);\n if (prop.key.name === \"await\" && !this.awaitIdentPos)\n { this.awaitIdentPos = startPos; }\n prop.kind = \"init\";\n if (isPattern) {\n prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));\n } else if (this.type === types$1.eq && refDestructuringErrors) {\n if (refDestructuringErrors.shorthandAssign < 0)\n { refDestructuringErrors.shorthandAssign = this.start; }\n prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));\n } else {\n prop.value = this.copyNode(prop.key);\n }\n prop.shorthand = true;\n } else { this.unexpected(); }\n};\n\npp$5.parsePropertyName = function(prop) {\n if (this.options.ecmaVersion >= 6) {\n if (this.eat(types$1.bracketL)) {\n prop.computed = true;\n prop.key = this.parseMaybeAssign();\n this.expect(types$1.bracketR);\n return prop.key\n } else {\n prop.computed = false;\n }\n }\n return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== \"never\")\n};\n\n// Initialize empty function node.\n\npp$5.initFunction = function(node) {\n node.id = null;\n if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; }\n if (this.options.ecmaVersion >= 8) { node.async = false; }\n};\n\n// Parse object or class method.\n\npp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {\n var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;\n\n this.initFunction(node);\n if (this.options.ecmaVersion >= 6)\n { node.generator = isGenerator; }\n if (this.options.ecmaVersion >= 8)\n { node.async = !!isAsync; }\n\n this.yieldPos = 0;\n this.awaitPos = 0;\n this.awaitIdentPos = 0;\n this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));\n\n this.expect(types$1.parenL);\n node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);\n this.checkYieldAwaitInDefaultParams();\n this.parseFunctionBody(node, false, true, false);\n\n this.yieldPos = oldYieldPos;\n this.awaitPos = oldAwaitPos;\n this.awaitIdentPos = oldAwaitIdentPos;\n return this.finishNode(node, \"FunctionExpression\")\n};\n\n// Parse arrow function expression with given parameters.\n\npp$5.parseArrowExpression = function(node, params, isAsync, forInit) {\n var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;\n\n this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);\n this.initFunction(node);\n if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; }\n\n this.yieldPos = 0;\n this.awaitPos = 0;\n this.awaitIdentPos = 0;\n\n node.params = this.toAssignableList(params, true);\n this.parseFunctionBody(node, true, false, forInit);\n\n this.yieldPos = oldYieldPos;\n this.awaitPos = oldAwaitPos;\n this.awaitIdentPos = oldAwaitIdentPos;\n return this.finishNode(node, \"ArrowFunctionExpression\")\n};\n\n// Parse function body and check parameters.\n\npp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {\n var isExpression = isArrowFunction && this.type !== types$1.braceL;\n var oldStrict = this.strict, useStrict = false;\n\n if (isExpression) {\n node.body = this.parseMaybeAssign(forInit);\n node.expression = true;\n this.checkParams(node, false);\n } else {\n var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);\n if (!oldStrict || nonSimple) {\n useStrict = this.strictDirective(this.end);\n // If this is a strict mode function, verify that argument names\n // are not repeated, and it does not try to bind the words `eval`\n // or `arguments`.\n if (useStrict && nonSimple)\n { this.raiseRecoverable(node.start, \"Illegal 'use strict' directive in function with non-simple parameter list\"); }\n }\n // Start a new scope with regard to labels and the `inFunction`\n // flag (restore them to their old value afterwards).\n var oldLabels = this.labels;\n this.labels = [];\n if (useStrict) { this.strict = true; }\n\n // Add the params to varDeclaredNames to ensure that an error is thrown\n // if a let/const declaration in the function clashes with one of the params.\n this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));\n // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'\n if (this.strict && node.id) { this.checkLValSimple(node.id, BIND_OUTSIDE); }\n node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);\n node.expression = false;\n this.adaptDirectivePrologue(node.body.body);\n this.labels = oldLabels;\n }\n this.exitScope();\n};\n\npp$5.isSimpleParamList = function(params) {\n for (var i = 0, list = params; i < list.length; i += 1)\n {\n var param = list[i];\n\n if (param.type !== \"Identifier\") { return false\n } }\n return true\n};\n\n// Checks function params for various disallowed patterns such as using \"eval\"\n// or \"arguments\" and duplicate parameters.\n\npp$5.checkParams = function(node, allowDuplicates) {\n var nameHash = Object.create(null);\n for (var i = 0, list = node.params; i < list.length; i += 1)\n {\n var param = list[i];\n\n this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);\n }\n};\n\n// Parses a comma-separated list of expressions, and returns them as\n// an array. `close` is the token type that ends the list, and\n// `allowEmpty` can be turned on to allow subsequent commas with\n// nothing in between them to be parsed as `null` (which is needed\n// for array literals).\n\npp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {\n var elts = [], first = true;\n while (!this.eat(close)) {\n if (!first) {\n this.expect(types$1.comma);\n if (allowTrailingComma && this.afterTrailingComma(close)) { break }\n } else { first = false; }\n\n var elt = (void 0);\n if (allowEmpty && this.type === types$1.comma)\n { elt = null; }\n else if (this.type === types$1.ellipsis) {\n elt = this.parseSpread(refDestructuringErrors);\n if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0)\n { refDestructuringErrors.trailingComma = this.start; }\n } else {\n elt = this.parseMaybeAssign(false, refDestructuringErrors);\n }\n elts.push(elt);\n }\n return elts\n};\n\npp$5.checkUnreserved = function(ref) {\n var start = ref.start;\n var end = ref.end;\n var name = ref.name;\n\n if (this.inGenerator && name === \"yield\")\n { this.raiseRecoverable(start, \"Cannot use 'yield' as identifier inside a generator\"); }\n if (this.inAsync && name === \"await\")\n { this.raiseRecoverable(start, \"Cannot use 'await' as identifier inside an async function\"); }\n if (this.currentThisScope().inClassFieldInit && name === \"arguments\")\n { this.raiseRecoverable(start, \"Cannot use 'arguments' in class field initializer\"); }\n if (this.inClassStaticBlock && (name === \"arguments\" || name === \"await\"))\n { this.raise(start, (\"Cannot use \" + name + \" in class static initialization block\")); }\n if (this.keywords.test(name))\n { this.raise(start, (\"Unexpected keyword '\" + name + \"'\")); }\n if (this.options.ecmaVersion < 6 &&\n this.input.slice(start, end).indexOf(\"\\\\\") !== -1) { return }\n var re = this.strict ? this.reservedWordsStrict : this.reservedWords;\n if (re.test(name)) {\n if (!this.inAsync && name === \"await\")\n { this.raiseRecoverable(start, \"Cannot use keyword 'await' outside an async function\"); }\n this.raiseRecoverable(start, (\"The keyword '\" + name + \"' is reserved\"));\n }\n};\n\n// Parse the next token as an identifier. If `liberal` is true (used\n// when parsing properties), it will also convert keywords into\n// identifiers.\n\npp$5.parseIdent = function(liberal) {\n var node = this.startNode();\n if (this.type === types$1.name) {\n node.name = this.value;\n } else if (this.type.keyword) {\n node.name = this.type.keyword;\n\n // To fix https://github.com/acornjs/acorn/issues/575\n // `class` and `function` keywords push new context into this.context.\n // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.\n // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword\n if ((node.name === \"class\" || node.name === \"function\") &&\n (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {\n this.context.pop();\n }\n } else {\n this.unexpected();\n }\n this.next(!!liberal);\n this.finishNode(node, \"Identifier\");\n if (!liberal) {\n this.checkUnreserved(node);\n if (node.name === \"await\" && !this.awaitIdentPos)\n { this.awaitIdentPos = node.start; }\n }\n return node\n};\n\npp$5.parsePrivateIdent = function() {\n var node = this.startNode();\n if (this.type === types$1.privateId) {\n node.name = this.value;\n } else {\n this.unexpected();\n }\n this.next();\n this.finishNode(node, \"PrivateIdentifier\");\n\n // For validating existence\n if (this.privateNameStack.length === 0) {\n this.raise(node.start, (\"Private field '#\" + (node.name) + \"' must be declared in an enclosing class\"));\n } else {\n this.privateNameStack[this.privateNameStack.length - 1].used.push(node);\n }\n\n return node\n};\n\n// Parses yield expression inside generator.\n\npp$5.parseYield = function(forInit) {\n if (!this.yieldPos) { this.yieldPos = this.start; }\n\n var node = this.startNode();\n this.next();\n if (this.type === types$1.semi || this.canInsertSemicolon() || (this.type !== types$1.star && !this.type.startsExpr)) {\n node.delegate = false;\n node.argument = null;\n } else {\n node.delegate = this.eat(types$1.star);\n node.argument = this.parseMaybeAssign(forInit);\n }\n return this.finishNode(node, \"YieldExpression\")\n};\n\npp$5.parseAwait = function(forInit) {\n if (!this.awaitPos) { this.awaitPos = this.start; }\n\n var node = this.startNode();\n this.next();\n node.argument = this.parseMaybeUnary(null, true, false, forInit);\n return this.finishNode(node, \"AwaitExpression\")\n};\n\nvar pp$4 = Parser.prototype;\n\n// This function is used to raise exceptions on parse errors. It\n// takes an offset integer (into the current `input`) to indicate\n// the location of the error, attaches the position to the end\n// of the error message, and then raises a `SyntaxError` with that\n// message.\n\npp$4.raise = function(pos, message) {\n var loc = getLineInfo(this.input, pos);\n message += \" (\" + loc.line + \":\" + loc.column + \")\";\n var err = new SyntaxError(message);\n err.pos = pos; err.loc = loc; err.raisedAt = this.pos;\n throw err\n};\n\npp$4.raiseRecoverable = pp$4.raise;\n\npp$4.curPosition = function() {\n if (this.options.locations) {\n return new Position(this.curLine, this.pos - this.lineStart)\n }\n};\n\nvar pp$3 = Parser.prototype;\n\nvar Scope = function Scope(flags) {\n this.flags = flags;\n // A list of var-declared names in the current lexical scope\n this.var = [];\n // A list of lexically-declared names in the current lexical scope\n this.lexical = [];\n // A list of lexically-declared FunctionDeclaration names in the current lexical scope\n this.functions = [];\n // A switch to disallow the identifier reference 'arguments'\n this.inClassFieldInit = false;\n};\n\n// The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.\n\npp$3.enterScope = function(flags) {\n this.scopeStack.push(new Scope(flags));\n};\n\npp$3.exitScope = function() {\n this.scopeStack.pop();\n};\n\n// The spec says:\n// > At the top level of a function, or script, function declarations are\n// > treated like var declarations rather than like lexical declarations.\npp$3.treatFunctionsAsVarInScope = function(scope) {\n return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP)\n};\n\npp$3.declareName = function(name, bindingType, pos) {\n var redeclared = false;\n if (bindingType === BIND_LEXICAL) {\n var scope = this.currentScope();\n redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;\n scope.lexical.push(name);\n if (this.inModule && (scope.flags & SCOPE_TOP))\n { delete this.undefinedExports[name]; }\n } else if (bindingType === BIND_SIMPLE_CATCH) {\n var scope$1 = this.currentScope();\n scope$1.lexical.push(name);\n } else if (bindingType === BIND_FUNCTION) {\n var scope$2 = this.currentScope();\n if (this.treatFunctionsAsVar)\n { redeclared = scope$2.lexical.indexOf(name) > -1; }\n else\n { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; }\n scope$2.functions.push(name);\n } else {\n for (var i = this.scopeStack.length - 1; i >= 0; --i) {\n var scope$3 = this.scopeStack[i];\n if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) ||\n !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {\n redeclared = true;\n break\n }\n scope$3.var.push(name);\n if (this.inModule && (scope$3.flags & SCOPE_TOP))\n { delete this.undefinedExports[name]; }\n if (scope$3.flags & SCOPE_VAR) { break }\n }\n }\n if (redeclared) { this.raiseRecoverable(pos, (\"Identifier '\" + name + \"' has already been declared\")); }\n};\n\npp$3.checkLocalExport = function(id) {\n // scope.functions must be empty as Module code is always strict.\n if (this.scopeStack[0].lexical.indexOf(id.name) === -1 &&\n this.scopeStack[0].var.indexOf(id.name) === -1) {\n this.undefinedExports[id.name] = id;\n }\n};\n\npp$3.currentScope = function() {\n return this.scopeStack[this.scopeStack.length - 1]\n};\n\npp$3.currentVarScope = function() {\n for (var i = this.scopeStack.length - 1;; i--) {\n var scope = this.scopeStack[i];\n if (scope.flags & SCOPE_VAR) { return scope }\n }\n};\n\n// Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.\npp$3.currentThisScope = function() {\n for (var i = this.scopeStack.length - 1;; i--) {\n var scope = this.scopeStack[i];\n if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope }\n }\n};\n\nvar Node = function Node(parser, pos, loc) {\n this.type = \"\";\n this.start = pos;\n this.end = 0;\n if (parser.options.locations)\n { this.loc = new SourceLocation(parser, loc); }\n if (parser.options.directSourceFile)\n { this.sourceFile = parser.options.directSourceFile; }\n if (parser.options.ranges)\n { this.range = [pos, 0]; }\n};\n\n// Start an AST node, attaching a start offset.\n\nvar pp$2 = Parser.prototype;\n\npp$2.startNode = function() {\n return new Node(this, this.start, this.startLoc)\n};\n\npp$2.startNodeAt = function(pos, loc) {\n return new Node(this, pos, loc)\n};\n\n// Finish an AST node, adding `type` and `end` properties.\n\nfunction finishNodeAt(node, type, pos, loc) {\n node.type = type;\n node.end = pos;\n if (this.options.locations)\n { node.loc.end = loc; }\n if (this.options.ranges)\n { node.range[1] = pos; }\n return node\n}\n\npp$2.finishNode = function(node, type) {\n return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)\n};\n\n// Finish node at given position\n\npp$2.finishNodeAt = function(node, type, pos, loc) {\n return finishNodeAt.call(this, node, type, pos, loc)\n};\n\npp$2.copyNode = function(node) {\n var newNode = new Node(this, node.start, this.startLoc);\n for (var prop in node) { newNode[prop] = node[prop]; }\n return newNode\n};\n\n// This file contains Unicode properties extracted from the ECMAScript specification.\n// The lists are extracted like so:\n// $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)\n\n// #table-binary-unicode-properties\nvar ecma9BinaryProperties = \"ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS\";\nvar ecma10BinaryProperties = ecma9BinaryProperties + \" Extended_Pictographic\";\nvar ecma11BinaryProperties = ecma10BinaryProperties;\nvar ecma12BinaryProperties = ecma11BinaryProperties + \" EBase EComp EMod EPres ExtPict\";\nvar ecma13BinaryProperties = ecma12BinaryProperties;\nvar ecma14BinaryProperties = ecma13BinaryProperties;\n\nvar unicodeBinaryProperties = {\n 9: ecma9BinaryProperties,\n 10: ecma10BinaryProperties,\n 11: ecma11BinaryProperties,\n 12: ecma12BinaryProperties,\n 13: ecma13BinaryProperties,\n 14: ecma14BinaryProperties\n};\n\n// #table-unicode-general-category-values\nvar unicodeGeneralCategoryValues = \"Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu\";\n\n// #table-unicode-script-values\nvar ecma9ScriptValues = \"Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb\";\nvar ecma10ScriptValues = ecma9ScriptValues + \" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd\";\nvar ecma11ScriptValues = ecma10ScriptValues + \" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho\";\nvar ecma12ScriptValues = ecma11ScriptValues + \" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi\";\nvar ecma13ScriptValues = ecma12ScriptValues + \" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith\";\nvar ecma14ScriptValues = ecma13ScriptValues + \" Kawi Nag_Mundari Nagm\";\n\nvar unicodeScriptValues = {\n 9: ecma9ScriptValues,\n 10: ecma10ScriptValues,\n 11: ecma11ScriptValues,\n 12: ecma12ScriptValues,\n 13: ecma13ScriptValues,\n 14: ecma14ScriptValues\n};\n\nvar data = {};\nfunction buildUnicodeData(ecmaVersion) {\n var d = data[ecmaVersion] = {\n binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + \" \" + unicodeGeneralCategoryValues),\n nonBinary: {\n General_Category: wordsRegexp(unicodeGeneralCategoryValues),\n Script: wordsRegexp(unicodeScriptValues[ecmaVersion])\n }\n };\n d.nonBinary.Script_Extensions = d.nonBinary.Script;\n\n d.nonBinary.gc = d.nonBinary.General_Category;\n d.nonBinary.sc = d.nonBinary.Script;\n d.nonBinary.scx = d.nonBinary.Script_Extensions;\n}\n\nfor (var i = 0, list = [9, 10, 11, 12, 13, 14]; i < list.length; i += 1) {\n var ecmaVersion = list[i];\n\n buildUnicodeData(ecmaVersion);\n}\n\nvar pp$1 = Parser.prototype;\n\nvar RegExpValidationState = function RegExpValidationState(parser) {\n this.parser = parser;\n this.validFlags = \"gim\" + (parser.options.ecmaVersion >= 6 ? \"uy\" : \"\") + (parser.options.ecmaVersion >= 9 ? \"s\" : \"\") + (parser.options.ecmaVersion >= 13 ? \"d\" : \"\");\n this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.options.ecmaVersion];\n this.source = \"\";\n this.flags = \"\";\n this.start = 0;\n this.switchU = false;\n this.switchN = false;\n this.pos = 0;\n this.lastIntValue = 0;\n this.lastStringValue = \"\";\n this.lastAssertionIsQuantifiable = false;\n this.numCapturingParens = 0;\n this.maxBackReference = 0;\n this.groupNames = [];\n this.backReferenceNames = [];\n};\n\nRegExpValidationState.prototype.reset = function reset (start, pattern, flags) {\n var unicode = flags.indexOf(\"u\") !== -1;\n this.start = start | 0;\n this.source = pattern + \"\";\n this.flags = flags;\n this.switchU = unicode && this.parser.options.ecmaVersion >= 6;\n this.switchN = unicode && this.parser.options.ecmaVersion >= 9;\n};\n\nRegExpValidationState.prototype.raise = function raise (message) {\n this.parser.raiseRecoverable(this.start, (\"Invalid regular expression: /\" + (this.source) + \"/: \" + message));\n};\n\n// If u flag is given, this returns the code point at the index (it combines a surrogate pair).\n// Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).\nRegExpValidationState.prototype.at = function at (i, forceU) {\n if ( forceU === void 0 ) forceU = false;\n\n var s = this.source;\n var l = s.length;\n if (i >= l) {\n return -1\n }\n var c = s.charCodeAt(i);\n if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {\n return c\n }\n var next = s.charCodeAt(i + 1);\n return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c\n};\n\nRegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) {\n if ( forceU === void 0 ) forceU = false;\n\n var s = this.source;\n var l = s.length;\n if (i >= l) {\n return l\n }\n var c = s.charCodeAt(i), next;\n if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l ||\n (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {\n return i + 1\n }\n return i + 2\n};\n\nRegExpValidationState.prototype.current = function current (forceU) {\n if ( forceU === void 0 ) forceU = false;\n\n return this.at(this.pos, forceU)\n};\n\nRegExpValidationState.prototype.lookahead = function lookahead (forceU) {\n if ( forceU === void 0 ) forceU = false;\n\n return this.at(this.nextIndex(this.pos, forceU), forceU)\n};\n\nRegExpValidationState.prototype.advance = function advance (forceU) {\n if ( forceU === void 0 ) forceU = false;\n\n this.pos = this.nextIndex(this.pos, forceU);\n};\n\nRegExpValidationState.prototype.eat = function eat (ch, forceU) {\n if ( forceU === void 0 ) forceU = false;\n\n if (this.current(forceU) === ch) {\n this.advance(forceU);\n return true\n }\n return false\n};\n\n/**\n * Validate the flags part of a given RegExpLiteral.\n *\n * @param {RegExpValidationState} state The state to validate RegExp.\n * @returns {void}\n */\npp$1.validateRegExpFlags = function(state) {\n var validFlags = state.validFlags;\n var flags = state.flags;\n\n for (var i = 0; i < flags.length; i++) {\n var flag = flags.charAt(i);\n if (validFlags.indexOf(flag) === -1) {\n this.raise(state.start, \"Invalid regular expression flag\");\n }\n if (flags.indexOf(flag, i + 1) > -1) {\n this.raise(state.start, \"Duplicate regular expression flag\");\n }\n }\n};\n\n/**\n * Validate the pattern part of a given RegExpLiteral.\n *\n * @param {RegExpValidationState} state The state to validate RegExp.\n * @returns {void}\n */\npp$1.validateRegExpPattern = function(state) {\n this.regexp_pattern(state);\n\n // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of\n // parsing contains a |GroupName|, reparse with the goal symbol\n // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*\n // exception if _P_ did not conform to the grammar, if any elements of _P_\n // were not matched by the parse, or if any Early Error conditions exist.\n if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {\n state.switchN = true;\n this.regexp_pattern(state);\n }\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern\npp$1.regexp_pattern = function(state) {\n state.pos = 0;\n state.lastIntValue = 0;\n state.lastStringValue = \"\";\n state.lastAssertionIsQuantifiable = false;\n state.numCapturingParens = 0;\n state.maxBackReference = 0;\n state.groupNames.length = 0;\n state.backReferenceNames.length = 0;\n\n this.regexp_disjunction(state);\n\n if (state.pos !== state.source.length) {\n // Make the same messages as V8.\n if (state.eat(0x29 /* ) */)) {\n state.raise(\"Unmatched ')'\");\n }\n if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) {\n state.raise(\"Lone quantifier brackets\");\n }\n }\n if (state.maxBackReference > state.numCapturingParens) {\n state.raise(\"Invalid escape\");\n }\n for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {\n var name = list[i];\n\n if (state.groupNames.indexOf(name) === -1) {\n state.raise(\"Invalid named capture referenced\");\n }\n }\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction\npp$1.regexp_disjunction = function(state) {\n this.regexp_alternative(state);\n while (state.eat(0x7C /* | */)) {\n this.regexp_alternative(state);\n }\n\n // Make the same message as V8.\n if (this.regexp_eatQuantifier(state, true)) {\n state.raise(\"Nothing to repeat\");\n }\n if (state.eat(0x7B /* { */)) {\n state.raise(\"Lone quantifier brackets\");\n }\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative\npp$1.regexp_alternative = function(state) {\n while (state.pos < state.source.length && this.regexp_eatTerm(state))\n { }\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term\npp$1.regexp_eatTerm = function(state) {\n if (this.regexp_eatAssertion(state)) {\n // Handle `QuantifiableAssertion Quantifier` alternative.\n // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion\n // is a QuantifiableAssertion.\n if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {\n // Make the same message as V8.\n if (state.switchU) {\n state.raise(\"Invalid quantifier\");\n }\n }\n return true\n }\n\n if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {\n this.regexp_eatQuantifier(state);\n return true\n }\n\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion\npp$1.regexp_eatAssertion = function(state) {\n var start = state.pos;\n state.lastAssertionIsQuantifiable = false;\n\n // ^, $\n if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {\n return true\n }\n\n // \\b \\B\n if (state.eat(0x5C /* \\ */)) {\n if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {\n return true\n }\n state.pos = start;\n }\n\n // Lookahead / Lookbehind\n if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {\n var lookbehind = false;\n if (this.options.ecmaVersion >= 9) {\n lookbehind = state.eat(0x3C /* < */);\n }\n if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {\n this.regexp_disjunction(state);\n if (!state.eat(0x29 /* ) */)) {\n state.raise(\"Unterminated group\");\n }\n state.lastAssertionIsQuantifiable = !lookbehind;\n return true\n }\n }\n\n state.pos = start;\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier\npp$1.regexp_eatQuantifier = function(state, noError) {\n if ( noError === void 0 ) noError = false;\n\n if (this.regexp_eatQuantifierPrefix(state, noError)) {\n state.eat(0x3F /* ? */);\n return true\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix\npp$1.regexp_eatQuantifierPrefix = function(state, noError) {\n return (\n state.eat(0x2A /* * */) ||\n state.eat(0x2B /* + */) ||\n state.eat(0x3F /* ? */) ||\n this.regexp_eatBracedQuantifier(state, noError)\n )\n};\npp$1.regexp_eatBracedQuantifier = function(state, noError) {\n var start = state.pos;\n if (state.eat(0x7B /* { */)) {\n var min = 0, max = -1;\n if (this.regexp_eatDecimalDigits(state)) {\n min = state.lastIntValue;\n if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {\n max = state.lastIntValue;\n }\n if (state.eat(0x7D /* } */)) {\n // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term\n if (max !== -1 && max < min && !noError) {\n state.raise(\"numbers out of order in {} quantifier\");\n }\n return true\n }\n }\n if (state.switchU && !noError) {\n state.raise(\"Incomplete quantifier\");\n }\n state.pos = start;\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Atom\npp$1.regexp_eatAtom = function(state) {\n return (\n this.regexp_eatPatternCharacters(state) ||\n state.eat(0x2E /* . */) ||\n this.regexp_eatReverseSolidusAtomEscape(state) ||\n this.regexp_eatCharacterClass(state) ||\n this.regexp_eatUncapturingGroup(state) ||\n this.regexp_eatCapturingGroup(state)\n )\n};\npp$1.regexp_eatReverseSolidusAtomEscape = function(state) {\n var start = state.pos;\n if (state.eat(0x5C /* \\ */)) {\n if (this.regexp_eatAtomEscape(state)) {\n return true\n }\n state.pos = start;\n }\n return false\n};\npp$1.regexp_eatUncapturingGroup = function(state) {\n var start = state.pos;\n if (state.eat(0x28 /* ( */)) {\n if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {\n this.regexp_disjunction(state);\n if (state.eat(0x29 /* ) */)) {\n return true\n }\n state.raise(\"Unterminated group\");\n }\n state.pos = start;\n }\n return false\n};\npp$1.regexp_eatCapturingGroup = function(state) {\n if (state.eat(0x28 /* ( */)) {\n if (this.options.ecmaVersion >= 9) {\n this.regexp_groupSpecifier(state);\n } else if (state.current() === 0x3F /* ? */) {\n state.raise(\"Invalid group\");\n }\n this.regexp_disjunction(state);\n if (state.eat(0x29 /* ) */)) {\n state.numCapturingParens += 1;\n return true\n }\n state.raise(\"Unterminated group\");\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom\npp$1.regexp_eatExtendedAtom = function(state) {\n return (\n state.eat(0x2E /* . */) ||\n this.regexp_eatReverseSolidusAtomEscape(state) ||\n this.regexp_eatCharacterClass(state) ||\n this.regexp_eatUncapturingGroup(state) ||\n this.regexp_eatCapturingGroup(state) ||\n this.regexp_eatInvalidBracedQuantifier(state) ||\n this.regexp_eatExtendedPatternCharacter(state)\n )\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier\npp$1.regexp_eatInvalidBracedQuantifier = function(state) {\n if (this.regexp_eatBracedQuantifier(state, true)) {\n state.raise(\"Nothing to repeat\");\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter\npp$1.regexp_eatSyntaxCharacter = function(state) {\n var ch = state.current();\n if (isSyntaxCharacter(ch)) {\n state.lastIntValue = ch;\n state.advance();\n return true\n }\n return false\n};\nfunction isSyntaxCharacter(ch) {\n return (\n ch === 0x24 /* $ */ ||\n ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||\n ch === 0x2E /* . */ ||\n ch === 0x3F /* ? */ ||\n ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||\n ch >= 0x7B /* { */ && ch <= 0x7D /* } */\n )\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter\n// But eat eager.\npp$1.regexp_eatPatternCharacters = function(state) {\n var start = state.pos;\n var ch = 0;\n while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {\n state.advance();\n }\n return state.pos !== start\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter\npp$1.regexp_eatExtendedPatternCharacter = function(state) {\n var ch = state.current();\n if (\n ch !== -1 &&\n ch !== 0x24 /* $ */ &&\n !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) &&\n ch !== 0x2E /* . */ &&\n ch !== 0x3F /* ? */ &&\n ch !== 0x5B /* [ */ &&\n ch !== 0x5E /* ^ */ &&\n ch !== 0x7C /* | */\n ) {\n state.advance();\n return true\n }\n return false\n};\n\n// GroupSpecifier ::\n// [empty]\n// `?` GroupName\npp$1.regexp_groupSpecifier = function(state) {\n if (state.eat(0x3F /* ? */)) {\n if (this.regexp_eatGroupName(state)) {\n if (state.groupNames.indexOf(state.lastStringValue) !== -1) {\n state.raise(\"Duplicate capture group name\");\n }\n state.groupNames.push(state.lastStringValue);\n return\n }\n state.raise(\"Invalid group\");\n }\n};\n\n// GroupName ::\n// `<` RegExpIdentifierName `>`\n// Note: this updates `state.lastStringValue` property with the eaten name.\npp$1.regexp_eatGroupName = function(state) {\n state.lastStringValue = \"\";\n if (state.eat(0x3C /* < */)) {\n if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {\n return true\n }\n state.raise(\"Invalid capture group name\");\n }\n return false\n};\n\n// RegExpIdentifierName ::\n// RegExpIdentifierStart\n// RegExpIdentifierName RegExpIdentifierPart\n// Note: this updates `state.lastStringValue` property with the eaten name.\npp$1.regexp_eatRegExpIdentifierName = function(state) {\n state.lastStringValue = \"\";\n if (this.regexp_eatRegExpIdentifierStart(state)) {\n state.lastStringValue += codePointToString(state.lastIntValue);\n while (this.regexp_eatRegExpIdentifierPart(state)) {\n state.lastStringValue += codePointToString(state.lastIntValue);\n }\n return true\n }\n return false\n};\n\n// RegExpIdentifierStart ::\n// UnicodeIDStart\n// `$`\n// `_`\n// `\\` RegExpUnicodeEscapeSequence[+U]\npp$1.regexp_eatRegExpIdentifierStart = function(state) {\n var start = state.pos;\n var forceU = this.options.ecmaVersion >= 11;\n var ch = state.current(forceU);\n state.advance(forceU);\n\n if (ch === 0x5C /* \\ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {\n ch = state.lastIntValue;\n }\n if (isRegExpIdentifierStart(ch)) {\n state.lastIntValue = ch;\n return true\n }\n\n state.pos = start;\n return false\n};\nfunction isRegExpIdentifierStart(ch) {\n return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */\n}\n\n// RegExpIdentifierPart ::\n// UnicodeIDContinue\n// `$`\n// `_`\n// `\\` RegExpUnicodeEscapeSequence[+U]\n// \n// \npp$1.regexp_eatRegExpIdentifierPart = function(state) {\n var start = state.pos;\n var forceU = this.options.ecmaVersion >= 11;\n var ch = state.current(forceU);\n state.advance(forceU);\n\n if (ch === 0x5C /* \\ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {\n ch = state.lastIntValue;\n }\n if (isRegExpIdentifierPart(ch)) {\n state.lastIntValue = ch;\n return true\n }\n\n state.pos = start;\n return false\n};\nfunction isRegExpIdentifierPart(ch) {\n return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* */ || ch === 0x200D /* */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape\npp$1.regexp_eatAtomEscape = function(state) {\n if (\n this.regexp_eatBackReference(state) ||\n this.regexp_eatCharacterClassEscape(state) ||\n this.regexp_eatCharacterEscape(state) ||\n (state.switchN && this.regexp_eatKGroupName(state))\n ) {\n return true\n }\n if (state.switchU) {\n // Make the same message as V8.\n if (state.current() === 0x63 /* c */) {\n state.raise(\"Invalid unicode escape\");\n }\n state.raise(\"Invalid escape\");\n }\n return false\n};\npp$1.regexp_eatBackReference = function(state) {\n var start = state.pos;\n if (this.regexp_eatDecimalEscape(state)) {\n var n = state.lastIntValue;\n if (state.switchU) {\n // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape\n if (n > state.maxBackReference) {\n state.maxBackReference = n;\n }\n return true\n }\n if (n <= state.numCapturingParens) {\n return true\n }\n state.pos = start;\n }\n return false\n};\npp$1.regexp_eatKGroupName = function(state) {\n if (state.eat(0x6B /* k */)) {\n if (this.regexp_eatGroupName(state)) {\n state.backReferenceNames.push(state.lastStringValue);\n return true\n }\n state.raise(\"Invalid named reference\");\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape\npp$1.regexp_eatCharacterEscape = function(state) {\n return (\n this.regexp_eatControlEscape(state) ||\n this.regexp_eatCControlLetter(state) ||\n this.regexp_eatZero(state) ||\n this.regexp_eatHexEscapeSequence(state) ||\n this.regexp_eatRegExpUnicodeEscapeSequence(state, false) ||\n (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||\n this.regexp_eatIdentityEscape(state)\n )\n};\npp$1.regexp_eatCControlLetter = function(state) {\n var start = state.pos;\n if (state.eat(0x63 /* c */)) {\n if (this.regexp_eatControlLetter(state)) {\n return true\n }\n state.pos = start;\n }\n return false\n};\npp$1.regexp_eatZero = function(state) {\n if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {\n state.lastIntValue = 0;\n state.advance();\n return true\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape\npp$1.regexp_eatControlEscape = function(state) {\n var ch = state.current();\n if (ch === 0x74 /* t */) {\n state.lastIntValue = 0x09; /* \\t */\n state.advance();\n return true\n }\n if (ch === 0x6E /* n */) {\n state.lastIntValue = 0x0A; /* \\n */\n state.advance();\n return true\n }\n if (ch === 0x76 /* v */) {\n state.lastIntValue = 0x0B; /* \\v */\n state.advance();\n return true\n }\n if (ch === 0x66 /* f */) {\n state.lastIntValue = 0x0C; /* \\f */\n state.advance();\n return true\n }\n if (ch === 0x72 /* r */) {\n state.lastIntValue = 0x0D; /* \\r */\n state.advance();\n return true\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter\npp$1.regexp_eatControlLetter = function(state) {\n var ch = state.current();\n if (isControlLetter(ch)) {\n state.lastIntValue = ch % 0x20;\n state.advance();\n return true\n }\n return false\n};\nfunction isControlLetter(ch) {\n return (\n (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||\n (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)\n )\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence\npp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {\n if ( forceU === void 0 ) forceU = false;\n\n var start = state.pos;\n var switchU = forceU || state.switchU;\n\n if (state.eat(0x75 /* u */)) {\n if (this.regexp_eatFixedHexDigits(state, 4)) {\n var lead = state.lastIntValue;\n if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {\n var leadSurrogateEnd = state.pos;\n if (state.eat(0x5C /* \\ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {\n var trail = state.lastIntValue;\n if (trail >= 0xDC00 && trail <= 0xDFFF) {\n state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;\n return true\n }\n }\n state.pos = leadSurrogateEnd;\n state.lastIntValue = lead;\n }\n return true\n }\n if (\n switchU &&\n state.eat(0x7B /* { */) &&\n this.regexp_eatHexDigits(state) &&\n state.eat(0x7D /* } */) &&\n isValidUnicode(state.lastIntValue)\n ) {\n return true\n }\n if (switchU) {\n state.raise(\"Invalid unicode escape\");\n }\n state.pos = start;\n }\n\n return false\n};\nfunction isValidUnicode(ch) {\n return ch >= 0 && ch <= 0x10FFFF\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape\npp$1.regexp_eatIdentityEscape = function(state) {\n if (state.switchU) {\n if (this.regexp_eatSyntaxCharacter(state)) {\n return true\n }\n if (state.eat(0x2F /* / */)) {\n state.lastIntValue = 0x2F; /* / */\n return true\n }\n return false\n }\n\n var ch = state.current();\n if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {\n state.lastIntValue = ch;\n state.advance();\n return true\n }\n\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape\npp$1.regexp_eatDecimalEscape = function(state) {\n state.lastIntValue = 0;\n var ch = state.current();\n if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {\n do {\n state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);\n state.advance();\n } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)\n return true\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape\npp$1.regexp_eatCharacterClassEscape = function(state) {\n var ch = state.current();\n\n if (isCharacterClassEscape(ch)) {\n state.lastIntValue = -1;\n state.advance();\n return true\n }\n\n if (\n state.switchU &&\n this.options.ecmaVersion >= 9 &&\n (ch === 0x50 /* P */ || ch === 0x70 /* p */)\n ) {\n state.lastIntValue = -1;\n state.advance();\n if (\n state.eat(0x7B /* { */) &&\n this.regexp_eatUnicodePropertyValueExpression(state) &&\n state.eat(0x7D /* } */)\n ) {\n return true\n }\n state.raise(\"Invalid property name\");\n }\n\n return false\n};\nfunction isCharacterClassEscape(ch) {\n return (\n ch === 0x64 /* d */ ||\n ch === 0x44 /* D */ ||\n ch === 0x73 /* s */ ||\n ch === 0x53 /* S */ ||\n ch === 0x77 /* w */ ||\n ch === 0x57 /* W */\n )\n}\n\n// UnicodePropertyValueExpression ::\n// UnicodePropertyName `=` UnicodePropertyValue\n// LoneUnicodePropertyNameOrValue\npp$1.regexp_eatUnicodePropertyValueExpression = function(state) {\n var start = state.pos;\n\n // UnicodePropertyName `=` UnicodePropertyValue\n if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {\n var name = state.lastStringValue;\n if (this.regexp_eatUnicodePropertyValue(state)) {\n var value = state.lastStringValue;\n this.regexp_validateUnicodePropertyNameAndValue(state, name, value);\n return true\n }\n }\n state.pos = start;\n\n // LoneUnicodePropertyNameOrValue\n if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {\n var nameOrValue = state.lastStringValue;\n this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);\n return true\n }\n return false\n};\npp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {\n if (!hasOwn(state.unicodeProperties.nonBinary, name))\n { state.raise(\"Invalid property name\"); }\n if (!state.unicodeProperties.nonBinary[name].test(value))\n { state.raise(\"Invalid property value\"); }\n};\npp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {\n if (!state.unicodeProperties.binary.test(nameOrValue))\n { state.raise(\"Invalid property name\"); }\n};\n\n// UnicodePropertyName ::\n// UnicodePropertyNameCharacters\npp$1.regexp_eatUnicodePropertyName = function(state) {\n var ch = 0;\n state.lastStringValue = \"\";\n while (isUnicodePropertyNameCharacter(ch = state.current())) {\n state.lastStringValue += codePointToString(ch);\n state.advance();\n }\n return state.lastStringValue !== \"\"\n};\nfunction isUnicodePropertyNameCharacter(ch) {\n return isControlLetter(ch) || ch === 0x5F /* _ */\n}\n\n// UnicodePropertyValue ::\n// UnicodePropertyValueCharacters\npp$1.regexp_eatUnicodePropertyValue = function(state) {\n var ch = 0;\n state.lastStringValue = \"\";\n while (isUnicodePropertyValueCharacter(ch = state.current())) {\n state.lastStringValue += codePointToString(ch);\n state.advance();\n }\n return state.lastStringValue !== \"\"\n};\nfunction isUnicodePropertyValueCharacter(ch) {\n return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)\n}\n\n// LoneUnicodePropertyNameOrValue ::\n// UnicodePropertyValueCharacters\npp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {\n return this.regexp_eatUnicodePropertyValue(state)\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass\npp$1.regexp_eatCharacterClass = function(state) {\n if (state.eat(0x5B /* [ */)) {\n state.eat(0x5E /* ^ */);\n this.regexp_classRanges(state);\n if (state.eat(0x5D /* ] */)) {\n return true\n }\n // Unreachable since it threw \"unterminated regular expression\" error before.\n state.raise(\"Unterminated character class\");\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges\n// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges\n// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash\npp$1.regexp_classRanges = function(state) {\n while (this.regexp_eatClassAtom(state)) {\n var left = state.lastIntValue;\n if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {\n var right = state.lastIntValue;\n if (state.switchU && (left === -1 || right === -1)) {\n state.raise(\"Invalid character class\");\n }\n if (left !== -1 && right !== -1 && left > right) {\n state.raise(\"Range out of order in character class\");\n }\n }\n }\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom\n// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash\npp$1.regexp_eatClassAtom = function(state) {\n var start = state.pos;\n\n if (state.eat(0x5C /* \\ */)) {\n if (this.regexp_eatClassEscape(state)) {\n return true\n }\n if (state.switchU) {\n // Make the same message as V8.\n var ch$1 = state.current();\n if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) {\n state.raise(\"Invalid class escape\");\n }\n state.raise(\"Invalid escape\");\n }\n state.pos = start;\n }\n\n var ch = state.current();\n if (ch !== 0x5D /* ] */) {\n state.lastIntValue = ch;\n state.advance();\n return true\n }\n\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape\npp$1.regexp_eatClassEscape = function(state) {\n var start = state.pos;\n\n if (state.eat(0x62 /* b */)) {\n state.lastIntValue = 0x08; /* */\n return true\n }\n\n if (state.switchU && state.eat(0x2D /* - */)) {\n state.lastIntValue = 0x2D; /* - */\n return true\n }\n\n if (!state.switchU && state.eat(0x63 /* c */)) {\n if (this.regexp_eatClassControlLetter(state)) {\n return true\n }\n state.pos = start;\n }\n\n return (\n this.regexp_eatCharacterClassEscape(state) ||\n this.regexp_eatCharacterEscape(state)\n )\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter\npp$1.regexp_eatClassControlLetter = function(state) {\n var ch = state.current();\n if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {\n state.lastIntValue = ch % 0x20;\n state.advance();\n return true\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence\npp$1.regexp_eatHexEscapeSequence = function(state) {\n var start = state.pos;\n if (state.eat(0x78 /* x */)) {\n if (this.regexp_eatFixedHexDigits(state, 2)) {\n return true\n }\n if (state.switchU) {\n state.raise(\"Invalid escape\");\n }\n state.pos = start;\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits\npp$1.regexp_eatDecimalDigits = function(state) {\n var start = state.pos;\n var ch = 0;\n state.lastIntValue = 0;\n while (isDecimalDigit(ch = state.current())) {\n state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);\n state.advance();\n }\n return state.pos !== start\n};\nfunction isDecimalDigit(ch) {\n return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits\npp$1.regexp_eatHexDigits = function(state) {\n var start = state.pos;\n var ch = 0;\n state.lastIntValue = 0;\n while (isHexDigit(ch = state.current())) {\n state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);\n state.advance();\n }\n return state.pos !== start\n};\nfunction isHexDigit(ch) {\n return (\n (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||\n (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||\n (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)\n )\n}\nfunction hexToInt(ch) {\n if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {\n return 10 + (ch - 0x41 /* A */)\n }\n if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {\n return 10 + (ch - 0x61 /* a */)\n }\n return ch - 0x30 /* 0 */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence\n// Allows only 0-377(octal) i.e. 0-255(decimal).\npp$1.regexp_eatLegacyOctalEscapeSequence = function(state) {\n if (this.regexp_eatOctalDigit(state)) {\n var n1 = state.lastIntValue;\n if (this.regexp_eatOctalDigit(state)) {\n var n2 = state.lastIntValue;\n if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {\n state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;\n } else {\n state.lastIntValue = n1 * 8 + n2;\n }\n } else {\n state.lastIntValue = n1;\n }\n return true\n }\n return false\n};\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit\npp$1.regexp_eatOctalDigit = function(state) {\n var ch = state.current();\n if (isOctalDigit(ch)) {\n state.lastIntValue = ch - 0x30; /* 0 */\n state.advance();\n return true\n }\n state.lastIntValue = 0;\n return false\n};\nfunction isOctalDigit(ch) {\n return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */\n}\n\n// https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits\n// https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit\n// And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence\npp$1.regexp_eatFixedHexDigits = function(state, length) {\n var start = state.pos;\n state.lastIntValue = 0;\n for (var i = 0; i < length; ++i) {\n var ch = state.current();\n if (!isHexDigit(ch)) {\n state.pos = start;\n return false\n }\n state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);\n state.advance();\n }\n return true\n};\n\n// Object type used to represent tokens. Note that normally, tokens\n// simply exist as properties on the parser object. This is only\n// used for the onToken callback and the external tokenizer.\n\nvar Token = function Token(p) {\n this.type = p.type;\n this.value = p.value;\n this.start = p.start;\n this.end = p.end;\n if (p.options.locations)\n { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); }\n if (p.options.ranges)\n { this.range = [p.start, p.end]; }\n};\n\n// ## Tokenizer\n\nvar pp = Parser.prototype;\n\n// Move to the next token\n\npp.next = function(ignoreEscapeSequenceInKeyword) {\n if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)\n { this.raiseRecoverable(this.start, \"Escape sequence in keyword \" + this.type.keyword); }\n if (this.options.onToken)\n { this.options.onToken(new Token(this)); }\n\n this.lastTokEnd = this.end;\n this.lastTokStart = this.start;\n this.lastTokEndLoc = this.endLoc;\n this.lastTokStartLoc = this.startLoc;\n this.nextToken();\n};\n\npp.getToken = function() {\n this.next();\n return new Token(this)\n};\n\n// If we're in an ES6 environment, make parsers iterable\nif (typeof Symbol !== \"undefined\")\n { pp[Symbol.iterator] = function() {\n var this$1$1 = this;\n\n return {\n next: function () {\n var token = this$1$1.getToken();\n return {\n done: token.type === types$1.eof,\n value: token\n }\n }\n }\n }; }\n\n// Toggle strict mode. Re-reads the next number or string to please\n// pedantic tests (`\"use strict\"; 010;` should fail).\n\n// Read a single token, updating the parser object's token-related\n// properties.\n\npp.nextToken = function() {\n var curContext = this.curContext();\n if (!curContext || !curContext.preserveSpace) { this.skipSpace(); }\n\n this.start = this.pos;\n if (this.options.locations) { this.startLoc = this.curPosition(); }\n if (this.pos >= this.input.length) { return this.finishToken(types$1.eof) }\n\n if (curContext.override) { return curContext.override(this) }\n else { this.readToken(this.fullCharCodeAtPos()); }\n};\n\npp.readToken = function(code) {\n // Identifier or keyword. '\\uXXXX' sequences are allowed in\n // identifiers, so '\\' also dispatches to that.\n if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\\' */)\n { return this.readWord() }\n\n return this.getTokenFromCode(code)\n};\n\npp.fullCharCodeAtPos = function() {\n var code = this.input.charCodeAt(this.pos);\n if (code <= 0xd7ff || code >= 0xdc00) { return code }\n var next = this.input.charCodeAt(this.pos + 1);\n return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00\n};\n\npp.skipBlockComment = function() {\n var startLoc = this.options.onComment && this.curPosition();\n var start = this.pos, end = this.input.indexOf(\"*/\", this.pos += 2);\n if (end === -1) { this.raise(this.pos - 2, \"Unterminated comment\"); }\n this.pos = end + 2;\n if (this.options.locations) {\n for (var nextBreak = (void 0), pos = start; (nextBreak = nextLineBreak(this.input, pos, this.pos)) > -1;) {\n ++this.curLine;\n pos = this.lineStart = nextBreak;\n }\n }\n if (this.options.onComment)\n { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,\n startLoc, this.curPosition()); }\n};\n\npp.skipLineComment = function(startSkip) {\n var start = this.pos;\n var startLoc = this.options.onComment && this.curPosition();\n var ch = this.input.charCodeAt(this.pos += startSkip);\n while (this.pos < this.input.length && !isNewLine(ch)) {\n ch = this.input.charCodeAt(++this.pos);\n }\n if (this.options.onComment)\n { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,\n startLoc, this.curPosition()); }\n};\n\n// Called at the start of the parse and after every token. Skips\n// whitespace and comments, and.\n\npp.skipSpace = function() {\n loop: while (this.pos < this.input.length) {\n var ch = this.input.charCodeAt(this.pos);\n switch (ch) {\n case 32: case 160: // ' '\n ++this.pos;\n break\n case 13:\n if (this.input.charCodeAt(this.pos + 1) === 10) {\n ++this.pos;\n }\n case 10: case 8232: case 8233:\n ++this.pos;\n if (this.options.locations) {\n ++this.curLine;\n this.lineStart = this.pos;\n }\n break\n case 47: // '/'\n switch (this.input.charCodeAt(this.pos + 1)) {\n case 42: // '*'\n this.skipBlockComment();\n break\n case 47:\n this.skipLineComment(2);\n break\n default:\n break loop\n }\n break\n default:\n if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {\n ++this.pos;\n } else {\n break loop\n }\n }\n }\n};\n\n// Called at the end of every token. Sets `end`, `val`, and\n// maintains `context` and `exprAllowed`, and skips the space after\n// the token, so that the next one's `start` will point at the\n// right position.\n\npp.finishToken = function(type, val) {\n this.end = this.pos;\n if (this.options.locations) { this.endLoc = this.curPosition(); }\n var prevType = this.type;\n this.type = type;\n this.value = val;\n\n this.updateContext(prevType);\n};\n\n// ### Token reading\n\n// This is the function that is called to fetch the next token. It\n// is somewhat obscure, because it works in character codes rather\n// than characters, and because operator parsing has been inlined\n// into it.\n//\n// All in the name of speed.\n//\npp.readToken_dot = function() {\n var next = this.input.charCodeAt(this.pos + 1);\n if (next >= 48 && next <= 57) { return this.readNumber(true) }\n var next2 = this.input.charCodeAt(this.pos + 2);\n if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'\n this.pos += 3;\n return this.finishToken(types$1.ellipsis)\n } else {\n ++this.pos;\n return this.finishToken(types$1.dot)\n }\n};\n\npp.readToken_slash = function() { // '/'\n var next = this.input.charCodeAt(this.pos + 1);\n if (this.exprAllowed) { ++this.pos; return this.readRegexp() }\n if (next === 61) { return this.finishOp(types$1.assign, 2) }\n return this.finishOp(types$1.slash, 1)\n};\n\npp.readToken_mult_modulo_exp = function(code) { // '%*'\n var next = this.input.charCodeAt(this.pos + 1);\n var size = 1;\n var tokentype = code === 42 ? types$1.star : types$1.modulo;\n\n // exponentiation operator ** and **=\n if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {\n ++size;\n tokentype = types$1.starstar;\n next = this.input.charCodeAt(this.pos + 2);\n }\n\n if (next === 61) { return this.finishOp(types$1.assign, size + 1) }\n return this.finishOp(tokentype, size)\n};\n\npp.readToken_pipe_amp = function(code) { // '|&'\n var next = this.input.charCodeAt(this.pos + 1);\n if (next === code) {\n if (this.options.ecmaVersion >= 12) {\n var next2 = this.input.charCodeAt(this.pos + 2);\n if (next2 === 61) { return this.finishOp(types$1.assign, 3) }\n }\n return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2)\n }\n if (next === 61) { return this.finishOp(types$1.assign, 2) }\n return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1)\n};\n\npp.readToken_caret = function() { // '^'\n var next = this.input.charCodeAt(this.pos + 1);\n if (next === 61) { return this.finishOp(types$1.assign, 2) }\n return this.finishOp(types$1.bitwiseXOR, 1)\n};\n\npp.readToken_plus_min = function(code) { // '+-'\n var next = this.input.charCodeAt(this.pos + 1);\n if (next === code) {\n if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&\n (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {\n // A `-->` line comment\n this.skipLineComment(3);\n this.skipSpace();\n return this.nextToken()\n }\n return this.finishOp(types$1.incDec, 2)\n }\n if (next === 61) { return this.finishOp(types$1.assign, 2) }\n return this.finishOp(types$1.plusMin, 1)\n};\n\npp.readToken_lt_gt = function(code) { // '<>'\n var next = this.input.charCodeAt(this.pos + 1);\n var size = 1;\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;\n if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) }\n return this.finishOp(types$1.bitShift, size)\n }\n if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&\n this.input.charCodeAt(this.pos + 3) === 45) {\n // `` line comment\n this.skipLineComment(3);\n this.skipSpace();\n return this.nextToken()\n }\n return this.finishOp(types$1.incDec, 2)\n }\n if (next === 61) { return this.finishOp(types$1.assign, 2) }\n return this.finishOp(types$1.plusMin, 1)\n};\n\npp.readToken_lt_gt = function(code) { // '<>'\n var next = this.input.charCodeAt(this.pos + 1);\n var size = 1;\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;\n if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) }\n return this.finishOp(types$1.bitShift, size)\n }\n if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&\n this.input.charCodeAt(this.pos + 3) === 45) {\n // `