/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ "use strict";var R5=Object.create;var El=Object.defineProperty;var M5=Object.getOwnPropertyDescriptor;var I5=Object.getOwnPropertyNames;var N5=Object.getPrototypeOf,j5=Object.prototype.hasOwnProperty;var Z5=(i,e,t)=>e in i?El(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Qe=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),z5=(i,e)=>{for(var t in e)El(i,t,{get:e[t],enumerable:!0})},wy=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of I5(e))!j5.call(i,r)&&r!==t&&El(i,r,{get:()=>e[r],enumerable:!(n=M5(e,r))||n.enumerable});return i};var Dp=(i,e,t)=>(t=i!=null?R5(N5(i)):{},wy(e||!i||!i.__esModule?El(t,"default",{value:i,enumerable:!0}):t,i)),q5=i=>wy(El({},"__esModule",{value:!0}),i);var J=(i,e,t)=>(Z5(i,typeof e!="symbol"?e+"":e,t),t),ky=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Fu=(i,e,t)=>(ky(i,e,"read from private field"),t?t.call(i):e.get(i)),Tl=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)};var Qp=(i,e,t)=>(ky(i,e,"access private method"),t);var Gp=Qe((IF,Qy)=>{"use strict";var Yp=Object.defineProperty,xE=Object.getOwnPropertyDescriptor,PE=Object.getOwnPropertyNames,CE=Object.prototype.hasOwnProperty,EE=(i,e)=>{for(var t in e)Yp(i,t,{get:e[t],enumerable:!0})},TE=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of PE(e))!CE.call(i,r)&&r!==t&&Yp(i,r,{get:()=>e[r],enumerable:!(n=xE(e,r))||n.enumerable});return i},AE=i=>TE(Yp({},"__esModule",{value:!0}),i),Dy={};EE(Dy,{FileInputSuggest:()=>QE,FolderInputSuggest:()=>DE,FuzzyInputSuggest:()=>Hp,setNodeIcon:()=>IE});Qy.exports=AE(Dy);var Up=require("obsidian"),Hp=class extends Up.AbstractInputSuggest{constructor(i,e,t){super(i,e.inputEl),this.items=t}getSuggestions(i){let e=(0,Up.prepareSimpleSearch)(i),t=[];for(let n of this.items){let r=e(this.getItemText(n));r&&t.push({item:n,match:r})}return t}renderSuggestion(i,e){e.addClass("mod-complex");let t=e.createDiv({cls:"suggestion-content"});if(!i?.item){t.setText("No match found"),t.parentElement?.addClass("is-selected");return}let n=t.createDiv("suggestion-title");this.renderTitle(n,i);let r=t.createDiv("suggestion-note");this.renderNote(r,i)}renderMatches(i,e,t,n){(0,Up.renderMatches)(i,e,t,n)}},Ty=require("obsidian"),DE=class extends Hp{getItemText(i){return i.path}renderNote(i,e){let{item:t,match:n}=e;(0,Ty.renderMatches)(i,t.path,n.matches)}renderTitle(i,e){let{item:t,match:n}=e;(0,Ty.renderMatches)(i,t.name,n.matches,t.path.length-t.name.length)}},Ay=require("obsidian"),QE=class extends Hp{getItemText(i){return i.path}renderNote(i,e){let{item:t,match:n}=e;(0,Ay.renderMatches)(i,t.path,n.matches)}renderTitle(i,e){let{item:t,match:n}=e;(0,Ay.renderMatches)(i,t.name,n.matches,t.path.length-t.name.length)}},RE=require("obsidian"),ME={"has-node-icon":"helpers_has-node-icon","x-small":"helpers_x-small",small:"helpers_small",medium:"helpers_medium",large:"helpers_large","x-large":"helpers_x-large"};function IE(i,e){i.addClass(ME["has-node-icon"]),(0,RE.setIcon)(i,e)}});var au=Qe(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.regexpCode=pt.getEsmExportName=pt.getProperty=pt.safeStringify=pt.stringify=pt.strConcat=pt.addCodeArg=pt.str=pt._=pt.nil=pt._Code=pt.Name=pt.IDENTIFIER=pt._CodeOrName=void 0;var su=class{};pt._CodeOrName=su;pt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Jo=class extends su{constructor(e){if(super(),!pt.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};pt.Name=Jo;var Vn=class extends su{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((t,n)=>`${t}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((t,n)=>(n instanceof Jo&&(t[n.str]=(t[n.str]||0)+1),t),{})}};pt._Code=Vn;pt.nil=new Vn("");function w4(i,...e){let t=[i[0]],n=0;for(;n{"use strict";Object.defineProperty(Ki,"__esModule",{value:!0});Ki.ValueScope=Ki.ValueScopeName=Ki.Scope=Ki.varKinds=Ki.UsedValueState=void 0;var On=au(),IO=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},NO;(function(i){i[i.Started=0]="Started",i[i.Completed=1]="Completed"})(NO=Ki.UsedValueState||(Ki.UsedValueState={}));Ki.varKinds={const:new On.Name("const"),let:new On.Name("let"),var:new On.Name("var")};var Lh=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof On.Name?e:this.name(e)}name(e){return new On.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){var t,n;if(!((n=(t=this._parent)===null||t===void 0?void 0:t._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Ki.Scope=Lh;var $h=class extends On.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:t,itemIndex:n}){this.value=e,this.scopePath=(0,On._)`.${new On.Name(t)}[${n}]`}};Ki.ValueScopeName=$h;var ij=(0,On._)`\n`,jO=class extends Lh{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?ij:On.nil}}get(){return this._scope}name(e){return new $h(e,this._newName(e))}value(e,t){var n;if(t.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let r=this.toName(e),{prefix:s}=r,o=(n=t.key)!==null&&n!==void 0?n:t.ref,a=this._values[s];if(a){let u=a.get(o);if(u)return u}else a=this._values[s]=new Map;a.set(o,r);let l=this._scope[s]||(this._scope[s]=[]),c=l.length;return l[c]=t.ref,r.setValue(t,{property:s,itemIndex:c}),r}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,On._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,r=>{if(r.value===void 0)throw new Error(`CodeGen: name "${r}" has no value`);return r.value.code},t,n)}_reduceValues(e,t,n={},r){let s=On.nil;for(let o in e){let a=e[o];if(!a)continue;let l=n[o]=n[o]||new Map;a.forEach(c=>{if(l.has(c))return;l.set(c,NO.Started);let u=t(c);if(u){let f=this.opts.es5?Ki.varKinds.var:Ki.varKinds.const;s=(0,On._)`${s}${f} ${c} = ${u};${this.opts._n}`}else if(u=r?.(c))s=(0,On._)`${s}${u}${this.opts._n}`;else throw new IO(c);l.set(c,NO.Completed)})}return s}};Ki.ValueScope=jO});var Je=Qe(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.or=Ye.and=Ye.not=Ye.CodeGen=Ye.operators=Ye.varKinds=Ye.ValueScopeName=Ye.ValueScope=Ye.Scope=Ye.Name=Ye.regexpCode=Ye.stringify=Ye.getProperty=Ye.nil=Ye.strConcat=Ye.str=Ye._=void 0;var ot=au(),_r=ZO(),oo=au();Object.defineProperty(Ye,"_",{enumerable:!0,get:function(){return oo._}});Object.defineProperty(Ye,"str",{enumerable:!0,get:function(){return oo.str}});Object.defineProperty(Ye,"strConcat",{enumerable:!0,get:function(){return oo.strConcat}});Object.defineProperty(Ye,"nil",{enumerable:!0,get:function(){return oo.nil}});Object.defineProperty(Ye,"getProperty",{enumerable:!0,get:function(){return oo.getProperty}});Object.defineProperty(Ye,"stringify",{enumerable:!0,get:function(){return oo.stringify}});Object.defineProperty(Ye,"regexpCode",{enumerable:!0,get:function(){return oo.regexpCode}});Object.defineProperty(Ye,"Name",{enumerable:!0,get:function(){return oo.Name}});var Wh=ZO();Object.defineProperty(Ye,"Scope",{enumerable:!0,get:function(){return Wh.Scope}});Object.defineProperty(Ye,"ValueScope",{enumerable:!0,get:function(){return Wh.ValueScope}});Object.defineProperty(Ye,"ValueScopeName",{enumerable:!0,get:function(){return Wh.ValueScopeName}});Object.defineProperty(Ye,"varKinds",{enumerable:!0,get:function(){return Wh.varKinds}});Ye.operators={GT:new ot._Code(">"),GTE:new ot._Code(">="),LT:new ot._Code("<"),LTE:new ot._Code("<="),EQ:new ot._Code("==="),NEQ:new ot._Code("!=="),NOT:new ot._Code("!"),OR:new ot._Code("||"),AND:new ot._Code("&&"),ADD:new ot._Code("+")};var _s=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},zO=class extends _s{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let n=e?_r.varKinds.var:this.varKind,r=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${r};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=ul(this.rhs,e,t)),this}get names(){return this.rhs instanceof ot._CodeOrName?this.rhs.names:{}}},Fh=class extends _s{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(!(this.lhs instanceof ot.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ul(this.rhs,e,t),this}get names(){let e=this.lhs instanceof ot.Name?{}:{...this.lhs.names};return Vh(e,this.rhs)}},qO=class extends Fh{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},LO=class extends _s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},$O=class extends _s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},FO=class extends _s{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},BO=class extends _s{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=ul(this.code,e,t),this}get names(){return this.code instanceof ot._CodeOrName?this.code.names:{}}},lu=class extends _s{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let s=n[r];s.optimizeNames(e,t)||(nj(e,s.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>ia(e,t.names),{})}},ws=class extends lu{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},VO=class extends lu{},cl=class extends ws{};cl.kind="else";var ea=class i extends ws{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let t=this.else;if(t){let n=t.optimizeNodes();t=this.else=Array.isArray(n)?new cl(n):n}if(t)return e===!1?t instanceof i?t:t.nodes:this.nodes.length?this:new i(S4(e),t instanceof i?[t]:t.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,t){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,t),!!(super.optimizeNames(e,t)||this.else))return this.condition=ul(this.condition,e,t),this}get names(){let e=super.names;return Vh(e,this.condition),this.else&&ia(e,this.else.names),e}};ea.kind="if";var ta=class extends ws{};ta.kind="for";var WO=class extends ta{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=ul(this.iteration,e,t),this}get names(){return ia(super.names,this.iteration.names)}},XO=class extends ta{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?_r.varKinds.var:this.varKind,{name:n,from:r,to:s}=this;return`for(${t} ${n}=${r}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Vh(super.names,this.from);return Vh(e,this.to)}},Bh=class extends ta{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=ul(this.iterable,e,t),this}get names(){return ia(super.names,this.iterable.names)}},cu=class extends ws{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};cu.kind="func";var uu=class extends lu{render(e){return"return "+super.render(e)}};uu.kind="return";var UO=class extends ws{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(t=this.finally)===null||t===void 0||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)===null||n===void 0||n.optimizeNames(e,t),(r=this.finally)===null||r===void 0||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&ia(e,this.catch.names),this.finally&&ia(e,this.finally.names),e}},fu=class extends ws{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};fu.kind="catch";var du=class extends ws{render(e){return"finally"+super.render(e)}};du.kind="finally";var YO=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?` `:""},this._extScope=e,this._scope=new _r.Scope({parent:e}),this._nodes=[new VO]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let s=this._scope.toName(t);return n!==void 0&&r&&(this._constants[s.str]=n),this._leafNode(new zO(e,s,n)),s}const(e,t,n){return this._def(_r.varKinds.const,e,t,n)}let(e,t,n){return this._def(_r.varKinds.let,e,t,n)}var(e,t,n){return this._def(_r.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new Fh(e,t,n))}add(e,t){return this._leafNode(new qO(e,Ye.operators.ADD,t))}code(e){return typeof e=="function"?e():e!==ot.nil&&this._leafNode(new BO(e)),this}object(...e){let t=["{"];for(let[n,r]of e)t.length>1&&t.push(","),t.push(n),(n!==r||this.opts.es5)&&(t.push(":"),(0,ot.addCodeArg)(t,r));return t.push("}"),new ot._Code(t)}if(e,t,n){if(this._blockNode(new ea(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new ea(e))}else(){return this._elseNode(new cl)}endIf(){return this._endBlockNode(ea,cl)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new WO(e),t)}forRange(e,t,n,r,s=this.opts.es5?_r.varKinds.var:_r.varKinds.let){let o=this._scope.toName(e);return this._for(new XO(s,o,t,n),()=>r(o))}forOf(e,t,n,r=_r.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let o=t instanceof ot.Name?t:this.var("_arr",t);return this.forRange("_i",0,(0,ot._)`${o}.length`,a=>{this.var(s,(0,ot._)`${o}[${a}]`),n(s)})}return this._for(new Bh("of",r,s,t),()=>n(s))}forIn(e,t,n,r=this.opts.es5?_r.varKinds.var:_r.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ot._)`Object.keys(${t})`,n);let s=this._scope.toName(e);return this._for(new Bh("in",r,s,t),()=>n(s))}endFor(){return this._endBlockNode(ta)}label(e){return this._leafNode(new LO(e))}break(e){return this._leafNode(new $O(e))}return(e){let t=new uu;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(uu)}try(e,t,n){if(!t&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let r=new UO;if(this._blockNode(r),this.code(e),t){let s=this.name("e");this._currNode=r.catch=new fu(s),t(s)}return n&&(this._currNode=r.finally=new du,this.code(n)),this._endBlockNode(fu,du)}throw(e){return this._leafNode(new FO(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=ot.nil,n,r){return this._blockNode(new cu(e,t,n)),r&&this.code(r).endFunc(),this}endFunc(){return this._endBlockNode(cu)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof ea))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};Ye.CodeGen=YO;function ia(i,e){for(let t in e)i[t]=(i[t]||0)+(e[t]||0);return i}function Vh(i,e){return e instanceof ot._CodeOrName?ia(i,e.names):i}function ul(i,e,t){if(i instanceof ot.Name)return n(i);if(!r(i))return i;return new ot._Code(i._items.reduce((s,o)=>(o instanceof ot.Name&&(o=n(o)),o instanceof ot._Code?s.push(...o._items):s.push(o),s),[]));function n(s){let o=t[s.str];return o===void 0||e[s.str]!==1?s:(delete e[s.str],o)}function r(s){return s instanceof ot._Code&&s._items.some(o=>o instanceof ot.Name&&e[o.str]===1&&t[o.str]!==void 0)}}function nj(i,e){for(let t in e)i[t]=(i[t]||0)-(e[t]||0)}function S4(i){return typeof i=="boolean"||typeof i=="number"||i===null?!i:(0,ot._)`!${HO(i)}`}Ye.not=S4;var rj=x4(Ye.operators.AND);function sj(...i){return i.reduce(rj)}Ye.and=sj;var oj=x4(Ye.operators.OR);function aj(...i){return i.reduce(oj)}Ye.or=aj;function x4(i){return(e,t)=>e===ot.nil?t:t===ot.nil?e:(0,ot._)`${HO(e)} ${i} ${HO(t)}`}function HO(i){return i instanceof ot.Name?i:(0,ot._)`(${i})`}});var mt=Qe(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.checkStrictMode=He.getErrorPath=He.Type=He.useFunc=He.setEvaluated=He.evaluatedPropsToName=He.mergeEvaluated=He.eachItem=He.unescapeJsonPointer=He.escapeJsonPointer=He.escapeFragment=He.unescapeFragment=He.schemaRefOrVal=He.schemaHasRulesButRef=He.schemaHasRules=He.checkUnknownRules=He.alwaysValidSchema=He.toHash=void 0;var Rt=Je(),lj=au();function cj(i){let e={};for(let t of i)e[t]=!0;return e}He.toHash=cj;function uj(i,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(E4(i,e),!T4(e,i.self.RULES.all))}He.alwaysValidSchema=uj;function E4(i,e=i.schema){let{opts:t,self:n}=i;if(!t.strictSchema||typeof e=="boolean")return;let r=n.RULES.keywords;for(let s in e)r[s]||R4(i,`unknown keyword: "${s}"`)}He.checkUnknownRules=E4;function T4(i,e){if(typeof i=="boolean")return!i;for(let t in i)if(e[t])return!0;return!1}He.schemaHasRules=T4;function fj(i,e){if(typeof i=="boolean")return!i;for(let t in i)if(t!=="$ref"&&e.all[t])return!0;return!1}He.schemaHasRulesButRef=fj;function dj({topSchemaRef:i,schemaPath:e},t,n,r){if(!r){if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return(0,Rt._)`${t}`}return(0,Rt._)`${i}${e}${(0,Rt.getProperty)(n)}`}He.schemaRefOrVal=dj;function hj(i){return A4(decodeURIComponent(i))}He.unescapeFragment=hj;function pj(i){return encodeURIComponent(GO(i))}He.escapeFragment=pj;function GO(i){return typeof i=="number"?`${i}`:i.replace(/~/g,"~0").replace(/\//g,"~1")}He.escapeJsonPointer=GO;function A4(i){return i.replace(/~1/g,"/").replace(/~0/g,"~")}He.unescapeJsonPointer=A4;function mj(i,e){if(Array.isArray(i))for(let t of i)e(t);else e(i)}He.eachItem=mj;function P4({mergeNames:i,mergeToName:e,mergeValues:t,resultToName:n}){return(r,s,o,a)=>{let l=o===void 0?s:o instanceof Rt.Name?(s instanceof Rt.Name?i(r,s,o):e(r,s,o),o):s instanceof Rt.Name?(e(r,o,s),s):t(s,o);return a===Rt.Name&&!(l instanceof Rt.Name)?n(r,l):l}}He.mergeEvaluated={props:P4({mergeNames:(i,e,t)=>i.if((0,Rt._)`${t} !== true && ${e} !== undefined`,()=>{i.if((0,Rt._)`${e} === true`,()=>i.assign(t,!0),()=>i.assign(t,(0,Rt._)`${t} || {}`).code((0,Rt._)`Object.assign(${t}, ${e})`))}),mergeToName:(i,e,t)=>i.if((0,Rt._)`${t} !== true`,()=>{e===!0?i.assign(t,!0):(i.assign(t,(0,Rt._)`${t} || {}`),KO(i,t,e))}),mergeValues:(i,e)=>i===!0?!0:{...i,...e},resultToName:D4}),items:P4({mergeNames:(i,e,t)=>i.if((0,Rt._)`${t} !== true && ${e} !== undefined`,()=>i.assign(t,(0,Rt._)`${e} === true ? true : ${t} > ${e} ? ${t} : ${e}`)),mergeToName:(i,e,t)=>i.if((0,Rt._)`${t} !== true`,()=>i.assign(t,e===!0?!0:(0,Rt._)`${t} > ${e} ? ${t} : ${e}`)),mergeValues:(i,e)=>i===!0?!0:Math.max(i,e),resultToName:(i,e)=>i.var("items",e)})};function D4(i,e){if(e===!0)return i.var("props",!0);let t=i.var("props",(0,Rt._)`{}`);return e!==void 0&&KO(i,t,e),t}He.evaluatedPropsToName=D4;function KO(i,e,t){Object.keys(t).forEach(n=>i.assign((0,Rt._)`${e}${(0,Rt.getProperty)(n)}`,!0))}He.setEvaluated=KO;var C4={};function gj(i,e){return i.scopeValue("func",{ref:e,code:C4[e.code]||(C4[e.code]=new lj._Code(e.code))})}He.useFunc=gj;var Q4;(function(i){i[i.Num=0]="Num",i[i.Str=1]="Str"})(Q4=He.Type||(He.Type={}));function Oj(i,e,t){if(i instanceof Rt.Name){let n=e===Q4.Num;return t?n?(0,Rt._)`"[" + ${i} + "]"`:(0,Rt._)`"['" + ${i} + "']"`:n?(0,Rt._)`"/" + ${i}`:(0,Rt._)`"/" + ${i}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return t?(0,Rt.getProperty)(i).toString():"/"+GO(i)}He.getErrorPath=Oj;function R4(i,e,t=i.opts.strictSchema){if(t){if(e=`strict mode: ${e}`,t===!0)throw new Error(e);i.self.logger.warn(e)}}He.checkStrictMode=R4});var ks=Qe(JO=>{"use strict";Object.defineProperty(JO,"__esModule",{value:!0});var Li=Je(),vj={data:new Li.Name("data"),valCxt:new Li.Name("valCxt"),instancePath:new Li.Name("instancePath"),parentData:new Li.Name("parentData"),parentDataProperty:new Li.Name("parentDataProperty"),rootData:new Li.Name("rootData"),dynamicAnchors:new Li.Name("dynamicAnchors"),vErrors:new Li.Name("vErrors"),errors:new Li.Name("errors"),this:new Li.Name("this"),self:new Li.Name("self"),scope:new Li.Name("scope"),json:new Li.Name("json"),jsonPos:new Li.Name("jsonPos"),jsonLen:new Li.Name("jsonLen"),jsonPart:new Li.Name("jsonPart")};JO.default=vj});var hu=Qe($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.extendErrors=$i.resetErrorsCount=$i.reportExtraError=$i.reportError=$i.keyword$DataError=$i.keywordError=void 0;var ft=Je(),Xh=mt(),Ji=ks();$i.keywordError={message:({keyword:i})=>(0,ft.str)`must pass "${i}" keyword validation`};$i.keyword$DataError={message:({keyword:i,schemaType:e})=>e?(0,ft.str)`"${i}" keyword must be ${e} ($data)`:(0,ft.str)`"${i}" keyword is invalid ($data)`};function yj(i,e=$i.keywordError,t,n){let{it:r}=i,{gen:s,compositeRule:o,allErrors:a}=r,l=N4(i,e,t);n??(o||a)?M4(s,l):I4(r,(0,ft._)`[${l}]`)}$i.reportError=yj;function bj(i,e=$i.keywordError,t){let{it:n}=i,{gen:r,compositeRule:s,allErrors:o}=n,a=N4(i,e,t);M4(r,a),s||o||I4(n,Ji.default.vErrors)}$i.reportExtraError=bj;function _j(i,e){i.assign(Ji.default.errors,e),i.if((0,ft._)`${Ji.default.vErrors} !== null`,()=>i.if(e,()=>i.assign((0,ft._)`${Ji.default.vErrors}.length`,e),()=>i.assign(Ji.default.vErrors,null)))}$i.resetErrorsCount=_j;function wj({gen:i,keyword:e,schemaValue:t,data:n,errsCount:r,it:s}){if(r===void 0)throw new Error("ajv implementation error");let o=i.name("err");i.forRange("i",r,Ji.default.errors,a=>{i.const(o,(0,ft._)`${Ji.default.vErrors}[${a}]`),i.if((0,ft._)`${o}.instancePath === undefined`,()=>i.assign((0,ft._)`${o}.instancePath`,(0,ft.strConcat)(Ji.default.instancePath,s.errorPath))),i.assign((0,ft._)`${o}.schemaPath`,(0,ft.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(i.assign((0,ft._)`${o}.schema`,t),i.assign((0,ft._)`${o}.data`,n))})}$i.extendErrors=wj;function M4(i,e){let t=i.const("err",e);i.if((0,ft._)`${Ji.default.vErrors} === null`,()=>i.assign(Ji.default.vErrors,(0,ft._)`[${t}]`),(0,ft._)`${Ji.default.vErrors}.push(${t})`),i.code((0,ft._)`${Ji.default.errors}++`)}function I4(i,e){let{gen:t,validateName:n,schemaEnv:r}=i;r.$async?t.throw((0,ft._)`new ${i.ValidationError}(${e})`):(t.assign((0,ft._)`${n}.errors`,e),t.return(!1))}var na={keyword:new ft.Name("keyword"),schemaPath:new ft.Name("schemaPath"),params:new ft.Name("params"),propertyName:new ft.Name("propertyName"),message:new ft.Name("message"),schema:new ft.Name("schema"),parentSchema:new ft.Name("parentSchema")};function N4(i,e,t){let{createErrors:n}=i.it;return n===!1?(0,ft._)`{}`:kj(i,e,t)}function kj(i,e,t={}){let{gen:n,it:r}=i,s=[Sj(r,t),xj(i,t)];return Pj(i,e,s),n.object(...s)}function Sj({errorPath:i},{instancePath:e}){let t=e?(0,ft.str)`${i}${(0,Xh.getErrorPath)(e,Xh.Type.Str)}`:i;return[Ji.default.instancePath,(0,ft.strConcat)(Ji.default.instancePath,t)]}function xj({keyword:i,it:{errSchemaPath:e}},{schemaPath:t,parentSchema:n}){let r=n?e:(0,ft.str)`${e}/${i}`;return t&&(r=(0,ft.str)`${r}${(0,Xh.getErrorPath)(t,Xh.Type.Str)}`),[na.schemaPath,r]}function Pj(i,{params:e,message:t},n){let{keyword:r,data:s,schemaValue:o,it:a}=i,{opts:l,propertyName:c,topSchemaRef:u,schemaPath:f}=a;n.push([na.keyword,r],[na.params,typeof e=="function"?e(i):e||(0,ft._)`{}`]),l.messages&&n.push([na.message,typeof t=="function"?t(i):t]),l.verbose&&n.push([na.schema,o],[na.parentSchema,(0,ft._)`${u}${f}`],[Ji.default.data,s]),c&&n.push([na.propertyName,c])}});var Z4=Qe(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});fl.boolOrEmptySchema=fl.topBoolOrEmptySchema=void 0;var Cj=hu(),Ej=Je(),Tj=ks(),Aj={message:"boolean schema is false"};function Dj(i){let{gen:e,schema:t,validateName:n}=i;t===!1?j4(i,!1):typeof t=="object"&&t.$async===!0?e.return(Tj.default.data):(e.assign((0,Ej._)`${n}.errors`,null),e.return(!0))}fl.topBoolOrEmptySchema=Dj;function Qj(i,e){let{gen:t,schema:n}=i;n===!1?(t.var(e,!1),j4(i)):t.var(e,!0)}fl.boolOrEmptySchema=Qj;function j4(i,e){let{gen:t,data:n}=i,r={gen:t,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:i};(0,Cj.reportError)(r,Aj,void 0,e)}});var ev=Qe(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});dl.getRules=dl.isJSONType=void 0;var Rj=["string","number","integer","boolean","null","object","array"],Mj=new Set(Rj);function Ij(i){return typeof i=="string"&&Mj.has(i)}dl.isJSONType=Ij;function Nj(){let i={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...i,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},i.number,i.string,i.array,i.object],post:{rules:[]},all:{},keywords:{}}}dl.getRules=Nj});var tv=Qe(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.shouldUseRule=ao.shouldUseGroup=ao.schemaHasRulesForType=void 0;function jj({schema:i,self:e},t){let n=e.RULES.types[t];return n&&n!==!0&&z4(i,n)}ao.schemaHasRulesForType=jj;function z4(i,e){return e.rules.some(t=>q4(i,t))}ao.shouldUseGroup=z4;function q4(i,e){var t;return i[e.keyword]!==void 0||((t=e.definition.implements)===null||t===void 0?void 0:t.some(n=>i[n]!==void 0))}ao.shouldUseRule=q4});var mu=Qe(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.reportTypeError=Di.checkDataTypes=Di.checkDataType=Di.coerceAndCheckDataType=Di.getJSONTypes=Di.getSchemaTypes=Di.DataType=void 0;var Zj=ev(),zj=tv(),qj=hu(),Ve=Je(),L4=mt(),pu;(function(i){i[i.Correct=0]="Correct",i[i.Wrong=1]="Wrong"})(pu=Di.DataType||(Di.DataType={}));function Lj(i){let e=$4(i.type);if(e.includes("null")){if(i.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&i.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');i.nullable===!0&&e.push("null")}return e}Di.getSchemaTypes=Lj;function $4(i){let e=Array.isArray(i)?i:i?[i]:[];if(e.every(Zj.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Di.getJSONTypes=$4;function $j(i,e){let{gen:t,data:n,opts:r}=i,s=Fj(e,r.coerceTypes),o=e.length>0&&!(s.length===0&&e.length===1&&(0,zj.schemaHasRulesForType)(i,e[0]));if(o){let a=nv(e,n,r.strictNumbers,pu.Wrong);t.if(a,()=>{s.length?Bj(i,e,s):rv(i)})}return o}Di.coerceAndCheckDataType=$j;var F4=new Set(["string","number","integer","boolean","null"]);function Fj(i,e){return e?i.filter(t=>F4.has(t)||e==="array"&&t==="array"):[]}function Bj(i,e,t){let{gen:n,data:r,opts:s}=i,o=n.let("dataType",(0,Ve._)`typeof ${r}`),a=n.let("coerced",(0,Ve._)`undefined`);s.coerceTypes==="array"&&n.if((0,Ve._)`${o} == 'object' && Array.isArray(${r}) && ${r}.length == 1`,()=>n.assign(r,(0,Ve._)`${r}[0]`).assign(o,(0,Ve._)`typeof ${r}`).if(nv(e,r,s.strictNumbers),()=>n.assign(a,r))),n.if((0,Ve._)`${a} !== undefined`);for(let c of t)(F4.has(c)||c==="array"&&s.coerceTypes==="array")&&l(c);n.else(),rv(i),n.endIf(),n.if((0,Ve._)`${a} !== undefined`,()=>{n.assign(r,a),Vj(i,a)});function l(c){switch(c){case"string":n.elseIf((0,Ve._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,Ve._)`"" + ${r}`).elseIf((0,Ve._)`${r} === null`).assign(a,(0,Ve._)`""`);return;case"number":n.elseIf((0,Ve._)`${o} == "boolean" || ${r} === null || (${o} == "string" && ${r} && ${r} == +${r})`).assign(a,(0,Ve._)`+${r}`);return;case"integer":n.elseIf((0,Ve._)`${o} === "boolean" || ${r} === null || (${o} === "string" && ${r} && ${r} == +${r} && !(${r} % 1))`).assign(a,(0,Ve._)`+${r}`);return;case"boolean":n.elseIf((0,Ve._)`${r} === "false" || ${r} === 0 || ${r} === null`).assign(a,!1).elseIf((0,Ve._)`${r} === "true" || ${r} === 1`).assign(a,!0);return;case"null":n.elseIf((0,Ve._)`${r} === "" || ${r} === 0 || ${r} === false`),n.assign(a,null);return;case"array":n.elseIf((0,Ve._)`${o} === "string" || ${o} === "number" || ${o} === "boolean" || ${r} === null`).assign(a,(0,Ve._)`[${r}]`)}}}function Vj({gen:i,parentData:e,parentDataProperty:t},n){i.if((0,Ve._)`${e} !== undefined`,()=>i.assign((0,Ve._)`${e}[${t}]`,n))}function iv(i,e,t,n=pu.Correct){let r=n===pu.Correct?Ve.operators.EQ:Ve.operators.NEQ,s;switch(i){case"null":return(0,Ve._)`${e} ${r} null`;case"array":s=(0,Ve._)`Array.isArray(${e})`;break;case"object":s=(0,Ve._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=o((0,Ve._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=o();break;default:return(0,Ve._)`typeof ${e} ${r} ${i}`}return n===pu.Correct?s:(0,Ve.not)(s);function o(a=Ve.nil){return(0,Ve.and)((0,Ve._)`typeof ${e} == "number"`,a,t?(0,Ve._)`isFinite(${e})`:Ve.nil)}}Di.checkDataType=iv;function nv(i,e,t,n){if(i.length===1)return iv(i[0],e,t,n);let r,s=(0,L4.toHash)(i);if(s.array&&s.object){let o=(0,Ve._)`typeof ${e} != "object"`;r=s.null?o:(0,Ve._)`!${e} || ${o}`,delete s.null,delete s.array,delete s.object}else r=Ve.nil;s.number&&delete s.integer;for(let o in s)r=(0,Ve.and)(r,iv(o,e,t,n));return r}Di.checkDataTypes=nv;var Wj={message:({schema:i})=>`must be ${i}`,params:({schema:i,schemaValue:e})=>typeof i=="string"?(0,Ve._)`{type: ${i}}`:(0,Ve._)`{type: ${e}}`};function rv(i){let e=Xj(i);(0,qj.reportError)(e,Wj)}Di.reportTypeError=rv;function Xj(i){let{gen:e,data:t,schema:n}=i,r=(0,L4.schemaRefOrVal)(i,n,"type");return{gen:e,keyword:"type",data:t,schema:n.type,schemaCode:r,schemaValue:r,parentSchema:n,params:{},it:i}}});var V4=Qe(Uh=>{"use strict";Object.defineProperty(Uh,"__esModule",{value:!0});Uh.assignDefaults=void 0;var hl=Je(),Uj=mt();function Yj(i,e){let{properties:t,items:n}=i.schema;if(e==="object"&&t)for(let r in t)B4(i,r,t[r].default);else e==="array"&&Array.isArray(n)&&n.forEach((r,s)=>B4(i,s,r.default))}Uh.assignDefaults=Yj;function B4(i,e,t){let{gen:n,compositeRule:r,data:s,opts:o}=i;if(t===void 0)return;let a=(0,hl._)`${s}${(0,hl.getProperty)(e)}`;if(r){(0,Uj.checkStrictMode)(i,`default is ignored for: ${a}`);return}let l=(0,hl._)`${a} === undefined`;o.useDefaults==="empty"&&(l=(0,hl._)`${l} || ${a} === null || ${a} === ""`),n.if(l,(0,hl._)`${a} = ${(0,hl.stringify)(t)}`)}});var Wn=Qe(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.validateUnion=Et.validateArray=Et.usePattern=Et.callValidateCode=Et.schemaProperties=Et.allSchemaProperties=Et.noPropertyInData=Et.propertyInData=Et.isOwnProperty=Et.hasPropFunc=Et.reportMissingProp=Et.checkMissingProp=Et.checkReportMissingProp=void 0;var Lt=Je(),sv=mt(),lo=ks(),Hj=mt();function Gj(i,e){let{gen:t,data:n,it:r}=i;t.if(av(t,n,e,r.opts.ownProperties),()=>{i.setParams({missingProperty:(0,Lt._)`${e}`},!0),i.error()})}Et.checkReportMissingProp=Gj;function Kj({gen:i,data:e,it:{opts:t}},n,r){return(0,Lt.or)(...n.map(s=>(0,Lt.and)(av(i,e,s,t.ownProperties),(0,Lt._)`${r} = ${s}`)))}Et.checkMissingProp=Kj;function Jj(i,e){i.setParams({missingProperty:e},!0),i.error()}Et.reportMissingProp=Jj;function W4(i){return i.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Lt._)`Object.prototype.hasOwnProperty`})}Et.hasPropFunc=W4;function ov(i,e,t){return(0,Lt._)`${W4(i)}.call(${e}, ${t})`}Et.isOwnProperty=ov;function eZ(i,e,t,n){let r=(0,Lt._)`${e}${(0,Lt.getProperty)(t)} !== undefined`;return n?(0,Lt._)`${r} && ${ov(i,e,t)}`:r}Et.propertyInData=eZ;function av(i,e,t,n){let r=(0,Lt._)`${e}${(0,Lt.getProperty)(t)} === undefined`;return n?(0,Lt.or)(r,(0,Lt.not)(ov(i,e,t))):r}Et.noPropertyInData=av;function X4(i){return i?Object.keys(i).filter(e=>e!=="__proto__"):[]}Et.allSchemaProperties=X4;function tZ(i,e){return X4(e).filter(t=>!(0,sv.alwaysValidSchema)(i,e[t]))}Et.schemaProperties=tZ;function iZ({schemaCode:i,data:e,it:{gen:t,topSchemaRef:n,schemaPath:r,errorPath:s},it:o},a,l,c){let u=c?(0,Lt._)`${i}, ${e}, ${n}${r}`:e,f=[[lo.default.instancePath,(0,Lt.strConcat)(lo.default.instancePath,s)],[lo.default.parentData,o.parentData],[lo.default.parentDataProperty,o.parentDataProperty],[lo.default.rootData,lo.default.rootData]];o.opts.dynamicRef&&f.push([lo.default.dynamicAnchors,lo.default.dynamicAnchors]);let d=(0,Lt._)`${u}, ${t.object(...f)}`;return l!==Lt.nil?(0,Lt._)`${a}.call(${l}, ${d})`:(0,Lt._)`${a}(${d})`}Et.callValidateCode=iZ;var nZ=(0,Lt._)`new RegExp`;function rZ({gen:i,it:{opts:e}},t){let n=e.unicodeRegExp?"u":"",{regExp:r}=e.code,s=r(t,n);return i.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,Lt._)`${r.code==="new RegExp"?nZ:(0,Hj.useFunc)(i,r)}(${t}, ${n})`})}Et.usePattern=rZ;function sZ(i){let{gen:e,data:t,keyword:n,it:r}=i,s=e.name("valid");if(r.allErrors){let a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(s,!0),o(()=>e.break()),s;function o(a){let l=e.const("len",(0,Lt._)`${t}.length`);e.forRange("i",0,l,c=>{i.subschema({keyword:n,dataProp:c,dataPropType:sv.Type.Num},s),e.if((0,Lt.not)(s),a)})}}Et.validateArray=sZ;function oZ(i){let{gen:e,schema:t,keyword:n,it:r}=i;if(!Array.isArray(t))throw new Error("ajv implementation error");if(t.some(l=>(0,sv.alwaysValidSchema)(r,l))&&!r.opts.unevaluated)return;let o=e.let("valid",!1),a=e.name("_valid");e.block(()=>t.forEach((l,c)=>{let u=i.subschema({keyword:n,schemaProp:c,compositeRule:!0},a);e.assign(o,(0,Lt._)`${o} || ${a}`),i.mergeValidEvaluated(u,a)||e.if((0,Lt.not)(o))})),i.result(o,()=>i.reset(),()=>i.error(!0))}Et.validateUnion=oZ});var H4=Qe(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.validateKeywordUsage=es.validSchemaType=es.funcKeywordCode=es.macroKeywordCode=void 0;var en=Je(),ra=ks(),aZ=Wn(),lZ=hu();function cZ(i,e){let{gen:t,keyword:n,schema:r,parentSchema:s,it:o}=i,a=e.macro.call(o.self,r,s,o),l=Y4(t,n,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let c=t.name("valid");i.subschema({schema:a,schemaPath:en.nil,errSchemaPath:`${o.errSchemaPath}/${n}`,topSchemaRef:l,compositeRule:!0},c),i.pass(c,()=>i.error(!0))}es.macroKeywordCode=cZ;function uZ(i,e){var t;let{gen:n,keyword:r,schema:s,parentSchema:o,$data:a,it:l}=i;dZ(l,e);let c=!a&&e.compile?e.compile.call(l.self,s,o,l):e.validate,u=Y4(n,r,c),f=n.let("valid");i.block$data(f,d),i.ok((t=e.valid)!==null&&t!==void 0?t:f);function d(){if(e.errors===!1)m(),e.modifying&&U4(i),g(()=>i.error());else{let O=e.async?h():p();e.modifying&&U4(i),g(()=>fZ(i,O))}}function h(){let O=n.let("ruleErrs",null);return n.try(()=>m((0,en._)`await `),w=>n.assign(f,!1).if((0,en._)`${w} instanceof ${l.ValidationError}`,()=>n.assign(O,(0,en._)`${w}.errors`),()=>n.throw(w))),O}function p(){let O=(0,en._)`${u}.errors`;return n.assign(O,null),m(en.nil),O}function m(O=e.async?(0,en._)`await `:en.nil){let w=l.opts.passContext?ra.default.this:ra.default.self,S=!("compile"in e&&!a||e.schema===!1);n.assign(f,(0,en._)`${O}${(0,aZ.callValidateCode)(i,u,w,S)}`,e.modifying)}function g(O){var w;n.if((0,en.not)((w=e.valid)!==null&&w!==void 0?w:f),O)}}es.funcKeywordCode=uZ;function U4(i){let{gen:e,data:t,it:n}=i;e.if(n.parentData,()=>e.assign(t,(0,en._)`${n.parentData}[${n.parentDataProperty}]`))}function fZ(i,e){let{gen:t}=i;t.if((0,en._)`Array.isArray(${e})`,()=>{t.assign(ra.default.vErrors,(0,en._)`${ra.default.vErrors} === null ? ${e} : ${ra.default.vErrors}.concat(${e})`).assign(ra.default.errors,(0,en._)`${ra.default.vErrors}.length`),(0,lZ.extendErrors)(i)},()=>i.error())}function dZ({schemaEnv:i},e){if(e.async&&!i.$async)throw new Error("async keyword in sync schema")}function Y4(i,e,t){if(t===void 0)throw new Error(`keyword "${e}" failed to compile`);return i.scopeValue("keyword",typeof t=="function"?{ref:t}:{ref:t,code:(0,en.stringify)(t)})}function hZ(i,e,t=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(i):n==="object"?i&&typeof i=="object"&&!Array.isArray(i):typeof i==n||t&&typeof i>"u")}es.validSchemaType=hZ;function pZ({schema:i,opts:e,self:t,errSchemaPath:n},r,s){if(Array.isArray(r.keyword)?!r.keyword.includes(s):r.keyword!==s)throw new Error("ajv implementation error");let o=r.dependencies;if(o?.some(a=>!Object.prototype.hasOwnProperty.call(i,a)))throw new Error(`parent schema must have dependencies of ${s}: ${o.join(",")}`);if(r.validateSchema&&!r.validateSchema(i[s])){let l=`keyword "${s}" value is invalid at path "${n}": `+t.errorsText(r.validateSchema.errors);if(e.validateSchema==="log")t.logger.error(l);else throw new Error(l)}}es.validateKeywordUsage=pZ});var K4=Qe(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.extendSubschemaMode=co.extendSubschemaData=co.getSubschema=void 0;var ts=Je(),G4=mt();function mZ(i,{keyword:e,schemaProp:t,schema:n,schemaPath:r,errSchemaPath:s,topSchemaRef:o}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=i.schema[e];return t===void 0?{schema:a,schemaPath:(0,ts._)`${i.schemaPath}${(0,ts.getProperty)(e)}`,errSchemaPath:`${i.errSchemaPath}/${e}`}:{schema:a[t],schemaPath:(0,ts._)`${i.schemaPath}${(0,ts.getProperty)(e)}${(0,ts.getProperty)(t)}`,errSchemaPath:`${i.errSchemaPath}/${e}/${(0,G4.escapeFragment)(t)}`}}if(n!==void 0){if(r===void 0||s===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:r,topSchemaRef:o,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}co.getSubschema=mZ;function gZ(i,e,{dataProp:t,dataPropType:n,data:r,dataTypes:s,propertyName:o}){if(r!==void 0&&t!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(t!==void 0){let{errorPath:c,dataPathArr:u,opts:f}=e,d=a.let("data",(0,ts._)`${e.data}${(0,ts.getProperty)(t)}`,!0);l(d),i.errorPath=(0,ts.str)`${c}${(0,G4.getErrorPath)(t,n,f.jsPropertySyntax)}`,i.parentDataProperty=(0,ts._)`${t}`,i.dataPathArr=[...u,i.parentDataProperty]}if(r!==void 0){let c=r instanceof ts.Name?r:a.let("data",r,!0);l(c),o!==void 0&&(i.propertyName=o)}s&&(i.dataTypes=s);function l(c){i.data=c,i.dataLevel=e.dataLevel+1,i.dataTypes=[],e.definedProperties=new Set,i.parentData=e.data,i.dataNames=[...e.dataNames,c]}}co.extendSubschemaData=gZ;function OZ(i,{jtdDiscriminator:e,jtdMetadata:t,compositeRule:n,createErrors:r,allErrors:s}){n!==void 0&&(i.compositeRule=n),r!==void 0&&(i.createErrors=r),s!==void 0&&(i.allErrors=s),i.jtdDiscriminator=e,i.jtdMetadata=t}co.extendSubschemaMode=OZ});var lv=Qe((Ote,J4)=>{"use strict";J4.exports=function i(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var n,r,s;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!i(e[r],t[r]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){var o=s[r];if(!i(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}});var tC=Qe((vte,eC)=>{"use strict";var uo=eC.exports=function(i,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var n=typeof t=="function"?t:t.pre||function(){},r=t.post||function(){};Yh(e,n,r,i,"",i)};uo.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};uo.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};uo.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};uo.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Yh(i,e,t,n,r,s,o,a,l,c){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,r,s,o,a,l,c);for(var u in n){var f=n[u];if(Array.isArray(f)){if(u in uo.arrayKeywords)for(var d=0;d{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.getSchemaRefs=vn.resolveUrl=vn.normalizeId=vn._getFullPath=vn.getFullPath=vn.inlineRef=void 0;var yZ=mt(),bZ=lv(),_Z=tC(),wZ=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function kZ(i,e=!0){return typeof i=="boolean"?!0:e===!0?!cv(i):e?iC(i)<=e:!1}vn.inlineRef=kZ;var SZ=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function cv(i){for(let e in i){if(SZ.has(e))return!0;let t=i[e];if(Array.isArray(t)&&t.some(cv)||typeof t=="object"&&cv(t))return!0}return!1}function iC(i){let e=0;for(let t in i){if(t==="$ref")return 1/0;if(e++,!wZ.has(t)&&(typeof i[t]=="object"&&(0,yZ.eachItem)(i[t],n=>e+=iC(n)),e===1/0))return 1/0}return e}function nC(i,e="",t){t!==!1&&(e=pl(e));let n=i.parse(e);return rC(i,n)}vn.getFullPath=nC;function rC(i,e){return i.serialize(e).split("#")[0]+"#"}vn._getFullPath=rC;var xZ=/#\/?$/;function pl(i){return i?i.replace(xZ,""):""}vn.normalizeId=pl;function PZ(i,e,t){return t=pl(t),i.resolve(e,t)}vn.resolveUrl=PZ;var CZ=/^[a-z_][-a-z0-9._]*$/i;function EZ(i,e){if(typeof i=="boolean")return{};let{schemaId:t,uriResolver:n}=this.opts,r=pl(i[t]||e),s={"":r},o=nC(n,r,!1),a={},l=new Set;return _Z(i,{allKeys:!0},(f,d,h,p)=>{if(p===void 0)return;let m=o+d,g=s[p];typeof f[t]=="string"&&(g=O.call(this,f[t])),w.call(this,f.$anchor),w.call(this,f.$dynamicAnchor),s[d]=g;function O(S){let C=this.opts.uriResolver.resolve;if(S=pl(g?C(g,S):S),l.has(S))throw u(S);l.add(S);let k=this.refs[S];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?c(f,k.schema,S):S!==pl(m)&&(S[0]==="#"?(c(f,a[S],S),a[S]=f):this.refs[S]=m),S}function w(S){if(typeof S=="string"){if(!CZ.test(S))throw new Error(`invalid anchor "${S}"`);O.call(this,`#${S}`)}}}),a;function c(f,d,h){if(d!==void 0&&!bZ(f,d))throw u(h)}function u(f){return new Error(`reference "${f}" resolves to more than one schema`)}}vn.getSchemaRefs=EZ});var yu=Qe(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.getData=fo.KeywordCxt=fo.validateFunctionCode=void 0;var cC=Z4(),sC=mu(),fv=tv(),Hh=mu(),TZ=V4(),vu=H4(),uv=K4(),Me=Je(),ze=ks(),AZ=gu(),Ss=mt(),Ou=hu();function DZ(i){if(dC(i)&&(hC(i),fC(i))){MZ(i);return}uC(i,()=>(0,cC.topBoolOrEmptySchema)(i))}fo.validateFunctionCode=DZ;function uC({gen:i,validateName:e,schema:t,schemaEnv:n,opts:r},s){r.code.es5?i.func(e,(0,Me._)`${ze.default.data}, ${ze.default.valCxt}`,n.$async,()=>{i.code((0,Me._)`"use strict"; ${oC(t,r)}`),RZ(i,r),i.code(s)}):i.func(e,(0,Me._)`${ze.default.data}, ${QZ(r)}`,n.$async,()=>i.code(oC(t,r)).code(s))}function QZ(i){return(0,Me._)`{${ze.default.instancePath}="", ${ze.default.parentData}, ${ze.default.parentDataProperty}, ${ze.default.rootData}=${ze.default.data}${i.dynamicRef?(0,Me._)`, ${ze.default.dynamicAnchors}={}`:Me.nil}}={}`}function RZ(i,e){i.if(ze.default.valCxt,()=>{i.var(ze.default.instancePath,(0,Me._)`${ze.default.valCxt}.${ze.default.instancePath}`),i.var(ze.default.parentData,(0,Me._)`${ze.default.valCxt}.${ze.default.parentData}`),i.var(ze.default.parentDataProperty,(0,Me._)`${ze.default.valCxt}.${ze.default.parentDataProperty}`),i.var(ze.default.rootData,(0,Me._)`${ze.default.valCxt}.${ze.default.rootData}`),e.dynamicRef&&i.var(ze.default.dynamicAnchors,(0,Me._)`${ze.default.valCxt}.${ze.default.dynamicAnchors}`)},()=>{i.var(ze.default.instancePath,(0,Me._)`""`),i.var(ze.default.parentData,(0,Me._)`undefined`),i.var(ze.default.parentDataProperty,(0,Me._)`undefined`),i.var(ze.default.rootData,ze.default.data),e.dynamicRef&&i.var(ze.default.dynamicAnchors,(0,Me._)`{}`)})}function MZ(i){let{schema:e,opts:t,gen:n}=i;uC(i,()=>{t.$comment&&e.$comment&&mC(i),zZ(i),n.let(ze.default.vErrors,null),n.let(ze.default.errors,0),t.unevaluated&&IZ(i),pC(i),$Z(i)})}function IZ(i){let{gen:e,validateName:t}=i;i.evaluated=e.const("evaluated",(0,Me._)`${t}.evaluated`),e.if((0,Me._)`${i.evaluated}.dynamicProps`,()=>e.assign((0,Me._)`${i.evaluated}.props`,(0,Me._)`undefined`)),e.if((0,Me._)`${i.evaluated}.dynamicItems`,()=>e.assign((0,Me._)`${i.evaluated}.items`,(0,Me._)`undefined`))}function oC(i,e){let t=typeof i=="object"&&i[e.schemaId];return t&&(e.code.source||e.code.process)?(0,Me._)`/*# sourceURL=${t} */`:Me.nil}function NZ(i,e){if(dC(i)&&(hC(i),fC(i))){jZ(i,e);return}(0,cC.boolOrEmptySchema)(i,e)}function fC({schema:i,self:e}){if(typeof i=="boolean")return!i;for(let t in i)if(e.RULES.all[t])return!0;return!1}function dC(i){return typeof i.schema!="boolean"}function jZ(i,e){let{schema:t,gen:n,opts:r}=i;r.$comment&&t.$comment&&mC(i),qZ(i),LZ(i);let s=n.const("_errs",ze.default.errors);pC(i,s),n.var(e,(0,Me._)`${s} === ${ze.default.errors}`)}function hC(i){(0,Ss.checkUnknownRules)(i),ZZ(i)}function pC(i,e){if(i.opts.jtd)return aC(i,[],!1,e);let t=(0,sC.getSchemaTypes)(i.schema),n=(0,sC.coerceAndCheckDataType)(i,t);aC(i,t,!n,e)}function ZZ(i){let{schema:e,errSchemaPath:t,opts:n,self:r}=i;e.$ref&&n.ignoreKeywordsWithRef&&(0,Ss.schemaHasRulesButRef)(e,r.RULES)&&r.logger.warn(`$ref: keywords ignored in schema at path "${t}"`)}function zZ(i){let{schema:e,opts:t}=i;e.default!==void 0&&t.useDefaults&&t.strictSchema&&(0,Ss.checkStrictMode)(i,"default is ignored in the schema root")}function qZ(i){let e=i.schema[i.opts.schemaId];e&&(i.baseId=(0,AZ.resolveUrl)(i.opts.uriResolver,i.baseId,e))}function LZ(i){if(i.schema.$async&&!i.schemaEnv.$async)throw new Error("async schema in sync schema")}function mC({gen:i,schemaEnv:e,schema:t,errSchemaPath:n,opts:r}){let s=t.$comment;if(r.$comment===!0)i.code((0,Me._)`${ze.default.self}.logger.log(${s})`);else if(typeof r.$comment=="function"){let o=(0,Me.str)`${n}/$comment`,a=i.scopeValue("root",{ref:e.root});i.code((0,Me._)`${ze.default.self}.opts.$comment(${s}, ${o}, ${a}.schema)`)}}function $Z(i){let{gen:e,schemaEnv:t,validateName:n,ValidationError:r,opts:s}=i;t.$async?e.if((0,Me._)`${ze.default.errors} === 0`,()=>e.return(ze.default.data),()=>e.throw((0,Me._)`new ${r}(${ze.default.vErrors})`)):(e.assign((0,Me._)`${n}.errors`,ze.default.vErrors),s.unevaluated&&FZ(i),e.return((0,Me._)`${ze.default.errors} === 0`))}function FZ({gen:i,evaluated:e,props:t,items:n}){t instanceof Me.Name&&i.assign((0,Me._)`${e}.props`,t),n instanceof Me.Name&&i.assign((0,Me._)`${e}.items`,n)}function aC(i,e,t,n){let{gen:r,schema:s,data:o,allErrors:a,opts:l,self:c}=i,{RULES:u}=c;if(s.$ref&&(l.ignoreKeywordsWithRef||!(0,Ss.schemaHasRulesButRef)(s,u))){r.block(()=>OC(i,"$ref",u.all.$ref.definition));return}l.jtd||BZ(i,e),r.block(()=>{for(let d of u.rules)f(d);f(u.post)});function f(d){(0,fv.shouldUseGroup)(s,d)&&(d.type?(r.if((0,Hh.checkDataType)(d.type,o,l.strictNumbers)),lC(i,d),e.length===1&&e[0]===d.type&&t&&(r.else(),(0,Hh.reportTypeError)(i)),r.endIf()):lC(i,d),a||r.if((0,Me._)`${ze.default.errors} === ${n||0}`))}}function lC(i,e){let{gen:t,schema:n,opts:{useDefaults:r}}=i;r&&(0,TZ.assignDefaults)(i,e.type),t.block(()=>{for(let s of e.rules)(0,fv.shouldUseRule)(n,s)&&OC(i,s.keyword,s.definition,e.type)})}function BZ(i,e){i.schemaEnv.meta||!i.opts.strictTypes||(VZ(i,e),i.opts.allowUnionTypes||WZ(i,e),XZ(i,i.dataTypes))}function VZ(i,e){if(e.length){if(!i.dataTypes.length){i.dataTypes=e;return}e.forEach(t=>{gC(i.dataTypes,t)||dv(i,`type "${t}" not allowed by context "${i.dataTypes.join(",")}"`)}),YZ(i,e)}}function WZ(i,e){e.length>1&&!(e.length===2&&e.includes("null"))&&dv(i,"use allowUnionTypes to allow union type keyword")}function XZ(i,e){let t=i.self.RULES.all;for(let n in t){let r=t[n];if(typeof r=="object"&&(0,fv.shouldUseRule)(i.schema,r)){let{type:s}=r.definition;s.length&&!s.some(o=>UZ(e,o))&&dv(i,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function UZ(i,e){return i.includes(e)||e==="number"&&i.includes("integer")}function gC(i,e){return i.includes(e)||e==="integer"&&i.includes("number")}function YZ(i,e){let t=[];for(let n of i.dataTypes)gC(e,n)?t.push(n):e.includes("integer")&&n==="number"&&t.push("integer");i.dataTypes=t}function dv(i,e){let t=i.schemaEnv.baseId+i.errSchemaPath;e+=` at "${t}" (strictTypes)`,(0,Ss.checkStrictMode)(i,e,i.opts.strictTypes)}var Gh=class{constructor(e,t,n){if((0,vu.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ss.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",vC(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,vu.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const("_errs",ze.default.errors))}result(e,t,n){this.failResult((0,Me.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,Me.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,Me._)`${t} !== undefined && (${(0,Me.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?Ou.reportExtraError:Ou.reportError)(this,this.def.error,t)}$dataError(){(0,Ou.reportError)(this,this.def.$dataError||Ou.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Ou.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=Me.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=Me.nil,t=Me.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:s,def:o}=this;n.if((0,Me.or)((0,Me._)`${r} === undefined`,t)),e!==Me.nil&&n.assign(e,!0),(s.length||o.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==Me.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:s}=this;return(0,Me.or)(o(),a());function o(){if(n.length){if(!(t instanceof Me.Name))throw new Error("ajv implementation error");let l=Array.isArray(n)?n:[n];return(0,Me._)`${(0,Hh.checkDataTypes)(l,t,s.opts.strictNumbers,Hh.DataType.Wrong)}`}return Me.nil}function a(){if(r.validateSchema){let l=e.scopeValue("validate$data",{ref:r.validateSchema});return(0,Me._)`!${l}(${t})`}return Me.nil}}subschema(e,t){let n=(0,uv.getSubschema)(this.it,e);(0,uv.extendSubschemaData)(n,this.it,e),(0,uv.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return NZ(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Ss.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=Ss.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,Me.Name)),!0}};fo.KeywordCxt=Gh;function OC(i,e,t,n){let r=new Gh(i,t,e);"code"in t?t.code(r,n):r.$data&&t.validate?(0,vu.funcKeywordCode)(r,t):"macro"in t?(0,vu.macroKeywordCode)(r,t):(t.compile||t.validate)&&(0,vu.funcKeywordCode)(r,t)}var HZ=/^\/(?:[^~]|~0|~1)*$/,GZ=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function vC(i,{dataLevel:e,dataNames:t,dataPathArr:n}){let r,s;if(i==="")return ze.default.rootData;if(i[0]==="/"){if(!HZ.test(i))throw new Error(`Invalid JSON-pointer: ${i}`);r=i,s=ze.default.rootData}else{let c=GZ.exec(i);if(!c)throw new Error(`Invalid JSON-pointer: ${i}`);let u=+c[1];if(r=c[2],r==="#"){if(u>=e)throw new Error(l("property/index",u));return n[e-u]}if(u>e)throw new Error(l("data",u));if(s=t[e-u],!r)return s}let o=s,a=r.split("/");for(let c of a)c&&(s=(0,Me._)`${s}${(0,Me.getProperty)((0,Ss.unescapeJsonPointer)(c))}`,o=(0,Me._)`${o} && ${s}`);return o;function l(c,u){return`Cannot access ${c} ${u} levels up, current level is ${e}`}}fo.getData=vC});var Kh=Qe(pv=>{"use strict";Object.defineProperty(pv,"__esModule",{value:!0});var hv=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};pv.default=hv});var Jh=Qe(Ov=>{"use strict";Object.defineProperty(Ov,"__esModule",{value:!0});var mv=gu(),gv=class extends Error{constructor(e,t,n,r){super(r||`can't resolve reference ${n} from id ${t}`),this.missingRef=(0,mv.resolveUrl)(e,t,n),this.missingSchema=(0,mv.normalizeId)((0,mv.getFullPath)(e,this.missingRef))}};Ov.default=gv});var tp=Qe(Xn=>{"use strict";Object.defineProperty(Xn,"__esModule",{value:!0});Xn.resolveSchema=Xn.getCompilingSchema=Xn.resolveRef=Xn.compileSchema=Xn.SchemaEnv=void 0;var wr=Je(),KZ=Kh(),sa=ks(),kr=gu(),yC=mt(),JZ=yu(),ml=class{constructor(e){var t;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:(0,kr.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Xn.SchemaEnv=ml;function yv(i){let e=bC.call(this,i);if(e)return e;let t=(0,kr.getFullPath)(this.opts.uriResolver,i.root.baseId),{es5:n,lines:r}=this.opts.code,{ownProperties:s}=this.opts,o=new wr.CodeGen(this.scope,{es5:n,lines:r,ownProperties:s}),a;i.$async&&(a=o.scopeValue("Error",{ref:KZ.default,code:(0,wr._)`require("ajv/dist/runtime/validation_error").default`}));let l=o.scopeName("validate");i.validateName=l;let c={gen:o,allErrors:this.opts.allErrors,data:sa.default.data,parentData:sa.default.parentData,parentDataProperty:sa.default.parentDataProperty,dataNames:[sa.default.data],dataPathArr:[wr.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:i.schema,code:(0,wr.stringify)(i.schema)}:{ref:i.schema}),validateName:l,ValidationError:a,schema:i.schema,schemaEnv:i,rootId:t,baseId:i.baseId||t,schemaPath:wr.nil,errSchemaPath:i.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,wr._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(i),(0,JZ.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);let f=o.toString();u=`${o.scopeRefs(sa.default.scope)}return ${f}`,this.opts.code.process&&(u=this.opts.code.process(u,i));let h=new Function(`${sa.default.self}`,`${sa.default.scope}`,u)(this,this.scope.get());if(this.scope.value(l,{ref:h}),h.errors=null,h.schema=i.schema,h.schemaEnv=i,i.$async&&(h.$async=!0),this.opts.code.source===!0&&(h.source={validateName:l,validateCode:f,scopeValues:o._values}),this.opts.unevaluated){let{props:p,items:m}=c;h.evaluated={props:p instanceof wr.Name?void 0:p,items:m instanceof wr.Name?void 0:m,dynamicProps:p instanceof wr.Name,dynamicItems:m instanceof wr.Name},h.source&&(h.source.evaluated=(0,wr.stringify)(h.evaluated))}return i.validate=h,i}catch(f){throw delete i.validate,delete i.validateName,u&&this.logger.error("Error compiling schema, function code:",u),f}finally{this._compilations.delete(i)}}Xn.compileSchema=yv;function ez(i,e,t){var n;t=(0,kr.resolveUrl)(this.opts.uriResolver,e,t);let r=i.refs[t];if(r)return r;let s=nz.call(this,i,t);if(s===void 0){let o=(n=i.localRefs)===null||n===void 0?void 0:n[t],{schemaId:a}=this.opts;o&&(s=new ml({schema:o,schemaId:a,root:i,baseId:e}))}if(s!==void 0)return i.refs[t]=tz.call(this,s)}Xn.resolveRef=ez;function tz(i){return(0,kr.inlineRef)(i.schema,this.opts.inlineRefs)?i.schema:i.validate?i:yv.call(this,i)}function bC(i){for(let e of this._compilations)if(iz(e,i))return e}Xn.getCompilingSchema=bC;function iz(i,e){return i.schema===e.schema&&i.root===e.root&&i.baseId===e.baseId}function nz(i,e){let t;for(;typeof(t=this.refs[e])=="string";)e=t;return t||this.schemas[e]||ep.call(this,i,e)}function ep(i,e){let t=this.opts.uriResolver.parse(e),n=(0,kr._getFullPath)(this.opts.uriResolver,t),r=(0,kr.getFullPath)(this.opts.uriResolver,i.baseId,void 0);if(Object.keys(i.schema).length>0&&n===r)return vv.call(this,t,i);let s=(0,kr.normalizeId)(n),o=this.refs[s]||this.schemas[s];if(typeof o=="string"){let a=ep.call(this,i,o);return typeof a?.schema!="object"?void 0:vv.call(this,t,a)}if(typeof o?.schema=="object"){if(o.validate||yv.call(this,o),s===(0,kr.normalizeId)(e)){let{schema:a}=o,{schemaId:l}=this.opts,c=a[l];return c&&(r=(0,kr.resolveUrl)(this.opts.uriResolver,r,c)),new ml({schema:a,schemaId:l,root:i,baseId:r})}return vv.call(this,t,o)}}Xn.resolveSchema=ep;var rz=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function vv(i,{baseId:e,schema:t,root:n}){var r;if(((r=i.fragment)===null||r===void 0?void 0:r[0])!=="/")return;for(let a of i.fragment.slice(1).split("/")){if(typeof t=="boolean")return;let l=t[(0,yC.unescapeFragment)(a)];if(l===void 0)return;t=l;let c=typeof t=="object"&&t[this.opts.schemaId];!rz.has(a)&&c&&(e=(0,kr.resolveUrl)(this.opts.uriResolver,e,c))}let s;if(typeof t!="boolean"&&t.$ref&&!(0,yC.schemaHasRulesButRef)(t,this.RULES)){let a=(0,kr.resolveUrl)(this.opts.uriResolver,e,t.$ref);s=ep.call(this,n,a)}let{schemaId:o}=this.opts;if(s=s||new ml({schema:t,schemaId:o,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var _C=Qe((Ste,sz)=>{sz.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var kC=Qe((ip,wC)=>{(function(i,e){typeof ip=="object"&&typeof wC<"u"?e(ip):typeof define=="function"&&define.amd?define(["exports"],e):e(i.URI=i.URI||{})})(ip,function(i){"use strict";function e(){for(var F=arguments.length,N=Array(F),W=0;W1){N[0]=N[0].slice(0,-1);for(var K=N.length-1,te=1;te= 0x80 (not a basic code point)","invalid-input":"Invalid input"},R=h-p,Z=Math.floor,Q=String.fromCharCode;function D(F){throw new RangeError(x[F])}function E(F,N){for(var W=[],K=F.length;K--;)W[K]=N(F[K]);return W}function j(F,N){var W=F.split("@"),K="";W.length>1&&(K=W[0]+"@",F=W[1]),F=F.replace(P,".");var te=F.split("."),Ce=E(te,N).join(".");return K+Ce}function z(F){for(var N=[],W=0,K=F.length;W=55296&&te<=56319&&W>1,N+=Z(N/W);N>R*m>>1;te+=h)N=Z(N/R);return Z(te+(R+1)*N/(N+g))},Pe=function(N){var W=[],K=N.length,te=0,Ce=S,Le=w,st=N.lastIndexOf(C);st<0&&(st=0);for(var Ot=0;Ot=128&&D("not-basic"),W.push(N.charCodeAt(Ot));for(var Yt=st>0?st+1:0;Yt=K&&D("invalid-input");var Mt=G(N.charCodeAt(Yt++));(Mt>=h||Mt>Z((d-te)/Zt))&&D("overflow"),te+=Mt*Zt;var ct=Ht<=Le?p:Ht>=Le+m?m:Ht-Le;if(MtZ(d/zt)&&D("overflow"),Zt*=zt}var _t=W.length+1;Le=ce(te-it,_t,it==0),Z(te/_t)>d-Ce&&D("overflow"),Ce+=Z(te/_t),te%=_t,W.splice(te++,0,Ce)}return String.fromCodePoint.apply(String,W)},ue=function(N){var W=[];N=z(N);var K=N.length,te=S,Ce=0,Le=w,st=!0,Ot=!1,Yt=void 0;try{for(var it=N[Symbol.iterator](),Zt;!(st=(Zt=it.next()).done);st=!0){var Ht=Zt.value;Ht<128&&W.push(Q(Ht))}}catch(I){Ot=!0,Yt=I}finally{try{!st&&it.return&&it.return()}finally{if(Ot)throw Yt}}var Mt=W.length,ct=Mt;for(Mt&&W.push(C);ct=te&&BiZ((d-Ce)/on)&&D("overflow"),Ce+=(zt-te)*on,te=zt;var Qn=!0,os=!1,Hn=void 0;try{for(var wo=N[Symbol.iterator](),fa;!(Qn=(fa=wo.next()).done);Qn=!0){var da=fa.value;if(dad&&D("overflow"),da==te){for(var Cs=Ce,Es=h;;Es+=h){var Gn=Es<=Le?p:Es>=Le+m?m:Es-Le;if(Cs>6|192).toString(16).toUpperCase()+"%"+(N&63|128).toString(16).toUpperCase():W="%"+(N>>12|224).toString(16).toUpperCase()+"%"+(N>>6&63|128).toString(16).toUpperCase()+"%"+(N&63|128).toString(16).toUpperCase(),W}function ke(F){for(var N="",W=0,K=F.length;W=194&&te<224){if(K-W>=6){var Ce=parseInt(F.substr(W+4,2),16);N+=String.fromCharCode((te&31)<<6|Ce&63)}else N+=F.substr(W,6);W+=6}else if(te>=224){if(K-W>=9){var Le=parseInt(F.substr(W+4,2),16),st=parseInt(F.substr(W+7,2),16);N+=String.fromCharCode((te&15)<<12|(Le&63)<<6|st&63)}else N+=F.substr(W,9);W+=9}else N+=F.substr(W,3),W+=3}return N}function yt(F,N){function W(K){var te=ke(K);return te.match(N.UNRESERVED)?te:K}return F.scheme&&(F.scheme=String(F.scheme).replace(N.PCT_ENCODED,W).toLowerCase().replace(N.NOT_SCHEME,"")),F.userinfo!==void 0&&(F.userinfo=String(F.userinfo).replace(N.PCT_ENCODED,W).replace(N.NOT_USERINFO,oe).replace(N.PCT_ENCODED,r)),F.host!==void 0&&(F.host=String(F.host).replace(N.PCT_ENCODED,W).toLowerCase().replace(N.NOT_HOST,oe).replace(N.PCT_ENCODED,r)),F.path!==void 0&&(F.path=String(F.path).replace(N.PCT_ENCODED,W).replace(F.scheme?N.NOT_PATH:N.NOT_PATH_NOSCHEME,oe).replace(N.PCT_ENCODED,r)),F.query!==void 0&&(F.query=String(F.query).replace(N.PCT_ENCODED,W).replace(N.NOT_QUERY,oe).replace(N.PCT_ENCODED,r)),F.fragment!==void 0&&(F.fragment=String(F.fragment).replace(N.PCT_ENCODED,W).replace(N.NOT_FRAGMENT,oe).replace(N.PCT_ENCODED,r)),F}function It(F){return F.replace(/^0*(.*)/,"$1")||"0"}function at(F,N){var W=F.match(N.IPV4ADDRESS)||[],K=u(W,2),te=K[1];return te?te.split(".").map(It).join("."):F}function Nt(F,N){var W=F.match(N.IPV6ADDRESS)||[],K=u(W,3),te=K[1],Ce=K[2];if(te){for(var Le=te.toLowerCase().split("::").reverse(),st=u(Le,2),Ot=st[0],Yt=st[1],it=Yt?Yt.split(":").map(It):[],Zt=Ot.split(":").map(It),Ht=N.IPV4ADDRESS.test(Zt[Zt.length-1]),Mt=Ht?7:8,ct=Zt.length-Mt,zt=Array(Mt),_t=0;_t1){var kt=zt.slice(0,Fi.index),Bi=zt.slice(Fi.index+Fi.length);sn=kt.join(":")+"::"+Bi.join(":")}else sn=zt.join(":");return Ce&&(sn+="%"+Ce),sn}else return F}var Pr=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,nn="".match(/(){0}/)[1]===void 0;function $t(F){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},W={},K=N.iri!==!1?c:l;N.reference==="suffix"&&(F=(N.scheme?N.scheme+":":"")+"//"+F);var te=F.match(Pr);if(te){nn?(W.scheme=te[1],W.userinfo=te[3],W.host=te[4],W.port=parseInt(te[5],10),W.path=te[6]||"",W.query=te[7],W.fragment=te[8],isNaN(W.port)&&(W.port=te[5])):(W.scheme=te[1]||void 0,W.userinfo=F.indexOf("@")!==-1?te[3]:void 0,W.host=F.indexOf("//")!==-1?te[4]:void 0,W.port=parseInt(te[5],10),W.path=te[6]||"",W.query=F.indexOf("?")!==-1?te[7]:void 0,W.fragment=F.indexOf("#")!==-1?te[8]:void 0,isNaN(W.port)&&(W.port=F.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?te[4]:void 0)),W.host&&(W.host=Nt(at(W.host,K),K)),W.scheme===void 0&&W.userinfo===void 0&&W.host===void 0&&W.port===void 0&&!W.path&&W.query===void 0?W.reference="same-document":W.scheme===void 0?W.reference="relative":W.fragment===void 0?W.reference="absolute":W.reference="uri",N.reference&&N.reference!=="suffix"&&N.reference!==W.reference&&(W.error=W.error||"URI is not a "+N.reference+" reference.");var Ce=Re[(N.scheme||W.scheme||"").toLowerCase()];if(!N.unicodeSupport&&(!Ce||!Ce.unicodeSupport)){if(W.host&&(N.domainHost||Ce&&Ce.domainHost))try{W.host=pe.toASCII(W.host.replace(K.PCT_ENCODED,ke).toLowerCase())}catch(Le){W.error=W.error||"Host's domain name can not be converted to ASCII via punycode: "+Le}yt(W,l)}else yt(W,K);Ce&&Ce.parse&&Ce.parse(W,N)}else W.error=W.error||"URI can not be parsed.";return W}function Tt(F,N){var W=N.iri!==!1?c:l,K=[];return F.userinfo!==void 0&&(K.push(F.userinfo),K.push("@")),F.host!==void 0&&K.push(Nt(at(String(F.host),W),W).replace(W.IPV6ADDRESS,function(te,Ce,Le){return"["+Ce+(Le?"%25"+Le:"")+"]"})),(typeof F.port=="number"||typeof F.port=="string")&&(K.push(":"),K.push(String(F.port))),K.length?K.join(""):void 0}var lt=/^\.\.?\//,dt=/^\/\.(\/|$)/,gt=/^\/\.\.(\/|$)/,jt=/^\/?(?:.|\n)*?(?=\/|$)/;function Cr(F){for(var N=[];F.length;)if(F.match(lt))F=F.replace(lt,"");else if(F.match(dt))F=F.replace(dt,"/");else if(F.match(gt))F=F.replace(gt,"/"),N.pop();else if(F==="."||F==="..")F="";else{var W=F.match(jt);if(W){var K=W[0];F=F.slice(K.length),N.push(K)}else throw new Error("Unexpected dot segment condition")}return N.join("")}function bt(F){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},W=N.iri?c:l,K=[],te=Re[(N.scheme||F.scheme||"").toLowerCase()];if(te&&te.serialize&&te.serialize(F,N),F.host&&!W.IPV6ADDRESS.test(F.host)){if(N.domainHost||te&&te.domainHost)try{F.host=N.iri?pe.toUnicode(F.host):pe.toASCII(F.host.replace(W.PCT_ENCODED,ke).toLowerCase())}catch(st){F.error=F.error||"Host's domain name can not be converted to "+(N.iri?"Unicode":"ASCII")+" via punycode: "+st}}yt(F,W),N.reference!=="suffix"&&F.scheme&&(K.push(F.scheme),K.push(":"));var Ce=Tt(F,N);if(Ce!==void 0&&(N.reference!=="suffix"&&K.push("//"),K.push(Ce),F.path&&F.path.charAt(0)!=="/"&&K.push("/")),F.path!==void 0){var Le=F.path;!N.absolutePath&&(!te||!te.absolutePath)&&(Le=Cr(Le)),Ce===void 0&&(Le=Le.replace(/^\/\//,"/%2F")),K.push(Le)}return F.query!==void 0&&(K.push("?"),K.push(F.query)),F.fragment!==void 0&&(K.push("#"),K.push(F.fragment)),K.join("")}function et(F,N){var W=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},K=arguments[3],te={};return K||(F=$t(bt(F,W),W),N=$t(bt(N,W),W)),W=W||{},!W.tolerant&&N.scheme?(te.scheme=N.scheme,te.userinfo=N.userinfo,te.host=N.host,te.port=N.port,te.path=Cr(N.path||""),te.query=N.query):(N.userinfo!==void 0||N.host!==void 0||N.port!==void 0?(te.userinfo=N.userinfo,te.host=N.host,te.port=N.port,te.path=Cr(N.path||""),te.query=N.query):(N.path?(N.path.charAt(0)==="/"?te.path=Cr(N.path):((F.userinfo!==void 0||F.host!==void 0||F.port!==void 0)&&!F.path?te.path="/"+N.path:F.path?te.path=F.path.slice(0,F.path.lastIndexOf("/")+1)+N.path:te.path=N.path,te.path=Cr(te.path)),te.query=N.query):(te.path=F.path,N.query!==void 0?te.query=N.query:te.query=F.query),te.userinfo=F.userinfo,te.host=F.host,te.port=F.port),te.scheme=F.scheme),te.fragment=N.fragment,te}function rs(F,N,W){var K=o({scheme:"null"},W);return bt(et($t(F,K),$t(N,K),K,!0),K)}function wl(F,N){return typeof F=="string"?F=bt($t(F,N),N):n(F)==="object"&&(F=$t(bt(F,N),N)),F}function Nu(F,N,W){return typeof F=="string"?F=bt($t(F,W),W):n(F)==="object"&&(F=bt(F,W)),typeof N=="string"?N=bt($t(N,W),W):n(N)==="object"&&(N=bt(N,W)),F===N}function ju(F,N){return F&&F.toString().replace(!N||!N.iri?l.ESCAPE:c.ESCAPE,oe)}function Dn(F,N){return F&&F.toString().replace(!N||!N.iri?l.PCT_ENCODED:c.PCT_ENCODED,ke)}var xs={scheme:"http",domainHost:!0,parse:function(N,W){return N.host||(N.error=N.error||"HTTP URIs must have a host."),N},serialize:function(N,W){var K=String(N.scheme).toLowerCase()==="https";return(N.port===(K?443:80)||N.port==="")&&(N.port=void 0),N.path||(N.path="/"),N}},kl={scheme:"https",domainHost:xs.domainHost,parse:xs.parse,serialize:xs.serialize};function Oo(F){return typeof F.secure=="boolean"?F.secure:String(F.scheme).toLowerCase()==="wss"}var vo={scheme:"ws",domainHost:!0,parse:function(N,W){var K=N;return K.secure=Oo(K),K.resourceName=(K.path||"/")+(K.query?"?"+K.query:""),K.path=void 0,K.query=void 0,K},serialize:function(N,W){if((N.port===(Oo(N)?443:80)||N.port==="")&&(N.port=void 0),typeof N.secure=="boolean"&&(N.scheme=N.secure?"wss":"ws",N.secure=void 0),N.resourceName){var K=N.resourceName.split("?"),te=u(K,2),Ce=te[0],Le=te[1];N.path=Ce&&Ce!=="/"?Ce:void 0,N.query=Le,N.resourceName=void 0}return N.fragment=void 0,N}},Zu={scheme:"wss",domainHost:vo.domainHost,parse:vo.parse,serialize:vo.serialize},ca={},Yn=!0,Er="[A-Za-z0-9\\-\\.\\_\\~"+(Yn?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",rn="[0-9A-Fa-f]",yo=t(t("%[EFef]"+rn+"%"+rn+rn+"%"+rn+rn)+"|"+t("%[89A-Fa-f]"+rn+"%"+rn+rn)+"|"+t("%"+rn+rn)),bo="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",zu="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",Sl=e(zu,'[\\"\\\\]'),Sp="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",xp=new RegExp(Er,"g"),Ps=new RegExp(yo,"g"),Pp=new RegExp(e("[^]",bo,"[\\.]",'[\\"]',Sl),"g"),ua=new RegExp(e("[^]",Er,Sp),"g"),Cp=ua;function xl(F){var N=ke(F);return N.match(xp)?N:F}var _o={scheme:"mailto",parse:function(N,W){var K=N,te=K.to=K.path?K.path.split(","):[];if(K.path=void 0,K.query){for(var Ce=!1,Le={},st=K.query.split("&"),Ot=0,Yt=st.length;Ot{"use strict";Object.defineProperty(bv,"__esModule",{value:!0});var SC=kC();SC.code='require("ajv/dist/runtime/uri").default';bv.default=SC});var RC=Qe(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.CodeGen=Qi.Name=Qi.nil=Qi.stringify=Qi.str=Qi._=Qi.KeywordCxt=void 0;var oz=yu();Object.defineProperty(Qi,"KeywordCxt",{enumerable:!0,get:function(){return oz.KeywordCxt}});var gl=Je();Object.defineProperty(Qi,"_",{enumerable:!0,get:function(){return gl._}});Object.defineProperty(Qi,"str",{enumerable:!0,get:function(){return gl.str}});Object.defineProperty(Qi,"stringify",{enumerable:!0,get:function(){return gl.stringify}});Object.defineProperty(Qi,"nil",{enumerable:!0,get:function(){return gl.nil}});Object.defineProperty(Qi,"Name",{enumerable:!0,get:function(){return gl.Name}});Object.defineProperty(Qi,"CodeGen",{enumerable:!0,get:function(){return gl.CodeGen}});var az=Kh(),AC=Jh(),lz=ev(),bu=tp(),cz=Je(),_u=gu(),np=mu(),wv=mt(),PC=_C(),uz=xC(),DC=(i,e)=>new RegExp(i,e);DC.code="new RegExp";var fz=["removeAdditional","useDefaults","coerceTypes"],dz=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),hz={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},pz={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},CC=200;function mz(i){var e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,w,S,C,k,_,P,x,R;let Z=i.strict,Q=(e=i.code)===null||e===void 0?void 0:e.optimize,D=Q===!0||Q===void 0?1:Q||0,E=(n=(t=i.code)===null||t===void 0?void 0:t.regExp)!==null&&n!==void 0?n:DC,j=(r=i.uriResolver)!==null&&r!==void 0?r:uz.default;return{strictSchema:(o=(s=i.strictSchema)!==null&&s!==void 0?s:Z)!==null&&o!==void 0?o:!0,strictNumbers:(l=(a=i.strictNumbers)!==null&&a!==void 0?a:Z)!==null&&l!==void 0?l:!0,strictTypes:(u=(c=i.strictTypes)!==null&&c!==void 0?c:Z)!==null&&u!==void 0?u:"log",strictTuples:(d=(f=i.strictTuples)!==null&&f!==void 0?f:Z)!==null&&d!==void 0?d:"log",strictRequired:(p=(h=i.strictRequired)!==null&&h!==void 0?h:Z)!==null&&p!==void 0?p:!1,code:i.code?{...i.code,optimize:D,regExp:E}:{optimize:D,regExp:E},loopRequired:(m=i.loopRequired)!==null&&m!==void 0?m:CC,loopEnum:(g=i.loopEnum)!==null&&g!==void 0?g:CC,meta:(O=i.meta)!==null&&O!==void 0?O:!0,messages:(w=i.messages)!==null&&w!==void 0?w:!0,inlineRefs:(S=i.inlineRefs)!==null&&S!==void 0?S:!0,schemaId:(C=i.schemaId)!==null&&C!==void 0?C:"$id",addUsedSchema:(k=i.addUsedSchema)!==null&&k!==void 0?k:!0,validateSchema:(_=i.validateSchema)!==null&&_!==void 0?_:!0,validateFormats:(P=i.validateFormats)!==null&&P!==void 0?P:!0,unicodeRegExp:(x=i.unicodeRegExp)!==null&&x!==void 0?x:!0,int32range:(R=i.int32range)!==null&&R!==void 0?R:!0,uriResolver:j}}var wu=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...mz(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new cz.ValueScope({scope:{},prefixes:dz,es5:t,lines:n}),this.logger=_z(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,lz.getRules)(),EC.call(this,hz,e,"NOT SUPPORTED"),EC.call(this,pz,e,"DEPRECATED","warn"),this._metaOpts=yz.call(this),e.formats&&Oz.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&vz.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),gz.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=PC;n==="id"&&(r={...PC},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[t]||e:void 0}validate(e,t){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return"$async"in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(u,f){await s.call(this,u.$schema);let d=this._addSchema(u,f);return d.validate||o.call(this,d)}async function s(u){u&&!this.getSchema(u)&&await r.call(this,{$ref:u},!0)}async function o(u){try{return this._compileSchemaEnv(u)}catch(f){if(!(f instanceof AC.default))throw f;return a.call(this,f),await l.call(this,f.missingSchema),o.call(this,u)}}function a({missingSchema:u,missingRef:f}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${f} cannot be resolved`)}async function l(u){let f=await c.call(this,u);this.refs[u]||await s.call(this,f.$schema),this.refs[u]||this.addSchema(f,u,t)}async function c(u){let f=this._loading[u];if(f)return f;try{return await(this._loading[u]=n(u))}finally{delete this._loading[u]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let o of e)this.addSchema(o,void 0,n,r);return this}let s;if(typeof e=="object"){let{schemaId:o}=this.opts;if(s=e[o],s!==void 0&&typeof s!="string")throw new Error(`schema ${o} must be string`)}return t=(0,_u.normalizeId)(t||s),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return r}getSchema(e){let t;for(;typeof(t=TC.call(this,e))=="string";)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new bu.SchemaEnv({schema:{},schemaId:n});if(t=bu.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let t=TC.call(this,e);return typeof t=="object"&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,_u.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e=="string")n=e,typeof t=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=n);else if(typeof e=="object"&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(kz.call(this,n,t),!t)return(0,wv.eachItem)(n,s=>_v.call(this,s)),this;xz.call(this,t);let r={...t,type:(0,np.getJSONTypes)(t.type),schemaType:(0,np.getJSONTypes)(t.schemaType)};return(0,wv.eachItem)(n,r.type.length===0?s=>_v.call(this,s,r):s=>r.type.forEach(o=>_v.call(this,s,r,o))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t=="object"?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let r=n.rules.findIndex(s=>s.keyword===e);r>=0&&n.rules.splice(r,1)}return this}addFormat(e,t){return typeof t=="string"&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(r=>`${n}${r.instancePath} ${r.message}`).reduce((r,s)=>r+t+s)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let s=r.split("/").slice(1),o=e;for(let a of s)o=o[a];for(let a in n){let l=n[a];if(typeof l!="object")continue;let{$data:c}=l.definition,u=o[a];c&&u&&(o[a]=QC(u))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r=="string"?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,s=this.opts.addUsedSchema){let o,{schemaId:a}=this.opts;if(typeof e=="object")o=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let l=this._cache.get(e);if(l!==void 0)return l;n=(0,_u.normalizeId)(o||n);let c=_u.getSchemaRefs.call(this,e,n);return l=new bu.SchemaEnv({schema:e,schemaId:a,meta:t,baseId:n,localRefs:c}),this._cache.set(l.schema,l),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):bu.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{bu.compileSchema.call(this,e)}finally{this.opts=t}}};Qi.default=wu;wu.ValidationError=az.default;wu.MissingRefError=AC.default;function EC(i,e,t,n="error"){for(let r in i){let s=r;s in e&&this.logger[n](`${t}: option ${r}. ${i[s]}`)}}function TC(i){return i=(0,_u.normalizeId)(i),this.schemas[i]||this.refs[i]}function gz(){let i=this.opts.schemas;if(i)if(Array.isArray(i))this.addSchema(i);else for(let e in i)this.addSchema(i[e],e)}function Oz(){for(let i in this.opts.formats){let e=this.opts.formats[i];e&&this.addFormat(i,e)}}function vz(i){if(Array.isArray(i)){this.addVocabulary(i);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in i){let t=i[e];t.keyword||(t.keyword=e),this.addKeyword(t)}}function yz(){let i={...this.opts};for(let e of fz)delete i[e];return i}var bz={log(){},warn(){},error(){}};function _z(i){if(i===!1)return bz;if(i===void 0)return console;if(i.log&&i.warn&&i.error)return i;throw new Error("logger must implement log, warn and error methods")}var wz=/^[a-z_$][a-z0-9_$:-]*$/i;function kz(i,e){let{RULES:t}=this;if((0,wv.eachItem)(i,n=>{if(t.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!wz.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function _v(i,e,t){var n;let r=e?.post;if(t&&r)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,o=r?s.post:s.rules.find(({type:l})=>l===t);if(o||(o={type:t,rules:[]},s.rules.push(o)),s.keywords[i]=!0,!e)return;let a={keyword:i,definition:{...e,type:(0,np.getJSONTypes)(e.type),schemaType:(0,np.getJSONTypes)(e.schemaType)}};e.before?Sz.call(this,o,a,e.before):o.rules.push(a),s.all[i]=a,(n=e.implements)===null||n===void 0||n.forEach(l=>this.addKeyword(l))}function Sz(i,e,t){let n=i.rules.findIndex(r=>r.keyword===t);n>=0?i.rules.splice(n,0,e):(i.rules.push(e),this.logger.warn(`rule ${t} is not defined`))}function xz(i){let{metaSchema:e}=i;e!==void 0&&(i.$data&&this.opts.$data&&(e=QC(e)),i.validateSchema=this.compile(e,!0))}var Pz={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function QC(i){return{anyOf:[i,Pz]}}});var MC=Qe(kv=>{"use strict";Object.defineProperty(kv,"__esModule",{value:!0});var Cz={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};kv.default=Cz});var ZC=Qe(oa=>{"use strict";Object.defineProperty(oa,"__esModule",{value:!0});oa.callRef=oa.getValidate=void 0;var Ez=Jh(),IC=Wn(),yn=Je(),Ol=ks(),NC=tp(),rp=mt(),Tz={keyword:"$ref",schemaType:"string",code(i){let{gen:e,schema:t,it:n}=i,{baseId:r,schemaEnv:s,validateName:o,opts:a,self:l}=n,{root:c}=s;if((t==="#"||t==="#/")&&r===c.baseId)return f();let u=NC.resolveRef.call(l,c,r,t);if(u===void 0)throw new Ez.default(n.opts.uriResolver,r,t);if(u instanceof NC.SchemaEnv)return d(u);return h(u);function f(){if(s===c)return sp(i,o,s,s.$async);let p=e.scopeValue("root",{ref:c});return sp(i,(0,yn._)`${p}.validate`,c,c.$async)}function d(p){let m=jC(i,p);sp(i,m,p,p.$async)}function h(p){let m=e.scopeValue("schema",a.code.source===!0?{ref:p,code:(0,yn.stringify)(p)}:{ref:p}),g=e.name("valid"),O=i.subschema({schema:p,dataTypes:[],schemaPath:yn.nil,topSchemaRef:m,errSchemaPath:t},g);i.mergeEvaluated(O),i.ok(g)}}};function jC(i,e){let{gen:t}=i;return e.validate?t.scopeValue("validate",{ref:e.validate}):(0,yn._)`${t.scopeValue("wrapper",{ref:e})}.validate`}oa.getValidate=jC;function sp(i,e,t,n){let{gen:r,it:s}=i,{allErrors:o,schemaEnv:a,opts:l}=s,c=l.passContext?Ol.default.this:yn.nil;n?u():f();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let p=r.let("valid");r.try(()=>{r.code((0,yn._)`await ${(0,IC.callValidateCode)(i,e,c)}`),h(e),o||r.assign(p,!0)},m=>{r.if((0,yn._)`!(${m} instanceof ${s.ValidationError})`,()=>r.throw(m)),d(m),o||r.assign(p,!1)}),i.ok(p)}function f(){i.result((0,IC.callValidateCode)(i,e,c),()=>h(e),()=>d(e))}function d(p){let m=(0,yn._)`${p}.errors`;r.assign(Ol.default.vErrors,(0,yn._)`${Ol.default.vErrors} === null ? ${m} : ${Ol.default.vErrors}.concat(${m})`),r.assign(Ol.default.errors,(0,yn._)`${Ol.default.vErrors}.length`)}function h(p){var m;if(!s.opts.unevaluated)return;let g=(m=t?.validate)===null||m===void 0?void 0:m.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=rp.mergeEvaluated.props(r,g.props,s.props));else{let O=r.var("props",(0,yn._)`${p}.evaluated.props`);s.props=rp.mergeEvaluated.props(r,O,s.props,yn.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=rp.mergeEvaluated.items(r,g.items,s.items));else{let O=r.var("items",(0,yn._)`${p}.evaluated.items`);s.items=rp.mergeEvaluated.items(r,O,s.items,yn.Name)}}}oa.callRef=sp;oa.default=Tz});var zC=Qe(Sv=>{"use strict";Object.defineProperty(Sv,"__esModule",{value:!0});var Az=MC(),Dz=ZC(),Qz=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Az.default,Dz.default];Sv.default=Qz});var qC=Qe(xv=>{"use strict";Object.defineProperty(xv,"__esModule",{value:!0});var op=Je(),ho=op.operators,ap={maximum:{okStr:"<=",ok:ho.LTE,fail:ho.GT},minimum:{okStr:">=",ok:ho.GTE,fail:ho.LT},exclusiveMaximum:{okStr:"<",ok:ho.LT,fail:ho.GTE},exclusiveMinimum:{okStr:">",ok:ho.GT,fail:ho.LTE}},Rz={message:({keyword:i,schemaCode:e})=>(0,op.str)`must be ${ap[i].okStr} ${e}`,params:({keyword:i,schemaCode:e})=>(0,op._)`{comparison: ${ap[i].okStr}, limit: ${e}}`},Mz={keyword:Object.keys(ap),type:"number",schemaType:"number",$data:!0,error:Rz,code(i){let{keyword:e,data:t,schemaCode:n}=i;i.fail$data((0,op._)`${t} ${ap[e].fail} ${n} || isNaN(${t})`)}};xv.default=Mz});var LC=Qe(Pv=>{"use strict";Object.defineProperty(Pv,"__esModule",{value:!0});var ku=Je(),Iz={message:({schemaCode:i})=>(0,ku.str)`must be multiple of ${i}`,params:({schemaCode:i})=>(0,ku._)`{multipleOf: ${i}}`},Nz={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Iz,code(i){let{gen:e,data:t,schemaCode:n,it:r}=i,s=r.opts.multipleOfPrecision,o=e.let("res"),a=s?(0,ku._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${s}`:(0,ku._)`${o} !== parseInt(${o})`;i.fail$data((0,ku._)`(${n} === 0 || (${o} = ${t}/${n}, ${a}))`)}};Pv.default=Nz});var FC=Qe(Cv=>{"use strict";Object.defineProperty(Cv,"__esModule",{value:!0});function $C(i){let e=i.length,t=0,n=0,r;for(;n=55296&&r<=56319&&n{"use strict";Object.defineProperty(Ev,"__esModule",{value:!0});var aa=Je(),jz=mt(),Zz=FC(),zz={message({keyword:i,schemaCode:e}){let t=i==="maxLength"?"more":"fewer";return(0,aa.str)`must NOT have ${t} than ${e} characters`},params:({schemaCode:i})=>(0,aa._)`{limit: ${i}}`},qz={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:zz,code(i){let{keyword:e,data:t,schemaCode:n,it:r}=i,s=e==="maxLength"?aa.operators.GT:aa.operators.LT,o=r.opts.unicode===!1?(0,aa._)`${t}.length`:(0,aa._)`${(0,jz.useFunc)(i.gen,Zz.default)}(${t})`;i.fail$data((0,aa._)`${o} ${s} ${n}`)}};Ev.default=qz});var VC=Qe(Tv=>{"use strict";Object.defineProperty(Tv,"__esModule",{value:!0});var Lz=Wn(),lp=Je(),$z={message:({schemaCode:i})=>(0,lp.str)`must match pattern "${i}"`,params:({schemaCode:i})=>(0,lp._)`{pattern: ${i}}`},Fz={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:$z,code(i){let{data:e,$data:t,schema:n,schemaCode:r,it:s}=i,o=s.opts.unicodeRegExp?"u":"",a=t?(0,lp._)`(new RegExp(${r}, ${o}))`:(0,Lz.usePattern)(i,n);i.fail$data((0,lp._)`!${a}.test(${e})`)}};Tv.default=Fz});var WC=Qe(Av=>{"use strict";Object.defineProperty(Av,"__esModule",{value:!0});var Su=Je(),Bz={message({keyword:i,schemaCode:e}){let t=i==="maxProperties"?"more":"fewer";return(0,Su.str)`must NOT have ${t} than ${e} properties`},params:({schemaCode:i})=>(0,Su._)`{limit: ${i}}`},Vz={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Bz,code(i){let{keyword:e,data:t,schemaCode:n}=i,r=e==="maxProperties"?Su.operators.GT:Su.operators.LT;i.fail$data((0,Su._)`Object.keys(${t}).length ${r} ${n}`)}};Av.default=Vz});var XC=Qe(Dv=>{"use strict";Object.defineProperty(Dv,"__esModule",{value:!0});var xu=Wn(),Pu=Je(),Wz=mt(),Xz={message:({params:{missingProperty:i}})=>(0,Pu.str)`must have required property '${i}'`,params:({params:{missingProperty:i}})=>(0,Pu._)`{missingProperty: ${i}}`},Uz={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Xz,code(i){let{gen:e,schema:t,schemaCode:n,data:r,$data:s,it:o}=i,{opts:a}=o;if(!s&&t.length===0)return;let l=t.length>=a.loopRequired;if(o.allErrors?c():u(),a.strictRequired){let h=i.parentSchema.properties,{definedProperties:p}=i.it;for(let m of t)if(h?.[m]===void 0&&!p.has(m)){let g=o.schemaEnv.baseId+o.errSchemaPath,O=`required property "${m}" is not defined at "${g}" (strictRequired)`;(0,Wz.checkStrictMode)(o,O,o.opts.strictRequired)}}function c(){if(l||s)i.block$data(Pu.nil,f);else for(let h of t)(0,xu.checkReportMissingProp)(i,h)}function u(){let h=e.let("missing");if(l||s){let p=e.let("valid",!0);i.block$data(p,()=>d(h,p)),i.ok(p)}else e.if((0,xu.checkMissingProp)(i,t,h)),(0,xu.reportMissingProp)(i,h),e.else()}function f(){e.forOf("prop",n,h=>{i.setParams({missingProperty:h}),e.if((0,xu.noPropertyInData)(e,r,h,a.ownProperties),()=>i.error())})}function d(h,p){i.setParams({missingProperty:h}),e.forOf(h,n,()=>{e.assign(p,(0,xu.propertyInData)(e,r,h,a.ownProperties)),e.if((0,Pu.not)(p),()=>{i.error(),e.break()})},Pu.nil)}}};Dv.default=Uz});var UC=Qe(Qv=>{"use strict";Object.defineProperty(Qv,"__esModule",{value:!0});var Cu=Je(),Yz={message({keyword:i,schemaCode:e}){let t=i==="maxItems"?"more":"fewer";return(0,Cu.str)`must NOT have ${t} than ${e} items`},params:({schemaCode:i})=>(0,Cu._)`{limit: ${i}}`},Hz={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Yz,code(i){let{keyword:e,data:t,schemaCode:n}=i,r=e==="maxItems"?Cu.operators.GT:Cu.operators.LT;i.fail$data((0,Cu._)`${t}.length ${r} ${n}`)}};Qv.default=Hz});var cp=Qe(Rv=>{"use strict";Object.defineProperty(Rv,"__esModule",{value:!0});var YC=lv();YC.code='require("ajv/dist/runtime/equal").default';Rv.default=YC});var HC=Qe(Iv=>{"use strict";Object.defineProperty(Iv,"__esModule",{value:!0});var Mv=mu(),Ri=Je(),Gz=mt(),Kz=cp(),Jz={message:({params:{i,j:e}})=>(0,Ri.str)`must NOT have duplicate items (items ## ${e} and ${i} are identical)`,params:({params:{i,j:e}})=>(0,Ri._)`{i: ${i}, j: ${e}}`},eq={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Jz,code(i){let{gen:e,data:t,$data:n,schema:r,parentSchema:s,schemaCode:o,it:a}=i;if(!n&&!r)return;let l=e.let("valid"),c=s.items?(0,Mv.getSchemaTypes)(s.items):[];i.block$data(l,u,(0,Ri._)`${o} === false`),i.ok(l);function u(){let p=e.let("i",(0,Ri._)`${t}.length`),m=e.let("j");i.setParams({i:p,j:m}),e.assign(l,!0),e.if((0,Ri._)`${p} > 1`,()=>(f()?d:h)(p,m))}function f(){return c.length>0&&!c.some(p=>p==="object"||p==="array")}function d(p,m){let g=e.name("item"),O=(0,Mv.checkDataTypes)(c,g,a.opts.strictNumbers,Mv.DataType.Wrong),w=e.const("indices",(0,Ri._)`{}`);e.for((0,Ri._)`;${p}--;`,()=>{e.let(g,(0,Ri._)`${t}[${p}]`),e.if(O,(0,Ri._)`continue`),c.length>1&&e.if((0,Ri._)`typeof ${g} == "string"`,(0,Ri._)`${g} += "_"`),e.if((0,Ri._)`typeof ${w}[${g}] == "number"`,()=>{e.assign(m,(0,Ri._)`${w}[${g}]`),i.error(),e.assign(l,!1).break()}).code((0,Ri._)`${w}[${g}] = ${p}`)})}function h(p,m){let g=(0,Gz.useFunc)(e,Kz.default),O=e.name("outer");e.label(O).for((0,Ri._)`;${p}--;`,()=>e.for((0,Ri._)`${m} = ${p}; ${m}--;`,()=>e.if((0,Ri._)`${g}(${t}[${p}], ${t}[${m}])`,()=>{i.error(),e.assign(l,!1).break(O)})))}}};Iv.default=eq});var GC=Qe(jv=>{"use strict";Object.defineProperty(jv,"__esModule",{value:!0});var Nv=Je(),tq=mt(),iq=cp(),nq={message:"must be equal to constant",params:({schemaCode:i})=>(0,Nv._)`{allowedValue: ${i}}`},rq={keyword:"const",$data:!0,error:nq,code(i){let{gen:e,data:t,$data:n,schemaCode:r,schema:s}=i;n||s&&typeof s=="object"?i.fail$data((0,Nv._)`!${(0,tq.useFunc)(e,iq.default)}(${t}, ${r})`):i.fail((0,Nv._)`${s} !== ${t}`)}};jv.default=rq});var KC=Qe(Zv=>{"use strict";Object.defineProperty(Zv,"__esModule",{value:!0});var Eu=Je(),sq=mt(),oq=cp(),aq={message:"must be equal to one of the allowed values",params:({schemaCode:i})=>(0,Eu._)`{allowedValues: ${i}}`},lq={keyword:"enum",schemaType:"array",$data:!0,error:aq,code(i){let{gen:e,data:t,$data:n,schema:r,schemaCode:s,it:o}=i;if(!n&&r.length===0)throw new Error("enum must have non-empty array");let a=r.length>=o.opts.loopEnum,l,c=()=>l??(l=(0,sq.useFunc)(e,oq.default)),u;if(a||n)u=e.let("valid"),i.block$data(u,f);else{if(!Array.isArray(r))throw new Error("ajv implementation error");let h=e.const("vSchema",s);u=(0,Eu.or)(...r.map((p,m)=>d(h,m)))}i.pass(u);function f(){e.assign(u,!1),e.forOf("v",s,h=>e.if((0,Eu._)`${c()}(${t}, ${h})`,()=>e.assign(u,!0).break()))}function d(h,p){let m=r[p];return typeof m=="object"&&m!==null?(0,Eu._)`${c()}(${t}, ${h}[${p}])`:(0,Eu._)`${t} === ${m}`}}};Zv.default=lq});var JC=Qe(zv=>{"use strict";Object.defineProperty(zv,"__esModule",{value:!0});var cq=qC(),uq=LC(),fq=BC(),dq=VC(),hq=WC(),pq=XC(),mq=UC(),gq=HC(),Oq=GC(),vq=KC(),yq=[cq.default,uq.default,fq.default,dq.default,hq.default,pq.default,mq.default,gq.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Oq.default,vq.default];zv.default=yq});var Lv=Qe(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});Tu.validateAdditionalItems=void 0;var la=Je(),qv=mt(),bq={message:({params:{len:i}})=>(0,la.str)`must NOT have more than ${i} items`,params:({params:{len:i}})=>(0,la._)`{limit: ${i}}`},_q={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:bq,code(i){let{parentSchema:e,it:t}=i,{items:n}=e;if(!Array.isArray(n)){(0,qv.checkStrictMode)(t,'"additionalItems" is ignored when "items" is not an array of schemas');return}e3(i,n)}};function e3(i,e){let{gen:t,schema:n,data:r,keyword:s,it:o}=i;o.items=!0;let a=t.const("len",(0,la._)`${r}.length`);if(n===!1)i.setParams({len:e.length}),i.pass((0,la._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,qv.alwaysValidSchema)(o,n)){let c=t.var("valid",(0,la._)`${a} <= ${e.length}`);t.if((0,la.not)(c),()=>l(c)),i.ok(c)}function l(c){t.forRange("i",e.length,a,u=>{i.subschema({keyword:s,dataProp:u,dataPropType:qv.Type.Num},c),o.allErrors||t.if((0,la.not)(c),()=>t.break())})}}Tu.validateAdditionalItems=e3;Tu.default=_q});var $v=Qe(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});Au.validateTuple=void 0;var t3=Je(),up=mt(),wq=Wn(),kq={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(i){let{schema:e,it:t}=i;if(Array.isArray(e))return i3(i,"additionalItems",e);t.items=!0,!(0,up.alwaysValidSchema)(t,e)&&i.ok((0,wq.validateArray)(i))}};function i3(i,e,t=i.schema){let{gen:n,parentSchema:r,data:s,keyword:o,it:a}=i;u(r),a.opts.unevaluated&&t.length&&a.items!==!0&&(a.items=up.mergeEvaluated.items(n,t.length,a.items));let l=n.name("valid"),c=n.const("len",(0,t3._)`${s}.length`);t.forEach((f,d)=>{(0,up.alwaysValidSchema)(a,f)||(n.if((0,t3._)`${c} > ${d}`,()=>i.subschema({keyword:o,schemaProp:d,dataProp:d},l)),i.ok(l))});function u(f){let{opts:d,errSchemaPath:h}=a,p=t.length,m=p===f.minItems&&(p===f.maxItems||f[e]===!1);if(d.strictTuples&&!m){let g=`"${o}" is ${p}-tuple, but minItems or maxItems/${e} are not specified or different at path "${h}"`;(0,up.checkStrictMode)(a,g,d.strictTuples)}}}Au.validateTuple=i3;Au.default=kq});var n3=Qe(Fv=>{"use strict";Object.defineProperty(Fv,"__esModule",{value:!0});var Sq=$v(),xq={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:i=>(0,Sq.validateTuple)(i,"items")};Fv.default=xq});var s3=Qe(Bv=>{"use strict";Object.defineProperty(Bv,"__esModule",{value:!0});var r3=Je(),Pq=mt(),Cq=Wn(),Eq=Lv(),Tq={message:({params:{len:i}})=>(0,r3.str)`must NOT have more than ${i} items`,params:({params:{len:i}})=>(0,r3._)`{limit: ${i}}`},Aq={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Tq,code(i){let{schema:e,parentSchema:t,it:n}=i,{prefixItems:r}=t;n.items=!0,!(0,Pq.alwaysValidSchema)(n,e)&&(r?(0,Eq.validateAdditionalItems)(i,r):i.ok((0,Cq.validateArray)(i)))}};Bv.default=Aq});var o3=Qe(Vv=>{"use strict";Object.defineProperty(Vv,"__esModule",{value:!0});var Un=Je(),fp=mt(),Dq={message:({params:{min:i,max:e}})=>e===void 0?(0,Un.str)`must contain at least ${i} valid item(s)`:(0,Un.str)`must contain at least ${i} and no more than ${e} valid item(s)`,params:({params:{min:i,max:e}})=>e===void 0?(0,Un._)`{minContains: ${i}}`:(0,Un._)`{minContains: ${i}, maxContains: ${e}}`},Qq={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Dq,code(i){let{gen:e,schema:t,parentSchema:n,data:r,it:s}=i,o,a,{minContains:l,maxContains:c}=n;s.opts.next?(o=l===void 0?1:l,a=c):o=1;let u=e.const("len",(0,Un._)`${r}.length`);if(i.setParams({min:o,max:a}),a===void 0&&o===0){(0,fp.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,fp.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),i.fail();return}if((0,fp.alwaysValidSchema)(s,t)){let m=(0,Un._)`${u} >= ${o}`;a!==void 0&&(m=(0,Un._)`${m} && ${u} <= ${a}`),i.pass(m);return}s.items=!0;let f=e.name("valid");a===void 0&&o===1?h(f,()=>e.if(f,()=>e.break())):o===0?(e.let(f,!0),a!==void 0&&e.if((0,Un._)`${r}.length > 0`,d)):(e.let(f,!1),d()),i.result(f,()=>i.reset());function d(){let m=e.name("_valid"),g=e.let("count",0);h(m,()=>e.if(m,()=>p(g)))}function h(m,g){e.forRange("i",0,u,O=>{i.subschema({keyword:"contains",dataProp:O,dataPropType:fp.Type.Num,compositeRule:!0},m),g()})}function p(m){e.code((0,Un._)`${m}++`),a===void 0?e.if((0,Un._)`${m} >= ${o}`,()=>e.assign(f,!0).break()):(e.if((0,Un._)`${m} > ${a}`,()=>e.assign(f,!1).break()),o===1?e.assign(f,!0):e.if((0,Un._)`${m} >= ${o}`,()=>e.assign(f,!0)))}}};Vv.default=Qq});var c3=Qe(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.validateSchemaDeps=is.validatePropertyDeps=is.error=void 0;var Wv=Je(),Rq=mt(),Du=Wn();is.error={message:({params:{property:i,depsCount:e,deps:t}})=>{let n=e===1?"property":"properties";return(0,Wv.str)`must have ${n} ${t} when property ${i} is present`},params:({params:{property:i,depsCount:e,deps:t,missingProperty:n}})=>(0,Wv._)`{property: ${i}, missingProperty: ${n}, depsCount: ${e}, deps: ${t}}`};var Mq={keyword:"dependencies",type:"object",schemaType:"object",error:is.error,code(i){let[e,t]=Iq(i);a3(i,e),l3(i,t)}};function Iq({schema:i}){let e={},t={};for(let n in i){if(n==="__proto__")continue;let r=Array.isArray(i[n])?e:t;r[n]=i[n]}return[e,t]}function a3(i,e=i.schema){let{gen:t,data:n,it:r}=i;if(Object.keys(e).length===0)return;let s=t.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let l=(0,Du.propertyInData)(t,n,o,r.opts.ownProperties);i.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),r.allErrors?t.if(l,()=>{for(let c of a)(0,Du.checkReportMissingProp)(i,c)}):(t.if((0,Wv._)`${l} && (${(0,Du.checkMissingProp)(i,a,s)})`),(0,Du.reportMissingProp)(i,s),t.else())}}is.validatePropertyDeps=a3;function l3(i,e=i.schema){let{gen:t,data:n,keyword:r,it:s}=i,o=t.name("valid");for(let a in e)(0,Rq.alwaysValidSchema)(s,e[a])||(t.if((0,Du.propertyInData)(t,n,a,s.opts.ownProperties),()=>{let l=i.subschema({keyword:r,schemaProp:a},o);i.mergeValidEvaluated(l,o)},()=>t.var(o,!0)),i.ok(o))}is.validateSchemaDeps=l3;is.default=Mq});var f3=Qe(Xv=>{"use strict";Object.defineProperty(Xv,"__esModule",{value:!0});var u3=Je(),Nq=mt(),jq={message:"property name must be valid",params:({params:i})=>(0,u3._)`{propertyName: ${i.propertyName}}`},Zq={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:jq,code(i){let{gen:e,schema:t,data:n,it:r}=i;if((0,Nq.alwaysValidSchema)(r,t))return;let s=e.name("valid");e.forIn("key",n,o=>{i.setParams({propertyName:o}),i.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},s),e.if((0,u3.not)(s),()=>{i.error(!0),r.allErrors||e.break()})}),i.ok(s)}};Xv.default=Zq});var Yv=Qe(Uv=>{"use strict";Object.defineProperty(Uv,"__esModule",{value:!0});var dp=Wn(),Sr=Je(),zq=ks(),hp=mt(),qq={message:"must NOT have additional properties",params:({params:i})=>(0,Sr._)`{additionalProperty: ${i.additionalProperty}}`},Lq={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:qq,code(i){let{gen:e,schema:t,parentSchema:n,data:r,errsCount:s,it:o}=i;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:l}=o;if(o.props=!0,l.removeAdditional!=="all"&&(0,hp.alwaysValidSchema)(o,t))return;let c=(0,dp.allSchemaProperties)(n.properties),u=(0,dp.allSchemaProperties)(n.patternProperties);f(),i.ok((0,Sr._)`${s} === ${zq.default.errors}`);function f(){e.forIn("key",r,g=>{!c.length&&!u.length?p(g):e.if(d(g),()=>p(g))})}function d(g){let O;if(c.length>8){let w=(0,hp.schemaRefOrVal)(o,n.properties,"properties");O=(0,dp.isOwnProperty)(e,w,g)}else c.length?O=(0,Sr.or)(...c.map(w=>(0,Sr._)`${g} === ${w}`)):O=Sr.nil;return u.length&&(O=(0,Sr.or)(O,...u.map(w=>(0,Sr._)`${(0,dp.usePattern)(i,w)}.test(${g})`))),(0,Sr.not)(O)}function h(g){e.code((0,Sr._)`delete ${r}[${g}]`)}function p(g){if(l.removeAdditional==="all"||l.removeAdditional&&t===!1){h(g);return}if(t===!1){i.setParams({additionalProperty:g}),i.error(),a||e.break();return}if(typeof t=="object"&&!(0,hp.alwaysValidSchema)(o,t)){let O=e.name("valid");l.removeAdditional==="failing"?(m(g,O,!1),e.if((0,Sr.not)(O),()=>{i.reset(),h(g)})):(m(g,O),a||e.if((0,Sr.not)(O),()=>e.break()))}}function m(g,O,w){let S={keyword:"additionalProperties",dataProp:g,dataPropType:hp.Type.Str};w===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),i.subschema(S,O)}}};Uv.default=Lq});var p3=Qe(Gv=>{"use strict";Object.defineProperty(Gv,"__esModule",{value:!0});var $q=yu(),d3=Wn(),Hv=mt(),h3=Yv(),Fq={keyword:"properties",type:"object",schemaType:"object",code(i){let{gen:e,schema:t,parentSchema:n,data:r,it:s}=i;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&h3.default.code(new $q.KeywordCxt(s,h3.default,"additionalProperties"));let o=(0,d3.allSchemaProperties)(t);for(let f of o)s.definedProperties.add(f);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=Hv.mergeEvaluated.props(e,(0,Hv.toHash)(o),s.props));let a=o.filter(f=>!(0,Hv.alwaysValidSchema)(s,t[f]));if(a.length===0)return;let l=e.name("valid");for(let f of a)c(f)?u(f):(e.if((0,d3.propertyInData)(e,r,f,s.opts.ownProperties)),u(f),s.allErrors||e.else().var(l,!0),e.endIf()),i.it.definedProperties.add(f),i.ok(l);function c(f){return s.opts.useDefaults&&!s.compositeRule&&t[f].default!==void 0}function u(f){i.subschema({keyword:"properties",schemaProp:f,dataProp:f},l)}}};Gv.default=Fq});var v3=Qe(Kv=>{"use strict";Object.defineProperty(Kv,"__esModule",{value:!0});var m3=Wn(),pp=Je(),g3=mt(),O3=mt(),Bq={keyword:"patternProperties",type:"object",schemaType:"object",code(i){let{gen:e,schema:t,data:n,parentSchema:r,it:s}=i,{opts:o}=s,a=(0,m3.allSchemaProperties)(t),l=a.filter(m=>(0,g3.alwaysValidSchema)(s,t[m]));if(a.length===0||l.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let c=o.strictSchema&&!o.allowMatchingProperties&&r.properties,u=e.name("valid");s.props!==!0&&!(s.props instanceof pp.Name)&&(s.props=(0,O3.evaluatedPropsToName)(e,s.props));let{props:f}=s;d();function d(){for(let m of a)c&&h(m),s.allErrors?p(m):(e.var(u,!0),p(m),e.if(u))}function h(m){for(let g in c)new RegExp(m).test(g)&&(0,g3.checkStrictMode)(s,`property ${g} matches pattern ${m} (use allowMatchingProperties)`)}function p(m){e.forIn("key",n,g=>{e.if((0,pp._)`${(0,m3.usePattern)(i,m)}.test(${g})`,()=>{let O=l.includes(m);O||i.subschema({keyword:"patternProperties",schemaProp:m,dataProp:g,dataPropType:O3.Type.Str},u),s.opts.unevaluated&&f!==!0?e.assign((0,pp._)`${f}[${g}]`,!0):!O&&!s.allErrors&&e.if((0,pp.not)(u),()=>e.break())})})}}};Kv.default=Bq});var y3=Qe(Jv=>{"use strict";Object.defineProperty(Jv,"__esModule",{value:!0});var Vq=mt(),Wq={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(i){let{gen:e,schema:t,it:n}=i;if((0,Vq.alwaysValidSchema)(n,t)){i.fail();return}let r=e.name("valid");i.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},r),i.failResult(r,()=>i.reset(),()=>i.error())},error:{message:"must NOT be valid"}};Jv.default=Wq});var b3=Qe(ey=>{"use strict";Object.defineProperty(ey,"__esModule",{value:!0});var Xq=Wn(),Uq={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Xq.validateUnion,error:{message:"must match a schema in anyOf"}};ey.default=Uq});var _3=Qe(ty=>{"use strict";Object.defineProperty(ty,"__esModule",{value:!0});var mp=Je(),Yq=mt(),Hq={message:"must match exactly one schema in oneOf",params:({params:i})=>(0,mp._)`{passingSchemas: ${i.passing}}`},Gq={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Hq,code(i){let{gen:e,schema:t,parentSchema:n,it:r}=i;if(!Array.isArray(t))throw new Error("ajv implementation error");if(r.opts.discriminator&&n.discriminator)return;let s=t,o=e.let("valid",!1),a=e.let("passing",null),l=e.name("_valid");i.setParams({passing:a}),e.block(c),i.result(o,()=>i.reset(),()=>i.error(!0));function c(){s.forEach((u,f)=>{let d;(0,Yq.alwaysValidSchema)(r,u)?e.var(l,!0):d=i.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},l),f>0&&e.if((0,mp._)`${l} && ${o}`).assign(o,!1).assign(a,(0,mp._)`[${a}, ${f}]`).else(),e.if(l,()=>{e.assign(o,!0),e.assign(a,f),d&&i.mergeEvaluated(d,mp.Name)})})}}};ty.default=Gq});var w3=Qe(iy=>{"use strict";Object.defineProperty(iy,"__esModule",{value:!0});var Kq=mt(),Jq={keyword:"allOf",schemaType:"array",code(i){let{gen:e,schema:t,it:n}=i;if(!Array.isArray(t))throw new Error("ajv implementation error");let r=e.name("valid");t.forEach((s,o)=>{if((0,Kq.alwaysValidSchema)(n,s))return;let a=i.subschema({keyword:"allOf",schemaProp:o},r);i.ok(r),i.mergeEvaluated(a)})}};iy.default=Jq});var x3=Qe(ny=>{"use strict";Object.defineProperty(ny,"__esModule",{value:!0});var gp=Je(),S3=mt(),eL={message:({params:i})=>(0,gp.str)`must match "${i.ifClause}" schema`,params:({params:i})=>(0,gp._)`{failingKeyword: ${i.ifClause}}`},tL={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:eL,code(i){let{gen:e,parentSchema:t,it:n}=i;t.then===void 0&&t.else===void 0&&(0,S3.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let r=k3(n,"then"),s=k3(n,"else");if(!r&&!s)return;let o=e.let("valid",!0),a=e.name("_valid");if(l(),i.reset(),r&&s){let u=e.let("ifClause");i.setParams({ifClause:u}),e.if(a,c("then",u),c("else",u))}else r?e.if(a,c("then")):e.if((0,gp.not)(a),c("else"));i.pass(o,()=>i.error(!0));function l(){let u=i.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);i.mergeEvaluated(u)}function c(u,f){return()=>{let d=i.subschema({keyword:u},a);e.assign(o,a),i.mergeValidEvaluated(d,o),f?e.assign(f,(0,gp._)`${u}`):i.setParams({ifClause:u})}}}};function k3(i,e){let t=i.schema[e];return t!==void 0&&!(0,S3.alwaysValidSchema)(i,t)}ny.default=tL});var P3=Qe(ry=>{"use strict";Object.defineProperty(ry,"__esModule",{value:!0});var iL=mt(),nL={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:i,parentSchema:e,it:t}){e.if===void 0&&(0,iL.checkStrictMode)(t,`"${i}" without "if" is ignored`)}};ry.default=nL});var C3=Qe(sy=>{"use strict";Object.defineProperty(sy,"__esModule",{value:!0});var rL=Lv(),sL=n3(),oL=$v(),aL=s3(),lL=o3(),cL=c3(),uL=f3(),fL=Yv(),dL=p3(),hL=v3(),pL=y3(),mL=b3(),gL=_3(),OL=w3(),vL=x3(),yL=P3();function bL(i=!1){let e=[pL.default,mL.default,gL.default,OL.default,vL.default,yL.default,uL.default,fL.default,cL.default,dL.default,hL.default];return i?e.push(sL.default,aL.default):e.push(rL.default,oL.default),e.push(lL.default),e}sy.default=bL});var E3=Qe(oy=>{"use strict";Object.defineProperty(oy,"__esModule",{value:!0});var si=Je(),_L={message:({schemaCode:i})=>(0,si.str)`must match format "${i}"`,params:({schemaCode:i})=>(0,si._)`{format: ${i}}`},wL={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:_L,code(i,e){let{gen:t,data:n,$data:r,schema:s,schemaCode:o,it:a}=i,{opts:l,errSchemaPath:c,schemaEnv:u,self:f}=a;if(!l.validateFormats)return;r?d():h();function d(){let p=t.scopeValue("formats",{ref:f.formats,code:l.code.formats}),m=t.const("fDef",(0,si._)`${p}[${o}]`),g=t.let("fType"),O=t.let("format");t.if((0,si._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>t.assign(g,(0,si._)`${m}.type || "string"`).assign(O,(0,si._)`${m}.validate`),()=>t.assign(g,(0,si._)`"string"`).assign(O,m)),i.fail$data((0,si.or)(w(),S()));function w(){return l.strictSchema===!1?si.nil:(0,si._)`${o} && !${O}`}function S(){let C=u.$async?(0,si._)`(${m}.async ? await ${O}(${n}) : ${O}(${n}))`:(0,si._)`${O}(${n})`,k=(0,si._)`(typeof ${O} == "function" ? ${C} : ${O}.test(${n}))`;return(0,si._)`${O} && ${O} !== true && ${g} === ${e} && !${k}`}}function h(){let p=f.formats[s];if(!p){w();return}if(p===!0)return;let[m,g,O]=S(p);m===e&&i.pass(C());function w(){if(l.strictSchema===!1){f.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${s}" ignored in schema at path "${c}"`}}function S(k){let _=k instanceof RegExp?(0,si.regexpCode)(k):l.code.formats?(0,si._)`${l.code.formats}${(0,si.getProperty)(s)}`:void 0,P=t.scopeValue("formats",{key:s,ref:k,code:_});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,si._)`${P}.validate`]:["string",k,P]}function C(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!u.$async)throw new Error("async format in sync schema");return(0,si._)`await ${O}(${n})`}return typeof g=="function"?(0,si._)`${O}(${n})`:(0,si._)`${O}.test(${n})`}}}};oy.default=wL});var T3=Qe(ay=>{"use strict";Object.defineProperty(ay,"__esModule",{value:!0});var kL=E3(),SL=[kL.default];ay.default=SL});var A3=Qe(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});vl.contentVocabulary=vl.metadataVocabulary=void 0;vl.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];vl.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Q3=Qe(ly=>{"use strict";Object.defineProperty(ly,"__esModule",{value:!0});var xL=zC(),PL=JC(),CL=C3(),EL=T3(),D3=A3(),TL=[xL.default,PL.default,(0,CL.default)(),EL.default,D3.metadataVocabulary,D3.contentVocabulary];ly.default=TL});var R3=Qe(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});Qu.DiscrError=void 0;var AL;(function(i){i.Tag="tag",i.Mapping="mapping"})(AL=Qu.DiscrError||(Qu.DiscrError={}))});var I3=Qe(uy=>{"use strict";Object.defineProperty(uy,"__esModule",{value:!0});var yl=Je(),cy=R3(),M3=tp(),DL=mt(),QL={message:({params:{discrError:i,tagName:e}})=>i===cy.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:i,tag:e,tagName:t}})=>(0,yl._)`{error: ${i}, tag: ${t}, tagValue: ${e}}`},RL={keyword:"discriminator",type:"object",schemaType:"object",error:QL,code(i){let{gen:e,data:t,schema:n,parentSchema:r,it:s}=i,{oneOf:o}=r;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let l=e.let("valid",!1),c=e.const("tag",(0,yl._)`${t}${(0,yl.getProperty)(a)}`);e.if((0,yl._)`typeof ${c} == "string"`,()=>u(),()=>i.error(!1,{discrError:cy.DiscrError.Tag,tag:c,tagName:a})),i.ok(l);function u(){let h=d();e.if(!1);for(let p in h)e.elseIf((0,yl._)`${c} === ${p}`),e.assign(l,f(h[p]));e.else(),i.error(!1,{discrError:cy.DiscrError.Mapping,tag:c,tagName:a}),e.endIf()}function f(h){let p=e.name("valid"),m=i.subschema({keyword:"oneOf",schemaProp:h},p);return i.mergeEvaluated(m,yl.Name),p}function d(){var h;let p={},m=O(r),g=!0;for(let C=0;C{ML.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var z3=Qe((Ut,Z3)=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.MissingRefError=Ut.ValidationError=Ut.CodeGen=Ut.Name=Ut.nil=Ut.stringify=Ut.str=Ut._=Ut.KeywordCxt=void 0;var IL=RC(),NL=Q3(),jL=I3(),j3=N3(),ZL=["/properties"],Op="http://json-schema.org/draft-07/schema",vp=class extends IL.default{_addVocabularies(){super._addVocabularies(),NL.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(jL.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(j3,ZL):j3;this.addMetaSchema(e,Op,!1),this.refs["http://json-schema.org/schema"]=Op}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Op)?Op:void 0)}};Z3.exports=Ut=vp;Object.defineProperty(Ut,"__esModule",{value:!0});Ut.default=vp;var zL=yu();Object.defineProperty(Ut,"KeywordCxt",{enumerable:!0,get:function(){return zL.KeywordCxt}});var bl=Je();Object.defineProperty(Ut,"_",{enumerable:!0,get:function(){return bl._}});Object.defineProperty(Ut,"str",{enumerable:!0,get:function(){return bl.str}});Object.defineProperty(Ut,"stringify",{enumerable:!0,get:function(){return bl.stringify}});Object.defineProperty(Ut,"nil",{enumerable:!0,get:function(){return bl.nil}});Object.defineProperty(Ut,"Name",{enumerable:!0,get:function(){return bl.Name}});Object.defineProperty(Ut,"CodeGen",{enumerable:!0,get:function(){return bl.CodeGen}});var qL=Kh();Object.defineProperty(Ut,"ValidationError",{enumerable:!0,get:function(){return qL.default}});var LL=Jh();Object.defineProperty(Ut,"MissingRefError",{enumerable:!0,get:function(){return LL.default}})});var M$={};z5(M$,{default:()=>kp});module.exports=q5(M$);var tn=require("obsidian");var Sy=require("obsidian");var ls=[{name:"Blinded",id:"Blinded",description:`A blinded creature can\u2019t see and automatically fails any ability check that requires sight. Attack rolls against the creature have advantage, and the creature\u2019s Attack rolls have disadvantage.`},{name:"Charmed",id:"Charmed",description:`A charmed creature can\u2019t Attack the charmer or target the charmer with harmful Abilities or magical Effects. The charmer has advantage on any ability check to interact socially with the creature.`},{name:"Concentrating",id:"Concentrating",description:`Some spells require you to maintain concentration in order to keep their magic active. If you lose concentration, such a spell ends. A creature loses concentration when: it casts another spell that requires concentration, is incapacitated, or dies. When a creature takes damage, it must make a constitution saving throw with a DC of 10 or half the damage it took, whichever is higher. On a failure, concentration is lost.`},{name:"Deafened",id:"Deafened",description:"A deafened creature can\u2019t hear and automatically fails any ability check that requires hearing."},{name:"Frightened",id:"Frightened",description:`A frightened creature has disadvantage on Ability Checks and Attack rolls while the source of its fear is within Line of Sight. The creature can\u2019t willingly move closer to the source of its fear.`},{name:"Grappled",id:"Grappled",description:`A grappled creature\u2019s speed becomes 0, and it can\u2019t benefit from any bonus to its speed. The condition ends if the Grappler is incapacitated. The condition also ends if an Effect removes the grappled creature from the reach of the Grappler or Grappling Effect, such as when a creature is hurled away by the Thunderwave spell.`},{name:"Incapacitated",id:"Incapacitated",description:"An incapacitated creature can\u2019t take Actions or Reactions."},{name:"Invisible",id:"Invisible",description:`An invisible creature is impossible to see without the aid of magic or a Special sense. For the Purpose of Hiding, the creature is heavily obscured. The creature\u2019s Location can be detected by any noise it makes or any tracks it leaves. Attack rolls against the creature have disadvantage, and the creature\u2019s Attack rolls have advantage.`},{name:"Paralyzed",id:"Paralyzed",description:`A paralyzed creature is incapacitated and can\u2019t move or speak. The creature automatically fails Strength and Dexterity Saving Throws. Attack rolls against the creature have advantage. Any Attack that hits the creature is a critical hit if the attacker is within 5 feet of the creature.`},{name:"Petrified",id:"Petrified",description:`A petrified creature is transformed, along with any nonmagical object it is wearing or carrying, into a solid inanimate substance (usually stone). Its weight increases by a factor of ten, and it ceases aging. The creature is incapacitated, can\u2019t move or speak, and is unaware of its surroundings. Attack rolls against the creature have advantage. The creature automatically fails Strength and Dexterity Saving Throws. The creature has Resistance to all damage. The creature is immune to poison and disease, although a poison or disease already in its system is suspended, not neutralized.`},{name:"Poisoned",id:"Poisoned",description:"A poisoned creature has disadvantage on Attack rolls and Ability Checks."},{name:"Prone",id:"Prone",description:`A prone creature\u2019s only Movement option is to crawl, unless it stands up and thereby ends the condition. The creature has disadvantage on Attack rolls. An Attack roll against the creature has advantage if the attacker is within 5 feet of the creature. Otherwise, the Attack roll has disadvantage.`},{name:"Reacted",id:"Reacted",description:`A creature, unless otherwise specified, gets one reaction per round of combat. A reaction is an instant response to a trigger of some kind, which can occur on your turn or on someone else\u2019s. A reaction can be spent to make an opportunity attack, do a readied action, or use an ability that requires a reaction. A creature that has already reacted cannot use a reaction until the start of its turn.`},{name:"Restrained",id:"Restrained",description:`A restrained creature\u2019s speed becomes 0, and it can\u2019t benefit from any bonus to its speed. Attack rolls against the creature have advantage, and the creature\u2019s Attack rolls have disadvantage. The creature has disadvantage on Dexterity Saving Throws.`},{name:"Stunned",id:"Stunned",description:`A stunned creature is incapacitated, can\u2019t move, and can speak only falteringly. The creature automatically fails Strength and Dexterity Saving Throws. Attack rolls against the creature have advantage.`},{name:"Unconscious",id:"Unconscious",description:`An unconscious creature is incapacitated, can\u2019t move or speak, and is unaware of its surroundings. The creature drops whatever it\u2019s holding and falls prone. The creature automatically fails Strength and Dexterity Saving Throws. Attack rolls against the creature have advantage. Any Attack that hits the creature is a critical hit if the attacker is within 5 feet of the creature.`}];var Mn="initiative-tracker-view",Ds="initiative-tracker-player-view",ko="initiative-tracker-creature-view";var We="\u2013",W$=Sy.Platform.isMacOS?"Meta":"Control";var In={ignore:"ignore",current:"current",temp:"temp"},Jn={playerFirst:"playerFirst",npcFirst:"npcFirst",random:"random"},xy={players:[],parties:[],defaultParty:null,statuses:[...ls],unconsciousId:"Unconscious",version:[],canUseDiceRoll:!1,preferStatblockLink:!1,initiative:"1d20 + %mod%",modifier:null,sync:!1,playerMarker:"default",monsterMarker:"default",state:{creatures:[],state:!1,name:null,round:null,logFile:null},condense:!1,clamp:!0,autoStatus:!0,beginnerTips:!0,displayDifficulty:!0,encounters:{},warnedAboutImports:!1,openState:{battle:!0,party:!0,status:!0,plugin:!0,player:!0,builder:!0},hpOverflow:In.ignore,additiveTemp:!1,rpgSystem:"dnd5e",logging:!1,logFolder:"/",resolveTies:Jn.playerFirst,useLegacy:!1,diplayPlayerHPValues:!0,rollHP:!1,descending:!0,builder:{showParty:!0,showXP:!0,sidebarIcon:!0},rollPlayerInitiatives:0},Rp={.125:"\u215B",.25:"\xBC",.375:"\u215C",.5:"\xBD",.625:"\u215D",.75:"\xBE",.875:"\u215E"};var SE=require("obsidian");var vt=require("obsidian"),cs="RANDOM_HP";function Py(){(0,vt.addIcon)(cs,` `),(0,vt.addIcon)(Zp,$5),(0,vt.addIcon)(Al,B5),(0,vt.addIcon)(zp,V5),(0,vt.addIcon)(W5,X5),(0,vt.addIcon)(qp,U5),(0,vt.addIcon)(Lp,Y5),(0,vt.addIcon)($p,H5),(0,vt.addIcon)(Fp,G5),(0,vt.addIcon)(K5,J5),(0,vt.addIcon)(an,eE),(0,vt.addIcon)(ir,tE),(0,vt.addIcon)(iE,nE),(0,vt.addIcon)(Ql,sE),(0,vt.addIcon)(Dl,rE),(0,vt.addIcon)(Bp,lE),(0,vt.addIcon)(oE,aE),(0,vt.addIcon)(So,cE),(0,vt.addIcon)(Vp,uE),(0,vt.addIcon)(Wu,fE),(0,vt.addIcon)(Qs,dE),(0,vt.addIcon)(us,F5),(0,vt.addIcon)(Wp,hE),(0,vt.addIcon)(Bu,''),(0,vt.addIcon)(Mp,''),(0,vt.addIcon)(L5,''),(0,vt.addIcon)(Ip,''),(0,vt.addIcon)(pE,mE),(0,vt.addIcon)(nr,gE),(0,vt.addIcon)(jp,''),(0,vt.addIcon)(Np,'')}var Mp="expand-creatures",Bu="group-creatures",L5="initiative-tracker-active",Ip="initiative-tracker-creature-view",er="eye-off",tr="heart-handshake",Np="ARROW_DOWN_A-Z",jp="ARROW_DOWN_0-1",Zp="initiative-tracker",$5='',us="crossed-swords",F5='',Al="initiative-tracker-save",B5='',zp="initiative-tracker-add",V5='',Vu="trash";var W5="initiative-tracker-restart",X5='',qp="initiative-tracker-play",U5='',Lp="initiative-tracker-forward",Y5='',$p="initiative-tracker-backward",H5='',Fp="initiative-tracker-stop",G5='',K5="initiative-tracker-grip",J5='',an="initiative-tracker-hp",eE='',ir="initiative-tracker-ac",tE='',iE="initiative-tracker-hamburger",nE='',Dl="initiative-tracker-disable",rE='',Ql="initiative-tracker-enable",sE='',oE="initiative-tracker-edit",aE='',Bp="initiative-tracker-tags",lE='',So="initiative-tracker-initiative",cE='',Vp="initiative-tracker-redo",uE='',Wu="initiative-tracker-new",fE='',Qs="initiative-tracker-dice",dE='',Wp="initiative-tracker-copy",hE='',pE="initiative-tracker-player-view",mE='',nr="intiative-tracker-encounter-builder",gE='';var ln=class{constructor(){J(this,"displayName",We);J(this,"valueUnit","XP")}getCreatureDifficulty(e,t){return 0}getAdditionalCreatureDifficultyStats(e,t){return[]}getEncounterDifficulty(e,t){return{displayName:We,cssClass:"",value:0,title:"Total XP",summary:We,intermediateValues:[]}}getDifficultyThresholds(e){return[]}formatDifficultyValue(e,t){return isNaN(e)?We:t?`${e.toLocaleString()} ${this.valueUnit}`:e.toLocaleString()}getAdditionalDifficultyBudgets(e){return[]}};var Cy={1:{daily:300,easy:25,medium:50,hard:75,deadly:100},2:{daily:600,easy:50,medium:100,hard:150,deadly:200},3:{daily:1200,easy:75,medium:150,hard:225,deadly:400},4:{daily:1700,easy:125,medium:250,hard:375,deadly:500},5:{daily:3500,easy:250,medium:500,hard:750,deadly:1100},6:{daily:4e3,easy:300,medium:600,hard:900,deadly:1400},7:{daily:5e3,easy:350,medium:750,hard:1100,deadly:1700},8:{daily:6e3,easy:450,medium:900,hard:1400,deadly:2100},9:{daily:7500,easy:550,medium:1100,hard:1600,deadly:2400},10:{daily:9e3,easy:600,medium:1200,hard:1900,deadly:2800},11:{daily:10500,easy:800,medium:1600,hard:2400,deadly:3600},12:{daily:11500,easy:1e3,medium:2e3,hard:3e3,deadly:4500},13:{daily:13500,easy:1100,medium:2200,hard:3400,deadly:5100},14:{daily:15e3,easy:1250,medium:2500,hard:3800,deadly:5700},15:{daily:18e3,easy:1400,medium:2800,hard:4300,deadly:6400},16:{daily:2e4,easy:1600,medium:3200,hard:4800,deadly:7200},17:{daily:25e3,easy:2e3,medium:3900,hard:5900,deadly:8800},18:{daily:27e3,easy:2100,medium:4200,hard:6300,deadly:9500},19:{daily:3e4,easy:2400,medium:4900,hard:7300,deadly:10900},20:{daily:4e4,easy:2800,medium:5700,hard:8500,deadly:12700}},OE={0:0,"0.125":25,"1/8":25,"0.25":50,"1/4":50,"0.5":100,"1/2":100,1:200,2:450,3:700,4:1100,5:1800,6:2300,7:2900,8:3900,9:5e3,10:5900,11:7200,12:8400,13:1e4,14:11500,15:13e3,16:15e3,17:18e3,18:2e4,19:22e3,20:25e3,21:33e3,22:41e3,23:5e4,24:62e3,25:75e3,26:9e4,27:105e3,28:12e4,29:135e3,30:155e3},Xu,Ey,va=class extends ln{constructor(t){super();Tl(this,Xu);J(this,"plugin");J(this,"systemDifficulties",["Easy","Medium","Hard","Deadly"]);this.plugin=t,this.displayName="DnD 5e"}getCreatureDifficulty(t,n){let r=cn(this.plugin,t,o=>o?.xp??0);if(r)return r;let s=cn(this.plugin,t,o=>o?.cr??"0");return OE[s]??0}getAdditionalCreatureDifficultyStats(t,n){let r=cn(this.plugin,t,s=>s?.cr??0);return[`${fs(r)} CR`]}getEncounterDifficulty(t,n){let r=[...t].reduce((d,[h,p])=>d+this.getCreatureDifficulty(h)*p,0),s=[...t.values()].reduce((d,h)=>d+h,0),o=Qp(this,Xu,Ey).call(this,s,n.length),a=n.length==0||s==0?0:r*o,l=this.getDifficultyThresholds(n),c=l.reverse().find(d=>a>=d.minValue)?.displayName??"Trivial",u=l.map(d=>`${d.displayName}: ${d.minValue}`).join(` `),f=`Encounter is ${c} Total XP: ${r} Adjusted XP: ${a} (x${o}) Threshold ${u}`;return{displayName:c,summary:f,cssClass:c.toLowerCase(),value:a,title:"Adjusted XP",intermediateValues:[{label:"Total XP",value:r}]}}getDifficultyThresholds(t){let n={easy:0,medium:0,hard:0,deadly:0},r=t.filter(s=>s&&s>0).map(s=>Math.max(1,Math.min(s,20)));return Object.keys(n).forEach(s=>{n[s]+=r.reduce((o,a)=>o+(Cy[a]?.[s]??0),0)}),Object.entries(n).map(([s,o])=>({displayName:s.charAt(0).toUpperCase()+s.slice(1),minValue:o})).sort((s,o)=>s.minValue-o.minValue)}getAdditionalDifficultyBudgets(t){return[{displayName:"Daily Budget",minValue:t.filter(n=>n&&n>0).reduce((n,r)=>n+Cy[Math.max(1,Math.min(r,20))].daily,0)}]}};Xu=new WeakSet,Ey=function(t,n){let r=[.5,1,1.5,2,2.5,3,4,5],s=1;switch(n<3?s++:n>5&&s--,!0){case t>=15:{s+=5;break}case t>=11:{s+=4;break}case t>=7:{s+=3;break}case t>=3:{s+=2;break}case t>=2:{s+=1;break}}return r[Math.min(s,r.length-1)]};var Uu=class extends ln{constructor(t){super();J(this,"plugin");J(this,"dnd5eRpgSystem");J(this,"systemDifficulties",["Not Deadly","Deadly"]);this.plugin=t,this.valueUnit="CR",this.displayName="DnD 5e Lazy GM",this.dnd5eRpgSystem=new va(t)}getCreatureDifficulty(t,n){return hi(cn(this.plugin,t,r=>r?.cr??0))}getAdditionalCreatureDifficultyStats(t,n){let r=this.dnd5eRpgSystem.getCreatureDifficulty(t);return[this.dnd5eRpgSystem.formatDifficultyValue(r,!0)]}getDifficultyThresholds(t){let n=t.reduce((s,o)=>s+o,0),r=t.length>0?n/t.length:0;return[{displayName:"Deadly",minValue:n/(r>4?2:4)}]}getEncounterDifficulty(t,n){let r=[...t].reduce((c,[u,f])=>c+this.getCreatureDifficulty(u)*f,0),s=this.getDifficultyThresholds(n).first()?.minValue??0,o=r>s?"Deadly":"Not Deadly",a=[...t].reduce((c,[u,f])=>c+this.dnd5eRpgSystem.getCreatureDifficulty(u)*f,0),l=`Encounter is ${o} Total XP: ${a} Total CR: ${r} Total levels: ${n.reduce((c,u)=>c+u,0)} Deadly Threshold: ${s}`;return{displayName:o,summary:l,cssClass:o=="Deadly"?"deadly":"easy",value:r,title:"Total CR",intermediateValues:[{label:"Total XP",value:a}]}}formatDifficultyValue(t,n){return t?fs(t)+(n?" CR":""):We}};var vE={1:11,2:14,3:18,4:23,5:32,6:35,7:41,8:44,9:49,10:53,11:62,12:68,13:71,14:74,15:82,16:84,17:103,18:119,19:131,20:141},yE={0:1,"1/8":5,"0.25":5,"1/4":10,"0.5":10,"1/2":16,1:22,2:28,3:37,4:48,5:60,6:65,7:70,8:85,9:85,10:95,11:106,12:115,13:120,14:125,15:130,16:140,17:150,18:160,19:165,20:180,21:200,22:225,23:250,24:275,25:300,26:325,27:350,28:375,29:400,30:425},bE={Mild:"easy",Bruising:"medium",Bloody:"medium",Brutal:"hard",Oppressive:"deadly"},Yu=class extends ln{constructor(t){super();J(this,"plugin");J(this,"valueUnit","Power");J(this,"systemDifficulties",["Mild","Bruising","Bloody","Brutal","Oppressive"]);this.plugin=t,this.displayName="DnD 5e CR2.0 Simple"}getCreatureDifficulty(t,n){let r=cn(this.plugin,t,s=>s?.cr??"0");return yE[r]??0}getAdditionalCreatureDifficultyStats(t,n){let r=cn(this.plugin,t,s=>s?.cr??0);return[`${fs(r)} CR`]}getEncounterDifficulty(t,n){let r=[...t].reduce((c,[u,f])=>c+this.getCreatureDifficulty(u)*f,0),s=this.getDifficultyThresholds(n),o=s.reverse().find(c=>r>=c.minValue)?.displayName??"Mild",a=s.map(c=>`${c.displayName}: ${c.minValue}`).join(` `),l=`Encounter is ${o} Total Power: ${r} Threshold ${a}`;return{displayName:o,summary:l,cssClass:bE[o],value:r,title:"Total Creature Power",intermediateValues:[]}}getDifficultyThresholds(t){let n={mild:.4,bruising:.6,bloody:.75,brutal:.9,Oppressive:1},r=t.map(s=>vE[s]).reduce((s,o)=>s+o,0);return Object.entries(n).map(([s,o])=>({displayName:s.charAt(0).toUpperCase()+s.slice(1),minValue:Math.round(o*r)})).sort((s,o)=>s.minValue-o.minValue)}};var Hu={1:{easy:.125,standard:.125,hard:.25,cap:1},2:{easy:.125,standard:.25,hard:.5,cap:3},3:{easy:.25,standard:.5,hard:.75,cap:4},4:{easy:.5,standard:.75,hard:1,cap:6},5:{easy:1,standard:1.5,hard:2.5,cap:8},6:{easy:1.5,standard:2,hard:3,cap:9},7:{easy:2,standard:2.5,hard:3.5,cap:10},8:{easy:2.5,standard:3,hard:4,cap:12},9:{easy:3,standard:3.5,hard:4.5,cap:13},10:{easy:3.5,standard:4,hard:5,cap:15},11:{easy:4,standard:4.5,hard:5.5,cap:16},12:{easy:4.5,standard:5,hard:6,cap:17},13:{easy:5,standard:5.5,hard:6.5,cap:19},14:{easy:5.5,standard:6,hard:7,cap:20},15:{easy:6,standard:6.5,hard:7.5,cap:22},16:{easy:6.5,standard:7,hard:8,cap:24},17:{easy:7,standard:7.5,hard:8.5,cap:25},18:{easy:7.5,standard:8,hard:9,cap:26},19:{easy:8,standard:8.5,hard:9.5,cap:28},20:{easy:8.5,standard:9,hard:10,cap:30}},_E={0:{xp:2,minionsPerStandard:5},"1/8":{xp:5,minionsPerStandard:5},"1/4":{xp:10,minionsPerStandard:5},"1/2":{xp:20,minionsPerStandard:5},1:{xp:40,minionsPerStandard:5},2:{xp:90,minionsPerStandard:5},3:{xp:140,minionsPerStandard:5},4:{xp:220,minionsPerStandard:5},5:{xp:225,minionsPerStandard:8},6:{xp:285,minionsPerStandard:8},7:{xp:360,minionsPerStandard:8},8:{xp:485,minionsPerStandard:8},9:{xp:500,minionsPerStandard:10},10:{xp:590,minionsPerStandard:10},11:{xp:720,minionsPerStandard:10},12:{xp:840,minionsPerStandard:10},13:{xp:1e3,minionsPerStandard:10},14:{xp:1150,minionsPerStandard:10},15:{xp:1300,minionsPerStandard:10},16:{xp:1500,minionsPerStandard:10},17:{xp:1800,minionsPerStandard:10},18:{xp:2e3,minionsPerStandard:10},19:{xp:2200,minionsPerStandard:10},20:{xp:2500,minionsPerStandard:10},21:{xp:3300,minionsPerStandard:10},22:{xp:4100,minionsPerStandard:10},23:{xp:5e3,minionsPerStandard:10},24:{xp:6200,minionsPerStandard:10},25:{xp:7500,minionsPerStandard:10},26:{xp:9e3,minionsPerStandard:10},27:{xp:10500,minionsPerStandard:10},28:{xp:12e3,minionsPerStandard:10},29:{xp:13500,minionsPerStandard:10},30:{xp:15500,minionsPerStandard:10}},Gu={Trivial:{encounterPoints:0,cssClass:"trivial"},Easy:{encounterPoints:1,cssClass:"easy"},Standard:{encounterPoints:2,cssClass:"medium"},Hard:{encounterPoints:4,cssClass:"hard"},Extreme:{encounterPoints:8,cssClass:"deadly"}},Ku=class extends ln{constructor(t){super();J(this,"plugin");J(this,"systemDifficulties",["Trivial","Easy","Standard","Hard","Extreme"]);this.plugin=t,this.displayName="DnD 5e Flee, Mortals!",this.valueUnit="CR"}isMinion(t){return"traits"in t&&t.traits?.find(n=>n.name==="Minion")}getAveragePlayerLevel(t){if(t.length===0)return 1;let n=t.filter(r=>r&&r>0).map(r=>Math.max(1,Math.min(r,20))).reduce((r,s)=>r+s,0);return Math.floor(n/t.length)}getCreatureStatistics(t){let n=0,r=0;return t.forEach((s,o)=>{let a=cn(this.plugin,o,c=>c?.cr??0),l=hi(o.cr);if(this.isMinion(o)){let c=_E[a].minionsPerStandard;a=l*Math.floor(s/c)}else a=l*s;rs?.cr??"0");return hi(r)}getEncounterDifficulty(t,n){let r=this.getAveragePlayerLevel(n),s=Hu[r]?.cap,{totalCreatureCr:o,maxCreatureCr:a}=this.getCreatureStatistics(t),l=this.getDifficultyThresholds(n),c=l.reverse().find(p=>o>=p.minValue)?.displayName,u=Gu[c].encounterPoints,f=Gu[c].cssClass;a>s&&(c="Extreme (Exceeds CR cap)",u=Gu.Extreme.encounterPoints,f=Gu.Extreme.cssClass);let d=l.map(p=>`${p.displayName}: ${p.minValue}`).join(` `),h=`Encounter is ${c} Total Creature CR: ${o} Daily Encounter Points: ${u} Party's CR Cap: ${s} Threshold ${d}`;return{displayName:c,summary:h,cssClass:f,value:o,title:"Total Creature CR",intermediateValues:[{label:"Daily Encounter Points",value:u},{label:"Creature CR Cap",value:s}]}}getDifficultyThresholds(t){let n=this.getAveragePlayerLevel(t),r=Hu[n]?.standard*t.length,s=Hu[n]?.hard*t.length,o=s+(s-r);return[{displayName:"Trivial",minValue:0},{displayName:"Easy",minValue:Hu[n]?.easy*t.length},{displayName:"Standard",minValue:r},{displayName:"Hard",minValue:s},{displayName:"Extreme",minValue:o}]}getAdditionalDifficultyBudgets(t){return[{displayName:"Encounter Points per Day",minValue:8}]}formatDifficultyValue(t,n){return isNaN(t)?We:n?`${fs(t)} ${this.valueUnit}`:fs(t)}};var wE={"-4":10,"-3":15,"-2":20,"-1":30,0:40,1:60,2:80,3:120,4:160};var kE={trivial:"trivial",low:"easy",moderate:"medium",severe:"hard",extreme:"deadly"},Ju=class extends ln{constructor(t){super();J(this,"plugin");J(this,"systemDifficulties",["Trivial","Low","Moderate","Severe","Extreme"]);this.plugin=t,this.displayName="Pathfinder 2e"}getCreatureDifficulty(t,n){let r=cn(this.plugin,t,a=>a?.level)?.toString().split(" ").slice(-1);if(r==null||r==null)return 0;let s=Math.round(n?.length??0>0?n.reduce((a,l)=>a+l)/n.length:0),o=String(r-s);return wE[o]??0}getDifficultyThresholds(t){let n=t.length*20,r={trivial:Math.floor(n*.5),low:Math.floor(n*.75),moderate:n,severe:Math.floor(n*1.5),extreme:Math.floor(n*2)};return Object.entries(r).map(([s,o])=>({displayName:s.charAt(0).toUpperCase()+s.slice(1),minValue:o})).sort((s,o)=>s.minValue-o.minValue)}getEncounterDifficulty(t,n){let r=[...t].reduce((c,[u,f])=>c+this.getCreatureDifficulty(u,n)*f,0),s=this.getDifficultyThresholds(n),o=s.findLast(c=>r>=c.minValue)?.displayName??"Trivial",a=s.map(c=>`${c.displayName}: ${c.minValue}`).join(` `),l=`Encounter is ${o} Total XP: ${r} Threshold ${a}`;return{displayName:o,summary:l,cssClass:kE[o.toLowerCase()]??"trivial",value:r,title:"Total XP",intermediateValues:[{label:"Total XP",value:r}]}}};var Rl=(s=>(s.Dnd5e="dnd5e",s.Dnd5eLazyGm="dnd5e-lazygm",s.Dnd5eCR2Simple="dnd5e-cr2-simple",s.Dnd5eFleeMortals="dnd5e-flee-mortals",s.Pathfinder2e="pathfinder2e",s))(Rl||{}),Xp=class extends ln{constructor(){super(...arguments);J(this,"systemDifficulties",[We,We])}};function ki(i,e){switch(e||i.data.rpgSystem){case"dnd5e":return new va(i);case"dnd5e-lazygm":return new Uu(i);case"dnd5e-cr2-simple":return new Yu(i);case"dnd5e-flee-mortals":return new Ku(i);case"pathfinder2e":return new Ju(i)}return new Xp}function hi(i){if(typeof i=="number")return i;if(typeof i!="string")return null;if(!i||i=="undefined"||!i.length)return 0;let e=i.split("/");return e.length==1?isNaN(Number(i))?0:Number(i):Number(e[0])/Number(e[1])}function fs(i){if(typeof i=="string"&&(i=hi(i)),i==0)return"0";let e=i%1,t=Math.floor(i);if(e==0)return t.toString();let n=t==0?"":t.toString();return e in Rp?n+=Rp[e]:n+=e.toString().slice(1),n}function cn(i,e,t){let n=t(e);return n||t(i.getCreatureFromBestiary(e.name))}var be=require("obsidian");var nf=Dp(Gp()),Ml=class extends nf.FuzzyInputSuggest{renderNote(e,t){e.setText([t.item.source].flat().join(", "))}renderTitle(e,t){this.renderMatches(e,t.item.name,t.match.matches)}getItemText(e){return e.name}},ef=class extends nf.FuzzyInputSuggest{renderNote(e,t){}renderTitle(e,t){this.renderMatches(e,t.item,t.match.matches)}getItemText(e){return e}},tf=class extends nf.FuzzyInputSuggest{renderNote(e,t){}renderTitle(e,t){this.renderMatches(e,t.item.name,t.match.matches)}getItemText(e){return e.name}};var _f=Dp(Gp());var Eo=require("obsidian");function xt(){return"ID_xyxyxyxyxyxy".replace(/[xy]/g,function(i){var e=Math.random()*16|0,t=i=="x"?e:e&3|8;return t.toString(16)})}var je=class i{constructor(e,t=0){this.creature=e;J(this,"active");J(this,"name");J(this,"modifier");J(this,"hp");J(this,"hit_dice");J(this,"rollHP");J(this,"temp");J(this,"ac");J(this,"current_ac");J(this,"dirty_ac");J(this,"note");J(this,"enabled",!0);J(this,"hidden",!1);J(this,"max");J(this,"current_max");J(this,"level");J(this,"player");J(this,"status",new Set);J(this,"marker");J(this,"initiative");J(this,"manualOrder");J(this,"static",!1);J(this,"source");J(this,"id");J(this,"xp");J(this,"viewing",!1);J(this,"number",0);J(this,"display");J(this,"friendly",!1);J(this,"statblock-link");J(this,"cr");J(this,"path");this.name=e.name,this.display=e.display,this.initiative="initiative"in e?e.initiative:Number(t??0),this.static=e.static??!1,this.setModifier(e.modifier),this.current_ac=this.ac=e.ac??void 0,this.dirty_ac=!1,this.max=this.current_max=e.hp?Number(e.hp):0,this.note=e.note,this.level=e.level,this.player=e.player,this.rollHP=e.rollHP,this.marker=e.marker,this.hp=this.max,this.temp=0,this.source=e.source,this.friendly=e.friendly??this.friendly,this.active=e.active,this.hidden=e.hidden??!1,this.note=e.note,this.path=e.path,this.xp=e.xp,this.cr=e.cr,this.id=e.id??xt(),"statblock-link"in e&&(this["statblock-link"]=e["statblock-link"]),"hit_dice"in e&&typeof e.hit_dice=="string"&&(this.hit_dice=e.hit_dice)}setModifier(e){e&&(Array.isArray(e)&&(this.modifier=[...e]),isNaN(Number(e))||(this.modifier=Number(e))),this.modifier=this.modifier??0}addCondition(e){[...this.status].find(t=>t.name===e.name&&t.amount===e.amount)||this.status.add(e)}removeCondition(e){this.status=new Set([...this.status].filter(t=>t.id!=e.id))}get hpDisplay(){return this.current_max?` 0?`aria-label="Temp HP: ${this.temp}" style="font-weight:bold"`:""}>${this.hp+this.temp}/${this.current_max} `:We}getName(){let e=[this.display??this.name];return this.number>0&&e.push(`${this.number}`),e.join(" ")}getStatblockLink(){if("statblock-link"in this){let e=this["statblock-link"];return e.startsWith("#")?`[${this.name}](${this.note}${e})`:e}}*[Symbol.iterator](){yield this.name,yield this.initiative,yield this.static,yield this.modifier,yield this.max,yield this.ac,yield this.note,yield this.path,yield this.id,yield this.marker,yield this.xp,yield this.hidden,yield this.hit_dice,yield this.current_ac,yield this.rollHP}static new(e){return new i({...e,id:xt()},e.initiative)}static from(e){let t="modifier"in e?e.modifier:Math.floor((("stats"in e&&e.stats.length>1?e.stats[1]:10)-10)/2);return new i({...e,modifier:t})}update(e){this.name=e.name,this.setModifier(e.modifier),this.current_max=this.max=e.hp?Number(e.hp):0,this.hp>this.max&&(this.hp=this.max),this.current_ac=this.ac=e.ac??void 0,this.note=e.note,this.level=e.level,this.player=e.player,this["statblock-link"]=e["statblock-link"],this.marker=e.marker,this.source=e.source}toProperties(){return{...this}}toJSON(){return{name:this.name,display:this.display,initiative:this.initiative,static:this.static,modifier:this.modifier,hp:this.max,currentMaxHP:this.current_max,cr:this.cr,ac:this.ac,currentAC:this.current_ac,note:this.note,path:this.path,id:this.id,marker:this.marker,currentHP:this.hp,tempHP:this.temp,status:Array.from(this.status).map(e=>e.name),enabled:this.enabled,level:this.level,player:this.player,xp:this.xp,active:this.active,hidden:this.hidden,friendly:this.friendly,"statblock-link":this["statblock-link"],hit_dice:this.hit_dice,rollHP:this.rollHP}}static fromJSON(e,t){let n;e.player?(n=t.getPlayerByName(e.name)??new i(e,e.initiative),n.initiative=e.initiative):n=new i(e,e.initiative),n.enabled=e.enabled,n.temp=e.tempHP?e.tempHP:0,n.current_max=e.currentMaxHP,n.hp=e.currentHP,n.current_ac=e.currentAC;let r=[];for(let s of e.status){let o=ls.find(({name:a})=>s==a);o?r.push(o):r.push({name:s,description:null,id:xt()})}return n.status=new Set(r),n.active=e.active,n}};function X(){}var Nn=i=>i;function ti(i,e){for(let t in e)i[t]=e[t];return i}function Kp(i){return i()}function rf(){return Object.create(null)}function de(i){i.forEach(Kp)}function Ge(i){return typeof i=="function"}function ie(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Ry(i){return Object.keys(i).length===0}function Mi(i,...e){if(i==null){for(let n of e)n(void 0);return X}let t=i.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function ut(i){let e;return Mi(i,t=>e=t)(),e}function Se(i,e,t){i.$$.on_destroy.push(Mi(e,t))}function Gt(i,e,t,n){if(i){let r=My(i,e,t,n);return i[0](r)}}function My(i,e,t,n){return i[1]&&n?ti(t.ctx.slice(),i[1](n(e))):t.ctx}function Kt(i,e,t,n){if(i[2]&&n){let r=i[2](n(t));if(e.dirty===void 0)return r;if(typeof r=="object"){let s=[],o=Math.max(e.dirty.length,r.length);for(let a=0;a32){let e=[],t=i.ctx.length/32;for(let n=0;nwindow.performance.now():()=>Date.now(),Il=Iy?i=>requestAnimationFrame(i):X;var ya=new Set;function Ny(i){ya.forEach(e=>{e.c(i)||(ya.delete(e),e.f())}),ya.size!==0&&Il(Ny)}function Rs(i){let e;return ya.size===0&&Il(Ny),{promise:new Promise(t=>{ya.add(e={c:i,f:t})}),abort(){ya.delete(e)}}}var Nl=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;var sf=class i{constructor(e){J(this,"_listeners","WeakMap"in Nl?new WeakMap:void 0);J(this,"_observer");J(this,"options");this.options=e}observe(e,t){return this._listeners.set(e,t),this._getObserver().observe(e,this.options),()=>{this._listeners.delete(e),this._observer.unobserve(e)}}_getObserver(){return this._observer??(this._observer=new ResizeObserver(e=>{for(let t of e)i.entries.set(t.target,t),this._listeners.get(t.target)?.(t)}))}};sf.entries="WeakMap"in Nl?new WeakMap:void 0;var jy=!1;function Zy(){jy=!0}function zy(){jy=!1}function y(i,e){i.appendChild(e)}function se(i,e,t){let n=of(i);if(!n.getElementById(e)){let r=b("style");r.id=e,r.textContent=t,Ly(n,r)}}function of(i){if(!i)return document;let e=i.getRootNode?i.getRootNode():i.ownerDocument;return e&&e.host?e:i.ownerDocument}function qy(i){let e=b("style");return e.textContent="/* empty */",Ly(of(i),e),e.sheet}function Ly(i,e){return y(i.head||i,e),e.sheet}function A(i,e,t){i.insertBefore(e,t||null)}function T(i){i.parentNode&&i.parentNode.removeChild(i)}function Ie(i,e){for(let t=0;ti.removeEventListener(e,t,n)}function Jp(i){return function(e){return e.preventDefault(),i.call(this,e)}}function Vt(i){return function(e){return e.stopPropagation(),i.call(this,e)}}function $y(i){return function(e){e.target===this&&i.call(this,e)}}function v(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function Ar(i,e){for(let t in e)v(i,t,e[t])}function pi(i){return i===""?null:+i}function Fy(i){return Array.from(i.childNodes)}function me(i,e){e=""+e,i.data!==e&&(i.data=e)}function Xe(i,e){i.value=e??""}function Te(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,n?"important":"")}function ge(i,e,t){i.classList.toggle(e,!!t)}function Zl(i,e,{bubbles:t=!1,cancelable:n=!1}={}){return new CustomEvent(i,{detail:e,bubbles:t,cancelable:n})}var jl=class{constructor(e=!1){J(this,"is_svg",!1);J(this,"e");J(this,"n");J(this,"t");J(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,t,n=null){this.e||(this.is_svg?this.e=sr(t.nodeName):this.e=b(t.nodeType===11?"TEMPLATE":t.nodeName),this.t=t.tagName!=="TEMPLATE"?t:t.content,this.c(e)),this.i(n)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let t=0;t{e[t.slot||"default"]=!0}),e}var af=new Map,lf=0;function jE(i){let e=5381,t=i.length;for(;t--;)e=(e<<5)-e^i.charCodeAt(t);return e>>>0}function ZE(i,e){let t={stylesheet:qy(e),rules:{}};return af.set(i,t),t}function zl(i,e,t,n,r,s,o,a=0){let l=16.666/n,c=`{ `;for(let g=0;g<=1;g+=l){let O=e+(t-e)*s(g);c+=g*100+`%{${o(O,1-O)}} `}let u=c+`100% {${o(t,1-t)}} }`,f=`__svelte_${jE(u)}_${a}`,d=of(i),{stylesheet:h,rules:p}=af.get(d)||ZE(d,i);p[f]||(p[f]=!0,h.insertRule(`@keyframes ${f} ${u}`,h.cssRules.length));let m=i.style.animation||"";return i.style.animation=`${m?`${m}, `:""}${f} ${n}ms linear ${r}ms 1 both`,lf+=1,f}function cf(i,e){let t=(i.style.animation||"").split(", "),n=t.filter(e?s=>s.indexOf(e)<0:s=>s.indexOf("__svelte")===-1),r=t.length-n.length;r&&(i.style.animation=n.join(", "),lf-=r,lf||zE())}function zE(){Il(()=>{lf||(af.forEach(i=>{let{ownerNode:e}=i.stylesheet;e&&T(e)}),af.clear())})}function Dr(i,e,t,n){if(!e)return X;let r=i.getBoundingClientRect();if(e.left===r.left&&e.right===r.right&&e.top===r.top&&e.bottom===r.bottom)return X;let{delay:s=0,duration:o=300,easing:a=Nn,start:l=ds()+s,end:c=l+o,tick:u=X,css:f}=t(i,{from:e,to:r},n),d=!0,h=!1,p;function m(){f&&(p=zl(i,0,1,o,s,a,f)),s||(h=!0)}function g(){f&&cf(i,p),d=!1}return Rs(O=>{if(!h&&O>=l&&(h=!0),h&&O>=c&&(u(1,0),g()),!d)return!1;if(h){let w=O-l,S=0+1*a(w/o);u(S,1-S)}return!0}),m(),u(0,1),g}function Qr(i){let e=getComputedStyle(i);if(e.position!=="absolute"&&e.position!=="fixed"){let{width:t,height:n}=e,r=i.getBoundingClientRect();i.style.position="absolute",i.style.width=t,i.style.height=n,qE(i,r)}}function qE(i,e){let t=i.getBoundingClientRect();if(e.left!==t.left||e.top!==t.top){let n=getComputedStyle(i),r=n.transform==="none"?"":n.transform;i.style.transform=`${r} translate(${e.left-t.left}px, ${e.top-t.top}px)`}}var Ms;function hs(i){Ms=i}function ba(){if(!Ms)throw new Error("Function called outside component initialization");return Ms}function uf(i){ba().$$.on_mount.push(i)}function ff(i){ba().$$.on_destroy.push(i)}function Fe(){let i=ba();return(e,t,{cancelable:n=!1}={})=>{let r=i.$$.callbacks[e];if(r){let s=Zl(e,t,{cancelable:n});return r.slice().forEach(o=>{o.call(i,s)}),!s.defaultPrevented}return!0}}function Vi(i,e){return ba().$$.context.set(i,e),e}function Ue(i){return ba().$$.context.get(i)}function ht(i,e){let t=i.$$.callbacks[e.type];t&&t.slice().forEach(n=>n.call(this,e))}var xo=[];var mi=[],wa=[],tm=[],Vy=Promise.resolve(),im=!1;function nm(){im||(im=!0,Vy.then(hf))}function df(){return nm(),Vy}function _n(i){wa.push(i)}function Rr(i){tm.push(i)}var em=new Set,_a=0;function hf(){if(_a!==0)return;let i=Ms;do{try{for(;_ai.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),wa=e}var ql;function $E(){return ql||(ql=Promise.resolve(),ql.then(()=>{ql=null})),ql}function rm(i,e,t){i.dispatchEvent(Zl(`${e?"intro":"outro"}${t}`))}var pf=new Set,ps;function Ae(){ps={r:0,c:[],p:ps}}function De(){ps.r||de(ps.c),ps=ps.p}function $(i,e){i&&i.i&&(pf.delete(i),i.i(e))}function V(i,e,t,n){if(i&&i.o){if(pf.has(i))return;pf.add(i),ps.c.push(()=>{pf.delete(i),n&&(t&&i.d(1),n())}),i.o(e)}else n&&n()}var FE={duration:0};function Po(i,e,t,n){let s=e(i,t,{direction:"both"}),o=n?0:1,a=null,l=null,c=null,u;function f(){c&&cf(i,c)}function d(p,m){let g=p.b-o;return m*=Math.abs(g),{a:o,b:p.b,d:g,duration:m,start:p.start,end:p.start+m,group:p.group}}function h(p){let{delay:m=0,duration:g=300,easing:O=Nn,tick:w=X,css:S}=s||FE,C={start:ds()+m,b:p};p||(C.group=ps,ps.r+=1),"inert"in i&&(p?u!==void 0&&(i.inert=u):(u=i.inert,i.inert=!0)),a||l?l=C:(S&&(f(),c=zl(i,o,p,g,m,O,S)),p&&w(0,1),a=d(C,g),_n(()=>rm(i,p,"start")),Rs(k=>{if(l&&k>l.start&&(a=d(l,g),l=null,rm(i,a.b,"start"),S&&(f(),c=zl(i,o,a.b,a.duration,0,O,s.css))),a){if(k>=a.end)w(o=a.b,1-o),rm(i,a.b,"end"),l||(a.b?f():--a.group.r||de(a.group.c)),a=null;else if(k>=a.start){let _=k-a.start;o=a.a+a.d*O(_/a.duration),w(o,1-o)}}return!!(a||l)}))}return{run(p){Ge(s)?$E().then(()=>{s=s({direction:p?"in":"out"}),h(p)}):h(p)},end(){f(),a=l=null}}}function fe(i){return i?.length!==void 0?i:Array.from(i)}function ms(i,e){i.d(1),e.delete(i.key)}function BE(i,e){V(i,1,1,()=>{e.delete(i.key)})}function mf(i,e){i.f(),ms(i,e)}function ka(i,e){i.f(),BE(i,e)}function yi(i,e,t,n,r,s,o,a,l,c,u,f){let d=i.length,h=s.length,p=d,m={};for(;p--;)m[i[p].key]=p;let g=[],O=new Map,w=new Map,S=[];for(p=h;p--;){let P=f(r,s,p),x=t(P),R=o.get(x);R?n&&S.push(()=>R.p(P,e)):(R=c(x,P),R.c()),O.set(x,g[p]=R),x in m&&w.set(x,Math.abs(p-m[x]))}let C=new Set,k=new Set;function _(P){$(P,1),P.m(a,u),o.set(P.key,P),u=P.first,h--}for(;d&&h;){let P=g[h-1],x=i[d-1],R=P.key,Z=x.key;P===x?(u=P.first,d--,h--):O.has(Z)?!o.has(R)||C.has(R)?_(P):k.has(Z)?d--:w.get(R)>w.get(Z)?(k.add(R),_(P)):(C.add(Z),d--):(l(x,o),d--)}for(;d--;){let P=i[d];O.has(P.key)||l(P,o)}for(;h;)_(g[h-1]);return de(S),g}function Mr(i,e){let t={},n={},r={$$scope:1},s=i.length;for(;s--;){let o=i[s],a=e[s];if(a){for(let l in o)l in a||(n[l]=1);for(let l in a)r[l]||(t[l]=a[l],r[l]=1);i[s]=a}else for(let l in o)r[l]=1}for(let o in n)o in t||(t[o]=void 0);return t}function sm(i){return typeof i=="object"&&i!==null?i:{}}var VE=["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],WE=new Set([...VE]);function Ir(i,e,t){let n=i.$$.props[e];n!==void 0&&(i.$$.bound[n]=t,t(i.$$.ctx[n]))}function ye(i){i&&i.c()}function Oe(i,e,t){let{fragment:n,after_update:r}=i.$$;n&&n.m(e,t),_n(()=>{let s=i.$$.on_mount.map(Kp).filter(Ge);i.$$.on_destroy?i.$$.on_destroy.push(...s):de(s),i.$$.on_mount=[]}),r.forEach(_n)}function ve(i,e){let t=i.$$;t.fragment!==null&&(Wy(t.after_update),de(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function UE(i,e){i.$$.dirty[0]===-1&&(xo.push(i),nm(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<{let p=h.length?h[0]:d;return c.ctx&&r(c.ctx[f],c.ctx[f]=p)&&(!c.skip_bound&&c.bound[f]&&c.bound[f](p),u&&UE(i,f)),d}):[],c.update(),u=!0,de(c.before_update),c.fragment=n?n(c.ctx):!1,e.target){if(e.hydrate){Zy();let f=Fy(e.target);c.fragment&&c.fragment.l(f),f.forEach(T)}else c.fragment&&c.fragment.c();e.intro&&$(i.$$.fragment),Oe(i,e.target,e.anchor),zy(),hf()}hs(l)}var YE;typeof HTMLElement=="function"&&(YE=class extends HTMLElement{constructor(e,t,n){super();J(this,"$$ctor");J(this,"$$s");J(this,"$$c");J(this,"$$cn",!1);J(this,"$$d",{});J(this,"$$r",!1);J(this,"$$p_d",{});J(this,"$$l",{});J(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,n&&this.attachShadow({mode:"open"})}addEventListener(e,t,n){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){let r=this.$$c.$on(e,t);this.$$l_u.set(t,r)}super.addEventListener(e,t,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),this.$$c){let r=this.$$l_u.get(t);r&&(r(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(s){return()=>{let o;return{c:function(){o=b("slot"),s!=="default"&&v(o,"name",s)},m:function(c,u){A(c,o,u)},d:function(c){c&&T(o)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;let t={},n=By(this);for(let s of this.$$s)s in n&&(t[s]=[e(s)]);for(let s of this.attributes){let o=this.$$g_p(s.name);o in this.$$d||(this.$$d[o]=om(o,s.value,this.$$p_d,"toProp"))}for(let s in this.$$p_d)!(s in this.$$d)&&this[s]!==void 0&&(this.$$d[s]=this[s],delete this[s]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});let r=()=>{this.$$r=!0;for(let s in this.$$p_d)if(this.$$d[s]=this.$$c.$$.ctx[this.$$c.$$.props[s]],this.$$p_d[s].reflect){let o=om(s,this.$$d[s],this.$$p_d,"toAttribute");o==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,o)}this.$$r=!1};this.$$c.$$.after_update.push(r),r();for(let s in this.$$l)for(let o of this.$$l[s]){let a=this.$$c.$on(s,o);this.$$l_u.set(o,a)}this.$$l={}}}attributeChangedCallback(e,t,n){this.$$r||(e=this.$$g_p(e),this.$$d[e]=om(e,n,this.$$p_d,"toProp"),this.$$c?.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function om(i,e,t,n){let r=t[i]?.type;if(e=r==="Boolean"&&typeof e!="boolean"?e!=null:e,!n||!t[i])return e;if(n==="toAttribute")switch(r){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(r){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}var ne=class{constructor(){J(this,"$$");J(this,"$$set")}$destroy(){ve(this,1),this.$destroy=X}$on(e,t){if(!Ge(t))return X;let n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}$set(e){this.$$set&&!Ry(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var Xy="4";var Sa=[];function HE(i,e){return{subscribe:$e(i,e).subscribe}}function $e(i,e=X){let t,n=new Set;function r(a){if(ie(i,a)&&(i=a,t)){let l=!Sa.length;for(let c of n)c[1](),Sa.push(c,i);if(l){for(let c=0;c{n.delete(c),n.size===0&&t&&(t(),t=null)}}return{set:r,update:s,subscribe:o}}function oi(i,e,t){let n=!Array.isArray(i),r=n?[i]:i;if(!r.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");let s=e.length<2;return HE(t,(o,a)=>{let l=!1,c=[],u=0,f=X,d=()=>{if(u)return;f();let p=e(n?c[0]:c,o,a);s?o(p):f=Ge(p)?p:X},h=r.map((p,m)=>Mi(p,g=>{c[m]=g,u&=~(1<{u|=1<{(0,gf.setIcon)(m,cs)},d=m=>{(0,gf.setIcon)(m,tr)},h=m=>{(0,gf.setIcon)(m,er)},p=m=>s.openCombatant(a,m.ctrlKey||m.metaKey);return i.$$set=m=>{"creature"in m&&t(0,a=m.creature),"count"in m&&t(1,l=m.count),"xp"in m&&t(2,c=m.xp),"shouldShowRoll"in m&&t(3,u=m.shouldShowRoll),"$$scope"in m&&t(9,r=m.$$scope)},[a,l,c,u,s,o,f,d,h,r,n,p]}var am=class extends ne{constructor(e){super(),re(this,e,tT,eT,ie,{creature:0,count:1,xp:2,shouldShowRoll:3},GE)}},Of=am;function iT(i){se(i,"svelte-s37km9",".encounter-name.svelte-s37km9.svelte-s37km9{display:flex;justify-content:flex-start;align-items:center}.encounter-name.svelte-s37km9 .initiative-tracker-name.svelte-s37km9{margin:0}.encounter-instance.svelte-s37km9>.creatures-container>.encounter-creatures:first-of-type h4.svelte-s37km9,.encounter-creatures.svelte-s37km9>ul.svelte-s37km9{margin-top:0}.creature-li.svelte-s37km9.svelte-s37km9{width:fit-content}.xp-parent.svelte-s37km9.svelte-s37km9{display:inline-flex}.difficulty.svelte-s37km9.svelte-s37km9{width:fit-content}.deadly.svelte-s37km9 .difficulty-label.svelte-s37km9{color:red}.hard.svelte-s37km9 .difficulty-label.svelte-s37km9{color:orange}.medium.svelte-s37km9 .difficulty-label.svelte-s37km9{color:yellow}.easy.svelte-s37km9 .difficulty-label.svelte-s37km9{color:green}.trivial.svelte-s37km9 .difficulty-label.svelte-s37km9{color:#aaaaaa}.icons.svelte-s37km9.svelte-s37km9{display:flex}.icons.svelte-s37km9>div.svelte-s37km9:first-child .clickable-icon{margin-right:0}.creature-name.svelte-s37km9.svelte-s37km9{display:inline-flex;align-items:center;gap:0.25rem}.has-icon.svelte-s37km9.svelte-s37km9{display:flex;align-items:center}")}function Ky(i,e,t){let n=i.slice();return n[21]=e[t][0],n[22]=e[t][1],n}function Jy(i,e,t){let n=i.slice();return n[25]=e[t],n}function eb(i){let e;function t(s,o){if(s[3]instanceof Array&&s[3].length)return rT;if(!s[3])return nT}let n=t(i,-1),r=n&&n(i);return{c(){r&&r.c(),e=tt()},m(s,o){r&&r.m(s,o),A(s,e,o)},p(s,o){n===(n=t(s,o))&&r?r.p(s,o):(r&&r.d(1),r=n&&n(s),r&&(r.c(),r.m(e.parentNode,e)))},d(s){s&&T(e),r&&r.d(s)}}}function nT(i){let e;return{c(){e=b("div"),e.innerHTML='

No Players

',v(e,"class","encounter-creatures encounter-players")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function rT(i){let e,t,n=(i[4]?i[4]:"Players")+"",r,s,o,a=fe(i[3]),l=[];for(let c=0;c{u[p]=null}),De(),s=u[r],s?s.p(d,h):(s=u[r]=c[r](d),s.c()),$(s,1),s.m(o.parentNode,o))},i(d){a||($(s),a=!0)},o(d){V(s),a=!1},d(d){d&&(T(e),T(n),T(o)),l&&l.d(),u[r].d(d)}}}function nb(i){let e,t,n,r;return{c(){e=b("span"),v(e,"class","has-icon svelte-s37km9"),v(e,"aria-label","Rolling for HP")},m(s,o){A(s,e,o),n||(r=H(t=i[17].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function sT(i){let e;return{c(){e=b("strong"),e.textContent="No creatures"},m(t,n){A(t,e,n)},p:X,i:X,o:X,d(t){t&&T(e)}}}function oT(i){let e,t,n=fe([...i[2]]),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){e=b("ul");for(let o=0;o0&&ab(i);return{c(){e=b("span"),t=b("strong"),r=ae(n),s=M(),o=b("span"),a=b("span"),a.textContent="(",l=M(),c=b("span"),p&&p.c(),u=M(),f=b("span"),f.textContent=")",v(t,"class","difficulty-label svelte-s37km9"),v(a,"class","paren left"),v(c,"class","xp-container"),v(f,"class","paren right"),v(o,"class","xp-parent difficulty svelte-s37km9"),v(e,"aria-label",d=i[9].summary),v(e,"class",h=un(i[9].cssClass)+" svelte-s37km9")},m(m,g){A(m,e,g),y(e,t),y(t,r),y(e,s),y(e,o),y(o,a),y(o,l),y(o,c),p&&p.m(c,null),y(o,u),y(o,f)},p(m,g){g&512&&n!==(n=m[9].displayName+"")&&me(r,n),m[9].value>0?p?p.p(m,g):(p=ab(m),p.c(),p.m(c,null)):p&&(p.d(1),p=null),g&512&&d!==(d=m[9].summary)&&v(e,"aria-label",d),g&512&&h!==(h=un(m[9].cssClass)+" svelte-s37km9")&&v(e,"class",h)},d(m){m&&T(e),p&&p.d()}}}function ab(i){let e,t=i[10].formatDifficultyValue(i[9].value)+"",n,r,s;return{c(){e=b("span"),n=ae(t),r=M(),s=b("span"),s.textContent=`${i[10].valueUnit}`,v(e,"class","xp number"),v(s,"class","xp text")},m(o,a){A(o,e,a),y(e,n),A(o,r,a),A(o,s,a)},p(o,a){a&512&&t!==(t=o[10].formatDifficultyValue(o[9].value)+"")&&me(n,t)},d(o){o&&(T(e),T(r),T(s))}}}function lT(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p=!i[5].includes("players"),m,g,O=!i[5].includes("creatures"),w,S,C,k,_=p&&eb(i),P=O&&ib(i),x=i[0].data.displayDifficulty&&sb(i);return{c(){e=b("div"),t=b("div"),n=b("h3"),r=ae(i[1]),s=M(),o=b("div"),a=b("div"),c=M(),u=b("div"),d=M(),h=b("div"),_&&_.c(),m=M(),g=b("div"),P&&P.c(),w=M(),x&&x.c(),v(n,"data-heading",i[1]),v(n,"class","initiative-tracker-name svelte-s37km9"),v(a,"aria-label","Start Encounter"),v(a,"class","svelte-s37km9"),v(u,"aria-label","Add to Encounter"),v(u,"class","svelte-s37km9"),v(o,"class","icons svelte-s37km9"),v(t,"class","encounter-name svelte-s37km9"),v(g,"class","encounter-creatures svelte-s37km9"),v(h,"class","creatures-container"),v(e,"class","encounter-instance svelte-s37km9")},m(R,Z){A(R,e,Z),y(e,t),y(t,n),y(n,r),y(t,s),y(t,o),y(o,a),y(o,c),y(o,u),y(e,d),y(e,h),_&&_.m(h,null),y(h,m),y(h,g),P&&P.m(g,null),y(h,w),x&&x.m(h,null),S=!0,C||(k=[H(l=i[11].call(null,a)),U(a,"click",i[12]),H(f=i[13].call(null,u)),U(u,"click",i[14])],C=!0)},p(R,[Z]){(!S||Z&2)&&me(r,R[1]),(!S||Z&2)&&v(n,"data-heading",R[1]),Z&32&&(p=!R[5].includes("players")),p?_?_.p(R,Z):(_=eb(R),_.c(),_.m(h,m)):_&&(_.d(1),_=null),Z&32&&(O=!R[5].includes("creatures")),O?P?(P.p(R,Z),Z&32&&$(P,1)):(P=ib(R),P.c(),$(P,1),P.m(g,null)):P&&(Ae(),V(P,1,1,()=>{P=null}),De()),R[0].data.displayDifficulty?x?x.p(R,Z):(x=sb(R),x.c(),x.m(h,null)):x&&(x.d(1),x=null)},i(R){S||($(P),S=!0)},o(R){V(P),S=!1},d(R){R&&T(e),_&&_.d(),P&&P.d(),x&&x.d(),C=!1,de(k)}}}function cT(i,e,t){let n,r,s;Se(i,he,x=>t(19,s=x));let{plugin:o}=e;Vi("plugin",o);let{name:a="Encounter"}=e,{creatures:l=new Map}=e,{players:c}=e,{party:u=null}=e,{hide:f=[]}=e,{rollHP:d=o.data.rollHP}=e,{playerLevels:h}=e,p=new Map,m=new Map,g=ki(o);for(let[x,R]of l){let Z=Number(R);if(o.canUseDiceRoller){let Q=o.getRoller(`${R}`);Q?(Q.on("new-result",()=>{p.set(x,Q.result),t(18,p)}),m.set(x,Q),Q.rollSync()):p.set(x,Z)}else p.set(x,Z)}let O=x=>{new Ll.ExtraButtonComponent(x).setIcon(us)},w=async()=>{o.view||await o.addTrackerView();let x=o.view,R=[...p].map(([E,j])=>isNaN(Number(j))||j<1?[E]:[...Array(j).keys()].map(z=>je.new(E))).flat(),Z=[],Q=[...u?o.getPlayerNamesForParty(u):[],...c],D=[];for(let E of new Set(Q))D.push(o.getPlayerByName(E));for(let E of[...D,...R])Z.push(E.toJSON());he.new(o,{creatures:Z,name:a,round:1,state:!1,logFile:null,roll:!0,rollHP:d,newLog:!0}),o.app.workspace.revealLeaf(x.leaf)},S=x=>{new Ll.ExtraButtonComponent(x).setIcon("plus-with-circle")},C=async x=>{o.view||await o.addTrackerView();let R=[...p].map(([Z,Q])=>isNaN(Number(Q))||Q<1?[Z]:[...Array(Q).keys()].map(D=>je.new(Z))).flat();for(let Z of c)s.find(Q=>Q.name===Z)||R.push(o.getPlayerByName(Z));he.add(o,d,...R)},k=(x,R)=>{o.canUseDiceRoller&&m.has(R)&&!m.get(R).isStatic?x.appendChild(m.get(R)?.containerEl??createSpan({text:`${p.get(R)}`})):x.setText(`${p.get(R)}`)},_=x=>{if(!x)return;let R=[];return x.hp&&R.push(`HP: ${x.hp}`),x.ac&&R.push(`AC: ${x.ac}`),x.modifier&&R.push(`MOD: ${x.modifier}`),`${R.join(", ")}`},P=x=>{(0,Ll.setIcon)(x,cs)};return i.$$set=x=>{"plugin"in x&&t(0,o=x.plugin),"name"in x&&t(1,a=x.name),"creatures"in x&&t(2,l=x.creatures),"players"in x&&t(3,c=x.players),"party"in x&&t(4,u=x.party),"hide"in x&&t(5,f=x.hide),"rollHP"in x&&t(6,d=x.rollHP),"playerLevels"in x&&t(7,h=x.playerLevels)},i.$$.update=()=>{i.$$.dirty&262272&&t(9,n=g.getEncounterDifficulty(p,h)),i.$$.dirty&68&&t(8,r=d&&[...l.keys()].filter(x=>x.hit_dice?.length).length==l.size)},[o,a,l,c,u,f,d,h,r,n,g,O,w,S,C,k,_,P,p]}var lm=class extends ne{constructor(e){super(),re(this,e,cT,lT,ie,{plugin:0,name:1,creatures:2,players:3,party:4,hide:5,rollHP:6,playerLevels:7},iT)}},lb=lm;var $l=require("obsidian");function uT(i){se(i,"svelte-1hp1xp6",".deadly.svelte-1hp1xp6 .difficulty-label.svelte-1hp1xp6{color:red}.hard.svelte-1hp1xp6 .difficulty-label.svelte-1hp1xp6{color:orange}.medium.svelte-1hp1xp6 .difficulty-label.svelte-1hp1xp6{color:yellow}.easy.svelte-1hp1xp6 .difficulty-label.svelte-1hp1xp6{color:green}.trivial.svelte-1hp1xp6 .difficulty-label.svelte-1hp1xp6{color:#aaaaaa}.icons.svelte-1hp1xp6.svelte-1hp1xp6{display:flex}.icons.svelte-1hp1xp6>div.svelte-1hp1xp6:first-child .clickable-icon{margin-right:0}ul.svelte-1hp1xp6.svelte-1hp1xp6{margin:0}")}function cb(i,e,t){let n=i.slice();return n[19]=e[t],n}function ub(i,e,t){let n=i.slice();return n[22]=e[t][0],n[23]=e[t][1],n}function fb(i){let e,t,n,r,s,o,a=[dT,fT],l=[];function c(u,f){return f&10&&(n=null),n==null&&(n=!!(!u[3].includes("creatures")&&u[1].size)),n?0:1}return r=c(i,-1),s=l[r]=a[r](i),{c(){e=b("td"),t=b("ul"),s.c(),v(t,"class","encounter-creatures encounter-list svelte-1hp1xp6")},m(u,f){A(u,e,f),y(e,t),l[r].m(t,null),o=!0},p(u,f){let d=r;r=c(u,f),r===d?l[r].p(u,f):(Ae(),V(l[d],1,1,()=>{l[d]=null}),De(),s=l[r],s?s.p(u,f):(s=l[r]=a[r](u),s.c()),$(s,1),s.m(t,null))},i(u){o||($(s),o=!0)},o(u){V(s),o=!1},d(u){u&&T(e),l[r].d()}}}function fT(i){let e;return{c(){e=ae("-")},m(t,n){A(t,e,n)},p:X,i:X,o:X,d(t){t&&T(e)}}}function dT(i){let e,t,n=fe([...i[1]]),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o{C=null}),De()),x&64&&(a=P[6].includes("players")),a?k?k.p(P,x):(k=hb(P),k.c(),k.m(e,l)):k&&(k.d(1),k=null),P[5].data.displayDifficulty?_?_.p(P,x):(_=mb(P),_.c(),_.m(e,c)):_&&(_.d(1),_=null)},i(P){O||($(C),O=!0)},o(P){V(C),O=!1},d(P){P&&T(e),C&&C.d(),k&&k.d(),_&&_.d(),w=!1,de(S)}}}function yT(i,e,t){let n,{name:r="Encounter"}=e,{creatures:s}=e,{players:o}=e,{hide:a=[]}=e,{playerLevels:l}=e,{plugin:c}=e;Vi("plugin",c);let{headers:u}=e,{rollHP:f=c.data.rollHP}=e,d=new Map,h=new Map,p=ki(c);for(let[_,P]of s){let x=Number(P);if(c.canUseDiceRoller){let R=c.getRoller(`${P}`);R?(R.on("new-result",()=>{d.set(_,R.result),t(15,d)}),h.set(_,R),R.rollSync()):d.set(_,x)}else d.set(_,x)}let m=_=>{new $l.ExtraButtonComponent(_).setIcon(us).setTooltip("Begin Encounter").onClick(async()=>{c.view||await c.addTrackerView();let P=c.view,x=[...d].map(([Z,Q])=>isNaN(Number(Q))||Q<1?[Z.toJSON()]:[...Array(Q).keys()].map(D=>je.new(Z).toJSON())).flat(),R=o.map(Z=>c.getPlayerByName(Z).toJSON());he.new(c,{creatures:[...R,...x],name:r,round:1,state:!1,logFile:null,newLog:!0,roll:!0,rollHP:f}),c.app.workspace.revealLeaf(P.leaf)})},g=_=>{new $l.ExtraButtonComponent(_).setIcon("plus-with-circle")},O=async _=>{c.view||await c.addTrackerView();let P=c.view,x=[...d].map(([R,Z])=>isNaN(Number(Z))||Z<1?[R]:[...Array(Z).keys()].map(Q=>je.new(R))).flat();he.add(c,f,...x)},w=(_,P)=>{c.canUseDiceRoller&&h.has(P)&&!h.get(P).isStatic?_.appendChild(h.get(P)?.containerEl??createSpan({text:`${d.get(P)}`})):_.setText(`${d.get(P)}`)},S=(_,P)=>{if(P==1||_==0)return"";let x=P>2?",":"";return _==P-1?`${x} and `:`${x} `},C=_=>{if(!_)return;let P=[];return _.hp&&P.push(`HP: ${_.hp}`),_.ac&&P.push(`AC: ${_.ac}`),_.modifier&&P.push(`MOD: ${_.modifier}`),`${P.join(", ")}`},k=_=>{(0,$l.setIcon)(_,cs)};return i.$$set=_=>{"name"in _&&t(0,r=_.name),"creatures"in _&&t(1,s=_.creatures),"players"in _&&t(2,o=_.players),"hide"in _&&t(3,a=_.hide),"playerLevels"in _&&t(4,l=_.playerLevels),"plugin"in _&&t(5,c=_.plugin),"headers"in _&&t(6,u=_.headers),"rollHP"in _&&t(7,f=_.rollHP)},i.$$.update=()=>{i.$$.dirty&32784&&t(8,n=p.getEncounterDifficulty(d,l))},[r,s,o,a,l,c,u,f,n,p,m,g,O,w,C,d]}var cm=class extends ne{constructor(e){super(),re(this,e,yT,vT,ie,{name:0,creatures:1,players:2,hide:3,playerLevels:4,plugin:5,headers:6,rollHP:7},uT)}},gb=cm;function Ob(i,e,t){let n=i.slice();return n[3]=e[t],n}function bT(i){let e;return{c(){e=b("th"),e.textContent="Creatures"},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function _T(i){let e;return{c(){e=b("th"),e.textContent="Players"},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function vb(i){let e;return{c(){e=b("th"),e.textContent="Difficulty"},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function yb(i){let e,t,n=[i[3],{headers:i[2]},{plugin:i[1]}],r={};for(let s=0;sV(S[k],1,1,()=>{S[k]=null});return{c(){e=b("table"),t=b("thead"),n=b("tr"),r=b("th"),r.textContent="Name",s=M(),m&&m.c(),a=M(),g&&g.c(),c=M(),O&&O.c(),u=M(),f=b("th"),f.textContent="Launch",d=M(),h=b("tbody");for(let k=0;k!o.hide.includes("players")&&(typeof o.players=="boolean"&&o.players||o.players instanceof Array&&o.players.length))&&s.push("players"),n.some(o=>!o.hide.includes("creatures")&&o.creatures.size)&&s.push("creatures"),i.$$set=o=>{"encounters"in o&&t(0,n=o.encounters),"plugin"in o&&t(1,r=o.plugin)},[n,r,s]}var um=class extends ne{constructor(e){super(),re(this,e,kT,wT,ie,{encounters:0,plugin:1})}},bb=um;var Ns=(i,e)=>i.name==e.name&&i.display==e.display&&i.ac==e.ac&&ST(i.modifier,e.modifier)&&i.xp==e.xp&&i.hidden==e.hidden&&i.friendly==e.friendly&&i.static==e.static;function ST(i,e){if(typeof i!=typeof e)return!1;if(typeof i=="number")return i==e;if(Array.isArray(i)&&Array.isArray(e)){for(let t=0;tthis.plugin.getPlayerByName(f)).map(f=>f.level).filter(f=>f&&!isNaN(Number(f)));return{name:t,players:n,party:r,hide:s,creatures:l,xp:c,playerLevels:u,rollHP:a}}parseHide(e){return"hide"in(e??{})?typeof e.hide=="string"?["creatures","players"].filter(t=>e.hide==t):Array.isArray(e.hide)?["creatures","players"].filter(t=>e.hide.includes(t)):[]:[]}parsePlayers(e){let t=[],n=e.players;if(e.party&&this.plugin.data.parties.find(r=>r.name.toLowerCase()==e.party.toLowerCase())){let r=this.plugin.data.parties.find(s=>s.name.toLowerCase()==e.party.toLowerCase());t.push(...r.players)}if(n=="none"||n==!1?t.splice(0,t.length):n==!0?t.push(...[...this.plugin.players.values()].map(r=>r.name)):typeof n=="string"?t.push(n):Array.isArray(n)&&t.push(...[...this.plugin.players.values()??[]].map(r=>r.name).filter(r=>n.map(s=>s.toLowerCase()).includes(r.toLowerCase()))),!t.length){let r=this.plugin.defaultParty?.name;if(r&&this.plugin.data.parties.find(s=>s.name.toLowerCase()==r.toLowerCase())){let s=this.plugin.data.parties.find(o=>o.name.toLowerCase()==r.toLowerCase());t.push(...s.players)}}return Array.from(new Set(t))}async parseRawCreatures(e,t){let n=new Map;if(e&&Array.isArray(e))for(let r of e){let{creature:s,number:o=1}=this.parseRawCreature(r,t)??{};if(!s)continue;let a={name:s.name,display:s.display,ac:s.ac,hp:s.hp,modifier:s.modifier,xp:s.xp,hidden:s.hidden,friendly:s.friendly,rollHP:s.rollHP},l=[...n].find(([c])=>Ns(c,a));if(!l)n.set(s,o);else{let c;!isNaN(Number(o))&&!isNaN(Number(l[1]))?c=Number(o)+l[1]:c=`${o} + ${l[1]}`,n.set(l[0],c)}}return n}parseRawCreature(e,t){if(!e)return{};let n,r=1;if(typeof e=="string"){let g=e.match(/(\d+)?:?\s?(.+)/)??[];r=isNaN(Number(g[1]??null))?r:Number(g[1]),n=g[2]}else if(Array.isArray(e))n=e;else if(typeof e=="object"){let g=Object.entries(e).flat();r=g[0],n=g[1]}if(!n)return{};typeof r=="string"&&!this.plugin.canUseDiceRoller&&/\d+d\d+/.test(r)&&(r=1),isNaN(Number(r))||(r=Number(r)),r!=0&&!r&&(r=1),typeof r=="number"&&r<1&&(r=0);let s,o,a,l,c,u,f=!1,d=!1,h=t;if(typeof n=="string"?(n.match(/,\s+hidden/)&&(f=!0,n=n.replace(/,\s*hidden/,"")),(n.match(/,\s+friend(?:ly)?/)||n.match(/,\s+ally/))&&(d=!0,n=n.replace(/,\s*friend(?:ly)?/,"").replace(/,\s*ally/,"")),s=n.split(/,\s?/)[0],[a,l,c,u]=n.split(/,\s?/).slice(1).map(g=>isNaN(Number(g))?null:Number(g))):Array.isArray(n)?(typeof n[0]=="string"?(s=n[0],o=n[1]):Array.isArray(n[0])&&(s=n[0][0],o=n[0][1]),f=n.slice(1).find(g=>g=="hidden")!=null,d=n.slice(1).find(g=>g=="friend"||g=="friendly"||g=="ally")!=null,[a,l,c,u]=n.slice(1).filter(g=>g!="hidden"&&g!="friend"&&g!="friendly"&&g!="ally").map(g=>isNaN(Number(g))?null:Number(g))):typeof n=="object"&&({creature:s,name:o,hp:a,ac:l,mod:c,xp:u}=n,f=n.hidden||!1,d=n.friend||n.ally||!1),a&&(h=!1),!s||typeof s!="string")return{};let p=this.plugin.getCreatureFromBestiary(s),m=p?je.from(p):new je({name:s});return m.display=o,m.hp=a??m.hp,m.ac=l??m.ac,m.modifier=c??m.modifier,m.xp=u??m.xp,m.hidden=f??m.hidden,m.friendly=d??m.friendly,m.rollHP=h??t??m.rollHP,{creature:m,number:r}}},fm=class{constructor(e,t,n){this.params=e;this.encounterEl=t;this.plugin=n;J(this,"instance");this.display()}async display(){this.instance=new lb({target:this.encounterEl,props:{plugin:this.plugin,name:this.params.name,party:this.params.party,players:this.params.players,playerLevels:this.params.playerLevels,creatures:this.params.creatures,hide:this.params.hide,rollHP:this.params.rollHP}})}},Co=class extends Is.MarkdownRenderChild{constructor(t,n,r,s=!1){super(r);this.plugin=t;this.src=n;this.containerEl=r;this.table=s;J(this,"parser");this.parser=new Fl(this.plugin),this.init()}init(){this.table?this.postprocessTable():this.postprocess()}async postprocess(){let t=this.src.split("---")??[],n=this.containerEl.createDiv("encounter-container"),r=n.createSpan({text:"No encounters created. Please check your syntax and try again."});for(let s of t)if(s?.trim().length)try{let o=(0,Is.parseYaml)(s);new fm(await this.parser.parse(o),n.createDiv("encounter-instance"),this.plugin),r.detach()}catch(o){console.error(o),new Is.Notice(`Initiative Tracker: here was an issue parsing: `+s)}this.plugin.register(()=>{this.containerEl.empty(),this.containerEl.createEl("pre").createEl("code",{text:`\`\`\`encounter ${this.src}\`\`\``})})}async postprocessTable(){let t=this.src.split("---")??[],r=this.containerEl.createDiv("encounter-container").createSpan({text:"No encounters created. Please check your syntax and try again."}),s=[];for(let o of t)if(o?.trim().length)try{let a=(0,Is.parseYaml)(o);s.push(await this.parser.parse(a))}catch(a){console.error(a),new Is.Notice(`Initiative Tracker: here was an issue parsing: `+o)}s.length&&(r.detach(),new bb({target:this.containerEl,props:{encounters:s,plugin:this.plugin}})),this.plugin.register(()=>{this.containerEl.empty(),this.containerEl.createEl("pre").createEl("code",{text:`\`\`\`encounter-table ${this.src}\`\`\``})})}};var dm=require("obsidian");var PT=dm.Platform.isMacOS?"Meta":"Control";function CT(){let i=$e([]),e=$e(new Map),t=$e(),{subscribe:n,set:r,update:s}=i,o=$e(),a,l=$e(1),c=$e(!1),u=Q=>{c.set(Q),Q?a?.logging?a?.log("Combat re-started"):a?.new({name:ut(f),players:O.filter(D=>D.player),creatures:O.filter(D=>!D.player),round:ut(l)}).then(()=>{o.set(a.getFile())}):a?.log("Combat stopped"),x(D=>(D.length&&!D.find(E=>E.active)&&(O[0].active=!0),D))},f=$e(),d=$e(),h=$e(),p=oi(h,Q=>Q.descending),m,g=oi(i,Q=>(m?.condense&&Q.forEach((D,E,j)=>{let z=j.filter(Y=>Ns(Y,D)),q=z.map(Y=>Y.initiative),G=q[Math.floor(Math.random()*q.length)];z.forEach(Y=>{Y.static||(Y.initiative=G)})}),Q)),O=[],w=oi([g,h],([Q,D])=>{let E=[...Q];return E.sort((j,z)=>{if(j.initiative!=z.initiative)return D.descending?z.initiative-j.initiative:j.initiative-z.initiative;if(j.manualOrder!==null&&j.manualOrder!==void 0&&z.manualOrder!==null&&z.manualOrder!==void 0&&j.manualOrder!==z.manualOrder){let q=j.manualOrder||0,G=z.manualOrder||0;return q-G}switch(m.resolveTies){case Jn.random:return Math.random()<.5?1:-1;case Jn.playerFirst:case Jn.npcFirst:let q=j.player?1:0,G=z.player?1:0;return m.resolveTies==Jn.playerFirst?G-q:q-G}}),O=E,E}),S=Q=>{a?.log(`${Q.getName()} initiative changed to ${Q.initiative}`)},C=(Q,...D)=>{for(let{creature:E,change:j}of D){if(j.initiative&&(E.initiative=Number(j.initiative),S(E)),j.name&&(E.name=j.name,E.number=0),j.hp){if(j.hp=Number(j.hp),j.hp<0&&E.temp>0){let z=E.temp+j.hp;E.temp=Math.max(0,z),j.hp=Math.min(0,z)}if(m.clamp&&E.hp+j.hp<0&&(j.hp=-E.hp),j.hp>0&&j.hp+E.hp>E.current_max)switch(m.hpOverflow){case In.ignore:j.hp=Math.max(E.current_max-E.hp,0);break;case In.temp:j.temp=j.hp-Math.min(E.current_max-E.hp,0),j.hp-=j.temp;break;case In.current:break}if(E.hp+=j.hp,m.autoStatus&&E.hp<=0){let z=m.statuses.find(q=>q.id==m.unconsciousId);z&&E.addCondition(z)}}if(j.max&&(E.current_max=Math.max(0,E.current_max+j.max),E.hp>=E.current_max&&m.hpOverflow!==In.current&&(E.hp=E.current_max)),j.set_hp&&(E.hp=j.set_hp),j.set_max_hp&&(E.current_max=E.max=j.set_max_hp),j.ac&&(E.current_ac=E.ac=j.ac),j.temp){let z=0;m.additiveTemp&&(z=E.temp),j.temp>0?E.temp=Math.max(E.temp,z+j.temp):E.temp=Math.max(0,E.temp+j.temp)}if(j.marker&&(E.marker=j.marker),j.status?.length)for(let z of j.status)E.addCondition(z);if(j.remove_status?.length)for(let z of j.remove_status)E.removeCondition(z);"hidden"in j&&(E.hidden=j.hidden,a.log(`${E.getName()} ${E.hidden?"hidden":"revealed"}`)),"enabled"in j&&(E.enabled=j.enabled,a.log(`${E.getName()} ${E.enabled?"enabled":"disabled"}`)),Q.includes(E)||Q.push(E)}return Q},k=(...Q)=>x(D=>C(D,...Q)),_=()=>({creatures:ut(i).map(Q=>Q.toJSON()),state:ut(c),name:ut(f),round:ut(l),logFile:a?.getLogFile()??null,rollHP:!1}),P=()=>{app.workspace.trigger("initiative-tracker:save-state",_())};function x(Q){s(Q),P()}let R=Q=>{for(let D=0;Dz.name==E.name).length==1||E.number>0)continue;let j=Q.filter(z=>z.display?z.display==E.display:z.name==E.name).map(z=>z.number);E.number=j?.length?Math.max(...j)+1:1}};function Z(Q,D){for(let E of D)E.static&&E.initiative||(E.active=!1,!(E.player&&Q.data.rollPlayerInitiatives==1)&&(E.player&&Q.data.rollPlayerInitiatives==2?E.initiative=0:E.initiative=Q.getInitiativeValue(E.modifier),E.manualOrder=null));return D}return{subscribe:n,set:r,data:h,setData:Q=>{h.set(Q),m=Q},getLogger:()=>a,setLogger:Q=>{a=Q},updating:e,updateTarget:t,updateCreatures:k,updateCreatureByName:(Q,D)=>x(E=>{let j=E.find(z=>z.name==Q);if(j){if(isNaN(Number(D.hp))||(j.hp=D.hp),D.max&&(j.current_max=Math.max(0,j.current_max+D.max),j.hp>=j.current_max&&m.hpOverflow!==In.current&&(j.hp=j.current_max)),D.temp){let z=0;m.additiveTemp&&(z=j.temp),D.temp>0?j.temp=Math.max(j.temp,z+D.temp):j.temp=Math.max(0,j.temp+D.temp)}if(D.marker&&(j.marker=D.marker),(typeof D.ac=="string"||!isNaN(Number(D.ac)))&&(j.ac=j.current_ac=D.ac),(typeof D.current_ac=="string"||!isNaN(Number(D.current_ac)))&&(j.current_ac=D.ac),isNaN(Number(D.initiative))||(j.initiative=D.initiative),typeof D.name=="string"&&(j.name=D.name),"hidden"in D&&(j.hidden=D.hidden),"enabled"in D&&(j.enabled=D.enabled),Array.isArray(D.status)&&D.status?.length)for(let z of D.status)if(typeof z=="string"){let q=m.statuses.find(G=>G.name==z)??{name:z,description:"",id:xt()};j.addCondition(q)}else typeof z=="object"&&z.name?.length&&j.addCondition(z)}return E}),players:oi(w,Q=>Q.filter(D=>D.player)),setUpdate:(Q,D)=>e.update(E=>(E.has(Q)?E.delete(Q):E.set(Q,{saved:D.getModifierState("Shift"),resist:D.getModifierState(PT),customMod:D.getModifierState("Alt")?"2":"1"}),E)),doUpdate:(Q,D,E,j=[])=>e.update(z=>{let q=[],G=[];return z.forEach((Y,ce)=>{let Pe=!Q.includes("."),ue={},B=(Y.saved?.5:1)*(Y.resist?.5:1)*Number(Y.customMod),ee=[ce.name];ce.number>0&&ee.push(`${ce.number}`);let pe={name:ee.join(" "),hp:null,temp:!1,max:!1,status:null,remove_status:null,saved:!1,unc:!1,ac:null,ac_add:!1};if(Q.charAt(0)=="t"){let Re=Number(Q.slice(1));pe.hp=Re,pe.temp=!0,ue.temp=Re}else{let Re=Q.charAt(0)==="m",oe=Number(Q.slice(+Re));oe=-1*Math.sign(oe)*Math.max(Math.abs(oe)*B,1),oe=Pe?Math.trunc(oe):oe,pe.hp=oe,Re&&(pe.max=!0,ue.max=oe),ue.hp=oe,ce.hp<=0&&(pe.unc=!0)}if(D.length&&(pe.status=D.map(Re=>Re.name),Y.saved?pe.saved=!0:ue.status=D),j.length&&(ue.remove_status=j),E){if(E.charAt(0)=="+"||E.charAt(0)=="-"){let Re=parseInt(String(ce.current_ac));isNaN(Re)?ce.current_ac=ce.current_ac+E:ce.current_ac=Re+parseInt(E),pe.ac_add=!0}else ce.current_ac=E.slice(+(E.charAt(0)=="\\"));pe.ac=E.slice(+(E.charAt(0)=="\\"))}q.push(pe),G.push({creature:ce,change:ue})}),a?.logUpdate(q),k(...G),z.clear(),z}),clearUpdate:()=>e.update(Q=>(Q.clear(),Q)),round:l,name:f,sort:p,party:d,setParty:(Q,D)=>x(E=>{let j=D.getPlayersForParty(Q);return d.set(Q),E=[...E.filter(z=>!z.player),...j],E}),state:c,getState:()=>ut(c),toggleState:()=>{u(!ut(c))},setState:u,goToNext:()=>x(Q=>{let D=O.findIndex(E=>E.active);if(D==-1)O[0].active=!0;else{let E,j=D;do if(j=((j+1)%O.length+O.length)%O.length,E=O[j],j==D)break;while(!E.enabled);if(E){if(O[D].active=!1,j!G.resetOnRound));a?.log("###",`Round ${z}`)}a?.log("#####",`${E.getName()}'s turn`),E.active=!0}}return Q}),goToPrevious:()=>x(Q=>{let D=O.findIndex(E=>E.active);if(D==0&&ut(l)==1)return Q;if(D==-1)O[0].active=!0;else{let E,j=D;do if(j=((j-1)%O.length+O.length)%O.length,E=O[j],j==D)break;while(!E.enabled);if(E){if(O[D].active=!1,j>D){let z=ut(l)-1;l.set(z);for(let q of Q)q.status=new Set([...q.status].filter(G=>!G.resetOnRound));a?.log("###",`Round ${z}`)}a?.log("#####",`${E.getName()}'s turn`),E.active=!0}}return Q}),ordered:w,add:async(Q,D=Q.data.rollHP,...E)=>x(j=>{Q.canUseDiceRoller&&D&&_b(E,Q,D),j.push(...E);let z=[];if(!m.condense)z.push(...E);else for(let q of E){let G=O.find(Y=>Ns(Y,q));G?q.initiative=G.initiative:z.push(q)}return Z(Q,z),a?.log(a?.join(E.map(q=>q.name)),"added to the combat."),R(j),j}),remove:(...Q)=>x(D=>(D=D.filter(E=>!Q.includes(E)),a?.log(a?.join(Q.map(E=>E.name)),"removed from the combat."),D)),replace:(Q,D)=>{x(E=>(E.splice(E.indexOf(Q),1,D),R(E),E))},update:()=>s(Q=>Q),updateAndSave:()=>x(Q=>Q),roll:Q=>x(D=>(Z(Q,D),D)),new:(Q,D)=>x(E=>{if(l.set(D?.round??1),c.set(D?.state??!1),f.set(D?.name??null),!D?.creatures)E=E.filter(j=>j.player);else{let j=[],z=ut(d),q=new Map([...z?Q.getPlayersForParty(z):[],...E.filter(G=>G.player)].map(G=>[G.id,G])).values();for(let G of D.creatures){let Y=null;G.player&&(Y=E.find(ce=>ce.player&&ce.id===G.id))&&Y!=null?j.push(Y):j.push(je.fromJSON(G,Q))}for(let G of q)j.find(Y=>Y.player&&Y.id==G.id)||j.push(G);E=j}return(!D||D?.roll)&&Z(Q,E),R(E),Q.canUseDiceRoller&&(D?.rollHP??Q.data.rollHP)&&_b(E,Q),D?.logFile&&a?.new(D.logFile).then(()=>{o.set(a.getFile())}),(!D&&a||D?.newLog)&&(a.logging=!1,o.set(null)),E}),reset:()=>x(Q=>{for(let D of Q)D.current_ac=D.ac,D.hp=D.current_max=D.max,D.enabled=!0,D.status.clear();return a?.log("Encounter HP & Statuses reset"),Q}),getOrderedCreatures:()=>ut(w),logUpdate:Q=>{let D=[];for(let E of Q){let j=[];E.hp&&(E.temp?j.push(`${E.name} gained ${E.hp.toString()} temporary HP`):E.max?E.hp<0?j.push(`${E.name} took ${(-1*E.hp).toString()} max HP damage${E.unc?" and died":""}`):j.push(`${E.name} gained ${(-1*E.hp).toString()} max HP`):E.hp<0?j.push(`${E.name} took ${(-1*E.hp).toString()} damage${E.unc?" and was knocked unconscious":""}`):E.hp>0&&j.push(`${E.name} was healed for ${E.hp.toString()} HP`)),E.status&&(j.length?j.push("and"):j.push(E.name),E.saved?j.push(`saved against ${E.status}`):j.push(`took ${E.status} status`)),D.push(j.join(" "))}a?.log(`${D.join(". ")}.`)},logNewInitiative:S,logFile:o,getEncounterState:_,updateState:()=>s(Q=>Q),difficulty:Q=>oi([i,h],([D])=>{let E=[],j=new Map,z=ki(Q);for(let q of D){if(!q.enabled||q.friendly)continue;if(q.player&&q.level){E.push(q.level);continue}let G={name:q.name,display:q.display,ac:q.ac,hp:q.hp,modifier:q.modifier,xp:q.xp,hidden:q.hidden},Y=[...j].find(([ce])=>Ns(ce,G));if(!Y){j.set(q,1);continue}j.set(Y[0],Y[1]+1)}return{difficulty:z.getEncounterDifficulty(j,E),thresholds:z.getDifficultyThresholds(E),labels:z.systemDifficulties}})}}var he=CT();function _b(i,e,t=!1){for(let n of i){if(!n.rollHP&&!t||!n.hit_dice?.length)continue;let r=e.getRoller(n.hit_dice);r&&(n.hp=n.max=n.current_max=r.rollSync())}}var Bl=class extends be.PluginSettingTab{constructor(t){super(t.app,t);this.plugin=t}async display(){try{let{containerEl:t}=this;t.empty(),t.addClass("initiative-tracker-settings"),t.createEl("h2",{text:"Initiative Tracker Settings"}),this._displayBase(t.createDiv()),this.plugin.data.openState||(this.plugin.data.openState={battle:!0,player:!0,party:!0,plugin:!0,status:!0,builder:!0}),this._displayBattle(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.player?{open:!0}:{}}})),this._displayPlayers(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.player?{open:!0}:{}}})),this._displayParties(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.party?{open:!0}:{}}})),this._displayBuilder(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.builder?{open:!0}:{}}})),this._displayStatuses(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.status?{open:!0}:{}}})),this._displayIntegrations(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.plugin?{open:!0}:{}}})),t.createDiv("coffee").createEl("a",{href:"https://www.buymeacoffee.com/valentine195"}).createEl("img",{attr:{src:"https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=\u2615&slug=valentine195&button_colour=e3e7ef&font_colour=262626&font_family=Inter&outline_colour=262626&coffee_colour=ff0000"}})}catch(t){console.error(t),new be.Notice("There was an error displaying the settings tab for Obsidian Initiative Tracker.")}}_displayBase(t){t.empty(),new be.Setting(t).setHeading().setName("Basic Settings"),new be.Setting(t).setName("Display Beginner Tips").setDesc("Display instructions in the initiative tracker, helping you get used to the workflow.").addToggle(n=>{n.setValue(this.plugin.data.beginnerTips).onChange(async r=>{this.plugin.data.beginnerTips=r,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Display Encounter Difficulty").setDesc("Display encounter difficulty based on creature CR and player level. Creatures without CR or level will not be considered in the calculation.").addToggle(n=>{n.setValue(this.plugin.data.displayDifficulty).onChange(async r=>{this.plugin.data.displayDifficulty=r,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Roll Equivalent Creatures Together").setDesc("Equivalent creatures (same Name and AC) will roll the same initiative by default.").addToggle(n=>{n.setValue(this.plugin.data.condense).onChange(async r=>{this.plugin.data.condense=r,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Embed statblock-link content in the Creature View").setDesc("Prefer embedded content from a statblock-link attribute when present. Fall back to the TTRPG plugin if the link is missing and the plugin is enabled.").addToggle(n=>{n.setValue(this.plugin.data.preferStatblockLink).onChange(async r=>{this.plugin.data.preferStatblockLink=r,await this.plugin.saveSettings()})})}async _displayBattle(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.battle=t.open};let n=t.createEl("summary");new be.Setting(n).setHeading().setName("Battle"),n.createDiv("collapser").createDiv("handle"),new be.Setting(t).setName("Clamp Minimum HP").setDesc("When a creature takes damage that would reduce its HP below 0, its HP is set to 0 instead.").addToggle(s=>{s.setValue(this.plugin.data.clamp).onChange(async o=>{this.plugin.data.clamp=o,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Overflow Healing").setDesc("Set what happens to healing which goes above creatures' max HP threshold.").addDropdown(s=>{s.addOption(In.ignore,"Ignore"),s.addOption(In.temp,"Add to temp HP"),s.addOption(In.current,"Add to current HP"),s.setValue(this.plugin.data.hpOverflow??In.ignore),s.onChange(async o=>{this.plugin.data.hpOverflow=o,this.plugin.saveSettings()})}),new be.Setting(t).setName("Automatic Unconscious Status Application").setDesc('When a creature takes damage that would reduce its HP below 0, it gains the "Unconscious" status effect.').addToggle(s=>{s.setValue(this.plugin.data.autoStatus).onChange(async o=>{this.plugin.data.autoStatus=o,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Additive Temporary HP").setDesc("Any temporary HP added to a creature will be added on top of existing temporary HP.").addToggle(s=>{s.setValue(this.plugin.data.additiveTemp).onChange(async o=>{this.plugin.data.additiveTemp=o,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Display Player HP in Player View").setDesc("If turned off, player health will display as 'Healthy', 'Hurt', etc.").addToggle(s=>{s.setValue(this.plugin.data.diplayPlayerHPValues).onChange(async o=>{this.plugin.data.diplayPlayerHPValues=o,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Roll HP for Creatures").setDesc(createFragment(s=>{s.createSpan({text:"Creatures added to encounters will automatically roll for HP if the "}),s.createEl("code",{text:"hit_dice"}),s.createSpan({text:" property is set for the creature."})})).addToggle(s=>{s.setValue(this.plugin.data.rollHP).onChange(async o=>{this.plugin.data.rollHP=o,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Log Battles").setDesc("Actions taken during battle will be logged to the specified log folder.").addToggle(s=>s.setValue(this.plugin.data.logging).onChange(async o=>{this.plugin.data.logging=o,await this.plugin.saveSettings()}));let r=await this.plugin.app.vault.adapter.exists(this.plugin.data.logFolder);new be.Setting(t).setName("Log Folder").setDesc(createFragment(async s=>{if(s.createSpan({text:"A new note will be created in this folder for each battle."}),s.createEl("br"),s.createSpan({text:"Current: "}),s.createEl("code",{text:this.plugin.data.logFolder}),!r){s.createEl("br");let o=s.createDiv("initiative-tracker-warning");(0,be.setIcon)(o,"initiative-tracker-warning"),o.createSpan({text:"This folder does not exist and will be created when a log file is written for the first time."})}})).addText(s=>{s.setValue(this.plugin.data.logFolder);let o=this.app.vault.getAllLoadedFiles().filter(l=>l instanceof be.TFolder);new _f.FolderInputSuggest(this.app,s,o).onSelect(async({item:l})=>{this.plugin.data.logFolder=(0,be.normalizePath)(l.path),await this.plugin.saveSettings(),this.display()})}),new be.Setting(t).setName("Resolve Initiative Ties").setDesc("Define what happens if two creatures have the same initiative.").addDropdown(s=>{s.addOption(Jn.playerFirst,"Player first"),s.addOption(Jn.npcFirst,"NPC first"),s.addOption(Jn.random,"Random"),s.setValue(this.plugin.data.resolveTies??Jn.playerFirst),s.onChange(async o=>{this.plugin.data.resolveTies=o,this.plugin.saveSettings()})})}_displayPlayers(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.player=t.open};let n=t.createEl("summary");new be.Setting(n).setHeading().setName("Players"),n.createDiv("collapser").createDiv("handle"),new be.Setting(t).setName("Add New Player").setDesc("Players added here will be available to add to a party. If you do not have a party created, all players will be added to a new encounter.").addButton(o=>o.setTooltip("Add Player").setButtonText("+").onClick(async()=>{let l=new vf(this.plugin);l.open(),l.onClose=async()=>{l.saved&&(await this.plugin.savePlayer({...l.player,player:!0}),this._displayPlayers(t))}}));let r=t.createDiv("additional"),s=r.createDiv("initiative-tracker-players");if(!this.plugin.players.size)r.createDiv({attr:{style:"display: flex; justify-content: center; padding-bottom: 18px;"}}).createSpan({text:"No saved players! Create one to see it here."});else{let o=s.createDiv("initiative-tracker-player headers");o.createDiv({text:"Name"}),(0,be.setIcon)(o.createDiv({attr:{"aria-label":"Level"}}),"swords"),(0,be.setIcon)(o.createDiv({attr:{"aria-label":"Max HP"}}),an),(0,be.setIcon)(o.createDiv({attr:{"aria-label":"Armor Class"}}),ir),(0,be.setIcon)(o.createDiv({attr:{"aria-label":"Initiative Modifier"}}),So),o.createDiv();for(let a of this.plugin.data.players){let l=s.createDiv("initiative-tracker-player");l.createDiv({text:a.name}),l.createDiv({text:`${a.level??We}`}),l.createDiv({text:`${a.hp??We}`}),l.createDiv({text:`${a.ac??We}`}),l.createDiv({text:`${a.modifier??We}`});let c=l.createDiv("initiative-tracker-player-icon");new be.ExtraButtonComponent(c.createDiv()).setIcon("pencil").setTooltip("Edit").onClick(()=>{let u=new vf(this.plugin,a);u.open(),u.onClose=async()=>{u.saved&&(await this.plugin.updatePlayer(a,u.player),this._displayPlayers(t))}}),new be.ExtraButtonComponent(c.createDiv()).setIcon("trash").setTooltip("Delete").onClick(async()=>{this.plugin.deletePlayer(a),await this.plugin.saveSettings(),this._displayPlayers(t)})}for(let[a,l]of this.plugin.statblock_players){let c=s.createDiv("initiative-tracker-player");c.createDiv({text:a}),c.createDiv({text:`${l.level??We}`}),c.createDiv({text:`${l.hp??We}`}),c.createDiv({text:`${l.ac??We}`}),c.createDiv({text:`${l.modifier??We}`});let u=c.createDiv({cls:"initiative-tracker-player-icon imported",attr:{"aria-label":"Imported from Fantasy Statblocks"}});(0,be.setIcon)(u,"heart-handshake")}}}_displayBuilder(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.player=t.open};let n=t.createEl("summary");new be.Setting(n).setHeading().setName("Encounters"),n.createDiv("collapser").createDiv("handle");let r=t.createDiv("initiative-tracker-explanation");r.createEl("span",{text:"The encounter builder allows you to quickly create encounters that can be saved for later use or immediately launched into a battle."}),r.createEl("br"),r.createEl("br"),r.createEl("span",{text:"It can be opened using the sidebar shortcut (if enabled) or by using the Open Encounter Builder command."}),new be.Setting(t).setName("Add Sidebar Shortcut").setDesc("A sidebar shortcut will be added to open the Encounter Builder.").addToggle(o=>{o.setValue(this.plugin.data.builder.sidebarIcon).onChange(a=>{this.plugin.data.builder.sidebarIcon=a,this.plugin.setBuilderIcon()})}),new be.Setting(t).setName("XP System").setDesc("XP system to use for encounters").addDropdown(o=>{Object.values(Rl).forEach(a=>o.addOption(a,ki(this.plugin,a).displayName)),o.setValue(this.plugin.data.rpgSystem??"dnd5e"),o.onChange(async a=>{this.plugin.data.rpgSystem=a,this.plugin.saveSettings()})});let s=t.createDiv("additional");if(new be.Setting(s).setHeading().setName("Saved Encounters"),!Object.keys(this.plugin.data.encounters).length)s.createDiv({attr:{style:"display: flex; justify-content: center; padding-bottom: 18px;"}}).createSpan({text:"No saved encounters! Create one to see it here."});else for(let[o,a]of Object.entries(this.plugin.data.encounters))new be.Setting(s).setName(o).setDesc(createFragment(l=>{let c=[],u=[];for(let f of a.creatures)f.player?c.push(f.name):u.push(f.name);c.length&&(l.createSpan({text:`Players: ${c.join(", ")}`}),l.createEl("br")),u.length&&(l.createSpan({text:`Creatures: ${u.join(", ")}`}),l.createEl("br")),a.timestamp&&l.createSpan({text:`${new Date(a.timestamp).toLocaleString()}`})})).addExtraButton(l=>{l.setIcon("trash").onClick(async()=>{this.plugin.removeEncounter(o),await this.plugin.saveSettings(),this._displayBuilder(t)})})}_displayParties(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.party=t.open};let n=t.createEl("summary");new be.Setting(n).setHeading().setName("Parties"),n.createDiv("collapser").createDiv("handle");let r=t.createDiv("initiative-tracker-explanation");r.createEl("span",{text:"Parties allow you to create different groups of your players. Each player can be a member of multiple parties."}),r.createEl("br"),r.createEl("br"),r.createEl("span",{text:"You can set a default party for encounters to use, or specify the party for the encounter in the encounter block. While running an encounter in the tracker, you can change the active party, allowing you to quickly switch which players are in combat."}),new be.Setting(t).setName("Default Party").setDesc("The tracker will load this party to encounters by default.").addDropdown(o=>{o.addOption("none","None");for(let a of this.plugin.data.parties)o.addOption(a.name,a.name);o.setValue(this.plugin.data.defaultParty??"none"),o.onChange(async a=>{this.plugin.data.defaultParty=a=="none"?null:a,this.plugin.saveSettings()})}),new be.Setting(t).setName("Add New Party").addButton(o=>o.setTooltip("Add Party").setButtonText("+").onClick(async()=>{let l=new bf(this.plugin);l.open(),l.onClose=async()=>{if(!l.canceled&&!(!l.party.name||!l.party.name.length)){if(this.plugin.data.parties.filter(c=>c.name==l.party.name)){let c=new Map([...this.plugin.data.parties].map(u=>[u.name,u]));c.set(l.party.name,l.party),this.plugin.data.parties=Array.from(c.values())}else this.plugin.data.parties.push(l.party);await this.plugin.saveSettings(),this._displayParties(t)}}}));let s=t.createDiv("additional");if(!this.plugin.data.parties.length)s.createDiv({attr:{style:"display: flex; justify-content: center; padding-bottom: 18px;"}}).createSpan({text:"No saved parties! Create one to see it here."});else for(let o of this.plugin.data.parties)new be.Setting(s).setName(o.name).setDesc(o.players.join(", ")).addExtraButton(a=>{a.setIcon("pencil").onClick(()=>{let l=new bf(this.plugin,o);l.open(),l.onClose=async()=>{if(!l.canceled&&!(!l.party.name||!l.party.name.length)){if(this.plugin.data.parties.splice(this.plugin.data.parties.indexOf(o),1,l.party),this.plugin.data.parties.filter(c=>c.name==l.party.name).length>1&&this.plugin.data.parties.filter(c=>c.name==l.party.name)){let c=new Map(this.plugin.data.parties.map(u=>[u.name,u]));c.set(l.party.name,l.party),this.plugin.data.parties=Array.from(c.values())}await this.plugin.saveSettings(),this._displayParties(t)}}})}).addExtraButton(a=>{a.setIcon("trash").onClick(async()=>{this.plugin.data.parties=this.plugin.data.parties.filter(l=>l.name!=o.name),this.plugin.data.defaultParty==o.name&&(this.plugin.data.defaultParty=this.plugin.data.parties[0]?.name??null),await this.plugin.saveSettings(),this._displayParties(t)})})}_displayStatuses(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.status=t.open};let n=t.createEl("summary");new be.Setting(n).setHeading().setName("Statuses"),new be.Setting(t).setName("Unconscious Status").setDesc("Choose a different status to be used as the default Unconscious status.").addDropdown(o=>{for(let a of this.plugin.data.statuses)o.addOption(a.id,a.name);o.setValue(this.plugin.data.unconsciousId),o.onChange(a=>this.plugin.data.unconsciousId=a)}),n.createDiv("collapser").createDiv("handle");let r=new be.Setting(t).setName("Add New Status").setDesc("These statuses will be available to apply to creatures.").addButton(o=>o.setTooltip("Add Status").setButtonText("+").onClick(async()=>{let l=new yf(this.plugin);l.onClose=async()=>{if(!l.canceled&&l.status.name){if(this.plugin.data.statuses.filter(c=>c.name==l.status.name)){let c=new Map([...this.plugin.data.statuses].map(u=>[u.name,u]));c.set(l.status.name,l.status),this.plugin.data.statuses=Array.from(c.values())}else this.plugin.data.statuses.push(l.status);await this.plugin.saveSettings(),this._displayStatuses(t)}},l.open()}));ls.every(o=>this.plugin.data.statuses.includes(o))||r.addExtraButton(o=>o.setIcon("reset").setTooltip("Re-add Default Statuses").onClick(async()=>{this.plugin.data.statuses=Array.from(new Map([...this.plugin.data.statuses,...ls].map(a=>[a.name,a])).values()),await this.plugin.saveSettings(),this._displayStatuses(t)}));let s=t.createDiv("additional");for(let o of this.plugin.data.statuses)new be.Setting(s).setName(createFragment(a=>{let l=a.createDiv("status-name-container");l.createSpan({text:o.name}),l.createDiv("status-metadata-container"),o.resetOnRound&&(0,be.setIcon)(l.createDiv({attr:{"aria-label":"Reset Each Round"}}),"timer-reset"),o.hasAmount&&(0,be.setIcon)(l.createDiv({attr:{"aria-label":"Has Amount"}}),"hash")})).setDesc(o.description??"").addExtraButton(a=>a.setIcon("pencil").onClick(()=>{let l=new yf(this.plugin,o);l.onClose=async()=>{if(!l.canceled&&l.status.name){if(this.plugin.data.statuses.splice(this.plugin.data.statuses.indexOf(o),1,l.status),this.plugin.data.statuses.filter(c=>c.name==l.status.name).length>1&&this.plugin.data.statuses.filter(c=>c.name==l.status.name)){let c=new Map(this.plugin.data.statuses.map(u=>[u.name,u]));c.set(l.status.name,l.status),this.plugin.data.statuses=Array.from(c.values())}await this.plugin.saveSettings(),this._displayStatuses(t)}},l.open()})).addExtraButton(a=>a.setIcon("trash").onClick(async()=>{this.plugin.data.statuses=this.plugin.data.statuses.filter(l=>l.name!=o.name),this.plugin.data.unconsciousId==o.id&&(this.plugin.data.unconsciousId="Unconscious"),await this.plugin.saveSettings(),this._displayStatuses(t)})).setClass("initiative-status-item")}async _displayIntegrations(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.plugin=t.open};let n=t.createEl("summary");if(new be.Setting(n).setHeading().setName("Plugin Integrations"),n.createDiv("collapser").createDiv("handle"),this.plugin.canUseStatBlocks||(this.plugin.data.sync=!1,await this.plugin.saveSettings()),new be.Setting(t).setName("Sync Monsters from Fantasy Statblocks").setDesc(createFragment(r=>{r.createSpan({text:"Homebrew creatures saved to the Fantasy Statblocks plugin will be available to use."}),this.plugin.canUseStatBlocks||(r.createEl("br"),r.createEl("br"),r.createSpan({text:"Install and enable the "}),r.createEl("a",{text:"Fantasy Statblocks",href:"obsidian://show-plugin?id=obsidian-5e-statblocks"}),r.createSpan({text:" plugin to use homebrew creatures."}))})).addToggle(r=>{r.setDisabled(!this.plugin.canUseStatBlocks).setValue(this.plugin.data.sync),r.onChange(async s=>{this.plugin.data.sync=s,await this.plugin.saveSettings(),this._displayIntegrations(t)})}),this.plugin.data.sync){let r=new be.Setting(t).setDesc(`${this.plugin.bestiary.length} creatures synced.`);r.settingEl.addClass("initiative-synced"),(0,be.setIcon)(r.nameEl,"check-in-circle"),r.nameEl.appendChild(createSpan({text:"Synced"}))}new be.Setting(t).setName("Initiative Formula").setDesc(createFragment(r=>{r.createSpan({text:"Initiative formula to use when calculating initiative. Use "}),r.createEl("code",{text:"%mod%"}),r.createSpan({text:" for the modifier placeholder."}),this.plugin.canUseDiceRoller||(r.createEl("br"),r.createEl("br"),r.createSpan({attr:{style:"color: var(--text-error);"},text:"Requires the "}),r.createEl("a",{text:"Dice Roller",href:"https://github.com/valentine195/obsidian-dice-roller",cls:"external-link"}),r.createSpan({attr:{style:"color: var(--text-error);"},text:" plugin to modify."}))})).addText(r=>{this.plugin.canUseDiceRoller||(r.setDisabled(!0),this.plugin.data.initiative="1d20 + %mod%"),r.setValue(this.plugin.data.initiative),r.onChange(s=>{this.plugin.data.initiative=s}),r.inputEl.onblur=async()=>{he.roll(this.plugin),await this.plugin.saveSettings()}})}},vf=class extends Eo.Modal{constructor(t,n={}){super(t.app);this.plugin=t;this.original=n;J(this,"player");J(this,"saved");this.player={...n??{}}}async display(t){let{contentEl:n}=this;n.addClass("initiative-tracker-add-player-modal"),n.empty();let r=!1;n.createEl("h2",{text:this.original?"Edit Player":"New Player"}),new be.Setting(n).setName("Link to Note").setDesc("Link player to a note in your vault.").addText(f=>{f.setValue(this.player.note??"");let d=this.app.vault.getFiles();new _f.FileInputSuggest(this.app,f,d).onSelect(async({item:p})=>{if(!p)return;let m=this.app.metadataCache.getFileCache(p);if(this.player.note=p.basename,this.player.path=p.path,this.player.name=p.basename,!m||!m.frontmatter)return;let{ac:g,hp:O,modifier:w,level:S,name:C}=m.frontmatter;this.player.name=C??this.player.name,this.player.ac=parseInt(g??this.player.ac,10),this.player.hp=parseInt(O??this.player.hp,10),this.player.level=parseInt(S??this.player.level,10),this.player.modifier=parseInt(w??this.player.modifier,10),this.player["statblock-link"]=m.frontmatter["statblock-link"],this.display()})});let s,o,a,l;new be.Setting(n).setName("Name").setDesc("Player name. Must be unique!").addText(f=>{s={input:f.inputEl,validate:d=>{let h=!1;return(!d.value.length&&!t||this.plugin.players.has(d.value)&&this.player.name!=this.original.name)&&(d.addClass("has-error"),h=!0),h}},f.setValue(this.player.name??""),f.onChange(d=>{f.inputEl.removeClass("has-error"),this.player.name=d})}),new be.Setting(n).setName("Level").setDesc("Player level.").addText(f=>{o={input:f.inputEl,validate:d=>{let h=!1;return(isNaN(Number(d.value))||Number(d.value)<=0)&&(d.addClass("has-error"),h=!0),h}},f.setValue(`${this.player.level??""}`),f.onChange(d=>{f.inputEl.removeClass("has-error"),this.player.level=Number(d)})}),new be.Setting(n).setName("Max Hit Points").addText(f=>{a={input:f.inputEl,validate:d=>{let h=!1;return isNaN(Number(d.value))&&(d.addClass("has-error"),h=!0),h}},f.setValue(`${this.player.hp??""}`),f.onChange(d=>{f.inputEl.removeClass("has-error"),this.player.hp=Number(d)})}),new be.Setting(n).setName("Armor Class").addText(f=>{f.setValue(`${this.player.ac??""}`),f.onChange(d=>{this.player.ac=d})}),new be.Setting(n).setName("Initiative Modifier").setDesc("This will be added to randomly-rolled initiatives.").addText(f=>{l={input:f.inputEl,validate:d=>{let h=!1;return isNaN(Number(d.value))&&(f.inputEl.addClass("has-error"),h=!0),h}},f.setValue(`${this.player.modifier??""}`),f.onChange(d=>{this.player.modifier=Number(d)})});let c=n.createDiv(),u=new be.Setting(c);u.addButton(f=>(f.setTooltip("Save").setIcon("checkmark").onClick(async()=>{if(this.validateInputs(s,a,l)){new be.Notice("Fix errors before saving.");return}this.saved=!0,this.close()}),f)),u.addExtraButton(f=>(f.setIcon("cross").setTooltip("Cancel").onClick(()=>{this.saved=!1,this.close()}),f)),this.validateInputs(s,a,l)}validateInputs(...t){let n=!1;for(let r of t)r.validate(r.input)?n=!0:r.input.removeClass("has-error");return n}onOpen(){this.display(!0)}};(0,be.addIcon)("initiative-tracker-warning",'');var yf=class extends Eo.Modal{constructor(t,n){super(t.app);this.plugin=t;J(this,"status",{name:null,description:null,id:xt()});J(this,"canceled",!1);J(this,"editing",!1);J(this,"original");J(this,"warned",!1);n&&(this.editing=!0,this.original=n.name,this.status={name:n.name,description:n.description,id:n.id??xt()})}onOpen(){this.titleEl.setText(this.editing?"Edit Status":"New Status"),this.contentEl.empty();let t=new be.Setting(this.contentEl).setName("Name").addText(n=>{n.setValue(this.status.name).onChange(r=>{this.status.name=r,this.plugin.data.statuses.find(s=>s.name==this.status.name)&&!this.warned&&this.original!=this.status.name?(this.warned=!0,t.setDesc(createFragment(s=>{let o=s.createDiv("initiative-tracker-warning");(0,be.setIcon)(o,"initiative-tracker-warning"),o.createSpan({text:"A status by this name already exists and will be overwritten."})}))):this.warned&&(this.warned=!1,t.setDesc(""))})});new be.Setting(this.contentEl).setName("Description").addTextArea(n=>{n.setValue(this.status.description).onChange(r=>this.status.description=r)}),new be.Setting(this.contentEl).setName("Remove Each Round").setDesc("This status will be removed from all creatures at the start of a new round.").addToggle(n=>n.setValue(this.status.resetOnRound).onChange(r=>this.status.resetOnRound=r)),new be.Setting(this.contentEl).setName("Has Amount").setDesc("This status has an amount that can be increased or decreased during combat.").addToggle(n=>n.setValue(this.status.hasAmount).onChange(r=>{this.status.hasAmount=r,this.onOpen()})),this.status.hasAmount&&new be.Setting(this.contentEl).setName("Starting Amount").setDesc("The status will default to this amount when added.").addText(n=>n.setValue(`${this.status.startingAmount}`).onChange(r=>{this.status.amount=this.status.startingAmount=Number(r)}).inputEl.type="number"),new Eo.ButtonComponent(this.contentEl.createDiv("initiative-tracker-cancel")).setButtonText("Cancel").onClick(()=>{this.canceled=!0,this.close()})}},bf=class extends Eo.Modal{constructor(t,n){super(t.app);this.plugin=t;J(this,"party",{name:null,players:[]});J(this,"canceled",!1);J(this,"editing",!1);J(this,"warned",!1);J(this,"original");n&&(this.editing=!0,this.original=n.name,this.party={name:n.name,players:[...n.players??[]]})}onOpen(){this.titleEl.setText(this.editing?`Edit ${this.party.name??"Party"}`:"New Party");let t=new be.Setting(this.contentEl).setName("Name").addText(o=>{o.setValue(this.party.name).onChange(a=>{this.party.name=a,this.plugin.data.parties.find(l=>l.name==this.party.name)&&!this.warned&&this.original!=this.party.name?(this.warned=!0,t.setDesc(createFragment(l=>{let c=l.createDiv("initiative-tracker-warning");(0,be.setIcon)(c,"initiative-tracker-warning"),c.createSpan({text:"A party by this name already exists and will be overwritten."})}))):this.warned&&(this.warned=!1,t.setDesc(""))})}),n=this.contentEl.createDiv("initiative-tracker-additional-container"),r;new be.Setting(n).setName("Add Player to Party").addText(o=>{r=o;let a=new tf(this.plugin.app,o,[...this.plugin.players.values()]).onSelect(({item:l})=>{o.setValue(l.name),a.close()})}).addExtraButton(o=>o.setIcon("plus-with-circle").onClick(()=>{if(!(!r.getValue()||!r.getValue().length)){if(this.party.players.includes(r.getValue())){new be.Notice("That player is already in this party!");return}if(!this.plugin.players.has(r.getValue())){new be.Notice("That player doesn't exist! You should make them first.");return}this.party.players.push(r.getValue()),this.displayPlayers(s),r.setValue("")}}));let s=n.createDiv("additional");this.displayPlayers(s),new Eo.ButtonComponent(this.contentEl.createDiv("initiative-tracker-cancel")).setButtonText("Cancel").onClick(()=>{this.canceled=!0,this.close()})}displayPlayers(t){if(t.empty(),this.party.players.length)for(let n of this.party.players)new be.Setting(t).setName(n).addExtraButton(r=>{r.setIcon("trash").onClick(()=>{this.party.players.splice(this.party.players.indexOf(n),1),this.displayPlayers(t)})});else t.createDiv({attr:{style:"display: flex; justify-content: center; padding-bottom: 18px;"}}).createSpan({text:"Add a player to the party to see it here."})}};var hm=require("obsidian");function ET(i){se(i,"svelte-10ii9u0",".creature-name.svelte-10ii9u0.svelte-10ii9u0{cursor:pointer}.encounter-line.svelte-10ii9u0.svelte-10ii9u0{display:flex;gap:1rem}.icons.svelte-10ii9u0.svelte-10ii9u0{display:flex}.icons.svelte-10ii9u0>span.svelte-10ii9u0 .clickable-icon{margin-right:0}")}function wb(i,e,t){let n=i.slice();return n[13]=e[t][0],n[14]=e[t][1],n[16]=t,n}function TT(i){let e;return{c(){e=ae("-")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function AT(i){let e,t=fe([...i[0]]),n=[];for(let r=0;r{o.set(g,S.result)}),a.set(g,S),S.rollSync()):o.set(g,w)}else o.set(g,w)}let l=g=>{new hm.ExtraButtonComponent(g).setIcon(us)},c=async()=>{r.view||await r.addTrackerView();let g=r.view,O=[...o].map(([w,S])=>isNaN(Number(S))||S<1?[w]:[...Array(S).keys()].map(C=>je.new(w))).flat();he.new(r,{creatures:O.map(w=>w.toJSON()),name:null,state:!1,round:1,logFile:null,newLog:!0,roll:!0}),r.app.workspace.revealLeaf(g.leaf)},u=g=>{new hm.ExtraButtonComponent(g).setIcon("plus-with-circle")},f=async g=>{r.view||await r.addTrackerView();let O=[...o].map(([w,S])=>isNaN(Number(S))||S<1?[w]:[...Array(S).keys()].map(C=>je.new(w))).flat();he.add(r,s,...O)},d=(g,O)=>{r.canUseDiceRoller&&a.has(O)&&!a.get(O).isStatic?g.appendChild(a.get(O)?.containerEl??createSpan({text:`${o.get(O)}`})):g.setText(`${o.get(O)}`)},h=(g,O)=>{if(O==1||g==0)return"";let w=O>2?",":"";return g==O-1?`${w} and `:`${w} `},p=g=>{if(!g)return;let O=[];return g.hp&&O.push(`HP: ${g.hp}`),g.ac&&O.push(`AC: ${g.ac}`),g.modifier&&O.push(`MOD: ${g.modifier}`),`${O.join(", ")}`},m=(g,O)=>r.openCombatant(g,O.ctrlKey||O.metaKey);return i.$$set=g=>{"creatures"in g&&t(0,n=g.creatures),"plugin"in g&&t(1,r=g.plugin),"rollHP"in g&&t(9,s=g.rollHP)},[n,r,l,c,u,f,d,h,p,s,m]}var pm=class extends ne{constructor(e){super(),re(this,e,MT,RT,ie,{creatures:0,plugin:1,rollHP:9},ET)}},Sb=pm;var kn=require("obsidian");var Wi=require("obsidian");function IT(i){se(i,"svelte-g63m31",".buttons.svelte-g63m31.svelte-g63m31{display:flex;justify-content:space-between;padding:0 0 0.5rem 0}.state.svelte-g63m31.svelte-g63m31{display:flex;justify-content:flex-start;align-items:center}.clean.svelte-g63m31.svelte-g63m31{display:flex;justify-content:flex-end;align-items:center}.state.svelte-g63m31>.svelte-g63m31:not(:last-child),.clean.svelte-g63m31>.svelte-g63m31:not(:last-child){margin-right:0.25rem}")}function NT(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","svelte-g63m31")},m(s,o){A(s,e,o),n||(r=H(t=i[8].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function jT(i){let e,t,n,r,s,o,a,l,c,u;return{c(){e=b("div"),n=M(),r=b("div"),o=M(),a=b("div"),v(e,"class","svelte-g63m31"),v(r,"class","svelte-g63m31"),v(a,"class","svelte-g63m31")},m(f,d){A(f,e,d),A(f,n,d),A(f,r,d),A(f,o,d),A(f,a,d),c||(u=[H(t=i[9].call(null,e)),H(s=i[11].call(null,r)),H(l=i[10].call(null,a))],c=!0)},d(f){f&&(T(e),T(n),T(r),T(o),T(a)),c=!1,de(u)}}}function xb(i){let e,t,n,r;return{c(){e=b("div"),v(e,"aria-label","Open Log File"),v(e,"class","svelte-g63m31")},m(s,o){A(s,e,o),n||(r=[H(t=i[16].call(null,e)),U(e,"click",i[17])],n=!0)},p:X,d(s){s&&T(e),n=!1,de(r)}}}function ZT(i){let e,t,n,r;return{c(){e=b("div"),v(e,"aria-label","Open Player View"),v(e,"class","svelte-g63m31")},m(s,o){A(s,e,o),n||(r=[H(t=i[15].call(null,e)),U(e,"click",i[18])],n=!0)},p:X,d(s){s&&T(e),n=!1,de(r)}}}function zT(i){let e,t,n,r,s,o,a,l,c,u;function f(g,O){return g[1]?jT:NT}let d=f(i,-1),h=d(i),p=i[0]&&xb(i),m=i[7]&&ZT(i);return{c(){e=b("div"),t=b("div"),h.c(),n=M(),r=b("div"),p&&p.c(),s=M(),m&&m.c(),o=M(),a=b("div"),v(t,"class","state svelte-g63m31"),v(a,"class","svelte-g63m31"),v(r,"class","clean svelte-g63m31"),v(e,"class","buttons svelte-g63m31")},m(g,O){A(g,e,O),y(e,t),h.m(t,null),y(e,n),y(e,r),p&&p.m(r,null),y(r,s),m&&m.m(r,null),y(r,o),y(r,a),c||(u=[H(l=i[14].call(null,a)),U(a,"click",i[19])],c=!0)},p(g,[O]){d!==(d=f(g,O))&&(h.d(1),h=d(g),h&&(h.c(),h.m(t,null))),g[0]?p?p.p(g,O):(p=xb(g),p.c(),p.m(r,s)):p&&(p.d(1),p=null),g[7]&&m.p(g,O)},i:X,o:X,d(g){g&&T(e),h.d(),p&&p.d(),m&&m.d(),c=!1,de(u)}}}function qT(i,e,t){let n,r,s,o,a,{state:l,data:c,logFile:u,sort:f,party:d}=he;Se(i,l,Q=>t(1,a=Q)),Se(i,c,Q=>t(22,s=Q)),Se(i,u,Q=>t(0,n=Q)),Se(i,f,Q=>t(23,o=Q)),Se(i,d,Q=>t(21,r=Q));let h=Wi.Platform.isDesktop,p=Q=>{new Wi.ExtraButtonComponent(Q).setIcon(qp).setTooltip("Play").onClick(()=>he.setState(!0))},m=Q=>{new Wi.ExtraButtonComponent(Q).setIcon(Fp).setTooltip("Stop").onClick(()=>he.setState(!1))},g=Q=>{new Wi.ExtraButtonComponent(Q).setIcon(Lp).setTooltip("Next").onClick(()=>he.goToNext())},O=Q=>{new Wi.ExtraButtonComponent(Q).setIcon($p).setTooltip("Previous").onClick(()=>he.goToPrevious())},w=Ue("plugin"),S=Fe(),C=Q=>{let D=new Wi.Menu;if(D.addItem(E=>{E.setIcon(Wu).setTitle("New Encounter").onClick(()=>he.new(w))}),D.addItem(E=>{E.setIcon(Wu).setTitle("Add Creatures").onClick(()=>S("add-creatures"))}),D.addItem(E=>{E.setIcon(Vp).setTitle("Reset HP / Status").onClick(()=>he.reset())}),D.addItem(E=>{E.setIcon(Qs).setTitle("Re-roll Initiatives").onClick(()=>he.roll(w))}),D.addItem(E=>{E.setIcon(Bu).setTitle(w.data.condense?"Expand Creatures":"Group Creatures").onClick(async()=>{w.data.condense=!w.data.condense,await w.saveSettings(),E.setIcon(w.data.condense?Mp:Bu),E.setTitle(w.data.condense?"Expand Creatures":"Group Creatures")})}),D.addItem(E=>{E.setTitle(o?"Sort Ascending":"Sort Descending").onClick(async()=>{w.data.descending=!w.data.descending,await w.saveSettings(),E.setTitle(w.data.descending?"Sort Ascending":"Sort Descending")})}),D.addSeparator(),s.parties&&s.parties.length)if(Wi.Platform.isMobile){D.addItem(E=>{E.setIcon("switch").setTitle("Switch Party").setIsLabel(!0)}),D.addItem(E=>{E.setTitle("None").onClick(()=>{he.setParty("",w)}).setChecked(!r||r=="")});for(let E of s.parties)D.addItem(j=>{j.setTitle(E.name).onClick(()=>{he.setParty(E.name,w)}).setChecked(r==E.name)})}else D.addItem(E=>{let j=E.setIcon("switch").setTitle("Switch Party").setSubmenu();j.addItem(z=>{z.setTitle("None").onClick(()=>{he.setParty("",w)}).setChecked(!r||r=="")});for(let z of s.parties)j.addItem(q=>{q.setTitle(z.name).onClick(()=>{he.setParty(z.name,w)}).setChecked(r==z.name)})});if(Wi.Platform.isMobile?(D.addItem(E=>{E.setIcon("dice").setTitle("Party Rolling Behavior").setIsLabel(!0)}),D.addItem(E=>{E.setTitle("Always Roll").onClick(async()=>{w.data.rollPlayerInitiatives=0,await w.saveSettings()}).setChecked(w.data.rollPlayerInitiatives==0)}),D.addItem(E=>{E.setTitle("Never Roll").onClick(async()=>{w.data.rollPlayerInitiatives=1,await w.saveSettings()}).setChecked(w.data.rollPlayerInitiatives==1)}),D.addItem(E=>{E.setTitle("Set to Zero").onClick(async()=>{w.data.rollPlayerInitiatives=2,await w.saveSettings()}).setChecked(w.data.rollPlayerInitiatives==2)})):D.addItem(E=>{let j=E.setIcon("dice").setTitle("Party Rolling Behavior").setSubmenu();j.addItem(z=>{z.setTitle("Always Roll").onClick(async()=>{w.data.rollPlayerInitiatives=0,await w.saveSettings()}).setChecked(w.data.rollPlayerInitiatives==0)}),j.addItem(z=>{z.setTitle("Never Roll").onClick(async()=>{w.data.rollPlayerInitiatives=1,await w.saveSettings()}).setChecked(w.data.rollPlayerInitiatives==1)}),j.addItem(z=>{z.setTitle("Set to Zero").onClick(async()=>{w.data.rollPlayerInitiatives=2,await w.saveSettings()}).setChecked(w.data.rollPlayerInitiatives==2)})}),D.addSeparator(),!Wi.Platform.isMobile)D.addItem(E=>{let j=E.setIcon("open-elsewhere-glyph").setTitle("Load Encounter").setDisabled(Object.keys(w.data.encounters).length==0).setSubmenu().setNoIcon();for(let z of Object.keys(w.data.encounters))j.addItem(q=>{q.setTitle(z).onClick(()=>{he.new(w,w.data.encounters[z])})})});else{D.addItem(E=>{E.setIcon("open-elsewhere-glyph").setTitle("Load Encounter").setIsLabel(!0)});for(let E of Object.keys(w.data.encounters))D.addItem(j=>{j.setTitle(E).onClick(()=>{he.new(w,w.data.encounters[E])})})}D.addItem(E=>{E.setIcon(Al).setTitle("Save Encounter").onClick(()=>{S("save")})}),D.showAtMouseEvent(Q)};return[n,a,l,c,u,f,d,h,p,m,g,O,S,C,Q=>{new Wi.ExtraButtonComponent(Q).setIcon("vertical-three-dots")},Q=>{new Wi.ExtraButtonComponent(Q).setIcon("view")},Q=>{new Wi.ExtraButtonComponent(Q).setIcon("file-signature")},async()=>{n&&w.app.workspace.getLeaf().openFile(n)},Q=>S("player-view"),Q=>C(Q)]}var mm=class extends ne{constructor(e){super(),re(this,e,qT,zT,ie,{},IT)}},Pb=mm;var ic=require("obsidian");var Eb=require("obsidian");function LT(i){se(i,"svelte-1kp13ds",'.tree-item-flair-outer.svelte-1kp13ds::after{content:""}.initiative.svelte-1kp13ds{display:block;padding:0;width:20px;text-align:center;white-space:nowrap;user-select:all;border:0;color:inherit}')}function Cb(i){let e,t,n,r;return{c(){e=b("input"),v(e,"class","editable initiative tree-item-flair svelte-1kp13ds"),v(e,"aria-label",t=`${i[0]-i[1]} + ${i[1]}`),e.value=i[0]},m(s,o){A(s,e,o),n||(r=[U(e,"click",FT),U(e,"blur",i[3]),U(e,"keydown",BT)],n=!0)},p(s,o){o&3&&t!==(t=`${s[0]-s[1]} + ${s[1]}`)&&v(e,"aria-label",t),o&1&&e.value!==s[0]&&(e.value=s[0])},d(s){s&&T(e),n=!1,de(r)}}}function $T(i){let e,t=i[0],n=Cb(i);return{c(){e=b("div"),n.c(),v(e,"class","tree-item-flair-outer svelte-1kp13ds")},m(r,s){A(r,e,s),n.m(e,null)},p(r,[s]){s&1&&ie(t,t=r[0])?(n.d(1),n=Cb(r),n.c(),n.m(e,null)):n.p(r,s)},i:X,o:X,d(r){r&&T(e),n.d(r)}}}var FT=function(i){this.select()},BT=function(i){if(i.key==="Enter"||i.key==="Tab"){i.preventDefault(),this.blur();return}if(!/^(-?\d*\.?\d*|Backspace|Delete|Arrow\w+)$/.test(i.key))return i.preventDefault(),!1};function VT(i,e,t){let n=Fe(),{initiative:r}=e,{modifier:s}=e,o=function(a){let l=this.value;if(isNaN(Number(l))){new Eb.Notice("Enter a valid initiative."),this.value=`${r}`;return}r!=Number(l)&&n("initiative",Number(l))};return i.$$set=a=>{"initiative"in a&&t(0,r=a.initiative),"modifier"in a&&t(1,s=a.modifier)},[r,s,n,o]}var gm=class extends ne{constructor(e){super(),re(this,e,VT,$T,ie,{initiative:0,modifier:1},LT)}},Tb=gm;var wf=require("obsidian");function WT(i){se(i,"svelte-ptr4mi",".controls.svelte-ptr4mi{display:flex;justify-content:flex-end}.icon.svelte-ptr4mi .clickable-icon{margin-right:0}")}function XT(i){let e,t,n,r,s;return{c(){e=b("div"),t=b("div"),v(t,"class","add-button icon svelte-ptr4mi"),v(e,"class","controls svelte-ptr4mi")},m(o,a){A(o,e,a),y(e,t),r||(s=H(n=i[0].call(null,t)),r=!0)},p:X,i:X,o:X,d(o){o&&T(e),r=!1,s()}}}function UT(i,e,t){let n=Fe(),{creature:r}=e,s=Ue("plugin"),o=a=>{let l=new wf.ExtraButtonComponent(a).setIcon("vertical-three-dots").setTooltip("Actions");l.extraSettingsEl.onclick=c=>{c.stopPropagation();let u=new wf.Menu;u.addItem(f=>{f.setIcon(an).setTitle("Set Health/Status").onClick(d=>{he.updateTarget.set("hp"),he.setUpdate(r,d)})}),r.current_ac!=r.ac&&u.addItem(f=>{f.setIcon(an).setTitle("Reset AC").onClick(d=>{t(1,r.current_ac=r.ac,r),he.updateAndSave()})}),u.addItem(f=>{f.setIcon("pencil").setTitle("Edit").onClick(()=>{n("edit",r)})}),r.hidden?u.addItem(f=>{f.setIcon("eye").setTitle("Show").onClick(()=>{he.updateCreatures({creature:r,change:{hidden:!1}})})}):u.addItem(f=>{f.setIcon(er).setTitle("Hide").onClick(()=>{he.updateCreatures({creature:r,change:{hidden:!0}})})}),r.enabled?u.addItem(f=>{f.setIcon(Dl).setTitle("Disable").onClick(()=>{he.updateCreatures({creature:r,change:{enabled:!1}})})}):u.addItem(f=>{f.setIcon(Ql).setTitle("Enable").onClick(()=>{he.updateCreatures({creature:r,change:{enabled:!0}})})}),u.addItem(f=>{f.setIcon(Vu).setTitle("Remove").onClick(()=>{he.remove(r)})}),u.showAtPosition(c)}};return i.$$set=a=>{"creature"in a&&t(1,r=a.creature)},[o,r]}var Om=class extends ne{constructor(e){super(),re(this,e,UT,XT,ie,{creature:1},WT)}},Ab=Om;var Vl=require("obsidian");function YT(i){se(i,"svelte-i278pw",".amount.svelte-i278pw,.tag.svelte-i278pw{display:flex;align-items:center;gap:0.125rem}.tag.svelte-i278pw{color:var(--text-muted);font-size:small;width:fit-content;border-color:var(--border-color);border-radius:0.25rem}.tag.svelte-i278pw .clickable-icon{margin:0}.icon.svelte-i278pw{display:flex;align-items:center}")}function Db(i){let e,t,n,r,s,o=i[0].amount+"",a,l,c,u,f,d;return{c(){e=b("div"),t=b("div"),r=M(),s=b("span"),a=ae(o),l=M(),c=b("div"),v(t,"class","icon svelte-i278pw"),v(c,"class","icon svelte-i278pw"),v(e,"class","amount svelte-i278pw")},m(h,p){A(h,e,p),y(e,t),y(e,r),y(e,s),y(s,a),y(e,l),y(e,c),f||(d=[H(n=i[3].call(null,t)),U(t,"click",i[5]),H(u=i[4].call(null,c)),U(c,"click",i[6])],f=!0)},p(h,p){p&1&&o!==(o=h[0].amount+"")&&me(a,o)},d(h){h&&T(e),f=!1,de(d)}}}function HT(i){let e,t,n=i[0].name+"",r,s,o,a,l,c,u,f,d=i[0].hasAmount&&Db(i);return{c(){e=b("div"),t=b("span"),r=ae(n),o=M(),d&&d.c(),a=M(),l=b("div"),v(t,"aria-label-classes","initiative-tracker-condition-tooltip"),v(t,"aria-label",s=i[0].description?.length?i[0].description:null),v(e,"class","tag svelte-i278pw")},m(h,p){A(h,e,p),y(e,t),y(t,r),y(e,o),d&&d.m(e,null),y(e,a),y(e,l),u||(f=[H(c=i[2].call(null,l)),U(l,"click",i[7])],u=!0)},p(h,[p]){p&1&&n!==(n=h[0].name+"")&&me(r,n),p&1&&s!==(s=h[0].description?.length?h[0].description:null)&&v(t,"aria-label",s),h[0].hasAmount?d?d.p(h,p):(d=Db(h),d.c(),d.m(e,a)):d&&(d.d(1),d=null)},i:X,o:X,d(h){h&&T(e),d&&d.d(),u=!1,de(f)}}}function GT(i,e,t){let n=Fe(),{status:r}=e;(isNaN(r.amount)||r.amount<0)&&(r.amount=r.startingAmount);let s=f=>{new Vl.ExtraButtonComponent(f).setIcon("cross-in-box")},o=f=>{(0,Vl.setIcon)(f,"minus")},a=f=>{(0,Vl.setIcon)(f,"plus")},l=()=>{t(0,r.amount--,r),r.amount<=0&&n("remove")},c=()=>t(0,r.amount++,r),u=()=>n("remove");return i.$$set=f=>{"status"in f&&t(0,r=f.status)},[r,n,s,o,a,l,c,u]}var vm=class extends ne{constructor(e){super(),re(this,e,GT,HT,ie,{status:0},YT)}},kf=vm;var xa=require("obsidian");function KT(i){se(i,"svelte-nkq4jj",".name-holder.svelte-nkq4jj{display:flex;align-items:center;gap:0.25rem;font-size:small}.centered-icon.svelte-nkq4jj{display:flex;align-items:center}.name.svelte-nkq4jj{display:block;text-align:left;background-color:inherit;border:0;padding:0;height:unset;word-break:keep-all}.center.svelte-nkq4jj{text-align:center}.creature-adder.svelte-nkq4jj{cursor:pointer}.statuses.svelte-nkq4jj{display:flex;flex-flow:row wrap;column-gap:0.25rem}.initiative-container.svelte-nkq4jj{border-top-left-radius:0.25rem;border-bottom-left-radius:0.25rem}.controls-container.svelte-nkq4jj{border-top-right-radius:0.25rem;border-bottom-right-radius:0.25rem}.dirty-ac.svelte-nkq4jj{font-weight:var(--font-bold)}.mobile.svelte-nkq4jj{font-size:smaller}")}function Qb(i,e,t){let n=i.slice();return n[21]=e[t],n}function Rb(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","centered-icon svelte-nkq4jj")},m(s,o){A(s,e,o),n||(r=H(t=i[6].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function Mb(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","centered-icon svelte-nkq4jj")},m(s,o){A(s,e,o),n||(r=H(t=i[7].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function JT(i){let e;return{c(){e=b("span"),e.textContent=`${i[5]()}`,v(e,"class","name svelte-nkq4jj")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function e6(i){let e,t=i[0].name+"",n;return{c(){e=b("strong"),n=ae(t),v(e,"class","name player svelte-nkq4jj")},m(r,s){A(r,e,s),y(e,n)},p(r,s){s&1&&t!==(t=r[0].name+"")&&me(n,t)},d(r){r&&T(e)}}}function Ib(i){let e,t,n=fe([...i[1]]),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o{z=null}),De()),(!P||G&1)&&h!==(h=q[0].hpDisplay+"")&&(d.innerHTML=h),(!P||G&1)&&O!==(O=(q[0].current_ac?q[0].current_ac:We)+"")&&me(w,O),(!P||G&1&&S!==(S=q[0].current_ac!=q[0].ac?`${q[0].ac}`:""))&&v(g,"aria-label",S),(!P||G&1)&&ge(g,"dirty-ac",q[0].current_ac!=q[0].ac);let ce={};G&1&&(ce.creature=q[0]),_.$set(ce)},i(q){P||($(t.$$.fragment,q),$(z),$(_.$$.fragment,q),P=!0)},o(q){V(t.$$.fragment,q),V(z),V(_.$$.fragment,q),P=!1},d(q){q&&(T(e),T(n),T(r),T(u),T(f),T(p),T(m),T(C),T(k)),ve(t),Z&&Z.d(),Q&&Q.d(),j.d(),z&&z.d(),ve(_),x=!1,de(R)}}}var jb=(i,e)=>i+e,i6=i=>i.stopPropagation(),n6=i=>i.stopPropagation(),r6=i=>i.stopPropagation(),s6=i=>i.stopPropagation();function o6(i,e,t){let n,r,s=Fe(),{updateTarget:o}=he;Se(i,o,x=>t(2,r=x));let{creature:a}=e,l=()=>a.getName(),c=()=>a.getStatblockLink(),u=x=>{(0,xa.setIcon)(x,er)},f=x=>{(0,xa.setIcon)(x,tr)},d={hoverPopover:null},h=null,p=x=>{h=setTimeout(()=>{if(a["statblock-link"]){let R=c();/\[.+\]\(.+\)/.test(R)?[,R]=R.match(/\[.+?\]\((.+?)\)/):/\[\[.+\]\]/.test(R)&&([,R]=R.match(/\[\[(.+?)(?:\|.+?)?\]\]/)),app.workspace.trigger("hover-link",{event:x,source:Mn,hoverParent:d,targetEl:x.target,linktext:R})}},1e3)},m=x=>{clearTimeout(h)},g=x=>{he.updateCreatures({creature:a,change:{initiative:Number(x.detail)}})},O=x=>{s("open-combatant",{creature:a,newLeaf:x.ctrlKey||x.metaKey})},w=x=>{he.updateCreatures({creature:a,change:{remove_status:[x]}})},S=x=>{let R=r;Ke(o,r="hp",r),R!="ac"&&he.setUpdate(a,x)},C=x=>{let R=r;Ke(o,r="ac",r),R!="hp"&&he.setUpdate(a,x)};function k(x){ht.call(this,i,x)}function _(x){ht.call(this,i,x)}function P(x){ht.call(this,i,x)}return i.$$set=x=>{"creature"in x&&t(0,a=x.creature)},i.$$.update=()=>{i.$$.dirty&1&&t(1,n=a.status)},[a,n,r,s,o,l,u,f,p,m,g,O,w,S,C,k,_,P]}var ym=class extends ne{constructor(e){super(),re(this,e,o6,t6,ie,{creature:0},KT)}},Zb=ym;function zb(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Pf(i){for(var e=1;e=0)&&(t[r]=i[r]);return t}function l6(i,e){if(i==null)return{};var t=a6(i,e),n,r;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);for(r=0;r=0)&&Object.prototype.propertyIsEnumerable.call(i,n)&&(t[n]=i[n])}return t}function c6(i,e){return f6(i)||h6(i,e)||Tm(i,e)||m6()}function Zn(i){return u6(i)||d6(i)||Tm(i)||p6()}function u6(i){if(Array.isArray(i))return _m(i)}function f6(i){if(Array.isArray(i))return i}function d6(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function h6(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n=[],r=!0,s=!1,o,a;try{for(t=t.call(i);!(r=(o=t.next()).done)&&(n.push(o.value),!(e&&n.length===e));r=!0);}catch(l){s=!0,a=l}finally{try{!r&&t.return!=null&&t.return()}finally{if(s)throw a}}return n}}function Tm(i,e){if(i){if(typeof i=="string")return _m(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _m(i,e)}}function _m(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(l){throw l},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){t=t.call(i)},n:function(){var l=t.next();return s=l.done,l},e:function(l){o=!0,a=l},f:function(){try{!s&&t.return!=null&&t.return()}finally{if(o)throw a}}}}var g6="finalize",O6="consider";function Ta(i,e,t){i.dispatchEvent(new CustomEvent(g6,{detail:{items:e,info:t}}))}function qs(i,e,t){i.dispatchEvent(new CustomEvent(O6,{detail:{items:e,info:t}}))}var Rf="draggedEntered",Jl="draggedLeft",Mf="draggedOverIndex",Am="draggedLeftDocument",Cf={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function v6(i,e,t){i.dispatchEvent(new CustomEvent(Rf,{detail:{indexObj:e,draggedEl:t}}))}function y6(i,e,t){i.dispatchEvent(new CustomEvent(Jl,{detail:{draggedEl:e,type:Cf.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function b6(i,e){i.dispatchEvent(new CustomEvent(Jl,{detail:{draggedEl:e,type:Cf.OUTSIDE_OF_ANY}}))}function _6(i,e,t){i.dispatchEvent(new CustomEvent(Mf,{detail:{indexObj:e,draggedEl:t}}))}function w6(i){window.dispatchEvent(new CustomEvent(Am,{detail:{draggedEl:i}}))}var Xi={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:Rf,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:Mf,DRAGGED_LEFT:Jl,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},dn={POINTER:"pointer",KEYBOARD:"keyboard"},If="isDndShadowItem",Dm="data-is-dnd-shadow-item-internal",k6="data-is-dnd-shadow-item-hint",ec="id:dnd-shadow-placeholder-0000",S6="dnd-action-dragged-el",bi="id",wm=0;function Kb(){wm++}function Jb(){if(wm===0)throw new Error("Bug! trying to decrement when there are no dropzones");wm--}var Qm=typeof window>"u",Be=function(){};function km(i){var e,t=i.getBoundingClientRect(),n=getComputedStyle(i),r=n.transform;if(r){var s,o,a,l;if(r.startsWith("matrix3d("))e=r.slice(9,-1).split(/, /),s=+e[0],o=+e[5],a=+e[12],l=+e[13];else if(r.startsWith("matrix("))e=r.slice(7,-1).split(/, /),s=+e[0],o=+e[3],a=+e[4],l=+e[5];else return t;var c=n.transformOrigin,u=t.x-a-(1-s)*parseFloat(c),f=t.y-l-(1-o)*parseFloat(c.slice(c.indexOf(" ")+1)),d=s?t.width/s:i.offsetWidth,h=o?t.height/o:i.offsetHeight;return{x:u,y:f,width:d,height:h,top:f,right:u+d,bottom:f+h,left:u}}else return t}function e_(i){var e=km(i);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function t_(i){var e=i.getBoundingClientRect();return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function i_(i){return{x:(i.left+i.right)/2,y:(i.top+i.bottom)/2}}function x6(i,e){return Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2))}function Nf(i,e){return i.y<=e.bottom&&i.y>=e.top&&i.x>=e.left&&i.x<=e.right}function Yl(i){return i_(t_(i))}function qb(i,e){var t=Yl(i),n=e_(e);return Nf(t,n)}function P6(i,e){var t=Yl(i),n=Yl(e);return x6(t,n)}function C6(i){var e=t_(i);return e.right<0||e.left>document.documentElement.scrollWidth||e.bottom<0||e.top>document.documentElement.scrollHeight}var Pa;function Rm(){Be(function(){return"resetting indexes cache"}),Pa=new Map}Rm();function E6(i){var e=Array.from(i.children).findIndex(function(t){return t.getAttribute(Dm)});if(e>=0)return Pa.has(i)||Pa.set(i,new Map),Pa.get(i).set(e,e_(i.children[e])),e}function T6(i,e){if(!qb(i,e))return null;var t=e.children;if(t.length===0)return{index:0,isProximityBased:!0};for(var n=E6(e),r=0;r1&&arguments[1]!==void 0?arguments[1]:0;return i.parentElement?n_(i.parentElement,e+1):e-1}function A6(i,e){if(Object.keys(i).length!==Object.keys(e).length)return!1;for(var t in i)if(!{}.hasOwnProperty.call(e,t)||e[t]!==i[t])return!1;return!0}function D6(i,e){if(i.length!==e.length)return!1;for(var t=0;t2&&arguments[2]!==void 0?arguments[2]:Q6,n=arguments.length>3?arguments[3]:void 0,r,s,o=!1,a,l=Array.from(e).sort(function(u,f){return Ef(f)-Ef(u)});function c(){var u=Yl(i),f=n.multiScrollIfNeeded();if(!f&&a&&Math.abs(a.x-u.x)o.clientHeight&&(a.bottomo.clientWidth&&(a.right0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0;Be(function(){return"creating multi-scroller"});var t=z6(i),n=Array.from(t).sort(function(a,l){return Ef(l)-Ef(a)}),r=I6(),s=r.scrollIfNeeded;function o(){var a=e();if(!a||!n)return!1;for(var l=n.filter(function(f){return Nf(a,f.getBoundingClientRect())||f===document.scrollingElement}),c=0;c0?o:function(){return!1}}}function Z6(i){if(!i)return[];for(var e=[],t=i;t;){var n=window.getComputedStyle(t),r=n.overflow;r.split(" ").some(function(s){return s.includes("auto")||s.includes("scroll")})&&e.push(t),t=t.parentElement}return e}function z6(i){var e=new Set,t=Kl(i),n;try{for(t.s();!(n=t.n()).done;){var r=n.value;Z6(r).forEach(function(s){return e.add(s)})}}catch(s){t.e(s)}finally{t.f()}return(document.scrollingElement.scrollHeight>document.scrollingElement.clientHeight||document.scrollingElement.scrollWidth>document.scrollingElement.clientHeight)&&e.add(document.scrollingElement),e}function q6(i){var e=i.cloneNode(!0),t=[],n=i.tagName==="SELECT",r=n?[i]:Zn(i.querySelectorAll("select")),s=Kl(r),o;try{for(s.s();!(o=s.n()).done;){var a=o.value;t.push(a.value)}}catch(S){s.e(S)}finally{s.f()}if(r.length>0)for(var l=n?[e]:Zn(e.querySelectorAll("select")),c=0;c0)for(var m=h?[e]:Zn(e.querySelectorAll("canvas")),g=0;g1&&arguments[1]!==void 0?arguments[1]:function(){},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};i.forEach(function(n){var r=e(n);Object.keys(r).forEach(function(s){n.style[s]=r[s]}),t(n).forEach(function(s){return n.classList.add(s)})})}function Tf(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};i.forEach(function(n){var r=e(n);Object.keys(r).forEach(function(s){n.style[s]=""}),t(n).forEach(function(s){return n.classList.contains(s)&&n.classList.remove(s)})})}function Y6(i){var e=i.style.minHeight;i.style.minHeight=window.getComputedStyle(i).getPropertyValue("height");var t=i.style.minWidth;return i.style.minWidth=window.getComputedStyle(i).getPropertyValue("width"),function(){i.style.minHeight=e,i.style.minWidth=t}}var H6="--any--",G6=100,K6=20,$b=3,Fb={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Bb="data-is-dnd-original-dragged-item",or,Pi,fn,jf,Wt,Zf,zs,xi,js,wn,Do=!1,Mm=!1,Im,tc=!1,Xl=[],cr=new Map,li=new Map,bm=new WeakMap;function J6(i,e){Be(function(){return"registering drop-zone if absent"}),cr.has(e)||cr.set(e,new Set),cr.get(e).has(i)||(cr.get(e).add(i),Kb())}function Vb(i,e){cr.get(e).delete(i),Jb(),cr.get(e).size===0&&cr.delete(e)}function e7(){Be(function(){return"watching dragged element"});var i=cr.get(jf),e=Kl(i),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;n.addEventListener(Rf,a_),n.addEventListener(Jl,l_),n.addEventListener(Mf,c_)}}catch(a){e.e(a)}finally{e.f()}window.addEventListener(Am,Aa);var r=Math.max.apply(Math,Zn(Array.from(i.keys()).map(function(a){return li.get(a).dropAnimationDurationMs}))),s=r===0?K6:Math.max(r,G6),o=j6(i,function(){return wn});R6(Pi,i,s*1.07,o)}function t7(){Be(function(){return"unwatching dragged element"});var i=cr.get(jf),e=Kl(i),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;n.removeEventListener(Rf,a_),n.removeEventListener(Jl,l_),n.removeEventListener(Mf,c_)}}catch(r){e.e(r)}finally{e.f()}window.removeEventListener(Am,Aa),M6()}function zf(i){return i.findIndex(function(e){return!!e[If]})}function i7(i){var e;return Pf(Pf({},i),{},(e={},Ea(e,If,!0),Ea(e,bi,ec),e))}function a_(i){Be(function(){return["dragged entered",i.currentTarget,i.detail]});var e=li.get(i.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&i.currentTarget!==Wt){Be(function(){return"ignoring dragged entered because drop is currently disabled"});return}if(tc=!1,t=t.filter(function(u){return u[bi]!==zs[bi]}),Be(function(){return"dragged entered items ".concat(Nr(t))}),Wt!==i.currentTarget){var r=li.get(Wt).items,s=r.filter(function(u){return!u[If]});qs(Wt,s,{trigger:Xi.DRAGGED_ENTERED_ANOTHER,id:fn[bi],source:dn.POINTER})}var o=i.detail.indexObj,a=o.index,l=o.isProximityBased,c=l&&a===i.currentTarget.children.length-1?a+1:a;xi=i.currentTarget,t.splice(c,0,zs),qs(i.currentTarget,t,{trigger:Xi.DRAGGED_ENTERED,id:fn[bi],source:dn.POINTER})}function l_(i){if(Do){Be(function(){return["dragged left",i.currentTarget,i.detail]});var e=li.get(i.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&i.currentTarget!==Wt&&i.currentTarget!==xi){Be(function(){return"drop is currently disabled"});return}var r=Zn(t),s=zf(r);s!==-1&&r.splice(s,1);var o=xi;xi=void 0;var a=i.detail,l=a.type,c=a.theOtherDz;if(l===Cf.OUTSIDE_OF_ANY||l===Cf.LEFT_FOR_ANOTHER&&c!==Wt&&li.get(c).dropFromOthersDisabled){Be(function(){return"dragged left all, putting shadow element back in the origin dz"}),tc=!0,xi=Wt;var u=o===Wt?r:Zn(li.get(Wt).items);u.splice(Zf,0,zs),qs(Wt,u,{trigger:Xi.DRAGGED_LEFT_ALL,id:fn[bi],source:dn.POINTER})}qs(i.currentTarget,r,{trigger:Xi.DRAGGED_LEFT,id:fn[bi],source:dn.POINTER})}}function c_(i){Be(function(){return["dragged is over index",i.currentTarget,i.detail]});var e=li.get(i.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&i.currentTarget!==Wt){Be(function(){return"drop is currently disabled"});return}var r=Zn(t);tc=!1;var s=i.detail.indexObj.index,o=zf(r);o!==-1&&r.splice(o,1),r.splice(s,0,zs),qs(i.currentTarget,r,{trigger:Xi.DRAGGED_OVER_INDEX,id:fn[bi],source:dn.POINTER})}function Af(i){i.preventDefault();var e=i.touches?i.touches[0]:i;wn={x:e.clientX,y:e.clientY},Pi.style.transform="translate3d(".concat(wn.x-js.x,"px, ").concat(wn.y-js.y,"px, 0)")}function Aa(){Be(function(){return"dropped"}),Mm=!0,window.removeEventListener("mousemove",Af),window.removeEventListener("touchmove",Af),window.removeEventListener("mouseup",Aa),window.removeEventListener("touchend",Aa),t7(),B6(Pi),xi||(Be(function(){return"element was dropped right after it left origin but before entering somewhere else"}),xi=Wt),Be(function(){return["dropped in dz",xi]});var i=li.get(xi),e=i.items,t=i.type;Tf(cr.get(t),function(s){return li.get(s).dropTargetStyle},function(s){return li.get(s).dropTargetClasses});var n=zf(e);n===-1&&xi===Wt&&(n=Zf),e=e.map(function(s){return s[If]?fn:s});function r(){Im(),Ta(xi,e,{trigger:tc?Xi.DROPPED_OUTSIDE_OF_ANY:Xi.DROPPED_INTO_ZONE,id:fn[bi],source:dn.POINTER}),xi!==Wt&&Ta(Wt,li.get(Wt).items,{trigger:Xi.DROPPED_INTO_ANOTHER,id:fn[bi],source:dn.POINTER}),n!==-1&&U6(xi.children[n]),s7()}n7(n,r)}function n7(i,e){var t=i>-1?km(xi.children[i]):km(xi),n={x:t.left-parseFloat(Pi.style.left),y:t.top-parseFloat(Pi.style.top)},r=li.get(xi),s=r.dropAnimationDurationMs,o="transform ".concat(s,"ms ease");Pi.style.transition=Pi.style.transition?Pi.style.transition+","+o:o,Pi.style.transform="translate3d(".concat(n.x,"px, ").concat(n.y,"px, 0)"),window.setTimeout(e,s)}function r7(i,e){Xl.push({dz:i,destroy:e}),window.requestAnimationFrame(function(){o_(i),document.body.appendChild(i)})}function s7(){Pi.remove(),or.remove(),Xl.length&&(Be(function(){return["will destroy zones that were removed during drag",Xl]}),Xl.forEach(function(i){var e=i.dz,t=i.destroy;t(),e.remove()}),Xl=[]),Pi=void 0,or=void 0,fn=void 0,jf=void 0,Wt=void 0,Zf=void 0,zs=void 0,xi=void 0,js=void 0,wn=void 0,Do=!1,Mm=!1,Im=void 0,tc=!1}function o7(i,e){var t=!1,n={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:Fb,dropTargetClasses:[],transformDraggedElement:function(){},centreDraggedOnCursor:!1};Be(function(){return["dndzone good to go options: ".concat(Nr(e),", config: ").concat(Nr(n)),{node:i}]});var r=new Map;function s(){window.addEventListener("mousemove",l,{passive:!1}),window.addEventListener("touchmove",l,{passive:!1,capture:!1}),window.addEventListener("mouseup",a,{passive:!1}),window.addEventListener("touchend",a,{passive:!1})}function o(){window.removeEventListener("mousemove",l),window.removeEventListener("touchmove",l),window.removeEventListener("mouseup",a),window.removeEventListener("touchend",a)}function a(d){o(),or=void 0,js=void 0,wn=void 0,d.type==="touchend"&&d.target.click()}function l(d){d.preventDefault();var h=d.touches?d.touches[0]:d;wn={x:h.clientX,y:h.clientY},(Math.abs(wn.x-js.x)>=$b||Math.abs(wn.y-js.y)>=$b)&&(o(),u())}function c(d){if(d.target!==d.currentTarget&&(d.target.value!==void 0||d.target.isContentEditable)){Be(function(){return"won't initiate drag on a nested input element"});return}if(d.button){Be(function(){return"ignoring none left click button: ".concat(d.button)});return}if(Do){Be(function(){return"cannot start a new drag before finalizing previous one"});return}d.preventDefault(),d.stopPropagation();var h=d.touches?d.touches[0]:d;js={x:h.clientX,y:h.clientY},wn=Pf({},js),or=d.currentTarget,s()}function u(){Be(function(){return["drag start config: ".concat(Nr(n)),or]}),Do=!0;var d=r.get(or);Zf=d,Wt=or.parentElement;var h=Wt.closest("dialog")||Wt.getRootNode(),p=h.body||h,m=n.items,g=n.type,O=n.centreDraggedOnCursor,w=Zn(m);fn=w[d],jf=g,zs=i7(fn),Pi=F6(or,O&&wn),or.setAttribute(Bb,!0);function S(){Pi.parentElement?window.requestAnimationFrame(S):(p.appendChild(Pi),Pi.focus(),e7(),o_(or),p.appendChild(or),zs[bi]=fn[bi])}window.requestAnimationFrame(S),xf(Array.from(cr.get(n.type)).filter(function(C){return C===Wt||!li.get(C).dropFromOthersDisabled}),function(C){return li.get(C).dropTargetStyle},function(C){return li.get(C).dropTargetClasses}),w.splice(d,1,zs),Im=Y6(Wt),qs(Wt,w,{trigger:Xi.DRAG_STARTED,id:fn[bi],source:dn.POINTER}),window.addEventListener("mousemove",Af,{passive:!1}),window.addEventListener("touchmove",Af,{passive:!1,capture:!1}),window.addEventListener("mouseup",Aa,{passive:!1}),window.addEventListener("touchend",Aa,{passive:!1})}function f(d){var h=d.items,p=h===void 0?void 0:h,m=d.flipDurationMs,g=m===void 0?0:m,O=d.type,w=O===void 0?H6:O,S=d.dragDisabled,C=S===void 0?!1:S,k=d.morphDisabled,_=k===void 0?!1:k,P=d.dropFromOthersDisabled,x=P===void 0?!1:P,R=d.dropTargetStyle,Z=R===void 0?Fb:R,Q=d.dropTargetClasses,D=Q===void 0?[]:Q,E=d.transformDraggedElement,j=E===void 0?function(){}:E,z=d.centreDraggedOnCursor,q=z===void 0?!1:z;n.dropAnimationDurationMs=g,n.type&&w!==n.type&&Vb(i,n.type),n.type=w,n.items=Zn(p),n.dragDisabled=C,n.morphDisabled=_,n.transformDraggedElement=j,n.centreDraggedOnCursor=q,t&&Do&&!Mm&&(!A6(Z,n.dropTargetStyle)||!D6(D,n.dropTargetClasses))&&(Tf([i],function(){return n.dropTargetStyle},function(){return D}),xf([i],function(){return Z},function(){return D})),n.dropTargetStyle=Z,n.dropTargetClasses=Zn(D);function G(ue,B){return li.get(ue)?li.get(ue)[B]:n[B]}t&&Do&&n.dropFromOthersDisabled!==x&&(x?Tf([i],function(ue){return G(ue,"dropTargetStyle")},function(ue){return G(ue,"dropTargetClasses")}):xf([i],function(ue){return G(ue,"dropTargetStyle")},function(ue){return G(ue,"dropTargetClasses")})),n.dropFromOthersDisabled=x,li.set(i,n),J6(i,w);for(var Y=zf(n.items),ce=0;ce".concat(e,"

"),t.style.display="none",t.style.position="fixed",t.style.zIndex="-5",t}function Ca(i){if(!Qm){ai||Pm(),ai.innerHTML="";var e=document.createTextNode(i);ai.appendChild(e),ai.style.display="none",ai.style.display="inline"}}var f7="--any--",Wb={outline:"rgba(255, 255, 102, 0.7) solid 2px"},jn=!1,Cm,Ii,Qo="",Ao,ar,Zs="",Df=new WeakSet,Xb=new WeakMap,Ub=new WeakMap,Em=new Map,Si=new Map,lr=new Map,Qf;function d7(i,e){Be(function(){return"registering drop-zone if absent"}),lr.size===0&&(Be(function(){return"adding global keydown and click handlers"}),Qf=l7(),window.addEventListener("keydown",f_),window.addEventListener("click",d_)),lr.has(e)||lr.set(e,new Set),lr.get(e).has(i)||(lr.get(e).add(i),Kb())}function Yb(i,e){Be(function(){return"unregistering drop-zone"}),Ii===i&&Gl(),lr.get(e).delete(i),Jb(),lr.get(e).size===0&&lr.delete(e),lr.size===0&&(Be(function(){return"removing global keydown and click handlers"}),window.removeEventListener("keydown",f_),window.removeEventListener("click",d_),Qf=void 0,c7())}function f_(i){if(jn)switch(i.key){case"Escape":{Gl();break}}}function d_(){jn&&(Df.has(document.activeElement)||(Be(function(){return"clicked outside of any draggable"}),Gl()))}function h7(i){if(Be(function(){return"zone focus"}),!!jn){var e=i.currentTarget;if(e!==Ii){Qo=e.getAttribute("aria-label")||"";var t=Si.get(Ii),n=t.items,r=n.find(function(f){return f[bi]===ar}),s=n.indexOf(r),o=n.splice(s,1)[0],a=Si.get(e),l=a.items,c=a.autoAriaDisabled;e.getBoundingClientRect().top0&&arguments[0]!==void 0?arguments[0]:!0;Be(function(){return"drop"}),Si.get(Ii).autoAriaDisabled||Ca("Stopped dragging item ".concat(Zs)),Df.has(document.activeElement)&&document.activeElement.blur(),i&&qs(Ii,Si.get(Ii).items,{trigger:Xi.DRAG_STOPPED,id:ar,source:dn.KEYBOARD}),Tf(lr.get(Cm),function(e){return Si.get(e).dropTargetStyle},function(e){return Si.get(e).dropTargetClasses}),Ao=null,ar=null,Zs="",Cm=null,Ii=null,Qo="",jn=!1,h_()}function p7(i,e){var t={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,zoneItemTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:Wb,dropTargetClasses:[],autoAriaDisabled:!1};function n(u,f,d){u.length<=1||u.splice(d,1,u.splice(f,1,u[d])[0])}function r(u){switch(Be(function(){return["handling key down",u.key]}),u.key){case"Enter":case" ":{if((u.target.disabled!==void 0||u.target.href||u.target.isContentEditable)&&!Df.has(u.target))return;u.preventDefault(),u.stopPropagation(),jn?Gl():s(u);break}case"ArrowDown":case"ArrowRight":{if(!jn)return;u.preventDefault(),u.stopPropagation();var f=Si.get(i),d=f.items,h=Array.from(i.children),p=h.indexOf(u.currentTarget);Be(function(){return["arrow down",p]}),p0&&(t.autoAriaDisabled||Ca("Moved item ".concat(Zs," to position ").concat(w," in the list ").concat(Qo)),n(g,w,w-1),Ta(i,g,{trigger:Xi.DROPPED_INTO_ZONE,id:ar,source:dn.KEYBOARD}));break}}}function s(u){Be(function(){return"drag start"}),a(u.currentTarget),Ii=i,Cm=t.type,jn=!0;var f=Array.from(lr.get(t.type)).filter(function(h){return h===Ii||!Si.get(h).dropFromOthersDisabled});if(xf(f,function(h){return Si.get(h).dropTargetStyle},function(h){return Si.get(h).dropTargetClasses}),!t.autoAriaDisabled){var d="Started dragging item ".concat(Zs,". Use the arrow keys to move it within its list ").concat(Qo);f.length>1&&(d+=", or tab to another list in order to move the item into it"),Ca(d)}qs(i,Si.get(i).items,{trigger:Xi.DRAG_STARTED,id:ar,source:dn.KEYBOARD}),h_()}function o(u){jn&&u.currentTarget!==Ao&&(u.stopPropagation(),Gl(!1),s(u))}function a(u){var f=Si.get(i),d=f.items,h=Array.from(i.children),p=h.indexOf(u);Ao=u,Ao.tabIndex=t.zoneItemTabIndex,ar=d[p][bi],Zs=h[p].getAttribute("aria-label")||""}function l(u){var f=u.items,d=f===void 0?[]:f,h=u.type,p=h===void 0?f7:h,m=u.dragDisabled,g=m===void 0?!1:m,O=u.zoneTabIndex,w=O===void 0?0:O,S=u.zoneItemTabIndex,C=S===void 0?0:S,k=u.dropFromOthersDisabled,_=k===void 0?!1:k,P=u.dropTargetStyle,x=P===void 0?Wb:P,R=u.dropTargetClasses,Z=R===void 0?[]:R,Q=u.autoAriaDisabled,D=Q===void 0?!1:Q;t.items=Zn(d),t.dragDisabled=g,t.dropFromOthersDisabled=_,t.zoneTabIndex=w,t.zoneItemTabIndex=C,t.dropTargetStyle=x,t.dropTargetClasses=Z,t.autoAriaDisabled=D,t.type&&p!==t.type&&Yb(i,t.type),t.type=p,d7(i,p),D||(i.setAttribute("aria-disabled",g),i.setAttribute("role","list"),i.setAttribute("aria-describedby",g?Qf.DND_ZONE_DRAG_DISABLED:Qf.DND_ZONE_ACTIVE)),Si.set(i,t),jn?i.tabIndex=i===Ii||Ao.contains(i)||t.dropFromOthersDisabled||Ii&&t.type!==Si.get(Ii).type?-1:0:i.tabIndex=t.zoneTabIndex,i.addEventListener("focus",h7);for(var E=function(q){var G=i.children[q];Df.add(G),G.tabIndex=jn?-1:t.zoneItemTabIndex,D||G.setAttribute("role","listitem"),G.removeEventListener("keydown",Xb.get(G)),G.removeEventListener("click",Ub.get(G)),g||(G.addEventListener("keydown",r),Xb.set(G,r),G.addEventListener("click",o),Ub.set(G,o)),jn&&t.items[q][bi]===ar&&(Be(function(){return["focusing on",{i:q,focusedItemId:ar}]}),Ao=G,Ao.tabIndex=t.zoneItemTabIndex,G.focus())},j=0;j0&&console.warn("dndzone will ignore unknown options",p),!e)throw new Error("no 'items' key provided to dndzone");var m=e.find(function(g){return!{}.hasOwnProperty.call(g,bi)});if(m)throw new Error("missing '".concat(bi,"' property for item ").concat(Nr(m)));if(u&&!Array.isArray(u))throw new Error("dropTargetClasses should be an array but instead it is a ".concat(Ul(u),", ").concat(Nr(u)));if(a&&!Gb(a))throw new Error("zoneTabIndex should be a number but instead it is a ".concat(Ul(a),", ").concat(Nr(a)));if(l&&!Gb(l))throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(Ul(l),", ").concat(Nr(l)))}function Gb(i){return!isNaN(i)&&function(e){return(e|0)===e}(parseFloat(i))}function Da(i){let e=i-1;return e*e*e+1}function jr(i,{from:e,to:t},n={}){let r=getComputedStyle(i),s=r.transform==="none"?"":r.transform,[o,a]=r.transformOrigin.split(" ").map(parseFloat),l=e.left+e.width*o/t.width-(t.left+o),c=e.top+e.height*a/t.height-(t.top+a),{delay:u=0,duration:f=h=>Math.sqrt(h)*120,easing:d=Da}=n;return{delay:u,duration:Ge(f)?f(Math.sqrt(l*l+c*c)):f,easing:d,css:(h,p)=>{let m=p*l,g=p*c,O=h+p*e.width/t.width,w=h+p*e.height/t.height;return`transform: ${s} translate(${m}px, ${g}px) scale(${O}, ${w});`}}}function O7(i){se(i,"svelte-mzbbdu",".no-creatures.svelte-mzbbdu{margin:1rem;text-align:center}.initiative-tracker-table.svelte-mzbbdu{padding:0.5rem;align-items:center;gap:0.25rem 0.5rem;width:100%;margin-left:0rem;table-layout:fixed;border-collapse:separate;border-spacing:0 2px}.left.svelte-mzbbdu{text-align:left}.center.svelte-mzbbdu{text-align:center}.tracker-table-header.svelte-mzbbdu{font-weight:bolder;display:contents}.initiative-tracker-creature.svelte-mzbbdu{position:relative}.initiative-tracker-creature.active.svelte-mzbbdu{background-color:rgba(0, 0, 0, 0.1)}.theme-dark .initiative-tracker-creature.active.svelte-mzbbdu{background-color:rgba(255, 255, 255, 0.1)}.initiative-tracker-creature.disabled.svelte-mzbbdu *{color:var(--text-faint)}.initiative-tracker-creature.svelte-mzbbdu td{border-top:1px solid transparent;border-bottom:1px solid transparent}.initiative-tracker-creature.svelte-mzbbdu td:first-child{border-left:1px solid transparent}.initiative-tracker-creature.svelte-mzbbdu td:last-child{border-right:1px solid transparent}.initiative-tracker-creature.svelte-mzbbdu:hover td,.initiative-tracker-creature.viewing.svelte-mzbbdu td{border-top:1px solid var(--background-modifier-border);border-bottom:1px solid var(--background-modifier-border)}.initiative-tracker-creature.svelte-mzbbdu:hover td:first-child,.initiative-tracker-creature.viewing.svelte-mzbbdu td:first-child{border-left:1px solid var(--background-modifier-border)}.initiative-tracker-creature.svelte-mzbbdu:hover td:last-child,.initiative-tracker-creature.viewing.svelte-mzbbdu td:last-child{border-right:1px solid var(--background-modifier-border)}")}function p_(i,e,t){let n=i.slice();return n[19]=e[t].creature,n[20]=e[t].id,n}function v7(i){let e;return{c(){e=b("div"),e.innerHTML="

Add a creature to get started!

Players may be created in settings.",v(e,"class","no-creatures svelte-mzbbdu")},m(t,n){A(t,e,n)},p:X,i:X,o:X,d(t){t&&T(e)}}}function y7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=[],O=new Map,w,S,C,k,_=fe(i[1]),P=x=>x[20];for(let x=0;x<_.length;x+=1){let R=p_(i,_,x),Z=P(R);O.set(Z,g[x]=m_(Z,R))}return{c(){e=b("thead"),t=b("td"),r=M(),s=b("th"),s.textContent="Name",o=M(),a=b("th"),c=M(),u=b("th"),d=M(),h=b("th"),p=M(),m=b("tbody");for(let x=0;x{o[u]=null}),De(),n=o[t],n?n.p(l,c):(n=o[t]=s[t](l),n.c()),$(n,1),n.m(e,null))},i(l){r||($(n),r=!0)},o(l){V(n),r=!1},d(l){l&&T(e),o[t].d()}}}var Nm=300;function _7(i,e,t){let n,r,s,o;Se(i,he,_=>t(18,r=_));let a=Ue("plugin"),{state:l,ordered:c}=he;Se(i,l,_=>t(2,o=_)),Se(i,c,_=>t(0,s=_));let u=Fe(),f=_=>{(0,ic.setIcon)(_,an)},d=_=>{(0,ic.setIcon)(_,ir)};function h(_){t(1,n=_.detail.items)}function p(_){if(_.detail.items.length>1){let P=_.detail.items.find(({id:R})=>R==_.detail.info.id),x=_.detail.items.findIndex(R=>R.id==_.detail.info.id);x==_.detail.items.length-1?P.creature.initiative=_.detail.items[x-1].creature.initiative:P.creature.initiative=_.detail.items[x+1].creature.initiative,he.logNewInitiative(P.creature)}t(1,n=_.detail.items),Ke(he,r=[...n.map(({creature:P},x)=>(P.manualOrder=x,P))],r)}let m=_=>{new ic.ExtraButtonComponent(_).setIcon(Qs)},g=_=>he.roll(a);function O(_){ht.call(this,i,_)}function w(_){ht.call(this,i,_)}function S(_){ht.call(this,i,_)}function C(_){ht.call(this,i,_)}let k=(_,P)=>{u("open-combatant",{creature:_,newLeaf:P.ctrlKey||P.metaKey}),P.stopPropagation()};return i.$$.update=()=>{i.$$.dirty&1&&t(1,n=[...s].map(_=>({creature:_,id:xt()})))},[s,n,o,a,l,c,u,f,d,h,p,m,g,O,w,S,C,k]}var jm=class extends ne{constructor(e){super(),re(this,e,_7,b7,ie,{},O7)}},g_=jm;function Qa(i){return Object.prototype.toString.call(i)==="[object Date]"}function Zm(i,e,t,n){if(typeof t=="number"||Qa(t)){let r=n-t,s=(t-e)/(i.dt||1/60),o=i.opts.stiffness*r,a=i.opts.damping*s,l=(o-a)*i.inv_mass,c=(s+l)*i.dt;return Math.abs(c)Zm(i,e[s],t[s],n[s]));if(typeof t=="object"){let r={};for(let s in t)r[s]=Zm(i,e[s],t[s],n[s]);return r}else throw new Error(`Cannot spring ${typeof t} values`)}}function O_(i,e={}){let t=$e(i),{stiffness:n=.15,damping:r=.8,precision:s=.01}=e,o,a,l,c=i,u=i,f=1,d=0,h=!1;function p(g,O={}){u=g;let w=l={};return i==null||O.hard||m.stiffness>=1&&m.damping>=1?(h=!0,o=ds(),c=g,t.set(i=u),Promise.resolve()):(O.soft&&(d=1/((O.soft===!0?.5:+O.soft)*60),f=0),a||(o=ds(),h=!1,a=Rs(S=>{if(h)return h=!1,a=null,!1;f=Math.min(f+d,1);let C={inv_mass:f,opts:m,settled:!0,dt:(S-o)*60/1e3},k=Zm(C,c,i,u);return o=S,c=i,t.set(i=k),C.settled&&(a=null),!C.settled})),new Promise(S=>{a.promise.then(()=>{w===l&&S()})}))}let m={set:p,update:(g,O)=>p(g(u,i),O),subscribe:t.subscribe,stiffness:n,damping:r,precision:s};return m}function zm(i,e){if(i===e||i!==i)return()=>i;let t=typeof i;if(t!==typeof e||Array.isArray(i)!==Array.isArray(e))throw new Error("Cannot interpolate values of different type");if(Array.isArray(i)){let n=e.map((r,s)=>zm(i[s],r));return r=>n.map(s=>s(r))}if(t==="object"){if(!i||!e)throw new Error("Object cannot be null");if(Qa(i)&&Qa(e)){i=i.getTime(),e=e.getTime();let s=e-i;return o=>new Date(i+o*s)}let n=Object.keys(e),r={};return n.forEach(s=>{r[s]=zm(i[s],e[s])}),s=>{let o={};return n.forEach(a=>{o[a]=r[a](s)}),o}}if(t==="number"){let n=e-i;return r=>i+r*n}throw new Error(`Cannot interpolate ${t} values`)}function v_(i,e={}){let t=$e(i),n,r=i;function s(o,a){if(i==null)return t.set(i=o),Promise.resolve();r=o;let l=n,c=!1,{delay:u=0,duration:f=400,easing:d=Nn,interpolate:h=zm}=ti(ti({},e),a);if(f===0)return l&&(l.abort(),l=null),t.set(i=r),Promise.resolve();let p=ds()+u,m;return n=Rs(g=>{if(gf?(t.set(i=o),!1):(t.set(i=m(d(O/f))),!0)}),n.promise}return{set:s,update:(o,a)=>s(o(r,i),a),subscribe:t.subscribe}}function w7(i){se(i,"svelte-137y560",".difficulty-bar-container.svelte-137y560{display:grid;grid-template-columns:auto 1fr auto;gap:0.5rem;align-items:center;padding:0 0.5rem;margin-bottom:0.5rem;width:100%}.difficulty-bar.svelte-137y560{width:100%;border:1px solid #ccc;border-radius:3px}")}function k7(i){let e,t,n=(i[0].labels?.[0]??"")+"",r,s,o,a,l,c,u=(i[0].labels?.last()??"")+"",f;return{c(){e=b("div"),t=b("span"),r=ae(n),s=M(),o=b("span"),a=b("meter"),l=M(),c=b("span"),f=ae(u),v(a,"class","difficulty-bar svelte-137y560"),v(a,"min","0"),v(a,"low","0.33"),v(a,"high","0.66"),v(a,"optimum","0"),a.value=i[2],v(e,"class","difficulty-bar-container svelte-137y560"),v(e,"aria-label",i[1])},m(d,h){A(d,e,h),y(e,t),y(t,r),y(e,s),y(e,o),y(o,a),y(e,l),y(e,c),y(c,f)},p(d,[h]){h&1&&n!==(n=(d[0].labels?.[0]??"")+"")&&me(r,n),h&4&&(a.value=d[2]),h&1&&u!==(u=(d[0].labels?.last()??"")+"")&&me(f,u),h&2&&v(e,"aria-label",d[1])},i:X,o:X,d(d){d&&T(e)}}}function S7(i,e,t){let n,r,s,{difficulty:o}=he,a=Ue("plugin"),l=o(a);Se(i,l,u=>t(0,r=u));let c=v_(0,{duration:400,easing:Da});return Se(i,c,u=>t(2,s=u)),i.$$.update=()=>{i.$$.dirty&1&&r.thresholds.last().minValue>0&&c.set(Math.min(r.difficulty.value/r.thresholds.last().minValue,1)),i.$$.dirty&1&&t(1,n=r.difficulty.summary)},[r,n,s,l,c]}var qm=class extends ne{constructor(e){super(),re(this,e,S7,k7,ie,{},w7)}},y_=qm;function x7(i){se(i,"svelte-1uuf6mm",".initiave-tracker-party.svelte-1uuf6mm{padding:0 0.5rem;margin:0}.initiative-tracker-name-container.svelte-1uuf6mm{display:flex;justify-content:space-between;align-items:center;padding:0 0.5rem;margin:0;margin-bottom:0.5rem}.initiative-tracker-name.svelte-1uuf6mm{margin:0}.initiative-tracker-round-container.svelte-1uuf6mm{padding:0 0.5rem}")}function b_(i){let e,t;return{c(){e=b("h2"),t=ae(i[0]),v(e,"class","initiative-tracker-name svelte-1uuf6mm")},m(n,r){A(n,e,r),y(e,t)},p(n,r){r&1&&me(t,n[0])},d(n){n&&T(e)}}}function __(i){let e,t=i[9].formatDifficultyValue(i[1]?.difficulty?.value,!0)+"",n;return{c(){e=b("span"),n=ae(t),v(e,"class","initiative-tracker-xp encounter-xp")},m(r,s){A(r,e,s),y(e,n)},p(r,s){s&2&&t!==(t=r[9].formatDifficultyValue(r[1]?.difficulty?.value,!0)+"")&&me(n,t)},d(r){r&&T(e)}}}function w_(i){let e,t;return e=new y_({}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function k_(i){let e,t;return{c(){e=b("h4"),t=ae(i[2]),v(e,"class","initiave-tracker-party svelte-1uuf6mm")},m(n,r){A(n,e,r),y(e,t)},p(n,r){r&4&&me(t,n[2])},d(n){n&&T(e)}}}function S_(i){let e,t,n,r,s;return{c(){e=b("div"),t=b("small"),n=b("em"),r=ae("Round "),s=ae(i[4]),v(e,"class","initiative-tracker-round-container svelte-1uuf6mm")},m(o,a){A(o,e,a),y(e,t),y(t,n),y(n,r),y(n,s)},p(o,a){a&16&&me(s,o[4])},d(o){o&&T(e)}}}function P7(i){let e,t,n,r,s,o,a,l=i[0]&&i[0].length&&b_(i),c=i[1]?.difficulty?.value>0&&__(i),u=i[1]&&w_(i),f=i[2]&&k_(i),d=i[3]&&S_(i);return{c(){e=b("div"),t=b("div"),l&&l.c(),n=M(),c&&c.c(),r=M(),u&&u.c(),s=M(),f&&f.c(),o=M(),d&&d.c(),v(t,"class","initiative-tracker-name-container svelte-1uuf6mm"),v(e,"class","initiatie-tracker-metadata")},m(h,p){A(h,e,p),y(e,t),l&&l.m(t,null),y(t,n),c&&c.m(t,null),y(e,r),u&&u.m(e,null),y(e,s),f&&f.m(e,null),y(e,o),d&&d.m(e,null),a=!0},p(h,[p]){h[0]&&h[0].length?l?l.p(h,p):(l=b_(h),l.c(),l.m(t,n)):l&&(l.d(1),l=null),h[1]?.difficulty?.value>0?c?c.p(h,p):(c=__(h),c.c(),c.m(t,null)):c&&(c.d(1),c=null),h[1]?u?p&2&&$(u,1):(u=w_(h),u.c(),$(u,1),u.m(e,s)):u&&(Ae(),V(u,1,1,()=>{u=null}),De()),h[2]?f?f.p(h,p):(f=k_(h),f.c(),f.m(e,o)):f&&(f.d(1),f=null),h[3]?d?d.p(h,p):(d=S_(h),d.c(),d.m(e,null)):d&&(d.d(1),d=null)},i(h){a||($(u),a=!0)},o(h){V(u),a=!1},d(h){h&&T(e),l&&l.d(),c&&c.d(),u&&u.d(),f&&f.d(),d&&d.d()}}}function C7(i,e,t){let n,r,s,o,a,{state:l,name:c,round:u,party:f,difficulty:d}=he;Se(i,l,g=>t(3,o=g)),Se(i,c,g=>t(0,n=g)),Se(i,u,g=>t(4,a=g)),Se(i,f,g=>t(2,s=g));let h=Ue("plugin"),p=ki(h),m=d(h);return Se(i,m,g=>t(1,r=g)),[n,r,s,o,a,l,c,u,f,p,m]}var Lm=class extends ne{constructor(e){super(),re(this,e,C7,P7,ie,{},x7)}},x_=Lm;var $m=require("obsidian");function E7(i){se(i,"svelte-1ud8n4x",".saving-container.svelte-1ud8n4x.svelte-1ud8n4x{padding:0.5rem}.saving-encounter.svelte-1ud8n4x.svelte-1ud8n4x{display:flex;align-items:center;justify-content:space-between}.save-buttons.svelte-1ud8n4x.svelte-1ud8n4x{margin-top:1rem;display:flex;justify-content:flex-end;gap:1rem}.save-buttons.svelte-1ud8n4x>div.svelte-1ud8n4x{display:flex;align-items:center}.save-buttons.svelte-1ud8n4x .clickable-icon{margin:0}.save-buttons.svelte-1ud8n4x>.save.svelte-1ud8n4x .clickable-icon.is-disabled{cursor:not-allowed;color:var(--text-faint)}")}function P_(i){let e;return{c(){e=b("span"),e.innerHTML="An encounter by that name already exists. Are you sure?",v(e,"class","checking")},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function T7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=i[1]&&P_(i);return{c(){e=b("div"),t=b("div"),n=b("span"),n.textContent="Save encounter as:",r=M(),s=b("input"),o=M(),a=b("div"),g&&g.c(),l=M(),c=b("div"),f=M(),d=b("div"),v(s,"type","text"),v(t,"class","saving-encounter svelte-1ud8n4x"),v(c,"class","save svelte-1ud8n4x"),v(d,"class","cancel svelte-1ud8n4x"),v(a,"class","save-buttons svelte-1ud8n4x"),v(e,"class","saving-container svelte-1ud8n4x")},m(O,w){A(O,e,w),y(e,t),y(t,n),y(t,r),y(t,s),Xe(s,i[0]),y(e,o),y(e,a),g&&g.m(a,null),y(a,l),y(a,c),y(a,f),y(a,d),p||(m=[U(s,"input",i[6]),U(s,"input",i[3]),H(u=i[4].call(null,c)),H(h=i[5].call(null,d))],p=!0)},p(O,[w]){w&1&&s.value!==O[0]&&Xe(s,O[0]),O[1]?g||(g=P_(O),g.c(),g.m(a,l)):g&&(g.d(1),g=null)},i:X,o:X,d(O){O&&T(e),g&&g.d(),p=!1,de(m)}}}function A7(i,e,t){let n,{name:r}=he;Se(i,r,p=>t(8,n=p));let s=n,o=Ue("plugin"),a,l=()=>{s?.length&&a.disabled?a.setDisabled(!1):!s?.length&&!a.disabled&&a.setDisabled(!0)},c=!1,u=p=>{a=new $m.ExtraButtonComponent(p).setIcon(Al).setDisabled(!(s!=null&&s?.length>0)).onClick(async()=>{s&&s in o.data.encounters&&!c?t(1,c=!0):(o.addEncounter(s,{...he.getEncounterState(),name:s,rollHP:o.data.rollHP,timestamp:Date.now()}),await o.saveSettings(),f("cancel"))})},f=Fe(),d=p=>{new $m.ExtraButtonComponent(p).setIcon("cross").onClick(()=>{f("cancel")})};function h(){s=this.value,t(0,s)}return[s,c,r,l,u,d,h]}var Fm=class extends ne{constructor(e){super(),re(this,e,A7,T7,ie,{},E7)}},C_=Fm;var qf=require("obsidian");function D7(i){se(i,"svelte-vsvyan",".controls.svelte-vsvyan.svelte-vsvyan{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid var(--background-modifier-border)}.controls.svelte-vsvyan h4.svelte-vsvyan{margin:0}.loading-container.svelte-vsvyan.svelte-vsvyan{display:flex;flex-flow:column nowrap;gap:0.5rem;padding:0.5rem;height:100%}.loading-container.svelte-vsvyan .clickable-icon{margin:0}.encounter-container.svelte-vsvyan.svelte-vsvyan{height:100%;display:flex;flex-flow:column nowrap;gap:1rem;overflow-y:auto}.no-encounters.svelte-vsvyan.svelte-vsvyan{color:var(--text-muted);display:flex;justify-content:center}.encounter.svelte-vsvyan.svelte-vsvyan{display:flex;justify-content:space-between;align-items:center}.encounter-controls.svelte-vsvyan.svelte-vsvyan{display:flex;align-items:center;gap:1rem}")}function E_(i,e,t){let n=i.slice();return n[7]=e[t],n}function T_(i){let e;return{c(){e=b("span"),e.innerHTML="There are no saved encounters.",v(e,"class","no-encounters svelte-vsvyan")},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function A_(i,e){let t,n,r=e[7]+"",s,o,a,l,c,u,f,d,h,p,m;return{key:i,first:null,c(){t=b("div"),n=b("span"),s=ae(r),o=M(),a=b("div"),l=b("div"),u=M(),f=b("div"),h=M(),v(a,"class","encounter-controls svelte-vsvyan"),v(t,"class","encounter svelte-vsvyan"),this.first=t},m(g,O){A(g,t,O),y(t,n),y(n,s),y(t,o),y(t,a),y(a,l),y(a,u),y(a,f),y(t,h),p||(m=[H(c=e[3].call(null,l,e[7])),H(d=e[4].call(null,f,e[7]))],p=!0)},p(g,O){e=g,O&1&&r!==(r=e[7]+"")&&me(s,r),c&&Ge(c.update)&&O&1&&c.update.call(null,e[7]),d&&Ge(d.update)&&O&1&&d.update.call(null,e[7])},d(g){g&&T(t),p=!1,de(m)}}}function Q7(i){let e,t,n,r,s,o,a,l,c=!i[0]||!Object.keys(i[0])?.length,u,f=[],d=new Map,h,p,m=c&&T_(i),g=fe(Object.keys(i[0])),O=w=>w[7];for(let w=0;w{new qf.ExtraButtonComponent(u).setIcon("cross").setTooltip("Cancel")},a=(u,f)=>{new qf.ExtraButtonComponent(u).setIcon("open-elsewhere-glyph").setTooltip("Load Encounter").onClick(()=>{he.new(s,n[f]),r("cancel")})},l=(u,f)=>{new qf.ExtraButtonComponent(u).setIcon("trash").setTooltip("Delete Encounter").onClick(()=>{s.removeEncounter(f),t(0,n=s.data.encounters)})},c=()=>r("cancel");return t(0,n=s.data.encounters),[n,r,o,a,l,c]}var Bm=class extends ne{constructor(e){super(),re(this,e,R7,Q7,ie,{},D7)}},D_=Bm;var Ia=require("obsidian");var ur=require("obsidian");function M7(i){se(i,"svelte-1u2coj9",".input.svelte-1u2coj9.svelte-1u2coj9{display:flex;align-items:center;gap:0.5rem}.is-disabled{cursor:not-allowed}.input-status.svelte-1u2coj9.svelte-1u2coj9{display:flex;justify-content:space-between}.input.svelte-1u2coj9>div.svelte-1u2coj9,.input-status.svelte-1u2coj9>div.svelte-1u2coj9,td.svelte-1u2coj9.svelte-1u2coj9:has(> svg),th.svelte-1u2coj9.svelte-1u2coj9:has(> svg){display:flex;align-items:center}.status-list.svelte-1u2coj9.svelte-1u2coj9{display:flex;margin:0.5rem 0 0.1rem 0}.status-list-entries.svelte-1u2coj9.svelte-1u2coj9{display:flex;flex-flow:row wrap;column-gap:0.25rem;margin:0 2rem 0 0.5rem}.left.svelte-1u2coj9.svelte-1u2coj9{text-align:left}.center.svelte-1u2coj9.svelte-1u2coj9{text-align:center}.updating-hp.svelte-1u2coj9.svelte-1u2coj9{display:flex;flex-flow:column;gap:0.5rem}.updating-container.svelte-1u2coj9.svelte-1u2coj9{display:flex;flex-flow:column nowrap;gap:0.5rem}.hp-status.svelte-1u2coj9.svelte-1u2coj9{display:flex;flex-flow:column}.updating-buttons.svelte-1u2coj9.svelte-1u2coj9{display:flex;justify-content:flex-end;gap:1rem;margin-right:0.7rem}td.svelte-1u2coj9>input.svelte-1u2coj9{margin:0}")}function Q_(i,e,t){let n=i.slice();return n[39]=e[t][0],n[40]=e[t][1],n[41]=e,n[42]=t,n}function R_(i,e,t){let n=i.slice();return n[0]=e[t],n}function I7(i){let e,t,n;return{c(){e=b("div")},m(r,s){A(r,e,s),t||(n=U(e,"load",i[36]),t=!0)},p:X,i:X,o:X,d(r){r&&T(e),t=!1,n()}}}function N7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,w,S,C,k,_=[Z7,j7],P=[];function x(D,E){return D[4]=="hp"?0:1}t=x(i,[-1,-1]),n=P[t]=_[t](i);let R=i[4]=="hp"&&N_(i),Z=fe([...i[6].entries()]),Q=[];for(let D=0;D{P[j]=null}),De(),n=P[t],n?n.p(D,E):(n=P[t]=_[t](D),n.c()),$(n,1),n.m(e,null)),D[4]=="hp"?R||(R=N_(D),R.c(),R.m(a,null)):R&&(R.d(1),R=null),E[0]&120){Z=fe([...D[6].entries()]);let z;for(z=0;z{E=null}),De())},i(j){x||($(E),x=!0)},o(j){V(E),x=!1},d(j){j&&T(e),Q&&Q.d(),D&&D.d(),E&&E.d(),R=!1,de(Z)}}}function z7(i){let e;return{c(){e=b("small"),e.textContent="Set AC",v(e,"class","label")},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function q7(i){let e;return{c(){e=b("small"),e.textContent="Apply damage, (-)healing, (t)temp HP, or (m)max HP",v(e,"class","label")},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function L7(i){let e;return{c(){e=b("small"),e.textContent=`Apply status effect to creatures that fail their saving throw`,v(e,"class","label")},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function M_(i){let e,t,n,r,s,o,a,l,c=fe(i[5]),u=[];for(let d=0;dV(u[d],1,1,()=>{u[d]=null});return{c(){e=b("div"),t=b("div"),r=M(),s=b("div");for(let d=0;d{o[u]=null}),De(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),$(t,1),t.m(n.parentNode,n))},i(l){r||($(t),r=!0)},o(l){V(t),r=!1},d(l){l&&T(n),o[e].d(l)}}}var F7=function(i){if(i.key==="Escape"){this.value="1";return}if(i.key==="Enter"){i.preventDefault();return}};function B7(i,e,t){let n,r,s,{updating:o,updateTarget:a}=he;Se(i,o,oe=>t(6,s=oe)),Se(i,a,oe=>t(4,n=oe));let l=Ue("plugin"),c=oe=>{(0,ur.setIcon)(oe,an)},u=oe=>{(0,ur.setIcon)(oe,ir)},f=oe=>{(0,ur.setIcon)(oe,Bp)},d,h=oe=>{t(22,d=new ur.ExtraButtonComponent(oe).setIcon("plus-circle"))},p=oe=>{(0,ur.setIcon)(oe,Vu)},m=oe=>{(0,ur.setIcon)(oe,"check")},g=oe=>{(0,ur.setIcon)(oe,"cross-in-box")},O="",w="",S=null,C=$e([]);Se(i,C,oe=>t(5,r=oe));let k=()=>{S&&(Ke(C,r=[...r,{...l.data.statuses.find(oe=>oe.name==S)??{name:S,id:xt(),description:""}}],r),t(0,S=null),t(3,_.items=l.data.statuses.filter(oe=>!r.find(ke=>ke.id==oe.id)).map(oe=>oe.name),_),P.setValue(""))},_,P,x=oe=>{P=new ur.TextComponent(oe),P.onChange(ke=>t(0,S=ke)),oe.onkeydown=ke=>{ke.key==="Enter"&&(S?k():Q(!0))},R()},R=()=>{t(3,_=new ef(l.app,P,l.data.statuses.filter(oe=>!r.find(ke=>ke.id==oe.id)).map(oe=>oe.name))),_.onSelect(async({item:oe})=>{t(0,S=oe),P.setValue(oe),_.close(),k()})};function Z(oe,ke){n==ke&&oe.focus()}let Q=oe=>{oe?he.doUpdate(O??"",r,w):he.clearUpdate(),t(1,O=null),t(0,S=null),t(2,w=null),Ke(C,r=[],r),t(3,_=null),Ke(a,n=null,n)};function D(){O=this.value,t(1,O)}let E=function(oe){if(oe.key=="Tab")return!0;if(oe.key=="Enter"||oe.key=="Escape"){Q(oe.key=="Enter");return}if(!/^((t|m)?-?\d*\.?\d*(Backspace|Delete|Arrow\w+)?)$/.test(this.value+oe.key))return oe.preventDefault(),!1},j=function(oe){Ke(C,r=[],r)},z=function(oe,ke){r.remove(oe),C.set(r)};function q(){w=this.value,t(2,w)}let G=function(){t(3,_=null)},Y=function(oe){if(oe.key=="Tab")return!0;if(oe.key=="Enter"||oe.key=="Escape"){Q(oe.key=="Enter");return}},ce=function(oe,ke,yt,It){Ke(o,ke[yt][1].saved=!oe.saved,s)},Pe=function(oe,ke,yt,It){Ke(o,ke[yt][1].resist=!oe.resist,s)};function ue(oe,ke){oe[ke][1].customMod=pi(this.value)}let B=function(oe,ke){he.setUpdate(oe,ke),s.size||(Ke(C,r=[],r),t(3,_=null))},ee=()=>Q(!0),pe=()=>Q(!1),Re=()=>Q(!1);return i.$$.update=()=>{i.$$.dirty[0]&4194305&&d&&d.setDisabled(!S)},[S,O,w,_,n,r,s,o,a,l,c,u,f,h,p,m,g,C,k,x,Z,Q,d,D,E,j,z,q,G,Y,ce,Pe,ue,B,ee,pe,Re]}var Vm=class extends ne{constructor(e){super(),re(this,e,B7,$7,ie,{},M7,[-1,-1])}},z_=Vm;var Ra=require("obsidian");var nc=class{constructor(e){this.plugin=e;J(this,"logFile");J(this,"file");J(this,"logging",!1)}async setLogFile(e){this.logFile=e,this.logging=!0,await this.setFile()}getLogFile(){return this.logFile?(0,Ra.normalizePath)(this.logFile):""}async setFile(){let e=await this.adapter.exists((0,Ra.normalizePath)(this.logFile))?await this.vault.getAbstractFileByPath((0,Ra.normalizePath)(this.logFile)):await this.vault.create(this.logFile,"");e instanceof Ra.TFile&&(this.file=e)}getFile(){return this.file}get enabled(){return this.plugin.data.logging}get folder(){return this.plugin.data.logFolder}get vault(){return this.plugin.app.vault}get adapter(){return this.plugin.app.vault.adapter}async new(e){if(this.enabled)if(typeof e=="string")await this.setLogFile(e);else{await this.setLogFile(`${this.folder}/${Date.now()} - ${e.name??"Combat"}.md`),await this.log(`**Combat started ${new Date().toLocaleString()}** `),await this.log("## Players"),await this.log("| Player | Initiative | HP | Statuses |"),await this.log("| --- | :-: | :-: | :-: |");for(let t of e.players.sort((n,r)=>r.initiative-n.initiative))await this.log("|",t.getName().replace("|","\\|"),"|",t.initiative.toString(),"|",t.hp?`${t.hp}/${t.max}`:"-","|",[...t.status.size?[...t.status].map(n=>n.name):["-"]].join(", ").replace("|","\\|"),"|");await this.log("## Creatures"),await this.log("| Creature | Initiative | HP | Statuses |"),await this.log("| --- | :-: | :-: | :-: |");for(let t of e.creatures.sort((n,r)=>r.initiative-n.initiative))await this.log("|",t.getName().replace("|","\\|"),"|",t.initiative.toString(),"|",t.hp?`${t.hp}/${t.max}`:"-","|",[...t.status.size?[...t.status].map(n=>n.name):["-"]].join(", ").replace("|","\\|"),"|");await this.log(` ## Combat Log`),await this.log(` ### Round 1`),await this.log(` ##### ${he.getOrderedCreatures()[0].getName()}'s turn`)}}async log(...e){this.enabled&&this.file&&(await this.adapter.exists(this.logFile)||await this.setLogFile(this.logFile),await this.vault.append(this.file,`${e.join(" ")} `))}join(e,t="and"){return e.length==1?e[0]:`${e.slice(0,-1).join(", ")} ${t} ${e.slice(-1)}`}logUpdate(e){let t=[];for(let n of e){let r=[];if(n.hp&&(n.temp?r.push(`${n.name} gained ${(-1*n.hp).toString()} temporary HP`):n.max?n.hp<0?r.push(`${n.name} took ${(-1*n.hp).toString()} max HP damage${n.unc?" and died":""}`):r.push(`${n.name} gained ${n.hp.toString()} max HP`):n.hp<0?r.push(`${n.name} took ${(-1*n.hp).toString()} damage${n.unc?" and was knocked unconscious":""}`):n.hp>0&&r.push(`${n.name} was healed for ${n.hp.toString()} HP`)),n.ac&&(r.length&&!n.status?r.push("and"):r.length&&r.push(","),n.ac_add?r.push(`${n.name} added ${n.ac} to AC`):r.push(`${n.name} AC set to ${n.ac?n.ac:"be blank"}`)),n.status){r.length?r.push("and"):r.push(n.name);let s;n.status.length>1?(s=[n.status.slice(0,n.status.length-1).join(", ")],s.push(n.status[n.status.length-1])):s=[n.status[0]],n.saved?r.push(`saved against ${s.join(" and ")}`):r.push(`took ${s.join(" and ")} status`)}if(n.remove_status){r.length?r.push("and"):r.push(n.name);let s;n.remove_status.length>1?(s=[n.remove_status.slice(0,n.remove_status.length-1).join(", ")],s.push(n.remove_status[n.remove_status.length-1])):s=[n.remove_status[0]],r.push(`relieved of ${s.join(" and ")} status`)}t.push(r.join(" "))}this.log(`${t.join(". ")}.`)}};var Ma=require("obsidian");var hn=require("obsidian");var _i=require("obsidian");function V7(i){se(i,"svelte-1rjv45j",".create-new.svelte-1rjv45j>.svelte-1rjv45j{display:grid;grid-template-columns:33% 66%;margin-bottom:0.5rem}.context-buttons.svelte-1rjv45j.svelte-1rjv45j{display:flex;justify-content:flex-end;align-items:center;grid-gap:0.125rem}.cancel-button.svelte-1rjv45j.svelte-1rjv45j{color:var(--text-faint)}.initiative.svelte-1rjv45j.svelte-1rjv45j{position:relative}.initiative.svelte-1rjv45j>.dice.svelte-1rjv45j{position:absolute;right:0.25rem;top:50%;transform:translateY(-50%)}")}function q_(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,w,S;return{c(){e=b("div"),t=b("label"),t.textContent="Static Initiative",n=M(),r=b("div"),o=M(),a=b("div"),l=b("label"),l.textContent="Hidden",c=M(),u=b("div"),d=M(),h=b("div"),p=b("label"),p.textContent="Friendly",m=M(),g=b("div"),v(t,"for","add-mod"),v(e,"class","svelte-1rjv45j"),v(l,"for","add-mod"),v(a,"class","svelte-1rjv45j"),v(p,"for","add-mod"),v(h,"class","svelte-1rjv45j")},m(C,k){A(C,e,k),y(e,t),y(e,n),y(e,r),A(C,o,k),A(C,a,k),y(a,l),y(a,c),y(a,u),A(C,d,k),A(C,h,k),y(h,p),y(h,m),y(h,g),w||(S=[H(s=i[14].call(null,r)),H(f=i[13].call(null,u)),H(O=i[15].call(null,g))],w=!0)},p:X,d(C){C&&(T(e),T(o),T(a),T(d),T(h)),w=!1,de(S)}}}function L_(i){let e,t,n,r,s,o;function a(u,f){return u[7]?X7:W7}let l=a(i,-1),c=l(i);return{c(){e=b("div"),t=b("div"),r=M(),c.c(),v(t,"class","add-button cancel-button svelte-1rjv45j"),v(e,"class","context-buttons svelte-1rjv45j")},m(u,f){A(u,e,f),y(e,t),y(e,r),c.m(e,null),s||(o=H(n=i[10].call(null,t)),s=!0)},p(u,f){l!==(l=a(u,f))&&(c.d(1),c=l(u),c&&(c.c(),c.m(e,null)))},d(u){u&&T(e),c.d(),s=!1,o()}}}function W7(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","add-button")},m(s,o){A(s,e,o),n||(r=H(t=i[8].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function X7(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","add-button")},m(s,o){A(s,e,o),n||(r=H(t=i[9].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function U7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,w,S,C,k,_,P,x,R,Z,Q,D,E,j,z,q,G,Y,ce,Pe,ue,B,ee,pe,Re,oe=i[4],ke,yt,It,at,Nt,Pr,nn,$t,Tt=q_(i),lt=!i[3]&&!_i.Platform.isMobile&&L_(i);return{c(){e=b("div"),t=b("div"),n=b("div"),r=b("label"),r.textContent="Creature",s=M(),o=b("div"),l=M(),c=b("div"),u=b("label"),u.textContent="Display Name",f=M(),d=b("input"),h=M(),p=b("div"),m=b("label"),m.textContent="HP",g=M(),O=b("input"),w=M(),S=b("div"),C=b("label"),C.textContent="Hit Dice",k=M(),_=b("input"),P=M(),x=b("div"),R=b("label"),R.textContent="AC",Z=M(),Q=b("input"),D=M(),E=b("div"),j=b("label"),j.textContent="Modifier",z=M(),q=b("input"),G=M(),Y=b("div"),ce=b("label"),ce.textContent="Initiative",Pe=M(),ue=b("input"),B=M(),ee=b("div"),Re=M(),Tt.c(),ke=M(),yt=b("div"),It=b("label"),It.textContent="Amount",at=M(),Nt=b("input"),Pr=M(),lt&<.c(),v(r,"for","add-name"),v(o,"id","add-name"),v(n,"class","svelte-1rjv45j"),v(u,"for","add-display"),v(d,"id","add-display"),v(d,"type","text"),v(d,"name","display"),v(d,"tabindex","0"),v(c,"class","svelte-1rjv45j"),v(m,"for","add-hp"),v(O,"id","add-hp"),v(O,"type","number"),v(O,"name","hp"),v(O,"tabindex","0"),v(p,"class","svelte-1rjv45j"),v(C,"for","hit-dice"),v(_,"id","hit-dice"),v(_,"type","text"),v(_,"name","hitdice"),v(_,"tabindex","0"),v(S,"class","svelte-1rjv45j"),v(R,"for","add-ac"),v(Q,"id","add-ac"),v(Q,"name","ac"),v(Q,"type","text"),v(Q,"tabindex","0"),v(x,"class","svelte-1rjv45j"),v(j,"for","add-mod"),v(q,"id","add-mod"),v(q,"type","text"),v(q,"name","add-mod"),v(q,"tabindex","0"),v(E,"class","svelte-1rjv45j"),v(ce,"for","add-init"),v(ue,"id","add-init"),v(ue,"type","number"),v(ue,"name","initiative"),v(ue,"tabindex","0"),v(ee,"class","dice svelte-1rjv45j"),v(Y,"class","initiative svelte-1rjv45j"),v(It,"for","add-init"),v(Nt,"id","add-init"),v(Nt,"type","number"),v(Nt,"name","initiative"),v(Nt,"tabindex","0"),v(yt,"class","amount svelte-1rjv45j"),v(t,"class","create-new svelte-1rjv45j"),v(e,"class","initiative-tracker-editor")},m(dt,gt){A(dt,e,gt),y(e,t),y(t,n),y(n,r),y(n,s),y(n,o),y(t,l),y(t,c),y(c,u),y(c,f),y(c,d),Xe(d,i[4].display),i[19](d),y(t,h),y(t,p),y(p,m),y(p,g),y(p,O),Xe(O,i[4].hp),y(t,w),y(t,S),y(S,C),y(S,k),y(S,_),Xe(_,i[4].hit_dice),y(t,P),y(t,x),y(x,R),y(x,Z),y(x,Q),Xe(Q,i[4].ac),y(t,D),y(t,E),y(E,j),y(E,z),y(E,q),Xe(q,i[5]),y(t,G),y(t,Y),y(Y,ce),y(Y,Pe),y(Y,ue),Xe(ue,i[4].initiative),y(Y,B),y(Y,ee),y(t,Re),Tt.m(t,null),y(t,ke),y(t,yt),y(yt,It),y(yt,at),y(yt,Nt),Xe(Nt,i[0]),y(e,Pr),lt&<.m(e,null),nn||($t=[H(a=i[12].call(null,o)),U(d,"input",i[18]),U(O,"input",i[20]),U(_,"input",i[21]),U(Q,"input",i[22]),U(Q,"change",i[23]),U(q,"input",i[24]),U(ue,"input",i[25]),H(pe=i[11].call(null,ee)),U(Nt,"input",i[26])],nn=!0)},p(dt,[gt]){gt&16&&d.value!==dt[4].display&&Xe(d,dt[4].display),gt&16&&pi(O.value)!==dt[4].hp&&Xe(O,dt[4].hp),gt&16&&_.value!==dt[4].hit_dice&&Xe(_,dt[4].hit_dice),gt&16&&Q.value!==dt[4].ac&&Xe(Q,dt[4].ac),gt&32&&q.value!==dt[5]&&Xe(q,dt[5]),gt&16&&pi(ue.value)!==dt[4].initiative&&Xe(ue,dt[4].initiative),gt&16&&ie(oe,oe=dt[4])?(Tt.d(1),Tt=q_(dt),Tt.c(),Tt.m(t,ke)):Tt.p(dt,gt),gt&1&&pi(Nt.value)!==dt[0]&&Xe(Nt,dt[0]),!dt[3]&&!_i.Platform.isMobile?lt?lt.p(dt,gt):(lt=L_(dt),lt.c(),lt.m(e,null)):lt&&(lt.d(1),lt=null)},i:X,o:X,d(dt){dt&&T(e),i[19](null),Tt.d(dt),lt&<.d(),nn=!1,de($t)}}}function Y7(i,e,t){let n,r=X,s=()=>(r(),r=Mi(h,B=>t(7,n=B)),h),o,a=X,l=()=>(a(),a=Mi(d,B=>t(17,o=B)),d);i.$$.on_destroy.push(()=>r()),i.$$.on_destroy.push(()=>a());let c=new je({}),{amount:u=1}=e,{plugin:f}=e,{adding:d}=e;l();let{editing:h}=e;s();let{isEditing:p}=e;h.subscribe(B=>{B&&t(4,c=B)});let m=JSON.stringify(c.modifier??0),g=m,O=B=>{new _i.ExtraButtonComponent(B).setTooltip("Add Creature").setIcon("plus").onClick(async()=>{if(!c||!c.name||!c.name?.length){new _i.Notice("Enter a name!");return}try{t(4,c.modifier=JSON.parse(`${m}`),c)}catch{console.warn("Initiative Tracker: Non-parseable modifier provided to creature."),t(4,c.modifier=JSON.parse(g),c)}c.modifier||t(4,c.modifier=JSON.parse(g),c),(Array.isArray(c.modifier)&&!c.modifier.every(pe=>!isNaN(Number(pe)))||isNaN(Number(c.modifier)))&&(console.warn("Initiative Tracker: Non-numeric modifier provided to creature."),t(4,c.modifier=0,c)),(c.initiative<=0||c.initiative==null||isNaN(c.initiative))&&t(4,c.initiative=await f.getInitiativeValue(c.modifier),c);let ee=o.findIndex(([pe])=>Ns(pe,c));ee>-1?Ke(d,o[ee][1]+=u,o):o.push([c,u]),d.set(o),Ke(h,n=null,n),t(4,c=new je({}))})},w=B=>{new _i.ExtraButtonComponent(B).setTooltip("Add Creature").setIcon("save").onClick(async()=>{if(!c||!c.name||!c.name?.length){new _i.Notice("Enter a name!");return}c.modifier||t(4,c.modifier=0,c),(c.initiative<=0||c.initiative==null||isNaN(c.initiative))&&t(4,c.initiative=await f.getInitiativeValue(c.modifier),c);let ee=o.findIndex(([pe])=>pe!=c&&Ns(pe,c));if(ee>-1&&await F_(app,`This will merge ${c.name} with ${o[ee][0].name}.`)){let pe=o.findIndex(([Re])=>Re==c);Ke(d,o[ee][1]+=o[pe][1],o),o.splice(pe,1)}d.set(o),Ke(h,n=null,n),t(4,c=new je({}))})},S=B=>{new _i.ExtraButtonComponent(B).setTooltip("Cancel").setIcon("reset").onClick(()=>{t(4,c=new je({}))})},C=B=>{new _i.ExtraButtonComponent(B).setIcon(Qs).setTooltip("Roll Initiative").onClick(async()=>{t(4,c.initiative=await f.getInitiativeValue(c.modifier),c)})},k,_,P=B=>{k=new _i.TextComponent(B).setValue(c.name).onChange(ee=>t(4,c.name=ee,c))},x,R=()=>{x=new Ml(f.app,k,f.bestiary),x.onSelect(async B=>{B.item&&(t(4,c=je.from(B.item)),t(4,c.initiative=await f.getInitiativeValue(c.modifier),c),k.setValue(c.name)),x.close()})};uf(()=>{p?setImmediate(()=>{_.focus(),R()}):R()});let Z=B=>{new _i.ToggleComponent(B).setValue(c.hidden).onChange(ee=>t(4,c.hidden=ee,c))},Q=B=>{new _i.ToggleComponent(B).setValue(c.static).onChange(ee=>t(4,c.static=ee,c))},D=B=>{new _i.ToggleComponent(B).setValue(c.friendly).onChange(ee=>t(4,c.friendly=ee,c))};function E(){c.display=this.value,t(4,c)}function j(B){mi[B?"unshift":"push"](()=>{_=B,t(6,_)})}function z(){c.hp=pi(this.value),t(4,c)}function q(){c.hit_dice=this.value,t(4,c)}function G(){c.ac=this.value,t(4,c)}let Y=()=>t(4,c.dirty_ac=!0,c);function ce(){m=this.value,t(5,m)}function Pe(){c.initiative=pi(this.value),t(4,c)}function ue(){u=pi(this.value),t(0,u)}return i.$$set=B=>{"amount"in B&&t(0,u=B.amount),"plugin"in B&&t(16,f=B.plugin),"adding"in B&&l(t(1,d=B.adding)),"editing"in B&&s(t(2,h=B.editing)),"isEditing"in B&&t(3,p=B.isEditing)},i.$$.update=()=>{i.$$.dirty&131089&&_i.Platform.isMobile&&o.splice(0,1,[c,u])},[u,d,h,p,c,m,_,n,O,w,S,C,P,Z,Q,D,f,o,E,j,z,q,G,Y,ce,Pe,ue]}var Wm=class extends ne{constructor(e){super(),re(this,e,Y7,U7,ie,{amount:0,plugin:16,adding:1,editing:2,isEditing:3},V7)}},$_=Wm;var fr=require("obsidian");function H7(i){se(i,"svelte-uvd81j",".initiative-tracker-list.svelte-uvd81j{display:flex;flex:1 1 auto;flex-flow:column nowrap;height:0px;overflow:scroll}.creature.svelte-uvd81j{border-radius:0.5rem;padding:0.5rem}.creature.svelte-uvd81j:hover{background-color:var(--background-secondary)}.creature-metadata.svelte-uvd81j{display:flex;align-items:center;gap:0.5rem}.creature-amount.svelte-uvd81j{margin-left:auto;display:grid;grid-template-columns:1fr 1fr 1fr 1fr;align-items:center;text-align:center}.creature-data.svelte-uvd81j{--icon-size:10px;display:flex;align-items:center;gap:0.375rem}.list-header.svelte-uvd81j{margin-top:0;margin-bottom:0.5rem}")}function B_(i,e,t){let n=i.slice();return n[21]=e[t][0],n[22]=e[t][1],n[24]=t,n}function G7(i){let e;return{c(){e=b("span"),e.textContent="Add a creature."},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function K7(i){let e,t=fe(i[3]),n=[];for(let r=0;r(r(),r=Mi(c,D=>t(3,n=D)),c),o,a=X,l=()=>(a(),a=Mi(u,D=>t(4,o=D)),u);i.$$.on_destroy.push(()=>r()),i.$$.on_destroy.push(()=>a());let{adding:c}=e;s();let{editing:u}=e;l();let{rollHP:f}=e,d=(D,E)=>{new fr.ExtraButtonComponent(D).setIcon("minus")},h=(D,E)=>{if(n[E][1]-1<1){O(D,E);return}Ke(c,n[E][1]-=1,n),c.set(n)},p=(D,E)=>{new fr.ExtraButtonComponent(D).setIcon("plus")},m=(D,E)=>{Ke(c,n[E][1]+=1,n),c.set(n)},g=(D,E)=>{new fr.ExtraButtonComponent(D).setIcon("trash")},O=(D,E)=>{n.splice(E,1),c.set(n)},w=D=>{(0,fr.setIcon)(D,an)},S=D=>{(0,fr.setIcon)(D,cs)},C=D=>{(0,fr.setIcon)(D,ir)},k=D=>{(0,fr.setIcon)(D,So)},_=D=>{(0,fr.setIcon)(D,er)},P=D=>{(0,fr.setIcon)(D,tr)},x=(D,E)=>h(E,D),R=(D,E)=>m(E,D),Z=(D,E)=>O(E,D),Q=D=>Ke(u,o=D,o);return i.$$set=D=>{"adding"in D&&s(t(0,c=D.adding)),"editing"in D&&l(t(1,u=D.editing)),"rollHP"in D&&t(2,f=D.rollHP)},[c,u,f,n,o,d,h,p,m,g,O,w,S,C,k,_,P,x,R,Z,Q]}var Xm=class extends ne{constructor(e){super(),re(this,e,iA,tA,ie,{adding:0,editing:1,rollHP:2},H7)}},U_=Xm;function nA(i){se(i,"svelte-caa9tv",".initiative-tracker-creator.svelte-caa9tv{margin-top:1rem;display:grid;grid-template-columns:1fr 1fr;gap:0.5rem}.initiative-tracker-creator.editing.svelte-caa9tv{grid-template-columns:1fr}.buttons.svelte-caa9tv{display:flex;margin-left:auto;justify-content:flex-end;gap:0.5rem}div.disabled.svelte-caa9tv>button{cursor:not-allowed}.creator-list.svelte-caa9tv{display:flex;justify-content:space-between;flex-flow:column nowrap;gap:0.5rem;margin-bottom:0.5rem}")}function Y_(i){let e,t,n,r,s,o,a,l,c,u;return t=new U_({props:{adding:i[4],editing:i[5],rollHP:i[2]}}),{c(){e=b("div"),ye(t.$$.fragment),n=M(),r=b("div"),s=b("input"),o=M(),a=b("label"),a.textContent="Roll for HP",v(s,"type","checkbox"),v(s,"name","roll-hp"),v(s,"id","roll-hp"),v(a,"for","roll-hp"),v(e,"class","creator-list svelte-caa9tv")},m(f,d){A(f,e,d),Oe(t,e,null),y(e,n),y(e,r),y(r,s),s.checked=i[2],y(r,o),y(r,a),l=!0,c||(u=U(s,"change",i[9]),c=!0)},p(f,d){let h={};d&4&&(h.rollHP=f[2]),t.$set(h),d&4&&(s.checked=f[2])},i(f){l||($(t.$$.fragment,f),l=!0)},o(f){V(t.$$.fragment,f),l=!1},d(f){f&&T(e),ve(t),c=!1,u()}}}function rA(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p;n=new $_({props:{plugin:i[0],editing:i[5],adding:i[4],isEditing:i[1]}});let m=!i[1]&&!hn.Platform.isMobile&&Y_(i);return{c(){e=b("div"),t=b("div"),ye(n.$$.fragment),r=M(),m&&m.c(),s=M(),o=b("div"),a=b("div"),c=M(),u=b("div"),v(t,"class","initiative-tracker-creator svelte-caa9tv"),ge(t,"editing",i[1]||hn.Platform.isMobile),v(u,"class","svelte-caa9tv"),ge(u,"disabled",!i[3].length&&!i[1]&&!hn.Platform.isMobile),v(o,"class","buttons svelte-caa9tv"),v(e,"class","initiative-tracker-creator-container"),ge(e,"mobile",hn.Platform.isMobileApp)},m(g,O){A(g,e,O),y(e,t),Oe(n,t,null),y(t,r),m&&m.m(t,null),y(e,s),y(e,o),y(o,a),y(o,c),y(o,u),d=!0,h||(p=[H(l=i[6].call(null,a)),H(f=i[7].call(null,u))],h=!0)},p(g,[O]){let w={};O&1&&(w.plugin=g[0]),O&2&&(w.isEditing=g[1]),n.$set(w),!g[1]&&!hn.Platform.isMobile?m?(m.p(g,O),O&2&&$(m,1)):(m=Y_(g),m.c(),$(m,1),m.m(t,null)):m&&(Ae(),V(m,1,1,()=>{m=null}),De()),(!d||O&2)&&ge(t,"editing",g[1]||hn.Platform.isMobile),(!d||O&10)&&ge(u,"disabled",!g[3].length&&!g[1]&&!hn.Platform.isMobile)},i(g){d||($(n.$$.fragment,g),$(m),d=!0)},o(g){V(n.$$.fragment,g),V(m),d=!1},d(g){g&&T(e),ve(n),m&&m.d(),h=!1,de(p)}}}function sA(i,e,t){let n,r,s=Fe(),{plugin:o}=e,{isEditing:a=!1}=e,{creature:l=null}=e,c=o.data.rollHP,u=$e([]);Se(i,u,m=>t(3,n=m));let f=$e(l);Se(i,f,m=>t(10,r=m));let d=m=>{new hn.ButtonComponent(m).setCta().setButtonText("Cancel").onClick(()=>{s("close")})},h=m=>{new hn.ButtonComponent(m).setButtonText(a?"Save":"Add to Encounter").onClick(async()=>{if(!(!n.length&&!a&&!hn.Platform.isMobile)){if(a)r.hp!=l.max&&t(8,l.max=t(8,l.current_max=r.hp,l),l),l.dirty_ac&&(t(8,l.current_ac=r.ac,l),t(8,l.dirty_ac=!1,l)),he.replace(l,r);else{let g=n.flatMap(([O,w])=>[...Array(w).keys()].map(S=>je.new(O)));he.add(o,c,...g)}if(l?.player&&l?.path){let g=await o.app.vault.getAbstractFileByPath(l.path);g&&g instanceof hn.TFile&&o.app.fileManager.processFrontMatter(g,O=>{O.ac=l.ac,O.hp=l.max,O.level=l.level,O.modifier=l.modifier})}s("close")}})};function p(){c=this.checked,t(2,c)}return i.$$set=m=>{"plugin"in m&&t(0,o=m.plugin),"isEditing"in m&&t(1,a=m.isEditing),"creature"in m&&t(8,l=m.creature)},[o,a,c,n,u,f,d,h,l,p]}var Um=class extends ne{constructor(e){super(),re(this,e,sA,rA,ie,{plugin:0,isEditing:1,creature:8},nA)}},H_=Um;var Lf=class extends Ma.Modal{constructor(t,n){super(t.app);this.plugin=t;this.creature=n}onOpen(){this.containerEl.addClass("initiative-tracker-modal"),new H_({target:this.contentEl,props:{plugin:this.plugin,...this.creature?{creature:this.creature,isEditing:!0}:{}}}).$on("close",()=>this.close())}};async function F_(i,e,t={cta:"Yes",secondary:"No"}){return new Promise((n,r)=>{try{let s=new Ym(i,e,t);s.onClose=()=>{n(s.confirmed)},s.open()}catch{r()}})}var Ym=class extends Ma.Modal{constructor(t,n,r){super(t);this.text=n;this.buttons=r;J(this,"confirmed",!1)}async display(){this.containerEl.addClass("initiative-tracker-modal"),this.contentEl.empty(),this.contentEl.addClass("confirm-modal"),this.contentEl.createEl("p",{text:this.text});let t=this.contentEl.createDiv("confirm-buttons");new Ma.ButtonComponent(t).setButtonText(this.buttons.cta).setCta().onClick(()=>{this.confirmed=!0,this.close()}),new Ma.ButtonComponent(t).setButtonText(this.buttons.secondary).onClick(()=>{this.close()})}onOpen(){this.display()}};var Hm=require("obsidian");function oA(i){se(i,"svelte-1yp1f6q",".obsidian-initiative-tracker.svelte-1yp1f6q{margin:0.5rem;min-width:180px;overflow-y:auto}.add-creature-container.svelte-1yp1f6q{display:flex;flex-flow:column nowrap;justify-content:flex-start;margin-right:0.5rem}.context-container.svelte-1yp1f6q{display:flex;flex-flow:row nowrap;justify-content:space-between}.copy-button.svelte-1yp1f6q{width:min-content;opacity:0.25}.copy-button.svelte-1yp1f6q:hover{opacity:1}.add-button.svelte-1yp1f6q{width:min-content}.add-button.svelte-1yp1f6q .clickable-icon{margin:0}")}function aA(i){let e,t,n,r,s,o,a,l,c;return{c(){e=b("div"),t=b("div"),n=b("div"),s=M(),o=b("div"),v(n,"class","copy-button svelte-1yp1f6q"),v(o,"class","add-button svelte-1yp1f6q"),v(t,"class","context-container svelte-1yp1f6q"),v(e,"class","add-creature-container svelte-1yp1f6q")},m(u,f){A(u,e,f),y(e,t),y(t,n),y(t,s),y(t,o),l||(c=[H(r=i[7].call(null,n)),H(a=i[6].call(null,o)),U(o,"click",i[18])],l=!0)},p:X,i:X,o:X,d(u){u&&T(e),l=!1,de(c)}}}function lA(i){let e,t;return e=new D_({}),e.$on("cancel",i[17]),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function cA(i){let e,t;return e=new C_({}),e.$on("cancel",i[16]),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function uA(i){let e,t,n,r,s,o,a,l,c,u,f,d;t=new Pb({}),t.$on("save",i[9]),t.$on("load",i[10]),t.$on("add-creatures",i[11]),t.$on("player-view",i[12]),t.$on("open-map",i[13]),r=new x_({}),o=new g_({}),o.$on("edit",i[14]),o.$on("open-combatant",i[15]),l=new z_({});let h=[cA,lA,aA],p=[];function m(g,O){return g[1]?0:g[2]?1:2}return u=m(i,-1),f=p[u]=h[u](i),{c(){e=b("div"),ye(t.$$.fragment),n=M(),ye(r.$$.fragment),s=M(),ye(o.$$.fragment),a=M(),ye(l.$$.fragment),c=M(),f.c(),v(e,"class","obsidian-initiative-tracker svelte-1yp1f6q")},m(g,O){A(g,e,O),Oe(t,e,null),y(e,n),Oe(r,e,null),y(e,s),Oe(o,e,null),y(e,a),Oe(l,e,null),y(e,c),p[u].m(e,null),d=!0},p(g,[O]){let w=u;u=m(g,O),u===w?p[u].p(g,O):(Ae(),V(p[w],1,1,()=>{p[w]=null}),De(),f=p[u],f?f.p(g,O):(f=p[u]=h[u](g),f.c()),$(f,1),f.m(e,null))},i(g){d||($(t.$$.fragment,g),$(r.$$.fragment,g),$(o.$$.fragment,g),$(l.$$.fragment,g),$(f),d=!0)},o(g){V(t.$$.fragment,g),V(r.$$.fragment,g),V(o.$$.fragment,g),V(l.$$.fragment,g),V(f),d=!1},d(g){g&&T(e),ve(t),ve(r),ve(o),ve(l),p[u].d()}}}function fA(i,e,t){let n,r,s,{plugin:o}=e,{data:a}=he;Se(i,a,x=>t(8,s=x)),he.setData(o.data),he.setLogger(new nc(o)),o.data.state?he.new(o,o.data.state):(he.setParty(o.data.defaultParty,o),he.roll(o));let{ordered:l}=he;Se(i,l,x=>t(20,r=x)),Vi("plugin",o);let c=!1,u=!1,f=x=>{let R=new Lf(o,x);R.onClose=()=>{},R.open()},d=x=>{new Ia.ExtraButtonComponent(x).setTooltip("Add Creature").setIcon(zp)},h=x=>{new Ia.ExtraButtonComponent(x).setTooltip("Copy Initiative Order").setIcon(Wp).onClick(async()=>{let R=r.map(Z=>`${Z.initiative} ${Z.name}`).join(` `);try{await navigator.clipboard.writeText(R),new Ia.Notice("Initiative order copied to clipboard.")}catch{new Ia.Notice("Initiative order could not be copied to clipboard.")}})},p=()=>t(1,c=!0),m=()=>t(2,u=!0),g=()=>f();function O(x){ht.call(this,i,x)}function w(x){ht.call(this,i,x)}let S=x=>f(x.detail),C=x=>o.openCombatant(x.detail.creature,x.detail.newLeaf),k=()=>t(1,c=!1),_=()=>t(2,u=!1),P=()=>f();return i.$$set=x=>{"plugin"in x&&t(0,o=x.plugin)},i.$$.update=()=>{i.$$.dirty&256&&(n=s.displayDifficulty)},[o,c,u,a,l,f,d,h,s,p,m,g,O,w,S,C,k,_,P]}var Gm=class extends ne{constructor(e){super(),re(this,e,fA,uA,ie,{plugin:0},oA)}},G_=Gm;var Na=class extends kn.ItemView{constructor(t,n){super(t);this.leaf=t;this.plugin=n;J(this,"ui");J(this,"playerViewOpened",!1);this.plugin.data.state?.creatures?.length}async onOpen(){this.ui=new G_({target:this.contentEl,props:{plugin:this.plugin}}),this.ui.$on("player-view",()=>this.openPlayerView())}async onClose(){this.ui?.$destroy()}getViewType(){return Mn}getDisplayText(){return"Initiative Tracker"}getIcon(){return Zp}get pcs(){return[]}get npcs(){return[]}getExistingPlayerView(){let t=this.plugin.app.workspace.getLeavesOfType(Ds);if(t.length)return t[0].view}async getPlayerView(){let t=this.getExistingPlayerView();if(t)return this.app.workspace.revealLeaf(t.leaf),t;let n=this.app.workspace.getLeaf("window");return await n.setViewState({type:Ds}),await this.app.workspace.setActiveLeaf(n,{focus:!0}),n.view}async openPlayerView(){await this.getPlayerView(),this.playerViewOpened=!0}},ja=class extends kn.ItemView{constructor(t,n){super(t);this.plugin=n;J(this,"buttonEl",this.contentEl.createDiv("creature-view-button"));J(this,"statblockEl",this.contentEl.createDiv("creature-statblock-container"));J(this,"currentCreatureId",null);J(this,"currentCreatureName",null);J(this,"bestiaryUnload",null);this.load(),this.containerEl.addClass("creature-view-container"),this.containerEl.on("mouseover","a.internal-link",(0,kn.debounce)(r=>this.app.workspace.trigger("hover-link",{event:r,source:Mn,hoverParent:this,targetEl:r.target,linktext:r.target.dataset.href??""}),10)),this.containerEl.on("click","a.internal-link",r=>this.app.workspace.openLinkText(r.target.dataset.href,"initiative-tracker"))}onload(){new kn.ExtraButtonComponent(this.buttonEl).setIcon("cross").setTooltip("Close Statblock").onClick(async()=>{await this.render(),this.app.workspace.trigger("initiative-tracker:stop-viewing")})}onunload(){this.bestiaryUnload&&(this.bestiaryUnload(),this.bestiaryUnload=null),this.app.workspace.trigger("initiative-tracker:stop-viewing")}getState(){return{creatureId:this.currentCreatureId,creatureName:this.currentCreatureName}}async setState(t,n){let r=typeof t?.creatureId=="string"?t.creatureId:null,s=typeof t?.creatureName=="string"?t.creatureName:null;if(!r&&!s){this.currentCreatureId=null,this.currentCreatureName=null,await this.render(),await super.setState(t,n);return}this.currentCreatureId=r,this.currentCreatureName=s;let o=async()=>{let a=this.plugin.tracker.getOrderedCreatures(),l=(r?a.find(c=>c.id===r):void 0)??(s?a.find(c=>c.name===s):void 0)??(s?this.plugin.playerCreatures.get(s):void 0)??(s?this.plugin.getCreatureFromBestiary(s):void 0);if(l){try{await this.render(l)}catch(c){console.error("Failed to restore creature view",c)}return}this.currentCreatureId=null,this.currentCreatureName=null,t.creatureId=null,t.creatureName=null,await this.render()};if(this.plugin.canUseStatBlocks&&!window.FantasyStatblocks.isResolved()){this.statblockEl.empty(),this.statblockEl.createEl("em",{text:"Loading bestiary\u2026"});let a=window.FantasyStatblocks.onResolved(()=>{this.bestiaryUnload=null,o().finally(a)});this.bestiaryUnload=a}else await o();await super.setState(t,n)}async render(t){if(this.currentCreatureId=t?.id??null,this.currentCreatureName=t?.name??null,this.statblockEl.empty(),!t){this.statblockEl.createEl("em",{text:"Select a creature to view it here."});return}if(t["statblock-link"]&&(this.plugin.data.preferStatblockLink||!this.plugin.canUseStatBlocks))await this.renderEmbed(t.getStatblockLink());else if(this.plugin.canUseStatBlocks){let n=window.FantasyStatblocks.render(t.creature,this.statblockEl,t.display);this.addChild(n)}else this.statblockEl.createEl("em",{text:"Install the TTRPG Statblocks plugin or add a statblock-link to your monster to use this feature!"})}async renderEmbed(t){this.plugin.canUseStatBlocks&&window.FantasyStatblocks.isStatblockLink?.(t)&&(t=window.FantasyStatblocks.parseStatblockLink(t)),/\[.+\]\(.+\)/.test(t)?[,t]=t.match(/\[.+?\]\((.+?)\)/):/\[\[.+\]\]/.test(t)&&([,t]=t.match(/\[\[(.+?)(?:\|.+?)?\]\]/));let{path:n,subpath:r}=(0,kn.parseLinktext)(t),s=this.app.metadataCache.getFirstLinkpathDest(n,"/"),o=`Oops! Something is wrong with your statblock-link:
${t}`;if(s){let a=await this.app.vault.cachedRead(s);if(r&&a){let l=this.app.metadataCache.getFileCache(s),c=(0,kn.resolveSubpath)(l,r);c&&(o=a.slice(c.start.offset,c.end.offset))}else a&&(o=a)}await kn.MarkdownRenderer.render(this.app,o,this.statblockEl.createDiv("markdown-rendered"),n,this)}getDisplayText(){return"Combatant"}getIcon(){return Ip}getViewType(){return ko}};var w5=require("obsidian");var qY=$e(0);function dA(){let i=$e([]),{subscribe:e,set:t,update:n}=i,r=oi(i,a=>a.filter(l=>l.isPlayer)),s=oi(i,a=>a.filter(l=>l.isPlayer==!1)),o=oi(i,a=>[...a].reduce((l,c)=>l+c.count,0));return{subscribe:e,party:r,generics:s,count:o,modifier:oi(o,a=>a<3?1:a>5?-1:0),average:oi(i,a=>a.length?a.reduce((l,c)=>l+(c.enabled?c.level:0),0)/a.length:0),add:a=>n(l=>((!a.count||a.count<=0)&&(a.count=1),l.push(a),l)),addFromState:a=>n(l=>{let c=a;return c.isPlayer=!0,(!c.count||c.count<=0)&&(c.count=1),l.push(c),l}),remove:a=>n(l=>(l=l.filter(c=>c!=a),l)),delete:a=>n(l=>(l=l.filter(c=>c!=a),l)),set:(a,l)=>n(c=>{let u=c.find(f=>f==a);return u.count=l,c}),setLevel:(a,l)=>n(c=>{let u=c.find(f=>f==a);return u.level=l,c}),switchParty:a=>{n(l=>(l=[...a,...ut(s)],l))},empty:()=>t([]),toggleEnabled:a=>n(l=>{let c=l.find(u=>u==a);return c.enabled=!c.enabled,l})}}var Ni=dA();var rc=require("obsidian");function hA(){let i=$e(new Map),{subscribe:e,set:t,update:n}=i;return{players:Ni,subscribe:e,add:r=>n(s=>(s.set(r,(s.get(r)??0)+1),s)),remove:r=>n(s=>{let o=s.get(r);return o&&(o==1&&s.delete(r),o>1&&s.set(r,o-1)),s}),delete:r=>n(s=>(s.delete(r),s)),set:(r,s)=>n(o=>(o.set(r,s),o)),setMultiple:r=>n(s=>{for(let[o,a]of r)s.set(o,a);return s}),empty:()=>t(new Map),update:r=>n(s=>(s.set(r,s.get(r)??1),s))}}var ii=hA();function pA(i){let e;return{c(){e=ae(i[0])},m(t,n){A(t,e,n)},p(t,[n]){n&1&&me(e,t[0])},i:X,o:X,d(t){t&&T(e)}}}function mA(i,e,t){let{str:n=We}=e;return i.$$set=r=>{"str"in r&&t(0,n=r.str)},[n]}var Km=class extends ne{constructor(e){super(),re(this,e,mA,pA,ie,{str:0})}},$f=Km;function gA(i){se(i,"svelte-ywuffm",`.creature-name-container.svelte-ywuffm{display:grid;grid-template-areas:"add name" ". desc";justify-content:flex-start;align-items:center;grid-template-columns:auto 1fr}.creature-name.svelte-ywuffm{cursor:pointer;display:flex;justify-content:space-between}.setting-item-description.svelte-ywuffm{grid-area:desc}`)}function K_(i,e,t){let n=i.slice();return n[14]=e[t],n}function J_(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon"),v(e,"aria-label",t="This creature is significantly under the average party level and might not contribute much to the fight.")},m(o,a){A(o,e,a),r||(s=H(n=i[8].call(null,e)),r=!0)},d(o){o&&T(e),r=!1,s()}}}function ew(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon"),v(e,"aria-label",t="This creature is significantly over the average party level and might prove a challenge.")},m(o,a){A(o,e,a),r||(s=H(n=i[9].call(null,e)),r=!0)},d(o){o&&T(e),r=!1,s()}}}function tw(i){let e,t=nw(i[0].source)+"",n,r;return{c(){e=b("span"),n=ae(t),v(e,"aria-label",r=rw(i[0].source))},m(s,o){A(s,e,o),y(e,n)},p(s,o){o&1&&t!==(t=nw(s[0].source)+"")&&me(n,t),o&1&&r!==(r=rw(s[0].source))&&v(e,"aria-label",r)},d(s){s&&T(e)}}}function iw(i){let e,t,n;return t=new $f({props:{str:i[0][i[14].field]??We}}),{c(){e=b("td"),ye(t.$$.fragment)},m(r,s){A(r,e,s),Oe(t,e,null),n=!0},p(r,s){let o={};s&9&&(o.str=r[0][r[14].field]??We),t.$set(o)},i(r){n||($(t.$$.fragment,r),n=!0)},o(r){V(t.$$.fragment,r),n=!1},d(r){r&&T(e),ve(t)}}}function OA(i){let e,t,n,r,s,o,a,l=i[0].name+"",c,u,f,d,h,p,m,g,O,w=i[2]&&J_(i),S=i[1]&&ew(i),C=i[0].source?.length&&tw(i),k=fe(i[3]),_=[];for(let x=0;xV(_[x],1,1,()=>{_[x]=null});return{c(){e=b("tr"),t=b("td"),n=b("div"),r=b("div"),o=M(),a=b("div"),c=ae(l),u=M(),w&&w.c(),f=M(),S&&S.c(),d=M(),h=b("div"),C&&C.c(),p=M();for(let x=0;x<_.length;x+=1)_[x].c();v(a,"class","setting-item-name creature-name svelte-ywuffm"),v(h,"class","setting-item-description svelte-ywuffm"),v(n,"class","creature-name-container svelte-ywuffm"),v(e,"class","creature")},m(x,R){A(x,e,R),y(e,t),y(t,n),y(n,r),y(n,o),y(n,a),y(a,c),y(a,u),w&&w.m(a,null),y(a,f),S&&S.m(a,null),y(n,d),y(n,h),C&&C.m(h,null),y(e,p);for(let Z=0;Z<_.length;Z+=1)_[Z]&&_[Z].m(e,null);m=!0,g||(O=[H(s=i[7].call(null,r)),U(r,"click",i[11]),U(a,"click",i[12])],g=!0)},p(x,[R]){if((!m||R&1)&&l!==(l=x[0].name+"")&&me(c,l),x[2]?w||(w=J_(x),w.c(),w.m(a,f)):w&&(w.d(1),w=null),x[1]?S||(S=ew(x),S.c(),S.m(a,null)):S&&(S.d(1),S=null),x[0].source?.length?C?C.p(x,R):(C=tw(x),C.c(),C.m(h,null)):C&&(C.d(1),C=null),R&9){k=fe(x[3]);let Z;for(Z=0;ZFf(s,e++)).join(t)}${n?")":""}`);else if(typeof i=="object")for(let s of Object.values(i))r.push(Ff(s,e++));return r.join(" ")}function nw(i){if(!Array.isArray(i))return i;let e=i.slice(0,2);return i.length>2&&e.push(`and ${i.length-2} more`),Ff(e,0,", ",!1)}function rw(i){return Array.isArray(i)?Ff(i,0,", ",!1):""}function vA(i,e,t){let n,r,s,o,{players:a}=ii,{average:l}=a;Se(i,l,O=>t(10,s=O));let c=Ue("plugin"),u=Ue("table");Se(i,u,O=>t(3,o=O));let{creature:f}=e,d=O=>{new rc.ExtraButtonComponent(O).setIcon("plus-with-circle")},h=O=>(0,rc.setIcon)(O,"baby"),p=O=>(0,rc.setIcon)(O,"skull"),m=()=>ii.add(f),g=O=>c.openCombatant(je.from(f),O.ctrlKey||O.metaKey);return i.$$set=O=>{"creature"in O&&t(0,f=O.creature)},i.$$.update=()=>{i.$$.dirty&1025&&t(2,n="cr"in f&&f.cr&&hi(f.cr)s+3)},[f,r,n,o,l,c,u,d,h,p,s,m,g]}var Jm=class extends ne{constructor(e){super(),re(this,e,vA,OA,ie,{creature:0},gA)}},sw=Jm;var Kf=require("obsidian");function Bf(i,{delay:e=0,duration:t=400,easing:n=Nn}={}){let r=+getComputedStyle(i).opacity;return{delay:e,duration:t,easing:n,css:s=>`opacity: ${s*r}`}}function eg(i,{delay:e=0,duration:t=400,easing:n=Da,axis:r="y"}={}){let s=getComputedStyle(i),o=+s.opacity,a=r==="y"?"height":"width",l=parseFloat(s[a]),c=r==="y"?["top","bottom"]:["left","right"],u=c.map(O=>`${O[0].toUpperCase()}${O.slice(1)}`),f=parseFloat(s[`padding${u[0]}`]),d=parseFloat(s[`padding${u[1]}`]),h=parseFloat(s[`margin${u[0]}`]),p=parseFloat(s[`margin${u[1]}`]),m=parseFloat(s[`border${u[0]}Width`]),g=parseFloat(s[`border${u[1]}Width`]);return{delay:e,duration:t,easing:n,css:O=>`overflow: hidden;opacity: ${Math.min(O*20,1)*o};${a}: ${O*l}px;padding-${c[0]}: ${O*f}px;padding-${c[1]}: ${O*d}px;margin-${c[0]}: ${O*h}px;margin-${c[1]}: ${O*p}px;border-${c[0]}-width: ${O*m}px;border-${c[1]}-width: ${O*g}px;`}}var yA=Function.prototype.toString,tg=Object.create,bA=Object.prototype.toString,_A=function(){function i(){this._keys=[],this._values=[]}return i.prototype.has=function(e){return!!~this._keys.indexOf(e)},i.prototype.get=function(e){return this._values[this._keys.indexOf(e)]},i.prototype.set=function(e,t){this._keys.push(e),this._values.push(t)},i}();function wA(){return new _A}function kA(){return new WeakMap}var SA=typeof WeakMap<"u"?kA:wA;function ng(i){if(!i)return tg(null);var e=i.constructor;if(e===Object)return i===Object.prototype?{}:tg(i);if(e&&~yA.call(e).indexOf("[native code]"))try{return new e}catch{}return tg(i)}function xA(i){var e="";return i.global&&(e+="g"),i.ignoreCase&&(e+="i"),i.multiline&&(e+="m"),i.unicode&&(e+="u"),i.sticky&&(e+="y"),e}function PA(i){return i.flags}var CA=/test/g.flags==="g"?PA:xA;function ow(i){var e=bA.call(i);return e.substring(8,e.length-1)}function EA(i){return i[Symbol.toStringTag]||ow(i)}var TA=typeof Symbol<"u"?EA:ow,AA=Object.defineProperty,DA=Object.getOwnPropertyDescriptor,aw=Object.getOwnPropertyNames,rg=Object.getOwnPropertySymbols,lw=Object.prototype,cw=lw.hasOwnProperty,QA=lw.propertyIsEnumerable,uw=typeof rg=="function";function RA(i){return aw(i).concat(rg(i))}var MA=uw?RA:aw;function Wf(i,e,t){for(var n=MA(i),r=0,s=n.length,o=void 0,a=void 0;r{let e=$e([...i.options]),{update:t,set:n,subscribe:r}=e,s=oi(e,o=>i.options[0]==o[0]&&i.options[1]==o[1]);return{isDefault:s,getIsDefault:()=>ut(s),update:t,set:n,subscribe:r,reset:()=>n([...i.options]),compare:o=>{if(ut(s))return!0;let a=ut(e);return hi(o)>=a[0]&&hi(o)<=a[1]},filter:i,...i}};function Xf(i){return typeof i!="string"?i:i.toLowerCase()}var JA=i=>{let e=$e([]),{subscribe:t,set:n,update:r}=e,s=oi(e,o=>!o.length);return{isDefault:s,getIsDefault:()=>ut(s),subscribe:t,set:n,reset:()=>n([]),compare:o=>{if(ut(s))return!0;if(typeof o=="number")return!1;let a=ut(e);return Array.isArray(o)?o.some(l=>a.includes(Xf(l))):a.includes(Xf(o))},update:r,filter:i,...i}},eD=i=>{let e="",t=$e(e),{subscribe:n,set:r,update:s}=t,o=oi(t,l=>!l.length),a=(0,ag.prepareSimpleSearch)("");return t.subscribe(l=>a=(0,ag.prepareSimpleSearch)(l)),{isDefault:o,getIsDefault:()=>ut(o),subscribe:n,set:r,reset:()=>r(e),compare:l=>ut(o)?!0:typeof l=="number"?!1:ut(o)||a(l)!=null,update:s,filter:i,...i}};function gw(i){switch(i.type){case 2:return JA(i);case 0:return KA(i);case 1:return eD(i)}}function Ow(i,e){let t=new Map(e.map(n=>[n,new Set]));for(let n of i)for(let r of e)for(let s of r.fields)if(s in n){switch(r.type){case 0:{let o=hi(n[s]);if(o==null||isNaN(o))continue;let a=[...t.get(r)];a.length||(a[0]=1/0,a[1]=-1/0),a[0]=Math.min(a[0],o),Math.max(a[1],o)!=a[0]&&(a[1]=Math.max(a[1],o)),t.set(r,new Set(a));break}case 2:{if(Array.isArray(n[s]))for(let o of n[s])t.get(r).add(Xf(o));else typeof n[s]=="string"&&t.get(r).add(Xf(n[s]));break}case 1:continue}continue}return t}function yw(i,e){let t=k=>{let _=gw(k);return n.set(k.id,_),o.set(k.id,_.subscribe(P=>{r.update(x=>x)})),_},n=new Map,r=$e(n),s=new Map;r.subscribe(k=>{for(let[_,P]of k)s.set(_,P.filter)});let o=new Map;e.data.builder||(e.data.builder={sidebarIcon:!0,showParty:!0,showXP:!0});let a=()=>ci(e.data.builder?.filters?.layout??vw),l=()=>ci(e.data.builder?.filters?.filters??og);e.data.builder.filters||(e.data.builder.filters={filters:l(),layout:a()});let c=e.data.builder?.filters?.filters??og,u=e.data.builder?.filters?.layout??a();if(c.filter(k=>k.derive).length){let k=Ow(ut(i),c);for(let[_,P]of k)_.options=Array.from(P)}for(let k of c)t(k);let d=oi([i,r],([k,_])=>{let P=[],x=Array.from(_.values());for(let R of k)x.every(Z=>{if(!Z.filter.fields.length)return!0;for(let Q of Z.filter.fields)if(Q in R)return Z.compare(R[Q]);return!0})&&P.push(R);return P}),h=$e(u??a()),p=k=>{h.set(k),e.data.builder.filters.layout=k,e.saveSettings()},m=k=>{p(k?vw:a()),g(_=>{_.clear();let P=k?og:l();for(let x of P)t(x);return _})};function g(k){r.update(_=>{let P=k(_);return e.data.builder.filters.filters=[...P.values()].map(x=>x.filter),e.saveSettings(),P})}let O=oi(r,k=>{let _=0;for(let P of k.values())P.getIsDefault()||_++;return _}),w=t(tD),S=(k,_)=>{if(k.derive){let x=Ow(ut(i),[k]);for(let[R,Z]of x)R.options=Array.from(Z)}let P=gw(k);return _.set(k.id,P),o.set(k.id,P.subscribe(x=>r.update(R=>R))),_},C=(k,_)=>(_.delete(k),o.has(k)&&(o.get(k)(),o.delete(k)),_);return{add:k=>g(_=>S(k,_)),update:(k,_)=>g(P=>(C(k,P),S(_,P))),remove:k=>g(_=>C(k.id,_)),reset:()=>g(k=>{for(let _ of k.values())_.reset();return k}),active:O,filtered:d,filters:r,filterMap:s,layout:{subscribe:h.subscribe,set:p},resetLayout:m,getOrDefault(k){return s?.get(k)??ci(lg)},name:w}}var pH=$e(),tD={type:1,text:"Name",fields:["name"],options:"",id:"ID_DEFAULT_NAME_FILTER",derive:!1},og=[{type:0,text:"CR",fields:["cr"],options:[0,30],id:"ID_DEFAULT_CR_FILTER",derive:!0},{type:2,text:"Size",fields:["size"],options:[],id:"ID_DEFAULT_SIZE_FILTER",derive:!0},{type:2,text:"Type",fields:["type"],options:[],id:"ID_DEFAULT_TYPE_FILTER",derive:!0},{type:2,text:"Alignment",fields:["alignment"],options:[],id:"ID_DEFAULT_ALIGNMENT_FILTER",derive:!0}],vw=[{nested:[{id:"ID_DEFAULT_CR_FILTER",type:"filter"}],id:"ID_DEFAULT_NESTED_CR",type:"nested"},{id:"ID_DEFAULT_NESTED_LAYOUT",type:"nested",nested:[{id:"ID_DEFAULT_SIZE_FILTER",type:"filter"},{id:"ID_DEFAULT_TYPE_FILTER",type:"filter"},{id:"ID_DEFAULT_ALIGNMENT_FILTER",type:"filter"}]}];function iD(i){se(i,"svelte-1dlbj12",'.thumb.svelte-1dlbj12{position:absolute;top:50%;width:0;height:0}.thumb-content.svelte-1dlbj12{position:relative;width:fit-content;height:fit-content;transform:translate(-50%, -50%)}.thumb-content.svelte-1dlbj12::before{content:"";position:absolute;width:200%;height:200%;transform:translate(-25%, -25%) scale(0);border-radius:100vh;background:var(--interactive-hover);opacity:30%;transition:transform 100ms ease-in-out}.thumb-content.active.svelte-1dlbj12::before{transform:translate(-25%, -25%) scale(1)}')}function nD(i){let e,t,n,r,s,o,a,l=i[4].default,c=Gt(l,i,i[3],null);return{c(){e=b("div"),t=b("div"),c&&c.c(),v(t,"class","thumb-content svelte-1dlbj12"),ge(t,"active",i[1]),v(e,"class","thumb svelte-1dlbj12"),v(e,"style",n=`left: ${i[0]*100}%;`)},m(u,f){A(u,e,f),y(e,t),c&&c.m(t,null),s=!0,o||(a=[H(r=rD.call(null,e)),U(e,"dragstart",i[6]),U(e,"drag",i[7]),U(e,"dragend",i[8]),U(e,"click",Vt(i[5]))],o=!0)},p(u,[f]){c&&c.p&&(!s||f&8)&&Jt(c,l,u,u[3],s?Kt(l,u[3],f,null):ei(u[3]),null),(!s||f&2)&&ge(t,"active",u[1]),(!s||f&1&&n!==(n=`left: ${u[0]*100}%;`))&&v(e,"style",n)},i(u){s||($(c,u),s=!0)},o(u){V(c,u),s=!1},d(u){u&&T(e),c&&c.d(u),o=!1,de(a)}}}function rD(i){let e=sD(i);return i.addEventListener("touchstart",e),i.addEventListener("mousedown",e),{destroy(){i.removeEventListener("touchstart",e),i.removeEventListener("mousedown",e)}}}function sD(i){let e=oD(i);return function(t){t.preventDefault(),i.dispatchEvent(new CustomEvent("dragstart"));let n="touches"in t?"touchmove":"mousemove",r="touches"in t?"touchend":"mouseup";document.addEventListener(n,e),document.addEventListener(r,s);function s(o){o.stopPropagation(),document.removeEventListener(n,e),document.removeEventListener(r,s),i.dispatchEvent(new CustomEvent("dragend"))}}}function oD(i){let e=i.parentElement;return function(t){let{left:n,width:r}=e.getBoundingClientRect(),s="touches"in t?t.touches[0].clientX:t.clientX,o=Math.min(Math.max((s-n)/r,0),1)||0;i.dispatchEvent(new CustomEvent("drag",{detail:o}))}}function aD(i,e,t){let{$$slots:n={},$$scope:r}=e,s=Fe(),o,{pos:a}=e;function l(d){ht.call(this,i,d)}let c=()=>(t(1,o=!0),s("active",!0)),u=({detail:d})=>t(0,a=d),f=()=>(t(1,o=!1),s("active",!1));return i.$$set=d=>{"pos"in d&&t(0,a=d.pos),"$$scope"in d&&t(3,r=d.$$scope)},[a,o,s,r,n,l,c,u,f]}var cg=class extends ne{constructor(e){super(),re(this,e,aD,nD,ie,{pos:0},iD)}},ug=cg;function lD(i){se(i,"svelte-1skvzai","input.svelte-1skvzai{display:none}.track-container.svelte-1skvzai{width:calc(100% - 16px);height:16px;display:flex;align-items:center}.track.svelte-1skvzai{margin:0 8px;position:relative;height:4px;width:calc(100% - 16px);border-radius:100vh;background:var(--background-modifier-form-field)}.progress.svelte-1skvzai{position:absolute;left:0;right:0;top:0;bottom:0;border-radius:100vh;background:var(--interactive-accent)}.thumb.svelte-1skvzai{width:16px;height:16px;border-radius:100vh;background:var(--interactive-accent)}.thumb.svelte-1skvzai:hover,.thumb.svelte-1skvzai:active{background:var(--interactive-hover)}")}function bw(i){let e,t,n;return{c(){e=b("input"),v(e,"type","number"),e.value=t=i[0][1],v(e,"name",n=i[1][1]),v(e,"class","svelte-1skvzai")},m(r,s){A(r,e,s)},p(r,s){s&1&&t!==(t=r[0][1])&&e.value!==t&&(e.value=t),s&2&&n!==(n=r[1][1])&&v(e,"name",n)},d(r){r&&T(e)}}}function cD(i){let e;return{c(){e=b("div"),v(e,"class","thumb svelte-1skvzai")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function _w(i){let e,t,n;function r(o){i[13](o)}let s={$$slots:{default:[uD]},$$scope:{ctx:i}};return i[3][1]!==void 0&&(s.pos=i[3][1]),e=new ug({props:s}),mi.push(()=>Ir(e,"pos",r)),e.$on("active",i[14]),{c(){ye(e.$$.fragment)},m(o,a){Oe(e,o,a),n=!0},p(o,a){let l={};a&524288&&(l.$$scope={dirty:a,ctx:o}),!t&&a&8&&(t=!0,l.pos=o[3][1],Rr(()=>t=!1)),e.$set(l)},i(o){n||($(e.$$.fragment,o),n=!0)},o(o){V(e.$$.fragment,o),n=!1},d(o){ve(e,o)}}}function uD(i){let e;return{c(){e=b("div"),v(e,"class","thumb svelte-1skvzai")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function fD(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=i[2]&&bw(i);function O(C){i[11](C)}let w={$$slots:{default:[cD]},$$scope:{ctx:i}};i[3][0]!==void 0&&(w.pos=i[3][0]),u=new ug({props:w}),mi.push(()=>Ir(u,"pos",O)),u.$on("active",i[12]);let S=i[2]&&_w(i);return{c(){e=b("div"),t=b("input"),s=M(),g&&g.c(),o=M(),a=b("div"),l=b("div"),c=M(),ye(u.$$.fragment),d=M(),S&&S.c(),v(t,"type","number"),t.value=n=i[0][0],v(t,"name",r=i[1][0]),v(t,"class","svelte-1skvzai"),v(l,"class","progress svelte-1skvzai"),v(l,"style",i[5]),v(a,"class","track svelte-1skvzai"),v(e,"class","track-container svelte-1skvzai")},m(C,k){A(C,e,k),y(e,t),y(e,s),g&&g.m(e,null),y(e,o),y(e,a),y(a,l),y(a,c),Oe(u,a,null),y(a,d),S&&S.m(a,null),h=!0,p||(m=U(e,"click",i[6]),p=!0)},p(C,[k]){(!h||k&1&&n!==(n=C[0][0])&&t.value!==n)&&(t.value=n),(!h||k&2&&r!==(r=C[1][0]))&&v(t,"name",r),C[2]?g?g.p(C,k):(g=bw(C),g.c(),g.m(e,o)):g&&(g.d(1),g=null),(!h||k&32)&&v(l,"style",C[5]);let _={};k&524288&&(_.$$scope={dirty:k,ctx:C}),!f&&k&8&&(f=!0,_.pos=C[3][0],Rr(()=>f=!1)),u.$set(_),C[2]?S?(S.p(C,k),k&4&&$(S,1)):(S=_w(C),S.c(),$(S,1),S.m(a,null)):S&&(Ae(),V(S,1,1,()=>{S=null}),De())},i(C){h||($(u.$$.fragment,C),$(S),h=!0)},o(C){V(u.$$.fragment,C),V(S),h=!1},d(C){C&&T(e),g&&g.d(),ve(u),S&&S.d(),p=!1,m()}}}function dD(i){return[Math.min(...i),Math.max(...i)]}function hD(i,e,t){let n,r=Fe(),{name:s=[]}=e,{range:o=!1}=e,{min:a=0}=e,{max:l=100}=e,{step:c=1}=e,{value:u=[a,l]}=e,f,d=!1,{order:h=!1}=e;function p(_){let P=a%c,x=l-a;t(0,u=_.map(R=>a+R*x).map(R=>Math.round((R-P)/c)*c+P)),r("input",u)}function m(_){t(3,f=_.map(P=>Math.min(Math.max(P,a),l)).map(P=>(P-a)/(l-a)))}function g(){m(u),p(f)}function O(_){let P=_.target,x=_.offsetX/P.clientWidth,R=f.map(Z=>Math.abs(x-Z));R[1]>R[0]?t(3,f=[x,f[1]]):t(3,f=[f[0],x]),p(f)}function w(_){i.$$.not_equal(f[0],_)&&(f[0]=_,t(3,f),t(2,o),t(10,h),t(4,d))}let S=({detail:_})=>t(4,d=_);function C(_){i.$$.not_equal(f[1],_)&&(f[1]=_,t(3,f),t(2,o),t(10,h),t(4,d))}let k=({detail:_})=>t(4,d=_);return i.$$set=_=>{"name"in _&&t(1,s=_.name),"range"in _&&t(2,o=_.range),"min"in _&&t(7,a=_.min),"max"in _&&t(8,l=_.max),"step"in _&&t(9,c=_.step),"value"in _&&t(0,u=_.value),"order"in _&&t(10,h=_.order)},i.$$.update=()=>{i.$$.dirty&1052&&o&&h&&d&&t(3,f=dD(f)),i.$$.dirty&24&&d&&p(f),i.$$.dirty&17&&(d||m(u)),i.$$.dirty&384&&g(),i.$$.dirty&12&&t(5,n=` left: ${o?Math.min(f[0],f[1])*100:0}%; right: ${100-Math.max(f[0],o?f[1]:f[0])*100}%; `)},[u,s,o,f,d,n,O,a,l,c,h,w,S,C,k]}var fg=class extends ne{constructor(e){super(),re(this,e,hD,fD,ie,{name:1,range:2,min:7,max:8,step:9,value:0,order:10},lD)}},ww=fg;function pD(i){se(i,"svelte-191t5bs",".range-filter.svelte-191t5bs{display:flex;align-items:center;gap:1rem;width:100%;white-space:nowrap}")}function mD(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,w,S,C;function k(P){i[5](P)}let _={range:!0,order:!0,min:i[0].options[0],max:i[0].options[1]};return i[3]!==void 0&&(_.value=i[3]),c=new ww({props:_}),mi.push(()=>Ir(c,"value",k)),{c(){e=b("div"),t=b("span"),n=ae(i[2]),r=M(),s=b("input"),l=M(),ye(c.$$.fragment),f=M(),d=b("input"),m=M(),g=b("span"),O=ae(i[1]),v(s,"type","number"),v(s,"placeholder",i[2]),v(s,"min",o=i[0].options[0]),v(s,"max",a=i[0].options[1]),v(d,"type","number"),v(d,"placeholder",i[1]),v(d,"min",h=i[0].options[0]),v(d,"max",p=i[0].options[1]),v(e,"class","range-filter svelte-191t5bs")},m(P,x){A(P,e,x),y(e,t),y(t,n),y(e,r),y(e,s),Xe(s,i[3][0]),y(e,l),Oe(c,e,null),y(e,f),y(e,d),Xe(d,i[3][1]),y(e,m),y(e,g),y(g,O),w=!0,S||(C=[U(s,"input",i[4]),U(d,"input",i[6])],S=!0)},p(P,[x]){(!w||x&4)&&me(n,P[2]),(!w||x&4)&&v(s,"placeholder",P[2]),(!w||x&1&&o!==(o=P[0].options[0]))&&v(s,"min",o),(!w||x&1&&a!==(a=P[0].options[1]))&&v(s,"max",a),x&8&&pi(s.value)!==P[3][0]&&Xe(s,P[3][0]);let R={};x&1&&(R.min=P[0].options[0]),x&1&&(R.max=P[0].options[1]),!u&&x&8&&(u=!0,R.value=P[3],Rr(()=>u=!1)),c.$set(R),(!w||x&2)&&v(d,"placeholder",P[1]),(!w||x&1&&h!==(h=P[0].options[0]))&&v(d,"min",h),(!w||x&1&&p!==(p=P[0].options[1]))&&v(d,"max",p),x&8&&pi(d.value)!==P[3][1]&&Xe(d,P[3][1]),(!w||x&2)&&me(O,P[1])},i(P){w||($(c.$$.fragment,P),w=!0)},o(P){V(c.$$.fragment,P),w=!1},d(P){P&&T(e),ve(c),S=!1,de(C)}}}function gD(i,e,t){let n,r,s,o=X,a=()=>(o(),o=Mi(l,d=>t(3,s=d)),l);i.$$.on_destroy.push(()=>o());let{filter:l}=e;a();function c(){s[0]=pi(this.value),l.set(s)}function u(d){s=d,l.set(s)}function f(){s[1]=pi(this.value),l.set(s)}return i.$$set=d=>{"filter"in d&&a(t(0,l=d.filter))},i.$$.update=()=>{i.$$.dirty&1&&t(2,n=`Min ${l.filter.text}`),i.$$.dirty&1&&t(1,r=`Max ${l.filter.text}`)},[l,r,n,s,c,u,f]}var dg=class extends ne{constructor(e){super(),re(this,e,gD,mD,ie,{filter:0},pD)}},kw=dg;function OD(i){se(i,"svelte-66wdl1","div.svelte-66wdl1{display:inline-block;vertical-align:middle;margin:0 3pt;border-width:calc(1em / 5);border-style:solid;border-radius:50%;animation:var(--duration) infinite svelte-66wdl1-rotate}@keyframes svelte-66wdl1-rotate{100%{transform:rotate(360deg)}}")}function vD(i){let e,t=`${i[0]} transparent ${i[0]} ${i[0]}`;return{c(){e=b("div"),Te(e,"--duration",i[1]),v(e,"class","svelte-66wdl1"),Te(e,"border-color",t),Te(e,"width",i[2]),Te(e,"height",i[2])},m(n,r){A(n,e,r)},p(n,[r]){r&2&&Te(e,"--duration",n[1]);let s=r&2;(r&3&&t!==(t=`${n[0]} transparent ${n[0]} ${n[0]}`)||s)&&Te(e,"border-color",t),(r&6||s)&&Te(e,"width",n[2]),(r&6||s)&&Te(e,"height",n[2])},i:X,o:X,d(n){n&&T(e)}}}function yD(i,e,t){let{color:n="cornflowerblue"}=e,{duration:r="1.5s"}=e,{size:s="1em"}=e;return i.$$set=o=>{"color"in o&&t(0,n=o.color),"duration"in o&&t(1,r=o.duration),"size"in o&&t(2,s=o.size)},[n,r,s]}var hg=class extends ne{constructor(e){super(),re(this,e,yD,vD,ie,{color:0,duration:1,size:2},OD)}},pg=hg;function bD(i){let e,t=`rotate(${i[0].angle}deg) scale(${i[0].scale}) translate(${i[0].dx}px, ${i[0].dy}px)`,n,r=i[11].default,s=Gt(r,i,i[10],null);return{c(){e=b("span"),s&&s.c(),Te(e,"transform",t)},m(o,a){A(o,e,a),s&&s.m(e,null),n=!0},p(o,[a]){s&&s.p&&(!n||a&1024)&&Jt(s,r,o,o[10],n?Kt(r,o[10],a,null):ei(o[10]),null),a&1&&t!==(t=`rotate(${o[0].angle}deg) scale(${o[0].scale}) translate(${o[0].dx}px, ${o[0].dy}px)`)&&Te(e,"transform",t)},i(o){n||($(s,o),n=!0)},o(o){V(s,o),n=!1},d(o){o&&T(e),s&&s.d(o)}}}function _D(i,e,t){let n,{$$slots:r={},$$scope:s}=e,{wiggle:o=!1}=e,{angle:a=0}=e,{scale:l=1}=e,{dx:c=0}=e,{dy:u=0}=e,{duration:f=200}=e,{stiffness:d=.05}=e,{damping:h=.1}=e,p={angle:0,scale:1,dx:0,dy:0},m=O_(p,{stiffness:d,damping:h});return Se(i,m,g=>t(0,n=g)),i.$$set=g=>{"wiggle"in g&&t(2,o=g.wiggle),"angle"in g&&t(3,a=g.angle),"scale"in g&&t(4,l=g.scale),"dx"in g&&t(5,c=g.dx),"dy"in g&&t(6,u=g.dy),"duration"in g&&t(7,f=g.duration),"stiffness"in g&&t(8,d=g.stiffness),"damping"in g&&t(9,h=g.damping),"$$scope"in g&&t(10,s=g.$$scope)},i.$$.update=()=>{i.$$.dirty&132&&o&&setTimeout(()=>t(2,o=!1),f),i.$$.dirty&124&&m.set(o?{scale:l,angle:a,dx:c,dy:u}:p)},[n,m,o,a,l,c,u,f,d,h,s,r]}var mg=class extends ne{constructor(e){super(),re(this,e,_D,bD,ie,{wiggle:2,angle:3,scale:4,dx:5,dy:6,duration:7,stiffness:8,damping:9})}},gg=mg;function wD(i){let e,t,n=[i[0],{fill:"currentColor"},{viewBox:"0 0 16 16"}],r={};for(let s=0;s{t(0,e=ti(ti({},e),rr(n)))},e=rr(e),[e]}var Og=class extends ne{constructor(e){super(),re(this,e,kD,wD,ie,{})}},vg=Og;function SD(i){let e,t,n=[i[0],{viewBox:"0 0 24 24"},{fill:"currentColor"}],r={};for(let s=0;s{t(0,e=ti(ti({},e),rr(n)))},e=rr(e),[e]}var yg=class extends ne{constructor(e){super(),re(this,e,xD,SD,ie,{})}},Uf=yg;function PD(i){let e,t,n=[i[0],{viewBox:"0 0 24 24"},{fill:"currentColor"}],r={};for(let s=0;s{t(0,e=ti(ti({},e),rr(n)))},e=rr(e),[e]}var bg=class extends ne{constructor(e){super(),re(this,e,CD,PD,ie,{})}},_g=bg;var wi=i=>i instanceof Object?(i.label===void 0&&console.error(`MultiSelect option ${JSON.stringify(i)} is an object but has no label key`),i.label):`${i}`;function sc(i,e=null){let t="";if(["selected","option",null].includes(e)||console.error(`MultiSelect: Invalid key=${e} for get_style`),typeof i=="object"&&i.style&&(typeof i.style=="string"&&(t=i.style),typeof i.style=="object")){if(e&&e in i.style)return i.style[e]??"";console.error(`Invalid style object for option=${JSON.stringify(i)}`)}return t.trim()&&!t.trim().endsWith(";")&&(t+=";"),t}var{Boolean:ED}=Nl;function TD(i){se(i,"svelte-1r2hsto",".svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect){position:relative;align-items:center;display:flex;cursor:text;box-sizing:border-box;border:var(--sms-border, 1pt solid lightgray);border-radius:var(--sms-border-radius, 3pt);background:var(--sms-bg);width:var(--sms-width);max-width:var(--sms-max-width);padding:var(--sms-padding, 0 3pt);color:var(--sms-text-color);font-size:var(--sms-font-size, inherit);min-height:var(--sms-min-height, 22pt);margin:var(--sms-margin)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect.open){z-index:var(--sms-open-z-index, 4)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect:focus-within){border:var(--sms-focus-border, 1pt solid var(--sms-active-color, cornflowerblue))}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect.disabled){background:var(--sms-disabled-bg, lightgray);cursor:not-allowed}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.selected){display:flex;flex:1;padding:0;margin:0;flex-wrap:wrap}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.selected > li){align-items:center;border-radius:3pt;display:flex;margin:2pt;line-height:normal;transition:0.3s;white-space:nowrap;background:var(--sms-selected-bg, rgba(0, 0, 0, 0.15));padding:var(--sms-selected-li-padding, 1pt 5pt);color:var(--sms-selected-text-color, var(--sms-text-color))}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.selected > li[draggable='true']){cursor:grab}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.selected > li.active){background:var(--sms-li-active-bg, var(--sms-active-color, rgba(0, 0, 0, 0.15)))}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect button){border-radius:50%;display:flex;transition:0.2s;color:inherit;background:transparent;border:none;cursor:pointer;outline:none;padding:0;margin:0 0 0 3pt}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect button.remove-all){margin:0 3pt}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(ul.selected > li button:hover, button.remove-all:hover, button:focus){color:var(--sms-remove-btn-hover-color, lightskyblue);background:var(--sms-remove-btn-hover-bg, rgba(0, 0, 0, 0.2))}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect input){margin:auto 0;padding:0}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.selected > input){border:none;outline:none;background:none;flex:1;min-width:2em;color:var(--sms-text-color);font-size:inherit;cursor:inherit;border-radius:0}div.multiselect.svelte-1r2hsto>ul.selected.svelte-1r2hsto>input.svelte-1r2hsto::placeholder{padding-left:5pt;color:var(--sms-placeholder-color);opacity:var(--sms-placeholder-opacity)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > input.form-control){width:2em;position:absolute;background:transparent;border:none;outline:none;z-index:-1;opacity:0;pointer-events:none}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options){list-style:none;top:100%;left:0;width:100%;position:absolute;overflow:auto;transition:all 0.2s;box-sizing:border-box;background:var(--sms-options-bg, white);max-height:var(--sms-options-max-height, 50vh);overscroll-behavior:var(--sms-options-overscroll, none);box-shadow:var(--sms-options-shadow, 0 0 14pt -8pt black);border:var(--sms-options-border);border-width:var(--sms-options-border-width);border-radius:var(--sms-options-border-radius, 1ex);padding:var(--sms-options-padding);margin:var(--sms-options-margin, inherit)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options.hidden){visibility:hidden;opacity:0;transform:translateY(50px)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options > li){padding:3pt 2ex;cursor:pointer;scroll-margin:var(--sms-options-scroll-margin, 100px)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options .user-msg){display:block;padding:3pt 2ex}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options > li.selected){background:var(--sms-li-selected-bg);color:var(--sms-li-selected-color)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options > li.active){background:var(--sms-li-active-bg, var(--sms-active-color, rgba(0, 0, 0, 0.15)))}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options > li.disabled){cursor:not-allowed;background:var(--sms-li-disabled-bg, #f5f5f6);color:var(--sms-li-disabled-text, #b8b8b8)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(span.max-select-msg){padding:0 3pt}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto::highlight(sms-search-matches){color:mediumaquamarine}")}var AD=i=>({searchText:i[0]&16,msgType:i[0]&68660|i[1]&16,msg:i[0]&101428|i[1]&16}),Sw=i=>({searchText:i[4],msgType:i[124],msg:i[125]});function wg(i){let e=i.slice(),t={dupe:e[15],create:e[10],"no-match":e[35]}[e[124]];return e[125]=t,e}function kg(i){let e=i.slice(),t=e[5].map(wi).includes(e[4]);e[120]=t;let n=!e[16]&&e[120]&&"dupe";e[121]=n;let r=!!(e[11]&&e[10])&&"create";e[122]=r;let s=!!(e[2]?.length==0&&e[35])&&"no-match";e[123]=s;let o=e[121]||e[122]||e[123];return e[124]=o,e}function xw(i,e,t){let n=i.slice();n[126]=e[t],n[133]=t;let r=n[126]instanceof Object?n[126]:{label:n[126]};n[127]=r.label,n[50]=r.disabled!==void 0?r.disabled:null,n[128]=r.title!==void 0?r.title:null,n[129]=r.selectedTitle!==void 0?r.selectedTitle:null,n[130]=r.disabledTitle!==void 0?r.disabledTitle:n[13];let s=n[0]===n[133];return n[131]=s,n}var DD=i=>({option:i[0]&1073741828}),Pw=i=>({option:i[126],idx:i[133]}),QD=i=>({option:i[0]&1073741828}),Cw=i=>({option:i[126],idx:i[133]}),RD=i=>({}),Ew=i=>({}),MD=i=>({}),Tw=i=>({}),ID=i=>({}),Aw=i=>({}),ND=i=>({selected:i[0]&32,disabled:i[1]&524288,invalid:i[0]&128,id:i[0]&262144,placeholder:i[1]&256,open:i[0]&256,required:i[1]&4096}),Dw=i=>({selected:i[5],disabled:i[50],invalid:i[7],id:i[18],placeholder:i[39],open:i[8],required:i[43]});function Qw(i,e,t){let n=i.slice();return n[126]=e[t],n[133]=t,n}var jD=i=>({}),Rw=i=>({}),ZD=i=>({option:i[0]&32,idx:i[0]&32}),Mw=i=>({option:i[126],idx:i[133]}),zD=i=>({option:i[0]&32,idx:i[0]&32}),Iw=i=>({option:i[126],idx:i[133]}),qD=i=>({open:i[0]&256}),Nw=i=>({open:i[8]});function LD(i){let e,t;return e=new vg({props:{width:"15px",style:"min-width: 1em; padding: 0 1pt; cursor: pointer;"}}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function $D(i){let e=wi(i[126])+"",t;return{c(){t=ae(e)},m(n,r){A(n,t,r)},p(n,r){r[0]&32&&e!==(e=wi(n[126])+"")&&me(t,e)},d(n){n&&T(t)}}}function FD(i){let e,t=wi(i[126])+"",n;return{c(){e=new jl(!1),n=tt(),e.a=n},m(r,s){e.m(t,r,s),A(r,n,s)},p(r,s){s[0]&32&&t!==(t=wi(r[126])+"")&&e.p(t)},d(r){r&&(T(n),e.d())}}}function BD(i){let e;function t(s,o){return s[37]?FD:$D}let n=t(i,[-1,-1,-1,-1,-1]),r=n(i);return{c(){r.c(),e=tt()},m(s,o){r.m(s,o),A(s,e,o)},p(s,o){n===(n=t(s,o))&&r?r.p(s,o):(r.d(1),r=n(s),r&&(r.c(),r.m(e.parentNode,e)))},d(s){s&&T(e),r.d(s)}}}function VD(i){let e,t=i[77].default,n=Gt(t,i,i[115],Mw),r=n||BD(i);return{c(){r&&r.c()},m(s,o){r&&r.m(s,o),e=!0},p(s,o){n?n.p&&(!e||o[0]&32|o[3]&4194304)&&Jt(n,t,s,s[115],e?Kt(t,s[115],o,ZD):ei(s[115]),Mw):r&&r.p&&(!e||o[0]&32|o[1]&64)&&r.p(s,e?o:[-1,-1,-1,-1,-1])},i(s){e||($(r,s),e=!0)},o(s){V(r,s),e=!1},d(s){r&&r.d(s)}}}function jw(i){let e,t,n,r,s,o=i[77]["remove-icon"],a=Gt(o,i,i[115],Rw),l=a||WD(i);function c(){return i[97](i[126])}function u(){return i[98](i[126])}return{c(){e=b("button"),l&&l.c(),v(e,"type","button"),v(e,"title",t=i[41]+" "+wi(i[126])),v(e,"class","remove svelte-1r2hsto")},m(f,d){A(f,e,d),l&&l.m(e,null),n=!0,r||(s=[U(e,"mouseup",Vt(c)),U(e,"keydown",function(){Ge(i[62](u))&&i[62](u).apply(this,arguments)})],r=!0)},p(f,d){i=f,a&&a.p&&(!n||d[3]&4194304)&&Jt(a,o,i,i[115],n?Kt(o,i[115],d,jD):ei(i[115]),Rw),(!n||d[0]&32|d[1]&1024&&t!==(t=i[41]+" "+wi(i[126])))&&v(e,"title",t)},i(f){n||($(l,f),n=!0)},o(f){V(l,f),n=!1},d(f){f&&T(e),l&&l.d(f),r=!1,de(s)}}}function WD(i){let e,t;return e=new Uf({props:{width:"15px"}}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function Zw(i,e){let t,n,r,s,o,a,l=X,c,u,f,d=e[77].selected,h=Gt(d,e,e[115],Iw),p=h||VD(e),m=!e[50]&&(e[42]===null||e[5].length>e[42])&&jw(e);function g(){return e[99](e[133])}return{key:i,first:null,c(){t=b("li"),p&&p.c(),n=M(),m&&m.c(),v(t,"class",r=un(e[26])+" svelte-1r2hsto"),v(t,"role","option"),v(t,"aria-selected","true"),v(t,"draggable",s=e[44]&&!e[50]&&e[5].length>1),v(t,"style",o=sc(e[126],"selected")+" "+e[27]),ge(t,"active",e[54]===e[133]),this.first=t},m(O,w){A(O,t,w),p&&p.m(t,null),y(t,n),m&&m.m(t,null),c=!0,u||(f=[U(t,"dragstart",function(){Ge(e[65](e[133]))&&e[65](e[133]).apply(this,arguments)}),U(t,"drop",Jp(function(){Ge(e[64](e[133]))&&e[64](e[133]).apply(this,arguments)})),U(t,"dragenter",g),U(t,"dragover",Jp(e[93]))],u=!0)},p(O,w){e=O,h?h.p&&(!c||w[0]&32|w[3]&4194304)&&Jt(h,d,e,e[115],c?Kt(d,e[115],w,zD):ei(e[115]),Iw):p&&p.p&&(!c||w[0]&32|w[1]&64|w[3]&4194304)&&p.p(e,c?w:[-1,-1,-1,-1,-1]),!e[50]&&(e[42]===null||e[5].length>e[42])?m?(m.p(e,w),w[0]&32|w[1]&526336&&$(m,1)):(m=jw(e),m.c(),$(m,1),m.m(t,null)):m&&(Ae(),V(m,1,1,()=>{m=null}),De()),(!c||w[0]&67108864&&r!==(r=un(e[26])+" svelte-1r2hsto"))&&v(t,"class",r),(!c||w[0]&32|w[1]&532480&&s!==(s=e[44]&&!e[50]&&e[5].length>1))&&v(t,"draggable",s),(!c||w[0]&134217760&&o!==(o=sc(e[126],"selected")+" "+e[27]))&&v(t,"style",o),(!c||w[0]&67108896|w[1]&8388608)&&ge(t,"active",e[54]===e[133])},r(){a=t.getBoundingClientRect()},f(){Qr(t),l()},a(){l(),l=Dr(t,a,jr,{duration:100})},i(O){c||($(p,O),$(m),c=!0)},o(O){V(p,O),V(m),c=!1},d(O){O&&T(t),p&&p.d(O),m&&m.d(),u=!1,de(f)}}}function zw(i){let e,t=i[77].spinner,n=Gt(t,i,i[115],Aw),r=n||XD(i);return{c(){r&&r.c()},m(s,o){r&&r.m(s,o),e=!0},p(s,o){n&&n.p&&(!e||o[3]&4194304)&&Jt(n,t,s,s[115],e?Kt(t,s[115],o,ID):ei(s[115]),Aw)},i(s){e||($(r,s),e=!0)},o(s){V(r,s),e=!1},d(s){r&&r.d(s)}}}function XD(i){let e,t;return e=new pg({}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function UD(i){let e,t,n,r=i[31]&&(i[31]>1||i[32])&&qw(i),s=i[31]!==1&&i[5].length>1&&Lw(i);return{c(){r&&r.c(),e=M(),s&&s.c(),t=tt()},m(o,a){r&&r.m(o,a),A(o,e,a),s&&s.m(o,a),A(o,t,a),n=!0},p(o,a){o[31]&&(o[31]>1||o[32])?r?(r.p(o,a),a[1]&3&&$(r,1)):(r=qw(o),r.c(),$(r,1),r.m(e.parentNode,e)):r&&(Ae(),V(r,1,1,()=>{r=null}),De()),o[31]!==1&&o[5].length>1?s?(s.p(o,a),a[0]&32|a[1]&1&&$(s,1)):(s=Lw(o),s.c(),$(s,1),s.m(t.parentNode,t)):s&&(Ae(),V(s,1,1,()=>{s=null}),De())},i(o){n||($(r),$(s),n=!0)},o(o){V(r),V(s),n=!1},d(o){o&&(T(e),T(t)),r&&r.d(o),s&&s.d(o)}}}function YD(i){let e,t=i[77]["disabled-icon"],n=Gt(t,i,i[115],Tw),r=n||KD(i);return{c(){r&&r.c()},m(s,o){r&&r.m(s,o),e=!0},p(s,o){n&&n.p&&(!e||o[3]&4194304)&&Jt(n,t,s,s[115],e?Kt(t,s[115],o,MD):ei(s[115]),Tw)},i(s){e||($(r,s),e=!0)},o(s){V(r,s),e=!1},d(s){r&&r.d(s)}}}function qw(i){let e,t,n;function r(o){i[102](o)}let s={angle:20,$$slots:{default:[HD]},$$scope:{ctx:i}};return i[51]!==void 0&&(s.wiggle=i[51]),e=new gg({props:s}),mi.push(()=>Ir(e,"wiggle",r)),{c(){ye(e.$$.fragment)},m(o,a){Oe(e,o,a),n=!0},p(o,a){let l={};a[0]&32|a[1]&7|a[3]&4194304&&(l.$$scope={dirty:a,ctx:o}),!t&&a[1]&1048576&&(t=!0,l.wiggle=o[51],Rr(()=>t=!1)),e.$set(l)},i(o){n||($(e.$$.fragment,o),n=!0)},o(o){V(e.$$.fragment,o),n=!1},d(o){ve(e,o)}}}function HD(i){let e,t=i[32]?.(i[5].length,i[31])+"",n,r;return{c(){e=b("span"),n=ae(t),v(e,"class",r="max-select-msg "+i[33]+" svelte-1r2hsto")},m(s,o){A(s,e,o),y(e,n)},p(s,o){o[0]&32|o[1]&3&&t!==(t=s[32]?.(s[5].length,s[31])+"")&&me(n,t),o[1]&4&&r!==(r="max-select-msg "+s[33]+" svelte-1r2hsto")&&v(e,"class",r)},d(s){s&&T(e)}}}function Lw(i){let e,t,n,r,s=i[77]["remove-icon"],o=Gt(s,i,i[115],Ew),a=o||GD(i);return{c(){e=b("button"),a&&a.c(),v(e,"type","button"),v(e,"class","remove remove-all svelte-1r2hsto"),v(e,"title",i[40])},m(l,c){A(l,e,c),a&&a.m(e,null),t=!0,n||(r=[U(e,"mouseup",Vt(i[61])),U(e,"keydown",i[62](i[61]))],n=!0)},p(l,c){o&&o.p&&(!t||c[3]&4194304)&&Jt(o,s,l,l[115],t?Kt(s,l[115],c,RD):ei(l[115]),Ew),(!t||c[1]&512)&&v(e,"title",l[40])},i(l){t||($(a,l),t=!0)},o(l){V(a,l),t=!1},d(l){l&&T(e),a&&a.d(l),n=!1,de(r)}}}function GD(i){let e,t;return e=new Uf({props:{width:"15px"}}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function KD(i){let e,t;return e=new _g({props:{width:"14pt",style:"margin: 0 2pt;","data-name":"disabled-icon"}}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function $w(i){let e,t,n,r,s,o,a=fe(i[2].slice(0,Math.max(0,i[30]??0)||1/0)),l=[];for(let f=0;fV(l[f],1,1,()=>{l[f]=null}),u=i[4]&&Bw(kg(i));return{c(){e=b("ul");for(let f=0;f1),v(e,"aria-expanded",i[8]),v(e,"aria-disabled",s=i[50]?"true":null),v(e,"style",i[49]),ge(e,"hidden",!i[8])},m(f,d){A(f,e,d);for(let h=0;h{u=null}),De()),(!o||d[1]&32768&&n!==(n="options "+f[46]+" svelte-1r2hsto"))&&v(e,"class",n),(!o||d[1]&1&&r!==(r=f[31]===null||f[31]>1))&&v(e,"aria-multiselectable",r),(!o||d[0]&256)&&v(e,"aria-expanded",f[8]),(!o||d[1]&524288&&s!==(s=f[50]?"true":null))&&v(e,"aria-disabled",s),(!o||d[1]&262144)&&v(e,"style",f[49]),(!o||d[0]&256|d[1]&32768)&&ge(e,"hidden",!f[8])},i(f){if(!o){for(let d=0;d{n=null}),De())},i(r){t||($(n),t=!0)},o(r){V(n),t=!1},d(r){r&&T(e),n&&n.d(r)}}}function Vw(i){let e,t,n,r,s,o=i[77]["user-msg"],a=Gt(o,i,i[115],Sw),l=a||n8(i);return{c(){e=b("li"),l&&l.c(),v(e,"title",i[10]),v(e,"role","option"),v(e,"aria-selected","false"),v(e,"class",t="user-msg "+i[28]+" "+(i[52]?i[23]:"")+" svelte-1r2hsto"),ge(e,"active",i[52]),Te(e,"cursor",{dupe:"not-allowed",create:"pointer","no-match":"default"}[i[124]])},m(c,u){A(c,e,u),l&&l.m(e,null),n=!0,r||(s=[U(e,"mousedown",Vt(i[78])),U(e,"mouseup",Vt(i[108])),U(e,"mouseover",i[109]),U(e,"focus",i[110]),U(e,"mouseout",i[111]),U(e,"blur",i[112])],r=!0)},p(c,u){a?a.p&&(!n||u[0]&101428|u[1]&16|u[3]&4194304)&&Jt(a,o,c,c[115],n?Kt(o,c[115],u,AD):ei(c[115]),Sw):l&&l.p&&(!n||u[0]&101428|u[1]&16)&&l.p(c,n?u:[-1,-1,-1,-1,-1]),(!n||u[0]&1024)&&v(e,"title",c[10]),(!n||u[0]&276824064|u[1]&2097152&&t!==(t="user-msg "+c[28]+" "+(c[52]?c[23]:"")+" svelte-1r2hsto"))&&v(e,"class",t),(!n||u[0]&276824064|u[1]&2097152)&&ge(e,"active",c[52]),u[0]&68660|u[1]&16&&Te(e,"cursor",{dupe:"not-allowed",create:"pointer","no-match":"default"}[c[124]])},i(c){n||($(l,c),n=!0)},o(c){V(l,c),n=!1},d(c){c&&T(e),l&&l.d(c),r=!1,de(s)}}}function n8(i){let e=i[125]+"",t;return{c(){t=ae(e)},m(n,r){A(n,t,r)},p(n,r){r[0]&101428|r[1]&16&&e!==(e=n[125]+"")&&me(t,e)},d(n){n&&T(t)}}}function r8(i){let e,t,n,r,s,o,a=[],l=new Map,c,u,f,d,h,p,m,g,O,w,S,C,k,_,P,x,R;_n(i[94]);let Z=i[77]["expand-icon"],Q=Gt(Z,i,i[115],Nw),D=Q||LD(i),E=fe(i[5]),j=B=>B[16]?[B[17](B[126]),B[133]]:B[17](B[126]);for(let B=0;B0?1:-1}~(w=Pe(i,[-1,-1,-1,-1,-1]))&&(S=ce[w]=Y[w](i));let ue=(i[4]&&i[35]||i[3]?.length>0)&&$w(i);return{c(){e=b("div"),t=b("input"),r=M(),D&&D.c(),s=M(),o=b("ul");for(let B=0;B=Number(i[43])?JSON.stringify(i[5]):null,v(t,"tabindex","-1"),v(t,"aria-hidden","true"),v(t,"aria-label","ignore this, used only to prevent form submission if select is required but empty"),v(t,"class","form-control svelte-1r2hsto"),v(u,"class",f=un(i[19])+" svelte-1r2hsto"),v(u,"style",i[20]),v(u,"id",i[18]),u.disabled=i[50],v(u,"autocomplete",i[12]),v(u,"inputmode",i[21]),v(u,"pattern",i[38]),v(u,"placeholder",d=i[5].length==0?i[39]:null),v(u,"aria-invalid",h=i[7]?"true":null),v(u,"ondrop","return false"),v(o,"class",m="selected "+i[47]+" svelte-1r2hsto"),v(o,"aria-label","selected options"),v(o,"style",i[48]),v(e,"class",k="multiselect "+i[36]+" svelte-1r2hsto"),v(e,"title",_=i[50]?i[14]:null),v(e,"data-id",i[18]),v(e,"role","searchbox"),v(e,"tabindex","-1"),v(e,"style",i[45]),ge(e,"disabled",i[50]),ge(e,"single",i[31]===1),ge(e,"open",i[8]),ge(e,"invalid",i[7])},m(B,ee){A(B,e,ee),y(e,t),i[95](t),y(e,r),D&&D.m(e,null),y(e,s),y(e,o);for(let pe=0;pe=Number(B[43])?JSON.stringify(B[5]):null)&&t.value!==n)&&(t.value=n),Q&&Q.p&&(!P||ee[0]&256|ee[3]&4194304)&&Jt(Q,Z,B,B[115],P?Kt(Z,B[115],ee,qD):ei(B[115]),Nw),ee[0]&201523232|ee[1]&143141952|ee[2]&13|ee[3]&4194304){E=fe(B[5]),Ae();for(let Re=0;Re{G=null}),De());let pe=w;w=Pe(B,ee),w===pe?~w&&ce[w].p(B,ee):(S&&(Ae(),V(ce[pe],1,1,()=>{ce[pe]=null}),De()),~w?(S=ce[w],S?S.p(B,ee):(S=ce[w]=Y[w](B),S.c()),$(S,1),S.m(e,C)):S=null),B[4]&&B[35]||B[3]?.length>0?ue?(ue.p(B,ee),ee[0]&24|ee[1]&16&&$(ue,1)):(ue=$w(B),ue.c(),$(ue,1),ue.m(e,null)):ue&&(Ae(),V(ue,1,1,()=>{ue=null}),De()),(!P||ee[1]&32&&k!==(k="multiselect "+B[36]+" svelte-1r2hsto"))&&v(e,"class",k),(!P||ee[0]&16384|ee[1]&524288&&_!==(_=B[50]?B[14]:null))&&v(e,"title",_),(!P||ee[0]&262144)&&v(e,"data-id",B[18]),(!P||ee[1]&16384)&&v(e,"style",B[45]),(!P||ee[1]&524320)&&ge(e,"disabled",B[50]),(!P||ee[1]&33)&&ge(e,"single",B[31]===1),(!P||ee[0]&256|ee[1]&32)&&ge(e,"open",B[8]),(!P||ee[0]&128|ee[1]&32)&&ge(e,"invalid",B[7])},i(B){if(!P){$(D,B);for(let ee=0;ee`${wi(I)}`.toLowerCase()}=e,{filterFunc:C=(I,nt)=>nt?`${wi(I)}`.toLowerCase().includes(nt.toLowerCase()):!0}=e,{closeDropdownOnSelect:k="desktop"}=e,{form_input:_=null}=e,{highlightMatches:P=!0}=e,{id:x=null}=e,{input:R=null}=e,{inputClass:Z=""}=e,{inputStyle:Q=null}=e,{inputmode:D=null}=e,{invalid:E=!1}=e,{liActiveOptionClass:j=""}=e,{liActiveUserMsgClass:z=""}=e,{liOptionClass:q=""}=e,{liOptionStyle:G=null}=e,{liSelectedClass:Y=""}=e,{liSelectedStyle:ce=null}=e,{liUserMsgClass:Pe=""}=e,{loading:ue=!1}=e,{matchingOptions:B=[]}=e,{maxOptions:ee=void 0}=e,{maxSelect:pe=null}=e,{maxSelectMsg:Re=(I,nt)=>nt>1?`${I}/${nt}`:""}=e,{maxSelectMsgClass:oe=""}=e,{name:ke=null}=e,{noMatchingOptionsMsg:yt="No matching options"}=e,{open:It=!1}=e,{options:at}=e,{outerDiv:Nt=null}=e,{outerDivClass:Pr=""}=e,{parseLabelsAsHtml:nn=!1}=e,{pattern:$t=null}=e,{placeholder:Tt=null}=e,{removeAllTitle:lt="Remove all"}=e,{removeBtnTitle:dt="Remove"}=e,{minSelect:gt=null}=e,{required:jt=!1}=e,{resetFilterOnAdd:Cr=!0}=e,{searchText:bt=""}=e,{selected:et=at?.filter(I=>I instanceof Object&&I?.preselected).slice(0,pe??void 0)??[]}=e,{sortSelected:rs=!1}=e,{selectedOptionsDraggable:wl=!rs}=e,{style:Nu=null}=e,{ulOptionsClass:ju=""}=e,{ulSelectedClass:Dn=""}=e,{ulSelectedStyle:xs=null}=e,{ulOptionsStyle:kl=null}=e,{value:Oo=null}=e,vo=I=>{t(67,Oo=pe===1?I[0]??null:I)},Zu=I=>{pe===1?t(5,et=I?[I]:[]):t(5,et=I??[])},ca=!1;at?.length>0||(c||ue||m||u?at=[]:console.error("MultiSelect received no options")),pe!==null&&pe<1&&console.error(`MultiSelect's maxSelect must be null or positive integer, got ${pe}`),Array.isArray(et)||console.error(`MultiSelect's selected prop should always be an array, got ${et}`),pe&&typeof jt=="number"&&jt>pe&&console.error(`MultiSelect maxSelect=${pe} < required=${jt}, makes it impossible for users to submit a valid form`),nn&&c&&console.warn("Don't combine parseLabelsAsHtml and allowUserOptions. It's susceptible to XSS attacks!"),rs&&wl&&console.warn("MultiSelect's sortSelected and selectedOptionsDraggable should not be combined as any user re-orderings of selected options will be undone by sortSelected on component re-renders."),c&&!l&&l!==null&&console.error(`MultiSelect has allowUserOptions=${c} but createOptionMsg=${l} is falsy. This prevents the "Add option" from showing up, resulting in a confusing user experience.`),ee&&(typeof ee!="number"||ee<0||ee%1!=0)&&console.error(`MultiSelect's maxOptions must be undefined or a positive integer, got ${ee}`);let Yn=Fe(),Er=!1,rn;if(o!==null&&!B[o])throw`Run time error, activeIndex=${o} is out of bounds, matchingOptions.length=${B.length}`;function yo(I,nt){pe&&pe>1&&et.length>=pe&&t(51,ca=!0),!isNaN(Number(I))&&typeof et.map(wi)[0]=="number"&&(I=Number(I));let Bt=et.map(S).includes(S(I));if((pe===null||pe===1||et.length0&&(typeof at[0]=="object"?I={label:bt}:(["number","undefined"].includes(typeof at[0])&&!isNaN(Number(bt))?I=Number(bt):I=bt,Yn("create",{option:I})),c==="append"&&t(3,at=[...at,I])),Cr&&t(4,bt=""),["",void 0,null].includes(I)){console.error(`MultiSelect: encountered falsy option ${I}`);return}pe===1?t(5,et=[I]):(t(5,et=[...et,I]),rs===!0?t(5,et=et.sort((as,Tr)=>{let[Kn,ha]=[wi(as),wi(Tr)];return`${Kn}`.localeCompare(`${ha}`)})):typeof rs=="function"&&t(5,et=et.sort(rs)));let vi=et.length===pe,Rn=k===!0||k==="desktop"&&rnS(vi)===S(I)),[Bt]=et.splice(nt,1);if(Bt===void 0&&c&&(Bt=typeof at[0]?{label:I}:I),Bt===void 0)return console.error(`Multiselect can't remove selected option ${JSON.stringify(I)}, not found in selected list`);t(5,et=[...et]),t(7,E=!1),_?.setCustomValidity(""),Yn("remove",{option:Bt}),Yn("change",{option:Bt,type:"remove"})}function zu(I){m||(t(8,It=!0),I instanceof FocusEvent||R?.focus(),Yn("open",{event:I}))}function Sl(I){t(8,It=!1),R?.blur(),t(0,o=null),Yn("close",{event:I})}async function Sp(I){if(I.key==="Escape"||I.key==="Tab")Sl(I),t(4,bt="");else if(I.key==="Enter")I.preventDefault(),a?(et.includes(a)?bo(a):yo(a,I),t(4,bt="")):c&&bt.length>0?yo(bt,I):zu(I);else if(["ArrowDown","ArrowUp"].includes(I.key)){if(o===null&&B.length>0){t(0,o=0);return}else if(c&&!B.length&&bt.length>0){t(52,Er=!Er);return}else if(o===null)return;I.preventDefault();let nt=I.key==="ArrowUp"?-1:1;if(t(0,o=(o+nt)%B.length),o<0&&t(0,o=B.length-1),d){await df();let Bt=document.querySelector("ul.options > li.active");Bt&&Bt.scrollIntoViewIfNeeded?.()}}else I.key==="Backspace"&&et.length>0&&!bt?bo(et.at(-1)):B.length>0&&t(0,o=0)}function xp(){Yn("removeAll",{options:et}),Yn("change",{options:et,type:"removeAll"}),t(5,et=[]),t(4,bt="")}let Ps=I=>nt=>{["Enter","Space"].includes(nt.code)&&(nt.preventDefault(),I())};function Pp(I){Nt&&!Nt.contains(I.target)&&Sl(I)}let ua=null,Cp=I=>nt=>{if(!nt.dataTransfer)return;nt.dataTransfer.dropEffect="move";let Bt=parseInt(nt.dataTransfer.getData("text/plain")),vi=[...et];Btnt=>{nt.dataTransfer&&(nt.dataTransfer.effectAllowed="move",nt.dataTransfer.dropEffect="move",nt.dataTransfer.setData("text/plain",`${I}`))},_o;function Ep(I){if(!P||typeof CSS>"u"||!CSS.highlights)return;CSS.highlights.clear();let nt=I?.target?.value.trim().toLowerCase();if(!nt)return;let Bt=document.createTreeWalker(_o,NodeFilter.SHOW_TEXT,{acceptNode:Tr=>Tr?.textContent===yt?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),vi=[],Rn=Bt.nextNode();for(;Rn;)vi.push(Rn),Rn=Bt.nextNode();let as=vi.map(Tr=>{let Kn=Tr.textContent?.toLowerCase(),ha=[],pa=0;for(;Kn&&pa{let bn=new Range;return bn.setStart(Tr,As),bn.setEnd(Tr,As+nt.length),bn})});CSS.highlights.set("sms-search-matches",new Highlight(...as.flat()))}function qu(I){ht.call(this,i,I)}function Tp(I){ht.call(this,i,I)}function Lu(I){ht.call(this,i,I)}function F(I){ht.call(this,i,I)}function N(I){ht.call(this,i,I)}function W(I){ht.call(this,i,I)}function K(I){ht.call(this,i,I)}function te(I){ht.call(this,i,I)}function Ce(I){ht.call(this,i,I)}function Le(I){ht.call(this,i,I)}function st(I){ht.call(this,i,I)}function Ot(I){ht.call(this,i,I)}function Yt(I){ht.call(this,i,I)}function it(I){ht.call(this,i,I)}function Zt(I){ht.call(this,i,I)}function Ht(I){ht.call(this,i,I)}function Mt(){t(53,rn=window.innerWidth)}function ct(I){mi[I?"unshift":"push"](()=>{_=I,t(1,_)})}let zt=()=>{t(7,E=!0);let I;pe&&pe>1&&Number(jt)>1?I=`Please select between ${jt} and ${pe} options`:Number(jt)>1?I=`Please select at least ${jt} options`:I="Please select an option",_?.setCustomValidity(I)},_t=I=>bo(I),ss=I=>bo(I),Fi=I=>t(54,ua=I);function sn(I){mi[I?"unshift":"push"](()=>{R=I,t(6,R)})}function kt(){bt=this.value,t(4,bt)}function Bi(I){ca=I,t(51,ca)}let on=(I,nt,Bt)=>{I||yo(nt,Bt)},Qn=(I,nt)=>{I||t(0,o=nt)},os=(I,nt)=>{I||t(0,o=nt)},Hn=()=>t(0,o=null),wo=()=>t(0,o=null),fa=I=>{c&&yo(bt,I)},da=()=>t(52,Er=!0),Cs=()=>t(52,Er=!0),Es=()=>t(52,Er=!1),Gn=()=>t(52,Er=!1);function Ts(I){mi[I?"unshift":"push"](()=>{_o=I,t(55,_o)})}function Pl(I){mi[I?"unshift":"push"](()=>{Nt=I,t(9,Nt)})}return i.$$set=I=>{"activeIndex"in I&&t(0,o=I.activeIndex),"activeOption"in I&&t(68,a=I.activeOption),"createOptionMsg"in I&&t(10,l=I.createOptionMsg),"allowUserOptions"in I&&t(11,c=I.allowUserOptions),"allowEmpty"in I&&t(69,u=I.allowEmpty),"autocomplete"in I&&t(12,f=I.autocomplete),"autoScroll"in I&&t(70,d=I.autoScroll),"breakpoint"in I&&t(71,h=I.breakpoint),"defaultDisabledTitle"in I&&t(13,p=I.defaultDisabledTitle),"disabled"in I&&t(50,m=I.disabled),"disabledInputTitle"in I&&t(14,g=I.disabledInputTitle),"duplicateOptionMsg"in I&&t(15,O=I.duplicateOptionMsg),"duplicates"in I&&t(16,w=I.duplicates),"key"in I&&t(17,S=I.key),"filterFunc"in I&&t(72,C=I.filterFunc),"closeDropdownOnSelect"in I&&t(73,k=I.closeDropdownOnSelect),"form_input"in I&&t(1,_=I.form_input),"highlightMatches"in I&&t(74,P=I.highlightMatches),"id"in I&&t(18,x=I.id),"input"in I&&t(6,R=I.input),"inputClass"in I&&t(19,Z=I.inputClass),"inputStyle"in I&&t(20,Q=I.inputStyle),"inputmode"in I&&t(21,D=I.inputmode),"invalid"in I&&t(7,E=I.invalid),"liActiveOptionClass"in I&&t(22,j=I.liActiveOptionClass),"liActiveUserMsgClass"in I&&t(23,z=I.liActiveUserMsgClass),"liOptionClass"in I&&t(24,q=I.liOptionClass),"liOptionStyle"in I&&t(25,G=I.liOptionStyle),"liSelectedClass"in I&&t(26,Y=I.liSelectedClass),"liSelectedStyle"in I&&t(27,ce=I.liSelectedStyle),"liUserMsgClass"in I&&t(28,Pe=I.liUserMsgClass),"loading"in I&&t(29,ue=I.loading),"matchingOptions"in I&&t(2,B=I.matchingOptions),"maxOptions"in I&&t(30,ee=I.maxOptions),"maxSelect"in I&&t(31,pe=I.maxSelect),"maxSelectMsg"in I&&t(32,Re=I.maxSelectMsg),"maxSelectMsgClass"in I&&t(33,oe=I.maxSelectMsgClass),"name"in I&&t(34,ke=I.name),"noMatchingOptionsMsg"in I&&t(35,yt=I.noMatchingOptionsMsg),"open"in I&&t(8,It=I.open),"options"in I&&t(3,at=I.options),"outerDiv"in I&&t(9,Nt=I.outerDiv),"outerDivClass"in I&&t(36,Pr=I.outerDivClass),"parseLabelsAsHtml"in I&&t(37,nn=I.parseLabelsAsHtml),"pattern"in I&&t(38,$t=I.pattern),"placeholder"in I&&t(39,Tt=I.placeholder),"removeAllTitle"in I&&t(40,lt=I.removeAllTitle),"removeBtnTitle"in I&&t(41,dt=I.removeBtnTitle),"minSelect"in I&&t(42,gt=I.minSelect),"required"in I&&t(43,jt=I.required),"resetFilterOnAdd"in I&&t(75,Cr=I.resetFilterOnAdd),"searchText"in I&&t(4,bt=I.searchText),"selected"in I&&t(5,et=I.selected),"sortSelected"in I&&t(76,rs=I.sortSelected),"selectedOptionsDraggable"in I&&t(44,wl=I.selectedOptionsDraggable),"style"in I&&t(45,Nu=I.style),"ulOptionsClass"in I&&t(46,ju=I.ulOptionsClass),"ulSelectedClass"in I&&t(47,Dn=I.ulSelectedClass),"ulSelectedStyle"in I&&t(48,xs=I.ulSelectedStyle),"ulOptionsStyle"in I&&t(49,kl=I.ulOptionsStyle),"value"in I&&t(67,Oo=I.value),"$$scope"in I&&t(115,s=I.$$scope)},i.$$.update=()=>{i.$$.dirty[0]&32&&vo(et),i.$$.dirty[2]&32&&Zu(Oo),i.$$.dirty[0]&196664|i.$$.dirty[2]&1024&&t(2,B=at.filter(I=>C(I,bt)&&(!et.map(S).includes(S(I))||w))),i.$$.dirty[0]&5&&t(68,a=B[o??-1]??null),i.$$.dirty[0]&32&&t(56,n=I=>et.map(wi).includes(I)),i.$$.dirty[0]&2|i.$$.dirty[1]&4096&&_?.setCustomValidity("")},[o,_,B,at,bt,et,R,E,It,Nt,l,c,f,p,g,O,w,S,x,Z,Q,D,j,z,q,G,Y,ce,Pe,ue,ee,pe,Re,oe,ke,yt,Pr,nn,$t,Tt,lt,dt,gt,jt,wl,Nu,ju,Dn,xs,kl,m,ca,Er,rn,ua,_o,n,yo,bo,zu,Sp,xp,Ps,Pp,Cp,xl,Ep,Oo,a,u,d,h,C,k,P,Cr,rs,r,qu,Tp,Lu,F,N,W,K,te,Ce,Le,st,Ot,Yt,it,Zt,Ht,Mt,ct,zt,_t,ss,Fi,sn,kt,Bi,on,Qn,os,Hn,wo,fa,da,Cs,Es,Gn,Ts,Pl,s]}var Sg=class extends ne{constructor(e){super(),re(this,e,s8,r8,ie,{activeIndex:0,activeOption:68,createOptionMsg:10,allowUserOptions:11,allowEmpty:69,autocomplete:12,autoScroll:70,breakpoint:71,defaultDisabledTitle:13,disabled:50,disabledInputTitle:14,duplicateOptionMsg:15,duplicates:16,key:17,filterFunc:72,closeDropdownOnSelect:73,form_input:1,highlightMatches:74,id:18,input:6,inputClass:19,inputStyle:20,inputmode:21,invalid:7,liActiveOptionClass:22,liActiveUserMsgClass:23,liOptionClass:24,liOptionStyle:25,liSelectedClass:26,liSelectedStyle:27,liUserMsgClass:28,loading:29,matchingOptions:2,maxOptions:30,maxSelect:31,maxSelectMsg:32,maxSelectMsgClass:33,name:34,noMatchingOptionsMsg:35,open:8,options:3,outerDiv:9,outerDivClass:36,parseLabelsAsHtml:37,pattern:38,placeholder:39,removeAllTitle:40,removeBtnTitle:41,minSelect:42,required:43,resetFilterOnAdd:75,searchText:4,selected:5,sortSelected:76,selectedOptionsDraggable:44,style:45,ulOptionsClass:46,ulSelectedClass:47,ulSelectedStyle:48,ulOptionsStyle:49,value:67},TD,[-1,-1,-1,-1,-1])}},oc=Sg;function o8(i=!0){let e=this,t=new IntersectionObserver(function([n]){let r=n.intersectionRatio;if(r<1){let s=r<=0&&i?"center":"nearest";e.scrollIntoView({block:s,inline:s})}this.disconnect()});return t.observe(e),t}typeof Element<"u"&&!Element.prototype?.scrollIntoViewIfNeeded&&typeof IntersectionObserver<"u"&&(Element.prototype.scrollIntoViewIfNeeded=o8);function a8(i){se(i,"svelte-1dl3a9e",".multiselect-container.svelte-1dl3a9e{width:100%}.multiselect-container.svelte-1dl3a9e .multiselect-dropdown{height:auto;min-height:var(--input-height, 30px)}.multiselect-container.svelte-1dl3a9e div.multiselect{--sms-border:none;--sms-bg:var(--interactive-normal);--sms-options-bg:var(--interactive-normal);--sms-border-radius:var(--radius)}.multiselect-container.svelte-1dl3a9e div.multiselect ul{padding-left:0;border-radius:var(--radius)}.multiselect-container.svelte-1dl3a9e div.multiselect button{height:0}.multiselect-container.svelte-1dl3a9e div.multiselect input{width:0;font-size:var(--font-ui-small)}.multiselect-container.svelte-1dl3a9e div.multiselect li{border-left:none}.multiselect-container.svelte-1dl3a9e div.multiselect li::before{content:none}")}function l8(i){let e,t,n,r;function s(a){i[2](a)}let o={options:i[0].options.flat(),outerDivClass:"multiselect-dropdown",placeholder:i[0].text};return i[1]!==void 0&&(o.selected=i[1]),t=new oc({props:o}),mi.push(()=>Ir(t,"selected",s)),{c(){e=b("div"),ye(t.$$.fragment),v(e,"class","multiselect-container svelte-1dl3a9e")},m(a,l){A(a,e,l),Oe(t,e,null),r=!0},p(a,[l]){let c={};l&1&&(c.options=a[0].options.flat()),l&1&&(c.placeholder=a[0].text),!n&&l&2&&(n=!0,c.selected=a[1],Rr(()=>n=!1)),t.$set(c)},i(a){r||($(t.$$.fragment,a),r=!0)},o(a){V(t.$$.fragment,a),r=!1},d(a){a&&T(e),ve(t)}}}function c8(i,e,t){let n,r=X,s=()=>(r(),r=Mi(o,l=>t(1,n=l)),o);i.$$.on_destroy.push(()=>r());let{filter:o}=e;s();function a(l){n=l,o.set(n)}return i.$$set=l=>{"filter"in l&&s(t(0,o=l.filter))},[o,n,a]}var xg=class extends ne{constructor(e){super(),re(this,e,c8,l8,ie,{filter:0},a8)}},Ww=xg;var Yf=require("obsidian");function u8(i){se(i,"svelte-1xutc2s",".search.svelte-1xutc2s,.search.svelte-1xutc2s input{width:100%}")}function f8(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","search svelte-1xutc2s")},m(s,o){A(s,e,o),n||(r=H(t=i[1].call(null,e)),n=!0)},p:X,i:X,o:X,d(s){s&&T(e),n=!1,r()}}}function d8(i,e,t){let n,r=X,s=()=>(r(),r=Mi(o,l=>t(2,n=l)),o);i.$$.on_destroy.push(()=>r());let{filter:o}=e;s();let a=l=>{new Yf.TextComponent(l).setPlaceholder(o.text).onChange((0,Yf.debounce)(c=>{Ke(o,n=c,n)},10))};return i.$$set=l=>{"filter"in l&&s(t(0,o=l.filter))},[o,a]}var Pg=class extends ne{constructor(e){super(),re(this,e,d8,f8,ie,{filter:0},u8)}},Hf=Pg;function h8(i){se(i,"svelte-hht686",".nested-filter-container{display:flex;flex-flow:row wrap;gap:0.5rem}.filter-container.svelte-hht686{flex-grow:1;flex-basis:0}")}function Xw(i,e,t){let n=i.slice();return n[5]=e[t],n}function p8(i){let e,t,n,r,s=i[1].type==0&&Uw(i),o=i[1].type==2&&Yw(i),a=i[1].type==1&&Hw(i);return{c(){e=b("div"),s&&s.c(),t=M(),o&&o.c(),n=M(),a&&a.c(),v(e,"class","filter-container svelte-hht686")},m(l,c){A(l,e,c),s&&s.m(e,null),y(e,t),o&&o.m(e,null),y(e,n),a&&a.m(e,null),r=!0},p(l,c){l[1].type==0?s?(s.p(l,c),c&2&&$(s,1)):(s=Uw(l),s.c(),$(s,1),s.m(e,t)):s&&(Ae(),V(s,1,1,()=>{s=null}),De()),l[1].type==2?o?(o.p(l,c),c&2&&$(o,1)):(o=Yw(l),o.c(),$(o,1),o.m(e,n)):o&&(Ae(),V(o,1,1,()=>{o=null}),De()),l[1].type==1?a?(a.p(l,c),c&2&&$(a,1)):(a=Hw(l),a.c(),$(a,1),a.m(e,null)):a&&(Ae(),V(a,1,1,()=>{a=null}),De())},i(l){r||($(s),$(o),$(a),r=!0)},o(l){V(s),V(o),V(a),r=!1},d(l){l&&T(e),s&&s.d(),o&&o.d(),a&&a.d()}}}function m8(i){let e,t,n=fe(i[0].nested),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){e=b("div");for(let o=0;o{o[u]=null}),De(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),$(t,1),t.m(n.parentNode,n))},i(l){r||($(t),r=!0)},o(l){V(t),r=!1},d(l){l&&T(n),o[e].d(l)}}}function O8(i,e,t){let n,r=Ue("filters"),{filters:s}=r;Se(i,s,l=>t(3,n=l));let{layout:o}=e,a;return i.$$set=l=>{"layout"in l&&t(0,o=l.layout)},i.$$.update=()=>{i.$$.dirty&9&&("nested"in o||t(1,a=n.get(o.id)))},[o,a,s,n]}var Gf=class extends ne{constructor(e){super(),re(this,e,O8,g8,ie,{layout:0},h8)}},Jw=Gf;function v8(i){se(i,"svelte-1teebz7",".filters-container.svelte-1teebz7{display:flex;flex-flow:column nowrap;gap:1rem}.controls.svelte-1teebz7{display:flex;justify-content:space-between;align-items:center;gap:0.5rem}.filter-button.svelte-1teebz7{position:relative}.filter-number.svelte-1teebz7{position:absolute;bottom:0;right:0;background-color:var(--interactive-normal);border-radius:50%;width:14px;height:14px;display:flex;align-items:center;justify-content:center;font-size:var(--font-smallest);pointer-events:none}.filters.svelte-1teebz7{display:flex;flex-flow:column nowrap;gap:1rem}")}function ek(i,e,t){let n=i.slice();return n[10]=e[t],n}function tk(i){let e,t,n,r=fe(i[2]),s=[];for(let a=0;aV(s[a],1,1,()=>{s[a]=null});return{c(){e=b("div");for(let a=0;a{n&&(t||(t=Po(e,eg,{easing:Nn},!0)),t.run(1))}),n=!0}},o(a){s=s.filter(Boolean);for(let l=0;l{k=null}),De())},i(_){w||($(n.$$.fragment,_),$(k),w=!0)},o(_){V(n.$$.fragment,_),V(k),w=!1},d(_){_&&T(e),ve(n),k&&k.d(),S=!1,de(C)}}}function b8(i,e,t){let n,r,s=!1,o=Fe(),a=Ue("filters"),{active:l,name:c,layout:u}=a;return Se(i,l,O=>t(1,n=O)),Se(i,u,O=>t(2,r=O)),[s,n,r,o,a,l,c,O=>{new Kf.ExtraButtonComponent(O).setIcon("reset")},O=>{new Kf.ExtraButtonComponent(O).setIcon("filter")},O=>{new Kf.ExtraButtonComponent(O).setIcon("settings")},u,()=>t(0,s=!s),()=>a.reset(),O=>o("settings",O)]}var Cg=class extends ne{constructor(e){super(),re(this,e,b8,y8,ie,{},v8)}},nk=Cg;var po=require("obsidian");var Ro=require("obsidian");function _8(i){se(i,"svelte-zo5pkp",".pagination.svelte-zo5pkp{display:flex;justify-content:space-between;align-items:center;gap:1rem}.paginated-container.svelte-zo5pkp{display:flex;align-items:center;gap:1rem}.paginated.svelte-zo5pkp{display:flex;align-items:center;gap:1rem}.clickable-icon.active.svelte-zo5pkp{background-color:var(--background-modifier-hover)}.slicer.svelte-zo5pkp{display:flex;align-items:center;gap:0.5rem}")}function rk(i,e,t){let n=i.slice();return n[14]=e[t],n}function w8(i){let e,t=i[14]+"",n,r,s,o;function a(){return i[13](i[14])}return{c(){e=b("span"),n=ae(t),r=M(),v(e,"class","clickable-icon svelte-zo5pkp"),ge(e,"active",i[14]==i[0])},m(l,c){A(l,e,c),y(e,n),y(e,r),s||(o=U(e,"click",a),s=!0)},p(l,c){i=l,c&2&&t!==(t=i[14]+"")&&me(n,t),c&3&&ge(e,"active",i[14]==i[0])},d(l){l&&T(e),s=!1,o()}}}function k8(i){let e,t,n;return{c(){e=b("span"),e.textContent="..."},m(r,s){A(r,e,s),t||(n=U(e,"click",i[12]),t=!0)},p:X,d(r){r&&T(e),t=!1,n()}}}function sk(i){let e;function t(s,o){return s[14]==null?k8:w8}let n=t(i,-1),r=n(i);return{c(){r.c(),e=tt()},m(s,o){r.m(s,o),A(s,e,o)},p(s,o){n===(n=t(s,o))&&r?r.p(s,o):(r.d(1),r=n(s),r&&(r.c(),r.m(e.parentNode,e)))},d(s){s&&T(e),r.d(s)}}}function S8(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,w=fe(i[1]),S=[];for(let C=0;C{new Ro.DropdownComponent(O).addOptions({10:"10",25:"25",50:"50",100:"100",200:"200"}).setValue(`${s}`).onChange(w=>l("slice",Number(w)))},u,f=O=>{t(9,u=new Ro.ExtraButtonComponent(O).setIcon("chevron-left").setDisabled(o==1).onClick(()=>{l("previous")}))},d,h=O=>{t(10,d=new Ro.ExtraButtonComponent(O).setIcon("chevron-right").setDisabled(o==a).onClick(()=>{l("next")}))},p=O=>{let w=new Ro.Menu;for(let S of n)w.addItem(C=>{C.setTitle(`${S}`).onClick(()=>{l("page",S)})});w.showAtMouseEvent(O)},m=O=>p(O),g=O=>l("page",O);return i.$$set=O=>{"slice"in O&&t(7,s=O.slice),"page"in O&&t(0,o=O.page),"pages"in O&&t(8,a=O.pages)},i.$$.update=()=>{i.$$.dirty&256&&t(11,n=[...Array(a).keys()].map(O=>O+1)),i.$$.dirty&1793&&d&&u&&(d.setDisabled(o==a),u.setDisabled(o==1)),i.$$.dirty&2305&&t(1,r=n.reduce((O,w)=>(w==1||o==1&&(w==2||w==3)||w==a||o==a&&(w==a-1||w==a-2)||w==o-1||w==o||w==o+1?O.push(w):O.length>=1&&O[O.length-1]!=null&&O.push(null),O),[]))},[o,r,l,c,f,h,p,s,a,u,d,n,m,g]}var Eg=class extends ne{constructor(e){super(),re(this,e,x8,S8,ie,{slice:7,page:0,pages:8},_8)}},ok=Eg;var a4=require("obsidian");var nK=require("obsidian");var aK=$e(0),$s=class i{constructor(e,t,n,r){this.text=e;this.field=t;this.type=n;this.func=r;J(this,"active");J(this,"id",xt());J(this,"_func",this.getSortByType())}getSortByType(){switch(this.type){case 0:return(e,t)=>(e[this.field]??"").localeCompare(t[this.field]??"");case 1:return(e,t)=>hi(e[this.field]??0)-hi(t[this.field]??0);case 2:return new Function("a","b",this.func)}}sortAsc(e,t){return this._func(e,t)}sortDesc(e,t){return this._func(t,e)}toState(){return{text:this.text,field:this.field,type:this.type,...this.func&&this.func.length?{func:this.func}:{}}}static fromState(e){return new i(e.text,e.field,e.type,e.func)}static get defaultState(){return{text:"",field:"",type:0}}},ak=[{text:"CR",field:"cr",type:1},{text:"Type",field:"type",type:0},{text:"Size",field:"size",type:0},{text:"Alignment",field:"alignment",type:0}],ac=$s.fromState({text:"Name",field:"name",type:0});function ck(i,e){i.data.builder||(i.data.builder={sidebarIcon:!0,showParty:!0,showXP:!0}),i.data.builder.headers||(i.data.builder.headers=ci(ak),i.saveSettings());let t=$e(i.data.builder.headers.map(f=>$s.fromState(f))),{subscribe:n,set:r,update:s}=t,o=$e(ci(e)),a=$e(!0),l=oi(t,f=>[ac,...f]),c=f=>s(d=>{if(f.active)a.update(h=>!h);else{let h=ut(l).find(p=>p.active);h&&(h.active=!1),f.active=!0,a.set(!0)}return o.update(h=>(h.sort(ut(a)?f.sortAsc.bind(f):f.sortDesc.bind(f)),h)),d});function u(f){s(f),i.saveSettings()}return{allHeaders:l,subscribe:n,set:r,update:s,sort:c,sortDir:a,creatures:o,reset:()=>o.update(()=>ci(e)),setHeadersFromState:f=>u(d=>{i.data.builder.headers=f;let h=f.map(m=>$s.fromState(m)),p=d.findIndex(m=>m.active);return p>=0&&pu(f=>(i.data.builder.headers=ci(ak),i.data.builder.headers.map(d=>$s.fromState(d))))}}var Jr=require("obsidian");var Kr=require("obsidian");var Ag=[],hk=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(i=hk[n])e=n+1;else return!0;if(e==t)return!1}}function uk(i){return i>=127462&&i<=127487}var fk=8205;function pk(i,e,t=!0,n=!0){return(t?mk:C8)(i,e,n)}function mk(i,e,t){if(e==i.length)return e;e&&gk(i.charCodeAt(e))&&Ok(i.charCodeAt(e-1))&&e--;let n=Tg(i,e);for(e+=dk(n);e=0&&uk(Tg(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function C8(i,e,t){for(;e>0;){let n=mk(i,e-2,t);if(n=56320&&i<57344}function Ok(i){return i>=55296&&i<56320}function dk(i){return i<65536?1:2}var rt=class i{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=$a(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),za.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=$a(this,e,t);let n=[];return this.decompose(e,t,n,0),za.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new No(this),s=new No(e);for(let o=t,a=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new No(this,e)}iterRange(e,t=this.length){return new id(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new nd(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?i.empty:e.length<=32?new Sn(e):za.from(Sn.split(e,[]))}},Sn=class i extends rt{constructor(e,t=E8(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],a=r+o.length;if((t?n:a)>=e)return new Qg(r,a,n,o);r=a+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new i(vk(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),a=td(s.text,o.text.slice(),0,s.length);if(a.length<=32)n.push(new i(a,o.length+s.length));else{let l=a.length>>1;n.push(new i(a.slice(0,l)),new i(a.slice(l)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof i))return super.replace(e,t,n);[e,t]=$a(this,e,t);let r=td(this.text,td(n.text,vk(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new i(r,s):za.from(i.split(r,[]),s)}sliceString(e,t=this.length,n=` `){[e,t]=$a(this,e,t);let r="";for(let s=0,o=0;s<=t&&oe&&o&&(r+=n),es&&(r+=a.slice(Math.max(0,e-s),t-s)),s=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new i(n,r)),n=[],r=-1);return r>-1&&t.push(new i(n,r)),t}},za=class i extends rt{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],a=r+o.length,l=n+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,n,r);r=a+1,n=l+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s=o){let c=r&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!c?n.push(a):a.decompose(e-o,t-o,n,c)}o=l+1}}replace(e,t,n){if([e,t]=$a(this,e,t),n.lines=s&&t<=a){let l=o.replace(e-s,t-s,n),c=this.lines-o.lines+l.lines;if(l.lines>4&&l.lines>c>>6){let u=this.children.slice();return u[r]=l,new i(u,this.length-(t-e)+n.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=` `){[e,t]=$a(this,e,t);let r="";for(let s=0,o=0;se&&s&&(r+=n),eo&&(r+=a.sliceString(e-o,t-o,n)),o=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof i))return 0;let n=0,[r,s,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==a)return n;let l=this.children[r],c=e.children[s];if(l!=c)return n+l.scanIdentical(c,t);n+=l.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let h of e)n+=h.lines;if(n<32){let h=[];for(let p of e)p.flatten(h);return new Sn(h,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,a=[],l=0,c=-1,u=[];function f(h){let p;if(h.lines>s&&h instanceof i)for(let m of h.children)f(m);else h.lines>o&&(l>o||!l)?(d(),a.push(h)):h instanceof Sn&&l&&(p=u[u.length-1])instanceof Sn&&h.lines+p.lines<=32?(l+=h.lines,c+=h.length+1,u[u.length-1]=new Sn(p.text.concat(h.text),p.length+1+h.length)):(l+h.lines>r&&d(),l+=h.lines,c+=h.length+1,u.push(h))}function d(){l!=0&&(a.push(u.length==1?u[0]:i.from(u,c)),c=-1,l=u.length=0)}for(let h of e)f(h);return d(),a.length==1?a[0]:new i(a,t)}};rt.empty=new Sn([""],0);function E8(i){let e=-1;for(let t of i)e+=t.length+1;return e}function td(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s=t&&(l>n&&(a=a.slice(0,n-r)),r0?1:(e instanceof Sn?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,a=r instanceof Sn?r.text.length:r.children.length;if(o==(t>0?a:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(r instanceof Sn){let l=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof Sn?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},id=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new No(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},nd=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(rt.prototype[Symbol.iterator]=function(){return this.iter()},No.prototype[Symbol.iterator]=id.prototype[Symbol.iterator]=nd.prototype[Symbol.iterator]=function(){return this});var Qg=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function $a(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}function ui(i,e,t=!0,n=!0){return pk(i,e,t,n)}function T8(i){return i>=56320&&i<57344}function A8(i){return i>=55296&&i<56320}function Zi(i,e){let t=i.charCodeAt(e);if(!A8(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return T8(n)?(t-55296<<10)+(n-56320)+65536:t}function hc(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function xn(i){return i<65536?1:2}var Rg=/\r\n?|\n/,Ci=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(Ci||(Ci={})),gs=class i{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return s+(e-r);s+=a}else{if(n!=Ci.Simple&&c>=e&&(n==Ci.TrackDel&&re||n==Ci.TrackBefore&&re))return null;if(c>e||c==e&&t<0&&!a)return e==r||t<0?s:s+l;s+=l}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let n=0,r=0;n=0&&r<=t&&a>=e)return rt?"cover":!0;r=a}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new i(e)}static create(e){return new i(e)}},Ui=class i extends gs{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Mg(this,(t,n,r,s,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return Ig(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,s=0;r=0){t[r]=a,t[r+1]=o;let l=r>>1;for(;n.length0&&Fs(n,t,s.text),s.forward(u),a+=u}let c=e[o++];for(;a>1].toJSON()))}return e}static of(e,t,n){let r=[],s=[],o=0,a=null;function l(u=!1){if(!u&&!r.length)return;od||f<0||d>t)throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${t})`);let p=h?typeof h=="string"?rt.of(h.split(n||Rg)):h:rt.empty,m=p.length;if(f==d&&m==0)return;fo&&ji(r,f-o,-1),ji(r,d-f,m),Fs(s,r,p),o=d}}return c(e),l(!a),a}static empty(e){return new i(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;ra&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length=0&&t<=0&&t==i[r+1]?i[r]+=e:r>=0&&e==0&&i[r]==0?i[r+1]+=t:n?(i[r]+=e,i[r+1]+=t):i.push(e,t)}function Fs(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)a=i.sections[o++],l=i.sections[o++];e(r,c,s,u,f),r=c,s=u}}}function Ig(i,e,t,n=!1){let r=[],s=n?[]:null,o=new jo(i),a=new jo(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);ji(r,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let c=0,u=o.len;for(;u;)if(a.ins==-1){let f=Math.min(u,a.len);c+=f,u-=f,a.forward(f)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||n.length>c),s.forward2(l),o.forward(l)}}}}var jo=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?rt.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?rt.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Za=class i{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new i(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return le.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return le.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return le.range(e.anchor,e.head)}static create(e,t,n){return new i(e,t,n)}},le=class i{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:i.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;ne.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new i(e.ranges.map(t=>Za.fromJSON(t)),e.main)}static single(e,t=e){return new i([i.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;re?8:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(n);for(let r=1;rs.head?i.range(l,a):i.range(a,l))}}return new i(e,t)}};function xk(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Vg=0,Ee=class i{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Vg++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new i(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:Wg),!!e.static,e.enables)}of(e){return new qa([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new qa(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new qa(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}};function Wg(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}var qa=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Vg++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?c=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||u.push(e[f.id]);return{create(f){return f.values[o]=n(f),1},update(f,d){if(l&&d.docChanged||c&&(d.docChanged||d.selection)||Ng(f,u)){let h=n(f);if(a?!yk(h,f.values[o],r):!r(h,f.values[o]))return f.values[o]=h,1}return 0},reconfigure:(f,d)=>{let h,p=d.config.address[s];if(p!=null){let m=ad(d,p);if(this.dependencies.every(g=>g instanceof Ee?d.facet(g)===f.facet(g):g instanceof Xt?d.field(g,!1)==f.field(g,!1):!0)||(a?yk(h=n(f),m,r):r(h=n(f),m)))return f.values[o]=m,0}else h=n(f);return f.values[o]=h,1}}}};function yk(i,e,t){if(i.length!=e.length)return!1;for(let n=0;ni[l.id]),r=t.map(l=>l.type),s=n.filter(l=>!(l&1)),o=i[e.id]>>1;function a(l){let c=[];for(let u=0;un===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(bk).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,r)=>{let s=n.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,r)=>r.config.address[this.id]!=null?(n.values[t]=r.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,bk.of({field:this,create:e})]}get extension(){return this}},Mo={lowest:4,low:3,default:2,high:1,highest:0};function lc(i){return e=>new rd(e,i)}var hr={highest:lc(Mo.highest),high:lc(Mo.high),default:lc(Mo.default),low:lc(Mo.low),lowest:lc(Mo.lowest)},rd=class{constructor(e,t){this.inner=e,this.prec=t}},sd=class i{of(e){return new uc(this,e)}reconfigure(e){return i.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},uc=class{constructor(e,t){this.compartment=e,this.inner=t}},od=class i{constructor(e,t,n,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,n){let r=[],s=Object.create(null),o=new Map;for(let d of Q8(e,t,o))d instanceof Xt?r.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let a=Object.create(null),l=[],c=[];for(let d of r)a[d.id]=c.length<<1,c.push(h=>d.slot(h));let u=n?.config.facets;for(let d in s){let h=s[d],p=h[0].facet,m=u&&u[d]||[];if(h.every(g=>g.type==0))if(a[p.id]=l.length<<1|1,Wg(m,h))l.push(n.facet(p));else{let g=p.combine(h.map(O=>O.value));l.push(n&&p.compare(g,n.facet(p))?n.facet(p):g)}else{for(let g of h)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=c.length<<1,c.push(O=>g.dynamicSlot(O)));a[p.id]=c.length<<1,c.push(g=>D8(g,p,h))}}let f=c.map(d=>d(a));return new i(e,o,f,a,l,s)}};function Q8(i,e,t){let n=[[],[],[],[],[]],r=new Map;function s(o,a){let l=r.get(o);if(l!=null){if(l<=a)return;let c=n[l].indexOf(o);c>-1&&n[l].splice(c,1),o instanceof uc&&t.delete(o.compartment)}if(r.set(o,a),Array.isArray(o))for(let c of o)s(c,a);else if(o instanceof uc){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),s(c,a)}else if(o instanceof rd)s(o.inner,o.prec);else if(o instanceof Xt)n[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof qa)n[a].push(o),o.facet.extensions&&s(o.facet.extensions,Mo.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,a)}}return s(i,Mo.default),n.reduce((o,a)=>o.concat(a))}function cc(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let r=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|r}function ad(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}var Pk=Ee.define(),jg=Ee.define({combine:i=>i.some(e=>e),static:!0}),Ck=Ee.define({combine:i=>i.length?i[0]:void 0,static:!0}),Ek=Ee.define(),Tk=Ee.define(),Ak=Ee.define(),Dk=Ee.define({combine:i=>i.length?i[0]:!1}),pn=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Zg}},Zg=class{of(e){return new pn(this,e)}},zg=class{constructor(e){this.map=e}of(e){return new Ze(this,e)}},Ze=class i{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new i(this.type,t)}is(e){return this.type==e}static define(e={}){return new zg(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(t);s&&n.push(s)}return n}};Ze.reconfigure=Ze.define();Ze.appendConfig=Ze.define();var gi=class i{constructor(e,t,n,r,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&xk(n,t.newLength),s.some(a=>a.type==i.time)||(this.annotations=s.concat(i.time.of(Date.now())))}static create(e,t,n,r,s,o){return new i(e,t,n,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(i.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};gi.time=pn.define();gi.userEvent=pn.define();gi.addToHistory=pn.define();gi.remote=pn.define();function R8(i,e){let t=[];for(let n=0,r=0;;){let s,o;if(n=i[n]))s=i[n++],o=i[n++];else if(r=0;r--){let s=n[r](i);s instanceof gi?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof gi?i=s[0]:i=Rk(e,La(s),!1)}return i}function I8(i){let e=i.startState,t=e.facet(Ak),n=i;for(let r=t.length-1;r>=0;r--){let s=t[r](i);s&&Object.keys(s).length&&(n=Qk(n,qg(e,s,i.changes.newLength),!0))}return n==i?i:gi.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}var N8=[];function La(i){return i==null?N8:Array.isArray(i)?i:[i]}var Pt=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(Pt||(Pt={})),j8=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Lg;try{Lg=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Z8(i){if(Lg)return Lg.test(i);for(let e=0;e"\x80"&&(t.toUpperCase()!=t.toLowerCase()||j8.test(t)))return!0}return!1}function z8(i){return e=>{if(!/\S/.test(e))return Pt.Space;if(Z8(e))return Pt.Word;for(let t=0;t-1)return Pt.Word;return Pt.Other}}var At=class i{constructor(e,t,n,r,s,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;ar.set(c,l)),t=null),r.set(a.value.compartment,a.value.extension)):a.is(Ze.reconfigure)?(t=null,n=a.value):a.is(Ze.appendConfig)&&(t=null,n=La(n).concat(a.value));let s;t?s=e.startState.values.slice():(t=od.resolve(n,r,this),s=new i(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(jg)?e.newSelection:e.newSelection.asSingle();new i(t,e.newDoc,o,s,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:le.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),s=[n.range],o=La(n.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return i.create({doc:e.doc,selection:le.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=od.resolve(e.extensions||[],new Map),n=e.doc instanceof rt?e.doc:rt.of((e.doc||"").split(t.staticFacet(i.lineSeparator)||Rg)),r=e.selection?e.selection instanceof le?e.selection:le.single(e.selection.anchor,e.selection.head):le.single(0);return xk(r,n.length),t.staticFacet(jg)||(r=r.asSingle()),new i(t,n,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(i.tabSize)}get lineBreak(){return this.facet(i.lineSeparator)||` `}get readOnly(){return this.facet(Dk)}phrase(e,...t){for(let n of this.facet(i.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet(Pk))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return z8(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,a=e-n;for(;o>0;){let l=ui(t,o,!1);if(s(t.slice(l,o))!=Pt.Word)break;o=l}for(;ai.length?i[0]:4});At.lineSeparator=Ck;At.readOnly=Dk;At.phrases=Ee.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(r=>i[r]==e[r])}});At.languageData=Pk;At.changeFilter=Ek;At.transactionFilter=Tk;At.transactionExtender=Ak;sd.reconfigure=Ze.define();function mn(i,e,t={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],a=n[s];if(a===void 0)n[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}var dr=class{eq(e){return this==e}range(e,t=e){return fc.create(e,t,this)}};dr.prototype.startSide=dr.prototype.endSide=0;dr.prototype.point=!1;dr.prototype.mapMode=Ci.TrackDel;var fc=class i{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new i(e,t,n)}};function $g(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var Fg=class i{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let o=r,a=s.length;;){if(o==a)return o;let l=o+a>>1,c=s[l]-e||(n?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return c>=0?o:a;c>=0?a=l:o=l+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);sh||d==h&&c.startSide>0&&c.endSide<=0)continue;(h-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(a=Math.max(a,h-d)),n.push(c),r.push(d-o),s.push(h-o))}return{mapped:n.length?new i(r,s,n,a):null,pos:o}}},St=class i{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new i(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort($g)),this.isEmpty)return t.length?i.of(t):this;let a=new ld(this,null,-1).goto(0),l=0,c=[],u=new Zr;for(;a.value||l=0){let f=t[l++];u.addInner(f.from,f.to,f.value)||c.push(f)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||sa.to||s=s&&e<=s+o.length&&o.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return dc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return dc.from(e).goto(t)}static compare(e,t,n,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=_k(o,a,n),c=new Io(o,l,s),u=new Io(a,l,s);n.iterGaps((f,d,h)=>wk(c,f,u,d,h,r)),n.empty&&n.length==0&&wk(c,0,u,0,0,r)}static eq(e,t,n=0,r){r==null&&(r=999999999);let s=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),o=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=_k(s,o),l=new Io(s,a,0).goto(n),c=new Io(o,a,0).goto(n);for(;;){if(l.to!=c.to||!Bg(l.active,c.active)||l.point&&(!c.point||!l.point.eq(c.point)))return!1;if(l.to>r)return!0;l.next(),c.next()}}static spans(e,t,n,r,s=-1){let o=new Io(e,null,s).goto(t),a=t,l=o.openStart;for(;;){let c=Math.min(o.to,n);if(o.point){let u=o.activeForPoint(o.to),f=o.pointFroma&&(r.span(a,c,o.active,l),l=o.openEnd(c));if(o.to>n)return l+(o.point&&o.to>n?1:0);a=o.to,o.next()}}static of(e,t=!1){let n=new Zr;for(let r of e instanceof fc?[e]:t?q8(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return i.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=i.empty;r=r.nextLayer)t=new i(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};St.empty=new St([],[],null,-1);function q8(i){if(i.length>1)for(let e=i[0],t=1;t0)return i.slice().sort($g);e=n}return i}St.empty.nextLayer=St.empty;var Zr=class i{finishChunk(e){this.chunks.push(new Fg(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new i)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(St.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=St.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function _k(i,e,t){let n=new Map;for(let s of i)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=n&&r.push(new ld(o,t,n,s));return r.length==1?r[0]:new i(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)Dg(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)Dg(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Dg(this.heap,0)}}};function Dg(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let r=i[n];if(n+1=0&&(r=i[n+1],n++),t.compare(r)<0)break;i[n]=t,i[e]=r,e=n}}var Io=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=dc.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Jf(this.active,e),Jf(this.activeTo,e),Jf(this.activeRank,e),this.minActive=kk(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t0;)t++;ed(this.active,t,n),ed(this.activeTo,t,r),ed(this.activeRank,t,s),e&&ed(e,t,this.cursor.from),this.minActive=kk(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Jf(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[r]=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function wk(i,e,t,n,r,s){i.goto(e),t.goto(n);let o=n+r,a=n,l=n-e;for(;;){let c=i.to+l-t.to,u=c||i.endSide-t.endSide,f=u<0?i.to+l:t.to,d=Math.min(f,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&Bg(i.activeForPoint(i.to),t.activeForPoint(t.to))||s.comparePoint(a,d,i.point,t.point):d>a&&!Bg(i.active,t.active)&&s.compareRange(a,d,i.active,t.active),f>o)break;(c||i.openEnd!=t.openEnd)&&s.boundChange&&s.boundChange(f),a=f,u<=0&&i.next(),u>=0&&t.next()}}function Bg(i,e){if(i.length!=e.length)return!1;for(let t=0;t=e;n--)i[n+1]=i[n];i[e]=t}function kk(i,e){let t=-1,n=1e9;for(let r=0;r=e)return r;if(r==i.length)break;s+=i.charCodeAt(r)==9?t-s%t:1,r=ui(i,r)}return n===!0?-1:i.length}var Xg="\u037C",Mk=typeof Symbol>"u"?"__"+Xg:Symbol.for(Xg),Ug=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ik=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},zn=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,a,l,c){let u=[],f=/^@(\w+)\b/.exec(o[0]),d=f&&f[1]=="keyframes";if(f&&a==null)return l.push(o[0]+";");for(let h in a){let p=a[h];if(/&/.test(h))s(h.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,l);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+h+") should be a primitive value.");s(r(h),p,u,d)}else p!=null&&u.push(h.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(u.length||d)&&l.push((n&&!f&&!c?o.map(n):o).join(", ")+" {"+u.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Ik[Mk]||1;return Ik[Mk]=e+1,Xg+e.toString(36)}static mount(e,t,n){let r=e[Ug],s=n&&n.nonce;r?s&&r.setNonce(s):r=new Yg(e,s),r.mount(Array.isArray(t)?t:[t],e)}},Nk=new Map,Yg=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Nk.get(n);if(s)return e[Ug]=s;this.sheet=new r.CSSStyleSheet,Nk.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Ug]=this}mount(e,t){let n=this.sheet,r=0,s=0;for(let o=0;o-1&&(this.modules.splice(l,1),s--,l=-1),l==-1){if(this.modules.splice(s++,0,a),n)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},L8=typeof navigator<"u"&&/Mac/.test(navigator.platform),$8=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(fi=0;fi<10;fi++)Os[48+fi]=Os[96+fi]=String(fi);var fi;for(fi=1;fi<=24;fi++)Os[fi+111]="F"+fi;var fi;for(fi=65;fi<=90;fi++)Os[fi]=String.fromCharCode(fi+32),Fa[fi]=String.fromCharCode(fi);var fi;for(ud in Os)Fa.hasOwnProperty(ud)||(Fa[ud]=Os[ud]);var ud;function jk(i){var e=L8&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||$8&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?Fa:Os)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function wt(){var i=arguments[0];typeof i=="string"&&(i=document.createElement(i));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=t[n];typeof r=="string"?i.setAttribute(n,r):r!=null&&(i[n]=r)}e++}for(;e2),xe={mac:Lk||/Mac/.test(Yi.platform),windows:/Win/.test(Yi.platform),linux:/Linux|X11/.test(Yi.platform),ie:qd,ie_version:S2?i0.documentMode||6:r0?+r0[1]:n0?+n0[1]:0,gecko:zk,gecko_version:zk?+(/Firefox\/(\d+)/.exec(Yi.userAgent)||[0,0])[1]:0,chrome:!!Hg,chrome_version:Hg?+Hg[1]:0,ios:Lk,android:/Android\b/.test(Yi.userAgent),webkit:qk,webkit_version:qk?+(/\bAppleWebKit\/(\d+)/.exec(Yi.userAgent)||[0,0])[1]:0,safari:s0,safari_version:s0?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Yi.userAgent)||[0,0])[1]:0,tabSize:i0.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function xc(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function o0(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function bd(i,e){if(!e.anchorNode)return!1;try{return o0(i,e.anchorNode)}catch{return!1}}function Pc(i){return i.nodeType==3?Lo(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function yc(i,e,t,n){return t?$k(i,e,t,n,-1)||$k(i,e,t,n,1):!1}function qo(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function xd(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function $k(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:Fr(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=qo(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[e+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=r<0?Fr(i):0}else return!1}}function Fr(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function Ld(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function F8(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function x2(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function B8(i,e,t,n,r,s,o,a){let l=i.ownerDocument,c=l.defaultView||window;for(let u=i,f=!1;u&&!f;)if(u.nodeType==1){let d,h=u==l.body,p=1,m=1;if(h)d=F8(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(f=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let w=u.getBoundingClientRect();({scaleX:p,scaleY:m}=x2(u,w)),d={left:w.left,right:w.left+u.clientWidth*p,top:w.top,bottom:w.top+u.clientHeight*m}}let g=0,O=0;if(r=="nearest")e.top0&&e.bottom>d.bottom+O&&(O=e.bottom-d.bottom+o)):e.bottom>d.bottom&&(O=e.bottom-d.bottom+o,t<0&&e.top-O0&&e.right>d.right+g&&(g=e.right-d.right+s)):e.right>d.right&&(g=e.right-d.right+s,t<0&&e.leftd.bottom||e.leftd.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function V8(i){let e=i.ownerDocument,t,n;for(let r=i.parentNode;r&&!(r==e.body||t&&n);)if(r.nodeType==1)!n&&r.scrollHeight>r.clientHeight&&(n=r),!t&&r.scrollWidth>r.clientWidth&&(t=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:t,y:n}}var a0=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Fr(t):0),n,Math.min(e.focusOffset,n?Fr(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},Zo=null;xe.safari&&xe.safari_version>=26&&(Zo=!1);function P2(i){if(i.setActive)return i.setActive();if(Zo)return i.focus(Zo);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(Zo==null?{get preventScroll(){return Zo={preventScroll:!0},!0}}:void 0),!Zo){Zo=!1;for(let t=0;tMath.max(1,i.scrollHeight-i.clientHeight-4)}function T2(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=Fr(t)}else if(t.parentNode&&!xd(t))n=qo(t),t=t.parentNode;else return null}}function A2(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&nt)return f.domBoundsAround(e,t,c);if(d>=e&&r==-1&&(r=l,s=c),c>t&&f.dom.parentNode==this.dom){o=l,a=u;break}u=d,c=d+f.breakAfter}return{from:s,to:a<0?n+this.length:a,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=q0){this.markDirty();for(let r=e;rthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}};function D2(i,e,t,n,r,s,o,a,l){let{children:c}=i,u=c.length?c[e]:null,f=s.length?s[s.length-1]:null,d=f?f.breakAfter:o;if(!(e==n&&u&&!o&&!d&&s.length<2&&u.merge(t,r,s.length?f:null,t==0,a,l))){if(n0&&(!o&&s.length&&u.merge(t,u.length,s[0],!1,a,0)?u.breakAfter=s.shift().breakAfter:(tU8||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new i(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Hi(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Y8(this.dom,e,t)}},Xs=class i extends Qt{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let r of t)r.setParent(this)}setAttrs(e){if(C2(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,r,s,o){return n&&(!(n instanceof i&&n.mark.eq(this.mark))||e&&s<=0||te&&t.push(n=e&&(r=s),n=l,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new i(this.mark,t,o)}domAtPos(e){return R2(this,e)}coordsAt(e,t){return I2(this,e,t)}};function Y8(i,e,t){let n=i.nodeValue.length;e>n&&(e=n);let r=e,s=e,o=0;e==0&&t<0||e==n&&t>=0?xe.chrome||xe.gecko||(e?(r--,o=1):s=0)?0:a.length-1];return xe.safari&&!o&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),o?Ld(l,o<0):l||null}var Cc=class i extends Qt{static create(e,t,n){return new i(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=i.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,r,s,o){return n&&(!(n instanceof i)||!this.widget.compare(n.widget)||e>0&&s<=0||t0)?Hi.before(this.dom):Hi.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let a=o?r.length-1:0;s=r[a],!(e>0?a==0:a==r.length-1||s.top0?Hi.before(this.dom):Hi.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return rt.empty}get isHidden(){return!0}};Br.prototype.children=Cc.prototype.children=Ec.prototype.children=q0;function R2(i,e){let t=i.dom,{children:n}=i,r=0;for(let s=0;rs&&e0;s--){let o=n[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s0&&e instanceof Xs&&r.length&&(n=r[r.length-1])instanceof Xs&&n.mark.eq(e.mark)?M2(n,e.children[0],t-1):(r.push(e),e.setParent(i)),i.length+=e.length}function I2(i,e,t){let n=null,r=-1,s=null,o=-1;function a(c,u){for(let f=0,d=0;f=u&&(h.children.length?a(h,u-d):(!s||s.isHidden&&(t>0||G8(s,h)))&&(p>u||d==p&&h.getSide()>0)?(s=h,o=u-d):(d-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of n)if(s!=t&&(r.indexOf(s)==-1||i[s]!==e[s]))return!1;return!0}function c0(i,e,t){let n=!1;if(e)for(let r in e)t&&r in t||(n=!0,r=="style"?i.style.cssText="":i.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(n=!0,r=="style"?i.style.cssText=t[r]:i.setAttribute(r,t[r]));return n}function K8(i){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new Us(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:o}=N2(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Us(e,n,r,t,e.widget||null,!0)}static line(e){return new Ac(e)}static set(e,t=!1){return St.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Ne.none=St.empty;var Tc=class i extends Ne{constructor(e){let{start:t,end:n}=N2(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof i&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&Cd(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};Tc.prototype.point=!1;var Ac=class i extends Ne{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof i&&this.spec.class==e.spec.class&&Cd(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};Ac.prototype.mapMode=Ci.TrackBefore;Ac.prototype.point=!0;var Us=class i extends Ne{constructor(e,t,n,r,s,o){super(t,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ci.TrackBefore:Ci.TrackAfter:Ci.TrackDel}get type(){return this.startSide!=this.endSide?Gi.WidgetRange:this.startSide<=0?Gi.WidgetBefore:Gi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof i&&J8(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};Us.prototype.point=!0;function N2(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function J8(i,e){return i==e||!!(i&&e&&i.compare(e))}function _d(i,e,t,n=0){let r=t.length-1;r>=0&&t[r]+n>=i?t[r]=Math.max(t[r],e):t.push(i,e)}var Ei=class i extends Qt{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,r,s,o){if(n){if(!(n instanceof i))return!1;this.dom||n.transferDOM(this)}return r&&this.setDeco(n?n.attrs:null),Q2(this,e,t,n?n.children.slice():[],s,o),!0}split(e){let t=new i;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:r}=this.childPos(e);r&&(t.append(this.children[n].split(r),0),this.children[n].merge(r,this.children[n].length,null,!1,0,0),n++);for(let s=n;s0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Cd(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){M2(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=l0(t,this.attrs||{})),n&&(this.attrs=l0({class:n},this.attrs||{}))}domAtPos(e){return R2(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(C2(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(c0(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&Qt.get(r)instanceof Xs;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((n=Qt.get(r))===null||n===void 0?void 0:n.isEditable)==!1&&(!xe.ios||!this.children.some(s=>s instanceof Br))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof Br)||/[^ -~]/.test(n.text))return null;let r=Pc(n.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=I2(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=n.bottom-n.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight=t){if(s instanceof i)return s;if(o>t)break}r=o+s.breakAfter}return null}},zo=class i extends Qt{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,r,s,o){return n&&(!(n instanceof i)||!this.widget.compare(n.widget)||e>0&&s<=0||t0}},Dc=class extends pr{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},bc=class i{constructor(e,t,n,r){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=r,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof zo&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ei),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(fd(new Ec(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof zo)&&this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:o,lineBreak:a,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(a){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=o,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e),s=Math.min(r,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(fd(new Br(this.text.slice(this.textOff,this.textOff+s)),t),n),this.atCursorPos=!0,this.textOff+=s,e-=s,n=r<=s?0:t.length}}span(e,t,n,r){this.buildText(t-e,n,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,n,r,s,o){if(this.disallowBlockEffectsFor[o]&&n instanceof Us){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let a=t-e;if(n instanceof Us)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new zo(n.widget||Ys.block,a,n));else{let l=Cc.create(n.widget||Ys.inline,a,a?0:n.startSide),c=this.atCursorPos&&!l.isEditable&&s<=r.length&&(e0),u=!l.isEditable&&(er.length||n.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!c&&!l.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),c&&(f.append(fd(new Ec(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(fd(l,r),s),this.atCursorPos=u,this.pendingBuffer=u?er.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);a&&(this.textOff+a<=this.text.length?this.textOff+=a:(this.skip+=a-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,n,r,s){let o=new i(e,t,n,s);return o.openEnd=St.spans(r,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function fd(i,e){for(let t of e)i=new Xs(t,[i],i.length);return i}var Ys=class extends pr{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};Ys.inline=new Ys("span");Ys.block=new Ys("div");var Ct=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(Ct||(Ct={})),$o=Ct.LTR,L0=Ct.RTL;function j2(i){let e=[];for(let t=0;t=t){if(a.level==n)return o;(s<0||(r!=0?r<0?a.fromt:e[s].level>a.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function z2(i,e){if(i.length!=e.length)return!1;for(let t=0;t=0;m-=3)if(zr[m+1]==-h){let g=zr[m+2],O=g&2?r:g&4?g&1?s:r:0;O&&(Dt[f]=Dt[zr[m]]=O),a=m;break}}else{if(zr.length==189)break;zr[a++]=f,zr[a++]=d,zr[a++]=l}else if((p=Dt[f])==2||p==1){let m=p==r;l=m?0:1;for(let g=a-3;g>=0;g-=3){let O=zr[g+2];if(O&2)break;if(m)zr[g+2]|=2;else{if(O&4)break;zr[g+2]|=4}}}}}function sQ(i,e,t,n){for(let r=0,s=n;r<=t.length;r++){let o=r?t[r-1].to:i,a=rl;)p==g&&(p=t[--m].from,g=m?t[m-1].to:i),Dt[--p]=h;l=u}else s=c,l++}}}function f0(i,e,t,n,r,s,o){let a=n%2?2:1;if(n%2==r%2)for(let l=e,c=0;ll&&o.push(new Lr(l,m.from,h));let g=m.direction==$o!=!(h%2);d0(i,g?n+1:n,r,m.inner,m.from,m.to,o),l=m.to}p=m.to}else{if(p==t||(u?Dt[p]!=a:Dt[p]==a))break;p++}d?f0(i,l,p,n+1,r,d,o):le;){let u=!0,f=!1;if(!c||l>s[c-1].to){let m=Dt[l-1];m!=a&&(u=!1,f=m==16)}let d=!u&&a==1?[]:null,h=u?n:n+1,p=l;e:for(;;)if(c&&p==s[c-1].to){if(f)break e;let m=s[--c];if(!u)for(let g=m.from,O=c;;){if(g==e)break e;if(O&&s[O-1].to==g)g=s[--O].from;else{if(Dt[g-1]==a)break e;break}}if(d)d.push(m);else{m.toDt.length;)Dt[Dt.length]=256;let n=[],r=e==$o?0:1;return d0(i,r,r,t,0,i.length,n),n}function q2(i){return[new Lr(0,i,0)]}var L2="";function aQ(i,e,t,n,r){var s;let o=n.head-i.from,a=Lr.find(e,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),l=e[a],c=l.side(r,t);if(o==c){let d=a+=r?1:-1;if(d<0||d>=e.length)return null;l=e[a=d],o=l.side(!r,t),c=l.side(r,t)}let u=ui(i.text,o,l.forward(r,t));(ul.to)&&(u=c),L2=i.text.slice(Math.min(o,u),Math.max(o,u));let f=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return f&&u==c&&f.level+(r?0:1)i.some(e=>e)}),Y2=Ee.define({combine:i=>i.some(e=>e)}),H2=Ee.define(),_c=class i{constructor(e,t="nearest",n="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new i(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new i(le.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},dd=Ze.define({map:(i,e)=>i.map(e)}),G2=Ze.define();function Ti(i,e,t){let n=i.facet(V2);n.length?n[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}var vs=Ee.define({combine:i=>i.length?i[0]:!0}),cQ=0,Ba=Ee.define({combine(i){return i.filter((e,t)=>{for(let n=0;n{let l=[];return o&&l.push(Qc.of(c=>{let u=c.plugin(a);return u?o(u):Ne.none})),s&&l.push(s(a)),l})}static fromClass(e,t){return i.define((n,r)=>new e(n,r),t)}},wc=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Ti(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Ti(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Ti(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},K2=Ee.define(),B0=Ee.define(),Qc=Ee.define(),J2=Ee.define(),Ic=Ee.define(),eS=Ee.define();function Wk(i,e){let t=i.state.facet(eS);if(!t.length)return t;let n=t.map(s=>s instanceof Function?s(i):s),r=[];return St.spans(n,e.from,e.to,{point(){},span(s,o,a,l){let c=s-e.from,u=o-e.from,f=r;for(let d=a.length-1;d>=0;d--,l--){let h=a[d].spec.bidiIsolate,p;if(h==null&&(h=lQ(e.text,c,u)),l>0&&f.length&&(p=f[f.length-1]).to==c&&p.direction==h)p.to=u,f=p.inner;else{let m={from:c,to:u,direction:h,inner:[]};f.push(m),f=m.inner}}}}),r}var tS=Ee.define();function V0(i){let e=0,t=0,n=0,r=0;for(let s of i.state.facet(tS)){let o=s(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:n,bottom:r}}var mc=Ee.define(),$r=class i{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new i(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toAu)break;s+=2}if(!l)return n;new i(l.fromA,l.toA,l.fromB,l.toB).addToSet(n),o=l.toA,a=l.toB}}},Ed=class i{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Ui.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,a,l)=>r.push(new $r(s,o,a,l))),this.changedRanges=r}static create(e,t,n){return new i(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Td=class extends Qt{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Ne.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ei],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new $r(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:c,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!gQ(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?fQ(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:c,to:u}=this.hasComposition;n=new $r(c,u,e.changes.mapPos(c,-1),e.changes.mapPos(u,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(xe.ie||xe.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.updateDeco(),l=pQ(o,a,e.changes);return n=$r.extendWithRanges(n,l),!(this.flags&7)&&n.length==0?!1:(this.updateInner(n,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=xe.chrome||xe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to=0?r[o]:null;if(!a)break;let{fromA:l,toA:c,fromB:u,toB:f}=a,d,h,p,m;if(n&&n.range.fromBu){let C=bc.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),k=bc.build(this.view.state.doc,n.range.toB,f,this.decorations,this.dynamicDecorationMap);h=C.breakAtStart,p=C.openStart,m=k.openEnd;let _=this.compositionView(n);k.breakAtStart?_.breakAfter=1:k.content.length&&_.merge(_.length,_.length,k.content[0],!1,k.openStart,0)&&(_.breakAfter=k.content[0].breakAfter,k.content.shift()),C.content.length&&_.merge(0,0,C.content[C.content.length-1],!0,0,C.openEnd)&&C.content.pop(),d=C.content.concat(_).concat(k.content)}else({content:d,breakAtStart:h,openStart:p,openEnd:m}=bc.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:g,off:O}=s.findPos(c,1),{i:w,off:S}=s.findPos(l,-1);D2(this,w,S,g,O,d,h,p,m)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(G2)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new Br(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Xs(r,[t],t.length);let n=new Ei;return n.append(t,0),n}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(l=>l.flags&7)?1:0),this.markedForComposition.add(o);let a=Qt.get(s);a&&a!=o&&(a.dom=null),o.setDOM(s)},n=this.childPos(e.range.fromB,1),r=this.children[n.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)n=r.childPos(n.off,1),r=r.children[n.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,r=n==this.dom,s=!r&&!(this.view.state.facet(vs)||this.dom.tabIndex>-1)&&bd(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(a.anchor)),c=a.empty?l:this.moveToLine(this.domAtPos(a.head));if(xe.gecko&&a.empty&&!this.hasComposition&&uQ(l)){let f=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(f,l.node.childNodes[l.offset]||null)),l=c=new Hi(f,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!yc(l.node,l.offset,u.anchorNode,u.anchorOffset)||!yc(c.node,c.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{xe.android&&xe.chrome&&this.dom.contains(u.focusNode)&&mQ(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=xc(this.view.root);if(f)if(a.empty){if(xe.gecko){let d=dQ(l.node,l.offset);if(d&&d!=3){let h=(d==1?T2:A2)(l.node,l.offset);h&&(l=new Hi(h.node,h.offset))}}f.collapse(l.node,l.offset),a.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(l.node,l.offset);try{f.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([l,c]=[c,l]),d.setEnd(c.node,c.offset),d.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(d)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(l,c)),this.impreciseAnchor=l.precise?null:new Hi(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new Hi(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&yc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=xc(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=Ei.find(this,t.head);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let l=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!l||!c||l.bottom>c.top)return;let u=this.domAtPos(t.head+t.assoc);n.collapse(u.node,u.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&n.collapse(r,s)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let r=e.offset;!n&&r=0;r--){let s=Qt.get(t.childNodes[r]);s instanceof Ei&&(n=s.domAtPos(s.length))}return n?new Hi(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let n=Qt.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t=0;o--){let a=this.children[o],l=s-a.breakAfter,c=l-a.length;if(le||a.covers(1))&&(!n||a instanceof Ei&&!(n instanceof Ei&&t>=0)))n=a,r=c;else if(n&&c==e&&l==e&&a instanceof zo&&Math.abs(t)<2){if(a.deco.startSide<0)break;o&&(n=null)}s=c}return n?n.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),r=this.children[t];if(!(r instanceof Ei))return null;for(;r.children.length;){let{i:a,off:l}=r.childPos(n,1);for(;;a++){if(a==r.children.length)return null;if((r=r.children[a]).length)break}n=l}if(!(r instanceof Br))return null;let s=ui(r.text,n);if(s==n)return null;let o=Lo(r.dom,n,s).getClientRects();for(let a=0;aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==Ct.LTR;for(let c=0,u=0;ur)break;if(c>=n){let h=f.dom.getBoundingClientRect();if(t.push(h.height),o){let p=f.dom.lastChild,m=p?Pc(p):[];if(m.length){let g=m[m.length-1],O=l?g.right-h.left:h.right-g.left;O>a&&(a=O,this.minWidth=s,this.minWidthFrom=c,this.minWidthTo=d)}}}c=d+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?Ct.RTL:Ct.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ei){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,n,r;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=Pc(e.firstChild)[0];t=e.getBoundingClientRect().height,n=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Pd(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>n){let a=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(Ne.replace({widget:new Dc(a),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return Ne.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Qc).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),n=!1,r=this.view.state.facet(J2).map((s,o)=>{let a=typeof s=="function";return a&&(n=!0),a?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(St.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];et.anchor?-1:1),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let s=V0(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;B8(this.view.scrollDOM,o,t.head{ne.from&&(t=!0)}),t}function OQ(i,e,t=1){let n=i.charCategorizer(e),r=i.doc.lineAt(e),s=e-r.from;if(r.length==0)return le.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,a=s;t<0?o=ui(r.text,s,!1):a=ui(r.text,s);let l=n(r.text.slice(o,a));for(;o>0;){let c=ui(r.text,o,!1);if(n(r.text.slice(c,o))!=l)break;o=c}for(;ai?e.left-i:Math.max(0,i-e.right)}function yQ(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function Gg(i,e){return i.tope.top+1}function Xk(i,e){return ei.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function p0(i,e,t){let n,r,s,o,a=!1,l,c,u,f;for(let p=i.firstChild;p;p=p.nextSibling){let m=Pc(p);for(let g=0;gS||o==S&&s>w)&&(n=p,r=O,s=w,o=S,a=w?e0:gO.bottom&&(!u||u.bottomO.top)&&(c=p,f=O):u&&Gg(u,O)?u=Uk(u,O.bottom):f&&Gg(f,O)&&(f=Xk(f,O.top))}}if(u&&u.bottom>=t?(n=l,r=u):f&&f.top<=t&&(n=c,r=f),!n)return{node:i,offset:0};let d=Math.max(r.left,Math.min(r.right,e));if(n.nodeType==3)return Yk(n,d,t);if(a&&n.contentEditable!="false")return p0(n,d,t);let h=Array.prototype.indexOf.call(i.childNodes,n)+(e>=(r.left+r.right)/2?1:0);return{node:i,offset:h}}function Yk(i,e,t){let n=i.nodeValue.length,r=-1,s=1e9,o=0;for(let a=0;at?u.top-t:t-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&f=(u.left+u.right)/2,h=d;if((xe.chrome||xe.gecko)&&Lo(i,a).getBoundingClientRect().left==u.right&&(h=!d),f<=0)return{node:i,offset:a+(h?1:0)};r=a+(h?1:0),s=f}}}return{node:i,offset:r>-1?r:o>0?i.nodeValue.length:0}}function nS(i,e,t,n=-1){var r,s;let o=i.contentDOM.getBoundingClientRect(),a=o.top+i.viewState.paddingTop,l,{docHeight:c}=i.viewState,{x:u,y:f}=e,d=f-a;if(d<0)return 0;if(d>c)return i.state.doc.length;for(let C=i.viewState.heightOracle.textHeight/2,k=!1;l=i.elementAtHeight(d),l.type!=Gi.Text;)for(;d=n>0?l.bottom+C:l.top-C,!(d>=0&&d<=c);){if(k)return t?null:0;k=!0,n=-n}f=a+d;let h=l.from;if(hi.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:Hk(i,o,l,u,f);let p=i.dom.ownerDocument,m=i.root.elementFromPoint?i.root:p,g=m.elementFromPoint(u,f);g&&!i.contentDOM.contains(g)&&(g=null),g||(u=Math.max(o.left+1,Math.min(o.right-1,u)),g=m.elementFromPoint(u,f),g&&!i.contentDOM.contains(g)&&(g=null));let O,w=-1;if(g&&((r=i.docView.nearest(g))===null||r===void 0?void 0:r.isEditable)!=!1){if(p.caretPositionFromPoint){let C=p.caretPositionFromPoint(u,f);C&&({offsetNode:O,offset:w}=C)}else if(p.caretRangeFromPoint){let C=p.caretRangeFromPoint(u,f);C&&({startContainer:O,startOffset:w}=C)}O&&(!i.contentDOM.contains(O)||xe.safari&&bQ(O,w,u)||xe.chrome&&_Q(O,w,u))&&(O=void 0),O&&(w=Math.min(Fr(O),w))}if(!O||!i.docView.dom.contains(O)){let C=Ei.find(i.docView,h);if(!C)return d>l.top+l.height/2?l.to:l.from;({node:O,offset:w}=p0(C.dom,u,f))}let S=i.docView.nearest(O);if(!S)return null;if(S.isWidget&&((s=S.dom)===null||s===void 0?void 0:s.nodeType)==1){let C=S.dom.getBoundingClientRect();return e.yi.defaultLineHeight*1.5){let a=i.viewState.heightOracle.textHeight,l=Math.floor((r-t.top-(i.defaultLineHeight-a)*.5)/a);s+=l*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+cd(o,s,i.state.tabSize)}function rS(i,e,t){let n,r=i;if(i.nodeType!=3||e!=(n=i.nodeValue.length))return!1;for(;;){let s=r.nextSibling;if(s){if(s.nodeName=="BR")break;return!1}else{let o=r.parentNode;if(!o||o.nodeName=="DIV")break;r=o}}return Lo(i,n-1,n).getBoundingClientRect().right>t}function bQ(i,e,t){return rS(i,e,t)}function _Q(i,e,t){if(e!=0)return rS(i,e,t);for(let r=i;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let n=i.nodeType==1?i.getBoundingClientRect():Lo(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function m0(i,e,t){let n=i.lineBlockAt(e);if(Array.isArray(n.type)){let r;for(let s of n.type){if(s.from>e)break;if(!(s.toe)return s;(!r||s.type==Gi.Text&&(r.type!=s.type||(t<0?s.frome)))&&(r=s)}}return r||n}return n}function wQ(i,e,t,n){let r=m0(i,e.head,e.assoc||-1),s=!n||r.type!=Gi.Text||!(i.lineWrapping||r.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=i.dom.getBoundingClientRect(),a=i.textDirectionAt(r.from),l=i.posAtCoords({x:t==(a==Ct.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(l!=null)return le.cursor(l,t?-1:1)}return le.cursor(t?r.to:r.from,t?-1:1)}function Gk(i,e,t,n){let r=i.state.doc.lineAt(e.head),s=i.bidiSpans(r),o=i.textDirectionAt(r.from);for(let a=e,l=null;;){let c=aQ(r,s,o,a,t),u=L2;if(!c){if(r.number==(t?i.state.doc.lines:1))return a;u=` `,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),c=i.visualLineSide(r,!t)}if(l){if(!l(u))return a}else{if(!n)return c;l=n(u)}a=c}}function kQ(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let o=n(s);return r==Pt.Space&&(r=o),r==o}}function SQ(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return le.cursor(r,e.assoc);let o=e.goalColumn,a,l=i.contentDOM.getBoundingClientRect(),c=i.coordsAtPos(r,e.assoc||-1),u=i.documentTop;if(c)o==null&&(o=c.left-l.left),a=s<0?c.top:c.bottom;else{let h=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(l.right-l.left,i.defaultCharacterWidth*(r-h.from))),a=(s<0?h.top:h.bottom)+u}let f=l.left+o,d=n??i.viewState.heightOracle.textHeight>>1;for(let h=0;;h+=10){let p=a+(d+h)*s,m=nS(i,{x:f,y:p},!1,s);if(pl.bottom||(s<0?mr)){let g=i.docView.coordsForChar(m),O=!g||p{if(e>s&&er(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:le.cursor(n,ns)&&!PQ(o,t)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,a;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(a=r.exec(t))&&(s=a.index,o=a[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);n=s+o}}readNode(e){if(e.cmIgnore)return;let t=Qt.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(xQ(e,n.node,n.offset)?t:0))}};function xQ(i,e,t){for(;;){if(!e||t-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let a=s||o?[]:EQ(e),l=new g0(a,e.state);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=TQ(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!o0(e.contentDOM,a.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!o0(e.contentDOM,a.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if((xe.ios||xe.chrome)&&e.state.selection.main.empty&&l!=c&&(u.from>0||u.toDate.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:a}=e.bounds,l=r.from,c=null;(s===8||xe.android&&e.text.length=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:i.state.doc.slice(r.from,t.from).append(t.insert).append(i.state.doc.slice(t.to,r.to))}:xe.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==` `&&i.lineWrapping&&(n&&(n=le.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:rt.of([" "])}),t)return W0(i,t,n,s);if(n&&!n.main.eq(r)){let o=!1,a="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),a=i.inputState.lastSelectionOrigin,a=="select.pointer"&&(n=sS(i.state.facet(Ic).map(l=>l(i)),n))),i.dispatch({selection:n,scrollIntoView:o,userEvent:a}),!0}else return!1}function W0(i,e,t,n=-1){if(xe.ios&&i.inputState.flushIOSKey(e))return!0;let r=i.state.selection.main;if(xe.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&i.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Xa(i.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||n==8&&e.insert.lengthr.head)&&Xa(i.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Xa(i.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,a=()=>o||(o=CQ(i,e,t));return i.state.facet(W2).some(l=>l(i,e.from,e.to,s,a))||i.dispatch(a()),!0}function CQ(i,e,t){let n,r=i.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let l=e.fromf(i)),c,l);e.from==u&&(o=u)}if(o>-1)n={changes:e,selection:le.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let l=s.frome.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(i.state.toText(l+e.insert.sliceString(0,void 0,i.state.lineBreak)+c))}else{let l=r.changes(e),c=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&i.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let u=i.state.sliceDoc(e.from,e.to),f,d=t&&iS(i,t.main.head);if(d){let m=e.insert.length-(e.to-e.from);f={from:d.from,to:d.to-m}}else f=i.state.doc.lineAt(s.head);let h=s.to-e.to,p=s.to-s.from;n=r.changeByRange(m=>{if(m.from==s.from&&m.to==s.to)return{changes:l,range:c||m.map(l)};let g=m.to-h,O=g-u.length;if(m.to-m.from!=p||i.state.sliceDoc(O,g)!=u||m.to>=f.from&&m.from<=f.to)return{range:m};let w=r.changes({from:O,to:g,insert:e.insert}),S=m.to-s.to;return{changes:w,range:c?le.range(Math.max(0,c.anchor+S),Math.max(0,c.head+S)):m.map(w)}})}else n={changes:l,selection:c&&r.selection.replaceRange(c)}}let a="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,a+=".compose",i.inputState.compositionFirstChange&&(a+=".start",i.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:a,scrollIntoView:!0})}function aS(i,e,t,n){let r=Math.min(i.length,e.length),s=0;for(;s0&&a>0&&i.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(n=="end"){let l=Math.max(0,s-Math.min(o,a));t-=o+l-s}if(o=o?s-t:0;s-=l,a=s+(a-o),o=s}else if(a=a?s-t:0;s-=l,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function EQ(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new Ad(t,n)),(r!=t||s!=n)&&e.push(new Ad(r,s))),e}function TQ(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?le.single(t+e,n+e):null}var v0=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,xe.safari&&e.contentDOM.addEventListener("input",()=>null),xe.gecko&&BQ(e.contentDOM.ownerDocument)}handleEvent(e){!NQ(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let r of n.observers)r(this.view,t);for(let r of n.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=AQ(e),n=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,a=n[s];a&&o!=!a.handlers.length&&(r.removeEventListener(s,this.handleEvent),a=null),a||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&cS.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),xe.android&&xe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return xe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=lS.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||DQ.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:xe.safari&&!xe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Kk(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(r){Ti(t.state,r)}}}function AQ(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let r=n.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let a in s){let l=s[a];l&&t(a).handlers.push(Kk(n.value,l))}if(o)for(let a in o){let l=o[a];l&&t(a).observers.push(Kk(n.value,l))}}for(let n in mr)t(n).handlers.push(mr[n]);for(let n in Ln)t(n).observers.push(Ln[n]);return e}var lS=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],DQ="dthko",cS=[16,17,18,20,91,92,224,225],hd=6;function pd(i){return Math.max(0,i)*.7+8}function QQ(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}var y0=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=V8(e.contentDOM),this.atoms=e.state.facet(Ic).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(At.allowMultipleSelections)&&RQ(e,t),this.dragging=IQ(e,t)&&dS(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&QQ(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,s=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=V0(this.view);e.clientX-l.left<=r+hd?t=-pd(r-e.clientX):e.clientX+l.right>=o-hd&&(t=pd(e.clientX-o)),e.clientY-l.top<=s+hd?n=-pd(s-e.clientY):e.clientY+l.bottom>=a-hd&&(n=pd(e.clientY-a)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=sS(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function RQ(i,e){let t=i.state.facet($2);return t.length?t[0](e):xe.mac?e.metaKey:e.ctrlKey}function MQ(i,e){let t=i.state.facet(F2);return t.length?t[0](e):xe.mac?!e.altKey:!e.ctrlKey}function IQ(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=xc(i.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function NQ(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=Qt.get(t))&&n.ignoreEvent(e))return!1;return!0}var mr=Object.create(null),Ln=Object.create(null),uS=xe.ie&&xe.ie_version<15||xe.ios&&xe.webkit_version<604;function jQ(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),fS(i,t.value)},50)}function $d(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function fS(i,e){e=$d(i.state,$0,e);let{state:t}=i,n,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(b0!=null&&t.selection.ranges.every(l=>l.empty)&&b0==s.toString()){let l=-1;n=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:f},range:le.cursor(c.from+f.length)}})}else o?n=t.changeByRange(l=>{let c=s.line(r++);return{changes:{from:l.from,to:l.to,insert:c.text},range:le.cursor(l.from+c.length)}}):n=t.replaceSelection(s);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Ln.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};mr.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);Ln.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};Ln.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};mr.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(B2))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=qQ(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new y0(i,e,t,n)),n&&i.observer.ignore(()=>{P2(i.contentDOM);let s=i.root.activeElement;s&&!s.contains(i.contentDOM)&&s.blur()});let r=i.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else i.inputState.setSelectionOrigin("select.pointer");return!1};function Jk(i,e,t,n){if(n==1)return le.cursor(e,t);if(n==2)return OQ(i.state,e,t);{let r=Ei.find(i.docView,e),s=i.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,a=r?r.posAtEnd:s.to;return ae>=t.top&&e<=t.bottom&&i>=t.left&&i<=t.right;function ZQ(i,e,t,n){let r=Ei.find(i.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&e2(t,n,o))return-1;let a=r.coordsAt(s,1);return a&&e2(t,n,a)?1:o&&o.bottom>=n?-1:1}function t2(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:ZQ(i,t,e.clientX,e.clientY)}}var zQ=xe.ie&&xe.ie_version<=11,i2=null,n2=0,r2=0;function dS(i){if(!zQ)return i.detail;let e=i2,t=r2;return i2=i,r2=Date.now(),n2=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(n2+1)%3:1}function qQ(i,e){let t=t2(i,e),n=dS(e),r=i.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,a){let l=t2(i,s),c,u=Jk(i,l.pos,l.bias,n);if(t.pos!=l.pos&&!o){let f=Jk(i,t.pos,t.bias,n),d=Math.min(f.from,u.from),h=Math.max(f.to,u.to);u=d1&&(c=LQ(r,l.pos))?c:a?r.addRange(u):le.create([u])}}}function LQ(i,e){for(let t=0;t=e)return le.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}mr.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let r=i.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=le.range(s,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",$d(i.state,F0,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};mr.dragend=i=>(i.inputState.draggedContent=null,!1);function s2(i,e,t,n){if(t=$d(i.state,$0,t),!t)return;let r=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=i.inputState,o=n&&s&&MQ(i,e)?{from:s.from,to:s.to}:null,a={from:r,insert:t},l=i.state.changes(o?[o,a]:a);i.focus(),i.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}mr.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),r=0,s=()=>{++r==t.length&&s2(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(n[o]=a.result),s()},a.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return s2(i,e,n,!0),!0}return!1};mr.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=uS?null:e.clipboardData;return t?(fS(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(jQ(i),!1)};function $Q(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function FQ(i){let e=[],t=[],n=!1;for(let r of i.selection.ranges)r.empty||(e.push(i.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),r=o.number}n=!0}return{text:$d(i,F0,e.join(i.lineBreak)),ranges:t,linewise:n}}var b0=null;mr.copy=mr.cut=(i,e)=>{let{text:t,ranges:n,linewise:r}=FQ(i.state);if(!t&&!r)return!1;b0=r?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=uS?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):($Q(i,t),!1)};var hS=pn.define();function pS(i,e){let t=[];for(let n of i.facet(X2)){let r=n(i,e);r&&t.push(r)}return t.length?i.update({effects:t,annotations:hS.of(!0)}):null}function mS(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=pS(i.state,e);t?i.dispatch(t):i.update([])}},10)}Ln.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),mS(i)};Ln.blur=i=>{i.observer.clearSelectionRange(),mS(i)};Ln.compositionstart=Ln.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};Ln.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,xe.chrome&&xe.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};Ln.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};mr.beforeinput=(i,e)=>{var t,n;if(e.inputType=="insertReplacementText"&&i.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let a=o[0],l=i.posAtDOM(a.startContainer,a.startOffset),c=i.posAtDOM(a.endContainer,a.endOffset);return W0(i,{from:l,to:c,insert:i.state.toText(s)},null),!0}}let r;if(xe.chrome&&xe.android&&(r=lS.find(s=>s.inputType==e.inputType))&&(i.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return xe.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),xe.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>Ln.compositionend(i,e),20),!1};var o2=new Set;function BQ(i){o2.has(i)||(o2.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}var a2=["pre-wrap","normal","pre-line","break-spaces"],Ua=!1;function l2(){Ua=!1}var _0=class{constructor(e){this.lineWrapping=e,this.doc=rt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return a2.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=s,l){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>wd&&(Ua=!0),this.height=e)}replace(e,t,n){return i.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let s=this,o=n.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:f}=r[a],d=s.lineAt(l,qt.ByPosNoHeight,n.setDoc(t),0,0),h=d.to>=c?d:s.lineAt(c,qt.ByPosNoHeight,n,0,0);for(f+=h.to-c,c=h.to;a>0&&d.from<=r[a-1].toA;)l=r[a-1].fromA,u=r[a-1].fromB,a--,ls*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),n+=1+a.break,r-=a.size}else if(s>r*2){let a=e[n];a.break?e.splice(n,1,a.left,null,a.right):e.splice(n,1,a.left,a.right),n+=2+a.break,s-=a.size}else break;else if(r=s&&o(this.blockAt(0,n,r,s))}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},qn=class i extends Qd{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,r){return new qr(r,this.length,n,this.height,this.breaks)}replace(e,t,n){let r=n[0];return n.length==1&&(r instanceof i||r instanceof Ws&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Ws?r=new i(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Pn.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setHeight(r.heights[r.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},Ws=class i extends Pn{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-n+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*s);o=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:a}}blockAt(e,t,n,r){let{firstLine:s,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e0){let s=n[n.length-1];s instanceof i?n[n.length-1]=new i(s.length+r):n.push(null,new i(r-1))}if(e>0){let s=n[0];s instanceof i?n[0]=new i(e+s.length):n.unshift(new i(e-1),null)}return Pn.of(n)}decomposeLeft(e,t){t.push(new i(e-1),null)}decomposeRight(e,t){t.push(null,new i(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],a=Math.max(t,r.from),l=-1;for(r.from>t&&o.push(new i(r.from-t-1).updateHeight(e,t));a<=s&&r.more;){let u=e.doc.lineAt(a).length;o.length&&o.push(null);let f=r.heights[r.index++];l==-1?l=f:Math.abs(f-l)>=wd&&(l=-2);let d=new qn(u,f);d.outdated=!1,o.push(d),a+=u+1}a<=s&&o.push(null,new i(s-a).updateHeight(e,a));let c=Pn.of(o);return(l<0||Math.abs(c.height-this.height)>=wd||Math.abs(l-this.heightMetrics(e,t).perLine)>=wd)&&(Ua=!0),Dd(this,c)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},k0=class extends Pn{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let s=n+this.left.height;return ea))return c;let u=t==qt.ByPosNoHeight?qt.ByPosNoHeight:qt.ByPos;return l?c.join(this.right.lineAt(a,u,n,o,a)):this.left.lineAt(a,u,n,r,s).join(c)}forEachLine(e,t,n,r,s,o){let a=r+this.left.height,l=s+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,n,a,l,o);else{let c=this.lineAt(l,qt.ByPos,n,r,s);e=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,a,l,o)}}replace(e,t,n){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of n)s.push(a);if(e>0&&c2(s,o-1),t=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?Pn.of(this.break?[e,null,t]:[e,t]):(this.left=Dd(this.left,e),this.right=Dd(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:s,right:o}=this,a=t+s.length+this.break,l=null;return r&&r.from<=t+s.length&&r.more?l=s=s.updateHeight(e,t,n,r):s.updateHeight(e,t,n),r&&r.from<=a+o.length&&r.more?l=o=o.updateHeight(e,a,n,r):o.updateHeight(e,a,n),l?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function c2(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof Ws&&(n=i[e+1])instanceof Ws&&i.splice(e-1,3,new Ws(t.length+1+n.length))}var VQ=5,S0=class i{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof qn?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new qn(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=VQ)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new qn(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new Ws(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof qn)return e;let t=new qn(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof qn)&&!this.isCovered?this.nodes.push(new qn(0,-1)):(this.writtenTou.clientHeight||u.scrollWidth>u.clientWidth)&&f.overflow!="visible"){let d=u.getBoundingClientRect();s=Math.max(s,d.left),o=Math.min(o,d.right),a=Math.max(a,d.top),l=Math.min(c==i.parentNode?r.innerHeight:l,d.bottom)}c=f.position=="absolute"||f.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function UQ(i){let e=i.getBoundingClientRect(),t=i.ownerDocument.defaultView||window;return e.left0&&e.top0}function YQ(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Sc=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;ntypeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new _0(t),this.stateDeco=e.facet(Qc).filter(n=>typeof n!="function"),this.heightMap=Pn.empty().applyChanges(this.stateDeco,rt.empty,this.heightOracle.setDoc(e.doc),[new $r(0,0,0,e.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ne.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Va(s,o))}}return this.viewports=e.sort((n,r)=>n.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?u2:new C0(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Oc(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Qc).filter(u=>typeof u!="function");let r=e.changedRanges,s=$r.extendWithRanges(r,WQ(n,this.stateDeco,e?e.changes:Ui.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);l2(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Ua)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Y2)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?Ct.RTL:Ct.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,u=0;if(a.width&&a.height){let{scaleX:C,scaleY:k}=x2(t,a);(C>.005&&Math.abs(this.scaleX-C)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=C,this.scaleY=k,c|=16,o=l=!0)}let f=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=d)&&(this.paddingTop=f,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let h=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=h&&(this.scrollAnchorHeight=-1,this.scrollTop=h),this.scrolledToBottom=E2(e.scrollDOM);let p=(this.printing?YQ:XQ)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(l=!0)),!this.inView&&!this.scrollTarget&&!UQ(e.dom))return 0;let w=a.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let C=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(C)&&(o=!0),o||r.lineWrapping&&Math.abs(w-this.contentDOMWidth)>r.charWidth){let{lineHeight:k,charWidth:_,textHeight:P}=e.docView.measureTextSize();o=k>0&&r.refresh(s,k,_,P,Math.max(5,w/_),C),o&&(e.docView.minWidth=0,c|=16)}m>0&&g>0?u=Math.max(m,g):m<0&&g<0&&(u=Math.min(m,g)),l2();for(let k of this.viewports){let _=k.from==this.viewport.from?C:e.docView.measureVisibleLineHeights(k);this.heightMap=(o?Pn.empty().applyChanges(this.stateDeco,rt.empty,this.heightOracle,[new $r(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new w0(k.from,_))}Ua&&(c|=2)}let S=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return S&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||S)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new Va(r.lineAt(o-n*1e3,qt.ByHeight,s,0,0).from,r.lineAt(a+(1-n)*1e3,qt.ByHeight,s,0,0).to);if(t){let{head:c}=t.range;if(cl.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(c,qt.ByPos,s,0,0),d;t.y=="center"?d=(f.top+f.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c=a+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&s>1,o=r<<1;if(this.defaultTextDirection!=Ct.LTR&&!n)return[];let a=[],l=(u,f,d,h)=>{if(f-uu&&OO.from>=d.from&&O.to<=d.to&&Math.abs(O.from-u)O.fromw));if(!g){if(fS.from<=f&&S.to>=f)){let S=t.moveToLineBoundary(le.cursor(f),!1,!0).head;S>u&&(f=S)}let O=this.gapSize(d,u,f,h),w=n||O<2e6?O:2e6;g=new Sc(u,f,O,w)}a.push(g)},c=u=>{if(u.length2e6)for(let _ of e)_.from>=u.from&&_.fromu.from&&l(u.from,h,u,f),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];St.spans(t,this.viewport.from,this.viewport.to,{span(s,o){n.push({from:s,to:o})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Oc(this.heightMap.lineAt(e,qt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Oc(this.heightMap.lineAt(this.scaler.fromDOM(e),qt.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Oc(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Va=class{constructor(e,t){this.from=e,this.to=t}};function HQ(i,e,t){let n=[],r=i,s=0;return St.spans(t,i,e,{span(){},point(o,a){o>r&&(n.push({from:r,to:o}),s+=o-r),r=a}},20),r=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let r=0;;r++){let{from:s,to:o}=e[r],a=o-s;if(n<=a)return s+n;n-=a}}function gd(i,e){let t=0;for(let{from:n,to:r}of i.ranges){if(e<=r){t+=e-n;break}t+=r-n}return t/i.total}function GQ(i,e){for(let t of i)if(e(t))return t}var u2={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}},C0=class i{constructor(e,t,n){let r=0,s=0,o=0;this.viewports=n.map(({from:a,to:l})=>{let c=t.lineAt(a,qt.ByPos,e,0,0).top,u=t.lineAt(l,qt.ByPos,e,0,0).bottom;return r+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let s=tt.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}};function Oc(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new qr(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(r=>Oc(r,e)):i._content)}var Od=Ee.define({combine:i=>i.join(" ")}),E0=Ee.define({combine:i=>i.indexOf(!0)>-1}),T0=zn.newName(),gS=zn.newName(),OS=zn.newName(),vS={"&light":"."+gS,"&dark":"."+OS};function A0(i,e,t){return new zn(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return i;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):i+" "+n}})}var KQ=A0("."+T0,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},vS),JQ={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Jg=xe.ie&&xe.ie_version<=11,D0=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new a0,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(xe.ie&&xe.ie_version<=11||xe.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&xe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(xe.chrome&&xe.chrome_version<126)&&(this.editContext=new Q0(e),e.state.facet(vs)&&(e.contentDOM.editContext=this.editContext.editContext)),Jg&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(vs)?n.root.activeElement!=this.dom:!bd(this.dom,r))return;let s=r.anchorNode&&n.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(xe.ie&&xe.ie_version<=11||xe.android&&xe.chrome)&&!n.state.selection.main.empty&&r.focusNode&&yc(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=xc(e.root);if(!t)return!1;let n=xe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&eR(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=bd(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Xa(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&bd(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new O0(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=oS(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=f2(t,e.previousSibling||e.target.previousSibling,-1),r=f2(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(vs)!=e.state.facet(vs)&&(e.view.contentDOM.editContext=e.state.facet(vs)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function f2(i,e,t){for(;e;){let n=Qt.get(e);if(n&&n.parent==i)return n;let r=e.parentNode;e=r!=i.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function d2(i,e){let t=e.startContainer,n=e.startOffset,r=e.endContainer,s=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor);return yc(o.node,o.offset,r,s)&&([t,n,r,s]=[r,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}}function eR(i,e){if(e.getComposedRanges){let r=e.getComposedRanges(i.root)[0];if(r)return d2(i,r)}let t=null;function n(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?d2(i,t):null}var Q0=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:s,head:o}=r,a=this.toEditorPos(n.updateRangeStart),l=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:a,drifted:!1});let c=l-a>n.text.length;a==this.from&&sthis.to&&(l=s);let u=aS(e.state.sliceDoc(a,l),n.text,(c?r.from:r.to)-a,c?"end":null);if(!u){let d=le.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));d.main.eq(r)||e.dispatch({selection:d,userEvent:"select"});return}let f={from:u.from+a,to:u.toA+a,insert:rt.of(n.text.slice(u.from,u.toB).split(` `))};if((xe.mac||xe.android)&&f.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:a,to:l,insert:rt.of([n.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let d=this.to-this.from+(f.to-f.from+f.insert.length);W0(e,f,le.single(this.toEditorPos(n.selectionStart,d),this.toEditorPos(n.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],s=null;for(let o=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);o{let r=[];for(let s of n.getTextFormats()){let o=s.underlineStyle,a=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(a)){let l=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(l{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let r=xc(n.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,a,l,c)=>{if(n)return;let u=c.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=u,this.to+=u;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=u,this.to+=u;else if(sthis.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),c.toString()),this.to+=u}t+=u}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},_e=class i{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(r=>r.forEach(s=>n(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||W8(e.parent)||document,this.viewState=new Rd(e.state||At.create(e)),e.scrollTo&&e.scrollTo.is(dd)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ba).map(r=>new wc(r));for(let r of this.plugins)r.update(this);this.observer=new D0(this),this.inputState=new v0(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Td(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof gi?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,r,s=this.state;for(let d of e){if(d.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=d.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,l=null;e.some(d=>d.annotation(hS))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=pS(s,o),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(At.phrases)!=this.state.facet(At.phrases))return this.setState(s);r=Ed.create(this,s,e),r.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(f&&(f=f.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection;f=new _c(h.empty?h:le.cursor(h.head,h.head>h.anchor?-1:1))}for(let h of d.effects)h.is(dd)&&(f=h.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Md.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(mc)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Od)!=r.state.facet(Od)&&(this.viewState.mustMeasureContent=!0),(t||n||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let d of this.state.facet(h0))try{d(r)}catch(h){Ti(this.state,h,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!oS(this,u)&&c.force&&Xa(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new Rd(e),this.plugins=e.facet(Ba).map(n=>new wc(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new Td(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ba),n=e.state.facet(Ba);if(t!=n){let r=[];for(let s of n){let o=t.indexOf(s);if(o<0)r.push(new wc(s));else{let a=this.plugins[o];a.mustUpdate=e,r.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(E2(n))s=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(r);s=h.from,o=h.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(h=>{try{return h.read(this)}catch(p){return Ti(this.state,p),h2}}),f=Ed.create(this,this.state,[]),d=!1;f.flags|=l,t?t.flags|=l:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),d=this.docView.update(f),d&&this.docViewUpdate());for(let h=0;h1||p<-1){r=r+p,n.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(h0))a(t)}get themeClasses(){return T0+" "+(this.state.facet(E0)?OS:gS)+" "+this.state.facet(Od)}updateAttrs(){let e=p2(this,K2,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(vs)?"true":"false",class:"cm-content",style:`${xe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),p2(this,B0,t);let n=this.observer.ignore(()=>{let r=c0(this.contentDOM,this.contentAttrs,t),s=c0(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let r of n.effects)if(r.is(i.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(mc);let e=this.state.facet(i.cspNonce);zn.mount(this.root,this.styleModules.concat(KQ).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;tn.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Kg(this,e,Gk(this,e,t,n))}moveByGroup(e,t){return Kg(this,e,Gk(this,e,t,n=>kQ(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=n[t?n.length-1:0];return le.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return wQ(this,e,t,n)}moveVertically(e,t,n){return Kg(this,e,SQ(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),nS(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Lr.find(s,e-r.from,-1,t)];return Ld(n,o.dir==Ct.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(U2)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>tR)return q2(e.length);let t=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||z2(s.isolates,n=Wk(this,e))))return s.order;n||(n=Wk(this,e));let r=oQ(e.text,t,n);return this.bidiCache.push(new Md(e.from,e.to,t,n,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||xe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{P2(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return dd.of(new _c(typeof e=="number"?le.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return dd.of(new _c(le.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return di.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return di.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=zn.newName(),r=[Od.of(n),mc.of(A0(`.${n}`,e))];return t&&t.dark&&r.push(E0.of(!0)),r}static baseTheme(e){return hr.lowest(mc.of(A0("."+T0,e,vS)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&Qt.get(n)||Qt.get(e);return((t=r?.rootView)===null||t===void 0?void 0:t.view)||null}};_e.styleModule=mc;_e.inputHandler=W2;_e.clipboardInputFilter=$0;_e.clipboardOutputFilter=F0;_e.scrollHandler=H2;_e.focusChangeEffect=X2;_e.perLineTextDirection=U2;_e.exceptionSink=V2;_e.updateListener=h0;_e.editable=vs;_e.mouseSelectionStyle=B2;_e.dragMovesSelection=F2;_e.clickAddsSelectionRange=$2;_e.decorations=Qc;_e.outerDecorations=J2;_e.atomicRanges=Ic;_e.bidiIsolatedRanges=eS;_e.scrollMargins=tS;_e.darkTheme=E0;_e.cspNonce=Ee.define({combine:i=>i.length?i[0]:""});_e.contentAttributes=B0;_e.editorAttributes=K2;_e.lineWrapping=_e.contentAttributes.of({class:"cm-lineWrapping"});_e.announce=Ze.define();var tR=4096,h2={},Md=class i{constructor(e,t,n,r,s,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:Ct.LTR;for(let s=Math.max(0,e.length-10);s=0;r--){let s=n[r],o=typeof s=="function"?s(i):s;o&&l0(o,t)}return t}var iR=xe.mac?"mac":xe.windows?"win":xe.linux?"linux":"key";function nR(i,e){let t=i.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,o,a;for(let l=0;ln.concat(r),[]))),t}function bS(i,e,t){return _S(yS(i.state),e,i,t)}var Vs=null,sR=4e3;function oR(i,e=iR){let t=Object.create(null),n=Object.create(null),r=(o,a)=>{let l=n[o];if(l==null)n[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,l,c,u)=>{var f,d;let h=t[o]||(t[o]=Object.create(null)),p=a.split(/ (?!$)/).map(O=>nR(O,e));for(let O=1;O{let C=Vs={view:S,prefix:w,scope:o};return setTimeout(()=>{Vs==C&&(Vs=null)},sR),!0}]})}let m=p.join(" ");r(m,!1);let g=h[m]||(h[m]={preventDefault:!1,stopPropagation:!1,run:((d=(f=h._any)===null||f===void 0?void 0:f.run)===null||d===void 0?void 0:d.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),u&&(g.stopPropagation=!0)};for(let o of i){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let d in u)u[d].run.push(h=>f(h,R0))}let l=o[e]||o.key;if(l)for(let c of a)s(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}var R0=null;function _S(i,e,t,n){R0=e;let r=jk(e),s=Zi(r,0),o=xn(s)==r.length&&r!=" ",a="",l=!1,c=!1,u=!1;Vs&&Vs.view==t&&Vs.scope==n&&(a=Vs.prefix+" ",cS.indexOf(e.keyCode)<0&&(c=!0,Vs=null));let f=new Set,d=g=>{if(g){for(let O of g.run)if(!f.has(O)&&(f.add(O),O(t)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},h=i[n],p,m;return h&&(d(h[a+vd(r,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(xe.windows&&e.ctrlKey&&e.altKey)&&!(xe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Os[e.keyCode])&&p!=r?(d(h[a+vd(p,e,!0)])||e.shiftKey&&(m=Fa[e.keyCode])!=r&&m!=p&&d(h[a+vd(m,e,!1)]))&&(l=!0):o&&e.shiftKey&&d(h[a+vd(r,e,!0)])&&(l=!0),!l&&d(h._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),R0=null,l}var Rc=class i{constructor(e,t,n,r,s){this.className=e,this.left=t,this.top=n,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=wS(e);return[new i(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return aR(e,t,n)}};function wS(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==Ct.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function g2(i,e,t,n){let r=i.coordsAtPos(e,t*2);if(!r)return n;let s=i.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,a=i.posAtCoords({x:s.left+1,y:o}),l=i.posAtCoords({x:s.right-1,y:o});return a==null||l==null?n:{from:Math.max(n.from,Math.min(a,l)),to:Math.min(n.to,Math.max(a,l))}}function aR(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),r=Math.min(t.to,i.viewport.to),s=i.textDirection==Ct.LTR,o=i.contentDOM,a=o.getBoundingClientRect(),l=wS(i),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),f=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),d=a.right-(u?parseInt(u.paddingRight):0),h=m0(i,n,1),p=m0(i,r,-1),m=h.type==Gi.Text?h:null,g=p.type==Gi.Text?p:null;if(m&&(i.lineWrapping||h.widgetLineBreaks)&&(m=g2(i,n,1,m)),g&&(i.lineWrapping||p.widgetLineBreaks)&&(g=g2(i,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return w(S(t.from,t.to,m));{let k=m?S(t.from,null,m):C(h,!1),_=g?S(null,t.to,g):C(p,!0),P=[];return(m||h).to<(g||p).from-(m&&g?1:0)||h.widgetLineBreaks>1&&k.bottom+i.defaultLineHeight/2<_.top?P.push(O(f,k.bottom,d,_.top)):k.bottom<_.top&&i.elementAtHeight((k.bottom+_.top)/2).type==Gi.Text&&(k.bottom=_.top=(k.bottom+_.top)/2),w(k).concat(P).concat(w(_))}function O(k,_,P,x){return new Rc(e,k-l.left,_-l.top,P-k,x-_)}function w({top:k,bottom:_,horizontal:P}){let x=[];for(let R=0;RD&&j.from=q)break;Pe>z&&Q(Math.max(ce,z),k==null&&ce<=D,Math.min(Pe,q),_==null&&Pe>=E,Y.dir)}if(z=G.to+1,z>=q)break}return Z.length==0&&Q(D,k==null,E,_==null,i.textDirection),{top:x,bottom:R,horizontal:Z}}function C(k,_){let P=a.top+(_?k.top:k.bottom);return{top:P,bottom:P,horizontal:[]}}}function lR(i,e){return i.constructor==e.constructor&&i.eq(e)}var M0=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(kd)!=e.state.facet(kd)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(kd);for(;t!lR(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,xe.safari&&xe.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},kd=Ee.define();function kS(i){return[di.define(e=>new M0(e,i)),kd.of(i)]}var Mc=Ee.define({combine(i){return mn(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function SS(i={}){return[Mc.of(i),cR,uR,fR,Y2.of(!0)]}function xS(i){return i.startState.facet(Mc)!=i.state.facet(Mc)}var cR=kS({above:!0,markers(i){let{state:e}=i,t=e.facet(Mc),n=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=r.empty?r:le.cursor(r.head,r.head>r.anchor?-1:1);for(let l of Rc.forRange(i,o,a))n.push(l)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=xS(i);return t&&O2(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){O2(e.state,i)},class:"cm-cursorLayer"});function O2(i,e){e.style.animationDuration=i.facet(Mc).cursorBlinkRate+"ms"}var uR=kS({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:Rc.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||xS(i)},class:"cm-selectionLayer"}),fR=hr.highest(_e.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),PS=Ze.define({map(i,e){return i==null?null:e.mapPos(i)}}),vc=Xt.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(PS)?n.value:t,i)}}),dR=di.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(vc);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(vc)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(vc),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(vc)!=i&&this.view.dispatch({effects:PS.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function CS(){return[vc,dR]}var _K=/x/.unicode!=null?"gu":"g";var I0=2e3;function hR(i,e,t){let n=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>I0||t.off>I0||e.col<0||t.col<0){let o=Math.min(e.off,t.off),a=Math.max(e.off,t.off);for(let l=n;l<=r;l++){let c=i.doc.line(l);c.length<=a&&s.push(le.range(c.from+o,c.to+a))}}else{let o=Math.min(e.col,t.col),a=Math.max(e.col,t.col);for(let l=n;l<=r;l++){let c=i.doc.line(l),u=cd(c.text,o,i.tabSize,!0);if(u<0)s.push(le.cursor(c.to));else{let f=cd(c.text,a,i.tabSize);s.push(le.range(c.from+u,c.from+f))}}}return s}function pR(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function v2(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),r=t-n.from,s=r>I0?-1:r==n.length?pR(i,e.clientX):Bs(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:s,off:r}}function mR(i,e){let t=v2(i,e),n=i.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(r.changes)}},get(r,s,o){let a=v2(i,r);if(!a)return n;let l=hR(i.state,t,a);return l.length?o?le.create(l.concat(n.ranges)):le.create(l):n}}:null}function ES(i){let e=i?.eventFilter||(t=>t.altKey&&t.button==0);return _e.mouseSelectionStyle.of((t,n)=>e(n)?mR(t,n):null)}var pc="-10000px",Id=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=n(o,s))}update(e,t){var n;let r=e.state.facet(this.facet),s=r.filter(l=>l);if(r===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=t?[]:null;for(let l=0;lt[c]=l),t.length=a.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}};function gR(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var e0=Ee.define({combine:i=>{var e,t,n;return{position:xe.ios?"absolute":((e=i.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(r=>r.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||gR}}}),y2=new WeakMap,X0=di.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(e0);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Id(i,jc,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(e0);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=pc,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(xe.gecko)t=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==pc&&s.style.left=="0px"){let o=s.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(t||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(i=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),r=V0(this.view);return{visible:{left:n.left+r.left,top:n.top+r.top,right:n.right-r.right,bottom:n.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let a=this.manager.tooltipViews[o];return a.getCoords?a.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(e0).tooltipSpace(this.view),scaleX:i,scaleY:e,makeAbsolute:t}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:t,space:n,scaleX:r,scaleY:s}=i,o=[];for(let a=0;a=Math.min(t.bottom,n.bottom)||f.rightMath.min(t.right,n.right)+.1)){u.style.top=pc;continue}let h=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,m=d.right-d.left,g=(e=y2.get(c))!==null&&e!==void 0?e:d.bottom-d.top,O=c.offset||vR,w=this.view.textDirection==Ct.LTR,S=d.width>n.right-n.left?w?n.left:n.right-d.width:w?Math.max(n.left,Math.min(f.left-(h?14:0)+O.x,n.right-m)):Math.min(Math.max(n.left,f.left-m+(h?14:0)-O.x),n.right-m),C=this.above[a];!l.strictSide&&(C?f.top-g-p-O.yn.bottom)&&C==n.bottom-f.bottom>f.top-n.top&&(C=this.above[a]=!C);let k=(C?f.top-n.top:n.bottom-f.bottom)-p;if(kS&&x.top<_+g&&x.bottom>_&&(_=C?x.top-g-2-p:x.bottom+p+2);if(this.position=="absolute"?(u.style.top=(_-i.parent.top)/s+"px",b2(u,(S-i.parent.left)/r)):(u.style.top=_/s+"px",b2(u,S/r)),h){let x=f.left+(w?O.x:-O.x)-(S+14-7);h.style.left=x/r+"px"}c.overlap!==!0&&o.push({left:S,top:_,right:P,bottom:_+g}),u.classList.toggle("cm-tooltip-above",C),u.classList.toggle("cm-tooltip-below",!C),c.positioned&&c.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=pc}},{eventObservers:{scroll(){this.maybeMeasure()}}});function b2(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}var OR=_e.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),vR={x:0,y:0},jc=Ee.define({enables:[X0,OR]}),Nd=Ee.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])}),jd=class i{static create(e){return new i(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Id(e,Nd,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},yR=jc.compute([Nd],i=>{let e=i.facet(Nd);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:jd.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),N0=class{constructor(e,t,n,r,s){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(u=>u.from<=r&&u.to>=r),c=l&&l.dir==Ct.RTL?-1:1;s=t.x{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Ti(e.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(X0),t=e?e.manager.tooltips.findIndex(n=>n.create==jd.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&s&&!bR(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,a=(n=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!_R(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},yd=4;function bR(i,e){let{left:t,right:n,top:r,bottom:s}=i.getBoundingClientRect(),o;if(o=i.querySelector(".cm-tooltip-arrow")){let a=o.getBoundingClientRect();r=Math.min(a.top,r),s=Math.max(a.bottom,s)}return e.clientX>=t-yd&&e.clientX<=n+yd&&e.clientY>=r-yd&&e.clientY<=s+yd}function _R(i,e,t,n,r,s){let o=i.scrollDOM.getBoundingClientRect(),a=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.rightr||Math.min(o.bottom,a)=e&&l<=t}function TS(i,e={}){let t=Ze.define(),n=Xt.define({create(){return[]},update(r,s){if(r.length&&(e.hideOnChange&&(s.docChanged||s.selection)?r=[]:e.hideOn&&(r=r.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let a of r){let l=s.changes.mapPos(a.pos,-1,Ci.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),a);c.pos=l,c.end!=null&&(c.end=s.changes.mapPos(c.end)),o.push(c)}}r=o}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(wR)&&(r=[]);return r},provide:r=>Nd.from(r)});return{active:n,extension:[n,di.define(r=>new N0(r,i,n,t,e.hoverTime||300)),yR]}}function U0(i,e){let t=i.plugin(X0);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}var wR=Ze.define();var _2=Ee.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Bo(i,e){let t=i.plugin(AS),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}var AS=di.fromClass(class{constructor(i){this.input=i.state.facet(Fo),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(_2);this.top=new Wa(i,!0,e.topContainer),this.bottom=new Wa(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(_2);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Wa(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Wa(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Fo);if(t!=this.input){let n=t.filter(l=>l),r=[],s=[],o=[],a=[];for(let l of n){let c=this.specs.indexOf(l),u;c<0?(u=l(i.view),a.push(u)):(u=this.panels[c],u.update&&u.update(i)),r.push(u),(u.top?s:o).push(u)}this.specs=n,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>_e.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Wa=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=w2(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=w2(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function w2(i){let e=i.nextSibling;return i.remove(),e}var Fo=Ee.define({enables:AS});var gr=class extends dr{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};gr.prototype.elementClass="";gr.prototype.toDOM=void 0;gr.prototype.mapMode=Ci.TrackBefore;gr.prototype.startSide=gr.prototype.endSide=-1;gr.prototype.point=!0;var t0=Ee.define(),kR=Ee.define(),SR={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>St.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Sd=Ee.define();function Y0(i){return[xR(),Sd.of({...SR,...i})]}var j0=Ee.define({combine:i=>i.some(e=>e)});function xR(i){let e=[PR];return i&&i.fixed===!1&&e.push(j0.of(!0)),e}var PR=di.fromClass(class{constructor(i){this.view=i,this.domAfter=null,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(Sd).map(e=>new Zd(i,e)),this.fixed=!i.state.facet(j0);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}if(i.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(j0)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=St.iter(this.view.state.facet(t0),this.view.viewport.from),n=[],r=this.gutters.map(s=>new z0(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==Gi.Text&&o){Z0(t,n,a.from);for(let l of r)l.line(this.view,a,n);o=!1}else if(a.widget)for(let l of r)l.widget(this.view,a)}else if(s.type==Gi.Text){Z0(t,n,s.from);for(let o of r)o.line(this.view,s,n)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();i&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(i){let e=i.startState.facet(Sd),t=i.state.facet(Sd),n=i.docChanged||i.heightChanged||i.viewportChanged||!St.eq(i.startState.facet(t0),i.state.facet(t0),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(i)&&(n=!0);else{n=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Zd(this.view,s)):(this.gutters[o].update(i),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i=>_e.scrollMargins.of(e=>{let t=e.plugin(i);if(!t||t.gutters.length==0||!t.fixed)return null;let n=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Ct.LTR?{left:n,right:r}:{right:n,left:r}})});function k2(i){return Array.isArray(i)?i:[i]}function Z0(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}var z0=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=St.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let a=new zd(e,o,s,n);r.elements.push(a),r.dom.appendChild(a.dom)}else r.elements[this.i].update(e,o,s,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];Z0(this.cursor,r,t.from),n.length&&(r=r.concat(n));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let s of e.state.facet(kR)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Zd=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=r.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,a,r)&&r.preventDefault()});this.markers=k2(t.markers(e)),t.initialSpacer&&(this.spacer=new zd(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=k2(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let n=e.view.viewport;return!St.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},zd=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),CR(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let a=o,l=s{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=zi.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};qe.closedBy=new qe({deserialize:i=>i.split(" ")});qe.openedBy=new qe({deserialize:i=>i.split(" ")});qe.group=new qe({deserialize:i=>i.split(" ")});qe.isolate=new qe({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});qe.contextHash=new qe({perNode:!0});qe.lookAhead=new qe({perNode:!0});qe.mounted=new qe({perNode:!0});var Ya=class{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[qe.mounted.id]}},TR=Object.create(null),zi=class i{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):TR,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new i(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(qe.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return n=>{for(let r=n.prop(qe.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}};zi.none=new zi("",Object.create(null),0,8);var zc=class i{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|ni.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=r&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&n&&(a||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:i1(zi.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new i(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new i(zi.none,t,n,r)))}static build(e){return DR(e)}};ri.empty=new ri(zi.none,[],[],0);var H0=class i{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new i(this.buffer,this.index)}},Hs=class i{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return zi.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function qc(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?a.length:-1;e!=c;e+=t){let u=a[e],f=l[e]+o.from;if(MS(r,n,f,f+u.length)){if(u instanceof Hs){if(s&ni.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,t,n-f,r);if(d>-1)return new Lc(new K0(o,u,e,f),null,d)}else if(s&ni.IncludeAnonymous||!u.type.isAnonymous||t1(u)){let d;if(!(s&ni.IgnoreMounts)&&(d=Ya.get(u))&&!d.overlay)return new i(d.tree,f,e,o);let h=new i(u,f,e,o);return s&ni.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(t<0?u.children.length-1:0,t,n,r)}}}if(s&ni.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let r;if(!(n&ni.IgnoreOverlays)&&(r=Ya.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:a}of r.overlay)if((t>0?o<=s:o=s:a>s))return new i(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function QS(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function G0(i,e,t=e.length-1){for(let n=i.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}var K0=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Lc=class i extends Vd{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new i(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&ni.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new i(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new i(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new i(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new ri(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function IS(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;st.from||o.to=e){let a=new Vr(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(qc(a,e,t,!1))}}return r?IS(r):n}var $c=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Vr)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Vr?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&ni.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ni.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ni.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let a=n._tree.children[s];if(this.mode&ni.IncludeAnonymous||a instanceof Hs||!a.type.isAnonymous||t1(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r=0;s--){if(s<0)return G0(this.node,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function t1(i){return i.children.some(e=>e instanceof Hs||!e.type.isAnonymous||t1(e))}function DR(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=n.types.length}=i,a=Array.isArray(t)?new H0(t,t.length):t,l=n.types,c=0,u=0;function f(k,_,P,x,R,Z){let{id:Q,start:D,end:E,size:j}=a,z=u;for(;j<0;)if(a.next(),j==-1){let Pe=s[Q];P.push(Pe),x.push(D-k);return}else if(j==-3){c=Q;return}else if(j==-4){u=Q;return}else throw new RangeError(`Unrecognized record size: ${j}`);let q=l[Q],G,Y,ce=D-k;if(E-D<=r&&(Y=g(a.pos-_,R))){let Pe=new Uint16Array(Y.size-Y.skip),ue=a.pos-Y.size,B=Pe.length;for(;a.pos>ue;)B=O(Y.start,Pe,B);G=new Hs(Pe,E-Y.start,n),ce=Y.start-k}else{let Pe=a.pos-j;a.next();let ue=[],B=[],ee=Q>=o?Q:-1,pe=0,Re=E;for(;a.pos>Pe;)ee>=0&&a.id==ee&&a.size>=0?(a.end<=Re-r&&(p(ue,B,D,pe,a.end,Re,ee,z),pe=ue.length,Re=a.end),a.next()):Z>2500?d(D,Pe,ue,B):f(D,Pe,ue,B,ee,Z+1);if(ee>=0&&pe>0&&pe-1&&pe>0){let oe=h(q);G=i1(q,ue,B,0,ue.length,0,E-D,oe,oe)}else G=m(q,ue,B,E-D,z-E)}P.push(G),x.push(ce)}function d(k,_,P,x){let R=[],Z=0,Q=-1;for(;a.pos>_;){let{id:D,start:E,end:j,size:z}=a;if(z>4)a.next();else{if(Q>-1&&E=0;j-=3)D[z++]=R[j],D[z++]=R[j+1]-E,D[z++]=R[j+2]-E,D[z++]=z;P.push(new Hs(D,R[2]-E,n)),x.push(E-k)}}function h(k){return(_,P,x)=>{let R=0,Z=_.length-1,Q,D;if(Z>=0&&(Q=_[Z])instanceof ri){if(!Z&&Q.type==k&&Q.length==x)return Q;(D=Q.prop(qe.lookAhead))&&(R=P[Z]+Q.length+D)}return m(k,_,P,x,R)}}function p(k,_,P,x,R,Z,Q,D){let E=[],j=[];for(;k.length>x;)E.push(k.pop()),j.push(_.pop()+P-R);k.push(m(n.types[Q],E,j,Z-R,D-Z)),_.push(R-P)}function m(k,_,P,x,R=0,Z){if(c){let Q=[qe.contextHash,c];Z=Z?[Q].concat(Z):[Q]}if(R>25){let Q=[qe.lookAhead,R];Z=Z?[Q].concat(Z):[Q]}return new ri(k,_,P,x,Z)}function g(k,_){let P=a.fork(),x=0,R=0,Z=0,Q=P.end-r,D={size:0,start:0,skip:0};e:for(let E=P.pos-k;P.pos>E;){let j=P.size;if(P.id==_&&j>=0){D.size=x,D.start=R,D.skip=Z,Z+=4,x+=4,P.next();continue}let z=P.pos-j;if(j<0||z=o?4:0,G=P.start;for(P.next();P.pos>z;){if(P.size<0)if(P.size==-3)q+=4;else break e;else P.id>=o&&(q+=4);P.next()}R=G,x+=j,Z+=q}return(_<0||x==k)&&(D.size=x,D.start=R,D.skip=Z),D.size>4?D:void 0}function O(k,_,P){let{id:x,start:R,end:Z,size:Q}=a;if(a.next(),Q>=0&&x4){let E=a.pos-(Q-4);for(;a.pos>E;)P=O(k,_,P)}_[--P]=D,_[--P]=Z-k,_[--P]=R-k,_[--P]=x}else Q==-3?c=x:Q==-4&&(u=x);return P}let w=[],S=[];for(;a.pos>0;)f(i.start||0,i.bufferStart||0,w,S,-1,0);let C=(e=i.length)!==null&&e!==void 0?e:w.length?S[0]+w[0].length:0;return new ri(l[i.topID],w.reverse(),S.reverse(),C)}var RS=new WeakMap;function Bd(i,e){if(!i.isAnonymous||e instanceof Hs||e.type!=i)return 1;let t=RS.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof ri)){t=1;break}t+=Bd(i,n)}RS.set(e,t)}return t}function i1(i,e,t,n,r,s,o,a,l){let c=0;for(let p=n;p=u)break;_+=P}if(S==C+1){if(_>u){let P=p[C];h(P.children,P.positions,0,P.children.length,m[C]+w);continue}f.push(p[C])}else{let P=m[S-1]+p[S-1].length-k;f.push(i1(i,p,m,C,S,k,P,null,l))}d.push(k+w-s)}}return h(e,t,n,r,0),(a||l)(f,d,o)}var Vo=class i{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new i(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a=n)for(;o&&o.from=d.from||f<=d.to||c){let h=Math.max(d.from,l)-c,p=Math.min(d.to,f)-c;d=h>=p?null:new i(h,p,d.tree,d.offset+c,a>0,!!u)}if(d&&r.push(d),o.to>f)break;o=snew Zc(r.from,r.to)):[new Zc(0,0)]:[new Zc(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}},e1=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var CK=new qe({perNode:!0});var QR=0,Yr=class i{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=QR++}static define(e){if(e?.base)throw new Error("Can not derive from a modified tag");let t=new i([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new Yd;return t=>t.modified.indexOf(e)>-1?t:Yd.get(t.base||t,t.modified.concat(e).sort((n,r)=>n.id-r.id))}},RR=0,Yd=class i{constructor(){this.instances=[],this.id=RR++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(a=>a.base==e&&MR(t,a.modified));if(n)return n;let r=[],s=new Yr(r,e,t);for(let a of t)a.instances.push(s);let o=IR(t);for(let a of e.set)if(!a.modified.length)for(let l of o)r.push(i.get(a,l));return s}};function MR(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function IR(i){let e=[[]];for(let t=0;tn.length-t.length)}function Hd(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,a=r;for(let f=0;;){if(a=="..."&&f>0&&f+3==r.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!d)throw new RangeError("Invalid path: "+r);if(s.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),f+=d[0].length,f==r.length)break;let h=r[f++];if(f==r.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+r);a=r.slice(f)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+r);let u=new Ga(n,o,l>0?s.slice(0,l):null);e[c]=u.sort(e[c])}}return ZS.add(e)}var ZS=new qe,Ga=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=r;for(let a of s)for(let l of a.set){let c=t[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:n}}function NR(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function zS(i,e,t,n=0,r=i.length){let s=new r1(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}var r1=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,s){let{type:o,from:a,to:l}=e;if(a>=n||l<=t)return;o.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(o)));let c=r,u=jR(e)||Ga.empty,f=NR(s,u.tags);if(f&&(c&&(c+=" "),c+=f,u.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,a),c),u.opaque)return;let d=e.tree&&e.tree.prop(qe.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+a,1),p=this.highlighters.filter(g=>!g.scope||g.scope(d.tree.type)),m=e.firstChild();for(let g=0,O=a;;g++){let w=g=S||!e.nextSibling())););if(!w||S>n)break;O=w.to+a,O>t&&(this.highlightRange(h.cursor(),Math.max(t,w.from+a),Math.min(n,O),"",p),this.startSpan(Math.min(n,O),c))}m&&e.parent()}else if(e.firstChild()){d&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function jR(i){let e=i.type.prop(ZS);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}var we=Yr.define,Wd=we(),Gs=we(),NS=we(Gs),jS=we(Gs),Ks=we(),Xd=we(Ks),n1=we(Ks),Ur=we(),Wo=we(Ur),Wr=we(),Xr=we(),s1=we(),Fc=we(s1),Ud=we(),L={comment:Wd,lineComment:we(Wd),blockComment:we(Wd),docComment:we(Wd),name:Gs,variableName:we(Gs),typeName:NS,tagName:we(NS),propertyName:jS,attributeName:we(jS),className:we(Gs),labelName:we(Gs),namespace:we(Gs),macroName:we(Gs),literal:Ks,string:Xd,docString:we(Xd),character:we(Xd),attributeValue:we(Xd),number:n1,integer:we(n1),float:we(n1),bool:we(Ks),regexp:we(Ks),escape:we(Ks),color:we(Ks),url:we(Ks),keyword:Wr,self:we(Wr),null:we(Wr),atom:we(Wr),unit:we(Wr),modifier:we(Wr),operatorKeyword:we(Wr),controlKeyword:we(Wr),definitionKeyword:we(Wr),moduleKeyword:we(Wr),operator:Xr,derefOperator:we(Xr),arithmeticOperator:we(Xr),logicOperator:we(Xr),bitwiseOperator:we(Xr),compareOperator:we(Xr),updateOperator:we(Xr),definitionOperator:we(Xr),typeOperator:we(Xr),controlOperator:we(Xr),punctuation:s1,separator:we(s1),bracket:Fc,angleBracket:we(Fc),squareBracket:we(Fc),paren:we(Fc),brace:we(Fc),content:Ur,heading:Wo,heading1:we(Wo),heading2:we(Wo),heading3:we(Wo),heading4:we(Wo),heading5:we(Wo),heading6:we(Wo),contentSeparator:we(Ur),list:we(Ur),quote:we(Ur),emphasis:we(Ur),strong:we(Ur),link:we(Ur),monospace:we(Ur),strikethrough:we(Ur),inserted:we(),deleted:we(),changed:we(),invalid:we(),meta:Ud,documentMeta:we(Ud),annotation:we(Ud),processingInstruction:we(Ud),definition:Yr.defineModifier(),constant:Yr.defineModifier(),function:Yr.defineModifier(),standard:Yr.defineModifier(),local:Yr.defineModifier(),special:Yr.defineModifier()},AK=o1([{tag:L.link,class:"tok-link"},{tag:L.heading,class:"tok-heading"},{tag:L.emphasis,class:"tok-emphasis"},{tag:L.strong,class:"tok-strong"},{tag:L.keyword,class:"tok-keyword"},{tag:L.atom,class:"tok-atom"},{tag:L.bool,class:"tok-bool"},{tag:L.url,class:"tok-url"},{tag:L.labelName,class:"tok-labelName"},{tag:L.inserted,class:"tok-inserted"},{tag:L.deleted,class:"tok-deleted"},{tag:L.literal,class:"tok-literal"},{tag:L.string,class:"tok-string"},{tag:L.number,class:"tok-number"},{tag:[L.regexp,L.escape,L.special(L.string)],class:"tok-string2"},{tag:L.variableName,class:"tok-variableName"},{tag:L.local(L.variableName),class:"tok-variableName tok-local"},{tag:L.definition(L.variableName),class:"tok-variableName tok-definition"},{tag:L.special(L.variableName),class:"tok-variableName2"},{tag:L.definition(L.propertyName),class:"tok-propertyName tok-definition"},{tag:L.typeName,class:"tok-typeName"},{tag:L.namespace,class:"tok-namespace"},{tag:L.className,class:"tok-className"},{tag:L.macroName,class:"tok-macroName"},{tag:L.propertyName,class:"tok-propertyName"},{tag:L.operator,class:"tok-operator"},{tag:L.comment,class:"tok-comment"},{tag:L.meta,class:"tok-meta"},{tag:L.invalid,class:"tok-invalid"},{tag:L.punctuation,class:"tok-punctuation"}]);var a1,Ka=new qe;function WS(i){return Ee.define({combine:i?e=>e.concat(i):void 0})}var XS=new qe,Cn=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,At.prototype.hasOwnProperty("tree")||Object.defineProperty(At.prototype,"tree",{get(){return Oi(this)}}),this.parser=t,this.extension=[Js.of(this),At.languageData.of((s,o,a)=>{let l=qS(s,o,a),c=l.type.prop(Ka);if(!c)return[];let u=s.facet(c),f=l.type.prop(XS);if(f){let d=l.resolve(o-l.from,a);for(let h of f)if(h.test(d,s)){let p=s.facet(h.facet);return h.type=="replace"?p:p.concat(u)}}return u})].concat(n)}isActiveAt(e,t,n=-1){return qS(e,t,n).type.prop(Ka)==this.data}findRegions(e){let t=e.facet(Js);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(Ka)==this.data){n.push({from:o,to:o+s.length});return}let a=s.prop(qe.mounted);if(a){if(a.tree.prop(Ka)==this.data){if(a.overlay)for(let l of a.overlay)n.push({from:l.from+o,to:l.to+o});else n.push({from:o,to:o+s.length});return}else if(a.overlay){let l=n.length;if(r(a.tree,a.overlay[0].from+o),n.length>l)return}}for(let l=0;ln.isTop?t:void 0)]}),e.name)}configure(e,t){return new i(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Oi(i){let e=i.field(Cn.state,!1);return e?e.tree:ri.empty}var f1=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Bc=null,d1=class i{constructor(e,t,n=[],r,s,o,a,l){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new i(e,t,[],ri.empty,0,n,[],null)}startParse(){return this.parser.startParse(new f1(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ri.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Vo.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Bc;Bc=this;try{return e()}finally{Bc=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=LS(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,f,d)=>l.push({fromA:c,toA:u,fromB:f,toB:d})),n=Vo.applyChanges(n,l),r=ri.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);ue.from&&(this.fragments=LS(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Ha{createParse(t,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let l=Bc;if(l){for(let c of r)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new ri(zi.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Bc}};function LS(i,e,t){return Vo.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}var Wc=class i{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new i(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=d1.create(e.facet(Js).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new i(n)}};Cn.state=Xt.define({create:Wc.init,update(i,e){for(let t of e.effects)if(t.is(Cn.setState))return t.value;return e.startState.facet(Js)!=e.state.facet(Js)?Wc.init(e.state):i.apply(e)}});var US=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(US=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var l1=typeof navigator<"u"&&(!((a1=navigator.scheduling)===null||a1===void 0)&&a1.isInputPending)?()=>navigator.scheduling.isInputPending():null,ZR=di.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Cn.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Cn.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=US(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,l=s.context.work(()=>l1&&l1()||Date.now()>o,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Cn.setState.of(new Wc(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ti(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Js=Ee.define({combine(i){return i.length?i[0]:null},enables:i=>[Cn.state,ZR,_e.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});var zR=Ee.define(),Xc=Ee.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Uc(i){let e=i.facet(Xc);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Ja(i,e){let t="",n=i.tabSize,r=i.facet(Xc)[0];if(r==" "){for(;e>=n;)t+=" ",e-=n;r=" "}for(let s=0;s=e?qR(i,t,e):null}var Xo=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Uc(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return Bs(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},y1=new qe;function qR(i,e,t){let n=e.resolveStack(t),r=n.node.enterUnfinishedNodesBefore(t);if(r!=n.node){let s=[];for(let o=r;o!=n.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return YS(n,i,t)}function YS(i,e,t){for(let n=i;n;n=n.next){let r=$R(n.node);if(r)return r(h1.create(e,t,n))}return 0}function LR(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function $R(i){let e=i.type.prop(y1);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(qe.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>GS(o,!0,1,void 0,s&&!LR(o)?r.from:void 0)}return i.parent==null?FR:null}function FR(){return 0}var h1=class i extends Xo{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new i(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(BR(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return YS(this.context.next,this.base,this.pos)}};function BR(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function VR(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==n)return null;if(!l.type.isSkipped)return l.fromGS(n,e,t,i)}function GS(i,e,t,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==i.pos+o,l=e?VR(i):null;return l?a?i.column(l.from):i.column(l.to):i.baseIndent+(a?0:i.unit*t)}var KS=i=>i.baseIndent;function th({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}var WR=200;function JS(){return At.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,r=t.lineAt(n);if(n>r.from+WR)return i;let s=t.sliceString(r.from,n);if(!e.some(c=>c.test(s)))return i;let{state:o}=i,a=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==a)continue;a=u.from;let f=eh(o,u.from);if(f==null)continue;let d=/^\s*/.exec(u.text)[0],h=Ja(o,f);d!=h&&l.push({from:u.from,to:u.from+d.length,insert:h})}return l.length?[i,{changes:l,sequential:!0}]:i})}var XR=Ee.define(),b1=new qe;function ex(i){let e=i.firstChild,t=i.lastChild;return e&&e.tot)continue;if(s&&a.from=e&&c.to>t&&(s=c)}}return s}function YR(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Kd(i,e,t){for(let n of i.facet(XR)){let r=n(i,e,t);if(r)return r}return UR(i,e,t)}function tx(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}var ih=Ze.define({map:tx}),Yc=Ze.define({map:tx});function ix(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}var Uo=Xt.define({create(){return Ne.none},update(i,e){i=i.map(e.changes);for(let t of e.effects)if(t.is(ih)&&!HR(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(_1),r=n?Ne.replace({widget:new p1(n(e.state,t.value))}):$S;i=i.update({add:[r.range(t.value.from,t.value.to)]})}else t.is(Yc)&&(i=i.update({filter:(n,r)=>t.value.from!=n||t.value.to!=r,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:n}=e.selection.main;i.between(n,n,(r,s)=>{rn&&(t=!0)}),t&&(i=i.update({filterFrom:n,filterTo:n,filter:(r,s)=>s<=n||r>=n}))}return i},provide:i=>_e.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,r)=>{t.push(n,r)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{(!r||r.from>s)&&(r={from:s,to:o})}),r}function HR(i,e,t){let n=!1;return i.between(e,e,(r,s)=>{r==e&&s==t&&(n=!0)}),n}function nx(i,e){return i.field(Uo,!1)?e:e.concat(Ze.appendConfig.of(ox()))}var GR=i=>{for(let e of ix(i)){let t=Kd(i.state,e.from,e.to);if(t)return i.dispatch({effects:nx(i.state,[ih.of(t),rx(i,t)])}),!0}return!1},KR=i=>{if(!i.state.field(Uo,!1))return!1;let e=[];for(let t of ix(i)){let n=Jd(i.state,t.from,t.to);n&&e.push(Yc.of(n),rx(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function rx(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,r=i.state.doc.lineAt(e.to).number;return _e.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${r}.`)}var JR=i=>{let{state:e}=i,t=[];for(let n=0;n{let e=i.state.field(Uo,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,r)=>{t.push(Yc.of({from:n,to:r}))}),i.dispatch({effects:t}),!0};var sx=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:GR},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:KR},{key:"Ctrl-Alt-[",run:JR},{key:"Ctrl-Alt-]",run:eM}],tM={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},_1=Ee.define({combine(i){return mn(i,tM)}});function ox(i){let e=[Uo,nM];return i&&e.push(_1.of(i)),e}function ax(i,e){let{state:t}=i,n=t.facet(_1),r=o=>{let a=i.lineBlockAt(i.posAtDOM(o.target)),l=Jd(i.state,a.from,a.to);l&&i.dispatch({effects:Yc.of(l)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,r,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}var $S=Ne.replace({widget:new class extends pr{toDOM(i){return ax(i,null)}}}),p1=class extends pr{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return ax(e,this.value)}},iM={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},Vc=class extends gr{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}};function lx(i={}){let e=Object.assign(Object.assign({},iM),i),t=new Vc(e,!0),n=new Vc(e,!1),r=di.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Js)!=o.state.facet(Js)||o.startState.field(Uo,!1)!=o.state.field(Uo,!1)||Oi(o.startState)!=Oi(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new Zr;for(let l of o.viewportLineBlocks){let c=Jd(o.state,l.from,l.to)?n:Kd(o.state,l.from,l.to)?t:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:s}=e;return[r,Y0({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(r))===null||a===void 0?void 0:a.markers)||St.empty},initialSpacer(){return new Vc(e,!1)},domEventHandlers:Object.assign(Object.assign({},s),{click:(o,a,l)=>{if(s.click&&s.click(o,a,l))return!0;let c=Jd(o.state,a.from,a.to);if(c)return o.dispatch({effects:Yc.of(c)}),!0;let u=Kd(o.state,a.from,a.to);return u?(o.dispatch({effects:ih.of(u)}),!0):!1}})}),ox()]}var nM=_e.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),eo=class i{constructor(e,t){this.specs=e;let n;function r(a){let l=zn.newName();return(n||(n=Object.create(null)))["."+l]=a,l}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof Cn?a=>a.prop(Ka)==o.data:o?a=>a==o:void 0,this.style=o1(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=n?new zn(n):null,this.themeType=t.themeType}static define(e,t){return new i(e,t||{})}},m1=Ee.define(),cx=Ee.define({combine(i){return i.length?[i[0]]:null}});function c1(i){let e=i.facet(m1);return e.length?e:i.facet(cx)}function el(i,e){let t=[rM],n;return i instanceof eo&&(i.module&&t.push(_e.styleModule.of(i.module)),n=i.themeType),e?.fallback?t.push(cx.of(i)):n?t.push(m1.computeN([_e.darkTheme],r=>r.facet(_e.darkTheme)==(n=="dark")?[i]:[])):t.push(m1.of(i)),t}var g1=class{constructor(e){this.markCache=Object.create(null),this.tree=Oi(e.state),this.decorations=this.buildDeco(e,c1(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Oi(e.state),n=c1(e.state),r=n!=c1(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return Ne.none;let n=new Zr;for(let{from:r,to:s}of e.visibleRanges)zS(this.tree,t,(o,a,l)=>{n.add(o,a,this.markCache[l]||(this.markCache[l]=Ne.mark({class:l})))},r,s);return n.finish()}},rM=hr.high(di.fromClass(g1,{decorations:i=>i.decorations})),ux=eo.define([{tag:L.meta,color:"#404740"},{tag:L.link,textDecoration:"underline"},{tag:L.heading,textDecoration:"underline",fontWeight:"bold"},{tag:L.emphasis,fontStyle:"italic"},{tag:L.strong,fontWeight:"bold"},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.keyword,color:"#708"},{tag:[L.atom,L.bool,L.url,L.contentSeparator,L.labelName],color:"#219"},{tag:[L.literal,L.inserted],color:"#164"},{tag:[L.string,L.deleted],color:"#a11"},{tag:[L.regexp,L.escape,L.special(L.string)],color:"#e40"},{tag:L.definition(L.variableName),color:"#00f"},{tag:L.local(L.variableName),color:"#30a"},{tag:[L.typeName,L.namespace],color:"#085"},{tag:L.className,color:"#167"},{tag:[L.special(L.variableName),L.macroName],color:"#256"},{tag:L.definition(L.propertyName),color:"#00c"},{tag:L.comment,color:"#940"},{tag:L.invalid,color:"#f00"}]),sM=_e.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),fx=1e4,dx="()[]{}",hx=Ee.define({combine(i){return mn(i,{afterCursor:!0,brackets:dx,maxScanDistance:fx,renderMatch:lM})}}),oM=Ne.mark({class:"cm-matchingBracket"}),aM=Ne.mark({class:"cm-nonmatchingBracket"});function lM(i){let e=[],t=i.matched?oM:aM;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}var cM=Xt.define({create(){return Ne.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(hx);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=Or(e.state,r.head,-1,n)||r.head>0&&Or(e.state,r.head-1,1,n)||n.afterCursor&&(Or(e.state,r.head,1,n)||r.head_e.decorations.from(i)}),uM=[cM,sM];function px(i={}){return[hx.of(i),uM]}var fM=new qe;function O1(i,e,t){let n=i.prop(e<0?qe.openedBy:qe.closedBy);if(n)return n;if(i.name.length==1){let r=t.indexOf(i.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function v1(i){let e=i.type.prop(fM);return e?e(i.node):i}function Or(i,e,t,n={}){let r=n.maxScanDistance||fx,s=n.brackets||dx,o=Oi(i),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=O1(l.type,t,s);if(c&&l.from0?e>=u.from&&eu.from&&e<=u.to))return dM(i,e,t,l,u,c,s)}}return hM(i,e,t,o,a.type,r,s)}function dM(i,e,t,n,r,s,o){let a=n.parent,l={from:r.from,to:r.to},c=0,u=a?.cursor();if(u&&(t<0?u.childBefore(n.from):u.childAfter(n.to)))do if(t<0?u.to<=n.from:u.from>=n.to){if(c==0&&s.indexOf(u.type.name)>-1&&u.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=i.doc.iterRange(e,t>0?i.doc.length:0),f=0;for(let d=0;!u.next().done&&d<=s;){let h=u.value;t<0&&(d+=h.length);let p=e+d*t;for(let m=t>0?0:h.length-1,g=t>0?h.length:-1;m!=g;m+=t){let O=o.indexOf(h[m]);if(!(O<0||n.resolveInner(p+m,1).type!=r))if(O%2==0==t>0)f++;else{if(f==1)return{start:c,end:{from:p+m,to:p+m+1},matched:O>>1==l>>1};f--}}t>0&&(d+=h.length)}return u.done?{start:c,matched:!1}:null}var pM=Object.create(null),FS=[zi.none];var BS=[],VS=Object.create(null),mM=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])mM[i]=gM(pM,e);function u1(i,e){BS.indexOf(i)>-1||(BS.push(i),console.warn(e))}function gM(i,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=i[c]||L[c];u?typeof u=="function"?l.length?l=l.map(u):u1(c,`Modifier ${c} used at start of tag`):l.length?u1(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:u1(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+t.map(a=>a.id),s=VS[r];if(s)return s.id;let o=VS[r]=zi.define({id:FS.length,name:n,props:[Hd({[n]:t})]});return FS.push(o),o.id}var ZK={rtl:Ne.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Ct.RTL}),ltr:Ne.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Ct.LTR}),auto:Ne.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var OM=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=C1(i.state,t.from);return n.line?vM(i):n.block?bM(i):!1};function P1(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=i(e,t);return r?(n(t.update(r)),!0):!1}}var vM=P1(kM,0);var yM=P1(kx,0);var bM=P1((i,e)=>kx(i,e,wM(e)),0);function C1(i,e){let t=i.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var Hc=50;function _M(i,{open:e,close:t},n,r){let s=i.sliceDoc(n-Hc,n),o=i.sliceDoc(r,r+Hc),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,c=s.length-a;if(s.slice(c-e.length,c)==e&&o.slice(l,l+t.length)==t)return{open:{pos:n-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let u,f;r-n<=2*Hc?u=f=i.sliceDoc(n,r):(u=i.sliceDoc(n,n+Hc),f=i.sliceDoc(r-Hc,r));let d=/^\s*/.exec(u)[0].length,h=/\s*$/.exec(f)[0].length,p=f.length-h-t.length;return u.slice(d,d+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:n+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:r-h-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function wM(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),r=t.to<=n.to?n:i.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=r.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return e}function kx(i,e,t=e.selection.ranges){let n=t.map(s=>C1(e,s.from).block);if(!n.every(s=>s))return null;let r=t.map((s,o)=>_M(e,n[o],s.from,s.to));if(i!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:n[o].open+" "},{from:s.to,insert:" "+n[o].close}]))};if(i!=1&&r.some(s=>s)){let s=[];for(let o=0,a;or&&(s==o||o>f.from)){r=f.from;let d=/^\s*/.exec(f.text)[0].length,h=d==f.length,p=f.text.slice(d,d+c.length)==c?d:-1;ds.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of n)(f||!u)&&s.push({from:a.from+c,insert:l+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(i!=1&&n.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:l}of n)if(a>=0){let c=o.from+a,u=c+l.length;o.text[u-o.from]==" "&&u++,s.push({from:c,to:u})}return{changes:s}}return null}var k1=pn.define(),SM=pn.define(),xM=Ee.define(),PM=Ee.define({combine(i){return mn(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),CM=Xt.define({create(){return Yo.empty},update(i,e){let t=e.state.facet(PM),n=e.annotation(k1);if(n){let l=vr.fromTransaction(e,n.selection),c=n.side,u=c==0?i.undone:i.done;return l?u=rh(u,u.length,t.minDepth,l):u=xx(u,e.startState.selection),new Yo(c==0?n.rest:u,c==0?u:n.rest)}let r=e.annotation(SM);if((r=="full"||r=="before")&&(i=i.isolate()),e.annotation(gi.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let s=vr.fromTransaction(e),o=e.annotation(gi.time),a=e.annotation(gi.userEvent);return s?i=i.addChanges(s,o,a,t,e):e.selection&&(i=i.addSelection(e.startState.selection,o,a,t.newGroupDelay)),(r=="full"||r=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new Yo(i.done.map(vr.fromJSON),i.undone.map(vr.fromJSON))}});function sh(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let r=t.field(CM,!1);if(!r)return!1;let s=r.pop(i,t,e);return s?(n(s),!0):!1}}var EM=sh(0,!1),mx=sh(1,!1),TM=sh(0,!0),AM=sh(1,!0);var vr=class i{constructor(e,t,n,r,s){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new i(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new i(e.changes&&Ui.fromJSON(e.changes),[],e.mapped&&gs.fromJSON(e.mapped),e.startSelection&&le.fromJSON(e.startSelection),e.selectionsAfter.map(le.fromJSON))}static fromTransaction(e,t){let n=$n;for(let r of e.startState.facet(xM)){let s=r(e);s.length&&(n=n.concat(s))}return!n.length&&e.changes.empty?null:new i(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,$n)}static selection(e){return new i(void 0,$n,void 0,void 0,e)}};function rh(i,e,t,n){let r=e+1>t+20?e-t-1:0,s=i.slice(r,e);return s.push(n),s}function DM(i,e){let t=[],n=!1;return i.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,a)=>{for(let l=0;l=c&&o<=u&&(n=!0)}}),n}function QM(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function Sx(i,e){return i.length?e.length?i.concat(e):i:e}var $n=[],RM=200;function xx(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-RM));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),rh(i,i.length-1,1e9,t.setSelAfter(n)))}else return[vr.selection([e])]}function MM(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function w1(i,e){if(!i.length)return i;let t=i.length,n=$n;for(;t;){let r=IM(i[t-1],e,n);if(r.changes&&!r.changes.empty||r.effects.length){let s=i.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,n=r.selectionsAfter}return n.length?[vr.selection(n)]:$n}function IM(i,e,t){let n=Sx(i.selectionsAfter.length?i.selectionsAfter.map(a=>a.map(e)):$n,t);if(!i.changes)return vr.selection(n);let r=i.changes.map(e),s=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(s):s;return new vr(r,Ze.mapEffects(i.effects,e),o,i.startSelection.map(s),n)}var NM=/^(input\.type|delete)($|\.)/,Yo=class i{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new i(this.done,this.undone):this}addChanges(e,t,n,r,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||NM.test(n))&&(!a.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?i.moveByChar(t,e):oh(t,e))}function qi(i){return i.textDirectionAt(i.state.selection.main.head)==Ct.LTR}var Ex=i=>Cx(i,!qi(i)),Tx=i=>Cx(i,qi(i));function Ax(i,e){return yr(i,t=>t.empty?i.moveByGroup(t,e):oh(t,e))}var jM=i=>Ax(i,!qi(i)),ZM=i=>Ax(i,qi(i));var XK=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function zM(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function ah(i,e,t){let n=Oi(i).resolveInner(e.head),r=t?qe.closedBy:qe.openedBy;for(let l=e.head;;){let c=t?n.childAfter(l):n.childBefore(l);if(!c)break;zM(i,c,r)?n=c:l=t?c.to:c.from}let s=n.type.prop(r),o,a;return s&&(o=t?Or(i,n.from,1):Or(i,n.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?n.to:n.from,le.cursor(a,t?-1:1)}var qM=i=>yr(i,e=>ah(i.state,e,!qi(i))),LM=i=>yr(i,e=>ah(i.state,e,qi(i)));function Dx(i,e){return yr(i,t=>{if(!t.empty)return oh(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}var Qx=i=>Dx(i,!1),Rx=i=>Dx(i,!0);function Mx(i){let e=i.scrollDOM.clientHeighto.empty?i.moveVertically(o,e,t.height):oh(o,e));if(r.eq(n.selection))return!1;let s;if(t.selfScroll){let o=i.coordsAtPos(n.selection.main.head),a=i.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;o&&o.top>l&&o.bottomIx(i,!1),S1=i=>Ix(i,!0);function to(i,e,t){let n=i.lineBlockAt(e.head),r=i.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?n.to:n.from)&&(r=i.moveToLineBoundary(e,t,!1)),!t&&r.head==n.from&&n.length){let s=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;s&&e.head!=n.from+s&&(r=le.cursor(n.from+s))}return r}var $M=i=>yr(i,e=>to(i,e,!0)),FM=i=>yr(i,e=>to(i,e,!1)),BM=i=>yr(i,e=>to(i,e,!qi(i))),VM=i=>yr(i,e=>to(i,e,qi(i))),WM=i=>yr(i,e=>le.cursor(i.lineBlockAt(e.head).from,1)),XM=i=>yr(i,e=>le.cursor(i.lineBlockAt(e.head).to,-1));function UM(i,e,t){let n=!1,r=tl(i.selection,s=>{let o=Or(i,s.head,-1)||Or(i,s.head,1)||s.head>0&&Or(i,s.head-1,1)||s.headUM(i,e,!1);function Fn(i,e){let t=tl(i.state.selection,n=>{let r=e(n);return le.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(Hr(i.state,t)),!0)}function Nx(i,e){return Fn(i,t=>i.moveByChar(t,e))}var jx=i=>Nx(i,!qi(i)),Zx=i=>Nx(i,qi(i));function zx(i,e){return Fn(i,t=>i.moveByGroup(t,e))}var HM=i=>zx(i,!qi(i)),GM=i=>zx(i,qi(i));var KM=i=>Fn(i,e=>ah(i.state,e,!qi(i))),JM=i=>Fn(i,e=>ah(i.state,e,qi(i)));function qx(i,e){return Fn(i,t=>i.moveVertically(t,e))}var Lx=i=>qx(i,!1),$x=i=>qx(i,!0);function Fx(i,e){return Fn(i,t=>i.moveVertically(t,e,Mx(i).height))}var Ox=i=>Fx(i,!1),vx=i=>Fx(i,!0),eI=i=>Fn(i,e=>to(i,e,!0)),tI=i=>Fn(i,e=>to(i,e,!1)),iI=i=>Fn(i,e=>to(i,e,!qi(i))),nI=i=>Fn(i,e=>to(i,e,qi(i))),rI=i=>Fn(i,e=>le.cursor(i.lineBlockAt(e.head).from)),sI=i=>Fn(i,e=>le.cursor(i.lineBlockAt(e.head).to)),yx=({state:i,dispatch:e})=>(e(Hr(i,{anchor:0})),!0),bx=({state:i,dispatch:e})=>(e(Hr(i,{anchor:i.doc.length})),!0),_x=({state:i,dispatch:e})=>(e(Hr(i,{anchor:i.selection.main.anchor,head:0})),!0),wx=({state:i,dispatch:e})=>(e(Hr(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),oI=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),aI=({state:i,dispatch:e})=>{let t=lh(i).map(({from:n,to:r})=>le.range(n,Math.min(r+1,i.doc.length)));return e(i.update({selection:le.create(t),userEvent:"select"})),!0},lI=({state:i,dispatch:e})=>{let t=tl(i.selection,n=>{var r;let s=Oi(i).resolveStack(n.from,1);for(let o=s;o;o=o.next){let{node:a}=o;if((a.from=n.to||a.to>n.to&&a.from<=n.from)&&(!((r=a.parent)===null||r===void 0)&&r.parent))return le.range(a.to,a.from)}return n});return e(Hr(i,t)),!0},cI=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=le.create([t.main]):t.main.empty||(n=le.create([le.cursor(t.main.head)])),n?(e(Hr(i,n)),!0):!1};function Gc(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,r=n.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=e(s);lo&&(t="delete.forward",l=nh(i,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=nh(i,o,!1),a=nh(i,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:le.cursor(o,or(i)))n.between(e,e,(r,s)=>{re&&(e=t?s:r)});return e}var Bx=(i,e,t)=>Gc(i,n=>{let r=n.from,{state:s}=i,o=s.doc.lineAt(r),a,l;if(t&&!e&&r>o.from&&rBx(i,!1,!0);var Vx=i=>Bx(i,!0,!1),Wx=(i,e)=>Gc(i,t=>{let n=t.head,{state:r}=i,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let a=null;;){if(n==(e?s.to:s.from)){n==t.head&&s.number!=(e?r.doc.lines:1)&&(n+=e?1:-1);break}let l=ui(s.text,n-s.from,e)+s.from,c=s.text.slice(Math.min(n,l)-s.from,Math.max(n,l)-s.from),u=o(c);if(a!=null&&u!=a)break;(c!=" "||n!=t.head)&&(a=u),n=l}return n}),Xx=i=>Wx(i,!1),uI=i=>Wx(i,!0),fI=i=>Gc(i,e=>{let t=i.lineBlockAt(e.head).to;return e.headGc(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),hI=i=>Gc(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:rt.of(["",""])},range:le.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},mI=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let r=n.from,s=i.doc.lineAt(r),o=r==s.from?r-1:ui(s.text,r-s.from,!1)+s.from,a=r==s.to?r+1:ui(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:i.doc.slice(r,a).append(i.doc.slice(o,r))},range:le.cursor(a)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function lh(i){let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.from),s=i.doc.lineAt(n.to);if(!n.empty&&n.to==s.from&&(s=i.doc.lineAt(n.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(n)}else e.push({from:r.from,to:s.to,ranges:[n]});t=s.number+1}return e}function Ux(i,e,t){if(i.readOnly)return!1;let n=[],r=[];for(let s of lh(i)){if(t?s.to==i.doc.length:s.from==0)continue;let o=i.doc.lineAt(t?s.to+1:s.from-1),a=o.length+1;if(t){n.push({from:s.to,to:o.to},{from:s.from,insert:o.text+i.lineBreak});for(let l of s.ranges)r.push(le.range(Math.min(i.doc.length,l.anchor+a),Math.min(i.doc.length,l.head+a)))}else{n.push({from:o.from,to:s.from},{from:s.to,insert:i.lineBreak+o.text});for(let l of s.ranges)r.push(le.range(l.anchor-a,l.head-a))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:le.create(r,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}var gI=({state:i,dispatch:e})=>Ux(i,e,!1),OI=({state:i,dispatch:e})=>Ux(i,e,!0);function Yx(i,e,t){if(i.readOnly)return!1;let n=[];for(let r of lh(i))t?n.push({from:r.from,insert:i.doc.slice(r.from,r.to)+i.lineBreak}):n.push({from:r.to,insert:i.lineBreak+i.doc.slice(r.from,r.to)});return e(i.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var vI=({state:i,dispatch:e})=>Yx(i,e,!1),yI=({state:i,dispatch:e})=>Yx(i,e,!0),bI=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(lh(e).map(({from:r,to:s})=>(r>0?r--:s{let s;if(i.lineWrapping){let o=i.lineBlockAt(r.head),a=i.coordsAtPos(r.head,r.assoc||1);a&&(s=o.bottom+i.documentTop-a.bottom+i.defaultLineHeight/2)}return i.moveVertically(r,!0,s)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function _I(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Oi(i).resolveInner(e),n=t.childBefore(e),r=t.childAfter(e),s;return n&&r&&n.to<=e&&r.from>=e&&(s=n.type.prop(qe.closedBy))&&s.indexOf(r.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(r.from).from&&!/\S/.test(i.sliceDoc(n.to,r.from))?{from:n.to,to:r.from}:null}var wI=Hx(!1),kI=Hx(!0);function Hx(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{let{from:s,to:o}=r,a=e.doc.lineAt(s),l=!i&&s==o&&_I(e,s);i&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new Xo(e,{simulateBreak:s,simulateDoubleBreak:!!l}),u=eh(c,s);for(u==null&&(u=Bs(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));oa.from&&s{let r=[];for(let o=n.from;o<=n.to;){let a=i.doc.lineAt(o);a.number>t&&(n.empty||n.to>a.from)&&(e(a,r,n),t=a.number),o=a.to+1}let s=i.changes(r);return{changes:r,range:le.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}var SI=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new Xo(i,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=E1(i,(s,o,a)=>{let l=eh(n,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],u=Ja(i,l);(c!=u||a.fromi.readOnly?!1:(e(i.update(E1(i,(t,n)=>{n.push({from:t.from,insert:i.facet(Xc)})}),{userEvent:"input.indent"})),!0),Kx=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(E1(i,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Bs(r,i.tabSize),o=0,a=Ja(i,Math.max(0,s-Uc(i)));for(;o({mac:i.key,run:i.run,shift:i.shift}))),Jx=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:qM,shift:KM},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:LM,shift:JM},{key:"Alt-ArrowUp",run:gI},{key:"Shift-Alt-ArrowUp",run:vI},{key:"Alt-ArrowDown",run:OI},{key:"Shift-Alt-ArrowDown",run:yI},{key:"Escape",run:cI},{key:"Mod-Enter",run:kI},{key:"Alt-l",mac:"Ctrl-l",run:aI},{key:"Mod-i",run:lI,preventDefault:!0},{key:"Mod-[",run:Kx},{key:"Mod-]",run:Gx},{key:"Mod-Alt-\\",run:SI},{key:"Shift-Mod-k",run:bI},{key:"Shift-Mod-\\",run:YM},{key:"Mod-/",run:OM},{key:"Alt-A",run:yM}].concat(PI),eP={key:"Tab",run:Gx,shift:Kx};var D1=class i{constructor(e,t,n,r,s,o,a,l,c,u=0,f){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let r=e.parser.context;return new i(e,[],t,n,n,0,[],0,r?new ch(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,r=e&65535,{parser:s}=this.p,o=s.dynamicPrecedence(r);if(o&&(this.score+=o),n==0){this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(r,l)}storeNode(e,t,n,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(t==n)return;if(o.buffer[a-2]>=t){o.buffer[a-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,r);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let s=e,{parser:o}=this.p;(r>this.pos||t<=o.maxNode)&&(this.pos=r,o.stateFlag(s,1)||(this.reducePos=r)),this.pushState(s,n),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new i(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Q1(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let s=0,o;sl&1&&a==o)||r.push(t[s],o)}t=r}let n=[];for(let r=0;r>19,r=t&65535,s=this.stack.length-n*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=n(o,s+1);if(a!=null)return a}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},ch=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},Q1=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},R1=class i{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new i(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new i(this.stack,this.pos,this.index)}};function Kc(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let n=0,r=0;n=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}t?t[r++]=s:t=new e(s)}return t}var il=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},tP=new il,M1=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=tP,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,s=this.pos+e;for(;sn.to:s>=n.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-n.to,n=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t=this.chunk2Pos&&na.to&&(this.chunk2=this.chunk2.slice(0,a.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=tP,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},io=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;oP(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};io.prototype.contextual=io.prototype.fallback=io.prototype.extend=!1;var nl=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?Kc(e):e}token(e,t){let n=e.pos,r=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(oP(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};nl.prototype.contextual=io.prototype.fallback=io.prototype.extend=!1;var Ho=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function oP(i,e,t,n,r,s){let o=0,a=1<0){let p=i[h];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||EI(p,e.token.value,r,s))){e.acceptToken(p);break}}let u=e.next,f=0,d=i[o+2];if(e.next<0&&d>f&&i[c+d*3-3]==65535){o=i[c+d*3-1];continue e}for(;f>1,p=c+h+(h<<1),m=i[p],g=i[p+1]||65536;if(u=g)f=h+1;else{o=i[p+2],e.advance();continue e}}break}}function iP(i,e,t){for(let n=e,r;(r=i[n])!=65535;n++)if(r==t)return n-e;return-1}function EI(i,e,t,n){let r=iP(t,n,e);return r<0||iP(t,n,i)e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(i.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:i.length}}var I1=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?nP(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?nP(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof ri){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}},N1=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new il)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;cf.end+25&&(l=Math.max(f.lookAhead,l)),f.value!=0)){let d=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!u.extend&&(n=f,t>d))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!n&&e.pos==this.stream.end&&(n=new il,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new il,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:s}=n.p;for(let o=0;o=0&&n.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let s=0;se.bufferLength*4?new I1(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)n.push(a);else{if(this.advanceStack(a,n,e))continue;{r||(r=[],s=[]),r.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!n.length){let o=r&&TI(r);if(o)return En&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw En&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,n);if(o)return En&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((a,l)=>l.score-a.score);n.length>o;)n.pop();n.some(a=>a.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)n.splice(l--,1);else{n.splice(o--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let f=this.fragments.nodeAt(r);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(d>-1&&f.length&&(!c||(f.prop(qe.contextHash)||0)==u))return e.useNode(f,d),En&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof ri)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof ri&&f.positions[0]==0)f=h;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),En&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;cr?t.push(p):n.push(p)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return rP(e,t),!0}}runRecovery(e,t,n){let r=null,s=!1;for(let o=0;o ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),En&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,n))))continue;let f=a.split(),d=u;for(let h=0;f.forceReduce()&&h<10&&(En&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,n));h++)En&&(d=this.stackID(f)+" -> ");for(let h of a.recoverByInsert(l))En&&console.log(u+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,n);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),En&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),rP(a,n)):(!r||r.scorei,uh=class{constructor(e){this.start=e.start,this.shift=e.shift||A1,this.reduce=e.reduce||A1,this.reuse=e.reuse||A1,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},fh=class i extends Ha{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;ae.topRules[a][1]),r=[];for(let a=0;a=0)s(u,l,a[c++]);else{let f=a[c+-u];for(let d=-u;d>0;d--)s(a[c++],l,f);c++}}}this.nodeSet=new zc(t.map((a,l)=>zi.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:n.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let o=Kc(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;atypeof a=="number"?new io(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new j1(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],a=o&1,l=r[s++];if(a&&n)return l;for(let c=s+(o>>1);s0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=ys(this.data,s+2);else break;r=t(ys(this.data,s+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=ys(this.data,n+2);else break;if(!(this.data[n+2]&1)){let r=this.data[n+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[n],r)}}return t}configure(e){let t=Object.assign(Object.create(i.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let r=e.tokenizers.find(s=>s.from==n);return r?r.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let s=e.specializers.find(a=>a.from==n.external);if(!s)return n;let o=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[r]=sP(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(n[o]=!0)}let r=null;for(let s=0;sn)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scorei.external(t,n)<<1|e}return i.get}var AI=310,aP=1,DI=2,QI=3,RI=311,MI=313,II=314,NI=4,jI=5,ZI=0,q1=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],lP=125,zI=59,L1=47,qI=42,LI=43,$I=45,FI=60,BI=44,VI=new uh({start:!1,shift(i,e){return e==NI||e==jI||e==MI?i:e==II},strict:!1}),WI=new Ho((i,e)=>{let{next:t}=i;(t==lP||t==-1||e.context)&&i.acceptToken(RI)},{contextual:!0,fallback:!0}),XI=new Ho((i,e)=>{let{next:t}=i,n;q1.indexOf(t)>-1||t==L1&&((n=i.peek(1))==L1||n==qI)||t!=lP&&t!=zI&&t!=-1&&!e.context&&i.acceptToken(AI)},{contextual:!0}),UI=new Ho((i,e)=>{let{next:t}=i;if((t==LI||t==$I)&&(i.advance(),t==i.next)){i.advance();let n=!e.context&&e.canShift(aP);i.acceptToken(n?aP:DI)}},{contextual:!0});function z1(i,e){return i>=65&&i<=90||i>=97&&i<=122||i==95||i>=192||!e&&i>=48&&i<=57}var YI=new Ho((i,e)=>{if(i.next!=FI||!e.dialectEnabled(ZI)||(i.advance(),i.next==L1))return;let t=0;for(;q1.indexOf(i.next)>-1;)i.advance(),t++;if(z1(i.next,!0)){for(i.advance(),t++;z1(i.next,!1);)i.advance(),t++;for(;q1.indexOf(i.next)>-1;)i.advance(),t++;if(i.next==BI)return;for(let n=0;;n++){if(n==7){if(!z1(i.next,!0))return;break}if(i.next!="extends".charCodeAt(n))break;i.advance(),t++}}i.acceptToken(QI,-t)}),HI=Hd({"get set async static":L.modifier,"for while do if else switch try catch finally return throw break continue default case":L.controlKeyword,"in of await yield void typeof delete instanceof":L.operatorKeyword,"let var const using function class extends":L.definitionKeyword,"import export from":L.moduleKeyword,"with debugger as new":L.keyword,TemplateString:L.special(L.string),super:L.atom,BooleanLiteral:L.bool,this:L.self,null:L.null,Star:L.modifier,VariableName:L.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":L.function(L.variableName),VariableDefinition:L.definition(L.variableName),Label:L.labelName,PropertyName:L.propertyName,PrivatePropertyName:L.special(L.propertyName),"CallExpression/MemberExpression/PropertyName":L.function(L.propertyName),"FunctionDeclaration/VariableDefinition":L.function(L.definition(L.variableName)),"ClassDeclaration/VariableDefinition":L.definition(L.className),PropertyDefinition:L.definition(L.propertyName),PrivatePropertyDefinition:L.definition(L.special(L.propertyName)),UpdateOp:L.updateOperator,"LineComment Hashbang":L.lineComment,BlockComment:L.blockComment,Number:L.number,String:L.string,Escape:L.escape,ArithOp:L.arithmeticOperator,LogicOp:L.logicOperator,BitOp:L.bitwiseOperator,CompareOp:L.compareOperator,RegExp:L.regexp,Equals:L.definitionOperator,Arrow:L.function(L.punctuation),": Spread":L.punctuation,"( )":L.paren,"[ ]":L.squareBracket,"{ }":L.brace,"InterpolationStart InterpolationEnd":L.special(L.brace),".":L.derefOperator,", ;":L.separator,"@":L.meta,TypeName:L.typeName,TypeDefinition:L.definition(L.typeName),"type enum interface implements namespace module declare":L.definitionKeyword,"abstract global Privacy readonly override":L.modifier,"is keyof unique infer":L.operatorKeyword,JSXAttributeValue:L.attributeValue,JSXText:L.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":L.angleBracket,"JSXIdentifier JSXNameSpacedName":L.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":L.attributeName,"JSXBuiltin/JSXIdentifier":L.standard(L.tagName)}),GI={__proto__:null,export:18,as:23,from:31,default:34,async:39,function:40,extends:52,this:56,true:64,false:64,null:76,void:80,typeof:84,super:102,new:136,delete:154,yield:163,await:167,class:172,public:229,private:229,protected:229,readonly:231,instanceof:250,satisfies:253,in:254,const:256,import:288,keyof:341,unique:345,infer:351,is:387,abstract:407,implements:409,type:411,let:414,var:416,using:419,interface:425,enum:429,namespace:435,module:437,declare:441,global:445,for:464,of:473,while:476,with:480,do:484,if:488,else:490,switch:494,case:500,try:506,catch:510,finally:514,return:518,throw:522,break:526,continue:530,debugger:534},KI={__proto__:null,async:123,get:125,set:127,declare:189,public:191,private:191,protected:191,static:193,abstract:195,override:197,readonly:203,accessor:205,new:391},JI={__proto__:null,"<":145},cP=fh.deserialize({version:14,states:"$=dO%TQ^OOO%[Q^OOO'_Q`OOP(lOWOOO*zQ?NdO'#ChO+RO!bO'#CiO+aO#tO'#CiO+oO!0LbO'#D^O.QQ^O'#DdO.bQ^O'#DoO%[Q^O'#DzO0fQ^O'#ESOOQ?Mr'#E['#E[O1PQWO'#EXOOQO'#Em'#EmOOQO'#If'#IfO1XQWO'#GnO1dQWO'#ElO1iQWO'#ElO3kQ?NdO'#JjO6[Q?NdO'#JkO6xQWO'#F[O6}Q&jO'#FrOOQ?Mr'#Fd'#FdO7YO,YO'#FdO7hQ7[O'#FyO9UQWO'#FxOOQ?Mr'#Jk'#JkOOQ?Mp'#Jj'#JjO9ZQWO'#GrOOQU'#KW'#KWO9fQWO'#ISO9kQ?MxO'#ITOOQU'#JX'#JXOOQU'#IX'#IXQ`Q^OOO`Q^OOO9sQMnO'#DsO9zQ^O'#EOO:RQ^O'#EQO9aQWO'#GnO:YQ7[O'#CnO:hQWO'#EkO:sQWO'#EvO:xQ7[O'#FcO;gQWO'#GnOOQO'#KX'#KXO;lQWO'#KXO;zQWO'#GvO;zQWO'#GwO;zQWO'#GyO9aQWO'#G|OYQWO'#CdO>jQWO'#H]O>rQWO'#HcO>rQWO'#HeO`Q^O'#HgO>rQWO'#HiO>rQWO'#HlO>wQWO'#HrO>|Q?MyO'#HxO%[Q^O'#HzO?XQ?MyO'#H|O?dQ?MyO'#IOO9kQ?MxO'#IQO?oQ?NdO'#ChO@qQ`O'#DiQOQWOOO%[Q^O'#EQOAXQWO'#ETO:YQ7[O'#EkOAdQWO'#EkOAoQpO'#FcOOQU'#Cf'#CfOOQ?Mp'#Dn'#DnOOQ?Mp'#Jn'#JnO%[Q^O'#JnOOQO'#Jr'#JrOOQO'#Ic'#IcOBoQ`O'#EdOOQ?Mp'#Ec'#EcOOQ?Mp'#Ju'#JuOCkQ?NQO'#EdOCuQ`O'#EWOOQO'#Jq'#JqODZQ`O'#JrOEhQ`O'#EWOCuQ`O'#EdPEuO#@ItO'#CaPOOO)CDv)CDvOOOO'#IY'#IYOFQO!bO,59TOOQ?Mr,59T,59TOOOO'#IZ'#IZOF`O#tO,59TO%[Q^O'#D`OOOO'#I]'#I]OFnO!0LbO,59xOOQ?Mr,59x,59xOF|Q^O'#I^OGaQWO'#JlOIcQrO'#JlO+}Q^O'#JlOIjQWO,5:OOJQQWO'#EmOJ_QWO'#J{OJjQWO'#JzOJjQWO'#JzOJrQWO,5;ZOJwQWO'#JyOOQ?Mv,5:Z,5:ZOKOQ^O,5:ZOMPQ?NdO,5:fOMpQWO,5:nONZQ?MxO'#JxONbQWO'#JwO9ZQWO'#JwONvQWO'#JwO! OQWO,5;YO! TQWO'#JwO!#]QrO'#JkOOQ?Mr'#Ch'#ChO%[Q^O'#ESO!#{QpO,5:sOOQO'#Js'#JsOOQO-EnOOQU'#Ja'#JaOOQU,5>o,5>oOOQU-EfQ?NdO,5:jO%[Q^O,5:jO!APQ?NdO,5:lOOQO,5@s,5@sO!ApQ7[O,5=YO!BOQ?MxO'#JbO9UQWO'#JbO!BaQ?MxO,59YO!BlQ`O,59YO!BtQ7[O,59YO:YQ7[O,59YO!CPQWO,5;WO!CXQWO'#H[O!CmQWO'#K]O%[Q^O,5;{O!9jQ`O,5;}O!CuQWO,5=uO!CzQWO,5=uO!DPQWO,5=uO9kQ?MxO,5=uO;zQWO,5=eOOQO'#Cu'#CuO!D_Q`O,5=bO!DgQ7[O,5=cO!DrQWO,5=eO!DwQpO,5=hO!EPQWO'#KXO>wQWO'#HRO9aQWO'#HTO!EUQWO'#HTO:YQ7[O'#HVO!EZQWO'#HVOOQU,5=k,5=kO!E`QWO'#HWO!EqQWO'#CnO!EvQWO,59OO!FQQWO,59OO!HVQ^O,59OOOQU,59O,59OO!HgQ?MxO,59OO%[Q^O,59OO!JrQ^O'#H_OOQU'#H`'#H`OOQU'#Ha'#HaO`Q^O,5=wO!KYQWO,5=wO`Q^O,5=}O`Q^O,5>PO!K_QWO,5>RO`Q^O,5>TO!KdQWO,5>WO!KiQ^O,5>^OOQU,5>d,5>dO%[Q^O,5>dO9kQ?MxO,5>fOOQU,5>h,5>hO# sQWO,5>hOOQU,5>j,5>jO# sQWO,5>jOOQU,5>l,5>lO#!aQ`O'#D[O%[Q^O'#JnO#!kQ`O'#JnO##YQ`O'#DjO##kQ`O'#DjO#%|Q^O'#DjO#&TQWO'#JmO#&]QWO,5:TO#&bQWO'#EqO#&pQWO'#J|O#&xQWO,5;[O#&}Q`O'#DjO#'[Q`O'#EVOOQ?Mr,5:o,5:oO%[Q^O,5:oO#'cQWO,5:oO>wQWO,5;VO!BlQ`O,5;VO!BtQ7[O,5;VO:YQ7[O,5;VO#'kQWO,5@YO#'pQ(CWO,5:sOOQO-ExO+}Q^O,5>xOOQO,5?O,5?OO#*xQ^O'#I^OOQO-E<[-E<[O#+VQWO,5@WO#+_QrO,5@WO#+fQWO,5@fOOQ?Mr1G/j1G/jO%[Q^O,5@gO#+nQWO'#IdOOQO-ErQWO1G3mO$5xQ^O1G3oO$9|Q^O'#HnOOQU1G3r1G3rO$:ZQWO'#HtO>wQWO'#HvOOQU1G3x1G3xO$:cQ^O1G3xO9kQ?MxO1G4OOOQU1G4Q1G4QOOQ?Mp'#GZ'#GZO9kQ?MxO1G4SO9kQ?MxO1G4UO$>jQWO,5@YO!*mQ^O,5;]O9ZQWO,5;]O>wQWO,5:UO!*mQ^O,5:UO!BlQ`O,5:UO$>oQ07bO,5:UOOQO,5;],5;]O$>yQ`O'#I_O$?aQWO,5@XOOQ?Mr1G/o1G/oO$?iQ`O'#IeO$?sQWO,5@hOOQ?Mp1G0v1G0vO##kQ`O,5:UOOQO'#Ib'#IbO$?{Q`O,5:qOOQ?Mv,5:q,5:qO#'fQWO1G0ZOOQ?Mr1G0Z1G0ZO%[Q^O1G0ZOOQ?Mr1G0q1G0qO>wQWO1G0qO!BlQ`O1G0qO!BtQ7[O1G0qOOQ?Mp1G5t1G5tO!BaQ?MxO1G0^OOQO1G0j1G0jO%[Q^O1G0jO$@SQ?MxO1G0jO$@_Q?MxO1G0jO!BlQ`O1G0^OCuQ`O1G0^O$@mQ?MxO1G0jOOQO1G0^1G0^O$ARQ?NdO1G0jPOOO-ExO$AoQWO1G5rO$AwQWO1G6QO$BPQrO1G6RO9ZQWO,5?OO$BZQ?NdO1G6OO%[Q^O1G6OO$BkQ?MxO1G6OO$B|QWO1G5}O$B|QWO1G5}O9ZQWO1G5}O$CUQWO,5?RO9ZQWO,5?ROOQO,5?R,5?RO$CjQWO,5?RO$*oQWO,5?ROOQO-EYOOQU,5>Y,5>YO%[Q^O'#HoO%;tQWO'#HqOOQU,5>`,5>`O9ZQWO,5>`OOQU,5>b,5>bOOQU7+)d7+)dOOQU7+)j7+)jOOQU7+)n7+)nOOQU7+)p7+)pO%;yQ`O1G5tO%<_Q07bO1G0wO%wQWO1G/pO!*mQ^O'#DjOOQO,5>y,5>yOOQO-E<]-E<]OOQO,5?P,5?POOQO-EwQWO7+&]O!BlQ`O7+&]OOQO7+%x7+%xO$ARQ?NdO7+&UOOQO7+&U7+&UO%[Q^O7+&UO%=OQ?MxO7+&UO!BaQ?MxO7+%xO!BlQ`O7+%xO%=ZQ?MxO7+&UO%=iQ?NdO7++jO%[Q^O7++jO%=yQWO7++iO%=yQWO7++iOOQO1G4m1G4mO9ZQWO1G4mO%>RQWO1G4mOOQO7+%}7+%}O#'fQWO<aQWO<iQWO<tQ?NdO,5?ZO%APQ?NdO,5?]O%C[Q?NdO1G2[O%EmQ?NdO1G2nO%GxQ?NdO1G2pO%JTQ7[O,5>zOOQO-E<^-E<^O%J_QrO,5>{O%[Q^O,5>{OOQO-E<_-E<_O%JiQWO1G5vOOQ?Mr<ZOOQU,5>],5>]O&wQWO7+%[OOQ?Mr<wQWO<wQWO7+)fO'*yQWO<PO#w$WO(q#}O(r$OO~P#>POP$^OZ$eOn$RO|#zO}#{O!P#|O!i$TO!j#xO!l#yO!p$^O#k$PO#l$QO#m$QO#n$QO#o$SO#p$TO#q$TO#r$dO#s$TO#u$UO#w$WO#y$YO(YVO(q#}O(r$OO~O`#ji!Y#ji#z#ji's#ji(j#ji'q#ji!V#ji!k#jir#ji![#ji%d#ji!d#ji~P#@wOP[XZ[Xn[X|[X}[X!P[X!i[X!j[X!l[X!p[X#][X#heX#k[X#l[X#m[X#n[X#o[X#p[X#q[X#r[X#s[X#u[X#w[X#y[X#z[X$P[X(Y[X(j[X(q[X(r[X!Y[X!Z[X~O#}[X~P#CbOP$^OZ;SOn:vO|#zO}#{O!P#|O!i:xO!j#xO!l#yO!p$^O#k:tO#l:uO#m:uO#n:uO#o:wO#p:xO#q:xO#r;RO#s:xO#u:yO#w:{O#y:}O#z;OO(YVO(j$[O(q#}O(r$OO~O#}.xO~P#EoO#];TO$P;TO#}(_X!Z(_X~P! cO`'^a!Y'^a's'^a'q'^a!k'^a!V'^ar'^a!['^a%d'^a!d'^a~P!:ROP#jiZ#ji`#jin#ji}#ji!Y#ji!i#ji!j#ji!l#ji!p#ji#k#ji#l#ji#m#ji#n#ji#o#ji#p#ji#q#ji#r#ji#s#ji#u#ji#w#ji#y#ji#z#ji's#ji(Y#ji(j#ji'q#ji!V#ji!k#jir#ji![#ji%d#ji!d#ji~P#/OO`$Oi!Y$Oi's$Oi'q$Oi!V$Oi!k$Oir$Oi![$Oi%d$Oi!d$Oi~P!:RO$Z.}O$].}O~O$Z/OO$]/OO~O!d)eO#]/PO![$aX$X$aX$Z$aX$]$aX$d$aX~O!X/QO~O![)hO$X/SO$Z)gO$])gO$d/TO~O!Y;PO!Z(^X~P#EoO!Z/UO~O!d)eO$d(sX~O$d/WO~Ot)wO(Z)xO([/ZO~O!V/_O~P!&kO(q%OOj%[a|%[a!P%[a(r%[a!Y%[a#]%[a~Of%[a#}%[a~P#NPO(r%QOj%^a|%^a!P%^a(q%^a!Y%^a#]%^a~Of%^a#}%^a~P#NrO!YeX!deX!keX!k$vX(jeX~P!/{O!X/hO!Y(YO'|/gO!V(nP!V(xP~P!1sOn*pO!_*nO!`*gO!a*gO!l*_O#X*oO%Z*jO'}!lO~Oo'XO!P/iO!X+VO!Z*mO(OTO(RUO(];cO!Z(pP~P$!]O!k/jO~P#/OO!Y/kO!d#vO(j'mO!k(wX~O!k/pO~O!P%fO!X*[O![%gO'|%eO!k(wP~O#h/rO~O!V$vX!Y$vX!d$}X~P!/{O!Y/sO!V(xX~P#/OO!d/uO~O!V/wO~Og%WOn/{O!d#vO!l%cO(j'mO~O'|/}O~O!d+eO~O`%lO!Y0RO's%lO~O!Z0TO~P!5gO!`0UO!a0UO'}!lO(]!mO~O!P0WO(]!mO~O#X0XO~Of%[a!Y%[a#]%[a#}%[a~P!1UOf%^a!Y%^a#]%^a#}%^a~P!1UO'|&WOf'gX!Y'gX~O!Y*vOf(Va~Of0bO~O|0cO}0cO!P0dOjya(qya(rya!Yya#]ya~Ofya#}ya~P$(OO|)|O!P)}Oj$oa(q$oa(r$oa!Y$oa#]$oa~Of$oa#}$oa~P$(tO|)|O!P)}Oj$qa(q$qa(r$qa!Y$qa#]$qa~Of$qa#}$qa~P$)gO#h0fO~Of%Pa!Y%Pa#]%Pa#}%Pa~P!1UO!d#vO~O#h0iO~O!Y+XO`(|a's(|a~O|#zO}#{O!P#|O!j#xO!l#yO(YVOP!riZ!rin!ri!Y!ri!i!ri!p!ri#k!ri#l!ri#m!ri#n!ri#o!ri#p!ri#q!ri#r!ri#s!ri#u!ri#w!ri#y!ri#z!ri(j!ri(q!ri(r!ri~O`!ri's!ri'q!ri!V!ri!k!rir!ri![!ri%d!ri!d!ri~P$+UOg%WOn$uOo$tOp$tOv%YOx%ZOz;YO!P$|O![$}O!fX#>_#>e#>s#?Y#@w#AV#A^#Br#CQ#Dl#Dz#EQ#EW#E^#Eh#En#Et#FO#Fb#FhPPPPPPPPPP#FnPPPPPPP#Gc#Jj#Ky#LQ#LYPPPP$#`$&W$,p$,s$,v$-c$-f$-i$-p$-xP$.OP$.l$.p$/h$0v$0{$1cPP$1h$1n$1rP$1u$1y$1}$2s$3[$3s$3w$3z$3}$4T$4W$4[$4`R!|RoqOXst!Z#d%k&o&q&r&t,m,r2P2SY!vQ']-_1d5fQ%rvQ%zyQ&R|Q&g!VS'T!e-VQ'c!iS'i!r!yU*g$}*X*lQ+k%{Q+x&TQ,^&aQ-]'[Q-g'dQ-o'jQ0U*nQ1n,_R;b:o%QdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#y#|$P$Q$R$S$T$U$V$W$X$Y$Z$b$f%k%r&P&h&k&o&q&r&t&x'Q'_'o(P(R(X(`(t(x(|){+S+W,j,m,r-c-k-y.P.q.x/i0d0i0y1g1w1x1z1|2P2S2U2u2{3c5c5m5}6O6R6f8P8U8e8oS#q]:l!r)^$]$n'U)p-O-R/Q2e3x5a6]9`9q:k:n:o:r:s:t:u:v:w:x:y:z:{:|:};O;P;T;b;d;e;g;o;p;y;z < TypeParamList TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . ?. PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression TypeArgList CompareOp < ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in const CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast ArrowFunction TypeParamList SequenceExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:373,context:VI,nodeProps:[["isolate",-8,4,5,13,33,35,48,50,52,""],["group",-26,8,16,18,65,202,206,210,211,213,216,219,229,231,237,239,241,243,246,252,258,260,262,264,266,268,269,"Statement",-33,12,13,28,31,32,38,48,51,52,54,59,67,69,76,80,82,84,85,107,108,117,118,135,138,140,141,142,143,145,146,165,166,168,"Expression",-23,27,29,33,37,39,41,169,171,173,174,176,177,178,180,181,182,184,185,186,196,198,200,201,"Type",-3,88,100,106,"ClassItem"],["openedBy",22,"<",34,"InterpolationStart",53,"[",57,"{",73,"(",158,"JSXStartCloseTag"],["closedBy",23,">",36,"InterpolationEnd",47,"]",58,"}",74,")",163,"JSXEndTag"]],propSources:[HI],skippedNodes:[0,4,5,272],repeatNodeCount:37,tokenData:"$HR07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$.S!c!}Er!}#O$/^#O#P$0h#P#Q$6P#Q#R$7Z#R#SEr#S#T$8h#T#o$9r#o#p$>S#p#q$>x#q#r$@Y#r#s$Af#s$f%Z$f$g+g$g#BYEr#BY#BZ$Bp#BZ$ISEr$IS$I_$Bp$I_$I|Er$I|$I}$E{$I}$JO$E{$JO$JTEr$JT$JU$Bp$JU$KVEr$KV$KW$Bp$KW&FUEr&FU&FV$Bp&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$Bp?HUOEr(n%d_$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$g&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$g&j(S!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(S!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$g&j(PpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(PpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Pp(S!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$g&j(Pp(S!b'u0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(Q#S$g&j'v0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$g&j(Pp(S!b'v0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$g&j!p),Q(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#u(Ch$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#u(Ch$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(O':f$g&j(S!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$g&j(S!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$g&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$b`$g&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$b``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$b`$g&j(S!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(S!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$b`(S!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$g&j(Pp(S!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXVS$g&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSVSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWVS(S!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]VS$g&j(PpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWVS(PpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYVS(Pp(S!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$g&j!U7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!U7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!U7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$g&j(S!b!U7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(S!b!U7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(S!b!U7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(S!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$g&j(S!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$g&j(Pp(S!bo'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$g&j(Pp(S!bo'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$g&j(Pp(S!bo'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$g&j(Pp(S!bo'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!d$b$g&j#})Lv(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_`l$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^g#)`!i-PP;=`<%l$9r#Jf$>]X![#Hb(Pp(S!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g,#x$?Ta(q+JY$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p#q$,u#q;'S%Z;'S;=`+a<%lO%Z(Kd$@g_!Z(Cdr`$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$Aq_!q7`$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$CR|$g&j(Pp(S!b'u0/l$Z#t'|,2j(]$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$Bp#BZ$ISEr$IS$I_$Bp$I_$JTEr$JT$JU$Bp$JU$KVEr$KV$KW$Bp$KW&FUEr&FU&FV$Bp&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$Bp?HUOEr07[$F^k$g&j(Pp(S!b'v0/l$Z#t'|,2j(]$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[XI,UI,YI,2,3,4,5,6,7,8,9,10,11,12,13,14,WI,new nl("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOt~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!R~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO([~~",141,333),new nl("j~RQYZXz{^~^O'y~~aP!P!Qd~iO'z~~",25,316)],topRules:{Script:[0,6],SingleExpression:[1,270],SingleClassItem:[2,271]},dialects:{jsx:0,ts:14840},dynamicPrecedences:{70:1,80:1,82:1,166:1,194:1},specialized:[{term:320,get:i=>GI[i]||-1},{term:335,get:i=>KI[i]||-1},{term:71,get:i=>JI[i]||-1}],tokenPrec:14864});var hh=class{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=Oi(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),s=r.search(OP(e,!1));return s<0?null:{from:n+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}};function uP(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function eN(i){let e=Object.create(null),t=Object.create(null);for(let{label:r}of i){e[r[0]]=!0;for(let s=1;stypeof r=="string"?{label:r}:r),[t,n]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:eN(e);return r=>{let s=r.matchBefore(n);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}var ph=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function no(i){return i.selection.main.from}function OP(i,e){var t;let{source:n}=i,r=e&&n[0]!="^",s=n[n.length-1]!="$";return!r&&!s?i:new RegExp(`${r?"^":""}(?:${n})${s?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}var vP=pn.define();function iN(i,e,t,n){let{main:r}=i.selection,s=t-r.from,o=n-r.from;return Object.assign(Object.assign({},i.changeByRange(a=>a!=r&&t!=n&&i.sliceDoc(a.from+s,a.from+o)!=i.sliceDoc(t,n)?{range:a}:{changes:{from:a.from+s,to:n==r.from?a.to:a.from+o,insert:e},range:le.cursor(a.from+s+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}var fP=new WeakMap;function nN(i){if(!Array.isArray(i))return i;let e=fP.get(i);return e||fP.set(i,e=tN(i)),e}var mh=Ze.define(),Jc=Ze.define(),B1=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(_=hc(k))!=_.toLowerCase()?1:_!=_.toUpperCase()?2:0;(!w||P==1&&g||C==0&&P!=0)&&(t[f]==k||n[f]==k&&(d=!0)?o[f++]=w:o.length&&(O=!1)),C=P,w+=xn(k)}return f==l&&o[0]==0&&O?this.result(-100+(d?-200:0),o,e):h==l&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):h==l?this.ret(-900-e.length,[p,m]):f==l?this.result(-100+(d?-200:0)+-700+(O?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],s=0;for(let o of t){let a=o+(this.astral?xn(Zi(n,o)):1);s&&r[s-1]==o?r[s-1]=a:(r[s++]=o,r[s++]=a)}return this.ret(e-n.length,r)}},V1=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:rN,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>dP(e(n),t(n)),optionClass:(e,t)=>n=>dP(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function dP(i,e){return i?e?i+" "+e:i:e}function rN(i,e,t,n,r,s){let o=i.textDirection==Ct.RTL,a=o,l=!1,c="top",u,f,d=e.left-r.left,h=r.right-e.right,p=n.right-n.left,m=n.bottom-n.top;if(a&&d=m||w>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let g=(e.bottom-e.top)/s.offsetHeight,O=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${f/O}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}function sN(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;cl&&o.appendChild(document.createTextNode(a.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(a.slice(u,f))),d.className="cm-completionMatchedText",l=f}return lt.position-n.position).map(t=>t.render)}function $1(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}var W1=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,a=e.state.facet(Ai);this.optionContent=sN(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=$1(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let u=l.target,f;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(f=/-(\d+)$/.exec(u.id))&&+f[1]{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Ai).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Jc.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){let{options:s,selected:o,disabled:a}=n.open;(!r.open||r.open.options!=s)&&(this.range=$1(s.length,o,e.state.facet(Ai).maxRenderedOptions),this.showOptions(s,n.id)),this.updateSel(),a!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected=this.range.to)&&(this.range=$1(t.options.length,t.selected,this.view.state.facet(Ai).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:r}=n;if(!r)return;let s=typeof r=="string"?document.createTextNode(r):r(n);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,n)}).catch(o=>Ti(this.view.state,o,"completion info")):this.addInfoPane(s,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;n.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!="LI"||!n.id?r--:r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&aN(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottomn.from||n.from==0))if(s=d,typeof c!="string"&&c.header)r.appendChild(c.header(c));else{let h=r.appendChild(document.createElement("completion-section"));h.textContent=d}}let u=r.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let f=this.optionClass(a);f&&(u.className=f);for(let d of this.optionContent){let h=d(a,this.view.state,this.view,l);h&&u.appendChild(h)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.tonew W1(t,i,e)}function aN(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),r=t.height/i.offsetHeight;n.topt.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/r)}function hP(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function lN(i,e){let t=[],n=null,r=c=>{t.push(c);let{section:u}=c.completion;if(u){n||(n=[]);let f=typeof u=="string"?u:u.name;n.some(d=>d.name==f)||n.push(typeof u=="string"?{name:f}:u)}},s=e.facet(Ai);for(let c of i)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)r(new ph(f,c.source,u?u(f):[],1e9-t.length));else{let f=e.sliceDoc(c.from,c.to),d,h=s.filterStrict?new V1(f):new B1(f);for(let p of c.result.options)if(d=h.match(p.label)){let m=p.displayLabel?u?u(p,d.matched):[]:d.matched;r(new ph(p,c.source,m,d.score+(p.boost||0)))}}}if(n){let c=Object.create(null),u=0,f=(d,h)=>{var p,m;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((m=h.rank)!==null&&m!==void 0?m:1e9)||(d.namef.score-u.score||l(u.completion,f.completion))){let u=c.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?o.push(c):hP(c.completion)>hP(a)&&(o[o.length-1]=c),a=c.completion}return o}var X1=class i{constructor(e,t,n,r,s,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new i(this.options,pP(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,s){let o=lN(e,t);if(!o.length)return r&&e.some(l=>l.state==1)?new i(r.options,r.attrs,r.tooltip,r.timestamp,r.selected,!0):null;let a=t.facet(Ai).selectOnOpen?0:-1;if(r&&r.selected!=a&&r.selected!=-1){let l=r.options[r.selected].completion;for(let c=0;cc.hasResult()?Math.min(l,c.from):l,1e8),create:hN,above:s.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new i(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}},U1=class i{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new i(fN,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(Ai),s=(n.override||t.languageDataAt("autocomplete",no(t)).map(nN)).map(a=>(this.active.find(c=>c.source==a)||new Gr(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));s.length==this.active.length&&s.every((a,l)=>a==this.active[l])&&(s=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!cN(s,this.active)?o=X1.build(s,t,this.id,o,n):o&&o.disabled&&!s.some(a=>a.state==1)&&(o=null),!o&&s.every(a=>a.state!=1)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new Gr(a.source,0):a));for(let a of e.effects)a.is(bP)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new i(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:uN}};function cN(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t-1&&(t["aria-activedescendant"]=i+"-"+e),t}var fN=[];function Y1(i,e){if(i.isUserEvent("input.complete")){let t=i.annotation(vP);if(t&&e.activateOnCompletion(t))return"input"}return i.isUserEvent("input.type")?"input":i.isUserEvent("delete.backward")?"delete":null}var Gr=class i{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=Y1(e,t),r=this;n?r=r.handleUserEvent(e,n,t):e.docChanged?r=r.handleChange(e):e.selection&&r.state!=0&&(r=new i(r.source,0));for(let s of e.effects)if(s.is(mh))r=new i(r.source,1,s.value?no(e.state):-1);else if(s.is(Jc))r=new i(r.source,0);else if(s.is(yP))for(let o of s.value)o.source==r.source&&(r=o);return r}handleUserEvent(e,t,n){return t=="delete"||!n.activateOnTyping?this.map(e.changes):new i(this.source,1)}handleChange(e){return e.changes.touchesRange(no(e.startState))?new i(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new i(this.source,this.state,e.mapPos(this.explicitPos))}},gh=class i extends Gr{constructor(e,t,n,r,s){super(e,2,t),this.result=n,this.from=r,this.to=s}hasResult(){return!0}handleUserEvent(e,t,n){var r;let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let o=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),l=no(e.state);if((this.explicitPos<0?l<=o:la||!s||t=="delete"&&no(e.startState)==this.from)return new Gr(this.source,t=="input"&&n.activateOnTyping?1:0);let c=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return dN(s.validFor,e.state,o,a)?new i(this.source,c,s,o,a):s.update&&(s=s.update(s,o,a,new hh(e.state,l,c>=0)))?new i(this.source,c,s,s.from,(r=s.to)!==null&&r!==void 0?r:no(e.state)):new Gr(this.source,1,c)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Gr(this.source,0):this.map(e.changes)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new i(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Gr(this.source,0)}};function dN(i,e,t,n){if(!i)return!1;let r=e.sliceDoc(t,n);return typeof i=="function"?i(r,t,n,e):OP(i,!0).test(r)}var yP=Ze.define({map(i,e){return i.map(t=>t.map(e))}}),bP=Ze.define(),gn=Xt.define({create(){return U1.start()},update(i,e){return i.update(e)},provide:i=>[jc.from(i,e=>e.tooltip),_e.contentAttributes.from(i,e=>e.attrs)]});function G1(i,e){let t=e.completion.apply||e.completion.label,n=i.state.field(gn).active.find(r=>r.source==e.source);return n instanceof gh?(typeof t=="string"?i.dispatch(Object.assign(Object.assign({},iN(i.state,t,n.from,n.to)),{annotations:vP.of(e.completion)})):t(i,e.completion,n.from,n.to),!0):!1}var hN=oN(gn,G1);function dh(i,e="option"){return t=>{let n=t.state.field(gn,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp-1?n.open.selected+r*(i?1:-1):i?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),t.dispatch({effects:bP.of(a)}),!0}}var pN=i=>{let e=i.state.field(gn,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampi.state.field(gn,!1)?(i.dispatch({effects:mh.of(!0)}),!0):!1,gN=i=>{let e=i.state.field(gn,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:Jc.of(null)}),!0)},H1=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},ON=50,vN=1e3,yN=di.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(gn).active)e.state==1&&this.startQuery(e)}update(i){let e=i.state.field(gn),t=i.state.facet(Ai);if(!i.selectionSet&&!i.docChanged&&i.startState.field(gn)==e)return;let n=i.transactions.some(s=>(s.selection||s.docChanged)&&!Y1(s,t));for(let s=0;sON&&Date.now()-o.time>vN){for(let a of o.context.abortListeners)try{a()}catch(l){Ti(this.view.state,l)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(s=>s.effects.some(o=>o.is(mh)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.state==1&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of i.transactions)Y1(s,t)=="input"?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(gn);for(let t of e.active)t.state==1&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t)}startQuery(i){let{state:e}=this.view,t=no(e),n=new hh(e,t,i.explicitPos==t),r=new H1(i,n);this.running.push(r),Promise.resolve(i.source(n)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Jc.of(null)}),Ti(this.view.state,s)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ai).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Ai);for(let n=0;no.source==r.active.source);if(s&&s.state==1)if(r.done==null){let o=new Gr(r.active.source,0);for(let a of r.updates)o=o.update(a,t);o.state!=1&&e.push(o)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:yP.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(gn,!1);if(e&&e.tooltip&&this.view.state.facet(Ai).closeOnBlur){let t=e.open&&U0(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Jc.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:mh.of(!1)}),20),this.composing=0}}}),bN=typeof navigator=="object"&&/Win/.test(navigator.platform),_N=hr.highest(_e.domEventHandlers({keydown(i,e){let t=e.state.field(gn,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(bN&&i.altKey)||i.metaKey)return!1;let n=t.open.options[t.open.selected],r=t.active.find(o=>o.source==n.source),s=n.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(i.key)>-1&&G1(e,n),!1}})),wN=_e.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});var eu={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Go=Ze.define({map(i,e){let t=e.mapPos(i,-1,Ci.TrackAfter);return t??void 0}}),K1=new class extends dr{};K1.startSide=1;K1.endSide=-1;var _P=Xt.define({create(){return St.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(Go)&&(i=i.update({add:[K1.range(t.value,t.value+1)]}));return i}});function wP(){return[SN,_P]}var F1="()[]{}<>";function kP(i){for(let e=0;e{if((kN?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let r=i.state.selection.main;if(n.length>2||n.length==2&&xn(Zi(n,0))==1||e!=r.from||t!=r.to)return!1;let s=PN(i.state,n);return s?(i.dispatch(s),!0):!1}),xN=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=SP(i,i.selection.main.head).brackets||eu.brackets,r=null,s=i.changeByRange(o=>{if(o.empty){let a=CN(i.doc,o.head);for(let l of n)if(l==a&&Oh(i.doc,o.head)==kP(Zi(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:le.cursor(o.head-l.length)}}return{range:r=o}});return r||e(i.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},xP=[{key:"Backspace",run:xN}];function PN(i,e){let t=SP(i,i.selection.main.head),n=t.brackets||eu.brackets;for(let r of n){let s=kP(Zi(r,0));if(e==r)return s==r?AN(i,r,n.indexOf(r+r+r)>-1,t):EN(i,r,s,t.before||eu.before);if(e==s&&PP(i,i.selection.main.from))return TN(i,r,s)}return null}function PP(i,e){let t=!1;return i.field(_P).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function Oh(i,e){let t=i.sliceString(e,e+2);return t.slice(0,xn(Zi(t,0)))}function CN(i,e){let t=i.sliceString(e-2,e);return xn(Zi(t,0))==t.length?t:t.slice(1)}function EN(i,e,t,n){let r=null,s=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Go.of(o.to+e.length),range:le.range(o.anchor+e.length,o.head+e.length)};let a=Oh(i.doc,o.head);return!a||/\s/.test(a)||n.indexOf(a)>-1?{changes:{insert:e+t,from:o.head},effects:Go.of(o.head+e.length),range:le.cursor(o.head+e.length)}:{range:r=o}});return r?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function TN(i,e,t){let n=null,r=i.changeByRange(s=>s.empty&&Oh(i.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:le.cursor(s.head+t.length)}:n={range:s});return n?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function AN(i,e,t,n){let r=n.stringPrefixes||eu.stringPrefixes,s=null,o=i.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Go.of(a.to+e.length),range:le.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=Oh(i.doc,l),u;if(c==e){if(mP(i,l))return{changes:{insert:e+e,from:l},effects:Go.of(l+e.length),range:le.cursor(l+e.length)};if(PP(i,l)){let d=t&&i.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+d.length,insert:d},range:le.cursor(l+d.length)}}}else{if(t&&i.sliceDoc(l-2*e.length,l)==e+e&&(u=gP(i,l-2*e.length,r))>-1&&mP(i,u))return{changes:{insert:e+e+e+e,from:l},effects:Go.of(l+e.length),range:le.cursor(l+e.length)};if(i.charCategorizer(l)(c)!=Pt.Word&&gP(i,l,r)>-1&&!DN(i,l,e,r))return{changes:{insert:e+e,from:l},effects:Go.of(l+e.length),range:le.cursor(l+e.length)}}return{range:s=a}});return s?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function mP(i,e){let t=Oi(i).resolveInner(e+1);return t.parent&&t.from==e}function DN(i,e,t,n){let r=Oi(i).resolveInner(e,-1),s=n.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=i.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),l=a.indexOf(t);if(!l||l>-1&&n.indexOf(a.slice(0,l))>-1){let u=r.firstChild;for(;u&&u.from==r.from&&u.to-u.from>t.length+l;){if(i.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=r.to==e&&r.parent;if(!c)break;r=c}return!1}function gP(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=Pt.Word)return e;for(let r of t){let s=e-r.length;if(i.sliceDoc(s,e)==r&&n(i.sliceDoc(s-1,s))!=Pt.Word)return s}return-1}function CP(i={}){return[_N,gn,Ai.of(i),yN,QN,wN]}var J1=[{key:"Ctrl-Space",run:mN},{key:"Escape",run:gN},{key:"ArrowDown",run:dh(!0)},{key:"ArrowUp",run:dh(!1)},{key:"PageDown",run:dh(!0,"page")},{key:"PageUp",run:dh(!1,"page")},{key:"Enter",run:pN}],QN=hr.highest(Nc.computeN([Ai],i=>i.facet(Ai).defaultKeymap?[J1]:[]));var EP=Gd.define({name:"javascript",parser:cP.configure({props:[y1.add({IfStatement:th({except:/^\s*({|else\b)/}),TryStatement:th({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:KS,SwitchBody:i=>{let e=i.textAfter,t=/^\s*\}/.test(e),n=/^\s*(case|default)\b/.test(e);return i.baseIndent+(t?0:n?1:2)*i.unit},Block:HS({closing:"}"}),ArrowFunction:i=>i.baseIndent+i.unit,"TemplateString BlockComment":()=>null,"Statement Property":th({except:/^{/}),JSXElement(i){let e=/^\s*<\//.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},JSXEscape(i){let e=/\s*\}/.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},"JSXOpenTag JSXSelfClosingTag"(i){return i.column(i.node.from)+i.unit}}),b1.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":ex,BlockComment(i){return{from:i.from+2,to:i.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}});var fJ=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent);var TP=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i,so=class{constructor(e,t,n=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=s?a=>s(TP(a)):TP,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Zi(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=hc(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=xn(e);let r=this.normalize(t);for(let s=0,o=n;;s++){let a=r.charCodeAt(s),l=this.match(a,o,this.bufferPos+this.bufferStart);if(s==r.length-1){if(l)return this.value=l,this;break}o==n&&sthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=kh(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(nthis.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=n||r.to<=t){let a=new i(t,e.sliceString(t,n));return eO.set(e,a),a}if(r.from==t&&r.to==n)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let n=this.flat.from+t.index,r=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this.matchPos=kh(this.text,r+(n==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=_h.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(bh.prototype[Symbol.iterator]=wh.prototype[Symbol.iterator]=function(){return this});function RN(i){try{return new RegExp(i,oO),!0}catch{return!1}}function kh(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e=56320&&n<57344;)e++;return e}function tO(i){let e=String(i.state.doc.lineAt(i.state.selection.main.head).number),t=wt("input",{class:"cm-textfield",name:"line",value:e}),n=wt("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),i.dispatch({effects:Sh.of(!1)}),i.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},wt("label",i.state.phrase("Go to line"),": ",t)," ",wt("button",{class:"cm-button",type:"submit"},i.state.phrase("go")));function r(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!s)return;let{state:o}=i,a=o.doc.lineAt(o.selection.main.head),[,l,c,u,f]=s,d=u?+u.slice(1):0,h=c?+c:a.number;if(c&&f){let g=h/100;l&&(g=g*(l=="-"?-1:1)+a.number/o.doc.lines),h=Math.round(o.doc.lines*g)}else c&&l&&(h=h*(l=="-"?-1:1)+a.number);let p=o.doc.line(Math.max(1,Math.min(o.doc.lines,h))),m=le.cursor(p.from+Math.max(0,Math.min(d,p.length)));i.dispatch({effects:[Sh.of(!1),_e.scrollIntoView(m.from,{y:"center"})],selection:m}),i.focus()}return{dom:n}}var Sh=Ze.define(),AP=Xt.define({create(){return!0},update(i,e){for(let t of e.effects)t.is(Sh)&&(i=t.value);return i},provide:i=>Fo.from(i,e=>e?tO:null)}),MN=i=>{let e=Bo(i,tO);if(!e){let t=[Sh.of(!0)];i.state.field(AP,!1)==null&&t.push(Ze.appendConfig.of([AP,IN])),i.dispatch({effects:t}),e=Bo(i,tO)}return e&&e.dom.querySelector("input").select(),!0},IN=_e.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),NN={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},MP=Ee.define({combine(i){return mn(i,NN,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function IP(i){let e=[LN,qN];return i&&e.push(MP.of(i)),e}var jN=Ne.mark({class:"cm-selectionMatch"}),ZN=Ne.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function DP(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=Pt.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=Pt.Word)}function zN(i,e,t,n){return i(e.sliceDoc(t,t+1))==Pt.Word&&i(e.sliceDoc(n-1,n))==Pt.Word}var qN=di.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(MP),{state:t}=i,n=t.selection;if(n.ranges.length>1)return Ne.none;let r=n.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return Ne.none;let l=t.wordAt(r.head);if(!l)return Ne.none;o=t.charCategorizer(r.head),s=t.sliceDoc(l.from,l.to)}else{let l=r.to-r.from;if(l200)return Ne.none;if(e.wholeWords){if(s=t.sliceDoc(r.from,r.to),o=t.charCategorizer(r.head),!(DP(o,t,r.from,r.to)&&zN(o,t,r.from,r.to)))return Ne.none}else if(s=t.sliceDoc(r.from,r.to),!s)return Ne.none}let a=[];for(let l of i.visibleRanges){let c=new so(t.doc,s,l.from,l.to);for(;!c.next().done;){let{from:u,to:f}=c.value;if((!o||DP(o,t,u,f))&&(r.empty&&u<=r.from&&f>=r.to?a.push(ZN.range(u,f)):(u>=r.to||f<=r.from)&&a.push(jN.range(u,f)),a.length>e.maxMatches))return Ne.none}}return Ne.set(a)}},{decorations:i=>i.decorations}),LN=_e.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),$N=({state:i,dispatch:e})=>{let{selection:t}=i,n=le.create(t.ranges.map(r=>i.wordAt(r.head)||le.cursor(r.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function FN(i,e){let{main:t,ranges:n}=i.selection,r=i.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,a=new so(i.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new so(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(l=>l.from==a.value.from))continue;if(s){let l=i.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}var BN=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(s=>s.from===s.to))return $N({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(s=>i.sliceDoc(s.from,s.to)!=n))return!1;let r=FN(i,n);return r?(e(i.update({selection:i.selection.addRange(le.range(r.from,r.to),!1),effects:_e.scrollIntoView(r.to)})),!0):!1},ol=Ee.define({combine(i){return mn(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new sO(e),scrollToMatch:e=>_e.scrollIntoView(e)})}});var xh=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||RN(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?` `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new nO(this):new iO(this)}getCursor(e,t=0,n){let r=e.doc?e:At.create({doc:e});return n==null&&(n=r.doc.length),this.regexp?sl(this,r,t,n):rl(this,r,t,n)}},Ph=class{constructor(e){this.spec=e}};function rl(i,e,t,n){return new so(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:r=>r.toLowerCase(),i.wholeWord?VN(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function VN(i,e){return(t,n,r,s)=>((s>t||s+r.length=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let s=rl(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}};function sl(i,e,t,n){return new bh(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?WN(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function Ch(i,e){return i.slice(ui(i,e,!1),e)}function Eh(i,e){return i.slice(e,ui(i,e))}function WN(i){return(e,t,n)=>!n[0].length||(i(Ch(n.input,n.index))!=Pt.Word||i(Eh(n.input,n.index))!=Pt.Word)&&(i(Eh(n.input,n.index+n[0].length))!=Pt.Word||i(Ch(n.input,n.index+n[0].length))!=Pt.Word)}var nO=class extends Ph{nextMatch(e,t,n){let r=sl(this.spec,e,n,e.doc.length).next();return r.done&&(r=sl(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let s=Math.max(t,n-r*1e4),o=sl(this.spec,e,s,n),a=null;for(;!o.next().done;)a=o.value;if(a&&(s==t||a.from>s+10))return a;if(s==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,n)=>n=="$"?"$":n=="&"?e.match[0]:n!="0"&&+n=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let s=sl(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}},iu=Ze.define(),aO=Ze.define(),ro=Xt.define({create(i){return new tu(rO(i).create(),null)},update(i,e){for(let t of e.effects)t.is(iu)?i=new tu(t.value.create(),i.panel):t.is(aO)&&(i=new tu(i.query,t.value?lO:null));return i},provide:i=>Fo.from(i,e=>e.panel)});var tu=class{constructor(e,t){this.query=e,this.panel=t}},XN=Ne.mark({class:"cm-searchMatch"}),UN=Ne.mark({class:"cm-searchMatch cm-searchMatch-selected"}),YN=di.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(ro))}update(i){let e=i.state.field(ro);(e!=i.startState.field(ro)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return Ne.none;let{view:t}=this,n=new Zr;for(let r=0,s=t.visibleRanges,o=s.length;rs[r+1].from-2*250;)l=s[++r].to;i.highlight(t.state,a,l,(c,u)=>{let f=t.state.selection.ranges.some(d=>d.from==c&&d.to==u);n.add(c,u,f?UN:XN)})}return n.finish()}},{decorations:i=>i.decorations});function nu(i){return e=>{let t=e.state.field(ro,!1);return t&&t.query.spec.valid?i(e,t):ZP(e)}}var Th=nu((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let r=le.single(n.from,n.to),s=i.state.facet(ol);return i.dispatch({selection:r,effects:[cO(i,n),s.scrollToMatch(r.main,i)],userEvent:"select.search"}),jP(i),!0}),Ah=nu((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,r=e.prevMatch(t,n,n);if(!r)return!1;let s=le.single(r.from,r.to),o=i.state.facet(ol);return i.dispatch({selection:s,effects:[cO(i,r),o.scrollToMatch(s.main,i)],userEvent:"select.search"}),jP(i),!0}),HN=nu((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:le.create(t.map(n=>le.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),GN=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:r}=t.main,s=[],o=0;for(let a=new so(i.doc,i.sliceDoc(n,r));!a.next().done;){if(s.length>1e3)return!1;a.value.from==n&&(o=s.length),s.push(le.range(a.value.from,a.value.to))}return e(i.update({selection:le.create(s,o),userEvent:"select.search.matches"})),!0},QP=nu((i,{query:e})=>{let{state:t}=i,{from:n,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,n,n);if(!s)return!1;let o=[],a,l,c=[];if(s.from==n&&s.to==r&&(l=t.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:l}),s=e.nextMatch(t,s.from,s.to),c.push(_e.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+"."))),s){let u=o.length==0||o[0].from>=s.to?0:s.to-s.from-l.length;a=le.single(s.from-u,s.to-u),c.push(cO(i,s)),c.push(t.facet(ol).scrollToMatch(a.main,i))}return i.dispatch({changes:o,selection:a,effects:c,userEvent:"input.replace"}),!0}),KN=nu((i,{query:e})=>{if(i.state.readOnly)return!1;let t=e.matchAll(i.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!t.length)return!1;let n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:_e.announce.of(n),userEvent:"input.replace.all"}),!0});function lO(i){return i.state.facet(ol).createPanel(i)}function rO(i,e){var t,n,r,s,o;let a=i.selection.main,l=a.empty||a.to>a.from+100?"":i.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=i.facet(ol);return new xh({search:((t=e?.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(n=e?.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:c.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function NP(i){let e=Bo(i,lO);return e&&e.dom.querySelector("[main-field]")}function jP(i){let e=NP(i);e&&e==i.root.activeElement&&e.select()}var ZP=i=>{let e=i.state.field(ro,!1);if(e&&e.panel){let t=NP(i);if(t&&t!=i.root.activeElement){let n=rO(i.state,e.query.spec);n.valid&&i.dispatch({effects:iu.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[aO.of(!0),e?iu.of(rO(i.state,e.query.spec)):Ze.appendConfig.of(e9)]});return!0},zP=i=>{let e=i.state.field(ro,!1);if(!e||!e.panel)return!1;let t=Bo(i,lO);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:aO.of(!1)}),!0},qP=[{key:"Mod-f",run:ZP,scope:"editor search-panel"},{key:"F3",run:Th,shift:Ah,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Th,shift:Ah,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:zP,scope:"editor search-panel"},{key:"Mod-Shift-l",run:GN},{key:"Mod-Alt-g",run:MN},{key:"Mod-d",run:BN,preventDefault:!0}],sO=class{constructor(e){this.view=e;let t=this.query=e.state.field(ro).query.spec;this.commit=this.commit.bind(this),this.searchField=wt("input",{value:t.search,placeholder:Tn(e,"Find"),"aria-label":Tn(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=wt("input",{value:t.replace,placeholder:Tn(e,"Replace"),"aria-label":Tn(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=wt("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=wt("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=wt("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(r,s,o){return wt("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=wt("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,n("next",()=>Th(e),[Tn(e,"next")]),n("prev",()=>Ah(e),[Tn(e,"previous")]),n("select",()=>HN(e),[Tn(e,"all")]),wt("label",null,[this.caseField,Tn(e,"match case")]),wt("label",null,[this.reField,Tn(e,"regexp")]),wt("label",null,[this.wordField,Tn(e,"by word")]),...e.state.readOnly?[]:[wt("br"),this.replaceField,n("replace",()=>QP(e),[Tn(e,"replace")]),n("replaceAll",()=>KN(e),[Tn(e,"replace all")])],wt("button",{name:"close",onclick:()=>zP(e),"aria-label":Tn(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new xh({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:iu.of(e)}))}keydown(e){bS(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Ah:Th)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),QP(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(iu)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ol).top}};function Tn(i,e){return i.state.phrase(e)}var vh=30,yh=/[\s\.,:;?!]/;function cO(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),r=i.state.doc.lineAt(t).to,s=Math.max(n.from,e-vh),o=Math.min(r,t+vh),a=i.state.sliceDoc(s,o);if(s!=n.from){for(let l=0;la.length-vh;l--)if(!yh.test(a[l-1])&&yh.test(a[l])){a=a.slice(0,l);break}}return _e.announce.of(`${i.state.phrase("current match")}. ${a} ${i.state.phrase("on line")} ${n.number}.`)}var JN=_e.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),e9=[ro,hr.low(YN),JN];var uO=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},Ko=class i{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=e,s=n.facet(VP).markerFilter;s&&(r=s(r,n));let o=Ne.set(r.map(a=>a.from==a.to||a.from==a.to-1&&n.doc.lineAt(a.from).to==a.from?Ne.widget({widget:new fO(a),diagnostic:a}).range(a.from):Ne.mark({attributes:{class:"cm-lintRange cm-lintRange-"+a.severity+(a.markClass?" "+a.markClass:"")},diagnostic:a,inclusive:!0}).range(a.from,a.to)),!0);return new i(o,t,al(o))}};function al(i,e=null,t=0){let n=null;return i.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return n=new uO(r,s,o.diagnostic),!1}),n}function t9(i,e){let t=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(n=>n.is($P))||i.changes.touchesRange(t.from,t.to))}function i9(i,e){return i.field(An,!1)?e:e.concat(Ze.appendConfig.of(u9))}var $P=Ze.define(),dO=Ze.define(),FP=Ze.define(),An=Xt.define({create(){return new Ko(Ne.none,null,null)},update(i,e){if(e.docChanged){let t=i.diagnostics.map(e.changes),n=null;if(i.selected){let r=e.changes.mapPos(i.selected.from,1);n=al(t,i.selected.diagnostic,r)||al(t,null,r)}i=new Ko(t,i.panel,n)}for(let t of e.effects)t.is($P)?i=Ko.init(t.value,i.panel,e.state):t.is(dO)?i=new Ko(i.diagnostics,t.value?Rh.open:null,i.selected):t.is(FP)&&(i=new Ko(i.diagnostics,i.panel,t.value));return i},provide:i=>[Fo.from(i,e=>e.panel),_e.decorations.from(i,e=>e.diagnostics)]});var n9=Ne.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function r9(i,e,t){let{diagnostics:n}=i.state.field(An),r=[],s=2e8,o=0;n.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:u})=>{e>=l&&e<=c&&(l==c||(e>l||t>0)&&(eXP(i,t,!1)))}var o9=i=>{let e=i.state.field(An,!1);(!e||!e.panel)&&i.dispatch({effects:i9(i.state,[dO.of(!0)])});let t=Bo(i,Rh.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},LP=i=>{let e=i.state.field(An,!1);return!e||!e.panel?!1:(i.dispatch({effects:dO.of(!1)}),!0)},a9=i=>{let e=i.state.field(An,!1);if(!e)return!1;let t=i.state.selection.main,n=e.diagnostics.iter(t.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==t.from&&n.to==t.to)?!1:(i.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)};var BP=[{key:"Mod-Shift-m",run:o9,preventDefault:!0},{key:"F8",run:a9}];var VP=Ee.define({combine(i){return Object.assign({sources:i.map(e=>e.source).filter(e=>e!=null)},mn(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))}});function WP(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;ns.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function XP(i,e,t){var n;let r=t?WP(e.actions):[];return wt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},wt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(n=e.actions)===null||n===void 0?void 0:n.map((s,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let h=al(i.state.field(An).diagnostics,e);h&&s.apply(i,h.from,h.to)},{name:c}=s,u=r[o]?c.indexOf(r[o]):-1,f=u<0?c:[c.slice(0,u),wt("u",c.slice(u,u+1)),c.slice(u+1)];return wt("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&wt("div",{class:"cm-diagnosticSource"},e.source))}var fO=class extends pr{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return wt("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},Qh=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=XP(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Rh=class i{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)LP(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=WP(s.actions);for(let a=0;a{for(let s=0;sLP(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(An).selected;if(!e)return-1;for(let t=0;t{let c=-1,u;for(let f=n;fn&&(this.items.splice(n,c-n),r=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),s=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),n++});n({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:a})=>{let l=a.height/this.list.offsetHeight;o.topa.bottom&&(this.list.scrollTop+=(o.bottom-a.bottom)/l)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(An),n=al(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:FP.of(n)})}static open(e){return new i(e)}};function l9(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(i)}')`}function Dh(i){return l9(``,'width="6" height="3"')}var c9=_e.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Dh("#d11")},".cm-lintRange-warning":{backgroundImage:Dh("orange")},".cm-lintRange-info":{backgroundImage:Dh("#999")},".cm-lintRange-hint":{backgroundImage:Dh("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});var u9=[An,_e.decorations.compute([An],i=>{let{selected:e,panel:t}=i.field(An);return!e||!t||e.from==e.to?Ne.none:Ne.set([n9.range(e.from,e.to)])}),TS(r9,{hideOn:t9}),c9];var Mh=[EP,lx(),SS(),CS(),JS(),el(ux,{fallback:!0}),_e.lineWrapping,px(),wP(),CP(),ES(),IP(),Nc.of([...xP,...Jx,...qP,...Px,eP,...sx,...J1,...BP])].filter(i=>i);var f9="#abb2bf",d9="#7d8799",h9="#ffffff",p9="#21252b",hO="rgba(0, 0, 0, 0.5)",m9="#292d3e",pO="#353a42",g9="rgba(128, 203, 196, 0.2)",UP="#ffcc00",O9=_e.theme({"&":{color:"#ffffff",backgroundColor:m9},".cm-content":{caretColor:UP},"&.cm-focused .cm-cursor":{borderLeftColor:UP},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:g9},".cm-panels":{backgroundColor:p9,color:"#ffffff"},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:hO},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847",outline:"1px solid #515a6b"},".cm-gutters":{background:"#292d3e",color:"#676e95",border:"none"},".cm-activeLineGutter":{backgroundColor:hO},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:pO},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:pO,borderBottomColor:pO},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:hO,color:f9}}},{dark:!0}),v9=eo.define([{tag:L.keyword,color:"#c792ea"},{tag:L.operator,color:"#89ddff"},{tag:L.special(L.variableName),color:"#eeffff"},{tag:L.typeName,color:"#f07178"},{tag:L.atom,color:"#f78c6c"},{tag:L.number,color:"#ff5370"},{tag:L.definition(L.variableName),color:"#82aaff"},{tag:L.string,color:"#c3e88d"},{tag:L.special(L.string),color:"#f07178"},{tag:L.comment,color:d9},{tag:L.variableName,color:"#f07178"},{tag:L.tagName,color:"#ff5370"},{tag:L.bracket,color:"#a2a1a4"},{tag:L.meta,color:"#ffcb6b"},{tag:L.attributeName,color:"#c792ea"},{tag:L.propertyName,color:"#c792ea"},{tag:L.className,color:"#decb6b"},{tag:L.invalid,color:h9}]),YP=[O9,el(v9)];var HP="#2e3440",bO="#3b4252",GP="#434c5e",Ih="#4c566a";var KP="#e5e9f0",yO="#eceff4",mO="#8fbcbb",JP="#88c0d0",y9="#81a1c1",br="#5e81ac",b9="#bf616a",ll="#d08770",gO="#ebcb8b",e4="#a3be8c",_9="#b48ead",t4="#d30102",_O=yO,OO=_O,w9="#ffffff",vO=bO,k9=_O,i4=bO,wO=_e.theme({"&":{color:HP,backgroundColor:w9},".cm-content":{caretColor:i4},".cm-cursor, .cm-dropCursor":{borderLeftColor:i4},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:k9},".cm-panels":{backgroundColor:_O,color:Ih},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${Ih}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:KP},".cm-activeLine":{backgroundColor:OO},".cm-selectionMatch":{backgroundColor:KP},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${Ih}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:yO},".cm-gutters":{backgroundColor:yO,color:HP,border:"none"},".cm-activeLineGutter":{backgroundColor:OO},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:vO},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:vO,borderBottomColor:vO},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:OO,color:Ih}}},{dark:!1}),S9=eo.define([{tag:L.keyword,color:br},{tag:[L.name,L.deleted,L.character,L.propertyName,L.macroName],color:ll},{tag:[L.variableName],color:ll},{tag:[L.function(L.variableName)],color:br},{tag:[L.labelName],color:y9},{tag:[L.color,L.constant(L.name),L.standard(L.name)],color:br},{tag:[L.definition(L.name),L.separator],color:e4},{tag:[L.brace],color:mO},{tag:[L.annotation],color:t4},{tag:[L.number,L.changed,L.annotation,L.modifier,L.self,L.namespace],color:JP},{tag:[L.typeName,L.className],color:gO},{tag:[L.operator,L.operatorKeyword],color:e4},{tag:[L.tagName],color:_9},{tag:[L.squareBracket],color:b9},{tag:[L.angleBracket],color:ll},{tag:[L.attributeName],color:gO},{tag:[L.regexp],color:br},{tag:[L.quote],color:bO},{tag:[L.string],color:ll},{tag:L.link,color:mO,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[L.url,L.escape,L.special(L.string)],color:ll},{tag:[L.meta],color:JP},{tag:[L.comment],color:GP,fontStyle:"italic"},{tag:L.strong,fontWeight:"bold",color:br},{tag:L.emphasis,fontStyle:"italic",color:br},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.heading,fontWeight:"bold",color:br},{tag:L.special(L.heading1),fontWeight:"bold",color:br},{tag:L.heading1,fontWeight:"bold",color:br},{tag:[L.heading2,L.heading3,L.heading4],fontWeight:"bold",color:br},{tag:[L.heading5,L.heading6],color:br},{tag:[L.atom,L.bool,L.special(L.variableName)],color:ll},{tag:[L.processingInstruction,L.inserted],color:mO},{tag:[L.contentSeparator],color:gO},{tag:L.invalid,color:GP,borderBottom:`1px dotted ${t4}`}]),zJ=[wO,el(S9)];function n4(i,e){document.body.hasClass("theme-dark")?Mh.push(YP):Mh.push(wO);let t=[...Mh];e&&t.push(e);let n=new _e({state:At.create({doc:i.value,extensions:t})});return i.parentNode.appendChild(n.dom),i.style.display="none",i.form&&i.form.addEventListener("submit",()=>{i.value=n.state.doc.toString()}),n}var Nh=class extends Kr.Modal{constructor(){super(...arguments);J(this,"header");J(this,"editing");J(this,"editor");J(this,"canceled",!1)}onOpen(){this.titleEl.setText(this.editing?"Edit Header":"Create Header"),this.display()}display(){if(this.contentEl.empty(),new Kr.Setting(this.contentEl).setName("Display Text").addText(t=>t.setValue(this.header.text).onChange(n=>{this.header.text=n})),new Kr.Setting(this.contentEl).setName("Linked Property").addText(t=>t.setValue(this.header.field).onChange(n=>this.header.field=n)),new Kr.Setting(this.contentEl).setName("Sort Type").setDesc("This determines how the field is sorted. Use the appropriate type for the data type of the field.").addDropdown(t=>{t.addOption("0","String"),t.addOption("1","Number"),t.addOption("2","Custom"),t.setValue(`${this.header.type}`).onChange(n=>{this.header.type=Number(n),this.header.type==2?this.header.func="":delete this.header.func,this.display()})}),"func"in this.header){new Kr.Setting(this.contentEl).setName("Custom Sorting Function").setDesc(createFragment(n=>{n.createSpan({text:"Specify a custom sorting JavaScript function."}),n.createEl("br"),n.createEl("br"),n.createSpan({text:"This function receives two monster objects, "}),n.createEl("code",{text:"a"}),n.createSpan({text:" and "}),n.createEl("code",{text:"b"}),n.createSpan({text:", and must return a number. The number determines sort order."})}));let t=new Kr.TextAreaComponent(this.contentEl).setValue(this.header.func);t.inputEl.addClass("initiative-tracker-textarea"),this.editor=n4(t.inputEl,_e.updateListener.of(n=>{n.docChanged&&(this.header.func=n.state.doc.toString())}))}new Kr.Setting(this.contentEl).addButton(t=>{t.setButtonText("Cancel").setCta().onClick(()=>{this.canceled=!0,this.close()})})}close(){this.editor?.destroy(),super.close()}};function x9(i){se(i,"svelte-1s0cntl",".header-container.svelte-1s0cntl{margin:0 0.5rem}.header.svelte-1s0cntl .header-desc{display:flex;align-items:center;gap:0.25rem}.header.svelte-1s0cntl .header-desc *:has(svg){display:flex;align-items:center}.cancel-button.svelte-1s0cntl{display:flex;justify-content:flex-end}")}function r4(i,e,t){let n=i.slice();return n[13]=e[t],n}function s4(i,e){let t,n,r,s,o,a=X,l,c;return{key:i,first:null,c(){t=b("div"),n=b("div"),s=M(),v(n,"class","header svelte-1s0cntl"),this.first=t},m(u,f){A(u,t,f),y(t,n),y(t,s),l||(c=H(r=e[5].call(null,n,e[13])),l=!0)},p(u,f){e=u,r&&Ge(r.update)&&f&1&&r.update.call(null,e[13])},r(){o=t.getBoundingClientRect()},f(){Qr(t),a()},a(){a(),a=Dr(t,o,jr,{duration:kO})},d(u){u&&T(t),l=!1,c()}}}function P9(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p=[],m=new Map,g,O,w,S,C,k,_,P=fe(i[0]),x=R=>R[13].id;for(let R=0;ROrganize your headers here. Headers can be drag-and-dropped!",l=M(),c=b("div"),u=b("div"),d=M(),h=b("section");for(let R=0;R{let O=new Nh(app);return O.header=g??$s.defaultState,g&&(O.editing=!0),O.open(),new Promise(w=>{O.onClose=()=>{O.canceled?w():w(O.header)}})},c=g=>{switch(g){case 0:return Np;case 1:return jp;case 2:return"function-square"}},u=g=>{new Jr.Setting(g).setName(createFragment(O=>{let w=O.createDiv("header-desc");(0,Jr.setIcon)(w.createDiv(),c(ac.type)),w.createSpan({text:ac.text})})).setDesc(createFragment(O=>{O.createEl("em",{text:ac.field})}))},f=(g,O)=>{let{header:w,id:S}=O;new Jr.Setting(g).setName(createFragment(C=>{let k=C.createDiv("header-desc");(0,Jr.setIcon)(k.createDiv(),c(w.type)),k.createSpan({text:w.text})})).setDesc(createFragment(C=>{C.createEl("em",{text:w.field})})).addExtraButton(C=>{C.setIcon("edit").onClick(async()=>{let k=await l(w);k&&k.text?.length&&k.field?.length&&(k.type!=2||k?.func?.length)&&(s.splice(s.findIndex(_=>_.id==S),1,{id:xt(),header:k}),t(0,s))})}).addExtraButton(C=>C.setIcon("trash").onClick(()=>{t(0,s=s.filter(k=>k.id!=S))}))},d=g=>{new Jr.Setting(g).setName("Add Header").addExtraButton(O=>O.setIcon("plus-circle").onClick(async()=>{let w=await l();w&&w.text?.length&&w.field?.length&&(w.type!=2||w?.func?.length)&&(s.push({id:xt(),header:w}),t(0,s))}))},h=g=>{new Jr.Setting(g).setName("Reset Headers").setDesc("Reset table headers to defaults.").addExtraButton(O=>O.setIcon("reset").onClick(()=>{n("reset")}))},p=g=>{new Jr.ButtonComponent(g).setButtonText("Cancel").setCta()},m=()=>n("cancel");return i.$$set=g=>{"headers"in g&&t(9,r=g.headers)},i.$$.update=()=>{i.$$.dirty&1&&n("update",s.reduce((g,O)=>(g.push(O.header),g),[]))},[s,n,o,a,u,f,d,h,p,r,m]}var SO=class extends ne{constructor(e){super(),re(this,e,C9,P9,ie,{headers:9},x9)}},o4=SO;var jh=class extends a4.Modal{constructor(t){super(app);this.headers=t;J(this,"canceled",!1);J(this,"reset",!1)}onOpen(){this.titleEl.setText("Edit Headers");let t=new o4({target:this.contentEl,props:{headers:ci(this.headers)}});t.$on("update",n=>{this.headers=ci(n.detail)}),t.$on("cancel",()=>{this.canceled=!0,this.close()}),t.$on("reset",()=>{this.reset=!0,this.close()})}};var QO=require("obsidian");var bs=require("obsidian");function E9(i){se(i,"svelte-n90cbf",".filter-container.svelte-n90cbf.svelte-n90cbf{flex-grow:1;flex-basis:0;display:grid;grid-template-columns:1fr auto;gap:0.5rem;align-items:center}.filter-container.svelte-n90cbf:hover .context.svelte-n90cbf{opacity:1}.name-container.svelte-n90cbf.svelte-n90cbf{display:flex;flex-flow:row nowrap;gap:0.5rem;align-items:center}.description-container.svelte-n90cbf.svelte-n90cbf{display:flex;align-items:center;gap:0.25rem;--icon-size:14px}.icon.svelte-n90cbf.svelte-n90cbf{display:flex;align-items:center}.warning-icon.svelte-n90cbf.svelte-n90cbf{color:var(--text-error)}.context.svelte-n90cbf.svelte-n90cbf{opacity:0;transition:opacity 0.25s;display:flex;align-items:center;gap:0.25rem}")}function T9(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","icon svelte-n90cbf")},m(s,o){A(s,e,o),n||(r=H(t=i[9].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function A9(i){let e,t,n,r,s,o;return{c(){e=b("div"),n=M(),r=b("span"),r.textContent="No fields",v(e,"class","warning-icon icon svelte-n90cbf"),v(r,"class","warning-icon svelte-n90cbf")},m(a,l){A(a,e,l),A(a,n,l),A(a,r,l),s||(o=H(t=i[8].call(null,e)),s=!0)},p:X,d(a){a&&(T(e),T(n),T(r)),s=!1,o()}}}function D9(i){let e=i[3].fields.join(", ")+"",t;return{c(){t=ae(e)},m(n,r){A(n,t,r)},p:X,d(n){n&&T(t)}}}function Q9(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,w,S,C,k,_,P=i[3].derive&&T9(i);function x(Q,D){return Q[3].fields.length?D9:A9}let Z=x(i,-1)(i);return{c(){e=b("div"),t=b("div"),n=b("div"),r=b("div"),o=M(),a=b("div"),l=b("span"),l.textContent=`${i[3].text}`,c=M(),u=b("div"),f=b("small"),d=b("em"),P&&P.c(),h=M(),Z.c(),p=M(),m=b("div"),g=b("div"),w=M(),S=b("div"),v(r,"class","icon svelte-n90cbf"),v(a,"class","text"),v(n,"class","name-container svelte-n90cbf"),v(d,"class","description-container svelte-n90cbf"),v(t,"class","filter"),v(g,"class","icon svelte-n90cbf"),v(S,"class","icon svelte-n90cbf"),v(m,"class","context svelte-n90cbf"),v(e,"class","filter-container svelte-n90cbf")},m(Q,D){A(Q,e,D),y(e,t),y(t,n),y(n,r),y(n,o),y(n,a),y(a,l),y(t,c),y(t,u),y(u,f),y(f,d),P&&P.m(d,null),y(d,h),Z.m(d,null),y(e,p),y(e,m),y(m,g),y(m,w),y(m,S),k||(_=[H(s=i[4].call(null,r)),H(O=i[5].call(null,g)),U(g,"click",i[10]),H(C=i[7].call(null,S)),U(S,"click",i[11])],k=!0)},p(Q,[D]){Z.p(Q,D)},i:X,o:X,d(Q){Q&&T(e),P&&P.d(),Z.d(),k=!1,de(_)}}}function R9(i,e,t){let n,r=Fe(),s=Ue("filterStore"),{filters:o}=s;Se(i,o,O=>t(12,n=O));let{id:a}=e,l=n.get(a).filter,c=O=>{switch(l.type){case 0:return(0,bs.setIcon)(O,"sliders-horizontal");case 1:return(0,bs.setIcon)(O,"search");case 2:return(0,bs.setIcon)(O,"list")}},u=O=>{new bs.ExtraButtonComponent(O).setIcon("pencil")},f=()=>{let O=new Zh(l);O.onClose=()=>{O.canceled||(s.update(l.id,O.filter),r("edit"))},O.open()},d=O=>{new bs.ExtraButtonComponent(O).setIcon("trash")},h=O=>{(0,bs.setIcon)(O,"alert-triangle")},p=O=>{(0,bs.setIcon)(O,"package-search")},m=()=>f(),g=()=>r("deleted",a);return i.$$set=O=>{"id"in O&&t(0,a=O.id)},[a,r,o,l,c,u,f,d,h,p,m,g]}var xO=class extends ne{constructor(e){super(),re(this,e,R9,Q9,ie,{id:0},E9)}},l4=xO;function M9(i){se(i,"svelte-1l1v7ik","section.svelte-1l1v7ik{padding:0.4em;overflow-y:auto;height:auto;width:100%}section.inline.svelte-1l1v7ik{display:flex;justify-content:space-between;flex-flow:row;gap:0.5rem}")}function c4(i,e,t){let n=i.slice();return n[10]=e[t],n}function I9(i){let e,t;return e=new l4({props:{id:i[1].id}}),e.$on("deleted",i[9]),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p(n,r){let s={};r&2&&(s.id=n[1].id),e.$set(s)},i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function N9(i){let e,t=[],n=new Map,r,s,o,a,l=fe(i[1].nested.filter(i[7])),c=u=>u[10].id;for(let u=0;u{o[u]=null}),De(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),$(t,1),t.m(n.parentNode,n))},i(l){r||($(t),r=!0)},o(l){V(t),r=!1},d(l){l&&T(n),o[e].d(l)}}}var PO=300;function Z9(i,e,t){let{layout:n}=e,{block:r}=e,{inline:s=!1}=e,o=Fe();function a(h){r.type=="nested"&&t(1,r.nested=h.detail.items,r)}function l(h){r.type=="nested"&&t(1,r.nested=h.detail.items,r),t(0,n=[...n]),o("update")}let c=h=>{r.type!="filter"&&(t(1,r.nested=r.nested.filter(p=>p.id!=h),r),t(0,n=[...n]),o("update"))},u=h=>h.id!==ec,f=h=>c(h.detail),d=h=>o("deleted",h.detail);return i.$$set=h=>{"layout"in h&&t(0,n=h.layout),"block"in h&&t(1,r=h.block),"inline"in h&&t(2,s=h.inline)},[n,r,s,o,a,l,c,u,f,d]}var zh=class extends ne{constructor(e){super(),re(this,e,Z9,j9,ie,{layout:0,block:1,inline:2},M9)}},f4=zh;var ru=require("obsidian");function d4(i,e,t){let n=i.slice();return n[11]=e[t],n}function h4(i){let e,t;return e=new f4({props:{layout:i[0],block:i[11],inline:!0}}),e.$on("update",i[8]),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p(n,r){let s={};r&1&&(s.layout=n[0]),r&1&&(s.block=n[11]),e.$set(s)},i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function p4(i){let e,t,n=fe(i[0]),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;ot(7,r=p));let l=Fe();Vi("filterStore",s),a.subscribe(()=>{n&&t(0,n=[...n])});let c=p=>{new ru.Setting(p).setName("Restore Default Layout").addExtraButton(m=>{m.setIcon("reset").onClick(()=>{s.resetLayout(!0)})})},u=p=>{new ru.Setting(p).setName("Add New Filter").addExtraButton(m=>{m.setIcon("plus-circle").onClick(()=>{let g=xt(),O={...lg,id:g};n.push({type:"nested",id:xt(),nested:[{type:"filter",id:g}]}),s.add(O)})})},f=p=>{new ru.ButtonComponent(p).setButtonText("Cancel").setCta()},d=()=>l("update",n),h=()=>l("cancel");return i.$$set=p=>{"filterStore"in p&&t(6,s=p.filterStore)},i.$$.update=()=>{i.$$.dirty&128&&t(0,n=ci(r)),i.$$.dirty&1&&l("update",n)},[n,o,l,c,u,f,s,r,d,h]}var CO=class extends ne{constructor(e){super(),re(this,e,q9,z9,ie,{filterStore:6})}},m4=CO;var Bn=require("obsidian");var v4=require("obsidian");function L9(i){se(i,"svelte-1uki7d6",".draggable-fields.svelte-1uki7d6{margin:0 1rem}")}function g4(i,e,t){let n=i.slice();return n[8]=e[t],n}function O4(i,e){let t,n,r,s,o,a=X,l,c;return{key:i,first:null,c(){t=b("div"),n=b("div"),s=M(),v(n,"class","draggable-field"),this.first=t},m(u,f){A(u,t,f),y(t,n),y(t,s),l||(c=H(r=e[3].call(null,n,e[8])),l=!0)},p(u,f){e=u,r&&Ge(r.update)&&f&1&&r.update.call(null,e[8])},r(){o=t.getBoundingClientRect()},f(){Qr(t),a()},a(){a(),a=Dr(t,o,jr,{duration:EO})},d(u){u&&T(t),l=!1,c()}}}function $9(i){let e,t=[],n=new Map,r,s,o,a=fe(i[0].filter(i[6])),l=c=>c[8].id;for(let c=0;cd.field))}let l=(f,d)=>{let{field:h,id:p}=d;new v4.Setting(f).setName(h).addExtraButton(m=>m.setIcon("trash").onClick(()=>{t(0,s=s.filter(g=>g.id!=p)),r("update",s.map(g=>g.field))}))},c=xt(),u=({id:f})=>f!=ec;return i.$$set=f=>{"fields"in f&&t(5,n=f.fields)},[s,o,a,l,c,n,u]}var TO=class extends ne{constructor(e){super(),re(this,e,F9,$9,ie,{fields:5},L9)}},AO=TO;function y4(i){let e,t,n,r,s=[V9,B9],o=[];function a(l,c){return l[0].type==0?0:l[0].type==2?1:-1}return~(e=a(i,-1))&&(t=o[e]=s[e](i)),{c(){t&&t.c(),n=tt()},m(l,c){~e&&o[e].m(l,c),A(l,n,c),r=!0},p(l,c){let u=e;e=a(l,c),e===u?~e&&o[e].p(l,c):(t&&(Ae(),V(o[u],1,1,()=>{o[u]=null}),De()),~e?(t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),$(t,1),t.m(n.parentNode,n)):t=null)},i(l){r||($(t),r=!0)},o(l){V(t),r=!1},d(l){l&&T(n),~e&&o[e].d(l)}}}function B9(i){let e,t,n,r,s,o,a;return r=new AO({props:{fields:i[0].options}}),r.$on("update",i[17]),{c(){e=b("div"),n=M(),ye(r.$$.fragment)},m(l,c){A(l,e,c),A(l,n,c),Oe(r,l,c),s=!0,o||(a=H(t=i[9].call(null,e)),o=!0)},p(l,c){let u={};c&1&&(u.fields=l[0].options),r.$set(u)},i(l){s||($(r.$$.fragment,l),s=!0)},o(l){V(r.$$.fragment,l),s=!1},d(l){l&&(T(e),T(n)),ve(r,l),o=!1,a()}}}function V9(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[11].call(null,e)),n=!0)},p:X,i:X,o:X,d(s){s&&T(e),n=!1,r()}}}function b4(i){let e,t,n,r,s,o,a,l,c;e=new AO({props:{fields:i[0].fields}}),e.$on("update",i[16]);let u=!i[0].derive&&y4(i);return{c(){ye(e.$$.fragment),t=M(),n=b("div"),s=M(),u&&u.c(),o=tt()},m(f,d){Oe(e,f,d),A(f,t,d),A(f,n,d),A(f,s,d),u&&u.m(f,d),A(f,o,d),a=!0,l||(c=H(r=i[8].call(null,n)),l=!0)},p(f,d){let h={};d&1&&(h.fields=f[0].fields),e.$set(h),f[0].derive?u&&(Ae(),V(u,1,1,()=>{u=null}),De()):u?(u.p(f,d),d&1&&$(u,1)):(u=y4(f),u.c(),$(u,1),u.m(o.parentNode,o))},i(f){a||($(e.$$.fragment,f),$(u),a=!0)},o(f){V(e.$$.fragment,f),V(u),a=!1},d(f){f&&(T(t),T(n),T(s),T(o)),ve(e,f),u&&u.d(f),l=!1,c()}}}function W9(i){let e,t,n,r,s,o,a,l,c,u,f,d,h=i[0],p,m,g,O,w,S,C,k=b4(i);return{c(){e=b("div"),n=M(),r=b("div"),o=M(),a=b("div"),c=M(),u=b("div"),d=M(),k.c(),p=M(),m=b("div"),g=b("div"),v(m,"class","cancel-button")},m(_,P){A(_,e,P),A(_,n,P),A(_,r,P),A(_,o,P),A(_,a,P),A(_,c,P),A(_,u,P),A(_,d,P),k.m(_,P),A(_,p,P),A(_,m,P),y(m,g),w=!0,S||(C=[H(t=i[2].call(null,e)),H(s=i[3].call(null,r)),H(l=i[4].call(null,a)),H(f=i[6].call(null,u)),H(O=i[12].call(null,g)),U(g,"click",i[18])],S=!0)},p(_,[P]){P&1&&ie(h,h=_[0])?(Ae(),V(k,1,1,X),De(),k=b4(_),k.c(),$(k,1),k.m(p.parentNode,p)):k.p(_,P)},i(_){w||($(k),w=!0)},o(_){V(k),w=!1},d(_){_&&(T(e),T(n),T(r),T(o),T(a),T(c),T(u),T(d),T(p),T(m)),k.d(_),S=!1,de(C)}}}function X9(i,e,t){let n,{filter:r}=e,{original:s}=e,o=Fe(),a=_=>{new Bn.Setting(_).setName("Reset").addExtraButton(P=>{P.setIcon("reset").onClick(()=>{t(0,r=ci(s))})})},l=_=>{new Bn.Setting(_).setName("Filter Type").addDropdown(P=>{P.addOption("0","Range"),P.addOption("2","Options"),P.addOption("1","Search"),P.setValue(`${r.type}`).onChange(x=>{switch(t(0,r.type=Number(x),r),r.type){case 0:t(0,r.options=[0,0],r);break;case 1:t(0,r.options="",r);break;case 2:t(0,r.options=[],r);break}})})},c=_=>{new Bn.Setting(_).setName("Display Text").addText(P=>{P.setValue(r.text).onChange(x=>t(0,r.text=x,r))})},u=$e(""),f;Se(i,u,_=>t(15,n=_));let d=_=>{let P=r,x;new Bn.Setting(_).setName("Fields").addText(R=>{x=R.onChange(Z=>Ke(u,n=Z,n))}).addExtraButton(R=>t(14,f=R.setIcon("plus-circle").onClick(()=>{if(P.fields.includes(n)){new Bn.Notice(createFragment(Z=>{Z.createSpan({text:"The field "}),Z.createEl("code",{text:n}),Z.createSpan(" has already been added to the options for this filter.")}));return}P.fields=[...P.fields,n],t(0,r={...r}),Ke(u,n="",n),x.setValue(n)})))},h=_=>{t(0,r.fields=_,r)},p=_=>{r.type!=1&&new Bn.Setting(_).setName("Derive Options").addToggle(P=>{P.setValue(r.derive).onChange(x=>t(0,r.derive=x,r))})},m=_=>{new Bn.Setting(_).setName("Options").addText(P=>P).addExtraButton(P=>P.setIcon("plus-circle"))},g=_=>{t(0,r.options=_,r)},O=_=>{if(r.type!=0)return;let P=r;new Bn.Setting(_).setName("Options").addText(x=>x.setValue(`${P.options[0]}`).onChange(R=>P.options[0]=Number(R)).inputEl.type="number").addText(x=>x.setValue(`${P.options[1]}`).onChange(R=>P.options[1]=Number(R)).inputEl.type="number")},w=_=>{new Bn.ButtonComponent(_).setButtonText("Cancel").setCta()},S=_=>h(_.detail),C=_=>g(_.detail),k=()=>o("cancel");return i.$$set=_=>{"filter"in _&&t(0,r=_.filter),"original"in _&&t(13,s=_.original)},i.$$.update=()=>{i.$$.dirty&49152&&f?.setDisabled(!n?.length),i.$$.dirty&1&&o("update",r)},[r,o,a,l,c,u,d,h,p,m,g,O,w,s,f,n,S,C,k]}var DO=class extends ne{constructor(e){super(),re(this,e,X9,W9,ie,{filter:0,original:13})}},_4=DO;var qh=class extends QO.Modal{constructor(t,n){super(app);this.filterStore=n;J(this,"canceled",!1);J(this,"reset",!1);J(this,"layout");this.layout=ci(t)}onOpen(){this.titleEl.setText("Edit Filters");let t=new m4({target:this.contentEl,props:{filterStore:this.filterStore}});t.$on("update",n=>{this.layout=ci(n.detail)}),t.$on("cancel",()=>{this.canceled=!0,this.close()})}},Zh=class extends QO.Modal{constructor(t){super(app);this.original=t;J(this,"canceled",!1);J(this,"filter");this.filter=ci(t)}onOpen(){this.titleEl.setText("Edit Filter");let t=new _4({target:this.contentEl,props:{filter:this.filter,original:this.original}});t.$on("update",n=>{this.filter=n.detail}),t.$on("cancel",n=>{this.canceled=!0,this.close()})}};var X3=Dp(z3());var q3={$ref:"#/definitions/BuilderState",$schema:"http://json-schema.org/draft-07/schema#",definitions:{BuilderState:{additionalProperties:!1,properties:{filters:{additionalProperties:!1,properties:{filters:{items:{$ref:"#/definitions/Filter"},type:"array"},layout:{$ref:"#/definitions/FilterLayout"}},required:["layout","filters"],type:"object"},headers:{items:{$ref:"#/definitions/TableHeaderState"},type:"array"},showParty:{type:"boolean"},showXP:{type:"boolean"},sidebarIcon:{type:"boolean"}},required:["sidebarIcon","showXP","showParty"],type:"object"},Filter:{additionalProperties:!1,properties:{derive:{type:"boolean"},fields:{items:{type:"string"},type:"array"},id:{type:"string"},options:{type:["string","number","boolean","integer","object","array"]},text:{type:"string"},type:{type:"number"}},required:["derive","fields","id","options","text","type"],type:"object"},FilterLayout:{items:{$ref:"#/definitions/NestedFilterLayoutItem"},type:"array"},FilterLayoutItem:{additionalProperties:!1,properties:{id:{type:"string"},type:{const:"filter",type:"string"}},required:["id","type"],type:"object"},NestedFilterLayoutItem:{additionalProperties:!1,properties:{id:{type:"string"},nested:{items:{$ref:"#/definitions/FilterLayoutItem"},type:"array"},type:{const:"nested",type:"string"}},required:["id","nested","type"],type:"object"},SortFunctions:{enum:[0,1,2],type:"number"},TableHeaderState:{additionalProperties:!1,properties:{field:{type:"string"},func:{type:"string"},text:{type:"string"},type:{$ref:"#/definitions/SortFunctions"}},required:["text","field","type"],type:"object"}}};function FL(i){se(i,"svelte-rwomh",".filters.svelte-rwomh{margin:1rem 0}.table-header.svelte-rwomh{display:flex;gap:0.25rem}.has-icon.svelte-rwomh{display:flex;align-items:center}table.svelte-rwomh{width:100%}")}function L3(i,e,t){let n=i.slice();return n[26]=e[t],n}function $3(i,e,t){let n=i.slice();return n[29]=e[t],n}function F3(i){let e,t,n=[],r=new Map,s,o,a,l=fe(i[4]),c=h=>h[29].text;for(let h=0;hV(f[h],1,1,()=>{f[h]=null});return{c(){e=b("table"),t=b("thead");for(let h=0;h{a=null}),De());let u={};c[0]&1&&(u.slice=l[0]),c[0]&4&&(u.page=l[2]),c[0]&8&&(u.pages=l[3]),s.$set(u)},i(l){o||($(t.$$.fragment,l),$(a),$(s.$$.fragment,l),o=!0)},o(l){V(t.$$.fragment,l),V(a),V(s.$$.fragment,l),o=!1},d(l){l&&(T(e),T(n),T(r)),ve(t),a&&a.d(l),ve(s,l)}}}function XL(i,e,t){let n,r,s,o,a,l,c=Ue("table");Se(i,c,E=>t(21,s=E));let{sortDir:u,allHeaders:f}=c;Se(i,u,E=>t(5,l=E)),Se(i,f,E=>t(4,a=E));let d=Ue("filters"),{filtered:h,layout:p}=d;Se(i,h,E=>t(1,r=E)),Se(i,p,E=>t(22,o=E));let m=Ue("plugin"),g=50,O=E=>{(0,po.setIcon)(E,"chevron-up")},w=E=>{(0,po.setIcon)(E,"chevron-down")},S=E=>{let j=new po.Menu;j.addItem(z=>{z.setTitle("Edit Headers").onClick(()=>{k()})}).addItem(z=>{z.setTitle("Edit Filters").onClick(()=>{C()})}).addSeparator().addItem(z=>{z.setTitle("Export").onClick(()=>{let q=createEl("a"),G=new Blob([JSON.stringify(m.data.builder)],{type:"json"}),Y=URL.createObjectURL(G);q.href=Y,q.download="initiative-tracker-encounter-builder.json",q.click()})}).addItem(z=>{z.setTitle("Import").onClick(()=>{let G=new X3.default().compile(q3),Y=createEl("input",{attr:{type:"file",name:"builder_state",accept:".json"}});Y.onchange=async()=>{let{files:ce}=Y;if(!ce.length)return;let Pe=new FileReader;Pe.onload=async ue=>{if(typeof ue.target.result=="string"){let B;try{B=JSON.parse(ue.target.result)}catch{new po.Notice("There was an issue parsing the file as JSON.")}G(B)?(m.data.builder={...B},await m.saveSettings(),d.resetLayout()):(console.log(...G.errors.map(ee=>ee.message)),new po.Notice("This file does not match the builder state schema."))}},Pe.readAsText(ce[0])},Y.click()})}),j.showAtMouseEvent(E.detail)},C=()=>{let E=new qh(o,d);E.open(),E.onClose=()=>{E.canceled||Ke(p,o=E.layout,o)}},k=()=>{let E=new jh(s.map(j=>j.toState()));E.open(),E.onClose=()=>{if(!E.canceled){if(E.reset){c.resetToDefault();return}c.setHeadersFromState(E.headers)}}},_=1,P=E=>S(E),x=E=>{c.sort(E)},R=E=>t(0,g=E.detail),Z=()=>t(2,_=_-1),Q=()=>t(2,_=Math.min(_+1,n)),D=E=>t(2,_=E.detail);return i.$$.update=()=>{i.$$.dirty[0]&3&&t(3,n=Math.ceil(r.length/g))},[g,r,_,n,a,l,c,u,f,h,p,O,w,S,P,x,R,Z,Q,D]}var fy=class extends ne{constructor(e){super(),re(this,e,XL,WL,ie,{},FL,[-1,-1])}},U3=fy;var Ft=require("obsidian");var xr=require("obsidian");function UL(i){se(i,"svelte-17aw8iw",".encounter-creature-container.svelte-17aw8iw{display:grid;align-items:center;justify-content:center;grid-template-columns:min-content 1fr 10% 10% auto auto auto;gap:0.5rem}.encounter-creature.svelte-17aw8iw{display:flex;align-items:center;gap:0.5rem}.encounter-creature-context.svelte-17aw8iw{text-align:right}.encounter-creature-controls.svelte-17aw8iw{display:flex;align-items:center;gap:0.5rem}input.svelte-17aw8iw{text-align:center;width:40px}.contains-icon.svelte-17aw8iw{display:flex;align-items:center}")}function Y3(i,e,t){let n=i.slice();return n[28]=e[t],n}function H3(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon svelte-17aw8iw"),v(e,"aria-label",t="This creature is hidden.")},m(o,a){A(o,e,a),r||(s=H(n=i[12].call(null,e)),r=!0)},d(o){o&&T(e),r=!1,s()}}}function G3(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon svelte-17aw8iw"),v(e,"aria-label",t="This creature is an ally.")},m(o,a){A(o,e,a),r||(s=H(n=i[14].call(null,e)),r=!0)},d(o){o&&T(e),r=!1,s()}}}function K3(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon svelte-17aw8iw"),v(e,"aria-label",t=`${i[1]>1?"These creatures are":"This creature is"} significantly under the average party level and might not contribute much to the fight.`)},m(o,a){A(o,e,a),r||(s=H(n=i[15].call(null,e)),r=!0)},p(o,a){a&2&&t!==(t=`${o[1]>1?"These creatures are":"This creature is"} significantly under the average party level and might not contribute much to the fight.`)&&v(e,"aria-label",t)},d(o){o&&T(e),r=!1,s()}}}function J3(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon svelte-17aw8iw"),v(e,"aria-label",t=`${i[1]>1?"These creatures are":"This creature is"} significantly over the average party level and might prove a challenge.`)},m(o,a){A(o,e,a),r||(s=H(n=i[16].call(null,e)),r=!0)},p(o,a){a&2&&t!==(t=`${o[1]>1?"These creatures are":"This creature is"} significantly over the average party level and might prove a challenge.`)&&v(e,"aria-label",t)},d(o){o&&T(e),r=!1,s()}}}function e5(i){let e,t,n=i[28]+"",r;return{c(){e=b("div"),t=b("span"),r=ae(n),v(e,"class","encounter-creature-context svelte-17aw8iw")},m(s,o){A(s,e,o),y(e,t),y(t,r)},p(s,o){o&5&&n!==(n=s[28]+"")&&me(r,n)},d(s){s&&T(e)}}}function YL(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m=i[0].name+"",g,O,w,S,C,k,_,P,x,R,Z,Q,D,E,j,z,q,G,Y,ce,Pe,ue=i[0].hidden&&H3(i),B=i[0].friendly&&G3(i),ee=i[4]&&K3(i),pe=i[3]&&J3(i),Re=fe(i[7].getAdditionalCreatureDifficultyStats(i[0],i[2])),oe=[];for(let ke=0;ket(18,o=z));let{average:c}=l;Se(i,c,z=>t(19,a=z));let u=Ue("plugin"),f=ki(u),d=z=>{new xr.ExtraButtonComponent(z).setIcon("minus-circle")},h=z=>{new xr.ExtraButtonComponent(z).setIcon("plus-with-circle")},p=z=>{new xr.ExtraButtonComponent(z).setIcon("trash-2")},m=z=>{new xr.ExtraButtonComponent(z).setIcon(er)},g=z=>{(0,xr.setIcon)(z,er)},O=z=>{new xr.ExtraButtonComponent(z).setIcon(tr)},w=z=>{(0,xr.setIcon)(z,tr)},{count:S}=e,{creature:C}=e,k=z=>(0,xr.setIcon)(z,"baby"),_=z=>(0,xr.setIcon)(z,"skull"),P=z=>{u.openCombatant(je.from(C),z.ctrlKey||z.metaKey)},x=()=>ii.remove(C);function R(){S=pi(this.value),t(1,S)}let Z=z=>ii.set(C,Number(z.currentTarget.value)),Q=()=>ii.add(C),D=()=>t(0,C.hidden=!C.hidden,C),E=()=>{t(0,C.friendly=!C.friendly,C),ii.update(C)},j=()=>ii.delete(C);return i.$$set=z=>{"count"in z&&t(1,S=z.count),"creature"in z&&t(0,C=z.creature)},i.$$.update=()=>{i.$$.dirty&524289&&t(4,n="cr"in C&&C.cr&&hi(C.cr)a+3),i.$$.dirty&262144&&t(2,s=o.filter(z=>z.enabled).map(z=>z.level))},[C,S,s,r,n,l,c,f,d,h,p,m,g,O,w,k,_,P,o,a,x,R,Z,Q,D,E,j]}var dy=class extends ne{constructor(e){super(),re(this,e,HL,YL,ie,{count:1,creature:0},UL)}},t5=dy;function GL(i){se(i,"svelte-1s1acwo",".encounter-name.svelte-1s1acwo{display:flex;align-items:center}.encounter-header.svelte-1s1acwo{display:flex;align-items:center;justify-content:space-between}.encounter-creatures.svelte-1s1acwo{display:flex;gap:0.5rem;flex-flow:column nowrap}.encounter-header.svelte-1s1acwo .is-disabled{cursor:not-allowed}.encounter-controls.svelte-1s1acwo{display:flex;gap:0.5rem;align-items:center}")}function i5(i,e,t){let n=i.slice();return n[31]=e[t][0],n[32]=e[t][1],n}function KL(i){let e,t,n,r,s,o,a;return{c(){e=b("h5"),t=ae(i[1]),n=M(),r=b("div"),v(e,"class","built-encounter")},m(l,c){A(l,e,c),y(e,t),A(l,n,c),A(l,r,c),o||(a=[H(s=i[11].call(null,r)),U(r,"click",i[26])],o=!0)},p(l,c){c[0]&2&&me(t,l[1])},d(l){l&&(T(e),T(n),T(r)),o=!1,de(a)}}}function JL(i){let e,t,n,r,s,o,a,l,c;return{c(){e=b("input"),t=M(),n=b("div"),s=M(),o=b("div"),v(e,"type","text"),v(e,"placeholder",i[1])},m(u,f){A(u,e,f),Xe(e,i[2]),A(u,t,f),A(u,n,f),A(u,s,f),A(u,o,f),l||(c=[U(e,"input",i[25]),H(r=i[12].call(null,n)),U(n,"click",i[8]),H(a=i[14].call(null,o)),U(o,"click",i[9])],l=!0)},p(u,f){f[0]&2&&v(e,"placeholder",u[1]),f[0]&4&&e.value!==u[2]&&Xe(e,u[2])},d(u){u&&(T(e),T(t),T(n),T(s),T(o)),l=!1,de(c)}}}function e$(i){let e,t,n=fe(i[0]),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){e=b("div");for(let o=0;o{j[Y]=null}),De(),k=j[C],k?k.p(q,G):(k=j[C]=E[C](q),k.c()),$(k,1),k.m(_.parentNode,_))},i(q){P||($(k),P=!0)},o(q){V(k),P=!1},d(q){q&&(T(e),T(S),T(_)),D.d(),j[C].d(q),x=!1,de(R)}}}function n$(i,e,t){let n,r,s,o,a,l;Se(i,ii,Y=>t(24,r=Y));let{players:c}=ii;Se(i,c,Y=>t(28,s=Y));let u=Ue("plugin"),f=$e("Encounter");Se(i,f,Y=>t(1,o=Y));let d=$e("");Se(i,d,Y=>t(2,a=Y));let h=$e(!1);Se(i,h,Y=>t(3,l=Y));let p=()=>{Ke(h,l=!1,l),Ke(f,o=a.length?a:o,o),Ke(d,a="",a)},m=()=>{Ke(h,l=!1,l),Ke(d,a="",a)},g=u.data.rollHP,O,w=Y=>{t(20,O=new Ft.ExtraButtonComponent(Y).setIcon(us).onClick(async()=>{u.view||await u.addTrackerView();let ce=u.view,Pe=[],ue=[];for(let[B,ee]of n){let pe=je.from(B),Re=Math.max(isNaN(Number(ee))?1:Number(ee),1);Pe.push(...[...Array(Re).keys()].map(oe=>je.new(pe)))}for(let B of[...s.map(ee=>u.getPlayerByName(ee.name)??je.from(ee)),...Pe])ue.push(B.toJSON());he.new(u,{creatures:ue,name:o,round:1,state:!1,logFile:null,newLog:!0,roll:!0,rollHP:g}),u.app.workspace.revealLeaf(ce.leaf)}))},S=Y=>{new Ft.ExtraButtonComponent(Y).setIcon("pencil")},C,k=Y=>{t(21,C=new Ft.ExtraButtonComponent(Y).setIcon("save"))},_=()=>{let Y=new Ft.Modal(app);Y.titleEl.setText("Save Encounter");let ce=o!="Encounter"?o:`Encounter ${Object.keys(u.data.encounters).length}`;new Ft.Setting(Y.contentEl).setName("Encounter Name").addText(ue=>{ue.setPlaceholder(ce).onChange(B=>ce=B)});let Pe=()=>{try{let ue=[...[...s].map(B=>je.from(B)),...[...r.entries()].map(B=>[...Array(B[1]).keys()].map(()=>je.from(B[0]))).flat()];u.addEncounter(ce,{creatures:[...ue.map(B=>B.toJSON())],state:!1,name:ce,round:1,roll:!0,rollHP:u.data.rollHP,logFile:null,timestamp:Date.now()}),u.saveSettings(),new Ft.Notice(`Encounter "${ce}" saved.`),Y.close()}catch{new Ft.Notice("There was an issue saving the encounter.")}};new Ft.Setting(Y.contentEl).addButton(ue=>ue.setButtonText("Save").onClick(()=>{if(ce in u.data.encounters){let B=new Ft.Modal(app);B.titleEl.setText("Are you sure?"),B.contentEl.createEl("p",{text:"This will overwrite an existing encounter. Are you sure?"}),new Ft.Setting(B.contentEl).addButton(ee=>ee.setButtonText("Overwrite").onClick(()=>{B.close(),Pe()})).addExtraButton(ee=>ee.setIcon("cross").onClick(()=>{B.close()})),B.open()}else Pe()})),Y.open()},P=Y=>{new Ft.ExtraButtonComponent(Y).setIcon("cross-in-box")},x,R=Y=>{t(22,x=new Ft.ExtraButtonComponent(Y).setIcon("copy"))},Z,Q=Y=>{t(23,Z=new Ft.ExtraButtonComponent(Y).setIcon("upload").setTooltip("Load Encounter"))},D=Y=>{let ce=new Ft.Menu;for(let Pe of Object.values(u.data.encounters))ce.addItem(ue=>{ue.setTitle(Pe.name).onClick(()=>{Ke(f,o=Pe.name,o),ii.empty(),c.empty();for(let B of Pe.creatures)B.player?c.addFromState(B):ii.add(je.fromJSON(B,u))})});ce.showAtMouseEvent(Y)},E=Y=>{new Ft.ExtraButtonComponent(Y).setIcon("eraser").setTooltip("Clear Encounter")},j=async()=>{let Y={};o?.length&&(Y.name=o),s?.length&&(Y.players=s.filter(ce=>ce.enabled).map(ce=>ce.name)),r?.size&&(Y.creatures=[...r.entries()].map(([ce,Pe])=>({[Number(Pe)]:`${ce.name}${ce.friendly?", friendly":""}${ce.hidden?", hidden":""}`})));try{await navigator.clipboard.writeText(`\`\`\`encounter ${(0,Ft.stringifyYaml)(Y)}\`\`\``),new Ft.Notice("Encounter saved to clipboard")}catch(ce){console.error(ce),new Ft.Notice("Could not save encounter, please check console for errors")}};function z(){a=this.value,d.set(a)}let q=()=>Ke(h,l=!0,l),G=()=>{ii.empty(),Ke(f,o="Encounter",o)};return i.$$.update=()=>{i.$$.dirty[0]&16777216&&t(0,n=[...r.entries()]),i.$$.dirty[0]&1048577&&O&&(n.length?(O.setDisabled(!1),O.setTooltip("Start Encounter")):(O.setDisabled(!0),O.setTooltip(""))),i.$$.dirty[0]&18874368&&C?.setDisabled(r.size==0),i.$$.dirty[0]&4194305&&x&&(n.length?(x.setDisabled(!1),x.setTooltip("Copy Encounter Block")):(x.setDisabled(!0),x.setTooltip(""))),i.$$.dirty[0]&8388608&&Z?.setDisabled(Object.keys(u.data.encounters).length==0)},[n,o,a,l,c,f,d,h,p,m,w,S,k,_,P,R,Q,D,E,j,O,C,x,Z,r,z,q,G]}var hy=class extends ne{constructor(e){super(),re(this,e,n$,i$,ie,{},GL,[-1,-1])}},r5=hy;function r$(i){se(i,"svelte-r6lzam","details.svelte-r6lzam>summary.svelte-r6lzam.svelte-r6lzam{outline:none;display:flex !important;align-items:center;justify-content:space-between;gap:0.25rem;list-style:none !important;list-style-type:none !important;min-height:1rem;border-top-left-radius:0.1rem;border-top-right-radius:0.1rem;cursor:pointer;position:relative;margin-bottom:1rem}details.svelte-r6lzam>summary.svelte-r6lzam.svelte-r6lzam::-webkit-details-marker,details.svelte-r6lzam>summary.svelte-r6lzam.svelte-r6lzam::marker{display:none !important}details.svelte-r6lzam>summary.svelte-r6lzam>.collapser.svelte-r6lzam{position:relative;display:flex;align-items:center}details.svelte-r6lzam>summary .collapser.svelte-r6lzam>.handle.svelte-r6lzam{transform:rotate(0deg);transition:transform 0.25s;background-color:currentColor;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-image:var(--admonition-details-icon);mask-image:var(--admonition-details-icon);width:20px;height:20px}details[open].svelte-r6lzam>summary .collapser.svelte-r6lzam>.handle.svelte-r6lzam{transform:rotate(90deg)}details.svelte-r6lzam>summary.svelte-r6lzam.svelte-r6lzam{border-bottom:1px solid var(--background-modifier-border)}details.svelte-r6lzam>summary.svelte-r6lzam.svelte-r6lzam{border-bottom:1px solid var(--background-modifier-border)}")}var s$=i=>({}),s5=i=>({}),o$=i=>({}),o5=i=>({});function a$(i){let e,t,n,r,s,o,a,l,c=i[2].title,u=Gt(c,i,i[1],o5),f=i[2].content,d=Gt(f,i,i[1],s5);return{c(){e=b("details"),t=b("summary"),u&&u.c(),n=M(),r=b("div"),r.innerHTML='
',s=M(),d&&d.c(),v(r,"class","collapser svelte-r6lzam"),v(t,"class","svelte-r6lzam"),e.open=i[0],v(e,"class","svelte-r6lzam")},m(h,p){A(h,e,p),y(e,t),u&&u.m(t,null),y(t,n),y(t,r),y(e,s),d&&d.m(e,null),o=!0,a||(l=U(e,"toggle",i[3]),a=!0)},p(h,[p]){u&&u.p&&(!o||p&2)&&Jt(u,c,h,h[1],o?Kt(c,h[1],p,o$):ei(h[1]),o5),d&&d.p&&(!o||p&2)&&Jt(d,f,h,h[1],o?Kt(f,h[1],p,s$):ei(h[1]),s5),(!o||p&1)&&(e.open=h[0])},i(h){o||($(u,h),$(d,h),o=!0)},o(h){V(u,h),V(d,h),o=!1},d(h){h&&T(e),u&&u.d(h),d&&d.d(h),a=!1,l()}}}function l$(i,e,t){let{$$slots:n={},$$scope:r}=e,{open:s}=e;function o(a){ht.call(this,i,a)}return i.$$set=a=>{"open"in a&&t(0,s=a.open),"$$scope"in a&&t(1,r=a.$$scope)},[s,r,n,o]}var py=class extends ne{constructor(e){super(),re(this,e,l$,a$,ie,{open:0},r$)}},yp=py;function c$(i){se(i,"svelte-1x58p02",".title-container.svelte-1x58p02{display:flex;flex-flow:column nowrap;gap:0.1rem}.title.svelte-1x58p02{margin-bottom:0}.content.svelte-1x58p02{display:flex;flex-flow:column nowrap;gap:0.25rem}.filtered.svelte-1x58p02{font-size:smaller;color:var(--text-muted)}.xp-container.svelte-1x58p02{margin-left:auto}.xp.svelte-1x58p02{display:flex;gap:1rem}.thresholds.svelte-1x58p02{display:flex;flex-flow:column;gap:0.5rem}.experience-amount.svelte-1x58p02{margin-left:auto}.encounter-difficulty.svelte-1x58p02{display:flex;flex-flow:column nowrap;gap:0.5rem;margin-bottom:1rem}.container.svelte-1x58p02{display:flex;flex-flow:column nowrap}.header.svelte-1x58p02{text-transform:uppercase;font-weight:bolder}")}function a5(i,e,t){let n=i.slice();return n[10]=e[t],n}function l5(i,e,t){let n=i.slice();return n[10]=e[t],n}function c5(i,e,t){let n=i.slice();return n[15]=e[t],n}function u5(i){let e,t=i[5].displayName+"",n,r;return{c(){e=ae("("),n=ae(t),r=ae(")")},m(s,o){A(s,e,o),A(s,n,o),A(s,r,o)},p:X,d(s){s&&(T(e),T(n),T(r))}}}function f5(i){let e,t,n,r,s=i[2]>1?"s":"",o;return{c(){e=b("span"),t=ae("Filtering "),n=ae(i[2]),r=ae(" allied creature"),o=ae(s),v(e,"class","filtered svelte-1x58p02")},m(a,l){A(a,e,l),y(e,t),y(e,n),y(e,r),y(e,o)},p(a,l){l&4&&me(n,a[2]),l&4&&s!==(s=a[2]>1?"s":"")&&me(o,s)},d(a){a&&T(e)}}}function u$(i){let e,t,n,r,s,o=i[1].data.rpgSystem!="dnd5e"&&u5(i),a=i[2]>0&&f5(i);return{c(){e=b("div"),t=b("h5"),t.textContent="Experience",n=M(),r=b("span"),o&&o.c(),s=M(),a&&a.c(),v(t,"class","title svelte-1x58p02"),v(e,"class","title-container svelte-1x58p02"),v(e,"slot","title")},m(l,c){A(l,e,c),y(e,t),y(e,n),y(e,r),o&&o.m(r,null),y(e,s),a&&a.m(e,null)},p(l,c){l[1].data.rpgSystem!="dnd5e"?o?o.p(l,c):(o=u5(l),o.c(),o.m(r,null)):o&&(o.d(1),o=null),l[2]>0?a?a.p(l,c):(a=f5(l),a.c(),a.m(e,null)):a&&(a.d(1),a=null)},d(l){l&&T(e),o&&o.d(),a&&a.d()}}}function d5(i){let e,t,n=i[15].label+"",r,s,o,a=i[15].value.toLocaleString()+"",l;return{c(){e=b("div"),t=b("strong"),r=ae(n),s=M(),o=b("span"),l=ae(a),v(t,"class","header svelte-1x58p02"),v(e,"class","adjusted container svelte-1x58p02")},m(c,u){A(c,e,u),y(e,t),y(t,r),y(e,s),y(e,o),y(o,l)},p(c,u){u&8&&n!==(n=c[15].label+"")&&me(r,n),u&8&&a!==(a=c[15].value.toLocaleString()+"")&&me(l,a)},d(c){c&&T(e)}}}function h5(i){let e,t,n=i[10].displayName+"",r,s,o,a=i[5].formatDifficultyValue(i[10].minValue,!0)+"",l,c,u;return{c(){e=b("div"),t=b("strong"),r=ae(n),s=M(),o=b("span"),l=ae(a),c=M(),v(t,"class","experience-name header svelte-1x58p02"),v(o,"class","experience-amount svelte-1x58p02"),v(e,"class",u="experience-threshold "+i[10].displayName.toLowerCase()+" container svelte-1x58p02")},m(f,d){A(f,e,d),y(e,t),y(t,r),y(e,s),y(e,o),y(o,l),y(e,c)},p(f,d){d&1&&n!==(n=f[10].displayName+"")&&me(r,n),d&1&&a!==(a=f[5].formatDifficultyValue(f[10].minValue,!0)+"")&&me(l,a),d&1&&u!==(u="experience-threshold "+f[10].displayName.toLowerCase()+" container svelte-1x58p02")&&v(e,"class",u)},d(f){f&&T(e)}}}function p5(i){let e,t=i[10].displayName+"",n,r,s,o=i[5].formatDifficultyValue(i[10].minValue,!0)+"",a,l;return{c(){e=b("h5"),n=ae(t),r=M(),s=b("span"),a=ae(o),l=M(),v(e,"class","experience-name"),v(s,"class","experience-amount svelte-1x58p02")},m(c,u){A(c,e,u),y(e,n),A(c,r,u),A(c,s,u),y(s,a),y(s,l)},p(c,u){u&1&&t!==(t=c[10].displayName+"")&&me(n,t),u&1&&o!==(o=c[5].formatDifficultyValue(c[10].minValue,!0)+"")&&me(a,o)},d(c){c&&(T(e),T(r),T(s))}}}function f$(i){let e,t,n,r,s,o,a,l=i[3].displayName+"",c,u,f,d,h,p=i[3].title+"",m,g,O,w=i[5].formatDifficultyValue(i[3].value)+"",S,C,k,_,P,x,R,Z=fe(i[3].intermediateValues),Q=[];for(let q=0;qt(7,o=h)),Se(i,ii,h=>t(8,a=h));let l=Ue("plugin"),c=l.data.builder.showXP,u=ki(l),f=0,d=()=>t(1,l.data.builder.showXP=!l.data.builder.showXP,l);return i.$$.update=()=>{if(i.$$.dirty&256&&t(6,n=new Map([...a.entries()].map(([h,p])=>h.friendly?[h,0]:[h,p]))),i.$$.dirty&324){t(2,f=0);for(let[h,p]of n)p===0&&t(2,f+=a.get(h)??0)}i.$$.dirty&128&&t(0,r=o.filter(h=>h.enabled).map(h=>h.level)),i.$$.dirty&65&&t(3,s=u.getEncounterDifficulty(n,r))},[r,l,f,s,c,u,n,o,a,d]}var my=class extends ne{constructor(e){super(),re(this,e,h$,d$,ie,{},c$)}},m5=my;var mo=require("obsidian");function p$(i){se(i,"svelte-wi0lrc",".players.svelte-wi0lrc.svelte-wi0lrc{display:flex;flex-flow:column;gap:0.25rem}.player.svelte-wi0lrc.svelte-wi0lrc{display:flex;justify-content:space-between;align-items:center}input.svelte-wi0lrc.svelte-wi0lrc{text-align:center;width:40px}.disabled.svelte-wi0lrc>.player-name.svelte-wi0lrc{text-decoration:line-through}.disabled.svelte-wi0lrc.svelte-wi0lrc{color:var(--text-faint)}.player-right.svelte-wi0lrc.svelte-wi0lrc{display:flex;align-items:center;gap:0.25rem}.add-player.svelte-wi0lrc.svelte-wi0lrc{display:flex;align-items:center;justify-content:flex-end}")}function g5(i,e,t){let n=i.slice();return n[21]=e[t],n[23]=t,n}function O5(i,e,t){let n=i.slice();return n[21]=e[t],n}function m$(i){let e;return{c(){e=b("h5"),e.textContent="Players",v(e,"class","player-header"),v(e,"slot","title")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function g$(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[7].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function O$(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[8].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function v$(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[9].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function v5(i,e){let t,n,r=e[21].name+"",s,o,a,l,c=e[21].level+"",u,f,d,h,p,m;function g(C,k){return C[21].enabled?v$:O$}let O=g(e,-1),w=O(e);function S(){return e[14](e[21])}return{key:i,first:null,c(){t=b("div"),n=b("span"),s=ae(r),o=M(),a=b("div"),l=b("span"),u=ae(c),f=M(),d=b("div"),w.c(),v(n,"class","player-name svelte-wi0lrc"),v(d,"class","clickable-icon setting-editor-extra-setting-button"),v(d,"aria-label",h=e[21].enabled?"Disable":"Enable"),v(a,"class","player-right svelte-wi0lrc"),v(t,"class","player svelte-wi0lrc"),ge(t,"disabled",!e[21].enabled),this.first=t},m(C,k){A(C,t,k),y(t,n),y(n,s),y(t,o),y(t,a),y(a,l),y(l,u),y(a,f),y(a,d),w.m(d,null),p||(m=U(d,"click",S),p=!0)},p(C,k){e=C,k&2&&r!==(r=e[21].name+"")&&me(s,r),k&2&&c!==(c=e[21].level+"")&&me(u,c),O!==(O=g(e,k))&&(w.d(1),w=O(e),w&&(w.c(),w.m(d,null))),k&2&&h!==(h=e[21].enabled?"Disable":"Enable")&&v(d,"aria-label",h),k&2&&ge(t,"disabled",!e[21].enabled)},d(C){C&&T(t),w.d(),p=!1,m()}}}function y$(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[8].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function b$(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[9].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function y5(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,w,S,C,k,_,P;function x(...z){return i[15](i[21],...z)}function R(...z){return i[16](i[21],...z)}function Z(z,q){return z[21].enabled?b$:y$}let Q=Z(i,-1),D=Q(i);function E(){return i[17](i[21])}function j(){return i[18](i[21])}return{c(){e=b("div"),t=b("input"),r=M(),s=b("span"),s.textContent="Player(s)",o=M(),a=b("div"),c=M(),u=b("span"),u.textContent="Level",f=M(),d=b("input"),p=M(),m=b("div"),g=b("div"),D.c(),w=M(),S=b("div"),C=b("div"),v(t,"type","number"),t.value=n=i[21].count,v(t,"min","1"),v(t,"class","svelte-wi0lrc"),v(d,"type","number"),d.value=h=i[21].level,v(d,"min","1"),v(d,"class","svelte-wi0lrc"),v(g,"class","clickable-icon setting-editor-extra-setting-button"),v(g,"aria-label",O=i[21].enabled?"Disable":"Enable"),v(S,"class","clickable-icon setting-editor-extra-setting-button"),v(m,"class","player-right svelte-wi0lrc"),v(e,"class","player svelte-wi0lrc"),ge(e,"disabled",!i[21].enabled)},m(z,q){A(z,e,q),y(e,t),y(e,r),y(e,s),y(e,o),y(e,a),y(e,c),y(e,u),y(e,f),y(e,d),y(e,p),y(e,m),y(m,g),D.m(g,null),y(m,w),y(m,S),y(S,C),_||(P=[U(t,"input",x),H(l=i[12].call(null,a)),U(d,"input",R),U(g,"click",E),H(k=i[13].call(null,C)),U(S,"click",j)],_=!0)},p(z,q){i=z,q&4&&n!==(n=i[21].count)&&t.value!==n&&(t.value=n),q&4&&h!==(h=i[21].level)&&d.value!==h&&(d.value=h),Q!==(Q=Z(i,q))&&(D.d(1),D=Q(i),D&&(D.c(),D.m(g,null))),q&4&&O!==(O=i[21].enabled?"Disable":"Enable")&&v(g,"aria-label",O),q&4&&ge(e,"disabled",!i[21].enabled)},d(z){z&&T(e),D.d(),_=!1,de(P)}}}function _$(i){let e,t,n,r,s=[],o=new Map,a,l,c,u,f,d,h,p=i[6].length&&g$(i),m=fe(i[1]),g=S=>S[21].name;for(let S=0;St(1,n=x)),Se(i,o,x=>t(2,r=x));let a=Ue("plugin"),l=a.data.builder.showParty,c=a.data.defaultParty,u=a.data.parties;return a.getPlayersForParty(c).forEach(x=>{Ni.add({level:x.level,name:x.name,...x.creature,isPlayer:!0,enabled:!0,count:1})}),[a,n,r,s,o,l,u,x=>{new mo.Setting(x).setName("Select a party").addDropdown(R=>{R.addOption("none","None").addOptions(Object.fromEntries(u.map(Z=>[Z.name,Z.name]))).onChange(Z=>{Ni.switchParty(a.getPlayersForParty(Z).map(Q=>({level:Q.level,name:Q.name,...Q.creature,isPlayer:!0,enabled:!0,count:1})))}),c&&R.setValue(c)})},x=>{(0,mo.setIcon)(x,Ql)},x=>{(0,mo.setIcon)(x,Dl)},x=>{(0,mo.setIcon)(x,"plus-with-circle")},()=>{Ni.add({isPlayer:!1,level:1,count:1,enabled:!0})},x=>{(0,mo.setIcon)(x,"x")},x=>{(0,mo.setIcon)(x,"x-square")},x=>Ni.toggleEnabled(x),(x,R)=>Ni.set(x,Number(R.currentTarget.value)),(x,R)=>Ni.setLevel(x,Number(R.currentTarget.value)),x=>Ni.toggleEnabled(x),x=>Ni.remove(x),()=>t(0,a.data.builder.showParty=!a.data.builder.showParty,a)]}var gy=class extends ne{constructor(e){super(),re(this,e,k$,w$,ie,{},p$)}},b5=gy;function S$(i){se(i,"svelte-jz7gin",".players-xp.svelte-jz7gin{display:grid;grid-template-columns:1fr 1fr}")}function x$(i){let e,t,n,r,s,o;return n=new b5({}),s=new m5({}),{c(){e=b("div"),t=b("div"),ye(n.$$.fragment),r=M(),ye(s.$$.fragment),v(t,"class","players-xp svelte-jz7gin"),v(e,"class","player-component-container")},m(a,l){A(a,e,l),y(e,t),Oe(n,t,null),y(t,r),Oe(s,t,null),o=!0},p:X,i(a){o||($(n.$$.fragment,a),$(s.$$.fragment,a),o=!0)},o(a){V(n.$$.fragment,a),V(s.$$.fragment,a),o=!1},d(a){a&&T(e),ve(n),ve(s)}}}var Oy=class extends ne{constructor(e){super(),re(this,e,null,x$,ie,{},S$)}},_5=Oy;function P$(i){se(i,"svelte-95ft2e",".encounter-builder.svelte-95ft2e{margin:1rem}")}function C$(i){let e,t,n,r,s,o,a;return t=new _5({}),r=new r5({}),o=new U3({}),{c(){e=b("div"),ye(t.$$.fragment),n=M(),ye(r.$$.fragment),s=M(),ye(o.$$.fragment),v(e,"class","initiative-tracker encounter-builder markdown-rendered svelte-95ft2e")},m(l,c){A(l,e,c),Oe(t,e,null),y(e,n),Oe(r,e,null),y(e,s),Oe(o,e,null),a=!0},p:X,i(l){a||($(t.$$.fragment,l),$(r.$$.fragment,l),$(o.$$.fragment,l),a=!0)},o(l){V(t.$$.fragment,l),V(r.$$.fragment,l),V(o.$$.fragment,l),a=!1},d(l){l&&T(e),ve(t),ve(r),ve(o)}}}function E$(i,e,t){let{plugin:n}=e,r=n.bestiary,s=ck(n,[...r]);Vi("table",s);let o=yw(s.creatures,n);return Vi("filters",o),n.data.builder||(n.data.builder={sidebarIcon:!0,showParty:!0,showXP:!0}),Vi("plugin",n),ff(()=>{Ni.empty()}),i.$$set=a=>{"plugin"in a&&t(0,n=a.plugin)},[n]}var vy=class extends ne{constructor(e){super(),re(this,e,E$,C$,ie,{plugin:0},P$)}},yy=vy;var _l=class extends w5.ItemView{constructor(t,n){super(t);this.plugin=n;J(this,"ui")}getState(){return{encounter:[...ut(ii).entries()]}}async setState(t,n){let r=Array.isArray(t)?t:t?.encounter;r&&Array.isArray(r)&&ii.setMultiple(r),super.setState(t,n)}async onOpen(){if(this.plugin.canUseStatBlocks&&!window.FantasyStatblocks.isResolved()){this.contentEl.addClasses(["waiting-for-bestiary","is-loading"]);let t=this.contentEl.createEl("p",{text:"Waiting for Fantasy Statblocks Bestiary..."}),n=window.FantasyStatblocks.onResolved(()=>{this.contentEl.removeClasses(["waiting-for-bestiary","is-loading"]),t.detach(),this.ui=new yy({target:this.contentEl,props:{plugin:this.plugin}}),n()})}else this.ui=new yy({target:this.contentEl,props:{plugin:this.plugin}})}async onClose(){this.ui?.$destroy()}getDisplayText(){return"Encounter Builder"}getIcon(){return nr}getViewType(){return nr}};var T5=require("obsidian");var Ru=require("obsidian");function T$(i){se(i,"svelte-1frc5is",".full-center.svelte-1frc5is{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.initiative-tracker-table.svelte-1frc5is{padding:0.5rem;align-items:center;gap:0.25rem 0.5rem;width:100%;margin-left:0rem;table-layout:fixed;border-collapse:separate;border-spacing:0 2px;font-size:larger}.left.svelte-1frc5is{text-align:left}.name.svelte-1frc5is,.name.svelte-1frc5is>svg{display:flex;align-items:center;gap:0.5rem}.center.svelte-1frc5is{text-align:center}.healthy.svelte-1frc5is{color:var(--text-success)}.hurt.svelte-1frc5is{color:var(--text-warning)}.bloodied.svelte-1frc5is{color:var(--text-error)}.defeated.svelte-1frc5is{color:var(--text-faint)}.active.svelte-1frc5is{background-color:rgba(0, 0, 0, 0.1)}.theme-dark .active.svelte-1frc5is{background-color:rgba(255, 255, 255, 0.1)}")}function S5(i,e,t){let n=i.slice();return n[14]=e[t],n}function x5(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon"),v(e,"aria-label",t="This creature is an ally.")},m(o,a){A(o,e,a),r||(s=H(n=i[11].call(null,e)),r=!0)},d(o){o&&T(e),r=!1,s()}}}function A$(i){let e,t=i[8](i[14].hp,i[14].max)+"",n;return{c(){e=b("span"),n=ae(t)},m(r,s){A(r,e,s),y(e,n)},p(r,s){s&1&&t!==(t=r[8](r[14].hp,r[14].max)+"")&&me(n,t)},d(r){r&&T(e)}}}function D$(i){let e,t=i[14].hpDisplay+"";return{c(){e=b("div"),v(e,"class","center svelte-1frc5is")},m(n,r){A(n,e,r),e.innerHTML=t},p(n,r){r&1&&t!==(t=n[14].hpDisplay+"")&&(e.innerHTML=t)},d(n){n&&T(e)}}}function P5(i,e){let t,n,r=e[14].initiative+"",s,o,a,l,c=e[10](e[14])+"",u,f,d,h,p,m,g=[...e[14].status].map(C5).join(", ")+"",O,w,S=e[14].friendly&&x5(e);function C(P,x){return P[14].player&&P[2].diplayPlayerHPValues?D$:A$}let k=C(e,-1),_=k(e);return{key:i,first:null,c(){t=b("tr"),n=b("td"),s=ae(r),o=M(),a=b("td"),S&&S.c(),l=M(),u=ae(c),f=M(),d=b("td"),_.c(),p=M(),m=b("td"),O=ae(g),w=M(),v(n,"class","center svelte-1frc5is"),v(a,"class","name svelte-1frc5is"),v(d,"class",h=un(e[8](e[14].hp,e[14].max).toLowerCase())+" svelte-1frc5is"),ge(d,"center",!0),v(m,"class","center svelte-1frc5is"),v(t,"class","svelte-1frc5is"),ge(t,"active",e[9](e[14])&&e[1]),this.first=t},m(P,x){A(P,t,x),y(t,n),y(n,s),y(t,o),y(t,a),S&&S.m(a,null),y(a,l),y(a,u),y(t,f),y(t,d),_.m(d,null),y(t,p),y(t,m),y(m,O),y(t,w)},p(P,x){e=P,x&1&&r!==(r=e[14].initiative+"")&&me(s,r),e[14].friendly?S||(S=x5(e),S.c(),S.m(a,l)):S&&(S.d(1),S=null),x&1&&c!==(c=e[10](e[14])+"")&&me(u,c),k===(k=C(e,x))&&_?_.p(e,x):(_.d(1),_=k(e),_&&(_.c(),_.m(d,null))),x&1&&h!==(h=un(e[8](e[14].hp,e[14].max).toLowerCase())+" svelte-1frc5is")&&v(d,"class",h),x&1&&ge(d,"center",!0),x&1&&g!==(g=[...e[14].status].map(C5).join(", ")+"")&&me(O,g),x&515&&ge(t,"active",e[9](e[14])&&e[1])},d(P){P&&T(t),S&&S.d(),_.d()}}}function Q$(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=[],O=new Map,w,S,C,k,_=fe(i[0]),P=x=>x[14].id;for(let x=0;x<_.length;x+=1){let R=S5(i,_,x),Z=P(R);O.set(Z,g[x]=P5(Z,R))}return{c(){e=b("table"),t=b("thead"),n=b("th"),r=b("strong"),o=M(),a=b("th"),a.innerHTML="Name",l=M(),c=b("th"),u=b("strong"),d=M(),h=b("th"),h.innerHTML="Statuses",p=M(),m=b("tbody");for(let x=0;x{S&&(w||(w=Po(e,Bf,{},!0)),w.run(1))}),S=!0)},o(x){x&&(w||(w=Po(e,Bf,{},!1)),w.run(0)),S=!1},d(x){x&&T(e);for(let R=0;Ri.name;function R$(i,e,t){let n,r,s,o,{state:a,ordered:l,data:c}=he;Se(i,a,O=>t(1,s=O)),Se(i,l,O=>t(12,r=O)),Se(i,c,O=>t(2,o=O));let u=O=>{(0,Ru.setIcon)(O,an)},f=O=>{(0,Ru.setIcon)(O,ir)},d=O=>{(0,Ru.setIcon)(O,So)},h=(O,w)=>O?O<=0?"Defeated":O{if(O.hidden)return!1;if(O.active)return!0;let w=r.findIndex(k=>k.active),S=r.indexOf(O);return w==-1||wk.hidden)},m=O=>O.getName(),g=O=>{(0,Ru.setIcon)(O,tr)};return i.$$.update=()=>{i.$$.dirty&4096&&t(0,n=r.filter(O=>O.enabled&&!O.hidden))},[n,s,o,a,l,c,u,d,h,p,m,g,r]}var by=class extends ne{constructor(e){super(),re(this,e,R$,Q$,ie,{},T$)}},E5=by;var Mu=class extends T5.ItemView{constructor(t,n){super(t);this.leaf=t;this.plugin=n;J(this,"_app")}getDisplayText(){return"Player View"}getViewType(){return Ds}getIcon(){return"lucide-view"}async onOpen(){this._app=new E5({target:this.contentEl,props:{}})}async onClose(){this._app?.$destroy()}};var _p=require("obsidian");var bp=class extends _p.EditorSuggest{constructor(t){super(t.app);this.plugin=t;J(this,"_context",5);J(this,"_encounter",{})}getSuggestions(t){let n=[];switch(this._context){case 4:{n=[];break}case 0:n=[...this.plugin.players.keys()].filter(r=>!this._encounter.players?.includes(r));break;case 1:n=this.plugin.bestiaryNames;break;case 2:n=["false",...this.plugin.data.parties?.map(r=>r.name)];break;case 3:n=["true","false"];break;case 5:n=["players","creatures","party","rollHP","name"].filter(r=>!(r in this._encounter));break}return n.filter(r=>!t.query.length||r.toLowerCase().contains(t.query.toLowerCase()))}renderSuggestion(t,n){n.createSpan({text:t})}selectSuggestion(t,n){if(this.context){switch(this._context){case 5:{t=`${t}:`,/^(players|creatures):/.test(t)?t=`${t} - `:t=`${t} `;break}case 1:case 0:{let r=this.context.editor.getLine(this.context.start.line).search(/\S/);t=`${t} ${" ".repeat(r)}- `;break}case 2:case 3:{t=`${/\s$/.test(this.context.editor.getLine(this.context.start.line))?"":" "}${t.trim()}`;break}case 4:break}this.context.editor.replaceRange(`${t}`,this.context.start,{...this.context.end,ch:this.context.start.ch+this.context.query.length},"initiative-tracker"),this.context.editor.setCursor(this.context.start.line,this.context.start.ch+t.length),this.close()}}onTrigger(t,n,r){this._context=5;let s=n.getRange({line:0,ch:0},t);if(s.indexOf("```encounter\n")===-1)return null;let o=s.split(` `),a=!1,l;for(let u=o.length-1;u>=0;u--){let f=o[u];if(/^```$/.test(f))return null;if(/^```encounter/.test(f)){a=!0,l=u;break}}if(!a)return null;try{let u=n.getValue().split(` `);u.splice(t.line,1),u=u.slice(l+1);let f=u.findIndex(d=>/^```$/.test(d));f<0&&(f=u.length),this._encounter=(0,_p.parseYaml)(u.slice(0,f).join(` `))}catch{this._encounter={}}this._encounter||(this._encounter={});let c=n.getLine(t.line);if(/^name/.test(c))return null;if(/^rollHP:/.test(c)){this._context=3;let[u,f]=c.match(/^rollHP:\s?(.*)$/);return f==="true"||f==="false"?null:{end:t,start:{ch:c.length-f.length,line:t.line},query:f}}if(/^party:/.test(c)){this._context=2;let[u,f]=c.match(/^party:\s?(.*)$/);return this.plugin.data.parties.find(d=>d.name===f)?null:{end:t,start:{ch:c.length-f.length,line:t.line},query:f}}if(/\s+- (?:\d:)?/.test(c)){let u=!1;for(let h=o.length-1;h>=0;h--){let p=o[h];if(/^```$/.test(p)||/^```encounter/.test(p))return null;if(/^players:/.test(p)){this._context=0,u=!0;break}if(/^creatures:/.test(p)){this._context=1,u=!0;break}}if(!u)return null;let[f,d]=c.match(/^\s+- (?:\d:)?(.*)$/);return{end:t,start:{ch:c.length-d.length,line:t.line},query:d}}return{end:t,start:{ch:0,line:t.line},query:c}}};var Iu,wp=class{constructor(e){this.plugin=e;Tl(this,Iu,he);(window.InitiativeTracker=this)&&this.plugin.register(()=>delete window.InitiativeTracker)}addCreatures(e,t=this.plugin.data.rollHP){if(!e||!Array.isArray(e)||!e.length)throw new Error("Creatures must be an array.");Fu(this,Iu).add(this.plugin,t,...e.map(n=>je.from(n)))}newEncounter(e){e?.creatures&&(e.creatures=e.creatures.map(t=>je.from(t).toJSON())),Fu(this,Iu).new(this.plugin,e)}};Iu=new WeakMap;var kp=class extends tn.Plugin{constructor(){super(...arguments);J(this,"api",new wp(this));J(this,"data");J(this,"tracker",he);J(this,"playerCreatures",new Map);J(this,"lastCombatantLeaf",null);J(this,"watchers",new Map);J(this,"_builderIcon")}getRoller(t){if(!this.canUseDiceRoller)return;let n=window.DiceRoller.getRoller(t,"statblock");return n===null?null:n}get canUseDiceRoller(){if(window.DiceRoller!=null)if(!window.DiceRoller.getRoller)new tn.Notice("Please update Dice Roller to the latest version to use with Initiative Tracker.");else return!0;return!1}getInitiativeValue(t=0){let n=Math.floor(Math.random()*19+1)+[t].flat().reduce((a,l)=>a+l,0);if(!this.canUseDiceRoller)return n;let r=this.data.initiative;if(typeof t=="number")r=r.replace(/%mod\d?%/g,`${t}`);else for(let a=0;an.name===t)?.players??[]}getPlayersForParty(t){return this.data.parties?.find(n=>n.name==t)?.players.map(n=>this.getPlayerByName(n))?.filter(n=>n)??[]}get canUseStatBlocks(){return this.app.plugins.enabledPlugins.has("obsidian-5e-statblocks")?(window.FantasyStatblocks?.getVersion()?.major??0)>=4:!1}get statblockVersion(){return window.FantasyStatblocks?.getVersion()??{major:0}}get statblock_creatures(){return window.FantasyStatblocks?window.FantasyStatblocks.getBestiaryCreatures():[]}get bestiary(){return this.statblock_creatures.filter(t=>!t.player&&t.bestiary!==!1)}addEncounter(t,n){this.data.encounters[t]=n,this.registerCommand(t)}removeEncounter(t){delete this.data.encounters[t],this.unregisterCommandsFor(t)}registerCommand(t){this.addCommand({id:`start-${t}`,name:`Start ${t}`,checkCallback:n=>{if(n)return t in this.data.encounters;t in this.data.encounters&&he.new(this,this.data.encounters[t])}})}unregisterCommandsFor(t){this.app.commands.findCommand(`initiative-tracker:start-${t}`)&&delete this.app.commands.commands[`initiative-tracker:start-${t}`]}get bestiaryNames(){return window.FantasyStatblocks?window.FantasyStatblocks.getBestiaryNames():[]}get view(){let t=this.app.workspace.getLeavesOfType(Mn),n=t?.length?t[0]:null;if(n&&n.view&&n.view instanceof Na)return n.view}get combatant(){let t=this.app.workspace.getLeavesOfType(ko),n=t?.length?t[0]:null;if(n&&n.view&&n.view instanceof ja)return n.view}get defaultParty(){return this.data.parties.find(t=>t.name==this.data.defaultParty)}getBaseCreatureFromBestiary(t){try{if(this.canUseStatBlocks&&window.FantasyStatblocks.hasCreature(t))return window.FantasyStatblocks.getCreatureFromBestiary(t)}catch{}return null}getCreatureFromBestiary(t){let n=this.getBaseCreatureFromBestiary(t);if(n)return je.from(n)}getCreatureFromBestiaryByDefinition(t){return t.player&&this.playerCreatures.has(t.name)?this.playerCreatures.get(t.name):this.getCreatureFromBestiary(t.name)??je.from(t)}get statblock_players(){return this.statblock_creatures.filter(t=>t.player).map(t=>[t.name,je.from(t)])}get players(){return new Map([...this.playerCreatures.entries(),...this.statblock_players])}async onload(){Py(),await this.loadSettings(),this.setBuilderIcon(),this.addSettingTab(new Bl(this)),this.registerView(Mn,t=>new Na(t,this)),this.registerView(Ds,t=>new Mu(t,this)),this.registerView(ko,t=>new ja(t,this)),this.registerView(nr,t=>new _l(t,this)),this.registerHoverLinkSource(Mn,{display:"Initiative Tracker",defaultMod:!1}),this.addCommands(),this.addEvents(),this.registerEditorSuggest(new bp(this)),this.registerMarkdownCodeBlockProcessor("encounter",(t,n,r)=>{if(this.canUseStatBlocks&&!window.FantasyStatblocks.isResolved()){n.addClasses(["waiting-for-bestiary","is-loading"]);let s=n.createEl("p",{text:"Waiting for Fantasy Statblocks Bestiary..."}),o=window.FantasyStatblocks.onResolved(()=>{n.removeClasses(["waiting-for-bestiary","is-loading"]),s.detach();let a=new Co(this,t,n);r.addChild(a),o()})}else{let s=new Co(this,t,n);r.addChild(s)}}),this.registerMarkdownCodeBlockProcessor("encounter-table",(t,n,r)=>{if(this.canUseStatBlocks&&!window.FantasyStatblocks.isResolved()){n.addClasses(["waiting-for-bestiary","is-loading"]);let s=n.createEl("p",{text:"Waiting for Fantasy Statblocks Bestiary..."}),o=window.FantasyStatblocks.onResolved(()=>{n.removeClasses(["waiting-for-bestiary","is-loading"]),s.detach();let a=new Co(this,t,n,!0);r.addChild(a),o()})}else{let s=new Co(this,t,n,!0);r.addChild(s)}}),this.registerMarkdownPostProcessor(async(t,n)=>{if(!t||!t.firstElementChild)return;let r=t.querySelectorAll("code");if(!r||!r.length)return;let s=Array.from(r).filter(o=>/^encounter:\s/.test(o.innerText));if(s.length)for(let o of s){let a=createSpan("initiative-tracker-encounter-line");o.replaceWith(a);let l=async()=>{let c=o.innerText.replace("encounter:",""),u=(0,tn.parseYaml)("["+c.trim()+"]"),d=await new Fl(this).parse({creatures:u});if(!d||!d.creatures||!d.creatures.size){a.setText("No creatures found.");return}new Sb({target:a,props:{...d,plugin:this}})};if(this.canUseStatBlocks&&!window.FantasyStatblocks.isResolved()){let c=a.createSpan("waiting-for-bestiary inline"),u=Math.floor(200*Math.random());(0,tn.setIcon)(c.createDiv({cls:"icon",attr:{style:`animation-delay: ${u}ms`}}),"loader-2"),c.createEl("em",{text:"Loading Bestiary..."});let f=window.FantasyStatblocks.onResolved(()=>{t.removeClasses(["waiting-for-bestiary","inline"]),c.detach(),l(),f()})}else l()}}),this.playerCreatures=new Map(this.data.players.map(t=>[t.name,je.from(t)])),this.app.workspace.onLayoutReady(async()=>{this.addTrackerView();for(let t of this.data.players){if(t.path||!t.note)continue;let n=await this.app.metadataCache.getFirstLinkpathDest(t.note,"");if(!n||!this.app.metadataCache.getFileCache(n)?.frontmatter){new tn.Notice(`Initiative Tracker: There was an issue with the linked note for ${t.name}. Please re-link it in settings.`);continue}}this.registerEvent(this.app.metadataCache.on("changed",t=>{if(!(t instanceof tn.TFile))return;let n=this.data.players.filter(s=>s.path==t.path);if(!n.length)return;let r=this.app.metadataCache.getFileCache(t)?.frontmatter;if(r)for(let s of n){let{ac:o,hp:a,modifier:l,level:c,name:u}=r;if(s.ac=o,s.hp=a,s.modifier=l,s.level=c,s.name=u||s.name,s["statblock-link"]=r["statblock-link"],this.playerCreatures.set(s.name,je.from(s)),this.view){let f=he.getOrderedCreatures().find(d=>d.name==s.name);f&&he.updateCreatures({creature:f,change:{set_max_hp:s.hp,ac:s.ac}})}}})),this.registerEvent(this.app.vault.on("rename",(t,n)=>{if(!(t instanceof tn.TFile))return;let r=this.data.players.filter(s=>s.path==n);if(r.length)for(let s of r)s.path=t.path,s.note=t.basename})),this.registerEvent(this.app.vault.on("delete",t=>{if(!(t instanceof tn.TFile))return;let n=this.data.players.filter(r=>r.path==t.path);if(n.length)for(let r of n)r.path=null,r.note=null}))}),console.log("Initiative Tracker v"+this.manifest.version+" loaded")}addCommands(){this.addCommand({id:"open-tracker",name:"Open Initiative Tracker",checkCallback:t=>{if(!this.view)return t||this.addTrackerView(),!0}}),this.addCommand({id:"open-builder",name:"Open Encounter Builder",checkCallback:t=>{if(!this.builder)return t||this.addBuilderView(),!0}}),this.addCommand({id:"toggle-encounter",name:"Toggle Encounter",checkCallback:t=>{if(this.view)return t||he.toggleState(),!0}}),this.addCommand({id:"next-combatant",name:"Next Combatant",checkCallback:t=>{if(this.view&&he.getState())return t||he.goToNext(),!0}}),this.addCommand({id:"prev-combatant",name:"Previous Combatant",checkCallback:t=>{if(this.view&&he.getState())return t||he.goToPrevious(),!0}});for(let t in this.data.encounters)this.registerCommand(t)}addEvents(){this.registerEvent(this.app.workspace.on("initiative-tracker:should-save",async()=>await this.saveSettings())),this.registerEvent(this.app.workspace.on("initiative-tracker:save-state",async t=>{this.data.state=t,await this.saveSettings()})),this.registerEvent(this.app.workspace.on("initiative-tracker:start-encounter",async t=>{try{let n=t.map(s=>je.from(s).toJSON()),r=this.view;r||await this.addTrackerView(),r?(he?.new(this,{creatures:n,state:!1,name:null,round:1,logFile:null,roll:!0}),this.app.workspace.revealLeaf(r.leaf)):new tn.Notice("Could not find the Initiative Tracker. Try reloading the note!")}catch(n){new tn.Notice(`There was an issue launching the encounter. `+n.message),console.error(n);return}}))}async onunload(){await this.saveSettings(),this.app.workspace.detachLeavesOfType(Mn),this.app.workspace.detachLeavesOfType(Ds),this.app.workspace.detachLeavesOfType(ko),this.app.workspace.detachLeavesOfType(nr),this.app.workspace.trigger("initiative-tracker:unloaded"),console.log("Initiative Tracker unloaded")}async addTrackerView(){this.app.workspace.getLeavesOfType(Mn)?.length||await this.app.workspace.ensureSideLeaf(Mn,"right",{active:!1})}get builder(){let t=this.app.workspace.getLeavesOfType(nr),n=t.length?t[0]:null;if(n&&n.view&&n.view instanceof _l)return n.view}async addBuilderView(){this.app.workspace.getLeavesOfType(nr)?.length||(await this.app.workspace.getLeaf(!0).setViewState({type:nr}),this.app.workspace.revealLeaf(this.builder.leaf))}async updatePlayer(t,n){if(!this.playerCreatures.has(t.name)){await this.savePlayer(n);return}let r=this.playerCreatures.get(t.name);r.update(n),this.data.players.splice(this.data.players.indexOf(t),1,n),this.playerCreatures.delete(t.name),this.playerCreatures.set(n.name,r),this.view&&he.updateState(),await this.saveSettings()}async savePlayer(t){this.data.players.push(t),this.playerCreatures.set(t.name,je.from(t)),await this.saveSettings()}async savePlayers(...t){for(let n of t)this.data.players.push(n),this.playerCreatures.set(n.name,je.from(n));await this.saveSettings()}async deletePlayer(t){this.data.players=this.data.players.filter(n=>n!=t),this.playerCreatures.delete(t.name),await this.saveSettings()}async loadSettings(){let t=Object.assign({},{...xy},await this.loadData());if(this.data=t,this.data.statuses?.some(n=>!n.id)){for(let n of this.data.statuses)n.id=n.id??ls.find(r=>r.name==n.name)?.id??xt();await this.saveSettings()}this.data.version=this.manifest.version.split(".").map(n=>Number(n))}async saveSettings(){await this.saveData(this.data),he.setData(this.data)}getActiveCombatant(){return this.lastCombatantLeaf?.view instanceof ja?this.lastCombatantLeaf.view:this.combatant}async openCombatant(t,n=!1){if(!this.canUseStatBlocks)return;let r=this.getActiveCombatant();if(n||!r){let s=this.app.workspace.getRightLeaf(!0);await s.setViewState({type:ko}),this.lastCombatantLeaf=s,await s.view.render(t),this.app.workspace.revealLeaf(s)}else this.lastCombatantLeaf=r.leaf,await r.render(t),this.app.workspace.revealLeaf(r.leaf)}setBuilderIcon(){this.data.builder.sidebarIcon?this._builderIcon=this.addRibbonIcon(nr,"Initiative Tracker Encounter Builder",()=>{this.addBuilderView()}):this._builderIcon?.detach()}}; /*! Bundled license information: uri-js/dist/es5/uri.all.js: (** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js *) */ /* nosourcemap */