mirror of
https://github.com/kristoferssolo/solorice.git
synced 2025-10-21 20:10:34 +00:00
1 line
112 KiB
JavaScript
1 line
112 KiB
JavaScript
(()=>{var __webpack_modules__={1924:(e,t,r)=>{"use strict";var n=r(210),i=r(5559),o=i(n("String.prototype.indexOf"));e.exports=function(e,t){var r=n(e,!!t);return"function"==typeof r&&o(e,".prototype.")>-1?i(r):r}},5559:(e,t,r)=>{"use strict";var n=r(8612),i=r(210),o=i("%Function.prototype.apply%"),s=i("%Function.prototype.call%"),a=i("%Reflect.apply%",!0)||n.call(s,o),l=i("%Object.getOwnPropertyDescriptor%",!0),u=i("%Object.defineProperty%",!0),c=i("%Math.max%");if(u)try{u({},"a",{value:1})}catch(e){u=null}e.exports=function(e){var t=a(n,s,arguments);if(l&&u){var r=l(t,"length");r.configurable&&u(t,"length",{value:1+c(0,e.length-(arguments.length-1))})}return t};var _=function(){return a(n,o,arguments)};u?u(e.exports,"apply",{value:_}):e.exports.apply=_},9804:e=>{var t=Object.prototype.hasOwnProperty,r=Object.prototype.toString;e.exports=function(e,n,i){if("[object Function]"!==r.call(n))throw new TypeError("iterator must be a function");var o=e.length;if(o===+o)for(var s=0;s<o;s++)n.call(i,e[s],s,e);else for(var a in e)t.call(e,a)&&n.call(i,e[a],a,e)}},7648:e=>{"use strict";var t="Function.prototype.bind called on incompatible ",r=Array.prototype.slice,n=Object.prototype.toString,i="[object Function]";e.exports=function(e){var o=this;if("function"!=typeof o||n.call(o)!==i)throw new TypeError(t+o);for(var s,a=r.call(arguments,1),l=function(){if(this instanceof s){var t=o.apply(this,a.concat(r.call(arguments)));return Object(t)===t?t:this}return o.apply(e,a.concat(r.call(arguments)))},u=Math.max(0,o.length-a.length),c=[],_=0;_<u;_++)c.push("$"+_);if(s=Function("binder","return function ("+c.join(",")+"){ return binder.apply(this,arguments); }")(l),o.prototype){var p=function(){};p.prototype=o.prototype,s.prototype=new p,p.prototype=null}return s}},8612:(e,t,r)=>{"use strict";var n=r(7648);e.exports=Function.prototype.bind||n},210:(e,t,r)=>{"use strict";var n,i=SyntaxError,o=Function,s=TypeError,a=function(e){try{return o('"use strict"; return ('+e+").constructor;")()}catch(e){}},l=Object.getOwnPropertyDescriptor;if(l)try{l({},"")}catch(e){l=null}var u=function(){throw new s},c=l?function(){try{return u}catch(e){try{return l(arguments,"callee").get}catch(e){return u}}}():u,_=r(1405)(),p=Object.getPrototypeOf||function(e){return e.__proto__},f={},h="undefined"==typeof Uint8Array?n:p(Uint8Array),d={"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":_?p([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":f,"%AsyncGenerator%":f,"%AsyncGeneratorFunction%":f,"%AsyncIteratorPrototype%":f,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":o,"%GeneratorFunction%":f,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":_?p(p([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&_?p((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&_?p((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":_?p(""[Symbol.iterator]()):n,"%Symbol%":_?Symbol:n,"%SyntaxError%":i,"%ThrowTypeError%":c,"%TypedArray%":h,"%TypeError%":s,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet},g=function e(t){var r;if("%AsyncFunction%"===t)r=a("async function () {}");else if("%GeneratorFunction%"===t)r=a("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=a("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&(r=p(i.prototype))}return d[t]=r,r},y={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},m=r(8612),b=r(7642),w=m.call(Function.call,Array.prototype.concat),x=m.call(Function.apply,Array.prototype.splice),v=m.call(Function.call,String.prototype.replace),E=m.call(Function.call,String.prototype.slice),O=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,S=/\\(\\)?/g,R=function(e){var t=E(e,0,1),r=E(e,-1);if("%"===t&&"%"!==r)throw new i("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new i("invalid intrinsic syntax, expected opening `%`");var n=[];return v(e,O,(function(e,t,r,i){n[n.length]=r?v(i,S,"$1"):t||e})),n},A=function(e,t){var r,n=e;if(b(y,n)&&(n="%"+(r=y[n])[0]+"%"),b(d,n)){var o=d[n];if(o===f&&(o=g(n)),void 0===o&&!t)throw new s("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:o}}throw new i("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new s("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new s('"allowMissing" argument must be a boolean');var r=R(e),n=r.length>0?r[0]:"",o=A("%"+n+"%",t),a=o.name,u=o.value,c=!1,_=o.alias;_&&(n=_[0],x(r,w([0,1],_)));for(var p=1,f=!0;p<r.length;p+=1){var h=r[p],g=E(h,0,1),y=E(h,-1);if(('"'===g||"'"===g||"`"===g||'"'===y||"'"===y||"`"===y)&&g!==y)throw new i("property names with quotes must have matching quotes");if("constructor"!==h&&f||(c=!0),b(d,a="%"+(n+="."+h)+"%"))u=d[a];else if(null!=u){if(!(h in u)){if(!t)throw new s("base intrinsic for "+e+" exists, but the property is not available.");return}if(l&&p+1>=r.length){var m=l(u,h);u=(f=!!m)&&"get"in m&&!("originalValue"in m.get)?m.get:u[h]}else f=b(u,h),u=u[h];f&&!c&&(d[a]=u)}}return u}},1405:(e,t,r)=>{"use strict";var n="undefined"!=typeof Symbol&&Symbol,i=r(5419);e.exports=function(){return"function"==typeof n&&"function"==typeof Symbol&&"symbol"==typeof n("foo")&&"symbol"==typeof Symbol("bar")&&i()}},5419:e=>{"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},6410:(e,t,r)=>{"use strict";var n=r(5419);e.exports=function(){return n()&&!!Symbol.toStringTag}},7642:(e,t,r)=>{"use strict";var n=r(8612);e.exports=n.call(Function.call,Object.prototype.hasOwnProperty)},5717:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},2584:(e,t,r)=>{"use strict";var n=r(6410)(),i=r(1924)("Object.prototype.toString"),o=function(e){return!(n&&e&&"object"==typeof e&&Symbol.toStringTag in e)&&"[object Arguments]"===i(e)},s=function(e){return!!o(e)||null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Array]"!==i(e)&&"[object Function]"===i(e.callee)},a=function(){return o(arguments)}();o.isLegacyArguments=s,e.exports=a?o:s},8662:(e,t,r)=>{"use strict";var n,i=Object.prototype.toString,o=Function.prototype.toString,s=/^\s*(?:function)?\*/,a=r(6410)(),l=Object.getPrototypeOf;e.exports=function(e){if("function"!=typeof e)return!1;if(s.test(o.call(e)))return!0;if(!a)return"[object GeneratorFunction]"===i.call(e);if(!l)return!1;if(void 0===n){var t=function(){if(!a)return!1;try{return Function("return function*() {}")()}catch(e){}}();n=!!t&&l(t)}return l(e)===n}},5692:(e,t,r)=>{"use strict";var n=r(9804),i=r(3083),o=r(1924),s=o("Object.prototype.toString"),a=r(6410)(),l="undefined"==typeof globalThis?r.g:globalThis,u=i(),c=o("Array.prototype.indexOf",!0)||function(e,t){for(var r=0;r<e.length;r+=1)if(e[r]===t)return r;return-1},_=o("String.prototype.slice"),p={},f=r(882),h=Object.getPrototypeOf;a&&f&&h&&n(u,(function(e){var t=new l[e];if(Symbol.toStringTag in t){var r=h(t),n=f(r,Symbol.toStringTag);if(!n){var i=h(r);n=f(i,Symbol.toStringTag)}p[e]=n.get}})),e.exports=function(e){if(!e||"object"!=typeof e)return!1;if(!a||!(Symbol.toStringTag in e)){var t=_(s(e),8,-1);return c(u,t)>-1}return!!f&&function(e){var t=!1;return n(p,(function(r,n){if(!t)try{t=r.call(e)===n}catch(e){}})),t}(e)}},4155:e=>{var t,r,n=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var a,l=[],u=!1,c=-1;function _(){u&&a&&(u=!1,a.length?l=a.concat(l):c=-1,l.length&&p())}function p(){if(!u){var e=s(_);u=!0;for(var t=l.length;t;){for(a=l,l=[];++c<t;)a&&a[c].run();c=-1,t=l.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function h(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new f(e,t)),1!==l.length||u||s(p)},f.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=h,n.addListener=h,n.once=h,n.off=h,n.removeListener=h,n.removeAllListeners=h,n.emit=h,n.prependListener=h,n.prependOnceListener=h,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},384:e=>{e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},5955:(e,t,r)=>{"use strict";var n=r(2584),i=r(8662),o=r(6430),s=r(5692);function a(e){return e.call.bind(e)}var l="undefined"!=typeof BigInt,u="undefined"!=typeof Symbol,c=a(Object.prototype.toString),_=a(Number.prototype.valueOf),p=a(String.prototype.valueOf),f=a(Boolean.prototype.valueOf);if(l)var h=a(BigInt.prototype.valueOf);if(u)var d=a(Symbol.prototype.valueOf);function g(e,t){if("object"!=typeof e)return!1;try{return t(e),!0}catch(e){return!1}}function y(e){return"[object Map]"===c(e)}function m(e){return"[object Set]"===c(e)}function b(e){return"[object WeakMap]"===c(e)}function w(e){return"[object WeakSet]"===c(e)}function x(e){return"[object ArrayBuffer]"===c(e)}function v(e){return"undefined"!=typeof ArrayBuffer&&(x.working?x(e):e instanceof ArrayBuffer)}function E(e){return"[object DataView]"===c(e)}function O(e){return"undefined"!=typeof DataView&&(E.working?E(e):e instanceof DataView)}t.isArgumentsObject=n,t.isGeneratorFunction=i,t.isTypedArray=s,t.isPromise=function(e){return"undefined"!=typeof Promise&&e instanceof Promise||null!==e&&"object"==typeof e&&"function"==typeof e.then&&"function"==typeof e.catch},t.isArrayBufferView=function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):s(e)||O(e)},t.isUint8Array=function(e){return"Uint8Array"===o(e)},t.isUint8ClampedArray=function(e){return"Uint8ClampedArray"===o(e)},t.isUint16Array=function(e){return"Uint16Array"===o(e)},t.isUint32Array=function(e){return"Uint32Array"===o(e)},t.isInt8Array=function(e){return"Int8Array"===o(e)},t.isInt16Array=function(e){return"Int16Array"===o(e)},t.isInt32Array=function(e){return"Int32Array"===o(e)},t.isFloat32Array=function(e){return"Float32Array"===o(e)},t.isFloat64Array=function(e){return"Float64Array"===o(e)},t.isBigInt64Array=function(e){return"BigInt64Array"===o(e)},t.isBigUint64Array=function(e){return"BigUint64Array"===o(e)},y.working="undefined"!=typeof Map&&y(new Map),t.isMap=function(e){return"undefined"!=typeof Map&&(y.working?y(e):e instanceof Map)},m.working="undefined"!=typeof Set&&m(new Set),t.isSet=function(e){return"undefined"!=typeof Set&&(m.working?m(e):e instanceof Set)},b.working="undefined"!=typeof WeakMap&&b(new WeakMap),t.isWeakMap=function(e){return"undefined"!=typeof WeakMap&&(b.working?b(e):e instanceof WeakMap)},w.working="undefined"!=typeof WeakSet&&w(new WeakSet),t.isWeakSet=function(e){return w(e)},x.working="undefined"!=typeof ArrayBuffer&&x(new ArrayBuffer),t.isArrayBuffer=v,E.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&E(new DataView(new ArrayBuffer(1),0,1)),t.isDataView=O;var S="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function R(e){return"[object SharedArrayBuffer]"===c(e)}function A(e){return void 0!==S&&(void 0===R.working&&(R.working=R(new S)),R.working?R(e):e instanceof S)}function q(e){return g(e,_)}function P(e){return g(e,p)}function j(e){return g(e,f)}function T(e){return l&&g(e,h)}function k(e){return u&&g(e,d)}t.isSharedArrayBuffer=A,t.isAsyncFunction=function(e){return"[object AsyncFunction]"===c(e)},t.isMapIterator=function(e){return"[object Map Iterator]"===c(e)},t.isSetIterator=function(e){return"[object Set Iterator]"===c(e)},t.isGeneratorObject=function(e){return"[object Generator]"===c(e)},t.isWebAssemblyCompiledModule=function(e){return"[object WebAssembly.Module]"===c(e)},t.isNumberObject=q,t.isStringObject=P,t.isBooleanObject=j,t.isBigIntObject=T,t.isSymbolObject=k,t.isBoxedPrimitive=function(e){return q(e)||P(e)||j(e)||T(e)||k(e)},t.isAnyArrayBuffer=function(e){return"undefined"!=typeof Uint8Array&&(v(e)||A(e))},["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(e){Object.defineProperty(t,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})}))},9539:(e,t,r)=>{var n=r(4155),i=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++)r[t[n]]=Object.getOwnPropertyDescriptor(e,t[n]);return r},o=/%[sdj%]/g;t.format=function(e){if(!b(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(u(arguments[r]));return t.join(" ")}r=1;for(var n=arguments,i=n.length,s=String(e).replace(o,(function(e){if("%%"===e)return"%";if(r>=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),a=n[r];r<i;a=n[++r])y(a)||!v(a)?s+=" "+a:s+=" "+u(a);return s},t.deprecate=function(e,r){if(void 0!==n&&!0===n.noDeprecation)return e;if(void 0===n)return function(){return t.deprecate(e,r).apply(this,arguments)};var i=!1;return function(){if(!i){if(n.throwDeprecation)throw new Error(r);n.traceDeprecation?console.trace(r):console.error(r),i=!0}return e.apply(this,arguments)}};var s={},a=/^$/;if(n.env.NODE_DEBUG){var l=n.env.NODE_DEBUG;l=l.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),a=new RegExp("^"+l+"$","i")}function u(e,r){var n={seen:[],stylize:_};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(r)?n.showHidden=r:r&&t._extend(n,r),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),p(n,e,n.depth)}function c(e,t){var r=u.styles[t];return r?"["+u.colors[r][0]+"m"+e+"["+u.colors[r][1]+"m":e}function _(e,t){return e}function p(e,r,n){if(e.customInspect&&r&&S(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return b(i)||(i=p(e,i,n)),i}var o=function(e,t){if(w(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return m(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):y(t)?e.stylize("null","null"):void 0}(e,r);if(o)return o;var s=Object.keys(r),a=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(r)),O(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(r);if(0===s.length){if(S(r)){var l=r.name?": "+r.name:"";return e.stylize("[Function"+l+"]","special")}if(x(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(E(r))return e.stylize(Date.prototype.toString.call(r),"date");if(O(r))return f(r)}var u,c="",_=!1,v=["{","}"];return d(r)&&(_=!0,v=["[","]"]),S(r)&&(c=" [Function"+(r.name?": "+r.name:"")+"]"),x(r)&&(c=" "+RegExp.prototype.toString.call(r)),E(r)&&(c=" "+Date.prototype.toUTCString.call(r)),O(r)&&(c=" "+f(r)),0!==s.length||_&&0!=r.length?n<0?x(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),u=_?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s<a;++s)j(t,String(s))?o.push(h(e,t,r,n,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(h(e,t,r,n,i,!0))})),o}(e,r,n,a,s):s.map((function(t){return h(e,r,n,a,t,_)})),e.seen.pop(),function(e,t,r){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}(u,c,v)):v[0]+c+v[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,r,n,i,o){var s,a,l;if((l=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(a=e.stylize("[Setter]","special")),j(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(l.value)<0?(a=y(r)?p(e,l.value,null):p(e,l.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function y(e){return null===e}function m(e){return"number"==typeof e}function b(e){return"string"==typeof e}function w(e){return void 0===e}function x(e){return v(e)&&"[object RegExp]"===R(e)}function v(e){return"object"==typeof e&&null!==e}function E(e){return v(e)&&"[object Date]"===R(e)}function O(e){return v(e)&&("[object Error]"===R(e)||e instanceof Error)}function S(e){return"function"==typeof e}function R(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(e=e.toUpperCase(),!s[e])if(a.test(e)){var r=n.pid;s[e]=function(){var n=t.format.apply(t,arguments);console.error("%s %d: %s",e,r,n)}}else s[e]=function(){};return s[e]},t.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.types=r(5955),t.isArray=d,t.isBoolean=g,t.isNull=y,t.isNullOrUndefined=function(e){return null==e},t.isNumber=m,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=w,t.isRegExp=x,t.types.isRegExp=x,t.isObject=v,t.isDate=E,t.types.isDate=E,t.isError=O,t.types.isNativeError=O,t.isFunction=S,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(384);var q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date,t=[A(e.getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":");return[e.getDate(),q[e.getMonth()],t].join(" ")}function j(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",P(),t.format.apply(t,arguments))},t.inherits=r(5717),t._extend=function(e,t){if(!t||!v(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};var T="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function k(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(T&&e[T]){var t;if("function"!=typeof(t=e[T]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,T,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise((function(e,n){t=e,r=n})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(e,n){e?r(e):t(n)}));try{e.apply(this,i)}catch(e){r(e)}return n}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),T&&Object.defineProperty(t,T,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,i(e))},t.promisify.custom=T,t.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function t(){for(var t=[],r=0;r<arguments.length;r++)t.push(arguments[r]);var i=t.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return i.apply(o,arguments)};e.apply(this,t).then((function(e){n.nextTick(s.bind(null,null,e))}),(function(e){n.nextTick(k.bind(null,e,s))}))}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,i(e)),t}},6430:(e,t,r)=>{"use strict";var n=r(9804),i=r(3083),o=r(1924),s=o("Object.prototype.toString"),a=r(6410)(),l="undefined"==typeof globalThis?r.g:globalThis,u=i(),c=o("String.prototype.slice"),_={},p=r(882),f=Object.getPrototypeOf;a&&p&&f&&n(u,(function(e){if("function"==typeof l[e]){var t=new l[e];if(Symbol.toStringTag in t){var r=f(t),n=p(r,Symbol.toStringTag);if(!n){var i=f(r);n=p(i,Symbol.toStringTag)}_[e]=n.get}}}));var h=r(5692);e.exports=function(e){return!!h(e)&&(a&&Symbol.toStringTag in e?function(e){var t=!1;return n(_,(function(r,n){if(!t)try{var i=r.call(e);i===n&&(t=i)}catch(e){}})),t}(e):c(s(e),8,-1))}},45:(e,t,r)=>{var n=r(4155);const i=r(4949),o=r(5174),s=r(7857),a=r(6987),l=r(371),u=r(8594),c=/^([0-9]+)(\.[0-9]+)?$/;class _ extends Error{}function p(e,t,r){if(e.length>r[0]&&(r[0]=e.length),-1==r[1])return;let n=c.exec(e);if(null===n)return void(!t&&e.length&&(r[1]=-1,r[2]=-1));let i=n[1].length;r[1]=Math.max(r[1],i);let o=void 0===n[2]?0:n[2].length;r[2]=Math.max(r[2],o)}function f(e,t,r,n){if(e=e.trim(),-1==r[1]){let t=Math.max(r[0]-e.length,0);return n?e:e+" ".repeat(t+1)}if(t&&null===c.exec(e)){let t=Math.max(r[0]-e.length,0);return n?e:e+" ".repeat(t+1)}let i=e.indexOf("."),o=-1==i?e.length:i,s=-1==i?0:e.length-i,a=Math.max(r[1]-o,0),l=Math.max(r[2]-s),u=n?"":" ".repeat(l+1);return" ".repeat(a)+e+u}function h(e){return"rbql_table_name:"+e}function d(e,t,r){var n,a="~"===(n=r).charAt(0)?s.join(i.homedir(),n.slice(1)):n;if(o.existsSync(a))return a;if(t&&!s.isAbsolute(a)&&(a=s.join(t,a),o.existsSync(a)))return a;let l=e?e.get(h(r)):null;return l&&o.existsSync(l)?l:null}function g(e,t){const r=e.lineCount;for(let n=0;n<r;++n){const r=e.lineAt(n).text;if(!t||!r.startsWith(t))return r}return null}class y extends Error{}class m extends a.RBQLInputIterator{constructor(e,t,r,n=!1,i=null,o="input",s="a"){super(),this.document=e,this.delim=t,this.policy=r,this.has_header=n,this.comment_prefix=i,this.table_name=o,this.variable_prefix=s,this.NR=0,this.NL=0,this.fields_info=new Object,this.first_defective_line=null,this.first_record=this.get_first_record()}stop(){}get_first_record(){let e=g(this.document,this.comment_prefix);return u.smart_split(e,this.delim,this.policy,!1)[0]}async get_variables_map(e){let t=new Object;a.parse_basic_variables(e,this.variable_prefix,t),a.parse_array_variables(e,this.variable_prefix,t);let r=g(this.document,this.comment_prefix),n=u.smart_split(r,this.delim,this.policy,!1)[0];return this.has_header&&(a.parse_attribute_variables(e,this.variable_prefix,n,"CSV header line",t),a.parse_dictionary_variables(e,this.variable_prefix,n,t)),t}async get_header(){return this.has_header?this.first_record:null}get_line_rfc(){let e=[];const t=this.document.lineCount;for(;this.NL<t;){let r=this.document.lineAt(this.NL).text;if(this.NL+=1,this.NL==t&&0==r.length)return null;let n=u.accumulate_rfc_line_into_record(e,r,this.comment_prefix);if(null!==n)return n}return null}get_line_simple(){const e=this.document.lineCount;for(;this.NL<e;){let t=this.document.lineAt(this.NL).text;if(this.NL+=1,this.NL==e&&0==t.length)return null;if(null===this.comment_prefix||!t.startsWith(this.comment_prefix))return t}return null}do_get_record(){let e="quoted_rfc"==this.policy?this.get_line_rfc():this.get_line_simple();if(null===e)return null;let[t,r]=u.smart_split(e,this.delim,this.policy,!1);if(r&&null===this.first_defective_line&&(this.first_defective_line=this.NL,"quoted_rfc"==this.policy))throw new y(`Inconsistent double quote escaping in ${this.table_name} table at record ${this.NR}, line ${this.NL}`);let n=t.length;return this.fields_info.hasOwnProperty(n)||(this.fields_info[n]=this.NR),t}async get_record(){return 0==this.NR&&this.has_header&&this.do_get_record(),this.NR+=1,this.do_get_record()}get_warnings(){let e=[];return null!==this.first_defective_line&&e.push(`Inconsistent double quote escaping in ${this.table_name} table. E.g. at line ${this.first_defective_line}`),Object.keys(this.fields_info).length>1&&e.push(function(e,t){let r=Object.keys(t),n=[];for(let e=0;e<r.length;e++){let i=r[e],o=t[i];n.push([o,i])}n.sort((function(e,t){return e[0]-t[0]})),function(e,t=null){if(!e)throw t||(t="Assertion error"),new _(t)}(n.length>1);let[i,o]=n[0],[s,a]=n[1],l=`Number of fields in "${e}" table is not consistent: `;return l+=`e.g. record ${i} -> ${o} fields, record ${s} -> ${a} fields`,l}(this.table_name,this.fields_info)),e}}class b extends a.RBQLOutputWriter{constructor(e,t){if(super(),this.delim=e,this.policy=t,this.header_len=null,this.null_in_output=!1,this.delim_in_simple_output=!1,this.output_lines=[],"simple"==t)this.polymorphic_join=this.simple_join;else if("quoted"==t)this.polymorphic_join=this.quoted_join;else if("quoted_rfc"==t)this.polymorphic_join=this.quoted_join_rfc;else if("monocolumn"==t)this.polymorphic_join=this.mono_join;else{if("whitespace"!=t)throw new y("Unknown output csv policy");this.polymorphic_join=this.simple_join}}set_header(e){null!==e&&(this.header_len=e.length,this.write(e))}quoted_join(e){let t=this.delim;return e.map((function(e){return u.quote_field(String(e),t)})).join(this.delim)}quoted_join_rfc(e){let t=this.delim;return e.map((function(e){return u.rfc_quote_field(String(e),t)})).join(this.delim)}mono_join(e){if(e.length>1)throw new y('Unable to use "Monocolumn" output format: some records have more than one field');return e[0]}simple_join(e){var t=e.join(this.delim);return-1!=e.join("").indexOf(this.delim)&&(this.delim_in_simple_output=!0),t}normalize_fields(e){for(var t=0;t<e.length;t++)null==e[t]?(this.null_in_output=!0,e[t]=""):Array.isArray(e[t])&&(this.normalize_fields(e[t]),e[t]=e[t].join(this.sub_array_delim))}write(e){if(null!==this.header_len&&e.length!=this.header_len)throw new y(`Inconsistent number of columns in output header and the current record: ${this.header_len} != ${e.length}`);return this.normalize_fields(e),this.output_lines.push(this.polymorphic_join(e)),!0}async finish(){}get_warnings(){let e=[];return this.null_in_output&&e.push("null values in output were replaced by empty strings"),this.delim_in_simple_output&&e.push("Some output fields contain separator"),e}}class w{constructor(){}get_iterator_by_table_id(e){throw new y("JOIN queries are currently not supported in vscode.dev web version.")}get_warnings(){return[]}}class x extends a.RBQLTableRegistry{constructor(e,t,r,n,i,o=!1,s=null,a=null){super(),this.vscode_global_state=e,this.input_file_dir=t,this.delim=r,this.policy=n,this.encoding=i,this.has_header=o,this.comment_prefix=s,this.stream=null,this.record_iterator=null,this.options=a,this.bulk_input_path=null,this.table_path=null}get_iterator_by_table_id(e){if(this.table_path=d(this.vscode_global_state,this.input_file_dir,e),null===this.table_path)throw new y(`Unable to find join table "${e}"`);return this.options&&this.options.bulk_read?this.bulk_input_path=this.table_path:this.stream=o.createReadStream(this.table_path),this.record_iterator=new l.CSVRecordIterator(this.stream,this.bulk_input_path,this.encoding,this.delim,this.policy,this.has_header,this.comment_prefix,e,"b"),this.record_iterator}get_warnings(e){this.record_iterator&&this.has_header&&e.push(`The first record in JOIN file ${s.basename(this.table_path)} was also treated as header (and skipped)`)}}e.exports.make_table_name_key=h,e.exports.find_table_path=d,e.exports.read_header=async function(e,t){"latin-1"==t&&(t="binary");let n=r(8391).createInterface({input:o.createReadStream(e,{encoding:t})}),i=!1,s=null,a=null,l=new Promise((function(e,t){s=e,a=t}));return n.on("line",(e=>{i||(i=!0,n.close(),s(e))})),n.on("error",(e=>{a(e)})),l},e.exports.rbql_query_web=async function(e,t,r,n,i,o,s,l,u=null){let c=new w,_=new m(t,r,n,l,u),p=new b(i,o);return await a.query(e,_,p,s,c,""),p.output_lines},e.exports.rbql_query_node=async function(e,t,r,u,c,_,p,f,h,d,g=!1,m=null,b="",w=null){let v=null,E=null;w&&w.bulk_read&&r?E=r:v=null===r?n.stdin:o.createReadStream(r);let[O,S]=null===_?[n.stdout,!1]:[o.createWriteStream(_),!0];if('"'==u&&"quoted"==c)throw new y('Double quote delimiter is incompatible with "quoted" policy');if("latin-1"==h&&(h="binary"),!l.is_ascii(t)&&"binary"==h)throw new y("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");if(!(l.is_ascii(u)&&l.is_ascii(p)||"binary"!=h))throw new y("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");let R=s.join(i.homedir(),".rbql_init_source.js");""==b&&o.existsSync(R)&&(b=l.read_user_init_code(R));let A=r?s.dirname(r):null,q=new x(e,A,u,c,h,g,m,w),P=new l.CSVRecordIterator(v,E,h,u,c,g,m),j=new l.CSVWriter(O,S,h,p,f);await a.query(t,P,j,d,q,b),q.get_warnings(d)},e.exports.get_header_line=g,e.exports.populate_optimistic_rfc_csv_record_map=function(e,t,r,n=null){let i=e.lineCount,o=null;var s;for(let a=r.length?(s=r,s[s.length-1])[1]:0;a<i&&r.length<t;++a){let t=e.lineAt(a).text;if(a+1>=i&&""==t)break;if(n&&t.startsWith(n))continue;let s=t.match(/"/g),l=s&&s.length%2==1;if(null!==o||l)if(null===o&&l)o=a;else{if(!l)continue;r.push([o,a+1]),o=null}else r.push([a,a+1])}null!==o&&r.push([o,i])},e.exports.get_default_js_udf_content=function(){return"// This file can be used to store RBQL UDFs. Example:\n //\n // function foo(value) {\n // return 'foo ' + String(value.length);\n // }\n // \n // Functions defined in this file can be used in RBQL queries e.g. \n // SELECT foo(a1), a2 WHERE foo(a3) != 'foo 5' LIMIT 10\n //\n // Don't forget to save this file after editing!\n //\n // Write your own functions bellow this line:\n ".replace(new RegExp(/^ */,"mg"),"")},e.exports.get_default_python_udf_content=function(){return"# This file can be used to store RBQL UDFs. Example:\n #\n # def foo(value):\n # return 'foo ' + str(len(value))\n # \n # \n # Functions defined in this file can be used in RBQL queries e.g. \n # SELECT foo(a1), a2 WHERE foo(a3) != 'foo 5' LIMIT 10\n #\n # Don't forget to save this file after editing!\n #\n # Write your own functions bellow this line:\n ".replace(new RegExp(/^ */,"mg"),"")},e.exports.align_columns=function(e,t,r,n,i){let o=[],s=e.lineCount,a=!1,l=!0;for(let c=0;c<s;c++){let _=e.lineAt(c).text;if(n&&_.startsWith(n)){o.push(_);continue}if(c+1==s&&""==_){o.push(_);continue}let p=u.smart_split(_,t,r,!0)[0];for(let e=0;e<p.length&&!(e>=i.length);e++){let t=e+1==i.length,r=f(p[e],l,i[e],t);p[e]!=r&&(p[e]=r,a=!0)}l=!1,o.push(p.join(t))}return a?o.join("\n"):null},e.exports.shrink_columns=function(e,t,r,n){let i=[],o=e.lineCount,s=!1;for(let a=0;a<o;a++){let o=e.lineAt(a).text;if(n&&o.startsWith(n)){i.push(o);continue}let[l,c]=u.smart_split(o,t,r,!0);if(c)return[null,a+1];for(let e=0;e<l.length;e++){let t=l[e].trim();l[e].length!=t.length&&(l[e]=t,s=!0)}i.push(l.join(t))}return s?[i.join("\n"),null]:[null,null]},e.exports.calc_column_stats=function(e,t,r,n){let i=[],o=e.lineCount,s=!0;for(let a=0;a<o;a++){let o=e.lineAt(a).text;if(n&&o.startsWith(n))continue;let[l,c]=u.smart_split(o,t,r,!0);if(c)return[null,a+1];for(let e=0;e<l.length;e++){let t=l[e].trim();i.length<=e&&i.push([0,0,0]),p(t,s,i[e])}s=!1}return[i,null]},e.exports.adjust_column_stats=function(e){let t=[];for(let r of e){if(r[1]<=0&&(r[1]=-1,r[2]=-1),r[1]>0&&(r[1]+r[2]>r[0]&&(r[0]=r[1]+r[2]),r[0]-r[2]>r[1]&&(r[1]=r[0]-r[2]),r[0]!=r[1]+r[2]))return null;t.push(r)}return t},e.exports.update_subcomponent_stats=p,e.exports.align_field=f},8594:e=>{let t=new RegExp('^"((?:[^"]*"")*[^"]*)"'),r=new RegExp('^ *"((?:[^"]*"")*[^"]*)" *');function n(e,n,i,o,s,a){var l=!1;let u=e.substring(s),c=(o?r:t).exec(u);if(null!==c){let t=c[0].length;if(s+t==e.length||e[s+t]==n)return i?a.push(c[0]):a.push(c[1].replace(/""/g,'"')),[s+t+1,!1];l=!0}var _=e.indexOf(n,s);-1==_&&(_=e.length);var p=e.substring(s,_);return l=l||-1!=p.indexOf('"'),a.push(p),[_+1,l]}function i(e,t,r=!1){if(-1==e.indexOf('"'))return[e.split(t),!1];var i=[],o=0,s=!1;let a=" "!=t;for(;o<e.length;){var l=n(e,t,r,a,o,i);o=l[0],s=s||l[1]}return e.charAt(e.length-1)==t&&i.push(""),[i,s]}function o(e){let t=new RegExp('^ *"((?:[^"]*"")*[^"]*)" *$').exec(e);return null!==t?t[1].replace(/""/g,'"'):e}function s(e,t=!1){var r=t?new RegExp(" *[^ ]+ *","g"):new RegExp("[^ ]+","g");let n=[],i=null;for(;null!==(i=r.exec(e));)n.push(i[0]);if(t)for(let e=0;e<n.length-1;e++)n[e]=n[e].slice(0,-1);return n}e.exports.split_quoted_str=i,e.exports.split_whitespace_separated_str=s,e.exports.smart_split=function(e,t,r,n){return"simple"===r?[e.split(t),!1]:"whitespace"===r?[s(e,n),!1]:"monocolumn"===r?[[e],!1]:i(e,t,n)},e.exports.quote_field=function(e,t){return-1!=e.indexOf(t)||-1!=e.indexOf('"')?`"${e.replace(/"/g,'""')}"`:e},e.exports.rfc_quote_field=function(e,t){return-1!=e.indexOf(t)||-1!=e.indexOf('"')||-1!=e.indexOf("\n")||-1!=e.indexOf("\r")?`"${e.replace(/"/g,'""')}"`:e},e.exports.unquote_field=o,e.exports.unquote_fields=function(e){return e.map(o)},e.exports.split_lines=function(e){return e.split(/\r\n|\r|\n/)},e.exports.accumulate_rfc_line_into_record=function(e,t,r=null){if(null!==r&&0==e.length&&t.startsWith(r))return null;let n=t.match(/"/g),i=n&&n.length%2==1;if(0==e.length&&!i)return t;if(0==e.length&&i)e.push(t);else{if(i){e.push(t);let r=e.join("\n");return e.splice(0,e.length),r}e.push(t)}return null}},6987:(__unused_webpack_module,exports)=>{(function(exports){class RbqlParsingError extends Error{}class RbqlRuntimeError extends Error{}class AssertionError extends Error{}class RbqlIOHandlingError extends Error{}class InternalBadFieldError extends Error{constructor(e,...t){super(...t),this.bad_idx=e}}function assert(e,t=null){if(!e)throw t||(t="Assertion error"),new AssertionError(t)}function replace_all(e,t,r){return e.split(t).join(r)}class RBQLContext{constructor(e,t,r,n){this.query_text=e,this.input_iterator=t,this.writer=r,this.user_init_code=n,this.unnest_list=null,this.top_count=null,this.like_regex_cache=new Map,this.sort_key_expression=null,this.aggregation_stage=0,this.aggregation_key_expression=null,this.functional_aggregators=[],this.join_map_impl=null,this.join_map=null,this.lhs_join_var_expression=null,this.where_expression=null,this.select_expression=null,this.update_expressions=null,this.variables_init_code=null}}var query_context=null;const wrong_aggregation_usage_error="Usage of RBQL aggregation functions inside JavaScript expressions is not allowed, see the docs",RBQL_VERSION="0.25.0";function check_if_brackets_match(e,t){return"["==e&&"]"==t||"("==e&&")"==t||"{"==e&&"}"==t}function parse_root_bracket_level_text_spans(e){let t=[],r=0,n=[];for(let i=0;i<e.length;i++){let o=e[i];if(","==o&&0==n.length)t.push(e.substring(r,i)),r=i+1;else if(-1!=["[","{","("].indexOf(o))n.push(o);else if(-1!=["]","}",")"].indexOf(o)){if(!n.length||!check_if_brackets_match(n[n.length-1],o))throw new RbqlParsingError(`Unable to parse column headers in SELECT expression: No matching opening bracket for closing "${o}"`);n.pop()}}if(n.length)throw new RbqlParsingError(`Unable to parse column headers in SELECT expression: No matching closing bracket for opening "${n[0]}"`);return t.push(e.substring(r,e.length)),t=t.map((e=>e.trim())),t}function unquote_string(e){return!e||e.length<2?null:"'"==e[0]&&"'"==e[e.length-1]?e.substring(1,e.length-1).replace(/\\'/g,"'").replace(/\\\\/g,"\\"):'"'==e[0]&&'"'==e[e.length-1]?e.substring(1,e.length-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"):null}function column_info_from_text_span(e,t){e=e.trim();let r="__RBQL_INTERNAL_STAR",n=/^[_a-zA-Z][_a-zA-Z0-9]*$/.exec(e),i=/^([ab])\.([_a-zA-Z][_a-zA-Z0-9]*)$/.exec(e),o=/^([ab])\[([0-9]+)\]$/.exec(e),s=/^([ab])\[___RBQL_STRING_LITERAL([0-9]+)___\]$/.exec(e);if(null!==n){if(e==r)return{table_name:null,column_index:null,column_name:null,is_star:!0};if(e.startsWith("___RBQL_STRING_LITERAL"))return null;let t=/^([ab])([0-9]+)$/.exec(e);return null!==t?{table_name:t[1],column_index:parseInt(t[2])-1,column_name:null,is_star:!1}:{table_name:null,column_index:null,column_name:e,is_star:!1}}if(null!==i){let e=i[1],t=i[2];return t==r?{table_name:e,column_index:null,column_name:null,is_star:!0}:{table_name:null,column_index:null,column_name:t,is_star:!1}}if(null!=o)return{table_name:o[1],column_index:parseInt(o[2])-1,column_name:null,is_star:!1};if(null!=s){s[1];let e=s[2];if(e<t.length){let r=unquote_string(t[e]);if(null!=r)return{table_name:null,column_index:null,column_name:r,is_star:!1}}}return null}function adhoc_parse_select_expression_to_column_infos(e,t){return parse_root_bracket_level_text_spans(e).map((e=>column_info_from_text_span(e,t)))}function stable_compare(e,t){for(var r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1}function safe_get(e,t){return t<e.length?e[t]:null}function safe_join_get(e,t){if(t<e.length)return e[t];throw new InternalBadFieldError(t)}function safe_set(e,t,r){if(!(t<e.length))throw new InternalBadFieldError(t);e[t]=r}function regexp_escape(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function like_to_regex(e){let t=0,r=0,n="";for(;r<e.length;)"_"!=e.charAt(r)&&"%"!=e.charAt(r)||(n+=regexp_escape(e.substring(t,r)),t=r+1,"_"==e.charAt(r)?n+=".":n+=".*"),r+=1;return n+=regexp_escape(e.substring(t,r)),"^"+n+"$"}function like(e,t){let r=query_context.like_regex_cache.get(t);return void 0===r&&(r=new RegExp(like_to_regex(t)),query_context.like_regex_cache.set(t,r)),r.test(e)}const LIKE=like;class RBQLAggregationToken{constructor(e,t){this.marker_id=e,this.value=t}toString(){throw new RbqlParsingError(wrong_aggregation_usage_error)}}class UnnestMarker{}function UNNEST(e){if(null!==query_context.unnest_list)throw new RbqlParsingError("Only one UNNEST is allowed per query");return query_context.unnest_list=e,new UnnestMarker}const unnest=UNNEST,Unnest=UNNEST,UNFOLD=UNNEST;function parse_number(e){let t=Number(e);if(isNaN(t))throw new RbqlRuntimeError(`Unable to convert value "${e}" to a number. MIN, MAX, SUM, AVG, MEDIAN and VARIANCE aggregate functions convert their string arguments to numeric values`);return t}class MinAggregator{constructor(){this.stats=new Map}increment(e,t){t=parse_number(t);var r=this.stats.get(e);void 0===r?this.stats.set(e,t):this.stats.set(e,Math.min(r,t))}get_final(e){return this.stats.get(e)}}class MaxAggregator{constructor(){this.stats=new Map}increment(e,t){t=parse_number(t);var r=this.stats.get(e);void 0===r?this.stats.set(e,t):this.stats.set(e,Math.max(r,t))}get_final(e){return this.stats.get(e)}}class SumAggregator{constructor(){this.stats=new Map}increment(e,t){t=parse_number(t);var r=this.stats.get(e);void 0===r?this.stats.set(e,t):this.stats.set(e,r+t)}get_final(e){return this.stats.get(e)}}class AvgAggregator{constructor(){this.stats=new Map}increment(e,t){t=parse_number(t);var r=this.stats.get(e);if(void 0===r)this.stats.set(e,[t,1]);else{var n=r[0],i=r[1];this.stats.set(e,[n+t,i+1])}}get_final(e){var t=this.stats.get(e);return t[0]/t[1]}}class VarianceAggregator{constructor(){this.stats=new Map}increment(e,t){t=parse_number(t);var r=this.stats.get(e);if(void 0===r)this.stats.set(e,[t,t*t,1]);else{var n=r[0],i=r[1],o=r[2];this.stats.set(e,[n+t,i+t*t,o+1])}}get_final(e){var t=this.stats.get(e),r=t[0],n=t[1],i=t[2],o=r/i;return n/i-o*o}}class MedianAggregator{constructor(){this.stats=new Map}increment(e,t){t=parse_number(t);var r=this.stats.get(e);void 0===r?this.stats.set(e,[t]):r.push(t)}get_final(e){var t=this.stats.get(e);t.sort((function(e,t){return e-t}));var r=Math.floor(t.length/2);return t.length%2?t[r]:(t[r-1]+t[r])/2}}class CountAggregator{constructor(){this.stats=new Map}increment(e,t){var r=this.stats.get(e);void 0===r?this.stats.set(e,1):this.stats.set(e,r+1)}get_final(e){return this.stats.get(e)}}class ArrayAggAggregator{constructor(e=null){this.post_proc=e,this.stats=new Map}increment(e,t){let r=this.stats.get(e);void 0===r?this.stats.set(e,[t]):r.push(t)}get_final(e){let t=this.stats.get(e);return null===this.post_proc?t:this.post_proc(t)}}class ConstGroupVerifier{constructor(e){this.output_index=e,this.const_values=new Map}increment(e,t){var r=this.const_values.get(e);if(void 0===r)this.const_values.set(e,t);else if(r!=t)throw new RbqlRuntimeError(`Invalid aggregate expression: non-constant values in output column ${this.output_index+1}. E.g. "${r}" and "${t}"`)}get_final(e){return this.const_values.get(e)}}function init_aggregator(e,t,r=null){query_context.aggregation_stage=1;var n=new RBQLAggregationToken(query_context.functional_aggregators.length,t);return null===r?query_context.functional_aggregators.push(new e):query_context.functional_aggregators.push(new e(r)),n}function MIN(e){return query_context.aggregation_stage<2?init_aggregator(MinAggregator,e):e}const min=MIN,Min=MIN;function MAX(e){return query_context.aggregation_stage<2?init_aggregator(MaxAggregator,e):e}const max=MAX,Max=MAX;function COUNT(e){return query_context.aggregation_stage<2?init_aggregator(CountAggregator,1):1}const count=COUNT,Count=COUNT;function SUM(e){return query_context.aggregation_stage<2?init_aggregator(SumAggregator,e):e}const sum=SUM,Sum=SUM;function AVG(e){return query_context.aggregation_stage<2?init_aggregator(AvgAggregator,e):e}const avg=AVG,Avg=AVG;function VARIANCE(e){return query_context.aggregation_stage<2?init_aggregator(VarianceAggregator,e):e}const variance=VARIANCE,Variance=VARIANCE;function MEDIAN(e){return query_context.aggregation_stage<2?init_aggregator(MedianAggregator,e):e}const median=MEDIAN,Median=MEDIAN;function ARRAY_AGG(e,t=null){return query_context.aggregation_stage<2?init_aggregator(ArrayAggAggregator,e,t):e}const array_agg=ARRAY_AGG,FOLD=ARRAY_AGG;function add_to_set(e,t){var r=e.size;return e.add(t),r!=e.size}class TopWriter{constructor(e,t){this.subwriter=e,this.NW=0,this.top_count=t}async write(e){return!(null!==this.top_count&&this.NW>=this.top_count||(await this.subwriter.write(e),this.NW+=1,0))}async finish(){await this.subwriter.finish()}}class UniqWriter{constructor(e){this.subwriter=e,this.seen=new Set}async write(e){return!add_to_set(this.seen,JSON.stringify(e))||!!await this.subwriter.write(e)}async finish(){await this.subwriter.finish()}}class UniqCountWriter{constructor(e){this.subwriter=e,this.records=new Map}async write(e){var t=JSON.stringify(e),r=this.records.get(t);return r?r[0]+=1:this.records.set(t,[1,e]),!0}async finish(){for(var[e,t]of this.records){let[e,r]=t;if(r.unshift(e),!await this.subwriter.write(r))break}await this.subwriter.finish()}}class SortedWriter{constructor(e,t){this.subwriter=e,this.reverse_sort=t,this.unsorted_entries=[]}async write(e){return this.unsorted_entries.push(e),!0}async finish(){var e=this.unsorted_entries;e.sort(stable_compare),this.reverse_sort&&e.reverse();for(var t=0;t<e.length;t++){var r=e[t];if(!await this.subwriter.write(r[r.length-1]))break}await this.subwriter.finish()}}class AggregateWriter{constructor(e){this.subwriter=e,this.aggregators=[],this.aggregation_keys=new Set}async finish(){var e=Array.from(this.aggregation_keys);e.sort();for(var t=0;t<e.length;t++){var r=e[t],n=[];for(var i of this.aggregators)n.push(i.get_final(r));if(!await this.subwriter.write(n))break}await this.subwriter.finish()}}class InnerJoiner{constructor(e){this.join_map=e}get_rhs(e){return this.join_map.get_join_records(e)}}class LeftJoiner{constructor(e){this.join_map=e,this.null_record=[[null,e.max_record_len,Array(e.max_record_len).fill(null)]]}get_rhs(e){let t=this.join_map.get_join_records(e);return 0==t.length?this.null_record:t}}class StrictLeftJoiner{constructor(e){this.join_map=e}get_rhs(e){let t=this.join_map.get_join_records(e);if(1!=t.length)throw new RbqlRuntimeError('In "STRICT LEFT JOIN" each key in A must have exactly one match in B. Bad A key: "'+e+'"');return t}}function select_except(e,t){let r=[];for(let n=0;n<e.length;n++)-1==t.indexOf(n)&&r.push(e[n]);return r}async function select_simple(e,t,r){if(null!==query_context.sort_key_expression){var n=e.concat([t,r]);if(!await query_context.writer.write(n))return!1}else if(!await query_context.writer.write(r))return!1;return!0}function select_aggregated(e,t){if(null!==e&&(e=JSON.stringify(e)),1===query_context.aggregation_stage){if(!(query_context.writer instanceof TopWriter))throw new RbqlParsingError('"ORDER BY", "UPDATE" and "DISTINCT" keywords are not allowed in aggregate queries');query_context.writer=new AggregateWriter(query_context.writer);let i=0;for(var r=0;r<t.length;r++)(n=t[r])instanceof RBQLAggregationToken?(query_context.writer.aggregators.push(query_context.functional_aggregators[n.marker_id]),query_context.writer.aggregators[query_context.writer.aggregators.length-1].increment(e,n.value),i+=1):(query_context.writer.aggregators.push(new ConstGroupVerifier(query_context.writer.aggregators.length)),query_context.writer.aggregators[query_context.writer.aggregators.length-1].increment(e,n));if(i!=query_context.functional_aggregators.length)throw new RbqlParsingError(wrong_aggregation_usage_error);query_context.aggregation_stage=2}else for(r=0;r<t.length;r++){var n=t[r];query_context.writer.aggregators[r].increment(e,n)}query_context.writer.aggregation_keys.add(e)}async function select_unnested(e,t,r){let n=r.slice(),i=r.findIndex((e=>e instanceof UnnestMarker));for(var o=0;o<query_context.unnest_list.length;o++)if(n[i]=query_context.unnest_list[o],!await select_simple(e,t,n.slice()))return!1;return!0}const PROCESS_SELECT_COMMON="\n__RBQLMP__variables_init_code\nif (__RBQLMP__where_expression) {\n let out_fields = __RBQLMP__select_expression;\n if (query_context.aggregation_stage > 0) {\n let key = __RBQLMP__aggregation_key_expression;\n select_aggregated(key, out_fields);\n } else {\n let sort_key = [__RBQLMP__sort_key_expression];\n if (query_context.unnest_list !== null) {\n if (!await select_unnested(sort_key, NR, out_fields))\n stop_flag = true;\n } else {\n if (!await select_simple(sort_key, NR, out_fields))\n stop_flag = true;\n }\n }\n}\n",PROCESS_SELECT_SIMPLE="\nlet star_fields = record_a;\n__CODE__\n",PROCESS_SELECT_JOIN="\nlet join_matches = query_context.join_map.get_rhs(__RBQLMP__lhs_join_var_expression);\nfor (let join_match of join_matches) {\n let [bNR, bNF, record_b] = join_match;\n let star_fields = record_a.concat(record_b);\n __CODE__\n if (stop_flag)\n break;\n}\n",PROCESS_UPDATE_JOIN="\nlet join_matches = query_context.join_map.get_rhs(__RBQLMP__lhs_join_var_expression);\nif (join_matches.length > 1)\n throw new RbqlRuntimeError('More than one record in UPDATE query matched a key from the input table in the join table');\nlet record_b = null;\nlet bNR = null;\nlet bNF = null;\nif (join_matches.length == 1)\n [bNR, bNF, record_b] = join_matches[0];\nlet up_fields = record_a;\n__RBQLMP__variables_init_code\nif (join_matches.length == 1 && (__RBQLMP__where_expression)) {\n NU += 1;\n __RBQLMP__update_expressions\n}\nif (!await query_context.writer.write(up_fields))\n stop_flag = true;\n",PROCESS_UPDATE_SIMPLE="\nlet up_fields = record_a;\n__RBQLMP__variables_init_code\nif (__RBQLMP__where_expression) {\n NU += 1;\n __RBQLMP__update_expressions\n}\nif (!await query_context.writer.write(up_fields))\n stop_flag = true;\n",MAIN_LOOP_BODY="\n__USER_INIT_CODE__\n\nlet NU = 0;\nlet NR = 0;\n\nlet stop_flag = false;\nwhile (!stop_flag) {\n let record_a = await query_context.input_iterator.get_record();\n if (record_a === null)\n break;\n NR += 1;\n let NF = record_a.length;\n query_context.unnest_list = null; // TODO optimize, don't need to set this every iteration\n try {\n __CODE__\n } catch (e) {\n if (e.constructor.name === 'InternalBadFieldError') {\n throw new RbqlRuntimeError(`No \"a${e.bad_idx + 1}\" field at record ${NR}`);\n } else if (e.constructor.name === 'RbqlParsingError') {\n throw(e);\n } else {\n throw new RbqlRuntimeError(`At record ${NR}, Details: ${e.message}`);\n }\n }\n}\n";function embed_expression(e,t,r){return replace_all(e,t,r)}function embed_code(e,t,r){let n=e.split("\n"),i=r.split("\n");for(let e=0;e<n.length;e++){let r=n[e].indexOf(t);if(-1==r)continue;assert(r%4==0);let o=n[e].substring(0,r);return i=i.map((e=>o+e)),n.slice(0,e).concat(i).concat(n.slice(e+1)).join("\n")+"\n"}assert(!1)}function generate_main_loop_code(e){let t=null!==e.select_expression,r=null!==e.join_map,n=null===e.where_expression?"true":e.where_expression,i=null===e.aggregation_key_expression?"null":e.aggregation_key_expression,o=null===e.sort_key_expression?"null":e.sort_key_expression,s=embed_code(MAIN_LOOP_BODY,"__USER_INIT_CODE__",e.user_init_code);return t?(r?(s=embed_code(embed_code(s,"__CODE__",PROCESS_SELECT_JOIN),"__CODE__",PROCESS_SELECT_COMMON),s=embed_expression(s,"__RBQLMP__lhs_join_var_expression",e.lhs_join_var_expression)):s=embed_code(embed_code(s,"__CODE__",PROCESS_SELECT_SIMPLE),"__CODE__",PROCESS_SELECT_COMMON),s=embed_code(s,"__RBQLMP__variables_init_code",e.variables_init_code),s=embed_expression(s,"__RBQLMP__select_expression",e.select_expression),s=embed_expression(s,"__RBQLMP__where_expression",n),s=embed_expression(s,"__RBQLMP__aggregation_key_expression",i),s=embed_expression(s,"__RBQLMP__sort_key_expression",o)):(r?(s=embed_code(s,"__CODE__",PROCESS_UPDATE_JOIN),s=embed_expression(s,"__RBQLMP__lhs_join_var_expression",e.lhs_join_var_expression)):s=embed_code(s,"__CODE__",PROCESS_UPDATE_SIMPLE),s=embed_code(s,"__RBQLMP__variables_init_code",e.variables_init_code),s=embed_code(s,"__RBQLMP__update_expressions",e.update_expressions),s=embed_expression(s,"__RBQLMP__where_expression",n)),"(async () => {"+s+"})()"}async function compile_and_run(query_context){let main_loop_body=generate_main_loop_code(query_context);try{let main_loop_promise=eval(main_loop_body);await main_loop_promise}catch(e){if(e instanceof SyntaxError){let t=query_context.query_text.toLowerCase();if(-1!=t.indexOf(" having "))throw new SyntaxError(e.message+'\nRBQL doesn\'t support "HAVING" keyword');if(-1!=t.indexOf(" like "))throw new SyntaxError(e.message+"\nRBQL doesn't support \"LIKE\" operator, use like() function instead e.g. ... WHERE like(a1, 'foo%bar') ... ");if(-1!=t.indexOf(" from "))throw new SyntaxError(e.message+'\nTip: If input table is defined by the environment, RBQL query should not have "FROM" keyword');if(e&&e.message&&-1!=String(e.message).toLowerCase().indexOf("unexpected identifier")){if(-1!=t.indexOf(" and "))throw new SyntaxError(e.message+"\nDid you use 'and' keyword in your query?\nJavaScript backend doesn't support 'and' keyword, use '&&' operator instead!");if(-1!=t.indexOf(" or "))throw new SyntaxError(e.message+"\nDid you use 'or' keyword in your query?\nJavaScript backend doesn't support 'or' keyword, use '||' operator instead!")}}if(e&&e.message&&-1!=e.message.indexOf("Received an instance of RBQLAggregationToken"))throw new RbqlParsingError(wrong_aggregation_usage_error);throw e}}const GROUP_BY="GROUP BY",UPDATE="UPDATE",SELECT="SELECT",JOIN="JOIN",INNER_JOIN="INNER JOIN",LEFT_JOIN="LEFT JOIN",LEFT_OUTER_JOIN="LEFT OUTER JOIN",STRICT_LEFT_JOIN="STRICT LEFT JOIN",ORDER_BY="ORDER BY",WHERE="WHERE",LIMIT="LIMIT",EXCEPT="EXCEPT",WITH="WITH";function get_ambiguous_error_msg(e){return`Ambiguous variable name: "${e}" is present both in input and in join tables`}function get_all_matches(e,t){var r=[];let n=null;for(;null!==(n=e.exec(t));)r.push(n);return r}function str_strip(e){return e.replace(/^ +| +$/g,"")}function strip_comments(e){return(e=e.trim()).startsWith("//")?"":e}function combine_string_literals(e,t){for(var r=0;r<t.length;r++)e=replace_all(e,`___RBQL_STRING_LITERAL${r}___`,t[r]);return e}function parse_basic_variables(e,t,r){assert("a"==t||"b"==t);let n=get_all_matches(new RegExp(`(?:^|[^_a-zA-Z0-9])${t}([1-9][0-9]*)(?:$|(?=[^_a-zA-Z0-9]))`,"g"),e);for(let e=0;e<n.length;e++){let i=parseInt(n[e][1]);r[t+String(i)]={initialize:!0,index:i-1}}}function parse_array_variables(e,t,r){assert("a"==t||"b"==t);let n=get_all_matches(new RegExp(`(?:^|[^_a-zA-Z0-9])${t}\\[([1-9][0-9]*)\\]`,"g"),e);for(let e=0;e<n.length;e++){let i=parseInt(n[e][1]);r[`${t}[${i}]`]={initialize:!0,index:i-1}}}function js_string_escape_column_name(e,t){return e=(e=(e=(e=e.replace(/\\/g,"\\\\")).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t"),"'"===t?e.replace(/'/g,"\\'"):'"'===t?e.replace(/"/g,'\\"'):(assert("`"===t),e.replace(/`/g,"\\`"))}function query_probably_has_dictionary_variable(e,t){let r=get_all_matches(new RegExp("[-a-zA-Z0-9_:;+=!.,()%^#@&* ]+","g"),t);for(let t of r)if(-1==e.indexOf(t))return!1;return!0}function parse_dictionary_variables(e,t,r,n){assert("a"===t||"b"===t);let i=new RegExp(`(?:^|[^_a-zA-Z0-9])${t}\\[`);if(-1!=e.search(i))for(let i=0;i<r.length;i++){let o=r[i];if(query_probably_has_dictionary_variable(e,o)){let e=js_string_escape_column_name(o,'"');n[`${t}["${e}"]`]={initialize:!0,index:i},e=js_string_escape_column_name(o,"'"),n[`${t}['${e}']`]={initialize:!1,index:i},e=js_string_escape_column_name(o,"`"),n[`${t}[\`${e}\`]`]={initialize:!1,index:i}}}}function parse_attribute_variables(e,t,r,n,i){assert("a"===t||"b"===t);let o=get_all_matches(new RegExp(`(?:^|[^_a-zA-Z0-9])${t}\\.([_a-zA-Z][_a-zA-Z0-9]*)`,"g"),e).map((e=>e[1]));for(let e of o){let o=r.indexOf(e);if(-1==o)throw new RbqlParsingError(`Unable to find column "${e}" in ${"a"==t?"input":"join"} ${n}`);i[`${t}.${e}`]={initialize:!0,index:o}}}function map_variables_directly(e,t,r){for(let n=0;n<t.length;n++){let i=t[n];if(null===/^[_a-zA-Z][_a-zA-Z0-9]*$/.exec(i))throw new RbqlIOHandlingError(`Unable to use column name "${i}" as RBQL/JS variable`);-1!=e.indexOf(i)&&(r[i]={initialize:!0,index:n})}}function ensure_no_ambiguous_variables(e,t,r){let n=new Set(r);for(let r of t)if(n.has(r)&&-1!=e.indexOf(r))throw new RbqlParsingError(get_ambiguous_error_msg(r))}function parse_join_expression(e){e=str_strip(e);const t="Invalid join syntax. Valid syntax: <JOIN> /path/to/B/table on a... == b... [and a... == b... [and ... ]]";let r=/^ *([^ ]+) +on +/i.exec(e);if(null===r)throw new RbqlParsingError(t);let n=r[1];e=e.substr(r[0].length);let i=[];for(var o=/^([^ =]+) *==? *([^ =]+)/,s=/^ +(and|&&) +/i;;){if(r=o.exec(e),null===r)throw new RbqlParsingError(t);if(i.push([r[1],r[2]]),!(e=e.substr(r[0].length)).length)break;if(r=s.exec(e),null===r)throw new RbqlParsingError(t);e=e.substr(r[0].length)}return[n,i]}function resolve_join_variables(e,t,r,n){let i=[],o=[];const s="Valid JOIN syntax: <JOIN> /path/to/B/table on a... == b... [and a... == b... [and ... ]]";for(let a of r){let[r,l]=a;if(r=combine_string_literals(r,n),l=combine_string_literals(l,n),e.hasOwnProperty(r)&&t.hasOwnProperty(r))throw new RbqlParsingError(get_ambiguous_error_msg(r));if(e.hasOwnProperty(l)&&t.hasOwnProperty(l))throw new RbqlParsingError(get_ambiguous_error_msg(l));e.hasOwnProperty(l)&&([r,l]=[l,r]);let[u,c]=[null,null];if(-1!=["NR","a.NR","aNR"].indexOf(r))u=-1;else{if(!e.hasOwnProperty(r))throw new RbqlParsingError(`Unable to parse JOIN expression: Input table does not have field "${r}"\n${s}`);u=e[r].index}if(-1!=["b.NR","bNR"].indexOf(l))c=-1;else{if(!t.hasOwnProperty(l))throw new RbqlParsingError(`Unable to parse JOIN expression: Join table does not have field "${l}"\n${s}`);c=t[l].index}let _=-1==u?"NR":`safe_join_get(record_a, ${u})`;o.push(c),i.push(_)}return[i,o]}function generate_common_init_code(e,t){assert("a"==t||"b"==t);let r=[];r.push(`${t} = new Object();`);let n="a"==t?"NR":"bNR",i=`${t}.NR`;return-1!=e.indexOf(i)&&r.push(`${i} = ${n};`),"a"==t&&-1!=e.indexOf("aNR")&&r.push("aNR = NR;"),r}function generate_init_statements(e,t,r,n){let i=generate_common_init_code(e,"a"),o=/^[_0-9a-zA-Z]+$/;for(const[e,r]of Object.entries(t))if(r.initialize){let t=o.exec(e)?"var ":"";i.push(`${t}${e} = safe_get(record_a, ${r.index});`)}if(r){i=i.concat(generate_common_init_code(e,"b"));for(const[e,t]of Object.entries(r))if(t.initialize){let r=o.exec(e)?"var ":"";i.push(`${r}${e} = record_b === null ? null : safe_get(record_b, ${t.index});`)}}for(let e=1;e<i.length;e++)i[e]=n+i[e];return i.join("\n")}function replace_star_count(e){return str_strip(e.replace(/(^|,) *COUNT\( *\* *\) *(?:$|(?=,))/gi,"$1 COUNT(1)"))}function replace_star_vars(e){let t=get_all_matches(/(?:^|,) *(\*|a\.\*|b\.\*) *(?=$|,)/g,e),r=0,n="";for(let i of t){let t="]).concat("+{"*":"star_fields","a.*":"record_a","b.*":"record_b"}[i[1]]+").concat([";r<i.index&&(n+=e.substring(r,i.index)),n+=t,r=i.index+i[0].length+1}return n+=e.substring(r),n}function replace_star_vars_for_header_parsing(e){let t=get_all_matches(/(?:(?<=^)|(?<=,)) *(\*|a\.\*|b\.\*) *(?=$|,)/g,e),r=0,n="";for(let i of t){let t={"*":"__RBQL_INTERNAL_STAR","a.*":"a.__RBQL_INTERNAL_STAR","b.*":"b.__RBQL_INTERNAL_STAR"}[i[1]];r<i.index&&(n+=e.substring(r,i.index)),n+=t,r=i.index+i[0].length}return n+=e.substring(r),n}function translate_update_expression(e,t,r,n){let i=`Unable to parse "UPDATE" expression: the expression must start with assignment, but "${str_strip(e.split("=")[0])}" does not look like an assignable field name`,o=/(?:^|,) *(a[.#a-zA-Z0-9\[\]_]*) *=(?=[^=])/g,s=[],a=0;for(;;){let l=o.exec(e);if(0==s.length&&(null===l||0!=l.index))throw new RbqlParsingError(i);if(null===l){s[s.length-1]+=str_strip(e.substr(a))+");";break}s.length&&(s[s.length-1]+=str_strip(e.substring(a,l.index))+");");let u=combine_string_literals(str_strip(l[1]),r);if(!t.hasOwnProperty(u))throw new RbqlParsingError(`Unable to parse "UPDATE" expression: Unknown field name: "${u}"`);let c=t[u].index,_=s.length?n:"";s.push(`${_}safe_set(up_fields, ${c}, `),a=l.index+l[0].length}return combine_string_literals(s.join("\n"),r)}function translate_select_expression(e){let t=replace_star_count(e),r=str_strip(replace_star_vars(t)),n=str_strip(replace_star_vars_for_header_parsing(t));if(!r.length)throw new RbqlParsingError('"SELECT" expression is empty');return[`[].concat([${r}])`,n]}function separate_string_literals(e){for(var t=/('(\\(\\\\)*'|[^'])*')|("(\\(\\\\)*"|[^"])*")|(`(\\(\\\\)*`|[^`])*`)/g,r=null,n=[],i=[],o=0;null!==(r=t.exec(e));){var s=i.length,a=r[0];i.push(a);var l=r.index;n.push(e.substring(o,l)),n.push(`___RBQL_STRING_LITERAL${s}___`),o=t.lastIndex}n.push(e.substring(o));var u=n.join("");return[u=u.replace(/\t/g," "),i]}function locate_statements(e){let t=[];t.push([STRICT_LEFT_JOIN,LEFT_OUTER_JOIN,LEFT_JOIN,INNER_JOIN,JOIN]),t.push([SELECT]),t.push([ORDER_BY]),t.push([WHERE]),t.push([UPDATE]),t.push([GROUP_BY]),t.push([LIMIT]),t.push([EXCEPT]);for(var r=[],n=0;n<t.length;n++)for(var i=0;i<t[n].length;i++){var o=t[n][i],s=get_all_matches(new RegExp("(?:^| )"+replace_all(o," "," *")+"(?= )","ig"),e);if(s.length){if(s.length>1)throw new RbqlParsingError(`More than one "${o}" statements found`);assert(1==s.length);var a=s[0],l=a[0];r.push([a.index,a.index+l.length,o]);break}}return r.sort((function(e,t){return e[0]-t[0]})),r}function separate_actions(e){e=str_strip(e);var t={};let r=/^(.*) *[Ww][Ii][Tt][Hh] *\(([a-z]{4,20})\) *$/.exec(e);null!==r&&(e=r[1],t[WITH]=r[2]);for(var n=locate_statements(e),i=0;i<n.length;i++){var o=n[i][0],s=n[i][1],a=n[i][2],l=i+1<n.length?n[i+1][0]:e.length;assert(o<s),assert(s<=l);var u=e.substring(s,l),c={};if(-1!=[STRICT_LEFT_JOIN,LEFT_OUTER_JOIN,LEFT_JOIN,INNER_JOIN,JOIN].indexOf(a)&&(c.join_subtype=a,a=JOIN),a==UPDATE){if(0!=o)throw new RbqlParsingError("UPDATE keyword must be at the beginning of the query");u=u.replace(/^ *SET/i,"")}if(a==ORDER_BY){var _=(u=u.replace(/ ASC *$/i,"")).replace(/ DESC *$/i,"");_!=u?(u=_,c.reverse=!0):c.reverse=!1}if(a==SELECT){if(0!=o)throw new RbqlParsingError("SELECT keyword must be at the beginning of the query");let e=/^ *TOP *([0-9]+) /i.exec(u);null!==e&&(c.top=parseInt(e[1]),u=u.substr(e.index+e[0].length)),e=/^ *DISTINCT *(COUNT)? /i.exec(u),null!==e&&(c.distinct=!0,e[1]&&(c.distinct_count=!0),u=u.substr(e.index+e[0].length))}c.text=str_strip(u),t[a]=c}if(!t.hasOwnProperty(SELECT)&&!t.hasOwnProperty(UPDATE))throw new RbqlParsingError("Query must contain either SELECT or UPDATE statement");return assert(t.hasOwnProperty(SELECT)!=t.hasOwnProperty(UPDATE)),t}function find_top(e){if(e.hasOwnProperty(LIMIT)){if(null===/^[0-9]+$/.exec(e[LIMIT].text))throw new RbqlParsingError("LIMIT keyword must be followed by an integer");return parseInt(e[LIMIT].text)}var t=e[SELECT];return t&&t.hasOwnProperty("top")?t.top:null}function translate_except_expression(e,t,r,n){let i=e.split(",");i=i.map(str_strip);let o=[];for(let e of i){if(e=combine_string_literals(e,r),!t.hasOwnProperty(e))throw new RbqlParsingError(`Unknown field in EXCEPT expression: "${e}"`);o.push(t[e].index)}return o=o.sort(((e,t)=>e-t)),[null===n?null:select_except(n,o),`select_except(record_a, [${o.join(",")}])`]}class HashJoinMap{constructor(e,t){this.max_record_len=0,this.hash_map=new Map,this.record_iterator=e,this.nr=0,1==t.length?(this.key_index=t[0],this.key_indices=null,this.polymorphic_get_key=this.get_single_key):(this.key_index=null,this.key_indices=t,this.polymorphic_get_key=this.get_multi_key)}get_single_key(e,t){if(this.key_index>=t.length)throw new RbqlRuntimeError(`No field with index ${this.key_index+1} at record ${this.nr} in "B" table`);return-1===this.key_index?this.nr:t[this.key_index]}get_multi_key(e,t){let r=[];for(let e of this.key_indices){if(e>=t.length)throw new RbqlRuntimeError(`No field with index ${e+1} at record ${this.nr} in "B" table`);r.push(-1===e?this.nr:t[e])}return JSON.stringify(r)}async build(){for(;;){let e=await this.record_iterator.get_record();if(null===e)break;this.nr+=1;let t=e.length;this.max_record_len=Math.max(this.max_record_len,t);let r=this.polymorphic_get_key(this.nr,e),n=this.hash_map.get(r);void 0===n?this.hash_map.set(r,[[this.nr,t,e]]):n.push([this.nr,t,e])}}get_join_records(e){let t=this.hash_map.get(e);return void 0===t?[]:t}get_warnings(){return this.record_iterator.get_warnings()}}function cleanup_query(e){return e.split("\n").map(strip_comments).filter((e=>e.length)).join(" ").replace(/;+$/g,"")}function remove_redundant_table_name(e){return e=str_strip(e.replace(/ +from +a(?: +|$)/gi," ")),str_strip(e.replace(/^ *update +a +set /gi,"update "))}function select_output_header(e,t,r){if(null===e&&null===t)return null;null===e&&(e=[]),null===t&&(t=[]);let n=[];for(let i of r)null===i?n.push("col"+(n.length+1)):i.is_star?null===i.table_name?n=n.concat(e).concat(t):"a"===i.table_name?n=n.concat(e):"b"===i.table_name&&(n=n.concat(t)):null!==i.column_name?n.push(i.column_name):null!==i.column_index?"a"==i.table_name&&i.column_index<e.length?n.push(e[i.column_index]):"b"==i.table_name&&i.column_index<t.length?n.push(t[i.column_index]):n.push("col"+(n.length+1)):n.push("col"+(n.length+1));return n}function make_inconsistent_num_fields_warning(e,t){let r=Object.keys(t),n=[];for(let e=0;e<r.length;e++){let i=r[e],o=t[i];n.push([o,i])}n.sort((function(e,t){return e[0]-t[0]})),assert(n.length>1);let[i,o]=n[0],[s,a]=n[1],l=`Number of fields in "${e}" table is not consistent: `;return l+=`e.g. record ${i} -> ${o} fields, record ${s} -> ${a} fields`,l}class RBQLInputIterator{constructor(){}stop(){throw new Error("Unable to call the interface method")}async get_variables_map(e){throw new Error("Unable to call the interface method")}async get_record(){throw new Error("Unable to call the interface method")}handle_query_modifier(){}get_warnings(){return[]}async get_header(){return null}}class RBQLOutputWriter{constructor(){}async write(e){throw new Error("Unable to call the interface method")}async finish(){}get_warnings(){return[]}set_header(){}}class RBQLTableRegistry{constructor(){}get_iterator_by_table_id(e){throw new Error("Unable to call the interface method")}get_warnings(){return[]}}class TableIterator extends RBQLInputIterator{constructor(e,t=null,r=!0,n="a"){super(),this.table=e,this.column_names=t,this.normalize_column_names=r,this.variable_prefix=n,this.nr=0,this.fields_info=new Object,this.stopped=!1}stop(){this.stopped=!0}async get_variables_map(e){let t=new Object;if(parse_basic_variables(e,this.variable_prefix,t),parse_array_variables(e,this.variable_prefix,t),null!==this.column_names){if(this.table.length&&this.column_names.length!=this.table[0].length)throw new RbqlIOHandlingError("List of column names and table records have different lengths");this.normalize_column_names?(parse_dictionary_variables(e,this.variable_prefix,this.column_names,t),parse_attribute_variables(e,this.variable_prefix,this.column_names,"column names list",t)):map_variables_directly(e,this.column_names,t)}return t}async get_record(){if(this.stopped)return null;if(this.nr>=this.table.length)return null;let e=this.table[this.nr];this.nr+=1;let t=e.length;return this.fields_info.hasOwnProperty(t)||(this.fields_info[t]=this.nr),e}get_warnings(){return Object.keys(this.fields_info).length>1?[make_inconsistent_num_fields_warning("input",this.fields_info)]:[]}async get_header(){return this.column_names}}class TableWriter extends RBQLOutputWriter{constructor(e){super(),this.table=e,this.header=null}async write(e){return this.table.push(e),!0}set_header(e){this.header=e}}class SingleTableRegistry extends RBQLTableRegistry{constructor(e,t=null,r=!0,n="b"){super(),this.table=e,this.table_id=n,this.column_names=t,this.normalize_column_names=r}get_iterator_by_table_id(e){if(e.toLowerCase()!==this.table_id)throw new RbqlIOHandlingError(`Unable to find join table: "${e}"`);return new TableIterator(this.table,this.column_names,this.normalize_column_names,"b")}}async function shallow_parse_input_query(e,t,r,n){e=cleanup_query(e);var[i,o]=separate_string_literals(e),s=separate_actions(i=remove_redundant_table_name(i));s.hasOwnProperty(WITH)&&t.handle_query_modifier(s[WITH]);var a=await t.get_variables_map(e);if(s.hasOwnProperty(ORDER_BY)&&s.hasOwnProperty(UPDATE))throw new RbqlParsingError('"ORDER BY" is not allowed in "UPDATE" queries');if(s.hasOwnProperty(GROUP_BY)){if(s.hasOwnProperty(ORDER_BY)||s.hasOwnProperty(UPDATE))throw new RbqlParsingError('"ORDER BY", "UPDATE" and "DISTINCT" keywords are not allowed in aggregate queries');n.aggregation_key_expression="["+combine_string_literals(s[GROUP_BY].text,o)+"]"}let l=null,u=null;if(s.hasOwnProperty(JOIN)){var[c,_]=parse_join_expression(s[JOIN].text);if(null===r)throw new RbqlParsingError("JOIN operations are not supported by the application");let t=r.get_iterator_by_table_id(c);if(!t)throw new RbqlParsingError(`Unable to find join table: "${c}"`);s.hasOwnProperty(WITH)&&t.handle_query_modifier(s[WITH]),l=await t.get_variables_map(e),u=await t.get_header();let[i,p]=resolve_join_variables(a,l,_,o),f={JOIN:InnerJoiner,"INNER JOIN":InnerJoiner,"LEFT JOIN":LeftJoiner,"LEFT OUTER JOIN":LeftJoiner,"STRICT LEFT JOIN":StrictLeftJoiner}[s[JOIN].join_subtype];n.lhs_join_var_expression=1==i.length?i[0]:"JSON.stringify(["+i.join(",")+"])",n.join_map_impl=new HashJoinMap(t,p),await n.join_map_impl.build(),n.join_map=new f(n.join_map_impl)}if(n.variables_init_code=combine_string_literals(generate_init_statements(i,a,l," ".repeat(4)),o),s.hasOwnProperty(WHERE)){var p=s[WHERE].text;if(/[^><!=]=[^=]/.exec(p))throw new RbqlParsingError('Assignments "=" are not allowed in "WHERE" expressions. For equality test use "==" or "==="');n.where_expression=combine_string_literals(p,o)}let f=await t.get_header();if(s.hasOwnProperty(UPDATE)){var h=translate_update_expression(s[UPDATE].text,a,o," ".repeat(8));n.update_expressions=combine_string_literals(h,o),n.writer.set_header(f)}if(s.hasOwnProperty(SELECT)){if(n.top_count=find_top(s),s.hasOwnProperty(EXCEPT)){let[e,t]=translate_except_expression(s[EXCEPT].text,a,o,f);n.select_expression=t,n.writer.set_header(e)}else{let[e,t]=translate_select_expression(s[SELECT].text);n.select_expression=combine_string_literals(e,o);let r=select_output_header(f,u,adhoc_parse_select_expression_to_column_infos(t,o));n.writer.set_header(r)}n.writer=new TopWriter(n.writer,n.top_count),s[SELECT].hasOwnProperty("distinct_count")?n.writer=new UniqCountWriter(n.writer):s[SELECT].hasOwnProperty("distinct")&&(n.writer=new UniqWriter(n.writer))}if(s.hasOwnProperty(ORDER_BY)){n.sort_key_expression=combine_string_literals(s[ORDER_BY].text,o);let e=s[ORDER_BY].reverse;n.writer=new SortedWriter(n.writer,e)}}async function query(e,t,r,n,i=null,o=""){query_context=new RBQLContext(e,t,r,o),await shallow_parse_input_query(e,t,i,query_context),await compile_and_run(query_context),await query_context.writer.finish(),n.push(...t.get_warnings()),query_context.join_map_impl&&n.push(...query_context.join_map_impl.get_warnings()),n.push(...r.get_warnings())}async function query_table(e,t,r,n,i=null,o=null,s=null,a=null,l=!0,u=""){l||null===o||null===s||ensure_no_ambiguous_variables(e,o,s);let c=new TableIterator(t,o,l),_=new TableWriter(r),p=null===i?null:new SingleTableRegistry(i,s,l);if(await query(e,c,_,n,p,u),null!==a&&(assert(0==a.length,"`output_column_names` param must be an empty list or null"),null!==_.header))for(let e of _.header)a.push(e)}function exception_to_error_info(e){let t={RbqlRuntimeError:"query execution",RbqlParsingError:"query parsing",SyntaxError:"JS syntax error",RbqlIOHandlingError:"IO handling"},r="unexpected";return e.constructor&&e.constructor.name&&t.hasOwnProperty(e.constructor.name)&&(r=t[e.constructor.name]),[r,e.hasOwnProperty("message")?e.message:String(e)]}exports.query=query,exports.query_table=query_table,exports.RBQLInputIterator=RBQLInputIterator,exports.RBQLOutputWriter=RBQLOutputWriter,exports.RBQLTableRegistry=RBQLTableRegistry,exports.version=RBQL_VERSION,exports.TableIterator=TableIterator,exports.TableWriter=TableWriter,exports.SingleTableRegistry=SingleTableRegistry,exports.exception_to_error_info=exception_to_error_info,exports.parse_basic_variables=parse_basic_variables,exports.parse_array_variables=parse_array_variables,exports.parse_dictionary_variables=parse_dictionary_variables,exports.parse_attribute_variables=parse_attribute_variables,exports.get_all_matches=get_all_matches,exports.strip_comments=strip_comments,exports.separate_actions=separate_actions,exports.separate_string_literals=separate_string_literals,exports.combine_string_literals=combine_string_literals,exports.parse_join_expression=parse_join_expression,exports.resolve_join_variables=resolve_join_variables,exports.translate_update_expression=translate_update_expression,exports.translate_select_expression=translate_select_expression,exports.translate_except_expression=translate_except_expression,exports.like_to_regex=like_to_regex,exports.adhoc_parse_select_expression_to_column_infos=adhoc_parse_select_expression_to_column_infos,exports.replace_star_count=replace_star_count,exports.replace_star_vars_for_header_parsing=replace_star_vars_for_header_parsing,exports.select_output_header=select_output_header})(exports)},371:(e,t,r)=>{var n=r(4155);const i=r(1606),o=r(4704),s=r(9426),a=r(9539),l=r(6987),u=r(8594),c="Unable to decode input table as UTF-8. Use binary (latin-1) encoding instead";class _ extends Error{}class p extends Error{}function f(e,t=null){if(!e)throw t||(t="Assertion error"),new p(t)}function h(e){return/^[\x00-\x7F]*$/.test(e)}function d(e){return i.readFileSync(e,"utf-8")}function g(e,t){var r,n="~"===(r=t).charAt(0)?s.join(o.homedir(),r.slice(1)):r;if(i.existsSync(n))return n;if(e&&!s.isAbsolute(n)&&(n=s.join(e,n),i.existsSync(n)))return n;var a=function(e,t){for(var r=function(e){var t=null;try{t=i.readFileSync(e,"utf-8")}catch(e){return[]}for(var r=t.split("\n"),n=[],o=0;o<r.length;o++)if(r[o]){var s=r[o].split("\t");n.push(s)}return n}(e),n=0;n<r.length;n++)if(r[n].length&&r[n][0]==t)return r[n];return null}(s.join(o.homedir(),".rbql_table_names"),t);return a&&a.length>1&&i.existsSync(a[1])?a[1]:null}class y{constructor(){this.push_stack=[],this.pull_stack=[]}enqueue(e){this.push_stack.push(e)}dequeue(){if(!this.pull_stack.length){if(!this.push_stack.length)return null;this.pull_stack=this.push_stack,this.pull_stack.reverse(),this.push_stack=[]}return this.pull_stack.pop()}}class m extends l.RBQLInputIterator{constructor(e,t,r,n,i,o=!1,s=null,l="input",u="a"){super(),this.stream=e,this.csv_path=t,f(null===this.stream!=(null===this.csv_path)),this.encoding=r,this.delim=n,this.policy=i,this.has_header=o,this.first_record=null,this.first_record_should_be_emitted=!o,this.header_preread_complete=!1,this.table_name=l,this.variable_prefix=u,this.comment_prefix=null!==s&&s.length?s:null,this.decoder=null,"utf-8"==r&&null===this.csv_path&&(this.decoder=new a.TextDecoder(r,{fatal:!0,stream:!0})),this.input_exhausted=!1,this.started=!1,this.utf8_bom_removed=!1,this.first_defective_line=null,this.fields_info=new Object,this.NR=0,this.NL=0,this.rfc_line_buffer=[],this.partially_decoded_line="",this.partially_decoded_line_ends_with_cr=!1,this.resolve_current_record=null,this.reject_current_record=null,this.current_exception=null,this.produced_records_queue=new y,this.process_line_polymorphic="quoted_rfc"==i?this.process_partial_rfc_record_line:this.process_record_line}handle_query_modifier(e){-1!=["header","headers"].indexOf(e)&&(this.has_header=!0,this.first_record_should_be_emitted=!1),-1!=["noheader","noheaders"].indexOf(e)&&(this.has_header=!1,this.first_record_should_be_emitted=!0)}reset_external_callbacks(){this.reject_current_record=null,this.resolve_current_record=null}try_propagate_exception(){if(this.current_exception&&this.reject_current_record){let e=this.reject_current_record,t=this.current_exception;this.reset_external_callbacks(),this.current_exception=null,e(t)}}store_or_propagate_exception(e){null===this.current_exception&&(this.current_exception=e),this.try_propagate_exception()}async preread_first_record(){this.header_preread_complete||(this.first_record=await this.get_record(),this.header_preread_complete=!0,null!==this.first_record&&(this.stream&&this.stream.pause(),this.first_record=this.first_record.slice()))}async get_variables_map(e){let t=new Object;return l.parse_basic_variables(e,this.variable_prefix,t),l.parse_array_variables(e,this.variable_prefix,t),await this.preread_first_record(),this.has_header&&this.first_record&&(l.parse_attribute_variables(e,this.variable_prefix,this.first_record,"CSV header line",t),l.parse_dictionary_variables(e,this.variable_prefix,this.first_record,t)),t}async get_header(){return await this.preread_first_record(),this.has_header?this.first_record:null}try_resolve_next_record(){if(this.try_propagate_exception(),null===this.resolve_current_record)return;let e=null;if(this.first_record_should_be_emitted&&this.header_preread_complete?(this.first_record_should_be_emitted=!1,e=this.first_record):e=this.produced_records_queue.dequeue(),null===e&&!this.input_exhausted)return;let t=this.resolve_current_record;this.reset_external_callbacks(),t(e)}async get_record(){this.started||await this.start(),this.stream&&this.stream.isPaused()&&this.stream.resume();let e=this,t=new Promise((function(t,r){e.resolve_current_record=t,e.reject_current_record=r}));return this.try_resolve_next_record(),t}async get_all_records(e=null){let t=[];for(;;){let r=await this.get_record();if(null===r)break;if(t.push(r),e&&t.length>=e){this.stop();break}}return t}process_record_line(e){if(null!==this.comment_prefix&&e.startsWith(this.comment_prefix))return;this.NR+=1;var[t,r]=u.smart_split(e,this.delim,this.policy,!1);r&&null===this.first_defective_line&&(this.first_defective_line=this.NL,"quoted_rfc"==this.policy&&this.store_or_propagate_exception(new _(`Inconsistent double quote escaping in ${this.table_name} table at record ${this.NR}, line ${this.NL}`)));let n=t.length;this.fields_info.hasOwnProperty(n)||(this.fields_info[n]=this.NR),this.produced_records_queue.enqueue(t),this.try_resolve_next_record()}process_partial_rfc_record_line(e){let t=u.accumulate_rfc_line_into_record(this.rfc_line_buffer,e,this.comment_prefix);null!==t&&this.process_record_line(t)}process_line(e){if(this.NL+=1,1===this.NL){var t=function(e,t){return"binary"==t&&e.length>=3&&239===e.charCodeAt(0)&&187===e.charCodeAt(1)&&191===e.charCodeAt(2)?e.substring(3):"utf-8"==t&&e.length>=1&&65279===e.charCodeAt(0)?e.substring(1):e}(e,this.encoding);t!=e&&(e=t,this.utf8_bom_removed=!0)}this.process_line_polymorphic(e)}process_data_stream_chunk(e){let t=null;if(this.decoder)try{t=this.decoder.decode(e)}catch(e){return void(e instanceof TypeError?this.store_or_propagate_exception(new _(c)):this.store_or_propagate_exception(e))}else t=e.toString(this.encoding);let r=t.length&&"\n"==t[0]&&this.partially_decoded_line_ends_with_cr?1:0;this.partially_decoded_line_ends_with_cr=t.length&&"\r"==t[t.length-1];let n=u.split_lines(t);n[0]=this.partially_decoded_line+n[0],f(0==r||0==n[0].length),this.partially_decoded_line=n.pop();for(let e=r;e<n.length;e++)this.process_line(n[e])}process_data_bulk(e){let t=e.toString(this.encoding);if("utf-8"==this.encoding){let r=Buffer.from(t,"utf-8");if(0!=Buffer.compare(e,r))return void this.store_or_propagate_exception(new _(c))}let r=u.split_lines(t);r.length&&0==r[r.length-1].length&&r.pop();for(let e=0;e<r.length;e++)this.process_line(r[e]);this.rfc_line_buffer.length>0&&this.process_record_line(this.rfc_line_buffer.join("\n")),this.input_exhausted=!0,this.try_resolve_next_record()}process_data_stream_end(){if(this.input_exhausted=!0,this.partially_decoded_line.length){let e=this.partially_decoded_line;this.partially_decoded_line="",this.process_line(e)}this.rfc_line_buffer.length>0&&this.process_record_line(this.rfc_line_buffer.join("\n")),this.try_resolve_next_record()}stop(){this.stream&&this.stream.destroy()}async start(){if(!this.started){if(this.started=!0,!this.stream){let e=this;return new Promise((function(t,r){i.readFile(e.csv_path,((n,i)=>{n?r(n):(e.process_data_bulk(i),t())}))}))}this.stream.on("data",(e=>{this.process_data_stream_chunk(e)})),this.stream.on("end",(()=>{this.process_data_stream_end()}))}}get_warnings(){let e=[];return null!==this.first_defective_line&&e.push(`Inconsistent double quote escaping in ${this.table_name} table. E.g. at line ${this.first_defective_line}`),this.utf8_bom_removed&&e.push(`UTF-8 Byte Order Mark (BOM) was found and skipped in ${this.table_name} table`),Object.keys(this.fields_info).length>1&&e.push(function(e,t){let r=Object.keys(t),n=[];for(let e=0;e<r.length;e++){let i=r[e],o=t[i];n.push([o,i])}n.sort((function(e,t){return e[0]-t[0]})),f(n.length>1);let[i,o]=n[0],[s,a]=n[1],l=`Number of fields in "${e}" table is not consistent: `;return l+=`e.g. record ${i} -> ${o} fields, record ${s} -> ${a} fields`,l}(this.table_name,this.fields_info)),e}}class b extends l.RBQLOutputWriter{constructor(e,t,r,n,i,o="\n"){if(super(),this.stream=e,this.encoding=r,r&&this.stream.setDefaultEncoding(r),this.stream.on("error",(e=>{this.store_first_error(e)})),this.delim=n,this.policy=i,this.line_separator=o,this.sub_array_delim="|"==n?";":"|",this.close_stream_on_finish=t,this.null_in_output=!1,this.delim_in_simple_output=!1,this.header_len=null,this.first_error=null,"simple"==i)this.polymorphic_join=this.simple_join;else if("quoted"==i)this.polymorphic_join=this.quoted_join;else if("quoted_rfc"==i)this.polymorphic_join=this.quoted_join_rfc;else if("monocolumn"==i)this.polymorphic_join=this.mono_join;else{if("whitespace"!=i)throw new _("Unknown output csv policy");this.polymorphic_join=this.simple_join}}store_first_error(e){null===this.first_error&&(this.first_error=e)}set_header(e){null!==e&&(this.header_len=e.length,this.write(e))}quoted_join(e){let t=this.delim;return e.map((function(e){return u.quote_field(String(e),t)})).join(this.delim)}quoted_join_rfc(e){let t=this.delim;return e.map((function(e){return u.rfc_quote_field(String(e),t)})).join(this.delim)}mono_join(e){if(e.length>1)throw new _('Unable to use "Monocolumn" output format: some records have more than one field');return e[0]}simple_join(e){var t=e.join(this.delim);return-1!=e.join("").indexOf(this.delim)&&(this.delim_in_simple_output=!0),t}normalize_fields(e){for(var t=0;t<e.length;t++)null==e[t]?(this.null_in_output=!0,e[t]=""):Array.isArray(e[t])&&(this.normalize_fields(e[t]),e[t]=e[t].join(this.sub_array_delim))}async write(e){if(null!==this.header_len&&e.length!=this.header_len)throw new _(`Inconsistent number of columns in output header and the current record: ${this.header_len} != ${e.length}`);this.normalize_fields(e),this.stream.write(this.polymorphic_join(e)),this.stream.write(this.line_separator);let t=this.first_error;return new Promise((function(e,r){null!==t?r(t):e(!0)}))}_write_all(e){for(let t=0;t<e.length;t++)this.write(e[t])}async finish(){let e=this.close_stream_on_finish,t=this.stream,r=this.encoding,n=this.first_error;return new Promise((function(i,o){null!==n&&o(n),e?t.end("",r,(()=>{i()})):setTimeout((()=>{i()}),0)}))}get_warnings(){let e=[];return this.null_in_output&&e.push("null values in output were replaced by empty strings"),this.delim_in_simple_output&&e.push("Some output fields contain separator"),e}}class w extends l.RBQLTableRegistry{constructor(e,t,r,n,i=!1,o=null,s=null){super(),this.input_file_dir=e,this.delim=t,this.policy=r,this.encoding=n,this.has_header=i,this.comment_prefix=o,this.stream=null,this.record_iterator=null,this.options=s,this.bulk_input_path=null,this.table_path=null}get_iterator_by_table_id(e){if(this.table_path=g(this.input_file_dir,e),null===this.table_path)throw new _(`Unable to find join table "${e}"`);return this.options&&this.options.bulk_read?this.bulk_input_path=this.table_path:this.stream=i.createReadStream(this.table_path),this.record_iterator=new m(this.stream,this.bulk_input_path,this.encoding,this.delim,this.policy,this.has_header,this.comment_prefix,e,"b"),this.record_iterator}get_warnings(e){this.record_iterator&&this.has_header&&e.push(`The first record in JOIN file ${s.basename(this.table_path)} was also treated as header (and skipped)`)}}e.exports.is_ascii=h,e.exports.CSVRecordIterator=m,e.exports.CSVWriter=b,e.exports.FileSystemCSVRegistry=w,e.exports.interpret_named_csv_format=function(e){if("monocolumn"==(e=e.toLowerCase()))return["","monocolumn"];if("csv"==e)return[",","quoted"];if("tsv"==e)return["\t","simple"];throw new _(`Unknown format name: "${e}"`)},e.exports.read_user_init_code=d,e.exports.query_csv=async function(e,t,r,a,u,c,p,f,g,y=!1,x=null,v="",E=null){let O=null,S=null;E&&E.bulk_read&&t?S=t:O=null===t?n.stdin:i.createReadStream(t);let[R,A]=null===u?[n.stdout,!1]:[i.createWriteStream(u),!0];if('"'==r&&"quoted"==a)throw new _('Double quote delimiter is incompatible with "quoted" policy');if("latin-1"==f&&(f="binary"),!h(e)&&"binary"==f)throw new _("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");if(!(h(r)&&h(c)||"binary"!=f))throw new _("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");let q=s.join(o.homedir(),".rbql_init_source.js");""==v&&i.existsSync(q)&&(v=d(q));let P=t?s.dirname(t):null,j=new w(P,r,a,f,y,x,E),T=new m(O,S,f,r,a,y,x),k=new b(R,A,f,c,p);await l.query(e,T,k,g,j,v),j.get_warnings(g)},e.exports.RecordQueue=y,e.exports.exception_to_error_info=l.exception_to_error_info},9496:e=>{"use strict";e.exports=require("vscode")},1606:()=>{},4704:()=>{},9426:()=>{},2667:()=>{},5174:()=>{},4949:()=>{},7857:()=>{},8391:()=>{},3083:(e,t,r)=>{"use strict";var n=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],i="undefined"==typeof globalThis?r.g:globalThis;e.exports=function(){for(var e=[],t=0;t<n.length;t++)"function"==typeof i[n[t]]&&(e[e.length]=n[t]);return e}},882:(e,t,r)=>{"use strict";var n=r(210)("%Object.getOwnPropertyDescriptor%",!0);if(n)try{n([],"length")}catch(e){n=null}e.exports=n}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var __webpack_exports__={};(()=>{var e=__webpack_exports__;const t=__webpack_require__(9496),r=__webpack_require__(7857),n=__webpack_require__(5174),i=__webpack_require__(4949),o=__webpack_require__(2667),s=__webpack_require__(8594);var a=null,l=null;function u(){return null===l&&(l=__webpack_require__(45)),l}const c=void 0===i.homedir,_=100,p="vscode_rbql_scratch";let f=null;var h=new Map,d=new Set,g=new Set,y=new Map,m=new Map,b=null,w=null,x=null,v=null,E=null;let O=null;var S=null,R=new Map,A=null,q=null,P=null,j=null,T=null,k=null;const I={csv:[",","quoted"],tsv:["\t","simple"],"csv (semicolon)":[";","quoted"],"csv (pipe)":["|","simple"],"csv (tilde)":["~","simple"],"csv (caret)":["^","simple"],"csv (colon)":[":","simple"],"csv (double quote)":['"',"simple"],"csv (equals)":["=","simple"],"csv (dot)":[".","simple"],"csv (whitespace)":[" ","whitespace"],"csv (hyphen)":["-","simple"]};let N={"rbql_client.js":null,"contrib/textarea-caret-position/index.js":null,"rbql_suggest.js":null,"rbql_logo.svg":null,"rbql_client.html":null,"rbql mock/rbql_mock.py":null,"rbql_core/vscode_rbql.py":null};function L(e){var r=t.window;r&&r.showErrorMessage(e)}function C(e){return new Promise((t=>setTimeout(t,e)))}async function U(){await C(0)}function M(e){for(let t in I)if(I.hasOwnProperty(t)&&I[t][0]==e)return t;return null}function B(e,t){if(q){var r=q.get(e);if(null!=r)return r}return t}async function $(e,t){return!(!q||!e||(await q.update(e,t),0))}function D(e,t,r){let n=[];for(let i=t;i<r&&i<e.lineCount;i++)n.push(e.lineAt(i).text);return n.join("\n")}async function F(e,r,n){let i=new t.Range(0,0,r.lineCount,0),o=r.validateRange(i);await e.edit((e=>e.replace(o,n)))}function W(e,t){let r=e.input_document,n=e.delim,i=e.policy;e.requested_start_record=Math.max(e.requested_start_record,0);let o=[];if(e.enable_rfc_newlines){let a=e.requested_start_record+_;u().populate_optimistic_rfc_csv_record_map(r,a,e.rfc_record_map),e.requested_start_record=Math.max(0,Math.min(e.requested_start_record,e.rfc_record_map.length-_));for(let a=e.requested_start_record;a<e.rfc_record_map.length&&o.length<_;a++){let[l,u]=e.rfc_record_map[a],c=D(r,l,u),[_,p]=s.smart_split(c,n,i,!1);if(p)return void(t.preview_sampling_error=`Double quotes are not consistent in record ${a+1} which starts at line ${l+1}`);o.push(_)}}else{let t=r.lineCount;""==r.lineAt(Math.max(t-1,0)).text&&(t-=1),e.requested_start_record=Math.max(0,Math.min(e.requested_start_record,t-_));for(let a=e.requested_start_record;a<t&&o.length<_;a++){let e=r.lineAt(a).text,t=s.smart_split(e,n,i,!1)[0];o.push(t)}}for(let e=0;e<o.length;e++){let t=o[e];for(let e=0;e<t.length;e++)t[e].length>250&&(t[e]=t[e].substr(0,250)+"###UI_STRING_TRIM_MARKER###")}t.preview_records=o,t.start_record_zero_based=e.requested_start_record}function J(e){return"rbql_header:"+e}function Q(e){return"enable_rfc_newlines:"+e}function z(e){return"rbql_with_headers:"+e}function V(e,r){const n=t.workspace.getConfiguration("rainbow_csv");return n?n.get(e):r}function G(e,t,r){let n=V("comment_prefix",""),i=u().get_header_line(e,n);return s.smart_split(i,t,r,!1)[0]}function H(e,t,r){var n=e.fileName;if(n){let e=B(J(n),null);if(e)return JSON.parse(e)}return G(e,t,r)}function Y(e,t){if(!e.length)return null;for(var r=0,n=e[r].length+1;t>n&&r+1<e.length;)n=n+e[r+=1].length+1;return r}function Z(){var e=t.window;return e&&e.activeTextEditor||null}function X(e=null){return e||(e=Z()),e&&e.document||null}function K(){let e=[b,w,v,E,x];for(let t=0;t<e.length;t++)e[t]&&e[t].hide()}function ee(e=null){e||(e=X()),O=e;var n=e?e.fileName:null;if(e&&n){if(!n.endsWith(".git")){K();var i=e.languageId;I.hasOwnProperty(i)&&(function(e,r){let n=`${e}.${r}`;if(h.has(n)){var i=h.get(n);b||(b=t.window.createStatusBarItem(t.StatusBarAlignment.Left)),b.text="CSVLint","OK"===i?b.color="#62f442":"Processing..."==i?b.color="#A0A0A0":-1!=i.indexOf("spaces detected")?b.color="#ffff28":b.color="#f44242",b.tooltip=i+"\nClick to recheck",b.command="rainbow-csv.CSVLint",b.show()}}(n,i),w||(w=t.window.createStatusBarItem(t.StatusBarAlignment.Left)),w.text="Query",w.tooltip="Click to run SQL-like RBQL query",w.command="rainbow-csv.RBQL",w.show(),function(e){x||(x=t.window.createStatusBarItem(t.StatusBarAlignment.Left)),d.has(e)?(x.text="Shrink",x.tooltip="Click to shrink table (Then you can click again to align)",x.command="rainbow-csv.Shrink"):(x.text="Align",x.tooltip="Click to align table (Then you can click again to shrink)",x.command="rainbow-csv.Align"),x.show()}(n),v||(v=t.window.createStatusBarItem(t.StatusBarAlignment.Left)),v.text="Rainbow OFF",v.tooltip="Click to restore original file type and syntax",v.command="rainbow-csv.RainbowSeparatorOff",v.show(),function(e){let n=m.get(e.toLowerCase());if(!n||-1!=n.indexOf(p))return;let i=r.basename(n);E||(E=t.window.createStatusBarItem(t.StatusBarAlignment.Left)),E.text="Copy Back",E.tooltip=`Copy to parent table: ${i}`,E.command="rainbow-csv.CopyBack",E.show()}(n))}}else K()}function te(e,t){if(e||(e=X()),!e)return null;var r=e.fileName;if(!r)return null;var n=e.languageId;if(!I.hasOwnProperty(n))return null;let i=`${r}.${n}`;if(!t){if(h.has(i))return null;if(!V("enable_auto_csv_lint",!1))return null}h.set(i,"Processing..."),ee(e);let[o,a]=I[n];var l=function(e,t,r){let n=V("comment_prefix",""),i=V("csv_lint_detect_trailing_spaces",!1),o=null;for(var a=e.lineCount,l=null,u=0;u<a;u++){var c=e.lineAt(u).text;if(u+1==a&&!c)break;if(!n||!c.startsWith(n)){var _=s.smart_split(c,t,r,!0);if(_[1])return"Error. Line "+(u+1)+" has formatting error: double quote chars are not consistent";if(i&&null===o){let e=_[0];for(let t=0;t<e.length;t++)!e[t].length||" "!=e[t].charAt(0)&&" "!=e[t].slice(-1)||(o=u)}if(l||(l=_[0].length),l!=_[0].length)return"Error. Number of fields is not consistent: e.g. line 1 has "+l+" fields, and line "+(u+1)+" has "+_[0].length+" fields."}}return null!==o?"Leading/Trailing spaces detected: e.g. at line "+(o+1)+'. Run "Shrink" command to remove them.':"OK"}(e,o,a);return h.set(i,l),l}async function re(){let e=te(null,!0);return await C(500),ee(),e}async function ne(e){return e&&e.check_initialization_state?{initialized:null!==q,lazy_loaded:null!==l}:e&&e.check_last_rbql_report?T:e&&e.check_last_rbql_warnings?{warnings:k}:null}async function ie(e,r){let n=M(S.output_delim);var i=t.window;if(i){try{await i.showTextDocument(e)}catch(e){return void L("Unable to open RBQL result document")}n&&e.language_id!=n&&(console.log("changing RBQL result language "+e.language_id+" -> "+n),await t.languages.setTextDocumentLanguage(e,n)),await async function(e){if(k=[],e&&e.length){var r=t.window;if(!r)return null;for(var n=0;n<e.length;n++)r.showWarningMessage("RBQL warning: "+e[n]);k=e}}(r)}}function oe(e,t,r,n){var i=o.spawn(e,t,{windowsHide:!0}),s="",a="";i.stdout.on("data",(function(e){s+=e.toString()})),i.stderr.on("data",(function(e){a+=e.toString()})),i.on("close",(function(e){r.process_reported||(r.process_reported=!0,n(e,s,a))})),i.on("error",(function(e){var t=e?e.name+": "+e.message:"";r.process_reported||(r.process_reported=!0,n(1,"","Something went wrong. Make sure you have python installed and added to PATH variable in your OS. Or you can use it with JavaScript instead - it should work out of the box\nDetails:\n"+t))}))}async function se(e,r,n,i,o,s){let a=i,l=null,u=null,c=[];if(n||!a||o)l="Integration",u=o||"empty error";else try{let e=JSON.parse(a);e.hasOwnProperty("error_type")&&(l=e.error_type),e.hasOwnProperty("error_msg")&&(u=e.error_msg),e.hasOwnProperty("warnings")&&(c=e.warnings)}catch(e){l="Integration",u="Unable to parse JSON report"}if(s(l,u),l||u)return;g.add(r),m.set(r.toLowerCase(),e);let _=await t.workspace.openTextDocument(r);await ie(_,c)}function ae(e){return e&&-1!=e.indexOf(p)?p:e}function le(e){var t=e.languageId;return I.hasOwnProperty(t)?I[t]:["monocolumn","monocolumn"]}async function ue(){let e=Z();if(!e)return;var t=X(e);if(!t)return;var r=le(t),n=r[0],i=r[1];if("monocolumn"==i)return void L("Unable to set header line: no separator specified");let o=t.fileName;if(!o)return void L("Unable to set header line for non-file documents");let a=e.selection,l=t.lineAt(a.start.line).text,u=s.smart_split(l,n,i,!1)[0];await $(J(o),JSON.stringify(u))}async function ce(){let e=Z();if(!e)return;var r=X(e);if(!r)return;let n=r.languageId,i=e.selection;if(!i)return void L("Selection is empty");if(i.start.line!=i.end.line||i.start.character+1!=i.end.character)return void L("Selection must contain exactly one separator character");let o=M(r.lineAt(i.start.line).text.charAt(i.start.character));if(!o)return void L("Selected separator is not supported");let s=await t.languages.setTextDocumentLanguage(r,o);y.set(s.fileName,n),te(s,!1),ee(s)}async function _e(){var e=X();if(!e)return;let r=e.fileName;g.add(r);let n="plaintext";if(y.has(r)&&(n=y.get(r)),!n||n==e.languageId)return void L("Unable to restore original language");let i=await t.languages.setTextDocumentLanguage(e,n);y.delete(r),ee(i)}async function pe(){if(c)return void L("This command is currently unavailable in web mode.");var e=X();if(!e)return;let r=e.fileName;if(!r)return void L("Unable to use this document as join table");let n=await t.window.showInputBox({prompt:"Input table name to use in RBQL JOIN expressions instead of table path",value:"b"});n&&$(u().make_table_name_key(n),r)}async function fe(){var e=X(),r=le(e),n=r[0],i=r[1],o=e.fileName;if(!o)return void L("Unable to edit column names for non-file documents");if("monocolumn"==i)return void L("Unable to set virtual header: no separator specified");var a=function(e,t){return e.map((function(e){return function(e,t){return-1!=e.indexOf('"')||-1!=e.indexOf(t)?'"'+e.replace(/"/g,'""')+'"':e}(e,t)})).join(t)}(H(e,n,i),n),l={prompt:"Adjust column names displayed in hover tooltips. Actual header line and file content won't be affected.",value:a};let u=await t.window.showInputBox(l);if(!u)return;let c=s.smart_split(u,n,i,!1)[0];await $(J(o),JSON.stringify(c))}async function he(e){let r=Z();if(!r||!r.selection)return;let n=r.document;if(!n)return;let i=le(n),o=i[0],a=i[1],l=V("comment_prefix",""),u=r.selection.active,c=u.line,_=u.character,p=n.lineAt(c).text,f=s.smart_split(p,o,a,!0),h=f[0],d=f[1],g=Y(h,_+1),y=[],m=n.lineCount;if(m>=1e4)L("Multicursor column edit works only for files smaller than 10000 lines.");else{for(let r=0;r<m;r++){let i=n.lineAt(r).text;if(r+1==m&&!i)break;if(l&&i.startsWith(l))continue;let u=s.smart_split(i,o,a,!0),c=u[0];if(d=d||u[1],g>=c.length)return void L(`Line ${r+1} doesn't have field number ${g+1}`);let _=c.slice(0,g).join("").length+g,p=c.slice(0,g+1).join("").length+g;if("ce_before"==e&&"quoted"==a&&-1!=i.substring(_-2,_+2).indexOf('"'))return void L(`Accidental data corruption prevention: Cursor at line ${r+1} will not be set: a double quote is in proximity.`);if("ce_after"==e&&"quoted"==a&&-1!=i.substring(p-2,p+2).indexOf('"'))return void L(`Accidental data corruption prevention: Cursor at line ${r+1} will not be set: a double quote is in proximity.`);if("ce_select"==e&&_==p)return void L(`Accidental data corruption prevention: The column can not be selected: field ${g+1} at line ${r+1} is empty.`);let f=new t.Position(r,_),h=new t.Position(r,p);"ce_before"==e&&y.push(new t.Selection(f,f)),"ce_after"==e&&y.push(new t.Selection(h,h)),"ce_select"==e&&y.push(new t.Selection(f,h))}r.selections=y,d&&t.window.showWarningMessage("Some lines have quoting issues: cursors positioning may be incorrect."),await t.window.showTextDocument(n)}}async function de(){let e=Z(),r=X(e);if(!r)return;let n=r.languageId;if(!I.hasOwnProperty(n))return;let[i,o]=I[n],s=V("comment_prefix",""),a={location:t.ProgressLocation.Window,title:"Rainbow CSV"};await t.window.withProgress(a,(async n=>{n.report({message:"Preparing"}),await U();let[a,l]=u().shrink_columns(r,i,o,s);l?L(`Unable to shrink: Inconsistent double quotes at line ${l}`):(d.delete(r.fileName),ee(r),null!==a?(n.report({message:"Shrinking columns"}),await U(),await F(e,r,a)):t.window.showWarningMessage("No trailing whitespaces found, skipping"))}))}async function ge(){let e=Z(),r=X(e);if(!r)return;let n=r.languageId;if(!I.hasOwnProperty(n))return;let[i,o]=I[n],s=V("comment_prefix",""),a={location:t.ProgressLocation.Window,title:"Rainbow CSV"};await t.window.withProgress(a,(async n=>{n.report({message:"Calculating column statistics"}),await U();let[a,l]=u().calc_column_stats(r,i,o,s);l?L(`Unable to align: Inconsistent double quotes at line ${l}`):(a=u().adjust_column_stats(a),null!==a?(n.report({message:"Preparing final alignment"}),await U(),aligned_doc_text=u().align_columns(r,i,o,s,a),d.add(r.fileName),ee(r),null!==aligned_doc_text?(n.report({message:"Aligning columns"}),await U(),await F(e,r,aligned_doc_text)):t.window.showWarningMessage("Table is already aligned, skipping")):L("Unable to allign: Internal Rainbow CSV Error"))}))}async function ye(){if(c)return void L("This command is currently unavailable in web mode.");let e=X();if(!e)return;let r=e.fileName,n=m.get(r.toLowerCase());if(!n)return;let i=await t.workspace.openTextDocument(n),o=await t.window.showTextDocument(i);await async function(e,t){let r=e.getText(),n=X(t);n&&await F(t,n,r)}(e,o)}async function me(e,o,l=null){let p=o.msg_type,f=async function(t,r){let n={msg_type:"rbql_report"};t&&(n.error_type=t),r&&(n.error_msg=r),T=n,await e.postMessage(n)};if("handshake"==p){var h={msg_type:"handshake",backend_language:B("rbql_backend_language","js"),encoding:B("rbql_encoding","utf-8")};W(S,h);let t=ae(S.input_document_path);R.has(t)&&(h.last_query=R.get(t));let r=B("rbql_query_history",[]);h.query_history=r,h.policy=S.policy,h.enable_rfc_newlines=S.enable_rfc_newlines,h.with_headers=S.with_headers,h.header=S.header,h.is_web_ext=c,l&&(h.integration_test_language=l.rbql_backend,h.integration_test_query=l.rbql_query,h.integration_test_with_headers=l.with_headers||!1,h.integration_test_enable_rfc_newlines=l.enable_rfc_newlines||!1),await e.postMessage(h)}if("fetch_table_header"==p)try{let t=o.table_id,n=o.encoding,i=S.input_document_path?r.dirname(S.input_document_path):null,a=u().find_table_path(q,i,t);if(!a)return;let l=await u().read_header(a,n),[c,_]=s.smart_split(l,S.delim,S.policy,!1);_||e.postMessage({msg_type:"fetch_table_header_response",header:c})}catch(e){console.error("Unable to get join table header: "+String(e))}if("update_query"==p){let e=o.query;if(!e)return;S.input_document_path&&R.set(ae(S.input_document_path),e)}if("newlines_policy_change"==p){S.enable_rfc_newlines=o.enable_rfc_newlines,S.input_document_path&&await $(Q(S.input_document_path),S.enable_rfc_newlines);let t={msg_type:"resample"};W(S,t),await e.postMessage(t)}if("with_headers_change"==p&&(S.with_headers=o.with_headers,S.input_document_path&&await $(z(S.input_document_path),S.with_headers)),"navigate"==p){var d=o.direction;"backward"==d?S.requested_start_record-=_:"forward"==d?S.requested_start_record+=_:"begin"==d?S.requested_start_record=0:"end"==d&&(S.requested_start_record=S.input_document.lineCount);let t={msg_type:"navigate"};W(S,t),await e.postMessage(t)}if("run"==p){let e=o.query,n=o.backend_language,s=o.encoding,l=o.output_dialect,_=o.enable_rfc_newlines,p=o.with_headers;await async function(e){let t=B("rbql_query_history",[]),r=t.indexOf(e);-1!=r?t.splice(r,1):t.length>=20&&t.splice(0,1),t.push(e),await $("rbql_query_history",t)}(e),await async function(e,n,o,s,l,_,p,f){R.set(ae(e),s);var h="python";let d={process_reported:!1},[y,b]=[S.delim,S.policy];"quoted"==b&&_&&(b="quoted_rfc");let[w,x]=[y,b];"csv"==l&&([w,x]=[",","quoted"]),"tsv"==l&&([w,x]=["\t","simple"]),S.output_delim=w;let v=c?null:r.join(function(e){let t=V("rbql_output_dir","TMP");return"TMP"==t?i.tmpdir():"INPUT"==t?r.dirname(e):t}(e),function(e,t){var n=r.basename(e),i=r.extname(n),o={"\t":".tsv",",":".csv"},s=".txt";o.hasOwnProperty(t)?s=o[t]:i.length>1&&(s=i);let a=n+s;return a==n&&(a+=".txt"),a}(e,w));if(s.startsWith("test "))return-1!=s.indexOf("nopython")&&(h="nopython"),void oe(h,[N["rbql mock/rbql_mock.py"],s],d,(function(t,r,n){se(e,v,t,r,n,f)}));if("js"==o){let r=[],i=null;try{if(c){let e={content:(await u().rbql_query_web(s,S.input_document,y,b,w,x,r,p,null)).join("\n"),language:M(w)};i=await t.workspace.openTextDocument(e)}else{let o={bulk_read:!0};await u().rbql_query_node(q,s,e,y,b,v,w,x,n,r,p,null,"",o),m.set(v.toLowerCase(),e),g.add(v),i=await t.workspace.openTextDocument(v)}}catch(e){let[t,r]=(null===a&&(a=__webpack_require__(371)),a).exception_to_error_info(e);return void f(t,r)}f(null,null),await ie(i,r)}else{if(c)return void f("Input error","Python backend for RBQL is not supported in web version, please use JavaScript backend.");let t=Buffer.from(s,"utf-8").toString("base64"),r=[N["rbql_core/vscode_rbql.py"],t,e,y,b,v,w,x,n];p&&r.push("--with_headers"),oe(h,r,d,(function(t,r,n){se(e,v,t,r,n,f)}))}}(S.input_document_path,s,n,e,l,_,p,f)}if("edit_udf"==p){if(c)return void f("Input error","UDFs are currently not supported in web version");let e=null,s="";"js"==o.backend_language?(e=r.join(i.homedir(),".rbql_init_source.js"),s=u().get_default_js_udf_content()):(e=r.join(i.homedir(),".rbql_init_source.py"),s=u().get_default_python_udf_content()),n.existsSync(e)||n.writeFileSync(e,s);let a=await t.workspace.openTextDocument(e);await t.window.showTextDocument(a)}"global_param_change"==p&&await $(o.key,o.value)}async function be(e=null){let o=t.window;if(!o)return;let s=o.activeTextEditor;if(!s)return;let a=s.document;if(!a)return;let l=a.uri;if(!l)return;if("file"!=l.scheme&&"untitled"!=l.scheme&&!c)return;if("file"==l.scheme&&a.isDirty&&!c)return void L("Unable to run RBQL: file has unsaved changes");let u=null;if("untitled"!=l.scheme||c)u=a.fileName;else{let e=a.getText(),t=String(Math.floor(1e6*Math.random()));u=r.join(i.tmpdir(),`vscode_rbql_scratch_${t}.txt`),n.writeFileSync(u,e)}if(!u)return void L("Unable to run RBQL for this file");let _=a.languageId,p="monocolumn",h="monocolumn";I.hasOwnProperty(_)&&([p,h]=I[_]);let d=B(Q(u),!1),g=V("rbql_with_headers_by_default",!1),y=B(z(u),g),m=G(a,p,h);S={input_document:a,input_document_path:u,requested_start_record:0,delim:p,policy:h,rfc_record_map:[],enable_rfc_newlines:d,with_headers:y,header:m},P=t.window.createWebviewPanel("rbql-console","RBQL Console",t.ViewColumn.Active,{enableScripts:!0}),A||(A=c?f:n.readFileSync(N["rbql_client.html"],"utf8"));let b=A;b=function(e,r){for(const e of["contrib/textarea-caret-position/index.js","rbql_suggest.js","rbql_client.js","rbql_logo.svg"]){let n=null;n=c?N[e]:P.webview.asWebviewUri(t.Uri.file(N[e])),r=r.replace(`src="${e}"`,`src="${n}"`)}return r}(0,b),P.webview.html=b,P.webview.onDidReceiveMessage((function(t){me(P.webview,t,e)}))}function we(e,t,r,n,i){var o=e.lineCount;let a=0,l=0,u=V("comment_prefix","");u||(u="#");for(var c=0;c<o;c++){var _=e.lineAt(c).text;if(c+1==o&&!_)break;if(_.startsWith(u))continue;let[i,p]=s.smart_split(_,t,r,!0);if(p)return 0;if(a||(a=i.length),a<n||a!=i.length)return 0;l+=1}return l>=i?a:0}function xe(e,t){let r=V("autodetection_min_line_count",10);if(e.lineCount<r)return null;let n=null,i=1;for(let o=0;o<t.length;o++){let s=M(t[o]);if(!s)continue;let[a,l]=I[s],u=we(e,a,l,i+1,r);u>i&&(i=u,n=s)}return n}async function ve(e){if(!e)return;j&&(j.dispose(),j=null);let r=e.document;if(!r)return;let n=xe(r,V("autodetect_separators",[]));if(!n)return;let i=await t.languages.setTextDocumentLanguage(r,n);te(i,!1),ee(i)}function Ee(e){let t=X(e);te(t,!1),ee(t)}async function Oe(e){await async function(e){if(!e)return;if(!V("enable_separator_autodetection",!1))return;let r=V("autodetect_separators",[]);var n=e.languageId,i=e.fileName;if(!i||g.has(i))return;let o=i.endsWith(".csv")&&"csv"==n;if("plaintext"!=n&&!o)return;let s=xe(e,r);if(!s&&o&&(s=function(e,t){let r="csv",n=0,i=e.getText();if(!i)return r;for(let e=0;e<t.length;e++){if(" "==t[e]||"."==t[e])continue;let o=M(t[e]),s=0;for(let r=0;r<1e4&&r<i.length;r++)i[r]==t[e]&&(s+=1);s>n&&(r=o,n=s)}return r}(e,r)),!s||s==n)return;let a=await t.languages.setTextDocumentLanguage(e,s);y.set(i,n),te(a,!1),ee(a)}(e),function(e){V("enable_separator_autodetection",!1)&&e&&!j&&(e.isUntitled||0==e.lineCount)&&(j=t.workspace.onDidChangeTextDocument(ve))}(e),te(e,!1),ee(e)}async function Se(e,o){if(c)return void L("This command is currently unavailable in web mode.");var s=e.fsPath;if(!s||!n.existsSync(s))return void t.window.showErrorMessage("Invalid file");var a=1024e3,l=n.statSync(s).size;if(l<=a){t.window.showWarningMessage("Rainbow CSV: The file is not big enough, showing the full file instead. Use this preview for files larger than 1MB");let e=await t.workspace.openTextDocument(s);return void await t.window.showTextDocument(e)}let u=r.basename(s);const _=r.join(i.tmpdir(),`.rb_csv_preview.${o}.${u}`);n.open(s,"r",((e,r)=>{if(e)return console.log(e.message),void t.window.showErrorMessage("Unable to preview file");var i=Buffer.alloc(a);let s="head"==o?0:Math.max(l-a,0);n.read(r,i,0,a,s,(function(e,r){if(e)return console.log(e.message),void t.window.showErrorMessage("Unable to preview file");const s=i.toString();let a=null;a="head"==o?s.substr(0,s.lastIndexOf(s.includes("\r\n")?"\r\n":"\n")):s.substr(s.indexOf("\n")+1),n.writeFileSync(_,a),t.workspace.openTextDocument(_).then((e=>t.window.showTextDocument(e)))}))}))}function Re(e,r){let n=t.languages.registerHoverProvider(e,{provideHover:(r,n,i)=>function(e,r,n,i){if(O!=e&&ee(e),V("enable_tooltip",!1)){var o=function(e,t,r,n,i){let[o,a]=I[r];var l=t.line,u=t.character,c=e.lineAt(l).text;let _=V("comment_prefix","");if(_&&c.startsWith(_))return"Comment";var p=s.smart_split(c,o,a,!0),f=p[0],h=p[1],d=Y(f,u+1);if(null==d)return null;var g="Col #"+(d+1),y=H(e,o,a);if(n&&d<y.length){const e=50;let t=y[d].trim();var m=t.substr(0,e);m!=t&&(m+="..."),g+=', Header: "'+m+'"'}return i&&(h?g+="; ERR: Inconsistent double quotes in line":y.length!=f.length&&(g+=`; WARN: Inconsistent num of fields, header: ${y.length}, this line: ${f.length}`)),g}(e,r,n,V("enable_tooltip_column_names",!1),V("enable_tooltip_warnings",!1));if(o&&!i.isCancellationRequested){let e=null;try{e=new t.MarkdownString,e.appendCodeblock(o,"rainbow hover markup")}catch(t){e=o}return new t.Hover(e)}return null}}(r,n,e,i)});r.subscriptions.push(n)}e.activate=async function(e){if(q=e.globalState,c){let r=t.Uri.joinPath(e.extensionUri,"rbql_client.html"),n=await t.workspace.fs.readFile(r);f=(new TextDecoder).decode(n)}for(let r in N)N.hasOwnProperty(r)&&(N[r]=c?t.Uri.joinPath(e.extensionUri,r):e.asAbsolutePath(r));for(let t in I)I.hasOwnProperty(t)&&Re(t,e);var r=t.commands.registerCommand("rainbow-csv.CSVLint",re),n=t.commands.registerCommand("rainbow-csv.RBQL",be),i=t.commands.registerCommand("rainbow-csv.SetHeaderLine",ue),o=t.commands.registerCommand("rainbow-csv.SetVirtualHeader",fe),s=t.commands.registerCommand("rainbow-csv.SetJoinTableName",pe),a=t.commands.registerCommand("rainbow-csv.ColumnEditBefore",(async function(){await he("ce_before")})),l=t.commands.registerCommand("rainbow-csv.ColumnEditAfter",(async function(){await he("ce_after")})),u=t.commands.registerCommand("rainbow-csv.ColumnEditSelect",(async function(){await he("ce_select")})),_=t.commands.registerCommand("rainbow-csv.RainbowSeparator",ce),p=t.commands.registerCommand("rainbow-csv.RainbowSeparatorOff",_e),h=t.commands.registerCommand("rainbow-csv.SampleHead",(async function(e){await Se(e,"head")})),d=t.commands.registerCommand("rainbow-csv.SampleTail",(async function(e){await Se(e,"tail")})),g=t.commands.registerCommand("rainbow-csv.Align",ge),y=t.commands.registerCommand("rainbow-csv.Shrink",de),m=t.commands.registerCommand("rainbow-csv.CopyBack",ye),b=t.commands.registerCommand("rainbow-csv.InternalTest",ne),w=t.workspace.onDidOpenTextDocument(Oe),x=t.window.onDidChangeActiveTextEditor(Ee);e.subscriptions.push(r),e.subscriptions.push(n),e.subscriptions.push(o),e.subscriptions.push(a),e.subscriptions.push(l),e.subscriptions.push(u),e.subscriptions.push(w),e.subscriptions.push(x),e.subscriptions.push(_),e.subscriptions.push(p),e.subscriptions.push(h),e.subscriptions.push(d),e.subscriptions.push(s),e.subscriptions.push(g),e.subscriptions.push(y),e.subscriptions.push(m),e.subscriptions.push(i),e.subscriptions.push(b),await C(1e3),Oe(X())},e.deactivate=function(){}})();var __webpack_export_target__=exports;for(var i in __webpack_exports__)__webpack_export_target__[i]=__webpack_exports__[i];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0})})(); |