energy-state-analyzer 0.23.2 → 0.23.4
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/CHANGELOG.md +17 -1
- package/dist/cli.js +1 -1
- package/docs/agent-integration.md +6 -3
- package/docs/cli.md +1 -1
- package/docs/detectors/file-coherence.md +2 -0
- package/package.json +1 -4
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
(()=>{"use strict";var __webpack_modules__={747(e,t,n){e.exports=n.p+"a5f4afce3ed7382a77b6.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}function newFinalizer(e){try{return new FinalizationRegistry(e)}catch(e){return void console.error("Unsupported FinalizationRegistry:",e)}}__name(assertInternal,"assertInternal"),__name(isPoint,"isPoint"),__name(setModule,"setModule"),__name(newFinalizer,"newFinalizer");var finalizer=newFinalizer(e=>{C._ts_lookahead_iterator_delete(e)}),LookaheadIterator=class{static{__name(this,"LookaheadIterator")}0=0;language;positioned=!1;constructor(e,t,n){assertInternal(e),this[0]=t,this.language=n,finalizer?.register(this,t,this)}get currentTypeId(){return this.positioned?C._ts_lookahead_iterator_current_symbol(this[0]):null}get currentType(){const e=this.currentTypeId;return null===e?null:this.language.types[e]??C.UTF8ToString(C._ts_language_symbol_name(this.language[0],e))}delete(){finalizer?.unregister(this),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,this.positioned=!1,!0)}resetState(e){return!!C._ts_lookahead_iterator_reset_state(this[0],e)&&(this.positioned=!1,!0)}[Symbol.iterator](){return{next:__name(()=>{this.positioned=Boolean(C._ts_lookahead_iterator_next(this[0]));const e=this.currentType;return null===e?{done:!0,value:""}:{done:!1,value:e}},"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 finalizer2=newFinalizer(e=>{C._ts_tree_delete(e)}),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,finalizer2?.register(this,t,this)}copy(){const t=C._ts_tree_copy(this[0]);return new e(INTERNAL,t,this.language,this.textCallback)}delete(){finalizer2?.unregister(this),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}},finalizer3=newFinalizer(e=>{C._ts_tree_cursor_delete_wasm(e)}),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),finalizer3?.register(this,this.tree[0],this)}copy(){const t=new e(INTERNAL,this.tree);return C._ts_tree_cursor_copy_wasm(this.tree[0]),unmarshalTreeCursor(t),t}delete(){finalizer3?.unregister(this),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 a=C.getValue(TRANSFER_BUFFER,"i32"),s=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),l=new Array(a);if(a>0){let e=s;for(let t=0;t<a;t++)l[t]=unmarshalNode(this.tree,e),e+=SIZE_OF_NODE}return C._free(s),C._free(i),l}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,a=o.length;i<a;i++){const a=C.getValue(n,"i32"),s=unmarshalNode(t,n+=SIZE_OF_INT);n+=SIZE_OF_NODE,o[i]={patternIndex:r,name:e.captureNames[a],node:s}}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 a=C.getValue(t,"i32");return new Node(INTERNAL,{id:n,tree:e,startIndex:r,startPosition:{row:o,column:i},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 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});return e.loadFromWasmExports(r,{sync:!1})}static loadFromWasmExports(t,{sync:n}){const r=Object.keys(t),o=r.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(r,null,2)}`),new Error(`Language.${n?"loadSync":"load"} failed: no language function found in Wasm file`);const i=t[o]();return new e(INTERNAL,i)}static loadSync(t){const n=C.loadWebAssemblyModule(t,{loadAsync:!1});return e.loadFromWasmExports(n,{sync:!0})}};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 a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var l=63&e[t++];if((a=224==(240&a)?(15&a)<<12|s<<6|l:(7&a)<<18|s<<12|l<<6|63&e[t++])<65536)i+=String.fromCharCode(a);else{var _=a-65536;i+=String.fromCharCode(55296|_>>10,56320|1023&_)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}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 a(){for(var e=o(),t=[];e--;)t.push(i());return t}function s(e,t){if(e)throw new Error(t)}if(__name(r,"getU8"),__name(o,"getLEB"),__name(i,"getString"),__name(a,"getStringList"),__name(s,"failIf"),e instanceof WebAssembly.Module){var l=WebAssembly.Module.customSections(e,"dylink.0");s(0===l.length,"need dylink section"),n=(e=new Uint8Array(l[0])).length}else{var _=new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer);s(!(1836278016==_[0]||6386541==_[0]),"need to see wasm magic number"),s(0!==e[8],"need the dylink section to be first"),t=9;var u=o();n=t+u,s("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=a();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=a():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=82240,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 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?i().then(o=>loadWebAssemblyModule(o,t,e,n,r)):loadWebAssemblyModule(i(),t,e,n,r)}function s(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(a,"getExports"),__name(s,"moduleLoaded"),t.loadAsync?a().then(e=>(s(e),!0)):(s(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=82240,___stack_low=16704,___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},82240),___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 a=LE_HEAP_LOAD_U32(4*(t>>2)),s=LE_HEAP_LOAD_U32(4*(t+4>>2));t+=8;for(var l=0;l<s;l++)printChar(e,HEAPU8[a+l]);o+=s}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,a=0;a<e.length;++a){var s=e.codePointAt(a);if(s<=127){if(n>=i)break;t[n++]=s}else if(s<=2047){if(n+1>=i)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=i)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=i)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s,a++}}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 a=e.charCodeAt(i);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_copy,_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,_iswpunct,_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_copy=_ts_query_copy=e.ts_query_copy,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._iswpunct=_iswpunct=e.iswpunct,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 finalizer4=newFinalizer(e=>{C._ts_parser_delete(e[0]),C._free(e[1])}),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(),finalizer4?.register(this,[this[0],this[1]],this)}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(){finalizer4?.unregister(this),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 a=new Tree(INTERNAL,i,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,o){super(e.formatMessage(t,n)),this.kind=t,this.info=n,this.index=r,this.length=o,this.name="QueryError"}kind;info;index;length;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,a=e[2].name;r[t].push(e=>{const t=[],r=[];for(const o of e)o.name===n&&t.push(o.node),o.name===a&&r.push(o.node);const s=__name((e,t,n)=>n?e.text===t.text:e.text!==t.text,"compare");return i?t.every(e=>r.some(t=>s(e,t,o))):t.some(e=>r.some(t=>s(e,t,o)))})}else{const n=e[1].name,a=e[2].value,s=__name(e=>e.text===a,"matches"),l=__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=o?s:l;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-"),a=e[1].name,s=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?s.test(e):!s.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,a=e.slice(2);if(!a.every(isStringStep))throw new Error(`Arguments to \`#${n}\` predicate must be strings.".`);const s=a.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=>s.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,a,s,l,_,u){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,a);break;case"any-not-match?":case"not-match?":case"any-match?":case"match?":parseMatchPredicate(i,e,t,a);break;case"not-any-of?":case"any-of?":parseAnyOfPredicate(i,e,t,a);break;case"is?":case"is-not?":parseIsPredicate(i,e,t,_,u);break;case"set!":parseSetDirective(i,e,l);break;default:s[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 finalizer5=newFinalizer(e=>{C._ts_query_delete(e)}),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],a=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:a},o,a.length);case QueryErrorKind.PatternStructure:throw new QueryError(e,{suffix:`${o}: '${i}'...`},o,0)}}const i=C._ts_query_string_count(o),a=C._ts_query_capture_count(o),s=C._ts_query_pattern_count(o),l=new Array(a),_=new Array(s),u=new Array(i);for(let e=0;e<a;e++){const t=C._ts_query_capture_name_for_id(o,e,TRANSFER_BUFFER),n=C.getValue(TRANSFER_BUFFER,"i32");l[e]=C.UTF8ToString(t,n)}for(let e=0;e<s;e++){const t=new Array(a);for(let n=0;n<a;n++){const r=C._ts_query_capture_quantifier_for_id(o,e,n);t[n]=r}_[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");u[e]=C.UTF8ToString(t,n)}const c=new Array(s),d=new Array(s),p=new Array(s),m=new Array(s),f=new Array(s);for(let e=0;e<s;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,u,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=l,this.captureQuantifiers=_,this.textPredicates=f,this.predicates=m,this.setProperties=c,this.assertedProperties=d,this.refutedProperties=p,this.exceededMatchLimit=!1,finalizer5?.register(this,o,this)}delete(){finalizer5?.unregister(this),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,a=t.startContainingPosition??ZERO_POINT,s=t.endContainingPosition??ZERO_POINT,l=t.startContainingIndex??0,_=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!==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!==_&&l>_)throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");if(s!==ZERO_POINT&&(a.row>s.row||a.row===s.row&&a.column>s.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,a.row,a.column,s.row,s.column,l,_,u,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,a=t.startContainingPosition??ZERO_POINT,s=t.endContainingPosition??ZERO_POINT,l=t.startContainingIndex??0,_=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!==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!==_&&l>_)throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");if(s!==ZERO_POINT&&(a.row>s.row||a.row===s.row&&a.column>s.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,a.row,a.column,s.row,s.column,l,_,u,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 a=2&r&&n;("object"==typeof a||"function"==typeof a)&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).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]()))}class ArrayEnumerator{constructor(e){this.current=defaultOf(),this.index=-1,this.array=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.index;return e<this.array.length?(this.current=this.array[e],!0):(this.current=defaultOf(),!1)}"System.Collections.IEnumerator.Reset"(){this.index=-1,this.current=defaultOf()}Dispose(){}}function getEnumerator(e){return isEnumerable(e)?e.GetEnumerator():Array.isArray(e)?new ArrayEnumerator(e):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 combineHashCode(e,t){return(e<<5)+e^t}function combineHashCodes(e){let t=0;const n=e.length;for(let r=0;r<n;r++)t=combineHashCode(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){let t=0;for(let n=0;n<e.length;n++)t=combineHashCode(t,structuralHash(e[n]));return t}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:if(isHashable(e))return e.GetHashCode();if(isArrayLike(e))return arrayHash(e);if(e instanceof Date)return dateHash(e);if(Object.getPrototypeOf(e)?.constructor===Object){const t=Object.values(e);let n=0;for(let e=0;e<t.length;e++)n=combineHashCode(n,structuralHash(t[e]));return n}return 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 a=n[o];if(a!==r[o])return a<r[o]?-1:1;if(i=compare(e[a],t[a]),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,a=i>.5-1e-8&&i<.5+1e-8?o%2==0?o:o+1:Math.round(r);return t?a/n:a}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){Array.isArray(e)?e.length=0:ArrayBuffer.isView(e)||("function"==typeof e.clear?e.clear():"function"==typeof e["System.Collections.Generic.ICollection`1.Clear"]?e["System.Collections.Generic.ICollection`1.Clear"]():"function"==typeof e["System.Collections.IList.Clear"]&&e["System.Collections.IList.Clear"]())}ObjectRef.idMap=new WeakMap,ObjectRef.count=0;const curriedKey=Symbol("curried");function getCurried(e){return null==e?void 0:e[curriedKey]}function uncurry2(e){if(null==e)return null;const t=(t,n)=>e(t)(n);return t[curriedKey]=e,t}function curry2(e){return getCurried(e)??(t=>n=>e(t,n))}function uncurry3(e){if(null==e)return null;const t=(t,n,r)=>e(t)(n)(r);return t[curriedKey]=e,t}function curry3(e){return getCurried(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 t[curriedKey]=e,t}function curry4(e){return getCurried(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 t[curriedKey]=e,t}function curry5(e){return getCurried(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,a)=>e(t)(n)(r)(o)(i)(a);return t[curriedKey]=e,t}function curry6(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>e(t,n,r,o,i,a))}function uncurry7(e){if(null==e)return null;const t=(t,n,r,o,i,a,s)=>e(t)(n)(r)(o)(i)(a)(s);return t[curriedKey]=e,t}function curry7(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>e(t,n,r,o,i,a,s))}function uncurry8(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l)=>e(t)(n)(r)(o)(i)(a)(s)(l);return t[curriedKey]=e,t}function curry8(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>e(t,n,r,o,i,a,s,l))}function uncurry9(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_);return t[curriedKey]=e,t}function curry9(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>e(t,n,r,o,i,a,s,l,_))}function uncurry10(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u);return t[curriedKey]=e,t}function curry10(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>e(t,n,r,o,i,a,s,l,_,u))}function uncurry11(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c);return t[curriedKey]=e,t}function curry11(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>e(t,n,r,o,i,a,s,l,_,u,c))}function uncurry12(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d);return t[curriedKey]=e,t}function curry12(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>e(t,n,r,o,i,a,s,l,_,u,c,d))}function uncurry13(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p);return t[curriedKey]=e,t}function curry13(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>e(t,n,r,o,i,a,s,l,_,u,c,d,p))}function uncurry14(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m);return t[curriedKey]=e,t}function curry14(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m))}function uncurry15(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f);return t[curriedKey]=e,t}function curry15(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f))}function uncurry16(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f)(y);return t[curriedKey]=e,t}function curry16(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>y=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y))}function uncurry17(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f)(y)(h);return t[curriedKey]=e,t}function curry17(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>y=>h=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h))}function uncurry18(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f)(y)(h)(g);return t[curriedKey]=e,t}function curry18(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>y=>h=>g=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g))}function uncurry19(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g,S)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f)(y)(h)(g)(S);return t[curriedKey]=e,t}function curry19(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>y=>h=>g=>S=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g,S))}function uncurry20(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g,S,$)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f)(y)(h)(g)(S)($);return t[curriedKey]=e,t}function curry20(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>y=>h=>g=>S=>$=>e(t,n,r,o,i,a,s,l,_,u,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(){let e=combineHashCode(0,numberHash(this.tag));for(let t=0;t<this.fields.length;t++)e=combineHashCode(e,structuralHash(this.fields[t]));return 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){const t=Object.values(e);let n=0;for(let e=0;e<t.length;e++)n=combineHashCode(n,structuralHash(t[e]));return n}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 void 0===this.getter?this.value:this.getter()}set contents(e){void 0===this.setter?this.value=e:this.setter(e)}constructor(e,t){"function"==typeof t?(this.getter=e,this.setter=t,this.value=void 0):(this.getter=void 0,this.setter=void 0,this.value=e)}}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="The input list 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 a=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(a);break;case 2:i+=padWithZeros(day(a),2);break;case 3:i+=shortDays[dayOfWeek(a)];break;default:i+=longDays[dayOfWeek(a)]}break;case"f":if(o=parseRepeatToken(t,r,"f"),r+=o,o<=3){const e=10**(3-o);i+=padWithZeros(Math.floor(millisecond(a)/e),o)}else{if(!(o<=7))throw"Input string was not in a correct format.";i+=(""+millisecond(a)).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(a)/e);0!=t&&(i+=padWithZeros(t,o))}else{if(!(o<=7))throw"Input string was not in a correct format.";{const e=millisecond(a);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(a)%12||12}else{i+=padWithZeros(hour(a)%12||12,2)}break;case"H":o=parseRepeatToken(t,r,"H"),r+=o,i+=1===o?hour(a):padWithZeros(hour(a),2);break;case"K":if(o=parseRepeatToken(t,r,"K"),r+=o,1===o)switch(getKind(a)){case DateTimeKind.Utc:i+="Z";break;case DateTimeKind.Local:i+=dateOffsetToString(-6e4*a.getTimezoneOffset());case DateTimeKind.Unspecified:}break;case"m":o=parseRepeatToken(t,r,"m"),r+=o,i+=1===o?minute(a):padWithZeros(minute(a),2);break;case"M":switch(o=parseRepeatToken(t,r,"M"),r+=o,o){case 1:i+=month(a);break;case 2:i+=padWithZeros(month(a),2);break;case 3:i+=shortMonths[month(a)-1];break;default:i+=longMonths[month(a)-1]}break;case"s":o=parseRepeatToken(t,r,"s"),r+=o,i+=1===o?second(a):padWithZeros(second(a),2);break;case"t":o=parseRepeatToken(t,r,"t"),r+=o,i+=1===o?a.getHours()<12?"A":"P":a.getHours()<12?"AM":"PM";break;case"y":switch(o=parseRepeatToken(t,r,"y"),r+=o,o){case 1:i+=year(a)%100;break;case 2:i+=padWithZeros(year(a)%100,2);break;default:i+=padWithZeros(year(a),o)}break;case"z":o=parseRepeatToken(t,r,"z"),r+=o;let s="";switch(getKind(a)){case DateTimeKind.Utc:s="+00:00";break;case DateTimeKind.Local:s=dateOffsetToString(-6e4*a.getTimezoneOffset());break;case DateTimeKind.Unspecified:s=dateOffsetToString(-6e4*toLocalTime(a).getTimezoneOffset())}const l="-"===s[0]?"-":"+",_=parseInt(s.substring(1,3),10),u=parseInt(s.substring(4,6),10);switch(o){case 1:i+=`${l}${_}`;break;case 2:i+=`${l}${padWithZeros(_,2)}`;break;default:i+=`${l}${padWithZeros(_,2)}:${padWithZeros(u,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(a,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=DateTime(e.getTime()+(e.offset??0),DateTimeKind.Utc);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,a=0,s){const l=s===Date_DateTimeKind.Utc?new Date(Date.UTC(e,t-1,n,r,o,i,a)):new Date(e,t-1,n,r,o,i,a);e<=99&&(s===Date_DateTimeKind.Utc?l.setUTCFullYear(e,t-1,n):l.setFullYear(e,t-1,n));const _=l.getTime();if(isNaN(_))throw new Date_Exception("The parameters describe an unrepresentable Date.");return DateTime(_,s)}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,a=daysInMonth(i,r);return create(i,r,Math.min(a,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_26_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 divide(e,t){return"number"==typeof e?e/t:"bigint"==typeof e?Number(e)/t:e[symbol]().multiply(1/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 bigintToExponential(e,t){const n=e<0n?"-":"";let r=(e<0n?-e:e).toString();if(0n===e)return n+(t?"0."+"0".repeat(t):"0")+"e+0";t=t??r.length-1;let o=r.length-1;if(r.length>t+1){const e=r.charCodeAt(t+1)>=53;r=(BigInt(r.slice(0,t+1))+(e?1n:0n)).toString(),r.length>t+1&&(r=r.slice(0,t+1),o+=1)}else r=r.padEnd(t+1,"0");return n+(t>0?r[0]+"."+r.slice(1):r[0])+"e+"+o}function toExponential(e,t){return"number"==typeof e?e.toExponential(t):"bigint"==typeof e?bigintToExponential(e,t):e[symbol]().toExponential(t)}function toRadix(e,t){return"number"==typeof e?(Number(e)>>>0).toString(t):"bigint"==typeof e?BigInt.asUintN(64,e).toString(t):16===t?e[symbol]().toHex():String(e)}function toHex(e){return toRadix(e,16)}function RegExp_create(e,t=0){if(-1308&t)throw new Exception("RegexOptions only supports: IgnoreCase, Multiline, Compiled, Singleline, ECMAScript and NonBacktracking");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,a,s,l)=>{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 _=a??s;if(null!=_){const n=parseInt(_,10);return n<t.length?t[n]??"":e}return null!=t.groups&&l in t.groups?t.groups[l]??"":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 a=i?o-3:o-2;for(let e=0;e<a;e++)t.push(arguments[e]);t.index=arguments[a++],t.input=arguments[a++],i&&(t.groups=arguments[a]),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,a=null==n?-1:n-1;for(const n of RegExp_matches(e,t,r)){if(0===a)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]);a--}return o.push(t.substring(i)),o}var String_escape,String_Exception;const dateTimeFormattableSymbol=Symbol.for("Fable.DateTimeFormattable");function isNetDateFormattable(e){return null!=e&&"function"==typeof e[dateTimeFormattableSymbol]}function formatDateLike(e,t){return e instanceof Date?Date_toString(e,t):e[dateTimeFormattableSymbol](t)}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,a="".concat.apply("",t);for(let t=r;t<i;t++)if(a.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 a=i.index+(i[1]||"").length;o+=e.substring(r,a).replace(/%%/g,"%");const[,,s,l,_,u]=i;r=interpolateRegExp.lastIndex,o+=formatReplacement(t[n++],s,l,_,u),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)){const n="x"===o||"X"===o?16:"o"===o?8:10;switch(10===n&&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":case"o":e=toRadix(e,n);break;case"X":e=toRadix(e,n).toUpperCase();break;default:e=String(e)}}else e=e instanceof Date||isNetDateFormattable(e)?formatDateLike(e,void 0):"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,a=o||!r?" ":"0";e="0"===a?i+(e=pad(e,n-i.length,a,o)):pad(i+e,n,a,o)}return e}function createPrinter(e,t,n,r="",o=-1){return(...i)=>{let a=r;const s=t.slice(),l=n.slice();for(const e of i){const[,,t,n,r,i]=l[0];let _=n;if(o>=0)_=o,o=-1;else if("*"===_){if(e<0)throw new Exception("Non-negative number required");o=e;continue}a+=s[0],a+=formatReplacement(e,t,_,r,i),s.splice(0,1),l.splice(0,1)}return 0===l.length?(a+=s[0],e(a)):createPrinter(e,s,l,a,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 splitExponential(e){const t=e.indexOf("e");return[e.slice(0,t).replace(".",""),Number(e.slice(t+1))]}function shortestSingle(e){const[t,n]=splitExponential(e.toExponential(99));for(let r=1;;r++){const o=Number(t.slice(0,r)),i=t.slice(r),a="5".padEnd(i.length,"0"),s=i>a||i===a&&o%2==1;for(const t of s?[o+1,o]:[o,o+1])if(Math.fround(Number(t+"e"+(n-r+1)))===e)return[String(t),n+String(t).length-r]}}function formatGeneral(e,t,n,r=!1){if(!Number.isFinite(e))return String(e);const o=e<0||Object.is(e,-0)?"-":"";e=Math.abs(e);const i="r"===t||"R"===t?0:n??0,[a,s]=i>0?splitExponential(e.toExponential(i-1)):r?shortestSingle(e):splitExponential(e.toExponential()),l=trimEnd(a,"0")||"0";if(s<-4||s>=(i>0?i:r?9:17))return o+(l.length>1?l[0]+"."+l.slice(1):l)+("G"===t||"R"===t?"E":"e")+(s<0?"-":"+")+padLeft(String(Math.abs(s)),2,"0");if(s<0)return o+"0."+"0".repeat(-s-1)+l;{const e=l.slice(s+1);return o+l.slice(0,s+1).padEnd(s+1,"0")+(e?"."+e:"")}}function formatSingle(e,t){const n=/^\{0:([GgRr])(\d{0,2})\}$/.exec(e);return null!=n?formatGeneral(Math.fround(t),n[1],n[2]?parseInt(n[2],10):null,!0):format(e,t)}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,a)=>{if(n<0||n>=t.length)throw new Exception("Index must be greater or equal to zero and less than the arguments' length.");let s,l=t[n];if(isNumeric(l))switch(i=""==i?null:parseInt(i,10),o){case"b":case"B":if(!isIntegral(l))throw new Exception("Format specifier was invalid.");l=(l>>>0).toString(2).replace(/^0+/,"").padStart(i||1,"0");break;case"c":case"C":const e=isLessThan(l,0);isLessThan(l,0)&&(l=multiply(l,-1)),l=toFixed(l,i=i??2),s=splitIntAndDecimalPart(l),l=i>0?"¤"+thousandSeparate(s.integral)+"."+padRight(s.decimal,i,"0"):"¤"+thousandSeparate(s.integral),e&&(l="("+l+")");break;case"d":case"D":if(!isIntegral(l))throw new Exception("Format specifier was invalid.");l=String(l),null!=i&&(l=l.startsWith("-")?"-"+padLeft(l.substring(1),i,"0"):padLeft(l,i,"0"));break;case"e":case"E":{i=null!=i?i:6,l=String(toExponential(l,i));const e=l.indexOf("e");l=l.slice(0,e)+o+l[e+1]+padLeft(l.slice(e+2),3,"0");break}case"f":case"F":l=toFixed(l,i=null!=i?i:2),i>0&&(s=splitIntAndDecimalPart(l),l=s.integral+"."+padRight(s.decimal,i,"0"));break;case"g":case"G":case"r":case"R":{if("number"==typeof l){l=formatGeneral(l,o,i);break}if(null==i){l=String(l);break}l=toPrecision(l,i);const e=l.indexOf("e");if(e>=0){const t=trimEnd(trimEnd(l.slice(0,e),"0"),"."),n=l[e+1],r=l.slice(e+2),i=r.length<2?"0"+r:r;l=t+("G"===o||"R"===o?"E":"e")+n+i}else l.indexOf(".")>=0&&(l=trimEnd(trimEnd(l,"0"),"."));break}case"n":case"N":l=toFixed(l,i=null!=i?i:2),s=splitIntAndDecimalPart(l),l=i>0?thousandSeparate(s.integral)+"."+padRight(s.decimal,i,"0"):thousandSeparate(s.integral);break;case"p":case"P":i=null!=i?i:2,l=toFixed(multiply(l,100),i),s=splitIntAndDecimalPart(l),l=i>0?thousandSeparate(s.integral)+"."+padRight(s.decimal,i,"0")+" %":thousandSeparate(s.integral)+" %";break;case"x":case"X":if(!isIntegral(l))throw new Exception("Format specifier was invalid.");i=null!=i?i:1,l=padLeft(toHex(l),i,"0"),"X"===o&&(l=l.toUpperCase());break;default:if(o)throw new Exception("Format specifier was invalid.");if(a){let e="";const t=a,n=(t.match(/%/g)??[]).length;n>0&&(l=multiply(l,Math.pow(100,n))),l=t.replace(/([0#,]+)(\.[0#]+)?(,*)/,(t,n,r)=>{const o=/,*$/.exec(n)[0].length;o>0&&(n=n.substring(0,n.length-o),l=divide(l,Math.pow(1e3,o))),isLessThan(l,0)&&(l=multiply(l,-1),e="-"),r=null==r?"":r.substring(1),l=toFixed(l,Math.max(r.length,0));let[i,a]=l.split(".");a||(a=""),i=padLeft(i,n.replace(/,/g,"").replace(/^#+/,"").length,"0");const s=r.replace(/#+$/,"").length;if(s>a.length?a=padRight(a,s,"0"):s<a.length&&(a=a.substring(0,s)+a.substring(s).replace(/0+$/,"")),n.indexOf(",")>0){const e=i.length%3,t=Math.floor(i.length/3);let n=e>0?i.substr(0,e)+(t>0?",":""):"";for(let r=0;r<t;r++)n+=i.substr(e+3*r,3)+(r<t-1?",":"");i=n}return a.length>0?i+"."+a:i}),l=e+l}}else l=l instanceof Date||isNetDateFormattable(l)?formatDateLike(l,a||o):Types_toString(l);return r=parseInt((r||" ").substring(1),10),isNaN(r)||(l=pad(String(l),Math.abs(r)," ",r<0)),l})}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 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 a=[],s=new RegExp(t.join("|"),"g");let l=!0,_=0;do{const t=s.exec(e);if(null===t){const t=i?e.substring(_).trim():e.substring(_);(!o||t.length>0)&&a.push(t),l=!1}else{const r=i?e.substring(_,t.index).trim():e.substring(_,t.index);(!o||r.length>0)&&(null!=n&&a.length+1===n?(a.push(i?e.substring(_).trim():e.substring(_)),l=!1):a.push(r)),_=s.lastIndex}}while(l);return a}function trim(e,...t){if(0===t.length)return e.trim();const n="["+RegExp_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_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(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(),System_defaultOf())}function ArgumentException_$ctor_Z721C83C5(e){return ArgumentException_$ctor_Z60A2B367(e,defaultOf(),defaultOf())}function ArgumentException_$ctor_Z384F8060(e,t){return ArgumentException_$ctor_Z60A2B367(e,t,defaultOf())}function ArgumentException_$ctor_68CE3CA2(e,t){return ArgumentException_$ctor_Z60A2B367(e,System_defaultOf(),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(System_defaultOf())}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(System_defaultOf())}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_InvalidArg(e,t){throw ArgumentException_$ctor_Z384F8060(t,e)}function Operators_InvalidOp(e){throw InvalidOperationException_$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 KeyNotFoundException_$ctor_Z721C83C5,Array_SR_keyNotFoundAlt,Array_SR_inputMustBeNonNegative,Array_SR_notEnoughElements,Array_SR_indexOutOfBounds,Array_SR_inputSequenceEmpty,Array_Operators_InvalidArg,Array_Operators_InvalidOp,Array_Helpers_allocateArrayFromCons,Array_defaultOf,Array_int32ToString,Array_getEnumerator,Array_disposeSafe,setItem_1,item_3,Array_ArgumentOutOfRangeException_$ctor_Z384F8060,Array_ArgumentException_$ctor_Z721C83C5,value_2,Array_some,Array_defaultArg,max_1,min_1,nonSeeded,List_defaultOf,List_isArrayLike,List_getEnumerator,List_disposeSafe,value_1,List_defaultArg,List_class_type,List_Operators_InvalidArg,List_Operators_InvalidOp,List_SR_inputWasEmpty,List_SR_inputSequenceEmpty,List_SR_inputMustBeNonNegative,List_SR_notEnoughElements,List_SR_inputSequenceTooLong,List_SR_indexOutOfBounds,foldBack_1,foldBack2_1,scanBack_1,tryFindBack_1,tryFindIndexBack_1,permute_1,map_1,chunkBySize_1,windowed_1,splitInto_1,transpose_1,List_randomShuffleInPlaceBy,randomChoiceBy_1,randomChoicesBy_1,randomSampleBy_1,List_nonSeeded;function indexNotFound(){throw KeyNotFoundException_$ctor_Z721C83C5(Array_SR_keyNotFoundAlt)}function differentLengths(e){throw Array_Operators_InvalidArg(e,"The arrays have 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_3(t,e));for(let e=0;e<=o-1;e++)setItem_1(i,e+r,item_3(e,t));return i}function Array_filter(e,t){return t.filter(e)}function fill(e,t,n,r){if(t<0)throw Operators_InvalidArg("targetIndex",SR_inputMustBeNonNegative);if(n<0)throw Operators_InvalidArg("count",SR_inputMustBeNonNegative);if(n>0&&t+n>e.length)throw IndexOutOfRangeException_$ctor();const o=0|t;return e.fill(r,o,o+n)}function getSubArray(e,t,n){if(t<0)throw Array_Operators_InvalidArg("startIndex",Array_SR_inputMustBeNonNegative);if(n<0)throw Array_Operators_InvalidArg("count",Array_SR_inputMustBeNonNegative);if(t+n>e.length)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("count","The index is outside the legal range.");const r=0|t;return e.slice(r,r+n)}function last(e){if(0===e.length)throw Array_Operators_InvalidArg("array","The input array was empty");return item_3(e.length-1,e)}function tryLast(e){return 0===e.length?void 0:some(Array_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,Array_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(Array_item(n,t)));return o}function mapIndexed2(e,t,n,r){t.length!==n.length&&differentLengths("array1");const o=Array_Helpers_allocateArrayFromCons(r,t.length);for(let r=0;r<=t.length-1;r++)setItem_1(o,r,e(r,item_3(r,t),item_3(r,n)));return o}function map2(e,t,n,r){t.length!==n.length&&differentLengths("array1");const o=Array_Helpers_allocateArrayFromCons(r,t.length);for(let r=0;r<=t.length-1;r++)setItem_1(o,r,e(item_3(r,t),item_3(r,n)));return o}function mapIndexed3(e,t,n,r,o){t.length===n.length&&n.length===r.length||differentLengths("array1, array2, array3");const i=Array_Helpers_allocateArrayFromCons(o,t.length);for(let o=0;o<=t.length-1;o++)setItem_1(i,o,e(o,item_3(o,t),item_3(o,n),item_3(o,r)));return i}function map3(e,t,n,r,o){t.length===n.length&&n.length===r.length||differentLengths("array1, array2, array3");const i=Array_Helpers_allocateArrayFromCons(o,t.length);for(let o=0;o<=t.length-1;o++)setItem_1(i,o,e(item_3(o,t),item_3(o,n),item_3(o,r)));return i}function mapFold(e,t,n,r){const o=0|n.length;if(0===o)return[[],t];{let i=t;const a=Array_Helpers_allocateArrayFromCons(r,o);for(let t=0;t<=n.length-1;t++){const r=e(i,item_3(t,n));setItem_1(a,t,r[0]),i=r[1]}return[a,i]}}function mapFoldBack(e,t,n,r){const o=0|t.length;if(0===o)return[[],n];{let i=n;const a=Array_Helpers_allocateArrayFromCons(r,o);for(let n=t.length-1;n>=0;n--){const r=e(item_3(n,t),i);setItem_1(a,n,r[0]),i=r[1]}return[a,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_3(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_3(0,n);default:{let e=0,r=0;for(let e=0;e<=n.length-1;e++)r=r+item_3(e,n).length|0;const o=Array_Helpers_allocateArrayFromCons(t,r);for(let t=0;t<=n.length-1;t++){const r=item_3(t,n);for(let t=0;t<=r.length-1;t++)setItem_1(o,e,item_3(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 a=0|defaultArg(n,0),s=0|defaultArg((i=r,null!=i?a+i:void 0),e.length);return 0|(n=>{for(;;){const r=n;if(r>=s)return-1;if(o.Equals(t,Array_item(r,e)))return 0|r;n=r+1}})(a)}function Array_contains(e,t,n){return Array_indexOf(t,e,void 0,void 0,n)>=0}function binarySearchFrom(e,t,n,r,o){return 0|((t,n)=>{e:for(;;){const i=t,a=n;if(i>a)return 0|~i;{const s=i+(a-i>>1)|0,l=0|o.Compare(item_3(s,e),r);if(0===l)return 0|s;if(l<0){t=s+1,n=a;continue e}t=i,n=s-1;continue e}}})(t,t+n-1)}function checkBinarySearchRange(e,t,n,r){if(n<0)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("index","Non-negative number required.");if(r<0)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060(e,"Non-negative number required.");if(t.length-n<r)throw Array_ArgumentException_$ctor_Z721C83C5("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.")}function binarySearch(e,t,n){return 0|binarySearchFrom(e,0,e.length,t,n)}function binarySearchRange(e,t,n,r,o){return checkBinarySearchRange("length",e,t,n),0|binarySearchFrom(e,t,n,r,o)}function binarySearchRangeCount(e,t,n,r,o){return checkBinarySearchRange("count",e,t,n),0|binarySearchFrom(e,t,n,r,o)}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 Operators_InvalidArg("count","The input must be non-negative");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,[Array_item(r,e),Array_item(r+1,e)]);return n}}function Array_replicate(e,t,n){if(e<0)throw Array_Operators_InvalidArg("count","The input must be non-negative");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 copyTypedArray(e,t,n,r,o){n.set(e.subarray(t,t+o),r)}function argumentOutOfRange(e,t,n){throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060(e,e+" ('"+Array_int32ToString(t)+"') must be "+n)}function copyTo(e,t,n,r,o){if(o<0&&argumentOutOfRange("length",o,"a non-negative value."),t<0&&argumentOutOfRange("sourceIndex",t,"greater than or equal to '0'."),t+o>e.length)throw Array_Operators_InvalidArg("sourceArray","Source array was not long enough. Check the source index, length, and the array's lower bounds.");if(r<0&&argumentOutOfRange("destinationIndex",r,"greater than or equal to '0'."),r+o>n.length)throw Array_Operators_InvalidArg("destinationArray","Destination array was not long enough. Check the destination index, length, and the array's lower bounds.");if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n))copyTypedArray(e,t,n,r,o);else if(t<r)for(let i=o-1;i>=0;i--){const o=r+i|0;let a;a=e[t+i|0],n[o]=a}else for(let i=0;i<=o-1;i++){const o=r+i|0;let a;a=e[t+i|0],n[o]=a}}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_3(t,o),item_3(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_3(n,t),item_3(n+1,o)));return o}function skip(e,t,n){if(e>t.length)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("count","The index is outside the legal range.");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_3(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 Array_Operators_InvalidArg("count","The input must be non-negative");if(e>t.length)throw Array_Operators_InvalidOp(Array_SR_notEnoughElements);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_3(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 a=0,s=0;for(let n=0;n<=r-1;n++)e(item_3(n,t))?(setItem_1(o,a,item_3(n,t)),a=a+1|0):(setItem_1(i,s,item_3(n,t)),s=s+1|0);return[truncate(a,o),truncate(s,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_3(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_3(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_3(r,t)))return item_3(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_3(r,t)))return Array_some(item_3(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_3(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_3(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_3(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(Array_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_3(n,t))}function iterateIndexed(e,t){for(let n=0;n<=t.length-1;n++)e(n,item_3(n,t))}function iterate2(e,t,n){t.length!==n.length&&differentLengths("array1");for(let r=0;r<=t.length-1;r++)e(item_3(r,t),item_3(r,n))}function iterateIndexed2(e,t,n){t.length!==n.length&&differentLengths("array1");for(let r=0;r<=t.length-1;r++)e(r,item_3(r,t),item_3(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();let o;const i=new Array(n);if(o=i.fill(0,0,0+n),iterateIndexed((t,i)=>{const a=0|e(t);if(a<0||a>=n)throw Array_Operators_InvalidArg("indexMap","The function did not compute a permutation.");setItem_1(r,a,i),setItem_1(o,a,1)},t),!o.every(e=>1===e))throw Array_Operators_InvalidArg("indexMap","The function did not compute a permutation.");return r}function setSlice(e,t,n,r){const o=0|Array_defaultArg(t,0),i=0|Array_defaultArg(n,-1),a=(i>=0?i:e.length-1)-o|0;for(let t=0;t<=a;t++)setItem_1(e,t+o,item_3(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_3(n,e),item_3(i,t)]);return o}function unfold(e,t){const n=[];return(t=>{e:for(;;){const r=e(t);if(null!=r){const e=r[0],o=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("array1");const n=new Array(e.length);for(let r=0;r<=e.length-1;r++)setItem_1(n,r,[item_3(r,e),item_3(r,t)]);return n}function zip3(e,t,n){e.length===t.length&&t.length===n.length||differentLengths("array1, array2, array3");const r=new Array(e.length);for(let o=0;o<=e.length-1;o++)setItem_1(r,o,[item_3(o,e),item_3(o,t),item_3(o,n)]);return r}function chunkBySize(e,t){if(e<1)throw Array_Operators_InvalidArg("chunkSize","The input must be positive.");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)throw Array_Operators_InvalidArg("index",Array_SR_indexOutOfBounds);if(e>t.length)throw Array_Operators_InvalidOp(Array_SR_notEnoughElements);return[t.slice(0,0+e),t.slice(e)]}function compareWith(e,t,n){if(null==t)return null==n?0:-1;if(null==n)return 1;{const r=0|t.length,o=0|n.length,i=0|(r<o?r:o);let a=0,s=0;for(;0===s&&a<i;)s=0|e(item_3(a,t),item_3(a,n)),a=a+1|0;return 0!==s?0|s:r>o?1:r<o?-1:0}}function Array_compareTo(e,t,n){if(null==t)return null==n?0:-1;if(null==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_3(o,t),item_3(o,n)),o=o+1|0;return 0|i}}}function equalsWith(e,t,n){if(null==t)return null==n;if(null==n)return!1;{let r=0,o=!0;const i=0|t.length,a=0|n.length;if(i>a)return!1;if(i<a)return!1;for(;r<i&&o;)o=e(item_3(r,t),item_3(r,n)),r=r+1|0;return o}}function exactlyOne(e){switch(e.length){case 1:return item_3(0,e);case 0:throw Array_Operators_InvalidArg("array","The input sequence was empty");default:throw Array_Operators_InvalidArg("array","Input array too long")}}function tryExactlyOne(e){return 1===e.length?Array_some(item_3(0,e)):void 0}function head(e){if(0===e.length)throw Array_Operators_InvalidArg("array","The input array was empty");return item_3(0,e)}function tryHead(e){return 0===e.length?void 0:Array_some(item_3(0,e))}function tail(e){if(0===e.length)throw Array_Operators_InvalidArg("array","Not enough elements");return e.slice(1)}function Array_item(e,t){const n=t[e];if(void 0===n&&(e<0||e>=t.length))throw Operators_InvalidArg("index","Index was outside the bounds of the array.");return n}function setItem(e,t,n){if(t<0||t>=e.length)throw Operators_InvalidArg("index","Index was outside the bounds of the array.");e[t]=n}function tryItem(e,t){return e<0||e>=t.length?void 0: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;n.length!==r.length&&differentLengths("array1");for(let t=0;t<=n.length-1;t++)o=e(t,o,item_3(t,n),item_3(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("array1");const i=0|t.length;for(let r=1;r<=i;r++)o=e(r-1,item_3(i-r,t),item_3(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 Array_Operators_InvalidArg("array","The input array was empty");const n=e;return t.reduce(n)}function reduceBack(e,t){if(0===t.length)throw Array_Operators_InvalidArg("array","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_3(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,a=n,s=r;if(s===i.length)return!1;if(o(item_3(s,i),item_3(s,a)))return!0;e=o,t=i,n=a,r=s+1}}function exists2(e,t,n){return t.length!==n.length&&differentLengths("array1"),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_3(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_3(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 Array_Operators_InvalidArg("array","The input array was empty");let n=t.GetZero();for(let r=0;r<=e.length-1;r++)n=t.Add(n,item_3(r,e));return t.DivideByInt(n,e.length)}function averageBy(e,t,n){if(0===t.length)throw Array_Operators_InvalidArg("array","The input array was empty");let r=n.GetZero();for(let o=0;o<=t.length-1;o++)r=n.Add(r,e(item_3(o,t)));return n.DivideByInt(r,t.length)}function windowed(e,t){if(e<=0)throw Array_Operators_InvalidArg("windowSize","The input 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 Array_Operators_InvalidArg("count","The input must be positive.");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 a;const s=e*o+min_1(i,e)|0;a=t.slice(s,s+r),n.push(a)}}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_3(0,n).length;forAll(t=>t.length===e,n)||differentLengths("array.[0]");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_3(i,o)[e]=item_3(i,item_3(e,n))}return o}}function insertAt(e,t,n,r){const o=0|n.length;if(e<0||e>o)throw Array_Operators_InvalidArg("index",Array_SR_indexOutOfBounds);const i=Array_Helpers_allocateArrayFromCons(r,o+1);for(let t=0;t<=e-1;t++)setItem_1(i,t,item_3(t,n));setItem_1(i,e,t);for(let t=e;t<=o-1;t++)setItem_1(i,t+1,item_3(t,n));return i}function insertManyAt(e,t,n,r){const o=0|n.length;if(e<0||e>o)throw Array_Operators_InvalidArg("index",Array_SR_indexOutOfBounds);const i=Array.from(t),a=0|i.length,s=Array_Helpers_allocateArrayFromCons(r,o+a);for(let t=0;t<=e-1;t++)setItem_1(s,t,item_3(t,n));for(let t=0;t<=a-1;t++)setItem_1(s,e+t,item_3(t,i));for(let t=e;t<=o-1;t++)setItem_1(s,t+a,item_3(t,n));return s}function randomShuffleInPlaceBy(e,t){for(let n=(0|t.length)-1;n>=1;n--){const r=e();if(r<0||r>=1)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("randomizer","The index is outside the legal range.");const o=r*(n+1)|0,i=item_3(n,t);setItem_1(t,n,item_3(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 Array_Operators_InvalidArg("source",Array_SR_inputSequenceEmpty);const n=0|t.length,r=e();if(r<0||r>=1)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("randomizer","The index is outside the legal range.");return item_3(~~(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 Array_Operators_InvalidArg("count",Array_SR_inputMustBeNonNegative);if(t>0&&isEmpty(n))throw Array_Operators_InvalidArg("source",Array_SR_inputSequenceEmpty);const o=0|n.length;return Array_initialize(t,t=>{const r=e();if(r<0||r>=1)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("randomizer","The index is outside the legal range.");return item_3(~~(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 Array_Operators_InvalidArg("count",Array_SR_inputMustBeNonNegative);const r=copy(n),o=0|r.length;if(0===o&&t>0)throw Array_Operators_InvalidArg("source",Array_SR_inputSequenceEmpty);if(t>o)throw Array_Operators_InvalidArg("count",Array_SR_notEnoughElements);for(let n=0;n<=t-1;n++){const t=e();if(t<0||t>=1)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("randomizer","The index is outside the legal range.");const i=n+~~(t*(o-n))|0,a=item_3(n,r);setItem_1(r,n,item_3(i,r)),setItem_1(r,i,a)}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 Array_Operators_InvalidArg("index",Array_SR_indexOutOfBounds);let n=-1;return Array_filter(t=>(n=n+1|0,n!==e),t)}function removeManyAt(e,t,n){if(e<0||e>n.length-t||e>n.length)throw Array_Operators_InvalidArg("index","index must be within bounds of the array");let r=-1;return Array_filter(n=>(r=r+1|0,r<e||r>=e+t),n)}function updateAt(e,t,n,r){const o=0|n.length;if(e<0||e>=o)throw Array_Operators_InvalidArg("index",Array_SR_indexOutOfBounds);const i=Array_Helpers_allocateArrayFromCons(r,o);for(let r=0;r<=o-1;r++)setItem_1(i,r,r===e?t:item_3(r,n));return i}function resize(e,t,n,r){let o,i,a,s;if(t<0)throw Array_Operators_InvalidArg("newSize","The input must be non-negative.");const l=Array_defaultArg(n,Array_defaultOf());if(null==e.contents)e.contents=(o=Array_Helpers_allocateArrayFromCons(r,t),o.fill(l,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&©To(e.contents,0,o,0,n),e.contents=(a=0|n,s=t-n|0,o.fill(l,a,a+s))}}}class FSharpList{constructor(e,t){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 FSharpList&&((e,t)=>{e:for(;;){const n=e,r=t,o=n.tail,i=r.tail;if(null!=o){if(null!=i){const a=o,s=i;if(equals(n.head,r.head)){e=a,t=s;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,a=i.tail;if(null!=a){const s=a;if(r>18)return 0|o;e=r+1,t=(o<<1)+structuralHash(i.head)+631*r,n=s;continue e}return 0|o}})(0,0,this)}toJSON(){return Array.from(this)}CompareTo(e){return e instanceof FSharpList?0|((e,t)=>{e:for(;;){const n=e,r=t,o=n.tail,i=r.tail;if(null!=o){if(null!=i){const a=o,s=i,l=0|compare(n.head,r.head);if(0===l){e=a,t=s;continue e}return 0|l}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 List_class_type("ListModule.FSharpList",[e],FSharpList)}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=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_$ctor_Z23DD7291(e,t){return new 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=r}})(0,e)}function FSharpList__get_Head(e){if(null!=e.tail)return e.head;throw Operators_InvalidOp(SR_inputWasEmpty)}function FSharpList__get_Tail(e){const t=e.tail;if(null!=t)return t;throw Operators_InvalidOp(SR_inputWasEmpty)}function FSharpList__get_Item_Z524259A4(e,t){return((e,n)=>{e:for(;;){const r=e,o=n,i=o.tail;if(null!=i){const a=i;if(r===t)return o.head;e=r+1,n=a;continue e}throw Operators_InvalidArg("index",SR_indexOutOfBounds)}})(0,e)}const emptyNode=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0);function List_empty(){return emptyNode}function List_indexNotFound(){throw System_Collections_Generic_KeyNotFoundException_$ctor_Z721C83C5(SR_keyNotFoundAlt)}function List_differentLengths(e){throw List_Operators_InvalidArg(e,"The lists had different lengths.")}function cons(e,t){return FSharpList_$ctor_Z23DD7291(e,t)}function List_singleton(e){return FSharpList_$ctor_Z23DD7291(e,List_empty())}function List_isEmpty(e){return FSharpList__get_IsEmpty(e)}function List_length(e){return 0|FSharpList__get_Length(e)}function List_head(e){if(null!=e.tail)return e.head;throw Operators_InvalidArg("list",SR_inputWasEmpty)}function List_tryHead(e){return FSharpList__get_IsEmpty(e)?void 0:some(FSharpList__get_Head(e))}function List_tail(e){const t=e.tail;if(null!=t)return t;throw Operators_InvalidArg("list",SR_inputWasEmpty)}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 List_Operators_InvalidArg("list",List_SR_inputWasEmpty);return 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),a=FSharpList__get_IsEmpty(o);if(i)return a?0:-1;if(a)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_$ctor_Z23DD7291(t,e),List_empty(),e)}function List_foldBack(e,t,n){return foldBack_1(e,List_toArray(t),n)}function List_foldIndexed(e,t,n){return((t,n,r)=>{for(;;){const o=t,i=n,a=r;if(FSharpList__get_IsEmpty(a))return i;t=o+1,n=e(o,i,FSharpList__get_Head(a)),r=FSharpList__get_Tail(a)}})(0,t,n)}function List_fold2(e,t,n,r){let o=t,i=n,a=r;for(;!FSharpList__get_IsEmpty(i)&&!FSharpList__get_IsEmpty(a);)o=e(o,FSharpList__get_Head(i),FSharpList__get_Head(a)),i=FSharpList__get_Tail(i),a=FSharpList__get_Tail(a);return FSharpList__get_IsEmpty(i)?FSharpList__get_IsEmpty(a)||List_differentLengths("list1"):List_differentLengths("list2"),o}function List_foldBack2(e,t,n,r){const o=List_toArray(t),i=List_toArray(n);return o.length!==i.length&&List_differentLengths(0===o.length?"list1":0===i.length?"list2":"list1, list2"),foldBack2_1(e,o,i,r)}function List_unfold(e,t){const n=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),r=((t,n)=>{for(;;){const r=n;let o;const i=e(t);if(null==i)return r;t=i[1],o=FSharpList_$ctor_Z23DD7291(i[0],void 0),r.tail=o,n=o}})(t,n),o=List_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_$ctor_Z23DD7291(Array_item(t,e),n);return n}function ofArray(e){return ofArrayWithTail(e,List_empty())}function ofSeq(e){if(isArrayLike(e))return ofArray(e);if(e instanceof FSharpList)return e;{const t=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0);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=FSharpList_$ctor_Z23DD7291(o,void 0),e.tail=t,n=t}}finally{disposeSafe(r)}const o=n,i=List_empty();return o.tail=i,FSharpList__get_Tail(t)}}function List_concat(e){const t=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0);let n=t;const r=e=>{n=List_fold((e,t)=>{const n=FSharpList_$ctor_Z23DD7291(t,void 0);return e.tail=n,n},n,e)};if(List_isArrayLike(e))e.forEach(r);else if(e instanceof 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=List_empty();return o.tail=i,FSharpList__get_Tail(t)}function List_scan(e,t,n){const r=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0);let o;const i=FSharpList_$ctor_Z23DD7291(t,void 0);r.tail=i,o=i;let a=t,s=n;for(;!FSharpList__get_IsEmpty(s);){let t,n;a=e(a,FSharpList__get_Head(s)),t=o,n=FSharpList_$ctor_Z23DD7291(a,void 0),t.tail=n,o=n,s=FSharpList__get_Tail(s)}const l=o,_=List_empty();return l.tail=_,FSharpList__get_Tail(r)}function List_scanBack(e,t,n){return ofArray(scanBack_1(e,List_toArray(t),n))}function List_append(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0);let r=n,o=e;for(;null!=o.tail;){let e,t;e=r,t=FSharpList_$ctor_Z23DD7291(o.head,void 0),e.tail=t,r=t,o=o.tail}return r.tail=t,FSharpList__get_Tail(n)}function List_collect(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0);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=FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(t),void 0),e.tail=n,r=n,t=FSharpList__get_Tail(t)}o=FSharpList__get_Tail(o)}const i=r,a=List_empty();return i.tail=a,FSharpList__get_Tail(n)}function List_mapIndexed(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=List_foldIndexed((t,n,r)=>{const o=FSharpList_$ctor_Z23DD7291(e(t,r),void 0);return n.tail=o,o},n,t),o=List_empty();return r.tail=o,FSharpList__get_Tail(n)}function List_map(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=List_fold((t,n)=>{const r=FSharpList_$ctor_Z23DD7291(e(n),void 0);return t.tail=r,r},n,t),o=List_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_$ctor_Z23DD7291(List_defaultOf(),void 0),o=List_fold2((t,n,r)=>{const o=FSharpList_$ctor_Z23DD7291(e(n,r),void 0);return t.tail=o,o},r,t,n),i=List_empty();return o.tail=i,FSharpList__get_Tail(r)}function List_mapIndexed2(e,t,n){const r=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),o=((t,n,r,o)=>{for(;;){const i=t,a=n,s=r,l=o;let _;if(FSharpList__get_IsEmpty(s)||FSharpList__get_IsEmpty(l))return FSharpList__get_IsEmpty(s)?FSharpList__get_IsEmpty(l)||List_differentLengths("list1"):List_differentLengths("list2"),a;t=i+1,_=FSharpList_$ctor_Z23DD7291(e(i,FSharpList__get_Head(s),FSharpList__get_Head(l)),void 0),a.tail=_,n=_,r=FSharpList__get_Tail(s),o=FSharpList__get_Tail(l)}})(0,r,t,n),i=List_empty();return o.tail=i,FSharpList__get_Tail(r)}function List_map3(e,t,n,r){const o=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),i=((t,n,r,o)=>{for(;;){const i=t,a=n,s=r,l=o;let _;if(FSharpList__get_IsEmpty(a)||FSharpList__get_IsEmpty(s)||FSharpList__get_IsEmpty(l))return FSharpList__get_IsEmpty(a)&&FSharpList__get_IsEmpty(s)&&FSharpList__get_IsEmpty(l)||List_differentLengths("list1, list2, list3"),i;_=FSharpList_$ctor_Z23DD7291(e(FSharpList__get_Head(a),FSharpList__get_Head(s),FSharpList__get_Head(l)),void 0),i.tail=_,t=_,n=FSharpList__get_Tail(a),r=FSharpList__get_Tail(s),o=FSharpList__get_Tail(l)}})(o,t,n,r),a=List_empty();return i.tail=a,FSharpList__get_Tail(o)}function List_mapFold(e,t,n){const r=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),o=List_fold((t,n)=>{let r;const o=e(t[1],n);return[(r=FSharpList_$ctor_Z23DD7291(o[0],void 0),t[0].tail=r,r),o[1]]},[r,t],n),i=List_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():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 tryFindBack_1(e,List_toArray(t))}function List_findBack(e,t){const n=List_tryFindBack(e,t);return null==n?List_indexNotFound():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|n}function List_tryFindIndexBack(e,t){return tryFindIndexBack_1(e,List_toArray(t))}function List_findIndexBack(e,t){const n=List_tryFindIndexBack(e,t);return null==n?(List_indexNotFound(),-1):0|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 item(e,t){return FSharpList__get_Item_Z524259A4(t,e)}function List_filter(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=List_fold((t,n)=>{if(e(n)){const e=FSharpList_$ctor_Z23DD7291(n,void 0);return t.tail=e,e}return t},n,t),o=List_empty();return r.tail=o,FSharpList__get_Tail(n)}function List_partition(e,t){const n=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),r=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),o=n,i=List_fold((t,n)=>{let r,o;const i=t[0],a=t[1];return e(n)?[(r=FSharpList_$ctor_Z23DD7291(n,void 0),i.tail=r,r),a]:[i,(o=FSharpList_$ctor_Z23DD7291(n,void 0),a.tail=o,o)]},[o,r],t),a=List_empty();i[0].tail=a;const s=List_empty();return i[1].tail=s,[FSharpList__get_Tail(o),FSharpList__get_Tail(r)]}function List_choose(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=List_fold((t,n)=>{const r=e(n);if(null==r)return t;{const e=FSharpList_$ctor_Z23DD7291(Option_value(r),void 0);return t.tail=e,e}},n,t),o=List_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){if(e<0)throw Operators_InvalidArg("count",SR_inputMustBeNonNegative);const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0);let r=n;for(let n=0;n<=e-1;n++){let e,o;e=r,o=FSharpList_$ctor_Z23DD7291(t(n),void 0),e.tail=o,r=o}const o=r,i=List_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 Operators_InvalidArg("list",SR_inputWasEmpty);return List_fold(e,List_head(t),List_tail(t))}function List_reduceBack(e,t){if(FSharpList__get_IsEmpty(t))throw List_Operators_InvalidArg("list",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){for(;;){const r=e,o=t,i=n,a=FSharpList__get_IsEmpty(o),s=FSharpList__get_IsEmpty(i);if(a)return!!s||List_differentLengths("list1");if(s)return List_differentLengths("list2");if(!r(FSharpList__get_Head(o),FSharpList__get_Head(i)))return!1;e=r,t=FSharpList__get_Tail(o),n=FSharpList__get_Tail(i)}}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,a=FSharpList__get_IsEmpty(o),s=FSharpList__get_IsEmpty(i);let l;switch(l=a?s?0:2:s?2:1,l){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:return List_differentLengths("list2")}break}}function List_unzip(e){return List_foldBack((e,t)=>[FSharpList_$ctor_Z23DD7291(e[0],t[0]),FSharpList_$ctor_Z23DD7291(e[1],t[1])],e,[List_empty(),List_empty()])}function List_unzip3(e){return List_foldBack((e,t)=>[FSharpList_$ctor_Z23DD7291(e[0],t[0]),FSharpList_$ctor_Z23DD7291(e[1],t[1]),FSharpList_$ctor_Z23DD7291(e[2],t[2])],e,[List_empty(),List_empty(),List_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),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){if(FSharpList__get_IsEmpty(e))throw List_Operators_InvalidArg("source",List_SR_inputSequenceEmpty);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){if(FSharpList__get_IsEmpty(t))throw List_Operators_InvalidArg("source",List_SR_inputSequenceEmpty);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 ofArray(permute_1(e,List_toArray(t)))}function List_chunkBySize(e,t){return ofArray(map_1(ofArray,chunkBySize_1(e,List_toArray(t))))}function List_allPairs(e,t){const n=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0);let r=n;List_iterate(e=>{List_iterate(t=>{let n,o;n=r,o=FSharpList_$ctor_Z23DD7291([e,t],void 0),n.tail=o,r=o},t)},e);const o=r,i=List_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 ArgumentOutOfRangeException_$ctor_Z384F8060("count","The index is outside the legal range.");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 Operators_InvalidArg("count",SR_inputMustBeNonNegative);const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=((e,t,n)=>{for(;;){const r=e,o=t,i=n;let a;if(r<=0)return o;if(FSharpList__get_IsEmpty(i))throw Operators_InvalidOp(SR_notEnoughElements);e=r-1,a=FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(i),void 0),o.tail=a,t=a,n=FSharpList__get_Tail(i)}})(e,n,t),o=List_empty();return r.tail=o,FSharpList__get_Tail(n)}function List_takeWhile(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),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=FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(o),void 0),r.tail=i,t=i,n=FSharpList__get_Tail(o)}})(n,t),o=List_empty();return r.tail=o,FSharpList__get_Tail(n)}function List_truncate(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=((e,t,n)=>{for(;;){const r=e,o=t,i=n;let a;if(r<=0)return o;if(FSharpList__get_IsEmpty(i))return o;e=r-1,a=FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(i),void 0),o.tail=a,t=a,n=FSharpList__get_Tail(i)}})(e,n,t),o=List_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 a;o=i<0?0:i;const s=0|List_defaultArg(t,r-1);return a=s>=r?r-1:s,a<o?List_empty():List_take(a-o+1,List_skip(o,n))}function List_splitAt(e,t){if(e<0)throw List_Operators_InvalidArg("index",List_SR_inputMustBeNonNegative);if(e>FSharpList__get_Length(t))throw List_Operators_InvalidOp(List_SR_notEnoughElements);return[List_take(e,t),List_skip(e,t)]}function List_exactlyOne(e){if(FSharpList__get_IsEmpty(e))throw List_Operators_InvalidArg("list",List_SR_inputSequenceEmpty);if(FSharpList__get_IsEmpty(FSharpList__get_Tail(e)))return FSharpList__get_Head(e);throw List_Operators_InvalidArg("list",List_SR_inputSequenceTooLong)}function List_tryExactlyOne(e){return!FSharpList__get_IsEmpty(e)&&FSharpList__get_IsEmpty(FSharpList__get_Tail(e))?some(FSharpList__get_Head(e)):void 0}function List_where(e,t){return List_filter(e,t)}function List_pairwise(e){return ofArray(pairwise(List_toArray(e)))}function List_windowed(e,t){return ofArray(map_1(ofArray,windowed_1(e,List_toArray(t))))}function List_splitInto(e,t){return ofArray(map_1(ofArray,splitInto_1(e,List_toArray(t))))}function List_transpose(e){return ofArray(map_1(ofArray,transpose_1(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_$ctor_Z23DD7291(i,FSharpList_$ctor_Z23DD7291(t,n))):FSharpList_$ctor_Z23DD7291(i,n)),List_empty(),n);return List_reverse(o?i:r+1===e?FSharpList_$ctor_Z23DD7291(t,i):(()=>{throw List_Operators_InvalidArg("index",List_SR_indexOutOfBounds)})())}function List_insertManyAt(e,t,n){let r=-1,o=!1;const i=ofSeq(t),a=List_fold((t,n)=>(r=r+1|0,r===e?(o=!0,FSharpList_$ctor_Z23DD7291(n,List_append(i,t))):FSharpList_$ctor_Z23DD7291(n,t)),List_empty(),n);return List_reverse(o?a:r+1===e?List_append(i,a):(()=>{throw List_Operators_InvalidArg("index",List_SR_indexOutOfBounds)})())}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 List_Operators_InvalidArg("index",List_SR_indexOutOfBounds);return o}function List_removeManyAt(e,t,n){if(e<0)throw List_Operators_InvalidArg("index","index must be within bounds of the list");const r=e+t|0;let o=-1;const i=List_filter(t=>(o=o+1|0,o<e||o>=r),n);if(r>o+1)throw List_Operators_InvalidArg("index","index must be within bounds of the list");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 List_Operators_InvalidArg("index",List_SR_indexOutOfBounds);return o}function List_randomShuffleBy(e,t){const n=List_toArray(t);return List_randomShuffleInPlaceBy(e,n),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 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 ofArray(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 ofArray(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)}var Seq_ArgumentOutOfRangeException_$ctor_Z721C83C5,Seq_disposeSafe,Seq_getEnumerator,Seq_isDisposable,Seq_isArrayLike,Seq_clear,Seq_class_type,Seq_some,Seq_value_1,Seq_KeyNotFoundException_$ctor_Z721C83C5,Seq_Operators_NullArgCheck,Seq_Operators_InvalidArg,Seq_Operators_Lock,Seq_Operators_InvalidOp,Seq_tryFindBack_1,Seq_tryFindIndexBack_1,Seq_foldBack_1,item_1,tryHead_1,tryItem_1,mapFold_1,mapFoldBack_1,reduceBack_1,reverse_1,Seq_scanBack_1,pairwise_1,Seq_splitInto_1,Seq_windowed_1,Seq_permute_1,Seq_chunkBySize_1,Seq_randomShuffleInPlaceBy,Seq_randomChoiceBy_1,randomChoiceWith_1,randomChoice_1,Seq_randomChoicesBy_1,Seq_randomSampleBy_1,Seq_FSharpList,tryHead_2,isEmpty_1,tryItem_2,length_1,Seq_min_1,Seq_SR_inputMustBeNonNegative,Seq_SR_indexOutOfBounds,Seq_nonSeeded;const SR_enumerationAlreadyFinished="Enumeration already finished.",SR_enumerationNotStarted="Enumeration has not started. Call MoveNext.",SR_inputMustBePositive="The input must be positive.",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 a=()=>{if(i=!0,null!=n){const e=n;try{disposeSafe(e)}finally{n=void 0}}if(null!=t){const e=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 s=t;if(null!=s)if(null!=n){const e=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=s;e["System.Collections.IEnumerator.MoveNext"]()?(i=e["System.Collections.Generic.IEnumerator`1.get_Current"](),n=getEnumerator(i)):(a(),o=!1)}else t=getEnumerator(e)}return Option_value(o)}},()=>{i||a()})}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 a=()=>{if(null!=i){const e=Option_value(i);try{n(e)}finally{i=void 0}}},s=()=>{try{a()}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 s(),e}return null!=n?(r=n,!0):(s(),!1)}return!1},a)}function Enumerator_unfold(e,t){let n,r=t;return Enumerator_FromFunctions$1_$ctor_58C54629(()=>{if(null!=n){const e=n[0];return n[1],e}return Enumerator_notStarted()},()=>{if(n=e(r),null!=n){n[0];const e=n[1];return r=e,!0}return!1},()=>{})}function Seq_indexNotFound(){throw Seq_KeyNotFoundException_$ctor_Z721C83C5(Seq_SR_keyNotFoundAlt)}function mkSeq(e){return Enumerator_Seq_$ctor_673A07F2(e)}function Seq_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 Seq_ofArray(e){return e}function Seq_toArray(e){if(isArrayLike(e))return Array.from(e);if(e instanceof FSharpList)return List_toArray(e);{const t=[],n=getEnumerator(e);try{for(;n["System.Collections.IEnumerator.MoveNext"]();)t.push(n["System.Collections.Generic.IEnumerator`1.get_Current"]());return t.slice()}finally{disposeSafe(n)}}}function ofList(e){return e}function toList(e){return isArrayLike(e)?ofArray(e):e instanceof FSharpList?e: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(()=>Seq_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=>{disposeSafe(e)})}function Seq_compareWith(e,t,n){const r=Seq_ofSeq(t);try{const t=Seq_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=Seq_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,Seq_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,Seq_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,a=!1,s=!1;const l=()=>{try{let t;if(null==r){const n=Seq_getEnumerator(e);r=n,t=n}else t=r;return t["System.Collections.IEnumerator.MoveNext"]()?(o=Seq_some(t["System.Collections.Generic.IEnumerator`1.get_Current"]()),!0):(s=!0,!1)}catch(e){if(i)throw e;{const o=e;if(0!==t(o)){if(i=!0,null==r);else{const e=r;try{Seq_disposeSafe(e)}catch(e){}r=void 0}return r=Seq_getEnumerator(n(o)),l()}throw e}}};return Enumerator_FromFunctions$1_$ctor_58C54629(()=>(a?s&&Enumerator_alreadyFinished():Enumerator_notStarted(),null!=o?Seq_value_1(o):Enumerator_alreadyFinished()),()=>(a||(a=!0),!s&&l()),()=>{null==r||Seq_disposeSafe(r)})})}function Seq_filter(e,t){return Seq_choose(t=>e(t)?some(t):void 0,t)}function Seq_exists(e,t){const n=Seq_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=Seq_ofSeq(t);try{const t=Seq_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=Seq_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 Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceTooLong);return e}throw Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty)}finally{Seq_disposeSafe(t)}}function Seq_tryExactlyOne(e){const t=Seq_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=Seq_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=some(r))}return t}finally{disposeSafe(n)}}function Seq_find(e,t){const n=Seq_tryFind(e,t);return null==n?Seq_indexNotFound():Seq_value_1(n)}function Seq_tryFindBack(e,t){return Seq_tryFindBack_1(e,Seq_toArray(t))}function Seq_findBack(e,t){const n=Seq_tryFindBack(e,t);return null==n?Seq_indexNotFound():Seq_value_1(n)}function Seq_tryFindIndex(e,t){const n=Seq_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|n}function Seq_tryFindIndexBack(e,t){return Seq_tryFindIndexBack_1(e,Seq_toArray(t))}function Seq_findIndexBack(e,t){const n=Seq_tryFindIndexBack(e,t);return null==n?(Seq_indexNotFound(),-1):0|n}function Seq_fold(e,t,n){const r=Seq_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 Seq_foldBack_1(e,Seq_toArray(t),n)}function Seq_fold2(e,t,n,r){const o=Seq_ofSeq(n);try{const n=Seq_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 a=r;for(let t=(0|Seq_min_1(o.length,i.length))-1;t>=0;t--)a=e(item_1(t,o),item_1(t,i),a);return a}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 Seq_FSharpList)return tryHead_2(e);{const t=Seq_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 Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty);return Seq_value_1(t)}function Seq_initialize(e,t){if(e<0)throw Seq_Operators_InvalidArg("count",Seq_SR_inputMustBeNonNegative);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 Seq_FSharpList)return isEmpty_1(e);{const t=Seq_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 Seq_FSharpList)return tryItem_2(e,t);{const n=Seq_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 Seq_Operators_InvalidArg("index",Seq_SR_notEnoughElements);return Seq_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=Seq_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 Seq_Operators_InvalidArg("source",Seq_SR_notEnoughElements);return Seq_value_1(t)}function Seq_length(e){if(Seq_isArrayLike(e))return 0|e.length;if(e instanceof Seq_FSharpList)return 0|length_1(e);{const t=Seq_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(()=>Seq_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(()=>Seq_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(()=>[Seq_ofSeq(t),Seq_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(()=>[Seq_ofSeq(t),Seq_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(()=>[Seq_ofSeq(t),Seq_ofSeq(n),Seq_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!=Seq_value_1(r)?(e=0,t=Seq_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=Seq_value_1(r);else{const n=Seq_getEnumerator(t);r=Seq_some(n),e=n}if(null==e);else{const t=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=Seq_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():Seq_value_1(n)}function Seq_reduce(e,t){const n=Seq_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 Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty)}finally{disposeSafe(n)}}function Seq_reduceBack(e,t){const n=Seq_toArray(t);if(n.length>0)return reduceBack_1(e,n);throw Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty)}function Seq_replicate(e,t){if(e<0)throw Seq_ArgumentOutOfRangeException_$ctor_Z721C83C5("count");return Seq_initialize(e,e=>t)}function Seq_reverse(e){return delay(()=>Seq_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(()=>Seq_ofArray(Seq_scanBack_1(e,Seq_toArray(t),n)))}function Seq_skip(e,t){return mkSeq(()=>{const n=Seq_ofSeq(t);try{for(let t=1;t<=e;t++)if(!n["System.Collections.IEnumerator.MoveNext"]())throw Seq_Operators_InvalidOp(Seq_SR_notEnoughElements);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 mkSeq(()=>{const t=Seq_ofSeq(e);try{if(!t["System.Collections.IEnumerator.MoveNext"]())throw Seq_Operators_InvalidArg("source",Seq_SR_notEnoughElements);return Enumerator_enumerateThenFinally(()=>{},t)}catch(e){throw Seq_disposeSafe(t),e}})}function Seq_take(e,t){if(e<0)throw Seq_Operators_InvalidArg("count",Seq_SR_inputMustBeNonNegative);return generateIndexed(()=>Seq_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 Seq_Operators_InvalidOp(Seq_SR_notEnoughElements)}},e=>{Seq_disposeSafe(e)})}function Seq_takeWhile(e,t){return generate(()=>Seq_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(()=>Seq_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(()=>Seq_ofArray(pairwise_1(Seq_toArray(e))))}function Seq_splitInto(e,t){if(e<1)throw Seq_Operators_InvalidArg("count",SR_inputMustBePositive);return delay(()=>Seq_ofArray(Seq_splitInto_1(e,Seq_toArray(t))))}function Seq_windowed(e,t){if(e<1)throw Seq_Operators_InvalidArg("windowSize",SR_inputMustBePositive);return delay(()=>Seq_ofArray(Seq_windowed_1(e,Seq_toArray(t))))}function Seq_transpose(e){return delay(()=>{const t=[],n=Seq_getEnumerator(e);try{for(;n["System.Collections.IEnumerator.MoveNext"]();){let e,r=0,o=n["System.Collections.Generic.IEnumerator`1.get_Current"]();e=Seq_getEnumerator(o);try{for(;e["System.Collections.IEnumerator.MoveNext"]();){const n=e["System.Collections.Generic.IEnumerator`1.get_Current"]();r===t.length&&t.push([]),item_1(r,t).push(n),r=r+1|0}}finally{Seq_disposeSafe(e)}}}finally{Seq_disposeSafe(n)}return Seq_map(e=>e,t)})}function Seq_sortWith(e,t){return delay(()=>{const n=Seq_toArray(t);return n.sort(e),Seq_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 Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty);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 Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty);return n.DivideByInt(o,r)}function Seq_permute(e,t){return delay(()=>Seq_ofArray(Seq_permute_1(e,Seq_toArray(t))))}function Seq_chunkBySize(e,t){if(e<1)throw Seq_Operators_InvalidArg("chunkSize",SR_inputMustBePositive);return delay(()=>Seq_ofArray(Seq_chunkBySize_1(e,Seq_toArray(t))))}function Seq_insertAt(e,t,n){let r=!1;if(e<0)throw Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds);return generateIndexed(()=>Seq_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 Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds)},e=>{Seq_disposeSafe(e)})}function Seq_insertManyAt(e,t,n){let r=-1;if(e<0)throw Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds);return generateIndexed(()=>[Seq_ofSeq(n),Seq_ofSeq(t)],(t,n)=>{const o=n[0],i=n[1];let a;if(t===e&&(r=0),0===r?i["System.Collections.IEnumerator.MoveNext"]()?a=Seq_some(i["System.Collections.Generic.IEnumerator`1.get_Current"]()):(r=1,a=void 0):a=void 0,null!=a)return Seq_some(Seq_value_1(a));if(o["System.Collections.IEnumerator.MoveNext"]())return Seq_some(o["System.Collections.Generic.IEnumerator`1.get_Current"]());if(r<1)throw Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds)},e=>{Seq_disposeSafe(e[0]),Seq_disposeSafe(e[1])})}function Seq_removeAt(e,t){let n=!1;if(e<0)throw Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds);return generateIndexed(()=>Seq_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 Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds)},e=>{Seq_disposeSafe(e)})}function Seq_removeManyAt(e,t,n){if(e<0)throw Seq_Operators_InvalidArg("index","index must be within bounds of the array");const r=e+t|0;return delay(()=>{let t=-1;return Seq_append(Seq_filter(n=>(t=t+1|0,t<e||t>=r),n),delay(()=>{if(t<e)throw Seq_Operators_InvalidArg("index","index must be within bounds of the array");return Seq_empty()}))})}function Seq_updateAt(e,t,n){let r=!1;if(e<0)throw Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds);return generateIndexed(()=>Seq_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 Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds)},e=>{Seq_disposeSafe(e)})}function Seq_randomShuffleBy(e,t){const n=Seq_toArray(t);return Seq_randomShuffleInPlaceBy(e,n),Seq_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 Seq_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 Seq_ofArray(Seq_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 Seq_ofArray(Seq_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_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,System_Collections_Generic_Operators_InvalidOp,Map_class_type,record_type,list_type,option_type,bool_type,Map_value_1,Map_some,Map_KeyNotFoundException_$ctor,Map_fill,map_2,Map_unfold,Map_map_1,pick_1,tryPick_1,union_type,Result_equals,Result_singleton,Result_empty,Result_some,Violation_union_type,Violation_record_type,int32_type,string_type,Violation_list_type,Report_record_type,Report_int32_type,Report_string_type,Report_list_type,Report_class_type,Report_EnergyViolation_$reflection;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(Array_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 System_Collections_Generic_Operators_InvalidOp("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 System_Collections_Generic_Operators_InvalidOp("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(Array_item(Queue$1__toIndex_Z524259A4(e,t),e.contents)),delay(()=>(t=t+1|0,Seq_empty())))))})}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){if(t instanceof MapTreeNode$2){const r=t;e=MapTreeModule_sizeAux(n+1,MapTreeNode$2__get_Left(r)),t=MapTreeNode$2__get_Right(r);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,a,s;a=null!=e?e instanceof MapTreeNode$2?(o=e,MapTreeNode$2__get_Height(o)):1:0,s=null!=r?r instanceof MapTreeNode$2?(i=r,MapTreeNode$2__get_Height(i)):1:0;const l=0|(a<s?s:a);return 0===l?MapTreeLeaf$2_$ctor_5BDDA1(t,n):MapTreeNode$2_$ctor_Z39DE9543(t,n,e,r,l+1)}function MapTreeModule_rebalance(e,t,n,r){let o,i,a,s,l,_,u,c,d,p;if(d=null!=e?e instanceof MapTreeNode$2?(o=e,MapTreeNode$2__get_Height(o)):1:0,p=null!=r?r instanceof MapTreeNode$2?(i=r,MapTreeNode$2__get_Height(i)):1:0,p>d+2){const o=Option_value(r);if(o instanceof MapTreeNode$2){const r=o;if(a=MapTreeNode$2__get_Left(r),(null!=a?(s=a,s instanceof MapTreeNode$2?(l=s,MapTreeNode$2__get_Height(l)):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(_=MapTreeNode$2__get_Right(e),(null!=_?(u=_,u instanceof MapTreeNode$2?(c=u,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=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=n,a=0|r.Compare(o,MapTreeLeaf$2__get_Key(i));if(0===a)return some(MapTreeLeaf$2__get_Value(i));if(i instanceof MapTreeNode$2){const s=i;e=r,t=o,n=a<0?MapTreeNode$2__get_Left(s):MapTreeNode$2__get_Right(s);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,a=t,s=[r,o];if(null!=n){const l=n;if(l instanceof MapTreeNode$2){const _=l,u=MapTreeModule_partitionAux(i,a,MapTreeNode$2__get_Right(_),s[0],s[1]),c=MapTreeModule_partition1(i,a,MapTreeLeaf$2__get_Key(_),MapTreeLeaf$2__get_Value(_),u[0],u[1]);e=i,t=a,n=MapTreeNode$2__get_Left(_),r=c[0],o=c[1];continue e}return MapTreeModule_partition1(i,a,MapTreeLeaf$2__get_Key(l),MapTreeLeaf$2__get_Value(l),s[0],s[1])}return s}}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,a=r;if(null!=n){const s=n;if(s instanceof MapTreeNode$2){const l=s,_=MapTreeModule_filterAux(o,i,MapTreeNode$2__get_Left(l),a),u=MapTreeModule_filter1(o,i,MapTreeLeaf$2__get_Key(l),MapTreeLeaf$2__get_Value(l),_);e=o,t=i,n=MapTreeNode$2__get_Right(l),r=u;continue e}return MapTreeModule_filter1(o,i,MapTreeLeaf$2__get_Key(s),MapTreeLeaf$2__get_Value(s),a)}return a}}function MapTreeModule_filter(e,t,n){return MapTreeModule_filterAux(e,t,n,MapTreeModule_empty())}function MapTreeModule_spliceOutSuccessor(e){if(null!=e){const t=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=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=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=n,a=0|r.Compare(o,MapTreeLeaf$2__get_Key(i));if(i instanceof MapTreeNode$2){const s=i;if(a<0){e=r,t=o,n=MapTreeNode$2__get_Left(s);continue e}if(0===a)return!0;e=r,t=o,n=MapTreeNode$2__get_Right(s);continue e}return 0===a}return!1}}function MapTreeModule_iterOpt(e,t){e:for(;;){const n=e;if(null!=t){const r=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=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=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=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=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=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=t;if(i instanceof MapTreeNode$2){const a=i,s=MapTreeModule_foldBackOpt(r,MapTreeNode$2__get_Right(a),o),l=r(MapTreeLeaf$2__get_Key(a),MapTreeLeaf$2__get_Value(a),s);e=r,t=MapTreeNode$2__get_Left(a),n=l;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=n;if(i instanceof MapTreeNode$2){const a=i;e=r,t=r(MapTreeModule_foldOpt(r,o,MapTreeNode$2__get_Left(a)),MapTreeLeaf$2__get_Key(a),MapTreeLeaf$2__get_Value(a)),n=MapTreeNode$2__get_Right(a);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 a=(r,o,i)=>{e:for(;;){const s=r,l=i;if(null!=o){const _=o;if(_ instanceof MapTreeNode$2){const u=_,c=0|e.Compare(t,MapTreeLeaf$2__get_Key(u)),d=0|e.Compare(MapTreeLeaf$2__get_Key(u),n),p=c<0?a(s,MapTreeNode$2__get_Left(u),l):l,m=c<=0&&d<=0?s(MapTreeLeaf$2__get_Key(u),MapTreeLeaf$2__get_Value(u),p):p;if(d<0){r=s,o=MapTreeNode$2__get_Right(u),i=m;continue e}return m}{const r=0|e.Compare(t,MapTreeLeaf$2__get_Key(_)),o=0|e.Compare(MapTreeLeaf$2__get_Key(_),n);return r<=0&&o<=0?s(MapTreeLeaf$2__get_Key(_),MapTreeLeaf$2__get_Value(_),l):l}}return l}};return 1===e.Compare(t,n)?i:a(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=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 a=i["System.Collections.Generic.IEnumerator`1.get_Current"]();e=r,t=MapTreeModule_add(r,a[0],a[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=Array_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 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}Equals(e){return this===e}GetHashCode(){return physicalHash(this)}}function MapTreeModule_MapIterator$2_$reflection(e,t){return record_type("Map.MapTreeModule.MapIterator`2",[e,t],MapTreeModule_MapIterator$2,()=>[["stack",list_type(option_type(MapTreeLeaf$2_$reflection(e,t)))],["started",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){if(r instanceof MapTreeNode$2){const t=r;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 Operators_InvalidOp("Enumeration has not started. Call MoveNext.")}function MapTreeModule_alreadyFinished(){throw Operators_InvalidOp("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=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(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=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=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 values cannot be mutated.")}"System.Collections.Generic.ICollection`1.Clear"(){throw NotSupportedException_$ctor_Z721C83C5("Map values cannot be mutated.")}"System.Collections.Generic.ICollection`1.Remove2B595"(e){throw NotSupportedException_$ctor_Z721C83C5("Map values 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 NotSupportedException_$ctor_Z721C83C5("Map values cannot be mutated.")}delete(e){throw NotSupportedException_$ctor_Z721C83C5("Map values 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 NotSupportedException_$ctor_Z721C83C5("Map values 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)}function FSharpResult$2_Ok(e){return new FSharpResult$2(0,[e])}function FSharpResult$2_Error$(e){return new FSharpResult$2(1,[e])}class FSharpResult$2 extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Ok","Error"]}}function FSharpResult$2_$reflection(e,t){return union_type("FSharp.Core.FSharpResult`2",[e,t],FSharpResult$2,()=>[[["ResultValue",e]],[["ErrorValue",t]]])}function Result_Map(e,t){return 0===t.tag?FSharpResult$2_Ok(e(t.fields[0])):FSharpResult$2_Error$(t.fields[0])}function Result_MapError(e,t){return 0===t.tag?FSharpResult$2_Ok(t.fields[0]):FSharpResult$2_Error$(e(t.fields[0]))}function Result_Bind(e,t){return 0===t.tag?e(t.fields[0]):FSharpResult$2_Error$(t.fields[0])}function Result_IsOk(e){return 0===e.tag}function Result_IsError(e){return 0!==e.tag}function Result_Contains(e,t){return 0===t.tag&&Result_equals(t.fields[0],e)}function Result_Count(e){return 0===e.tag?1:0}function Result_DefaultValue(e,t){return 0===t.tag?t.fields[0]:e}function Result_DefaultWith(e,t){return 0===t.tag?t.fields[0]:e(t.fields[0])}function Result_Exists(e,t){return 0===t.tag&&e(t.fields[0])}function Result_Fold(e,t,n){return 0===n.tag?e(t,n.fields[0]):t}function Result_FoldBack(e,t,n){return 0===t.tag?e(t.fields[0],n):n}function Result_ForAll(e,t){return 0!==t.tag||e(t.fields[0])}function Result_Iterate(e,t){0===t.tag&&e(t.fields[0])}function Result_ToArray(e){return 0===e.tag?[e.fields[0]]:[]}function Result_ToList(e){return 0===e.tag?Result_singleton(e.fields[0]):Result_empty()}function Result_ToOption(e){return 0===e.tag?Result_some(e.fields[0]):void 0}function Result_ToValueOption(e){return 0===e.tag?Result_some(e.fields[0]):void 0}function error(e){console.error(e)}function output(e){console.log(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 Violation_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","ErrorShadowing","RecoveryDominance","OversizedRecoveryBlock","Suppression","ParseDontValidate"]}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 ErrorShadowing=new ViolationType(12,[]);static RecoveryDominance=new ViolationType(13,[]);static OversizedRecoveryBlock=new ViolationType(14,[]);static Suppression=new ViolationType(15,[]);static ParseDontValidate=new ViolationType(16,[])}function ViolationType_$reflection(){return Violation_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",int32_type],["Weight",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",int32_type],["Column",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 13:return"recovery-dominance";case 14:return"oversized-recovery-block";case 12:return"error-shadowing";case 16:return"parse-dont-validate";case 15:return"suppression";default:return"nesting"}}function violationRuleName(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"PrimitiveObsession";case 9:return"MatchOpportunity";case 10:return"LogicalControlFlow";case 11:return"OpaqueBoolean";case 12:return"ErrorShadowing";case 13:return"RecoveryDominance";case 14:return"OversizedRecoveryBlock";case 16:return"ParseDontValidate";case 15:return"Suppression";default:return"Nesting"}}function violationDisplayName(e){switch(e.tag){case 12:return"Broad Protected Scope";case 13:return"Recovery Dominance";case 14:return"Oversized Recovery Block";default:return violationTypeName(e)}}function violationRuleId(e){switch(e.tag){case 1:return"ESA002";case 2:return"ESA003";case 3:return"ESA004";case 4:return"ESA005";case 5:return"ESA006";case 6:return"ESA007";case 7:return"ESA008";case 8:return"ESA009";case 9:return"ESA010";case 10:return"ESA011";case 11:return"ESA012";case 12:return"ESA013";case 15:return"ESA014";case 16:return"ESA015";case 13:return"ESA016";case 14:return"ESA017";default:return"ESA001"}}function violationHelpUri(e){switch(e.tag){case 1:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/cyclomatic-complexity.md";case 2:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/cognitive-complexity.md";case 3:case 4:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/file-coherence.md";case 5:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/magic-values.md";case 6:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/parameter-explosion.md";case 7:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/inversion-opportunities.md";case 8:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/primitive-obsession.md";case 9:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/match-opportunities.md";case 10:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/logical-operator-control-flow.md";case 11:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/opaque-boolean-literal.md";case 13:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/recovery-dominance.md";case 14:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/oversized-recovery-block.md";case 12:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/error-shadowing.md";case 16:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/parse-dont-validate.md";case 15:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/suppression.md";default:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/excessive-nesting.md"}}function severityName(e){switch(e.tag){case 1:return"medium";case 2:return"high";default:return"low"}}const mediumWeight=4,highWeight=9;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+mediumWeight*e.Medium+highWeight*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(ofArray(["# Energy State Report","",(t=r-n|0,toText(printf("**%d file%s scanned** — %d with no findings, %d with findings"))(r)(o)(n)(t)),"","| File | Score | High | Medium | Low |","| --- | --- | --- | --- | --- |"]),List_append(i,ofArray(["",toText(printf("**Total score: %d** (%d high, %d medium, %d low)"))(e.TotalScore)(e.TotalCounts.High)(e.TotalCounts.Medium)(e.TotalCounts.Low)]))))}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 Task_delay(e,t){return new Promise((n,r)=>{if(t?.isCancelled)return void r(new OperationCanceledException);let o;const i=-1===e?void 0:setTimeout(()=>{void 0!==o&&t.removeListener(o),n()},e);null!=t&&(o=t.addListener(()=>{clearTimeout(i),r(new OperationCanceledException)}))})}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 task(){return TaskBuilder_singleton}const external_node_path_namespaceObject=require("node:path");var web_tree_sitter=__webpack_require__(132),TreeSitter_record_type,TreeSitter_int32_type,Language,Parser,TreeSitter_task;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",TreeSitter_int32_type],["Column",TreeSitter_int32_type]])}const initialization=new Lazy(()=>web_tree_sitter.iX.init());function init(){return initialization.Value}function withParsedTree(e,t,n){const r=e.parse(t);try{return n(r.rootNode)}finally{r.delete()}}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 ofArray(e.children)}function nodeNamedChildren(e){return ofArray(e.namedChildren)}function nodeField(e,t){const n=t.childForFieldName(e);return equals(n,defaultOf())?void 0:some(n)}function nodeParent(e){const t=e.parent;return equals(t,defaultOf())?void 0:some(t)}function nodePreviousNamedSibling(e){const t=e.previousNamedSibling;return equals(t,defaultOf())?void 0:some(t)}function parseWith(e,t){const n=TreeSitter_task();return n.Run(n.Delay(()=>n.Bind(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 external_node_fs_namespaceObject=require("node:fs"),external_node_child_process_namespaceObject=require("node:child_process");function attempt(e){try{return new FSharpResult$2(0,[e()])}catch(e){return new FSharpResult$2(1,[Types_toString(e)])}}function readFileSyncSafe(e,t){return attempt(()=>(0,external_node_fs_namespaceObject.readFileSync)(e,t))}function execFileSyncSafe(e,t,n){return attempt(()=>(0,external_node_child_process_namespaceObject.execFileSync)(e,t,n))}function jsonParseResult(e){try{const t=JSON.parse(e);return null===t||"object"!=typeof t||Array.isArray(t)?new FSharpResult$2(1,["Expected a JSON object"]):new FSharpResult$2(0,[t])}catch(e){return new FSharpResult$2(1,[Types_toString(e)])}}var Config_union_type,Config_string_type,Config_record_type,Config_bool_type,Config_int32_type,float64_type,Config_list_type,Config_option_type;class ConfigError extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["ConfigNotFound","ConfigReadFailed","ConfigInvalid"]}}function ConfigError_$reflection(){return Config_union_type("Energy.Core.Config.ConfigError",[],ConfigError,()=>[[["path",Config_string_type]],[["path",Config_string_type],["message",Config_string_type]],[["path",Config_string_type],["message",Config_string_type]]])}function configErrorMessage(e){switch(e.tag){case 1:return"Could not read configuration "+e.fields[0]+": "+e.fields[1];case 2:return"Invalid configuration "+e.fields[0]+": "+e.fields[1];default:return"Configuration file not found: "+e.fields[0]}}class NestingThresholds extends Record{constructor(e,t,n){super(),this.Enabled=e,this.MediumThreshold=0|t,this.HighThreshold=0|n}}function NestingThresholds_$reflection(){return Config_record_type("Energy.Core.Config.NestingThresholds",[],NestingThresholds,()=>[["Enabled",Config_bool_type],["MediumThreshold",Config_int32_type],["HighThreshold",Config_int32_type]])}class CyclomaticThresholds extends Record{constructor(e,t,n){super(),this.Enabled=e,this.MediumThreshold=0|t,this.HighThreshold=0|n}}function CyclomaticThresholds_$reflection(){return Config_record_type("Energy.Core.Config.CyclomaticThresholds",[],CyclomaticThresholds,()=>[["Enabled",Config_bool_type],["MediumThreshold",Config_int32_type],["HighThreshold",Config_int32_type]])}class CognitiveThresholds extends Record{constructor(e,t,n){super(),this.Enabled=e,this.MediumThreshold=0|t,this.HighThreshold=0|n}}function CognitiveThresholds_$reflection(){return Config_record_type("Energy.Core.Config.CognitiveThresholds",[],CognitiveThresholds,()=>[["Enabled",Config_bool_type],["MediumThreshold",Config_int32_type],["HighThreshold",Config_int32_type]])}class CoherenceThresholds extends Record{constructor(e,t,n,r,o,i,a,s,l,_,u,c,d,p,m,f){super(),this.Enabled=e,this.LargeFunctionLines=0|t,this.MaxLargeFunctions=0|n,this.SingleDomainNameShare=r,this.MaxTypeDiversityRatio=o,this.MinTypedCoverage=i,this.SiblingOpenThreshold=0|a,this.ImportBreadthThreshold=0|s,this.HighImportBreadthThreshold=0|l,this.MemberImportFanOutThreshold=0|_,this.UtilsFileFunctionCount=0|u,this.GenericFunctionCount=0|c,this.HighFunctionCount=0|d,this.MethodCountMedium=0|p,this.MethodCountHigh=0|m,this.LargeFunctionSeverityMultiplier=f}}function CoherenceThresholds_$reflection(){return Config_record_type("Energy.Core.Config.CoherenceThresholds",[],CoherenceThresholds,()=>[["Enabled",Config_bool_type],["LargeFunctionLines",Config_int32_type],["MaxLargeFunctions",Config_int32_type],["SingleDomainNameShare",float64_type],["MaxTypeDiversityRatio",float64_type],["MinTypedCoverage",float64_type],["SiblingOpenThreshold",Config_int32_type],["ImportBreadthThreshold",Config_int32_type],["HighImportBreadthThreshold",Config_int32_type],["MemberImportFanOutThreshold",Config_int32_type],["UtilsFileFunctionCount",Config_int32_type],["GenericFunctionCount",Config_int32_type],["HighFunctionCount",Config_int32_type],["MethodCountMedium",Config_int32_type],["MethodCountHigh",Config_int32_type],["LargeFunctionSeverityMultiplier",float64_type]])}class MatchOpportunityThresholds extends Record{constructor(e,t){super(),this.Enabled=e,this.MinBranches=0|t}}function MatchOpportunityThresholds_$reflection(){return Config_record_type("Energy.Core.Config.MatchOpportunityThresholds",[],MatchOpportunityThresholds,()=>[["Enabled",Config_bool_type],["MinBranches",Config_int32_type]])}class ErrorShadowingModeThresholds extends Record{constructor(e,t,n){super(),this.Threshold=e,this.HighThreshold=t,this.MinItems=0|n}}function ErrorShadowingModeThresholds_$reflection(){return Config_record_type("Energy.Core.Config.ErrorShadowingModeThresholds",[],ErrorShadowingModeThresholds,()=>[["Threshold",float64_type],["HighThreshold",float64_type],["MinItems",Config_int32_type]])}class RecoveryBlockThresholds extends Record{constructor(e){super(),this.MaxLines=0|e}}function RecoveryBlockThresholds_$reflection(){return Config_record_type("Energy.Core.Config.RecoveryBlockThresholds",[],RecoveryBlockThresholds,()=>[["MaxLines",Config_int32_type]])}class ErrorShadowingThresholds extends Record{constructor(e,t,n,r,o,i){super(),this.Enabled=e,this.ProtectedScope=t,this.Recovery=n,this.RecoveryDominanceEnabled=r,this.OversizedRecoveryBlockEnabled=o,this.RecoveryBlock=i}}function ErrorShadowingThresholds_$reflection(){return Config_record_type("Energy.Core.Config.ErrorShadowingThresholds",[],ErrorShadowingThresholds,()=>[["Enabled",Config_bool_type],["ProtectedScope",ErrorShadowingModeThresholds_$reflection()],["Recovery",ErrorShadowingModeThresholds_$reflection()],["RecoveryDominanceEnabled",Config_bool_type],["OversizedRecoveryBlockEnabled",Config_bool_type],["RecoveryBlock",RecoveryBlockThresholds_$reflection()]])}class ParameterCountThresholds extends Record{constructor(e,t,n){super(),this.Enabled=e,this.MediumThreshold=0|t,this.HighThreshold=0|n}}function ParameterCountThresholds_$reflection(){return Config_record_type("Energy.Core.Config.ParameterCountThresholds",[],ParameterCountThresholds,()=>[["Enabled",Config_bool_type],["MediumThreshold",Config_int32_type],["HighThreshold",Config_int32_type]])}class PrimitiveObsessionThresholds extends Record{constructor(e){super(),this.Enabled=e}}function PrimitiveObsessionThresholds_$reflection(){return Config_record_type("Energy.Core.Config.PrimitiveObsessionThresholds",[],PrimitiveObsessionThresholds,()=>[["Enabled",Config_bool_type]])}class OpaqueBooleanThresholds extends Record{constructor(e,t){super(),this.Enabled=e,this.IncludeTestFiles=t}}function OpaqueBooleanThresholds_$reflection(){return Config_record_type("Energy.Core.Config.OpaqueBooleanThresholds",[],OpaqueBooleanThresholds,()=>[["Enabled",Config_bool_type],["IncludeTestFiles",Config_bool_type]])}class ParseDontValidateThresholds extends Record{constructor(e){super(),this.Enabled=e}}function ParseDontValidateThresholds_$reflection(){return Config_record_type("Energy.Core.Config.ParseDontValidateThresholds",[],ParseDontValidateThresholds,()=>[["Enabled",Config_bool_type]])}class LogicalControlFlowThresholds extends Record{constructor(e){super(),this.Enabled=e}}function LogicalControlFlowThresholds_$reflection(){return Config_record_type("Energy.Core.Config.LogicalControlFlowThresholds",[],LogicalControlFlowThresholds,()=>[["Enabled",Config_bool_type]])}class InversionThresholds extends Record{constructor(e){super(),this.Enabled=e}}function InversionThresholds_$reflection(){return Config_record_type("Energy.Core.Config.InversionThresholds",[],InversionThresholds,()=>[["Enabled",Config_bool_type]])}class MagicNumberOptions extends Record{constructor(e,t,n){super(),this.Enabled=e,this.Allowlist=t,this.IncludeTestFiles=n}}function MagicNumberOptions_$reflection(){return Config_record_type("Energy.Core.Config.MagicNumberOptions",[],MagicNumberOptions,()=>[["Enabled",Config_bool_type],["Allowlist",Config_list_type(float64_type)],["IncludeTestFiles",Config_bool_type]])}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 Config_record_type("Energy.Core.Config.MagicStringOptions",[],MagicStringOptions,()=>[["Enabled",Config_bool_type],["MinDuplicates",Config_int32_type],["Allowlist",Config_list_type(Config_string_type)],["IncludeTestFiles",Config_bool_type]])}class AnalyzeOptions extends Record{constructor(e,t,n,r,o,i,a,s,l,_,u,c,d,p){super(),this.Nesting=e,this.Cyclomatic=t,this.Cognitive=n,this.Coherence=r,this.MatchOpportunity=o,this.ParameterCount=i,this.MagicNumber=a,this.MagicString=s,this.PrimitiveObsession=l,this.OpaqueBoolean=_,this.ParseDontValidate=u,this.LogicalControlFlow=c,this.Inversion=d,this.ErrorShadowing=p}}function AnalyzeOptions_$reflection(){return Config_record_type("Energy.Core.Config.AnalyzeOptions",[],AnalyzeOptions,()=>[["Nesting",NestingThresholds_$reflection()],["Cyclomatic",CyclomaticThresholds_$reflection()],["Cognitive",CognitiveThresholds_$reflection()],["Coherence",CoherenceThresholds_$reflection()],["MatchOpportunity",MatchOpportunityThresholds_$reflection()],["ParameterCount",ParameterCountThresholds_$reflection()],["MagicNumber",MagicNumberOptions_$reflection()],["MagicString",MagicStringOptions_$reflection()],["PrimitiveObsession",PrimitiveObsessionThresholds_$reflection()],["OpaqueBoolean",OpaqueBooleanThresholds_$reflection()],["ParseDontValidate",ParseDontValidateThresholds_$reflection()],["LogicalControlFlow",LogicalControlFlowThresholds_$reflection()],["Inversion",InversionThresholds_$reflection()],["ErrorShadowing",ErrorShadowingThresholds_$reflection()]])}const defaultAnalyzeOptions=new AnalyzeOptions(new NestingThresholds(!0,3,5),new CyclomaticThresholds(!0,10,15),new CognitiveThresholds(!0,15,25),new CoherenceThresholds(!0,20,5,.7,.4,.5,7,10,15,10,8,12,15,15,25,1.5),new MatchOpportunityThresholds(!0,3),new ParameterCountThresholds(!0,5,8),new MagicNumberOptions(!0,ofArray([0,1,-1,2]),!1),new MagicStringOptions(!0,2,ofArray(["","utf-8","__main__"]),!1),new PrimitiveObsessionThresholds(!0),new OpaqueBooleanThresholds(!0,!1),new ParseDontValidateThresholds(!0),new LogicalControlFlowThresholds(!0),new InversionThresholds(!0),new ErrorShadowingThresholds(!0,new ErrorShadowingModeThresholds(.5,.7,8),new ErrorShadowingModeThresholds(.5,.7,5),!0,!0,new RecoveryBlockThresholds(20))),defaultNestingThresholds=defaultAnalyzeOptions.Nesting,defaultCyclomaticThresholds=defaultAnalyzeOptions.Cyclomatic,defaultCognitiveThresholds=defaultAnalyzeOptions.Cognitive,defaultCoherenceThresholds=defaultAnalyzeOptions.Coherence,defaultMatchOpportunityThresholds=defaultAnalyzeOptions.MatchOpportunity,defaultParameterCountThresholds=defaultAnalyzeOptions.ParameterCount,defaultPrimitiveObsessionThresholds=defaultAnalyzeOptions.PrimitiveObsession,defaultOpaqueBooleanThresholds=defaultAnalyzeOptions.OpaqueBoolean,defaultLogicalControlFlowThresholds=defaultAnalyzeOptions.LogicalControlFlow,defaultInversionThresholds=defaultAnalyzeOptions.Inversion,defaultErrorShadowingThresholds=defaultAnalyzeOptions.ErrorShadowing,defaultMagicNumberOptions=defaultAnalyzeOptions.MagicNumber,defaultMagicStringOptions=defaultAnalyzeOptions.MagicString;class EnergyColors extends Record{constructor(e,t,n,r){super(),this.HighEnergy=e,this.MediumEnergy=t,this.LowEnergy=n,this.BackgroundOpacity=r}}function EnergyColors_$reflection(){return Config_record_type("Energy.Core.Config.EnergyColors",[],EnergyColors,()=>[["HighEnergy",Config_string_type],["MediumEnergy",Config_string_type],["LowEnergy",Config_string_type],["BackgroundOpacity",float64_type]])}const defaultEnergyColors=new EnergyColors("#fb8500","#ffb703","#99dd99",.1),configFileName=".esaconfig.json";class FileNesting extends Record{constructor(e,t){super(),this.MediumThreshold=e,this.HighThreshold=t}}function FileNesting_$reflection(){return Config_record_type("Energy.Core.Config.FileNesting",[],FileNesting,()=>[["MediumThreshold",Config_option_type(Config_int32_type)],["HighThreshold",Config_option_type(Config_int32_type)]])}class FileCyclomatic extends Record{constructor(e,t){super(),this.MediumThreshold=e,this.HighThreshold=t}}function FileCyclomatic_$reflection(){return Config_record_type("Energy.Core.Config.FileCyclomatic",[],FileCyclomatic,()=>[["MediumThreshold",Config_option_type(Config_int32_type)],["HighThreshold",Config_option_type(Config_int32_type)]])}class FileCognitive extends Record{constructor(e,t){super(),this.MediumThreshold=e,this.HighThreshold=t}}function FileCognitive_$reflection(){return Config_record_type("Energy.Core.Config.FileCognitive",[],FileCognitive,()=>[["MediumThreshold",Config_option_type(Config_int32_type)],["HighThreshold",Config_option_type(Config_int32_type)]])}class FileCoherence extends Record{constructor(e,t,n,r,o,i,a,s,l,_,u,c,d,p,m){super(),this.LargeFunctionLines=e,this.MaxLargeFunctions=t,this.SingleDomainNameShare=n,this.MaxTypeDiversityRatio=r,this.MinTypedCoverage=o,this.SiblingOpenThreshold=i,this.ImportBreadthThreshold=a,this.HighImportBreadthThreshold=s,this.MemberImportFanOutThreshold=l,this.UtilsFileFunctionCount=_,this.GenericFunctionCount=u,this.HighFunctionCount=c,this.MethodCountMedium=d,this.MethodCountHigh=p,this.LargeFunctionSeverityMultiplier=m}}function FileCoherence_$reflection(){return Config_record_type("Energy.Core.Config.FileCoherence",[],FileCoherence,()=>[["LargeFunctionLines",Config_option_type(Config_int32_type)],["MaxLargeFunctions",Config_option_type(Config_int32_type)],["SingleDomainNameShare",Config_option_type(float64_type)],["MaxTypeDiversityRatio",Config_option_type(float64_type)],["MinTypedCoverage",Config_option_type(float64_type)],["SiblingOpenThreshold",Config_option_type(Config_int32_type)],["ImportBreadthThreshold",Config_option_type(Config_int32_type)],["HighImportBreadthThreshold",Config_option_type(Config_int32_type)],["MemberImportFanOutThreshold",Config_option_type(Config_int32_type)],["UtilsFileFunctionCount",Config_option_type(Config_int32_type)],["GenericFunctionCount",Config_option_type(Config_int32_type)],["HighFunctionCount",Config_option_type(Config_int32_type)],["MethodCountMedium",Config_option_type(Config_int32_type)],["MethodCountHigh",Config_option_type(Config_int32_type)],["LargeFunctionSeverityMultiplier",Config_option_type(float64_type)]])}class FileMatchOpportunity extends Record{constructor(e){super(),this.MinBranches=e}}function FileMatchOpportunity_$reflection(){return Config_record_type("Energy.Core.Config.FileMatchOpportunity",[],FileMatchOpportunity,()=>[["MinBranches",Config_option_type(Config_int32_type)]])}class FileErrorShadowingMode extends Record{constructor(e,t,n){super(),this.Threshold=e,this.HighThreshold=t,this.MinItems=n}}function FileErrorShadowingMode_$reflection(){return Config_record_type("Energy.Core.Config.FileErrorShadowingMode",[],FileErrorShadowingMode,()=>[["Threshold",Config_option_type(float64_type)],["HighThreshold",Config_option_type(float64_type)],["MinItems",Config_option_type(Config_int32_type)]])}class FileErrorShadowing extends Record{constructor(e,t,n){super(),this.ProtectedScope=e,this.Recovery=t,this.RecoveryBlockMaxLines=n}}function FileErrorShadowing_$reflection(){return Config_record_type("Energy.Core.Config.FileErrorShadowing",[],FileErrorShadowing,()=>[["ProtectedScope",FileErrorShadowingMode_$reflection()],["Recovery",FileErrorShadowingMode_$reflection()],["RecoveryBlockMaxLines",Config_option_type(Config_int32_type)]])}class FileParameterCount extends Record{constructor(e,t){super(),this.MediumThreshold=e,this.HighThreshold=t}}function FileParameterCount_$reflection(){return Config_record_type("Energy.Core.Config.FileParameterCount",[],FileParameterCount,()=>[["MediumThreshold",Config_option_type(Config_int32_type)],["HighThreshold",Config_option_type(Config_int32_type)]])}class FileMagicNumber extends Record{constructor(e){super(),this.Allowlist=e}}function FileMagicNumber_$reflection(){return Config_record_type("Energy.Core.Config.FileMagicNumber",[],FileMagicNumber,()=>[["Allowlist",Config_option_type(Config_list_type(float64_type))]])}class FileMagicString extends Record{constructor(e,t){super(),this.MinDuplicates=e,this.Allowlist=t}}function FileMagicString_$reflection(){return Config_record_type("Energy.Core.Config.FileMagicString",[],FileMagicString,()=>[["MinDuplicates",Config_option_type(Config_int32_type)],["Allowlist",Config_option_type(Config_list_type(Config_string_type))]])}class FileConfig extends Record{constructor(e,t,n,r,o,i,a,s,l){super(),this.Nesting=e,this.Cyclomatic=t,this.Cognitive=n,this.Coherence=r,this.MatchOpportunity=o,this.ErrorShadowing=i,this.ParameterCount=a,this.MagicNumber=s,this.MagicString=l}}function FileConfig_$reflection(){return Config_record_type("Energy.Core.Config.FileConfig",[],FileConfig,()=>[["Nesting",FileNesting_$reflection()],["Cyclomatic",FileCyclomatic_$reflection()],["Cognitive",FileCognitive_$reflection()],["Coherence",FileCoherence_$reflection()],["MatchOpportunity",FileMatchOpportunity_$reflection()],["ErrorShadowing",FileErrorShadowing_$reflection()],["ParameterCount",FileParameterCount_$reflection()],["MagicNumber",FileMagicNumber_$reflection()],["MagicString",FileMagicString_$reflection()]])}function field(e,t){const n=e[t];return null==n?void 0:some(n)}function readNumber(e,t){let n;return n=null!=e?field(Option_value(e),t):void 0,null!=n?Option_value(n):void 0}function readList(e,t){let n;return n=null!=e?field(Option_value(e),t):void 0,null!=n?ofArray(Option_value(n)):void 0}function findConfigFile(e){return(e=>{e:for(;;){const t=e,n=(0,external_node_path_namespaceObject.join)(t,configFileName);if((0,external_node_fs_namespaceObject.existsSync)(n))return n;{const n=(0,external_node_path_namespaceObject.dirname)(t);if(null==n||equals(n,t))return;e=n;continue e}}})(e)}function readConfigJson(e){const t=e,n=t;return(0,external_node_fs_namespaceObject.existsSync)(t)?Result_Bind(e=>Result_MapError(e=>new ConfigError(2,[n,e]),jsonParseResult(e)),Result_MapError(e=>new ConfigError(1,[n,e]),readFileSyncSafe(t,"utf8"))):new FSharpResult$2(1,[new ConfigError(0,[n])])}function parseFileConfig(e){let t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g,S,$,C,L,T,E,w,x;const v=field(e,"nesting"),M=field(e,"cyclomaticComplexity"),A=field(e,"cognitiveComplexity"),b=field(e,"coherence"),F=field(e,"matchOpportunity"),I=field(e,"errorShadowing");let N,O,R;N=null!=I?field(Option_value(I),"protectedScope"):void 0,O=null!=I?field(Option_value(I),"recovery"):void 0,R=null!=I?field(Option_value(I),"recoveryBlock"):void 0;const q=field(e,"parameterCount"),P=field(e,"magicNumber"),k=field(e,"magicString");return new FileConfig(new FileNesting((t=readNumber(v,"mediumThreshold"),null!=t?~~t:void 0),(n=readNumber(v,"highThreshold"),null!=n?~~n:void 0)),new FileCyclomatic((r=readNumber(M,"mediumThreshold"),null!=r?~~r:void 0),(o=readNumber(M,"highThreshold"),null!=o?~~o:void 0)),new FileCognitive((i=readNumber(A,"mediumThreshold"),null!=i?~~i:void 0),(a=readNumber(A,"highThreshold"),null!=a?~~a:void 0)),new FileCoherence((s=readNumber(b,"largeFunctionLines"),null!=s?~~s:void 0),(l=readNumber(b,"maxLargeFunctions"),null!=l?~~l:void 0),readNumber(b,"singleDomainNameShare"),readNumber(b,"maxTypeDiversityRatio"),readNumber(b,"minTypedCoverage"),(_=readNumber(b,"siblingOpenThreshold"),null!=_?~~_:void 0),(u=readNumber(b,"importBreadthThreshold"),null!=u?~~u:void 0),(c=readNumber(b,"highImportBreadthThreshold"),null!=c?~~c:void 0),(d=readNumber(b,"memberImportFanOutThreshold"),null!=d?~~d:void 0),(p=readNumber(b,"utilsFileFunctionCount"),null!=p?~~p:void 0),(m=readNumber(b,"genericFunctionCount"),null!=m?~~m:void 0),(f=readNumber(b,"highFunctionCount"),null!=f?~~f:void 0),(y=readNumber(b,"godClassMethodCountMedium"),null!=y?~~y:void 0),(h=readNumber(b,"godClassMethodCountHigh"),null!=h?~~h:void 0),readNumber(b,"largeFunctionSeverityMultiplier")),new FileMatchOpportunity((g=readNumber(F,"minBranches"),null!=g?~~g:void 0)),new FileErrorShadowing(new FileErrorShadowingMode(readNumber(N,"threshold"),readNumber(N,"highThreshold"),(S=readNumber(N,"minItems"),null!=S?~~S:void 0)),new FileErrorShadowingMode(readNumber(O,"threshold"),readNumber(O,"highThreshold"),($=readNumber(O,"minItems"),null!=$?~~$:void 0)),(C=readNumber(R,"maxLines"),null!=C?~~C:void 0)),new FileParameterCount((L=readNumber(q,"mediumThreshold"),null!=L?~~L:void 0),(T=readNumber(q,"highThreshold"),null!=T?~~T:void 0)),new FileMagicNumber((E=readList(P,"allowlist"),null!=E?List_map(e=>e,E):void 0)),new FileMagicString((w=readNumber(k,"minDuplicates"),null!=w?~~w:void 0),(x=readList(k,"allowlist"),null!=x?List_map(e=>e,x):void 0)))}function mergeOptions(e,t){let n,r;const o=e.MagicNumber.Allowlist,i=e.MagicString.Allowlist,a=new NestingThresholds(e.Nesting.Enabled,defaultArg(t.Nesting.MediumThreshold,e.Nesting.MediumThreshold),defaultArg(t.Nesting.HighThreshold,e.Nesting.HighThreshold)),s=new CyclomaticThresholds(e.Cyclomatic.Enabled,defaultArg(t.Cyclomatic.MediumThreshold,e.Cyclomatic.MediumThreshold),defaultArg(t.Cyclomatic.HighThreshold,e.Cyclomatic.HighThreshold)),l=new CognitiveThresholds(e.Cognitive.Enabled,defaultArg(t.Cognitive.MediumThreshold,e.Cognitive.MediumThreshold),defaultArg(t.Cognitive.HighThreshold,e.Cognitive.HighThreshold)),_=new CoherenceThresholds(e.Coherence.Enabled,defaultArg(t.Coherence.LargeFunctionLines,e.Coherence.LargeFunctionLines),defaultArg(t.Coherence.MaxLargeFunctions,e.Coherence.MaxLargeFunctions),defaultArg(t.Coherence.SingleDomainNameShare,e.Coherence.SingleDomainNameShare),defaultArg(t.Coherence.MaxTypeDiversityRatio,e.Coherence.MaxTypeDiversityRatio),defaultArg(t.Coherence.MinTypedCoverage,e.Coherence.MinTypedCoverage),defaultArg(t.Coherence.SiblingOpenThreshold,e.Coherence.SiblingOpenThreshold),defaultArg(t.Coherence.ImportBreadthThreshold,e.Coherence.ImportBreadthThreshold),defaultArg(t.Coherence.HighImportBreadthThreshold,e.Coherence.HighImportBreadthThreshold),defaultArg(t.Coherence.MemberImportFanOutThreshold,e.Coherence.MemberImportFanOutThreshold),defaultArg(t.Coherence.UtilsFileFunctionCount,e.Coherence.UtilsFileFunctionCount),defaultArg(t.Coherence.GenericFunctionCount,e.Coherence.GenericFunctionCount),defaultArg(t.Coherence.HighFunctionCount,e.Coherence.HighFunctionCount),defaultArg(t.Coherence.MethodCountMedium,e.Coherence.MethodCountMedium),defaultArg(t.Coherence.MethodCountHigh,e.Coherence.MethodCountHigh),defaultArg(t.Coherence.LargeFunctionSeverityMultiplier,e.Coherence.LargeFunctionSeverityMultiplier)),u=new MatchOpportunityThresholds(e.MatchOpportunity.Enabled,defaultArg(t.MatchOpportunity.MinBranches,e.MatchOpportunity.MinBranches));let c;const d=e.ErrorShadowing;return c=new ErrorShadowingThresholds(d.Enabled,new ErrorShadowingModeThresholds(defaultArg(t.ErrorShadowing.ProtectedScope.Threshold,e.ErrorShadowing.ProtectedScope.Threshold),defaultArg(t.ErrorShadowing.ProtectedScope.HighThreshold,e.ErrorShadowing.ProtectedScope.HighThreshold),defaultArg(t.ErrorShadowing.ProtectedScope.MinItems,e.ErrorShadowing.ProtectedScope.MinItems)),new ErrorShadowingModeThresholds(defaultArg(t.ErrorShadowing.Recovery.Threshold,e.ErrorShadowing.Recovery.Threshold),defaultArg(t.ErrorShadowing.Recovery.HighThreshold,e.ErrorShadowing.Recovery.HighThreshold),defaultArg(t.ErrorShadowing.Recovery.MinItems,e.ErrorShadowing.Recovery.MinItems)),d.RecoveryDominanceEnabled,d.OversizedRecoveryBlockEnabled,new RecoveryBlockThresholds(defaultArg(t.ErrorShadowing.RecoveryBlockMaxLines,e.ErrorShadowing.RecoveryBlock.MaxLines))),new AnalyzeOptions(a,s,l,_,u,new ParameterCountThresholds(e.ParameterCount.Enabled,defaultArg(t.ParameterCount.MediumThreshold,e.ParameterCount.MediumThreshold),defaultArg(t.ParameterCount.HighThreshold,e.ParameterCount.HighThreshold)),(n=e.MagicNumber,new MagicNumberOptions(n.Enabled,List_append(o,List_filter(e=>!List_contains(e,o,{Equals:(e,t)=>e===t,GetHashCode:e=>0|numberHash(e)}),defaultArg(t.MagicNumber.Allowlist,List_empty()))),n.IncludeTestFiles)),(r=e.MagicString,new MagicStringOptions(r.Enabled,defaultArg(t.MagicString.MinDuplicates,e.MagicString.MinDuplicates),List_append(i,List_filter(e=>!List_contains(e,i,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),defaultArg(t.MagicString.Allowlist,List_empty()))),r.IncludeTestFiles)),e.PrimitiveObsession,e.OpaqueBoolean,e.ParseDontValidate,e.LogicalControlFlow,e.Inversion,c)}function optionsFromConfig(e,t){try{return new FSharpResult$2(0,[mergeOptions(defaultAnalyzeOptions,parseFileConfig(t))])}catch(t){return new FSharpResult$2(1,[new ConfigError(2,[e,Types_toString(t)])])}}function loadAnalyzeOptions(e){const t=findConfigFile(e);if(null!=t){const e=t;return Result_Bind(t=>optionsFromConfig(e,t),readConfigJson(e))}return new FSharpResult$2(0,[defaultAnalyzeOptions])}function loadAnalyzeOptionsFromConfigPath(e){return Result_Bind(t=>optionsFromConfig(e,t),readConfigJson(e))}var LanguageAdapter_union_type,LanguageAdapter_list_type,obj_type,LanguageAdapter_record_type,LanguageAdapter_string_type,LanguageAdapter_option_type,lambda_type,LanguageAdapter_bool_type,LanguageAdapter_int32_type,LanguageAdapter_class_type,tuple_type,Set_class_type,Set_record_type,Set_list_type,Set_option_type,Set_bool_type,Set_some,Set_value_2,Set_Exception,Set_Operators_InvalidArg,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,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 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 CognitiveIncrement extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Structural","Hybrid","Fundamental"]}static Structural=new CognitiveIncrement(0,[]);static Hybrid=new CognitiveIncrement(1,[]);static Fundamental=new CognitiveIncrement(2,[])}function CognitiveIncrement_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.CognitiveIncrement",[],CognitiveIncrement,()=>[[],[],[]])}class CognitiveStructure extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Flow","Closure","BooleanGroup"]}static Closure=new CognitiveStructure(1,[])}function CognitiveStructure_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.CognitiveStructure",[],CognitiveStructure,()=>[[["Item1",CognitiveIncrement_$reflection()],["Item2",LanguageAdapter_list_type(obj_type)]],[],[["Item",obj_type]]])}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 RecoveryBody extends Record{constructor(e,t){super(),this.Anchor=e,this.Items=t}}function RecoveryBody_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.RecoveryBody",[],RecoveryBody,()=>[["Anchor",obj_type],["Items",LanguageAdapter_list_type(obj_type)]])}class ErrorHandlingRegion extends Record{constructor(e,t,n,r,o){super(),this.Anchor=e,this.ProtectedBody=t,this.ProtectedItems=n,this.RecoveryItems=r,this.RecoveryBodies=o}}function ErrorHandlingRegion_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.ErrorHandlingRegion",[],ErrorHandlingRegion,()=>[["Anchor",obj_type],["ProtectedBody",LanguageAdapter_list_type(obj_type)],["ProtectedItems",LanguageAdapter_list_type(obj_type)],["RecoveryItems",LanguageAdapter_list_type(obj_type)],["RecoveryBodies",LanguageAdapter_list_type(RecoveryBody_$reflection())]])}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 BooleanLiteralPolarity extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["LiteralTrue","LiteralFalse"]}static LiteralTrue=new BooleanLiteralPolarity(0,[]);static LiteralFalse=new BooleanLiteralPolarity(1,[])}function BooleanLiteralPolarity_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.BooleanLiteralPolarity",[],BooleanLiteralPolarity,()=>[[],[]])}class ValidationSuccess extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["UnchangedInput","NoValue","BareBoolean"]}static NoValue=new ValidationSuccess(1,[])}function ValidationSuccess_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.ValidationSuccess",[],ValidationSuccess,()=>[[["Item",obj_type]],[],[["Item",obj_type]]])}class IdentityReturnPolicy extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["RequireParameterAnnotation","AcceptUntypedParameter"]}static RequireParameterAnnotation=new IdentityReturnPolicy(0,[]);static AcceptUntypedParameter=new IdentityReturnPolicy(1,[])}function IdentityReturnPolicy_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.IdentityReturnPolicy",[],IdentityReturnPolicy,()=>[[],[]])}class GuardedValidation extends Record{constructor(e,t,n,r){super(),this.Anchor=e,this.Condition=t,this.Success=n,this.IdentityReturnPolicy=r}}function GuardedValidation_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.GuardedValidation",[],GuardedValidation,()=>[["Anchor",obj_type],["Condition",obj_type],["Success",ValidationSuccess_$reflection()],["IdentityReturnPolicy",IdentityReturnPolicy_$reflection()]])}class FunctionHead extends Record{constructor(e,t){super(),this.ParametersRoot=e,this.Body=t}}function FunctionHead_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.FunctionHead",[],FunctionHead,()=>[["ParametersRoot",obj_type],["Body",obj_type]])}class AnonymousBindingScope extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["ModuleBinding","ClassMemberBinding"]}static ModuleBinding=new AnonymousBindingScope(0,[]);static ClassMemberBinding=new AnonymousBindingScope(1,[])}function AnonymousBindingScope_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.AnonymousBindingScope",[],AnonymousBindingScope,()=>[[],[]])}class CallableRole extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["NamedDefinition","BoundAnonymous","InlineAnonymous"]}static NamedDefinition=new CallableRole(0,[]);static InlineAnonymous=new CallableRole(2,[])}function CallableRole_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.CallableRole",[],CallableRole,()=>[[],[["Item",AnonymousBindingScope_$reflection()]],[]])}class CallableView extends Record{constructor(e,t,n,r,o,i){super(),this.Anchor=e,this.Body=t,this.ReturnTypeRoot=n,this.Role=r,this.BindingName=o,this.Parameters=i}}function CallableView_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.CallableView",[],CallableView,()=>[["Anchor",obj_type],["Body",obj_type],["ReturnTypeRoot",obj_type],["Role",CallableRole_$reflection()],["BindingName",LanguageAdapter_option_type(LanguageAdapter_string_type)],["Parameters",LanguageAdapter_list_type(obj_type)]])}class ImportKind extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Module","Members","Wildcard","ScopeOpen","Header"]}static Module=new ImportKind(0,[]);static Members=new ImportKind(1,[]);static Wildcard=new ImportKind(2,[]);static ScopeOpen=new ImportKind(3,[]);static Header=new ImportKind(4,[])}function ImportKind_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.ImportKind",[],ImportKind,()=>[[],[],[],[],[]])}class ImportBinding extends Record{constructor(e,t){super(),this.ImportedName=e,this.LocalName=t}}function ImportBinding_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.ImportBinding",[],ImportBinding,()=>[["ImportedName",LanguageAdapter_string_type],["LocalName",LanguageAdapter_string_type]])}class ImportInfo extends Record{constructor(e,t,n){super(),this.Kind=e,this.Source=t,this.Bindings=n}}function ImportInfo_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.ImportInfo",[],ImportInfo,()=>[["Kind",ImportKind_$reflection()],["Source",LanguageAdapter_string_type],["Bindings",LanguageAdapter_list_type(ImportBinding_$reflection())]])}class NodeTypes extends Record{constructor(e,t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g){super(),this.Block=e,this.Parameters=t,this.IfStatement=n,this.ElseClause=r,this.ForStatement=o,this.WhileStatement=i,this.ConditionalExpression=a,this.Lambda=s,this.ImportStatement=l,this.ImportFromStatement=_,this.AdditionalImportTypes=u,this.ExpressionStatement=c,this.Assignment=d,this.Module=p,this.ExportStatement=m,this.Comment=f,this.IntegerLiteral=y,this.FloatLiteral=h,this.StringLiteral=g}}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)],["AdditionalImportTypes",LanguageAdapter_list_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,a,s,l,_,u,c,d,p,m,f,y,h,g,S,$,C,L,T,E,w,x,v,M,A,b,F,I,N,O,R,q,P,k,D,B){super(),this.Id=e,this.GrammarPath=t,this.NodeTypes=n,this.IsFunctionDefinition=r,this.GetFunctionHeads=o,this.GetCallableViews=i,this.ParameterChildTypes=a,this.DecisionNodeTypes=s,this.CyclomaticBranchCount=l,this.GetCognitiveStructure=_,this.NestingControlTypes=u,this.GetBooleanOperator=c,this.IsTryElseClause=d,this.VariableReferenceNodeTypes=p,this.ExtractTypedParameter=m,this.ExtractReturnType=f,this.GenericBrackets=y,this.PrimitiveTypeNames=h,this.GetErrorHandlingRegion=g,this.GetFunctionLogicalItems=S,this.KeywordOnlyBoundaryTypes=$,this.DistinctTypeAdvice=C,this.GetEqualityComparisons=L,this.GetMatchStringCases=T,this.GetMembershipComparisons=E,this.IsMatchCaseLiteral=w,this.GetElseIfBranches=x,this.SubscriptNodeTypes=v,this.IsFormattedOrInterpolatedString=M,this.IsDefaultParameterValue=A,this.IsStructuralNumber=b,this.NumericLiteralText=F,this.IsBooleanLiteral=I,this.IsPositionalCallArgument=N,this.IsExplicitConstant=O,this.ImportInfo=R,this.IsClassDefinition=q,this.IsStaticMethod=P,this.GetClassName=k,this.GetBaseClassNames=D,this.GetGuardedValidation=B}}function LanguageAdapter_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.LanguageAdapter",[],LanguageAdapter,()=>[["Id",LanguageAdapter_string_type],["GrammarPath",LanguageAdapter_string_type],["NodeTypes",NodeTypes_$reflection()],["IsFunctionDefinition",lambda_type(obj_type,LanguageAdapter_bool_type)],["GetFunctionHeads",lambda_type(obj_type,LanguageAdapter_list_type(FunctionHead_$reflection()))],["GetCallableViews",lambda_type(obj_type,LanguageAdapter_list_type(CallableView_$reflection()))],["ParameterChildTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["DecisionNodeTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["CyclomaticBranchCount",lambda_type(obj_type,LanguageAdapter_option_type(LanguageAdapter_int32_type))],["GetCognitiveStructure",lambda_type(obj_type,LanguageAdapter_option_type(CognitiveStructure_$reflection()))],["NestingControlTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["GetBooleanOperator",lambda_type(obj_type,LanguageAdapter_option_type(BooleanOperator_$reflection()))],["IsTryElseClause",lambda_type(obj_type,LanguageAdapter_bool_type)],["VariableReferenceNodeTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["ExtractTypedParameter",lambda_type(obj_type,LanguageAdapter_option_type(TypedParameter_$reflection()))],["ExtractReturnType",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])],["GetErrorHandlingRegion",lambda_type(obj_type,LanguageAdapter_option_type(ErrorHandlingRegion_$reflection()))],["GetFunctionLogicalItems",lambda_type(obj_type,LanguageAdapter_list_type(obj_type))],["KeywordOnlyBoundaryTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["DistinctTypeAdvice",LanguageAdapter_string_type],["GetEqualityComparisons",lambda_type(obj_type,LanguageAdapter_list_type(EqualityComparison_$reflection()))],["GetMatchStringCases",lambda_type(obj_type,LanguageAdapter_option_type(tuple_type(obj_type,LanguageAdapter_list_type(obj_type))))],["GetMembershipComparisons",lambda_type(obj_type,LanguageAdapter_list_type(MembershipComparison_$reflection()))],["IsMatchCaseLiteral",lambda_type(obj_type,LanguageAdapter_bool_type)],["GetElseIfBranches",lambda_type(obj_type,LanguageAdapter_list_type(obj_type))],["SubscriptNodeTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["IsFormattedOrInterpolatedString",lambda_type(obj_type,LanguageAdapter_bool_type)],["IsDefaultParameterValue",lambda_type(obj_type,LanguageAdapter_bool_type)],["IsStructuralNumber",lambda_type(obj_type,LanguageAdapter_bool_type)],["NumericLiteralText",lambda_type(obj_type,LanguageAdapter_string_type)],["IsBooleanLiteral",lambda_type(obj_type,LanguageAdapter_bool_type)],["IsPositionalCallArgument",lambda_type(obj_type,LanguageAdapter_bool_type)],["IsExplicitConstant",lambda_type(obj_type,LanguageAdapter_bool_type)],["ImportInfo",lambda_type(obj_type,LanguageAdapter_list_type(ImportInfo_$reflection()))],["IsClassDefinition",lambda_type(obj_type,LanguageAdapter_bool_type)],["IsStaticMethod",lambda_type(obj_type,LanguageAdapter_bool_type)],["GetClassName",lambda_type(obj_type,LanguageAdapter_option_type(LanguageAdapter_string_type))],["GetBaseClassNames",lambda_type(obj_type,LanguageAdapter_list_type(LanguageAdapter_string_type))],["GetGuardedValidation",lambda_type(FunctionHead_$reflection(),LanguageAdapter_option_type(GuardedValidation_$reflection()))]])}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){if(e instanceof SetTreeNode$1){const r=e;e=SetTreeNode$1__get_Left(r),t=SetTreeModule_countAux(SetTreeNode$1__get_Right(r),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,a;i=null!=e?e instanceof SetTreeNode$1?(r=e,SetTreeNode$1__get_Height(r)):1:0,a=null!=n?n instanceof SetTreeNode$1?(o=n,SetTreeNode$1__get_Height(o)):1:0;const s=0|(i<a?a:i);return 0===s?SetTreeLeaf$1_$ctor_2B595(t):SetTreeNode$1_$ctor_5F465FC9(t,e,n,s+1)}function SetTreeModule_rebalance(e,t,n){let r,o,i,a,s,l,_,u,c,d;if(c=null!=e?e instanceof SetTreeNode$1?(r=e,SetTreeNode$1__get_Height(r)):1:0,d=null!=n?n instanceof SetTreeNode$1?(o=n,SetTreeNode$1__get_Height(o)):1:0,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?(a=i,a instanceof SetTreeNode$1?(s=a,SetTreeNode$1__get_Height(s)):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(l=SetTreeNode$1__get_Right(e),(null!=l?(_=l,_ instanceof SetTreeNode$1?(u=_,SetTreeNode$1__get_Height(u)):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=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=t;if(null!=r){const i=r;if(o instanceof SetTreeNode$1){const a=o;if(i instanceof SetTreeNode$1){const o=i;return SetTreeNode$1__get_Height(a)+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(a)?SetTreeModule_rebalance(SetTreeNode$1__get_Left(a),SetTreeLeaf$1__get_Key(a),SetTreeModule_balance(e,SetTreeNode$1__get_Right(a),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=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=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=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=n,a=0|r.Compare(o,SetTreeLeaf$1__get_Key(i));if(i instanceof SetTreeNode$1){const s=i;if(a<0){e=r,t=o,n=SetTreeNode$1__get_Left(s);continue e}if(0===a)return!0;e=r,t=o,n=SetTreeNode$1__get_Right(s);continue e}return 0===a}return!1}}function SetTreeModule_iter(e,t){e:for(;;){const n=e;if(null!=t){const r=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=t;if(i instanceof SetTreeNode$1){const a=i;e=r,t=SetTreeNode$1__get_Left(a),n=r(SetTreeLeaf$1__get_Key(a),SetTreeModule_foldBackOpt(r,SetTreeNode$1__get_Right(a),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=n;if(i instanceof SetTreeNode$1){const a=i;e=r,t=r(SetTreeModule_foldOpt(r,o,SetTreeNode$1__get_Left(a)),SetTreeLeaf$1__get_Key(a)),n=SetTreeNode$1__get_Right(a);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=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=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,a=r;if(null!=n){const s=n;if(s instanceof SetTreeNode$1){const l=s,_=i(SetTreeLeaf$1__get_Key(l))?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(l),a):a;e=o,t=i,n=SetTreeNode$1__get_Left(l),r=SetTreeModule_filterAux(o,i,SetTreeNode$1__get_Right(l),_);continue e}return i(SetTreeLeaf$1__get_Key(s))?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(s),a):a}return a}}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=t;if(i instanceof SetTreeNode$1){const a=i;e=r,t=SetTreeNode$1__get_Left(a),n=SetTreeModule_diffAux(r,SetTreeNode$1__get_Right(a),SetTreeModule_remove(r,SetTreeLeaf$1__get_Key(a),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=t;if(null!=n){const o=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,a=r;if(null!=n){const s=n;if(s instanceof SetTreeNode$1){const l=s,_=SetTreeModule_intersectionAux(o,i,SetTreeNode$1__get_Right(l),a),u=SetTreeModule_mem(o,SetTreeLeaf$1__get_Key(l),i)?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(l),_):_;e=o,t=i,n=SetTreeNode$1__get_Left(l),r=u;continue e}return SetTreeModule_mem(o,SetTreeLeaf$1__get_Key(s),i)?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(s),a):a}return a}}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,a=t,s=[r,o];if(null!=n){const l=n;if(l instanceof SetTreeNode$1){const _=l,u=SetTreeModule_partitionAux(i,a,SetTreeNode$1__get_Right(_),s[0],s[1]),c=SetTreeModule_partition1(i,a,SetTreeLeaf$1__get_Key(_),u[0],u[1]);e=i,t=a,n=SetTreeNode$1__get_Left(_),r=c[0],o=c[1];continue e}return SetTreeModule_partition1(i,a,SetTreeLeaf$1__get_Key(l),s[0],s[1])}return s}}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=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=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=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=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 Set_Operators_InvalidArg("s","Set contains no elements.");return Set_value_2(t)}function SetTreeModule_maximumElement(e){const t=SetTreeModule_maximumElementOpt(e);if(null==t)throw Set_Operators_InvalidArg("s","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}Equals(e){return this===e}GetHashCode(){return physicalHash(this)}}function SetTreeModule_SetIterator$1_$reflection(e){return Set_record_type("Set.SetTreeModule.SetIterator`1",[e],SetTreeModule_SetIterator$1,()=>[["stack",Set_list_type(Set_option_type(SetTreeLeaf$1_$reflection(e)))],["started",Set_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){if(n instanceof SetTreeNode$1){const t=n;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 Operators_InvalidOp("Enumeration has not started. Call MoveNext.")}function SetTreeModule_alreadyFinished(){throw Operators_InvalidOp("Enumeration already finished.")}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(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(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 a=List_head(o),s=List_head(i);if(a instanceof SetTreeNode$1){const l=a;if(null==SetTreeNode$1__get_Left(l)){if(!(s instanceof SetTreeNode$1)){const a=0|r.Compare(SetTreeLeaf$1__get_Key(l),SetTreeLeaf$1__get_Key(s));if(0!==a)return 0|a;e=r,t=cons(SetTreeNode$1__get_Right(l),List_tail(o)),n=cons(SetTreeModule_empty(),List_tail(i));continue e}{const a=s;if(null==SetTreeNode$1__get_Left(a)){const s=0|r.Compare(SetTreeLeaf$1__get_Key(l),SetTreeLeaf$1__get_Key(a));if(0!==s)return 0|s;e=r,t=cons(SetTreeNode$1__get_Right(l),List_tail(o)),n=cons(SetTreeNode$1__get_Right(a),List_tail(i));continue e}{let a,s,l,_,u;switch(List_isEmpty(o)?List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2:null!=List_head(o)?(a=0,s=List_tail(o),l=List_head(o)):List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2,a){case 0:if(l instanceof SetTreeNode$1){const o=l;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)],s),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],s),n=i;continue e;case 1:if(u instanceof SetTreeNode$1){const i=u;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)],_);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(u))],_);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}}}else{let a,s,l,_,u;switch(List_isEmpty(o)?List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2:null!=List_head(o)?(a=0,s=List_tail(o),l=List_head(o)):List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2,a){case 0:if(l instanceof SetTreeNode$1){const o=l;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)],s),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],s),n=i;continue e;case 1:if(u instanceof SetTreeNode$1){const i=u;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)],_);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(u))],_);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}}else{if(!(s instanceof SetTreeNode$1)){const l=0|r.Compare(SetTreeLeaf$1__get_Key(a),SetTreeLeaf$1__get_Key(s));if(0!==l)return 0|l;e=r,t=List_tail(o),n=List_tail(i);continue e}{const l=s;if(null==SetTreeNode$1__get_Left(l)){const s=0|r.Compare(SetTreeLeaf$1__get_Key(a),SetTreeLeaf$1__get_Key(l));if(0!==s)return 0|s;e=r,t=cons(SetTreeModule_empty(),List_tail(o)),n=cons(SetTreeNode$1__get_Right(l),List_tail(i));continue e}{let a,s,l,_,u;switch(List_isEmpty(o)?List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2:null!=List_head(o)?(a=0,s=List_tail(o),l=List_head(o)):List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2,a){case 0:if(l instanceof SetTreeNode$1){const o=l;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)],s),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],s),n=i;continue e;case 1:if(u instanceof SetTreeNode$1){const i=u;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)],_);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(u))],_);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}}}}else{let a,s,l,_,u;switch(List_head(i),List_isEmpty(o)?List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2:null!=List_head(o)?(a=0,s=List_tail(o),l=List_head(o)):List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2,a){case 0:if(l instanceof SetTreeNode$1){const o=l;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)],s),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],s),n=i;continue e;case 1:if(u instanceof SetTreeNode$1){const i=u;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)],_);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(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 a,s,l,_,u;switch(List_head(o),List_isEmpty(o)?List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2:null!=List_head(o)?(a=0,s=List_tail(o),l=List_head(o)):List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2,a){case 0:if(l instanceof SetTreeNode$1){const o=l;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)],s),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],s),n=i;continue e;case 1:if(u instanceof SetTreeNode$1){const i=u;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)],_);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(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=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 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())))}const scopeGroupIndex=2,typeGroupIndex=3;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(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],["parse-dont-validate",ViolationType.ParseDontValidate],["error-shadowing",ViolationType.ErrorShadowing],["recovery-dominance",ViolationType.RecoveryDominance],["oversized-recovery-block",ViolationType.OversizedRecoveryBlock],["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=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 ofArray(choose(e=>e,mapIndexed((e,t)=>{const n=match(directivePattern,t);if(null!=n){const r=parseTypeList(n[typeGroupIndex]||"");return new Suppression(e,n.index,null!=n[scopeGroupIndex]?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 Position_record_type,Position_int32_type,Position_lambda_type,Context_record_type,Context_string_type,Context_obj_type,Context_list_type,Context_lambda_type,Context_PositionLookup_$reflection,Context_LanguageAdapter_$reflection,Context_AnalyzeOptions_$reflection,Context_EnergyViolation_$reflection;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",Position_lambda_type(Position_int32_type,Position_$reflection())]])}function createPositionLookup(e){const t=[0];for(let n=0;n<=e.length-1;n++)"\n"===getCharAtIndex(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;Array_item(o,t)<=e?n=0|o:r=o-1|0}return new Position(n,e-Array_item(n,t))})}class AnalysisContext extends Record{constructor(e,t,n,r,o,i,a){super(),this.Source=e,this.Tree=t,this.Positions=n,this.Language=r,this.FileName=o,this.Options=i,this.Violations=a}}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],["Options",Context_AnalyzeOptions_$reflection()],["Violations",Context_list_type(Context_EnergyViolation_$reflection())]])}function addViolations(e,t){return new AnalysisContext(t.Source,t.Tree,t.Positions,t.Language,t.FileName,t.Options,List_append(List_reverse(e),t.Violations))}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(),AnalysisContext_$reflection())]])}function analyzeNesting(e){const t=(n,r)=>{const o=List_contains(n.type,e.Language.NestingControlTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),i=0|(o?r+1:r),a=List_collect(e=>t(e,i),nodeChildren(n));if(o&&r>e.Options.Nesting.MediumThreshold){const t=e.Positions.toPosition(n.startIndex);return cons(new EnergyViolation(t.Line,t.Column,ViolationType.Nesting,r>e.Options.Nesting.HighThreshold?Severity.High:Severity.Medium,toText(printf("Excessive nesting depth: %d. Consider extracting."))(r),List_empty()),a)}return a};return addViolations(t(e.Tree,0),e)}const detector=new Detector("nesting",analyzeNesting);var Cyclomatic_union_type,Cyclomatic_int32_type,Cyclomatic_record_type,Cyclomatic_list_type;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 CallableScope extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["RootCallable","NestedCallable"]}static RootCallable=new CallableScope(0,[]);static NestedCallable=new CallableScope(1,[])}function CallableScope_$reflection(){return Cyclomatic_union_type("Energy.Core.Detectors.Cyclomatic.CallableScope",[],CallableScope,()=>[[],[]])}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(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 isCallableBoundary(e,t){return!List_isEmpty(e.GetCallableViews(t))}function buildControlFlowGraph(e,t,n,r){const o=isDecisionPoint(e,t)?addDecision(decisionOutcomes(e,t),r):r;return equals(n,CallableScope.NestedCallable)&&isCallableBoundary(e,t)?o:List_fold((t,n)=>buildControlFlowGraph(e,n,CallableScope.NestedCallable,t),o,nodeChildren(t))}function complexityOf(e,t){const n=buildControlFlowGraph(e,t,CallableScope.RootCallable,initialGraph);return List_length(n.Edges)-List_length(n.Nodes)+mccabeComponentMultiplier*connectedComponents|0}function complexityOfCallable(e,t){return 0|complexityOf(e,t.Body)}function findCyclomaticHotspots(e,t,n,r,o){const i=isDecisionPoint(e,n),a=i?List_singleton(new Hotspot(t.toPosition(n.startIndex).Line,(decisionOutcomes(e,n)-1)*(1+r))):List_empty();if(equals(o,CallableScope.NestedCallable)&&isCallableBoundary(e,n))return a;{const o=0|(i?r+1:r);return List_append(a,List_collect(n=>findCyclomaticHotspots(e,t,n,o,CallableScope.NestedCallable),nodeChildren(n)))}}function analyzeCallable(e,t){const n=0|complexityOfCallable(e.Language,t);if(n>e.Options.Cyclomatic.MediumThreshold){const r=e.Positions.toPosition(t.Anchor.startIndex);return List_singleton(new EnergyViolation(r.Line,r.Column,ViolationType.Complexity,n>e.Options.Cyclomatic.HighThreshold?Severity.High:Severity.Medium,toText(printf("High cyclomatic complexity: %d. Consider breaking down this function."))(n),findCyclomaticHotspots(e.Language,e.Positions,t.Body,0,CallableScope.RootCallable)))}return List_empty()}function analyzeFunctionComplexity(e){const t=n=>List_append(List_collect(t=>analyzeCallable(e,t),e.Language.GetCallableViews(n)),List_collect(t,nodeChildren(n)));return addViolations(t(e.Tree),e)}const Cyclomatic_detector=new Detector("cyclomatic",analyzeFunctionComplexity);var Cognitive_union_type,Cognitive_obj_type,Cognitive_BooleanOperator_$reflection;class BooleanPart extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Operator","Operand"]}}function BooleanPart_$reflection(){return Cognitive_union_type("Energy.Core.Detectors.Cognitive.BooleanPart",[],BooleanPart,()=>[[["Item1",Cognitive_obj_type],["Item2",Cognitive_BooleanOperator_$reflection()]],[["Item",Cognitive_obj_type]]])}function operatorAnchor(e,t,n){return defaultArg(List_tryFind(e=>e.startIndex>=t.endIndex&&e.endIndex<=n.startIndex,nodeChildren(e)),e)}function booleanParts(e,t){e:for(;;){const n=e,r=t;let o,i;const a=n.GetBooleanOperator(r),s=n.GetCognitiveStructure(r);let l,_,u;switch(null==a?null!=s&&2===s.tag?(l=1,u=s.fields[0]):l=2:(l=0,_=a),l){case 0:{const e=nodeNamedChildren(r),t=List_tryHead(e),a=List_tryLast(e);let s,l,u;return null!=t&&null!=a?(o=Option_value(a),i=Option_value(t),i.id!==o.id?(s=0,l=Option_value(t),u=Option_value(a)):s=1):s=1,0===s?List_append(booleanParts(n,l),List_append(List_singleton(new BooleanPart(0,[operatorAnchor(r,l,u),_])),booleanParts(n,u))):List_map(e=>new BooleanPart(1,[e]),e)}case 1:e=n,t=u;continue e;default:return List_singleton(new BooleanPart(1,[r]))}break}}function scoreBooleanParts(e,t,n){return 0|List_fold((n,r)=>{const o=0|n[0],i=n[1];if(1===r.tag)return[o+e(r.fields[0]),i];{const e=r.fields[1],n=0|(equals(i,e)?0:1);return n>0&&t(r.fields[0],n),[o+n,e]}},[0,void 0],n)[0]}function cognitiveWalk(e,t,n,r){let o;const i=o=>0|List_sumBy(t=>0|cognitiveWalk(e,t,o(t)?n+1:n,r),nodeChildren(t),{GetZero:()=>0,Add:(e,t)=>e+t|0});if(null!=e.GetBooleanOperator(t))return 0|scoreBooleanParts(t=>0|cognitiveWalk(e,t,n,r),r,booleanParts(e,t));{const a=e.GetCognitiveStructure(t);let s,l,_;if(null!=a)switch(a.tag){case 0:s=0,l=a.fields[0],_=a.fields[1];break;case 1:s=1;break;default:s=e.IsFunctionDefinition(t)?2:3}else s=e.IsFunctionDefinition(t)?2:3;switch(s){case 0:return 0|(o=0|(1===l.tag||2===l.tag?1:1+n),o>0&&r(t,o),o+i(e=>List_exists(t=>t.id===e.id,_)));case 1:return 0|i(e=>!0);case 2:return 0|i(e=>!0);default:return 0|i(e=>!1)}}}function callableBodyRoots(e){return e.Anchor.id===e.Body.id?nodeChildren(e.Body):List_singleton(e.Body)}function cognitiveScoreOf(e,t){return 0|List_sumBy(t=>0|cognitiveWalk(e,t,0,(e,t)=>{}),callableBodyRoots(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))})},callableBodyRoots(t)),ofSeq(r)}function Cognitive_analyzeCallable(e,t){const n=0|cognitiveScoreOf(e.Language,t);if(n>e.Options.Cognitive.MediumThreshold){const r=e.Positions.toPosition(t.Anchor.startIndex);return List_singleton(new EnergyViolation(r.Line,r.Column,ViolationType.Cognitive,n>e.Options.Cognitive.HighThreshold?Severity.High:Severity.Medium,toText(printf("High cognitive complexity: %d. This function is hard to read; consider flattening nesting or extracting functions."))(n),findCognitiveHotspots(e.Language,t,e.Positions)))}return List_empty()}function analyzeCognitiveComplexity(e){const t=n=>List_append(List_collect(t=>Cognitive_analyzeCallable(e,t),e.Language.GetCallableViews(n)),List_collect(t,nodeChildren(n)));return addViolations(t(e.Tree),e)}const Cognitive_detector=new Detector("cognitive",analyzeCognitiveComplexity);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}const wordBoundaryPattern=/[A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+/gu;function 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(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),splitIntoWords((t=0|n.lastIndexOf("."),-1===t?n:substring(n,0,t))))}function callableNameWords(e){const t=e.BindingName;let n,r;return null!=t?isNullOrEmpty(t)?n=1:(n=0,r=t):n=1,0===n?splitIntoWords(r):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=splitIntoWords(o["System.Collections.Generic.IEnumerator`1.get_Current"]());List_length(e)>0&&(n.push(item(0,e)),r.push(item(List_length(e)-1,e)))}}finally{disposeSafe(o)}return 0!==n.length&&(dominantShare(ofSeq(n))>=t||dominantShare(ofSeq(r))>=t)}function looksLikeSingleDomain(e,t){return looksLikeSingleDomainByNames(List_map(e=>join(" ",callableNameWords(e)),e),t)}var TypeCohesion_record_type,TypeCohesion_bool_type,TypeCohesion_int32_type,TypeCohesion_union_type,TypeCohesion_float64_type;const nonDomainBaseTypes=Set_ofList(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|indexOf(n,t.Open,4),r=-1===e?n.trim():substring(n,0,e).trim();return isMatch(/^[A-Za-z_][A-Za-z0-9_]*(?:(?:\.|::)[A-Za-z_][A-Za-z0-9_]*)*$/gu,r)?FSharpSet__Contains(nonDomainBaseTypes,r)||isTypeParameterName(r)?void 0:r:void 0}}function collectTypeSignals(e,t){let n,r;const o=new Set([]),i=getEnumerator(e.Parameters);try{for(;i["System.Collections.IEnumerator.MoveNext"]();){let e,n;e=t.ExtractTypedParameter(i["System.Collections.Generic.IEnumerator`1.get_Current"]()),null!=e&&(n=baseTypeName(e.Type,t.GenericBrackets),null!=n&&some(void addToSet(n,o)))}}finally{disposeSafe(i)}return n=t.ExtractReturnType(e.ReturnTypeRoot),null!=n&&(r=baseTypeName(n,t.GenericBrackets),null!=r&&some(void addToSet(r,o))),o}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)])}}var MutableSet_item_1,MutableSet_some,MutableSet_class_type,MutableMap_class_type,Seq2_delay,Seq2_filter,Seq2_toArray,Seq2_map,Seq2_toList,Seq2_HashSet,Seq2_addToSet,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,ClassRelatedness_CallableView_$reflection,ClassRelatedness_LanguageAdapter_$reflection,ClassRelatedness_Severity_$reflection,ClassRelatedness_CoherenceThresholds_$reflection,ClassRelatedness_PositionLookup_$reflection,CoherenceCollection_CallableView_$reflection,CoherenceCollection_ImportInfo_$reflection,CoherenceCollection_record_type,CoherenceCollection_list_type,CoherenceCollection_option_type,CoherenceCollection_obj_type,CoherenceCollection_ClassInfo_$reflection;class MutableSet_HashSet{constructor(e,t){const n=new FSharpRef(defaultOf());this.comparer=t,n.contents=this,this.hashMap=new Map([]),this.count=0,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"]();HashSet__Add_2B595(n.contents,e)}}finally{disposeSafe(r)}}get[Symbol.toStringTag](){return"HashSet"}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){HashSet__Add_2B595(this,e)}"System.Collections.Generic.ICollection`1.Clear"(){HashSet__Clear(this)}"System.Collections.Generic.ICollection`1.Contains2B595"(e){return HashSet__Contains_2B595(this,e)}"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|HashSet__get_Count(this)}"System.Collections.Generic.ICollection`1.get_IsReadOnly"(){return!1}"System.Collections.Generic.ICollection`1.Remove2B595"(e){return HashSet__Remove_2B595(this,e)}get size(){return 0|HashSet__get_Count(this)}add(e){return HashSet__Add_2B595(this,e),this}clear(){HashSet__Clear(this)}delete(e){return HashSet__Remove_2B595(this,e)}has(e){return HashSet__Contains_2B595(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 HashSet_$reflection(e){return MutableSet_class_type("Fable.Collections.HashSet",[e],MutableSet_HashSet)}function MutableSet_HashSet_$ctor_Z6150332D(e,t){return new MutableSet_HashSet(e,t)}function HashSet__TryFindBucket_Z524259A4(e,t){return e.hashMap.has(t)?getItemFromDict(e.hashMap,t):void 0}function HashSet__FindIndex_Z142BBCA7(e,t,n){let r=0,o=-1;for(;o<0&&r<n.length;)e.comparer.Equals(t,Array_item(r,n))&&(o=0|r),r=r+1|0;return 0|o}function HashSet__TryFind_2B595(e,t){const n=HashSet__TryFindBucket_Z524259A4(e,e.comparer.GetHashCode(t));if(null!=n){const r=n,o=0|HashSet__FindIndex_Z142BBCA7(e,t,r);return o>-1?MutableSet_some(MutableSet_item_1(o,r)):void 0}}function MutableSet_HashSet_get_Comparer(e){return e.comparer}function HashSet__Clear(e){e.hashMap.clear(),e.count=0}function HashSet__get_Count(e){return 0|e.count}function HashSet__Add_2B595(e,t){const n=0|e.comparer.GetHashCode(t),r=HashSet__TryFindBucket_Z524259A4(e,n);if(null==r)return e.hashMap.set(n,[t]),e.count=e.count+1|0,!0;{const n=r;return!(HashSet__FindIndex_Z142BBCA7(e,t,n)>-1||(n.push(t),e.count=e.count+1|0,0))}}function HashSet__Contains_2B595(e,t){const n=HashSet__TryFindBucket_Z524259A4(e,e.comparer.GetHashCode(t));return null!=n&&HashSet__FindIndex_Z142BBCA7(e,t,n)>-1}function HashSet__Remove_2B595(e,t){const n=0|e.comparer.GetHashCode(t),r=HashSet__TryFindBucket_Z524259A4(e,n);if(null==r)return!1;{const o=r,i=0|HashSet__FindIndex_Z142BBCA7(e,t,o);return i>-1&&(o.splice(i,1),e.count=e.count-1|0,0===o.length&&e.hashMap.delete(n),!0)}}class Dictionary{constructor(e,t){const n=new FSharpRef(defaultOf());this.comparer=t,n.contents=this,this.hashMap=new Map([]),this.count=0,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(t[1],e[1])?(n=0,r=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(t[1],e[1])?(n=0,r=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=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__TryFindBucket_Z524259A4(e,t){return e.hashMap.has(t)?getItemFromDict(e.hashMap,t):void 0}function Dictionary__FindIndex_Z61A8C007(e,t,n){let r=0,o=-1;for(;o<0&&r<n.length;)e.comparer.Equals(t,Array_item(r,n)[0])&&(o=0|r),r=r+1|0;return 0|o}function Dictionary__TryFind_2B595(e,t){const n=Dictionary__TryFindBucket_Z524259A4(e,e.comparer.GetHashCode(t));if(null!=n){const r=n,o=0|Dictionary__FindIndex_Z61A8C007(e,t,r);return o>-1?Array_item(o,r):void 0}}function Dictionary__get_Comparer(e){return e.comparer}function Dictionary__Clear(e){e.hashMap.clear(),e.count=0}function Dictionary__get_Count(e){return 0|e.count}function Dictionary__get_Item_2B595(e,t){const n=Dictionary__TryFind_2B595(e,t);if(null!=n)return 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=0|e.comparer.GetHashCode(t),o=Dictionary__TryFindBucket_Z524259A4(e,r);if(null==o)e.hashMap.set(r,[[t,n]]),e.count=e.count+1|0;else{const r=o,i=0|Dictionary__FindIndex_Z61A8C007(e,t,r);i>-1?setItem(r,i,[t,n]):(r.push([t,n]),e.count=e.count+1|0)}}function Dictionary__Add_5BDDA1(e,t,n){const r=0|e.comparer.GetHashCode(t),o=Dictionary__TryFindBucket_Z524259A4(e,r);if(null==o)e.hashMap.set(r,[[t,n]]),e.count=e.count+1|0;else{const r=o;if(Dictionary__FindIndex_Z61A8C007(e,t,r)>-1)throw ArgumentException_$ctor_Z721C83C5(format("An item with the same key has already been added. Key: {0}",t));r.push([t,n]),e.count=e.count+1|0}}function Dictionary__ContainsKey_2B595(e,t){const n=Dictionary__TryFindBucket_Z524259A4(e,e.comparer.GetHashCode(t));return null!=n&&Dictionary__FindIndex_Z61A8C007(e,t,n)>-1}function Dictionary__Remove_2B595(e,t){const n=0|e.comparer.GetHashCode(t),r=Dictionary__TryFindBucket_Z524259A4(e,n);if(null==r)return!1;{const o=r,i=0|Dictionary__FindIndex_Z61A8C007(e,t,o);return i>-1&&(o.splice(i,1),e.count=e.count-1|0,0===o.length&&e.hashMap.delete(n),!0)}}function distinct(e,t){return delay(()=>{const n=new MutableSet_HashSet([],t);return Seq_filter(e=>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;const a=new FSharpRef(0);n=[tryGetValue(r,t,a),a.contents],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 a;const s=new FSharpRef(defaultOf());a=[tryGetValue(r,n,s),s.contents],a[0]?a[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 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 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_CallableView_$reflection())]])}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(Array_item(n,t)===n)return 0|n;setItem(t,n,0|Array_item(Array_item(n,t),t)),e=Array_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(Array_item(0,e),Array_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(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,a;if(!(List_length(e)<2)){const s=groupClassesIntoFamilies(e,n),l=List_map(e=>e.Name,e);let _;switch(_=List_isEmpty(s)?namesHaveSharedDomain(e,t)?1:2:List_isEmpty(List_tail(s))?0:namesHaveSharedDomain(e,t)?1:2,_){case 0:case 1:return;default:{const t=r.toPosition(item(0,e).Node.startIndex);return new EnergyViolation(t.Line,t.Column,ViolationType.Coherence,List_length(s)>2?Severity.High:Severity.Medium,(o=0|List_length(e),i=0|List_length(s),a=groupDescription(s,l),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)(a)),List_empty())}}}}class GodClassCtx extends Record{constructor(e,t,n){super(),this.Language=e,this.Thresholds=t,this.Positions=n}}function GodClassCtx_$reflection(){return ClassRelatedness_record_type("Energy.Core.Detectors.ClassRelatedness.GodClassCtx",[],GodClassCtx,()=>[["Language",ClassRelatedness_LanguageAdapter_$reflection()],["Thresholds",ClassRelatedness_CoherenceThresholds_$reflection()],["Positions",ClassRelatedness_PositionLookup_$reflection()]])}class MethodSignals extends Record{constructor(e,t){super(),this.MethodCount=0|e,this.DistinctTypes=0|t}}function MethodSignals_$reflection(){return ClassRelatedness_record_type("Energy.Core.Detectors.ClassRelatedness.MethodSignals",[],MethodSignals,()=>[["MethodCount",ClassRelatedness_int32_type],["DistinctTypes",ClassRelatedness_int32_type]])}class GodClassCandidate extends Record{constructor(e,t,n){super(),this.Class=e,this.Signals=t,this.Severity=n}}function GodClassCandidate_$reflection(){return ClassRelatedness_record_type("Energy.Core.Detectors.ClassRelatedness.GodClassCandidate",[],GodClassCandidate,()=>[["Class",ClassInfo_$reflection()],["Signals",MethodSignals_$reflection()],["Severity",ClassRelatedness_Severity_$reflection()]])}function GodClassCandidate_Create_Z55957A70(e){return t=>{const n=e.toPosition(t.Class.Node.startIndex);return new EnergyViolation(n.Line,n.Column,ViolationType.Coherence,t.Severity,toText(printf("File coherence warning: this class has %d methods spanning %d unrelated types. Its methods touch too many distinct concerns to be one responsibility — consider splitting it, or confirm these are one cohesive API (e.g. a tagged union of combinators over a single domain type)."))(t.Signals.MethodCount)(t.Signals.DistinctTypes),List_empty())}}function shouldMeasureGodClass(e,t){return List_length(t)>e.Thresholds.MethodCountMedium&&List_exists(t=>!e.Language.IsStaticMethod(t.Anchor),t)}function distinctSignals(e,t){const n=ofSeq(t.Methods),r=new TypeCohesionThresholds(e.Thresholds.MaxTypeDiversityRatio,e.Thresholds.MinTypedCoverage);if(shouldMeasureGodClass(e,n)){const t=typeCohesionResult(n,e.Language,r);let o,i;return 1===t.tag?t.fields[0].Result?o=1:(o=0,i=t.fields[0]):o=1,0===o?[List_length(n),i.DistinctTypes]:void 0}}function considerGodClass(e,t){const n=distinctSignals(e,t);if(null!=n){const r=0|n[0];return new GodClassCandidate(t,new MethodSignals(r,n[1]),r>e.Thresholds.MethodCountHigh?Severity.High:Severity.Medium)}}function checkGodClass(e,t){const n=List_choose(e=>considerGodClass(t,e),e);return List_isEmpty(n)?void 0:GodClassCandidate_Create_Z55957A70(t.Positions)(List_maxBy(e=>0|e.Signals.MethodCount,n,{Compare:(e,t)=>0|comparePrimitives(e,t)}))}class Collected extends Record{constructor(e,t,n,r){super(),this.FreeFunctions=e,this.Classes=t,this.Imports=n,this.FirstImportNode=r}}function Collected_$reflection(){return CoherenceCollection_record_type("Energy.Core.CoherenceCollection.Collected",[],Collected,()=>[["FreeFunctions",CoherenceCollection_list_type(CoherenceCollection_CallableView_$reflection())],["Classes",CoherenceCollection_list_type(CoherenceCollection_ClassInfo_$reflection())],["Imports",CoherenceCollection_list_type(CoherenceCollection_ImportInfo_$reflection())],["FirstImportNode",CoherenceCollection_option_type(CoherenceCollection_obj_type)]])}function isImportNode(e,t){const n=t.type;return!(!Seq_exists(e=>equals(n,e),toArray(e.NodeTypes.ImportStatement))&&!Seq_exists(e=>equals(n,e),toArray(e.NodeTypes.ImportFromStatement)))||List_contains(n,e.NodeTypes.AdditionalImportTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})}const CoherenceCollection_empty=new Collected(List_empty(),List_empty(),List_empty(),void 0);function merge(e,t){return new Collected(List_append(e.FreeFunctions,t.FreeFunctions),List_append(e.Classes,t.Classes),List_append(e.Imports,t.Imports),orElse(t.FirstImportNode,e.FirstImportNode))}function collectFree(e){return new Collected(List_singleton(e),CoherenceCollection_empty.Classes,CoherenceCollection_empty.Imports,CoherenceCollection_empty.FirstImportNode)}function collectClass(e,t){return null==e||e.Methods.push(t),CoherenceCollection_empty}function collectCallable(e,t){const n=t.Role;switch(n.tag){case 1:return 1===n.fields[0].tag?collectClass(e,t):collectFree(t);case 2:return CoherenceCollection_empty;default:return null==e?collectFree(t):collectClass(e,t)}}function classAt(e,t){return e.IsClassDefinition(t)?new ClassInfo(e.GetClassName(t),t,e.GetBaseClassNames(t),[]):void 0}function normalizeImportSource(e,t){return isNullOrEmpty(t.Source)?new ImportInfo(t.Kind,e.text,t.Bindings):t}function collectStructure(e,t,n){return null==n?isImportNode(e,t)?new Collected(CoherenceCollection_empty.FreeFunctions,CoherenceCollection_empty.Classes,List_map(e=>normalizeImportSource(t,e),e.ImportInfo(t)),some(t)):CoherenceCollection_empty:new Collected(CoherenceCollection_empty.FreeFunctions,List_singleton(n),CoherenceCollection_empty.Imports,CoherenceCollection_empty.FirstImportNode)}function traverse(e,t,n){let r;const o=classAt(e,t),i=orElse(n,o);return List_fold(merge,(r=List_map(e=>collectCallable(n,e),e.GetCallableViews(t)),List_fold(merge,collectStructure(e,t,o),r)),List_map(t=>traverse(e,t,i),nodeChildren(t)))}function CoherenceCollection_collect(e,t){return traverse(t,e,void 0)}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 TestFile_splitIntoWords(e){let t,n;return 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=n>0?substring(e,0,n):e,o=endsWith(e,".rs",5),i=e=>"test"===e||!!o&&"tests"===e,a=List_map(e=>e.toLowerCase(),TestFile_splitIntoWords(r));let s,l,_;return List_isEmpty(a)?(s=1,_=a):i(List_head(a))?(s=0,l=List_head(a)):(s=1,_=a),0===s||Seq_exists(i,toArray(List_tryLast(_)))}}function isCfgTestAttribute(e){if(equals(e.type,"attribute_item")){const t=nodeNamedChildren(e);let n,r;if(List_isEmpty(t)?n=1:List_isEmpty(List_tail(t))?(n=0,r=List_head(t)):n=1,0===n){const e=nodeNamedChildren(r);let t,n,o;if(List_isEmpty(e)||List_isEmpty(List_tail(e))?t=1:List_isEmpty(List_tail(List_tail(e)))&&"cfg"===List_head(e).text?(t=0,n=List_head(List_tail(e)),o=List_head(e)):t=1,0===t){const e=nodeNamedChildren(n);let t,r;return List_isEmpty(e)?t=1:List_isEmpty(List_tail(e))?(t=0,r=List_head(e)):t=1,0===t&&!!equals(r.type,"identifier")&&"test"===r.text}return!1}return!1}return!1}function hasCfgTestAttribute(e){for(;;){const t=e;let n,r,o;if(null!=t?(n=Option_value(t),equals(n.type,"attribute_item")?(r=0,o=Option_value(t)):r=1):r=1,0!==r)return!1;if(isCfgTestAttribute(o))return!0;e=nodePreviousNamedSibling(o)}}function isRustTestModule(e,t){return!("rust"!==e.Id||!equals(t.type,"mod_item"))&&(!!Seq_exists(e=>isTestFile(e.text+".rs"),toArray(nodeField("name",t)))||hasCfgTestAttribute(nodePreviousNamedSibling(t)))}function isRustTestFunction(e){return!!equals(e.type,"function_item")&&(e=>{for(;;){const t=e;let n,r,o,i,a,s;if(null!=t?(i=Option_value(t),equals(i.type,"attribute_item")?(a=0,s=Option_value(t)):a=1):a=1,0!==a)return!1;if(isCfgTestAttribute(s)||(n=s,equals(n.type,"attribute_item")&&(r=nodeNamedChildren(n),!List_isEmpty(r)&&List_isEmpty(List_tail(r))&&(o=nodeNamedChildren(List_head(r)),!List_isEmpty(o)&&List_isEmpty(List_tail(o))&&List_contains(List_head(o).text,ofArray(["test","tokio::test","async_std::test"]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})))))return!0;e=nodePreviousNamedSibling(s)}})(nodePreviousNamedSibling(e))}function isRustTestCode(e,t,n){if("rust"!==e.Id)return!1;if(isTestFile(t))return!0;{const t=n=>!(!isRustTestModule(e,n)&&!isRustTestFunction(n))||Seq_exists(t,toArray(nodeParent(n)));return t(n)}}const kotlinMemberImportFanOutThreshold=30;function mostOpenedFSharpSiblingNamespace(e,t){return List_tryHead(List_sortByDescending(e=>0|e[1],List_filter(e=>e[1]>=t,List_countBy(e=>e,List_choose(e=>{const t=0|e.lastIndexOf(".");return t>0&&t<e.length-1?substring(e,0,t):void 0},Set_toList(e)),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})),{Compare:(e,t)=>0|comparePrimitives(e,t)}))}function widestMemberImportFanOut(e,t){return List_tryHead(List_sortByDescending(e=>0|e[1],List_filter(e=>e[1]>=t,List_countBy(e=>e,List_collect(e=>List_map(t=>e.Source,e.Bindings),List_filter(e=>equals(e.Kind,ImportKind.Members),e)),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})),{Compare:(e,t)=>0|comparePrimitives(e,t)}))}function memberImportFanOutThreshold(e,t){return"kotlin"===e?0|kotlinMemberImportFanOutThreshold:0|t.MemberImportFanOutThreshold}function importMessage(e,t,n,r,o){let i;switch(i=null!=n?0:t?1:"fsharp"===e&&null!=r?2:3,i){case 0:{const e=n[0],t=0|n[1];return toText(printf("Import member fan-out: %d declarations from %s enter this file's local vocabulary. This is a broad API surface even though it is one dependency; review whether it is an intentional composition boundary, otherwise depend on a smaller cohesive API. Do not replace explicit imports with a wildcard import."))(t)(e)}case 1:return"Import scope pollution: a wildcard import makes an entire external scope available without qualification. Prefer explicit imports so symbol origins and collisions remain visible.";case 2:{const e=0|r[1],t=r[0];return toText(printf("Import scope sprawl: %d modules are opened, including %d siblings beneath %s. This is a name-resolution risk: opened values can shadow one another and their origin is unclear. Prefer explicit qualified access or a small named module alias; do not split a cohesive file merely to reduce the count."))(o)(e)(t)}default:return toText(printf("Import sprawl: %d distinct modules create a broad dependency surface. This can mean the file has multiple responsibilities, or that one cohesive capability is exposed through too many sibling modules. Review repeated sibling imports first; introduce a focused facade only when those imports serve one capability, and don't split the file merely to reduce the count."))(o)}}function check(e,t,n,r,o){const i=Set_ofList(List_map(e=>e.Source,e),{Compare:(e,t)=>0|comparePrimitives(e,t)}),a=List_exists(e=>equals(e.Kind,ImportKind.Wildcard),e),s="fsharp"===n.Id?mostOpenedFSharpSiblingNamespace(i,o.SiblingOpenThreshold):void 0,l=widestMemberImportFanOut(e,memberImportFanOutThreshold(n.Id,o));if(!(FSharpSet__get_Count(i)<=o.ImportBreadthThreshold)||a||null!=l||null!=s){let e;if(null==t)e=new Position(0,0);else{const n=Option_value(t);e=r.toPosition(n.startIndex)}const _=importMessage(n.Id,a,l,s,FSharpSet__get_Count(i));return new EnergyViolation(e.Line,e.Column,ViolationType.Coherence,FSharpSet__get_Count(i)>o.HighImportBreadthThreshold?Severity.High:Severity.Medium,_,List_empty())}}function isCohesiveByNamingOrType(e,t,n){return 0===n.tag?looksLikeSingleDomain(e,t.SingleDomainNameShare):n.fields[0].Result}function functionCountViolation(e,t,n,r){return new EnergyViolation(n.Line,n.Column,ViolationType.Coherence,e>r.HighFunctionCount?Severity.High:Severity.Medium,t,List_empty())}function checkFunctionCountSprawl(e,t,n,r,o){let i,a;if(!(List_length(e)<=n.UtilsFileFunctionCount)){const s=isUtilsFileName(t),l=typeCohesionResult(e,r,new TypeCohesionThresholds(n.MaxTypeDiversityRatio,n.MinTypedCoverage)),_=!s&&isCohesiveByNamingOrType(e,n,l);if(!s&&(List_length(e)<=n.GenericFunctionCount||_))return;{const t=o.toPosition(item(0,e).Anchor.startIndex);let r,s;return 1===l.tag?l.fields[0].Result?r=1:(r=0,s=l.fields[0]):r=1,functionCountViolation(List_length(e),0===r?(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)(s.DistinctTypes)):(a=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."))(a)),t,n)}}}function lineCount(e){let t;const n=List_tryFind(e=>!equals(e.type,"xml_doc"),List_reverse(nodeChildren(e.Body)));return(null==n?e.Body.endPosition.row:(t=Option_value(n),t.endPosition.row))-e.Anchor.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(item(0,o).Anchor.startIndex);return new EnergyViolation(e.Line,e.Column,ViolationType.Coherence,List_length(o)>t.MaxLargeFunctions*t.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 analyzeFileCoherence(e){const t=CoherenceCollection_collect(e.Tree,e.Language),n=t.FreeFunctions,r=List_filter(t=>!isRustTestCode(e.Language,e.FileName,t.Anchor),n),o=t.Classes,i=List_append(n,List_collect(e=>ofSeq(e.Methods),o));return addViolations(List_choose(e=>e,ofArray([checkFunctionCountSprawl(r,e.FileName,e.Options.Coherence,e.Language,e.Positions),checkLargeFunctionSprawl(i,e.Options.Coherence,e.Positions),check(t.Imports,t.FirstImportNode,e.Language,e.Positions,e.Options.Coherence),checkClassRelatedness(o,e.Options.Coherence.SingleDomainNameShare,e.Language,e.Positions),checkGodClass(o,new GodClassCtx(e.Language,e.Options.Coherence,e.Positions))])),e)}const Coherence_detector=new Detector("coherence",analyzeFileCoherence),NumberStyles={None:0,AllowLeadingWhite:1,AllowTrailingWhite:2,AllowLeadingSign:4,AllowTrailingSign:8,AllowParentheses:16,AllowDecimalPoint:32,AllowThousands:64,AllowExponent:128,AllowHexSpecifier:512,Integer:7,Number:111,Float:167};function digitsPattern(e){const t=e&NumberStyles.AllowThousands?"\\d+(?:,\\d*)*":"\\d+",n=e&NumberStyles.AllowDecimalPoint?"(?:\\.\\d*)?":"",r=e&NumberStyles.AllowDecimalPoint?"|\\.\\d+":"",o=e&NumberStyles.AllowExponent?"(?:[eE][+-]?\\d+)?":"";return new RegExp(`^(?:${t}${n}${r})${o}$`)}function splitNumber(e,t){if(t&NumberStyles.AllowHexSpecifier)throw new Exception("The number style AllowHexSpecifier is not supported on floating point data types.");let n=e.replace(/\0+$/,"");t&NumberStyles.AllowLeadingWhite&&(n=n.replace(/^[\t-\r ]+/,"")),t&NumberStyles.AllowTrailingWhite&&(n=n.replace(/[\t-\r ]+$/,""));let r=!1;if(t&NumberStyles.AllowParentheses&&n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1),r=!0),t&NumberStyles.AllowLeadingSign&&/^[+-]/.test(n)?(r="-"===n[0]?!r:r,n=n.slice(1)):t&NumberStyles.AllowTrailingSign&&/[+-]$/.test(n)&&(r="-"===n[n.length-1]?!r:r,n=n.slice(0,-1)),digitsPattern(t).test(n))return{digits:n.replace(/,/g,""),negative:r}}var Double_FSharpRef,Double_ArgumentNullException_$ctor_Z721C83C5,Double_FormatException_$ctor_Z721C83C5,Double_NumberStyles;const symbolRegex=/^[\t-\r \u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]*(?:[+-]?nan|([+-]?)infinity)[\t-\r \u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]*$/i,defaultStyle=NumberStyles.Float|NumberStyles.AllowThousands;function Double_tryParse(e,t,n){if(null!=e){const r=splitNumber(e,t);if(void 0!==r){const e=Number.parseFloat(r.digits);return n.contents=r.negative?-e:e,!0}const o=symbolRegex.exec(e);if(null!=o)return n.contents=null==o[1]?NaN:"-"===o[1]?-1/0:1/0,!0}return!1}function Double_parse(e,t=defaultStyle){const n=new Double_FSharpRef(0);if(Double_tryParse(e,t,n))return n.contents;throw null==e?Double_ArgumentNullException_$ctor_Z721C83C5("s"):Double_FormatException_$ctor_Z721C83C5(`The input string '${e}' was not in a correct format.`)}function parseIgnoringUnderscores(e){return Double_parse(null==e?e:e.replace(/_/g,""),Double_NumberStyles.Float)}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}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,a,s,l,_,u;switch(null!=o&&isNodeType(e.NodeTypes.ExpressionStatement,Option_value(o))?(i=0,a=Option_value(o)):(i=1,s=o),n=0===i?nodeParent(a):s,null!=n?isNodeType(e.NodeTypes.Module,Option_value(n))?(l=0,_=Option_value(n)):isNodeType(e.NodeTypes.ExportStatement,Option_value(n))?(l=1,u=Option_value(n)):l=2:l=2,l){case 0:return!hasEnclosingFunction(e,r);case 1:return Seq_exists(t=>isNodeType(e.NodeTypes.Module,t),toArray(nodeParent(u)));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 analyzeEnabledMagicNumbers(e){const t=n=>{let r,o;if(!e.Options.MagicNumber.IncludeTestFiles&&isRustTestModule(e.Language,n))return List_empty();if(r=n,isNodeType(e.Language.NodeTypes.IntegerLiteral,r)||isNodeType(e.Language.NodeTypes.FloatLiteral,r)){let t;const r=new FSharpRef(0);if(t=[Double_tryParse(e.Language.NumericLiteralText(n),231,r),r.contents],t[0]){if(List_contains(signedValue(n,t[1]),e.Options.MagicNumber.Allowlist,{Equals:(e,t)=>e===t,GetHashCode:e=>0|numberHash(e)})||e.Language.IsStructuralNumber(n)||isInConstantContext(e.Language,n)||Seq_exists(t=>List_contains(t.type,e.Language.SubscriptNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),toArray(nodeParent(n)))||e.Language.IsDefaultParameterValue(n))return List_empty();{const t=e.Positions.toPosition(n.startIndex);return List_singleton(new EnergyViolation(t.Line,t.Column,ViolationType.Magic,Severity.Low,(o=n.text,toText(printf("Magic number: %s. Consider extracting to a named constant."))(o)),List_empty()))}}return List_empty()}return List_collect(t,nodeChildren(n))};return addViolations(t(e.Tree),e)}function analyzeMagicNumbers(e){return!e.Options.MagicNumber.Enabled||!e.Options.MagicNumber.IncludeTestFiles&&isTestFile(e.FileName)?e:analyzeEnabledMagicNumbers(e)}const MagicNumber_detector=new Detector("magicNumber",analyzeMagicNumbers);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,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 decisionStringCandidate(e,t){let n;if(Seq_exists((n=t.type,e=>equals(n,e)),toArray(e.Language.NodeTypes.StringLiteral))){const n=stripQuotes(t.text),r=!(!isEqualityComparisonOperand(e.Language,t)&&!isMembershipOperand(e.Language,t,n))||isKeyOrIndexPosition(e.Language,t),o=!!(isDocstring(e.Language,t)||e.Language.IsFormattedOrInterpolatedString(t)||List_contains(n,e.Options.MagicString.Allowlist,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}))||n.length<=1;return r&&!o?List_singleton([t,n]):List_empty()}return List_empty()}function analyzeEnabledMagicStrings(e){const t=n=>!e.Options.MagicString.IncludeTestFiles&&isRustTestModule(e.Language,n)?List_empty():List_append(decisionStringCandidate(e,n),List_collect(t,nodeChildren(n)));return addViolations(List_choose(t=>{let n;const r=t[1];if(!(List_length(r)<e.Options.MagicString.MinDuplicates)){const o=List_head(r),i=e.Positions.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.'))(t[0])(n)),List_empty())}},List_groupBy(e=>e[1],t(e.Tree),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})),e)}function analyzeMagicStrings(e){return!e.Options.MagicString.Enabled||!e.Options.MagicString.IncludeTestFiles&&isTestFile(e.FileName)?e:analyzeEnabledMagicStrings(e)}const MagicString_detector=new Detector("magicString",analyzeMagicStrings);function findParametersNode(e,t){const n=List_tryFind(e=>equals(e.type,t),nodeChildren(e));return null==n?List_tryHead(List_collect(e=>ofArray(toArray(findParametersNode(e,t))),nodeChildren(e))):some(Option_value(n))}function ParameterCount_analyzeCallable(e,t){const n=0|List_length(t.Parameters);if(n>e.Options.ParameterCount.MediumThreshold){const r=e.Positions.toPosition(t.Anchor.startIndex);return List_singleton(new EnergyViolation(r.Line,r.Column,ViolationType.Parameters,n>e.Options.ParameterCount.HighThreshold?Severity.High:Severity.Medium,toText(printf("Parameter explosion: %d parameters. Consider using objects or builder pattern."))(n),List_empty()))}return List_empty()}function analyzeParameterCount(e){const t=n=>List_append(List_collect(t=>ParameterCount_analyzeCallable(e,t),e.Language.GetCallableViews(n)),List_collect(t,nodeChildren(n)));return addViolations(t(e.Tree),e)}const ParameterCount_detector=new Detector("parameterCount",analyzeParameterCount);var Range_delay,Range_unfold,fromZero,Range_op_Addition,toInt64_unchecked,toUInt64_unchecked,fromParts,op_Addition_1,ErrorShadowing_record_type,ErrorShadowing_int32_type,ErrorShadowing_float64_type,ErrorShadowing_string_type,ErrorShadowing_list_type,ErrorShadowing_obj_type,ErrorShadowing_Severity_$reflection,ErrorShadowing_ViolationType_$reflection,ErrorShadowing_ErrorShadowingModeThresholds_$reflection;function makeRangeStepFunction(e,t,n,r){const o=0|compare(e,n);if(0===o)throw Operators_InvalidArg("step","The step of a range cannot be zero.");const i=o>0;return n=>{const o=0|compare(n,t);return i&&o<=0||!i&&o>=0?[n,r(n,e)]:void 0}}function integralRangeStep(e,t,n,r,o){const i=makeRangeStepFunction(t,n,r,o);return delay(()=>Seq_unfold(i,e))}function rangeBigInt(e,t,n){return integralRangeStep(e,t,n,fromZero(),Range_op_Addition)}function rangeDecimal(e,t,n){return integralRangeStep(e,t,n,fromParts(0,0,0,!1,0),op_Addition_1)}function rangeDouble(e,t,n){return integralRangeStep(e,t,n,0,(e,t)=>e+t)}function rangeInt64(e,t,n){return integralRangeStep(e,t,n,0n,(e,t)=>toInt64_unchecked(Range_op_Addition(e,t)))}function rangeUInt64(e,t,n){return integralRangeStep(e,t,n,0n,(e,t)=>toUInt64_unchecked(Range_op_Addition(e,t)))}function rangeChar(e,t){const n=0|t.charCodeAt(0);return Range_delay(()=>Range_unfold(e=>e<=n?[String.fromCharCode(65535&e),e+1]:void 0,~~e.charCodeAt(0)))}function BodyLines_count(e,t,n){const r=e=>List_contains(e.type,ofArray(["comment","line_comment","block_comment"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})?List_singleton([e.startIndex,e.endIndex]):List_collect(r,nodeNamedChildren(e));return 0|Set_count(Set_ofList(List_collect(n=>{const o=r(n);return List_map(e=>0|t.toPosition(e).Line,List_filter(t=>!isWhiteSpace(getCharAtIndex(e,t))&&!List_exists(e=>t>=e[0]&&t<e[1],o),toList(rangeDouble(n.startIndex,1,n.endIndex-1))))},n),{Compare:(e,t)=>0|comparePrimitives(e,t)}))}const atFunctionRoot=!0,descendIntoBody=!1;function allFunctions(e,t){const n=t=>List_append(e.IsFunctionDefinition(t)?List_singleton(t):List_empty(),List_collect(n,nodeChildren(t)));return n(t)}function regionsInFunction(e,t){const n=(t,r)=>{let o;return!t&&e.IsFunctionDefinition(r)?List_empty():List_append(ofArray(toArray(e.GetErrorHandlingRegion(r))),(o=nodeChildren(r),List_collect(curry2(n)(descendIntoBody),o)))};return n(atFunctionRoot,t)}function expand(e,t){const n=e.GetErrorHandlingRegion(t);if(null==n)return List_singleton(t);{const t=n;return List_collect(t=>expand(e,t),List_append(t.ProtectedItems,t.RecoveryItems))}}function functionItems(e,t){return List_collect(t=>expand(e,t),e.GetFunctionLogicalItems(t))}const percentScale=100;class ModeMeasurement extends Record{constructor(e,t,n){super(),this.ItemCount=0|e,this.Share=t,this.Severity=n}}function ModeMeasurement_$reflection(){return ErrorShadowing_record_type("Energy.Core.Detectors.ErrorShadowing.ModeMeasurement",[],ModeMeasurement,()=>[["ItemCount",ErrorShadowing_int32_type],["Share",ErrorShadowing_float64_type],["Severity",ErrorShadowing_Severity_$reflection()]])}class MeasurementInput extends Record{constructor(e,t){super(),this.ItemCount=0|e,this.FunctionItemCount=0|t}}function MeasurementInput_$reflection(){return ErrorShadowing_record_type("Energy.Core.Detectors.ErrorShadowing.MeasurementInput",[],MeasurementInput,()=>[["ItemCount",ErrorShadowing_int32_type],["FunctionItemCount",ErrorShadowing_int32_type]])}function qualifies(e,t){if(!(t.ItemCount<e.MinItems||0===t.FunctionItemCount)){const n=t.ItemCount/t.FunctionItemCount;return n<e.Threshold?void 0:new ModeMeasurement(t.ItemCount,n,n>=e.HighThreshold?Severity.High:Severity.Medium)}}function finding(e,t,n,r,o){const i=e.Positions.toPosition(t.startIndex);return new EnergyViolation(i.Line,i.Column,n,r,o,List_empty())}class ShareRule extends Record{constructor(e,t,n,r,o){super(),this.Kind=e,this.Label=t,this.Advice=n,this.Thresholds=r,this.Items=o}}function ShareRule_$reflection(){return ErrorShadowing_record_type("Energy.Core.Detectors.ErrorShadowing.ShareRule",[],ShareRule,()=>[["Kind",ErrorShadowing_ViolationType_$reflection()],["Label",ErrorShadowing_string_type],["Advice",ErrorShadowing_string_type],["Thresholds",ErrorShadowing_ErrorShadowingModeThresholds_$reflection()],["Items",ErrorShadowing_list_type(ErrorShadowing_obj_type)]])}function shareFinding(e,t,n,r){let o,i,a;return ofArray(toArray((o=qualifies(r.Thresholds,new MeasurementInput(List_length(r.Items),n)),null!=o?(i=o,finding(e,t.Anchor,r.Kind,i.Severity,(a=0|round(i.Share*percentScale),toText(printf("%s: %d logical items (%d%%) of %d function logical items. %s"))(r.Label)(i.ItemCount)(a)(n)(r.Advice)))):void 0)))}function oversizedFindings(e,t){const n=e.Options.ErrorShadowing;return n.Enabled&&n.OversizedRecoveryBlockEnabled?List_choose(t=>{const r=0|BodyLines_count(e.Source,e.Positions,t.Items);return r<=n.RecoveryBlock.MaxLines?void 0:finding(e,t.Anchor,ViolationType.OversizedRecoveryBlock,Severity.Medium,toText(printf("Oversized recovery block: %d body lines exceeds the maximum of %d. Extract or simplify this handler or cleanup body."))(r)(n.RecoveryBlock.MaxLines))},t.RecoveryBodies):List_empty()}function boundaryFindings(e,t,n){const r=e.Options.ErrorShadowing,o=0|BodyLines_count(e.Source,e.Positions,n.ProtectedBody);return toList(delay(()=>Seq_append(shareFinding(e,n,t,new ShareRule(ViolationType.ErrorShadowing,"Broad protected scope","Narrow the protected region to operations this boundary can recover from.",r.ProtectedScope,n.ProtectedItems)),delay(()=>Seq_append(r.RecoveryDominanceEnabled&&o>1?shareFinding(e,n,t,new ShareRule(ViolationType.RecoveryDominance,"Recovery/cleanup dominance","Extract or simplify recovery and cleanup policy so the happy path remains clear.",r.Recovery,n.RecoveryItems)):Seq_empty(),delay(()=>oversizedFindings(e,n)))))))}function analyzeErrorShadowing(e){return addViolations(List_collect(t=>{const n=0|List_length(functionItems(e.Language,t));return List_collect(t=>boundaryFindings(e,n,t),regionsInFunction(e.Language,t))},allFunctions(e.Language,e.Tree)),e)}const ErrorShadowing_detector=new Detector("errorShadowing",analyzeErrorShadowing),inversionRatioThreshold=.5,deepIfDepthThreshold=3;function 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=>hasType(e.NodeTypes.Block,t),nodeChildren(t));return null==n?List_tryFind(t=>hasType(e.NodeTypes.Block,t),List_collect(nodeChildren,nodeChildren(t))):some(Option_value(n))}function functionStatements(e,t){return List_filter(t=>!hasType(e.NodeTypes.Comment,t)&&!List_contains(t.type,ofArray(["line_comment","block_comment"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&!isNullOrWhiteSpace(t.text),nodeNamedChildren(t))}function hasElse(e,t){return!List_isEmpty(e.GetElseIfBranches(t))||List_exists(t=>!!hasType(e.NodeTypes.ElseClause,t)||equals(t.type,"else"),nodeChildren(t))}function terminalConditional(e,t){const n=functionStatements(e,t);let r,o,i,a;switch(List_isEmpty(n)?r=2:List_isEmpty(List_tail(n))?hasType(e.NodeTypes.IfStatement,List_head(n))?(r=0,o=List_head(n)):r=2:List_isEmpty(List_tail(List_tail(n)))&&hasType(e.NodeTypes.IfStatement,List_head(n))&&List_contains(List_head(List_tail(n)).type,ofArray(["return_statement","return_expression"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})?(r=1,i=List_head(List_tail(n)),a=List_head(n)):r=2,r){case 0:return some(o);case 1:return some(a);default:return}}function guardChain(e,t){let n;if(hasElse(e,t))return List_empty();{const r=defaultArg((n=List_tryFind(t=>hasType(e.NodeTypes.Block,t),nodeChildren(t)),null!=n?functionStatements(e,Option_value(n)):void 0),List_empty());let o,i;return List_isEmpty(r)?o=1:List_isEmpty(List_tail(r))&&hasType(e.NodeTypes.IfStatement,List_head(r))?(o=0,i=List_head(r)):o=1,0===o?cons(t,guardChain(e,i)):List_singleton(t)}}function deeper(e,t,n,r){const o=[e,t],i=[n,r];return compare(i[0],o[0])>0?i:o}function deepestIfNode(e,t,n){let r,o;const i=e.GetCognitiveStructure(t);if(e.IsFunctionDefinition(t)||equals(i,CognitiveStructure.Closure))return[0,void 0];{const a=!!hasType(e.NodeTypes.IfStatement,t)||Seq_exists(n=>List_exists(e=>e.id===t.id,e.GetElseIfBranches(n)),toArray(nodeParent(t))),s=a?[n+1,some(t)]:[0,void 0],l=null!=i&&0===i.tag?1===i.fields[0].tag?(r=i.fields[1],r):(i.fields[1],a?(o=i.fields[1],o):List_empty()):List_empty();return List_fold((e,t)=>deeper(e[0],e[1],t[0],t[1]),s,List_map(t=>deepestIfNode(e,t,List_exists(e=>e.id===t.id,l)?n+1:n),nodeChildren(t)))}}function dominantBody(e,t,n){return Seq_exists(n=>{const r=(n.endIndex-n.startIndex)/(t.endIndex-t.startIndex);return List_length(functionStatements(e,n))>2&&r>inversionRatioThreshold},toArray(List_tryFind(t=>hasType(e.NodeTypes.Block,t),nodeChildren(n))))}function recommendation(e,t,n){let r,o;const i=defaultArg((r=terminalConditional(e,n),null!=r?guardChain(e,Option_value(r)):void 0),List_empty());let a,s,l;switch(List_isEmpty(i)?a=2:List_length(i)>=2?(a=0,s=List_head(i)):List_isEmpty(List_tail(i))&&dominantBody(e,t,List_head(i))?(a=1,l=List_head(i)):a=2,a){case 0:return[s,(o=0|List_length(i),toText(printf("These %d nested conditions keep the main operation indented. Consider guard clauses, preserving the existing return values and fallthrough behavior."))(o))];case 1:return[l,"This condition encloses most of the function. Consider a guard clause to bring the main operation to the top level, preserving the existing return values and fallthrough behavior."];default:{const t=deepestIfNode(e,n,0),r=0|t[0];let o;const i=t[1];return o=null!=i?(Option_value(i),r>=deepIfDepthThreshold?i:void 0):void 0,null!=o?[Option_value(o),toText(printf("These conditions are nested %d levels deep. Consider extracting a named operation to reduce how many conditions readers must track."))(r)]:void 0}}}function analyzeInversionOpportunities(e){const t=n=>{let r,o,i,a;return List_append(e.Language.IsFunctionDefinition(n)?ofArray(toArray((o=findBody(e.Language,n),r=null!=o?recommendation(e.Language,n,Option_value(o)):void 0,null!=r?(i=r,a=e.Positions.toPosition(i[0].startIndex),new EnergyViolation(a.Line,a.Column,ViolationType.Inversion,Severity.Medium,i[1],List_empty())):void 0))):List_empty(),List_collect(t,nodeChildren(n)))};return addViolations(t(e.Tree),e)}const Inversion_detector=new Detector("inversion",analyzeInversionOpportunities);function MatchOpportunitySupport_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,a;return defaultArg((o=null==e.NodeTypes.ElseClause?List_tryFind(t=>MatchOpportunitySupport_hasType(e.NodeTypes.IfStatement,t),nodeChildren(t)):(i=List_tryFind(t=>MatchOpportunitySupport_hasType(e.NodeTypes.ElseClause,t),nodeChildren(t)),null!=i?List_tryFind(t=>MatchOpportunitySupport_hasType(e.NodeTypes.IfStatement,t),nodeChildren(Option_value(i))):void 0),null!=o?(a=Option_value(o),n(a,cons(a,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=>e.IsMatchCaseLiteral(t),i=t=>MatchOpportunitySupport_hasType(e.NodeTypes.StringLiteral,t)?MatchOpportunitySupport_stripQuotes(t.text):t.text,a=n=>FSharpSet__Contains(t,n.id)||MatchOpportunitySupport_hasType(e.NodeTypes.Block,n)||MatchOpportunitySupport_hasType(e.NodeTypes.ElseClause,n)?List_empty():List_append(List_collect(e=>{const t=r(e.Left),n=o(e.Right),a=r(e.Right),s=o(e.Left);let l;switch(l=t&&n?0:a&&s?1:2,l){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(a,nodeChildren(n))));return a(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)))}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){const t=(n,r)=>{let o,i,a,s;if(MatchOpportunitySupport_hasType(e.Language.NodeTypes.IfStatement,r)&&!FSharpSet__Contains(n,r.id)){const t=collectChainBranches(e.Language,r),a=List_fold((e,t)=>FSharpSet__Add(e,t.id),n,List_tail(t)),l=List_map(n=>collectDiscriminants(e.Language,otherBranchIds(n,t),n),t);s=[ofArray(toArray((o=List_forAll(e=>!List_isEmpty(e),l),o&&List_length(t)>=e.Options.MatchOpportunity.MinBranches?(i=commonDiscriminant(l),null!=i?matchOpportunityViolation(e.Positions,r,t,i):void 0):void 0))),a]}else s=[List_empty(),n];return List_append(s[0],(a=nodeChildren(r),List_collect(curry2(t)(s[1]),a)))};return addViolations(t(Set_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}),e.Tree),e)}const MatchOpportunity_detector=new Detector("matchOpportunity",analyzeMatchOpportunities);function analyzeLogicalControlFlow(e){const t=n=>{let r,o,i,a,s,l,_,u,c,d;return List_append((r=e.Language.GetBooleanOperator(n),o=nodeParent(n),null!=r?1===r.tag?null!=o?(i=Option_value(o),Seq_exists((a=i.type,e=>equals(a,e)),toArray(e.Language.NodeTypes.ExpressionStatement))?(s=Option_value(o),l=e.Positions.toPosition(n.startIndex),List_singleton(new EnergyViolation(l.Line,l.Column,ViolationType.LogicalControlFlow,Severity.Low,"If-statement disguised as '||'. Consider an explicit if-statement instead.",List_empty()))):List_empty()):List_empty():null!=o?(_=Option_value(o),Seq_exists((u=_.type,e=>equals(u,e)),toArray(e.Language.NodeTypes.ExpressionStatement))?(c=Option_value(o),d=e.Positions.toPosition(n.startIndex),List_singleton(new EnergyViolation(d.Line,d.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(t,nodeChildren(n)))};return addViolations(t(e.Tree),e)}const LogicalControlFlow_detector=new Detector("logicalControlFlow",analyzeLogicalControlFlow);function analyzeEnabledOpaqueBooleans(e){const t=n=>{let r,o;return!e.Options.OpaqueBoolean.IncludeTestFiles&&isRustTestModule(e.Language,n)?List_empty():List_append(e.Language.IsBooleanLiteral(n)&&e.Language.IsPositionalCallArgument(n)?(r=e.Positions.toPosition(n.startIndex),List_singleton(new EnergyViolation(r.Line,r.Column,ViolationType.OpaqueBoolean,Severity.Low,(o=n.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."))(o)),List_empty()))):List_empty(),List_collect(t,nodeChildren(n)))};return addViolations(t(e.Tree),e)}function analyzeOpaqueBooleanLiteral(e){return!e.Options.OpaqueBoolean.Enabled||!e.Options.OpaqueBoolean.IncludeTestFiles&&isTestFile(e.FileName)?e:analyzeEnabledOpaqueBooleans(e)}const OpaqueBoolean_detector=new Detector("opaqueBoolean",analyzeOpaqueBooleanLiteral);function descendants(e){return cons(e,List_collect(descendants,nodeChildren(e)))}function parameters(e,t){let n;return List_map(t=>{const n=e.ExtractTypedParameter(t);if(null==n)return[t.text,void 0];{const e=n;return[e.Name,e.Type]}},defaultArg((n=findParametersNode(t.ParametersRoot,e.NodeTypes.Parameters),null!=n?nodeNamedChildren(Option_value(n)):void 0),List_empty()))}function rejectsNull(e,t,n){const r=nodeChildren(n);return!(!List_exists(n=>n.text===t&&List_contains(n.type,e.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),r)||!List_exists(e=>List_contains(e.text,ofArray(["null","None","nil","nullptr"]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),r))&&List_exists(e=>List_contains(e.text,ofArray(["==","===","is","="]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),r)}function checkedParameter(e,t,n){const r=descendants(n.Condition),o=e.ExtractReturnType(t.ParametersRoot);return List_tryFind(t=>{const i=t[0];if(!List_exists(t=>!!List_contains(t.type,e.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&t.text===i,r))return!1;{const r=n.Success;switch(r.tag){case 0:{const a=r.fields[0];return!(a.text!==i||!List_contains(a.type,e.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||0===n.IdentityReturnPolicy.tag&&!Seq_exists(e=>Seq_forAll(t=>e===t,toArray(o)),toArray(t[1]))||rejectsNull(e,i,n.Condition))}case 2:return!0;default:return Seq_forAll(e=>List_contains(e,ofArray(["None","unit","Unit","void","undefined"]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),toArray(o))}}},parameters(e,t))}function inspect(e,t){let n,r,o,i,a,s,l;return ofArray(toArray((n=e.Language.GetGuardedValidation(t),null!=n?(r=n,o=checkedParameter(e.Language,t,r),null!=o?(i=o,a=e.Positions.toPosition(r.Anchor.startIndex),new EnergyViolation(a.Line,a.Column,ViolationType.ParseDontValidate,Severity.Low,(l=r.Success,s=0===l.tag?"returned unchanged":2===l.tag?"success returns only a boolean":"success returns no useful value",toText(printf("Parse, don't validate: '%s' is checked but %s. Consider returning a domain type that preserves the checked property instead of requiring callers to remember it."))(i[0])(s)),List_empty())):void 0):void 0)))}function analyzeParseDontValidate(e){const t=n=>List_append(e.Language.IsFunctionDefinition(n)?List_collect(t=>inspect(e,t),e.Language.GetFunctionHeads(n)):List_empty(),List_collect(t,nodeNamedChildren(n)));return addViolations(t(e.Tree),e)}const ParseDontValidate_detector=new Detector("parseDontValidate",analyzeParseDontValidate);var PrimitiveObsession_record_type,PrimitiveObsession_string_type,PrimitiveObsession_obj_type,PrimitiveObsession_bool_type;const minDistinctValues=3,sampleSize=4,booleanTypeNames=Set_ofList(ofArray(["bool","boolean","Boolean"]),{Compare:(e,t)=>0|comparePrimitives(e,t)});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 findSwapRiskViolations(e,t,n){return List_map(e=>{const r=e[0],o=e[1];return new EnergyViolation(t.toPosition(r.Node.startIndex).Line,t.toPosition(r.Node.startIndex).Column,ViolationType.PrimitiveObsession,Severity.Medium,`Primitive obsession: consecutive parameters '${r.Name}: ${r.Type}' and '${o.Name}: ${o.Type}' share the same primitive type — a caller can swap them and nothing will complain. Consider ${n.DistinctTypeAdvice} so the type checker catches it.`,List_empty())},List_filter(e=>{const t=e[0],r=e[1];return!(t.Type!==r.Type||!Set_contains(t.Type,n.PrimitiveTypeNames)||Set_contains(t.Type,booleanTypeNames)||t.KeywordOnly&&r.KeywordOnly)},List_pairwise(e)))}function findBooleanBlindness(e,t){const n=List_filter(e=>!!Set_contains(e.Type,booleanTypeNames)&&!e.KeywordOnly,e);let r,o,i;if(List_isEmpty(n)||List_isEmpty(List_tail(n))?r=1:(r=0,o=n,i=List_head(n)),0===r){const e=0|List_length(o),n=join(", ",List_map(e=>e.Name,o)),r=e>2?", ...":"";return new EnergyViolation(t.toPosition(i.Node.startIndex).Line,t.toPosition(i.Node.startIndex).Column,ViolationType.PrimitiveObsession,Severity.Medium,`Boolean blindness: this signature takes ${interpolate("%d%P()",[e])} boolean parameters (${n}), adjacent or not — a call site like f(true, false${r}) doesn't say which flag is which, and combinations invalid in this domain still type-check. Consider a single enum or union naming the valid combinations instead of independent booleans.`,List_empty())}}function findParameterCollisions(e,t,n){const r=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];return List_append(findSwapRiskViolations(r,t,n),ofArray(toArray(findBooleanBlindness(r,t))))}function PrimitiveObsession_stripQuotes(e){return substring(e,1,e.length-2)}function stringEquality(e,t){const n=t=>List_contains(t.type,e.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),r=t=>{let n;return Seq_exists((n=t.type,e=>equals(n,e)),toArray(e.NodeTypes.StringLiteral))},o=n(t.Left),i=r(t.Right),a=n(t.Right),s=r(t.Left);let l;switch(l=o&&i?0:a&&s?1:2,l){case 0:return[t.Left,PrimitiveObsession_stripQuotes(t.Right.text)];case 1:return[t.Right,PrimitiveObsession_stripQuotes(t.Left.text)];default:return}}function recordStringValues(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)}}function findStringlyTypedControlFlow(e,t,n){const r=(e,t)=>{let o;const i=List_fold((e,t)=>List_contains(t.Left.type,n.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&!List_isEmpty(t.Values)?recordStringValues(t.Left,t.Values,e):e,List_fold((e,t)=>recordStringValues(t[0],List_singleton(t[1]),e),t,List_choose(e=>stringEquality(n,e),n.GetEqualityComparisons(e))),n.GetMembershipComparisons(e));return List_fold((e,t)=>r(t,e),(o=n.GetMatchStringCases(e),null==o?i:recordStringValues(o[0],List_map(e=>PrimitiveObsession_stripQuotes(e.text),o[1]),i)),nodeChildren(e))};return List_choose(e=>{let n,r;const o=e[1],i=o[0];if(!(Set_count(i)<minDistinctValues)){const a=t.toPosition(o[1].startIndex),s=List_truncate(sampleSize,Set_toList(i)),l=Set_count(i)>List_length(s)?", …":"";return new EnergyViolation(a.Line,a.Column,ViolationType.PrimitiveObsession,Severity.Low,(n=0|Set_count(i),r=join(", ",s),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)(l)),List_empty())}},Map_toList(r(e,Map_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}))))}function analyzePrimitiveObsession(e){const t=n=>List_append(e.Language.IsFunctionDefinition(n)?List_collect(t=>{let n;return List_append((n=findParametersNode(t.ParametersRoot,e.Language.NodeTypes.Parameters),null==n?List_empty():findParameterCollisions(Option_value(n),e.Positions,e.Language)),findStringlyTypedControlFlow(t.Body,e.Positions,e.Language))},e.Language.GetFunctionHeads(n)):List_empty(),List_collect(t,nodeChildren(n)));return addViolations(t(e.Tree),e)}const PrimitiveObsession_detector=new Detector("primitiveObsession",analyzePrimitiveObsession);function runWhen(e,t,n){return e?t(n):n}function detectorPipeline(e){return runWhen(e.Options.Nesting.Enabled,detector.Run,runWhen(e.Options.Cyclomatic.Enabled,Cyclomatic_detector.Run,runWhen(e.Options.Cognitive.Enabled,Cognitive_detector.Run,runWhen(e.Options.Coherence.Enabled,Coherence_detector.Run,runWhen(e.Options.MagicNumber.Enabled,MagicNumber_detector.Run,runWhen(e.Options.MagicString.Enabled,MagicString_detector.Run,runWhen(e.Options.ParameterCount.Enabled,ParameterCount_detector.Run,runWhen(e.Options.ErrorShadowing.Enabled,ErrorShadowing_detector.Run,runWhen(e.Options.Inversion.Enabled,Inversion_detector.Run,runWhen(e.Options.MatchOpportunity.Enabled,MatchOpportunity_detector.Run,runWhen(e.Options.LogicalControlFlow.Enabled,LogicalControlFlow_detector.Run,runWhen(e.Options.OpaqueBoolean.Enabled,OpaqueBoolean_detector.Run,runWhen(e.Options.ParseDontValidate.Enabled,ParseDontValidate_detector.Run,runWhen(e.Options.PrimitiveObsession.Enabled,PrimitiveObsession_detector.Run,e))))))))))))))}var Analyze_defaultAnalyzeOptions,Analyze_record_type,Analyze_string_type,Analyze_obj_type,Analyze_list_type,Analyze_union_type,Analyze_LanguageAdapter_$reflection,Analyze_EnergyViolation_$reflection;const defaultThresholds=null;class AnalysisInput extends Record{constructor(e,t,n,r){super(),this.Source=e,this.Tree=t,this.Language=n,this.FileName=r}}function AnalysisInput_$reflection(){return Analyze_record_type("Energy.Core.Analyze.AnalysisInput",[],AnalysisInput,()=>[["Source",Analyze_string_type],["Tree",Analyze_obj_type],["Language",Analyze_LanguageAdapter_$reflection()],["FileName",Analyze_string_type]])}class AnalysisResult extends Record{constructor(e){super(),this.Violations=e}}function AnalysisResult_$reflection(){return Analyze_record_type("Energy.Core.Analyze.AnalysisResult",[],AnalysisResult,()=>[["Violations",Analyze_list_type(Analyze_EnergyViolation_$reflection())]])}class AnalysisError extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["UnsupportedLanguage","ConfigurationFailed","SourceReadFailed","GrammarLoadFailed","ParseFailed","AnalysisFailed","ReportWriteFailed"]}}function AnalysisError_$reflection(){return Analyze_union_type("Energy.Core.Analyze.AnalysisError",[],AnalysisError,()=>[[["filePath",Analyze_string_type]],[["message",Analyze_string_type]],[["filePath",Analyze_string_type],["message",Analyze_string_type]],[["languageId",Analyze_string_type],["message",Analyze_string_type]],[["filePath",Analyze_string_type],["message",Analyze_string_type]],[["filePath",Analyze_string_type],["message",Analyze_string_type]],[["filePath",Analyze_string_type],["message",Analyze_string_type]]])}function analysisErrorMessage(e){switch(e.tag){case 1:return e.fields[0];case 2:return"Could not read "+e.fields[0]+": "+e.fields[1];case 3:return"Could not load "+e.fields[0]+" grammar: "+e.fields[1];case 4:return"Could not parse "+e.fields[0]+": "+e.fields[1];case 5:return"Could not analyze "+e.fields[0]+": "+e.fields[1];case 6:return"Could not write report "+e.fields[0]+": "+e.fields[1];default:return"Unsupported file type: "+e.fields[0]}}function applySuppressionStage(e,t){const n=applySuppressions(t,e.Source);return List_append(n.Violations,n.SuppressionNotes)}function runPipeline(e){const t=detectorPipeline(e);return applySuppressionStage(t,List_reverse(t.Violations))}function createContext(e,t){return new AnalysisContext(t.Source,t.Tree,createPositionLookup(t.Source),t.Language,t.FileName,e,List_empty())}function toResult(e){return new AnalysisResult(e)}function analyze(e){return toResult(runPipeline(createContext(Analyze_defaultAnalyzeOptions,e)))}function analyzeWith(e,t){return toResult(runPipeline(createContext(e,t)))}function isConditional(e){return List_contains(e.type,ofArray(["if_statement","if_expression"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})}function isElif(e){return List_contains(e.type,ofArray(["elif_clause","elif_expression"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})}function significantChildren(e){return List_filter(e=>!List_contains(e.type,ofArray(["comment","line_comment","block_comment"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(e))}function afterElse(e){return List_tryItem(1,List_skipWhile(e=>!equals(e.type,"else"),significantChildren(e)))}function isElseIf(e){return Seq_exists(t=>!!equals(t.type,"else_clause")||!!isConditional(t)&&Seq_exists(t=>t.id===e.id,toArray(afterElse(t))),toArray(nodeParent(e)))}function nestedChildren(e){let t,n;const r=nodeNamedChildren(e),o=List_choose(t=>nodeField(t,e),ofArray(["body","consequence","then","else","alternative","block"]));return List_filter(e=>!(equals(e.type,"else_clause")||isElif(e)||isConditional(e)&&isElseIf(e)),List_isEmpty(o)?isConditional(e)||isElif(e)?(n=nodeField("condition",e),t=null!=n?n:nodeField("guard",e),List_filter(e=>Seq_forAll(t=>t.id!==e.id,toArray(t)),r)):equals(e.type,"when_expression")?List_filter(e=>equals(e.type,"when_entry"),r):equals(e.type,"do_while_statement")?List_truncate(1,r):List_truncate(1,List_reverse(r)):o)}function isCatchRule(e){let t;return!!equals(e.type,"rule")&&Seq_exists(e=>equals(e.type,"try_expression"),toArray((t=nodeParent(e),null!=t?nodeParent(Option_value(t)):void 0)))}function isLabelJump(e){const t=e.type;let n;switch(n="goto_statement"===t?0:"break_statement"===t||"continue_statement"===t?1:"labeled_expression"===t?2:3,n){case 0:return!0;case 1:return!List_isEmpty(nodeNamedChildren(e));case 2:return Seq_exists(e=>"break@"===e.text||"continue@"===e.text,toArray(List_tryHead(nodeNamedChildren(e))));default:return!1}}function classify(e,t){let n,r;const o=t.type;let i;switch(i="parenthesized_expression"===o||"paren_expression"===o?0:"arrow_function"===o||"lambda"===o||"lambda_expression"===o||"lambda_literal"===o||"fun_expression"===o||"function_expression"===o||"anonymous_method_expression"===o?1:"else_clause"===o?2:"else"===o?3:"ternary_expression"===o?isElif(t)||isConditional(t)&&isElseIf(t)?4:List_contains(t.type,e,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||isCatchRule(t)?5:6:"conditional_expression"===o?isElif(t)||isConditional(t)&&isElseIf(t)?4:List_contains(t.type,e,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||isCatchRule(t)?5:6:isElif(t)||isConditional(t)&&isElseIf(t)?4:List_contains(t.type,e,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||isCatchRule(t)?5:isLabelJump(t)?7:8,i){case 0:{const e=List_tryExactlyOne(nodeNamedChildren(t));return null!=e?new CognitiveStructure(2,[Option_value(e)]):void 0}case 1:return CognitiveStructure.Closure;case 2:return Seq_exists(e=>equals(e.type,"try_statement"),toArray(nodeParent(t)))||Seq_exists(isConditional,toArray(afterElse(t)))?void 0:new CognitiveStructure(0,[CognitiveIncrement.Hybrid,nodeNamedChildren(t)]);case 3:{const e=nodeParent(t);let r,o;return null!=e?(n=Option_value(e),isConditional(n)&&!Seq_exists(isConditional,toArray(afterElse(n)))?(r=0,o=Option_value(e)):r=1):r=1,0===r?new CognitiveStructure(0,[CognitiveIncrement.Fundamental,List_empty()]):void 0}case 4:return new CognitiveStructure(0,[CognitiveIncrement.Hybrid,nestedChildren(t)]);case 5:return new CognitiveStructure(0,[CognitiveIncrement.Structural,nestedChildren(t)]);case 6:{const e=List_choose(e=>nodeField(e,t),ofArray(["consequence","alternative"]));return new CognitiveStructure(0,[CognitiveIncrement.Structural,List_isEmpty(e)?(r=nodeNamedChildren(t),List_choose(e=>e,ofArray([List_tryHead(r),List_tryLast(r)]))):e])}case 7:return new CognitiveStructure(0,[CognitiveIncrement.Fundamental,List_empty()]);default:return}}const comparisonOperatorNodeType="comparison_operator",importFromStatementNodeType="import_from_statement",fromPrefix="from ",importSeparator=" import ",importPrefix="import ",aliasedImportPartCount=3;function collectStringValues(e){const t=List_fold((e,t)=>{const n=e[1];if(e[0])return[!0,n];if(t.isNamed){if(equals(t.type,"string")){const e=t.text;return[!1,List_append(n,List_singleton(substring(e,1,e.length-2)))]}return[!0,n]}return[!1,n]},[!1,List_empty()],nodeChildren(e)),n=t[1];return t[0]||List_isEmpty(n)?void 0:n}function membershipComparison(e,t,n){const r=item(t,e),o=item(n,e);if(List_contains(o.type,ofArray(["tuple","list","set"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})){const e=collectStringValues(o);return null!=e?new MembershipComparison(r,e):void 0}}function membershipComparisons(e){if(equals(e.type,comparisonOperatorNodeType)){const t=nodeChildren(e);return List_choose(e=>membershipComparison(t,e[0],e[1]),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()}function importBinding(e){const t=String_split(e,[" "],void 0,1),n=Array_item(0,t);return new ImportBinding(n,t.length>=aliasedImportPartCount&&"as"===Array_item(1,t)?Array_item(2,t):n)}function importedMembers(e,t){const n=substring(e,fromPrefix.length,t-fromPrefix.length).trim(),r=trim(substring(e,t+importSeparator.length).trim(),"(",")");return List_singleton("*"===r?new ImportInfo(ImportKind.Wildcard,n,List_empty()):new ImportInfo(ImportKind.Members,n,List_map(importBinding,List_filter(e=>""!==e,List_map(e=>e.trim(),ofArray(String_split(r,[","],void 0,0)))))))}function importFromInfo(e){const t=e.text,n=0|indexOf(t,importSeparator,4);return n>fromPrefix.length?importedMembers(t,n):List_singleton(new ImportInfo(ImportKind.Members,t,List_empty()))}function moduleImport(e){return new ImportInfo(ImportKind.Module,Array_item(0,String_split(e.trim(),[" "],void 0,1)),List_empty())}function importInfo(e){return equals(e.type,importFromStatementNodeType)?importFromInfo(e):List_map(moduleImport,ofArray(String_split(substring(e.text,importPrefix.length),[","],void 0,0)))}var ValidationSyntax_record_type,ValidationSyntax_list_type,ValidationSyntax_string_type,ValidationSyntax_option_type,ValidationSyntax_lambda_type,ValidationSyntax_obj_type,ValidationSyntax_bool_type,ValidationSyntax_BooleanLiteralPolarity_$reflection;class GuardSyntax extends Record{constructor(e,t,n,r,o,i,a,s,l){super(),this.Containers=e,this.Conditional=t,this.Rejections=n,this.Return=r,this.FailureCalls=o,this.EmptyValues=i,this.IsNonExecutable=a,this.BooleanLiteralValue=s,this.PreservesCheckedInformation=l}}function GuardSyntax_$reflection(){return ValidationSyntax_record_type("Energy.Languages.ValidationSyntax.GuardSyntax",[],GuardSyntax,()=>[["Containers",ValidationSyntax_list_type(ValidationSyntax_string_type)],["Conditional",ValidationSyntax_string_type],["Rejections",ValidationSyntax_list_type(ValidationSyntax_string_type)],["Return",ValidationSyntax_option_type(ValidationSyntax_string_type)],["FailureCalls",ValidationSyntax_list_type(ValidationSyntax_string_type)],["EmptyValues",ValidationSyntax_list_type(ValidationSyntax_string_type)],["IsNonExecutable",ValidationSyntax_lambda_type(ValidationSyntax_obj_type,ValidationSyntax_bool_type)],["BooleanLiteralValue",ValidationSyntax_lambda_type(ValidationSyntax_obj_type,ValidationSyntax_option_type(ValidationSyntax_BooleanLiteralPolarity_$reflection()))],["PreservesCheckedInformation",ValidationSyntax_lambda_type(ValidationSyntax_obj_type,ValidationSyntax_lambda_type(ValidationSyntax_option_type(ValidationSyntax_obj_type),ValidationSyntax_bool_type))]])}function children(e,t){return List_filter(t=>!List_contains(t.type,ofArray(["comment","line_comment","block_comment"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&!e.IsNonExecutable(t),nodeNamedChildren(t))}function statements(e,t){return List_contains(t.type,e.Containers,{Equals:equals,GetHashCode:e=>0|safeHash(e)})?List_collect(t=>statements(e,t),children(e,t)):List_singleton(t)}function callee(e,t){e:for(;;){const n=e,r=t;if(equals(r.type,"application_expression")){const o=List_tryHead(children(n,r));if(null!=o){e=n,t=Option_value(o);continue e}return}return r.text}}function rejects(e,t){let n;const r=statements(e,t);let o,i;if(List_isEmpty(r)?o=1:List_isEmpty(List_tail(r))?(o=0,i=List_head(r)):o=1,0===o){if(List_contains(i.type,e.Rejections,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||equals(i.type,"application_expression")&&Seq_exists(t=>List_contains(t,e.FailureCalls,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),toArray(callee(e,i))))return!0;{const t=i,r=e.Return;let o,a;if(null!=r?(n=r,equals(t.type,n)?(o=0,a=r):o=1):o=1,0===o){const n=children(e,t);let r,o;return List_isEmpty(n)?r=1:List_isEmpty(List_tail(n))?(r=0,o=List_head(n)):r=1,0===r&&equals(e.BooleanLiteralValue(o),BooleanLiteralPolarity.LiteralFalse)}return!1}}return!1}function ValidationSyntax_classify(e,t){const n=e.BooleanLiteralValue(t);return new ValidationSuccess(null==n?0:2,[t])}function success(e,t){let n;const r=e.Return;if(null==r)return List_contains(t.text,e.EmptyValues,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})?ValidationSuccess.NoValue:ValidationSyntax_classify(e,t);if(n=r,equals(t.type,n)){const n=children(e,t);return List_isEmpty(n)?ValidationSuccess.NoValue:List_isEmpty(List_tail(n))?List_contains(List_head(n).text,e.EmptyValues,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})?ValidationSuccess.NoValue:ValidationSyntax_classify(e,List_head(n)):void 0}}function bodyItems(e,t){return List_contains(t.Body.type,e.Containers,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||equals(t.Body.type,e.Conditional)?statements(e,t.Body):List_collect(t=>statements(e,t),List_filter(t=>!!List_contains(t.type,e.Containers,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||equals(t.type,e.Conditional),children(e,t.Body)))}function extract(e,t){let n,r;const o=e.PreservesCheckedInformation(t.ParametersRoot,void 0)?List_empty():bodyItems(e,t);let i,a,s,l;switch(List_isEmpty(o)?i=2:List_isEmpty(List_tail(o))?(i=0,a=List_head(o)):List_isEmpty(List_tail(List_tail(o)))?(i=1,s=List_head(o),l=List_head(List_tail(o))):i=2,i){case 0:r=[a,ValidationSuccess.NoValue];break;case 1:{const t=success(e,l);r=null!=t?[s,t]:void 0;break}default:r=void 0}if(null!=r){const t=r,o=t[0];if(equals(o.type,e.Conditional)){const r=children(e,o);let i,a,s,l,_,u;switch(List_isEmpty(r)||List_isEmpty(List_tail(r))?i=2:List_isEmpty(List_tail(List_tail(r)))?rejects(e,List_head(List_tail(r)))?(i=0,a=List_head(r),s=List_head(List_tail(r))):i=2:List_isEmpty(List_tail(List_tail(List_tail(r))))&&equals(e.BooleanLiteralValue(List_head(List_tail(r))),BooleanLiteralPolarity.LiteralFalse)?(i=1,l=List_head(r),_=List_head(List_tail(List_tail(r))),u=List_head(List_tail(r))):i=2,i){case 0:n=new GuardedValidation(o,a,t[1],IdentityReturnPolicy.RequireParameterAnnotation);break;case 1:n=new GuardedValidation(o,l,ValidationSyntax_classify(e,_),IdentityReturnPolicy.RequireParameterAnnotation);break;default:n=void 0}}else n=void 0}else n=void 0;return null!=n?e.PreservesCheckedInformation(t.ParametersRoot,some(n.Condition))?void 0:n:void 0}const typeAnnotationNodeType="type",argumentListNodeType="argument_list",attributeNodeType="attribute",identifierNodeType="identifier",typedDefaultParameterNodeType="typed_default_parameter",Python_comparisonOperatorNodeType="comparison_operator",callNodeType="call",andOperatorNodeType="and",tryStatementNodeType="try_statement",exceptClauseNodeType="except_clause",finallyClauseNodeType="finally_clause",functionDefinitionNodeType="function_definition",lambdaNodeType="lambda",parametersNodeType="parameters",lambdaParametersNodeType="lambda_parameters",parameterChildTypes=ofArray([identifierNodeType,"default_parameter","typed_parameter",typedDefaultParameterNodeType]);function parametersOf(e,t){let n;return defaultArg((n=List_tryFind(t=>equals(t.type,e),nodeChildren(t)),null!=n?List_filter(e=>List_contains(e.type,parameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(n))):void 0),List_empty())}function anonymousBinding(e){let t,n,r,o,i;const a=nodeParent(e);let s,l;if(null!=a?(i=Option_value(a),equals(i.type,"assignment")&&Seq_exists(t=>t.id===e.id,toArray(nodeField("right",i)))?(s=0,l=Option_value(a)):s=1):s=1,0===s){let e,i;const a=nodeField("left",l);let s;i=null!=a?(t=Option_value(a),equals(t.type,identifierNodeType)?a:void 0):void 0,e=null!=i?(n=Option_value(i),n.text):void 0;const _=nodeParent(l);let u,c,d;switch(s=null!=_?nodeParent(Option_value(_)):void 0,null!=s?(r=Option_value(s),equals(r.type,"module")?(u=0,c=Option_value(s)):(o=Option_value(s),equals(o.type,"block")&&Seq_exists(e=>equals(e.type,"class_definition"),toArray(nodeParent(o)))?(u=1,d=Option_value(s)):u=2)):u=2,u){case 0:return[new CallableRole(1,[AnonymousBindingScope.ModuleBinding]),e];case 1:return[new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding]),e];default:return[CallableRole.InlineAnonymous,e]}}return[CallableRole.InlineAnonymous,void 0]}function callableViews(e){let t,n;const r=e.type;if(equals(r,functionDefinitionNodeType))return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,CallableRole.NamedDefinition,(t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0),parametersOf(parametersNodeType,e)));if(equals(r,lambdaNodeType)){const t=anonymousBinding(e);return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,t[0],t[1],parametersOf(lambdaParametersNodeType,e)))}return List_empty()}function Python_isDocstring(e){if(equals(e.type,"expression_statement")){const t=nodeNamedChildren(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,"string")}return!1}function Python_bodyItems(e){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,"block"),t);return null==n?t:nodeNamedChildren(Option_value(n))}function errorHandlingRegion(e){let t;if(equals(e.type,tryStatementNodeType)){const n=nodeNamedChildren(e);let r;const o=List_tryFind(e=>equals(e.type,"block"),n);return r=null!=o?nodeNamedChildren(Option_value(o)):void 0,null!=r?(t=r,new ErrorHandlingRegion(e,t,t,List_collect(Python_bodyItems,List_filter(e=>!!equals(e.type,exceptClauseNodeType)||equals(e.type,finallyClauseNodeType),n)),List_map(e=>new RecoveryBody(e,Python_bodyItems(e)),List_filter(e=>!!equals(e.type,exceptClauseNodeType)||equals(e.type,finallyClauseNodeType),n)))):void 0}}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"binary_operator"===r?!!n&&List_exists(e=>equals(e.type,"%"),nodeChildren(t)):!!equals(r,attributeNodeType)&&!!n&&isFormatCall(t)}const pythonLanguageAdapter=new LanguageAdapter("python","grammars/tree-sitter-python.wasm",new NodeTypes("block",parametersNodeType,"if_statement","else_clause","for_statement","while_statement","conditional_expression",lambdaNodeType,"import_statement","import_from_statement",List_empty(),"expression_statement","assignment","module",void 0,"comment","integer","float","string"),e=>equals(e.type,functionDefinitionNodeType),e=>List_singleton(new FunctionHead(e,e)),callableViews,parameterChildTypes,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)}},e=>classify(ofArray(["if_statement","elif_clause","for_statement","while_statement","except_clause","match_statement"]),e),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=>{if(equals(e.type,"else_clause")){const t=nodeParent(e);return null!=t&&equals(Option_value(t).type,"try_statement")}return!1},ofArray([identifierNodeType,attributeNodeType]),e=>{let t,n;if(equals(e.type,"typed_parameter")||equals(e.type,typedDefaultParameterNodeType)){const r=List_tryFind(e=>equals(e.type,identifierNodeType),nodeChildren(e)),o=List_tryFind(e=>equals(e.type,typeAnnotationNodeType),nodeChildren(e));return null!=r&&null!=o?(t=Option_value(r),n=Option_value(o),new TypedParameter(t.text,n.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=item(n+1,r);return equals(e.type,typeAnnotationNodeType)?e.text:void 0}return}},new GenericBrackets("[","]"),Set_ofList(ofArray(["str","int","float","bool","bytes"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),errorHandlingRegion,Python_bodyItems,ofArray(["keyword_separator","list_splat_pattern"]),"NewType or a dataclass",e=>{if(equals(e.type,Python_comparisonOperatorNodeType)){const t=nodeChildren(e);return List_map(e=>{const n=0|e[0];return new EqualityComparison(item(n-1,t),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=>{},membershipComparisons,e=>!(!equals(e.type,"string")&&!equals(e.type,"integer"))||equals(e.type,"float"),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)&&item(List_length(r)-1,r).id===e.id}},e=>!1,e=>e.text,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,importInfo,e=>equals(e.type,"class_definition"),e=>{let t,n;return Seq_exists(e=>List_exists(e=>!!equals(e.type,"decorator")&&"@staticmethod"===e.text,nodeChildren(e)),toArray((t=nodeParent(e),null!=t?(n=Option_value(t),equals(n.type,"decorated_definition")?t:void 0):void 0)))},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))))},(()=>{const e=new GuardSyntax(List_singleton("block"),"if_statement",List_singleton("raise_statement"),"return_statement",List_empty(),List_singleton("None"),Python_isDocstring,e=>equals(e.type,"true")?BooleanLiteralPolarity.LiteralTrue:equals(e.type,"false")?BooleanLiteralPolarity.LiteralFalse:void 0,(e,t)=>List_exists(e=>{if(equals(e.type,"type")){const t=e.text;return!!contains(t,"TypeGuard[",4)||contains(t,"TypeIs[",4)}return!1},nodeChildren(e)));return t=>extract(e,t)})()),functionDeclarationLeft="function_declaration_left",FSharp_functionDefinitionNodeType="function_or_value_defn",functionExpressionNodeType="fun_expression",argumentPatternsNodeType="argument_patterns",FSharp_parameterChildTypes=ofArray(["long_identifier","typed_pattern"]);function firstDescendant(e,t){return List_tryPick(t=>e(t)?some(t):firstDescendant(e,t),nodeChildren(t))}function FSharp_parametersOf(e){let t;return defaultArg((t=firstDescendant(e=>equals(e.type,argumentPatternsNodeType),e),null!=t?List_filter(e=>List_contains(e.type,FSharp_parameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(t))):void 0),List_empty())}function bindingNameIn(e){let t;const n=firstDescendant(e=>equals(e.type,"identifier"),e);return null!=n?(t=Option_value(n),t.text):void 0}function functionHeads(e){const t=nodeChildren(e),n=List_filter(e=>equals(e.type,functionDeclarationLeft),t);return List_length(n)<=1?List_singleton(new FunctionHead(e,e)):List_map(n=>{let r,o;const i=List_skip(List_findIndex(e=>e.id===n.id,t)+1,t);return new FunctionHead(n,(r=List_tryFindIndex(e=>equals(e.type,"="),i),null!=r&&r+1<List_length(i)?(o=0|r,item(o+1,i)):e))},n)}function classMemberBinding(e,t){return Seq_exists(t=>t.id===e.id,toArray(List_tryLast(nodeNamedChildren(t))))?[new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding]),bindingNameIn(t)]:[CallableRole.InlineAnonymous,void 0]}function valueBindingName(e){const t=List_tryFind(e=>equals(e.type,"value_declaration_left"),nodeChildren(e));return null!=t?bindingNameIn(Option_value(t)):void 0}function isModuleBinding(e){let t;return Seq_exists(e=>equals(e.type,"file"),toArray((t=nodeParent(e),null!=t?nodeParent(Option_value(t)):void 0)))}function valueBinding(e,t){const n=Seq_exists(t=>t.id===e.id,toArray(nodeField("body",t))),r=valueBindingName(t);return n&&isModuleBinding(t)?[new CallableRole(1,[AnonymousBindingScope.ModuleBinding]),r]:[CallableRole.InlineAnonymous,r]}function FSharp_anonymousBinding(e){let t,n;const r=nodeParent(e);let o,i,a;switch(null!=r?(t=Option_value(r),equals(t.type,"method_or_prop_defn")?(o=0,i=Option_value(r)):(n=Option_value(r),equals(n.type,FSharp_functionDefinitionNodeType)?(o=1,a=Option_value(r)):o=2)):o=2,o){case 0:return classMemberBinding(e,i);case 1:return valueBinding(e,a);default:return[CallableRole.InlineAnonymous,void 0]}}function namedCallableView(e,t){return new CallableView(t.ParametersRoot,t.Body,e,CallableRole.NamedDefinition,bindingNameIn(t.ParametersRoot),FSharp_parametersOf(t.ParametersRoot))}function anonymousCallableView(e){const t=FSharp_anonymousBinding(e);return new CallableView(e,defaultArg(List_tryLast(nodeNamedChildren(e)),e),e,t[0],t[1],FSharp_parametersOf(e))}function FSharp_callableViews(e){const t=List_exists(e=>equals(e.type,functionDeclarationLeft),nodeChildren(e)),n=e.type;return equals(n,FSharp_functionDefinitionNodeType)&&t?List_map(t=>namedCallableView(e,t),functionHeads(e)):equals(n,functionExpressionNodeType)?List_singleton(anonymousCallableView(e)):List_empty()}function stringCaseOf(e){const t=List_tryHead(nodeNamedChildren(e));if(null!=t){const e=Option_value(t);return equals(e.type,"string")?some(e):List_tryFind(e=>equals(e.type,"string"),nodeNamedChildren(e))}}function matchStringCases(e){if(equals(e.type,"match_expression")){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,"long_identifier_or_op"),t),r=List_collect(e=>equals(e.type,"rules")?List_choose(stringCaseOf,nodeNamedChildren(e)):List_empty(),t);let o,i,a;return null!=n?(Option_value(n),List_length(r)>0?(o=0,i=r,a=Option_value(n)):o=1):o=1,0===o?[a,i]:void 0}}function isNamedArgumentPosition(e){return(e=>{e:for(;;){const t=e;let n,r;const o=nodeParent(t);let i,a,s;switch(null!=o?(n=Option_value(o),equals(n.type,"paren_expression")||equals(n.type,"tuple_expression")?(i=0,a=Option_value(o)):(r=Option_value(o),equals(r.type,"application_expression")?(i=1,s=Option_value(o)):i=2)):i=2,i){case 0:e=a;continue e;case 1:{const e=List_tryItem(0,nodeChildren(s));return null==e||Option_value(e).id!==t.id}default:return!1}break}})(e)}const tryExpressionNodeType="try_expression",declarationExpressionNodeType="declaration_expression",rulesNodeType="rules",ruleNodeType="rule";function logicalItems(e){let t;const n=e.type;return t=n,equals(t,declarationExpressionNodeType)||equals(t,"sequential_expression")||equals(n,rulesNodeType)?List_collect(logicalItems,nodeNamedChildren(e)):equals(n,ruleNodeType)?List_singleton(e):equals(n,"function_or_value_defn")?List_collect(logicalItems,List_filter(e=>"="!==e.text,List_skipWhile(e=>"="!==e.text,nodeChildren(e)))):equals(n,"ce_expression")?List_collect(logicalItems,List_skip(1,nodeNamedChildren(e))):List_singleton(e)}function FSharp_errorHandlingRegion(e){if(equals(e.type,tryExpressionNodeType)){const t=nodeNamedChildren(e),n=List_tryFindIndex(e=>equals(e.type,rulesNodeType),t);if(null==n){let n,r,o;return List_isEmpty(t)||List_isEmpty(List_tail(t))?n=1:(n=0,r=List_head(List_tail(t)),o=List_head(t)),0===n?new ErrorHandlingRegion(e,List_singleton(o),logicalItems(o),logicalItems(r),List_singleton(new RecoveryBody(defaultArg(List_tryFind(e=>"finally"===e.text,nodeChildren(e)),r),List_singleton(r)))):void 0}{const r=0|n;return new ErrorHandlingRegion(e,List_take(r,t),List_collect(logicalItems,List_take(r,t)),List_collect(logicalItems,List_skip(r,t)),List_map(e=>{let t;return new RecoveryBody(e,(t=List_skipWhile(e=>"->"!==e.text,nodeChildren(e)),List_isEmpty(t)?List_empty():List_tail(t)))},List_filter(e=>equals(e.type,ruleNodeType),List_collect(nodeNamedChildren,List_skip(r,t)))))}}}const fSharpLanguageAdapter=new LanguageAdapter("fsharp","grammars/tree-sitter-fsharp.wasm",new NodeTypes(void 0,argumentPatternsNodeType,"if_expression",void 0,"for_expression","while_expression",void 0,functionExpressionNodeType,"import_decl",void 0,List_empty(),void 0,"function_or_value_defn","declaration_expression",void 0,"line_comment","int","float","string"),e=>!!equals(e.type,FSharp_functionDefinitionNodeType)&&List_exists(e=>equals(e.type,functionDeclarationLeft),nodeChildren(e)),functionHeads,FSharp_callableViews,FSharp_parameterChildTypes,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)}},e=>classify(ofArray(["if_expression","elif_expression","for_expression","while_expression","match_expression"]),e),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;switch(Option_value(t).text){case"&&":return BooleanOperator.And;case"||":return BooleanOperator.Or;default:return}}},e=>!1,List_singleton("long_identifier_or_op"),e=>{if(equals(e.type,"typed_pattern")){const t=nodeChildren(e),n=List_tryFind(e=>equals(e.type,"identifier_pattern"),t);let r;const o=List_tryFindIndex(e=>equals(e.type,":"),t);if(null!=o){const e=0|o;r=e+1<List_length(t)?some(item(e+1,t)):void 0}else r=void 0;let i,a,s;return null!=n&&null!=r?(i=0,a=Option_value(n),s=Option_value(r)):i=1,0===i?new TypedParameter(a.text,s.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,a;return null!=t&&t+1<List_length(nodeChildren(e))?(r=0,a=t):r=1,0===r?item(a+1,nodeChildren(e)).text:void 0}return}},new GenericBrackets("<",">"),Set_ofList(ofArray(["string","int","float","bool"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),FSharp_errorHandlingRegion,logicalItems,List_empty(),"a single-case union type",e=>{let t;if(!equals(e.type,"infix_expression")||isNamedArgumentPosition(e))return List_empty();{let n;const r=List_tryFind(e=>equals(e.type,"infix_op"),nodeChildren(e));if(n=null!=r?(t=Option_value(r),"="===t.text?r:void 0):void 0,null==n)return List_empty();{const t=Option_value(n),r=List_filter(e=>e.id!==t.id,nodeChildren(e));let o,i,a;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),a=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,equals(a.type,"const")&&1===List_length(nodeChildren(a))?List_head(nodeChildren(a)):a)):List_empty()}}},matchStringCases,e=>List_empty(),e=>!(!equals(e.type,"string")&&!equals(e.type,"int"))||equals(e.type,"float"),e=>List_filter(e=>equals(e.type,"elif_expression"),nodeChildren(e)),List_empty(),e=>!1,e=>!1,e=>!1,e=>e.text,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,a;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,a=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(a);return null!=e&&equals(Option_value(e).type,"application_expression")}default:return!1}},e=>!1,e=>{let t,n;return List_singleton(new ImportInfo(ImportKind.ScopeOpen,(t=List_tryFind(e=>equals(e.type,"long_identifier"),nodeChildren(e)),null==t?e.text:(n=Option_value(t),n.text)),List_empty()))},e=>!1,e=>!1,e=>{},e=>List_empty(),(()=>{const e=new GuardSyntax(List_singleton("sequential_expression"),"if_expression",List_empty(),void 0,ofArray(["invalidArg","invalidArgf","failwith","failwithf","raise"]),ofArray(["()","None"]),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))&&equals(List_head(t).type,"bool")?(n=0,r=List_head(t)):n=1,0===n?"true"===e.text?BooleanLiteralPolarity.LiteralTrue:"false"===e.text?BooleanLiteralPolarity.LiteralFalse:void 0:void 0}},(e,t)=>!1);return t=>extract(e,t)})()),TypeScript_typeAnnotationNodeType="type_annotation",typeIdentifierNodeType="type_identifier",TypeScript_tryStatementNodeType="try_statement",statementBlockNodeType="statement_block",catchClauseNodeType="catch_clause",TypeScript_finallyClauseNodeType="finally_clause",functionDeclarationNodeType="function_declaration",methodDefinitionNodeType="method_definition",arrowFunctionNodeType="arrow_function",TypeScript_functionExpressionNodeType="function_expression",formalParametersNodeType="formal_parameters",TypeScript_parameterChildTypes=ofArray(["required_parameter","optional_parameter"]);function TypeScript_parametersOf(e){const t=nodeField("parameters",e),n=nodeField("parameter",e);return null==t?null==n?List_empty():List_singleton(Option_value(n)):List_filter(e=>List_contains(e.type,TypeScript_parameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(t)))}function moduleDeclarationContainer(e){let t;const n=nodeParent(e);let r,o,i;return null!=n?(t=Option_value(n),equals(t.type,"export_statement")?(r=0,o=Option_value(n)):(r=1,i=n)):(r=1,i=n),0===r?nodeParent(o):i}function TypeScript_anonymousBinding(e){let t,n,r,o,i,a,s,l,_;const u=nodeParent(e);let c,d,p;switch(null!=u?(l=Option_value(u),equals(l.type,"public_field_definition")&&Seq_exists(t=>t.id===e.id,toArray(nodeField("value",l)))?(c=0,d=Option_value(u)):(_=Option_value(u),equals(_.type,"variable_declarator")&&Seq_exists(t=>t.id===e.id,toArray(nodeField("value",_)))?(c=1,p=Option_value(u)):c=2)):c=2,c){case 0:return[new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding]),(t=nodeField("name",d),null!=t?(n=Option_value(t),n.text):void 0)];case 1:{let e;const t=nodeField("name",p);return e=null!=t?(r=Option_value(t),r.text):void 0,[defaultArg((a=nodeParent(p),i=null!=a?moduleDeclarationContainer(Option_value(a)):void 0,o=null!=i?(s=Option_value(i),equals(s.type,"program")?i:void 0):void 0,null!=o?(Option_value(o),new CallableRole(1,[AnonymousBindingScope.ModuleBinding])):void 0),CallableRole.InlineAnonymous),e]}default:return[CallableRole.InlineAnonymous,void 0]}}function TypeScript_callableViews(e){let t,n,r,o;const i=e.type;if(t=i,equals(t,functionDeclarationNodeType)||equals(t,methodDefinitionNodeType))return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,CallableRole.NamedDefinition,(n=nodeField("name",e),null!=n?(r=Option_value(n),r.text):void 0),TypeScript_parametersOf(e)));if(o=i,equals(o,arrowFunctionNodeType)||equals(o,TypeScript_functionExpressionNodeType)){const t=TypeScript_anonymousBinding(e);return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,t[0],t[1],TypeScript_parametersOf(e)))}return List_empty()}function TypeScript_bodyItems(e){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,statementBlockNodeType),t);return null==n?t:nodeNamedChildren(Option_value(n))}function TypeScript_errorHandlingRegion(e){let t;if(equals(e.type,TypeScript_tryStatementNodeType)){const n=nodeNamedChildren(e),r=List_tryFind(e=>equals(e.type,statementBlockNodeType),n);return null!=r?(t=Option_value(r),new ErrorHandlingRegion(e,nodeNamedChildren(t),nodeNamedChildren(t),List_collect(TypeScript_bodyItems,List_filter(e=>!!equals(e.type,catchClauseNodeType)||equals(e.type,TypeScript_finallyClauseNodeType),n)),List_map(e=>new RecoveryBody(e,TypeScript_bodyItems(e)),List_filter(e=>!!equals(e.type,catchClauseNodeType)||equals(e.type,TypeScript_finallyClauseNodeType),n)))):void 0}}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 typeScriptLanguageAdapter=new LanguageAdapter("typescript","grammars/tree-sitter-typescript.wasm",new NodeTypes("statement_block",formalParametersNodeType,"if_statement","else_clause","for_statement","while_statement","ternary_expression",arrowFunctionNodeType,"import_statement",void 0,List_empty(),"expression_statement","lexical_declaration","program","export_statement","comment","number",void 0,"string"),e=>!!equals(e.type,functionDeclarationNodeType)||equals(e.type,methodDefinitionNodeType),e=>List_singleton(new FunctionHead(e,e)),TypeScript_callableViews,TypeScript_parameterChildTypes,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)}},e=>classify(ofArray(["if_statement","for_statement","for_in_statement","while_statement","catch_clause","switch_statement","do_statement"]),e),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=>!1,ofArray(["identifier","member_expression"]),e=>{let t;if(equals(e.type,"required_parameter")||equals(e.type,"optional_parameter")){const n=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(e)),r=List_tryFind(e=>equals(e.type,TypeScript_typeAnnotationNodeType),nodeChildren(e));if(null!=n){const e=Option_value(n);if(null!=r){const n=List_tryFind(e=>!equals(e.type,":"),nodeChildren(Option_value(r)));return null!=n?(t=Option_value(n),new TypedParameter(e.text,t.text)):void 0}return}return}},e=>{let t;const n=List_tryFind(e=>equals(e.type,TypeScript_typeAnnotationNodeType),nodeChildren(e));if(null!=n){const e=List_tryFind(e=>!equals(e.type,":"),nodeChildren(Option_value(n)));return null!=e?(t=Option_value(e),t.text):void 0}},new GenericBrackets("<",">"),Set_ofList(ofArray(["string","number","boolean"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),TypeScript_errorHandlingRegion,TypeScript_bodyItems,List_empty(),"a branded type (a nominal/opaque type with zero runtime overhead)",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,a;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),a=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,a)):List_empty()}}return List_empty()},e=>{},e=>List_empty(),e=>!!equals(e.type,"string")||equals(e.type,"number"),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=>!1,e=>e.text,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=>{let t;const n=List_tryFind(e=>equals(e.type,"string"),nodeChildren(e));t=null==n?e.text:Option_value(n).text;const r=e.text,o=0|r.indexOf("{"),i=0|r.indexOf("}");return o>=0&&i>o?List_singleton(new ImportInfo(ImportKind.Members,t,List_map(e=>{const t=String_split(e,[" "],void 0,1),n=Array_item(0,t);return new ImportBinding(n,t.length>=3&&"as"===Array_item(1,t)?Array_item(2,t):n)},List_filter(e=>""!==e,List_map(e=>String_replace(e.trim(),"type ",""),ofArray(String_split(substring(r,o+1,i-o-1),[","],void 0,0))))))):(r.indexOf("* as "),List_singleton(new ImportInfo(ImportKind.Module,t,List_empty())))},e=>!!equals(e.type,"class_declaration")||equals(e.type,"abstract_class_declaration"),e=>{let t,n,r;return List_exists(e=>"static"===e.text,nodeChildren((t=nodeParent(e),null!=t?(n=Option_value(t),equals(n.type,"public_field_definition")?(r=Option_value(t),r):e):e)))},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))}},(()=>{const e=new GuardSyntax(List_singleton("statement_block"),"if_statement",List_singleton("throw_statement"),"return_statement",List_empty(),List_singleton("undefined"),e=>!1,e=>equals(e.type,"true")?BooleanLiteralPolarity.LiteralTrue:equals(e.type,"false")?BooleanLiteralPolarity.LiteralFalse:void 0,(e,t)=>List_exists(e=>!(!equals(e.type,"asserts_annotation")&&!equals(e.type,"type_predicate_annotation"))||!!equals(e.type,"property_identifier")&&"constructor"===e.text,nodeNamedChildren(e)));return t=>extract(e,t)})()),Kotlin_tryExpressionNodeType="try_expression",blockNodeType="block",functionBodyNodeType="function_body",catchBlockNodeType="catch_block",finallyBlockNodeType="finally_block",Kotlin_functionDeclarationNodeType="function_declaration",lambdaLiteralNodeType="lambda_literal",functionParametersNodeType="function_value_parameters",namedParameterChildTypes=List_singleton("parameter");function namedParametersOf(e){let t;return defaultArg((t=List_tryFind(e=>equals(e.type,functionParametersNodeType),nodeChildren(e)),null!=t?List_filter(e=>List_contains(e.type,namedParameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(t))):void 0),List_empty())}function lambdaParametersOf(e){let t;return defaultArg((t=List_tryFind(e=>equals(e.type,"lambda_parameters"),nodeChildren(e)),null!=t?List_filter(e=>equals(e.type,"variable_declaration"),nodeChildren(Option_value(t))):void 0),List_empty())}function hasNarrowingContract(e){let t,n;return null!=(n=List_tryFind(e=>equals(e.type,functionBodyNodeType),nodeNamedChildren(e)),t=null!=n?List_tryHead(nodeNamedChildren(Option_value(n))):void 0,null!=t?List_tryFind(e=>!!equals(e.type,"call_expression")&&Seq_exists(e=>!!equals(e.type,"identifier")&&"contract"===e.text,toArray(List_tryHead(nodeNamedChildren(e)))),nodeNamedChildren(Option_value(t))):void 0)}function booleanLiteralPolarity(e){if(equals(e.type,"identifier"))switch(e.text){case"true":return BooleanLiteralPolarity.LiteralTrue;case"false":return BooleanLiteralPolarity.LiteralFalse;default:return}}function propertyBindingName(e){let t,n;const r=List_tryFind(e=>equals(e.type,"variable_declaration"),nodeChildren(e));return n=null!=r?List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(Option_value(r))):void 0,null!=n?(t=Option_value(n),t.text):void 0}function Kotlin_anonymousBinding(e){let t,n,r,o,i,a;const s=nodeParent(e);let l,_;return null!=s?(a=Option_value(s),equals(a.type,"property_declaration")&&Seq_exists(t=>t.id===e.id,toArray(List_tryLast(nodeNamedChildren(a))))?(l=0,_=Option_value(s)):l=1):l=1,0===l?[(t=nodeParent(_),null!=t?(n=Option_value(t),equals(n.type,"source_file")?(r=Option_value(t),new CallableRole(1,[AnonymousBindingScope.ModuleBinding])):(o=Option_value(t),equals(o.type,"class_body")?(i=Option_value(t),new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding])):CallableRole.InlineAnonymous)):CallableRole.InlineAnonymous),propertyBindingName(_)]:[CallableRole.InlineAnonymous,void 0]}function Kotlin_callableViews(e){let t,n;const r=e.type;if(equals(r,Kotlin_functionDeclarationNodeType))return List_singleton(new CallableView(e,e,e,CallableRole.NamedDefinition,(t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0),namedParametersOf(e)));if(equals(r,lambdaLiteralNodeType)){const t=Kotlin_anonymousBinding(e);return List_singleton(new CallableView(e,e,e,t[0],t[1],lambdaParametersOf(e)))}return List_empty()}function Kotlin_bodyItems(e){e:for(;;){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,blockNodeType),t);if(null==n){const n=List_tryFind(e=>equals(e.type,functionBodyNodeType),t);if(null==n)return t;e=Option_value(n);continue e}return nodeNamedChildren(Option_value(n))}}function Kotlin_errorHandlingRegion(e){let t;if(equals(e.type,Kotlin_tryExpressionNodeType)){const n=nodeNamedChildren(e),r=List_tryFind(e=>equals(e.type,blockNodeType),n);return null!=r?(t=Option_value(r),new ErrorHandlingRegion(e,nodeNamedChildren(t),nodeNamedChildren(t),List_collect(Kotlin_bodyItems,List_filter(e=>!!equals(e.type,catchBlockNodeType)||equals(e.type,finallyBlockNodeType),n)),List_map(e=>new RecoveryBody(e,Kotlin_bodyItems(e)),List_filter(e=>!!equals(e.type,catchBlockNodeType)||equals(e.type,finallyBlockNodeType),n)))):void 0}}const expectedInfixIdentifierCount=3;function isUserType(e){return equals(e.type,"user_type")}function isParameterType(e){return!!equals(e.type,"user_type")||equals(e.type,"nullable_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(List_length(t)!==expectedInfixIdentifierCount)return!1;{const e=List_toArray(t);return"const"===Array_item(0,e).text&&"val"===Array_item(1,e).text}}}}function delegationSpecifierName(e){let t,n;const r=orElse(List_tryFind(isUserType,nodeChildren(e)),(t=List_tryFind(e=>equals(e.type,"constructor_invocation"),nodeChildren(e)),null!=t?List_tryFind(isUserType,nodeChildren(Option_value(t))):void 0));if(null!=r){const e=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(Option_value(r)));return null!=e?(n=Option_value(e),n.text):void 0}}const kotlinLanguageAdapter=new LanguageAdapter("kotlin","grammars/tree-sitter-kotlin.wasm",new NodeTypes("block",functionParametersNodeType,"if_expression",void 0,"for_statement","while_statement",void 0,lambdaLiteralNodeType,"import",void 0,List_empty(),void 0,"property_declaration","source_file",void 0,"line_comment","number_literal","float_literal","string_literal"),e=>equals(e.type,Kotlin_functionDeclarationNodeType),e=>List_singleton(new FunctionHead(e,e)),Kotlin_callableViews,namedParameterChildTypes,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)}},e=>classify(ofArray(["if_expression","for_statement","while_statement","when_expression","catch_block","do_while_statement"]),e),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=>!1,ofArray(["identifier","navigation_expression"]),e=>{if(equals(e.type,"parameter")){const t=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(e)),n=List_tryFind(isParameterType,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));let n,r;if(null!=t&&t+1<List_length(nodeChildren(e))?(n=0,r=t):n=1,0===n)return item(r+1,nodeChildren(e)).text},new GenericBrackets("<",">"),Set_ofList(ofArray(["Int","Long","Short","Byte","Double","Float","Boolean","String","Char"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),Kotlin_errorHandlingRegion,Kotlin_bodyItems,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,a;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),a=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,a)):List_empty()}}return List_empty()},e=>{},e=>List_empty(),e=>!(!equals(e.type,"string_literal")&&!equals(e.type,"number_literal"))||equals(e.type,"float_literal"),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,a;return null!=e&&null!=n?(r=0,o=Option_value(e),a=Option_value(n)):r=1,0===r&&!!equals(o.type,"=")&&equals(a.type,"parameter")}return!1}return!1},e=>!1,e=>e.text,e=>null!=booleanLiteralPolarity(e),e=>{let t,n,r;const o=nodeParent(e);let i,a;if(null!=o?(r=Option_value(o),equals(r.type,"value_argument")?(i=0,a=Option_value(o)):i=1):i=1,0===i){const r=nodeParent(a);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(a));return null!=t&&Option_value(t).id===e.id}return!1}return!1}return!1},e=>{const t=e.type;return"property_declaration"===t?isConstPropertyDeclaration(e):"assignment"===t&&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 List_singleton(new ImportInfo(ImportKind.Wildcard,t,List_empty()));{const e=0|t.lastIndexOf(".");if(-1===e)return List_singleton(new ImportInfo(ImportKind.Members,t,List_empty()));{const n=0|e,r=substring(t,n+1);return List_singleton(new ImportInfo(ImportKind.Members,substring(t,0,n),List_singleton(new ImportBinding(r,r))))}}}return List_singleton(new ImportInfo(ImportKind.Members,e.text,List_empty()))},e=>equals(e.type,"class_declaration"),e=>!1,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))))},(()=>{const e=new GuardSyntax(ofArray(["function_body","block"]),"if_expression",List_singleton("throw_expression"),"return_expression",List_empty(),List_singleton("Unit"),e=>!1,booleanLiteralPolarity,(e,t)=>hasNarrowingContract(e));return t=>extract(e,t)})()),CPlusPlus_tryStatementNodeType="try_statement",compoundStatementNodeType="compound_statement",CPlusPlus_catchClauseNodeType="catch_clause",CPlusPlus_functionDefinitionNodeType="function_definition",lambdaExpressionNodeType="lambda_expression",parameterListNodeType="parameter_list",CPlusPlus_parameterChildTypes=ofArray(["parameter_declaration","optional_parameter_declaration","variadic_parameter_declaration"]);function CPlusPlus_bodyItems(e){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,compoundStatementNodeType),t);return null==n?t:nodeNamedChildren(Option_value(n))}function CPlusPlus_errorHandlingRegion(e){let t;if(equals(e.type,CPlusPlus_tryStatementNodeType)){const n=nodeNamedChildren(e),r=List_tryFind(e=>equals(e.type,compoundStatementNodeType),n);return null!=r?(t=Option_value(r),new ErrorHandlingRegion(e,nodeNamedChildren(t),nodeNamedChildren(t),List_collect(CPlusPlus_bodyItems,List_filter(e=>equals(e.type,CPlusPlus_catchClauseNodeType),n)),List_map(e=>new RecoveryBody(e,CPlusPlus_bodyItems(e)),List_filter(e=>equals(e.type,CPlusPlus_catchClauseNodeType),n)))):void 0}}const typeNodeTypes=Set_ofList(ofArray(["primitive_type","sized_type_specifier","type_identifier","qualified_identifier","template_type","placeholder_type_specifier","decltype","dependent_type"]),{Compare:(e,t)=>0|compare(e,t)}),declaratorNodeTypes=Set_ofList(ofArray(["identifier","field_identifier","pointer_declarator","reference_declarator","array_declarator","function_declarator","parenthesized_declarator"]),{Compare:(e,t)=>0|compare(e,t)});function tryFindDescendant(e,t){return e(t)?some(t):List_tryPick(t=>tryFindDescendant(e,t),nodeChildren(t))}function isTypeNode(e){return Set_contains(e.type,typeNodeTypes)}function isDeclaratorNode(e){return Set_contains(e.type,declaratorNodeTypes)}function CPlusPlus_parametersOf(e){let t;return defaultArg((t=tryFindDescendant(e=>equals(e.type,parameterListNodeType),e),null!=t?List_filter(e=>List_contains(e.type,CPlusPlus_parameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(t))):void 0),List_empty())}function declaratorName(e){let t;const n=tryFindDescendant(e=>!!equals(e.type,"identifier")||equals(e.type,"field_identifier"),e);return null!=n?(t=Option_value(n),t.text):void 0}function CPlusPlus_anonymousBinding(e){let t,n,r,o,i,a,s,l;const _=nodeParent(e);let u,c,d;switch(null!=_?(s=Option_value(_),equals(s.type,"field_declaration")&&Seq_exists(e=>equals(e.type,"field_declaration_list"),toArray(nodeParent(s)))?(u=0,c=Option_value(_)):(l=Option_value(_),equals(l.type,"init_declarator")&&Seq_exists(t=>t.id===e.id,toArray(nodeField("value",l)))?(u=1,d=Option_value(_)):u=2)):u=2,u){case 0:return[new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding]),(t=nodeField("declarator",c),null!=t?declaratorName(Option_value(t)):void 0)];case 1:{let e;const t=nodeField("declarator",d);return e=null!=t?declaratorName(Option_value(t)):void 0,[(n=nodeParent(d),null!=n?(r=Option_value(n),equals(r.type,"declaration")&&Seq_exists(e=>equals(e.type,"translation_unit"),toArray(nodeParent(r)))?(o=Option_value(n),new CallableRole(1,[AnonymousBindingScope.ModuleBinding])):(i=Option_value(n),equals(i.type,"field_declaration")&&Seq_exists(e=>equals(e.type,"field_declaration_list"),toArray(nodeParent(i)))?(a=Option_value(n),new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding])):CallableRole.InlineAnonymous)):CallableRole.InlineAnonymous),e]}default:return[CallableRole.InlineAnonymous,void 0]}}function CPlusPlus_callableViews(e){let t;const n=e.type;if(equals(n,CPlusPlus_functionDefinitionNodeType))return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,CallableRole.NamedDefinition,(t=nodeField("declarator",e),null!=t?declaratorName(Option_value(t)):void 0),CPlusPlus_parametersOf(e)));if(equals(n,lambdaExpressionNodeType)){const t=CPlusPlus_anonymousBinding(e);return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,t[0],t[1],CPlusPlus_parametersOf(e)))}return List_empty()}function extractTypedParameter(e){const t=List_tryFind(isTypeNode,nodeChildren(e)),n=List_tryFind(isDeclaratorNode,nodeChildren(e));let r,o,i;if(null!=t&&null!=n?(r=0,o=Option_value(n),i=Option_value(t)):r=1,0===r){const e=tryFindDescendant(e=>!!equals(e.type,"identifier")||equals(e.type,"field_identifier"),o);if(null==e)return;{const t=Option_value(e),n=replace(String_replace(o.text,t.text,""),"\\s+","");return new TypedParameter(t.text,i.text+n)}}}function extractReturnType(e){let t,n,r;const o=List_tryFind(isDeclaratorNode,nodeChildren(e));if(r=null!=o?tryFindDescendant(e=>equals(e.type,"trailing_return_type"),Option_value(o)):void 0,null==r){const n=List_tryFind(isTypeNode,nodeChildren(e));return null!=n?(t=Option_value(n),t.text):void 0}{const e=tryFindDescendant(isTypeNode,Option_value(r));return null!=e?(n=Option_value(e),n.text):void 0}}function switchBranchCount(e){if(equals(e.type,"switch_statement")){const t=List_filter(e=>equals(e.type,"case_statement"),List_collect(nodeNamedChildren,nodeNamedChildren(e))),n=List_exists(e=>List_exists(e=>equals(e.type,"default"),nodeChildren(e)),t);return List_length(t)+(n?0:1)}}function equalityComparisons(e){if(equals(e.type,"binary_expression")){const t=List_tryFind(e=>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,a;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),a=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,a)):List_empty()}}return List_empty()}function isDefaultParameterValue(e){e:for(;;){const t=e;let n,r;const o=nodeParent(t);let i,a,s;switch(null!=o?(n=Option_value(o),equals(n.type,"optional_parameter_declaration")?(i=0,a=Option_value(o)):(r=Option_value(o),equals(r.type,"function_definition")?i=2:(i=1,s=Option_value(o)))):i=2,i){case 0:return Seq_exists(e=>t.startIndex>e.startIndex,toArray(List_tryFind(e=>equals(e.type,"="),nodeChildren(a))));case 1:e=s;continue e;default:return!1}break}}function isExplicitConstant(e){return!!equals(e.type,"enumerator")||!(!equals(e.type,"declaration")&&!equals(e.type,"field_declaration"))&&List_exists(e=>!!equals(e.type,"type_qualifier")&&("const"===e.text||"constexpr"===e.text),nodeChildren(e))}function baseClassNames(e){const t=List_tryFind(e=>equals(e.type,"base_class_clause"),nodeChildren(e));return null==t?List_empty():List_map(e=>e.text,List_filter(isTypeNode,nodeNamedChildren(Option_value(t))))}function isMatchCaseLiteral(e){if(equals(e.type,"char_literal"))return!0;if(equals(e.type,"number_literal")){const t=e.text.toLowerCase();return startsWith(t,"0x",4)?!(t.indexOf(".")>=0||t.indexOf("p")>=0):!(t.indexOf(".")>=0||t.indexOf("e")>=0)}return!1}function isClassDefinition(e){return!(!equals(e.type,"class_specifier")&&!equals(e.type,"struct_specifier"))&&List_exists(e=>equals(e.type,"field_declaration_list"),nodeChildren(e))}const cPlusPlusLanguageAdapter=new LanguageAdapter("cpp","grammars/tree-sitter-cpp.wasm",new NodeTypes("compound_statement",parameterListNodeType,"if_statement","else_clause","for_statement","while_statement","conditional_expression",lambdaExpressionNodeType,"preproc_include",void 0,List_empty(),"expression_statement","declaration","translation_unit",void 0,"comment","number_literal",void 0,"string_literal"),e=>equals(e.type,CPlusPlus_functionDefinitionNodeType),e=>List_singleton(new FunctionHead(e,e)),CPlusPlus_callableViews,CPlusPlus_parameterChildTypes,ofArray(["if_statement","for_statement","for_range_loop","while_statement","do_statement","catch_clause","conditional_expression","switch_statement"]),switchBranchCount,e=>classify(ofArray(["if_statement","for_statement","for_range_loop","while_statement","do_statement","catch_clause","switch_statement"]),e),ofArray(["if_statement","for_statement","for_range_loop","while_statement","do_statement","try_statement","switch_statement"]),e=>equals(e.type,"binary_expression")?List_tryPick(e=>{const t=e.type;let n;switch(n="&&"===t||"and"===t?0:"||"===t||"or"===t?1:2,n){case 0:return BooleanOperator.And;case 1:return BooleanOperator.Or;default:return}},nodeChildren(e)):void 0,e=>!1,ofArray(["identifier","field_expression","qualified_identifier"]),extractTypedParameter,extractReturnType,new GenericBrackets("<",">"),Set_ofList(ofArray(["bool","char","char8_t","char16_t","char32_t","double","float","int","long","long double","long int","long long","long long int","short","short int","signed","signed char","signed int","signed long","signed long int","signed long long","signed long long int","signed short","signed short int","string","std::string","unsigned","unsigned char","unsigned int","unsigned long","unsigned long int","unsigned long long","unsigned long long int","unsigned short","unsigned short int","wchar_t"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),CPlusPlus_errorHandlingRegion,CPlusPlus_bodyItems,List_empty(),"a small value type (for example, a struct or enum class)",equalityComparisons,e=>{},e=>List_empty(),isMatchCaseLiteral,e=>List_empty(),List_singleton("subscript_expression"),e=>!startsWith(e.text,'"',4),isDefaultParameterValue,e=>!1,e=>e.text,e=>!!equals(e.type,"true")||equals(e.type,"false"),e=>{let t;const n=nodeParent(e);let r,o;return null!=n?(t=Option_value(n),equals(t.type,"argument_list")?(r=0,o=Option_value(n)):r=1):r=1,0===r&&Seq_exists(e=>equals(e.type,"call_expression"),toArray(nodeParent(o)))},isExplicitConstant,e=>{let t,n;return List_singleton(new ImportInfo(ImportKind.Header,(t=List_tryFind(e=>!(!equals(e.type,"system_lib_string")&&!equals(e.type,"string_literal"))||equals(e.type,"identifier"),nodeChildren(e)),null==t?e.text:(n=Option_value(t),trim(n.text,"<",">",'"'))),List_empty()))},isClassDefinition,e=>{const t=e=>!!List_exists(e=>"static"===e.text,nodeChildren(e))||!equals(e.type,"field_declaration_list")&&Seq_exists(t,toArray(nodeParent(e)));return t(e)},e=>{let t;const n=List_tryFind(e=>!!equals(e.type,"type_identifier")||equals(e.type,"qualified_identifier"),nodeChildren(e));return null!=n?(t=Option_value(n),t.text):void 0},baseClassNames,(()=>{const e=new GuardSyntax(List_singleton("compound_statement"),"if_statement",List_singleton("throw_statement"),"return_statement",List_empty(),List_empty(),e=>!1,e=>equals(e.type,"true")?BooleanLiteralPolarity.LiteralTrue:equals(e.type,"false")?BooleanLiteralPolarity.LiteralFalse:void 0,(e,t)=>!1);return t=>extract(e,t)})()),CSharp_blockNodeType="block",CSharp_tryStatementNodeType="try_statement",CSharp_catchClauseNodeType="catch_clause",CSharp_finallyClauseNodeType="finally_clause",CSharp_lambdaExpressionNodeType="lambda_expression",anonymousMethodNodeType="anonymous_method_expression",CSharp_parameterListNodeType="parameter_list",namedFunctionNodeTypes=Set_ofList(ofArray(["method_declaration","constructor_declaration","local_function_statement"]),{Compare:(e,t)=>0|compare(e,t)});function CSharp_parametersOf(e){let t;const n=nodeField("parameters",e);return null==n?List_empty():(t=Option_value(n),equals(t.type,"implicit_parameter")?List_singleton(Option_value(n)):List_filter(e=>equals(e.type,"parameter"),nodeChildren(Option_value(n))))}function CSharp_anonymousBinding(e){let t,n,r,o,i,a;const s=nodeParent(e);let l,_;if(null!=s?(a=Option_value(s),equals(a.type,"variable_declarator")?(l=0,_=Option_value(s)):l=1):l=1,0===l){let e;const a=nodeField("name",_);return e=null!=a?(t=Option_value(a),t.text):void 0,Seq_exists(e=>equals(e.type,"declaration_list"),toArray((o=nodeParent(_),r=null!=o?nodeParent(Option_value(o)):void 0,n=null!=r?(i=Option_value(r),equals(i.type,"field_declaration")?r:void 0):void 0,null!=n?nodeParent(Option_value(n)):void 0)))?[new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding]),e]:[CallableRole.InlineAnonymous,e]}return[CallableRole.InlineAnonymous,void 0]}function callableBody(e){let t;return defaultArg((t=nodeField("body",e),null!=t?t:List_tryLast(nodeNamedChildren(e))),e)}function CSharp_callableViews(e){let t,n;if(Set_contains(e.type,namedFunctionNodeTypes))return List_singleton(new CallableView(e,callableBody(e),e,CallableRole.NamedDefinition,(t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0),CSharp_parametersOf(e)));if(equals(e.type,CSharp_lambdaExpressionNodeType)||equals(e.type,anonymousMethodNodeType)){const t=CSharp_anonymousBinding(e);return List_singleton(new CallableView(e,callableBody(e),e,t[0],t[1],CSharp_parametersOf(e)))}return List_empty()}function CSharp_bodyItems(e){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,CSharp_blockNodeType),t);return null==n?t:nodeNamedChildren(Option_value(n))}function CSharp_errorHandlingRegion(e){let t;if(equals(e.type,CSharp_tryStatementNodeType)){const n=nodeNamedChildren(e),r=List_tryFind(e=>equals(e.type,CSharp_blockNodeType),n);return null!=r?(t=Option_value(r),new ErrorHandlingRegion(e,nodeNamedChildren(t),nodeNamedChildren(t),List_collect(CSharp_bodyItems,List_filter(e=>!!equals(e.type,CSharp_catchClauseNodeType)||equals(e.type,CSharp_finallyClauseNodeType),n)),List_map(e=>new RecoveryBody(e,CSharp_bodyItems(e)),List_filter(e=>!!equals(e.type,CSharp_catchClauseNodeType)||equals(e.type,CSharp_finallyClauseNodeType),n)))):void 0}}function CSharp_switchBranchCount(e){if(equals(e.type,"switch_statement")){const t=List_filter(e=>equals(e.type,"switch_section"),List_collect(nodeNamedChildren,nodeNamedChildren(e))),n=List_exists(e=>startsWith(e.text,"default:",4),t);return List_length(t)+(n?0:1)}}function CSharp_equalityComparisons(e){if(equals(e.type,"binary_expression")){const t=List_tryFind(e=>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,a;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),a=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,a)):List_empty()}}return List_empty()}function CSharp_extractTypedParameter(e){if(equals(e.type,"parameter")){const t=nodeNamedChildren(e);let n,r,o;return List_isEmpty(t)||List_isEmpty(List_tail(t))?n=1:(n=0,r=List_head(t),o=List_head(List_tail(t))),0===n?new TypedParameter(o.text,r.text):void 0}}function CSharp_extractReturnType(e){let t;if(equals(e.type,"method_declaration")){const n=List_tryFind(e=>!equals(e.type,"modifier")&&!equals(e.type,"attribute_list"),nodeNamedChildren(e));return null!=n?(t=Option_value(n),t.text):void 0}}function isNotNullWhenAttribute(e){let t,n;return!!equals(e.type,"attribute")&&Seq_exists(e=>!("NotNullWhen"!==e&&"NotNullWhenAttribute"!==e&&!endsWith(e,".NotNullWhen",4))||endsWith(e,".NotNullWhenAttribute",4),toArray((t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0)))}function conditionReferencesNotNullWhenParameter(e,t){const n=(e,t)=>{if(equals(t.type,"identifier")&&t.text===e)return!0;{const r=nodeChildren(t);return List_exists(curry2(n)(e),r)}},r=nodeField("name",t);if(null==r)return!1;{const o=Option_value(r);return!!List_exists(isNotNullWhenAttribute,List_collect(nodeNamedChildren,List_filter(e=>equals(e.type,"attribute_list"),nodeNamedChildren(t))))&&n(o.text,e)}}function CSharp_baseClassNames(e){let t;return List_map(e=>e.text,defaultArg((t=List_tryFind(e=>equals(e.type,"base_list"),nodeChildren(e)),null!=t?nodeNamedChildren(Option_value(t)):void 0),List_empty()))}const cSharpLanguageAdapter=new LanguageAdapter("csharp","grammars/tree-sitter-c-sharp.wasm",new NodeTypes(CSharp_blockNodeType,CSharp_parameterListNodeType,"if_statement",void 0,"for_statement","while_statement","conditional_expression",CSharp_lambdaExpressionNodeType,"using_directive",void 0,List_empty(),"expression_statement","variable_declaration","compilation_unit",void 0,"comment","integer_literal","real_literal","string_literal"),e=>Set_contains(e.type,namedFunctionNodeTypes),e=>List_singleton(new FunctionHead(e,e)),CSharp_callableViews,List_singleton("parameter"),ofArray(["if_statement","for_statement","foreach_statement","while_statement","do_statement","catch_clause","conditional_expression","switch_statement"]),CSharp_switchBranchCount,e=>classify(ofArray(["if_statement","for_statement","foreach_statement","while_statement","do_statement","catch_clause","switch_statement"]),e),ofArray(["if_statement","for_statement","foreach_statement","while_statement","do_statement","try_statement","switch_statement"]),e=>equals(e.type,"binary_expression")?List_tryPick(e=>{const t=e.type;return"&&"===t?BooleanOperator.And:"||"===t?BooleanOperator.Or:void 0},nodeChildren(e)):void 0,e=>!1,ofArray(["identifier","member_access_expression"]),CSharp_extractTypedParameter,CSharp_extractReturnType,new GenericBrackets("<",">"),Set_ofList(ofArray(["bool","byte","char","decimal","double","float","int","long","sbyte","short","string","uint","ulong","ushort"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),CSharp_errorHandlingRegion,CSharp_bodyItems,List_empty(),"a readonly record struct or enum",CSharp_equalityComparisons,e=>{},e=>List_empty(),e=>!!equals(e.type,"integer_literal")||equals(e.type,"character_literal"),e=>List_empty(),List_singleton("element_access_expression"),e=>!1,e=>{let t;const n=nodeParent(e);let r,o;if(null!=n?(t=Option_value(n),equals(t.type,"parameter")?(r=0,o=Option_value(n)):r=1):r=1,0===r){const t=nodeChildren(o);return!!List_exists(e=>equals(e.type,"="),t)&&Seq_exists(t=>t.id===e.id,toArray(List_tryLast(t)))}return!1},e=>!1,e=>e.text,e=>equals(e.type,"boolean_literal"),e=>{let t,n;const r=nodeParent(e);let o,i;if(null!=r?(n=Option_value(r),equals(n.type,"argument")?(o=0,i=Option_value(r)):o=1):o=1,0===o){const e=nodeParent(i);if(null==e)return!1;if(t=Option_value(e),equals(t.type,"argument_list")){const t=nodeParent(Option_value(e));return null!=t&&equals(Option_value(t).type,"invocation_expression")}return!1}return!1},e=>!!equals(e.type,"field_declaration")&&List_exists(e=>"const"===e.text,nodeChildren(e)),e=>{let t,n;return List_singleton(new ImportInfo(ImportKind.Module,defaultArg((t=List_tryLast(nodeNamedChildren(e)),null!=t?(n=Option_value(t),n.text):void 0),e.text),List_empty()))},e=>!!(equals(e.type,"class_declaration")||equals(e.type,"struct_declaration")||equals(e.type,"record_declaration"))||equals(e.type,"interface_declaration"),e=>{const t=e=>!!List_exists(e=>"static"===e.text,nodeChildren(e))||!equals(e.type,"declaration_list")&&Seq_exists(t,toArray(nodeParent(e)));return t(e)},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},CSharp_baseClassNames,(()=>{const e=new GuardSyntax(List_singleton("block"),"if_statement",List_singleton("throw_statement"),"return_statement",List_empty(),List_empty(),e=>!1,e=>{if(equals(e.type,"boolean_literal")){const t=e.text;return"true"===t?BooleanLiteralPolarity.LiteralTrue:"false"===t?BooleanLiteralPolarity.LiteralFalse:void 0}},(e,t)=>!!equals(e.type,"constructor_declaration")||Seq_exists(t=>List_exists(e=>conditionReferencesNotNullWhenParameter(t,e),CSharp_parametersOf(e)),toArray(t)));return t=>extract(e,t)})()),trueAtom="true";function expressionChildren(e){return List_filter(e=>!equals(e.type,"comment"),nodeNamedChildren(e))}function singleClauseExpression(e){const t=nodeField("body",e);if(null!=t){const e=expressionChildren(Option_value(t));let n,r;return List_isEmpty(e)?n=1:List_isEmpty(List_tail(e))?(n=0,r=List_head(e)):n=1,0===n?some(r):void 0}}function isFailureCall(e){let t;return Seq_exists(e=>{let t,n;const r=nodeField("expr",e);let o;n=null!=r?(t=Option_value(r),t.text):void 0;const i=nodeField("args",e);let a;if(o=null!=i?List_length(expressionChildren(Option_value(i))):void 0,null!=n)switch(n){case"error":if(null!=o)switch(o){case 1:case 2:a=0;break;default:a=1}else a=1;break;case"throw":case"exit":a=null!=o&&1===o?0:1;break;default:a=1}else a=1;return 0===a},toArray((t=e.type,"call"===t?some(e):"remote"===t&&Seq_exists(e=>"erlang:"===e.text,toArray(nodeField("module",e)))?nodeField("fun",e):void 0)))}function validationSuccess(e){const t=e.type;let n;switch(n="var"===t?0:"atom"===t&&List_contains(e.text,ofArray([trueAtom,"false"]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})?1:2,n){case 0:return new ValidationSuccess(0,[e]);case 1:return new ValidationSuccess(2,[e]);default:return}}function caseValidation(e){let t;const n=List_filter(e=>equals(e.type,"cr_clause"),nodeNamedChildren(e)),r=nodeField("expr",e);let o,i,a,s;if(null!=r?List_isEmpty(n)||List_isEmpty(List_tail(n))?o=1:List_isEmpty(List_tail(List_tail(n)))?(t=List_head(n),Option_value(r),Seq_exists(e=>List_contains(e.type,ofArray(["atom","integer","float","string","list","tuple"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),toArray(nodeField("pat",t)))&&null==nodeField("guard",t)&&null==nodeField("guard",List_head(List_tail(n)))?(o=0,i=Option_value(r),a=List_head(n),s=List_head(List_tail(n))):o=1):o=1:o=1,0===o){const e=singleClauseExpression(a),t=singleClauseExpression(s);let n,r,o;if(null!=e&&null!=t?(Option_value(t),isFailureCall(Option_value(e))?(n=0,r=Option_value(e),o=Option_value(t)):n=1):n=1,0===n){const e=validationSuccess(o);return null!=e?[i,e]:void 0}return}}function ifValidation(e){let t,n,r;const o=List_filter(e=>equals(e.type,"if_clause"),nodeNamedChildren(e));let i,a,s;if(List_isEmpty(o)||List_isEmpty(List_tail(o))?i=1:List_isEmpty(List_tail(List_tail(o)))?(i=0,a=List_head(o),s=List_head(List_tail(o))):i=1,0===i){const e=nodeField("guard",a),o=nodeField("guard",s),i=singleClauseExpression(a),l=singleClauseExpression(s);let _,u,c,d,p;if(null!=e&&null!=o&&null!=i&&null!=l?(Option_value(l),t=Option_value(o),n=Option_value(i),r=Option_value(e),r.text!==trueAtom&&t.text===trueAtom&&isFailureCall(n)?(_=0,u=Option_value(e),c=Option_value(i),d=Option_value(o),p=Option_value(l)):_=1):_=1,0===_){const e=validationSuccess(p);return null!=e?[u,e]:void 0}return}}function ErlangValidation_extract(e){let t,n;const r=nodeField("body",e.Body);let o,i;if(null!=r?(Option_value(r),null==nodeField("guard",e.ParametersRoot)?(o=0,i=Option_value(r)):o=1):o=1,0===o){let e;const r=expressionChildren(i);let o,a;switch(List_isEmpty(r)?o=1:List_isEmpty(List_tail(r))?(o=0,a=List_head(r)):o=1,o){case 0:{const t=a.type;if("case_expr"===t){const t=caseValidation(a);e=null!=t?[a,t]:void 0}else if("if_expr"===t){const t=ifValidation(a);e=null!=t?[a,t]:void 0}else e=void 0;break}default:e=void 0}return null!=e?(t=e,n=t[1],new GuardedValidation(t[0],n[0],n[1],IdentityReturnPolicy.AcceptUntypedParameter)):void 0}}const functionClause="function_clause",funDeclaration="fun_decl",anonymousFun="anonymous_fun",clauseBody="clause_body",expressionArguments="expr_args";function declarationClause(e){let t;const n=nodeField("clause",e);return null!=n?(t=Option_value(n),equals(t.type,functionClause)?n:void 0):void 0}function Erlang_parametersOf(e){let t;return defaultArg((t=nodeField("args",e),null!=t?nodeNamedChildren(Option_value(t)):void 0),List_empty())}function Erlang_bodyItems(e){let t,n;return equals(e.type,clauseBody)?nodeNamedChildren(e):defaultArg((t=equals(e.type,funDeclaration)?(n=declarationClause(e),null!=n?nodeField("body",Option_value(n)):void 0):nodeField("body",e),null!=t?nodeNamedChildren(Option_value(t)):void 0),nodeNamedChildren(e))}function namedCallable(e,t){let n,r;return new CallableView(e,defaultArg(nodeField("body",t),t),e,CallableRole.NamedDefinition,(n=nodeField("name",t),null!=n?(r=Option_value(n),r.text):void 0),Erlang_parametersOf(t))}function anonymousCallable(e){let t,n;return new CallableView(e,defaultArg(nodeField("body",e),e),e,CallableRole.InlineAnonymous,(t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0),Erlang_parametersOf(e))}function Erlang_callableViews(e){let t;const n=e.type;return equals(n,funDeclaration)?ofArray(toArray((t=declarationClause(e),null!=t?namedCallable(e,Option_value(t)):void 0))):equals(n,anonymousFun)?List_map(anonymousCallable,List_filter(e=>equals(e.type,"fun_clause"),nodeNamedChildren(e))):List_empty()}function branchCount(e){const t=List_filter(e=>List_contains(e.type,ofArray(["cr_clause","if_clause"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeNamedChildren(e)),n=e.type;if("case_expr"===n){const e=List_exists(e=>null==nodeField("guard",e)&&Seq_exists(e=>equals(e.type,"var"),toArray(nodeField("pat",e))),t);return List_length(t)+(e?0:1)}if("if_expr"===n){const e=List_exists(e=>Seq_exists(e=>List_exists(e=>"true"===e.text,nodeNamedChildren(e)),toArray(nodeField("guard",e))),t);return List_length(t)+(e?0:1)}if("receive_expr"===n){const n=null!=nodeField("after",e);return List_length(t)+(n?1:0)}}function cognitiveStructure(e){const t=e.type;let n,r;switch("case_expr"===t||"if_expr"===t||"receive_expr"===t?n=0:"catch_clause"===t?n=1:"paren_expr"===t?equals(t,anonymousFun)?(n=2,r=t):n=3:equals(t,anonymousFun)?(n=2,r=t):n=4,n){case 0:return new CognitiveStructure(0,[CognitiveIncrement.Structural,List_filter(e=>List_contains(e.type,ofArray(["cr_clause","if_clause","receive_after"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeNamedChildren(e))]);case 1:{const t=nodeField("body",e);return null!=t?new CognitiveStructure(0,[CognitiveIncrement.Structural,List_singleton(Option_value(t))]):void 0}case 2:return CognitiveStructure.Closure;case 3:{const t=nodeField("expr",e);return null!=t?new CognitiveStructure(2,[Option_value(t)]):void 0}default:return}}function booleanOperator(e){return equals(e.type,"binary_op_expr")?List_tryPick(e=>{switch(e.text){case"andalso":return BooleanOperator.And;case"orelse":return BooleanOperator.Or;default:return}},nodeChildren(e)):void 0}function Erlang_equalityComparisons(e){if(equals(e.type,"binary_op_expr")){const t=List_exists(e=>List_contains(e.text,ofArray(["==","=:="]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),nodeChildren(e)),n=nodeField("lhs",e),r=nodeField("rhs",e);let o,i,a;return null!=n&&null!=r?(Option_value(r),Option_value(n),t?(o=0,i=Option_value(n),a=Option_value(r)):o=1):o=1,0===o?List_singleton(new EqualityComparison(i,a)):List_empty()}return List_empty()}function Erlang_importInfo(e){let t,n;const r=e.type;let o;switch(o="import_attribute"===r?0:"pp_include"===r||"pp_include_lib"===r?1:2,o){case 0:return ofArray(toArray((t=nodeField("module",e),null!=t?(n=Option_value(t),new ImportInfo(ImportKind.Module,n.text,List_choose(e=>{let t;const n=nodeField("fun",e);return null!=n?(t=Option_value(n),new ImportBinding(t.text,t.text)):void 0},List_filter(e=>equals(e.type,"fa"),nodeNamedChildren(e))))):void 0)));case 1:return List_map(e=>new ImportInfo(ImportKind.Header,trim(e.text,'"'),List_empty()),List_filter(e=>equals(e.type,"string"),nodeNamedChildren(e)));default:return List_empty()}}function Erlang_errorHandlingRegion(e){if(equals(e.type,"try_expr")&&!List_exists(e=>equals(e.type,"cr_clause"),nodeNamedChildren(e))){const t=nodeNamedChildren(e),n=List_append(List_filter(e=>equals(e.type,"catch_clause"),t),List_filter(e=>equals(e.type,"try_after"),t));if(List_isEmpty(n))return;{const r=List_takeWhile(e=>!List_contains(e.type,ofArray(["cr_clause","catch_clause","try_after"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),t);return new ErrorHandlingRegion(e,r,r,List_collect(Erlang_bodyItems,n),List_map(e=>new RecoveryBody(e,Erlang_bodyItems(e)),n))}}}const erlangLanguageAdapter=new LanguageAdapter("erlang","grammars/tree-sitter-erlang.wasm",new NodeTypes(clauseBody,expressionArguments,void 0,void 0,void 0,void 0,void 0,anonymousFun,"import_attribute","pp_include",List_singleton("pp_include_lib"),void 0,"match_expr","source_file",void 0,"comment","integer","float","string"),e=>equals(e.type,funDeclaration),e=>{let t,n;return ofArray(toArray((t=declarationClause(e),null!=t?(n=Option_value(t),new FunctionHead(n,n)):void 0)))},Erlang_callableViews,ofArray(["var","atom","tuple","list","match_expr"]),ofArray(["case_expr","if_expr","receive_expr","catch_clause"]),branchCount,cognitiveStructure,ofArray(["case_expr","if_expr","receive_expr","try_expr"]),booleanOperator,e=>!1,List_singleton("var"),e=>{},e=>{},new GenericBrackets("<",">"),Set_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}),Erlang_errorHandlingRegion,Erlang_bodyItems,List_empty(),"a tagged tuple or record",Erlang_equalityComparisons,e=>{},e=>List_empty(),e=>!!equals(e.type,"atom")||equals(e.type,"integer"),e=>List_empty(),List_empty(),e=>!1,e=>!1,e=>Seq_exists(e=>equals(e.type,"arity"),toArray(nodeParent(e))),e=>e.text,e=>!!equals(e.type,"atom")&&List_contains(e.text,ofArray(["true","false"]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),e=>Seq_exists(e=>!!equals(e.type,expressionArguments)&&Seq_exists(e=>equals(e.type,"call"),toArray(nodeParent(e))),toArray(nodeParent(e))),e=>equals(e.type,"pp_define"),Erlang_importInfo,e=>!1,e=>!1,e=>{},e=>List_empty(),ErlangValidation_extract);function simpleImport(e,t){const n=t.text;return List_singleton(new ImportInfo(ImportKind.Module,""===e?n:e,List_singleton(new ImportBinding(n,n))))}function aliasImport(e,t){const n=nodeField("path",t),r=nodeField("alias",t);let o,i,a;return null!=n&&null!=r?(o=0,i=Option_value(r),a=Option_value(n)):o=1,0===o?List_singleton(new ImportInfo(ImportKind.Members,""===e?a.text:e,List_singleton(new ImportBinding(a.text,i.text)))):List_empty()}function memberImport(e,t){const n=nodeField("path",t),r=nodeField("name",t);let o,i,a;if(null!=n&&null!=r?(o=0,i=Option_value(r),a=Option_value(n)):o=1,0===o){const t=""===e?a.text:e+"::"+a.text,n=i.text;return List_singleton(new ImportInfo(ImportKind.Members,t,List_singleton(new ImportBinding(n,n))))}return List_empty()}function wildcardImport(e,t){let n,r;return List_singleton(new ImportInfo(ImportKind.Wildcard,defaultArg((n=List_tryHead(nodeNamedChildren(t)),null!=n?(r=Option_value(n),r.text):void 0),e),List_empty()))}function readUseTree(e,t){const n=t.type;return"scoped_use_list"===n?scopedImport(e,t):"use_list"===n?List_collect(t=>readUseTree(e,t),nodeNamedChildren(t)):"use_as_clause"===n?aliasImport(e,t):"scoped_identifier"===n?memberImport(e,t):"use_wildcard"===n?wildcardImport(e,t):simpleImport(e,t)}function scopedImport(e,t){let n,r,o;const i=defaultArg((n=nodeField("path",t),null!=n?(r=Option_value(n),r.text):void 0),e),a=List_collect(e=>readUseTree(i,e),defaultArg((o=nodeField("list",t),null!=o?nodeNamedChildren(Option_value(o)):void 0),List_empty()));return List_singleton(new ImportInfo(List_exists(e=>equals(e.Kind,ImportKind.Wildcard),a)?ImportKind.Wildcard:List_isEmpty(a)?ImportKind.Module:ImportKind.Members,i,List_collect(e=>e.Bindings,a)))}function RustImports_importInfo(e){let t;return defaultArg((t=nodeField("argument",e),null!=t?readUseTree("",Option_value(t)):void 0),List_empty())}const noneVariant="None";function expressions(e){return List_filter(e=>!List_contains(e.type,ofArray(["line_comment","block_comment"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeNamedChildren(e))}function RustValidation_unwrap(e){e:for(;;){const t=e;if(List_contains(t.type,ofArray(["expression_statement","return_expression"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})){const n=expressions(t);let r,o;if(List_isEmpty(n)?r=1:List_isEmpty(List_tail(n))?(r=0,o=List_head(n)):r=1,0===r){e=o;continue e}return t}return t}}function carrier(e){const t=nodeField("return_type",e.ParametersRoot);if(null!=t){const e=Option_value(t);if(equals(e.type,"generic_type")){const t=expressions(e);let n,r;if(List_isEmpty(t)?n=1:equals(List_head(t).type,"type_identifier")?(n=0,r=List_head(t)):n=1,0===n)switch(r.text){case"Result":return["Err","Ok"];case"Option":return[noneVariant,"Some"];default:return}return}return}}function variantPayload(e,t){let n;const r=RustValidation_unwrap(t);if(equals(r.type,"call_expression")){const t=nodeField("function",r),o=nodeField("arguments",r);let i,a,s;if(null!=t&&null!=o?(n=Option_value(t),Option_value(o),equals(n.type,"identifier")&&n.text===e?(i=0,a=Option_value(o),s=Option_value(t)):i=1):i=1,0===i){const e=expressions(a);let t,n;return List_isEmpty(e)?t=1:List_isEmpty(List_tail(e))?(t=0,n=List_head(e)):t=1,0===t?some(n):void 0}return}}function RustValidation_rejects(e,t){const n=RustValidation_unwrap(t);return e===noneVariant?!!equals(n.type,"identifier")&&n.text===noneVariant:null!=variantPayload(e,n)}function RustValidation_success(e,t){let n,r;const o=variantPayload(e,t);return r=null!=o?(n=Option_value(o),equals(n.type,"identifier")?o:void 0):void 0,null!=r?new ValidationSuccess(0,[Option_value(r)]):void 0}function earlyRejects(e,t){const n=expressions(t);let r,o;if(List_isEmpty(n)?r=1:List_isEmpty(List_tail(n))&&equals(List_head(n).type,"expression_statement")?(r=0,o=List_head(n)):r=1,0===r){const t=expressions(o);let n,r;return List_isEmpty(t)?n=1:List_isEmpty(List_tail(t))&&equals(List_head(t).type,"return_expression")?(n=0,r=List_head(t)):n=1,0===n&&RustValidation_rejects(e,r)}return!1}function guardedIf(e,t,n){let r,o,i;if(List_isEmpty(n)||List_isEmpty(List_tail(n))?r=1:List_isEmpty(List_tail(List_tail(n)))&&equals(RustValidation_unwrap(List_head(n)).type,"if_expression")?(r=0,o=List_head(n),i=List_head(List_tail(n))):r=1,0===r){const n=RustValidation_unwrap(o),r=nodeField("condition",n),a=nodeField("consequence",n),s=nodeField("alternative",n);let l,_,u;if(null!=r&&null!=a&&null==s?(Option_value(r),earlyRejects(e,Option_value(a))?(l=0,_=Option_value(a),u=Option_value(r)):l=1):l=1,0===l){const e=RustValidation_success(t,i);return null!=e?[n,u,e]:void 0}return}}function matched(e,t,n){let r,o,i,a,s,l;if(List_isEmpty(n)?s=1:List_isEmpty(List_tail(n))&&equals(RustValidation_unwrap(List_head(n)).type,"match_expression")?(s=0,l=List_head(n)):s=1,0===s){const n=RustValidation_unwrap(l),s=defaultArg((r=nodeField("body",n),null!=r?expressions(Option_value(r)):void 0),List_empty()),_=nodeField("value",n);let u,c,d,p;if(null!=_?List_isEmpty(s)||List_isEmpty(List_tail(s))?u=1:List_isEmpty(List_tail(List_tail(s)))?(u=0,c=Option_value(_),d=List_head(s),p=List_head(List_tail(s))):u=1:u=1,0===u){const r=nodeField("pattern",d),s=nodeField("pattern",p),l=nodeField("value",d),_=nodeField("value",p);let u,m,f,y,h;if(null!=r&&null!=s&&null!=l&&null!=_?(Option_value(_),o=Option_value(s),i=Option_value(l),a=expressions(Option_value(r)),!List_isEmpty(a)&&List_isEmpty(List_tail(a))&&List_contains(List_head(a).type,ofArray(["integer_literal","char_literal","string_literal","boolean_literal","slice_pattern","tuple_pattern"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&"_"===o.text&&RustValidation_rejects(e,i)?(u=0,m=Option_value(l),f=Option_value(s),y=Option_value(r),h=Option_value(_)):u=1):u=1,0===u){const e=RustValidation_success(t,h);return null!=e?[n,c,e]:void 0}return}return}}function RustValidation_extract(e){let t;const n=carrier(e);if(null!=n){const r=n[1],o=n[0],i=expressions(e.Body);let a;return a=guardedIf(o,r,i)??matched(o,r,i),null!=a?(t=a,new GuardedValidation(t[0],t[1],t[2],IdentityReturnPolicy.AcceptUntypedParameter)):void 0}}function kind(e){return e}function is(e,t){return equals(t.type,kind(e))}function Rust_parameters(e){let t,n,r;return defaultArg((t=nodeField("parameters",e),null!=t?(n=Option_value(t),r=nodeNamedChildren(n),is("closure_parameters",n)?r:List_filter(e=>is("parameter",e),r)):void 0),List_empty())}function hasSelfParameter(e){return Seq_exists(e=>List_exists(e=>is("self_parameter",e),nodeNamedChildren(e)),toArray(nodeField("parameters",e)))}function Rust_callableViews(e){let t,n,r,o,i,a;const s=e.type;if("function_item"===s)return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,CallableRole.NamedDefinition,(t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0),Rust_parameters(e)));if("closure_expression"===s){let t;const n=nodeParent(e);let s,l;switch(null!=n&&is("let_declaration",Option_value(n))?(s=0,l=Option_value(n)):s=1,s){case 0:{let e;const n=nodeField("pattern",l);e=null!=n?(r=Option_value(n),r.text):void 0,t=[(i=nodeParent(l),o=null!=i?(a=Option_value(i),a.type):void 0,null!=o&&"source_file"===o?new CallableRole(1,[AnonymousBindingScope.ModuleBinding]):CallableRole.InlineAnonymous),e];break}default:t=[CallableRole.InlineAnonymous,void 0]}return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,t[0],t[1],Rust_parameters(e)))}return List_empty()}function typedParameter(e){const t=nodeField("pattern",e),n=nodeField("type",e);let r,o,i;if(null!=t&&null!=n?(Option_value(n),is("identifier",Option_value(t))?(r=0,o=Option_value(n),i=Option_value(t)):r=1):r=1,0===r)return new TypedParameter(i.text,o.text)}function Rust_branchCount(e){let t;return is("match_expression",e)?List_length(List_filter(e=>is("match_arm",e),defaultArg((t=nodeField("body",e),null!=t?nodeNamedChildren(Option_value(t)):void 0),List_empty()))):void 0}function Rust_cognitiveStructure(e){return is("match_expression",e)?new CognitiveStructure(0,[CognitiveIncrement.Structural,ofArray(toArray(nodeField("body",e)))]):classify(ofArray([kind("if_expression"),kind("for_expression"),kind("while_expression"),kind("loop_expression")]),e)}function numericLiteralText(e){return String_replace(replace(e.text,"_?(?:u(?:8|16|32|64|128|size)|i(?:8|16|32|64|128|size)|f(?:32|64))$",""),"_","")}const rustLanguageAdapter=new LanguageAdapter("rust","grammars/tree-sitter-rust.wasm",new NodeTypes(kind("block"),kind("parameters"),kind("if_expression"),kind("else_clause"),kind("for_expression"),kind("while_expression"),void 0,kind("closure_expression"),kind("use_declaration"),void 0,List_empty(),kind("expression_statement"),kind("let_declaration"),kind("source_file"),void 0,kind("line_comment"),kind("integer_literal"),kind("float_literal"),kind("string_literal")),e=>is("function_item",e),e=>List_singleton(new FunctionHead(e,defaultArg(nodeField("body",e),e))),Rust_callableViews,List_singleton(kind("parameter")),ofArray([kind("if_expression"),kind("for_expression"),kind("while_expression"),kind("loop_expression"),kind("match_expression")]),Rust_branchCount,Rust_cognitiveStructure,ofArray([kind("if_expression"),kind("for_expression"),kind("while_expression"),kind("loop_expression"),kind("match_expression")]),e=>{let t;if(is("binary_expression",e)){let n;const r=nodeField("operator",e);let o;if(n=null!=r?(t=Option_value(r),t.text):void 0,null!=n)switch(n){case"&&":o=0;break;case"||":o=1;break;default:o=2}else o=2;switch(o){case 0:return BooleanOperator.And;case 1:return BooleanOperator.Or;default:return}}},e=>!1,ofArray([kind("identifier"),kind("field_expression"),kind("scoped_identifier")]),typedParameter,e=>{let t;const n=nodeField("return_type",e);return null!=n?(t=Option_value(n),t.text):void 0},new GenericBrackets("<",">"),Set_ofList(ofArray(["bool","char","i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","String"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),e=>{},e=>{let t;return defaultArg((t=nodeField("body",e),null!=t?nodeNamedChildren(Option_value(t)):void 0),nodeNamedChildren(e))},List_empty(),"a newtype struct or enum",e=>{if(is("binary_expression",e)&&Seq_exists(e=>"=="===e.text,toArray(nodeField("operator",e)))){const t=nodeField("left",e),n=nodeField("right",e);let r,o,i;return null!=t&&null!=n?(r=0,o=Option_value(t),i=Option_value(n)):r=1,0===r?List_singleton(new EqualityComparison(o,i)):List_empty()}return List_empty()},e=>{},e=>List_empty(),e=>List_contains(e.type,ofArray([kind("integer_literal"),kind("char_literal"),kind("boolean_literal"),kind("string_literal")]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),e=>List_empty(),List_singleton(kind("index_expression")),e=>!1,e=>!1,e=>Seq_exists(e=>is("array_type",e),toArray(nodeParent(e))),numericLiteralText,e=>is("boolean_literal",e),e=>Seq_exists(e=>!!is("arguments",e)&&Seq_exists(e=>is("call_expression",e),toArray(nodeParent(e))),toArray(nodeParent(e))),e=>List_contains(e.type,ofArray([kind("const_item"),kind("static_item"),kind("enum_variant")]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),RustImports_importInfo,e=>is("impl_item",e),e=>!hasSelfParameter(e),e=>{let t;const n=nodeField("type",e);return null!=n?(t=Option_value(n),t.text):void 0},e=>List_empty(),RustValidation_extract),languages=Map_ofList(ofArray([["python",pythonLanguageAdapter],["fsharp",fSharpLanguageAdapter],["typescript",typeScriptLanguageAdapter],["kotlin",kotlinLanguageAdapter],["cpp",cPlusPlusLanguageAdapter],["csharp",cSharpLanguageAdapter],["erlang",erlangLanguageAdapter],["rust",rustLanguageAdapter]]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),suffixToLanguageId=List_sortByDescending(e=>0|e[0].length,ofArray([[".py","python"],[".fs","fsharp"],[".fsx","fsharp"],[".fsi","fsharp"],[".ts","typescript"],[".cs","csharp"],[".csx","csharp"],[".erl","erlang"],[".hrl","erlang"],[".rs","rust"],[".kt","kotlin"],[".kts","kotlin"],[".cpp","cpp"],[".cppm","cpp"],[".cc","cpp"],[".ccm","cpp"],[".cxx","cpp"],[".cxxm","cpp"],[".c++","cpp"],[".c++m","cpp"],[".hpp","cpp"],[".hh","cpp"],[".hxx","cpp"],[".h++","cpp"],[".h","cpp"],[".ii","cpp"],[".ino","cpp"],[".inl","cpp"],[".ipp","cpp"],[".ixx","cpp"],[".mpp","cpp"],[".mxx","cpp"],[".tpp","cpp"],[".txx","cpp"],[".hpp.in","cpp"],[".h.in","cpp"]]),{Compare:(e,t)=>0|comparePrimitives(e,t)});function Registry_tryFind(e){return Map_tryFind(e,languages)}function resolveLanguageForFile(e){let t;const n=List_tryFind(t=>endsWith(e,t[0],5),suffixToLanguageId);return t=null!=n?n[1]:void 0,null!=t?Registry_tryFind(t):void 0}function analyzeParsedSource(e,t,n,r,o){const i=n;try{return withParsedTree(e,r,e=>{try{return new FSharpResult$2(0,[analyzeWith(o,new AnalysisInput(r,e,t,i))])}catch(e){return new FSharpResult$2(1,[new AnalysisError(5,[i,Types_toString(e)])])}})}catch(e){return new FSharpResult$2(1,[new AnalysisError(4,[i,Types_toString(e)])])}}const parserCache=new Map([]);function grammarPath(e){return(0,external_node_path_namespaceObject.join)((0,external_node_path_namespaceObject.join)(__dirname,".."),e)}function createParser(e){const t=task();return t.Run(t.Delay(()=>t.TryWith(t.Delay(()=>t.Bind(init(),()=>t.Bind(web_tree_sitter.TM.load(grammarPath(e.GrammarPath)),e=>{const n=new web_tree_sitter.iX;return n.setLanguage(e),t.Return(new FSharpResult$2(0,[n]))}))),n=>t.Return(new FSharpResult$2(1,[new AnalysisError(3,[e.Id,Types_toString(n)])])))))}function loadParser(e){const t=task();return t.Run(t.Delay(()=>{let n;const r=new FSharpRef(defaultOf());return n=[tryGetValue(parserCache,e.Id,r),r.contents],n[0]?t.Return(new FSharpResult$2(0,[n[1]])):t.Bind(createParser(e),n=>{const r=n;if(0===r.tag){const n=r.fields[0];return addToDict(parserCache,e.Id,n),t.Return(new FSharpResult$2(0,[n]))}return t.Return(new FSharpResult$2(1,[r.fields[0]]))})}))}function analyzeFile(e,t,n){const r=e,o=task();return o.Run(o.Delay(()=>{const e=resolveLanguageForFile(r);if(null!=e){const i=e;return o.Bind(loadParser(i),e=>o.Return(Result_Bind(e=>Result_Map(e=>e.Violations,analyzeParsedSource(e,i,r,t,n)),e)))}return o.Return(new FSharpResult$2(1,[new AnalysisError(0,[r])]))}))}function readSource(e){const t=readFileSyncSafe(e,"utf8");return 1===t.tag?new FSharpResult$2(1,[new AnalysisError(2,[e,t.fields[0]])]):new FSharpResult$2(0,[t.fields[0]])}function analyzePath(e,t){const n=task();return n.Run(n.Delay(()=>{const r=readSource(e);return 0===r.tag?n.ReturnFrom(analyzeFile(e,r.fields[0],t)):n.Return(new FSharpResult$2(1,[r.fields[0]]))}))}function analyzeFiles(e,t){const n=task();return n.Run(n.Delay(()=>{if(List_isEmpty(e))return n.Return(new FSharpResult$2(0,[List_empty()]));{const r=List_head(e);return n.Bind(analyzePath(r,t),o=>{const i=o;return 0===i.tag?n.Bind(analyzeFiles(List_tail(e),t),e=>n.Return(Result_Map(e=>cons(new FileResult((0,external_node_path_namespaceObject.relative)(process.cwd(),r),i.fields[0]),e),e))):n.Return(new FSharpResult$2(1,[i.fields[0]]))})}}))}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)?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&&!startsWith(e,"#",4))))):List_empty()}function matchesLiteralPattern(e,t){const n=t;return n.indexOf("/")>=0?e===n||startsWith(e,n+"/",4):Array_contains(n,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(startsWith(t,List_head(r),4)){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}}})(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=>{const t=e;return e.indexOf("*")>=0?matchesBasenameGlob(t,o):matchesLiteralPattern(r,t)},n)}}var Scan_record_type,Scan_string_type,Scan_list_type;const ignoredDirectoryNames=Set_ofList(ofArray(["node_modules",".git","bin","obj","dist","out","build","fable-out","fable_modules","fable-tests","spike-js",".next","coverage",".vscode-test","target",".gradle","__pycache__",".venv","venv",".tox",".nox",".pytest_cache",".mypy_cache",".ruff_cache"]),{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(getCharAtIndex(external_node_path_namespaceObject.sep,0),o),a=-1===i?".":substring(e,0,i),s=substring(e,e.lastIndexOf("*")+1),l=!startsWith(s,".",4)||s.indexOf("*")>=0?void 0:s;if((0,external_node_fs_namespaceObject.existsSync)(a)&&(0,external_node_fs_namespaceObject.statSync)(a).isDirectory()){const e=walkDirectory(a,t,List_empty());return defaultArg((n=l,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|compare(e,t)})),{Compare:(e,t)=>0|compare(e,t)})}const toolVersion="0.23.2";function sarifLevel(e){switch(e.tag){case 1:return"warning";case 0:return"note";default:return"error"}}function renderSarif(e){const t=List_collect(e=>List_map(t=>[e.FilePath,t],e.Violations),e),n=List_toArray(List_map(e=>({id:violationRuleId(e),name:violationRuleName(e),shortDescription:{text:"Energy State Analyzer "+violationDisplayName(e)+" finding"},helpUri:violationHelpUri(e)}),List_sortBy(violationTypeName,List_distinct(List_map(e=>e.Type,List_map(e=>e[1],t)),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),{Compare:(e,t)=>0|comparePrimitives(e,t)}))),r=List_toArray(List_map(e=>{const t=e[1],n=List_toArray(List_map(e=>({line:e.Line+1,weight:e.Weight}),t.Hotspots));return{ruleId:violationRuleId(t.Type),level:sarifLevel(t.Severity),message:{text:t.Message},locations:[{physicalLocation:{artifactLocation:{uri:e[0]},region:{startLine:t.Line+1,startColumn:t.Column+1}}}],properties:{energyStateSeverity:severityName(t.Severity),hotspots:n}}},t));return{$schema:"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",version:"2.1.0",runs:[{tool:{driver:{name:"Energy State Analyzer",version:toolVersion,informationUri:"https://github.com/cardamomcode/energy-state-analyzer",rules:n}},results:r}]}}const Int32_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&Int32_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 parseOverflow(e,t){return OverflowException_$ctor_Z721C83C5(`Value was either too large or too small for ${8===t?e?"an unsigned byte":"a signed byte":(e?"a UInt":"an Int")+t}.`)}function Int32_parse(e,t,n,r,o){if(null==e)throw ArgumentNullException_$ctor_Z721C83C5("s");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[a,s]=Int32_getRange(n,r);if(e>=a&&e<=s)return e;throw parseOverflow(n,r)}}throw FormatException_$ctor_Z721C83C5(`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 ReportHuman_union_type;const maxComplexityScore=100,scoreCeiling=10,lowThreshold=4,mediumThreshold=7,highThreshold=9,highFileScore=7.5,mediumFileScore=5;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=ofArray([[0,0],[10,3.9],[20,6.9],[50,8.9],[100,10]]);function complexityToScore(e){if(e<=0)return 0;if(e>=maxComplexityScore)return scoreCeiling;{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<lowThreshold?RiskLevel.LowRisk:e<mediumThreshold?RiskLevel.MediumRisk:e<highThreshold?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"relatively simple; keep changes small and verify behavior";case 2:return"becoming harder to understand and test; simplify branching or nesting";case 3:return"complex and difficult to verify; separate responsibilities and test decisions independently";case 4:return"extremely complex; restructure into smaller, independently understandable and testable units";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"Broad Protected Scope";case 13:return"Recovery Dominance";case 14:return"Oversized Recovery Block";case 16:return"Parse, don't validate";case 15: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"terminal conditionals or deep if-nesting that may be easier to read with guard clauses or a named operation";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 overly broad protected try region";case 13:return"recovery/cleanup policy that dominates a function";case 14:return"an individual handler or cleanup body exceeding the configured line limit";case 16:return"a checked property that is not preserved in the returned type";case 15: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),a=classifyScore(i);let s;if(1===List_length(o))s=toText(printf("1 function scores %d"))(t);else{const e=0|List_length(o),n=join(", ",List_map(int32ToString,o));s=toText(printf("%d functions score %s (worst: %d)"))(e)(n)(t)}return n=riskLabel(a),r=riskDescription(a),toText(printf("- **%s**: %s — score %.1f (%s): %s."))(e)(s)(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),a=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)},ofArray(["high","medium","low"]))),s=defaultArg((n=categoryBlurb(e),null!=n?" — "+n:void 0),""),l=1===List_length(t)?"":"s";return r=categoryLabel(e),o=0|List_length(t),toText(printf("- **%s**: %d finding%s (%s)%s."))(r)(o)(l)(a)(s)}}}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)?highFileScore:List_exists(e=>equals(e.Severity,Severity.Medium),e)?mediumFileScore: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(ofArray([(t=riskLabel(classifyScore(n)),toText(printf("## %s — %s (score %.1f)"))(e.FilePath)(t)(n)),""]),r))}const scoreLegend=join("\n",["## Score legend","","_Scores use the familiar [CVSS 0–10 severity bands](https://www.first.org/cvss/v3.1/specification-document#t5) to communicate the seriousness of analyzer findings. These are code complexity and maintainability scores, not security vulnerability scores._","","| Score | Severity | Meaning and action | Cyclomatic/cognitive input |","| --- | --- | --- | --- |","| 0.0 | None | No violations found | — |","| 0.1–3.9 | Low | Relatively simple; keep changes small and verify behavior | 1–10 |","| 4.0–6.9 | Medium | Becoming harder to understand and test; simplify branching or nesting | 11–20 |","| 7.0–8.9 | High | Complex and difficult to verify; separate responsibilities and test decisions independently | 21–50 |","| 9.0–10.0 | Critical | Extremely complex; restructure into smaller, independently understandable and testable units | 50+ |","","_Cyclomatic complexity describes independent control-flow paths; cognitive complexity estimates reading effort. The report applies the same numeric curve to both as a prioritization heuristic, not evidence that they measure equivalent effort. A file with no complexity violations 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,a,s;const l=List_sortByDescending(e=>fileScore(e.Violations),List_filter(e=>!List_isEmpty(e.Violations),e),{Compare:(e,t)=>0|comparePrimitives(e,t)}),_=List_length(e)-List_length(l)|0,u=List_map(e=>[e.FilePath,fileScore(e.Violations)],e),c=List_fold((e,t)=>t[1]>e[1]?t:e,["",0],u),d=Map_ofList(List_countBy(e=>classifyScore(e[1]),u,{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(ofArray(["# Energy State Report","",scoreLegend,"",(t=0|List_length(e),n=0|List_length(l),toText(printf("**%d file%s scanned** — %d with no findings, %d flagged"))(t)(f)(_)(n)),""]),List_append(List_collect(e=>ofArray([renderFileSection(e),""]),l),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)),(a=0|defaultArg(Map_tryFind(RiskLevel.HighRisk,d),0),toText(printf("| High | %d |"))(a)),(s=0|defaultArg(Map_tryFind(RiskLevel.Critical,d),0),toText(printf("| Critical | %d |"))(s)),"",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)]))))}var ReportDiff_union_type,ReportDiff_record_type,ReportDiff_string_type,ReportDiff_option_type,ReportDiff_int32_type,CliModes_union_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)),a=0|List_length(List_filter(e=>equals(e.Status,DiffStatus.New),e)),s=1===List_length(e)?"":"s";return join("\n",List_append(ofArray([toText(printf("# Energy State Diff vs `%s`"))(t),"","| File | Base | Head | Δ | Status |","| --- | --- | --- | --- | --- |"]),List_append(r,ofArray(["",(n=0|List_length(e),toText(printf("_%d file%s changed, %d worsened, %d improved, %d new._"))(n)(s)(o)(i)(a))]))))}class ReportFormat extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Human","Markdown","Sarif","Json"]}static Human=new ReportFormat(0,[]);static Markdown=new ReportFormat(1,[]);static Sarif=new ReportFormat(2,[]);static Json=new ReportFormat(3,[])}function ReportFormat_$reflection(){return CliModes_union_type("Energy.CliModes.ReportFormat",[],ReportFormat,()=>[[],[],[],[]])}const reportFormats=Map_ofList(ofArray([["human",ReportFormat.Human],["md",ReportFormat.Markdown],["markdown",ReportFormat.Markdown],["sarif",ReportFormat.Sarif],["json",ReportFormat.Json]]),{Compare:(e,t)=>0|comparePrimitives(e,t)});function parseReportFormat(e){const t=Map_tryFind(e,reportFormats);return null==t?new FSharpResult$2(1,["Unsupported report format: "+e]):new FSharpResult$2(0,[t])}function printUsage(){error("Usage: energy-state-cli <file.py|.fs|.fsx|.ts> [thresholds...]"),error(" energy-state-cli <path...> [--report json|md|human|sarif] [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 --medium-parameter-count N --high-parameter-count N"),error("Flags: --include-test-files (also flag magic numbers, magic strings, and opaque booleans 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){const t=summarize(e);return{files:List_toArray(List_map(e=>{const t=summarizeFile(e);return{filePath:t.FilePath,score:t.Score,counts:{low:t.Counts.Low,medium:t.Counts.Medium,high:t.Counts.High},byType:createObj(List_map(e=>[e[0],e[1]],Map_toList(t.ByType))),violations:List_toArray(List_map(violationJson,e.Violations))}},List_filter(e=>!equals(e.Violations,List_empty()),e))),filesScanned:List_length(e),totalScore:t.TotalScore,totalCounts:{low:t.TotalCounts.Low,medium:t.TotalCounts.Medium,high:t.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 runScan(e,t,n){const r=task();return r.Run(r.Delay(()=>r.Bind(analyzeFiles(resolveSupportedFiles(e,process.cwd()),t),e=>{const t=e;if(0===t.tag){const e=t.fields[0],o=summarize(e);return output(1===n.tag?renderMarkdownReport(o):2===n.tag?JSON.stringify(renderSarif(e),null,2):3===n.tag?JSON.stringify(summaryJson(e),null,2):renderHumanReport(e)),process.exit(hasBlockingViolations(o.TotalCounts)?1:0),r.Zero()}return error("energy-state-cli failed: "+analysisErrorMessage(t.fields[0])),process.exit(1),r.Zero()})))}function changedFilesFromGit(e){let t;return 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){const n=execFileSyncSafe("git",["show",e+":"+t],{encoding:"utf8",stdio:["ignore","pipe","ignore"]});return 1===n.tag?void error("energy-state-cli: could not read "+t+" at "+e+" (new file or rename) — treating as new"):n.fields[0]}function analyzeChanged(e,t,n,r,o){const i=task();return i.Run(i.Delay(()=>{if(List_isEmpty(n))return i.Return(new FSharpResult$2(0,[[List_reverse(r),List_reverse(o)]]));{const a=List_tail(n),s=List_head(n);return i.Bind(analyzePath(s,t),n=>{const l=n;if(0===l.tag){const n=summarizeFile(new FileResult(s,l.fields[0])),_=readAtRef(e,s);if(null!=_){const l=_;return i.Bind(analyzeFile(s,l,t),l=>{const _=l;if(0===_.tag){const l=summarizeFile(new FileResult(s,_.fields[0]));return i.ReturnFrom(analyzeChanged(e,t,a,cons(l,r),cons(n,o)))}return i.Return(new FSharpResult$2(1,[_.fields[0]]))})}return i.ReturnFrom(analyzeChanged(e,t,a,r,cons(n,o)))}return i.Return(new FSharpResult$2(1,[l.fields[0]]))})}}))}function runDiff(e,t,n,r){const o=task();return o.Run(o.Delay(()=>{const i=process.cwd(),a=loadIgnorePatterns(i),s=List_filter(e=>!isIgnored((0,external_node_path_namespaceObject.resolve)(e),i,a),List_filter(e=>null!=resolveLanguageForFile(e)&&(0,external_node_fs_namespaceObject.existsSync)(e),List_isEmpty(t)?changedFilesFromGit(e):t));return o.Bind(analyzeChanged(e,n,s,List_empty(),List_empty()),t=>{const n=t;if(0===n.tag){const t=diffSummaries(n.fields[0][0],n.fields[0][1]);return output(equals(r,ReportFormat.Markdown)?renderDiffMarkdown(t,e):JSON.stringify(diffJson(t),null,2)),process.exit(List_exists(e=>equals(e.Status,DiffStatus.Worsened),t)?1:0),o.Zero()}return error("energy-state-cli failed: "+analysisErrorMessage(n.fields[0])),process.exit(1),o.Zero()})}))}var Cli_record_type,Cli_list_type,Cli_string_type,Cli_option_type,Cli_tuple_type,Cli_int32_type,Cli_bool_type,Cli_union_type,Cli_ReportFormat_$reflection;class ParsedArguments extends Record{constructor(e,t,n,r,o,i,a,s,l){super(),this.Paths=e,this.BaseRef=t,this.Report=n,this.ConfigFile=r,this.Nesting=o,this.Cyclomatic=i,this.Cognitive=a,this.ParameterCount=s,this.IncludeTestFiles=l}}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_ReportFormat_$reflection())],["ConfigFile",Cli_option_type(Cli_string_type)],["Nesting",Cli_tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["Cyclomatic",Cli_tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["Cognitive",Cli_tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["ParameterCount",Cli_tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["IncludeTestFiles",Cli_bool_type]])}const valueFlags=Set_ofList(ofArray(["base-ref","report","config","medium-nesting","high-nesting","medium-cyclomatic","high-cyclomatic","medium-cognitive","high-cognitive","medium-parameter-count","high-parameter-count"]),{Compare:(e,t)=>0|comparePrimitives(e,t)});class CliToken extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["PositionalPath","BooleanFlag","ValueFlag","InvalidOption"]}}function CliToken_$reflection(){return Cli_union_type("Energy.Cli.CliToken",[],CliToken,()=>[[["Item",Cli_string_type]],[["Item",Cli_string_type]],[["Item",Cli_string_type]],[["Item",Cli_string_type]]])}function classifyArgument(e){if(startsWith(e,"--",4)){const t=substring(e,2);return"include-test-files"===t?new CliToken(1,[t]):FSharpSet__Contains(valueFlags,t)?new CliToken(2,[t]):new CliToken(3,[e])}return new CliToken(0,[e])}function parseValues(e){return((t,n,r)=>{e:for(;;){const o=t,i=n,a=r;if(o>=e.length)return new FSharpResult$2(0,[[List_reverse(i),a]]);{const s=classifyArgument(Array_item(o,e));switch(s.tag){case 1:t=o+1,n=i,r=Map_add(s.fields[0],"true",a);continue e;case 3:return new FSharpResult$2(1,["Unknown option: "+s.fields[0]]);case 2:{const l=s.fields[0],_=tryItem(o+1,e);let u,c;if(null!=_?startsWith(_,"--",4)?u=1:(u=0,c=_):u=1,0===u){t=o+2,n=i,r=Map_add(l,c,a);continue e}return new FSharpResult$2(1,["Missing value for --"+l])}default:t=o+1,n=cons(s.fields[0],i),r=a;continue e}}break}})(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){const e=n;let t;const r=new FSharpRef(0);return t=[Int32_tryParse(e,511,!1,32,r),r.contents],t[0]?t[1]:void 0}}function parseArguments(e){return Result_Bind(e=>{let t;const n=e[1],r=Seq_tryFind(e=>Seq_exists(e=>{let t;return!(t=new FSharpRef(0),[Int32_tryParse(e,511,!1,32,t),t.contents])[0]},toArray(Map_tryFind(e,n))),Set_filter(e=>"base-ref"!==e&&"report"!==e&&"config"!==e,valueFlags));return null==r?Result_Map(t=>new ParsedArguments(e[0],Map_tryFind("base-ref",n),t,Map_tryFind("config",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")],[asNumber(n,"medium-parameter-count"),asNumber(n,"high-parameter-count")],containsKey("include-test-files",n)),(t=Map_tryFind("report",n),null==t?new FSharpResult$2(0,[void 0]):Result_Map(e=>e,parseReportFormat(t)))):new FSharpResult$2(1,["Invalid integer for --"+r])},parseValues(e))}function buildThresholds(e){let t;return Result_Map(t=>{let n;const r=t.MagicNumber;let o;n=new MagicNumberOptions(r.Enabled,r.Allowlist,e.IncludeTestFiles);const i=t.MagicString;o=new MagicStringOptions(i.Enabled,i.MinDuplicates,i.Allowlist,e.IncludeTestFiles);const a=new OpaqueBooleanThresholds(t.OpaqueBoolean.Enabled,e.IncludeTestFiles);return new AnalyzeOptions(new NestingThresholds(t.Nesting.Enabled,defaultArg(e.Nesting[0],t.Nesting.MediumThreshold),defaultArg(e.Nesting[1],t.Nesting.HighThreshold)),new CyclomaticThresholds(t.Cyclomatic.Enabled,defaultArg(e.Cyclomatic[0],t.Cyclomatic.MediumThreshold),defaultArg(e.Cyclomatic[1],t.Cyclomatic.HighThreshold)),new CognitiveThresholds(t.Cognitive.Enabled,defaultArg(e.Cognitive[0],t.Cognitive.MediumThreshold),defaultArg(e.Cognitive[1],t.Cognitive.HighThreshold)),t.Coherence,t.MatchOpportunity,new ParameterCountThresholds(t.ParameterCount.Enabled,defaultArg(e.ParameterCount[0],t.ParameterCount.MediumThreshold),defaultArg(e.ParameterCount[1],t.ParameterCount.HighThreshold)),n,o,t.PrimitiveObsession,a,t.ParseDontValidate,t.LogicalControlFlow,t.Inversion,t.ErrorShadowing)},Result_MapError(configErrorMessage,(t=e.ConfigFile,null==t?loadAnalyzeOptions(process.cwd()):loadAnalyzeOptionsFromConfigPath(t))))}function validatePaths(e){const t=List_tryPick(e=>e.indexOf("*")>=0?void 0:(0,external_node_fs_namespaceObject.existsSync)(e)?(0,external_node_fs_namespaceObject.statSync)(e).isFile()&&null==resolveLanguageForFile(e)?"Unsupported input file: "+e:void 0:"Input path not found: "+e,e);return null==t?new FSharpResult$2(0,[void 0]):new FSharpResult$2(1,[t])}function runCli(){const e=task();return e.Run(e.Delay(()=>e.TryWith(e.Delay(()=>{const t=Result_Bind(e=>Result_Bind(()=>Result_Map(t=>[e,t],buildThresholds(e)),validatePaths(e.Paths)),parseArguments(process.argv.slice(2)));if(0===t.tag){const n=t.fields[0][1],r=t.fields[0][0],o=defaultArg(r.Report,null!=r.BaseRef?ReportFormat.Markdown:ReportFormat.Json),i=r.BaseRef;if(null==i)return List_isEmpty(r.Paths)?(printUsage(),process.exit(2),e.Zero()):e.Bind(runScan(r.Paths,n,o),()=>e.Zero());{const t=i;return e.Bind(runDiff(t,r.Paths,n,o),()=>e.Zero())}}return error("energy-state-cli: "+t.fields[0]),process.exit(2),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__})();
|
|
2
|
+
(()=>{"use strict";var __webpack_modules__={747(e,t,n){e.exports=n.p+"a5f4afce3ed7382a77b6.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}function newFinalizer(e){try{return new FinalizationRegistry(e)}catch(e){return void console.error("Unsupported FinalizationRegistry:",e)}}__name(assertInternal,"assertInternal"),__name(isPoint,"isPoint"),__name(setModule,"setModule"),__name(newFinalizer,"newFinalizer");var finalizer=newFinalizer(e=>{C._ts_lookahead_iterator_delete(e)}),LookaheadIterator=class{static{__name(this,"LookaheadIterator")}0=0;language;positioned=!1;constructor(e,t,n){assertInternal(e),this[0]=t,this.language=n,finalizer?.register(this,t,this)}get currentTypeId(){return this.positioned?C._ts_lookahead_iterator_current_symbol(this[0]):null}get currentType(){const e=this.currentTypeId;return null===e?null:this.language.types[e]??C.UTF8ToString(C._ts_language_symbol_name(this.language[0],e))}delete(){finalizer?.unregister(this),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,this.positioned=!1,!0)}resetState(e){return!!C._ts_lookahead_iterator_reset_state(this[0],e)&&(this.positioned=!1,!0)}[Symbol.iterator](){return{next:__name(()=>{this.positioned=Boolean(C._ts_lookahead_iterator_next(this[0]));const e=this.currentType;return null===e?{done:!0,value:""}:{done:!1,value:e}},"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 finalizer2=newFinalizer(e=>{C._ts_tree_delete(e)}),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,finalizer2?.register(this,t,this)}copy(){const t=C._ts_tree_copy(this[0]);return new e(INTERNAL,t,this.language,this.textCallback)}delete(){finalizer2?.unregister(this),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}},finalizer3=newFinalizer(e=>{C._ts_tree_cursor_delete_wasm(e)}),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),finalizer3?.register(this,this.tree[0],this)}copy(){const t=new e(INTERNAL,this.tree);return C._ts_tree_cursor_copy_wasm(this.tree[0]),unmarshalTreeCursor(t),t}delete(){finalizer3?.unregister(this),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 a=C.getValue(TRANSFER_BUFFER,"i32"),s=C.getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),l=new Array(a);if(a>0){let e=s;for(let t=0;t<a;t++)l[t]=unmarshalNode(this.tree,e),e+=SIZE_OF_NODE}return C._free(s),C._free(i),l}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,a=o.length;i<a;i++){const a=C.getValue(n,"i32"),s=unmarshalNode(t,n+=SIZE_OF_INT);n+=SIZE_OF_NODE,o[i]={patternIndex:r,name:e.captureNames[a],node:s}}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 a=C.getValue(t,"i32");return new Node(INTERNAL,{id:n,tree:e,startIndex:r,startPosition:{row:o,column:i},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 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});return e.loadFromWasmExports(r,{sync:!1})}static loadFromWasmExports(t,{sync:n}){const r=Object.keys(t),o=r.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(r,null,2)}`),new Error(`Language.${n?"loadSync":"load"} failed: no language function found in Wasm file`);const i=t[o]();return new e(INTERNAL,i)}static loadSync(t){const n=C.loadWebAssemblyModule(t,{loadAsync:!1});return e.loadFromWasmExports(n,{sync:!0})}};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 a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var l=63&e[t++];if((a=224==(240&a)?(15&a)<<12|s<<6|l:(7&a)<<18|s<<12|l<<6|63&e[t++])<65536)i+=String.fromCharCode(a);else{var _=a-65536;i+=String.fromCharCode(55296|_>>10,56320|1023&_)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}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 a(){for(var e=o(),t=[];e--;)t.push(i());return t}function s(e,t){if(e)throw new Error(t)}if(__name(r,"getU8"),__name(o,"getLEB"),__name(i,"getString"),__name(a,"getStringList"),__name(s,"failIf"),e instanceof WebAssembly.Module){var l=WebAssembly.Module.customSections(e,"dylink.0");s(0===l.length,"need dylink section"),n=(e=new Uint8Array(l[0])).length}else{var _=new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer);s(!(1836278016==_[0]||6386541==_[0]),"need to see wasm magic number"),s(0!==e[8],"need the dylink section to be first"),t=9;var u=o();n=t+u,s("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=a();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=a():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=82240,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 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?i().then(o=>loadWebAssemblyModule(o,t,e,n,r)):loadWebAssemblyModule(i(),t,e,n,r)}function s(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(a,"getExports"),__name(s,"moduleLoaded"),t.loadAsync?a().then(e=>(s(e),!0)):(s(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=82240,___stack_low=16704,___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},82240),___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 a=LE_HEAP_LOAD_U32(4*(t>>2)),s=LE_HEAP_LOAD_U32(4*(t+4>>2));t+=8;for(var l=0;l<s;l++)printChar(e,HEAPU8[a+l]);o+=s}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,a=0;a<e.length;++a){var s=e.codePointAt(a);if(s<=127){if(n>=i)break;t[n++]=s}else if(s<=2047){if(n+1>=i)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=i)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=i)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s,a++}}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 a=e.charCodeAt(i);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_copy,_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,_iswpunct,_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_copy=_ts_query_copy=e.ts_query_copy,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._iswpunct=_iswpunct=e.iswpunct,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 finalizer4=newFinalizer(e=>{C._ts_parser_delete(e[0]),C._free(e[1])}),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(),finalizer4?.register(this,[this[0],this[1]],this)}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(){finalizer4?.unregister(this),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 a=new Tree(INTERNAL,i,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,o){super(e.formatMessage(t,n)),this.kind=t,this.info=n,this.index=r,this.length=o,this.name="QueryError"}kind;info;index;length;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,a=e[2].name;r[t].push(e=>{const t=[],r=[];for(const o of e)o.name===n&&t.push(o.node),o.name===a&&r.push(o.node);const s=__name((e,t,n)=>n?e.text===t.text:e.text!==t.text,"compare");return i?t.every(e=>r.some(t=>s(e,t,o))):t.some(e=>r.some(t=>s(e,t,o)))})}else{const n=e[1].name,a=e[2].value,s=__name(e=>e.text===a,"matches"),l=__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=o?s:l;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-"),a=e[1].name,s=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?s.test(e):!s.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,a=e.slice(2);if(!a.every(isStringStep))throw new Error(`Arguments to \`#${n}\` predicate must be strings.".`);const s=a.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=>s.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,a,s,l,_,u){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,a);break;case"any-not-match?":case"not-match?":case"any-match?":case"match?":parseMatchPredicate(i,e,t,a);break;case"not-any-of?":case"any-of?":parseAnyOfPredicate(i,e,t,a);break;case"is?":case"is-not?":parseIsPredicate(i,e,t,_,u);break;case"set!":parseSetDirective(i,e,l);break;default:s[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 finalizer5=newFinalizer(e=>{C._ts_query_delete(e)}),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],a=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:a},o,a.length);case QueryErrorKind.PatternStructure:throw new QueryError(e,{suffix:`${o}: '${i}'...`},o,0)}}const i=C._ts_query_string_count(o),a=C._ts_query_capture_count(o),s=C._ts_query_pattern_count(o),l=new Array(a),_=new Array(s),u=new Array(i);for(let e=0;e<a;e++){const t=C._ts_query_capture_name_for_id(o,e,TRANSFER_BUFFER),n=C.getValue(TRANSFER_BUFFER,"i32");l[e]=C.UTF8ToString(t,n)}for(let e=0;e<s;e++){const t=new Array(a);for(let n=0;n<a;n++){const r=C._ts_query_capture_quantifier_for_id(o,e,n);t[n]=r}_[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");u[e]=C.UTF8ToString(t,n)}const c=new Array(s),d=new Array(s),p=new Array(s),m=new Array(s),f=new Array(s);for(let e=0;e<s;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,u,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=l,this.captureQuantifiers=_,this.textPredicates=f,this.predicates=m,this.setProperties=c,this.assertedProperties=d,this.refutedProperties=p,this.exceededMatchLimit=!1,finalizer5?.register(this,o,this)}delete(){finalizer5?.unregister(this),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,a=t.startContainingPosition??ZERO_POINT,s=t.endContainingPosition??ZERO_POINT,l=t.startContainingIndex??0,_=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!==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!==_&&l>_)throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");if(s!==ZERO_POINT&&(a.row>s.row||a.row===s.row&&a.column>s.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,a.row,a.column,s.row,s.column,l,_,u,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,a=t.startContainingPosition??ZERO_POINT,s=t.endContainingPosition??ZERO_POINT,l=t.startContainingIndex??0,_=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!==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!==_&&l>_)throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");if(s!==ZERO_POINT&&(a.row>s.row||a.row===s.row&&a.column>s.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,a.row,a.column,s.row,s.column,l,_,u,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 a=2&r&&n;("object"==typeof a||"function"==typeof a)&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).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]()))}class ArrayEnumerator{constructor(e){this.current=defaultOf(),this.index=-1,this.array=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.index;return e<this.array.length?(this.current=this.array[e],!0):(this.current=defaultOf(),!1)}"System.Collections.IEnumerator.Reset"(){this.index=-1,this.current=defaultOf()}Dispose(){}}function getEnumerator(e){return isEnumerable(e)?e.GetEnumerator():Array.isArray(e)?new ArrayEnumerator(e):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 combineHashCode(e,t){return(e<<5)+e^t}function combineHashCodes(e){let t=0;const n=e.length;for(let r=0;r<n;r++)t=combineHashCode(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){let t=0;for(let n=0;n<e.length;n++)t=combineHashCode(t,structuralHash(e[n]));return t}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:if(isHashable(e))return e.GetHashCode();if(isArrayLike(e))return arrayHash(e);if(e instanceof Date)return dateHash(e);if(Object.getPrototypeOf(e)?.constructor===Object){const t=Object.values(e);let n=0;for(let e=0;e<t.length;e++)n=combineHashCode(n,structuralHash(t[e]));return n}return 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 a=n[o];if(a!==r[o])return a<r[o]?-1:1;if(i=compare(e[a],t[a]),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,a=i>.5-1e-8&&i<.5+1e-8?o%2==0?o:o+1:Math.round(r);return t?a/n:a}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){Array.isArray(e)?e.length=0:ArrayBuffer.isView(e)||("function"==typeof e.clear?e.clear():"function"==typeof e["System.Collections.Generic.ICollection`1.Clear"]?e["System.Collections.Generic.ICollection`1.Clear"]():"function"==typeof e["System.Collections.IList.Clear"]&&e["System.Collections.IList.Clear"]())}ObjectRef.idMap=new WeakMap,ObjectRef.count=0;const curriedKey=Symbol("curried");function getCurried(e){return null==e?void 0:e[curriedKey]}function uncurry2(e){if(null==e)return null;const t=(t,n)=>e(t)(n);return t[curriedKey]=e,t}function curry2(e){return getCurried(e)??(t=>n=>e(t,n))}function uncurry3(e){if(null==e)return null;const t=(t,n,r)=>e(t)(n)(r);return t[curriedKey]=e,t}function curry3(e){return getCurried(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 t[curriedKey]=e,t}function curry4(e){return getCurried(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 t[curriedKey]=e,t}function curry5(e){return getCurried(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,a)=>e(t)(n)(r)(o)(i)(a);return t[curriedKey]=e,t}function curry6(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>e(t,n,r,o,i,a))}function uncurry7(e){if(null==e)return null;const t=(t,n,r,o,i,a,s)=>e(t)(n)(r)(o)(i)(a)(s);return t[curriedKey]=e,t}function curry7(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>e(t,n,r,o,i,a,s))}function uncurry8(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l)=>e(t)(n)(r)(o)(i)(a)(s)(l);return t[curriedKey]=e,t}function curry8(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>e(t,n,r,o,i,a,s,l))}function uncurry9(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_);return t[curriedKey]=e,t}function curry9(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>e(t,n,r,o,i,a,s,l,_))}function uncurry10(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u);return t[curriedKey]=e,t}function curry10(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>e(t,n,r,o,i,a,s,l,_,u))}function uncurry11(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c);return t[curriedKey]=e,t}function curry11(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>e(t,n,r,o,i,a,s,l,_,u,c))}function uncurry12(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d);return t[curriedKey]=e,t}function curry12(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>e(t,n,r,o,i,a,s,l,_,u,c,d))}function uncurry13(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p);return t[curriedKey]=e,t}function curry13(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>e(t,n,r,o,i,a,s,l,_,u,c,d,p))}function uncurry14(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m);return t[curriedKey]=e,t}function curry14(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m))}function uncurry15(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f);return t[curriedKey]=e,t}function curry15(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f))}function uncurry16(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f)(y);return t[curriedKey]=e,t}function curry16(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>y=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y))}function uncurry17(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f)(y)(h);return t[curriedKey]=e,t}function curry17(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>y=>h=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h))}function uncurry18(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f)(y)(h)(g);return t[curriedKey]=e,t}function curry18(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>y=>h=>g=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g))}function uncurry19(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g,S)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f)(y)(h)(g)(S);return t[curriedKey]=e,t}function curry19(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>y=>h=>g=>S=>e(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g,S))}function uncurry20(e){if(null==e)return null;const t=(t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g,S,$)=>e(t)(n)(r)(o)(i)(a)(s)(l)(_)(u)(c)(d)(p)(m)(f)(y)(h)(g)(S)($);return t[curriedKey]=e,t}function curry20(e){return getCurried(e)??(t=>n=>r=>o=>i=>a=>s=>l=>_=>u=>c=>d=>p=>m=>f=>y=>h=>g=>S=>$=>e(t,n,r,o,i,a,s,l,_,u,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(){let e=combineHashCode(0,numberHash(this.tag));for(let t=0;t<this.fields.length;t++)e=combineHashCode(e,structuralHash(this.fields[t]));return 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){const t=Object.values(e);let n=0;for(let e=0;e<t.length;e++)n=combineHashCode(n,structuralHash(t[e]));return n}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 void 0===this.getter?this.value:this.getter()}set contents(e){void 0===this.setter?this.value=e:this.setter(e)}constructor(e,t){"function"==typeof t?(this.getter=e,this.setter=t,this.value=void 0):(this.getter=void 0,this.setter=void 0,this.value=e)}}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="The input list 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 a=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(a);break;case 2:i+=padWithZeros(day(a),2);break;case 3:i+=shortDays[dayOfWeek(a)];break;default:i+=longDays[dayOfWeek(a)]}break;case"f":if(o=parseRepeatToken(t,r,"f"),r+=o,o<=3){const e=10**(3-o);i+=padWithZeros(Math.floor(millisecond(a)/e),o)}else{if(!(o<=7))throw"Input string was not in a correct format.";i+=(""+millisecond(a)).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(a)/e);0!=t&&(i+=padWithZeros(t,o))}else{if(!(o<=7))throw"Input string was not in a correct format.";{const e=millisecond(a);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(a)%12||12}else{i+=padWithZeros(hour(a)%12||12,2)}break;case"H":o=parseRepeatToken(t,r,"H"),r+=o,i+=1===o?hour(a):padWithZeros(hour(a),2);break;case"K":if(o=parseRepeatToken(t,r,"K"),r+=o,1===o)switch(getKind(a)){case DateTimeKind.Utc:i+="Z";break;case DateTimeKind.Local:i+=dateOffsetToString(-6e4*a.getTimezoneOffset());case DateTimeKind.Unspecified:}break;case"m":o=parseRepeatToken(t,r,"m"),r+=o,i+=1===o?minute(a):padWithZeros(minute(a),2);break;case"M":switch(o=parseRepeatToken(t,r,"M"),r+=o,o){case 1:i+=month(a);break;case 2:i+=padWithZeros(month(a),2);break;case 3:i+=shortMonths[month(a)-1];break;default:i+=longMonths[month(a)-1]}break;case"s":o=parseRepeatToken(t,r,"s"),r+=o,i+=1===o?second(a):padWithZeros(second(a),2);break;case"t":o=parseRepeatToken(t,r,"t"),r+=o,i+=1===o?a.getHours()<12?"A":"P":a.getHours()<12?"AM":"PM";break;case"y":switch(o=parseRepeatToken(t,r,"y"),r+=o,o){case 1:i+=year(a)%100;break;case 2:i+=padWithZeros(year(a)%100,2);break;default:i+=padWithZeros(year(a),o)}break;case"z":o=parseRepeatToken(t,r,"z"),r+=o;let s="";switch(getKind(a)){case DateTimeKind.Utc:s="+00:00";break;case DateTimeKind.Local:s=dateOffsetToString(-6e4*a.getTimezoneOffset());break;case DateTimeKind.Unspecified:s=dateOffsetToString(-6e4*toLocalTime(a).getTimezoneOffset())}const l="-"===s[0]?"-":"+",_=parseInt(s.substring(1,3),10),u=parseInt(s.substring(4,6),10);switch(o){case 1:i+=`${l}${_}`;break;case 2:i+=`${l}${padWithZeros(_,2)}`;break;default:i+=`${l}${padWithZeros(_,2)}:${padWithZeros(u,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(a,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=DateTime(e.getTime()+(e.offset??0),DateTimeKind.Utc);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,a=0,s){const l=s===Date_DateTimeKind.Utc?new Date(Date.UTC(e,t-1,n,r,o,i,a)):new Date(e,t-1,n,r,o,i,a);e<=99&&(s===Date_DateTimeKind.Utc?l.setUTCFullYear(e,t-1,n):l.setFullYear(e,t-1,n));const _=l.getTime();if(isNaN(_))throw new Date_Exception("The parameters describe an unrepresentable Date.");return DateTime(_,s)}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,a=daysInMonth(i,r);return create(i,r,Math.min(a,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_26_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 divide(e,t){return"number"==typeof e?e/t:"bigint"==typeof e?Number(e)/t:e[symbol]().multiply(1/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 bigintToExponential(e,t){const n=e<0n?"-":"";let r=(e<0n?-e:e).toString();if(0n===e)return n+(t?"0."+"0".repeat(t):"0")+"e+0";t=t??r.length-1;let o=r.length-1;if(r.length>t+1){const e=r.charCodeAt(t+1)>=53;r=(BigInt(r.slice(0,t+1))+(e?1n:0n)).toString(),r.length>t+1&&(r=r.slice(0,t+1),o+=1)}else r=r.padEnd(t+1,"0");return n+(t>0?r[0]+"."+r.slice(1):r[0])+"e+"+o}function toExponential(e,t){return"number"==typeof e?e.toExponential(t):"bigint"==typeof e?bigintToExponential(e,t):e[symbol]().toExponential(t)}function toRadix(e,t){return"number"==typeof e?(Number(e)>>>0).toString(t):"bigint"==typeof e?BigInt.asUintN(64,e).toString(t):16===t?e[symbol]().toHex():String(e)}function toHex(e){return toRadix(e,16)}function RegExp_create(e,t=0){if(-1308&t)throw new Exception("RegexOptions only supports: IgnoreCase, Multiline, Compiled, Singleline, ECMAScript and NonBacktracking");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,a,s,l)=>{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 _=a??s;if(null!=_){const n=parseInt(_,10);return n<t.length?t[n]??"":e}return null!=t.groups&&l in t.groups?t.groups[l]??"":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 a=i?o-3:o-2;for(let e=0;e<a;e++)t.push(arguments[e]);t.index=arguments[a++],t.input=arguments[a++],i&&(t.groups=arguments[a]),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,a=null==n?-1:n-1;for(const n of RegExp_matches(e,t,r)){if(0===a)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]);a--}return o.push(t.substring(i)),o}var String_escape,String_Exception;const dateTimeFormattableSymbol=Symbol.for("Fable.DateTimeFormattable");function isNetDateFormattable(e){return null!=e&&"function"==typeof e[dateTimeFormattableSymbol]}function formatDateLike(e,t){return e instanceof Date?Date_toString(e,t):e[dateTimeFormattableSymbol](t)}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,a="".concat.apply("",t);for(let t=r;t<i;t++)if(a.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 a=i.index+(i[1]||"").length;o+=e.substring(r,a).replace(/%%/g,"%");const[,,s,l,_,u]=i;r=interpolateRegExp.lastIndex,o+=formatReplacement(t[n++],s,l,_,u),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)){const n="x"===o||"X"===o?16:"o"===o?8:10;switch(10===n&&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":case"o":e=toRadix(e,n);break;case"X":e=toRadix(e,n).toUpperCase();break;default:e=String(e)}}else e=e instanceof Date||isNetDateFormattable(e)?formatDateLike(e,void 0):"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,a=o||!r?" ":"0";e="0"===a?i+(e=pad(e,n-i.length,a,o)):pad(i+e,n,a,o)}return e}function createPrinter(e,t,n,r="",o=-1){return(...i)=>{let a=r;const s=t.slice(),l=n.slice();for(const e of i){const[,,t,n,r,i]=l[0];let _=n;if(o>=0)_=o,o=-1;else if("*"===_){if(e<0)throw new Exception("Non-negative number required");o=e;continue}a+=s[0],a+=formatReplacement(e,t,_,r,i),s.splice(0,1),l.splice(0,1)}return 0===l.length?(a+=s[0],e(a)):createPrinter(e,s,l,a,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 splitExponential(e){const t=e.indexOf("e");return[e.slice(0,t).replace(".",""),Number(e.slice(t+1))]}function shortestSingle(e){const[t,n]=splitExponential(e.toExponential(99));for(let r=1;;r++){const o=Number(t.slice(0,r)),i=t.slice(r),a="5".padEnd(i.length,"0"),s=i>a||i===a&&o%2==1;for(const t of s?[o+1,o]:[o,o+1])if(Math.fround(Number(t+"e"+(n-r+1)))===e)return[String(t),n+String(t).length-r]}}function formatGeneral(e,t,n,r=!1){if(!Number.isFinite(e))return String(e);const o=e<0||Object.is(e,-0)?"-":"";e=Math.abs(e);const i="r"===t||"R"===t?0:n??0,[a,s]=i>0?splitExponential(e.toExponential(i-1)):r?shortestSingle(e):splitExponential(e.toExponential()),l=trimEnd(a,"0")||"0";if(s<-4||s>=(i>0?i:r?9:17))return o+(l.length>1?l[0]+"."+l.slice(1):l)+("G"===t||"R"===t?"E":"e")+(s<0?"-":"+")+padLeft(String(Math.abs(s)),2,"0");if(s<0)return o+"0."+"0".repeat(-s-1)+l;{const e=l.slice(s+1);return o+l.slice(0,s+1).padEnd(s+1,"0")+(e?"."+e:"")}}function formatSingle(e,t){const n=/^\{0:([GgRr])(\d{0,2})\}$/.exec(e);return null!=n?formatGeneral(Math.fround(t),n[1],n[2]?parseInt(n[2],10):null,!0):format(e,t)}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,a)=>{if(n<0||n>=t.length)throw new Exception("Index must be greater or equal to zero and less than the arguments' length.");let s,l=t[n];if(isNumeric(l))switch(i=""==i?null:parseInt(i,10),o){case"b":case"B":if(!isIntegral(l))throw new Exception("Format specifier was invalid.");l=(l>>>0).toString(2).replace(/^0+/,"").padStart(i||1,"0");break;case"c":case"C":const e=isLessThan(l,0);isLessThan(l,0)&&(l=multiply(l,-1)),l=toFixed(l,i=i??2),s=splitIntAndDecimalPart(l),l=i>0?"¤"+thousandSeparate(s.integral)+"."+padRight(s.decimal,i,"0"):"¤"+thousandSeparate(s.integral),e&&(l="("+l+")");break;case"d":case"D":if(!isIntegral(l))throw new Exception("Format specifier was invalid.");l=String(l),null!=i&&(l=l.startsWith("-")?"-"+padLeft(l.substring(1),i,"0"):padLeft(l,i,"0"));break;case"e":case"E":{i=null!=i?i:6,l=String(toExponential(l,i));const e=l.indexOf("e");l=l.slice(0,e)+o+l[e+1]+padLeft(l.slice(e+2),3,"0");break}case"f":case"F":l=toFixed(l,i=null!=i?i:2),i>0&&(s=splitIntAndDecimalPart(l),l=s.integral+"."+padRight(s.decimal,i,"0"));break;case"g":case"G":case"r":case"R":{if("number"==typeof l){l=formatGeneral(l,o,i);break}if(null==i){l=String(l);break}l=toPrecision(l,i);const e=l.indexOf("e");if(e>=0){const t=trimEnd(trimEnd(l.slice(0,e),"0"),"."),n=l[e+1],r=l.slice(e+2),i=r.length<2?"0"+r:r;l=t+("G"===o||"R"===o?"E":"e")+n+i}else l.indexOf(".")>=0&&(l=trimEnd(trimEnd(l,"0"),"."));break}case"n":case"N":l=toFixed(l,i=null!=i?i:2),s=splitIntAndDecimalPart(l),l=i>0?thousandSeparate(s.integral)+"."+padRight(s.decimal,i,"0"):thousandSeparate(s.integral);break;case"p":case"P":i=null!=i?i:2,l=toFixed(multiply(l,100),i),s=splitIntAndDecimalPart(l),l=i>0?thousandSeparate(s.integral)+"."+padRight(s.decimal,i,"0")+" %":thousandSeparate(s.integral)+" %";break;case"x":case"X":if(!isIntegral(l))throw new Exception("Format specifier was invalid.");i=null!=i?i:1,l=padLeft(toHex(l),i,"0"),"X"===o&&(l=l.toUpperCase());break;default:if(o)throw new Exception("Format specifier was invalid.");if(a){let e="";const t=a,n=(t.match(/%/g)??[]).length;n>0&&(l=multiply(l,Math.pow(100,n))),l=t.replace(/([0#,]+)(\.[0#]+)?(,*)/,(t,n,r)=>{const o=/,*$/.exec(n)[0].length;o>0&&(n=n.substring(0,n.length-o),l=divide(l,Math.pow(1e3,o))),isLessThan(l,0)&&(l=multiply(l,-1),e="-"),r=null==r?"":r.substring(1),l=toFixed(l,Math.max(r.length,0));let[i,a]=l.split(".");a||(a=""),i=padLeft(i,n.replace(/,/g,"").replace(/^#+/,"").length,"0");const s=r.replace(/#+$/,"").length;if(s>a.length?a=padRight(a,s,"0"):s<a.length&&(a=a.substring(0,s)+a.substring(s).replace(/0+$/,"")),n.indexOf(",")>0){const e=i.length%3,t=Math.floor(i.length/3);let n=e>0?i.substr(0,e)+(t>0?",":""):"";for(let r=0;r<t;r++)n+=i.substr(e+3*r,3)+(r<t-1?",":"");i=n}return a.length>0?i+"."+a:i}),l=e+l}}else l=l instanceof Date||isNetDateFormattable(l)?formatDateLike(l,a||o):Types_toString(l);return r=parseInt((r||" ").substring(1),10),isNaN(r)||(l=pad(String(l),Math.abs(r)," ",r<0)),l})}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 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 a=[],s=new RegExp(t.join("|"),"g");let l=!0,_=0;do{const t=s.exec(e);if(null===t){const t=i?e.substring(_).trim():e.substring(_);(!o||t.length>0)&&a.push(t),l=!1}else{const r=i?e.substring(_,t.index).trim():e.substring(_,t.index);(!o||r.length>0)&&(null!=n&&a.length+1===n?(a.push(i?e.substring(_).trim():e.substring(_)),l=!1):a.push(r)),_=s.lastIndex}}while(l);return a}function trim(e,...t){if(0===t.length)return e.trim();const n="["+RegExp_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_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(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(),System_defaultOf())}function ArgumentException_$ctor_Z721C83C5(e){return ArgumentException_$ctor_Z60A2B367(e,defaultOf(),defaultOf())}function ArgumentException_$ctor_Z384F8060(e,t){return ArgumentException_$ctor_Z60A2B367(e,t,defaultOf())}function ArgumentException_$ctor_68CE3CA2(e,t){return ArgumentException_$ctor_Z60A2B367(e,System_defaultOf(),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(System_defaultOf())}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(System_defaultOf())}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_InvalidArg(e,t){throw ArgumentException_$ctor_Z384F8060(t,e)}function Operators_InvalidOp(e){throw InvalidOperationException_$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 KeyNotFoundException_$ctor_Z721C83C5,Array_SR_keyNotFoundAlt,Array_SR_inputMustBeNonNegative,Array_SR_notEnoughElements,Array_SR_indexOutOfBounds,Array_SR_inputSequenceEmpty,Array_Operators_InvalidArg,Array_Operators_InvalidOp,Array_Helpers_allocateArrayFromCons,Array_defaultOf,Array_int32ToString,Array_getEnumerator,Array_disposeSafe,setItem_1,item_3,Array_ArgumentOutOfRangeException_$ctor_Z384F8060,Array_ArgumentException_$ctor_Z721C83C5,value_2,Array_some,Array_defaultArg,max_1,min_1,nonSeeded,List_defaultOf,List_isArrayLike,List_getEnumerator,List_disposeSafe,value_1,List_defaultArg,List_class_type,List_Operators_InvalidArg,List_Operators_InvalidOp,List_SR_inputWasEmpty,List_SR_inputSequenceEmpty,List_SR_inputMustBeNonNegative,List_SR_notEnoughElements,List_SR_inputSequenceTooLong,List_SR_indexOutOfBounds,foldBack_1,foldBack2_1,scanBack_1,tryFindBack_1,tryFindIndexBack_1,permute_1,map_1,chunkBySize_1,windowed_1,splitInto_1,transpose_1,List_randomShuffleInPlaceBy,randomChoiceBy_1,randomChoicesBy_1,randomSampleBy_1,List_nonSeeded;function indexNotFound(){throw KeyNotFoundException_$ctor_Z721C83C5(Array_SR_keyNotFoundAlt)}function differentLengths(e){throw Array_Operators_InvalidArg(e,"The arrays have 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_3(t,e));for(let e=0;e<=o-1;e++)setItem_1(i,e+r,item_3(e,t));return i}function Array_filter(e,t){return t.filter(e)}function fill(e,t,n,r){if(t<0)throw Operators_InvalidArg("targetIndex",SR_inputMustBeNonNegative);if(n<0)throw Operators_InvalidArg("count",SR_inputMustBeNonNegative);if(n>0&&t+n>e.length)throw IndexOutOfRangeException_$ctor();const o=0|t;return e.fill(r,o,o+n)}function getSubArray(e,t,n){if(t<0)throw Array_Operators_InvalidArg("startIndex",Array_SR_inputMustBeNonNegative);if(n<0)throw Array_Operators_InvalidArg("count",Array_SR_inputMustBeNonNegative);if(t+n>e.length)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("count","The index is outside the legal range.");const r=0|t;return e.slice(r,r+n)}function last(e){if(0===e.length)throw Operators_InvalidArg("array","The input array was empty");return Array_item(e.length-1,e)}function tryLast(e){return 0===e.length?void 0:some(Array_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,Array_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(Array_item(n,t)));return o}function mapIndexed2(e,t,n,r){t.length!==n.length&&differentLengths("array1");const o=Array_Helpers_allocateArrayFromCons(r,t.length);for(let r=0;r<=t.length-1;r++)setItem_1(o,r,e(r,item_3(r,t),item_3(r,n)));return o}function map2(e,t,n,r){t.length!==n.length&&differentLengths("array1");const o=Array_Helpers_allocateArrayFromCons(r,t.length);for(let r=0;r<=t.length-1;r++)setItem_1(o,r,e(item_3(r,t),item_3(r,n)));return o}function mapIndexed3(e,t,n,r,o){t.length===n.length&&n.length===r.length||differentLengths("array1, array2, array3");const i=Array_Helpers_allocateArrayFromCons(o,t.length);for(let o=0;o<=t.length-1;o++)setItem_1(i,o,e(o,item_3(o,t),item_3(o,n),item_3(o,r)));return i}function map3(e,t,n,r,o){t.length===n.length&&n.length===r.length||differentLengths("array1, array2, array3");const i=Array_Helpers_allocateArrayFromCons(o,t.length);for(let o=0;o<=t.length-1;o++)setItem_1(i,o,e(item_3(o,t),item_3(o,n),item_3(o,r)));return i}function mapFold(e,t,n,r){const o=0|n.length;if(0===o)return[[],t];{let i=t;const a=Array_Helpers_allocateArrayFromCons(r,o);for(let t=0;t<=n.length-1;t++){const r=e(i,item_3(t,n));setItem_1(a,t,r[0]),i=r[1]}return[a,i]}}function mapFoldBack(e,t,n,r){const o=0|t.length;if(0===o)return[[],n];{let i=n;const a=Array_Helpers_allocateArrayFromCons(r,o);for(let n=t.length-1;n>=0;n--){const r=e(item_3(n,t),i);setItem_1(a,n,r[0]),i=r[1]}return[a,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_3(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_3(0,n);default:{let e=0,r=0;for(let e=0;e<=n.length-1;e++)r=r+item_3(e,n).length|0;const o=Array_Helpers_allocateArrayFromCons(t,r);for(let t=0;t<=n.length-1;t++){const r=item_3(t,n);for(let t=0;t<=r.length-1;t++)setItem_1(o,e,item_3(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 a=0|defaultArg(n,0),s=0|defaultArg((i=r,null!=i?a+i:void 0),e.length);return 0|(n=>{for(;;){const r=n;if(r>=s)return-1;if(o.Equals(t,Array_item(r,e)))return 0|r;n=r+1}})(a)}function Array_contains(e,t,n){return Array_indexOf(t,e,void 0,void 0,n)>=0}function binarySearchFrom(e,t,n,r,o){return 0|((t,n)=>{e:for(;;){const i=t,a=n;if(i>a)return 0|~i;{const s=i+(a-i>>1)|0,l=0|o.Compare(item_3(s,e),r);if(0===l)return 0|s;if(l<0){t=s+1,n=a;continue e}t=i,n=s-1;continue e}}})(t,t+n-1)}function checkBinarySearchRange(e,t,n,r){if(n<0)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("index","Non-negative number required.");if(r<0)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060(e,"Non-negative number required.");if(t.length-n<r)throw Array_ArgumentException_$ctor_Z721C83C5("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.")}function binarySearch(e,t,n){return 0|binarySearchFrom(e,0,e.length,t,n)}function binarySearchRange(e,t,n,r,o){return checkBinarySearchRange("length",e,t,n),0|binarySearchFrom(e,t,n,r,o)}function binarySearchRangeCount(e,t,n,r,o){return checkBinarySearchRange("count",e,t,n),0|binarySearchFrom(e,t,n,r,o)}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 Operators_InvalidArg("count","The input must be non-negative");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,[Array_item(r,e),Array_item(r+1,e)]);return n}}function Array_replicate(e,t,n){if(e<0)throw Array_Operators_InvalidArg("count","The input must be non-negative");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 copyTypedArray(e,t,n,r,o){n.set(e.subarray(t,t+o),r)}function argumentOutOfRange(e,t,n){throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060(e,e+" ('"+Array_int32ToString(t)+"') must be "+n)}function copyTo(e,t,n,r,o){if(o<0&&argumentOutOfRange("length",o,"a non-negative value."),t<0&&argumentOutOfRange("sourceIndex",t,"greater than or equal to '0'."),t+o>e.length)throw Array_Operators_InvalidArg("sourceArray","Source array was not long enough. Check the source index, length, and the array's lower bounds.");if(r<0&&argumentOutOfRange("destinationIndex",r,"greater than or equal to '0'."),r+o>n.length)throw Array_Operators_InvalidArg("destinationArray","Destination array was not long enough. Check the destination index, length, and the array's lower bounds.");if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n))copyTypedArray(e,t,n,r,o);else if(t<r)for(let i=o-1;i>=0;i--){const o=r+i|0;let a;a=e[t+i|0],n[o]=a}else for(let i=0;i<=o-1;i++){const o=r+i|0;let a;a=e[t+i|0],n[o]=a}}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_3(t,o),item_3(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_3(n,t),item_3(n+1,o)));return o}function skip(e,t,n){if(e>t.length)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("count","The index is outside the legal range.");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_3(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 Array_Operators_InvalidArg("count","The input must be non-negative");if(e>t.length)throw Array_Operators_InvalidOp(Array_SR_notEnoughElements);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_3(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 a=0,s=0;for(let n=0;n<=r-1;n++)e(item_3(n,t))?(setItem_1(o,a,item_3(n,t)),a=a+1|0):(setItem_1(i,s,item_3(n,t)),s=s+1|0);return[truncate(a,o),truncate(s,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_3(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_3(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_3(r,t)))return item_3(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_3(r,t)))return Array_some(item_3(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_3(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_3(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_3(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(Array_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_3(n,t))}function iterateIndexed(e,t){for(let n=0;n<=t.length-1;n++)e(n,item_3(n,t))}function iterate2(e,t,n){t.length!==n.length&&differentLengths("array1");for(let r=0;r<=t.length-1;r++)e(item_3(r,t),item_3(r,n))}function iterateIndexed2(e,t,n){t.length!==n.length&&differentLengths("array1");for(let r=0;r<=t.length-1;r++)e(r,item_3(r,t),item_3(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();let o;const i=new Array(n);if(o=i.fill(0,0,0+n),iterateIndexed((t,i)=>{const a=0|e(t);if(a<0||a>=n)throw Array_Operators_InvalidArg("indexMap","The function did not compute a permutation.");setItem_1(r,a,i),setItem_1(o,a,1)},t),!o.every(e=>1===e))throw Array_Operators_InvalidArg("indexMap","The function did not compute a permutation.");return r}function setSlice(e,t,n,r){const o=0|Array_defaultArg(t,0),i=0|Array_defaultArg(n,-1),a=(i>=0?i:e.length-1)-o|0;for(let t=0;t<=a;t++)setItem_1(e,t+o,item_3(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_3(n,e),item_3(i,t)]);return o}function unfold(e,t){const n=[];return(t=>{e:for(;;){const r=e(t);if(null!=r){const e=r[0],o=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("array1");const n=new Array(e.length);for(let r=0;r<=e.length-1;r++)setItem_1(n,r,[item_3(r,e),item_3(r,t)]);return n}function zip3(e,t,n){e.length===t.length&&t.length===n.length||differentLengths("array1, array2, array3");const r=new Array(e.length);for(let o=0;o<=e.length-1;o++)setItem_1(r,o,[item_3(o,e),item_3(o,t),item_3(o,n)]);return r}function chunkBySize(e,t){if(e<1)throw Array_Operators_InvalidArg("chunkSize","The input must be positive.");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)throw Array_Operators_InvalidArg("index",Array_SR_indexOutOfBounds);if(e>t.length)throw Array_Operators_InvalidOp(Array_SR_notEnoughElements);return[t.slice(0,0+e),t.slice(e)]}function compareWith(e,t,n){if(null==t)return null==n?0:-1;if(null==n)return 1;{const r=0|t.length,o=0|n.length,i=0|(r<o?r:o);let a=0,s=0;for(;0===s&&a<i;)s=0|e(item_3(a,t),item_3(a,n)),a=a+1|0;return 0!==s?0|s:r>o?1:r<o?-1:0}}function Array_compareTo(e,t,n){if(null==t)return null==n?0:-1;if(null==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_3(o,t),item_3(o,n)),o=o+1|0;return 0|i}}}function equalsWith(e,t,n){if(null==t)return null==n;if(null==n)return!1;{let r=0,o=!0;const i=0|t.length,a=0|n.length;if(i>a)return!1;if(i<a)return!1;for(;r<i&&o;)o=e(item_3(r,t),item_3(r,n)),r=r+1|0;return o}}function exactlyOne(e){switch(e.length){case 1:return item_3(0,e);case 0:throw Array_Operators_InvalidArg("array","The input sequence was empty");default:throw Array_Operators_InvalidArg("array","Input array too long")}}function tryExactlyOne(e){return 1===e.length?Array_some(item_3(0,e)):void 0}function head(e){if(0===e.length)throw Array_Operators_InvalidArg("array","The input array was empty");return item_3(0,e)}function tryHead(e){return 0===e.length?void 0:Array_some(item_3(0,e))}function tail(e){if(0===e.length)throw Array_Operators_InvalidArg("array","Not enough elements");return e.slice(1)}function Array_item(e,t){const n=t[e];if(void 0===n&&(e<0||e>=t.length))throw Operators_InvalidArg("index","Index was outside the bounds of the array.");return n}function setItem(e,t,n){if(t<0||t>=e.length)throw Operators_InvalidArg("index","Index was outside the bounds of the array.");e[t]=n}function tryItem(e,t){return e<0||e>=t.length?void 0: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;n.length!==r.length&&differentLengths("array1");for(let t=0;t<=n.length-1;t++)o=e(t,o,item_3(t,n),item_3(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("array1");const i=0|t.length;for(let r=1;r<=i;r++)o=e(r-1,item_3(i-r,t),item_3(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 Array_Operators_InvalidArg("array","The input array was empty");const n=e;return t.reduce(n)}function reduceBack(e,t){if(0===t.length)throw Array_Operators_InvalidArg("array","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_3(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,a=n,s=r;if(s===i.length)return!1;if(o(item_3(s,i),item_3(s,a)))return!0;e=o,t=i,n=a,r=s+1}}function exists2(e,t,n){return t.length!==n.length&&differentLengths("array1"),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_3(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_3(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 Array_Operators_InvalidArg("array","The input array was empty");let n=t.GetZero();for(let r=0;r<=e.length-1;r++)n=t.Add(n,item_3(r,e));return t.DivideByInt(n,e.length)}function averageBy(e,t,n){if(0===t.length)throw Array_Operators_InvalidArg("array","The input array was empty");let r=n.GetZero();for(let o=0;o<=t.length-1;o++)r=n.Add(r,e(item_3(o,t)));return n.DivideByInt(r,t.length)}function windowed(e,t){if(e<=0)throw Array_Operators_InvalidArg("windowSize","The input 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 Array_Operators_InvalidArg("count","The input must be positive.");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 a;const s=e*o+min_1(i,e)|0;a=t.slice(s,s+r),n.push(a)}}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_3(0,n).length;forAll(t=>t.length===e,n)||differentLengths("array.[0]");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_3(i,o)[e]=item_3(i,item_3(e,n))}return o}}function insertAt(e,t,n,r){const o=0|n.length;if(e<0||e>o)throw Array_Operators_InvalidArg("index",Array_SR_indexOutOfBounds);const i=Array_Helpers_allocateArrayFromCons(r,o+1);for(let t=0;t<=e-1;t++)setItem_1(i,t,item_3(t,n));setItem_1(i,e,t);for(let t=e;t<=o-1;t++)setItem_1(i,t+1,item_3(t,n));return i}function insertManyAt(e,t,n,r){const o=0|n.length;if(e<0||e>o)throw Array_Operators_InvalidArg("index",Array_SR_indexOutOfBounds);const i=Array.from(t),a=0|i.length,s=Array_Helpers_allocateArrayFromCons(r,o+a);for(let t=0;t<=e-1;t++)setItem_1(s,t,item_3(t,n));for(let t=0;t<=a-1;t++)setItem_1(s,e+t,item_3(t,i));for(let t=e;t<=o-1;t++)setItem_1(s,t+a,item_3(t,n));return s}function randomShuffleInPlaceBy(e,t){for(let n=(0|t.length)-1;n>=1;n--){const r=e();if(r<0||r>=1)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("randomizer","The index is outside the legal range.");const o=r*(n+1)|0,i=item_3(n,t);setItem_1(t,n,item_3(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 Array_Operators_InvalidArg("source",Array_SR_inputSequenceEmpty);const n=0|t.length,r=e();if(r<0||r>=1)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("randomizer","The index is outside the legal range.");return item_3(~~(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 Array_Operators_InvalidArg("count",Array_SR_inputMustBeNonNegative);if(t>0&&isEmpty(n))throw Array_Operators_InvalidArg("source",Array_SR_inputSequenceEmpty);const o=0|n.length;return Array_initialize(t,t=>{const r=e();if(r<0||r>=1)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("randomizer","The index is outside the legal range.");return item_3(~~(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 Array_Operators_InvalidArg("count",Array_SR_inputMustBeNonNegative);const r=copy(n),o=0|r.length;if(0===o&&t>0)throw Array_Operators_InvalidArg("source",Array_SR_inputSequenceEmpty);if(t>o)throw Array_Operators_InvalidArg("count",Array_SR_notEnoughElements);for(let n=0;n<=t-1;n++){const t=e();if(t<0||t>=1)throw Array_ArgumentOutOfRangeException_$ctor_Z384F8060("randomizer","The index is outside the legal range.");const i=n+~~(t*(o-n))|0,a=item_3(n,r);setItem_1(r,n,item_3(i,r)),setItem_1(r,i,a)}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 Array_Operators_InvalidArg("index",Array_SR_indexOutOfBounds);let n=-1;return Array_filter(t=>(n=n+1|0,n!==e),t)}function removeManyAt(e,t,n){if(e<0||e>n.length-t||e>n.length)throw Array_Operators_InvalidArg("index","index must be within bounds of the array");let r=-1;return Array_filter(n=>(r=r+1|0,r<e||r>=e+t),n)}function updateAt(e,t,n,r){const o=0|n.length;if(e<0||e>=o)throw Array_Operators_InvalidArg("index",Array_SR_indexOutOfBounds);const i=Array_Helpers_allocateArrayFromCons(r,o);for(let r=0;r<=o-1;r++)setItem_1(i,r,r===e?t:item_3(r,n));return i}function resize(e,t,n,r){let o,i,a,s;if(t<0)throw Array_Operators_InvalidArg("newSize","The input must be non-negative.");const l=Array_defaultArg(n,Array_defaultOf());if(null==e.contents)e.contents=(o=Array_Helpers_allocateArrayFromCons(r,t),o.fill(l,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&©To(e.contents,0,o,0,n),e.contents=(a=0|n,s=t-n|0,o.fill(l,a,a+s))}}}class FSharpList{constructor(e,t){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 FSharpList&&((e,t)=>{e:for(;;){const n=e,r=t,o=n.tail,i=r.tail;if(null!=o){if(null!=i){const a=o,s=i;if(equals(n.head,r.head)){e=a,t=s;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,a=i.tail;if(null!=a){const s=a;if(r>18)return 0|o;e=r+1,t=(o<<1)+structuralHash(i.head)+631*r,n=s;continue e}return 0|o}})(0,0,this)}toJSON(){return Array.from(this)}CompareTo(e){return e instanceof FSharpList?0|((e,t)=>{e:for(;;){const n=e,r=t,o=n.tail,i=r.tail;if(null!=o){if(null!=i){const a=o,s=i,l=0|compare(n.head,r.head);if(0===l){e=a,t=s;continue e}return 0|l}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 List_class_type("ListModule.FSharpList",[e],FSharpList)}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=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_$ctor_Z23DD7291(e,t){return new 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=r}})(0,e)}function FSharpList__get_Head(e){if(null!=e.tail)return e.head;throw Operators_InvalidOp(SR_inputWasEmpty)}function FSharpList__get_Tail(e){const t=e.tail;if(null!=t)return t;throw Operators_InvalidOp(SR_inputWasEmpty)}function FSharpList__get_Item_Z524259A4(e,t){return((e,n)=>{e:for(;;){const r=e,o=n,i=o.tail;if(null!=i){const a=i;if(r===t)return o.head;e=r+1,n=a;continue e}throw Operators_InvalidArg("index",SR_indexOutOfBounds)}})(0,e)}const emptyNode=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0);function List_empty(){return emptyNode}function List_indexNotFound(){throw System_Collections_Generic_KeyNotFoundException_$ctor_Z721C83C5(SR_keyNotFoundAlt)}function List_differentLengths(e){throw List_Operators_InvalidArg(e,"The lists had different lengths.")}function cons(e,t){return FSharpList_$ctor_Z23DD7291(e,t)}function List_singleton(e){return FSharpList_$ctor_Z23DD7291(e,List_empty())}function List_isEmpty(e){return FSharpList__get_IsEmpty(e)}function List_length(e){return 0|FSharpList__get_Length(e)}function List_head(e){if(null!=e.tail)return e.head;throw Operators_InvalidArg("list",SR_inputWasEmpty)}function List_tryHead(e){return FSharpList__get_IsEmpty(e)?void 0:some(FSharpList__get_Head(e))}function List_tail(e){const t=e.tail;if(null!=t)return t;throw Operators_InvalidArg("list",SR_inputWasEmpty)}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 List_Operators_InvalidArg("list",List_SR_inputWasEmpty);return 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),a=FSharpList__get_IsEmpty(o);if(i)return a?0:-1;if(a)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_$ctor_Z23DD7291(t,e),List_empty(),e)}function List_foldBack(e,t,n){return foldBack_1(e,List_toArray(t),n)}function List_foldIndexed(e,t,n){return((t,n,r)=>{for(;;){const o=t,i=n,a=r;if(FSharpList__get_IsEmpty(a))return i;t=o+1,n=e(o,i,FSharpList__get_Head(a)),r=FSharpList__get_Tail(a)}})(0,t,n)}function List_fold2(e,t,n,r){let o=t,i=n,a=r;for(;!FSharpList__get_IsEmpty(i)&&!FSharpList__get_IsEmpty(a);)o=e(o,FSharpList__get_Head(i),FSharpList__get_Head(a)),i=FSharpList__get_Tail(i),a=FSharpList__get_Tail(a);return FSharpList__get_IsEmpty(i)?FSharpList__get_IsEmpty(a)||List_differentLengths("list1"):List_differentLengths("list2"),o}function List_foldBack2(e,t,n,r){const o=List_toArray(t),i=List_toArray(n);return o.length!==i.length&&List_differentLengths(0===o.length?"list1":0===i.length?"list2":"list1, list2"),foldBack2_1(e,o,i,r)}function List_unfold(e,t){const n=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),r=((t,n)=>{for(;;){const r=n;let o;const i=e(t);if(null==i)return r;t=i[1],o=FSharpList_$ctor_Z23DD7291(i[0],void 0),r.tail=o,n=o}})(t,n),o=List_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_$ctor_Z23DD7291(Array_item(t,e),n);return n}function ofArray(e){return ofArrayWithTail(e,List_empty())}function ofSeq(e){if(isArrayLike(e))return ofArray(e);if(e instanceof FSharpList)return e;{const t=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0);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=FSharpList_$ctor_Z23DD7291(o,void 0),e.tail=t,n=t}}finally{disposeSafe(r)}const o=n,i=List_empty();return o.tail=i,FSharpList__get_Tail(t)}}function List_concat(e){const t=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0);let n=t;const r=e=>{n=List_fold((e,t)=>{const n=FSharpList_$ctor_Z23DD7291(t,void 0);return e.tail=n,n},n,e)};if(List_isArrayLike(e))e.forEach(r);else if(e instanceof 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=List_empty();return o.tail=i,FSharpList__get_Tail(t)}function List_scan(e,t,n){const r=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0);let o;const i=FSharpList_$ctor_Z23DD7291(t,void 0);r.tail=i,o=i;let a=t,s=n;for(;!FSharpList__get_IsEmpty(s);){let t,n;a=e(a,FSharpList__get_Head(s)),t=o,n=FSharpList_$ctor_Z23DD7291(a,void 0),t.tail=n,o=n,s=FSharpList__get_Tail(s)}const l=o,_=List_empty();return l.tail=_,FSharpList__get_Tail(r)}function List_scanBack(e,t,n){return ofArray(scanBack_1(e,List_toArray(t),n))}function List_append(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0);let r=n,o=e;for(;null!=o.tail;){let e,t;e=r,t=FSharpList_$ctor_Z23DD7291(o.head,void 0),e.tail=t,r=t,o=o.tail}return r.tail=t,FSharpList__get_Tail(n)}function List_collect(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0);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=FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(t),void 0),e.tail=n,r=n,t=FSharpList__get_Tail(t)}o=FSharpList__get_Tail(o)}const i=r,a=List_empty();return i.tail=a,FSharpList__get_Tail(n)}function List_mapIndexed(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=List_foldIndexed((t,n,r)=>{const o=FSharpList_$ctor_Z23DD7291(e(t,r),void 0);return n.tail=o,o},n,t),o=List_empty();return r.tail=o,FSharpList__get_Tail(n)}function List_map(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=List_fold((t,n)=>{const r=FSharpList_$ctor_Z23DD7291(e(n),void 0);return t.tail=r,r},n,t),o=List_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_$ctor_Z23DD7291(List_defaultOf(),void 0),o=List_fold2((t,n,r)=>{const o=FSharpList_$ctor_Z23DD7291(e(n,r),void 0);return t.tail=o,o},r,t,n),i=List_empty();return o.tail=i,FSharpList__get_Tail(r)}function List_mapIndexed2(e,t,n){const r=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),o=((t,n,r,o)=>{for(;;){const i=t,a=n,s=r,l=o;let _;if(FSharpList__get_IsEmpty(s)||FSharpList__get_IsEmpty(l))return FSharpList__get_IsEmpty(s)?FSharpList__get_IsEmpty(l)||List_differentLengths("list1"):List_differentLengths("list2"),a;t=i+1,_=FSharpList_$ctor_Z23DD7291(e(i,FSharpList__get_Head(s),FSharpList__get_Head(l)),void 0),a.tail=_,n=_,r=FSharpList__get_Tail(s),o=FSharpList__get_Tail(l)}})(0,r,t,n),i=List_empty();return o.tail=i,FSharpList__get_Tail(r)}function List_map3(e,t,n,r){const o=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),i=((t,n,r,o)=>{for(;;){const i=t,a=n,s=r,l=o;let _;if(FSharpList__get_IsEmpty(a)||FSharpList__get_IsEmpty(s)||FSharpList__get_IsEmpty(l))return FSharpList__get_IsEmpty(a)&&FSharpList__get_IsEmpty(s)&&FSharpList__get_IsEmpty(l)||List_differentLengths("list1, list2, list3"),i;_=FSharpList_$ctor_Z23DD7291(e(FSharpList__get_Head(a),FSharpList__get_Head(s),FSharpList__get_Head(l)),void 0),i.tail=_,t=_,n=FSharpList__get_Tail(a),r=FSharpList__get_Tail(s),o=FSharpList__get_Tail(l)}})(o,t,n,r),a=List_empty();return i.tail=a,FSharpList__get_Tail(o)}function List_mapFold(e,t,n){const r=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),o=List_fold((t,n)=>{let r;const o=e(t[1],n);return[(r=FSharpList_$ctor_Z23DD7291(o[0],void 0),t[0].tail=r,r),o[1]]},[r,t],n),i=List_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():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 tryFindBack_1(e,List_toArray(t))}function List_findBack(e,t){const n=List_tryFindBack(e,t);return null==n?List_indexNotFound():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|n}function List_tryFindIndexBack(e,t){return tryFindIndexBack_1(e,List_toArray(t))}function List_findIndexBack(e,t){const n=List_tryFindIndexBack(e,t);return null==n?(List_indexNotFound(),-1):0|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 item(e,t){return FSharpList__get_Item_Z524259A4(t,e)}function List_filter(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=List_fold((t,n)=>{if(e(n)){const e=FSharpList_$ctor_Z23DD7291(n,void 0);return t.tail=e,e}return t},n,t),o=List_empty();return r.tail=o,FSharpList__get_Tail(n)}function List_partition(e,t){const n=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),r=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0),o=n,i=List_fold((t,n)=>{let r,o;const i=t[0],a=t[1];return e(n)?[(r=FSharpList_$ctor_Z23DD7291(n,void 0),i.tail=r,r),a]:[i,(o=FSharpList_$ctor_Z23DD7291(n,void 0),a.tail=o,o)]},[o,r],t),a=List_empty();i[0].tail=a;const s=List_empty();return i[1].tail=s,[FSharpList__get_Tail(o),FSharpList__get_Tail(r)]}function List_choose(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=List_fold((t,n)=>{const r=e(n);if(null==r)return t;{const e=FSharpList_$ctor_Z23DD7291(Option_value(r),void 0);return t.tail=e,e}},n,t),o=List_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){if(e<0)throw Operators_InvalidArg("count",SR_inputMustBeNonNegative);const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0);let r=n;for(let n=0;n<=e-1;n++){let e,o;e=r,o=FSharpList_$ctor_Z23DD7291(t(n),void 0),e.tail=o,r=o}const o=r,i=List_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 Operators_InvalidArg("list",SR_inputWasEmpty);return List_fold(e,List_head(t),List_tail(t))}function List_reduceBack(e,t){if(FSharpList__get_IsEmpty(t))throw List_Operators_InvalidArg("list",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){for(;;){const r=e,o=t,i=n,a=FSharpList__get_IsEmpty(o),s=FSharpList__get_IsEmpty(i);if(a)return!!s||List_differentLengths("list1");if(s)return List_differentLengths("list2");if(!r(FSharpList__get_Head(o),FSharpList__get_Head(i)))return!1;e=r,t=FSharpList__get_Tail(o),n=FSharpList__get_Tail(i)}}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,a=FSharpList__get_IsEmpty(o),s=FSharpList__get_IsEmpty(i);let l;switch(l=a?s?0:2:s?2:1,l){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:return List_differentLengths("list2")}break}}function List_unzip(e){return List_foldBack((e,t)=>[FSharpList_$ctor_Z23DD7291(e[0],t[0]),FSharpList_$ctor_Z23DD7291(e[1],t[1])],e,[List_empty(),List_empty()])}function List_unzip3(e){return List_foldBack((e,t)=>[FSharpList_$ctor_Z23DD7291(e[0],t[0]),FSharpList_$ctor_Z23DD7291(e[1],t[1]),FSharpList_$ctor_Z23DD7291(e[2],t[2])],e,[List_empty(),List_empty(),List_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),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){if(FSharpList__get_IsEmpty(e))throw List_Operators_InvalidArg("source",List_SR_inputSequenceEmpty);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){if(FSharpList__get_IsEmpty(t))throw List_Operators_InvalidArg("source",List_SR_inputSequenceEmpty);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 ofArray(permute_1(e,List_toArray(t)))}function List_chunkBySize(e,t){return ofArray(map_1(ofArray,chunkBySize_1(e,List_toArray(t))))}function List_allPairs(e,t){const n=FSharpList_$ctor_Z23DD7291(List_defaultOf(),void 0);let r=n;List_iterate(e=>{List_iterate(t=>{let n,o;n=r,o=FSharpList_$ctor_Z23DD7291([e,t],void 0),n.tail=o,r=o},t)},e);const o=r,i=List_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 ArgumentOutOfRangeException_$ctor_Z384F8060("count","The index is outside the legal range.");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 Operators_InvalidArg("count",SR_inputMustBeNonNegative);const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=((e,t,n)=>{for(;;){const r=e,o=t,i=n;let a;if(r<=0)return o;if(FSharpList__get_IsEmpty(i))throw Operators_InvalidOp(SR_notEnoughElements);e=r-1,a=FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(i),void 0),o.tail=a,t=a,n=FSharpList__get_Tail(i)}})(e,n,t),o=List_empty();return r.tail=o,FSharpList__get_Tail(n)}function List_takeWhile(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),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=FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(o),void 0),r.tail=i,t=i,n=FSharpList__get_Tail(o)}})(n,t),o=List_empty();return r.tail=o,FSharpList__get_Tail(n)}function List_truncate(e,t){const n=FSharpList_$ctor_Z23DD7291(defaultOf(),void 0),r=((e,t,n)=>{for(;;){const r=e,o=t,i=n;let a;if(r<=0)return o;if(FSharpList__get_IsEmpty(i))return o;e=r-1,a=FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(i),void 0),o.tail=a,t=a,n=FSharpList__get_Tail(i)}})(e,n,t),o=List_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 a;o=i<0?0:i;const s=0|List_defaultArg(t,r-1);return a=s>=r?r-1:s,a<o?List_empty():List_take(a-o+1,List_skip(o,n))}function List_splitAt(e,t){if(e<0)throw List_Operators_InvalidArg("index",List_SR_inputMustBeNonNegative);if(e>FSharpList__get_Length(t))throw List_Operators_InvalidOp(List_SR_notEnoughElements);return[List_take(e,t),List_skip(e,t)]}function List_exactlyOne(e){if(FSharpList__get_IsEmpty(e))throw List_Operators_InvalidArg("list",List_SR_inputSequenceEmpty);if(FSharpList__get_IsEmpty(FSharpList__get_Tail(e)))return FSharpList__get_Head(e);throw List_Operators_InvalidArg("list",List_SR_inputSequenceTooLong)}function List_tryExactlyOne(e){return!FSharpList__get_IsEmpty(e)&&FSharpList__get_IsEmpty(FSharpList__get_Tail(e))?some(FSharpList__get_Head(e)):void 0}function List_where(e,t){return List_filter(e,t)}function List_pairwise(e){return ofArray(pairwise(List_toArray(e)))}function List_windowed(e,t){return ofArray(map_1(ofArray,windowed_1(e,List_toArray(t))))}function List_splitInto(e,t){return ofArray(map_1(ofArray,splitInto_1(e,List_toArray(t))))}function List_transpose(e){return ofArray(map_1(ofArray,transpose_1(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_$ctor_Z23DD7291(i,FSharpList_$ctor_Z23DD7291(t,n))):FSharpList_$ctor_Z23DD7291(i,n)),List_empty(),n);return List_reverse(o?i:r+1===e?FSharpList_$ctor_Z23DD7291(t,i):(()=>{throw List_Operators_InvalidArg("index",List_SR_indexOutOfBounds)})())}function List_insertManyAt(e,t,n){let r=-1,o=!1;const i=ofSeq(t),a=List_fold((t,n)=>(r=r+1|0,r===e?(o=!0,FSharpList_$ctor_Z23DD7291(n,List_append(i,t))):FSharpList_$ctor_Z23DD7291(n,t)),List_empty(),n);return List_reverse(o?a:r+1===e?List_append(i,a):(()=>{throw List_Operators_InvalidArg("index",List_SR_indexOutOfBounds)})())}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 List_Operators_InvalidArg("index",List_SR_indexOutOfBounds);return o}function List_removeManyAt(e,t,n){if(e<0)throw List_Operators_InvalidArg("index","index must be within bounds of the list");const r=e+t|0;let o=-1;const i=List_filter(t=>(o=o+1|0,o<e||o>=r),n);if(r>o+1)throw List_Operators_InvalidArg("index","index must be within bounds of the list");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 List_Operators_InvalidArg("index",List_SR_indexOutOfBounds);return o}function List_randomShuffleBy(e,t){const n=List_toArray(t);return List_randomShuffleInPlaceBy(e,n),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 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 ofArray(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 ofArray(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)}var Seq_ArgumentOutOfRangeException_$ctor_Z721C83C5,Seq_disposeSafe,Seq_getEnumerator,Seq_isDisposable,Seq_isArrayLike,Seq_clear,Seq_class_type,Seq_some,Seq_value_1,Seq_KeyNotFoundException_$ctor_Z721C83C5,Seq_Operators_NullArgCheck,Seq_Operators_InvalidArg,Seq_Operators_Lock,Seq_Operators_InvalidOp,Seq_tryFindBack_1,Seq_tryFindIndexBack_1,Seq_foldBack_1,item_1,tryHead_1,tryItem_1,mapFold_1,mapFoldBack_1,reduceBack_1,reverse_1,Seq_scanBack_1,pairwise_1,Seq_splitInto_1,Seq_windowed_1,Seq_permute_1,Seq_chunkBySize_1,Seq_randomShuffleInPlaceBy,Seq_randomChoiceBy_1,randomChoiceWith_1,randomChoice_1,Seq_randomChoicesBy_1,Seq_randomSampleBy_1,Seq_FSharpList,tryHead_2,isEmpty_1,tryItem_2,length_1,Seq_min_1,Seq_SR_inputMustBeNonNegative,Seq_SR_indexOutOfBounds,Seq_nonSeeded;const SR_enumerationAlreadyFinished="Enumeration already finished.",SR_enumerationNotStarted="Enumeration has not started. Call MoveNext.",SR_inputMustBePositive="The input must be positive.",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 a=()=>{if(i=!0,null!=n){const e=n;try{disposeSafe(e)}finally{n=void 0}}if(null!=t){const e=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 s=t;if(null!=s)if(null!=n){const e=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=s;e["System.Collections.IEnumerator.MoveNext"]()?(i=e["System.Collections.Generic.IEnumerator`1.get_Current"](),n=getEnumerator(i)):(a(),o=!1)}else t=getEnumerator(e)}return Option_value(o)}},()=>{i||a()})}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 a=()=>{if(null!=i){const e=Option_value(i);try{n(e)}finally{i=void 0}}},s=()=>{try{a()}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 s(),e}return null!=n?(r=n,!0):(s(),!1)}return!1},a)}function Enumerator_unfold(e,t){let n,r=t;return Enumerator_FromFunctions$1_$ctor_58C54629(()=>{if(null!=n){const e=n[0];return n[1],e}return Enumerator_notStarted()},()=>{if(n=e(r),null!=n){n[0];const e=n[1];return r=e,!0}return!1},()=>{})}function Seq_indexNotFound(){throw Seq_KeyNotFoundException_$ctor_Z721C83C5(Seq_SR_keyNotFoundAlt)}function mkSeq(e){return Enumerator_Seq_$ctor_673A07F2(e)}function Seq_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 Seq_ofArray(e){return e}function Seq_toArray(e){if(isArrayLike(e))return Array.from(e);if(e instanceof FSharpList)return List_toArray(e);{const t=[],n=getEnumerator(e);try{for(;n["System.Collections.IEnumerator.MoveNext"]();)t.push(n["System.Collections.Generic.IEnumerator`1.get_Current"]());return t.slice()}finally{disposeSafe(n)}}}function ofList(e){return e}function toList(e){return isArrayLike(e)?ofArray(e):e instanceof FSharpList?e: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(()=>Seq_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=>{disposeSafe(e)})}function Seq_compareWith(e,t,n){const r=Seq_ofSeq(t);try{const t=Seq_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=Seq_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,Seq_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,Seq_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,a=!1,s=!1;const l=()=>{try{let t;if(null==r){const n=Seq_getEnumerator(e);r=n,t=n}else t=r;return t["System.Collections.IEnumerator.MoveNext"]()?(o=Seq_some(t["System.Collections.Generic.IEnumerator`1.get_Current"]()),!0):(s=!0,!1)}catch(e){if(i)throw e;{const o=e;if(0!==t(o)){if(i=!0,null==r);else{const e=r;try{Seq_disposeSafe(e)}catch(e){}r=void 0}return r=Seq_getEnumerator(n(o)),l()}throw e}}};return Enumerator_FromFunctions$1_$ctor_58C54629(()=>(a?s&&Enumerator_alreadyFinished():Enumerator_notStarted(),null!=o?Seq_value_1(o):Enumerator_alreadyFinished()),()=>(a||(a=!0),!s&&l()),()=>{null==r||Seq_disposeSafe(r)})})}function Seq_filter(e,t){return Seq_choose(t=>e(t)?some(t):void 0,t)}function Seq_exists(e,t){const n=Seq_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=Seq_ofSeq(t);try{const t=Seq_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=Seq_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 Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceTooLong);return e}throw Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty)}finally{Seq_disposeSafe(t)}}function Seq_tryExactlyOne(e){const t=Seq_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=Seq_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=some(r))}return t}finally{disposeSafe(n)}}function Seq_find(e,t){const n=Seq_tryFind(e,t);return null==n?Seq_indexNotFound():Seq_value_1(n)}function Seq_tryFindBack(e,t){return Seq_tryFindBack_1(e,Seq_toArray(t))}function Seq_findBack(e,t){const n=Seq_tryFindBack(e,t);return null==n?Seq_indexNotFound():Seq_value_1(n)}function Seq_tryFindIndex(e,t){const n=Seq_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|n}function Seq_tryFindIndexBack(e,t){return Seq_tryFindIndexBack_1(e,Seq_toArray(t))}function Seq_findIndexBack(e,t){const n=Seq_tryFindIndexBack(e,t);return null==n?(Seq_indexNotFound(),-1):0|n}function Seq_fold(e,t,n){const r=Seq_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 Seq_foldBack_1(e,Seq_toArray(t),n)}function Seq_fold2(e,t,n,r){const o=Seq_ofSeq(n);try{const n=Seq_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 a=r;for(let t=(0|Seq_min_1(o.length,i.length))-1;t>=0;t--)a=e(item_1(t,o),item_1(t,i),a);return a}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 Seq_FSharpList)return tryHead_2(e);{const t=Seq_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 Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty);return Seq_value_1(t)}function Seq_initialize(e,t){if(e<0)throw Seq_Operators_InvalidArg("count",Seq_SR_inputMustBeNonNegative);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 Seq_FSharpList)return isEmpty_1(e);{const t=Seq_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 Seq_FSharpList)return tryItem_2(e,t);{const n=Seq_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 Seq_Operators_InvalidArg("index",Seq_SR_notEnoughElements);return Seq_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=Seq_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 Seq_Operators_InvalidArg("source",Seq_SR_notEnoughElements);return Seq_value_1(t)}function Seq_length(e){if(Seq_isArrayLike(e))return 0|e.length;if(e instanceof Seq_FSharpList)return 0|length_1(e);{const t=Seq_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(()=>Seq_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(()=>Seq_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(()=>[Seq_ofSeq(t),Seq_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(()=>[Seq_ofSeq(t),Seq_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(()=>[Seq_ofSeq(t),Seq_ofSeq(n),Seq_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!=Seq_value_1(r)?(e=0,t=Seq_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=Seq_value_1(r);else{const n=Seq_getEnumerator(t);r=Seq_some(n),e=n}if(null==e);else{const t=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=Seq_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():Seq_value_1(n)}function Seq_reduce(e,t){const n=Seq_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 Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty)}finally{disposeSafe(n)}}function Seq_reduceBack(e,t){const n=Seq_toArray(t);if(n.length>0)return reduceBack_1(e,n);throw Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty)}function Seq_replicate(e,t){if(e<0)throw Seq_ArgumentOutOfRangeException_$ctor_Z721C83C5("count");return Seq_initialize(e,e=>t)}function Seq_reverse(e){return delay(()=>Seq_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(()=>Seq_ofArray(Seq_scanBack_1(e,Seq_toArray(t),n)))}function Seq_skip(e,t){return mkSeq(()=>{const n=Seq_ofSeq(t);try{for(let t=1;t<=e;t++)if(!n["System.Collections.IEnumerator.MoveNext"]())throw Seq_Operators_InvalidOp(Seq_SR_notEnoughElements);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 mkSeq(()=>{const t=Seq_ofSeq(e);try{if(!t["System.Collections.IEnumerator.MoveNext"]())throw Seq_Operators_InvalidArg("source",Seq_SR_notEnoughElements);return Enumerator_enumerateThenFinally(()=>{},t)}catch(e){throw Seq_disposeSafe(t),e}})}function Seq_take(e,t){if(e<0)throw Seq_Operators_InvalidArg("count",Seq_SR_inputMustBeNonNegative);return generateIndexed(()=>Seq_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 Seq_Operators_InvalidOp(Seq_SR_notEnoughElements)}},e=>{Seq_disposeSafe(e)})}function Seq_takeWhile(e,t){return generate(()=>Seq_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(()=>Seq_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(()=>Seq_ofArray(pairwise_1(Seq_toArray(e))))}function Seq_splitInto(e,t){if(e<1)throw Seq_Operators_InvalidArg("count",SR_inputMustBePositive);return delay(()=>Seq_ofArray(Seq_splitInto_1(e,Seq_toArray(t))))}function Seq_windowed(e,t){if(e<1)throw Seq_Operators_InvalidArg("windowSize",SR_inputMustBePositive);return delay(()=>Seq_ofArray(Seq_windowed_1(e,Seq_toArray(t))))}function Seq_transpose(e){return delay(()=>{const t=[],n=Seq_getEnumerator(e);try{for(;n["System.Collections.IEnumerator.MoveNext"]();){let e,r=0,o=n["System.Collections.Generic.IEnumerator`1.get_Current"]();e=Seq_getEnumerator(o);try{for(;e["System.Collections.IEnumerator.MoveNext"]();){const n=e["System.Collections.Generic.IEnumerator`1.get_Current"]();r===t.length&&t.push([]),item_1(r,t).push(n),r=r+1|0}}finally{Seq_disposeSafe(e)}}}finally{Seq_disposeSafe(n)}return Seq_map(e=>e,t)})}function Seq_sortWith(e,t){return delay(()=>{const n=Seq_toArray(t);return n.sort(e),Seq_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 Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty);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 Seq_Operators_InvalidArg("source",Seq_SR_inputSequenceEmpty);return n.DivideByInt(o,r)}function Seq_permute(e,t){return delay(()=>Seq_ofArray(Seq_permute_1(e,Seq_toArray(t))))}function Seq_chunkBySize(e,t){if(e<1)throw Seq_Operators_InvalidArg("chunkSize",SR_inputMustBePositive);return delay(()=>Seq_ofArray(Seq_chunkBySize_1(e,Seq_toArray(t))))}function Seq_insertAt(e,t,n){let r=!1;if(e<0)throw Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds);return generateIndexed(()=>Seq_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 Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds)},e=>{Seq_disposeSafe(e)})}function Seq_insertManyAt(e,t,n){let r=-1;if(e<0)throw Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds);return generateIndexed(()=>[Seq_ofSeq(n),Seq_ofSeq(t)],(t,n)=>{const o=n[0],i=n[1];let a;if(t===e&&(r=0),0===r?i["System.Collections.IEnumerator.MoveNext"]()?a=Seq_some(i["System.Collections.Generic.IEnumerator`1.get_Current"]()):(r=1,a=void 0):a=void 0,null!=a)return Seq_some(Seq_value_1(a));if(o["System.Collections.IEnumerator.MoveNext"]())return Seq_some(o["System.Collections.Generic.IEnumerator`1.get_Current"]());if(r<1)throw Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds)},e=>{Seq_disposeSafe(e[0]),Seq_disposeSafe(e[1])})}function Seq_removeAt(e,t){let n=!1;if(e<0)throw Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds);return generateIndexed(()=>Seq_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 Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds)},e=>{Seq_disposeSafe(e)})}function Seq_removeManyAt(e,t,n){if(e<0)throw Seq_Operators_InvalidArg("index","index must be within bounds of the array");const r=e+t|0;return delay(()=>{let t=-1;return Seq_append(Seq_filter(n=>(t=t+1|0,t<e||t>=r),n),delay(()=>{if(t<e)throw Seq_Operators_InvalidArg("index","index must be within bounds of the array");return Seq_empty()}))})}function Seq_updateAt(e,t,n){let r=!1;if(e<0)throw Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds);return generateIndexed(()=>Seq_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 Seq_Operators_InvalidArg("index",Seq_SR_indexOutOfBounds)},e=>{Seq_disposeSafe(e)})}function Seq_randomShuffleBy(e,t){const n=Seq_toArray(t);return Seq_randomShuffleInPlaceBy(e,n),Seq_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 Seq_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 Seq_ofArray(Seq_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 Seq_ofArray(Seq_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_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,System_Collections_Generic_Operators_InvalidOp,Map_class_type,record_type,list_type,option_type,bool_type,Map_value_1,Map_some,Map_KeyNotFoundException_$ctor,Map_fill,map_2,Map_unfold,Map_map_1,pick_1,tryPick_1,union_type,Result_equals,Result_singleton,Result_empty,Result_some,Violation_union_type,Violation_record_type,int32_type,string_type,Violation_list_type,Report_record_type,Report_int32_type,Report_string_type,Report_list_type,Report_class_type,Report_EnergyViolation_$reflection;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(Array_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 System_Collections_Generic_Operators_InvalidOp("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 System_Collections_Generic_Operators_InvalidOp("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(Array_item(Queue$1__toIndex_Z524259A4(e,t),e.contents)),delay(()=>(t=t+1|0,Seq_empty())))))})}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){if(t instanceof MapTreeNode$2){const r=t;e=MapTreeModule_sizeAux(n+1,MapTreeNode$2__get_Left(r)),t=MapTreeNode$2__get_Right(r);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,a,s;a=null!=e?e instanceof MapTreeNode$2?(o=e,MapTreeNode$2__get_Height(o)):1:0,s=null!=r?r instanceof MapTreeNode$2?(i=r,MapTreeNode$2__get_Height(i)):1:0;const l=0|(a<s?s:a);return 0===l?MapTreeLeaf$2_$ctor_5BDDA1(t,n):MapTreeNode$2_$ctor_Z39DE9543(t,n,e,r,l+1)}function MapTreeModule_rebalance(e,t,n,r){let o,i,a,s,l,_,u,c,d,p;if(d=null!=e?e instanceof MapTreeNode$2?(o=e,MapTreeNode$2__get_Height(o)):1:0,p=null!=r?r instanceof MapTreeNode$2?(i=r,MapTreeNode$2__get_Height(i)):1:0,p>d+2){const o=Option_value(r);if(o instanceof MapTreeNode$2){const r=o;if(a=MapTreeNode$2__get_Left(r),(null!=a?(s=a,s instanceof MapTreeNode$2?(l=s,MapTreeNode$2__get_Height(l)):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(_=MapTreeNode$2__get_Right(e),(null!=_?(u=_,u instanceof MapTreeNode$2?(c=u,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=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=n,a=0|r.Compare(o,MapTreeLeaf$2__get_Key(i));if(0===a)return some(MapTreeLeaf$2__get_Value(i));if(i instanceof MapTreeNode$2){const s=i;e=r,t=o,n=a<0?MapTreeNode$2__get_Left(s):MapTreeNode$2__get_Right(s);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,a=t,s=[r,o];if(null!=n){const l=n;if(l instanceof MapTreeNode$2){const _=l,u=MapTreeModule_partitionAux(i,a,MapTreeNode$2__get_Right(_),s[0],s[1]),c=MapTreeModule_partition1(i,a,MapTreeLeaf$2__get_Key(_),MapTreeLeaf$2__get_Value(_),u[0],u[1]);e=i,t=a,n=MapTreeNode$2__get_Left(_),r=c[0],o=c[1];continue e}return MapTreeModule_partition1(i,a,MapTreeLeaf$2__get_Key(l),MapTreeLeaf$2__get_Value(l),s[0],s[1])}return s}}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,a=r;if(null!=n){const s=n;if(s instanceof MapTreeNode$2){const l=s,_=MapTreeModule_filterAux(o,i,MapTreeNode$2__get_Left(l),a),u=MapTreeModule_filter1(o,i,MapTreeLeaf$2__get_Key(l),MapTreeLeaf$2__get_Value(l),_);e=o,t=i,n=MapTreeNode$2__get_Right(l),r=u;continue e}return MapTreeModule_filter1(o,i,MapTreeLeaf$2__get_Key(s),MapTreeLeaf$2__get_Value(s),a)}return a}}function MapTreeModule_filter(e,t,n){return MapTreeModule_filterAux(e,t,n,MapTreeModule_empty())}function MapTreeModule_spliceOutSuccessor(e){if(null!=e){const t=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=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=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=n,a=0|r.Compare(o,MapTreeLeaf$2__get_Key(i));if(i instanceof MapTreeNode$2){const s=i;if(a<0){e=r,t=o,n=MapTreeNode$2__get_Left(s);continue e}if(0===a)return!0;e=r,t=o,n=MapTreeNode$2__get_Right(s);continue e}return 0===a}return!1}}function MapTreeModule_iterOpt(e,t){e:for(;;){const n=e;if(null!=t){const r=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=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=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=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=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=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=t;if(i instanceof MapTreeNode$2){const a=i,s=MapTreeModule_foldBackOpt(r,MapTreeNode$2__get_Right(a),o),l=r(MapTreeLeaf$2__get_Key(a),MapTreeLeaf$2__get_Value(a),s);e=r,t=MapTreeNode$2__get_Left(a),n=l;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=n;if(i instanceof MapTreeNode$2){const a=i;e=r,t=r(MapTreeModule_foldOpt(r,o,MapTreeNode$2__get_Left(a)),MapTreeLeaf$2__get_Key(a),MapTreeLeaf$2__get_Value(a)),n=MapTreeNode$2__get_Right(a);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 a=(r,o,i)=>{e:for(;;){const s=r,l=i;if(null!=o){const _=o;if(_ instanceof MapTreeNode$2){const u=_,c=0|e.Compare(t,MapTreeLeaf$2__get_Key(u)),d=0|e.Compare(MapTreeLeaf$2__get_Key(u),n),p=c<0?a(s,MapTreeNode$2__get_Left(u),l):l,m=c<=0&&d<=0?s(MapTreeLeaf$2__get_Key(u),MapTreeLeaf$2__get_Value(u),p):p;if(d<0){r=s,o=MapTreeNode$2__get_Right(u),i=m;continue e}return m}{const r=0|e.Compare(t,MapTreeLeaf$2__get_Key(_)),o=0|e.Compare(MapTreeLeaf$2__get_Key(_),n);return r<=0&&o<=0?s(MapTreeLeaf$2__get_Key(_),MapTreeLeaf$2__get_Value(_),l):l}}return l}};return 1===e.Compare(t,n)?i:a(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=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 a=i["System.Collections.Generic.IEnumerator`1.get_Current"]();e=r,t=MapTreeModule_add(r,a[0],a[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=Array_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 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}Equals(e){return this===e}GetHashCode(){return physicalHash(this)}}function MapTreeModule_MapIterator$2_$reflection(e,t){return record_type("Map.MapTreeModule.MapIterator`2",[e,t],MapTreeModule_MapIterator$2,()=>[["stack",list_type(option_type(MapTreeLeaf$2_$reflection(e,t)))],["started",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){if(r instanceof MapTreeNode$2){const t=r;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 Operators_InvalidOp("Enumeration has not started. Call MoveNext.")}function MapTreeModule_alreadyFinished(){throw Operators_InvalidOp("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=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(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=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=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 values cannot be mutated.")}"System.Collections.Generic.ICollection`1.Clear"(){throw NotSupportedException_$ctor_Z721C83C5("Map values cannot be mutated.")}"System.Collections.Generic.ICollection`1.Remove2B595"(e){throw NotSupportedException_$ctor_Z721C83C5("Map values 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 NotSupportedException_$ctor_Z721C83C5("Map values cannot be mutated.")}delete(e){throw NotSupportedException_$ctor_Z721C83C5("Map values 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 NotSupportedException_$ctor_Z721C83C5("Map values 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)}function FSharpResult$2_Ok(e){return new FSharpResult$2(0,[e])}function FSharpResult$2_Error$(e){return new FSharpResult$2(1,[e])}class FSharpResult$2 extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Ok","Error"]}}function FSharpResult$2_$reflection(e,t){return union_type("FSharp.Core.FSharpResult`2",[e,t],FSharpResult$2,()=>[[["ResultValue",e]],[["ErrorValue",t]]])}function Result_Map(e,t){return 0===t.tag?FSharpResult$2_Ok(e(t.fields[0])):FSharpResult$2_Error$(t.fields[0])}function Result_MapError(e,t){return 0===t.tag?FSharpResult$2_Ok(t.fields[0]):FSharpResult$2_Error$(e(t.fields[0]))}function Result_Bind(e,t){return 0===t.tag?e(t.fields[0]):FSharpResult$2_Error$(t.fields[0])}function Result_IsOk(e){return 0===e.tag}function Result_IsError(e){return 0!==e.tag}function Result_Contains(e,t){return 0===t.tag&&Result_equals(t.fields[0],e)}function Result_Count(e){return 0===e.tag?1:0}function Result_DefaultValue(e,t){return 0===t.tag?t.fields[0]:e}function Result_DefaultWith(e,t){return 0===t.tag?t.fields[0]:e(t.fields[0])}function Result_Exists(e,t){return 0===t.tag&&e(t.fields[0])}function Result_Fold(e,t,n){return 0===n.tag?e(t,n.fields[0]):t}function Result_FoldBack(e,t,n){return 0===t.tag?e(t.fields[0],n):n}function Result_ForAll(e,t){return 0!==t.tag||e(t.fields[0])}function Result_Iterate(e,t){0===t.tag&&e(t.fields[0])}function Result_ToArray(e){return 0===e.tag?[e.fields[0]]:[]}function Result_ToList(e){return 0===e.tag?Result_singleton(e.fields[0]):Result_empty()}function Result_ToOption(e){return 0===e.tag?Result_some(e.fields[0]):void 0}function Result_ToValueOption(e){return 0===e.tag?Result_some(e.fields[0]):void 0}function error(e){console.error(e)}function output(e){console.log(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 Violation_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","ErrorShadowing","RecoveryDominance","OversizedRecoveryBlock","Suppression","ParseDontValidate"]}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 ErrorShadowing=new ViolationType(12,[]);static RecoveryDominance=new ViolationType(13,[]);static OversizedRecoveryBlock=new ViolationType(14,[]);static Suppression=new ViolationType(15,[]);static ParseDontValidate=new ViolationType(16,[])}function ViolationType_$reflection(){return Violation_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",int32_type],["Weight",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",int32_type],["Column",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 13:return"recovery-dominance";case 14:return"oversized-recovery-block";case 12:return"error-shadowing";case 16:return"parse-dont-validate";case 15:return"suppression";default:return"nesting"}}function violationRuleName(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"PrimitiveObsession";case 9:return"MatchOpportunity";case 10:return"LogicalControlFlow";case 11:return"OpaqueBoolean";case 12:return"ErrorShadowing";case 13:return"RecoveryDominance";case 14:return"OversizedRecoveryBlock";case 16:return"ParseDontValidate";case 15:return"Suppression";default:return"Nesting"}}function violationDisplayName(e){switch(e.tag){case 12:return"Broad Protected Scope";case 13:return"Recovery Dominance";case 14:return"Oversized Recovery Block";default:return violationTypeName(e)}}function violationRuleId(e){switch(e.tag){case 1:return"ESA002";case 2:return"ESA003";case 3:return"ESA004";case 4:return"ESA005";case 5:return"ESA006";case 6:return"ESA007";case 7:return"ESA008";case 8:return"ESA009";case 9:return"ESA010";case 10:return"ESA011";case 11:return"ESA012";case 12:return"ESA013";case 15:return"ESA014";case 16:return"ESA015";case 13:return"ESA016";case 14:return"ESA017";default:return"ESA001"}}function violationHelpUri(e){switch(e.tag){case 1:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/cyclomatic-complexity.md";case 2:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/cognitive-complexity.md";case 3:case 4:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/file-coherence.md";case 5:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/magic-values.md";case 6:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/parameter-explosion.md";case 7:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/inversion-opportunities.md";case 8:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/primitive-obsession.md";case 9:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/match-opportunities.md";case 10:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/logical-operator-control-flow.md";case 11:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/opaque-boolean-literal.md";case 13:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/recovery-dominance.md";case 14:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/oversized-recovery-block.md";case 12:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/error-shadowing.md";case 16:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/parse-dont-validate.md";case 15:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/suppression.md";default:return"https://github.com/cardamomcode/energy-state-analyzer/tree/main/docs/detectors/excessive-nesting.md"}}function severityName(e){switch(e.tag){case 1:return"medium";case 2:return"high";default:return"low"}}const mediumWeight=4,highWeight=9;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+mediumWeight*e.Medium+highWeight*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(ofArray(["# Energy State Report","",(t=r-n|0,toText(printf("**%d file%s scanned** — %d with no findings, %d with findings"))(r)(o)(n)(t)),"","| File | Score | High | Medium | Low |","| --- | --- | --- | --- | --- |"]),List_append(i,ofArray(["",toText(printf("**Total score: %d** (%d high, %d medium, %d low)"))(e.TotalScore)(e.TotalCounts.High)(e.TotalCounts.Medium)(e.TotalCounts.Low)]))))}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 Task_delay(e,t){return new Promise((n,r)=>{if(t?.isCancelled)return void r(new OperationCanceledException);let o;const i=-1===e?void 0:setTimeout(()=>{void 0!==o&&t.removeListener(o),n()},e);null!=t&&(o=t.addListener(()=>{clearTimeout(i),r(new OperationCanceledException)}))})}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 task(){return TaskBuilder_singleton}const external_node_path_namespaceObject=require("node:path");var web_tree_sitter=__webpack_require__(132),TreeSitter_record_type,TreeSitter_int32_type,Language,Parser,TreeSitter_task;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",TreeSitter_int32_type],["Column",TreeSitter_int32_type]])}const initialization=new Lazy(()=>web_tree_sitter.iX.init());function init(){return initialization.Value}function withParsedTree(e,t,n){const r=e.parse(t);try{return n(r.rootNode)}finally{r.delete()}}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 ofArray(e.children)}function nodeNamedChildren(e){return ofArray(e.namedChildren)}function nodeField(e,t){const n=t.childForFieldName(e);return equals(n,defaultOf())?void 0:some(n)}function nodeParent(e){const t=e.parent;return equals(t,defaultOf())?void 0:some(t)}function nodePreviousNamedSibling(e){const t=e.previousNamedSibling;return equals(t,defaultOf())?void 0:some(t)}function parseWith(e,t){const n=TreeSitter_task();return n.Run(n.Delay(()=>n.Bind(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 external_node_fs_namespaceObject=require("node:fs"),external_node_child_process_namespaceObject=require("node:child_process");function attempt(e){try{return new FSharpResult$2(0,[e()])}catch(e){return new FSharpResult$2(1,[Types_toString(e)])}}function readFileSyncSafe(e,t){return attempt(()=>(0,external_node_fs_namespaceObject.readFileSync)(e,t))}function execFileSyncSafe(e,t,n){return attempt(()=>(0,external_node_child_process_namespaceObject.execFileSync)(e,t,n))}function jsonParseResult(e){try{const t=JSON.parse(e);return null===t||"object"!=typeof t||Array.isArray(t)?new FSharpResult$2(1,["Expected a JSON object"]):new FSharpResult$2(0,[t])}catch(e){return new FSharpResult$2(1,[Types_toString(e)])}}var Config_union_type,Config_string_type,Config_record_type,Config_bool_type,Config_int32_type,float64_type,Config_list_type,Config_option_type;class ConfigError extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["ConfigNotFound","ConfigReadFailed","ConfigInvalid"]}}function ConfigError_$reflection(){return Config_union_type("Energy.Core.Config.ConfigError",[],ConfigError,()=>[[["path",Config_string_type]],[["path",Config_string_type],["message",Config_string_type]],[["path",Config_string_type],["message",Config_string_type]]])}function configErrorMessage(e){switch(e.tag){case 1:return"Could not read configuration "+e.fields[0]+": "+e.fields[1];case 2:return"Invalid configuration "+e.fields[0]+": "+e.fields[1];default:return"Configuration file not found: "+e.fields[0]}}class NestingThresholds extends Record{constructor(e,t,n){super(),this.Enabled=e,this.MediumThreshold=0|t,this.HighThreshold=0|n}}function NestingThresholds_$reflection(){return Config_record_type("Energy.Core.Config.NestingThresholds",[],NestingThresholds,()=>[["Enabled",Config_bool_type],["MediumThreshold",Config_int32_type],["HighThreshold",Config_int32_type]])}class CyclomaticThresholds extends Record{constructor(e,t,n){super(),this.Enabled=e,this.MediumThreshold=0|t,this.HighThreshold=0|n}}function CyclomaticThresholds_$reflection(){return Config_record_type("Energy.Core.Config.CyclomaticThresholds",[],CyclomaticThresholds,()=>[["Enabled",Config_bool_type],["MediumThreshold",Config_int32_type],["HighThreshold",Config_int32_type]])}class CognitiveThresholds extends Record{constructor(e,t,n){super(),this.Enabled=e,this.MediumThreshold=0|t,this.HighThreshold=0|n}}function CognitiveThresholds_$reflection(){return Config_record_type("Energy.Core.Config.CognitiveThresholds",[],CognitiveThresholds,()=>[["Enabled",Config_bool_type],["MediumThreshold",Config_int32_type],["HighThreshold",Config_int32_type]])}class CoherenceThresholds extends Record{constructor(e,t,n,r,o,i,a,s,l,_,u,c,d,p,m,f){super(),this.Enabled=e,this.LargeFunctionLines=0|t,this.MaxLargeFunctions=0|n,this.SingleDomainNameShare=r,this.MaxTypeDiversityRatio=o,this.MinTypedCoverage=i,this.SiblingOpenThreshold=0|a,this.ImportBreadthThreshold=0|s,this.HighImportBreadthThreshold=0|l,this.MemberImportFanOutThreshold=0|_,this.UtilsFileFunctionCount=0|u,this.GenericFunctionCount=0|c,this.HighFunctionCount=0|d,this.MethodCountMedium=0|p,this.MethodCountHigh=0|m,this.LargeFunctionSeverityMultiplier=f}}function CoherenceThresholds_$reflection(){return Config_record_type("Energy.Core.Config.CoherenceThresholds",[],CoherenceThresholds,()=>[["Enabled",Config_bool_type],["LargeFunctionLines",Config_int32_type],["MaxLargeFunctions",Config_int32_type],["SingleDomainNameShare",float64_type],["MaxTypeDiversityRatio",float64_type],["MinTypedCoverage",float64_type],["SiblingOpenThreshold",Config_int32_type],["ImportBreadthThreshold",Config_int32_type],["HighImportBreadthThreshold",Config_int32_type],["MemberImportFanOutThreshold",Config_int32_type],["UtilsFileFunctionCount",Config_int32_type],["GenericFunctionCount",Config_int32_type],["HighFunctionCount",Config_int32_type],["MethodCountMedium",Config_int32_type],["MethodCountHigh",Config_int32_type],["LargeFunctionSeverityMultiplier",float64_type]])}class MatchOpportunityThresholds extends Record{constructor(e,t){super(),this.Enabled=e,this.MinBranches=0|t}}function MatchOpportunityThresholds_$reflection(){return Config_record_type("Energy.Core.Config.MatchOpportunityThresholds",[],MatchOpportunityThresholds,()=>[["Enabled",Config_bool_type],["MinBranches",Config_int32_type]])}class ErrorShadowingModeThresholds extends Record{constructor(e,t,n){super(),this.Threshold=e,this.HighThreshold=t,this.MinItems=0|n}}function ErrorShadowingModeThresholds_$reflection(){return Config_record_type("Energy.Core.Config.ErrorShadowingModeThresholds",[],ErrorShadowingModeThresholds,()=>[["Threshold",float64_type],["HighThreshold",float64_type],["MinItems",Config_int32_type]])}class RecoveryBlockThresholds extends Record{constructor(e){super(),this.MaxLines=0|e}}function RecoveryBlockThresholds_$reflection(){return Config_record_type("Energy.Core.Config.RecoveryBlockThresholds",[],RecoveryBlockThresholds,()=>[["MaxLines",Config_int32_type]])}class ErrorShadowingThresholds extends Record{constructor(e,t,n,r,o,i){super(),this.Enabled=e,this.ProtectedScope=t,this.Recovery=n,this.RecoveryDominanceEnabled=r,this.OversizedRecoveryBlockEnabled=o,this.RecoveryBlock=i}}function ErrorShadowingThresholds_$reflection(){return Config_record_type("Energy.Core.Config.ErrorShadowingThresholds",[],ErrorShadowingThresholds,()=>[["Enabled",Config_bool_type],["ProtectedScope",ErrorShadowingModeThresholds_$reflection()],["Recovery",ErrorShadowingModeThresholds_$reflection()],["RecoveryDominanceEnabled",Config_bool_type],["OversizedRecoveryBlockEnabled",Config_bool_type],["RecoveryBlock",RecoveryBlockThresholds_$reflection()]])}class ParameterCountThresholds extends Record{constructor(e,t,n){super(),this.Enabled=e,this.MediumThreshold=0|t,this.HighThreshold=0|n}}function ParameterCountThresholds_$reflection(){return Config_record_type("Energy.Core.Config.ParameterCountThresholds",[],ParameterCountThresholds,()=>[["Enabled",Config_bool_type],["MediumThreshold",Config_int32_type],["HighThreshold",Config_int32_type]])}class PrimitiveObsessionThresholds extends Record{constructor(e){super(),this.Enabled=e}}function PrimitiveObsessionThresholds_$reflection(){return Config_record_type("Energy.Core.Config.PrimitiveObsessionThresholds",[],PrimitiveObsessionThresholds,()=>[["Enabled",Config_bool_type]])}class OpaqueBooleanThresholds extends Record{constructor(e,t){super(),this.Enabled=e,this.IncludeTestFiles=t}}function OpaqueBooleanThresholds_$reflection(){return Config_record_type("Energy.Core.Config.OpaqueBooleanThresholds",[],OpaqueBooleanThresholds,()=>[["Enabled",Config_bool_type],["IncludeTestFiles",Config_bool_type]])}class ParseDontValidateThresholds extends Record{constructor(e){super(),this.Enabled=e}}function ParseDontValidateThresholds_$reflection(){return Config_record_type("Energy.Core.Config.ParseDontValidateThresholds",[],ParseDontValidateThresholds,()=>[["Enabled",Config_bool_type]])}class LogicalControlFlowThresholds extends Record{constructor(e){super(),this.Enabled=e}}function LogicalControlFlowThresholds_$reflection(){return Config_record_type("Energy.Core.Config.LogicalControlFlowThresholds",[],LogicalControlFlowThresholds,()=>[["Enabled",Config_bool_type]])}class InversionThresholds extends Record{constructor(e){super(),this.Enabled=e}}function InversionThresholds_$reflection(){return Config_record_type("Energy.Core.Config.InversionThresholds",[],InversionThresholds,()=>[["Enabled",Config_bool_type]])}class MagicNumberOptions extends Record{constructor(e,t,n){super(),this.Enabled=e,this.Allowlist=t,this.IncludeTestFiles=n}}function MagicNumberOptions_$reflection(){return Config_record_type("Energy.Core.Config.MagicNumberOptions",[],MagicNumberOptions,()=>[["Enabled",Config_bool_type],["Allowlist",Config_list_type(float64_type)],["IncludeTestFiles",Config_bool_type]])}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 Config_record_type("Energy.Core.Config.MagicStringOptions",[],MagicStringOptions,()=>[["Enabled",Config_bool_type],["MinDuplicates",Config_int32_type],["Allowlist",Config_list_type(Config_string_type)],["IncludeTestFiles",Config_bool_type]])}class AnalyzeOptions extends Record{constructor(e,t,n,r,o,i,a,s,l,_,u,c,d,p){super(),this.Nesting=e,this.Cyclomatic=t,this.Cognitive=n,this.Coherence=r,this.MatchOpportunity=o,this.ParameterCount=i,this.MagicNumber=a,this.MagicString=s,this.PrimitiveObsession=l,this.OpaqueBoolean=_,this.ParseDontValidate=u,this.LogicalControlFlow=c,this.Inversion=d,this.ErrorShadowing=p}}function AnalyzeOptions_$reflection(){return Config_record_type("Energy.Core.Config.AnalyzeOptions",[],AnalyzeOptions,()=>[["Nesting",NestingThresholds_$reflection()],["Cyclomatic",CyclomaticThresholds_$reflection()],["Cognitive",CognitiveThresholds_$reflection()],["Coherence",CoherenceThresholds_$reflection()],["MatchOpportunity",MatchOpportunityThresholds_$reflection()],["ParameterCount",ParameterCountThresholds_$reflection()],["MagicNumber",MagicNumberOptions_$reflection()],["MagicString",MagicStringOptions_$reflection()],["PrimitiveObsession",PrimitiveObsessionThresholds_$reflection()],["OpaqueBoolean",OpaqueBooleanThresholds_$reflection()],["ParseDontValidate",ParseDontValidateThresholds_$reflection()],["LogicalControlFlow",LogicalControlFlowThresholds_$reflection()],["Inversion",InversionThresholds_$reflection()],["ErrorShadowing",ErrorShadowingThresholds_$reflection()]])}const defaultAnalyzeOptions=new AnalyzeOptions(new NestingThresholds(!0,3,5),new CyclomaticThresholds(!0,10,15),new CognitiveThresholds(!0,15,25),new CoherenceThresholds(!0,20,5,.7,.4,.5,7,10,15,10,8,12,15,15,25,1.5),new MatchOpportunityThresholds(!0,3),new ParameterCountThresholds(!0,5,8),new MagicNumberOptions(!0,ofArray([0,1,-1,2]),!1),new MagicStringOptions(!0,2,ofArray(["","utf-8","__main__"]),!1),new PrimitiveObsessionThresholds(!0),new OpaqueBooleanThresholds(!0,!1),new ParseDontValidateThresholds(!0),new LogicalControlFlowThresholds(!0),new InversionThresholds(!0),new ErrorShadowingThresholds(!0,new ErrorShadowingModeThresholds(.5,.7,8),new ErrorShadowingModeThresholds(.5,.7,5),!0,!0,new RecoveryBlockThresholds(20))),defaultNestingThresholds=defaultAnalyzeOptions.Nesting,defaultCyclomaticThresholds=defaultAnalyzeOptions.Cyclomatic,defaultCognitiveThresholds=defaultAnalyzeOptions.Cognitive,defaultCoherenceThresholds=defaultAnalyzeOptions.Coherence,defaultMatchOpportunityThresholds=defaultAnalyzeOptions.MatchOpportunity,defaultParameterCountThresholds=defaultAnalyzeOptions.ParameterCount,defaultPrimitiveObsessionThresholds=defaultAnalyzeOptions.PrimitiveObsession,defaultOpaqueBooleanThresholds=defaultAnalyzeOptions.OpaqueBoolean,defaultLogicalControlFlowThresholds=defaultAnalyzeOptions.LogicalControlFlow,defaultInversionThresholds=defaultAnalyzeOptions.Inversion,defaultErrorShadowingThresholds=defaultAnalyzeOptions.ErrorShadowing,defaultMagicNumberOptions=defaultAnalyzeOptions.MagicNumber,defaultMagicStringOptions=defaultAnalyzeOptions.MagicString;class EnergyColors extends Record{constructor(e,t,n,r){super(),this.HighEnergy=e,this.MediumEnergy=t,this.LowEnergy=n,this.BackgroundOpacity=r}}function EnergyColors_$reflection(){return Config_record_type("Energy.Core.Config.EnergyColors",[],EnergyColors,()=>[["HighEnergy",Config_string_type],["MediumEnergy",Config_string_type],["LowEnergy",Config_string_type],["BackgroundOpacity",float64_type]])}const defaultEnergyColors=new EnergyColors("#fb8500","#ffb703","#99dd99",.1),configFileName=".esaconfig.json";class FileNesting extends Record{constructor(e,t){super(),this.MediumThreshold=e,this.HighThreshold=t}}function FileNesting_$reflection(){return Config_record_type("Energy.Core.Config.FileNesting",[],FileNesting,()=>[["MediumThreshold",Config_option_type(Config_int32_type)],["HighThreshold",Config_option_type(Config_int32_type)]])}class FileCyclomatic extends Record{constructor(e,t){super(),this.MediumThreshold=e,this.HighThreshold=t}}function FileCyclomatic_$reflection(){return Config_record_type("Energy.Core.Config.FileCyclomatic",[],FileCyclomatic,()=>[["MediumThreshold",Config_option_type(Config_int32_type)],["HighThreshold",Config_option_type(Config_int32_type)]])}class FileCognitive extends Record{constructor(e,t){super(),this.MediumThreshold=e,this.HighThreshold=t}}function FileCognitive_$reflection(){return Config_record_type("Energy.Core.Config.FileCognitive",[],FileCognitive,()=>[["MediumThreshold",Config_option_type(Config_int32_type)],["HighThreshold",Config_option_type(Config_int32_type)]])}class FileCoherence extends Record{constructor(e,t,n,r,o,i,a,s,l,_,u,c,d,p,m){super(),this.LargeFunctionLines=e,this.MaxLargeFunctions=t,this.SingleDomainNameShare=n,this.MaxTypeDiversityRatio=r,this.MinTypedCoverage=o,this.SiblingOpenThreshold=i,this.ImportBreadthThreshold=a,this.HighImportBreadthThreshold=s,this.MemberImportFanOutThreshold=l,this.UtilsFileFunctionCount=_,this.GenericFunctionCount=u,this.HighFunctionCount=c,this.MethodCountMedium=d,this.MethodCountHigh=p,this.LargeFunctionSeverityMultiplier=m}}function FileCoherence_$reflection(){return Config_record_type("Energy.Core.Config.FileCoherence",[],FileCoherence,()=>[["LargeFunctionLines",Config_option_type(Config_int32_type)],["MaxLargeFunctions",Config_option_type(Config_int32_type)],["SingleDomainNameShare",Config_option_type(float64_type)],["MaxTypeDiversityRatio",Config_option_type(float64_type)],["MinTypedCoverage",Config_option_type(float64_type)],["SiblingOpenThreshold",Config_option_type(Config_int32_type)],["ImportBreadthThreshold",Config_option_type(Config_int32_type)],["HighImportBreadthThreshold",Config_option_type(Config_int32_type)],["MemberImportFanOutThreshold",Config_option_type(Config_int32_type)],["UtilsFileFunctionCount",Config_option_type(Config_int32_type)],["GenericFunctionCount",Config_option_type(Config_int32_type)],["HighFunctionCount",Config_option_type(Config_int32_type)],["MethodCountMedium",Config_option_type(Config_int32_type)],["MethodCountHigh",Config_option_type(Config_int32_type)],["LargeFunctionSeverityMultiplier",Config_option_type(float64_type)]])}class FileMatchOpportunity extends Record{constructor(e){super(),this.MinBranches=e}}function FileMatchOpportunity_$reflection(){return Config_record_type("Energy.Core.Config.FileMatchOpportunity",[],FileMatchOpportunity,()=>[["MinBranches",Config_option_type(Config_int32_type)]])}class FileErrorShadowingMode extends Record{constructor(e,t,n){super(),this.Threshold=e,this.HighThreshold=t,this.MinItems=n}}function FileErrorShadowingMode_$reflection(){return Config_record_type("Energy.Core.Config.FileErrorShadowingMode",[],FileErrorShadowingMode,()=>[["Threshold",Config_option_type(float64_type)],["HighThreshold",Config_option_type(float64_type)],["MinItems",Config_option_type(Config_int32_type)]])}class FileErrorShadowing extends Record{constructor(e,t,n){super(),this.ProtectedScope=e,this.Recovery=t,this.RecoveryBlockMaxLines=n}}function FileErrorShadowing_$reflection(){return Config_record_type("Energy.Core.Config.FileErrorShadowing",[],FileErrorShadowing,()=>[["ProtectedScope",FileErrorShadowingMode_$reflection()],["Recovery",FileErrorShadowingMode_$reflection()],["RecoveryBlockMaxLines",Config_option_type(Config_int32_type)]])}class FileParameterCount extends Record{constructor(e,t){super(),this.MediumThreshold=e,this.HighThreshold=t}}function FileParameterCount_$reflection(){return Config_record_type("Energy.Core.Config.FileParameterCount",[],FileParameterCount,()=>[["MediumThreshold",Config_option_type(Config_int32_type)],["HighThreshold",Config_option_type(Config_int32_type)]])}class FileMagicNumber extends Record{constructor(e){super(),this.Allowlist=e}}function FileMagicNumber_$reflection(){return Config_record_type("Energy.Core.Config.FileMagicNumber",[],FileMagicNumber,()=>[["Allowlist",Config_option_type(Config_list_type(float64_type))]])}class FileMagicString extends Record{constructor(e,t){super(),this.MinDuplicates=e,this.Allowlist=t}}function FileMagicString_$reflection(){return Config_record_type("Energy.Core.Config.FileMagicString",[],FileMagicString,()=>[["MinDuplicates",Config_option_type(Config_int32_type)],["Allowlist",Config_option_type(Config_list_type(Config_string_type))]])}class FileConfig extends Record{constructor(e,t,n,r,o,i,a,s,l){super(),this.Nesting=e,this.Cyclomatic=t,this.Cognitive=n,this.Coherence=r,this.MatchOpportunity=o,this.ErrorShadowing=i,this.ParameterCount=a,this.MagicNumber=s,this.MagicString=l}}function FileConfig_$reflection(){return Config_record_type("Energy.Core.Config.FileConfig",[],FileConfig,()=>[["Nesting",FileNesting_$reflection()],["Cyclomatic",FileCyclomatic_$reflection()],["Cognitive",FileCognitive_$reflection()],["Coherence",FileCoherence_$reflection()],["MatchOpportunity",FileMatchOpportunity_$reflection()],["ErrorShadowing",FileErrorShadowing_$reflection()],["ParameterCount",FileParameterCount_$reflection()],["MagicNumber",FileMagicNumber_$reflection()],["MagicString",FileMagicString_$reflection()]])}function field(e,t){const n=e[t];return null==n?void 0:some(n)}function readNumber(e,t){let n;return n=null!=e?field(Option_value(e),t):void 0,null!=n?Option_value(n):void 0}function readList(e,t){let n;return n=null!=e?field(Option_value(e),t):void 0,null!=n?ofArray(Option_value(n)):void 0}function findConfigFile(e){return(e=>{e:for(;;){const t=e,n=(0,external_node_path_namespaceObject.join)(t,configFileName);if((0,external_node_fs_namespaceObject.existsSync)(n))return n;{const n=(0,external_node_path_namespaceObject.dirname)(t);if(null==n||equals(n,t))return;e=n;continue e}}})(e)}function readConfigJson(e){const t=e,n=t;return(0,external_node_fs_namespaceObject.existsSync)(t)?Result_Bind(e=>Result_MapError(e=>new ConfigError(2,[n,e]),jsonParseResult(e)),Result_MapError(e=>new ConfigError(1,[n,e]),readFileSyncSafe(t,"utf8"))):new FSharpResult$2(1,[new ConfigError(0,[n])])}function parseFileConfig(e){let t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g,S,$,C,L,T,E,w,x;const v=field(e,"nesting"),A=field(e,"cyclomaticComplexity"),M=field(e,"cognitiveComplexity"),F=field(e,"coherence"),b=field(e,"matchOpportunity"),I=field(e,"errorShadowing");let N,O,R;N=null!=I?field(Option_value(I),"protectedScope"):void 0,O=null!=I?field(Option_value(I),"recovery"):void 0,R=null!=I?field(Option_value(I),"recoveryBlock"):void 0;const q=field(e,"parameterCount"),P=field(e,"magicNumber"),k=field(e,"magicString");return new FileConfig(new FileNesting((t=readNumber(v,"mediumThreshold"),null!=t?~~t:void 0),(n=readNumber(v,"highThreshold"),null!=n?~~n:void 0)),new FileCyclomatic((r=readNumber(A,"mediumThreshold"),null!=r?~~r:void 0),(o=readNumber(A,"highThreshold"),null!=o?~~o:void 0)),new FileCognitive((i=readNumber(M,"mediumThreshold"),null!=i?~~i:void 0),(a=readNumber(M,"highThreshold"),null!=a?~~a:void 0)),new FileCoherence((s=readNumber(F,"largeFunctionLines"),null!=s?~~s:void 0),(l=readNumber(F,"maxLargeFunctions"),null!=l?~~l:void 0),readNumber(F,"singleDomainNameShare"),readNumber(F,"maxTypeDiversityRatio"),readNumber(F,"minTypedCoverage"),(_=readNumber(F,"siblingOpenThreshold"),null!=_?~~_:void 0),(u=readNumber(F,"importBreadthThreshold"),null!=u?~~u:void 0),(c=readNumber(F,"highImportBreadthThreshold"),null!=c?~~c:void 0),(d=readNumber(F,"memberImportFanOutThreshold"),null!=d?~~d:void 0),(p=readNumber(F,"utilsFileFunctionCount"),null!=p?~~p:void 0),(m=readNumber(F,"genericFunctionCount"),null!=m?~~m:void 0),(f=readNumber(F,"highFunctionCount"),null!=f?~~f:void 0),(y=readNumber(F,"godClassMethodCountMedium"),null!=y?~~y:void 0),(h=readNumber(F,"godClassMethodCountHigh"),null!=h?~~h:void 0),readNumber(F,"largeFunctionSeverityMultiplier")),new FileMatchOpportunity((g=readNumber(b,"minBranches"),null!=g?~~g:void 0)),new FileErrorShadowing(new FileErrorShadowingMode(readNumber(N,"threshold"),readNumber(N,"highThreshold"),(S=readNumber(N,"minItems"),null!=S?~~S:void 0)),new FileErrorShadowingMode(readNumber(O,"threshold"),readNumber(O,"highThreshold"),($=readNumber(O,"minItems"),null!=$?~~$:void 0)),(C=readNumber(R,"maxLines"),null!=C?~~C:void 0)),new FileParameterCount((L=readNumber(q,"mediumThreshold"),null!=L?~~L:void 0),(T=readNumber(q,"highThreshold"),null!=T?~~T:void 0)),new FileMagicNumber((E=readList(P,"allowlist"),null!=E?List_map(e=>e,E):void 0)),new FileMagicString((w=readNumber(k,"minDuplicates"),null!=w?~~w:void 0),(x=readList(k,"allowlist"),null!=x?List_map(e=>e,x):void 0)))}function mergeOptions(e,t){let n,r;const o=e.MagicNumber.Allowlist,i=e.MagicString.Allowlist,a=new NestingThresholds(e.Nesting.Enabled,defaultArg(t.Nesting.MediumThreshold,e.Nesting.MediumThreshold),defaultArg(t.Nesting.HighThreshold,e.Nesting.HighThreshold)),s=new CyclomaticThresholds(e.Cyclomatic.Enabled,defaultArg(t.Cyclomatic.MediumThreshold,e.Cyclomatic.MediumThreshold),defaultArg(t.Cyclomatic.HighThreshold,e.Cyclomatic.HighThreshold)),l=new CognitiveThresholds(e.Cognitive.Enabled,defaultArg(t.Cognitive.MediumThreshold,e.Cognitive.MediumThreshold),defaultArg(t.Cognitive.HighThreshold,e.Cognitive.HighThreshold)),_=new CoherenceThresholds(e.Coherence.Enabled,defaultArg(t.Coherence.LargeFunctionLines,e.Coherence.LargeFunctionLines),defaultArg(t.Coherence.MaxLargeFunctions,e.Coherence.MaxLargeFunctions),defaultArg(t.Coherence.SingleDomainNameShare,e.Coherence.SingleDomainNameShare),defaultArg(t.Coherence.MaxTypeDiversityRatio,e.Coherence.MaxTypeDiversityRatio),defaultArg(t.Coherence.MinTypedCoverage,e.Coherence.MinTypedCoverage),defaultArg(t.Coherence.SiblingOpenThreshold,e.Coherence.SiblingOpenThreshold),defaultArg(t.Coherence.ImportBreadthThreshold,e.Coherence.ImportBreadthThreshold),defaultArg(t.Coherence.HighImportBreadthThreshold,e.Coherence.HighImportBreadthThreshold),defaultArg(t.Coherence.MemberImportFanOutThreshold,e.Coherence.MemberImportFanOutThreshold),defaultArg(t.Coherence.UtilsFileFunctionCount,e.Coherence.UtilsFileFunctionCount),defaultArg(t.Coherence.GenericFunctionCount,e.Coherence.GenericFunctionCount),defaultArg(t.Coherence.HighFunctionCount,e.Coherence.HighFunctionCount),defaultArg(t.Coherence.MethodCountMedium,e.Coherence.MethodCountMedium),defaultArg(t.Coherence.MethodCountHigh,e.Coherence.MethodCountHigh),defaultArg(t.Coherence.LargeFunctionSeverityMultiplier,e.Coherence.LargeFunctionSeverityMultiplier)),u=new MatchOpportunityThresholds(e.MatchOpportunity.Enabled,defaultArg(t.MatchOpportunity.MinBranches,e.MatchOpportunity.MinBranches));let c;const d=e.ErrorShadowing;return c=new ErrorShadowingThresholds(d.Enabled,new ErrorShadowingModeThresholds(defaultArg(t.ErrorShadowing.ProtectedScope.Threshold,e.ErrorShadowing.ProtectedScope.Threshold),defaultArg(t.ErrorShadowing.ProtectedScope.HighThreshold,e.ErrorShadowing.ProtectedScope.HighThreshold),defaultArg(t.ErrorShadowing.ProtectedScope.MinItems,e.ErrorShadowing.ProtectedScope.MinItems)),new ErrorShadowingModeThresholds(defaultArg(t.ErrorShadowing.Recovery.Threshold,e.ErrorShadowing.Recovery.Threshold),defaultArg(t.ErrorShadowing.Recovery.HighThreshold,e.ErrorShadowing.Recovery.HighThreshold),defaultArg(t.ErrorShadowing.Recovery.MinItems,e.ErrorShadowing.Recovery.MinItems)),d.RecoveryDominanceEnabled,d.OversizedRecoveryBlockEnabled,new RecoveryBlockThresholds(defaultArg(t.ErrorShadowing.RecoveryBlockMaxLines,e.ErrorShadowing.RecoveryBlock.MaxLines))),new AnalyzeOptions(a,s,l,_,u,new ParameterCountThresholds(e.ParameterCount.Enabled,defaultArg(t.ParameterCount.MediumThreshold,e.ParameterCount.MediumThreshold),defaultArg(t.ParameterCount.HighThreshold,e.ParameterCount.HighThreshold)),(n=e.MagicNumber,new MagicNumberOptions(n.Enabled,List_append(o,List_filter(e=>!List_contains(e,o,{Equals:(e,t)=>e===t,GetHashCode:e=>0|numberHash(e)}),defaultArg(t.MagicNumber.Allowlist,List_empty()))),n.IncludeTestFiles)),(r=e.MagicString,new MagicStringOptions(r.Enabled,defaultArg(t.MagicString.MinDuplicates,e.MagicString.MinDuplicates),List_append(i,List_filter(e=>!List_contains(e,i,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),defaultArg(t.MagicString.Allowlist,List_empty()))),r.IncludeTestFiles)),e.PrimitiveObsession,e.OpaqueBoolean,e.ParseDontValidate,e.LogicalControlFlow,e.Inversion,c)}function optionsFromConfig(e,t){try{return new FSharpResult$2(0,[mergeOptions(defaultAnalyzeOptions,parseFileConfig(t))])}catch(t){return new FSharpResult$2(1,[new ConfigError(2,[e,Types_toString(t)])])}}function loadAnalyzeOptions(e){const t=findConfigFile(e);if(null!=t){const e=t;return Result_Bind(t=>optionsFromConfig(e,t),readConfigJson(e))}return new FSharpResult$2(0,[defaultAnalyzeOptions])}function loadAnalyzeOptionsFromConfigPath(e){return Result_Bind(t=>optionsFromConfig(e,t),readConfigJson(e))}var LanguageAdapter_union_type,LanguageAdapter_list_type,obj_type,LanguageAdapter_record_type,LanguageAdapter_string_type,LanguageAdapter_option_type,lambda_type,LanguageAdapter_bool_type,LanguageAdapter_int32_type,LanguageAdapter_class_type,tuple_type,Set_class_type,Set_record_type,Set_list_type,Set_option_type,Set_bool_type,Set_some,Set_value_2,Set_Exception,Set_Operators_InvalidArg,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,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 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 CognitiveIncrement extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Structural","Hybrid","Fundamental"]}static Structural=new CognitiveIncrement(0,[]);static Hybrid=new CognitiveIncrement(1,[]);static Fundamental=new CognitiveIncrement(2,[])}function CognitiveIncrement_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.CognitiveIncrement",[],CognitiveIncrement,()=>[[],[],[]])}class CognitiveStructure extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Flow","Closure","BooleanGroup"]}static Closure=new CognitiveStructure(1,[])}function CognitiveStructure_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.CognitiveStructure",[],CognitiveStructure,()=>[[["Item1",CognitiveIncrement_$reflection()],["Item2",LanguageAdapter_list_type(obj_type)]],[],[["Item",obj_type]]])}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 RecoveryBody extends Record{constructor(e,t){super(),this.Anchor=e,this.Items=t}}function RecoveryBody_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.RecoveryBody",[],RecoveryBody,()=>[["Anchor",obj_type],["Items",LanguageAdapter_list_type(obj_type)]])}class ErrorHandlingRegion extends Record{constructor(e,t,n,r,o){super(),this.Anchor=e,this.ProtectedBody=t,this.ProtectedItems=n,this.RecoveryItems=r,this.RecoveryBodies=o}}function ErrorHandlingRegion_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.ErrorHandlingRegion",[],ErrorHandlingRegion,()=>[["Anchor",obj_type],["ProtectedBody",LanguageAdapter_list_type(obj_type)],["ProtectedItems",LanguageAdapter_list_type(obj_type)],["RecoveryItems",LanguageAdapter_list_type(obj_type)],["RecoveryBodies",LanguageAdapter_list_type(RecoveryBody_$reflection())]])}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 BooleanLiteralPolarity extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["LiteralTrue","LiteralFalse"]}static LiteralTrue=new BooleanLiteralPolarity(0,[]);static LiteralFalse=new BooleanLiteralPolarity(1,[])}function BooleanLiteralPolarity_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.BooleanLiteralPolarity",[],BooleanLiteralPolarity,()=>[[],[]])}class ValidationSuccess extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["UnchangedInput","NoValue","BareBoolean"]}static NoValue=new ValidationSuccess(1,[])}function ValidationSuccess_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.ValidationSuccess",[],ValidationSuccess,()=>[[["Item",obj_type]],[],[["Item",obj_type]]])}class IdentityReturnPolicy extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["RequireParameterAnnotation","AcceptUntypedParameter"]}static RequireParameterAnnotation=new IdentityReturnPolicy(0,[]);static AcceptUntypedParameter=new IdentityReturnPolicy(1,[])}function IdentityReturnPolicy_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.IdentityReturnPolicy",[],IdentityReturnPolicy,()=>[[],[]])}class GuardedValidation extends Record{constructor(e,t,n,r){super(),this.Anchor=e,this.Condition=t,this.Success=n,this.IdentityReturnPolicy=r}}function GuardedValidation_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.GuardedValidation",[],GuardedValidation,()=>[["Anchor",obj_type],["Condition",obj_type],["Success",ValidationSuccess_$reflection()],["IdentityReturnPolicy",IdentityReturnPolicy_$reflection()]])}class FunctionHead extends Record{constructor(e,t){super(),this.ParametersRoot=e,this.Body=t}}function FunctionHead_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.FunctionHead",[],FunctionHead,()=>[["ParametersRoot",obj_type],["Body",obj_type]])}class AnonymousBindingScope extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["ModuleBinding","ClassMemberBinding"]}static ModuleBinding=new AnonymousBindingScope(0,[]);static ClassMemberBinding=new AnonymousBindingScope(1,[])}function AnonymousBindingScope_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.AnonymousBindingScope",[],AnonymousBindingScope,()=>[[],[]])}class CallableRole extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["NamedDefinition","BoundAnonymous","InlineAnonymous"]}static NamedDefinition=new CallableRole(0,[]);static InlineAnonymous=new CallableRole(2,[])}function CallableRole_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.CallableRole",[],CallableRole,()=>[[],[["Item",AnonymousBindingScope_$reflection()]],[]])}class CallableView extends Record{constructor(e,t,n,r,o,i){super(),this.Anchor=e,this.Body=t,this.ReturnTypeRoot=n,this.Role=r,this.BindingName=o,this.Parameters=i}}function CallableView_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.CallableView",[],CallableView,()=>[["Anchor",obj_type],["Body",obj_type],["ReturnTypeRoot",obj_type],["Role",CallableRole_$reflection()],["BindingName",LanguageAdapter_option_type(LanguageAdapter_string_type)],["Parameters",LanguageAdapter_list_type(obj_type)]])}class ImportKind extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Module","Members","Wildcard","ScopeOpen","Header"]}static Module=new ImportKind(0,[]);static Members=new ImportKind(1,[]);static Wildcard=new ImportKind(2,[]);static ScopeOpen=new ImportKind(3,[]);static Header=new ImportKind(4,[])}function ImportKind_$reflection(){return LanguageAdapter_union_type("Energy.Core.LanguageAdapter.ImportKind",[],ImportKind,()=>[[],[],[],[],[]])}class ImportBinding extends Record{constructor(e,t){super(),this.ImportedName=e,this.LocalName=t}}function ImportBinding_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.ImportBinding",[],ImportBinding,()=>[["ImportedName",LanguageAdapter_string_type],["LocalName",LanguageAdapter_string_type]])}class ImportInfo extends Record{constructor(e,t,n){super(),this.Kind=e,this.Source=t,this.Bindings=n}}function ImportInfo_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.ImportInfo",[],ImportInfo,()=>[["Kind",ImportKind_$reflection()],["Source",LanguageAdapter_string_type],["Bindings",LanguageAdapter_list_type(ImportBinding_$reflection())]])}class NodeTypes extends Record{constructor(e,t,n,r,o,i,a,s,l,_,u,c,d,p,m,f,y,h,g){super(),this.Block=e,this.Parameters=t,this.IfStatement=n,this.ElseClause=r,this.ForStatement=o,this.WhileStatement=i,this.ConditionalExpression=a,this.Lambda=s,this.ImportStatement=l,this.ImportFromStatement=_,this.AdditionalImportTypes=u,this.ExpressionStatement=c,this.Assignment=d,this.Module=p,this.ExportStatement=m,this.Comment=f,this.IntegerLiteral=y,this.FloatLiteral=h,this.StringLiteral=g}}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)],["AdditionalImportTypes",LanguageAdapter_list_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,a,s,l,_,u,c,d,p,m,f,y,h,g,S,$,C,L,T,E,w,x,v,A,M,F,b,I,N,O,R,q,P,k,D,B,H){super(),this.Id=e,this.GrammarPath=t,this.NodeTypes=n,this.IsFunctionDefinition=r,this.GetFunctionHeads=o,this.GetCallableViews=i,this.ParameterChildTypes=a,this.DecisionNodeTypes=s,this.CyclomaticBranchCount=l,this.GetCognitiveStructure=_,this.NestingControlTypes=u,this.GetBooleanOperator=c,this.IsTryElseClause=d,this.VariableReferenceNodeTypes=p,this.ExtractTypedParameter=m,this.ExtractReturnType=f,this.GenericBrackets=y,this.PrimitiveTypeNames=h,this.GetErrorHandlingRegion=g,this.GetFunctionLogicalItems=S,this.KeywordOnlyBoundaryTypes=$,this.DistinctTypeAdvice=C,this.GetEqualityComparisons=L,this.GetMatchStringCases=T,this.GetMembershipComparisons=E,this.IsMatchCaseLiteral=w,this.GetElseIfBranches=x,this.SubscriptNodeTypes=v,this.IsFormattedOrInterpolatedString=A,this.IsDefaultParameterValue=M,this.IsStructuralNumber=F,this.NumericLiteralText=b,this.IsBooleanLiteral=I,this.IsPositionalCallArgument=N,this.IsExplicitConstant=O,this.ImportInfo=R,this.IsReExport=q,this.IsClassDefinition=P,this.IsStaticMethod=k,this.GetClassName=D,this.GetBaseClassNames=B,this.GetGuardedValidation=H}}function LanguageAdapter_$reflection(){return LanguageAdapter_record_type("Energy.Core.LanguageAdapter.LanguageAdapter",[],LanguageAdapter,()=>[["Id",LanguageAdapter_string_type],["GrammarPath",LanguageAdapter_string_type],["NodeTypes",NodeTypes_$reflection()],["IsFunctionDefinition",lambda_type(obj_type,LanguageAdapter_bool_type)],["GetFunctionHeads",lambda_type(obj_type,LanguageAdapter_list_type(FunctionHead_$reflection()))],["GetCallableViews",lambda_type(obj_type,LanguageAdapter_list_type(CallableView_$reflection()))],["ParameterChildTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["DecisionNodeTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["CyclomaticBranchCount",lambda_type(obj_type,LanguageAdapter_option_type(LanguageAdapter_int32_type))],["GetCognitiveStructure",lambda_type(obj_type,LanguageAdapter_option_type(CognitiveStructure_$reflection()))],["NestingControlTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["GetBooleanOperator",lambda_type(obj_type,LanguageAdapter_option_type(BooleanOperator_$reflection()))],["IsTryElseClause",lambda_type(obj_type,LanguageAdapter_bool_type)],["VariableReferenceNodeTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["ExtractTypedParameter",lambda_type(obj_type,LanguageAdapter_option_type(TypedParameter_$reflection()))],["ExtractReturnType",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])],["GetErrorHandlingRegion",lambda_type(obj_type,LanguageAdapter_option_type(ErrorHandlingRegion_$reflection()))],["GetFunctionLogicalItems",lambda_type(obj_type,LanguageAdapter_list_type(obj_type))],["KeywordOnlyBoundaryTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["DistinctTypeAdvice",LanguageAdapter_string_type],["GetEqualityComparisons",lambda_type(obj_type,LanguageAdapter_list_type(EqualityComparison_$reflection()))],["GetMatchStringCases",lambda_type(obj_type,LanguageAdapter_option_type(tuple_type(obj_type,LanguageAdapter_list_type(obj_type))))],["GetMembershipComparisons",lambda_type(obj_type,LanguageAdapter_list_type(MembershipComparison_$reflection()))],["IsMatchCaseLiteral",lambda_type(obj_type,LanguageAdapter_bool_type)],["GetElseIfBranches",lambda_type(obj_type,LanguageAdapter_list_type(obj_type))],["SubscriptNodeTypes",LanguageAdapter_list_type(LanguageAdapter_string_type)],["IsFormattedOrInterpolatedString",lambda_type(obj_type,LanguageAdapter_bool_type)],["IsDefaultParameterValue",lambda_type(obj_type,LanguageAdapter_bool_type)],["IsStructuralNumber",lambda_type(obj_type,LanguageAdapter_bool_type)],["NumericLiteralText",lambda_type(obj_type,LanguageAdapter_string_type)],["IsBooleanLiteral",lambda_type(obj_type,LanguageAdapter_bool_type)],["IsPositionalCallArgument",lambda_type(obj_type,LanguageAdapter_bool_type)],["IsExplicitConstant",lambda_type(obj_type,LanguageAdapter_bool_type)],["ImportInfo",lambda_type(obj_type,LanguageAdapter_list_type(ImportInfo_$reflection()))],["IsReExport",lambda_type(LanguageAdapter_string_type,lambda_type(obj_type,LanguageAdapter_bool_type))],["IsClassDefinition",lambda_type(obj_type,LanguageAdapter_bool_type)],["IsStaticMethod",lambda_type(obj_type,LanguageAdapter_bool_type)],["GetClassName",lambda_type(obj_type,LanguageAdapter_option_type(LanguageAdapter_string_type))],["GetBaseClassNames",lambda_type(obj_type,LanguageAdapter_list_type(LanguageAdapter_string_type))],["GetGuardedValidation",lambda_type(FunctionHead_$reflection(),LanguageAdapter_option_type(GuardedValidation_$reflection()))]])}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){if(e instanceof SetTreeNode$1){const r=e;e=SetTreeNode$1__get_Left(r),t=SetTreeModule_countAux(SetTreeNode$1__get_Right(r),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,a;i=null!=e?e instanceof SetTreeNode$1?(r=e,SetTreeNode$1__get_Height(r)):1:0,a=null!=n?n instanceof SetTreeNode$1?(o=n,SetTreeNode$1__get_Height(o)):1:0;const s=0|(i<a?a:i);return 0===s?SetTreeLeaf$1_$ctor_2B595(t):SetTreeNode$1_$ctor_5F465FC9(t,e,n,s+1)}function SetTreeModule_rebalance(e,t,n){let r,o,i,a,s,l,_,u,c,d;if(c=null!=e?e instanceof SetTreeNode$1?(r=e,SetTreeNode$1__get_Height(r)):1:0,d=null!=n?n instanceof SetTreeNode$1?(o=n,SetTreeNode$1__get_Height(o)):1:0,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?(a=i,a instanceof SetTreeNode$1?(s=a,SetTreeNode$1__get_Height(s)):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(l=SetTreeNode$1__get_Right(e),(null!=l?(_=l,_ instanceof SetTreeNode$1?(u=_,SetTreeNode$1__get_Height(u)):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=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=t;if(null!=r){const i=r;if(o instanceof SetTreeNode$1){const a=o;if(i instanceof SetTreeNode$1){const o=i;return SetTreeNode$1__get_Height(a)+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(a)?SetTreeModule_rebalance(SetTreeNode$1__get_Left(a),SetTreeLeaf$1__get_Key(a),SetTreeModule_balance(e,SetTreeNode$1__get_Right(a),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=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=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=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=n,a=0|r.Compare(o,SetTreeLeaf$1__get_Key(i));if(i instanceof SetTreeNode$1){const s=i;if(a<0){e=r,t=o,n=SetTreeNode$1__get_Left(s);continue e}if(0===a)return!0;e=r,t=o,n=SetTreeNode$1__get_Right(s);continue e}return 0===a}return!1}}function SetTreeModule_iter(e,t){e:for(;;){const n=e;if(null!=t){const r=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=t;if(i instanceof SetTreeNode$1){const a=i;e=r,t=SetTreeNode$1__get_Left(a),n=r(SetTreeLeaf$1__get_Key(a),SetTreeModule_foldBackOpt(r,SetTreeNode$1__get_Right(a),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=n;if(i instanceof SetTreeNode$1){const a=i;e=r,t=r(SetTreeModule_foldOpt(r,o,SetTreeNode$1__get_Left(a)),SetTreeLeaf$1__get_Key(a)),n=SetTreeNode$1__get_Right(a);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=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=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,a=r;if(null!=n){const s=n;if(s instanceof SetTreeNode$1){const l=s,_=i(SetTreeLeaf$1__get_Key(l))?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(l),a):a;e=o,t=i,n=SetTreeNode$1__get_Left(l),r=SetTreeModule_filterAux(o,i,SetTreeNode$1__get_Right(l),_);continue e}return i(SetTreeLeaf$1__get_Key(s))?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(s),a):a}return a}}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=t;if(i instanceof SetTreeNode$1){const a=i;e=r,t=SetTreeNode$1__get_Left(a),n=SetTreeModule_diffAux(r,SetTreeNode$1__get_Right(a),SetTreeModule_remove(r,SetTreeLeaf$1__get_Key(a),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=t;if(null!=n){const o=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,a=r;if(null!=n){const s=n;if(s instanceof SetTreeNode$1){const l=s,_=SetTreeModule_intersectionAux(o,i,SetTreeNode$1__get_Right(l),a),u=SetTreeModule_mem(o,SetTreeLeaf$1__get_Key(l),i)?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(l),_):_;e=o,t=i,n=SetTreeNode$1__get_Left(l),r=u;continue e}return SetTreeModule_mem(o,SetTreeLeaf$1__get_Key(s),i)?SetTreeModule_add(o,SetTreeLeaf$1__get_Key(s),a):a}return a}}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,a=t,s=[r,o];if(null!=n){const l=n;if(l instanceof SetTreeNode$1){const _=l,u=SetTreeModule_partitionAux(i,a,SetTreeNode$1__get_Right(_),s[0],s[1]),c=SetTreeModule_partition1(i,a,SetTreeLeaf$1__get_Key(_),u[0],u[1]);e=i,t=a,n=SetTreeNode$1__get_Left(_),r=c[0],o=c[1];continue e}return SetTreeModule_partition1(i,a,SetTreeLeaf$1__get_Key(l),s[0],s[1])}return s}}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=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=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=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=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 Set_Operators_InvalidArg("s","Set contains no elements.");return Set_value_2(t)}function SetTreeModule_maximumElement(e){const t=SetTreeModule_maximumElementOpt(e);if(null==t)throw Set_Operators_InvalidArg("s","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}Equals(e){return this===e}GetHashCode(){return physicalHash(this)}}function SetTreeModule_SetIterator$1_$reflection(e){return Set_record_type("Set.SetTreeModule.SetIterator`1",[e],SetTreeModule_SetIterator$1,()=>[["stack",Set_list_type(Set_option_type(SetTreeLeaf$1_$reflection(e)))],["started",Set_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){if(n instanceof SetTreeNode$1){const t=n;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 Operators_InvalidOp("Enumeration has not started. Call MoveNext.")}function SetTreeModule_alreadyFinished(){throw Operators_InvalidOp("Enumeration already finished.")}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(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(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 a=List_head(o),s=List_head(i);if(a instanceof SetTreeNode$1){const l=a;if(null==SetTreeNode$1__get_Left(l)){if(!(s instanceof SetTreeNode$1)){const a=0|r.Compare(SetTreeLeaf$1__get_Key(l),SetTreeLeaf$1__get_Key(s));if(0!==a)return 0|a;e=r,t=cons(SetTreeNode$1__get_Right(l),List_tail(o)),n=cons(SetTreeModule_empty(),List_tail(i));continue e}{const a=s;if(null==SetTreeNode$1__get_Left(a)){const s=0|r.Compare(SetTreeLeaf$1__get_Key(l),SetTreeLeaf$1__get_Key(a));if(0!==s)return 0|s;e=r,t=cons(SetTreeNode$1__get_Right(l),List_tail(o)),n=cons(SetTreeNode$1__get_Right(a),List_tail(i));continue e}{let a,s,l,_,u;switch(List_isEmpty(o)?List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2:null!=List_head(o)?(a=0,s=List_tail(o),l=List_head(o)):List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2,a){case 0:if(l instanceof SetTreeNode$1){const o=l;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)],s),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],s),n=i;continue e;case 1:if(u instanceof SetTreeNode$1){const i=u;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)],_);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(u))],_);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}}}else{let a,s,l,_,u;switch(List_isEmpty(o)?List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2:null!=List_head(o)?(a=0,s=List_tail(o),l=List_head(o)):List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2,a){case 0:if(l instanceof SetTreeNode$1){const o=l;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)],s),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],s),n=i;continue e;case 1:if(u instanceof SetTreeNode$1){const i=u;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)],_);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(u))],_);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}}else{if(!(s instanceof SetTreeNode$1)){const l=0|r.Compare(SetTreeLeaf$1__get_Key(a),SetTreeLeaf$1__get_Key(s));if(0!==l)return 0|l;e=r,t=List_tail(o),n=List_tail(i);continue e}{const l=s;if(null==SetTreeNode$1__get_Left(l)){const s=0|r.Compare(SetTreeLeaf$1__get_Key(a),SetTreeLeaf$1__get_Key(l));if(0!==s)return 0|s;e=r,t=cons(SetTreeModule_empty(),List_tail(o)),n=cons(SetTreeNode$1__get_Right(l),List_tail(i));continue e}{let a,s,l,_,u;switch(List_isEmpty(o)?List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2:null!=List_head(o)?(a=0,s=List_tail(o),l=List_head(o)):List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2,a){case 0:if(l instanceof SetTreeNode$1){const o=l;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)],s),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],s),n=i;continue e;case 1:if(u instanceof SetTreeNode$1){const i=u;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)],_);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(u))],_);continue e;default:throw new Exception("unexpected state in SetTree.compareStacks")}}}}}else{let a,s,l,_,u;switch(List_head(i),List_isEmpty(o)?List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2:null!=List_head(o)?(a=0,s=List_tail(o),l=List_head(o)):List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2,a){case 0:if(l instanceof SetTreeNode$1){const o=l;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)],s),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],s),n=i;continue e;case 1:if(u instanceof SetTreeNode$1){const i=u;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)],_);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(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 a,s,l,_,u;switch(List_head(o),List_isEmpty(o)?List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2:null!=List_head(o)?(a=0,s=List_tail(o),l=List_head(o)):List_isEmpty(i)?a=2:null!=List_head(i)?(a=1,_=List_tail(i),u=List_head(i)):a=2,a){case 0:if(l instanceof SetTreeNode$1){const o=l;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)],s),n=i;continue e}e=r,t=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(l))],s),n=i;continue e;case 1:if(u instanceof SetTreeNode$1){const i=u;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)],_);continue e}e=r,t=o,n=ofArrayWithTail([SetTreeModule_empty(),SetTreeLeaf$1_$ctor_2B595(SetTreeLeaf$1__get_Key(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=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 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())))}const scopeGroupIndex=2,typeGroupIndex=3;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(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],["parse-dont-validate",ViolationType.ParseDontValidate],["error-shadowing",ViolationType.ErrorShadowing],["recovery-dominance",ViolationType.RecoveryDominance],["oversized-recovery-block",ViolationType.OversizedRecoveryBlock],["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=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 ofArray(choose(e=>e,mapIndexed((e,t)=>{const n=match(directivePattern,t);if(null!=n){const r=parseTypeList(n[typeGroupIndex]||"");return new Suppression(e,n.index,null!=n[scopeGroupIndex]?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 Position_record_type,Position_int32_type,Position_lambda_type,Context_record_type,Context_string_type,Context_obj_type,Context_list_type,Context_lambda_type,Context_PositionLookup_$reflection,Context_LanguageAdapter_$reflection,Context_AnalyzeOptions_$reflection,Context_EnergyViolation_$reflection;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",Position_lambda_type(Position_int32_type,Position_$reflection())]])}function createPositionLookup(e){const t=[0];for(let n=0;n<=e.length-1;n++)"\n"===getCharAtIndex(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;Array_item(o,t)<=e?n=0|o:r=o-1|0}return new Position(n,e-Array_item(n,t))})}class AnalysisContext extends Record{constructor(e,t,n,r,o,i,a){super(),this.Source=e,this.Tree=t,this.Positions=n,this.Language=r,this.FileName=o,this.Options=i,this.Violations=a}}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],["Options",Context_AnalyzeOptions_$reflection()],["Violations",Context_list_type(Context_EnergyViolation_$reflection())]])}function addViolations(e,t){return new AnalysisContext(t.Source,t.Tree,t.Positions,t.Language,t.FileName,t.Options,List_append(List_reverse(e),t.Violations))}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(),AnalysisContext_$reflection())]])}function analyzeNesting(e){const t=(n,r)=>{const o=List_contains(n.type,e.Language.NestingControlTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),i=0|(o?r+1:r),a=List_collect(e=>t(e,i),nodeChildren(n));if(o&&r>e.Options.Nesting.MediumThreshold){const t=e.Positions.toPosition(n.startIndex);return cons(new EnergyViolation(t.Line,t.Column,ViolationType.Nesting,r>e.Options.Nesting.HighThreshold?Severity.High:Severity.Medium,toText(printf("Excessive nesting depth: %d. Consider extracting."))(r),List_empty()),a)}return a};return addViolations(t(e.Tree,0),e)}const detector=new Detector("nesting",analyzeNesting);var Cyclomatic_union_type,Cyclomatic_int32_type,Cyclomatic_record_type,Cyclomatic_list_type;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 CallableScope extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["RootCallable","NestedCallable"]}static RootCallable=new CallableScope(0,[]);static NestedCallable=new CallableScope(1,[])}function CallableScope_$reflection(){return Cyclomatic_union_type("Energy.Core.Detectors.Cyclomatic.CallableScope",[],CallableScope,()=>[[],[]])}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(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 isCallableBoundary(e,t){return!List_isEmpty(e.GetCallableViews(t))}function buildControlFlowGraph(e,t,n,r){const o=isDecisionPoint(e,t)?addDecision(decisionOutcomes(e,t),r):r;return equals(n,CallableScope.NestedCallable)&&isCallableBoundary(e,t)?o:List_fold((t,n)=>buildControlFlowGraph(e,n,CallableScope.NestedCallable,t),o,nodeChildren(t))}function complexityOf(e,t){const n=buildControlFlowGraph(e,t,CallableScope.RootCallable,initialGraph);return List_length(n.Edges)-List_length(n.Nodes)+mccabeComponentMultiplier*connectedComponents|0}function complexityOfCallable(e,t){return 0|complexityOf(e,t.Body)}function findCyclomaticHotspots(e,t,n,r,o){const i=isDecisionPoint(e,n),a=i?List_singleton(new Hotspot(t.toPosition(n.startIndex).Line,(decisionOutcomes(e,n)-1)*(1+r))):List_empty();if(equals(o,CallableScope.NestedCallable)&&isCallableBoundary(e,n))return a;{const o=0|(i?r+1:r);return List_append(a,List_collect(n=>findCyclomaticHotspots(e,t,n,o,CallableScope.NestedCallable),nodeChildren(n)))}}function analyzeCallable(e,t){const n=0|complexityOfCallable(e.Language,t);if(n>e.Options.Cyclomatic.MediumThreshold){const r=e.Positions.toPosition(t.Anchor.startIndex);return List_singleton(new EnergyViolation(r.Line,r.Column,ViolationType.Complexity,n>e.Options.Cyclomatic.HighThreshold?Severity.High:Severity.Medium,toText(printf("High cyclomatic complexity: %d. Consider breaking down this function."))(n),findCyclomaticHotspots(e.Language,e.Positions,t.Body,0,CallableScope.RootCallable)))}return List_empty()}function analyzeFunctionComplexity(e){const t=n=>List_append(List_collect(t=>analyzeCallable(e,t),e.Language.GetCallableViews(n)),List_collect(t,nodeChildren(n)));return addViolations(t(e.Tree),e)}const Cyclomatic_detector=new Detector("cyclomatic",analyzeFunctionComplexity);var Cognitive_union_type,Cognitive_obj_type,Cognitive_BooleanOperator_$reflection;class BooleanPart extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Operator","Operand"]}}function BooleanPart_$reflection(){return Cognitive_union_type("Energy.Core.Detectors.Cognitive.BooleanPart",[],BooleanPart,()=>[[["Item1",Cognitive_obj_type],["Item2",Cognitive_BooleanOperator_$reflection()]],[["Item",Cognitive_obj_type]]])}function operatorAnchor(e,t,n){return defaultArg(List_tryFind(e=>e.startIndex>=t.endIndex&&e.endIndex<=n.startIndex,nodeChildren(e)),e)}function booleanParts(e,t){e:for(;;){const n=e,r=t;let o,i;const a=n.GetBooleanOperator(r),s=n.GetCognitiveStructure(r);let l,_,u;switch(null==a?null!=s&&2===s.tag?(l=1,u=s.fields[0]):l=2:(l=0,_=a),l){case 0:{const e=nodeNamedChildren(r),t=List_tryHead(e),a=List_tryLast(e);let s,l,u;return null!=t&&null!=a?(o=Option_value(a),i=Option_value(t),i.id!==o.id?(s=0,l=Option_value(t),u=Option_value(a)):s=1):s=1,0===s?List_append(booleanParts(n,l),List_append(List_singleton(new BooleanPart(0,[operatorAnchor(r,l,u),_])),booleanParts(n,u))):List_map(e=>new BooleanPart(1,[e]),e)}case 1:e=n,t=u;continue e;default:return List_singleton(new BooleanPart(1,[r]))}break}}function scoreBooleanParts(e,t,n){return 0|List_fold((n,r)=>{const o=0|n[0],i=n[1];if(1===r.tag)return[o+e(r.fields[0]),i];{const e=r.fields[1],n=0|(equals(i,e)?0:1);return n>0&&t(r.fields[0],n),[o+n,e]}},[0,void 0],n)[0]}function cognitiveWalk(e,t,n,r){let o;const i=o=>0|List_sumBy(t=>0|cognitiveWalk(e,t,o(t)?n+1:n,r),nodeChildren(t),{GetZero:()=>0,Add:(e,t)=>e+t|0});if(null!=e.GetBooleanOperator(t))return 0|scoreBooleanParts(t=>0|cognitiveWalk(e,t,n,r),r,booleanParts(e,t));{const a=e.GetCognitiveStructure(t);let s,l,_;if(null!=a)switch(a.tag){case 0:s=0,l=a.fields[0],_=a.fields[1];break;case 1:s=1;break;default:s=e.IsFunctionDefinition(t)?2:3}else s=e.IsFunctionDefinition(t)?2:3;switch(s){case 0:return 0|(o=0|(1===l.tag||2===l.tag?1:1+n),o>0&&r(t,o),o+i(e=>List_exists(t=>t.id===e.id,_)));case 1:return 0|i(e=>!0);case 2:return 0|i(e=>!0);default:return 0|i(e=>!1)}}}function callableBodyRoots(e){return e.Anchor.id===e.Body.id?nodeChildren(e.Body):List_singleton(e.Body)}function cognitiveScoreOf(e,t){return 0|List_sumBy(t=>0|cognitiveWalk(e,t,0,(e,t)=>{}),callableBodyRoots(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))})},callableBodyRoots(t)),ofSeq(r)}function Cognitive_analyzeCallable(e,t){const n=0|cognitiveScoreOf(e.Language,t);if(n>e.Options.Cognitive.MediumThreshold){const r=e.Positions.toPosition(t.Anchor.startIndex);return List_singleton(new EnergyViolation(r.Line,r.Column,ViolationType.Cognitive,n>e.Options.Cognitive.HighThreshold?Severity.High:Severity.Medium,toText(printf("High cognitive complexity: %d. This function is hard to read; consider flattening nesting or extracting functions."))(n),findCognitiveHotspots(e.Language,t,e.Positions)))}return List_empty()}function analyzeCognitiveComplexity(e){const t=n=>List_append(List_collect(t=>Cognitive_analyzeCallable(e,t),e.Language.GetCallableViews(n)),List_collect(t,nodeChildren(n)));return addViolations(t(e.Tree),e)}const Cognitive_detector=new Detector("cognitive",analyzeCognitiveComplexity);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}const wordBoundaryPattern=/[A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+|[0-9]+/gu;function 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(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),splitIntoWords((t=0|n.lastIndexOf("."),-1===t?n:substring(n,0,t))))}function callableNameWords(e){const t=e.BindingName;let n,r;return null!=t?isNullOrEmpty(t)?n=1:(n=0,r=t):n=1,0===n?splitIntoWords(r):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=splitIntoWords(o["System.Collections.Generic.IEnumerator`1.get_Current"]());List_length(e)>0&&(n.push(item(0,e)),r.push(item(List_length(e)-1,e)))}}finally{disposeSafe(o)}return 0!==n.length&&(dominantShare(ofSeq(n))>=t||dominantShare(ofSeq(r))>=t)}function looksLikeSingleDomain(e,t){return looksLikeSingleDomainByNames(List_map(e=>join(" ",callableNameWords(e)),e),t)}var TypeCohesion_record_type,TypeCohesion_bool_type,TypeCohesion_int32_type,TypeCohesion_union_type,TypeCohesion_float64_type;const nonDomainBaseTypes=Set_ofList(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|indexOf(n,t.Open,4),r=-1===e?n.trim():substring(n,0,e).trim();return isMatch(/^[A-Za-z_][A-Za-z0-9_]*(?:(?:\.|::)[A-Za-z_][A-Za-z0-9_]*)*$/gu,r)?FSharpSet__Contains(nonDomainBaseTypes,r)||isTypeParameterName(r)?void 0:r:void 0}}function collectTypeSignals(e,t){let n,r;const o=new Set([]),i=getEnumerator(e.Parameters);try{for(;i["System.Collections.IEnumerator.MoveNext"]();){let e,n;e=t.ExtractTypedParameter(i["System.Collections.Generic.IEnumerator`1.get_Current"]()),null!=e&&(n=baseTypeName(e.Type,t.GenericBrackets),null!=n&&some(void addToSet(n,o)))}}finally{disposeSafe(i)}return n=t.ExtractReturnType(e.ReturnTypeRoot),null!=n&&(r=baseTypeName(n,t.GenericBrackets),null!=r&&some(void addToSet(r,o))),o}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)])}}var MutableSet_item_1,MutableSet_some,MutableSet_class_type,MutableMap_class_type,Seq2_delay,Seq2_filter,Seq2_toArray,Seq2_map,Seq2_toList,Seq2_HashSet,Seq2_addToSet,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,ClassRelatedness_CallableView_$reflection,ClassRelatedness_LanguageAdapter_$reflection,ClassRelatedness_Severity_$reflection,ClassRelatedness_CoherenceThresholds_$reflection,ClassRelatedness_PositionLookup_$reflection,CoherenceCollection_CallableView_$reflection,CoherenceCollection_ImportInfo_$reflection,CoherenceCollection_record_type,CoherenceCollection_list_type,CoherenceCollection_option_type,CoherenceCollection_obj_type,CoherenceCollection_ClassInfo_$reflection;class MutableSet_HashSet{constructor(e,t){const n=new FSharpRef(defaultOf());this.comparer=t,n.contents=this,this.hashMap=new Map([]),this.count=0,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"]();HashSet__Add_2B595(n.contents,e)}}finally{disposeSafe(r)}}get[Symbol.toStringTag](){return"HashSet"}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){HashSet__Add_2B595(this,e)}"System.Collections.Generic.ICollection`1.Clear"(){HashSet__Clear(this)}"System.Collections.Generic.ICollection`1.Contains2B595"(e){return HashSet__Contains_2B595(this,e)}"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|HashSet__get_Count(this)}"System.Collections.Generic.ICollection`1.get_IsReadOnly"(){return!1}"System.Collections.Generic.ICollection`1.Remove2B595"(e){return HashSet__Remove_2B595(this,e)}get size(){return 0|HashSet__get_Count(this)}add(e){return HashSet__Add_2B595(this,e),this}clear(){HashSet__Clear(this)}delete(e){return HashSet__Remove_2B595(this,e)}has(e){return HashSet__Contains_2B595(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 HashSet_$reflection(e){return MutableSet_class_type("Fable.Collections.HashSet",[e],MutableSet_HashSet)}function MutableSet_HashSet_$ctor_Z6150332D(e,t){return new MutableSet_HashSet(e,t)}function HashSet__TryFindBucket_Z524259A4(e,t){return e.hashMap.has(t)?getItemFromDict(e.hashMap,t):void 0}function HashSet__FindIndex_Z142BBCA7(e,t,n){let r=0,o=-1;for(;o<0&&r<n.length;)e.comparer.Equals(t,Array_item(r,n))&&(o=0|r),r=r+1|0;return 0|o}function HashSet__TryFind_2B595(e,t){const n=HashSet__TryFindBucket_Z524259A4(e,e.comparer.GetHashCode(t));if(null!=n){const r=n,o=0|HashSet__FindIndex_Z142BBCA7(e,t,r);return o>-1?MutableSet_some(MutableSet_item_1(o,r)):void 0}}function MutableSet_HashSet_get_Comparer(e){return e.comparer}function HashSet__Clear(e){e.hashMap.clear(),e.count=0}function HashSet__get_Count(e){return 0|e.count}function HashSet__Add_2B595(e,t){const n=0|e.comparer.GetHashCode(t),r=HashSet__TryFindBucket_Z524259A4(e,n);if(null==r)return e.hashMap.set(n,[t]),e.count=e.count+1|0,!0;{const n=r;return!(HashSet__FindIndex_Z142BBCA7(e,t,n)>-1||(n.push(t),e.count=e.count+1|0,0))}}function HashSet__Contains_2B595(e,t){const n=HashSet__TryFindBucket_Z524259A4(e,e.comparer.GetHashCode(t));return null!=n&&HashSet__FindIndex_Z142BBCA7(e,t,n)>-1}function HashSet__Remove_2B595(e,t){const n=0|e.comparer.GetHashCode(t),r=HashSet__TryFindBucket_Z524259A4(e,n);if(null==r)return!1;{const o=r,i=0|HashSet__FindIndex_Z142BBCA7(e,t,o);return i>-1&&(o.splice(i,1),e.count=e.count-1|0,0===o.length&&e.hashMap.delete(n),!0)}}class Dictionary{constructor(e,t){const n=new FSharpRef(defaultOf());this.comparer=t,n.contents=this,this.hashMap=new Map([]),this.count=0,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(t[1],e[1])?(n=0,r=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(t[1],e[1])?(n=0,r=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=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__TryFindBucket_Z524259A4(e,t){return e.hashMap.has(t)?getItemFromDict(e.hashMap,t):void 0}function Dictionary__FindIndex_Z61A8C007(e,t,n){let r=0,o=-1;for(;o<0&&r<n.length;)e.comparer.Equals(t,Array_item(r,n)[0])&&(o=0|r),r=r+1|0;return 0|o}function Dictionary__TryFind_2B595(e,t){const n=Dictionary__TryFindBucket_Z524259A4(e,e.comparer.GetHashCode(t));if(null!=n){const r=n,o=0|Dictionary__FindIndex_Z61A8C007(e,t,r);return o>-1?Array_item(o,r):void 0}}function Dictionary__get_Comparer(e){return e.comparer}function Dictionary__Clear(e){e.hashMap.clear(),e.count=0}function Dictionary__get_Count(e){return 0|e.count}function Dictionary__get_Item_2B595(e,t){const n=Dictionary__TryFind_2B595(e,t);if(null!=n)return 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=0|e.comparer.GetHashCode(t),o=Dictionary__TryFindBucket_Z524259A4(e,r);if(null==o)e.hashMap.set(r,[[t,n]]),e.count=e.count+1|0;else{const r=o,i=0|Dictionary__FindIndex_Z61A8C007(e,t,r);i>-1?setItem(r,i,[t,n]):(r.push([t,n]),e.count=e.count+1|0)}}function Dictionary__Add_5BDDA1(e,t,n){const r=0|e.comparer.GetHashCode(t),o=Dictionary__TryFindBucket_Z524259A4(e,r);if(null==o)e.hashMap.set(r,[[t,n]]),e.count=e.count+1|0;else{const r=o;if(Dictionary__FindIndex_Z61A8C007(e,t,r)>-1)throw ArgumentException_$ctor_Z721C83C5(format("An item with the same key has already been added. Key: {0}",t));r.push([t,n]),e.count=e.count+1|0}}function Dictionary__ContainsKey_2B595(e,t){const n=Dictionary__TryFindBucket_Z524259A4(e,e.comparer.GetHashCode(t));return null!=n&&Dictionary__FindIndex_Z61A8C007(e,t,n)>-1}function Dictionary__Remove_2B595(e,t){const n=0|e.comparer.GetHashCode(t),r=Dictionary__TryFindBucket_Z524259A4(e,n);if(null==r)return!1;{const o=r,i=0|Dictionary__FindIndex_Z61A8C007(e,t,o);return i>-1&&(o.splice(i,1),e.count=e.count-1|0,0===o.length&&e.hashMap.delete(n),!0)}}function distinct(e,t){return delay(()=>{const n=new MutableSet_HashSet([],t);return Seq_filter(e=>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;const a=new FSharpRef(0);n=[tryGetValue(r,t,a),a.contents],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 a;const s=new FSharpRef(defaultOf());a=[tryGetValue(r,n,s),s.contents],a[0]?a[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 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 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_CallableView_$reflection())]])}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(Array_item(n,t)===n)return 0|n;setItem(t,n,0|Array_item(Array_item(n,t),t)),e=Array_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(Array_item(0,e),Array_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(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,a;if(!(List_length(e)<2)){const s=groupClassesIntoFamilies(e,n),l=List_map(e=>e.Name,e);let _;switch(_=List_isEmpty(s)?namesHaveSharedDomain(e,t)?1:2:List_isEmpty(List_tail(s))?0:namesHaveSharedDomain(e,t)?1:2,_){case 0:case 1:return;default:{const t=r.toPosition(item(0,e).Node.startIndex);return new EnergyViolation(t.Line,t.Column,ViolationType.Coherence,List_length(s)>2?Severity.High:Severity.Medium,(o=0|List_length(e),i=0|List_length(s),a=groupDescription(s,l),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)(a)),List_empty())}}}}class GodClassCtx extends Record{constructor(e,t,n){super(),this.Language=e,this.Thresholds=t,this.Positions=n}}function GodClassCtx_$reflection(){return ClassRelatedness_record_type("Energy.Core.Detectors.ClassRelatedness.GodClassCtx",[],GodClassCtx,()=>[["Language",ClassRelatedness_LanguageAdapter_$reflection()],["Thresholds",ClassRelatedness_CoherenceThresholds_$reflection()],["Positions",ClassRelatedness_PositionLookup_$reflection()]])}class MethodSignals extends Record{constructor(e,t){super(),this.MethodCount=0|e,this.DistinctTypes=0|t}}function MethodSignals_$reflection(){return ClassRelatedness_record_type("Energy.Core.Detectors.ClassRelatedness.MethodSignals",[],MethodSignals,()=>[["MethodCount",ClassRelatedness_int32_type],["DistinctTypes",ClassRelatedness_int32_type]])}class GodClassCandidate extends Record{constructor(e,t,n){super(),this.Class=e,this.Signals=t,this.Severity=n}}function GodClassCandidate_$reflection(){return ClassRelatedness_record_type("Energy.Core.Detectors.ClassRelatedness.GodClassCandidate",[],GodClassCandidate,()=>[["Class",ClassInfo_$reflection()],["Signals",MethodSignals_$reflection()],["Severity",ClassRelatedness_Severity_$reflection()]])}function GodClassCandidate_Create_Z55957A70(e){return t=>{const n=e.toPosition(t.Class.Node.startIndex);return new EnergyViolation(n.Line,n.Column,ViolationType.Coherence,t.Severity,toText(printf("File coherence warning: this class has %d methods spanning %d unrelated types. Its methods touch too many distinct concerns to be one responsibility — consider splitting it, or confirm these are one cohesive API (e.g. a tagged union of combinators over a single domain type)."))(t.Signals.MethodCount)(t.Signals.DistinctTypes),List_empty())}}function shouldMeasureGodClass(e,t){return List_length(t)>e.Thresholds.MethodCountMedium&&List_exists(t=>!e.Language.IsStaticMethod(t.Anchor),t)}function distinctSignals(e,t){const n=ofSeq(t.Methods),r=new TypeCohesionThresholds(e.Thresholds.MaxTypeDiversityRatio,e.Thresholds.MinTypedCoverage);if(shouldMeasureGodClass(e,n)){const t=typeCohesionResult(n,e.Language,r);let o,i;return 1===t.tag?t.fields[0].Result?o=1:(o=0,i=t.fields[0]):o=1,0===o?[List_length(n),i.DistinctTypes]:void 0}}function considerGodClass(e,t){const n=distinctSignals(e,t);if(null!=n){const r=0|n[0];return new GodClassCandidate(t,new MethodSignals(r,n[1]),r>e.Thresholds.MethodCountHigh?Severity.High:Severity.Medium)}}function checkGodClass(e,t){const n=List_choose(e=>considerGodClass(t,e),e);return List_isEmpty(n)?void 0:GodClassCandidate_Create_Z55957A70(t.Positions)(List_maxBy(e=>0|e.Signals.MethodCount,n,{Compare:(e,t)=>0|comparePrimitives(e,t)}))}class Collected extends Record{constructor(e,t,n,r){super(),this.FreeFunctions=e,this.Classes=t,this.Imports=n,this.FirstImportNode=r}}function Collected_$reflection(){return CoherenceCollection_record_type("Energy.Core.CoherenceCollection.Collected",[],Collected,()=>[["FreeFunctions",CoherenceCollection_list_type(CoherenceCollection_CallableView_$reflection())],["Classes",CoherenceCollection_list_type(CoherenceCollection_ClassInfo_$reflection())],["Imports",CoherenceCollection_list_type(CoherenceCollection_ImportInfo_$reflection())],["FirstImportNode",CoherenceCollection_option_type(CoherenceCollection_obj_type)]])}function isImportNode(e,t){const n=t.type;return!(!Seq_exists(e=>equals(n,e),toArray(e.NodeTypes.ImportStatement))&&!Seq_exists(e=>equals(n,e),toArray(e.NodeTypes.ImportFromStatement)))||List_contains(n,e.NodeTypes.AdditionalImportTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})}const CoherenceCollection_empty=new Collected(List_empty(),List_empty(),List_empty(),void 0);function merge(e,t){return new Collected(List_append(e.FreeFunctions,t.FreeFunctions),List_append(e.Classes,t.Classes),List_append(e.Imports,t.Imports),orElse(t.FirstImportNode,e.FirstImportNode))}function collectFree(e){return new Collected(List_singleton(e),CoherenceCollection_empty.Classes,CoherenceCollection_empty.Imports,CoherenceCollection_empty.FirstImportNode)}function collectClass(e,t){return null==e||e.Methods.push(t),CoherenceCollection_empty}function collectCallable(e,t){const n=t.Role;switch(n.tag){case 1:return 1===n.fields[0].tag?collectClass(e,t):collectFree(t);case 2:return CoherenceCollection_empty;default:return null==e?collectFree(t):collectClass(e,t)}}function classAt(e,t){return e.IsClassDefinition(t)?new ClassInfo(e.GetClassName(t),t,e.GetBaseClassNames(t),[]):void 0}function normalizeImportSource(e,t){return isNullOrEmpty(t.Source)?new ImportInfo(t.Kind,e.text,t.Bindings):t}function collectStructure(e,t,n,r){return null==r?isImportNode(e,n)&&e.IsReExport(t,n)?CoherenceCollection_empty:isImportNode(e,n)?new Collected(CoherenceCollection_empty.FreeFunctions,CoherenceCollection_empty.Classes,List_map(e=>normalizeImportSource(n,e),e.ImportInfo(n)),some(n)):CoherenceCollection_empty:new Collected(CoherenceCollection_empty.FreeFunctions,List_singleton(r),CoherenceCollection_empty.Imports,CoherenceCollection_empty.FirstImportNode)}function traverse(e,t,n,r){let o;const i=classAt(e,n),a=orElse(r,i);return List_fold(merge,(o=List_map(e=>collectCallable(r,e),e.GetCallableViews(n)),List_fold(merge,collectStructure(e,t,n,i),o)),List_map(n=>traverse(e,t,n,a),nodeChildren(n)))}function CoherenceCollection_collect(e,t,n){return traverse(t,n,e,void 0)}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 TestFile_splitIntoWords(e){let t,n;return 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=n>0?substring(e,0,n):e,o=endsWith(e,".rs",5),i=e=>"test"===e||!!o&&"tests"===e,a=List_map(e=>e.toLowerCase(),TestFile_splitIntoWords(r));let s,l,_;return List_isEmpty(a)?(s=1,_=a):i(List_head(a))?(s=0,l=List_head(a)):(s=1,_=a),0===s||Seq_exists(i,toArray(List_tryLast(_)))}}function isCfgTestAttribute(e){if(equals(e.type,"attribute_item")){const t=nodeNamedChildren(e);let n,r;if(List_isEmpty(t)?n=1:List_isEmpty(List_tail(t))?(n=0,r=List_head(t)):n=1,0===n){const e=nodeNamedChildren(r);let t,n,o;if(List_isEmpty(e)||List_isEmpty(List_tail(e))?t=1:List_isEmpty(List_tail(List_tail(e)))&&"cfg"===List_head(e).text?(t=0,n=List_head(List_tail(e)),o=List_head(e)):t=1,0===t){const e=nodeNamedChildren(n);let t,r;return List_isEmpty(e)?t=1:List_isEmpty(List_tail(e))?(t=0,r=List_head(e)):t=1,0===t&&!!equals(r.type,"identifier")&&"test"===r.text}return!1}return!1}return!1}function hasCfgTestAttribute(e){for(;;){const t=e;let n,r,o;if(null!=t?(n=Option_value(t),equals(n.type,"attribute_item")?(r=0,o=Option_value(t)):r=1):r=1,0!==r)return!1;if(isCfgTestAttribute(o))return!0;e=nodePreviousNamedSibling(o)}}function isRustTestModule(e,t){return!("rust"!==e.Id||!equals(t.type,"mod_item"))&&(!!Seq_exists(e=>isTestFile(e.text+".rs"),toArray(nodeField("name",t)))||hasCfgTestAttribute(nodePreviousNamedSibling(t)))}function isRustTestFunction(e){return!!equals(e.type,"function_item")&&(e=>{for(;;){const t=e;let n,r,o,i,a,s;if(null!=t?(i=Option_value(t),equals(i.type,"attribute_item")?(a=0,s=Option_value(t)):a=1):a=1,0!==a)return!1;if(isCfgTestAttribute(s)||(n=s,equals(n.type,"attribute_item")&&(r=nodeNamedChildren(n),!List_isEmpty(r)&&List_isEmpty(List_tail(r))&&(o=nodeNamedChildren(List_head(r)),!List_isEmpty(o)&&List_isEmpty(List_tail(o))&&List_contains(List_head(o).text,ofArray(["test","tokio::test","async_std::test"]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})))))return!0;e=nodePreviousNamedSibling(s)}})(nodePreviousNamedSibling(e))}function isRustTestCode(e,t,n){if("rust"!==e.Id)return!1;if(isTestFile(t))return!0;{const t=n=>!(!isRustTestModule(e,n)&&!isRustTestFunction(n))||Seq_exists(t,toArray(nodeParent(n)));return t(n)}}const kotlinMemberImportFanOutThreshold=30;function mostOpenedFSharpSiblingNamespace(e,t){return List_tryHead(List_sortByDescending(e=>0|e[1],List_filter(e=>e[1]>=t,List_countBy(e=>e,List_choose(e=>{const t=0|e.lastIndexOf(".");return t>0&&t<e.length-1?substring(e,0,t):void 0},Set_toList(e)),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})),{Compare:(e,t)=>0|comparePrimitives(e,t)}))}function widestMemberImportFanOut(e,t){return List_tryHead(List_sortByDescending(e=>0|e[1],List_filter(e=>e[1]>=t,List_countBy(e=>e,List_collect(e=>List_map(t=>e.Source,e.Bindings),List_filter(e=>equals(e.Kind,ImportKind.Members),e)),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})),{Compare:(e,t)=>0|comparePrimitives(e,t)}))}function memberImportFanOutThreshold(e,t){return"kotlin"===e?0|kotlinMemberImportFanOutThreshold:0|t.MemberImportFanOutThreshold}function importMessage(e,t,n,r,o){let i;switch(i=null!=n?0:t?1:"fsharp"===e&&null!=r?2:3,i){case 0:{const e=n[0],t=0|n[1];return toText(printf("Import member fan-out: %d declarations from %s enter this file's local vocabulary. This is a broad API surface even though it is one dependency; review whether it is an intentional composition boundary, otherwise depend on a smaller cohesive API. Do not replace explicit imports with a wildcard import."))(t)(e)}case 1:return"Import scope pollution: a wildcard import makes an entire external scope available without qualification. Prefer explicit imports so symbol origins and collisions remain visible.";case 2:{const e=0|r[1],t=r[0];return toText(printf("Import scope sprawl: %d modules are opened, including %d siblings beneath %s. This is a name-resolution risk: opened values can shadow one another and their origin is unclear. Prefer explicit qualified access or a small named module alias; do not split a cohesive file merely to reduce the count."))(o)(e)(t)}default:return toText(printf("Import sprawl: %d distinct modules create a broad dependency surface. This can mean the file has multiple responsibilities, or that one cohesive capability is exposed through too many sibling modules. Review repeated sibling imports first; introduce a focused facade only when those imports serve one capability, and don't split the file merely to reduce the count."))(o)}}function check(e,t,n,r,o){const i=Set_ofList(List_map(e=>e.Source,e),{Compare:(e,t)=>0|comparePrimitives(e,t)}),a=List_exists(e=>equals(e.Kind,ImportKind.Wildcard),e),s="fsharp"===n.Id?mostOpenedFSharpSiblingNamespace(i,o.SiblingOpenThreshold):void 0,l=widestMemberImportFanOut(e,memberImportFanOutThreshold(n.Id,o));if(!(FSharpSet__get_Count(i)<=o.ImportBreadthThreshold)||a||null!=l||null!=s){let e;if(null==t)e=new Position(0,0);else{const n=Option_value(t);e=r.toPosition(n.startIndex)}const _=importMessage(n.Id,a,l,s,FSharpSet__get_Count(i));return new EnergyViolation(e.Line,e.Column,ViolationType.Coherence,FSharpSet__get_Count(i)>o.HighImportBreadthThreshold?Severity.High:Severity.Medium,_,List_empty())}}function isCohesiveByNamingOrType(e,t,n){return 0===n.tag?looksLikeSingleDomain(e,t.SingleDomainNameShare):n.fields[0].Result}function functionCountViolation(e,t,n,r){return new EnergyViolation(n.Line,n.Column,ViolationType.Coherence,e>r.HighFunctionCount?Severity.High:Severity.Medium,t,List_empty())}function checkFunctionCountSprawl(e,t,n,r,o){let i,a;if(!(List_length(e)<=n.UtilsFileFunctionCount)){const s=isUtilsFileName(t),l=typeCohesionResult(e,r,new TypeCohesionThresholds(n.MaxTypeDiversityRatio,n.MinTypedCoverage)),_=!s&&isCohesiveByNamingOrType(e,n,l);if(!s&&(List_length(e)<=n.GenericFunctionCount||_))return;{const t=o.toPosition(item(0,e).Anchor.startIndex);let r,s;return 1===l.tag?l.fields[0].Result?r=1:(r=0,s=l.fields[0]):r=1,functionCountViolation(List_length(e),0===r?(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)(s.DistinctTypes)):(a=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."))(a)),t,n)}}}function lineCount(e){let t;const n=List_tryFind(e=>!equals(e.type,"xml_doc"),List_reverse(nodeChildren(e.Body)));return(null==n?e.Body.endPosition.row:(t=Option_value(n),t.endPosition.row))-e.Anchor.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(item(0,o).Anchor.startIndex);return new EnergyViolation(e.Line,e.Column,ViolationType.Coherence,List_length(o)>t.MaxLargeFunctions*t.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 analyzeFileCoherence(e){const t=CoherenceCollection_collect(e.Tree,e.Language,e.FileName),n=t.FreeFunctions,r=List_filter(t=>!isRustTestCode(e.Language,e.FileName,t.Anchor),n),o=t.Classes,i=List_append(n,List_collect(e=>ofSeq(e.Methods),o));return addViolations(List_choose(e=>e,ofArray([checkFunctionCountSprawl(r,e.FileName,e.Options.Coherence,e.Language,e.Positions),checkLargeFunctionSprawl(i,e.Options.Coherence,e.Positions),check(t.Imports,t.FirstImportNode,e.Language,e.Positions,e.Options.Coherence),checkClassRelatedness(o,e.Options.Coherence.SingleDomainNameShare,e.Language,e.Positions),checkGodClass(o,new GodClassCtx(e.Language,e.Options.Coherence,e.Positions))])),e)}const Coherence_detector=new Detector("coherence",analyzeFileCoherence),NumberStyles={None:0,AllowLeadingWhite:1,AllowTrailingWhite:2,AllowLeadingSign:4,AllowTrailingSign:8,AllowParentheses:16,AllowDecimalPoint:32,AllowThousands:64,AllowExponent:128,AllowHexSpecifier:512,Integer:7,Number:111,Float:167};function digitsPattern(e){const t=e&NumberStyles.AllowThousands?"\\d+(?:,\\d*)*":"\\d+",n=e&NumberStyles.AllowDecimalPoint?"(?:\\.\\d*)?":"",r=e&NumberStyles.AllowDecimalPoint?"|\\.\\d+":"",o=e&NumberStyles.AllowExponent?"(?:[eE][+-]?\\d+)?":"";return new RegExp(`^(?:${t}${n}${r})${o}$`)}function splitNumber(e,t){if(t&NumberStyles.AllowHexSpecifier)throw new Exception("The number style AllowHexSpecifier is not supported on floating point data types.");let n=e.replace(/\0+$/,"");t&NumberStyles.AllowLeadingWhite&&(n=n.replace(/^[\t-\r ]+/,"")),t&NumberStyles.AllowTrailingWhite&&(n=n.replace(/[\t-\r ]+$/,""));let r=!1;if(t&NumberStyles.AllowParentheses&&n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1),r=!0),t&NumberStyles.AllowLeadingSign&&/^[+-]/.test(n)?(r="-"===n[0]?!r:r,n=n.slice(1)):t&NumberStyles.AllowTrailingSign&&/[+-]$/.test(n)&&(r="-"===n[n.length-1]?!r:r,n=n.slice(0,-1)),digitsPattern(t).test(n))return{digits:n.replace(/,/g,""),negative:r}}var Double_FSharpRef,Double_ArgumentNullException_$ctor_Z721C83C5,Double_FormatException_$ctor_Z721C83C5,Double_NumberStyles;const symbolRegex=/^[\t-\r \u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]*(?:[+-]?nan|([+-]?)infinity)[\t-\r \u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]*$/i,defaultStyle=NumberStyles.Float|NumberStyles.AllowThousands;function Double_tryParse(e,t,n){if(null!=e){const r=splitNumber(e,t);if(void 0!==r){const e=Number.parseFloat(r.digits);return n.contents=r.negative?-e:e,!0}const o=symbolRegex.exec(e);if(null!=o)return n.contents=null==o[1]?NaN:"-"===o[1]?-1/0:1/0,!0}return!1}function Double_parse(e,t=defaultStyle){const n=new Double_FSharpRef(0);if(Double_tryParse(e,t,n))return n.contents;throw null==e?Double_ArgumentNullException_$ctor_Z721C83C5("s"):Double_FormatException_$ctor_Z721C83C5(`The input string '${e}' was not in a correct format.`)}function parseIgnoringUnderscores(e){return Double_parse(null==e?e:e.replace(/_/g,""),Double_NumberStyles.Float)}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}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,a,s,l,_,u;switch(null!=o&&isNodeType(e.NodeTypes.ExpressionStatement,Option_value(o))?(i=0,a=Option_value(o)):(i=1,s=o),n=0===i?nodeParent(a):s,null!=n?isNodeType(e.NodeTypes.Module,Option_value(n))?(l=0,_=Option_value(n)):isNodeType(e.NodeTypes.ExportStatement,Option_value(n))?(l=1,u=Option_value(n)):l=2:l=2,l){case 0:return!hasEnclosingFunction(e,r);case 1:return Seq_exists(t=>isNodeType(e.NodeTypes.Module,t),toArray(nodeParent(u)));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 analyzeEnabledMagicNumbers(e){const t=n=>{let r,o;if(!e.Options.MagicNumber.IncludeTestFiles&&isRustTestModule(e.Language,n))return List_empty();if(r=n,isNodeType(e.Language.NodeTypes.IntegerLiteral,r)||isNodeType(e.Language.NodeTypes.FloatLiteral,r)){let t;const r=new FSharpRef(0);if(t=[Double_tryParse(e.Language.NumericLiteralText(n),231,r),r.contents],t[0]){if(List_contains(signedValue(n,t[1]),e.Options.MagicNumber.Allowlist,{Equals:(e,t)=>e===t,GetHashCode:e=>0|numberHash(e)})||e.Language.IsStructuralNumber(n)||isInConstantContext(e.Language,n)||Seq_exists(t=>List_contains(t.type,e.Language.SubscriptNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),toArray(nodeParent(n)))||e.Language.IsDefaultParameterValue(n))return List_empty();{const t=e.Positions.toPosition(n.startIndex);return List_singleton(new EnergyViolation(t.Line,t.Column,ViolationType.Magic,Severity.Low,(o=n.text,toText(printf("Magic number: %s. Consider extracting to a named constant."))(o)),List_empty()))}}return List_empty()}return List_collect(t,nodeChildren(n))};return addViolations(t(e.Tree),e)}function analyzeMagicNumbers(e){return!e.Options.MagicNumber.Enabled||!e.Options.MagicNumber.IncludeTestFiles&&isTestFile(e.FileName)?e:analyzeEnabledMagicNumbers(e)}const MagicNumber_detector=new Detector("magicNumber",analyzeMagicNumbers);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,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 decisionStringCandidate(e,t){let n;if(Seq_exists((n=t.type,e=>equals(n,e)),toArray(e.Language.NodeTypes.StringLiteral))){const n=stripQuotes(t.text),r=!(!isEqualityComparisonOperand(e.Language,t)&&!isMembershipOperand(e.Language,t,n))||isKeyOrIndexPosition(e.Language,t),o=!!(isDocstring(e.Language,t)||e.Language.IsFormattedOrInterpolatedString(t)||List_contains(n,e.Options.MagicString.Allowlist,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}))||n.length<=1;return r&&!o?List_singleton([t,n]):List_empty()}return List_empty()}function analyzeEnabledMagicStrings(e){const t=n=>!e.Options.MagicString.IncludeTestFiles&&isRustTestModule(e.Language,n)?List_empty():List_append(decisionStringCandidate(e,n),List_collect(t,nodeChildren(n)));return addViolations(List_choose(t=>{let n;const r=t[1];if(!(List_length(r)<e.Options.MagicString.MinDuplicates)){const o=List_head(r),i=e.Positions.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.'))(t[0])(n)),List_empty())}},List_groupBy(e=>e[1],t(e.Tree),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})),e)}function analyzeMagicStrings(e){return!e.Options.MagicString.Enabled||!e.Options.MagicString.IncludeTestFiles&&isTestFile(e.FileName)?e:analyzeEnabledMagicStrings(e)}const MagicString_detector=new Detector("magicString",analyzeMagicStrings);function findParametersNode(e,t){const n=List_tryFind(e=>equals(e.type,t),nodeChildren(e));return null==n?List_tryHead(List_collect(e=>ofArray(toArray(findParametersNode(e,t))),nodeChildren(e))):some(Option_value(n))}function ParameterCount_analyzeCallable(e,t){const n=0|List_length(t.Parameters);if(n>e.Options.ParameterCount.MediumThreshold){const r=e.Positions.toPosition(t.Anchor.startIndex);return List_singleton(new EnergyViolation(r.Line,r.Column,ViolationType.Parameters,n>e.Options.ParameterCount.HighThreshold?Severity.High:Severity.Medium,toText(printf("Parameter explosion: %d parameters. Consider using objects or builder pattern."))(n),List_empty()))}return List_empty()}function analyzeParameterCount(e){const t=n=>List_append(List_collect(t=>ParameterCount_analyzeCallable(e,t),e.Language.GetCallableViews(n)),List_collect(t,nodeChildren(n)));return addViolations(t(e.Tree),e)}const ParameterCount_detector=new Detector("parameterCount",analyzeParameterCount);var Range_delay,Range_unfold,fromZero,Range_op_Addition,toInt64_unchecked,toUInt64_unchecked,fromParts,op_Addition_1,ErrorShadowing_record_type,ErrorShadowing_int32_type,ErrorShadowing_float64_type,ErrorShadowing_string_type,ErrorShadowing_list_type,ErrorShadowing_obj_type,ErrorShadowing_Severity_$reflection,ErrorShadowing_ViolationType_$reflection,ErrorShadowing_ErrorShadowingModeThresholds_$reflection;function makeRangeStepFunction(e,t,n,r){const o=0|compare(e,n);if(0===o)throw Operators_InvalidArg("step","The step of a range cannot be zero.");const i=o>0;return n=>{const o=0|compare(n,t);return i&&o<=0||!i&&o>=0?[n,r(n,e)]:void 0}}function integralRangeStep(e,t,n,r,o){const i=makeRangeStepFunction(t,n,r,o);return delay(()=>Seq_unfold(i,e))}function rangeBigInt(e,t,n){return integralRangeStep(e,t,n,fromZero(),Range_op_Addition)}function rangeDecimal(e,t,n){return integralRangeStep(e,t,n,fromParts(0,0,0,!1,0),op_Addition_1)}function rangeDouble(e,t,n){return integralRangeStep(e,t,n,0,(e,t)=>e+t)}function rangeInt64(e,t,n){return integralRangeStep(e,t,n,0n,(e,t)=>toInt64_unchecked(Range_op_Addition(e,t)))}function rangeUInt64(e,t,n){return integralRangeStep(e,t,n,0n,(e,t)=>toUInt64_unchecked(Range_op_Addition(e,t)))}function rangeChar(e,t){const n=0|t.charCodeAt(0);return Range_delay(()=>Range_unfold(e=>e<=n?[String.fromCharCode(65535&e),e+1]:void 0,~~e.charCodeAt(0)))}function BodyLines_count(e,t,n){const r=e=>List_contains(e.type,ofArray(["comment","line_comment","block_comment"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})?List_singleton([e.startIndex,e.endIndex]):List_collect(r,nodeNamedChildren(e));return 0|Set_count(Set_ofList(List_collect(n=>{const o=r(n);return List_map(e=>0|t.toPosition(e).Line,List_filter(t=>!isWhiteSpace(getCharAtIndex(e,t))&&!List_exists(e=>t>=e[0]&&t<e[1],o),toList(rangeDouble(n.startIndex,1,n.endIndex-1))))},n),{Compare:(e,t)=>0|comparePrimitives(e,t)}))}const atFunctionRoot=!0,descendIntoBody=!1;function allFunctions(e,t){const n=t=>List_append(e.IsFunctionDefinition(t)?List_singleton(t):List_empty(),List_collect(n,nodeChildren(t)));return n(t)}function regionsInFunction(e,t){const n=(t,r)=>{let o;return!t&&e.IsFunctionDefinition(r)?List_empty():List_append(ofArray(toArray(e.GetErrorHandlingRegion(r))),(o=nodeChildren(r),List_collect(curry2(n)(descendIntoBody),o)))};return n(atFunctionRoot,t)}function expand(e,t){const n=e.GetErrorHandlingRegion(t);if(null==n)return List_singleton(t);{const t=n;return List_collect(t=>expand(e,t),List_append(t.ProtectedItems,t.RecoveryItems))}}function functionItems(e,t){return List_collect(t=>expand(e,t),e.GetFunctionLogicalItems(t))}const percentScale=100;class ModeMeasurement extends Record{constructor(e,t,n){super(),this.ItemCount=0|e,this.Share=t,this.Severity=n}}function ModeMeasurement_$reflection(){return ErrorShadowing_record_type("Energy.Core.Detectors.ErrorShadowing.ModeMeasurement",[],ModeMeasurement,()=>[["ItemCount",ErrorShadowing_int32_type],["Share",ErrorShadowing_float64_type],["Severity",ErrorShadowing_Severity_$reflection()]])}class MeasurementInput extends Record{constructor(e,t){super(),this.ItemCount=0|e,this.FunctionItemCount=0|t}}function MeasurementInput_$reflection(){return ErrorShadowing_record_type("Energy.Core.Detectors.ErrorShadowing.MeasurementInput",[],MeasurementInput,()=>[["ItemCount",ErrorShadowing_int32_type],["FunctionItemCount",ErrorShadowing_int32_type]])}function qualifies(e,t){if(!(t.ItemCount<e.MinItems||0===t.FunctionItemCount)){const n=t.ItemCount/t.FunctionItemCount;return n<e.Threshold?void 0:new ModeMeasurement(t.ItemCount,n,n>=e.HighThreshold?Severity.High:Severity.Medium)}}function finding(e,t,n,r,o){const i=e.Positions.toPosition(t.startIndex);return new EnergyViolation(i.Line,i.Column,n,r,o,List_empty())}class ShareRule extends Record{constructor(e,t,n,r,o){super(),this.Kind=e,this.Label=t,this.Advice=n,this.Thresholds=r,this.Items=o}}function ShareRule_$reflection(){return ErrorShadowing_record_type("Energy.Core.Detectors.ErrorShadowing.ShareRule",[],ShareRule,()=>[["Kind",ErrorShadowing_ViolationType_$reflection()],["Label",ErrorShadowing_string_type],["Advice",ErrorShadowing_string_type],["Thresholds",ErrorShadowing_ErrorShadowingModeThresholds_$reflection()],["Items",ErrorShadowing_list_type(ErrorShadowing_obj_type)]])}function shareFinding(e,t,n,r){let o,i,a;return ofArray(toArray((o=qualifies(r.Thresholds,new MeasurementInput(List_length(r.Items),n)),null!=o?(i=o,finding(e,t.Anchor,r.Kind,i.Severity,(a=0|round(i.Share*percentScale),toText(printf("%s: %d logical items (%d%%) of %d function logical items. %s"))(r.Label)(i.ItemCount)(a)(n)(r.Advice)))):void 0)))}function oversizedFindings(e,t){const n=e.Options.ErrorShadowing;return n.Enabled&&n.OversizedRecoveryBlockEnabled?List_choose(t=>{const r=0|BodyLines_count(e.Source,e.Positions,t.Items);return r<=n.RecoveryBlock.MaxLines?void 0:finding(e,t.Anchor,ViolationType.OversizedRecoveryBlock,Severity.Medium,toText(printf("Oversized recovery block: %d body lines exceeds the maximum of %d. Extract or simplify this handler or cleanup body."))(r)(n.RecoveryBlock.MaxLines))},t.RecoveryBodies):List_empty()}function boundaryFindings(e,t,n){const r=e.Options.ErrorShadowing,o=0|BodyLines_count(e.Source,e.Positions,n.ProtectedBody);return toList(delay(()=>Seq_append(shareFinding(e,n,t,new ShareRule(ViolationType.ErrorShadowing,"Broad protected scope","Narrow the protected region to operations this boundary can recover from.",r.ProtectedScope,n.ProtectedItems)),delay(()=>Seq_append(r.RecoveryDominanceEnabled&&o>1?shareFinding(e,n,t,new ShareRule(ViolationType.RecoveryDominance,"Recovery/cleanup dominance","Extract or simplify recovery and cleanup policy so the happy path remains clear.",r.Recovery,n.RecoveryItems)):Seq_empty(),delay(()=>oversizedFindings(e,n)))))))}function analyzeErrorShadowing(e){return addViolations(List_collect(t=>{const n=0|List_length(functionItems(e.Language,t));return List_collect(t=>boundaryFindings(e,n,t),regionsInFunction(e.Language,t))},allFunctions(e.Language,e.Tree)),e)}const ErrorShadowing_detector=new Detector("errorShadowing",analyzeErrorShadowing),inversionRatioThreshold=.5,deepIfDepthThreshold=3;function 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=>hasType(e.NodeTypes.Block,t),nodeChildren(t));return null==n?List_tryFind(t=>hasType(e.NodeTypes.Block,t),List_collect(nodeChildren,nodeChildren(t))):some(Option_value(n))}function functionStatements(e,t){return List_filter(t=>!hasType(e.NodeTypes.Comment,t)&&!List_contains(t.type,ofArray(["line_comment","block_comment"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&!isNullOrWhiteSpace(t.text),nodeNamedChildren(t))}function hasElse(e,t){return!List_isEmpty(e.GetElseIfBranches(t))||List_exists(t=>!!hasType(e.NodeTypes.ElseClause,t)||equals(t.type,"else"),nodeChildren(t))}function terminalConditional(e,t){const n=functionStatements(e,t);let r,o,i,a;switch(List_isEmpty(n)?r=2:List_isEmpty(List_tail(n))?hasType(e.NodeTypes.IfStatement,List_head(n))?(r=0,o=List_head(n)):r=2:List_isEmpty(List_tail(List_tail(n)))&&hasType(e.NodeTypes.IfStatement,List_head(n))&&List_contains(List_head(List_tail(n)).type,ofArray(["return_statement","return_expression"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})?(r=1,i=List_head(List_tail(n)),a=List_head(n)):r=2,r){case 0:return some(o);case 1:return some(a);default:return}}function guardChain(e,t){let n;if(hasElse(e,t))return List_empty();{const r=defaultArg((n=List_tryFind(t=>hasType(e.NodeTypes.Block,t),nodeChildren(t)),null!=n?functionStatements(e,Option_value(n)):void 0),List_empty());let o,i;return List_isEmpty(r)?o=1:List_isEmpty(List_tail(r))&&hasType(e.NodeTypes.IfStatement,List_head(r))?(o=0,i=List_head(r)):o=1,0===o?cons(t,guardChain(e,i)):List_singleton(t)}}function deeper(e,t,n,r){const o=[e,t],i=[n,r];return compare(i[0],o[0])>0?i:o}function deepestIfNode(e,t,n){let r,o;const i=e.GetCognitiveStructure(t);if(e.IsFunctionDefinition(t)||equals(i,CognitiveStructure.Closure))return[0,void 0];{const a=!!hasType(e.NodeTypes.IfStatement,t)||Seq_exists(n=>List_exists(e=>e.id===t.id,e.GetElseIfBranches(n)),toArray(nodeParent(t))),s=a?[n+1,some(t)]:[0,void 0],l=null!=i&&0===i.tag?1===i.fields[0].tag?(r=i.fields[1],r):(i.fields[1],a?(o=i.fields[1],o):List_empty()):List_empty();return List_fold((e,t)=>deeper(e[0],e[1],t[0],t[1]),s,List_map(t=>deepestIfNode(e,t,List_exists(e=>e.id===t.id,l)?n+1:n),nodeChildren(t)))}}function dominantBody(e,t,n){return Seq_exists(n=>{const r=(n.endIndex-n.startIndex)/(t.endIndex-t.startIndex);return List_length(functionStatements(e,n))>2&&r>inversionRatioThreshold},toArray(List_tryFind(t=>hasType(e.NodeTypes.Block,t),nodeChildren(n))))}function recommendation(e,t,n){let r,o;const i=defaultArg((r=terminalConditional(e,n),null!=r?guardChain(e,Option_value(r)):void 0),List_empty());let a,s,l;switch(List_isEmpty(i)?a=2:List_length(i)>=2?(a=0,s=List_head(i)):List_isEmpty(List_tail(i))&&dominantBody(e,t,List_head(i))?(a=1,l=List_head(i)):a=2,a){case 0:return[s,(o=0|List_length(i),toText(printf("These %d nested conditions keep the main operation indented. Consider guard clauses, preserving the existing return values and fallthrough behavior."))(o))];case 1:return[l,"This condition encloses most of the function. Consider a guard clause to bring the main operation to the top level, preserving the existing return values and fallthrough behavior."];default:{const t=deepestIfNode(e,n,0),r=0|t[0];let o;const i=t[1];return o=null!=i?(Option_value(i),r>=deepIfDepthThreshold?i:void 0):void 0,null!=o?[Option_value(o),toText(printf("These conditions are nested %d levels deep. Consider extracting a named operation to reduce how many conditions readers must track."))(r)]:void 0}}}function analyzeInversionOpportunities(e){const t=n=>{let r,o,i,a;return List_append(e.Language.IsFunctionDefinition(n)?ofArray(toArray((o=findBody(e.Language,n),r=null!=o?recommendation(e.Language,n,Option_value(o)):void 0,null!=r?(i=r,a=e.Positions.toPosition(i[0].startIndex),new EnergyViolation(a.Line,a.Column,ViolationType.Inversion,Severity.Medium,i[1],List_empty())):void 0))):List_empty(),List_collect(t,nodeChildren(n)))};return addViolations(t(e.Tree),e)}const Inversion_detector=new Detector("inversion",analyzeInversionOpportunities);function MatchOpportunitySupport_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,a;return defaultArg((o=null==e.NodeTypes.ElseClause?List_tryFind(t=>MatchOpportunitySupport_hasType(e.NodeTypes.IfStatement,t),nodeChildren(t)):(i=List_tryFind(t=>MatchOpportunitySupport_hasType(e.NodeTypes.ElseClause,t),nodeChildren(t)),null!=i?List_tryFind(t=>MatchOpportunitySupport_hasType(e.NodeTypes.IfStatement,t),nodeChildren(Option_value(i))):void 0),null!=o?(a=Option_value(o),n(a,cons(a,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=>e.IsMatchCaseLiteral(t),i=t=>MatchOpportunitySupport_hasType(e.NodeTypes.StringLiteral,t)?MatchOpportunitySupport_stripQuotes(t.text):t.text,a=n=>FSharpSet__Contains(t,n.id)||MatchOpportunitySupport_hasType(e.NodeTypes.Block,n)||MatchOpportunitySupport_hasType(e.NodeTypes.ElseClause,n)?List_empty():List_append(List_collect(e=>{const t=r(e.Left),n=o(e.Right),a=r(e.Right),s=o(e.Left);let l;switch(l=t&&n?0:a&&s?1:2,l){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(a,nodeChildren(n))));return a(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)))}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){const t=(n,r)=>{let o,i,a,s;if(MatchOpportunitySupport_hasType(e.Language.NodeTypes.IfStatement,r)&&!FSharpSet__Contains(n,r.id)){const t=collectChainBranches(e.Language,r),a=List_fold((e,t)=>FSharpSet__Add(e,t.id),n,List_tail(t)),l=List_map(n=>collectDiscriminants(e.Language,otherBranchIds(n,t),n),t);s=[ofArray(toArray((o=List_forAll(e=>!List_isEmpty(e),l),o&&List_length(t)>=e.Options.MatchOpportunity.MinBranches?(i=commonDiscriminant(l),null!=i?matchOpportunityViolation(e.Positions,r,t,i):void 0):void 0))),a]}else s=[List_empty(),n];return List_append(s[0],(a=nodeChildren(r),List_collect(curry2(t)(s[1]),a)))};return addViolations(t(Set_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}),e.Tree),e)}const MatchOpportunity_detector=new Detector("matchOpportunity",analyzeMatchOpportunities);function analyzeLogicalControlFlow(e){const t=n=>{let r,o,i,a,s,l,_,u,c,d;return List_append((r=e.Language.GetBooleanOperator(n),o=nodeParent(n),null!=r?1===r.tag?null!=o?(i=Option_value(o),Seq_exists((a=i.type,e=>equals(a,e)),toArray(e.Language.NodeTypes.ExpressionStatement))?(s=Option_value(o),l=e.Positions.toPosition(n.startIndex),List_singleton(new EnergyViolation(l.Line,l.Column,ViolationType.LogicalControlFlow,Severity.Low,"If-statement disguised as '||'. Consider an explicit if-statement instead.",List_empty()))):List_empty()):List_empty():null!=o?(_=Option_value(o),Seq_exists((u=_.type,e=>equals(u,e)),toArray(e.Language.NodeTypes.ExpressionStatement))?(c=Option_value(o),d=e.Positions.toPosition(n.startIndex),List_singleton(new EnergyViolation(d.Line,d.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(t,nodeChildren(n)))};return addViolations(t(e.Tree),e)}const LogicalControlFlow_detector=new Detector("logicalControlFlow",analyzeLogicalControlFlow);function analyzeEnabledOpaqueBooleans(e){const t=n=>{let r,o;return!e.Options.OpaqueBoolean.IncludeTestFiles&&isRustTestModule(e.Language,n)?List_empty():List_append(e.Language.IsBooleanLiteral(n)&&e.Language.IsPositionalCallArgument(n)?(r=e.Positions.toPosition(n.startIndex),List_singleton(new EnergyViolation(r.Line,r.Column,ViolationType.OpaqueBoolean,Severity.Low,(o=n.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."))(o)),List_empty()))):List_empty(),List_collect(t,nodeChildren(n)))};return addViolations(t(e.Tree),e)}function analyzeOpaqueBooleanLiteral(e){return!e.Options.OpaqueBoolean.Enabled||!e.Options.OpaqueBoolean.IncludeTestFiles&&isTestFile(e.FileName)?e:analyzeEnabledOpaqueBooleans(e)}const OpaqueBoolean_detector=new Detector("opaqueBoolean",analyzeOpaqueBooleanLiteral);function descendants(e){return cons(e,List_collect(descendants,nodeChildren(e)))}function parameters(e,t){let n;return List_map(t=>{const n=e.ExtractTypedParameter(t);if(null==n)return[t.text,void 0];{const e=n;return[e.Name,e.Type]}},defaultArg((n=findParametersNode(t.ParametersRoot,e.NodeTypes.Parameters),null!=n?nodeNamedChildren(Option_value(n)):void 0),List_empty()))}function rejectsNull(e,t,n){const r=nodeChildren(n);return!(!List_exists(n=>n.text===t&&List_contains(n.type,e.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),r)||!List_exists(e=>List_contains(e.text,ofArray(["null","None","nil","nullptr"]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),r))&&List_exists(e=>List_contains(e.text,ofArray(["==","===","is","="]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),r)}function checkedParameter(e,t,n){const r=descendants(n.Condition),o=e.ExtractReturnType(t.ParametersRoot);return List_tryFind(t=>{const i=t[0];if(!List_exists(t=>!!List_contains(t.type,e.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&t.text===i,r))return!1;{const r=n.Success;switch(r.tag){case 0:{const a=r.fields[0];return!(a.text!==i||!List_contains(a.type,e.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||0===n.IdentityReturnPolicy.tag&&!Seq_exists(e=>Seq_forAll(t=>e===t,toArray(o)),toArray(t[1]))||rejectsNull(e,i,n.Condition))}case 2:return!0;default:return Seq_forAll(e=>List_contains(e,ofArray(["None","unit","Unit","void","undefined"]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),toArray(o))}}},parameters(e,t))}function inspect(e,t){let n,r,o,i,a,s,l;return ofArray(toArray((n=e.Language.GetGuardedValidation(t),null!=n?(r=n,o=checkedParameter(e.Language,t,r),null!=o?(i=o,a=e.Positions.toPosition(r.Anchor.startIndex),new EnergyViolation(a.Line,a.Column,ViolationType.ParseDontValidate,Severity.Low,(l=r.Success,s=0===l.tag?"returned unchanged":2===l.tag?"success returns only a boolean":"success returns no useful value",toText(printf("Parse, don't validate: '%s' is checked but %s. Consider returning a domain type that preserves the checked property instead of requiring callers to remember it."))(i[0])(s)),List_empty())):void 0):void 0)))}function analyzeParseDontValidate(e){const t=n=>List_append(e.Language.IsFunctionDefinition(n)?List_collect(t=>inspect(e,t),e.Language.GetFunctionHeads(n)):List_empty(),List_collect(t,nodeNamedChildren(n)));return addViolations(t(e.Tree),e)}const ParseDontValidate_detector=new Detector("parseDontValidate",analyzeParseDontValidate);var PrimitiveObsession_record_type,PrimitiveObsession_string_type,PrimitiveObsession_obj_type,PrimitiveObsession_bool_type;const minDistinctValues=3,sampleSize=4,booleanTypeNames=Set_ofList(ofArray(["bool","boolean","Boolean"]),{Compare:(e,t)=>0|comparePrimitives(e,t)});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 findSwapRiskViolations(e,t,n){return List_map(e=>{const r=e[0],o=e[1];return new EnergyViolation(t.toPosition(r.Node.startIndex).Line,t.toPosition(r.Node.startIndex).Column,ViolationType.PrimitiveObsession,Severity.Medium,`Primitive obsession: consecutive parameters '${r.Name}: ${r.Type}' and '${o.Name}: ${o.Type}' share the same primitive type — a caller can swap them and nothing will complain. Consider ${n.DistinctTypeAdvice} so the type checker catches it.`,List_empty())},List_filter(e=>{const t=e[0],r=e[1];return!(t.Type!==r.Type||!Set_contains(t.Type,n.PrimitiveTypeNames)||Set_contains(t.Type,booleanTypeNames)||t.KeywordOnly&&r.KeywordOnly)},List_pairwise(e)))}function findBooleanBlindness(e,t){const n=List_filter(e=>!!Set_contains(e.Type,booleanTypeNames)&&!e.KeywordOnly,e);let r,o,i;if(List_isEmpty(n)||List_isEmpty(List_tail(n))?r=1:(r=0,o=n,i=List_head(n)),0===r){const e=0|List_length(o),n=join(", ",List_map(e=>e.Name,o)),r=e>2?", ...":"";return new EnergyViolation(t.toPosition(i.Node.startIndex).Line,t.toPosition(i.Node.startIndex).Column,ViolationType.PrimitiveObsession,Severity.Medium,`Boolean blindness: this signature takes ${interpolate("%d%P()",[e])} boolean parameters (${n}), adjacent or not — a call site like f(true, false${r}) doesn't say which flag is which, and combinations invalid in this domain still type-check. Consider a single enum or union naming the valid combinations instead of independent booleans.`,List_empty())}}function findParameterCollisions(e,t,n){const r=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];return List_append(findSwapRiskViolations(r,t,n),ofArray(toArray(findBooleanBlindness(r,t))))}function PrimitiveObsession_stripQuotes(e){return substring(e,1,e.length-2)}function stringEquality(e,t){const n=t=>List_contains(t.type,e.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),r=t=>{let n;return Seq_exists((n=t.type,e=>equals(n,e)),toArray(e.NodeTypes.StringLiteral))},o=n(t.Left),i=r(t.Right),a=n(t.Right),s=r(t.Left);let l;switch(l=o&&i?0:a&&s?1:2,l){case 0:return[t.Left,PrimitiveObsession_stripQuotes(t.Right.text)];case 1:return[t.Right,PrimitiveObsession_stripQuotes(t.Left.text)];default:return}}function recordStringValues(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)}}function findStringlyTypedControlFlow(e,t,n){const r=(e,t)=>{let o;const i=List_fold((e,t)=>List_contains(t.Left.type,n.VariableReferenceNodeTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&!List_isEmpty(t.Values)?recordStringValues(t.Left,t.Values,e):e,List_fold((e,t)=>recordStringValues(t[0],List_singleton(t[1]),e),t,List_choose(e=>stringEquality(n,e),n.GetEqualityComparisons(e))),n.GetMembershipComparisons(e));return List_fold((e,t)=>r(t,e),(o=n.GetMatchStringCases(e),null==o?i:recordStringValues(o[0],List_map(e=>PrimitiveObsession_stripQuotes(e.text),o[1]),i)),nodeChildren(e))};return List_choose(e=>{let n,r;const o=e[1],i=o[0];if(!(Set_count(i)<minDistinctValues)){const a=t.toPosition(o[1].startIndex),s=List_truncate(sampleSize,Set_toList(i)),l=Set_count(i)>List_length(s)?", …":"";return new EnergyViolation(a.Line,a.Column,ViolationType.PrimitiveObsession,Severity.Low,(n=0|Set_count(i),r=join(", ",s),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)(l)),List_empty())}},Map_toList(r(e,Map_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}))))}function analyzePrimitiveObsession(e){const t=n=>List_append(e.Language.IsFunctionDefinition(n)?List_collect(t=>{let n;return List_append((n=findParametersNode(t.ParametersRoot,e.Language.NodeTypes.Parameters),null==n?List_empty():findParameterCollisions(Option_value(n),e.Positions,e.Language)),findStringlyTypedControlFlow(t.Body,e.Positions,e.Language))},e.Language.GetFunctionHeads(n)):List_empty(),List_collect(t,nodeChildren(n)));return addViolations(t(e.Tree),e)}const PrimitiveObsession_detector=new Detector("primitiveObsession",analyzePrimitiveObsession);function runWhen(e,t,n){return e?t(n):n}function detectorPipeline(e){return runWhen(e.Options.Nesting.Enabled,detector.Run,runWhen(e.Options.Cyclomatic.Enabled,Cyclomatic_detector.Run,runWhen(e.Options.Cognitive.Enabled,Cognitive_detector.Run,runWhen(e.Options.Coherence.Enabled,Coherence_detector.Run,runWhen(e.Options.MagicNumber.Enabled,MagicNumber_detector.Run,runWhen(e.Options.MagicString.Enabled,MagicString_detector.Run,runWhen(e.Options.ParameterCount.Enabled,ParameterCount_detector.Run,runWhen(e.Options.ErrorShadowing.Enabled,ErrorShadowing_detector.Run,runWhen(e.Options.Inversion.Enabled,Inversion_detector.Run,runWhen(e.Options.MatchOpportunity.Enabled,MatchOpportunity_detector.Run,runWhen(e.Options.LogicalControlFlow.Enabled,LogicalControlFlow_detector.Run,runWhen(e.Options.OpaqueBoolean.Enabled,OpaqueBoolean_detector.Run,runWhen(e.Options.ParseDontValidate.Enabled,ParseDontValidate_detector.Run,runWhen(e.Options.PrimitiveObsession.Enabled,PrimitiveObsession_detector.Run,e))))))))))))))}var Analyze_defaultAnalyzeOptions,Analyze_record_type,Analyze_string_type,Analyze_obj_type,Analyze_list_type,Analyze_union_type,Analyze_LanguageAdapter_$reflection,Analyze_EnergyViolation_$reflection;const defaultThresholds=null;class AnalysisInput extends Record{constructor(e,t,n,r){super(),this.Source=e,this.Tree=t,this.Language=n,this.FileName=r}}function AnalysisInput_$reflection(){return Analyze_record_type("Energy.Core.Analyze.AnalysisInput",[],AnalysisInput,()=>[["Source",Analyze_string_type],["Tree",Analyze_obj_type],["Language",Analyze_LanguageAdapter_$reflection()],["FileName",Analyze_string_type]])}class AnalysisResult extends Record{constructor(e){super(),this.Violations=e}}function AnalysisResult_$reflection(){return Analyze_record_type("Energy.Core.Analyze.AnalysisResult",[],AnalysisResult,()=>[["Violations",Analyze_list_type(Analyze_EnergyViolation_$reflection())]])}class AnalysisError extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["UnsupportedLanguage","ConfigurationFailed","SourceReadFailed","GrammarLoadFailed","ParseFailed","AnalysisFailed","ReportWriteFailed"]}}function AnalysisError_$reflection(){return Analyze_union_type("Energy.Core.Analyze.AnalysisError",[],AnalysisError,()=>[[["filePath",Analyze_string_type]],[["message",Analyze_string_type]],[["filePath",Analyze_string_type],["message",Analyze_string_type]],[["languageId",Analyze_string_type],["message",Analyze_string_type]],[["filePath",Analyze_string_type],["message",Analyze_string_type]],[["filePath",Analyze_string_type],["message",Analyze_string_type]],[["filePath",Analyze_string_type],["message",Analyze_string_type]]])}function analysisErrorMessage(e){switch(e.tag){case 1:return e.fields[0];case 2:return"Could not read "+e.fields[0]+": "+e.fields[1];case 3:return"Could not load "+e.fields[0]+" grammar: "+e.fields[1];case 4:return"Could not parse "+e.fields[0]+": "+e.fields[1];case 5:return"Could not analyze "+e.fields[0]+": "+e.fields[1];case 6:return"Could not write report "+e.fields[0]+": "+e.fields[1];default:return"Unsupported file type: "+e.fields[0]}}function applySuppressionStage(e,t){const n=applySuppressions(t,e.Source);return List_append(n.Violations,n.SuppressionNotes)}function runPipeline(e){const t=detectorPipeline(e);return applySuppressionStage(t,List_reverse(t.Violations))}function createContext(e,t){return new AnalysisContext(t.Source,t.Tree,createPositionLookup(t.Source),t.Language,t.FileName,e,List_empty())}function toResult(e){return new AnalysisResult(e)}function analyze(e){return toResult(runPipeline(createContext(Analyze_defaultAnalyzeOptions,e)))}function analyzeWith(e,t){return toResult(runPipeline(createContext(e,t)))}function isConditional(e){return List_contains(e.type,ofArray(["if_statement","if_expression"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})}function isElif(e){return List_contains(e.type,ofArray(["elif_clause","elif_expression"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})}function significantChildren(e){return List_filter(e=>!List_contains(e.type,ofArray(["comment","line_comment","block_comment"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(e))}function afterElse(e){return List_tryItem(1,List_skipWhile(e=>!equals(e.type,"else"),significantChildren(e)))}function isElseIf(e){return Seq_exists(t=>!!equals(t.type,"else_clause")||!!isConditional(t)&&Seq_exists(t=>t.id===e.id,toArray(afterElse(t))),toArray(nodeParent(e)))}function nestedChildren(e){let t,n;const r=nodeNamedChildren(e),o=List_choose(t=>nodeField(t,e),ofArray(["body","consequence","then","else","alternative","block"]));return List_filter(e=>!(equals(e.type,"else_clause")||isElif(e)||isConditional(e)&&isElseIf(e)),List_isEmpty(o)?isConditional(e)||isElif(e)?(n=nodeField("condition",e),t=null!=n?n:nodeField("guard",e),List_filter(e=>Seq_forAll(t=>t.id!==e.id,toArray(t)),r)):equals(e.type,"when_expression")?List_filter(e=>equals(e.type,"when_entry"),r):equals(e.type,"do_while_statement")?List_truncate(1,r):List_truncate(1,List_reverse(r)):o)}function isCatchRule(e){let t;return!!equals(e.type,"rule")&&Seq_exists(e=>equals(e.type,"try_expression"),toArray((t=nodeParent(e),null!=t?nodeParent(Option_value(t)):void 0)))}function isLabelJump(e){const t=e.type;let n;switch(n="goto_statement"===t?0:"break_statement"===t||"continue_statement"===t?1:"labeled_expression"===t?2:3,n){case 0:return!0;case 1:return!List_isEmpty(nodeNamedChildren(e));case 2:return Seq_exists(e=>"break@"===e.text||"continue@"===e.text,toArray(List_tryHead(nodeNamedChildren(e))));default:return!1}}function classify(e,t){let n,r;const o=t.type;let i;switch(i="parenthesized_expression"===o||"paren_expression"===o?0:"arrow_function"===o||"lambda"===o||"lambda_expression"===o||"lambda_literal"===o||"fun_expression"===o||"function_expression"===o||"anonymous_method_expression"===o?1:"else_clause"===o?2:"else"===o?3:"ternary_expression"===o?isElif(t)||isConditional(t)&&isElseIf(t)?4:List_contains(t.type,e,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||isCatchRule(t)?5:6:"conditional_expression"===o?isElif(t)||isConditional(t)&&isElseIf(t)?4:List_contains(t.type,e,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||isCatchRule(t)?5:6:isElif(t)||isConditional(t)&&isElseIf(t)?4:List_contains(t.type,e,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||isCatchRule(t)?5:isLabelJump(t)?7:8,i){case 0:{const e=List_tryExactlyOne(nodeNamedChildren(t));return null!=e?new CognitiveStructure(2,[Option_value(e)]):void 0}case 1:return CognitiveStructure.Closure;case 2:return Seq_exists(e=>equals(e.type,"try_statement"),toArray(nodeParent(t)))||Seq_exists(isConditional,toArray(afterElse(t)))?void 0:new CognitiveStructure(0,[CognitiveIncrement.Hybrid,nodeNamedChildren(t)]);case 3:{const e=nodeParent(t);let r,o;return null!=e?(n=Option_value(e),isConditional(n)&&!Seq_exists(isConditional,toArray(afterElse(n)))?(r=0,o=Option_value(e)):r=1):r=1,0===r?new CognitiveStructure(0,[CognitiveIncrement.Fundamental,List_empty()]):void 0}case 4:return new CognitiveStructure(0,[CognitiveIncrement.Hybrid,nestedChildren(t)]);case 5:return new CognitiveStructure(0,[CognitiveIncrement.Structural,nestedChildren(t)]);case 6:{const e=List_choose(e=>nodeField(e,t),ofArray(["consequence","alternative"]));return new CognitiveStructure(0,[CognitiveIncrement.Structural,List_isEmpty(e)?(r=nodeNamedChildren(t),List_choose(e=>e,ofArray([List_tryHead(r),List_tryLast(r)]))):e])}case 7:return new CognitiveStructure(0,[CognitiveIncrement.Fundamental,List_empty()]);default:return}}const comparisonOperatorNodeType="comparison_operator",importFromStatementNodeType="import_from_statement",fromPrefix="from ",importSeparator=" import ",importPrefix="import ",aliasedImportPartCount=3;function collectStringValues(e){const t=List_fold((e,t)=>{const n=e[1];if(e[0])return[!0,n];if(t.isNamed){if(equals(t.type,"string")){const e=t.text;return[!1,List_append(n,List_singleton(substring(e,1,e.length-2)))]}return[!0,n]}return[!1,n]},[!1,List_empty()],nodeChildren(e)),n=t[1];return t[0]||List_isEmpty(n)?void 0:n}function membershipComparison(e,t,n){const r=item(t,e),o=item(n,e);if(List_contains(o.type,ofArray(["tuple","list","set"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})){const e=collectStringValues(o);return null!=e?new MembershipComparison(r,e):void 0}}function membershipComparisons(e){if(equals(e.type,comparisonOperatorNodeType)){const t=nodeChildren(e);return List_choose(e=>membershipComparison(t,e[0],e[1]),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()}function importBinding(e){const t=String_split(e,[" "],void 0,1),n=Array_item(0,t);return new ImportBinding(n,t.length>=aliasedImportPartCount&&"as"===Array_item(1,t)?Array_item(2,t):n)}function importedMembers(e,t){const n=substring(e,fromPrefix.length,t-fromPrefix.length).trim(),r=trim(substring(e,t+importSeparator.length).trim(),"(",")");return List_singleton("*"===r?new ImportInfo(ImportKind.Wildcard,n,List_empty()):new ImportInfo(ImportKind.Members,n,List_map(importBinding,List_filter(e=>""!==e,List_map(e=>e.trim(),ofArray(String_split(r,[","],void 0,0)))))))}function importFromInfo(e){const t=e.text,n=0|indexOf(t,importSeparator,4);return n>fromPrefix.length?importedMembers(t,n):List_singleton(new ImportInfo(ImportKind.Members,t,List_empty()))}function moduleImport(e){return new ImportInfo(ImportKind.Module,Array_item(0,String_split(e.trim(),[" "],void 0,1)),List_empty())}function importInfo(e){return equals(e.type,importFromStatementNodeType)?importFromInfo(e):List_map(moduleImport,ofArray(String_split(substring(e.text,importPrefix.length),[","],void 0,0)))}function staticAllNames(e){let t;const n=nodeNamedChildren(e);let r,o;if(List_isEmpty(n)?r=1:List_isEmpty(List_tail(n))&&equals(List_head(n).type,"assignment")?(r=0,o=List_head(n)):r=1,0===r){const e=nodeField("left",o),n=nodeField("right",o);let r,i,a;if(null!=e&&null!=n?(Option_value(n),t=Option_value(e),"__all__"===t.text?(r=0,i=Option_value(e),a=Option_value(n)):r=1):r=1,0===r){if(List_contains(a.type,ofArray(["list","tuple"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})){const e=nodeNamedChildren(a);return List_forAll(e=>equals(e.type,"string"),e)?List_map(e=>trim(e.text,"'",'"'),e):void 0}return}return}}function isFacadeItem(e){const t=e.type;let n;switch(n="import_statement"===t||"import_from_statement"===t||"comment"===t?0:"expression_statement"===t?1:2,n){case 0:return!0;case 1:return!!List_exists(e=>equals(e.type,"string"),nodeNamedChildren(e))||null!=staticAllNames(e);default:return!1}}function sameNameAliases(e){return List_choose(e=>{let t,n;const r=nodeField("name",e),o=nodeField("alias",e);let i,a,s;if(null!=r&&null!=o?(t=Option_value(r),n=Option_value(o),t.text===n.text?(i=0,a=Option_value(o),s=Option_value(r)):i=1):i=1,0===i)return a.text},List_filter(e=>equals(e.type,"aliased_import"),nodeNamedChildren(e)))}function isReExport(e,t){let n;if("__init__.py"===last(String_split(String_replace(e,"\\","/"),["/"],void 0,0))&&equals(t.type,importFromStatementNodeType)){const e=nodeParent(t),r=nodeField("module_name",t);let o,i,a;if(null!=e&&null!=r?(Option_value(r),n=Option_value(e),equals(n.type,"module")?(o=0,i=Option_value(e),a=Option_value(r)):o=1):o=1,0===o){const e=nodeNamedChildren(i);let n;const r=Set_ofList(List_collect(e=>e,List_choose(staticAllNames,e)),{Compare:(e,t)=>0|comparePrimitives(e,t)});n=union(Set_ofList(sameNameAliases(t),{Compare:(e,t)=>0|comparePrimitives(e,t)}),r);const o=List_collect(e=>e.Bindings,importFromInfo(t));return!(!equals(a.type,"relative_import")||!List_forAll(isFacadeItem,e)||List_isEmpty(o))&&List_forAll(e=>FSharpSet__Contains(n,e.LocalName),o)}return!1}return!1}var ValidationSyntax_record_type,ValidationSyntax_list_type,ValidationSyntax_string_type,ValidationSyntax_option_type,ValidationSyntax_lambda_type,ValidationSyntax_obj_type,ValidationSyntax_bool_type,ValidationSyntax_BooleanLiteralPolarity_$reflection;class GuardSyntax extends Record{constructor(e,t,n,r,o,i,a,s,l){super(),this.Containers=e,this.Conditional=t,this.Rejections=n,this.Return=r,this.FailureCalls=o,this.EmptyValues=i,this.IsNonExecutable=a,this.BooleanLiteralValue=s,this.PreservesCheckedInformation=l}}function GuardSyntax_$reflection(){return ValidationSyntax_record_type("Energy.Languages.ValidationSyntax.GuardSyntax",[],GuardSyntax,()=>[["Containers",ValidationSyntax_list_type(ValidationSyntax_string_type)],["Conditional",ValidationSyntax_string_type],["Rejections",ValidationSyntax_list_type(ValidationSyntax_string_type)],["Return",ValidationSyntax_option_type(ValidationSyntax_string_type)],["FailureCalls",ValidationSyntax_list_type(ValidationSyntax_string_type)],["EmptyValues",ValidationSyntax_list_type(ValidationSyntax_string_type)],["IsNonExecutable",ValidationSyntax_lambda_type(ValidationSyntax_obj_type,ValidationSyntax_bool_type)],["BooleanLiteralValue",ValidationSyntax_lambda_type(ValidationSyntax_obj_type,ValidationSyntax_option_type(ValidationSyntax_BooleanLiteralPolarity_$reflection()))],["PreservesCheckedInformation",ValidationSyntax_lambda_type(ValidationSyntax_obj_type,ValidationSyntax_lambda_type(ValidationSyntax_option_type(ValidationSyntax_obj_type),ValidationSyntax_bool_type))]])}function children(e,t){return List_filter(t=>!List_contains(t.type,ofArray(["comment","line_comment","block_comment"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&!e.IsNonExecutable(t),nodeNamedChildren(t))}function statements(e,t){return List_contains(t.type,e.Containers,{Equals:equals,GetHashCode:e=>0|safeHash(e)})?List_collect(t=>statements(e,t),children(e,t)):List_singleton(t)}function callee(e,t){e:for(;;){const n=e,r=t;if(equals(r.type,"application_expression")){const o=List_tryHead(children(n,r));if(null!=o){e=n,t=Option_value(o);continue e}return}return r.text}}function rejects(e,t){let n;const r=statements(e,t);let o,i;if(List_isEmpty(r)?o=1:List_isEmpty(List_tail(r))?(o=0,i=List_head(r)):o=1,0===o){if(List_contains(i.type,e.Rejections,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||equals(i.type,"application_expression")&&Seq_exists(t=>List_contains(t,e.FailureCalls,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),toArray(callee(e,i))))return!0;{const t=i,r=e.Return;let o,a;if(null!=r?(n=r,equals(t.type,n)?(o=0,a=r):o=1):o=1,0===o){const n=children(e,t);let r,o;return List_isEmpty(n)?r=1:List_isEmpty(List_tail(n))?(r=0,o=List_head(n)):r=1,0===r&&equals(e.BooleanLiteralValue(o),BooleanLiteralPolarity.LiteralFalse)}return!1}}return!1}function ValidationSyntax_classify(e,t){const n=e.BooleanLiteralValue(t);return new ValidationSuccess(null==n?0:2,[t])}function success(e,t){let n;const r=e.Return;if(null==r)return List_contains(t.text,e.EmptyValues,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})?ValidationSuccess.NoValue:ValidationSyntax_classify(e,t);if(n=r,equals(t.type,n)){const n=children(e,t);return List_isEmpty(n)?ValidationSuccess.NoValue:List_isEmpty(List_tail(n))?List_contains(List_head(n).text,e.EmptyValues,{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})?ValidationSuccess.NoValue:ValidationSyntax_classify(e,List_head(n)):void 0}}function bodyItems(e,t){return List_contains(t.Body.type,e.Containers,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||equals(t.Body.type,e.Conditional)?statements(e,t.Body):List_collect(t=>statements(e,t),List_filter(t=>!!List_contains(t.type,e.Containers,{Equals:equals,GetHashCode:e=>0|safeHash(e)})||equals(t.type,e.Conditional),children(e,t.Body)))}function extract(e,t){let n,r;const o=e.PreservesCheckedInformation(t.ParametersRoot,void 0)?List_empty():bodyItems(e,t);let i,a,s,l;switch(List_isEmpty(o)?i=2:List_isEmpty(List_tail(o))?(i=0,a=List_head(o)):List_isEmpty(List_tail(List_tail(o)))?(i=1,s=List_head(o),l=List_head(List_tail(o))):i=2,i){case 0:r=[a,ValidationSuccess.NoValue];break;case 1:{const t=success(e,l);r=null!=t?[s,t]:void 0;break}default:r=void 0}if(null!=r){const t=r,o=t[0];if(equals(o.type,e.Conditional)){const r=children(e,o);let i,a,s,l,_,u;switch(List_isEmpty(r)||List_isEmpty(List_tail(r))?i=2:List_isEmpty(List_tail(List_tail(r)))?rejects(e,List_head(List_tail(r)))?(i=0,a=List_head(r),s=List_head(List_tail(r))):i=2:List_isEmpty(List_tail(List_tail(List_tail(r))))&&equals(e.BooleanLiteralValue(List_head(List_tail(r))),BooleanLiteralPolarity.LiteralFalse)?(i=1,l=List_head(r),_=List_head(List_tail(List_tail(r))),u=List_head(List_tail(r))):i=2,i){case 0:n=new GuardedValidation(o,a,t[1],IdentityReturnPolicy.RequireParameterAnnotation);break;case 1:n=new GuardedValidation(o,l,ValidationSyntax_classify(e,_),IdentityReturnPolicy.RequireParameterAnnotation);break;default:n=void 0}}else n=void 0}else n=void 0;return null!=n?e.PreservesCheckedInformation(t.ParametersRoot,some(n.Condition))?void 0:n:void 0}const typeAnnotationNodeType="type",argumentListNodeType="argument_list",attributeNodeType="attribute",identifierNodeType="identifier",typedDefaultParameterNodeType="typed_default_parameter",Python_comparisonOperatorNodeType="comparison_operator",callNodeType="call",andOperatorNodeType="and",tryStatementNodeType="try_statement",exceptClauseNodeType="except_clause",finallyClauseNodeType="finally_clause",functionDefinitionNodeType="function_definition",lambdaNodeType="lambda",parametersNodeType="parameters",lambdaParametersNodeType="lambda_parameters",parameterChildTypes=ofArray([identifierNodeType,"default_parameter","typed_parameter",typedDefaultParameterNodeType]);function parametersOf(e,t){let n;return defaultArg((n=List_tryFind(t=>equals(t.type,e),nodeChildren(t)),null!=n?List_filter(e=>List_contains(e.type,parameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(n))):void 0),List_empty())}function anonymousBinding(e){let t,n,r,o,i;const a=nodeParent(e);let s,l;if(null!=a?(i=Option_value(a),equals(i.type,"assignment")&&Seq_exists(t=>t.id===e.id,toArray(nodeField("right",i)))?(s=0,l=Option_value(a)):s=1):s=1,0===s){let e,i;const a=nodeField("left",l);let s;i=null!=a?(t=Option_value(a),equals(t.type,identifierNodeType)?a:void 0):void 0,e=null!=i?(n=Option_value(i),n.text):void 0;const _=nodeParent(l);let u,c,d;switch(s=null!=_?nodeParent(Option_value(_)):void 0,null!=s?(r=Option_value(s),equals(r.type,"module")?(u=0,c=Option_value(s)):(o=Option_value(s),equals(o.type,"block")&&Seq_exists(e=>equals(e.type,"class_definition"),toArray(nodeParent(o)))?(u=1,d=Option_value(s)):u=2)):u=2,u){case 0:return[new CallableRole(1,[AnonymousBindingScope.ModuleBinding]),e];case 1:return[new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding]),e];default:return[CallableRole.InlineAnonymous,e]}}return[CallableRole.InlineAnonymous,void 0]}function callableViews(e){let t,n;const r=e.type;if(equals(r,functionDefinitionNodeType))return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,CallableRole.NamedDefinition,(t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0),parametersOf(parametersNodeType,e)));if(equals(r,lambdaNodeType)){const t=anonymousBinding(e);return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,t[0],t[1],parametersOf(lambdaParametersNodeType,e)))}return List_empty()}function Python_isDocstring(e){if(equals(e.type,"expression_statement")){const t=nodeNamedChildren(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,"string")}return!1}function Python_bodyItems(e){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,"block"),t);return null==n?t:nodeNamedChildren(Option_value(n))}function errorHandlingRegion(e){let t;if(equals(e.type,tryStatementNodeType)){const n=nodeNamedChildren(e);let r;const o=List_tryFind(e=>equals(e.type,"block"),n);return r=null!=o?nodeNamedChildren(Option_value(o)):void 0,null!=r?(t=r,new ErrorHandlingRegion(e,t,t,List_collect(Python_bodyItems,List_filter(e=>!!equals(e.type,exceptClauseNodeType)||equals(e.type,finallyClauseNodeType),n)),List_map(e=>new RecoveryBody(e,Python_bodyItems(e)),List_filter(e=>!!equals(e.type,exceptClauseNodeType)||equals(e.type,finallyClauseNodeType),n)))):void 0}}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"binary_operator"===r?!!n&&List_exists(e=>equals(e.type,"%"),nodeChildren(t)):!!equals(r,attributeNodeType)&&!!n&&isFormatCall(t)}const pythonLanguageAdapter=new LanguageAdapter("python","grammars/tree-sitter-python.wasm",new NodeTypes("block",parametersNodeType,"if_statement","else_clause","for_statement","while_statement","conditional_expression",lambdaNodeType,"import_statement","import_from_statement",List_empty(),"expression_statement","assignment","module",void 0,"comment","integer","float","string"),e=>equals(e.type,functionDefinitionNodeType),e=>List_singleton(new FunctionHead(e,e)),callableViews,parameterChildTypes,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)}},e=>classify(ofArray(["if_statement","elif_clause","for_statement","while_statement","except_clause","match_statement"]),e),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=>{if(equals(e.type,"else_clause")){const t=nodeParent(e);return null!=t&&equals(Option_value(t).type,"try_statement")}return!1},ofArray([identifierNodeType,attributeNodeType]),e=>{let t,n;if(equals(e.type,"typed_parameter")||equals(e.type,typedDefaultParameterNodeType)){const r=List_tryFind(e=>equals(e.type,identifierNodeType),nodeChildren(e)),o=List_tryFind(e=>equals(e.type,typeAnnotationNodeType),nodeChildren(e));return null!=r&&null!=o?(t=Option_value(r),n=Option_value(o),new TypedParameter(t.text,n.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=item(n+1,r);return equals(e.type,typeAnnotationNodeType)?e.text:void 0}return}},new GenericBrackets("[","]"),Set_ofList(ofArray(["str","int","float","bool","bytes"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),errorHandlingRegion,Python_bodyItems,ofArray(["keyword_separator","list_splat_pattern"]),"NewType or a dataclass",e=>{if(equals(e.type,Python_comparisonOperatorNodeType)){const t=nodeChildren(e);return List_map(e=>{const n=0|e[0];return new EqualityComparison(item(n-1,t),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=>{},membershipComparisons,e=>!(!equals(e.type,"string")&&!equals(e.type,"integer"))||equals(e.type,"float"),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)&&item(List_length(r)-1,r).id===e.id}},e=>!1,e=>e.text,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,importInfo,isReExport,e=>equals(e.type,"class_definition"),e=>{let t,n;return Seq_exists(e=>List_exists(e=>!!equals(e.type,"decorator")&&"@staticmethod"===e.text,nodeChildren(e)),toArray((t=nodeParent(e),null!=t?(n=Option_value(t),equals(n.type,"decorated_definition")?t:void 0):void 0)))},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))))},(()=>{const e=new GuardSyntax(List_singleton("block"),"if_statement",List_singleton("raise_statement"),"return_statement",List_empty(),List_singleton("None"),Python_isDocstring,e=>equals(e.type,"true")?BooleanLiteralPolarity.LiteralTrue:equals(e.type,"false")?BooleanLiteralPolarity.LiteralFalse:void 0,(e,t)=>List_exists(e=>{if(equals(e.type,"type")){const t=e.text;return!!contains(t,"TypeGuard[",4)||contains(t,"TypeIs[",4)}return!1},nodeChildren(e)));return t=>extract(e,t)})()),functionDeclarationLeft="function_declaration_left",FSharp_functionDefinitionNodeType="function_or_value_defn",functionExpressionNodeType="fun_expression",argumentPatternsNodeType="argument_patterns",FSharp_parameterChildTypes=ofArray(["long_identifier","typed_pattern"]);function firstDescendant(e,t){return List_tryPick(t=>e(t)?some(t):firstDescendant(e,t),nodeChildren(t))}function FSharp_parametersOf(e){let t;return defaultArg((t=firstDescendant(e=>equals(e.type,argumentPatternsNodeType),e),null!=t?List_filter(e=>List_contains(e.type,FSharp_parameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(t))):void 0),List_empty())}function bindingNameIn(e){let t;const n=firstDescendant(e=>equals(e.type,"identifier"),e);return null!=n?(t=Option_value(n),t.text):void 0}function functionHeads(e){const t=nodeChildren(e),n=List_filter(e=>equals(e.type,functionDeclarationLeft),t);return List_length(n)<=1?List_singleton(new FunctionHead(e,e)):List_map(n=>{let r,o;const i=List_skip(List_findIndex(e=>e.id===n.id,t)+1,t);return new FunctionHead(n,(r=List_tryFindIndex(e=>equals(e.type,"="),i),null!=r&&r+1<List_length(i)?(o=0|r,item(o+1,i)):e))},n)}function classMemberBinding(e,t){return Seq_exists(t=>t.id===e.id,toArray(List_tryLast(nodeNamedChildren(t))))?[new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding]),bindingNameIn(t)]:[CallableRole.InlineAnonymous,void 0]}function valueBindingName(e){const t=List_tryFind(e=>equals(e.type,"value_declaration_left"),nodeChildren(e));return null!=t?bindingNameIn(Option_value(t)):void 0}function isModuleBinding(e){let t;return Seq_exists(e=>equals(e.type,"file"),toArray((t=nodeParent(e),null!=t?nodeParent(Option_value(t)):void 0)))}function valueBinding(e,t){const n=Seq_exists(t=>t.id===e.id,toArray(nodeField("body",t))),r=valueBindingName(t);return n&&isModuleBinding(t)?[new CallableRole(1,[AnonymousBindingScope.ModuleBinding]),r]:[CallableRole.InlineAnonymous,r]}function FSharp_anonymousBinding(e){let t,n;const r=nodeParent(e);let o,i,a;switch(null!=r?(t=Option_value(r),equals(t.type,"method_or_prop_defn")?(o=0,i=Option_value(r)):(n=Option_value(r),equals(n.type,FSharp_functionDefinitionNodeType)?(o=1,a=Option_value(r)):o=2)):o=2,o){case 0:return classMemberBinding(e,i);case 1:return valueBinding(e,a);default:return[CallableRole.InlineAnonymous,void 0]}}function namedCallableView(e,t){return new CallableView(t.ParametersRoot,t.Body,e,CallableRole.NamedDefinition,bindingNameIn(t.ParametersRoot),FSharp_parametersOf(t.ParametersRoot))}function anonymousCallableView(e){const t=FSharp_anonymousBinding(e);return new CallableView(e,defaultArg(List_tryLast(nodeNamedChildren(e)),e),e,t[0],t[1],FSharp_parametersOf(e))}function FSharp_callableViews(e){const t=List_exists(e=>equals(e.type,functionDeclarationLeft),nodeChildren(e)),n=e.type;return equals(n,FSharp_functionDefinitionNodeType)&&t?List_map(t=>namedCallableView(e,t),functionHeads(e)):equals(n,functionExpressionNodeType)?List_singleton(anonymousCallableView(e)):List_empty()}function stringCaseOf(e){const t=List_tryHead(nodeNamedChildren(e));if(null!=t){const e=Option_value(t);return equals(e.type,"string")?some(e):List_tryFind(e=>equals(e.type,"string"),nodeNamedChildren(e))}}function matchStringCases(e){if(equals(e.type,"match_expression")){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,"long_identifier_or_op"),t),r=List_collect(e=>equals(e.type,"rules")?List_choose(stringCaseOf,nodeNamedChildren(e)):List_empty(),t);let o,i,a;return null!=n?(Option_value(n),List_length(r)>0?(o=0,i=r,a=Option_value(n)):o=1):o=1,0===o?[a,i]:void 0}}function isNamedArgumentPosition(e){return(e=>{e:for(;;){const t=e;let n,r;const o=nodeParent(t);let i,a,s;switch(null!=o?(n=Option_value(o),equals(n.type,"paren_expression")||equals(n.type,"tuple_expression")?(i=0,a=Option_value(o)):(r=Option_value(o),equals(r.type,"application_expression")?(i=1,s=Option_value(o)):i=2)):i=2,i){case 0:e=a;continue e;case 1:{const e=List_tryItem(0,nodeChildren(s));return null==e||Option_value(e).id!==t.id}default:return!1}break}})(e)}const tryExpressionNodeType="try_expression",declarationExpressionNodeType="declaration_expression",rulesNodeType="rules",ruleNodeType="rule";function logicalItems(e){let t;const n=e.type;return t=n,equals(t,declarationExpressionNodeType)||equals(t,"sequential_expression")||equals(n,rulesNodeType)?List_collect(logicalItems,nodeNamedChildren(e)):equals(n,ruleNodeType)?List_singleton(e):equals(n,"function_or_value_defn")?List_collect(logicalItems,List_filter(e=>"="!==e.text,List_skipWhile(e=>"="!==e.text,nodeChildren(e)))):equals(n,"ce_expression")?List_collect(logicalItems,List_skip(1,nodeNamedChildren(e))):List_singleton(e)}function FSharp_errorHandlingRegion(e){if(equals(e.type,tryExpressionNodeType)){const t=nodeNamedChildren(e),n=List_tryFindIndex(e=>equals(e.type,rulesNodeType),t);if(null==n){let n,r,o;return List_isEmpty(t)||List_isEmpty(List_tail(t))?n=1:(n=0,r=List_head(List_tail(t)),o=List_head(t)),0===n?new ErrorHandlingRegion(e,List_singleton(o),logicalItems(o),logicalItems(r),List_singleton(new RecoveryBody(defaultArg(List_tryFind(e=>"finally"===e.text,nodeChildren(e)),r),List_singleton(r)))):void 0}{const r=0|n;return new ErrorHandlingRegion(e,List_take(r,t),List_collect(logicalItems,List_take(r,t)),List_collect(logicalItems,List_skip(r,t)),List_map(e=>{let t;return new RecoveryBody(e,(t=List_skipWhile(e=>"->"!==e.text,nodeChildren(e)),List_isEmpty(t)?List_empty():List_tail(t)))},List_filter(e=>equals(e.type,ruleNodeType),List_collect(nodeNamedChildren,List_skip(r,t)))))}}}const fSharpLanguageAdapter=new LanguageAdapter("fsharp","grammars/tree-sitter-fsharp.wasm",new NodeTypes(void 0,argumentPatternsNodeType,"if_expression",void 0,"for_expression","while_expression",void 0,functionExpressionNodeType,"import_decl",void 0,List_empty(),void 0,"function_or_value_defn","declaration_expression",void 0,"line_comment","int","float","string"),e=>!!equals(e.type,FSharp_functionDefinitionNodeType)&&List_exists(e=>equals(e.type,functionDeclarationLeft),nodeChildren(e)),functionHeads,FSharp_callableViews,FSharp_parameterChildTypes,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)}},e=>classify(ofArray(["if_expression","elif_expression","for_expression","while_expression","match_expression"]),e),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;switch(Option_value(t).text){case"&&":return BooleanOperator.And;case"||":return BooleanOperator.Or;default:return}}},e=>!1,List_singleton("long_identifier_or_op"),e=>{if(equals(e.type,"typed_pattern")){const t=nodeChildren(e),n=List_tryFind(e=>equals(e.type,"identifier_pattern"),t);let r;const o=List_tryFindIndex(e=>equals(e.type,":"),t);if(null!=o){const e=0|o;r=e+1<List_length(t)?some(item(e+1,t)):void 0}else r=void 0;let i,a,s;return null!=n&&null!=r?(i=0,a=Option_value(n),s=Option_value(r)):i=1,0===i?new TypedParameter(a.text,s.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,a;return null!=t&&t+1<List_length(nodeChildren(e))?(r=0,a=t):r=1,0===r?item(a+1,nodeChildren(e)).text:void 0}return}},new GenericBrackets("<",">"),Set_ofList(ofArray(["string","int","float","bool"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),FSharp_errorHandlingRegion,logicalItems,List_empty(),"a single-case union type",e=>{let t;if(!equals(e.type,"infix_expression")||isNamedArgumentPosition(e))return List_empty();{let n;const r=List_tryFind(e=>equals(e.type,"infix_op"),nodeChildren(e));if(n=null!=r?(t=Option_value(r),"="===t.text?r:void 0):void 0,null==n)return List_empty();{const t=Option_value(n),r=List_filter(e=>e.id!==t.id,nodeChildren(e));let o,i,a;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),a=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,equals(a.type,"const")&&1===List_length(nodeChildren(a))?List_head(nodeChildren(a)):a)):List_empty()}}},matchStringCases,e=>List_empty(),e=>!(!equals(e.type,"string")&&!equals(e.type,"int"))||equals(e.type,"float"),e=>List_filter(e=>equals(e.type,"elif_expression"),nodeChildren(e)),List_empty(),e=>!1,e=>!1,e=>!1,e=>e.text,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,a;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,a=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(a);return null!=e&&equals(Option_value(e).type,"application_expression")}default:return!1}},e=>!1,e=>{let t,n;return List_singleton(new ImportInfo(ImportKind.ScopeOpen,(t=List_tryFind(e=>equals(e.type,"long_identifier"),nodeChildren(e)),null==t?e.text:(n=Option_value(t),n.text)),List_empty()))},(e,t)=>!1,e=>!1,e=>!1,e=>{},e=>List_empty(),(()=>{const e=new GuardSyntax(List_singleton("sequential_expression"),"if_expression",List_empty(),void 0,ofArray(["invalidArg","invalidArgf","failwith","failwithf","raise"]),ofArray(["()","None"]),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))&&equals(List_head(t).type,"bool")?(n=0,r=List_head(t)):n=1,0===n?"true"===e.text?BooleanLiteralPolarity.LiteralTrue:"false"===e.text?BooleanLiteralPolarity.LiteralFalse:void 0:void 0}},(e,t)=>!1);return t=>extract(e,t)})());function importedNames(e){return List_collect(e=>List_collect(e=>{let t,n;const r=e.type;return"identifier"===r?List_singleton(e.text):"namespace_import"===r?ofArray(toArray((t=List_tryLast(nodeNamedChildren(e)),null!=t?(n=Option_value(t),n.text):void 0))):"named_imports"===r?List_choose(e=>{let t,n;const r=nodeField("alias",e);return n=null!=r?r:nodeField("name",e),null!=n?(t=Option_value(n),t.text):void 0},List_filter(e=>equals(e.type,"import_specifier"),nodeNamedChildren(e))):List_empty()},nodeNamedChildren(e)),List_filter(e=>equals(e.type,"import_clause"),nodeNamedChildren(e)))}function locallyExportedNames(e){return equals(e.type,"export_statement")&&null==nodeField("source",e)?List_collect(e=>List_choose(e=>{let t;const n=nodeField("name",e);return null!=n?(t=Option_value(n),t.text):void 0},nodeNamedChildren(e)),List_filter(e=>equals(e.type,"export_clause"),nodeNamedChildren(e))):List_empty()}function isBarrelItem(e){const t=e.type;let n;switch(n="import_statement"===t||"comment"===t?0:"export_statement"===t?1:2,n){case 0:return!0;case 1:return null!=nodeField("source",e)||List_exists(e=>equals(e.type,"export_clause"),nodeNamedChildren(e));default:return!1}}function TypeScriptReExports_isReExport(e,t){let n;const r=nodeParent(t);let o,i;if(null!=r?(n=Option_value(r),equals(n.type,"program")?(o=0,i=Option_value(r)):o=1):o=1,0===o){const e=nodeNamedChildren(i),n=importedNames(t),r=Set_ofList(List_collect(locallyExportedNames,e),{Compare:(e,t)=>0|comparePrimitives(e,t)});return!(!List_forAll(isBarrelItem,e)||List_isEmpty(n))&&List_forAll(e=>FSharpSet__Contains(r,e),n)}return!1}const TypeScript_typeAnnotationNodeType="type_annotation",typeIdentifierNodeType="type_identifier",TypeScript_tryStatementNodeType="try_statement",statementBlockNodeType="statement_block",catchClauseNodeType="catch_clause",TypeScript_finallyClauseNodeType="finally_clause",functionDeclarationNodeType="function_declaration",methodDefinitionNodeType="method_definition",arrowFunctionNodeType="arrow_function",TypeScript_functionExpressionNodeType="function_expression",formalParametersNodeType="formal_parameters",TypeScript_parameterChildTypes=ofArray(["required_parameter","optional_parameter"]);function TypeScript_parametersOf(e){const t=nodeField("parameters",e),n=nodeField("parameter",e);return null==t?null==n?List_empty():List_singleton(Option_value(n)):List_filter(e=>List_contains(e.type,TypeScript_parameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(t)))}function moduleDeclarationContainer(e){let t;const n=nodeParent(e);let r,o,i;return null!=n?(t=Option_value(n),equals(t.type,"export_statement")?(r=0,o=Option_value(n)):(r=1,i=n)):(r=1,i=n),0===r?nodeParent(o):i}function TypeScript_anonymousBinding(e){let t,n,r,o,i,a,s,l,_;const u=nodeParent(e);let c,d,p;switch(null!=u?(l=Option_value(u),equals(l.type,"public_field_definition")&&Seq_exists(t=>t.id===e.id,toArray(nodeField("value",l)))?(c=0,d=Option_value(u)):(_=Option_value(u),equals(_.type,"variable_declarator")&&Seq_exists(t=>t.id===e.id,toArray(nodeField("value",_)))?(c=1,p=Option_value(u)):c=2)):c=2,c){case 0:return[new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding]),(t=nodeField("name",d),null!=t?(n=Option_value(t),n.text):void 0)];case 1:{let e;const t=nodeField("name",p);return e=null!=t?(r=Option_value(t),r.text):void 0,[defaultArg((a=nodeParent(p),i=null!=a?moduleDeclarationContainer(Option_value(a)):void 0,o=null!=i?(s=Option_value(i),equals(s.type,"program")?i:void 0):void 0,null!=o?(Option_value(o),new CallableRole(1,[AnonymousBindingScope.ModuleBinding])):void 0),CallableRole.InlineAnonymous),e]}default:return[CallableRole.InlineAnonymous,void 0]}}function TypeScript_callableViews(e){let t,n,r,o;const i=e.type;if(t=i,equals(t,functionDeclarationNodeType)||equals(t,methodDefinitionNodeType))return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,CallableRole.NamedDefinition,(n=nodeField("name",e),null!=n?(r=Option_value(n),r.text):void 0),TypeScript_parametersOf(e)));if(o=i,equals(o,arrowFunctionNodeType)||equals(o,TypeScript_functionExpressionNodeType)){const t=TypeScript_anonymousBinding(e);return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,t[0],t[1],TypeScript_parametersOf(e)))}return List_empty()}function TypeScript_bodyItems(e){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,statementBlockNodeType),t);return null==n?t:nodeNamedChildren(Option_value(n))}function TypeScript_errorHandlingRegion(e){let t;if(equals(e.type,TypeScript_tryStatementNodeType)){const n=nodeNamedChildren(e),r=List_tryFind(e=>equals(e.type,statementBlockNodeType),n);return null!=r?(t=Option_value(r),new ErrorHandlingRegion(e,nodeNamedChildren(t),nodeNamedChildren(t),List_collect(TypeScript_bodyItems,List_filter(e=>!!equals(e.type,catchClauseNodeType)||equals(e.type,TypeScript_finallyClauseNodeType),n)),List_map(e=>new RecoveryBody(e,TypeScript_bodyItems(e)),List_filter(e=>!!equals(e.type,catchClauseNodeType)||equals(e.type,TypeScript_finallyClauseNodeType),n)))):void 0}}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 typeScriptLanguageAdapter=new LanguageAdapter("typescript","grammars/tree-sitter-typescript.wasm",new NodeTypes("statement_block",formalParametersNodeType,"if_statement","else_clause","for_statement","while_statement","ternary_expression",arrowFunctionNodeType,"import_statement",void 0,List_empty(),"expression_statement","lexical_declaration","program","export_statement","comment","number",void 0,"string"),e=>!!equals(e.type,functionDeclarationNodeType)||equals(e.type,methodDefinitionNodeType),e=>List_singleton(new FunctionHead(e,e)),TypeScript_callableViews,TypeScript_parameterChildTypes,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)}},e=>classify(ofArray(["if_statement","for_statement","for_in_statement","while_statement","catch_clause","switch_statement","do_statement"]),e),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=>!1,ofArray(["identifier","member_expression"]),e=>{let t;if(equals(e.type,"required_parameter")||equals(e.type,"optional_parameter")){const n=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(e)),r=List_tryFind(e=>equals(e.type,TypeScript_typeAnnotationNodeType),nodeChildren(e));if(null!=n){const e=Option_value(n);if(null!=r){const n=List_tryFind(e=>!equals(e.type,":"),nodeChildren(Option_value(r)));return null!=n?(t=Option_value(n),new TypedParameter(e.text,t.text)):void 0}return}return}},e=>{let t;const n=List_tryFind(e=>equals(e.type,TypeScript_typeAnnotationNodeType),nodeChildren(e));if(null!=n){const e=List_tryFind(e=>!equals(e.type,":"),nodeChildren(Option_value(n)));return null!=e?(t=Option_value(e),t.text):void 0}},new GenericBrackets("<",">"),Set_ofList(ofArray(["string","number","boolean"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),TypeScript_errorHandlingRegion,TypeScript_bodyItems,List_empty(),"a branded type (a nominal/opaque type with zero runtime overhead)",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,a;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),a=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,a)):List_empty()}}return List_empty()},e=>{},e=>List_empty(),e=>!!equals(e.type,"string")||equals(e.type,"number"),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=>!1,e=>e.text,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=>{let t;const n=List_tryFind(e=>equals(e.type,"string"),nodeChildren(e));t=null==n?e.text:Option_value(n).text;const r=e.text,o=0|r.indexOf("{"),i=0|r.indexOf("}");return o>=0&&i>o?List_singleton(new ImportInfo(ImportKind.Members,t,List_map(e=>{const t=String_split(e,[" "],void 0,1),n=Array_item(0,t);return new ImportBinding(n,t.length>=3&&"as"===Array_item(1,t)?Array_item(2,t):n)},List_filter(e=>""!==e,List_map(e=>String_replace(e.trim(),"type ",""),ofArray(String_split(substring(r,o+1,i-o-1),[","],void 0,0))))))):(r.indexOf("* as "),List_singleton(new ImportInfo(ImportKind.Module,t,List_empty())))},TypeScriptReExports_isReExport,e=>!!equals(e.type,"class_declaration")||equals(e.type,"abstract_class_declaration"),e=>{let t,n,r;return List_exists(e=>"static"===e.text,nodeChildren((t=nodeParent(e),null!=t?(n=Option_value(t),equals(n.type,"public_field_definition")?(r=Option_value(t),r):e):e)))},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))}},(()=>{const e=new GuardSyntax(List_singleton("statement_block"),"if_statement",List_singleton("throw_statement"),"return_statement",List_empty(),List_singleton("undefined"),e=>!1,e=>equals(e.type,"true")?BooleanLiteralPolarity.LiteralTrue:equals(e.type,"false")?BooleanLiteralPolarity.LiteralFalse:void 0,(e,t)=>List_exists(e=>!(!equals(e.type,"asserts_annotation")&&!equals(e.type,"type_predicate_annotation"))||!!equals(e.type,"property_identifier")&&"constructor"===e.text,nodeNamedChildren(e)));return t=>extract(e,t)})()),Kotlin_tryExpressionNodeType="try_expression",blockNodeType="block",functionBodyNodeType="function_body",catchBlockNodeType="catch_block",finallyBlockNodeType="finally_block",Kotlin_functionDeclarationNodeType="function_declaration",lambdaLiteralNodeType="lambda_literal",functionParametersNodeType="function_value_parameters",namedParameterChildTypes=List_singleton("parameter");function namedParametersOf(e){let t;return defaultArg((t=List_tryFind(e=>equals(e.type,functionParametersNodeType),nodeChildren(e)),null!=t?List_filter(e=>List_contains(e.type,namedParameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(t))):void 0),List_empty())}function lambdaParametersOf(e){let t;return defaultArg((t=List_tryFind(e=>equals(e.type,"lambda_parameters"),nodeChildren(e)),null!=t?List_filter(e=>equals(e.type,"variable_declaration"),nodeChildren(Option_value(t))):void 0),List_empty())}function hasNarrowingContract(e){let t,n;return null!=(n=List_tryFind(e=>equals(e.type,functionBodyNodeType),nodeNamedChildren(e)),t=null!=n?List_tryHead(nodeNamedChildren(Option_value(n))):void 0,null!=t?List_tryFind(e=>!!equals(e.type,"call_expression")&&Seq_exists(e=>!!equals(e.type,"identifier")&&"contract"===e.text,toArray(List_tryHead(nodeNamedChildren(e)))),nodeNamedChildren(Option_value(t))):void 0)}function booleanLiteralPolarity(e){if(equals(e.type,"identifier"))switch(e.text){case"true":return BooleanLiteralPolarity.LiteralTrue;case"false":return BooleanLiteralPolarity.LiteralFalse;default:return}}function propertyBindingName(e){let t,n;const r=List_tryFind(e=>equals(e.type,"variable_declaration"),nodeChildren(e));return n=null!=r?List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(Option_value(r))):void 0,null!=n?(t=Option_value(n),t.text):void 0}function Kotlin_anonymousBinding(e){let t,n,r,o,i,a;const s=nodeParent(e);let l,_;return null!=s?(a=Option_value(s),equals(a.type,"property_declaration")&&Seq_exists(t=>t.id===e.id,toArray(List_tryLast(nodeNamedChildren(a))))?(l=0,_=Option_value(s)):l=1):l=1,0===l?[(t=nodeParent(_),null!=t?(n=Option_value(t),equals(n.type,"source_file")?(r=Option_value(t),new CallableRole(1,[AnonymousBindingScope.ModuleBinding])):(o=Option_value(t),equals(o.type,"class_body")?(i=Option_value(t),new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding])):CallableRole.InlineAnonymous)):CallableRole.InlineAnonymous),propertyBindingName(_)]:[CallableRole.InlineAnonymous,void 0]}function Kotlin_callableViews(e){let t,n;const r=e.type;if(equals(r,Kotlin_functionDeclarationNodeType))return List_singleton(new CallableView(e,e,e,CallableRole.NamedDefinition,(t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0),namedParametersOf(e)));if(equals(r,lambdaLiteralNodeType)){const t=Kotlin_anonymousBinding(e);return List_singleton(new CallableView(e,e,e,t[0],t[1],lambdaParametersOf(e)))}return List_empty()}function Kotlin_bodyItems(e){e:for(;;){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,blockNodeType),t);if(null==n){const n=List_tryFind(e=>equals(e.type,functionBodyNodeType),t);if(null==n)return t;e=Option_value(n);continue e}return nodeNamedChildren(Option_value(n))}}function Kotlin_errorHandlingRegion(e){let t;if(equals(e.type,Kotlin_tryExpressionNodeType)){const n=nodeNamedChildren(e),r=List_tryFind(e=>equals(e.type,blockNodeType),n);return null!=r?(t=Option_value(r),new ErrorHandlingRegion(e,nodeNamedChildren(t),nodeNamedChildren(t),List_collect(Kotlin_bodyItems,List_filter(e=>!!equals(e.type,catchBlockNodeType)||equals(e.type,finallyBlockNodeType),n)),List_map(e=>new RecoveryBody(e,Kotlin_bodyItems(e)),List_filter(e=>!!equals(e.type,catchBlockNodeType)||equals(e.type,finallyBlockNodeType),n)))):void 0}}const expectedInfixIdentifierCount=3;function isUserType(e){return equals(e.type,"user_type")}function isParameterType(e){return!!equals(e.type,"user_type")||equals(e.type,"nullable_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(List_length(t)!==expectedInfixIdentifierCount)return!1;{const e=List_toArray(t);return"const"===Array_item(0,e).text&&"val"===Array_item(1,e).text}}}}function delegationSpecifierName(e){let t,n;const r=orElse(List_tryFind(isUserType,nodeChildren(e)),(t=List_tryFind(e=>equals(e.type,"constructor_invocation"),nodeChildren(e)),null!=t?List_tryFind(isUserType,nodeChildren(Option_value(t))):void 0));if(null!=r){const e=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(Option_value(r)));return null!=e?(n=Option_value(e),n.text):void 0}}const kotlinLanguageAdapter=new LanguageAdapter("kotlin","grammars/tree-sitter-kotlin.wasm",new NodeTypes("block",functionParametersNodeType,"if_expression",void 0,"for_statement","while_statement",void 0,lambdaLiteralNodeType,"import",void 0,List_empty(),void 0,"property_declaration","source_file",void 0,"line_comment","number_literal","float_literal","string_literal"),e=>equals(e.type,Kotlin_functionDeclarationNodeType),e=>List_singleton(new FunctionHead(e,e)),Kotlin_callableViews,namedParameterChildTypes,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)}},e=>classify(ofArray(["if_expression","for_statement","while_statement","when_expression","catch_block","do_while_statement"]),e),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=>!1,ofArray(["identifier","navigation_expression"]),e=>{if(equals(e.type,"parameter")){const t=List_tryFind(e=>equals(e.type,"identifier"),nodeChildren(e)),n=List_tryFind(isParameterType,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));let n,r;if(null!=t&&t+1<List_length(nodeChildren(e))?(n=0,r=t):n=1,0===n)return item(r+1,nodeChildren(e)).text},new GenericBrackets("<",">"),Set_ofList(ofArray(["Int","Long","Short","Byte","Double","Float","Boolean","String","Char"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),Kotlin_errorHandlingRegion,Kotlin_bodyItems,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,a;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),a=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,a)):List_empty()}}return List_empty()},e=>{},e=>List_empty(),e=>!(!equals(e.type,"string_literal")&&!equals(e.type,"number_literal"))||equals(e.type,"float_literal"),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,a;return null!=e&&null!=n?(r=0,o=Option_value(e),a=Option_value(n)):r=1,0===r&&!!equals(o.type,"=")&&equals(a.type,"parameter")}return!1}return!1},e=>!1,e=>e.text,e=>null!=booleanLiteralPolarity(e),e=>{let t,n,r;const o=nodeParent(e);let i,a;if(null!=o?(r=Option_value(o),equals(r.type,"value_argument")?(i=0,a=Option_value(o)):i=1):i=1,0===i){const r=nodeParent(a);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(a));return null!=t&&Option_value(t).id===e.id}return!1}return!1}return!1},e=>{const t=e.type;return"property_declaration"===t?isConstPropertyDeclaration(e):"assignment"===t&&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 List_singleton(new ImportInfo(ImportKind.Wildcard,t,List_empty()));{const e=0|t.lastIndexOf(".");if(-1===e)return List_singleton(new ImportInfo(ImportKind.Members,t,List_empty()));{const n=0|e,r=substring(t,n+1);return List_singleton(new ImportInfo(ImportKind.Members,substring(t,0,n),List_singleton(new ImportBinding(r,r))))}}}return List_singleton(new ImportInfo(ImportKind.Members,e.text,List_empty()))},(e,t)=>!1,e=>equals(e.type,"class_declaration"),e=>!1,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))))},(()=>{const e=new GuardSyntax(ofArray(["function_body","block"]),"if_expression",List_singleton("throw_expression"),"return_expression",List_empty(),List_singleton("Unit"),e=>!1,booleanLiteralPolarity,(e,t)=>hasNarrowingContract(e));return t=>extract(e,t)})()),CPlusPlus_tryStatementNodeType="try_statement",compoundStatementNodeType="compound_statement",CPlusPlus_catchClauseNodeType="catch_clause",CPlusPlus_functionDefinitionNodeType="function_definition",lambdaExpressionNodeType="lambda_expression",parameterListNodeType="parameter_list",CPlusPlus_parameterChildTypes=ofArray(["parameter_declaration","optional_parameter_declaration","variadic_parameter_declaration"]);function CPlusPlus_bodyItems(e){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,compoundStatementNodeType),t);return null==n?t:nodeNamedChildren(Option_value(n))}function CPlusPlus_errorHandlingRegion(e){let t;if(equals(e.type,CPlusPlus_tryStatementNodeType)){const n=nodeNamedChildren(e),r=List_tryFind(e=>equals(e.type,compoundStatementNodeType),n);return null!=r?(t=Option_value(r),new ErrorHandlingRegion(e,nodeNamedChildren(t),nodeNamedChildren(t),List_collect(CPlusPlus_bodyItems,List_filter(e=>equals(e.type,CPlusPlus_catchClauseNodeType),n)),List_map(e=>new RecoveryBody(e,CPlusPlus_bodyItems(e)),List_filter(e=>equals(e.type,CPlusPlus_catchClauseNodeType),n)))):void 0}}const typeNodeTypes=Set_ofList(ofArray(["primitive_type","sized_type_specifier","type_identifier","qualified_identifier","template_type","placeholder_type_specifier","decltype","dependent_type"]),{Compare:(e,t)=>0|compare(e,t)}),declaratorNodeTypes=Set_ofList(ofArray(["identifier","field_identifier","pointer_declarator","reference_declarator","array_declarator","function_declarator","parenthesized_declarator"]),{Compare:(e,t)=>0|compare(e,t)});function tryFindDescendant(e,t){return e(t)?some(t):List_tryPick(t=>tryFindDescendant(e,t),nodeChildren(t))}function isTypeNode(e){return Set_contains(e.type,typeNodeTypes)}function isDeclaratorNode(e){return Set_contains(e.type,declaratorNodeTypes)}function CPlusPlus_parametersOf(e){let t;return defaultArg((t=tryFindDescendant(e=>equals(e.type,parameterListNodeType),e),null!=t?List_filter(e=>List_contains(e.type,CPlusPlus_parameterChildTypes,{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeChildren(Option_value(t))):void 0),List_empty())}function declaratorName(e){let t;const n=tryFindDescendant(e=>!!equals(e.type,"identifier")||equals(e.type,"field_identifier"),e);return null!=n?(t=Option_value(n),t.text):void 0}function CPlusPlus_anonymousBinding(e){let t,n,r,o,i,a,s,l;const _=nodeParent(e);let u,c,d;switch(null!=_?(s=Option_value(_),equals(s.type,"field_declaration")&&Seq_exists(e=>equals(e.type,"field_declaration_list"),toArray(nodeParent(s)))?(u=0,c=Option_value(_)):(l=Option_value(_),equals(l.type,"init_declarator")&&Seq_exists(t=>t.id===e.id,toArray(nodeField("value",l)))?(u=1,d=Option_value(_)):u=2)):u=2,u){case 0:return[new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding]),(t=nodeField("declarator",c),null!=t?declaratorName(Option_value(t)):void 0)];case 1:{let e;const t=nodeField("declarator",d);return e=null!=t?declaratorName(Option_value(t)):void 0,[(n=nodeParent(d),null!=n?(r=Option_value(n),equals(r.type,"declaration")&&Seq_exists(e=>equals(e.type,"translation_unit"),toArray(nodeParent(r)))?(o=Option_value(n),new CallableRole(1,[AnonymousBindingScope.ModuleBinding])):(i=Option_value(n),equals(i.type,"field_declaration")&&Seq_exists(e=>equals(e.type,"field_declaration_list"),toArray(nodeParent(i)))?(a=Option_value(n),new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding])):CallableRole.InlineAnonymous)):CallableRole.InlineAnonymous),e]}default:return[CallableRole.InlineAnonymous,void 0]}}function CPlusPlus_callableViews(e){let t;const n=e.type;if(equals(n,CPlusPlus_functionDefinitionNodeType))return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,CallableRole.NamedDefinition,(t=nodeField("declarator",e),null!=t?declaratorName(Option_value(t)):void 0),CPlusPlus_parametersOf(e)));if(equals(n,lambdaExpressionNodeType)){const t=CPlusPlus_anonymousBinding(e);return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,t[0],t[1],CPlusPlus_parametersOf(e)))}return List_empty()}function extractTypedParameter(e){const t=List_tryFind(isTypeNode,nodeChildren(e)),n=List_tryFind(isDeclaratorNode,nodeChildren(e));let r,o,i;if(null!=t&&null!=n?(r=0,o=Option_value(n),i=Option_value(t)):r=1,0===r){const e=tryFindDescendant(e=>!!equals(e.type,"identifier")||equals(e.type,"field_identifier"),o);if(null==e)return;{const t=Option_value(e),n=replace(String_replace(o.text,t.text,""),"\\s+","");return new TypedParameter(t.text,i.text+n)}}}function extractReturnType(e){let t,n,r;const o=List_tryFind(isDeclaratorNode,nodeChildren(e));if(r=null!=o?tryFindDescendant(e=>equals(e.type,"trailing_return_type"),Option_value(o)):void 0,null==r){const n=List_tryFind(isTypeNode,nodeChildren(e));return null!=n?(t=Option_value(n),t.text):void 0}{const e=tryFindDescendant(isTypeNode,Option_value(r));return null!=e?(n=Option_value(e),n.text):void 0}}function switchBranchCount(e){if(equals(e.type,"switch_statement")){const t=List_filter(e=>equals(e.type,"case_statement"),List_collect(nodeNamedChildren,nodeNamedChildren(e))),n=List_exists(e=>List_exists(e=>equals(e.type,"default"),nodeChildren(e)),t);return List_length(t)+(n?0:1)}}function equalityComparisons(e){if(equals(e.type,"binary_expression")){const t=List_tryFind(e=>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,a;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),a=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,a)):List_empty()}}return List_empty()}function isDefaultParameterValue(e){e:for(;;){const t=e;let n,r;const o=nodeParent(t);let i,a,s;switch(null!=o?(n=Option_value(o),equals(n.type,"optional_parameter_declaration")?(i=0,a=Option_value(o)):(r=Option_value(o),equals(r.type,"function_definition")?i=2:(i=1,s=Option_value(o)))):i=2,i){case 0:return Seq_exists(e=>t.startIndex>e.startIndex,toArray(List_tryFind(e=>equals(e.type,"="),nodeChildren(a))));case 1:e=s;continue e;default:return!1}break}}function isExplicitConstant(e){return!!equals(e.type,"enumerator")||!(!equals(e.type,"declaration")&&!equals(e.type,"field_declaration"))&&List_exists(e=>!!equals(e.type,"type_qualifier")&&("const"===e.text||"constexpr"===e.text),nodeChildren(e))}function baseClassNames(e){const t=List_tryFind(e=>equals(e.type,"base_class_clause"),nodeChildren(e));return null==t?List_empty():List_map(e=>e.text,List_filter(isTypeNode,nodeNamedChildren(Option_value(t))))}function isMatchCaseLiteral(e){if(equals(e.type,"char_literal"))return!0;if(equals(e.type,"number_literal")){const t=e.text.toLowerCase();return startsWith(t,"0x",4)?!(t.indexOf(".")>=0||t.indexOf("p")>=0):!(t.indexOf(".")>=0||t.indexOf("e")>=0)}return!1}function isClassDefinition(e){return!(!equals(e.type,"class_specifier")&&!equals(e.type,"struct_specifier"))&&List_exists(e=>equals(e.type,"field_declaration_list"),nodeChildren(e))}const cPlusPlusLanguageAdapter=new LanguageAdapter("cpp","grammars/tree-sitter-cpp.wasm",new NodeTypes("compound_statement",parameterListNodeType,"if_statement","else_clause","for_statement","while_statement","conditional_expression",lambdaExpressionNodeType,"preproc_include",void 0,List_empty(),"expression_statement","declaration","translation_unit",void 0,"comment","number_literal",void 0,"string_literal"),e=>equals(e.type,CPlusPlus_functionDefinitionNodeType),e=>List_singleton(new FunctionHead(e,e)),CPlusPlus_callableViews,CPlusPlus_parameterChildTypes,ofArray(["if_statement","for_statement","for_range_loop","while_statement","do_statement","catch_clause","conditional_expression","switch_statement"]),switchBranchCount,e=>classify(ofArray(["if_statement","for_statement","for_range_loop","while_statement","do_statement","catch_clause","switch_statement"]),e),ofArray(["if_statement","for_statement","for_range_loop","while_statement","do_statement","try_statement","switch_statement"]),e=>equals(e.type,"binary_expression")?List_tryPick(e=>{const t=e.type;let n;switch(n="&&"===t||"and"===t?0:"||"===t||"or"===t?1:2,n){case 0:return BooleanOperator.And;case 1:return BooleanOperator.Or;default:return}},nodeChildren(e)):void 0,e=>!1,ofArray(["identifier","field_expression","qualified_identifier"]),extractTypedParameter,extractReturnType,new GenericBrackets("<",">"),Set_ofList(ofArray(["bool","char","char8_t","char16_t","char32_t","double","float","int","long","long double","long int","long long","long long int","short","short int","signed","signed char","signed int","signed long","signed long int","signed long long","signed long long int","signed short","signed short int","string","std::string","unsigned","unsigned char","unsigned int","unsigned long","unsigned long int","unsigned long long","unsigned long long int","unsigned short","unsigned short int","wchar_t"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),CPlusPlus_errorHandlingRegion,CPlusPlus_bodyItems,List_empty(),"a small value type (for example, a struct or enum class)",equalityComparisons,e=>{},e=>List_empty(),isMatchCaseLiteral,e=>List_empty(),List_singleton("subscript_expression"),e=>!startsWith(e.text,'"',4),isDefaultParameterValue,e=>!1,e=>e.text,e=>!!equals(e.type,"true")||equals(e.type,"false"),e=>{let t;const n=nodeParent(e);let r,o;return null!=n?(t=Option_value(n),equals(t.type,"argument_list")?(r=0,o=Option_value(n)):r=1):r=1,0===r&&Seq_exists(e=>equals(e.type,"call_expression"),toArray(nodeParent(o)))},isExplicitConstant,e=>{let t,n;return List_singleton(new ImportInfo(ImportKind.Header,(t=List_tryFind(e=>!(!equals(e.type,"system_lib_string")&&!equals(e.type,"string_literal"))||equals(e.type,"identifier"),nodeChildren(e)),null==t?e.text:(n=Option_value(t),trim(n.text,"<",">",'"'))),List_empty()))},(e,t)=>!1,isClassDefinition,e=>{const t=e=>!!List_exists(e=>"static"===e.text,nodeChildren(e))||!equals(e.type,"field_declaration_list")&&Seq_exists(t,toArray(nodeParent(e)));return t(e)},e=>{let t;const n=List_tryFind(e=>!!equals(e.type,"type_identifier")||equals(e.type,"qualified_identifier"),nodeChildren(e));return null!=n?(t=Option_value(n),t.text):void 0},baseClassNames,(()=>{const e=new GuardSyntax(List_singleton("compound_statement"),"if_statement",List_singleton("throw_statement"),"return_statement",List_empty(),List_empty(),e=>!1,e=>equals(e.type,"true")?BooleanLiteralPolarity.LiteralTrue:equals(e.type,"false")?BooleanLiteralPolarity.LiteralFalse:void 0,(e,t)=>!1);return t=>extract(e,t)})()),CSharp_blockNodeType="block",CSharp_tryStatementNodeType="try_statement",CSharp_catchClauseNodeType="catch_clause",CSharp_finallyClauseNodeType="finally_clause",CSharp_lambdaExpressionNodeType="lambda_expression",anonymousMethodNodeType="anonymous_method_expression",CSharp_parameterListNodeType="parameter_list",namedFunctionNodeTypes=Set_ofList(ofArray(["method_declaration","constructor_declaration","local_function_statement"]),{Compare:(e,t)=>0|compare(e,t)});function CSharp_parametersOf(e){let t;const n=nodeField("parameters",e);return null==n?List_empty():(t=Option_value(n),equals(t.type,"implicit_parameter")?List_singleton(Option_value(n)):List_filter(e=>equals(e.type,"parameter"),nodeChildren(Option_value(n))))}function CSharp_anonymousBinding(e){let t,n,r,o,i,a;const s=nodeParent(e);let l,_;if(null!=s?(a=Option_value(s),equals(a.type,"variable_declarator")?(l=0,_=Option_value(s)):l=1):l=1,0===l){let e;const a=nodeField("name",_);return e=null!=a?(t=Option_value(a),t.text):void 0,Seq_exists(e=>equals(e.type,"declaration_list"),toArray((o=nodeParent(_),r=null!=o?nodeParent(Option_value(o)):void 0,n=null!=r?(i=Option_value(r),equals(i.type,"field_declaration")?r:void 0):void 0,null!=n?nodeParent(Option_value(n)):void 0)))?[new CallableRole(1,[AnonymousBindingScope.ClassMemberBinding]),e]:[CallableRole.InlineAnonymous,e]}return[CallableRole.InlineAnonymous,void 0]}function callableBody(e){let t;return defaultArg((t=nodeField("body",e),null!=t?t:List_tryLast(nodeNamedChildren(e))),e)}function CSharp_callableViews(e){let t,n;if(Set_contains(e.type,namedFunctionNodeTypes))return List_singleton(new CallableView(e,callableBody(e),e,CallableRole.NamedDefinition,(t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0),CSharp_parametersOf(e)));if(equals(e.type,CSharp_lambdaExpressionNodeType)||equals(e.type,anonymousMethodNodeType)){const t=CSharp_anonymousBinding(e);return List_singleton(new CallableView(e,callableBody(e),e,t[0],t[1],CSharp_parametersOf(e)))}return List_empty()}function CSharp_bodyItems(e){const t=nodeNamedChildren(e),n=List_tryFind(e=>equals(e.type,CSharp_blockNodeType),t);return null==n?t:nodeNamedChildren(Option_value(n))}function CSharp_errorHandlingRegion(e){let t;if(equals(e.type,CSharp_tryStatementNodeType)){const n=nodeNamedChildren(e),r=List_tryFind(e=>equals(e.type,CSharp_blockNodeType),n);return null!=r?(t=Option_value(r),new ErrorHandlingRegion(e,nodeNamedChildren(t),nodeNamedChildren(t),List_collect(CSharp_bodyItems,List_filter(e=>!!equals(e.type,CSharp_catchClauseNodeType)||equals(e.type,CSharp_finallyClauseNodeType),n)),List_map(e=>new RecoveryBody(e,CSharp_bodyItems(e)),List_filter(e=>!!equals(e.type,CSharp_catchClauseNodeType)||equals(e.type,CSharp_finallyClauseNodeType),n)))):void 0}}function CSharp_switchBranchCount(e){if(equals(e.type,"switch_statement")){const t=List_filter(e=>equals(e.type,"switch_section"),List_collect(nodeNamedChildren,nodeNamedChildren(e))),n=List_exists(e=>startsWith(e.text,"default:",4),t);return List_length(t)+(n?0:1)}}function CSharp_equalityComparisons(e){if(equals(e.type,"binary_expression")){const t=List_tryFind(e=>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,a;return List_isEmpty(r)||List_isEmpty(List_tail(r))?o=1:List_isEmpty(List_tail(List_tail(r)))?(o=0,i=List_head(r),a=List_head(List_tail(r))):o=1,0===o?List_singleton(new EqualityComparison(i,a)):List_empty()}}return List_empty()}function CSharp_extractTypedParameter(e){if(equals(e.type,"parameter")){const t=nodeNamedChildren(e);let n,r,o;return List_isEmpty(t)||List_isEmpty(List_tail(t))?n=1:(n=0,r=List_head(t),o=List_head(List_tail(t))),0===n?new TypedParameter(o.text,r.text):void 0}}function CSharp_extractReturnType(e){let t;if(equals(e.type,"method_declaration")){const n=List_tryFind(e=>!equals(e.type,"modifier")&&!equals(e.type,"attribute_list"),nodeNamedChildren(e));return null!=n?(t=Option_value(n),t.text):void 0}}function isNotNullWhenAttribute(e){let t,n;return!!equals(e.type,"attribute")&&Seq_exists(e=>!("NotNullWhen"!==e&&"NotNullWhenAttribute"!==e&&!endsWith(e,".NotNullWhen",4))||endsWith(e,".NotNullWhenAttribute",4),toArray((t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0)))}function conditionReferencesNotNullWhenParameter(e,t){const n=(e,t)=>{if(equals(t.type,"identifier")&&t.text===e)return!0;{const r=nodeChildren(t);return List_exists(curry2(n)(e),r)}},r=nodeField("name",t);if(null==r)return!1;{const o=Option_value(r);return!!List_exists(isNotNullWhenAttribute,List_collect(nodeNamedChildren,List_filter(e=>equals(e.type,"attribute_list"),nodeNamedChildren(t))))&&n(o.text,e)}}function CSharp_baseClassNames(e){let t;return List_map(e=>e.text,defaultArg((t=List_tryFind(e=>equals(e.type,"base_list"),nodeChildren(e)),null!=t?nodeNamedChildren(Option_value(t)):void 0),List_empty()))}const cSharpLanguageAdapter=new LanguageAdapter("csharp","grammars/tree-sitter-c-sharp.wasm",new NodeTypes(CSharp_blockNodeType,CSharp_parameterListNodeType,"if_statement",void 0,"for_statement","while_statement","conditional_expression",CSharp_lambdaExpressionNodeType,"using_directive",void 0,List_empty(),"expression_statement","variable_declaration","compilation_unit",void 0,"comment","integer_literal","real_literal","string_literal"),e=>Set_contains(e.type,namedFunctionNodeTypes),e=>List_singleton(new FunctionHead(e,e)),CSharp_callableViews,List_singleton("parameter"),ofArray(["if_statement","for_statement","foreach_statement","while_statement","do_statement","catch_clause","conditional_expression","switch_statement"]),CSharp_switchBranchCount,e=>classify(ofArray(["if_statement","for_statement","foreach_statement","while_statement","do_statement","catch_clause","switch_statement"]),e),ofArray(["if_statement","for_statement","foreach_statement","while_statement","do_statement","try_statement","switch_statement"]),e=>equals(e.type,"binary_expression")?List_tryPick(e=>{const t=e.type;return"&&"===t?BooleanOperator.And:"||"===t?BooleanOperator.Or:void 0},nodeChildren(e)):void 0,e=>!1,ofArray(["identifier","member_access_expression"]),CSharp_extractTypedParameter,CSharp_extractReturnType,new GenericBrackets("<",">"),Set_ofList(ofArray(["bool","byte","char","decimal","double","float","int","long","sbyte","short","string","uint","ulong","ushort"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),CSharp_errorHandlingRegion,CSharp_bodyItems,List_empty(),"a readonly record struct or enum",CSharp_equalityComparisons,e=>{},e=>List_empty(),e=>!!equals(e.type,"integer_literal")||equals(e.type,"character_literal"),e=>List_empty(),List_singleton("element_access_expression"),e=>!1,e=>{let t;const n=nodeParent(e);let r,o;if(null!=n?(t=Option_value(n),equals(t.type,"parameter")?(r=0,o=Option_value(n)):r=1):r=1,0===r){const t=nodeChildren(o);return!!List_exists(e=>equals(e.type,"="),t)&&Seq_exists(t=>t.id===e.id,toArray(List_tryLast(t)))}return!1},e=>!1,e=>e.text,e=>equals(e.type,"boolean_literal"),e=>{let t,n;const r=nodeParent(e);let o,i;if(null!=r?(n=Option_value(r),equals(n.type,"argument")?(o=0,i=Option_value(r)):o=1):o=1,0===o){const e=nodeParent(i);if(null==e)return!1;if(t=Option_value(e),equals(t.type,"argument_list")){const t=nodeParent(Option_value(e));return null!=t&&equals(Option_value(t).type,"invocation_expression")}return!1}return!1},e=>!!equals(e.type,"field_declaration")&&List_exists(e=>"const"===e.text,nodeChildren(e)),e=>{let t,n;return List_singleton(new ImportInfo(ImportKind.Module,defaultArg((t=List_tryLast(nodeNamedChildren(e)),null!=t?(n=Option_value(t),n.text):void 0),e.text),List_empty()))},(e,t)=>!1,e=>!!(equals(e.type,"class_declaration")||equals(e.type,"struct_declaration")||equals(e.type,"record_declaration"))||equals(e.type,"interface_declaration"),e=>{const t=e=>!!List_exists(e=>"static"===e.text,nodeChildren(e))||!equals(e.type,"declaration_list")&&Seq_exists(t,toArray(nodeParent(e)));return t(e)},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},CSharp_baseClassNames,(()=>{const e=new GuardSyntax(List_singleton("block"),"if_statement",List_singleton("throw_statement"),"return_statement",List_empty(),List_empty(),e=>!1,e=>{if(equals(e.type,"boolean_literal")){const t=e.text;return"true"===t?BooleanLiteralPolarity.LiteralTrue:"false"===t?BooleanLiteralPolarity.LiteralFalse:void 0}},(e,t)=>!!equals(e.type,"constructor_declaration")||Seq_exists(t=>List_exists(e=>conditionReferencesNotNullWhenParameter(t,e),CSharp_parametersOf(e)),toArray(t)));return t=>extract(e,t)})()),trueAtom="true";function expressionChildren(e){return List_filter(e=>!equals(e.type,"comment"),nodeNamedChildren(e))}function singleClauseExpression(e){const t=nodeField("body",e);if(null!=t){const e=expressionChildren(Option_value(t));let n,r;return List_isEmpty(e)?n=1:List_isEmpty(List_tail(e))?(n=0,r=List_head(e)):n=1,0===n?some(r):void 0}}function isFailureCall(e){let t;return Seq_exists(e=>{let t,n;const r=nodeField("expr",e);let o;n=null!=r?(t=Option_value(r),t.text):void 0;const i=nodeField("args",e);let a;if(o=null!=i?List_length(expressionChildren(Option_value(i))):void 0,null!=n)switch(n){case"error":if(null!=o)switch(o){case 1:case 2:a=0;break;default:a=1}else a=1;break;case"throw":case"exit":a=null!=o&&1===o?0:1;break;default:a=1}else a=1;return 0===a},toArray((t=e.type,"call"===t?some(e):"remote"===t&&Seq_exists(e=>"erlang:"===e.text,toArray(nodeField("module",e)))?nodeField("fun",e):void 0)))}function validationSuccess(e){const t=e.type;let n;switch(n="var"===t?0:"atom"===t&&List_contains(e.text,ofArray([trueAtom,"false"]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)})?1:2,n){case 0:return new ValidationSuccess(0,[e]);case 1:return new ValidationSuccess(2,[e]);default:return}}function caseValidation(e){let t;const n=List_filter(e=>equals(e.type,"cr_clause"),nodeNamedChildren(e)),r=nodeField("expr",e);let o,i,a,s;if(null!=r?List_isEmpty(n)||List_isEmpty(List_tail(n))?o=1:List_isEmpty(List_tail(List_tail(n)))?(t=List_head(n),Option_value(r),Seq_exists(e=>List_contains(e.type,ofArray(["atom","integer","float","string","list","tuple"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),toArray(nodeField("pat",t)))&&null==nodeField("guard",t)&&null==nodeField("guard",List_head(List_tail(n)))?(o=0,i=Option_value(r),a=List_head(n),s=List_head(List_tail(n))):o=1):o=1:o=1,0===o){const e=singleClauseExpression(a),t=singleClauseExpression(s);let n,r,o;if(null!=e&&null!=t?(Option_value(t),isFailureCall(Option_value(e))?(n=0,r=Option_value(e),o=Option_value(t)):n=1):n=1,0===n){const e=validationSuccess(o);return null!=e?[i,e]:void 0}return}}function ifValidation(e){let t,n,r;const o=List_filter(e=>equals(e.type,"if_clause"),nodeNamedChildren(e));let i,a,s;if(List_isEmpty(o)||List_isEmpty(List_tail(o))?i=1:List_isEmpty(List_tail(List_tail(o)))?(i=0,a=List_head(o),s=List_head(List_tail(o))):i=1,0===i){const e=nodeField("guard",a),o=nodeField("guard",s),i=singleClauseExpression(a),l=singleClauseExpression(s);let _,u,c,d,p;if(null!=e&&null!=o&&null!=i&&null!=l?(Option_value(l),t=Option_value(o),n=Option_value(i),r=Option_value(e),r.text!==trueAtom&&t.text===trueAtom&&isFailureCall(n)?(_=0,u=Option_value(e),c=Option_value(i),d=Option_value(o),p=Option_value(l)):_=1):_=1,0===_){const e=validationSuccess(p);return null!=e?[u,e]:void 0}return}}function ErlangValidation_extract(e){let t,n;const r=nodeField("body",e.Body);let o,i;if(null!=r?(Option_value(r),null==nodeField("guard",e.ParametersRoot)?(o=0,i=Option_value(r)):o=1):o=1,0===o){let e;const r=expressionChildren(i);let o,a;switch(List_isEmpty(r)?o=1:List_isEmpty(List_tail(r))?(o=0,a=List_head(r)):o=1,o){case 0:{const t=a.type;if("case_expr"===t){const t=caseValidation(a);e=null!=t?[a,t]:void 0}else if("if_expr"===t){const t=ifValidation(a);e=null!=t?[a,t]:void 0}else e=void 0;break}default:e=void 0}return null!=e?(t=e,n=t[1],new GuardedValidation(t[0],n[0],n[1],IdentityReturnPolicy.AcceptUntypedParameter)):void 0}}const functionClause="function_clause",funDeclaration="fun_decl",anonymousFun="anonymous_fun",clauseBody="clause_body",expressionArguments="expr_args";function declarationClause(e){let t;const n=nodeField("clause",e);return null!=n?(t=Option_value(n),equals(t.type,functionClause)?n:void 0):void 0}function Erlang_parametersOf(e){let t;return defaultArg((t=nodeField("args",e),null!=t?nodeNamedChildren(Option_value(t)):void 0),List_empty())}function Erlang_bodyItems(e){let t,n;return equals(e.type,clauseBody)?nodeNamedChildren(e):defaultArg((t=equals(e.type,funDeclaration)?(n=declarationClause(e),null!=n?nodeField("body",Option_value(n)):void 0):nodeField("body",e),null!=t?nodeNamedChildren(Option_value(t)):void 0),nodeNamedChildren(e))}function namedCallable(e,t){let n,r;return new CallableView(e,defaultArg(nodeField("body",t),t),e,CallableRole.NamedDefinition,(n=nodeField("name",t),null!=n?(r=Option_value(n),r.text):void 0),Erlang_parametersOf(t))}function anonymousCallable(e){let t,n;return new CallableView(e,defaultArg(nodeField("body",e),e),e,CallableRole.InlineAnonymous,(t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0),Erlang_parametersOf(e))}function Erlang_callableViews(e){let t;const n=e.type;return equals(n,funDeclaration)?ofArray(toArray((t=declarationClause(e),null!=t?namedCallable(e,Option_value(t)):void 0))):equals(n,anonymousFun)?List_map(anonymousCallable,List_filter(e=>equals(e.type,"fun_clause"),nodeNamedChildren(e))):List_empty()}function branchCount(e){const t=List_filter(e=>List_contains(e.type,ofArray(["cr_clause","if_clause"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeNamedChildren(e)),n=e.type;if("case_expr"===n){const e=List_exists(e=>null==nodeField("guard",e)&&Seq_exists(e=>equals(e.type,"var"),toArray(nodeField("pat",e))),t);return List_length(t)+(e?0:1)}if("if_expr"===n){const e=List_exists(e=>Seq_exists(e=>List_exists(e=>"true"===e.text,nodeNamedChildren(e)),toArray(nodeField("guard",e))),t);return List_length(t)+(e?0:1)}if("receive_expr"===n){const n=null!=nodeField("after",e);return List_length(t)+(n?1:0)}}function cognitiveStructure(e){const t=e.type;let n,r;switch("case_expr"===t||"if_expr"===t||"receive_expr"===t?n=0:"catch_clause"===t?n=1:"paren_expr"===t?equals(t,anonymousFun)?(n=2,r=t):n=3:equals(t,anonymousFun)?(n=2,r=t):n=4,n){case 0:return new CognitiveStructure(0,[CognitiveIncrement.Structural,List_filter(e=>List_contains(e.type,ofArray(["cr_clause","if_clause","receive_after"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeNamedChildren(e))]);case 1:{const t=nodeField("body",e);return null!=t?new CognitiveStructure(0,[CognitiveIncrement.Structural,List_singleton(Option_value(t))]):void 0}case 2:return CognitiveStructure.Closure;case 3:{const t=nodeField("expr",e);return null!=t?new CognitiveStructure(2,[Option_value(t)]):void 0}default:return}}function booleanOperator(e){return equals(e.type,"binary_op_expr")?List_tryPick(e=>{switch(e.text){case"andalso":return BooleanOperator.And;case"orelse":return BooleanOperator.Or;default:return}},nodeChildren(e)):void 0}function Erlang_equalityComparisons(e){if(equals(e.type,"binary_op_expr")){const t=List_exists(e=>List_contains(e.text,ofArray(["==","=:="]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),nodeChildren(e)),n=nodeField("lhs",e),r=nodeField("rhs",e);let o,i,a;return null!=n&&null!=r?(Option_value(r),Option_value(n),t?(o=0,i=Option_value(n),a=Option_value(r)):o=1):o=1,0===o?List_singleton(new EqualityComparison(i,a)):List_empty()}return List_empty()}function Erlang_importInfo(e){let t,n;const r=e.type;let o;switch(o="import_attribute"===r?0:"pp_include"===r||"pp_include_lib"===r?1:2,o){case 0:return ofArray(toArray((t=nodeField("module",e),null!=t?(n=Option_value(t),new ImportInfo(ImportKind.Module,n.text,List_choose(e=>{let t;const n=nodeField("fun",e);return null!=n?(t=Option_value(n),new ImportBinding(t.text,t.text)):void 0},List_filter(e=>equals(e.type,"fa"),nodeNamedChildren(e))))):void 0)));case 1:return List_map(e=>new ImportInfo(ImportKind.Header,trim(e.text,'"'),List_empty()),List_filter(e=>equals(e.type,"string"),nodeNamedChildren(e)));default:return List_empty()}}function Erlang_errorHandlingRegion(e){if(equals(e.type,"try_expr")&&!List_exists(e=>equals(e.type,"cr_clause"),nodeNamedChildren(e))){const t=nodeNamedChildren(e),n=List_append(List_filter(e=>equals(e.type,"catch_clause"),t),List_filter(e=>equals(e.type,"try_after"),t));if(List_isEmpty(n))return;{const r=List_takeWhile(e=>!List_contains(e.type,ofArray(["cr_clause","catch_clause","try_after"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),t);return new ErrorHandlingRegion(e,r,r,List_collect(Erlang_bodyItems,n),List_map(e=>new RecoveryBody(e,Erlang_bodyItems(e)),n))}}}const erlangLanguageAdapter=new LanguageAdapter("erlang","grammars/tree-sitter-erlang.wasm",new NodeTypes(clauseBody,expressionArguments,void 0,void 0,void 0,void 0,void 0,anonymousFun,"import_attribute","pp_include",List_singleton("pp_include_lib"),void 0,"match_expr","source_file",void 0,"comment","integer","float","string"),e=>equals(e.type,funDeclaration),e=>{let t,n;return ofArray(toArray((t=declarationClause(e),null!=t?(n=Option_value(t),new FunctionHead(n,n)):void 0)))},Erlang_callableViews,ofArray(["var","atom","tuple","list","match_expr"]),ofArray(["case_expr","if_expr","receive_expr","catch_clause"]),branchCount,cognitiveStructure,ofArray(["case_expr","if_expr","receive_expr","try_expr"]),booleanOperator,e=>!1,List_singleton("var"),e=>{},e=>{},new GenericBrackets("<",">"),Set_empty({Compare:(e,t)=>0|comparePrimitives(e,t)}),Erlang_errorHandlingRegion,Erlang_bodyItems,List_empty(),"a tagged tuple or record",Erlang_equalityComparisons,e=>{},e=>List_empty(),e=>!!equals(e.type,"atom")||equals(e.type,"integer"),e=>List_empty(),List_empty(),e=>!1,e=>!1,e=>Seq_exists(e=>equals(e.type,"arity"),toArray(nodeParent(e))),e=>e.text,e=>!!equals(e.type,"atom")&&List_contains(e.text,ofArray(["true","false"]),{Equals:(e,t)=>e===t,GetHashCode:e=>0|stringHash(e)}),e=>Seq_exists(e=>!!equals(e.type,expressionArguments)&&Seq_exists(e=>equals(e.type,"call"),toArray(nodeParent(e))),toArray(nodeParent(e))),e=>equals(e.type,"pp_define"),Erlang_importInfo,(e,t)=>!1,e=>!1,e=>!1,e=>{},e=>List_empty(),ErlangValidation_extract);function simpleImport(e,t){const n=t.text;return List_singleton(new ImportInfo(ImportKind.Module,""===e?n:e,List_singleton(new ImportBinding(n,n))))}function aliasImport(e,t){const n=nodeField("path",t),r=nodeField("alias",t);let o,i,a;return null!=n&&null!=r?(o=0,i=Option_value(r),a=Option_value(n)):o=1,0===o?List_singleton(new ImportInfo(ImportKind.Members,""===e?a.text:e,List_singleton(new ImportBinding(a.text,i.text)))):List_empty()}function memberImport(e,t){const n=nodeField("path",t),r=nodeField("name",t);let o,i,a;if(null!=n&&null!=r?(o=0,i=Option_value(r),a=Option_value(n)):o=1,0===o){const t=""===e?a.text:e+"::"+a.text,n=i.text;return List_singleton(new ImportInfo(ImportKind.Members,t,List_singleton(new ImportBinding(n,n))))}return List_empty()}function wildcardImport(e,t){let n,r;return List_singleton(new ImportInfo(ImportKind.Wildcard,defaultArg((n=List_tryHead(nodeNamedChildren(t)),null!=n?(r=Option_value(n),r.text):void 0),e),List_empty()))}function readUseTree(e,t){const n=t.type;return"scoped_use_list"===n?scopedImport(e,t):"use_list"===n?List_collect(t=>readUseTree(e,t),nodeNamedChildren(t)):"use_as_clause"===n?aliasImport(e,t):"scoped_identifier"===n?memberImport(e,t):"use_wildcard"===n?wildcardImport(e,t):simpleImport(e,t)}function scopedImport(e,t){let n,r,o;const i=defaultArg((n=nodeField("path",t),null!=n?(r=Option_value(n),r.text):void 0),e),a=List_collect(e=>readUseTree(i,e),defaultArg((o=nodeField("list",t),null!=o?nodeNamedChildren(Option_value(o)):void 0),List_empty()));return List_singleton(new ImportInfo(List_exists(e=>equals(e.Kind,ImportKind.Wildcard),a)?ImportKind.Wildcard:List_isEmpty(a)?ImportKind.Module:ImportKind.Members,i,List_collect(e=>e.Bindings,a)))}function RustImports_importInfo(e){let t;return defaultArg((t=nodeField("argument",e),null!=t?readUseTree("",Option_value(t)):void 0),List_empty())}function RustImports_isReExport(e,t){let n;const r=nodeParent(t);let o,i;return null!=r?(n=Option_value(r),equals(n.type,"source_file")?(o=0,i=Option_value(r)):o=1):o=1,0===o&&!!List_exists(e=>equals(e.type,"visibility_modifier"),nodeChildren(t))&&List_forAll(e=>{const t=e.type;return"mod_item"===t?null==nodeField("body",e):List_contains(t,ofArray(["use_declaration","line_comment","block_comment","attribute_item","inner_attribute_item"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})},nodeNamedChildren(i))}const noneVariant="None";function expressions(e){return List_filter(e=>!List_contains(e.type,ofArray(["line_comment","block_comment"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),nodeNamedChildren(e))}function RustValidation_unwrap(e){e:for(;;){const t=e;if(List_contains(t.type,ofArray(["expression_statement","return_expression"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})){const n=expressions(t);let r,o;if(List_isEmpty(n)?r=1:List_isEmpty(List_tail(n))?(r=0,o=List_head(n)):r=1,0===r){e=o;continue e}return t}return t}}function carrier(e){const t=nodeField("return_type",e.ParametersRoot);if(null!=t){const e=Option_value(t);if(equals(e.type,"generic_type")){const t=expressions(e);let n,r;if(List_isEmpty(t)?n=1:equals(List_head(t).type,"type_identifier")?(n=0,r=List_head(t)):n=1,0===n)switch(r.text){case"Result":return["Err","Ok"];case"Option":return[noneVariant,"Some"];default:return}return}return}}function variantPayload(e,t){let n;const r=RustValidation_unwrap(t);if(equals(r.type,"call_expression")){const t=nodeField("function",r),o=nodeField("arguments",r);let i,a,s;if(null!=t&&null!=o?(n=Option_value(t),Option_value(o),equals(n.type,"identifier")&&n.text===e?(i=0,a=Option_value(o),s=Option_value(t)):i=1):i=1,0===i){const e=expressions(a);let t,n;return List_isEmpty(e)?t=1:List_isEmpty(List_tail(e))?(t=0,n=List_head(e)):t=1,0===t?some(n):void 0}return}}function RustValidation_rejects(e,t){const n=RustValidation_unwrap(t);return e===noneVariant?!!equals(n.type,"identifier")&&n.text===noneVariant:null!=variantPayload(e,n)}function RustValidation_success(e,t){let n,r;const o=variantPayload(e,t);return r=null!=o?(n=Option_value(o),equals(n.type,"identifier")?o:void 0):void 0,null!=r?new ValidationSuccess(0,[Option_value(r)]):void 0}function earlyRejects(e,t){const n=expressions(t);let r,o;if(List_isEmpty(n)?r=1:List_isEmpty(List_tail(n))&&equals(List_head(n).type,"expression_statement")?(r=0,o=List_head(n)):r=1,0===r){const t=expressions(o);let n,r;return List_isEmpty(t)?n=1:List_isEmpty(List_tail(t))&&equals(List_head(t).type,"return_expression")?(n=0,r=List_head(t)):n=1,0===n&&RustValidation_rejects(e,r)}return!1}function guardedIf(e,t,n){let r,o,i;if(List_isEmpty(n)||List_isEmpty(List_tail(n))?r=1:List_isEmpty(List_tail(List_tail(n)))&&equals(RustValidation_unwrap(List_head(n)).type,"if_expression")?(r=0,o=List_head(n),i=List_head(List_tail(n))):r=1,0===r){const n=RustValidation_unwrap(o),r=nodeField("condition",n),a=nodeField("consequence",n),s=nodeField("alternative",n);let l,_,u;if(null!=r&&null!=a&&null==s?(Option_value(r),earlyRejects(e,Option_value(a))?(l=0,_=Option_value(a),u=Option_value(r)):l=1):l=1,0===l){const e=RustValidation_success(t,i);return null!=e?[n,u,e]:void 0}return}}function matched(e,t,n){let r,o,i,a,s,l;if(List_isEmpty(n)?s=1:List_isEmpty(List_tail(n))&&equals(RustValidation_unwrap(List_head(n)).type,"match_expression")?(s=0,l=List_head(n)):s=1,0===s){const n=RustValidation_unwrap(l),s=defaultArg((r=nodeField("body",n),null!=r?expressions(Option_value(r)):void 0),List_empty()),_=nodeField("value",n);let u,c,d,p;if(null!=_?List_isEmpty(s)||List_isEmpty(List_tail(s))?u=1:List_isEmpty(List_tail(List_tail(s)))?(u=0,c=Option_value(_),d=List_head(s),p=List_head(List_tail(s))):u=1:u=1,0===u){const r=nodeField("pattern",d),s=nodeField("pattern",p),l=nodeField("value",d),_=nodeField("value",p);let u,m,f,y,h;if(null!=r&&null!=s&&null!=l&&null!=_?(Option_value(_),o=Option_value(s),i=Option_value(l),a=expressions(Option_value(r)),!List_isEmpty(a)&&List_isEmpty(List_tail(a))&&List_contains(List_head(a).type,ofArray(["integer_literal","char_literal","string_literal","boolean_literal","slice_pattern","tuple_pattern"]),{Equals:equals,GetHashCode:e=>0|safeHash(e)})&&"_"===o.text&&RustValidation_rejects(e,i)?(u=0,m=Option_value(l),f=Option_value(s),y=Option_value(r),h=Option_value(_)):u=1):u=1,0===u){const e=RustValidation_success(t,h);return null!=e?[n,c,e]:void 0}return}return}}function RustValidation_extract(e){let t;const n=carrier(e);if(null!=n){const r=n[1],o=n[0],i=expressions(e.Body);let a;return a=guardedIf(o,r,i)??matched(o,r,i),null!=a?(t=a,new GuardedValidation(t[0],t[1],t[2],IdentityReturnPolicy.AcceptUntypedParameter)):void 0}}function kind(e){return e}function is(e,t){return equals(t.type,kind(e))}function Rust_parameters(e){let t,n,r;return defaultArg((t=nodeField("parameters",e),null!=t?(n=Option_value(t),r=nodeNamedChildren(n),is("closure_parameters",n)?r:List_filter(e=>is("parameter",e),r)):void 0),List_empty())}function hasSelfParameter(e){return Seq_exists(e=>List_exists(e=>is("self_parameter",e),nodeNamedChildren(e)),toArray(nodeField("parameters",e)))}function Rust_callableViews(e){let t,n,r,o,i,a;const s=e.type;if("function_item"===s)return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,CallableRole.NamedDefinition,(t=nodeField("name",e),null!=t?(n=Option_value(t),n.text):void 0),Rust_parameters(e)));if("closure_expression"===s){let t;const n=nodeParent(e);let s,l;switch(null!=n&&is("let_declaration",Option_value(n))?(s=0,l=Option_value(n)):s=1,s){case 0:{let e;const n=nodeField("pattern",l);e=null!=n?(r=Option_value(n),r.text):void 0,t=[(i=nodeParent(l),o=null!=i?(a=Option_value(i),a.type):void 0,null!=o&&"source_file"===o?new CallableRole(1,[AnonymousBindingScope.ModuleBinding]):CallableRole.InlineAnonymous),e];break}default:t=[CallableRole.InlineAnonymous,void 0]}return List_singleton(new CallableView(e,defaultArg(nodeField("body",e),e),e,t[0],t[1],Rust_parameters(e)))}return List_empty()}function typedParameter(e){const t=nodeField("pattern",e),n=nodeField("type",e);let r,o,i;if(null!=t&&null!=n?(Option_value(n),is("identifier",Option_value(t))?(r=0,o=Option_value(n),i=Option_value(t)):r=1):r=1,0===r)return new TypedParameter(i.text,o.text)}function Rust_branchCount(e){let t;return is("match_expression",e)?List_length(List_filter(e=>is("match_arm",e),defaultArg((t=nodeField("body",e),null!=t?nodeNamedChildren(Option_value(t)):void 0),List_empty()))):void 0}function Rust_cognitiveStructure(e){return is("match_expression",e)?new CognitiveStructure(0,[CognitiveIncrement.Structural,ofArray(toArray(nodeField("body",e)))]):classify(ofArray([kind("if_expression"),kind("for_expression"),kind("while_expression"),kind("loop_expression")]),e)}function numericLiteralText(e){return String_replace(replace(e.text,"_?(?:u(?:8|16|32|64|128|size)|i(?:8|16|32|64|128|size)|f(?:32|64))$",""),"_","")}const rustLanguageAdapter=new LanguageAdapter("rust","grammars/tree-sitter-rust.wasm",new NodeTypes(kind("block"),kind("parameters"),kind("if_expression"),kind("else_clause"),kind("for_expression"),kind("while_expression"),void 0,kind("closure_expression"),kind("use_declaration"),void 0,List_empty(),kind("expression_statement"),kind("let_declaration"),kind("source_file"),void 0,kind("line_comment"),kind("integer_literal"),kind("float_literal"),kind("string_literal")),e=>is("function_item",e),e=>List_singleton(new FunctionHead(e,defaultArg(nodeField("body",e),e))),Rust_callableViews,List_singleton(kind("parameter")),ofArray([kind("if_expression"),kind("for_expression"),kind("while_expression"),kind("loop_expression"),kind("match_expression")]),Rust_branchCount,Rust_cognitiveStructure,ofArray([kind("if_expression"),kind("for_expression"),kind("while_expression"),kind("loop_expression"),kind("match_expression")]),e=>{let t;if(is("binary_expression",e)){let n;const r=nodeField("operator",e);let o;if(n=null!=r?(t=Option_value(r),t.text):void 0,null!=n)switch(n){case"&&":o=0;break;case"||":o=1;break;default:o=2}else o=2;switch(o){case 0:return BooleanOperator.And;case 1:return BooleanOperator.Or;default:return}}},e=>!1,ofArray([kind("identifier"),kind("field_expression"),kind("scoped_identifier")]),typedParameter,e=>{let t;const n=nodeField("return_type",e);return null!=n?(t=Option_value(n),t.text):void 0},new GenericBrackets("<",">"),Set_ofList(ofArray(["bool","char","i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","String"]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),e=>{},e=>{let t;return defaultArg((t=nodeField("body",e),null!=t?nodeNamedChildren(Option_value(t)):void 0),nodeNamedChildren(e))},List_empty(),"a newtype struct or enum",e=>{if(is("binary_expression",e)&&Seq_exists(e=>"=="===e.text,toArray(nodeField("operator",e)))){const t=nodeField("left",e),n=nodeField("right",e);let r,o,i;return null!=t&&null!=n?(r=0,o=Option_value(t),i=Option_value(n)):r=1,0===r?List_singleton(new EqualityComparison(o,i)):List_empty()}return List_empty()},e=>{},e=>List_empty(),e=>List_contains(e.type,ofArray([kind("integer_literal"),kind("char_literal"),kind("boolean_literal"),kind("string_literal")]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),e=>List_empty(),List_singleton(kind("index_expression")),e=>!1,e=>!1,e=>Seq_exists(e=>is("array_type",e),toArray(nodeParent(e))),numericLiteralText,e=>is("boolean_literal",e),e=>Seq_exists(e=>!!is("arguments",e)&&Seq_exists(e=>is("call_expression",e),toArray(nodeParent(e))),toArray(nodeParent(e))),e=>List_contains(e.type,ofArray([kind("const_item"),kind("static_item"),kind("enum_variant")]),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),RustImports_importInfo,RustImports_isReExport,e=>is("impl_item",e),e=>!hasSelfParameter(e),e=>{let t;const n=nodeField("type",e);return null!=n?(t=Option_value(n),t.text):void 0},e=>List_empty(),RustValidation_extract),languages=Map_ofList(ofArray([["python",pythonLanguageAdapter],["fsharp",fSharpLanguageAdapter],["typescript",typeScriptLanguageAdapter],["kotlin",kotlinLanguageAdapter],["cpp",cPlusPlusLanguageAdapter],["csharp",cSharpLanguageAdapter],["erlang",erlangLanguageAdapter],["rust",rustLanguageAdapter]]),{Compare:(e,t)=>0|comparePrimitives(e,t)}),suffixToLanguageId=List_sortByDescending(e=>0|e[0].length,ofArray([[".py","python"],[".fs","fsharp"],[".fsx","fsharp"],[".fsi","fsharp"],[".ts","typescript"],[".cs","csharp"],[".csx","csharp"],[".erl","erlang"],[".hrl","erlang"],[".rs","rust"],[".kt","kotlin"],[".kts","kotlin"],[".cpp","cpp"],[".cppm","cpp"],[".cc","cpp"],[".ccm","cpp"],[".cxx","cpp"],[".cxxm","cpp"],[".c++","cpp"],[".c++m","cpp"],[".hpp","cpp"],[".hh","cpp"],[".hxx","cpp"],[".h++","cpp"],[".h","cpp"],[".ii","cpp"],[".ino","cpp"],[".inl","cpp"],[".ipp","cpp"],[".ixx","cpp"],[".mpp","cpp"],[".mxx","cpp"],[".tpp","cpp"],[".txx","cpp"],[".hpp.in","cpp"],[".h.in","cpp"]]),{Compare:(e,t)=>0|comparePrimitives(e,t)});function Registry_tryFind(e){return Map_tryFind(e,languages)}function resolveLanguageForFile(e){let t;const n=List_tryFind(t=>endsWith(e,t[0],5),suffixToLanguageId);return t=null!=n?n[1]:void 0,null!=t?Registry_tryFind(t):void 0}function analyzeParsedSource(e,t,n,r,o){const i=n;try{return withParsedTree(e,r,e=>{try{return new FSharpResult$2(0,[analyzeWith(o,new AnalysisInput(r,e,t,i))])}catch(e){return new FSharpResult$2(1,[new AnalysisError(5,[i,Types_toString(e)])])}})}catch(e){return new FSharpResult$2(1,[new AnalysisError(4,[i,Types_toString(e)])])}}const parserCache=new Map([]);function grammarPath(e){return(0,external_node_path_namespaceObject.join)((0,external_node_path_namespaceObject.join)(__dirname,".."),e)}function createParser(e){const t=task();return t.Run(t.Delay(()=>t.TryWith(t.Delay(()=>t.Bind(init(),()=>t.Bind(web_tree_sitter.TM.load(grammarPath(e.GrammarPath)),e=>{const n=new web_tree_sitter.iX;return n.setLanguage(e),t.Return(new FSharpResult$2(0,[n]))}))),n=>t.Return(new FSharpResult$2(1,[new AnalysisError(3,[e.Id,Types_toString(n)])])))))}function loadParser(e){const t=task();return t.Run(t.Delay(()=>{let n;const r=new FSharpRef(defaultOf());return n=[tryGetValue(parserCache,e.Id,r),r.contents],n[0]?t.Return(new FSharpResult$2(0,[n[1]])):t.Bind(createParser(e),n=>{const r=n;if(0===r.tag){const n=r.fields[0];return addToDict(parserCache,e.Id,n),t.Return(new FSharpResult$2(0,[n]))}return t.Return(new FSharpResult$2(1,[r.fields[0]]))})}))}function analyzeFile(e,t,n){const r=e,o=task();return o.Run(o.Delay(()=>{const e=resolveLanguageForFile(r);if(null!=e){const i=e;return o.Bind(loadParser(i),e=>o.Return(Result_Bind(e=>Result_Map(e=>e.Violations,analyzeParsedSource(e,i,r,t,n)),e)))}return o.Return(new FSharpResult$2(1,[new AnalysisError(0,[r])]))}))}function readSource(e){const t=readFileSyncSafe(e,"utf8");return 1===t.tag?new FSharpResult$2(1,[new AnalysisError(2,[e,t.fields[0]])]):new FSharpResult$2(0,[t.fields[0]])}function analyzePath(e,t){const n=task();return n.Run(n.Delay(()=>{const r=readSource(e);return 0===r.tag?n.ReturnFrom(analyzeFile(e,r.fields[0],t)):n.Return(new FSharpResult$2(1,[r.fields[0]]))}))}function analyzeFiles(e,t){const n=task();return n.Run(n.Delay(()=>{if(List_isEmpty(e))return n.Return(new FSharpResult$2(0,[List_empty()]));{const r=List_head(e);return n.Bind(analyzePath(r,t),o=>{const i=o;return 0===i.tag?n.Bind(analyzeFiles(List_tail(e),t),e=>n.Return(Result_Map(e=>cons(new FileResult((0,external_node_path_namespaceObject.relative)(process.cwd(),r),i.fields[0]),e),e))):n.Return(new FSharpResult$2(1,[i.fields[0]]))})}}))}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)?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&&!startsWith(e,"#",4))))):List_empty()}function matchesLiteralPattern(e,t){const n=t;return n.indexOf("/")>=0?e===n||startsWith(e,n+"/",4):Array_contains(n,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(startsWith(t,List_head(r),4)){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}}})(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=>{const t=e;return e.indexOf("*")>=0?matchesBasenameGlob(t,o):matchesLiteralPattern(r,t)},n)}}var Scan_record_type,Scan_string_type,Scan_list_type;const ignoredDirectoryNames=Set_ofList(ofArray(["node_modules",".git","bin","obj","dist","out","build","fable-out","fable_modules","fable-tests","spike-js",".next","coverage",".vscode-test","target",".gradle","__pycache__",".venv","venv",".tox",".nox",".pytest_cache",".mypy_cache",".ruff_cache"]),{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(getCharAtIndex(external_node_path_namespaceObject.sep,0),o),a=-1===i?".":substring(e,0,i),s=substring(e,e.lastIndexOf("*")+1),l=!startsWith(s,".",4)||s.indexOf("*")>=0?void 0:s;if((0,external_node_fs_namespaceObject.existsSync)(a)&&(0,external_node_fs_namespaceObject.statSync)(a).isDirectory()){const e=walkDirectory(a,t,List_empty());return defaultArg((n=l,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|compare(e,t)})),{Compare:(e,t)=>0|compare(e,t)})}const toolVersion="0.23.4";function sarifLevel(e){switch(e.tag){case 1:return"warning";case 0:return"note";default:return"error"}}function renderSarif(e){const t=List_collect(e=>List_map(t=>[e.FilePath,t],e.Violations),e),n=List_toArray(List_map(e=>({id:violationRuleId(e),name:violationRuleName(e),shortDescription:{text:"Energy State Analyzer "+violationDisplayName(e)+" finding"},helpUri:violationHelpUri(e)}),List_sortBy(violationTypeName,List_distinct(List_map(e=>e.Type,List_map(e=>e[1],t)),{Equals:equals,GetHashCode:e=>0|safeHash(e)}),{Compare:(e,t)=>0|comparePrimitives(e,t)}))),r=List_toArray(List_map(e=>{const t=e[1],n=List_toArray(List_map(e=>({line:e.Line+1,weight:e.Weight}),t.Hotspots));return{ruleId:violationRuleId(t.Type),level:sarifLevel(t.Severity),message:{text:t.Message},locations:[{physicalLocation:{artifactLocation:{uri:e[0]},region:{startLine:t.Line+1,startColumn:t.Column+1}}}],properties:{energyStateSeverity:severityName(t.Severity),hotspots:n}}},t));return{$schema:"https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",version:"2.1.0",runs:[{tool:{driver:{name:"Energy State Analyzer",version:toolVersion,informationUri:"https://github.com/cardamomcode/energy-state-analyzer",rules:n}},results:r}]}}const Int32_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&Int32_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 parseOverflow(e,t){return OverflowException_$ctor_Z721C83C5(`Value was either too large or too small for ${8===t?e?"an unsigned byte":"a signed byte":(e?"a UInt":"an Int")+t}.`)}function Int32_parse(e,t,n,r,o){if(null==e)throw ArgumentNullException_$ctor_Z721C83C5("s");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[a,s]=Int32_getRange(n,r);if(e>=a&&e<=s)return e;throw parseOverflow(n,r)}}throw FormatException_$ctor_Z721C83C5(`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 ReportHuman_union_type;const maxComplexityScore=100,scoreCeiling=10,lowThreshold=4,mediumThreshold=7,highThreshold=9,highFileScore=7.5,mediumFileScore=5;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=ofArray([[0,0],[10,3.9],[20,6.9],[50,8.9],[100,10]]);function complexityToScore(e){if(e<=0)return 0;if(e>=maxComplexityScore)return scoreCeiling;{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<lowThreshold?RiskLevel.LowRisk:e<mediumThreshold?RiskLevel.MediumRisk:e<highThreshold?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"relatively simple; keep changes small and verify behavior";case 2:return"becoming harder to understand and test; simplify branching or nesting";case 3:return"complex and difficult to verify; separate responsibilities and test decisions independently";case 4:return"extremely complex; restructure into smaller, independently understandable and testable units";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"Broad Protected Scope";case 13:return"Recovery Dominance";case 14:return"Oversized Recovery Block";case 16:return"Parse, don't validate";case 15: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"terminal conditionals or deep if-nesting that may be easier to read with guard clauses or a named operation";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 overly broad protected try region";case 13:return"recovery/cleanup policy that dominates a function";case 14:return"an individual handler or cleanup body exceeding the configured line limit";case 16:return"a checked property that is not preserved in the returned type";case 15: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),a=classifyScore(i);let s;if(1===List_length(o))s=toText(printf("1 function scores %d"))(t);else{const e=0|List_length(o),n=join(", ",List_map(int32ToString,o));s=toText(printf("%d functions score %s (worst: %d)"))(e)(n)(t)}return n=riskLabel(a),r=riskDescription(a),toText(printf("- **%s**: %s — score %.1f (%s): %s."))(e)(s)(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),a=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)},ofArray(["high","medium","low"]))),s=defaultArg((n=categoryBlurb(e),null!=n?" — "+n:void 0),""),l=1===List_length(t)?"":"s";return r=categoryLabel(e),o=0|List_length(t),toText(printf("- **%s**: %d finding%s (%s)%s."))(r)(o)(l)(a)(s)}}}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)?highFileScore:List_exists(e=>equals(e.Severity,Severity.Medium),e)?mediumFileScore: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(ofArray([(t=riskLabel(classifyScore(n)),toText(printf("## %s — %s (score %.1f)"))(e.FilePath)(t)(n)),""]),r))}const scoreLegend=join("\n",["## Score legend","","_Scores use the familiar [CVSS 0–10 severity bands](https://www.first.org/cvss/v3.1/specification-document#t5) to communicate the seriousness of analyzer findings. These are code complexity and maintainability scores, not security vulnerability scores._","","| Score | Severity | Meaning and action | Cyclomatic/cognitive input |","| --- | --- | --- | --- |","| 0.0 | None | No violations found | — |","| 0.1–3.9 | Low | Relatively simple; keep changes small and verify behavior | 1–10 |","| 4.0–6.9 | Medium | Becoming harder to understand and test; simplify branching or nesting | 11–20 |","| 7.0–8.9 | High | Complex and difficult to verify; separate responsibilities and test decisions independently | 21–50 |","| 9.0–10.0 | Critical | Extremely complex; restructure into smaller, independently understandable and testable units | 50+ |","","_Cyclomatic complexity describes independent control-flow paths; cognitive complexity estimates reading effort. The report applies the same numeric curve to both as a prioritization heuristic, not evidence that they measure equivalent effort. A file with no complexity violations 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,a,s;const l=List_sortByDescending(e=>fileScore(e.Violations),List_filter(e=>!List_isEmpty(e.Violations),e),{Compare:(e,t)=>0|comparePrimitives(e,t)}),_=List_length(e)-List_length(l)|0,u=List_map(e=>[e.FilePath,fileScore(e.Violations)],e),c=List_fold((e,t)=>t[1]>e[1]?t:e,["",0],u),d=Map_ofList(List_countBy(e=>classifyScore(e[1]),u,{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(ofArray(["# Energy State Report","",scoreLegend,"",(t=0|List_length(e),n=0|List_length(l),toText(printf("**%d file%s scanned** — %d with no findings, %d flagged"))(t)(f)(_)(n)),""]),List_append(List_collect(e=>ofArray([renderFileSection(e),""]),l),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)),(a=0|defaultArg(Map_tryFind(RiskLevel.HighRisk,d),0),toText(printf("| High | %d |"))(a)),(s=0|defaultArg(Map_tryFind(RiskLevel.Critical,d),0),toText(printf("| Critical | %d |"))(s)),"",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)]))))}var ReportDiff_union_type,ReportDiff_record_type,ReportDiff_string_type,ReportDiff_option_type,ReportDiff_int32_type,CliModes_union_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)),a=0|List_length(List_filter(e=>equals(e.Status,DiffStatus.New),e)),s=1===List_length(e)?"":"s";return join("\n",List_append(ofArray([toText(printf("# Energy State Diff vs `%s`"))(t),"","| File | Base | Head | Δ | Status |","| --- | --- | --- | --- | --- |"]),List_append(r,ofArray(["",(n=0|List_length(e),toText(printf("_%d file%s changed, %d worsened, %d improved, %d new._"))(n)(s)(o)(i)(a))]))))}class ReportFormat extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["Human","Markdown","Sarif","Json"]}static Human=new ReportFormat(0,[]);static Markdown=new ReportFormat(1,[]);static Sarif=new ReportFormat(2,[]);static Json=new ReportFormat(3,[])}function ReportFormat_$reflection(){return CliModes_union_type("Energy.CliModes.ReportFormat",[],ReportFormat,()=>[[],[],[],[]])}const reportFormats=Map_ofList(ofArray([["human",ReportFormat.Human],["md",ReportFormat.Markdown],["markdown",ReportFormat.Markdown],["sarif",ReportFormat.Sarif],["json",ReportFormat.Json]]),{Compare:(e,t)=>0|comparePrimitives(e,t)});function parseReportFormat(e){const t=Map_tryFind(e,reportFormats);return null==t?new FSharpResult$2(1,["Unsupported report format: "+e]):new FSharpResult$2(0,[t])}function printUsage(){error("Usage: energy-state-cli <file.py|.fs|.fsx|.ts> [thresholds...]"),error(" energy-state-cli <path...> [--report json|md|human|sarif] [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 --medium-parameter-count N --high-parameter-count N"),error("Flags: --include-test-files (also flag magic numbers, magic strings, and opaque booleans 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){const t=summarize(e);return{files:List_toArray(List_map(e=>{const t=summarizeFile(e);return{filePath:t.FilePath,score:t.Score,counts:{low:t.Counts.Low,medium:t.Counts.Medium,high:t.Counts.High},byType:createObj(List_map(e=>[e[0],e[1]],Map_toList(t.ByType))),violations:List_toArray(List_map(violationJson,e.Violations))}},List_filter(e=>!equals(e.Violations,List_empty()),e))),filesScanned:List_length(e),totalScore:t.TotalScore,totalCounts:{low:t.TotalCounts.Low,medium:t.TotalCounts.Medium,high:t.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 runScan(e,t,n){const r=task();return r.Run(r.Delay(()=>r.Bind(analyzeFiles(resolveSupportedFiles(e,process.cwd()),t),e=>{const t=e;if(0===t.tag){const e=t.fields[0],o=summarize(e);return output(1===n.tag?renderMarkdownReport(o):2===n.tag?JSON.stringify(renderSarif(e),null,2):3===n.tag?JSON.stringify(summaryJson(e),null,2):renderHumanReport(e)),process.exit(hasBlockingViolations(o.TotalCounts)?1:0),r.Zero()}return error("energy-state-cli failed: "+analysisErrorMessage(t.fields[0])),process.exit(1),r.Zero()})))}function changedFilesFromGit(e){let t;return 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){const n=execFileSyncSafe("git",["show",e+":"+t],{encoding:"utf8",stdio:["ignore","pipe","ignore"]});return 1===n.tag?void error("energy-state-cli: could not read "+t+" at "+e+" (new file or rename) — treating as new"):n.fields[0]}function analyzeChanged(e,t,n,r,o){const i=task();return i.Run(i.Delay(()=>{if(List_isEmpty(n))return i.Return(new FSharpResult$2(0,[[List_reverse(r),List_reverse(o)]]));{const a=List_tail(n),s=List_head(n);return i.Bind(analyzePath(s,t),n=>{const l=n;if(0===l.tag){const n=summarizeFile(new FileResult(s,l.fields[0])),_=readAtRef(e,s);if(null!=_){const l=_;return i.Bind(analyzeFile(s,l,t),l=>{const _=l;if(0===_.tag){const l=summarizeFile(new FileResult(s,_.fields[0]));return i.ReturnFrom(analyzeChanged(e,t,a,cons(l,r),cons(n,o)))}return i.Return(new FSharpResult$2(1,[_.fields[0]]))})}return i.ReturnFrom(analyzeChanged(e,t,a,r,cons(n,o)))}return i.Return(new FSharpResult$2(1,[l.fields[0]]))})}}))}function runDiff(e,t,n,r){const o=task();return o.Run(o.Delay(()=>{const i=process.cwd(),a=loadIgnorePatterns(i),s=List_filter(e=>!isIgnored((0,external_node_path_namespaceObject.resolve)(e),i,a),List_filter(e=>null!=resolveLanguageForFile(e)&&(0,external_node_fs_namespaceObject.existsSync)(e),List_isEmpty(t)?changedFilesFromGit(e):t));return o.Bind(analyzeChanged(e,n,s,List_empty(),List_empty()),t=>{const n=t;if(0===n.tag){const t=diffSummaries(n.fields[0][0],n.fields[0][1]);return output(equals(r,ReportFormat.Markdown)?renderDiffMarkdown(t,e):JSON.stringify(diffJson(t),null,2)),process.exit(List_exists(e=>equals(e.Status,DiffStatus.Worsened),t)?1:0),o.Zero()}return error("energy-state-cli failed: "+analysisErrorMessage(n.fields[0])),process.exit(1),o.Zero()})}))}var Cli_record_type,Cli_list_type,Cli_string_type,Cli_option_type,Cli_tuple_type,Cli_int32_type,Cli_bool_type,Cli_union_type,Cli_ReportFormat_$reflection;class ParsedArguments extends Record{constructor(e,t,n,r,o,i,a,s,l){super(),this.Paths=e,this.BaseRef=t,this.Report=n,this.ConfigFile=r,this.Nesting=o,this.Cyclomatic=i,this.Cognitive=a,this.ParameterCount=s,this.IncludeTestFiles=l}}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_ReportFormat_$reflection())],["ConfigFile",Cli_option_type(Cli_string_type)],["Nesting",Cli_tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["Cyclomatic",Cli_tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["Cognitive",Cli_tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["ParameterCount",Cli_tuple_type(Cli_option_type(Cli_int32_type),Cli_option_type(Cli_int32_type))],["IncludeTestFiles",Cli_bool_type]])}const valueFlags=Set_ofList(ofArray(["base-ref","report","config","medium-nesting","high-nesting","medium-cyclomatic","high-cyclomatic","medium-cognitive","high-cognitive","medium-parameter-count","high-parameter-count"]),{Compare:(e,t)=>0|comparePrimitives(e,t)});class CliToken extends Union{constructor(e,t){super(),this.tag=e,this.fields=t}cases(){return["PositionalPath","BooleanFlag","ValueFlag","InvalidOption"]}}function CliToken_$reflection(){return Cli_union_type("Energy.Cli.CliToken",[],CliToken,()=>[[["Item",Cli_string_type]],[["Item",Cli_string_type]],[["Item",Cli_string_type]],[["Item",Cli_string_type]]])}function classifyArgument(e){if(startsWith(e,"--",4)){const t=substring(e,2);return"include-test-files"===t?new CliToken(1,[t]):FSharpSet__Contains(valueFlags,t)?new CliToken(2,[t]):new CliToken(3,[e])}return new CliToken(0,[e])}function parseValues(e){return((t,n,r)=>{e:for(;;){const o=t,i=n,a=r;if(o>=e.length)return new FSharpResult$2(0,[[List_reverse(i),a]]);{const s=classifyArgument(Array_item(o,e));switch(s.tag){case 1:t=o+1,n=i,r=Map_add(s.fields[0],"true",a);continue e;case 3:return new FSharpResult$2(1,["Unknown option: "+s.fields[0]]);case 2:{const l=s.fields[0],_=tryItem(o+1,e);let u,c;if(null!=_?startsWith(_,"--",4)?u=1:(u=0,c=_):u=1,0===u){t=o+2,n=i,r=Map_add(l,c,a);continue e}return new FSharpResult$2(1,["Missing value for --"+l])}default:t=o+1,n=cons(s.fields[0],i),r=a;continue e}}break}})(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){const e=n;let t;const r=new FSharpRef(0);return t=[Int32_tryParse(e,511,!1,32,r),r.contents],t[0]?t[1]:void 0}}function parseArguments(e){return Result_Bind(e=>{let t;const n=e[1],r=Seq_tryFind(e=>Seq_exists(e=>{let t;return!(t=new FSharpRef(0),[Int32_tryParse(e,511,!1,32,t),t.contents])[0]},toArray(Map_tryFind(e,n))),Set_filter(e=>"base-ref"!==e&&"report"!==e&&"config"!==e,valueFlags));return null==r?Result_Map(t=>new ParsedArguments(e[0],Map_tryFind("base-ref",n),t,Map_tryFind("config",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")],[asNumber(n,"medium-parameter-count"),asNumber(n,"high-parameter-count")],containsKey("include-test-files",n)),(t=Map_tryFind("report",n),null==t?new FSharpResult$2(0,[void 0]):Result_Map(e=>e,parseReportFormat(t)))):new FSharpResult$2(1,["Invalid integer for --"+r])},parseValues(e))}function buildThresholds(e){let t;return Result_Map(t=>{let n;const r=t.MagicNumber;let o;n=new MagicNumberOptions(r.Enabled,r.Allowlist,e.IncludeTestFiles);const i=t.MagicString;o=new MagicStringOptions(i.Enabled,i.MinDuplicates,i.Allowlist,e.IncludeTestFiles);const a=new OpaqueBooleanThresholds(t.OpaqueBoolean.Enabled,e.IncludeTestFiles);return new AnalyzeOptions(new NestingThresholds(t.Nesting.Enabled,defaultArg(e.Nesting[0],t.Nesting.MediumThreshold),defaultArg(e.Nesting[1],t.Nesting.HighThreshold)),new CyclomaticThresholds(t.Cyclomatic.Enabled,defaultArg(e.Cyclomatic[0],t.Cyclomatic.MediumThreshold),defaultArg(e.Cyclomatic[1],t.Cyclomatic.HighThreshold)),new CognitiveThresholds(t.Cognitive.Enabled,defaultArg(e.Cognitive[0],t.Cognitive.MediumThreshold),defaultArg(e.Cognitive[1],t.Cognitive.HighThreshold)),t.Coherence,t.MatchOpportunity,new ParameterCountThresholds(t.ParameterCount.Enabled,defaultArg(e.ParameterCount[0],t.ParameterCount.MediumThreshold),defaultArg(e.ParameterCount[1],t.ParameterCount.HighThreshold)),n,o,t.PrimitiveObsession,a,t.ParseDontValidate,t.LogicalControlFlow,t.Inversion,t.ErrorShadowing)},Result_MapError(configErrorMessage,(t=e.ConfigFile,null==t?loadAnalyzeOptions(process.cwd()):loadAnalyzeOptionsFromConfigPath(t))))}function validatePaths(e){const t=List_tryPick(e=>e.indexOf("*")>=0?void 0:(0,external_node_fs_namespaceObject.existsSync)(e)?(0,external_node_fs_namespaceObject.statSync)(e).isFile()&&null==resolveLanguageForFile(e)?"Unsupported input file: "+e:void 0:"Input path not found: "+e,e);return null==t?new FSharpResult$2(0,[void 0]):new FSharpResult$2(1,[t])}function runCli(){const e=task();return e.Run(e.Delay(()=>e.TryWith(e.Delay(()=>{const t=Result_Bind(e=>Result_Bind(()=>Result_Map(t=>[e,t],buildThresholds(e)),validatePaths(e.Paths)),parseArguments(process.argv.slice(2)));if(0===t.tag){const n=t.fields[0][1],r=t.fields[0][0],o=defaultArg(r.Report,null!=r.BaseRef?ReportFormat.Markdown:ReportFormat.Json),i=r.BaseRef;if(null==i)return List_isEmpty(r.Paths)?(printUsage(),process.exit(2),e.Zero()):e.Bind(runScan(r.Paths,n,o),()=>e.Zero());{const t=i;return e.Bind(runDiff(t,r.Paths,n,o),()=>e.Zero())}}return error("energy-state-cli: "+t.fields[0]),process.exit(2),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__})();
|