var Rooc=(()=>{var Ct=Object.create;var Q=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,kt=Object.prototype.hasOwnProperty;var I=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Ut=(i,e)=>{for(var t in e)Q(i,t,{get:e[t],enumerable:!0})},ye=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Dt(e))!kt.call(i,n)&&n!==t&&Q(i,n,{get:()=>e[n],enumerable:!(r=Tt(e,n))||r.enumerable});return i};var Bt=(i,e,t)=>(t=i!=null?Ct(Lt(i)):{},ye(e||!i||!i.__esModule?Q(t,"default",{value:i,enumerable:!0}):t,i)),Mt=i=>ye(Q({},"__esModule",{value:!0}),i);var re=I((oi,Ye)=>{"use strict";var Nr="\0",q="\0",qe="",he=class{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(e){e&&(this._isDirected=Object.hasOwn(e,"directed")?e.directed:!0,this._isMultigraph=Object.hasOwn(e,"multigraph")?e.multigraph:!1,this._isCompound=Object.hasOwn(e,"compound")?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[q]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,typeof e!="function"&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter(t=>Object.keys(e._in[t]).length===0)}sinks(){var e=this;return this.nodes().filter(t=>Object.keys(e._out[t]).length===0)}setNodes(e,t){var r=arguments,n=this;return e.forEach(function(s){r.length>1?n.setNode(s,t):n.setNode(s)}),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=q,this._children[e]={},this._children[q][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var r=n=>t.removeEdge(t._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(function(n){t.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(r),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t=q;else{t+="";for(var r=t;r!==void 0;r=this.parent(r))if(r===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==q)return t}}children(e=q){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else{if(e===q)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){let n=new Set(t);for(var r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){var t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var r=this;Object.entries(this._nodes).forEach(function([o,a]){e(o)&&t.setNode(o,a)}),Object.values(this._edgeObjs).forEach(function(o){t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,r.edge(o))});var n={};function s(o){var a=r.parent(o);return a===void 0||t.hasNode(a)?(n[o]=a,a):a in n?n[a]:s(a)}return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,s(o))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,typeof e!="function"&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var r=this,n=arguments;return e.reduce(function(s,o){return n.length>1?r.setEdge(s,o,t):r.setEdge(s,o),o}),this}setEdge(){var e,t,r,n,s=!1,o=arguments[0];typeof o=="object"&&o!==null&&"v"in o?(e=o.v,t=o.w,r=o.name,arguments.length===2&&(n=arguments[1],s=!0)):(e=o,t=arguments[1],r=arguments[3],arguments.length>2&&(n=arguments[2],s=!0)),e=""+e,t=""+t,r!==void 0&&(r=""+r);var a=V(this._isDirected,e,t,r);if(Object.hasOwn(this._edgeLabels,a))return s&&(this._edgeLabels[a]=n),this;if(r!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[a]=s?n:this._defaultEdgeLabelFn(e,t,r);var f=Sr(this._isDirected,e,t,r);return e=f.v,t=f.w,Object.freeze(f),this._edgeObjs[a]=f,$e(this._preds[t],e),$e(this._sucs[e],t),this._in[t][a]=f,this._out[e][a]=f,this._edgeCount++,this}edge(e,t,r){var n=arguments.length===1?le(this._isDirected,arguments[0]):V(this._isDirected,e,t,r);return this._edgeLabels[n]}edgeAsObj(){let e=this.edge(...arguments);return typeof e!="object"?{label:e}:e}hasEdge(e,t,r){var n=arguments.length===1?le(this._isDirected,arguments[0]):V(this._isDirected,e,t,r);return Object.hasOwn(this._edgeLabels,n)}removeEdge(e,t,r){var n=arguments.length===1?le(this._isDirected,arguments[0]):V(this._isDirected,e,t,r),s=this._edgeObjs[n];return s&&(e=s.v,t=s.w,delete this._edgeLabels[n],delete this._edgeObjs[n],Ve(this._preds[t],e),Ve(this._sucs[e],t),delete this._in[t][n],delete this._out[e][n],this._edgeCount--),this}inEdges(e,t){var r=this._in[e];if(r){var n=Object.values(r);return t?n.filter(s=>s.v===t):n}}outEdges(e,t){var r=this._out[e];if(r){var n=Object.values(r);return t?n.filter(s=>s.w===t):n}}nodeEdges(e,t){var r=this.inEdges(e,t);if(r)return r.concat(this.outEdges(e,t))}};function $e(i,e){i[e]?i[e]++:i[e]=1}function Ve(i,e){--i[e]||delete i[e]}function V(i,e,t,r){var n=""+e,s=""+t;if(!i&&n>s){var o=n;n=s,s=o}return n+qe+s+qe+(r===void 0?Nr:r)}function Sr(i,e,t,r){var n=""+e,s=""+t;if(!i&&n>s){var o=n;n=s,s=o}var a={v:n,w:s};return r&&(a.name=r),a}function le(i,e){return V(i,e.v,e.w,e.name)}Ye.exports=he});var ze=I((ai,Je)=>{Je.exports="2.2.4"});var Qe=I((ui,Ge)=>{Ge.exports={Graph:re(),version:ze()}});var We=I((fi,He)=>{var Ar=re();He.exports={write:Rr,read:Tr};function Rr(i){var e={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:Fr(i),edges:Cr(i)};return i.graph()!==void 0&&(e.value=structuredClone(i.graph())),e}function Fr(i){return i.nodes().map(function(e){var t=i.node(e),r=i.parent(e),n={v:e};return t!==void 0&&(n.value=t),r!==void 0&&(n.parent=r),n})}function Cr(i){return i.edges().map(function(e){var t=i.edge(e),r={v:e.v,w:e.w};return e.name!==void 0&&(r.name=e.name),t!==void 0&&(r.value=t),r})}function Tr(i){var e=new Ar(i.options).setGraph(i.value);return i.nodes.forEach(function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent)}),i.edges.forEach(function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),e}});var Xe=I((li,Ke)=>{Ke.exports=Dr;function Dr(i){var e={},t=[],r;function n(s){Object.hasOwn(e,s)||(e[s]=!0,r.push(s),i.successors(s).forEach(n),i.predecessors(s).forEach(n))}return i.nodes().forEach(function(s){r=[],n(s),r.length&&t.push(r)}),t}});var de=I((hi,Ze)=>{var ce=class{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(e){return e.key})}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){var r=this._keyIndices;if(e=String(e),!Object.hasOwn(r,e)){var n=this._arr,s=n.length;return r[e]=s,n.push({key:e,priority:t}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var r=this._keyIndices[e];if(t>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[r].priority+" New: "+t);this._arr[r].priority=t,this._decrease(r)}_heapify(e){var t=this._arr,r=2*e,n=r+1,s=e;r>1,!(t[n].priority{var Lr=de();et.exports=Ur;var kr=()=>1;function Ur(i,e,t,r){return Br(i,String(e),t||kr,r||function(n){return i.outEdges(n)})}function Br(i,e,t,r){var n={},s=new Lr,o,a,f=function(l){var h=l.v!==o?l.v:l.w,c=n[h],d=t(l),p=a.distance+d;if(d<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+l+" Weight: "+d);p0&&(o=s.removeMin(),a=n[o],a.distance!==Number.POSITIVE_INFINITY);)r(o).forEach(f);return n}});var rt=I((di,tt)=>{var Mr=_e();tt.exports=Pr;function Pr(i,e,t){return i.nodes().reduce(function(r,n){return r[n]=Mr(i,n,e,t),r},{})}});var pe=I((_i,it)=>{it.exports=jr;function jr(i){var e=0,t=[],r={},n=[];function s(o){var a=r[o]={onStack:!0,lowlink:e,index:e++};if(t.push(o),i.successors(o).forEach(function(h){Object.hasOwn(r,h)?r[h].onStack&&(a.lowlink=Math.min(a.lowlink,r[h].index)):(s(h),a.lowlink=Math.min(a.lowlink,r[h].lowlink))}),a.lowlink===a.index){var f=[],l;do l=t.pop(),r[l].onStack=!1,f.push(l);while(o!==l);n.push(f)}}return i.nodes().forEach(function(o){Object.hasOwn(r,o)||s(o)}),n}});var st=I((pi,nt)=>{var qr=pe();nt.exports=$r;function $r(i){return qr(i).filter(function(e){return e.length>1||e.length===1&&i.hasEdge(e[0],e[0])})}});var at=I((mi,ot)=>{ot.exports=Yr;var Vr=()=>1;function Yr(i,e,t){return Jr(i,e||Vr,t||function(r){return i.outEdges(r)})}function Jr(i,e,t){var r={},n=i.nodes();return n.forEach(function(s){r[s]={},r[s][s]={distance:0},n.forEach(function(o){s!==o&&(r[s][o]={distance:Number.POSITIVE_INFINITY})}),t(s).forEach(function(o){var a=o.v===s?o.w:o.v,f=e(o);r[s][a]={distance:f,predecessor:s}})}),n.forEach(function(s){var o=r[s];n.forEach(function(a){var f=r[a];n.forEach(function(l){var h=f[s],c=o[l],d=f[l],p=h.distance+c.distance;p{function ut(i){var e={},t={},r=[];function n(s){if(Object.hasOwn(t,s))throw new Y;Object.hasOwn(e,s)||(t[s]=!0,e[s]=!0,i.predecessors(s).forEach(n),delete t[s],r.push(s))}if(i.sinks().forEach(n),Object.keys(e).length!==i.nodeCount())throw new Y;return r}var Y=class extends Error{constructor(){super(...arguments)}};ft.exports=ut;ut.CycleException=Y});var ct=I((wi,ht)=>{var lt=me();ht.exports=zr;function zr(i){try{lt(i)}catch(e){if(e instanceof lt.CycleException)return!1;throw e}return!0}});var ge=I((yi,_t)=>{_t.exports=Gr;function Gr(i,e,t){Array.isArray(e)||(e=[e]);var r=i.isDirected()?a=>i.successors(a):a=>i.neighbors(a),n=t==="post"?Qr:Hr,s=[],o={};return e.forEach(a=>{if(!i.hasNode(a))throw new Error("Graph does not have node: "+a);n(a,r,o,s)}),s}function Qr(i,e,t,r){for(var n=[[i,!1]];n.length>0;){var s=n.pop();s[1]?r.push(s[0]):Object.hasOwn(t,s[0])||(t[s[0]]=!0,n.push([s[0],!0]),dt(e(s[0]),o=>n.push([o,!1])))}}function Hr(i,e,t,r){for(var n=[i];n.length>0;){var s=n.pop();Object.hasOwn(t,s)||(t[s]=!0,r.push(s),dt(e(s),o=>n.push(o)))}}function dt(i,e){for(var t=i.length;t--;)e(i[t],t,i);return i}});var mt=I((Ei,pt)=>{var Wr=ge();pt.exports=Kr;function Kr(i,e){return Wr(i,e,"post")}});var wt=I((xi,gt)=>{var Xr=ge();gt.exports=Zr;function Zr(i,e){return Xr(i,e,"pre")}});var Et=I((Ii,yt)=>{var ei=re(),ti=de();yt.exports=ri;function ri(i,e){var t=new ei,r={},n=new ti,s;function o(f){var l=f.v===s?f.w:f.v,h=n.priority(l);if(h!==void 0){var c=e(f);c0;){if(s=n.removeMin(),Object.hasOwn(r,s))t.setEdge(s,r[s]);else{if(a)throw new Error("Input graph is not connected: "+i);a=!0}i.nodeEdges(s).forEach(o)}return t}});var It=I((bi,xt)=>{xt.exports={components:Xe(),dijkstra:_e(),dijkstraAll:rt(),findCycles:st(),floydWarshall:at(),isAcyclic:ct(),postorder:mt(),preorder:wt(),prim:Et(),tarjan:pe(),topsort:me()}});var Ot=I((vi,vt)=>{var bt=Qe();vt.exports={Graph:bt.Graph,json:We(),alg:It(),version:bt.version}});var ii={};Ut(ii,{Rooc:()=>Nt});var Ee=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},D=[],R=[],Pt=typeof Uint8Array<"u"?Uint8Array:Array,oe=!1;function Ne(){oe=!0;for(var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=i.length;e0)throw new Error("Invalid string. Length must be a multiple of 4");s=i[a-2]==="="?2:i[a-1]==="="?1:0,o=new Pt(a*3/4-s),r=s>0?a-4:a;var f=0;for(e=0,t=0;e>16&255,o[f++]=n>>8&255,o[f++]=n&255;return s===2?(n=R[i.charCodeAt(e)]<<2|R[i.charCodeAt(e+1)]>>4,o[f++]=n&255):s===1&&(n=R[i.charCodeAt(e)]<<10|R[i.charCodeAt(e+1)]<<4|R[i.charCodeAt(e+2)]>>2,o[f++]=n>>8&255,o[f++]=n&255),o}function qt(i){return D[i>>18&63]+D[i>>12&63]+D[i>>6&63]+D[i&63]}function $t(i,e,t){for(var r,n=[],s=e;sf?f:a+o));return r===1?(e=i[t-1],n+=D[e>>2],n+=D[e<<4&63],n+="=="):r===2&&(e=(i[t-2]<<8)+i[t-1],n+=D[e>>10],n+=D[e>>4&63],n+=D[e<<2&63],n+="="),s.push(n),s.join("")}function X(i,e,t,r,n){var s,o,a=n*8-r-1,f=(1<>1,h=-7,c=t?n-1:0,d=t?-1:1,p=i[e+c];for(c+=d,s=p&(1<<-h)-1,p>>=-h,h+=a;h>0;s=s*256+i[e+c],c+=d,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=r;h>0;o=o*256+i[e+c],c+=d,h-=8);if(s===0)s=1-l;else{if(s===f)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-l}return(p?-1:1)*o*Math.pow(2,s-r)}function Se(i,e,t,r,n,s){var o,a,f,l=s*8-n-1,h=(1<>1,d=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:s-1,b=r?1:-1,y=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-o))<1&&(o--,f*=2),o+c>=1?e+=d/f:e+=d*Math.pow(2,1-c),e*f>=2&&(o++,f/=2),o+c>=h?(a=0,o=h):o+c>=1?(a=(e*f-1)*Math.pow(2,n),o=o+c):(a=e*Math.pow(2,c-1)*Math.pow(2,n),o=0));n>=8;i[t+p]=a&255,p+=b,a/=256,n-=8);for(o=o<0;i[t+p]=o&255,p+=b,o/=256,l-=8);i[t+p-b]|=y*128}var Vt={}.toString,Ae=Array.isArray||function(i){return Vt.call(i)=="[object Array]"},Yt=50;u.TYPED_ARRAY_SUPPORT=Ee.TYPED_ARRAY_SUPPORT!==void 0?Ee.TYPED_ARRAY_SUPPORT:!0;H();function H(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function U(i,e){if(H()=H())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+H().toString(16)+" bytes");return i|0}u.isBuffer=F;function L(i){return!!(i!=null&&i._isBuffer)}u.compare=function(e,t){if(!L(e)||!L(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,s=0,o=Math.min(r,n);s>>1;case"base64":return Me(i).length;default:if(r)return W(i).length;e=(""+e).toLowerCase(),r=!0}}u.byteLength=Ce;function Ht(i,e,t){var r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(i||(i="utf8");;)switch(i){case"hex":return sr(this,e,t);case"utf8":case"utf-8":return Le(this,e,t);case"ascii":return ir(this,e,t);case"latin1":case"binary":return nr(this,e,t);case"base64":return tr(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return or(this,e,t);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),r=!0}}u.prototype._isBuffer=!0;function j(i,e,t){var r=i[e];i[e]=i[t],i[t]=r}u.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""};u.prototype.compare=function(e,t,r,n,s){if(!L(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),r===void 0&&(r=e?e.length:0),n===void 0&&(n=0),s===void 0&&(s=this.length),t<0||r>e.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&t>=r)return 0;if(n>=s)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,s>>>=0,this===e)return 0;for(var o=s-n,a=r-t,f=Math.min(o,a),l=this.slice(n,s),h=e.slice(t,r),c=0;c2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=n?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(n)return-1;t=i.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=u.from(e,r)),L(e))return e.length===0?-1:Ie(i,e,t,r,n);if(typeof e=="number")return e=e&255,u.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(i,e,t):Uint8Array.prototype.lastIndexOf.call(i,e,t):Ie(i,[e],t,r,n);throw new TypeError("val must be string, number or Buffer")}function Ie(i,e,t,r,n){var s=1,o=i.length,a=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(i.length<2||e.length<2)return-1;s=2,o/=2,a/=2,t/=2}function f(p,b){return s===1?p[b]:p.readUInt16BE(b*s)}var l;if(n){var h=-1;for(l=t;lo&&(t=o-a),l=t;l>=0;l--){for(var c=!0,d=0;dn&&(r=n)):r=n;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;os)&&(r=s),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Wt(this,e,t,r);case"utf8":case"utf-8":return Kt(this,e,t,r);case"ascii":return De(this,e,t,r);case"latin1":case"binary":return Xt(this,e,t,r);case"base64":return Zt(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return er(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}};u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function tr(i,e,t){return e===0&&t===i.length?xe(i):xe(i.slice(e,t))}function Le(i,e,t){t=Math.min(i.length,t);for(var r=[],n=e;n239?4:s>223?3:s>191?2:1;if(n+a<=t){var f,l,h,c;switch(a){case 1:s<128&&(o=s);break;case 2:f=i[n+1],(f&192)===128&&(c=(s&31)<<6|f&63,c>127&&(o=c));break;case 3:f=i[n+1],l=i[n+2],(f&192)===128&&(l&192)===128&&(c=(s&15)<<12|(f&63)<<6|l&63,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:f=i[n+1],l=i[n+2],h=i[n+3],(f&192)===128&&(l&192)===128&&(h&192)===128&&(c=(s&15)<<18|(f&63)<<12|(l&63)<<6|h&63,c>65535&&c<1114112&&(o=c))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|o&1023),r.push(o),n+=a}return rr(r)}var be=4096;function rr(i){var e=i.length;if(e<=be)return String.fromCharCode.apply(String,i);for(var t="",r=0;rr)&&(t=r);for(var n="",s=e;sr&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),tt)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUIntLE=function(e,t,r){e=e|0,t=t|0,r||v(e,t,this.length);for(var n=this[e],s=1,o=0;++o0&&(s*=256);)n+=this[e+--t]*s;return n};u.prototype.readUInt8=function(e,t){return t||v(e,1,this.length),this[e]};u.prototype.readUInt16LE=function(e,t){return t||v(e,2,this.length),this[e]|this[e+1]<<8};u.prototype.readUInt16BE=function(e,t){return t||v(e,2,this.length),this[e]<<8|this[e+1]};u.prototype.readUInt32LE=function(e,t){return t||v(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};u.prototype.readUInt32BE=function(e,t){return t||v(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};u.prototype.readIntLE=function(e,t,r){e=e|0,t=t|0,r||v(e,t,this.length);for(var n=this[e],s=1,o=0;++o=s&&(n-=Math.pow(2,8*t)),n};u.prototype.readIntBE=function(e,t,r){e=e|0,t=t|0,r||v(e,t,this.length);for(var n=t,s=1,o=this[e+--n];n>0&&(s*=256);)o+=this[e+--n]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};u.prototype.readInt8=function(e,t){return t||v(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};u.prototype.readInt16LE=function(e,t){t||v(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};u.prototype.readInt16BE=function(e,t){t||v(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};u.prototype.readInt32LE=function(e,t){return t||v(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};u.prototype.readInt32BE=function(e,t){return t||v(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};u.prototype.readFloatLE=function(e,t){return t||v(e,4,this.length),X(this,e,!0,23,4)};u.prototype.readFloatBE=function(e,t){return t||v(e,4,this.length),X(this,e,!1,23,4)};u.prototype.readDoubleLE=function(e,t){return t||v(e,8,this.length),X(this,e,!0,52,8)};u.prototype.readDoubleBE=function(e,t){return t||v(e,8,this.length),X(this,e,!1,52,8)};function A(i,e,t,r,n,s){if(!L(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||ei.length)throw new RangeError("Index out of range")}u.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t=t|0,r=r|0,!n){var s=Math.pow(2,8*r)-1;A(this,e,t,r,s,0)}var o=1,a=0;for(this[t]=e&255;++a=0&&(a*=256);)this[t+o]=e/a&255;return t+r};u.prototype.writeUInt8=function(e,t,r){return e=+e,t=t|0,r||A(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};function Z(i,e,t,r){e<0&&(e=65535+e+1);for(var n=0,s=Math.min(i.length-t,2);n>>(r?n:1-n)*8}u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=t|0,r||A(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Z(this,e,t,!0),t+2};u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=t|0,r||A(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Z(this,e,t,!1),t+2};function ee(i,e,t,r){e<0&&(e=4294967295+e+1);for(var n=0,s=Math.min(i.length-t,4);n>>(r?n:3-n)*8&255}u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=t|0,r||A(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):ee(this,e,t,!0),t+4};u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=t|0,r||A(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):ee(this,e,t,!1),t+4};u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=t|0,!n){var s=Math.pow(2,8*r-1);A(this,e,t,r,s-1,-s)}var o=0,a=1,f=0;for(this[t]=e&255;++o>0)-f&255;return t+r};u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=t|0,!n){var s=Math.pow(2,8*r-1);A(this,e,t,r,s-1,-s)}var o=r-1,a=1,f=0;for(this[t+o]=e&255;--o>=0&&(a*=256);)e<0&&f===0&&this[t+o+1]!==0&&(f=1),this[t+o]=(e/a>>0)-f&255;return t+r};u.prototype.writeInt8=function(e,t,r){return e=+e,t=t|0,r||A(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};u.prototype.writeInt16LE=function(e,t,r){return e=+e,t=t|0,r||A(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Z(this,e,t,!0),t+2};u.prototype.writeInt16BE=function(e,t,r){return e=+e,t=t|0,r||A(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Z(this,e,t,!1),t+2};u.prototype.writeInt32LE=function(e,t,r){return e=+e,t=t|0,r||A(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ee(this,e,t,!0),t+4};u.prototype.writeInt32BE=function(e,t,r){return e=+e,t=t|0,r||A(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):ee(this,e,t,!1),t+4};function ke(i,e,t,r,n,s){if(t+r>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Ue(i,e,t,r,n){return n||ke(i,e,t,4),Se(i,e,t,r,23,4),t+4}u.prototype.writeFloatLE=function(e,t,r){return Ue(this,e,t,!0,r)};u.prototype.writeFloatBE=function(e,t,r){return Ue(this,e,t,!1,r)};function Be(i,e,t,r,n){return n||ke(i,e,t,8),Se(i,e,t,r,52,8),t+8}u.prototype.writeDoubleLE=function(e,t,r){return Be(this,e,t,!0,r)};u.prototype.writeDoubleBE=function(e,t,r){return Be(this,e,t,!1,r)};u.prototype.copy=function(e,t,r,n){if(r||(r=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o>>0,r=r===void 0?this.length:r>>>0,e||(e=0);var o;if(typeof e=="number")for(o=t;o55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===r){(e-=3)>-1&&s.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function hr(i){for(var e=[],t=0;t>8,n=t%256,s.push(n),s.push(r);return s}function Me(i){return jt(ur(i))}function te(i,e,t,r){for(var n=0;n=e.length||n>=i.length);++n)e[n+t]=i[n];return n}function dr(i){return i!==i}function F(i){return i!=null&&(!!i._isBuffer||Pe(i)||_r(i))}function Pe(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function _r(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&Pe(i.slice(0,0))}var m=class i extends Error{constructor(e,t,r,...n){Array.isArray(t)&&(t=t.join(" ").trim()),super(t),Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,i),this.code=e;for(let s of n)for(let o in s){let a=s[o];this[o]=F(a)?a.toString(r.encoding):a==null?a:JSON.parse(JSON.stringify(a))}}},pr=function(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)},je=function(i){let e=[];for(let t=0,r=i.length;t=this.size&&(this.resize(),t>=this.size))throw Error("INVALID_BUFFER_STATE");let r=this.buf;this.buf=u.allocUnsafe(this.size),e.copy(this.buf,0),r.copy(this.buf,e.length),this.length+=e.length}else{let t=this.length++;t===this.size&&this.resize();let r=this.clone();this.buf[0]=e,r.copy(this.buf,1,0,t)}}append(e){let t=this.length++;t===this.size&&this.resize(),this.buf[t]=e}clone(){return u.from(this.buf.slice(0,this.length))}resize(){let e=this.length;this.size=this.size*2;let t=u.allocUnsafe(this.size);this.buf.copy(t,0,0,e),this.buf=t}toString(e){return e?this.buf.slice(0,this.length).toString(e):Uint8Array.prototype.slice.call(this.buf.slice(0,this.length))}toJSON(){return this.toString("utf8")}reset(){this.length=0}},mr=12,gr=13,wr=10,yr=32,Er=9,xr=function(i){return{bomSkipped:!1,bufBytesStart:0,castField:i.cast_function,commenting:!1,error:void 0,enabled:i.from_line===1,escaping:!1,escapeIsQuote:F(i.escape)&&F(i.quote)&&u.compare(i.escape,i.quote)===0,expectedRecordLength:Array.isArray(i.columns)?i.columns.length:void 0,field:new K(20),firstLineToHeaders:i.cast_first_line_to_header,needMoreDataSize:Math.max(i.comment!==null?i.comment.length:0,...i.delimiter.map(e=>e.length),i.quote!==null?i.quote.length:0),previousBuf:void 0,quoting:!1,stop:!1,rawBuffer:new K(100),record:[],recordHasError:!1,record_length:0,recordDelimiterMaxLength:i.record_delimiter.length===0?0:Math.max(...i.record_delimiter.map(e=>e.length)),trimChars:[u.from(" ",i.encoding)[0],u.from(" ",i.encoding)[0]],wasQuoting:!1,wasRowDelimiter:!1,timchars:[u.from(u.from([gr],"utf8").toString(),i.encoding),u.from(u.from([wr],"utf8").toString(),i.encoding),u.from(u.from([mr],"utf8").toString(),i.encoding),u.from(u.from([yr],"utf8").toString(),i.encoding),u.from(u.from([Er],"utf8").toString(),i.encoding)]}},Ir=function(i){return i.replace(/([A-Z])/g,function(e,t){return"_"+t.toLowerCase()})},ve=function(i){let e={};for(let r in i)e[Ir(r)]=i[r];if(e.encoding===void 0||e.encoding===!0)e.encoding="utf8";else if(e.encoding===null||e.encoding===!1)e.encoding=null;else if(typeof e.encoding!="string"&&e.encoding!==null)throw new m("CSV_INVALID_OPTION_ENCODING",["Invalid option encoding:","encoding must be a string or null to return a buffer,",`got ${JSON.stringify(e.encoding)}`],e);if(e.bom===void 0||e.bom===null||e.bom===!1)e.bom=!1;else if(e.bom!==!0)throw new m("CSV_INVALID_OPTION_BOM",["Invalid option bom:","bom must be true,",`got ${JSON.stringify(e.bom)}`],e);if(e.cast_function=null,e.cast===void 0||e.cast===null||e.cast===!1||e.cast==="")e.cast=void 0;else if(typeof e.cast=="function")e.cast_function=e.cast,e.cast=!0;else if(e.cast!==!0)throw new m("CSV_INVALID_OPTION_CAST",["Invalid option cast:","cast must be true or a function,",`got ${JSON.stringify(e.cast)}`],e);if(e.cast_date===void 0||e.cast_date===null||e.cast_date===!1||e.cast_date==="")e.cast_date=!1;else if(e.cast_date===!0)e.cast_date=function(r){let n=Date.parse(r);return isNaN(n)?r:new Date(n)};else if(typeof e.cast_date!="function")throw new m("CSV_INVALID_OPTION_CAST_DATE",["Invalid option cast_date:","cast_date must be true or a function,",`got ${JSON.stringify(e.cast_date)}`],e);if(e.cast_first_line_to_header=null,e.columns===!0)e.cast_first_line_to_header=void 0;else if(typeof e.columns=="function")e.cast_first_line_to_header=e.columns,e.columns=!0;else if(Array.isArray(e.columns))e.columns=je(e.columns);else if(e.columns===void 0||e.columns===null||e.columns===!1)e.columns=!1;else throw new m("CSV_INVALID_OPTION_COLUMNS",["Invalid option columns:","expect an array, a function or true,",`got ${JSON.stringify(e.columns)}`],e);if(e.group_columns_by_name===void 0||e.group_columns_by_name===null||e.group_columns_by_name===!1)e.group_columns_by_name=!1;else{if(e.group_columns_by_name!==!0)throw new m("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","expect an boolean,",`got ${JSON.stringify(e.group_columns_by_name)}`],e);if(e.columns===!1)throw new m("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","the `columns` mode must be activated."],e)}if(e.comment===void 0||e.comment===null||e.comment===!1||e.comment==="")e.comment=null;else if(typeof e.comment=="string"&&(e.comment=u.from(e.comment,e.encoding)),!F(e.comment))throw new m("CSV_INVALID_OPTION_COMMENT",["Invalid option comment:","comment must be a buffer or a string,",`got ${JSON.stringify(e.comment)}`],e);if(e.comment_no_infix===void 0||e.comment_no_infix===null||e.comment_no_infix===!1)e.comment_no_infix=!1;else if(e.comment_no_infix!==!0)throw new m("CSV_INVALID_OPTION_COMMENT",["Invalid option comment_no_infix:","value must be a boolean,",`got ${JSON.stringify(e.comment_no_infix)}`],e);let t=JSON.stringify(e.delimiter);if(Array.isArray(e.delimiter)||(e.delimiter=[e.delimiter]),e.delimiter.length===0)throw new m("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${t}`],e);if(e.delimiter=e.delimiter.map(function(r){if(r==null||r===!1)return u.from(",",e.encoding);if(typeof r=="string"&&(r=u.from(r,e.encoding)),!F(r)||r.length===0)throw new m("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${t}`],e);return r}),e.escape===void 0||e.escape===!0?e.escape=u.from('"',e.encoding):typeof e.escape=="string"?e.escape=u.from(e.escape,e.encoding):(e.escape===null||e.escape===!1)&&(e.escape=null),e.escape!==null&&!F(e.escape))throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(e.escape)}`);if(e.from===void 0||e.from===null)e.from=1;else if(typeof e.from=="string"&&/\d+/.test(e.from)&&(e.from=parseInt(e.from)),Number.isInteger(e.from)){if(e.from<0)throw new Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(i.from)}`)}else throw new Error(`Invalid Option: from must be an integer, got ${JSON.stringify(e.from)}`);if(e.from_line===void 0||e.from_line===null)e.from_line=1;else if(typeof e.from_line=="string"&&/\d+/.test(e.from_line)&&(e.from_line=parseInt(e.from_line)),Number.isInteger(e.from_line)){if(e.from_line<=0)throw new Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(i.from_line)}`)}else throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(i.from_line)}`);if(e.ignore_last_delimiters===void 0||e.ignore_last_delimiters===null)e.ignore_last_delimiters=!1;else if(typeof e.ignore_last_delimiters=="number")e.ignore_last_delimiters=Math.floor(e.ignore_last_delimiters),e.ignore_last_delimiters===0&&(e.ignore_last_delimiters=!1);else if(typeof e.ignore_last_delimiters!="boolean")throw new m("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",["Invalid option `ignore_last_delimiters`:","the value must be a boolean value or an integer,",`got ${JSON.stringify(e.ignore_last_delimiters)}`],e);if(e.ignore_last_delimiters===!0&&e.columns===!1)throw new m("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",["The option `ignore_last_delimiters`","requires the activation of the `columns` option"],e);if(e.info===void 0||e.info===null||e.info===!1)e.info=!1;else if(e.info!==!0)throw new Error(`Invalid Option: info must be true, got ${JSON.stringify(e.info)}`);if(e.max_record_size===void 0||e.max_record_size===null||e.max_record_size===!1)e.max_record_size=0;else if(!(Number.isInteger(e.max_record_size)&&e.max_record_size>=0))if(typeof e.max_record_size=="string"&&/\d+/.test(e.max_record_size))e.max_record_size=parseInt(e.max_record_size);else throw new Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(e.max_record_size)}`);if(e.objname===void 0||e.objname===null||e.objname===!1)e.objname=void 0;else if(F(e.objname)){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty buffer");e.encoding===null||(e.objname=e.objname.toString(e.encoding))}else if(typeof e.objname=="string"){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty string")}else if(typeof e.objname!="number")throw new Error(`Invalid Option: objname must be a string or a buffer, got ${e.objname}`);if(e.objname!==void 0){if(typeof e.objname=="number"){if(e.columns!==!1)throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field")}else if(e.columns===!1)throw Error("Invalid Option: objname field must be combined with columns or be defined as an index")}if(e.on_record===void 0||e.on_record===null)e.on_record=void 0;else if(typeof e.on_record!="function")throw new m("CSV_INVALID_OPTION_ON_RECORD",["Invalid option `on_record`:","expect a function,",`got ${JSON.stringify(e.on_record)}`],e);if(e.on_skip!==void 0&&e.on_skip!==null&&typeof e.on_skip!="function")throw new Error(`Invalid Option: on_skip must be a function, got ${JSON.stringify(e.on_skip)}`);if(e.quote===null||e.quote===!1||e.quote==="")e.quote=null;else if(e.quote===void 0||e.quote===!0?e.quote=u.from('"',e.encoding):typeof e.quote=="string"&&(e.quote=u.from(e.quote,e.encoding)),!F(e.quote))throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(e.quote)}`);if(e.raw===void 0||e.raw===null||e.raw===!1)e.raw=!1;else if(e.raw!==!0)throw new Error(`Invalid Option: raw must be true, got ${JSON.stringify(e.raw)}`);if(e.record_delimiter===void 0)e.record_delimiter=[];else if(typeof e.record_delimiter=="string"||F(e.record_delimiter)){if(e.record_delimiter.length===0)throw new m("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);e.record_delimiter=[e.record_delimiter]}else if(!Array.isArray(e.record_delimiter))throw new m("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);if(e.record_delimiter=e.record_delimiter.map(function(r,n){if(typeof r!="string"&&!F(r))throw new m("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${n},`,`got ${JSON.stringify(r)}`],e);if(r.length===0)throw new m("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${n},`,`got ${JSON.stringify(r)}`],e);return typeof r=="string"&&(r=u.from(r,e.encoding)),r}),typeof e.relax_column_count!="boolean")if(e.relax_column_count===void 0||e.relax_column_count===null)e.relax_column_count=!1;else throw new Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(e.relax_column_count)}`);if(typeof e.relax_column_count_less!="boolean")if(e.relax_column_count_less===void 0||e.relax_column_count_less===null)e.relax_column_count_less=!1;else throw new Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(e.relax_column_count_less)}`);if(typeof e.relax_column_count_more!="boolean")if(e.relax_column_count_more===void 0||e.relax_column_count_more===null)e.relax_column_count_more=!1;else throw new Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(e.relax_column_count_more)}`);if(typeof e.relax_quotes!="boolean")if(e.relax_quotes===void 0||e.relax_quotes===null)e.relax_quotes=!1;else throw new Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(e.relax_quotes)}`);if(typeof e.skip_empty_lines!="boolean")if(e.skip_empty_lines===void 0||e.skip_empty_lines===null)e.skip_empty_lines=!1;else throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(e.skip_empty_lines)}`);if(typeof e.skip_records_with_empty_values!="boolean")if(e.skip_records_with_empty_values===void 0||e.skip_records_with_empty_values===null)e.skip_records_with_empty_values=!1;else throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(e.skip_records_with_empty_values)}`);if(typeof e.skip_records_with_error!="boolean")if(e.skip_records_with_error===void 0||e.skip_records_with_error===null)e.skip_records_with_error=!1;else throw new Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(e.skip_records_with_error)}`);if(e.rtrim===void 0||e.rtrim===null||e.rtrim===!1)e.rtrim=!1;else if(e.rtrim!==!0)throw new Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(e.rtrim)}`);if(e.ltrim===void 0||e.ltrim===null||e.ltrim===!1)e.ltrim=!1;else if(e.ltrim!==!0)throw new Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(e.ltrim)}`);if(e.trim===void 0||e.trim===null||e.trim===!1)e.trim=!1;else if(e.trim!==!0)throw new Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(e.trim)}`);if(e.trim===!0&&i.ltrim!==!1?e.ltrim=!0:e.ltrim!==!0&&(e.ltrim=!1),e.trim===!0&&i.rtrim!==!1?e.rtrim=!0:e.rtrim!==!0&&(e.rtrim=!1),e.to===void 0||e.to===null)e.to=-1;else if(typeof e.to=="string"&&/\d+/.test(e.to)&&(e.to=parseInt(e.to)),Number.isInteger(e.to)){if(e.to<=0)throw new Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(i.to)}`)}else throw new Error(`Invalid Option: to must be an integer, got ${JSON.stringify(i.to)}`);if(e.to_line===void 0||e.to_line===null)e.to_line=-1;else if(typeof e.to_line=="string"&&/\d+/.test(e.to_line)&&(e.to_line=parseInt(e.to_line)),Number.isInteger(e.to_line)){if(e.to_line<=0)throw new Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(i.to_line)}`)}else throw new Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(i.to_line)}`);return e},Oe=function(i){return i.every(e=>e==null||e.toString&&e.toString().trim()==="")},br=13,vr=10,$={utf8:u.from([239,187,191]),utf16le:u.from([255,254])},Or=function(i={}){let e={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0},t=ve(i);return{info:e,original_options:i,options:t,state:xr(t),__needMoreData:function(r,n,s){if(s)return!1;let{encoding:o,escape:a,quote:f}=this.options,{quoting:l,needMoreDataSize:h,recordDelimiterMaxLength:c}=this.state,d=n-r-1,p=Math.max(h,c===0?u.from(`\r `,o).length:c,l?(a===null?0:a.length)+f.length:0,l?f.length+c:0);return dE){this.state.stop=!0,o();return}this.state.quoting===!1&&ie.length===0&&this.__autoDiscoverRecordDelimiter(w,_)&&(ie=this.options.record_delimiter);let x=w[_];if(p===!0&&At.append(x),(x===br||x===vr)&&this.state.wasRowDelimiter===!1&&(this.state.wasRowDelimiter=!0),this.state.escaping===!0)this.state.escaping=!1;else{if(S!==null&&this.state.quoting===!0&&this.__isEscape(w,_,x)&&_+S.length$[P].equals(this.state.field.toString())?P:!1).filter(Boolean)[0],k=this.__error(new m("INVALID_OPENING_QUOTE",["Invalid Opening Quote:",`a quote is found on field ${JSON.stringify(O.column)} at line ${O.lines}, value is ${JSON.stringify(this.state.field.toString(l))}`,M?`(${M} bom)`:void 0],this.options,O,{field:this.state.field}));if(k!==void 0)return k}}else{this.state.quoting=!0,_+=C.length-1;continue}if(this.state.quoting===!1){let O=this.__isRecordDelimiter(x,w,_);if(O!==0){if(this.state.commenting&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0)this.info.comment_lines++;else{if(this.state.enabled===!1&&this.info.lines+(this.state.wasRowDelimiter===!0?1:0)>=h){this.state.enabled=!0,this.__resetField(),this.__resetRecord(),_+=O-1;continue}if(T===!0&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++,_+=O-1;continue}this.info.bytes=this.state.bufBytesStart+_;let P=this.__onField();if(P!==void 0)return P;this.info.bytes=this.state.bufBytesStart+_+O;let G=this.__onRecord(s);if(G!==void 0)return G;if(N!==-1&&this.info.records>=N){this.state.stop=!0,o();return}}this.state.commenting=!1,_+=O-1;continue}if(this.state.commenting)continue;if(g!==null&&(f===!1||this.state.record.length===0&&this.state.field.length===0)&&this.__compareBytes(g,w,_,x)!==0){this.state.commenting=!0;continue}let M=this.__isDelimiter(w,_,x);if(M!==0){this.info.bytes=this.state.bufBytesStart+_;let k=this.__onField();if(k!==void 0)return k;_+=M-1;continue}}}if(this.state.commenting===!1&&d!==0&&this.state.record_length+this.state.field.length>d)return this.__error(new m("CSV_MAX_RECORD_SIZE",["Max Record Size:","record exceed the maximum number of tolerated bytes",`of ${d}`,`at line ${this.info.lines}`],this.options,this.__infoField()));let B=c===!1||this.state.quoting===!0||this.state.field.length!==0||!this.__isCharTrimable(w,_),Ft=y===!1||this.state.wasQuoting===!1;if(B===!0&&Ft===!0)this.state.field.append(x);else{if(y===!0&&!this.__isCharTrimable(w,_))return this.__error(new m("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",["Invalid Closing Quote:","found non trimable byte after quote",`at line ${this.info.lines}`],this.options,this.__infoField()));B===!1&&(_+=this.__isCharTrimable(w,_)-1);continue}}if(n===!0)if(this.state.quoting===!0){let x=this.__error(new m("CSV_QUOTE_NOT_CLOSED",["Quote Not Closed:",`the parsing is finished with an opening quote at line ${this.info.lines}`],this.options,this.__infoField()));if(x!==void 0)return x}else if(this.state.wasQuoting===!0||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+_;let x=this.__onField();if(x!==void 0)return x;let B=this.__onRecord(s);if(B!==void 0)return B}else this.state.wasRowDelimiter===!0?this.info.empty_lines++:this.state.commenting===!0&&this.info.comment_lines++;else this.state.bufBytesStart+=_,this.state.previousBuf=w.slice(_);this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1)},__onRecord:function(r){let{columns:n,group_columns_by_name:s,encoding:o,info:a,from:f,relax_column_count:l,relax_column_count_less:h,relax_column_count_more:c,raw:d,skip_records_with_empty_values:p}=this.options,{enabled:b,record:y}=this.state;if(b===!1)return this.__resetRecord();let T=y.length;if(n===!0){if(p===!0&&Oe(y)){this.__resetRecord();return}return this.__firstLineToColumns(y)}if(n===!1&&this.info.records===0&&(this.state.expectedRecordLength=T),T!==this.state.expectedRecordLength){let N=n===!1?new m("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${T} on line ${this.info.lines}`],this.options,this.__infoField(),{record:y}):new m("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${n.length},`,`got ${T} on line ${this.info.lines}`],this.options,this.__infoField(),{record:y});if(l===!0||h===!0&&Tthis.state.expectedRecordLength)this.info.invalid_field_length++,this.state.error=N;else{let E=this.__error(N);if(E)return E}}if(p===!0&&Oe(y)){this.__resetRecord();return}if(this.state.recordHasError===!0){this.__resetRecord(),this.state.recordHasError=!1;return}if(this.info.records++,f===1||this.info.records>=f){let{objname:N}=this.options;if(n!==!1){let E={};for(let g=0,S=y.length;g{let{timchars:f}=this.state;e:for(let l=0;l=0},__compareBytes:function(r,n,s,o){if(r[0]!==o)return 0;let a=r.length;for(let f=1;fthis.state.record.length?r[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}}}},fe=function(i,e={}){typeof i=="string"&&(i=u.from(i));let t=e&&e.objname?{}:[],r=Or(e),n=f=>{r.options.objname===void 0?t.push(f):t[f[0]]=f[1]},s=()=>{},o=r.parse(i,!1,n,s);if(o!==void 0)throw o;let a=r.parse(void 0,!0,n,s);if(a!==void 0)throw a;return t};var J=Bt(Ot(),1),Nt;(l=>{function i(){}l.start_ROOC=i;let e={cast:!0,skip_empty_lines:!0,trim:!0};function t(h,c=",",d){return fe(h,{...e,delimiter:c,...d})}l.parseCsvTable=t;function r(h,c=",",d){return fe(h,{...e,delimiter:c,columns:!0,...d})}l.parseCsvObject=r;function n(h){let c=new J.Graph;return h.vertices.forEach(d=>{c.setNode(d.name,d),Object.entries(d.edges).forEach(([p,b])=>{c.setEdge(b.from,b.to,{label:p,weight:b.weight})})}),c}l.fromSerializedGraph=n;function s(h){return{vertices:h.nodes().map(d=>{let p=h.nodeEdges(d).reduce((b,y)=>{let T=h.edge(y);return b[y.name]={from:y.v,to:y.w,weight:T.weight},b},{});return{name:d,edges:p}})}}l.toSerializedGraph=s,l.RoocGraph=J.Graph,l.GraphAlgorithms=J.alg;function f(){}l.end_ROOC=f})(Nt||={});return Mt(ii);})();