energy-state-analyzer 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- (()=>{"use strict";var __webpack_modules__={186(e,t,n){var r,s=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=r(e),a=0;a<n.length;a++)"default"!==n[a]&&s(t,e,n[a]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0});const i=a(n(896)),_=n(212),l=n(106),u=n(58),c=n(380),d=["base-ref","report","medium-nesting","high-nesting","medium-cyclomatic","high-cyclomatic","medium-cognitive","high-cognitive"];function m(e,t){if(void 0!==e.mediumThreshold||void 0!==e.highThreshold)return{...t,mediumThreshold:e.mediumThreshold??t.mediumThreshold,highThreshold:e.highThreshold??t.highThreshold}}(async function(){const e=function(e){const t=[],n=new Map;for(let r=0;r<e.length;r++){const s=e[r];if(s.startsWith("--")){const t=s.slice(2);d.includes(t)&&(n.set(t,e[r+1]),r++)}else t.push(s)}const r=e=>n.get(e),s=e=>{const t=r(e);return void 0!==t?Number(t):void 0};return{paths:t,baseRef:r("base-ref"),report:r("report"),nesting:{mediumThreshold:s("medium-nesting"),highThreshold:s("high-nesting")},cyclomatic:{mediumThreshold:s("medium-cyclomatic"),highThreshold:s("high-cyclomatic")},cognitive:{mediumThreshold:s("medium-cognitive"),highThreshold:s("high-cognitive")}}}(process.argv.slice(2)),t=function(e){return{nesting:m(e.nesting,_.DEFAULT_NESTING_THRESHOLDS),cyclomatic:m(e.cyclomatic,l.DEFAULT_CYCLOMATIC_THRESHOLDS),cognitive:m(e.cognitive,u.DEFAULT_COGNITIVE_THRESHOLDS)}}(e),n=e.report??(e.baseRef||1!==e.paths.length?"md":"json");e.baseRef?await(0,c.runDiff)(e.baseRef,e.paths,t,n):(0===e.paths.length&&((0,c.printUsage)(),process.exit(2)),1===e.paths.length&&i.existsSync(e.paths[0])&&i.statSync(e.paths[0]).isFile()&&!e.report?await(0,c.runLegacySingleFile)(e.paths[0],t):await(0,c.runScan)(e.paths,t,n))})().catch(e=>{console.error("energy-state-cli failed:",e),process.exit(1)})},380(e,t,n){var r,s=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=r(e),a=0;a<n.length;a++)"default"!==n[a]&&s(t,e,n[a]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.printUsage=y,t.runLegacySingleFile=async function(e,t){(0,m.resolveLanguageForFile)(e)||(console.error(`Unsupported file type: ${e}`),y(),process.exit(2));const n=i.readFileSync(e,"utf8"),r=await w(e,n,t);console.log(JSON.stringify(r,null,2));const s=r.some(e=>e.severity===g.SEVERITY.HIGH||e.severity===g.SEVERITY.MEDIUM);process.exit(s?1:0)},t.runScan=async function(e,t,n){const r=(0,p.resolveSupportedFiles)(e),s=[];for(const e of r){const n=i.readFileSync(e,"utf8"),r=await w(e,n,t);s.push({filePath:_.relative(process.cwd(),e),violations:r})}const o=(0,f.summarize)(s);var a;"human"===n?console.log((0,f.renderHumanReport)(s)):"md"===n?console.log((0,f.renderMarkdownReport)(o)):console.log(JSON.stringify(o,null,2)),a=o.totalCounts,process.exit((0,f.hasBlockingViolations)(a)?1:0)},t.runDiff=async function(e,t,n,r){const s=process.cwd(),o=(0,h.loadIgnorePatterns)(s),a=(t.length>0?t:function(e){return(0,l.execFileSync)("git",["diff","--name-only","--diff-filter=d",`${e}...HEAD`],{encoding:"utf8"}).split("\n").map(e=>e.trim()).filter(Boolean)}(e)).filter(e=>(0,m.resolveLanguageForFile)(e)&&i.existsSync(e)).filter(e=>!(0,h.isIgnored)(_.resolve(e),s,o)),u=[],c=[];for(const t of a){const r=i.readFileSync(t,"utf8"),s=await w(t,r,n);u.push((0,f.summarizeFile)({filePath:t,violations:s}));const o=T(e,t);if(null!==o){const e=await w(t,o,n);c.push((0,f.summarizeFile)({filePath:t,violations:e}))}}const d=(0,f.diffSummaries)(c,u);console.log("md"===r?(0,f.renderDiffMarkdown)(d,e):JSON.stringify(d,null,2)),process.exit(d.some(e=>"worsened"===e.status)?1:0)};const i=a(n(896)),_=a(n(928)),l=n(317),{Parser:u,Language:c}=n(43),d=n(958),m=n(912),p=n(53),h=n(119),f=n(254),g=n(613);function y(){console.error("Usage: energy-state-cli <file.py|.fs|.fsx|.ts> [thresholds...]"),console.error(" energy-state-cli <path...> [--report json|md|human] [thresholds...] (scan a directory/subtree)"),console.error(" energy-state-cli --base-ref <ref> [<path...>] [--report json|md] [thresholds...] (diff PR head against a base ref)"),console.error("Thresholds: --medium-nesting N --high-nesting N --medium-cyclomatic N --high-cyclomatic N --medium-cognitive N --high-cognitive N")}const E=new Map;async function w(e,t,n){const r=(0,m.resolveLanguageForFile)(e);if(!r)return[];const s=await async function(e){const t=E.get(e);if(t)return t;await u.init();const n=new u,r=_.join(__dirname,"..",e.grammarPath),s=await c.load(r);return n.setLanguage(s),E.set(e,n),n}(r),o=s.parse(t);return(0,d.analyzeSource)(t,o,r,e,n)}function T(e,t){try{return(0,l.execFileSync)("git",["show",`${e}:${t}`],{encoding:"utf8",stdio:["ignore","pipe","ignore"]})}catch(n){return console.error(`energy-state-cli: could not read ${t} at ${e} (new file or rename) — treating as new`),null}}},958(e,t,n){t.analyzeSource=function(e,t,n,g,y={}){const E=(0,r.createPositionLookup)(e),w=[];w.push(...(0,s.analyzeNesting)(t,E,n,y.nesting??s.DEFAULT_NESTING_THRESHOLDS)),w.push(...(0,o.analyzeFunctionComplexity)(t,E,n,y.cyclomatic??o.DEFAULT_CYCLOMATIC_THRESHOLDS)),w.push(...(0,a.analyzeCognitiveComplexity)(t,E,n,y.cognitive??a.DEFAULT_COGNITIVE_THRESHOLDS)),w.push(...(0,i.analyzeFileCoherence)(t,g,n,E,y.coherence??i.DEFAULT_COHERENCE_THRESHOLDS)),w.push(...(0,_.analyzeMagicNumbers)(t,E,n,g,y.magicNumber??_.DEFAULT_MAGIC_NUMBER_OPTIONS)),w.push(...(0,l.analyzeMagicStrings)(t,E,n,y.magicString??l.DEFAULT_MAGIC_STRING_OPTIONS)),w.push(...(0,u.analyzeParameterCount)(t,E,n)),w.push(...(0,c.analyzeInversionOpportunities)(t,E,n)),w.push(...(0,d.analyzePrimitiveObsession)(t,E,n)),w.push(...(0,m.analyzeMatchOpportunities)(t,E,n,y.matchOpportunity??m.DEFAULT_MATCH_OPPORTUNITY_THRESHOLDS)),w.push(...(0,p.analyzeLogicalControlFlow)(t,E,n)),w.push(...(0,h.analyzeOpaqueBooleanLiteral)(t,E,n));const{violations:T,suppressionNotes:I}=(0,f.applySuppressions)(w,e);return[...T,...I]};const r=n(599),s=n(212),o=n(106),a=n(58),i=n(764),_=n(268),l=n(668),u=n(622),c=n(907),d=n(164),m=n(774),p=n(632),h=n(487),f=n(692)},736(e,t,n){t.checkClassRelatedness=function(e,t,n,a){if(e.length<2)return null;const i=function(e,t){const n=e.map(e=>e.name),{union:r,find:s}=function(e){const t=Array.from({length:e},(e,t)=>t);function n(e){for(;t[e]!==e;)t[e]=t[t[e]],e=t[e];return e}return{union:function(e,r){const s=n(e),o=n(r);s!==o&&(t[s]=o)},find:n}}(e.length);(function(e,t,n){e.forEach((e,r)=>{for(const s of e.baseNames){const e=t.findIndex(e=>null!==e&&e===s);-1!==e&&n(r,e)}})})(e,n,r),function(e,t){const n=new Map;e.forEach((e,t)=>{for(const r of e.baseNames){const e=n.get(r)??[];e.push(t),n.set(r,e)}});for(const e of n.values())for(let n=1;n<e.length;n++)t(e[0],e[n])}(e,r),function(e,t,n,r){e.forEach((e,s)=>{for(const a of e.methods)for(const e of(0,o.collectTypeSignals)(a,n)){const n=t.findIndex(t=>null!==t&&t===e);-1!==n&&n!==s&&r(s,n)}})}(e,n,t,r);const a=new Map;return e.forEach((e,t)=>{const n=s(t),r=a.get(n)??[];r.push(t),a.set(n,r)}),[...a.values()]}(e,n);if(i.length<=1)return null;const _=e.map(e=>e.name),l=_.filter(e=>null!==e);if(l.length===_.length&&(0,s.looksLikeSingleDomainByNames)(l,t))return null;const u=i.map(e=>e.map(e=>_[e]??"(anonymous)")).sort((e,t)=>t.length-e.length),c=a.toPosition(e[0].node.startIndex);return{line:c.line,column:c.column,type:r.VIOLATION_TYPE.COHERENCE,severity:u.length>2?r.SEVERITY.HIGH:r.SEVERITY.MEDIUM,message:`File coherence warning: ${e.length} classes in one file split into ${u.length} unrelated groups: ${u.map(e=>`{${e.join(", ")}}`).join(" vs ")}. These share no inheritance, type relationship, or naming pattern — each group likely belongs in its own file.`}};const r=n(613),s=n(552),o=n(844)},58(e,t,n){t.DEFAULT_COGNITIVE_THRESHOLDS=void 0,t.analyzeCognitiveComplexity=function(e,n,a,i=t.DEFAULT_COGNITIVE_THRESHOLDS){const _=[];return function e(t){if(a.isFunctionDefinition(t)){const e=s(t,a);if(e>i.mediumThreshold){const s=n.toPosition(t.startIndex);_.push({line:s.line,column:s.column,type:r.VIOLATION_TYPE.COGNITIVE,severity:e>i.highThreshold?r.SEVERITY.HIGH:r.SEVERITY.MEDIUM,message:`High cognitive complexity: ${e}. This function is hard to read; consider flattening nesting or extracting functions.`,hotspots:o(t,n,a)})}}for(const n of t.children)e(n)}(e.rootNode),_};const r=n(613);function s(e,t,n){let r=0;const{nodeTypes:s}=t;function o(e,t){r+=t,n?.(e,t)}function a(e,n){for(const r of e.children)i(r,t.entersNestedScope(r)?n+1:n)}function i(e,n){const r=t.getBooleanOperator(e);if(r){t.getBooleanOperator(e.parent)!==r&&o(e,1);for(const t of e.children)i(t,n)}else{if(t.cognitiveNestedDecisionTypes.includes(e.type))return o(e,1+n),void a(e,n);if(e.type===s.elseClause)return o(e,1),void a(e,n);if(e.type!==s.conditionalExpression)if(t.isFunctionDefinition(e))o(e,1+n);else{if(e.type===s.lambda)return o(e,1+n),void a(e,n);for(const t of e.children||[])i(t,n)}else{o(e,1+n);for(const t of e.children)i(t,n+1)}}}for(const t of e.children)i(t,0);return r}function o(e,t,n){const r=[];return s(e,n,(e,n)=>{r.push({line:t.toPosition(e.startIndex).line,weight:n})}),r}t.DEFAULT_COGNITIVE_THRESHOLDS={mediumThreshold:15,highThreshold:25}},764(e,t,n){t.DEFAULT_COHERENCE_THRESHOLDS=void 0,t.analyzeFileCoherence=function(e,n,r,s,o=t.DEFAULT_COHERENCE_THRESHOLDS){const{freeFunctions:i,classes:c,importSources:d,firstImportNode:m}=function(e,t){const n=[],r=[],s=new Set;let o=null;function a(e,i){if(t.classDefinitionNodeTypes.includes(e.type))!function(e){const n={name:t.getClassName(e),node:e,baseNames:t.getBaseClassNames(e),methods:[]};r.push(n);for(const t of e.children)a(t,n)}(e);else{t.isFunctionDefinition(e)?(i?i.methods:n).push(e):function(e){const{nodeTypes:n}=t;return e.isNamed&&(e.type===n.importStatement||e.type===n.importFromStatement)}(e)&&(s.add(t.importSource(e)||e.text||""),o??=e);for(const t of e.children)a(t,i)}}return a(e.rootNode,null),{freeFunctions:n,classes:r,importSources:s,firstImportNode:o}}(e,r),p=[...i,...c.flatMap(e=>e.methods)];return[_(i,n,o,r,s),l(p,o,s),u(d,m,s),(0,a.checkClassRelatedness)(c,o.singleDomainNameShare,r,s)].filter(e=>null!==e)};const r=n(613),s=n(552),o=n(844),a=n(736);function i(e,t,n){return{line:n.line,column:n.column,type:r.VIOLATION_TYPE.COHERENCE,severity:e>15?r.SEVERITY.HIGH:r.SEVERITY.MEDIUM,message:t}}function _(e,t,n,r,a){if(e.length<=8)return null;const _=(0,s.isUtilsFileName)(t),l=(0,o.typeCohesionResult)(e,r,{maxDiversityRatio:n.maxTypeDiversityRatio,minCoverage:n.minTypedCoverage}),u=!_&&function(e,t,n){return"boolean"==typeof n.result?n.result:(0,s.looksLikeSingleDomain)(e,t.singleDomainNameShare)}(e,n,l);if(!_&&(e.length<=12||u))return null;const c=a.toPosition(e[0].startIndex);return!1===l.result?i(e.length,`File coherence warning: ${e.length} functions in one file spanning ${l.distinctTypes} unrelated types. This is a stronger sprawl signal than function count alone — the functions don't share a common domain type, so moving them into existing cohesive modules (grouped by the type they operate on) is likely to help more than an arbitrary split.`,c):i(e.length,`File coherence warning: ${e.length} functions in one file. If they belong to distinct domains, prefer moving them into existing cohesive modules; splitting into a new file only helps if it doesn't just relocate the same imports/coupling.`,c)}function l(e,t,n){const s=e.filter(e=>{return(n=e).endPosition.row-n.startPosition.row+1>t.largeFunctionLines;var n});if(s.length<=t.maxLargeFunctions)return null;const o=n.toPosition(s[0].startIndex);return{line:o.line,column:o.column,type:r.VIOLATION_TYPE.COHERENCE,severity:s.length>1.5*t.maxLargeFunctions?r.SEVERITY.HIGH:r.SEVERITY.MEDIUM,message:`${s.length} functions exceed ${t.largeFunctionLines} lines. Large functions carry more complexity than function count alone suggests.`}}function u(e,t,n){if(e.size<=10)return null;const s=t?n.toPosition(t.startIndex):{line:0,column:0};return{line:s.line,column:s.column,type:r.VIOLATION_TYPE.COHERENCE,severity:e.size>15?r.SEVERITY.HIGH:r.SEVERITY.MEDIUM,message:`Import sprawl: ${e.size} distinct modules imported suggest this file does too much. Splitting only helps if the resulting files don't each still need most of these imports.`}}t.DEFAULT_COHERENCE_THRESHOLDS={largeFunctionLines:20,maxLargeFunctions:5,singleDomainNameShare:.7,maxTypeDiversityRatio:.4,minTypedCoverage:.5}},106(e,t,n){t.DEFAULT_CYCLOMATIC_THRESHOLDS=void 0,t.analyzeFunctionComplexity=function(e,n,o,a=t.DEFAULT_CYCLOMATIC_THRESHOLDS){const i=[];return function e(t){if(o.isFunctionDefinition(t)){const e=function(e,t){let n=1;return function e(r,s){if((t.decisionNodeTypes.includes(r.type)||null!==t.getBooleanOperator(r)||t.isTryElseClause(r))&&n++,s||!t.isFunctionDefinition(r))for(const t of r.children)e(t,!1)}(e,!0),n}(t,o);if(e>a.mediumThreshold){const _=n.toPosition(t.startIndex);i.push({line:_.line,column:_.column,type:r.VIOLATION_TYPE.COMPLEXITY,severity:e>a.highThreshold?r.SEVERITY.HIGH:r.SEVERITY.MEDIUM,message:`High cyclomatic complexity: ${e}. Consider breaking down this function.`,hotspots:s(t,n,o)})}}for(const n of t.children)e(n)}(e.rootNode),i};const r=n(613);function s(e,t,n){const r=[];return function e(s,o,a){let i=o;if(n.decisionNodeTypes.includes(s.type)||null!==n.getBooleanOperator(s)||n.isTryElseClause(s)){const e=t.toPosition(s.startIndex).line;r.push({line:e,weight:1+o}),i=o+1}if(a||!n.isFunctionDefinition(s))for(const t of s.children)e(t,i,!1)}(e,0,!0),r}t.DEFAULT_CYCLOMATIC_THRESHOLDS={mediumThreshold:10,highThreshold:15}},907(e,t,n){t.analyzeInversionOpportunities=function(e,t,n){const s=[],{nodeTypes:o}=n;return function e(a){n.isFunctionDefinition(a)&&function(e){const a=e.children.find(e=>e.type===o.block)??e.children.flatMap(e=>e.children??[]).find(e=>e.type===o.block);if(!a)return;const i=a.children.filter(e=>e.isNamed&&e.type!==o.comment&&e.text?.trim());if(i.length>=1){const n=i[0];if(n.type===o.ifStatement){const a=n.children.find(e=>e.type===o.block);if(a&&a.children.length>2){const o=e.endIndex-e.startIndex;if((a.endIndex-a.startIndex)/o>.5){const e=t.toPosition(n.startIndex);s.push({line:e.line,column:e.column,type:r.VIOLATION_TYPE.INVERSION,severity:r.SEVERITY.MEDIUM,message:"Consider inverting this condition and using early return for cleaner flow."})}}}}!function(e){let a=e,i=0;const _=[];for(;a&&i<4;){const e=a.children?.filter(e=>n.nestingControlTypes.includes(e.type))||[];if(1!==e.length||e[0].type!==o.ifStatement)break;{const t=e[0];if(_.push(t),o.elseClause?t.children.some(e=>e.type===o.elseClause):t.children.filter(e=>e.type===o.block).length>1||t.children.some(e=>e.type===o.ifStatement))break;a=t.children.find(e=>e.type===o.block),i++}}if(_.length>=2){const e=_[0],n=t.toPosition(e.startIndex);s.push({line:n.line,column:n.column,type:r.VIOLATION_TYPE.INVERSION,severity:r.SEVERITY.MEDIUM,message:`Found ${_.length} nested validation checks. Consider using guard clauses with early returns.`})}}(a),function(e){let a=0,i=null;if(function e(t,r=0){if(!n.isFunctionDefinition(t)){t.type===o.ifStatement&&(r>a&&(a=r,i=t),r++);for(const n of t.children||[])e(n,r)}}(e),a>=3&&i){const e=t.toPosition(i.startIndex);s.push({line:e.line,column:e.column,type:r.VIOLATION_TYPE.INVERSION,severity:r.SEVERITY.MEDIUM,message:`Deep if-nesting (${a} levels). Consider inverting conditions or extracting functions.`})}}(a)}(a);for(const t of a.children)e(t)}(e.rootNode),s};const r=n(613)},632(e,t,n){t.analyzeLogicalControlFlow=function(e,t,n){const s=[],{nodeTypes:o}=n;return function e(a){const i=n.getBooleanOperator(a);if(null!==i&&a.parent?.type===o.expressionStatement){const e=t.toPosition(a.startIndex);s.push({line:e.line,column:e.column,type:r.VIOLATION_TYPE.LOGICAL_CONTROL_FLOW,severity:r.SEVERITY.LOW,message:"and"===i?"If-statement disguised as '&&'. Consider an explicit if-statement instead.":"If-statement disguised as '||'. Consider an explicit if-statement instead."})}for(const t of a.children)e(t)}(e.rootNode),s};const r=n(613)},268(e,t,n){t.DEFAULT_MAGIC_NUMBER_OPTIONS=void 0,t.analyzeMagicNumbers=function(e,n,s,o,a=t.DEFAULT_MAGIC_NUMBER_OPTIONS){const i=[];if(!a.enabled||function(e){const t=e.replace(/\\/g,"/").split("/").filter(Boolean);if(t.some(e=>/^tests?$/i.test(e)))return!0;const n=(t[t.length-1]??"").replace(/\.[^./]+$/,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean);return 0!==n.length&&("test"===n[0].toLowerCase()||"test"===n[n.length-1].toLowerCase())}(o))return i;const{nodeTypes:_}=s;function l(e){let t=e.parent;for(;t;){if(s.isFunctionDefinition(t))return!0;t=t.parent}return!1}return function e(t){if(t.type===_.integerLiteral||t.type===_.floatLiteral){const e=parseFloat(t.text);if(!Number.isNaN(e)){const o=function(e,t){const n=e.parent;return 2===n?.children?.length&&"-"===n.children[0]?.text?-t:t}(t,e);if(!(a.allowlist.includes(o)||function(e){let t=e.parent;for(;t;){if(s.isExplicitConstant(t))return!0;if(t.type===_.assignment){if(s.isFunctionDefinition(t))return!1;let e=t.parent;if(e?.type===_.expressionStatement&&(e=e.parent),e?.type===_.module)return!l(t);if(_.exportStatement&&e?.type===_.exportStatement&&e.parent?.type===_.module)return!0}t=t.parent}return!1}(t)||function(e){return!!e.parent&&s.subscriptNodeTypes.includes(e.parent.type)}(t)||s.isDefaultParameterValue(t))){const e=n.toPosition(t.startIndex);i.push({line:e.line,column:e.column,type:r.VIOLATION_TYPE.MAGIC,severity:r.SEVERITY.LOW,message:`Magic number: ${t.text}. Consider extracting to a named constant.`})}}return}for(const n of t.children)e(n)}(e.rootNode),i};const r=n(613);t.DEFAULT_MAGIC_NUMBER_OPTIONS={enabled:!0,allowlist:[0,1,-1,2]}},668(e,t,n){t.DEFAULT_MAGIC_STRING_OPTIONS=void 0,t.analyzeMagicStrings=function(e,n,s,o=t.DEFAULT_MAGIC_STRING_OPTIONS){const a=[];if(!o.enabled)return a;const{nodeTypes:i}=s;const _=[];!function e(t){if(t.type===i.stringLiteral){const e=(n=t.text).length>=2?n.slice(1,-1):n;(function(e,t){return function(e){return[e.parent,e.parent?.parent].filter(Boolean).some(t=>s.getEqualityComparisons(t).some(({left:t,right:n})=>t.id===e.id||n.id===e.id))}(e)||function(e,t){const n=e.parent?.parent;return!!n&&s.getMembershipComparisons(n).some(({values:e})=>e.includes(t))}(e,t)||function(e){return!!e.parent&&s.subscriptNodeTypes.includes(e.parent.type)}(e)})(t,e)&&!function(e,t){return function(e){return e.parent?.type===i.expressionStatement}(e)||s.isFormattedOrInterpolatedString(e)||o.allowlist.includes(t)||t.length<=1}(t,e)&&_.push({node:t,content:e})}var n;for(const n of t.children)e(n)}(e.rootNode);const l=new Map;for(const e of _){const t=l.get(e.content)??[];t.push(e),l.set(e.content,t)}for(const[e,t]of l){if(t.length<o.minDuplicates)continue;const s=t[0].node,i=n.toPosition(s.startIndex);a.push({line:i.line,column:i.column,type:r.VIOLATION_TYPE.MAGIC,severity:r.SEVERITY.LOW,message:`Magic string: "${e}" is compared/keyed against directly ${t.length} time(s). Consider extracting to a named constant or enum.`})}return a};const r=n(613);t.DEFAULT_MAGIC_STRING_OPTIONS={enabled:!0,minDuplicates:2,allowlist:["","utf-8","__main__"]}},774(e,t,n){t.DEFAULT_MATCH_OPPORTUNITY_THRESHOLDS=void 0,t.analyzeMatchOpportunities=function(e,n,s,o=t.DEFAULT_MATCH_OPPORTUNITY_THRESHOLDS){const a=[],{nodeTypes:i}=s,_=new Set;return function e(t){t.type!==i.ifStatement||_.has(t)||function(e){const t=function(e,t){const n=[e],r=t.getElseIfBranches(e);if(r.length>0)return n.push(...r),n;let s=e;for(;;){const e=t.nodeTypes.elseClause?s.children?.find(e=>e.type===t.nodeTypes.elseClause)?.children?.find(e=>e.type===t.nodeTypes.ifStatement):s.children?.find(e=>e.type===t.nodeTypes.ifStatement);if(!e)break;n.push(e),s=e}return n}(e,s);if(t.slice(1).forEach(e=>_.add(e)),t.length<o.minBranches)return;const i=t.map(e=>function(e,t,n){const{nodeTypes:r}=n,s=[];function o(e){return n.variableReferenceNodeTypes.includes(e.type)}function a(e){return e.type===r.stringLiteral||e.type===r.integerLiteral||e.type===r.floatLiteral}function i(e){return e.type===r.stringLiteral?e.text.slice(1,-1):e.text}return function e(_){if(!t.has(_)&&_.type!==r.block&&_.type!==r.elseClause){for(const{left:e,right:t}of n.getEqualityComparisons(_))o(e)&&a(t)?s.push({variable:e.text,value:i(t)}):o(t)&&a(e)&&s.push({variable:t.text,value:i(e)});for(const{left:e,values:t}of n.getMembershipComparisons(_))o(e)&&t.forEach(t=>s.push({variable:e.text,value:t}));for(const t of _.children||[])e(t)}}(e),s}(e,new Set(t.filter(t=>t!==e)),s));if(i.some(e=>0===e.length))return;const l=i[0].map(e=>e.variable).find(e=>i.every(t=>t.some(t=>t.variable===e)));if(!l)return;const u=n.toPosition(e.startIndex);a.push({line:u.line,column:u.column,type:r.VIOLATION_TYPE.MATCH_OPPORTUNITY,severity:r.SEVERITY.LOW,message:`This ${t.length}-way if/elif chain all branch on '${l}'. Consider a match/switch statement for clearer, exhaustiveness-checked dispatch.`})}(t);for(const n of t.children||[])e(n)}(e.rootNode),a};const r=n(613);t.DEFAULT_MATCH_OPPORTUNITY_THRESHOLDS={minBranches:3}},212(e,t,n){t.DEFAULT_NESTING_THRESHOLDS=void 0,t.analyzeNesting=function(e,n,s,o=t.DEFAULT_NESTING_THRESHOLDS){const a=[];return function e(t,i=0){if(s.nestingControlTypes.includes(t.type)){if(i>o.mediumThreshold){const e=n.toPosition(t.startIndex);a.push({line:e.line,column:e.column,type:r.VIOLATION_TYPE.NESTING,severity:i>o.highThreshold?r.SEVERITY.HIGH:r.SEVERITY.MEDIUM,message:`Excessive nesting depth: ${i}. Consider extracting.`})}i++}for(const n of t.children)e(n,i)}(e.rootNode),a};const r=n(613);t.DEFAULT_NESTING_THRESHOLDS={mediumThreshold:3,highThreshold:5}},487(e,t,n){t.analyzeOpaqueBooleanLiteral=function(e,t,n){const s=[];return function e(o){n.isBooleanLiteral(o)&&n.isPositionalCallArgument(o)&&s.push(function(e,t){const n=t.toPosition(e.startIndex);return{line:n.line,column:n.column,type:r.VIOLATION_TYPE.OPAQUE_BOOLEAN,severity:r.SEVERITY.LOW,message:`Opaque boolean literal: a bare '${e.text}' passed positionally tells the reader nothing without checking the callee's signature. Name it at the call site (a keyword argument, an object-literal field, or F#'s named-argument syntax) — or better, split into two clearly named functions (e.g. enableX()/disableX()) or use an enum.`}}(o,t));for(const t of o.children)e(t)}(e.rootNode),s};const r=n(613)},622(e,t,n){t.findParametersNode=s,t.analyzeParameterCount=function(e,t,n){const o=[];return function e(a){if(n.isFunctionDefinition(a)){const e=s(a,n.nodeTypes.parameters);if(e){const s=e.children.filter(e=>n.parameterChildTypes.includes(e.type)).length;if(s>5){const e=t.toPosition(a.startIndex);o.push({line:e.line,column:e.column,type:r.VIOLATION_TYPE.PARAMETERS,severity:s>8?r.SEVERITY.HIGH:r.SEVERITY.MEDIUM,message:`Parameter explosion: ${s} parameters. Consider using objects or builder pattern.`})}}}for(const t of a.children)e(t)}(e.rootNode),o};const r=n(613);function s(e,t){for(const n of e.children)if(n.type===t)return n;for(const n of e.children){const e=s(n,t);if(e)return e}}},164(e,t,n){t.analyzePrimitiveObsession=function(e,t,n){const a=[];return function e(i){if(n.isFunctionDefinition(i)){const e=(0,s.findParametersNode)(i,n.nodeTypes.parameters);e&&a.push(...function(e,t,n){const s=[];let o=!1;const a=[];for(const t of e.children){if(n.keywordOnlyBoundaryTypes.includes(t.type)){o=!0;continue}const e=n.extractTypedParameter(t);e&&a.push({...e,node:t,keywordOnly:o})}for(let e=0;e<a.length-1;e++){const o=a[e],i=a[e+1];if(o.type!==i.type||!n.primitiveTypeNames.has(o.type))continue;if(o.keywordOnly&&i.keywordOnly)continue;const _=t.toPosition(o.node.startIndex);s.push({line:_.line,column:_.column,type:r.VIOLATION_TYPE.PRIMITIVE_OBSESSION,severity:r.SEVERITY.MEDIUM,message:`Primitive obsession: consecutive parameters '${o.name}: ${o.type}' and '${i.name}: ${i.type}' share the same primitive type — a caller can swap them and nothing will complain. Consider ${n.distinctTypeAdvice} so the type checker catches it.`})}return s}(e,t,n)),a.push(...function(e,t,n){const{nodeTypes:s}=n,a=new Map,i=new Map;function _(e){return n.variableReferenceNodeTypes.includes(e.type)}function l(e,t){const n=e.text;a.has(n)||(a.set(n,new Set),i.set(n,e));const r=a.get(n);t.forEach(e=>r.add(e))}!function e(t){for(const{left:e,right:r}of n.getEqualityComparisons(t))_(e)&&r.type===s.stringLiteral?l(e,[o(r.text)]):_(r)&&e.type===s.stringLiteral&&l(r,[o(e.text)]);for(const{left:e,values:r}of n.getMembershipComparisons(t))_(e)&&r.length>0&&l(e,r);for(const n of t.children)e(n)}(e);const u=[];for(const[e,n]of a)if(n.size>=3){const s=i.get(e),o=t.toPosition(s.startIndex),a=Array.from(n).slice(0,4);u.push({line:o.line,column:o.column,type:r.VIOLATION_TYPE.PRIMITIVE_OBSESSION,severity:r.SEVERITY.LOW,message:`Stringly-typed control flow: '${e}' is compared against ${n.size} distinct string literals (${a.join(", ")}${n.size>a.length?", …":""}). Consider an Enum or Literal type to catch typos and get exhaustiveness checking.`})}return u}(i,t,n))}for(const t of i.children)e(t)}(e.rootNode),a};const r=n(613),s=n(622);function o(e){return e.slice(1,-1)}},119(e,t,n){var r,s=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=r(e),a=0;a<n.length;a++)"default"!==n[a]&&s(t,e,n[a]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.ESAIGNORE_FILENAME=void 0,t.loadIgnorePatterns=function(e){const n=_.join(e,t.ESAIGNORE_FILENAME);return i.existsSync(n)?i.readFileSync(n,"utf8").split("\n").map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith("#")).map(e=>e.replace(/\/+$/,"")):[]},t.isIgnored=function(e,t,n){if(0===n.length)return!1;const r=_.relative(t,e).split(_.sep).join("/"),s=_.basename(e);return n.some(e=>e.includes("*")?function(e){const t=e.split("*").map(e=>e.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`)}(e).test(s):function(e,t){return t.includes("/")?e===t||e.startsWith(`${t}/`):e.split("/").includes(t)}(r,e))};const i=a(n(896)),_=a(n(928));t.ESAIGNORE_FILENAME=".esaignore"},552(e,t){t.isUtilsFileName=function(e){return r((e.split("/").pop()||"").replace(/\.[^.]+$/,"")).some(e=>s.has(e))},t.looksLikeSingleDomainByNames=a,t.looksLikeSingleDomain=function(e,t){return a(e.map(e=>function(e){const t=e.children?.find(e=>"identifier"===e.type);return t?.text?r(t.text):[]}(e).join(" ")),t)};const n=/[A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+/g;function r(e){const t=e.match(n);return t?t.map(e=>e.toLowerCase()):[]}const s=new Set(["util","utils","helper","helpers","common"]);function o(e){if(0===e.length)return 0;const t=new Map;for(const n of e)t.set(n,(t.get(n)??0)+1);return Math.max(...t.values())/e.length}function a(e,t){const n=[],s=[];for(const t of e){const e=r(t);0!==e.length&&(n.push(e[0]),s.push(e[e.length-1]))}return 0!==n.length&&(o(n)>=t||o(s)>=t)}},599(e,t){t.createPositionLookup=function(e){const t=[0];for(let n=0;n<e.length;n++)"\n"===e[n]&&t.push(n+1);return{toPosition(e){let n=0,r=t.length-1;for(;n<r;){const s=Math.ceil((n+r)/2);t[s]<=e?n=s:r=s-1}return{line:n,column:e-t[n]}}}}},254(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeFile=a,t.summarize=function(e){const t=e.map(a),n=(0,o.emptyCounts)();let r=0;for(const e of t)r+=e.score,n.low+=e.counts.low,n.medium+=e.counts.medium,n.high+=e.counts.high;return{files:t,totalScore:r,totalCounts:n}},t.hasBlockingViolations=function(e){return e.medium>0||e.high>0},t.renderMarkdownReport=function(e){const t=e.files.filter(e=>0===e.score).length,n=[];n.push("# Energy State Report"),n.push(""),n.push(`**${e.files.length} file${1===e.files.length?"":"s"} scanned** — ${t} clean, ${e.files.length-t} with violations`),n.push(""),n.push("| File | Score | High | Medium | Low |"),n.push("| --- | --- | --- | --- | --- |");for(const t of e.files)n.push(`| ${t.filePath} | ${t.score} | ${t.counts.high} | ${t.counts.medium} | ${t.counts.low} |`);return n.push(""),n.push(`**Total score: ${e.totalScore}** (${e.totalCounts.high} high, ${e.totalCounts.medium} medium, ${e.totalCounts.low} low)`),n.join("\n")};const o=n(627);function a(e){const t=(0,o.emptyCounts)(),n={};for(const r of e.violations)t[r.severity]+=1,n[r.type]=(n[r.type]??0)+1;const r=1*t.low+4*t.medium+9*t.high;return{filePath:e.filePath,score:r,counts:t,byType:n}}s(n(701),t),s(n(997),t)},701(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.diffSummaries=function(e,t){const n=new Map(e.map(e=>[e.filePath,e.score]));return t.map(e=>{const t=n.get(e.filePath)??null,r=null===t?e.score:e.score-t,s=null===t?"new":r<0?"improved":r>0?"worsened":"unchanged";return{filePath:e.filePath,baseScore:t,headScore:e.score,delta:r,status:s}})},t.renderDiffMarkdown=function(e,t){const s=[];s.push(`# Energy State Diff vs \`${t}\``),s.push(""),s.push("| File | Base | Head | Δ | Status |"),s.push("| --- | --- | --- | --- | --- |");for(const t of e){const e=null===t.baseScore?"—":String(t.baseScore),r=null===t.baseScore?"—":t.delta>0?`+${t.delta}`:String(t.delta);s.push(`| ${t.filePath} | ${e} | ${t.headScore} | ${r} | ${n[t.status]} ${t.status} |`)}const o=e.reduce((e,t)=>(e[t.status]+=1,e),{...r});return s.push(""),s.push(`_${e.length} file${1===e.length?"":"s"} changed, ${o.worsened} worsened, ${o.improved} improved, ${o.new} new._`),s.join("\n")};const n={new:"🆕",improved:"🟢",worsened:"🔴",unchanged:"⚪"},r={new:0,improved:0,worsened:0,unchanged:0}},997(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.complexityToScore=_,t.classifyScore=l,t.classifyComplexityScore=function(e){return l(_(e))},t.renderHumanReport=function(e){const t=e.filter(e=>e.violations.length>0).sort((e,t)=>g(t.violations)-g(e.violations)),n=e.length-t.length,r=[];r.push("# Energy State Report"),r.push(""),r.push(E),r.push(""),r.push(`**${e.length} file${1===e.length?"":"s"} scanned** — ${n} clean, ${t.length} flagged`),r.push("");for(const e of t)r.push(y(e)),r.push("");r.push("## Total evaluation"),r.push("");const o=e.map(e=>({filePath:e.filePath,score:g(e.violations)})),a=o.reduce((e,t)=>t.score>e.score?t:e,{filePath:"",score:0}),i=l(a.score);a.score>0?r.push(`**Repo score: ${a.score.toFixed(1)} (${u[i]})** — driven by the worst file in the scan, \`${a.filePath}\` (${c[i]}).`):r.push("**Repo score: 0.0 (None)** — no violations were found anywhere in the scan."),r.push(""),r.push("This is the _maximum_ file score, not an average across files — see the note at the top of this report for why an average would hide the file most worth fixing."),r.push("");const _={none:0,low:0,medium:0,high:0,critical:0};for(const{score:e}of o)_[l(e)]+=1;r.push("| Risk | Files |"),r.push("| --- | --- |"),r.push(`| None | ${_.none} |`),r.push(`| Low | ${_.low} |`),r.push(`| Medium | ${_.medium} |`),r.push(`| High | ${_.high} |`),r.push(`| Critical | ${_.critical} |`),r.push("");const d=(0,s.emptyCounts)();for(const t of e)for(const e of t.violations)d[e.severity]+=1;const m=d.low+d.medium+d.high;return r.push(`**${m} total finding${1===m?"":"s"}** (${d.high} high, ${d.medium} medium, ${d.low} low) — breadth of issues across the scan, independent of peak severity.`),r.join("\n")};const r=n(613),s=n(627),o=[{value:0,score:0},{value:10,score:3.9},{value:20,score:6.9},{value:50,score:8.9},{value:100,score:10}],a=o[o.length-1].value,i=o[o.length-1].score;function _(e){if(e<=0)return 0;if(e>=a)return i;for(let t=1;t<o.length;t++){const n=o[t-1],r=o[t];if(e<=r.value){const t=(e-n.value)/(r.value-n.value);return Math.round(10*(n.score+t*(r.score-n.score)))/10}}return i}function l(e){return e<=0?"none":e<4?"low":e<7?"medium":e<9?"high":"critical"}const u={none:"None",low:"Low",medium:"Medium",high:"High",critical:"Critical"},c={none:"no violations found",low:"simple, easy to test exhaustively",medium:"getting harder to cover with tests",high:"complex, testing all paths is impractical",critical:"effectively untestable"},d={[r.VIOLATION_TYPE.NESTING]:"Nesting depth",[r.VIOLATION_TYPE.COMPLEXITY]:"Cyclomatic complexity",[r.VIOLATION_TYPE.COGNITIVE]:"Cognitive complexity",[r.VIOLATION_TYPE.NAMING]:"Naming",[r.VIOLATION_TYPE.COHERENCE]:"File coherence",[r.VIOLATION_TYPE.MAGIC]:"Magic values",[r.VIOLATION_TYPE.PARAMETERS]:"Parameter count",[r.VIOLATION_TYPE.INVERSION]:"Inversion opportunities",[r.VIOLATION_TYPE.PRIMITIVE_OBSESSION]:"Primitive obsession",[r.VIOLATION_TYPE.MATCH_OPPORTUNITY]:"Match opportunities",[r.VIOLATION_TYPE.LOGICAL_CONTROL_FLOW]:"Logical operator as control flow",[r.VIOLATION_TYPE.OPAQUE_BOOLEAN]:"Opaque boolean literals",[r.VIOLATION_TYPE.SUPPRESSION]:"Suppression directives"},m={[r.VIOLATION_TYPE.NESTING]:"control-flow blocks nested deep enough that a reader has to hold several levels of context in mind at once",[r.VIOLATION_TYPE.NAMING]:"naming that obscures intent",[r.VIOLATION_TYPE.COHERENCE]:"the file mixes too many responsibilities (too many functions/imports, or too many large functions) to read as one coherent unit",[r.VIOLATION_TYPE.MAGIC]:"unnamed literals standing in for a value that deserves a name",[r.VIOLATION_TYPE.PARAMETERS]:"a function with enough parameters that call sites are easy to get wrong",[r.VIOLATION_TYPE.INVERSION]:"validation/guard logic that would read more clearly as early returns",[r.VIOLATION_TYPE.PRIMITIVE_OBSESSION]:"adjacent same-typed values a caller could silently swap without the compiler noticing",[r.VIOLATION_TYPE.MATCH_OPPORTUNITY]:"an if/elif chain on one variable that would read more clearly as a match/switch",[r.VIOLATION_TYPE.LOGICAL_CONTROL_FLOW]:"&&/|| used to hide an if statement",[r.VIOLATION_TYPE.OPAQUE_BOOLEAN]:"a bare true/false at a call site that only makes sense by reading the callee",[r.VIOLATION_TYPE.SUPPRESSION]:"an esa-ignore comment that names an unknown violation type, or no longer matches any violation"},p=/complexity: (\d+)/i;function h(e){if(e.type!==r.VIOLATION_TYPE.COMPLEXITY&&e.type!==r.VIOLATION_TYPE.COGNITIVE)return;const t=e.message.match(p);return t?Number(t[1]):void 0}function f(e,t){const n=d[e]??e;if(e===r.VIOLATION_TYPE.COMPLEXITY||e===r.VIOLATION_TYPE.COGNITIVE)return function(e,t){const n=t.map(h).filter(e=>void 0!==e).sort((e,t)=>t-e);if(0===n.length)return"";const r=n[0],s=_(r),o=l(s);return`- **${e}**: ${1===n.length?`1 function scores ${r}`:`${n.length} functions score ${n.join(", ")} (worst: ${r})`} — score ${s.toFixed(1)} (${u[o]}): ${c[o]}.`}(n,t);const o=(0,s.emptyCounts)();for(const e of t)o[e.severity]+=1;const a=["high","medium","low"].filter(e=>o[e]>0).map(e=>`${o[e]} ${e}`).join(", "),i=m[e];return`- **${n}**: ${t.length} finding${1===t.length?"":"s"} (${a})${i?` — ${i}`:""}.`}function g(e){const t=e.map(h).filter(e=>void 0!==e);return t.length>0?_(Math.max(...t)):e.some(e=>e.severity===r.SEVERITY.HIGH)?7.5:e.some(e=>e.severity===r.SEVERITY.MEDIUM)?5:e.length>0?2:0}function y(e){const t=[],n=g(e.violations),r=l(n);t.push(`## ${e.filePath} — ${u[r]} (score ${n.toFixed(1)})`),t.push("");const s=new Map;for(const t of e.violations){const e=s.get(t.type)??[];e.push(t),s.set(t.type,e)}for(const[e,n]of s){const r=f(e,n);r&&t.push(r)}return t.join("\n")}const E=["## Score legend","","_Risk is reported on a 0.0–10.0 complexity score, sorted into the same None/Low/Medium/High/Critical levels already used elsewhere in this tool._","","| Score | Risk | Roughly | Cyclomatic/cognitive complexity |","| --- | --- | --- | --- |","| 0.0 | None | No violations found | — |","| 0.1–3.9 | Low | Simple, easy to test exhaustively | 1–10 |","| 4.0–6.9 | Medium | Getting harder to cover with tests | 11–20 |","| 7.0–8.9 | High | Complex, testing all paths is impractical | 21–50 |","| 9.0–10.0 | Critical | Effectively untestable | 50+ |","","_Cyclomatic and cognitive complexity numbers are converted to the score using the ranges above. Other detectors flag a pattern rather than a path count, so a file with no complexity violations of its own instead gets a fixed score from its worst other finding (Low 2.0 / Medium 5.0 / High 7.5)._"].join("\n")},53(e,t,n){var r,s=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=r(e),a=0;a<n.length;a++)"default"!==n[a]&&s(t,e,n[a]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.resolveSupportedFiles=function(e,t=process.cwd()){const n={rootDir:t,ignorePatterns:(0,u.loadIgnorePatterns)(t)},r=[];for(const t of e){if(t.includes("*")){r.push(...p(t,n));continue}if(!i.existsSync(t))continue;const e=i.statSync(t);e.isDirectory()?d(t,n)||m(t,n,r):e.isFile()&&(0,l.resolveLanguageForFile)(t)&&!d(t,n)&&r.push(t)}const s=r.map(e=>_.resolve(e));return Array.from(new Set(s)).sort()};const i=a(n(896)),_=a(n(928)),l=n(912),u=n(119),c=new Set(["node_modules",".git","dist","out","build",".next","coverage",".vscode-test"]);function d(e,t){return(0,u.isIgnored)(e,t.rootDir,t.ignorePatterns)}function m(e,t,n){for(const r of i.readdirSync(e,{withFileTypes:!0})){const s=_.join(e,r.name);c.has(r.name)||d(s,t)||(r.isDirectory()?m(s,t,n):r.isFile()&&(0,l.resolveLanguageForFile)(r.name)&&n.push(s))}}function p(e,t){const n=e.indexOf("*"),r=e.lastIndexOf(_.sep,n),s=-1===r?".":e.slice(0,r),o=e.slice(e.lastIndexOf(".")),a=o.startsWith(".")&&!o.includes("*")?o:void 0;if(!i.existsSync(s)||!i.statSync(s).isDirectory())return[];const l=[];return m(s,t,l),a?l.filter(e=>e.toLowerCase().endsWith(a.toLowerCase())):l}},627(e,t){t.emptyCounts=function(){return{low:0,medium:0,high:0}}},692(e,t,n){t.applySuppressions=function(e,t){const n=function(e){const t=e.split("\n"),n=[];return t.forEach((e,t)=>{const r=s.exec(e);if(!r)return;const{types:a,unknownTypes:i}=function(e){if(!e)return{types:"all",unknownTypes:[]};const t=e.split(",").map(e=>e.trim()).filter(Boolean);return{types:t.filter(e=>o.has(e)),unknownTypes:t.filter(e=>!o.has(e))}}(r[3]);n.push({line:t,column:r.index,scope:r[2]?"file":"line",types:a,unknownTypes:i,standalone:""===e.slice(0,r.index).trim()})}),n}(t);if(0===n.length)return{violations:e,suppressionNotes:[]};const a=new Map(n.map(e=>[e,0])),i=e.filter(e=>{const t=n.find(t=>{return function(e,t){return"file"===e.scope||(t===e.line||e.standalone&&t===e.line+1)}(t,e.line)&&(n=t,r=e.type,"all"===n.types||n.types.includes(r));var n,r});return!t||(a.set(t,(a.get(t)??0)+1),!1)}),_=[];for(const e of n)if(e.unknownTypes.length>0&&_.push({line:e.line,column:e.column,type:r.VIOLATION_TYPE.SUPPRESSION,severity:"low",message:`esa-ignore names unknown violation type(s): ${e.unknownTypes.join(", ")}.`}),0===(a.get(e)??0)){const t="file"===e.scope?"file-wide ":"";_.push({line:e.line,column:e.column,type:r.VIOLATION_TYPE.SUPPRESSION,severity:"low",message:`Unused ${t}esa-ignore — no matching violation found. Remove it or fix the type list.`})}return{violations:i,suppressionNotes:_}};const r=n(613),s=/(\/\/|#)\s*esa-ignore(-file)?(?::\s*([\w,\s-]+))?/,o=new Set(Object.values(r.VIOLATION_TYPE))},844(e,t,n){t.collectTypeSignals=a,t.typeCohesionResult=function(e,t,{maxDiversityRatio:n,minCoverage:r}){const s=e.map(e=>a(e,t)).filter(e=>e.size>0);if((0===e.length?0:s.length/e.length)<r)return{result:"insufficient-data",distinctTypes:0};const o=new Set;for(const e of s)for(const t of e)o.add(t);return{result:o.size/s.length<=n,distinctTypes:o.size}};const r=n(622),s=new Set(["Callable","Function","Any","None","Unit","void"]);function o(e,t){const n=e.trim();if(!n)return null;const r=n.indexOf(t.open),o=(-1===r?n:n.slice(0,r)).trim();return/^[A-Za-z_][A-Za-z0-9_.]*$/.test(o)?s.has(o)||/^[A-Z]$/.test(a=o)||/^_?T([A-Z]\w*|\d*)$/.test(a)?null:o:null;var a}function a(e,t){const n=new Set,s=(0,r.findParametersNode)(e,t.nodeTypes.parameters);if(s)for(const e of s.children){const r=t.extractTypedParameter(e);if(r){const e=o(r.type,t.genericBrackets);e&&n.add(e)}}const a=t.extractReturnType(e);if(a){const e=o(a,t.genericBrackets);e&&n.add(e)}return n}},964(e,t){t.FSHARP=void 0;const n="function_declaration_left";t.FSHARP={id:"fsharp",grammarPath:"grammars/tree-sitter-fsharp.wasm",nodeTypes:{block:null,parameters:"argument_patterns",ifStatement:"if_expression",elseClause:null,forStatement:"for_expression",whileStatement:"while_expression",conditionalExpression:null,lambda:"fun_expression",importStatement:"import_decl",importFromStatement:null,expressionStatement:null,assignment:"function_or_value_defn",module:"declaration_expression",exportStatement:null,comment:"line_comment",integerLiteral:"int",floatLiteral:"float",stringLiteral:"string"},isFunctionDefinition:e=>"function_or_value_defn"===e?.type&&e.children?.some(e=>e.type===n),parameterChildTypes:["long_identifier","typed_pattern"],decisionNodeTypes:["if_expression","elif_expression","for_expression","while_expression","try_expression","match_expression"],cognitiveNestedDecisionTypes:["if_expression","elif_expression","for_expression","while_expression","try_expression","match_expression"],nestingControlTypes:["if_expression","elif_expression","for_expression","while_expression","try_expression","match_expression"],getBooleanOperator(e){if(!e||"infix_expression"!==e.type)return null;const t=e.children?.find(e=>"infix_op"===e.type);return"&&"===t?.text?"and":"||"===t?.text?"or":null},entersNestedScope:()=>!0,isTryElseClause:()=>!1,variableReferenceNodeTypes:["long_identifier_or_op"],extractTypedParameter(e){if("typed_pattern"!==e?.type)return null;const t=e.children.find(e=>"identifier_pattern"===e.type),n=e.children.find(e=>"simple_type"===e.type||"generic_type"===e.type);return t&&n?{name:t.text,type:n.text}:null},extractReturnType(e){if("function_or_value_defn"!==e?.type)return null;const t=e.children.findIndex(e=>e.type===n),r=e.children.findIndex(e=>"="===e.type);if(-1===t||-1===r)return null;const s=e.children.findIndex((e,n)=>":"===e.type&&n>t&&n<r);return-1===s?null:e.children[s+1]?.text??null},genericBrackets:{open:"<",close:">"},primitiveTypeNames:new Set(["string","int","float","bool"]),keywordOnlyBoundaryTypes:[],distinctTypeAdvice:"a single-case union type",getEqualityComparisons(e){if("infix_expression"!==e?.type)return[];const t=e.children.find(e=>"infix_op"===e.type);if(!t||"="!==t.text)return[];const n=e.children.filter(e=>"infix_op"!==e.type);if(2!==n.length)return[];const[r,s]=n;return[{left:r,right:"const"===s.type&&1===s.children?.length?s.children[0]:s}]},getMembershipComparisons:()=>[],getElseIfBranches:e=>e?.children?.filter(e=>"elif_expression"===e.type)??[],subscriptNodeTypes:[],isFormattedOrInterpolatedString:()=>!1,isDefaultParameterValue:()=>!1,isBooleanLiteral:e=>"const"===e?.type&&1===e.children?.length&&"bool"===e.children[0]?.type,isPositionalCallArgument(e){const t=e?.parent;return"application_expression"===t?.type?t.children?.[0]?.id!==e.id:"tuple_expression"===t?.type&&"application_expression"===t.parent?.type},isExplicitConstant:()=>!1,importSource(e){const t=e?.children?.find(e=>"long_identifier"===e.type);return t?.text??e?.text??""},classDefinitionNodeTypes:[],getClassName:()=>null,getBaseClassNames:()=>[]}},912(e,t,n){t.Y=void 0,t.resolveLanguageForFile=function(e){const n=e.lastIndexOf(".");if(-1===n)return;const r=e.slice(n).toLowerCase(),s=i[r];return s?t.Y[s]:void 0};const r=n(996),s=n(964),o=n(501),a=n(135);t.Y={python:r.PYTHON,fsharp:s.FSHARP,typescript:o.TYPESCRIPT,kotlin:a.KOTLIN};const i={".py":"python",".fs":"fsharp",".fsx":"fsharp",".fsi":"fsharp",".ts":"typescript",".kt":"kotlin",".kts":"kotlin"}},135(e,t){function n(e){const t=e.children?.find(r)??e.children?.find(e=>"constructor_invocation"===e.type)?.children?.find(r);return t?.children?.find(e=>"identifier"===e.type)?.text??null}function r(e){return"user_type"===e?.type}t.KOTLIN=void 0,t.KOTLIN={id:"kotlin",grammarPath:"grammars/tree-sitter-kotlin.wasm",nodeTypes:{block:"block",parameters:"function_value_parameters",ifStatement:"if_expression",elseClause:null,forStatement:"for_statement",whileStatement:"while_statement",conditionalExpression:null,lambda:"lambda_literal",importStatement:"import",importFromStatement:null,expressionStatement:null,assignment:"property_declaration",module:"source_file",exportStatement:null,comment:"line_comment",integerLiteral:"number_literal",floatLiteral:"float_literal",stringLiteral:"string_literal"},isFunctionDefinition:e=>"function_declaration"===e?.type,parameterChildTypes:["parameter"],decisionNodeTypes:["if_expression","for_statement","while_statement","when_expression","catch_block"],cognitiveNestedDecisionTypes:["if_expression","for_statement","while_statement","when_expression","catch_block"],nestingControlTypes:["if_expression","for_statement","while_statement","try_expression"],getBooleanOperator(e){if(!e||"binary_expression"!==e.type)return null;const t=e.children?.find(e=>"&&"===e.type||"||"===e.type);return t?"&&"===t.type?"and":"or":null},entersNestedScope:e=>"block"===e?.type,isTryElseClause:()=>!1,variableReferenceNodeTypes:["identifier","navigation_expression"],extractTypedParameter(e){if("parameter"!==e?.type)return null;const t=e.children.find(e=>"identifier"===e.type),n=e.children.find(r);if(!t||!n)return null;const s=n.children?.find(e=>"identifier"===e.type);return s?{name:t.text,type:s.text}:null},extractReturnType(e){const t=e?.children?.findIndex(e=>":"===e.type)??-1;return-1===t?null:e.children[t+1]?.text??null},genericBrackets:{open:"<",close:">"},primitiveTypeNames:new Set(["Int","Long","Short","Byte","Double","Float","Boolean","String","Char"]),keywordOnlyBoundaryTypes:[],distinctTypeAdvice:"a value class (@JvmInline value class)",getEqualityComparisons(e){if("binary_expression"!==e?.type)return[];const t=e.children.find(e=>"=="===e.type||"==="===e.type);if(!t)return[];const n=e.children.filter(e=>e!==t);return 2!==n.length?[]:[{left:n[0],right:n[1]}]},getMembershipComparisons:()=>[],getElseIfBranches:()=>[],subscriptNodeTypes:["index_expression"],isFormattedOrInterpolatedString:e=>e?.children?.some(e=>"interpolation"===e.type)??!1,isDefaultParameterValue(e){const t=e?.parent;if("function_value_parameters"!==t?.type)return!1;const n=t.children??[],r=n.findIndex(t=>t.id===e.id);return r>=2&&"="===n[r-1]?.type&&"parameter"===n[r-2]?.type},isBooleanLiteral:e=>"identifier"===e?.type&&("true"===e.text||"false"===e.text),isPositionalCallArgument(e){const t=e?.parent;return"value_argument"===t?.type&&"value_arguments"===t.parent?.type&&"call_expression"===t.parent.parent?.type&&t.children?.[0]?.id===e.id},isExplicitConstant:e=>"property_declaration"===e?.type?function(e){const t=e.children?.find(e=>"modifiers"===e.type);return t?.children?.some(e=>"property_modifier"===e.type&&e.children?.some(e=>"const"===e.type))??!1}(e):"assignment"===e?.type&&function(e){const t=e.children?.find(e=>"annotated_expression"===e.type),n=t?.children?.find(e=>"infix_expression"===e.type),r=n?.children?.filter(e=>"identifier"===e.type)??[];return 3===r.length&&"const"===r[0]?.text&&"val"===r[1]?.text}(e),importSource(e){const t=e?.children?.find(e=>"qualified_identifier"===e.type);if(!t?.text)return e?.text??"";const n=e.children?.some(e=>"*"===e.type);if(n)return t.text;const r=t.text.lastIndexOf(".");return-1===r?t.text:t.text.slice(0,r)},classDefinitionNodeTypes:["class_declaration"],getClassName:e=>e?.children?.find(e=>"identifier"===e.type)?.text??null,getBaseClassNames(e){const t=e?.children?.find(e=>"delegation_specifiers"===e.type);return t?(t.children??[]).filter(e=>"delegation_specifier"===e.type).map(n).filter(e=>null!==e):[]}}},996(e,t){t.PYTHON=void 0;const n="type",r="argument_list",s="attribute";t.PYTHON={id:"python",grammarPath:"grammars/tree-sitter-python.wasm",nodeTypes:{block:"block",parameters:"parameters",ifStatement:"if_statement",elseClause:"else_clause",forStatement:"for_statement",whileStatement:"while_statement",conditionalExpression:"conditional_expression",lambda:"lambda",importStatement:"import_statement",importFromStatement:"import_from_statement",expressionStatement:"expression_statement",assignment:"assignment",module:"module",exportStatement:null,comment:"comment",integerLiteral:"integer",floatLiteral:"float",stringLiteral:"string"},isFunctionDefinition:e=>"function_definition"===e?.type,parameterChildTypes:["identifier","default_parameter"],decisionNodeTypes:["if_statement","elif_clause","while_statement","for_statement","except_clause","conditional_expression","match_statement"],cognitiveNestedDecisionTypes:["if_statement","elif_clause","for_statement","while_statement","except_clause","match_statement"],nestingControlTypes:["if_statement","for_statement","while_statement","with_statement","try_statement","match_statement"],getBooleanOperator(e){if(!e||"boolean_operator"!==e.type)return null;const t=e.children?.find(e=>"and"===e.type||"or"===e.type);return t?t.type:null},entersNestedScope:e=>"block"===e?.type,isTryElseClause:e=>"else_clause"===e?.type&&"try_statement"===e?.parent?.type,variableReferenceNodeTypes:["identifier","attribute"],extractTypedParameter(e){if("typed_parameter"!==e?.type&&"typed_default_parameter"!==e?.type)return null;const t=e.children.find(e=>"identifier"===e.type),r=e.children.find(e=>e.type===n);return t&&r?{name:t.text,type:r.text}:null},extractReturnType(e){const t=e?.children?.findIndex(e=>"->"===e.type)??-1;if(-1===t)return null;const r=e.children[t+1];return r?.type===n?r.text:null},genericBrackets:{open:"[",close:"]"},primitiveTypeNames:new Set(["str","int","float","bool","bytes"]),keywordOnlyBoundaryTypes:["keyword_separator","list_splat_pattern"],distinctTypeAdvice:"NewType or a dataclass",getEqualityComparisons(e){if("comparison_operator"!==e?.type)return[];const t=[],n=e.children;for(let e=1;e<n.length-1;e++)"=="===n[e].type&&t.push({left:n[e-1],right:n[e+1]});return t},getMembershipComparisons(e){if("comparison_operator"!==e?.type)return[];const t=[],n=e.children;for(let e=1;e<n.length-1;e++){if("in"!==n[e].type)continue;const r=n[e-1],s=n[e+1];if("tuple"!==s.type&&"list"!==s.type&&"set"!==s.type)continue;const o=[];let a=!0;for(const e of s.children)if(e.isNamed){if("string"!==e.type){a=!1;break}o.push(e.text.slice(1,-1))}a&&o.length>0&&t.push({left:r,values:o})}return t},getElseIfBranches:e=>e?.children?.filter(e=>"elif_clause"===e.type)??[],subscriptNodeTypes:["subscript"],isFormattedOrInterpolatedString(e){if(e?.children?.some(e=>"interpolation"===e.type))return!0;const t=e?.parent;if("binary_operator"===t?.type&&t.children?.[0]?.id===e.id&&t.children?.some(e=>"%"===e.type))return!0;if(t?.type===s&&t.children?.[0]?.id===e.id){const e=t.children?.find(e=>"identifier"===e.type);if("format"===e?.text&&"call"===t.parent?.type)return!0}return!1},isDefaultParameterValue(e){const t=e?.parent;return("default_parameter"===t?.type||"typed_default_parameter"===t?.type)&&t.children?.[t.children.length-1]?.id===e.id},isBooleanLiteral:e=>"true"===e?.type||"false"===e?.type,isPositionalCallArgument:e=>e?.parent?.type===r&&"call"===e.parent.parent?.type,isExplicitConstant:()=>!1,importSource(e){const t=e?.children??[];if("import_from_statement"===e?.type){const n=t.findIndex(e=>"import"===e.type);return t[n-1]?.text??e.text??""}const n=t.find(e=>"dotted_name"===e.type);return n?.text??e?.text??""},classDefinitionNodeTypes:["class_definition"],getClassName:e=>e?.children?.find(e=>"identifier"===e.type)?.text??null,getBaseClassNames(e){const t=e?.children?.find(e=>e.type===r);return t?t.children.filter(e=>"identifier"===e.type||e.type===s).map(e=>e.text):[]}}},501(e,t){t.TYPESCRIPT=void 0;const n="type_annotation",r="type_identifier";function s(e){const t=e.children?.find(e=>"extends_clause"===e.type),n=t?.children?.find(e=>"extends"!==e.type);return n?[n.text]:[]}function o(e){const t=e.children?.find(e=>"implements_clause"===e.type);return(t?.children??[]).filter(e=>e.type===r).map(e=>e.text)}t.TYPESCRIPT={id:"typescript",grammarPath:"grammars/tree-sitter-typescript.wasm",nodeTypes:{block:"statement_block",parameters:"formal_parameters",ifStatement:"if_statement",elseClause:"else_clause",forStatement:"for_statement",whileStatement:"while_statement",conditionalExpression:"ternary_expression",lambda:"arrow_function",importStatement:"import_statement",importFromStatement:null,expressionStatement:"expression_statement",assignment:"lexical_declaration",module:"program",exportStatement:"export_statement",comment:"comment",integerLiteral:"number",floatLiteral:null,stringLiteral:"string"},isFunctionDefinition:e=>"function_declaration"===e?.type||"method_definition"===e?.type,parameterChildTypes:["required_parameter","optional_parameter"],decisionNodeTypes:["if_statement","for_statement","for_in_statement","while_statement","catch_clause","ternary_expression"],cognitiveNestedDecisionTypes:["if_statement","for_statement","for_in_statement","while_statement","catch_clause"],nestingControlTypes:["if_statement","for_statement","for_in_statement","while_statement","try_statement"],getBooleanOperator(e){if(!e||"binary_expression"!==e.type)return null;const t=e.children?.find(e=>"&&"===e.type||"||"===e.type);return t?"&&"===t.type?"and":"or":null},entersNestedScope:e=>"statement_block"===e?.type,isTryElseClause:()=>!1,variableReferenceNodeTypes:["identifier","member_expression"],extractTypedParameter(e){if("required_parameter"!==e?.type&&"optional_parameter"!==e?.type)return null;const t=e.children.find(e=>"identifier"===e.type),r=e.children.find(e=>e.type===n);if(!t||!r)return null;const s=r.children.find(e=>":"!==e.type);return s?{name:t.text,type:s.text}:null},extractReturnType(e){const t=e?.children?.find(e=>e.type===n);if(!t)return null;const r=t.children.find(e=>":"!==e.type);return r?.text??null},genericBrackets:{open:"<",close:">"},primitiveTypeNames:new Set(["string","number","boolean"]),keywordOnlyBoundaryTypes:[],distinctTypeAdvice:"a branded/nominal type (e.g. a tagged type alias)",getEqualityComparisons(e){if("binary_expression"!==e?.type)return[];const t=e.children.find(e=>"==="===e.type||"=="===e.type);if(!t)return[];const n=e.children.filter(e=>e!==t);return 2!==n.length?[]:[{left:n[0],right:n[1]}]},getMembershipComparisons:()=>[],getElseIfBranches:()=>[],subscriptNodeTypes:["subscript_expression"],isFormattedOrInterpolatedString:()=>!1,isDefaultParameterValue(e){const t=e?.parent;return("required_parameter"===t?.type||"optional_parameter"===t?.type)&&t.children?.some(e=>"="===e.type)&&t.children?.[t.children.length-1]?.id===e.id},isBooleanLiteral:e=>"true"===e?.type||"false"===e?.type,isPositionalCallArgument:e=>"arguments"===e?.parent?.type&&"call_expression"===e.parent.parent?.type,isExplicitConstant:()=>!1,importSource(e){const t=e?.children?.find(e=>"string"===e.type);return t?.text??e?.text??""},classDefinitionNodeTypes:["class_declaration","abstract_class_declaration"],getClassName:e=>e?.children?.find(e=>e.type===r)?.text??null,getBaseClassNames(e){const t=e?.children?.find(e=>"class_heritage"===e.type);return t?[...s(t),...o(t)]:[]}}},613(e,t){t.VIOLATION_TYPE=t.SEVERITY=void 0,t.SEVERITY={LOW:"low",MEDIUM:"medium",HIGH:"high"},t.VIOLATION_TYPE={NESTING:"nesting",COMPLEXITY:"complexity",COGNITIVE:"cognitive",NAMING:"naming",COHERENCE:"coherence",MAGIC:"magic",PARAMETERS:"parameters",INVERSION:"inversion",PRIMITIVE_OBSESSION:"primitive-obsession",MATCH_OPPORTUNITY:"match-opportunity",LOGICAL_CONTROL_FLOW:"logical-control-flow",OPAQUE_BOOLEAN:"opaque-boolean",SUPPRESSION:"suppression"}},317(e){e.exports=require("child_process")},896(e){e.exports=require("fs")},943(e){e.exports=require("fs/promises")},928(e){e.exports=require("path")},43(module,exports,__webpack_require__){var __WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__,__create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__name=(e,t)=>__defProp(e,"name",{value:t,configurable:!0}),__commonJS=(e,t)=>function(){return t||(0,e[__getOwnPropNames(e)[0]])((t={exports:{}}).exports,t),t.exports},__export=(e,t)=>{for(var n in t)__defProp(e,n,{get:t[n],enumerable:!0})},__copyProps=(e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of __getOwnPropNames(t))__hasOwnProp.call(e,s)||s===n||__defProp(e,s,{get:()=>t[s],enumerable:!(r=__getOwnPropDesc(t,s))||r.enumerable});return e},__toESM=(e,t,n)=>(n=null!=e?__create(__getProtoOf(e)):{},__copyProps(!t&&e&&e.__esModule?n:__defProp(n,"default",{value:e,enumerable:!0}),e)),__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),require_web_tree_sitter=__commonJS({"lib/web-tree-sitter.cjs"(exports,module){var Module=(()=>{var _scriptName="undefined"!=typeof document?document.currentScript?.src:void 0;return async function(moduleArg={}){var moduleRtn,Module=moduleArg,ENVIRONMENT_IS_WEB="object"==typeof window,ENVIRONMENT_IS_WORKER="undefined"!=typeof WorkerGlobalScope,ENVIRONMENT_IS_NODE="object"==typeof process&&process.versions?.node&&"renderer"!=process.type;Module.currentQueryProgressCallback=null,Module.currentProgressCallback=null,Module.currentLogCallback=null,Module.currentParseCallback=null;var arguments_=[],thisProgram="./this.program",quit_=__name((e,t)=>{throw t},"quit_");_scriptName=__filename;var scriptDirectory="",readAsync,readBinary;function locateFile(e){return Module.locateFile?Module.locateFile(e,scriptDirectory):scriptDirectory+e}if(__name(locateFile,"locateFile"),ENVIRONMENT_IS_NODE){var fs=__webpack_require__(896);scriptDirectory=__dirname+"/",readBinary=__name(e=>(e=isFileURI(e)?new URL(e):e,fs.readFileSync(e)),"readBinary"),readAsync=__name(async(e,t=!0)=>(e=isFileURI(e)?new URL(e):e,fs.readFileSync(e,t?void 0:"utf8")),"readAsync"),process.argv.length>1&&(thisProgram=process.argv[1].replace(/\\/g,"/")),arguments_=process.argv.slice(2),quit_=__name((e,t)=>{throw process.exitCode=e,t},"quit_")}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}ENVIRONMENT_IS_WORKER&&(readBinary=__name(e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)},"readBinary")),readAsync=__name(async e=>{if(isFileURI(e))return new Promise((t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n(r.status)},r.onerror=n,r.send(null)});var t=await fetch(e,{credentials:"same-origin"});if(t.ok)return t.arrayBuffer();throw new Error(t.status+" : "+t.url)},"readAsync")}var out=console.log.bind(console),err=console.error.bind(console),dynamicLibraries=[],wasmBinary,ABORT=!1,EXITSTATUS,isFileURI=__name(e=>e.startsWith("file://"),"isFileURI"),readyPromiseResolve,readyPromiseReject,wasmMemory,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64,HEAP64,HEAPU64,HEAP_DATA_VIEW,runtimeInitialized=!1;function updateMemoryViews(){var e=wasmMemory.buffer;Module.HEAP8=HEAP8=new Int8Array(e),Module.HEAP16=HEAP16=new Int16Array(e),Module.HEAPU8=HEAPU8=new Uint8Array(e),Module.HEAPU16=HEAPU16=new Uint16Array(e),Module.HEAP32=HEAP32=new Int32Array(e),Module.HEAPU32=HEAPU32=new Uint32Array(e),Module.HEAPF32=HEAPF32=new Float32Array(e),Module.HEAPF64=HEAPF64=new Float64Array(e),Module.HEAP64=HEAP64=new BigInt64Array(e),Module.HEAPU64=HEAPU64=new BigUint64Array(e),Module.HEAP_DATA_VIEW=HEAP_DATA_VIEW=new DataView(e),LE_HEAP_UPDATE()}function initMemory(){if(Module.wasmMemory)wasmMemory=Module.wasmMemory;else{var e=Module.INITIAL_MEMORY||33554432;wasmMemory=new WebAssembly.Memory({initial:e/65536,maximum:32768})}updateMemoryViews()}__name(updateMemoryViews,"updateMemoryViews"),__name(initMemory,"initMemory");var __RELOC_FUNCS__=[],wasmBinaryFile;function preRun(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),wasmExports.__wasm_call_ctors(),callRuntimeCallbacks(onPostCtors)}function preMain(){}function postRun(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(onPostRuns)}function abort(e){Module.onAbort?.(e),err(e="Aborted("+e+")"),ABORT=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw readyPromiseReject?.(t),t}function findWasmBinary(){return locateFile("web-tree-sitter.wasm")}function getBinarySync(e){if(e==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(e);throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(e){if(!wasmBinary)try{var t=await readAsync(e);return new Uint8Array(t)}catch{}return getBinarySync(e)}async function instantiateArrayBuffer(e,t){try{var n=await getWasmBinary(e);return await WebAssembly.instantiate(n,t)}catch(e){err(`failed to asynchronously prepare wasm: ${e}`),abort(e)}}async function instantiateAsync(e,t,n){if(!e&&!isFileURI(t)&&!ENVIRONMENT_IS_NODE)try{var r=fetch(t,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(r,n)}catch(e){err(`wasm streaming compile failed: ${e}`),err("falling back to ArrayBuffer instantiation")}return instantiateArrayBuffer(t,n)}function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports,"GOT.mem":new Proxy(wasmImports,GOTHandler),"GOT.func":new Proxy(wasmImports,GOTHandler)}}async function createWasm(){function e(e,t){wasmExports=e.exports,wasmExports=relocateExports(wasmExports,1024);var n=getDylinkMetadata(t);return n.neededDynlibs&&(dynamicLibraries=n.neededDynlibs.concat(dynamicLibraries)),mergeLibSymbols(wasmExports,"main"),LDSO.init(),loadDylibs(),__RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs),assignWasmExports(wasmExports),wasmExports}function t(t){return e(t.instance,t.module)}__name(e,"receiveInstance"),__name(t,"receiveInstantiationResult");var n=getWasmImports();return Module.instantiateWasm?new Promise((t,r)=>{Module.instantiateWasm(n,(n,r)=>{t(e(n,r))})}):(wasmBinaryFile??=findWasmBinary(),t(await instantiateAsync(wasmBinary,wasmBinaryFile,n)))}__name(preRun,"preRun"),__name(initRuntime,"initRuntime"),__name(preMain,"preMain"),__name(postRun,"postRun"),__name(abort,"abort"),__name(findWasmBinary,"findWasmBinary"),__name(getBinarySync,"getBinarySync"),__name(getWasmBinary,"getWasmBinary"),__name(instantiateArrayBuffer,"instantiateArrayBuffer"),__name(instantiateAsync,"instantiateAsync"),__name(getWasmImports,"getWasmImports"),__name(createWasm,"createWasm");class ExitStatus{static{__name(this,"ExitStatus")}name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var GOT={},currentModuleWeakSymbols=new Set([]),GOTHandler={get(e,t){var n=GOT[t];return n||(n=GOT[t]=new WebAssembly.Global({value:"i32",mutable:!0})),currentModuleWeakSymbols.has(t)||(n.required=!0),n}},LE_ATOMICS_NATIVE_BYTE_ORDER=[],LE_HEAP_LOAD_F32=__name(e=>HEAP_DATA_VIEW.getFloat32(e,!0),"LE_HEAP_LOAD_F32"),LE_HEAP_LOAD_F64=__name(e=>HEAP_DATA_VIEW.getFloat64(e,!0),"LE_HEAP_LOAD_F64"),LE_HEAP_LOAD_I16=__name(e=>HEAP_DATA_VIEW.getInt16(e,!0),"LE_HEAP_LOAD_I16"),LE_HEAP_LOAD_I32=__name(e=>HEAP_DATA_VIEW.getInt32(e,!0),"LE_HEAP_LOAD_I32"),LE_HEAP_LOAD_I64=__name(e=>HEAP_DATA_VIEW.getBigInt64(e,!0),"LE_HEAP_LOAD_I64"),LE_HEAP_LOAD_U32=__name(e=>HEAP_DATA_VIEW.getUint32(e,!0),"LE_HEAP_LOAD_U32"),LE_HEAP_STORE_F32=__name((e,t)=>HEAP_DATA_VIEW.setFloat32(e,t,!0),"LE_HEAP_STORE_F32"),LE_HEAP_STORE_F64=__name((e,t)=>HEAP_DATA_VIEW.setFloat64(e,t,!0),"LE_HEAP_STORE_F64"),LE_HEAP_STORE_I16=__name((e,t)=>HEAP_DATA_VIEW.setInt16(e,t,!0),"LE_HEAP_STORE_I16"),LE_HEAP_STORE_I32=__name((e,t)=>HEAP_DATA_VIEW.setInt32(e,t,!0),"LE_HEAP_STORE_I32"),LE_HEAP_STORE_I64=__name((e,t)=>HEAP_DATA_VIEW.setBigInt64(e,t,!0),"LE_HEAP_STORE_I64"),LE_HEAP_STORE_U32=__name((e,t)=>HEAP_DATA_VIEW.setUint32(e,t,!0),"LE_HEAP_STORE_U32"),callRuntimeCallbacks=__name(e=>{for(;e.length>0;)e.shift()(Module)},"callRuntimeCallbacks"),onPostRuns=[],addOnPostRun=__name(e=>onPostRuns.push(e),"addOnPostRun"),onPreRuns=[],addOnPreRun=__name(e=>onPreRuns.push(e),"addOnPreRun"),UTF8Decoder="undefined"!=typeof TextDecoder?new TextDecoder:void 0,findStringEnd=__name((e,t,n,r)=>{var s=t+n;if(r)return s;for(;e[t]&&!(t>=s);)++t;return t},"findStringEnd"),UTF8ArrayToString=__name((e,t=0,n,r)=>{var s=findStringEnd(e,t,n,r);if(s-t>16&&e.buffer&&UTF8Decoder)return UTF8Decoder.decode(e.subarray(t,s));for(var o="";t<s;){var a=e[t++];if(128&a){var i=63&e[t++];if(192!=(224&a)){var _=63&e[t++];if((a=224==(240&a)?(15&a)<<12|i<<6|_:(7&a)<<18|i<<12|_<<6|63&e[t++])<65536)o+=String.fromCharCode(a);else{var l=a-65536;o+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else o+=String.fromCharCode((31&a)<<6|i)}else o+=String.fromCharCode(a)}return o},"UTF8ArrayToString"),getDylinkMetadata=__name(e=>{var t=0,n=0;function r(){return e[t++]}function s(){for(var n=0,r=1;;){var s=e[t++];if(n+=(127&s)*r,r*=128,!(128&s))break}return n}function o(){var n=s();return UTF8ArrayToString(e,(t+=n)-n,n)}function a(){for(var e=s(),t=[];e--;)t.push(o());return t}function i(e,t){if(e)throw new Error(t)}if(__name(r,"getU8"),__name(s,"getLEB"),__name(o,"getString"),__name(a,"getStringList"),__name(i,"failIf"),e instanceof WebAssembly.Module){var _=WebAssembly.Module.customSections(e,"dylink.0");i(0===_.length,"need dylink section"),n=(e=new Uint8Array(_[0])).length}else{var l=new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer);i(!(1836278016==l[0]||6386541==l[0]),"need to see wasm magic number"),i(0!==e[8],"need the dylink section to be first"),t=9;var u=s();n=t+u,i("dylink.0"!==o())}for(var c={neededDynlibs:[],tlsExports:new Set,weakImports:new Set,runtimePaths:[]};t<n;){var d=r(),m=s();if(1===d)c.memorySize=s(),c.memoryAlign=s(),c.tableSize=s(),c.tableAlign=s();else if(2===d)c.neededDynlibs=a();else if(3===d)for(var p=s();p--;){var h=o();256&s()&&c.tlsExports.add(h)}else if(4===d)for(p=s();p--;)o(),h=o(),1==(3&s())&&c.weakImports.add(h);else 5===d?c.runtimePaths=a():t+=m}return c},"getDylinkMetadata");function getValue(e,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":case"i8":return HEAP8[e];case"i16":return LE_HEAP_LOAD_I16(2*(e>>1));case"i32":return LE_HEAP_LOAD_I32(4*(e>>2));case"i64":return LE_HEAP_LOAD_I64(8*(e>>3));case"float":return LE_HEAP_LOAD_F32(4*(e>>2));case"double":return LE_HEAP_LOAD_F64(8*(e>>3));case"*":return LE_HEAP_LOAD_U32(4*(e>>2));default:abort(`invalid type for getValue: ${t}`)}}__name(getValue,"getValue");var newDSO=__name((e,t,n)=>{var r={refcount:1/0,name:e,exports:n,global:!0};return LDSO.loadedLibsByName[e]=r,null!=t&&(LDSO.loadedLibsByHandle[t]=r),r},"newDSO"),LDSO={loadedLibsByName:{},loadedLibsByHandle:{},init(){newDSO("__main__",0,wasmImports)}},___heap_base=78240,alignMemory=__name((e,t)=>Math.ceil(e/t)*t,"alignMemory"),getMemory=__name(e=>{if(runtimeInitialized)return _calloc(e,1);var t=___heap_base,n=t+alignMemory(e,16);return ___heap_base=n,GOT.__heap_base.value=n,t},"getMemory"),isInternalSym=__name(e=>["__cpp_exception","__c_longjmp","__wasm_apply_data_relocs","__dso_handle","__tls_size","__tls_align","__set_stack_limits","_emscripten_tls_init","__wasm_init_tls","__wasm_call_ctors","__start_em_asm","__stop_em_asm","__start_em_js","__stop_em_js"].includes(e)||e.startsWith("__em_js__"),"isInternalSym"),uleb128EncodeWithLen=__name(e=>{const t=e.length;return[t%128|128,t>>7,...e]},"uleb128EncodeWithLen"),wasmTypeCodes={i:127,p:127,j:126,f:125,d:124,e:111},generateTypePack=__name(e=>uleb128EncodeWithLen(Array.from(e,e=>wasmTypeCodes[e])),"generateTypePack"),convertJsFunctionToWasm=__name((e,t)=>{var n=Uint8Array.of(0,97,115,109,1,0,0,0,1,...uleb128EncodeWithLen([1,96,...generateTypePack(t.slice(1)),...generateTypePack("v"===t[0]?"":t[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),r=new WebAssembly.Module(n);return new WebAssembly.Instance(r,{e:{f:e}}).exports.f},"convertJsFunctionToWasm"),wasmTableMirror=[],wasmTable=new WebAssembly.Table({initial:31,element:"anyfunc"}),getWasmTableEntry=__name(e=>{var t=wasmTableMirror[e];return t||(wasmTableMirror[e]=t=wasmTable.get(e)),t},"getWasmTableEntry"),updateTableMap=__name((e,t)=>{if(functionsInTableMap)for(var n=e;n<e+t;n++){var r=getWasmTableEntry(n);r&&functionsInTableMap.set(r,n)}},"updateTableMap"),functionsInTableMap,getFunctionAddress=__name(e=>(functionsInTableMap||(functionsInTableMap=new WeakMap,updateTableMap(0,wasmTable.length)),functionsInTableMap.get(e)||0),"getFunctionAddress"),freeTableIndexes=[],getEmptyTableSlot=__name(()=>freeTableIndexes.length?freeTableIndexes.pop():wasmTable.grow(1),"getEmptyTableSlot"),setWasmTableEntry=__name((e,t)=>{wasmTable.set(e,t),wasmTableMirror[e]=wasmTable.get(e)},"setWasmTableEntry"),addFunction=__name((e,t)=>{var n=getFunctionAddress(e);if(n)return n;var r=getEmptyTableSlot();try{setWasmTableEntry(r,e)}catch(n){if(!(n instanceof TypeError))throw n;var s=convertJsFunctionToWasm(e,t);setWasmTableEntry(r,s)}return functionsInTableMap.set(e,r),r},"addFunction"),updateGOT=__name((e,t)=>{for(var n in e)if(!isInternalSym(n)){var r=e[n];GOT[n]||=new WebAssembly.Global({value:"i32",mutable:!0}),(t||0==GOT[n].value)&&("function"==typeof r?GOT[n].value=addFunction(r):"number"==typeof r?GOT[n].value=r:err(`unhandled export type for '${n}': ${typeof r}`))}},"updateGOT"),relocateExports=__name((e,t,n)=>{var r={};for(var s in e){var o=e[s];"object"==typeof o&&(o=o.value),"number"==typeof o&&(o+=t),r[s]=o}return updateGOT(r,n),r},"relocateExports"),isSymbolDefined=__name(e=>{var t=wasmImports[e];return!(!t||t.stub)},"isSymbolDefined"),dynCall=__name((e,t,n=[],r=!1)=>{var s=getWasmTableEntry(t)(...n);return __name(function(e){return e},"convert"),s},"dynCall"),stackSave=__name(()=>_emscripten_stack_get_current(),"stackSave"),stackRestore=__name(e=>__emscripten_stack_restore(e),"stackRestore"),createInvokeFunction=__name(e=>(t,...n)=>{var r=stackSave();try{return dynCall(e,t,n)}catch(t){if(stackRestore(r),t!==t+0)throw t;if(_setThrew(1,0),"j"==e[0])return 0n}},"createInvokeFunction"),resolveGlobalSymbol=__name((e,t=!1)=>{var n;return isSymbolDefined(e)?n=wasmImports[e]:e.startsWith("invoke_")&&(n=wasmImports[e]=createInvokeFunction(e.split("_")[1])),{sym:n,name:e}},"resolveGlobalSymbol"),onPostCtors=[],addOnPostCtor=__name(e=>onPostCtors.push(e),"addOnPostCtor"),UTF8ToString=__name((e,t,n)=>e?UTF8ArrayToString(HEAPU8,e,t,n):"","UTF8ToString"),loadWebAssemblyModule=__name((binary,flags,libName,localScope,handle)=>{var metadata=getDylinkMetadata(binary);function loadModule(){var memAlign=Math.pow(2,metadata.memoryAlign),memoryBase=metadata.memorySize?alignMemory(getMemory(metadata.memorySize+memAlign),memAlign):0,tableBase=metadata.tableSize?wasmTable.length:0,moduleExports;function resolveSymbol(e){var t=resolveGlobalSymbol(e).sym;return!t&&localScope&&(t=localScope[e]),t||(t=moduleExports[e]),t}handle&&(HEAP8[handle+8]=1,LE_HEAP_STORE_U32(4*(handle+12>>2),memoryBase),LE_HEAP_STORE_I32(4*(handle+16>>2),metadata.memorySize),LE_HEAP_STORE_U32(4*(handle+20>>2),tableBase),LE_HEAP_STORE_I32(4*(handle+24>>2),metadata.tableSize)),metadata.tableSize&&wasmTable.grow(metadata.tableSize),__name(resolveSymbol,"resolveSymbol");var proxyHandler={get(e,t){switch(t){case"__memory_base":return memoryBase;case"__table_base":return tableBase}var n;return t in wasmImports&&!wasmImports[t].stub?wasmImports[t]:(t in e||(e[t]=(...e)=>(n||=resolveSymbol(t),n(...e))),e[t])}},proxy=new Proxy({},proxyHandler);currentModuleWeakSymbols=metadata.weakImports;var info={"GOT.mem":new Proxy({},GOTHandler),"GOT.func":new Proxy({},GOTHandler),env:proxy,wasi_snapshot_preview1:proxy};function postInstantiation(module,instance){function addEmAsm(addr,body){for(var args=[],arity=0;arity<16&&-1!=body.indexOf("$"+arity);arity++)args.push("$"+arity);args=args.join(",");var func=`(${args}) => { ${body} };`;ASM_CONSTS[start]=eval(func)}if(updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),flags.allowUndefined||reportUndefinedSymbols(),__name(addEmAsm,"addEmAsm"),"__start_em_asm"in moduleExports)for(var start=moduleExports.__start_em_asm,stop=moduleExports.__stop_em_asm;start<stop;){var jsString=UTF8ToString(start);addEmAsm(start,jsString),start=HEAPU8.indexOf(0,start)+1}function addEmJs(name,cSig,body){var jsArgs=[];if(cSig=cSig.slice(1,-1),"void"!=cSig)for(var i in cSig=cSig.split(","),cSig){var jsArg=cSig[i].split(" ").pop();jsArgs.push(jsArg.replace("*",""))}var func=`(${jsArgs}) => ${body};`;moduleExports[name]=eval(func)}for(var name in __name(addEmJs,"addEmJs"),moduleExports)if(name.startsWith("__em_js__")){var start=moduleExports[name],jsString=UTF8ToString(start),parts=jsString.split("<::>");addEmJs(name.replace("__em_js__",""),parts[0],parts[1]),delete moduleExports[name]}var applyRelocs=moduleExports.__wasm_apply_data_relocs;applyRelocs&&(runtimeInitialized?applyRelocs():__RELOC_FUNCS__.push(applyRelocs));var init=moduleExports.__wasm_call_ctors;return init&&(runtimeInitialized?init():addOnPostCtor(init)),moduleExports}if(__name(postInstantiation,"postInstantiation"),flags.loadAsync)return(async()=>{var e;return binary instanceof WebAssembly.Module?e=new WebAssembly.Instance(binary,info):({module:binary,instance:e}=await WebAssembly.instantiate(binary,info)),postInstantiation(binary,e)})();var module=binary instanceof WebAssembly.Module?binary:new WebAssembly.Module(binary),instance=new WebAssembly.Instance(module,info);return postInstantiation(module,instance)}return __name(loadModule,"loadModule"),flags={...flags,rpath:{parentLibPath:libName,paths:metadata.runtimePaths}},flags.loadAsync?metadata.neededDynlibs.reduce((e,t)=>e.then(()=>loadDynamicLibrary(t,flags,localScope)),Promise.resolve()).then(loadModule):(metadata.neededDynlibs.forEach(e=>loadDynamicLibrary(e,flags,localScope)),loadModule())},"loadWebAssemblyModule"),mergeLibSymbols=__name((e,t)=>{for(var[n,r]of Object.entries(e)){const e=__name(e=>{isSymbolDefined(e)||(wasmImports[e]=r)},"setImport");e(n);const t="__main_argc_argv";"main"==n&&e(t),n==t&&e("main")}},"mergeLibSymbols"),asyncLoad=__name(async e=>{var t=await readAsync(e);return new Uint8Array(t)},"asyncLoad");function loadDynamicLibrary(e,t={global:!0,nodelete:!0},n,r){var s=LDSO.loadedLibsByName[e];if(s)return t.global?s.global||(s.global=!0,mergeLibSymbols(s.exports,e)):n&&Object.assign(n,s.exports),t.nodelete&&s.refcount!==1/0&&(s.refcount=1/0),s.refcount++,r&&(LDSO.loadedLibsByHandle[r]=s),!t.loadAsync||Promise.resolve(!0);function o(){if(r){var n=LE_HEAP_LOAD_U32(4*(r+28>>2)),s=LE_HEAP_LOAD_U32(4*(r+32>>2));if(n&&s){var o=HEAP8.slice(n,n+s);return t.loadAsync?Promise.resolve(o):o}}var a=locateFile(e);if(t.loadAsync)return asyncLoad(a);if(!readBinary)throw new Error(`${a}: file not found, and synchronous loading of external files is not available`);return readBinary(a)}function a(){return t.loadAsync?o().then(s=>loadWebAssemblyModule(s,t,e,n,r)):loadWebAssemblyModule(o(),t,e,n,r)}function i(t){s.global?mergeLibSymbols(t,e):n&&Object.assign(n,t),s.exports=t}return(s=newDSO(e,r,"loading")).refcount=t.nodelete?1/0:1,s.global=t.global,__name(o,"loadLibData"),__name(a,"getExports"),__name(i,"moduleLoaded"),t.loadAsync?a().then(e=>(i(e),!0)):(i(a()),!0)}__name(loadDynamicLibrary,"loadDynamicLibrary");var reportUndefinedSymbols=__name(()=>{for(var[e,t]of Object.entries(GOT))if(0==t.value){var n=resolveGlobalSymbol(e,!0).sym;if(!n&&!t.required)continue;if("function"==typeof n)t.value=addFunction(n,n.sig);else{if("number"!=typeof n)throw new Error(`bad export type for '${e}': ${typeof n}`);t.value=n}}},"reportUndefinedSymbols"),runDependencies=0,dependenciesFulfilled=null,removeRunDependency=__name(e=>{if(runDependencies--,Module.monitorRunDependencies?.(runDependencies),0==runDependencies&&dependenciesFulfilled){var t=dependenciesFulfilled;dependenciesFulfilled=null,t()}},"removeRunDependency"),addRunDependency=__name(e=>{runDependencies++,Module.monitorRunDependencies?.(runDependencies)},"addRunDependency"),loadDylibs=__name(async()=>{if(dynamicLibraries.length){for(var e of(addRunDependency("loadDylibs"),dynamicLibraries))await loadDynamicLibrary(e,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0});reportUndefinedSymbols(),removeRunDependency("loadDylibs")}else reportUndefinedSymbols()},"loadDylibs"),noExitRuntime=!0;function setValue(e,t,n="i8"){switch(n.endsWith("*")&&(n="*"),n){case"i1":case"i8":HEAP8[e]=t;break;case"i16":LE_HEAP_STORE_I16(2*(e>>1),t);break;case"i32":LE_HEAP_STORE_I32(4*(e>>2),t);break;case"i64":LE_HEAP_STORE_I64(8*(e>>3),BigInt(t));break;case"float":LE_HEAP_STORE_F32(4*(e>>2),t);break;case"double":LE_HEAP_STORE_F64(8*(e>>3),t);break;case"*":LE_HEAP_STORE_U32(4*(e>>2),t);break;default:abort(`invalid type for setValue: ${n}`)}}__name(setValue,"setValue");var ___memory_base=new WebAssembly.Global({value:"i32",mutable:!1},1024),___stack_high=78240,___stack_low=12704,___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},78240),___table_base=new WebAssembly.Global({value:"i32",mutable:!1},1),__abort_js=__name(()=>abort(""),"__abort_js");__abort_js.sig="v";var getHeapMax=__name(()=>2147483648,"getHeapMax"),growMemory=__name(e=>{var t=(e-wasmMemory.buffer.byteLength+65535)/65536|0;try{return wasmMemory.grow(t),updateMemoryViews(),1}catch(e){}},"growMemory"),_emscripten_resize_heap=__name(e=>{var t=HEAPU8.length;e>>>=0;var n=getHeapMax();if(e>n)return!1;for(var r=1;r<=4;r*=2){var s=t*(1+.2/r);s=Math.min(s,e+100663296);var o=Math.min(n,alignMemory(Math.max(e,s),65536));if(growMemory(o))return!0}return!1},"_emscripten_resize_heap");_emscripten_resize_heap.sig="ip";var _fd_close=__name(e=>52,"_fd_close");_fd_close.sig="ii";var INT53_MAX=9007199254740992,INT53_MIN=-9007199254740992,bigintToI53Checked=__name(e=>e<INT53_MIN||e>INT53_MAX?NaN:Number(e),"bigintToI53Checked");function _fd_seek(e,t,n,r){return t=bigintToI53Checked(t),70}__name(_fd_seek,"_fd_seek"),_fd_seek.sig="iijip";var printCharBuffers=[null,[],[]],printChar=__name((e,t)=>{var n=printCharBuffers[e];0===t||10===t?((1===e?out:err)(UTF8ArrayToString(n)),n.length=0):n.push(t)},"printChar"),_fd_write=__name((e,t,n,r)=>{for(var s=0,o=0;o<n;o++){var a=LE_HEAP_LOAD_U32(4*(t>>2)),i=LE_HEAP_LOAD_U32(4*(t+4>>2));t+=8;for(var _=0;_<i;_++)printChar(e,HEAPU8[a+_]);s+=i}return LE_HEAP_STORE_U32(4*(r>>2),s),0},"_fd_write");function _tree_sitter_log_callback(e,t){if(Module.currentLogCallback){const n=UTF8ToString(t);Module.currentLogCallback(n,0!==e)}}function _tree_sitter_parse_callback(e,t,n,r,s){const o=Module.currentParseCallback(t,{row:n,column:r});"string"==typeof o?(setValue(s,o.length,"i32"),stringToUTF16(o,e,10240)):setValue(s,0,"i32")}function _tree_sitter_progress_callback(e,t){return!!Module.currentProgressCallback&&Module.currentProgressCallback({currentOffset:e,hasError:t})}function _tree_sitter_query_progress_callback(e){return!!Module.currentQueryProgressCallback&&Module.currentQueryProgressCallback({currentOffset:e})}_fd_write.sig="iippp",__name(_tree_sitter_log_callback,"_tree_sitter_log_callback"),__name(_tree_sitter_parse_callback,"_tree_sitter_parse_callback"),__name(_tree_sitter_progress_callback,"_tree_sitter_progress_callback"),__name(_tree_sitter_query_progress_callback,"_tree_sitter_query_progress_callback");var runtimeKeepaliveCounter=0,keepRuntimeAlive=__name(()=>noExitRuntime||runtimeKeepaliveCounter>0,"keepRuntimeAlive"),_proc_exit=__name(e=>{EXITSTATUS=e,keepRuntimeAlive()||(Module.onExit?.(e),ABORT=!0),quit_(e,new ExitStatus(e))},"_proc_exit");_proc_exit.sig="vi";var exitJS=__name((e,t)=>{EXITSTATUS=e,_proc_exit(e)},"exitJS"),handleException=__name(e=>{if(e instanceof ExitStatus||"unwind"==e)return EXITSTATUS;quit_(1,e)},"handleException"),lengthBytesUTF8=__name(e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r<=127?t++:r<=2047?t+=2:r>=55296&&r<=57343?(t+=4,++n):t+=3}return t},"lengthBytesUTF8"),stringToUTF8Array=__name((e,t,n,r)=>{if(!(r>0))return 0;for(var s=n,o=n+r-1,a=0;a<e.length;++a){var i=e.codePointAt(a);if(i<=127){if(n>=o)break;t[n++]=i}else if(i<=2047){if(n+1>=o)break;t[n++]=192|i>>6,t[n++]=128|63&i}else if(i<=65535){if(n+2>=o)break;t[n++]=224|i>>12,t[n++]=128|i>>6&63,t[n++]=128|63&i}else{if(n+3>=o)break;t[n++]=240|i>>18,t[n++]=128|i>>12&63,t[n++]=128|i>>6&63,t[n++]=128|63&i,a++}}return t[n]=0,n-s},"stringToUTF8Array"),stringToUTF8=__name((e,t,n)=>stringToUTF8Array(e,HEAPU8,t,n),"stringToUTF8"),stackAlloc=__name(e=>__emscripten_stack_alloc(e),"stackAlloc"),stringToUTF8OnStack=__name(e=>{var t=lengthBytesUTF8(e)+1,n=stackAlloc(t);return stringToUTF8(e,n,t),n},"stringToUTF8OnStack"),AsciiToString=__name(e=>{for(var t="";;){var n=HEAPU8[e++];if(!n)return t;t+=String.fromCharCode(n)}},"AsciiToString"),stringToUTF16=__name((e,t,n)=>{if(n??=2147483647,n<2)return 0;for(var r=t,s=(n-=2)<2*e.length?n/2:e.length,o=0;o<s;++o){var a=e.charCodeAt(o);LE_HEAP_STORE_I16(2*(t>>1),a),t+=2}return LE_HEAP_STORE_I16(2*(t>>1),0),t-r},"stringToUTF16");function LE_HEAP_UPDATE(){HEAPU16.unsigned=e=>65535&e,HEAPU32.unsigned=e=>e>>>0}if(LE_ATOMICS_NATIVE_BYTE_ORDER=1===new Int8Array(new Int16Array([1]).buffer)[0]?[e=>e,e=>e,void 0,e=>e]:[e=>e,e=>((65280&e)<<8|(255&e)<<24)>>16,void 0,e=>e>>24&255|e>>8&65280|(65280&e)<<8|(255&e)<<24],__name(LE_HEAP_UPDATE,"LE_HEAP_UPDATE"),initMemory(),Module.noExitRuntime&&(noExitRuntime=Module.noExitRuntime),Module.print&&(out=Module.print),Module.printErr&&(err=Module.printErr),Module.dynamicLibraries&&(dynamicLibraries=Module.dynamicLibraries),Module.wasmBinary&&(wasmBinary=Module.wasmBinary),Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram),Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.shift()();Module.setValue=setValue,Module.getValue=getValue,Module.UTF8ToString=UTF8ToString,Module.stringToUTF8=stringToUTF8,Module.lengthBytesUTF8=lengthBytesUTF8,Module.AsciiToString=AsciiToString,Module.stringToUTF16=stringToUTF16,Module.loadWebAssemblyModule=loadWebAssemblyModule,Module.LE_HEAP_STORE_I64=LE_HEAP_STORE_I64;var ASM_CONSTS={},_malloc,_calloc,_realloc,_free,_ts_range_edit,_memcmp,_ts_language_symbol_count,_ts_language_state_count,_ts_language_abi_version,_ts_language_name,_ts_language_field_count,_ts_language_next_state,_ts_language_symbol_name,_ts_language_symbol_for_name,_strncmp,_ts_language_symbol_type,_ts_language_field_name_for_id,_ts_lookahead_iterator_new,_ts_lookahead_iterator_delete,_ts_lookahead_iterator_reset_state,_ts_lookahead_iterator_reset,_ts_lookahead_iterator_next,_ts_lookahead_iterator_current_symbol,_ts_point_edit,_ts_parser_delete,_ts_parser_reset,_ts_parser_set_language,_ts_parser_set_included_ranges,_ts_query_new,_ts_query_delete,_iswspace,_iswalnum,_ts_query_pattern_count,_ts_query_capture_count,_ts_query_string_count,_ts_query_capture_name_for_id,_ts_query_capture_quantifier_for_id,_ts_query_string_value_for_id,_ts_query_predicates_for_pattern,_ts_query_start_byte_for_pattern,_ts_query_end_byte_for_pattern,_ts_query_is_pattern_rooted,_ts_query_is_pattern_non_local,_ts_query_is_pattern_guaranteed_at_step,_ts_query_disable_capture,_ts_query_disable_pattern,_ts_tree_copy,_ts_tree_delete,_ts_init,_ts_parser_new_wasm,_ts_parser_enable_logger_wasm,_ts_parser_parse_wasm,_ts_parser_included_ranges_wasm,_ts_language_type_is_named_wasm,_ts_language_type_is_visible_wasm,_ts_language_metadata_wasm,_ts_language_supertypes_wasm,_ts_language_subtypes_wasm,_ts_tree_root_node_wasm,_ts_tree_root_node_with_offset_wasm,_ts_tree_edit_wasm,_ts_tree_included_ranges_wasm,_ts_tree_get_changed_ranges_wasm,_ts_tree_cursor_new_wasm,_ts_tree_cursor_copy_wasm,_ts_tree_cursor_delete_wasm,_ts_tree_cursor_reset_wasm,_ts_tree_cursor_reset_to_wasm,_ts_tree_cursor_goto_first_child_wasm,_ts_tree_cursor_goto_last_child_wasm,_ts_tree_cursor_goto_first_child_for_index_wasm,_ts_tree_cursor_goto_first_child_for_position_wasm,_ts_tree_cursor_goto_next_sibling_wasm,_ts_tree_cursor_goto_previous_sibling_wasm,_ts_tree_cursor_goto_descendant_wasm,_ts_tree_cursor_goto_parent_wasm,_ts_tree_cursor_current_node_type_id_wasm,_ts_tree_cursor_current_node_state_id_wasm,_ts_tree_cursor_current_node_is_named_wasm,_ts_tree_cursor_current_node_is_missing_wasm,_ts_tree_cursor_current_node_id_wasm,_ts_tree_cursor_start_position_wasm,_ts_tree_cursor_end_position_wasm,_ts_tree_cursor_start_index_wasm,_ts_tree_cursor_end_index_wasm,_ts_tree_cursor_current_field_id_wasm,_ts_tree_cursor_current_depth_wasm,_ts_tree_cursor_current_descendant_index_wasm,_ts_tree_cursor_current_node_wasm,_ts_node_symbol_wasm,_ts_node_field_name_for_child_wasm,_ts_node_field_name_for_named_child_wasm,_ts_node_children_by_field_id_wasm,_ts_node_first_child_for_byte_wasm,_ts_node_first_named_child_for_byte_wasm,_ts_node_grammar_symbol_wasm,_ts_node_child_count_wasm,_ts_node_named_child_count_wasm,_ts_node_child_wasm,_ts_node_named_child_wasm,_ts_node_child_by_field_id_wasm,_ts_node_next_sibling_wasm,_ts_node_prev_sibling_wasm,_ts_node_next_named_sibling_wasm,_ts_node_prev_named_sibling_wasm,_ts_node_descendant_count_wasm,_ts_node_parent_wasm,_ts_node_child_with_descendant_wasm,_ts_node_descendant_for_index_wasm,_ts_node_named_descendant_for_index_wasm,_ts_node_descendant_for_position_wasm,_ts_node_named_descendant_for_position_wasm,_ts_node_start_point_wasm,_ts_node_end_point_wasm,_ts_node_start_index_wasm,_ts_node_end_index_wasm,_ts_node_to_string_wasm,_ts_node_children_wasm,_ts_node_named_children_wasm,_ts_node_descendants_of_type_wasm,_ts_node_is_named_wasm,_ts_node_has_changes_wasm,_ts_node_has_error_wasm,_ts_node_is_error_wasm,_ts_node_is_missing_wasm,_ts_node_is_extra_wasm,_ts_node_parse_state_wasm,_ts_node_next_parse_state_wasm,_ts_query_matches_wasm,_ts_query_captures_wasm,_memset,_memcpy,_memmove,_iswalpha,_iswblank,_iswdigit,_iswlower,_iswupper,_iswxdigit,_memchr,_strlen,_strcmp,_strncat,_strncpy,_towlower,_towupper,_setThrew,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___wasm_apply_data_relocs;function assignWasmExports(e){Module._malloc=_malloc=e.malloc,Module._calloc=_calloc=e.calloc,Module._realloc=_realloc=e.realloc,Module._free=_free=e.free,Module._ts_range_edit=_ts_range_edit=e.ts_range_edit,Module._memcmp=_memcmp=e.memcmp,Module._ts_language_symbol_count=_ts_language_symbol_count=e.ts_language_symbol_count,Module._ts_language_state_count=_ts_language_state_count=e.ts_language_state_count,Module._ts_language_abi_version=_ts_language_abi_version=e.ts_language_abi_version,Module._ts_language_name=_ts_language_name=e.ts_language_name,Module._ts_language_field_count=_ts_language_field_count=e.ts_language_field_count,Module._ts_language_next_state=_ts_language_next_state=e.ts_language_next_state,Module._ts_language_symbol_name=_ts_language_symbol_name=e.ts_language_symbol_name,Module._ts_language_symbol_for_name=_ts_language_symbol_for_name=e.ts_language_symbol_for_name,Module._strncmp=_strncmp=e.strncmp,Module._ts_language_symbol_type=_ts_language_symbol_type=e.ts_language_symbol_type,Module._ts_language_field_name_for_id=_ts_language_field_name_for_id=e.ts_language_field_name_for_id,Module._ts_lookahead_iterator_new=_ts_lookahead_iterator_new=e.ts_lookahead_iterator_new,Module._ts_lookahead_iterator_delete=_ts_lookahead_iterator_delete=e.ts_lookahead_iterator_delete,Module._ts_lookahead_iterator_reset_state=_ts_lookahead_iterator_reset_state=e.ts_lookahead_iterator_reset_state,Module._ts_lookahead_iterator_reset=_ts_lookahead_iterator_reset=e.ts_lookahead_iterator_reset,Module._ts_lookahead_iterator_next=_ts_lookahead_iterator_next=e.ts_lookahead_iterator_next,Module._ts_lookahead_iterator_current_symbol=_ts_lookahead_iterator_current_symbol=e.ts_lookahead_iterator_current_symbol,Module._ts_point_edit=_ts_point_edit=e.ts_point_edit,Module._ts_parser_delete=_ts_parser_delete=e.ts_parser_delete,Module._ts_parser_reset=_ts_parser_reset=e.ts_parser_reset,Module._ts_parser_set_language=_ts_parser_set_language=e.ts_parser_set_language,Module._ts_parser_set_included_ranges=_ts_parser_set_included_ranges=e.ts_parser_set_included_ranges,Module._ts_query_new=_ts_query_new=e.ts_query_new,Module._ts_query_delete=_ts_query_delete=e.ts_query_delete,Module._iswspace=_iswspace=e.iswspace,Module._iswalnum=_iswalnum=e.iswalnum,Module._ts_query_pattern_count=_ts_query_pattern_count=e.ts_query_pattern_count,Module._ts_query_capture_count=_ts_query_capture_count=e.ts_query_capture_count,Module._ts_query_string_count=_ts_query_string_count=e.ts_query_string_count,Module._ts_query_capture_name_for_id=_ts_query_capture_name_for_id=e.ts_query_capture_name_for_id,Module._ts_query_capture_quantifier_for_id=_ts_query_capture_quantifier_for_id=e.ts_query_capture_quantifier_for_id,Module._ts_query_string_value_for_id=_ts_query_string_value_for_id=e.ts_query_string_value_for_id,Module._ts_query_predicates_for_pattern=_ts_query_predicates_for_pattern=e.ts_query_predicates_for_pattern,Module._ts_query_start_byte_for_pattern=_ts_query_start_byte_for_pattern=e.ts_query_start_byte_for_pattern,Module._ts_query_end_byte_for_pattern=_ts_query_end_byte_for_pattern=e.ts_query_end_byte_for_pattern,Module._ts_query_is_pattern_rooted=_ts_query_is_pattern_rooted=e.ts_query_is_pattern_rooted,Module._ts_query_is_pattern_non_local=_ts_query_is_pattern_non_local=e.ts_query_is_pattern_non_local,Module._ts_query_is_pattern_guaranteed_at_step=_ts_query_is_pattern_guaranteed_at_step=e.ts_query_is_pattern_guaranteed_at_step,Module._ts_query_disable_capture=_ts_query_disable_capture=e.ts_query_disable_capture,Module._ts_query_disable_pattern=_ts_query_disable_pattern=e.ts_query_disable_pattern,Module._ts_tree_copy=_ts_tree_copy=e.ts_tree_copy,Module._ts_tree_delete=_ts_tree_delete=e.ts_tree_delete,Module._ts_init=_ts_init=e.ts_init,Module._ts_parser_new_wasm=_ts_parser_new_wasm=e.ts_parser_new_wasm,Module._ts_parser_enable_logger_wasm=_ts_parser_enable_logger_wasm=e.ts_parser_enable_logger_wasm,Module._ts_parser_parse_wasm=_ts_parser_parse_wasm=e.ts_parser_parse_wasm,Module._ts_parser_included_ranges_wasm=_ts_parser_included_ranges_wasm=e.ts_parser_included_ranges_wasm,Module._ts_language_type_is_named_wasm=_ts_language_type_is_named_wasm=e.ts_language_type_is_named_wasm,Module._ts_language_type_is_visible_wasm=_ts_language_type_is_visible_wasm=e.ts_language_type_is_visible_wasm,Module._ts_language_metadata_wasm=_ts_language_metadata_wasm=e.ts_language_metadata_wasm,Module._ts_language_supertypes_wasm=_ts_language_supertypes_wasm=e.ts_language_supertypes_wasm,Module._ts_language_subtypes_wasm=_ts_language_subtypes_wasm=e.ts_language_subtypes_wasm,Module._ts_tree_root_node_wasm=_ts_tree_root_node_wasm=e.ts_tree_root_node_wasm,Module._ts_tree_root_node_with_offset_wasm=_ts_tree_root_node_with_offset_wasm=e.ts_tree_root_node_with_offset_wasm,Module._ts_tree_edit_wasm=_ts_tree_edit_wasm=e.ts_tree_edit_wasm,Module._ts_tree_included_ranges_wasm=_ts_tree_included_ranges_wasm=e.ts_tree_included_ranges_wasm,Module._ts_tree_get_changed_ranges_wasm=_ts_tree_get_changed_ranges_wasm=e.ts_tree_get_changed_ranges_wasm,Module._ts_tree_cursor_new_wasm=_ts_tree_cursor_new_wasm=e.ts_tree_cursor_new_wasm,Module._ts_tree_cursor_copy_wasm=_ts_tree_cursor_copy_wasm=e.ts_tree_cursor_copy_wasm,Module._ts_tree_cursor_delete_wasm=_ts_tree_cursor_delete_wasm=e.ts_tree_cursor_delete_wasm,Module._ts_tree_cursor_reset_wasm=_ts_tree_cursor_reset_wasm=e.ts_tree_cursor_reset_wasm,Module._ts_tree_cursor_reset_to_wasm=_ts_tree_cursor_reset_to_wasm=e.ts_tree_cursor_reset_to_wasm,Module._ts_tree_cursor_goto_first_child_wasm=_ts_tree_cursor_goto_first_child_wasm=e.ts_tree_cursor_goto_first_child_wasm,Module._ts_tree_cursor_goto_last_child_wasm=_ts_tree_cursor_goto_last_child_wasm=e.ts_tree_cursor_goto_last_child_wasm,Module._ts_tree_cursor_goto_first_child_for_index_wasm=_ts_tree_cursor_goto_first_child_for_index_wasm=e.ts_tree_cursor_goto_first_child_for_index_wasm,Module._ts_tree_cursor_goto_first_child_for_position_wasm=_ts_tree_cursor_goto_first_child_for_position_wasm=e.ts_tree_cursor_goto_first_child_for_position_wasm,Module._ts_tree_cursor_goto_next_sibling_wasm=_ts_tree_cursor_goto_next_sibling_wasm=e.ts_tree_cursor_goto_next_sibling_wasm,Module._ts_tree_cursor_goto_previous_sibling_wasm=_ts_tree_cursor_goto_previous_sibling_wasm=e.ts_tree_cursor_goto_previous_sibling_wasm,Module._ts_tree_cursor_goto_descendant_wasm=_ts_tree_cursor_goto_descendant_wasm=e.ts_tree_cursor_goto_descendant_wasm,Module._ts_tree_cursor_goto_parent_wasm=_ts_tree_cursor_goto_parent_wasm=e.ts_tree_cursor_goto_parent_wasm,Module._ts_tree_cursor_current_node_type_id_wasm=_ts_tree_cursor_current_node_type_id_wasm=e.ts_tree_cursor_current_node_type_id_wasm,Module._ts_tree_cursor_current_node_state_id_wasm=_ts_tree_cursor_current_node_state_id_wasm=e.ts_tree_cursor_current_node_state_id_wasm,Module._ts_tree_cursor_current_node_is_named_wasm=_ts_tree_cursor_current_node_is_named_wasm=e.ts_tree_cursor_current_node_is_named_wasm,Module._ts_tree_cursor_current_node_is_missing_wasm=_ts_tree_cursor_current_node_is_missing_wasm=e.ts_tree_cursor_current_node_is_missing_wasm,Module._ts_tree_cursor_current_node_id_wasm=_ts_tree_cursor_current_node_id_wasm=e.ts_tree_cursor_current_node_id_wasm,Module._ts_tree_cursor_start_position_wasm=_ts_tree_cursor_start_position_wasm=e.ts_tree_cursor_start_position_wasm,Module._ts_tree_cursor_end_position_wasm=_ts_tree_cursor_end_position_wasm=e.ts_tree_cursor_end_position_wasm,Module._ts_tree_cursor_start_index_wasm=_ts_tree_cursor_start_index_wasm=e.ts_tree_cursor_start_index_wasm,Module._ts_tree_cursor_end_index_wasm=_ts_tree_cursor_end_index_wasm=e.ts_tree_cursor_end_index_wasm,Module._ts_tree_cursor_current_field_id_wasm=_ts_tree_cursor_current_field_id_wasm=e.ts_tree_cursor_current_field_id_wasm,Module._ts_tree_cursor_current_depth_wasm=_ts_tree_cursor_current_depth_wasm=e.ts_tree_cursor_current_depth_wasm,Module._ts_tree_cursor_current_descendant_index_wasm=_ts_tree_cursor_current_descendant_index_wasm=e.ts_tree_cursor_current_descendant_index_wasm,Module._ts_tree_cursor_current_node_wasm=_ts_tree_cursor_current_node_wasm=e.ts_tree_cursor_current_node_wasm,Module._ts_node_symbol_wasm=_ts_node_symbol_wasm=e.ts_node_symbol_wasm,Module._ts_node_field_name_for_child_wasm=_ts_node_field_name_for_child_wasm=e.ts_node_field_name_for_child_wasm,Module._ts_node_field_name_for_named_child_wasm=_ts_node_field_name_for_named_child_wasm=e.ts_node_field_name_for_named_child_wasm,Module._ts_node_children_by_field_id_wasm=_ts_node_children_by_field_id_wasm=e.ts_node_children_by_field_id_wasm,Module._ts_node_first_child_for_byte_wasm=_ts_node_first_child_for_byte_wasm=e.ts_node_first_child_for_byte_wasm,Module._ts_node_first_named_child_for_byte_wasm=_ts_node_first_named_child_for_byte_wasm=e.ts_node_first_named_child_for_byte_wasm,Module._ts_node_grammar_symbol_wasm=_ts_node_grammar_symbol_wasm=e.ts_node_grammar_symbol_wasm,Module._ts_node_child_count_wasm=_ts_node_child_count_wasm=e.ts_node_child_count_wasm,Module._ts_node_named_child_count_wasm=_ts_node_named_child_count_wasm=e.ts_node_named_child_count_wasm,Module._ts_node_child_wasm=_ts_node_child_wasm=e.ts_node_child_wasm,Module._ts_node_named_child_wasm=_ts_node_named_child_wasm=e.ts_node_named_child_wasm,Module._ts_node_child_by_field_id_wasm=_ts_node_child_by_field_id_wasm=e.ts_node_child_by_field_id_wasm,Module._ts_node_next_sibling_wasm=_ts_node_next_sibling_wasm=e.ts_node_next_sibling_wasm,Module._ts_node_prev_sibling_wasm=_ts_node_prev_sibling_wasm=e.ts_node_prev_sibling_wasm,Module._ts_node_next_named_sibling_wasm=_ts_node_next_named_sibling_wasm=e.ts_node_next_named_sibling_wasm,Module._ts_node_prev_named_sibling_wasm=_ts_node_prev_named_sibling_wasm=e.ts_node_prev_named_sibling_wasm,Module._ts_node_descendant_count_wasm=_ts_node_descendant_count_wasm=e.ts_node_descendant_count_wasm,Module._ts_node_parent_wasm=_ts_node_parent_wasm=e.ts_node_parent_wasm,Module._ts_node_child_with_descendant_wasm=_ts_node_child_with_descendant_wasm=e.ts_node_child_with_descendant_wasm,Module._ts_node_descendant_for_index_wasm=_ts_node_descendant_for_index_wasm=e.ts_node_descendant_for_index_wasm,Module._ts_node_named_descendant_for_index_wasm=_ts_node_named_descendant_for_index_wasm=e.ts_node_named_descendant_for_index_wasm,Module._ts_node_descendant_for_position_wasm=_ts_node_descendant_for_position_wasm=e.ts_node_descendant_for_position_wasm,Module._ts_node_named_descendant_for_position_wasm=_ts_node_named_descendant_for_position_wasm=e.ts_node_named_descendant_for_position_wasm,Module._ts_node_start_point_wasm=_ts_node_start_point_wasm=e.ts_node_start_point_wasm,Module._ts_node_end_point_wasm=_ts_node_end_point_wasm=e.ts_node_end_point_wasm,Module._ts_node_start_index_wasm=_ts_node_start_index_wasm=e.ts_node_start_index_wasm,Module._ts_node_end_index_wasm=_ts_node_end_index_wasm=e.ts_node_end_index_wasm,Module._ts_node_to_string_wasm=_ts_node_to_string_wasm=e.ts_node_to_string_wasm,Module._ts_node_children_wasm=_ts_node_children_wasm=e.ts_node_children_wasm,Module._ts_node_named_children_wasm=_ts_node_named_children_wasm=e.ts_node_named_children_wasm,Module._ts_node_descendants_of_type_wasm=_ts_node_descendants_of_type_wasm=e.ts_node_descendants_of_type_wasm,Module._ts_node_is_named_wasm=_ts_node_is_named_wasm=e.ts_node_is_named_wasm,Module._ts_node_has_changes_wasm=_ts_node_has_changes_wasm=e.ts_node_has_changes_wasm,Module._ts_node_has_error_wasm=_ts_node_has_error_wasm=e.ts_node_has_error_wasm,Module._ts_node_is_error_wasm=_ts_node_is_error_wasm=e.ts_node_is_error_wasm,Module._ts_node_is_missing_wasm=_ts_node_is_missing_wasm=e.ts_node_is_missing_wasm,Module._ts_node_is_extra_wasm=_ts_node_is_extra_wasm=e.ts_node_is_extra_wasm,Module._ts_node_parse_state_wasm=_ts_node_parse_state_wasm=e.ts_node_parse_state_wasm,Module._ts_node_next_parse_state_wasm=_ts_node_next_parse_state_wasm=e.ts_node_next_parse_state_wasm,Module._ts_query_matches_wasm=_ts_query_matches_wasm=e.ts_query_matches_wasm,Module._ts_query_captures_wasm=_ts_query_captures_wasm=e.ts_query_captures_wasm,Module._memset=_memset=e.memset,Module._memcpy=_memcpy=e.memcpy,Module._memmove=_memmove=e.memmove,Module._iswalpha=_iswalpha=e.iswalpha,Module._iswblank=_iswblank=e.iswblank,Module._iswdigit=_iswdigit=e.iswdigit,Module._iswlower=_iswlower=e.iswlower,Module._iswupper=_iswupper=e.iswupper,Module._iswxdigit=_iswxdigit=e.iswxdigit,Module._memchr=_memchr=e.memchr,Module._strlen=_strlen=e.strlen,Module._strcmp=_strcmp=e.strcmp,Module._strncat=_strncat=e.strncat,Module._strncpy=_strncpy=e.strncpy,Module._towlower=_towlower=e.towlower,Module._towupper=_towupper=e.towupper,_setThrew=e.setThrew,__emscripten_stack_restore=e._emscripten_stack_restore,__emscripten_stack_alloc=e._emscripten_stack_alloc,_emscripten_stack_get_current=e.emscripten_stack_get_current,___wasm_apply_data_relocs=e.__wasm_apply_data_relocs}__name(assignWasmExports,"assignWasmExports");var wasmImports={__heap_base:___heap_base,__indirect_function_table:wasmTable,__memory_base:___memory_base,__stack_high:___stack_high,__stack_low:___stack_low,__stack_pointer:___stack_pointer,__table_base:___table_base,_abort_js:__abort_js,emscripten_resize_heap:_emscripten_resize_heap,fd_close:_fd_close,fd_seek:_fd_seek,fd_write:_fd_write,memory:wasmMemory,tree_sitter_log_callback:_tree_sitter_log_callback,tree_sitter_parse_callback:_tree_sitter_parse_callback,tree_sitter_progress_callback:_tree_sitter_progress_callback,tree_sitter_query_progress_callback:_tree_sitter_query_progress_callback},wasmExports;function callMain(e=[]){var t=resolveGlobalSymbol("main").sym;if(t){e.unshift(thisProgram);var n=e.length,r=stackAlloc(4*(n+1)),s=r;e.forEach(e=>{LE_HEAP_STORE_U32(4*(s>>2),stringToUTF8OnStack(e)),s+=4}),LE_HEAP_STORE_U32(4*(s>>2),0);try{var o=t(n,r);return exitJS(o,!0),o}catch(e){return handleException(e)}}}function run(e=arguments_){function t(){Module.calledRun=!0,ABORT||(initRuntime(),preMain(),readyPromiseResolve?.(Module),Module.onRuntimeInitialized?.(),Module.noInitialRun||callMain(e),postRun())}runDependencies>0?dependenciesFulfilled=run:(preRun(),runDependencies>0?dependenciesFulfilled=run:(__name(t,"doRun"),Module.setStatus?(Module.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>Module.setStatus(""),1),t()},1)):t()))}return __name(callMain,"callMain"),__name(run,"run"),wasmExports=await createWasm(),run(),moduleRtn=runtimeInitialized?Module:new Promise((e,t)=>{readyPromiseResolve=e,readyPromiseReject=t}),moduleRtn}})();"object"==typeof exports&&"object"==typeof module?(module.exports=Module,module.exports.default=Module):(__WEBPACK_AMD_DEFINE_ARRAY__=[],__WEBPACK_AMD_DEFINE_RESULT__=(()=>Module).apply(exports,__WEBPACK_AMD_DEFINE_ARRAY__),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__))}}),index_exports={};__export(index_exports,{CaptureQuantifier:()=>CaptureQuantifier,Edit:()=>Edit,LANGUAGE_VERSION:()=>LANGUAGE_VERSION,Language:()=>Language,LookaheadIterator:()=>LookaheadIterator,MIN_COMPATIBLE_VERSION:()=>MIN_COMPATIBLE_VERSION,Node:()=>Node,Parser:()=>Parser,Query:()=>Query,Tree:()=>Tree,TreeCursor:()=>TreeCursor}),module.exports=__toCommonJS(index_exports);var Edit=class{static{__name(this,"Edit")}startPosition;oldEndPosition;newEndPosition;startIndex;oldEndIndex;newEndIndex;constructor({startIndex:e,oldEndIndex:t,newEndIndex:n,startPosition:r,oldEndPosition:s,newEndPosition:o}){this.startIndex=e>>>0,this.oldEndIndex=t>>>0,this.newEndIndex=n>>>0,this.startPosition=r,this.oldEndPosition=s,this.newEndPosition=o}editPoint(e,t){let n=t;const r={...e};if(t>=this.oldEndIndex){n=this.newEndIndex+(t-this.oldEndIndex);const s=e.row;r.row=this.newEndPosition.row+(e.row-this.oldEndPosition.row),r.column=s===this.oldEndPosition.row?this.newEndPosition.column+(e.column-this.oldEndPosition.column):e.column}else t>this.startIndex&&(n=this.newEndIndex,r.row=this.newEndPosition.row,r.column=this.newEndPosition.column);return{point:r,index:n}}editRange(e){const t={startIndex:e.startIndex,startPosition:{...e.startPosition},endIndex:e.endIndex,endPosition:{...e.endPosition}};return e.endIndex>=this.oldEndIndex?e.endIndex!==Number.MAX_SAFE_INTEGER&&(t.endIndex=this.newEndIndex+(e.endIndex-this.oldEndIndex),t.endPosition={row:this.newEndPosition.row+(e.endPosition.row-this.oldEndPosition.row),column:e.endPosition.row===this.oldEndPosition.row?this.newEndPosition.column+(e.endPosition.column-this.oldEndPosition.column):e.endPosition.column},t.endIndex<this.newEndIndex&&(t.endIndex=Number.MAX_SAFE_INTEGER,t.endPosition={row:Number.MAX_SAFE_INTEGER,column:Number.MAX_SAFE_INTEGER})):e.endIndex>this.startIndex&&(t.endIndex=this.startIndex,t.endPosition={...this.startPosition}),e.startIndex>=this.oldEndIndex?(t.startIndex=this.newEndIndex+(e.startIndex-this.oldEndIndex),t.startPosition={row:this.newEndPosition.row+(e.startPosition.row-this.oldEndPosition.row),column:e.startPosition.row===this.oldEndPosition.row?this.newEndPosition.column+(e.startPosition.column-this.oldEndPosition.column):e.startPosition.column},t.startIndex<this.newEndIndex&&(t.startIndex=Number.MAX_SAFE_INTEGER,t.startPosition={row:Number.MAX_SAFE_INTEGER,column:Number.MAX_SAFE_INTEGER})):e.startIndex>this.startIndex&&(t.startIndex=this.startIndex,t.startPosition={...this.startPosition}),t}},SIZE_OF_SHORT=2,SIZE_OF_INT=4,SIZE_OF_CURSOR=4*SIZE_OF_INT,SIZE_OF_NODE=5*SIZE_OF_INT,SIZE_OF_POINT=2*SIZE_OF_INT,SIZE_OF_RANGE=2*SIZE_OF_INT+2*SIZE_OF_POINT,ZERO_POINT={row:0,column:0},INTERNAL=Symbol("INTERNAL"),C;function assertInternal(e){if(e!==INTERNAL)throw new Error("Illegal constructor")}function isPoint(e){return!!e&&"number"==typeof e.row&&"number"==typeof e.column}function setModule(e){C=e}__name(assertInternal,"assertInternal"),__name(isPoint,"isPoint"),__name(setModule,"setModule");var LookaheadIterator=class{static{__name(this,"LookaheadIterator")}0=0;language;constructor(e,t,n){assertInternal(e),this[0]=t,this.language=n}get currentTypeId(){return C._ts_lookahead_iterator_current_symbol(this[0])}get currentType(){return this.language.types[this.currentTypeId]||"ERROR"}delete(){C._ts_lookahead_iterator_delete(this[0]),this[0]=0}reset(e,t){return!!C._ts_lookahead_iterator_reset(this[0],e[0],t)&&(this.language=e,!0)}resetState(e){return Boolean(C._ts_lookahead_iterator_reset_state(this[0],e))}[Symbol.iterator](){return{next:__name(()=>C._ts_lookahead_iterator_next(this[0])?{done:!1,value:this.currentType}:{done:!0,value:""},"next")}}};function getText(e,t,n,r){const s=n-t;let o=e.textCallback(t,r);if(o){for(t+=o.length;t<n;){const n=e.textCallback(t,r);if(!(n&&n.length>0))break;t+=n.length,o+=n}t>n&&(o=o.slice(0,s))}return o??""}__name(getText,"getText");var Tree=class e{static{__name(this,"Tree")}0=0;textCallback;language;constructor(e,t,n,r){assertInternal(e),this[0]=t,this.language=n,this.textCallback=r}copy(){const t=C._ts_tree_copy(this[0]);return new e(INTERNAL,t,this.language,this.textCallback)}delete(){C._ts_tree_delete(this[0]),this[0]=0}get rootNode(){return C._ts_tree_root_node_wasm(this[0]),unmarshalNode(this)}rootNodeWithOffset(e,t){const n=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(n,e,"i32"),marshalPoint(n+SIZE_OF_INT,t),C._ts_tree_root_node_with_offset_wasm(this[0]),unmarshalNode(this)}edit(e){marshalEdit(e),C._ts_tree_edit_wasm(this[0])}walk(){return this.rootNode.walk()}getChangedRanges(t){if(!(t instanceof e))throw new TypeError("Argument must be a Tree");C._ts_tree_get_changed_ranges_wasm(this[0],t[0]);const n=C.getValue(TRANSFER_BUFFER,"i32"),r=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),s=new Array(n);if(n>0){let e=r;for(let t=0;t<n;t++)s[t]=unmarshalRange(e),e+=SIZE_OF_RANGE;C._free(r)}return s}getIncludedRanges(){C._ts_tree_included_ranges_wasm(this[0]);const e=C.getValue(TRANSFER_BUFFER,"i32"),t=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),n=new Array(e);if(e>0){let r=t;for(let t=0;t<e;t++)n[t]=unmarshalRange(r),r+=SIZE_OF_RANGE;C._free(t)}return n}},TreeCursor=class e{static{__name(this,"TreeCursor")}0=0;1=0;2=0;3=0;tree;constructor(e,t){assertInternal(e),this.tree=t,unmarshalTreeCursor(this)}copy(){const t=new e(INTERNAL,this.tree);return C._ts_tree_cursor_copy_wasm(this.tree[0]),unmarshalTreeCursor(t),t}delete(){marshalTreeCursor(this),C._ts_tree_cursor_delete_wasm(this.tree[0]),this[0]=this[1]=this[2]=0}get currentNode(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_wasm(this.tree[0]),unmarshalNode(this.tree)}get currentFieldId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_field_id_wasm(this.tree[0])}get currentFieldName(){return this.tree.language.fields[this.currentFieldId]}get currentDepth(){return marshalTreeCursor(this),C._ts_tree_cursor_current_depth_wasm(this.tree[0])}get currentDescendantIndex(){return marshalTreeCursor(this),C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0])}get nodeType(){return this.tree.language.types[this.nodeTypeId]||"ERROR"}get nodeTypeId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0])}get nodeStateId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0])}get nodeId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_id_wasm(this.tree[0])}get nodeIsNamed(){return marshalTreeCursor(this),1===C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0])}get nodeIsMissing(){return marshalTreeCursor(this),1===C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0])}get nodeText(){marshalTreeCursor(this);const e=C._ts_tree_cursor_start_index_wasm(this.tree[0]),t=C._ts_tree_cursor_end_index_wasm(this.tree[0]);C._ts_tree_cursor_start_position_wasm(this.tree[0]);const n=unmarshalPoint(TRANSFER_BUFFER);return getText(this.tree,e,t,n)}get startPosition(){return marshalTreeCursor(this),C._ts_tree_cursor_start_position_wasm(this.tree[0]),unmarshalPoint(TRANSFER_BUFFER)}get endPosition(){return marshalTreeCursor(this),C._ts_tree_cursor_end_position_wasm(this.tree[0]),unmarshalPoint(TRANSFER_BUFFER)}get startIndex(){return marshalTreeCursor(this),C._ts_tree_cursor_start_index_wasm(this.tree[0])}get endIndex(){return marshalTreeCursor(this),C._ts_tree_cursor_end_index_wasm(this.tree[0])}gotoFirstChild(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoLastChild(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoParent(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoNextSibling(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoPreviousSibling(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoDescendant(e){marshalTreeCursor(this),C._ts_tree_cursor_goto_descendant_wasm(this.tree[0],e),unmarshalTreeCursor(this)}gotoFirstChildForIndex(e){marshalTreeCursor(this),C.setValue(TRANSFER_BUFFER+SIZE_OF_CURSOR,e,"i32");const t=C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===t}gotoFirstChildForPosition(e){marshalTreeCursor(this),marshalPoint(TRANSFER_BUFFER+SIZE_OF_CURSOR,e);const t=C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===t}reset(e){marshalNode(e),marshalTreeCursor(this,TRANSFER_BUFFER+SIZE_OF_NODE),C._ts_tree_cursor_reset_wasm(this.tree[0]),unmarshalTreeCursor(this)}resetTo(e){marshalTreeCursor(this,TRANSFER_BUFFER),marshalTreeCursor(e,TRANSFER_BUFFER+SIZE_OF_CURSOR),C._ts_tree_cursor_reset_to_wasm(this.tree[0],e.tree[0]),unmarshalTreeCursor(this)}},Node=class{static{__name(this,"Node")}0=0;_children;_namedChildren;constructor(e,{id:t,tree:n,startIndex:r,startPosition:s,other:o}){assertInternal(e),this[0]=o,this.id=t,this.tree=n,this.startIndex=r,this.startPosition=s}id;startIndex;startPosition;tree;get typeId(){return marshalNode(this),C._ts_node_symbol_wasm(this.tree[0])}get grammarId(){return marshalNode(this),C._ts_node_grammar_symbol_wasm(this.tree[0])}get type(){return this.tree.language.types[this.typeId]||"ERROR"}get grammarType(){return this.tree.language.types[this.grammarId]||"ERROR"}get isNamed(){return marshalNode(this),1===C._ts_node_is_named_wasm(this.tree[0])}get isExtra(){return marshalNode(this),1===C._ts_node_is_extra_wasm(this.tree[0])}get isError(){return marshalNode(this),1===C._ts_node_is_error_wasm(this.tree[0])}get isMissing(){return marshalNode(this),1===C._ts_node_is_missing_wasm(this.tree[0])}get hasChanges(){return marshalNode(this),1===C._ts_node_has_changes_wasm(this.tree[0])}get hasError(){return marshalNode(this),1===C._ts_node_has_error_wasm(this.tree[0])}get endIndex(){return marshalNode(this),C._ts_node_end_index_wasm(this.tree[0])}get endPosition(){return marshalNode(this),C._ts_node_end_point_wasm(this.tree[0]),unmarshalPoint(TRANSFER_BUFFER)}get text(){return getText(this.tree,this.startIndex,this.endIndex,this.startPosition)}get parseState(){return marshalNode(this),C._ts_node_parse_state_wasm(this.tree[0])}get nextParseState(){return marshalNode(this),C._ts_node_next_parse_state_wasm(this.tree[0])}equals(e){return this.tree===e.tree&&this.id===e.id}child(e){return marshalNode(this),C._ts_node_child_wasm(this.tree[0],e),unmarshalNode(this.tree)}namedChild(e){return marshalNode(this),C._ts_node_named_child_wasm(this.tree[0],e),unmarshalNode(this.tree)}childForFieldId(e){return marshalNode(this),C._ts_node_child_by_field_id_wasm(this.tree[0],e),unmarshalNode(this.tree)}childForFieldName(e){const t=this.tree.language.fields.indexOf(e);return-1!==t?this.childForFieldId(t):null}fieldNameForChild(e){marshalNode(this);const t=C._ts_node_field_name_for_child_wasm(this.tree[0],e);return t?C.AsciiToString(t):null}fieldNameForNamedChild(e){marshalNode(this);const t=C._ts_node_field_name_for_named_child_wasm(this.tree[0],e);return t?C.AsciiToString(t):null}childrenForFieldName(e){const t=this.tree.language.fields.indexOf(e);return-1!==t&&0!==t?this.childrenForFieldId(t):[]}childrenForFieldId(e){marshalNode(this),C._ts_node_children_by_field_id_wasm(this.tree[0],e);const t=C.getValue(TRANSFER_BUFFER,"i32"),n=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),r=new Array(t);if(t>0){let e=n;for(let n=0;n<t;n++)r[n]=unmarshalNode(this.tree,e),e+=SIZE_OF_NODE;C._free(n)}return r}firstChildForIndex(e){marshalNode(this);const t=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(t,e,"i32"),C._ts_node_first_child_for_byte_wasm(this.tree[0]),unmarshalNode(this.tree)}firstNamedChildForIndex(e){marshalNode(this);const t=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(t,e,"i32"),C._ts_node_first_named_child_for_byte_wasm(this.tree[0]),unmarshalNode(this.tree)}get childCount(){return marshalNode(this),C._ts_node_child_count_wasm(this.tree[0])}get namedChildCount(){return marshalNode(this),C._ts_node_named_child_count_wasm(this.tree[0])}get firstChild(){return this.child(0)}get firstNamedChild(){return this.namedChild(0)}get lastChild(){return this.child(this.childCount-1)}get lastNamedChild(){return this.namedChild(this.namedChildCount-1)}get children(){if(!this._children){marshalNode(this),C._ts_node_children_wasm(this.tree[0]);const e=C.getValue(TRANSFER_BUFFER,"i32"),t=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32");if(this._children=new Array(e),e>0){let n=t;for(let t=0;t<e;t++)this._children[t]=unmarshalNode(this.tree,n),n+=SIZE_OF_NODE;C._free(t)}}return this._children}get namedChildren(){if(!this._namedChildren){marshalNode(this),C._ts_node_named_children_wasm(this.tree[0]);const e=C.getValue(TRANSFER_BUFFER,"i32"),t=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32");if(this._namedChildren=new Array(e),e>0){let n=t;for(let t=0;t<e;t++)this._namedChildren[t]=unmarshalNode(this.tree,n),n+=SIZE_OF_NODE;C._free(t)}}return this._namedChildren}descendantsOfType(e,t=ZERO_POINT,n=ZERO_POINT){Array.isArray(e)||(e=[e]);const r=[],s=this.tree.language.types;for(const t of e)"ERROR"==t&&r.push(65535);for(let t=0,n=s.length;t<n;t++)e.includes(s[t])&&r.push(t);const o=C._malloc(SIZE_OF_INT*r.length);for(let e=0,t=r.length;e<t;e++)C.setValue(o+e*SIZE_OF_INT,r[e],"i32");marshalNode(this),C._ts_node_descendants_of_type_wasm(this.tree[0],o,r.length,t.row,t.column,n.row,n.column);const a=C.getValue(TRANSFER_BUFFER,"i32"),i=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),_=new Array(a);if(a>0){let e=i;for(let t=0;t<a;t++)_[t]=unmarshalNode(this.tree,e),e+=SIZE_OF_NODE}return C._free(i),C._free(o),_}get nextSibling(){return marshalNode(this),C._ts_node_next_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get previousSibling(){return marshalNode(this),C._ts_node_prev_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get nextNamedSibling(){return marshalNode(this),C._ts_node_next_named_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get previousNamedSibling(){return marshalNode(this),C._ts_node_prev_named_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get descendantCount(){return marshalNode(this),C._ts_node_descendant_count_wasm(this.tree[0])}get parent(){return marshalNode(this),C._ts_node_parent_wasm(this.tree[0]),unmarshalNode(this.tree)}childWithDescendant(e){return marshalNode(this),marshalNode(e,1),C._ts_node_child_with_descendant_wasm(this.tree[0]),unmarshalNode(this.tree)}descendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");marshalNode(this);const n=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(n,e,"i32"),C.setValue(n+SIZE_OF_INT,t,"i32"),C._ts_node_descendant_for_index_wasm(this.tree[0]),unmarshalNode(this.tree)}namedDescendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");marshalNode(this);const n=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(n,e,"i32"),C.setValue(n+SIZE_OF_INT,t,"i32"),C._ts_node_named_descendant_for_index_wasm(this.tree[0]),unmarshalNode(this.tree)}descendantForPosition(e,t=e){if(!isPoint(e)||!isPoint(t))throw new Error("Arguments must be {row, column} objects");marshalNode(this);const n=TRANSFER_BUFFER+SIZE_OF_NODE;return marshalPoint(n,e),marshalPoint(n+SIZE_OF_POINT,t),C._ts_node_descendant_for_position_wasm(this.tree[0]),unmarshalNode(this.tree)}namedDescendantForPosition(e,t=e){if(!isPoint(e)||!isPoint(t))throw new Error("Arguments must be {row, column} objects");marshalNode(this);const n=TRANSFER_BUFFER+SIZE_OF_NODE;return marshalPoint(n,e),marshalPoint(n+SIZE_OF_POINT,t),C._ts_node_named_descendant_for_position_wasm(this.tree[0]),unmarshalNode(this.tree)}walk(){return marshalNode(this),C._ts_tree_cursor_new_wasm(this.tree[0]),new TreeCursor(INTERNAL,this.tree)}edit(e){if(this.startIndex>=e.oldEndIndex){let t,n;this.startIndex=e.newEndIndex+(this.startIndex-e.oldEndIndex),this.startPosition.row>e.oldEndPosition.row?(t=this.startPosition.row-e.oldEndPosition.row,n=this.startPosition.column):(t=0,n=this.startPosition.column,this.startPosition.column>=e.oldEndPosition.column&&(n=this.startPosition.column-e.oldEndPosition.column)),t>0?(this.startPosition.row+=t,this.startPosition.column=n):this.startPosition.column+=n}else this.startIndex>e.startIndex&&(this.startIndex=e.newEndIndex,this.startPosition.row=e.newEndPosition.row,this.startPosition.column=e.newEndPosition.column)}toString(){marshalNode(this);const e=C._ts_node_to_string_wasm(this.tree[0]),t=C.AsciiToString(e);return C._free(e),t}};function unmarshalCaptures(e,t,n,r,s){for(let o=0,a=s.length;o<a;o++){const a=C.getValue(n,"i32"),i=unmarshalNode(t,n+=SIZE_OF_INT);n+=SIZE_OF_NODE,s[o]={patternIndex:r,name:e.captureNames[a],node:i}}return n}function marshalNode(e,t=0){let n=TRANSFER_BUFFER+t*SIZE_OF_NODE;C.setValue(n,e.id,"i32"),n+=SIZE_OF_INT,C.setValue(n,e.startIndex,"i32"),n+=SIZE_OF_INT,C.setValue(n,e.startPosition.row,"i32"),n+=SIZE_OF_INT,C.setValue(n,e.startPosition.column,"i32"),n+=SIZE_OF_INT,C.setValue(n,e[0],"i32")}function unmarshalNode(e,t=TRANSFER_BUFFER){const n=C.getValue(t,"i32");if(t+=SIZE_OF_INT,0===n)return null;const r=C.getValue(t,"i32");t+=SIZE_OF_INT;const s=C.getValue(t,"i32");t+=SIZE_OF_INT;const o=C.getValue(t,"i32");t+=SIZE_OF_INT;const a=C.getValue(t,"i32");return new Node(INTERNAL,{id:n,tree:e,startIndex:r,startPosition:{row:s,column:o},other:a})}function marshalTreeCursor(e,t=TRANSFER_BUFFER){C.setValue(t+0*SIZE_OF_INT,e[0],"i32"),C.setValue(t+1*SIZE_OF_INT,e[1],"i32"),C.setValue(t+2*SIZE_OF_INT,e[2],"i32"),C.setValue(t+3*SIZE_OF_INT,e[3],"i32")}function unmarshalTreeCursor(e){e[0]=C.getValue(TRANSFER_BUFFER+0*SIZE_OF_INT,"i32"),e[1]=C.getValue(TRANSFER_BUFFER+1*SIZE_OF_INT,"i32"),e[2]=C.getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),e[3]=C.getValue(TRANSFER_BUFFER+3*SIZE_OF_INT,"i32")}function marshalPoint(e,t){C.setValue(e,t.row,"i32"),C.setValue(e+SIZE_OF_INT,t.column,"i32")}function unmarshalPoint(e){return{row:C.getValue(e,"i32")>>>0,column:C.getValue(e+SIZE_OF_INT,"i32")>>>0}}function marshalRange(e,t){marshalPoint(e,t.startPosition),marshalPoint(e+=SIZE_OF_POINT,t.endPosition),e+=SIZE_OF_POINT,C.setValue(e,t.startIndex,"i32"),e+=SIZE_OF_INT,C.setValue(e,t.endIndex,"i32"),e+=SIZE_OF_INT}function unmarshalRange(e){const t={};return t.startPosition=unmarshalPoint(e),e+=SIZE_OF_POINT,t.endPosition=unmarshalPoint(e),e+=SIZE_OF_POINT,t.startIndex=C.getValue(e,"i32")>>>0,e+=SIZE_OF_INT,t.endIndex=C.getValue(e,"i32")>>>0,t}function marshalEdit(e,t=TRANSFER_BUFFER){marshalPoint(t,e.startPosition),marshalPoint(t+=SIZE_OF_POINT,e.oldEndPosition),marshalPoint(t+=SIZE_OF_POINT,e.newEndPosition),t+=SIZE_OF_POINT,C.setValue(t,e.startIndex,"i32"),t+=SIZE_OF_INT,C.setValue(t,e.oldEndIndex,"i32"),t+=SIZE_OF_INT,C.setValue(t,e.newEndIndex,"i32"),t+=SIZE_OF_INT}function unmarshalLanguageMetadata(e){return{major_version:C.getValue(e,"i32"),minor_version:C.getValue(e+=SIZE_OF_INT,"i32"),patch_version:C.getValue(e+=SIZE_OF_INT,"i32")}}__name(unmarshalCaptures,"unmarshalCaptures"),__name(marshalNode,"marshalNode"),__name(unmarshalNode,"unmarshalNode"),__name(marshalTreeCursor,"marshalTreeCursor"),__name(unmarshalTreeCursor,"unmarshalTreeCursor"),__name(marshalPoint,"marshalPoint"),__name(unmarshalPoint,"unmarshalPoint"),__name(marshalRange,"marshalRange"),__name(unmarshalRange,"unmarshalRange"),__name(marshalEdit,"marshalEdit"),__name(unmarshalLanguageMetadata,"unmarshalLanguageMetadata");var LANGUAGE_FUNCTION_REGEX=/^tree_sitter_\w+$/,Language=class e{static{__name(this,"Language")}0=0;types;fields;constructor(e,t){assertInternal(e),this[0]=t,this.types=new Array(C._ts_language_symbol_count(this[0]));for(let e=0,t=this.types.length;e<t;e++)C._ts_language_symbol_type(this[0],e)<2&&(this.types[e]=C.UTF8ToString(C._ts_language_symbol_name(this[0],e)));this.fields=new Array(C._ts_language_field_count(this[0])+1);for(let e=0,t=this.fields.length;e<t;e++){const t=C._ts_language_field_name_for_id(this[0],e);this.fields[e]=0!==t?C.UTF8ToString(t):null}}get name(){const e=C._ts_language_name(this[0]);return 0===e?null:C.UTF8ToString(e)}get abiVersion(){return C._ts_language_abi_version(this[0])}get metadata(){return C._ts_language_metadata_wasm(this[0]),0===C.getValue(TRANSFER_BUFFER,"i32")?null:unmarshalLanguageMetadata(TRANSFER_BUFFER+SIZE_OF_INT)}get fieldCount(){return this.fields.length-1}get stateCount(){return C._ts_language_state_count(this[0])}fieldIdForName(e){const t=this.fields.indexOf(e);return-1!==t?t:null}fieldNameForId(e){return this.fields[e]??null}idForNodeType(e,t){const n=C.lengthBytesUTF8(e),r=C._malloc(n+1);C.stringToUTF8(e,r,n+1);const s=C._ts_language_symbol_for_name(this[0],r,n,t?1:0);return C._free(r),s||null}get nodeTypeCount(){return C._ts_language_symbol_count(this[0])}nodeTypeForId(e){const t=C._ts_language_symbol_name(this[0],e);return t?C.UTF8ToString(t):null}nodeTypeIsNamed(e){return!!C._ts_language_type_is_named_wasm(this[0],e)}nodeTypeIsVisible(e){return!!C._ts_language_type_is_visible_wasm(this[0],e)}get supertypes(){C._ts_language_supertypes_wasm(this[0]);const e=C.getValue(TRANSFER_BUFFER,"i32"),t=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),n=new Array(e);if(e>0){let r=t;for(let t=0;t<e;t++)n[t]=C.getValue(r,"i16"),r+=SIZE_OF_SHORT}return n}subtypes(e){C._ts_language_subtypes_wasm(this[0],e);const t=C.getValue(TRANSFER_BUFFER,"i32"),n=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),r=new Array(t);if(t>0){let e=n;for(let n=0;n<t;n++)r[n]=C.getValue(e,"i16"),e+=SIZE_OF_SHORT}return r}nextState(e,t){return C._ts_language_next_state(this[0],e,t)}lookaheadIterator(e){const t=C._ts_lookahead_iterator_new(this[0],e);return t?new LookaheadIterator(INTERNAL,t,this):null}static async load(t){let n;if(t instanceof Uint8Array)n=t;else if(globalThis.process?.versions.node){const e=await Promise.resolve().then(__webpack_require__.t.bind(__webpack_require__,943,23));n=await e.readFile(t)}else{const e=await fetch(t);if(!e.ok){const t=await e.text();throw new Error(`Language.load failed with status ${e.status}.\n\n${t}`)}const r=e.clone();try{n=await WebAssembly.compileStreaming(e)}catch(e){console.error("wasm streaming compile failed:",e),console.error("falling back to ArrayBuffer instantiation"),n=new Uint8Array(await r.arrayBuffer())}}const r=await C.loadWebAssemblyModule(n,{loadAsync:!0}),s=Object.keys(r),o=s.find(e=>LANGUAGE_FUNCTION_REGEX.test(e)&&!e.includes("external_scanner_"));if(!o)throw console.log(`Couldn't find language function in Wasm file. Symbols:\n${JSON.stringify(s,null,2)}`),new Error("Language.load failed: no language function found in Wasm file");const a=r[o]();return new e(INTERNAL,a)}},import_web_tree_sitter=__toESM(require_web_tree_sitter(),1),Module2=null,TRANSFER_BUFFER,LANGUAGE_VERSION,MIN_COMPATIBLE_VERSION;async function initializeBinding(e){return Module2??=await(0,import_web_tree_sitter.default)(e)}function checkModule(){return!!Module2}__name(initializeBinding,"initializeBinding"),__name(checkModule,"checkModule");var Parser=class{static{__name(this,"Parser")}0=0;1=0;logCallback=null;language=null;static async init(e){setModule(await initializeBinding(e)),TRANSFER_BUFFER=C._ts_init(),LANGUAGE_VERSION=C.getValue(TRANSFER_BUFFER,"i32"),MIN_COMPATIBLE_VERSION=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}constructor(){this.initialize()}initialize(){if(!checkModule())throw new Error("cannot construct a Parser before calling `init()`");C._ts_parser_new_wasm(),this[0]=C.getValue(TRANSFER_BUFFER,"i32"),this[1]=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}delete(){C._ts_parser_delete(this[0]),C._free(this[1]),this[0]=0,this[1]=0}setLanguage(e){let t;if(e){if(e.constructor!==Language)throw new Error("Argument must be a Language");{t=e[0];const n=C._ts_language_abi_version(t);if(n<MIN_COMPATIBLE_VERSION||LANGUAGE_VERSION<n)throw new Error(`Incompatible language version ${n}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`);this.language=e}}else t=0,this.language=null;return C._ts_parser_set_language(this[0],t),this}parse(e,t,n){if("string"==typeof e)C.currentParseCallback=t=>e.slice(t);else{if("function"!=typeof e)throw new Error("Argument must be a string or a function");C.currentParseCallback=e}C.currentProgressCallback=n?.progressCallback?n.progressCallback:null,this.logCallback?(C.currentLogCallback=this.logCallback,C._ts_parser_enable_logger_wasm(this[0],1)):(C.currentLogCallback=null,C._ts_parser_enable_logger_wasm(this[0],0));let r=0,s=0;if(n?.includedRanges){r=n.includedRanges.length,s=C._calloc(r,SIZE_OF_RANGE);let e=s;for(let t=0;t<r;t++)marshalRange(e,n.includedRanges[t]),e+=SIZE_OF_RANGE}const o=C._ts_parser_parse_wasm(this[0],this[1],t?t[0]:0,s,r);if(!o)return C.currentParseCallback=null,C.currentLogCallback=null,C.currentProgressCallback=null,null;if(!this.language)throw new Error("Parser must have a language to parse");const a=new Tree(INTERNAL,o,this.language,C.currentParseCallback);return C.currentParseCallback=null,C.currentLogCallback=null,C.currentProgressCallback=null,a}reset(){C._ts_parser_reset(this[0])}getIncludedRanges(){C._ts_parser_included_ranges_wasm(this[0]);const e=C.getValue(TRANSFER_BUFFER,"i32"),t=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),n=new Array(e);if(e>0){let r=t;for(let t=0;t<e;t++)n[t]=unmarshalRange(r),r+=SIZE_OF_RANGE;C._free(t)}return n}setLogger(e){if(e){if("function"!=typeof e)throw new Error("Logger callback must be a function");this.logCallback=e}else this.logCallback=null;return this}getLogger(){return this.logCallback}},PREDICATE_STEP_TYPE_CAPTURE=1,PREDICATE_STEP_TYPE_STRING=2,QUERY_WORD_REGEX=/[\w-]+/g,CaptureQuantifier={Zero:0,ZeroOrOne:1,ZeroOrMore:2,One:3,OneOrMore:4},isCaptureStep=__name(e=>"capture"===e.type,"isCaptureStep"),isStringStep=__name(e=>"string"===e.type,"isStringStep"),QueryErrorKind={Syntax:1,NodeName:2,FieldName:3,CaptureName:4,PatternStructure:5},QueryError=class e extends Error{constructor(t,n,r,s){super(e.formatMessage(t,n)),this.kind=t,this.info=n,this.index=r,this.length=s,this.name="QueryError"}static{__name(this,"QueryError")}static formatMessage(e,t){switch(e){case QueryErrorKind.NodeName:return`Bad node name '${t.word}'`;case QueryErrorKind.FieldName:return`Bad field name '${t.word}'`;case QueryErrorKind.CaptureName:return`Bad capture name @${t.word}`;case QueryErrorKind.PatternStructure:return`Bad pattern structure at offset ${t.suffix}`;case QueryErrorKind.Syntax:return`Bad syntax at offset ${t.suffix}`}}};function parseAnyPredicate(e,t,n,r){if(3!==e.length)throw new Error(`Wrong number of arguments to \`#${n}\` predicate. Expected 2, got ${e.length-1}`);if(!isCaptureStep(e[1]))throw new Error(`First argument of \`#${n}\` predicate must be a capture. Got "${e[1].value}"`);const s="eq?"===n||"any-eq?"===n,o=!n.startsWith("any-");if(isCaptureStep(e[2])){const n=e[1].name,a=e[2].name;r[t].push(e=>{const t=[],r=[];for(const s of e)s.name===n&&t.push(s.node),s.name===a&&r.push(s.node);const i=__name((e,t,n)=>n?e.text===t.text:e.text!==t.text,"compare");return o?t.every(e=>r.some(t=>i(e,t,s))):t.some(e=>r.some(t=>i(e,t,s)))})}else{const n=e[1].name,a=e[2].value,i=__name(e=>e.text===a,"matches"),_=__name(e=>e.text!==a,"doesNotMatch");r[t].push(e=>{const t=[];for(const r of e)r.name===n&&t.push(r.node);const r=s?i:_;return o?t.every(r):t.some(r)})}}function parseMatchPredicate(e,t,n,r){if(3!==e.length)throw new Error(`Wrong number of arguments to \`#${n}\` predicate. Expected 2, got ${e.length-1}.`);if("capture"!==e[1].type)throw new Error(`First argument of \`#${n}\` predicate must be a capture. Got "${e[1].value}".`);if("string"!==e[2].type)throw new Error(`Second argument of \`#${n}\` predicate must be a string. Got @${e[2].name}.`);const s="match?"===n||"any-match?"===n,o=!n.startsWith("any-"),a=e[1].name,i=new RegExp(e[2].value);r[t].push(e=>{const t=[];for(const n of e)n.name===a&&t.push(n.node.text);const n=__name((e,t)=>t?i.test(e):!i.test(e),"test");return 0===t.length?!s:o?t.every(e=>n(e,s)):t.some(e=>n(e,s))})}function parseAnyOfPredicate(e,t,n,r){if(e.length<2)throw new Error(`Wrong number of arguments to \`#${n}\` predicate. Expected at least 1. Got ${e.length-1}.`);if("capture"!==e[1].type)throw new Error(`First argument of \`#${n}\` predicate must be a capture. Got "${e[1].value}".`);const s="any-of?"===n,o=e[1].name,a=e.slice(2);if(!a.every(isStringStep))throw new Error(`Arguments to \`#${n}\` predicate must be strings.".`);const i=a.map(e=>e.value);r[t].push(e=>{const t=[];for(const n of e)n.name===o&&t.push(n.node.text);return 0===t.length?!s:t.every(e=>i.includes(e))===s})}function parseIsPredicate(e,t,n,r,s){if(e.length<2||e.length>3)throw new Error(`Wrong number of arguments to \`#${n}\` predicate. Expected 1 or 2. Got ${e.length-1}.`);if(!e.every(isStringStep))throw new Error(`Arguments to \`#${n}\` predicate must be strings.".`);const o="is?"===n?r:s;o[t]||(o[t]={}),o[t][e[1].value]=e[2]?.value??null}function parseSetDirective(e,t,n){if(e.length<2||e.length>3)throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${e.length-1}.`);if(!e.every(isStringStep))throw new Error('Arguments to `#set!` predicate must be strings.".');n[t]||(n[t]={}),n[t][e[1].value]=e[2]?.value??null}function parsePattern(e,t,n,r,s,o,a,i,_,l,u){if(t===PREDICATE_STEP_TYPE_CAPTURE){const e=r[n];o.push({type:"capture",name:e})}else if(t===PREDICATE_STEP_TYPE_STRING)o.push({type:"string",value:s[n]});else if(o.length>0){if("string"!==o[0].type)throw new Error("Predicates must begin with a literal value");const t=o[0].value;switch(t){case"any-not-eq?":case"not-eq?":case"any-eq?":case"eq?":parseAnyPredicate(o,e,t,a);break;case"any-not-match?":case"not-match?":case"any-match?":case"match?":parseMatchPredicate(o,e,t,a);break;case"not-any-of?":case"any-of?":parseAnyOfPredicate(o,e,t,a);break;case"is?":case"is-not?":parseIsPredicate(o,e,t,l,u);break;case"set!":parseSetDirective(o,e,_);break;default:i[e].push({operator:t,operands:o.slice(1)})}o.length=0}}__name(parseAnyPredicate,"parseAnyPredicate"),__name(parseMatchPredicate,"parseMatchPredicate"),__name(parseAnyOfPredicate,"parseAnyOfPredicate"),__name(parseIsPredicate,"parseIsPredicate"),__name(parseSetDirective,"parseSetDirective"),__name(parsePattern,"parsePattern");var Query=class{static{__name(this,"Query")}0=0;exceededMatchLimit;textPredicates;captureNames;captureQuantifiers;predicates;setProperties;assertedProperties;refutedProperties;matchLimit;constructor(e,t){const n=C.lengthBytesUTF8(t),r=C._malloc(n+1);C.stringToUTF8(t,r,n+1);const s=C._ts_query_new(e[0],r,n,TRANSFER_BUFFER,TRANSFER_BUFFER+SIZE_OF_INT);if(!s){const e=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),n=C.getValue(TRANSFER_BUFFER,"i32"),s=C.UTF8ToString(r,n).length,o=t.slice(s,s+100).split("\n")[0],a=o.match(QUERY_WORD_REGEX)?.[0]??"";switch(C._free(r),e){case QueryErrorKind.Syntax:throw new QueryError(QueryErrorKind.Syntax,{suffix:`${s}: '${o}'...`},s,0);case QueryErrorKind.NodeName:case QueryErrorKind.FieldName:case QueryErrorKind.CaptureName:throw new QueryError(e,{word:a},s,a.length);case QueryErrorKind.PatternStructure:throw new QueryError(e,{suffix:`${s}: '${o}'...`},s,0)}}const o=C._ts_query_string_count(s),a=C._ts_query_capture_count(s),i=C._ts_query_pattern_count(s),_=new Array(a),l=new Array(i),u=new Array(o);for(let e=0;e<a;e++){const t=C._ts_query_capture_name_for_id(s,e,TRANSFER_BUFFER),n=C.getValue(TRANSFER_BUFFER,"i32");_[e]=C.UTF8ToString(t,n)}for(let e=0;e<i;e++){const t=new Array(a);for(let n=0;n<a;n++){const r=C._ts_query_capture_quantifier_for_id(s,e,n);t[n]=r}l[e]=t}for(let e=0;e<o;e++){const t=C._ts_query_string_value_for_id(s,e,TRANSFER_BUFFER),n=C.getValue(TRANSFER_BUFFER,"i32");u[e]=C.UTF8ToString(t,n)}const c=new Array(i),d=new Array(i),m=new Array(i),p=new Array(i),h=new Array(i);for(let e=0;e<i;e++){const t=C._ts_query_predicates_for_pattern(s,e,TRANSFER_BUFFER),n=C.getValue(TRANSFER_BUFFER,"i32");p[e]=[],h[e]=[];const r=new Array;let o=t;for(let t=0;t<n;t++){const t=C.getValue(o,"i32");o+=SIZE_OF_INT;const n=C.getValue(o,"i32");o+=SIZE_OF_INT,parsePattern(e,t,n,_,u,r,h,p,c,d,m)}Object.freeze(h[e]),Object.freeze(p[e]),Object.freeze(c[e]),Object.freeze(d[e]),Object.freeze(m[e])}C._free(r),this[0]=s,this.captureNames=_,this.captureQuantifiers=l,this.textPredicates=h,this.predicates=p,this.setProperties=c,this.assertedProperties=d,this.refutedProperties=m,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(e,t={}){const n=t.startPosition??ZERO_POINT,r=t.endPosition??ZERO_POINT,s=t.startIndex??0,o=t.endIndex??0,a=t.startContainingPosition??ZERO_POINT,i=t.endContainingPosition??ZERO_POINT,_=t.startContainingIndex??0,l=t.endContainingIndex??0,u=t.matchLimit??4294967295,c=t.maxStartDepth??4294967295,d=t.progressCallback;if("number"!=typeof u)throw new Error("Arguments must be numbers");if(this.matchLimit=u,0!==o&&s>o)throw new Error("`startIndex` cannot be greater than `endIndex`");if(r!==ZERO_POINT&&(n.row>r.row||n.row===r.row&&n.column>r.column))throw new Error("`startPosition` cannot be greater than `endPosition`");if(0!==l&&_>l)throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");if(i!==ZERO_POINT&&(a.row>i.row||a.row===i.row&&a.column>i.column))throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");d&&(C.currentQueryProgressCallback=d),marshalNode(e),C._ts_query_matches_wasm(this[0],e.tree[0],n.row,n.column,r.row,r.column,s,o,a.row,a.column,i.row,i.column,_,l,u,c);const m=C.getValue(TRANSFER_BUFFER,"i32"),p=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),h=C.getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),f=new Array(m);this.exceededMatchLimit=Boolean(h);let g=0,y=p;for(let t=0;t<m;t++){const t=C.getValue(y,"i32");y+=SIZE_OF_INT;const n=C.getValue(y,"i32");y+=SIZE_OF_INT;const r=new Array(n);if(y=unmarshalCaptures(this,e.tree,y,t,r),this.textPredicates[t].every(e=>e(r))){f[g]={patternIndex:t,captures:r};const e=this.setProperties[t];f[g].setProperties=e;const n=this.assertedProperties[t];f[g].assertedProperties=n;const s=this.refutedProperties[t];f[g].refutedProperties=s,g++}}return f.length=g,C._free(p),C.currentQueryProgressCallback=null,f}captures(e,t={}){const n=t.startPosition??ZERO_POINT,r=t.endPosition??ZERO_POINT,s=t.startIndex??0,o=t.endIndex??0,a=t.startContainingPosition??ZERO_POINT,i=t.endContainingPosition??ZERO_POINT,_=t.startContainingIndex??0,l=t.endContainingIndex??0,u=t.matchLimit??4294967295,c=t.maxStartDepth??4294967295,d=t.progressCallback;if("number"!=typeof u)throw new Error("Arguments must be numbers");if(this.matchLimit=u,0!==o&&s>o)throw new Error("`startIndex` cannot be greater than `endIndex`");if(r!==ZERO_POINT&&(n.row>r.row||n.row===r.row&&n.column>r.column))throw new Error("`startPosition` cannot be greater than `endPosition`");if(0!==l&&_>l)throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");if(i!==ZERO_POINT&&(a.row>i.row||a.row===i.row&&a.column>i.column))throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");d&&(C.currentQueryProgressCallback=d),marshalNode(e),C._ts_query_captures_wasm(this[0],e.tree[0],n.row,n.column,r.row,r.column,s,o,a.row,a.column,i.row,i.column,_,l,u,c);const m=C.getValue(TRANSFER_BUFFER,"i32"),p=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),h=C.getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),f=new Array;this.exceededMatchLimit=Boolean(h);const g=new Array;let y=p;for(let t=0;t<m;t++){const t=C.getValue(y,"i32");y+=SIZE_OF_INT;const n=C.getValue(y,"i32");y+=SIZE_OF_INT;const r=C.getValue(y,"i32");if(y+=SIZE_OF_INT,g.length=n,y=unmarshalCaptures(this,e.tree,y,t,g),this.textPredicates[t].every(e=>e(g))){const e=g[r],n=this.setProperties[t];e.setProperties=n;const s=this.assertedProperties[t];e.assertedProperties=s;const o=this.refutedProperties[t];e.refutedProperties=o,f.push(e)}}return C._free(p),C.currentQueryProgressCallback=null,f}predicatesForPattern(e){return this.predicates[e]}disableCapture(e){const t=C.lengthBytesUTF8(e),n=C._malloc(t+1);C.stringToUTF8(e,n,t+1),C._ts_query_disable_capture(this[0],n,t),C._free(n)}disablePattern(e){if(e>=this.predicates.length)throw new Error(`Pattern index is ${e} but the pattern count is ${this.predicates.length}`);C._ts_query_disable_pattern(this[0],e)}didExceedMatchLimit(){return this.exceededMatchLimit}startIndexForPattern(e){if(e>=this.predicates.length)throw new Error(`Pattern index is ${e} but the pattern count is ${this.predicates.length}`);return C._ts_query_start_byte_for_pattern(this[0],e)}endIndexForPattern(e){if(e>=this.predicates.length)throw new Error(`Pattern index is ${e} but the pattern count is ${this.predicates.length}`);return C._ts_query_end_byte_for_pattern(this[0],e)}patternCount(){return C._ts_query_pattern_count(this[0])}captureIndexForName(e){return this.captureNames.indexOf(e)}isPatternRooted(e){return 1===C._ts_query_is_pattern_rooted(this[0],e)}isPatternNonLocal(e){return 1===C._ts_query_is_pattern_non_local(this[0],e)}isPatternGuaranteedAtStep(e){return 1===C._ts_query_is_pattern_guaranteed_at_step(this[0],e)}};module.exports.default=module.exports}};const __webpack_module_cache__={};function __webpack_require__(e){const t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;const n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}(()=>{const e=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;let t;__webpack_require__.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}const s=Object.create(null);__webpack_require__.r(s);const o={};t=t||[null,e({}),e([]),e(e)];for(var a=2&r&&n;("object"==typeof a||"function"==typeof a)&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach(e=>o[e]=()=>n[e]);return o.default=()=>n,__webpack_require__.d(s,o),s}})(),__webpack_require__.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var r=t[n++],s=t[n++];__webpack_require__.o(e,r)?0===s&&n++:0===s?Object.defineProperty(e,r,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,r,{enumerable:!0,get:s})}else for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let __webpack_exports__=__webpack_require__(186);module.exports=__webpack_exports__})();
2
+ (()=>{"use strict";var __webpack_modules__={747(e,t,n){e.exports=n.p+"498894f52e4b9dcbc99d.wasm"},943(e){e.exports=require("fs/promises")},339(e){e.exports=require("module")},132(__unused_webpack___webpack_module__,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{TM:()=>Language,iX:()=>Parser});var __defProp=Object.defineProperty,__name=(e,t)=>__defProp(e,"name",{value:t,configurable:!0}),Edit=class{static{__name(this,"Edit")}startPosition;oldEndPosition;newEndPosition;startIndex;oldEndIndex;newEndIndex;constructor({startIndex:e,oldEndIndex:t,newEndIndex:n,startPosition:r,oldEndPosition:o,newEndPosition:i}){this.startIndex=e>>>0,this.oldEndIndex=t>>>0,this.newEndIndex=n>>>0,this.startPosition=r,this.oldEndPosition=o,this.newEndPosition=i}editPoint(e,t){let n=t;const r={...e};if(t>=this.oldEndIndex){n=this.newEndIndex+(t-this.oldEndIndex);const o=e.row;r.row=this.newEndPosition.row+(e.row-this.oldEndPosition.row),r.column=o===this.oldEndPosition.row?this.newEndPosition.column+(e.column-this.oldEndPosition.column):e.column}else t>this.startIndex&&(n=this.newEndIndex,r.row=this.newEndPosition.row,r.column=this.newEndPosition.column);return{point:r,index:n}}editRange(e){const t={startIndex:e.startIndex,startPosition:{...e.startPosition},endIndex:e.endIndex,endPosition:{...e.endPosition}};return e.endIndex>=this.oldEndIndex?e.endIndex!==Number.MAX_SAFE_INTEGER&&(t.endIndex=this.newEndIndex+(e.endIndex-this.oldEndIndex),t.endPosition={row:this.newEndPosition.row+(e.endPosition.row-this.oldEndPosition.row),column:e.endPosition.row===this.oldEndPosition.row?this.newEndPosition.column+(e.endPosition.column-this.oldEndPosition.column):e.endPosition.column},t.endIndex<this.newEndIndex&&(t.endIndex=Number.MAX_SAFE_INTEGER,t.endPosition={row:Number.MAX_SAFE_INTEGER,column:Number.MAX_SAFE_INTEGER})):e.endIndex>this.startIndex&&(t.endIndex=this.startIndex,t.endPosition={...this.startPosition}),e.startIndex>=this.oldEndIndex?(t.startIndex=this.newEndIndex+(e.startIndex-this.oldEndIndex),t.startPosition={row:this.newEndPosition.row+(e.startPosition.row-this.oldEndPosition.row),column:e.startPosition.row===this.oldEndPosition.row?this.newEndPosition.column+(e.startPosition.column-this.oldEndPosition.column):e.startPosition.column},t.startIndex<this.newEndIndex&&(t.startIndex=Number.MAX_SAFE_INTEGER,t.startPosition={row:Number.MAX_SAFE_INTEGER,column:Number.MAX_SAFE_INTEGER})):e.startIndex>this.startIndex&&(t.startIndex=this.startIndex,t.startPosition={...this.startPosition}),t}},SIZE_OF_SHORT=2,SIZE_OF_INT=4,SIZE_OF_CURSOR=4*SIZE_OF_INT,SIZE_OF_NODE=5*SIZE_OF_INT,SIZE_OF_POINT=2*SIZE_OF_INT,SIZE_OF_RANGE=2*SIZE_OF_INT+2*SIZE_OF_POINT,ZERO_POINT={row:0,column:0},INTERNAL=Symbol("INTERNAL"),C;function assertInternal(e){if(e!==INTERNAL)throw new Error("Illegal constructor")}function isPoint(e){return!!e&&"number"==typeof e.row&&"number"==typeof e.column}function setModule(e){C=e}__name(assertInternal,"assertInternal"),__name(isPoint,"isPoint"),__name(setModule,"setModule");var LookaheadIterator=class{static{__name(this,"LookaheadIterator")}0=0;language;constructor(e,t,n){assertInternal(e),this[0]=t,this.language=n}get currentTypeId(){return C._ts_lookahead_iterator_current_symbol(this[0])}get currentType(){return this.language.types[this.currentTypeId]||"ERROR"}delete(){C._ts_lookahead_iterator_delete(this[0]),this[0]=0}reset(e,t){return!!C._ts_lookahead_iterator_reset(this[0],e[0],t)&&(this.language=e,!0)}resetState(e){return Boolean(C._ts_lookahead_iterator_reset_state(this[0],e))}[Symbol.iterator](){return{next:__name(()=>C._ts_lookahead_iterator_next(this[0])?{done:!1,value:this.currentType}:{done:!0,value:""},"next")}}};function getText(e,t,n,r){const o=n-t;let i=e.textCallback(t,r);if(i){for(t+=i.length;t<n;){const n=e.textCallback(t,r);if(!(n&&n.length>0))break;t+=n.length,i+=n}t>n&&(i=i.slice(0,o))}return i??""}__name(getText,"getText");var Tree=class e{static{__name(this,"Tree")}0=0;textCallback;language;constructor(e,t,n,r){assertInternal(e),this[0]=t,this.language=n,this.textCallback=r}copy(){const t=C._ts_tree_copy(this[0]);return new e(INTERNAL,t,this.language,this.textCallback)}delete(){C._ts_tree_delete(this[0]),this[0]=0}get rootNode(){return C._ts_tree_root_node_wasm(this[0]),unmarshalNode(this)}rootNodeWithOffset(e,t){const n=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(n,e,"i32"),marshalPoint(n+SIZE_OF_INT,t),C._ts_tree_root_node_with_offset_wasm(this[0]),unmarshalNode(this)}edit(e){marshalEdit(e),C._ts_tree_edit_wasm(this[0])}walk(){return this.rootNode.walk()}getChangedRanges(t){if(!(t instanceof e))throw new TypeError("Argument must be a Tree");C._ts_tree_get_changed_ranges_wasm(this[0],t[0]);const n=C.getValue(TRANSFER_BUFFER,"i32"),r=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),o=new Array(n);if(n>0){let e=r;for(let t=0;t<n;t++)o[t]=unmarshalRange(e),e+=SIZE_OF_RANGE;C._free(r)}return o}getIncludedRanges(){C._ts_tree_included_ranges_wasm(this[0]);const e=C.getValue(TRANSFER_BUFFER,"i32"),t=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),n=new Array(e);if(e>0){let r=t;for(let t=0;t<e;t++)n[t]=unmarshalRange(r),r+=SIZE_OF_RANGE;C._free(t)}return n}},TreeCursor=class e{static{__name(this,"TreeCursor")}0=0;1=0;2=0;3=0;tree;constructor(e,t){assertInternal(e),this.tree=t,unmarshalTreeCursor(this)}copy(){const t=new e(INTERNAL,this.tree);return C._ts_tree_cursor_copy_wasm(this.tree[0]),unmarshalTreeCursor(t),t}delete(){marshalTreeCursor(this),C._ts_tree_cursor_delete_wasm(this.tree[0]),this[0]=this[1]=this[2]=0}get currentNode(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_wasm(this.tree[0]),unmarshalNode(this.tree)}get currentFieldId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_field_id_wasm(this.tree[0])}get currentFieldName(){return this.tree.language.fields[this.currentFieldId]}get currentDepth(){return marshalTreeCursor(this),C._ts_tree_cursor_current_depth_wasm(this.tree[0])}get currentDescendantIndex(){return marshalTreeCursor(this),C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0])}get nodeType(){return this.tree.language.types[this.nodeTypeId]||"ERROR"}get nodeTypeId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0])}get nodeStateId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0])}get nodeId(){return marshalTreeCursor(this),C._ts_tree_cursor_current_node_id_wasm(this.tree[0])}get nodeIsNamed(){return marshalTreeCursor(this),1===C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0])}get nodeIsMissing(){return marshalTreeCursor(this),1===C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0])}get nodeText(){marshalTreeCursor(this);const e=C._ts_tree_cursor_start_index_wasm(this.tree[0]),t=C._ts_tree_cursor_end_index_wasm(this.tree[0]);C._ts_tree_cursor_start_position_wasm(this.tree[0]);const n=unmarshalPoint(TRANSFER_BUFFER);return getText(this.tree,e,t,n)}get startPosition(){return marshalTreeCursor(this),C._ts_tree_cursor_start_position_wasm(this.tree[0]),unmarshalPoint(TRANSFER_BUFFER)}get endPosition(){return marshalTreeCursor(this),C._ts_tree_cursor_end_position_wasm(this.tree[0]),unmarshalPoint(TRANSFER_BUFFER)}get startIndex(){return marshalTreeCursor(this),C._ts_tree_cursor_start_index_wasm(this.tree[0])}get endIndex(){return marshalTreeCursor(this),C._ts_tree_cursor_end_index_wasm(this.tree[0])}gotoFirstChild(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoLastChild(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoParent(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoNextSibling(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoPreviousSibling(){marshalTreeCursor(this);const e=C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===e}gotoDescendant(e){marshalTreeCursor(this),C._ts_tree_cursor_goto_descendant_wasm(this.tree[0],e),unmarshalTreeCursor(this)}gotoFirstChildForIndex(e){marshalTreeCursor(this),C.setValue(TRANSFER_BUFFER+SIZE_OF_CURSOR,e,"i32");const t=C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===t}gotoFirstChildForPosition(e){marshalTreeCursor(this),marshalPoint(TRANSFER_BUFFER+SIZE_OF_CURSOR,e);const t=C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);return unmarshalTreeCursor(this),1===t}reset(e){marshalNode(e),marshalTreeCursor(this,TRANSFER_BUFFER+SIZE_OF_NODE),C._ts_tree_cursor_reset_wasm(this.tree[0]),unmarshalTreeCursor(this)}resetTo(e){marshalTreeCursor(this,TRANSFER_BUFFER),marshalTreeCursor(e,TRANSFER_BUFFER+SIZE_OF_CURSOR),C._ts_tree_cursor_reset_to_wasm(this.tree[0],e.tree[0]),unmarshalTreeCursor(this)}},Node=class{static{__name(this,"Node")}0=0;_children;_namedChildren;constructor(e,{id:t,tree:n,startIndex:r,startPosition:o,other:i}){assertInternal(e),this[0]=i,this.id=t,this.tree=n,this.startIndex=r,this.startPosition=o}id;startIndex;startPosition;tree;get typeId(){return marshalNode(this),C._ts_node_symbol_wasm(this.tree[0])}get grammarId(){return marshalNode(this),C._ts_node_grammar_symbol_wasm(this.tree[0])}get type(){return this.tree.language.types[this.typeId]||"ERROR"}get grammarType(){return this.tree.language.types[this.grammarId]||"ERROR"}get isNamed(){return marshalNode(this),1===C._ts_node_is_named_wasm(this.tree[0])}get isExtra(){return marshalNode(this),1===C._ts_node_is_extra_wasm(this.tree[0])}get isError(){return marshalNode(this),1===C._ts_node_is_error_wasm(this.tree[0])}get isMissing(){return marshalNode(this),1===C._ts_node_is_missing_wasm(this.tree[0])}get hasChanges(){return marshalNode(this),1===C._ts_node_has_changes_wasm(this.tree[0])}get hasError(){return marshalNode(this),1===C._ts_node_has_error_wasm(this.tree[0])}get endIndex(){return marshalNode(this),C._ts_node_end_index_wasm(this.tree[0])}get endPosition(){return marshalNode(this),C._ts_node_end_point_wasm(this.tree[0]),unmarshalPoint(TRANSFER_BUFFER)}get text(){return getText(this.tree,this.startIndex,this.endIndex,this.startPosition)}get parseState(){return marshalNode(this),C._ts_node_parse_state_wasm(this.tree[0])}get nextParseState(){return marshalNode(this),C._ts_node_next_parse_state_wasm(this.tree[0])}equals(e){return this.tree===e.tree&&this.id===e.id}child(e){return marshalNode(this),C._ts_node_child_wasm(this.tree[0],e),unmarshalNode(this.tree)}namedChild(e){return marshalNode(this),C._ts_node_named_child_wasm(this.tree[0],e),unmarshalNode(this.tree)}childForFieldId(e){return marshalNode(this),C._ts_node_child_by_field_id_wasm(this.tree[0],e),unmarshalNode(this.tree)}childForFieldName(e){const t=this.tree.language.fields.indexOf(e);return-1!==t?this.childForFieldId(t):null}fieldNameForChild(e){marshalNode(this);const t=C._ts_node_field_name_for_child_wasm(this.tree[0],e);return t?C.AsciiToString(t):null}fieldNameForNamedChild(e){marshalNode(this);const t=C._ts_node_field_name_for_named_child_wasm(this.tree[0],e);return t?C.AsciiToString(t):null}childrenForFieldName(e){const t=this.tree.language.fields.indexOf(e);return-1!==t&&0!==t?this.childrenForFieldId(t):[]}childrenForFieldId(e){marshalNode(this),C._ts_node_children_by_field_id_wasm(this.tree[0],e);const t=C.getValue(TRANSFER_BUFFER,"i32"),n=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),r=new Array(t);if(t>0){let e=n;for(let n=0;n<t;n++)r[n]=unmarshalNode(this.tree,e),e+=SIZE_OF_NODE;C._free(n)}return r}firstChildForIndex(e){marshalNode(this);const t=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(t,e,"i32"),C._ts_node_first_child_for_byte_wasm(this.tree[0]),unmarshalNode(this.tree)}firstNamedChildForIndex(e){marshalNode(this);const t=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(t,e,"i32"),C._ts_node_first_named_child_for_byte_wasm(this.tree[0]),unmarshalNode(this.tree)}get childCount(){return marshalNode(this),C._ts_node_child_count_wasm(this.tree[0])}get namedChildCount(){return marshalNode(this),C._ts_node_named_child_count_wasm(this.tree[0])}get firstChild(){return this.child(0)}get firstNamedChild(){return this.namedChild(0)}get lastChild(){return this.child(this.childCount-1)}get lastNamedChild(){return this.namedChild(this.namedChildCount-1)}get children(){if(!this._children){marshalNode(this),C._ts_node_children_wasm(this.tree[0]);const e=C.getValue(TRANSFER_BUFFER,"i32"),t=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32");if(this._children=new Array(e),e>0){let n=t;for(let t=0;t<e;t++)this._children[t]=unmarshalNode(this.tree,n),n+=SIZE_OF_NODE;C._free(t)}}return this._children}get namedChildren(){if(!this._namedChildren){marshalNode(this),C._ts_node_named_children_wasm(this.tree[0]);const e=C.getValue(TRANSFER_BUFFER,"i32"),t=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32");if(this._namedChildren=new Array(e),e>0){let n=t;for(let t=0;t<e;t++)this._namedChildren[t]=unmarshalNode(this.tree,n),n+=SIZE_OF_NODE;C._free(t)}}return this._namedChildren}descendantsOfType(e,t=ZERO_POINT,n=ZERO_POINT){Array.isArray(e)||(e=[e]);const r=[],o=this.tree.language.types;for(const t of e)"ERROR"==t&&r.push(65535);for(let t=0,n=o.length;t<n;t++)e.includes(o[t])&&r.push(t);const i=C._malloc(SIZE_OF_INT*r.length);for(let e=0,t=r.length;e<t;e++)C.setValue(i+e*SIZE_OF_INT,r[e],"i32");marshalNode(this),C._ts_node_descendants_of_type_wasm(this.tree[0],i,r.length,t.row,t.column,n.row,n.column);const s=C.getValue(TRANSFER_BUFFER,"i32"),a=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),_=new Array(s);if(s>0){let e=a;for(let t=0;t<s;t++)_[t]=unmarshalNode(this.tree,e),e+=SIZE_OF_NODE}return C._free(a),C._free(i),_}get nextSibling(){return marshalNode(this),C._ts_node_next_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get previousSibling(){return marshalNode(this),C._ts_node_prev_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get nextNamedSibling(){return marshalNode(this),C._ts_node_next_named_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get previousNamedSibling(){return marshalNode(this),C._ts_node_prev_named_sibling_wasm(this.tree[0]),unmarshalNode(this.tree)}get descendantCount(){return marshalNode(this),C._ts_node_descendant_count_wasm(this.tree[0])}get parent(){return marshalNode(this),C._ts_node_parent_wasm(this.tree[0]),unmarshalNode(this.tree)}childWithDescendant(e){return marshalNode(this),marshalNode(e,1),C._ts_node_child_with_descendant_wasm(this.tree[0]),unmarshalNode(this.tree)}descendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");marshalNode(this);const n=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(n,e,"i32"),C.setValue(n+SIZE_OF_INT,t,"i32"),C._ts_node_descendant_for_index_wasm(this.tree[0]),unmarshalNode(this.tree)}namedDescendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");marshalNode(this);const n=TRANSFER_BUFFER+SIZE_OF_NODE;return C.setValue(n,e,"i32"),C.setValue(n+SIZE_OF_INT,t,"i32"),C._ts_node_named_descendant_for_index_wasm(this.tree[0]),unmarshalNode(this.tree)}descendantForPosition(e,t=e){if(!isPoint(e)||!isPoint(t))throw new Error("Arguments must be {row, column} objects");marshalNode(this);const n=TRANSFER_BUFFER+SIZE_OF_NODE;return marshalPoint(n,e),marshalPoint(n+SIZE_OF_POINT,t),C._ts_node_descendant_for_position_wasm(this.tree[0]),unmarshalNode(this.tree)}namedDescendantForPosition(e,t=e){if(!isPoint(e)||!isPoint(t))throw new Error("Arguments must be {row, column} objects");marshalNode(this);const n=TRANSFER_BUFFER+SIZE_OF_NODE;return marshalPoint(n,e),marshalPoint(n+SIZE_OF_POINT,t),C._ts_node_named_descendant_for_position_wasm(this.tree[0]),unmarshalNode(this.tree)}walk(){return marshalNode(this),C._ts_tree_cursor_new_wasm(this.tree[0]),new TreeCursor(INTERNAL,this.tree)}edit(e){if(this.startIndex>=e.oldEndIndex){let t,n;this.startIndex=e.newEndIndex+(this.startIndex-e.oldEndIndex),this.startPosition.row>e.oldEndPosition.row?(t=this.startPosition.row-e.oldEndPosition.row,n=this.startPosition.column):(t=0,n=this.startPosition.column,this.startPosition.column>=e.oldEndPosition.column&&(n=this.startPosition.column-e.oldEndPosition.column)),t>0?(this.startPosition.row+=t,this.startPosition.column=n):this.startPosition.column+=n}else this.startIndex>e.startIndex&&(this.startIndex=e.newEndIndex,this.startPosition.row=e.newEndPosition.row,this.startPosition.column=e.newEndPosition.column)}toString(){marshalNode(this);const e=C._ts_node_to_string_wasm(this.tree[0]),t=C.AsciiToString(e);return C._free(e),t}};function unmarshalCaptures(e,t,n,r,o){for(let i=0,s=o.length;i<s;i++){const s=C.getValue(n,"i32"),a=unmarshalNode(t,n+=SIZE_OF_INT);n+=SIZE_OF_NODE,o[i]={patternIndex:r,name:e.captureNames[s],node:a}}return n}function marshalNode(e,t=0){let n=TRANSFER_BUFFER+t*SIZE_OF_NODE;C.setValue(n,e.id,"i32"),n+=SIZE_OF_INT,C.setValue(n,e.startIndex,"i32"),n+=SIZE_OF_INT,C.setValue(n,e.startPosition.row,"i32"),n+=SIZE_OF_INT,C.setValue(n,e.startPosition.column,"i32"),n+=SIZE_OF_INT,C.setValue(n,e[0],"i32")}function unmarshalNode(e,t=TRANSFER_BUFFER){const n=C.getValue(t,"i32");if(t+=SIZE_OF_INT,0===n)return null;const r=C.getValue(t,"i32");t+=SIZE_OF_INT;const o=C.getValue(t,"i32");t+=SIZE_OF_INT;const i=C.getValue(t,"i32");t+=SIZE_OF_INT;const s=C.getValue(t,"i32");return new Node(INTERNAL,{id:n,tree:e,startIndex:r,startPosition:{row:o,column:i},other:s})}function marshalTreeCursor(e,t=TRANSFER_BUFFER){C.setValue(t+0*SIZE_OF_INT,e[0],"i32"),C.setValue(t+1*SIZE_OF_INT,e[1],"i32"),C.setValue(t+2*SIZE_OF_INT,e[2],"i32"),C.setValue(t+3*SIZE_OF_INT,e[3],"i32")}function unmarshalTreeCursor(e){e[0]=C.getValue(TRANSFER_BUFFER+0*SIZE_OF_INT,"i32"),e[1]=C.getValue(TRANSFER_BUFFER+1*SIZE_OF_INT,"i32"),e[2]=C.getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),e[3]=C.getValue(TRANSFER_BUFFER+3*SIZE_OF_INT,"i32")}function marshalPoint(e,t){C.setValue(e,t.row,"i32"),C.setValue(e+SIZE_OF_INT,t.column,"i32")}function unmarshalPoint(e){return{row:C.getValue(e,"i32")>>>0,column:C.getValue(e+SIZE_OF_INT,"i32")>>>0}}function marshalRange(e,t){marshalPoint(e,t.startPosition),marshalPoint(e+=SIZE_OF_POINT,t.endPosition),e+=SIZE_OF_POINT,C.setValue(e,t.startIndex,"i32"),e+=SIZE_OF_INT,C.setValue(e,t.endIndex,"i32"),e+=SIZE_OF_INT}function unmarshalRange(e){const t={};return t.startPosition=unmarshalPoint(e),e+=SIZE_OF_POINT,t.endPosition=unmarshalPoint(e),e+=SIZE_OF_POINT,t.startIndex=C.getValue(e,"i32")>>>0,e+=SIZE_OF_INT,t.endIndex=C.getValue(e,"i32")>>>0,t}function marshalEdit(e,t=TRANSFER_BUFFER){marshalPoint(t,e.startPosition),marshalPoint(t+=SIZE_OF_POINT,e.oldEndPosition),marshalPoint(t+=SIZE_OF_POINT,e.newEndPosition),t+=SIZE_OF_POINT,C.setValue(t,e.startIndex,"i32"),t+=SIZE_OF_INT,C.setValue(t,e.oldEndIndex,"i32"),t+=SIZE_OF_INT,C.setValue(t,e.newEndIndex,"i32"),t+=SIZE_OF_INT}function unmarshalLanguageMetadata(e){return{major_version:C.getValue(e,"i32"),minor_version:C.getValue(e+=SIZE_OF_INT,"i32"),patch_version:C.getValue(e+=SIZE_OF_INT,"i32")}}__name(unmarshalCaptures,"unmarshalCaptures"),__name(marshalNode,"marshalNode"),__name(unmarshalNode,"unmarshalNode"),__name(marshalTreeCursor,"marshalTreeCursor"),__name(unmarshalTreeCursor,"unmarshalTreeCursor"),__name(marshalPoint,"marshalPoint"),__name(unmarshalPoint,"unmarshalPoint"),__name(marshalRange,"marshalRange"),__name(unmarshalRange,"unmarshalRange"),__name(marshalEdit,"marshalEdit"),__name(unmarshalLanguageMetadata,"unmarshalLanguageMetadata");var LANGUAGE_FUNCTION_REGEX=/^tree_sitter_\w+$/,Language=class e{static{__name(this,"Language")}0=0;types;fields;constructor(e,t){assertInternal(e),this[0]=t,this.types=new Array(C._ts_language_symbol_count(this[0]));for(let e=0,t=this.types.length;e<t;e++)C._ts_language_symbol_type(this[0],e)<2&&(this.types[e]=C.UTF8ToString(C._ts_language_symbol_name(this[0],e)));this.fields=new Array(C._ts_language_field_count(this[0])+1);for(let e=0,t=this.fields.length;e<t;e++){const t=C._ts_language_field_name_for_id(this[0],e);this.fields[e]=0!==t?C.UTF8ToString(t):null}}get name(){const e=C._ts_language_name(this[0]);return 0===e?null:C.UTF8ToString(e)}get abiVersion(){return C._ts_language_abi_version(this[0])}get metadata(){return C._ts_language_metadata_wasm(this[0]),0===C.getValue(TRANSFER_BUFFER,"i32")?null:unmarshalLanguageMetadata(TRANSFER_BUFFER+SIZE_OF_INT)}get fieldCount(){return this.fields.length-1}get stateCount(){return C._ts_language_state_count(this[0])}fieldIdForName(e){const t=this.fields.indexOf(e);return-1!==t?t:null}fieldNameForId(e){return this.fields[e]??null}idForNodeType(e,t){const n=C.lengthBytesUTF8(e),r=C._malloc(n+1);C.stringToUTF8(e,r,n+1);const o=C._ts_language_symbol_for_name(this[0],r,n,t?1:0);return C._free(r),o||null}get nodeTypeCount(){return C._ts_language_symbol_count(this[0])}nodeTypeForId(e){const t=C._ts_language_symbol_name(this[0],e);return t?C.UTF8ToString(t):null}nodeTypeIsNamed(e){return!!C._ts_language_type_is_named_wasm(this[0],e)}nodeTypeIsVisible(e){return!!C._ts_language_type_is_visible_wasm(this[0],e)}get supertypes(){C._ts_language_supertypes_wasm(this[0]);const e=C.getValue(TRANSFER_BUFFER,"i32"),t=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),n=new Array(e);if(e>0){let r=t;for(let t=0;t<e;t++)n[t]=C.getValue(r,"i16"),r+=SIZE_OF_SHORT}return n}subtypes(e){C._ts_language_subtypes_wasm(this[0],e);const t=C.getValue(TRANSFER_BUFFER,"i32"),n=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),r=new Array(t);if(t>0){let e=n;for(let n=0;n<t;n++)r[n]=C.getValue(e,"i16"),e+=SIZE_OF_SHORT}return r}nextState(e,t){return C._ts_language_next_state(this[0],e,t)}lookaheadIterator(e){const t=C._ts_lookahead_iterator_new(this[0],e);return t?new LookaheadIterator(INTERNAL,t,this):null}static async load(t){let n;if(t instanceof Uint8Array)n=t;else if(globalThis.process?.versions.node){const e=await Promise.resolve().then(()=>__webpack_require__.t(943,19));n=await e.readFile(t)}else{const e=await fetch(t);if(!e.ok){const t=await e.text();throw new Error(`Language.load failed with status ${e.status}.\n\n${t}`)}const r=e.clone();try{n=await WebAssembly.compileStreaming(e)}catch(e){console.error("wasm streaming compile failed:",e),console.error("falling back to ArrayBuffer instantiation"),n=new Uint8Array(await r.arrayBuffer())}}const r=await C.loadWebAssemblyModule(n,{loadAsync:!0}),o=Object.keys(r),i=o.find(e=>LANGUAGE_FUNCTION_REGEX.test(e)&&!e.includes("external_scanner_"));if(!i)throw console.log(`Couldn't find language function in Wasm file. Symbols:\n${JSON.stringify(o,null,2)}`),new Error("Language.load failed: no language function found in Wasm file");const s=r[i]();return new e(INTERNAL,s)}};async function Module2(moduleArg={}){var moduleRtn,Module=moduleArg,ENVIRONMENT_IS_WEB="object"==typeof window,ENVIRONMENT_IS_WORKER="undefined"!=typeof WorkerGlobalScope,ENVIRONMENT_IS_NODE="object"==typeof process&&process.versions?.node&&"renderer"!=process.type;if(ENVIRONMENT_IS_NODE){const{createRequire:e}=await Promise.resolve().then(()=>__webpack_require__.t(339,19));var require=e("file:///home/runner/work/energy-state-analyzer/energy-state-analyzer/node_modules/web-tree-sitter/web-tree-sitter.js")}Module.currentQueryProgressCallback=null,Module.currentProgressCallback=null,Module.currentLogCallback=null,Module.currentParseCallback=null;var arguments_=[],thisProgram="./this.program",quit_=__name((e,t)=>{throw t},"quit_"),_scriptName="file:///home/runner/work/energy-state-analyzer/energy-state-analyzer/node_modules/web-tree-sitter/web-tree-sitter.js",scriptDirectory="",readAsync,readBinary;function locateFile(e){return Module.locateFile?Module.locateFile(e,scriptDirectory):scriptDirectory+e}if(__name(locateFile,"locateFile"),ENVIRONMENT_IS_NODE){var fs=require("fs");_scriptName.startsWith("file:")&&(scriptDirectory=require("path").dirname(require("url").fileURLToPath(_scriptName))+"/"),readBinary=__name(e=>(e=isFileURI(e)?new URL(e):e,fs.readFileSync(e)),"readBinary"),readAsync=__name(async(e,t=!0)=>(e=isFileURI(e)?new URL(e):e,fs.readFileSync(e,t?void 0:"utf8")),"readAsync"),process.argv.length>1&&(thisProgram=process.argv[1].replace(/\\/g,"/")),arguments_=process.argv.slice(2),quit_=__name((e,t)=>{throw process.exitCode=e,t},"quit_")}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}ENVIRONMENT_IS_WORKER&&(readBinary=__name(e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)},"readBinary")),readAsync=__name(async e=>{if(isFileURI(e))return new Promise((t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n(r.status)},r.onerror=n,r.send(null)});var t=await fetch(e,{credentials:"same-origin"});if(t.ok)return t.arrayBuffer();throw new Error(t.status+" : "+t.url)},"readAsync")}var out=console.log.bind(console),err=console.error.bind(console),dynamicLibraries=[],wasmBinary,ABORT=!1,EXITSTATUS,isFileURI=__name(e=>e.startsWith("file://"),"isFileURI"),readyPromiseResolve,readyPromiseReject,wasmMemory,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64,HEAP64,HEAPU64,HEAP_DATA_VIEW,runtimeInitialized=!1;function updateMemoryViews(){var e=wasmMemory.buffer;Module.HEAP8=HEAP8=new Int8Array(e),Module.HEAP16=HEAP16=new Int16Array(e),Module.HEAPU8=HEAPU8=new Uint8Array(e),Module.HEAPU16=HEAPU16=new Uint16Array(e),Module.HEAP32=HEAP32=new Int32Array(e),Module.HEAPU32=HEAPU32=new Uint32Array(e),Module.HEAPF32=HEAPF32=new Float32Array(e),Module.HEAPF64=HEAPF64=new Float64Array(e),Module.HEAP64=HEAP64=new BigInt64Array(e),Module.HEAPU64=HEAPU64=new BigUint64Array(e),Module.HEAP_DATA_VIEW=HEAP_DATA_VIEW=new DataView(e),LE_HEAP_UPDATE()}function initMemory(){if(Module.wasmMemory)wasmMemory=Module.wasmMemory;else{var e=Module.INITIAL_MEMORY||33554432;wasmMemory=new WebAssembly.Memory({initial:e/65536,maximum:32768})}updateMemoryViews()}__name(updateMemoryViews,"updateMemoryViews"),__name(initMemory,"initMemory");var __RELOC_FUNCS__=[],wasmBinaryFile;function preRun(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),wasmExports.__wasm_call_ctors(),callRuntimeCallbacks(onPostCtors)}function preMain(){}function postRun(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(onPostRuns)}function abort(e){Module.onAbort?.(e),err(e="Aborted("+e+")"),ABORT=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw readyPromiseReject?.(t),t}function findWasmBinary(){return Module.locateFile?locateFile("web-tree-sitter.wasm"):new URL(__webpack_require__(747),__webpack_require__.b).href}function getBinarySync(e){if(e==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(e);throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(e){if(!wasmBinary)try{var t=await readAsync(e);return new Uint8Array(t)}catch{}return getBinarySync(e)}async function instantiateArrayBuffer(e,t){try{var n=await getWasmBinary(e);return await WebAssembly.instantiate(n,t)}catch(e){err(`failed to asynchronously prepare wasm: ${e}`),abort(e)}}async function instantiateAsync(e,t,n){if(!e&&!isFileURI(t)&&!ENVIRONMENT_IS_NODE)try{var r=fetch(t,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(r,n)}catch(e){err(`wasm streaming compile failed: ${e}`),err("falling back to ArrayBuffer instantiation")}return instantiateArrayBuffer(t,n)}function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports,"GOT.mem":new Proxy(wasmImports,GOTHandler),"GOT.func":new Proxy(wasmImports,GOTHandler)}}async function createWasm(){function e(e,t){wasmExports=e.exports,wasmExports=relocateExports(wasmExports,1024);var n=getDylinkMetadata(t);return n.neededDynlibs&&(dynamicLibraries=n.neededDynlibs.concat(dynamicLibraries)),mergeLibSymbols(wasmExports,"main"),LDSO.init(),loadDylibs(),__RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs),assignWasmExports(wasmExports),wasmExports}function t(t){return e(t.instance,t.module)}__name(e,"receiveInstance"),__name(t,"receiveInstantiationResult");var n=getWasmImports();return Module.instantiateWasm?new Promise((t,r)=>{Module.instantiateWasm(n,(n,r)=>{t(e(n,r))})}):(wasmBinaryFile??=findWasmBinary(),t(await instantiateAsync(wasmBinary,wasmBinaryFile,n)))}__name(preRun,"preRun"),__name(initRuntime,"initRuntime"),__name(preMain,"preMain"),__name(postRun,"postRun"),__name(abort,"abort"),__name(findWasmBinary,"findWasmBinary"),__name(getBinarySync,"getBinarySync"),__name(getWasmBinary,"getWasmBinary"),__name(instantiateArrayBuffer,"instantiateArrayBuffer"),__name(instantiateAsync,"instantiateAsync"),__name(getWasmImports,"getWasmImports"),__name(createWasm,"createWasm");class ExitStatus{static{__name(this,"ExitStatus")}name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var GOT={},currentModuleWeakSymbols=new Set([]),GOTHandler={get(e,t){var n=GOT[t];return n||(n=GOT[t]=new WebAssembly.Global({value:"i32",mutable:!0})),currentModuleWeakSymbols.has(t)||(n.required=!0),n}},LE_ATOMICS_NATIVE_BYTE_ORDER=[],LE_HEAP_LOAD_F32=__name(e=>HEAP_DATA_VIEW.getFloat32(e,!0),"LE_HEAP_LOAD_F32"),LE_HEAP_LOAD_F64=__name(e=>HEAP_DATA_VIEW.getFloat64(e,!0),"LE_HEAP_LOAD_F64"),LE_HEAP_LOAD_I16=__name(e=>HEAP_DATA_VIEW.getInt16(e,!0),"LE_HEAP_LOAD_I16"),LE_HEAP_LOAD_I32=__name(e=>HEAP_DATA_VIEW.getInt32(e,!0),"LE_HEAP_LOAD_I32"),LE_HEAP_LOAD_I64=__name(e=>HEAP_DATA_VIEW.getBigInt64(e,!0),"LE_HEAP_LOAD_I64"),LE_HEAP_LOAD_U32=__name(e=>HEAP_DATA_VIEW.getUint32(e,!0),"LE_HEAP_LOAD_U32"),LE_HEAP_STORE_F32=__name((e,t)=>HEAP_DATA_VIEW.setFloat32(e,t,!0),"LE_HEAP_STORE_F32"),LE_HEAP_STORE_F64=__name((e,t)=>HEAP_DATA_VIEW.setFloat64(e,t,!0),"LE_HEAP_STORE_F64"),LE_HEAP_STORE_I16=__name((e,t)=>HEAP_DATA_VIEW.setInt16(e,t,!0),"LE_HEAP_STORE_I16"),LE_HEAP_STORE_I32=__name((e,t)=>HEAP_DATA_VIEW.setInt32(e,t,!0),"LE_HEAP_STORE_I32"),LE_HEAP_STORE_I64=__name((e,t)=>HEAP_DATA_VIEW.setBigInt64(e,t,!0),"LE_HEAP_STORE_I64"),LE_HEAP_STORE_U32=__name((e,t)=>HEAP_DATA_VIEW.setUint32(e,t,!0),"LE_HEAP_STORE_U32"),callRuntimeCallbacks=__name(e=>{for(;e.length>0;)e.shift()(Module)},"callRuntimeCallbacks"),onPostRuns=[],addOnPostRun=__name(e=>onPostRuns.push(e),"addOnPostRun"),onPreRuns=[],addOnPreRun=__name(e=>onPreRuns.push(e),"addOnPreRun"),UTF8Decoder="undefined"!=typeof TextDecoder?new TextDecoder:void 0,findStringEnd=__name((e,t,n,r)=>{var o=t+n;if(r)return o;for(;e[t]&&!(t>=o);)++t;return t},"findStringEnd"),UTF8ArrayToString=__name((e,t=0,n,r)=>{var o=findStringEnd(e,t,n,r);if(o-t>16&&e.buffer&&UTF8Decoder)return UTF8Decoder.decode(e.subarray(t,o));for(var i="";t<o;){var s=e[t++];if(128&s){var a=63&e[t++];if(192!=(224&s)){var _=63&e[t++];if((s=224==(240&s)?(15&s)<<12|a<<6|_:(7&s)<<18|a<<12|_<<6|63&e[t++])<65536)i+=String.fromCharCode(s);else{var u=s-65536;i+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else i+=String.fromCharCode((31&s)<<6|a)}else i+=String.fromCharCode(s)}return i},"UTF8ArrayToString"),getDylinkMetadata=__name(e=>{var t=0,n=0;function r(){return e[t++]}function o(){for(var n=0,r=1;;){var o=e[t++];if(n+=(127&o)*r,r*=128,!(128&o))break}return n}function i(){var n=o();return UTF8ArrayToString(e,(t+=n)-n,n)}function s(){for(var e=o(),t=[];e--;)t.push(i());return t}function a(e,t){if(e)throw new Error(t)}if(__name(r,"getU8"),__name(o,"getLEB"),__name(i,"getString"),__name(s,"getStringList"),__name(a,"failIf"),e instanceof WebAssembly.Module){var _=WebAssembly.Module.customSections(e,"dylink.0");a(0===_.length,"need dylink section"),n=(e=new Uint8Array(_[0])).length}else{var u=new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer);a(!(1836278016==u[0]||6386541==u[0]),"need to see wasm magic number"),a(0!==e[8],"need the dylink section to be first"),t=9;var l=o();n=t+l,a("dylink.0"!==i())}for(var c={neededDynlibs:[],tlsExports:new Set,weakImports:new Set,runtimePaths:[]};t<n;){var d=r(),p=o();if(1===d)c.memorySize=o(),c.memoryAlign=o(),c.tableSize=o(),c.tableAlign=o();else if(2===d)c.neededDynlibs=s();else if(3===d)for(var m=o();m--;){var f=i();256&o()&&c.tlsExports.add(f)}else if(4===d)for(m=o();m--;)i(),f=i(),1==(3&o())&&c.weakImports.add(f);else 5===d?c.runtimePaths=s():t+=p}return c},"getDylinkMetadata");function getValue(e,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":case"i8":return HEAP8[e];case"i16":return LE_HEAP_LOAD_I16(2*(e>>1));case"i32":return LE_HEAP_LOAD_I32(4*(e>>2));case"i64":return LE_HEAP_LOAD_I64(8*(e>>3));case"float":return LE_HEAP_LOAD_F32(4*(e>>2));case"double":return LE_HEAP_LOAD_F64(8*(e>>3));case"*":return LE_HEAP_LOAD_U32(4*(e>>2));default:abort(`invalid type for getValue: ${t}`)}}__name(getValue,"getValue");var newDSO=__name((e,t,n)=>{var r={refcount:1/0,name:e,exports:n,global:!0};return LDSO.loadedLibsByName[e]=r,null!=t&&(LDSO.loadedLibsByHandle[t]=r),r},"newDSO"),LDSO={loadedLibsByName:{},loadedLibsByHandle:{},init(){newDSO("__main__",0,wasmImports)}},___heap_base=78240,alignMemory=__name((e,t)=>Math.ceil(e/t)*t,"alignMemory"),getMemory=__name(e=>{if(runtimeInitialized)return _calloc(e,1);var t=___heap_base,n=t+alignMemory(e,16);return ___heap_base=n,GOT.__heap_base.value=n,t},"getMemory"),isInternalSym=__name(e=>["__cpp_exception","__c_longjmp","__wasm_apply_data_relocs","__dso_handle","__tls_size","__tls_align","__set_stack_limits","_emscripten_tls_init","__wasm_init_tls","__wasm_call_ctors","__start_em_asm","__stop_em_asm","__start_em_js","__stop_em_js"].includes(e)||e.startsWith("__em_js__"),"isInternalSym"),uleb128EncodeWithLen=__name(e=>{const t=e.length;return[t%128|128,t>>7,...e]},"uleb128EncodeWithLen"),wasmTypeCodes={i:127,p:127,j:126,f:125,d:124,e:111},generateTypePack=__name(e=>uleb128EncodeWithLen(Array.from(e,e=>wasmTypeCodes[e])),"generateTypePack"),convertJsFunctionToWasm=__name((e,t)=>{var n=Uint8Array.of(0,97,115,109,1,0,0,0,1,...uleb128EncodeWithLen([1,96,...generateTypePack(t.slice(1)),...generateTypePack("v"===t[0]?"":t[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),r=new WebAssembly.Module(n);return new WebAssembly.Instance(r,{e:{f:e}}).exports.f},"convertJsFunctionToWasm"),wasmTableMirror=[],wasmTable=new WebAssembly.Table({initial:31,element:"anyfunc"}),getWasmTableEntry=__name(e=>{var t=wasmTableMirror[e];return t||(wasmTableMirror[e]=t=wasmTable.get(e)),t},"getWasmTableEntry"),updateTableMap=__name((e,t)=>{if(functionsInTableMap)for(var n=e;n<e+t;n++){var r=getWasmTableEntry(n);r&&functionsInTableMap.set(r,n)}},"updateTableMap"),functionsInTableMap,getFunctionAddress=__name(e=>(functionsInTableMap||(functionsInTableMap=new WeakMap,updateTableMap(0,wasmTable.length)),functionsInTableMap.get(e)||0),"getFunctionAddress"),freeTableIndexes=[],getEmptyTableSlot=__name(()=>freeTableIndexes.length?freeTableIndexes.pop():wasmTable.grow(1),"getEmptyTableSlot"),setWasmTableEntry=__name((e,t)=>{wasmTable.set(e,t),wasmTableMirror[e]=wasmTable.get(e)},"setWasmTableEntry"),addFunction=__name((e,t)=>{var n=getFunctionAddress(e);if(n)return n;var r=getEmptyTableSlot();try{setWasmTableEntry(r,e)}catch(n){if(!(n instanceof TypeError))throw n;var o=convertJsFunctionToWasm(e,t);setWasmTableEntry(r,o)}return functionsInTableMap.set(e,r),r},"addFunction"),updateGOT=__name((e,t)=>{for(var n in e)if(!isInternalSym(n)){var r=e[n];GOT[n]||=new WebAssembly.Global({value:"i32",mutable:!0}),(t||0==GOT[n].value)&&("function"==typeof r?GOT[n].value=addFunction(r):"number"==typeof r?GOT[n].value=r:err(`unhandled export type for '${n}': ${typeof r}`))}},"updateGOT"),relocateExports=__name((e,t,n)=>{var r={};for(var o in e){var i=e[o];"object"==typeof i&&(i=i.value),"number"==typeof i&&(i+=t),r[o]=i}return updateGOT(r,n),r},"relocateExports"),isSymbolDefined=__name(e=>{var t=wasmImports[e];return!(!t||t.stub)},"isSymbolDefined"),dynCall=__name((e,t,n=[],r=!1)=>{var o=getWasmTableEntry(t)(...n);return __name(function(e){return e},"convert"),o},"dynCall"),stackSave=__name(()=>_emscripten_stack_get_current(),"stackSave"),stackRestore=__name(e=>__emscripten_stack_restore(e),"stackRestore"),createInvokeFunction=__name(e=>(t,...n)=>{var r=stackSave();try{return dynCall(e,t,n)}catch(t){if(stackRestore(r),t!==t+0)throw t;if(_setThrew(1,0),"j"==e[0])return 0n}},"createInvokeFunction"),resolveGlobalSymbol=__name((e,t=!1)=>{var n;return isSymbolDefined(e)?n=wasmImports[e]:e.startsWith("invoke_")&&(n=wasmImports[e]=createInvokeFunction(e.split("_")[1])),{sym:n,name:e}},"resolveGlobalSymbol"),onPostCtors=[],addOnPostCtor=__name(e=>onPostCtors.push(e),"addOnPostCtor"),UTF8ToString=__name((e,t,n)=>e?UTF8ArrayToString(HEAPU8,e,t,n):"","UTF8ToString"),loadWebAssemblyModule=__name((binary,flags,libName,localScope,handle)=>{var metadata=getDylinkMetadata(binary);function loadModule(){var memAlign=Math.pow(2,metadata.memoryAlign),memoryBase=metadata.memorySize?alignMemory(getMemory(metadata.memorySize+memAlign),memAlign):0,tableBase=metadata.tableSize?wasmTable.length:0,moduleExports;function resolveSymbol(e){var t=resolveGlobalSymbol(e).sym;return!t&&localScope&&(t=localScope[e]),t||(t=moduleExports[e]),t}handle&&(HEAP8[handle+8]=1,LE_HEAP_STORE_U32(4*(handle+12>>2),memoryBase),LE_HEAP_STORE_I32(4*(handle+16>>2),metadata.memorySize),LE_HEAP_STORE_U32(4*(handle+20>>2),tableBase),LE_HEAP_STORE_I32(4*(handle+24>>2),metadata.tableSize)),metadata.tableSize&&wasmTable.grow(metadata.tableSize),__name(resolveSymbol,"resolveSymbol");var proxyHandler={get(e,t){switch(t){case"__memory_base":return memoryBase;case"__table_base":return tableBase}var n;return t in wasmImports&&!wasmImports[t].stub?wasmImports[t]:(t in e||(e[t]=(...e)=>(n||=resolveSymbol(t),n(...e))),e[t])}},proxy=new Proxy({},proxyHandler);currentModuleWeakSymbols=metadata.weakImports;var info={"GOT.mem":new Proxy({},GOTHandler),"GOT.func":new Proxy({},GOTHandler),env:proxy,wasi_snapshot_preview1:proxy};function postInstantiation(module,instance){function addEmAsm(addr,body){for(var args=[],arity=0;arity<16&&-1!=body.indexOf("$"+arity);arity++)args.push("$"+arity);args=args.join(",");var func=`(${args}) => { ${body} };`;ASM_CONSTS[start]=eval(func)}if(updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),flags.allowUndefined||reportUndefinedSymbols(),__name(addEmAsm,"addEmAsm"),"__start_em_asm"in moduleExports)for(var start=moduleExports.__start_em_asm,stop=moduleExports.__stop_em_asm;start<stop;){var jsString=UTF8ToString(start);addEmAsm(start,jsString),start=HEAPU8.indexOf(0,start)+1}function addEmJs(name,cSig,body){var jsArgs=[];if(cSig=cSig.slice(1,-1),"void"!=cSig)for(var i in cSig=cSig.split(","),cSig){var jsArg=cSig[i].split(" ").pop();jsArgs.push(jsArg.replace("*",""))}var func=`(${jsArgs}) => ${body};`;moduleExports[name]=eval(func)}for(var name in __name(addEmJs,"addEmJs"),moduleExports)if(name.startsWith("__em_js__")){var start=moduleExports[name],jsString=UTF8ToString(start),parts=jsString.split("<::>");addEmJs(name.replace("__em_js__",""),parts[0],parts[1]),delete moduleExports[name]}var applyRelocs=moduleExports.__wasm_apply_data_relocs;applyRelocs&&(runtimeInitialized?applyRelocs():__RELOC_FUNCS__.push(applyRelocs));var init=moduleExports.__wasm_call_ctors;return init&&(runtimeInitialized?init():addOnPostCtor(init)),moduleExports}if(__name(postInstantiation,"postInstantiation"),flags.loadAsync)return(async()=>{var e;return binary instanceof WebAssembly.Module?e=new WebAssembly.Instance(binary,info):({module:binary,instance:e}=await WebAssembly.instantiate(binary,info)),postInstantiation(binary,e)})();var module=binary instanceof WebAssembly.Module?binary:new WebAssembly.Module(binary),instance=new WebAssembly.Instance(module,info);return postInstantiation(module,instance)}return __name(loadModule,"loadModule"),flags={...flags,rpath:{parentLibPath:libName,paths:metadata.runtimePaths}},flags.loadAsync?metadata.neededDynlibs.reduce((e,t)=>e.then(()=>loadDynamicLibrary(t,flags,localScope)),Promise.resolve()).then(loadModule):(metadata.neededDynlibs.forEach(e=>loadDynamicLibrary(e,flags,localScope)),loadModule())},"loadWebAssemblyModule"),mergeLibSymbols=__name((e,t)=>{for(var[n,r]of Object.entries(e)){const e=__name(e=>{isSymbolDefined(e)||(wasmImports[e]=r)},"setImport");e(n);const t="__main_argc_argv";"main"==n&&e(t),n==t&&e("main")}},"mergeLibSymbols"),asyncLoad=__name(async e=>{var t=await readAsync(e);return new Uint8Array(t)},"asyncLoad");function loadDynamicLibrary(e,t={global:!0,nodelete:!0},n,r){var o=LDSO.loadedLibsByName[e];if(o)return t.global?o.global||(o.global=!0,mergeLibSymbols(o.exports,e)):n&&Object.assign(n,o.exports),t.nodelete&&o.refcount!==1/0&&(o.refcount=1/0),o.refcount++,r&&(LDSO.loadedLibsByHandle[r]=o),!t.loadAsync||Promise.resolve(!0);function i(){if(r){var n=LE_HEAP_LOAD_U32(4*(r+28>>2)),o=LE_HEAP_LOAD_U32(4*(r+32>>2));if(n&&o){var i=HEAP8.slice(n,n+o);return t.loadAsync?Promise.resolve(i):i}}var s=locateFile(e);if(t.loadAsync)return asyncLoad(s);if(!readBinary)throw new Error(`${s}: file not found, and synchronous loading of external files is not available`);return readBinary(s)}function s(){return t.loadAsync?i().then(o=>loadWebAssemblyModule(o,t,e,n,r)):loadWebAssemblyModule(i(),t,e,n,r)}function a(t){o.global?mergeLibSymbols(t,e):n&&Object.assign(n,t),o.exports=t}return(o=newDSO(e,r,"loading")).refcount=t.nodelete?1/0:1,o.global=t.global,__name(i,"loadLibData"),__name(s,"getExports"),__name(a,"moduleLoaded"),t.loadAsync?s().then(e=>(a(e),!0)):(a(s()),!0)}__name(loadDynamicLibrary,"loadDynamicLibrary");var reportUndefinedSymbols=__name(()=>{for(var[e,t]of Object.entries(GOT))if(0==t.value){var n=resolveGlobalSymbol(e,!0).sym;if(!n&&!t.required)continue;if("function"==typeof n)t.value=addFunction(n,n.sig);else{if("number"!=typeof n)throw new Error(`bad export type for '${e}': ${typeof n}`);t.value=n}}},"reportUndefinedSymbols"),runDependencies=0,dependenciesFulfilled=null,removeRunDependency=__name(e=>{if(runDependencies--,Module.monitorRunDependencies?.(runDependencies),0==runDependencies&&dependenciesFulfilled){var t=dependenciesFulfilled;dependenciesFulfilled=null,t()}},"removeRunDependency"),addRunDependency=__name(e=>{runDependencies++,Module.monitorRunDependencies?.(runDependencies)},"addRunDependency"),loadDylibs=__name(async()=>{if(dynamicLibraries.length){for(var e of(addRunDependency("loadDylibs"),dynamicLibraries))await loadDynamicLibrary(e,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0});reportUndefinedSymbols(),removeRunDependency("loadDylibs")}else reportUndefinedSymbols()},"loadDylibs"),noExitRuntime=!0;function setValue(e,t,n="i8"){switch(n.endsWith("*")&&(n="*"),n){case"i1":case"i8":HEAP8[e]=t;break;case"i16":LE_HEAP_STORE_I16(2*(e>>1),t);break;case"i32":LE_HEAP_STORE_I32(4*(e>>2),t);break;case"i64":LE_HEAP_STORE_I64(8*(e>>3),BigInt(t));break;case"float":LE_HEAP_STORE_F32(4*(e>>2),t);break;case"double":LE_HEAP_STORE_F64(8*(e>>3),t);break;case"*":LE_HEAP_STORE_U32(4*(e>>2),t);break;default:abort(`invalid type for setValue: ${n}`)}}__name(setValue,"setValue");var ___memory_base=new WebAssembly.Global({value:"i32",mutable:!1},1024),___stack_high=78240,___stack_low=12704,___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},78240),___table_base=new WebAssembly.Global({value:"i32",mutable:!1},1),__abort_js=__name(()=>abort(""),"__abort_js");__abort_js.sig="v";var getHeapMax=__name(()=>2147483648,"getHeapMax"),growMemory=__name(e=>{var t=(e-wasmMemory.buffer.byteLength+65535)/65536|0;try{return wasmMemory.grow(t),updateMemoryViews(),1}catch(e){}},"growMemory"),_emscripten_resize_heap=__name(e=>{var t=HEAPU8.length;e>>>=0;var n=getHeapMax();if(e>n)return!1;for(var r=1;r<=4;r*=2){var o=t*(1+.2/r);o=Math.min(o,e+100663296);var i=Math.min(n,alignMemory(Math.max(e,o),65536));if(growMemory(i))return!0}return!1},"_emscripten_resize_heap");_emscripten_resize_heap.sig="ip";var _fd_close=__name(e=>52,"_fd_close");_fd_close.sig="ii";var INT53_MAX=9007199254740992,INT53_MIN=-9007199254740992,bigintToI53Checked=__name(e=>e<INT53_MIN||e>INT53_MAX?NaN:Number(e),"bigintToI53Checked");function _fd_seek(e,t,n,r){return t=bigintToI53Checked(t),70}__name(_fd_seek,"_fd_seek"),_fd_seek.sig="iijip";var printCharBuffers=[null,[],[]],printChar=__name((e,t)=>{var n=printCharBuffers[e];0===t||10===t?((1===e?out:err)(UTF8ArrayToString(n)),n.length=0):n.push(t)},"printChar"),_fd_write=__name((e,t,n,r)=>{for(var o=0,i=0;i<n;i++){var s=LE_HEAP_LOAD_U32(4*(t>>2)),a=LE_HEAP_LOAD_U32(4*(t+4>>2));t+=8;for(var _=0;_<a;_++)printChar(e,HEAPU8[s+_]);o+=a}return LE_HEAP_STORE_U32(4*(r>>2),o),0},"_fd_write");function _tree_sitter_log_callback(e,t){if(Module.currentLogCallback){const n=UTF8ToString(t);Module.currentLogCallback(n,0!==e)}}function _tree_sitter_parse_callback(e,t,n,r,o){const i=Module.currentParseCallback(t,{row:n,column:r});"string"==typeof i?(setValue(o,i.length,"i32"),stringToUTF16(i,e,10240)):setValue(o,0,"i32")}function _tree_sitter_progress_callback(e,t){return!!Module.currentProgressCallback&&Module.currentProgressCallback({currentOffset:e,hasError:t})}function _tree_sitter_query_progress_callback(e){return!!Module.currentQueryProgressCallback&&Module.currentQueryProgressCallback({currentOffset:e})}_fd_write.sig="iippp",__name(_tree_sitter_log_callback,"_tree_sitter_log_callback"),__name(_tree_sitter_parse_callback,"_tree_sitter_parse_callback"),__name(_tree_sitter_progress_callback,"_tree_sitter_progress_callback"),__name(_tree_sitter_query_progress_callback,"_tree_sitter_query_progress_callback");var runtimeKeepaliveCounter=0,keepRuntimeAlive=__name(()=>noExitRuntime||runtimeKeepaliveCounter>0,"keepRuntimeAlive"),_proc_exit=__name(e=>{EXITSTATUS=e,keepRuntimeAlive()||(Module.onExit?.(e),ABORT=!0),quit_(e,new ExitStatus(e))},"_proc_exit");_proc_exit.sig="vi";var exitJS=__name((e,t)=>{EXITSTATUS=e,_proc_exit(e)},"exitJS"),handleException=__name(e=>{if(e instanceof ExitStatus||"unwind"==e)return EXITSTATUS;quit_(1,e)},"handleException"),lengthBytesUTF8=__name(e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r<=127?t++:r<=2047?t+=2:r>=55296&&r<=57343?(t+=4,++n):t+=3}return t},"lengthBytesUTF8"),stringToUTF8Array=__name((e,t,n,r)=>{if(!(r>0))return 0;for(var o=n,i=n+r-1,s=0;s<e.length;++s){var a=e.codePointAt(s);if(a<=127){if(n>=i)break;t[n++]=a}else if(a<=2047){if(n+1>=i)break;t[n++]=192|a>>6,t[n++]=128|63&a}else if(a<=65535){if(n+2>=i)break;t[n++]=224|a>>12,t[n++]=128|a>>6&63,t[n++]=128|63&a}else{if(n+3>=i)break;t[n++]=240|a>>18,t[n++]=128|a>>12&63,t[n++]=128|a>>6&63,t[n++]=128|63&a,s++}}return t[n]=0,n-o},"stringToUTF8Array"),stringToUTF8=__name((e,t,n)=>stringToUTF8Array(e,HEAPU8,t,n),"stringToUTF8"),stackAlloc=__name(e=>__emscripten_stack_alloc(e),"stackAlloc"),stringToUTF8OnStack=__name(e=>{var t=lengthBytesUTF8(e)+1,n=stackAlloc(t);return stringToUTF8(e,n,t),n},"stringToUTF8OnStack"),AsciiToString=__name(e=>{for(var t="";;){var n=HEAPU8[e++];if(!n)return t;t+=String.fromCharCode(n)}},"AsciiToString"),stringToUTF16=__name((e,t,n)=>{if(n??=2147483647,n<2)return 0;for(var r=t,o=(n-=2)<2*e.length?n/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);LE_HEAP_STORE_I16(2*(t>>1),s),t+=2}return LE_HEAP_STORE_I16(2*(t>>1),0),t-r},"stringToUTF16");function LE_HEAP_UPDATE(){HEAPU16.unsigned=e=>65535&e,HEAPU32.unsigned=e=>e>>>0}if(LE_ATOMICS_NATIVE_BYTE_ORDER=1===new Int8Array(new Int16Array([1]).buffer)[0]?[e=>e,e=>e,void 0,e=>e]:[e=>e,e=>((65280&e)<<8|(255&e)<<24)>>16,void 0,e=>e>>24&255|e>>8&65280|(65280&e)<<8|(255&e)<<24],__name(LE_HEAP_UPDATE,"LE_HEAP_UPDATE"),initMemory(),Module.noExitRuntime&&(noExitRuntime=Module.noExitRuntime),Module.print&&(out=Module.print),Module.printErr&&(err=Module.printErr),Module.dynamicLibraries&&(dynamicLibraries=Module.dynamicLibraries),Module.wasmBinary&&(wasmBinary=Module.wasmBinary),Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram),Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.shift()();Module.setValue=setValue,Module.getValue=getValue,Module.UTF8ToString=UTF8ToString,Module.stringToUTF8=stringToUTF8,Module.lengthBytesUTF8=lengthBytesUTF8,Module.AsciiToString=AsciiToString,Module.stringToUTF16=stringToUTF16,Module.loadWebAssemblyModule=loadWebAssemblyModule,Module.LE_HEAP_STORE_I64=LE_HEAP_STORE_I64;var ASM_CONSTS={},_malloc,_calloc,_realloc,_free,_ts_range_edit,_memcmp,_ts_language_symbol_count,_ts_language_state_count,_ts_language_abi_version,_ts_language_name,_ts_language_field_count,_ts_language_next_state,_ts_language_symbol_name,_ts_language_symbol_for_name,_strncmp,_ts_language_symbol_type,_ts_language_field_name_for_id,_ts_lookahead_iterator_new,_ts_lookahead_iterator_delete,_ts_lookahead_iterator_reset_state,_ts_lookahead_iterator_reset,_ts_lookahead_iterator_next,_ts_lookahead_iterator_current_symbol,_ts_point_edit,_ts_parser_delete,_ts_parser_reset,_ts_parser_set_language,_ts_parser_set_included_ranges,_ts_query_new,_ts_query_delete,_iswspace,_iswalnum,_ts_query_pattern_count,_ts_query_capture_count,_ts_query_string_count,_ts_query_capture_name_for_id,_ts_query_capture_quantifier_for_id,_ts_query_string_value_for_id,_ts_query_predicates_for_pattern,_ts_query_start_byte_for_pattern,_ts_query_end_byte_for_pattern,_ts_query_is_pattern_rooted,_ts_query_is_pattern_non_local,_ts_query_is_pattern_guaranteed_at_step,_ts_query_disable_capture,_ts_query_disable_pattern,_ts_tree_copy,_ts_tree_delete,_ts_init,_ts_parser_new_wasm,_ts_parser_enable_logger_wasm,_ts_parser_parse_wasm,_ts_parser_included_ranges_wasm,_ts_language_type_is_named_wasm,_ts_language_type_is_visible_wasm,_ts_language_metadata_wasm,_ts_language_supertypes_wasm,_ts_language_subtypes_wasm,_ts_tree_root_node_wasm,_ts_tree_root_node_with_offset_wasm,_ts_tree_edit_wasm,_ts_tree_included_ranges_wasm,_ts_tree_get_changed_ranges_wasm,_ts_tree_cursor_new_wasm,_ts_tree_cursor_copy_wasm,_ts_tree_cursor_delete_wasm,_ts_tree_cursor_reset_wasm,_ts_tree_cursor_reset_to_wasm,_ts_tree_cursor_goto_first_child_wasm,_ts_tree_cursor_goto_last_child_wasm,_ts_tree_cursor_goto_first_child_for_index_wasm,_ts_tree_cursor_goto_first_child_for_position_wasm,_ts_tree_cursor_goto_next_sibling_wasm,_ts_tree_cursor_goto_previous_sibling_wasm,_ts_tree_cursor_goto_descendant_wasm,_ts_tree_cursor_goto_parent_wasm,_ts_tree_cursor_current_node_type_id_wasm,_ts_tree_cursor_current_node_state_id_wasm,_ts_tree_cursor_current_node_is_named_wasm,_ts_tree_cursor_current_node_is_missing_wasm,_ts_tree_cursor_current_node_id_wasm,_ts_tree_cursor_start_position_wasm,_ts_tree_cursor_end_position_wasm,_ts_tree_cursor_start_index_wasm,_ts_tree_cursor_end_index_wasm,_ts_tree_cursor_current_field_id_wasm,_ts_tree_cursor_current_depth_wasm,_ts_tree_cursor_current_descendant_index_wasm,_ts_tree_cursor_current_node_wasm,_ts_node_symbol_wasm,_ts_node_field_name_for_child_wasm,_ts_node_field_name_for_named_child_wasm,_ts_node_children_by_field_id_wasm,_ts_node_first_child_for_byte_wasm,_ts_node_first_named_child_for_byte_wasm,_ts_node_grammar_symbol_wasm,_ts_node_child_count_wasm,_ts_node_named_child_count_wasm,_ts_node_child_wasm,_ts_node_named_child_wasm,_ts_node_child_by_field_id_wasm,_ts_node_next_sibling_wasm,_ts_node_prev_sibling_wasm,_ts_node_next_named_sibling_wasm,_ts_node_prev_named_sibling_wasm,_ts_node_descendant_count_wasm,_ts_node_parent_wasm,_ts_node_child_with_descendant_wasm,_ts_node_descendant_for_index_wasm,_ts_node_named_descendant_for_index_wasm,_ts_node_descendant_for_position_wasm,_ts_node_named_descendant_for_position_wasm,_ts_node_start_point_wasm,_ts_node_end_point_wasm,_ts_node_start_index_wasm,_ts_node_end_index_wasm,_ts_node_to_string_wasm,_ts_node_children_wasm,_ts_node_named_children_wasm,_ts_node_descendants_of_type_wasm,_ts_node_is_named_wasm,_ts_node_has_changes_wasm,_ts_node_has_error_wasm,_ts_node_is_error_wasm,_ts_node_is_missing_wasm,_ts_node_is_extra_wasm,_ts_node_parse_state_wasm,_ts_node_next_parse_state_wasm,_ts_query_matches_wasm,_ts_query_captures_wasm,_memset,_memcpy,_memmove,_iswalpha,_iswblank,_iswdigit,_iswlower,_iswupper,_iswxdigit,_memchr,_strlen,_strcmp,_strncat,_strncpy,_towlower,_towupper,_setThrew,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,___wasm_apply_data_relocs;function assignWasmExports(e){Module._malloc=_malloc=e.malloc,Module._calloc=_calloc=e.calloc,Module._realloc=_realloc=e.realloc,Module._free=_free=e.free,Module._ts_range_edit=_ts_range_edit=e.ts_range_edit,Module._memcmp=_memcmp=e.memcmp,Module._ts_language_symbol_count=_ts_language_symbol_count=e.ts_language_symbol_count,Module._ts_language_state_count=_ts_language_state_count=e.ts_language_state_count,Module._ts_language_abi_version=_ts_language_abi_version=e.ts_language_abi_version,Module._ts_language_name=_ts_language_name=e.ts_language_name,Module._ts_language_field_count=_ts_language_field_count=e.ts_language_field_count,Module._ts_language_next_state=_ts_language_next_state=e.ts_language_next_state,Module._ts_language_symbol_name=_ts_language_symbol_name=e.ts_language_symbol_name,Module._ts_language_symbol_for_name=_ts_language_symbol_for_name=e.ts_language_symbol_for_name,Module._strncmp=_strncmp=e.strncmp,Module._ts_language_symbol_type=_ts_language_symbol_type=e.ts_language_symbol_type,Module._ts_language_field_name_for_id=_ts_language_field_name_for_id=e.ts_language_field_name_for_id,Module._ts_lookahead_iterator_new=_ts_lookahead_iterator_new=e.ts_lookahead_iterator_new,Module._ts_lookahead_iterator_delete=_ts_lookahead_iterator_delete=e.ts_lookahead_iterator_delete,Module._ts_lookahead_iterator_reset_state=_ts_lookahead_iterator_reset_state=e.ts_lookahead_iterator_reset_state,Module._ts_lookahead_iterator_reset=_ts_lookahead_iterator_reset=e.ts_lookahead_iterator_reset,Module._ts_lookahead_iterator_next=_ts_lookahead_iterator_next=e.ts_lookahead_iterator_next,Module._ts_lookahead_iterator_current_symbol=_ts_lookahead_iterator_current_symbol=e.ts_lookahead_iterator_current_symbol,Module._ts_point_edit=_ts_point_edit=e.ts_point_edit,Module._ts_parser_delete=_ts_parser_delete=e.ts_parser_delete,Module._ts_parser_reset=_ts_parser_reset=e.ts_parser_reset,Module._ts_parser_set_language=_ts_parser_set_language=e.ts_parser_set_language,Module._ts_parser_set_included_ranges=_ts_parser_set_included_ranges=e.ts_parser_set_included_ranges,Module._ts_query_new=_ts_query_new=e.ts_query_new,Module._ts_query_delete=_ts_query_delete=e.ts_query_delete,Module._iswspace=_iswspace=e.iswspace,Module._iswalnum=_iswalnum=e.iswalnum,Module._ts_query_pattern_count=_ts_query_pattern_count=e.ts_query_pattern_count,Module._ts_query_capture_count=_ts_query_capture_count=e.ts_query_capture_count,Module._ts_query_string_count=_ts_query_string_count=e.ts_query_string_count,Module._ts_query_capture_name_for_id=_ts_query_capture_name_for_id=e.ts_query_capture_name_for_id,Module._ts_query_capture_quantifier_for_id=_ts_query_capture_quantifier_for_id=e.ts_query_capture_quantifier_for_id,Module._ts_query_string_value_for_id=_ts_query_string_value_for_id=e.ts_query_string_value_for_id,Module._ts_query_predicates_for_pattern=_ts_query_predicates_for_pattern=e.ts_query_predicates_for_pattern,Module._ts_query_start_byte_for_pattern=_ts_query_start_byte_for_pattern=e.ts_query_start_byte_for_pattern,Module._ts_query_end_byte_for_pattern=_ts_query_end_byte_for_pattern=e.ts_query_end_byte_for_pattern,Module._ts_query_is_pattern_rooted=_ts_query_is_pattern_rooted=e.ts_query_is_pattern_rooted,Module._ts_query_is_pattern_non_local=_ts_query_is_pattern_non_local=e.ts_query_is_pattern_non_local,Module._ts_query_is_pattern_guaranteed_at_step=_ts_query_is_pattern_guaranteed_at_step=e.ts_query_is_pattern_guaranteed_at_step,Module._ts_query_disable_capture=_ts_query_disable_capture=e.ts_query_disable_capture,Module._ts_query_disable_pattern=_ts_query_disable_pattern=e.ts_query_disable_pattern,Module._ts_tree_copy=_ts_tree_copy=e.ts_tree_copy,Module._ts_tree_delete=_ts_tree_delete=e.ts_tree_delete,Module._ts_init=_ts_init=e.ts_init,Module._ts_parser_new_wasm=_ts_parser_new_wasm=e.ts_parser_new_wasm,Module._ts_parser_enable_logger_wasm=_ts_parser_enable_logger_wasm=e.ts_parser_enable_logger_wasm,Module._ts_parser_parse_wasm=_ts_parser_parse_wasm=e.ts_parser_parse_wasm,Module._ts_parser_included_ranges_wasm=_ts_parser_included_ranges_wasm=e.ts_parser_included_ranges_wasm,Module._ts_language_type_is_named_wasm=_ts_language_type_is_named_wasm=e.ts_language_type_is_named_wasm,Module._ts_language_type_is_visible_wasm=_ts_language_type_is_visible_wasm=e.ts_language_type_is_visible_wasm,Module._ts_language_metadata_wasm=_ts_language_metadata_wasm=e.ts_language_metadata_wasm,Module._ts_language_supertypes_wasm=_ts_language_supertypes_wasm=e.ts_language_supertypes_wasm,Module._ts_language_subtypes_wasm=_ts_language_subtypes_wasm=e.ts_language_subtypes_wasm,Module._ts_tree_root_node_wasm=_ts_tree_root_node_wasm=e.ts_tree_root_node_wasm,Module._ts_tree_root_node_with_offset_wasm=_ts_tree_root_node_with_offset_wasm=e.ts_tree_root_node_with_offset_wasm,Module._ts_tree_edit_wasm=_ts_tree_edit_wasm=e.ts_tree_edit_wasm,Module._ts_tree_included_ranges_wasm=_ts_tree_included_ranges_wasm=e.ts_tree_included_ranges_wasm,Module._ts_tree_get_changed_ranges_wasm=_ts_tree_get_changed_ranges_wasm=e.ts_tree_get_changed_ranges_wasm,Module._ts_tree_cursor_new_wasm=_ts_tree_cursor_new_wasm=e.ts_tree_cursor_new_wasm,Module._ts_tree_cursor_copy_wasm=_ts_tree_cursor_copy_wasm=e.ts_tree_cursor_copy_wasm,Module._ts_tree_cursor_delete_wasm=_ts_tree_cursor_delete_wasm=e.ts_tree_cursor_delete_wasm,Module._ts_tree_cursor_reset_wasm=_ts_tree_cursor_reset_wasm=e.ts_tree_cursor_reset_wasm,Module._ts_tree_cursor_reset_to_wasm=_ts_tree_cursor_reset_to_wasm=e.ts_tree_cursor_reset_to_wasm,Module._ts_tree_cursor_goto_first_child_wasm=_ts_tree_cursor_goto_first_child_wasm=e.ts_tree_cursor_goto_first_child_wasm,Module._ts_tree_cursor_goto_last_child_wasm=_ts_tree_cursor_goto_last_child_wasm=e.ts_tree_cursor_goto_last_child_wasm,Module._ts_tree_cursor_goto_first_child_for_index_wasm=_ts_tree_cursor_goto_first_child_for_index_wasm=e.ts_tree_cursor_goto_first_child_for_index_wasm,Module._ts_tree_cursor_goto_first_child_for_position_wasm=_ts_tree_cursor_goto_first_child_for_position_wasm=e.ts_tree_cursor_goto_first_child_for_position_wasm,Module._ts_tree_cursor_goto_next_sibling_wasm=_ts_tree_cursor_goto_next_sibling_wasm=e.ts_tree_cursor_goto_next_sibling_wasm,Module._ts_tree_cursor_goto_previous_sibling_wasm=_ts_tree_cursor_goto_previous_sibling_wasm=e.ts_tree_cursor_goto_previous_sibling_wasm,Module._ts_tree_cursor_goto_descendant_wasm=_ts_tree_cursor_goto_descendant_wasm=e.ts_tree_cursor_goto_descendant_wasm,Module._ts_tree_cursor_goto_parent_wasm=_ts_tree_cursor_goto_parent_wasm=e.ts_tree_cursor_goto_parent_wasm,Module._ts_tree_cursor_current_node_type_id_wasm=_ts_tree_cursor_current_node_type_id_wasm=e.ts_tree_cursor_current_node_type_id_wasm,Module._ts_tree_cursor_current_node_state_id_wasm=_ts_tree_cursor_current_node_state_id_wasm=e.ts_tree_cursor_current_node_state_id_wasm,Module._ts_tree_cursor_current_node_is_named_wasm=_ts_tree_cursor_current_node_is_named_wasm=e.ts_tree_cursor_current_node_is_named_wasm,Module._ts_tree_cursor_current_node_is_missing_wasm=_ts_tree_cursor_current_node_is_missing_wasm=e.ts_tree_cursor_current_node_is_missing_wasm,Module._ts_tree_cursor_current_node_id_wasm=_ts_tree_cursor_current_node_id_wasm=e.ts_tree_cursor_current_node_id_wasm,Module._ts_tree_cursor_start_position_wasm=_ts_tree_cursor_start_position_wasm=e.ts_tree_cursor_start_position_wasm,Module._ts_tree_cursor_end_position_wasm=_ts_tree_cursor_end_position_wasm=e.ts_tree_cursor_end_position_wasm,Module._ts_tree_cursor_start_index_wasm=_ts_tree_cursor_start_index_wasm=e.ts_tree_cursor_start_index_wasm,Module._ts_tree_cursor_end_index_wasm=_ts_tree_cursor_end_index_wasm=e.ts_tree_cursor_end_index_wasm,Module._ts_tree_cursor_current_field_id_wasm=_ts_tree_cursor_current_field_id_wasm=e.ts_tree_cursor_current_field_id_wasm,Module._ts_tree_cursor_current_depth_wasm=_ts_tree_cursor_current_depth_wasm=e.ts_tree_cursor_current_depth_wasm,Module._ts_tree_cursor_current_descendant_index_wasm=_ts_tree_cursor_current_descendant_index_wasm=e.ts_tree_cursor_current_descendant_index_wasm,Module._ts_tree_cursor_current_node_wasm=_ts_tree_cursor_current_node_wasm=e.ts_tree_cursor_current_node_wasm,Module._ts_node_symbol_wasm=_ts_node_symbol_wasm=e.ts_node_symbol_wasm,Module._ts_node_field_name_for_child_wasm=_ts_node_field_name_for_child_wasm=e.ts_node_field_name_for_child_wasm,Module._ts_node_field_name_for_named_child_wasm=_ts_node_field_name_for_named_child_wasm=e.ts_node_field_name_for_named_child_wasm,Module._ts_node_children_by_field_id_wasm=_ts_node_children_by_field_id_wasm=e.ts_node_children_by_field_id_wasm,Module._ts_node_first_child_for_byte_wasm=_ts_node_first_child_for_byte_wasm=e.ts_node_first_child_for_byte_wasm,Module._ts_node_first_named_child_for_byte_wasm=_ts_node_first_named_child_for_byte_wasm=e.ts_node_first_named_child_for_byte_wasm,Module._ts_node_grammar_symbol_wasm=_ts_node_grammar_symbol_wasm=e.ts_node_grammar_symbol_wasm,Module._ts_node_child_count_wasm=_ts_node_child_count_wasm=e.ts_node_child_count_wasm,Module._ts_node_named_child_count_wasm=_ts_node_named_child_count_wasm=e.ts_node_named_child_count_wasm,Module._ts_node_child_wasm=_ts_node_child_wasm=e.ts_node_child_wasm,Module._ts_node_named_child_wasm=_ts_node_named_child_wasm=e.ts_node_named_child_wasm,Module._ts_node_child_by_field_id_wasm=_ts_node_child_by_field_id_wasm=e.ts_node_child_by_field_id_wasm,Module._ts_node_next_sibling_wasm=_ts_node_next_sibling_wasm=e.ts_node_next_sibling_wasm,Module._ts_node_prev_sibling_wasm=_ts_node_prev_sibling_wasm=e.ts_node_prev_sibling_wasm,Module._ts_node_next_named_sibling_wasm=_ts_node_next_named_sibling_wasm=e.ts_node_next_named_sibling_wasm,Module._ts_node_prev_named_sibling_wasm=_ts_node_prev_named_sibling_wasm=e.ts_node_prev_named_sibling_wasm,Module._ts_node_descendant_count_wasm=_ts_node_descendant_count_wasm=e.ts_node_descendant_count_wasm,Module._ts_node_parent_wasm=_ts_node_parent_wasm=e.ts_node_parent_wasm,Module._ts_node_child_with_descendant_wasm=_ts_node_child_with_descendant_wasm=e.ts_node_child_with_descendant_wasm,Module._ts_node_descendant_for_index_wasm=_ts_node_descendant_for_index_wasm=e.ts_node_descendant_for_index_wasm,Module._ts_node_named_descendant_for_index_wasm=_ts_node_named_descendant_for_index_wasm=e.ts_node_named_descendant_for_index_wasm,Module._ts_node_descendant_for_position_wasm=_ts_node_descendant_for_position_wasm=e.ts_node_descendant_for_position_wasm,Module._ts_node_named_descendant_for_position_wasm=_ts_node_named_descendant_for_position_wasm=e.ts_node_named_descendant_for_position_wasm,Module._ts_node_start_point_wasm=_ts_node_start_point_wasm=e.ts_node_start_point_wasm,Module._ts_node_end_point_wasm=_ts_node_end_point_wasm=e.ts_node_end_point_wasm,Module._ts_node_start_index_wasm=_ts_node_start_index_wasm=e.ts_node_start_index_wasm,Module._ts_node_end_index_wasm=_ts_node_end_index_wasm=e.ts_node_end_index_wasm,Module._ts_node_to_string_wasm=_ts_node_to_string_wasm=e.ts_node_to_string_wasm,Module._ts_node_children_wasm=_ts_node_children_wasm=e.ts_node_children_wasm,Module._ts_node_named_children_wasm=_ts_node_named_children_wasm=e.ts_node_named_children_wasm,Module._ts_node_descendants_of_type_wasm=_ts_node_descendants_of_type_wasm=e.ts_node_descendants_of_type_wasm,Module._ts_node_is_named_wasm=_ts_node_is_named_wasm=e.ts_node_is_named_wasm,Module._ts_node_has_changes_wasm=_ts_node_has_changes_wasm=e.ts_node_has_changes_wasm,Module._ts_node_has_error_wasm=_ts_node_has_error_wasm=e.ts_node_has_error_wasm,Module._ts_node_is_error_wasm=_ts_node_is_error_wasm=e.ts_node_is_error_wasm,Module._ts_node_is_missing_wasm=_ts_node_is_missing_wasm=e.ts_node_is_missing_wasm,Module._ts_node_is_extra_wasm=_ts_node_is_extra_wasm=e.ts_node_is_extra_wasm,Module._ts_node_parse_state_wasm=_ts_node_parse_state_wasm=e.ts_node_parse_state_wasm,Module._ts_node_next_parse_state_wasm=_ts_node_next_parse_state_wasm=e.ts_node_next_parse_state_wasm,Module._ts_query_matches_wasm=_ts_query_matches_wasm=e.ts_query_matches_wasm,Module._ts_query_captures_wasm=_ts_query_captures_wasm=e.ts_query_captures_wasm,Module._memset=_memset=e.memset,Module._memcpy=_memcpy=e.memcpy,Module._memmove=_memmove=e.memmove,Module._iswalpha=_iswalpha=e.iswalpha,Module._iswblank=_iswblank=e.iswblank,Module._iswdigit=_iswdigit=e.iswdigit,Module._iswlower=_iswlower=e.iswlower,Module._iswupper=_iswupper=e.iswupper,Module._iswxdigit=_iswxdigit=e.iswxdigit,Module._memchr=_memchr=e.memchr,Module._strlen=_strlen=e.strlen,Module._strcmp=_strcmp=e.strcmp,Module._strncat=_strncat=e.strncat,Module._strncpy=_strncpy=e.strncpy,Module._towlower=_towlower=e.towlower,Module._towupper=_towupper=e.towupper,_setThrew=e.setThrew,__emscripten_stack_restore=e._emscripten_stack_restore,__emscripten_stack_alloc=e._emscripten_stack_alloc,_emscripten_stack_get_current=e.emscripten_stack_get_current,___wasm_apply_data_relocs=e.__wasm_apply_data_relocs}__name(assignWasmExports,"assignWasmExports");var wasmImports={__heap_base:___heap_base,__indirect_function_table:wasmTable,__memory_base:___memory_base,__stack_high:___stack_high,__stack_low:___stack_low,__stack_pointer:___stack_pointer,__table_base:___table_base,_abort_js:__abort_js,emscripten_resize_heap:_emscripten_resize_heap,fd_close:_fd_close,fd_seek:_fd_seek,fd_write:_fd_write,memory:wasmMemory,tree_sitter_log_callback:_tree_sitter_log_callback,tree_sitter_parse_callback:_tree_sitter_parse_callback,tree_sitter_progress_callback:_tree_sitter_progress_callback,tree_sitter_query_progress_callback:_tree_sitter_query_progress_callback},wasmExports;function callMain(e=[]){var t=resolveGlobalSymbol("main").sym;if(t){e.unshift(thisProgram);var n=e.length,r=stackAlloc(4*(n+1)),o=r;e.forEach(e=>{LE_HEAP_STORE_U32(4*(o>>2),stringToUTF8OnStack(e)),o+=4}),LE_HEAP_STORE_U32(4*(o>>2),0);try{var i=t(n,r);return exitJS(i,!0),i}catch(e){return handleException(e)}}}function run(e=arguments_){function t(){Module.calledRun=!0,ABORT||(initRuntime(),preMain(),readyPromiseResolve?.(Module),Module.onRuntimeInitialized?.(),Module.noInitialRun||callMain(e),postRun())}runDependencies>0?dependenciesFulfilled=run:(preRun(),runDependencies>0?dependenciesFulfilled=run:(__name(t,"doRun"),Module.setStatus?(Module.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>Module.setStatus(""),1),t()},1)):t()))}return __name(callMain,"callMain"),__name(run,"run"),wasmExports=await createWasm(),run(),moduleRtn=runtimeInitialized?Module:new Promise((e,t)=>{readyPromiseResolve=e,readyPromiseReject=t}),moduleRtn}__name(Module2,"Module");var web_tree_sitter_default=Module2,Module3=null,TRANSFER_BUFFER,LANGUAGE_VERSION,MIN_COMPATIBLE_VERSION;async function initializeBinding(e){return Module3??=await web_tree_sitter_default(e)}function checkModule(){return!!Module3}__name(initializeBinding,"initializeBinding"),__name(checkModule,"checkModule");var Parser=class{static{__name(this,"Parser")}0=0;1=0;logCallback=null;language=null;static async init(e){setModule(await initializeBinding(e)),TRANSFER_BUFFER=C._ts_init(),LANGUAGE_VERSION=C.getValue(TRANSFER_BUFFER,"i32"),MIN_COMPATIBLE_VERSION=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}constructor(){this.initialize()}initialize(){if(!checkModule())throw new Error("cannot construct a Parser before calling `init()`");C._ts_parser_new_wasm(),this[0]=C.getValue(TRANSFER_BUFFER,"i32"),this[1]=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}delete(){C._ts_parser_delete(this[0]),C._free(this[1]),this[0]=0,this[1]=0}setLanguage(e){let t;if(e){if(e.constructor!==Language)throw new Error("Argument must be a Language");{t=e[0];const n=C._ts_language_abi_version(t);if(n<MIN_COMPATIBLE_VERSION||LANGUAGE_VERSION<n)throw new Error(`Incompatible language version ${n}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`);this.language=e}}else t=0,this.language=null;return C._ts_parser_set_language(this[0],t),this}parse(e,t,n){if("string"==typeof e)C.currentParseCallback=t=>e.slice(t);else{if("function"!=typeof e)throw new Error("Argument must be a string or a function");C.currentParseCallback=e}C.currentProgressCallback=n?.progressCallback?n.progressCallback:null,this.logCallback?(C.currentLogCallback=this.logCallback,C._ts_parser_enable_logger_wasm(this[0],1)):(C.currentLogCallback=null,C._ts_parser_enable_logger_wasm(this[0],0));let r=0,o=0;if(n?.includedRanges){r=n.includedRanges.length,o=C._calloc(r,SIZE_OF_RANGE);let e=o;for(let t=0;t<r;t++)marshalRange(e,n.includedRanges[t]),e+=SIZE_OF_RANGE}const i=C._ts_parser_parse_wasm(this[0],this[1],t?t[0]:0,o,r);if(!i)return C.currentParseCallback=null,C.currentLogCallback=null,C.currentProgressCallback=null,null;if(!this.language)throw new Error("Parser must have a language to parse");const s=new Tree(INTERNAL,i,this.language,C.currentParseCallback);return C.currentParseCallback=null,C.currentLogCallback=null,C.currentProgressCallback=null,s}reset(){C._ts_parser_reset(this[0])}getIncludedRanges(){C._ts_parser_included_ranges_wasm(this[0]);const e=C.getValue(TRANSFER_BUFFER,"i32"),t=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),n=new Array(e);if(e>0){let r=t;for(let t=0;t<e;t++)n[t]=unmarshalRange(r),r+=SIZE_OF_RANGE;C._free(t)}return n}setLogger(e){if(e){if("function"!=typeof e)throw new Error("Logger callback must be a function");this.logCallback=e}else this.logCallback=null;return this}getLogger(){return this.logCallback}},PREDICATE_STEP_TYPE_CAPTURE=1,PREDICATE_STEP_TYPE_STRING=2,QUERY_WORD_REGEX=/[\w-]+/g,CaptureQuantifier={Zero:0,ZeroOrOne:1,ZeroOrMore:2,One:3,OneOrMore:4},isCaptureStep=__name(e=>"capture"===e.type,"isCaptureStep"),isStringStep=__name(e=>"string"===e.type,"isStringStep"),QueryErrorKind={Syntax:1,NodeName:2,FieldName:3,CaptureName:4,PatternStructure:5},QueryError=class e extends Error{constructor(t,n,r,o){super(e.formatMessage(t,n)),this.kind=t,this.info=n,this.index=r,this.length=o,this.name="QueryError"}static{__name(this,"QueryError")}static formatMessage(e,t){switch(e){case QueryErrorKind.NodeName:return`Bad node name '${t.word}'`;case QueryErrorKind.FieldName:return`Bad field name '${t.word}'`;case QueryErrorKind.CaptureName:return`Bad capture name @${t.word}`;case QueryErrorKind.PatternStructure:return`Bad pattern structure at offset ${t.suffix}`;case QueryErrorKind.Syntax:return`Bad syntax at offset ${t.suffix}`}}};function parseAnyPredicate(e,t,n,r){if(3!==e.length)throw new Error(`Wrong number of arguments to \`#${n}\` predicate. Expected 2, got ${e.length-1}`);if(!isCaptureStep(e[1]))throw new Error(`First argument of \`#${n}\` predicate must be a capture. Got "${e[1].value}"`);const o="eq?"===n||"any-eq?"===n,i=!n.startsWith("any-");if(isCaptureStep(e[2])){const n=e[1].name,s=e[2].name;r[t].push(e=>{const t=[],r=[];for(const o of e)o.name===n&&t.push(o.node),o.name===s&&r.push(o.node);const a=__name((e,t,n)=>n?e.text===t.text:e.text!==t.text,"compare");return i?t.every(e=>r.some(t=>a(e,t,o))):t.some(e=>r.some(t=>a(e,t,o)))})}else{const n=e[1].name,s=e[2].value,a=__name(e=>e.text===s,"matches"),_=__name(e=>e.text!==s,"doesNotMatch");r[t].push(e=>{const t=[];for(const r of e)r.name===n&&t.push(r.node);const r=o?a:_;return i?t.every(r):t.some(r)})}}function parseMatchPredicate(e,t,n,r){if(3!==e.length)throw new Error(`Wrong number of arguments to \`#${n}\` predicate. Expected 2, got ${e.length-1}.`);if("capture"!==e[1].type)throw new Error(`First argument of \`#${n}\` predicate must be a capture. Got "${e[1].value}".`);if("string"!==e[2].type)throw new Error(`Second argument of \`#${n}\` predicate must be a string. Got @${e[2].name}.`);const o="match?"===n||"any-match?"===n,i=!n.startsWith("any-"),s=e[1].name,a=new RegExp(e[2].value);r[t].push(e=>{const t=[];for(const n of e)n.name===s&&t.push(n.node.text);const n=__name((e,t)=>t?a.test(e):!a.test(e),"test");return 0===t.length?!o:i?t.every(e=>n(e,o)):t.some(e=>n(e,o))})}function parseAnyOfPredicate(e,t,n,r){if(e.length<2)throw new Error(`Wrong number of arguments to \`#${n}\` predicate. Expected at least 1. Got ${e.length-1}.`);if("capture"!==e[1].type)throw new Error(`First argument of \`#${n}\` predicate must be a capture. Got "${e[1].value}".`);const o="any-of?"===n,i=e[1].name,s=e.slice(2);if(!s.every(isStringStep))throw new Error(`Arguments to \`#${n}\` predicate must be strings.".`);const a=s.map(e=>e.value);r[t].push(e=>{const t=[];for(const n of e)n.name===i&&t.push(n.node.text);return 0===t.length?!o:t.every(e=>a.includes(e))===o})}function parseIsPredicate(e,t,n,r,o){if(e.length<2||e.length>3)throw new Error(`Wrong number of arguments to \`#${n}\` predicate. Expected 1 or 2. Got ${e.length-1}.`);if(!e.every(isStringStep))throw new Error(`Arguments to \`#${n}\` predicate must be strings.".`);const i="is?"===n?r:o;i[t]||(i[t]={}),i[t][e[1].value]=e[2]?.value??null}function parseSetDirective(e,t,n){if(e.length<2||e.length>3)throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${e.length-1}.`);if(!e.every(isStringStep))throw new Error('Arguments to `#set!` predicate must be strings.".');n[t]||(n[t]={}),n[t][e[1].value]=e[2]?.value??null}function parsePattern(e,t,n,r,o,i,s,a,_,u,l){if(t===PREDICATE_STEP_TYPE_CAPTURE){const e=r[n];i.push({type:"capture",name:e})}else if(t===PREDICATE_STEP_TYPE_STRING)i.push({type:"string",value:o[n]});else if(i.length>0){if("string"!==i[0].type)throw new Error("Predicates must begin with a literal value");const t=i[0].value;switch(t){case"any-not-eq?":case"not-eq?":case"any-eq?":case"eq?":parseAnyPredicate(i,e,t,s);break;case"any-not-match?":case"not-match?":case"any-match?":case"match?":parseMatchPredicate(i,e,t,s);break;case"not-any-of?":case"any-of?":parseAnyOfPredicate(i,e,t,s);break;case"is?":case"is-not?":parseIsPredicate(i,e,t,u,l);break;case"set!":parseSetDirective(i,e,_);break;default:a[e].push({operator:t,operands:i.slice(1)})}i.length=0}}__name(parseAnyPredicate,"parseAnyPredicate"),__name(parseMatchPredicate,"parseMatchPredicate"),__name(parseAnyOfPredicate,"parseAnyOfPredicate"),__name(parseIsPredicate,"parseIsPredicate"),__name(parseSetDirective,"parseSetDirective"),__name(parsePattern,"parsePattern");var Query=class{static{__name(this,"Query")}0=0;exceededMatchLimit;textPredicates;captureNames;captureQuantifiers;predicates;setProperties;assertedProperties;refutedProperties;matchLimit;constructor(e,t){const n=C.lengthBytesUTF8(t),r=C._malloc(n+1);C.stringToUTF8(t,r,n+1);const o=C._ts_query_new(e[0],r,n,TRANSFER_BUFFER,TRANSFER_BUFFER+SIZE_OF_INT);if(!o){const e=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),n=C.getValue(TRANSFER_BUFFER,"i32"),o=C.UTF8ToString(r,n).length,i=t.slice(o,o+100).split("\n")[0],s=i.match(QUERY_WORD_REGEX)?.[0]??"";switch(C._free(r),e){case QueryErrorKind.Syntax:throw new QueryError(QueryErrorKind.Syntax,{suffix:`${o}: '${i}'...`},o,0);case QueryErrorKind.NodeName:case QueryErrorKind.FieldName:case QueryErrorKind.CaptureName:throw new QueryError(e,{word:s},o,s.length);case QueryErrorKind.PatternStructure:throw new QueryError(e,{suffix:`${o}: '${i}'...`},o,0)}}const i=C._ts_query_string_count(o),s=C._ts_query_capture_count(o),a=C._ts_query_pattern_count(o),_=new Array(s),u=new Array(a),l=new Array(i);for(let e=0;e<s;e++){const t=C._ts_query_capture_name_for_id(o,e,TRANSFER_BUFFER),n=C.getValue(TRANSFER_BUFFER,"i32");_[e]=C.UTF8ToString(t,n)}for(let e=0;e<a;e++){const t=new Array(s);for(let n=0;n<s;n++){const r=C._ts_query_capture_quantifier_for_id(o,e,n);t[n]=r}u[e]=t}for(let e=0;e<i;e++){const t=C._ts_query_string_value_for_id(o,e,TRANSFER_BUFFER),n=C.getValue(TRANSFER_BUFFER,"i32");l[e]=C.UTF8ToString(t,n)}const c=new Array(a),d=new Array(a),p=new Array(a),m=new Array(a),f=new Array(a);for(let e=0;e<a;e++){const t=C._ts_query_predicates_for_pattern(o,e,TRANSFER_BUFFER),n=C.getValue(TRANSFER_BUFFER,"i32");m[e]=[],f[e]=[];const r=new Array;let i=t;for(let t=0;t<n;t++){const t=C.getValue(i,"i32");i+=SIZE_OF_INT;const n=C.getValue(i,"i32");i+=SIZE_OF_INT,parsePattern(e,t,n,_,l,r,f,m,c,d,p)}Object.freeze(f[e]),Object.freeze(m[e]),Object.freeze(c[e]),Object.freeze(d[e]),Object.freeze(p[e])}C._free(r),this[0]=o,this.captureNames=_,this.captureQuantifiers=u,this.textPredicates=f,this.predicates=m,this.setProperties=c,this.assertedProperties=d,this.refutedProperties=p,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(e,t={}){const n=t.startPosition??ZERO_POINT,r=t.endPosition??ZERO_POINT,o=t.startIndex??0,i=t.endIndex??0,s=t.startContainingPosition??ZERO_POINT,a=t.endContainingPosition??ZERO_POINT,_=t.startContainingIndex??0,u=t.endContainingIndex??0,l=t.matchLimit??4294967295,c=t.maxStartDepth??4294967295,d=t.progressCallback;if("number"!=typeof l)throw new Error("Arguments must be numbers");if(this.matchLimit=l,0!==i&&o>i)throw new Error("`startIndex` cannot be greater than `endIndex`");if(r!==ZERO_POINT&&(n.row>r.row||n.row===r.row&&n.column>r.column))throw new Error("`startPosition` cannot be greater than `endPosition`");if(0!==u&&_>u)throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");if(a!==ZERO_POINT&&(s.row>a.row||s.row===a.row&&s.column>a.column))throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");d&&(C.currentQueryProgressCallback=d),marshalNode(e),C._ts_query_matches_wasm(this[0],e.tree[0],n.row,n.column,r.row,r.column,o,i,s.row,s.column,a.row,a.column,_,u,l,c);const p=C.getValue(TRANSFER_BUFFER,"i32"),m=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),f=C.getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),y=new Array(p);this.exceededMatchLimit=Boolean(f);let h=0,g=m;for(let t=0;t<p;t++){const t=C.getValue(g,"i32");g+=SIZE_OF_INT;const n=C.getValue(g,"i32");g+=SIZE_OF_INT;const r=new Array(n);if(g=unmarshalCaptures(this,e.tree,g,t,r),this.textPredicates[t].every(e=>e(r))){y[h]={patternIndex:t,captures:r};const e=this.setProperties[t];y[h].setProperties=e;const n=this.assertedProperties[t];y[h].assertedProperties=n;const o=this.refutedProperties[t];y[h].refutedProperties=o,h++}}return y.length=h,C._free(m),C.currentQueryProgressCallback=null,y}captures(e,t={}){const n=t.startPosition??ZERO_POINT,r=t.endPosition??ZERO_POINT,o=t.startIndex??0,i=t.endIndex??0,s=t.startContainingPosition??ZERO_POINT,a=t.endContainingPosition??ZERO_POINT,_=t.startContainingIndex??0,u=t.endContainingIndex??0,l=t.matchLimit??4294967295,c=t.maxStartDepth??4294967295,d=t.progressCallback;if("number"!=typeof l)throw new Error("Arguments must be numbers");if(this.matchLimit=l,0!==i&&o>i)throw new Error("`startIndex` cannot be greater than `endIndex`");if(r!==ZERO_POINT&&(n.row>r.row||n.row===r.row&&n.column>r.column))throw new Error("`startPosition` cannot be greater than `endPosition`");if(0!==u&&_>u)throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");if(a!==ZERO_POINT&&(s.row>a.row||s.row===a.row&&s.column>a.column))throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");d&&(C.currentQueryProgressCallback=d),marshalNode(e),C._ts_query_captures_wasm(this[0],e.tree[0],n.row,n.column,r.row,r.column,o,i,s.row,s.column,a.row,a.column,_,u,l,c);const p=C.getValue(TRANSFER_BUFFER,"i32"),m=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),f=C.getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),y=new Array;this.exceededMatchLimit=Boolean(f);const h=new Array;let g=m;for(let t=0;t<p;t++){const t=C.getValue(g,"i32");g+=SIZE_OF_INT;const n=C.getValue(g,"i32");g+=SIZE_OF_INT;const r=C.getValue(g,"i32");if(g+=SIZE_OF_INT,h.length=n,g=unmarshalCaptures(this,e.tree,g,t,h),this.textPredicates[t].every(e=>e(h))){const e=h[r],n=this.setProperties[t];e.setProperties=n;const o=this.assertedProperties[t];e.assertedProperties=o;const i=this.refutedProperties[t];e.refutedProperties=i,y.push(e)}}return C._free(m),C.currentQueryProgressCallback=null,y}predicatesForPattern(e){return this.predicates[e]}disableCapture(e){const t=C.lengthBytesUTF8(e),n=C._malloc(t+1);C.stringToUTF8(e,n,t+1),C._ts_query_disable_capture(this[0],n,t),C._free(n)}disablePattern(e){if(e>=this.predicates.length)throw new Error(`Pattern index is ${e} but the pattern count is ${this.predicates.length}`);C._ts_query_disable_pattern(this[0],e)}didExceedMatchLimit(){return this.exceededMatchLimit}startIndexForPattern(e){if(e>=this.predicates.length)throw new Error(`Pattern index is ${e} but the pattern count is ${this.predicates.length}`);return C._ts_query_start_byte_for_pattern(this[0],e)}endIndexForPattern(e){if(e>=this.predicates.length)throw new Error(`Pattern index is ${e} but the pattern count is ${this.predicates.length}`);return C._ts_query_end_byte_for_pattern(this[0],e)}patternCount(){return C._ts_query_pattern_count(this[0])}captureIndexForName(e){return this.captureNames.indexOf(e)}isPatternRooted(e){return 1===C._ts_query_is_pattern_rooted(this[0],e)}isPatternNonLocal(e){return 1===C._ts_query_is_pattern_non_local(this[0],e)}isPatternGuaranteedAtStep(e){return 1===C._ts_query_is_pattern_guaranteed_at_step(this[0],e)}}}};const __webpack_module_cache__={};function __webpack_require__(e){const t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;const n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](n,n.exports,__webpack_require__),n.exports}(()=>{const e=Object.getPrototypeOf;let t;__webpack_require__.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}const o=Object.create(null);__webpack_require__.r(o);const i={};t=t||[null,e({}),e([]),e(e)];for(var s=2&r&&n;("object"==typeof s||"function"==typeof s)&&!~t.indexOf(s);s=e(s))Object.getOwnPropertyNames(s).forEach(e=>i[e]=()=>n[e]);return i.default=()=>n,__webpack_require__.d(o,i),o}})(),__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.p="",__webpack_require__.b=require("node:url").pathToFileURL(__filename);let __webpack_exports__={};const DateTimeKind={Unspecified:0,Utc:1,Local:2};class Exception{constructor(e,t){this.message=e??"",this.innerException=t}toString(){return this.message}}function isException(e){return e instanceof Exception||e instanceof Error}function isPromise(e){return e instanceof Promise}function ensureErrorOrException(e){return isException(e)||isPromise(e)?e:new Exception(String(e))}function isArrayLike(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function isMutableArray(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function isIterable(e){return null!=e&&"object"==typeof e&&Symbol.iterator in e}function isEnumerable(e){return null!=e&&"function"==typeof e.GetEnumerator}function isComparer(e){return null!=e&&"function"==typeof e.Compare}function isComparable(e){return null!=e&&"function"==typeof e.CompareTo}function isEquatable(e){return null!=e&&"function"==typeof e.Equals}function isHashable(e){return null!=e&&"function"==typeof e.GetHashCode}function isDisposable(e){return null!=e&&"function"==typeof e.Dispose}function disposeSafe(e){isDisposable(e)&&e.Dispose()}function defaultOf(){return null}function sameConstructor(e,t){return Object.getPrototypeOf(e)?.constructor===Object.getPrototypeOf(t)?.constructor}class Enumerable{constructor(e){this.en=e}GetEnumerator(){return this.en}"System.Collections.IEnumerable.GetEnumerator"(){return this.en}[Symbol.iterator](){return this}next(){const e=this.en["System.Collections.IEnumerator.MoveNext"]();return{done:!e,value:e?this.en["System.Collections.Generic.IEnumerator`1.get_Current"]():void 0}}}class Enumerator{constructor(e){this.current=defaultOf(),this.iter=e}"System.Collections.Generic.IEnumerator`1.get_Current"(){return this.current}"System.Collections.IEnumerator.get_Current"(){return this.current}"System.Collections.IEnumerator.MoveNext"(){const e=this.iter.next();return this.current=e.value,!e.done}"System.Collections.IEnumerator.Reset"(){throw new Exception("JS iterators cannot be reset")}Dispose(){}}function toEnumerable(e){return isEnumerable(e)?e:new Enumerable(new Enumerator(e[Symbol.iterator]()))}function getEnumerator(e){return isEnumerable(e)?e.GetEnumerator():new Enumerator(e[Symbol.iterator]())}function toIterator(e){return{next(){const t=e["System.Collections.IEnumerator.MoveNext"]();return{done:!t,value:t?e["System.Collections.Generic.IEnumerator`1.get_Current"]():void 0}}}}function enumerableToIterator(e){return toIterator(toEnumerable(e).GetEnumerator())}class Comparer{constructor(e){this.Compare=e||compare}}function comparerFromEqualityComparer(e){return isComparer(e)?new Comparer(e.Compare):new Comparer((t,n)=>{const r=e.GetHashCode(t),o=e.GetHashCode(n);return r===o?e.Equals(t,n)?0:-1:r<o?-1:1})}function assertEqual(e,t,n){if(!equals(e,t))throw Object.assign(new Exception(n||`Expected: ${t} - Actual: ${e}`),{actual:e,expected:t})}function assertNotEqual(e,t,n){if(equals(e,t))throw Object.assign(new Exception(n||`Expected: ${t} - Actual: ${e}`),{actual:e,expected:t})}class Lazy{constructor(e){this.factory=e,this.isValueCreated=!1}get Value(){return this.isValueCreated||(this.createdValue=this.factory(),this.isValueCreated=!0),this.createdValue}get IsValueCreated(){return this.isValueCreated}}function lazyFromValue(e){return new Lazy(()=>e)}function padWithZeros(e,t){return e.toString(10).padStart(t,"0")}function padLeftAndRightWithZeros(e,t,n){return e.toString(10).padStart(t,"0").padEnd(n,"0")}function dateOffset(e){const t=e;return"number"==typeof t.offset?t.offset:e.kind===DateTimeKind.Utc?0:-6e4*e.getTimezoneOffset()}function int16ToString(e,t){return(e=e<0&&null!=t&&10!==t?65535+e+1:e).toString(t)}function int32ToString(e,t){return(e=e<0&&null!=t&&10!==t?4294967295+e+1:e).toString(t)}function int64ToString(e,t){return(e=e<0&&null!=t&&10!==t?0xffffffffffffffffn+e+1n:e).toString(t)}class ObjectRef{static id(e){return ObjectRef.idMap.has(e)||ObjectRef.idMap.set(e,++ObjectRef.count),ObjectRef.idMap.get(e)}}function stringHash(e){let t=0,n=5381;const r=e.length;for(;t<r;)n=33*n^e.charCodeAt(t++);return n}function numberHash(e){return 2654435761*e|0}function bigintHash(e){return stringHash(e.toString(32))}function combineHashCodes(e){let t=0;const n=e.length;for(let r=0;r<n;r++)t=(t<<5)+t^e[r];return t}function physicalHash(e){if(null==e)return 0;switch(typeof e){case"boolean":return e?1:0;case"number":return numberHash(e);case"bigint":return bigintHash(e);case"string":return stringHash(e);default:return numberHash(ObjectRef.id(e))}}function identityHash(e){return isHashable(e)?e.GetHashCode():physicalHash(e)}function dateHash(e){return e.getTime()}function arrayHash(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r++)n[r]=structuralHash(e[r]);return combineHashCodes(n)}function structuralHash(e){if(null==e)return 0;switch(typeof e){case"boolean":return e?1:0;case"number":return numberHash(e);case"bigint":return bigintHash(e);case"string":return stringHash(e);default:return isHashable(e)?e.GetHashCode():isArrayLike(e)?arrayHash(e):e instanceof Date?dateHash(e):Object.getPrototypeOf(e)?.constructor===Object?combineHashCodes(Object.values(e).map(e=>structuralHash(e))):numberHash(ObjectRef.id(e))}}function fastStructuralHash(e){return stringHash(String(e))}function safeHash(e){return identityHash(e)}function equalArraysWith(e,t,n){if(null==e)return null==t;if(null==t)return!1;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function equalArrays(e,t){return equalArraysWith(e,t,equals)}function equalObjects(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;n.sort(),r.sort();for(let o=0;o<n.length;o++)if(n[o]!==r[o]||!equals(e[n[o]],t[r[o]]))return!1;return!0}function physicalEquals(e,t){return e===t}function equals(e,t){return e===t||(null==e?null==t:null!=t&&(isEquatable(e)?e.Equals(t):isArrayLike(e)?isArrayLike(t)&&equalArrays(e,t):"object"==typeof e&&(e instanceof Date?t instanceof Date&&0===compareDates(e,t):Object.getPrototypeOf(e)?.constructor===Object&&equalObjects(e,t))))}function compareDates(e,t){let n,r;return"offset"in e&&"offset"in t?(n=e.getTime(),r=t.getTime()):(n=e.getTime()+dateOffset(e),r=t.getTime()+dateOffset(t)),n===r?0:n<r?-1:1}function comparePrimitives(e,t){return e===t?0:e<t?-1:e>t?1:Number.isNaN(e)?Number.isNaN(t)?0:-1:1}function compareArraysWith(e,t,n){if(null==e)return null==t?0:1;if(null==t)return-1;if(e.length!==t.length)return e.length<t.length?-1:1;for(let r=0,o=0;r<e.length;r++)if(o=n(e[r],t[r]),0!==o)return o;return 0}function compareArrays(e,t){return compareArraysWith(e,t,compare)}function compareObjects(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return n.length<r.length?-1:1;n.sort(),r.sort();for(let o=0,i=0;o<n.length;o++){const s=n[o];if(s!==r[o])return s<r[o]?-1:1;if(i=compare(e[s],t[s]),0!==i)return i}return 0}function compare(e,t){return e===t?0:null==e?null==t?0:-1:null==t?1:isComparable(e)?e.CompareTo(t):isArrayLike(e)?isArrayLike(t)?compareArrays(e,t):-1:"object"!=typeof e?comparePrimitives(e,t):e instanceof Date?t instanceof Date?compareDates(e,t):-1:Object.getPrototypeOf(e)?.constructor===Object?compareObjects(e,t):-1}function min(e,t,n){return e(t,n)<0?t:n}function max(e,t,n){return e(t,n)>0?t:n}function clamp(e,t,n,r){return e(t,n)<0?n:e(t,r)>0?r:t}function createAtom(e){let t=e;return(...e)=>{if(0===e.length)return t;t=e[0]}}function createObj(e){const t={};for(const n of e)t[n[0]]=n[1];return t}function jsOptions(e){const t={};return e(t),t}function round(e,t=0){const n=Math.pow(10,t),r=+(t?e*n:e).toFixed(8),o=Math.floor(r),i=r-o,s=i>.5-1e-8&&i<.5+1e-8?o%2==0?o:o+1:Math.round(r);return t?s/n:s}function sign(e){return e>0?1:e<0?-1:0}function unescapeDataString(e){return decodeURIComponent(e.replace(/\+/g,"%20"))}function escapeDataString(e){return encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")}function escapeUriString(e){return encodeURI(e)}function count(e){if(isArrayLike(e))return e.length;{let t=0;for(const n of e)t++;return t}}function clear(e){isArrayLike(e)?e.splice(0):e.clear()}ObjectRef.idMap=new WeakMap,ObjectRef.count=0;const curried=new WeakMap;function uncurry2(e){if(null==e)return null;const t=(t,n)=>e(t)(n);return curried.set(t,e),t}function curry2(e){return curried.get(e)??(t=>n=>e(t,n))}function uncurry3(e){if(null==e)return null;const t=(t,n,r)=>e(t)(n)(r);return curried.set(t,e),t}function curry3(e){return curried.get(e)??(t=>n=>r=>e(t,n,r))}function uncurry4(e){if(null==e)return null;const t=(t,n,r,o)=>e(t)(n)(r)(o);return curried.set(t,e),t}function curry4(e){return curried.get(e)??(t=>n=>r=>o=>e(t,n,r,o))}function uncurry5(e){if(null==e)return null;const t=(t,n,r,o,i)=>e(t)(n)(r)(o)(i);return curried.set(t,e),t}function curry5(e){return curried.get(e)??(t=>n=>r=>o=>i=>e(t,n,r,o,i))}function uncurry6(e){if(null==e)return null;const t=(t,n,r,o,i,s)=>e(t)(n)(r)(o)(i)(s);return curried.set(t,e),t}function curry6(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>e(t,n,r,o,i,s))}function uncurry7(e){if(null==e)return null;const t=(t,n,r,o,i,s,a)=>e(t)(n)(r)(o)(i)(s)(a);return curried.set(t,e),t}function curry7(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>e(t,n,r,o,i,s,a))}function uncurry8(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_)=>e(t)(n)(r)(o)(i)(s)(a)(_);return curried.set(t,e),t}function curry8(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>e(t,n,r,o,i,s,a,_))}function uncurry9(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u);return curried.set(t,e),t}function curry9(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>e(t,n,r,o,i,s,a,_,u))}function uncurry10(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l);return curried.set(t,e),t}function curry10(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>e(t,n,r,o,i,s,a,_,u,l))}function uncurry11(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l,c)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l)(c);return curried.set(t,e),t}function curry11(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>c=>e(t,n,r,o,i,s,a,_,u,l,c))}function uncurry12(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l,c,d)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l)(c)(d);return curried.set(t,e),t}function curry12(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>c=>d=>e(t,n,r,o,i,s,a,_,u,l,c,d))}function uncurry13(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l,c,d,p)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l)(c)(d)(p);return curried.set(t,e),t}function curry13(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>c=>d=>p=>e(t,n,r,o,i,s,a,_,u,l,c,d,p))}function uncurry14(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l,c,d,p,m)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l)(c)(d)(p)(m);return curried.set(t,e),t}function curry14(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>c=>d=>p=>m=>e(t,n,r,o,i,s,a,_,u,l,c,d,p,m))}function uncurry15(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l)(c)(d)(p)(m)(f);return curried.set(t,e),t}function curry15(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>c=>d=>p=>m=>f=>e(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f))}function uncurry16(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l)(c)(d)(p)(m)(f)(y);return curried.set(t,e),t}function curry16(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>c=>d=>p=>m=>f=>y=>e(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y))}function uncurry17(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y,h)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l)(c)(d)(p)(m)(f)(y)(h);return curried.set(t,e),t}function curry17(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>c=>d=>p=>m=>f=>y=>h=>e(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y,h))}function uncurry18(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y,h,g)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l)(c)(d)(p)(m)(f)(y)(h)(g);return curried.set(t,e),t}function curry18(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>c=>d=>p=>m=>f=>y=>h=>g=>e(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y,h,g))}function uncurry19(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y,h,g,S)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l)(c)(d)(p)(m)(f)(y)(h)(g)(S);return curried.set(t,e),t}function curry19(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>c=>d=>p=>m=>f=>y=>h=>g=>S=>e(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y,h,g,S))}function uncurry20(e){if(null==e)return null;const t=(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y,h,g,S,$)=>e(t)(n)(r)(o)(i)(s)(a)(_)(u)(l)(c)(d)(p)(m)(f)(y)(h)(g)(S)($);return curried.set(t,e),t}function curry20(e){return curried.get(e)??(t=>n=>r=>o=>i=>s=>a=>_=>u=>l=>c=>d=>p=>m=>f=>y=>h=>g=>S=>$=>e(t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y,h,g,S,$))}function copyToArray(e,t,n,r,o){if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n))n.set(e.subarray(t,t+o),r);else for(let i=0;i<o;++i)n[r+i]=e[t+i]}function seqToString(e){let t=0,n="[";for(const r of e){if(0===t)n+=toStringQuoted(r);else{if(100===t){n+="; ...";break}n+="; "+toStringQuoted(r)}t++}return n+"]"}function toStringQuoted(e,t=0){return"string"==typeof e?'"'+e+'"':Types_toString(e,t)}function Types_toString(e,t=0){if(null!=e&&"object"==typeof e){if("function"==typeof e.toString&&e.toString!==Object.prototype.toString)return e.toString();if(Symbol.iterator in e)return seqToString(e);{const n=Object.getPrototypeOf(e)?.constructor;return n===Object&&t<10?"{ "+Object.entries(e).map(([e,n])=>e+" = "+toStringQuoted(n,t+1)).join("\n ")+" }":n?.name??""}}return String(e)}function unionToString(e,t){if(0===t.length)return e;{let n,r=!0;return 1===t.length?(n=toStringQuoted(t[0]),r=n.indexOf(" ")>=0):n=t.map(e=>toStringQuoted(e)).join(", "),e+(r?" (":" ")+n+(r?")":"")}}class Union{get name(){return this.cases()[this.tag]}toJSON(){return 0===this.fields.length?this.name:[this.name].concat(this.fields)}toString(){return unionToString(this.name,this.fields)}GetHashCode(){const e=this.fields.map(e=>structuralHash(e));return e.splice(0,0,numberHash(this.tag)),combineHashCodes(e)}Equals(e){return this===e||!!sameConstructor(this,e)&&this.tag===e.tag&&equalArrays(this.fields,e.fields)}CompareTo(e){return this===e?0:sameConstructor(this,e)?this.tag===e.tag?compareArrays(this.fields,e.fields):this.tag<e.tag?-1:1:-1}}function recordToJSON(e){const t={},n=Object.keys(e);for(let r=0;r<n.length;r++)t[n[r]]=e[n[r]];return t}function recordToString(e){return"{ "+Object.entries(e).map(([e,t])=>e+" = "+toStringQuoted(t)).join("\n ")+" }"}function recordGetHashCode(e){return combineHashCodes(Object.values(e).map(e=>structuralHash(e)))}function recordEquals(e,t){if(e===t)return!0;if(sameConstructor(e,t)){const n=Object.keys(e);for(let r=0;r<n.length;r++)if(!equals(e[n[r]],t[n[r]]))return!1;return!0}return!1}function recordCompareTo(e,t){if(e===t)return 0;if(sameConstructor(e,t)){const n=Object.keys(e);for(let r=0;r<n.length;r++){const o=compare(e[n[r]],t[n[r]]);if(0!==o)return o}return 0}return-1}class Record{toJSON(){return recordToJSON(this)}toString(){return recordToString(this)}GetHashCode(){return recordGetHashCode(this)}Equals(e){return recordEquals(this,e)}CompareTo(e){return recordCompareTo(this,e)}}class FSharpRef{get contents(){return this.getter()}set contents(e){this.setter(e)}constructor(e,t){"function"==typeof t?(this.getter=e,this.setter=t):(this.getter=()=>e,this.setter=t=>{e=t})}}class FSharpException extends Exception{toJSON(){return recordToJSON(this)}toString(){return recordToString(this)}GetHashCode(){return recordGetHashCode(this)}Equals(e){return recordEquals(this,e)}CompareTo(e){return recordCompareTo(this,e)}}class MatchFailureException extends FSharpException{constructor(e,t,n){super(),this.arg1=e,this.arg2=0|t,this.arg3=0|n,this.message="The match cases were incomplete"}}class Attribute{}var Option_Exception;class Some{constructor(e){this.value=e}toJSON(){return this.value}toString(){return String(this.value)}GetHashCode(){return structuralHash(this.value)}Equals(e){return null!=e&&equals(this.value,e instanceof Some?e.value:e)}CompareTo(e){return null==e?1:compare(this.value,e instanceof Some?e.value:e)}}function nonNullValue(e){if(null==e)throw new Option_Exception("Nullable has no value");return e}function Option_value(e){if(null==e)throw new Exception("Option has no value");return e instanceof Some?e.value:e}function unwrap(e){return e instanceof Some?e.value:e}function some(e){return null==e||e instanceof Some?new Some(e):e}function ofNullable(e){return e??void 0}function toNullable(e){return null==e?null:Option_value(e)}function flatten(e){return null==e?void 0:Option_value(e)}function toArray(e){return null==e?[]:[Option_value(e)]}function defaultArg(e,t){return null!=e?Option_value(e):t}function orElse(e,t){return e??t}function map(e,t){return null!=t?some(e(Option_value(t))):void 0}function tryOp(e,t){try{return some(e(t))}catch{return}}const SR_indexOutOfBounds="The index was outside the range of elements in the collection.",SR_inputWasEmpty="Collection was empty.",SR_inputMustBeNonNegative="The input must be non-negative.",SR_inputSequenceEmpty="The input sequence was empty.",SR_inputSequenceTooLong="The input sequence contains more than one element.",SR_keyNotFoundAlt="An index satisfying the predicate was not found in the collection.",SR_differentLengths="The collections had different lengths.",SR_notEnoughElements="The input sequence has an insufficient number of elements.",SR_Arg_ApplicationException="Error in the application.",SR_Arg_ArgumentException="Value does not fall within the expected range.",SR_Arg_ArgumentOutOfRangeException="Specified argument was out of the range of valid values.",SR_ArgumentNull_Generic="Value cannot be null.",SR_Arg_ParamName_Name=" (Parameter '",SR_Arg_ArithmeticException="Overflow or underflow in the arithmetic operation.",SR_Arg_DivideByZero="Attempted to divide by zero.",SR_Arg_FormatException="One of the identified items was in an invalid format.",SR_Arg_IndexOutOfRangeException="Index was outside the bounds of the array.",SR_Arg_InvalidOperationException="Operation is not valid due to the current state of the object.",SR_Arg_KeyNotFound="The given key was not present in the dictionary.",SR_Arg_NotFiniteNumberException="Number encountered was not a finite quantity.",SR_Arg_NotImplementedException="The method or operation is not implemented.",SR_Arg_NotSupportedException="Specified method is not supported.",SR_Arg_NullReferenceException="Object reference not set to an instance of an object.",SR_Arg_OutOfMemoryException="Insufficient memory to continue the execution of the program.",SR_Arg_OverflowException="Arithmetic operation resulted in an overflow.",SR_Arg_RankException="Attempted to operate on an array with the incorrect number of dimensions.",SR_Arg_StackOverflowException="Operation caused a stack overflow.",SR_Arg_SystemException="System error.",SR_Arg_TimeoutException="The operation has timed out.";var toInt64,toFloat64,Date_DateTimeKind,Date_dateOffset,Date_Exception,Date_compareDates;const shortDays=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longDays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortMonths=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longMonths=["January","February","March","April","May","June","July","August","September","October","November","December"];function parseRepeatToken(e,t,n){let r=0,o=t;for(;o<e.length&&e[o]===n;)o++,r++;return r}function parseNextChar(e,t){return t>=e.length-1?-1:e.charCodeAt(t+1)}function parseQuotedString(e,t){let n=t;const r=e[t];let o="",i=!1;for(;t<e.length;){const n=e[++t];if(n===r){i=!0;break}if("\\"===n){if(!(t<e.length))throw new Exception("Invalid string format");o+=e[++t]}else o+=n}if(!i)throw new Exception(`Invalid string format could not find matching quote for ${r}`);return[o,t-n+1]}function dateToStringWithCustomFormat(e,t,n){let r=0,o=0,i="";const s=n?DateTime(e.getTime(),DateTimeKind.Utc):e;for(;r<t.length;){const e=t[r];switch(e){case"d":switch(o=parseRepeatToken(t,r,"d"),r+=o,o){case 1:i+=day(s);break;case 2:i+=padWithZeros(day(s),2);break;case 3:i+=shortDays[dayOfWeek(s)];break;default:i+=longDays[dayOfWeek(s)]}break;case"f":if(o=parseRepeatToken(t,r,"f"),r+=o,o<=3){const e=10**(3-o);i+=padWithZeros(Math.floor(millisecond(s)/e),o)}else{if(!(o<=7))throw"Input string was not in a correct format.";i+=(""+millisecond(s)).padEnd(o,"0")}break;case"F":if(o=parseRepeatToken(t,r,"F"),r+=o,o<=3){const e=10**(3-o),t=Math.floor(millisecond(s)/e);0!=t&&(i+=padWithZeros(t,o))}else{if(!(o<=7))throw"Input string was not in a correct format.";{const e=millisecond(s);0!=e&&(i+=padWithZeros(e,3))}}break;case"g":o=parseRepeatToken(t,r,"g"),r+=o,i+="A.D.";break;case"h":if(o=parseRepeatToken(t,r,"h"),r+=o,1===o){i+=hour(s)%12||12}else{i+=padWithZeros(hour(s)%12||12,2)}break;case"H":o=parseRepeatToken(t,r,"H"),r+=o,i+=1===o?hour(s):padWithZeros(hour(s),2);break;case"K":if(o=parseRepeatToken(t,r,"K"),r+=o,1===o)switch(getKind(s)){case DateTimeKind.Utc:i+="Z";break;case DateTimeKind.Local:i+=dateOffsetToString(-6e4*s.getTimezoneOffset());case DateTimeKind.Unspecified:}break;case"m":o=parseRepeatToken(t,r,"m"),r+=o,i+=1===o?minute(s):padWithZeros(minute(s),2);break;case"M":switch(o=parseRepeatToken(t,r,"M"),r+=o,o){case 1:i+=month(s);break;case 2:i+=padWithZeros(month(s),2);break;case 3:i+=shortMonths[month(s)-1];break;default:i+=longMonths[month(s)-1]}break;case"s":o=parseRepeatToken(t,r,"s"),r+=o,i+=1===o?second(s):padWithZeros(second(s),2);break;case"t":o=parseRepeatToken(t,r,"t"),r+=o,i+=1===o?s.getHours()<12?"A":"P":s.getHours()<12?"AM":"PM";break;case"y":switch(o=parseRepeatToken(t,r,"y"),r+=o,o){case 1:i+=year(s)%100;break;case 2:i+=padWithZeros(year(s)%100,2);break;default:i+=padWithZeros(year(s),o)}break;case"z":o=parseRepeatToken(t,r,"z"),r+=o;let a="";switch(getKind(s)){case DateTimeKind.Utc:a="+00:00";break;case DateTimeKind.Local:a=dateOffsetToString(-6e4*s.getTimezoneOffset());break;case DateTimeKind.Unspecified:a=dateOffsetToString(-6e4*toLocalTime(s).getTimezoneOffset())}const _="-"===a[0]?"-":"+",u=parseInt(a.substring(1,3),10),l=parseInt(a.substring(4,6),10);switch(o){case 1:i+=`${_}${u}`;break;case 2:i+=`${_}${padWithZeros(u,2)}`;break;default:i+=`${_}${padWithZeros(u,2)}:${padWithZeros(l,2)}`}break;case":":i+=":",r++;break;case"/":i+="/",r++;break;case"'":case'"':const[c,d]=parseQuotedString(t,r);i+=c,r+=d;break;case"%":const p=parseNextChar(t,r);if(!(p>=0&&p!=="%".charCodeAt(0)))throw new Exception("Invalid format string");r+=2,i+=dateToStringWithCustomFormat(s,String.fromCharCode(p),n);break;case"\\":const m=parseNextChar(t,r);if(!(m>=0))throw new Exception("Invalid format string");r+=2,i+=String.fromCharCode(m);break;default:r++,i+=e}}return i}function getKind(e){return e.kind??DateTimeKind.Unspecified}function unixEpochMillisecondsToTicks(e,t){return toInt64(10000n*(BigInt(e)+62135596800000n+BigInt(t)))}function ticksToUnixEpochMilliseconds(e){return Number(BigInt(e)/10000n-62135596800000n)}function dateOffsetToString(e){const t=e<0,n=(e=Math.abs(e))%36e5/6e4;return(t?"-":"+")+padWithZeros(~~(e/36e5),2)+":"+padWithZeros(n,2)}function dateToISOString(e,t){if(t)return e.toISOString();{const t=null==e.kind||e.kind===DateTimeKind.Local;return padWithZeros(e.getFullYear(),4)+"-"+padWithZeros(e.getMonth()+1,2)+"-"+padWithZeros(e.getDate(),2)+"T"+padWithZeros(e.getHours(),2)+":"+padWithZeros(e.getMinutes(),2)+":"+padWithZeros(e.getSeconds(),2)+"."+padWithZeros(e.getMilliseconds(),3)+(t?dateOffsetToString(-6e4*e.getTimezoneOffset()):"")}}function dateToISOStringWithOffset(e,t){const n=e.toISOString();return n.substring(0,n.length-1)+dateOffsetToString(t)}function dateToStringWithOffset(e,t){const n=new Date(e.getTime()+(e.offset??0));if("string"!=typeof t)return n.toISOString().replace(/\.\d+/,"").replace(/[A-Z]|\.\d+/g," ")+dateOffsetToString(e.offset??0);if(1!==t.length)return dateToStringWithCustomFormat(n,t,!0);switch(t){case"D":return dateToString_D(n);case"d":return dateToString_d(n);case"F":return dateToString_D(n)+" "+dateToString_T(n);case"f":return dateToString_D(n)+" "+dateToString_t(n);case"G":return dateToString_d(n)+" "+dateToString_T(n);case"g":return dateToString_d(n)+" "+dateToString_t(n);case"M":case"m":return dateToString_M(n);case"O":case"o":return dateToISOStringWithOffset(n,e.offset??0);case"R":case"r":return dateToString_R(DateTime(e.getTime(),DateTimeKind.Utc));case"s":return dateToString_s(toUniversalTime(n));case"T":return dateToString_T(toUniversalTime(n));case"t":return dateToString_t(toUniversalTime(n));case"u":return dateToString_u(DateTime(e.getTime(),DateTimeKind.Utc));case"U":{const t=DateTime(e.getTime(),DateTimeKind.Utc);return dateToString_D(t)+" "+dateToString_T(t)}case"Y":case"y":return dateToString_Y(n);default:throw new Exception("Unrecognized Date print format")}}function dateToString_D(e){return longDays[dayOfWeek(e)]+", "+padWithZeros(day(e),2)+" "+longMonths[month(e)-1]+" "+year(e)}function dateToString_d(e){return padWithZeros(month(e),2)+"/"+padWithZeros(day(e),2)+"/"+year(e)}function dateToString_T(e){return padWithZeros(hour(e),2)+":"+padWithZeros(minute(e),2)+":"+padWithZeros(second(e),2)}function dateToString_t(e){return padWithZeros(hour(e),2)+":"+padWithZeros(minute(e),2)}function dateToString_R(e){const t=toUniversalTime(e);return shortDays[dayOfWeek(t)]+", "+padWithZeros(day(t),2)+" "+shortMonths[month(t)-1]+" "+year(t)+" "+padWithZeros(hour(t),2)+":"+padWithZeros(minute(t),2)+":"+padWithZeros(second(t),2)+" GMT"}function dateToString_s(e){return padWithZeros(year(e),4)+"-"+padWithZeros(month(e),2)+"-"+padWithZeros(day(e),2)+"T"+padWithZeros(hour(e),2)+":"+padWithZeros(minute(e),2)+":"+padWithZeros(second(e),2)}function dateToString_u(e){const t=toUniversalTime(e);return padWithZeros(year(t),4)+"-"+padWithZeros(month(t),2)+"-"+padWithZeros(day(t),2)+" "+padWithZeros(hour(t),2)+":"+padWithZeros(minute(t),2)+":"+padWithZeros(second(t),2)+"Z"}function dateToString_M(e){return longMonths[month(e)-1]+" "+padWithZeros(day(e),2)}function dateToString_Y(e){return year(e)+" "+longMonths[month(e)-1]}function dateToStringWithKind(e,t){const n=e.kind===DateTimeKind.Utc;if("string"!=typeof t)return dateToString_d(e)+" "+dateToString_T(e);if(1!==t.length)return dateToStringWithCustomFormat(e,t,n);switch(t){case"D":return dateToString_D(e);case"d":return dateToString_d(e);case"F":return dateToString_D(e)+" "+dateToString_T(e);case"f":return dateToString_D(e)+" "+dateToString_t(e);case"G":return dateToString_d(e)+" "+dateToString_T(e);case"g":return dateToString_d(e)+" "+dateToString_t(e);case"M":case"m":return dateToString_M(e);case"O":case"o":return dateToISOString(e,n);case"R":case"r":return dateToString_R(e);case"s":return dateToString_s(e);case"T":return dateToString_T(e);case"t":return dateToString_t(e);case"u":return dateToString_u(e);case"U":return dateToString_D(toUniversalTime(e))+" "+dateToString_T(toUniversalTime(e));case"Y":case"y":return dateToString_Y(e);default:throw new Exception("Unrecognized Date print format")}}function Date_toString(e,t,n){return null!=e.offset?dateToStringWithOffset(e,t):dateToStringWithKind(e,t)}function DateTime(e,t){const n=new Date(e);return n.kind=t??DateTimeKind.Unspecified,n}function fromTicks(e,t){t=null!=t?t:Date_DateTimeKind.Local;let n=DateTime(ticksToUnixEpochMilliseconds(e),t);return t!==Date_DateTimeKind.Utc&&(n=DateTime(n.getTime()-Date_dateOffset(n),t)),n}function fromDateTime(e,t,n){const r=DateTime(e.getTime()+t,n);return DateTime(r.getTime()-Date_dateOffset(r),n)}function fromDateTimeOffset(e,t){switch(t){case Date_DateTimeKind.Utc:return DateTime(e.getTime(),Date_DateTimeKind.Utc);case Date_DateTimeKind.Local:return DateTime(e.getTime(),Date_DateTimeKind.Local);default:const n=DateTime(e.getTime()+(e.offset??0),t);return DateTime(n.getTime()-Date_dateOffset(n),t)}}function getTicks(e){return unixEpochMillisecondsToTicks(e.getTime(),Date_dateOffset(e))}function minValue(){return DateTime(-621355968e5,Date_DateTimeKind.Utc)}function maxValue(){return DateTime(0xe677d21fdbff,Date_DateTimeKind.Utc)}const recognizedDateWords=new Set(["january","february","march","april","may","june","july","august","september","october","november","december","jan","feb","mar","apr","jun","jul","aug","sep","sept","oct","nov","dec","monday","tuesday","wednesday","thursday","friday","saturday","sunday","mon","tue","wed","thu","fri","sat","sun","am","pm","gmt","utc","ut","t","z"]);function parseRaw(e){function t(){throw new Date_Exception(`The string is not a valid Date: ${e}`)}null!=e&&""!==e.trim()||t(),(e.match(/[a-z]+/gi)??[]).some(e=>!recognizedDateWords.has(e.toLowerCase()))&&t(),10===e.length&&"-"===e[4]&&"-"===e[7]&&(e+="T00:00:00");let n=new Date(e),r=null;if(isNaN(n.getTime())){const o=/^\s*(\d+[^\w\s:]\d+[^\w\s:]\d+)?\s*(\d+:\d+(?::\d+(?:\.\d+)?)?)?\s*([AaPp][Mm])?\s*(Z|[+-]([01]?\d):?([0-5]?\d)?)?\s*$/.exec(e);if(null!=o){let e,t=0;if(null!=o[2]){const e=o[2].split(":"),n=parseInt(e[0],10);t=3600*n+60*parseInt(e[1]||"0",10)+parseFloat(e[2]||"0"),null!=o[3]&&"PM"===o[3].toUpperCase()&&n<12?t+=43200:null!=o[3]&&"AM"===o[3].toUpperCase()&&12===n&&(t-=43200)}if(null!=o[4]){if(null!=o[1])e=new Date(o[1]+" UTC");else{const t=new Date;e=new Date(t.getUTCFullYear()+"/"+(t.getUTCMonth()+1)+"/"+t.getUTCDate())}if("Z"===o[4])r="Z";else{let e=60*parseInt(o[5],10)+parseInt(o[6]||"0",10);"-"===o[4][0]&&(e*=-1),r=e,t-=60*e}}else if(null!=o[1])e=new Date(o[1]);else{const t=new Date;e=new Date(t.getFullYear()+"/"+(t.getMonth()+1)+"/"+t.getDate())}n=new Date(e.getTime()+1e3*t),n=new Date(n.getTime()+6e4*(n.getTimezoneOffset()-e.getTimezoneOffset()))}else t();isNaN(n.getTime())&&t()}return[n,r]}function parse(e,t=!1){const[n,r]=parseRaw(e),o=null!=r?t&&"Z"===r?Date_DateTimeKind.Utc:Date_DateTimeKind.Local:Date_DateTimeKind.Unspecified;return DateTime(n.getTime(),o)}function tryParse(e,t){try{return t.contents=parse(e),!0}catch(e){return!1}}function create(e,t,n,r=0,o=0,i=0,s=0,a){const _=a===Date_DateTimeKind.Utc?new Date(Date.UTC(e,t-1,n,r,o,i,s)):new Date(e,t-1,n,r,o,i,s);e<=99&&(a===Date_DateTimeKind.Utc?_.setUTCFullYear(e,t-1,n):_.setFullYear(e,t-1,n));const u=_.getTime();if(isNaN(u))throw new Date_Exception("The parameters describe an unrepresentable Date.");return DateTime(u,a)}function now(){return DateTime(Date.now(),Date_DateTimeKind.Local)}function utcNow(){return DateTime(Date.now(),Date_DateTimeKind.Utc)}function today(){return date(now())}function isLeapYear(e){return e%4==0&&e%100!=0||e%400==0}function daysInMonth(e,t){return 2===t?isLeapYear(e)?29:28:t>=8?t%2==0?31:30:t%2==0?30:31}function toUniversalTime(e){return e.kind===DateTimeKind.Utc?e:DateTime(e.getTime(),DateTimeKind.Utc)}function toLocalTime(e){return e.kind===DateTimeKind.Local?e:DateTime(e.getTime(),DateTimeKind.Local)}function specifyKind(e,t){return create(year(e),month(e),day(e),hour(e),minute(e),second(e),millisecond(e),t)}function timeOfDay(e){return 36e5*hour(e)+6e4*minute(e)+1e3*second(e)+millisecond(e)}function date(e){return create(year(e),month(e),day(e),0,0,0,0,e.kind)}function day(e){return e.kind===DateTimeKind.Utc?e.getUTCDate():e.getDate()}function hour(e){return e.kind===DateTimeKind.Utc?e.getUTCHours():e.getHours()}function millisecond(e){return e.kind===DateTimeKind.Utc?e.getUTCMilliseconds():e.getMilliseconds()}function minute(e){return e.kind===DateTimeKind.Utc?e.getUTCMinutes():e.getMinutes()}function month(e){return(e.kind===DateTimeKind.Utc?e.getUTCMonth():e.getMonth())+1}function second(e){return e.kind===DateTimeKind.Utc?e.getUTCSeconds():e.getSeconds()}function year(e){return e.kind===DateTimeKind.Utc?e.getUTCFullYear():e.getFullYear()}function dayOfWeek(e){return e.kind===DateTimeKind.Utc?e.getUTCDay():e.getDay()}function dayOfYear(e){const t=year(e),n=month(e);let r=day(e);for(let e=1;e<n;e++)r+=daysInMonth(t,e);return r}function add(e,t){const n=DateTime(e.getTime()+t,e.kind);if(e.kind!==Date_DateTimeKind.Utc){const t=e.getTimezoneOffset(),r=n.getTimezoneOffset();return t!==r?DateTime(n.getTime()+6e4*(r-t),e.kind):n}return n}function addDays(e,t){return add(e,864e5*t)}function addHours(e,t){return add(e,36e5*t)}function addMinutes(e,t){return add(e,6e4*t)}function addSeconds(e,t){return add(e,1e3*t)}function addMilliseconds(e,t){return add(e,t)}function addTicks(e,t){return add(e,toFloat64(t/10000n))}function addYears(e,t){const n=month(e),r=year(e)+t,o=daysInMonth(r,n);return create(r,n,Math.min(o,day(e)),hour(e),minute(e),second(e),millisecond(e),e.kind)}function addMonths(e,t){const n=month(e)+t,r=((n-1)%12+12)%12+1,o=Math.floor((n-1)/12),i=year(e)+o,s=daysInMonth(i,r);return create(i,r,Math.min(s,day(e)),hour(e),minute(e),second(e),millisecond(e),e.kind)}function subtract(e,t){return"number"==typeof t?add(e,-t):e.getTime()-t.getTime()}function toLongDateString(e){return e.toDateString()}function toShortDateString(e){return e.toLocaleDateString()}function toLongTimeString(e){return e.toLocaleTimeString()}function toShortTimeString(e){return e.toLocaleTimeString().replace(/:\d\d(?!:)/,"")}function Date_equals(e,t){return e.getTime()===t.getTime()}const Date_compare=null,compareTo=null;function op_Addition(e,t){return add(e,t)}function op_Subtraction(e,t){return subtract(e,t)}function isDaylightSavingTime(e){const t=new Date(e.getFullYear(),0,1),n=new Date(e.getFullYear(),6,1);return isDST(t.getTimezoneOffset(),n.getTimezoneOffset(),e.getTimezoneOffset())}function isDST(e,t,n){return Math.min(e,t)===n}const fable_library_js_5_15_0_Date=null,symbol=Symbol("numeric");function isNumeric(e){return"number"==typeof e||"bigint"==typeof e||e?.[symbol]}function isIntegral(e){return"number"==typeof e&&Number.isInteger(e)||"bigint"==typeof e}function Numeric_compare(e,t){return"number"==typeof e||"bigint"==typeof e?e<t?-1:e>t?1:0:e.CompareTo(t)}function multiply(e,t){return"number"==typeof e?e*t:"bigint"==typeof e?e*BigInt(t):e[symbol]().multiply(t)}function toFixed(e,t){return"number"==typeof e?e.toFixed(t):"bigint"==typeof e?e.toString():e[symbol]().toFixed(t)}function toPrecision(e,t){return"number"==typeof e?e.toPrecision(t):"bigint"==typeof e?e.toString():e[symbol]().toPrecision(t)}function toExponential(e,t){return"number"==typeof e?e.toExponential(t):"bigint"==typeof e?e:e[symbol]().toExponential(t)}function toHex(e){return"number"==typeof e?(Number(e)>>>0).toString(16):"bigint"==typeof e?BigInt.asUintN(64,e).toString(16):e[symbol]().toHex()}var RegExp_Exception,String_escape,String_Exception;function RegExp_create(e,t=0){if(-284&t)throw new RegExp_Exception("RegexOptions only supports: IgnoreCase, Multiline, Compiled, Singleline and ECMAScript");let n="gu";return n+=1&t?"i":"",n+=2&t?"m":"",n+=16&t?"s":"",new RegExp(e,n)}function RegExp_escape(e){return e.replace(/[$()*+.?[\\\^{|}\]]/g,"\\$&")}function RegExp_unescape(e){return e.replace(/\\([$()*+.?[\\\^{|}\]])/g,"$1")}function isMatch(e,t,n=0){return e.lastIndex=n,e.test(t)}function match(e,t,n=0){return e.lastIndex=n,e.exec(t)}function RegExp_matches(e,t,n=0){if(null==t)throw new Exception("Input cannot ve null");if(!e.global)throw new Exception("Non-global RegExp");e.lastIndex=n;const r=[];let o,i=-1;for(;null!=(o=e.exec(t));)o.index===i?e.lastIndex++:(i=o.index,r.push(o));return r}function options(e){let t=256;return t|=e.ignoreCase?1:0,t|=e.multiline?2:0,t}function replace(e,t,n,r,o=0){if("string"==typeof e){const n=e;e=RegExp_create(t,r??0),t=n,r=void 0}if("string"==typeof n){const e=n;n=t=>e.replace(/\$(?:(\$)|(&)|(`)|(')|(\d+)|\{(\d+)\}|\{([^}]+)\})/g,(e,n,r,o,i,s,a,_)=>{if(null!=n)return"$";if(null!=r)return t[0];if(null!=o)return t.input.substring(0,t.index);if(null!=i)return t.input.substring(t.index+t[0].length);const u=s??a;if(null!=u){const n=parseInt(u,10);return n<t.length?t[n]??"":e}return null!=t.groups&&_ in t.groups?t.groups[_]??"":e})}return r=r??-1,t.substring(0,o)+t.substring(o).replace(e,function(){let e=arguments[0];if(r){r--;const t=[],o=arguments.length,i="string"!=typeof arguments[o-1];let s=i?o-3:o-2;for(let e=0;e<s;e++)t.push(arguments[e]);t.index=arguments[s++],t.input=arguments[s++],i&&(t.groups=arguments[s]),e=n(t)}return e})}function split(e,t,n,r=0){if("string"==typeof e){const r=e;e=RegExp_create(t,n??0),t=r,n=void 0}const o=[];let i=0,s=null==n?-1:n-1;for(const n of RegExp_matches(e,t,r)){if(0===s)break;o.push(t.substring(i,n.index)),i=n.index+n[0].length;for(let e=1;e<n.length;e++)void 0!==n[e]&&o.push(n[e]);s--}return o.push(t.substring(i)),o}const fsFormatRegExp=/(^|[^%])%([0+\- ]*)(\*|\d+)?(?:\.(\d+))?(\w)/g,interpolateRegExp=/(?:(^|[^%])%([0+\- ]*)(\d+)?(?:\.(\d+))?(\w))?%P\(\)/g,formatRegExp=/\{(\d+)(,-?\d+)?(?:\:([a-zA-Z])(\d{0,2})|\:(.+?))?\}/g;function isLessThan(e,t){return Numeric_compare(e,t)<0}const StringComparison={CurrentCulture:0,CurrentCultureIgnoreCase:1,InvariantCulture:2,InvariantCultureIgnoreCase:3,Ordinal:4,OrdinalIgnoreCase:5};function cmp(e,t,n){function r(e){return!0===e||e===StringComparison.CurrentCultureIgnoreCase||e===StringComparison.InvariantCultureIgnoreCase||e===StringComparison.OrdinalIgnoreCase}return null==e?null==t?0:-1:null==t?1:(o=n)===StringComparison.Ordinal||o===StringComparison.OrdinalIgnoreCase?(r(n)&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t?0:e<t?-1:1):(r(n)&&(e=e.toLocaleLowerCase(),t=t.toLocaleLowerCase()),e.localeCompare(t));var o}function String_compare(...e){switch(e.length){case 2:return cmp(e[0],e[1],!1);case 3:return cmp(e[0],e[1],e[2]);case 4:return cmp(e[0],e[1],!0===e[2]);case 5:return cmp(e[0].slice(e[1],e[1]+e[4]),e[2].slice(e[3],e[3]+e[4]),!1);case 6:return cmp(e[0].slice(e[1],e[1]+e[4]),e[2].slice(e[3],e[3]+e[4]),e[5]);case 7:return cmp(e[0].slice(e[1],e[1]+e[4]),e[2].slice(e[3],e[3]+e[4]),!0===e[5]);default:throw new String_Exception("String.compare: Unsupported number of parameters")}}function compareOrdinal(e,t){return cmp(e,t,StringComparison.Ordinal)}function String_compareTo(e,t){return cmp(e,t,StringComparison.CurrentCulture)}function startsWith(e,t,n){return n===StringComparison.Ordinal?e.startsWith(t):e.length>=t.length&&0===cmp(e.slice(0,t.length),t,n)}function endsWith(e,t,n){return n===StringComparison.Ordinal?e.endsWith(t):e.length>=t.length&&0===cmp(e.slice(e.length-t.length),t,n)}function contains(e,t,n){if(n===StringComparison.Ordinal)return e.includes(t);const r=t.length;for(let o=0;o<=e.length-r;o++)if(0===cmp(e.slice(o,o+r),t,n))return!0;return!1}function indexOf(e,t,n,r=0){if(n===StringComparison.Ordinal)return e.indexOf(t,r);const o=t.length;for(let i=Math.max(r,0);i<=e.length-o;i++)if(0===cmp(e.slice(i,i+o),t,n))return i;return-1}function lastIndexOf(e,t,n,r=e.length-1){if(n===StringComparison.Ordinal)return e.lastIndexOf(t,r);const o=t.length;for(let i=Math.min(r,e.length-o);i>=0;i--)if(0===cmp(e.slice(i,i+o),t,n))return i;return-1}function indexOfAny(e,t,...n){if(null==e||""===e)return-1;const r=n.length>0?n[0]:0;if(r<0)throw new String_Exception("Start index cannot be negative");const o=n.length>1?n[1]:e.length-r;if(o<0)throw new String_Exception("Length cannot be negative");if(r+o>e.length)throw new String_Exception("Invalid startIndex and length");const i=r+o,s="".concat.apply("",t);for(let t=r;t<i;t++)if(s.indexOf(e[t])>-1)return t;return-1}function printf(e){return{input:e,cont:fsFormat(e)}}function interpolate(e,t){let n=0,r=0,o="";interpolateRegExp.lastIndex=0;let i=interpolateRegExp.exec(e);for(;i;){const s=i.index+(i[1]||"").length;o+=e.substring(r,s).replace(/%%/g,"%");const[,,a,_,u,l]=i;r=interpolateRegExp.lastIndex,o+=formatReplacement(t[n++],a,_,u,l),interpolateRegExp.lastIndex=r-1,i=interpolateRegExp.exec(e)}return o+=e.substring(r).replace(/%%/g,"%"),o}function continuePrint(e,t){return"string"==typeof t?e(t):t.cont(e)}function toConsole(e){return continuePrint(e=>console.log(e),e)}function toConsoleError(e){return continuePrint(e=>console.error(e),e)}function toText(e){return continuePrint(e=>e,e)}function toFail(e){return continuePrint(e=>{throw new String_Exception(e)},e)}function formatReplacement(e,t,n,r,o){let i="";if(t=t||"",o=o||"",isNumeric(e))switch("x"!==o.toLowerCase()&&(isLessThan(e,0)?(e=multiply(e,-1),i="-"):t.indexOf(" ")>=0?i=" ":t.indexOf("+")>=0&&(i="+")),r=null==r?null:parseInt(r,10),o){case"f":case"F":e=toFixed(e,r=null!=r?r:6);break;case"g":case"G":e=null!=r?toPrecision(e,r):toPrecision(e);break;case"e":case"E":e=null!=r?toExponential(e,r):toExponential(e);break;case"x":e=toHex(e);break;case"X":e=toHex(e).toUpperCase();break;default:e=String(e)}else e=e instanceof Date?Date_toString(e):"A"===o&&"string"==typeof e?'"'+e+'"':Types_toString(e);if(n="number"==typeof n?n:parseInt(n,10),isNaN(n))e=i+e;else{const r=t.indexOf("0")>=0,o=t.indexOf("-")>=0,s=o||!r?" ":"0";e="0"===s?i+(e=pad(e,n-i.length,s,o)):pad(i+e,n,s,o)}return e}function createPrinter(e,t,n,r="",o=-1){return(...i)=>{let s=r;const a=t.slice(),_=n.slice();for(const e of i){const[,,t,n,r,i]=_[0];let u=n;if(o>=0)u=o,o=-1;else if("*"===u){if(e<0)throw new Exception("Non-negative number required");o=e;continue}s+=a[0],s+=formatReplacement(e,t,u,r,i),a.splice(0,1),_.splice(0,1)}return 0===_.length?(s+=a[0],e(s)):createPrinter(e,a,_,s,o)}}function fsFormat(e){return t=>{fsFormatRegExp.lastIndex=0;const n=[],r=[];let o=0,i=fsFormatRegExp.exec(e);for(;i;){const t=i.index+(i[1]||"").length;n.push(e.substring(o,t).replace(/%%/g,"%")),r.push(i),o=fsFormatRegExp.lastIndex,fsFormatRegExp.lastIndex-=1,i=fsFormatRegExp.exec(e)}return 0===n.length?t(e.replace(/%%/g,"%")):(n.push(e.substring(o).replace(/%%/g,"%")),createPrinter(t,n,r))}}function splitIntAndDecimalPart(e){let[t,n]=e.split(".");return void 0===n&&(n=""),{integral:t,decimal:n}}function thousandSeparate(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,",")}function format(e,...t){let n;return"object"==typeof e?(n=String(t[0]),t.shift()):n=e,n.replace(formatRegExp,(e,n,r,o,i,s)=>{if(n<0||n>=t.length)throw new Exception("Index must be greater or equal to zero and less than the arguments' length.");let a,_=t[n];if(isNumeric(_))switch(i=""==i?null:parseInt(i,10),o){case"b":case"B":if(!isIntegral(_))throw new Exception("Format specifier was invalid.");_=(_>>>0).toString(2).replace(/^0+/,"").padStart(i||1,"0");break;case"c":case"C":const e=isLessThan(_,0);isLessThan(_,0)&&(_=multiply(_,-1)),_=toFixed(_,i=i??2),a=splitIntAndDecimalPart(_),_=i>0?"¤"+thousandSeparate(a.integral)+"."+padRight(a.decimal,i,"0"):"¤"+thousandSeparate(a.integral),e&&(_="("+_+")");break;case"d":case"D":if(!isIntegral(_))throw new Exception("Format specifier was invalid.");_=String(_),null!=i&&(_=_.startsWith("-")?"-"+padLeft(_.substring(1),i,"0"):padLeft(_,i,"0"));break;case"e":case"E":_=null!=i?toExponential(_,i):toExponential(_);break;case"f":case"F":_=toFixed(_,i=null!=i?i:2),i>0&&(a=splitIntAndDecimalPart(_),_=a.integral+"."+padRight(a.decimal,i,"0"));break;case"g":case"G":{_=null!=i?toPrecision(_,i):toPrecision(_);const e=_.indexOf("e");if(e>=0){const t=trimEnd(trimEnd(_.slice(0,e),"0"),"."),n=_[e+1],r=_.slice(e+2),i=r.length<2?"0"+r:r;_=t+("G"===o?"E":"e")+n+i}else _=trimEnd(trimEnd(_,"0"),".");break}case"n":case"N":_=toFixed(_,i=null!=i?i:2),a=splitIntAndDecimalPart(_),_=i>0?thousandSeparate(a.integral)+"."+padRight(a.decimal,i,"0"):thousandSeparate(a.integral);break;case"p":case"P":i=null!=i?i:2,_=toFixed(multiply(_,100),i),a=splitIntAndDecimalPart(_),_=i>0?thousandSeparate(a.integral)+"."+padRight(a.decimal,i,"0")+" %":thousandSeparate(a.integral)+" %";break;case"r":case"R":throw new Exception("The round-trip format is not supported by Fable");case"x":case"X":if(!isIntegral(_))throw new Exception("Format specifier was invalid.");i=null!=i?i:1,_=padLeft(toHex(_),i,"0"),"X"===o&&(_=_.toUpperCase());break;default:if(o)throw new Exception("Format specifier was invalid.");if(s){let e="";_=s.replace(/([0#,]+)(\.[0#]+)?/,(t,n,r)=>{isLessThan(_,0)&&(_=multiply(_,-1),e="-"),r=null==r?"":r.substring(1),_=toFixed(_,Math.max(r.length,0));let[o,i]=_.split(".");i||(i=""),o=padLeft(o,n.replace(/,/g,"").replace(/^#+/,"").length,"0");const s=r.replace(/#+$/,"").length;if(s>i.length?i=padRight(i,s,"0"):s<i.length&&(i=i.substring(0,s)+i.substring(s).replace(/0+$/,"")),n.indexOf(",")>0){const e=o.length%3,t=Math.floor(o.length/3);let n=e>0?o.substr(0,e)+(t>0?",":""):"";for(let r=0;r<t;r++)n+=o.substr(e+3*r,3)+(r<t-1?",":"");o=n}return i.length>0?o+"."+i:o}),_=e+_}}else _=_ instanceof Date?Date_toString(_,s||o):Types_toString(_);return r=parseInt((r||" ").substring(1),10),isNaN(r)||(_=pad(String(_),Math.abs(r)," ",r<0)),_})}function initialize(e,t){if(e<0)throw new String_Exception("String length must be non-negative");const n=new Array(e);for(let r=0;r<e;r++)n[r]=t(r);return n.join("")}function insert(e,t,n){if(t<0||t>e.length)throw new String_Exception("startIndex is negative or greater than the length of this instance.");return e.substring(0,t)+n+e.substring(t)}function isNullOrEmpty(e){return"string"!=typeof e||0===e.length}function isNullOrWhiteSpace(e){return"string"!=typeof e||/^\s*$/.test(e)}function concat(...e){return e.map(e=>String(e)).join("")}function join(e,t){return Array.isArray(t)?t.join(e):Array.from(t).join(e)}function joinWithIndices(e,t,n,r){const o=n+r;if(o>t.length)throw new String_Exception("Index and count must refer to a location within the buffer.");return t.slice(n,o).join(e)}function notSupported(e){throw new String_Exception("The environment doesn't support '"+e+"', please use a polyfill.")}function toBase64String(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return"function"==typeof btoa?btoa(t):notSupported("btoa")}function fromBase64String(e){const t="function"==typeof atob?atob(e):notSupported("atob"),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function pad(e,t,n,r){n=n||" ",t-=e.length;for(let o=0;o<t;o++)e=r?e+n:n+e;return e}function padLeft(e,t,n){return pad(e,t,n)}function padRight(e,t,n){return pad(e,t,n,!0)}function remove(e,t,n){if(t>=e.length)throw new String_Exception("startIndex must be less than length of string");if("number"==typeof n&&t+n>e.length)throw new String_Exception("Index and count must refer to a location within the string.");return e.slice(0,t)+("number"==typeof n?e.substr(t+n):"")}function String_replace(e,t,n){return e.replace(new RegExp(RegExp_escape(t),"g"),n)}function replicate(e,t){return initialize(e,()=>t)}function getCharAtIndex(e,t){if(t<0||t>=e.length)throw new String_Exception("Index was outside the bounds of the array.");return e[t]}function String_split(e,t,n,r){if(r="number"==typeof r?r:0,(n="number"==typeof n?n:void 0)&&n<0)throw new Exception("Count cannot be less than zero");if(0===n)return[];const o=!(1&~r),i=!(2&~r);t=(t=(t=t||[]).filter(e=>e).map(RegExp_escape)).length>0?t:["\\s"];const s=[],a=new RegExp(t.join("|"),"g");let _=!0,u=0;do{const t=a.exec(e);if(null===t){const t=i?e.substring(u).trim():e.substring(u);(!o||t.length>0)&&s.push(t),_=!1}else{const r=i?e.substring(u,t.index).trim():e.substring(u,t.index);(!o||r.length>0)&&(null!=n&&s.length+1===n?(s.push(i?e.substring(u).trim():e.substring(u)),_=!1):s.push(r)),u=a.lastIndex}}while(_);return s}function trim(e,...t){if(0===t.length)return e.trim();const n="["+String_escape(t.join(""))+"]+";return e.replace(new RegExp("^"+n),"").replace(new RegExp(n+"$"),"")}function trimStart(e,...t){return 0===t.length?e.trimStart():e.replace(new RegExp("^["+String_escape(t.join(""))+"]+"),"")}function trimEnd(e,...t){return 0===t.length?e.trimEnd():e.replace(new RegExp("["+RegExp_escape(t.join(""))+"]+$"),"")}function filter(e,t){return t.split("").filter(t=>e(t)).join("")}function substring(e,t,n){if(t+(n||0)>e.length)throw new Exception("Invalid startIndex and/or length");return null!=n?e.substr(t,n):e.substr(t)}function toCharArray2(e,t,n){return substring(e,t,n).split("")}function fmt(e,...t){return{strs:e,args:t}}function fmtWith(e){return(t,...n)=>({strs:t,args:n,fmts:e})}function getFormat(e){const t=e.strs.map(e=>e.replace(/{/g,"{{").replace(/}/g,"}}"));return e.fmts?t.reduce((t,n,r)=>t+`{${String(r-1)+e.fmts[r-1]}}`+n):t.reduce((e,t,n)=>e+`{${n-1}}`+t)}var System_defaultOf,class_type,System_SR_Arg_SystemException,System_SR_Arg_ApplicationException,System_SR_Arg_ArithmeticException,System_SR_Arg_DivideByZero,System_SR_Arg_FormatException,System_SR_Arg_IndexOutOfRangeException,System_SR_Arg_InvalidOperationException,System_SR_Arg_NotFiniteNumberException,System_SR_Arg_NotImplementedException,System_SR_Arg_NotSupportedException,System_SR_Arg_NullReferenceException,System_SR_Arg_OutOfMemoryException,System_SR_Arg_OverflowException,System_SR_Arg_RankException,System_SR_Arg_StackOverflowException,System_SR_Arg_TimeoutException,System_SR_Arg_ArgumentException,System_SR_Arg_ArgumentOutOfRangeException,FSharp_Core_equals,FSharp_Core_structuralHash,FSharp_Core_Exception,FSharp_Core_defaultOf,FSharp_Core_disposeSafe,ComparisonIdentity_Structural,HashIdentity_Structural,FSharp_Core_nonNullValue,FSharp_Core_ArgumentNullException_$ctor_Z721C83C5,FSharp_Core_NullReferenceException_$ctor,FSharpChoice$2_Choice1Of2,FSharpChoice$2_Choice2Of2,StringBuilder__Append_Z721C83C5;class SystemException extends Exception{constructor(e){super(e)}}function SystemException_$reflection(){return class_type("System.SystemException",void 0,SystemException,class_type("System.Exception"))}function SystemException_$ctor_Z721C83C5(e){return new SystemException(e)}function SystemException_$ctor(){return SystemException_$ctor_Z721C83C5(System_SR_Arg_SystemException)}class ApplicationException extends Exception{constructor(e){super(e)}}function ApplicationException_$reflection(){return class_type("System.ApplicationException",void 0,ApplicationException,class_type("System.Exception"))}function ApplicationException_$ctor_Z721C83C5(e){return new ApplicationException(e)}function ApplicationException_$ctor(){return ApplicationException_$ctor_Z721C83C5(System_SR_Arg_ApplicationException)}class ArithmeticException extends Exception{constructor(e){super(e)}}function ArithmeticException_$reflection(){return class_type("System.ArithmeticException",void 0,ArithmeticException,class_type("System.Exception"))}function ArithmeticException_$ctor_Z721C83C5(e){return new ArithmeticException(e)}function ArithmeticException_$ctor(){return ArithmeticException_$ctor_Z721C83C5(System_SR_Arg_ArithmeticException)}class DivideByZeroException extends Exception{constructor(e){super(e)}}function DivideByZeroException_$reflection(){return class_type("System.DivideByZeroException",void 0,DivideByZeroException,class_type("System.Exception"))}function DivideByZeroException_$ctor_Z721C83C5(e){return new DivideByZeroException(e)}function DivideByZeroException_$ctor(){return DivideByZeroException_$ctor_Z721C83C5(System_SR_Arg_DivideByZero)}class FormatException extends Exception{constructor(e){super(e)}}function FormatException_$reflection(){return class_type("System.FormatException",void 0,FormatException,class_type("System.Exception"))}function FormatException_$ctor_Z721C83C5(e){return new FormatException(e)}function FormatException_$ctor(){return FormatException_$ctor_Z721C83C5(System_SR_Arg_FormatException)}class IndexOutOfRangeException extends Exception{constructor(e){super(e)}}function IndexOutOfRangeException_$reflection(){return class_type("System.IndexOutOfRangeException",void 0,IndexOutOfRangeException,class_type("System.Exception"))}function IndexOutOfRangeException_$ctor_Z721C83C5(e){return new IndexOutOfRangeException(e)}function IndexOutOfRangeException_$ctor(){return IndexOutOfRangeException_$ctor_Z721C83C5(System_SR_Arg_IndexOutOfRangeException)}class InvalidOperationException extends Exception{constructor(e){super(e)}}function InvalidOperationException_$reflection(){return class_type("System.InvalidOperationException",void 0,InvalidOperationException,class_type("System.Exception"))}function InvalidOperationException_$ctor_Z721C83C5(e){return new InvalidOperationException(e)}function InvalidOperationException_$ctor(){return InvalidOperationException_$ctor_Z721C83C5(System_SR_Arg_InvalidOperationException)}class NotFiniteNumberException extends Exception{constructor(e){super(e)}}function NotFiniteNumberException_$reflection(){return class_type("System.NotFiniteNumberException",void 0,NotFiniteNumberException,class_type("System.Exception"))}function NotFiniteNumberException_$ctor_Z721C83C5(e){return new NotFiniteNumberException(e)}function NotFiniteNumberException_$ctor(){return NotFiniteNumberException_$ctor_Z721C83C5(System_SR_Arg_NotFiniteNumberException)}class NotImplementedException extends Exception{constructor(e){super(e)}}function NotImplementedException_$reflection(){return class_type("System.NotImplementedException",void 0,NotImplementedException,class_type("System.Exception"))}function NotImplementedException_$ctor_Z721C83C5(e){return new NotImplementedException(e)}function NotImplementedException_$ctor(){return NotImplementedException_$ctor_Z721C83C5(System_SR_Arg_NotImplementedException)}class NotSupportedException extends Exception{constructor(e){super(e)}}function NotSupportedException_$reflection(){return class_type("System.NotSupportedException",void 0,NotSupportedException,class_type("System.Exception"))}function NotSupportedException_$ctor_Z721C83C5(e){return new NotSupportedException(e)}function NotSupportedException_$ctor(){return NotSupportedException_$ctor_Z721C83C5(System_SR_Arg_NotSupportedException)}class NullReferenceException extends Exception{constructor(e){super(e)}}function NullReferenceException_$reflection(){return class_type("System.NullReferenceException",void 0,NullReferenceException,class_type("System.Exception"))}function NullReferenceException_$ctor_Z721C83C5(e){return new NullReferenceException(e)}function NullReferenceException_$ctor(){return NullReferenceException_$ctor_Z721C83C5(System_SR_Arg_NullReferenceException)}class OutOfMemoryException extends Exception{constructor(e){super(e)}}function OutOfMemoryException_$reflection(){return class_type("System.OutOfMemoryException",void 0,OutOfMemoryException,class_type("System.Exception"))}function OutOfMemoryException_$ctor_Z721C83C5(e){return new OutOfMemoryException(e)}function OutOfMemoryException_$ctor(){return OutOfMemoryException_$ctor_Z721C83C5(System_SR_Arg_OutOfMemoryException)}class OverflowException extends Exception{constructor(e){super(e)}}function OverflowException_$reflection(){return class_type("System.OverflowException",void 0,OverflowException,class_type("System.Exception"))}function OverflowException_$ctor_Z721C83C5(e){return new OverflowException(e)}function OverflowException_$ctor(){return OverflowException_$ctor_Z721C83C5(System_SR_Arg_OverflowException)}class RankException extends Exception{constructor(e){super(e)}}function RankException_$reflection(){return class_type("System.RankException",void 0,RankException,class_type("System.Exception"))}function RankException_$ctor_Z721C83C5(e){return new RankException(e)}function RankException_$ctor(){return RankException_$ctor_Z721C83C5(System_SR_Arg_RankException)}class StackOverflowException extends Exception{constructor(e){super(e)}}function StackOverflowException_$reflection(){return class_type("System.StackOverflowException",void 0,StackOverflowException,class_type("System.Exception"))}function StackOverflowException_$ctor_Z721C83C5(e){return new StackOverflowException(e)}function StackOverflowException_$ctor(){return StackOverflowException_$ctor_Z721C83C5(System_SR_Arg_StackOverflowException)}class TimeoutException extends Exception{constructor(e){super(e)}}function TimeoutException_$reflection(){return class_type("System.TimeoutException",void 0,TimeoutException,class_type("System.Exception"))}function TimeoutException_$ctor_Z721C83C5(e){return new TimeoutException(e)}function TimeoutException_$ctor(){return TimeoutException_$ctor_Z721C83C5(System_SR_Arg_TimeoutException)}class ArgumentException extends Exception{constructor(e,t,n){super(isNullOrEmpty(t)?e:e+SR_Arg_ParamName_Name+t+"')",n),this.paramName=t}}function ArgumentException_$reflection(){return class_type("System.ArgumentException",void 0,ArgumentException,class_type("System.Exception"))}function ArgumentException_$ctor_Z60A2B367(e,t,n){return new ArgumentException(e,t,n)}function ArgumentException_$ctor(){return ArgumentException_$ctor_Z60A2B367(System_SR_Arg_ArgumentException,"",System_defaultOf())}function ArgumentException_$ctor_Z721C83C5(e){return ArgumentException_$ctor_Z60A2B367(e,"",defaultOf())}function ArgumentException_$ctor_Z384F8060(e,t){return ArgumentException_$ctor_Z60A2B367(e,t,System_defaultOf())}function ArgumentException_$ctor_68CE3CA2(e,t){return ArgumentException_$ctor_Z60A2B367(e,"",t)}function ArgumentException__get_ParamName(e){return e.paramName}class ArgumentNullException extends ArgumentException{constructor(e,t){super(t,e,defaultOf())}}function ArgumentNullException_$reflection(){return class_type("System.ArgumentNullException",void 0,ArgumentNullException,ArgumentException_$reflection())}function ArgumentNullException_$ctor_Z384F8060(e,t){return new ArgumentNullException(e,t)}function ArgumentNullException_$ctor_Z721C83C5(e){return ArgumentNullException_$ctor_Z384F8060(e,SR_ArgumentNull_Generic)}function ArgumentNullException_$ctor(){return ArgumentNullException_$ctor_Z721C83C5("")}class ArgumentOutOfRangeException extends ArgumentException{constructor(e,t){super(t,e,defaultOf())}}function ArgumentOutOfRangeException_$reflection(){return class_type("System.ArgumentOutOfRangeException",void 0,ArgumentOutOfRangeException,ArgumentException_$reflection())}function ArgumentOutOfRangeException_$ctor_Z384F8060(e,t){return new ArgumentOutOfRangeException(e,t)}function ArgumentOutOfRangeException_$ctor_Z721C83C5(e){return ArgumentOutOfRangeException_$ctor_Z384F8060(e,System_SR_Arg_ArgumentOutOfRangeException)}function ArgumentOutOfRangeException_$ctor(){return ArgumentOutOfRangeException_$ctor_Z721C83C5("")}const LanguagePrimitives_GenericEqualityComparer=null,LanguagePrimitives_GenericEqualityERComparer=null;function LanguagePrimitives_FastGenericComparer(){return ComparisonIdentity_Structural()}function LanguagePrimitives_FastGenericComparerFromTable(){return ComparisonIdentity_Structural()}function LanguagePrimitives_FastGenericEqualityComparer(){return HashIdentity_Structural()}function LanguagePrimitives_FastGenericEqualityComparerFromTable(){return HashIdentity_Structural()}function Operators_Failure(e){return new FSharp_Core_Exception(e)}function Operators_FailurePattern(e){return e.message}function Operators_NullArg(e){throw FSharp_Core_ArgumentNullException_$ctor_Z721C83C5(e)}function Operators_Using(e,t){try{return t(e)}finally{FSharp_Core_equals(e,FSharp_Core_defaultOf())||FSharp_Core_disposeSafe(e)}}function Operators_Lock(e,t){return t()}function Operators_IsNull(e){return!!FSharp_Core_equals(e,FSharp_Core_defaultOf())}function Operators_IsNotNull(e){return!FSharp_Core_equals(e,FSharp_Core_defaultOf())}function Operators_IsNullV(e){return!(null!=e)}function Operators_NonNull(e){if(FSharp_Core_equals(e,FSharp_Core_defaultOf()))throw FSharp_Core_NullReferenceException_$ctor();return e}function Operators_NonNullV(e){if(null!=e)return FSharp_Core_nonNullValue(e);throw FSharp_Core_NullReferenceException_$ctor()}function Operators_NullMatchPattern(e){return FSharp_Core_equals(e,FSharp_Core_defaultOf())?FSharpChoice$2_Choice1Of2(void 0):FSharpChoice$2_Choice2Of2(e)}function Operators_NullValueMatchPattern(e){return null!=e?FSharpChoice$2_Choice2Of2(FSharp_Core_nonNullValue(e)):FSharpChoice$2_Choice1Of2(void 0)}function Operators_NonNullQuickPattern(e){if(FSharp_Core_equals(e,FSharp_Core_defaultOf()))throw FSharp_Core_NullReferenceException_$ctor();return e}function Operators_NonNullQuickValuePattern(e){if(null!=e)return FSharp_Core_nonNullValue(e);throw FSharp_Core_NullReferenceException_$ctor()}function Operators_WithNull(e){return e}function Operators_WithNullV(e){return e}function Operators_NullV(){return null}function Operators_NullArgCheck(e,t){if(equals(t,defaultOf()))throw ArgumentNullException_$ctor_Z721C83C5(e);return t}function ExtraTopLevelOperators_LazyPattern(e){return e.Value}function PrintfModule_PrintFormatToStringBuilderThen(e,t,n){return n.cont(n=>(StringBuilder__Append_Z721C83C5(t,n),e()))}function PrintfModule_PrintFormatToStringBuilder(e,t){return PrintfModule_PrintFormatToStringBuilderThen(()=>{},e,t)}function Helpers_allocateArrayFromCons(e,t){return null==e?new Array(t):"function"==typeof e?new e(t):new Array(t)}var Array_Exception,Array_defaultOf,Array_copyToArray,Array_getEnumerator,Array_disposeSafe,Array_Helpers_allocateArrayFromCons,setItem_1,item_2,value_2,Array_some,Array_defaultArg,max_1,min_1,Array_SR_indexOutOfBounds,Array_SR_Arg_ArgumentOutOfRangeException,Array_SR_inputSequenceEmpty,Array_SR_inputMustBeNonNegative,Array_SR_notEnoughElements,Array_Operators_IsNull,nonSeeded,Seq_disposeSafe,Seq_getEnumerator,Seq_isDisposable,Seq_Exception,Seq_isArrayLike,Seq_clear,Seq_class_type,Seq_some,value_1,KeyNotFoundException_$ctor_Z721C83C5,Seq_Operators_NullArgCheck,Seq_Operators_Lock,tryFindBack_1,tryFindIndexBack_1,foldBack_1,item_1,tryHead_1,tryItem_1,mapFold_1,mapFoldBack_1,reverse_1,scanBack_1,pairwise_1,splitInto_1,windowed_1,map_1,transpose_1,permute_1,chunkBySize_1,Seq_randomShuffleInPlaceBy,randomChoiceBy_1,randomChoiceWith_1,randomChoice_1,randomChoicesBy_1,randomSampleBy_1,FSharpList,tryHead_2,isEmpty_1,tryItem_2,length_1,Seq_min_1,Seq_SR_indexOutOfBounds,Seq_nonSeeded;function indexNotFound(){throw new Array_Exception("An index satisfying the predicate was not found in the collection.")}function differentLengths(){throw new Array_Exception("Arrays had different lengths")}function append(e,t,n){const r=0|e.length,o=0|t.length,i=Array_Helpers_allocateArrayFromCons(n,r+o);for(let t=0;t<=r-1;t++)setItem_1(i,t,item_2(t,e));for(let e=0;e<=o-1;e++)setItem_1(i,e+r,item_2(e,t));return i}function Array_filter(e,t){return t.filter(e)}function fill(e,t,n,r){const o=0|t;return e.fill(r,o,o+n)}function getSubArray(e,t,n){const r=0|t;return e.slice(r,r+n)}function last(e){if(0===e.length)throw new Array_Exception("The input array was empty (Parameter 'array')");return item_2(e.length-1,e)}function tryLast(e){return 0===e.length?void 0:some(item(e.length-1,e))}function mapIndexed(e,t,n){const r=0|t.length,o=Helpers_allocateArrayFromCons(n,r);for(let n=0;n<=r-1;n++)setItem(o,n,e(n,item(n,t)));return o}function Array_map(e,t,n){const r=0|t.length,o=Helpers_allocateArrayFromCons(n,r);for(let n=0;n<=r-1;n++)setItem(o,n,e(item(n,t)));return o}function mapIndexed2(e,t,n,r){if(t.length!==n.length)throw new Array_Exception("Arrays had different lengths");const o=Array_Helpers_allocateArrayFromCons(r,t.length);for(let r=0;r<=t.length-1;r++)setItem_1(o,r,e(r,item_2(r,t),item_2(r,n)));return o}function map2(e,t,n,r){if(t.length!==n.length)throw new Array_Exception("Arrays had different lengths");const o=Array_Helpers_allocateArrayFromCons(r,t.length);for(let r=0;r<=t.length-1;r++)setItem_1(o,r,e(item_2(r,t),item_2(r,n)));return o}function mapIndexed3(e,t,n,r,o){if(t.length!==n.length||n.length!==r.length)throw new Array_Exception("Arrays had different lengths");const i=Array_Helpers_allocateArrayFromCons(o,t.length);for(let o=0;o<=t.length-1;o++)setItem_1(i,o,e(o,item_2(o,t),item_2(o,n),item_2(o,r)));return i}function map3(e,t,n,r,o){if(t.length!==n.length||n.length!==r.length)throw new Array_Exception("Arrays had different lengths");const i=Array_Helpers_allocateArrayFromCons(o,t.length);for(let o=0;o<=t.length-1;o++)setItem_1(i,o,e(item_2(o,t),item_2(o,n),item_2(o,r)));return i}function mapFold(e,t,n,r){const o=0|n.length;if(0===o)return[[],t];{let i=t;const s=Array_Helpers_allocateArrayFromCons(r,o);for(let t=0;t<=n.length-1;t++){const r=e(i,item_2(t,n));setItem_1(s,t,r[0]),i=r[1]}return[s,i]}}function mapFoldBack(e,t,n,r){const o=0|t.length;if(0===o)return[[],n];{let i=n;const s=Array_Helpers_allocateArrayFromCons(r,o);for(let n=t.length-1;n>=0;n--){const r=e(item_2(n,t),i);setItem_1(s,n,r[0]),i=r[1]}return[s,i]}}function indexed(e){const t=0|e.length,n=new Array(t);for(let r=0;r<=t-1;r++)setItem_1(n,r,[r,item_2(r,e)]);return n}function truncate(e,t){const n=0|max_1(0,e);return t.slice(0,0+n)}function Array_concat(e,t){const n=Array.isArray(e)?e:Array.from(e);switch(0|n.length){case 0:return Array_Helpers_allocateArrayFromCons(t,0);case 1:return item_2(0,n);default:{let e=0,r=0;for(let e=0;e<=n.length-1;e++)r=r+item_2(e,n).length|0;const o=Array_Helpers_allocateArrayFromCons(t,r);for(let t=0;t<=n.length-1;t++){const r=item_2(t,n);for(let t=0;t<=r.length-1;t++)setItem_1(o,e,item_2(t,r)),e=e+1|0}return o}}}function collect(e,t,n){return Array_concat(Array_map(e,t,Array_defaultOf()),n)}function where(e,t){return t.filter(e)}function Array_indexOf(e,t,n,r,o){let i;const s=0|defaultArg(n,0),a=0|defaultArg((i=r,null!=i?s+Option_value(i):void 0),e.length);return 0|(n=>{for(;;){const r=n;if(r>=a)return-1;if(o.Equals(t,item(r,e)))return 0|r;n=r+1}})(s)}function Array_contains(e,t,n){return Array_indexOf(t,e,void 0,void 0,n)>=0}function empty(e){return Array_Helpers_allocateArrayFromCons(e,0)}function singleton(e,t){const n=Helpers_allocateArrayFromCons(t,1);return setItem(n,0,e),n}function Array_initialize(e,t,n){if(e<0)throw new Exception("The input must be non-negative (Parameter 'count')");const r=Helpers_allocateArrayFromCons(n,e);for(let n=0;n<=e-1;n++)setItem(r,n,t(n));return r}function pairwise(e){if(e.length<2)return[];{const t=e.length-1|0,n=new Array(t);for(let r=0;r<=t-1;r++)setItem(n,r,[item(r,e),item(r+1,e)]);return n}}function Array_replicate(e,t,n){if(e<0)throw new Array_Exception("The input must be non-negative (Parameter 'count')");const r=Array_Helpers_allocateArrayFromCons(n,e);for(let e=0;e<=r.length-1;e++)setItem_1(r,e,t);return r}function copy(e){return e.slice()}function copyTo(e,t,n,r,o){Array_copyToArray(e,t,n,r,o)}function reverse(e){return e.slice().reverse()}function scan(e,t,n,r){const o=Array_Helpers_allocateArrayFromCons(r,n.length+1);setItem_1(o,0,t);for(let t=0;t<=n.length-1;t++)setItem_1(o,t+1,e(item_2(t,o),item_2(t,n)));return o}function scanBack(e,t,n,r){const o=Array_Helpers_allocateArrayFromCons(r,t.length+1);setItem_1(o,t.length,n);for(let n=t.length-1;n>=0;n--)setItem_1(o,n,e(item_2(n,t),item_2(n+1,o)));return o}function skip(e,t,n){if(e>t.length)throw new Array_Exception("count is greater than array length (Parameter 'count')");if(e===t.length)return Array_Helpers_allocateArrayFromCons(n,0);{const n=0|(e<0?0:e);return t.slice(n)}}function skipWhile(e,t,n){let r=0;for(;r<t.length&&e(item_2(r,t));)r=r+1|0;if(r===t.length)return Array_Helpers_allocateArrayFromCons(n,0);{const e=0|r;return t.slice(e)}}function take(e,t,n){if(e<0)throw new Array_Exception("The input must be non-negative (Parameter 'count')");if(e>t.length)throw new Array_Exception("count is greater than array length (Parameter 'count')");return 0===e?Array_Helpers_allocateArrayFromCons(n,0):t.slice(0,0+e)}function takeWhile(e,t,n){let r=0;for(;r<t.length&&e(item_2(r,t));)r=r+1|0;if(0===r)return Array_Helpers_allocateArrayFromCons(n,0);{const e=0|r;return t.slice(0,0+e)}}function findAll(e,t){return t.filter(e)}function getRange(e,t,n){const r=0|t;return e.slice(r,r+n)}function addInPlace(e,t){t.push(e)}function addRangeInPlace(e,t){const n=Array_getEnumerator(e);try{for(;n["System.Collections.IEnumerator.MoveNext"]();)addInPlace(n["System.Collections.Generic.IEnumerator`1.get_Current"](),t)}finally{Array_disposeSafe(n)}}function insertRangeInPlace(e,t,n){let r=e;const o=Array_getEnumerator(t);try{for(;o["System.Collections.IEnumerator.MoveNext"]();){let e;const t=o["System.Collections.Generic.IEnumerator`1.get_Current"]();e=0|r,n.splice(e,0,t),r=r+1|0}}finally{Array_disposeSafe(o)}}function removeInPlace(e,t,n){const r=0|Array_indexOf(t,e,void 0,void 0,n);return r>-1&&(t.splice(r,1),!0)}function removeAllInPlace(e,t){const n=r=>{let o;return o=t.findIndex(e),o>-1?(t.splice(o,1),n(r)+1|0):0|r};return 0|n(0)}function partition(e,t,n){const r=0|t.length,o=Array_Helpers_allocateArrayFromCons(n,r),i=Array_Helpers_allocateArrayFromCons(n,r);let s=0,a=0;for(let n=0;n<=r-1;n++)e(item_2(n,t))?(setItem_1(o,s,item_2(n,t)),s=s+1|0):(setItem_1(i,a,item_2(n,t)),a=a+1|0);return[truncate(s,o),truncate(a,i)]}function find(e,t){const n=t.find(e);return null==n?indexNotFound():value_2(n)}function tryFind(e,t){return t.find(e)}function findIndex(e,t){const n=0|t.findIndex(e);return n>-1?0|n:(indexNotFound(),-1)}function tryFindIndex(e,t){const n=0|t.findIndex(e);return n>-1?n:void 0}function pick(e,t){return(n=>{e:for(;;){const r=n;if(r>=t.length)return indexNotFound();{const o=e(item_2(r,t));if(null!=o)return value_2(o);n=r+1;continue e}}})(0)}function tryPick(e,t){return(n=>{e:for(;;){const r=n;if(r>=t.length)return;{const o=e(item_2(r,t));if(null==o){n=r+1;continue e}return o}}})(0)}function findBack(e,t){return(n=>{for(;;){const r=n;if(r<0)return indexNotFound();if(e(item_2(r,t)))return item_2(r,t);n=r-1}})(t.length-1)}function tryFindBack(e,t){return(n=>{for(;;){const r=n;if(r<0)return;if(e(item_2(r,t)))return Array_some(item_2(r,t));n=r-1}})(t.length-1)}function findLastIndex(e,t){return 0|(n=>{for(;;){const r=n;if(r<0)return-1;if(e(item_2(r,t)))return 0|r;n=r-1}})(t.length-1)}function findIndexBack(e,t){return 0|(n=>{for(;;){const r=n;if(r<0)return indexNotFound(),-1;if(e(item_2(r,t)))return 0|r;n=r-1}})(t.length-1)}function tryFindIndexBack(e,t){return(n=>{for(;;){const r=n;if(r<0)return;if(e(item_2(r,t)))return r;n=r-1}})(t.length-1)}function choose(e,t,n){const r=[];for(let n=0;n<=t.length-1;n++){const o=e(item(n,t));if(null!=o){const e=Option_value(o);r.push(e)}}return null==n?r:Array_map(e=>e,r,n)}function foldIndexed(e,t,n){return n.reduce((t,n,r)=>e(r,t,n),t)}function fold(e,t,n){const r=e;return n.reduce(r,t)}function iterate(e,t){for(let n=0;n<=t.length-1;n++)e(item_2(n,t))}function iterateIndexed(e,t){for(let n=0;n<=t.length-1;n++)e(n,item_2(n,t))}function iterate2(e,t,n){t.length!==n.length&&differentLengths();for(let r=0;r<=t.length-1;r++)e(item_2(r,t),item_2(r,n))}function iterateIndexed2(e,t,n){t.length!==n.length&&differentLengths();for(let r=0;r<=t.length-1;r++)e(r,item_2(r,t),item_2(r,n))}function isEmpty(e){return 0===e.length}function forAll(e,t){return t.every(e)}function permute(e,t){const n=0|t.length,r=t.slice(),o=new Array(n);if(iterateIndexed((t,i)=>{const s=0|e(t);if(s<0||s>=n)throw new Array_Exception("Not a valid permutation");setItem_1(r,s,i),setItem_1(o,s,1)},t),!o.every(e=>1===e))throw new Array_Exception("Not a valid permutation");return r}function setSlice(e,t,n,r){const o=0|Array_defaultArg(t,0),i=0|Array_defaultArg(n,-1),s=(i>=0?i:e.length-1)-o|0;for(let t=0;t<=s;t++)setItem_1(e,t+o,item_2(t,r))}function sortInPlaceBy(e,t,n){t.sort((t,r)=>0|n.Compare(e(t),e(r)))}function sortInPlace(e,t){e.sort((e,n)=>0|t.Compare(e,n))}function sort(e,t){const n=e.slice();return n.sort((e,n)=>0|t.Compare(e,n)),n}function sortBy(e,t,n){const r=t.slice();return r.sort((t,r)=>0|n.Compare(e(t),e(r))),r}function sortDescending(e,t){const n=e.slice();return n.sort((e,n)=>-1*t.Compare(e,n)|0),n}function sortByDescending(e,t,n){const r=t.slice();return r.sort((t,r)=>-1*n.Compare(e(t),e(r))|0),r}function sortWith(e,t){const n=e,r=t.slice();return r.sort(n),r}function allPairs(e,t){const n=0|e.length,r=0|t.length,o=new Array(n*r);for(let n=0;n<=e.length-1;n++)for(let i=0;i<=t.length-1;i++)setItem_1(o,n*r+i,[item_2(n,e),item_2(i,t)]);return o}function unfold(e,t){const n=[];return(t=>{e:for(;;){const r=e(t);if(null!=r){const e=value_2(r)[0],o=value_2(r)[1];n.push(e),t=o;continue e}break}})(t),n}function unzip(e){const t=0|e.length,n=new Array(t),r=new Array(t);return iterateIndexed((e,t)=>{setItem_1(n,e,t[0]),setItem_1(r,e,t[1])},e),[n,r]}function unzip3(e){const t=0|e.length,n=new Array(t),r=new Array(t),o=new Array(t);return iterateIndexed((e,t)=>{setItem_1(n,e,t[0]),setItem_1(r,e,t[1]),setItem_1(o,e,t[2])},e),[n,r,o]}function zip(e,t){e.length!==t.length&&differentLengths();const n=new Array(e.length);for(let r=0;r<=e.length-1;r++)setItem_1(n,r,[item_2(r,e),item_2(r,t)]);return n}function zip3(e,t,n){e.length===t.length&&t.length===n.length||differentLengths();const r=new Array(e.length);for(let o=0;o<=e.length-1;o++)setItem_1(r,o,[item_2(o,e),item_2(o,t),item_2(o,n)]);return r}function chunkBySize(e,t){if(e<1)throw new Array_Exception("The input must be positive. (Parameter 'size')");const n=[];if(t.length>0){const r=0|Math.ceil(t.length/e);for(let o=0;o<=r-1;o++){let r;const i=o*e|0;r=t.slice(i,i+e),n.push(r)}}return n}function splitAt(e,t){if(e<0||e>t.length)throw new Array_Exception(Array_SR_indexOutOfBounds+" (Parameter 'index')");return[t.slice(0,0+e),t.slice(e)]}function compareWith(e,t,n){if(Array_Operators_IsNull(t))return Array_Operators_IsNull(n)?0:-1;if(Array_Operators_IsNull(n))return 1;{const r=0|t.length,o=0|n.length,i=0|(r<o?r:o);let s=0,a=0;for(;0===a&&s<i;)a=0|e(item_2(s,t),item_2(s,n)),s=s+1|0;return 0!==a?0|a:r>o?1:r<o?-1:0}}function Array_compareTo(e,t,n){if(Array_Operators_IsNull(t))return Array_Operators_IsNull(n)?0:-1;if(Array_Operators_IsNull(n))return 1;{const r=0|t.length,o=0|n.length;if(r>o)return 1;if(r<o)return-1;{let o=0,i=0;for(;0===i&&o<r;)i=0|e(item_2(o,t),item_2(o,n)),o=o+1|0;return 0|i}}}function equalsWith(e,t,n){if(Array_Operators_IsNull(t))return!!Array_Operators_IsNull(n);if(Array_Operators_IsNull(n))return!1;{let r=0,o=!0;const i=0|t.length,s=0|n.length;if(i>s)return!1;if(i<s)return!1;for(;r<i&&o;)o=e(item_2(r,t),item_2(r,n)),r=r+1|0;return o}}function exactlyOne(e){switch(e.length){case 1:return item_2(0,e);case 0:throw new Array_Exception("The input sequence was empty (Parameter 'array')");default:throw new Array_Exception("Input array too long (Parameter 'array')")}}function tryExactlyOne(e){return 1===e.length?Array_some(item_2(0,e)):void 0}function head(e){if(0===e.length)throw new Array_Exception("The input array was empty (Parameter 'array')");return item_2(0,e)}function tryHead(e){return 0===e.length?void 0:Array_some(item_2(0,e))}function tail(e){if(0===e.length)throw new Array_Exception("Not enough elements (Parameter 'array')");return e.slice(1)}function item(e,t){if(e<0||e>=t.length)throw new Exception("Index was outside the bounds of the array. (Parameter 'index')");return t[e]}function setItem(e,t,n){if(t<0||t>=e.length)throw new Exception("Index was outside the bounds of the array. (Parameter 'index')");e[t]=n}function tryItem(e,t){return e<0||e>=t.length?void 0:Array_some(t[e])}function foldBackIndexed(e,t,n){return t.reduceRight((t,n,r)=>e(r,n,t),n)}function foldBack(e,t,n){return t.reduceRight((t,n)=>e(n,t),n)}function foldIndexed2(e,t,n,r){let o=t;if(n.length!==r.length)throw new Array_Exception("Arrays have different lengths");for(let t=0;t<=n.length-1;t++)o=e(t,o,item_2(t,n),item_2(t,r));return o}function fold2(e,t,n,r){return foldIndexed2((t,n,r,o)=>e(n,r,o),t,n,r)}function foldBackIndexed2(e,t,n,r){let o=r;t.length!==n.length&&differentLengths();const i=0|t.length;for(let r=1;r<=i;r++)o=e(r-1,item_2(i-r,t),item_2(i-r,n),o);return o}function foldBack2(e,t,n,r){return foldBackIndexed2((t,n,r,o)=>e(n,r,o),t,n,r)}function reduce(e,t){if(0===t.length)throw new Array_Exception("The input array was empty");const n=e;return t.reduce(n)}function reduceBack(e,t){if(0===t.length)throw new Array_Exception("The input array was empty");const n=e;return t.reduceRight(n)}function forAll2(e,t,n){return fold2((t,n,r)=>t&&e(n,r),!0,t,n)}function existsOffset(e,t,n){for(;;){const r=e,o=t,i=n;if(i===o.length)return!1;if(r(item_2(i,o)))return!0;e=r,t=o,n=i+1}}function exists(e,t){return existsOffset(e,t,0)}function existsOffset2(e,t,n,r){for(;;){const o=e,i=t,s=n,a=r;if(a===i.length)return!1;if(o(item_2(a,i),item_2(a,s)))return!0;e=o,t=i,n=s,r=a+1}}function exists2(e,t,n){return t.length!==n.length&&differentLengths(),existsOffset2(e,t,n,0)}function sum(e,t){let n=t.GetZero();for(let r=0;r<=e.length-1;r++)n=t.Add(n,item_2(r,e));return n}function sumBy(e,t,n){let r=n.GetZero();for(let o=0;o<=t.length-1;o++)r=n.Add(r,e(item_2(o,t)));return r}function maxBy(e,t,n){return reduce((t,r)=>n.Compare(e(r),e(t))>0?r:t,t)}function Array_max(e,t){return reduce((e,n)=>t.Compare(n,e)>0?n:e,e)}function minBy(e,t,n){return reduce((t,r)=>n.Compare(e(r),e(t))>0?t:r,t)}function Array_min(e,t){return reduce((e,n)=>t.Compare(n,e)>0?e:n,e)}function average(e,t){if(0===e.length)throw new Array_Exception("The input array was empty (Parameter 'array')");let n=t.GetZero();for(let r=0;r<=e.length-1;r++)n=t.Add(n,item_2(r,e));return t.DivideByInt(n,e.length)}function averageBy(e,t,n){if(0===t.length)throw new Array_Exception("The input array was empty (Parameter 'array')");let r=n.GetZero();for(let o=0;o<=t.length-1;o++)r=n.Add(r,e(item_2(o,t)));return n.DivideByInt(r,t.length)}function windowed(e,t){if(e<=0)throw new Array_Exception("windowSize must be positive");let n;const r=0|max_1(0,t.length-e+1);n=new Array(r);for(let r=e;r<=t.length;r++)setItem_1(n,r-e,t.slice(r-e,r-1+1));return n}function splitInto(e,t){if(e<1)throw new Array_Exception("The input must be positive. (Parameter 'chunks')");const n=[];if(t.length>0){const r=0|min_1(e,t.length),o=t.length/r|0,i=t.length%r|0;for(let e=0;e<=r-1;e++){const r=0|(e<i?o+1:o);let s;const a=e*o+min_1(i,e)|0;s=t.slice(a,a+r),n.push(s)}}return n}function transpose(e,t){const n=Array.isArray(e)?e:Array.from(e),r=0|n.length;if(0===r)return new Array(0);{const e=0|item_2(0,n).length;forAll(t=>t.length===e,n)||differentLengths();const o=new Array(e);for(let i=0;i<=e-1;i++){setItem_1(o,i,Array_Helpers_allocateArrayFromCons(t,r));for(let e=0;e<=r-1;e++)item_2(i,o)[e]=item_2(i,item_2(e,n))}return o}}function insertAt(e,t,n,r){const o=0|n.length;if(e<0||e>o)throw new Array_Exception(Array_SR_indexOutOfBounds+" (Parameter 'index')");const i=Array_Helpers_allocateArrayFromCons(r,o+1);for(let t=0;t<=e-1;t++)setItem_1(i,t,item_2(t,n));setItem_1(i,e,t);for(let t=e;t<=o-1;t++)setItem_1(i,t+1,item_2(t,n));return i}function insertManyAt(e,t,n,r){const o=0|n.length;if(e<0||e>o)throw new Array_Exception(Array_SR_indexOutOfBounds+" (Parameter 'index')");const i=Array.from(t),s=0|i.length,a=Array_Helpers_allocateArrayFromCons(r,o+s);for(let t=0;t<=e-1;t++)setItem_1(a,t,item_2(t,n));for(let t=0;t<=s-1;t++)setItem_1(a,e+t,item_2(t,i));for(let t=e;t<=o-1;t++)setItem_1(a,t+s,item_2(t,n));return a}function randomShuffleInPlaceBy(e,t){for(let n=(0|t.length)-1;n>=1;n--){const r=e();if(r<0||r>=1)throw new Array_Exception(Array_SR_Arg_ArgumentOutOfRangeException+" (Parameter 'randomizer')");const o=r*(n+1)|0,i=item_2(n,t);setItem_1(t,n,item_2(o,t)),setItem_1(t,o,i)}}function randomShuffleInPlaceWith(e,t){randomShuffleInPlaceBy(()=>e.NextDouble(),t)}function randomShuffleInPlace(e){randomShuffleInPlaceWith(nonSeeded(),e)}function randomShuffleBy(e,t){const n=copy(t);return randomShuffleInPlaceBy(e,n),n}function randomShuffleWith(e,t){return randomShuffleBy(()=>e.NextDouble(),t)}function randomShuffle(e){return randomShuffleWith(nonSeeded(),e)}function randomChoiceBy(e,t){if(isEmpty(t))throw new Array_Exception(Array_SR_inputSequenceEmpty+" (Parameter 'source')");const n=0|t.length,r=e();if(r<0||r>=1)throw new Array_Exception(Array_SR_Arg_ArgumentOutOfRangeException+" (Parameter 'randomizer')");return item_2(~~(r*n),t)}function randomChoiceWith(e,t){return randomChoiceBy(()=>e.NextDouble(),t)}function randomChoice(e){return randomChoiceWith(nonSeeded(),e)}function randomChoicesBy(e,t,n,r){if(t<0)throw new Array_Exception(Array_SR_inputMustBeNonNegative+" (Parameter 'count')");if(t>0&&isEmpty(n))throw new Array_Exception(Array_SR_inputSequenceEmpty+" (Parameter 'source')");const o=0|n.length;return Array_initialize(t,t=>{const r=e();if(r<0||r>=1)throw new Array_Exception(Array_SR_Arg_ArgumentOutOfRangeException+" (Parameter 'randomizer')");return item_2(~~(r*o),n)},r)}function randomChoicesWith(e,t,n,r){return randomChoicesBy(()=>e.NextDouble(),t,n,r)}function randomChoices(e,t,n){return randomChoicesWith(nonSeeded(),e,t,n)}function randomSampleBy(e,t,n){if(t<0)throw new Array_Exception(Array_SR_inputMustBeNonNegative+" (Parameter 'count')");const r=copy(n),o=0|r.length;if(0===o&&t>0)throw new Array_Exception(Array_SR_inputSequenceEmpty+" (Parameter 'source')");if(t>o)throw new Array_Exception(Array_SR_notEnoughElements+" (Parameter 'count')");for(let n=0;n<=t-1;n++){const t=e();if(t<0||t>=1)throw new Array_Exception(Array_SR_Arg_ArgumentOutOfRangeException+" (Parameter 'randomizer')");const i=n+~~(t*(o-n))|0,s=item_2(n,r);setItem_1(r,n,item_2(i,r)),setItem_1(r,i,s)}return getSubArray(r,0,t)}function randomSampleWith(e,t,n){return randomSampleBy(()=>e.NextDouble(),t,n)}function randomSample(e,t){return randomSampleWith(nonSeeded(),e,t)}function removeAt(e,t){if(e<0||e>=t.length)throw new Array_Exception(Array_SR_indexOutOfBounds+" (Parameter 'index')");let n=-1;return Array_filter(t=>(n=n+1|0,n!==e),t)}function removeManyAt(e,t,n){let r=-1,o=-1;const i=Array_filter(n=>(r=r+1|0,r===e?(o=0,!1):!(r>e&&(r<e+t||(o=1,0)))),n),s=0|(0===o&&r+1===e+t?1:o);if(s<1)throw new Array_Exception(Array_SR_indexOutOfBounds+" (Parameter '"+(s<0?"index":"count")+"')");return i}function updateAt(e,t,n,r){const o=0|n.length;if(e<0||e>=o)throw new Array_Exception(Array_SR_indexOutOfBounds+" (Parameter 'index')");const i=Array_Helpers_allocateArrayFromCons(r,o);for(let r=0;r<=o-1;r++)setItem_1(i,r,r===e?t:item_2(r,n));return i}function resize(e,t,n,r){let o,i,s,a;if(t<0)throw new Array_Exception("The input must be non-negative. (Parameter 'newSize')");const _=Array_defaultArg(n,Array_defaultOf());if(Array_Operators_IsNull(e.contents))e.contents=(o=Array_Helpers_allocateArrayFromCons(r,t),o.fill(_,0,0+t));else{const n=0|e.contents.length;if(t<n)e.contents=(i=e.contents,i.slice(0,0+t));else if(t>n){const o=Array_Helpers_allocateArrayFromCons(r,t);n>0&&copyTo(e.contents,0,o,0,n),e.contents=(s=0|n,a=t-n|0,o.fill(_,s,s+a))}}}const SR_enumerationAlreadyFinished="Enumeration already finished.",SR_enumerationNotStarted="Enumeration has not started. Call MoveNext.",Seq_SR_inputSequenceEmpty="The input sequence was empty.",Seq_SR_inputSequenceTooLong="The input sequence contains more than one element.",Seq_SR_keyNotFoundAlt="An index satisfying the predicate was not found in the collection.",Seq_SR_notEnoughElements="The input sequence has an insufficient number of elements.",SR_resetNotSupported="Reset is not supported on this enumerator.";function Enumerator_noReset(){throw NotSupportedException_$ctor_Z721C83C5(SR_resetNotSupported)}function Enumerator_notStarted(){throw InvalidOperationException_$ctor_Z721C83C5(SR_enumerationNotStarted)}function Enumerator_alreadyFinished(){throw InvalidOperationException_$ctor_Z721C83C5(SR_enumerationAlreadyFinished)}class Enumerator_Seq{constructor(e){this.f=e}toString(){let e=0,t="seq [";const n=getEnumerator(this);try{for(;e<4&&n["System.Collections.IEnumerator.MoveNext"]();)e>0&&(t+="; "),t+=Types_toString(n["System.Collections.Generic.IEnumerator`1.get_Current"]()),e=e+1|0;return 4===e&&(t+="; ..."),t+"]"}finally{disposeSafe(n)}}GetEnumerator(){return this.f()}[Symbol.iterator](){return toIterator(getEnumerator(this))}"System.Collections.IEnumerable.GetEnumerator"(){return this.f()}}function Enumerator_Seq_$reflection(e){return Seq_class_type("SeqModule.Enumerator.Seq",[e],Enumerator_Seq)}function Enumerator_Seq_$ctor_673A07F2(e){return new Enumerator_Seq(e)}class Enumerator_FromFunctions$1{constructor(e,t,n){this.current=e,this.next=t,this.dispose=n}"System.Collections.Generic.IEnumerator`1.get_Current"(){return this.current()}"System.Collections.IEnumerator.get_Current"(){return this.current()}"System.Collections.IEnumerator.MoveNext"(){return this.next()}"System.Collections.IEnumerator.Reset"(){Enumerator_noReset()}Dispose(){this.dispose()}}function Enumerator_FromFunctions$1_$reflection(e){return Seq_class_type("SeqModule.Enumerator.FromFunctions`1",[e],Enumerator_FromFunctions$1)}function Enumerator_FromFunctions$1_$ctor_58C54629(e,t,n){return new Enumerator_FromFunctions$1(e,t,n)}function Enumerator_cast(e){return Enumerator_FromFunctions$1_$ctor_58C54629(()=>e["System.Collections.Generic.IEnumerator`1.get_Current"](),()=>e["System.Collections.IEnumerator.MoveNext"](),()=>{Seq_disposeSafe(e)})}function Enumerator_concat(e){let t,n,r,o=!1,i=!1;const s=()=>{if(i=!0,null!=n){const e=Option_value(n);try{disposeSafe(e)}finally{n=void 0}}if(null!=t){const e=Option_value(t);try{disposeSafe(e)}finally{t=void 0}}};return Enumerator_FromFunctions$1_$ctor_58C54629(()=>(o?i&&Enumerator_alreadyFinished():Enumerator_notStarted(),null!=r?Option_value(r):Enumerator_alreadyFinished()),()=>{if(o||(o=!0),i)return!1;{let o;for(;null==o;){let i;const a=t;if(null!=a)if(null!=n){const e=Option_value(n);if(e["System.Collections.IEnumerator.MoveNext"]())r=some(e["System.Collections.Generic.IEnumerator`1.get_Current"]()),o=!0;else try{disposeSafe(e)}finally{n=void 0}}else{const e=Option_value(a);e["System.Collections.IEnumerator.MoveNext"]()?(i=e["System.Collections.Generic.IEnumerator`1.get_Current"](),n=getEnumerator(i)):(s(),o=!1)}else t=getEnumerator(e)}return Option_value(o)}},()=>{i||s()})}function Enumerator_enumerateThenFinally(e,t){return Enumerator_FromFunctions$1_$ctor_58C54629(()=>t["System.Collections.Generic.IEnumerator`1.get_Current"](),()=>t["System.Collections.IEnumerator.MoveNext"](),()=>{try{Seq_disposeSafe(t)}finally{e()}})}function Enumerator_generateWhileSome(e,t,n){let r,o=!1,i=some(e());const s=()=>{if(null!=i){const e=Option_value(i);try{n(e)}finally{i=void 0}}},a=()=>{try{s()}finally{r=void 0}};return Enumerator_FromFunctions$1_$ctor_58C54629(()=>(o||Enumerator_notStarted(),null!=r?Option_value(r):Enumerator_alreadyFinished()),()=>{if(o||(o=!0),null!=i){const e=Option_value(i);let n;try{n=t(e)}catch(e){throw a(),e}return null!=n?(r=n,!0):(a(),!1)}return!1},s)}function Enumerator_unfold(e,t){let n,r=t;return Enumerator_FromFunctions$1_$ctor_58C54629(()=>{if(null!=n){const e=Option_value(n)[0];return Option_value(n)[1],e}return Enumerator_notStarted()},()=>{if(n=e(r),null!=n){Option_value(n)[0];const e=Option_value(n)[1];return r=e,!0}return!1},()=>{})}function Seq_indexNotFound(){throw KeyNotFoundException_$ctor_Z721C83C5(Seq_SR_keyNotFoundAlt)}function mkSeq(e){return Enumerator_Seq_$ctor_673A07F2(e)}function ofSeq(e){return getEnumerator(Operators_NullArgCheck("source",e))}function delay(e){return mkSeq(()=>getEnumerator(e()))}function Seq_concat(e){return mkSeq(()=>Enumerator_concat(e))}function Seq_unfold(e,t){return mkSeq(()=>Enumerator_unfold(e,t))}function Seq_empty(){return delay(()=>new Array(0))}function Seq_singleton(e){return delay(()=>singleton(e))}function ofArray(e){return e}function Seq_toArray(e){return e instanceof List_FSharpList?List_toArray(e):Array.from(e)}function ofList(e){return e}function toList(e){return isArrayLike(e)?List_ofArray(e):e instanceof List_FSharpList?e:List_ofSeq(e)}function generate(e,t,n){return mkSeq(()=>Enumerator_generateWhileSome(e,t,n))}function generateIndexed(e,t,n){return mkSeq(()=>{let r=-1;return Enumerator_generateWhileSome(e,e=>(r=r+1|0,t(r,e)),n)})}function Seq_append(e,t){return Seq_concat([e,t])}function cast(e){return mkSeq(()=>Enumerator_cast(Seq_getEnumerator(Seq_Operators_NullArgCheck("source",e))))}function Seq_choose(e,t){return generate(()=>ofSeq(t),t=>{let n;for(;null==n&&t["System.Collections.IEnumerator.MoveNext"]();)n=e(t["System.Collections.Generic.IEnumerator`1.get_Current"]());return n},e=>{Seq_disposeSafe(e)})}function Seq_compareWith(e,t,n){const r=ofSeq(t);try{const t=ofSeq(n);try{let n=0,o=r["System.Collections.IEnumerator.MoveNext"](),i=t["System.Collections.IEnumerator.MoveNext"]();for(;0===n&&o&&i;)n=0|e(r["System.Collections.Generic.IEnumerator`1.get_Current"](),t["System.Collections.Generic.IEnumerator`1.get_Current"]()),0===n&&(o=r["System.Collections.IEnumerator.MoveNext"](),i=t["System.Collections.IEnumerator.MoveNext"]());return 0|(0!==n?n:o?1:i?-1:0)}finally{disposeSafe(t)}}finally{disposeSafe(r)}}function Seq_contains(e,t,n){const r=ofSeq(t);try{let t=!1;for(;!t&&r["System.Collections.IEnumerator.MoveNext"]();)t=n.Equals(e,r["System.Collections.Generic.IEnumerator`1.get_Current"]());return t}finally{Seq_disposeSafe(r)}}function enumerateFromFunctions(e,t,n){return generate(e,e=>t(e)?Seq_some(n(e)):void 0,e=>{const t=e;Seq_isDisposable(t)&&Seq_disposeSafe(t)})}function enumerateThenFinally(e,t){const n=t;return mkSeq(()=>{try{return Enumerator_enumerateThenFinally(n,ofSeq(e))}catch(e){throw n(),e}})}function enumerateUsing(e,t){const n=()=>{null==e||Seq_disposeSafe(e)};return mkSeq(()=>{try{return Enumerator_enumerateThenFinally(n,ofSeq(t(e)))}catch(e){throw n(),e}})}function enumerateWhile(e,t){return Seq_concat(Seq_unfold(n=>e()?[t,n+1]:void 0,0))}function enumerateTryWith(e,t,n){return mkSeq(()=>{let r,o,i=!1,s=!1,a=!1;const _=()=>{try{let t;if(null==r){const n=Seq_getEnumerator(e);r=n,t=n}else t=value_1(r);return t["System.Collections.IEnumerator.MoveNext"]()?(o=Seq_some(t["System.Collections.Generic.IEnumerator`1.get_Current"]()),!0):(a=!0,!1)}catch(e){if(i)throw e;{const o=e;if(0!==t(o)){if(i=!0,null==r);else{const e=value_1(r);try{Seq_disposeSafe(e)}catch(e){}r=void 0}return r=Seq_getEnumerator(n(o)),_()}throw e}}};return Enumerator_FromFunctions$1_$ctor_58C54629(()=>(s?a&&Enumerator_alreadyFinished():Enumerator_notStarted(),null!=o?value_1(o):Enumerator_alreadyFinished()),()=>(s||(s=!0),!a&&_()),()=>{null==r||Seq_disposeSafe(value_1(r))})})}function Seq_filter(e,t){return Seq_choose(t=>e(t)?Seq_some(t):void 0,t)}function Seq_exists(e,t){const n=ofSeq(t);try{let t=!1;for(;!t&&n["System.Collections.IEnumerator.MoveNext"]();)t=e(n["System.Collections.Generic.IEnumerator`1.get_Current"]());return t}finally{disposeSafe(n)}}function Seq_exists2(e,t,n){const r=ofSeq(t);try{const t=ofSeq(n);try{let n=!1;for(;!n&&r["System.Collections.IEnumerator.MoveNext"]()&&t["System.Collections.IEnumerator.MoveNext"]();)n=e(r["System.Collections.Generic.IEnumerator`1.get_Current"](),t["System.Collections.Generic.IEnumerator`1.get_Current"]());return n}finally{Seq_disposeSafe(t)}}finally{Seq_disposeSafe(r)}}function Seq_exactlyOne(e){const t=ofSeq(e);try{if(t["System.Collections.IEnumerator.MoveNext"]()){const e=t["System.Collections.Generic.IEnumerator`1.get_Current"]();if(t["System.Collections.IEnumerator.MoveNext"]())throw new Seq_Exception(Seq_SR_inputSequenceTooLong+" (Parameter 'source')");return e}throw new Seq_Exception(Seq_SR_inputSequenceEmpty+" (Parameter 'source')")}finally{Seq_disposeSafe(t)}}function Seq_tryExactlyOne(e){const t=ofSeq(e);try{if(t["System.Collections.IEnumerator.MoveNext"]()){const e=t["System.Collections.Generic.IEnumerator`1.get_Current"]();return t["System.Collections.IEnumerator.MoveNext"]()?void 0:Seq_some(e)}return}finally{Seq_disposeSafe(t)}}function Seq_tryFind(e,t){const n=ofSeq(t);try{let t;for(;null==t&&n["System.Collections.IEnumerator.MoveNext"]();){const r=n["System.Collections.Generic.IEnumerator`1.get_Current"]();e(r)&&(t=Seq_some(r))}return t}finally{Seq_disposeSafe(n)}}function Seq_find(e,t){const n=Seq_tryFind(e,t);return null==n?Seq_indexNotFound():value_1(n)}function Seq_tryFindBack(e,t){return tryFindBack_1(e,Seq_toArray(t))}function Seq_findBack(e,t){const n=Seq_tryFindBack(e,t);return null==n?Seq_indexNotFound():value_1(n)}function Seq_tryFindIndex(e,t){const n=ofSeq(t);try{return(t=>{for(;;){const r=t;if(!n["System.Collections.IEnumerator.MoveNext"]())return;if(e(n["System.Collections.Generic.IEnumerator`1.get_Current"]()))return r;t=r+1}})(0)}finally{Seq_disposeSafe(n)}}function Seq_findIndex(e,t){const n=Seq_tryFindIndex(e,t);return null==n?(Seq_indexNotFound(),-1):0|value_1(n)}function Seq_tryFindIndexBack(e,t){return tryFindIndexBack_1(e,Seq_toArray(t))}function Seq_findIndexBack(e,t){const n=Seq_tryFindIndexBack(e,t);return null==n?(Seq_indexNotFound(),-1):0|value_1(n)}function Seq_fold(e,t,n){const r=ofSeq(n);try{let n=t;for(;r["System.Collections.IEnumerator.MoveNext"]();)n=e(n,r["System.Collections.Generic.IEnumerator`1.get_Current"]());return n}finally{disposeSafe(r)}}function Seq_foldBack(e,t,n){return foldBack_1(e,Seq_toArray(t),n)}function Seq_fold2(e,t,n,r){const o=ofSeq(n);try{const n=ofSeq(r);try{let r=t;for(;o["System.Collections.IEnumerator.MoveNext"]()&&n["System.Collections.IEnumerator.MoveNext"]();)r=e(r,o["System.Collections.Generic.IEnumerator`1.get_Current"](),n["System.Collections.Generic.IEnumerator`1.get_Current"]());return r}finally{Seq_disposeSafe(n)}}finally{Seq_disposeSafe(o)}}function Seq_foldBack2(e,t,n,r){const o=Seq_toArray(t),i=Seq_toArray(n);let s=r;for(let t=(0|Seq_min_1(o.length,i.length))-1;t>=0;t--)s=e(item_1(t,o),item_1(t,i),s);return s}function Seq_forAll(e,t){return!Seq_exists(t=>!e(t),t)}function Seq_forAll2(e,t,n){return!Seq_exists2((t,n)=>!e(t,n),t,n)}function Seq_tryHead(e){if(Seq_isArrayLike(e))return tryHead_1(e);if(e instanceof FSharpList)return tryHead_2(e);{const t=ofSeq(e);try{return t["System.Collections.IEnumerator.MoveNext"]()?Seq_some(t["System.Collections.Generic.IEnumerator`1.get_Current"]()):void 0}finally{Seq_disposeSafe(t)}}}function Seq_head(e){const t=Seq_tryHead(e);if(null==t)throw new Seq_Exception(Seq_SR_inputSequenceEmpty+" (Parameter 'source')");return value_1(t)}function Seq_initialize(e,t){return Seq_unfold(n=>n<e?[t(n),n+1]:void 0,0)}function initializeInfinite(e){return Seq_initialize(2147483647,e)}function Seq_isEmpty(e){if(Seq_isArrayLike(e))return 0===e.length;if(e instanceof FSharpList)return isEmpty_1(e);{const t=ofSeq(e);try{return!t["System.Collections.IEnumerator.MoveNext"]()}finally{Seq_disposeSafe(t)}}}function Seq_tryItem(e,t){if(Seq_isArrayLike(t))return tryItem_1(e,t);if(t instanceof FSharpList)return tryItem_2(e,t);{const n=ofSeq(t);try{return(e=>{for(;;){const t=e;if(!n["System.Collections.IEnumerator.MoveNext"]())return;if(0===t)return Seq_some(n["System.Collections.Generic.IEnumerator`1.get_Current"]());e=t-1}})(e)}finally{Seq_disposeSafe(n)}}}function Seq_item(e,t){const n=Seq_tryItem(e,t);if(null==n)throw new Seq_Exception(Seq_SR_notEnoughElements+" (Parameter 'index')");return value_1(n)}function Seq_iterate(e,t){Seq_fold((t,n)=>{e(n)},void 0,t)}function Seq_iterate2(e,t,n){Seq_fold2((t,n,r)=>{e(n,r)},void 0,t,n)}function Seq_iterateIndexed(e,t){Seq_fold((t,n)=>(e(t,n),t+1|0),0,t)}function Seq_iterateIndexed2(e,t,n){Seq_fold2((t,n,r)=>(e(t,n,r),t+1|0),0,t,n)}function Seq_tryLast(e){const t=ofSeq(e);try{const e=e=>{for(;;){const n=e;if(!t["System.Collections.IEnumerator.MoveNext"]())return n;e=t["System.Collections.Generic.IEnumerator`1.get_Current"]()}};return t["System.Collections.IEnumerator.MoveNext"]()?Seq_some(e(t["System.Collections.Generic.IEnumerator`1.get_Current"]())):void 0}finally{Seq_disposeSafe(t)}}function Seq_last(e){const t=Seq_tryLast(e);if(null==t)throw new Seq_Exception(Seq_SR_notEnoughElements+" (Parameter 'source')");return value_1(t)}function Seq_length(e){if(Seq_isArrayLike(e))return 0|e.length;if(e instanceof FSharpList)return 0|length_1(e);{const t=ofSeq(e);try{let e=0;for(;t["System.Collections.IEnumerator.MoveNext"]();)e=e+1|0;return 0|e}finally{Seq_disposeSafe(t)}}}function Seq_map(e,t){return generate(()=>ofSeq(t),t=>t["System.Collections.IEnumerator.MoveNext"]()?some(e(t["System.Collections.Generic.IEnumerator`1.get_Current"]())):void 0,e=>{disposeSafe(e)})}function Seq_mapIndexed(e,t){return generateIndexed(()=>ofSeq(t),(t,n)=>n["System.Collections.IEnumerator.MoveNext"]()?Seq_some(e(t,n["System.Collections.Generic.IEnumerator`1.get_Current"]())):void 0,e=>{Seq_disposeSafe(e)})}function Seq_indexed(e){return Seq_mapIndexed((e,t)=>[e,t],e)}function Seq_map2(e,t,n){return generate(()=>[ofSeq(t),ofSeq(n)],t=>{const n=t[0],r=t[1];return n["System.Collections.IEnumerator.MoveNext"]()&&r["System.Collections.IEnumerator.MoveNext"]()?Seq_some(e(n["System.Collections.Generic.IEnumerator`1.get_Current"](),r["System.Collections.Generic.IEnumerator`1.get_Current"]())):void 0},e=>{try{Seq_disposeSafe(e[0])}finally{Seq_disposeSafe(e[1])}})}function Seq_mapIndexed2(e,t,n){return generateIndexed(()=>[ofSeq(t),ofSeq(n)],(t,n)=>{const r=n[0],o=n[1];return r["System.Collections.IEnumerator.MoveNext"]()&&o["System.Collections.IEnumerator.MoveNext"]()?Seq_some(e(t,r["System.Collections.Generic.IEnumerator`1.get_Current"](),o["System.Collections.Generic.IEnumerator`1.get_Current"]())):void 0},e=>{try{Seq_disposeSafe(e[0])}finally{Seq_disposeSafe(e[1])}})}function Seq_map3(e,t,n,r){return generate(()=>[ofSeq(t),ofSeq(n),ofSeq(r)],t=>{const n=t[0],r=t[1],o=t[2];return n["System.Collections.IEnumerator.MoveNext"]()&&r["System.Collections.IEnumerator.MoveNext"]()&&o["System.Collections.IEnumerator.MoveNext"]()?Seq_some(e(n["System.Collections.Generic.IEnumerator`1.get_Current"](),r["System.Collections.Generic.IEnumerator`1.get_Current"](),o["System.Collections.Generic.IEnumerator`1.get_Current"]())):void 0},e=>{try{Seq_disposeSafe(e[0])}finally{try{Seq_disposeSafe(e[1])}finally{Seq_disposeSafe(e[2])}}})}function readOnly(e){return Seq_map(e=>e,Seq_Operators_NullArgCheck("source",e))}class CachedSeq$1{constructor(e,t){this.cleanup=e,this.res=t}Dispose(){this.cleanup()}GetEnumerator(){return getEnumerator(this.res)}[Symbol.iterator](){return toIterator(getEnumerator(this))}"System.Collections.IEnumerable.GetEnumerator"(){return getEnumerator(this.res)}}function CachedSeq$1_$reflection(e){return Seq_class_type("SeqModule.CachedSeq`1",[e],CachedSeq$1)}function CachedSeq$1_$ctor_Z7A8347D4(e,t){return new CachedSeq$1(e,t)}function CachedSeq$1__Clear(e){e.cleanup()}function cache(e){const t=Seq_Operators_NullArgCheck("source",e),n=[];let r;return CachedSeq$1_$ctor_Z7A8347D4(()=>{Seq_Operators_Lock(n,()=>{let e,t;Seq_clear(n),null!=r&&null!=value_1(r)?(e=0,t=value_1(value_1(r))):e=1,0===e&&Seq_disposeSafe(t),r=void 0})},Seq_unfold(e=>Seq_Operators_Lock(n,()=>{if(e<n.length)return[item_1(e,n),e+1];if(e>=n.length){let e;if(null!=r)e=value_1(r);else{const n=Seq_getEnumerator(t);r=Seq_some(n),e=n}if(null==e);else{const t=value_1(e);t["System.Collections.IEnumerator.MoveNext"]()?n.push(t["System.Collections.Generic.IEnumerator`1.get_Current"]()):(Seq_disposeSafe(t),r=Seq_some(void 0))}}return e<n.length?[item_1(e,n),e+1]:void 0}),0))}function Seq_allPairs(e,t){const n=cache(t);return delay(()=>Seq_concat(Seq_map(e=>Seq_map(t=>[e,t],n),e)))}function Seq_mapFold(e,t,n){const r=mapFold_1(e,t,Seq_toArray(n));return[readOnly(r[0]),r[1]]}function Seq_mapFoldBack(e,t,n){const r=mapFoldBack_1(e,Seq_toArray(t),n);return[readOnly(r[0]),r[1]]}function Seq_tryPick(e,t){const n=ofSeq(t);try{let t;for(;null==t&&n["System.Collections.IEnumerator.MoveNext"]();)t=e(n["System.Collections.Generic.IEnumerator`1.get_Current"]());return t}finally{Seq_disposeSafe(n)}}function Seq_pick(e,t){const n=Seq_tryPick(e,t);return null==n?Seq_indexNotFound():value_1(n)}function Seq_reduce(e,t){const n=ofSeq(t);try{const t=t=>{for(;;){const r=t;if(!n["System.Collections.IEnumerator.MoveNext"]())return r;t=e(r,n["System.Collections.Generic.IEnumerator`1.get_Current"]())}};if(n["System.Collections.IEnumerator.MoveNext"]())return t(n["System.Collections.Generic.IEnumerator`1.get_Current"]());throw new Exception(Seq_SR_inputSequenceEmpty)}finally{disposeSafe(n)}}function Seq_reduceBack(e,t){const n=Seq_toArray(t);if(n.length>0)return n.reduceRight(e);throw new Seq_Exception(Seq_SR_inputSequenceEmpty)}function Seq_replicate(e,t){return Seq_initialize(e,e=>t)}function Seq_reverse(e){return delay(()=>ofArray(reverse_1(Seq_toArray(e))))}function Seq_scan(e,t,n){return delay(()=>{let r=t;return Seq_concat([Seq_singleton(t),Seq_map(t=>(r=e(r,t),r),n)])})}function Seq_scanBack(e,t,n){return delay(()=>ofArray(scanBack_1(e,Seq_toArray(t),n)))}function Seq_skip(e,t){return mkSeq(()=>{const n=ofSeq(t);try{for(let t=1;t<=e;t++)if(!n["System.Collections.IEnumerator.MoveNext"]())throw new Seq_Exception(Seq_SR_notEnoughElements+" (Parameter 'source')");return Enumerator_enumerateThenFinally(()=>{},n)}catch(e){throw Seq_disposeSafe(n),e}})}function Seq_skipWhile(e,t){return delay(()=>{let n=!0;return Seq_filter(t=>(n&&(n=e(t)),!n),t)})}function Seq_tail(e){return Seq_skip(1,e)}function Seq_take(e,t){return generateIndexed(()=>ofSeq(t),(t,n)=>{if(t<e){if(n["System.Collections.IEnumerator.MoveNext"]())return Seq_some(n["System.Collections.Generic.IEnumerator`1.get_Current"]());throw new Seq_Exception(Seq_SR_notEnoughElements+" (Parameter 'source')")}},e=>{Seq_disposeSafe(e)})}function Seq_takeWhile(e,t){return generate(()=>ofSeq(t),t=>t["System.Collections.IEnumerator.MoveNext"]()&&e(t["System.Collections.Generic.IEnumerator`1.get_Current"]())?Seq_some(t["System.Collections.Generic.IEnumerator`1.get_Current"]()):void 0,e=>{Seq_disposeSafe(e)})}function Seq_truncate(e,t){return generateIndexed(()=>ofSeq(t),(t,n)=>t<e&&n["System.Collections.IEnumerator.MoveNext"]()?Seq_some(n["System.Collections.Generic.IEnumerator`1.get_Current"]()):void 0,e=>{Seq_disposeSafe(e)})}function Seq_zip(e,t){return Seq_map2((e,t)=>[e,t],e,t)}function Seq_zip3(e,t,n){return Seq_map3((e,t,n)=>[e,t,n],e,t,n)}function Seq_collect(e,t){return delay(()=>Seq_concat(Seq_map(e,t)))}function Seq_where(e,t){return Seq_filter(e,t)}function Seq_pairwise(e){return delay(()=>ofArray(pairwise_1(Seq_toArray(e))))}function Seq_splitInto(e,t){return delay(()=>ofArray(splitInto_1(e,Seq_toArray(t))))}function Seq_windowed(e,t){return delay(()=>ofArray(windowed_1(e,Seq_toArray(t))))}function Seq_transpose(e){return delay(()=>ofArray(map_1(ofArray,transpose_1(map_1(Seq_toArray,Seq_toArray(e))))))}function Seq_sortWith(e,t){return delay(()=>{const n=Seq_toArray(t);return n.sort(e),ofArray(n)})}function Seq_sort(e,t){return Seq_sortWith((e,n)=>0|t.Compare(e,n),e)}function Seq_sortBy(e,t,n){return Seq_sortWith((t,r)=>0|n.Compare(e(t),e(r)),t)}function Seq_sortDescending(e,t){return Seq_sortWith((e,n)=>-1*t.Compare(e,n)|0,e)}function Seq_sortByDescending(e,t,n){return Seq_sortWith((t,r)=>-1*n.Compare(e(t),e(r))|0,t)}function Seq_sum(e,t){return Seq_fold((e,n)=>t.Add(e,n),t.GetZero(),e)}function Seq_sumBy(e,t,n){return Seq_fold((t,r)=>n.Add(t,e(r)),n.GetZero(),t)}function Seq_maxBy(e,t,n){return Seq_reduce((t,r)=>n.Compare(e(r),e(t))>0?r:t,t)}function Seq_max(e,t){return Seq_reduce((e,n)=>t.Compare(n,e)>0?n:e,e)}function Seq_minBy(e,t,n){return Seq_reduce((t,r)=>n.Compare(e(r),e(t))>0?t:r,t)}function Seq_min(e,t){return Seq_reduce((e,n)=>t.Compare(n,e)>0?e:n,e)}function Seq_average(e,t){let n=0;const r=Seq_fold((e,r)=>(n=n+1|0,t.Add(e,r)),t.GetZero(),e);if(0===n)throw new Seq_Exception(Seq_SR_inputSequenceEmpty+" (Parameter 'source')");return t.DivideByInt(r,n)}function Seq_averageBy(e,t,n){let r=0;const o=Seq_fold((t,o)=>(r=r+1|0,n.Add(t,e(o))),n.GetZero(),t);if(0===r)throw new Seq_Exception(Seq_SR_inputSequenceEmpty+" (Parameter 'source')");return n.DivideByInt(o,r)}function Seq_permute(e,t){return delay(()=>ofArray(permute_1(e,Seq_toArray(t))))}function Seq_chunkBySize(e,t){return delay(()=>ofArray(chunkBySize_1(e,Seq_toArray(t))))}function Seq_insertAt(e,t,n){let r=!1;if(e<0)throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'index')");return generateIndexed(()=>ofSeq(n),(n,o)=>{if((r||n<e)&&o["System.Collections.IEnumerator.MoveNext"]())return Seq_some(o["System.Collections.Generic.IEnumerator`1.get_Current"]());if(n===e)return r=!0,Seq_some(t);if(!r)throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'index')")},e=>{Seq_disposeSafe(e)})}function Seq_insertManyAt(e,t,n){let r=-1;if(e<0)throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'index')");return generateIndexed(()=>[ofSeq(n),ofSeq(t)],(t,n)=>{const o=n[0],i=n[1];let s;if(t===e&&(r=0),0===r?i["System.Collections.IEnumerator.MoveNext"]()?s=Seq_some(i["System.Collections.Generic.IEnumerator`1.get_Current"]()):(r=1,s=void 0):s=void 0,null!=s)return Seq_some(value_1(s));if(o["System.Collections.IEnumerator.MoveNext"]())return Seq_some(o["System.Collections.Generic.IEnumerator`1.get_Current"]());if(r<1)throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'index')")},e=>{Seq_disposeSafe(e[0]),Seq_disposeSafe(e[1])})}function Seq_removeAt(e,t){let n=!1;if(e<0)throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'index')");return generateIndexed(()=>ofSeq(t),(t,r)=>{if((n||t<e)&&r["System.Collections.IEnumerator.MoveNext"]())return Seq_some(r["System.Collections.Generic.IEnumerator`1.get_Current"]());if(t===e&&r["System.Collections.IEnumerator.MoveNext"]())return n=!0,r["System.Collections.IEnumerator.MoveNext"]()?Seq_some(r["System.Collections.Generic.IEnumerator`1.get_Current"]()):void 0;if(!n)throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'index')")},e=>{Seq_disposeSafe(e)})}function Seq_removeManyAt(e,t,n){if(e<0)throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'index')");return generateIndexed(()=>ofSeq(n),(n,r)=>{if(n<e){if(r["System.Collections.IEnumerator.MoveNext"]())return Seq_some(r["System.Collections.Generic.IEnumerator`1.get_Current"]());throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'index')")}if(n===e)for(let e=1;e<=t;e++)if(!r["System.Collections.IEnumerator.MoveNext"]())throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'count')");return r["System.Collections.IEnumerator.MoveNext"]()?Seq_some(r["System.Collections.Generic.IEnumerator`1.get_Current"]()):void 0},e=>{Seq_disposeSafe(e)})}function Seq_updateAt(e,t,n){let r=!1;if(e<0)throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'index')");return generateIndexed(()=>ofSeq(n),(n,o)=>{if((r||n<e)&&o["System.Collections.IEnumerator.MoveNext"]())return Seq_some(o["System.Collections.Generic.IEnumerator`1.get_Current"]());if(n===e&&o["System.Collections.IEnumerator.MoveNext"]())return r=!0,Seq_some(t);if(!r)throw new Seq_Exception(Seq_SR_indexOutOfBounds+" (Parameter 'index')")},e=>{Seq_disposeSafe(e)})}function Seq_randomShuffleBy(e,t){const n=Seq_toArray(t);return Seq_randomShuffleInPlaceBy(e,n),ofArray(n)}function Seq_randomShuffleWith(e,t){return Seq_randomShuffleBy(()=>e.NextDouble(),t)}function Seq_randomShuffle(e){return Seq_randomShuffleWith(Seq_nonSeeded(),e)}function Seq_randomChoiceBy(e,t){return randomChoiceBy_1(e,Seq_toArray(t))}function Seq_randomChoiceWith(e,t){return randomChoiceWith_1(e,Seq_toArray(t))}function Seq_randomChoice(e){return randomChoice_1(Seq_toArray(e))}function Seq_randomChoicesBy(e,t,n){return ofArray(randomChoicesBy_1(e,t,Seq_toArray(n)))}function Seq_randomChoicesWith(e,t,n){return Seq_randomChoicesBy(()=>e.NextDouble(),t,n)}function Seq_randomChoices(e,t){return Seq_randomChoicesWith(Seq_nonSeeded(),e,t)}function Seq_randomSampleBy(e,t,n){return ofArray(randomSampleBy_1(e,t,Seq_toArray(n)))}function Seq_randomSampleWith(e,t,n){return Seq_randomSampleBy(()=>e.NextDouble(),t,n)}function Seq_randomSample(e,t){return Seq_randomSampleWith(Seq_nonSeeded(),e,t)}var System_Collections_Generic_compare,equals_1,System_Collections_Generic_structuralHash,System_Collections_Generic_defaultOf,System_Collections_Generic_Exception,System_Collections_Generic_getEnumerator,System_Collections_Generic_disposeSafe,System_Collections_Generic_class_type,System_Collections_Generic_toArray,System_Collections_Generic_fill,System_Collections_Generic_copyTo,System_Collections_Generic_item_1,System_Collections_Generic_initialize,System_Collections_Generic_setItem,System_Collections_Generic_max,System_Collections_Generic_ArgumentOutOfRangeException_$ctor_Z721C83C5,List_Exception,List_isArrayLike,List_getEnumerator,List_disposeSafe,List_value_1,List_defaultArg,List_some,record_type,option_type,List_class_type,List_SR_inputWasEmpty,List_SR_differentLengths,List_SR_notEnoughElements,List_SR_inputMustBeNonNegative,List_SR_inputSequenceEmpty,List_SR_inputSequenceTooLong,List_SR_indexOutOfBounds,List_foldBack_1,foldBack2_1,List_scanBack_1,List_tryFindBack_1,List_tryFindIndexBack_1,List_permute_1,List_map_1,List_chunkBySize_1,List_windowed_1,List_splitInto_1,List_transpose_1,List_randomShuffleInPlaceBy,List_randomChoiceBy_1,List_randomChoicesBy_1,List_randomSampleBy_1,List_nonSeeded,Set_class_type,Set_record_type,list_type,Set_option_type,bool_type,Set_value_2,Set_some,Set_Exception,Set_fill,Set_setItem,Set_reduce,fold_3,Set_map_1,iterate_1,forAll_1,exists_1,Set_iterateIndexed,Set_truncate,Set_skip,HashSet,HashSet_$ctor_Z6150332D,HashSet__get_Comparer,Map_class_type,Map_record_type,Map_list_type,Map_option_type,Map_bool_type,Map_value_1,Map_some,Map_KeyNotFoundException_$ctor,Map_fill,map_2,Map_unfold,Map_map_1,pick_1,tryPick_1;class KeyNotFoundException extends Exception{constructor(e){super(e)}}function KeyNotFoundException_$reflection(){return System_Collections_Generic_class_type("System.Collections.Generic.KeyNotFoundException",void 0,KeyNotFoundException,System_Collections_Generic_class_type("System.Exception"))}function System_Collections_Generic_KeyNotFoundException_$ctor_Z721C83C5(e){return new KeyNotFoundException(e)}function KeyNotFoundException_$ctor(){return System_Collections_Generic_KeyNotFoundException_$ctor_Z721C83C5(SR_Arg_KeyNotFound)}class Comparer$1{constructor(e){this.comparison=e}Compare(e,t){return 0|(null==e?null==t?0:-1:null==t?1:this.comparison(e,t))}}function Comparer$1_$reflection(e){return System_Collections_Generic_class_type("System.Collections.Generic.Comparer`1",[e],Comparer$1)}function Comparer$1_$ctor_47C913C(e){return new Comparer$1(e)}function Comparer$1_get_Default(){return Comparer$1_$ctor_47C913C((e,t)=>0|System_Collections_Generic_compare(e,t))}function Comparer$1_Create_47C913C(e){return Comparer$1_$ctor_47C913C(e)}function Comparer$1__Compare_5BDDA0(e,t,n){return 0|e.comparison(t,n)}class EqualityComparer$1{constructor(e,t){this.equals=e,this.getHashCode=t}Equals(e,t){return null==e?null==t:null!=t&&this.equals(e,t)}GetHashCode(e){return 0|this.getHashCode(e)}}function EqualityComparer$1_$reflection(e){return System_Collections_Generic_class_type("System.Collections.Generic.EqualityComparer`1",[e],EqualityComparer$1)}function EqualityComparer$1_$ctor_Z6EE254AB(e,t){return new EqualityComparer$1(e,t)}function EqualityComparer$1_get_Default(){return EqualityComparer$1_$ctor_Z6EE254AB(equals_1,e=>0|System_Collections_Generic_structuralHash(e))}function EqualityComparer$1_Create_Z6EE254AB(e,t){return EqualityComparer$1_$ctor_Z6EE254AB(e,t)}function EqualityComparer$1__Equals_5BDDA0(e,t,n){return e.equals(t,n)}function EqualityComparer$1__GetHashCode_2B595(e,t){return 0|e.getHashCode(t)}class Stack$1{constructor(e,t){this.contents=e,this.count=0|t}GetEnumerator(){const e=this;return getEnumerator(delay(()=>{let t=e.count-1;return enumerateWhile(()=>t>=0,delay(()=>Seq_append(Seq_singleton(item(t,e.contents)),delay(()=>(t=t-1|0,Seq_empty())))))}))}[Symbol.iterator](){return toIterator(getEnumerator(this))}"System.Collections.IEnumerable.GetEnumerator"(){return getEnumerator(this)}}function Stack$1_$reflection(e){return System_Collections_Generic_class_type("System.Collections.Generic.Stack`1",[e],Stack$1)}function Stack$1_$ctor_Z3B4C077E(e,t){return new Stack$1(e,t)}function Stack$1_$ctor_Z524259A4(e){return Stack$1_$ctor_Z3B4C077E(System_Collections_Generic_fill(new Array(e),0,e,null),0)}function Stack$1_$ctor(){return Stack$1_$ctor_Z524259A4(4)}function Stack$1_$ctor_BB573A(e){const t=Array.from(e);return Stack$1_$ctor_Z3B4C077E(t,t.length)}function Stack$1__Ensure_Z524259A4(e,t){const n=0|e.contents.length;if(t>n){const r=e.contents;e.contents=System_Collections_Generic_fill(new Array(System_Collections_Generic_max(t,2*n)),0,System_Collections_Generic_max(t,2*n),null),System_Collections_Generic_copyTo(r,0,e.contents,0,e.count)}}function Stack$1__get_Count(e){return 0|e.count}function Stack$1__Pop(e){return e.count=e.count-1|0,System_Collections_Generic_item_1(e.count,e.contents)}function Stack$1__Peek(e){return System_Collections_Generic_item_1(e.count-1,e.contents)}function Stack$1__Contains_2B595(e,t){let n=!1,r=0;for(;r<e.count&&!n;)equals_1(t,System_Collections_Generic_item_1(r,e.contents))?n=!0:r=r+1|0;return n}function Stack$1__TryPeek_1F3DB691(e,t){return e.count>0&&(t.contents=Stack$1__Peek(e),!0)}function Stack$1__TryPop_1F3DB691(e,t){return e.count>0&&(t.contents=Stack$1__Pop(e),!0)}function Stack$1__Push_2B595(e,t){Stack$1__Ensure_Z524259A4(e,e.count+1),e.contents[e.count]=t,e.count=e.count+1|0}function Stack$1__Clear(e){e.count=0,System_Collections_Generic_fill(e.contents,0,e.contents.length,System_Collections_Generic_defaultOf())}function Stack$1__TrimExcess(e){e.count/e.contents.length>.9&&Stack$1__Ensure_Z524259A4(e,e.count)}function Stack$1__ToArray(e){return System_Collections_Generic_initialize(e.count,t=>System_Collections_Generic_item_1(e.count-1-t,e.contents))}class Queue$1{constructor(e,t){this.contents=e,this.count=0|t,this.head=0,this.tail=0|(t===this.contents.length?0:t)}GetEnumerator(){return getEnumerator(Queue$1__toSeq(this))}[Symbol.iterator](){return toIterator(getEnumerator(this))}"System.Collections.IEnumerable.GetEnumerator"(){return getEnumerator(this)}}function Queue$1_$reflection(e){return System_Collections_Generic_class_type("System.Collections.Generic.Queue`1",[e],Queue$1)}function Queue$1_$ctor_Z3B4C077E(e,t){return new Queue$1(e,t)}function Queue$1_$ctor_Z524259A4(e){if(e<0)throw System_Collections_Generic_ArgumentOutOfRangeException_$ctor_Z721C83C5("capacity is less than 0");return Queue$1_$ctor_Z3B4C077E(System_Collections_Generic_fill(new Array(e),0,e,null),0)}function Queue$1_$ctor(){return Queue$1_$ctor_Z524259A4(4)}function Queue$1_$ctor_BB573A(e){const t=Array.from(e);return Queue$1_$ctor_Z3B4C077E(t,t.length)}function Queue$1__get_Count(e){return 0|e.count}function Queue$1__Enqueue_2B595(e,t){e.count===Queue$1__size(e)&&Queue$1__ensure_Z524259A4(e,e.count+1),e.contents[e.tail]=t,e.tail=(e.tail+1)%Queue$1__size(e)|0,e.count=e.count+1|0}function Queue$1__Dequeue(e){if(0===e.count)throw new System_Collections_Generic_Exception("Queue is empty");const t=System_Collections_Generic_item_1(e.head,e.contents);return e.head=(e.head+1)%Queue$1__size(e)|0,e.count=e.count-1|0,t}function Queue$1__Peek(e){if(0===e.count)throw new System_Collections_Generic_Exception("Queue is empty");return System_Collections_Generic_item_1(e.head,e.contents)}function Queue$1__TryDequeue_1F3DB691(e,t){return 0!==e.count&&(t.contents=Queue$1__Dequeue(e),!0)}function Queue$1__TryPeek_1F3DB691(e,t){return 0!==e.count&&(t.contents=Queue$1__Peek(e),!0)}function Queue$1__Contains_2B595(e,t){let n=!1,r=0;for(;r<e.count&&!n;)equals_1(t,System_Collections_Generic_item_1(Queue$1__toIndex_Z524259A4(e,r),e.contents))?n=!0:r=r+1|0;return n}function Queue$1__Clear(e){e.count=0,e.head=0,e.tail=0,System_Collections_Generic_fill(e.contents,0,Queue$1__size(e),System_Collections_Generic_defaultOf())}function Queue$1__TrimExcess(e){e.count/e.contents.length>.9&&Queue$1__ensure_Z524259A4(e,e.count)}function Queue$1__ToArray(e){return System_Collections_Generic_toArray(Queue$1__toSeq(e))}function Queue$1__CopyTo_Z3B4C077E(e,t,n){let r=n;const o=System_Collections_Generic_getEnumerator(Queue$1__toSeq(e));try{for(;o["System.Collections.IEnumerator.MoveNext"]();){const e=o["System.Collections.Generic.IEnumerator`1.get_Current"]();System_Collections_Generic_setItem(t,r,e),r=r+1|0}}finally{System_Collections_Generic_disposeSafe(o)}}function Queue$1__size(e){return 0|e.contents.length}function Queue$1__toIndex_Z524259A4(e,t){return(e.head+t)%Queue$1__size(e)|0}function Queue$1__ensure_Z524259A4(e,t){const n=System_Collections_Generic_fill(new Array(t),0,t,null);e.head<e.tail?System_Collections_Generic_copyTo(e.contents,e.head,n,0,e.count):(System_Collections_Generic_copyTo(e.contents,e.head,n,0,Queue$1__size(e)-e.head),System_Collections_Generic_copyTo(e.contents,0,n,Queue$1__size(e)-e.head,e.tail)),e.head=0,e.contents=n,e.tail=0|(e.count===Queue$1__size(e)?0:e.count)}function Queue$1__toSeq(e){return delay(()=>{let t=0;return enumerateWhile(()=>t<e.count,delay(()=>Seq_append(Seq_singleton(item(Queue$1__toIndex_Z524259A4(e,t),e.contents)),delay(()=>(t=t+1|0,Seq_empty())))))})}class List_FSharpList extends Record{constructor(e,t){super(),this.head=e,this.tail=t}toString(){let e="[",t=!0;const n=getEnumerator(this);try{for(;n["System.Collections.IEnumerator.MoveNext"]();){let r,o,i;e=(t?e:e+"; ")+(r=n["System.Collections.Generic.IEnumerator`1.get_Current"](),o=r,"string"==typeof o?(i=o,'"'+i+'"'):Types_toString(r)),t=!1}}finally{disposeSafe(n)}return e+"]"}Equals(e){const t=this;return t===e||e instanceof List_FSharpList&&((e,t)=>{e:for(;;){const n=e,r=t,o=n.tail,i=r.tail;if(null!=o){if(null!=i){const s=Option_value(o),a=Option_value(i);if(equals(n.head,r.head)){e=s,t=a;continue e}return!1}return!1}return null==i}})(t,e)}GetHashCode(){return 0|((e,t,n)=>{e:for(;;){const r=e,o=t,i=n,s=i.tail;if(null!=s){const a=Option_value(s);if(r>18)return 0|o;e=r+1,t=(o<<1)+structuralHash(i.head)+631*r,n=a;continue e}return 0|o}})(0,0,this)}toJSON(){return Array.from(this)}CompareTo(e){return e instanceof List_FSharpList?0|((e,t)=>{e:for(;;){const n=e,r=t,o=n.tail,i=r.tail;if(null!=o){if(null!=i){const s=Option_value(o),a=Option_value(i),_=0|compare(n.head,r.head);if(0===_){e=s,t=a;continue e}return 0|_}return 1}return null!=i?-1:0}})(this,e):1}GetEnumerator(){return ListEnumerator$1_$ctor_3002E699(this)}[Symbol.iterator](){return toIterator(getEnumerator(this))}"System.Collections.IEnumerable.GetEnumerator"(){return getEnumerator(this)}}function FSharpList_$reflection(e){return record_type("ListModule.FSharpList",[e],List_FSharpList,()=>[["head",e],["tail",option_type(FSharpList_$reflection(e))]])}class ListEnumerator$1{constructor(e){this.xs=e,this.it=this.xs,this.current=defaultOf()}"System.Collections.Generic.IEnumerator`1.get_Current"(){return this.current}"System.Collections.IEnumerator.get_Current"(){return this.current}"System.Collections.IEnumerator.MoveNext"(){const e=this,t=e.it.tail;if(null!=t){const n=Option_value(t);return e.current=e.it.head,e.it=n,!0}return!1}"System.Collections.IEnumerator.Reset"(){const e=this;e.it=e.xs,e.current=defaultOf()}Dispose(){}}function ListEnumerator$1_$reflection(e){return List_class_type("ListModule.ListEnumerator`1",[e],ListEnumerator$1)}function ListEnumerator$1_$ctor_3002E699(e){return new ListEnumerator$1(e)}function FSharpList_get_Empty(){return new List_FSharpList(defaultOf(),void 0)}function FSharpList_Cons_305B8EAC(e,t){return new List_FSharpList(e,t)}function FSharpList__get_IsEmpty(e){return null==e.tail}function FSharpList__get_Length(e){return 0|((e,t)=>{for(;;){const n=e,r=t.tail;if(null==r)return 0|n;e=n+1,t=Option_value(r)}})(0,e)}function FSharpList__get_Head(e){if(null!=e.tail)return e.head;throw new Exception(SR_inputWasEmpty+" (Parameter 'list')")}function FSharpList__get_Tail(e){const t=e.tail;if(null!=t)return Option_value(t);throw new Exception(SR_inputWasEmpty+" (Parameter 'list')")}function FSharpList__get_Item_Z524259A4(e,t){return((e,n)=>{e:for(;;){const r=e,o=n,i=o.tail;if(null!=i){const s=Option_value(i);if(r===t)return o.head;e=r+1,n=s;continue e}throw new Exception(SR_indexOutOfBounds+" (Parameter 'index')")}})(0,e)}function List_indexNotFound(){throw System_Collections_Generic_KeyNotFoundException_$ctor_Z721C83C5(SR_keyNotFoundAlt)}function List_empty(){return FSharpList_get_Empty()}function cons(e,t){return FSharpList_Cons_305B8EAC(e,t)}function List_singleton(e){return FSharpList_Cons_305B8EAC(e,FSharpList_get_Empty())}function List_isEmpty(e){return FSharpList__get_IsEmpty(e)}function List_length(e){return 0|FSharpList__get_Length(e)}function List_head(e){return FSharpList__get_Head(e)}function List_tryHead(e){return FSharpList__get_IsEmpty(e)?void 0:some(FSharpList__get_Head(e))}function List_tail(e){return FSharpList__get_Tail(e)}function List_tryLast(e){e:for(;;){const t=e;if(FSharpList__get_IsEmpty(t))return;{const n=FSharpList__get_Tail(t);if(FSharpList__get_IsEmpty(n))return some(FSharpList__get_Head(t));e=n;continue e}}}function List_last(e){const t=List_tryLast(e);if(null==t)throw new List_Exception(List_SR_inputWasEmpty);return List_value_1(t)}function List_compareWith(e,t,n){return 0|((t,n)=>{e:for(;;){const r=t,o=n,i=FSharpList__get_IsEmpty(r),s=FSharpList__get_IsEmpty(o);if(i)return s?0:-1;if(s)return 1;{const i=0|e(FSharpList__get_Head(r),FSharpList__get_Head(o));if(0===i){t=FSharpList__get_Tail(r),n=FSharpList__get_Tail(o);continue e}return 0|i}}})(t,n)}function List_toArray(e){const t=0|FSharpList__get_Length(e),n=fill(new Array(t),0,t,null);return((e,t)=>{for(;;){const r=e,o=t;if(FSharpList__get_IsEmpty(o))break;setItem(n,r,FSharpList__get_Head(o)),e=r+1,t=FSharpList__get_Tail(o)}})(0,e),n}function List_fold(e,t,n){let r=t,o=n;for(;!FSharpList__get_IsEmpty(o);)r=e(r,List_head(o)),o=FSharpList__get_Tail(o);return r}function List_reverse(e){return List_fold((e,t)=>FSharpList_Cons_305B8EAC(t,e),FSharpList_get_Empty(),e)}function List_foldBack(e,t,n){return List_foldBack_1(e,List_toArray(t),n)}function List_foldIndexed(e,t,n){return((t,n,r)=>{for(;;){const o=t,i=n,s=r;if(FSharpList__get_IsEmpty(s))return i;t=o+1,n=e(o,i,FSharpList__get_Head(s)),r=FSharpList__get_Tail(s)}})(0,t,n)}function List_fold2(e,t,n,r){let o=t,i=n,s=r;for(;!FSharpList__get_IsEmpty(i)&&!FSharpList__get_IsEmpty(s);)o=e(o,FSharpList__get_Head(i),FSharpList__get_Head(s)),i=FSharpList__get_Tail(i),s=FSharpList__get_Tail(s);return o}function List_foldBack2(e,t,n,r){return foldBack2_1(e,List_toArray(t),List_toArray(n),r)}function List_unfold(e,t){const n=FSharpList_get_Empty(),r=((t,n)=>{for(;;){const r=n;let o;const i=e(t);if(null==i)return r;t=List_value_1(i)[1],o=new List_FSharpList(List_value_1(i)[0],void 0),r.tail=o,n=o}})(t,n),o=FSharpList_get_Empty();return r.tail=o,FSharpList__get_Tail(n)}function List_iterate(e,t){List_fold((t,n)=>{e(n)},void 0,t)}function List_iterate2(e,t,n){List_fold2((t,n,r)=>{e(n,r)},void 0,t,n)}function List_iterateIndexed(e,t){List_fold((t,n)=>(e(t,n),t+1|0),0,t)}function List_iterateIndexed2(e,t,n){List_fold2((t,n,r)=>(e(t,n,r),t+1|0),0,t,n)}function toSeq(e){return e}function ofArrayWithTail(e,t){let n=t;for(let t=e.length-1;t>=0;t--)n=FSharpList_Cons_305B8EAC(item(t,e),n);return n}function List_ofArray(e){return ofArrayWithTail(e,FSharpList_get_Empty())}function List_ofSeq(e){if(isArrayLike(e))return List_ofArray(e);if(e instanceof List_FSharpList)return e;{const t=FSharpList_get_Empty();let n=t;const r=getEnumerator(e);try{for(;r["System.Collections.IEnumerator.MoveNext"]();){let e,t;const o=r["System.Collections.Generic.IEnumerator`1.get_Current"]();e=n,t=new List_FSharpList(o,void 0),e.tail=t,n=t}}finally{disposeSafe(r)}const o=n,i=FSharpList_get_Empty();return o.tail=i,FSharpList__get_Tail(t)}}function List_concat(e){const t=FSharpList_get_Empty();let n=t;const r=e=>{n=List_fold((e,t)=>{const n=new List_FSharpList(t,void 0);return e.tail=n,n},n,e)};if(List_isArrayLike(e))e.forEach(r);else if(e instanceof List_FSharpList)List_iterate(r,e);else{const t=List_getEnumerator(e);try{for(;t["System.Collections.IEnumerator.MoveNext"]();)r(t["System.Collections.Generic.IEnumerator`1.get_Current"]())}finally{List_disposeSafe(t)}}const o=n,i=FSharpList_get_Empty();return o.tail=i,FSharpList__get_Tail(t)}function List_scan(e,t,n){const r=FSharpList_get_Empty();let o;const i=new List_FSharpList(t,void 0);r.tail=i,o=i;let s=t,a=n;for(;!FSharpList__get_IsEmpty(a);){let t,n;s=e(s,FSharpList__get_Head(a)),t=o,n=new List_FSharpList(s,void 0),t.tail=n,o=n,a=FSharpList__get_Tail(a)}const _=o,u=FSharpList_get_Empty();return _.tail=u,FSharpList__get_Tail(r)}function List_scanBack(e,t,n){return List_ofArray(List_scanBack_1(e,List_toArray(t),n))}function List_append(e,t){return List_fold((e,t)=>FSharpList_Cons_305B8EAC(t,e),t,List_reverse(e))}function List_collect(e,t){const n=FSharpList_get_Empty();let r=n,o=t;for(;!FSharpList__get_IsEmpty(o);){let t=e(FSharpList__get_Head(o));for(;!FSharpList__get_IsEmpty(t);){let e,n;e=r,n=new List_FSharpList(FSharpList__get_Head(t),void 0),e.tail=n,r=n,t=FSharpList__get_Tail(t)}o=FSharpList__get_Tail(o)}const i=r,s=FSharpList_get_Empty();return i.tail=s,FSharpList__get_Tail(n)}function List_mapIndexed(e,t){const n=FSharpList_get_Empty(),r=List_foldIndexed((t,n,r)=>{const o=new List_FSharpList(e(t,r),void 0);return n.tail=o,o},n,t),o=FSharpList_get_Empty();return r.tail=o,FSharpList__get_Tail(n)}function List_map(e,t){const n=FSharpList_get_Empty(),r=List_fold((t,n)=>{const r=new List_FSharpList(e(n),void 0);return t.tail=r,r},n,t),o=FSharpList_get_Empty();return r.tail=o,FSharpList__get_Tail(n)}function List_indexed(e){return List_mapIndexed((e,t)=>[e,t],e)}function List_map2(e,t,n){const r=FSharpList_get_Empty(),o=List_fold2((t,n,r)=>{const o=new List_FSharpList(e(n,r),void 0);return t.tail=o,o},r,t,n),i=FSharpList_get_Empty();return o.tail=i,FSharpList__get_Tail(r)}function List_mapIndexed2(e,t,n){const r=FSharpList_get_Empty(),o=((t,n,r,o)=>{for(;;){const i=t,s=n,a=r,_=o;let u;if(FSharpList__get_IsEmpty(a)||FSharpList__get_IsEmpty(_))return s;t=i+1,u=new List_FSharpList(e(i,FSharpList__get_Head(a),FSharpList__get_Head(_)),void 0),s.tail=u,n=u,r=FSharpList__get_Tail(a),o=FSharpList__get_Tail(_)}})(0,r,t,n),i=FSharpList_get_Empty();return o.tail=i,FSharpList__get_Tail(r)}function List_map3(e,t,n,r){const o=FSharpList_get_Empty(),i=((t,n,r,o)=>{for(;;){const i=t,s=n,a=r,_=o;let u;if(FSharpList__get_IsEmpty(s)||FSharpList__get_IsEmpty(a)||FSharpList__get_IsEmpty(_))return i;u=new List_FSharpList(e(FSharpList__get_Head(s),FSharpList__get_Head(a),FSharpList__get_Head(_)),void 0),i.tail=u,t=u,n=FSharpList__get_Tail(s),r=FSharpList__get_Tail(a),o=FSharpList__get_Tail(_)}})(o,t,n,r),s=FSharpList_get_Empty();return i.tail=s,FSharpList__get_Tail(o)}function List_mapFold(e,t,n){const r=FSharpList_get_Empty(),o=List_fold((t,n)=>{let r;const o=e(t[1],n);return[(r=new List_FSharpList(o[0],void 0),t[0].tail=r,r),o[1]]},[r,t],n),i=FSharpList_get_Empty();return o[0].tail=i,[FSharpList__get_Tail(r),o[1]]}function List_mapFoldBack(e,t,n){return List_mapFold((t,n)=>e(n,t),n,List_reverse(t))}function List_tryPick(e,t){return(t=>{e:for(;;){const n=t;if(FSharpList__get_IsEmpty(n))return;{const r=e(FSharpList__get_Head(n));if(null==r){t=FSharpList__get_Tail(n);continue e}return r}}})(t)}function List_pick(e,t){const n=List_tryPick(e,t);return null==n?List_indexNotFound():List_value_1(n)}function List_tryFind(e,t){return List_tryPick(t=>e(t)?some(t):void 0,t)}function List_find(e,t){const n=List_tryFind(e,t);return null==n?List_indexNotFound():Option_value(n)}function List_tryFindBack(e,t){return List_tryFindBack_1(e,List_toArray(t))}function List_findBack(e,t){const n=List_tryFindBack(e,t);return null==n?List_indexNotFound():List_value_1(n)}function List_tryFindIndex(e,t){return((t,n)=>{for(;;){const r=t,o=n;if(FSharpList__get_IsEmpty(o))return;if(e(FSharpList__get_Head(o)))return r;t=r+1,n=FSharpList__get_Tail(o)}})(0,t)}function List_findIndex(e,t){const n=List_tryFindIndex(e,t);return null==n?(List_indexNotFound(),-1):0|List_value_1(n)}function List_tryFindIndexBack(e,t){return List_tryFindIndexBack_1(e,List_toArray(t))}function List_findIndexBack(e,t){const n=List_tryFindIndexBack(e,t);return null==n?(List_indexNotFound(),-1):0|List_value_1(n)}function List_tryItem(e,t){return((t,n)=>{for(;;){const r=t,o=n;if(FSharpList__get_IsEmpty(o))return;if(r===e)return some(FSharpList__get_Head(o));t=r+1,n=FSharpList__get_Tail(o)}})(0,t)}function List_item(e,t){return FSharpList__get_Item_Z524259A4(t,e)}function List_filter(e,t){const n=FSharpList_get_Empty(),r=List_fold((t,n)=>{if(e(n)){const e=new List_FSharpList(n,void 0);return t.tail=e,e}return t},n,t),o=FSharpList_get_Empty();return r.tail=o,FSharpList__get_Tail(n)}function List_partition(e,t){const n=FSharpList_get_Empty(),r=FSharpList_get_Empty(),o=n,i=List_fold((t,n)=>{let r,o;const i=t[0],s=t[1];return e(n)?[(r=new List_FSharpList(n,void 0),i.tail=r,r),s]:[i,(o=new List_FSharpList(n,void 0),s.tail=o,o)]},[o,r],t),s=FSharpList_get_Empty();i[0].tail=s;const a=FSharpList_get_Empty();return i[1].tail=a,[FSharpList__get_Tail(o),FSharpList__get_Tail(r)]}function List_choose(e,t){const n=FSharpList_get_Empty(),r=List_fold((t,n)=>{const r=e(n);if(null==r)return t;{const e=new List_FSharpList(Option_value(r),void 0);return t.tail=e,e}},n,t),o=FSharpList_get_Empty();return r.tail=o,FSharpList__get_Tail(n)}function List_contains(e,t,n){return null!=List_tryFindIndex(t=>n.Equals(e,t),t)}function List_initialize(e,t){const n=FSharpList_get_Empty();let r=n;for(let n=0;n<=e-1;n++){let e,o;e=r,o=new List_FSharpList(t(n),void 0),e.tail=o,r=o}const o=r,i=FSharpList_get_Empty();return o.tail=i,FSharpList__get_Tail(n)}function List_replicate(e,t){return List_initialize(e,e=>t)}function List_reduce(e,t){if(FSharpList__get_IsEmpty(t))throw new List_Exception(List_SR_inputWasEmpty);return List_fold(e,List_head(t),List_tail(t))}function List_reduceBack(e,t){if(FSharpList__get_IsEmpty(t))throw new List_Exception(List_SR_inputWasEmpty);return List_foldBack(e,List_tail(t),List_head(t))}function List_forAll(e,t){return List_fold((t,n)=>t&&e(n),!0,t)}function List_forAll2(e,t,n){return List_fold2((t,n,r)=>t&&e(n,r),!0,t,n)}function List_exists(e,t){return null!=List_tryFindIndex(e,t)}function List_exists2(e,t,n){e:for(;;){const r=e,o=t,i=n,s=FSharpList__get_IsEmpty(o),a=FSharpList__get_IsEmpty(i);let _;switch(_=s?a?0:2:a?2:1,_){case 0:return!1;case 1:if(r(FSharpList__get_Head(o),FSharpList__get_Head(i)))return!0;e=r,t=FSharpList__get_Tail(o),n=FSharpList__get_Tail(i);continue e;default:throw new List_Exception(List_SR_differentLengths+" (Parameter 'list2')")}break}}function List_unzip(e){return List_foldBack((e,t)=>[FSharpList_Cons_305B8EAC(e[0],t[0]),FSharpList_Cons_305B8EAC(e[1],t[1])],e,[FSharpList_get_Empty(),FSharpList_get_Empty()])}function List_unzip3(e){return List_foldBack((e,t)=>[FSharpList_Cons_305B8EAC(e[0],t[0]),FSharpList_Cons_305B8EAC(e[1],t[1]),FSharpList_Cons_305B8EAC(e[2],t[2])],e,[FSharpList_get_Empty(),FSharpList_get_Empty(),FSharpList_get_Empty()])}function List_zip(e,t){return List_map2((e,t)=>[e,t],e,t)}function List_zip3(e,t,n){return List_map3((e,t,n)=>[e,t,n],e,t,n)}function List_sortWith(e,t){const n=List_toArray(t);return n.sort(e),List_ofArray(n)}function List_sort(e,t){return List_sortWith((e,n)=>0|t.Compare(e,n),e)}function List_sortBy(e,t,n){return List_sortWith((t,r)=>0|n.Compare(e(t),e(r)),t)}function List_sortDescending(e,t){return List_sortWith((e,n)=>-1*t.Compare(e,n)|0,e)}function List_sortByDescending(e,t,n){return List_sortWith((t,r)=>-1*n.Compare(e(t),e(r))|0,t)}function List_sum(e,t){return List_fold((e,n)=>t.Add(e,n),t.GetZero(),e)}function List_sumBy(e,t,n){return List_fold((t,r)=>n.Add(t,e(r)),n.GetZero(),t)}function List_maxBy(e,t,n){return List_reduce((t,r)=>n.Compare(e(r),e(t))>0?r:t,t)}function List_max(e,t){return List_reduce((e,n)=>t.Compare(n,e)>0?n:e,e)}function List_minBy(e,t,n){return List_reduce((t,r)=>n.Compare(e(r),e(t))>0?t:r,t)}function List_min(e,t){return List_reduce((e,n)=>t.Compare(n,e)>0?e:n,e)}function List_average(e,t){let n=0;const r=List_fold((e,r)=>(n=n+1|0,t.Add(e,r)),t.GetZero(),e);return t.DivideByInt(r,n)}function List_averageBy(e,t,n){let r=0;const o=List_fold((t,o)=>(r=r+1|0,n.Add(t,e(o))),n.GetZero(),t);return n.DivideByInt(o,r)}function List_permute(e,t){return List_ofArray(List_permute_1(e,List_toArray(t)))}function List_chunkBySize(e,t){return List_ofArray(List_map_1(List_ofArray,List_chunkBySize_1(e,List_toArray(t))))}function List_allPairs(e,t){const n=FSharpList_get_Empty();let r=n;List_iterate(e=>{List_iterate(t=>{let n,o;n=r,o=new List_FSharpList([e,t],void 0),n.tail=o,r=o},t)},e);const o=r,i=FSharpList_get_Empty();return o.tail=i,FSharpList__get_Tail(n)}function List_skip(e,t){for(;;){const n=e,r=t;if(n<=0)return r;if(FSharpList__get_IsEmpty(r))throw new List_Exception(List_SR_notEnoughElements+" (Parameter 'list')");e=n-1,t=FSharpList__get_Tail(r)}}function List_skipWhile(e,t){for(;;){const n=e,r=t;if(FSharpList__get_IsEmpty(r))return r;if(!n(FSharpList__get_Head(r)))return r;e=n,t=FSharpList__get_Tail(r)}}function List_take(e,t){if(e<0)throw new List_Exception(List_SR_inputMustBeNonNegative+" (Parameter 'count')");const n=FSharpList_get_Empty(),r=((e,t,n)=>{for(;;){const r=e,o=t,i=n;let s;if(r<=0)return o;if(FSharpList__get_IsEmpty(i))throw new List_Exception(List_SR_notEnoughElements+" (Parameter 'list')");e=r-1,s=new List_FSharpList(FSharpList__get_Head(i),void 0),o.tail=s,t=s,n=FSharpList__get_Tail(i)}})(e,n,t),o=FSharpList_get_Empty();return r.tail=o,FSharpList__get_Tail(n)}function List_takeWhile(e,t){const n=FSharpList_get_Empty(),r=((t,n)=>{for(;;){const r=t,o=n;let i;if(FSharpList__get_IsEmpty(o))return r;if(!e(FSharpList__get_Head(o)))return r;i=new List_FSharpList(FSharpList__get_Head(o),void 0),r.tail=i,t=i,n=FSharpList__get_Tail(o)}})(n,t),o=FSharpList_get_Empty();return r.tail=o,FSharpList__get_Tail(n)}function List_truncate(e,t){const n=FSharpList_get_Empty(),r=((e,t,n)=>{for(;;){const r=e,o=t,i=n;let s;if(r<=0)return o;if(FSharpList__get_IsEmpty(i))return o;e=r-1,s=new List_FSharpList(FSharpList__get_Head(i),void 0),o.tail=s,t=s,n=FSharpList__get_Tail(i)}})(e,n,t),o=FSharpList_get_Empty();return r.tail=o,FSharpList__get_Tail(n)}function getSlice(e,t,n){const r=0|List_length(n);let o;const i=0|List_defaultArg(e,0);let s;o=i<0?0:i;const a=0|List_defaultArg(t,r-1);return s=a>=r?r-1:a,s<o?FSharpList_get_Empty():List_take(s-o+1,List_skip(o,n))}function List_splitAt(e,t){if(e<0)throw new List_Exception(List_SR_inputMustBeNonNegative+" (Parameter 'index')");if(e>FSharpList__get_Length(t))throw new List_Exception(List_SR_notEnoughElements+" (Parameter 'index')");return[List_take(e,t),List_skip(e,t)]}function List_exactlyOne(e){if(FSharpList__get_IsEmpty(e))throw new List_Exception(List_SR_inputSequenceEmpty+" (Parameter 'list')");if(FSharpList__get_IsEmpty(FSharpList__get_Tail(e)))return FSharpList__get_Head(e);throw new List_Exception(List_SR_inputSequenceTooLong+" (Parameter 'list')")}function List_tryExactlyOne(e){return!FSharpList__get_IsEmpty(e)&&FSharpList__get_IsEmpty(FSharpList__get_Tail(e))?List_some(FSharpList__get_Head(e)):void 0}function List_where(e,t){return List_filter(e,t)}function List_pairwise(e){return List_ofArray(pairwise(List_toArray(e)))}function List_windowed(e,t){return List_ofArray(List_map_1(List_ofArray,List_windowed_1(e,List_toArray(t))))}function List_splitInto(e,t){return List_ofArray(List_map_1(List_ofArray,List_splitInto_1(e,List_toArray(t))))}function List_transpose(e){return List_ofArray(List_map_1(List_ofArray,List_transpose_1(List_map_1(List_toArray,Array.from(e)))))}function List_insertAt(e,t,n){let r=-1,o=!1;const i=List_fold((n,i)=>(r=r+1|0,r===e?(o=!0,FSharpList_Cons_305B8EAC(i,FSharpList_Cons_305B8EAC(t,n))):FSharpList_Cons_305B8EAC(i,n)),FSharpList_get_Empty(),n);return List_reverse(o?i:r+1===e?FSharpList_Cons_305B8EAC(t,i):(()=>{throw new List_Exception(List_SR_indexOutOfBounds+" (Parameter 'index')")})())}function List_insertManyAt(e,t,n){let r=-1,o=!1;const i=List_ofSeq(t),s=List_fold((t,n)=>(r=r+1|0,r===e?(o=!0,FSharpList_Cons_305B8EAC(n,List_append(i,t))):FSharpList_Cons_305B8EAC(n,t)),FSharpList_get_Empty(),n);return List_reverse(o?s:r+1===e?List_append(i,s):(()=>{throw new List_Exception(List_SR_indexOutOfBounds+" (Parameter 'index')")})())}function List_removeAt(e,t){let n=-1,r=!1;const o=List_filter(t=>(n=n+1|0,n!==e||(r=!0,!1)),t);if(!r)throw new List_Exception(List_SR_indexOutOfBounds+" (Parameter 'index')");return o}function List_removeManyAt(e,t,n){let r=-1,o=-1;const i=List_filter(n=>(r=r+1|0,r===e?(o=0,!1):!(r>e&&(r<e+t||(o=1,0)))),n),s=0|(0===o&&r+1===e+t?1:o);if(s<1)throw new List_Exception(List_SR_indexOutOfBounds+" (Parameter '"+(s<0?"index":"count")+"')");return i}function List_updateAt(e,t,n){let r=!1;const o=List_mapIndexed((n,o)=>n===e?(r=!0,t):o,n);if(!r)throw new List_Exception(List_SR_indexOutOfBounds+" (Parameter 'index')");return o}function List_randomShuffleBy(e,t){const n=List_toArray(t);return List_randomShuffleInPlaceBy(e,n),List_ofArray(n)}function List_randomShuffleWith(e,t){return List_randomShuffleBy(()=>e.NextDouble(),t)}function List_randomShuffle(e){return List_randomShuffleWith(List_nonSeeded(),e)}function List_randomChoiceBy(e,t){return List_randomChoiceBy_1(e,List_toArray(t))}function List_randomChoiceWith(e,t){return List_randomChoiceBy(()=>e.NextDouble(),t)}function List_randomChoice(e){return List_randomChoiceWith(List_nonSeeded(),e)}function List_randomChoicesBy(e,t,n){return List_ofArray(List_randomChoicesBy_1(e,t,List_toArray(n)))}function List_randomChoicesWith(e,t,n){return List_randomChoicesBy(()=>e.NextDouble(),t,n)}function List_randomChoices(e,t){return List_randomChoicesWith(List_nonSeeded(),e,t)}function List_randomSampleBy(e,t,n){return List_ofArray(List_randomSampleBy_1(e,t,List_toArray(n)))}function List_randomSampleWith(e,t,n){return List_randomSampleBy(()=>e.NextDouble(),t,n)}function List_randomSample(e,t){return List_randomSampleWith(List_nonSeeded(),e,t)}class SetTreeLeaf$1{constructor(e){this.k=e}}function SetTreeLeaf$1_$reflection(e){return Set_class_type("Set.SetTreeLeaf`1",[e],SetTreeLeaf$1)}function SetTreeLeaf$1_$ctor_2B595(e){return new SetTreeLeaf$1(e)}function SetTreeLeaf$1__get_Key(e){return e.k}class SetTreeNode$1 extends SetTreeLeaf$1{constructor(e,t,n,r){super(e),this.left=t,this.right=n,this.h=0|r}}function SetTreeNode$1_$reflection(e){return Set_class_type("Set.SetTreeNode`1",[e],SetTreeNode$1,SetTreeLeaf$1_$reflection(e))}function SetTreeNode$1_$ctor_5F465FC9(e,t,n,r){return new SetTreeNode$1(e,t,n,r)}function SetTreeNode$1__get_Left(e){return e.left}function SetTreeNode$1__get_Right(e){return e.right}function SetTreeNode$1__get_Height(e){return 0|e.h}function SetTreeModule_empty(){}function SetTreeModule_countAux(e,t){e:for(;;){const n=t;if(null!=e){const r=Option_value(e);if(r instanceof SetTreeNode$1){const o=r;e=SetTreeNode$1__get_Left(o),t=SetTreeModule_countAux(SetTreeNode$1__get_Right(o),n+1);continue e}return n+1|0}return 0|n}}function SetTreeModule_count(e){return 0|SetTreeModule_countAux(e,0)}function SetTreeModule_mk(e,t,n){let r,o,i,s;if(null!=e){const t=Option_value(e);i=t instanceof SetTreeNode$1?(r=t,SetTreeNode$1__get_Height(r)):1}else i=0;if(null!=n){const e=Option_value(n);s=e instanceof SetTreeNode$1?(o=e,SetTreeNode$1__get_Height(o)):1}else s=0;const a=0|(i<s?s:i);return 0===a?SetTreeLeaf$1_$ctor_2B595(t):SetTreeNode$1_$ctor_5F465FC9(t,e,n,a+1)}function SetTreeModule_rebalance(e,t,n){let r,o,i,s,a,_,u,l,c,d;if(null!=e){const t=Option_value(e);c=t instanceof SetTreeNode$1?(r=t,SetTreeNode$1__get_Height(r)):1}else c=0;if(null!=n){const e=Option_value(n);d=e instanceof SetTreeNode$1?(o=e,SetTreeNode$1__get_Height(o)):1}else d=0;if(d>c+2){const r=Option_value(n);if(r instanceof SetTreeNode$1){const n=r;if(i=SetTreeNode$1__get_Left(n),(null!=i?(s=Option_value(i),s instanceof SetTreeNode$1?(a=s,SetTreeNode$1__get_Height(a)):1):0)>c+1){const r=Option_value(SetTreeNode$1__get_Left(n));if(r instanceof SetTreeNode$1){const o=r;return SetTreeModule_mk(SetTreeModule_mk(e,t,SetTreeNode$1__get_Left(o)),SetTreeLeaf$1__get_Key(o),SetTreeModule_mk(SetTreeNode$1__get_Right(o),SetTreeLeaf$1__get_Key(n),SetTreeNode$1__get_Right(n)))}throw new Exception("internal error: Set.rebalance")}return SetTreeModule_mk(SetTreeModule_mk(e,t,SetTreeNode$1__get_Left(n)),SetTreeLeaf$1__get_Key(n),SetTreeNode$1__get_Right(n))}throw new Exception("internal error: Set.rebalance")}if(c>d+2){const r=Option_value(e);if(r instanceof SetTreeNode$1){const e=r;if(_=SetTreeNode$1__get_Right(e),(null!=_?(u=Option_value(_),u instanceof SetTreeNode$1?(l=u,SetTreeNode$1__get_Height(l)):1):0)>d+1){const r=Option_value(SetTreeNode$1__get_Right(e));if(r instanceof SetTreeNode$1){const o=r;return SetTreeModule_mk(SetTreeModule_mk(SetTreeNode$1__get_Left(e),SetTreeLeaf$1__get_Key(e),SetTreeNode$1__get_Left(o)),SetTreeLeaf$1__get_Key(o),SetTreeModule_mk(SetTreeNode$1__get_Right(o),t,n))}throw new Exception("internal error: Set.rebalance")}return SetTreeModule_mk(SetTreeNode$1__get_Left(e),SetTreeLeaf$1__get_Key(e),SetTreeModule_mk(SetTreeNode$1__get_Right(e),t,n))}throw new Exception("internal error: Set.rebalance")}return SetTreeModule_mk(e,t,n)}function SetTreeModule_add(e,t,n){if(null!=n){const r=Option_value(n),o=0|e.Compare(t,SetTreeLeaf$1__get_Key(r));if(r instanceof SetTreeNode$1){const i=r;return o<0?SetTreeModule_rebalance(SetTreeModule_add(e,t,SetTreeNode$1__get_Left(i)),SetTreeLeaf$1__get_Key(i),SetTreeNode$1__get_Right(i)):0===o?n:SetTreeModule_rebalance(SetTreeNode$1__get_Left(i),SetTreeLeaf$1__get_Key(i),SetTreeModule_add(e,t,SetTreeNode$1__get_Right(i)))}{const o=0|e.Compare(t,SetTreeLeaf$1__get_Key(r));return o<0?SetTreeNode$1_$ctor_5F465FC9(t,SetTreeModule_empty(),n,2):0===o?n:SetTreeNode$1_$ctor_5F465FC9(t,n,SetTreeModule_empty(),2)}}return SetTreeLeaf$1_$ctor_2B595(t)}function SetTreeModule_balance(e,t,n,r){if(null!=t){const o=Option_value(t);if(null!=r){const i=Option_value(r);if(o instanceof SetTreeNode$1){const s=o;if(i instanceof SetTreeNode$1){const o=i;return SetTreeNode$1__get_Height(s)+2<SetTreeNode$1__get_Height(o)?SetTreeModule_rebalance(SetTreeModule_balance(e,t,n,SetTreeNode$1__get_Left(o)),SetTreeLeaf$1__get_Key(o),SetTreeNode$1__get_Right(o)):SetTreeNode$1__get_Height(o)+2<SetTreeNode$1__get_Height(s)?SetTreeModule_rebalance(SetTreeNode$1__get_Left(s),SetTreeLeaf$1__get_Key(s),SetTreeModule_balance(e,SetTreeNode$1__get_Right(s),n,r)):SetTreeModule_mk(t,n,r)}return SetTreeModule_add(e,n,SetTreeModule_add(e,SetTreeLeaf$1__get_Key(i),t))}return SetTreeModule_add(e,n,SetTreeModule_add(e,SetTreeLeaf$1__get_Key(o),r))}return SetTreeModule_add(e,n,t)}return SetTreeModule_add(e,n,r)}function SetTreeModule_split(e,t,n){if(null!=n){const r=Option_value(n);if(r instanceof SetTreeNode$1){const n=r,o=0|e.Compare(t,SetTreeLeaf$1__get_Key(n));if(o<0){const r=SetTreeModule_split(e,t,SetTreeNode$1__get_Left(n));return[r[0],r[1],SetTreeModule_balance(e,r[2],SetTreeLeaf$1__get_Key(n),SetTreeNode$1__get_Right(n))]}if(0===o)return[SetTreeNode$1__get_Left(n),!0,SetTreeNode$1__get_Right(n)];{const r=SetTreeModule_split(e,t,SetTreeNode$1__get_Right(n));return[SetTreeModule_balance(e,SetTreeNode$1__get_Left(n),SetTreeLeaf$1__get_Key(n),r[0]),r[1],r[2]]}}{const o=0|e.Compare(SetTreeLeaf$1__get_Key(r),t);return o<0?[n,!1,SetTreeModule_empty()]:0===o?[SetTreeModule_empty(),!0,SetTreeModule_empty()]:[SetTreeModule_empty(),!1,n]}}return[SetTreeModule_empty(),!1,SetTreeModule_empty()]}function SetTreeModule_spliceOutSuccessor(e){if(null!=e){const t=Set_value_2(e);if(t instanceof SetTreeNode$1){const e=t;if(null==SetTreeNode$1__get_Left(e))return[SetTreeLeaf$1__get_Key(e),SetTreeNode$1__get_Right(e)];{const t=SetTreeModule_spliceOutSuccessor(SetTreeNode$1__get_Left(e));return[t[0],SetTreeModule_mk(t[1],SetTreeLeaf$1__get_Key(e),SetTreeNode$1__get_Right(e))]}}return[SetTreeLeaf$1__get_Key(t),SetTreeModule_empty()]}throw new Set_Exception("internal error: Set.spliceOutSuccessor")}function SetTreeModule_remove(e,t,n){if(null!=n){const r=Set_value_2(n),o=0|e.Compare(t,SetTreeLeaf$1__get_Key(r));if(r instanceof SetTreeNode$1){const n=r;if(o<0)return SetTreeModule_rebalance(SetTreeModule_remove(e,t,SetTreeNode$1__get_Left(n)),SetTreeLeaf$1__get_Key(n),SetTreeNode$1__get_Right(n));if(0===o){if(null==SetTreeNode$1__get_Left(n))return SetTreeNode$1__get_Right(n);if(null==SetTreeNode$1__get_Right(n))return SetTreeNode$1__get_Left(n);{const e=SetTreeModule_spliceOutSuccessor(SetTreeNode$1__get_Right(n));return SetTreeModule_mk(SetTreeNode$1__get_Left(n),e[0],e[1])}}return SetTreeModule_rebalance(SetTreeNode$1__get_Left(n),SetTreeLeaf$1__get_Key(n),SetTreeModule_remove(e,t,SetTreeNode$1__get_Right(n)))}return 0===o?SetTreeModule_empty():n}return n}function SetTreeModule_mem(e,t,n){e:for(;;){const r=e,o=t;if(null!=n){const i=Option_value(n),s=0|r.Compare(o,SetTreeLeaf$1__get_Key(i));if(i instanceof SetTreeNode$1){const a=i;if(s<0){e=r,t=o,n=SetTreeNode$1__get_Left(a);continue e}if(0===s)return!0;e=r,t=o,n=SetTreeNode$1__get_Right(a);continue e}return 0===s}return!1}}function SetTreeModule_iter(e,t){e:for(;;){const n=e;if(null!=t){const r=Option_value(t);if(r instanceof SetTreeNode$1){const o=r;SetTreeModule_iter(n,SetTreeNode$1__get_Left(o)),n(SetTreeLeaf$1__get_Key(o)),e=n,t=SetTreeNode$1__get_Right(o);continue e}n(SetTreeLeaf$1__get_Key(r))}break}}function SetTreeModule_foldBackOpt(e,t,n){e:for(;;){const r=e,o=n;if(null!=t){const i=Set_value_2(t);if(i instanceof SetTreeNode$1){const s=i;e=r,t=SetTreeNode$1__get_Left(s),n=r(SetTreeLeaf$1__get_Key(s),SetTreeModule_foldBackOpt(r,SetTreeNode$1__get_Right(s),o));continue e}return r(SetTreeLeaf$1__get_Key(i),o)}return o}}function SetTreeModule_foldBack(e,t,n){return SetTreeModule_foldBackOpt(e,t,n)}function SetTreeModule_foldOpt(e,t,n){e:for(;;){const r=e,o=t;if(null!=n){const i=Set_value_2(n);if(i instanceof SetTreeNode$1){const s=i;e=r,t=r(SetTreeModule_foldOpt(r,o,SetTreeNode$1__get_Left(s)),SetTreeLeaf$1__get_Key(s)),n=SetTreeNode$1__get_Right(s);continue e}return r(o,SetTreeLeaf$1__get_Key(i))}return o}}function SetTreeModule_fold(e,t,n){return SetTreeModule_foldOpt(e,t,n)}function SetTreeModule_forall(e,t){e:for(;;){const n=e;if(null!=t){const r=Set_value_2(t);if(r instanceof SetTreeNode$1){const o=r;if(n(SetTreeLeaf$1__get_Key(o))&&SetTreeModule_forall(n,SetTreeNode$1__get_Left(o))){e=n,t=SetTreeNode$1__get_Right(o);continue e}return!1}return n(SetTreeLeaf$1__get_Key(r))}return!0}}function SetTreeModule_exists(e,t){e:for(;;){const n=e;if(null!=t){const r=Set_value_2(t);if(r instanceof SetTreeNode$1){const o=r;if(n(SetTreeLeaf$1__get_Key(o))||SetTreeModule_exists(n,SetTreeNode$1__get_Left(o)))return!0;e=n,t=SetTreeNode$1__get_Right(o);continue e}return n(SetTreeLeaf$1__get_Key(r))}return!1}}function SetTreeModule_subset(e,t,n){return SetTreeModule_forall(t=>SetTreeModule_mem(e,t,n),t)}function SetTreeModule_properSubset(e,t,n){return!!SetTreeModule_forall(t=>SetTreeModule_mem(e,t,n),t)&&SetTreeModule_exists(n=>!SetTreeModule_mem(e,n,t),n)}function SetTreeModule_filterAux(e,t,n,r){e:for(;;){const o=e,i=t,s=r;if(null!=n){const a=Set_value_2(n);if(a instanceof SetTreeNode$1){const _=a,u=i(SetTreeLeaf$1__get_Key(_))?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(_),s):s;e=o,t=i,n=SetTreeNode$1__get_Left(_),r=SetTreeModule_filterAux(o,i,SetTreeNode$1__get_Right(_),u);continue e}return i(SetTreeLeaf$1__get_Key(a))?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(a),s):s}return s}}function SetTreeModule_filter(e,t,n){return SetTreeModule_filterAux(e,t,n,SetTreeModule_empty())}function SetTreeModule_diffAux(e,t,n){e:for(;;){const r=e,o=n;if(null==o)return o;if(null!=t){const i=Set_value_2(t);if(i instanceof SetTreeNode$1){const s=i;e=r,t=SetTreeNode$1__get_Left(s),n=SetTreeModule_diffAux(r,SetTreeNode$1__get_Right(s),SetTreeModule_remove(r,SetTreeLeaf$1__get_Key(s),o));continue e}return SetTreeModule_remove(r,SetTreeLeaf$1__get_Key(i),o)}return o}}function SetTreeModule_diff(e,t,n){return SetTreeModule_diffAux(e,n,t)}function SetTreeModule_union(e,t,n){if(null!=t){const r=Option_value(t);if(null!=n){const o=Option_value(n);if(r instanceof SetTreeNode$1){const i=r;if(o instanceof SetTreeNode$1){const r=o;if(SetTreeNode$1__get_Height(i)>SetTreeNode$1__get_Height(r)){const t=SetTreeModule_split(e,SetTreeLeaf$1__get_Key(i),n);return SetTreeModule_balance(e,SetTreeModule_union(e,SetTreeNode$1__get_Left(i),t[0]),SetTreeLeaf$1__get_Key(i),SetTreeModule_union(e,SetTreeNode$1__get_Right(i),t[2]))}{const n=SetTreeModule_split(e,SetTreeLeaf$1__get_Key(r),t);return SetTreeModule_balance(e,SetTreeModule_union(e,SetTreeNode$1__get_Left(r),n[0]),SetTreeLeaf$1__get_Key(r),SetTreeModule_union(e,SetTreeNode$1__get_Right(r),n[2]))}}return SetTreeModule_add(e,SetTreeLeaf$1__get_Key(o),t)}return SetTreeModule_add(e,SetTreeLeaf$1__get_Key(r),n)}return t}return n}function SetTreeModule_intersectionAux(e,t,n,r){e:for(;;){const o=e,i=t,s=r;if(null!=n){const a=Set_value_2(n);if(a instanceof SetTreeNode$1){const _=a,u=SetTreeModule_intersectionAux(o,i,SetTreeNode$1__get_Right(_),s),l=SetTreeModule_mem(o,SetTreeLeaf$1__get_Key(_),i)?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(_),u):u;e=o,t=i,n=SetTreeNode$1__get_Left(_),r=l;continue e}return SetTreeModule_mem(o,SetTreeLeaf$1__get_Key(a),i)?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(a),s):s}return s}}function SetTreeModule_intersection(e,t,n){return SetTreeModule_intersectionAux(e,n,t,SetTreeModule_empty())}function SetTreeModule_partition1(e,t,n,r,o){return t(n)?[SetTreeModule_add(e,n,r),o]:[r,SetTreeModule_add(e,n,o)]}function SetTreeModule_partitionAux(e,t,n,r,o){e:for(;;){const i=e,s=t,a=[r,o];if(null!=n){const _=Set_value_2(n);if(_ instanceof SetTreeNode$1){const u=_,l=SetTreeModule_partitionAux(i,s,SetTreeNode$1__get_Right(u),a[0],a[1]),c=SetTreeModule_partition1(i,s,SetTreeLeaf$1__get_Key(u),l[0],l[1]);e=i,t=s,n=SetTreeNode$1__get_Left(u),r=c[0],o=c[1];continue e}return SetTreeModule_partition1(i,s,SetTreeLeaf$1__get_Key(_),a[0],a[1])}return a}}function SetTreeModule_partition(e,t,n){return SetTreeModule_partitionAux(e,t,n,SetTreeModule_empty(),SetTreeModule_empty())}function SetTreeModule_minimumElementAux(e,t){e:for(;;){const n=t;if(null!=e){const n=Set_value_2(e);if(n instanceof SetTreeNode$1){const r=n;e=SetTreeNode$1__get_Left(r),t=SetTreeLeaf$1__get_Key(r);continue e}return SetTreeLeaf$1__get_Key(n)}return n}}function SetTreeModule_minimumElementOpt(e){if(null!=e){const t=Set_value_2(e);if(t instanceof SetTreeNode$1){const e=t;return Set_some(SetTreeModule_minimumElementAux(SetTreeNode$1__get_Left(e),SetTreeLeaf$1__get_Key(e)))}return Set_some(SetTreeLeaf$1__get_Key(t))}}function SetTreeModule_maximumElementAux(e,t){e:for(;;){const n=t;if(null!=e){const n=Set_value_2(e);if(n instanceof SetTreeNode$1){const r=n;e=SetTreeNode$1__get_Right(r),t=SetTreeLeaf$1__get_Key(r);continue e}return SetTreeLeaf$1__get_Key(n)}return n}}function SetTreeModule_maximumElementOpt(e){if(null!=e){const t=Set_value_2(e);if(t instanceof SetTreeNode$1){const e=t;return Set_some(SetTreeModule_maximumElementAux(SetTreeNode$1__get_Right(e),SetTreeLeaf$1__get_Key(e)))}return Set_some(SetTreeLeaf$1__get_Key(t))}}function SetTreeModule_minimumElement(e){const t=SetTreeModule_minimumElementOpt(e);if(null==t)throw new Set_Exception("Set contains no elements");return Set_value_2(t)}function SetTreeModule_maximumElement(e){const t=SetTreeModule_maximumElementOpt(e);if(null==t)throw new Set_Exception("Set contains no elements");return Set_value_2(t)}class SetTreeModule_SetIterator$1 extends Record{constructor(e,t){super(),this.stack=e,this.started=t}}function SetTreeModule_SetIterator$1_$reflection(e){return Set_record_type("Set.SetTreeModule.SetIterator`1",[e],SetTreeModule_SetIterator$1,()=>[["stack",list_type(Set_option_type(SetTreeLeaf$1_$reflection(e)))],["started",bool_type]])}function SetTreeModule_collapseLHS(e){e:for(;;){const t=e;if(List_isEmpty(t))return List_empty();{const n=List_head(t),r=List_tail(t);if(null!=n){const o=Option_value(n);if(o instanceof SetTreeNode$1){const t=o;e=ofArrayWithTail([SetTreeNode$1__get_Left(t),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(t)),SetTreeNode$1__get_Right(t)],r);continue e}return t}e=r;continue e}}}function SetTreeModule_mkIterator(e){return new SetTreeModule_SetIterator$1(SetTreeModule_collapseLHS(List_singleton(e)),!1)}function SetTreeModule_notStarted(){throw new Exception("Enumeration not started")}function SetTreeModule_alreadyFinished(){throw new Exception("Enumeration already started")}function SetTreeModule_current(e){if(e.started){const t=e.stack;if(List_isEmpty(t))return SetTreeModule_alreadyFinished();if(null!=List_head(t))return SetTreeLeaf$1__get_Key(Option_value(List_head(t)));throw new Exception("Please report error: Set iterator, unexpected stack for current")}return SetTreeModule_notStarted()}function SetTreeModule_moveNext(e){if(e.started){const t=e.stack;if(List_isEmpty(t))return!1;if(null!=List_head(t)){if(Option_value(List_head(t))instanceof SetTreeNode$1)throw new Exception("Please report error: Set iterator, unexpected stack for moveNext");return e.stack=SetTreeModule_collapseLHS(List_tail(t)),!List_isEmpty(e.stack)}throw new Exception("Please report error: Set iterator, unexpected stack for moveNext")}return e.started=!0,!List_isEmpty(e.stack)}function SetTreeModule_mkIEnumerator(e){let t=SetTreeModule_mkIterator(e);return{"System.Collections.Generic.IEnumerator`1.get_Current":()=>SetTreeModule_current(t),"System.Collections.IEnumerator.get_Current":()=>SetTreeModule_current(t),"System.Collections.IEnumerator.MoveNext":()=>SetTreeModule_moveNext(t),"System.Collections.IEnumerator.Reset"(){t=SetTreeModule_mkIterator(e)},Dispose(){}}}function SetTreeModule_compareStacks(e,t,n){e:for(;;){const r=e,o=t,i=n;if(List_isEmpty(o))return List_isEmpty(i)?0:-1;if(List_isEmpty(i))return 1;if(null!=List_head(i))if(null!=List_head(o)){const s=Option_value(List_head(o)),a=Option_value(List_head(i));if(s instanceof SetTreeNode$1){const _=s;if(null==SetTreeNode$1__get_Left(_)){if(!(a instanceof SetTreeNode$1)){const s=0|r.Compare(SetTreeLeaf$1__get_Key(_),SetTreeLeaf$1__get_Key(a));if(0!==s)return 0|s;e=r,t=cons(SetTreeNode$1__get_Right(_),List_tail(o)),n=cons(SetTreeModule_empty(),List_tail(i));continue e}{const s=a;if(null==SetTreeNode$1__get_Left(s)){const a=0|r.Compare(SetTreeLeaf$1__get_Key(_),SetTreeLeaf$1__get_Key(s));if(0!==a)return 0|a;e=r,t=cons(SetTreeNode$1__get_Right(_),List_tail(o)),n=cons(SetTreeNode$1__get_Right(s),List_tail(i));continue e}{let s,a,_,u,l;switch(List_isEmpty(o)?List_isEmpty(i)?s=2:null!=List_head(i)?(s=1,u=List_tail(i),l=Option_value(List_head(i))):s=2:null!=List_head(o)?(s=0,a=List_tail(o),_=Option_value(List_head(o))):List_isEmpty(i)?s=2:null!=List_head(i)?(s=1,u=List_tail(i),l=Option_value(List_head(i))):s=2,s){case 0:if(_ instanceof SetTreeNode$1){const o=_;e=r,t=ofArrayWithTail([SetTreeNode$1__get_Left(o),SetTreeNode$1_$ctor_5F465FC9(SetTreeLeaf$1__get_Key(o),SetTreeModule_empty(),SetTreeNode$1__get_Right(o),0)],a),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(_))],a),n=i;continue e;case 1:if(l instanceof SetTreeNode$1){const i=l;e=r,t=o,n=ofArrayWithTail([SetTreeNode$1__get_Left(i),SetTreeNode$1_$ctor_5F465FC9(SetTreeLeaf$1__get_Key(i),SetTreeModule_empty(),SetTreeNode$1__get_Right(i),0)],u);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],u);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}}}else{let s,a,_,u,l;switch(List_isEmpty(o)?List_isEmpty(i)?s=2:null!=List_head(i)?(s=1,u=List_tail(i),l=Option_value(List_head(i))):s=2:null!=List_head(o)?(s=0,a=List_tail(o),_=Option_value(List_head(o))):List_isEmpty(i)?s=2:null!=List_head(i)?(s=1,u=List_tail(i),l=Option_value(List_head(i))):s=2,s){case 0:if(_ instanceof SetTreeNode$1){const o=_;e=r,t=ofArrayWithTail([SetTreeNode$1__get_Left(o),SetTreeNode$1_$ctor_5F465FC9(SetTreeLeaf$1__get_Key(o),SetTreeModule_empty(),SetTreeNode$1__get_Right(o),0)],a),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(_))],a),n=i;continue e;case 1:if(l instanceof SetTreeNode$1){const i=l;e=r,t=o,n=ofArrayWithTail([SetTreeNode$1__get_Left(i),SetTreeNode$1_$ctor_5F465FC9(SetTreeLeaf$1__get_Key(i),SetTreeModule_empty(),SetTreeNode$1__get_Right(i),0)],u);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],u);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}}else{if(!(a instanceof SetTreeNode$1)){const _=0|r.Compare(SetTreeLeaf$1__get_Key(s),SetTreeLeaf$1__get_Key(a));if(0!==_)return 0|_;e=r,t=List_tail(o),n=List_tail(i);continue e}{const _=a;if(null==SetTreeNode$1__get_Left(_)){const a=0|r.Compare(SetTreeLeaf$1__get_Key(s),SetTreeLeaf$1__get_Key(_));if(0!==a)return 0|a;e=r,t=cons(SetTreeModule_empty(),List_tail(o)),n=cons(SetTreeNode$1__get_Right(_),List_tail(i));continue e}{let s,a,_,u,l;switch(List_isEmpty(o)?List_isEmpty(i)?s=2:null!=List_head(i)?(s=1,u=List_tail(i),l=Option_value(List_head(i))):s=2:null!=List_head(o)?(s=0,a=List_tail(o),_=Option_value(List_head(o))):List_isEmpty(i)?s=2:null!=List_head(i)?(s=1,u=List_tail(i),l=Option_value(List_head(i))):s=2,s){case 0:if(_ instanceof SetTreeNode$1){const o=_;e=r,t=ofArrayWithTail([SetTreeNode$1__get_Left(o),SetTreeNode$1_$ctor_5F465FC9(SetTreeLeaf$1__get_Key(o),SetTreeModule_empty(),SetTreeNode$1__get_Right(o),0)],a),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(_))],a),n=i;continue e;case 1:if(l instanceof SetTreeNode$1){const i=l;e=r,t=o,n=ofArrayWithTail([SetTreeNode$1__get_Left(i),SetTreeNode$1_$ctor_5F465FC9(SetTreeLeaf$1__get_Key(i),SetTreeModule_empty(),SetTreeNode$1__get_Right(i),0)],u);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],u);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}}}}else{let s,a,_,u,l;switch(Option_value(List_head(i)),List_isEmpty(o)?List_isEmpty(i)?s=2:null!=List_head(i)?(s=1,u=List_tail(i),l=Option_value(List_head(i))):s=2:null!=List_head(o)?(s=0,a=List_tail(o),_=Option_value(List_head(o))):List_isEmpty(i)?s=2:null!=List_head(i)?(s=1,u=List_tail(i),l=Option_value(List_head(i))):s=2,s){case 0:if(_ instanceof SetTreeNode$1){const o=_;e=r,t=ofArrayWithTail([SetTreeNode$1__get_Left(o),SetTreeNode$1_$ctor_5F465FC9(SetTreeLeaf$1__get_Key(o),SetTreeModule_empty(),SetTreeNode$1__get_Right(o),0)],a),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(_))],a),n=i;continue e;case 1:if(l instanceof SetTreeNode$1){const i=l;e=r,t=o,n=ofArrayWithTail([SetTreeNode$1__get_Left(i),SetTreeNode$1_$ctor_5F465FC9(SetTreeLeaf$1__get_Key(i),SetTreeModule_empty(),SetTreeNode$1__get_Right(i),0)],u);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],u);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}else{if(null==List_head(o)){e=r,t=List_tail(o),n=List_tail(i);continue e}{let s,a,_,u,l;switch(Option_value(List_head(o)),List_isEmpty(o)?List_isEmpty(i)?s=2:null!=List_head(i)?(s=1,u=List_tail(i),l=Option_value(List_head(i))):s=2:null!=List_head(o)?(s=0,a=List_tail(o),_=Option_value(List_head(o))):List_isEmpty(i)?s=2:null!=List_head(i)?(s=1,u=List_tail(i),l=Option_value(List_head(i))):s=2,s){case 0:if(_ instanceof SetTreeNode$1){const o=_;e=r,t=ofArrayWithTail([SetTreeNode$1__get_Left(o),SetTreeNode$1_$ctor_5F465FC9(SetTreeLeaf$1__get_Key(o),SetTreeModule_empty(),SetTreeNode$1__get_Right(o),0)],a),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(_))],a),n=i;continue e;case 1:if(l instanceof SetTreeNode$1){const i=l;e=r,t=o,n=ofArrayWithTail([SetTreeNode$1__get_Left(i),SetTreeNode$1_$ctor_5F465FC9(SetTreeLeaf$1__get_Key(i),SetTreeModule_empty(),SetTreeNode$1__get_Right(i),0)],u);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],u);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}}break}}function SetTreeModule_compare(e,t,n){return null==t?null==n?0:-1:null==n?1:0|SetTreeModule_compareStacks(e,List_singleton(t),List_singleton(n))}function SetTreeModule_choose(e){return SetTreeModule_minimumElement(e)}function SetTreeModule_toList(e){const t=(e,n)=>{e:for(;;){const r=n;if(null!=e){const o=Option_value(e);if(o instanceof SetTreeNode$1){const i=o;e=SetTreeNode$1__get_Left(i),n=cons(SetTreeLeaf$1__get_Key(i),t(SetTreeNode$1__get_Right(i),r));continue e}return cons(SetTreeLeaf$1__get_Key(o),r)}return r}};return t(e,List_empty())}function SetTreeModule_copyToArray(e,t,n){let r=n;SetTreeModule_iter(e=>{setItem(t,r,e),r=r+1|0},e)}function SetTreeModule_toArray(e){const t=0|SetTreeModule_count(e),n=Set_fill(new Array(t),0,t,null);return SetTreeModule_copyToArray(e,n,0),n}function SetTreeModule_mkFromEnumerator(e,t,n){for(;;){const r=e,o=t,i=n;if(!i["System.Collections.IEnumerator.MoveNext"]())return o;e=r,t=SetTreeModule_add(r,i["System.Collections.Generic.IEnumerator`1.get_Current"](),o),n=i}}function SetTreeModule_ofArray(e,t){return fold((t,n)=>SetTreeModule_add(e,n,t),SetTreeModule_empty(),t)}function SetTreeModule_ofList(e,t){return List_fold((t,n)=>SetTreeModule_add(e,n,t),SetTreeModule_empty(),t)}function SetTreeModule_ofSeq(e,t){if(isArrayLike(t))return SetTreeModule_ofArray(e,t);if(t instanceof List_FSharpList)return SetTreeModule_ofList(e,t);{const n=getEnumerator(t);try{return SetTreeModule_mkFromEnumerator(e,SetTreeModule_empty(),n)}finally{disposeSafe(n)}}}class FSharpSet{constructor(e,t){this.comparer=e,this.tree=t}GetHashCode(){return 0|FSharpSet__ComputeHashCode(this)}Equals(e){let t;return e instanceof FSharpSet&&(t=e,0===SetTreeModule_compare(FSharpSet__get_Comparer(this),FSharpSet__get_Tree(this),FSharpSet__get_Tree(t)))}toString(){let e="set [",t=!0;const n=getEnumerator(this);try{for(;n["System.Collections.IEnumerator.MoveNext"]();){let r,o,i;e=(t?e:e+"; ")+(r=n["System.Collections.Generic.IEnumerator`1.get_Current"](),o=r,"string"==typeof o?(i=o,'"'+i+'"'):Types_toString(r)),t=!1}}finally{disposeSafe(n)}return e+"]"}get[Symbol.toStringTag](){return"FSharpSet"}toJSON(){return Array.from(this)}CompareTo(e){let t;return 0|(e instanceof FSharpSet?(t=e,SetTreeModule_compare(FSharpSet__get_Comparer(this),FSharpSet__get_Tree(this),FSharpSet__get_Tree(t))):1)}"System.Collections.Generic.ICollection`1.Add2B595"(e){throw NotSupportedException_$ctor_Z721C83C5("ReadOnlyCollection")}"System.Collections.Generic.ICollection`1.Clear"(){throw NotSupportedException_$ctor_Z721C83C5("ReadOnlyCollection")}"System.Collections.Generic.ICollection`1.Remove2B595"(e){throw NotSupportedException_$ctor_Z721C83C5("ReadOnlyCollection")}"System.Collections.Generic.ICollection`1.Contains2B595"(e){return SetTreeModule_mem(FSharpSet__get_Comparer(this),e,FSharpSet__get_Tree(this))}"System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(e,t){SetTreeModule_copyToArray(FSharpSet__get_Tree(this),e,t)}"System.Collections.Generic.ICollection`1.get_IsReadOnly"(){return!0}"System.Collections.Generic.ICollection`1.get_Count"(){return 0|FSharpSet__get_Count(this)}"System.Collections.Generic.IReadOnlyCollection`1.get_Count"(){return 0|FSharpSet__get_Count(this)}GetEnumerator(){return SetTreeModule_mkIEnumerator(FSharpSet__get_Tree(this))}[Symbol.iterator](){return toIterator(getEnumerator(this))}"System.Collections.IEnumerable.GetEnumerator"(){return SetTreeModule_mkIEnumerator(FSharpSet__get_Tree(this))}get size(){return 0|FSharpSet__get_Count(this)}add(e){throw new Exception("Set cannot be mutated")}clear(){throw new Exception("Set cannot be mutated")}delete(e){throw new Exception("Set cannot be mutated")}has(e){return FSharpSet__Contains(this,e)}keys(){return Seq_map(e=>e,this)}values(){return Seq_map(e=>e,this)}entries(){return Seq_map(e=>[e,e],this)}forEach(e,t){const n=this;Seq_iterate(t=>{e(t,t,n)},n)}}function FSharpSet_$reflection(e){return Set_class_type("Set.FSharpSet",[e],FSharpSet)}function FSharpSet_$ctor(e,t){return new FSharpSet(e,t)}function FSharpSet__get_Comparer(e){return e.comparer}function FSharpSet__get_Tree(e){return e.tree}function FSharpSet_Empty(e){return FSharpSet_$ctor(e,SetTreeModule_empty())}function FSharpSet__Add(e,t){return FSharpSet_$ctor(FSharpSet__get_Comparer(e),SetTreeModule_add(FSharpSet__get_Comparer(e),t,FSharpSet__get_Tree(e)))}function FSharpSet__Remove(e,t){return FSharpSet_$ctor(FSharpSet__get_Comparer(e),SetTreeModule_remove(FSharpSet__get_Comparer(e),t,FSharpSet__get_Tree(e)))}function FSharpSet__get_Count(e){return 0|SetTreeModule_count(FSharpSet__get_Tree(e))}function FSharpSet__Contains(e,t){return SetTreeModule_mem(FSharpSet__get_Comparer(e),t,FSharpSet__get_Tree(e))}function FSharpSet__Iterate(e,t){SetTreeModule_iter(t,FSharpSet__get_Tree(e))}function FSharpSet__Fold(e,t,n){const r=t;return SetTreeModule_fold((e,t)=>r(t,e),n,FSharpSet__get_Tree(e))}function FSharpSet__get_IsEmpty(e){return null==FSharpSet__get_Tree(e)}function FSharpSet__Partition(e,t){if(null==FSharpSet__get_Tree(e))return[e,e];{const n=SetTreeModule_partition(FSharpSet__get_Comparer(e),t,FSharpSet__get_Tree(e));return[FSharpSet_$ctor(FSharpSet__get_Comparer(e),n[0]),FSharpSet_$ctor(FSharpSet__get_Comparer(e),n[1])]}}function FSharpSet__Filter(e,t){return null==FSharpSet__get_Tree(e)?e:FSharpSet_$ctor(FSharpSet__get_Comparer(e),SetTreeModule_filter(FSharpSet__get_Comparer(e),t,FSharpSet__get_Tree(e)))}function FSharpSet__Map(e,t,n){return FSharpSet_$ctor(n,SetTreeModule_fold((e,r)=>SetTreeModule_add(n,t(r),e),SetTreeModule_empty(),FSharpSet__get_Tree(e)))}function FSharpSet__Exists(e,t){return SetTreeModule_exists(t,FSharpSet__get_Tree(e))}function FSharpSet__ForAll(e,t){return SetTreeModule_forall(t,FSharpSet__get_Tree(e))}function FSharpSet_op_Subtraction(e,t){return null==FSharpSet__get_Tree(e)||null==FSharpSet__get_Tree(t)?e:FSharpSet_$ctor(FSharpSet__get_Comparer(e),SetTreeModule_diff(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(e),FSharpSet__get_Tree(t)))}function FSharpSet_op_Addition(e,t){return null==FSharpSet__get_Tree(t)?e:null==FSharpSet__get_Tree(e)?t:FSharpSet_$ctor(FSharpSet__get_Comparer(e),SetTreeModule_union(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(e),FSharpSet__get_Tree(t)))}function FSharpSet_Intersection(e,t){return null==FSharpSet__get_Tree(t)?t:null==FSharpSet__get_Tree(e)?e:FSharpSet_$ctor(FSharpSet__get_Comparer(e),SetTreeModule_intersection(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(e),FSharpSet__get_Tree(t)))}function FSharpSet_IntersectionMany(e){return Set_reduce(FSharpSet_Intersection,e)}function FSharpSet_Equality(e,t){return 0===SetTreeModule_compare(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(e),FSharpSet__get_Tree(t))}function FSharpSet_Compare(e,t){return 0|SetTreeModule_compare(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(e),FSharpSet__get_Tree(t))}function FSharpSet__get_Choose(e){return SetTreeModule_choose(FSharpSet__get_Tree(e))}function FSharpSet__get_MinimumElement(e){return SetTreeModule_minimumElement(FSharpSet__get_Tree(e))}function FSharpSet__get_MaximumElement(e){return SetTreeModule_maximumElement(FSharpSet__get_Tree(e))}function FSharpSet__IsSubsetOf(e,t){return SetTreeModule_subset(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(e),FSharpSet__get_Tree(t))}function FSharpSet__IsSupersetOf(e,t){return SetTreeModule_subset(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(t),FSharpSet__get_Tree(e))}function FSharpSet__IsProperSubsetOf(e,t){return SetTreeModule_properSubset(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(e),FSharpSet__get_Tree(t))}function FSharpSet__IsProperSupersetOf(e,t){return SetTreeModule_properSubset(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(t),FSharpSet__get_Tree(e))}function FSharpSet__ToList(e){return SetTreeModule_toList(FSharpSet__get_Tree(e))}function FSharpSet__ToArray(e){return SetTreeModule_toArray(FSharpSet__get_Tree(e))}function FSharpSet__ComputeHashCode(e){let t=0;const n=getEnumerator(e);try{for(;n["System.Collections.IEnumerator.MoveNext"]();)t=(t<<1)+structuralHash(n["System.Collections.Generic.IEnumerator`1.get_Current"]())+631|0}finally{disposeSafe(n)}return 0|Math.abs(t)}function Set_isEmpty(e){return FSharpSet__get_IsEmpty(e)}function Set_contains(e,t){return FSharpSet__Contains(t,e)}function Set_add(e,t){return FSharpSet__Add(t,e)}function Set_singleton(e,t){return FSharpSet__Add(FSharpSet_Empty(t),e)}function Set_remove(e,t){return FSharpSet__Remove(t,e)}function union(e,t){return FSharpSet_op_Addition(e,t)}function unionMany(e,t){return fold_3(FSharpSet_op_Addition,FSharpSet_Empty(t),e)}function intersect(e,t){return FSharpSet_Intersection(e,t)}function intersectMany(e){return FSharpSet_IntersectionMany(e)}function Set_iterate(e,t){FSharpSet__Iterate(t,e)}function Set_empty(e){return FSharpSet_Empty(e)}function Set_forAll(e,t){return FSharpSet__ForAll(t,e)}function Set_exists(e,t){return FSharpSet__Exists(t,e)}function Set_filter(e,t){return FSharpSet__Filter(t,e)}function Set_partition(e,t){return FSharpSet__Partition(t,e)}function Set_fold(e,t,n){return SetTreeModule_fold(e,t,FSharpSet__get_Tree(n))}function Set_foldBack(e,t,n){return SetTreeModule_foldBack(e,FSharpSet__get_Tree(t),n)}function Set_map(e,t,n){return FSharpSet__Map(t,e,n)}function Set_count(e){return 0|FSharpSet__get_Count(e)}function Set_ofList(e,t){return FSharpSet_$ctor(t,SetTreeModule_ofSeq(t,e))}function Set_ofArray(e,t){return FSharpSet_$ctor(t,SetTreeModule_ofArray(t,e))}function Set_toList(e){return FSharpSet__ToList(e)}function Set_toArray(e){return FSharpSet__ToArray(e)}function Set_toSeq(e){return Set_map_1(e=>e,e)}function Set_ofSeq(e,t){return FSharpSet_$ctor(t,SetTreeModule_ofSeq(t,e))}function difference(e,t){return FSharpSet_op_Subtraction(e,t)}function isSubset(e,t){return SetTreeModule_subset(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(e),FSharpSet__get_Tree(t))}function isSuperset(e,t){return SetTreeModule_subset(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(t),FSharpSet__get_Tree(e))}function isProperSubset(e,t){return SetTreeModule_properSubset(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(e),FSharpSet__get_Tree(t))}function isProperSuperset(e,t){return SetTreeModule_properSubset(FSharpSet__get_Comparer(e),FSharpSet__get_Tree(t),FSharpSet__get_Tree(e))}function minElement(e){return FSharpSet__get_MinimumElement(e)}function maxElement(e){return FSharpSet__get_MaximumElement(e)}function unionWith(e,t){return fold_3((e,t)=>e.add(t),e,t)}function newMutableSetWith(e,t){return e instanceof HashSet?HashSet_$ctor_Z6150332D(t,HashSet__get_Comparer(e)):new Set(t)}function intersectWith(e,t){const n=newMutableSetWith(e,t);iterate_1(t=>{n.has(t)||e.delete(t)},e.values())}function exceptWith(e,t){iterate_1(t=>{e.delete(t)},t)}function isSubsetOf(e,t){const n=newMutableSetWith(e,t);return forAll_1(e=>n.has(e),e.values())}function isSupersetOf(e,t){return forAll_1(t=>e.has(t),t)}function isProperSubsetOf(e,t){const n=newMutableSetWith(e,t);return n.size>e.size&&forAll_1(e=>n.has(e),e.values())}function isProperSupersetOf(e,t){const n=newMutableSetWith(e,t);return e.size>n.size&&forAll_1(t=>e.has(t),n.values())}function symmetricExceptWith(e,t){const n=newMutableSetWith(e,t);iterate_1(t=>{e.has(t)?e.delete(t):e.add(t)},n.values())}function overlaps(e,t){return exists_1(t=>e.has(t),t)}function setEquals(e,t){const n=newMutableSetWith(e,t);return e.size===n.size&&forAll_1(e=>n.has(e),e.values())}function Set_copyToArray(e,t,n,r,o){Set_iterateIndexed((e,n)=>{Set_setItem(t,r+e,n)},Set_truncate(o,Set_skip(n,e.values())))}class MapTreeLeaf$2{constructor(e,t){this.k=e,this.v=t}}function MapTreeLeaf$2_$reflection(e,t){return Map_class_type("Map.MapTreeLeaf`2",[e,t],MapTreeLeaf$2)}function MapTreeLeaf$2_$ctor_5BDDA1(e,t){return new MapTreeLeaf$2(e,t)}function MapTreeLeaf$2__get_Key(e){return e.k}function MapTreeLeaf$2__get_Value(e){return e.v}class MapTreeNode$2 extends MapTreeLeaf$2{constructor(e,t,n,r,o){super(e,t),this.left=n,this.right=r,this.h=0|o}}function MapTreeNode$2_$reflection(e,t){return Map_class_type("Map.MapTreeNode`2",[e,t],MapTreeNode$2,MapTreeLeaf$2_$reflection(e,t))}function MapTreeNode$2_$ctor_Z39DE9543(e,t,n,r,o){return new MapTreeNode$2(e,t,n,r,o)}function MapTreeNode$2__get_Left(e){return e.left}function MapTreeNode$2__get_Right(e){return e.right}function MapTreeNode$2__get_Height(e){return 0|e.h}function MapTreeModule_empty(){}function MapTreeModule_sizeAux(e,t){e:for(;;){const n=e;if(null!=t){const r=Option_value(t);if(r instanceof MapTreeNode$2){const o=r;e=MapTreeModule_sizeAux(n+1,MapTreeNode$2__get_Left(o)),t=MapTreeNode$2__get_Right(o);continue e}return n+1|0}return 0|n}}function MapTreeModule_size(e){return 0|MapTreeModule_sizeAux(0,e)}function MapTreeModule_mk(e,t,n,r){let o,i,s,a;if(null!=e){const t=Option_value(e);s=t instanceof MapTreeNode$2?(o=t,MapTreeNode$2__get_Height(o)):1}else s=0;if(null!=r){const e=Option_value(r);a=e instanceof MapTreeNode$2?(i=e,MapTreeNode$2__get_Height(i)):1}else a=0;const _=0|(s<a?a:s);return 0===_?MapTreeLeaf$2_$ctor_5BDDA1(t,n):MapTreeNode$2_$ctor_Z39DE9543(t,n,e,r,_+1)}function MapTreeModule_rebalance(e,t,n,r){let o,i,s,a,_,u,l,c,d,p;if(null!=e){const t=Option_value(e);d=t instanceof MapTreeNode$2?(o=t,MapTreeNode$2__get_Height(o)):1}else d=0;if(null!=r){const e=Option_value(r);p=e instanceof MapTreeNode$2?(i=e,MapTreeNode$2__get_Height(i)):1}else p=0;if(p>d+2){const o=Option_value(r);if(o instanceof MapTreeNode$2){const r=o;if(s=MapTreeNode$2__get_Left(r),(null!=s?(a=Option_value(s),a instanceof MapTreeNode$2?(_=a,MapTreeNode$2__get_Height(_)):1):0)>d+1){const o=Option_value(MapTreeNode$2__get_Left(r));if(o instanceof MapTreeNode$2){const i=o;return MapTreeModule_mk(MapTreeModule_mk(e,t,n,MapTreeNode$2__get_Left(i)),MapTreeLeaf$2__get_Key(i),MapTreeLeaf$2__get_Value(i),MapTreeModule_mk(MapTreeNode$2__get_Right(i),MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r),MapTreeNode$2__get_Right(r)))}throw new Exception("internal error: Map.rebalance")}return MapTreeModule_mk(MapTreeModule_mk(e,t,n,MapTreeNode$2__get_Left(r)),MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r),MapTreeNode$2__get_Right(r))}throw new Exception("internal error: Map.rebalance")}if(d>p+2){const o=Option_value(e);if(o instanceof MapTreeNode$2){const e=o;if(u=MapTreeNode$2__get_Right(e),(null!=u?(l=Option_value(u),l instanceof MapTreeNode$2?(c=l,MapTreeNode$2__get_Height(c)):1):0)>p+1){const o=Option_value(MapTreeNode$2__get_Right(e));if(o instanceof MapTreeNode$2){const i=o;return MapTreeModule_mk(MapTreeModule_mk(MapTreeNode$2__get_Left(e),MapTreeLeaf$2__get_Key(e),MapTreeLeaf$2__get_Value(e),MapTreeNode$2__get_Left(i)),MapTreeLeaf$2__get_Key(i),MapTreeLeaf$2__get_Value(i),MapTreeModule_mk(MapTreeNode$2__get_Right(i),t,n,r))}throw new Exception("internal error: Map.rebalance")}return MapTreeModule_mk(MapTreeNode$2__get_Left(e),MapTreeLeaf$2__get_Key(e),MapTreeLeaf$2__get_Value(e),MapTreeModule_mk(MapTreeNode$2__get_Right(e),t,n,r))}throw new Exception("internal error: Map.rebalance")}return MapTreeModule_mk(e,t,n,r)}function MapTreeModule_add(e,t,n,r){if(null!=r){const o=Option_value(r),i=0|e.Compare(t,MapTreeLeaf$2__get_Key(o));if(o instanceof MapTreeNode$2){const r=o;return i<0?MapTreeModule_rebalance(MapTreeModule_add(e,t,n,MapTreeNode$2__get_Left(r)),MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r),MapTreeNode$2__get_Right(r)):0===i?MapTreeNode$2_$ctor_Z39DE9543(t,n,MapTreeNode$2__get_Left(r),MapTreeNode$2__get_Right(r),MapTreeNode$2__get_Height(r)):MapTreeModule_rebalance(MapTreeNode$2__get_Left(r),MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r),MapTreeModule_add(e,t,n,MapTreeNode$2__get_Right(r)))}return i<0?MapTreeNode$2_$ctor_Z39DE9543(t,n,MapTreeModule_empty(),r,2):0===i?MapTreeLeaf$2_$ctor_5BDDA1(t,n):MapTreeNode$2_$ctor_Z39DE9543(t,n,r,MapTreeModule_empty(),2)}return MapTreeLeaf$2_$ctor_5BDDA1(t,n)}function MapTreeModule_tryFind(e,t,n){e:for(;;){const r=e,o=t;if(null!=n){const i=Option_value(n),s=0|r.Compare(o,MapTreeLeaf$2__get_Key(i));if(0===s)return some(MapTreeLeaf$2__get_Value(i));if(i instanceof MapTreeNode$2){const a=i;e=r,t=o,n=s<0?MapTreeNode$2__get_Left(a):MapTreeNode$2__get_Right(a);continue e}return}return}}function MapTreeModule_find(e,t,n){const r=MapTreeModule_tryFind(e,t,n);if(null==r)throw KeyNotFoundException_$ctor();return Option_value(r)}function MapTreeModule_partition1(e,t,n,r,o,i){return t(n,r)?[MapTreeModule_add(e,n,r,o),i]:[o,MapTreeModule_add(e,n,r,i)]}function MapTreeModule_partitionAux(e,t,n,r,o){e:for(;;){const i=e,s=t,a=[r,o];if(null!=n){const _=Map_value_1(n);if(_ instanceof MapTreeNode$2){const u=_,l=MapTreeModule_partitionAux(i,s,MapTreeNode$2__get_Right(u),a[0],a[1]),c=MapTreeModule_partition1(i,s,MapTreeLeaf$2__get_Key(u),MapTreeLeaf$2__get_Value(u),l[0],l[1]);e=i,t=s,n=MapTreeNode$2__get_Left(u),r=c[0],o=c[1];continue e}return MapTreeModule_partition1(i,s,MapTreeLeaf$2__get_Key(_),MapTreeLeaf$2__get_Value(_),a[0],a[1])}return a}}function MapTreeModule_partition(e,t,n){return MapTreeModule_partitionAux(e,t,n,MapTreeModule_empty(),MapTreeModule_empty())}function MapTreeModule_filter1(e,t,n,r,o){return t(n,r)?MapTreeModule_add(e,n,r,o):o}function MapTreeModule_filterAux(e,t,n,r){e:for(;;){const o=e,i=t,s=r;if(null!=n){const a=Map_value_1(n);if(a instanceof MapTreeNode$2){const _=a,u=MapTreeModule_filterAux(o,i,MapTreeNode$2__get_Left(_),s),l=MapTreeModule_filter1(o,i,MapTreeLeaf$2__get_Key(_),MapTreeLeaf$2__get_Value(_),u);e=o,t=i,n=MapTreeNode$2__get_Right(_),r=l;continue e}return MapTreeModule_filter1(o,i,MapTreeLeaf$2__get_Key(a),MapTreeLeaf$2__get_Value(a),s)}return s}}function MapTreeModule_filter(e,t,n){return MapTreeModule_filterAux(e,t,n,MapTreeModule_empty())}function MapTreeModule_spliceOutSuccessor(e){if(null!=e){const t=Option_value(e);if(t instanceof MapTreeNode$2){const e=t;if(null==MapTreeNode$2__get_Left(e))return[MapTreeLeaf$2__get_Key(e),MapTreeLeaf$2__get_Value(e),MapTreeNode$2__get_Right(e)];{const t=MapTreeModule_spliceOutSuccessor(MapTreeNode$2__get_Left(e));return[t[0],t[1],MapTreeModule_mk(t[2],MapTreeLeaf$2__get_Key(e),MapTreeLeaf$2__get_Value(e),MapTreeNode$2__get_Right(e))]}}return[MapTreeLeaf$2__get_Key(t),MapTreeLeaf$2__get_Value(t),MapTreeModule_empty()]}throw new Exception("internal error: Map.spliceOutSuccessor")}function MapTreeModule_remove(e,t,n){if(null!=n){const r=Map_value_1(n),o=0|e.Compare(t,MapTreeLeaf$2__get_Key(r));if(r instanceof MapTreeNode$2){const n=r;if(o<0)return MapTreeModule_rebalance(MapTreeModule_remove(e,t,MapTreeNode$2__get_Left(n)),MapTreeLeaf$2__get_Key(n),MapTreeLeaf$2__get_Value(n),MapTreeNode$2__get_Right(n));if(0===o){if(null==MapTreeNode$2__get_Left(n))return MapTreeNode$2__get_Right(n);if(null==MapTreeNode$2__get_Right(n))return MapTreeNode$2__get_Left(n);{const e=MapTreeModule_spliceOutSuccessor(MapTreeNode$2__get_Right(n));return MapTreeModule_mk(MapTreeNode$2__get_Left(n),e[0],e[1],e[2])}}return MapTreeModule_rebalance(MapTreeNode$2__get_Left(n),MapTreeLeaf$2__get_Key(n),MapTreeLeaf$2__get_Value(n),MapTreeModule_remove(e,t,MapTreeNode$2__get_Right(n)))}return 0===o?MapTreeModule_empty():n}return MapTreeModule_empty()}function MapTreeModule_change(e,t,n,r){if(null!=r){const o=Option_value(r);if(o instanceof MapTreeNode$2){const r=o,i=0|e.Compare(t,MapTreeLeaf$2__get_Key(r));if(i<0)return MapTreeModule_rebalance(MapTreeModule_change(e,t,n,MapTreeNode$2__get_Left(r)),MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r),MapTreeNode$2__get_Right(r));if(0===i){const e=n(some(MapTreeLeaf$2__get_Value(r)));if(null!=e)return MapTreeNode$2_$ctor_Z39DE9543(t,Option_value(e),MapTreeNode$2__get_Left(r),MapTreeNode$2__get_Right(r),MapTreeNode$2__get_Height(r));if(null==MapTreeNode$2__get_Left(r))return MapTreeNode$2__get_Right(r);if(null==MapTreeNode$2__get_Right(r))return MapTreeNode$2__get_Left(r);{const e=MapTreeModule_spliceOutSuccessor(MapTreeNode$2__get_Right(r));return MapTreeModule_mk(MapTreeNode$2__get_Left(r),e[0],e[1],e[2])}}return MapTreeModule_rebalance(MapTreeNode$2__get_Left(r),MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r),MapTreeModule_change(e,t,n,MapTreeNode$2__get_Right(r)))}{const i=0|e.Compare(t,MapTreeLeaf$2__get_Key(o));if(i<0){const e=n(void 0);return null!=e?MapTreeNode$2_$ctor_Z39DE9543(t,Option_value(e),MapTreeModule_empty(),r,2):r}if(0===i){const e=n(some(MapTreeLeaf$2__get_Value(o)));return null!=e?MapTreeLeaf$2_$ctor_5BDDA1(t,Option_value(e)):MapTreeModule_empty()}{const e=n(void 0);return null!=e?MapTreeNode$2_$ctor_Z39DE9543(t,Option_value(e),r,MapTreeModule_empty(),2):r}}}{const e=n(void 0);return null!=e?MapTreeLeaf$2_$ctor_5BDDA1(t,Option_value(e)):r}}function MapTreeModule_mem(e,t,n){e:for(;;){const r=e,o=t;if(null!=n){const i=Option_value(n),s=0|r.Compare(o,MapTreeLeaf$2__get_Key(i));if(i instanceof MapTreeNode$2){const a=i;if(s<0){e=r,t=o,n=MapTreeNode$2__get_Left(a);continue e}if(0===s)return!0;e=r,t=o,n=MapTreeNode$2__get_Right(a);continue e}return 0===s}return!1}}function MapTreeModule_iterOpt(e,t){e:for(;;){const n=e;if(null!=t){const r=Option_value(t);if(r instanceof MapTreeNode$2){const o=r;MapTreeModule_iterOpt(n,MapTreeNode$2__get_Left(o)),n(MapTreeLeaf$2__get_Key(o),MapTreeLeaf$2__get_Value(o)),e=n,t=MapTreeNode$2__get_Right(o);continue e}n(MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r))}break}}function MapTreeModule_iter(e,t){MapTreeModule_iterOpt(e,t)}function MapTreeModule_tryPickOpt(e,t){e:for(;;){const n=e;if(null!=t){const r=Map_value_1(t);if(r instanceof MapTreeNode$2){const o=r,i=MapTreeModule_tryPickOpt(n,MapTreeNode$2__get_Left(o));if(null==i){const r=n(MapTreeLeaf$2__get_Key(o),MapTreeLeaf$2__get_Value(o));if(null==r){e=n,t=MapTreeNode$2__get_Right(o);continue e}return r}return i}return n(MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r))}return}}function MapTreeModule_tryPick(e,t){return MapTreeModule_tryPickOpt(e,t)}function MapTreeModule_existsOpt(e,t){e:for(;;){const n=e;if(null!=t){const r=Map_value_1(t);if(r instanceof MapTreeNode$2){const o=r;if(MapTreeModule_existsOpt(n,MapTreeNode$2__get_Left(o))||n(MapTreeLeaf$2__get_Key(o),MapTreeLeaf$2__get_Value(o)))return!0;e=n,t=MapTreeNode$2__get_Right(o);continue e}return n(MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r))}return!1}}function MapTreeModule_exists(e,t){return MapTreeModule_existsOpt(e,t)}function MapTreeModule_forallOpt(e,t){e:for(;;){const n=e;if(null!=t){const r=Map_value_1(t);if(r instanceof MapTreeNode$2){const o=r;if(MapTreeModule_forallOpt(n,MapTreeNode$2__get_Left(o))&&n(MapTreeLeaf$2__get_Key(o),MapTreeLeaf$2__get_Value(o))){e=n,t=MapTreeNode$2__get_Right(o);continue e}return!1}return n(MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r))}return!0}}function MapTreeModule_forall(e,t){return MapTreeModule_forallOpt(e,t)}function MapTreeModule_map(e,t){if(null!=t){const n=Map_value_1(t);if(n instanceof MapTreeNode$2){const t=n,r=MapTreeModule_map(e,MapTreeNode$2__get_Left(t)),o=e(MapTreeLeaf$2__get_Value(t)),i=MapTreeModule_map(e,MapTreeNode$2__get_Right(t));return MapTreeNode$2_$ctor_Z39DE9543(MapTreeLeaf$2__get_Key(t),o,r,i,MapTreeNode$2__get_Height(t))}return MapTreeLeaf$2_$ctor_5BDDA1(MapTreeLeaf$2__get_Key(n),e(MapTreeLeaf$2__get_Value(n)))}return MapTreeModule_empty()}function MapTreeModule_mapiOpt(e,t){if(null!=t){const n=Map_value_1(t);if(n instanceof MapTreeNode$2){const t=n,r=MapTreeModule_mapiOpt(e,MapTreeNode$2__get_Left(t)),o=e(MapTreeLeaf$2__get_Key(t),MapTreeLeaf$2__get_Value(t)),i=MapTreeModule_mapiOpt(e,MapTreeNode$2__get_Right(t));return MapTreeNode$2_$ctor_Z39DE9543(MapTreeLeaf$2__get_Key(t),o,r,i,MapTreeNode$2__get_Height(t))}return MapTreeLeaf$2_$ctor_5BDDA1(MapTreeLeaf$2__get_Key(n),e(MapTreeLeaf$2__get_Key(n),MapTreeLeaf$2__get_Value(n)))}return MapTreeModule_empty()}function MapTreeModule_mapi(e,t){return MapTreeModule_mapiOpt(e,t)}function MapTreeModule_foldBackOpt(e,t,n){e:for(;;){const r=e,o=n;if(null!=t){const i=Map_value_1(t);if(i instanceof MapTreeNode$2){const s=i,a=MapTreeModule_foldBackOpt(r,MapTreeNode$2__get_Right(s),o),_=r(MapTreeLeaf$2__get_Key(s),MapTreeLeaf$2__get_Value(s),a);e=r,t=MapTreeNode$2__get_Left(s),n=_;continue e}return r(MapTreeLeaf$2__get_Key(i),MapTreeLeaf$2__get_Value(i),o)}return o}}function MapTreeModule_foldBack(e,t,n){return MapTreeModule_foldBackOpt(e,t,n)}function MapTreeModule_foldOpt(e,t,n){e:for(;;){const r=e,o=t;if(null!=n){const i=Map_value_1(n);if(i instanceof MapTreeNode$2){const s=i;e=r,t=r(MapTreeModule_foldOpt(r,o,MapTreeNode$2__get_Left(s)),MapTreeLeaf$2__get_Key(s),MapTreeLeaf$2__get_Value(s)),n=MapTreeNode$2__get_Right(s);continue e}return r(o,MapTreeLeaf$2__get_Key(i),MapTreeLeaf$2__get_Value(i))}return o}}function MapTreeModule_fold(e,t,n){return MapTreeModule_foldOpt(e,t,n)}function MapTreeModule_foldSectionOpt(e,t,n,r,o,i){const s=(r,o,i)=>{e:for(;;){const a=r,_=i;if(null!=o){const u=Map_value_1(o);if(u instanceof MapTreeNode$2){const l=u,c=0|e.Compare(t,MapTreeLeaf$2__get_Key(l)),d=0|e.Compare(MapTreeLeaf$2__get_Key(l),n),p=c<0?s(a,MapTreeNode$2__get_Left(l),_):_,m=c<=0&&d<=0?a(MapTreeLeaf$2__get_Key(l),MapTreeLeaf$2__get_Value(l),p):p;if(d<0){r=a,o=MapTreeNode$2__get_Right(l),i=m;continue e}return m}{const r=0|e.Compare(t,MapTreeLeaf$2__get_Key(u)),o=0|e.Compare(MapTreeLeaf$2__get_Key(u),n);return r<=0&&o<=0?a(MapTreeLeaf$2__get_Key(u),MapTreeLeaf$2__get_Value(u),_):_}}return _}};return 1===e.Compare(t,n)?i:s(r,o,i)}function MapTreeModule_foldSection(e,t,n,r,o,i){return MapTreeModule_foldSectionOpt(e,t,n,r,o,i)}function MapTreeModule_toList(e){const t=(e,n)=>{e:for(;;){const r=n;if(null!=e){const o=Option_value(e);if(o instanceof MapTreeNode$2){const i=o;e=MapTreeNode$2__get_Left(i),n=cons([MapTreeLeaf$2__get_Key(i),MapTreeLeaf$2__get_Value(i)],t(MapTreeNode$2__get_Right(i),r));continue e}return cons([MapTreeLeaf$2__get_Key(o),MapTreeLeaf$2__get_Value(o)],r)}return r}};return t(e,List_empty())}function MapTreeModule_copyToArray(e,t,n){let r=n;MapTreeModule_iter((e,n)=>{setItem(t,r,[e,n]),r=r+1|0},e)}function MapTreeModule_toArray(e){const t=0|MapTreeModule_size(e),n=Map_fill(new Array(t),0,t,[null,null]);return MapTreeModule_copyToArray(e,n,0),n}function MapTreeModule_ofList(e,t){return List_fold((t,n)=>MapTreeModule_add(e,n[0],n[1],t),MapTreeModule_empty(),t)}function MapTreeModule_mkFromEnumerator(e,t,n){e:for(;;){const r=e,o=t,i=n;if(i["System.Collections.IEnumerator.MoveNext"]()){const s=i["System.Collections.Generic.IEnumerator`1.get_Current"]();e=r,t=MapTreeModule_add(r,s[0],s[1],o),n=i;continue e}return o}}function MapTreeModule_ofArray(e,t){let n=MapTreeModule_empty();for(let r=0;r<=t.length-1;r++){const o=item(r,t);n=MapTreeModule_add(e,o[0],o[1],n)}return n}function MapTreeModule_ofSeq(e,t){if(isArrayLike(t))return MapTreeModule_ofArray(e,t);if(t instanceof List_FSharpList)return MapTreeModule_ofList(e,t);{const n=getEnumerator(t);try{return MapTreeModule_mkFromEnumerator(e,MapTreeModule_empty(),n)}finally{disposeSafe(n)}}}class MapTreeModule_MapIterator$2 extends Record{constructor(e,t){super(),this.stack=e,this.started=t}}function MapTreeModule_MapIterator$2_$reflection(e,t){return Map_record_type("Map.MapTreeModule.MapIterator`2",[e,t],MapTreeModule_MapIterator$2,()=>[["stack",Map_list_type(Map_option_type(MapTreeLeaf$2_$reflection(e,t)))],["started",Map_bool_type]])}function MapTreeModule_collapseLHS(e){e:for(;;){const t=e;if(List_isEmpty(t))return List_empty();{const n=List_tail(t),r=List_head(t);if(null!=r){const o=Option_value(r);if(o instanceof MapTreeNode$2){const t=o;e=ofArrayWithTail([MapTreeNode$2__get_Left(t),MapTreeLeaf$2_$ctor_5BDDA1(MapTreeLeaf$2__get_Key(t),MapTreeLeaf$2__get_Value(t)),MapTreeNode$2__get_Right(t)],n);continue e}return t}e=n;continue e}}}function MapTreeModule_mkIterator(e){return new MapTreeModule_MapIterator$2(MapTreeModule_collapseLHS(List_singleton(e)),!1)}function MapTreeModule_notStarted(){throw new Exception("enumeration not started")}function MapTreeModule_alreadyFinished(){throw new Exception("enumeration already finished")}function MapTreeModule_current(e){if(e.started){const t=e.stack;if(List_isEmpty(t))return MapTreeModule_alreadyFinished();if(null!=List_head(t)){const e=Option_value(List_head(t));if(e instanceof MapTreeNode$2)throw new Exception("Please report error: Map iterator, unexpected stack for current");return[MapTreeLeaf$2__get_Key(e),MapTreeLeaf$2__get_Value(e)]}throw new Exception("Please report error: Map iterator, unexpected stack for current")}return MapTreeModule_notStarted()}function MapTreeModule_moveNext(e){if(e.started){const t=e.stack;if(List_isEmpty(t))return!1;if(null!=List_head(t)){if(Option_value(List_head(t))instanceof MapTreeNode$2)throw new Exception("Please report error: Map iterator, unexpected stack for moveNext");return e.stack=MapTreeModule_collapseLHS(List_tail(t)),!List_isEmpty(e.stack)}throw new Exception("Please report error: Map iterator, unexpected stack for moveNext")}return e.started=!0,!List_isEmpty(e.stack)}function MapTreeModule_mkIEnumerator(e){let t=MapTreeModule_mkIterator(e);return{"System.Collections.Generic.IEnumerator`1.get_Current":()=>MapTreeModule_current(t),"System.Collections.IEnumerator.get_Current":()=>MapTreeModule_current(t),"System.Collections.IEnumerator.MoveNext":()=>MapTreeModule_moveNext(t),"System.Collections.IEnumerator.Reset"(){t=MapTreeModule_mkIterator(e)},Dispose(){}}}function MapTreeModule_toSeq(e){return Map_unfold(e=>e["System.Collections.IEnumerator.MoveNext"]()?[e["System.Collections.Generic.IEnumerator`1.get_Current"](),e]:void 0,MapTreeModule_mkIEnumerator(e))}function MapTreeModule_leftmost(e){e:for(;;){if(null!=e){const t=Map_value_1(e);let n,r;if(t instanceof MapTreeNode$2&&MapTreeNode$2__get_Height(t)>1?(n=0,r=t):n=1,0===n){if(null==MapTreeNode$2__get_Left(r))return[MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r)];e=MapTreeNode$2__get_Left(r);continue e}return[MapTreeLeaf$2__get_Key(t),MapTreeLeaf$2__get_Value(t)]}throw Map_KeyNotFoundException_$ctor()}}function MapTreeModule_rightmost(e){e:for(;;){if(null!=e){const t=Map_value_1(e);let n,r;if(t instanceof MapTreeNode$2&&MapTreeNode$2__get_Height(t)>1?(n=0,r=t):n=1,0===n){if(null==MapTreeNode$2__get_Right(r))return[MapTreeLeaf$2__get_Key(r),MapTreeLeaf$2__get_Value(r)];e=MapTreeNode$2__get_Right(r);continue e}return[MapTreeLeaf$2__get_Key(t),MapTreeLeaf$2__get_Value(t)]}throw Map_KeyNotFoundException_$ctor()}}class FSharpMap{constructor(e,t){this.comparer=e,this.tree=t}GetHashCode(){return 0|FSharpMap__ComputeHashCode(this)}Equals(e){if(!(e instanceof FSharpMap))return!1;{const t=e,n=getEnumerator(this);try{const e=getEnumerator(t);try{const t=()=>{const r=n["System.Collections.IEnumerator.MoveNext"]();if(r===e["System.Collections.IEnumerator.MoveNext"]()){if(r){const r=n["System.Collections.Generic.IEnumerator`1.get_Current"](),o=e["System.Collections.Generic.IEnumerator`1.get_Current"]();return!(!equals(r[0],o[0])||!equals(r[1],o[1]))&&t()}return!0}return!1};return t()}finally{disposeSafe(e)}}finally{disposeSafe(n)}}}toString(){return"map ["+join("; ",Seq_map(e=>format("({0}, {1})",e[0],e[1]),this))+"]"}get[Symbol.toStringTag](){return"FSharpMap"}toJSON(){return Array.from(this)}GetEnumerator(){return MapTreeModule_mkIEnumerator(this.tree)}[Symbol.iterator](){return toIterator(getEnumerator(this))}"System.Collections.IEnumerable.GetEnumerator"(){return MapTreeModule_mkIEnumerator(this.tree)}CompareTo(e){let t;const n=this;return 0|(e instanceof FSharpMap?(t=e,Seq_compareWith((e,t)=>{const r=0|n.comparer.Compare(e[0],t[0]);return 0|(0!==r?r:compare(e[1],t[1]))},n,t)):1)}"System.Collections.Generic.ICollection`1.Add2B595"(e){throw NotSupportedException_$ctor_Z721C83C5("Map cannot be mutated")}"System.Collections.Generic.ICollection`1.Clear"(){throw NotSupportedException_$ctor_Z721C83C5("Map cannot be mutated")}"System.Collections.Generic.ICollection`1.Remove2B595"(e){throw NotSupportedException_$ctor_Z721C83C5("Map cannot be mutated")}"System.Collections.Generic.ICollection`1.Contains2B595"(e){return FSharpMap__ContainsKey(this,e[0])&&equals(FSharpMap__get_Item(this,e[0]),e[1])}"System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(e,t){MapTreeModule_copyToArray(this.tree,e,t)}"System.Collections.Generic.ICollection`1.get_IsReadOnly"(){return!0}"System.Collections.Generic.ICollection`1.get_Count"(){return 0|FSharpMap__get_Count(this)}"System.Collections.Generic.IReadOnlyCollection`1.get_Count"(){return 0|FSharpMap__get_Count(this)}get size(){return 0|FSharpMap__get_Count(this)}clear(){throw new Exception("Map cannot be mutated")}delete(e){throw new Exception("Map cannot be mutated")}entries(){return Seq_map(e=>[e[0],e[1]],this)}get(e){return FSharpMap__get_Item(this,e)}has(e){return FSharpMap__ContainsKey(this,e)}keys(){return Seq_map(e=>e[0],this)}set(e,t){throw new Exception("Map cannot be mutated")}values(){return Seq_map(e=>e[1],this)}forEach(e,t){const n=this;Seq_iterate(t=>{e(t[1],t[0],n)},n)}}function FSharpMap_$reflection(e,t){return Map_class_type("Map.FSharpMap",[e,t],FSharpMap)}function FSharpMap_$ctor(e,t){return new FSharpMap(e,t)}function FSharpMap_Empty(e){return FSharpMap_$ctor(e,MapTreeModule_empty())}function FSharpMap__get_Comparer(e){return e.comparer}function FSharpMap__get_Tree(e){return e.tree}function FSharpMap__Add(e,t,n){return FSharpMap_$ctor(e.comparer,MapTreeModule_add(e.comparer,t,n,e.tree))}function FSharpMap__Change(e,t,n){return FSharpMap_$ctor(e.comparer,MapTreeModule_change(e.comparer,t,n,e.tree))}function FSharpMap__get_IsEmpty(e){return null==e.tree}function FSharpMap__get_Item(e,t){return MapTreeModule_find(e.comparer,t,e.tree)}function FSharpMap__TryPick(e,t){return MapTreeModule_tryPick(t,e.tree)}function FSharpMap__Exists(e,t){return MapTreeModule_exists(t,e.tree)}function FSharpMap__Filter(e,t){return FSharpMap_$ctor(e.comparer,MapTreeModule_filter(e.comparer,t,e.tree))}function FSharpMap__ForAll(e,t){return MapTreeModule_forall(t,e.tree)}function FSharpMap__Fold(e,t,n){return MapTreeModule_foldBack(t,e.tree,n)}function FSharpMap__FoldSection(e,t,n,r,o){return MapTreeModule_foldSection(e.comparer,t,n,r,e.tree,o)}function FSharpMap__Iterate(e,t){MapTreeModule_iter(t,e.tree)}function FSharpMap__MapRange(e,t){return FSharpMap_$ctor(e.comparer,MapTreeModule_map(t,e.tree))}function FSharpMap__Map(e,t){return FSharpMap_$ctor(e.comparer,MapTreeModule_mapi(t,e.tree))}function FSharpMap__Partition(e,t){const n=MapTreeModule_partition(e.comparer,t,e.tree);return[FSharpMap_$ctor(e.comparer,n[0]),FSharpMap_$ctor(e.comparer,n[1])]}function FSharpMap__get_Count(e){return 0|MapTreeModule_size(e.tree)}function FSharpMap__ContainsKey(e,t){return MapTreeModule_mem(e.comparer,t,e.tree)}function FSharpMap__Remove(e,t){return FSharpMap_$ctor(e.comparer,MapTreeModule_remove(e.comparer,t,e.tree))}function FSharpMap__TryGetValue(e,t,n){const r=MapTreeModule_tryFind(e.comparer,t,e.tree);if(null==r)return!1;{const e=Map_value_1(r);return n.contents=e,!0}}function FSharpMap__get_Keys(e){return map_2(e=>e[0],MapTreeModule_toArray(e.tree))}function FSharpMap__get_Values(e){return map_2(e=>e[1],MapTreeModule_toArray(e.tree))}function FSharpMap__get_MinKeyValue(e){return MapTreeModule_leftmost(e.tree)}function FSharpMap__get_MaxKeyValue(e){return MapTreeModule_rightmost(e.tree)}function FSharpMap__TryFind(e,t){return MapTreeModule_tryFind(e.comparer,t,e.tree)}function FSharpMap__ToList(e){return MapTreeModule_toList(e.tree)}function FSharpMap__ToArray(e){return MapTreeModule_toArray(e.tree)}function FSharpMap__ComputeHashCode(e){const t=(e,t)=>(e<<1)+t+631|0;let n=0;const r=getEnumerator(e);try{for(;r["System.Collections.IEnumerator.MoveNext"]();){const e=r["System.Collections.Generic.IEnumerator`1.get_Current"]();n=0|t(n,structuralHash(e[0])),n=0|t(n,structuralHash(e[1]))}}finally{disposeSafe(r)}return 0|n}function Map_isEmpty(e){return FSharpMap__get_IsEmpty(e)}function Map_add(e,t,n){return FSharpMap__Add(n,e,t)}function change(e,t,n){return FSharpMap__Change(n,e,t)}function Map_find(e,t){return FSharpMap__get_Item(t,e)}function Map_tryFind(e,t){return FSharpMap__TryFind(t,e)}function Map_remove(e,t){return FSharpMap__Remove(t,e)}function containsKey(e,t){return FSharpMap__ContainsKey(t,e)}function Map_iterate(e,t){FSharpMap__Iterate(t,e)}function Map_tryPick(e,t){return FSharpMap__TryPick(t,e)}function Map_pick(e,t){const n=Map_tryPick(e,t);if(null!=n)return Map_value_1(n);throw Map_KeyNotFoundException_$ctor()}function Map_exists(e,t){return FSharpMap__Exists(t,e)}function Map_filter(e,t){return FSharpMap__Filter(t,e)}function Map_partition(e,t){return FSharpMap__Partition(t,e)}function Map_forAll(e,t){return FSharpMap__ForAll(t,e)}function Map_map(e,t){return FSharpMap__Map(t,e)}function Map_fold(e,t,n){return MapTreeModule_fold(e,t,FSharpMap__get_Tree(n))}function Map_foldBack(e,t,n){return MapTreeModule_foldBack(e,FSharpMap__get_Tree(t),n)}function Map_toSeq(e){return Map_map_1(e=>[e[0],e[1]],e)}function findKey(e,t){return pick_1(t=>{const n=t[0];return e(n,t[1])?Map_some(n):void 0},t)}function tryFindKey(e,t){return tryPick_1(t=>{const n=t[0];return e(n,t[1])?Map_some(n):void 0},t)}function Map_ofList(e,t){return FSharpMap_$ctor(t,MapTreeModule_ofSeq(t,e))}function Map_ofSeq(e,t){return FSharpMap_$ctor(t,MapTreeModule_ofSeq(t,e))}function Map_ofArray(e,t){return FSharpMap_$ctor(t,MapTreeModule_ofSeq(t,e))}function Map_toList(e){return FSharpMap__ToList(e)}function Map_toArray(e){return FSharpMap__ToArray(e)}function keys(e){return FSharpMap__get_Keys(e)}function values(e){return FSharpMap__get_Values(e)}function minKeyValue(e){return FSharpMap__get_MinKeyValue(e)}function maxKeyValue(e){return FSharpMap__get_MaxKeyValue(e)}function Map_empty(e){return FSharpMap_Empty(e)}function Map_count(e){return 0|FSharpMap__get_Count(e)}const NumberStyles={AllowHexSpecifier:512};function validResponse(e,t){const[,n,r,o]=e;return{sign:n||"",prefix:r||"",digits:o,radix:t}}function Int32_getRange(e,t){switch(t){case 8:return e?[0,255]:[-128,127];case 16:return e?[0,65535]:[-32768,32767];case 32:return e?[0,4294967295]:[-2147483648,2147483647];default:throw new Exception("Invalid bit size.")}}function getInvalidDigits(e){switch(e){case 2:return/[^0-1]/;case 8:return/[^0-7]/;case 10:return/[^0-9]/;case 16:return/[^0-9a-fA-F]/;default:throw new Exception("Invalid Base.")}}function getPrefix(e){switch(e){case 2:return"0b";case 8:return"0o";case 10:default:return"";case 16:return"0x"}}function getRadix(e,t){if(t&NumberStyles.AllowHexSpecifier)return 16;switch(e){case"0b":case"0B":return 2;case"0o":case"0O":return 8;case"0x":case"0X":return 16;default:return 10}}function isValid(e,t,n){const r=/^\s*([\+\-])?(0[xXoObB])?([0-9a-fA-F]+)\s*$/.exec(e.replace(/_/g,""));if(null!=r){const[,,e,o]=r;if(!getInvalidDigits(n=n||getRadix(e,t)).test(o))return validResponse(r,n)}return null}function Int32_parse(e,t,n,r,o){const i=isValid(e,t,o);if(null!=i){let e=Number.parseInt(i.sign+i.digits,i.radix);if(!Number.isNaN(e)){const[t,o]=Int32_getRange(!0,r);!n&&10!==i.radix&&e>=t&&e<=o&&(e=e<<32-r>>32-r);const[s,a]=Int32_getRange(n,r);if(e>=s&&e<=a)return e}}throw new Exception(`The input string ${e} was not in a correct format.`)}function Int32_tryParse(e,t,n,r,o){try{return o.contents=Int32_parse(e,t,n,r),!0}catch{return!1}}function op_UnaryNegation_Int8(e){return-128===e?e:-e}function op_UnaryNegation_Int16(e){return-32768===e?e:-e}function op_UnaryNegation_Int32(e){return-2147483648===e?e:-e}function divRem(e,t,n){const r=~~(e/t),o=e%t;return void 0===n?[r,o]:(n.contents=o,r)}var web_tree_sitter=__webpack_require__(132),TreeSitter_record_type,int32_type,task,Parser,Language;class SourcePosition extends Record{constructor(e,t){super(),this.Row=0|e,this.Column=0|t}}function SourcePosition_$reflection(){return TreeSitter_record_type("Energy.Core.TreeSitter.SourcePosition",[],SourcePosition,()=>[["Row",int32_type],["Column",int32_type]])}function nodeStartPosition(e){return new SourcePosition(e.startPosition.row,e.startPosition.column)}function nodeEndPosition(e){return new SourcePosition(e.endPosition.row,e.endPosition.column)}function nodeChildren(e){return List_ofArray(e.children)}function nodeNamedChildren(e){return List_ofArray(e.namedChildren)}function nodeParent(e){const t=e.parent;return equals(t,defaultOf())?void 0:some(t)}function parseWith(e,t){const n=task();return n.Run(n.Delay(()=>n.Bind(Parser.init(),()=>n.Bind(Language.load(e),e=>{const r=new Parser;r.setLanguage(e);const o=r.parse(t);return n.Return(o.rootNode)}))))}const rangeDeltas="#C$&$&$$$$$$%-%&%=$$$$$$=$$$$D$$'$$$$$$$$$$$$%$$%$$$$&$:$*;$+$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%$$$$$$$$$$$$$$$%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%$$$$&%$$$%$&%'$%$&&%$%$$$$$%$$%$$%$&$$$%%$$&'$$$$$$$$$$$$$$$$$$$$$$$$%$$$$$$$$$$$$$$$$$%$$$$$&$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*%$%%$$'$$$$$$$$h$>5'/1(*$$$4“$$$$$$$$%$&$$'%$$&$$$%$4$,F$%&&$$$$$$$$$$$$$$$$$$$$$$$($$$$$%%VS$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$(%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%$$$$$$$$$$$$%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$I%$)L$$%%$$P$$$%$%$$+>''%.)&%$%%.$$$%C$-8-'%$†$$*$$)%%$'%-&%$1$$$$A>%|.$1-D,%$&$%$%9'$,$&$(%2$<&%$$.X8$5.2$C$Y$$$$&+'$%$*-%%-$$2$%$+%%%9$*$$&'%$$&'%%%%$$+$'%$&%%-%%)$$$$$%%$$)'%%9$*$%$%$%%$$&%'%%&&$*'$$*-%&$$-%$$,$&$9$*$%$(%$$&($%$$%$%$2%%%-$$*$)$$%$+%%%9$*$%$(%$$$$$'%%%%$*%$'%$&%%-$$)-$$$)&&$'&%$$$%&%&&&/'%$%&&$&$%$)$1-&)$$($&$+$&$:$3&$&'$&$'*%$&(%%%-*$*$$$%$+$&$:$-$(%$$$$($$%$%%*%*$$%%%-$%0%%,$&$L%$&'$&$&$$$'&$*&%%-,$)$$%$5&;$,$$%*&$'&&$$$+)-%%$/S$%*'$)$+$-%H%$$$($;$$$-$%,$%($$$)%-%'C$&2$$&%)--$$$$$$$$$$%+$G'1$($%(.$G$+$)$%('%HN%'$)$%%%$-))%%'&$&%*&'0$%%)$$$-&$%I$$($%N$$&Ŭ$'%*$$$'%L$'%D$'%*$$$'%2$\\$'%f%&,7&3-)y%)%$ʏ$$4$=$$&n&&+*0$'&.5&%,5%/0$&$%/W%$*+$%.&$&$$$%-)-))$'&$$-)F$X*(%E$$(i-B$&'%&'%$)&'$&%-A%(.O'=)-$&E:%%$%%X$$$*$$$$%+)-%$-)-)*$)%1$%b'$R$$($$($%*'-*-,,&%$A$'%%$&%-O$$%&$$&%+'G++%%&(-&&-A)%,*N%&++&$0$*'$)$%$%$(Ob0$EH]$($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$,+)%)%++++)%)%+$$$$$$$$++1%++++++($%'$$$&&$%'$&'%%'$&+(&%&$%'$%$.()%$$$%$$$+$$($,$$'%&$$$.$$$-$($-$$%)&$$$-&$$$0&C30'$&/2%$'$%$&%&$$$%$()$$$$$$'$$'$'$%%%($'$$%$$3F$$'$%'((%'$%$%$*$B%%$$$Bį+$$$$7%*$$t$A<K)h<.8_q9Ú$,$Y+’$ě$$$$$$$$$$$$$$AO($$B$$$$$$$$$$3ģ¦$$$$$$$$$$$$$$$$$$$$$$b$$$$C$$ĥS8%)J%C$ŒR$R$$$&%$$$$$$'$$%$)%&$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%)$$$$&$$('$%I$$($%[*$$1$:,*$*$*$*$*$*$*$*$C%$$$$&$$$$$,$%$$$$%$$$$$$$$$$($-%'$$$0%$P=$|/ù=/'$&$$$$$$$$$$$$$$%$$$$$$$$$$%$,'%$(%&$$$%$y%%%%$$}$&$(N$$%'-CG/3B$-A+$2C-J2ţ᧣c删&8$Қ&Z,K)%į$&3-%7$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$&$-$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%%i-%)+:,%$$$$$$$$$$$$$&$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$+$$$$%$$$$$$$$$$%$$$$$$$$&$$$$$$$$$$$$$$$$$$$$($($$$$$$$$$$$%$$'$$$M$$$%$*$&$'$:%%$'$&)%$$)W'+%U3%+%-)5)&$$%$-?+%:.%.$@&&$R$%'%%&0$$-'%($$,-($L)%%%%,&$+$$%-%'3$)&$$$$U$$&%%(%$$$;%$%.$%%%$%$$-)%)%),*$*$N$',$%'sF%$%$%$$$%-)⯇/:'T'ࠣᤣƑ%I*/(($$-$0$($$$%$%$34Ǝ$$3c%YK/$$%3*$$$)3$%%$$$$$$$$$$$$$$$$%$$'&&$'$$$$$$$&$$&$$$%'($ª%$$&$&$$$$$$%-%&%=$$$$$$=$$$$$$$$$%-$P%B&)%)%)%&&%$$$%$$'%-&%%/$=$6$%$2%1Ež(&'P&,X'4%&$0&$RP$¥@&T2$>'C',7$+$(I((A$$G'+$(MKKq%-)G'G'K+W.$³Ś,9-+»)%$$O$%&$%:$$+:%*B+,S6$%((9)&$=($c['%%3%Q$&$%(''$&$@%&'$,*,*@%$@&C+$?%'(*,Y&*9%+6(+5*'/*slZV0V*)G'+-ʼnB$M$%$%%q@-$+9.'(y8*7:,$$$X2*'7-2&$P&'%%%$'.$%<*-)&G($+$-'$%$+F$%$,%$S&,%'''$$$-$$$&$7.5$<&&%$$%)$d*$$$'$2$-$)R$&+(-)%%$+%%%9$*$%$($%$%$'%%%&%$)$((%%*&(®X&+%&$$'(-%$$$&AS&)$$'%$%%$$+-ÉR&'%'%$%:'%ES&+%$$%&$.-)06N$$$%)$$$*-Y>%&%'$('-%&$ãO&,$%$‡CC-,/+%$%+$%$;)$%%%$$$$$$$&,-i+%J&'%%'$$$$$>$-K)$$'+$+$)%&Q0$%&$(@\\Ī,$H$*$)$$$(--6&%A%9$$*$%$%l*$%$I)&$$%$*$$+-))$%$C($%$%$$$$*-ř6%%%Ú$28+'40$ν‰’$(.ç૟ђ$,࿪ɪ⇜ɜ*B$-'%ƒA%($-S*(''$$--$*$8(6˓CC:'ˆn'$$Z*'0c%$$$.%1᠛+ӹM,⌚łT&4'+ƯधŽ(0&,*-%$%$'፿ę-J%_%&&)++%*A'^:e&$½7/z,<ª===*$5==$$%%$%%%'$+'$$$*$.==%$'%+$*$=%$'$($$&*$============?%<$<$)<$<$)<$<$)<$<$)<$<$)$$%UȣZ'U+$1$%(2($2ճ*$4%*$%$(øP&**%-'$$ƓO'-($ԣè%,*LEE*$'-'%̴^$&$'oP$2å'$>$%$$%$$-$'$$$$)$'$$$$$$&$%$$%$$$$$$$$$$%$$%'$*$'$'$$$-$4(&$($4W%ıO'‡/2%2$2$H-0Ä[@0O',*%1)½Ğ(˻+0&0&—/|*/7/'[+-)K+A%%qœ$u$ª/1%(&&(*,<**,&0*L¶$ZH-Щ꜁Eၘ.ā%ᚥ1ᵔూɁ؅፮򮳙$Aƒ£ē︳𐀡%𐀡",Unicode_13_0_0_categories="1.;=;78;<;6;+;<;#7;8>5>$7<8<1.;=?;>?'9<2?>?<->$;>-':-;#<#$<$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$'#$'#%$#%$#%$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#%$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$'$&>&>&>&>&>(#$#$&>#$@&$;#@>#;#@#@#$#@#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$<#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$?(*#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$@#@&;$;6@?=@(6(;(;(;(@'@';@2<;=;?(;2@;'&'(+;'(';'(2?(&(?('+'?';@2'('(@'('@+'(&?;&@(='(&(&(&(@;@'(@;@'@'@'@(2()'()(')()()'('(;+;&'()@'@'@'@'@'@'@(')(@)@)('@)@'@'(@+'=-?=';(@()@'@'@'@'@'@'@'@(@)(@(@(@(@'@'@+('(;@()@'@'@'@'@'@'@(')(@()@)(@'@'(@+;=@'(@()@'@'@'@'@'@'@(')()(@)@)(@()@'@'(@+?'-@('@'@'@'@'@'@'@'@'@'@)()@)@)(@'@)@+-?=?@()('@'@'@'@'()@(@(@(@'@'(@+@;-?'();'@'@'@'@'@(')()@()@)(@)@'@'(@+@'@()'@'@'(')(@)@)('?@')-'(@+-?'@()@'@'@'@'@'@(@)(@(@)@+@);@'('(@='&(;+;@'@'@'@'@'@'('('@'@&@(@+@'@'?;?;?(?+-?(?(?(7878)'@'@()(;('(@(@?(?@?;?;@')()()()('+;')('(')')'('()()(')+)(?#@#@#@$;&$'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@(;-@'?@#@$@6'?;'.'78@';,'@'@'(@'(;@'(@'@'@(@'()()()(;&;='(@+@-@;6;(2@+@'&'@'('('@'@'@()()@)()(@?@;+'@'@'@'@+-@?'()(@;')()(@()()()(@(+@+@;&;@(*(@()'()()()()'@+;?(?@()')()()('+'()()()()@;')()(@;+@'+'&;$@#@#;@(;()('('(')('@$&$&$&(@(#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$@#@$#$#$@#@$@#@#@#@#$#$@$%$%$%$@$#%>$>$@$#%>$@$#@>$#>@$@$#%>@.26;9:79:79;/02.;9:;5;<78;<;5;.2@2-&@-<78&-<78@&@=@(*(*(@?#?#?$#$#$?#?<#?#?#?#?#?$#$'$?$#<#$?<?$?-,#$,-?@<?<?<?<?<?<?<?<?<?<?7878?<?78?<?<?<?@?@-?-?<?<?<?<?78787878787878-?<78<7878787878<?<7878787878787878787878<7878<78<?<?<?@?@?#@$@#$#$#$#$#$#$#$#$&#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$?#$#$(#$@;-;$@$@$@'@&;@('@'@'@'@'@'@'@'@'@(;9:9:;9:;9:;6;6;9:;9:78787878;&;6;6;7;?;@?@?@?@?@.;?&',7878787878?78787878678?,()6&?,&';?@'@(>&'6';&'@'@'@?-?'?@'?@-?-?-?-?-?'?'@'&'@?@'&;'&;'+'@#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$'(*;(;&#$#$#$#$#$#$#$#$#$#$#$#$#$#$&(',(;@>&>#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$&$#$#$#$#$#$#$#$&>#$#$'#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$@#$#$#$@#$'&$'('('(')()?(@-?=?@';@)')(@;+@(';';'(+'(;'()@;'@()'()()();@&+@;'(&'+'@'()()(@'('()@+@;'&'?')()'('('('('('@'&;')();'&)(@'@'@'@'@'@$>&$&>@$')()();)(@+@'@'@'@34'@'@$@$@'('<'@'@'@'@'@'>@'87@'@'@'=?@(;78;@(;657878787878787878;78;5;@;6787878;<6<@;=;@'@'@2@;=;78;<;6;+;<;#7;8>5>$7<8<78;78;'&'&'@'@'@'@'@=<>?=@?<?@2?@'@'@'@'@'@'@'@;@-@?,-?-?@?@?@?(@'@'@(-@'-@',',@'(@'@;'@';,@#$'@+@#@$@'@'@;@'@'@'@'@'@'@'@'@'@;-'?-'@-@'@'@-'-@;'@;@'@-'-@-'(@(@('@'@'@(@(-@;@'-;'-@'?'(@-;@'@;'@-'@-'@;@-@'@#@$@-'(@+@-@'@(6@'@'-'@'(-;@'-@'@)()'(;@-+@()')()(;2;@2@'@+@('()(@+;')'@'(;'@()')()';(;)(+';';@-@'@')()()(;(@'@'@'@'@';@'()(@+@()@'@'@'@'@'@'@(')()@)@)@'@)@')@(@(@')()()(';+;@;('@')()()()(';'@+@')(@)()(;'(@')()()(;'@+@;@'()()()('@+@'@()()(@+-;?@')()(;@#$+-@'@'@'@'@')@)@()(')')(;@+@'@')(@()(';')@'('()'(;(@'()('()(;';@'@'@')(@()(';@+-@;'@(@)()()(@'@'@'(@(@(@('(@+@'@'@')@(@)()('@+@'();@'@-?=?@;'@,@;@'@'@2@'@'@'@+@;@'@(;@'(;?&;?@+@-@'@'@#$-;@'@(')@(&@&;&(@)@'@'@'@'@'@'@'@'@'@'@'@?(;2@?@?@?)(?)2(?(?(?@?(?@-@?@-@#$#$@$#$#@#@#@#@#@#$@$@$@$#$#@#@#@#@$#@#@#@#@#@$#$#$#$#$#$#$@#<$<$#<$<$#<$<$#<$<$#<$<$#$@+?(?(?(?(?;@(@(@(@(@(@(@(@'@(&@+@'?@'(+@=@'@-(@#$(&@+@;@-?-=-@-?-@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@'@<@?@?@?@?@?@?@-?@?@?@?@?@?@?>?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@?@+@'@'@'@'@'@'@'@2@2@(@4@4@";var Char_Exception;function getCategoryFunc(){const e=[...rangeDeltas].map(e=>(e.codePointAt(0)??0)-35),t=[...Unicode_13_0_0_categories].map(e=>(e.codePointAt(0)??0)-35),n=new Uint32Array(e),r=new Uint8Array(t);for(let e=1;e<n.length;++e)n[e]+=n[e-1];return e=>{let t=n.length,o=0;for(;t-o>1;){const r=Math.floor((t+o)/2),i=n[r];if(e<i)t=r;else{if(e===i){t=o=r;break}i<e&&(o=r)}}return r[o]}}const UnicodeCategory={UppercaseLetter:0,LowercaseLetter:1,TitlecaseLetter:2,ModifierLetter:3,OtherLetter:4,NonSpacingMark:5,SpacingCombiningMark:6,EnclosingMark:7,DecimalDigitNumber:8,LetterNumber:9,OtherNumber:10,SpaceSeparator:11,LineSeparator:12,ParagraphSeparator:13,Control:14,Format:15,Surrogate:16,PrivateUse:17,ConnectorPunctuation:18,DashPunctuation:19,OpenPunctuation:20,ClosePunctuation:21,InitialQuotePunctuation:22,FinalQuotePunctuation:23,OtherPunctuation:24,MathSymbol:25,CurrencySymbol:26,ModifierSymbol:27,OtherSymbol:28,OtherNotAssigned:29},isControlMask=1<<UnicodeCategory.Control,isDigitMask=1<<UnicodeCategory.DecimalDigitNumber,isLetterMask=1<<UnicodeCategory.UppercaseLetter|1<<UnicodeCategory.LowercaseLetter|1<<UnicodeCategory.TitlecaseLetter|1<<UnicodeCategory.ModifierLetter|1<<UnicodeCategory.OtherLetter,isLetterOrDigitMask=isLetterMask|isDigitMask,isUpperMask=1<<UnicodeCategory.UppercaseLetter,isLowerMask=1<<UnicodeCategory.LowercaseLetter,isNumberMask=1<<UnicodeCategory.DecimalDigitNumber|1<<UnicodeCategory.LetterNumber|1<<UnicodeCategory.OtherNumber,isPunctuationMask=1<<UnicodeCategory.ConnectorPunctuation|1<<UnicodeCategory.DashPunctuation|1<<UnicodeCategory.OpenPunctuation|1<<UnicodeCategory.ClosePunctuation|1<<UnicodeCategory.InitialQuotePunctuation|1<<UnicodeCategory.FinalQuotePunctuation|1<<UnicodeCategory.OtherPunctuation,isSeparatorMask=1<<UnicodeCategory.SpaceSeparator|1<<UnicodeCategory.LineSeparator|1<<UnicodeCategory.ParagraphSeparator,isSymbolMask=1<<UnicodeCategory.MathSymbol|1<<UnicodeCategory.CurrencySymbol|1<<UnicodeCategory.ModifierSymbol|1<<UnicodeCategory.OtherSymbol,isWhiteSpaceMask=1<<UnicodeCategory.SpaceSeparator|1<<UnicodeCategory.LineSeparator|1<<UnicodeCategory.ParagraphSeparator,unicodeCategoryFunc=getCategoryFunc();function charCodeAt(e,t){if(t>=0&&t<e.length)return e.charCodeAt(t);throw new Exception("Index out of range.")}const getUnicodeCategory=e=>getUnicodeCategory2(e,0),isControl=e=>isControl2(e,0),isDigit=e=>isDigit2(e,0),isLetter=e=>isLetter2(e,0),isLetterOrDigit=e=>isLetterOrDigit2(e,0),isUpper=e=>isUpper2(e,0),isLower=e=>isLower2(e,0),isNumber=e=>isNumber2(e,0),isPunctuation=e=>isPunctuation2(e,0),isSeparator=e=>isSeparator2(e,0),isSymbol=e=>isSymbol2(e,0),isWhiteSpace=e=>isWhiteSpace2(e,0),isHighSurrogate=e=>isHighSurrogate2(e,0),isLowSurrogate=e=>isLowSurrogate2(e,0),isSurrogate=e=>isSurrogate2(e,0);function getUnicodeCategory2(e,t){const n=charCodeAt(e,t);return unicodeCategoryFunc(n)}function isControl2(e,t){return!!(1<<getUnicodeCategory2(e,t)&isControlMask)}function isDigit2(e,t){return!!(1<<getUnicodeCategory2(e,t)&isDigitMask)}function isLetter2(e,t){return!!(1<<getUnicodeCategory2(e,t)&isLetterMask)}function isLetterOrDigit2(e,t){return!!(1<<getUnicodeCategory2(e,t)&isLetterOrDigitMask)}function isUpper2(e,t){return!!(1<<getUnicodeCategory2(e,t)&isUpperMask)}function isLower2(e,t){return!!(1<<getUnicodeCategory2(e,t)&isLowerMask)}function isNumber2(e,t){return!!(1<<getUnicodeCategory2(e,t)&isNumberMask)}function isPunctuation2(e,t){return!!(1<<getUnicodeCategory2(e,t)&isPunctuationMask)}function isSeparator2(e,t){return!!(1<<getUnicodeCategory2(e,t)&isSeparatorMask)}function isSymbol2(e,t){return!!(1<<getUnicodeCategory2(e,t)&isSymbolMask)}function isWhiteSpace2(e,t){if(1<<getUnicodeCategory2(e,t)&isWhiteSpaceMask)return!0;const n=charCodeAt(e,t);return 9<=n&&n<=13||133===n||160===n}function isHighSurrogate2(e,t){const n=charCodeAt(e,t);return 55296<=n&&n<=56319}function isLowSurrogate2(e,t){const n=charCodeAt(e,t);return 56320<=n&&n<=57343}function isSurrogate2(e,t){const n=charCodeAt(e,t);return 55296<=n&&n<=57343}function isSurrogatePair(e,t){return"number"==typeof t?isHighSurrogate2(e,t)&&isLowSurrogate2(e,t+1):isHighSurrogate(e)&&isLowSurrogate(t)}function Char_parse(e){if(1===e.length)return e[0];throw new Char_Exception("String must be exactly one character long.")}function splitIntoWords(e){let t,n;return List_ofArray((t=String_split((n=[void 0,""],Seq_fold((e,t)=>[t,e[1]+(Seq_exists(e=>!(!isLower(e)&&!isDigit(e))&&isUpper(t),toArray(e[0]))?" ":"")+t],[n[0],n[1]],e.split("")))[1],[" ","_","-","."]),t.filter(e=>!isNullOrWhiteSpace(e))))}function isTestFile(e){let t;if(t=String_split(String_replace(e,"\\","/"),["/"],void 0,0).filter(e=>!isNullOrWhiteSpace(e)),t.some(e=>{const t=e.toLowerCase();return"test"===t||"tests"===t}))return!0;{const e=defaultArg(tryLast(t),""),n=0|e.lastIndexOf("."),r=List_map(e=>e.toLowerCase(),splitIntoWords(n>0?substring(e,0,n):e));let o,i,s;return List_isEmpty(r)?(o=1,s=r):"test"===List_head(r)?(o=0,i=List_head(r)):(o=1,s=r),0===o||equals(List_tryLast(s),"test")}}var Double_FSharpRef,Double_Exception,union_type,Violation_record_type,Violation_int32_type,string_type,Violation_list_type,Position_record_type,Position_int32_type,lambda_type,LanguageAdapter_union_type,LanguageAdapter_record_type,LanguageAdapter_string_type,obj_type,LanguageAdapter_list_type,LanguageAdapter_option_type,LanguageAdapter_lambda_type,LanguageAdapter_bool_type,LanguageAdapter_int32_type,LanguageAdapter_class_type,Context_record_type,Context_string_type,Context_obj_type,Context_lambda_type,Context_list_type,Context_PositionLookup_$reflection,Context_LanguageAdapter_$reflection,Context_EnergyViolation_$reflection,MagicNumber_record_type,MagicNumber_bool_type,MagicNumber_list_type,float64_type;function Double_tryParse(e,t){if(null!=e&&/\S/.test(e)){const n=+e.replace("_","");if(!Number.isNaN(n))return t.contents=n,!0}return!1}function Double_parse(e){const t=new Double_FSharpRef(0);if(Double_tryParse(e,t))return t.contents;throw new Double_Exception(`The input string ${e} was not in a correct format.`)}function isPositiveInfinity(e){return e===Number.POSITIVE_INFINITY}function isNegativeInfinity(e){return e===Number.NEGATIVE_INFINITY}function isInfinity(e){return e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY}function Double_max(e,t){return Math.max(e,t)}function Double_min(e,t){return Math.min(e,t)}function maxMagnitude(e,t){return Number.isNaN(e)||Number.isNaN(t)?NaN:Math.abs(e)>Math.abs(t)?e:t}function minMagnitude(e,t){return Number.isNaN(e)||Number.isNaN(t)?NaN:Math.abs(e)<Math.abs(t)?e:t}function Double_clamp(e,t,n){return e<t?t:e>n?n:e}class Severity extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Low","Medium","High"]}static Low=new Severity(0,[]);static Medium=new Severity(1,[]);static High=new Severity(2,[])}function Severity_$reflection(){return union_type("Energy.Core.Violation.Severity",[],Severity,()=>[[],[],[]])}class ViolationType extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Nesting","Complexity","Cognitive","Naming","Coherence","Magic","Parameters","Inversion","PrimitiveObsession","MatchOpportunity","LogicalControlFlow","OpaqueBoolean","Suppression"]}static Nesting=new ViolationType(0,[]);static Complexity=new ViolationType(1,[]);static Cognitive=new ViolationType(2,[]);static Naming=new ViolationType(3,[]);static Coherence=new ViolationType(4,[]);static Magic=new ViolationType(5,[]);static Parameters=new ViolationType(6,[]);static Inversion=new ViolationType(7,[]);static PrimitiveObsession=new ViolationType(8,[]);static MatchOpportunity=new ViolationType(9,[]);static LogicalControlFlow=new ViolationType(10,[]);static OpaqueBoolean=new ViolationType(11,[]);static Suppression=new ViolationType(12,[])}function ViolationType_$reflection(){return union_type("Energy.Core.Violation.ViolationType",[],ViolationType,()=>[[],[],[],[],[],[],[],[],[],[],[],[],[]])}class Hotspot extends Record{constructor(e,t){super(),this.Line=0|e,this.Weight=0|t}}function Hotspot_$reflection(){return Violation_record_type("Energy.Core.Violation.Hotspot",[],Hotspot,()=>[["Line",Violation_int32_type],["Weight",Violation_int32_type]])}class EnergyViolation extends Record{constructor(e,t,n,r,o,i){super(),this.Line=0|e,this.Column=0|t,this.Type=n,this.Severity=r,this.Message=o,this.Hotspots=i}}function EnergyViolation_$reflection(){return Violation_record_type("Energy.Core.Violation.EnergyViolation",[],EnergyViolation,()=>[["Line",Violation_int32_type],["Column",Violation_int32_type],["Type",ViolationType_$reflection()],["Severity",Severity_$reflection()],["Message",string_type],["Hotspots",Violation_list_type(Hotspot_$reflection())]])}function violationTypeName(e){switch(e.tag){case 1:return"complexity";case 2:return"cognitive";case 3:return"naming";case 4:return"coherence";case 5:return"magic";case 6:return"parameters";case 7:return"inversion";case 8:return"primitive-obsession";case 9:return"match-opportunity";case 10:return"logical-control-flow";case 11:return"opaque-boolean";case 12:return"suppression";default:return"nesting"}}function severityName(e){switch(e.tag){case 1:return"medium";case 2:return"high";default:return"low"}}class Position extends Record{constructor(e,t){super(),this.Line=0|e,this.Column=0|t}}function Position_$reflection(){return Position_record_type("Energy.Core.Position.Position",[],Position,()=>[["Line",Position_int32_type],["Column",Position_int32_type]])}class PositionLookup extends Record{constructor(e){super(),this.toPosition=e}}function PositionLookup_$reflection(){return Position_record_type("Energy.Core.Position.PositionLookup",[],PositionLookup,()=>[["toPosition",lambda_type(Position_int32_type,Position_$reflection())]])}function createPositionLookup(e){const t=[0];for(let n=0;n<=e.length-1;n++)"\n"===e[n]&&t.push(n+1);return new PositionLookup(e=>{let n=0,r=t.length-1;for(;n<r;){const o=(n+r+1)/2|0;item(o,t)<=e?n=0|o:r=o-1|0}return new Position(n,e-item(n,t))})}class BooleanOperator extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["And","Or"]}static And=new BooleanOperator(0,[]);static Or=new BooleanOperator(1,[])}function BooleanOperator_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.BooleanOperator",[],BooleanOperator,()=>[[],[]])}class TypedParameter extends Record{constructor(e,t){super(),this.Name=e,this.Type=t}}function TypedParameter_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.TypedParameter",[],TypedParameter,()=>[["Name",LanguageAdapter_string_type],["Type",LanguageAdapter_string_type]])}class GenericBrackets extends Record{constructor(e,t){super(),this.Open=e,this.Close=t}}function GenericBrackets_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.GenericBrackets",[],GenericBrackets,()=>[["Open",LanguageAdapter_string_type],["Close",LanguageAdapter_string_type]])}class EqualityComparison extends Record{constructor(e,t){super(),this.Left=e,this.Right=t}}function EqualityComparison_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.EqualityComparison",[],EqualityComparison,()=>[["Left",obj_type],["Right",obj_type]])}class MembershipComparison extends Record{constructor(e,t){super(),this.Left=e,this.Values=t}}function MembershipComparison_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.MembershipComparison",[],MembershipComparison,()=>[["Left",obj_type],["Values",LanguageAdapter_list_type(LanguageAdapter_string_type)]])}class NodeTypes extends Record{constructor(e,t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y,h){super(),this.Block=e,this.Parameters=t,this.IfStatement=n,this.ElseClause=r,this.ForStatement=o,this.WhileStatement=i,this.ConditionalExpression=s,this.Lambda=a,this.ImportStatement=_,this.ImportFromStatement=u,this.ExpressionStatement=l,this.Assignment=c,this.Module=d,this.ExportStatement=p,this.Comment=m,this.IntegerLiteral=f,this.FloatLiteral=y,this.StringLiteral=h}}function NodeTypes_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.NodeTypes",[],NodeTypes,()=>[["Block",LanguageAdapter_option_type(LanguageAdapter_string_type)],["Parameters",LanguageAdapter_string_type],["IfStatement",LanguageAdapter_option_type(LanguageAdapter_string_type)],["ElseClause",LanguageAdapter_option_type(LanguageAdapter_string_type)],["ForStatement",LanguageAdapter_option_type(LanguageAdapter_string_type)],["WhileStatement",LanguageAdapter_option_type(LanguageAdapter_string_type)],["ConditionalExpression",LanguageAdapter_option_type(LanguageAdapter_string_type)],["Lambda",LanguageAdapter_option_type(LanguageAdapter_string_type)],["ImportStatement",LanguageAdapter_option_type(LanguageAdapter_string_type)],["ImportFromStatement",LanguageAdapter_option_type(LanguageAdapter_string_type)],["ExpressionStatement",LanguageAdapter_option_type(LanguageAdapter_string_type)],["Assignment",LanguageAdapter_option_type(LanguageAdapter_string_type)],["Module",LanguageAdapter_option_type(LanguageAdapter_string_type)],["ExportStatement",LanguageAdapter_option_type(LanguageAdapter_string_type)],["Comment",LanguageAdapter_option_type(LanguageAdapter_string_type)],["IntegerLiteral",LanguageAdapter_option_type(LanguageAdapter_string_type)],["FloatLiteral",LanguageAdapter_option_type(LanguageAdapter_string_type)],["StringLiteral",LanguageAdapter_option_type(LanguageAdapter_string_type)]])}class LanguageAdapter extends Record{constructor(e,t,n,r,o,i,s,a,_,u,l,c,d,p,m,f,y,h,g,S,$,T,L,C,E,w,M,x,F,A,N,v){super(),this.Id=e,this.GrammarPath=t,this.NodeTypes=n,this.IsFunctionDefinition=r,this.ParameterChildTypes=o,this.DecisionNodeTypes=i,this.CyclomaticBranchCount=s,this.CognitiveNestedDecisionTypes=a,this.NestingControlTypes=_,this.GetBooleanOperator=u,this.EntersNestedScope=l,this.IsTryElseClause=c,this.VariableReferenceNodeTypes=d,this.ExtractTypedParameter=p,this.ExtractReturnType=m,this.GenericBrackets=f,this.PrimitiveTypeNames=y,this.KeywordOnlyBoundaryTypes=h,this.DistinctTypeAdvice=g,this.GetEqualityComparisons=S,this.GetMembershipComparisons=$,this.GetElseIfBranches=T,this.SubscriptNodeTypes=L,this.IsFormattedOrInterpolatedString=C,this.IsDefaultParameterValue=E,this.IsBooleanLiteral=w,this.IsPositionalCallArgument=M,this.IsExplicitConstant=x,this.ImportSource=F,this.ClassDefinitionNodeTypes=A,this.GetClassName=N,this.GetBaseClassNames=v}}function LanguageAdapter_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.LanguageAdapter",[],LanguageAdapter,()=>[["Id",LanguageAdapter_string_type],["GrammarPath",LanguageAdapter_string_type],["NodeTypes",NodeTypes_$reflection()],["IsFunctionDefinition",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_bool_type)],["ParameterChildTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["DecisionNodeTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["CyclomaticBranchCount",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_option_type(LanguageAdapter_int32_type))],["CognitiveNestedDecisionTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["NestingControlTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["GetBooleanOperator",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_option_type(BooleanOperator_$reflection()))],["EntersNestedScope",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_bool_type)],["IsTryElseClause",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_bool_type)],["VariableReferenceNodeTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["ExtractTypedParameter",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_option_type(TypedParameter_$reflection()))],["ExtractReturnType",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_option_type(LanguageAdapter_string_type))],["GenericBrackets",GenericBrackets_$reflection()],["PrimitiveTypeNames",LanguageAdapter_class_type("Microsoft.FSharp.Collections.FSharpSet`1",[LanguageAdapter_string_type])],["KeywordOnlyBoundaryTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["DistinctTypeAdvice",LanguageAdapter_string_type],["GetEqualityComparisons",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_list_type(EqualityComparison_$reflection()))],["GetMembershipComparisons",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_list_type(MembershipComparison_$reflection()))],["GetElseIfBranches",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_list_type(obj_type))],["SubscriptNodeTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["IsFormattedOrInterpolatedString",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_bool_type)],["IsDefaultParameterValue",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_bool_type)],["IsBooleanLiteral",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_bool_type)],["IsPositionalCallArgument",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_bool_type)],["IsExplicitConstant",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_bool_type)],["ImportSource",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_string_type)],["ClassDefinitionNodeTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["GetClassName",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_option_type(LanguageAdapter_string_type))],["GetBaseClassNames",LanguageAdapter_lambda_type(obj_type,LanguageAdapter_list_type(LanguageAdapter_string_type))]])}class AnalysisContext extends Record{constructor(e,t,n,r,o){super(),this.Source=e,this.Tree=t,this.Positions=n,this.Language=r,this.FileName=o}}function AnalysisContext_$reflection(){return Context_record_type("Energy.Core.Context.AnalysisContext",[],AnalysisContext,()=>[["Source",Context_string_type],["Tree",Context_obj_type],["Positions",Context_PositionLookup_$reflection()],["Language",Context_LanguageAdapter_$reflection()],["FileName",Context_string_type]])}class Detector extends Record{constructor(e,t){super(),this.Name=e,this.Run=t}}function Detector_$reflection(){return Context_record_type("Energy.Core.Context.Detector",[],Detector,()=>[["Name",Context_string_type],["Run",Context_lambda_type(AnalysisContext_$reflection(),Context_list_type(Context_EnergyViolation_$reflection()))]])}class MagicNumberOptions extends Record{constructor(e,t,n){super(),this.Enabled=e,this.Allowlist=t,this.IncludeTestFiles=n}}function MagicNumberOptions_$reflection(){return MagicNumber_record_type("Energy.Core.Detectors.MagicNumber.MagicNumberOptions",[],MagicNumberOptions,()=>[["Enabled",MagicNumber_bool_type],["Allowlist",MagicNumber_list_type(float64_type)],["IncludeTestFiles",MagicNumber_bool_type]])}const defaultOptions=new MagicNumberOptions(!0,List_ofArray([0,1,-1,2]),!1);function isNodeType(e,t){let n;return Seq_exists((n=t.type,e=>equals(n,e)),toArray(e))}function hasEnclosingFunction(e,t){return(t=>{for(;;){const n=nodeParent(t);if(null==n)return!1;if(e.IsFunctionDefinition(Option_value(n)))return Option_value(n),!0;t=Option_value(n)}})(t)}function isInConstantContext(e,t){return(t=>{e:for(;;){const n=nodeParent(t);if(null==n)return!1;if(e.IsExplicitConstant(Option_value(n)))return Option_value(n),!0;if(isNodeType(e.NodeTypes.Assignment,Option_value(n))){{const r=Option_value(n);if(e.IsFunctionDefinition(r))return!1;{let n;const o=nodeParent(r);let i,s,a,_,u,l;switch(null!=o&&isNodeType(e.NodeTypes.ExpressionStatement,Option_value(o))?(i=0,s=Option_value(o)):(i=1,a=o),n=0===i?nodeParent(s):a,null!=n?isNodeType(e.NodeTypes.Module,Option_value(n))?(_=0,u=Option_value(n)):isNodeType(e.NodeTypes.ExportStatement,Option_value(n))?(_=1,l=Option_value(n)):_=2:_=2,_){case 0:return!hasEnclosingFunction(e,r);case 1:return Seq_exists(t=>isNodeType(e.NodeTypes.Module,t),toArray(nodeParent(l)));default:t=r;continue e}}}break}t=Option_value(n)}})(t)}function signedValue(e,t){const n=nodeParent(e);if(null==n)return t;{const e=nodeChildren(Option_value(n));let r,o;return List_isEmpty(e)||List_isEmpty(List_tail(e))?r=1:List_isEmpty(List_tail(List_tail(e)))&&"-"===List_head(e).text?(r=0,o=List_head(e)):r=1,0===r?-t:t}}function analyzeMagicNumbers(e,t,n,r,o){if(!o.Enabled||!o.IncludeTestFiles&&isTestFile(r))return List_empty();{const r=e=>{let i,s;if(i=e,isNodeType(n.NodeTypes.IntegerLiteral,i)||isNodeType(n.NodeTypes.FloatLiteral,i)){let r,i=0;if(r=[Double_tryParse(e.text,new FSharpRef(()=>i,e=>{i=e})),i],r[0]){if(List_contains(signedValue(e,r[1]),o.Allowlist,{Equals:(e,t)=>e===t,GetHashCode:e=>0|numberHash(e)})||isInConstantContext(n,e)||Seq_exists(e=>List_contains(e.type,n.SubscriptNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),toArray(nodeParent(e)))||n.IsDefaultParameterValue(e))return List_empty();{const n=t.toPosition(e.startIndex);return List_singleton(new EnergyViolation(n.Line,n.Column,ViolationType.Magic,Severity.Low,(s=e.text,toText(printf("Magic number: %s. Consider extracting to a named constant."))(s)),List_empty()))}}return List_empty()}return List_collect(r,nodeChildren(e))};return r(e)}}const detector=new Detector("magicNumber",e=>analyzeMagicNumbers(e.Tree,e.Positions,e.Language,e.FileName,defaultOptions));var MapUtil_Exception,MapUtil_equals,MapUtil_Union;const CaseRules=null;function dashify(e,t){return e.replace(/[a-z]?[A-Z]/g,e=>1===e.length?e.toLowerCase():e.charAt(0)+t+e.charAt(1).toLowerCase())}function changeCase(e,t){switch(t){case CaseRules.LowerFirst:return e.charAt(0).toLowerCase()+e.slice(1);case CaseRules.SnakeCase:return dashify(e,"_");case CaseRules.SnakeCaseAllCaps:return dashify(e,"_").toUpperCase();case CaseRules.KebabCase:return dashify(e,"-");case CaseRules.LowerAll:return e.toLowerCase();case CaseRules.None:default:return e}}function keyValueList(e,t=CaseRules.None){const n={},r=t;function o(e){throw new MapUtil_Exception("Cannot infer key and value of "+String(e))}function i(e,t,r){e=changeCase(e,t),n[e]=r}for(let t of e){let e=CaseRules.None;if(null==t&&o(t),t instanceof MapUtil_Union){const n=t.cases()[t.tag];t=0===t.fields.length?n:[n].concat(t.fields),e=r}if(Array.isArray(t))switch(t.length){case 0:o(t);break;case 1:i(t[0],e,!0);break;case 2:const n=t[1];i(t[0],e,n);break;default:i(t[0],e,t.slice(1))}else"string"==typeof t?i(t,e,!0):o(t)}return n}function containsValue(e,t){for(const n of t)if(MapUtil_equals(e,n[1]))return!0;return!1}function tryGetValue(e,t,n){return!!e.has(t)&&(n.contents=e.get(t),!0)}function addToSet(e,t){return!t.has(e)&&(t.add(e),!0)}function tryAddToDict(e,t,n){return!e.has(t)&&(e.set(t,n),!0)}function addToDict(e,t,n){if(e.has(t))throw new Exception("An item with the same key has already been added. Key: "+t);e.set(t,n)}function getItemFromDict(e,t){if(e.has(t))return e.get(t);throw new Exception(`The given key '${t}' was not present in the dictionary.`)}function getItemFromDictOrCreate(e,t,n){if(e.has(t))return e.get(t);const r=n(t);return e.set(t,r),r}var MutableMap_class_type,Seq2_delay,Seq2_filter,Seq2_toArray,Seq2_map,Seq2_toList,Seq2_HashSet,Seq2_addToSet,MagicString_record_type,MagicString_bool_type,MagicString_int32_type,MagicString_list_type,MagicString_string_type;class Dictionary{constructor(e,t){const n=new FSharpRef(defaultOf());this.comparer=t,n.contents=this,this.hashMap=new Map([]),this["init@9"]=1;const r=getEnumerator(e);try{for(;r["System.Collections.IEnumerator.MoveNext"]();){const e=r["System.Collections.Generic.IEnumerator`1.get_Current"]();Dictionary__Add_5BDDA1(n.contents,e[0],e[1])}}finally{disposeSafe(r)}}get[Symbol.toStringTag](){return"Dictionary"}toJSON(){return Array.from(this)}"System.Collections.IEnumerable.GetEnumerator"(){return getEnumerator(this)}GetEnumerator(){return getEnumerator(Seq_concat(this.hashMap.values()))}[Symbol.iterator](){return toIterator(getEnumerator(this))}"System.Collections.Generic.ICollection`1.Add2B595"(e){Dictionary__Add_5BDDA1(this,e[0],e[1])}"System.Collections.Generic.ICollection`1.Clear"(){Dictionary__Clear(this)}"System.Collections.Generic.ICollection`1.Contains2B595"(e){const t=Dictionary__TryFind_2B595(this,e[0]);let n,r;return null!=t&&equals(Option_value(t)[1],e[1])?(n=0,r=Option_value(t)):n=1,0===n}"System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"(e,t){Seq_iterateIndexed((n,r)=>{setItem(e,t+n,r)},this)}"System.Collections.Generic.ICollection`1.get_Count"(){return 0|Dictionary__get_Count(this)}"System.Collections.Generic.ICollection`1.get_IsReadOnly"(){return!1}"System.Collections.Generic.ICollection`1.Remove2B595"(e){const t=Dictionary__TryFind_2B595(this,e[0]);let n,r;return null!=t&&equals(Option_value(t)[1],e[1])?(n=0,r=Option_value(t)):n=1,0===n&&Dictionary__Remove_2B595(this,e[0])}"System.Collections.Generic.IDictionary`2.Add5BDDA1"(e,t){Dictionary__Add_5BDDA1(this,e,t)}"System.Collections.Generic.IDictionary`2.ContainsKey2B595"(e){return Dictionary__ContainsKey_2B595(this,e)}"System.Collections.Generic.IDictionary`2.get_Item2B595"(e){return Dictionary__get_Item_2B595(this,e)}"System.Collections.Generic.IDictionary`2.set_Item5BDDA1"(e,t){Dictionary__set_Item_5BDDA1(this,e,t)}"System.Collections.Generic.IDictionary`2.get_Keys"(){const e=this;return Seq_toArray(delay(()=>Seq_map(e=>e[0],e)))}"System.Collections.Generic.IDictionary`2.Remove2B595"(e){return Dictionary__Remove_2B595(this,e)}"System.Collections.Generic.IDictionary`2.TryGetValue6DC89625"(e,t){const n=Dictionary__TryFind_2B595(this,e);if(null!=n){const e=Option_value(n);return t.contents=e[1],!0}return!1}"System.Collections.Generic.IDictionary`2.get_Values"(){const e=this;return Seq_toArray(delay(()=>Seq_map(e=>e[1],e)))}get size(){return 0|Dictionary__get_Count(this)}clear(){Dictionary__Clear(this)}delete(e){return Dictionary__Remove_2B595(this,e)}entries(){return Seq_map(e=>[e[0],e[1]],this)}get(e){return Dictionary__get_Item_2B595(this,e)}has(e){return Dictionary__ContainsKey_2B595(this,e)}keys(){return Seq_map(e=>e[0],this)}set(e,t){return Dictionary__set_Item_5BDDA1(this,e,t),this}values(){return Seq_map(e=>e[1],this)}forEach(e,t){const n=this;Seq_iterate(t=>{e(t[1],t[0],n)},n)}}function Dictionary_$reflection(e,t){return MutableMap_class_type("Fable.Collections.Dictionary",[e,t],Dictionary)}function Dictionary_$ctor_6623D9B3(e,t){return new Dictionary(e,t)}function Dictionary__TryFindIndex_2B595(e,t){const n=0|e.comparer.GetHashCode(t);let r,o=defaultOf();return r=[tryGetValue(e.hashMap,n,new FSharpRef(()=>o,e=>{o=e})),o],r[0]?[!0,n,r[1].findIndex(n=>e.comparer.Equals(t,n[0]))]:[!1,n,-1]}function Dictionary__TryFind_2B595(e,t){const n=Dictionary__TryFindIndex_2B595(e,t);let r;if(r=n[0]&&n[2]>-1?0:1,0===r)return item(n[2],getItemFromDict(e.hashMap,n[1]))}function Dictionary__get_Comparer(e){return e.comparer}function Dictionary__Clear(e){e.hashMap.clear()}function Dictionary__get_Count(e){let t=0,n=getEnumerator(e.hashMap.values());try{for(;n["System.Collections.IEnumerator.MoveNext"]();)t=t+n["System.Collections.Generic.IEnumerator`1.get_Current"]().length|0}finally{disposeSafe(n)}return 0|t}function Dictionary__get_Item_2B595(e,t){const n=Dictionary__TryFind_2B595(e,t);if(null!=n)return Option_value(n)[1];throw System_Collections_Generic_KeyNotFoundException_$ctor_Z721C83C5("The item was not found in collection")}function Dictionary__set_Item_5BDDA1(e,t,n){const r=Dictionary__TryFindIndex_2B595(e,t);r[0]?r[2]>-1?setItem(getItemFromDict(e.hashMap,r[1]),r[2],[t,n]):getItemFromDict(e.hashMap,r[1]).push([t,n]):e.hashMap.set(r[1],[[t,n]])}function Dictionary__Add_5BDDA1(e,t,n){const r=Dictionary__TryFindIndex_2B595(e,t);if(r[0]){if(r[2]>-1)throw ArgumentException_$ctor_Z721C83C5(format("An item with the same key has already been added. Key: {0}",t));getItemFromDict(e.hashMap,r[1]).push([t,n])}else e.hashMap.set(r[1],[[t,n]])}function Dictionary__ContainsKey_2B595(e,t){const n=Dictionary__TryFindIndex_2B595(e,t);let r;return r=n[0]&&n[2]>-1?0:1,0===r}function Dictionary__Remove_2B595(e,t){const n=Dictionary__TryFindIndex_2B595(e,t);let r;return r=n[0]&&n[2]>-1?0:1,0===r&&(getItemFromDict(e.hashMap,n[1]).splice(n[2],1),!0)}function distinct(e,t){return Seq2_delay(()=>{const n=new Seq2_HashSet([],t);return Seq2_filter(e=>Seq2_addToSet(e,n),e)})}function distinctBy(e,t,n){return Seq2_delay(()=>{const r=new Seq2_HashSet([],n);return Seq2_filter(t=>Seq2_addToSet(e(t),r),t)})}function except(e,t,n){return Seq2_delay(()=>{const r=new Seq2_HashSet(e,n);return Seq2_filter(e=>Seq2_addToSet(e,r),t)})}function countBy(e,t,n){return delay(()=>{const r=new Dictionary([],n),o=[],i=getEnumerator(t);try{for(;i["System.Collections.IEnumerator.MoveNext"]();){const t=e(i["System.Collections.Generic.IEnumerator`1.get_Current"]());let n,s=0;n=[tryGetValue(r,t,new FSharpRef(()=>0|s,e=>{s=0|e})),s],n[0]?r.set(t,n[1]+1):(r.set(t,1),o.push(t))}}finally{disposeSafe(i)}return Seq_map(e=>[e,getItemFromDict(r,e)],o)})}function groupBy(e,t,n){return delay(()=>{const r=new Dictionary([],n),o=[],i=getEnumerator(t);try{for(;i["System.Collections.IEnumerator.MoveNext"]();){const t=i["System.Collections.Generic.IEnumerator`1.get_Current"](),n=e(t);let s,a=defaultOf();s=[tryGetValue(r,n,new FSharpRef(()=>a,e=>{a=e})),a],s[0]?s[1].push(t):(addToDict(r,n,[t]),o.push(n))}}finally{disposeSafe(i)}return Seq_map(e=>[e,getItemFromDict(r,e)],o)})}function Array_distinct(e,t){return Seq2_toArray(distinct(e,t))}function Array_distinctBy(e,t,n){return Seq2_toArray(distinctBy(e,t,n))}function Array_except(e,t,n){return Seq2_toArray(except(e,t,n))}function Array_countBy(e,t,n){return Seq2_toArray(countBy(e,t,n))}function Array_groupBy(e,t,n){return Seq2_toArray(Seq2_map(e=>[e[0],Seq2_toArray(e[1])],groupBy(e,t,n)))}function List_distinct(e,t){return Seq2_toList(distinct(e,t))}function List_distinctBy(e,t,n){return Seq2_toList(distinctBy(e,t,n))}function List_except(e,t,n){return Seq2_toList(except(e,t,n))}function List_countBy(e,t,n){return toList(countBy(e,t,n))}function List_groupBy(e,t,n){return toList(Seq_map(e=>[e[0],toList(e[1])],groupBy(e,t,n)))}class MagicStringOptions extends Record{constructor(e,t,n,r){super(),this.Enabled=e,this.MinDuplicates=0|t,this.Allowlist=n,this.IncludeTestFiles=r}}function MagicStringOptions_$reflection(){return MagicString_record_type("Energy.Core.Detectors.MagicString.MagicStringOptions",[],MagicStringOptions,()=>[["Enabled",MagicString_bool_type],["MinDuplicates",MagicString_int32_type],["Allowlist",MagicString_list_type(MagicString_string_type)],["IncludeTestFiles",MagicString_bool_type]])}const MagicString_defaultOptions=new MagicStringOptions(!0,2,List_ofArray(["","utf-8","__main__"]),!1);function stripQuotes(e){return e.length>=2?substring(e,1,e.length-2):e}function isDocstring(e,t){return Seq_exists(t=>{let n;return Seq_exists((n=t.type,e=>equals(n,e)),toArray(e.NodeTypes.ExpressionStatement))},toArray(nodeParent(t)))}function isEqualityComparisonOperand(e,t){let n;return List_exists(n=>List_exists(e=>e.Left.id===t.id||e.Right.id===t.id,e.GetEqualityComparisons(n)),List_choose(e=>e,List_ofArray([nodeParent(t),(n=nodeParent(t),null!=n?nodeParent(Option_value(n)):void 0)])))}function isMembershipOperand(e,t,n){let r;return Seq_exists(t=>List_exists(e=>List_contains(n,e.Values,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),e.GetMembershipComparisons(t)),toArray((r=nodeParent(t),null!=r?nodeParent(Option_value(r)):void 0)))}function isKeyOrIndexPosition(e,t){return Seq_exists(t=>List_contains(t.type,e.SubscriptNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),toArray(nodeParent(t)))}function analyzeMagicStrings(e,t,n,r,o){if(!o.Enabled||!o.IncludeTestFiles&&isTestFile(r))return List_empty();{const r=e=>{let t,i,s,a;return List_append(Seq_exists((t=e.type,e=>equals(t,e)),toArray(n.NodeTypes.StringLiteral))?(i=stripQuotes(e.text),s=!(!isEqualityComparisonOperand(n,e)&&!isMembershipOperand(n,e,i))||isKeyOrIndexPosition(n,e),a=!!(isDocstring(n,e)||n.IsFormattedOrInterpolatedString(e)||List_contains(i,o.Allowlist,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}))||i.length<=1,s&&!a?List_singleton([e,i]):List_empty()):List_empty(),List_collect(r,nodeChildren(e)))};return List_choose(e=>{let n;const r=e[1];if(!(List_length(r)<o.MinDuplicates)){const o=List_head(r),i=t.toPosition(o[0].startIndex);return new EnergyViolation(i.Line,i.Column,ViolationType.Magic,Severity.Low,(n=0|List_length(r),toText(printf('Magic string: "%s" is compared/keyed against directly %d time(s). Consider extracting to a named constant or enum.'))(e[0])(n)),List_empty())}},List_groupBy(e=>e[1],r(e),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}))}}const MagicString_detector=new Detector("magicString",e=>analyzeMagicStrings(e.Tree,e.Positions,e.Language,e.FileName,MagicString_defaultOptions));var Nesting_record_type,Nesting_int32_type;class NestingThresholds extends Record{constructor(e,t){super(),this.MediumThreshold=0|e,this.HighThreshold=0|t}}function NestingThresholds_$reflection(){return Nesting_record_type("Energy.Core.Detectors.Nesting.NestingThresholds",[],NestingThresholds,()=>[["MediumThreshold",Nesting_int32_type],["HighThreshold",Nesting_int32_type]])}const defaultNestingThresholds=new NestingThresholds(3,5);function analyzeNesting(e,t){const n=(r,o)=>{const i=List_contains(r.type,e.Language.NestingControlTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),s=0|(i?o+1:o),a=List_collect(e=>n(e,s),nodeChildren(r));if(i&&o>t.MediumThreshold){const n=e.Positions.toPosition(r.startIndex);return cons(new EnergyViolation(n.Line,n.Column,ViolationType.Nesting,o>t.HighThreshold?Severity.High:Severity.Medium,toText(printf("Excessive nesting depth: %d. Consider extracting."))(o),List_empty()),a)}return a};return n(e.Tree,0)}const Nesting_detector=new Detector("nesting",e=>analyzeNesting(e,defaultNestingThresholds));var Cyclomatic_record_type,Cyclomatic_int32_type,Cyclomatic_union_type,Cyclomatic_list_type;class CyclomaticThresholds extends Record{constructor(e,t){super(),this.MediumThreshold=0|e,this.HighThreshold=0|t}}function CyclomaticThresholds_$reflection(){return Cyclomatic_record_type("Energy.Core.Detectors.Cyclomatic.CyclomaticThresholds",[],CyclomaticThresholds,()=>[["MediumThreshold",Cyclomatic_int32_type],["HighThreshold",Cyclomatic_int32_type]])}const defaultCyclomaticThresholds=new CyclomaticThresholds(10,15);class FlowNode extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Entry","Exit","Decision"]}static Entry=new FlowNode(0,[]);static Exit=new FlowNode(1,[])}function FlowNode_$reflection(){return Cyclomatic_union_type("Energy.Core.Detectors.Cyclomatic.FlowNode",[],FlowNode,()=>[[],[],[["Item",Cyclomatic_int32_type]]])}class FunctionScope extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["RootFunction","NestedFunction"]}static RootFunction=new FunctionScope(0,[]);static NestedFunction=new FunctionScope(1,[])}function FunctionScope_$reflection(){return Cyclomatic_union_type("Energy.Core.Detectors.Cyclomatic.FunctionScope",[],FunctionScope,()=>[[],[]])}class FlowEdge extends Record{constructor(e,t){super(),this.From=e,this.To=t}}function FlowEdge_$reflection(){return Cyclomatic_record_type("Energy.Core.Detectors.Cyclomatic.FlowEdge",[],FlowEdge,()=>[["From",FlowNode_$reflection()],["To",FlowNode_$reflection()]])}class ControlFlowGraph extends Record{constructor(e,t,n){super(),this.Nodes=e,this.Edges=t,this.ExitPredecessors=n}}function ControlFlowGraph_$reflection(){return Cyclomatic_record_type("Energy.Core.Detectors.Cyclomatic.ControlFlowGraph",[],ControlFlowGraph,()=>[["Nodes",Cyclomatic_list_type(FlowNode_$reflection())],["Edges",Cyclomatic_list_type(FlowEdge_$reflection())],["ExitPredecessors",Cyclomatic_list_type(FlowNode_$reflection())]])}const initialGraph=new ControlFlowGraph(List_ofArray([FlowNode.Entry,FlowNode.Exit]),List_singleton(new FlowEdge(FlowNode.Entry,FlowNode.Exit)),List_singleton(FlowNode.Entry)),connectedComponents=1,mccabeComponentMultiplier=2;function addDecision(e,t){const n=new FlowNode(2,[List_length(t.Nodes)]),r=List_map(e=>new FlowEdge(e,n),t.ExitPredecessors),o=List_replicate(e,new FlowEdge(n,FlowNode.Exit));return new ControlFlowGraph(cons(n,t.Nodes),List_append(List_filter(e=>!equals(e.To,FlowNode.Exit),t.Edges),List_append(r,o)),List_replicate(e,n))}function isDecisionPoint(e,t){return!(!List_contains(t.type,e.DecisionNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&null==e.GetBooleanOperator(t))||e.IsTryElseClause(t)}function decisionOutcomes(e,t){return null!=e.GetBooleanOperator(t)?2:0|defaultArg(e.CyclomaticBranchCount(t),2)}function buildControlFlowGraph(e,t,n,r){const o=isDecisionPoint(e,t)?addDecision(decisionOutcomes(e,t),r):r;return equals(n,FunctionScope.NestedFunction)&&e.IsFunctionDefinition(t)?o:List_fold((t,n)=>buildControlFlowGraph(e,n,FunctionScope.NestedFunction,t),o,nodeChildren(t))}function complexityOf(e,t){const n=buildControlFlowGraph(e,t,FunctionScope.RootFunction,initialGraph);return List_length(n.Edges)-List_length(n.Nodes)+mccabeComponentMultiplier*connectedComponents|0}function findCyclomaticHotspots(e,t,n,r,o){const i=isDecisionPoint(e,n),s=i?List_singleton(new Hotspot(t.toPosition(n.startIndex).Line,(decisionOutcomes(e,n)-1)*(1+r))):List_empty();if(equals(o,FunctionScope.NestedFunction)&&e.IsFunctionDefinition(n))return s;{const o=0|(i?r+1:r);return List_append(s,List_collect(n=>findCyclomaticHotspots(e,t,n,o,FunctionScope.NestedFunction),nodeChildren(n)))}}function analyzeFunctionComplexity(e,t,n,r){const o=e=>{let i,s;return List_append(n.IsFunctionDefinition(e)?(i=0|complexityOf(n,e),i>r.MediumThreshold?(s=t.toPosition(e.startIndex),List_singleton(new EnergyViolation(s.Line,s.Column,ViolationType.Complexity,i>r.HighThreshold?Severity.High:Severity.Medium,toText(printf("High cyclomatic complexity: %d. Consider breaking down this function."))(i),findCyclomaticHotspots(n,t,e,0,FunctionScope.RootFunction)))):List_empty()):List_empty(),List_collect(o,nodeChildren(e)))};return o(e)}const Cyclomatic_detector=new Detector("cyclomatic",e=>analyzeFunctionComplexity(e.Tree,e.Positions,e.Language,defaultCyclomaticThresholds));var Cognitive_record_type,Cognitive_int32_type,Cognitive_union_type;class CognitiveThresholds extends Record{constructor(e,t){super(),this.MediumThreshold=0|e,this.HighThreshold=0|t}}function CognitiveThresholds_$reflection(){return Cognitive_record_type("Energy.Core.Detectors.Cognitive.CognitiveThresholds",[],CognitiveThresholds,()=>[["MediumThreshold",Cognitive_int32_type],["HighThreshold",Cognitive_int32_type]])}const defaultCognitiveThresholds=new CognitiveThresholds(15,25);function hasNodeType(e,t){if(null==e)return!1;{const n=e;return equals(t.type,n)}}class CognitiveNodeKind extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["BooleanOperator","NestedDecision","ElseClause","ConditionalExpression","FunctionDefinition","Lambda","Other"]}static NestedDecision=new CognitiveNodeKind(1,[]);static ElseClause=new CognitiveNodeKind(2,[]);static ConditionalExpression=new CognitiveNodeKind(3,[]);static FunctionDefinition=new CognitiveNodeKind(4,[]);static Lambda=new CognitiveNodeKind(5,[]);static Other=new CognitiveNodeKind(6,[])}function CognitiveNodeKind_$reflection(){return Cognitive_union_type("Energy.Core.Detectors.Cognitive.CognitiveNodeKind",[],CognitiveNodeKind,()=>[[["Item",Cognitive_int32_type]],[],[],[],[],[],[]])}function classifyNode(e,t){let n,r,o,i;const s=e.GetBooleanOperator(t);return null==s?List_contains(t.type,e.CognitiveNestedDecisionTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})?CognitiveNodeKind.NestedDecision:hasNodeType(e.NodeTypes.ElseClause,t)?CognitiveNodeKind.ElseClause:hasNodeType(e.NodeTypes.ConditionalExpression,t)?CognitiveNodeKind.ConditionalExpression:e.IsFunctionDefinition(t)?CognitiveNodeKind.FunctionDefinition:hasNodeType(e.NodeTypes.Lambda,t)?CognitiveNodeKind.Lambda:CognitiveNodeKind.Other:new CognitiveNodeKind(0,[(n=s,defaultArg((i=nodeParent(t),o=null!=i?e.GetBooleanOperator(Option_value(i)):void 0,r=null!=o?equals(n,o)?void 0:o:void 0,null!=r?1:void 0),null==nodeParent(t)?1:0))])}function cognitiveWalk(e,t,n,r){const o=o=>0|List_sumBy(t=>0|o(e)(t)(n)(e=>{const t=curry2(r)(e);return e=>{t(e)}}),nodeChildren(t),{GetZero:()=>0,Add:(e,t)=>e+t|0}),i=(e,n)=>(r(t,e),e+o(n)|0),s=classifyNode(e,t);switch(s.tag){case 1:return 0|i(1+n,e=>t=>n=>r=>0|cognitiveWalkChild(e,t,n,uncurry2(r)));case 2:return 0|i(1,e=>t=>n=>r=>0|cognitiveWalkChild(e,t,n,uncurry2(r)));case 3:return r(t,1+n),1+n+List_sumBy(t=>0|cognitiveWalk(e,t,n+1,r),nodeChildren(t),{GetZero:()=>0,Add:(e,t)=>e+t|0})|0;case 4:{const e=1+n|0;return r(t,e),0|e}case 5:return 0|i(1+n,e=>t=>n=>r=>0|cognitiveWalkChild(e,t,n,uncurry2(r)));case 6:return 0|o(e=>t=>n=>r=>0|cognitiveWalk(e,t,n,uncurry2(r)));default:return 0|i(s.fields[0],e=>t=>n=>r=>0|cognitiveWalk(e,t,n,uncurry2(r)))}}function cognitiveWalkChild(e,t,n,r){return 0|cognitiveWalk(e,t,e.EntersNestedScope(t)?n+1:n,r)}function cognitiveScoreOf(e,t){return 0|List_sumBy(t=>0|cognitiveWalk(e,t,0,(e,t)=>{}),nodeChildren(t),{GetZero:()=>0,Add:(e,t)=>e+t|0})}function findCognitiveHotspots(e,t,n){const r=[];return List_iterate(t=>{cognitiveWalk(e,t,0,(e,t)=>{const o=n.toPosition(e.startIndex);r.push(new Hotspot(o.Line,t))})},nodeChildren(t)),List_ofSeq(r)}function analyzeCognitiveComplexity(e,t,n,r){const o=e=>{let i,s;return List_append(n.IsFunctionDefinition(e)?(i=0|cognitiveScoreOf(n,e),i>r.MediumThreshold?(s=t.toPosition(e.startIndex),List_singleton(new EnergyViolation(s.Line,s.Column,ViolationType.Cognitive,i>r.HighThreshold?Severity.High:Severity.Medium,toText(printf("High cognitive complexity: %d. This function is hard to read; consider flattening nesting or extracting functions."))(i),findCognitiveHotspots(n,e,t)))):List_empty()):List_empty(),List_collect(o,nodeChildren(e)))};return o(e)}const Cognitive_detector=new Detector("cognitive",e=>analyzeCognitiveComplexity(e.Tree,e.Positions,e.Language,defaultCognitiveThresholds));function findParametersNode(e,t){const n=List_tryFind(e=>equals(e.type,t),nodeChildren(e));return null==n?List_tryHead(List_collect(e=>List_ofArray(toArray(findParametersNode(e,t))),nodeChildren(e))):some(Option_value(n))}function analyzeParameterCount(e,t,n){const r=e=>{let o,i,s;return List_append(n.IsFunctionDefinition(e)?(o=findParametersNode(e,n.NodeTypes.Parameters),null==o?List_empty():(i=0|List_length(List_filter(e=>List_contains(e.type,n.ParameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(o)))),i>5?(s=t.toPosition(e.startIndex),List_singleton(new EnergyViolation(s.Line,s.Column,ViolationType.Parameters,i>8?Severity.High:Severity.Medium,toText(printf("Parameter explosion: %d parameters. Consider using objects or builder pattern."))(i),List_empty()))):List_empty())):List_empty(),List_collect(r,nodeChildren(e)))};return r(e)}const ParameterCount_detector=new Detector("parameterCount",e=>analyzeParameterCount(e.Tree,e.Positions,e.Language));var TypeCohesion_record_type,TypeCohesion_bool_type,TypeCohesion_int32_type,TypeCohesion_union_type,TypeCohesion_float64_type;const nonDomainBaseTypes=Set_ofList(List_ofArray(["Callable","Function","Any","None","Unit","void"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),singleUpperPattern=/^[A-Z]$/gu,genericTypeParameterPattern=/^_?T([A-Z]\w*|\d*)$/gu;function isTypeParameterName(e){return!!isMatch(singleUpperPattern,e)||isMatch(genericTypeParameterPattern,e)}function baseTypeName(e,t){const n=e.trim();if(!isNullOrEmpty(n)){const e=0|n.indexOf(t.Open),r=-1===e?n.trim():substring(n,0,e).trim();return isMatch(/^[A-Za-z_][A-Za-z0-9_.]*$/gu,r)?FSharpSet__Contains(nonDomainBaseTypes,r)||isTypeParameterName(r)?void 0:r:void 0}}function collectTypeSignals(e,t){const n=new Set([]),r=findParametersNode(e,t.NodeTypes.Parameters);if(null==r);else{const e=getEnumerator(nodeChildren(Option_value(r)));try{for(;e["System.Collections.IEnumerator.MoveNext"]();){const r=t.ExtractTypedParameter(e["System.Collections.Generic.IEnumerator`1.get_Current"]());if(null==r);else{const e=baseTypeName(r.Type,t.GenericBrackets);null==e||addToSet(e,n)}}}finally{disposeSafe(e)}}const o=t.ExtractReturnType(e);if(null==o);else{const e=baseTypeName(o,t.GenericBrackets);null==e||addToSet(e,n)}return n}class MeasuredTypeCohesion extends Record{constructor(e,t){super(),this.Result=e,this.DistinctTypes=0|t}}function MeasuredTypeCohesion_$reflection(){return TypeCohesion_record_type("Energy.Core.TypeCohesion.MeasuredTypeCohesion",[],MeasuredTypeCohesion,()=>[["Result",TypeCohesion_bool_type],["DistinctTypes",TypeCohesion_int32_type]])}class TypeCohesionResult extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["InsufficientData","Measured"]}static InsufficientData=new TypeCohesionResult(0,[])}function TypeCohesionResult_$reflection(){return TypeCohesion_union_type("Energy.Core.TypeCohesion.TypeCohesionResult",[],TypeCohesionResult,()=>[[],[["Item",MeasuredTypeCohesion_$reflection()]]])}class TypeCohesionThresholds extends Record{constructor(e,t){super(),this.MaxDiversityRatio=e,this.MinCoverage=t}}function TypeCohesionThresholds_$reflection(){return TypeCohesion_record_type("Energy.Core.TypeCohesion.TypeCohesionThresholds",[],TypeCohesionThresholds,()=>[["MaxDiversityRatio",TypeCohesion_float64_type],["MinCoverage",TypeCohesion_float64_type]])}function typeCohesionResult(e,t,n){const r=List_filter(e=>e.size>0,List_map(e=>collectTypeSignals(e,t),e));if((0===List_length(e)?0:List_length(r)/List_length(e))<n.MinCoverage)return TypeCohesionResult.InsufficientData;{const e=new Set([]),t=getEnumerator(r);try{for(;t["System.Collections.IEnumerator.MoveNext"]();){let n=getEnumerator(t["System.Collections.Generic.IEnumerator`1.get_Current"]());try{for(;n["System.Collections.IEnumerator.MoveNext"]();)addToSet(n["System.Collections.Generic.IEnumerator`1.get_Current"](),e)}finally{disposeSafe(n)}}}finally{disposeSafe(t)}return new TypeCohesionResult(1,[new MeasuredTypeCohesion(e.size/List_length(r)<=n.MaxDiversityRatio,e.size)])}}const wordBoundaryPattern=/[A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+/gu;function NamingCohesion_splitIntoWords(e){const t=RegExp_matches(wordBoundaryPattern,e);return 0===t.length?List_empty():toList(delay(()=>Seq_map(e=>e[0].toLowerCase(),t)))}const utilsFileWords=Set_ofList(List_ofArray(["util","utils","helper","helpers","common"]),{Compare:(e,t)=>0|comparePrimitives(e,t)});function isUtilsFileName(e){let t;const n=defaultArg(tryLast(String_split(e,["/"],void 0,0)),"");return List_exists(e=>FSharpSet__Contains(utilsFileWords,e),NamingCohesion_splitIntoWords((t=0|n.lastIndexOf("."),-1===t?n:substring(n,0,t))))}function functionNameWords(e){let t;const n=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(e));let r,o;return null!=n?(t=Option_value(n),isNullOrEmpty(t.text)?r=1:(r=0,o=Option_value(n))):r=1,0===r?NamingCohesion_splitIntoWords(o.text):List_empty()}function dominantShare(e){if(0===List_length(e))return 0;{const t=new Map([]),n=getEnumerator(e);try{for(;n["System.Collections.IEnumerator.MoveNext"]();){const e=n["System.Collections.Generic.IEnumerator`1.get_Current"](),r=0|(t.has(e)?getItemFromDict(t,e):0);t.set(e,r+1)}}finally{disposeSafe(n)}return Seq_max(t.values(),{Compare:(e,t)=>0|comparePrimitives(e,t)})/List_length(e)}}function looksLikeSingleDomainByNames(e,t){const n=[],r=[],o=getEnumerator(e);try{for(;o["System.Collections.IEnumerator.MoveNext"]();){const e=NamingCohesion_splitIntoWords(o["System.Collections.Generic.IEnumerator`1.get_Current"]());List_length(e)>0&&(n.push(List_item(0,e)),r.push(List_item(List_length(e)-1,e)))}}finally{disposeSafe(o)}return 0!==n.length&&(dominantShare(List_ofSeq(n))>=t||dominantShare(List_ofSeq(r))>=t)}function looksLikeSingleDomain(e,t){return looksLikeSingleDomainByNames(List_map(e=>join(" ",functionNameWords(e)),e),t)}var ClassRelatedness_record_type,ClassRelatedness_option_type,ClassRelatedness_string_type,ClassRelatedness_obj_type,ClassRelatedness_list_type,array_type,ClassRelatedness_lambda_type,ClassRelatedness_int32_type,unit_type,Coherence_record_type,Coherence_int32_type,Coherence_float64_type,Coherence_list_type,Coherence_obj_type,Coherence_class_type,Coherence_string_type,Coherence_option_type,Coherence_ClassInfo_$reflection;class ClassInfo extends Record{constructor(e,t,n,r){super(),this.Name=e,this.Node=t,this.BaseNames=n,this.Methods=r}}function ClassInfo_$reflection(){return ClassRelatedness_record_type("Energy.Core.Detectors.ClassRelatedness.ClassInfo",[],ClassInfo,()=>[["Name",ClassRelatedness_option_type(ClassRelatedness_string_type)],["Node",ClassRelatedness_obj_type],["BaseNames",ClassRelatedness_list_type(ClassRelatedness_string_type)],["Methods",array_type(ClassRelatedness_obj_type)]])}class UnionFind extends Record{constructor(e,t){super(),this.Find=e,this.Union=t}}function UnionFind_$reflection(){return ClassRelatedness_record_type("Energy.Core.Detectors.ClassRelatedness.UnionFind",[],UnionFind,()=>[["Find",ClassRelatedness_lambda_type(ClassRelatedness_int32_type,ClassRelatedness_int32_type)],["Union",ClassRelatedness_lambda_type(ClassRelatedness_int32_type,ClassRelatedness_lambda_type(ClassRelatedness_int32_type,unit_type))]])}function unionFind(e){const t=Array_initialize(e,e=>0|e,Int32Array),n=e=>{for(;;){const n=e;if(item(n,t)===n)return 0|n;setItem(t,n,0|item(item(n,t),t)),e=item(n,t)}};return new UnionFind(n,(e,r)=>{const o=0|n(e),i=0|n(r);o!==i&&setItem(t,o,0|i)})}function linkDirectInheritance(e,t,n){List_iterateIndexed((e,r)=>{const o=getEnumerator(r.BaseNames);try{for(;o["System.Collections.IEnumerator.MoveNext"]();){const r=o["System.Collections.Generic.IEnumerator`1.get_Current"](),i=List_tryFindIndex(e=>Seq_exists(e=>e===r,toArray(e)),t);null==i||n.Union(e,i)}}finally{disposeSafe(o)}},e)}function linkSharedBase(e,t){const n=new Map([]);List_iterateIndexed((e,t)=>{const r=getEnumerator(t.BaseNames);try{for(;r["System.Collections.IEnumerator.MoveNext"]();){const t=r["System.Collections.Generic.IEnumerator`1.get_Current"]();let o;if(n.has(t))o=getItemFromDict(n,t);else{const e=[];n.set(t,e),o=e}o.push(e)}}finally{disposeSafe(r)}},e);let r=getEnumerator(n.values());try{for(;r["System.Collections.IEnumerator.MoveNext"]();){const e=r["System.Collections.Generic.IEnumerator`1.get_Current"]();for(let n=1;n<=e.length-1;n++)t.Union(item(0,e),item(n,e))}}finally{disposeSafe(r)}}function linkTypeCrossReference(e,t,n,r){List_iterate(e=>{r.Union(e[0],e[1])},List_collect(e=>{const r=0|e[0];return List_collect(e=>List_choose(e=>{let n;const o=List_tryFindIndex(t=>Seq_exists(t=>e===t,toArray(t)),t);return n=null!=o&&r!==o?o:void 0,null!=n?[r,n]:void 0},toList(collectTypeSignals(e,n))),toList(e[1].Methods))},List_indexed(e)))}function groupClassesIntoFamilies(e,t){const n=List_map(e=>e.Name,e),r=unionFind(List_length(e));return linkDirectInheritance(e,n,r),linkSharedBase(e,r),linkTypeCrossReference(e,n,t,r),List_map(e=>List_map(e=>0|e[0],e[1]),List_groupBy(e=>0|r.Find(e[0]),List_indexed(e),{Equals:(e,t)=>e===t,GetHashCode:e=>0|numberHash(e)}))}function namesHaveSharedDomain(e,t){const n=List_map(e=>e.Name,e),r=List_choose(e=>e,n);return List_length(r)===List_length(n)&&looksLikeSingleDomainByNames(r,t)}function groupDescription(e,t){let n,r,o;return join(" vs ",(n=List_sortByDescending(e=>0|List_length(e),List_map(e=>List_map(e=>defaultArg(List_item(e,t),"(anonymous)"),e),e),{Compare:(e,t)=>0|comparePrimitives(e,t)}),List_map((o=toText(printf("{%s}")),r=o,e=>r(join(", ",e))),n)))}function checkClassRelatedness(e,t,n,r){let o,i,s;if(!(List_length(e)<2)){const a=groupClassesIntoFamilies(e,n),_=List_map(e=>e.Name,e);let u;switch(u=List_isEmpty(a)?namesHaveSharedDomain(e,t)?1:2:List_isEmpty(List_tail(a))?0:namesHaveSharedDomain(e,t)?1:2,u){case 0:case 1:return;default:{const t=r.toPosition(List_item(0,e).Node.startIndex);return new EnergyViolation(t.Line,t.Column,ViolationType.Coherence,List_length(a)>2?Severity.High:Severity.Medium,(o=0|List_length(e),i=0|List_length(a),s=groupDescription(a,_),toText(printf("File coherence warning: %d classes in one file split into %d unrelated groups: %s. These share no inheritance, type relationship, or naming pattern — each group likely belongs in its own file."))(o)(i)(s)),List_empty())}}}}class CoherenceThresholds extends Record{constructor(e,t,n,r,o){super(),this.LargeFunctionLines=0|e,this.MaxLargeFunctions=0|t,this.SingleDomainNameShare=n,this.MaxTypeDiversityRatio=r,this.MinTypedCoverage=o}}function CoherenceThresholds_$reflection(){return Coherence_record_type("Energy.Core.Detectors.Coherence.CoherenceThresholds",[],CoherenceThresholds,()=>[["LargeFunctionLines",Coherence_int32_type],["MaxLargeFunctions",Coherence_int32_type],["SingleDomainNameShare",Coherence_float64_type],["MaxTypeDiversityRatio",Coherence_float64_type],["MinTypedCoverage",Coherence_float64_type]])}const defaultCoherenceThresholds=new CoherenceThresholds(20,5,.7,.4,.5),utilsFileFunctionThreshold=8,genericFunctionCountThreshold=12,highFunctionCountThreshold=15,largeFunctionSeverityMultiplier=1.5,importCountThreshold=10,highImportCountThreshold=15;class Collected extends Record{constructor(e,t,n,r){super(),this.FreeFunctions=e,this.Classes=t,this.ImportSources=n,this.FirstImportNode=r}}function Collected_$reflection(){return Coherence_record_type("Energy.Core.Detectors.Coherence.Collected",[],Collected,()=>[["FreeFunctions",Coherence_list_type(Coherence_obj_type)],["Classes",Coherence_list_type(Coherence_ClassInfo_$reflection())],["ImportSources",Coherence_class_type("Microsoft.FSharp.Collections.FSharpSet`1",[Coherence_string_type])],["FirstImportNode",Coherence_option_type(Coherence_obj_type)]])}function collectFunctionsClassesAndImports(e,t){const n=new Collected(List_empty(),List_empty(),Set_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}),void 0),r=(e,t)=>new Collected(List_append(e.FreeFunctions,t.FreeFunctions),List_append(e.Classes,t.Classes),union(e.ImportSources,t.ImportSources),orElse(t.FirstImportNode,e.FirstImportNode)),o=e=>i=>{let s,a,_;return List_fold(r,List_contains(e.type,t.ClassDefinitionNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})?(e=>{const n=new ClassInfo(t.GetClassName(e),e,t.GetBaseClassNames(e),[]),i=List_map(e=>o(e)(n),nodeChildren(e));return List_fold(r,new Collected(List_empty(),List_singleton(n),Set_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}),void 0),i)})(e):t.IsFunctionDefinition(e)?null==i?new Collected(List_singleton(e),n.Classes,n.ImportSources,n.FirstImportNode):(s=i,s.Methods.push(e),n):(a=e.type,Seq_exists(e=>equals(a,e),toArray(t.NodeTypes.ImportStatement))||Seq_exists(e=>equals(a,e),toArray(t.NodeTypes.ImportFromStatement))?(_=t.ImportSource(e),new Collected(n.FreeFunctions,n.Classes,Set_singleton(isNullOrEmpty(_)?e.text:_,{Compare:(e,t)=>0|comparePrimitives(e,t)}),some(e))):n),List_map(e=>o(e)(i),nodeChildren(e)))};return o(e)(void 0)}function isCohesiveByNamingOrType(e,t,n){return 0===n.tag?looksLikeSingleDomain(e,t.SingleDomainNameShare):n.fields[0].Result}function functionCountViolation(e,t,n){return new EnergyViolation(n.Line,n.Column,ViolationType.Coherence,e>highFunctionCountThreshold?Severity.High:Severity.Medium,t,List_empty())}function checkFunctionCountSprawl(e,t,n,r,o){let i,s;if(!(List_length(e)<=utilsFileFunctionThreshold)){const a=isUtilsFileName(t),_=typeCohesionResult(e,r,new TypeCohesionThresholds(n.MaxTypeDiversityRatio,n.MinTypedCoverage)),u=!a&&isCohesiveByNamingOrType(e,n,_);if(!a&&(List_length(e)<=genericFunctionCountThreshold||u))return;{const t=o.toPosition(List_item(0,e).startIndex);let n,r;return 1===_.tag?_.fields[0].Result?n=1:(n=0,r=_.fields[0]):n=1,functionCountViolation(List_length(e),0===n?(i=0|List_length(e),toText(printf("File coherence warning: %d functions in one file spanning %d unrelated types. This is a stronger sprawl signal than function count alone — the functions don't share a common domain type, so moving them into existing cohesive modules (grouped by the type they operate on) is likely to help more than an arbitrary split."))(i)(r.DistinctTypes)):(s=0|List_length(e),toText(printf("File coherence warning: %d functions in one file. If they belong to distinct domains, prefer moving them into existing cohesive modules; splitting into a new file only helps if it doesn't just relocate the same imports/coupling."))(s)),t)}}}function lineCount(e){return e.endPosition.row-e.startPosition.row+1|0}function checkLargeFunctionSprawl(e,t,n){let r;const o=List_filter(e=>lineCount(e)>t.LargeFunctionLines,e);if(!(List_length(o)<=t.MaxLargeFunctions)){const e=n.toPosition(List_item(0,o).startIndex);return new EnergyViolation(e.Line,e.Column,ViolationType.Coherence,List_length(o)>t.MaxLargeFunctions*largeFunctionSeverityMultiplier?Severity.High:Severity.Medium,(r=0|List_length(o),toText(printf("%d functions exceed %d lines. Large functions carry more complexity than function count alone suggests."))(r)(t.LargeFunctionLines)),List_empty())}}function checkImportSprawl(e,t,n){let r;if(!(FSharpSet__get_Count(e)<=importCountThreshold)){let o;if(null==t)o=new Position(0,0);else{const e=Option_value(t);o=n.toPosition(e.startIndex)}return new EnergyViolation(o.Line,o.Column,ViolationType.Coherence,FSharpSet__get_Count(e)>highImportCountThreshold?Severity.High:Severity.Medium,(r=0|FSharpSet__get_Count(e),toText(printf("Import sprawl: %d distinct modules imported suggest this file does too much. Splitting only helps if the resulting files don't each still need most of these imports."))(r)),List_empty())}}function analyzeFileCoherence(e,t,n,r,o){const i=collectFunctionsClassesAndImports(e,n),s=i.FreeFunctions,a=i.Classes,_=List_append(s,List_collect(e=>List_ofSeq(e.Methods),a));return List_choose(e=>e,List_ofArray([checkFunctionCountSprawl(s,t,o,n,r),checkLargeFunctionSprawl(_,o,r),checkImportSprawl(i.ImportSources,i.FirstImportNode,r),checkClassRelatedness(a,o.SingleDomainNameShare,n,r)]))}const Coherence_detector=new Detector("coherence",e=>analyzeFileCoherence(e.Tree,e.FileName,e.Language,e.Positions,defaultCoherenceThresholds));function hasType(e,t){let n;return Seq_exists((n=t.type,e=>equals(n,e)),toArray(e))}function MatchOpportunitySupport_stripQuotes(e){return e.length>=2?substring(e,1,e.length-2):e}function collectChainBranches(e,t){const n=e.GetElseIfBranches(t);if(List_length(n)>0)return cons(t,n);{const n=(t,r)=>{let o,i,s;return defaultArg((o=null==e.NodeTypes.ElseClause?List_tryFind(t=>hasType(e.NodeTypes.IfStatement,t),nodeChildren(t)):(i=List_tryFind(t=>hasType(e.NodeTypes.ElseClause,t),nodeChildren(t)),null!=i?List_tryFind(t=>hasType(e.NodeTypes.IfStatement,t),nodeChildren(Option_value(i))):void 0),null!=o?(s=Option_value(o),n(s,cons(s,r))):void 0),List_reverse(r))};return n(t,List_singleton(t))}}function collectDiscriminants(e,t,n){const r=t=>List_contains(t.type,e.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),o=t=>!(!hasType(e.NodeTypes.StringLiteral,t)&&!hasType(e.NodeTypes.IntegerLiteral,t))||hasType(e.NodeTypes.FloatLiteral,t),i=t=>hasType(e.NodeTypes.StringLiteral,t)?MatchOpportunitySupport_stripQuotes(t.text):t.text,s=n=>FSharpSet__Contains(t,n.id)||hasType(e.NodeTypes.Block,n)||hasType(e.NodeTypes.ElseClause,n)?List_empty():List_append(List_collect(e=>{const t=r(e.Left),n=o(e.Right),s=r(e.Right),a=o(e.Left);let _;switch(_=t&&n?0:s&&a?1:2,_){case 0:return List_singleton([e.Left.text,i(e.Right)]);case 1:return List_singleton([e.Right.text,i(e.Left)]);default:return List_empty()}},e.GetEqualityComparisons(n)),List_append(List_collect(e=>List_filter(t=>r(e.Left),List_map(t=>[e.Left.text,t],e.Values)),e.GetMembershipComparisons(n)),List_collect(s,nodeChildren(n))));return s(n)}function otherBranchIds(e,t){return Set_ofList(List_map(e=>0|e.id,List_filter(t=>t.id!==e.id,t)),{Compare:(e,t)=>0|comparePrimitives(e,t)})}function commonDiscriminant(e){return List_isEmpty(e)?void 0:List_tryFind(t=>List_forAll(e=>List_exists(e=>e[0]===t,e),List_tail(e)),List_map(e=>e[0],List_head(e)))}var MatchOpportunity_record_type,MatchOpportunity_int32_type;class MatchOpportunityThresholds extends Record{constructor(e){super(),this.MinBranches=0|e}}function MatchOpportunityThresholds_$reflection(){return MatchOpportunity_record_type("Energy.Core.Detectors.MatchOpportunity.MatchOpportunityThresholds",[],MatchOpportunityThresholds,()=>[["MinBranches",MatchOpportunity_int32_type]])}const defaultThresholds=new MatchOpportunityThresholds(3);function matchOpportunityViolation(e,t,n,r){let o;const i=e.toPosition(t.startIndex);return new EnergyViolation(i.Line,i.Column,ViolationType.MatchOpportunity,Severity.Low,(o=0|List_length(n),toText(printf("This %d-way if/elif chain all branch on '%s'. Consider a match/switch statement for clearer, exhaustiveness-checked dispatch."))(o)(r)),List_empty())}function analyzeMatchOpportunities(e,t,n,r){const o=(e,i)=>{let s,a,_,u;if(hasType(n.NodeTypes.IfStatement,i)&&!FSharpSet__Contains(e,i.id)){const o=collectChainBranches(n,i),_=List_fold((e,t)=>FSharpSet__Add(e,t.id),e,List_tail(o)),l=List_map(e=>collectDiscriminants(n,otherBranchIds(e,o),e),o);u=[List_ofArray(toArray((s=List_forAll(e=>!List_isEmpty(e),l),s&&List_length(o)>=r.MinBranches?(a=commonDiscriminant(l),null!=a?matchOpportunityViolation(t,i,o,a):void 0):void 0))),_]}else u=[List_empty(),e];return List_append(u[0],(_=nodeChildren(i),List_collect(curry2(o)(u[1]),_)))};return o(Set_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}),e)}const MatchOpportunity_detector=new Detector("matchOpportunity",e=>analyzeMatchOpportunities(e.Tree,e.Positions,e.Language,defaultThresholds));function Inversion_hasType(e,t){let n;return Seq_exists((n=t.type,e=>equals(n,e)),toArray(e))}function findBody(e,t){const n=List_tryFind(t=>Inversion_hasType(e.NodeTypes.Block,t),nodeChildren(t));return null==n?List_tryFind(t=>Inversion_hasType(e.NodeTypes.Block,t),List_collect(nodeChildren,nodeChildren(t))):some(Option_value(n))}function functionStatements(e,t){return List_filter(t=>!(!t.isNamed||Inversion_hasType(e.NodeTypes.Comment,t)||isNullOrWhiteSpace(t.text)),nodeChildren(t))}function hasElse(e,t){return null==e.NodeTypes.ElseClause?List_length(List_filter(t=>Inversion_hasType(e.NodeTypes.Block,t),nodeChildren(t)))>1||List_exists(t=>Inversion_hasType(e.NodeTypes.IfStatement,t),nodeChildren(t)):List_exists(t=>Inversion_hasType(e.NodeTypes.ElseClause,t),nodeChildren(t))}function nestedValidation(e,t){return List_reverse(((t,n,r)=>{e:for(;;){const o=n,i=r;let s;if(o>=4)return i;{const a=List_filter(t=>List_contains(t.type,e.NestingControlTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(t));let _,u;if(List_isEmpty(a)?_=1:List_isEmpty(List_tail(a))?(s=List_head(a),Inversion_hasType(e.NodeTypes.IfStatement,s)&&!hasElse(e,s)?(_=0,u=List_head(a)):_=1):_=1,0===_){const s=List_tryFind(t=>Inversion_hasType(e.NodeTypes.Block,t),nodeChildren(u));if(null==s)return cons(u,i);t=Option_value(s),n=o+1,r=cons(u,i);continue e}return i}}})(t,0,List_empty()))}function deepestIf(e,t){const n=(t,r)=>{if(e.IsFunctionDefinition(t))return[0,void 0];{const o=Inversion_hasType(e.NodeTypes.IfStatement,t)?[r,some(t)]:[0,void 0],i=o[1],s=0|(null!=i?r+1:r);return List_fold((e,t)=>{const r=0|e[0],o=n(t,s),i=0|o[0];return i>r?[i,o[1]]:[r,e[1]]},[o[0],i],nodeChildren(t))}};return List_fold((e,t)=>{const r=0|e[0],o=n(t,0),i=0|o[0];return i>r?[i,o[1]]:[r,e[1]]},[0,void 0],nodeChildren(t))}function analyzeFunction(e,t,n){let r,o,i;const s=findBody(t,n);if(null!=s){const a=Option_value(s);let _;const u=functionStatements(t,a);let l,c;switch(List_isEmpty(u)?l=1:Inversion_hasType(t.NodeTypes.IfStatement,List_head(u))?(l=0,c=List_head(u)):l=1,l){case 0:{const r=List_tryFind(e=>Inversion_hasType(t.NodeTypes.Block,e),nodeChildren(c));let o,i;if(null!=r&&List_length(nodeChildren(Option_value(r)))>2?(o=0,i=Option_value(r)):o=1,0===o)if((i.endIndex-i.startIndex)/(n.endIndex-n.startIndex)>.5){const t=e.toPosition(c.startIndex);_=List_singleton(new EnergyViolation(t.Line,t.Column,ViolationType.Inversion,Severity.Medium,"Consider inverting this condition and using early return for cleaner flow.",List_empty()))}else _=List_empty();else _=List_empty();break}default:_=List_empty()}const d=nestedValidation(t,a);let p,m,f;switch(List_isEmpty(d)?m=1:List_length(d)>=2?(m=0,f=List_head(d)):m=1,m){case 0:{const t=e.toPosition(f.startIndex);p=List_singleton(new EnergyViolation(t.Line,t.Column,ViolationType.Inversion,Severity.Medium,(r=0|List_length(d),toText(printf("Found %d nested validation checks. Consider using guard clauses with early returns."))(r)),List_empty()));break}default:p=List_empty()}const y=deepestIf(t,a),h=y[1],g=0|y[0];return List_append(_,List_append(p,null!=h?(Option_value(h),g>=3?(o=Option_value(h),i=e.toPosition(o.startIndex),List_singleton(new EnergyViolation(i.Line,i.Column,ViolationType.Inversion,Severity.Medium,toText(printf("Deep if-nesting (%d levels). Consider inverting conditions or extracting functions."))(g),List_empty()))):List_empty()):List_empty()))}return List_empty()}function analyzeInversionOpportunities(e,t,n){const r=e=>List_append(n.IsFunctionDefinition(e)?analyzeFunction(t,n,e):List_empty(),List_collect(r,nodeChildren(e)));return r(e)}const Inversion_detector=new Detector("inversion",e=>analyzeInversionOpportunities(e.Tree,e.Positions,e.Language));function analyzeLogicalControlFlow(e,t,n){const r=e=>{let o,i,s,a,_,u,l,c,d,p;return List_append((o=n.GetBooleanOperator(e),i=nodeParent(e),null!=o?1===o.tag?null!=i?(s=Option_value(i),Seq_exists((a=s.type,e=>equals(a,e)),toArray(n.NodeTypes.ExpressionStatement))?(_=Option_value(i),u=t.toPosition(e.startIndex),List_singleton(new EnergyViolation(u.Line,u.Column,ViolationType.LogicalControlFlow,Severity.Low,"If-statement disguised as '||'. Consider an explicit if-statement instead.",List_empty()))):List_empty()):List_empty():null!=i?(l=Option_value(i),Seq_exists((c=l.type,e=>equals(c,e)),toArray(n.NodeTypes.ExpressionStatement))?(d=Option_value(i),p=t.toPosition(e.startIndex),List_singleton(new EnergyViolation(p.Line,p.Column,ViolationType.LogicalControlFlow,Severity.Low,"If-statement disguised as '&&'. Consider an explicit if-statement instead.",List_empty()))):List_empty()):List_empty():List_empty()),List_collect(r,nodeChildren(e)))};return r(e)}const LogicalControlFlow_detector=new Detector("logicalControlFlow",e=>analyzeLogicalControlFlow(e.Tree,e.Positions,e.Language));function analyzeOpaqueBooleanLiteral(e,t,n){const r=e=>{let o,i;return List_append(n.IsBooleanLiteral(e)&&n.IsPositionalCallArgument(e)?(o=t.toPosition(e.startIndex),List_singleton(new EnergyViolation(o.Line,o.Column,ViolationType.OpaqueBoolean,Severity.Low,(i=e.text,toText(printf("Opaque boolean literal: a bare '%s' passed positionally tells the reader nothing without checking the callee's signature. Name it at the call site (a keyword argument, an object-literal field, or F#'s named-argument syntax) — or better, split into two clearly named functions (e.g. enableX()/disableX()) or use an enum."))(i)),List_empty()))):List_empty(),List_collect(r,nodeChildren(e)))};return r(e)}const OpaqueBoolean_detector=new Detector("opaqueBoolean",e=>analyzeOpaqueBooleanLiteral(e.Tree,e.Positions,e.Language));var PrimitiveObsession_record_type,PrimitiveObsession_string_type,PrimitiveObsession_obj_type,PrimitiveObsession_bool_type;class TypedParameterNode extends Record{constructor(e,t,n,r){super(),this.Name=e,this.Type=t,this.Node=n,this.KeywordOnly=r}}function TypedParameterNode_$reflection(){return PrimitiveObsession_record_type("Energy.Core.Detectors.PrimitiveObsession.TypedParameterNode",[],TypedParameterNode,()=>[["Name",PrimitiveObsession_string_type],["Type",PrimitiveObsession_string_type],["Node",PrimitiveObsession_obj_type],["KeywordOnly",PrimitiveObsession_bool_type]])}function findParameterCollisions(e,t,n){return List_choose(e=>{const r=e[0],o=e[1];if(!(r.Type!==o.Type||!Set_contains(r.Type,n.PrimitiveTypeNames)||r.KeywordOnly&&o.KeywordOnly)){const e=t.toPosition(r.Node.startIndex);return new EnergyViolation(e.Line,e.Column,ViolationType.PrimitiveObsession,Severity.Medium,toText(printf("Primitive obsession: consecutive parameters '%s: %s' and '%s: %s' share the same primitive type — a caller can swap them and nothing will complain. Consider %s so the type checker catches it."))(r.Name)(r.Type)(o.Name)(o.Type)(n.DistinctTypeAdvice),List_empty())}},List_pairwise(List_fold((e,t)=>{const r=e[0],o=e[1];if(List_contains(t.type,n.KeywordOnlyBoundaryTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}))return[!0,o];{const e=n.ExtractTypedParameter(t);if(null==e)return[r,o];{const n=e;return[r,List_append(o,List_singleton(new TypedParameterNode(n.Name,n.Type,t,r)))]}}},[!1,List_empty()],nodeChildren(e))[1]))}function PrimitiveObsession_stripQuotes(e){return substring(e,1,e.length-2)}function findStringlyTypedControlFlow(e,t,n){const r=e=>Seq_exists(t=>equals(e.type,t),toArray(n.NodeTypes.StringLiteral)),o=(e,t,n)=>{const r=e.text,o=Map_tryFind(r,n);if(null==o)return Map_add(r,[Set_ofList(t,{Compare:(e,t)=>0|comparePrimitives(e,t)}),e],n);{const e=o[1];return Map_add(r,[union(o[0],Set_ofList(t,{Compare:(e,t)=>0|comparePrimitives(e,t)})),e],n)}},i=(e,t)=>List_fold((e,t)=>i(t,e),List_fold((e,t)=>List_contains(t.Left.type,n.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&!List_isEmpty(t.Values)?o(t.Left,t.Values,e):e,List_fold((e,t)=>List_contains(t.Left.type,n.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&r(t.Right)?o(t.Left,List_singleton(PrimitiveObsession_stripQuotes(t.Right.text)),e):List_contains(t.Right.type,n.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&r(t.Left)?o(t.Right,List_singleton(PrimitiveObsession_stripQuotes(t.Left.text)),e):e,t,n.GetEqualityComparisons(e)),n.GetMembershipComparisons(e)),nodeChildren(e));return List_choose(e=>{let n,r;const o=e[1],i=o[0];if(!(Set_count(i)<3)){const s=t.toPosition(o[1].startIndex),a=List_truncate(4,Set_toList(i)),_=Set_count(i)>List_length(a)?", …":"";return new EnergyViolation(s.Line,s.Column,ViolationType.PrimitiveObsession,Severity.Low,(n=0|Set_count(i),r=join(", ",a),toText(printf("Stringly-typed control flow: '%s' is compared against %d distinct string literals (%s%s). Consider an Enum or Literal type to catch typos and get exhaustiveness checking."))(e[0])(n)(r)(_)),List_empty())}},Map_toList(i(e,Map_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}))))}function analyzePrimitiveObsession(e,t,n){const r=e=>{let o;return List_append(n.IsFunctionDefinition(e)?List_append((o=findParametersNode(e,n.NodeTypes.Parameters),null==o?List_empty():findParameterCollisions(Option_value(o),t,n)),findStringlyTypedControlFlow(e,t,n)):List_empty(),List_collect(r,nodeChildren(e)))};return r(e)}const PrimitiveObsession_detector=new Detector("primitiveObsession",e=>analyzePrimitiveObsession(e.Tree,e.Positions,e.Language));var Suppressions_union_type,Suppressions_record_type,Suppressions_int32_type,Suppressions_option_type,Suppressions_class_type,Suppressions_list_type,Suppressions_string_type,Suppressions_bool_type,Suppressions_ViolationType_$reflection,Suppressions_EnergyViolation_$reflection;class SuppressionScope extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Line","File"]}static Line=new SuppressionScope(0,[]);static File=new SuppressionScope(1,[])}function SuppressionScope_$reflection(){return Suppressions_union_type("Energy.Core.Suppressions.SuppressionScope",[],SuppressionScope,()=>[[],[]])}class Suppression extends Record{constructor(e,t,n,r,o,i){super(),this.Line=0|e,this.Column=0|t,this.Scope=n,this.Types=r,this.UnknownTypes=o,this.Standalone=i}}function Suppression_$reflection(){return Suppressions_record_type("Energy.Core.Suppressions.Suppression",[],Suppression,()=>[["Line",Suppressions_int32_type],["Column",Suppressions_int32_type],["Scope",SuppressionScope_$reflection()],["Types",Suppressions_option_type(Suppressions_class_type("Microsoft.FSharp.Collections.FSharpSet`1",[Suppressions_ViolationType_$reflection()]))],["UnknownTypes",Suppressions_list_type(Suppressions_string_type)],["Standalone",Suppressions_bool_type]])}class ApplySuppressionsResult extends Record{constructor(e,t){super(),this.Violations=e,this.SuppressionNotes=t}}function ApplySuppressionsResult_$reflection(){return Suppressions_record_type("Energy.Core.Suppressions.ApplySuppressionsResult",[],ApplySuppressionsResult,()=>[["Violations",Suppressions_list_type(Suppressions_EnergyViolation_$reflection())],["SuppressionNotes",Suppressions_list_type(Suppressions_EnergyViolation_$reflection())]])}const directivePattern=/(\/\/|#)\s*esa-ignore(-file)?(?::\s*([\w,\s-]+))?\s*$/gu,knownTypes=Map_ofList(List_ofArray([["nesting",ViolationType.Nesting],["complexity",ViolationType.Complexity],["cognitive",ViolationType.Cognitive],["naming",ViolationType.Naming],["coherence",ViolationType.Coherence],["magic",ViolationType.Magic],["parameters",ViolationType.Parameters],["inversion",ViolationType.Inversion],["primitive-obsession",ViolationType.PrimitiveObsession],["match-opportunity",ViolationType.MatchOpportunity],["logical-control-flow",ViolationType.LogicalControlFlow],["opaque-boolean",ViolationType.OpaqueBoolean],["suppression",ViolationType.Suppression]]),{Compare:(e,t)=>0|comparePrimitives(e,t)});function parseTypeList(e){let t;if(isNullOrWhiteSpace(e))return[void 0,List_empty()];{const n=List_ofArray((t=Array_map(e=>e.trim(),String_split(e,[","],void 0,0)),t.filter(e=>""!==e))),r=List_fold((e,t)=>{const n=e[0],r=e[1],o=Map_tryFind(t,knownTypes);return null==o?[n,List_append(r,List_singleton(t))]:[Set_add(o,n),r]},[Set_empty({Compare:(e,t)=>0|compare(e,t)}),List_empty()],n);return[r[0],r[1]]}}function parseSuppressions(e){return List_ofArray(choose(e=>e,mapIndexed((e,t)=>{const n=match(directivePattern,t);if(null!=n){const r=parseTypeList(n[3]||"");return new Suppression(e,n.index,null!=n[2]?SuppressionScope.File:SuppressionScope.Line,r[0],r[1],""===substring(t,0,n.index).trim())}},String_split(e,["\n"],void 0,0))))}function coversLine(e,t){return 0!==e.Scope.tag||t===e.Line||!!e.Standalone&&t===e.Line+1}function matchesType(e,t){return Seq_forAll(e=>Set_contains(t,e),toArray(e.Types))}function applySuppressions(e,t){const n=List_indexed(parseSuppressions(t));if(List_isEmpty(n))return new ApplySuppressionsResult(e,List_empty());{const t=List_fold((e,t)=>{const r=e[0],o=e[1],i=List_tryFind(e=>{const n=e[1];return!!coversLine(n,t.Line)&&matchesType(n,t.Type)},n);return null==i?[cons(t,r),o]:[r,change(i[0],e=>1+defaultArg(e,0),o)]},[List_empty(),Map_empty({Compare:(e,t)=>0|comparePrimitives(e,t)})],e),r=List_collect(e=>{let n,r;const o=e[1];return List_append(List_isEmpty(o.UnknownTypes)?List_empty():List_singleton(new EnergyViolation(o.Line,o.Column,ViolationType.Suppression,Severity.Low,(n=join(", ",o.UnknownTypes),toText(printf("esa-ignore names unknown violation type(s): %s."))(n)),List_empty())),defaultArg(Map_tryFind(e[0],t[1]),0)>0?List_empty():(r=equals(o.Scope,SuppressionScope.File)?"file-wide ":"",List_singleton(new EnergyViolation(o.Line,o.Column,ViolationType.Suppression,Severity.Low,toText(printf("Unused %sesa-ignore — no matching violation found. Remove it or fix the type list."))(r),List_empty()))))},n);return new ApplySuppressionsResult(List_reverse(t[0]),r)}}var Analyze_NestingThresholds_$reflection,Analyze_record_type,Analyze_option_type,Analyze_CyclomaticThresholds_$reflection,Analyze_CognitiveThresholds_$reflection,Analyze_CoherenceThresholds_$reflection,Analyze_MatchOpportunityThresholds_$reflection,Analyze_MagicNumberOptions_$reflection,Analyze_MagicStringOptions_$reflection,Analyze_collect,Analyze_append,Analyze_applySuppressions,Analyze_createPositionLookup,Analyze_AnalysisContext;class AnalyzeThresholds extends Record{constructor(e,t,n,r,o,i,s){super(),this.Nesting=e,this.Cyclomatic=t,this.Cognitive=n,this.Coherence=r,this.MatchOpportunity=o,this.MagicNumber=i,this.MagicString=s}}function AnalyzeThresholds_$reflection(){return Analyze_record_type("Energy.Core.Analyze.AnalyzeThresholds",[],AnalyzeThresholds,()=>[["Nesting",Analyze_option_type(Analyze_NestingThresholds_$reflection())],["Cyclomatic",Analyze_option_type(Analyze_CyclomaticThresholds_$reflection())],["Cognitive",Analyze_option_type(Analyze_CognitiveThresholds_$reflection())],["Coherence",Analyze_option_type(Analyze_CoherenceThresholds_$reflection())],["MatchOpportunity",Analyze_option_type(Analyze_MatchOpportunityThresholds_$reflection())],["MagicNumber",Analyze_option_type(Analyze_MagicNumberOptions_$reflection())],["MagicString",Analyze_option_type(Analyze_MagicStringOptions_$reflection())]])}const Analyze_defaultThresholds=new AnalyzeThresholds(void 0,void 0,void 0,void 0,void 0,void 0,void 0),allDetectors=List_ofArray([Nesting_detector,Cyclomatic_detector,Cognitive_detector,Coherence_detector,detector,MagicString_detector,ParameterCount_detector,Inversion_detector,MatchOpportunity_detector,LogicalControlFlow_detector,OpaqueBoolean_detector,PrimitiveObsession_detector]);function runPipeline(e){const t=Analyze_applySuppressions(Analyze_collect(t=>t.Run(e),allDetectors),e.Source);return Analyze_append(t.Violations,t.SuppressionNotes)}function runPipelineWith(e,t){const n=applySuppressions(List_collect(e=>e,List_ofArray([analyzeNesting(t,defaultArg(e.Nesting,defaultNestingThresholds)),analyzeFunctionComplexity(t.Tree,t.Positions,t.Language,defaultArg(e.Cyclomatic,defaultCyclomaticThresholds)),analyzeCognitiveComplexity(t.Tree,t.Positions,t.Language,defaultArg(e.Cognitive,defaultCognitiveThresholds)),analyzeFileCoherence(t.Tree,t.FileName,t.Language,t.Positions,defaultArg(e.Coherence,defaultCoherenceThresholds)),analyzeMagicNumbers(t.Tree,t.Positions,t.Language,t.FileName,defaultArg(e.MagicNumber,defaultOptions)),analyzeMagicStrings(t.Tree,t.Positions,t.Language,t.FileName,defaultArg(e.MagicString,MagicString_defaultOptions)),analyzeParameterCount(t.Tree,t.Positions,t.Language),analyzeInversionOpportunities(t.Tree,t.Positions,t.Language),analyzeMatchOpportunities(t.Tree,t.Positions,t.Language,defaultArg(e.MatchOpportunity,defaultThresholds)),analyzeLogicalControlFlow(t.Tree,t.Positions,t.Language),analyzeOpaqueBooleanLiteral(t.Tree,t.Positions,t.Language),analyzePrimitiveObsession(t.Tree,t.Positions,t.Language)])),t.Source);return List_append(n.Violations,n.SuppressionNotes)}function analyzeSource(e,t,n,r){return runPipeline(new Analyze_AnalysisContext(e,t,Analyze_createPositionLookup(e),n,r))}function analyzeSourceWith(e,t,n,r,o){return runPipelineWith(e,new AnalysisContext(t,n,createPositionLookup(t),r,o))}var OperationCanceledException;class TaskCompletionSource{constructor(){this.task=new Promise((e,t)=>{this._resolve=e,this._reject=t})}SetResult(e){this._resolve(e)}SetException(e){this._reject(e)}SetCancelled(){this._reject(new OperationCanceledException)}get_Task(){return this.task}}function fromResult(e){return Promise.resolve(e)}function zero(){return Promise.resolve()}function getAwaiter(e){return e}function getResult(e){return e}class TaskBuilder{Bind(e,t){return e.then(t)}Combine(e,t){return e.then(t)}Delay(e){return e}For(e,t){const n=e[Symbol.iterator]();let r=n.next();return this.While(()=>!r.done,this.Delay(()=>{const e=t(r.value);return r=n.next(),e}))}Return(e){return Promise.resolve(e)}ReturnFrom(e){return e}TryFinally(e,t){try{return e().finally(t)}catch(e){return t(),Promise.reject(e)}}TryWith(e,t){try{return e().catch(t)}catch(e){try{return t(e)}catch(e){return Promise.reject(e)}}}Using(e,t){return this.TryFinally(()=>t(e),()=>e.Dispose())}While(e,t){return(async()=>{for(;e();)await t()})()}Zero(){return zero()}Run(e){try{return e()}catch(e){return Promise.reject(e)}}}const TaskBuilder_singleton=new TaskBuilder;function TaskBuilder_task(){return TaskBuilder_singleton}function error(e){console.error(e)}function output(e){console.log(e)}const typeAnnotationNodeType="type",argumentListNodeType="argument_list",attributeNodeType="attribute",identifierNodeType="identifier",typedDefaultParameterNodeType="typed_default_parameter",comparisonOperatorNodeType="comparison_operator",callNodeType="call",andOperatorNodeType="and";function isFirstChild(e,t){let n,r;const o=List_tryHead(nodeChildren(t));return r=null!=o?(n=Option_value(o),n.id):void 0,equals(e.id,r)}function isFormatCall(e){return!!Seq_exists(e=>"format"===e.text,toArray(List_tryFind(e=>equals(e.type,identifierNodeType),nodeChildren(e))))&&Seq_exists(e=>equals(e.type,callNodeType),toArray(nodeParent(e)))}function isFormattedStringParent(e,t){const n=isFirstChild(e,t),r=t.type;return equals(r,"binary_operator")?!!n&&List_exists(e=>equals(e.type,"%"),nodeChildren(t)):!!equals(r,attributeNodeType)&&!!n&&isFormatCall(t)}const PYTHON=new LanguageAdapter("python","grammars/tree-sitter-python.wasm",new NodeTypes("block","parameters","if_statement","else_clause","for_statement","while_statement","conditional_expression","lambda","import_statement","import_from_statement","expression_statement","assignment","module",void 0,"comment","integer","float","string"),e=>equals(e.type,"function_definition"),List_ofArray([identifierNodeType,"default_parameter"]),List_ofArray(["if_statement","elif_clause","while_statement","for_statement","except_clause","conditional_expression","match_statement"]),e=>{if(equals(e.type,"match_statement")){const t=List_filter(e=>equals(e.type,"case_clause"),List_collect(nodeNamedChildren,nodeNamedChildren(e))),n=List_exists(e=>e.text.indexOf("case _")>=0,t);return List_length(t)+(n?0:1)}},List_ofArray(["if_statement","elif_clause","for_statement","while_statement","except_clause","match_statement"]),List_ofArray(["if_statement","for_statement","while_statement","with_statement","try_statement","match_statement"]),e=>{let t;if(equals(e.type,"boolean_operator")){const n=List_tryFind(e=>!!equals(e.type,andOperatorNodeType)||equals(e.type,"or"),nodeChildren(e));return null!=n?(t=Option_value(n),equals(t.type,andOperatorNodeType)?BooleanOperator.And:BooleanOperator.Or):void 0}},e=>equals(e.type,"block"),e=>{if(equals(e.type,"else_clause")){const t=nodeParent(e);return null!=t&&equals(Option_value(t).type,"try_statement")}return!1},List_ofArray([identifierNodeType,attributeNodeType]),e=>{if(equals(e.type,"typed_parameter")||equals(e.type,typedDefaultParameterNodeType)){const t=List_tryFind(e=>equals(e.type,identifierNodeType),nodeChildren(e)),n=List_tryFind(e=>equals(e.type,typeAnnotationNodeType),nodeChildren(e));let r,o,i;return null!=t&&null!=n?(r=0,o=Option_value(t),i=Option_value(n)):r=1,0===r?new TypedParameter(o.text,i.text):void 0}},e=>{const t=List_tryFindIndex(e=>equals(e.type,"->"),nodeChildren(e));if(null!=t){const n=0|t,r=nodeChildren(e);if(n+1<List_length(r)){const e=List_item(n+1,r);return equals(e.type,typeAnnotationNodeType)?e.text:void 0}return}},new GenericBrackets("[","]"),Set_ofList(List_ofArray(["str","int","float","bool","bytes"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),List_ofArray(["keyword_separator","list_splat_pattern"]),"NewType or a dataclass",e=>{if(equals(e.type,comparisonOperatorNodeType)){const t=nodeChildren(e);return List_map(e=>{const n=0|e[0];return new EqualityComparison(List_item(n-1,t),List_item(n+1,t))},List_filter(e=>equals(e[1].type,"=="),List_filter(e=>{const n=0|e[0];return n>=1&&n+1<List_length(t)},List_mapIndexed((e,t)=>[e,t],t))))}return List_empty()},e=>{if(equals(e.type,comparisonOperatorNodeType)){const t=nodeChildren(e);return List_choose(e=>{const n=List_item(e[0],t),r=List_item(e[1],t);if(equals(r.type,"tuple")||equals(r.type,"list")||equals(r.type,"set")){const e=List_fold((e,t)=>{let n;const r=e[1],o=t;return e[0]?[!0,r]:o.isNamed?equals(o.type,"string")?[!1,List_append(r,List_singleton((n=o.text,substring(n,1,n.length-2))))]:[!0,r]:[!1,r]},[!1,List_empty()],nodeChildren(r)),t=e[1];return e[0]?void 0:List_length(t)>0?new MembershipComparison(n,t):void 0}},List_map(e=>{const t=0|e[0];return[t-1,t+1]},List_filter(e=>equals(e[1].type,"in"),List_filter(e=>{const n=0|e[0];return n>=1&&n+1<List_length(t)},List_mapIndexed((e,t)=>[e,t],t)))))}return List_empty()},e=>List_filter(e=>equals(e.type,"elif_clause"),nodeChildren(e)),List_singleton("subscript"),e=>null!=List_tryFind(e=>equals(e.type,"interpolation"),nodeChildren(e))||Seq_exists(t=>isFormattedStringParent(e,t),toArray(nodeParent(e))),e=>{const t=nodeParent(e);if(null==t)return!1;{const n=Option_value(t),r=nodeChildren(n);return(!!equals(n.type,"default_parameter")||equals(n.type,typedDefaultParameterNodeType))&&List_length(r)>0&&List_item(List_length(r)-1,r).id===e.id}},e=>!!equals(e.type,"true")||equals(e.type,"false"),e=>{const t=nodeParent(e);if(null==t)return!1;{const e=Option_value(t);if(equals(e.type,argumentListNodeType)){const t=nodeParent(e);return null!=t&&equals(Option_value(t).type,callNodeType)}return!1}},e=>!1,e=>{const t=nodeChildren(e);if(equals(e.type,"import_from_statement")){const n=List_tryFindIndex(e=>equals(e.type,"import"),t);let r,o;return null!=n&&n>=1?(r=0,o=n):r=1,0===r?List_item(o-1,t).text:e.text}{const n=List_tryFind(e=>equals(e.type,"dotted_name"),t);return null==n?e.text:Option_value(n).text}},List_singleton("class_definition"),e=>{let t;const n=List_tryFind(e=>equals(e.type,identifierNodeType),nodeChildren(e));return null!=n?(t=Option_value(n),t.text):void 0},e=>{const t=List_tryFind(e=>equals(e.type,argumentListNodeType),nodeChildren(e));return null==t?List_empty():List_map(e=>e.text,List_filter(e=>!!equals(e.type,identifierNodeType)||equals(e.type,attributeNodeType),nodeChildren(Option_value(t))))}),functionDeclarationLeft="function_declaration_left",FSHARP=new LanguageAdapter("fsharp","grammars/tree-sitter-fsharp.wasm",new NodeTypes(void 0,"argument_patterns","if_expression",void 0,"for_expression","while_expression",void 0,"fun_expression","import_decl",void 0,void 0,"function_or_value_defn","declaration_expression",void 0,"line_comment","int","float","string"),e=>equals(e.type,"function_or_value_defn")&&List_exists(e=>equals(e.type,functionDeclarationLeft),nodeChildren(e)),List_ofArray(["long_identifier","typed_pattern"]),List_ofArray(["if_expression","elif_expression","for_expression","while_expression","try_expression","match_expression"]),e=>{if(equals(e.type,"match_expression")){const t=List_filter(e=>equals(e.type,"rule"),List_collect(nodeNamedChildren,nodeNamedChildren(e))),n=List_exists(e=>e.text.indexOf("_ ->")>=0,t);return List_length(t)+(n?0:1)}},List_ofArray(["if_expression","elif_expression","for_expression","while_expression","try_expression","match_expression"]),List_ofArray(["if_expression","elif_expression","for_expression","while_expression","try_expression","match_expression"]),e=>{if(equals(e.type,"infix_expression")){const t=List_tryFind(e=>equals(e.type,"infix_op"),nodeChildren(e));if(null==t)return;{const e=Option_value(t).text;return"&&"===e?BooleanOperator.And:"||"===e?BooleanOperator.Or:void 0}}},e=>!0,e=>!1,List_singleton("long_identifier_or_op"),e=>{if(equals(e.type,"typed_pattern")){const t=List_tryFind(e=>equals(e.type,"identifier_pattern"),nodeChildren(e)),n=List_tryFind(e=>!!equals(e.type,"simple_type")||equals(e.type,"generic_type"),nodeChildren(e));let r,o,i;return null!=t&&null!=n?(r=0,o=Option_value(t),i=Option_value(n)):r=1,0===r?new TypedParameter(o.text,i.text):void 0}},e=>{if(equals(e.type,"function_or_value_defn")){const t=List_tryFindIndex(e=>equals(e.type,functionDeclarationLeft),nodeChildren(e)),n=List_tryFindIndex(e=>equals(e.type,"="),nodeChildren(e));let r,o,i;if(null!=t&&null!=n?(r=0,o=t,i=n):r=1,0===r){let t;const n=List_tryFindIndex(e=>equals(e.type,":"),nodeChildren(e));if(null!=n){const e=0|n;t=e>o&&e<i?e:void 0}else t=void 0;let r,s;return null!=t&&t+1<List_length(nodeChildren(e))?(r=0,s=t):r=1,0===r?List_item(s+1,nodeChildren(e)).text:void 0}return}},new GenericBrackets("<",">"),Set_ofList(List_ofArray(["string","int","float","bool"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),List_empty(),"a single-case union type",e=>{let t;if(equals(e.type,"infix_expression")){const n=List_tryFind(e=>equals(e.type,"infix_op"),nodeChildren(e));let r,o;if(null!=n?(t=Option_value(n),"="===t.text?(r=0,o=Option_value(n)):r=1):r=1,0===r){const t=List_filter(e=>e.id!==o.id,nodeChildren(e));let n,r,i;return List_isEmpty(t)||List_isEmpty(List_tail(t))?n=1:List_isEmpty(List_tail(List_tail(t)))?(n=0,r=List_head(t),i=List_head(List_tail(t))):n=1,0===n?List_singleton(new EqualityComparison(r,equals(i.type,"const")&&1===List_length(nodeChildren(i))?List_head(nodeChildren(i)):i)):List_empty()}return List_empty()}return List_empty()},e=>List_empty(),e=>List_filter(e=>equals(e.type,"elif_expression"),nodeChildren(e)),List_empty(),e=>!1,e=>!1,e=>{if(equals(e.type,"const")){const t=nodeChildren(e);let n,r;return List_isEmpty(t)?n=1:List_isEmpty(List_tail(t))?(n=0,r=List_head(t)):n=1,0===n&&equals(r.type,"bool")}return!1},e=>{let t,n;const r=nodeParent(e);let o,i,s;switch(null!=r?(t=Option_value(r),equals(t.type,"application_expression")?(o=0,i=Option_value(r)):(n=Option_value(r),equals(n.type,"tuple_expression")?(o=1,s=Option_value(r)):o=2)):o=2,o){case 0:{const t=List_tryItem(0,nodeChildren(i));return null==t||Option_value(t).id!==e.id}case 1:{const e=nodeParent(s);return null!=e&&equals(Option_value(e).type,"application_expression")}default:return!1}},e=>!1,e=>{const t=List_tryFind(e=>equals(e.type,"long_identifier"),nodeChildren(e));return null==t?e.text:Option_value(t).text},List_empty(),e=>{},e=>List_empty()),TypeScript_typeAnnotationNodeType="type_annotation",typeIdentifierNodeType="type_identifier";function extendsTargetNames(e){const t=List_tryFind(e=>equals(e.type,"extends_clause"),nodeChildren(e)),n=null==t?void 0:List_tryFind(e=>!equals(e.type,"extends"),nodeChildren(Option_value(t)));return null==n?List_empty():List_singleton(Option_value(n).text)}function implementsTargetNames(e){const t=List_tryFind(e=>equals(e.type,"implements_clause"),nodeChildren(e));return null==t?List_empty():List_map(e=>e.text,List_filter(e=>equals(e.type,typeIdentifierNodeType),nodeChildren(Option_value(t))))}const TYPESCRIPT=new LanguageAdapter("typescript","grammars/tree-sitter-typescript.wasm",new NodeTypes("statement_block","formal_parameters","if_statement","else_clause","for_statement","while_statement","ternary_expression","arrow_function","import_statement",void 0,"expression_statement","lexical_declaration","program","export_statement","comment","number",void 0,"string"),e=>!!equals(e.type,"function_declaration")||equals(e.type,"method_definition"),List_ofArray(["required_parameter","optional_parameter"]),List_ofArray(["if_statement","for_statement","for_in_statement","while_statement","catch_clause","ternary_expression","switch_statement"]),e=>{if(equals(e.type,"switch_statement")){const t=List_filter(e=>!!equals(e.type,"switch_case")||equals(e.type,"switch_default"),List_collect(nodeNamedChildren,nodeNamedChildren(e))),n=List_exists(e=>equals(e.type,"switch_default"),t);return List_length(t)+(n?0:1)}},List_ofArray(["if_statement","for_statement","for_in_statement","while_statement","catch_clause"]),List_ofArray(["if_statement","for_statement","for_in_statement","while_statement","try_statement"]),e=>{let t;if(equals(e.type,"binary_expression")){const n=List_tryFind(e=>!!equals(e.type,"&&")||equals(e.type,"||"),nodeChildren(e));return null!=n?(t=Option_value(n),equals(t.type,"&&")?BooleanOperator.And:BooleanOperator.Or):void 0}},e=>equals(e.type,"statement_block"),e=>!1,List_ofArray(["identifier","member_expression"]),e=>{if(equals(e.type,"required_parameter")||equals(e.type,"optional_parameter")){const t=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(e)),n=List_tryFind(e=>equals(e.type,TypeScript_typeAnnotationNodeType),nodeChildren(e));let r,o,i;if(null!=t&&null!=n?(r=0,o=Option_value(t),i=Option_value(n)):r=1,0===r){const e=List_tryFind(e=>!equals(e.type,":"),nodeChildren(i));if(null==e)return;{const t=Option_value(e);return new TypedParameter(o.text,t.text)}}return}},e=>{const t=List_tryFind(e=>equals(e.type,TypeScript_typeAnnotationNodeType),nodeChildren(e));if(null!=t){const e=List_tryFind(e=>!equals(e.type,":"),nodeChildren(Option_value(t)));if(null==e)return;return Option_value(e).text}},new GenericBrackets("<",">"),Set_ofList(List_ofArray(["string","number","boolean"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),List_empty(),"a branded/nominal type (e.g. a tagged type alias)",e=>{if(equals(e.type,"binary_expression")){const t=List_tryFind(e=>!!equals(e.type,"===")||equals(e.type,"=="),nodeChildren(e));if(null==t)return List_empty();{const n=Option_value(t),r=List_filter(e=>e.id!==n.id,nodeChildren(e));let o,i,s;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),s=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,s)):List_empty()}}return List_empty()},e=>List_empty(),e=>List_empty(),List_singleton("subscript_expression"),e=>!1,e=>{let t;const n=nodeParent(e);let r,o;if(null!=n?(t=Option_value(n),equals(t.type,"required_parameter")||equals(t.type,"optional_parameter")?(r=0,o=Option_value(n)):r=1):r=1,0===r){const t=nodeChildren(o);if(List_exists(e=>equals(e.type,"="),t)){const n=List_tryItem(List_length(t)-1,t);return null!=n&&Option_value(n).id===e.id}return!1}return!1},e=>!!equals(e.type,"true")||equals(e.type,"false"),e=>{const t=nodeParent(e);if(null==t)return!1;{const e=Option_value(t),n=nodeParent(e);if(null==n)return!1;{const t=Option_value(n);return equals(e.type,"arguments")&&equals(t.type,"call_expression")}}},e=>!1,e=>{const t=List_tryFind(e=>equals(e.type,"string"),nodeChildren(e));return null==t?e.text:Option_value(t).text},List_ofArray(["class_declaration","abstract_class_declaration"]),e=>{let t;const n=List_tryFind(e=>equals(e.type,typeIdentifierNodeType),nodeChildren(e));return null!=n?(t=Option_value(n),t.text):void 0},e=>{const t=List_tryFind(e=>equals(e.type,"class_heritage"),nodeChildren(e));if(null==t)return List_empty();{const e=Option_value(t);return List_append(extendsTargetNames(e),implementsTargetNames(e))}});function isUserType(e){return equals(e.type,"user_type")}function isConstPropertyDeclaration(e){const t=List_tryFind(e=>equals(e.type,"modifiers"),nodeChildren(e));return null!=t&&List_exists(e=>!!equals(e.type,"property_modifier")&&List_exists(e=>equals(e.type,"const"),nodeChildren(e)),nodeChildren(Option_value(t)))}function isAnnotatedConstValMisparse(e){const t=List_tryFind(e=>equals(e.type,"annotated_expression"),nodeChildren(e));if(null==t)return!1;{const e=List_tryFind(e=>equals(e.type,"infix_expression"),nodeChildren(Option_value(t)));if(null==e)return!1;{const t=List_filter(e=>equals(e.type,"identifier"),nodeChildren(Option_value(e)));if(3!==List_length(t))return!1;{const e=List_toArray(t);return"const"===item(0,e).text&&"val"===item(1,e).text}}}}function delegationSpecifierName(e){let t,n;const r=List_tryFind(isUserType,nodeChildren(e));if(null==r){const t=List_tryFind(e=>equals(e.type,"constructor_invocation"),nodeChildren(e));n=null==t?void 0:List_tryFind(isUserType,nodeChildren(Option_value(t)))}else n=some(Option_value(r));if(null!=n){const e=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(Option_value(n)));return null!=e?(t=Option_value(e),t.text):void 0}}const KOTLIN=new LanguageAdapter("kotlin","grammars/tree-sitter-kotlin.wasm",new NodeTypes("block","function_value_parameters","if_expression",void 0,"for_statement","while_statement",void 0,"lambda_literal","import",void 0,void 0,"property_declaration","source_file",void 0,"line_comment","number_literal","float_literal","string_literal"),e=>equals(e.type,"function_declaration"),List_singleton("parameter"),List_ofArray(["if_expression","for_statement","while_statement","when_expression","catch_block"]),e=>{if(equals(e.type,"when_expression")){const t=List_filter(e=>equals(e.type,"when_entry"),nodeNamedChildren(e)),n=List_exists(e=>e.text.indexOf("else ->")>=0,t);return List_length(t)+(n?0:1)}},List_ofArray(["if_expression","for_statement","while_statement","when_expression","catch_block"]),List_ofArray(["if_expression","for_statement","while_statement","try_expression"]),e=>{let t;if(equals(e.type,"binary_expression")){const n=List_tryFind(e=>!!equals(e.type,"&&")||equals(e.type,"||"),nodeChildren(e));return null!=n?(t=Option_value(n),equals(t.type,"&&")?BooleanOperator.And:BooleanOperator.Or):void 0}},e=>equals(e.type,"block"),e=>!1,List_ofArray(["identifier","navigation_expression"]),e=>{if(equals(e.type,"parameter")){const t=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(e)),n=List_tryFind(isUserType,nodeChildren(e));let r,o,i;if(null!=t&&null!=n?(r=0,o=Option_value(t),i=Option_value(n)):r=1,0===r){const e=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(i));if(null==e)return;{const t=Option_value(e);return new TypedParameter(o.text,t.text)}}return}},e=>{const t=List_tryFindIndex(e=>equals(e.type,":"),nodeChildren(e));let n,r;if(null!=t&&t+1<List_length(nodeChildren(e))?(n=0,r=t):n=1,0===n)return List_item(r+1,nodeChildren(e)).text},new GenericBrackets("<",">"),Set_ofList(List_ofArray(["Int","Long","Short","Byte","Double","Float","Boolean","String","Char"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),List_empty(),"a value class (@JvmInline value class)",e=>{if(equals(e.type,"binary_expression")){const t=List_tryFind(e=>!!equals(e.type,"==")||equals(e.type,"==="),nodeChildren(e));if(null==t)return List_empty();{const n=Option_value(t),r=List_filter(e=>e.id!==n.id,nodeChildren(e));let o,i,s;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),s=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,s)):List_empty()}}return List_empty()},e=>List_empty(),e=>List_empty(),List_singleton("index_expression"),e=>List_exists(e=>equals(e.type,"interpolation"),nodeChildren(e)),e=>{let t;const n=nodeParent(e);let r,o;if(null!=n?(t=Option_value(n),equals(t.type,"function_value_parameters")?(r=0,o=Option_value(n)):r=1):r=1,0===r){const t=nodeChildren(o),n=List_tryFindIndex(t=>t.id===e.id,t);let r,i;if(null!=n&&n>=2?(r=0,i=n):r=1,0===r){const e=List_tryItem(i-1,t),n=List_tryItem(i-2,t);let r,o,s;return null!=e&&null!=n?(r=0,o=Option_value(e),s=Option_value(n)):r=1,0===r&&equals(o.type,"=")&&equals(s.type,"parameter")}return!1}return!1},e=>{if(equals(e.type,"identifier")){const t=e.text;return"true"===t||"false"===t}return!1},e=>{let t,n,r;const o=nodeParent(e);let i,s;if(null!=o?(r=Option_value(o),equals(r.type,"value_argument")?(i=0,s=Option_value(o)):i=1):i=1,0===i){const r=nodeParent(s);let o,i;if(null!=r?(n=Option_value(r),equals(n.type,"value_arguments")?(o=0,i=Option_value(r)):o=1):o=1,0===o){const n=nodeParent(i);let r,o;if(null!=n?(t=Option_value(n),equals(t.type,"call_expression")?(r=0,o=Option_value(n)):r=1):r=1,0===r){const t=List_tryItem(0,nodeChildren(s));return null!=t&&Option_value(t).id===e.id}return!1}return!1}return!1},e=>{const t=e.type;return equals(t,"property_declaration")?isConstPropertyDeclaration(e):equals(t,"assignment")&&isAnnotatedConstValMisparse(e)},e=>{let t;const n=List_tryFind(e=>equals(e.type,"qualified_identifier"),nodeChildren(e));let r,o;if(null!=n?(t=Option_value(n),""!==t.text?(r=0,o=Option_value(n)):r=1):r=1,0===r){const t=o.text;if(List_exists(e=>equals(e.type,"*"),nodeChildren(e)))return t;{const e=0|t.lastIndexOf(".");return-1===e?t:substring(t,0,e)}}return e.text},List_singleton("class_declaration"),e=>{let t;const n=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(e));return null!=n?(t=Option_value(n),t.text):void 0},e=>{const t=List_tryFind(e=>equals(e.type,"delegation_specifiers"),nodeChildren(e));return null==t?List_empty():List_choose(delegationSpecifierName,List_filter(e=>equals(e.type,"delegation_specifier"),nodeChildren(Option_value(t))))}),languages=Map_ofList(List_ofArray([["python",PYTHON],["fsharp",FSHARP],["typescript",TYPESCRIPT],["kotlin",KOTLIN]]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),extensionToLanguageId=Map_ofList(List_ofArray([[".py","python"],[".fs","fsharp"],[".fsx","fsharp"],[".fsi","fsharp"],[".ts","typescript"],[".kt","kotlin"],[".kts","kotlin"]]),{Compare:(e,t)=>0|comparePrimitives(e,t)});function Registry_tryFind(e){return Map_tryFind(e,languages)}function resolveLanguageForFile(e){let t,n;const r=0|e.lastIndexOf(".");return n=r<0?void 0:substring(e,r).toLowerCase(),t=null!=n?Map_tryFind(n,extensionToLanguageId):void 0,null!=t?Registry_tryFind(t):void 0}const external_node_path_namespaceObject=require("node:path"),external_node_fs_namespaceObject=require("node:fs");var Report_record_type,Report_int32_type,Report_string_type,Report_list_type,Report_class_type,Report_EnergyViolation_$reflection;class SeverityCounts extends Record{constructor(e,t,n){super(),this.Low=0|e,this.Medium=0|t,this.High=0|n}}function SeverityCounts_$reflection(){return Report_record_type("Energy.Core.Report.SeverityCounts",[],SeverityCounts,()=>[["Low",Report_int32_type],["Medium",Report_int32_type],["High",Report_int32_type]])}class FileResult extends Record{constructor(e,t){super(),this.FilePath=e,this.Violations=t}}function FileResult_$reflection(){return Report_record_type("Energy.Core.Report.FileResult",[],FileResult,()=>[["FilePath",Report_string_type],["Violations",Report_list_type(Report_EnergyViolation_$reflection())]])}class FileSummary extends Record{constructor(e,t,n,r){super(),this.FilePath=e,this.Score=0|t,this.Counts=n,this.ByType=r}}function FileSummary_$reflection(){return Report_record_type("Energy.Core.Report.FileSummary",[],FileSummary,()=>[["FilePath",Report_string_type],["Score",Report_int32_type],["Counts",SeverityCounts_$reflection()],["ByType",Report_class_type("Microsoft.FSharp.Collections.FSharpMap`2",[Report_string_type,Report_int32_type])]])}class AggregateSummary extends Record{constructor(e,t,n){super(),this.Files=e,this.TotalScore=0|t,this.TotalCounts=n}}function AggregateSummary_$reflection(){return Report_record_type("Energy.Core.Report.AggregateSummary",[],AggregateSummary,()=>[["Files",Report_list_type(FileSummary_$reflection())],["TotalScore",Report_int32_type],["TotalCounts",SeverityCounts_$reflection()]])}const emptyCounts=new SeverityCounts(0,0,0);function addViolation(e,t){switch(t.Severity.tag){case 1:return new SeverityCounts(e.Low,e.Medium+1,e.High);case 2:return new SeverityCounts(e.Low,e.Medium,e.High+1);default:return new SeverityCounts(e.Low+1,e.Medium,e.High)}}function score(e){return e.Low+4*e.Medium+9*e.High|0}function summarizeFile(e){const t=List_fold(addViolation,emptyCounts,e.Violations),n=List_fold((e,t)=>change(violationTypeName(t.Type),e=>1+defaultArg(e,0),e),Map_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}),e.Violations);return new FileSummary(e.FilePath,score(t),t,n)}function summarize(e){const t=List_map(summarizeFile,e),n=List_fold((e,t)=>new SeverityCounts(e.Low+t.Counts.Low,e.Medium+t.Counts.Medium,e.High+t.Counts.High),emptyCounts,t);return new AggregateSummary(t,List_sumBy(e=>0|e.Score,t,{GetZero:()=>0,Add:(e,t)=>e+t|0}),n)}function hasBlockingViolations(e){return e.Medium>0||e.High>0}function renderMarkdownReport(e){let t;const n=0|List_length(List_filter(e=>0===e.Score,e.Files)),r=0|List_length(e.Files),o=1===r?"":"s",i=List_map(e=>toText(printf("| %s | %d | %d | %d | %d |"))(e.FilePath)(e.Score)(e.Counts.High)(e.Counts.Medium)(e.Counts.Low),e.Files);return join("\n",List_append(List_ofArray(["# Energy State Report","",(t=r-n|0,toText(printf("**%d file%s scanned** — %d clean, %d with violations"))(r)(o)(n)(t)),"","| File | Score | High | Medium | Low |","| --- | --- | --- | --- | --- |"]),List_append(i,List_ofArray(["",toText(printf("**Total score: %d** (%d high, %d medium, %d low)"))(e.TotalScore)(e.TotalCounts.High)(e.TotalCounts.Medium)(e.TotalCounts.Low)]))))}const parserCache=new Map([]);function grammarPath(e){return(0,external_node_path_namespaceObject.join)((0,external_node_path_namespaceObject.join)(__dirname,".."),e)}function loadParser(e){const t=TaskBuilder_task();return t.Run(t.Delay(()=>{let n,r=defaultOf();return n=[tryGetValue(parserCache,e.Id,new FSharpRef(()=>r,e=>{r=e})),r],n[0]?t.Return(n[1]):t.Bind(web_tree_sitter.iX.init(),()=>t.Bind(web_tree_sitter.TM.load(grammarPath(e.GrammarPath)),n=>{const r=new web_tree_sitter.iX;return r.setLanguage(n),addToDict(parserCache,e.Id,r),t.Return(r)}))}))}function analyzeFile(e,t,n){const r=TaskBuilder_task();return r.Run(r.Delay(()=>{const o=resolveLanguageForFile(e);if(null!=o){const i=o;return r.Bind(loadParser(i),o=>{let s;return s=o.parse(t).rootNode,r.Return(analyzeSourceWith(n,t,s,i,e))})}return r.Return(List_empty())}))}function analyzeFiles(e,t){const n=TaskBuilder_task();return n.Run(n.Delay(()=>{if(List_isEmpty(e))return n.Return(List_empty());{const r=List_head(e);return n.Bind(analyzeFile(r,(0,external_node_fs_namespaceObject.readFileSync)(r,"utf8"),t),o=>n.Bind(analyzeFiles(List_tail(e),t),e=>n.Return(cons(new FileResult((0,external_node_path_namespaceObject.relative)(process.cwd(),r),o),e))))}}))}const esaignoreFileName=".esaignore";function loadIgnorePatterns(e){let t;const n=(0,external_node_path_namespaceObject.join)(e,esaignoreFileName);return(0,external_node_fs_namespaceObject.existsSync)(n)?List_ofArray(Array_map(e=>trimEnd(e,"/"),(t=Array_map(e=>e.trim(),String_split((0,external_node_fs_namespaceObject.readFileSync)(n,"utf8"),["\n"],void 0,0)),t.filter(e=>""!==e&&!e.startsWith("#"))))):List_empty()}function matchesLiteralPattern(e,t){return t.indexOf("/")>=0?e===t||e.startsWith(t+"/"):Array_contains(t,String_split(e,["/"],void 0,0),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})}function matchesBasenameGlob(e,t){return((e,n)=>{e:for(;;){const r=e,o=n;if(List_isEmpty(r))return o===t.length;if(0===o){if(t.startsWith(List_head(r))){e=List_tail(r),n=List_head(r).length;continue e}return!1}{const i=0|indexOf(t,List_head(r),4,o);if(i<0)return!1;e=List_tail(r),n=i+List_head(r).length;continue e}}})(List_ofArray(String_split(e,["*"],void 0,0)),0)}function isIgnored(e,t,n){if(List_isEmpty(n))return!1;{const r=String_replace((0,external_node_path_namespaceObject.relative)(t,e),external_node_path_namespaceObject.sep,"/"),o=(0,external_node_path_namespaceObject.basename)(e);return List_exists(e=>e.indexOf("*")>=0?matchesBasenameGlob(e,o):matchesLiteralPattern(r,e),n)}}var Scan_record_type,Scan_string_type,Scan_list_type;const ignoredDirectoryNames=Set_ofList(List_ofArray(["node_modules",".git","dist","out","build",".next","coverage",".vscode-test"]),{Compare:(e,t)=>0|comparePrimitives(e,t)});class IgnoreContext extends Record{constructor(e,t){super(),this.RootDir=e,this.Patterns=t}}function IgnoreContext_$reflection(){return Scan_record_type("Energy.Core.Scan.IgnoreContext",[],IgnoreContext,()=>[["RootDir",Scan_string_type],["Patterns",Scan_list_type(Scan_string_type)]])}function isPathIgnored(e,t){return isIgnored(e,t.RootDir,t.Patterns)}function walkDirectory(e,t,n){return fold((n,r)=>{const o=r.name,i=(0,external_node_path_namespaceObject.join)(e,o);return Set_contains(o,ignoredDirectoryNames)||isPathIgnored(i,t)?n:r.isDirectory()?walkDirectory(i,t,n):r.isFile()&&null!=resolveLanguageForFile(o)?cons(i,n):n},n,(0,external_node_fs_namespaceObject.readdirSync)(e,{withFileTypes:!0}))}function expandGlobLike(e,t){let n,r;const o=0|e.indexOf("*"),i=0|e.lastIndexOf(external_node_path_namespaceObject.sep[0],o),s=-1===i?".":substring(e,0,i),a=substring(e,e.lastIndexOf(".")),_=!a.startsWith(".")||a.indexOf("*")>=0?void 0:a;if((0,external_node_fs_namespaceObject.existsSync)(s)&&(0,external_node_fs_namespaceObject.statSync)(s).isDirectory()){const e=walkDirectory(s,t,List_empty());return defaultArg((n=_,null!=n?(r=n,List_filter(e=>endsWith(e,r,5),e)):void 0),e)}return List_empty()}function resolveSupportedFiles(e,t){const n=new IgnoreContext(t,loadIgnorePatterns(t));return List_sort(Set_toList(Set_ofList(List_map(external_node_path_namespaceObject.resolve,List_collect(e=>{if(e.indexOf("*")>=0)return expandGlobLike(e,n);if((0,external_node_fs_namespaceObject.existsSync)(e)){const t=e,r=(0,external_node_fs_namespaceObject.statSync)(t);return r.isDirectory()?isPathIgnored(t,n)?List_empty():walkDirectory(t,n,List_empty()):r.isFile()&&null!=resolveLanguageForFile(t)&&!isPathIgnored(t,n)?List_singleton(t):List_empty()}return List_empty()},e)),{Compare:(e,t)=>0|comparePrimitives(e,t)})),{Compare:(e,t)=>0|comparePrimitives(e,t)})}var ReportHuman_union_type;class RiskLevel extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["NoRisk","LowRisk","MediumRisk","HighRisk","Critical"]}static NoRisk=new RiskLevel(0,[]);static LowRisk=new RiskLevel(1,[]);static MediumRisk=new RiskLevel(2,[]);static HighRisk=new RiskLevel(3,[]);static Critical=new RiskLevel(4,[])}function RiskLevel_$reflection(){return ReportHuman_union_type("Energy.Core.ReportHuman.RiskLevel",[],RiskLevel,()=>[[],[],[],[],[]])}const complexityCurve=List_ofArray([[0,0],[10,3.9],[20,6.9],[50,8.9],[100,10]]);function complexityToScore(e){if(e<=0)return 0;if(e>=100)return 10;{const t=List_find(t=>e<=t[1][0],List_pairwise(complexityCurve)),n=t[0],r=t[1],o=0|n[0],i=n[1];return round(i+(e-o)/(r[0]-o)*(r[1]-i),1)}}function classifyScore(e){return e<=0?RiskLevel.NoRisk:e<4?RiskLevel.LowRisk:e<7?RiskLevel.MediumRisk:e<9?RiskLevel.HighRisk:RiskLevel.Critical}function classifyComplexityScore(e){return classifyScore(complexityToScore(e))}function riskLabel(e){switch(e.tag){case 1:return"Low";case 2:return"Medium";case 3:return"High";case 4:return"Critical";default:return"None"}}function riskDescription(e){switch(e.tag){case 1:return"simple, easy to test exhaustively";case 2:return"getting harder to cover with tests";case 3:return"complex, testing all paths is impractical";case 4:return"effectively untestable";default:return"no violations found"}}function categoryLabel(e){switch(e.tag){case 1:return"Cyclomatic complexity";case 2:return"Cognitive complexity";case 3:return"Naming";case 4:return"File coherence";case 5:return"Magic values";case 6:return"Parameter count";case 7:return"Inversion opportunities";case 8:return"Primitive obsession";case 9:return"Match opportunities";case 10:return"Logical operator as control flow";case 11:return"Opaque boolean literals";case 12:return"Suppression directives";default:return"Nesting depth"}}function categoryBlurb(e){switch(e.tag){case 3:return"naming that obscures intent";case 4:return"the file mixes too many responsibilities (too many functions/imports, or too many large functions) to read as one coherent unit";case 5:return"unnamed literals standing in for a value that deserves a name";case 6:return"a function with enough parameters that call sites are easy to get wrong";case 7:return"validation/guard logic that would read more clearly as early returns";case 8:return"adjacent same-typed values a caller could silently swap without the compiler noticing";case 9:return"an if/elif chain on one variable that would read more clearly as a match/switch";case 10:return"&&/|| used to hide an if statement";case 11:return"a bare true/false at a call site that only makes sense by reading the callee";case 12:return"an esa-ignore comment that names an unknown violation type, or no longer matches any violation";case 1:case 2:return;default:return"control-flow blocks nested deep enough that a reader has to hold several levels of context in mind at once"}}function extractComplexityValue(e){switch(e.Type.tag){case 1:case 2:{const t=match(/complexity: (\d+)/giu,e.Message);return null!=t?Int32_parse(t[1]||"",511,!1,32):void 0}default:return}}function describeComplexityFindings(e,t){let n,r;const o=List_sortDescending(List_choose(extractComplexityValue,t),{Compare:(e,t)=>0|comparePrimitives(e,t)});if(!List_isEmpty(o)){const t=0|List_head(o),i=complexityToScore(t),s=classifyScore(i);let a;if(1===List_length(o))a=toText(printf("1 function scores %d"))(t);else{const e=0|List_length(o),n=join(", ",List_map(int32ToString,o));a=toText(printf("%d functions score %s (worst: %d)"))(e)(n)(t)}return n=riskLabel(s),r=riskDescription(s),toText(printf("- **%s**: %s — score %.1f (%s): %s."))(e)(a)(i)(n)(r)}}function describeCategoryFindings(e,t){let n,r,o;switch(e.tag){case 1:case 2:return describeComplexityFindings(categoryLabel(e),t);default:{const i=List_fold((e,t)=>{switch(t.Severity.tag){case 1:return List_append(e,List_singleton("medium"));case 0:return List_append(e,List_singleton("low"));default:return List_append(e,List_singleton("high"))}},List_empty(),t),s=join(", ",List_choose(e=>{const t=0|List_length(List_filter(t=>e===t,i));return 0===t?void 0:toText(printf("%d %s"))(t)(e)},List_ofArray(["high","medium","low"]))),a=defaultArg((n=categoryBlurb(e),null!=n?" — "+n:void 0),""),_=1===List_length(t)?"":"s";return r=categoryLabel(e),o=0|List_length(t),toText(printf("- **%s**: %d finding%s (%s)%s."))(r)(o)(_)(s)(a)}}}function fileScore(e){const t=List_sortDescending(List_choose(extractComplexityValue,e),{Compare:(e,t)=>0|comparePrimitives(e,t)});return List_isEmpty(t)?List_exists(e=>equals(e.Severity,Severity.High),e)?7.5:List_exists(e=>equals(e.Severity,Severity.Medium),e)?5:List_isEmpty(e)?0:2:complexityToScore(List_head(t))}function renderFileSection(e){let t;const n=fileScore(e.Violations),r=List_choose(e=>describeCategoryFindings(e[0],e[1]),List_groupBy(e=>e.Type,e.Violations,{Equals:equals,GetHashCode:e=>0|safeHash(e)}));return join("\n",List_append(List_ofArray([(t=riskLabel(classifyScore(n)),toText(printf("## %s — %s (score %.1f)"))(e.FilePath)(t)(n)),""]),r))}const scoreLegend=join("\n",["## Score legend","","_Risk is reported on a 0.0–10.0 complexity score, sorted into the same None/Low/Medium/High/Critical levels already used elsewhere in this tool._","","| Score | Risk | Roughly | Cyclomatic/cognitive complexity |","| --- | --- | --- | --- |","| 0.0 | None | No violations found | — |","| 0.1–3.9 | Low | Simple, easy to test exhaustively | 1–10 |","| 4.0–6.9 | Medium | Getting harder to cover with tests | 11–20 |","| 7.0–8.9 | High | Complex, testing all paths is impractical | 21–50 |","| 9.0–10.0 | Critical | Effectively untestable | 50+ |","","_Cyclomatic and cognitive complexity numbers are converted to the score using the ranges above. Other detectors flag a pattern rather than a path count, so a file with no complexity violations of its own instead gets a fixed score from its worst other finding (Low 2.0 / Medium 5.0 / High 7.5)._"]);function renderHumanReport(e){let t,n,r,o,i,s,a;const _=List_sortByDescending(e=>fileScore(e.Violations),List_filter(e=>!List_isEmpty(e.Violations),e),{Compare:(e,t)=>0|comparePrimitives(e,t)}),u=List_length(e)-List_length(_)|0,l=List_map(e=>[e.FilePath,fileScore(e.Violations)],e),c=List_fold((e,t)=>t[1]>e[1]?t:e,["",0],l),d=Map_ofList(List_countBy(e=>classifyScore(e[1]),l,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),{Compare:(e,t)=>0|compare(e,t)}),p=List_fold((e,t)=>{switch(t.Severity.tag){case 1:return new SeverityCounts(e.Low,e.Medium+1,e.High);case 2:return new SeverityCounts(e.Low,e.Medium,e.High+1);default:return new SeverityCounts(e.Low+1,e.Medium,e.High)}},emptyCounts,List_collect(e=>e.Violations,e));let m;if(c[1]>0){const e=riskLabel(classifyScore(c[1])),t=riskDescription(classifyScore(c[1]));m=toText(printf("**Repo score: %.1f (%s)** — driven by the worst file in the scan, `%s` (%s)."))(c[1])(e)(c[0])(t)}else m="**Repo score: 0.0 (None)** — no violations were found anywhere in the scan.";const f=1===List_length(e)?"":"s",y=p.Low+p.Medium+p.High|0,h=1===y?"":"s";return join("\n",List_append(List_ofArray(["# Energy State Report","",scoreLegend,"",(t=0|List_length(e),n=0|List_length(_),toText(printf("**%d file%s scanned** — %d clean, %d flagged"))(t)(f)(u)(n)),""]),List_append(List_collect(e=>List_ofArray([renderFileSection(e),""]),_),List_ofArray(["## Total evaluation","",m,"","This is the _maximum_ file score, not an average across files — see the note at the top of this report for why an average would hide the file most worth fixing.","","| Risk | Files |","| --- | --- |",(r=0|defaultArg(Map_tryFind(RiskLevel.NoRisk,d),0),toText(printf("| None | %d |"))(r)),(o=0|defaultArg(Map_tryFind(RiskLevel.LowRisk,d),0),toText(printf("| Low | %d |"))(o)),(i=0|defaultArg(Map_tryFind(RiskLevel.MediumRisk,d),0),toText(printf("| Medium | %d |"))(i)),(s=0|defaultArg(Map_tryFind(RiskLevel.HighRisk,d),0),toText(printf("| High | %d |"))(s)),(a=0|defaultArg(Map_tryFind(RiskLevel.Critical,d),0),toText(printf("| Critical | %d |"))(a)),"",toText(printf("**%d total finding%s** (%d high, %d medium, %d low) — breadth of issues across the scan, independent of peak severity."))(y)(h)(p.High)(p.Medium)(p.Low)]))))}const external_node_child_process_namespaceObject=require("node:child_process");var ReportDiff_union_type,ReportDiff_record_type,ReportDiff_string_type,ReportDiff_option_type,ReportDiff_int32_type,Cli_record_type,Cli_list_type,Cli_string_type,Cli_option_type,tuple_type,Cli_int32_type,Cli_bool_type;class DiffStatus extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["New","Improved","Worsened","Unchanged"]}static New=new DiffStatus(0,[]);static Improved=new DiffStatus(1,[]);static Worsened=new DiffStatus(2,[]);static Unchanged=new DiffStatus(3,[])}function DiffStatus_$reflection(){return ReportDiff_union_type("Energy.Core.ReportDiff.DiffStatus",[],DiffStatus,()=>[[],[],[],[]])}class DiffEntry extends Record{constructor(e,t,n,r,o){super(),this.FilePath=e,this.BaseScore=t,this.HeadScore=0|n,this.Delta=0|r,this.Status=o}}function DiffEntry_$reflection(){return ReportDiff_record_type("Energy.Core.ReportDiff.DiffEntry",[],DiffEntry,()=>[["FilePath",ReportDiff_string_type],["BaseScore",ReportDiff_option_type(ReportDiff_int32_type)],["HeadScore",ReportDiff_int32_type],["Delta",ReportDiff_int32_type],["Status",DiffStatus_$reflection()]])}function diffSummaries(e,t){const n=Map_ofList(List_map(e=>[e.FilePath,e.Score],e),{Compare:(e,t)=>0|comparePrimitives(e,t)});return List_map(e=>{let t;const r=Map_tryFind(e.FilePath,n),o=0|defaultArg((t=r,null!=t?e.Score-t:void 0),e.Score);return new DiffEntry(e.FilePath,r,e.Score,o,null!=r?o<0?DiffStatus.Improved:o>0?DiffStatus.Worsened:DiffStatus.Unchanged:DiffStatus.New)},t)}function icon(e){switch(e.tag){case 1:return"🟢";case 2:return"🔴";case 3:return"⚪";default:return"🆕"}}function ReportDiff_name(e){switch(e.tag){case 1:return"improved";case 2:return"worsened";case 3:return"unchanged";default:return"new"}}function renderDiffMarkdown(e,t){let n;const r=List_map(e=>{let t;const n=defaultArg((t=e.BaseScore,null!=t?int32ToString(t):void 0),"—"),r=null==e.BaseScore?"—":e.Delta>0?"+"+int32ToString(e.Delta):int32ToString(e.Delta),o=icon(e.Status),i=ReportDiff_name(e.Status);return toText(printf("| %s | %s | %d | %s | %s %s |"))(e.FilePath)(n)(e.HeadScore)(r)(o)(i)},e),o=0|List_length(List_filter(e=>equals(e.Status,DiffStatus.Worsened),e)),i=0|List_length(List_filter(e=>equals(e.Status,DiffStatus.Improved),e)),s=0|List_length(List_filter(e=>equals(e.Status,DiffStatus.New),e)),a=1===List_length(e)?"":"s";return join("\n",List_append(List_ofArray([toText(printf("# Energy State Diff vs `%s`"))(t),"","| File | Base | Head | Δ | Status |","| --- | --- | --- | --- | --- |"]),List_append(r,List_ofArray(["",(n=0|List_length(e),toText(printf("_%d file%s changed, %d worsened, %d improved, %d new._"))(n)(a)(o)(i)(s))]))))}function printUsage(){error("Usage: energy-state-cli <file.py|.fs|.fsx|.ts> [thresholds...]"),error(" energy-state-cli <path...> [--report json|md|human] [thresholds...] (scan a directory/subtree)"),error(" energy-state-cli --base-ref <ref> [<path...>] [--report json|md] [thresholds...] (diff PR head against a base ref)"),error("Thresholds: --medium-nesting N --high-nesting N --medium-cyclomatic N --high-cyclomatic N --medium-cognitive N --high-cognitive N"),error("Flags: --include-test-files (also flag magic numbers and magic strings in test files)")}function violationJson(e){const t=List_toArray(List_map(e=>({line:e.Line,weight:e.Weight}),e.Hotspots));return{line:e.Line,column:e.Column,type:violationTypeName(e.Type),severity:severityName(e.Severity),message:e.Message,hotspots:t}}function summaryJson(e){return{files:List_toArray(List_map(e=>({filePath:e.FilePath,score:e.Score,counts:{low:e.Counts.Low,medium:e.Counts.Medium,high:e.Counts.High},byType:createObj(List_map(e=>[e[0],e[1]],Map_toList(e.ByType)))}),e.Files)),totalScore:e.TotalScore,totalCounts:{low:e.TotalCounts.Low,medium:e.TotalCounts.Medium,high:e.TotalCounts.High}}}function diffJson(e){return List_toArray(List_map(e=>{let t;return{filePath:e.FilePath,baseScore:e.BaseScore,headScore:e.HeadScore,delta:e.Delta,status:(t=e.Status,1===t.tag?"improved":2===t.tag?"worsened":3===t.tag?"unchanged":"new")}},e))}function runLegacySingleFile(e,t){const n=TaskBuilder_task();return n.Run(n.Delay(()=>null==resolveLanguageForFile(e)?(error("Unsupported file type: "+e),printUsage(),process.exit(2),n.Zero()):n.Bind(analyzeFile(e,(0,external_node_fs_namespaceObject.readFileSync)(e,"utf8"),t),e=>{const t=e;return output(JSON.stringify(List_toArray(List_map(violationJson,t)),null,2)),process.exit(List_exists(e=>!!equals(e.Severity,Severity.Medium)||equals(e.Severity,Severity.High),t)?1:0),n.Zero()})))}function runScan(e,t,n){const r=TaskBuilder_task();return r.Run(r.Delay(()=>r.Bind(analyzeFiles(resolveSupportedFiles(e,process.cwd()),t),e=>{const t=e,o=summarize(t);return output("human"===n?renderHumanReport(t):"md"===n?renderMarkdownReport(o):JSON.stringify(summaryJson(o),null,2)),process.exit(hasBlockingViolations(o.TotalCounts)?1:0),r.Zero()})))}function changedFilesFromGit(e){let t;return List_ofArray((t=Array_map(e=>e.trim(),String_split((0,external_node_child_process_namespaceObject.execFileSync)("git",["diff","--name-only","--diff-filter=d",e+"...HEAD"],{encoding:"utf8"}),["\n"],void 0,0)),t.filter(e=>""!==e)))}function readAtRef(e,t){try{return(0,external_node_child_process_namespaceObject.execFileSync)("git",["show",e+":"+t],{encoding:"utf8",stdio:["ignore","pipe","ignore"]})}catch(n){return void error("energy-state-cli: could not read "+t+" at "+e+" (new file or rename) — treating as new")}}function runDiff(e,t,n,r){const o=TaskBuilder_task();return o.Run(o.Delay(()=>{const i=process.cwd(),s=loadIgnorePatterns(i),a=List_filter(e=>!isIgnored((0,external_node_path_namespaceObject.resolve)(e),i,s),List_filter(e=>null!=resolveLanguageForFile(e)&&(0,external_node_fs_namespaceObject.existsSync)(e),List_isEmpty(t)?changedFilesFromGit(e):t)),_=(t,r,o)=>{const i=TaskBuilder_task();return i.Run(i.Delay(()=>{if(List_isEmpty(t))return i.Return([List_reverse(r),List_reverse(o)]);{const s=List_tail(t),a=List_head(t);return i.Bind(analyzeFile(a,(0,external_node_fs_namespaceObject.readFileSync)(a,"utf8"),n),t=>{const u=summarizeFile(new FileResult(a,t)),l=readAtRef(e,a);if(null!=l){const e=l;return i.Bind(analyzeFile(a,e,n),e=>{const t=summarizeFile(new FileResult(a,e));return i.ReturnFrom(_(s,cons(t,r),cons(u,o)))})}return i.ReturnFrom(_(s,r,cons(u,o)))})}}))};return o.Bind(_(a,List_empty(),List_empty()),t=>{const n=diffSummaries(t[0],t[1]);return output("md"===r?renderDiffMarkdown(n,e):JSON.stringify(diffJson(n),null,2)),process.exit(List_exists(e=>equals(e.Status,DiffStatus.Worsened),n)?1:0),o.Zero()})}))}class ParsedArguments extends Record{constructor(e,t,n,r,o,i,s){super(),this.Paths=e,this.BaseRef=t,this.Report=n,this.Nesting=r,this.Cyclomatic=o,this.Cognitive=i,this.IncludeTestFiles=s}}function ParsedArguments_$reflection(){return Cli_record_type("Energy.Cli.ParsedArguments",[],ParsedArguments,()=>[["Paths",Cli_list_type(Cli_string_type)],["BaseRef",Cli_option_type(Cli_string_type)],["Report",Cli_option_type(Cli_string_type)],["Nesting",tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["Cyclomatic",tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["Cognitive",tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["IncludeTestFiles",Cli_bool_type]])}const valueFlags=Set_ofList(List_ofArray(["base-ref","report","medium-nesting","high-nesting","medium-cyclomatic","high-cyclomatic","medium-cognitive","high-cognitive"]),{Compare:(e,t)=>0|comparePrimitives(e,t)});function parseValues(e){const t=Set_ofList(List_singleton("include-test-files"),{Compare:(e,t)=>0|comparePrimitives(e,t)});return((n,r,o)=>{e:for(;;){const i=n,s=r,a=o;if(i>=e.length)return[List_reverse(s),a];{const _=item(i,e);if(_.startsWith("--")&&FSharpSet__Contains(t,substring(_,2))){n=i+1,r=s,o=Map_add(substring(_,2),"true",a);continue e}if(_.startsWith("--")&&FSharpSet__Contains(valueFlags,substring(_,2))&&i+1<e.length){n=i+2,r=s,o=Map_add(substring(_,2),item(i+1,e),a);continue e}if(_.startsWith("--")){n=i+1,r=s,o=a;continue e}n=i+1,r=cons(_,s),o=a;continue e}}})(0,List_empty(),Map_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}))}function asNumber(e,t){const n=Map_tryFind(t,e);if(null!=n){let e,t=0;return e=[Int32_tryParse(n,511,!1,32,new FSharpRef(()=>0|t,e=>{t=0|e})),t],e[0]?e[1]:void 0}}function parseArguments(e){const t=parseValues(e),n=t[1];return new ParsedArguments(t[0],Map_tryFind("base-ref",n),Map_tryFind("report",n),[asNumber(n,"medium-nesting"),asNumber(n,"high-nesting")],[asNumber(n,"medium-cyclomatic"),asNumber(n,"high-cyclomatic")],[asNumber(n,"medium-cognitive"),asNumber(n,"high-cognitive")],containsKey("include-test-files",n))}function thresholdOverride(e,t,n,r,o){let i;if(i=null==r&&null==o?0:1,0!==i)return some(n(defaultArg(r,e),defaultArg(o,t)))}function buildThresholds(e){let t,n,r;const o=new MagicNumberOptions(defaultOptions.Enabled,defaultOptions.Allowlist,e.IncludeTestFiles),i=new MagicStringOptions(MagicString_defaultOptions.Enabled,MagicString_defaultOptions.MinDuplicates,MagicString_defaultOptions.Allowlist,e.IncludeTestFiles);return new AnalyzeThresholds((t=e.Nesting,thresholdOverride(defaultNestingThresholds.MediumThreshold,defaultNestingThresholds.HighThreshold,(e,t)=>new NestingThresholds(e,t),t[0],t[1])),(n=e.Cyclomatic,thresholdOverride(defaultCyclomaticThresholds.MediumThreshold,defaultCyclomaticThresholds.HighThreshold,(e,t)=>new CyclomaticThresholds(e,t),n[0],n[1])),(r=e.Cognitive,thresholdOverride(defaultCognitiveThresholds.MediumThreshold,defaultCognitiveThresholds.HighThreshold,(e,t)=>new CognitiveThresholds(e,t),r[0],r[1])),Analyze_defaultThresholds.Coherence,Analyze_defaultThresholds.MatchOpportunity,o,i)}function runCli(){const e=TaskBuilder_task();return e.Run(e.Delay(()=>e.TryWith(e.Delay(()=>{let t;const n=parseArguments(process.argv.slice(2)),r=buildThresholds(n),o=defaultArg(n.Report,null!=n.BaseRef||1!==List_length(n.Paths)?"md":"json"),i=n.BaseRef,s=n.Paths;let a,_,u;switch(null==i?List_isEmpty(s)?a=1:List_isEmpty(List_tail(s))?(t=List_head(s),(0,external_node_fs_namespaceObject.existsSync)(t)&&(0,external_node_fs_namespaceObject.statSync)(t).isFile()&&null==n.Report?(a=2,u=List_head(s)):a=3):a=3:(a=0,_=i),a){case 0:return e.Bind(runDiff(_,n.Paths,r,o),()=>e.Zero());case 1:return printUsage(),process.exit(2),e.Zero();case 2:return e.Bind(runLegacySingleFile(u,r),()=>e.Zero());default:return e.Bind(runScan(n.Paths,r,o),()=>e.Zero())}}),t=>(error("energy-state-cli failed: "+Types_toString(t)),process.exit(1),e.Zero()))))}"object"==typeof process&&process.argv.slice(2),runCli(),module.exports=__webpack_exports__})();