/*! For license information please see index.js.LICENSE.txt */ (()=>{var __webpack_modules__={1528:e=>{e.exports=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]]},3222:(e,t,n)=>{"use strict";var r=n(1528),a={nul:0,control:0};function i(e,t){return 0===e?t.nul:e<32||e>=127&&e<160?t.control:function(e){var t,n=0,a=r.length-1;if(er[a][1])return!1;for(;a>=n;)if(t=Math.floor((n+a)/2),e>r[t][1])n=t+1;else{if(!(e=4352&&(e<=4447||9001==e||9002==e||e>=11904&&e<=42191&&12351!=e||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=196605||e>=196608&&e<=262141))}e.exports=function(e){return function(e,t){if("string"!=typeof e)return i(e,t);for(var n=0,r=0;r{const r=n(1398),a=n(7507),i=n(9175),o=n(2196),l=n(6510),s=n(3568),c=n(4285);var u=null,_=null;function d(){return null===_&&(_=n(785)),_}const p=void 0===o.homedir;var f=null;const g=100,h="vscode_rbql_scratch";var m=new Set,w=new Map,b=new Map,y=new Set,x=null,v=null,q=null,E=null,S=null,O=null,A=null,R=null,j=null,k=new Map,T=null,I=null,P=null,C=null,M=null,N=null,D=null,$=null,L=null,B=null;let U=null,F=null,V=null,W=null;const z="plaintext",J="dynamic csv",Q="quoted",G="whitespace",H="quoted_rfc",Y="simple";let Z={lint_results:new Map,lint_status_bar_button:null,dynamic_document_dialects:new Map,custom_comment_prefixes:new Map,original_language_ids:new Map,reenable_rainbow_language_infos:new Map,autodetection_stoplist:new Set,autodetection_temporarily_disabled_for_rbql:!1,dynamic_dialect_for_next_request:null,logging_enabled:!1,logging_next_context_id:1};const X={csv:[",",Q],tsv:["\t",Y],"csv (semicolon)":[";",Q],"csv (pipe)":["|",Y],"csv (whitespace)":[" ",G],[J]:[null,null]},K="comment",ee=["rainbow1","rainbow2","rainbow3","rainbow4","rainbow5","rainbow6","rainbow7","rainbow8","rainbow9","rainbow10"],te=ee.concat([K]),ne=new r.SemanticTokensLegend(te);function re(e){return e&&e.uri&&e.fileName&&function(e){return e&&e.uri&&-1!=["file","untitled","vscode-test-web"].indexOf(e.uri.scheme)}(e)}function ae(e){return re(e)&&X.hasOwnProperty(e.languageId)}function ie(e,t){return{delim:e,policy:t}}function oe(e){return"dynamic_dialect:"+e}async function le(e,t,n){await me(oe(t),n),e.dynamic_document_dialects.set(t,n)}function se(e){if(Z.dynamic_document_dialects.has(e))return Z.dynamic_document_dialects.get(e);let t=he(oe(e),null);return t&&t.hasOwnProperty("delim")&&t.hasOwnProperty("policy")?(Z.dynamic_document_dialects.set(e,t),t):null}function ce(e){return e?e.toLowerCase():e}function ue(e){for(let t in X)if(X.hasOwnProperty(t)&&X[t][0]==e)return X[t][1];return Y}function _e(e,t){for(let n in X)if(X.hasOwnProperty(n)&&X[n][0]==e&&X[n][1]==t)return n;return J}let de={"rbql_client.js":null,"contrib/textarea-caret-position/index.js":null,"rbql_suggest.js":null,"rbql_logo.svg":null,"rbql_client.html":null,"dialect_select.html":null,"dialect_select.js":null,"rbql mock/rbql_mock.py":null,"rbql_core/vscode_rbql.py":null};function pe(e){var t=r.window;t&&t.showErrorMessage(e)}function fe(e){return new Promise((t=>setTimeout(t,e)))}async function ge(e,t){e.report({message:t}),await fe(0)}function he(e,t){if(P){var n=P.get(e);if(null!=n)return n}return t}async function me(e,t){return!(!P||!e||(await P.update(e,t),0))}async function we(e,t,n){let a=new r.Range(0,0,t.lineCount,0),i=t.validateRange(a);await e.edit((e=>e.replace(i,n)))}function be(e){return"rbql_header_info:"+e}function ye(e){return"rbql_with_headers:"+e}function xe(e,t,n=null){return n||(n=r.workspace.getConfiguration("rainbow_csv")),n?n.get(e):t}class ve{constructor(e,t=null){this.context_name=e,this.logging_enabled=Z.logging_enabled,this.context_id=null===t?Z.logging_next_context_id:t,Z.logging_next_context_id+=1}log_doc_event(e,t=null){if(this.logging_enabled)try{let n=`CID:${this.context_id}, ${this.context_name}:${e}`;t?(n=`${n}, doc_lang:${t.languageId}`,t.uri&&(n=`${n}, doc_uri:${t.uri.toString(!0)}`)):n=`${n}, no_doc:1`,j.info(n)}catch(e){return void console.error(`Rainbow CSV: Unexpected log failure. ${this.context_name}:${this.event_name}`)}}log_simple_event(e){if(this.logging_enabled)try{let t=`CID:${this.context_id}, ${this.context_name}:${e}`;j.info(t)}catch(e){return void console.error(`Rainbow CSV: Unexpected log failure. ${this.context_name}:${this.event_name}`)}}}function qe(e,t,n,r){let[a,i]=d().get_header_line(e,r);return i?c.smart_split(i,t,n,!1)[0]:null}function Ee(e,t,n,r){var a=e.fileName;if(a){let e=he(be(a),null);if(null!==e&&null!==e.header)return e.header}return qe(e,t,n,r)}function Se(e){let t=e.languageId,n=null,r=null,a="";if(a=Z.custom_comment_prefixes.has(e.fileName)?Z.custom_comment_prefixes.get(e.fileName):xe("comment_prefix",""),t!=J&&X.hasOwnProperty(t))return[n,r]=X[t],[n,r,a];let i=null;return t==J&&(i=se(e.fileName)),i?[i.delim,i.policy,a]:[null,null,null]}class Oe{constructor(){}async provideDocumentSymbols(e){let[t,n,a]=Se(e);if(!n)return null;let i=null;var o=e.fileName;if(o){let e=he(be(o),null);null!==e&&null!==e.header_line_num&&(i=e.header_line_num)}if(null===i&&(i=d().get_header_line(e,a)[0]),null===i||i>=e.lineCount-1)return null;let l=new r.Range(i,0,e.lineCount-1,65535);l=e.validateRange(l);let s=new r.Range(i,0,i,65535);if(!l.contains(s))return;let c=r.SymbolKind.File;return[new r.DocumentSymbol("data","",c,l,s)]}}function Ae(e=!1){if(!xe("enable_sticky_header",!1))return void(null!==W&&(W.dispose(),W=null));if(null!==W&&e&&(W.dispose(),W=null),null!==W)return;let t=new Oe,n=[];for(let e in X)X.hasOwnProperty(e)&&n.push({language:e});W=r.languages.registerDocumentSymbolProvider(n,t)}function Re(){let e=new wt;null!==F&&F.dispose();let t={language:J};F=r.languages.registerDocumentRangeSemanticTokensProvider(t,e,ne)}function je(){let e=new bt;null!==V&&V.dispose();let t=[];for(let e in X)X.hasOwnProperty(e)&&e!=J&&t.push({language:e});V=r.languages.registerDocumentRangeSemanticTokensProvider(t,e,ne)}async function ke(e=null){let t=new ve("choose_dynamic_separator");t.log_doc_event("starting",a);let n=Ce();if(!n)return;var a=Me(n);if(!re(a))return;let i=function(e,t){if(!e||!t)return"";let n=e.selection;return n?n.start.line!=n.end.line?"":t.lineAt(n.start.line).text.substring(n.start.character,n.end.character):""}(n,a);I||(I=await yt("dialect_select.html")),(M=r.window.createWebviewPanel("rainbow-dialect-select","Choose CSV Dialect",r.ViewColumn.Beside,{enableScripts:!0})).webview.html=ot(M,I,["dialect_select.js"]),M.webview.onDidReceiveMessage((function(n){!async function(e,t,n,a,i,o){if(n){if("dialect_handshake"==n.msg_type){let e={msg_type:"dialect_handshake",selected_separator:a};o&&o.integration_test&&(e.integration_test=!0),await t.webview.postMessage(e)}if("apply_dialect"==n.msg_type){let a=n.delim,o=n.policy,l=n.comment_prefix;if("whitespace"==o&&" "!=a)return void pe("Selected policy can only be used with whitespace separator");if("double_escape"==o&&'"'==a)return void pe("Double quote separator in incompatible with double quote escape policy");if(!a)return void pe("Separator is empty");if(-1==[Y,H,Q,G].indexOf(o))return void pe("Selected policy is empty or not supported");t.dispose(),await le(Z,e.fileName,ie(a,o)),Z.custom_comment_prefixes.set(e.fileName,l),e.languageId==J&&Ne(e)?await Te(e,i):await r.languages.setTextDocumentLanguage(e,J)}}}(a,M,n,i,t,e)}))}async function Te(e,t){if(t.log_doc_event("start enable-rainbow-features-if-csv",e),!ae(e))return void t.log_simple_event("abort enable-rainbow-features-if-csv: non-rainbow dialect");E&&E.hide();var n=e.languageId;n==J&&null!=Z.dynamic_dialect_for_next_request&&(await le(Z,e.fileName,Z.dynamic_dialect_for_next_request),Z.dynamic_dialect_for_next_request=null);let[i,o,l]=Se(e);if(!i||!o)return t.log_simple_event("abort enable-rainbow-features-if-csv: missing delim or policy"),Ie(),A||(A=r.window.createStatusBarItem(r.StatusBarAlignment.Left)),A.text="Choose Separator...",A.tooltip="Click to choose Dynamic CSV separator",A.command="rainbow-csv.RainbowSeparator",void A.show();l&&r.languages.setLanguageConfiguration(n,{comments:{lineComment:l}}),n==J&&Re(),function(e){A&&A.hide(),d().show_lint_status_bar_button(r,Z,e.fileName,e.languageId),x||(x=r.window.createStatusBarItem(r.StatusBarAlignment.Left)),x.text="Query",x.tooltip="Click to run SQL-like RBQL query",x.command="rainbow-csv.RBQL",x.show(),De(e.fileName),q||(q=r.window.createStatusBarItem(r.StatusBarAlignment.Left)),q.text="Rainbow OFF",q.tooltip="Click to restore original file type and syntax",q.command="rainbow-csv.RainbowSeparatorOff",q.show(),function(e){let t=w.get(ce(e));if(!t||-1!=t.indexOf(h))return;let n=a.basename(t);S||(S=r.window.createStatusBarItem(r.StatusBarAlignment.Left)),S.text="Copy Back",S.tooltip=`Copy to parent table: ${n}`,S.command="rainbow-csv.CopyBack",S.show()}(e.fileName),$e(),xe("enable_cursor_position_info",!1)&&(D=r.window.onDidChangeTextEditorSelection(dt))}(e),await Le(e,!1),t.log_simple_event("finish enable-rainbow-features-if-csv")}function Ie(){let e=[Z.lint_status_bar_button,x,q,S,v,O,A,E];for(let t=0;t=1e4)return void pe("Multicursor column edit works only for files smaller than 10000 lines.");let s=d().get_cursor_position_info(r,n,a,i,o,l).column_number,[c,u,_]=d().generate_column_edit_selections(r,n,a,i,o,e,s);null===u?(_&&r.window.showWarningMessage(_),t.selections=c,await r.window.showTextDocument(n)):pe(u)}async function nt(){let e=Ce(),t=Me(e);if(!ae(t))return;let[n,a,i]=Se(t);if(null===a)return;let o={location:r.ProgressLocation.Window,title:"Rainbow CSV"};await r.window.withProgress(o,(async o=>{await ge(o,"Preparing");let[l,s]=d().shrink_columns(t,n,a,i);s?pe(`Unable to shrink: Inconsistent double quotes at line ${s}`):(m.delete(t.fileName),De(t.fileName),null!==l?(await ge(o,"Shrinking columns"),await we(e,t,l)):r.window.showWarningMessage("No trailing whitespaces found, skipping"))}))}async function rt(){let e=Ce(),t=Me(e);if(!ae(t))return;let[n,a,i]=Se(t);if(null===a)return;let o={location:r.ProgressLocation.Window,title:"Rainbow CSV"};await r.window.withProgress(o,(async o=>{await ge(o,"Calculating column statistics");let l=xe("double_width_alignment",!0),[s,c,u,_]=d().calc_column_stats(t,n,a,i,l);if(c)return void pe(`Unable to align: Inconsistent double quotes at line ${c}`);if(s=d().adjust_column_stats(s,n.length),null===s)return void pe("Unable to allign: Internal Rainbow CSV Error");await ge(o,"Preparing final alignment");let p=d().align_columns(u,_,s,n);await ge(o,"Aligning columns");let f=xe("align_in_scratch_file",!1),g=t.uri&&"untitled"==t.uri.scheme;if(f&&!g){let e={content:p,language:t.languageId},n=await r.workspace.openTextDocument(e);m.add(n.fileName),await r.window.showTextDocument(n),De(n.fileName)}else await we(e,t,p),m.add(t.fileName),De(t.fileName)}))}async function at(){if(p)return void pe("This command is currently unavailable in web mode.");let e=Me();if(!e)return;let t=e.fileName,n=w.get(ce(t));if(!n)return;let a=await r.workspace.openTextDocument(n),i=await r.window.showTextDocument(a);await async function(e,t){let n=e.getText(),r=Me(t);r&&await we(t,r,n)}(e,i)}async function it(e,t,l=null){let s=t.msg_type;if("handshake"==s){var _={msg_type:"handshake",backend_language:he("rbql_backend_language","js"),encoding:he("rbql_encoding","utf-8")};d().sample_preview_records_from_context(R,_,g,b);let t=We(R.input_document_path);k.has(t)&&(_.last_query=k.get(t));let n=he("rbql_query_history",[]);_.query_history=n,_.policy=R.policy,_.with_headers=R.with_headers,_.header_for_ui=R.header_for_ui,_.is_web_ext=p,l&&(_.integration_test_language=l.rbql_backend,_.integration_test_query=l.rbql_query,_.integration_test_with_headers=l.with_headers||!1,_.integration_test_delay=l.integration_test_delay||2e3),await e.postMessage(_)}if("fetch_table_header"==s)try{let n=t.table_id,r=t.encoding,i=R.input_document_path?a.dirname(R.input_document_path):null,o=d().find_table_path(P,i,n);if(!o)return;let l=await d().read_header(o,r);if(!l)return;let[s,u]=c.smart_split(l,R.delim,R.policy,!1);u||e.postMessage({msg_type:"fetch_table_header_response",header_for_ui:s})}catch(e){console.error("Unable to get join table header: "+String(e))}if("update_query"==s){let e=t.query;if(!e)return;R.input_document_path&&k.set(We(R.input_document_path),e)}if("with_headers_change"==s&&(R.with_headers=t.with_headers,R.input_document_path&&await me(ye(R.input_document_path),R.with_headers)),"navigate"==s){var f=t.direction;"backward"==f?R.requested_start_record-=g:"forward"==f?R.requested_start_record+=g:"begin"==f?R.requested_start_record=0:"end"==f&&(R.requested_start_record=R.input_document.lineCount);let n={msg_type:"navigate"};d().sample_preview_records_from_context(R,n,g,b),await e.postMessage(n)}if("run"==s){let i=t.query,l=t.backend_language,s=t.encoding,c=t.output_dialect,_=t.with_headers;await async function(e){let t=he("rbql_query_history",[]),n=t.indexOf(e);-1!=n?t.splice(n,1):t.length>=20&&t.splice(0,1),t.push(e),await me("rbql_query_history",t)}(i),await async function(e,t,i,l,s,c,_){let f=new ve("run-rbql-query");f.log_simple_event("start"),k.set(We(t),s);let g=["python3","python"],[h,m,b]=[R.delim,R.policy,R.comment_prefix],[y,x]=[h,m];"csv"==c&&([y,x]=[",",Q]),"tsv"==c&&([y,x]=["\t",Y]),R.output_delim=y,R.output_policy=x;let v=p?null:a.join(function(e){let t=xe("rbql_output_dir","TMP");return"TMP"==t?o.tmpdir():"INPUT"==t?a.dirname(e):t}(t),function(e,t){var n=a.basename(e),r=a.extname(n),i={"\t":".tsv",",":".csv"},o=".txt";i.hasOwnProperty(t)?o=i[t]:r.length>1&&(o=r);let l=n+o;return l==n&&(l+=".txt"),l}(t,y));if(s.startsWith("test ")){f.log_simple_event("test mode");let t=[de["rbql mock/rbql_mock.py"],s],n=await Je(g,t,f);return console.log(JSON.stringify(n)),n.hasOwnProperty("error_type")||n.hasOwnProperty("error_msg")?void await Qe(e,n.error_type,n.error_msg):void await Qe(e,null,null)}if("js"==l){f.log_simple_event("using js backend");let a=[],o=null,l=_e(y,x);try{if(p){f.log_simple_event("using web mode");let t={content:(await d().rbql_query_web(s,R.input_document,h,m,y,x,a,_,b)).join("\n"),language:l};l==J&&(Z.dynamic_dialect_for_next_request=ie(y,x)),Z.autodetection_temporarily_disabled_for_rbql=!0,o=await r.workspace.openTextDocument(t),await Qe(e,null,null),await async function(e,t){try{await r.window.showTextDocument(e)}catch(e){return void pe("Unable to open RBQL result document")}await Fe(t)}(o,a),Z.dynamic_dialect_for_next_request=null,Z.autodetection_temporarily_disabled_for_rbql=!1,f.log_simple_event("finished OK")}else{f.log_simple_event("using electron mode");let n={bulk_read:!0};await d().rbql_query_node(P,s,t,h,m,v,y,x,i,a,_,b,"",n),w.set(ce(v),t),l==J&&(Z.dynamic_dialect_for_next_request=ie(y,x)),Z.autodetection_temporarily_disabled_for_rbql=!0,o=await r.workspace.openTextDocument(v),await Qe(e,null,null),await Ve(o,y,x,a),Z.dynamic_dialect_for_next_request=null,Z.autodetection_temporarily_disabled_for_rbql=!1,f.log_simple_event("finished OK")}}catch(t){let[r,a]=(null===u&&(u=n(6945)),u).exception_to_error_info(t);return f.log_simple_event("finished with error"),void await Qe(e,r,a)}}else{if(f.log_simple_event("using python backend"),p)return void await Qe(e,"Input error","Python backend for RBQL is not supported in web version, please use JavaScript backend.");let n=Buffer.from(s,"utf-8").toString("base64");b||(b="");let a=[de["rbql_core/vscode_rbql.py"],n,t,h,m,v,y,x,b,i];_&&a.push("--with_headers");let o=await Je(g,a,f);if(o.hasOwnProperty("error_type")||o.hasOwnProperty("error_msg"))return f.log_simple_event("finished with error"),void await Qe(e,o.error_type,o.error_msg);f.log_simple_event("finished OK"),await Qe(e,null,null),Z.autodetection_stoplist.add(v),w.set(ce(v),t),Z.autodetection_temporarily_disabled_for_rbql=!0;let l=_e(y,x),c=await r.workspace.openTextDocument(v);Z.autodetection_temporarily_disabled_for_rbql=!1,l==J&&(Z.dynamic_dialect_for_next_request=ie(y,x)),await Ve(c,y,x,o.warnings),Z.dynamic_dialect_for_next_request=null}}(e,R.input_document_path,s,l,i,c,_)}if("edit_udf"==s){if(p)return void await Qe(e,"Input error","UDFs are currently not supported in web version");let n=null,l="";"js"==t.backend_language?(n=a.join(o.homedir(),".rbql_init_source.js"),l=d().get_default_js_udf_content()):(n=a.join(o.homedir(),".rbql_init_source.py"),l=d().get_default_python_udf_content()),i.existsSync(n)||i.writeFileSync(n,l);let s=await r.workspace.openTextDocument(n);await r.window.showTextDocument(s)}"global_param_change"==s&&await me(t.key,t.value)}function ot(e,t,n){for(const a of n){let n=null;n=p?de[a]:e.webview.asWebviewUri(r.Uri.file(de[a])),t=t.replace(`src="${a}"`,`src="${n}"`)}return t}async function lt(e=null){let t=r.window;if(!t)return;let n=t.activeTextEditor;if(!n)return;let l=n.document;if(!l)return;let s=l.uri;if(!s)return;if("file"!=s.scheme&&"untitled"!=s.scheme&&!p)return;if("file"==s.scheme&&l.isDirty&&!p)return void pe("Unable to run RBQL: file has unsaved changes");let c=null;if("untitled"!=s.scheme||p)c=l.fileName;else{let e=l.getText(),t=String(Math.floor(1e6*Math.random()));c=a.join(o.tmpdir(),`${h}_${t}.txt`),i.writeFileSync(c,e)}if(!c)return void pe("Unable to run RBQL for this file");let[u,_,d]=Se(l);null===_&&(_="monocolumn",u="monocolumn");let f=xe("rbql_with_headers_by_default",!1),g=he(ye(c),f),m=qe(l,u,_,d);R={input_document:l,input_document_path:c,requested_start_record:0,delim:u,policy:_,comment_prefix:d,with_headers:g,header_for_ui:m},C=r.window.createWebviewPanel("rbql-console","RBQL Console",r.ViewColumn.Active,{enableScripts:!0}),T||(T=await yt("rbql_client.html")),C.webview.html=ot(C,T,["contrib/textarea-caret-position/index.js","rbql_suggest.js","rbql_client.js","rbql_logo.svg"]),C.webview.onDidReceiveMessage((function(t){it(C.webview,t,e)}))}function st(e,t,n){let[r,a,i]=["csv",",",Q],o=0,l=e.getText();if(!l)return[r,a,i];for(let e of t){if(" "==e||"."==e)continue;let t=0;for(let r=0;ro){let n=ue(e),l=_e(e,n);[r,a,i]=[l,e,n],o=t}}return[r,a,i]}async function ct(e,t,n,r,a=null){let i=new ve("autodetection",a);if(i.log_doc_event("starting...",r),n.autodetection_temporarily_disabled_for_rbql)return i.log_simple_event("abort: disabled for rbql"),[r,!1];if(!re(r))return i.log_simple_event("abort: ineligible doc"),[r,!1];if(!xe("enable_separator_autodetection",!1,t))return i.log_simple_event("abort: disabled in config"),[r,!1];var o=r.fileName,l=r.languageId;if(n.autodetection_stoplist.has(o))return i.log_simple_event("abort: doc path in stoplist"),[r,!1];let c=(o.endsWith(".csv")||o.endsWith(".CSV"))&&"csv"==l;if(l!=z&&!c)return i.log_simple_event("abort: ineligible original language id"),[r,!1];let u=xe("autodetect_separators",[],t).map((e=>"TAB"===e?"\t":e));if(!X.hasOwnProperty(l)&&$&&$.file_path===o&&Math.abs(Date.now()-$.timestamp)<1e3)return i.log_simple_event("abort: recent doc language switch prevention"),[r,!1];let _=xe("comment_prefix","",t)||"#";i.log_simple_event("starting standard dialect autodetection...");let[d,p,f,g]=function(e,t,n,r){let a=[];for(let e of n){let t=ue(e),n=_e(e,t);n&&t&&(a.push([n,e,t]),","!=e&&";"!=e||a.push([J,e,H]))}let i=xe("csv_lint_detect_trailing_spaces",!1,e),o=xe("autodetection_min_line_count",10,e);if(t.lineCount=d+1&&(d=y,[l,c,u]=[n,a,p],_=w)}return[l,c,u,_]}(t,r,u,_);if(d?n.lint_results.set(`${o}.${d}`,{is_ok:!0,first_trailing_space_line:g}):!d&&c&&(i.log_simple_event("starting frequency-based dialect autodetection..."),[d,p,f]=st(r,u,1e4)),!d)return i.log_simple_event("abort: content-based autodetection did not detect anything"),[r,!1];if(d==J&&await le(n,o,ie(p,f)),d==l)return i.log_simple_event("abort: autodetected dialect matches the original one"),[r,!1];He(o,l,n.original_language_ids),i.log_simple_event(`autodetection successful - switching from ${l} to ${d}`);let h=await e.languages.setTextDocumentLanguage(r,d);return i.log_doc_event("after language switch",h),[h,!0]}async function ut(e){if(!e)return;N&&(N.dispose(),N=null);let t=new ve("handle_first_edit_for_an_empty_doc");t.log_doc_event("starting",e.document),await ct(r,r.workspace.getConfiguration("rainbow_csv"),Z,e.document,t.context_id)}async function _t(e){let t=new ve("handle_editor_switch"),n=Me(e);t.log_doc_event("editor switch",n),Pe(n,t),await Te(n,t)}function dt(e){null!==U&&clearTimeout(U),U=setTimeout((()=>{!$e()&&O&&O.hide()}),10)}async function pt(e){let t=new ve("handle_doc_open");if(t.log_doc_event("opening doc",e),!re(e))return void t.log_simple_event("abort: ineligible doc");if(xe("enable_separator_autodetection",!1)&&null===N&&e.isUntitled&&e.lineCount<=1)return N=r.workspace.onDidChangeTextDocument(ut),void t.log_simple_event("creating empty doc subscription");let n=!1;[e,n]=await ct(r,r.workspace.getConfiguration("rainbow_csv"),Z,e,t.context_id),t.log_doc_event(`after autodetection. filetype changed: ${n}`,e),Ne(e)&&(t.log_simple_event("active doc - enabling features"),Pe(e,t),await Te(e,t)),t.log_simple_event("finishing")}async function ft(e){let t=new ve("handle_doc_close");if(t.log_doc_event("closing doc",e),!ae(e))return t.log_simple_event("abort: non rainbow doc"),void($=null);$={file_path:e.fileName,timestamp:Date.now()},Ne(e)&&(t.log_simple_event("disabling ui elements"),Ie()),t.log_simple_event("finalizing")}async function gt(e){let t=Z.logging_enabled;Z.logging_enabled=xe("enable_debug_logging",!1),Z.logging_enabled&&!t&&new ve("config change").log_simple_event("logging enabled"),Ae()}async function ht(e,t){if(p)return void pe("This command is currently unavailable in web mode.");var n=e.fsPath;if(!n||!i.existsSync(n))return void r.window.showErrorMessage("Invalid file");var l=1024e3,s=i.statSync(n).size;if(s<=l){r.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 r.workspace.openTextDocument(n);return void await r.window.showTextDocument(e)}let c=a.basename(n);const u=a.join(o.tmpdir(),`.rb_csv_preview.${t}.${c}`);i.open(n,"r",((e,n)=>{if(e)return console.log(e.message),void r.window.showErrorMessage("Unable to preview file");var a=Buffer.alloc(l);let o="head"==t?0:Math.max(s-l,0);i.read(n,a,0,l,o,(function(e,n){if(e)return console.log(e.message),void r.window.showErrorMessage("Unable to preview file");const o=a.toString();let l=null;l="head"==t?o.substr(0,o.lastIndexOf(o.includes("\r\n")?"\r\n":"\n")):o.substr(o.indexOf("\n")+1),i.writeFileSync(u,l),r.workspace.openTextDocument(u).then((e=>r.window.showTextDocument(e)))}))}))}function mt(e,t){let n=r.languages.registerHoverProvider(e,{provideHover:(e,t,n)=>function(e,t,n,a){if(!xe("enable_tooltip",!1))return;let[i,o,l]=Se(e),s=d().get_cursor_position_info(r,e,i,o,l,n);if(!s||a.isCancellationRequested)return null;let c=xe("enable_tooltip_column_names",!1),u=Ee(e,i,o,l);if(!u)return null;let[_,p]=d().format_cursor_position_info(s,u,c,!0,25),f=new r.MarkdownString;return f.appendText(p),new r.Hover(f)}(e,0,t,n)});t.subscriptions.push(n)}class wt{constructor(){}async provideDocumentRangeSemanticTokens(e,t,n){let[a,i,o]=Se(e);if(!i||e.languageId!=J)return null;let l=d().parse_document_range(r,e,a,i,o,t);const s=new r.SemanticTokensBuilder(ne);for(let e of l)if(e.hasOwnProperty("comment_range"))s.push(e.comment_range,K);else for(let t=0;t{const r=n(4285);class a extends Error{}function i(e,t=null){if(!e)throw t||(t="Assertion error"),new a(t)}class o{constructor(e,t,n,r,a,i,o){this.delim=e,this.policy=t,this.stop_on_warning=n,this.first_defective_line=null,this.records=r?[]:null,this.collect_records=r,this.num_records_parsed=0,this.fields_info=new Map,this.first_trailing_space_line=null,this.detect_trailing_spaces=i,this.preserve_quotes_and_whitespaces=a,this.min_num_fields_for_autodetection=o}consume(e,t){let[n,a]=r.smart_split(e,this.delim,this.policy,this.preserve_quotes_and_whitespaces);if(a&&(null===this.first_defective_line&&(this.first_defective_line=t),this.stop_on_warning))return!1;if(this.detect_trailing_spaces&&null===this.first_trailing_space_line)for(let e of n)!e.length||" "!=e.charAt(0)&&" "!=e.charAt(e.length-1)||(this.first_trailing_space_line=t);if(!this.fields_info.has(n.length)&&(this.fields_info.set(n.length,this.num_records_parsed),-1!=this.min_num_fields_for_autodetection)){if(n.length1)return!1}return this.collect_records&&this.records.push(n),this.num_records_parsed+=1,!0}}e.exports.parse_document_records=function(e,t,n,a=null,l=!1,s=-1,c=!0,u=!1,_=!1,d=-1){let p=e.lineCount,f=0,g=new r.MultilineRecordAggregator(a),h=new o(t,n,l,c,u,_,d),m=[];for(let t=0;t=p&&""==r){c&&m.push({record_num:h.num_records_parsed,comment_text:r});break}let i=null;if("quoted_rfc"==n){if(g.add_line(r),g.has_comment_line){f=t+1,g.reset(),c&&m.push({record_num:h.num_records_parsed,comment_text:r});continue}if(!g.has_full_record)continue;i=g.get_full_line("\n"),g.reset()}else{if(a&&r.startsWith(a)){f=t+1,c&&m.push({record_num:h.num_records_parsed,comment_text:r});continue}i=r}if(!h.consume(i,f))return[h.records,h.num_records_parsed,h.fields_info,h.first_defective_line,h.first_trailing_space_line,m];if(f=t+1,-1!==s&&h.num_records_parsed>=s)return[h.records,h.num_records_parsed,h.fields_info,h.first_defective_line,h.first_trailing_space_line,m]}return g.is_inside_multiline_record()&&(i("quoted_rfc"==n),h.consume(g.get_full_line("\n"),f)),[h.records,h.num_records_parsed,h.fields_info,h.first_defective_line,h.first_trailing_space_line,m]},e.exports.assert=i},4148:(e,t,n)=>{"use strict";var r=n(5606);function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function i(e,t){for(var n=0;n1?n-1:0),a=1;a1?n-1:0),a=1;a1?n-1:0),a=1;a1?n-1:0),a=1;a{"use strict";var r=n(5606);function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;te.length)&&(n=e.length),e.substring(n-t.length,n)===t}var b="",y="",x="",v="",q={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};function E(e){var t=Object.keys(e),n=Object.create(Object.getPrototypeOf(e));return t.forEach((function(t){n[t]=e[t]})),Object.defineProperty(n,"message",{value:e.message}),n}function S(e){return h(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}var O=function(e,t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(O,e);var n,a,l,u,_=(n=O,a=d(),function(){var e,t=f(n);if(a){var r=f(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return s(this,e)});function O(e){var t;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,O),"object"!==g(e)||null===e)throw new m("options","Object",e);var n=e.message,a=e.operator,i=e.stackStartFn,o=e.actual,l=e.expected,u=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=n)t=_.call(this,String(n));else if(r.stderr&&r.stderr.isTTY&&(r.stderr&&r.stderr.getColorDepth&&1!==r.stderr.getColorDepth()?(b="",y="",v="",x=""):(b="",y="",v="",x="")),"object"===g(o)&&null!==o&&"object"===g(l)&&null!==l&&"stack"in o&&o instanceof Error&&"stack"in l&&l instanceof Error&&(o=E(o),l=E(l)),"deepStrictEqual"===a||"strictEqual"===a)t=_.call(this,function(e,t,n){var a="",i="",o=0,l="",s=!1,c=S(e),u=c.split("\n"),_=S(t).split("\n"),d=0,p="";if("strictEqual"===n&&"object"===g(e)&&"object"===g(t)&&null!==e&&null!==t&&(n="strictEqualObject"),1===u.length&&1===_.length&&u[0]!==_[0]){var f=u[0].length+_[0].length;if(f<=10){if(!("object"===g(e)&&null!==e||"object"===g(t)&&null!==t||0===e&&0===t))return"".concat(q[n],"\n\n")+"".concat(u[0]," !== ").concat(_[0],"\n")}else if("strictEqualObject"!==n&&f<(r.stderr&&r.stderr.isTTY?r.stderr.columns:80)){for(;u[0][d]===_[0][d];)d++;d>2&&(p="\n ".concat(function(e,t){if(t=Math.floor(t),0==e.length||0==t)return"";var n=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+e.substring(0,n-e.length)}(" ",d),"^"),d=0)}}for(var h=u[u.length-1],m=_[_.length-1];h===m&&(d++<2?l="\n ".concat(h).concat(l):a=h,u.pop(),_.pop(),0!==u.length&&0!==_.length);)h=u[u.length-1],m=_[_.length-1];var E=Math.max(u.length,_.length);if(0===E){var O=c.split("\n");if(O.length>30)for(O[26]="".concat(b,"...").concat(v);O.length>27;)O.pop();return"".concat(q.notIdentical,"\n\n").concat(O.join("\n"),"\n")}d>3&&(l="\n".concat(b,"...").concat(v).concat(l),s=!0),""!==a&&(l="\n ".concat(a).concat(l),a="");var A=0,R=q[n]+"\n".concat(y,"+ actual").concat(v," ").concat(x,"- expected").concat(v),j=" ".concat(b,"...").concat(v," Lines skipped");for(d=0;d1&&d>2&&(k>4?(i+="\n".concat(b,"...").concat(v),s=!0):k>3&&(i+="\n ".concat(_[d-2]),A++),i+="\n ".concat(_[d-1]),A++),o=d,a+="\n".concat(x,"-").concat(v," ").concat(_[d]),A++;else if(_.length1&&d>2&&(k>4?(i+="\n".concat(b,"...").concat(v),s=!0):k>3&&(i+="\n ".concat(u[d-2]),A++),i+="\n ".concat(u[d-1]),A++),o=d,i+="\n".concat(y,"+").concat(v," ").concat(u[d]),A++;else{var T=_[d],I=u[d],P=I!==T&&(!w(I,",")||I.slice(0,-1)!==T);P&&w(T,",")&&T.slice(0,-1)===I&&(P=!1,I+=","),P?(k>1&&d>2&&(k>4?(i+="\n".concat(b,"...").concat(v),s=!0):k>3&&(i+="\n ".concat(u[d-2]),A++),i+="\n ".concat(u[d-1]),A++),o=d,i+="\n".concat(y,"+").concat(v," ").concat(I),a+="\n".concat(x,"-").concat(v," ").concat(T),A+=2):(i+=a,a="",1!==k&&0!==d||(i+="\n ".concat(I),A++))}if(A>20&&d30)for(p[26]="".concat(b,"...").concat(v);p.length>27;)p.pop();t=1===p.length?_.call(this,"".concat(d," ").concat(p[0])):_.call(this,"".concat(d,"\n\n").concat(p.join("\n"),"\n"))}else{var f=S(o),h="",A=q[a];"notDeepEqual"===a||"notEqual"===a?(f="".concat(q[a],"\n\n").concat(f)).length>1024&&(f="".concat(f.slice(0,1021),"...")):(h="".concat(S(l)),f.length>512&&(f="".concat(f.slice(0,509),"...")),h.length>512&&(h="".concat(h.slice(0,509),"...")),"deepEqual"===a||"equal"===a?f="".concat(A,"\n\n").concat(f,"\n\nshould equal\n\n"):h=" ".concat(a," ").concat(h)),t=_.call(this,"".concat(f).concat(h))}return Error.stackTraceLimit=u,t.generatedMessage=!n,Object.defineProperty(c(t),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),t.code="ERR_ASSERTION",t.actual=o,t.expected=l,t.operator=a,Error.captureStackTrace&&Error.captureStackTrace(c(t),i),t.stack,t.name="AssertionError",s(t)}return l=O,(u=[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:t,value:function(e,t){return h(this,i(i({},t),{},{customInspect:!1,depth:0}))}}])&&o(l.prototype,u),Object.defineProperty(l,"prototype",{writable:!1}),O}(u(Error),h.custom);e.exports=O},9597:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}var o,l,s={};function c(e,t,n){n||(n=Error);var o=function(n){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(u,n);var o,l,s,c=(l=u,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=i(l);if(s){var n=i(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function u(n,r,a){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),i=c.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,a)),i.code=e,i}return o=u,Object.defineProperty(o,"prototype",{writable:!1}),o}(n);s[e]=o}function u(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}c("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),c("ERR_INVALID_ARG_TYPE",(function(e,t,a){var i,l,s,c,_;if(void 0===o&&(o=n(4148)),o("string"==typeof e,"'name' must be a string"),"string"==typeof t&&(l="not ",t.substr(0,4)===l)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-9,n)===t}(e," argument"))s="The ".concat(e," ").concat(i," ").concat(u(t,"type"));else{var d=("number"!=typeof _&&(_=0),_+1>(c=e).length||-1===c.indexOf(".",_)?"argument":"property");s='The "'.concat(e,'" ').concat(d," ").concat(i," ").concat(u(t,"type"))}return s+". Received type ".concat(r(a))}),TypeError),c("ERR_INVALID_ARG_VALUE",(function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===l&&(l=n(537));var a=l.inspect(t);return a.length>128&&(a="".concat(a.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(a)}),TypeError,RangeError),c("ERR_INVALID_RETURN_VALUE",(function(e,t,n){var a;return a=n&&n.constructor&&n.constructor.name?"instance of ".concat(n.constructor.name):"type ".concat(r(n)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(a,".")}),TypeError),c("ERR_MISSING_ARGS",(function(){for(var e=arguments.length,t=new Array(e),r=0;r0,"At least one arg needs to be specified");var a="The ",i=t.length;switch(t=t.map((function(e){return'"'.concat(e,'"')})),i){case 1:a+="".concat(t[0]," argument");break;case 2:a+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:a+=t.slice(0,i-1).join(", "),a+=", and ".concat(t[i-1]," arguments")}return"".concat(a," must be specified")}),TypeError),e.exports.codes=s},2299:(e,t,n)=>{"use strict";function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,o,l=[],s=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw a}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n10)return!0;for(var t=0;t57)return!0}return 10===e.length&&e>=Math.pow(2,32)}function P(e){return Object.keys(e).filter(I).concat(u(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}function C(e,t){if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);a{"use strict";var r=n(453),a=n(487),i=a(r("String.prototype.indexOf"));e.exports=function(e,t){var n=r(e,!!t);return"function"==typeof n&&i(e,".prototype.")>-1?a(n):n}},487:(e,t,n)=>{"use strict";var r=n(6743),a=n(453),i=n(6897),o=n(9675),l=a("%Function.prototype.apply%"),s=a("%Function.prototype.call%"),c=a("%Reflect.apply%",!0)||r.call(s,l),u=n(655),_=a("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new o("a function is required");var t=c(r,s,arguments);return i(t,1+_(0,e.length-(arguments.length-1)),!0)};var d=function(){return c(r,l,arguments)};u?u(e.exports,"apply",{value:d}):e.exports.apply=d},41:(e,t,n)=>{"use strict";var r=n(655),a=n(8068),i=n(9675),o=n(5795);e.exports=function(e,t,n){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new i("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new i("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new i("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new i("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new i("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new i("`loose`, if provided, must be a boolean");var l=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,u=arguments.length>6&&arguments[6],_=!!o&&o(e,t);if(r)r(e,t,{configurable:null===c&&_?_.configurable:!c,enumerable:null===l&&_?_.enumerable:!l,value:n,writable:null===s&&_?_.writable:!s});else{if(!u&&(l||s||c))throw new a("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=n}}},8452:(e,t,n)=>{"use strict";var r=n(1189),a="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),i=Object.prototype.toString,o=Array.prototype.concat,l=n(41),s=n(592)(),c=function(e,t,n,r){if(t in e)if(!0===r){if(e[t]===n)return}else if("function"!=typeof(a=r)||"[object Function]"!==i.call(a)||!r())return;var a;s?l(e,t,n,!0):l(e,t,n)},u=function(e,t){var n=arguments.length>2?arguments[2]:{},i=r(t);a&&(i=o.call(i,Object.getOwnPropertySymbols(t)));for(var l=0;l{"use strict";var r=n(453)("%Object.defineProperty%",!0)||!1;if(r)try{r({},"a",{value:1})}catch(e){r=!1}e.exports=r},1237:e=>{"use strict";e.exports=EvalError},9383:e=>{"use strict";e.exports=Error},9290:e=>{"use strict";e.exports=RangeError},9538:e=>{"use strict";e.exports=ReferenceError},8068:e=>{"use strict";e.exports=SyntaxError},9675:e=>{"use strict";e.exports=TypeError},5345:e=>{"use strict";e.exports=URIError},2682:(e,t,n)=>{"use strict";var r=n(9600),a=Object.prototype.toString,i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){if(!r(t))throw new TypeError("iterator must be a function");var o;arguments.length>=3&&(o=n),"[object Array]"===a.call(e)?function(e,t,n){for(var r=0,a=e.length;r{"use strict";var t=Object.prototype.toString,n=Math.max,r=function(e,t){for(var n=[],r=0;r{"use strict";var r=n(9353);e.exports=Function.prototype.bind||r},453:(e,t,n)=>{"use strict";var r,a=n(9383),i=n(1237),o=n(9290),l=n(9538),s=n(8068),c=n(9675),u=n(5345),_=Function,d=function(e){try{return _('"use strict"; return ('+e+").constructor;")()}catch(e){}},p=Object.getOwnPropertyDescriptor;if(p)try{p({},"")}catch(e){p=null}var f=function(){throw new c},g=p?function(){try{return f}catch(e){try{return p(arguments,"callee").get}catch(e){return f}}}():f,h=n(4039)(),m=n(24)(),w=Object.getPrototypeOf||(m?function(e){return e.__proto__}:null),b={},y="undefined"!=typeof Uint8Array&&w?w(Uint8Array):r,x={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?r:ArrayBuffer,"%ArrayIteratorPrototype%":h&&w?w([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":b,"%AsyncGenerator%":b,"%AsyncGeneratorFunction%":b,"%AsyncIteratorPrototype%":b,"%Atomics%":"undefined"==typeof Atomics?r:Atomics,"%BigInt%":"undefined"==typeof BigInt?r:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?r:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?r:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":a,"%eval%":eval,"%EvalError%":i,"%Float32Array%":"undefined"==typeof Float32Array?r:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?r:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?r:FinalizationRegistry,"%Function%":_,"%GeneratorFunction%":b,"%Int8Array%":"undefined"==typeof Int8Array?r:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?r:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":h&&w?w(w([][Symbol.iterator]())):r,"%JSON%":"object"==typeof JSON?JSON:r,"%Map%":"undefined"==typeof Map?r:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&h&&w?w((new Map)[Symbol.iterator]()):r,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?r:Promise,"%Proxy%":"undefined"==typeof Proxy?r:Proxy,"%RangeError%":o,"%ReferenceError%":l,"%Reflect%":"undefined"==typeof Reflect?r:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?r:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&h&&w?w((new Set)[Symbol.iterator]()):r,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":h&&w?w(""[Symbol.iterator]()):r,"%Symbol%":h?Symbol:r,"%SyntaxError%":s,"%ThrowTypeError%":g,"%TypedArray%":y,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?r:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?r:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?r:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?r:Uint32Array,"%URIError%":u,"%WeakMap%":"undefined"==typeof WeakMap?r:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?r:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?r:WeakSet};if(w)try{null.error}catch(e){var v=w(w(e));x["%Error.prototype%"]=v}var q=function e(t){var n;if("%AsyncFunction%"===t)n=d("async function () {}");else if("%GeneratorFunction%"===t)n=d("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=d("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var a=e("%AsyncGenerator%");a&&w&&(n=w(a.prototype))}return x[t]=n,n},E={__proto__:null,"%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"]},S=n(6743),O=n(9957),A=S.call(Function.call,Array.prototype.concat),R=S.call(Function.apply,Array.prototype.splice),j=S.call(Function.call,String.prototype.replace),k=S.call(Function.call,String.prototype.slice),T=S.call(Function.call,RegExp.prototype.exec),I=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,P=/\\(\\)?/g,C=function(e,t){var n,r=e;if(O(E,r)&&(r="%"+(n=E[r])[0]+"%"),O(x,r)){var a=x[r];if(a===b&&(a=q(r)),void 0===a&&!t)throw new c("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:r,value:a}}throw new s("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new c('"allowMissing" argument must be a boolean');if(null===T(/^%?[^%]*%?$/,e))throw new s("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(e){var t=k(e,0,1),n=k(e,-1);if("%"===t&&"%"!==n)throw new s("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new s("invalid intrinsic syntax, expected opening `%`");var r=[];return j(e,I,(function(e,t,n,a){r[r.length]=n?j(a,P,"$1"):t||e})),r}(e),r=n.length>0?n[0]:"",a=C("%"+r+"%",t),i=a.name,o=a.value,l=!1,u=a.alias;u&&(r=u[0],R(n,A([0,1],u)));for(var _=1,d=!0;_=n.length){var m=p(o,f);o=(d=!!m)&&"get"in m&&!("originalValue"in m.get)?m.get:o[f]}else d=O(o,f),o=o[f];d&&!l&&(x[i]=o)}}return o}},5795:(e,t,n)=>{"use strict";var r=n(453)("%Object.getOwnPropertyDescriptor%",!0);if(r)try{r([],"length")}catch(e){r=null}e.exports=r},592:(e,t,n)=>{"use strict";var r=n(655),a=function(){return!!r};a.hasArrayLengthDefineBug=function(){if(!r)return null;try{return 1!==r([],"length",{value:1}).length}catch(e){return!0}},e.exports=a},24:e=>{"use strict";var t={__proto__:null,foo:{}},n=Object;e.exports=function(){return{__proto__:t}.foo===t.foo&&!(t instanceof n)}},4039:(e,t,n)=>{"use strict";var r="undefined"!=typeof Symbol&&Symbol,a=n(1333);e.exports=function(){return"function"==typeof r&&"function"==typeof Symbol&&"symbol"==typeof r("foo")&&"symbol"==typeof Symbol("bar")&&a()}},1333: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"),n=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(n))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 r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var a=Object.getOwnPropertyDescriptor(e,t);if(42!==a.value||!0!==a.enumerable)return!1}return!0}},9092:(e,t,n)=>{"use strict";var r=n(1333);e.exports=function(){return r()&&!!Symbol.toStringTag}},9957:(e,t,n)=>{"use strict";var r=Function.prototype.call,a=Object.prototype.hasOwnProperty,i=n(6743);e.exports=i.call(r,a)},6698: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 n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},7244:(e,t,n)=>{"use strict";var r=n(9092)(),a=n(8075)("Object.prototype.toString"),i=function(e){return!(r&&e&&"object"==typeof e&&Symbol.toStringTag in e)&&"[object Arguments]"===a(e)},o=function(e){return!!i(e)||null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Array]"!==a(e)&&"[object Function]"===a(e.callee)},l=function(){return i(arguments)}();i.isLegacyArguments=o,e.exports=l?i:o},9600:e=>{"use strict";var t,n,r=Function.prototype.toString,a="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof a&&"function"==typeof Object.defineProperty)try{t=Object.defineProperty({},"length",{get:function(){throw n}}),n={},a((function(){throw 42}),null,t)}catch(e){e!==n&&(a=null)}else a=null;var i=/^\s*class\b/,o=function(e){try{var t=r.call(e);return i.test(t)}catch(e){return!1}},l=function(e){try{return!o(e)&&(r.call(e),!0)}catch(e){return!1}},s=Object.prototype.toString,c="function"==typeof Symbol&&!!Symbol.toStringTag,u=!(0 in[,]),_=function(){return!1};if("object"==typeof document){var d=document.all;s.call(d)===s.call(document.all)&&(_=function(e){if((u||!e)&&(void 0===e||"object"==typeof e))try{var t=s.call(e);return("[object HTMLAllCollection]"===t||"[object HTML document.all class]"===t||"[object HTMLCollection]"===t||"[object Object]"===t)&&null==e("")}catch(e){}return!1})}e.exports=a?function(e){if(_(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{a(e,null,t)}catch(e){if(e!==n)return!1}return!o(e)&&l(e)}:function(e){if(_(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(c)return l(e);if(o(e))return!1;var t=s.call(e);return!("[object Function]"!==t&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t))&&l(e)}},8184:(e,t,n)=>{"use strict";var r,a=Object.prototype.toString,i=Function.prototype.toString,o=/^\s*(?:function)?\*/,l=n(9092)(),s=Object.getPrototypeOf;e.exports=function(e){if("function"!=typeof e)return!1;if(o.test(i.call(e)))return!0;if(!l)return"[object GeneratorFunction]"===a.call(e);if(!s)return!1;if(void 0===r){var t=function(){if(!l)return!1;try{return Function("return function*() {}")()}catch(e){}}();r=!!t&&s(t)}return s(e)===r}},3003:e=>{"use strict";e.exports=function(e){return e!=e}},4133:(e,t,n)=>{"use strict";var r=n(487),a=n(8452),i=n(3003),o=n(6642),l=n(2464),s=r(o(),Number);a(s,{getPolyfill:o,implementation:i,shim:l}),e.exports=s},6642:(e,t,n)=>{"use strict";var r=n(3003);e.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:r}},2464:(e,t,n)=>{"use strict";var r=n(8452),a=n(6642);e.exports=function(){var e=a();return r(Number,{isNaN:e},{isNaN:function(){return Number.isNaN!==e}}),e}},5680:(e,t,n)=>{"use strict";var r=n(5767);e.exports=function(e){return!!r(e)}},9211:e=>{"use strict";var t=function(e){return e!=e};e.exports=function(e,n){return 0===e&&0===n?1/e==1/n:e===n||!(!t(e)||!t(n))}},7653:(e,t,n)=>{"use strict";var r=n(8452),a=n(487),i=n(9211),o=n(9394),l=n(6576),s=a(o(),Object);r(s,{getPolyfill:o,implementation:i,shim:l}),e.exports=s},9394:(e,t,n)=>{"use strict";var r=n(9211);e.exports=function(){return"function"==typeof Object.is?Object.is:r}},6576:(e,t,n)=>{"use strict";var r=n(9394),a=n(8452);e.exports=function(){var e=r();return a(Object,{is:e},{is:function(){return Object.is!==e}}),e}},8875:(e,t,n)=>{"use strict";var r;if(!Object.keys){var a=Object.prototype.hasOwnProperty,i=Object.prototype.toString,o=n(1093),l=Object.prototype.propertyIsEnumerable,s=!l.call({toString:null},"toString"),c=l.call((function(){}),"prototype"),u=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],_=function(e){var t=e.constructor;return t&&t.prototype===e},d={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!d["$"+e]&&a.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{_(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();r=function(e){var t=null!==e&&"object"==typeof e,n="[object Function]"===i.call(e),r=o(e),l=t&&"[object String]"===i.call(e),d=[];if(!t&&!n&&!r)throw new TypeError("Object.keys called on a non-object");var f=c&&n;if(l&&e.length>0&&!a.call(e,0))for(var g=0;g0)for(var h=0;h{"use strict";var r=Array.prototype.slice,a=n(1093),i=Object.keys,o=i?function(e){return i(e)}:n(8875),l=Object.keys;o.shim=function(){if(Object.keys){var e=function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2);e||(Object.keys=function(e){return a(e)?l(r.call(e)):l(e)})}else Object.keys=o;return Object.keys||o},e.exports=o},1093:e=>{"use strict";var t=Object.prototype.toString;e.exports=function(e){var n=t.call(e),r="[object Arguments]"===n;return r||(r="[object Array]"!==n&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===t.call(e.callee)),r}},8403:(e,t,n)=>{"use strict";var r=n(1189),a=n(1333)(),i=n(8075),o=Object,l=i("Array.prototype.push"),s=i("Object.prototype.propertyIsEnumerable"),c=a?Object.getOwnPropertySymbols:null;e.exports=function(e,t){if(null==e)throw new TypeError("target must be an object");var n=o(e);if(1===arguments.length)return n;for(var i=1;i{"use strict";var r=n(8403);e.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),n={},r=0;r{"use strict";e.exports=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]},5606:e=>{var t,n,r=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var l,s=[],c=!1,u=-1;function _(){c&&l&&(c=!1,l.length?s=l.concat(s):u=-1,s.length&&d())}function d(){if(!c){var e=o(_);c=!0;for(var t=s.length;t;){for(l=s,s=[];++u1)for(var n=1;n{"use strict";var r=n(453),a=n(41),i=n(592)(),o=n(5795),l=n(9675),s=r("%Math.floor%");e.exports=function(e,t){if("function"!=typeof e)throw new l("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||s(t)!==t)throw new l("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],r=!0,c=!0;if("length"in e&&o){var u=o(e,"length");u&&!u.configurable&&(r=!1),u&&!u.writable&&(c=!1)}return(r||c||!n)&&(i?a(e,"length",t,!0,!0):a(e,"length",t)),e}},1135:e=>{e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},9032:(e,t,n)=>{"use strict";var r=n(7244),a=n(8184),i=n(5767),o=n(5680);function l(e){return e.call.bind(e)}var s="undefined"!=typeof BigInt,c="undefined"!=typeof Symbol,u=l(Object.prototype.toString),_=l(Number.prototype.valueOf),d=l(String.prototype.valueOf),p=l(Boolean.prototype.valueOf);if(s)var f=l(BigInt.prototype.valueOf);if(c)var g=l(Symbol.prototype.valueOf);function h(e,t){if("object"!=typeof e)return!1;try{return t(e),!0}catch(e){return!1}}function m(e){return"[object Map]"===u(e)}function w(e){return"[object Set]"===u(e)}function b(e){return"[object WeakMap]"===u(e)}function y(e){return"[object WeakSet]"===u(e)}function x(e){return"[object ArrayBuffer]"===u(e)}function v(e){return"undefined"!=typeof ArrayBuffer&&(x.working?x(e):e instanceof ArrayBuffer)}function q(e){return"[object DataView]"===u(e)}function E(e){return"undefined"!=typeof DataView&&(q.working?q(e):e instanceof DataView)}t.isArgumentsObject=r,t.isGeneratorFunction=a,t.isTypedArray=o,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):o(e)||E(e)},t.isUint8Array=function(e){return"Uint8Array"===i(e)},t.isUint8ClampedArray=function(e){return"Uint8ClampedArray"===i(e)},t.isUint16Array=function(e){return"Uint16Array"===i(e)},t.isUint32Array=function(e){return"Uint32Array"===i(e)},t.isInt8Array=function(e){return"Int8Array"===i(e)},t.isInt16Array=function(e){return"Int16Array"===i(e)},t.isInt32Array=function(e){return"Int32Array"===i(e)},t.isFloat32Array=function(e){return"Float32Array"===i(e)},t.isFloat64Array=function(e){return"Float64Array"===i(e)},t.isBigInt64Array=function(e){return"BigInt64Array"===i(e)},t.isBigUint64Array=function(e){return"BigUint64Array"===i(e)},m.working="undefined"!=typeof Map&&m(new Map),t.isMap=function(e){return"undefined"!=typeof Map&&(m.working?m(e):e instanceof Map)},w.working="undefined"!=typeof Set&&w(new Set),t.isSet=function(e){return"undefined"!=typeof Set&&(w.working?w(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)},y.working="undefined"!=typeof WeakSet&&y(new WeakSet),t.isWeakSet=function(e){return y(e)},x.working="undefined"!=typeof ArrayBuffer&&x(new ArrayBuffer),t.isArrayBuffer=v,q.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&q(new DataView(new ArrayBuffer(1),0,1)),t.isDataView=E;var S="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function O(e){return"[object SharedArrayBuffer]"===u(e)}function A(e){return void 0!==S&&(void 0===O.working&&(O.working=O(new S)),O.working?O(e):e instanceof S)}function R(e){return h(e,_)}function j(e){return h(e,d)}function k(e){return h(e,p)}function T(e){return s&&h(e,f)}function I(e){return c&&h(e,g)}t.isSharedArrayBuffer=A,t.isAsyncFunction=function(e){return"[object AsyncFunction]"===u(e)},t.isMapIterator=function(e){return"[object Map Iterator]"===u(e)},t.isSetIterator=function(e){return"[object Set Iterator]"===u(e)},t.isGeneratorObject=function(e){return"[object Generator]"===u(e)},t.isWebAssemblyCompiledModule=function(e){return"[object WebAssembly.Module]"===u(e)},t.isNumberObject=R,t.isStringObject=j,t.isBooleanObject=k,t.isBigIntObject=T,t.isSymbolObject=I,t.isBoxedPrimitive=function(e){return R(e)||j(e)||k(e)||T(e)||I(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")}})}))},537:(e,t,n)=>{var r=n(5606),a=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r=a)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),l=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),h(n)?r.showHidden=n:n&&t._extend(r,n),y(r.showHidden)&&(r.showHidden=!1),y(r.depth)&&(r.depth=2),y(r.colors)&&(r.colors=!1),y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=u),d(r,e,r.depth)}function u(e,t){var n=c.styles[t];return n?"["+c.colors[n][0]+"m"+e+"["+c.colors[n][1]+"m":e}function _(e,t){return e}function d(e,n,r){if(e.customInspect&&n&&S(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var a=n.inspect(r,e);return b(a)||(a=d(e,a,r)),a}var i=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(b(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return w(t)?e.stylize(""+t,"number"):h(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}(e,n);if(i)return i;var o=Object.keys(n),l=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(n)),E(n)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return p(n);if(0===o.length){if(S(n)){var s=n.name?": "+n.name:"";return e.stylize("[Function"+s+"]","special")}if(x(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(q(n))return e.stylize(Date.prototype.toString.call(n),"date");if(E(n))return p(n)}var c,u="",_=!1,v=["{","}"];return g(n)&&(_=!0,v=["[","]"]),S(n)&&(u=" [Function"+(n.name?": "+n.name:"")+"]"),x(n)&&(u=" "+RegExp.prototype.toString.call(n)),q(n)&&(u=" "+Date.prototype.toUTCString.call(n)),E(n)&&(u=" "+p(n)),0!==o.length||_&&0!=n.length?r<0?x(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),c=_?function(e,t,n,r,a){for(var i=[],o=0,l=t.length;o60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(c,u,v)):v[0]+u+v[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,n,r,a,i){var o,l,s;if((s=Object.getOwnPropertyDescriptor(t,a)||{value:t[a]}).get?l=s.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):s.set&&(l=e.stylize("[Setter]","special")),j(r,a)||(o="["+a+"]"),l||(e.seen.indexOf(s.value)<0?(l=m(n)?d(e,s.value,null):d(e,s.value,n-1)).indexOf("\n")>-1&&(l=i?l.split("\n").map((function(e){return" "+e})).join("\n").slice(2):"\n"+l.split("\n").map((function(e){return" "+e})).join("\n")):l=e.stylize("[Circular]","special")),y(o)){if(i&&a.match(/^\d+$/))return l;(o=JSON.stringify(""+a)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.slice(1,-1),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+l}function g(e){return Array.isArray(e)}function h(e){return"boolean"==typeof e}function m(e){return null===e}function w(e){return"number"==typeof e}function b(e){return"string"==typeof e}function y(e){return void 0===e}function x(e){return v(e)&&"[object RegExp]"===O(e)}function v(e){return"object"==typeof e&&null!==e}function q(e){return v(e)&&"[object Date]"===O(e)}function E(e){return v(e)&&("[object Error]"===O(e)||e instanceof Error)}function S(e){return"function"==typeof e}function O(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(),!o[e])if(l.test(e)){var n=r.pid;o[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else o[e]=function(){};return o[e]},t.inspect=c,c.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]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.types=n(9032),t.isArray=g,t.isBoolean=h,t.isNull=m,t.isNullOrUndefined=function(e){return null==e},t.isNumber=w,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=y,t.isRegExp=x,t.types.isRegExp=x,t.isObject=v,t.isDate=q,t.types.isDate=q,t.isError=E,t.types.isNativeError=E,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=n(1135);var R=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function j(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,n;console.log("%s - %s",(n=[A((e=new Date).getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":"),[e.getDate(),R[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=n(6698),t._extend=function(e,t){if(!t||!v(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};var k="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function T(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(k&&e[k]){var t;if("function"!=typeof(t=e[k]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,k,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),a=[],i=0;i{"use strict";var r=n(2682),a=n(9209),i=n(487),o=n(8075),l=n(5795),s=o("Object.prototype.toString"),c=n(9092)(),u="undefined"==typeof globalThis?n.g:globalThis,_=a(),d=o("String.prototype.slice"),p=Object.getPrototypeOf,f=o("Array.prototype.indexOf",!0)||function(e,t){for(var n=0;n-1?t:"Object"===t&&function(e){var t=!1;return r(g,(function(n,r){if(!t)try{n(e),t=d(r,1)}catch(e){}})),t}(e)}return l?function(e){var t=!1;return r(g,(function(n,r){if(!t)try{"$"+n(e)===r&&(t=d(r,1))}catch(e){}})),t}(e):null}},785:(e,t,n)=>{var r=n(5606);const a=n(2196),i=n(9175),o=n(7507),l=n(9022),s=n(6945),c=n(4285),u=n(3568),_=n(3222),d=-1,p=/^([0-9]+)(\.[0-9]+)?$/,f="quoted_rfc",g="quoted",h=1;class m extends Error{}function w(e,t=null){if(!e)throw t||(t="Assertion error"),new m(t)}function b(e,t,n,r){let a=r?_(e):e.length;if(n.has_wide_chars=n.has_wide_chars||a!=e.length,n.max_total_length=Math.max(n.max_total_length,a),n.max_int_length==d)return;let i=p.exec(e);if(null===i)return void(!t&&e.length&&(n.max_int_length=d,n.max_fractional_length=d));let o=i[1].length;n.max_int_length=Math.max(n.max_int_length,o);let l=void 0===i[2]?0:i[2].length;n.max_fractional_length=Math.max(n.max_fractional_length,l)}function y(e,t,n,r){e=e.trim();let a=n.has_wide_chars?_(e):e.length;if(n.max_int_length==d){let t=Math.max(n.max_total_length-a,0);return r?e:e+" ".repeat(t+h)}if(t&&null===p.exec(e)){let t=Math.max(n.max_total_length-a,0);return r?e:e+" ".repeat(t+h)}let i=e.indexOf("."),o=-1==i?e.length:i,l=-1==i?0:e.length-i,s=Math.max(n.max_int_length-o,0),c=Math.max(n.max_fractional_length-l),u=r?"":" ".repeat(c+h);return" ".repeat(s)+e+u}function x(e,t,n,r,a){let i=y(e,t,n,a);return r&&(i=" ".repeat(n.start_offset)+i),i}class v{constructor(e,t){this.records=e,this.comments=t,this.nr=0,this.next_comment=0}get_next(){if(this.has_comments_left()&&(!this.has_records_left()||this.comments[this.next_comment].record_num<=this.nr)){let e=[null,this.comments[this.next_comment].comment_text];return this.next_comment+=1,e}if(this.has_records_left()){let e=[this.records[this.nr],null];return this.nr+=1,e}return[null,null]}has_comments_left(){return this.next_comment=this.records.length)return null;let e=this.records[this.next_record_index];return this.next_record_index+=1,e}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}`),this.fields_info.size>1&&e.push(function(e,t){let[n,r,a,i]=l.sample_first_two_inconsistent_records(t),o=`Number of fields in "${e}" table is not consistent: `;return o+=`e.g. record ${n+1} -> ${r} fields, record ${a+1} -> ${i} fields`,o}(this.table_name,this.fields_info)),e}}class A extends l.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 S("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 c.quote_field(String(e),t)})).join(this.delim)}quoted_join_rfc(e){let t=this.delim;return e.map((function(e){return c.rfc_quote_field(String(e),t)})).join(this.delim)}mono_join(e){if(e.length>1)throw new S('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;ta&&r+1{a||(a=!0,r.close(),o(e))})),r.on("error",(e=>{l(e)})),s},e.exports.rbql_query_web=async function(e,t,n,r,a,i,o,s,c=null){let u=new R,_=new O(t,n,r,s,c),d=new A(a,i);return await l.query(e,_,d,o,u,""),d.output_lines},e.exports.rbql_query_node=async function(e,t,n,c,u,_,d,p,f,g,h=!1,m=null,w="",b=null){let y=null,x=null;b&&b.bulk_read&&n?x=n:y=null===n?r.stdin:i.createReadStream(n);let[v,q]=null===_?[r.stdout,!1]:[i.createWriteStream(_),!0];if('"'==c&&"quoted"==u)throw new S('Double quote delimiter is incompatible with "quoted" policy');if("latin-1"==f&&(f="binary"),!s.is_ascii(t)&&"binary"==f)throw new S("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");if(!(s.is_ascii(c)&&s.is_ascii(d)||"binary"!=f))throw new S("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");let E=o.join(a.homedir(),".rbql_init_source.js");""==w&&i.existsSync(E)&&(w=s.read_user_init_code(E));let O=n?o.dirname(n):null,A=new j(e,O,c,u,f,h,m,b),R=new s.CSVRecordIterator(y,x,f,c,u,h,m),k=new s.CSVWriter(v,q,f,d,p);await l.query(t,R,k,g,A,w),A.get_warnings(g)},e.exports.get_header_line=function(e,t){const n=e.lineCount;for(let r=0;r=n.length);t++){let o=!1,s=e[t].split("\n");for(let c=0;c0&&(a.push(l.join(r)),l=[],o=!0);let u=t+1==e.length||s.length>1&&c+10&&(_.push(r.join(t)),r=[]);let n=a[e].trim();n.length!=a[e].length&&(d=!0),r.push(n)}}_.push(r.join(t))}return d?[_.join("\n"),null]:[null,null]},e.exports.calc_column_stats=function(e,t,n,r,a){let[i,o,l,s,c,_]=u.parse_document_records(e,t,n,r,!0,-1,!0,!0);if(null!==s)return[null,s+1,null,null];let p=[],f=!0,g=!1;for(let e of i){for(let t=0;t1&&(p[t].max_int_length=d,p[t].max_fractional_length=d);for(let e of r)b(e.trim(),f,p[t],g)}f=!1}return[p,null,i,_]},e.exports.adjust_column_stats=function(e,t){let n=[];for(let r of e){if(r.max_int_length<=0&&(r.max_int_length=-1,r.max_fractional_length=-1),r.max_int_length>0&&(r.max_int_length+r.max_fractional_length>r.max_total_length&&(r.max_total_length=r.max_int_length+r.max_fractional_length),r.max_total_length-r.max_fractional_length>r.max_int_length&&(r.max_int_length=r.max_total_length-r.max_fractional_length),r.max_total_length!=r.max_int_length+r.max_fractional_length))return null;let e=n.length?n[n.length-1]:null;r.start_offset=null===e?0:e.start_offset+e.max_total_length+h+t,n.push(r)}return n},e.exports.update_subcomponent_stats=b,e.exports.align_field=y,e.exports.rfc_align_field=x,e.exports.assert=w,e.exports.get_field_by_line_position=P,e.exports.get_cursor_position_info=function(e,t,n,r,a,i){return null===r?null:r==f?function(e,t,n,r,a){let i=new e.Range(Math.max(a.line-20,0),0,a.line+20,0),o=I(e,t,n,r,i),l=null;for(let e of o)if(e.hasOwnProperty("comment_range"))e.comment_range.contains(a)&&(l={is_comment:!0});else for(let t=0;t250&&(t[e]=t[e].substr(0,250)+"###UI_STRING_TRIM_MARKER###")}t.preview_records=d,t.actual_start_record=e.requested_start_record},e.exports.parse_document_range_rfc=I,e.exports.sample_first_two_inconsistent_records=l.sample_first_two_inconsistent_records,e.exports.is_opening_rfc_line=T,e.exports.show_lint_status_bar_button=function(e,t,n,r){const a="#f44242";let i=`${n}.${r}`;if(!t.lint_results.has(i))return;var o=t.lint_results.get(i);t.lint_status_bar_button||(t.lint_status_bar_button=e.window.createStatusBarItem(e.StatusBarAlignment.Left)),t.lint_status_bar_button.text="CSVLint";let s="";if(o.is_processing)t.lint_status_bar_button.color="#A0A0A0",t.lint_status_bar_button.text="$(clock) CSVLint",s="Processing";else if(Number.isInteger(o.first_defective_line))s=`Error. Line ${o.first_defective_line} has formatting error: double quote chars are not consistent`,t.lint_status_bar_button.color=a,t.lint_status_bar_button.text="$(error) CSVLint";else if(o.fields_info&&o.fields_info.size>1){let[e,n,r,i]=l.sample_first_two_inconsistent_records(o.fields_info);s=`Error. Number of fields is not consistent: e.g. record ${e+1} has ${n} fields, and record ${r+1} has ${i} fields`,t.lint_status_bar_button.color=a,t.lint_status_bar_button.text="$(error) CSVLint"}else Number.isInteger(o.first_trailing_space_line)?(s=`Leading/Trailing spaces detected: e.g. at line ${o.first_trailing_space_line+1}. Run "Shrink" command to remove them`,t.lint_status_bar_button.color="#ffff28",t.lint_status_bar_button.text="$(alert) CSVLint"):(w(o.is_ok),t.lint_status_bar_button.color="#62f442",t.lint_status_bar_button.text="$(pass) CSVLint",s="OK");t.lint_status_bar_button.tooltip=s+"\nClick to recheck",t.lint_status_bar_button.command="rainbow-csv.CSVLint",t.lint_status_bar_button.show()},e.exports.get_cursor_position_if_unambiguous=function(e){let t=e.selections;if(!t||1!=t.length)return null;let n=t[0],r=n.active;return r.isEqual(n.anchor)?r:null},e.exports.RecordCommentMerger=v,e.exports.generate_column_edit_selections=function(e,t,n,r,a,i,o){let[l,s,c,_,d,p]=u.parse_document_records(t,n,r,a,!0,-1,!0,!0);if(null!==_)return[null,`Unable to enter column edit mode: quoting error at line ${_+1}`,null];if(l.length+p.length!=t.lineCount)return[null,"Column edit mode is not supported for files with multiline fields",null];let h=0,m=[],b=null,y=new v(l,p);for(;y.has_entries_left();){let[t,a]=y.get_next();if(w(null===a!=(null===t)),null!==t){if(o>=t.length)return[null,`Line ${h+1} doesn't have field number ${o+1}`,null];let a=t.slice(0,o).join("").length+o*n.length,l=t.slice(0,o+1).join("").length+o*n.length,s=t.join(n);b||"ce_before"!=i||r!=g&&r!=f||-1==s.substring(a-2,a+2).indexOf('"')||(b=`Be careful, cursor at line ${h+1} has a double quote is in proximity.`),b||"ce_after"!=i||r!=g&&r!=f||-1==s.substring(l-2,l+2).indexOf('"')||(b=`Be careful, cursor at line ${h+1} has a double quote is in proximity.`),b||"ce_select"!=i||a!=l||(b=`Be careful, Field ${o+1} at line ${h+1} is empty.`);let c=new e.Position(h,a),u=new e.Position(h,l);"ce_before"==i&&m.push(new e.Selection(c,c)),"ce_after"==i&&m.push(new e.Selection(u,u)),"ce_select"==i&&m.push(new e.Selection(c,u))}h+=1}return[m,null,b]}},4285:e=>{let t='"((?:[^"]*"")*[^"]*)"',n=new RegExp("^"+t),r=new RegExp("^ *"+t+" *");function a(e,t,a,i,o,l){var s=!1;let c=e.substring(o),u=(i?r:n).exec(c);if(null!==u){let n=u[0].length;if(o+n==e.length||e[o+n]==t)return a?l.push(u[0]):l.push(u[1].replace(/""/g,'"')),[o+n+1,!1];s=!0}var _=e.indexOf(t,o);-1==_&&(_=e.length);var d=e.substring(o,_);return s=s||-1!=d.indexOf('"'),l.push(d),[_+1,s]}function i(e,t,n=!1){if(-1==e.indexOf('"'))return[e.split(t),!1];var r=[],i=0,o=!1;let l=" "!=t;for(;i1,this.has_full_record}is_inside_multiline_record(){return this.rfc_line_buffer.length&&!this.has_full_record}get_full_line(e){return this.rfc_line_buffer.join(e)}get_num_lines_in_record(){return this.rfc_line_buffer.length}reset(){this.rfc_line_buffer=[],this.has_full_record=!1,this.has_comment_line=!1}}},9022:(__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,n){return e.split(t).join(n)}class RBQLContext{constructor(e,t,n,r){this.query_text=e,this.input_iterator=t,this.writer=n,this.user_init_code=r,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.27.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=[],n=0,r=[];for(let a=0;ae.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 n="__RBQL_INTERNAL_STAR",r=/^[_a-zA-Z][_a-zA-Z0-9]*$/.exec(e),a=/^([ab])\.([_a-zA-Z][_a-zA-Z0-9]*)$/.exec(e),i=/^([ab])\[([0-9]+)\]$/.exec(e),o=/^([ab])\[___RBQL_STRING_LITERAL([0-9]+)___\]$/.exec(e),l=/^(.*) (as|AS) +([a-zA-Z][a-zA-Z0-9_]*) *$/.exec(e);if(null!==l)return{table_name:null,column_index:null,column_name:null,is_star:!1,alias_name:l[3]};if(null!==r){if(e==n)return{table_name:null,column_index:null,column_name:null,is_star:!0,alias_name:null};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,alias_name:null}:{table_name:null,column_index:null,column_name:e,is_star:!1,alias_name:null}}if(null!==a){let e=a[1],t=a[2];return t==n?{table_name:e,column_index:null,column_name:null,is_star:!0,alias_name:null}:{table_name:null,column_index:null,column_name:t,is_star:!1,alias_name:null}}if(null!=i)return{table_name:i[1],column_index:parseInt(i[2])-1,column_name:null,is_star:!1,alias_name:null};if(null!=o){o[1];let e=o[2];if(ecolumn_info_from_text_span(e,t)))}function stable_compare(e,t){for(var n=0;n=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),n=this.records.get(t);return n?n[0]+=1:this.records.set(t,[1,e]),!0}async finish(){for(var[e,t]of this.records){let[e,n]=t;if(n.unshift(e),!await this.subwriter.write(n))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;te instanceof UnnestMarker));for(var i=0;ii+e)),r.slice(0,e).concat(a).concat(r.slice(e+1)).join("\n")+"\n"}assert(!1)}function generate_main_loop_code(e){let t=null!==e.select_expression,n=null!==e.join_map,r=null===e.where_expression?"true":e.where_expression,a=null===e.aggregation_key_expression?"null":e.aggregation_key_expression,i=null===e.sort_key_expression?"null":e.sort_key_expression,o=embed_code(MAIN_LOOP_BODY,"__USER_INIT_CODE__",e.user_init_code);return t?(n?(o=embed_code(embed_code(o,"__CODE__",PROCESS_SELECT_JOIN),"__CODE__",PROCESS_SELECT_COMMON),o=embed_expression(o,"__RBQLMP__lhs_join_var_expression",e.lhs_join_var_expression)):o=embed_code(embed_code(o,"__CODE__",PROCESS_SELECT_SIMPLE),"__CODE__",PROCESS_SELECT_COMMON),o=embed_code(o,"__RBQLMP__variables_init_code",e.variables_init_code),o=embed_expression(o,"__RBQLMP__select_expression",e.select_expression),o=embed_expression(o,"__RBQLMP__where_expression",r),o=embed_expression(o,"__RBQLMP__aggregation_key_expression",a),o=embed_expression(o,"__RBQLMP__sort_key_expression",i)):(n?(o=embed_code(o,"__CODE__",PROCESS_UPDATE_JOIN),o=embed_expression(o,"__RBQLMP__lhs_join_var_expression",e.lhs_join_var_expression)):o=embed_code(o,"__CODE__",PROCESS_UPDATE_SIMPLE),o=embed_code(o,"__RBQLMP__variables_init_code",e.variables_init_code),o=embed_code(o,"__RBQLMP__update_expressions",e.update_expressions),o=embed_expression(o,"__RBQLMP__where_expression",r)),"(async () => {"+o+"})()"}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 n=[];let r=null;for(;null!==(r=e.exec(t));)n.push(r);return n}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 n=0;ne[1]));for(let e of i){let i=n.indexOf(e);if(-1==i)throw new RbqlParsingError(`Unable to find column "${e}" in ${"a"==t?"input":"join"} ${r}`);a[`${t}.${e}`]={initialize:!0,index:i}}}function map_variables_directly(e,t,n){for(let r=0;r1)throw new RbqlParsingError(`More than one "${i}" statements found`);assert(1==o.length);var l=o[0],s=l[0];n.push([l.index,l.index+s.length,i]);break}}return n.sort((function(e,t){return e[0]-t[0]})),n}function separate_actions(e){e=str_strip(e);var t={};let n=/^(.*) *[Ww][Ii][Tt][Hh] *\(([a-z]{4,20})\) *$/.exec(e);null!==n&&(e=n[1],t[WITH]=n[2]);for(var r=locate_statements(e),a=0;ae-t)),[null===r?null:select_except(r,i),`select_except(record_a, [${i.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 n=[];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`);n.push(-1===e?this.nr:t[e])}return JSON.stringify(n)}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 n=this.polymorphic_get_key(this.nr,e),r=this.hash_map.get(n);void 0===r?this.hash_map.set(n,[[this.nr,t,e]]):r.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,n){null===e&&assert(null===t);let r=!1,a=!1;for(let e of n)r=r||null!==e&&e.is_star,a=a||null!==e&&null!==e.alias_name;if(null===e){if(r&&a)throw new RbqlParsingError("Using both * (star) and AS alias in the same query is not allowed for input tables without header");if(!a)return null;e=[],t=[]}null===t&&(t=[]);let i=[];for(let r of n)null===r?i.push("col"+(i.length+1)):r.is_star?null===r.table_name?i=i.concat(e).concat(t):"a"===r.table_name?i=i.concat(e):"b"===r.table_name&&(i=i.concat(t)):null!==r.column_name?i.push(r.column_name):null!==r.alias_name?i.push(r.alias_name):null!==r.column_index?"a"==r.table_name&&r.column_index1);let[n,r]=t[0],[a,i]=t[1];return[r,n,i,a]}function make_inconsistent_num_fields_warning(e,t){let[n,r,a,i]=sample_first_two_inconsistent_records(t),o=`Number of fields in "${e}" table is not consistent: `;return o+=`e.g. record ${n} -> ${r} fields, record ${a} -> ${i} fields`,o}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,n=!0,r="a"){super(),this.table=e,this.column_names=t,this.normalize_column_names=n,this.variable_prefix=r,this.nr=0,this.fields_info=new Map,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.has(t)||this.fields_info.set(t,this.nr),e}get_warnings(){return this.fields_info.size>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,n=!0,r="b"){super(),this.table=e,this.table_id=r,this.column_names=t,this.normalize_column_names=n}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,n,r){e=cleanup_query(e);var[a,i]=separate_string_literals(e),o=separate_actions(a=remove_redundant_table_name(a));o.hasOwnProperty(WITH)&&t.handle_query_modifier(o[WITH]);var l=await t.get_variables_map(e);if(o.hasOwnProperty(ORDER_BY)&&o.hasOwnProperty(UPDATE))throw new RbqlParsingError('"ORDER BY" is not allowed in "UPDATE" queries');if(o.hasOwnProperty(GROUP_BY)){if(o.hasOwnProperty(ORDER_BY)||o.hasOwnProperty(UPDATE))throw new RbqlParsingError('"ORDER BY", "UPDATE" and "DISTINCT" keywords are not allowed in aggregate queries');r.aggregation_key_expression="["+combine_string_literals(o[GROUP_BY].text,i)+"]",r.aggregation_stage=1}let s=await t.get_header(),c=null,u=null;if(o.hasOwnProperty(JOIN)){var[_,d]=parse_join_expression(o[JOIN].text);if(null===n)throw new RbqlParsingError("JOIN operations are not supported by the application");let t=n.get_iterator_by_table_id(_);if(!t)throw new RbqlParsingError(`Unable to find join table: "${_}"`);if(o.hasOwnProperty(WITH)&&t.handle_query_modifier(o[WITH]),c=await t.get_variables_map(e),u=await t.get_header(),null===s&&null!==u)throw new RbqlIOHandlingError("Inconsistent modes: Input table doesn't have a header while the Join table has a header");if(null!==s&&null===u)throw new RbqlIOHandlingError("Inconsistent modes: Input table has a header while the Join table doesn't have a header");let[a,p]=resolve_join_variables(l,c,d,i),f={JOIN:InnerJoiner,"INNER JOIN":InnerJoiner,"LEFT JOIN":LeftJoiner,"LEFT OUTER JOIN":LeftJoiner,"STRICT LEFT JOIN":StrictLeftJoiner}[o[JOIN].join_subtype];r.lhs_join_var_expression=1==a.length?a[0]:"JSON.stringify(["+a.join(",")+"])",r.join_map_impl=new HashJoinMap(t,p),await r.join_map_impl.build(),r.join_map=new f(r.join_map_impl)}if(r.variables_init_code=combine_string_literals(generate_init_statements(a,l,c," ".repeat(4)),i),o.hasOwnProperty(WHERE)){var p=o[WHERE].text;if(/[^>{var r=n(5606);const a=n(8364),i=n(9135),o=n(1820),l=n(537),s=n(9022),c=n(4285),u="Unable to decode input table as UTF-8. Use binary (latin-1) encoding instead";class _ extends Error{}class d extends Error{}function p(e,t=null){if(!e)throw t||(t="Assertion error"),new d(t)}function f(e){return/^[\x00-\x7F]*$/.test(e)}function g(e){return a.readFileSync(e,"utf-8")}function h(e,t){var n,r="~"===(n=t).charAt(0)?o.join(i.homedir(),n.slice(1)):n;if(a.existsSync(r))return r;if(e&&!o.isAbsolute(r)&&(r=o.join(e,r),a.existsSync(r)))return r;var l=function(e,t){for(var n=function(e){var t=null;try{t=a.readFileSync(e,"utf-8")}catch(e){return[]}for(var n=t.split("\n"),r=[],i=0;i1&&a.existsSync(l[1])?l[1]:null}class m{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 w extends s.RBQLInputIterator{constructor(e,t,n,r,a,i=!1,o=null,s="input",u="a"){super(),this.stream=e,this.csv_path=t,p(null===this.stream!=(null===this.csv_path)),this.encoding=n,this.delim=r,this.policy=a,this.has_header=i,this.first_record=null,this.first_record_should_be_emitted=!i,this.header_preread_complete=!1,this.table_name=s,this.variable_prefix=u,this.comment_prefix=o,this.decoder=null,"utf-8"==n&&null===this.csv_path&&(this.decoder=new l.TextDecoder(n,{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 Map,this.NR=0,this.NL=0,this.line_aggregator=new c.MultilineRecordAggregator(o),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 m,this.process_line_polymorphic="quoted_rfc"==a?this.process_partial_rfc_record_line:this.process_record_line_simple}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 s.parse_basic_variables(e,this.variable_prefix,t),s.parse_array_variables(e,this.variable_prefix,t),await this.preread_first_record(),this.has_header&&this.first_record&&(s.parse_attribute_variables(e,this.variable_prefix,this.first_record,"CSV header line",t),s.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,n){e.resolve_current_record=t,e.reject_current_record=n}));return this.try_resolve_next_record(),t}async get_all_records(e=null){let t=[];for(;;){let n=await this.get_record();if(null===n)break;if(t.push(n),e&&t.length>=e){this.stop();break}}return t}process_record_line_simple(e){this.comment_prefix&&e.startsWith(this.comment_prefix)||this.process_record_line(e)}process_record_line(e){this.NR+=1;var[t,n]=c.smart_split(e,this.delim,this.policy,!1);n&&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 r=t.length;this.fields_info.has(r)||this.fields_info.set(r,this.NR),this.produced_records_queue.enqueue(t),this.try_resolve_next_record()}process_partial_rfc_record_line(e){this.line_aggregator.add_line(e),this.line_aggregator.has_comment_line?this.line_aggregator.reset():this.line_aggregator.has_full_record&&(this.process_record_line(this.line_aggregator.get_full_line("\n")),this.line_aggregator.reset())}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 _(u)):this.store_or_propagate_exception(e))}else t=e.toString(this.encoding);let n=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 r=c.split_lines(t);r[0]=this.partially_decoded_line+r[0],p(0==n||0==r[0].length),this.partially_decoded_line=r.pop();for(let e=n;e{r?n(r):(e.process_data_bulk(a),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`),this.fields_info.size>1&&e.push(function(e,t){let[n,r,a,i]=s.sample_first_two_inconsistent_records(t),o=`Number of fields in "${e}" table is not consistent: `;return o+=`e.g. record ${n} -> ${r} fields, record ${a} -> ${i} fields`,o}(this.table_name,this.fields_info)),e}}class b extends s.RBQLOutputWriter{constructor(e,t,n,r,a,i="\n"){if(super(),this.stream=e,this.encoding=n,n&&this.stream.setDefaultEncoding(n),this.stream.on("error",(e=>{this.store_first_error(e)})),this.delim=r,this.policy=a,this.line_separator=i,this.sub_array_delim="|"==r?";":"|",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"==a)this.polymorphic_join=this.simple_join;else if("quoted"==a)this.polymorphic_join=this.quoted_join;else if("quoted_rfc"==a)this.polymorphic_join=this.quoted_join_rfc;else if("monocolumn"==a)this.polymorphic_join=this.mono_join;else{if("whitespace"!=a)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 c.quote_field(String(e),t)})).join(this.delim)}quoted_join_rfc(e){let t=this.delim;return e.map((function(e){return c.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{a()})):setTimeout((()=>{a()}),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 y extends s.RBQLTableRegistry{constructor(e,t,n,r,a=!1,i=null,o=null){super(),this.input_file_dir=e,this.delim=t,this.policy=n,this.encoding=r,this.has_header=a,this.comment_prefix=i,this.stream=null,this.record_iterator=null,this.options=o,this.bulk_input_path=null,this.table_path=null}get_iterator_by_table_id(e){if(this.table_path=h(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=a.createReadStream(this.table_path),this.record_iterator=new w(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 ${o.basename(this.table_path)} was also treated as header (and skipped)`)}}e.exports.is_ascii=f,e.exports.CSVRecordIterator=w,e.exports.CSVWriter=b,e.exports.FileSystemCSVRegistry=y,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=g,e.exports.query_csv=async function(e,t,n,l,c,u,d,p,h,m=!1,x=null,v="",q=null){let E=null,S=null;q&&q.bulk_read&&t?S=t:E=null===t?r.stdin:a.createReadStream(t);let[O,A]=null===c?[r.stdout,!1]:[a.createWriteStream(c),!0];if('"'==n&&"quoted"==l)throw new _('Double quote delimiter is incompatible with "quoted" policy');if("latin-1"==p&&(p="binary"),!f(e)&&"binary"==p)throw new _("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");if(!(f(n)&&f(u)||"binary"!=p))throw new _("To use non-ascii characters in query enable UTF-8 encoding instead of latin-1/binary");let R=o.join(i.homedir(),".rbql_init_source.js");""==v&&a.existsSync(R)&&(v=g(R));let j=t?o.dirname(t):null,k=new y(j,n,l,p,m,x,q),T=new w(E,S,p,n,l,m,x),I=new b(O,A,p,u,d);await s.query(e,T,I,h,k,v),k.get_warnings(h)},e.exports.RecordQueue=m,e.exports.exception_to_error_info=s.exception_to_error_info},7181:(e,t,n)=>{const r=n(4148),a=n(785),i=n(3568);class o{constructor(e,t){this.line=e,this.character=t}}class l{constructor(e,t){this.anchor=e,this.active=t}}class s{constructor(e,t,n,r){this.start=new o(e,t),this.end=new o(n,r)}contains(e){let t=e.line>this.start.line||e.line===this.start.line&&e.character>=this.start.character,n=e.line{"use strict";e.exports=require("vscode")},8364:()=>{},9135:()=>{},1820:()=>{},7349:()=>{},6510:()=>{},9175:()=>{},2196:()=>{},7507:()=>{},7560:()=>{},9209:(e,t,n)=>{"use strict";var r=n(6578),a="undefined"==typeof globalThis?n.g:globalThis;e.exports=function(){for(var e=[],t=0;t{var e=__webpack_exports__;const t=__webpack_require__(4148),n=__webpack_require__(7349),r=__webpack_require__(1398),a=(__webpack_require__(785),__webpack_require__(7181)),i=__webpack_require__(4012),o=void 0===n.homedir,l=6e3;function s(e){return new Promise((t=>setTimeout(t,e)))}async function c(){await s(200),await r.commands.executeCommand("cursorTop")}function u(e){console.log("###RAINBOW_CSV_UNIT_TEST_MESSAGE### "+e)}async function _(e){let[n,a,i,_]=[null,null,null,null];n=r.Uri.joinPath(e,"csv_files","countries_with_comments.csv"),a=await r.workspace.openTextDocument(n),i=await r.window.showTextDocument(a),await s(1e3),_=await r.commands.executeCommand("rainbow-csv.CSVLint"),t(!_.is_ok),await c(),await r.commands.executeCommand("cursorRightSelect"),await r.commands.executeCommand("cursorRightSelect"),await s(1e3),await r.commands.executeCommand("rainbow-csv.SetCommentPrefix"),await s(1500),_=await r.commands.executeCommand("rainbow-csv.CSVLint"),t(_.is_ok),await s(1e3),await r.commands.executeCommand("cursorTop"),await r.commands.executeCommand("cursorRight"),await r.commands.executeCommand("cursorRight"),await s(500),await r.commands.executeCommand("editor.action.commentLine"),_=await r.commands.executeCommand("rainbow-csv.CSVLint"),t(!_.is_ok),await s(1e3),await r.commands.executeCommand("editor.action.commentLine"),_=await r.commands.executeCommand("rainbow-csv.CSVLint"),t(_.is_ok),await s(1e3),await r.commands.executeCommand("undo"),await r.commands.executeCommand("undo"),await s(1e3),await r.commands.executeCommand("rainbow-csv.RBQL",{rbql_backend:"js",rbql_query:"SELECT a.Country, a.Population",with_headers:!0,integration_test_delay:1500}),await s(l),a=r.window.activeTextEditor.document;let d=a.lineCount;u(`Length after js query: ${d}`);let p=11;o||(p+=1),t.equal(p,d)}e.run=async function(){try{u("Starting tests"),t.equal(-1,[1,2,3].indexOf(0));let e=null;t(r.workspace.workspaceFolders),t.equal(1,r.workspace.workspaceFolders.length),e=r.workspace.workspaceFolders[0].uri;let n=e;if(function(){let[e,n,i,o]=[null,null,null,null];e=new r.Range(1,0,1,10),n=new r.Position(1,4),i=new a.VscodeRangeTestDouble(1,0,1,10),o=new a.VscodePositionTestDouble(1,4),t(e.contains(n)),t(i.contains(o)),e=new r.Range(1,0,1,10),n=new r.Position(2,4),i=new a.VscodeRangeTestDouble(1,0,1,10),o=new a.VscodePositionTestDouble(2,4),t(!e.contains(n)),t(!i.contains(o)),e=new r.Range(3,5,3,10),n=new r.Position(3,11),i=new a.VscodeRangeTestDouble(3,5,3,10),o=new a.VscodePositionTestDouble(3,11),t(!e.contains(n)),t(!i.contains(o)),e=new r.Range(3,5,3,10),n=new r.Position(3,10),i=new a.VscodeRangeTestDouble(3,5,3,10),o=new a.VscodePositionTestDouble(3,10),t(e.contains(n)),t(i.contains(o)),e=new r.Range(3,5,3,10),n=new r.Position(3,5),i=new a.VscodeRangeTestDouble(3,5,3,10),o=new a.VscodePositionTestDouble(3,5),t(e.contains(n)),t(i.contains(o)),e=new r.Range(3,5,3,10),n=new r.Position(2,5),i=new a.VscodeRangeTestDouble(3,5,3,10),o=new a.VscodePositionTestDouble(2,5),t(!e.contains(n)),t(!i.contains(o)),e=new r.Range(3,5,10,4),n=new r.Position(3,100),i=new a.VscodeRangeTestDouble(3,5,10,4),o=new a.VscodePositionTestDouble(3,100),t(e.contains(n)),t(i.contains(o))}(),a.test_all(),function(){let[e,n,r,o,l]=[null,null,null,null,null];e=["a1;a2","b1;b2","#comment","c1;c2","d1;d2"],n=new a.VscodeDocumentTestDouble(e),r=[",",";"],o=1e4,l=i.autodetect_dialect_frequency_based(n,r,o),t.deepEqual(["csv (semicolon)",";","quoted"],l),e=[],n=new a.VscodeDocumentTestDouble(e),r=["|"," ","\t",",",";"],o=1e4,l=i.autodetect_dialect_frequency_based(n,r,o),t.deepEqual(["csv",",","quoted"],l),e=["a|b|c|d,f|g|h|d","a,b","c,d","e,f","g,h","k,l","m,n","o,p"],n=new a.VscodeDocumentTestDouble(e),r=["|",",",";"],t.deepEqual(["csv (pipe)","|","simple"],i.autodetect_dialect_frequency_based(n,r,10)),t.deepEqual(["csv",",","quoted"],i.autodetect_dialect_frequency_based(n,r,1e4)),e=["a$b","c$d","e$f","g,h","k,l"],n=new a.VscodeDocumentTestDouble(e),r=["$",",",";"],t.deepEqual(["dynamic csv","$","simple"],i.autodetect_dialect_frequency_based(n,r,1e4)),e=["a; b...","c ;d...","e ;f...","g ; h...","k l..."],n=new a.VscodeDocumentTestDouble(e),r=[" ",".",";"],t.deepEqual(["csv (semicolon)",";","quoted"],i.autodetect_dialect_frequency_based(n,r,1e4)),e=["a|b","c|d","e|f"],n=new a.VscodeDocumentTestDouble(e),r=[";","\t"],t.deepEqual(["csv",",","quoted"],i.autodetect_dialect_frequency_based(n,r,1e4)),e=["a|b","c|d","e|f"],n=new a.VscodeDocumentTestDouble(e),r=[],t.deepEqual(["csv",",","quoted"],i.autodetect_dialect_frequency_based(n,r,1e4))}(),await async function(){let[e,n,r,o]=[null,null,null,null];r=["a|b","c|d ","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set(["other_fake.txt"])},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("csv (pipe)",o.languageId),t.deepEqual([["fake.txt.csv (pipe)",{is_ok:!0,first_trailing_space_line:null}]],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([["fake.txt","plaintext"]],Array.from(n.original_language_ids.entries())),r=["a|b","c|d","e|f","g,h"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a|b","c|d","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!1],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a\tb","c\td","e\tf"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!1],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a|b","c|d","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set(["fake.txt"])},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a|b","c|d","e|f"],o=new a.VscodeDocumentTestDouble(r,"","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a|b","c|d","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.git","plaintext","git"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a|b","c|d","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","foobar"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("foobar",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a|b","c|d","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.csv","csv"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("csv (pipe)",o.languageId),t.deepEqual([["fake.csv.csv (pipe)",{is_ok:!0,first_trailing_space_line:null}]],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a,b",'c,"d','a""sd""f','ef"',"g,h","i,j"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("dynamic csv",o.languageId),t.deepEqual([["fake.txt.dynamic csv",{is_ok:!0,first_trailing_space_line:null}]],Array.from(n.lint_results.entries())),t.deepEqual([["fake.txt",{delim:",",policy:"quoted_rfc"}]],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([["fake.txt","plaintext"]],Array.from(n.original_language_ids.entries())),r=["a|b",'c|"d','a""sd""f','ef"',"g|h","i|j"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a|b","c |d","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set(["other_fake.txt"])},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!0],["autodetection_min_line_count",3],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("csv (pipe)",o.languageId),t.deepEqual([["fake.txt.csv (pipe)",{is_ok:!0,first_trailing_space_line:1}]],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([["fake.txt","plaintext"]],Array.from(n.original_language_ids.entries())),r=["a|b","c|d","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",4],["comment_prefix","#"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a|b","#comment","c|d","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("csv (pipe)",o.languageId),t.deepEqual([["fake.txt.csv (pipe)",{is_ok:!0,first_trailing_space_line:null}]],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([["fake.txt","plaintext"]],Array.from(n.original_language_ids.entries())),r=["a|b","$$comment","c|d","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","$$"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("csv (pipe)",o.languageId),t.deepEqual([["fake.txt.csv (pipe)",{is_ok:!0,first_trailing_space_line:null}]],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([["fake.txt","plaintext"]],Array.from(n.original_language_ids.entries())),r=["a|b","$$comment","c|d","e|f"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a,b\tc\td","a,b\tc\td","a,b\tc\td","a,b\tc\td"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",","TAB"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3],["comment_prefix","$$"]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("tsv",o.languageId),t.deepEqual([["fake.txt.tsv",{is_ok:!0,first_trailing_space_line:null}]],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([["fake.txt","plaintext"]],Array.from(n.original_language_ids.entries())),r=["a|b","c|d","e|f","e|f|g"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a,b","c,d",'e,"fsdf""',"g,h"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",",";","\t","|"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a,b,c","a,b,c","a,b,c","a,b\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tc"],o=new a.VscodeDocumentTestDouble(r,"fake.csv","csv"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",","TAB"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("tsv",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["a,b,c","a,b,c","a,b ,c","#comment"],o=new a.VscodeDocumentTestDouble(r,"fake.csv","csv"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",","TAB"]],["csv_lint_detect_trailing_spaces",!0],["autodetection_min_line_count",3]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("csv",o.languageId),t.deepEqual([["fake.csv.csv",{is_ok:!0,first_trailing_space_line:2}]],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=["Device ids, use with caution!","#a20","#a50","#a30"],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",","TAB"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries())),r=['hello,"world',"asd,fasf","","sadf",'fasdf"'],o=new a.VscodeDocumentTestDouble(r,"fake.txt","plaintext"),n={lint_results:new Map,dynamic_document_dialects:new Map,original_language_ids:new Map,autodetection_stoplist:new Set},e=new Map([["enable_separator_autodetection",!0],["autodetect_separators",[",","TAB"]],["csv_lint_detect_trailing_spaces",!1],["autodetection_min_line_count",3]]),await i.try_autodetect_and_set_rainbow_filetype(a.vscode_test_double,e,n,o),t.equal("plaintext",o.languageId),t.deepEqual([],Array.from(n.lint_results.entries())),t.deepEqual([],Array.from(n.dynamic_document_dialects.entries())),t.deepEqual([],Array.from(n.original_language_ids.entries()))}(),await async function(e){let n=r.Uri.joinPath(e,"csv_files","lorem_ipsum.txt"),a=await r.workspace.openTextDocument(n);u(`languageId for lorem_ipsum.txt: ${a.languageId}`),t.equal(a.languageId,"plaintext");let i=await r.window.showTextDocument(a);await s(1e3),n=r.Uri.joinPath(e,"suite","index.js"),a=await r.workspace.openTextDocument(n),u(`languageId for index.js: ${a.languageId}`),t.equal(a.languageId,"javascript"),i=await r.window.showTextDocument(a),await s(1e3),n=r.Uri.joinPath(e,"csv_files","lorem_ipsum"),a=await r.workspace.openTextDocument(n),u(`languageId for lorem_ipsum: ${a.languageId}`),t.equal(a.languageId,"plaintext"),i=await r.window.showTextDocument(a),await s(1e3)}(n),!o){let e=await r.commands.executeCommand("rainbow-csv.InternalTest",{check_initialization_state:!0});t(e.initialized),t(!e.lazy_loaded)}if(await async function(e){let n=r.Uri.joinPath(e,"csv_files","university_ranking_semicolon.txt"),a=await r.workspace.openTextDocument(n);await r.window.showTextDocument(a),u(`languageId for university_ranking_semicolon.txt: ${a.languageId}`),t.equal(a.languageId,"csv (semicolon)"),await s(1e3)}(n),await async function(e){let n=r.Uri.joinPath(e,"csv_files","small_movies.pipe"),a=await r.workspace.openTextDocument(n);u(`languageId for small_movies.pipe: ${a.languageId}`),t.equal(a.languageId,"plaintext"),await r.window.showTextDocument(a),await c(),await s(1e3);for(let e=0;e<6;e++)await r.commands.executeCommand("cursorRight");await r.commands.executeCommand("cursorRightSelect"),await s(1e3),await r.commands.executeCommand("rainbow-csv.RainbowSeparator",{integration_test:!0}),await s(4e3),u(`languageId for small_movies.pipe after RainbowSeparator: ${a.languageId}`),t.equal(a.languageId,"dynamic csv"),await r.commands.executeCommand("rainbow-csv.RainbowSeparatorOff"),await s(2e3),u(`languageId for small_movies.pipe after RainbowSeparatorOff: ${a.languageId}`),t.equal(a.languageId,"plaintext"),await s(1e3)}(n),await async function(e){let n=performance.now(),a=r.Uri.joinPath(e,"csv_files","books_huge.txt"),i=await r.workspace.openTextDocument(a);await r.window.showTextDocument(i),t.equal(i.languageId,"csv"),await r.commands.executeCommand("cursorBottom"),await s(500),await r.commands.executeCommand("cursorTop"),await s(500);for(let e=0;e<100;e++)await r.commands.executeCommand("scrollPageDown"),await s(10);for(let e=0;e<10;e++)await r.commands.executeCommand("editor.action.deleteLines"),await s(10);await s(500),await r.commands.executeCommand("cursorTop"),await s(500);let o=performance.now()-n-900;u(`total adjusted latency: ${o}`),t(o<2e4)}(n),await async function(e){let n=r.Uri.joinPath(e,"csv_files","movies_multichar_separator.txt"),a=await r.workspace.openTextDocument(n);u(`languageId for movies_multichar_separator.txt: ${a.languageId}`),t.equal(a.languageId,"plaintext"),await r.window.showTextDocument(a),await c(),await s(1e3);for(let e=0;e<6;e++)await r.commands.executeCommand("cursorRight");for(let e=0;e<3;e++)await r.commands.executeCommand("cursorRightSelect");await s(1e3);let i={integration_test:!0};await r.commands.executeCommand("rainbow-csv.RainbowSeparator",i),await s(4e3),u(`languageId for small_movies.pipe after RainbowSeparator: ${a.languageId}`),t.equal(a.languageId,"dynamic csv"),await r.commands.executeCommand("rainbow-csv.RainbowSeparatorOff"),await s(2e3),u(`languageId for small_movies.pipe after RainbowSeparatorOff: ${a.languageId}`),t.equal(a.languageId,"plaintext"),await s(1e3),await r.commands.executeCommand("rainbow-csv.RainbowSeparator",i),await s(4e3),await r.commands.executeCommand("scrollPageDown"),await s(500),await r.commands.executeCommand("scrollPageUp"),await s(500);let _=a.getText().length;await r.commands.executeCommand("rainbow-csv.Align");let d=a.getText().length;t.equal(_+8513,d),await s(1e3),await r.commands.executeCommand("rainbow-csv.Shrink"),await s(1e3);let p=a.getText().length;t.equal(_,p),await r.commands.executeCommand("undo"),await s(500),await r.commands.executeCommand("undo"),await s(500),await r.commands.executeCommand("rainbow-csv.RBQL",{rbql_backend:"js",rbql_query:"select a1, a4 % 100, a5 order by a1 limit 20"}),await s(l),a=r.window.activeTextEditor.document;let f=a.getText().length;u(`Length after js query: ${f}`),await s(1e3);let g=742;o||(g+=1),t.equal(g,f)}(n),o?await async function(e){let[n,a,i]=[null,null,null];await _(e),n=r.Uri.joinPath(e,"csv_files","university_ranking.csv"),a=await r.workspace.openTextDocument(n),i=await r.window.showTextDocument(a),await s(1e3);let o={rbql_backend:"js",with_headers:!0,rbql_query:"select top 20 a1, Math.ceil(parseFloat(a.total_score) * 100), a['university_name'], null, 'foo bar' order by a2"};await r.commands.executeCommand("rainbow-csv.RBQL",o),await s(l);let c=await r.commands.executeCommand("rainbow-csv.InternalTest",{check_last_rbql_warnings:!0});t.equal('["null values in output were replaced by empty strings"]',JSON.stringify(c.warnings)),a=r.window.activeTextEditor.document;let d=a.getText().length;u(`Length after first js query: ${d}`),t.equal(846,d),o={rbql_backend:"js",rbql_query:"select a2 * 10, a3, a3.length where NR > 1 order by a3.length limit 10"},await r.commands.executeCommand("rainbow-csv.RBQL",o),await s(l),a=r.window.activeTextEditor.document,d=a.getText().length,u(`Length after second js query: ${d}`),t.equal(267,d),o={rbql_backend:"js",rbql_query:"select nonexistent_function(a1)"},await r.commands.executeCommand("rainbow-csv.RBQL",o),await s(l),c=await r.commands.executeCommand("rainbow-csv.InternalTest",{check_last_rbql_report:!0}),t.equal("query execution",c.error_type),t.equal("At record 1, Details: nonexistent_function is not defined",c.error_msg),u("Starting multiline records test"),n=r.Uri.joinPath(e,"csv_files","synthetic_rfc_newline_data.csv"),a=await r.workspace.openTextDocument(n),i=await r.window.showTextDocument(a),await s(1e3),o={rbql_backend:"js",rbql_query:"select '<<<<<', a3, a2, a1, '>>>>> NR: ' + NR",enable_rfc_newlines:!0},await r.commands.executeCommand("rainbow-csv.RBQL",o),await s(l),a=r.window.activeTextEditor.document,d=a.getText().length,u(`Length after js multiline-record query: ${d}`),t.equal(644,d)}(n):await async function(e){let[n,a,i]=[null,null,null];await _(e),await async function(e){let[n,a,i,o]=[null,null,null,null];n=r.Uri.joinPath(e,"csv_files","countries_with_comments.csv"),a=await r.workspace.openTextDocument(n),i=await r.window.showTextDocument(a),await s(1e3),await r.commands.executeCommand("rainbow-csv.RBQL",{rbql_backend:"python",rbql_query:"SELECT '[{}]'.format(a.Country), int(a.Population) / 10",with_headers:!0,integration_test_delay:1500}),await s(l),a=r.window.activeTextEditor.document;let c=a.lineCount;u(`Length after python query: ${c}`),t.equal(12,c)}(e),n=r.Uri.joinPath(e,"csv_files","university_ranking.csv"),a=await r.workspace.openTextDocument(n),i=await r.window.showTextDocument(a),await s(1e3);let o={rbql_backend:"python",with_headers:!0,rbql_query:"select top 20 a1, math.ceil(float(a.total_score) * 100), a['university_name'], None, 'foo bar' order by a2"};await r.commands.executeCommand("rainbow-csv.RBQL",o),await s(l);let c=await r.commands.executeCommand("rainbow-csv.InternalTest",{check_last_rbql_warnings:!0});t.equal('["None values in output were replaced by empty strings"]',JSON.stringify(c.warnings)),a=r.window.activeTextEditor.document;let d=a.getText().length;u(`Length after python query: ${d}`),t.equal(868,d),o={rbql_backend:"js",with_headers:!1,rbql_query:"select a2 * 10, a3, a3.length where NR > 1 order by a3.length limit 10"},await r.commands.executeCommand("rainbow-csv.RBQL",o),await s(l),a=r.window.activeTextEditor.document,d=a.getText().length,u(`Length after js query: ${d}`),t.equal(268,d),o={rbql_backend:"python",rbql_query:"select nonexistent_function(a1)"},await r.commands.executeCommand("rainbow-csv.RBQL",o),await s(l),c=await r.commands.executeCommand("rainbow-csv.InternalTest",{check_last_rbql_report:!0}),t.equal("query execution",c.error_type),t.equal("At record 1, Details: name 'nonexistent_function' is not defined",c.error_msg),n=r.Uri.joinPath(e,"csv_files","synthetic_rfc_newline_data.csv"),a=await r.workspace.openTextDocument(n),i=await r.window.showTextDocument(a),await s(1e3),t.equal(a.languageId,"dynamic csv"),o={rbql_backend:"js",rbql_query:"select '<<<<<', a3, a2, a1, '>>>>> NR: ' + NR"},await r.commands.executeCommand("rainbow-csv.RBQL",o),await s(l),a=r.window.activeTextEditor.document,d=a.getText().length,u(`Length after js multiline-record query: ${d}`),t.equal(645,d),n=r.Uri.joinPath(e,"csv_files","university_ranking.csv"),a=await r.workspace.openTextDocument(n),i=await r.window.showTextDocument(a),await s(1e3),o={rbql_backend:"python",with_headers:!0,rbql_query:"select a.university_name, b.Country, b.Population, b['GDP per capita'] JOIN countries.csv on a.country == b.Country order by int(b.Population) desc"},await r.commands.executeCommand("rainbow-csv.RBQL",o),await s(l),c=await r.commands.executeCommand("rainbow-csv.InternalTest",{check_last_rbql_warnings:!0}),t.equal('["The first record in JOIN file countries.csv was also treated as header (and skipped)"]',JSON.stringify(c.warnings)),a=r.window.activeTextEditor.document,d=a.getText().length,u(`Length after join query: ${d}`),t.equal(11592,d),t.equal(202,a.lineCount),n=r.Uri.joinPath(e,"csv_files","countries.csv"),a=await r.workspace.openTextDocument(n);let p=a.fileName,f=a.getText().length;i=await r.window.showTextDocument(a),t(-1==a.getText().indexOf("oceania")),t(a.getText().indexOf("OCEANIA")>0),await s(1e3),o={rbql_backend:"python",with_headers:!0,rbql_query:"UPDATE set a.Region = a.Region.lower()"},await r.commands.executeCommand("rainbow-csv.RBQL",o),await s(l),c=await r.commands.executeCommand("rainbow-csv.InternalTest",{check_last_rbql_warnings:!0}),t.equal("[]",JSON.stringify(c.warnings)),a=r.window.activeTextEditor.document,a.fileName,d=a.getText().length,u(`Length after update query: ${d}`),t.equal(f,d-a.lineCount+1),t(-1==a.getText().indexOf("OCEANIA")),t(a.getText().indexOf("oceania")>0),await s(1e3),await r.commands.executeCommand("rainbow-csv.CopyBack"),await s(1e3),a=await r.workspace.openTextDocument(n);let g=a.fileName;t.equal(p,g),t(-1==a.getText().indexOf("OCEANIA")),t(a.getText().indexOf("oceania")>0)}(n),!o){let e=await r.commands.executeCommand("rainbow-csv.InternalTest",{check_initialization_state:!0});t(e.initialized),t(e.lazy_loaded)}await async function(e){let n=r.Uri.joinPath(e,"csv_files","university_ranking.csv"),a=await r.workspace.openTextDocument(n),i=(await r.window.showTextDocument(a),a.getText().length);u(`Original length: ${i}`),t.equal(12538,i),await s(2e3),await r.commands.executeCommand("rainbow-csv.Align");let o=a.getText().length;u(`Aligned length: ${o}`),t.equal(25896,o),t(o>i);let l=await r.commands.executeCommand("rainbow-csv.CSVLint");t(l.is_ok),await s(2e3),await r.commands.executeCommand("rainbow-csv.Shrink");let c=a.getText().length;u(`Shrinked length: ${c}`),t.equal(i,c),await s(500);await r.commands.executeCommand("default:type",{text:"foobar,"}),l=await r.commands.executeCommand("rainbow-csv.CSVLint"),t(l.fields_info.size>1),await s(500);for(let e=0;e<7;e++)await r.commands.executeCommand("deleteLeft");await s(500)}(n),await async function(e){let n=r.Uri.joinPath(e,"csv_files","double_width_chars.csv"),a=await r.workspace.openTextDocument(n),i=(await r.window.showTextDocument(a),a.getText().length);u(`Original length: ${i}`),t.equal(274,i),await s(2e3),await r.commands.executeCommand("rainbow-csv.Align");let o=a.getText().length;u(`Aligned length: ${o}`),t.equal(461,o),t(o>i);let l=await r.commands.executeCommand("rainbow-csv.CSVLint");t(l.is_ok),await s(2e3),await r.commands.executeCommand("rainbow-csv.Shrink");let c=a.getText().length;u(`Shrinked length: ${c}`),t.equal(i,c),await s(500)}(n),await async function(e){let n=r.Uri.joinPath(e,"csv_files","movies.txt"),a=await r.workspace.openTextDocument(n),i=(await r.window.showTextDocument(a),a.getText().length);t.equal(9986,i),await c();for(let e=0;e<10;e++)await r.commands.executeCommand("cursorRight");await s(1e3),await r.commands.executeCommand("rainbow-csv.ColumnEditAfter"),await s(1e3);await r.commands.executeCommand("default:type",{text:"foobar,"});let o=a.getText().length;t.equal(i+7*a.lineCount,o),await s(1e3);for(let e=0;e<7;e++)await r.commands.executeCommand("deleteLeft");await s(1e3);let l=a.getText().length;t.equal(i,l)}(n),u("Finishing tests")}catch(e){u("Error: tests have failed. Exception:"),u(String(e)),u(String(e.stack))}}})();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})})();