/*
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 vC=Object.create;var xl=Object.defineProperty;var yC=Object.getOwnPropertyDescriptor;var bC=Object.getOwnPropertyNames;var _C=Object.getPrototypeOf,wC=Object.prototype.hasOwnProperty;var kC=(i,e,t)=>e in i?xl(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var De=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),SC=(i,e)=>{for(var t in e)xl(i,t,{get:e[t],enumerable:!0})},dy=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of bC(e))!wC.call(i,r)&&r!==t&&xl(i,r,{get:()=>e[r],enumerable:!(n=yC(e,r))||n.enumerable});return i};var xp=(i,e,t)=>(t=i!=null?vC(_C(i)):{},dy(e||!i||!i.__esModule?xl(t,"default",{value:i,enumerable:!0}):t,i)),xC=i=>dy(xl({},"__esModule",{value:!0}),i);var te=(i,e,t)=>(kC(i,typeof e!="symbol"?e+"":e,t),t),hy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Zu=(i,e,t)=>(hy(i,e,"read from private field"),t?t.call(i):e.get(i)),Pl=(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 Pp=(i,e,t)=>(hy(i,e,"access private method"),t);var Vp=De((gF,wy)=>{"use strict";var Fp=Object.defineProperty,uE=Object.getOwnPropertyDescriptor,fE=Object.getOwnPropertyNames,dE=Object.prototype.hasOwnProperty,hE=(i,e)=>{for(var t in e)Fp(i,t,{get:e[t],enumerable:!0})},pE=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of fE(e))!dE.call(i,r)&&r!==t&&Fp(i,r,{get:()=>e[r],enumerable:!(n=uE(e,r))||n.enumerable});return i},mE=i=>pE(Fp({},"__esModule",{value:!0}),i),_y={};hE(_y,{FileInputSuggest:()=>OE,FolderInputSuggest:()=>gE,FuzzyInputSuggest:()=>Bp,setNodeIcon:()=>bE});wy.exports=mE(_y);var $p=require("obsidian"),Bp=class extends $p.AbstractInputSuggest{constructor(i,e,t){super(i,e.inputEl),this.items=t}getSuggestions(i){let e=(0,$p.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,$p.renderMatches)(i,e,t,n)}},yy=require("obsidian"),gE=class extends Bp{getItemText(i){return i.path}renderNote(i,e){let{item:t,match:n}=e;(0,yy.renderMatches)(i,t.path,n.matches)}renderTitle(i,e){let{item:t,match:n}=e;(0,yy.renderMatches)(i,t.name,n.matches,t.path.length-t.name.length)}},by=require("obsidian"),OE=class extends Bp{getItemText(i){return i.path}renderNote(i,e){let{item:t,match:n}=e;(0,by.renderMatches)(i,t.path,n.matches)}renderTitle(i,e){let{item:t,match:n}=e;(0,by.renderMatches)(i,t.name,n.matches,t.path.length-t.name.length)}},vE=require("obsidian"),yE={"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 bE(i,e){i.addClass(yE["has-node-icon"]),(0,vE.setIcon)(i,e)}});var iu=De(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 eu=class{};pt._CodeOrName=eu;pt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Uo=class extends eu{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=Uo;var Bn=class extends eu{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 Uo&&(t[n.str]=(t[n.str]||0)+1),t),{})}};pt._Code=Bn;pt.nil=new Bn("");function a4(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=iu(),xO=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},PO;(function(i){i[i.Started=0]="Started",i[i.Completed=1]="Completed"})(PO=Ki.UsedValueState||(Ki.UsedValueState={}));Ki.varKinds={const:new On.Name("const"),let:new On.Name("let"),var:new On.Name("var")};var Ih=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=Ih;var Nh=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=Nh;var jN=(0,On._)`\n`,CO=class extends Ih{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?jN:On.nil}}get(){return this._scope}name(e){return new Nh(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,PO.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 xO(c);l.set(c,PO.Completed)})}return s}};Ki.ValueScope=CO});var Je=De(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.or=Ue.and=Ue.not=Ue.CodeGen=Ue.operators=Ue.varKinds=Ue.ValueScopeName=Ue.ValueScope=Ue.Scope=Ue.Name=Ue.regexpCode=Ue.stringify=Ue.getProperty=Ue.nil=Ue.strConcat=Ue.str=Ue._=void 0;var st=iu(),yr=EO(),no=iu();Object.defineProperty(Ue,"_",{enumerable:!0,get:function(){return no._}});Object.defineProperty(Ue,"str",{enumerable:!0,get:function(){return no.str}});Object.defineProperty(Ue,"strConcat",{enumerable:!0,get:function(){return no.strConcat}});Object.defineProperty(Ue,"nil",{enumerable:!0,get:function(){return no.nil}});Object.defineProperty(Ue,"getProperty",{enumerable:!0,get:function(){return no.getProperty}});Object.defineProperty(Ue,"stringify",{enumerable:!0,get:function(){return no.stringify}});Object.defineProperty(Ue,"regexpCode",{enumerable:!0,get:function(){return no.regexpCode}});Object.defineProperty(Ue,"Name",{enumerable:!0,get:function(){return no.Name}});var qh=EO();Object.defineProperty(Ue,"Scope",{enumerable:!0,get:function(){return qh.Scope}});Object.defineProperty(Ue,"ValueScope",{enumerable:!0,get:function(){return qh.ValueScope}});Object.defineProperty(Ue,"ValueScopeName",{enumerable:!0,get:function(){return qh.ValueScopeName}});Object.defineProperty(Ue,"varKinds",{enumerable:!0,get:function(){return qh.varKinds}});Ue.operators={GT:new st._Code(">"),GTE:new st._Code(">="),LT:new st._Code("<"),LTE:new st._Code("<="),EQ:new st._Code("==="),NEQ:new st._Code("!=="),NOT:new st._Code("!"),OR:new st._Code("||"),AND:new st._Code("&&"),ADD:new st._Code("+")};var ys=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},TO=class extends ys{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let n=e?yr.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=al(this.rhs,e,t)),this}get names(){return this.rhs instanceof st._CodeOrName?this.rhs.names:{}}},jh=class extends ys{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 st.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=al(this.rhs,e,t),this}get names(){let e=this.lhs instanceof st.Name?{}:{...this.lhs.names};return zh(e,this.rhs)}},AO=class extends jh{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},DO=class extends ys{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},QO=class extends ys{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},RO=class extends ys{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},MO=class extends ys{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=al(this.code,e,t),this}get names(){return this.code instanceof st._CodeOrName?this.code.names:{}}},nu=class extends ys{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)||(ZN(e,s.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>Ko(e,t.names),{})}},bs=class extends nu{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},IO=class extends nu{},ol=class extends bs{};ol.kind="else";var Ho=class i extends bs{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 ol(n):n}if(t)return e===!1?t instanceof i?t:t.nodes:this.nodes.length?this:new i(c4(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=al(this.condition,e,t),this}get names(){let e=super.names;return zh(e,this.condition),this.else&&Ko(e,this.else.names),e}};Ho.kind="if";var Go=class extends bs{};Go.kind="for";var NO=class extends Go{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=al(this.iteration,e,t),this}get names(){return Ko(super.names,this.iteration.names)}},jO=class extends Go{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?yr.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=zh(super.names,this.from);return zh(e,this.to)}},Zh=class extends Go{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=al(this.iterable,e,t),this}get names(){return Ko(super.names,this.iterable.names)}},ru=class extends bs{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)}};ru.kind="func";var su=class extends nu{render(e){return"return "+super.render(e)}};su.kind="return";var ZO=class extends bs{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&&Ko(e,this.catch.names),this.finally&&Ko(e,this.finally.names),e}},ou=class extends bs{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ou.kind="catch";var au=class extends bs{render(e){return"finally"+super.render(e)}};au.kind="finally";var zO=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
`:""},this._extScope=e,this._scope=new yr.Scope({parent:e}),this._nodes=[new IO]}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 TO(e,s,n)),s}const(e,t,n){return this._def(yr.varKinds.const,e,t,n)}let(e,t,n){return this._def(yr.varKinds.let,e,t,n)}var(e,t,n){return this._def(yr.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new jh(e,t,n))}add(e,t){return this._leafNode(new AO(e,Ue.operators.ADD,t))}code(e){return typeof e=="function"?e():e!==st.nil&&this._leafNode(new MO(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,st.addCodeArg)(t,r));return t.push("}"),new st._Code(t)}if(e,t,n){if(this._blockNode(new Ho(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 Ho(e))}else(){return this._elseNode(new ol)}endIf(){return this._endBlockNode(Ho,ol)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new NO(e),t)}forRange(e,t,n,r,s=this.opts.es5?yr.varKinds.var:yr.varKinds.let){let o=this._scope.toName(e);return this._for(new jO(s,o,t,n),()=>r(o))}forOf(e,t,n,r=yr.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let o=t instanceof st.Name?t:this.var("_arr",t);return this.forRange("_i",0,(0,st._)`${o}.length`,a=>{this.var(s,(0,st._)`${o}[${a}]`),n(s)})}return this._for(new Zh("of",r,s,t),()=>n(s))}forIn(e,t,n,r=this.opts.es5?yr.varKinds.var:yr.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,st._)`Object.keys(${t})`,n);let s=this._scope.toName(e);return this._for(new Zh("in",r,s,t),()=>n(s))}endFor(){return this._endBlockNode(Go)}label(e){return this._leafNode(new DO(e))}break(e){return this._leafNode(new QO(e))}return(e){let t=new su;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(su)}try(e,t,n){if(!t&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let r=new ZO;if(this._blockNode(r),this.code(e),t){let s=this.name("e");this._currNode=r.catch=new ou(s),t(s)}return n&&(this._currNode=r.finally=new au,this.code(n)),this._endBlockNode(ou,au)}throw(e){return this._leafNode(new RO(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=st.nil,n,r){return this._blockNode(new ru(e,t,n)),r&&this.code(r).endFunc(),this}endFunc(){return this._endBlockNode(ru)}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 Ho))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}};Ue.CodeGen=zO;function Ko(i,e){for(let t in e)i[t]=(i[t]||0)+(e[t]||0);return i}function zh(i,e){return e instanceof st._CodeOrName?Ko(i,e.names):i}function al(i,e,t){if(i instanceof st.Name)return n(i);if(!r(i))return i;return new st._Code(i._items.reduce((s,o)=>(o instanceof st.Name&&(o=n(o)),o instanceof st._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 st._Code&&s._items.some(o=>o instanceof st.Name&&e[o.str]===1&&t[o.str]!==void 0)}}function ZN(i,e){for(let t in e)i[t]=(i[t]||0)-(e[t]||0)}function c4(i){return typeof i=="boolean"||typeof i=="number"||i===null?!i:(0,st._)`!${qO(i)}`}Ue.not=c4;var zN=u4(Ue.operators.AND);function qN(...i){return i.reduce(zN)}Ue.and=qN;var LN=u4(Ue.operators.OR);function $N(...i){return i.reduce(LN)}Ue.or=$N;function u4(i){return(e,t)=>e===st.nil?t:t===st.nil?e:(0,st._)`${qO(e)} ${i} ${qO(t)}`}function qO(i){return i instanceof st.Name?i:(0,st._)`(${i})`}});var mt=De(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 Qt=Je(),FN=iu();function BN(i){let e={};for(let t of i)e[t]=!0;return e}He.toHash=BN;function VN(i,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(h4(i,e),!p4(e,i.self.RULES.all))}He.alwaysValidSchema=VN;function h4(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]||v4(i,`unknown keyword: "${s}"`)}He.checkUnknownRules=h4;function p4(i,e){if(typeof i=="boolean")return!i;for(let t in i)if(e[t])return!0;return!1}He.schemaHasRules=p4;function WN(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=WN;function XN({topSchemaRef:i,schemaPath:e},t,n,r){if(!r){if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return(0,Qt._)`${t}`}return(0,Qt._)`${i}${e}${(0,Qt.getProperty)(n)}`}He.schemaRefOrVal=XN;function YN(i){return m4(decodeURIComponent(i))}He.unescapeFragment=YN;function UN(i){return encodeURIComponent(LO(i))}He.escapeFragment=UN;function LO(i){return typeof i=="number"?`${i}`:i.replace(/~/g,"~0").replace(/\//g,"~1")}He.escapeJsonPointer=LO;function m4(i){return i.replace(/~1/g,"/").replace(/~0/g,"~")}He.unescapeJsonPointer=m4;function HN(i,e){if(Array.isArray(i))for(let t of i)e(t);else e(i)}He.eachItem=HN;function f4({mergeNames:i,mergeToName:e,mergeValues:t,resultToName:n}){return(r,s,o,a)=>{let l=o===void 0?s:o instanceof Qt.Name?(s instanceof Qt.Name?i(r,s,o):e(r,s,o),o):s instanceof Qt.Name?(e(r,o,s),s):t(s,o);return a===Qt.Name&&!(l instanceof Qt.Name)?n(r,l):l}}He.mergeEvaluated={props:f4({mergeNames:(i,e,t)=>i.if((0,Qt._)`${t} !== true && ${e} !== undefined`,()=>{i.if((0,Qt._)`${e} === true`,()=>i.assign(t,!0),()=>i.assign(t,(0,Qt._)`${t} || {}`).code((0,Qt._)`Object.assign(${t}, ${e})`))}),mergeToName:(i,e,t)=>i.if((0,Qt._)`${t} !== true`,()=>{e===!0?i.assign(t,!0):(i.assign(t,(0,Qt._)`${t} || {}`),$O(i,t,e))}),mergeValues:(i,e)=>i===!0?!0:{...i,...e},resultToName:g4}),items:f4({mergeNames:(i,e,t)=>i.if((0,Qt._)`${t} !== true && ${e} !== undefined`,()=>i.assign(t,(0,Qt._)`${e} === true ? true : ${t} > ${e} ? ${t} : ${e}`)),mergeToName:(i,e,t)=>i.if((0,Qt._)`${t} !== true`,()=>i.assign(t,e===!0?!0:(0,Qt._)`${t} > ${e} ? ${t} : ${e}`)),mergeValues:(i,e)=>i===!0?!0:Math.max(i,e),resultToName:(i,e)=>i.var("items",e)})};function g4(i,e){if(e===!0)return i.var("props",!0);let t=i.var("props",(0,Qt._)`{}`);return e!==void 0&&$O(i,t,e),t}He.evaluatedPropsToName=g4;function $O(i,e,t){Object.keys(t).forEach(n=>i.assign((0,Qt._)`${e}${(0,Qt.getProperty)(n)}`,!0))}He.setEvaluated=$O;var d4={};function GN(i,e){return i.scopeValue("func",{ref:e,code:d4[e.code]||(d4[e.code]=new FN._Code(e.code))})}He.useFunc=GN;var O4;(function(i){i[i.Num=0]="Num",i[i.Str=1]="Str"})(O4=He.Type||(He.Type={}));function KN(i,e,t){if(i instanceof Qt.Name){let n=e===O4.Num;return t?n?(0,Qt._)`"[" + ${i} + "]"`:(0,Qt._)`"['" + ${i} + "']"`:n?(0,Qt._)`"/" + ${i}`:(0,Qt._)`"/" + ${i}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return t?(0,Qt.getProperty)(i).toString():"/"+LO(i)}He.getErrorPath=KN;function v4(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=v4});var _s=De(FO=>{"use strict";Object.defineProperty(FO,"__esModule",{value:!0});var Li=Je(),JN={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")};FO.default=JN});var lu=De($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(),Lh=mt(),Ji=_s();$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 ej(i,e=$i.keywordError,t,n){let{it:r}=i,{gen:s,compositeRule:o,allErrors:a}=r,l=_4(i,e,t);n??(o||a)?y4(s,l):b4(r,(0,ft._)`[${l}]`)}$i.reportError=ej;function tj(i,e=$i.keywordError,t){let{it:n}=i,{gen:r,compositeRule:s,allErrors:o}=n,a=_4(i,e,t);y4(r,a),s||o||b4(n,Ji.default.vErrors)}$i.reportExtraError=tj;function ij(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=ij;function nj({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=nj;function y4(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 b4(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 Jo={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 _4(i,e,t){let{createErrors:n}=i.it;return n===!1?(0,ft._)`{}`:rj(i,e,t)}function rj(i,e,t={}){let{gen:n,it:r}=i,s=[sj(r,t),oj(i,t)];return aj(i,e,s),n.object(...s)}function sj({errorPath:i},{instancePath:e}){let t=e?(0,ft.str)`${i}${(0,Lh.getErrorPath)(e,Lh.Type.Str)}`:i;return[Ji.default.instancePath,(0,ft.strConcat)(Ji.default.instancePath,t)]}function oj({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,Lh.getErrorPath)(t,Lh.Type.Str)}`),[Jo.schemaPath,r]}function aj(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([Jo.keyword,r],[Jo.params,typeof e=="function"?e(i):e||(0,ft._)`{}`]),l.messages&&n.push([Jo.message,typeof t=="function"?t(i):t]),l.verbose&&n.push([Jo.schema,o],[Jo.parentSchema,(0,ft._)`${u}${f}`],[Ji.default.data,s]),c&&n.push([Jo.propertyName,c])}});var k4=De(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});ll.boolOrEmptySchema=ll.topBoolOrEmptySchema=void 0;var lj=lu(),cj=Je(),uj=_s(),fj={message:"boolean schema is false"};function dj(i){let{gen:e,schema:t,validateName:n}=i;t===!1?w4(i,!1):typeof t=="object"&&t.$async===!0?e.return(uj.default.data):(e.assign((0,cj._)`${n}.errors`,null),e.return(!0))}ll.topBoolOrEmptySchema=dj;function hj(i,e){let{gen:t,schema:n}=i;n===!1?(t.var(e,!1),w4(i)):t.var(e,!0)}ll.boolOrEmptySchema=hj;function w4(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,lj.reportError)(r,fj,void 0,e)}});var BO=De(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});cl.getRules=cl.isJSONType=void 0;var pj=["string","number","integer","boolean","null","object","array"],mj=new Set(pj);function gj(i){return typeof i=="string"&&mj.has(i)}cl.isJSONType=gj;function Oj(){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:{}}}cl.getRules=Oj});var VO=De(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.shouldUseRule=ro.shouldUseGroup=ro.schemaHasRulesForType=void 0;function vj({schema:i,self:e},t){let n=e.RULES.types[t];return n&&n!==!0&&S4(i,n)}ro.schemaHasRulesForType=vj;function S4(i,e){return e.rules.some(t=>x4(i,t))}ro.shouldUseGroup=S4;function x4(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))}ro.shouldUseRule=x4});var uu=De(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.reportTypeError=Qi.checkDataTypes=Qi.checkDataType=Qi.coerceAndCheckDataType=Qi.getJSONTypes=Qi.getSchemaTypes=Qi.DataType=void 0;var yj=BO(),bj=VO(),_j=lu(),Ve=Je(),P4=mt(),cu;(function(i){i[i.Correct=0]="Correct",i[i.Wrong=1]="Wrong"})(cu=Qi.DataType||(Qi.DataType={}));function wj(i){let e=C4(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}Qi.getSchemaTypes=wj;function C4(i){let e=Array.isArray(i)?i:i?[i]:[];if(e.every(yj.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Qi.getJSONTypes=C4;function kj(i,e){let{gen:t,data:n,opts:r}=i,s=Sj(e,r.coerceTypes),o=e.length>0&&!(s.length===0&&e.length===1&&(0,bj.schemaHasRulesForType)(i,e[0]));if(o){let a=XO(e,n,r.strictNumbers,cu.Wrong);t.if(a,()=>{s.length?xj(i,e,s):YO(i)})}return o}Qi.coerceAndCheckDataType=kj;var E4=new Set(["string","number","integer","boolean","null"]);function Sj(i,e){return e?i.filter(t=>E4.has(t)||e==="array"&&t==="array"):[]}function xj(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(XO(e,r,s.strictNumbers),()=>n.assign(a,r))),n.if((0,Ve._)`${a} !== undefined`);for(let c of t)(E4.has(c)||c==="array"&&s.coerceTypes==="array")&&l(c);n.else(),YO(i),n.endIf(),n.if((0,Ve._)`${a} !== undefined`,()=>{n.assign(r,a),Pj(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 Pj({gen:i,parentData:e,parentDataProperty:t},n){i.if((0,Ve._)`${e} !== undefined`,()=>i.assign((0,Ve._)`${e}[${t}]`,n))}function WO(i,e,t,n=cu.Correct){let r=n===cu.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===cu.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)}}Qi.checkDataType=WO;function XO(i,e,t,n){if(i.length===1)return WO(i[0],e,t,n);let r,s=(0,P4.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,WO(o,e,t,n));return r}Qi.checkDataTypes=XO;var Cj={message:({schema:i})=>`must be ${i}`,params:({schema:i,schemaValue:e})=>typeof i=="string"?(0,Ve._)`{type: ${i}}`:(0,Ve._)`{type: ${e}}`};function YO(i){let e=Ej(i);(0,_j.reportError)(e,Cj)}Qi.reportTypeError=YO;function Ej(i){let{gen:e,data:t,schema:n}=i,r=(0,P4.schemaRefOrVal)(i,n,"type");return{gen:e,keyword:"type",data:t,schema:n.type,schemaCode:r,schemaValue:r,parentSchema:n,params:{},it:i}}});var A4=De($h=>{"use strict";Object.defineProperty($h,"__esModule",{value:!0});$h.assignDefaults=void 0;var ul=Je(),Tj=mt();function Aj(i,e){let{properties:t,items:n}=i.schema;if(e==="object"&&t)for(let r in t)T4(i,r,t[r].default);else e==="array"&&Array.isArray(n)&&n.forEach((r,s)=>T4(i,s,r.default))}$h.assignDefaults=Aj;function T4(i,e,t){let{gen:n,compositeRule:r,data:s,opts:o}=i;if(t===void 0)return;let a=(0,ul._)`${s}${(0,ul.getProperty)(e)}`;if(r){(0,Tj.checkStrictMode)(i,`default is ignored for: ${a}`);return}let l=(0,ul._)`${a} === undefined`;o.useDefaults==="empty"&&(l=(0,ul._)`${l} || ${a} === null || ${a} === ""`),n.if(l,(0,ul._)`${a} = ${(0,ul.stringify)(t)}`)}});var Vn=De(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(),UO=mt(),so=_s(),Dj=mt();function Qj(i,e){let{gen:t,data:n,it:r}=i;t.if(GO(t,n,e,r.opts.ownProperties),()=>{i.setParams({missingProperty:(0,Lt._)`${e}`},!0),i.error()})}Et.checkReportMissingProp=Qj;function Rj({gen:i,data:e,it:{opts:t}},n,r){return(0,Lt.or)(...n.map(s=>(0,Lt.and)(GO(i,e,s,t.ownProperties),(0,Lt._)`${r} = ${s}`)))}Et.checkMissingProp=Rj;function Mj(i,e){i.setParams({missingProperty:e},!0),i.error()}Et.reportMissingProp=Mj;function D4(i){return i.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Lt._)`Object.prototype.hasOwnProperty`})}Et.hasPropFunc=D4;function HO(i,e,t){return(0,Lt._)`${D4(i)}.call(${e}, ${t})`}Et.isOwnProperty=HO;function Ij(i,e,t,n){let r=(0,Lt._)`${e}${(0,Lt.getProperty)(t)} !== undefined`;return n?(0,Lt._)`${r} && ${HO(i,e,t)}`:r}Et.propertyInData=Ij;function GO(i,e,t,n){let r=(0,Lt._)`${e}${(0,Lt.getProperty)(t)} === undefined`;return n?(0,Lt.or)(r,(0,Lt.not)(HO(i,e,t))):r}Et.noPropertyInData=GO;function Q4(i){return i?Object.keys(i).filter(e=>e!=="__proto__"):[]}Et.allSchemaProperties=Q4;function Nj(i,e){return Q4(e).filter(t=>!(0,UO.alwaysValidSchema)(i,e[t]))}Et.schemaProperties=Nj;function jj({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=[[so.default.instancePath,(0,Lt.strConcat)(so.default.instancePath,s)],[so.default.parentData,o.parentData],[so.default.parentDataProperty,o.parentDataProperty],[so.default.rootData,so.default.rootData]];o.opts.dynamicRef&&f.push([so.default.dynamicAnchors,so.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=jj;var Zj=(0,Lt._)`new RegExp`;function zj({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"?Zj:(0,Dj.useFunc)(i,r)}(${t}, ${n})`})}Et.usePattern=zj;function qj(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:UO.Type.Num},s),e.if((0,Lt.not)(s),a)})}}Et.validateArray=qj;function Lj(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,UO.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=Lj});var I4=De(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.validateKeywordUsage=Kr.validSchemaType=Kr.funcKeywordCode=Kr.macroKeywordCode=void 0;var en=Je(),ea=_s(),$j=Vn(),Fj=lu();function Bj(i,e){let{gen:t,keyword:n,schema:r,parentSchema:s,it:o}=i,a=e.macro.call(o.self,r,s,o),l=M4(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))}Kr.macroKeywordCode=Bj;function Vj(i,e){var t;let{gen:n,keyword:r,schema:s,parentSchema:o,$data:a,it:l}=i;Xj(l,e);let c=!a&&e.compile?e.compile.call(l.self,s,o,l):e.validate,u=M4(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&&R4(i),g(()=>i.error());else{let O=e.async?h():p();e.modifying&&R4(i),g(()=>Wj(i,O))}}function h(){let O=n.let("ruleErrs",null);return n.try(()=>m((0,en._)`await `),_=>n.assign(f,!1).if((0,en._)`${_} instanceof ${l.ValidationError}`,()=>n.assign(O,(0,en._)`${_}.errors`),()=>n.throw(_))),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 _=l.opts.passContext?ea.default.this:ea.default.self,S=!("compile"in e&&!a||e.schema===!1);n.assign(f,(0,en._)`${O}${(0,$j.callValidateCode)(i,u,_,S)}`,e.modifying)}function g(O){var _;n.if((0,en.not)((_=e.valid)!==null&&_!==void 0?_:f),O)}}Kr.funcKeywordCode=Vj;function R4(i){let{gen:e,data:t,it:n}=i;e.if(n.parentData,()=>e.assign(t,(0,en._)`${n.parentData}[${n.parentDataProperty}]`))}function Wj(i,e){let{gen:t}=i;t.if((0,en._)`Array.isArray(${e})`,()=>{t.assign(ea.default.vErrors,(0,en._)`${ea.default.vErrors} === null ? ${e} : ${ea.default.vErrors}.concat(${e})`).assign(ea.default.errors,(0,en._)`${ea.default.vErrors}.length`),(0,Fj.extendErrors)(i)},()=>i.error())}function Xj({schemaEnv:i},e){if(e.async&&!i.$async)throw new Error("async keyword in sync schema")}function M4(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 Yj(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")}Kr.validSchemaType=Yj;function Uj({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)}}Kr.validateKeywordUsage=Uj});var j4=De(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.extendSubschemaMode=oo.extendSubschemaData=oo.getSubschema=void 0;var Jr=Je(),N4=mt();function Hj(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,Jr._)`${i.schemaPath}${(0,Jr.getProperty)(e)}`,errSchemaPath:`${i.errSchemaPath}/${e}`}:{schema:a[t],schemaPath:(0,Jr._)`${i.schemaPath}${(0,Jr.getProperty)(e)}${(0,Jr.getProperty)(t)}`,errSchemaPath:`${i.errSchemaPath}/${e}/${(0,N4.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')}oo.getSubschema=Hj;function Gj(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,Jr._)`${e.data}${(0,Jr.getProperty)(t)}`,!0);l(d),i.errorPath=(0,Jr.str)`${c}${(0,N4.getErrorPath)(t,n,f.jsPropertySyntax)}`,i.parentDataProperty=(0,Jr._)`${t}`,i.dataPathArr=[...u,i.parentDataProperty]}if(r!==void 0){let c=r instanceof Jr.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]}}oo.extendSubschemaData=Gj;function Kj(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}oo.extendSubschemaMode=Kj});var KO=De((Uee,Z4)=>{"use strict";Z4.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 q4=De((Hee,z4)=>{"use strict";var ao=z4.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(){};Fh(e,n,r,i,"",i)};ao.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};ao.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};ao.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};ao.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 Fh(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 ao.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 eZ=mt(),tZ=KO(),iZ=q4(),nZ=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function rZ(i,e=!0){return typeof i=="boolean"?!0:e===!0?!JO(i):e?L4(i)<=e:!1}vn.inlineRef=rZ;var sZ=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function JO(i){for(let e in i){if(sZ.has(e))return!0;let t=i[e];if(Array.isArray(t)&&t.some(JO)||typeof t=="object"&&JO(t))return!0}return!1}function L4(i){let e=0;for(let t in i){if(t==="$ref")return 1/0;if(e++,!nZ.has(t)&&(typeof i[t]=="object"&&(0,eZ.eachItem)(i[t],n=>e+=L4(n)),e===1/0))return 1/0}return e}function $4(i,e="",t){t!==!1&&(e=fl(e));let n=i.parse(e);return F4(i,n)}vn.getFullPath=$4;function F4(i,e){return i.serialize(e).split("#")[0]+"#"}vn._getFullPath=F4;var oZ=/#\/?$/;function fl(i){return i?i.replace(oZ,""):""}vn.normalizeId=fl;function aZ(i,e,t){return t=fl(t),i.resolve(e,t)}vn.resolveUrl=aZ;var lZ=/^[a-z_][-a-z0-9._]*$/i;function cZ(i,e){if(typeof i=="boolean")return{};let{schemaId:t,uriResolver:n}=this.opts,r=fl(i[t]||e),s={"":r},o=$4(n,r,!1),a={},l=new Set;return iZ(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])),_.call(this,f.$anchor),_.call(this,f.$dynamicAnchor),s[d]=g;function O(S){let P=this.opts.uriResolver.resolve;if(S=fl(g?P(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!==fl(m)&&(S[0]==="#"?(c(f,a[S],S),a[S]=f):this.refs[S]=m),S}function _(S){if(typeof S=="string"){if(!lZ.test(S))throw new Error(`invalid anchor "${S}"`);O.call(this,`#${S}`)}}}),a;function c(f,d,h){if(d!==void 0&&!tZ(f,d))throw u(h)}function u(f){return new Error(`reference "${f}" resolves to more than one schema`)}}vn.getSchemaRefs=cZ});var pu=De(lo=>{"use strict";Object.defineProperty(lo,"__esModule",{value:!0});lo.getData=lo.KeywordCxt=lo.validateFunctionCode=void 0;var Y4=k4(),B4=uu(),tv=VO(),Bh=uu(),uZ=A4(),hu=I4(),ev=j4(),Me=Je(),Ze=_s(),fZ=fu(),ws=mt(),du=lu();function dZ(i){if(G4(i)&&(K4(i),H4(i))){mZ(i);return}U4(i,()=>(0,Y4.topBoolOrEmptySchema)(i))}lo.validateFunctionCode=dZ;function U4({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"; ${V4(t,r)}`),pZ(i,r),i.code(s)}):i.func(e,(0,Me._)`${Ze.default.data}, ${hZ(r)}`,n.$async,()=>i.code(V4(t,r)).code(s))}function hZ(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 pZ(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;U4(i,()=>{t.$comment&&e.$comment&&e3(i),bZ(i),n.let(Ze.default.vErrors,null),n.let(Ze.default.errors,0),t.unevaluated&&gZ(i),J4(i),kZ(i)})}function gZ(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 V4(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 OZ(i,e){if(G4(i)&&(K4(i),H4(i))){vZ(i,e);return}(0,Y4.boolOrEmptySchema)(i,e)}function H4({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 G4(i){return typeof i.schema!="boolean"}function vZ(i,e){let{schema:t,gen:n,opts:r}=i;r.$comment&&t.$comment&&e3(i),_Z(i),wZ(i);let s=n.const("_errs",Ze.default.errors);J4(i,s),n.var(e,(0,Me._)`${s} === ${Ze.default.errors}`)}function K4(i){(0,ws.checkUnknownRules)(i),yZ(i)}function J4(i,e){if(i.opts.jtd)return W4(i,[],!1,e);let t=(0,B4.getSchemaTypes)(i.schema),n=(0,B4.coerceAndCheckDataType)(i,t);W4(i,t,!n,e)}function yZ(i){let{schema:e,errSchemaPath:t,opts:n,self:r}=i;e.$ref&&n.ignoreKeywordsWithRef&&(0,ws.schemaHasRulesButRef)(e,r.RULES)&&r.logger.warn(`$ref: keywords ignored in schema at path "${t}"`)}function bZ(i){let{schema:e,opts:t}=i;e.default!==void 0&&t.useDefaults&&t.strictSchema&&(0,ws.checkStrictMode)(i,"default is ignored in the schema root")}function _Z(i){let e=i.schema[i.opts.schemaId];e&&(i.baseId=(0,fZ.resolveUrl)(i.opts.uriResolver,i.baseId,e))}function wZ(i){if(i.schema.$async&&!i.schemaEnv.$async)throw new Error("async schema in sync schema")}function e3({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 kZ(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&&SZ(i),e.return((0,Me._)`${Ze.default.errors} === 0`))}function SZ({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 W4(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,ws.schemaHasRulesButRef)(s,u))){r.block(()=>i3(i,"$ref",u.all.$ref.definition));return}l.jtd||xZ(i,e),r.block(()=>{for(let d of u.rules)f(d);f(u.post)});function f(d){(0,tv.shouldUseGroup)(s,d)&&(d.type?(r.if((0,Bh.checkDataType)(d.type,o,l.strictNumbers)),X4(i,d),e.length===1&&e[0]===d.type&&t&&(r.else(),(0,Bh.reportTypeError)(i)),r.endIf()):X4(i,d),a||r.if((0,Me._)`${Ze.default.errors} === ${n||0}`))}}function X4(i,e){let{gen:t,schema:n,opts:{useDefaults:r}}=i;r&&(0,uZ.assignDefaults)(i,e.type),t.block(()=>{for(let s of e.rules)(0,tv.shouldUseRule)(n,s)&&i3(i,s.keyword,s.definition,e.type)})}function xZ(i,e){i.schemaEnv.meta||!i.opts.strictTypes||(PZ(i,e),i.opts.allowUnionTypes||CZ(i,e),EZ(i,i.dataTypes))}function PZ(i,e){if(e.length){if(!i.dataTypes.length){i.dataTypes=e;return}e.forEach(t=>{t3(i.dataTypes,t)||iv(i,`type "${t}" not allowed by context "${i.dataTypes.join(",")}"`)}),AZ(i,e)}}function CZ(i,e){e.length>1&&!(e.length===2&&e.includes("null"))&&iv(i,"use allowUnionTypes to allow union type keyword")}function EZ(i,e){let t=i.self.RULES.all;for(let n in t){let r=t[n];if(typeof r=="object"&&(0,tv.shouldUseRule)(i.schema,r)){let{type:s}=r.definition;s.length&&!s.some(o=>TZ(e,o))&&iv(i,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function TZ(i,e){return i.includes(e)||e==="number"&&i.includes("integer")}function t3(i,e){return i.includes(e)||e==="integer"&&i.includes("number")}function AZ(i,e){let t=[];for(let n of i.dataTypes)t3(e,n)?t.push(n):e.includes("integer")&&n==="number"&&t.push("integer");i.dataTypes=t}function iv(i,e){let t=i.schemaEnv.baseId+i.errSchemaPath;e+=` at "${t}" (strictTypes)`,(0,ws.checkStrictMode)(i,e,i.opts.strictTypes)}var Vh=class{constructor(e,t,n){if((0,hu.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,ws.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",n3(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,hu.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?du.reportExtraError:du.reportError)(this,this.def.error,t)}$dataError(){(0,du.reportError)(this,this.def.$dataError||du.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,du.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,Bh.checkDataTypes)(l,t,s.opts.strictNumbers,Bh.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,ev.getSubschema)(this.it,e);(0,ev.extendSubschemaData)(n,this.it,e),(0,ev.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return OZ(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=ws.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=ws.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}};lo.KeywordCxt=Vh;function i3(i,e,t,n){let r=new Vh(i,t,e);"code"in t?t.code(r,n):r.$data&&t.validate?(0,hu.funcKeywordCode)(r,t):"macro"in t?(0,hu.macroKeywordCode)(r,t):(t.compile||t.validate)&&(0,hu.funcKeywordCode)(r,t)}var DZ=/^\/(?:[^~]|~0|~1)*$/,QZ=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function n3(i,{dataLevel:e,dataNames:t,dataPathArr:n}){let r,s;if(i==="")return Ze.default.rootData;if(i[0]==="/"){if(!DZ.test(i))throw new Error(`Invalid JSON-pointer: ${i}`);r=i,s=Ze.default.rootData}else{let c=QZ.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,ws.unescapeJsonPointer)(c))}`,o=(0,Me._)`${o} && ${s}`);return o;function l(c,u){return`Cannot access ${c} ${u} levels up, current level is ${e}`}}lo.getData=n3});var Wh=De(rv=>{"use strict";Object.defineProperty(rv,"__esModule",{value:!0});var nv=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};rv.default=nv});var Xh=De(av=>{"use strict";Object.defineProperty(av,"__esModule",{value:!0});var sv=fu(),ov=class extends Error{constructor(e,t,n,r){super(r||`can't resolve reference ${n} from id ${t}`),this.missingRef=(0,sv.resolveUrl)(e,t,n),this.missingSchema=(0,sv.normalizeId)((0,sv.getFullPath)(e,this.missingRef))}};av.default=ov});var Uh=De(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.resolveSchema=Wn.getCompilingSchema=Wn.resolveRef=Wn.compileSchema=Wn.SchemaEnv=void 0;var br=Je(),RZ=Wh(),ta=_s(),_r=fu(),r3=mt(),MZ=pu(),dl=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,_r.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Wn.SchemaEnv=dl;function cv(i){let e=s3.call(this,i);if(e)return e;let t=(0,_r.getFullPath)(this.opts.uriResolver,i.root.baseId),{es5:n,lines:r}=this.opts.code,{ownProperties:s}=this.opts,o=new br.CodeGen(this.scope,{es5:n,lines:r,ownProperties:s}),a;i.$async&&(a=o.scopeValue("Error",{ref:RZ.default,code:(0,br._)`require("ajv/dist/runtime/validation_error").default`}));let l=o.scopeName("validate");i.validateName=l;let c={gen:o,allErrors:this.opts.allErrors,data:ta.default.data,parentData:ta.default.parentData,parentDataProperty:ta.default.parentDataProperty,dataNames:[ta.default.data],dataPathArr:[br.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:i.schema,code:(0,br.stringify)(i.schema)}:{ref:i.schema}),validateName:l,ValidationError:a,schema:i.schema,schemaEnv:i,rootId:t,baseId:i.baseId||t,schemaPath:br.nil,errSchemaPath:i.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,br._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(i),(0,MZ.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);let f=o.toString();u=`${o.scopeRefs(ta.default.scope)}return ${f}`,this.opts.code.process&&(u=this.opts.code.process(u,i));let h=new Function(`${ta.default.self}`,`${ta.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 br.Name?void 0:p,items:m instanceof br.Name?void 0:m,dynamicProps:p instanceof br.Name,dynamicItems:m instanceof br.Name},h.source&&(h.source.evaluated=(0,br.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)}}Wn.compileSchema=cv;function IZ(i,e,t){var n;t=(0,_r.resolveUrl)(this.opts.uriResolver,e,t);let r=i.refs[t];if(r)return r;let s=ZZ.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 dl({schema:o,schemaId:a,root:i,baseId:e}))}if(s!==void 0)return i.refs[t]=NZ.call(this,s)}Wn.resolveRef=IZ;function NZ(i){return(0,_r.inlineRef)(i.schema,this.opts.inlineRefs)?i.schema:i.validate?i:cv.call(this,i)}function s3(i){for(let e of this._compilations)if(jZ(e,i))return e}Wn.getCompilingSchema=s3;function jZ(i,e){return i.schema===e.schema&&i.root===e.root&&i.baseId===e.baseId}function ZZ(i,e){let t;for(;typeof(t=this.refs[e])=="string";)e=t;return t||this.schemas[e]||Yh.call(this,i,e)}function Yh(i,e){let t=this.opts.uriResolver.parse(e),n=(0,_r._getFullPath)(this.opts.uriResolver,t),r=(0,_r.getFullPath)(this.opts.uriResolver,i.baseId,void 0);if(Object.keys(i.schema).length>0&&n===r)return lv.call(this,t,i);let s=(0,_r.normalizeId)(n),o=this.refs[s]||this.schemas[s];if(typeof o=="string"){let a=Yh.call(this,i,o);return typeof a?.schema!="object"?void 0:lv.call(this,t,a)}if(typeof o?.schema=="object"){if(o.validate||cv.call(this,o),s===(0,_r.normalizeId)(e)){let{schema:a}=o,{schemaId:l}=this.opts,c=a[l];return c&&(r=(0,_r.resolveUrl)(this.opts.uriResolver,r,c)),new dl({schema:a,schemaId:l,root:i,baseId:r})}return lv.call(this,t,o)}}Wn.resolveSchema=Yh;var zZ=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function lv(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,r3.unescapeFragment)(a)];if(l===void 0)return;t=l;let c=typeof t=="object"&&t[this.opts.schemaId];!zZ.has(a)&&c&&(e=(0,_r.resolveUrl)(this.opts.uriResolver,e,c))}let s;if(typeof t!="boolean"&&t.$ref&&!(0,r3.schemaHasRulesButRef)(t,this.RULES)){let a=(0,_r.resolveUrl)(this.opts.uriResolver,e,t.$ref);s=Yh.call(this,n,a)}let{schemaId:o}=this.opts;if(s=s||new dl({schema:t,schemaId:o,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var o3=De((ite,qZ)=>{qZ.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 l3=De((Hh,a3)=>{(function(i,e){typeof Hh=="object"&&typeof a3<"u"?e(Hh):typeof define=="function"&&define.amd?define(["exports"],e):e(i.URI=i.URI||{})})(Hh,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,ee=1;ee= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=h-p,Z=Math.floor,Q=String.fromCharCode;function D(F){throw new RangeError(C[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(x,".");var ee=F.split("."),Pe=E(ee,N).join(".");return K+Pe}function z(F){for(var N=[],W=0,K=F.length;W=55296&&ee<=56319&&W>1,N+=Z(N/W);N>M*m>>1;ee+=h)N=Z(N/M);return Z(ee+(M+1)*N/(N+g))},xe=function(N){var W=[],K=N.length,ee=0,Pe=S,Le=_,rt=N.lastIndexOf(P);rt<0&&(rt=0);for(var Ot=0;Ot
"),t.style.display="none",t.style.position="fixed",t.style.zIndex="-5",t}function Sa(i){if(!Pm){ai||bm(),ai.innerHTML="";var e=document.createTextNode(i);ai.appendChild(e),ai.style.display="none",ai.style.display="inline"}}var H6="--any--",Nb={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Nn=!1,_m,Ni,Ao="",Eo,sr,Is="",Pf=new WeakSet,jb=new WeakMap,Zb=new WeakMap,wm=new Map,xi=new Map,or=new Map,Cf;function G6(i,e){Be(function(){return"registering drop-zone if absent"}),or.size===0&&(Be(function(){return"adding global keydown and click handlers"}),Cf=X6(),window.addEventListener("keydown",t_),window.addEventListener("click",i_)),or.has(e)||or.set(e,new Set),or.get(e).has(i)||(or.get(e).add(i),$b())}function zb(i,e){Be(function(){return"unregistering drop-zone"}),Ni===i&&Yl(),or.get(e).delete(i),Fb(),or.get(e).size===0&&or.delete(e),or.size===0&&(Be(function(){return"removing global keydown and click handlers"}),window.removeEventListener("keydown",t_),window.removeEventListener("click",i_),Cf=void 0,Y6())}function t_(i){if(Nn)switch(i.key){case"Escape":{Yl();break}}}function i_(){Nn&&(Pf.has(document.activeElement)||(Be(function(){return"clicked outside of any draggable"}),Yl()))}function K6(i){if(Be(function(){return"zone focus"}),!!Nn){var e=i.currentTarget;if(e!==Ni){Ao=e.getAttribute("aria-label")||"";var t=xi.get(Ni),n=t.items,r=n.find(function(f){return f[_i]===sr}),s=n.indexOf(r),o=n.splice(s,1)[0],a=xi.get(e),l=a.items,c=a.autoAriaDisabled;e.getBoundingClientRect().top0&&arguments[0]!==void 0?arguments[0]:!0;Be(function(){return"drop"}),xi.get(Ni).autoAriaDisabled||Sa("Stopped dragging item ".concat(Is)),Pf.has(document.activeElement)&&document.activeElement.blur(),i&&js(Ni,xi.get(Ni).items,{trigger:Xi.DRAG_STOPPED,id:sr,source:dn.KEYBOARD}),Sf(or.get(_m),function(e){return xi.get(e).dropTargetStyle},function(e){return xi.get(e).dropTargetClasses}),Eo=null,sr=null,Is="",_m=null,Ni=null,Ao="",Nn=!1,n_()}function J6(i,e){var t={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,zoneItemTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:Nb,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)&&!Pf.has(u.target))return;u.preventDefault(),u.stopPropagation(),Nn?Yl():s(u);break}case"ArrowDown":case"ArrowRight":{if(!Nn)return;u.preventDefault(),u.stopPropagation();var f=xi.get(i),d=f.items,h=Array.from(i.children),p=h.indexOf(u.currentTarget);Be(function(){return["arrow down",p]}),p0&&(t.autoAriaDisabled||Sa("Moved item ".concat(Is," to position ").concat(_," in the list ").concat(Ao)),n(g,_,_-1),Pa(i,g,{trigger:Xi.DROPPED_INTO_ZONE,id:sr,source:dn.KEYBOARD}));break}}}function s(u){Be(function(){return"drag start"}),a(u.currentTarget),Ni=i,_m=t.type,Nn=!0;var f=Array.from(or.get(t.type)).filter(function(h){return h===Ni||!xi.get(h).dropFromOthersDisabled});if(bf(f,function(h){return xi.get(h).dropTargetStyle},function(h){return xi.get(h).dropTargetClasses}),!t.autoAriaDisabled){var d="Started dragging item ".concat(Is,". Use the arrow keys to move it within its list ").concat(Ao);f.length>1&&(d+=", or tab to another list in order to move the item into it"),Sa(d)}js(i,xi.get(i).items,{trigger:Xi.DRAG_STARTED,id:sr,source:dn.KEYBOARD}),n_()}function o(u){Nn&&u.currentTarget!==Eo&&(u.stopPropagation(),Yl(!1),s(u))}function a(u){var f=xi.get(i),d=f.items,h=Array.from(i.children),p=h.indexOf(u);Eo=u,Eo.tabIndex=t.zoneItemTabIndex,sr=d[p][_i],Is=h[p].getAttribute("aria-label")||""}function l(u){var f=u.items,d=f===void 0?[]:f,h=u.type,p=h===void 0?H6:h,m=u.dragDisabled,g=m===void 0?!1:m,O=u.zoneTabIndex,_=O===void 0?0:O,S=u.zoneItemTabIndex,P=S===void 0?0:S,k=u.dropFromOthersDisabled,w=k===void 0?!1:k,x=u.dropTargetStyle,C=x===void 0?Nb:x,M=u.dropTargetClasses,Z=M===void 0?[]:M,Q=u.autoAriaDisabled,D=Q===void 0?!1:Q;t.items=jn(d),t.dragDisabled=g,t.dropFromOthersDisabled=w,t.zoneTabIndex=_,t.zoneItemTabIndex=P,t.dropTargetStyle=C,t.dropTargetClasses=Z,t.autoAriaDisabled=D,t.type&&p!==t.type&&zb(i,t.type),t.type=p,G6(i,p),D||(i.setAttribute("aria-disabled",g),i.setAttribute("role","list"),i.setAttribute("aria-describedby",g?Cf.DND_ZONE_DRAG_DISABLED:Cf.DND_ZONE_ACTIVE)),xi.set(i,t),Nn?i.tabIndex=i===Ni||Eo.contains(i)||t.dropFromOthersDisabled||Ni&&t.type!==xi.get(Ni).type?-1:0:i.tabIndex=t.zoneTabIndex,i.addEventListener("focus",K6);for(var E=function(q){var G=i.children[q];Pf.add(G),G.tabIndex=Nn?-1:t.zoneItemTabIndex,D||G.setAttribute("role","listitem"),G.removeEventListener("keydown",jb.get(G)),G.removeEventListener("click",Zb.get(G)),g||(G.addEventListener("keydown",r),jb.set(G,r),G.addEventListener("click",o),Zb.set(G,o)),Nn&&t.items[q][_i]===sr&&(Be(function(){return["focusing on",{i:q,focusedItemId:sr}]}),Eo=G,Eo.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,_i)});if(m)throw new Error("missing '".concat(_i,"' property for item ").concat(Ir(m)));if(u&&!Array.isArray(u))throw new Error("dropTargetClasses should be an array but instead it is a ".concat(Vl(u),", ").concat(Ir(u)));if(a&&!Lb(a))throw new Error("zoneTabIndex should be a number but instead it is a ".concat(Vl(a),", ").concat(Ir(a)));if(l&&!Lb(l))throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(Vl(l),", ").concat(Ir(l)))}function Lb(i){return!isNaN(i)&&function(e){return(e|0)===e}(parseFloat(i))}function Ea(i){let e=i-1;return e*e*e+1}function Nr(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=Ea}=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,_=h+p*e.height/t.height;return`transform: ${s} translate(${m}px, ${g}px) scale(${O}, ${_});`}}}function i7(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 r_(i,e,t){let n=i.slice();return n[19]=e[t].creature,n[20]=e[t].id,n}function n7(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 r7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=[],O=new Map,_,S,P,k,w=fe(i[1]),x=C=>C[20];for(let C=0;C{o[u]=null}),Te(),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 Am=300;function o7(i,e,t){let n,r,s,o;ke(i,he,w=>t(18,r=w));let a=Ye("plugin"),{state:l,ordered:c}=he;ke(i,l,w=>t(2,o=w)),ke(i,c,w=>t(0,s=w));let u=Fe(),f=w=>{(0,Jl.setIcon)(w,an)},d=w=>{(0,Jl.setIcon)(w,tr)};function h(w){t(1,n=w.detail.items)}function p(w){if(w.detail.items.length>1){let x=w.detail.items.find(({id:M})=>M==w.detail.info.id),C=w.detail.items.findIndex(M=>M.id==w.detail.info.id);C==w.detail.items.length-1?x.creature.initiative=w.detail.items[C-1].creature.initiative:x.creature.initiative=w.detail.items[C+1].creature.initiative,he.logNewInitiative(x.creature)}t(1,n=w.detail.items),Ke(he,r=[...n.map(({creature:x},C)=>(x.manualOrder=C,x))],r)}let m=w=>{new Jl.ExtraButtonComponent(w).setIcon(Ts)},g=w=>he.roll(a);function O(w){ht.call(this,i,w)}function _(w){ht.call(this,i,w)}function S(w){ht.call(this,i,w)}function P(w){ht.call(this,i,w)}let k=(w,x)=>{u("open-combatant",w),x.stopPropagation()};return i.$$.update=()=>{i.$$.dirty&1&&t(1,n=[...s].map(w=>({creature:w,id:xt()})))},[s,n,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P,k]}var Dm=class extends ne{constructor(e){super(),re(this,e,o7,s7,ie,{},i7)}},o_=Dm;function Ta(i){return Object.prototype.toString.call(i)==="[object Date]"}function Qm(i,e,t,n){if(typeof t=="number"||Ta(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)Qm(i,e[s],t[s],n[s]));if(typeof t=="object"){let r={};for(let s in t)r[s]=Qm(i,e[s],t[s],n[s]);return r}else throw new Error(`Cannot spring ${typeof t} values`)}}function a_(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 _=l={};return i==null||O.hard||m.stiffness>=1&&m.damping>=1?(h=!0,o=us(),c=g,t.set(i=u),Promise.resolve()):(O.soft&&(d=1/((O.soft===!0?.5:+O.soft)*60),f=0),a||(o=us(),h=!1,a=As(S=>{if(h)return h=!1,a=null,!1;f=Math.min(f+d,1);let P={inv_mass:f,opts:m,settled:!0,dt:(S-o)*60/1e3},k=Qm(P,c,i,u);return o=S,c=i,t.set(i=k),P.settled&&(a=null),!P.settled})),new Promise(S=>{a.promise.then(()=>{_===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 Rm(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)=>Rm(i[s],r));return r=>n.map(s=>s(r))}if(t==="object"){if(!i||!e)throw new Error("Object cannot be null");if(Ta(i)&&Ta(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]=Rm(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 l_(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=In,interpolate:h=Rm}=ti(ti({},e),a);if(f===0)return l&&(l.abort(),l=null),t.set(i=r),Promise.resolve();let p=us()+u,m;return n=As(g=>{if(g
f?(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 a7(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 l7(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=R(),o=b("span"),a=b("meter"),l=R(),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 c7(i,e,t){let n,r,s,{difficulty:o}=he,a=Ye("plugin"),l=o(a);ke(i,l,u=>t(0,r=u));let c=l_(0,{duration:400,easing:Ea});return ke(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 Mm=class extends ne{constructor(e){super(),re(this,e,c7,l7,ie,{},a7)}},c_=Mm;function u7(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 u_(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 f_(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 d_(i){let e,t;return e=new c_({}),{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 h_(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 p_(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 f7(i){let e,t,n,r,s,o,a,l=i[0]&&i[0].length&&u_(i),c=i[1]?.difficulty?.value>0&&f_(i),u=i[1]&&d_(i),f=i[2]&&h_(i),d=i[3]&&p_(i);return{c(){e=b("div"),t=b("div"),l&&l.c(),n=R(),c&&c.c(),r=R(),u&&u.c(),s=R(),f&&f.c(),o=R(),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=u_(h),l.c(),l.m(t,n)):l&&(l.d(1),l=null),h[1]?.difficulty?.value>0?c?c.p(h,p):(c=f_(h),c.c(),c.m(t,null)):c&&(c.d(1),c=null),h[1]?u?p&2&&$(u,1):(u=d_(h),u.c(),$(u,1),u.m(e,s)):u&&(Ee(),V(u,1,1,()=>{u=null}),Te()),h[2]?f?f.p(h,p):(f=h_(h),f.c(),f.m(e,o)):f&&(f.d(1),f=null),h[3]?d?d.p(h,p):(d=p_(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 d7(i,e,t){let n,r,s,o,a,{state:l,name:c,round:u,party:f,difficulty:d}=he;ke(i,l,g=>t(3,o=g)),ke(i,c,g=>t(0,n=g)),ke(i,u,g=>t(4,a=g)),ke(i,f,g=>t(2,s=g));let h=Ye("plugin"),p=Si(h),m=d(h);return ke(i,m,g=>t(1,r=g)),[n,r,s,o,a,l,c,u,f,p,m]}var Im=class extends ne{constructor(e){super(),re(this,e,d7,f7,ie,{},u7)}},m_=Im;var Nm=require("obsidian");function h7(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 g_(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 p7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=i[1]&&g_(i);return{c(){e=b("div"),t=b("div"),n=b("span"),n.textContent="Save encounter as:",r=R(),s=b("input"),o=R(),a=b("div"),g&&g.c(),l=R(),c=b("div"),f=R(),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,_){A(O,e,_),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=[Y(s,"input",i[6]),Y(s,"input",i[3]),H(u=i[4].call(null,c)),H(h=i[5].call(null,d))],p=!0)},p(O,[_]){_&1&&s.value!==O[0]&&Xe(s,O[0]),O[1]?g||(g=g_(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 m7(i,e,t){let n,{name:r}=he;ke(i,r,p=>t(8,n=p));let s=n,o=Ye("plugin"),a,l=()=>{s?.length&&a.disabled?a.setDisabled(!1):!s?.length&&!a.disabled&&a.setDisabled(!0)},c=!1,u=p=>{a=new Nm.ExtraButtonComponent(p).setIcon(Cl).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 Nm.ExtraButtonComponent(p).setIcon("cross").onClick(()=>{f("cancel")})};function h(){s=this.value,t(0,s)}return[s,c,r,l,u,d,h]}var jm=class extends ne{constructor(e){super(),re(this,e,m7,p7,ie,{},h7)}},O_=jm;var If=require("obsidian");function g7(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 v_(i,e,t){let n=i.slice();return n[7]=e[t],n}function y_(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 b_(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=R(),a=b("div"),l=b("div"),u=R(),f=b("div"),h=R(),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 O7(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&&y_(i),g=fe(Object.keys(i[0])),O=_=>_[7];for(let _=0;_{new If.ExtraButtonComponent(u).setIcon("cross").setTooltip("Cancel")},a=(u,f)=>{new If.ExtraButtonComponent(u).setIcon("open-elsewhere-glyph").setTooltip("Load Encounter").onClick(()=>{he.new(s,n[f]),r("cancel")})},l=(u,f)=>{new If.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 Zm=class extends ne{constructor(e){super(),re(this,e,v7,O7,ie,{},g7)}},__=Zm;var Qa=require("obsidian");var lr=require("obsidian");function y7(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 w_(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 k_(i,e,t){let n=i.slice();return n[0]=e[t],n}function b7(i){let e,t,n;return{c(){e=b("div")},m(r,s){A(r,e,s),t||(n=Y(e,"load",i[36]),t=!0)},p:X,i:X,o:X,d(r){r&&T(e),t=!1,n()}}}function _7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P,k,w=[k7,w7],x=[];function C(D,E){return D[4]=="hp"?0:1}t=C(i,[-1,-1]),n=x[t]=w[t](i);let M=i[4]=="hp"&&P_(i),Z=fe([...i[6].entries()]),Q=[];for(let D=0;D{x[j]=null}),Te(),n=x[t],n?n.p(D,E):(n=x[t]=w[t](D),n.c()),$(n,1),n.m(e,null)),D[4]=="hp"?M||(M=P_(D),M.c(),M.m(a,null)):M&&(M.d(1),M=null),E[0]&120){Z=fe([...D[6].entries()]);let z;for(z=0;z{E=null}),Te())},i(j){C||($(E),C=!0)},o(j){V(E),C=!1},d(j){j&&T(e),Q&&Q.d(),D&&D.d(),E&&E.d(),M=!1,de(Z)}}}function S7(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 x7(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 P7(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 S_(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=R(),s=b("div");for(let d=0;d{o[u]=null}),Te(),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 E7=function(i){if(i.key==="Escape"){this.value="1";return}if(i.key==="Enter"){i.preventDefault();return}};function T7(i,e,t){let n,r,s,{updating:o,updateTarget:a}=he;ke(i,o,oe=>t(6,s=oe)),ke(i,a,oe=>t(4,n=oe));let l=Ye("plugin"),c=oe=>{(0,lr.setIcon)(oe,an)},u=oe=>{(0,lr.setIcon)(oe,tr)},f=oe=>{(0,lr.setIcon)(oe,Zp)},d,h=oe=>{t(22,d=new lr.ExtraButtonComponent(oe).setIcon("plus-circle"))},p=oe=>{(0,lr.setIcon)(oe,qu)},m=oe=>{(0,lr.setIcon)(oe,"check")},g=oe=>{(0,lr.setIcon)(oe,"cross-in-box")},O="",_="",S=null,P=$e([]);ke(i,P,oe=>t(5,r=oe));let k=()=>{S&&(Ke(P,r=[...r,{...l.data.statuses.find(oe=>oe.name==S)??{name:S,id:xt(),description:""}}],r),t(0,S=null),t(3,w.items=l.data.statuses.filter(oe=>!r.find(we=>we.id==oe.id)).map(oe=>oe.name),w),x.setValue(""))},w,x,C=oe=>{x=new lr.TextComponent(oe),x.onChange(we=>t(0,S=we)),oe.onkeydown=we=>{we.key==="Enter"&&(S?k():Q(!0))},M()},M=()=>{t(3,w=new Uu(l.app,x,l.data.statuses.filter(oe=>!r.find(we=>we.id==oe.id)).map(oe=>oe.name))),w.onSelect(async({item:oe})=>{t(0,S=oe),x.setValue(oe),w.close(),k()})};function Z(oe,we){n==we&&oe.focus()}let Q=oe=>{oe?he.doUpdate(O??"",r,_):he.clearUpdate(),t(1,O=null),t(0,S=null),t(2,_=null),Ke(P,r=[],r),t(3,w=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(P,r=[],r)},z=function(oe,we){r.remove(oe),P.set(r)};function q(){_=this.value,t(2,_)}let G=function(){t(3,w=null)},U=function(oe){if(oe.key=="Tab")return!0;if(oe.key=="Enter"||oe.key=="Escape"){Q(oe.key=="Enter");return}},le=function(oe,we,yt,It){Ke(o,we[yt][1].saved=!oe.saved,s)},xe=function(oe,we,yt,It){Ke(o,we[yt][1].resist=!oe.resist,s)};function ue(oe,we){oe[we][1].customMod=pi(this.value)}let B=function(oe,we){he.setUpdate(oe,we),s.size||(Ke(P,r=[],r),t(3,w=null))},J=()=>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,P,k,C,Z,Q,d,D,E,j,z,q,G,U,le,xe,ue,B,J,pe,Re]}var zm=class extends ne{constructor(e){super(),re(this,e,T7,C7,ie,{},y7,[-1,-1])}},T_=zm;var Aa=require("obsidian");var ec=class{constructor(e){this.plugin=e;te(this,"logFile");te(this,"file");te(this,"logging",!1)}async setLogFile(e){this.logFile=e,this.logging=!0,await this.setFile()}getLogFile(){return this.logFile?(0,Aa.normalizePath)(this.logFile):""}async setFile(){let e=await this.adapter.exists((0,Aa.normalizePath)(this.logFile))?await this.vault.getAbstractFileByPath((0,Aa.normalizePath)(this.logFile)):await this.vault.create(this.logFile,"");e instanceof Aa.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 Da=require("obsidian");var hn=require("obsidian");var wi=require("obsidian");function A7(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 A_(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S;return{c(){e=b("div"),t=b("label"),t.textContent="Static Initiative",n=R(),r=b("div"),o=R(),a=b("div"),l=b("label"),l.textContent="Hidden",c=R(),u=b("div"),d=R(),h=b("div"),p=b("label"),p.textContent="Friendly",m=R(),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(P,k){A(P,e,k),y(e,t),y(e,n),y(e,r),A(P,o,k),A(P,a,k),y(a,l),y(a,c),y(a,u),A(P,d,k),A(P,h,k),y(h,p),y(h,m),y(h,g),_||(S=[H(s=i[14].call(null,r)),H(f=i[13].call(null,u)),H(O=i[15].call(null,g))],_=!0)},p:X,d(P){P&&(T(e),T(o),T(a),T(d),T(h)),_=!1,de(S)}}}function D_(i){let e,t,n,r,s,o;function a(u,f){return u[7]?Q7:D7}let l=a(i,-1),c=l(i);return{c(){e=b("div"),t=b("div"),r=R(),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 D7(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 Q7(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 R7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P,k,w,x,C,M,Z,Q,D,E,j,z,q,G,U,le,xe,ue,B,J,pe,Re,oe=i[4],we,yt,It,ot,Nt,Sr,nn,$t,Tt=A_(i),at=!i[3]&&!wi.Platform.isMobile&&D_(i);return{c(){e=b("div"),t=b("div"),n=b("div"),r=b("label"),r.textContent="Creature",s=R(),o=b("div"),l=R(),c=b("div"),u=b("label"),u.textContent="Display Name",f=R(),d=b("input"),h=R(),p=b("div"),m=b("label"),m.textContent="HP",g=R(),O=b("input"),_=R(),S=b("div"),P=b("label"),P.textContent="Hit Dice",k=R(),w=b("input"),x=R(),C=b("div"),M=b("label"),M.textContent="AC",Z=R(),Q=b("input"),D=R(),E=b("div"),j=b("label"),j.textContent="Modifier",z=R(),q=b("input"),G=R(),U=b("div"),le=b("label"),le.textContent="Initiative",xe=R(),ue=b("input"),B=R(),J=b("div"),Re=R(),Tt.c(),we=R(),yt=b("div"),It=b("label"),It.textContent="Amount",ot=R(),Nt=b("input"),Sr=R(),at&&at.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(P,"for","hit-dice"),v(w,"id","hit-dice"),v(w,"type","text"),v(w,"name","hitdice"),v(w,"tabindex","0"),v(S,"class","svelte-1rjv45j"),v(M,"for","add-ac"),v(Q,"id","add-ac"),v(Q,"name","ac"),v(Q,"type","text"),v(Q,"tabindex","0"),v(C,"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(le,"for","add-init"),v(ue,"id","add-init"),v(ue,"type","number"),v(ue,"name","initiative"),v(ue,"tabindex","0"),v(J,"class","dice svelte-1rjv45j"),v(U,"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,_),y(t,S),y(S,P),y(S,k),y(S,w),Xe(w,i[4].hit_dice),y(t,x),y(t,C),y(C,M),y(C,Z),y(C,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,U),y(U,le),y(U,xe),y(U,ue),Xe(ue,i[4].initiative),y(U,B),y(U,J),y(t,Re),Tt.m(t,null),y(t,we),y(t,yt),y(yt,It),y(yt,ot),y(yt,Nt),Xe(Nt,i[0]),y(e,Sr),at&&at.m(e,null),nn||($t=[H(a=i[12].call(null,o)),Y(d,"input",i[18]),Y(O,"input",i[20]),Y(w,"input",i[21]),Y(Q,"input",i[22]),Y(Q,"change",i[23]),Y(q,"input",i[24]),Y(ue,"input",i[25]),H(pe=i[11].call(null,J)),Y(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&&w.value!==dt[4].hit_dice&&Xe(w,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=A_(dt),Tt.c(),Tt.m(t,we)):Tt.p(dt,gt),gt&1&&pi(Nt.value)!==dt[0]&&Xe(Nt,dt[0]),!dt[3]&&!wi.Platform.isMobile?at?at.p(dt,gt):(at=D_(dt),at.c(),at.m(e,null)):at&&(at.d(1),at=null)},i:X,o:X,d(dt){dt&&T(e),i[19](null),Tt.d(dt),at&&at.d(),nn=!1,de($t)}}}function M7(i,e,t){let n,r=X,s=()=>(r(),r=Ii(h,B=>t(7,n=B)),h),o,a=X,l=()=>(a(),a=Ii(d,B=>t(17,o=B)),d);i.$$.on_destroy.push(()=>r()),i.$$.on_destroy.push(()=>a());let c=new Ne({}),{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 wi.ExtraButtonComponent(B).setTooltip("Add Creature").setIcon("plus").onClick(async()=>{if(!c||!c.name||!c.name?.length){new wi.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 J=o.findIndex(([pe])=>Rs(pe,c));J>-1?Ke(d,o[J][1]+=u,o):o.push([c,u]),d.set(o),Ke(h,n=null,n),t(4,c=new Ne({}))})},_=B=>{new wi.ExtraButtonComponent(B).setTooltip("Add Creature").setIcon("save").onClick(async()=>{if(!c||!c.name||!c.name?.length){new wi.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 J=o.findIndex(([pe])=>pe!=c&&Rs(pe,c));if(J>-1&&await R_(app,`This will merge ${c.name} with ${o[J][0].name}.`)){let pe=o.findIndex(([Re])=>Re==c);Ke(d,o[J][1]+=o[pe][1],o),o.splice(pe,1)}d.set(o),Ke(h,n=null,n),t(4,c=new Ne({}))})},S=B=>{new wi.ExtraButtonComponent(B).setTooltip("Cancel").setIcon("reset").onClick(()=>{t(4,c=new Ne({}))})},P=B=>{new wi.ExtraButtonComponent(B).setIcon(Ts).setTooltip("Roll Initiative").onClick(async()=>{t(4,c.initiative=await f.getInitiativeValue(c.modifier),c)})},k,w,x=B=>{k=new wi.TextComponent(B).setValue(c.name).onChange(J=>t(4,c.name=J,c))},C,M=()=>{C=new Dl(f.app,k,f.bestiary),C.onSelect(async B=>{B.item&&(t(4,c=Ne.from(B.item)),t(4,c.initiative=await f.getInitiativeValue(c.modifier),c),k.setValue(c.name)),C.close()})};sf(()=>{p?setImmediate(()=>{w.focus(),M()}):M()});let Z=B=>{new wi.ToggleComponent(B).setValue(c.hidden).onChange(J=>t(4,c.hidden=J,c))},Q=B=>{new wi.ToggleComponent(B).setValue(c.static).onChange(J=>t(4,c.static=J,c))},D=B=>{new wi.ToggleComponent(B).setValue(c.friendly).onChange(J=>t(4,c.friendly=J,c))};function E(){c.display=this.value,t(4,c)}function j(B){mi[B?"unshift":"push"](()=>{w=B,t(6,w)})}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 U=()=>t(4,c.dirty_ac=!0,c);function le(){m=this.value,t(5,m)}function xe(){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&&wi.Platform.isMobile&&o.splice(0,1,[c,u])},[u,d,h,p,c,m,w,n,O,_,S,P,x,Z,Q,D,f,o,E,j,z,q,G,U,le,xe,ue]}var qm=class extends ne{constructor(e){super(),re(this,e,M7,R7,ie,{amount:0,plugin:16,adding:1,editing:2,isEditing:3},A7)}},Q_=qm;var cr=require("obsidian");function I7(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 M_(i,e,t){let n=i.slice();return n[21]=e[t][0],n[22]=e[t][1],n[24]=t,n}function N7(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 j7(i){let e,t=fe(i[3]),n=[];for(let r=0;r(r(),r=Ii(c,D=>t(3,n=D)),c),o,a=X,l=()=>(a(),a=Ii(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 cr.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 cr.ExtraButtonComponent(D).setIcon("plus")},m=(D,E)=>{Ke(c,n[E][1]+=1,n),c.set(n)},g=(D,E)=>{new cr.ExtraButtonComponent(D).setIcon("trash")},O=(D,E)=>{n.splice(E,1),c.set(n)},_=D=>{(0,cr.setIcon)(D,an)},S=D=>{(0,cr.setIcon)(D,as)},P=D=>{(0,cr.setIcon)(D,tr)},k=D=>{(0,cr.setIcon)(D,wo)},w=D=>{(0,cr.setIcon)(D,Jn)},x=D=>{(0,cr.setIcon)(D,er)},C=(D,E)=>h(E,D),M=(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,_,S,P,k,w,x,C,M,Z,Q]}var Lm=class extends ne{constructor(e){super(),re(this,e,L7,q7,ie,{adding:0,editing:1,rollHP:2},I7)}},Z_=Lm;function $7(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 z_(i){let e,t,n,r,s,o,a,l,c,u;return t=new Z_({props:{adding:i[4],editing:i[5],rollHP:i[2]}}),{c(){e=b("div"),ye(t.$$.fragment),n=R(),r=b("div"),s=b("input"),o=R(),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=Y(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 F7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p;n=new Q_({props:{plugin:i[0],editing:i[5],adding:i[4],isEditing:i[1]}});let m=!i[1]&&!hn.Platform.isMobile&&z_(i);return{c(){e=b("div"),t=b("div"),ye(n.$$.fragment),r=R(),m&&m.c(),s=R(),o=b("div"),a=b("div"),c=R(),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 _={};O&1&&(_.plugin=g[0]),O&2&&(_.isEditing=g[1]),n.$set(_),!g[1]&&!hn.Platform.isMobile?m?(m.p(g,O),O&2&&$(m,1)):(m=z_(g),m.c(),$(m,1),m.m(t,null)):m&&(Ee(),V(m,1,1,()=>{m=null}),Te()),(!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 B7(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([]);ke(i,u,m=>t(3,n=m));let f=$e(l);ke(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,_])=>[...Array(_).keys()].map(S=>Ne.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 $m=class extends ne{constructor(e){super(),re(this,e,B7,F7,ie,{plugin:0,isEditing:1,creature:8},$7)}},q_=$m;var Nf=class extends Da.Modal{constructor(t,n){super(t.app);this.plugin=t;this.creature=n}onOpen(){this.containerEl.addClass("initiative-tracker-modal"),new q_({target:this.contentEl,props:{plugin:this.plugin,...this.creature?{creature:this.creature,isEditing:!0}:{}}}).$on("close",()=>this.close())}};async function R_(i,e,t={cta:"Yes",secondary:"No"}){return new Promise((n,r)=>{try{let s=new Fm(i,e,t);s.onClose=()=>{n(s.confirmed)},s.open()}catch{r()}})}var Fm=class extends Da.Modal{constructor(t,n,r){super(t);this.text=n;this.buttons=r;te(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 Da.ButtonComponent(t).setButtonText(this.buttons.cta).setCta().onClick(()=>{this.confirmed=!0,this.close()}),new Da.ButtonComponent(t).setButtonText(this.buttons.secondary).onClick(()=>{this.close()})}onOpen(){this.display()}};var Bm=require("obsidian");function V7(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 W7(i){let e,t,n,r,s,o,a,l,c;return{c(){e=b("div"),t=b("div"),n=b("div"),s=R(),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)),Y(o,"click",i[18])],l=!0)},p:X,i:X,o:X,d(u){u&&T(e),l=!1,de(c)}}}function X7(i){let e,t;return e=new __({}),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 Y7(i){let e,t;return e=new O_({}),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 U7(i){let e,t,n,r,s,o,a,l,c,u,f,d;t=new gb({}),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 m_({}),o=new o_({}),o.$on("edit",i[14]),o.$on("open-combatant",i[15]),l=new T_({});let h=[Y7,X7,W7],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=R(),ye(r.$$.fragment),s=R(),ye(o.$$.fragment),a=R(),ye(l.$$.fragment),c=R(),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 _=u;u=m(g,O),u===_?p[u].p(g,O):(Ee(),V(p[_],1,1,()=>{p[_]=null}),Te(),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 H7(i,e,t){let n,r,s,{plugin:o}=e,{data:a}=he;ke(i,a,C=>t(8,s=C)),he.setData(o.data),he.setLogger(new ec(o)),o.data.state?he.new(o,o.data.state):(he.setParty(o.data.defaultParty,o),he.roll(o));let{ordered:l}=he;ke(i,l,C=>t(20,r=C)),Vi("plugin",o);let c=!1,u=!1,f=C=>{let M=new Nf(o,C);M.onClose=()=>{},M.open()},d=C=>{new Qa.ExtraButtonComponent(C).setTooltip("Add Creature").setIcon(Rp)},h=C=>{new Qa.ExtraButtonComponent(C).setTooltip("Copy Initiative Order").setIcon(qp).onClick(async()=>{let M=r.map(Z=>`${Z.initiative} ${Z.name}`).join(`
`);try{await navigator.clipboard.writeText(M),new Qa.Notice("Initiative order copied to clipboard.")}catch{new Qa.Notice("Initiative order could not be copied to clipboard.")}})},p=()=>t(1,c=!0),m=()=>t(2,u=!0),g=()=>f();function O(C){ht.call(this,i,C)}function _(C){ht.call(this,i,C)}let S=C=>f(C.detail),P=C=>o.openCombatant(C.detail),k=()=>t(1,c=!1),w=()=>t(2,u=!1),x=()=>f();return i.$$set=C=>{"plugin"in C&&t(0,o=C.plugin)},i.$$.update=()=>{i.$$.dirty&256&&(n=s.displayDifficulty)},[o,c,u,a,l,f,d,h,s,p,m,g,O,_,S,P,k,w,x]}var Vm=class extends ne{constructor(e){super(),re(this,e,H7,U7,ie,{plugin:0},V7)}},L_=Vm;var Ra=class extends kn.ItemView{constructor(t,n){super(t);this.leaf=t;this.plugin=n;te(this,"ui");te(this,"playerViewOpened",!1);this.plugin.data.state?.creatures?.length}async onOpen(){this.ui=new L_({target:this.contentEl,props:{plugin:this.plugin}}),this.ui.$on("player-view",()=>this.openPlayerView())}getViewType(){return bo}getDisplayText(){return"Initiative Tracker"}getIcon(){return Qp}get pcs(){return[]}get npcs(){return[]}getExistingPlayerView(){let t=this.plugin.app.workspace.getLeavesOfType(_o);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:_o}),await this.app.workspace.setActiveLeaf(n,{focus:!0}),n.view}async openPlayerView(){await this.getPlayerView(),this.playerViewOpened=!0}},tc=class extends kn.ItemView{constructor(t,n){super(t);this.plugin=n;te(this,"buttonEl",this.contentEl.createDiv("creature-view-button"));te(this,"statblockEl",this.contentEl.createDiv("creature-statblock-container"));this.load(),this.containerEl.addClass("creature-view-container"),this.containerEl.on("mouseover","a.internal-link",(0,kn.debounce)(r=>app.workspace.trigger("link-hover",{},r.target,r.target.dataset.href,"initiative-tracker "),10)),this.containerEl.on("click","a.internal-link",r=>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.app.workspace.trigger("initiative-tracker:stop-viewing")}async render(t){if(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=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 Tp}getViewType(){return pa}};var aC=require("obsidian");var _U=$e(0);function G7(){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,...ct(s)],l))},empty:()=>t([]),toggleEnabled:a=>n(l=>{let c=l.find(u=>u==a);return c.enabled=!c.enabled,l})}}var ji=G7();var ic=require("obsidian");function K7(){let i=$e(new Map),{subscribe:e,set:t,update:n}=i;return{players:ji,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=K7();function J7(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 eA(i,e,t){let{str:n=We}=e;return i.$$set=r=>{"str"in r&&t(0,n=r.str)},[n]}var Wm=class extends ne{constructor(e){super(),re(this,e,eA,J7,ie,{str:0})}},jf=Wm;function tA(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 $_(i,e,t){let n=i.slice();return n[14]=e[t],n}function F_(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 B_(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 V_(i){let e,t=X_(i[0].source)+"",n,r;return{c(){e=b("span"),n=ae(t),v(e,"aria-label",r=Y_(i[0].source))},m(s,o){A(s,e,o),y(e,n)},p(s,o){o&1&&t!==(t=X_(s[0].source)+"")&&me(n,t),o&1&&r!==(r=Y_(s[0].source))&&v(e,"aria-label",r)},d(s){s&&T(e)}}}function W_(i){let e,t,n;return t=new jf({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 iA(i){let e,t,n,r,s,o,a,l=i[0].name+"",c,u,f,d,h,p,m,g,O,_=i[2]&&F_(i),S=i[1]&&B_(i),P=i[0].source?.length&&V_(i),k=fe(i[3]),w=[];for(let C=0;CV(w[C],1,1,()=>{w[C]=null});return{c(){e=b("tr"),t=b("td"),n=b("div"),r=b("div"),o=R(),a=b("div"),c=ae(l),u=R(),_&&_.c(),f=R(),S&&S.c(),d=R(),h=b("div"),P&&P.c(),p=R();for(let C=0;CZf(s,e++)).join(t)}${n?")":""}`);else if(typeof i=="object")for(let s of Object.values(i))r.push(Zf(s,e++));return r.join(" ")}function X_(i){if(!Array.isArray(i))return i;let e=i.slice(0,2);return i.length>2&&e.push(`and ${i.length-2} more`),Zf(e,0,", ",!1)}function Y_(i){return Array.isArray(i)?Zf(i,0,", ",!1):""}function nA(i,e,t){let n,r,s,o,{players:a}=ii,{average:l}=a;ke(i,l,O=>t(10,s=O));let c=Ye("plugin"),u=Ye("table");ke(i,u,O=>t(3,o=O));let{creature:f}=e,d=O=>{new ic.ExtraButtonComponent(O).setIcon("plus-with-circle")},h=O=>(0,ic.setIcon)(O,"baby"),p=O=>(0,ic.setIcon)(O,"skull"),m=()=>ii.add(f),g=O=>c.openCombatant(Ne.from(f));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 Xm=class extends ne{constructor(e){super(),re(this,e,nA,iA,ie,{creature:0},tA)}},U_=Xm;var Xf=require("obsidian");function zf(i,{delay:e=0,duration:t=400,easing:n=In}={}){let r=+getComputedStyle(i).opacity;return{delay:e,duration:t,easing:n,css:s=>`opacity: ${s*r}`}}function Ym(i,{delay:e=0,duration:t=400,easing:n=Ea,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 rA=Function.prototype.toString,Um=Object.create,sA=Object.prototype.toString,oA=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 aA(){return new oA}function lA(){return new WeakMap}var cA=typeof WeakMap<"u"?lA:aA;function Gm(i){if(!i)return Um(null);var e=i.constructor;if(e===Object)return i===Object.prototype?{}:Um(i);if(e&&~rA.call(e).indexOf("[native code]"))try{return new e}catch{}return Um(i)}function uA(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 fA(i){return i.flags}var dA=/test/g.flags==="g"?fA:uA;function H_(i){var e=sA.call(i);return e.substring(8,e.length-1)}function hA(i){return i[Symbol.toStringTag]||H_(i)}var pA=typeof Symbol<"u"?hA:H_,mA=Object.defineProperty,gA=Object.getOwnPropertyDescriptor,G_=Object.getOwnPropertyNames,Km=Object.getOwnPropertySymbols,K_=Object.prototype,J_=K_.hasOwnProperty,OA=K_.propertyIsEnumerable,ew=typeof Km=="function";function vA(i){return G_(i).concat(Km(i))}var yA=ew?vA:G_;function Lf(i,e,t){for(var n=yA(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:()=>ct(s),update:t,set:n,subscribe:r,reset:()=>n([...i.options]),compare:o=>{if(ct(s))return!0;let a=ct(e);return hi(o)>=a[0]&&hi(o)<=a[1]},filter:i,...i}};function $f(i){return typeof i!="string"?i:i.toLowerCase()}var ZA=i=>{let e=$e([]),{subscribe:t,set:n,update:r}=e,s=oi(e,o=>!o.length);return{isDefault:s,getIsDefault:()=>ct(s),subscribe:t,set:n,reset:()=>n([]),compare:o=>{if(ct(s))return!0;if(typeof o=="number")return!1;let a=ct(e);return Array.isArray(o)?o.some(l=>a.includes($f(l))):a.includes($f(o))},update:r,filter:i,...i}},zA=i=>{let e="",t=$e(e),{subscribe:n,set:r,update:s}=t,o=oi(t,l=>!l.length),a=(0,tg.prepareSimpleSearch)("");return t.subscribe(l=>a=(0,tg.prepareSimpleSearch)(l)),{isDefault:o,getIsDefault:()=>ct(o),subscribe:n,set:r,reset:()=>r(e),compare:l=>ct(o)?!0:typeof l=="number"?!1:ct(o)||a(l)!=null,update:s,filter:i,...i}};function ow(i){switch(i.type){case 2:return ZA(i);case 0:return jA(i);case 1:return zA(i)}}function aw(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($f(o));else typeof n[s]=="string"&&t.get(r).add($f(n[s]));break}case 1:continue}continue}return t}function cw(i,e){let t=k=>{let w=ow(k);return n.set(k.id,w),o.set(k.id,w.subscribe(x=>{r.update(C=>C)})),w},n=new Map,r=$e(n),s=new Map;r.subscribe(k=>{for(let[w,x]of k)s.set(w,x.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??lw),l=()=>ci(e.data.builder?.filters?.filters??eg);e.data.builder.filters||(e.data.builder.filters={filters:l(),layout:a()});let c=e.data.builder?.filters?.filters??eg,u=e.data.builder?.filters?.layout??a();if(c.filter(k=>k.derive).length){let k=aw(ct(i),c);for(let[w,x]of k)w.options=Array.from(x)}for(let k of c)t(k);let d=oi([i,r],([k,w])=>{let x=[],C=Array.from(w.values());for(let M of k)C.every(Z=>{if(!Z.filter.fields.length)return!0;for(let Q of Z.filter.fields)if(Q in M)return Z.compare(M[Q]);return!0})&&x.push(M);return x}),h=$e(u??a()),p=k=>{h.set(k),e.data.builder.filters.layout=k,e.saveSettings()},m=k=>{p(k?lw:a()),g(w=>{w.clear();let x=k?eg:l();for(let C of x)t(C);return w})};function g(k){r.update(w=>{let x=k(w);return e.data.builder.filters.filters=[...x.values()].map(C=>C.filter),e.saveSettings(),x})}let O=oi(r,k=>{let w=0;for(let x of k.values())x.getIsDefault()||w++;return w}),_=t(qA),S=(k,w)=>{if(k.derive){let C=aw(ct(i),[k]);for(let[M,Z]of C)M.options=Array.from(Z)}let x=ow(k);return w.set(k.id,x),o.set(k.id,x.subscribe(C=>r.update(M=>M))),w},P=(k,w)=>(w.delete(k),o.has(k)&&(o.get(k)(),o.delete(k)),w);return{add:k=>g(w=>S(k,w)),update:(k,w)=>g(x=>(P(k,x),S(w,x))),remove:k=>g(w=>P(k.id,w)),reset:()=>g(k=>{for(let w of k.values())w.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(ig)},name:_}}var UU=$e(),qA={type:1,text:"Name",fields:["name"],options:"",id:"ID_DEFAULT_NAME_FILTER",derive:!1},eg=[{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}],lw=[{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 LA(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 $A(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=FA.call(null,e)),Y(e,"dragstart",i[6]),Y(e,"drag",i[7]),Y(e,"dragend",i[8]),Y(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 FA(i){let e=BA(i);return i.addEventListener("touchstart",e),i.addEventListener("mousedown",e),{destroy(){i.removeEventListener("touchstart",e),i.removeEventListener("mousedown",e)}}}function BA(i){let e=VA(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 VA(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 WA(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 ng=class extends ne{constructor(e){super(),re(this,e,WA,$A,ie,{pos:0},LA)}},rg=ng;function XA(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 uw(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 YA(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 fw(i){let e,t,n;function r(o){i[13](o)}let s={$$slots:{default:[UA]},$$scope:{ctx:i}};return i[3][1]!==void 0&&(s.pos=i[3][1]),e=new rg({props:s}),mi.push(()=>Mr(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],Qr(()=>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 UA(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 HA(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=i[2]&&uw(i);function O(P){i[11](P)}let _={$$slots:{default:[YA]},$$scope:{ctx:i}};i[3][0]!==void 0&&(_.pos=i[3][0]),u=new rg({props:_}),mi.push(()=>Mr(u,"pos",O)),u.$on("active",i[12]);let S=i[2]&&fw(i);return{c(){e=b("div"),t=b("input"),s=R(),g&&g.c(),o=R(),a=b("div"),l=b("div"),c=R(),ye(u.$$.fragment),d=R(),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(P,k){A(P,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=Y(e,"click",i[6]),p=!0)},p(P,[k]){(!h||k&1&&n!==(n=P[0][0])&&t.value!==n)&&(t.value=n),(!h||k&2&&r!==(r=P[1][0]))&&v(t,"name",r),P[2]?g?g.p(P,k):(g=uw(P),g.c(),g.m(e,o)):g&&(g.d(1),g=null),(!h||k&32)&&v(l,"style",P[5]);let w={};k&524288&&(w.$$scope={dirty:k,ctx:P}),!f&&k&8&&(f=!0,w.pos=P[3][0],Qr(()=>f=!1)),u.$set(w),P[2]?S?(S.p(P,k),k&4&&$(S,1)):(S=fw(P),S.c(),$(S,1),S.m(a,null)):S&&(Ee(),V(S,1,1,()=>{S=null}),Te())},i(P){h||($(u.$$.fragment,P),$(S),h=!0)},o(P){V(u.$$.fragment,P),V(S),h=!1},d(P){P&&T(e),g&&g.d(),ve(u),S&&S.d(),p=!1,m()}}}function GA(i){return[Math.min(...i),Math.max(...i)]}function KA(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(w){let x=a%c,C=l-a;t(0,u=w.map(M=>a+M*C).map(M=>Math.round((M-x)/c)*c+x)),r("input",u)}function m(w){t(3,f=w.map(x=>Math.min(Math.max(x,a),l)).map(x=>(x-a)/(l-a)))}function g(){m(u),p(f)}function O(w){let x=w.target,C=w.offsetX/x.clientWidth,M=f.map(Z=>Math.abs(C-Z));M[1]>M[0]?t(3,f=[C,f[1]]):t(3,f=[f[0],C]),p(f)}function _(w){i.$$.not_equal(f[0],w)&&(f[0]=w,t(3,f),t(2,o),t(10,h),t(4,d))}let S=({detail:w})=>t(4,d=w);function P(w){i.$$.not_equal(f[1],w)&&(f[1]=w,t(3,f),t(2,o),t(10,h),t(4,d))}let k=({detail:w})=>t(4,d=w);return i.$$set=w=>{"name"in w&&t(1,s=w.name),"range"in w&&t(2,o=w.range),"min"in w&&t(7,a=w.min),"max"in w&&t(8,l=w.max),"step"in w&&t(9,c=w.step),"value"in w&&t(0,u=w.value),"order"in w&&t(10,h=w.order)},i.$$.update=()=>{i.$$.dirty&1052&&o&&h&&d&&t(3,f=GA(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,_,S,P,k]}var sg=class extends ne{constructor(e){super(),re(this,e,KA,HA,ie,{name:1,range:2,min:7,max:8,step:9,value:0,order:10},XA)}},dw=sg;function JA(i){se(i,"svelte-191t5bs",".range-filter.svelte-191t5bs{display:flex;align-items:center;gap:1rem;width:100%;white-space:nowrap}")}function eD(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P;function k(x){i[5](x)}let w={range:!0,order:!0,min:i[0].options[0],max:i[0].options[1]};return i[3]!==void 0&&(w.value=i[3]),c=new dw({props:w}),mi.push(()=>Mr(c,"value",k)),{c(){e=b("div"),t=b("span"),n=ae(i[2]),r=R(),s=b("input"),l=R(),ye(c.$$.fragment),f=R(),d=b("input"),m=R(),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(x,C){A(x,e,C),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),_=!0,S||(P=[Y(s,"input",i[4]),Y(d,"input",i[6])],S=!0)},p(x,[C]){(!_||C&4)&&me(n,x[2]),(!_||C&4)&&v(s,"placeholder",x[2]),(!_||C&1&&o!==(o=x[0].options[0]))&&v(s,"min",o),(!_||C&1&&a!==(a=x[0].options[1]))&&v(s,"max",a),C&8&&pi(s.value)!==x[3][0]&&Xe(s,x[3][0]);let M={};C&1&&(M.min=x[0].options[0]),C&1&&(M.max=x[0].options[1]),!u&&C&8&&(u=!0,M.value=x[3],Qr(()=>u=!1)),c.$set(M),(!_||C&2)&&v(d,"placeholder",x[1]),(!_||C&1&&h!==(h=x[0].options[0]))&&v(d,"min",h),(!_||C&1&&p!==(p=x[0].options[1]))&&v(d,"max",p),C&8&&pi(d.value)!==x[3][1]&&Xe(d,x[3][1]),(!_||C&2)&&me(O,x[1])},i(x){_||($(c.$$.fragment,x),_=!0)},o(x){V(c.$$.fragment,x),_=!1},d(x){x&&T(e),ve(c),S=!1,de(P)}}}function tD(i,e,t){let n,r,s,o=X,a=()=>(o(),o=Ii(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 og=class extends ne{constructor(e){super(),re(this,e,tD,eD,ie,{filter:0},JA)}},hw=og;function iD(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 nD(i){let e,t=`${i[0]} transparent ${i[0]}
${i[0]}`;return{c(){e=b("div"),Ce(e,"--duration",i[1]),v(e,"class","svelte-66wdl1"),Ce(e,"border-color",t),Ce(e,"width",i[2]),Ce(e,"height",i[2])},m(n,r){A(n,e,r)},p(n,[r]){r&2&&Ce(e,"--duration",n[1]);let s=r&2;(r&3&&t!==(t=`${n[0]} transparent ${n[0]}
${n[0]}`)||s)&&Ce(e,"border-color",t),(r&6||s)&&Ce(e,"width",n[2]),(r&6||s)&&Ce(e,"height",n[2])},i:X,o:X,d(n){n&&T(e)}}}function rD(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 ag=class extends ne{constructor(e){super(),re(this,e,rD,nD,ie,{color:0,duration:1,size:2},iD)}},lg=ag;function sD(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(),Ce(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)`)&&Ce(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 oD(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=a_(p,{stiffness:d,damping:h});return ke(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 cg=class extends ne{constructor(e){super(),re(this,e,oD,sD,ie,{wiggle:2,angle:3,scale:4,dx:5,dy:6,duration:7,stiffness:8,damping:9})}},ug=cg;function aD(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),ir(n)))},e=ir(e),[e]}var fg=class extends ne{constructor(e){super(),re(this,e,lD,aD,ie,{})}},dg=fg;function cD(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),ir(n)))},e=ir(e),[e]}var hg=class extends ne{constructor(e){super(),re(this,e,uD,cD,ie,{})}},Ff=hg;function fD(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),ir(n)))},e=ir(e),[e]}var pg=class extends ne{constructor(e){super(),re(this,e,dD,fD,ie,{})}},mg=pg;var ki=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 nc(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:hD}=Rl;function pD(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 mD=i=>({searchText:i[0]&16,msgType:i[0]&68660|i[1]&16,msg:i[0]&101428|i[1]&16}),pw=i=>({searchText:i[4],msgType:i[124],msg:i[125]});function gg(i){let e=i.slice(),t={dupe:e[15],create:e[10],"no-match":e[35]}[e[124]];return e[125]=t,e}function Og(i){let e=i.slice(),t=e[5].map(ki).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 mw(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 gD=i=>({option:i[0]&1073741828}),gw=i=>({option:i[126],idx:i[133]}),OD=i=>({option:i[0]&1073741828}),Ow=i=>({option:i[126],idx:i[133]}),vD=i=>({}),vw=i=>({}),yD=i=>({}),yw=i=>({}),bD=i=>({}),bw=i=>({}),_D=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}),_w=i=>({selected:i[5],disabled:i[50],invalid:i[7],id:i[18],placeholder:i[39],open:i[8],required:i[43]});function ww(i,e,t){let n=i.slice();return n[126]=e[t],n[133]=t,n}var wD=i=>({}),kw=i=>({}),kD=i=>({option:i[0]&32,idx:i[0]&32}),Sw=i=>({option:i[126],idx:i[133]}),SD=i=>({option:i[0]&32,idx:i[0]&32}),xw=i=>({option:i[126],idx:i[133]}),xD=i=>({open:i[0]&256}),Pw=i=>({open:i[8]});function PD(i){let e,t;return e=new dg({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 CD(i){let e=ki(i[126])+"",t;return{c(){t=ae(e)},m(n,r){A(n,t,r)},p(n,r){r[0]&32&&e!==(e=ki(n[126])+"")&&me(t,e)},d(n){n&&T(t)}}}function ED(i){let e,t=ki(i[126])+"",n;return{c(){e=new Ml(!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=ki(r[126])+"")&&e.p(t)},d(r){r&&(T(n),e.d())}}}function TD(i){let e;function t(s,o){return s[37]?ED:CD}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 AD(i){let e,t=i[77].default,n=Gt(t,i,i[115],Sw),r=n||TD(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,kD):ei(s[115]),Sw):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 Cw(i){let e,t,n,r,s,o=i[77]["remove-icon"],a=Gt(o,i,i[115],kw),l=a||DD(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]+" "+ki(i[126])),v(e,"class","remove svelte-1r2hsto")},m(f,d){A(f,e,d),l&&l.m(e,null),n=!0,r||(s=[Y(e,"mouseup",Vt(c)),Y(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,wD):ei(i[115]),kw),(!n||d[0]&32|d[1]&1024&&t!==(t=i[41]+" "+ki(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 DD(i){let e,t;return e=new Ff({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 Ew(i,e){let t,n,r,s,o,a,l=X,c,u,f,d=e[77].selected,h=Gt(d,e,e[115],xw),p=h||AD(e),m=!e[50]&&(e[42]===null||e[5].length>e[42])&&Cw(e);function g(){return e[99](e[133])}return{key:i,first:null,c(){t=b("li"),p&&p.c(),n=R(),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=nc(e[126],"selected")+" "+e[27]),ge(t,"active",e[54]===e[133]),this.first=t},m(O,_){A(O,t,_),p&&p.m(t,null),y(t,n),m&&m.m(t,null),c=!0,u||(f=[Y(t,"dragstart",function(){Ge(e[65](e[133]))&&e[65](e[133]).apply(this,arguments)}),Y(t,"drop",Xp(function(){Ge(e[64](e[133]))&&e[64](e[133]).apply(this,arguments)})),Y(t,"dragenter",g),Y(t,"dragover",Xp(e[93]))],u=!0)},p(O,_){e=O,h?h.p&&(!c||_[0]&32|_[3]&4194304)&&Jt(h,d,e,e[115],c?Kt(d,e[115],_,SD):ei(e[115]),xw):p&&p.p&&(!c||_[0]&32|_[1]&64|_[3]&4194304)&&p.p(e,c?_:[-1,-1,-1,-1,-1]),!e[50]&&(e[42]===null||e[5].length>e[42])?m?(m.p(e,_),_[0]&32|_[1]&526336&&$(m,1)):(m=Cw(e),m.c(),$(m,1),m.m(t,null)):m&&(Ee(),V(m,1,1,()=>{m=null}),Te()),(!c||_[0]&67108864&&r!==(r=un(e[26])+" svelte-1r2hsto"))&&v(t,"class",r),(!c||_[0]&32|_[1]&532480&&s!==(s=e[44]&&!e[50]&&e[5].length>1))&&v(t,"draggable",s),(!c||_[0]&134217760&&o!==(o=nc(e[126],"selected")+" "+e[27]))&&v(t,"style",o),(!c||_[0]&67108896|_[1]&8388608)&&ge(t,"active",e[54]===e[133])},r(){a=t.getBoundingClientRect()},f(){Dr(t),l()},a(){l(),l=Ar(t,a,Nr,{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 Tw(i){let e,t=i[77].spinner,n=Gt(t,i,i[115],bw),r=n||QD(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,bD):ei(s[115]),bw)},i(s){e||($(r,s),e=!0)},o(s){V(r,s),e=!1},d(s){r&&r.d(s)}}}function QD(i){let e,t;return e=new lg({}),{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 RD(i){let e,t,n,r=i[31]&&(i[31]>1||i[32])&&Aw(i),s=i[31]!==1&&i[5].length>1&&Dw(i);return{c(){r&&r.c(),e=R(),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=Aw(o),r.c(),$(r,1),r.m(e.parentNode,e)):r&&(Ee(),V(r,1,1,()=>{r=null}),Te()),o[31]!==1&&o[5].length>1?s?(s.p(o,a),a[0]&32|a[1]&1&&$(s,1)):(s=Dw(o),s.c(),$(s,1),s.m(t.parentNode,t)):s&&(Ee(),V(s,1,1,()=>{s=null}),Te())},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 MD(i){let e,t=i[77]["disabled-icon"],n=Gt(t,i,i[115],yw),r=n||jD(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,yD):ei(s[115]),yw)},i(s){e||($(r,s),e=!0)},o(s){V(r,s),e=!1},d(s){r&&r.d(s)}}}function Aw(i){let e,t,n;function r(o){i[102](o)}let s={angle:20,$$slots:{default:[ID]},$$scope:{ctx:i}};return i[51]!==void 0&&(s.wiggle=i[51]),e=new ug({props:s}),mi.push(()=>Mr(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],Qr(()=>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 ID(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 Dw(i){let e,t,n,r,s=i[77]["remove-icon"],o=Gt(s,i,i[115],vw),a=o||ND(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=[Y(e,"mouseup",Vt(i[61])),Y(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,vD):ei(l[115]),vw),(!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 ND(i){let e,t;return e=new Ff({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 jD(i){let e,t;return e=new mg({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 Qw(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]&&Mw(Og(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}),Te()),(!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}),Te())},i(r){t||($(n),t=!0)},o(r){V(n),t=!1},d(r){r&&T(e),n&&n.d(r)}}}function Iw(i){let e,t,n,r,s,o=i[77]["user-msg"],a=Gt(o,i,i[115],pw),l=a||$D(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]),Ce(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=[Y(e,"mousedown",Vt(i[78])),Y(e,"mouseup",Vt(i[108])),Y(e,"mouseover",i[109]),Y(e,"focus",i[110]),Y(e,"mouseout",i[111]),Y(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,mD):ei(c[115]),pw):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&&Ce(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 $D(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 FD(i){let e,t,n,r,s,o,a=[],l=new Map,c,u,f,d,h,p,m,g,O,_,S,P,k,w,x,C,M;_n(i[94]);let Z=i[77]["expand-icon"],Q=Gt(Z,i,i[115],Pw),D=Q||PD(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}~(_=xe(i,[-1,-1,-1,-1,-1]))&&(S=le[_]=U[_](i));let ue=(i[4]&&i[35]||i[3]?.length>0)&&Qw(i);return{c(){e=b("div"),t=b("input"),r=R(),D&&D.c(),s=R(),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",w=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,J){A(B,e,J),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&&(!x||J[0]&256|J[3]&4194304)&&Jt(Q,Z,B,B[115],x?Kt(Z,B[115],J,xD):ei(B[115]),Pw),J[0]&201523232|J[1]&143141952|J[2]&13|J[3]&4194304){E=fe(B[5]),Ee();for(let Re=0;Re{G=null}),Te());let pe=_;_=xe(B,J),_===pe?~_&&le[_].p(B,J):(S&&(Ee(),V(le[pe],1,1,()=>{le[pe]=null}),Te()),~_?(S=le[_],S?S.p(B,J):(S=le[_]=U[_](B),S.c()),$(S,1),S.m(e,P)):S=null),B[4]&&B[35]||B[3]?.length>0?ue?(ue.p(B,J),J[0]&24|J[1]&16&&$(ue,1)):(ue=Qw(B),ue.c(),$(ue,1),ue.m(e,null)):ue&&(Ee(),V(ue,1,1,()=>{ue=null}),Te()),(!x||J[1]&32&&k!==(k="multiselect "+B[36]+" svelte-1r2hsto"))&&v(e,"class",k),(!x||J[0]&16384|J[1]&524288&&w!==(w=B[50]?B[14]:null))&&v(e,"title",w),(!x||J[0]&262144)&&v(e,"data-id",B[18]),(!x||J[1]&16384)&&v(e,"style",B[45]),(!x||J[1]&524320)&&ge(e,"disabled",B[50]),(!x||J[1]&33)&&ge(e,"single",B[31]===1),(!x||J[0]&256|J[1]&32)&&ge(e,"open",B[8]),(!x||J[0]&128|J[1]&32)&&ge(e,"invalid",B[7])},i(B){if(!x){$(D,B);for(let J=0;J`${ki(I)}`.toLowerCase()}=e,{filterFunc:P=(I,nt)=>nt?`${ki(I)}`.toLowerCase().includes(nt.toLowerCase()):!0}=e,{closeDropdownOnSelect:k="desktop"}=e,{form_input:w=null}=e,{highlightMatches:x=!0}=e,{id:C=null}=e,{input:M=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:U=""}=e,{liSelectedStyle:le=null}=e,{liUserMsgClass:xe=""}=e,{loading:ue=!1}=e,{matchingOptions:B=[]}=e,{maxOptions:J=void 0}=e,{maxSelect:pe=null}=e,{maxSelectMsg:Re=(I,nt)=>nt>1?`${I}/${nt}`:""}=e,{maxSelectMsgClass:oe=""}=e,{name:we=null}=e,{noMatchingOptionsMsg:yt="No matching options"}=e,{open:It=!1}=e,{options:ot}=e,{outerDiv:Nt=null}=e,{outerDivClass:Sr=""}=e,{parseLabelsAsHtml:nn=!1}=e,{pattern:$t=null}=e,{placeholder:Tt=null}=e,{removeAllTitle:at="Remove all"}=e,{removeBtnTitle:dt="Remove"}=e,{minSelect:gt=null}=e,{required:jt=!1}=e,{resetFilterOnAdd:xr=!0}=e,{searchText:bt=""}=e,{selected:et=ot?.filter(I=>I instanceof Object&&I?.preselected).slice(0,pe??void 0)??[]}=e,{sortSelected:is=!1}=e,{selectedOptionsDraggable:yl=!is}=e,{style:Du=null}=e,{ulOptionsClass:Qu=""}=e,{ulSelectedClass:Dn=""}=e,{ulSelectedStyle:ks=null}=e,{ulOptionsStyle:bl=null}=e,{value:po=null}=e,mo=I=>{t(67,po=pe===1?I[0]??null:I)},Ru=I=>{pe===1?t(5,et=I?[I]:[]):t(5,et=I??[])},sa=!1;ot?.length>0||(c||ue||m||u?ot=[]: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!"),is&&yl&&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.`),J&&(typeof J!="number"||J<0||J%1!=0)&&console.error(`MultiSelect's maxOptions must be undefined or a positive integer, got ${J}`);let Yn=Fe(),Pr=!1,rn;if(o!==null&&!B[o])throw`Run time error, activeIndex=${o} is out of bounds, matchingOptions.length=${B.length}`;function go(I,nt){pe&&pe>1&&et.length>=pe&&t(51,sa=!0),!isNaN(Number(I))&&typeof et.map(ki)[0]=="number"&&(I=Number(I));let Bt=et.map(S).includes(S(I));if((pe===null||pe===1||et.length0&&(typeof ot[0]=="object"?I={label:bt}:(["number","undefined"].includes(typeof ot[0])&&!isNaN(Number(bt))?I=Number(bt):I=bt,Yn("create",{option:I})),c==="append"&&t(3,ot=[...ot,I])),xr&&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]),is===!0?t(5,et=et.sort((ss,Cr)=>{let[Gn,ca]=[ki(ss),ki(Cr)];return`${Gn}`.localeCompare(`${ca}`)})):typeof is=="function"&&t(5,et=et.sort(is)));let yi=et.length===pe,Rn=k===!0||k==="desktop"&&rnS(yi)===S(I)),[Bt]=et.splice(nt,1);if(Bt===void 0&&c&&(Bt=typeof ot[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),w?.setCustomValidity(""),Yn("remove",{option:Bt}),Yn("change",{option:Bt,type:"remove"})}function Mu(I){m||(t(8,It=!0),I instanceof FocusEvent||M?.focus(),Yn("open",{event:I}))}function _l(I){t(8,It=!1),M?.blur(),t(0,o=null),Yn("close",{event:I})}async function vp(I){if(I.key==="Escape"||I.key==="Tab")_l(I),t(4,bt="");else if(I.key==="Enter")I.preventDefault(),a?(et.includes(a)?Oo(a):go(a,I),t(4,bt="")):c&&bt.length>0?go(bt,I):Mu(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,Pr=!Pr);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 af();let Bt=document.querySelector("ul.options > li.active");Bt&&Bt.scrollIntoViewIfNeeded?.()}}else I.key==="Backspace"&&et.length>0&&!bt?Oo(et.at(-1)):B.length>0&&t(0,o=0)}function yp(){Yn("removeAll",{options:et}),Yn("change",{options:et,type:"removeAll"}),t(5,et=[]),t(4,bt="")}let Ss=I=>nt=>{["Enter","Space"].includes(nt.code)&&(nt.preventDefault(),I())};function bp(I){Nt&&!Nt.contains(I.target)&&_l(I)}let oa=null,_p=I=>nt=>{if(!nt.dataTransfer)return;nt.dataTransfer.dropEffect="move";let Bt=parseInt(nt.dataTransfer.getData("text/plain")),yi=[...et];Btnt=>{nt.dataTransfer&&(nt.dataTransfer.effectAllowed="move",nt.dataTransfer.dropEffect="move",nt.dataTransfer.setData("text/plain",`${I}`))},vo;function wp(I){if(!x||typeof CSS>"u"||!CSS.highlights)return;CSS.highlights.clear();let nt=I?.target?.value.trim().toLowerCase();if(!nt)return;let Bt=document.createTreeWalker(vo,NodeFilter.SHOW_TEXT,{acceptNode:Cr=>Cr?.textContent===yt?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),yi=[],Rn=Bt.nextNode();for(;Rn;)yi.push(Rn),Rn=Bt.nextNode();let ss=yi.map(Cr=>{let Gn=Cr.textContent?.toLowerCase(),ca=[],ua=0;for(;Gn&&ua{let bn=new Range;return bn.setStart(Cr,Es),bn.setEnd(Cr,Es+nt.length),bn})});CSS.highlights.set("sms-search-matches",new Highlight(...ss.flat()))}function Iu(I){ht.call(this,i,I)}function kp(I){ht.call(this,i,I)}function Nu(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 ee(I){ht.call(this,i,I)}function Pe(I){ht.call(this,i,I)}function Le(I){ht.call(this,i,I)}function rt(I){ht.call(this,i,I)}function Ot(I){ht.call(this,i,I)}function Ut(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 Rt(){t(53,rn=window.innerWidth)}function lt(I){mi[I?"unshift":"push"](()=>{w=I,t(1,w)})}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",w?.setCustomValidity(I)},_t=I=>Oo(I),ns=I=>Oo(I),Fi=I=>t(54,oa=I);function sn(I){mi[I?"unshift":"push"](()=>{M=I,t(6,M)})}function wt(){bt=this.value,t(4,bt)}function Bi(I){sa=I,t(51,sa)}let on=(I,nt,Bt)=>{I||go(nt,Bt)},Qn=(I,nt)=>{I||t(0,o=nt)},rs=(I,nt)=>{I||t(0,o=nt)},Un=()=>t(0,o=null),yo=()=>t(0,o=null),aa=I=>{c&&go(bt,I)},la=()=>t(52,Pr=!0),xs=()=>t(52,Pr=!0),Ps=()=>t(52,Pr=!1),Hn=()=>t(52,Pr=!1);function Cs(I){mi[I?"unshift":"push"](()=>{vo=I,t(55,vo)})}function kl(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,_=I.duplicates),"key"in I&&t(17,S=I.key),"filterFunc"in I&&t(72,P=I.filterFunc),"closeDropdownOnSelect"in I&&t(73,k=I.closeDropdownOnSelect),"form_input"in I&&t(1,w=I.form_input),"highlightMatches"in I&&t(74,x=I.highlightMatches),"id"in I&&t(18,C=I.id),"input"in I&&t(6,M=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,U=I.liSelectedClass),"liSelectedStyle"in I&&t(27,le=I.liSelectedStyle),"liUserMsgClass"in I&&t(28,xe=I.liUserMsgClass),"loading"in I&&t(29,ue=I.loading),"matchingOptions"in I&&t(2,B=I.matchingOptions),"maxOptions"in I&&t(30,J=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,we=I.name),"noMatchingOptionsMsg"in I&&t(35,yt=I.noMatchingOptionsMsg),"open"in I&&t(8,It=I.open),"options"in I&&t(3,ot=I.options),"outerDiv"in I&&t(9,Nt=I.outerDiv),"outerDivClass"in I&&t(36,Sr=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,at=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,xr=I.resetFilterOnAdd),"searchText"in I&&t(4,bt=I.searchText),"selected"in I&&t(5,et=I.selected),"sortSelected"in I&&t(76,is=I.sortSelected),"selectedOptionsDraggable"in I&&t(44,yl=I.selectedOptionsDraggable),"style"in I&&t(45,Du=I.style),"ulOptionsClass"in I&&t(46,Qu=I.ulOptionsClass),"ulSelectedClass"in I&&t(47,Dn=I.ulSelectedClass),"ulSelectedStyle"in I&&t(48,ks=I.ulSelectedStyle),"ulOptionsStyle"in I&&t(49,bl=I.ulOptionsStyle),"value"in I&&t(67,po=I.value),"$$scope"in I&&t(115,s=I.$$scope)},i.$$.update=()=>{i.$$.dirty[0]&32&&mo(et),i.$$.dirty[2]&32&&Ru(po),i.$$.dirty[0]&196664|i.$$.dirty[2]&1024&&t(2,B=ot.filter(I=>P(I,bt)&&(!et.map(S).includes(S(I))||_))),i.$$.dirty[0]&5&&t(68,a=B[o??-1]??null),i.$$.dirty[0]&32&&t(56,n=I=>et.map(ki).includes(I)),i.$$.dirty[0]&2|i.$$.dirty[1]&4096&&w?.setCustomValidity("")},[o,w,B,ot,bt,et,M,E,It,Nt,l,c,f,p,g,O,_,S,C,Z,Q,D,j,z,q,G,U,le,xe,ue,J,pe,Re,oe,we,yt,Sr,nn,$t,Tt,at,dt,gt,jt,yl,Du,Qu,Dn,ks,bl,m,sa,Pr,rn,oa,vo,n,go,Oo,Mu,vp,yp,Ss,bp,_p,wl,wp,po,a,u,d,h,P,k,x,xr,is,r,Iu,kp,Nu,F,N,W,K,ee,Pe,Le,rt,Ot,Ut,it,Zt,Ht,Rt,lt,zt,_t,ns,Fi,sn,wt,Bi,on,Qn,rs,Un,yo,aa,la,xs,Ps,Hn,Cs,kl,s]}var vg=class extends ne{constructor(e){super(),re(this,e,BD,FD,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},pD,[-1,-1,-1,-1,-1])}},rc=vg;function VD(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=VD);function WD(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 XD(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 rc({props:o}),mi.push(()=>Mr(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],Qr(()=>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 YD(i,e,t){let n,r=X,s=()=>(r(),r=Ii(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 yg=class extends ne{constructor(e){super(),re(this,e,YD,XD,ie,{filter:0},WD)}},Nw=yg;var Bf=require("obsidian");function UD(i){se(i,"svelte-1xutc2s",".search.svelte-1xutc2s,.search.svelte-1xutc2s input{width:100%}")}function HD(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 GD(i,e,t){let n,r=X,s=()=>(r(),r=Ii(o,l=>t(2,n=l)),o);i.$$.on_destroy.push(()=>r());let{filter:o}=e;s();let a=l=>{new Bf.TextComponent(l).setPlaceholder(o.text).onChange((0,Bf.debounce)(c=>{Ke(o,n=c,n)},10))};return i.$$set=l=>{"filter"in l&&s(t(0,o=l.filter))},[o,a]}var bg=class extends ne{constructor(e){super(),re(this,e,GD,HD,ie,{filter:0},UD)}},Vf=bg;function KD(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 jw(i,e,t){let n=i.slice();return n[5]=e[t],n}function JD(i){let e,t,n,r,s=i[1].type==0&&Zw(i),o=i[1].type==2&&zw(i),a=i[1].type==1&&qw(i);return{c(){e=b("div"),s&&s.c(),t=R(),o&&o.c(),n=R(),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=Zw(l),s.c(),$(s,1),s.m(e,t)):s&&(Ee(),V(s,1,1,()=>{s=null}),Te()),l[1].type==2?o?(o.p(l,c),c&2&&$(o,1)):(o=zw(l),o.c(),$(o,1),o.m(e,n)):o&&(Ee(),V(o,1,1,()=>{o=null}),Te()),l[1].type==1?a?(a.p(l,c),c&2&&$(a,1)):(a=qw(l),a.c(),$(a,1),a.m(e,null)):a&&(Ee(),V(a,1,1,()=>{a=null}),Te())},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 e8(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}),Te(),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 i8(i,e,t){let n,r=Ye("filters"),{filters:s}=r;ke(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 Wf=class extends ne{constructor(e){super(),re(this,e,i8,t8,ie,{layout:0},KD)}},Fw=Wf;function n8(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 Bw(i,e,t){let n=i.slice();return n[10]=e[t],n}function Vw(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=So(e,Ym,{easing:In},!0)),t.run(1))}),n=!0}},o(a){s=s.filter(Boolean);for(let l=0;l{k=null}),Te())},i(w){_||($(n.$$.fragment,w),$(k),_=!0)},o(w){V(n.$$.fragment,w),V(k),_=!1},d(w){w&&T(e),ve(n),k&&k.d(),S=!1,de(P)}}}function s8(i,e,t){let n,r,s=!1,o=Fe(),a=Ye("filters"),{active:l,name:c,layout:u}=a;return ke(i,l,O=>t(1,n=O)),ke(i,u,O=>t(2,r=O)),[s,n,r,o,a,l,c,O=>{new Xf.ExtraButtonComponent(O).setIcon("reset")},O=>{new Xf.ExtraButtonComponent(O).setIcon("filter")},O=>{new Xf.ExtraButtonComponent(O).setIcon("settings")},u,()=>t(0,s=!s),()=>a.reset(),O=>o("settings",O)]}var _g=class extends ne{constructor(e){super(),re(this,e,s8,r8,ie,{},n8)}},Xw=_g;var uo=require("obsidian");var Do=require("obsidian");function o8(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 Yw(i,e,t){let n=i.slice();return n[14]=e[t],n}function a8(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=R(),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=Y(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 l8(i){let e,t,n;return{c(){e=b("span"),e.textContent="..."},m(r,s){A(r,e,s),t||(n=Y(e,"click",i[12]),t=!0)},p:X,d(r){r&&T(e),t=!1,n()}}}function Uw(i){let e;function t(s,o){return s[14]==null?l8:a8}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 c8(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_=fe(i[1]),S=[];for(let P=0;P<_.length;P+=1)S[P]=Uw(Yw(i,_,P));return{c(){e=b("div"),t=b("div"),n=b("div"),s=R(),o=b("span"),o.textContent="per page",a=R(),l=b("div"),c=b("div"),f=R(),d=b("div");for(let P=0;P{new Do.DropdownComponent(O).addOptions({10:"10",25:"25",50:"50",100:"100",200:"200"}).setValue(`${s}`).onChange(_=>l("slice",Number(_)))},u,f=O=>{t(9,u=new Do.ExtraButtonComponent(O).setIcon("chevron-left").setDisabled(o==1).onClick(()=>{l("previous")}))},d,h=O=>{t(10,d=new Do.ExtraButtonComponent(O).setIcon("chevron-right").setDisabled(o==a).onClick(()=>{l("next")}))},p=O=>{let _=new Do.Menu;for(let S of n)_.addItem(P=>{P.setTitle(`${S}`).onClick(()=>{l("page",S)})});_.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,_)=>(_==1||o==1&&(_==2||_==3)||_==a||o==a&&(_==a-1||_==a-2)||_==o-1||_==o||_==o+1?O.push(_):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 wg=class extends ne{constructor(e){super(),re(this,e,u8,c8,ie,{slice:7,page:0,pages:8},o8)}},Hw=wg;var WP=require("obsidian");var ZG=require("obsidian");var $G=$e(0),zs=class i{constructor(e,t,n,r){this.text=e;this.field=t;this.type=n;this.func=r;te(this,"active");te(this,"id",xt());te(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}}},Gw=[{text:"CR",field:"cr",type:1},{text:"Type",field:"type",type:0},{text:"Size",field:"size",type:0},{text:"Alignment",field:"alignment",type:0}],sc=zs.fromState({text:"Name",field:"name",type:0});function Jw(i,e){i.data.builder||(i.data.builder={sidebarIcon:!0,showParty:!0,showXP:!0}),i.data.builder.headers||(i.data.builder.headers=ci(Gw),i.saveSettings());let t=$e(i.data.builder.headers.map(f=>zs.fromState(f))),{subscribe:n,set:r,update:s}=t,o=$e(ci(e)),a=$e(!0),l=oi(t,f=>[sc,...f]),c=f=>s(d=>{if(f.active)a.update(h=>!h);else{let h=ct(l).find(p=>p.active);h&&(h.active=!1),f.active=!0,a.set(!0)}return o.update(h=>(h.sort(ct(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=>zs.fromState(m)),p=d.findIndex(m=>m.active);return p>=0&&pu(f=>(i.data.builder.headers=ci(Gw),i.data.builder.headers.map(d=>zs.fromState(d))))}}var Gr=require("obsidian");var Hr=require("obsidian");var ut=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]=za(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),Ia.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]=za(this,e,t);let n=[];return this.decompose(e,t,n,0),Ia.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 Mo(this),s=new Mo(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 Mo(this,e)}iterRange(e,t=this.length){return new Gf(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 Kf(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):Ia.from(Sn.split(e,[]))}},Sn=class i extends ut{constructor(e,t=f8(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 Sg(r,a,n,o);r=a+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new i(ek(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),a=Hf(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]=za(this,e,t);let r=Hf(this.text,Hf(n.text,ek(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new i(r,s):Ia.from(i.split(r,[]),s)}sliceString(e,t=this.length,n=`
`){[e,t]=za(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}},Ia=class i extends ut{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]=za(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]=za(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)}};ut.empty=new Sn([""],0);function f8(i){let e=-1;for(let t of i)e+=t.length+1;return e}function Hf(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)}},Gf=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Mo(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!=""}},Kf=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"&&(ut.prototype[Symbol.iterator]=function(){return this.iter()},Mo.prototype[Symbol.iterator]=Gf.prototype[Symbol.iterator]=Kf.prototype[Symbol.iterator]=function(){return this});var Sg=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 za(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}var Na="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(i=>i?parseInt(i,36):1);for(let i=1;ii)return Na[e-1]<=i;return!1}function tk(i){return i>=127462&&i<=127487}var ik=8205;function ui(i,e,t=!0,n=!0){return(t?lk:h8)(i,e,n)}function lk(i,e,t){if(e==i.length)return e;e&&ck(i.charCodeAt(e))&&uk(i.charCodeAt(e-1))&&e--;let n=gi(i,e);for(e+=Yi(n);e=0&&tk(gi(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function h8(i,e,t){for(;e>0;){let n=lk(i,e-2,t);if(n=56320&&i<57344}function uk(i){return i>=55296&&i<56320}function gi(i,e){let t=i.charCodeAt(e);if(!uk(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return ck(n)?(t-55296<<10)+(n-56320)+65536:t}function fc(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function Yi(i){return i<65536?1:2}var xg=/\r\n?|\n/,Ei=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(Ei||(Ei={})),ps=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!=Ei.Simple&&c>=e&&(n==Ei.TrackDel&&re||n==Ei.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 ps{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 Pg(this,(t,n,r,s,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return Cg(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&&qs(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"?ut.of(h.split(n||xg)):h:ut.empty,m=p.length;if(f==d&&m==0)return;fo&&Zi(r,f-o,-1),Zi(r,d-f,m),qs(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:e==0&&i[r]==0?i[r+1]+=t:n?(i[r]+=e,i[r+1]+=t):i.push(e,t)}function qs(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 Cg(i,e,t,n=!1){let r=[],s=n?[]:null,o=new Io(i),a=new Io(e);for(let l=-1;;)if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);Zi(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 Io=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?ut.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?ut.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)}},Ma=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 ce.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return ce.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 ce.range(e.anchor,e.head)}static create(e,t,n){return new i(e,t,n)}},ce=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=>Ma.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 dk(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var jg=0,Ae=class i{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=jg++,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:Zg),!!e.static,e.enables)}of(e){return new ja([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ja(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ja(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}};function Zg(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}var ja=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=jg++}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)||Eg(f,u)){let h=n(f);if(a?!nk(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=id(d,p);if(this.dependencies.every(g=>g instanceof Ae?d.facet(g)===f.facet(g):g instanceof Xt?d.field(g,!1)==f.field(g,!1):!0)||(a?nk(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 nk(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(rk).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,rk.of({field:this,create:e})]}get extension(){return this}},Qo={lowest:4,low:3,default:2,high:1,highest:0};function oc(i){return e=>new Jf(e,i)}var fr={highest:oc(Qo.highest),high:oc(Qo.high),default:oc(Qo.default),low:oc(Qo.low),lowest:oc(Qo.lowest)},Jf=class{constructor(e,t){this.inner=e,this.prec=t}},ed=class i{of(e){return new lc(this,e)}reconfigure(e){return i.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},lc=class{constructor(e,t){this.compartment=e,this.inner=t}},td=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 m8(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,Zg(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=>p8(g,p,h))}}let f=c.map(d=>d(a));return new i(e,o,f,a,l,s)}};function m8(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 lc&&t.delete(o.compartment)}if(r.set(o,a),Array.isArray(o))for(let c of o)s(c,a);else if(o instanceof lc){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 Jf)s(o.inner,o.prec);else if(o instanceof Xt)n[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof ja)n[a].push(o),o.facet.extensions&&s(o.facet.extensions,Qo.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,Qo.default),n.reduce((o,a)=>o.concat(a))}function ac(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 id(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}var hk=Ae.define(),Tg=Ae.define({combine:i=>i.some(e=>e),static:!0}),pk=Ae.define({combine:i=>i.length?i[0]:void 0,static:!0}),mk=Ae.define(),gk=Ae.define(),Ok=Ae.define(),vk=Ae.define({combine:i=>i.length?i[0]:!1}),pn=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Ag}},Ag=class{of(e){return new pn(this,e)}},Dg=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 Dg(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 Oi=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&&dk(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]=="."))}};Oi.time=pn.define();Oi.userEvent=pn.define();Oi.addToHistory=pn.define();Oi.remote=pn.define();function g8(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 Oi?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Oi?i=s[0]:i=bk(e,Za(s),!1)}return i}function v8(i){let e=i.startState,t=e.facet(Ok),n=i;for(let r=t.length-1;r>=0;r--){let s=t[r](i);s&&Object.keys(s).length&&(n=yk(n,Qg(e,s,i.changes.newLength),!0))}return n==i?i:Oi.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}var y8=[];function Za(i){return i==null?y8: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={})),b8=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Rg;try{Rg=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function _8(i){if(Rg)return Rg.test(i);for(let e=0;e"\x80"&&(t.toUpperCase()!=t.toLowerCase()||b8.test(t)))return!0}return!1}function w8(i){return e=>{if(!/\S/.test(e))return Pt.Space;if(_8(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=Za(n).concat(a.value));let s;t?s=e.startState.values.slice():(t=td.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(Tg)?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:ce.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=Za(n.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return i.create({doc:e.doc,selection:ce.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=td.resolve(e.extensions||[],new Map),n=e.doc instanceof ut?e.doc:ut.of((e.doc||"").split(t.staticFacet(i.lineSeparator)||xg)),r=e.selection?e.selection instanceof ce?e.selection:ce.single(e.selection.anchor,e.selection.head):ce.single(0);return dk(r,n.length),t.staticFacet(Tg)||(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(vk)}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(hk))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return w8(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=pk;At.readOnly=vk;At.phrases=Ae.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=hk;At.changeFilter=mk;At.transactionFilter=gk;At.transactionExtender=Ok;ed.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 ur=class{eq(e){return this==e}range(e,t=e){return cc.create(e,t,this)}};ur.prototype.startSide=ur.prototype.endSide=0;ur.prototype.point=!1;ur.prototype.mapMode=Ei.TrackDel;var cc=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 Mg(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var Ig=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}}},kt=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(Mg)),this.isEmpty)return t.length?i.of(t):this;let a=new nd(this,null,-1).goto(0),l=0,c=[],u=new jr;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 uc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return uc.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=sk(o,a,n),c=new Ro(o,l,s),u=new Ro(a,l,s);n.iterGaps((f,d,h)=>ok(c,f,u,d,h,r)),n.empty&&n.length==0&&ok(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=sk(s,o),l=new Ro(s,a,0).goto(n),c=new Ro(o,a,0).goto(n);for(;;){if(l.to!=c.to||!Ng(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 Ro(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 jr;for(let r of e instanceof cc?[e]:t?k8(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}};kt.empty=new kt([],[],null,-1);function k8(i){if(i.length>1)for(let e=i[0],t=1;t0)return i.slice().sort(Mg);e=n}return i}kt.empty.nextLayer=kt.empty;var jr=class i{finishChunk(e){this.chunks.push(new Ig(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(kt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=kt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function sk(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 nd(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--)kg(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--)kg(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(),kg(this.heap,0)}}};function kg(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 Ro=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=uc.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){Yf(this.active,e),Yf(this.activeTo,e),Yf(this.activeRank,e),this.minActive=ak(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t0;)t++;Uf(this.active,t,n),Uf(this.activeTo,t,r),Uf(this.activeRank,t,s),e&&Uf(e,t,this.cursor.from),this.minActive=ak(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&&Yf(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 ok(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||i.endSide-t.endSide,u=c<0?i.to+l:t.to,f=Math.min(u,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&Ng(i.activeForPoint(i.to),t.activeForPoint(t.to))||s.comparePoint(a,f,i.point,t.point):f>a&&!Ng(i.active,t.active)&&s.compareRange(a,f,i.active,t.active),u>o)break;a=u,c<=0&&i.next(),c>=0&&t.next()}}function Ng(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 ak(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 zg="\u037C",_k=typeof Symbol>"u"?"__"+zg:Symbol.for(zg),qg=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),wk=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=wk[_k]||1;return wk[_k]=e+1,zg+e.toString(36)}static mount(e,t,n){let r=e[qg],s=n&&n.nonce;r?s&&r.setNonce(s):r=new Lg(e,s),r.mount(Array.isArray(t)?t:[t],e)}},kk=new Map,Lg=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=kk.get(n);if(s)return e[qg]=s;this.sheet=new r.CSSStyleSheet,kk.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[qg]=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:'"'},S8=typeof navigator<"u"&&/Mac/.test(navigator.platform),x8=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(fi=0;fi<10;fi++)ms[48+fi]=ms[96+fi]=String(fi);var fi;for(fi=1;fi<=24;fi++)ms[fi+111]="F"+fi;var fi;for(fi=65;fi<=90;fi++)ms[fi]=String.fromCharCode(fi+32),qa[fi]=String.fromCharCode(fi);var fi;for(sd in ms)qa.hasOwnProperty(sd)||(qa[sd]=ms[sd]);var sd;function Sk(i){var e=S8&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||x8&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?qa:ms)[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 bd(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function Yg(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function P8(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function md(i,e){if(!e.anchorNode)return!1;try{return Yg(i,e.anchorNode)}catch{return!1}}function kc(i){return i.nodeType==3?jo(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function vc(i,e,t,n){return t?xk(i,e,t,n,-1)||xk(i,e,t,n,1):!1}function No(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function _d(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function xk(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:gs(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=No(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?gs(i):0}else return!1}}function gs(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function D0(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function C8(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 l2(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 E8(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=C8(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 _=u.getBoundingClientRect();({scaleX:p,scaleY:m}=l2(u,_)),d={left:_.left,right:_.left+u.clientWidth*p,top:_.top,bottom:_.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+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+g+s)):e.right>d.right&&(g=e.right-d.right+s,t<0&&e.leftt.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}var Ug=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?gs(t):0),n,Math.min(e.focusOffset,n?gs(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},La=null;function c2(i){if(i.setActive)return i.setActive();if(La)return i.focus(La);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(La==null?{get preventScroll(){return La={preventScroll:!0},!0}}:void 0),!La){La=!1;for(let t=0;tMath.max(1,i.scrollHeight-i.clientHeight-4)}function d2(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=gs(t)}else if(t.parentNode&&!_d(t))n=No(t),t=t.parentNode;else return null}}function h2(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 p2(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:(t2),Qe={mac:Ak||/Mac/.test(xn.platform),windows:/Win/.test(xn.platform),linux:/Linux|X11/.test(xn.platform),ie:Id,ie_version:g2?Hg.documentMode||6:Kg?+Kg[1]:Gg?+Gg[1]:0,gecko:Ek,gecko_version:Ek?+(/Firefox\/(\d+)/.exec(xn.userAgent)||[0,0])[1]:0,chrome:!!$g,chrome_version:$g?+$g[1]:0,ios:Ak,android:/Android\b/.test(xn.userAgent),webkit:Tk,safari:O2,webkit_version:Tk?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Hg.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},Q8=256,$r=class i extends Mt{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof i)||this.length-(t-e)+n.length>Q8||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 R8(this.dom,e,t)}},Bs=class i extends Mt{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(u2(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 v2(this,e)}coordsAt(e,t){return b2(this,e,t)}};function R8(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?Qe.chrome||Qe.gecko||(e?(r--,o=1):s=0)?0:a.length-1];return Qe.safari&&!o&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),o?D0(l,o<0):l||null}var Sc=class i extends Mt{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 ut.empty}get isHidden(){return!0}};$r.prototype.children=Sc.prototype.children=xc.prototype.children=Q0;function v2(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 Bs&&r.length&&(n=r[r.length-1])instanceof Bs&&n.mark.eq(e.mark)?y2(n,e.children[0],t-1):(r.push(e),e.setParent(i)),i.length+=e.length}function b2(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)&&(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 e0(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 I8(i){let e=Object.create(null);for(let t=0;t0&&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){R0(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){y2(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Jg(t,this.attrs||{})),n&&(this.attrs=Jg({class:n},this.attrs||{}))}domAtPos(e){return v2(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(u2(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&&(e0(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&&Mt.get(r)instanceof Bs;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((n=Mt.get(r))===null||n===void 0?void 0:n.isEditable)==!1&&(!Qe.ios||!this.children.some(s=>s instanceof $r))){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 $r)||/[^ -~]/.test(n.text))return null;let r=kc(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=b2(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}},Va=class i extends Mt{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}},dr=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Gi=function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i}(Gi||(Gi={})),je=class extends ur{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Pc(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Vs(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}=_2(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Vs(e,n,r,t,e.widget||null,!0)}static line(e){return new Cc(e)}static set(e,t=!1){return kt.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};je.none=kt.empty;var Pc=class i extends je{constructor(e){let{start:t,end:n}=_2(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))&&R0(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)}};Pc.prototype.point=!1;var Cc=class i extends je{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof i&&this.spec.class==e.spec.class&&R0(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)}};Cc.prototype.mapMode=Ei.TrackBefore;Cc.prototype.point=!0;var Vs=class i extends je{constructor(e,t,n,r,s,o){super(t,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ei.TrackBefore:Ei.TrackAfter:Ei.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&&N8(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)}};Vs.prototype.point=!0;function _2(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 N8(i,e){return i==e||!!(i&&e&&i.compare(e))}function t0(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 yc=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 Va&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ti),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(od(new xc(-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 Va)&&this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)throw new Error("Ran out of text content when drawing inline views");if(o){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=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(od(new $r(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=0}}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 Vs){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 Vs)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Va(n.widget||Ws.block,a,n));else{let l=Sc.create(n.widget||Ws.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(od(new xc(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(od(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=kt.spans(r,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function od(i,e){for(let t of e)i=new Bs(t,[i],i.length);return i}var Ws=class extends dr{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}};Ws.inline=new Ws("span");Ws.block=new Ws("div");var Ct=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(Ct||(Ct={})),Zo=Ct.LTR,M0=Ct.RTL;function w2(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 S2(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 $8(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 n0(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 qr(l,m.from,h));let g=m.direction==Zo!=!(h%2);r0(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?n0(i,l,p,n+1,r,d,o):l