@telepath-computer/television 0.1.183 → 0.1.184

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,16 +26,16 @@
26
26
  height: 100%;
27
27
  }
28
28
  </style>
29
- <script type="module">var Mv=Object.defineProperty;var nO=i=>{throw TypeError(i)};var zv=(i,t,e)=>t in i?Mv(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var P=(i,t,e)=>zv(i,typeof t!="symbol"?t+"":t,e),ih=(i,t,e)=>t.has(i)||nO("Cannot "+e);var w=(i,t,e)=>(ih(i,t,"read from private field"),e?e.call(i):t.get(i)),A=(i,t,e)=>t.has(i)?nO("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),R=(i,t,e,n)=>(ih(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),Zt=(i,t,e)=>(ih(i,t,"access private method"),e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=e(r);fetch(r.href,s)}})();const _v=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function Iv(i){for(const t of Object.keys(i))if(_v.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function jv(i,t){Iv(t);for(const e of Object.keys(t))Object.defineProperty(i,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function Dv(){class i extends Event{constructor(e,n){const{type:r,bubbles:s,cancelable:o,composed:l,...a}=n??{};if(r!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(e,{bubbles:s,cancelable:o,composed:l}),jv(this,a)}}return i}let Vv=class extends globalThis.EventTarget{};function Bv(i,t,e){const n=i.dispose.bind(i);i.dispose=()=>{if(!t())return e(),n()}}function Wv(i){var e;class t extends i{constructor(...s){super(...s);A(this,e,!1);Bv(this,()=>w(this,e),()=>{R(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return w(this,e)}}return e=new WeakMap,t}const kg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Aa=32,Yv=16,Qg=10,rO=0xffffffffffff;var er;(function(i){i.Base32IncorrectEncoding="B32_ENC_INVALID",i.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",i.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",i.EncodeTimeNegative="ENC_TIME_NEG",i.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",i.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",i.PRNGDetectFailure="PRNG_DETECT",i.ULIDInvalid="ULID_INVALID",i.Unexpected="UNEXPECTED",i.UUIDInvalid="UUID_INVALID"})(er||(er={}));class Ao extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function qv(i){const t=Math.floor(i()*Aa)%Aa;return kg.charAt(t)}function Nv(i){const t=Gv(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const n=new Uint8Array(1);return e.getRandomValues(n),n[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new Ao(er.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Gv(){return Fv()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Uv(i,t){let e="";for(;i>0;i--)e=qv(t)+e;return e}function Hv(i,t=Qg){if(isNaN(i))throw new Ao(er.EncodeTimeValueMalformed,`Time must be a number: ${i}`);if(i>rO)throw new Ao(er.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${rO}: ${i}`);if(i<0)throw new Ao(er.EncodeTimeNegative,`Time must be positive: ${i}`);if(Number.isInteger(i)===!1)throw new Ao(er.EncodeTimeValueMalformed,`Time must be an integer: ${i}`);let e,n="";for(let r=t;r>0;r--)e=i%Aa,n=kg.charAt(e)+n,i=(i-e)/Aa;return n}function Fv(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function $g(i,t){const e=Nv(),n=Date.now();return Hv(n,Qg)+Uv(Yv,e)}function Oa(i){return typeof i=="object"&&i!==null}function Cg(i){return!Oa(i)||i.type!=="content-updated"||typeof i.content!="string"?!1:!("id"in i)}function Pg(i){if(!Oa(i)||i.type!=="response"||typeof i.id!="string")return!1;const t="result"in i&&i.result!==void 0,e="error"in i&&i.error!==void 0;return!(t===e||t&&(!Oa(i.result)||Object.keys(i.result).length!==0)||e&&(!Oa(i.error)||typeof i.error.message!="string"))}const Tg=Dv(),Ag=Wv(Vv);var Nr,Gr,Ur,vn,mi,Rg,Zg,Hh,Xg;class Kv extends Ag{constructor(e=globalThis){super();A(this,mi);A(this,Nr);A(this,Gr);A(this,Ur);A(this,vn,new Map);R(this,Nr,e);const n=e.parent;if(!n||n===e)throw new Error("ArtifactContext: window has no parent");R(this,Gr,n),R(this,Ur,r=>Zt(this,mi,Rg).call(this,r)),w(this,Nr).addEventListener("message",w(this,Ur)),Zt(this,mi,Hh).call(this,{type:"ready"})}updateContent(e){Zt(this,mi,Xg).call(this);const n=$g(),r={type:"update-content",id:n,content:e};return new Promise((s,o)=>{w(this,vn).set(n,{resolve:s,reject:o}),Zt(this,mi,Hh).call(this,r)})}dispose(){w(this,Nr).removeEventListener("message",w(this,Ur));const e=[...w(this,vn).values()];w(this,vn).clear();for(const{reject:n}of e)n(new Error("ArtifactContext disposed"))}}Nr=new WeakMap,Gr=new WeakMap,Ur=new WeakMap,vn=new WeakMap,mi=new WeakSet,Rg=function(e){if(this.disposed||e.source!==w(this,Gr))return;const n=e.data;if(Cg(n)){this.dispatchEvent(new Tg("content-updated",{content:n.content}));return}if(Pg(n)){Zt(this,mi,Zg).call(this,n);return}},Zg=function(e){const n=w(this,vn).get(e.id);if(n){if(w(this,vn).delete(e.id),e.error!==void 0){n.reject(new Error(e.error.message));return}n.resolve()}},Hh=function(e){w(this,Gr).postMessage(e,"*")},Xg=function(){if(this.disposed)throw new Error("ArtifactContext is disposed")};var ml,gl,xn,gi,Eg,Lg,Fh,Mg;class Jv extends Ag{constructor(e=globalThis){super();A(this,gi);A(this,ml);A(this,gl);A(this,xn,new Map);const n=e.__televisionContentBridge;if(!n)throw new Error("WebviewArtifactContext: window has no __televisionContentBridge");R(this,ml,n),R(this,gl,n.onHostMessage(r=>Zt(this,gi,Eg).call(this,r))),Zt(this,gi,Fh).call(this,{type:"ready"})}updateContent(e){Zt(this,gi,Mg).call(this);const n=$g(),r={type:"update-content",id:n,content:e};return new Promise((s,o)=>{w(this,xn).set(n,{resolve:s,reject:o}),Zt(this,gi,Fh).call(this,r)})}dispose(){w(this,gl).call(this);const e=[...w(this,xn).values()];w(this,xn).clear();for(const{reject:n}of e)n(new Error("WebviewArtifactContext disposed"))}}ml=new WeakMap,gl=new WeakMap,xn=new WeakMap,gi=new WeakSet,Eg=function(e){if(!this.disposed){if(Cg(e)){this.dispatchEvent(new Tg("content-updated",{content:e.content}));return}if(Pg(e)){Zt(this,gi,Lg).call(this,e);return}}},Lg=function(e){const n=w(this,xn).get(e.id);if(n){if(w(this,xn).delete(e.id),e.error!==void 0){n.reject(new Error(e.error.message));return}n.resolve()}},Fh=function(e){w(this,ml).postToHost(e)},Mg=function(){if(this.disposed)throw new Error("WebviewArtifactContext is disposed")};function tx(i=window,t={}){const e=i;if(e.__televisionArtifactBridgeInstalled===!0||(e.__televisionArtifactBridgeInstalled=!0,i.parent===i))return;const r=(()=>{const m=Date.now().toString(36);try{const g=i.crypto;if(g&&typeof g.getRandomValues=="function"){const b=new Uint32Array(4);return g.getRandomValues(b),`tvb-${m}-${Array.from(b,S=>S.toString(36)).join("-")}`}}catch{}return`tvb-${m}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`})(),s=()=>{i.parent.postMessage({type:"bridge-ready",url:i.location.href,guid:r},"*")};i.addEventListener("pagehide",()=>{i.parent.postMessage({type:"leaving",guid:r},"*")}),i.addEventListener("pageshow",O=>{O.persisted===!0&&s()});const o=i.location.href;if((O=>{try{const p=new URL(O);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(p.pathname)}catch{return!1}})(o)&&typeof i.fetch=="function"){let m=null,g=5e3,b=!1;const S=()=>{(async()=>{try{const x=await i.fetch(o,{method:"HEAD"});if(!x.ok)throw new Error("Artifact poll failed");const y=x.headers.get("ETag");if(!y)throw new Error("Artifact poll missing ETag");g=5e3,m===null?m=y:y!==m&&(m=y,i.parent.postMessage({type:"proxy-content-changed"},"*"))}catch{g=Math.min(15e3,g*2)}finally{b||i.setTimeout(S,g)}})()};i.addEventListener("pagehide",()=>{b=!0}),S()}const a=()=>{i.document.documentElement&&(i.document.documentElement.style.touchAction="pan-y",i.document.documentElement.style.overscrollBehaviorX="contain",i.document.documentElement.style.overscrollBehaviorY="contain"),i.document.body&&(i.document.body.style.overscrollBehaviorX="contain",i.document.body.style.overscrollBehaviorY="contain")};if(a(),i.document.body||i.document.addEventListener("DOMContentLoaded",a,{once:!0}),t.reportNavigation!==!1){const O=m=>{i.parent.postMessage({type:"navigation-request",...m},"*")};O({url:i.location.href});const p=i.navigation;if(p)p.addEventListener("navigate",m=>{var k,Q;const g=m,b=(k=g.destination)==null?void 0:k.url;if(typeof b!="string")return;const S=((Q=g.destination)==null?void 0:Q.sameDocument)===!0,x={url:b,...g.navigationType==="replace"?{replace:!0}:{},...S?{sameDocument:!0}:{}};if(S){O(x);return}try{if(new URL(b,i.location.href).origin===i.location.origin){O({...x,native:!0});return}}catch{}g.canIntercept!==!1&&g.preventDefault(),O(x)});else{i.document.addEventListener("click",b=>{var X;const S=b;if(S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const x=(X=i.document.defaultView)==null?void 0:X.Element;if(!x||!(S.target instanceof x))return;const y=S.target.closest("a[href]");if(!y||y.target&&y.target.toLowerCase()!=="_self"||y.hasAttribute("download"))return;const k=y.getAttribute("href");if(!k||k.startsWith("javascript:"))return;let Q;try{Q=new URL(y.href,i.document.baseURI)}catch{return}if(Q.origin===i.location.origin&&Q.pathname===i.location.pathname&&Q.search===i.location.search&&Q.hash!==""){O({url:Q.href,sameDocument:!0});return}S.preventDefault(),O({url:Q.href})},!0);const m=i.history.pushState.bind(i.history),g=i.history.replaceState.bind(i.history);i.history.pushState=function(...S){m(...S),O({url:i.location.href,sameDocument:!0})},i.history.replaceState=function(...S){g(...S),O({url:i.location.href,replace:!0,sameDocument:!0})},i.addEventListener("popstate",()=>{O({url:i.location.href,sameDocument:!0})}),i.addEventListener("hashchange",()=>{O({url:i.location.href,sameDocument:!0})}),i.document.addEventListener("submit",b=>{var X,B;const S=b,x=S.target,y=(X=i.document.defaultView)==null?void 0:X.HTMLFormElement;if(!y||!(x instanceof y)||x.target&&x.target.toLowerCase()!=="_self")return;S.preventDefault();const k=x.method.toLowerCase(),Q=new URL(x.action||i.location.href,i.document.baseURI);if(k==="get"){const L=(B=i.document.defaultView)==null?void 0:B.FormData;if(!L)return;const V=new URLSearchParams;for(const[_,G]of new L(x))typeof G=="string"&&V.append(_,G);Q.search=V.toString()}O({url:Q.href})},!0)}}const c=O=>{var b,S;const p=(b=i.document.defaultView)==null?void 0:b.Element;if(!p||!(O instanceof p))return!1;const g=O.closest("input, textarea, select, [contenteditable], [role='textbox'], [role='searchbox'], [role='combobox'], [role='spinbutton'], [role='slider']");return g?g.hasAttribute("contenteditable")?((S=g.getAttribute("contenteditable"))==null?void 0:S.toLowerCase())!=="false":!0:!1};i.addEventListener("keydown",O=>{const p=O;p.key!=="ArrowLeft"&&p.key!=="ArrowRight"||p.metaKey||p.ctrlKey||p.altKey||p.shiftKey||c(p.target)||(p.preventDefault(),i.parent.postMessage({type:"filmstrip-key",direction:p.key==="ArrowRight"?1:-1},"*"))},{capture:!0}),i.addEventListener("wheel",O=>{const p=O,m=p.shiftKey&&p.deltaX===0&&p.deltaY!==0,g=m?p.deltaY:p.deltaX,b=Math.abs(g),S=m?0:Math.abs(p.deltaY);b<=S||(p.preventDefault(),i.parent.postMessage({type:"wheel",deltaX:g,shiftKey:p.shiftKey},"*"))},{passive:!1});const h=8,u=100,f=1e3,d=new Map;i.addEventListener("pointerdown",O=>{const p=O;p.pointerType==="touch"&&d.set(p.pointerId,{startX:p.clientX,startY:p.clientY,lastX:p.clientX,offset:0,active:!1,discarded:!1,samples:[{time:p.timeStamp,offset:0}]})},{passive:!0}),i.addEventListener("pointermove",O=>{const p=O,m=d.get(p.pointerId);if(!m||m.discarded)return;if(!m.active){const x=p.clientX-m.startX,y=p.clientY-m.startY,k=Math.abs(x),Q=Math.abs(y);if(k<h&&Q<h)return;if(Q>=k){m.discarded=!0;return}m.active=!0}const g=p.clientX-m.lastX;m.lastX=p.clientX,m.offset+=g,m.samples.push({time:p.timeStamp,offset:m.offset});const b=p.timeStamp-u;let S=0;for(let x=0;x<m.samples.length;x+=1){if(m.samples[x].time>=b){S=x;break}S=x+1}if(S>0){const x=Math.max(0,S-1);m.samples.splice(0,x)}i.parent.postMessage({type:"swipe-move",deltaX:g},"*"),p.preventDefault()},{passive:!1}),i.addEventListener("pointerup",O=>{const p=O,m=d.get(p.pointerId);if(!m||(d.delete(p.pointerId),!m.active))return;let g=0;if(m.samples.length>=2){const b=m.samples[0],S=m.samples[m.samples.length-1],x=S.time-b.time;x>0&&(g=(S.offset-b.offset)/x*f)}i.parent.postMessage({type:"swipe-end",velocityX:g},"*")}),i.addEventListener("pointercancel",O=>{const p=O,m=d.get(p.pointerId);m&&(d.delete(p.pointerId),m.active&&i.parent.postMessage({type:"swipe-end",velocityX:0},"*"))}),s()}let Kh=[],zg=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,e=0;t<i.length;t++)(t%2?zg:Kh).push(e=e+i[t])})();function ex(i){if(i<768)return!1;for(let t=0,e=Kh.length;;){let n=t+e>>1;if(i<Kh[n])e=n;else if(i>=zg[n])t=n+1;else return!0;if(t==e)return!1}}function sO(i){return i>=127462&&i<=127487}const oO=8205;function ix(i,t,e=!0,n=!0){return(e?_g:nx)(i,t,n)}function _g(i,t,e){if(t==i.length)return t;t&&Ig(i.charCodeAt(t))&&jg(i.charCodeAt(t-1))&&t--;let n=nh(i,t);for(t+=lO(n);t<i.length;){let r=nh(i,t);if(n==oO||r==oO||e&&ex(r))t+=lO(r),n=r;else if(sO(r)){let s=0,o=t-2;for(;o>=0&&sO(nh(i,o));)s++,o-=2;if(s%2==0)break;t+=2}else break}return t}function nx(i,t,e){for(;t>0;){let n=_g(i,t-2,e);if(n<t)return n;t--}return 0}function nh(i,t){let e=i.charCodeAt(t);if(!jg(e)||t+1==i.length)return e;let n=i.charCodeAt(t+1);return Ig(n)?(e-55296<<10)+(n-56320)+65536:e}function Ig(i){return i>=56320&&i<57344}function jg(i){return i>=55296&&i<56320}function lO(i){return i<65536?1:2}let Y=class Dg{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,n){[t,e]=Bs(this,t,e);let r=[];return this.decompose(0,t,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(e,this.length,r,1),Zi.from(r,this.length-(e-t)+n.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=Bs(this,t,e);let n=[];return this.decompose(t,e,n,0),Zi.from(n,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),n=this.length-this.scanIdentical(t,-1),r=new zo(this),s=new zo(t);for(let o=e,l=e;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=n)return!0}}iter(t=1){return new zo(this,t)}iterRange(t,e=this.length){return new Vg(this,t,e)}iterLines(t,e){let n;if(t==null)n=this.iter();else{e==null&&(e=this.lines+1);let r=this.line(t).from;n=this.iterRange(r,Math.max(r,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new Bg(n)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?Dg.empty:t.length<=32?new jt(t):Zi.from(jt.split(t,[]))}};class jt extends Y{constructor(t,e=rx(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,n,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((e?n:l)>=t)return new sx(r,l,n,o);r=l+1,n++}}decompose(t,e,n,r){let s=t<=0&&e>=this.length?this:new jt(aO(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(r&1){let o=n.pop(),l=pa(s.text,o.text.slice(),0,s.length);if(l.length<=32)n.push(new jt(l,o.length+s.length));else{let a=l.length>>1;n.push(new jt(l.slice(0,a)),new jt(l.slice(a)))}}else n.push(s)}replace(t,e,n){if(!(n instanceof jt))return super.replace(t,e,n);[t,e]=Bs(this,t,e);let r=pa(this.text,pa(n.text,aO(this.text,0,t)),e),s=this.length+n.length-(e-t);return r.length<=32?new jt(r,s):Zi.from(jt.split(r,[]),s)}sliceString(t,e=this.length,n=`
29
+ <script type="module">var Mv=Object.defineProperty;var nO=i=>{throw TypeError(i)};var zv=(i,t,e)=>t in i?Mv(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var P=(i,t,e)=>zv(i,typeof t!="symbol"?t+"":t,e),ih=(i,t,e)=>t.has(i)||nO("Cannot "+e);var w=(i,t,e)=>(ih(i,t,"read from private field"),e?e.call(i):t.get(i)),A=(i,t,e)=>t.has(i)?nO("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),R=(i,t,e,n)=>(ih(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),Zt=(i,t,e)=>(ih(i,t,"access private method"),e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=e(r);fetch(r.href,s)}})();const _v=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function Iv(i){for(const t of Object.keys(i))if(_v.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function jv(i,t){Iv(t);for(const e of Object.keys(t))Object.defineProperty(i,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function Dv(){class i extends Event{constructor(e,n){const{type:r,bubbles:s,cancelable:o,composed:l,...a}=n??{};if(r!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(e,{bubbles:s,cancelable:o,composed:l}),jv(this,a)}}return i}let Vv=class extends globalThis.EventTarget{};function Bv(i,t,e){const n=i.dispose.bind(i);i.dispose=()=>{if(!t())return e(),n()}}function Wv(i){var e;class t extends i{constructor(...s){super(...s);A(this,e,!1);Bv(this,()=>w(this,e),()=>{R(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return w(this,e)}}return e=new WeakMap,t}const kg="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Aa=32,Yv=16,Qg=10,rO=0xffffffffffff;var er;(function(i){i.Base32IncorrectEncoding="B32_ENC_INVALID",i.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",i.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",i.EncodeTimeNegative="ENC_TIME_NEG",i.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",i.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",i.PRNGDetectFailure="PRNG_DETECT",i.ULIDInvalid="ULID_INVALID",i.Unexpected="UNEXPECTED",i.UUIDInvalid="UUID_INVALID"})(er||(er={}));class Ao extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function qv(i){const t=Math.floor(i()*Aa)%Aa;return kg.charAt(t)}function Nv(i){const t=Gv(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const n=new Uint8Array(1);return e.getRandomValues(n),n[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new Ao(er.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Gv(){return Fv()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Uv(i,t){let e="";for(;i>0;i--)e=qv(t)+e;return e}function Hv(i,t=Qg){if(isNaN(i))throw new Ao(er.EncodeTimeValueMalformed,`Time must be a number: ${i}`);if(i>rO)throw new Ao(er.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${rO}: ${i}`);if(i<0)throw new Ao(er.EncodeTimeNegative,`Time must be positive: ${i}`);if(Number.isInteger(i)===!1)throw new Ao(er.EncodeTimeValueMalformed,`Time must be an integer: ${i}`);let e,n="";for(let r=t;r>0;r--)e=i%Aa,n=kg.charAt(e)+n,i=(i-e)/Aa;return n}function Fv(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function $g(i,t){const e=Nv(),n=Date.now();return Hv(n,Qg)+Uv(Yv,e)}function Oa(i){return typeof i=="object"&&i!==null}function Cg(i){return!Oa(i)||i.type!=="content-updated"||typeof i.content!="string"?!1:!("id"in i)}function Pg(i){if(!Oa(i)||i.type!=="response"||typeof i.id!="string")return!1;const t="result"in i&&i.result!==void 0,e="error"in i&&i.error!==void 0;return!(t===e||t&&(!Oa(i.result)||Object.keys(i.result).length!==0)||e&&(!Oa(i.error)||typeof i.error.message!="string"))}const Tg=Dv(),Ag=Wv(Vv);var Nr,Gr,Ur,vn,mi,Rg,Zg,Hh,Xg;class Kv extends Ag{constructor(e=globalThis){super();A(this,mi);A(this,Nr);A(this,Gr);A(this,Ur);A(this,vn,new Map);R(this,Nr,e);const n=e.parent;if(!n||n===e)throw new Error("ArtifactContext: window has no parent");R(this,Gr,n),R(this,Ur,r=>Zt(this,mi,Rg).call(this,r)),w(this,Nr).addEventListener("message",w(this,Ur)),Zt(this,mi,Hh).call(this,{type:"ready"})}updateContent(e){Zt(this,mi,Xg).call(this);const n=$g(),r={type:"update-content",id:n,content:e};return new Promise((s,o)=>{w(this,vn).set(n,{resolve:s,reject:o}),Zt(this,mi,Hh).call(this,r)})}dispose(){w(this,Nr).removeEventListener("message",w(this,Ur));const e=[...w(this,vn).values()];w(this,vn).clear();for(const{reject:n}of e)n(new Error("ArtifactContext disposed"))}}Nr=new WeakMap,Gr=new WeakMap,Ur=new WeakMap,vn=new WeakMap,mi=new WeakSet,Rg=function(e){if(this.disposed||e.source!==w(this,Gr))return;const n=e.data;if(Cg(n)){this.dispatchEvent(new Tg("content-updated",{content:n.content}));return}if(Pg(n)){Zt(this,mi,Zg).call(this,n);return}},Zg=function(e){const n=w(this,vn).get(e.id);if(n){if(w(this,vn).delete(e.id),e.error!==void 0){n.reject(new Error(e.error.message));return}n.resolve()}},Hh=function(e){w(this,Gr).postMessage(e,"*")},Xg=function(){if(this.disposed)throw new Error("ArtifactContext is disposed")};var ml,gl,xn,gi,Eg,Lg,Fh,Mg;class Jv extends Ag{constructor(e=globalThis){super();A(this,gi);A(this,ml);A(this,gl);A(this,xn,new Map);const n=e.__televisionContentBridge;if(!n)throw new Error("WebviewArtifactContext: window has no __televisionContentBridge");R(this,ml,n),R(this,gl,n.onHostMessage(r=>Zt(this,gi,Eg).call(this,r))),Zt(this,gi,Fh).call(this,{type:"ready"})}updateContent(e){Zt(this,gi,Mg).call(this);const n=$g(),r={type:"update-content",id:n,content:e};return new Promise((s,o)=>{w(this,xn).set(n,{resolve:s,reject:o}),Zt(this,gi,Fh).call(this,r)})}dispose(){w(this,gl).call(this);const e=[...w(this,xn).values()];w(this,xn).clear();for(const{reject:n}of e)n(new Error("WebviewArtifactContext disposed"))}}ml=new WeakMap,gl=new WeakMap,xn=new WeakMap,gi=new WeakSet,Eg=function(e){if(!this.disposed){if(Cg(e)){this.dispatchEvent(new Tg("content-updated",{content:e.content}));return}if(Pg(e)){Zt(this,gi,Lg).call(this,e);return}}},Lg=function(e){const n=w(this,xn).get(e.id);if(n){if(w(this,xn).delete(e.id),e.error!==void 0){n.reject(new Error(e.error.message));return}n.resolve()}},Fh=function(e){w(this,ml).postToHost(e)},Mg=function(){if(this.disposed)throw new Error("WebviewArtifactContext is disposed")};function tx(i=window,t={}){const e=i;if(e.__televisionArtifactBridgeInstalled===!0||(e.__televisionArtifactBridgeInstalled=!0,i.parent===i))return;const r=(()=>{const m=Date.now().toString(36);try{const g=i.crypto;if(g&&typeof g.getRandomValues=="function"){const b=new Uint32Array(4);return g.getRandomValues(b),`tvb-${m}-${Array.from(b,S=>S.toString(36)).join("-")}`}}catch{}return`tvb-${m}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`})(),s=()=>{i.parent.postMessage({type:"bridge-ready",url:i.location.href,guid:r},"*")};i.addEventListener("pagehide",()=>{i.parent.postMessage({type:"leaving",guid:r},"*")}),i.addEventListener("pageshow",O=>{O.persisted===!0&&s()});const o=i.location.href;if((O=>{try{const p=new URL(O);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(p.pathname)}catch{return!1}})(o)&&typeof i.fetch=="function"){const m=t.pollCadence,g=m!==void 0&&Number.isFinite(m.normalMs)&&m.normalMs>0&&Number.isFinite(m.slowMs)&&m.slowMs>=m.normalMs?m:null,b=(g==null?void 0:g.normalMs)??5e3,S=(g==null?void 0:g.slowMs)??15e3;let x=null,y=b,k=!1;const Q=()=>{(async()=>{try{const Z=await i.fetch(o,{method:"HEAD"});if(!Z.ok)throw new Error("Artifact poll failed");const D=Z.headers.get("ETag");if(!D)throw new Error("Artifact poll missing ETag");y=b,x===null?x=D:D!==x&&(x=D,i.parent.postMessage({type:"proxy-content-changed"},"*"))}catch{y=Math.min(S,y*2)}finally{k||i.setTimeout(Q,y)}})()};i.addEventListener("pagehide",()=>{k=!0}),Q()}const a=()=>{i.document.documentElement&&(i.document.documentElement.style.touchAction="pan-y",i.document.documentElement.style.overscrollBehaviorX="contain",i.document.documentElement.style.overscrollBehaviorY="contain"),i.document.body&&(i.document.body.style.overscrollBehaviorX="contain",i.document.body.style.overscrollBehaviorY="contain")};if(a(),i.document.body||i.document.addEventListener("DOMContentLoaded",a,{once:!0}),t.reportNavigation!==!1){const O=m=>{i.parent.postMessage({type:"navigation-request",...m},"*")};O({url:i.location.href});const p=i.navigation;if(p)p.addEventListener("navigate",m=>{var k,Q;const g=m,b=(k=g.destination)==null?void 0:k.url;if(typeof b!="string")return;const S=((Q=g.destination)==null?void 0:Q.sameDocument)===!0,x={url:b,...g.navigationType==="replace"?{replace:!0}:{},...S?{sameDocument:!0}:{}};if(S){O(x);return}try{if(new URL(b,i.location.href).origin===i.location.origin){O({...x,native:!0});return}}catch{}g.canIntercept!==!1&&g.preventDefault(),O(x)});else{i.document.addEventListener("click",b=>{var Z;const S=b;if(S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const x=(Z=i.document.defaultView)==null?void 0:Z.Element;if(!x||!(S.target instanceof x))return;const y=S.target.closest("a[href]");if(!y||y.target&&y.target.toLowerCase()!=="_self"||y.hasAttribute("download"))return;const k=y.getAttribute("href");if(!k||k.startsWith("javascript:"))return;let Q;try{Q=new URL(y.href,i.document.baseURI)}catch{return}if(Q.origin===i.location.origin&&Q.pathname===i.location.pathname&&Q.search===i.location.search&&Q.hash!==""){O({url:Q.href,sameDocument:!0});return}S.preventDefault(),O({url:Q.href})},!0);const m=i.history.pushState.bind(i.history),g=i.history.replaceState.bind(i.history);i.history.pushState=function(...S){m(...S),O({url:i.location.href,sameDocument:!0})},i.history.replaceState=function(...S){g(...S),O({url:i.location.href,replace:!0,sameDocument:!0})},i.addEventListener("popstate",()=>{O({url:i.location.href,sameDocument:!0})}),i.addEventListener("hashchange",()=>{O({url:i.location.href,sameDocument:!0})}),i.document.addEventListener("submit",b=>{var Z,D;const S=b,x=S.target,y=(Z=i.document.defaultView)==null?void 0:Z.HTMLFormElement;if(!y||!(x instanceof y)||x.target&&x.target.toLowerCase()!=="_self")return;S.preventDefault();const k=x.method.toLowerCase(),Q=new URL(x.action||i.location.href,i.document.baseURI);if(k==="get"){const L=(D=i.document.defaultView)==null?void 0:D.FormData;if(!L)return;const B=new URLSearchParams;for(const[_,G]of new L(x))typeof G=="string"&&B.append(_,G);Q.search=B.toString()}O({url:Q.href})},!0)}}const c=O=>{var b,S;const p=(b=i.document.defaultView)==null?void 0:b.Element;if(!p||!(O instanceof p))return!1;const g=O.closest("input, textarea, select, [contenteditable], [role='textbox'], [role='searchbox'], [role='combobox'], [role='spinbutton'], [role='slider']");return g?g.hasAttribute("contenteditable")?((S=g.getAttribute("contenteditable"))==null?void 0:S.toLowerCase())!=="false":!0:!1};i.addEventListener("keydown",O=>{const p=O;p.key!=="ArrowLeft"&&p.key!=="ArrowRight"||p.metaKey||p.ctrlKey||p.altKey||p.shiftKey||c(p.target)||(p.preventDefault(),i.parent.postMessage({type:"filmstrip-key",direction:p.key==="ArrowRight"?1:-1},"*"))},{capture:!0}),i.addEventListener("wheel",O=>{const p=O,m=p.shiftKey&&p.deltaX===0&&p.deltaY!==0,g=m?p.deltaY:p.deltaX,b=Math.abs(g),S=m?0:Math.abs(p.deltaY);b<=S||(p.preventDefault(),i.parent.postMessage({type:"wheel",deltaX:g,shiftKey:p.shiftKey},"*"))},{passive:!1});const h=8,u=100,f=1e3,d=new Map;i.addEventListener("pointerdown",O=>{const p=O;p.pointerType==="touch"&&d.set(p.pointerId,{startX:p.clientX,startY:p.clientY,lastX:p.clientX,offset:0,active:!1,discarded:!1,samples:[{time:p.timeStamp,offset:0}]})},{passive:!0}),i.addEventListener("pointermove",O=>{const p=O,m=d.get(p.pointerId);if(!m||m.discarded)return;if(!m.active){const x=p.clientX-m.startX,y=p.clientY-m.startY,k=Math.abs(x),Q=Math.abs(y);if(k<h&&Q<h)return;if(Q>=k){m.discarded=!0;return}m.active=!0}const g=p.clientX-m.lastX;m.lastX=p.clientX,m.offset+=g,m.samples.push({time:p.timeStamp,offset:m.offset});const b=p.timeStamp-u;let S=0;for(let x=0;x<m.samples.length;x+=1){if(m.samples[x].time>=b){S=x;break}S=x+1}if(S>0){const x=Math.max(0,S-1);m.samples.splice(0,x)}i.parent.postMessage({type:"swipe-move",deltaX:g},"*"),p.preventDefault()},{passive:!1}),i.addEventListener("pointerup",O=>{const p=O,m=d.get(p.pointerId);if(!m||(d.delete(p.pointerId),!m.active))return;let g=0;if(m.samples.length>=2){const b=m.samples[0],S=m.samples[m.samples.length-1],x=S.time-b.time;x>0&&(g=(S.offset-b.offset)/x*f)}i.parent.postMessage({type:"swipe-end",velocityX:g},"*")}),i.addEventListener("pointercancel",O=>{const p=O,m=d.get(p.pointerId);m&&(d.delete(p.pointerId),m.active&&i.parent.postMessage({type:"swipe-end",velocityX:0},"*"))}),s()}let Kh=[],zg=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,e=0;t<i.length;t++)(t%2?zg:Kh).push(e=e+i[t])})();function ex(i){if(i<768)return!1;for(let t=0,e=Kh.length;;){let n=t+e>>1;if(i<Kh[n])e=n;else if(i>=zg[n])t=n+1;else return!0;if(t==e)return!1}}function sO(i){return i>=127462&&i<=127487}const oO=8205;function ix(i,t,e=!0,n=!0){return(e?_g:nx)(i,t,n)}function _g(i,t,e){if(t==i.length)return t;t&&Ig(i.charCodeAt(t))&&jg(i.charCodeAt(t-1))&&t--;let n=nh(i,t);for(t+=lO(n);t<i.length;){let r=nh(i,t);if(n==oO||r==oO||e&&ex(r))t+=lO(r),n=r;else if(sO(r)){let s=0,o=t-2;for(;o>=0&&sO(nh(i,o));)s++,o-=2;if(s%2==0)break;t+=2}else break}return t}function nx(i,t,e){for(;t>0;){let n=_g(i,t-2,e);if(n<t)return n;t--}return 0}function nh(i,t){let e=i.charCodeAt(t);if(!jg(e)||t+1==i.length)return e;let n=i.charCodeAt(t+1);return Ig(n)?(e-55296<<10)+(n-56320)+65536:e}function Ig(i){return i>=56320&&i<57344}function jg(i){return i>=55296&&i<56320}function lO(i){return i<65536?1:2}let Y=class Dg{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,n){[t,e]=Bs(this,t,e);let r=[];return this.decompose(0,t,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(e,this.length,r,1),Zi.from(r,this.length-(e-t)+n.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=Bs(this,t,e);let n=[];return this.decompose(t,e,n,0),Zi.from(n,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),n=this.length-this.scanIdentical(t,-1),r=new zo(this),s=new zo(t);for(let o=e,l=e;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=n)return!0}}iter(t=1){return new zo(this,t)}iterRange(t,e=this.length){return new Vg(this,t,e)}iterLines(t,e){let n;if(t==null)n=this.iter();else{e==null&&(e=this.lines+1);let r=this.line(t).from;n=this.iterRange(r,Math.max(r,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new Bg(n)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?Dg.empty:t.length<=32?new jt(t):Zi.from(jt.split(t,[]))}};class jt extends Y{constructor(t,e=rx(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,n,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((e?n:l)>=t)return new sx(r,l,n,o);r=l+1,n++}}decompose(t,e,n,r){let s=t<=0&&e>=this.length?this:new jt(aO(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(r&1){let o=n.pop(),l=pa(s.text,o.text.slice(),0,s.length);if(l.length<=32)n.push(new jt(l,o.length+s.length));else{let a=l.length>>1;n.push(new jt(l.slice(0,a)),new jt(l.slice(a)))}}else n.push(s)}replace(t,e,n){if(!(n instanceof jt))return super.replace(t,e,n);[t,e]=Bs(this,t,e);let r=pa(this.text,pa(n.text,aO(this.text,0,t)),e),s=this.length+n.length-(e-t);return r.length<=32?new jt(r,s):Zi.from(jt.split(r,[]),s)}sliceString(t,e=this.length,n=`
30
30
  `){[t,e]=Bs(this,t,e);let r="";for(let s=0,o=0;s<=e&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>t&&o&&(r+=n),t<a&&e>s&&(r+=l.slice(Math.max(0,t-s),e-s)),s=a+1}return r}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let n=[],r=-1;for(let s of t)n.push(s),r+=s.length+1,n.length==32&&(e.push(new jt(n,r)),n=[],r=-1);return r>-1&&e.push(new jt(n,r)),e}}class Zi extends Y{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let n of t)this.lines+=n.lines}lineInner(t,e,n,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=n+o.lines-1;if((e?a:l)>=t)return o.lineInner(t,e,n,r);r=l+1,n=a+1}}decompose(t,e,n,r){for(let s=0,o=0;o<=e&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(t<=a&&e>=o){let c=r&((o<=t?1:0)|(a>=e?2:0));o>=t&&a<=e&&!c?n.push(l):l.decompose(t-o,e-o,n,c)}o=a+1}}replace(t,e,n){if([t,e]=Bs(this,t,e),n.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(t>=s&&e<=l){let a=o.replace(t-s,e-s,n),c=this.lines-o.lines+a.lines;if(a.lines<c>>4&&a.lines>c>>6){let h=this.children.slice();return h[r]=a,new Zi(h,this.length-(e-t)+n.length)}return super.replace(s,l,a)}s=l+1}return super.replace(t,e,n)}sliceString(t,e=this.length,n=`
31
31
  `){[t,e]=Bs(this,t,e);let r="";for(let s=0,o=0;s<this.children.length&&o<=e;s++){let l=this.children[s],a=o+l.length;o>t&&s&&(r+=n),t<a&&e>o&&(r+=l.sliceString(t-o,e-o,n)),o=a+1}return r}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Zi))return 0;let n=0,[r,s,o,l]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;r+=e,s+=e){if(r==o||s==l)return n;let a=this.children[r],c=t.children[s];if(a!=c)return n+a.scanIdentical(c,e);n+=a.length+1}}static from(t,e=t.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let d of t)n+=d.lines;if(n<32){let d=[];for(let O of t)O.flatten(d);return new jt(d,e)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,l=[],a=0,c=-1,h=[];function u(d){let O;if(d.lines>s&&d instanceof Zi)for(let p of d.children)u(p);else d.lines>o&&(a>o||!a)?(f(),l.push(d)):d instanceof jt&&a&&(O=h[h.length-1])instanceof jt&&d.lines+O.lines<=32?(a+=d.lines,c+=d.length+1,h[h.length-1]=new jt(O.text.concat(d.text),O.length+1+d.length)):(a+d.lines>r&&f(),a+=d.lines,c+=d.length+1,h.push(d))}function f(){a!=0&&(l.push(h.length==1?h[0]:Zi.from(h,c)),c=-1,a=h.length=0)}for(let d of t)u(d);return f(),l.length==1?l[0]:new Zi(l,e)}}Y.empty=new jt([""],0);function rx(i){let t=-1;for(let e of i)t+=e.length+1;return t}function pa(i,t,e=0,n=1e9){for(let r=0,s=0,o=!0;s<i.length&&r<=n;s++){let l=i[s],a=r+l.length;a>=e&&(a>n&&(l=l.slice(0,n-r)),r<e&&(l=l.slice(e-r)),o?(t[t.length-1]+=l,o=!1):t.push(l)),r=a+1}return t}function aO(i,t,e){return pa(i,[""],t,e)}class zo{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof jt?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,l=r instanceof jt?r.text.length:r.children.length;if(o==(e>0?l:0)){if(n==0)return this.done=!0,this.value="",this;e>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(e>0?0:1)){if(this.offsets[n]+=e,t==0)return this.lineBreak=!0,this.value=`
32
- `,this;t--}else if(r instanceof jt){let a=r.text[o+(e<0?-1:0)];if(this.offsets[n]+=e,a.length>Math.max(0,t))return this.value=t==0?a:e>0?a.slice(t):a.slice(0,a.length-t),this;t-=a.length}else{let a=r.children[o+(e<0?-1:0)];t>a.length?(t-=a.length,this.offsets[n]+=e):(e<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(e>0?1:(a instanceof jt?a.text.length:a.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class Vg{constructor(t,e,n){this.value="",this.done=!1,this.cursor=new zo(t,e>n?-1:1),this.pos=e>n?t.length:0,this.from=Math.min(e,n),this.to=Math.max(e,n)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let n=e<0?this.pos-this.from:this.to-this.pos;t>n&&(t=n),n-=t;let{value:r}=this.cursor.next(t);return this.pos+=(r.length+t)*e,this.value=r.length<=n?r:e<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Bg{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:n,value:r}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(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"&&(Y.prototype[Symbol.iterator]=function(){return this.iter()},zo.prototype[Symbol.iterator]=Vg.prototype[Symbol.iterator]=Bg.prototype[Symbol.iterator]=function(){return this});let sx=class{constructor(t,e,n,r){this.from=t,this.to=e,this.number=n,this.text=r}get length(){return this.to-this.from}};function Bs(i,t,e){return t=Math.max(0,Math.min(i.length,t)),[t,Math.max(t,Math.min(i.length,e))]}function ae(i,t,e=!0,n=!0){return ix(i,t,e,n)}function ox(i){return i>=56320&&i<57344}function lx(i){return i>=55296&&i<56320}function ax(i,t){let e=i.charCodeAt(t);if(!lx(e)||t+1==i.length)return e;let n=i.charCodeAt(t+1);return ox(n)?(e-55296<<10)+(n-56320)+65536:e}function cx(i){return i<65536?1:2}const Jh=/\r\n?|\n/;var Oe=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(Oe||(Oe={}));class Ii{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let n=this.sections[e+1];t+=n<0?this.sections[e]:n}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let e=0,n=0,r=0;e<this.sections.length;){let s=this.sections[e++],o=this.sections[e++];o<0?(t(n,r,s),r+=s):r+=o,n+=s}}iterChangedRanges(t,e=!1){tu(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new Ii(t)}composeDesc(t){return this.empty?t:t.empty?this:Wg(this,t)}mapDesc(t,e=!1){return t.empty?this:eu(this,t,e)}mapPos(t,e=-1,n=Oe.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],c=r+l;if(a<0){if(c>t)return s+(t-r);s+=l}else{if(n!=Oe.Simple&&c>=t&&(n==Oe.TrackDel&&r<t&&c>t||n==Oe.TrackBefore&&r<t||n==Oe.TrackAfter&&c>t))return null;if(c>t||c==t&&e<0&&!l)return t==r||e<0?s:s+a;s+=a}r=c}if(t>r)throw new RangeError(`Position ${t} is out of range for changeset of length ${r}`);return s}touchesRange(t,e=t){for(let n=0,r=0;n<this.sections.length&&r<=e;){let s=this.sections[n++],o=this.sections[n++],l=r+s;if(o>=0&&r<=e&&l>=t)return r<t&&l>e?"cover":!0;r=l}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];t+=(t?" ":"")+n+(r>=0?":"+r:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ii(t)}static create(t){return new Ii(t)}}class Lt extends Ii{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return tu(this,(e,n,r,s,o)=>t=t.replace(r,r+(n-e),o),!1),t}mapDesc(t,e=!1){return eu(this,t,e,!0)}invert(t){let e=this.sections.slice(),n=[];for(let r=0,s=0;r<e.length;r+=2){let o=e[r],l=e[r+1];if(l>=0){e[r]=l,e[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(Y.empty);n.push(o?t.slice(s,s+o):Y.empty)}s+=o}return new Lt(e,n)}compose(t){return this.empty?t:t.empty?this:Wg(this,t,!0)}map(t,e=!1){return t.empty?this:eu(this,t,e,!0)}iterChanges(t,e=!1){tu(this,t,e)}get desc(){return Ii.create(this.sections)}filter(t){let e=[],n=[],r=[],s=new No(this);t:for(let o=0,l=0;;){let a=o==t.length?1e9:t[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break t;let h=Math.min(s.len,a-l);oe(r,h,-1);let u=s.ins==-1?-1:s.off==0?s.ins:0;oe(e,h,u),u>0&&kn(n,e,s.text),s.forward(h),l+=h}let c=t[o++];for(;l<c;){if(s.done)break t;let h=Math.min(s.len,c-l);oe(e,h,-1),oe(r,h,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(h),l+=h}}return{changes:new Lt(e,n),filtered:Ii.create(r)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let n=this.sections[e],r=this.sections[e+1];r<0?t.push(n):r==0?t.push([n]):t.push([n].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,n){let r=[],s=[],o=0,l=null;function a(h=!1){if(!h&&!r.length)return;o<e&&oe(r,e-o,-1);let u=new Lt(r,s);l=l?l.compose(u.map(l)):u,r=[],s=[],o=0}function c(h){if(Array.isArray(h))for(let u of h)c(u);else if(h instanceof Lt){if(h.length!=e)throw new RangeError(`Mismatched change set length (got ${h.length}, expected ${e})`);a(),l=l?l.compose(h.map(l)):h}else{let{from:u,to:f=u,insert:d}=h;if(u>f||u<0||f>e)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${e})`);let O=d?typeof d=="string"?Y.of(d.split(n||Jh)):d:Y.empty,p=O.length;if(u==f&&p==0)return;u<o&&a(),u>o&&oe(r,u-o,-1),oe(r,f-u,p),kn(s,r,O),o=f}}return c(t),a(!l),l}static empty(t){return new Lt(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],n=[];for(let r=0;r<t.length;r++){let s=t[r];if(typeof s=="number")e.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)e.push(s[0],0);else{for(;n.length<r;)n.push(Y.empty);n[r]=Y.of(s.slice(1)),e.push(s[0],n[r].length)}}}return new Lt(e,n)}static createSet(t,e){return new Lt(t,e)}}function oe(i,t,e,n=!1){if(t==0&&e<=0)return;let r=i.length-2;r>=0&&e<=0&&e==i[r+1]?i[r]+=t:r>=0&&t==0&&i[r]==0?i[r+1]+=e:n?(i[r]+=t,i[r+1]+=e):i.push(t,e)}function kn(i,t,e){if(e.length==0)return;let n=t.length-2>>1;if(n<i.length)i[i.length-1]=i[i.length-1].append(e);else{for(;i.length<n;)i.push(Y.empty);i.push(e)}}function tu(i,t,e){let n=i.inserted;for(let r=0,s=0,o=0;o<i.sections.length;){let l=i.sections[o++],a=i.sections[o++];if(a<0)r+=l,s+=l;else{let c=r,h=s,u=Y.empty;for(;c+=l,h+=a,a&&n&&(u=u.append(n[o-2>>1])),!(e||o==i.sections.length||i.sections[o+1]<0);)l=i.sections[o++],a=i.sections[o++];t(r,c,s,h,u),r=c,s=h}}}function eu(i,t,e,n=!1){let r=[],s=n?[]:null,o=new No(i),l=new No(t);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let c=Math.min(o.len,l.len);oe(r,c,-1),o.forward(c),l.forward(c)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!e))){let c=l.len;for(oe(r,l.ins,-1);c;){let h=Math.min(o.len,c);o.ins>=0&&a<o.i&&o.len<=h&&(oe(r,0,o.ins),s&&kn(s,r,o.text),a=o.i),o.forward(h),c-=h}l.next()}else if(o.ins>=0){let c=0,h=o.len;for(;h;)if(l.ins==-1){let u=Math.min(h,l.len);c+=u,h-=u,l.forward(u)}else if(l.ins==0&&l.len<h)h-=l.len,l.next();else break;oe(r,c,a<o.i?o.ins:0),s&&a<o.i&&kn(s,r,o.text),a=o.i,o.forward(o.len-h)}else{if(o.done&&l.done)return s?Lt.createSet(r,s):Ii.create(r);throw new Error("Mismatched change set lengths")}}}function Wg(i,t,e=!1){let n=[],r=e?[]:null,s=new No(i),o=new No(t);for(let l=!1;;){if(s.done&&o.done)return r?Lt.createSet(n,r):Ii.create(n);if(s.ins==0)oe(n,s.len,0,l),s.next();else if(o.len==0&&!o.done)oe(n,0,o.ins,l),r&&kn(r,n,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),c=n.length;if(s.ins==-1){let h=o.ins==-1?-1:o.off?0:o.ins;oe(n,a,h,l),r&&h&&kn(r,n,o.text)}else o.ins==-1?(oe(n,s.off?0:s.len,a,l),r&&kn(r,n,s.textBit(a))):(oe(n,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&kn(r,n,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>c),s.forward2(a),o.forward(a)}}}}class No{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?Y.empty:t[e]}textBit(t){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length&&!t?Y.empty:e[n].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class ir{constructor(t,e,n){this.from=t,this.to=e,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 t=this.flags&7;return t==7?null:t}get goalColumn(){let t=this.flags>>6;return t==16777215?void 0:t}map(t,e=-1){let n,r;return this.empty?n=r=t.mapPos(this.from,e):(n=t.mapPos(this.from,1),r=t.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new ir(n,r,this.flags)}extend(t,e=t,n=0){if(t<=this.anchor&&e>=this.anchor)return C.range(t,e,void 0,void 0,n);let r=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return C.range(this.anchor,r,void 0,void 0,n)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&this.goalColumn==t.goalColumn&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return C.range(t.anchor,t.head)}static create(t,e,n){return new ir(t,e,n)}}class C{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:C.create(this.ranges.map(n=>n.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(t.ranges[n],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new C([this.main],0)}addRange(t,e=!0){return C.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let n=this.ranges.slice();return n[e]=t,C.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new C(t.ranges.map(e=>ir.fromJSON(e)),t.main)}static single(t,e=t){return new C([C.range(t,e)],0)}static create(t,e=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<t.length;r++){let s=t[r];if(s.empty?s.from<=n:s.from<n)return C.normalized(t.slice(),e);n=s.to}return new C(t,e)}static cursor(t,e=0,n,r){return ir.create(t,t,(e==0?0:e<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(t,e,n,r,s){let o=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!s&&t!=e&&(s=e<t?1:-1),e<t?ir.create(e,t,48|o):ir.create(t,e,(s?s<0?8:16:0)|o)}static normalized(t,e=0){let n=t[e];t.sort((r,s)=>r.from-s.from),e=t.indexOf(n);for(let r=1;r<t.length;r++){let s=t[r],o=t[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=e&&e--,t.splice(--r,2,s.anchor>s.head?C.range(a,l):C.range(l,a))}}return new C(t,e)}}function Yg(i,t){for(let e of i.ranges)if(e.to>t)throw new RangeError("Selection points outside of document")}let Qf=0;class D{constructor(t,e,n,r,s){this.combine=t,this.compareInput=e,this.compare=n,this.isStatic=r,this.id=Qf++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new D(t.combine||(e=>e),t.compareInput||((e,n)=>e===n),t.compare||(t.combine?(e,n)=>e===n:$f),!!t.static,t.enables)}of(t){return new ma([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new ma(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new ma(t,this,2,e)}from(t,e){return e||(e=n=>n),this.compute([t],n=>e(n.field(t)))}}function $f(i,t){return i==t||i.length==t.length&&i.every((e,n)=>e===t[n])}class ma{constructor(t,e,n,r){this.dependencies=t,this.facet=e,this.type=n,this.value=r,this.id=Qf++}dynamicSlot(t){var e;let n=this.value,r=this.facet.compareInput,s=this.id,o=t[s]>>1,l=this.type==2,a=!1,c=!1,h=[];for(let u of this.dependencies)u=="doc"?a=!0:u=="selection"?c=!0:((e=t[u.id])!==null&&e!==void 0?e:1)&1||h.push(t[u.id]);return{create(u){return u.values[o]=n(u),1},update(u,f){if(a&&f.docChanged||c&&(f.docChanged||f.selection)||iu(u,h)){let d=n(u);if(l?!cO(d,u.values[o],r):!r(d,u.values[o]))return u.values[o]=d,1}return 0},reconfigure:(u,f)=>{let d,O=f.config.address[s];if(O!=null){let p=Za(f,O);if(this.dependencies.every(m=>m instanceof D?f.facet(m)===u.facet(m):m instanceof bi?f.field(m,!1)==u.field(m,!1):!0)||(l?cO(d=n(u),p,r):r(d=n(u),p)))return u.values[o]=p,0}else d=n(u);return u.values[o]=d,1}}}}function cO(i,t,e){if(i.length!=t.length)return!1;for(let n=0;n<i.length;n++)if(!e(i[n],t[n]))return!1;return!0}function iu(i,t){let e=!1;for(let n of t)_o(i,n)&1&&(e=!0);return e}function hx(i,t,e){let n=e.map(a=>i[a.id]),r=e.map(a=>a.type),s=n.filter(a=>!(a&1)),o=i[t.id]>>1;function l(a){let c=[];for(let h=0;h<n.length;h++){let u=Za(a,n[h]);if(r[h]==2)for(let f of u)c.push(f);else c.push(u)}return t.combine(c)}return{create(a){for(let c of n)_o(a,c);return a.values[o]=l(a),1},update(a,c){if(!iu(a,s))return 0;let h=l(a);return t.compare(h,a.values[o])?0:(a.values[o]=h,1)},reconfigure(a,c){let h=iu(a,n),u=c.config.facets[t.id],f=c.facet(t);if(u&&!h&&$f(e,u))return a.values[o]=f,0;let d=l(a);return t.compare(d,f)?(a.values[o]=f,0):(a.values[o]=d,1)}}}const Il=D.define({static:!0});class bi{constructor(t,e,n,r,s){this.id=t,this.createF=e,this.updateF=n,this.compareF=r,this.spec=s,this.provides=void 0}static define(t){let e=new bi(Qf++,t.create,t.update,t.compare||((n,r)=>n===r),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(Il).find(n=>n.field==this);return((e==null?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:n=>(n.values[e]=this.create(n),1),update:(n,r)=>{let s=n.values[e],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[e]=o,1)},reconfigure:(n,r)=>{let s=n.facet(Il),o=r.facet(Il),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(n.values[e]=l.create(n),1):r.config.address[this.id]!=null?(n.values[e]=r.field(this),0):(n.values[e]=this.create(n),1)}}}init(t){return[this,Il.of({field:this,create:t})]}get extension(){return this}}const Fn={lowest:4,low:3,default:2,high:1,highest:0};function wo(i){return t=>new qg(t,i)}const hn={highest:wo(Fn.highest),high:wo(Fn.high),default:wo(Fn.default),low:wo(Fn.low),lowest:wo(Fn.lowest)};class qg{constructor(t,e){this.inner=t,this.prec=e}}class yc{of(t){return new nu(this,t)}reconfigure(t){return yc.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class nu{constructor(t,e){this.compartment=t,this.inner=e}}class Ra{constructor(t,e,n,r,s,o){for(this.base=t,this.compartments=e,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return e==null?t.default:this.staticValues[e>>1]}static resolve(t,e,n){let r=[],s=Object.create(null),o=new Map;for(let f of ux(t,e,o))f instanceof bi?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],c=[];for(let f of r)l[f.id]=c.length<<1,c.push(d=>f.slot(d));let h=n==null?void 0:n.config.facets;for(let f in s){let d=s[f],O=d[0].facet,p=h&&h[f]||[];if(d.every(m=>m.type==0))if(l[O.id]=a.length<<1|1,$f(p,d))a.push(n.facet(O));else{let m=O.combine(d.map(g=>g.value));a.push(n&&O.compare(m,n.facet(O))?n.facet(O):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=c.length<<1,c.push(g=>m.dynamicSlot(g)));l[O.id]=c.length<<1,c.push(m=>hx(m,O,d))}}let u=c.map(f=>f(l));return new Ra(t,o,u,l,a,s)}}function ux(i,t,e){let n=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let c=n[a].indexOf(o);c>-1&&n[a].splice(c,1),o instanceof nu&&e.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let c of o)s(c,l);else if(o instanceof nu){if(e.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=t.get(o.compartment)||o.inner;e.set(o.compartment,c),s(c,l)}else if(o instanceof qg)s(o.inner,o.prec);else if(o instanceof bi)n[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof ma)n[l].push(o),o.facet.extensions&&s(o.facet.extensions,Fn.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,l)}}return s(i,Fn.default),n.reduce((o,l)=>o.concat(l))}function _o(i,t){if(t&1)return 2;let e=t>>1,n=i.status[e];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[e]=4;let r=i.computeSlot(i,i.config.dynamicSlots[e]);return i.status[e]=2|r}function Za(i,t){return t&1?i.config.staticValues[t>>1]:i.values[t>>1]}const Ng=D.define(),ru=D.define({combine:i=>i.some(t=>t),static:!0}),Gg=D.define({combine:i=>i.length?i[0]:void 0,static:!0}),Ug=D.define(),Hg=D.define(),Fg=D.define(),Kg=D.define({combine:i=>i.length?i[0]:!1});class Ke{constructor(t,e){this.type=t,this.value=e}static define(){return new fx}}class fx{of(t){return new Ke(this,t)}}class dx{constructor(t){this.map=t}of(t){return new Ct(this,t)}}class Ct{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return e===void 0?void 0:e==this.value?this:new Ct(this.type,e)}is(t){return this.type==t}static define(t={}){return new dx(t.map||(e=>e))}static mapEffects(t,e){if(!t.length)return t;let n=[];for(let r of t){let s=r.map(e);s&&n.push(s)}return n}}Ct.reconfigure=Ct.define();Ct.appendConfig=Ct.define();class Pt{constructor(t,e,n,r,s,o){this.startState=t,this.changes=e,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&Yg(n,e.newLength),s.some(l=>l.type==Pt.time)||(this.annotations=s.concat(Pt.time.of(Date.now())))}static create(t,e,n,r,s,o){return new Pt(t,e,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(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(Pt.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&e[t.length]=="."))}}Pt.time=Ke.define();Pt.userEvent=Ke.define();Pt.addToHistory=Ke.define();Pt.remote=Ke.define();function Ox(i,t){let e=[];for(let n=0,r=0;;){let s,o;if(n<i.length&&(r==t.length||t[r]>=i[n]))s=i[n++],o=i[n++];else if(r<t.length)s=t[r++],o=t[r++];else return e;!e.length||e[e.length-1]<s?e.push(s,o):e[e.length-1]<o&&(e[e.length-1]=o)}}function Jg(i,t,e){var n;let r,s,o;return e?(r=t.changes,s=Lt.empty(t.changes.length),o=i.changes.compose(t.changes)):(r=t.changes.map(i.changes),s=i.changes.mapDesc(t.changes,!0),o=i.changes.compose(r)),{changes:o,selection:t.selection?t.selection.map(s):(n=i.selection)===null||n===void 0?void 0:n.map(r),effects:Ct.mapEffects(i.effects,r).concat(Ct.mapEffects(t.effects,s)),annotations:i.annotations.length?i.annotations.concat(t.annotations):t.annotations,scrollIntoView:i.scrollIntoView||t.scrollIntoView}}function su(i,t,e){let n=t.selection,r=zr(t.annotations);return t.userEvent&&(r=r.concat(Pt.userEvent.of(t.userEvent))),{changes:t.changes instanceof Lt?t.changes:Lt.of(t.changes||[],e,i.facet(Gg)),selection:n&&(n instanceof C?n:C.single(n.anchor,n.head)),effects:zr(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}function tb(i,t,e){let n=su(i,t.length?t[0]:{},i.doc.length);t.length&&t[0].filter===!1&&(e=!1);for(let s=1;s<t.length;s++){t[s].filter===!1&&(e=!1);let o=!!t[s].sequential;n=Jg(n,su(i,t[s],o?n.changes.newLength:i.doc.length),o)}let r=Pt.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return mx(e?px(r):r)}function px(i){let t=i.startState,e=!0;for(let r of t.facet(Ug)){let s=r(i);if(s===!1){e=!1;break}Array.isArray(s)&&(e=e===!0?s:Ox(e,s))}if(e!==!0){let r,s;if(e===!1)s=i.changes.invertedDesc,r=Lt.empty(t.doc.length);else{let o=i.changes.filter(e);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}i=Pt.create(t,r,i.selection&&i.selection.map(s),Ct.mapEffects(i.effects,s),i.annotations,i.scrollIntoView)}let n=t.facet(Hg);for(let r=n.length-1;r>=0;r--){let s=n[r](i);s instanceof Pt?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Pt?i=s[0]:i=tb(t,zr(s),!1)}return i}function mx(i){let t=i.startState,e=t.facet(Fg),n=i;for(let r=e.length-1;r>=0;r--){let s=e[r](i);s&&Object.keys(s).length&&(n=Jg(n,su(t,s,i.changes.newLength),!0))}return n==i?i:Pt.create(t,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const gx=[];function zr(i){return i==null?gx:Array.isArray(i)?i:[i]}var tn=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(tn||(tn={}));const bx=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ou;try{ou=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function wx(i){if(ou)return ou.test(i);for(let t=0;t<i.length;t++){let e=i[t];if(/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||bx.test(e)))return!0}return!1}function Sx(i){return t=>{if(!/\S/.test(t))return tn.Space;if(wx(t))return tn.Word;for(let e=0;e<i.length;e++)if(t.indexOf(i[e])>-1)return tn.Word;return tn.Other}}class K{constructor(t,e,n,r,s,o){this.config=t,this.doc=e,this.selection=n,this.values=r,this.status=t.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)_o(this,l<<1);this.computeSlot=null}field(t,e=!0){let n=this.config.address[t.id];if(n==null){if(e)throw new RangeError("Field is not present in this state");return}return _o(this,n),Za(this,n)}update(...t){return tb(this,t,!0)}applyTransaction(t){let e=this.config,{base:n,compartments:r}=e;for(let l of t.effects)l.is(yc.reconfigure)?(e&&(r=new Map,e.compartments.forEach((a,c)=>r.set(c,a)),e=null),r.set(l.value.compartment,l.value.extension)):l.is(Ct.reconfigure)?(e=null,n=l.value):l.is(Ct.appendConfig)&&(e=null,n=zr(n).concat(l.value));let s;e?s=t.startState.values.slice():(e=Ra.resolve(n,r,this),s=new K(e,this.doc,this.selection,e.dynamicSlots.map(()=>null),(a,c)=>c.reconfigure(a,this),null).values);let o=t.startState.facet(ru)?t.newSelection:t.newSelection.asSingle();new K(e,t.newDoc,o,s,(l,a)=>a.update(l,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:C.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,n=t(e.ranges[0]),r=this.changes(n.changes),s=[n.range],o=zr(n.effects);for(let l=1;l<e.ranges.length;l++){let a=t(e.ranges[l]),c=this.changes(a.changes),h=c.map(r);for(let f=0;f<l;f++)s[f]=s[f].map(h);let u=r.mapDesc(c,!0);s.push(a.range.map(u)),r=r.compose(h),o=Ct.mapEffects(o,h).concat(Ct.mapEffects(zr(a.effects),u))}return{changes:r,selection:C.create(s,e.mainIndex),effects:o}}changes(t=[]){return t instanceof Lt?t:Lt.of(t,this.doc.length,this.facet(K.lineSeparator))}toText(t){return Y.of(t.split(this.facet(K.lineSeparator)||Jh))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return e==null?t.default:(_o(this,e),Za(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let n in t){let r=t[n];r instanceof bi&&this.config.address[r.id]!=null&&(e[n]=r.spec.toJSON(this.field(t[n]),this))}return e}static fromJSON(t,e={},n){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(t,s)){let o=n[s],l=t[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return K.create({doc:t.doc,selection:C.fromJSON(t.selection),extensions:e.extensions?r.concat([e.extensions]):r})}static create(t={}){let e=Ra.resolve(t.extensions||[],new Map),n=t.doc instanceof Y?t.doc:Y.of((t.doc||"").split(e.staticFacet(K.lineSeparator)||Jh)),r=t.selection?t.selection instanceof C?t.selection:C.single(t.selection.anchor,t.selection.head):C.single(0);return Yg(r,n.length),e.staticFacet(ru)||(r=r.asSingle()),new K(e,n,r,e.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(K.tabSize)}get lineBreak(){return this.facet(K.lineSeparator)||`
33
- `}get readOnly(){return this.facet(Kg)}phrase(t,...e){for(let n of this.facet(K.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>e.length?n:e[s-1]})),t}languageDataAt(t,e,n=-1){let r=[];for(let s of this.facet(Ng))for(let o of s(this,e,n))Object.prototype.hasOwnProperty.call(o,t)&&r.push(o[t]);return r}charCategorizer(t){let e=this.languageDataAt("wordChars",t);return Sx(e.length?e[0]:"")}wordAt(t){let{text:e,from:n,length:r}=this.doc.lineAt(t),s=this.charCategorizer(t),o=t-n,l=t-n;for(;o>0;){let a=ae(e,o,!1);if(s(e.slice(a,o))!=tn.Word)break;o=a}for(;l<r;){let a=ae(e,l);if(s(e.slice(l,a))!=tn.Word)break;l=a}return o==l?null:C.range(o+n,l+n)}}K.allowMultipleSelections=ru;K.tabSize=D.define({combine:i=>i.length?i[0]:4});K.lineSeparator=Gg;K.readOnly=Kg;K.phrases=D.define({compare(i,t){let e=Object.keys(i),n=Object.keys(t);return e.length==n.length&&e.every(r=>i[r]==t[r])}});K.languageData=Ng;K.changeFilter=Ug;K.transactionFilter=Hg;K.transactionExtender=Fg;yc.reconfigure=Ct.define();function eb(i,t,e={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],l=n[s];if(l===void 0)n[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(e,s))n[s]=e[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in t)n[r]===void 0&&(n[r]=t[r]);return n}class Zn{eq(t){return this==t}range(t,e=t){return lu.create(t,e,this)}}Zn.prototype.startSide=Zn.prototype.endSide=0;Zn.prototype.point=!1;Zn.prototype.mapMode=Oe.TrackDel;function Cf(i,t){return i==t||i.constructor==t.constructor&&i.eq(t)}let lu=class ib{constructor(t,e,n){this.from=t,this.to=e,this.value=n}static create(t,e,n){return new ib(t,e,n)}};function au(i,t){return i.from-t.from||i.value.startSide-t.value.startSide}class Pf{constructor(t,e,n,r){this.from=t,this.to=e,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(t,e,n,r=0){let s=n?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,c=s[a]-t||(n?this.value[a].endSide:this.value[a].startSide)-e;if(a==o)return c>=0?o:l;c>=0?l=a:o=a+1}}between(t,e,n,r){for(let s=this.findIndex(e,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(r(this.from[s]+t,this.to[s]+t,this.value[s])===!1)return!1}map(t,e){let n=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let c=this.value[a],h=this.from[a]+t,u=this.to[a]+t,f,d;if(h==u){let O=e.mapPos(h,c.startSide,c.mapMode);if(O==null||(f=d=O,c.startSide!=c.endSide&&(d=e.mapPos(h,c.endSide),d<f)))continue}else if(f=e.mapPos(h,c.startSide),d=e.mapPos(u,c.endSide),f>d||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(o<0&&(o=f),c.point&&(l=Math.max(l,d-f)),n.push(c),r.push(f-o),s.push(d-o))}return{mapped:n.length?new Pf(r,s,n,l):null,pos:o}}}class Ot{constructor(t,e,n,r){this.chunkPos=t,this.chunk=e,this.nextLayer=n,this.maxPoint=r}static create(t,e,n,r){return new Ot(t,e,n,r)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=t,o=t.filter;if(e.length==0&&!o)return this;if(n&&(e=e.slice().sort(au)),this.isEmpty)return e.length?Ot.of(e):this;let l=new nb(this,null,-1).goto(0),a=0,c=[],h=new Ws;for(;l.value||a<e.length;)if(a<e.length&&(l.from-e[a].from||l.startSide-e[a].value.startSide)>=0){let u=e[a++];h.addInner(u.from,u.to,u.value)||c.push(u)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==e.length||this.chunkEnd(l.chunkIndex)<e[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&h.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(h.addInner(l.from,l.to,l.value)||c.push(lu.create(l.from,l.to,l.value))),l.next());return h.finishInner(this.nextLayer.isEmpty&&!c.length?Ot.empty:this.nextLayer.update({add:c,filter:o,filterFrom:r,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],n=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],c=t.touchesRange(l,l+a.length);if(c===!1)r=Math.max(r,a.maxPoint),e.push(a),n.push(t.mapPos(l));else if(c===!0){let{mapped:h,pos:u}=a.map(l,t);h&&(r=Math.max(r,h.maxPoint),e.push(h),n.push(u))}}let s=this.nextLayer.map(t);return e.length==0?s:new Ot(n,e,s||Ot.empty,r)}between(t,e,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(e>=s&&t<=s+o.length&&o.between(s,t-s,e-s,n)===!1)return}this.nextLayer.between(t,e,n)}}iter(t=0){return Go.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Go.from(t).goto(e)}static compare(t,e,n,r,s=-1){let o=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),l=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),a=hO(o,l,n),c=new So(o,a,s),h=new So(l,a,s);n.iterGaps((u,f,d)=>uO(c,u,h,f,d,r)),n.empty&&n.length==0&&uO(c,0,h,0,0,r)}static eq(t,e,n=0,r){r==null&&(r=999999999);let s=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0),o=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=hO(s,o),a=new So(s,l,0).goto(n),c=new So(o,l,0).goto(n);for(;;){if(a.to!=c.to||!cu(a.active,c.active)||a.point&&(!c.point||!Cf(a.point,c.point)))return!1;if(a.to>r)return!0;a.next(),c.next()}}static spans(t,e,n,r,s=-1){let o=new So(t,null,s).goto(e),l=e,a=o.openStart;for(;;){let c=Math.min(o.to,n);if(o.point){let h=o.activeForPoint(o.to),u=o.pointFrom<e?h.length+1:o.point.startSide<0?h.length:Math.min(h.length,a);r.point(l,c,o.point,h,u,o.pointRank),a=Math.min(o.openEnd(c),h.length)}else c>l&&(r.span(l,c,o.active,a),a=o.openEnd(c));if(o.to>n)return a+(o.point&&o.to>n?1:0);l=o.to,o.next()}}static of(t,e=!1){let n=new Ws;for(let r of t instanceof lu?[t]:e?vx(t):t)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return Ot.empty;let e=t[t.length-1];for(let n=t.length-2;n>=0;n--)for(let r=t[n];r!=Ot.empty;r=r.nextLayer)e=new Ot(r.chunkPos,r.chunk,e,Math.max(r.maxPoint,e.maxPoint));return e}}Ot.empty=new Ot([],[],null,-1);function vx(i){if(i.length>1)for(let t=i[0],e=1;e<i.length;e++){let n=i[e];if(au(t,n)>0)return i.slice().sort(au);t=n}return i}Ot.empty.nextLayer=Ot.empty;class Ws{finishChunk(t){this.chunks.push(new Pf(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,t&&(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(t,e,n){this.addInner(t,e,n)||(this.nextLayer||(this.nextLayer=new Ws)).add(t,e,n)}addInner(t,e,n){let r=t-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(t-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=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=n,this.lastFrom=t,this.lastTo=e,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let n=e.value.length-1;return this.last=e.value[n],this.lastFrom=e.from[n]+t,this.lastTo=e.to[n]+t,!0}finish(){return this.finishInner(Ot.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let e=Ot.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function hO(i,t,e){let n=new Map;for(let s of i)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&n.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of t)for(let o=0;o<s.chunk.length;o++){let l=n.get(s.chunk[o]);l!=null&&(e?e.mapPos(l):l)==s.chunkPos[o]&&!(e!=null&&e.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}class nb{constructor(t,e,n,r=0){this.layer=t,this.skip=e,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,n){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<t||r.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],n=t+e.from[this.rangeIndex];if(this.from=n,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Go{constructor(t){this.heap=t}static from(t,e=null,n=-1){let r=[];for(let s=0;s<t.length;s++)for(let o=t[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new nb(o,e,n,s));return r.length==1?r[0]:new Go(r)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let n of this.heap)n.goto(t,e);for(let n=this.heap.length>>1;n>=0;n--)rh(this.heap,n);return this.next(),this}forward(t,e){for(let n of this.heap)n.forward(t,e);for(let n=this.heap.length>>1;n>=0;n--)rh(this.heap,n);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),rh(this.heap,0)}}}function rh(i,t){for(let e=i[t];;){let n=(t<<1)+1;if(n>=i.length)break;let r=i[n];if(n+1<i.length&&r.compare(i[n+1])>=0&&(r=i[n+1],n++),e.compare(r)<0)break;i[n]=e,i[t]=r,t=n}}class So{constructor(t,e,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=Go.from(t,e,n)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){jl(this.active,t),jl(this.activeTo,t),jl(this.activeRank,t),this.minActive=fO(this.active,this.activeTo)}addActive(t){let e=0,{value:n,to:r,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||r-this.activeTo[e])>0;)e++;Dl(this.active,e,n),Dl(this.activeTo,e,r),Dl(this.activeRank,e,s),t&&Dl(t,e,this.cursor.from),this.minActive=fO(this.active,this.activeTo)}next(){let t=this.to,e=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]>t){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&jl(n,r)}else if(this.cursor.value)if(this.cursor.from>t){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(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let r=n.length-1;r>=0&&n[r]<t;r--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>t||this.activeTo[n]==t&&this.active[n].endSide>=this.point.endSide)&&e.push(this.active[n]);return e.reverse()}openEnd(t){let e=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>t;n--)e++;return e}}function uO(i,t,e,n,r,s){i.goto(t),e.goto(n);let o=n+r,l=n,a=n-t,c=!!s.boundChange;for(let h=!1;;){let u=i.to+a-e.to,f=u||i.endSide-e.endSide,d=f<0?i.to+a:e.to,O=Math.min(d,o);if(i.point||e.point?(i.point&&e.point&&Cf(i.point,e.point)&&cu(i.activeForPoint(i.to),e.activeForPoint(e.to))||s.comparePoint(l,O,i.point,e.point),h=!1):(h&&s.boundChange(l),O>l&&!cu(i.active,e.active)&&s.compareRange(l,O,i.active,e.active),c&&O<o&&(u||i.openEnd(d)!=e.openEnd(d))&&(h=!0)),d>o)break;l=d,f<=0&&i.next(),f>=0&&e.next()}}function cu(i,t){if(i.length!=t.length)return!1;for(let e=0;e<i.length;e++)if(i[e]!=t[e]&&!Cf(i[e],t[e]))return!1;return!0}function jl(i,t){for(let e=t,n=i.length-1;e<n;e++)i[e]=i[e+1];i.pop()}function Dl(i,t,e){for(let n=i.length-1;n>=t;n--)i[n+1]=i[n];i[t]=e}function fO(i,t){let e=-1,n=1e9;for(let r=0;r<t.length;r++)(t[r]-n||i[r].endSide-i[e].endSide)<0&&(e=r,n=t[r]);return e}function an(i,t,e=i.length){let n=0;for(let r=0;r<e&&r<i.length;)i.charCodeAt(r)==9?(n+=t-n%t,r++):(n++,r=ae(i,r));return n}function xx(i,t,e,n){for(let r=0,s=0;;){if(s>=t)return r;if(r==i.length)break;s+=i.charCodeAt(r)==9?e-s%e:1,r=ae(i,r)}return i.length}const hu="ͼ",dO=typeof Symbol>"u"?"__"+hu:Symbol.for(hu),uu=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),OO=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Xn{constructor(t,e){this.rules=[];let{finish:n}=e||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,c){let h=[],u=/^@(\w+)\b/.exec(o[0]),f=u&&u[1]=="keyframes";if(u&&l==null)return a.push(o[0]+";");for(let d in l){let O=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(p=>o.map(m=>p.replace(/&/,m))).reduce((p,m)=>p.concat(m)),O,a);else if(O&&typeof O=="object"){if(!u)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),O,h,f)}else O!=null&&h.push(d.replace(/_.*/,"").replace(/[A-Z]/g,p=>"-"+p.toLowerCase())+": "+O+";")}(h.length||f)&&a.push((n&&!u&&!c?o.map(n):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in t)s(r(o),t[o],this.rules)}getRules(){return this.rules.join(`
32
+ `,this;t--}else if(r instanceof jt){let a=r.text[o+(e<0?-1:0)];if(this.offsets[n]+=e,a.length>Math.max(0,t))return this.value=t==0?a:e>0?a.slice(t):a.slice(0,a.length-t),this;t-=a.length}else{let a=r.children[o+(e<0?-1:0)];t>a.length?(t-=a.length,this.offsets[n]+=e):(e<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(e>0?1:(a instanceof jt?a.text.length:a.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class Vg{constructor(t,e,n){this.value="",this.done=!1,this.cursor=new zo(t,e>n?-1:1),this.pos=e>n?t.length:0,this.from=Math.min(e,n),this.to=Math.max(e,n)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let n=e<0?this.pos-this.from:this.to-this.pos;t>n&&(t=n),n-=t;let{value:r}=this.cursor.next(t);return this.pos+=(r.length+t)*e,this.value=r.length<=n?r:e<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Bg{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:n,value:r}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(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"&&(Y.prototype[Symbol.iterator]=function(){return this.iter()},zo.prototype[Symbol.iterator]=Vg.prototype[Symbol.iterator]=Bg.prototype[Symbol.iterator]=function(){return this});let sx=class{constructor(t,e,n,r){this.from=t,this.to=e,this.number=n,this.text=r}get length(){return this.to-this.from}};function Bs(i,t,e){return t=Math.max(0,Math.min(i.length,t)),[t,Math.max(t,Math.min(i.length,e))]}function ae(i,t,e=!0,n=!0){return ix(i,t,e,n)}function ox(i){return i>=56320&&i<57344}function lx(i){return i>=55296&&i<56320}function ax(i,t){let e=i.charCodeAt(t);if(!lx(e)||t+1==i.length)return e;let n=i.charCodeAt(t+1);return ox(n)?(e-55296<<10)+(n-56320)+65536:e}function cx(i){return i<65536?1:2}const Jh=/\r\n?|\n/;var Oe=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(Oe||(Oe={}));class Ii{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let n=this.sections[e+1];t+=n<0?this.sections[e]:n}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let e=0,n=0,r=0;e<this.sections.length;){let s=this.sections[e++],o=this.sections[e++];o<0?(t(n,r,s),r+=s):r+=o,n+=s}}iterChangedRanges(t,e=!1){tu(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new Ii(t)}composeDesc(t){return this.empty?t:t.empty?this:Wg(this,t)}mapDesc(t,e=!1){return t.empty?this:eu(this,t,e)}mapPos(t,e=-1,n=Oe.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],c=r+l;if(a<0){if(c>t)return s+(t-r);s+=l}else{if(n!=Oe.Simple&&c>=t&&(n==Oe.TrackDel&&r<t&&c>t||n==Oe.TrackBefore&&r<t||n==Oe.TrackAfter&&c>t))return null;if(c>t||c==t&&e<0&&!l)return t==r||e<0?s:s+a;s+=a}r=c}if(t>r)throw new RangeError(`Position ${t} is out of range for changeset of length ${r}`);return s}touchesRange(t,e=t){for(let n=0,r=0;n<this.sections.length&&r<=e;){let s=this.sections[n++],o=this.sections[n++],l=r+s;if(o>=0&&r<=e&&l>=t)return r<t&&l>e?"cover":!0;r=l}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];t+=(t?" ":"")+n+(r>=0?":"+r:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ii(t)}static create(t){return new Ii(t)}}class Lt extends Ii{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return tu(this,(e,n,r,s,o)=>t=t.replace(r,r+(n-e),o),!1),t}mapDesc(t,e=!1){return eu(this,t,e,!0)}invert(t){let e=this.sections.slice(),n=[];for(let r=0,s=0;r<e.length;r+=2){let o=e[r],l=e[r+1];if(l>=0){e[r]=l,e[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(Y.empty);n.push(o?t.slice(s,s+o):Y.empty)}s+=o}return new Lt(e,n)}compose(t){return this.empty?t:t.empty?this:Wg(this,t,!0)}map(t,e=!1){return t.empty?this:eu(this,t,e,!0)}iterChanges(t,e=!1){tu(this,t,e)}get desc(){return Ii.create(this.sections)}filter(t){let e=[],n=[],r=[],s=new No(this);t:for(let o=0,l=0;;){let a=o==t.length?1e9:t[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break t;let h=Math.min(s.len,a-l);oe(r,h,-1);let u=s.ins==-1?-1:s.off==0?s.ins:0;oe(e,h,u),u>0&&kn(n,e,s.text),s.forward(h),l+=h}let c=t[o++];for(;l<c;){if(s.done)break t;let h=Math.min(s.len,c-l);oe(e,h,-1),oe(r,h,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(h),l+=h}}return{changes:new Lt(e,n),filtered:Ii.create(r)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let n=this.sections[e],r=this.sections[e+1];r<0?t.push(n):r==0?t.push([n]):t.push([n].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,n){let r=[],s=[],o=0,l=null;function a(h=!1){if(!h&&!r.length)return;o<e&&oe(r,e-o,-1);let u=new Lt(r,s);l=l?l.compose(u.map(l)):u,r=[],s=[],o=0}function c(h){if(Array.isArray(h))for(let u of h)c(u);else if(h instanceof Lt){if(h.length!=e)throw new RangeError(`Mismatched change set length (got ${h.length}, expected ${e})`);a(),l=l?l.compose(h.map(l)):h}else{let{from:u,to:f=u,insert:d}=h;if(u>f||u<0||f>e)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${e})`);let O=d?typeof d=="string"?Y.of(d.split(n||Jh)):d:Y.empty,p=O.length;if(u==f&&p==0)return;u<o&&a(),u>o&&oe(r,u-o,-1),oe(r,f-u,p),kn(s,r,O),o=f}}return c(t),a(!l),l}static empty(t){return new Lt(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],n=[];for(let r=0;r<t.length;r++){let s=t[r];if(typeof s=="number")e.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)e.push(s[0],0);else{for(;n.length<r;)n.push(Y.empty);n[r]=Y.of(s.slice(1)),e.push(s[0],n[r].length)}}}return new Lt(e,n)}static createSet(t,e){return new Lt(t,e)}}function oe(i,t,e,n=!1){if(t==0&&e<=0)return;let r=i.length-2;r>=0&&e<=0&&e==i[r+1]?i[r]+=t:r>=0&&t==0&&i[r]==0?i[r+1]+=e:n?(i[r]+=t,i[r+1]+=e):i.push(t,e)}function kn(i,t,e){if(e.length==0)return;let n=t.length-2>>1;if(n<i.length)i[i.length-1]=i[i.length-1].append(e);else{for(;i.length<n;)i.push(Y.empty);i.push(e)}}function tu(i,t,e){let n=i.inserted;for(let r=0,s=0,o=0;o<i.sections.length;){let l=i.sections[o++],a=i.sections[o++];if(a<0)r+=l,s+=l;else{let c=r,h=s,u=Y.empty;for(;c+=l,h+=a,a&&n&&(u=u.append(n[o-2>>1])),!(e||o==i.sections.length||i.sections[o+1]<0);)l=i.sections[o++],a=i.sections[o++];t(r,c,s,h,u),r=c,s=h}}}function eu(i,t,e,n=!1){let r=[],s=n?[]:null,o=new No(i),l=new No(t);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let c=Math.min(o.len,l.len);oe(r,c,-1),o.forward(c),l.forward(c)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!e))){let c=l.len;for(oe(r,l.ins,-1);c;){let h=Math.min(o.len,c);o.ins>=0&&a<o.i&&o.len<=h&&(oe(r,0,o.ins),s&&kn(s,r,o.text),a=o.i),o.forward(h),c-=h}l.next()}else if(o.ins>=0){let c=0,h=o.len;for(;h;)if(l.ins==-1){let u=Math.min(h,l.len);c+=u,h-=u,l.forward(u)}else if(l.ins==0&&l.len<h)h-=l.len,l.next();else break;oe(r,c,a<o.i?o.ins:0),s&&a<o.i&&kn(s,r,o.text),a=o.i,o.forward(o.len-h)}else{if(o.done&&l.done)return s?Lt.createSet(r,s):Ii.create(r);throw new Error("Mismatched change set lengths")}}}function Wg(i,t,e=!1){let n=[],r=e?[]:null,s=new No(i),o=new No(t);for(let l=!1;;){if(s.done&&o.done)return r?Lt.createSet(n,r):Ii.create(n);if(s.ins==0)oe(n,s.len,0,l),s.next();else if(o.len==0&&!o.done)oe(n,0,o.ins,l),r&&kn(r,n,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),c=n.length;if(s.ins==-1){let h=o.ins==-1?-1:o.off?0:o.ins;oe(n,a,h,l),r&&h&&kn(r,n,o.text)}else o.ins==-1?(oe(n,s.off?0:s.len,a,l),r&&kn(r,n,s.textBit(a))):(oe(n,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&kn(r,n,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>c),s.forward2(a),o.forward(a)}}}}class No{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?Y.empty:t[e]}textBit(t){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length&&!t?Y.empty:e[n].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class ir{constructor(t,e,n){this.from=t,this.to=e,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 t=this.flags&7;return t==7?null:t}get goalColumn(){let t=this.flags>>6;return t==16777215?void 0:t}map(t,e=-1){let n,r;return this.empty?n=r=t.mapPos(this.from,e):(n=t.mapPos(this.from,1),r=t.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new ir(n,r,this.flags)}extend(t,e=t,n=0){if(t<=this.anchor&&e>=this.anchor)return C.range(t,e,void 0,void 0,n);let r=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return C.range(this.anchor,r,void 0,void 0,n)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&this.goalColumn==t.goalColumn&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return C.range(t.anchor,t.head)}static create(t,e,n){return new ir(t,e,n)}}class C{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:C.create(this.ranges.map(n=>n.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(t.ranges[n],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new C([this.main],0)}addRange(t,e=!0){return C.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let n=this.ranges.slice();return n[e]=t,C.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new C(t.ranges.map(e=>ir.fromJSON(e)),t.main)}static single(t,e=t){return new C([C.range(t,e)],0)}static create(t,e=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<t.length;r++){let s=t[r];if(s.empty?s.from<=n:s.from<n)return C.normalized(t.slice(),e);n=s.to}return new C(t,e)}static cursor(t,e=0,n,r){return ir.create(t,t,(e==0?0:e<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(t,e,n,r,s){let o=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!s&&t!=e&&(s=e<t?1:-1),e<t?ir.create(e,t,48|o):ir.create(t,e,(s?s<0?8:16:0)|o)}static normalized(t,e=0){let n=t[e];t.sort((r,s)=>r.from-s.from),e=t.indexOf(n);for(let r=1;r<t.length;r++){let s=t[r],o=t[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=e&&e--,t.splice(--r,2,s.anchor>s.head?C.range(a,l):C.range(l,a))}}return new C(t,e)}}function Yg(i,t){for(let e of i.ranges)if(e.to>t)throw new RangeError("Selection points outside of document")}let Qf=0;class V{constructor(t,e,n,r,s){this.combine=t,this.compareInput=e,this.compare=n,this.isStatic=r,this.id=Qf++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new V(t.combine||(e=>e),t.compareInput||((e,n)=>e===n),t.compare||(t.combine?(e,n)=>e===n:$f),!!t.static,t.enables)}of(t){return new ma([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new ma(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new ma(t,this,2,e)}from(t,e){return e||(e=n=>n),this.compute([t],n=>e(n.field(t)))}}function $f(i,t){return i==t||i.length==t.length&&i.every((e,n)=>e===t[n])}class ma{constructor(t,e,n,r){this.dependencies=t,this.facet=e,this.type=n,this.value=r,this.id=Qf++}dynamicSlot(t){var e;let n=this.value,r=this.facet.compareInput,s=this.id,o=t[s]>>1,l=this.type==2,a=!1,c=!1,h=[];for(let u of this.dependencies)u=="doc"?a=!0:u=="selection"?c=!0:((e=t[u.id])!==null&&e!==void 0?e:1)&1||h.push(t[u.id]);return{create(u){return u.values[o]=n(u),1},update(u,f){if(a&&f.docChanged||c&&(f.docChanged||f.selection)||iu(u,h)){let d=n(u);if(l?!cO(d,u.values[o],r):!r(d,u.values[o]))return u.values[o]=d,1}return 0},reconfigure:(u,f)=>{let d,O=f.config.address[s];if(O!=null){let p=Za(f,O);if(this.dependencies.every(m=>m instanceof V?f.facet(m)===u.facet(m):m instanceof bi?f.field(m,!1)==u.field(m,!1):!0)||(l?cO(d=n(u),p,r):r(d=n(u),p)))return u.values[o]=p,0}else d=n(u);return u.values[o]=d,1}}}}function cO(i,t,e){if(i.length!=t.length)return!1;for(let n=0;n<i.length;n++)if(!e(i[n],t[n]))return!1;return!0}function iu(i,t){let e=!1;for(let n of t)_o(i,n)&1&&(e=!0);return e}function hx(i,t,e){let n=e.map(a=>i[a.id]),r=e.map(a=>a.type),s=n.filter(a=>!(a&1)),o=i[t.id]>>1;function l(a){let c=[];for(let h=0;h<n.length;h++){let u=Za(a,n[h]);if(r[h]==2)for(let f of u)c.push(f);else c.push(u)}return t.combine(c)}return{create(a){for(let c of n)_o(a,c);return a.values[o]=l(a),1},update(a,c){if(!iu(a,s))return 0;let h=l(a);return t.compare(h,a.values[o])?0:(a.values[o]=h,1)},reconfigure(a,c){let h=iu(a,n),u=c.config.facets[t.id],f=c.facet(t);if(u&&!h&&$f(e,u))return a.values[o]=f,0;let d=l(a);return t.compare(d,f)?(a.values[o]=f,0):(a.values[o]=d,1)}}}const Il=V.define({static:!0});class bi{constructor(t,e,n,r,s){this.id=t,this.createF=e,this.updateF=n,this.compareF=r,this.spec=s,this.provides=void 0}static define(t){let e=new bi(Qf++,t.create,t.update,t.compare||((n,r)=>n===r),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(Il).find(n=>n.field==this);return((e==null?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:n=>(n.values[e]=this.create(n),1),update:(n,r)=>{let s=n.values[e],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[e]=o,1)},reconfigure:(n,r)=>{let s=n.facet(Il),o=r.facet(Il),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(n.values[e]=l.create(n),1):r.config.address[this.id]!=null?(n.values[e]=r.field(this),0):(n.values[e]=this.create(n),1)}}}init(t){return[this,Il.of({field:this,create:t})]}get extension(){return this}}const Fn={lowest:4,low:3,default:2,high:1,highest:0};function wo(i){return t=>new qg(t,i)}const hn={highest:wo(Fn.highest),high:wo(Fn.high),default:wo(Fn.default),low:wo(Fn.low),lowest:wo(Fn.lowest)};class qg{constructor(t,e){this.inner=t,this.prec=e}}class yc{of(t){return new nu(this,t)}reconfigure(t){return yc.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class nu{constructor(t,e){this.compartment=t,this.inner=e}}class Ra{constructor(t,e,n,r,s,o){for(this.base=t,this.compartments=e,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return e==null?t.default:this.staticValues[e>>1]}static resolve(t,e,n){let r=[],s=Object.create(null),o=new Map;for(let f of ux(t,e,o))f instanceof bi?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],c=[];for(let f of r)l[f.id]=c.length<<1,c.push(d=>f.slot(d));let h=n==null?void 0:n.config.facets;for(let f in s){let d=s[f],O=d[0].facet,p=h&&h[f]||[];if(d.every(m=>m.type==0))if(l[O.id]=a.length<<1|1,$f(p,d))a.push(n.facet(O));else{let m=O.combine(d.map(g=>g.value));a.push(n&&O.compare(m,n.facet(O))?n.facet(O):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=c.length<<1,c.push(g=>m.dynamicSlot(g)));l[O.id]=c.length<<1,c.push(m=>hx(m,O,d))}}let u=c.map(f=>f(l));return new Ra(t,o,u,l,a,s)}}function ux(i,t,e){let n=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let c=n[a].indexOf(o);c>-1&&n[a].splice(c,1),o instanceof nu&&e.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let c of o)s(c,l);else if(o instanceof nu){if(e.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=t.get(o.compartment)||o.inner;e.set(o.compartment,c),s(c,l)}else if(o instanceof qg)s(o.inner,o.prec);else if(o instanceof bi)n[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof ma)n[l].push(o),o.facet.extensions&&s(o.facet.extensions,Fn.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,l)}}return s(i,Fn.default),n.reduce((o,l)=>o.concat(l))}function _o(i,t){if(t&1)return 2;let e=t>>1,n=i.status[e];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[e]=4;let r=i.computeSlot(i,i.config.dynamicSlots[e]);return i.status[e]=2|r}function Za(i,t){return t&1?i.config.staticValues[t>>1]:i.values[t>>1]}const Ng=V.define(),ru=V.define({combine:i=>i.some(t=>t),static:!0}),Gg=V.define({combine:i=>i.length?i[0]:void 0,static:!0}),Ug=V.define(),Hg=V.define(),Fg=V.define(),Kg=V.define({combine:i=>i.length?i[0]:!1});class Ke{constructor(t,e){this.type=t,this.value=e}static define(){return new fx}}class fx{of(t){return new Ke(this,t)}}class dx{constructor(t){this.map=t}of(t){return new Ct(this,t)}}class Ct{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return e===void 0?void 0:e==this.value?this:new Ct(this.type,e)}is(t){return this.type==t}static define(t={}){return new dx(t.map||(e=>e))}static mapEffects(t,e){if(!t.length)return t;let n=[];for(let r of t){let s=r.map(e);s&&n.push(s)}return n}}Ct.reconfigure=Ct.define();Ct.appendConfig=Ct.define();class Pt{constructor(t,e,n,r,s,o){this.startState=t,this.changes=e,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&Yg(n,e.newLength),s.some(l=>l.type==Pt.time)||(this.annotations=s.concat(Pt.time.of(Date.now())))}static create(t,e,n,r,s,o){return new Pt(t,e,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(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(Pt.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&e[t.length]=="."))}}Pt.time=Ke.define();Pt.userEvent=Ke.define();Pt.addToHistory=Ke.define();Pt.remote=Ke.define();function Ox(i,t){let e=[];for(let n=0,r=0;;){let s,o;if(n<i.length&&(r==t.length||t[r]>=i[n]))s=i[n++],o=i[n++];else if(r<t.length)s=t[r++],o=t[r++];else return e;!e.length||e[e.length-1]<s?e.push(s,o):e[e.length-1]<o&&(e[e.length-1]=o)}}function Jg(i,t,e){var n;let r,s,o;return e?(r=t.changes,s=Lt.empty(t.changes.length),o=i.changes.compose(t.changes)):(r=t.changes.map(i.changes),s=i.changes.mapDesc(t.changes,!0),o=i.changes.compose(r)),{changes:o,selection:t.selection?t.selection.map(s):(n=i.selection)===null||n===void 0?void 0:n.map(r),effects:Ct.mapEffects(i.effects,r).concat(Ct.mapEffects(t.effects,s)),annotations:i.annotations.length?i.annotations.concat(t.annotations):t.annotations,scrollIntoView:i.scrollIntoView||t.scrollIntoView}}function su(i,t,e){let n=t.selection,r=zr(t.annotations);return t.userEvent&&(r=r.concat(Pt.userEvent.of(t.userEvent))),{changes:t.changes instanceof Lt?t.changes:Lt.of(t.changes||[],e,i.facet(Gg)),selection:n&&(n instanceof C?n:C.single(n.anchor,n.head)),effects:zr(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}function tb(i,t,e){let n=su(i,t.length?t[0]:{},i.doc.length);t.length&&t[0].filter===!1&&(e=!1);for(let s=1;s<t.length;s++){t[s].filter===!1&&(e=!1);let o=!!t[s].sequential;n=Jg(n,su(i,t[s],o?n.changes.newLength:i.doc.length),o)}let r=Pt.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return mx(e?px(r):r)}function px(i){let t=i.startState,e=!0;for(let r of t.facet(Ug)){let s=r(i);if(s===!1){e=!1;break}Array.isArray(s)&&(e=e===!0?s:Ox(e,s))}if(e!==!0){let r,s;if(e===!1)s=i.changes.invertedDesc,r=Lt.empty(t.doc.length);else{let o=i.changes.filter(e);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}i=Pt.create(t,r,i.selection&&i.selection.map(s),Ct.mapEffects(i.effects,s),i.annotations,i.scrollIntoView)}let n=t.facet(Hg);for(let r=n.length-1;r>=0;r--){let s=n[r](i);s instanceof Pt?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Pt?i=s[0]:i=tb(t,zr(s),!1)}return i}function mx(i){let t=i.startState,e=t.facet(Fg),n=i;for(let r=e.length-1;r>=0;r--){let s=e[r](i);s&&Object.keys(s).length&&(n=Jg(n,su(t,s,i.changes.newLength),!0))}return n==i?i:Pt.create(t,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const gx=[];function zr(i){return i==null?gx:Array.isArray(i)?i:[i]}var tn=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(tn||(tn={}));const bx=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ou;try{ou=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function wx(i){if(ou)return ou.test(i);for(let t=0;t<i.length;t++){let e=i[t];if(/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||bx.test(e)))return!0}return!1}function Sx(i){return t=>{if(!/\S/.test(t))return tn.Space;if(wx(t))return tn.Word;for(let e=0;e<i.length;e++)if(t.indexOf(i[e])>-1)return tn.Word;return tn.Other}}class K{constructor(t,e,n,r,s,o){this.config=t,this.doc=e,this.selection=n,this.values=r,this.status=t.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)_o(this,l<<1);this.computeSlot=null}field(t,e=!0){let n=this.config.address[t.id];if(n==null){if(e)throw new RangeError("Field is not present in this state");return}return _o(this,n),Za(this,n)}update(...t){return tb(this,t,!0)}applyTransaction(t){let e=this.config,{base:n,compartments:r}=e;for(let l of t.effects)l.is(yc.reconfigure)?(e&&(r=new Map,e.compartments.forEach((a,c)=>r.set(c,a)),e=null),r.set(l.value.compartment,l.value.extension)):l.is(Ct.reconfigure)?(e=null,n=l.value):l.is(Ct.appendConfig)&&(e=null,n=zr(n).concat(l.value));let s;e?s=t.startState.values.slice():(e=Ra.resolve(n,r,this),s=new K(e,this.doc,this.selection,e.dynamicSlots.map(()=>null),(a,c)=>c.reconfigure(a,this),null).values);let o=t.startState.facet(ru)?t.newSelection:t.newSelection.asSingle();new K(e,t.newDoc,o,s,(l,a)=>a.update(l,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:C.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,n=t(e.ranges[0]),r=this.changes(n.changes),s=[n.range],o=zr(n.effects);for(let l=1;l<e.ranges.length;l++){let a=t(e.ranges[l]),c=this.changes(a.changes),h=c.map(r);for(let f=0;f<l;f++)s[f]=s[f].map(h);let u=r.mapDesc(c,!0);s.push(a.range.map(u)),r=r.compose(h),o=Ct.mapEffects(o,h).concat(Ct.mapEffects(zr(a.effects),u))}return{changes:r,selection:C.create(s,e.mainIndex),effects:o}}changes(t=[]){return t instanceof Lt?t:Lt.of(t,this.doc.length,this.facet(K.lineSeparator))}toText(t){return Y.of(t.split(this.facet(K.lineSeparator)||Jh))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return e==null?t.default:(_o(this,e),Za(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let n in t){let r=t[n];r instanceof bi&&this.config.address[r.id]!=null&&(e[n]=r.spec.toJSON(this.field(t[n]),this))}return e}static fromJSON(t,e={},n){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(t,s)){let o=n[s],l=t[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return K.create({doc:t.doc,selection:C.fromJSON(t.selection),extensions:e.extensions?r.concat([e.extensions]):r})}static create(t={}){let e=Ra.resolve(t.extensions||[],new Map),n=t.doc instanceof Y?t.doc:Y.of((t.doc||"").split(e.staticFacet(K.lineSeparator)||Jh)),r=t.selection?t.selection instanceof C?t.selection:C.single(t.selection.anchor,t.selection.head):C.single(0);return Yg(r,n.length),e.staticFacet(ru)||(r=r.asSingle()),new K(e,n,r,e.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(K.tabSize)}get lineBreak(){return this.facet(K.lineSeparator)||`
33
+ `}get readOnly(){return this.facet(Kg)}phrase(t,...e){for(let n of this.facet(K.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>e.length?n:e[s-1]})),t}languageDataAt(t,e,n=-1){let r=[];for(let s of this.facet(Ng))for(let o of s(this,e,n))Object.prototype.hasOwnProperty.call(o,t)&&r.push(o[t]);return r}charCategorizer(t){let e=this.languageDataAt("wordChars",t);return Sx(e.length?e[0]:"")}wordAt(t){let{text:e,from:n,length:r}=this.doc.lineAt(t),s=this.charCategorizer(t),o=t-n,l=t-n;for(;o>0;){let a=ae(e,o,!1);if(s(e.slice(a,o))!=tn.Word)break;o=a}for(;l<r;){let a=ae(e,l);if(s(e.slice(l,a))!=tn.Word)break;l=a}return o==l?null:C.range(o+n,l+n)}}K.allowMultipleSelections=ru;K.tabSize=V.define({combine:i=>i.length?i[0]:4});K.lineSeparator=Gg;K.readOnly=Kg;K.phrases=V.define({compare(i,t){let e=Object.keys(i),n=Object.keys(t);return e.length==n.length&&e.every(r=>i[r]==t[r])}});K.languageData=Ng;K.changeFilter=Ug;K.transactionFilter=Hg;K.transactionExtender=Fg;yc.reconfigure=Ct.define();function eb(i,t,e={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],l=n[s];if(l===void 0)n[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(e,s))n[s]=e[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in t)n[r]===void 0&&(n[r]=t[r]);return n}class Zn{eq(t){return this==t}range(t,e=t){return lu.create(t,e,this)}}Zn.prototype.startSide=Zn.prototype.endSide=0;Zn.prototype.point=!1;Zn.prototype.mapMode=Oe.TrackDel;function Cf(i,t){return i==t||i.constructor==t.constructor&&i.eq(t)}let lu=class ib{constructor(t,e,n){this.from=t,this.to=e,this.value=n}static create(t,e,n){return new ib(t,e,n)}};function au(i,t){return i.from-t.from||i.value.startSide-t.value.startSide}class Pf{constructor(t,e,n,r){this.from=t,this.to=e,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(t,e,n,r=0){let s=n?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,c=s[a]-t||(n?this.value[a].endSide:this.value[a].startSide)-e;if(a==o)return c>=0?o:l;c>=0?l=a:o=a+1}}between(t,e,n,r){for(let s=this.findIndex(e,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(r(this.from[s]+t,this.to[s]+t,this.value[s])===!1)return!1}map(t,e){let n=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let c=this.value[a],h=this.from[a]+t,u=this.to[a]+t,f,d;if(h==u){let O=e.mapPos(h,c.startSide,c.mapMode);if(O==null||(f=d=O,c.startSide!=c.endSide&&(d=e.mapPos(h,c.endSide),d<f)))continue}else if(f=e.mapPos(h,c.startSide),d=e.mapPos(u,c.endSide),f>d||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(o<0&&(o=f),c.point&&(l=Math.max(l,d-f)),n.push(c),r.push(f-o),s.push(d-o))}return{mapped:n.length?new Pf(r,s,n,l):null,pos:o}}}class Ot{constructor(t,e,n,r){this.chunkPos=t,this.chunk=e,this.nextLayer=n,this.maxPoint=r}static create(t,e,n,r){return new Ot(t,e,n,r)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=t,o=t.filter;if(e.length==0&&!o)return this;if(n&&(e=e.slice().sort(au)),this.isEmpty)return e.length?Ot.of(e):this;let l=new nb(this,null,-1).goto(0),a=0,c=[],h=new Ws;for(;l.value||a<e.length;)if(a<e.length&&(l.from-e[a].from||l.startSide-e[a].value.startSide)>=0){let u=e[a++];h.addInner(u.from,u.to,u.value)||c.push(u)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==e.length||this.chunkEnd(l.chunkIndex)<e[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&h.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(h.addInner(l.from,l.to,l.value)||c.push(lu.create(l.from,l.to,l.value))),l.next());return h.finishInner(this.nextLayer.isEmpty&&!c.length?Ot.empty:this.nextLayer.update({add:c,filter:o,filterFrom:r,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],n=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],c=t.touchesRange(l,l+a.length);if(c===!1)r=Math.max(r,a.maxPoint),e.push(a),n.push(t.mapPos(l));else if(c===!0){let{mapped:h,pos:u}=a.map(l,t);h&&(r=Math.max(r,h.maxPoint),e.push(h),n.push(u))}}let s=this.nextLayer.map(t);return e.length==0?s:new Ot(n,e,s||Ot.empty,r)}between(t,e,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(e>=s&&t<=s+o.length&&o.between(s,t-s,e-s,n)===!1)return}this.nextLayer.between(t,e,n)}}iter(t=0){return Go.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Go.from(t).goto(e)}static compare(t,e,n,r,s=-1){let o=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),l=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),a=hO(o,l,n),c=new So(o,a,s),h=new So(l,a,s);n.iterGaps((u,f,d)=>uO(c,u,h,f,d,r)),n.empty&&n.length==0&&uO(c,0,h,0,0,r)}static eq(t,e,n=0,r){r==null&&(r=999999999);let s=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0),o=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=hO(s,o),a=new So(s,l,0).goto(n),c=new So(o,l,0).goto(n);for(;;){if(a.to!=c.to||!cu(a.active,c.active)||a.point&&(!c.point||!Cf(a.point,c.point)))return!1;if(a.to>r)return!0;a.next(),c.next()}}static spans(t,e,n,r,s=-1){let o=new So(t,null,s).goto(e),l=e,a=o.openStart;for(;;){let c=Math.min(o.to,n);if(o.point){let h=o.activeForPoint(o.to),u=o.pointFrom<e?h.length+1:o.point.startSide<0?h.length:Math.min(h.length,a);r.point(l,c,o.point,h,u,o.pointRank),a=Math.min(o.openEnd(c),h.length)}else c>l&&(r.span(l,c,o.active,a),a=o.openEnd(c));if(o.to>n)return a+(o.point&&o.to>n?1:0);l=o.to,o.next()}}static of(t,e=!1){let n=new Ws;for(let r of t instanceof lu?[t]:e?vx(t):t)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return Ot.empty;let e=t[t.length-1];for(let n=t.length-2;n>=0;n--)for(let r=t[n];r!=Ot.empty;r=r.nextLayer)e=new Ot(r.chunkPos,r.chunk,e,Math.max(r.maxPoint,e.maxPoint));return e}}Ot.empty=new Ot([],[],null,-1);function vx(i){if(i.length>1)for(let t=i[0],e=1;e<i.length;e++){let n=i[e];if(au(t,n)>0)return i.slice().sort(au);t=n}return i}Ot.empty.nextLayer=Ot.empty;class Ws{finishChunk(t){this.chunks.push(new Pf(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,t&&(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(t,e,n){this.addInner(t,e,n)||(this.nextLayer||(this.nextLayer=new Ws)).add(t,e,n)}addInner(t,e,n){let r=t-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(t-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=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=n,this.lastFrom=t,this.lastTo=e,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let n=e.value.length-1;return this.last=e.value[n],this.lastFrom=e.from[n]+t,this.lastTo=e.to[n]+t,!0}finish(){return this.finishInner(Ot.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let e=Ot.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function hO(i,t,e){let n=new Map;for(let s of i)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&n.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of t)for(let o=0;o<s.chunk.length;o++){let l=n.get(s.chunk[o]);l!=null&&(e?e.mapPos(l):l)==s.chunkPos[o]&&!(e!=null&&e.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}class nb{constructor(t,e,n,r=0){this.layer=t,this.skip=e,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,n){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<t||r.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],n=t+e.from[this.rangeIndex];if(this.from=n,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Go{constructor(t){this.heap=t}static from(t,e=null,n=-1){let r=[];for(let s=0;s<t.length;s++)for(let o=t[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new nb(o,e,n,s));return r.length==1?r[0]:new Go(r)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let n of this.heap)n.goto(t,e);for(let n=this.heap.length>>1;n>=0;n--)rh(this.heap,n);return this.next(),this}forward(t,e){for(let n of this.heap)n.forward(t,e);for(let n=this.heap.length>>1;n>=0;n--)rh(this.heap,n);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),rh(this.heap,0)}}}function rh(i,t){for(let e=i[t];;){let n=(t<<1)+1;if(n>=i.length)break;let r=i[n];if(n+1<i.length&&r.compare(i[n+1])>=0&&(r=i[n+1],n++),e.compare(r)<0)break;i[n]=e,i[t]=r,t=n}}class So{constructor(t,e,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=Go.from(t,e,n)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){jl(this.active,t),jl(this.activeTo,t),jl(this.activeRank,t),this.minActive=fO(this.active,this.activeTo)}addActive(t){let e=0,{value:n,to:r,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||r-this.activeTo[e])>0;)e++;Dl(this.active,e,n),Dl(this.activeTo,e,r),Dl(this.activeRank,e,s),t&&Dl(t,e,this.cursor.from),this.minActive=fO(this.active,this.activeTo)}next(){let t=this.to,e=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]>t){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&jl(n,r)}else if(this.cursor.value)if(this.cursor.from>t){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(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let r=n.length-1;r>=0&&n[r]<t;r--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>t||this.activeTo[n]==t&&this.active[n].endSide>=this.point.endSide)&&e.push(this.active[n]);return e.reverse()}openEnd(t){let e=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>t;n--)e++;return e}}function uO(i,t,e,n,r,s){i.goto(t),e.goto(n);let o=n+r,l=n,a=n-t,c=!!s.boundChange;for(let h=!1;;){let u=i.to+a-e.to,f=u||i.endSide-e.endSide,d=f<0?i.to+a:e.to,O=Math.min(d,o);if(i.point||e.point?(i.point&&e.point&&Cf(i.point,e.point)&&cu(i.activeForPoint(i.to),e.activeForPoint(e.to))||s.comparePoint(l,O,i.point,e.point),h=!1):(h&&s.boundChange(l),O>l&&!cu(i.active,e.active)&&s.compareRange(l,O,i.active,e.active),c&&O<o&&(u||i.openEnd(d)!=e.openEnd(d))&&(h=!0)),d>o)break;l=d,f<=0&&i.next(),f>=0&&e.next()}}function cu(i,t){if(i.length!=t.length)return!1;for(let e=0;e<i.length;e++)if(i[e]!=t[e]&&!Cf(i[e],t[e]))return!1;return!0}function jl(i,t){for(let e=t,n=i.length-1;e<n;e++)i[e]=i[e+1];i.pop()}function Dl(i,t,e){for(let n=i.length-1;n>=t;n--)i[n+1]=i[n];i[t]=e}function fO(i,t){let e=-1,n=1e9;for(let r=0;r<t.length;r++)(t[r]-n||i[r].endSide-i[e].endSide)<0&&(e=r,n=t[r]);return e}function an(i,t,e=i.length){let n=0;for(let r=0;r<e&&r<i.length;)i.charCodeAt(r)==9?(n+=t-n%t,r++):(n++,r=ae(i,r));return n}function xx(i,t,e,n){for(let r=0,s=0;;){if(s>=t)return r;if(r==i.length)break;s+=i.charCodeAt(r)==9?e-s%e:1,r=ae(i,r)}return i.length}const hu="ͼ",dO=typeof Symbol>"u"?"__"+hu:Symbol.for(hu),uu=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),OO=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Xn{constructor(t,e){this.rules=[];let{finish:n}=e||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,c){let h=[],u=/^@(\w+)\b/.exec(o[0]),f=u&&u[1]=="keyframes";if(u&&l==null)return a.push(o[0]+";");for(let d in l){let O=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(p=>o.map(m=>p.replace(/&/,m))).reduce((p,m)=>p.concat(m)),O,a);else if(O&&typeof O=="object"){if(!u)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),O,h,f)}else O!=null&&h.push(d.replace(/_.*/,"").replace(/[A-Z]/g,p=>"-"+p.toLowerCase())+": "+O+";")}(h.length||f)&&a.push((n&&!u&&!c?o.map(n):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in t)s(r(o),t[o],this.rules)}getRules(){return this.rules.join(`
34
34
  `)}static newName(){let t=OO[dO]||1;return OO[dO]=t+1,hu+t.toString(36)}static mount(t,e,n){let r=t[uu],s=n&&n.nonce;r?s&&r.setNonce(s):r=new yx(t,s),r.mount(Array.isArray(e)?e:[e],t)}}let pO=new Map;class yx{constructor(t,e){let n=t.ownerDocument||t,r=n.defaultView;if(!t.head&&t.adoptedStyleSheets&&r.CSSStyleSheet){let s=pO.get(n);if(s)return t[uu]=s;this.sheet=new r.CSSStyleSheet,pO.set(n,this)}else this.styleTag=n.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[uu]=this}mount(t,e){let n=this.sheet,r=0,s=0;for(let o=0;o<t.length;o++){let l=t[o],a=this.modules.indexOf(l);if(a<s&&a>-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),n)for(let c=0;c<l.rules.length;c++)n.insertRule(l.rules[c],r++)}else{for(;s<a;)r+=this.modules[s++].rules.length;r+=l.rules.length,s++}}if(n)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
35
- `;this.styleTag.textContent=o;let l=e.head||e;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}var En={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Uo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},kx=typeof navigator<"u"&&/Mac/.test(navigator.platform),Qx=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ee=0;ee<10;ee++)En[48+ee]=En[96+ee]=String(ee);for(var ee=1;ee<=24;ee++)En[ee+111]="F"+ee;for(var ee=65;ee<=90;ee++)En[ee]=String.fromCharCode(ee+32),Uo[ee]=String.fromCharCode(ee);for(var sh in En)Uo.hasOwnProperty(sh)||(Uo[sh]=En[sh]);function $x(i){var t=kx&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||Qx&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",e=!t&&i.key||(i.shiftKey?Uo:En)[i.keyCode]||i.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}let de=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},fu=typeof document<"u"?document:{documentElement:{style:{}}};const du=/Edge\/(\d+)/.exec(de.userAgent),rb=/MSIE \d/.test(de.userAgent),Ou=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(de.userAgent),kc=!!(rb||Ou||du),mO=!kc&&/gecko\/(\d+)/i.test(de.userAgent),oh=!kc&&/Chrome\/(\d+)/.exec(de.userAgent),gO="webkitFontSmoothing"in fu.documentElement.style,pu=!kc&&/Apple Computer/.test(de.vendor),bO=pu&&(/Mobile\/\w+/.test(de.userAgent)||de.maxTouchPoints>2);var M={mac:bO||/Mac/.test(de.platform),windows:/Win/.test(de.platform),linux:/Linux|X11/.test(de.platform),ie:kc,ie_version:rb?fu.documentMode||6:Ou?+Ou[1]:du?+du[1]:0,gecko:mO,gecko_version:mO?+(/Firefox\/(\d+)/.exec(de.userAgent)||[0,0])[1]:0,chrome:!!oh,chrome_version:oh?+oh[1]:0,ios:bO,android:/Android\b/.test(de.userAgent),webkit:gO,webkit_version:gO?+(/\bAppleWebKit\/(\d+)/.exec(de.userAgent)||[0,0])[1]:0,safari:pu,safari_version:pu?+(/\bVersion\/(\d+(\.\d+)?)/.exec(de.userAgent)||[0,0])[1]:0,tabSize:fu.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Tf(i,t){for(let e in i)e=="class"&&t.class?t.class+=" "+i.class:e=="style"&&t.style?t.style+=";"+i.style:t[e]=i[e];return t}const Xa=Object.create(null);function Af(i,t,e){if(i==t)return!0;i||(i=Xa),t||(t=Xa);let n=Object.keys(i),r=Object.keys(t);if(n.length-0!=r.length-0)return!1;for(let s of n)if(s!=e&&(r.indexOf(s)==-1||i[s]!==t[s]))return!1;return!0}function Cx(i,t){for(let e=i.attributes.length-1;e>=0;e--){let n=i.attributes[e].name;t[n]==null&&i.removeAttribute(n)}for(let e in t){let n=t[e];e=="style"?i.style.cssText=n:i.getAttribute(e)!=n&&i.setAttribute(e,n)}}function wO(i,t,e){let n=!1;if(t)for(let r in t)e&&r in e||(n=!0,r=="style"?i.style.cssText="":i.removeAttribute(r));if(e)for(let r in e)t&&t[r]==e[r]||(n=!0,r=="style"?i.style.cssText=e[r]:i.setAttribute(r,e[r]));return n}function Px(i){let t=Object.create(null);for(let e=0;e<i.attributes.length;e++){let n=i.attributes[e];t[n.name]=n.value}return t}class jn{eq(t){return!1}updateDOM(t,e,n){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var pe=function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i}(pe||(pe={}));class J extends Zn{constructor(t,e,n,r){super(),this.startSide=t,this.endSide=e,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(t){return new xl(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),n=!!t.block;return e+=n&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new wr(t,e,e,n,t.widget||null,!1)}static replace(t){let e=!!t.block,n,r;if(t.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:o}=sb(t,e);n=(s?e?-3e8:-1:5e8)-1,r=(o?e?2e8:1:-6e8)+1}return new wr(t,n,r,e,t.widget||null,!0)}static line(t){return new yl(t)}static set(t,e=!1){return Ot.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}J.none=Ot.empty;class xl extends J{constructor(t){let{start:e,end:n}=sb(t);super(e?-1:5e8,n?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?Tf(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||Xa}eq(t){return this==t||t instanceof xl&&this.tagName==t.tagName&&Af(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}xl.prototype.point=!1;class yl extends J{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof yl&&this.spec.class==t.spec.class&&Af(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}yl.prototype.mapMode=Oe.TrackBefore;yl.prototype.point=!0;class wr extends J{constructor(t,e,n,r,s,o){super(e,n,s,t),this.block=r,this.isReplace=o,this.mapMode=r?e<=0?Oe.TrackBefore:Oe.TrackAfter:Oe.TrackDel}get type(){return this.startSide!=this.endSide?pe.WidgetRange:this.startSide<=0?pe.WidgetBefore:pe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof wr&&Tx(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}wr.prototype.point=!0;function sb(i,t=!1){let{inclusiveStart:e,inclusiveEnd:n}=i;return e==null&&(e=i.inclusive),n==null&&(n=i.inclusive),{start:e??t,end:n??t}}function Tx(i,t){return i==t||!!(i&&t&&i.compare(t))}function _r(i,t,e,n=0){let r=e.length-1;r>=0&&e[r]+n>=i?e[r]=Math.max(e[r],t):e.push(i,t)}class Ho extends Zn{constructor(t,e,n){super(),this.tagName=t,this.attributes=e,this.rank=n}eq(t){return t==this||t instanceof Ho&&this.tagName==t.tagName&&Af(this.attributes,t.attributes)}static create(t){return new Ho(t.tagName,t.attributes||Xa,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(t,e=!1){return Ot.of(t,e)}}Ho.prototype.startSide=Ho.prototype.endSide=-1;function Fo(i){let t;return i.nodeType==11?t=i.getSelection?i:i.ownerDocument:t=i,t.getSelection()}function mu(i,t){return t?i==t||i.contains(t.nodeType!=1?t.parentNode:t):!1}function Io(i,t){if(!t.anchorNode)return!1;try{return mu(i,t.anchorNode)}catch{return!1}}function ga(i){return i.nodeType==3?Ko(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function jo(i,t,e,n){return e?SO(i,t,e,n,-1)||SO(i,t,e,n,1):!1}function Ln(i){for(var t=0;;t++)if(i=i.previousSibling,!i)return t}function Ea(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function SO(i,t,e,n,r){for(;;){if(i==e&&t==n)return!0;if(t==(r<0?0:cn(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;t=Ln(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[t+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;t=r<0?cn(i):0}else return!1}}function cn(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function La(i,t){let e=t?i.left:i.right;return{left:e,right:e,top:i.top,bottom:i.bottom}}function Ax(i){let t=i.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function ob(i,t){let e=t.width/i.offsetWidth,n=t.height/i.offsetHeight;return(e>.995&&e<1.005||!isFinite(e)||Math.abs(t.width-i.offsetWidth)<1)&&(e=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.height-i.offsetHeight)<1)&&(n=1),{scaleX:e,scaleY:n}}function Rx(i,t,e,n,r,s,o,l){let a=i.ownerDocument,c=a.defaultView||window;for(let h=i,u=!1;h&&!u;)if(h.nodeType==1){let f,d=h==a.body,O=1,p=1;if(d)f=Ax(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let b=h.getBoundingClientRect();({scaleX:O,scaleY:p}=ob(h,b)),f={left:b.left,right:b.left+h.clientWidth*O,top:b.top,bottom:b.top+h.clientHeight*p}}let m=0,g=0;if(r=="nearest")t.top<f.top+o?(g=t.top-(f.top+o),e>0&&t.bottom>f.bottom+g&&(g=t.bottom-f.bottom+o)):t.bottom>f.bottom-o&&(g=t.bottom-f.bottom+o,e<0&&t.top-g<f.top&&(g=t.top-(f.top+o)));else{let b=t.bottom-t.top,S=f.bottom-f.top;g=(r=="center"&&b<=S?t.top+b/2-S/2:r=="start"||r=="center"&&e<0?t.top-o:t.bottom-S+o)-f.top}if(n=="nearest"?t.left<f.left+s?(m=t.left-(f.left+s),e>0&&t.right>f.right+m&&(m=t.right-f.right+s)):t.right>f.right-s&&(m=t.right-f.right+s,e<0&&t.left<f.left+m&&(m=t.left-(f.left+s))):m=(n=="center"?t.left+(t.right-t.left)/2-(f.right-f.left)/2:n=="start"==l?t.left-s:t.right-(f.right-f.left)+s)-f.left,m||g)if(d)c.scrollBy(m,g);else{let b=0,S=0;if(g){let x=h.scrollTop;h.scrollTop+=g/p,S=(h.scrollTop-x)*p}if(m){let x=h.scrollLeft;h.scrollLeft+=m/O,b=(h.scrollLeft-x)*O}t={left:t.left-b,top:t.top-S,right:t.right-b,bottom:t.bottom-S},b&&Math.abs(b-m)<1&&(n="nearest"),S&&Math.abs(S-g)<1&&(r="nearest")}if(d)break;(t.top<f.top||t.bottom>f.bottom||t.left<f.left||t.right>f.right)&&(t={left:Math.max(t.left,f.left),right:Math.min(t.right,f.right),top:Math.max(t.top,f.top),bottom:Math.min(t.bottom,f.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function lb(i,t=!0){let e=i.ownerDocument,n=null,r=null;for(let s=i.parentNode;s&&!(s==e.body||(!t||n)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),t&&!n&&s.scrollWidth>s.clientWidth&&(n=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:n,y:r}}class Zx{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:n}=t;this.set(e,Math.min(t.anchorOffset,e?cn(e):0),n,Math.min(t.focusOffset,n?cn(n):0))}set(t,e,n,r){this.anchorNode=t,this.anchorOffset=e,this.focusNode=n,this.focusOffset=r}}let Hn=null;M.safari&&M.safari_version>=26&&(Hn=!1);function ab(i){if(i.setActive)return i.setActive();if(Hn)return i.focus(Hn);let t=[];for(let e=i;e&&(t.push(e,e.scrollTop,e.scrollLeft),e!=e.ownerDocument);e=e.parentNode);if(i.focus(Hn==null?{get preventScroll(){return Hn={preventScroll:!0},!0}}:void 0),!Hn){Hn=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],s=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=s&&(n.scrollLeft=s)}}}let vO;function Ko(i,t,e=t){let n=vO||(vO=document.createRange());return n.setEnd(i,e),n.setStart(i,t),n}function Ir(i,t,e,n){let r={key:t,code:t,keyCode:e,which:e,cancelable:!0};n&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=n);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,i.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,i.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Xx(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function Ex(i,t){let e=t.focusNode,n=t.focusOffset;if(!e||t.anchorNode!=e||t.anchorOffset!=n)return!1;for(n=Math.min(n,cn(e));;)if(n){if(e.nodeType!=1)return!1;let r=e.childNodes[n-1];r.contentEditable=="false"?n--:(e=r,n=cn(e))}else{if(e==i)return!0;n=Ln(e),e=e.parentNode}}function cb(i){return i instanceof Window?i.pageYOffset>Math.max(0,i.document.documentElement.scrollHeight-i.innerHeight-4):i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function hb(i,t){for(let e=i,n=t;;){if(e.nodeType==3&&n>0)return{node:e,offset:n};if(e.nodeType==1&&n>0){if(e.contentEditable=="false")return null;e=e.childNodes[n-1],n=cn(e)}else if(e.parentNode&&!Ea(e))n=Ln(e),e=e.parentNode;else return null}}function ub(i,t){for(let e=i,n=t;;){if(e.nodeType==3&&n<e.nodeValue.length)return{node:e,offset:n};if(e.nodeType==1&&n<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[n],n=0}else if(e.parentNode&&!Ea(e))n=Ln(e)+1,e=e.parentNode;else return null}}class ai{constructor(t,e,n=!0){this.node=t,this.offset=e,this.precise=n}static before(t,e){return new ai(t.parentNode,Ln(t),e)}static after(t,e){return new ai(t.parentNode,Ln(t)+1,e)}}var Tt=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(Tt||(Tt={}));const Sr=Tt.LTR,Rf=Tt.RTL;function fb(i){let t=[];for(let e=0;e<i.length;e++)t.push(1<<+i[e]);return t}const Lx=fb("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Mx=fb("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),gu=Object.create(null),yi=[];for(let i of["()","[]","{}"]){let t=i.charCodeAt(0),e=i.charCodeAt(1);gu[t]=e,gu[e]=-t}function db(i){return i<=247?Lx[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?Mx[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}const zx=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ei{get dir(){return this.level%2?Rf:Sr}constructor(t,e,n){this.from=t,this.to=e,this.level=n}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,n,r){let s=-1;for(let o=0;o<t.length;o++){let l=t[o];if(l.from<=e&&l.to>=e){if(l.level==n)return o;(s<0||(r!=0?r<0?l.from<e:l.to>e:t[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Ob(i,t){if(i.length!=t.length)return!1;for(let e=0;e<i.length;e++){let n=i[e],r=t[e];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!Ob(n.inner,r.inner))return!1}return!0}const wt=[];function _x(i,t,e,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:t,l=s<n.length?n[s].from:e,a=s?256:r;for(let c=o,h=a,u=a;c<l;c++){let f=db(i.charCodeAt(c));f==512?f=h:f==8&&u==4&&(f=16),wt[c]=f==4?2:f,f&7&&(u=f),h=f}for(let c=o,h=a,u=a;c<l;c++){let f=wt[c];if(f==128)c<l-1&&h==wt[c+1]&&h&24?f=wt[c]=h:wt[c]=256;else if(f==64){let d=c+1;for(;d<l&&wt[d]==64;)d++;let O=c&&h==8||d<e&&wt[d]==8?u==1?1:8:256;for(let p=c;p<d;p++)wt[p]=O;c=d-1}else f==8&&u==1&&(wt[c]=1);h=f,f&7&&(u=f)}}}function Ix(i,t,e,n,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let c=o?n[o-1].to:t,h=o<n.length?n[o].from:e;for(let u=c,f,d,O;u<h;u++)if(d=gu[f=i.charCodeAt(u)])if(d<0){for(let p=l-3;p>=0;p-=3)if(yi[p+1]==-d){let m=yi[p+2],g=m&2?r:m&4?m&1?s:r:0;g&&(wt[u]=wt[yi[p]]=g),l=p;break}}else{if(yi.length==189)break;yi[l++]=u,yi[l++]=f,yi[l++]=a}else if((O=wt[u])==2||O==1){let p=O==r;a=p?0:1;for(let m=l-3;m>=0;m-=3){let g=yi[m+2];if(g&2)break;if(p)yi[m+2]|=2;else{if(g&4)break;yi[m+2]|=4}}}}}function jx(i,t,e,n){for(let r=0,s=n;r<=e.length;r++){let o=r?e[r-1].to:i,l=r<e.length?e[r].from:t;for(let a=o;a<l;){let c=wt[a];if(c==256){let h=a+1;for(;;)if(h==l){if(r==e.length)break;h=e[r++].to,l=r<e.length?e[r].from:t}else if(wt[h]==256)h++;else break;let u=s==1,f=(h<t?wt[h]:n)==1,d=u==f?u?1:2:n;for(let O=h,p=r,m=p?e[p-1].to:i;O>a;)O==m&&(O=e[--p].from,m=p?e[p-1].to:i),wt[--O]=d;a=h}else s=c,a++}}}function bu(i,t,e,n,r,s,o){let l=n%2?2:1;if(n%2==r%2)for(let a=t,c=0;a<e;){let h=!0,u=!1;if(c==s.length||a<s[c].from){let p=wt[a];p!=l&&(h=!1,u=p==16)}let f=!h&&l==1?[]:null,d=h?n:n+1,O=a;t:for(;;)if(c<s.length&&O==s[c].from){if(u)break t;let p=s[c];if(!h)for(let m=p.to,g=c+1;;){if(m==e)break t;if(g<s.length&&s[g].from==m)m=s[g++].to;else{if(wt[m]==l)break t;break}}if(c++,f)f.push(p);else{p.from>a&&o.push(new Ei(a,p.from,d));let m=p.direction==Sr!=!(d%2);wu(i,m?n+1:n,r,p.inner,p.from,p.to,o),a=p.to}O=p.to}else{if(O==e||(h?wt[O]!=l:wt[O]==l))break;O++}f?bu(i,a,O,n+1,r,f,o):a<O&&o.push(new Ei(a,O,d)),a=O}else for(let a=e,c=s.length;a>t;){let h=!0,u=!1;if(!c||a>s[c-1].to){let p=wt[a-1];p!=l&&(h=!1,u=p==16)}let f=!h&&l==1?[]:null,d=h?n:n+1,O=a;t:for(;;)if(c&&O==s[c-1].to){if(u)break t;let p=s[--c];if(!h)for(let m=p.from,g=c;;){if(m==t)break t;if(g&&s[g-1].to==m)m=s[--g].from;else{if(wt[m-1]==l)break t;break}}if(f)f.push(p);else{p.to<a&&o.push(new Ei(p.to,a,d));let m=p.direction==Sr!=!(d%2);wu(i,m?n+1:n,r,p.inner,p.from,p.to,o),a=p.from}O=p.from}else{if(O==t||(h?wt[O-1]!=l:wt[O-1]==l))break;O--}f?bu(i,O,a,n+1,r,f,o):O<a&&o.push(new Ei(O,a,d)),a=O}}function wu(i,t,e,n,r,s,o){let l=t%2?2:1;_x(i,r,s,n,l),Ix(i,r,s,n,l),jx(r,s,n,l),bu(i,r,s,t,e,n,o)}function Dx(i,t,e){if(!i)return[new Ei(0,0,t==Rf?1:0)];if(t==Sr&&!e.length&&!zx.test(i))return pb(i.length);if(e.length)for(;i.length>wt.length;)wt[wt.length]=256;let n=[],r=t==Sr?0:1;return wu(i,r,r,e,0,i.length,n),n}function pb(i){return[new Ei(0,i,0)]}let mb="";function Vx(i,t,e,n,r){var s;let o=n.head-i.from,l=Ei.find(t,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),a=t[l],c=a.side(r,e);if(o==c){let f=l+=r?1:-1;if(f<0||f>=t.length)return null;a=t[l=f],o=a.side(!r,e),c=a.side(r,e)}let h=ae(i.text,o,a.forward(r,e));(h<a.from||h>a.to)&&(h=c),mb=i.text.slice(Math.min(o,h),Math.max(o,h));let u=l==(r?t.length-1:0)?null:t[l+(r?1:-1)];return u&&h==c&&u.level+(r?0:1)<a.level?C.cursor(u.side(!r,e)+i.from,u.forward(r,e)?1:-1,u.level):C.cursor(h+i.from,a.forward(r,e)?-1:1,a.level)}function Bx(i,t,e){for(let n=t;n<e;n++){let r=db(i.charCodeAt(n));if(r==1)return Sr;if(r==2||r==4)return Rf}return Sr}const gb=D.define(),bb=D.define(),wb=D.define(),Sb=D.define(),Su=D.define(),vb=D.define(),xb=D.define(),Zf=D.define(),Xf=D.define(),yb=D.define({combine:i=>i.some(t=>t)}),kb=D.define({combine:i=>i.some(t=>t)}),Qb=D.define();class jr{constructor(t,e,n,r,s,o=!1){this.range=t,this.y=e,this.x=n,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(t){return t.empty?this:new jr(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new jr(C.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Vl=Ct.define({map:(i,t)=>i.map(t)}),$b=Ct.define();function Li(i,t,e){let n=i.facet(Sb);n.length?n[0](t):window.onerror&&window.onerror(String(t),e,void 0,void 0,t)||(e?console.error(e+":",t):console.error(t))}const Ji=D.define({combine:i=>i.length?i[0]:!0});let Wx=0;const Xr=D.define({combine(i){return i.filter((t,e)=>{for(let n=0;n<e;n++)if(i[n].plugin==t.plugin)return!1;return!0})}});class ui{constructor(t,e,n,r,s){this.id=t,this.create=e,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Xr.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(Xr.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:n,eventObservers:r,provide:s,decorations:o}=e||{};return new ui(Wx++,t,n,r,l=>{let a=[];return o&&a.push(Qc.of(c=>{let h=c.plugin(l);return h?o(h):J.none})),s&&a.push(s(l)),a})}static fromClass(t,e){return ui.define((n,r)=>new t(n,r),e)}}class lh{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(n){if(Li(e.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){Li(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(!((e=this.value)===null||e===void 0)&&e.destroy)try{this.value.destroy()}catch(n){Li(t.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Cb=D.define(),Ef=D.define(),Qc=D.define(),Pb=D.define(),Lf=D.define(),kl=D.define(),Tb=D.define();function xO(i,t){let e=i.state.facet(Tb);if(!e.length)return e;let n=e.map(s=>s instanceof Function?s(i):s),r=[];return Ot.spans(n,t.from,t.to,{point(){},span(s,o,l,a){let c=s-t.from,h=o-t.from,u=r;for(let f=l.length-1;f>=0;f--,a--){let d=l[f].spec.bidiIsolate,O;if(d==null&&(d=Bx(t.text,c,h)),a>0&&u.length&&(O=u[u.length-1]).to==c&&O.direction==d)O.to=h,u=O.inner;else{let p={from:c,to:h,direction:d,inner:[]};u.push(p),u=p.inner}}}}),r}const Ab=D.define();function Mf(i){let t=0,e=0,n=0,r=0;for(let s of i.state.facet(Ab)){let o=s(i);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(e=Math.max(e,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:t,right:e,top:n,bottom:r}}const Ro=D.define();class Ye{constructor(t,e,n,r){this.fromA=t,this.toA=e,this.fromB=n,this.toB=r}join(t){return new Ye(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,n=this;for(;e>0;e--){let r=t[e-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),t.splice(e-1,1)}}return t.splice(e,0,n),t}static extendWithRanges(t,e){if(e.length==0)return t;let n=[];for(let r=0,s=0,o=0;;){let l=r<t.length?t[r].fromB:1e9,a=s<e.length?e[s]:1e9,c=Math.min(l,a);if(c==1e9)break;let h=c+o,u=c,f=h;for(;;)if(s<e.length&&e[s]<=u){let d=e[s+1];s+=2,u=Math.max(u,d);for(let O=r;O<t.length&&t[O].fromB<=u;O++)o=t[O].toA-t[O].toB;f=Math.max(f,d+o)}else if(r<t.length&&t[r].fromB<=u){let d=t[r++];u=Math.max(u,d.toB),f=Math.max(f,d.toA),o=d.toA-d.toB}else break;n.push(new Ye(h,f,c,u))}return n}}class Ma{constructor(t,e,n){this.view=t,this.state=e,this.transactions=n,this.flags=0,this.startState=t.state,this.changes=Lt.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new Ye(s,o,l,a))),this.changedRanges=r}static create(t,e,n){return new Ma(t,e,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Yx=[];class zt{constructor(t,e,n=0){this.dom=t,this.length=e,this.flags=n,this.parent=null,t.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Yx}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&Cx(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,e=this.posAtStart){let n=e;for(let r of this.children){if(r==t)return n;n+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,e){return null}domPosFor(t,e){let n=Ln(this.dom),r=this.length?t>0:e>0;return new ai(this.parent.dom,n+(r?1:0),t==0||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof Cc)return t;return null}static get(t){return t.cmTile}}class $c extends zt{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(this.flags&2)return;super.sync(t);let e=this.dom,n=null,r,s=(t==null?void 0:t.node)==e?t:null,o=0;for(let l of this.children){if(l.sync(t),o+=l.length+l.breakAfter,r=n?n.nextSibling:e.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==e)for(;r&&r!=l.dom;)r=yO(r);else e.insertBefore(l.dom,r);n=l.dom}for(r=n?n.nextSibling:e.firstChild,s&&r&&(s.written=!0);r;)r=yO(r);this.length=o}}function yO(i){let t=i.nextSibling;return i.parentNode.removeChild(i),t}class Cc extends $c{constructor(t,e){super(e),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let e=zt.get(t);if(e&&this.owns(e))return e;t=t.parentNode}}blockTiles(t){for(let e=[],n=this,r=0,s=0;;)if(r==n.children.length){if(!e.length)return;n=n.parent,n.breakAfter&&s++,r=e.pop()}else{let o=n.children[r++];if(o instanceof nn)e.push(r),n=o,r=0;else{let l=s+o.length,a=t(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(t,e){let n,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let c=a+l.length;if(t>=a&&t<=c){if(l.isWidget()&&e>=-1&&e<=1){if(l.flags&32)return!0;l.flags&16&&(n=void 0)}(a<t||t==c&&(e<-1?l.length:l.covers(1)))&&(!n||!l.isWidget()&&n.isWidget())&&(n=l,r=t-a),(c>t||t==a&&(e>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=t-a)}}),!n&&!s)throw new Error("No tile at position "+t);return n&&e<0||!s?{tile:n,offset:r}:{tile:s,offset:o}}}class nn extends $c{constructor(t,e){super(t),this.wrapper=e}isBlock(){return!0}covers(t){return this.children.length?t<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,e){let n=new nn(e||document.createElement(t.tagName),t);return e||(n.flags|=4),n}}class Ys extends $c{constructor(t,e){super(t),this.attrs=e}isLine(){return!0}static start(t,e,n){let r=new Ys(e||document.createElement("div"),t);return(!e||!n)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(t,e,n){let r=null,s=-1,o=null,l=-1;function a(h,u){for(let f=0,d=0;f<h.children.length&&d<=u;f++){let O=h.children[f],p=d+O.length;p>=u&&(O.isComposite()?a(O,u-d):(!o||o.isHidden&&(e>0||n&&Nx(o,O)))&&(p>u||O.flags&32)?(o=O,l=u-d):(d<u||O.flags&16&&!O.isHidden)&&(r=O,s=u-d)),d=p}}a(this,t);let c=(e<0?r:o)||r||o;return c?{tile:c,offset:c==r?s:l}:null}coordsIn(t,e){let n=this.resolveInline(t,e,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),e):qx(this)}domIn(t,e){let n=this.resolveInline(t,e);if(n){let{tile:r,offset:s}=n;if(this.dom.contains(r.dom))return r.isText()?new ai(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:e);let o=n.tile.parent,l=!1;for(let a of o.children){if(l)return new ai(a.dom,0);a==n.tile&&(l=!0)}}return new ai(this.dom,0)}}function qx(i){let t=i.dom.lastChild;if(!t)return i.dom.getBoundingClientRect();let e=ga(t);return e[e.length-1]||null}function Nx(i,t){let e=i.coordsIn(0,1),n=t.coordsIn(0,1);return e&&n&&n.top<e.bottom}class ve extends $c{constructor(t,e){super(t),this.mark=e}get domAttrs(){return this.mark.attrs}static of(t,e){let n=new ve(e||document.createElement(t.tagName),t);return e||(n.flags|=4),n}}class nr extends zt{constructor(t,e){super(t,e.length),this.text=e}sync(t){this.flags&2||(super.sync(t),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(t,e){let n=this.dom.nodeValue.length;t>n&&(t=n);let r=t,s=t,o=0;t==0&&e<0||t==n&&e>=0?M.chrome||M.gecko||(t?(r--,o=1):s<n&&(s++,o=-1)):e<0?r--:s<n&&s++;let l=Ko(this.dom,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:e>=0)?0:l.length-1];return M.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,c=>c.width)||a),o?La(a,o<0):a||null}static of(t,e){let n=new nr(e||document.createTextNode(t),t);return e||(n.flags|=2),n}}class vr extends zt{constructor(t,e,n,r){super(t,e,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return this.flags&48?!1:(this.flags&(t<0?64:128))>0}coordsIn(t,e){return this.coordsInWidget(t,e,!1)}coordsInWidget(t,e,n){let r=this.widget.coordsAt(this.dom,t,e);if(r)return r;if(n)return La(this.dom.getBoundingClientRect(),this.length?t==0:e<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:t>0;for(let a=l?s.length-1:0;o=s[a],!(t>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return La(o,!l)}}get overrideDOMText(){if(!this.length)return Y.empty;let{root:t}=this;if(!t)return Y.empty;let e=this.posAtStart;return t.view.state.doc.slice(e,e+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,e,n,r,s){return s||(s=t.toDOM(e),t.editable||(s.contentEditable="false")),new vr(s,n,t,r)}}class za extends zt{constructor(t){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),super(e,0,t)}get isHidden(){return!0}get overrideDOMText(){return Y.empty}coordsIn(t){return this.dom.getBoundingClientRect()}}class Gx{constructor(t){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t}advance(t,e,n){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;t||e>0;)if(r.isComposite())if(o){if(!t)break;n&&n.break(),t--,o=!1}else if(s==r.children.length){if(!t&&!l.length)break;n&&n.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],c=a.breakAfter;(e>0?a.length<=t:a.length<t)&&(!n||n.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!c,s++,t-=a.length):(l.push({tile:r,index:s}),r=a,s=0,n&&a.isComposite()&&n.enter(a))}else if(s==r.length)o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++;else if(t){let a=Math.min(t,r.length-s);n&&n.skip(r,s,s+a),t-=a,s+=a}else break;return this.tile=r,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Ux{constructor(t,e,n,r){this.from=t,this.to=e,this.wrapper=n,this.rank=r}}class Hx{constructor(t,e,n){this.cache=t,this.root=e,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(t,e,n,r){var s;this.flushBuffer();let o=this.ensureMarks(e,n),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+t.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new nr(l.dom,l.text+t);a.parent=o}else o.append(r||nr.of(t,(s=this.cache.find(nr))===null||s===void 0?void 0:s.dom));this.pos+=t.length,this.afterWidget=null}addComposition(t,e){let n=this.curLine;n.dom!=e.line.dom&&(n.setDOM(this.cache.reused.has(e.line)?ah(e.line.dom):e.line.dom),this.cache.reused.set(e.line,2));let r=n;for(let l=e.marks.length-1;l>=0;l--){let a=e.marks[l],c=r.lastChild;if(c instanceof ve&&c.mark.eq(a.mark))c.dom!=a.dom&&c.setDOM(ah(a.dom)),r=c;else{if(this.cache.reused.get(a)){let u=zt.get(a.dom);u&&u.setDOM(ah(a.dom))}let h=ve.of(a.mark,a.dom);r.append(h),r=h}this.cache.reused.set(a,2)}let s=zt.get(t.text);s&&this.cache.reused.set(s,2);let o=new nr(t.text,t.text.nodeValue);o.flags|=8,this.pos=t.range.toB,r.append(o)}addInlineWidget(t,e,n){let r=this.afterWidget&&t.flags&48&&(this.afterWidget.flags&48)==(t.flags&48);r||this.flushBuffer();let s=this.ensureMarks(e,n);!r&&!(t.flags&16)&&s.append(this.getBuffer(1)),s.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,e,n){this.flushBuffer(),this.ensureMarks(e,n).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){let e=this.afterWidget||this.lastBlock;e.length+=t,this.pos+=t}addLineStart(t,e){var n;t||(t=Rb);let r=Ys.start(t,e||((n=this.cache.find(Ys))===null||n===void 0?void 0:n.dom),!!e);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,e){var n;let r=this.curLine;for(let s=t.length-1;s>=0;s--){let o=t[s],l;if(e>0&&(l=r.lastChild)&&l instanceof ve&&l.mark.eq(o))r=l,e--;else{let a=ve.of(o,(n=this.cache.find(ve,c=>c.mark.eq(o)))===null||n===void 0?void 0:n.dom);r.append(a),r=a,e=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;(!t||!kO(this.curLine,!1)||t.dom.nodeName!="BR"&&t.isWidget()&&!(M.ios&&kO(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(ch,0,32)||new vr(ch.toDOM(),0,ch,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to<this.pos&&this.wrappers.splice(t,1);for(let t=this.blockWrappers;t.value&&t.from<=this.pos;t.next())if(t.to>=this.pos){let e=t.rank*102+t.value.rank,n=new Ux(t.from,t.to,t.value,e),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let e=this.root;for(let n of this.wrappers){let r=e.lastChild;if(n.from<this.pos&&r instanceof nn&&r.wrapper.eq(n.wrapper))e=r;else{let s=nn.of(n.wrapper,(t=this.cache.find(nn,o=>o.wrapper.eq(n.wrapper)))===null||t===void 0?void 0:t.dom);e.append(s),e=s}}return e}blockPosCovered(){let t=this.lastBlock;return t!=null&&!t.breakAfter&&(!t.isWidget()||(t.flags&160)>0)}getBuffer(t){let e=2|(t<0?16:32),n=this.cache.find(za,void 0,1);return n&&(n.flags=e),n||new za(e)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Fx{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(t,r.length);return s?null:r.slice(0,l)}let e=Math.min(this.text.length,this.textOff+t),n=this.text.slice(this.textOff,e);return this.textOff=e,n}}const _a=[vr,Ys,nr,ve,za,nn,Cc];for(let i=0;i<_a.length;i++)_a[i].bucket=i;class Kx{constructor(t){this.view=t,this.buckets=_a.map(()=>[]),this.index=_a.map(()=>0),this.reused=new Map}add(t){let e=t.constructor.bucket,n=this.buckets[e];n.length<6?n.push(t):n[this.index[e]=(this.index[e]+1)%6]=t}find(t,e,n=2){let r=t.bucket,s=this.buckets[r],o=this.index[r];for(let l=s.length-1;l>=0;l--){let a=(l+o)%s.length,c=s[a];if((!e||e(c))&&!this.reused.has(c))return s.splice(a,1),a<o&&this.index[r]--,this.reused.set(c,n),c}return null}findWidget(t,e,n){let r=this.buckets[0];if(r.length)for(let s=0,o=0;;s++){if(s==r.length){if(o)return null;o=1,s=0}let l=r[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(t):l.widget.constructor==t.constructor&&t.updateDOM(l.dom,this.view,l.widget)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==t&&l.length==e&&(l.flags&497)==n?(this.reused.set(l,1),l):(this.reused.set(l,2),new vr(l.dom,e,t,l.flags&-498|n))}}reuse(t){return this.reused.set(t,1),t}maybeReuse(t,e=2){if(!this.reused.has(t))return this.reused.set(t,e),t.dom}clear(){for(let t=0;t<this.buckets.length;t++)this.buckets[t].length=this.index[t]=0}}class Jx{constructor(t,e,n,r,s){this.view=t,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new Kx(t),this.text=new Fx(t.state.doc),this.builder=new Hx(this.cache,new Cc(t,t.contentDOM),Ot.iter(n)),this.cache.reused.set(e,2),this.old=new Gx(e),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(t,e){let n=e&&this.getCompositionContext(e.text);for(let r=0,s=0,o=0;;){let l=o<t.length?t[o++]:null,a=l?l.fromA:this.old.root.length;if(a>r){let c=a-r;this.preserve(c,!o,!l),r=a,s+=c}if(!l)break;e&&l.fromA<=e.range.fromA&&l.toA>=e.range.toA?(this.forward(l.fromA,e.range.fromA,e.range.fromA<e.range.toA?1:-1),this.emit(s,e.range.fromB),this.cache.clear(),this.builder.addComposition(e,n),this.text.skip(e.range.toB-e.range.fromB),this.forward(e.range.fromA,l.toA),this.emit(e.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,r=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(t,e,n){let r=iy(this.old),s=this.openMarks;this.old.advance(t,n?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let c=a>0||l<o.length?vr.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);c.flags&256?(c.flags&=-2,this.builder.addBlockWidget(c)):(this.builder.ensureLine(null),this.builder.addInlineWidget(c,r,s),s=r.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,r,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),r,s)),s=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof za)this.cache.add(o);else if(o instanceof ve)this.builder.ensureLine(null),this.builder.addMark(o,r,s),this.cache.reused.set(o,1),s=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof ve&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof ve&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,e){let n=null,r=this.builder,s=0,o=Ot.spans(this.decorations,t,e,{point:(l,a,c,h,u,f)=>{if(c instanceof wr){if(this.disallowBlockEffectsFor[f]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=h.length,u>h.length)r.continueWidget(a-l);else{let d=c.widget||(c.block?qs.block:qs.inline),O=ty(c),p=this.cache.findWidget(d,a-l,O)||vr.of(d,this.view,a-l,O);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(p)):(r.ensureLine(n),r.addInlineWidget(p,h,u))}n=null}else n=ey(n,c);a>l&&this.text.skip(a-l)},span:(l,a,c,h)=>{for(let u=l;u<a;){let f=this.text.next(Math.min(512,a-u));f==null?(r.addLineStartIfNotCovered(n),r.addBreak(),u++):(r.ensureLine(n),r.addText(f,c,u==l?h:c.length),u+=f.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=o>s,this.openMarks=o}forward(t,e,n=1){e-t<=10?this.old.advance(e-t,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(e-t-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(t){let e=[],n=null;for(let r=t.parentNode;;r=r.parentNode){let s=zt.get(r);if(r==this.view.contentDOM)break;s instanceof ve?e.push(s):s!=null&&s.isLine()?n=s:s instanceof nn||(r.nodeName=="DIV"&&!n&&r!=this.view.contentDOM?n=new Ys(r,Rb):n||e.push(ve.of(new xl({tagName:r.nodeName.toLowerCase(),attributes:Px(r)}),r)))}return{line:n,marks:e}}}function kO(i,t){let e=n=>{for(let r of n.children)if((t?r.isText():r.length)||e(r))return!0;return!1};return e(i)}function ty(i){let t=i.isReplace?(i.startSide<0?64:0)|(i.endSide>0?128:0):i.startSide>0?32:16;return i.block&&(t|=256),t}const Rb={class:"cm-line"};function ey(i,t){let e=t.spec.attributes,n=t.spec.class;return!e&&!n||(i||(i={class:"cm-line"}),e&&Tf(e,i),n&&(i.class+=" "+n)),i}function iy(i){let t=[];for(let e=i.parents.length;e>1;e--){let n=e==i.parents.length?i.tile:i.parents[e].tile;n instanceof ve&&t.push(n.mark)}return t}function ah(i){let t=zt.get(i);return t&&t.setDOM(i.cloneNode()),i}class qs extends jn{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}qs.inline=new qs("span");qs.block=new qs("div");const ch=new class extends jn{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class QO{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=J.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Cc(t,t.contentDOM),this.updateInner([new Ye(0,0,0,t.state.doc.length)],null)}update(t){var e;let n=t.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:h,toA:u})=>u<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((e=this.domChanged)===null||e===void 0)&&e.newSel?r=this.domChanged.newSel.head:!uy(t.changes,this.hasComposition)&&!t.selectionSet&&(r=t.state.selection.main.head));let s=r>-1?ry(this.view,t.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:u}=this.hasComposition;n=new Ye(h,u,t.changes.mapPos(h,-1),t.changes.mapPos(u,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(M.ie||M.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=ly(o,this.decorations,t.changes);a.length&&(n=Ye.extendWithRanges(n,a));let c=cy(l,this.blockWrappers,t.changes);return c.length&&(n=Ye.extendWithRanges(n,c)),s&&!n.some(h=>h.fromA<=s.range.fromA&&h.toA>=s.range.toA)&&(n=s.range.addToSet(n.slice())),this.tile.flags&2&&n.length==0?!1:(this.updateInner(n,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(e||t.length){let o=this.tile,l=new Jx(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);e&&zt.get(e.text)&&l.cache.reused.set(zt.get(e.text),2),this.tile=l.run(t,e),vu(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=M.chrome||M.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||n.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof hh&&r.push(s.dom);n.updateGaps(r)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let n of e.effects)n.is($b)&&(this.editContextFormatting=n.value)}updateSelection(t=!1,e=!1){(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,s=r==n,o=!s&&!(this.view.state.facet(Ji)||n.tabIndex>-1)&&Io(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(s||e||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,c,h;if(a.empty?h=c=this.inlineDOMNearPos(a.anchor,a.assoc||1):(h=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),c=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),M.gecko&&a.empty&&!this.hasComposition&&ny(c)){let f=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(f,c.node.childNodes[c.offset]||null)),c=h=new ai(f,0),l=!0}let u=this.view.observer.selectionRange;(l||!u.focusNode||(!jo(c.node,c.offset,u.anchorNode,u.anchorOffset)||!jo(h.node,h.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{M.android&&M.chrome&&n.contains(u.focusNode)&&hy(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let f=Fo(this.view.root);if(f)if(a.empty){if(M.gecko){let d=sy(c.node,c.offset);if(d&&d!=3){let O=(d==1?hb:ub)(c.node,c.offset);O&&(c=new ai(O.node,O.offset))}}f.collapse(c.node,c.offset),a.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(c.node,c.offset);try{f.extend(h.node,h.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([c,h]=[h,c]),d.setEnd(h.node,h.offset),d.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(d)}o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,h)),this.impreciseAnchor=c.precise?null:new ai(u.anchorNode,u.anchorOffset),this.impreciseHead=h.precise?null:new ai(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&jo(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,n=Fo(t.root),{anchorNode:r,anchorOffset:s}=t.observer.selectionRange;if(!n||!e.empty||!e.assoc||!n.modify)return;let o=this.lineAt(e.head,e.assoc);if(!o)return;let l=o.posAtStart;if(e.head==l||e.head==l+o.length)return;let a=this.coordsAt(e.head,-1),c=this.coordsAt(e.head,1);if(!a||!c||a.bottom>c.top)return;let h=this.domAtPos(e.head+e.assoc,e.assoc);n.collapse(h.node,h.offset),n.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let u=t.observer.selectionRange;t.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=e.from&&n.collapse(r,s)}posFromDOM(t,e){let n=this.tile.nearest(t);if(!n)return this.tile.dom.compareDocumentPosition(t)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let s;if(t==n.dom)s=n.dom.childNodes[e];else{let o=cn(t)==0?0:e==0?-1:1;for(;;){let l=t.parentNode;if(l==n.dom)break;o==0&&l.firstChild!=l.lastChild&&(t==l.firstChild?o=-1:o=1),t=l}o<0?s=t:s=t.nextSibling}if(s==n.dom.firstChild)return r;for(;s&&!zt.get(s);)s=s.nextSibling;if(!s)return r+n.length;for(let o=0,l=r;;o++){let a=n.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return n.isText()?t==n.dom?r+e:r+(e?n.length:0):r}domAtPos(t,e){let{tile:n,offset:r}=this.tile.resolveBlock(t,e);return n.isWidget()?n.domPosFor(t,e):n.domIn(r,e)}inlineDOMNearPos(t,e){let n,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((c,h)=>{if(c.isWidget()){if(c.flags&32&&h>=t)return!0;c.flags&16&&(s=!0)}else{let u=h+c.length;if(h<=t&&(n=c,r=t-h,s=u<t),u>=t&&!o&&(o=c,l=t-h,a=h>t),h>t&&o)return!0}}),!n&&!o?this.domAtPos(t,e):(s&&o?n=null:a&&n&&(o=null),n&&e<0||!o?n.domIn(r,e):o.domIn(l,e))}coordsAt(t,e){let{tile:n,offset:r}=this.tile.resolveBlock(t,e);return n.isWidget()?n.widget instanceof hh?null:n.coordsInWidget(r,e,!0):n.coordsIn(r,e)}lineAt(t,e){let{tile:n}=this.tile.resolveBlock(t,e);return n.isLine()?n:null}coordsForChar(t){let{tile:e,offset:n}=this.tile.resolveBlock(t,1);if(!e.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=ae(s.text,o);if(l==o)return null;let a=Ko(s.dom,o,l).getClientRects();for(let c=0;c<a.length;c++){let h=a[c];if(c==a.length-1||h.top<h.bottom&&h.left<h.right)return h}}return null}return r(e,n)}measureVisibleLineHeights(t){let e=[],{from:n,to:r}=t,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==Tt.LTR,c=0,h=(u,f,d)=>{for(let O=0;O<u.children.length&&!(f>r);O++){let p=u.children[O],m=f+p.length,g=p.dom.getBoundingClientRect(),{height:b}=g;if(d&&!O&&(c+=g.top-d.top),p instanceof nn)m>n&&h(p,f,g);else if(f>=n&&(c>0&&e.push(-c),e.push(b+c),c=0,o)){let S=p.dom.lastChild,x=S?ga(S):[];if(x.length){let y=x[x.length-1],k=a?y.right-g.left:g.right-y.left;k>l&&(l=k,this.minWidth=s,this.minWidthFrom=f,this.minWidthTo=m)}}d&&O==u.children.length-1&&(c+=d.bottom-g.bottom),f=m+p.breakAfter}};return h(this.tile,0,null),e}textDirectionAt(t){let{tile:e}=this.tile.resolveBlock(t,1);return getComputedStyle(e.dom).direction=="rtl"?Tt.RTL:Tt.LTR}measureTextSize(){let t=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let h=ga(c.dom);if(h.length!=1)return;l+=h[0].width,a=h[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(t)return t;let e=document.createElement("div"),n,r,s;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(e);let o=ga(e.firstChild)[0];n=e.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:n,e.remove()}),{lineHeight:n,charWidth:r,textHeight:s}}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let n=0,r=0;;r++){let s=r==e.viewports.length?null:e.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>n){let l=(e.lineBlockAt(o).bottom-e.lineBlockAt(n).top)/this.view.scaleY;t.push(J.replace({widget:new hh(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return J.set(t)}updateDeco(){let t=1,e=this.view.state.facet(Qc).map(s=>(this.dynamicDecorationMap[t++]=typeof s=="function")?s(this.view):s),n=!1,r=this.view.state.facet(Lf).map((s,o)=>{let l=typeof s=="function";return l&&(n=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[t++]=n,e.push(Ot.join(r))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;this.blockWrappers=this.view.state.facet(Pb).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(t){var e;if(t.isSnapshot){let h=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=h.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let h of this.view.state.facet(Qb))try{if(h(this.view,t.range,t))return!0}catch(u){Li(this.view.state,u,"scroll handler")}let{range:n}=t,r=this.coordsAt(n.head,(e=n.assoc)!==null&&e!==void 0?e:n.empty?0:n.head>n.anchor?-1:1),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=Mf(this.view),l={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:a,offsetHeight:c}=this.view.scrollDOM;if(Rx(this.view.scrollDOM,l,n.head<n.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,a),-a),Math.max(Math.min(t.yMargin,c),-c),this.view.textDirection==Tt.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(r.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||r.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(n.head,1);h&&h.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(t){let e=n=>n.isWidget()||n.children.some(e);return e(this.tile.resolveBlock(t,1).tile)}destroy(){vu(this.tile)}}function vu(i,t){let e=t==null?void 0:t.get(i);if(e!=1){e==null&&i.destroy();for(let n of i.children)vu(n,t)}}function ny(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function Zb(i,t){let e=i.observer.selectionRange;if(!e.focusNode)return null;let n=hb(e.focusNode,e.focusOffset),r=ub(e.focusNode,e.focusOffset),s=n||r;if(r&&n&&r.node!=n.node){let l=zt.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(i.docView.lastCompositionAfterCursor){let a=zt.get(n.node);!a||a.isText()&&a.text!=n.node.nodeValue||(s=r)}}if(i.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=t-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function ry(i,t,e){let n=Zb(i,e);if(!n)return null;let{node:r,from:s,to:o}=n,l=r.nodeValue;if(/[\n\r]/.test(l)||i.state.doc.sliceString(n.from,n.to)!=l)return null;let a=t.invertedDesc;return{range:new Ye(a.mapPos(s),a.mapPos(o),s,o),text:r}}function sy(i,t){return i.nodeType!=1?0:(t&&i.childNodes[t-1].contentEditable=="false"?1:0)|(t<i.childNodes.length&&i.childNodes[t].contentEditable=="false"?2:0)}let oy=class{constructor(){this.changes=[]}compareRange(t,e){_r(t,e,this.changes)}comparePoint(t,e){_r(t,e,this.changes)}boundChange(t){_r(t,t,this.changes)}};function ly(i,t,e){let n=new oy;return Ot.compare(i,t,e,n),n.changes}class ay{constructor(){this.changes=[]}compareRange(t,e){_r(t,e,this.changes)}comparePoint(){}boundChange(t){_r(t,t,this.changes)}}function cy(i,t,e){let n=new ay;return Ot.compare(i,t,e,n),n.changes}function hy(i,t){for(let e=i;e&&e!=t;e=e.assignedSlot||e.parentNode)if(e.nodeType==1&&e.contentEditable=="false")return!0;return!1}function uy(i,t){let e=!1;return t&&i.iterChangedRanges((n,r)=>{n<t.to&&r>t.from&&(e=!0)}),e}class hh extends jn{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function fy(i,t,e=1){let n=i.charCategorizer(t),r=i.doc.lineAt(t),s=t-r.from;if(r.length==0)return C.cursor(t);s==0?e=1:s==r.length&&(e=-1);let o=s,l=s;e<0?o=ae(r.text,s,!1):l=ae(r.text,s);let a=n(r.text.slice(o,l));for(;o>0;){let c=ae(r.text,o,!1);if(n(r.text.slice(c,o))!=a)break;o=c}for(;l<r.length;){let c=ae(r.text,l);if(n(r.text.slice(l,c))!=a)break;l=c}return C.range(o+r.from,l+r.from)}function dy(i,t,e,n,r){let s=Math.round((n-t.left)*i.defaultCharacterWidth);if(i.lineWrapping&&e.height>i.defaultLineHeight*1.5){let l=i.viewState.heightOracle.textHeight,a=Math.floor((r-e.top-(i.defaultLineHeight-l)*.5)/l);s+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(e.from,e.to);return e.from+xx(o,s,i.state.tabSize)}function xu(i,t,e){let n=i.lineBlockAt(t);if(Array.isArray(n.type)){let r;for(let s of n.type){if(s.from>t)break;if(!(s.to<t)){if(s.from<t&&s.to>t)return s;(!r||s.type==pe.Text&&(r.type!=s.type||(e<0?s.from<t:s.to>t)))&&(r=s)}}return r||n}return n}function Oy(i,t,e,n){let r=xu(i,t.head,t.assoc||-1),s=!n||r.type!=pe.Text||!(i.lineWrapping||r.widgetLineBreaks)?null:i.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head);if(s){let o=i.dom.getBoundingClientRect(),l=i.textDirectionAt(r.from),a=i.posAtCoords({x:e==(l==Tt.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return C.cursor(a,e?-1:1)}return C.cursor(e?r.to:r.from,e?-1:1)}function $O(i,t,e,n){let r=i.state.doc.lineAt(t.head),s=i.bidiSpans(r),o=i.textDirectionAt(r.from);for(let l=t,a=null;;){let c=Vx(r,s,o,l,e),h=mb;if(!c){if(r.number==(e?i.state.doc.lines:1))return l;h=`
35
+ `;this.styleTag.textContent=o;let l=e.head||e;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}var En={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Uo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},kx=typeof navigator<"u"&&/Mac/.test(navigator.platform),Qx=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ee=0;ee<10;ee++)En[48+ee]=En[96+ee]=String(ee);for(var ee=1;ee<=24;ee++)En[ee+111]="F"+ee;for(var ee=65;ee<=90;ee++)En[ee]=String.fromCharCode(ee+32),Uo[ee]=String.fromCharCode(ee);for(var sh in En)Uo.hasOwnProperty(sh)||(Uo[sh]=En[sh]);function $x(i){var t=kx&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||Qx&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",e=!t&&i.key||(i.shiftKey?Uo:En)[i.keyCode]||i.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}let de=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},fu=typeof document<"u"?document:{documentElement:{style:{}}};const du=/Edge\/(\d+)/.exec(de.userAgent),rb=/MSIE \d/.test(de.userAgent),Ou=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(de.userAgent),kc=!!(rb||Ou||du),mO=!kc&&/gecko\/(\d+)/i.test(de.userAgent),oh=!kc&&/Chrome\/(\d+)/.exec(de.userAgent),gO="webkitFontSmoothing"in fu.documentElement.style,pu=!kc&&/Apple Computer/.test(de.vendor),bO=pu&&(/Mobile\/\w+/.test(de.userAgent)||de.maxTouchPoints>2);var M={mac:bO||/Mac/.test(de.platform),windows:/Win/.test(de.platform),linux:/Linux|X11/.test(de.platform),ie:kc,ie_version:rb?fu.documentMode||6:Ou?+Ou[1]:du?+du[1]:0,gecko:mO,gecko_version:mO?+(/Firefox\/(\d+)/.exec(de.userAgent)||[0,0])[1]:0,chrome:!!oh,chrome_version:oh?+oh[1]:0,ios:bO,android:/Android\b/.test(de.userAgent),webkit:gO,webkit_version:gO?+(/\bAppleWebKit\/(\d+)/.exec(de.userAgent)||[0,0])[1]:0,safari:pu,safari_version:pu?+(/\bVersion\/(\d+(\.\d+)?)/.exec(de.userAgent)||[0,0])[1]:0,tabSize:fu.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Tf(i,t){for(let e in i)e=="class"&&t.class?t.class+=" "+i.class:e=="style"&&t.style?t.style+=";"+i.style:t[e]=i[e];return t}const Xa=Object.create(null);function Af(i,t,e){if(i==t)return!0;i||(i=Xa),t||(t=Xa);let n=Object.keys(i),r=Object.keys(t);if(n.length-0!=r.length-0)return!1;for(let s of n)if(s!=e&&(r.indexOf(s)==-1||i[s]!==t[s]))return!1;return!0}function Cx(i,t){for(let e=i.attributes.length-1;e>=0;e--){let n=i.attributes[e].name;t[n]==null&&i.removeAttribute(n)}for(let e in t){let n=t[e];e=="style"?i.style.cssText=n:i.getAttribute(e)!=n&&i.setAttribute(e,n)}}function wO(i,t,e){let n=!1;if(t)for(let r in t)e&&r in e||(n=!0,r=="style"?i.style.cssText="":i.removeAttribute(r));if(e)for(let r in e)t&&t[r]==e[r]||(n=!0,r=="style"?i.style.cssText=e[r]:i.setAttribute(r,e[r]));return n}function Px(i){let t=Object.create(null);for(let e=0;e<i.attributes.length;e++){let n=i.attributes[e];t[n.name]=n.value}return t}class jn{eq(t){return!1}updateDOM(t,e,n){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var pe=function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i}(pe||(pe={}));class J extends Zn{constructor(t,e,n,r){super(),this.startSide=t,this.endSide=e,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(t){return new xl(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),n=!!t.block;return e+=n&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new wr(t,e,e,n,t.widget||null,!1)}static replace(t){let e=!!t.block,n,r;if(t.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:o}=sb(t,e);n=(s?e?-3e8:-1:5e8)-1,r=(o?e?2e8:1:-6e8)+1}return new wr(t,n,r,e,t.widget||null,!0)}static line(t){return new yl(t)}static set(t,e=!1){return Ot.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}J.none=Ot.empty;class xl extends J{constructor(t){let{start:e,end:n}=sb(t);super(e?-1:5e8,n?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?Tf(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||Xa}eq(t){return this==t||t instanceof xl&&this.tagName==t.tagName&&Af(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}xl.prototype.point=!1;class yl extends J{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof yl&&this.spec.class==t.spec.class&&Af(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}yl.prototype.mapMode=Oe.TrackBefore;yl.prototype.point=!0;class wr extends J{constructor(t,e,n,r,s,o){super(e,n,s,t),this.block=r,this.isReplace=o,this.mapMode=r?e<=0?Oe.TrackBefore:Oe.TrackAfter:Oe.TrackDel}get type(){return this.startSide!=this.endSide?pe.WidgetRange:this.startSide<=0?pe.WidgetBefore:pe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof wr&&Tx(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}wr.prototype.point=!0;function sb(i,t=!1){let{inclusiveStart:e,inclusiveEnd:n}=i;return e==null&&(e=i.inclusive),n==null&&(n=i.inclusive),{start:e??t,end:n??t}}function Tx(i,t){return i==t||!!(i&&t&&i.compare(t))}function _r(i,t,e,n=0){let r=e.length-1;r>=0&&e[r]+n>=i?e[r]=Math.max(e[r],t):e.push(i,t)}class Ho extends Zn{constructor(t,e,n){super(),this.tagName=t,this.attributes=e,this.rank=n}eq(t){return t==this||t instanceof Ho&&this.tagName==t.tagName&&Af(this.attributes,t.attributes)}static create(t){return new Ho(t.tagName,t.attributes||Xa,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(t,e=!1){return Ot.of(t,e)}}Ho.prototype.startSide=Ho.prototype.endSide=-1;function Fo(i){let t;return i.nodeType==11?t=i.getSelection?i:i.ownerDocument:t=i,t.getSelection()}function mu(i,t){return t?i==t||i.contains(t.nodeType!=1?t.parentNode:t):!1}function Io(i,t){if(!t.anchorNode)return!1;try{return mu(i,t.anchorNode)}catch{return!1}}function ga(i){return i.nodeType==3?Ko(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function jo(i,t,e,n){return e?SO(i,t,e,n,-1)||SO(i,t,e,n,1):!1}function Ln(i){for(var t=0;;t++)if(i=i.previousSibling,!i)return t}function Ea(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function SO(i,t,e,n,r){for(;;){if(i==e&&t==n)return!0;if(t==(r<0?0:cn(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;t=Ln(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[t+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;t=r<0?cn(i):0}else return!1}}function cn(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function La(i,t){let e=t?i.left:i.right;return{left:e,right:e,top:i.top,bottom:i.bottom}}function Ax(i){let t=i.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function ob(i,t){let e=t.width/i.offsetWidth,n=t.height/i.offsetHeight;return(e>.995&&e<1.005||!isFinite(e)||Math.abs(t.width-i.offsetWidth)<1)&&(e=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.height-i.offsetHeight)<1)&&(n=1),{scaleX:e,scaleY:n}}function Rx(i,t,e,n,r,s,o,l){let a=i.ownerDocument,c=a.defaultView||window;for(let h=i,u=!1;h&&!u;)if(h.nodeType==1){let f,d=h==a.body,O=1,p=1;if(d)f=Ax(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let b=h.getBoundingClientRect();({scaleX:O,scaleY:p}=ob(h,b)),f={left:b.left,right:b.left+h.clientWidth*O,top:b.top,bottom:b.top+h.clientHeight*p}}let m=0,g=0;if(r=="nearest")t.top<f.top+o?(g=t.top-(f.top+o),e>0&&t.bottom>f.bottom+g&&(g=t.bottom-f.bottom+o)):t.bottom>f.bottom-o&&(g=t.bottom-f.bottom+o,e<0&&t.top-g<f.top&&(g=t.top-(f.top+o)));else{let b=t.bottom-t.top,S=f.bottom-f.top;g=(r=="center"&&b<=S?t.top+b/2-S/2:r=="start"||r=="center"&&e<0?t.top-o:t.bottom-S+o)-f.top}if(n=="nearest"?t.left<f.left+s?(m=t.left-(f.left+s),e>0&&t.right>f.right+m&&(m=t.right-f.right+s)):t.right>f.right-s&&(m=t.right-f.right+s,e<0&&t.left<f.left+m&&(m=t.left-(f.left+s))):m=(n=="center"?t.left+(t.right-t.left)/2-(f.right-f.left)/2:n=="start"==l?t.left-s:t.right-(f.right-f.left)+s)-f.left,m||g)if(d)c.scrollBy(m,g);else{let b=0,S=0;if(g){let x=h.scrollTop;h.scrollTop+=g/p,S=(h.scrollTop-x)*p}if(m){let x=h.scrollLeft;h.scrollLeft+=m/O,b=(h.scrollLeft-x)*O}t={left:t.left-b,top:t.top-S,right:t.right-b,bottom:t.bottom-S},b&&Math.abs(b-m)<1&&(n="nearest"),S&&Math.abs(S-g)<1&&(r="nearest")}if(d)break;(t.top<f.top||t.bottom>f.bottom||t.left<f.left||t.right>f.right)&&(t={left:Math.max(t.left,f.left),right:Math.min(t.right,f.right),top:Math.max(t.top,f.top),bottom:Math.min(t.bottom,f.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function lb(i,t=!0){let e=i.ownerDocument,n=null,r=null;for(let s=i.parentNode;s&&!(s==e.body||(!t||n)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),t&&!n&&s.scrollWidth>s.clientWidth&&(n=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:n,y:r}}class Zx{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:n}=t;this.set(e,Math.min(t.anchorOffset,e?cn(e):0),n,Math.min(t.focusOffset,n?cn(n):0))}set(t,e,n,r){this.anchorNode=t,this.anchorOffset=e,this.focusNode=n,this.focusOffset=r}}let Hn=null;M.safari&&M.safari_version>=26&&(Hn=!1);function ab(i){if(i.setActive)return i.setActive();if(Hn)return i.focus(Hn);let t=[];for(let e=i;e&&(t.push(e,e.scrollTop,e.scrollLeft),e!=e.ownerDocument);e=e.parentNode);if(i.focus(Hn==null?{get preventScroll(){return Hn={preventScroll:!0},!0}}:void 0),!Hn){Hn=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],s=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=s&&(n.scrollLeft=s)}}}let vO;function Ko(i,t,e=t){let n=vO||(vO=document.createRange());return n.setEnd(i,e),n.setStart(i,t),n}function Ir(i,t,e,n){let r={key:t,code:t,keyCode:e,which:e,cancelable:!0};n&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=n);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,i.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,i.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Xx(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function Ex(i,t){let e=t.focusNode,n=t.focusOffset;if(!e||t.anchorNode!=e||t.anchorOffset!=n)return!1;for(n=Math.min(n,cn(e));;)if(n){if(e.nodeType!=1)return!1;let r=e.childNodes[n-1];r.contentEditable=="false"?n--:(e=r,n=cn(e))}else{if(e==i)return!0;n=Ln(e),e=e.parentNode}}function cb(i){return i instanceof Window?i.pageYOffset>Math.max(0,i.document.documentElement.scrollHeight-i.innerHeight-4):i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function hb(i,t){for(let e=i,n=t;;){if(e.nodeType==3&&n>0)return{node:e,offset:n};if(e.nodeType==1&&n>0){if(e.contentEditable=="false")return null;e=e.childNodes[n-1],n=cn(e)}else if(e.parentNode&&!Ea(e))n=Ln(e),e=e.parentNode;else return null}}function ub(i,t){for(let e=i,n=t;;){if(e.nodeType==3&&n<e.nodeValue.length)return{node:e,offset:n};if(e.nodeType==1&&n<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[n],n=0}else if(e.parentNode&&!Ea(e))n=Ln(e)+1,e=e.parentNode;else return null}}class ai{constructor(t,e,n=!0){this.node=t,this.offset=e,this.precise=n}static before(t,e){return new ai(t.parentNode,Ln(t),e)}static after(t,e){return new ai(t.parentNode,Ln(t)+1,e)}}var Tt=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(Tt||(Tt={}));const Sr=Tt.LTR,Rf=Tt.RTL;function fb(i){let t=[];for(let e=0;e<i.length;e++)t.push(1<<+i[e]);return t}const Lx=fb("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Mx=fb("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),gu=Object.create(null),yi=[];for(let i of["()","[]","{}"]){let t=i.charCodeAt(0),e=i.charCodeAt(1);gu[t]=e,gu[e]=-t}function db(i){return i<=247?Lx[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?Mx[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}const zx=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ei{get dir(){return this.level%2?Rf:Sr}constructor(t,e,n){this.from=t,this.to=e,this.level=n}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,n,r){let s=-1;for(let o=0;o<t.length;o++){let l=t[o];if(l.from<=e&&l.to>=e){if(l.level==n)return o;(s<0||(r!=0?r<0?l.from<e:l.to>e:t[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Ob(i,t){if(i.length!=t.length)return!1;for(let e=0;e<i.length;e++){let n=i[e],r=t[e];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!Ob(n.inner,r.inner))return!1}return!0}const wt=[];function _x(i,t,e,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:t,l=s<n.length?n[s].from:e,a=s?256:r;for(let c=o,h=a,u=a;c<l;c++){let f=db(i.charCodeAt(c));f==512?f=h:f==8&&u==4&&(f=16),wt[c]=f==4?2:f,f&7&&(u=f),h=f}for(let c=o,h=a,u=a;c<l;c++){let f=wt[c];if(f==128)c<l-1&&h==wt[c+1]&&h&24?f=wt[c]=h:wt[c]=256;else if(f==64){let d=c+1;for(;d<l&&wt[d]==64;)d++;let O=c&&h==8||d<e&&wt[d]==8?u==1?1:8:256;for(let p=c;p<d;p++)wt[p]=O;c=d-1}else f==8&&u==1&&(wt[c]=1);h=f,f&7&&(u=f)}}}function Ix(i,t,e,n,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let c=o?n[o-1].to:t,h=o<n.length?n[o].from:e;for(let u=c,f,d,O;u<h;u++)if(d=gu[f=i.charCodeAt(u)])if(d<0){for(let p=l-3;p>=0;p-=3)if(yi[p+1]==-d){let m=yi[p+2],g=m&2?r:m&4?m&1?s:r:0;g&&(wt[u]=wt[yi[p]]=g),l=p;break}}else{if(yi.length==189)break;yi[l++]=u,yi[l++]=f,yi[l++]=a}else if((O=wt[u])==2||O==1){let p=O==r;a=p?0:1;for(let m=l-3;m>=0;m-=3){let g=yi[m+2];if(g&2)break;if(p)yi[m+2]|=2;else{if(g&4)break;yi[m+2]|=4}}}}}function jx(i,t,e,n){for(let r=0,s=n;r<=e.length;r++){let o=r?e[r-1].to:i,l=r<e.length?e[r].from:t;for(let a=o;a<l;){let c=wt[a];if(c==256){let h=a+1;for(;;)if(h==l){if(r==e.length)break;h=e[r++].to,l=r<e.length?e[r].from:t}else if(wt[h]==256)h++;else break;let u=s==1,f=(h<t?wt[h]:n)==1,d=u==f?u?1:2:n;for(let O=h,p=r,m=p?e[p-1].to:i;O>a;)O==m&&(O=e[--p].from,m=p?e[p-1].to:i),wt[--O]=d;a=h}else s=c,a++}}}function bu(i,t,e,n,r,s,o){let l=n%2?2:1;if(n%2==r%2)for(let a=t,c=0;a<e;){let h=!0,u=!1;if(c==s.length||a<s[c].from){let p=wt[a];p!=l&&(h=!1,u=p==16)}let f=!h&&l==1?[]:null,d=h?n:n+1,O=a;t:for(;;)if(c<s.length&&O==s[c].from){if(u)break t;let p=s[c];if(!h)for(let m=p.to,g=c+1;;){if(m==e)break t;if(g<s.length&&s[g].from==m)m=s[g++].to;else{if(wt[m]==l)break t;break}}if(c++,f)f.push(p);else{p.from>a&&o.push(new Ei(a,p.from,d));let m=p.direction==Sr!=!(d%2);wu(i,m?n+1:n,r,p.inner,p.from,p.to,o),a=p.to}O=p.to}else{if(O==e||(h?wt[O]!=l:wt[O]==l))break;O++}f?bu(i,a,O,n+1,r,f,o):a<O&&o.push(new Ei(a,O,d)),a=O}else for(let a=e,c=s.length;a>t;){let h=!0,u=!1;if(!c||a>s[c-1].to){let p=wt[a-1];p!=l&&(h=!1,u=p==16)}let f=!h&&l==1?[]:null,d=h?n:n+1,O=a;t:for(;;)if(c&&O==s[c-1].to){if(u)break t;let p=s[--c];if(!h)for(let m=p.from,g=c;;){if(m==t)break t;if(g&&s[g-1].to==m)m=s[--g].from;else{if(wt[m-1]==l)break t;break}}if(f)f.push(p);else{p.to<a&&o.push(new Ei(p.to,a,d));let m=p.direction==Sr!=!(d%2);wu(i,m?n+1:n,r,p.inner,p.from,p.to,o),a=p.from}O=p.from}else{if(O==t||(h?wt[O-1]!=l:wt[O-1]==l))break;O--}f?bu(i,O,a,n+1,r,f,o):O<a&&o.push(new Ei(O,a,d)),a=O}}function wu(i,t,e,n,r,s,o){let l=t%2?2:1;_x(i,r,s,n,l),Ix(i,r,s,n,l),jx(r,s,n,l),bu(i,r,s,t,e,n,o)}function Dx(i,t,e){if(!i)return[new Ei(0,0,t==Rf?1:0)];if(t==Sr&&!e.length&&!zx.test(i))return pb(i.length);if(e.length)for(;i.length>wt.length;)wt[wt.length]=256;let n=[],r=t==Sr?0:1;return wu(i,r,r,e,0,i.length,n),n}function pb(i){return[new Ei(0,i,0)]}let mb="";function Vx(i,t,e,n,r){var s;let o=n.head-i.from,l=Ei.find(t,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),a=t[l],c=a.side(r,e);if(o==c){let f=l+=r?1:-1;if(f<0||f>=t.length)return null;a=t[l=f],o=a.side(!r,e),c=a.side(r,e)}let h=ae(i.text,o,a.forward(r,e));(h<a.from||h>a.to)&&(h=c),mb=i.text.slice(Math.min(o,h),Math.max(o,h));let u=l==(r?t.length-1:0)?null:t[l+(r?1:-1)];return u&&h==c&&u.level+(r?0:1)<a.level?C.cursor(u.side(!r,e)+i.from,u.forward(r,e)?1:-1,u.level):C.cursor(h+i.from,a.forward(r,e)?-1:1,a.level)}function Bx(i,t,e){for(let n=t;n<e;n++){let r=db(i.charCodeAt(n));if(r==1)return Sr;if(r==2||r==4)return Rf}return Sr}const gb=V.define(),bb=V.define(),wb=V.define(),Sb=V.define(),Su=V.define(),vb=V.define(),xb=V.define(),Zf=V.define(),Xf=V.define(),yb=V.define({combine:i=>i.some(t=>t)}),kb=V.define({combine:i=>i.some(t=>t)}),Qb=V.define();class jr{constructor(t,e,n,r,s,o=!1){this.range=t,this.y=e,this.x=n,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(t){return t.empty?this:new jr(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new jr(C.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Vl=Ct.define({map:(i,t)=>i.map(t)}),$b=Ct.define();function Li(i,t,e){let n=i.facet(Sb);n.length?n[0](t):window.onerror&&window.onerror(String(t),e,void 0,void 0,t)||(e?console.error(e+":",t):console.error(t))}const Ji=V.define({combine:i=>i.length?i[0]:!0});let Wx=0;const Xr=V.define({combine(i){return i.filter((t,e)=>{for(let n=0;n<e;n++)if(i[n].plugin==t.plugin)return!1;return!0})}});class ui{constructor(t,e,n,r,s){this.id=t,this.create=e,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Xr.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(Xr.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:n,eventObservers:r,provide:s,decorations:o}=e||{};return new ui(Wx++,t,n,r,l=>{let a=[];return o&&a.push(Qc.of(c=>{let h=c.plugin(l);return h?o(h):J.none})),s&&a.push(s(l)),a})}static fromClass(t,e){return ui.define((n,r)=>new t(n,r),e)}}class lh{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(n){if(Li(e.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){Li(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(!((e=this.value)===null||e===void 0)&&e.destroy)try{this.value.destroy()}catch(n){Li(t.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Cb=V.define(),Ef=V.define(),Qc=V.define(),Pb=V.define(),Lf=V.define(),kl=V.define(),Tb=V.define();function xO(i,t){let e=i.state.facet(Tb);if(!e.length)return e;let n=e.map(s=>s instanceof Function?s(i):s),r=[];return Ot.spans(n,t.from,t.to,{point(){},span(s,o,l,a){let c=s-t.from,h=o-t.from,u=r;for(let f=l.length-1;f>=0;f--,a--){let d=l[f].spec.bidiIsolate,O;if(d==null&&(d=Bx(t.text,c,h)),a>0&&u.length&&(O=u[u.length-1]).to==c&&O.direction==d)O.to=h,u=O.inner;else{let p={from:c,to:h,direction:d,inner:[]};u.push(p),u=p.inner}}}}),r}const Ab=V.define();function Mf(i){let t=0,e=0,n=0,r=0;for(let s of i.state.facet(Ab)){let o=s(i);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(e=Math.max(e,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:t,right:e,top:n,bottom:r}}const Ro=V.define();class Ye{constructor(t,e,n,r){this.fromA=t,this.toA=e,this.fromB=n,this.toB=r}join(t){return new Ye(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,n=this;for(;e>0;e--){let r=t[e-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),t.splice(e-1,1)}}return t.splice(e,0,n),t}static extendWithRanges(t,e){if(e.length==0)return t;let n=[];for(let r=0,s=0,o=0;;){let l=r<t.length?t[r].fromB:1e9,a=s<e.length?e[s]:1e9,c=Math.min(l,a);if(c==1e9)break;let h=c+o,u=c,f=h;for(;;)if(s<e.length&&e[s]<=u){let d=e[s+1];s+=2,u=Math.max(u,d);for(let O=r;O<t.length&&t[O].fromB<=u;O++)o=t[O].toA-t[O].toB;f=Math.max(f,d+o)}else if(r<t.length&&t[r].fromB<=u){let d=t[r++];u=Math.max(u,d.toB),f=Math.max(f,d.toA),o=d.toA-d.toB}else break;n.push(new Ye(h,f,c,u))}return n}}class Ma{constructor(t,e,n){this.view=t,this.state=e,this.transactions=n,this.flags=0,this.startState=t.state,this.changes=Lt.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new Ye(s,o,l,a))),this.changedRanges=r}static create(t,e,n){return new Ma(t,e,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Yx=[];class zt{constructor(t,e,n=0){this.dom=t,this.length=e,this.flags=n,this.parent=null,t.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Yx}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&Cx(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,e=this.posAtStart){let n=e;for(let r of this.children){if(r==t)return n;n+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,e){return null}domPosFor(t,e){let n=Ln(this.dom),r=this.length?t>0:e>0;return new ai(this.parent.dom,n+(r?1:0),t==0||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof Cc)return t;return null}static get(t){return t.cmTile}}class $c extends zt{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(this.flags&2)return;super.sync(t);let e=this.dom,n=null,r,s=(t==null?void 0:t.node)==e?t:null,o=0;for(let l of this.children){if(l.sync(t),o+=l.length+l.breakAfter,r=n?n.nextSibling:e.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==e)for(;r&&r!=l.dom;)r=yO(r);else e.insertBefore(l.dom,r);n=l.dom}for(r=n?n.nextSibling:e.firstChild,s&&r&&(s.written=!0);r;)r=yO(r);this.length=o}}function yO(i){let t=i.nextSibling;return i.parentNode.removeChild(i),t}class Cc extends $c{constructor(t,e){super(e),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let e=zt.get(t);if(e&&this.owns(e))return e;t=t.parentNode}}blockTiles(t){for(let e=[],n=this,r=0,s=0;;)if(r==n.children.length){if(!e.length)return;n=n.parent,n.breakAfter&&s++,r=e.pop()}else{let o=n.children[r++];if(o instanceof nn)e.push(r),n=o,r=0;else{let l=s+o.length,a=t(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(t,e){let n,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let c=a+l.length;if(t>=a&&t<=c){if(l.isWidget()&&e>=-1&&e<=1){if(l.flags&32)return!0;l.flags&16&&(n=void 0)}(a<t||t==c&&(e<-1?l.length:l.covers(1)))&&(!n||!l.isWidget()&&n.isWidget())&&(n=l,r=t-a),(c>t||t==a&&(e>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=t-a)}}),!n&&!s)throw new Error("No tile at position "+t);return n&&e<0||!s?{tile:n,offset:r}:{tile:s,offset:o}}}class nn extends $c{constructor(t,e){super(t),this.wrapper=e}isBlock(){return!0}covers(t){return this.children.length?t<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,e){let n=new nn(e||document.createElement(t.tagName),t);return e||(n.flags|=4),n}}class Ys extends $c{constructor(t,e){super(t),this.attrs=e}isLine(){return!0}static start(t,e,n){let r=new Ys(e||document.createElement("div"),t);return(!e||!n)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(t,e,n){let r=null,s=-1,o=null,l=-1;function a(h,u){for(let f=0,d=0;f<h.children.length&&d<=u;f++){let O=h.children[f],p=d+O.length;p>=u&&(O.isComposite()?a(O,u-d):(!o||o.isHidden&&(e>0||n&&Nx(o,O)))&&(p>u||O.flags&32)?(o=O,l=u-d):(d<u||O.flags&16&&!O.isHidden)&&(r=O,s=u-d)),d=p}}a(this,t);let c=(e<0?r:o)||r||o;return c?{tile:c,offset:c==r?s:l}:null}coordsIn(t,e){let n=this.resolveInline(t,e,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),e):qx(this)}domIn(t,e){let n=this.resolveInline(t,e);if(n){let{tile:r,offset:s}=n;if(this.dom.contains(r.dom))return r.isText()?new ai(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:e);let o=n.tile.parent,l=!1;for(let a of o.children){if(l)return new ai(a.dom,0);a==n.tile&&(l=!0)}}return new ai(this.dom,0)}}function qx(i){let t=i.dom.lastChild;if(!t)return i.dom.getBoundingClientRect();let e=ga(t);return e[e.length-1]||null}function Nx(i,t){let e=i.coordsIn(0,1),n=t.coordsIn(0,1);return e&&n&&n.top<e.bottom}class ve extends $c{constructor(t,e){super(t),this.mark=e}get domAttrs(){return this.mark.attrs}static of(t,e){let n=new ve(e||document.createElement(t.tagName),t);return e||(n.flags|=4),n}}class nr extends zt{constructor(t,e){super(t,e.length),this.text=e}sync(t){this.flags&2||(super.sync(t),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(t,e){let n=this.dom.nodeValue.length;t>n&&(t=n);let r=t,s=t,o=0;t==0&&e<0||t==n&&e>=0?M.chrome||M.gecko||(t?(r--,o=1):s<n&&(s++,o=-1)):e<0?r--:s<n&&s++;let l=Ko(this.dom,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:e>=0)?0:l.length-1];return M.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,c=>c.width)||a),o?La(a,o<0):a||null}static of(t,e){let n=new nr(e||document.createTextNode(t),t);return e||(n.flags|=2),n}}class vr extends zt{constructor(t,e,n,r){super(t,e,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return this.flags&48?!1:(this.flags&(t<0?64:128))>0}coordsIn(t,e){return this.coordsInWidget(t,e,!1)}coordsInWidget(t,e,n){let r=this.widget.coordsAt(this.dom,t,e);if(r)return r;if(n)return La(this.dom.getBoundingClientRect(),this.length?t==0:e<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:t>0;for(let a=l?s.length-1:0;o=s[a],!(t>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return La(o,!l)}}get overrideDOMText(){if(!this.length)return Y.empty;let{root:t}=this;if(!t)return Y.empty;let e=this.posAtStart;return t.view.state.doc.slice(e,e+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,e,n,r,s){return s||(s=t.toDOM(e),t.editable||(s.contentEditable="false")),new vr(s,n,t,r)}}class za extends zt{constructor(t){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),super(e,0,t)}get isHidden(){return!0}get overrideDOMText(){return Y.empty}coordsIn(t){return this.dom.getBoundingClientRect()}}class Gx{constructor(t){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t}advance(t,e,n){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;t||e>0;)if(r.isComposite())if(o){if(!t)break;n&&n.break(),t--,o=!1}else if(s==r.children.length){if(!t&&!l.length)break;n&&n.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],c=a.breakAfter;(e>0?a.length<=t:a.length<t)&&(!n||n.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!c,s++,t-=a.length):(l.push({tile:r,index:s}),r=a,s=0,n&&a.isComposite()&&n.enter(a))}else if(s==r.length)o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++;else if(t){let a=Math.min(t,r.length-s);n&&n.skip(r,s,s+a),t-=a,s+=a}else break;return this.tile=r,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Ux{constructor(t,e,n,r){this.from=t,this.to=e,this.wrapper=n,this.rank=r}}class Hx{constructor(t,e,n){this.cache=t,this.root=e,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(t,e,n,r){var s;this.flushBuffer();let o=this.ensureMarks(e,n),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+t.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new nr(l.dom,l.text+t);a.parent=o}else o.append(r||nr.of(t,(s=this.cache.find(nr))===null||s===void 0?void 0:s.dom));this.pos+=t.length,this.afterWidget=null}addComposition(t,e){let n=this.curLine;n.dom!=e.line.dom&&(n.setDOM(this.cache.reused.has(e.line)?ah(e.line.dom):e.line.dom),this.cache.reused.set(e.line,2));let r=n;for(let l=e.marks.length-1;l>=0;l--){let a=e.marks[l],c=r.lastChild;if(c instanceof ve&&c.mark.eq(a.mark))c.dom!=a.dom&&c.setDOM(ah(a.dom)),r=c;else{if(this.cache.reused.get(a)){let u=zt.get(a.dom);u&&u.setDOM(ah(a.dom))}let h=ve.of(a.mark,a.dom);r.append(h),r=h}this.cache.reused.set(a,2)}let s=zt.get(t.text);s&&this.cache.reused.set(s,2);let o=new nr(t.text,t.text.nodeValue);o.flags|=8,this.pos=t.range.toB,r.append(o)}addInlineWidget(t,e,n){let r=this.afterWidget&&t.flags&48&&(this.afterWidget.flags&48)==(t.flags&48);r||this.flushBuffer();let s=this.ensureMarks(e,n);!r&&!(t.flags&16)&&s.append(this.getBuffer(1)),s.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,e,n){this.flushBuffer(),this.ensureMarks(e,n).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){let e=this.afterWidget||this.lastBlock;e.length+=t,this.pos+=t}addLineStart(t,e){var n;t||(t=Rb);let r=Ys.start(t,e||((n=this.cache.find(Ys))===null||n===void 0?void 0:n.dom),!!e);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,e){var n;let r=this.curLine;for(let s=t.length-1;s>=0;s--){let o=t[s],l;if(e>0&&(l=r.lastChild)&&l instanceof ve&&l.mark.eq(o))r=l,e--;else{let a=ve.of(o,(n=this.cache.find(ve,c=>c.mark.eq(o)))===null||n===void 0?void 0:n.dom);r.append(a),r=a,e=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;(!t||!kO(this.curLine,!1)||t.dom.nodeName!="BR"&&t.isWidget()&&!(M.ios&&kO(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(ch,0,32)||new vr(ch.toDOM(),0,ch,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to<this.pos&&this.wrappers.splice(t,1);for(let t=this.blockWrappers;t.value&&t.from<=this.pos;t.next())if(t.to>=this.pos){let e=t.rank*102+t.value.rank,n=new Ux(t.from,t.to,t.value,e),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let e=this.root;for(let n of this.wrappers){let r=e.lastChild;if(n.from<this.pos&&r instanceof nn&&r.wrapper.eq(n.wrapper))e=r;else{let s=nn.of(n.wrapper,(t=this.cache.find(nn,o=>o.wrapper.eq(n.wrapper)))===null||t===void 0?void 0:t.dom);e.append(s),e=s}}return e}blockPosCovered(){let t=this.lastBlock;return t!=null&&!t.breakAfter&&(!t.isWidget()||(t.flags&160)>0)}getBuffer(t){let e=2|(t<0?16:32),n=this.cache.find(za,void 0,1);return n&&(n.flags=e),n||new za(e)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Fx{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(t,r.length);return s?null:r.slice(0,l)}let e=Math.min(this.text.length,this.textOff+t),n=this.text.slice(this.textOff,e);return this.textOff=e,n}}const _a=[vr,Ys,nr,ve,za,nn,Cc];for(let i=0;i<_a.length;i++)_a[i].bucket=i;class Kx{constructor(t){this.view=t,this.buckets=_a.map(()=>[]),this.index=_a.map(()=>0),this.reused=new Map}add(t){let e=t.constructor.bucket,n=this.buckets[e];n.length<6?n.push(t):n[this.index[e]=(this.index[e]+1)%6]=t}find(t,e,n=2){let r=t.bucket,s=this.buckets[r],o=this.index[r];for(let l=s.length-1;l>=0;l--){let a=(l+o)%s.length,c=s[a];if((!e||e(c))&&!this.reused.has(c))return s.splice(a,1),a<o&&this.index[r]--,this.reused.set(c,n),c}return null}findWidget(t,e,n){let r=this.buckets[0];if(r.length)for(let s=0,o=0;;s++){if(s==r.length){if(o)return null;o=1,s=0}let l=r[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(t):l.widget.constructor==t.constructor&&t.updateDOM(l.dom,this.view,l.widget)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==t&&l.length==e&&(l.flags&497)==n?(this.reused.set(l,1),l):(this.reused.set(l,2),new vr(l.dom,e,t,l.flags&-498|n))}}reuse(t){return this.reused.set(t,1),t}maybeReuse(t,e=2){if(!this.reused.has(t))return this.reused.set(t,e),t.dom}clear(){for(let t=0;t<this.buckets.length;t++)this.buckets[t].length=this.index[t]=0}}class Jx{constructor(t,e,n,r,s){this.view=t,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new Kx(t),this.text=new Fx(t.state.doc),this.builder=new Hx(this.cache,new Cc(t,t.contentDOM),Ot.iter(n)),this.cache.reused.set(e,2),this.old=new Gx(e),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(t,e){let n=e&&this.getCompositionContext(e.text);for(let r=0,s=0,o=0;;){let l=o<t.length?t[o++]:null,a=l?l.fromA:this.old.root.length;if(a>r){let c=a-r;this.preserve(c,!o,!l),r=a,s+=c}if(!l)break;e&&l.fromA<=e.range.fromA&&l.toA>=e.range.toA?(this.forward(l.fromA,e.range.fromA,e.range.fromA<e.range.toA?1:-1),this.emit(s,e.range.fromB),this.cache.clear(),this.builder.addComposition(e,n),this.text.skip(e.range.toB-e.range.fromB),this.forward(e.range.fromA,l.toA),this.emit(e.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,r=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(t,e,n){let r=iy(this.old),s=this.openMarks;this.old.advance(t,n?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let c=a>0||l<o.length?vr.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);c.flags&256?(c.flags&=-2,this.builder.addBlockWidget(c)):(this.builder.ensureLine(null),this.builder.addInlineWidget(c,r,s),s=r.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,r,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),r,s)),s=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof za)this.cache.add(o);else if(o instanceof ve)this.builder.ensureLine(null),this.builder.addMark(o,r,s),this.cache.reused.set(o,1),s=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof ve&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof ve&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,e){let n=null,r=this.builder,s=0,o=Ot.spans(this.decorations,t,e,{point:(l,a,c,h,u,f)=>{if(c instanceof wr){if(this.disallowBlockEffectsFor[f]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=h.length,u>h.length)r.continueWidget(a-l);else{let d=c.widget||(c.block?qs.block:qs.inline),O=ty(c),p=this.cache.findWidget(d,a-l,O)||vr.of(d,this.view,a-l,O);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(p)):(r.ensureLine(n),r.addInlineWidget(p,h,u))}n=null}else n=ey(n,c);a>l&&this.text.skip(a-l)},span:(l,a,c,h)=>{for(let u=l;u<a;){let f=this.text.next(Math.min(512,a-u));f==null?(r.addLineStartIfNotCovered(n),r.addBreak(),u++):(r.ensureLine(n),r.addText(f,c,u==l?h:c.length),u+=f.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=o>s,this.openMarks=o}forward(t,e,n=1){e-t<=10?this.old.advance(e-t,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(e-t-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(t){let e=[],n=null;for(let r=t.parentNode;;r=r.parentNode){let s=zt.get(r);if(r==this.view.contentDOM)break;s instanceof ve?e.push(s):s!=null&&s.isLine()?n=s:s instanceof nn||(r.nodeName=="DIV"&&!n&&r!=this.view.contentDOM?n=new Ys(r,Rb):n||e.push(ve.of(new xl({tagName:r.nodeName.toLowerCase(),attributes:Px(r)}),r)))}return{line:n,marks:e}}}function kO(i,t){let e=n=>{for(let r of n.children)if((t?r.isText():r.length)||e(r))return!0;return!1};return e(i)}function ty(i){let t=i.isReplace?(i.startSide<0?64:0)|(i.endSide>0?128:0):i.startSide>0?32:16;return i.block&&(t|=256),t}const Rb={class:"cm-line"};function ey(i,t){let e=t.spec.attributes,n=t.spec.class;return!e&&!n||(i||(i={class:"cm-line"}),e&&Tf(e,i),n&&(i.class+=" "+n)),i}function iy(i){let t=[];for(let e=i.parents.length;e>1;e--){let n=e==i.parents.length?i.tile:i.parents[e].tile;n instanceof ve&&t.push(n.mark)}return t}function ah(i){let t=zt.get(i);return t&&t.setDOM(i.cloneNode()),i}class qs extends jn{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}qs.inline=new qs("span");qs.block=new qs("div");const ch=new class extends jn{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class QO{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=J.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Cc(t,t.contentDOM),this.updateInner([new Ye(0,0,0,t.state.doc.length)],null)}update(t){var e;let n=t.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:h,toA:u})=>u<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((e=this.domChanged)===null||e===void 0)&&e.newSel?r=this.domChanged.newSel.head:!uy(t.changes,this.hasComposition)&&!t.selectionSet&&(r=t.state.selection.main.head));let s=r>-1?ry(this.view,t.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:u}=this.hasComposition;n=new Ye(h,u,t.changes.mapPos(h,-1),t.changes.mapPos(u,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(M.ie||M.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=ly(o,this.decorations,t.changes);a.length&&(n=Ye.extendWithRanges(n,a));let c=cy(l,this.blockWrappers,t.changes);return c.length&&(n=Ye.extendWithRanges(n,c)),s&&!n.some(h=>h.fromA<=s.range.fromA&&h.toA>=s.range.toA)&&(n=s.range.addToSet(n.slice())),this.tile.flags&2&&n.length==0?!1:(this.updateInner(n,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(e||t.length){let o=this.tile,l=new Jx(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);e&&zt.get(e.text)&&l.cache.reused.set(zt.get(e.text),2),this.tile=l.run(t,e),vu(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=M.chrome||M.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||n.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof hh&&r.push(s.dom);n.updateGaps(r)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let n of e.effects)n.is($b)&&(this.editContextFormatting=n.value)}updateSelection(t=!1,e=!1){(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,s=r==n,o=!s&&!(this.view.state.facet(Ji)||n.tabIndex>-1)&&Io(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(s||e||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,c,h;if(a.empty?h=c=this.inlineDOMNearPos(a.anchor,a.assoc||1):(h=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),c=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),M.gecko&&a.empty&&!this.hasComposition&&ny(c)){let f=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(f,c.node.childNodes[c.offset]||null)),c=h=new ai(f,0),l=!0}let u=this.view.observer.selectionRange;(l||!u.focusNode||(!jo(c.node,c.offset,u.anchorNode,u.anchorOffset)||!jo(h.node,h.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{M.android&&M.chrome&&n.contains(u.focusNode)&&hy(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let f=Fo(this.view.root);if(f)if(a.empty){if(M.gecko){let d=sy(c.node,c.offset);if(d&&d!=3){let O=(d==1?hb:ub)(c.node,c.offset);O&&(c=new ai(O.node,O.offset))}}f.collapse(c.node,c.offset),a.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(c.node,c.offset);try{f.extend(h.node,h.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([c,h]=[h,c]),d.setEnd(h.node,h.offset),d.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(d)}o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,h)),this.impreciseAnchor=c.precise?null:new ai(u.anchorNode,u.anchorOffset),this.impreciseHead=h.precise?null:new ai(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&jo(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,n=Fo(t.root),{anchorNode:r,anchorOffset:s}=t.observer.selectionRange;if(!n||!e.empty||!e.assoc||!n.modify)return;let o=this.lineAt(e.head,e.assoc);if(!o)return;let l=o.posAtStart;if(e.head==l||e.head==l+o.length)return;let a=this.coordsAt(e.head,-1),c=this.coordsAt(e.head,1);if(!a||!c||a.bottom>c.top)return;let h=this.domAtPos(e.head+e.assoc,e.assoc);n.collapse(h.node,h.offset),n.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let u=t.observer.selectionRange;t.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=e.from&&n.collapse(r,s)}posFromDOM(t,e){let n=this.tile.nearest(t);if(!n)return this.tile.dom.compareDocumentPosition(t)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let s;if(t==n.dom)s=n.dom.childNodes[e];else{let o=cn(t)==0?0:e==0?-1:1;for(;;){let l=t.parentNode;if(l==n.dom)break;o==0&&l.firstChild!=l.lastChild&&(t==l.firstChild?o=-1:o=1),t=l}o<0?s=t:s=t.nextSibling}if(s==n.dom.firstChild)return r;for(;s&&!zt.get(s);)s=s.nextSibling;if(!s)return r+n.length;for(let o=0,l=r;;o++){let a=n.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return n.isText()?t==n.dom?r+e:r+(e?n.length:0):r}domAtPos(t,e){let{tile:n,offset:r}=this.tile.resolveBlock(t,e);return n.isWidget()?n.domPosFor(t,e):n.domIn(r,e)}inlineDOMNearPos(t,e){let n,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((c,h)=>{if(c.isWidget()){if(c.flags&32&&h>=t)return!0;c.flags&16&&(s=!0)}else{let u=h+c.length;if(h<=t&&(n=c,r=t-h,s=u<t),u>=t&&!o&&(o=c,l=t-h,a=h>t),h>t&&o)return!0}}),!n&&!o?this.domAtPos(t,e):(s&&o?n=null:a&&n&&(o=null),n&&e<0||!o?n.domIn(r,e):o.domIn(l,e))}coordsAt(t,e){let{tile:n,offset:r}=this.tile.resolveBlock(t,e);return n.isWidget()?n.widget instanceof hh?null:n.coordsInWidget(r,e,!0):n.coordsIn(r,e)}lineAt(t,e){let{tile:n}=this.tile.resolveBlock(t,e);return n.isLine()?n:null}coordsForChar(t){let{tile:e,offset:n}=this.tile.resolveBlock(t,1);if(!e.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=ae(s.text,o);if(l==o)return null;let a=Ko(s.dom,o,l).getClientRects();for(let c=0;c<a.length;c++){let h=a[c];if(c==a.length-1||h.top<h.bottom&&h.left<h.right)return h}}return null}return r(e,n)}measureVisibleLineHeights(t){let e=[],{from:n,to:r}=t,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==Tt.LTR,c=0,h=(u,f,d)=>{for(let O=0;O<u.children.length&&!(f>r);O++){let p=u.children[O],m=f+p.length,g=p.dom.getBoundingClientRect(),{height:b}=g;if(d&&!O&&(c+=g.top-d.top),p instanceof nn)m>n&&h(p,f,g);else if(f>=n&&(c>0&&e.push(-c),e.push(b+c),c=0,o)){let S=p.dom.lastChild,x=S?ga(S):[];if(x.length){let y=x[x.length-1],k=a?y.right-g.left:g.right-y.left;k>l&&(l=k,this.minWidth=s,this.minWidthFrom=f,this.minWidthTo=m)}}d&&O==u.children.length-1&&(c+=d.bottom-g.bottom),f=m+p.breakAfter}};return h(this.tile,0,null),e}textDirectionAt(t){let{tile:e}=this.tile.resolveBlock(t,1);return getComputedStyle(e.dom).direction=="rtl"?Tt.RTL:Tt.LTR}measureTextSize(){let t=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let c of o.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let h=ga(c.dom);if(h.length!=1)return;l+=h[0].width,a=h[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(t)return t;let e=document.createElement("div"),n,r,s;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(e);let o=ga(e.firstChild)[0];n=e.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:n,e.remove()}),{lineHeight:n,charWidth:r,textHeight:s}}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let n=0,r=0;;r++){let s=r==e.viewports.length?null:e.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>n){let l=(e.lineBlockAt(o).bottom-e.lineBlockAt(n).top)/this.view.scaleY;t.push(J.replace({widget:new hh(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return J.set(t)}updateDeco(){let t=1,e=this.view.state.facet(Qc).map(s=>(this.dynamicDecorationMap[t++]=typeof s=="function")?s(this.view):s),n=!1,r=this.view.state.facet(Lf).map((s,o)=>{let l=typeof s=="function";return l&&(n=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[t++]=n,e.push(Ot.join(r))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;this.blockWrappers=this.view.state.facet(Pb).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(t){var e;if(t.isSnapshot){let h=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=h.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let h of this.view.state.facet(Qb))try{if(h(this.view,t.range,t))return!0}catch(u){Li(this.view.state,u,"scroll handler")}let{range:n}=t,r=this.coordsAt(n.head,(e=n.assoc)!==null&&e!==void 0?e:n.empty?0:n.head>n.anchor?-1:1),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=Mf(this.view),l={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:a,offsetHeight:c}=this.view.scrollDOM;if(Rx(this.view.scrollDOM,l,n.head<n.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,a),-a),Math.max(Math.min(t.yMargin,c),-c),this.view.textDirection==Tt.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(r.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||r.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(n.head,1);h&&h.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(t){let e=n=>n.isWidget()||n.children.some(e);return e(this.tile.resolveBlock(t,1).tile)}destroy(){vu(this.tile)}}function vu(i,t){let e=t==null?void 0:t.get(i);if(e!=1){e==null&&i.destroy();for(let n of i.children)vu(n,t)}}function ny(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function Zb(i,t){let e=i.observer.selectionRange;if(!e.focusNode)return null;let n=hb(e.focusNode,e.focusOffset),r=ub(e.focusNode,e.focusOffset),s=n||r;if(r&&n&&r.node!=n.node){let l=zt.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(i.docView.lastCompositionAfterCursor){let a=zt.get(n.node);!a||a.isText()&&a.text!=n.node.nodeValue||(s=r)}}if(i.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=t-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function ry(i,t,e){let n=Zb(i,e);if(!n)return null;let{node:r,from:s,to:o}=n,l=r.nodeValue;if(/[\n\r]/.test(l)||i.state.doc.sliceString(n.from,n.to)!=l)return null;let a=t.invertedDesc;return{range:new Ye(a.mapPos(s),a.mapPos(o),s,o),text:r}}function sy(i,t){return i.nodeType!=1?0:(t&&i.childNodes[t-1].contentEditable=="false"?1:0)|(t<i.childNodes.length&&i.childNodes[t].contentEditable=="false"?2:0)}let oy=class{constructor(){this.changes=[]}compareRange(t,e){_r(t,e,this.changes)}comparePoint(t,e){_r(t,e,this.changes)}boundChange(t){_r(t,t,this.changes)}};function ly(i,t,e){let n=new oy;return Ot.compare(i,t,e,n),n.changes}class ay{constructor(){this.changes=[]}compareRange(t,e){_r(t,e,this.changes)}comparePoint(){}boundChange(t){_r(t,t,this.changes)}}function cy(i,t,e){let n=new ay;return Ot.compare(i,t,e,n),n.changes}function hy(i,t){for(let e=i;e&&e!=t;e=e.assignedSlot||e.parentNode)if(e.nodeType==1&&e.contentEditable=="false")return!0;return!1}function uy(i,t){let e=!1;return t&&i.iterChangedRanges((n,r)=>{n<t.to&&r>t.from&&(e=!0)}),e}class hh extends jn{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function fy(i,t,e=1){let n=i.charCategorizer(t),r=i.doc.lineAt(t),s=t-r.from;if(r.length==0)return C.cursor(t);s==0?e=1:s==r.length&&(e=-1);let o=s,l=s;e<0?o=ae(r.text,s,!1):l=ae(r.text,s);let a=n(r.text.slice(o,l));for(;o>0;){let c=ae(r.text,o,!1);if(n(r.text.slice(c,o))!=a)break;o=c}for(;l<r.length;){let c=ae(r.text,l);if(n(r.text.slice(l,c))!=a)break;l=c}return C.range(o+r.from,l+r.from)}function dy(i,t,e,n,r){let s=Math.round((n-t.left)*i.defaultCharacterWidth);if(i.lineWrapping&&e.height>i.defaultLineHeight*1.5){let l=i.viewState.heightOracle.textHeight,a=Math.floor((r-e.top-(i.defaultLineHeight-l)*.5)/l);s+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(e.from,e.to);return e.from+xx(o,s,i.state.tabSize)}function xu(i,t,e){let n=i.lineBlockAt(t);if(Array.isArray(n.type)){let r;for(let s of n.type){if(s.from>t)break;if(!(s.to<t)){if(s.from<t&&s.to>t)return s;(!r||s.type==pe.Text&&(r.type!=s.type||(e<0?s.from<t:s.to>t)))&&(r=s)}}return r||n}return n}function Oy(i,t,e,n){let r=xu(i,t.head,t.assoc||-1),s=!n||r.type!=pe.Text||!(i.lineWrapping||r.widgetLineBreaks)?null:i.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head);if(s){let o=i.dom.getBoundingClientRect(),l=i.textDirectionAt(r.from),a=i.posAtCoords({x:e==(l==Tt.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return C.cursor(a,e?-1:1)}return C.cursor(e?r.to:r.from,e?-1:1)}function $O(i,t,e,n){let r=i.state.doc.lineAt(t.head),s=i.bidiSpans(r),o=i.textDirectionAt(r.from);for(let l=t,a=null;;){let c=Vx(r,s,o,l,e),h=mb;if(!c){if(r.number==(e?i.state.doc.lines:1))return l;h=`
36
36
  `,r=i.state.doc.line(r.number+(e?1:-1)),s=i.bidiSpans(r),c=i.visualLineSide(r,!e)}if(a){if(!a(h))return l}else{if(!n)return c;a=n(h)}l=c}}function py(i,t,e){let n=i.state.charCategorizer(t),r=n(e);return s=>{let o=n(s);return r==tn.Space&&(r=o),r==o}}function my(i,t,e,n){let r=t.head,s=e?1:-1;if(r==(e?i.state.doc.length:0))return C.cursor(r,t.assoc);let o=t.goalColumn,l,a=i.contentDOM.getBoundingClientRect(),c=i.coordsAtPos(r,t.assoc||((t.empty?e:t.head==t.from)?1:-1)),h=i.documentTop;if(c)o==null&&(o=c.left-a.left),l=s<0?c.top:c.bottom;else{let O=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(r-O.from))),l=(s<0?O.top:O.bottom)+h}let u=a.left+o,f=i.viewState.heightOracle.textHeight>>1,d=n??f;for(let O=0;;O+=f){let p=l+(d+O)*s,m=yu(i,{x:u,y:p},!1,s);if(e?p>a.bottom:p<a.top)return C.cursor(m.pos,m.assoc);let g=i.coordsAtPos(m.pos,m.assoc),b=g?(g.top+g.bottom)/2:0;if(!g||(e?b>l:b<l))return C.cursor(m.pos,m.assoc,void 0,o)}}function Do(i,t,e){for(;;){let n=0;for(let r of i)r.between(t-1,t+1,(s,o,l)=>{if(t>s&&t<o){let a=n||e||(t-s<o-t?-1:1);t=a<0?s:o,n=a}});if(!n)return t}}function Xb(i,t){let e=null;for(let n=0;n<t.ranges.length;n++){let r=t.ranges[n],s=null;if(r.empty){let o=Do(i,r.from,0);o!=r.from&&(s=C.cursor(o,-1))}else{let o=Do(i,r.from,-1),l=Do(i,r.to,1);(o!=r.from||l!=r.to)&&(s=C.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(e||(e=t.ranges.slice()),e[n]=s)}return e?C.create(e,t.mainIndex):t}function uh(i,t,e){let n=Do(i.state.facet(kl).map(r=>r(i)),e.from,t.head>e.from?-1:1);return n==e.from?e:C.cursor(n,n<e.from?1:-1)}class Xi{constructor(t,e){this.pos=t,this.assoc=e}}function yu(i,t,e,n){let r=i.contentDOM.getBoundingClientRect(),s=r.top+i.viewState.paddingTop,{x:o,y:l}=t,a=l-s,c;for(;;){if(a<0)return new Xi(0,1);if(a>i.viewState.docHeight)return new Xi(i.state.doc.length,-1);if(c=i.elementAtHeight(a),n==null)break;if(c.type==pe.Text){if(n<0?c.to<i.viewport.from:c.from>i.viewport.to)break;let f=i.docView.coordsAt(n<0?c.from:c.to,n>0?-1:1);if(f&&(n<0?f.top<=a+s:f.bottom>=a+s))break}let u=i.viewState.heightOracle.textHeight/2;a=n>0?c.bottom+u:c.top-u}if(i.viewport.from>=c.to||i.viewport.to<=c.from){if(e)return null;if(c.type==pe.Text){let u=dy(i,r,c,o,l);return new Xi(u,u==c.from?1:-1)}}if(c.type!=pe.Text)return a<(c.top+c.bottom)/2?new Xi(c.from,1):new Xi(c.to,-1);let h=i.docView.lineAt(c.from,2);return(!h||h.length!=c.length)&&(h=i.docView.lineAt(c.from,-2)),new gy(i,o,l,i.textDirectionAt(c.from)).scanTile(h,c.from)}class gy{constructor(t,e,n,r){this.view=t,this.x=e,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(t){return(!this.line||this.line.from>t||this.line.to<t)&&(this.line=this.view.state.doc.lineAt(t),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(t,e){let{line:n,spans:r}=this.bidiSpansAt(t);return r[Ei.find(r,t-n.from,-1,e)].level==this.baseDir}dirAt(t,e){let{line:n,spans:r}=this.bidiSpansAt(t);return r[Ei.find(r,t-n.from,-1,e)].dir}bidiIn(t,e){let{spans:n,line:r}=this.bidiSpansAt(t);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<e)}scan(t,e,n=!1){let r=0,s=t.length-1,o=new Set,l=this.bidiIn(t[0],t[s]),a,c,h=-1,u=1e9,f;t:for(;r<s;){let O=s-r,p=r+s>>1;e:if(o.has(p)){let g=r+Math.floor(Math.random()*O);for(let b=0;b<O;b++){if(!o.has(g)){p=g;break e}g++,g==s&&(g=r)}break t}o.add(p);let m=e(p);if(m)for(let g=0;g<m.length;g++){let b=m[g],S=0;if(!(b.width==0&&m.length>1)){if(b.bottom<this.y)(!a||a.bottom<b.bottom)&&(a=b),S=1;else if(b.top>this.y)(!c||c.top>b.top)&&(c=b),S=-1;else{let x=b.left>this.x?this.x-b.left:b.right<this.x?this.x-b.right:0,y=Math.abs(x);y<u&&(h=p,u=y,f=b),x&&(S=x<0==(this.baseDir==Tt.LTR)?-1:1)}S==-1&&(!l||this.baseDirAt(t[p],1))?s=p:S==1&&(!l||this.baseDirAt(t[p+1],-1))&&(r=p+1)}}}if(!f){let O=a&&(!c||this.y-a.bottom<c.top-this.y)?a:c;return this.y=(O.top+O.bottom)/2,this.scan(t,e,!0)}if(u&&!n){let{top:O,bottom:p}=f;if(a&&a.bottom>(O+O+p)/3)return this.y=a.bottom-1,this.scan(t,e,!0);if(c&&c.top<(O+p+p)/3)return this.y=c.top+1,this.scan(t,e,!0)}let d=(l?this.dirAt(t[h],1):this.baseDir)==Tt.LTR;return{i:h,after:this.x>(f.left+f.right)/2==d}}scanText(t,e){let n=[];for(let s=0;s<t.length;s=ae(t.text,s))n.push(e+s);n.push(e+t.length);let r=this.scan(n,s=>{let o=n[s]-e,l=n[s+1]-e;return Ko(t.dom,o,l).getClientRects()});return r.after?new Xi(n[r.i+1],-1):new Xi(n[r.i],1)}scanTile(t,e){if(!t.length)return new Xi(e,1);if(t.children.length==1){let l=t.children[0];if(l.isText())return this.scanText(l,e);if(l.isComposite())return this.scanTile(l,e)}let n=[e];for(let l=0,a=e;l<t.children.length;l++)n.push(a+=t.children[l].length);let r=this.scan(n,l=>{let a=t.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Ko(a.dom,0,a.length)).getClientRects()}),s=t.children[r.i],o=n[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new Xi(n[r.i+1],-1):new Xi(o,1)}}const Zr="￿";class by{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineSeparator=e.state.facet(K.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Zr}readRange(t,e){if(!t)return this;let n=t.parentNode;for(let r=t;;){this.findPointBefore(n,r);let s=this.text.length;this.readNode(r);let o=zt.get(r),l=r.nextSibling;if(l==e){o!=null&&o.breakAfter&&!l&&n!=this.view.contentDOM&&this.lineBreak();break}let a=zt.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Ea(r))||Ea(l)&&(r.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!Sy(l,e)&&this.lineBreak(),r=l}return this.findPointBefore(n,e),this}readTextNode(t){let e=t.nodeValue;for(let n of this.points)n.node==t&&(n.pos=this.text.length+Math.min(n.offset,e.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=e.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(l=r.exec(e))&&(s=l.index,o=l[0].length),this.append(e.slice(n,s<0?e.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==t&&a.pos>this.text.length&&(a.pos-=o-1);n=s+o}}readNode(t){let e=zt.get(t),n=e&&e.overrideDOMText;if(n!=null){this.findPointInside(t,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let n of this.points)n.node==t&&t.childNodes[n.offset]==e&&(n.pos=this.text.length)}findPointInside(t,e){for(let n of this.points)(t.nodeType==3?n.node==t:t.contains(n.node))&&(n.pos=this.text.length+(wy(t,n.node,n.offset)?e:0))}}function wy(i,t,e){for(;;){if(!t||e<cn(t))return!1;if(t==i)return!0;e=Ln(t)+1,t=t.parentNode}}function Sy(i,t){let e;for(;!(i==t||!i);i=i.nextSibling){let n=zt.get(i);if(!(n!=null&&n.isWidget()))return!1;n&&(e||(e=[])).push(n)}if(e)for(let n of e){let r=n.overrideDOMText;if(r!=null&&r.length)return!1}return!0}class CO{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class vy{constructor(t,e,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:o}=t.docView,l=t.state.selection;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=Eb(t.docView.tile,e,n,0))){let a=s||o?[]:yy(t),c=new by(a,t);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=ky(a,this.bounds.from)}else{let a=t.observer.selectionRange,c=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!mu(t.contentDOM,a.focusNode)?l.main.head:t.docView.posFromDOM(a.focusNode,a.focusOffset),h=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!mu(t.contentDOM,a.anchorNode)?l.main.anchor:t.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=t.viewport;if((M.ios||M.chrome)&&l.main.empty&&c!=h&&(u.from>0||u.to<t.state.doc.length)){let f=Math.min(c,h),d=Math.max(c,h),O=u.from-f,p=u.to-d;(O==0||O==1||f==0)&&(p==0||p==-1||d==t.state.doc.length)&&(c=0,h=t.state.doc.length)}if(t.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(C.range(h,c));else if(t.lineWrapping&&h==c&&!(l.main.empty&&l.main.head==c)&&t.inputState.lastTouchTime>Date.now()-100){let f=t.coordsAtPos(c,-1),d=0;f&&(d=t.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=C.create([C.cursor(c,d)])}else this.newSel=C.single(h,c)}}}function Eb(i,t,e,n){if(i.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,c=n,h=n;a<i.children.length;a++){let u=i.children[a],f=c+u.length;if(c<t&&f>e)return Eb(u,t,e,c);if(f>=t&&r==-1&&(r=a,s=c),c>e&&u.dom.parentNode==i.dom){o=a,l=h;break}h=f,c=f+u.breakAfter}return{from:s,to:l<0?n+i.length:l,startDOM:(r?i.children[r-1].dom.nextSibling:null)||i.dom.firstChild,endDOM:o<i.children.length&&o>=0?i.children[o].dom:null}}else return i.isText()?{from:n,to:n+i.length,startDOM:i.dom,endDOM:i.dom.nextSibling}:null}function Lb(i,t){let e,{newSel:n}=t,{state:r}=i,s=r.selection.main,o=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(t.bounds){let{from:l,to:a}=t.bounds,c=s.from,h=null;(o===8||M.android&&t.text.length<a-l)&&(c=s.to,h="end");let u=r.doc.sliceString(l,a,Zr),f,d;!s.empty&&s.from>=l&&s.to<=a&&(t.typeOver||u!=t.text)&&u.slice(0,s.from-l)==t.text.slice(0,s.from-l)&&u.slice(s.to-l)==t.text.slice(f=t.text.length-(u.length-(s.to-l)))?e={from:s.from,to:s.to,insert:Y.of(t.text.slice(s.from-l,f).split(Zr))}:(d=Mb(u,t.text,c-l,h))&&(M.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==Zr+Zr&&d.toB--,e={from:l+d.from,to:l+d.toA,insert:Y.of(t.text.slice(d.from,d.toB).split(Zr))})}else n&&(!i.hasFocus&&r.facet(Ji)||Ia(n,s))&&(n=null);if(!e&&!n)return!1;if((M.mac||M.android)&&e&&e.from==e.to&&e.from==s.head-1&&/^\. ?$/.test(e.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&e.insert.length==2&&(n=C.single(n.main.anchor-1,n.main.head-1)),e={from:e.from,to:e.to,insert:Y.of([e.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).to<s.to&&i.docView.lineHasWidget(s.to)&&i.inputState.insertingTextAt>Date.now()-50?e={from:s.from,to:s.to,insert:r.toText(i.inputState.insertingText)}:M.chrome&&e&&e.from==e.to&&e.from==s.head&&e.insert.toString()==`
37
- `&&i.lineWrapping&&(n&&(n=C.single(n.main.anchor-1,n.main.head-1)),e={from:s.from,to:s.to,insert:Y.of([" "])}),e)return zf(i,e,n,o);if(n&&!Ia(n,s)){let l=!1,a="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(l=!0),a=i.inputState.lastSelectionOrigin,a=="select.pointer"&&(n=Xb(r.facet(kl).map(c=>c(i)),n))),i.dispatch({selection:n,scrollIntoView:l,userEvent:a}),!0}else return!1}function zf(i,t,e,n=-1){if(M.ios&&i.inputState.flushIOSKey(t))return!0;let r=i.state.selection.main;if(M.android&&(t.to==r.to&&(t.from==r.from||t.from==r.from-1&&i.state.sliceDoc(t.from,r.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&Ir(i.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||n==8&&t.insert.length<t.to-t.from&&t.to>r.head)&&Ir(i.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Ir(i.contentDOM,"Delete",46)))return!0;let s=t.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=xy(i,t,e));return i.state.facet(vb).some(a=>a(i,t.from,t.to,s,l))||i.dispatch(l()),!0}function xy(i,t,e){let n,r=i.state,s=r.selection.main,o=-1;if(t.from==t.to&&t.from<s.from||t.from>s.to){let a=t.from<s.from?-1:1,c=a<0?s.from:s.to,h=Do(r.facet(kl).map(u=>u(i)),c,a);t.from==h&&(o=h)}if(o>-1)n={changes:t,selection:C.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!e||e.main.empty&&e.main.from==t.from+t.insert.length)&&i.inputState.composing<0){let a=s.from<t.from?r.sliceDoc(s.from,t.from):"",c=s.to>t.to?r.sliceDoc(t.to,s.to):"";n=r.replaceSelection(i.state.toText(a+t.insert.sliceString(0,void 0,i.state.lineBreak)+c))}else{let a=r.changes(t),c=e&&e.main.to<=a.newLength?e.main:void 0;if(r.selection.ranges.length>1&&(i.inputState.composing>=0||i.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let h=i.state.sliceDoc(t.from,t.to),u,f=e&&Zb(i,e.main.head);if(f){let O=t.insert.length-(t.to-t.from);u={from:f.from,to:f.to-O}}else u=i.state.doc.lineAt(s.head);let d=s.to-t.to;n=r.changeByRange(O=>{if(O.from==s.from&&O.to==s.to)return{changes:a,range:c||O.map(a)};let p=O.to-d,m=p-h.length;if(i.state.sliceDoc(m,p)!=h||p>=u.from&&m<=u.to)return{range:O};let g=r.changes({from:m,to:p,insert:t.insert}),b=O.to-s.to;return{changes:g,range:c?C.range(Math.max(0,c.anchor+b),Math.max(0,c.head+b)):O.map(g)}})}else n={changes:a,selection:c&&r.selection.replaceRange(c)}}let l="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,l+=".compose",i.inputState.compositionFirstChange&&(l+=".start",i.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:l,scrollIntoView:!0})}function Mb(i,t,e,n){let r=Math.min(i.length,t.length),s=0;for(;s<r&&i.charCodeAt(s)==t.charCodeAt(s);)s++;if(s==r&&i.length==t.length)return null;let o=i.length,l=t.length;for(;o>0&&l>0&&i.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,s-Math.min(o,l));e-=o+a-s}if(o<s&&i.length<t.length){let a=e<=s&&e>=o?s-e:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=e<=s&&e>=l?s-e:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function yy(i){let t=[];if(i.root.activeElement!=i.contentDOM)return t;let{anchorNode:e,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return e&&(t.push(new CO(e,n)),(r!=e||s!=n)&&t.push(new CO(r,s))),t}function ky(i,t){if(i.length==0)return null;let e=i[0].pos,n=i.length==2?i[1].pos:e;return e>-1&&n>-1?C.single(e+t,n+t):null}function Ia(i,t){return t.head==i.main.head&&t.anchor==i.main.anchor}class Qy{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,M.safari&&t.contentDOM.addEventListener("input",()=>null),M.gecko&&jy(t.contentDOM.ownerDocument)}handleEvent(t){!Xy(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let n=this.handlers[t];if(n){for(let r of n.observers)r(this.view,e);for(let r of n.handlers){if(e.defaultPrevented)break;if(r(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=$y(t),n=this.handlers,r=this.view.contentDOM;for(let s in e)if(s!="scroll"){let o=!e[s].handlers.length,l=n[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!e[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&_b.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),M.android&&M.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return M.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&!t.shiftKey&&((e=zb.find(n=>n.keyCode==t.keyCode))&&!t.ctrlKey||Cy.indexOf(t.key)>-1&&t.ctrlKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(t.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(t){let e=this.pendingIOSKey;return!e||e.key=="Enter"&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString())?!1:(this.pendingIOSKey=void 0,Ir(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0))}ignoreDuringComposition(t){return!/^key/.test(t.type)||t.synthetic?!1:this.composing>0?!0:M.safari&&!M.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function PO(i,t){return(e,n)=>{try{return t.call(i,n,e)}catch(r){Li(e.state,r)}}}function $y(i){let t=Object.create(null);function e(n){return t[n]||(t[n]={observers:[],handlers:[]})}for(let n of i){let r=n.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&e(l).handlers.push(PO(n.value,a))}if(o)for(let l in o){let a=o[l];a&&e(l).observers.push(PO(n.value,a))}}for(let n in fi)e(n).handlers.push(fi[n]);for(let n in Qe)e(n).observers.push(Qe[n]);return t}const zb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Cy="dthko",_b=[16,17,18,20,91,92,224,225],Bl=6;function Wl(i){return Math.max(0,i)*.7+8}function Py(i,t){return Math.max(Math.abs(i.clientX-t.clientX),Math.abs(i.clientY-t.clientY))}class Ty{constructor(t,e,n,r){this.view=t,this.startEvent=e,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=lb(t.contentDOM),this.atoms=t.state.facet(kl).map(o=>o(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(K.allowMultipleSelections)&&Ay(t,e),this.dragging=Zy(t,e)&&Db(e)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Py(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let e=0,n=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Mf(this.view);t.clientX-a.left<=r+Bl?e=-Wl(r-t.clientX):t.clientX+a.right>=o-Bl&&(e=Wl(t.clientX-o)),t.clientY-a.top<=s+Bl?n=-Wl(s-t.clientY):t.clientY+a.bottom>=l-Bl&&(n=Wl(t.clientY-l)),this.setScrollSpeed(e,n)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),this.dragging===!1&&this.select(this.lastEvent)}select(t){let{view:e}=this,n=Xb(this.atoms,this.style.get(t,this.extend,this.multiple));(this.mustSelect||!n.eq(e.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Ay(i,t){let e=i.state.facet(gb);return e.length?e[0](t):M.mac?t.metaKey:t.ctrlKey}function Ry(i,t){let e=i.state.facet(bb);return e.length?e[0](t):M.mac?!t.altKey:!t.ctrlKey}function Zy(i,t){let{main:e}=i.state.selection;if(e.empty)return!1;let n=Fo(i.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=t.clientX&&o.right>=t.clientX&&o.top<=t.clientY&&o.bottom>=t.clientY)return!0}return!1}function Xy(i,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target,n;e!=i.contentDOM;e=e.parentNode)if(!e||e.nodeType==11||(n=zt.get(e))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0}const fi=Object.create(null),Qe=Object.create(null),Ib=M.ie&&M.ie_version<15||M.ios&&M.webkit_version<604;function Ey(i){let t=i.dom.parentNode;if(!t)return;let e=t.appendChild(document.createElement("textarea"));e.style.cssText="position: fixed; left: -10000px; top: 10px",e.focus(),setTimeout(()=>{i.focus(),e.remove(),jb(i,e.value)},50)}function Pc(i,t,e){for(let n of i.facet(t))e=n(e,i);return e}function jb(i,t){t=Pc(i.state,Zf,t);let{state:e}=i,n,r=1,s=e.toText(t),o=s.lines==e.selection.ranges.length;if(ku!=null&&e.selection.ranges.every(a=>a.empty)&&ku==s.toString()){let a=-1;n=e.changeByRange(c=>{let h=e.doc.lineAt(c.from);if(h.from==a)return{range:c};a=h.from;let u=e.toText((o?s.line(r++).text:t)+e.lineBreak);return{changes:{from:h.from,insert:u},range:C.cursor(c.from+u.length)}})}else o?n=e.changeByRange(a=>{let c=s.line(r++);return{changes:{from:a.from,to:a.to,insert:c.text},range:C.cursor(a.from+c.length)}}):n=e.replaceSelection(s);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Qe.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};Qe.wheel=Qe.mousewheel=i=>{i.inputState.lastWheelEvent=Date.now()};fi.keydown=(i,t)=>(i.inputState.setSelectionOrigin("select"),t.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);Qe.touchstart=(i,t)=>{let e=i.inputState,n=t.targetTouches[0];e.lastTouchTime=Date.now(),n&&(e.lastTouchX=n.clientX,e.lastTouchY=n.clientY),e.setSelectionOrigin("select.pointer")};Qe.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};fi.mousedown=(i,t)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let e=null;for(let n of i.state.facet(wb))if(e=n(i,t),e)break;if(!e&&t.button==0&&(e=My(i,t)),e){let n=!i.hasFocus;i.inputState.startMouseSelection(new Ty(i,t,e,n)),n&&i.observer.ignore(()=>{ab(i.contentDOM);let s=i.root.activeElement;s&&!s.contains(i.contentDOM)&&s.blur()});let r=i.inputState.mouseSelection;if(r)return r.start(t),r.dragging===!1}else i.inputState.setSelectionOrigin("select.pointer");return!1};function TO(i,t,e,n){if(n==1)return C.cursor(t,e);if(n==2)return fy(i.state,t,e);{let r=i.docView.lineAt(t,e),s=i.state.doc.lineAt(r?r.posAtEnd:t),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<i.state.doc.length&&l==s.to&&l++,C.range(o,l)}}const Ly=M.ie&&M.ie_version<=11;let AO=null,RO=0,ZO=0;function Db(i){if(!Ly)return i.detail;let t=AO,e=ZO;return AO=i,ZO=Date.now(),RO=!t||e>Date.now()-400&&Math.abs(t.clientX-i.clientX)<2&&Math.abs(t.clientY-i.clientY)<2?(RO+1)%3:1}function My(i,t){let e=i.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),n=Db(t),r=i.state.selection;return{update(s){s.docChanged&&(e.pos=s.changes.mapPos(e.pos),r=r.map(s.changes))},get(s,o,l){let a=i.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),c,h=TO(i,a.pos,a.assoc,n);if(e.pos!=a.pos&&!o){let u=TO(i,e.pos,e.assoc,n),f=Math.min(u.from,h.from),d=Math.max(u.to,h.to);h=f<h.from?C.range(f,d,h.assoc):C.range(d,f,h.assoc)}return o?r.replaceRange(r.main.extend(h.from,h.to,h.assoc)):l&&n==1&&r.ranges.length>1&&(c=zy(r,a.pos))?c:l?r.addRange(h):C.create([h])}}}function zy(i,t){for(let e=0;e<i.ranges.length;e++){let{from:n,to:r}=i.ranges[e];if(n<=t&&r>=t)return C.create(i.ranges.slice(0,e).concat(i.ranges.slice(e+1)),i.mainIndex==e?0:i.mainIndex-(i.mainIndex>e?1:0))}return null}fi.dragstart=(i,t)=>{let{selection:{main:e}}=i.state;if(t.target.draggable){let r=i.docView.tile.nearest(t.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=e.to||o<=e.from)&&(e=C.range(s,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=e,t.dataTransfer&&(t.dataTransfer.setData("Text",Pc(i.state,Xf,i.state.sliceDoc(e.from,e.to))),t.dataTransfer.effectAllowed="copyMove"),!1};fi.dragend=i=>(i.inputState.draggedContent=null,!1);function XO(i,t,e,n){if(e=Pc(i.state,Zf,e),!e)return;let r=i.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=i.inputState,o=n&&s&&Ry(i,t)?{from:s.from,to:s.to}:null,l={from:r,insert:e},a=i.state.changes(o?[o,l]:l);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}fi.drop=(i,t)=>{if(!t.dataTransfer)return!1;if(i.state.readOnly)return!0;let e=t.dataTransfer.files;if(e&&e.length){let n=Array(e.length),r=0,s=()=>{++r==e.length&&XO(i,t,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o<e.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[o]=l.result),s()},l.readAsText(e[o])}return!0}else{let n=t.dataTransfer.getData("Text");if(n)return XO(i,t,n,!0),!0}return!1};fi.paste=(i,t)=>{if(i.state.readOnly)return!0;i.observer.flush();let e=Ib?null:t.clipboardData;return e?(jb(i,e.getData("text/plain")||e.getData("text/uri-list")),!0):(Ey(i),!1)};function _y(i,t){let e=i.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=t,n.focus(),n.selectionEnd=t.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function Iy(i){let t=[],e=[],n=!1;for(let r of i.selection.ranges)r.empty||(t.push(i.sliceDoc(r.from,r.to)),e.push(r));if(!t.length){let r=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>r&&(t.push(o.text),e.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),r=o.number}n=!0}return{text:Pc(i,Xf,t.join(i.lineBreak)),ranges:e,linewise:n}}let ku=null;fi.copy=fi.cut=(i,t)=>{if(!Io(i.contentDOM,i.observer.selectionRange))return!1;let{text:e,ranges:n,linewise:r}=Iy(i.state);if(!e&&!r)return!1;ku=r?e:null,t.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=Ib?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",e),!0):(_y(i,e),!1)};const Vb=Ke.define();function Bb(i,t){let e=[];for(let n of i.facet(xb)){let r=n(i,t);r&&e.push(r)}return e.length?i.update({effects:e,annotations:Vb.of(!0)}):null}function Wb(i){setTimeout(()=>{let t=i.hasFocus;if(t!=i.inputState.notifiedFocused){let e=Bb(i.state,t);e?i.dispatch(e):i.update([])}},10)}Qe.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),Wb(i)};Qe.blur=i=>{i.observer.clearSelectionRange(),Wb(i)};Qe.compositionstart=Qe.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};Qe.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,M.chrome&&M.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};Qe.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};fi.beforeinput=(i,t)=>{var e,n;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(i.inputState.insertingText=t.data,i.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&i.observer.editContext){let s=(e=t.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain"),o=t.getTargetRanges();if(s&&o.length){let l=o[0],a=i.posAtDOM(l.startContainer,l.startOffset),c=i.posAtDOM(l.endContainer,l.endOffset);return zf(i,{from:a,to:c,insert:i.state.toText(s)},null),!0}}let r;if(M.chrome&&M.android&&(r=zb.find(s=>s.inputType==t.inputType))&&(i.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return M.ios&&t.inputType=="deleteContentForward"&&i.observer.flushSoon(),M.safari&&t.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>Qe.compositionend(i,t),20),!1};const EO=new Set;function jy(i){EO.has(i)||(EO.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const LO=["pre-wrap","normal","pre-line","break-spaces"];let Ns=!1;function MO(){Ns=!1}class Dy{constructor(t){this.lineWrapping=t,this.doc=Y.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let n=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((e-t-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return LO.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let n=0;n<t.length;n++){let r=t[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(e=!0,this.heightSamples[Math.floor(r*10)]=!0)}return e}refresh(t,e,n,r,s,o){let l=LO.indexOf(t)>-1,a=Math.abs(e-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=e,this.charWidth=n,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let c=0;c<o.length;c++){let h=o[c];h<0?c++:this.heightSamples[Math.floor(h*10)]=!0}}return a}}class Vy{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class li{constructor(t,e,n,r,s){this.from=t,this.length=e,this.top=n,this.height=r,this._content=s}get type(){return typeof this._content=="number"?pe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof wr?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new li(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var xt=function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i}(xt||(xt={}));const ba=.001;class me{constructor(t,e,n=2){this.length=t,this.height=e,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>ba&&(Ns=!0),this.height=t)}replace(t,e,n){return me.of(n)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,n,r){let s=this,o=n.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:h,toB:u}=r[l],f=s.lineAt(a,xt.ByPosNoHeight,n.setDoc(e),0,0),d=f.to>=c?f:s.lineAt(c,xt.ByPosNoHeight,n,0,0);for(u+=d.to-c,c=d.to;l>0&&f.from<=r[l-1].toA;)a=r[l-1].fromA,h=r[l-1].fromB,l--,a<f.from&&(f=s.lineAt(a,xt.ByPosNoHeight,n,0,0));h+=f.from-a,a=f.from;let O=_f.build(n.setDoc(o),t,h,u);s=ja(s,s.replace(a,c,O))}return s.updateHeight(n,0)}static empty(){return new Me(0,0,0)}static of(t){if(t.length==1)return t[0];let e=0,n=t.length,r=0,s=0;for(;;)if(e==n)if(r>s*2){let l=t[e-1];l.break?t.splice(--e,1,l.left,null,l.right):t.splice(--e,1,l.left,l.right),n+=1+l.break,r-=l.size}else if(s>r*2){let l=t[n];l.break?t.splice(n,1,l.left,null,l.right):t.splice(n,1,l.left,l.right),n+=2+l.break,s-=l.size}else break;else if(r<s){let l=t[e++];l&&(r+=l.size)}else{let l=t[--n];l&&(s+=l.size)}let o=0;return t[e-1]==null?(o=1,e--):t[e]==null&&(o=1,n++),new Wy(me.of(t.slice(0,e)),o,me.of(t.slice(n)))}}function ja(i,t){return i==t?i:(i.constructor!=t.constructor&&(Ns=!0),t)}me.prototype.size=1;const By=J.replace({});class Yb extends me{constructor(t,e,n){super(t,e),this.deco=n,this.spaceAbove=0}mainBlock(t,e){return new li(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(t,e,n,r){return this.spaceAbove&&t<n+this.spaceAbove?new li(r,0,n,this.spaceAbove,By):this.mainBlock(n,r)}lineAt(t,e,n,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,n,r,s).join(o):o}forEachLine(t,e,n,r,s,o){t<=s+this.length&&e>=s&&o(this.lineAt(0,xt.ByPos,n,r,s))}setMeasuredHeight(t){let e=t.heights[t.index++];e<0?(this.spaceAbove=-e,e=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(e)}updateHeight(t,e=0,n=!1,r){return r&&r.from<=e&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Me extends Yb{constructor(t,e,n){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(t,e){return new li(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,e,n){let r=n[0];return n.length==1&&(r instanceof Me||r instanceof Jt&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Jt?r=new Me(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):me.of(n)}updateHeight(t,e=0,n=!1,r){return r&&r.from<=e&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Jt extends me{constructor(t){super(t,0)}heightMetrics(t,e){let n=t.doc.lineAt(e).number,r=t.doc.lineAt(e+this.length).number,s=r-n+1,o,l=0;if(t.lineWrapping){let a=Math.min(this.height,t.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:l}}blockAt(t,e,n,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(e,r);if(e.lineWrapping){let c=r+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-n)/this.height))*this.length)),h=e.doc.lineAt(c),u=l+h.length*a,f=Math.max(n,t-u/2);return new li(h.from,h.length,f,u,0)}else{let c=Math.max(0,Math.min(o-s,Math.floor((t-n)/l))),{from:h,length:u}=e.doc.line(s+c);return new li(h,u,n+l*c,l,0)}}lineAt(t,e,n,r,s){if(e==xt.ByHeight)return this.blockAt(t,n,r,s);if(e==xt.ByPosNoHeight){let{from:d,to:O}=n.doc.lineAt(t);return new li(d,O-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,s),c=n.doc.lineAt(t),h=l+c.length*a,u=c.number-o,f=r+l*u+a*(c.from-s-u);return new li(c.from,c.length,Math.max(r,Math.min(f,r+this.height-h)),h,0)}forEachLine(t,e,n,r,s,o){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(n,s);for(let h=t,u=r;h<=e;){let f=n.doc.lineAt(h);if(h==t){let O=f.number-l;u+=a*O+c*(t-s-O)}let d=a+c*f.length;o(new li(f.from,f.length,u,d,0)),u+=d,h=f.to+1}}replace(t,e,n){let r=this.length-e;if(r>0){let s=n[n.length-1];s instanceof Jt?n[n.length-1]=new Jt(s.length+r):n.push(null,new Jt(r-1))}if(t>0){let s=n[0];s instanceof Jt?n[0]=new Jt(t+s.length):n.unshift(new Jt(t-1),null)}return me.of(n)}decomposeLeft(t,e){e.push(new Jt(t-1),null)}decomposeRight(t,e){e.push(null,new Jt(this.length-t-1))}updateHeight(t,e=0,n=!1,r){let s=e+this.length;if(r&&r.from<=e+this.length&&r.more){let o=[],l=Math.max(e,r.from),a=-1;for(r.from>e&&o.push(new Jt(r.from-e-1).updateHeight(t,e));l<=s&&r.more;){let h=t.doc.lineAt(l).length;o.length&&o.push(null);let u=r.heights[r.index++],f=0;u<0&&(f=-u,u=r.heights[r.index++]),a==-1?a=u:Math.abs(u-a)>=ba&&(a=-2);let d=new Me(h,u,f);d.outdated=!1,o.push(d),l+=h+1}l<=s&&o.push(null,new Jt(s-l).updateHeight(t,l));let c=me.of(o);return(a<0||Math.abs(c.height-this.height)>=ba||Math.abs(a-this.heightMetrics(t,e).perLine)>=ba)&&(Ns=!0),ja(this,c)}else(n||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Wy extends me{constructor(t,e,n){super(t.length+e+n.length,t.height+n.height,e|(t.outdated||n.outdated?2:0)),this.left=t,this.right=n,this.size=t.size+n.size}get break(){return this.flags&1}blockAt(t,e,n,r){let s=n+this.left.height;return t<s?this.left.blockAt(t,e,n,r):this.right.blockAt(t,e,s,r+this.left.length+this.break)}lineAt(t,e,n,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=e==xt.ByHeight?t<o:t<l,c=a?this.left.lineAt(t,e,n,r,s):this.right.lineAt(t,e,n,o,l);if(this.break||(a?c.to<l:c.from>l))return c;let h=e==xt.ByPosNoHeight?xt.ByPosNoHeight:xt.ByPos;return a?c.join(this.right.lineAt(l,h,n,o,l)):this.left.lineAt(l,h,n,r,s).join(c)}forEachLine(t,e,n,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,n,r,s,o),e>=a&&this.right.forEachLine(t,e,n,l,a,o);else{let c=this.lineAt(a,xt.ByPos,n,r,s);t<c.from&&this.left.forEachLine(t,c.from-1,n,r,s,o),c.to>=t&&c.from<=e&&o(c),e>c.to&&this.right.forEachLine(c.to+1,e,n,l,a,o)}}replace(t,e,n){let r=this.left.length+this.break;if(e<r)return this.balanced(this.left.replace(t,e,n),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-r,e-r,n));let s=[];t>0&&this.decomposeLeft(t,s);let o=s.length;for(let l of n)s.push(l);if(t>0&&zO(s,o-1),e<this.length){let l=s.length;this.decomposeRight(e,s),zO(s,l)}return me.of(s)}decomposeLeft(t,e){let n=this.left.length;if(t<=n)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(n++,t>=n&&e.push(null)),t>n&&this.right.decomposeLeft(t-n,e)}decomposeRight(t,e){let n=this.left.length,r=n+this.break;if(t>=r)return this.right.decomposeRight(t-r,e);t<n&&this.left.decomposeRight(t,e),this.break&&t<r&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?me.of(this.break?[t,null,e]:[t,e]):(this.left=ja(this.left,t),this.right=ja(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,n=!1,r){let{left:s,right:o}=this,l=e+s.length+this.break,a=null;return r&&r.from<=e+s.length&&r.more?a=s=s.updateHeight(t,e,n,r):s.updateHeight(t,e,n),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(t,l,n,r):o.updateHeight(t,l,n),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function zO(i,t){let e,n;i[t]==null&&(e=i[t-1])instanceof Jt&&(n=i[t+1])instanceof Jt&&i.splice(t-1,3,new Jt(e.length+1+n.length))}const Yy=5;class _f{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let n=Math.min(e,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Me?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Me(n-this.pos,-1,0)),this.writtenTo=n,e>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,n){if(t<e||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=e-t;n.block?this.addBlock(new Yb(o,r,n)):(o||s||r>=Yy)&&this.addLineDeco(r,s,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Me(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,e){let n=new Jt(e-t);return this.oracle.doc.lineAt(t).to==e&&(n.flags|=4),n}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Me)return t;let e=new Me(0,-1,0);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,t),r.breaks+=e,this.writtenTo=this.pos=this.pos+n}finish(t){let e=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(e instanceof Me)&&!this.isCovered?this.nodes.push(new Me(0,-1,0)):(this.writtenTo<this.pos||e==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=t;for(let r of this.nodes)r instanceof Me&&r.updateHeight(this.oracle,n),n+=r?r.length:1;return this.nodes}static build(t,e,n,r){let s=new _f(n,t);return Ot.spans(e,n,r,s,0),s.finish(n)}}function qy(i,t,e){let n=new Ny;return Ot.compare(i,t,e,n,0),n.changes}class Ny{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,n,r){(t<e||n&&n.heightRelevant||r&&r.heightRelevant)&&_r(t,e,this.changes,5)}}function Gy(i,t){let e=i.getBoundingClientRect(),n=i.ownerDocument,r=n.defaultView||window,s=Math.max(0,e.left),o=Math.min(r.innerWidth,e.right),l=Math.max(0,e.top),a=Math.min(r.innerHeight,e.bottom);for(let c=i.parentNode;c&&c!=n.body;)if(c.nodeType==1){let h=c,u=window.getComputedStyle(h);if((h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth)&&u.overflow!="visible"){let f=h.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(c==i.parentNode?r.innerHeight:a,f.bottom)}c=u.position=="absolute"||u.position=="fixed"?h.offsetParent:h.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-e.left,right:Math.max(s,o)-e.left,top:l-(e.top+t),bottom:Math.max(l,a)-(e.top+t)}}function Uy(i){let t=i.getBoundingClientRect(),e=i.ownerDocument.defaultView||window;return t.left<e.innerWidth&&t.right>0&&t.top<e.innerHeight&&t.bottom>0}function Hy(i,t){let e=i.getBoundingClientRect();return{left:0,right:e.right-e.left,top:t,bottom:e.bottom-(e.top+t)}}class fh{constructor(t,e,n,r){this.from=t,this.to=e,this.size=n,this.displaySize=r}static same(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],s=e[n];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(t,e){return J.replace({widget:new Fy(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class Fy extends jn{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class _O{constructor(t,e){this.view=t,this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=IO,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Tt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=e.facet(Ef).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new Dy(n),this.stateDeco=jO(e),this.heightMap=me.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle.setDoc(e.doc),[new Ye(0,0,0,e.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=J.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=t.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let n=0;n<=1;n++){let r=n?e.head:e.anchor;if(!t.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);t.push(new Yl(s,o))}}return this.viewports=t.sort((n,r)=>n.from-r.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?IO:new If(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(Zo(t,this.scaler))})}update(t,e=null){this.state=t.state;let n=this.stateDeco;this.stateDeco=jO(this.state);let r=t.changedRanges,s=Ye.extendWithRanges(r,qy(n,this.stateDeco,t?t.changes:Lt.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);MO(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Ns)&&(t.flags|=2),l?(this.scrollAnchorPos=t.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let c=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,t.flags|=this.updateForViewport(),(c||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(kb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,e=t.contentDOM,n=window.getComputedStyle(e),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?Tt.RTL:Tt.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=e.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,h=0;if(l.width&&l.height){let{scaleX:y,scaleY:k}=ob(e,l);(y>.005&&Math.abs(this.scaleX-y)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=y,this.scaleY=k,c|=16,o=a=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,f=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=f)&&(this.paddingTop=u,this.paddingBottom=f,c|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,c|=16);let d=lb(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let O=this.getScrollOffset();this.scrollOffset!=O&&(this.scrollAnchorHeight=-1,this.scrollOffset=O),this.scrolledToBottom=cb(this.scrollParent||t.win);let p=(this.printing?Hy:Gy)(e,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView&&!this.scrollTarget&&!Uy(t.dom))return 0;let S=l.width;if((this.contentDOMWidth!=S||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,c|=16),a){let y=t.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(y)&&(o=!0),o||r.lineWrapping&&Math.abs(S-this.contentDOMWidth)>r.charWidth){let{lineHeight:k,charWidth:Q,textHeight:X}=t.docView.measureTextSize();o=k>0&&r.refresh(s,k,Q,X,Math.max(5,S/Q),y),o&&(t.docView.minWidth=0,c|=16)}m>0&&g>0?h=Math.max(m,g):m<0&&g<0&&(h=Math.min(m,g)),MO();for(let k of this.viewports){let Q=k.from==this.viewport.from?y:t.docView.measureVisibleLineHeights(k);this.heightMap=(o?me.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle,[new Ye(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Vy(k.from,Q))}Ns&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(c&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let n=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Yl(r.lineAt(o-n*1e3,xt.ByHeight,s,0,0).from,r.lineAt(l+(1-n)*1e3,xt.ByHeight,s,0,0).to);if(e){let{head:c}=e.range;if(c<a.from||c>a.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=r.lineAt(c,xt.ByPos,s,0,0),f;e.y=="center"?f=(u.top+u.bottom)/2-h/2:e.y=="start"||e.y=="nearest"&&c<a.from?f=u.top:f=u.bottom-h,a=new Yl(r.lineAt(f-1e3/2,xt.ByHeight,s,0,0).from,r.lineAt(f+h+1e3/2,xt.ByHeight,s,0,0).to)}}return a}mapViewport(t,e){let n=e.mapPos(t.from,-1),r=e.mapPos(t.to,1);return new Yl(this.heightMap.lineAt(n,xt.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,xt.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(t,xt.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,xt.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(t==0||r<=o-Math.max(10,Math.min(-n,250)))&&(e==this.state.doc.length||s>=l+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let n=[];for(let r of t)e.touchesRange(r.from,r.to)||n.push(new fh(e.mapPos(r.from),e.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(t,e){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=Tt.LTR&&!n)return[];let l=[],a=(h,u,f,d)=>{if(u-h<s)return;let O=this.state.selection.main,p=[O.from];O.empty||p.push(O.to);for(let g of p)if(g>h&&g<u){a(h,g-10,f,d),a(g+10,u,f,d);return}let m=Jy(t,g=>g.from>=f.from&&g.to<=f.to&&Math.abs(g.from-h)<s&&Math.abs(g.to-u)<s&&!p.some(b=>g.from<b&&g.to>b));if(!m){if(u<f.to&&e&&n&&e.visibleRanges.some(S=>S.from<=u&&S.to>=u)){let S=e.moveToLineBoundary(C.cursor(u),!1,!0).head;S>h&&(u=S)}let g=this.gapSize(f,h,u,d),b=n||g<2e6?g:2e6;m=new fh(h,u,g,b)}l.push(m)},c=h=>{if(h.length<o||h.type!=pe.Text)return;let u=Ky(h.from,h.to,this.stateDeco);if(u.total<o)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,d,O;if(n){let p=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,g;if(f!=null){let b=Nl(u,f),S=((this.visibleBottom-this.visibleTop)/2+p)/h.height;m=b-S,g=b+S}else m=(this.visibleTop-h.top-p)/h.height,g=(this.visibleBottom-h.top+p)/h.height;d=ql(u,m),O=ql(u,g)}else{let p=u.total*this.heightOracle.charWidth,m=r*this.heightOracle.charWidth,g=0;if(p>2e6)for(let k of t)k.from>=h.from&&k.from<h.to&&k.size!=k.displaySize&&k.from*this.heightOracle.charWidth+g<this.pixelViewport.left&&(g=k.size-k.displaySize);let b=this.pixelViewport.left+g,S=this.pixelViewport.right+g,x,y;if(f!=null){let k=Nl(u,f),Q=((S-b)/2+m)/p;x=k-Q,y=k+Q}else x=(b-m)/p,y=(S+m)/p;d=ql(u,x),O=ql(u,y)}d>h.from&&a(h.from,d,h,u),O<h.to&&a(O,h.to,h,u)};for(let h of this.viewportLines)Array.isArray(h.type)?h.type.forEach(c):c(h);return l}gapSize(t,e,n,r){let s=Nl(r,n)-Nl(r,e);return this.heightOracle.lineWrapping?t.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(t){fh.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=J.set(t.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let n=[];Ot.spans(e,this.viewport.from,this.viewport.to,{span(s,o){n.push({from:s,to:o})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let s=0;s<n.length&&!(r&8);s++){let o=this.visibleRanges[s],l=n[s];(o.from!=l.from||o.to!=l.to)&&(r|=4,t&&t.mapPos(o.from,-1)==l.from&&t.mapPos(o.to,1)==l.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||Zo(this.heightMap.lineAt(t,xt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||Zo(this.heightMap.lineAt(this.scaler.fromDOM(t),xt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return Zo(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Yl{constructor(t,e){this.from=t,this.to=e}}function Ky(i,t,e){let n=[],r=i,s=0;return Ot.spans(e,i,t,{span(){},point(o,l){o>r&&(n.push({from:r,to:o}),s+=o-r),r=l}},20),r<t&&(n.push({from:r,to:t}),s+=t-r),{total:s,ranges:n}}function ql({total:i,ranges:t},e){if(e<=0)return t[0].from;if(e>=1)return t[t.length-1].to;let n=Math.floor(i*e);for(let r=0;;r++){let{from:s,to:o}=t[r],l=o-s;if(n<=l)return s+n;n-=l}}function Nl(i,t){let e=0;for(let{from:n,to:r}of i.ranges){if(t<=r){e+=t-n;break}e+=r-n}return e/i.total}function Jy(i,t){for(let e of i)if(t(e))return e}const IO={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};function jO(i){let t=i.facet(Qc).filter(n=>typeof n!="function"),e=i.facet(Lf).filter(n=>typeof n!="function");return e.length&&t.push(Ot.join(e)),t}class If{constructor(t,e,n){let r=0,s=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let c=e.lineAt(l,xt.ByPos,t,0,0).top,h=e.lineAt(a,xt.ByPos,t,0,0).bottom;return r+=h-c,{from:l,to:a,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(e.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(t){for(let e=0,n=0,r=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return r+(t-n)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);n=s.bottom,r=s.domBottom}}fromDOM(t){for(let e=0,n=0,r=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return n+(t-r)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);n=s.bottom,r=s.domBottom}}eq(t){return t instanceof If?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to):!1}}function Zo(i,t){if(t.scale==1)return i;let e=t.toDOM(i.top),n=t.toDOM(i.bottom);return new li(i.from,i.length,e,n-e,Array.isArray(i._content)?i._content.map(r=>Zo(r,t)):i._content)}const Gl=D.define({combine:i=>i.join(" ")}),Qu=D.define({combine:i=>i.indexOf(!0)>-1}),$u=Xn.newName(),qb=Xn.newName(),Nb=Xn.newName(),Gb={"&light":"."+qb,"&dark":"."+Nb};function Cu(i,t,e){return new Xn(t,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return i;if(!e||!e[r])throw new RangeError(`Unsupported selector: ${r}`);return e[r]}):i+" "+n}})}const tk=Cu("."+$u,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Gb),ek={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},dh=M.ie&&M.ie_version<=11;class ik{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new Zx,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let n of e)this.queue.push(n);(M.ie&&M.ie_version<=11||M.ios&&t.composing)&&e.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&M.android&&t.constructor.EDIT_CONTEXT!==!1&&!(M.chrome&&M.chrome_version<126)&&(this.editContext=new rk(t),t.state.facet(Ji)&&(t.contentDOM.editContext=this.editContext.editContext)),dh&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var e;((e=this.view.docView)===null||e===void 0?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,n)=>e!=t[n]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Ji)?n.root.activeElement!=this.dom:!Io(this.dom,r))return;let s=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(M.ie&&M.ie_version<=11||M.android&&M.chrome)&&!n.state.selection.main.empty&&r.focusNode&&jo(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Fo(t.root);if(!e)return!1;let n=M.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&nk(this.view,e)||e;if(!n||this.selectionRange.eq(n))return!1;let r=Io(this.dom,n);return r&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&Ex(this.dom,n)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let n=this.dom;n;)if(n.nodeType==1)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==n?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=e)n.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,ek),dh&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),dh&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var n;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ir(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,n=-1,r=!1;for(let s of t){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),e==-1?{from:e,to:n}=o:(e=Math.min(o.from,e),n=Math.max(o.to,n)))}return{from:e,to:n,typeOver:r}}readChange(){let{from:t,to:e,typeOver:n}=this.processRecords(),r=this.selectionChanged&&Io(this.dom,this.selectionRange);if(t<0&&!r)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new vy(this.view,t,e,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let n=this.view.state,r=Lb(this.view,e);return this.view.state==n&&(e.domChanged||e.newSel&&!Ia(this.view.state.selection,e.newSel.main))&&this.view.update([]),r}readMutation(t){let e=this.view.docView.tile.nearest(t.target);if(!e||e.isWidget())return null;if(e.markDirty(t.type=="attributes"),t.type=="childList"){let n=DO(e,t.previousSibling||t.target.previousSibling,-1),r=DO(e,t.nextSibling||t.target.nextSibling,1);return{from:n?e.posAfter(n):e.posAtStart,to:r?e.posBefore(r):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Ji)!=t.state.facet(Ji)&&(t.view.contentDOM.editContext=t.state.facet(Ji)?this.editContext.editContext:null))}destroy(){var t,e,n;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function DO(i,t,e){for(;t;){let n=zt.get(t);if(n&&n.parent==i)return n;let r=t.parentNode;t=r!=i.dom?r:e>0?t.nextSibling:t.previousSibling}return null}function VO(i,t){let e=t.startContainer,n=t.startOffset,r=t.endContainer,s=t.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor,1);return jo(o.node,o.offset,r,s)&&([e,n,r,s]=[r,s,e,n]),{anchorNode:e,anchorOffset:n,focusNode:r,focusOffset:s}}function nk(i,t){if(t.getComposedRanges){let r=t.getComposedRanges(i.root)[0];if(r)return VO(i,r)}let e=null;function n(r){r.preventDefault(),r.stopImmediatePropagation(),e=r.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),e?VO(i,e):null}class rk{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=n=>{let r=t.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:l,drifted:!1});let c=a-l>n.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let h=Mb(t.state.sliceDoc(l,a),n.text,(c?r.from:r.to)-l,c?"end":null);if(!h){let f=C.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));Ia(f,r)||t.dispatch({selection:f,userEvent:"select"});return}let u={from:h.from+l,to:h.toA+l,insert:Y.of(n.text.slice(h.from,h.toB).split(`
38
- `))};if((M.mac||M.android)&&u.from==o-1&&/^\. ?$/.test(n.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:l,to:a,insert:Y.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!t.state.readOnly){let f=this.to-this.from+(u.to-u.from+u.insert.length);zf(t,u,C.single(this.toEditorPos(n.selectionStart,f),this.toEditorPos(n.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),u.from<u.to&&!u.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(e.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],s=null;for(let o=this.toEditorPos(n.rangeStart),l=this.toEditorPos(n.rangeEnd);o<l;o++){let a=t.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}e.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=n=>{let r=[];for(let s of n.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(a<c){let h=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(J.mark({attributes:{style:h}}).range(a,c))}}}t.dispatch({effects:$b.of(J.set(r))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(t.state)}};for(let n in this.handlers)e.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let r=Fo(n.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,n=!1,r=this.pendingContextChange;return t.changes.iterChanges((s,o,l,a,c)=>{if(n)return;let h=c.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(c)){r=this.pendingContextChange=null,e+=h,this.to+=h;return}else r=null,this.revertPending(t.state);if(s+=e,o+=e,o<=this.from)this.from+=h,this.to+=h;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),c.toString()),this.to+=h}e+=h}),r&&!n&&this.revertPending(t.state),!n}update(t){let e=this.pendingContextChange,n=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(n.from,n.to)&&t.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),r=this.toContextPos(e.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let n=this.composing;return n&&n.drifted?n.editorBase+(t-n.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class z{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:n}=t;this.dispatchTransactions=t.dispatchTransactions||n&&(r=>r.forEach(s=>n(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=t.root||Xx(t.parent)||document,this.viewState=new _O(this,t.state||K.create(t)),t.scrollTo&&t.scrollTo.is(Vl)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Xr).map(r=>new lh(r));for(let r of this.plugins)r.update(this);this.observer=new ik(this),this.inputState=new Qy(this),this.inputState.ensureHandlers(this.plugins),this.docView=new QO(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((e=document.fonts)===null||e===void 0)&&e.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let e=t.length==1&&t[0]instanceof Pt?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,n=!1,r,s=this.state;for(let f of t){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;t.some(f=>f.annotation(Vb))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Bb(s,o),a||(l=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(K.phrases)!=this.state.facet(K.phrases))return this.setState(s);r=Ma.create(this,s,t),r.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let f of t){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection,{x:O,y:p}=this.state.facet(z.cursorScrollMargin);u=new jr(d.empty?d:C.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",p,O)}for(let d of f.effects)d.is(Vl)&&(u=d.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=Da.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),e=this.docView.update(r),this.state.facet(Ro)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Gl)!=r.state.facet(Gl)&&(this.viewState.mustMeasureContent=!0),(e||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Su))try{f(r)}catch(d){Li(this.state,d,"update listener")}(a||h)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!Lb(this,h)&&c.force&&Ir(this.contentDOM,c.key,c.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new _O(this,t),this.plugins=t.facet(Xr).map(n=>new lh(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new QO(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Xr),n=t.state.facet(Xr);if(e!=n){let r=[];for(let s of n){let o=e.indexOf(s);if(o<0)r.push(new lh(s));else{let l=this.plugins[o];l.mustUpdate=t,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=t&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=t;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);e!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(n){Li(this.state,n,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(cb(n||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let h=c.map(d=>{try{return d.read(this)}catch(O){return Li(this.state,O),BO}}),u=Ma.create(this,this.state,[]),f=!1;u.flags|=a,e?e.flags|=a:e=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u),f&&this.docViewUpdate());for(let d=0;d<c.length;d++)if(h[d]!=BO)try{let O=c[d];O.write&&O.write(h[d],this)}catch(O){Li(this.state,O)}if(f&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let O=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o)/this.scaleY;if((O>1||O<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+O,n?n.scrollTop+=O:this.win.scrollBy(0,O),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let l of this.state.facet(Su))l(e)}get themeClasses(){return $u+" "+(this.state.facet(Qu)?Nb:qb)+" "+this.state.facet(Gl)}updateAttrs(){let t=WO(this,Cb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ji)?"true":"false",class:"cm-content",style:`${M.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),WO(this,Ef,e);let n=this.observer.ignore(()=>{let r=wO(this.contentDOM,this.contentAttrs,e),s=wO(this.dom,this.editorAttrs,t);return r||s});return this.editorAttrs=t,this.contentAttrs=e,n}showAnnouncements(t){let e=!0;for(let n of t)for(let r of n.effects)if(r.is(z.announce)){e&&(this.announceDOM.textContent=""),e=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Ro);let t=this.state.facet(z.cspNonce);Xn.mount(this.root,this.styleModules.concat(tk).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(e===void 0||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(n=>n.plugin==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,n){return uh(this,t,$O(this,t,e,n))}moveByGroup(t,e){return uh(this,t,$O(this,t,e,n=>py(this,t.head,n)))}visualLineSide(t,e){let n=this.bidiSpans(t),r=this.textDirectionAt(t.from),s=n[e?n.length-1:0];return C.cursor(s.side(e,r)+t.from,s.forward(!e,r)?1:-1)}moveToLineBoundary(t,e,n=!0){return Oy(this,t,e,n)}moveVertically(t,e,n){return uh(this,t,my(this,t,e,n))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let n=yu(this,t,e);return n&&n.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),yu(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let n=this.docView.coordsAt(t,e);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(t),s=this.bidiSpans(r),o=s[Ei.find(s,t-r.from,-1,e)];return La(n,o.dir==Tt.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(yb)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>sk)return pb(t.length);let e=this.textDirectionAt(t.from),n;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==e&&(s.fresh||Ob(s.isolates,n=xO(this,t))))return s.order;n||(n=xO(this,t));let r=Dx(t.text,e,n);return this.bidiCache.push(new Da(t.from,t.to,e,n,!0,r)),r}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||M.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ab(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){var n,r,s,o;return Vl.of(new jr(typeof t=="number"?C.cursor(t):t,(n=e.y)!==null&&n!==void 0?n:"nearest",(r=e.x)!==null&&r!==void 0?r:"nearest",(s=e.yMargin)!==null&&s!==void 0?s:5,(o=e.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,n=this.viewState.scrollAnchorAt(t);return Vl.of(new jr(C.cursor(n.from),"start","start",n.top-t,e,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return ui.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return ui.define(()=>({}),{eventObservers:t})}static theme(t,e){let n=Xn.newName(),r=[Gl.of(n),Ro.of(Cu(`.${n}`,t))];return e&&e.dark&&r.push(Qu.of(!0)),r}static baseTheme(t){return hn.lowest(Ro.of(Cu("."+$u,t,Gb)))}static findFromDOM(t){var e;let n=t.querySelector(".cm-content"),r=n&&zt.get(n)||zt.get(t);return((e=r==null?void 0:r.root)===null||e===void 0?void 0:e.view)||null}}z.styleModule=Ro;z.inputHandler=vb;z.clipboardInputFilter=Zf;z.clipboardOutputFilter=Xf;z.scrollHandler=Qb;z.focusChangeEffect=xb;z.perLineTextDirection=yb;z.exceptionSink=Sb;z.updateListener=Su;z.editable=Ji;z.mouseSelectionStyle=wb;z.dragMovesSelection=bb;z.clickAddsSelectionRange=gb;z.decorations=Qc;z.blockWrappers=Pb;z.outerDecorations=Lf;z.atomicRanges=kl;z.bidiIsolatedRanges=Tb;z.cursorScrollMargin=D.define({combine:i=>{let t=5,e=5;for(let n of i)typeof n=="number"?t=e=n:{x:t,y:e}=n;return{x:t,y:e}}});z.scrollMargins=Ab;z.darkTheme=Qu;z.cspNonce=D.define({combine:i=>i.length?i[0]:""});z.contentAttributes=Ef;z.editorAttributes=Cb;z.lineWrapping=z.contentAttributes.of({class:"cm-lineWrapping"});z.announce=Ct.define();const sk=4096,BO={};class Da{constructor(t,e,n,r,s,o){this.from=t,this.to=e,this.dir=n,this.isolates=r,this.fresh=s,this.order=o}static update(t,e){if(e.empty&&!t.some(s=>s.fresh))return t;let n=[],r=t.length?t[t.length-1].dir:Tt.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let o=t[s];o.dir==r&&!e.touchesRange(o.from,o.to)&&n.push(new Da(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function WO(i,t,e){for(let n=i.state.facet(t),r=n.length-1;r>=0;r--){let s=n[r],o=typeof s=="function"?s(i):s;o&&Tf(o,e)}return e}const ok=M.mac?"mac":M.windows?"win":M.linux?"linux":"key";function lk(i,t){const e=i.split(/-(?!$)/);let n=e[e.length-1];n=="Space"&&(n=" ");let r,s,o,l;for(let a=0;a<e.length-1;++a){const c=e[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))t=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Ul(i,t,e){return t.altKey&&(i="Alt-"+i),t.ctrlKey&&(i="Ctrl-"+i),t.metaKey&&(i="Meta-"+i),e!==!1&&t.shiftKey&&(i="Shift-"+i),i}const ak=hn.default(z.domEventHandlers({keydown(i,t){return Hb(Ub(t.state),i,t,"editor")}})),Dn=D.define({enables:ak}),YO=new WeakMap;function Ub(i){let t=i.facet(Dn),e=YO.get(t);return e||YO.set(t,e=uk(t.reduce((n,r)=>n.concat(r),[]))),e}function ck(i,t,e){return Hb(Ub(i.state),t,i,e)}let Sn=null;const hk=4e3;function uk(i,t=ok){let e=Object.create(null),n=Object.create(null),r=(o,l)=>{let a=n[o];if(a==null)n[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,c,h)=>{var u,f;let d=e[o]||(e[o]=Object.create(null)),O=l.split(/ (?!$)/).map(g=>lk(g,t));for(let g=1;g<O.length;g++){let b=O.slice(0,g).join(" ");r(b,!0),d[b]||(d[b]={preventDefault:!0,stopPropagation:!1,run:[S=>{let x=Sn={view:S,prefix:b,scope:o};return setTimeout(()=>{Sn==x&&(Sn=null)},hk),!0}]})}let p=O.join(" ");r(p,!1);let m=d[p]||(d[p]={preventDefault:!1,stopPropagation:!1,run:((f=(u=d._any)===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.slice())||[]});a&&m.run.push(a),c&&(m.preventDefault=!0),h&&(m.stopPropagation=!0)};for(let o of i){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of l){let h=e[c]||(e[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let f in h)h[f].run.push(d=>u(d,Pu))}let a=o[t]||o.key;if(a)for(let c of l)s(c,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return e}let Pu=null;function Hb(i,t,e,n){Pu=t;let r=$x(t),s=ax(r,0),o=cx(s)==r.length&&r!=" ",l="",a=!1,c=!1,h=!1;Sn&&Sn.view==e&&Sn.scope==n&&(l=Sn.prefix+" ",_b.indexOf(t.keyCode)<0&&(c=!0,Sn=null));let u=new Set,f=m=>{if(m){for(let g of m.run)if(!u.has(g)&&(u.add(g),g(e)))return m.stopPropagation&&(h=!0),!0;m.preventDefault&&(m.stopPropagation&&(h=!0),c=!0)}return!1},d=i[n],O,p;return d&&(f(d[l+Ul(r,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(M.windows&&t.ctrlKey&&t.altKey)&&!(M.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(O=En[t.keyCode])&&O!=r?(f(d[l+Ul(O,t,!0)])||t.shiftKey&&(p=Uo[t.keyCode])!=r&&p!=O&&f(d[l+Ul(p,t,!1)]))&&(a=!0):o&&t.shiftKey&&f(d[l+Ul(r,t,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),c&&(a=!0),a&&h&&t.stopPropagation(),Pu=null,a}class Or{constructor(t,e,n,r,s){this.className=t,this.left=e,this.top=n,this.width=r,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,n){if(n.empty){let r=t.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=Fb(t);return[new Or(e,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return fk(t,e,n)}}function Fb(i){let t=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==Tt.LTR?t.left:t.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:t.top-i.scrollDOM.scrollTop*i.scaleY}}function qO(i,t,e,n){let r=i.coordsAtPos(t,e*2);if(!r)return n;let s=i.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=i.posAtCoords({x:s.left+1,y:o}),a=i.posAtCoords({x:s.right-1,y:o});return l==null||a==null?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}function fk(i,t,e){if(e.to<=i.viewport.from||e.from>=i.viewport.to)return[];let n=Math.max(e.from,i.viewport.from),r=Math.min(e.to,i.viewport.to),s=i.textDirection==Tt.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=Fb(i),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=l.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),f=l.right-(h?parseInt(h.paddingRight):0),d=xu(i,n,1),O=xu(i,r,-1),p=d.type==pe.Text?d:null,m=O.type==pe.Text?O:null;if(p&&(i.lineWrapping||d.widgetLineBreaks)&&(p=qO(i,n,1,p)),m&&(i.lineWrapping||O.widgetLineBreaks)&&(m=qO(i,r,-1,m)),p&&m&&p.from==m.from&&p.to==m.to)return b(S(e.from,e.to,p));{let y=p?S(e.from,null,p):x(d,!1),k=m?S(null,e.to,m):x(O,!0),Q=[];return(p||d).to<(m||O).from-(p&&m?1:0)||d.widgetLineBreaks>1&&y.bottom+i.defaultLineHeight/2<k.top?Q.push(g(u,y.bottom,f,k.top)):y.bottom<k.top&&i.elementAtHeight((y.bottom+k.top)/2).type==pe.Text&&(y.bottom=k.top=(y.bottom+k.top)/2),b(y).concat(Q).concat(b(k))}function g(y,k,Q,X){return new Or(t,y-a.left,k-a.top,Math.max(0,Q-y),X-k)}function b({top:y,bottom:k,horizontal:Q}){let X=[];for(let B=0;B<Q.length;B+=2)X.push(g(Q[B],y,Q[B+1],k));return X}function S(y,k,Q){let X=1e9,B=-1e9,L=[];function V(U,H,Xt,_t,Yt){let lt=i.coordsAtPos(U,U==Q.to?-2:2),Vt=i.coordsAtPos(Xt,Xt==Q.from?2:-2);!lt||!Vt||(X=Math.min(lt.top,Vt.top,X),B=Math.max(lt.bottom,Vt.bottom,B),Yt==Tt.LTR?L.push(s&&H?u:lt.left,s&&_t?f:Vt.right):L.push(!s&&_t?u:Vt.left,!s&&H?f:lt.right))}let _=y??Q.from,G=k??Q.to;for(let U of i.visibleRanges)if(U.to>_&&U.from<G)for(let H=Math.max(U.from,_),Xt=Math.min(U.to,G);;){let _t=i.state.doc.lineAt(H);for(let Yt of i.bidiSpans(_t)){let lt=Yt.from+_t.from,Vt=Yt.to+_t.from;if(lt>=Xt)break;Vt>H&&V(Math.max(lt,H),y==null&&lt<=_,Math.min(Vt,Xt),k==null&&Vt>=G,Yt.dir)}if(H=_t.to+1,H>=Xt)break}return L.length==0&&V(_,y==null,G,k==null,i.textDirection),{top:X,bottom:B,horizontal:L}}function x(y,k){let Q=l.top+(k?y.top:y.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function dk(i,t){return i.constructor==t.constructor&&i.eq(t)}class Ok{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(wa)!=t.state.facet(wa)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,n=t.facet(wa);for(;e<n.length&&n[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;(t!=this.scaleX||e!=this.scaleY)&&(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some((e,n)=>!dk(e,this.drawn[n]))){let e=this.dom.firstChild,n=0;for(let r of t)r.update&&e&&r.constructor&&this.drawn[n].constructor&&r.update(e,this.drawn[n])?(e=e.nextSibling,n++):this.dom.insertBefore(r.draw(),e);for(;e;){let r=e.nextSibling;e.remove(),e=r}this.drawn=t,M.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const wa=D.define();function Kb(i){return[ui.define(t=>new Ok(t,i)),wa.of(i)]}const Gs=D.define({combine(i){return eb(i,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});function pk(i={}){return[Gs.of(i),mk,gk,bk,kb.of(!0)]}function Jb(i){return i.startState.facet(Gs)!=i.state.facet(Gs)}const mk=Kb({above:!0,markers(i){let{state:t}=i,e=t.facet(Gs),n=[];for(let r of t.selection.ranges){let s=r==t.selection.main;if(r.empty||e.drawRangeCursor&&!(s&&M.ios&&e.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:C.cursor(r.head,r.assoc);for(let a of Or.forRange(i,o,l))n.push(a)}}return n},update(i,t){i.transactions.some(n=>n.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let e=Jb(i);return e&&NO(i.state,t),i.docChanged||i.selectionSet||e},mount(i,t){NO(t.state,i)},class:"cm-cursorLayer"});function NO(i,t){t.style.animationDuration=i.facet(Gs).cursorBlinkRate+"ms"}const gk=Kb({above:!1,markers(i){let t=[],{main:e,ranges:n}=i.state.selection;for(let r of n)if(!r.empty)for(let s of Or.forRange(i,"cm-selectionBackground",r))t.push(s);if(M.ios&&!e.empty&&i.state.facet(Gs).iosSelectionHandles){for(let r of Or.forRange(i,"cm-selectionHandle cm-selectionHandle-start",C.cursor(e.from,1)))t.push(r);for(let r of Or.forRange(i,"cm-selectionHandle cm-selectionHandle-end",C.cursor(e.to,1)))t.push(r)}return t},update(i,t){return i.docChanged||i.selectionSet||i.viewportChanged||Jb(i)},class:"cm-selectionLayer"}),bk=hn.highest(z.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Hl="-10000px";class wk{constructor(t,e,n,r){this.facet=e,this.createTooltipView=n,this.removeTooltipView=r,this.input=t.state.facet(e),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=n(o,s))}update(t,e){var n;let r=t.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(t);return!1}let o=[],l=e?[]:null;for(let a=0;a<s.length;a++){let c=s[a],h=-1;if(c){for(let u=0;u<this.tooltips.length;u++){let f=this.tooltips[u];f&&f.create==c.create&&(h=u)}if(h<0)o[a]=this.createTooltipView(c,a?o[a-1]:null),l&&(l[a]=!!c.above);else{let u=o[a]=this.tooltipViews[h];l&&(l[a]=e[h]),u.update&&u.update(t)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(n=a.destroy)===null||n===void 0||n.call(a));return e&&(l.forEach((a,c)=>e[c]=a),e.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function Sk(i){let t=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Oh=D.define({combine:i=>{var t,e,n;return{position:M.ios?"absolute":((t=i.find(r=>r.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((e=i.find(r=>r.parent))===null||e===void 0?void 0:e.parent)||null,tooltipSpace:((n=i.find(r=>r.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||Sk}}}),GO=new WeakMap,t0=ui.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=i.state.facet(Oh);this.position=t.position,this.parent=t.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new wk(i,e0,(e,n)=>this.createTooltip(e,n),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(i,this.above);t&&this.observeIntersection();let e=t||i.geometryChanged,n=i.state.facet(Oh);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;e=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);e=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);e&&this.maybeMeasure()}createTooltip(i,t){let e=i.create(this.view),n=t?t.dom:null;if(e.dom.classList.add("cm-tooltip"),i.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",e.dom.appendChild(r)}return e.dom.style.position=this.position,e.dom.style.top=Hl,e.dom.style.left="0px",this.container.insertBefore(e.dom,n),e.mount&&e.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(e.dom),e}destroy(){var i,t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,t=1,e=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(M.safari){let o=s.getBoundingClientRect();e=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else e=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(e||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(i=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:t}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),r=Mf(this.view);return{visible:{left:n.left+r.left,top:n.top+r.top,right:n.right-r.right,bottom:n.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Oh).tooltipSpace(this.view),scaleX:i,scaleY:t,makeAbsolute:e}}writeMeasure(i){var t;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:e,space:n,scaleX:r,scaleY:s}=i,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],c=this.manager.tooltipViews[l],{dom:h}=c,u=i.pos[l],f=i.size[l];if(!u||a.clip!==!1&&(u.bottom<=Math.max(e.top,n.top)||u.top>=Math.min(e.bottom,n.bottom)||u.right<Math.max(e.left,n.left)-.1||u.left>Math.min(e.right,n.right)+.1)){h.style.top=Hl;continue}let d=a.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,O=d?7:0,p=f.right-f.left,m=(t=GO.get(c))!==null&&t!==void 0?t:f.bottom-f.top,g=c.offset||xk,b=this.view.textDirection==Tt.LTR,S=f.width>n.right-n.left?b?n.left:n.right-f.width:b?Math.max(n.left,Math.min(u.left-(d?14:0)+g.x,n.right-p)):Math.min(Math.max(n.left,u.left-p+(d?14:0)-g.x),n.right-p),x=this.above[l];!a.strictSide&&(x?u.top-m-O-g.y<n.top:u.bottom+m+O+g.y>n.bottom)&&x==n.bottom-u.bottom>u.top-n.top&&(x=this.above[l]=!x);let y=(x?u.top-n.top:n.bottom-u.bottom)-O;if(y<m&&c.resize!==!1){if(y<this.view.defaultLineHeight){h.style.top=Hl;continue}GO.set(c,m),h.style.height=(m=y)/s+"px"}else h.style.height&&(h.style.height="");let k=x?u.top-m-O-g.y:u.bottom+O+g.y,Q=S+p;if(c.overlap!==!0)for(let X of o)X.left<Q&&X.right>S&&X.top<k+m&&X.bottom>k&&(k=x?X.top-m-2-O:X.bottom+O+2);if(this.position=="absolute"?(h.style.top=(k-i.parent.top)/s+"px",UO(h,(S-i.parent.left)/r)):(h.style.top=k/s+"px",UO(h,S/r)),d){let X=u.left+(b?g.x:-g.x)-(S+14-7);d.style.left=X/r+"px"}c.overlap!==!0&&o.push({left:S,top:k,right:Q,bottom:k+m}),h.classList.toggle("cm-tooltip-above",x),h.classList.toggle("cm-tooltip-below",!x),c.positioned&&c.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=Hl}},{eventObservers:{scroll(){this.maybeMeasure()}}});function UO(i,t){let e=parseInt(i.style.left,10);(isNaN(e)||Math.abs(t-e)>1)&&(i.style.left=t+"px")}const vk=z.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),xk={x:0,y:0},e0=D.define({enables:[t0,vk]});function yk(i,t){let e=i.plugin(t0);if(!e)return null;let n=e.manager.tooltips.indexOf(t);return n<0?null:e.manager.tooltipViews[n]}class Us extends Zn{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Us.prototype.elementClass="";Us.prototype.toDOM=void 0;Us.prototype.mapMode=Oe.TrackBefore;Us.prototype.startSide=Us.prototype.endSide=-1;Us.prototype.point=!0;const i0=1024;let kk=0;class qe{constructor(t,e){this.from=t,this.to=e}}class N{constructor(t={}){this.id=kk++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=qt.match(t)),e=>{let n=t(e);return n===void 0?null:[this,n]}}}N.closedBy=new N({deserialize:i=>i.split(" ")});N.openedBy=new N({deserialize:i=>i.split(" ")});N.group=new N({deserialize:i=>i.split(" ")});N.isolate=new N({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});N.contextHash=new N({perNode:!0});N.lookAhead=new N({perNode:!0});N.mounted=new N({perNode:!0});class Dr{constructor(t,e,n,r=!1){this.tree=t,this.overlay=e,this.parser=n,this.bracketed=r}static get(t){return t&&t.props&&t.props[N.mounted.id]}}const Qk=Object.create(null);class qt{constructor(t,e,n,r=0){this.name=t,this.props=e,this.id=n,this.flags=r}static define(t){let e=t.props&&t.props.length?Object.create(null):Qk,n=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),r=new qt(t.name||"",e,t.id,n);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[s[0].id]=s[1]}}return r}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(N.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let n in t)for(let r of n.split(" "))e[r]=t[n];return n=>{for(let r=n.prop(N.group),s=-1;s<(r?r.length:0);s++){let o=e[s<0?n.name:r[s]];if(o)return o}}}}qt.none=new qt("",Object.create(null),0,8);class Ql{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let n of this.types){let r=null;for(let s of t){let o=s(n);if(o){r||(r=Object.assign({},n.props));let l=o[1],a=o[0];a.combine&&a.id in r&&(l=a.combine(r[a.id],l)),r[a.id]=l}}e.push(r?new qt(n.name,r,n.id,n.flags):n)}return new Ql(e)}}const Fl=new WeakMap,HO=new WeakMap;var ft;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays",i[i.EnterBracketed=16]="EnterBracketed"})(ft||(ft={}));class ht{constructor(t,e,n,r,s){if(this.type=t,this.children=e,this.positions=n,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let t=Dr.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let n of this.children){let r=n.toString();r&&(e&&(e+=","),e+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new Va(this.topNode,t)}cursorAt(t,e=0,n=0){let r=Fl.get(this)||this.topNode,s=new Va(r);return s.moveTo(t,e),Fl.set(this,s._tree),s}get topNode(){return new he(this,0,0,null)}resolve(t,e=0){let n=Jo(Fl.get(this)||this.topNode,t,e,!1);return Fl.set(this,n),n}resolveInner(t,e=0){let n=Jo(HO.get(this)||this.topNode,t,e,!0);return HO.set(this,n),n}resolveStack(t,e=0){return Pk(this,t,e)}iterate(t){let{enter:e,leave:n,from:r=0,to:s=this.length}=t,o=t.mode||0,l=(o&ft.IncludeAnonymous)>0;for(let a=this.cursor(o|ft.IncludeAnonymous);;){let c=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||e(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;c=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:Vf(qt.none,this.children,this.positions,0,this.children.length,0,this.length,(e,n,r)=>new ht(this.type,e,n,r,this.propValues),t.makeTree||((e,n,r)=>new ht(qt.none,e,n,r)))}static build(t){return Tk(t)}}ht.empty=new ht(qt.none,[],[],0);class jf{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new jf(this.buffer,this.index)}}class Mn{constructor(t,e,n){this.buffer=t,this.length=e,this.set=n}get type(){return qt.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],n=this.buffer[t+3],r=this.set.types[e],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),t+=4,n==t)return s;let o=[];for(;t<n;)o.push(this.childString(t)),t=this.buffer[t+3];return s+"("+o.join(",")+")"}findChild(t,e,n,r,s){let{buffer:o}=this,l=-1;for(let a=t;a!=e&&!(n0(s,r,o[a+1],o[a+2])&&(l=a,n>0));a=o[a+3]);return l}slice(t,e,n){let r=this.buffer,s=new Uint16Array(e-t),o=0;for(let l=t,a=0;l<e;){s[a++]=r[l++],s[a++]=r[l++]-n;let c=s[a++]=r[l++]-n;s[a++]=r[l++]-t,o=Math.max(o,c)}return new Mn(s,o,this.set)}}function n0(i,t,e,n){switch(i){case-2:return e<t;case-1:return n>=t&&e<t;case 0:return e<t&&n>t;case 1:return e<=t&&n>t;case 2:return n>t;case 4:return!0}}function Jo(i,t,e,n){for(var r;i.from==i.to||(e<1?i.from>=t:i.from>t)||(e>-1?i.to<=t:i.to<t);){let o=!n&&i instanceof he&&i.index<0?null:i.parent;if(!o)return i;i=o}let s=n?0:ft.IgnoreOverlays;if(n)for(let o=i,l=o.parent;l;o=l,l=o.parent)o instanceof he&&o.index<0&&((r=l.enter(t,e,s))===null||r===void 0?void 0:r.from)!=o.from&&(i=l);for(;;){let o=i.enter(t,e,s);if(!o)return i;i=o}}class r0{cursor(t=0){return new Va(this,t)}getChild(t,e=null,n=null){let r=FO(this,t,e,n);return r.length?r[0]:null}getChildren(t,e=null,n=null){return FO(this,t,e,n)}resolve(t,e=0){return Jo(this,t,e,!1)}resolveInner(t,e=0){return Jo(this,t,e,!0)}matchContext(t){return Tu(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),n=this;for(;e;){let r=e.lastChild;if(!r||r.to!=e.to)break;r.type.isError&&r.from==r.to?(n=e,e=r.prevSibling):e=r}return n}get node(){return this}get next(){return this.parent}}class he extends r0{constructor(t,e,n,r){super(),this._tree=t,this.from=e,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,n,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,c=e>0?l.length:-1;t!=c;t+=e){let h=l[t],u=a[t]+o.from,f;if(!(!(s&ft.EnterBracketed&&h instanceof ht&&(f=Dr.get(h))&&!f.overlay&&f.bracketed&&n>=u&&n<=u+h.length)&&!n0(r,n,u,u+h.length))){if(h instanceof Mn){if(s&ft.ExcludeBuffers)continue;let d=h.findChild(0,h.buffer.length,e,n-u,r);if(d>-1)return new Mi(new $k(o,h,t,u),null,d)}else if(s&ft.IncludeAnonymous||!h.type.isAnonymous||Df(h)){let d;if(!(s&ft.IgnoreMounts)&&(d=Dr.get(h))&&!d.overlay)return new he(d.tree,u,t,o);let O=new he(h,u,t,o);return s&ft.IncludeAnonymous||!O.type.isAnonymous?O:O.nextChild(e<0?h.children.length-1:0,e,n,r,s)}}}if(s&ft.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,n=0){let r;if(!(n&ft.IgnoreOverlays)&&(r=Dr.get(this._tree))&&r.overlay){let s=t-this.from,o=n&ft.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((e>0||o?l<=s:l<s)&&(e<0||o?a>=s:a>s))return new he(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function FO(i,t,e,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(e!=null){for(let o=!1;!o;)if(o=r.type.is(e),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(t)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function Tu(i,t,e=t.length-1){for(let n=i;e>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[e]&&t[e]!=n.name)return!1;e--}}return!0}class $k{constructor(t,e,n,r){this.parent=t,this.buffer=e,this.index=n,this.start=r}}class Mi extends r0{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,n){super(),this.context=t,this._parent=e,this.index=n,this.type=t.buffer.set.types[t.buffer.buffer[n]]}child(t,e,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.context.start,n);return s<0?null:new Mi(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,n=0){if(n&ft.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new Mi(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Mi(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new Mi(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];t.push(n.slice(r,s,o)),e.push(0)}return new ht(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function s0(i){if(!i.length)return null;let t=0,e=i[0];for(let s=1;s<i.length;s++){let o=i[s];(o.from>e.from||o.to<e.to)&&(e=o,t=s)}let n=e instanceof he&&e.index<0?null:e.parent,r=i.slice();return n?r[t]=n:r.splice(t,1),new Ck(r,e)}class Ck{constructor(t,e){this.heads=t,this.node=e}get next(){return s0(this.heads)}}function Pk(i,t,e){let n=i.resolveInner(t,e),r=null;for(let s=n instanceof he?n:n.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[n])).push(o.resolve(t,e)),s=o}else{let o=Dr.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let l=new he(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(Jo(l,t,e,!1))}}return r?s0(r):n}class Va{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~ft.EnterBracketed,t instanceof he)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let n=t._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:n,buffer:r}=this.buffer;return this.type=e||r.set.types[r.buffer[t]],this.from=n+r.buffer[t+1],this.to=n+r.buffer[t+2],!0}yield(t){return t?t instanceof he?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,n){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,n=this.mode){return this.buffer?n&ft.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ft.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&ft.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,n=this.stack.length-1;if(t<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(e.findChild(r,this.index,-1,0,4))}else{let r=e.buffer[this.index+3];if(r<(n<0?e.buffer.length:e.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,n,{buffer:r}=this;if(r){if(t>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:e,parent:n}=r)}else({index:e,_parent:n}=this._tree);for(;n;{index:e,_parent:n}=n)if(e>-1)for(let s=e+t,o=t<0?-1:n._tree.children.length;s!=o;s+=t){let l=n._tree.children[s];if(this.mode&ft.IncludeAnonymous||l instanceof Mn||!l.type.isAnonymous||Df(l))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,n=0;if(t&&t.context==this.buffer)t:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=t;o;o=o._parent)if(o.index==r){if(r==this.index)return o;e=o,n=s+1;break t}r=this.stack[--s]}for(let r=n;r<this.stack.length;r++)e=new Mi(this.buffer,e,this.stack[r]);return this.bufferNode=new Mi(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let n=0;;){let r=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&e&&e(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(t){if(!this.buffer)return Tu(this.node.parent,t);let{buffer:e}=this.buffer,{types:n}=e.set;for(let r=t.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return Tu(this._tree,t,r);let o=n[e.buffer[this.stack[s]]];if(!o.isAnonymous){if(t[r]&&t[r]!=o.name)return!1;r--}}return!0}}function Df(i){return i.children.some(t=>t instanceof Mn||!t.type.isAnonymous||Df(t))}function Tk(i){var t;let{buffer:e,nodeSet:n,maxBufferLength:r=i0,reused:s=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(e)?new jf(e,e.length):e,a=n.types,c=0,h=0;function u(y,k,Q,X,B,L){let{id:V,start:_,end:G,size:U}=l,H=h,Xt=c;if(U<0)if(l.next(),U==-1){let $e=s[V];Q.push($e),X.push(_-y);return}else if(U==-3){c=V;return}else if(U==-4){h=V;return}else throw new RangeError(`Unrecognized record size: ${U}`);let _t=a[V],Yt,lt,Vt=_-y;if(G-_<=r&&(lt=m(l.pos-k,B))){let $e=new Uint16Array(lt.size-lt.skip),yt=l.pos-lt.size,Nt=$e.length;for(;l.pos>yt;)Nt=g(lt.start,$e,Nt);Yt=new Mn($e,G-lt.start,n),Vt=lt.start-y}else{let $e=l.pos-U;l.next();let yt=[],Nt=[],re=V>=o?V:-1,be=0,tt=G;for(;l.pos>$e;)re>=0&&l.id==re&&l.size>=0?(l.end<=tt-r&&(O(yt,Nt,_,be,l.end,tt,re,H,Xt),be=yt.length,tt=l.end),l.next()):L>2500?f(_,$e,yt,Nt):u(_,$e,yt,Nt,re,L+1);if(re>=0&&be>0&&be<yt.length&&O(yt,Nt,_,be,_,tt,re,H,Xt),yt.reverse(),Nt.reverse(),re>-1&&be>0){let pt=d(_t,Xt);Yt=Vf(_t,yt,Nt,0,yt.length,0,G-_,pt,pt)}else Yt=p(_t,yt,Nt,G-_,H-G,Xt)}Q.push(Yt),X.push(Vt)}function f(y,k,Q,X){let B=[],L=0,V=-1;for(;l.pos>k;){let{id:_,start:G,end:U,size:H}=l;if(H>4)l.next();else{if(V>-1&&G<V)break;V<0&&(V=U-r),B.push(_,G,U),L++,l.next()}}if(L){let _=new Uint16Array(L*4),G=B[B.length-2];for(let U=B.length-3,H=0;U>=0;U-=3)_[H++]=B[U],_[H++]=B[U+1]-G,_[H++]=B[U+2]-G,_[H++]=H;Q.push(new Mn(_,B[2]-G,n)),X.push(G-y)}}function d(y,k){return(Q,X,B)=>{let L=0,V=Q.length-1,_,G;if(V>=0&&(_=Q[V])instanceof ht){if(!V&&_.type==y&&_.length==B)return _;(G=_.prop(N.lookAhead))&&(L=X[V]+_.length+G)}return p(y,Q,X,B,L,k)}}function O(y,k,Q,X,B,L,V,_,G){let U=[],H=[];for(;y.length>X;)U.push(y.pop()),H.push(k.pop()+Q-B);y.push(p(n.types[V],U,H,L-B,_-L,G)),k.push(B-Q)}function p(y,k,Q,X,B,L,V){if(L){let _=[N.contextHash,L];V=V?[_].concat(V):[_]}if(B>25){let _=[N.lookAhead,B];V=V?[_].concat(V):[_]}return new ht(y,k,Q,X,V)}function m(y,k){let Q=l.fork(),X=0,B=0,L=0,V=Q.end-r,_={size:0,start:0,skip:0};t:for(let G=Q.pos-y;Q.pos>G;){let U=Q.size;if(Q.id==k&&U>=0){_.size=X,_.start=B,_.skip=L,L+=4,X+=4,Q.next();continue}let H=Q.pos-U;if(U<0||H<G||Q.start<V)break;let Xt=Q.id>=o?4:0,_t=Q.start;for(Q.next();Q.pos>H;){if(Q.size<0)if(Q.size==-3||Q.size==-4)Xt+=4;else break t;else Q.id>=o&&(Xt+=4);Q.next()}B=_t,X+=U,L+=Xt}return(k<0||X==y)&&(_.size=X,_.start=B,_.skip=L),_.size>4?_:void 0}function g(y,k,Q){let{id:X,start:B,end:L,size:V}=l;if(l.next(),V>=0&&X<o){let _=Q;if(V>4){let G=l.pos-(V-4);for(;l.pos>G;)Q=g(y,k,Q)}k[--Q]=_,k[--Q]=L-y,k[--Q]=B-y,k[--Q]=X}else V==-3?c=X:V==-4&&(h=X);return Q}let b=[],S=[];for(;l.pos>0;)u(i.start||0,i.bufferStart||0,b,S,-1,0);let x=(t=i.length)!==null&&t!==void 0?t:b.length?S[0]+b[0].length:0;return new ht(a[i.topID],b.reverse(),S.reverse(),x)}const KO=new WeakMap;function Sa(i,t){if(!i.isAnonymous||t instanceof Mn||t.type!=i)return 1;let e=KO.get(t);if(e==null){e=1;for(let n of t.children){if(n.type!=i||!(n instanceof ht)){e=1;break}e+=Sa(i,n)}KO.set(t,e)}return e}function Vf(i,t,e,n,r,s,o,l,a){let c=0;for(let O=n;O<r;O++)c+=Sa(i,t[O]);let h=Math.ceil(c*1.5/8),u=[],f=[];function d(O,p,m,g,b){for(let S=m;S<g;){let x=S,y=p[S],k=Sa(i,O[S]);for(S++;S<g;S++){let Q=Sa(i,O[S]);if(k+Q>=h)break;k+=Q}if(S==x+1){if(k>h){let Q=O[x];d(Q.children,Q.positions,0,Q.children.length,p[x]+b);continue}u.push(O[x])}else{let Q=p[S-1]+O[S-1].length-y;u.push(Vf(i,O,p,x,S,y,Q,null,a))}f.push(y+b-s)}}return d(t,e,n,r,0),(l||a)(u,f,o)}class o0{constructor(){this.map=new WeakMap}setBuffer(t,e,n){let r=this.map.get(t);r||this.map.set(t,r=new Map),r.set(e,n)}getBuffer(t,e){let n=this.map.get(t);return n&&n.get(e)}set(t,e){t instanceof Mi?this.setBuffer(t.context.buffer,t.index,e):t instanceof he&&this.map.set(t.tree,e)}get(t){return t instanceof Mi?this.getBuffer(t.context.buffer,t.index):t instanceof he?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class rn{constructor(t,e,n,r,s=!1,o=!1){this.from=t,this.to=e,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],n=!1){let r=[new rn(0,t.length,t,0,!1,n)];for(let s of e)s.to>t.length&&r.push(s);return r}static applyChanges(t,e,n=128){if(!e.length)return t;let r=[],s=1,o=t.length?t[0]:null;for(let l=0,a=0,c=0;;l++){let h=l<e.length?e[l]:null,u=h?h.fromA:1e9;if(u-a>=n)for(;o&&o.from<u;){let f=o;if(a>=f.from||u<=f.to||c){let d=Math.max(f.from,a)-c,O=Math.min(f.to,u)-c;f=d>=O?null:new rn(d,O,f.tree,f.offset+c,l>0,!!h)}if(f&&r.push(f),o.to>u)break;o=s<t.length?t[s++]:null}if(!h)break;a=h.toA,c=h.toA-h.toB}return r}}class Bf{startParse(t,e,n){return typeof t=="string"&&(t=new Ak(t)),n=n?n.length?n.map(r=>new qe(r.from,r.to)):[new qe(0,0)]:[new qe(0,t.length)],this.createParse(t,e||[],n)}parse(t,e,n){let r=this.startParse(t,e,n);for(;;){let s=r.advance();if(s)return s}}}class Ak{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function l0(i){return(t,e,n,r)=>new Zk(t,i,e,n,r)}class JO{constructor(t,e,n,r,s,o){this.parser=t,this.parse=e,this.overlay=n,this.bracketed=r,this.target=s,this.from=o}}function tp(i){if(!i.length||i.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(i))}class Rk{constructor(t,e,n,r,s,o,l,a){this.parser=t,this.predicate=e,this.mounts=n,this.index=r,this.start=s,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Au=new N({perNode:!0});class Zk{constructor(t,e,n,r,s){this.nest=e,this.input=n,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let n=this.baseParse.advance();if(!n)return null;if(this.baseParse=null,this.baseTree=n,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let n=this.baseTree;return this.stoppedAt!=null&&(n=new ht(n.type,n.children,n.positions,n.length,n.propValues.concat([[Au,this.stoppedAt]]))),n}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let n=Object.assign(Object.create(null),t.target.props);n[N.mounted.id]=new Dr(e,t.overlay,t.parser,t.bracketed),t.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new Lk(this.fragments),e=null,n=null,r=new Va(new he(this.baseTree,this.ranges[0].from,0,null),ft.IncludeAnonymous|ft.IgnoreMounts);t:for(let s,o;;){let l=!0,a;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)l=!1;else if(t.hasNode(r)){if(e){let c=e.mounts.find(h=>h.frag.from<=r.from&&h.frag.to>=r.to&&h.mount.overlay);if(c)for(let h of c.mount.overlay){let u=h.from+c.pos,f=h.to+c.pos;u>=r.from&&f<=r.to&&!e.ranges.some(d=>d.from<f&&d.to>u)&&e.ranges.push({from:u,to:f})}}l=!1}else if(n&&(o=Xk(n.ranges,r.from,r.to)))l=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.from<r.to||!s.overlay)){r.tree||(Ek(r),e&&e.depth++,n&&n.depth++);let c=t.findMounts(r.from,s.parser);if(typeof s.overlay=="function")e=new Rk(s.parser,s.overlay,c,this.inner.length,r.from,!!s.bracketed,r.tree,e);else{let h=np(this.ranges,s.overlay||(r.from<r.to?[new qe(r.from,r.to)]:[]));h.length&&tp(h),(h.length||!s.overlay)&&this.inner.push(new JO(s.parser,h.length?s.parser.startParse(this.input,rp(c,h),h):s.parser.startParse(""),s.overlay?s.overlay.map(u=>new qe(u.from-r.from,u.to-r.from)):null,!!s.bracketed,r.tree,h.length?h[0].from:r.from)),s.overlay?h.length&&(n={ranges:h,depth:0,prev:n}):l=!1}}else if(e&&(a=e.predicate(r))&&(a===!0&&(a=new qe(r.from,r.to)),a.from<a.to)){let c=e.ranges.length-1;c>=0&&e.ranges[c].to==a.from?e.ranges[c]={from:e.ranges[c].from,to:a.to}:e.ranges.push(a)}if(l&&r.firstChild())e&&e.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break t;if(e&&!--e.depth){let c=np(this.ranges,e.ranges);c.length&&(tp(c),this.inner.splice(e.index,0,new JO(e.parser,e.parser.startParse(this.input,rp(e.mounts,c),c),e.ranges.map(h=>new qe(h.from-e.start,h.to-e.start)),e.bracketed,e.target,c[0].from))),e=e.prev}n&&!--n.depth&&(n=n.prev)}}}}function Xk(i,t,e){for(let n of i){if(n.from>=e)break;if(n.to>t)return n.from<=t&&n.to>=e?2:1}return 0}function ep(i,t,e,n,r,s){if(t<e){let o=i.buffer[t+1];n.push(i.slice(t,e,o)),r.push(o-s)}}function Ek(i){let{node:t}=i,e=[],n=t.context.buffer;do e.push(i.index),i.parent();while(!i.tree);let r=i.tree,s=r.children.indexOf(n),o=r.children[s],l=o.buffer,a=[s];function c(h,u,f,d,O,p){let m=e[p],g=[],b=[];ep(o,h,m,g,b,d);let S=l[m+1],x=l[m+2];a.push(g.length);let y=p?c(m+4,l[m+3],o.set.types[l[m]],S,x-S,p-1):t.toTree();return g.push(y),b.push(S-d),ep(o,l[m+3],u,g,b,d),new ht(f,g,b,O)}r.children[s]=c(0,l.length,qt.none,0,o.length,e.length-1);for(let h of a){let u=i.tree.children[h],f=i.tree.positions[h];i.yield(new he(u,f+i.from,h,i._tree))}}class ip{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(ft.IncludeAnonymous|ft.IgnoreMounts)}moveTo(t){let{cursor:e}=this,n=t-this.offset;for(;!this.done&&e.from<n;)if(!(e.to>=t&&e.enter(n,1,ft.IgnoreOverlays|ft.ExcludeBuffers)))if(e.to<=t)e.next(!1)||(this.done=!0);else break}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof ht)e=e.children[0];else break}return!1}}let Lk=class{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let n=this.curFrag=t[0];this.curTo=(e=n.tree.prop(Au))!==null&&e!==void 0?e:n.to,this.inner=new ip(n.tree,-n.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=(t=e.tree.prop(Au))!==null&&t!==void 0?t:e.to,this.inner=new ip(e.tree,-e.offset)}}findMounts(t,e){var n;let r=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(n=s.tree)===null||n===void 0?void 0:n.prop(N.mounted);if(o&&o.parser==e)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=s.to)break;a.tree==this.curFrag.tree&&r.push({frag:a,pos:s.from-a.offset,mount:o})}}}return r}};function np(i,t){let e=null,n=t;for(let r=1,s=0;r<i.length;r++){let o=i[r-1].to,l=i[r].from;for(;s<n.length;s++){let a=n[s];if(a.from>=l)break;a.to<=o||(e||(n=e=t.slice()),a.from<o?(e[s]=new qe(a.from,o),a.to>l&&e.splice(s+1,0,new qe(l,a.to))):a.to>l?e[s--]=new qe(l,a.to):e.splice(s--,1))}}return n}function Mk(i,t,e,n){let r=0,s=0,o=!1,l=!1,a=-1e9,c=[];for(;;){let h=r==i.length?1e9:o?i[r].to:i[r].from,u=s==t.length?1e9:l?t[s].to:t[s].from;if(o!=l){let f=Math.max(a,e),d=Math.min(h,u,n);f<d&&c.push(new qe(f,d))}if(a=Math.min(h,u),a==1e9)break;h==a&&(o?(o=!1,r++):o=!0),u==a&&(l?(l=!1,s++):l=!0)}return c}function rp(i,t){let e=[];for(let{pos:n,mount:r,frag:s}of i){let o=n+(r.overlay?r.overlay[0].from:0),l=o+r.tree.length,a=Math.max(s.from,o),c=Math.min(s.to,l);if(r.overlay){let h=r.overlay.map(f=>new qe(f.from+n,f.to+n)),u=Mk(t,h,a,c);for(let f=0,d=a;;f++){let O=f==u.length,p=O?c:u[f].from;if(p>d&&e.push(new rn(d,p,r.tree,-o,s.from>=d||s.openStart,s.to<=p||s.openEnd)),O)break;d=u[f].to}}else e.push(new rn(a,c,r.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return e}let zk=0;class _e{constructor(t,e,n,r){this.name=t,this.set=e,this.base=n,this.modified=r,this.id=zk++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let n=typeof t=="string"?t:"?";if(t instanceof _e&&(e=t),e!=null&&e.base)throw new Error("Can not derive from a modified tag");let r=new _e(n,[],null,[]);if(r.set.push(r),e)for(let s of e.set)r.set.push(s);return r}static defineModifier(t){let e=new Ba(t);return n=>n.modified.indexOf(e)>-1?n:Ba.get(n.base||n,n.modified.concat(e).sort((r,s)=>r.id-s.id))}}let _k=0;class Ba{constructor(t){this.name=t,this.instances=[],this.id=_k++}static get(t,e){if(!e.length)return t;let n=e[0].instances.find(l=>l.base==t&&Ik(e,l.modified));if(n)return n;let r=[],s=new _e(t.name,r,t,e);for(let l of e)l.instances.push(s);let o=jk(e);for(let l of t.set)if(!l.modified.length)for(let a of o)r.push(Ba.get(l,a));return s}}function Ik(i,t){return i.length==t.length&&i.every((e,n)=>e==t[n])}function jk(i){let t=[[]];for(let e=0;e<i.length;e++)for(let n=0,r=t.length;n<r;n++)t.push(t[n].concat(i[e]));return t.sort((e,n)=>n.length-e.length)}function ho(i){let t=Object.create(null);for(let e in i){let n=i[e];Array.isArray(n)||(n=[n]);for(let r of e.split(" "))if(r){let s=[],o=2,l=r;for(let u=0;;){if(l=="..."&&u>0&&u+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==r.length)break;let d=r[u++];if(u==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(u)}let a=s.length-1,c=s[a];if(!c)throw new RangeError("Invalid path: "+r);let h=new tl(n,o,a>0?s.slice(0,a):null);t[c]=h.sort(t[c])}}return a0.add(t)}const a0=new N({combine(i,t){let e,n,r;for(;i||t;){if(!i||t&&i.depth>=t.depth?(r=t,t=t.next):(r=i,i=i.next),e&&e.mode==r.mode&&!r.context&&!e.context)continue;let s=new tl(r.tags,r.mode,r.context);e?e.next=s:n=s,e=s}return n}});class tl{constructor(t,e,n,r){this.tags=t,this.mode=e,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}tl.empty=new tl([],2,null);function c0(i,t){let e=Object.create(null);for(let s of i)if(!Array.isArray(s.tag))e[s.tag.id]=s.class;else for(let o of s.tag)e[o.id]=s.class;let{scope:n,all:r=null}=t||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let c=e[a.id];if(c){o=o?o+" "+c:c;break}}return o},scope:n}}function Dk(i,t){let e=null;for(let n of i){let r=n.style(t);r&&(e=e?e+" "+r:r)}return e}function Vk(i,t,e,n=0,r=i.length){let s=new Bk(n,Array.isArray(t)?t:[t],e);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}class Bk{constructor(t,e,n){this.at=t,this.highlighters=e,this.span=n,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,n,r,s){let{type:o,from:l,to:a}=t;if(l>=n||a<=e)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let c=r,h=h0(t)||tl.empty,u=Dk(s,h.tags);if(u&&(c&&(c+=" "),c+=u,h.mode==1&&(r+=(r?" ":"")+u)),this.startSpan(Math.max(e,l),c),h.opaque)return;let f=t.tree&&t.tree.prop(N.mounted);if(f&&f.overlay){let d=t.node.enter(f.overlay[0].from+l,1),O=this.highlighters.filter(m=>!m.scope||m.scope(f.tree.type)),p=t.firstChild();for(let m=0,g=l;;m++){let b=m<f.overlay.length?f.overlay[m]:null,S=b?b.from+l:a,x=Math.max(e,g),y=Math.min(n,S);if(x<y&&p)for(;t.from<y&&(this.highlightRange(t,x,y,r,s),this.startSpan(Math.min(y,t.to),c),!(t.to>=S||!t.nextSibling())););if(!b||S>n)break;g=b.to+l,g>e&&(this.highlightRange(d.cursor(),Math.max(e,b.from+l),Math.min(n,g),"",O),this.startSpan(Math.min(n,g),c))}p&&t.parent()}else if(t.firstChild()){f&&(r="");do if(!(t.to<=e)){if(t.from>=n)break;this.highlightRange(t,e,n,r,s),this.startSpan(Math.min(n,t.to),c)}while(t.nextSibling());t.parent()}}}function h0(i){let t=i.type.prop(a0);for(;t&&t.context&&!i.matchContext(t.context);)t=t.next;return t||null}const Z=_e.define,Kl=Z(),mn=Z(),sp=Z(mn),op=Z(mn),gn=Z(),Jl=Z(gn),ph=Z(gn),Ci=Z(),qn=Z(Ci),ki=Z(),Qi=Z(),Ru=Z(),vo=Z(Ru),ta=Z(),v={comment:Kl,lineComment:Z(Kl),blockComment:Z(Kl),docComment:Z(Kl),name:mn,variableName:Z(mn),typeName:sp,tagName:Z(sp),propertyName:op,attributeName:Z(op),className:Z(mn),labelName:Z(mn),namespace:Z(mn),macroName:Z(mn),literal:gn,string:Jl,docString:Z(Jl),character:Z(Jl),attributeValue:Z(Jl),number:ph,integer:Z(ph),float:Z(ph),bool:Z(gn),regexp:Z(gn),escape:Z(gn),color:Z(gn),url:Z(gn),keyword:ki,self:Z(ki),null:Z(ki),atom:Z(ki),unit:Z(ki),modifier:Z(ki),operatorKeyword:Z(ki),controlKeyword:Z(ki),definitionKeyword:Z(ki),moduleKeyword:Z(ki),operator:Qi,derefOperator:Z(Qi),arithmeticOperator:Z(Qi),logicOperator:Z(Qi),bitwiseOperator:Z(Qi),compareOperator:Z(Qi),updateOperator:Z(Qi),definitionOperator:Z(Qi),typeOperator:Z(Qi),controlOperator:Z(Qi),punctuation:Ru,separator:Z(Ru),bracket:vo,angleBracket:Z(vo),squareBracket:Z(vo),paren:Z(vo),brace:Z(vo),content:Ci,heading:qn,heading1:Z(qn),heading2:Z(qn),heading3:Z(qn),heading4:Z(qn),heading5:Z(qn),heading6:Z(qn),contentSeparator:Z(Ci),list:Z(Ci),quote:Z(Ci),emphasis:Z(Ci),strong:Z(Ci),link:Z(Ci),monospace:Z(Ci),strikethrough:Z(Ci),inserted:Z(),deleted:Z(),changed:Z(),invalid:Z(),meta:ta,documentMeta:Z(ta),annotation:Z(ta),processingInstruction:Z(ta),definition:_e.defineModifier("definition"),constant:_e.defineModifier("constant"),function:_e.defineModifier("function"),standard:_e.defineModifier("standard"),local:_e.defineModifier("local"),special:_e.defineModifier("special")};for(let i in v){let t=v[i];t instanceof _e&&(t.name=i)}c0([{tag:v.link,class:"tok-link"},{tag:v.heading,class:"tok-heading"},{tag:v.emphasis,class:"tok-emphasis"},{tag:v.strong,class:"tok-strong"},{tag:v.keyword,class:"tok-keyword"},{tag:v.atom,class:"tok-atom"},{tag:v.bool,class:"tok-bool"},{tag:v.url,class:"tok-url"},{tag:v.labelName,class:"tok-labelName"},{tag:v.inserted,class:"tok-inserted"},{tag:v.deleted,class:"tok-deleted"},{tag:v.literal,class:"tok-literal"},{tag:v.string,class:"tok-string"},{tag:v.number,class:"tok-number"},{tag:[v.regexp,v.escape,v.special(v.string)],class:"tok-string2"},{tag:v.variableName,class:"tok-variableName"},{tag:v.local(v.variableName),class:"tok-variableName tok-local"},{tag:v.definition(v.variableName),class:"tok-variableName tok-definition"},{tag:v.special(v.variableName),class:"tok-variableName2"},{tag:v.definition(v.propertyName),class:"tok-propertyName tok-definition"},{tag:v.typeName,class:"tok-typeName"},{tag:v.namespace,class:"tok-namespace"},{tag:v.className,class:"tok-className"},{tag:v.macroName,class:"tok-macroName"},{tag:v.propertyName,class:"tok-propertyName"},{tag:v.operator,class:"tok-operator"},{tag:v.comment,class:"tok-comment"},{tag:v.meta,class:"tok-meta"},{tag:v.invalid,class:"tok-invalid"},{tag:v.punctuation,class:"tok-punctuation"}]);var mh;const rr=new N;function Wf(i){return D.define({combine:i?t=>t.concat(i):void 0})}const Yf=new N;class Ie{constructor(t,e,n=[],r=""){this.data=t,this.name=r,K.prototype.hasOwnProperty("tree")||Object.defineProperty(K.prototype,"tree",{get(){return St(this)}}),this.parser=e,this.extension=[Ks.of(this),K.languageData.of((s,o,l)=>{let a=lp(s,o,l),c=a.type.prop(rr);if(!c)return[];let h=s.facet(c),u=a.type.prop(Yf);if(u){let f=a.resolve(o-a.from,l);for(let d of u)if(d.test(f,s)){let O=s.facet(d.facet);return d.type=="replace"?O:O.concat(h)}}return h})].concat(n)}isActiveAt(t,e,n=-1){return lp(t,e,n).type.prop(rr)==this.data}findRegions(t){let e=t.facet(Ks);if((e==null?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(rr)==this.data){n.push({from:o,to:o+s.length});return}let l=s.prop(N.mounted);if(l){if(l.tree.prop(rr)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+s.length});return}else if(l.overlay){let a=n.length;if(r(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;a<s.children.length;a++){let c=s.children[a];c instanceof ht&&r(c,s.positions[a]+o)}};return r(St(t),0),n}get allowsNesting(){return!0}}Ie.setState=Ct.define();function lp(i,t,e){let n=i.facet(Ks),r=St(i).topNode;if(!n||n.allowsNesting)for(let s=r;s;s=s.enter(t,e,ft.ExcludeBuffers|ft.EnterBracketed))s.type.isTop&&(r=s);return r}class Hs extends Ie{constructor(t,e,n){super(t,e,[],n),this.parser=e}static define(t){let e=Wf(t.languageData);return new Hs(e,t.parser.configure({props:[rr.add(n=>n.isTop?e:void 0)]}),t.name)}configure(t,e){return new Hs(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function St(i){let t=i.field(Ie.state,!1);return t?t.tree:ht.empty}function Wk(i,t=i.doc.length){var e;return((e=i.field(Ie.state,!1))===null||e===void 0?void 0:e.context.isDone(t))||!1}class Tc{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let n=this.cursorPos-this.string.length;return t<n||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-n,e-n)}}let xo=null;class el{constructor(t,e,n=[],r,s,o,l,a){this.parser=t,this.state=e,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,n){return new el(t,e,[],ht.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Tc(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=ht.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof t=="number"){let r=Date.now()+t;t=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(rn.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(rn.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=xo;xo=this;try{return t()}finally{xo=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=ap(t,e.from,e.to);return t}changes(t,e){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let a=[];if(t.iterChangedRanges((c,h,u,f)=>a.push({fromA:c,toA:h,fromB:u,toB:f})),n=rn.applyChanges(n,a),r=ht.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let h=t.mapPos(c.from,1),u=t.mapPos(c.to,-1);h<u&&l.push({from:h,to:u})}}}return new el(this.parser,e,n,r,s,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:r,to:s}=this.skipped[n];r<t.to&&s>t.from&&(this.fragments=ap(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Bf{createParse(e,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=xo;if(a){for(let c of r)a.tempSkipped.push(c);t&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,t]):t)}return this.parsedPos=o,new ht(qt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return xo}}function ap(i,t,e){return rn.applyChanges(i,[{fromA:t,toA:e,fromB:t,toB:e}])}class Fs{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),n=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,n)||e.takeTree(),new Fs(e)}static init(t){let e=Math.min(3e3,t.doc.length),n=el.create(t.facet(Ks).parser,t,{from:0,to:e});return n.work(20,e)||n.takeTree(),new Fs(n)}}Ie.state=bi.define({create:Fs.init,update(i,t){for(let e of t.effects)if(e.is(Ie.setState))return e.value;return t.startState.facet(Ks)!=t.state.facet(Ks)?Fs.init(t.state):i.apply(t)}});let u0=i=>{let t=setTimeout(()=>i(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(u0=i=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(i,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const gh=typeof navigator<"u"&&(!((mh=navigator.scheduling)===null||mh===void 0)&&mh.isInputPending)?()=>navigator.scheduling.isInputPending():null,Yk=ui.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Ie.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Ie.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=u0(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,s=n.field(Ie.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!gh?Math.max(25,t.timeRemaining()-5):1e9),l=s.context.treeLen<r&&n.doc.length>r+1e3,a=s.context.work(()=>gh&&gh()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ie.setState.of(new Fs(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>Li(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ks=D.define({combine(i){return i.length?i[0]:null},enables:i=>[Ie.state,Yk,z.contentAttributes.compute([i],t=>{let e=t.facet(i);return e&&e.name?{"data-language":e.name}:{}})]});class il{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Wa{constructor(t,e,n,r,s,o=void 0){this.name=t,this.alias=e,this.extensions=n,this.filename=r,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:n}=t;if(!e){if(!n)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(n)}return new Wa(t.name,(t.alias||[]).concat(t.name).map(r=>r.toLowerCase()),t.extensions||[],t.filename,e,n)}static matchFilename(t,e){for(let r of t)if(r.filename&&r.filename.test(e))return r;let n=/\.([^.]+)$/.exec(e);if(n){for(let r of t)if(r.extensions.indexOf(n[1])>-1)return r}return null}static matchLanguageName(t,e,n=!0){e=e.toLowerCase();for(let r of t)if(r.alias.some(s=>s==e))return r;if(n)for(let r of t)for(let s of r.alias){let o=e.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(e[o-1])&&!/\w/.test(e[o+s.length])))return r}return null}}const qk=D.define(),uo=D.define({combine:i=>{if(!i.length)return" ";let t=i[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return t}});function Ya(i){let t=i.facet(uo);return t.charCodeAt(0)==9?i.tabSize*t.length:t.length}function qa(i,t){let e="",n=i.tabSize,r=i.facet(uo)[0];if(r==" "){for(;t>=n;)e+=" ",t-=n;r=" "}for(let s=0;s<t;s++)e+=r;return e}function f0(i,t){i instanceof K&&(i=new Ac(i));for(let n of i.state.facet(qk)){let r=n(i,t);if(r!==void 0)return r}let e=St(i.state);return e.length>=t?Nk(i,e,t):null}class Ac{constructor(t,e={}){this.state=t,this.options=e,this.unit=Ya(t)}lineAt(t,e=1){let n=this.state.doc.lineAt(t),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==t?{text:"",from:t}:(e<0?r<t:r<=t)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(t,e);return n.slice(t-r,Math.min(n.length,t+100-r))}column(t,e=1){let{text:n,from:r}=this.lineAt(t,e),s=this.countColumn(n,t-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(t,e=t.length){return an(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:n,from:r}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const $l=new N;function Nk(i,t,e){let n=t.resolveStack(e),r=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(r!=n.node){let s=[];for(let o=r;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return d0(n,i,e)}function d0(i,t,e){for(let n=i;n;n=n.next){let r=Uk(n.node);if(r)return r(qf.create(t,e,n))}return 0}function Gk(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function Uk(i){let t=i.type.prop($l);if(t)return t;let e=i.firstChild,n;if(e&&(n=e.type.prop(N.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>O0(o,!0,1,void 0,s&&!Gk(o)?r.from:void 0)}return i.parent==null?Hk:null}function Hk(){return 0}class qf extends Ac{constructor(t,e,n){super(t.state,t.options),this.base=t,this.pos=e,this.context=n}get node(){return this.context.node}static create(t,e,n){return new qf(t,e,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let n=t.resolve(e.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Fk(n,t))break;e=this.state.doc.lineAt(n.from)}return this.lineIndent(e.from)}continue(){return d0(this.context.next,this.base,this.pos)}}function Fk(i,t){for(let e=t;e;e=e.parent)if(i==e)return!0;return!1}function Kk(i){let t=i.node,e=t.childAfter(t.from),n=t.lastChild;if(!e)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(e.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=e.to;;){let a=t.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let c=/^ */.exec(s.text.slice(e.to-s.from))[0].length;return{from:e.from,to:e.to+c}}l=a.to}}function Jk({closing:i,align:t=!0,units:e=1}){return n=>O0(n,t,e,i)}function O0(i,t,e,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||r==i.pos+o,a=t?Kk(i):null;return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*e)}const tQ=i=>i.baseIndent;function va({except:i,units:t=1}={}){return e=>{let n=i&&i.test(e.textAfter);return e.baseIndent+(n?0:t*e.unit)}}const eQ=D.define(),Cl=new N;function p0(i){let t=i.firstChild,e=i.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?i.to:e.from}:null}class Rc{constructor(t,e){this.specs=t;let n;function r(l){let a=Xn.newName();return(n||(n=Object.create(null)))["."+a]=l,a}const s=typeof e.all=="string"?e.all:e.all?r(e.all):void 0,o=e.scope;this.scope=o instanceof Ie?l=>l.prop(rr)==o.data:o?l=>l==o:void 0,this.style=c0(t.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=n?new Xn(n):null,this.themeType=e.themeType}static define(t,e){return new Rc(t,e||{})}}const Zu=D.define(),iQ=D.define({combine(i){return i.length?[i[0]]:null}});function xa(i){let t=i.facet(Zu);return t.length?t:i.facet(iQ)}function m0(i,t){let e=[sQ],n;return i instanceof Rc&&(i.module&&e.push(z.styleModule.of(i.module)),n=i.themeType),n?e.push(Zu.computeN([z.darkTheme],r=>r.facet(z.darkTheme)==(n=="dark")?[i]:[])):e.push(Zu.of(i)),e}function nQ(i,t,e){let n=xa(i),r=null;if(n){for(let s of n)if(!s.scope||e){let o=s.style(t);o&&(r=r?r+" "+o:o)}}return r}class rQ{constructor(t){this.markCache=Object.create(null),this.tree=St(t.state),this.decorations=this.buildDeco(t,xa(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=St(t.state),n=xa(t.state),r=n!=xa(t.startState),{viewport:s}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<s.to&&!r&&e.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||r)&&(this.tree=e,this.decorations=this.buildDeco(t.view,n),this.decoratedTo=s.to)}buildDeco(t,e){if(!e||!this.tree.length)return J.none;let n=new Ws;for(let{from:r,to:s}of t.visibleRanges)Vk(this.tree,e,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=J.mark({class:a})))},r,s);return n.finish()}}const sQ=hn.high(ui.fromClass(rQ,{decorations:i=>i.decorations})),oQ=1e4,lQ="()[]{}",g0=new N;function Xu(i,t,e){let n=i.prop(t<0?N.openedBy:N.closedBy);if(n)return n;if(i.name.length==1){let r=e.indexOf(i.name);if(r>-1&&r%2==(t<0?1:0))return[e[r+t]]}return null}function Eu(i){let t=i.type.prop(g0);return t?t(i.node):i}function Er(i,t,e,n={}){let r=n.maxScanDistance||oQ,s=n.brackets||lQ,o=St(i),l=o.resolveInner(t,e);for(let a=l;a;a=a.parent){let c=Xu(a.type,e,s);if(c&&a.from<a.to){let h=Eu(a);if(h&&(e>0?t>=h.from&&t<h.to:t>h.from&&t<=h.to))return aQ(i,t,e,a,h,c,s)}}return cQ(i,t,e,o,l.type,r,s)}function aQ(i,t,e,n,r,s,o){let l=n.parent,a={from:r.from,to:r.to},c=0,h=l==null?void 0:l.cursor();if(h&&(e<0?h.childBefore(n.from):h.childAfter(n.to)))do if(e<0?h.to<=n.from:h.from>=n.to){if(c==0&&s.indexOf(h.type.name)>-1&&h.from<h.to){let u=Eu(h);return{start:a,end:u?{from:u.from,to:u.to}:void 0,matched:!0}}else if(Xu(h.type,e,o))c++;else if(Xu(h.type,-e,o)){if(c==0){let u=Eu(h);return{start:a,end:u&&u.from<u.to?{from:u.from,to:u.to}:void 0,matched:!1}}c--}}while(e<0?h.prevSibling():h.nextSibling());return{start:a,matched:!1}}function cQ(i,t,e,n,r,s,o){if(e<0?!t:t==i.doc.length)return null;let l=e<0?i.sliceDoc(t-1,t):i.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=e>0)return null;let c={from:e<0?t-1:t,to:e>0?t+1:t},h=i.doc.iterRange(t,e>0?i.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=s;){let d=h.value;e<0&&(f+=d.length);let O=t+f*e;for(let p=e>0?0:d.length-1,m=e>0?d.length:-1;p!=m;p+=e){let g=o.indexOf(d[p]);if(!(g<0||n.resolveInner(O+p,1).type!=r))if(g%2==0==e>0)u++;else{if(u==1)return{start:c,end:{from:O+p,to:O+p+1},matched:g>>1==a>>1};u--}}e>0&&(f+=d.length)}return h.done?{start:c,matched:!1}:null}const hQ=Object.create(null),cp=[qt.none],hp=[],up=Object.create(null),uQ=Object.create(null);for(let[i,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])uQ[i]=fQ(hQ,t);function bh(i,t){hp.indexOf(i)>-1||(hp.push(i),console.warn(t))}function fQ(i,t){let e=[];for(let l of t.split(" ")){let a=[];for(let c of l.split(".")){let h=i[c]||v[c];h?typeof h=="function"?a.length?a=a.map(h):bh(c,`Modifier ${c} used at start of tag`):a.length?bh(c,`Tag ${c} used as modifier`):a=Array.isArray(h)?h:[h]:bh(c,`Unknown highlighting tag ${c}`)}for(let c of a)e.push(c)}if(!e.length)return 0;let n=t.replace(/ /g,"_"),r=n+" "+e.map(l=>l.id),s=up[r];if(s)return s.id;let o=up[r]=qt.define({id:cp.length,name:n,props:[ho({[n]:e})]});return cp.push(o),o.id}Tt.RTL,Tt.LTR;const dQ=i=>{let{state:t}=i,e=t.doc.lineAt(t.selection.main.from),n=Gf(i.state,e.from);return n.line?OQ(i):n.block?mQ(i):!1};function Nf(i,t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=i(t,e);return r?(n(e.update(r)),!0):!1}}const OQ=Nf(wQ,0),pQ=Nf(b0,0),mQ=Nf((i,t)=>b0(i,t,bQ(t)),0);function Gf(i,t){let e=i.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}const yo=50;function gQ(i,{open:t,close:e},n,r){let s=i.sliceDoc(n-yo,n),o=i.sliceDoc(r,r+yo),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,c=s.length-l;if(s.slice(c-t.length,c)==t&&o.slice(a,a+e.length)==e)return{open:{pos:n-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let h,u;r-n<=2*yo?h=u=i.sliceDoc(n,r):(h=i.sliceDoc(n,n+yo),u=i.sliceDoc(r-yo,r));let f=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(u)[0].length,O=u.length-d-e.length;return h.slice(f,f+t.length)==t&&u.slice(O,O+e.length)==e?{open:{pos:n+f+t.length,margin:/\s/.test(h.charAt(f+t.length))?1:0},close:{pos:r-d-e.length,margin:/\s/.test(u.charAt(O-1))?1:0}}:null}function bQ(i){let t=[];for(let e of i.selection.ranges){let n=i.doc.lineAt(e.from),r=e.to<=n.to?n:i.doc.lineAt(e.to);r.from>n.from&&r.from==e.to&&(r=e.to==n.to+1?n:i.doc.lineAt(e.to-1));let s=t.length-1;s>=0&&t[s].to>n.from?t[s].to=r.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return t}function b0(i,t,e=t.selection.ranges){let n=e.map(s=>Gf(t,s.from).block);if(!n.every(s=>s))return null;let r=e.map((s,o)=>gQ(t,n[o],s.from,s.to));if(i!=2&&!r.every(s=>s))return{changes:t.changes(e.map((s,o)=>r[o]?[]:[{from:s.from,insert:n[o].open+" "},{from:s.to,insert:" "+n[o].close}]))};if(i!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=n[o],{open:c,close:h}=l;s.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:h.pos-h.margin,to:h.pos+a.close.length})}return{changes:s}}return null}function wQ(i,t,e=t.selection.ranges){let n=[],r=-1;t:for(let{from:s,to:o}of e){let l=n.length,a=1e9,c;for(let h=s;h<=o;){let u=t.doc.lineAt(h);if(c==null&&(c=Gf(t,u.from).line,!c))continue t;if(u.from>r&&(s==o||o>u.from)){r=u.from;let f=/^\s*/.exec(u.text)[0].length,d=f==u.length,O=u.text.slice(f,f+c.length)==c?f:-1;f<u.text.length&&f<a&&(a=f),n.push({line:u,comment:O,token:c,indent:f,empty:d,single:!1})}h=u.to+1}if(a<1e9)for(let h=l;h<n.length;h++)n[h].indent<n[h].line.text.length&&(n[h].indent=a);n.length==l+1&&(n[l].single=!0)}if(i!=2&&n.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:c,empty:h,single:u}of n)(u||!h)&&s.push({from:l.from+c,insert:a+" "});let o=t.changes(s);return{changes:o,selection:t.selection.map(o,1)}}else if(i!=1&&n.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of n)if(l>=0){let c=o.from+l,h=c+a.length;o.text[h-o.from]==" "&&h++,s.push({from:c,to:h})}return{changes:s}}return null}const Lu=Ke.define(),SQ=Ke.define(),w0=D.define(),S0=D.define({combine(i){return eb(i,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(n,r)=>t(n,r)||e(n,r)})}}),Uf=bi.define({create(){return zi.empty},update(i,t){let e=t.state.facet(S0),n=t.annotation(Lu);if(n){let a=ye.fromTransaction(t,n.selection),c=n.side,h=c==0?i.undone:i.done;return a?h=Ga(h,h.length,e.minDepth,a):h=y0(h,t.startState.selection),new zi(c==0?n.rest:h,c==0?h:n.rest)}let r=t.annotation(SQ);if((r=="full"||r=="before")&&(i=i.isolate()),t.annotation(Pt.addToHistory)===!1)return t.changes.empty?i:i.addMapping(t.changes.desc);let s=ye.fromTransaction(t),o=t.annotation(Pt.time),l=t.annotation(Pt.userEvent);return s?i=i.addChanges(s,o,l,e,t):t.selection&&(i=i.addSelection(t.startState.selection,o,l,e.newGroupDelay)),(r=="full"||r=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(t=>t.toJSON()),undone:i.undone.map(t=>t.toJSON())}},fromJSON(i){return new zi(i.done.map(ye.fromJSON),i.undone.map(ye.fromJSON))}});function vQ(i={}){return[Uf,S0.of(i),z.domEventHandlers({beforeinput(t,e){let n=t.inputType=="historyUndo"?Hf:t.inputType=="historyRedo"?Na:null;return n?(t.preventDefault(),n(e)):!1}})]}function Zc(i,t){return function({state:e,dispatch:n}){if(!t&&e.readOnly)return!1;let r=e.field(Uf,!1);if(!r)return!1;let s=r.pop(i,e,t);return s?(n(s),!0):!1}}const Hf=Zc(0,!1),Na=Zc(1,!1),xQ=Zc(0,!0),yQ=Zc(1,!0);function v0(i){return function(t){let e=t.field(Uf,!1);if(!e)return 0;let n=i==0?e.done:e.undone;return n.length-(n.length&&!n[0].changes?1:0)}}const kQ=v0(0),QQ=v0(1);class ye{constructor(t,e,n,r,s){this.changes=t,this.effects=e,this.mapped=n,this.startSelection=r,this.selectionsAfter=s}setSelAfter(t){return new ye(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,n;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(e=this.mapped)===null||e===void 0?void 0:e.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(t){return new ye(t.changes&&Lt.fromJSON(t.changes),[],t.mapped&&Ii.fromJSON(t.mapped),t.startSelection&&C.fromJSON(t.startSelection),t.selectionsAfter.map(C.fromJSON))}static fromTransaction(t,e){let n=Ne;for(let r of t.startState.facet(w0)){let s=r(t);s.length&&(n=n.concat(s))}return!n.length&&t.changes.empty?null:new ye(t.changes.invert(t.startState.doc),n,void 0,e||t.startState.selection,Ne)}static selection(t){return new ye(void 0,Ne,void 0,void 0,t)}}function Ga(i,t,e,n){let r=t+1>e+20?t-e-1:0,s=i.slice(r,t);return s.push(n),s}function $Q(i,t){let e=[],n=!1;return i.iterChangedRanges((r,s)=>e.push(r,s)),t.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<e.length;){let c=e[a++],h=e[a++];l>=c&&o<=h&&(n=!0)}}),n}function CQ(i,t){return i.ranges.length==t.ranges.length&&i.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function x0(i,t){return i.length?t.length?i.concat(t):i:t}const Ne=[],PQ=200;function y0(i,t){if(i.length){let e=i[i.length-1],n=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-PQ));return n.length&&n[n.length-1].eq(t)?i:(n.push(t),Ga(i,i.length-1,1e9,e.setSelAfter(n)))}else return[ye.selection([t])]}function TQ(i){let t=i[i.length-1],e=i.slice();return e[i.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),e}function wh(i,t){if(!i.length)return i;let e=i.length,n=Ne;for(;e;){let r=AQ(i[e-1],t,n);if(r.changes&&!r.changes.empty||r.effects.length){let s=i.slice(0,e);return s[e-1]=r,s}else t=r.mapped,e--,n=r.selectionsAfter}return n.length?[ye.selection(n)]:Ne}function AQ(i,t,e){let n=x0(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(t)):Ne,e);if(!i.changes)return ye.selection(n);let r=i.changes.map(t),s=t.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(s):s;return new ye(r,Ct.mapEffects(i.effects,t),o,i.startSelection.map(s),n)}const RQ=/^(input\.type|delete)($|\.)/;class zi{constructor(t,e,n=0,r=void 0){this.done=t,this.undone=e,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new zi(this.done,this.undone):this}addChanges(t,e,n,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&t.changes&&(!n||RQ.test(n))&&(!l.selectionsAfter.length&&e-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,$Q(l.changes,t.changes))||n=="input.type.compose")?o=Ga(o,o.length-1,r.minDepth,new ye(t.changes.compose(l.changes),x0(Ct.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,Ne)):o=Ga(o,o.length,r.minDepth,t),new zi(o,Ne,e,n)}addSelection(t,e,n,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Ne;return s.length>0&&e-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&CQ(s[s.length-1],t)?this:new zi(y0(this.done,t),this.undone,e,n)}addMapping(t){return new zi(wh(this.done,t),wh(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,n){let r=t==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):e.selection);if(n&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Lu.of({side:t,rest:TQ(r),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Ne:r.slice(0,r.length-1);return s.mapped&&(l=wh(l,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Lu.of({side:t,rest:l,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}zi.empty=new zi(Ne,Ne);const k0=[{key:"Mod-z",run:Hf,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Na,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Na,preventDefault:!0},{key:"Mod-u",run:xQ,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:yQ,preventDefault:!0}];function fo(i,t){return C.create(i.ranges.map(t),i.mainIndex)}function wi(i,t){return i.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Si({state:i,dispatch:t},e){let n=fo(i.selection,e);return n.eq(i.selection,!0)?!1:(t(wi(i,n)),!0)}function Xc(i,t){return C.cursor(t?i.to:i.from)}function Q0(i,t){return Si(i,e=>e.empty?i.moveByChar(e,t):Xc(e,t))}function ue(i){return i.textDirectionAt(i.state.selection.main.head)==Tt.LTR}const $0=i=>Q0(i,!ue(i)),C0=i=>Q0(i,ue(i));function P0(i,t){return Si(i,e=>e.empty?i.moveByGroup(e,t):Xc(e,t))}const ZQ=i=>P0(i,!ue(i)),XQ=i=>P0(i,ue(i));function EQ(i,t,e){if(t.type.prop(e))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(t.from,t.to)))||t.firstChild}function Ec(i,t,e){let n=St(i).resolveInner(t.head),r=e?N.closedBy:N.openedBy;for(let a=t.head;;){let c=e?n.childAfter(a):n.childBefore(a);if(!c)break;EQ(i,c,r)?n=c:a=e?c.to:c.from}let s=n.type.prop(r),o,l;return s&&(o=e?Er(i,n.from,1):Er(i,n.to,-1))&&o.matched?l=e?o.end.to:o.end.from:l=e?n.to:n.from,C.cursor(l,e?-1:1)}const LQ=i=>Si(i,t=>Ec(i.state,t,!ue(i))),MQ=i=>Si(i,t=>Ec(i.state,t,ue(i)));function T0(i,t){return Si(i,e=>{if(!e.empty)return Xc(e,t);let n=i.moveVertically(e,t);return n.head!=e.head?n:i.moveToLineBoundary(e,t)})}const A0=i=>T0(i,!1),R0=i=>T0(i,!0);function Z0(i){let t=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,e=0,n=0,r;if(t){for(let s of i.state.facet(z.scrollMargins)){let o=s(i);o!=null&&o.top&&(e=Math.max(o==null?void 0:o.top,e)),o!=null&&o.bottom&&(n=Math.max(o==null?void 0:o.bottom,n))}r=i.scrollDOM.clientHeight-e-n}else r=(i.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:n,selfScroll:t,height:Math.max(i.defaultLineHeight,r-5)}}function X0(i,t){let e=Z0(i),{state:n}=i,r=fo(n.selection,o=>o.empty?i.moveVertically(o,t,e.height):Xc(o,t));if(r.eq(n.selection))return!1;let s;if(e.selfScroll){let o=i.coordsAtPos(n.selection.main.head),l=i.scrollDOM.getBoundingClientRect(),a=l.top+e.marginTop,c=l.bottom-e.marginBottom;o&&o.top>a&&o.bottom<c&&(s=z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return i.dispatch(wi(n,r),{effects:s}),!0}const fp=i=>X0(i,!1),Mu=i=>X0(i,!0);function Vn(i,t,e){let n=i.lineBlockAt(t.head),r=i.moveToLineBoundary(t,e);if(r.head==t.head&&r.head!=(e?n.to:n.from)&&(r=i.moveToLineBoundary(t,e,!1)),!e&&r.head==n.from&&n.length){let s=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;s&&t.head!=n.from+s&&(r=C.cursor(n.from+s))}return r}const zQ=i=>Si(i,t=>Vn(i,t,!0)),_Q=i=>Si(i,t=>Vn(i,t,!1)),IQ=i=>Si(i,t=>Vn(i,t,!ue(i))),jQ=i=>Si(i,t=>Vn(i,t,ue(i))),DQ=i=>Si(i,t=>C.cursor(i.lineBlockAt(t.head).from,1)),VQ=i=>Si(i,t=>C.cursor(i.lineBlockAt(t.head).to,-1));function BQ(i,t,e){let n=!1,r=fo(i.selection,s=>{let o=Er(i,s.head,-1)||Er(i,s.head,1)||s.head>0&&Er(i,s.head-1,1)||s.head<i.doc.length&&Er(i,s.head+1,-1);if(!o||!o.end)return s;n=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return C.cursor(l)});return n?(t(wi(i,r)),!0):!1}const WQ=({state:i,dispatch:t})=>BQ(i,t);function Je(i,t){let e=fo(i.state.selection,n=>{let r=t(n);return C.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return e.eq(i.state.selection)?!1:(i.dispatch(wi(i.state,e)),!0)}function E0(i,t){return Je(i,e=>i.moveByChar(e,t))}const L0=i=>E0(i,!ue(i)),M0=i=>E0(i,ue(i));function z0(i,t){return Je(i,e=>i.moveByGroup(e,t))}const YQ=i=>z0(i,!ue(i)),qQ=i=>z0(i,ue(i)),NQ=i=>Je(i,t=>Ec(i.state,t,!ue(i))),GQ=i=>Je(i,t=>Ec(i.state,t,ue(i)));function _0(i,t){return Je(i,e=>i.moveVertically(e,t))}const I0=i=>_0(i,!1),j0=i=>_0(i,!0);function D0(i,t){return Je(i,e=>i.moveVertically(e,t,Z0(i).height))}const dp=i=>D0(i,!1),Op=i=>D0(i,!0),UQ=i=>Je(i,t=>Vn(i,t,!0)),HQ=i=>Je(i,t=>Vn(i,t,!1)),FQ=i=>Je(i,t=>Vn(i,t,!ue(i))),KQ=i=>Je(i,t=>Vn(i,t,ue(i))),JQ=i=>Je(i,t=>C.cursor(i.lineBlockAt(t.head).from)),t$=i=>Je(i,t=>C.cursor(i.lineBlockAt(t.head).to)),pp=({state:i,dispatch:t})=>(t(wi(i,{anchor:0})),!0),mp=({state:i,dispatch:t})=>(t(wi(i,{anchor:i.doc.length})),!0),gp=({state:i,dispatch:t})=>(t(wi(i,{anchor:i.selection.main.anchor,head:0})),!0),bp=({state:i,dispatch:t})=>(t(wi(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),e$=({state:i,dispatch:t})=>(t(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),i$=({state:i,dispatch:t})=>{let e=Lc(i).map(({from:n,to:r})=>C.range(n,Math.min(r+1,i.doc.length)));return t(i.update({selection:C.create(e),userEvent:"select"})),!0},n$=({state:i,dispatch:t})=>{let e=fo(i.selection,n=>{let r=St(i),s=r.resolveStack(n.from,1);if(n.empty){let o=r.resolveStack(n.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&o.next)return C.range(l.to,l.from)}return n});return e.eq(i.selection)?!1:(t(wi(i,e)),!0)};function V0(i,t){let{state:e}=i,n=e.selection,r=e.selection.ranges.slice();for(let s of e.selection.ranges){let o=e.doc.lineAt(s.head);if(t?o.to<i.state.doc.length:o.from>0)for(let l=s;;){let a=i.moveVertically(l,t);if(a.head<o.from||a.head>o.to){r.some(c=>c.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==n.ranges.length?!1:(i.dispatch(wi(e,C.create(r,r.length-1))),!0)}const r$=i=>V0(i,!1),s$=i=>V0(i,!0),o$=({state:i,dispatch:t})=>{let e=i.selection,n=null;return e.ranges.length>1?n=C.create([e.main]):e.main.empty||(n=C.create([C.cursor(e.main.head)])),n?(t(wi(i,n)),!0):!1};function Pl(i,t){if(i.state.readOnly)return!1;let e="delete.selection",{state:n}=i,r=n.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=t(s);a<o?(e="delete.backward",a=ea(i,a,!1)):a>o&&(e="delete.forward",a=ea(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=ea(i,o,!1),l=ea(i,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:C.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(i.dispatch(n.update(r,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?z.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function ea(i,t,e){if(i instanceof z)for(let n of i.state.facet(z.atomicRanges).map(r=>r(i)))n.between(t,t,(r,s)=>{r<t&&s>t&&(t=e?s:r)});return t}const B0=(i,t,e)=>Pl(i,n=>{let r=n.from,{state:s}=i,o=s.doc.lineAt(r),l,a;if(e&&!t&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]==" ")return r-1;let c=an(l,s.tabSize),h=c%Ya(s)||Ya(s);for(let u=0;u<h&&l[l.length-1-u]==" ";u++)r--;a=r}else a=ae(o.text,r-o.from,t,t)+o.from,a==r&&o.number!=(t?s.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=ae(o.text,a-o.from,!1,!1)+o.from);return a}),zu=i=>B0(i,!1,!0),W0=i=>B0(i,!0,!1),Y0=(i,t)=>Pl(i,e=>{let n=e.head,{state:r}=i,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let l=null;;){if(n==(t?s.to:s.from)){n==e.head&&s.number!=(t?r.doc.lines:1)&&(n+=t?1:-1);break}let a=ae(s.text,n-s.from,t)+s.from,c=s.text.slice(Math.min(n,a)-s.from,Math.max(n,a)-s.from),h=o(c);if(l!=null&&h!=l)break;(c!=" "||n!=e.head)&&(l=h),n=a}return n}),q0=i=>Y0(i,!1),l$=i=>Y0(i,!0),a$=i=>Pl(i,t=>{let e=i.lineBlockAt(t.head).to;return t.head<e?e:Math.min(i.state.doc.length,t.head+1)}),c$=i=>Pl(i,t=>{let e=i.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),h$=i=>Pl(i,t=>{let e=i.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(i.state.doc.length,t.head+1)}),u$=({state:i,dispatch:t})=>{if(i.readOnly)return!1;let e=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:Y.of(["",""])},range:C.cursor(n.from)}));return t(i.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},f$=({state:i,dispatch:t})=>{if(i.readOnly)return!1;let e=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let r=n.from,s=i.doc.lineAt(r),o=r==s.from?r-1:ae(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:ae(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:i.doc.slice(r,l).append(i.doc.slice(o,r))},range:C.cursor(l)}});return e.changes.empty?!1:(t(i.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Lc(i){let t=[],e=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.from),s=i.doc.lineAt(n.to);if(!n.empty&&n.to==s.from&&(s=i.doc.lineAt(n.to-1)),e>=r.number){let o=t[t.length-1];o.to=s.to,o.ranges.push(n)}else t.push({from:r.from,to:s.to,ranges:[n]});e=s.number+1}return t}function N0(i,t,e){if(i.readOnly)return!1;let n=[],r=[];for(let s of Lc(i)){if(e?s.to==i.doc.length:s.from==0)continue;let o=i.doc.lineAt(e?s.to+1:s.from-1),l=o.length+1;if(e){n.push({from:s.to,to:o.to},{from:s.from,insert:o.text+i.lineBreak});for(let a of s.ranges)r.push(C.range(Math.min(i.doc.length,a.anchor+l),Math.min(i.doc.length,a.head+l)))}else{n.push({from:o.from,to:s.from},{from:s.to,insert:i.lineBreak+o.text});for(let a of s.ranges)r.push(C.range(a.anchor-l,a.head-l))}}return n.length?(t(i.update({changes:n,scrollIntoView:!0,selection:C.create(r,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const d$=({state:i,dispatch:t})=>N0(i,t,!1),O$=({state:i,dispatch:t})=>N0(i,t,!0);function G0(i,t,e){if(i.readOnly)return!1;let n=[];for(let s of Lc(i))e?n.push({from:s.from,insert:i.doc.slice(s.from,s.to)+i.lineBreak}):n.push({from:s.to,insert:i.lineBreak+i.doc.slice(s.from,s.to)});let r=i.changes(n);return t(i.update({changes:r,selection:i.selection.map(r,e?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const p$=({state:i,dispatch:t})=>G0(i,t,!1),m$=({state:i,dispatch:t})=>G0(i,t,!0),g$=i=>{if(i.state.readOnly)return!1;let{state:t}=i,e=t.changes(Lc(t).map(({from:r,to:s})=>(r>0?r--:s<t.doc.length&&s++,{from:r,to:s}))),n=fo(t.selection,r=>{let s;if(i.lineWrapping){let o=i.lineBlockAt(r.head),l=i.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+i.documentTop-l.bottom+i.defaultLineHeight/2)}return i.moveVertically(r,!0,s)}).map(e);return i.dispatch({changes:e,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function b$(i,t){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=St(i).resolveInner(t),n=e.childBefore(t),r=e.childAfter(t),s;return n&&r&&n.to<=t&&r.from>=t&&(s=n.type.prop(N.closedBy))&&s.indexOf(r.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(r.from).from&&!/\S/.test(i.sliceDoc(n.to,r.from))?{from:n.to,to:r.from}:null}const wp=U0(!1),w$=U0(!0);function U0(i){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{let{from:s,to:o}=r,l=t.doc.lineAt(s),a=!i&&s==o&&b$(t,s);i&&(s=o=(o<=l.to?l:t.doc.lineAt(o)).to);let c=new Ac(t,{simulateBreak:s,simulateDoubleBreak:!!a}),h=f0(c,s);for(h==null&&(h=an(/^\s*/.exec(t.doc.lineAt(s).text)[0],t.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let u=["",qa(t,h)];return a&&u.push(qa(t,c.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:Y.of(u)},range:C.cursor(s+1+u[1].length)}});return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ff(i,t){let e=-1;return i.changeByRange(n=>{let r=[];for(let o=n.from;o<=n.to;){let l=i.doc.lineAt(o);l.number>e&&(n.empty||n.to>l.from)&&(t(l,r,n),e=l.number),o=l.to+1}let s=i.changes(r);return{changes:r,range:C.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}const S$=({state:i,dispatch:t})=>{if(i.readOnly)return!1;let e=Object.create(null),n=new Ac(i,{overrideIndentation:s=>{let o=e[s];return o??-1}}),r=Ff(i,(s,o,l)=>{let a=f0(n,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let c=/^\s*/.exec(s.text)[0],h=qa(i,a);(c!=h||l.from<s.from+c.length)&&(e[s.from]=a,o.push({from:s.from,to:s.from+c.length,insert:h}))});return r.changes.empty||t(i.update(r,{userEvent:"indent"})),!0},H0=({state:i,dispatch:t})=>i.readOnly?!1:(t(i.update(Ff(i,(e,n)=>{n.push({from:e.from,insert:i.facet(uo)})}),{userEvent:"input.indent"})),!0),F0=({state:i,dispatch:t})=>i.readOnly?!1:(t(i.update(Ff(i,(e,n)=>{let r=/^\s*/.exec(e.text)[0];if(!r)return;let s=an(r,i.tabSize),o=0,l=qa(i,Math.max(0,s-Ya(i)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;n.push({from:e.from+o,to:e.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),v$=i=>(i.setTabFocusMode(),!0),x$=[{key:"Ctrl-b",run:$0,shift:L0,preventDefault:!0},{key:"Ctrl-f",run:C0,shift:M0},{key:"Ctrl-p",run:A0,shift:I0},{key:"Ctrl-n",run:R0,shift:j0},{key:"Ctrl-a",run:DQ,shift:JQ},{key:"Ctrl-e",run:VQ,shift:t$},{key:"Ctrl-d",run:W0},{key:"Ctrl-h",run:zu},{key:"Ctrl-k",run:a$},{key:"Ctrl-Alt-h",run:q0},{key:"Ctrl-o",run:u$},{key:"Ctrl-t",run:f$},{key:"Ctrl-v",run:Mu}],y$=[{key:"ArrowLeft",run:$0,shift:L0,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ZQ,shift:YQ,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:IQ,shift:FQ,preventDefault:!0},{key:"ArrowRight",run:C0,shift:M0,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:XQ,shift:qQ,preventDefault:!0},{mac:"Cmd-ArrowRight",run:jQ,shift:KQ,preventDefault:!0},{key:"ArrowUp",run:A0,shift:I0,preventDefault:!0},{mac:"Cmd-ArrowUp",run:pp,shift:gp},{mac:"Ctrl-ArrowUp",run:fp,shift:dp},{key:"ArrowDown",run:R0,shift:j0,preventDefault:!0},{mac:"Cmd-ArrowDown",run:mp,shift:bp},{mac:"Ctrl-ArrowDown",run:Mu,shift:Op},{key:"PageUp",run:fp,shift:dp},{key:"PageDown",run:Mu,shift:Op},{key:"Home",run:_Q,shift:HQ,preventDefault:!0},{key:"Mod-Home",run:pp,shift:gp},{key:"End",run:zQ,shift:UQ,preventDefault:!0},{key:"Mod-End",run:mp,shift:bp},{key:"Enter",run:wp,shift:wp},{key:"Mod-a",run:e$},{key:"Backspace",run:zu,shift:zu,preventDefault:!0},{key:"Delete",run:W0,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:q0,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:l$,preventDefault:!0},{mac:"Mod-Backspace",run:c$,preventDefault:!0},{mac:"Mod-Delete",run:h$,preventDefault:!0}].concat(x$.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),K0=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:LQ,shift:NQ},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:MQ,shift:GQ},{key:"Alt-ArrowUp",run:d$},{key:"Shift-Alt-ArrowUp",run:p$},{key:"Alt-ArrowDown",run:O$},{key:"Shift-Alt-ArrowDown",run:m$},{key:"Mod-Alt-ArrowUp",run:r$},{key:"Mod-Alt-ArrowDown",run:s$},{key:"Escape",run:o$},{key:"Mod-Enter",run:w$},{key:"Alt-l",mac:"Ctrl-l",run:i$},{key:"Mod-i",run:n$,preventDefault:!0},{key:"Mod-[",run:F0},{key:"Mod-]",run:H0},{key:"Mod-Alt-\\",run:S$},{key:"Shift-Mod-k",run:g$},{key:"Shift-Mod-\\",run:WQ},{key:"Mod-/",run:dQ},{key:"Alt-A",run:pQ},{key:"Ctrl-m",mac:"Shift-Alt-m",run:v$}].concat(y$),k$={key:"Tab",run:H0,shift:F0};class Q${constructor(t,e,n,r){this.state=t,this.pos=e,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=St(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),r=e.text.slice(n-e.from,this.pos-e.from),s=r.search(T$(t));return s<0?null:{from:n+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(t,e,n){t=="abort"&&this.abortListeners&&(this.abortListeners.push(e),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Sp(i){let t=Object.keys(i).join(""),e=/\w/.test(t);return e&&(t=t.replace(/\w/g,"")),`[${e?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function $$(i){let t=Object.create(null),e=Object.create(null);for(let{label:r}of i){t[r[0]]=!0;for(let s=1;s<r.length;s++)e[r[s]]=!0}let n=Sp(t)+Sp(e)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function C$(i){let t=i.map(r=>typeof r=="string"?{label:r}:r),[e,n]=t.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:$$(t);return r=>{let s=r.matchBefore(n);return s||r.explicit?{from:s?s.from:r.pos,options:t,validFor:e}:null}}function P$(i,t){return e=>{for(let n=St(e.state).resolveInner(e.pos,-1);n;n=n.parent){if(i.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return t(e)}}function T$(i,t){var e;let{source:n}=i,r=n[n.length-1]!="$";return r?new RegExp(`(?:${n})${r?"$":""}`,(e=i.flags)!==null&&e!==void 0?e:i.ignoreCase?"i":""):i}const A$=Ke.define(),R$=z.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Z${constructor(t,e,n,r){this.field=t,this.line=e,this.from=n,this.to=r}}class Kf{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,Oe.TrackDel),n=t.mapPos(this.to,1,Oe.TrackDel);return e==null||n==null?null:new Kf(this.field,e,n)}}class Jf{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],r=[e],s=t.doc.lineAt(e),o=/^\s*/.exec(s.text)[0];for(let a of this.lines){if(n.length){let c=o,h=/^\t*/.exec(a)[0].length;for(let u=0;u<h;u++)c+=t.facet(uo);r.push(e+c.length-h),a=c+a.slice(h)}n.push(a),e+=a.length+1}let l=this.fieldPositions.map(a=>new Kf(a.field,r[a.line]+a.from,r[a.line]+a.to));return{text:n,ranges:l}}static parse(t){let e=[],n=[],r=[],s;for(let o of t.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=s[1]?+s[1]:null,a=s[2]||s[3]||"",c=-1,h=a.replace(/\\[{}]/g,u=>u[1]);for(let u=0;u<e.length;u++)(l!=null?e[u].seq==l:h&&e[u].name==h)&&(c=u);if(c<0){let u=0;for(;u<e.length&&(l==null||e[u].seq!=null&&e[u].seq<l);)u++;e.splice(u,0,{seq:l,name:h}),c=u;for(let f of r)f.field>=c&&f.field++}for(let u of r)if(u.line==n.length&&u.from>s.index){let f=s[2]?3+(s[1]||"").length:2;u.from-=f,u.to-=f}r.push(new Z$(c,n.length,s.index,s.index+h.length)),o=o.slice(0,s.index)+a+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(l,a,c)=>{for(let h of r)h.line==n.length&&h.from>c&&(h.from--,h.to--);return a}),n.push(o)}return new Jf(n,r)}}let X$=J.widget({widget:new class extends jn{toDOM(){let i=document.createElement("span");return i.className="cm-snippetFieldPosition",i}ignoreEvent(){return!1}}}),E$=J.mark({class:"cm-snippetField"});class Oo{constructor(t,e){this.ranges=t,this.active=e,this.deco=J.set(t.map(n=>(n.from==n.to?X$:E$).range(n.from,n.to)),!0)}map(t){let e=[];for(let n of this.ranges){let r=n.map(t);if(!r)return null;e.push(r)}return new Oo(e,this.active)}selectionInsideField(t){return t.ranges.every(e=>this.ranges.some(n=>n.field==this.active&&n.from<=e.from&&n.to>=e.to))}}const Tl=Ct.define({map(i,t){return i&&i.map(t)}}),L$=Ct.define(),nl=bi.define({create(){return null},update(i,t){for(let e of t.effects){if(e.is(Tl))return e.value;if(e.is(L$)&&i)return new Oo(i.ranges,e.value)}return i&&t.docChanged&&(i=i.map(t.changes)),i&&t.selection&&!i.selectionInsideField(t.selection)&&(i=null),i},provide:i=>z.decorations.from(i,t=>t?t.deco:J.none)});function td(i,t){return C.create(i.filter(e=>e.field==t).map(e=>C.range(e.from,e.to)))}function M$(i){let t=Jf.parse(i);return(e,n,r,s)=>{let{text:o,ranges:l}=t.instantiate(e.state,r),{main:a}=e.state.selection,c={changes:{from:r,to:s==a.from?a.to:s,insert:Y.of(o)},scrollIntoView:!0,annotations:n?[A$.of(n),Pt.userEvent.of("input.complete")]:void 0};if(l.length&&(c.selection=td(l,0)),l.some(h=>h.field>0)){let h=new Oo(l,0),u=c.effects=[Tl.of(h)];e.state.field(nl,!1)===void 0&&u.push(Ct.appendConfig.of([nl,D$,V$,R$]))}e.dispatch(e.state.update(c))}}function J0(i){return({state:t,dispatch:e})=>{let n=t.field(nl,!1);if(!n||i<0&&n.active==0)return!1;let r=n.active+i,s=i>0&&!n.ranges.some(o=>o.field==r+i);return e(t.update({selection:td(n.ranges,r),effects:Tl.of(s?null:new Oo(n.ranges,r)),scrollIntoView:!0})),!0}}const z$=({state:i,dispatch:t})=>i.field(nl,!1)?(t(i.update({effects:Tl.of(null)})),!0):!1,_$=J0(1),I$=J0(-1),j$=[{key:"Tab",run:_$,shift:I$},{key:"Escape",run:z$}],vp=D.define({combine(i){return i.length?i[0]:j$}}),D$=hn.highest(Dn.compute([vp],i=>i.facet(vp)));function we(i,t){return{...t,apply:M$(i)}}const V$=z.domEventHandlers({mousedown(i,t){let e=t.state.field(nl,!1),n;if(!e||(n=t.posAtCoords({x:i.clientX,y:i.clientY}))==null)return!1;let r=e.ranges.find(s=>s.from<=n&&s.to>=n);return!r||r.field==e.active?!1:(t.dispatch({selection:td(e.ranges,r.field),effects:Tl.of(e.ranges.some(s=>s.field>r.field)?new Oo(e.ranges,r.field):null),scrollIntoView:!0}),!0)}}),tw=new class extends Zn{};tw.startSide=1;tw.endSide=-1;class Ua{static create(t,e,n,r,s){let o=r+(r<<8)+t+(e<<4)|0;return new Ua(t,e,n,o,s,[],[])}constructor(t,e,n,r,s,o,l){this.type=t,this.value=e,this.from=n,this.hash=r,this.end=s,this.children=o,this.positions=l,this.hashProp=[[N.contextHash,r]]}addChild(t,e){t.prop(N.contextHash)!=this.hash&&(t=new ht(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(e)}toTree(t,e=this.end){let n=this.children.length-1;return n>=0&&(e=Math.max(e,this.positions[n]+this.children[n].length+this.from)),new ht(t.types[this.type],this.children,this.positions,e-this.from).balance({makeTree:(r,s,o)=>new ht(qt.none,r,s,o,this.hashProp)})}}var T;(function(i){i[i.Document=1]="Document",i[i.CodeBlock=2]="CodeBlock",i[i.FencedCode=3]="FencedCode",i[i.Blockquote=4]="Blockquote",i[i.HorizontalRule=5]="HorizontalRule",i[i.BulletList=6]="BulletList",i[i.OrderedList=7]="OrderedList",i[i.ListItem=8]="ListItem",i[i.ATXHeading1=9]="ATXHeading1",i[i.ATXHeading2=10]="ATXHeading2",i[i.ATXHeading3=11]="ATXHeading3",i[i.ATXHeading4=12]="ATXHeading4",i[i.ATXHeading5=13]="ATXHeading5",i[i.ATXHeading6=14]="ATXHeading6",i[i.SetextHeading1=15]="SetextHeading1",i[i.SetextHeading2=16]="SetextHeading2",i[i.HTMLBlock=17]="HTMLBlock",i[i.LinkReference=18]="LinkReference",i[i.Paragraph=19]="Paragraph",i[i.CommentBlock=20]="CommentBlock",i[i.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",i[i.Escape=22]="Escape",i[i.Entity=23]="Entity",i[i.HardBreak=24]="HardBreak",i[i.Emphasis=25]="Emphasis",i[i.StrongEmphasis=26]="StrongEmphasis",i[i.Link=27]="Link",i[i.Image=28]="Image",i[i.InlineCode=29]="InlineCode",i[i.HTMLTag=30]="HTMLTag",i[i.Comment=31]="Comment",i[i.ProcessingInstruction=32]="ProcessingInstruction",i[i.Autolink=33]="Autolink",i[i.HeaderMark=34]="HeaderMark",i[i.QuoteMark=35]="QuoteMark",i[i.ListMark=36]="ListMark",i[i.LinkMark=37]="LinkMark",i[i.EmphasisMark=38]="EmphasisMark",i[i.CodeMark=39]="CodeMark",i[i.CodeText=40]="CodeText",i[i.CodeInfo=41]="CodeInfo",i[i.LinkTitle=42]="LinkTitle",i[i.LinkLabel=43]="LinkLabel",i[i.URL=44]="URL"})(T||(T={}));class B${constructor(t,e){this.start=t,this.content=e,this.marks=[],this.parsers=[]}}class W${constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return Vo(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,e=0,n=0){for(let r=e;r<t;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(t){let e=0;for(let n=0;e<this.text.length&&n<t;e++)n+=this.text.charCodeAt(e)==9?4-n%4:1;return e}scrub(){if(!this.baseIndent)return this.text;let t="";for(let e=0;e<this.basePos;e++)t+=" ";return t+this.text.slice(this.basePos)}}function xp(i,t,e){if(e.pos==e.text.length||i!=t.block&&e.indent>=t.stack[e.depth+1].value+e.baseIndent)return!0;if(e.indent>=e.baseIndent+4)return!1;let n=(i.type==T.OrderedList?nd:id)(e,t,!1);return n>0&&(i.type!=T.BulletList||ed(e,t,!1)<0)&&e.text.charCodeAt(e.pos+n-1)==i.value}const ew={[T.Blockquote](i,t,e){return e.next!=62?!1:(e.markers.push(st(T.QuoteMark,t.lineStart+e.pos,t.lineStart+e.pos+1)),e.moveBase(e.pos+(ti(e.text.charCodeAt(e.pos+1))?2:1)),i.end=t.lineStart+e.text.length,!0)},[T.ListItem](i,t,e){return e.indent<e.baseIndent+i.value&&e.next>-1?!1:(e.moveBaseColumn(e.baseIndent+i.value),!0)},[T.OrderedList]:xp,[T.BulletList]:xp,[T.Document](){return!0}};function ti(i){return i==32||i==9||i==10||i==13}function Vo(i,t=0){for(;t<i.length&&ti(i.charCodeAt(t));)t++;return t}function yp(i,t,e){for(;t>e&&ti(i.charCodeAt(t-1));)t--;return t}function iw(i){if(i.next!=96&&i.next!=126)return-1;let t=i.pos+1;for(;t<i.text.length&&i.text.charCodeAt(t)==i.next;)t++;if(t<i.pos+3)return-1;if(i.next==96){for(let e=t;e<i.text.length;e++)if(i.text.charCodeAt(e)==96)return-1}return t}function nw(i){return i.next!=62?-1:i.text.charCodeAt(i.pos+1)==32?2:1}function ed(i,t,e){if(i.next!=42&&i.next!=45&&i.next!=95)return-1;let n=1;for(let r=i.pos+1;r<i.text.length;r++){let s=i.text.charCodeAt(r);if(s==i.next)n++;else if(!ti(s))return-1}return e&&i.next==45&&ow(i)>-1&&i.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(hw.SetextHeading)>-1||n<3?-1:1}function rw(i,t){for(let e=i.stack.length-1;e>=0;e--)if(i.stack[e].type==t)return!0;return!1}function id(i,t,e){return(i.next==45||i.next==43||i.next==42)&&(i.pos==i.text.length-1||ti(i.text.charCodeAt(i.pos+1)))&&(!e||rw(t,T.BulletList)||i.skipSpace(i.pos+2)<i.text.length)?1:-1}function nd(i,t,e){let n=i.pos,r=i.next;for(;r>=48&&r<=57;){n++;if(n==i.text.length)return-1;r=i.text.charCodeAt(n)}return n==i.pos||n>i.pos+9||r!=46&&r!=41||n<i.text.length-1&&!ti(i.text.charCodeAt(n+1))||e&&!rw(t,T.OrderedList)&&(i.skipSpace(n+1)==i.text.length||n>i.pos+1||i.next!=49)?-1:n+1-i.pos}function sw(i){if(i.next!=35)return-1;let t=i.pos+1;for(;t<i.text.length&&i.text.charCodeAt(t)==35;)t++;if(t<i.text.length&&i.text.charCodeAt(t)!=32)return-1;let e=t-i.pos;return e>6?-1:e}function ow(i){if(i.next!=45&&i.next!=61||i.indent>=i.baseIndent+4)return-1;let t=i.pos+1;for(;t<i.text.length&&i.text.charCodeAt(t)==i.next;)t++;let e=t;for(;t<i.text.length&&ti(i.text.charCodeAt(t));)t++;return t==i.text.length?e:-1}const _u=/^[ \t]*$/,lw=/-->/,aw=/\?>/,Iu=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,lw],[/^\s*<\?/,aw],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,_u],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,_u]];function cw(i,t,e){if(i.next!=60)return-1;let n=i.text.slice(i.pos);for(let r=0,s=Iu.length-(e?1:0);r<s;r++)if(Iu[r][0].test(n))return r;return-1}function kp(i,t){let e=i.countIndent(t,i.pos,i.indent),n=i.countIndent(i.skipSpace(t),t,e);return n>=e+5?e+1:n}function On(i,t,e){let n=i.length-1;n>=0&&i[n].to==t&&i[n].type==T.CodeText?i[n].to=e:i.push(st(T.CodeText,t,e))}const ia={LinkReference:void 0,IndentedCode(i,t){let e=t.baseIndent+4;if(t.indent<e)return!1;let n=t.findColumn(e),r=i.lineStart+n,s=i.lineStart+t.text.length,o=[],l=[];for(On(o,r,s);i.nextLine()&&t.depth>=i.stack.length;)if(t.pos==t.text.length){On(l,i.lineStart-1,i.lineStart);for(let a of t.markers)l.push(a)}else{if(t.indent<e)break;{if(l.length){for(let c of l)c.type==T.CodeText?On(o,c.from,c.to):o.push(c);l=[]}On(o,i.lineStart-1,i.lineStart);for(let c of t.markers)o.push(c);s=i.lineStart+t.text.length;let a=i.lineStart+t.findColumn(t.baseIndent+4);a<s&&On(o,a,s)}}return l.length&&(l=l.filter(a=>a.type!=T.CodeText),l.length&&(t.markers=l.concat(t.markers))),i.addNode(i.buffer.writeElements(o,-r).finish(T.CodeBlock,s-r),r),!0},FencedCode(i,t){let e=iw(t);if(e<0)return!1;let n=i.lineStart+t.pos,r=t.next,s=e-t.pos,o=t.skipSpace(e),l=yp(t.text,t.text.length,o),a=[st(T.CodeMark,n,n+s)];o<l&&a.push(st(T.CodeInfo,i.lineStart+o,i.lineStart+l));for(let c=!0,h=!0,u=!1;i.nextLine()&&t.depth>=i.stack.length;c=!1){let f=t.pos;if(t.indent-t.baseIndent<4)for(;f<t.text.length&&t.text.charCodeAt(f)==r;)f++;if(f-t.pos>=s&&t.skipSpace(f)==t.text.length){for(let d of t.markers)a.push(d);h&&u&&On(a,i.lineStart-1,i.lineStart),a.push(st(T.CodeMark,i.lineStart+t.pos,i.lineStart+f)),i.nextLine();break}else{u=!0,c||(On(a,i.lineStart-1,i.lineStart),h=!1);for(let p of t.markers)a.push(p);let d=i.lineStart+t.basePos,O=i.lineStart+t.text.length;d<O&&(On(a,d,O),h=!1)}}return i.addNode(i.buffer.writeElements(a,-n).finish(T.FencedCode,i.prevLineEnd()-n),n),!0},Blockquote(i,t){let e=nw(t);return e<0?!1:(i.startContext(T.Blockquote,t.pos),i.addNode(T.QuoteMark,i.lineStart+t.pos,i.lineStart+t.pos+1),t.moveBase(t.pos+e),null)},HorizontalRule(i,t){if(ed(t,i,!1)<0)return!1;let e=i.lineStart+t.pos;return i.nextLine(),i.addNode(T.HorizontalRule,e),!0},BulletList(i,t){let e=id(t,i,!1);if(e<0)return!1;i.block.type!=T.BulletList&&i.startContext(T.BulletList,t.basePos,t.next);let n=kp(t,t.pos+1);return i.startContext(T.ListItem,t.basePos,n-t.baseIndent),i.addNode(T.ListMark,i.lineStart+t.pos,i.lineStart+t.pos+e),t.moveBaseColumn(n),null},OrderedList(i,t){let e=nd(t,i,!1);if(e<0)return!1;i.block.type!=T.OrderedList&&i.startContext(T.OrderedList,t.basePos,t.text.charCodeAt(t.pos+e-1));let n=kp(t,t.pos+e);return i.startContext(T.ListItem,t.basePos,n-t.baseIndent),i.addNode(T.ListMark,i.lineStart+t.pos,i.lineStart+t.pos+e),t.moveBaseColumn(n),null},ATXHeading(i,t){let e=sw(t);if(e<0)return!1;let n=t.pos,r=i.lineStart+n,s=yp(t.text,t.text.length,n),o=s;for(;o>n&&t.text.charCodeAt(o-1)==t.next;)o--;(o==s||o==n||!ti(t.text.charCodeAt(o-1)))&&(o=t.text.length);let l=i.buffer.write(T.HeaderMark,0,e).writeElements(i.parser.parseInline(t.text.slice(n+e+1,o),r+e+1),-r);o<t.text.length&&l.write(T.HeaderMark,o-n,s-n);let a=l.finish(T.ATXHeading1-1+e,t.text.length-n);return i.nextLine(),i.addNode(a,r),!0},HTMLBlock(i,t){let e=cw(t,i,!1);if(e<0)return!1;let n=i.lineStart+t.pos,r=Iu[e][1],s=[],o=r!=_u;for(;!r.test(t.text)&&i.nextLine();){if(t.depth<i.stack.length){o=!1;break}for(let c of t.markers)s.push(c)}o&&i.nextLine();let l=r==lw?T.CommentBlock:r==aw?T.ProcessingInstructionBlock:T.HTMLBlock,a=i.prevLineEnd();return i.addNode(i.buffer.writeElements(s,-n).finish(l,a-n),n),!0},SetextHeading:void 0};class Y${constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,e,n){if(this.stage==-1)return!1;let r=n.content+`
37
+ `&&i.lineWrapping&&(n&&(n=C.single(n.main.anchor-1,n.main.head-1)),e={from:s.from,to:s.to,insert:Y.of([" "])}),e)return zf(i,e,n,o);if(n&&!Ia(n,s)){let l=!1,a="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(l=!0),a=i.inputState.lastSelectionOrigin,a=="select.pointer"&&(n=Xb(r.facet(kl).map(c=>c(i)),n))),i.dispatch({selection:n,scrollIntoView:l,userEvent:a}),!0}else return!1}function zf(i,t,e,n=-1){if(M.ios&&i.inputState.flushIOSKey(t))return!0;let r=i.state.selection.main;if(M.android&&(t.to==r.to&&(t.from==r.from||t.from==r.from-1&&i.state.sliceDoc(t.from,r.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&Ir(i.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||n==8&&t.insert.length<t.to-t.from&&t.to>r.head)&&Ir(i.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Ir(i.contentDOM,"Delete",46)))return!0;let s=t.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=xy(i,t,e));return i.state.facet(vb).some(a=>a(i,t.from,t.to,s,l))||i.dispatch(l()),!0}function xy(i,t,e){let n,r=i.state,s=r.selection.main,o=-1;if(t.from==t.to&&t.from<s.from||t.from>s.to){let a=t.from<s.from?-1:1,c=a<0?s.from:s.to,h=Do(r.facet(kl).map(u=>u(i)),c,a);t.from==h&&(o=h)}if(o>-1)n={changes:t,selection:C.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!e||e.main.empty&&e.main.from==t.from+t.insert.length)&&i.inputState.composing<0){let a=s.from<t.from?r.sliceDoc(s.from,t.from):"",c=s.to>t.to?r.sliceDoc(t.to,s.to):"";n=r.replaceSelection(i.state.toText(a+t.insert.sliceString(0,void 0,i.state.lineBreak)+c))}else{let a=r.changes(t),c=e&&e.main.to<=a.newLength?e.main:void 0;if(r.selection.ranges.length>1&&(i.inputState.composing>=0||i.inputState.compositionPendingChange)&&t.to<=s.to+10&&t.to>=s.to-10){let h=i.state.sliceDoc(t.from,t.to),u,f=e&&Zb(i,e.main.head);if(f){let O=t.insert.length-(t.to-t.from);u={from:f.from,to:f.to-O}}else u=i.state.doc.lineAt(s.head);let d=s.to-t.to;n=r.changeByRange(O=>{if(O.from==s.from&&O.to==s.to)return{changes:a,range:c||O.map(a)};let p=O.to-d,m=p-h.length;if(i.state.sliceDoc(m,p)!=h||p>=u.from&&m<=u.to)return{range:O};let g=r.changes({from:m,to:p,insert:t.insert}),b=O.to-s.to;return{changes:g,range:c?C.range(Math.max(0,c.anchor+b),Math.max(0,c.head+b)):O.map(g)}})}else n={changes:a,selection:c&&r.selection.replaceRange(c)}}let l="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,l+=".compose",i.inputState.compositionFirstChange&&(l+=".start",i.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:l,scrollIntoView:!0})}function Mb(i,t,e,n){let r=Math.min(i.length,t.length),s=0;for(;s<r&&i.charCodeAt(s)==t.charCodeAt(s);)s++;if(s==r&&i.length==t.length)return null;let o=i.length,l=t.length;for(;o>0&&l>0&&i.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,s-Math.min(o,l));e-=o+a-s}if(o<s&&i.length<t.length){let a=e<=s&&e>=o?s-e:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=e<=s&&e>=l?s-e:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function yy(i){let t=[];if(i.root.activeElement!=i.contentDOM)return t;let{anchorNode:e,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return e&&(t.push(new CO(e,n)),(r!=e||s!=n)&&t.push(new CO(r,s))),t}function ky(i,t){if(i.length==0)return null;let e=i[0].pos,n=i.length==2?i[1].pos:e;return e>-1&&n>-1?C.single(e+t,n+t):null}function Ia(i,t){return t.head==i.main.head&&t.anchor==i.main.anchor}class Qy{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,M.safari&&t.contentDOM.addEventListener("input",()=>null),M.gecko&&jy(t.contentDOM.ownerDocument)}handleEvent(t){!Xy(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let n=this.handlers[t];if(n){for(let r of n.observers)r(this.view,e);for(let r of n.handlers){if(e.defaultPrevented)break;if(r(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=$y(t),n=this.handlers,r=this.view.contentDOM;for(let s in e)if(s!="scroll"){let o=!e[s].handlers.length,l=n[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!e[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&_b.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),M.android&&M.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return M.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&!t.shiftKey&&((e=zb.find(n=>n.keyCode==t.keyCode))&&!t.ctrlKey||Cy.indexOf(t.key)>-1&&t.ctrlKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(t.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(t){let e=this.pendingIOSKey;return!e||e.key=="Enter"&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString())?!1:(this.pendingIOSKey=void 0,Ir(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0))}ignoreDuringComposition(t){return!/^key/.test(t.type)||t.synthetic?!1:this.composing>0?!0:M.safari&&!M.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function PO(i,t){return(e,n)=>{try{return t.call(i,n,e)}catch(r){Li(e.state,r)}}}function $y(i){let t=Object.create(null);function e(n){return t[n]||(t[n]={observers:[],handlers:[]})}for(let n of i){let r=n.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&e(l).handlers.push(PO(n.value,a))}if(o)for(let l in o){let a=o[l];a&&e(l).observers.push(PO(n.value,a))}}for(let n in fi)e(n).handlers.push(fi[n]);for(let n in Qe)e(n).observers.push(Qe[n]);return t}const zb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Cy="dthko",_b=[16,17,18,20,91,92,224,225],Bl=6;function Wl(i){return Math.max(0,i)*.7+8}function Py(i,t){return Math.max(Math.abs(i.clientX-t.clientX),Math.abs(i.clientY-t.clientY))}class Ty{constructor(t,e,n,r){this.view=t,this.startEvent=e,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=lb(t.contentDOM),this.atoms=t.state.facet(kl).map(o=>o(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(K.allowMultipleSelections)&&Ay(t,e),this.dragging=Zy(t,e)&&Db(e)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Py(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let e=0,n=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Mf(this.view);t.clientX-a.left<=r+Bl?e=-Wl(r-t.clientX):t.clientX+a.right>=o-Bl&&(e=Wl(t.clientX-o)),t.clientY-a.top<=s+Bl?n=-Wl(s-t.clientY):t.clientY+a.bottom>=l-Bl&&(n=Wl(t.clientY-l)),this.setScrollSpeed(e,n)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),this.dragging===!1&&this.select(this.lastEvent)}select(t){let{view:e}=this,n=Xb(this.atoms,this.style.get(t,this.extend,this.multiple));(this.mustSelect||!n.eq(e.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Ay(i,t){let e=i.state.facet(gb);return e.length?e[0](t):M.mac?t.metaKey:t.ctrlKey}function Ry(i,t){let e=i.state.facet(bb);return e.length?e[0](t):M.mac?!t.altKey:!t.ctrlKey}function Zy(i,t){let{main:e}=i.state.selection;if(e.empty)return!1;let n=Fo(i.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=t.clientX&&o.right>=t.clientX&&o.top<=t.clientY&&o.bottom>=t.clientY)return!0}return!1}function Xy(i,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target,n;e!=i.contentDOM;e=e.parentNode)if(!e||e.nodeType==11||(n=zt.get(e))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0}const fi=Object.create(null),Qe=Object.create(null),Ib=M.ie&&M.ie_version<15||M.ios&&M.webkit_version<604;function Ey(i){let t=i.dom.parentNode;if(!t)return;let e=t.appendChild(document.createElement("textarea"));e.style.cssText="position: fixed; left: -10000px; top: 10px",e.focus(),setTimeout(()=>{i.focus(),e.remove(),jb(i,e.value)},50)}function Pc(i,t,e){for(let n of i.facet(t))e=n(e,i);return e}function jb(i,t){t=Pc(i.state,Zf,t);let{state:e}=i,n,r=1,s=e.toText(t),o=s.lines==e.selection.ranges.length;if(ku!=null&&e.selection.ranges.every(a=>a.empty)&&ku==s.toString()){let a=-1;n=e.changeByRange(c=>{let h=e.doc.lineAt(c.from);if(h.from==a)return{range:c};a=h.from;let u=e.toText((o?s.line(r++).text:t)+e.lineBreak);return{changes:{from:h.from,insert:u},range:C.cursor(c.from+u.length)}})}else o?n=e.changeByRange(a=>{let c=s.line(r++);return{changes:{from:a.from,to:a.to,insert:c.text},range:C.cursor(a.from+c.length)}}):n=e.replaceSelection(s);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Qe.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};Qe.wheel=Qe.mousewheel=i=>{i.inputState.lastWheelEvent=Date.now()};fi.keydown=(i,t)=>(i.inputState.setSelectionOrigin("select"),t.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);Qe.touchstart=(i,t)=>{let e=i.inputState,n=t.targetTouches[0];e.lastTouchTime=Date.now(),n&&(e.lastTouchX=n.clientX,e.lastTouchY=n.clientY),e.setSelectionOrigin("select.pointer")};Qe.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};fi.mousedown=(i,t)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let e=null;for(let n of i.state.facet(wb))if(e=n(i,t),e)break;if(!e&&t.button==0&&(e=My(i,t)),e){let n=!i.hasFocus;i.inputState.startMouseSelection(new Ty(i,t,e,n)),n&&i.observer.ignore(()=>{ab(i.contentDOM);let s=i.root.activeElement;s&&!s.contains(i.contentDOM)&&s.blur()});let r=i.inputState.mouseSelection;if(r)return r.start(t),r.dragging===!1}else i.inputState.setSelectionOrigin("select.pointer");return!1};function TO(i,t,e,n){if(n==1)return C.cursor(t,e);if(n==2)return fy(i.state,t,e);{let r=i.docView.lineAt(t,e),s=i.state.doc.lineAt(r?r.posAtEnd:t),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<i.state.doc.length&&l==s.to&&l++,C.range(o,l)}}const Ly=M.ie&&M.ie_version<=11;let AO=null,RO=0,ZO=0;function Db(i){if(!Ly)return i.detail;let t=AO,e=ZO;return AO=i,ZO=Date.now(),RO=!t||e>Date.now()-400&&Math.abs(t.clientX-i.clientX)<2&&Math.abs(t.clientY-i.clientY)<2?(RO+1)%3:1}function My(i,t){let e=i.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),n=Db(t),r=i.state.selection;return{update(s){s.docChanged&&(e.pos=s.changes.mapPos(e.pos),r=r.map(s.changes))},get(s,o,l){let a=i.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),c,h=TO(i,a.pos,a.assoc,n);if(e.pos!=a.pos&&!o){let u=TO(i,e.pos,e.assoc,n),f=Math.min(u.from,h.from),d=Math.max(u.to,h.to);h=f<h.from?C.range(f,d,h.assoc):C.range(d,f,h.assoc)}return o?r.replaceRange(r.main.extend(h.from,h.to,h.assoc)):l&&n==1&&r.ranges.length>1&&(c=zy(r,a.pos))?c:l?r.addRange(h):C.create([h])}}}function zy(i,t){for(let e=0;e<i.ranges.length;e++){let{from:n,to:r}=i.ranges[e];if(n<=t&&r>=t)return C.create(i.ranges.slice(0,e).concat(i.ranges.slice(e+1)),i.mainIndex==e?0:i.mainIndex-(i.mainIndex>e?1:0))}return null}fi.dragstart=(i,t)=>{let{selection:{main:e}}=i.state;if(t.target.draggable){let r=i.docView.tile.nearest(t.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=e.to||o<=e.from)&&(e=C.range(s,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=e,t.dataTransfer&&(t.dataTransfer.setData("Text",Pc(i.state,Xf,i.state.sliceDoc(e.from,e.to))),t.dataTransfer.effectAllowed="copyMove"),!1};fi.dragend=i=>(i.inputState.draggedContent=null,!1);function XO(i,t,e,n){if(e=Pc(i.state,Zf,e),!e)return;let r=i.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:s}=i.inputState,o=n&&s&&Ry(i,t)?{from:s.from,to:s.to}:null,l={from:r,insert:e},a=i.state.changes(o?[o,l]:l);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}fi.drop=(i,t)=>{if(!t.dataTransfer)return!1;if(i.state.readOnly)return!0;let e=t.dataTransfer.files;if(e&&e.length){let n=Array(e.length),r=0,s=()=>{++r==e.length&&XO(i,t,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o<e.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[o]=l.result),s()},l.readAsText(e[o])}return!0}else{let n=t.dataTransfer.getData("Text");if(n)return XO(i,t,n,!0),!0}return!1};fi.paste=(i,t)=>{if(i.state.readOnly)return!0;i.observer.flush();let e=Ib?null:t.clipboardData;return e?(jb(i,e.getData("text/plain")||e.getData("text/uri-list")),!0):(Ey(i),!1)};function _y(i,t){let e=i.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=t,n.focus(),n.selectionEnd=t.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function Iy(i){let t=[],e=[],n=!1;for(let r of i.selection.ranges)r.empty||(t.push(i.sliceDoc(r.from,r.to)),e.push(r));if(!t.length){let r=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>r&&(t.push(o.text),e.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),r=o.number}n=!0}return{text:Pc(i,Xf,t.join(i.lineBreak)),ranges:e,linewise:n}}let ku=null;fi.copy=fi.cut=(i,t)=>{if(!Io(i.contentDOM,i.observer.selectionRange))return!1;let{text:e,ranges:n,linewise:r}=Iy(i.state);if(!e&&!r)return!1;ku=r?e:null,t.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=Ib?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",e),!0):(_y(i,e),!1)};const Vb=Ke.define();function Bb(i,t){let e=[];for(let n of i.facet(xb)){let r=n(i,t);r&&e.push(r)}return e.length?i.update({effects:e,annotations:Vb.of(!0)}):null}function Wb(i){setTimeout(()=>{let t=i.hasFocus;if(t!=i.inputState.notifiedFocused){let e=Bb(i.state,t);e?i.dispatch(e):i.update([])}},10)}Qe.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),Wb(i)};Qe.blur=i=>{i.observer.clearSelectionRange(),Wb(i)};Qe.compositionstart=Qe.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};Qe.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,M.chrome&&M.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};Qe.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};fi.beforeinput=(i,t)=>{var e,n;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(i.inputState.insertingText=t.data,i.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&i.observer.editContext){let s=(e=t.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain"),o=t.getTargetRanges();if(s&&o.length){let l=o[0],a=i.posAtDOM(l.startContainer,l.startOffset),c=i.posAtDOM(l.endContainer,l.endOffset);return zf(i,{from:a,to:c,insert:i.state.toText(s)},null),!0}}let r;if(M.chrome&&M.android&&(r=zb.find(s=>s.inputType==t.inputType))&&(i.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return M.ios&&t.inputType=="deleteContentForward"&&i.observer.flushSoon(),M.safari&&t.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>Qe.compositionend(i,t),20),!1};const EO=new Set;function jy(i){EO.has(i)||(EO.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const LO=["pre-wrap","normal","pre-line","break-spaces"];let Ns=!1;function MO(){Ns=!1}class Dy{constructor(t){this.lineWrapping=t,this.doc=Y.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let n=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((e-t-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return LO.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let n=0;n<t.length;n++){let r=t[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(e=!0,this.heightSamples[Math.floor(r*10)]=!0)}return e}refresh(t,e,n,r,s,o){let l=LO.indexOf(t)>-1,a=Math.abs(e-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=e,this.charWidth=n,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let c=0;c<o.length;c++){let h=o[c];h<0?c++:this.heightSamples[Math.floor(h*10)]=!0}}return a}}class Vy{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class li{constructor(t,e,n,r,s){this.from=t,this.length=e,this.top=n,this.height=r,this._content=s}get type(){return typeof this._content=="number"?pe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof wr?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new li(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var xt=function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i}(xt||(xt={}));const ba=.001;class me{constructor(t,e,n=2){this.length=t,this.height=e,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>ba&&(Ns=!0),this.height=t)}replace(t,e,n){return me.of(n)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,n,r){let s=this,o=n.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:h,toB:u}=r[l],f=s.lineAt(a,xt.ByPosNoHeight,n.setDoc(e),0,0),d=f.to>=c?f:s.lineAt(c,xt.ByPosNoHeight,n,0,0);for(u+=d.to-c,c=d.to;l>0&&f.from<=r[l-1].toA;)a=r[l-1].fromA,h=r[l-1].fromB,l--,a<f.from&&(f=s.lineAt(a,xt.ByPosNoHeight,n,0,0));h+=f.from-a,a=f.from;let O=_f.build(n.setDoc(o),t,h,u);s=ja(s,s.replace(a,c,O))}return s.updateHeight(n,0)}static empty(){return new Me(0,0,0)}static of(t){if(t.length==1)return t[0];let e=0,n=t.length,r=0,s=0;for(;;)if(e==n)if(r>s*2){let l=t[e-1];l.break?t.splice(--e,1,l.left,null,l.right):t.splice(--e,1,l.left,l.right),n+=1+l.break,r-=l.size}else if(s>r*2){let l=t[n];l.break?t.splice(n,1,l.left,null,l.right):t.splice(n,1,l.left,l.right),n+=2+l.break,s-=l.size}else break;else if(r<s){let l=t[e++];l&&(r+=l.size)}else{let l=t[--n];l&&(s+=l.size)}let o=0;return t[e-1]==null?(o=1,e--):t[e]==null&&(o=1,n++),new Wy(me.of(t.slice(0,e)),o,me.of(t.slice(n)))}}function ja(i,t){return i==t?i:(i.constructor!=t.constructor&&(Ns=!0),t)}me.prototype.size=1;const By=J.replace({});class Yb extends me{constructor(t,e,n){super(t,e),this.deco=n,this.spaceAbove=0}mainBlock(t,e){return new li(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(t,e,n,r){return this.spaceAbove&&t<n+this.spaceAbove?new li(r,0,n,this.spaceAbove,By):this.mainBlock(n,r)}lineAt(t,e,n,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,n,r,s).join(o):o}forEachLine(t,e,n,r,s,o){t<=s+this.length&&e>=s&&o(this.lineAt(0,xt.ByPos,n,r,s))}setMeasuredHeight(t){let e=t.heights[t.index++];e<0?(this.spaceAbove=-e,e=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(e)}updateHeight(t,e=0,n=!1,r){return r&&r.from<=e&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Me extends Yb{constructor(t,e,n){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(t,e){return new li(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,e,n){let r=n[0];return n.length==1&&(r instanceof Me||r instanceof Jt&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Jt?r=new Me(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):me.of(n)}updateHeight(t,e=0,n=!1,r){return r&&r.from<=e&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Jt extends me{constructor(t){super(t,0)}heightMetrics(t,e){let n=t.doc.lineAt(e).number,r=t.doc.lineAt(e+this.length).number,s=r-n+1,o,l=0;if(t.lineWrapping){let a=Math.min(this.height,t.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:l}}blockAt(t,e,n,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(e,r);if(e.lineWrapping){let c=r+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-n)/this.height))*this.length)),h=e.doc.lineAt(c),u=l+h.length*a,f=Math.max(n,t-u/2);return new li(h.from,h.length,f,u,0)}else{let c=Math.max(0,Math.min(o-s,Math.floor((t-n)/l))),{from:h,length:u}=e.doc.line(s+c);return new li(h,u,n+l*c,l,0)}}lineAt(t,e,n,r,s){if(e==xt.ByHeight)return this.blockAt(t,n,r,s);if(e==xt.ByPosNoHeight){let{from:d,to:O}=n.doc.lineAt(t);return new li(d,O-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,s),c=n.doc.lineAt(t),h=l+c.length*a,u=c.number-o,f=r+l*u+a*(c.from-s-u);return new li(c.from,c.length,Math.max(r,Math.min(f,r+this.height-h)),h,0)}forEachLine(t,e,n,r,s,o){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(n,s);for(let h=t,u=r;h<=e;){let f=n.doc.lineAt(h);if(h==t){let O=f.number-l;u+=a*O+c*(t-s-O)}let d=a+c*f.length;o(new li(f.from,f.length,u,d,0)),u+=d,h=f.to+1}}replace(t,e,n){let r=this.length-e;if(r>0){let s=n[n.length-1];s instanceof Jt?n[n.length-1]=new Jt(s.length+r):n.push(null,new Jt(r-1))}if(t>0){let s=n[0];s instanceof Jt?n[0]=new Jt(t+s.length):n.unshift(new Jt(t-1),null)}return me.of(n)}decomposeLeft(t,e){e.push(new Jt(t-1),null)}decomposeRight(t,e){e.push(null,new Jt(this.length-t-1))}updateHeight(t,e=0,n=!1,r){let s=e+this.length;if(r&&r.from<=e+this.length&&r.more){let o=[],l=Math.max(e,r.from),a=-1;for(r.from>e&&o.push(new Jt(r.from-e-1).updateHeight(t,e));l<=s&&r.more;){let h=t.doc.lineAt(l).length;o.length&&o.push(null);let u=r.heights[r.index++],f=0;u<0&&(f=-u,u=r.heights[r.index++]),a==-1?a=u:Math.abs(u-a)>=ba&&(a=-2);let d=new Me(h,u,f);d.outdated=!1,o.push(d),l+=h+1}l<=s&&o.push(null,new Jt(s-l).updateHeight(t,l));let c=me.of(o);return(a<0||Math.abs(c.height-this.height)>=ba||Math.abs(a-this.heightMetrics(t,e).perLine)>=ba)&&(Ns=!0),ja(this,c)}else(n||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Wy extends me{constructor(t,e,n){super(t.length+e+n.length,t.height+n.height,e|(t.outdated||n.outdated?2:0)),this.left=t,this.right=n,this.size=t.size+n.size}get break(){return this.flags&1}blockAt(t,e,n,r){let s=n+this.left.height;return t<s?this.left.blockAt(t,e,n,r):this.right.blockAt(t,e,s,r+this.left.length+this.break)}lineAt(t,e,n,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=e==xt.ByHeight?t<o:t<l,c=a?this.left.lineAt(t,e,n,r,s):this.right.lineAt(t,e,n,o,l);if(this.break||(a?c.to<l:c.from>l))return c;let h=e==xt.ByPosNoHeight?xt.ByPosNoHeight:xt.ByPos;return a?c.join(this.right.lineAt(l,h,n,o,l)):this.left.lineAt(l,h,n,r,s).join(c)}forEachLine(t,e,n,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,n,r,s,o),e>=a&&this.right.forEachLine(t,e,n,l,a,o);else{let c=this.lineAt(a,xt.ByPos,n,r,s);t<c.from&&this.left.forEachLine(t,c.from-1,n,r,s,o),c.to>=t&&c.from<=e&&o(c),e>c.to&&this.right.forEachLine(c.to+1,e,n,l,a,o)}}replace(t,e,n){let r=this.left.length+this.break;if(e<r)return this.balanced(this.left.replace(t,e,n),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-r,e-r,n));let s=[];t>0&&this.decomposeLeft(t,s);let o=s.length;for(let l of n)s.push(l);if(t>0&&zO(s,o-1),e<this.length){let l=s.length;this.decomposeRight(e,s),zO(s,l)}return me.of(s)}decomposeLeft(t,e){let n=this.left.length;if(t<=n)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(n++,t>=n&&e.push(null)),t>n&&this.right.decomposeLeft(t-n,e)}decomposeRight(t,e){let n=this.left.length,r=n+this.break;if(t>=r)return this.right.decomposeRight(t-r,e);t<n&&this.left.decomposeRight(t,e),this.break&&t<r&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?me.of(this.break?[t,null,e]:[t,e]):(this.left=ja(this.left,t),this.right=ja(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,n=!1,r){let{left:s,right:o}=this,l=e+s.length+this.break,a=null;return r&&r.from<=e+s.length&&r.more?a=s=s.updateHeight(t,e,n,r):s.updateHeight(t,e,n),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(t,l,n,r):o.updateHeight(t,l,n),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function zO(i,t){let e,n;i[t]==null&&(e=i[t-1])instanceof Jt&&(n=i[t+1])instanceof Jt&&i.splice(t-1,3,new Jt(e.length+1+n.length))}const Yy=5;class _f{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let n=Math.min(e,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Me?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Me(n-this.pos,-1,0)),this.writtenTo=n,e>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,n){if(t<e||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=e-t;n.block?this.addBlock(new Yb(o,r,n)):(o||s||r>=Yy)&&this.addLineDeco(r,s,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Me(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,e){let n=new Jt(e-t);return this.oracle.doc.lineAt(t).to==e&&(n.flags|=4),n}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Me)return t;let e=new Me(0,-1,0);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,t),r.breaks+=e,this.writtenTo=this.pos=this.pos+n}finish(t){let e=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(e instanceof Me)&&!this.isCovered?this.nodes.push(new Me(0,-1,0)):(this.writtenTo<this.pos||e==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=t;for(let r of this.nodes)r instanceof Me&&r.updateHeight(this.oracle,n),n+=r?r.length:1;return this.nodes}static build(t,e,n,r){let s=new _f(n,t);return Ot.spans(e,n,r,s,0),s.finish(n)}}function qy(i,t,e){let n=new Ny;return Ot.compare(i,t,e,n,0),n.changes}class Ny{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,n,r){(t<e||n&&n.heightRelevant||r&&r.heightRelevant)&&_r(t,e,this.changes,5)}}function Gy(i,t){let e=i.getBoundingClientRect(),n=i.ownerDocument,r=n.defaultView||window,s=Math.max(0,e.left),o=Math.min(r.innerWidth,e.right),l=Math.max(0,e.top),a=Math.min(r.innerHeight,e.bottom);for(let c=i.parentNode;c&&c!=n.body;)if(c.nodeType==1){let h=c,u=window.getComputedStyle(h);if((h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth)&&u.overflow!="visible"){let f=h.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(c==i.parentNode?r.innerHeight:a,f.bottom)}c=u.position=="absolute"||u.position=="fixed"?h.offsetParent:h.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-e.left,right:Math.max(s,o)-e.left,top:l-(e.top+t),bottom:Math.max(l,a)-(e.top+t)}}function Uy(i){let t=i.getBoundingClientRect(),e=i.ownerDocument.defaultView||window;return t.left<e.innerWidth&&t.right>0&&t.top<e.innerHeight&&t.bottom>0}function Hy(i,t){let e=i.getBoundingClientRect();return{left:0,right:e.right-e.left,top:t,bottom:e.bottom-(e.top+t)}}class fh{constructor(t,e,n,r){this.from=t,this.to=e,this.size=n,this.displaySize=r}static same(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],s=e[n];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(t,e){return J.replace({widget:new Fy(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class Fy extends jn{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class _O{constructor(t,e){this.view=t,this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=IO,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Tt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=e.facet(Ef).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new Dy(n),this.stateDeco=jO(e),this.heightMap=me.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle.setDoc(e.doc),[new Ye(0,0,0,e.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=J.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=t.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let n=0;n<=1;n++){let r=n?e.head:e.anchor;if(!t.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);t.push(new Yl(s,o))}}return this.viewports=t.sort((n,r)=>n.from-r.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?IO:new If(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(Zo(t,this.scaler))})}update(t,e=null){this.state=t.state;let n=this.stateDeco;this.stateDeco=jO(this.state);let r=t.changedRanges,s=Ye.extendWithRanges(r,qy(n,this.stateDeco,t?t.changes:Lt.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);MO(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Ns)&&(t.flags|=2),l?(this.scrollAnchorPos=t.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let c=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,t.flags|=this.updateForViewport(),(c||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(kb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,e=t.contentDOM,n=window.getComputedStyle(e),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?Tt.RTL:Tt.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=e.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,h=0;if(l.width&&l.height){let{scaleX:y,scaleY:k}=ob(e,l);(y>.005&&Math.abs(this.scaleX-y)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=y,this.scaleY=k,c|=16,o=a=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,f=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=f)&&(this.paddingTop=u,this.paddingBottom=f,c|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,c|=16);let d=lb(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let O=this.getScrollOffset();this.scrollOffset!=O&&(this.scrollAnchorHeight=-1,this.scrollOffset=O),this.scrolledToBottom=cb(this.scrollParent||t.win);let p=(this.printing?Hy:Gy)(e,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView&&!this.scrollTarget&&!Uy(t.dom))return 0;let S=l.width;if((this.contentDOMWidth!=S||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,c|=16),a){let y=t.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(y)&&(o=!0),o||r.lineWrapping&&Math.abs(S-this.contentDOMWidth)>r.charWidth){let{lineHeight:k,charWidth:Q,textHeight:Z}=t.docView.measureTextSize();o=k>0&&r.refresh(s,k,Q,Z,Math.max(5,S/Q),y),o&&(t.docView.minWidth=0,c|=16)}m>0&&g>0?h=Math.max(m,g):m<0&&g<0&&(h=Math.min(m,g)),MO();for(let k of this.viewports){let Q=k.from==this.viewport.from?y:t.docView.measureVisibleLineHeights(k);this.heightMap=(o?me.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle,[new Ye(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Vy(k.from,Q))}Ns&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(c&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let n=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Yl(r.lineAt(o-n*1e3,xt.ByHeight,s,0,0).from,r.lineAt(l+(1-n)*1e3,xt.ByHeight,s,0,0).to);if(e){let{head:c}=e.range;if(c<a.from||c>a.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=r.lineAt(c,xt.ByPos,s,0,0),f;e.y=="center"?f=(u.top+u.bottom)/2-h/2:e.y=="start"||e.y=="nearest"&&c<a.from?f=u.top:f=u.bottom-h,a=new Yl(r.lineAt(f-1e3/2,xt.ByHeight,s,0,0).from,r.lineAt(f+h+1e3/2,xt.ByHeight,s,0,0).to)}}return a}mapViewport(t,e){let n=e.mapPos(t.from,-1),r=e.mapPos(t.to,1);return new Yl(this.heightMap.lineAt(n,xt.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,xt.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(t,xt.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,xt.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(t==0||r<=o-Math.max(10,Math.min(-n,250)))&&(e==this.state.doc.length||s>=l+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let n=[];for(let r of t)e.touchesRange(r.from,r.to)||n.push(new fh(e.mapPos(r.from),e.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(t,e){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=Tt.LTR&&!n)return[];let l=[],a=(h,u,f,d)=>{if(u-h<s)return;let O=this.state.selection.main,p=[O.from];O.empty||p.push(O.to);for(let g of p)if(g>h&&g<u){a(h,g-10,f,d),a(g+10,u,f,d);return}let m=Jy(t,g=>g.from>=f.from&&g.to<=f.to&&Math.abs(g.from-h)<s&&Math.abs(g.to-u)<s&&!p.some(b=>g.from<b&&g.to>b));if(!m){if(u<f.to&&e&&n&&e.visibleRanges.some(S=>S.from<=u&&S.to>=u)){let S=e.moveToLineBoundary(C.cursor(u),!1,!0).head;S>h&&(u=S)}let g=this.gapSize(f,h,u,d),b=n||g<2e6?g:2e6;m=new fh(h,u,g,b)}l.push(m)},c=h=>{if(h.length<o||h.type!=pe.Text)return;let u=Ky(h.from,h.to,this.stateDeco);if(u.total<o)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,d,O;if(n){let p=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,g;if(f!=null){let b=Nl(u,f),S=((this.visibleBottom-this.visibleTop)/2+p)/h.height;m=b-S,g=b+S}else m=(this.visibleTop-h.top-p)/h.height,g=(this.visibleBottom-h.top+p)/h.height;d=ql(u,m),O=ql(u,g)}else{let p=u.total*this.heightOracle.charWidth,m=r*this.heightOracle.charWidth,g=0;if(p>2e6)for(let k of t)k.from>=h.from&&k.from<h.to&&k.size!=k.displaySize&&k.from*this.heightOracle.charWidth+g<this.pixelViewport.left&&(g=k.size-k.displaySize);let b=this.pixelViewport.left+g,S=this.pixelViewport.right+g,x,y;if(f!=null){let k=Nl(u,f),Q=((S-b)/2+m)/p;x=k-Q,y=k+Q}else x=(b-m)/p,y=(S+m)/p;d=ql(u,x),O=ql(u,y)}d>h.from&&a(h.from,d,h,u),O<h.to&&a(O,h.to,h,u)};for(let h of this.viewportLines)Array.isArray(h.type)?h.type.forEach(c):c(h);return l}gapSize(t,e,n,r){let s=Nl(r,n)-Nl(r,e);return this.heightOracle.lineWrapping?t.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(t){fh.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=J.set(t.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let n=[];Ot.spans(e,this.viewport.from,this.viewport.to,{span(s,o){n.push({from:s,to:o})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let s=0;s<n.length&&!(r&8);s++){let o=this.visibleRanges[s],l=n[s];(o.from!=l.from||o.to!=l.to)&&(r|=4,t&&t.mapPos(o.from,-1)==l.from&&t.mapPos(o.to,1)==l.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||Zo(this.heightMap.lineAt(t,xt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||Zo(this.heightMap.lineAt(this.scaler.fromDOM(t),xt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return Zo(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Yl{constructor(t,e){this.from=t,this.to=e}}function Ky(i,t,e){let n=[],r=i,s=0;return Ot.spans(e,i,t,{span(){},point(o,l){o>r&&(n.push({from:r,to:o}),s+=o-r),r=l}},20),r<t&&(n.push({from:r,to:t}),s+=t-r),{total:s,ranges:n}}function ql({total:i,ranges:t},e){if(e<=0)return t[0].from;if(e>=1)return t[t.length-1].to;let n=Math.floor(i*e);for(let r=0;;r++){let{from:s,to:o}=t[r],l=o-s;if(n<=l)return s+n;n-=l}}function Nl(i,t){let e=0;for(let{from:n,to:r}of i.ranges){if(t<=r){e+=t-n;break}e+=r-n}return e/i.total}function Jy(i,t){for(let e of i)if(t(e))return e}const IO={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};function jO(i){let t=i.facet(Qc).filter(n=>typeof n!="function"),e=i.facet(Lf).filter(n=>typeof n!="function");return e.length&&t.push(Ot.join(e)),t}class If{constructor(t,e,n){let r=0,s=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let c=e.lineAt(l,xt.ByPos,t,0,0).top,h=e.lineAt(a,xt.ByPos,t,0,0).bottom;return r+=h-c,{from:l,to:a,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(e.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(t){for(let e=0,n=0,r=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return r+(t-n)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);n=s.bottom,r=s.domBottom}}fromDOM(t){for(let e=0,n=0,r=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return n+(t-r)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);n=s.bottom,r=s.domBottom}}eq(t){return t instanceof If?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to):!1}}function Zo(i,t){if(t.scale==1)return i;let e=t.toDOM(i.top),n=t.toDOM(i.bottom);return new li(i.from,i.length,e,n-e,Array.isArray(i._content)?i._content.map(r=>Zo(r,t)):i._content)}const Gl=V.define({combine:i=>i.join(" ")}),Qu=V.define({combine:i=>i.indexOf(!0)>-1}),$u=Xn.newName(),qb=Xn.newName(),Nb=Xn.newName(),Gb={"&light":"."+qb,"&dark":"."+Nb};function Cu(i,t,e){return new Xn(t,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return i;if(!e||!e[r])throw new RangeError(`Unsupported selector: ${r}`);return e[r]}):i+" "+n}})}const tk=Cu("."+$u,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Gb),ek={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},dh=M.ie&&M.ie_version<=11;class ik{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new Zx,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let n of e)this.queue.push(n);(M.ie&&M.ie_version<=11||M.ios&&t.composing)&&e.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&M.android&&t.constructor.EDIT_CONTEXT!==!1&&!(M.chrome&&M.chrome_version<126)&&(this.editContext=new rk(t),t.state.facet(Ji)&&(t.contentDOM.editContext=this.editContext.editContext)),dh&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var e;((e=this.view.docView)===null||e===void 0?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,n)=>e!=t[n]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Ji)?n.root.activeElement!=this.dom:!Io(this.dom,r))return;let s=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(M.ie&&M.ie_version<=11||M.android&&M.chrome)&&!n.state.selection.main.empty&&r.focusNode&&jo(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Fo(t.root);if(!e)return!1;let n=M.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&nk(this.view,e)||e;if(!n||this.selectionRange.eq(n))return!1;let r=Io(this.dom,n);return r&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&Ex(this.dom,n)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let n=this.dom;n;)if(n.nodeType==1)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==n?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=e)n.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,ek),dh&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),dh&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var n;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ir(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,n=-1,r=!1;for(let s of t){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),e==-1?{from:e,to:n}=o:(e=Math.min(o.from,e),n=Math.max(o.to,n)))}return{from:e,to:n,typeOver:r}}readChange(){let{from:t,to:e,typeOver:n}=this.processRecords(),r=this.selectionChanged&&Io(this.dom,this.selectionRange);if(t<0&&!r)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new vy(this.view,t,e,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let n=this.view.state,r=Lb(this.view,e);return this.view.state==n&&(e.domChanged||e.newSel&&!Ia(this.view.state.selection,e.newSel.main))&&this.view.update([]),r}readMutation(t){let e=this.view.docView.tile.nearest(t.target);if(!e||e.isWidget())return null;if(e.markDirty(t.type=="attributes"),t.type=="childList"){let n=DO(e,t.previousSibling||t.target.previousSibling,-1),r=DO(e,t.nextSibling||t.target.nextSibling,1);return{from:n?e.posAfter(n):e.posAtStart,to:r?e.posBefore(r):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Ji)!=t.state.facet(Ji)&&(t.view.contentDOM.editContext=t.state.facet(Ji)?this.editContext.editContext:null))}destroy(){var t,e,n;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function DO(i,t,e){for(;t;){let n=zt.get(t);if(n&&n.parent==i)return n;let r=t.parentNode;t=r!=i.dom?r:e>0?t.nextSibling:t.previousSibling}return null}function VO(i,t){let e=t.startContainer,n=t.startOffset,r=t.endContainer,s=t.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor,1);return jo(o.node,o.offset,r,s)&&([e,n,r,s]=[r,s,e,n]),{anchorNode:e,anchorOffset:n,focusNode:r,focusOffset:s}}function nk(i,t){if(t.getComposedRanges){let r=t.getComposedRanges(i.root)[0];if(r)return VO(i,r)}let e=null;function n(r){r.preventDefault(),r.stopImmediatePropagation(),e=r.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),e?VO(i,e):null}class rk{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=n=>{let r=t.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:l,drifted:!1});let c=a-l>n.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let h=Mb(t.state.sliceDoc(l,a),n.text,(c?r.from:r.to)-l,c?"end":null);if(!h){let f=C.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));Ia(f,r)||t.dispatch({selection:f,userEvent:"select"});return}let u={from:h.from+l,to:h.toA+l,insert:Y.of(n.text.slice(h.from,h.toB).split(`
38
+ `))};if((M.mac||M.android)&&u.from==o-1&&/^\. ?$/.test(n.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:l,to:a,insert:Y.of([n.text.replace("."," ")])}),this.pendingContextChange=u,!t.state.readOnly){let f=this.to-this.from+(u.to-u.from+u.insert.length);zf(t,u,C.single(this.toEditorPos(n.selectionStart,f),this.toEditorPos(n.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),u.from<u.to&&!u.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(e.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],s=null;for(let o=this.toEditorPos(n.rangeStart),l=this.toEditorPos(n.rangeEnd);o<l;o++){let a=t.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}e.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=n=>{let r=[];for(let s of n.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(a<c){let h=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(J.mark({attributes:{style:h}}).range(a,c))}}}t.dispatch({effects:$b.of(J.set(r))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(t.state)}};for(let n in this.handlers)e.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let r=Fo(n.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,n=!1,r=this.pendingContextChange;return t.changes.iterChanges((s,o,l,a,c)=>{if(n)return;let h=c.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(c)){r=this.pendingContextChange=null,e+=h,this.to+=h;return}else r=null,this.revertPending(t.state);if(s+=e,o+=e,o<=this.from)this.from+=h,this.to+=h;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),c.toString()),this.to+=h}e+=h}),r&&!n&&this.revertPending(t.state),!n}update(t){let e=this.pendingContextChange,n=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(n.from,n.to)&&t.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),r=this.toContextPos(e.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let n=this.composing;return n&&n.drifted?n.editorBase+(t-n.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class z{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:n}=t;this.dispatchTransactions=t.dispatchTransactions||n&&(r=>r.forEach(s=>n(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=t.root||Xx(t.parent)||document,this.viewState=new _O(this,t.state||K.create(t)),t.scrollTo&&t.scrollTo.is(Vl)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Xr).map(r=>new lh(r));for(let r of this.plugins)r.update(this);this.observer=new ik(this),this.inputState=new Qy(this),this.inputState.ensureHandlers(this.plugins),this.docView=new QO(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((e=document.fonts)===null||e===void 0)&&e.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let e=t.length==1&&t[0]instanceof Pt?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,n=!1,r,s=this.state;for(let f of t){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;t.some(f=>f.annotation(Vb))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Bb(s,o),a||(l=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(K.phrases)!=this.state.facet(K.phrases))return this.setState(s);r=Ma.create(this,s,t),r.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let f of t){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection,{x:O,y:p}=this.state.facet(z.cursorScrollMargin);u=new jr(d.empty?d:C.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",p,O)}for(let d of f.effects)d.is(Vl)&&(u=d.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=Da.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),e=this.docView.update(r),this.state.facet(Ro)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Gl)!=r.state.facet(Gl)&&(this.viewState.mustMeasureContent=!0),(e||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Su))try{f(r)}catch(d){Li(this.state,d,"update listener")}(a||h)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!Lb(this,h)&&c.force&&Ir(this.contentDOM,c.key,c.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new _O(this,t),this.plugins=t.facet(Xr).map(n=>new lh(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new QO(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Xr),n=t.state.facet(Xr);if(e!=n){let r=[];for(let s of n){let o=e.indexOf(s);if(o<0)r.push(new lh(s));else{let l=this.plugins[o];l.mustUpdate=t,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=t&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=t;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);e!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(n){Li(this.state,n,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(cb(n||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let h=c.map(d=>{try{return d.read(this)}catch(O){return Li(this.state,O),BO}}),u=Ma.create(this,this.state,[]),f=!1;u.flags|=a,e?e.flags|=a:e=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u),f&&this.docViewUpdate());for(let d=0;d<c.length;d++)if(h[d]!=BO)try{let O=c[d];O.write&&O.write(h[d],this)}catch(O){Li(this.state,O)}if(f&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let O=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o)/this.scaleY;if((O>1||O<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+O,n?n.scrollTop+=O:this.win.scrollBy(0,O),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let l of this.state.facet(Su))l(e)}get themeClasses(){return $u+" "+(this.state.facet(Qu)?Nb:qb)+" "+this.state.facet(Gl)}updateAttrs(){let t=WO(this,Cb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ji)?"true":"false",class:"cm-content",style:`${M.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),WO(this,Ef,e);let n=this.observer.ignore(()=>{let r=wO(this.contentDOM,this.contentAttrs,e),s=wO(this.dom,this.editorAttrs,t);return r||s});return this.editorAttrs=t,this.contentAttrs=e,n}showAnnouncements(t){let e=!0;for(let n of t)for(let r of n.effects)if(r.is(z.announce)){e&&(this.announceDOM.textContent=""),e=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Ro);let t=this.state.facet(z.cspNonce);Xn.mount(this.root,this.styleModules.concat(tk).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(e===void 0||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(n=>n.plugin==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,n){return uh(this,t,$O(this,t,e,n))}moveByGroup(t,e){return uh(this,t,$O(this,t,e,n=>py(this,t.head,n)))}visualLineSide(t,e){let n=this.bidiSpans(t),r=this.textDirectionAt(t.from),s=n[e?n.length-1:0];return C.cursor(s.side(e,r)+t.from,s.forward(!e,r)?1:-1)}moveToLineBoundary(t,e,n=!0){return Oy(this,t,e,n)}moveVertically(t,e,n){return uh(this,t,my(this,t,e,n))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let n=yu(this,t,e);return n&&n.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),yu(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let n=this.docView.coordsAt(t,e);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(t),s=this.bidiSpans(r),o=s[Ei.find(s,t-r.from,-1,e)];return La(n,o.dir==Tt.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(yb)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>sk)return pb(t.length);let e=this.textDirectionAt(t.from),n;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==e&&(s.fresh||Ob(s.isolates,n=xO(this,t))))return s.order;n||(n=xO(this,t));let r=Dx(t.text,e,n);return this.bidiCache.push(new Da(t.from,t.to,e,n,!0,r)),r}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||M.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ab(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){var n,r,s,o;return Vl.of(new jr(typeof t=="number"?C.cursor(t):t,(n=e.y)!==null&&n!==void 0?n:"nearest",(r=e.x)!==null&&r!==void 0?r:"nearest",(s=e.yMargin)!==null&&s!==void 0?s:5,(o=e.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,n=this.viewState.scrollAnchorAt(t);return Vl.of(new jr(C.cursor(n.from),"start","start",n.top-t,e,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return ui.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return ui.define(()=>({}),{eventObservers:t})}static theme(t,e){let n=Xn.newName(),r=[Gl.of(n),Ro.of(Cu(`.${n}`,t))];return e&&e.dark&&r.push(Qu.of(!0)),r}static baseTheme(t){return hn.lowest(Ro.of(Cu("."+$u,t,Gb)))}static findFromDOM(t){var e;let n=t.querySelector(".cm-content"),r=n&&zt.get(n)||zt.get(t);return((e=r==null?void 0:r.root)===null||e===void 0?void 0:e.view)||null}}z.styleModule=Ro;z.inputHandler=vb;z.clipboardInputFilter=Zf;z.clipboardOutputFilter=Xf;z.scrollHandler=Qb;z.focusChangeEffect=xb;z.perLineTextDirection=yb;z.exceptionSink=Sb;z.updateListener=Su;z.editable=Ji;z.mouseSelectionStyle=wb;z.dragMovesSelection=bb;z.clickAddsSelectionRange=gb;z.decorations=Qc;z.blockWrappers=Pb;z.outerDecorations=Lf;z.atomicRanges=kl;z.bidiIsolatedRanges=Tb;z.cursorScrollMargin=V.define({combine:i=>{let t=5,e=5;for(let n of i)typeof n=="number"?t=e=n:{x:t,y:e}=n;return{x:t,y:e}}});z.scrollMargins=Ab;z.darkTheme=Qu;z.cspNonce=V.define({combine:i=>i.length?i[0]:""});z.contentAttributes=Ef;z.editorAttributes=Cb;z.lineWrapping=z.contentAttributes.of({class:"cm-lineWrapping"});z.announce=Ct.define();const sk=4096,BO={};class Da{constructor(t,e,n,r,s,o){this.from=t,this.to=e,this.dir=n,this.isolates=r,this.fresh=s,this.order=o}static update(t,e){if(e.empty&&!t.some(s=>s.fresh))return t;let n=[],r=t.length?t[t.length-1].dir:Tt.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let o=t[s];o.dir==r&&!e.touchesRange(o.from,o.to)&&n.push(new Da(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function WO(i,t,e){for(let n=i.state.facet(t),r=n.length-1;r>=0;r--){let s=n[r],o=typeof s=="function"?s(i):s;o&&Tf(o,e)}return e}const ok=M.mac?"mac":M.windows?"win":M.linux?"linux":"key";function lk(i,t){const e=i.split(/-(?!$)/);let n=e[e.length-1];n=="Space"&&(n=" ");let r,s,o,l;for(let a=0;a<e.length-1;++a){const c=e[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))t=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Ul(i,t,e){return t.altKey&&(i="Alt-"+i),t.ctrlKey&&(i="Ctrl-"+i),t.metaKey&&(i="Meta-"+i),e!==!1&&t.shiftKey&&(i="Shift-"+i),i}const ak=hn.default(z.domEventHandlers({keydown(i,t){return Hb(Ub(t.state),i,t,"editor")}})),Dn=V.define({enables:ak}),YO=new WeakMap;function Ub(i){let t=i.facet(Dn),e=YO.get(t);return e||YO.set(t,e=uk(t.reduce((n,r)=>n.concat(r),[]))),e}function ck(i,t,e){return Hb(Ub(i.state),t,i,e)}let Sn=null;const hk=4e3;function uk(i,t=ok){let e=Object.create(null),n=Object.create(null),r=(o,l)=>{let a=n[o];if(a==null)n[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,c,h)=>{var u,f;let d=e[o]||(e[o]=Object.create(null)),O=l.split(/ (?!$)/).map(g=>lk(g,t));for(let g=1;g<O.length;g++){let b=O.slice(0,g).join(" ");r(b,!0),d[b]||(d[b]={preventDefault:!0,stopPropagation:!1,run:[S=>{let x=Sn={view:S,prefix:b,scope:o};return setTimeout(()=>{Sn==x&&(Sn=null)},hk),!0}]})}let p=O.join(" ");r(p,!1);let m=d[p]||(d[p]={preventDefault:!1,stopPropagation:!1,run:((f=(u=d._any)===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.slice())||[]});a&&m.run.push(a),c&&(m.preventDefault=!0),h&&(m.stopPropagation=!0)};for(let o of i){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of l){let h=e[c]||(e[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=o;for(let f in h)h[f].run.push(d=>u(d,Pu))}let a=o[t]||o.key;if(a)for(let c of l)s(c,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return e}let Pu=null;function Hb(i,t,e,n){Pu=t;let r=$x(t),s=ax(r,0),o=cx(s)==r.length&&r!=" ",l="",a=!1,c=!1,h=!1;Sn&&Sn.view==e&&Sn.scope==n&&(l=Sn.prefix+" ",_b.indexOf(t.keyCode)<0&&(c=!0,Sn=null));let u=new Set,f=m=>{if(m){for(let g of m.run)if(!u.has(g)&&(u.add(g),g(e)))return m.stopPropagation&&(h=!0),!0;m.preventDefault&&(m.stopPropagation&&(h=!0),c=!0)}return!1},d=i[n],O,p;return d&&(f(d[l+Ul(r,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(M.windows&&t.ctrlKey&&t.altKey)&&!(M.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(O=En[t.keyCode])&&O!=r?(f(d[l+Ul(O,t,!0)])||t.shiftKey&&(p=Uo[t.keyCode])!=r&&p!=O&&f(d[l+Ul(p,t,!1)]))&&(a=!0):o&&t.shiftKey&&f(d[l+Ul(r,t,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),c&&(a=!0),a&&h&&t.stopPropagation(),Pu=null,a}class Or{constructor(t,e,n,r,s){this.className=t,this.left=e,this.top=n,this.width=r,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,n){if(n.empty){let r=t.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=Fb(t);return[new Or(e,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return fk(t,e,n)}}function Fb(i){let t=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==Tt.LTR?t.left:t.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:t.top-i.scrollDOM.scrollTop*i.scaleY}}function qO(i,t,e,n){let r=i.coordsAtPos(t,e*2);if(!r)return n;let s=i.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=i.posAtCoords({x:s.left+1,y:o}),a=i.posAtCoords({x:s.right-1,y:o});return l==null||a==null?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}function fk(i,t,e){if(e.to<=i.viewport.from||e.from>=i.viewport.to)return[];let n=Math.max(e.from,i.viewport.from),r=Math.min(e.to,i.viewport.to),s=i.textDirection==Tt.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=Fb(i),c=o.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=l.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),f=l.right-(h?parseInt(h.paddingRight):0),d=xu(i,n,1),O=xu(i,r,-1),p=d.type==pe.Text?d:null,m=O.type==pe.Text?O:null;if(p&&(i.lineWrapping||d.widgetLineBreaks)&&(p=qO(i,n,1,p)),m&&(i.lineWrapping||O.widgetLineBreaks)&&(m=qO(i,r,-1,m)),p&&m&&p.from==m.from&&p.to==m.to)return b(S(e.from,e.to,p));{let y=p?S(e.from,null,p):x(d,!1),k=m?S(null,e.to,m):x(O,!0),Q=[];return(p||d).to<(m||O).from-(p&&m?1:0)||d.widgetLineBreaks>1&&y.bottom+i.defaultLineHeight/2<k.top?Q.push(g(u,y.bottom,f,k.top)):y.bottom<k.top&&i.elementAtHeight((y.bottom+k.top)/2).type==pe.Text&&(y.bottom=k.top=(y.bottom+k.top)/2),b(y).concat(Q).concat(b(k))}function g(y,k,Q,Z){return new Or(t,y-a.left,k-a.top,Math.max(0,Q-y),Z-k)}function b({top:y,bottom:k,horizontal:Q}){let Z=[];for(let D=0;D<Q.length;D+=2)Z.push(g(Q[D],y,Q[D+1],k));return Z}function S(y,k,Q){let Z=1e9,D=-1e9,L=[];function B(U,H,Xt,_t,Yt){let lt=i.coordsAtPos(U,U==Q.to?-2:2),Vt=i.coordsAtPos(Xt,Xt==Q.from?2:-2);!lt||!Vt||(Z=Math.min(lt.top,Vt.top,Z),D=Math.max(lt.bottom,Vt.bottom,D),Yt==Tt.LTR?L.push(s&&H?u:lt.left,s&&_t?f:Vt.right):L.push(!s&&_t?u:Vt.left,!s&&H?f:lt.right))}let _=y??Q.from,G=k??Q.to;for(let U of i.visibleRanges)if(U.to>_&&U.from<G)for(let H=Math.max(U.from,_),Xt=Math.min(U.to,G);;){let _t=i.state.doc.lineAt(H);for(let Yt of i.bidiSpans(_t)){let lt=Yt.from+_t.from,Vt=Yt.to+_t.from;if(lt>=Xt)break;Vt>H&&B(Math.max(lt,H),y==null&&lt<=_,Math.min(Vt,Xt),k==null&&Vt>=G,Yt.dir)}if(H=_t.to+1,H>=Xt)break}return L.length==0&&B(_,y==null,G,k==null,i.textDirection),{top:Z,bottom:D,horizontal:L}}function x(y,k){let Q=l.top+(k?y.top:y.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function dk(i,t){return i.constructor==t.constructor&&i.eq(t)}class Ok{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(wa)!=t.state.facet(wa)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,n=t.facet(wa);for(;e<n.length&&n[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;(t!=this.scaleX||e!=this.scaleY)&&(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some((e,n)=>!dk(e,this.drawn[n]))){let e=this.dom.firstChild,n=0;for(let r of t)r.update&&e&&r.constructor&&this.drawn[n].constructor&&r.update(e,this.drawn[n])?(e=e.nextSibling,n++):this.dom.insertBefore(r.draw(),e);for(;e;){let r=e.nextSibling;e.remove(),e=r}this.drawn=t,M.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const wa=V.define();function Kb(i){return[ui.define(t=>new Ok(t,i)),wa.of(i)]}const Gs=V.define({combine(i){return eb(i,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});function pk(i={}){return[Gs.of(i),mk,gk,bk,kb.of(!0)]}function Jb(i){return i.startState.facet(Gs)!=i.state.facet(Gs)}const mk=Kb({above:!0,markers(i){let{state:t}=i,e=t.facet(Gs),n=[];for(let r of t.selection.ranges){let s=r==t.selection.main;if(r.empty||e.drawRangeCursor&&!(s&&M.ios&&e.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:C.cursor(r.head,r.assoc);for(let a of Or.forRange(i,o,l))n.push(a)}}return n},update(i,t){i.transactions.some(n=>n.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let e=Jb(i);return e&&NO(i.state,t),i.docChanged||i.selectionSet||e},mount(i,t){NO(t.state,i)},class:"cm-cursorLayer"});function NO(i,t){t.style.animationDuration=i.facet(Gs).cursorBlinkRate+"ms"}const gk=Kb({above:!1,markers(i){let t=[],{main:e,ranges:n}=i.state.selection;for(let r of n)if(!r.empty)for(let s of Or.forRange(i,"cm-selectionBackground",r))t.push(s);if(M.ios&&!e.empty&&i.state.facet(Gs).iosSelectionHandles){for(let r of Or.forRange(i,"cm-selectionHandle cm-selectionHandle-start",C.cursor(e.from,1)))t.push(r);for(let r of Or.forRange(i,"cm-selectionHandle cm-selectionHandle-end",C.cursor(e.to,1)))t.push(r)}return t},update(i,t){return i.docChanged||i.selectionSet||i.viewportChanged||Jb(i)},class:"cm-selectionLayer"}),bk=hn.highest(z.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Hl="-10000px";class wk{constructor(t,e,n,r){this.facet=e,this.createTooltipView=n,this.removeTooltipView=r,this.input=t.state.facet(e),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=n(o,s))}update(t,e){var n;let r=t.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(t);return!1}let o=[],l=e?[]:null;for(let a=0;a<s.length;a++){let c=s[a],h=-1;if(c){for(let u=0;u<this.tooltips.length;u++){let f=this.tooltips[u];f&&f.create==c.create&&(h=u)}if(h<0)o[a]=this.createTooltipView(c,a?o[a-1]:null),l&&(l[a]=!!c.above);else{let u=o[a]=this.tooltipViews[h];l&&(l[a]=e[h]),u.update&&u.update(t)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(n=a.destroy)===null||n===void 0||n.call(a));return e&&(l.forEach((a,c)=>e[c]=a),e.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function Sk(i){let t=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Oh=V.define({combine:i=>{var t,e,n;return{position:M.ios?"absolute":((t=i.find(r=>r.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((e=i.find(r=>r.parent))===null||e===void 0?void 0:e.parent)||null,tooltipSpace:((n=i.find(r=>r.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||Sk}}}),GO=new WeakMap,t0=ui.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=i.state.facet(Oh);this.position=t.position,this.parent=t.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new wk(i,e0,(e,n)=>this.createTooltip(e,n),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(i,this.above);t&&this.observeIntersection();let e=t||i.geometryChanged,n=i.state.facet(Oh);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;e=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);e=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);e&&this.maybeMeasure()}createTooltip(i,t){let e=i.create(this.view),n=t?t.dom:null;if(e.dom.classList.add("cm-tooltip"),i.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",e.dom.appendChild(r)}return e.dom.style.position=this.position,e.dom.style.top=Hl,e.dom.style.left="0px",this.container.insertBefore(e.dom,n),e.mount&&e.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(e.dom),e}destroy(){var i,t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,t=1,e=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(M.safari){let o=s.getBoundingClientRect();e=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else e=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(e||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(i=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:t}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),r=Mf(this.view);return{visible:{left:n.left+r.left,top:n.top+r.top,right:n.right-r.right,bottom:n.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Oh).tooltipSpace(this.view),scaleX:i,scaleY:t,makeAbsolute:e}}writeMeasure(i){var t;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:e,space:n,scaleX:r,scaleY:s}=i,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],c=this.manager.tooltipViews[l],{dom:h}=c,u=i.pos[l],f=i.size[l];if(!u||a.clip!==!1&&(u.bottom<=Math.max(e.top,n.top)||u.top>=Math.min(e.bottom,n.bottom)||u.right<Math.max(e.left,n.left)-.1||u.left>Math.min(e.right,n.right)+.1)){h.style.top=Hl;continue}let d=a.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,O=d?7:0,p=f.right-f.left,m=(t=GO.get(c))!==null&&t!==void 0?t:f.bottom-f.top,g=c.offset||xk,b=this.view.textDirection==Tt.LTR,S=f.width>n.right-n.left?b?n.left:n.right-f.width:b?Math.max(n.left,Math.min(u.left-(d?14:0)+g.x,n.right-p)):Math.min(Math.max(n.left,u.left-p+(d?14:0)-g.x),n.right-p),x=this.above[l];!a.strictSide&&(x?u.top-m-O-g.y<n.top:u.bottom+m+O+g.y>n.bottom)&&x==n.bottom-u.bottom>u.top-n.top&&(x=this.above[l]=!x);let y=(x?u.top-n.top:n.bottom-u.bottom)-O;if(y<m&&c.resize!==!1){if(y<this.view.defaultLineHeight){h.style.top=Hl;continue}GO.set(c,m),h.style.height=(m=y)/s+"px"}else h.style.height&&(h.style.height="");let k=x?u.top-m-O-g.y:u.bottom+O+g.y,Q=S+p;if(c.overlap!==!0)for(let Z of o)Z.left<Q&&Z.right>S&&Z.top<k+m&&Z.bottom>k&&(k=x?Z.top-m-2-O:Z.bottom+O+2);if(this.position=="absolute"?(h.style.top=(k-i.parent.top)/s+"px",UO(h,(S-i.parent.left)/r)):(h.style.top=k/s+"px",UO(h,S/r)),d){let Z=u.left+(b?g.x:-g.x)-(S+14-7);d.style.left=Z/r+"px"}c.overlap!==!0&&o.push({left:S,top:k,right:Q,bottom:k+m}),h.classList.toggle("cm-tooltip-above",x),h.classList.toggle("cm-tooltip-below",!x),c.positioned&&c.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=Hl}},{eventObservers:{scroll(){this.maybeMeasure()}}});function UO(i,t){let e=parseInt(i.style.left,10);(isNaN(e)||Math.abs(t-e)>1)&&(i.style.left=t+"px")}const vk=z.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),xk={x:0,y:0},e0=V.define({enables:[t0,vk]});function yk(i,t){let e=i.plugin(t0);if(!e)return null;let n=e.manager.tooltips.indexOf(t);return n<0?null:e.manager.tooltipViews[n]}class Us extends Zn{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Us.prototype.elementClass="";Us.prototype.toDOM=void 0;Us.prototype.mapMode=Oe.TrackBefore;Us.prototype.startSide=Us.prototype.endSide=-1;Us.prototype.point=!0;const i0=1024;let kk=0;class qe{constructor(t,e){this.from=t,this.to=e}}class N{constructor(t={}){this.id=kk++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=qt.match(t)),e=>{let n=t(e);return n===void 0?null:[this,n]}}}N.closedBy=new N({deserialize:i=>i.split(" ")});N.openedBy=new N({deserialize:i=>i.split(" ")});N.group=new N({deserialize:i=>i.split(" ")});N.isolate=new N({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});N.contextHash=new N({perNode:!0});N.lookAhead=new N({perNode:!0});N.mounted=new N({perNode:!0});class Dr{constructor(t,e,n,r=!1){this.tree=t,this.overlay=e,this.parser=n,this.bracketed=r}static get(t){return t&&t.props&&t.props[N.mounted.id]}}const Qk=Object.create(null);class qt{constructor(t,e,n,r=0){this.name=t,this.props=e,this.id=n,this.flags=r}static define(t){let e=t.props&&t.props.length?Object.create(null):Qk,n=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),r=new qt(t.name||"",e,t.id,n);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[s[0].id]=s[1]}}return r}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(N.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let n in t)for(let r of n.split(" "))e[r]=t[n];return n=>{for(let r=n.prop(N.group),s=-1;s<(r?r.length:0);s++){let o=e[s<0?n.name:r[s]];if(o)return o}}}}qt.none=new qt("",Object.create(null),0,8);class Ql{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let n of this.types){let r=null;for(let s of t){let o=s(n);if(o){r||(r=Object.assign({},n.props));let l=o[1],a=o[0];a.combine&&a.id in r&&(l=a.combine(r[a.id],l)),r[a.id]=l}}e.push(r?new qt(n.name,r,n.id,n.flags):n)}return new Ql(e)}}const Fl=new WeakMap,HO=new WeakMap;var ft;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays",i[i.EnterBracketed=16]="EnterBracketed"})(ft||(ft={}));class ht{constructor(t,e,n,r,s){if(this.type=t,this.children=e,this.positions=n,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let t=Dr.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let n of this.children){let r=n.toString();r&&(e&&(e+=","),e+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new Va(this.topNode,t)}cursorAt(t,e=0,n=0){let r=Fl.get(this)||this.topNode,s=new Va(r);return s.moveTo(t,e),Fl.set(this,s._tree),s}get topNode(){return new he(this,0,0,null)}resolve(t,e=0){let n=Jo(Fl.get(this)||this.topNode,t,e,!1);return Fl.set(this,n),n}resolveInner(t,e=0){let n=Jo(HO.get(this)||this.topNode,t,e,!0);return HO.set(this,n),n}resolveStack(t,e=0){return Pk(this,t,e)}iterate(t){let{enter:e,leave:n,from:r=0,to:s=this.length}=t,o=t.mode||0,l=(o&ft.IncludeAnonymous)>0;for(let a=this.cursor(o|ft.IncludeAnonymous);;){let c=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||e(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;c=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:Vf(qt.none,this.children,this.positions,0,this.children.length,0,this.length,(e,n,r)=>new ht(this.type,e,n,r,this.propValues),t.makeTree||((e,n,r)=>new ht(qt.none,e,n,r)))}static build(t){return Tk(t)}}ht.empty=new ht(qt.none,[],[],0);class jf{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new jf(this.buffer,this.index)}}class Mn{constructor(t,e,n){this.buffer=t,this.length=e,this.set=n}get type(){return qt.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],n=this.buffer[t+3],r=this.set.types[e],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),t+=4,n==t)return s;let o=[];for(;t<n;)o.push(this.childString(t)),t=this.buffer[t+3];return s+"("+o.join(",")+")"}findChild(t,e,n,r,s){let{buffer:o}=this,l=-1;for(let a=t;a!=e&&!(n0(s,r,o[a+1],o[a+2])&&(l=a,n>0));a=o[a+3]);return l}slice(t,e,n){let r=this.buffer,s=new Uint16Array(e-t),o=0;for(let l=t,a=0;l<e;){s[a++]=r[l++],s[a++]=r[l++]-n;let c=s[a++]=r[l++]-n;s[a++]=r[l++]-t,o=Math.max(o,c)}return new Mn(s,o,this.set)}}function n0(i,t,e,n){switch(i){case-2:return e<t;case-1:return n>=t&&e<t;case 0:return e<t&&n>t;case 1:return e<=t&&n>t;case 2:return n>t;case 4:return!0}}function Jo(i,t,e,n){for(var r;i.from==i.to||(e<1?i.from>=t:i.from>t)||(e>-1?i.to<=t:i.to<t);){let o=!n&&i instanceof he&&i.index<0?null:i.parent;if(!o)return i;i=o}let s=n?0:ft.IgnoreOverlays;if(n)for(let o=i,l=o.parent;l;o=l,l=o.parent)o instanceof he&&o.index<0&&((r=l.enter(t,e,s))===null||r===void 0?void 0:r.from)!=o.from&&(i=l);for(;;){let o=i.enter(t,e,s);if(!o)return i;i=o}}class r0{cursor(t=0){return new Va(this,t)}getChild(t,e=null,n=null){let r=FO(this,t,e,n);return r.length?r[0]:null}getChildren(t,e=null,n=null){return FO(this,t,e,n)}resolve(t,e=0){return Jo(this,t,e,!1)}resolveInner(t,e=0){return Jo(this,t,e,!0)}matchContext(t){return Tu(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),n=this;for(;e;){let r=e.lastChild;if(!r||r.to!=e.to)break;r.type.isError&&r.from==r.to?(n=e,e=r.prevSibling):e=r}return n}get node(){return this}get next(){return this.parent}}class he extends r0{constructor(t,e,n,r){super(),this._tree=t,this.from=e,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,n,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,c=e>0?l.length:-1;t!=c;t+=e){let h=l[t],u=a[t]+o.from,f;if(!(!(s&ft.EnterBracketed&&h instanceof ht&&(f=Dr.get(h))&&!f.overlay&&f.bracketed&&n>=u&&n<=u+h.length)&&!n0(r,n,u,u+h.length))){if(h instanceof Mn){if(s&ft.ExcludeBuffers)continue;let d=h.findChild(0,h.buffer.length,e,n-u,r);if(d>-1)return new Mi(new $k(o,h,t,u),null,d)}else if(s&ft.IncludeAnonymous||!h.type.isAnonymous||Df(h)){let d;if(!(s&ft.IgnoreMounts)&&(d=Dr.get(h))&&!d.overlay)return new he(d.tree,u,t,o);let O=new he(h,u,t,o);return s&ft.IncludeAnonymous||!O.type.isAnonymous?O:O.nextChild(e<0?h.children.length-1:0,e,n,r,s)}}}if(s&ft.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,n=0){let r;if(!(n&ft.IgnoreOverlays)&&(r=Dr.get(this._tree))&&r.overlay){let s=t-this.from,o=n&ft.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((e>0||o?l<=s:l<s)&&(e<0||o?a>=s:a>s))return new he(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function FO(i,t,e,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(e!=null){for(let o=!1;!o;)if(o=r.type.is(e),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(t)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function Tu(i,t,e=t.length-1){for(let n=i;e>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[e]&&t[e]!=n.name)return!1;e--}}return!0}class $k{constructor(t,e,n,r){this.parent=t,this.buffer=e,this.index=n,this.start=r}}class Mi extends r0{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,n){super(),this.context=t,this._parent=e,this.index=n,this.type=t.buffer.set.types[t.buffer.buffer[n]]}child(t,e,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.context.start,n);return s<0?null:new Mi(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,n=0){if(n&ft.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new Mi(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Mi(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new Mi(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];t.push(n.slice(r,s,o)),e.push(0)}return new ht(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function s0(i){if(!i.length)return null;let t=0,e=i[0];for(let s=1;s<i.length;s++){let o=i[s];(o.from>e.from||o.to<e.to)&&(e=o,t=s)}let n=e instanceof he&&e.index<0?null:e.parent,r=i.slice();return n?r[t]=n:r.splice(t,1),new Ck(r,e)}class Ck{constructor(t,e){this.heads=t,this.node=e}get next(){return s0(this.heads)}}function Pk(i,t,e){let n=i.resolveInner(t,e),r=null;for(let s=n instanceof he?n:n.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[n])).push(o.resolve(t,e)),s=o}else{let o=Dr.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let l=new he(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(Jo(l,t,e,!1))}}return r?s0(r):n}class Va{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~ft.EnterBracketed,t instanceof he)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let n=t._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:n,buffer:r}=this.buffer;return this.type=e||r.set.types[r.buffer[t]],this.from=n+r.buffer[t+1],this.to=n+r.buffer[t+2],!0}yield(t){return t?t instanceof he?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,n){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],t,e-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,n=this.mode){return this.buffer?n&ft.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ft.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&ft.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,n=this.stack.length-1;if(t<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(e.findChild(r,this.index,-1,0,4))}else{let r=e.buffer[this.index+3];if(r<(n<0?e.buffer.length:e.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,n,{buffer:r}=this;if(r){if(t>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:e,parent:n}=r)}else({index:e,_parent:n}=this._tree);for(;n;{index:e,_parent:n}=n)if(e>-1)for(let s=e+t,o=t<0?-1:n._tree.children.length;s!=o;s+=t){let l=n._tree.children[s];if(this.mode&ft.IncludeAnonymous||l instanceof Mn||!l.type.isAnonymous||Df(l))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,n=0;if(t&&t.context==this.buffer)t:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=t;o;o=o._parent)if(o.index==r){if(r==this.index)return o;e=o,n=s+1;break t}r=this.stack[--s]}for(let r=n;r<this.stack.length;r++)e=new Mi(this.buffer,e,this.stack[r]);return this.bufferNode=new Mi(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let n=0;;){let r=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&e&&e(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(t){if(!this.buffer)return Tu(this.node.parent,t);let{buffer:e}=this.buffer,{types:n}=e.set;for(let r=t.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return Tu(this._tree,t,r);let o=n[e.buffer[this.stack[s]]];if(!o.isAnonymous){if(t[r]&&t[r]!=o.name)return!1;r--}}return!0}}function Df(i){return i.children.some(t=>t instanceof Mn||!t.type.isAnonymous||Df(t))}function Tk(i){var t;let{buffer:e,nodeSet:n,maxBufferLength:r=i0,reused:s=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(e)?new jf(e,e.length):e,a=n.types,c=0,h=0;function u(y,k,Q,Z,D,L){let{id:B,start:_,end:G,size:U}=l,H=h,Xt=c;if(U<0)if(l.next(),U==-1){let $e=s[B];Q.push($e),Z.push(_-y);return}else if(U==-3){c=B;return}else if(U==-4){h=B;return}else throw new RangeError(`Unrecognized record size: ${U}`);let _t=a[B],Yt,lt,Vt=_-y;if(G-_<=r&&(lt=m(l.pos-k,D))){let $e=new Uint16Array(lt.size-lt.skip),yt=l.pos-lt.size,Nt=$e.length;for(;l.pos>yt;)Nt=g(lt.start,$e,Nt);Yt=new Mn($e,G-lt.start,n),Vt=lt.start-y}else{let $e=l.pos-U;l.next();let yt=[],Nt=[],re=B>=o?B:-1,be=0,tt=G;for(;l.pos>$e;)re>=0&&l.id==re&&l.size>=0?(l.end<=tt-r&&(O(yt,Nt,_,be,l.end,tt,re,H,Xt),be=yt.length,tt=l.end),l.next()):L>2500?f(_,$e,yt,Nt):u(_,$e,yt,Nt,re,L+1);if(re>=0&&be>0&&be<yt.length&&O(yt,Nt,_,be,_,tt,re,H,Xt),yt.reverse(),Nt.reverse(),re>-1&&be>0){let pt=d(_t,Xt);Yt=Vf(_t,yt,Nt,0,yt.length,0,G-_,pt,pt)}else Yt=p(_t,yt,Nt,G-_,H-G,Xt)}Q.push(Yt),Z.push(Vt)}function f(y,k,Q,Z){let D=[],L=0,B=-1;for(;l.pos>k;){let{id:_,start:G,end:U,size:H}=l;if(H>4)l.next();else{if(B>-1&&G<B)break;B<0&&(B=U-r),D.push(_,G,U),L++,l.next()}}if(L){let _=new Uint16Array(L*4),G=D[D.length-2];for(let U=D.length-3,H=0;U>=0;U-=3)_[H++]=D[U],_[H++]=D[U+1]-G,_[H++]=D[U+2]-G,_[H++]=H;Q.push(new Mn(_,D[2]-G,n)),Z.push(G-y)}}function d(y,k){return(Q,Z,D)=>{let L=0,B=Q.length-1,_,G;if(B>=0&&(_=Q[B])instanceof ht){if(!B&&_.type==y&&_.length==D)return _;(G=_.prop(N.lookAhead))&&(L=Z[B]+_.length+G)}return p(y,Q,Z,D,L,k)}}function O(y,k,Q,Z,D,L,B,_,G){let U=[],H=[];for(;y.length>Z;)U.push(y.pop()),H.push(k.pop()+Q-D);y.push(p(n.types[B],U,H,L-D,_-L,G)),k.push(D-Q)}function p(y,k,Q,Z,D,L,B){if(L){let _=[N.contextHash,L];B=B?[_].concat(B):[_]}if(D>25){let _=[N.lookAhead,D];B=B?[_].concat(B):[_]}return new ht(y,k,Q,Z,B)}function m(y,k){let Q=l.fork(),Z=0,D=0,L=0,B=Q.end-r,_={size:0,start:0,skip:0};t:for(let G=Q.pos-y;Q.pos>G;){let U=Q.size;if(Q.id==k&&U>=0){_.size=Z,_.start=D,_.skip=L,L+=4,Z+=4,Q.next();continue}let H=Q.pos-U;if(U<0||H<G||Q.start<B)break;let Xt=Q.id>=o?4:0,_t=Q.start;for(Q.next();Q.pos>H;){if(Q.size<0)if(Q.size==-3||Q.size==-4)Xt+=4;else break t;else Q.id>=o&&(Xt+=4);Q.next()}D=_t,Z+=U,L+=Xt}return(k<0||Z==y)&&(_.size=Z,_.start=D,_.skip=L),_.size>4?_:void 0}function g(y,k,Q){let{id:Z,start:D,end:L,size:B}=l;if(l.next(),B>=0&&Z<o){let _=Q;if(B>4){let G=l.pos-(B-4);for(;l.pos>G;)Q=g(y,k,Q)}k[--Q]=_,k[--Q]=L-y,k[--Q]=D-y,k[--Q]=Z}else B==-3?c=Z:B==-4&&(h=Z);return Q}let b=[],S=[];for(;l.pos>0;)u(i.start||0,i.bufferStart||0,b,S,-1,0);let x=(t=i.length)!==null&&t!==void 0?t:b.length?S[0]+b[0].length:0;return new ht(a[i.topID],b.reverse(),S.reverse(),x)}const KO=new WeakMap;function Sa(i,t){if(!i.isAnonymous||t instanceof Mn||t.type!=i)return 1;let e=KO.get(t);if(e==null){e=1;for(let n of t.children){if(n.type!=i||!(n instanceof ht)){e=1;break}e+=Sa(i,n)}KO.set(t,e)}return e}function Vf(i,t,e,n,r,s,o,l,a){let c=0;for(let O=n;O<r;O++)c+=Sa(i,t[O]);let h=Math.ceil(c*1.5/8),u=[],f=[];function d(O,p,m,g,b){for(let S=m;S<g;){let x=S,y=p[S],k=Sa(i,O[S]);for(S++;S<g;S++){let Q=Sa(i,O[S]);if(k+Q>=h)break;k+=Q}if(S==x+1){if(k>h){let Q=O[x];d(Q.children,Q.positions,0,Q.children.length,p[x]+b);continue}u.push(O[x])}else{let Q=p[S-1]+O[S-1].length-y;u.push(Vf(i,O,p,x,S,y,Q,null,a))}f.push(y+b-s)}}return d(t,e,n,r,0),(l||a)(u,f,o)}class o0{constructor(){this.map=new WeakMap}setBuffer(t,e,n){let r=this.map.get(t);r||this.map.set(t,r=new Map),r.set(e,n)}getBuffer(t,e){let n=this.map.get(t);return n&&n.get(e)}set(t,e){t instanceof Mi?this.setBuffer(t.context.buffer,t.index,e):t instanceof he&&this.map.set(t.tree,e)}get(t){return t instanceof Mi?this.getBuffer(t.context.buffer,t.index):t instanceof he?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class rn{constructor(t,e,n,r,s=!1,o=!1){this.from=t,this.to=e,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],n=!1){let r=[new rn(0,t.length,t,0,!1,n)];for(let s of e)s.to>t.length&&r.push(s);return r}static applyChanges(t,e,n=128){if(!e.length)return t;let r=[],s=1,o=t.length?t[0]:null;for(let l=0,a=0,c=0;;l++){let h=l<e.length?e[l]:null,u=h?h.fromA:1e9;if(u-a>=n)for(;o&&o.from<u;){let f=o;if(a>=f.from||u<=f.to||c){let d=Math.max(f.from,a)-c,O=Math.min(f.to,u)-c;f=d>=O?null:new rn(d,O,f.tree,f.offset+c,l>0,!!h)}if(f&&r.push(f),o.to>u)break;o=s<t.length?t[s++]:null}if(!h)break;a=h.toA,c=h.toA-h.toB}return r}}class Bf{startParse(t,e,n){return typeof t=="string"&&(t=new Ak(t)),n=n?n.length?n.map(r=>new qe(r.from,r.to)):[new qe(0,0)]:[new qe(0,t.length)],this.createParse(t,e||[],n)}parse(t,e,n){let r=this.startParse(t,e,n);for(;;){let s=r.advance();if(s)return s}}}class Ak{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function l0(i){return(t,e,n,r)=>new Zk(t,i,e,n,r)}class JO{constructor(t,e,n,r,s,o){this.parser=t,this.parse=e,this.overlay=n,this.bracketed=r,this.target=s,this.from=o}}function tp(i){if(!i.length||i.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(i))}class Rk{constructor(t,e,n,r,s,o,l,a){this.parser=t,this.predicate=e,this.mounts=n,this.index=r,this.start=s,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Au=new N({perNode:!0});class Zk{constructor(t,e,n,r,s){this.nest=e,this.input=n,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let n=this.baseParse.advance();if(!n)return null;if(this.baseParse=null,this.baseTree=n,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let n=this.baseTree;return this.stoppedAt!=null&&(n=new ht(n.type,n.children,n.positions,n.length,n.propValues.concat([[Au,this.stoppedAt]]))),n}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let n=Object.assign(Object.create(null),t.target.props);n[N.mounted.id]=new Dr(e,t.overlay,t.parser,t.bracketed),t.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new Lk(this.fragments),e=null,n=null,r=new Va(new he(this.baseTree,this.ranges[0].from,0,null),ft.IncludeAnonymous|ft.IgnoreMounts);t:for(let s,o;;){let l=!0,a;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)l=!1;else if(t.hasNode(r)){if(e){let c=e.mounts.find(h=>h.frag.from<=r.from&&h.frag.to>=r.to&&h.mount.overlay);if(c)for(let h of c.mount.overlay){let u=h.from+c.pos,f=h.to+c.pos;u>=r.from&&f<=r.to&&!e.ranges.some(d=>d.from<f&&d.to>u)&&e.ranges.push({from:u,to:f})}}l=!1}else if(n&&(o=Xk(n.ranges,r.from,r.to)))l=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.from<r.to||!s.overlay)){r.tree||(Ek(r),e&&e.depth++,n&&n.depth++);let c=t.findMounts(r.from,s.parser);if(typeof s.overlay=="function")e=new Rk(s.parser,s.overlay,c,this.inner.length,r.from,!!s.bracketed,r.tree,e);else{let h=np(this.ranges,s.overlay||(r.from<r.to?[new qe(r.from,r.to)]:[]));h.length&&tp(h),(h.length||!s.overlay)&&this.inner.push(new JO(s.parser,h.length?s.parser.startParse(this.input,rp(c,h),h):s.parser.startParse(""),s.overlay?s.overlay.map(u=>new qe(u.from-r.from,u.to-r.from)):null,!!s.bracketed,r.tree,h.length?h[0].from:r.from)),s.overlay?h.length&&(n={ranges:h,depth:0,prev:n}):l=!1}}else if(e&&(a=e.predicate(r))&&(a===!0&&(a=new qe(r.from,r.to)),a.from<a.to)){let c=e.ranges.length-1;c>=0&&e.ranges[c].to==a.from?e.ranges[c]={from:e.ranges[c].from,to:a.to}:e.ranges.push(a)}if(l&&r.firstChild())e&&e.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break t;if(e&&!--e.depth){let c=np(this.ranges,e.ranges);c.length&&(tp(c),this.inner.splice(e.index,0,new JO(e.parser,e.parser.startParse(this.input,rp(e.mounts,c),c),e.ranges.map(h=>new qe(h.from-e.start,h.to-e.start)),e.bracketed,e.target,c[0].from))),e=e.prev}n&&!--n.depth&&(n=n.prev)}}}}function Xk(i,t,e){for(let n of i){if(n.from>=e)break;if(n.to>t)return n.from<=t&&n.to>=e?2:1}return 0}function ep(i,t,e,n,r,s){if(t<e){let o=i.buffer[t+1];n.push(i.slice(t,e,o)),r.push(o-s)}}function Ek(i){let{node:t}=i,e=[],n=t.context.buffer;do e.push(i.index),i.parent();while(!i.tree);let r=i.tree,s=r.children.indexOf(n),o=r.children[s],l=o.buffer,a=[s];function c(h,u,f,d,O,p){let m=e[p],g=[],b=[];ep(o,h,m,g,b,d);let S=l[m+1],x=l[m+2];a.push(g.length);let y=p?c(m+4,l[m+3],o.set.types[l[m]],S,x-S,p-1):t.toTree();return g.push(y),b.push(S-d),ep(o,l[m+3],u,g,b,d),new ht(f,g,b,O)}r.children[s]=c(0,l.length,qt.none,0,o.length,e.length-1);for(let h of a){let u=i.tree.children[h],f=i.tree.positions[h];i.yield(new he(u,f+i.from,h,i._tree))}}class ip{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(ft.IncludeAnonymous|ft.IgnoreMounts)}moveTo(t){let{cursor:e}=this,n=t-this.offset;for(;!this.done&&e.from<n;)if(!(e.to>=t&&e.enter(n,1,ft.IgnoreOverlays|ft.ExcludeBuffers)))if(e.to<=t)e.next(!1)||(this.done=!0);else break}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof ht)e=e.children[0];else break}return!1}}let Lk=class{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let n=this.curFrag=t[0];this.curTo=(e=n.tree.prop(Au))!==null&&e!==void 0?e:n.to,this.inner=new ip(n.tree,-n.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=(t=e.tree.prop(Au))!==null&&t!==void 0?t:e.to,this.inner=new ip(e.tree,-e.offset)}}findMounts(t,e){var n;let r=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(n=s.tree)===null||n===void 0?void 0:n.prop(N.mounted);if(o&&o.parser==e)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=s.to)break;a.tree==this.curFrag.tree&&r.push({frag:a,pos:s.from-a.offset,mount:o})}}}return r}};function np(i,t){let e=null,n=t;for(let r=1,s=0;r<i.length;r++){let o=i[r-1].to,l=i[r].from;for(;s<n.length;s++){let a=n[s];if(a.from>=l)break;a.to<=o||(e||(n=e=t.slice()),a.from<o?(e[s]=new qe(a.from,o),a.to>l&&e.splice(s+1,0,new qe(l,a.to))):a.to>l?e[s--]=new qe(l,a.to):e.splice(s--,1))}}return n}function Mk(i,t,e,n){let r=0,s=0,o=!1,l=!1,a=-1e9,c=[];for(;;){let h=r==i.length?1e9:o?i[r].to:i[r].from,u=s==t.length?1e9:l?t[s].to:t[s].from;if(o!=l){let f=Math.max(a,e),d=Math.min(h,u,n);f<d&&c.push(new qe(f,d))}if(a=Math.min(h,u),a==1e9)break;h==a&&(o?(o=!1,r++):o=!0),u==a&&(l?(l=!1,s++):l=!0)}return c}function rp(i,t){let e=[];for(let{pos:n,mount:r,frag:s}of i){let o=n+(r.overlay?r.overlay[0].from:0),l=o+r.tree.length,a=Math.max(s.from,o),c=Math.min(s.to,l);if(r.overlay){let h=r.overlay.map(f=>new qe(f.from+n,f.to+n)),u=Mk(t,h,a,c);for(let f=0,d=a;;f++){let O=f==u.length,p=O?c:u[f].from;if(p>d&&e.push(new rn(d,p,r.tree,-o,s.from>=d||s.openStart,s.to<=p||s.openEnd)),O)break;d=u[f].to}}else e.push(new rn(a,c,r.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return e}let zk=0;class _e{constructor(t,e,n,r){this.name=t,this.set=e,this.base=n,this.modified=r,this.id=zk++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let n=typeof t=="string"?t:"?";if(t instanceof _e&&(e=t),e!=null&&e.base)throw new Error("Can not derive from a modified tag");let r=new _e(n,[],null,[]);if(r.set.push(r),e)for(let s of e.set)r.set.push(s);return r}static defineModifier(t){let e=new Ba(t);return n=>n.modified.indexOf(e)>-1?n:Ba.get(n.base||n,n.modified.concat(e).sort((r,s)=>r.id-s.id))}}let _k=0;class Ba{constructor(t){this.name=t,this.instances=[],this.id=_k++}static get(t,e){if(!e.length)return t;let n=e[0].instances.find(l=>l.base==t&&Ik(e,l.modified));if(n)return n;let r=[],s=new _e(t.name,r,t,e);for(let l of e)l.instances.push(s);let o=jk(e);for(let l of t.set)if(!l.modified.length)for(let a of o)r.push(Ba.get(l,a));return s}}function Ik(i,t){return i.length==t.length&&i.every((e,n)=>e==t[n])}function jk(i){let t=[[]];for(let e=0;e<i.length;e++)for(let n=0,r=t.length;n<r;n++)t.push(t[n].concat(i[e]));return t.sort((e,n)=>n.length-e.length)}function ho(i){let t=Object.create(null);for(let e in i){let n=i[e];Array.isArray(n)||(n=[n]);for(let r of e.split(" "))if(r){let s=[],o=2,l=r;for(let u=0;;){if(l=="..."&&u>0&&u+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==r.length)break;let d=r[u++];if(u==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(u)}let a=s.length-1,c=s[a];if(!c)throw new RangeError("Invalid path: "+r);let h=new tl(n,o,a>0?s.slice(0,a):null);t[c]=h.sort(t[c])}}return a0.add(t)}const a0=new N({combine(i,t){let e,n,r;for(;i||t;){if(!i||t&&i.depth>=t.depth?(r=t,t=t.next):(r=i,i=i.next),e&&e.mode==r.mode&&!r.context&&!e.context)continue;let s=new tl(r.tags,r.mode,r.context);e?e.next=s:n=s,e=s}return n}});class tl{constructor(t,e,n,r){this.tags=t,this.mode=e,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}tl.empty=new tl([],2,null);function c0(i,t){let e=Object.create(null);for(let s of i)if(!Array.isArray(s.tag))e[s.tag.id]=s.class;else for(let o of s.tag)e[o.id]=s.class;let{scope:n,all:r=null}=t||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let c=e[a.id];if(c){o=o?o+" "+c:c;break}}return o},scope:n}}function Dk(i,t){let e=null;for(let n of i){let r=n.style(t);r&&(e=e?e+" "+r:r)}return e}function Vk(i,t,e,n=0,r=i.length){let s=new Bk(n,Array.isArray(t)?t:[t],e);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}class Bk{constructor(t,e,n){this.at=t,this.highlighters=e,this.span=n,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,n,r,s){let{type:o,from:l,to:a}=t;if(l>=n||a<=e)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let c=r,h=h0(t)||tl.empty,u=Dk(s,h.tags);if(u&&(c&&(c+=" "),c+=u,h.mode==1&&(r+=(r?" ":"")+u)),this.startSpan(Math.max(e,l),c),h.opaque)return;let f=t.tree&&t.tree.prop(N.mounted);if(f&&f.overlay){let d=t.node.enter(f.overlay[0].from+l,1),O=this.highlighters.filter(m=>!m.scope||m.scope(f.tree.type)),p=t.firstChild();for(let m=0,g=l;;m++){let b=m<f.overlay.length?f.overlay[m]:null,S=b?b.from+l:a,x=Math.max(e,g),y=Math.min(n,S);if(x<y&&p)for(;t.from<y&&(this.highlightRange(t,x,y,r,s),this.startSpan(Math.min(y,t.to),c),!(t.to>=S||!t.nextSibling())););if(!b||S>n)break;g=b.to+l,g>e&&(this.highlightRange(d.cursor(),Math.max(e,b.from+l),Math.min(n,g),"",O),this.startSpan(Math.min(n,g),c))}p&&t.parent()}else if(t.firstChild()){f&&(r="");do if(!(t.to<=e)){if(t.from>=n)break;this.highlightRange(t,e,n,r,s),this.startSpan(Math.min(n,t.to),c)}while(t.nextSibling());t.parent()}}}function h0(i){let t=i.type.prop(a0);for(;t&&t.context&&!i.matchContext(t.context);)t=t.next;return t||null}const X=_e.define,Kl=X(),mn=X(),sp=X(mn),op=X(mn),gn=X(),Jl=X(gn),ph=X(gn),Ci=X(),qn=X(Ci),ki=X(),Qi=X(),Ru=X(),vo=X(Ru),ta=X(),v={comment:Kl,lineComment:X(Kl),blockComment:X(Kl),docComment:X(Kl),name:mn,variableName:X(mn),typeName:sp,tagName:X(sp),propertyName:op,attributeName:X(op),className:X(mn),labelName:X(mn),namespace:X(mn),macroName:X(mn),literal:gn,string:Jl,docString:X(Jl),character:X(Jl),attributeValue:X(Jl),number:ph,integer:X(ph),float:X(ph),bool:X(gn),regexp:X(gn),escape:X(gn),color:X(gn),url:X(gn),keyword:ki,self:X(ki),null:X(ki),atom:X(ki),unit:X(ki),modifier:X(ki),operatorKeyword:X(ki),controlKeyword:X(ki),definitionKeyword:X(ki),moduleKeyword:X(ki),operator:Qi,derefOperator:X(Qi),arithmeticOperator:X(Qi),logicOperator:X(Qi),bitwiseOperator:X(Qi),compareOperator:X(Qi),updateOperator:X(Qi),definitionOperator:X(Qi),typeOperator:X(Qi),controlOperator:X(Qi),punctuation:Ru,separator:X(Ru),bracket:vo,angleBracket:X(vo),squareBracket:X(vo),paren:X(vo),brace:X(vo),content:Ci,heading:qn,heading1:X(qn),heading2:X(qn),heading3:X(qn),heading4:X(qn),heading5:X(qn),heading6:X(qn),contentSeparator:X(Ci),list:X(Ci),quote:X(Ci),emphasis:X(Ci),strong:X(Ci),link:X(Ci),monospace:X(Ci),strikethrough:X(Ci),inserted:X(),deleted:X(),changed:X(),invalid:X(),meta:ta,documentMeta:X(ta),annotation:X(ta),processingInstruction:X(ta),definition:_e.defineModifier("definition"),constant:_e.defineModifier("constant"),function:_e.defineModifier("function"),standard:_e.defineModifier("standard"),local:_e.defineModifier("local"),special:_e.defineModifier("special")};for(let i in v){let t=v[i];t instanceof _e&&(t.name=i)}c0([{tag:v.link,class:"tok-link"},{tag:v.heading,class:"tok-heading"},{tag:v.emphasis,class:"tok-emphasis"},{tag:v.strong,class:"tok-strong"},{tag:v.keyword,class:"tok-keyword"},{tag:v.atom,class:"tok-atom"},{tag:v.bool,class:"tok-bool"},{tag:v.url,class:"tok-url"},{tag:v.labelName,class:"tok-labelName"},{tag:v.inserted,class:"tok-inserted"},{tag:v.deleted,class:"tok-deleted"},{tag:v.literal,class:"tok-literal"},{tag:v.string,class:"tok-string"},{tag:v.number,class:"tok-number"},{tag:[v.regexp,v.escape,v.special(v.string)],class:"tok-string2"},{tag:v.variableName,class:"tok-variableName"},{tag:v.local(v.variableName),class:"tok-variableName tok-local"},{tag:v.definition(v.variableName),class:"tok-variableName tok-definition"},{tag:v.special(v.variableName),class:"tok-variableName2"},{tag:v.definition(v.propertyName),class:"tok-propertyName tok-definition"},{tag:v.typeName,class:"tok-typeName"},{tag:v.namespace,class:"tok-namespace"},{tag:v.className,class:"tok-className"},{tag:v.macroName,class:"tok-macroName"},{tag:v.propertyName,class:"tok-propertyName"},{tag:v.operator,class:"tok-operator"},{tag:v.comment,class:"tok-comment"},{tag:v.meta,class:"tok-meta"},{tag:v.invalid,class:"tok-invalid"},{tag:v.punctuation,class:"tok-punctuation"}]);var mh;const rr=new N;function Wf(i){return V.define({combine:i?t=>t.concat(i):void 0})}const Yf=new N;class Ie{constructor(t,e,n=[],r=""){this.data=t,this.name=r,K.prototype.hasOwnProperty("tree")||Object.defineProperty(K.prototype,"tree",{get(){return St(this)}}),this.parser=e,this.extension=[Ks.of(this),K.languageData.of((s,o,l)=>{let a=lp(s,o,l),c=a.type.prop(rr);if(!c)return[];let h=s.facet(c),u=a.type.prop(Yf);if(u){let f=a.resolve(o-a.from,l);for(let d of u)if(d.test(f,s)){let O=s.facet(d.facet);return d.type=="replace"?O:O.concat(h)}}return h})].concat(n)}isActiveAt(t,e,n=-1){return lp(t,e,n).type.prop(rr)==this.data}findRegions(t){let e=t.facet(Ks);if((e==null?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(rr)==this.data){n.push({from:o,to:o+s.length});return}let l=s.prop(N.mounted);if(l){if(l.tree.prop(rr)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+s.length});return}else if(l.overlay){let a=n.length;if(r(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;a<s.children.length;a++){let c=s.children[a];c instanceof ht&&r(c,s.positions[a]+o)}};return r(St(t),0),n}get allowsNesting(){return!0}}Ie.setState=Ct.define();function lp(i,t,e){let n=i.facet(Ks),r=St(i).topNode;if(!n||n.allowsNesting)for(let s=r;s;s=s.enter(t,e,ft.ExcludeBuffers|ft.EnterBracketed))s.type.isTop&&(r=s);return r}class Hs extends Ie{constructor(t,e,n){super(t,e,[],n),this.parser=e}static define(t){let e=Wf(t.languageData);return new Hs(e,t.parser.configure({props:[rr.add(n=>n.isTop?e:void 0)]}),t.name)}configure(t,e){return new Hs(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function St(i){let t=i.field(Ie.state,!1);return t?t.tree:ht.empty}function Wk(i,t=i.doc.length){var e;return((e=i.field(Ie.state,!1))===null||e===void 0?void 0:e.context.isDone(t))||!1}class Tc{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let n=this.cursorPos-this.string.length;return t<n||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-n,e-n)}}let xo=null;class el{constructor(t,e,n=[],r,s,o,l,a){this.parser=t,this.state=e,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,n){return new el(t,e,[],ht.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Tc(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=ht.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof t=="number"){let r=Date.now()+t;t=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(rn.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(rn.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=xo;xo=this;try{return t()}finally{xo=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=ap(t,e.from,e.to);return t}changes(t,e){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let a=[];if(t.iterChangedRanges((c,h,u,f)=>a.push({fromA:c,toA:h,fromB:u,toB:f})),n=rn.applyChanges(n,a),r=ht.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let h=t.mapPos(c.from,1),u=t.mapPos(c.to,-1);h<u&&l.push({from:h,to:u})}}}return new el(this.parser,e,n,r,s,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:r,to:s}=this.skipped[n];r<t.to&&s>t.from&&(this.fragments=ap(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Bf{createParse(e,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=xo;if(a){for(let c of r)a.tempSkipped.push(c);t&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,t]):t)}return this.parsedPos=o,new ht(qt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return xo}}function ap(i,t,e){return rn.applyChanges(i,[{fromA:t,toA:e,fromB:t,toB:e}])}class Fs{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),n=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,n)||e.takeTree(),new Fs(e)}static init(t){let e=Math.min(3e3,t.doc.length),n=el.create(t.facet(Ks).parser,t,{from:0,to:e});return n.work(20,e)||n.takeTree(),new Fs(n)}}Ie.state=bi.define({create:Fs.init,update(i,t){for(let e of t.effects)if(e.is(Ie.setState))return e.value;return t.startState.facet(Ks)!=t.state.facet(Ks)?Fs.init(t.state):i.apply(t)}});let u0=i=>{let t=setTimeout(()=>i(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(u0=i=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(i,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const gh=typeof navigator<"u"&&(!((mh=navigator.scheduling)===null||mh===void 0)&&mh.isInputPending)?()=>navigator.scheduling.isInputPending():null,Yk=ui.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Ie.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Ie.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=u0(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,s=n.field(Ie.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!gh?Math.max(25,t.timeRemaining()-5):1e9),l=s.context.treeLen<r&&n.doc.length>r+1e3,a=s.context.work(()=>gh&&gh()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ie.setState.of(new Fs(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>Li(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ks=V.define({combine(i){return i.length?i[0]:null},enables:i=>[Ie.state,Yk,z.contentAttributes.compute([i],t=>{let e=t.facet(i);return e&&e.name?{"data-language":e.name}:{}})]});class il{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Wa{constructor(t,e,n,r,s,o=void 0){this.name=t,this.alias=e,this.extensions=n,this.filename=r,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:n}=t;if(!e){if(!n)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(n)}return new Wa(t.name,(t.alias||[]).concat(t.name).map(r=>r.toLowerCase()),t.extensions||[],t.filename,e,n)}static matchFilename(t,e){for(let r of t)if(r.filename&&r.filename.test(e))return r;let n=/\.([^.]+)$/.exec(e);if(n){for(let r of t)if(r.extensions.indexOf(n[1])>-1)return r}return null}static matchLanguageName(t,e,n=!0){e=e.toLowerCase();for(let r of t)if(r.alias.some(s=>s==e))return r;if(n)for(let r of t)for(let s of r.alias){let o=e.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(e[o-1])&&!/\w/.test(e[o+s.length])))return r}return null}}const qk=V.define(),uo=V.define({combine:i=>{if(!i.length)return" ";let t=i[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return t}});function Ya(i){let t=i.facet(uo);return t.charCodeAt(0)==9?i.tabSize*t.length:t.length}function qa(i,t){let e="",n=i.tabSize,r=i.facet(uo)[0];if(r==" "){for(;t>=n;)e+=" ",t-=n;r=" "}for(let s=0;s<t;s++)e+=r;return e}function f0(i,t){i instanceof K&&(i=new Ac(i));for(let n of i.state.facet(qk)){let r=n(i,t);if(r!==void 0)return r}let e=St(i.state);return e.length>=t?Nk(i,e,t):null}class Ac{constructor(t,e={}){this.state=t,this.options=e,this.unit=Ya(t)}lineAt(t,e=1){let n=this.state.doc.lineAt(t),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==t?{text:"",from:t}:(e<0?r<t:r<=t)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(t,e);return n.slice(t-r,Math.min(n.length,t+100-r))}column(t,e=1){let{text:n,from:r}=this.lineAt(t,e),s=this.countColumn(n,t-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(t,e=t.length){return an(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:n,from:r}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const $l=new N;function Nk(i,t,e){let n=t.resolveStack(e),r=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(r!=n.node){let s=[];for(let o=r;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return d0(n,i,e)}function d0(i,t,e){for(let n=i;n;n=n.next){let r=Uk(n.node);if(r)return r(qf.create(t,e,n))}return 0}function Gk(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function Uk(i){let t=i.type.prop($l);if(t)return t;let e=i.firstChild,n;if(e&&(n=e.type.prop(N.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>O0(o,!0,1,void 0,s&&!Gk(o)?r.from:void 0)}return i.parent==null?Hk:null}function Hk(){return 0}class qf extends Ac{constructor(t,e,n){super(t.state,t.options),this.base=t,this.pos=e,this.context=n}get node(){return this.context.node}static create(t,e,n){return new qf(t,e,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let n=t.resolve(e.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Fk(n,t))break;e=this.state.doc.lineAt(n.from)}return this.lineIndent(e.from)}continue(){return d0(this.context.next,this.base,this.pos)}}function Fk(i,t){for(let e=t;e;e=e.parent)if(i==e)return!0;return!1}function Kk(i){let t=i.node,e=t.childAfter(t.from),n=t.lastChild;if(!e)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(e.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=e.to;;){let a=t.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let c=/^ */.exec(s.text.slice(e.to-s.from))[0].length;return{from:e.from,to:e.to+c}}l=a.to}}function Jk({closing:i,align:t=!0,units:e=1}){return n=>O0(n,t,e,i)}function O0(i,t,e,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||r==i.pos+o,a=t?Kk(i):null;return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*e)}const tQ=i=>i.baseIndent;function va({except:i,units:t=1}={}){return e=>{let n=i&&i.test(e.textAfter);return e.baseIndent+(n?0:t*e.unit)}}const eQ=V.define(),Cl=new N;function p0(i){let t=i.firstChild,e=i.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?i.to:e.from}:null}class Rc{constructor(t,e){this.specs=t;let n;function r(l){let a=Xn.newName();return(n||(n=Object.create(null)))["."+a]=l,a}const s=typeof e.all=="string"?e.all:e.all?r(e.all):void 0,o=e.scope;this.scope=o instanceof Ie?l=>l.prop(rr)==o.data:o?l=>l==o:void 0,this.style=c0(t.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=n?new Xn(n):null,this.themeType=e.themeType}static define(t,e){return new Rc(t,e||{})}}const Zu=V.define(),iQ=V.define({combine(i){return i.length?[i[0]]:null}});function xa(i){let t=i.facet(Zu);return t.length?t:i.facet(iQ)}function m0(i,t){let e=[sQ],n;return i instanceof Rc&&(i.module&&e.push(z.styleModule.of(i.module)),n=i.themeType),n?e.push(Zu.computeN([z.darkTheme],r=>r.facet(z.darkTheme)==(n=="dark")?[i]:[])):e.push(Zu.of(i)),e}function nQ(i,t,e){let n=xa(i),r=null;if(n){for(let s of n)if(!s.scope||e){let o=s.style(t);o&&(r=r?r+" "+o:o)}}return r}class rQ{constructor(t){this.markCache=Object.create(null),this.tree=St(t.state),this.decorations=this.buildDeco(t,xa(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=St(t.state),n=xa(t.state),r=n!=xa(t.startState),{viewport:s}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<s.to&&!r&&e.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||r)&&(this.tree=e,this.decorations=this.buildDeco(t.view,n),this.decoratedTo=s.to)}buildDeco(t,e){if(!e||!this.tree.length)return J.none;let n=new Ws;for(let{from:r,to:s}of t.visibleRanges)Vk(this.tree,e,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=J.mark({class:a})))},r,s);return n.finish()}}const sQ=hn.high(ui.fromClass(rQ,{decorations:i=>i.decorations})),oQ=1e4,lQ="()[]{}",g0=new N;function Xu(i,t,e){let n=i.prop(t<0?N.openedBy:N.closedBy);if(n)return n;if(i.name.length==1){let r=e.indexOf(i.name);if(r>-1&&r%2==(t<0?1:0))return[e[r+t]]}return null}function Eu(i){let t=i.type.prop(g0);return t?t(i.node):i}function Er(i,t,e,n={}){let r=n.maxScanDistance||oQ,s=n.brackets||lQ,o=St(i),l=o.resolveInner(t,e);for(let a=l;a;a=a.parent){let c=Xu(a.type,e,s);if(c&&a.from<a.to){let h=Eu(a);if(h&&(e>0?t>=h.from&&t<h.to:t>h.from&&t<=h.to))return aQ(i,t,e,a,h,c,s)}}return cQ(i,t,e,o,l.type,r,s)}function aQ(i,t,e,n,r,s,o){let l=n.parent,a={from:r.from,to:r.to},c=0,h=l==null?void 0:l.cursor();if(h&&(e<0?h.childBefore(n.from):h.childAfter(n.to)))do if(e<0?h.to<=n.from:h.from>=n.to){if(c==0&&s.indexOf(h.type.name)>-1&&h.from<h.to){let u=Eu(h);return{start:a,end:u?{from:u.from,to:u.to}:void 0,matched:!0}}else if(Xu(h.type,e,o))c++;else if(Xu(h.type,-e,o)){if(c==0){let u=Eu(h);return{start:a,end:u&&u.from<u.to?{from:u.from,to:u.to}:void 0,matched:!1}}c--}}while(e<0?h.prevSibling():h.nextSibling());return{start:a,matched:!1}}function cQ(i,t,e,n,r,s,o){if(e<0?!t:t==i.doc.length)return null;let l=e<0?i.sliceDoc(t-1,t):i.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=e>0)return null;let c={from:e<0?t-1:t,to:e>0?t+1:t},h=i.doc.iterRange(t,e>0?i.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=s;){let d=h.value;e<0&&(f+=d.length);let O=t+f*e;for(let p=e>0?0:d.length-1,m=e>0?d.length:-1;p!=m;p+=e){let g=o.indexOf(d[p]);if(!(g<0||n.resolveInner(O+p,1).type!=r))if(g%2==0==e>0)u++;else{if(u==1)return{start:c,end:{from:O+p,to:O+p+1},matched:g>>1==a>>1};u--}}e>0&&(f+=d.length)}return h.done?{start:c,matched:!1}:null}const hQ=Object.create(null),cp=[qt.none],hp=[],up=Object.create(null),uQ=Object.create(null);for(let[i,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])uQ[i]=fQ(hQ,t);function bh(i,t){hp.indexOf(i)>-1||(hp.push(i),console.warn(t))}function fQ(i,t){let e=[];for(let l of t.split(" ")){let a=[];for(let c of l.split(".")){let h=i[c]||v[c];h?typeof h=="function"?a.length?a=a.map(h):bh(c,`Modifier ${c} used at start of tag`):a.length?bh(c,`Tag ${c} used as modifier`):a=Array.isArray(h)?h:[h]:bh(c,`Unknown highlighting tag ${c}`)}for(let c of a)e.push(c)}if(!e.length)return 0;let n=t.replace(/ /g,"_"),r=n+" "+e.map(l=>l.id),s=up[r];if(s)return s.id;let o=up[r]=qt.define({id:cp.length,name:n,props:[ho({[n]:e})]});return cp.push(o),o.id}Tt.RTL,Tt.LTR;const dQ=i=>{let{state:t}=i,e=t.doc.lineAt(t.selection.main.from),n=Gf(i.state,e.from);return n.line?OQ(i):n.block?mQ(i):!1};function Nf(i,t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=i(t,e);return r?(n(e.update(r)),!0):!1}}const OQ=Nf(wQ,0),pQ=Nf(b0,0),mQ=Nf((i,t)=>b0(i,t,bQ(t)),0);function Gf(i,t){let e=i.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}const yo=50;function gQ(i,{open:t,close:e},n,r){let s=i.sliceDoc(n-yo,n),o=i.sliceDoc(r,r+yo),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,c=s.length-l;if(s.slice(c-t.length,c)==t&&o.slice(a,a+e.length)==e)return{open:{pos:n-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let h,u;r-n<=2*yo?h=u=i.sliceDoc(n,r):(h=i.sliceDoc(n,n+yo),u=i.sliceDoc(r-yo,r));let f=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(u)[0].length,O=u.length-d-e.length;return h.slice(f,f+t.length)==t&&u.slice(O,O+e.length)==e?{open:{pos:n+f+t.length,margin:/\s/.test(h.charAt(f+t.length))?1:0},close:{pos:r-d-e.length,margin:/\s/.test(u.charAt(O-1))?1:0}}:null}function bQ(i){let t=[];for(let e of i.selection.ranges){let n=i.doc.lineAt(e.from),r=e.to<=n.to?n:i.doc.lineAt(e.to);r.from>n.from&&r.from==e.to&&(r=e.to==n.to+1?n:i.doc.lineAt(e.to-1));let s=t.length-1;s>=0&&t[s].to>n.from?t[s].to=r.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return t}function b0(i,t,e=t.selection.ranges){let n=e.map(s=>Gf(t,s.from).block);if(!n.every(s=>s))return null;let r=e.map((s,o)=>gQ(t,n[o],s.from,s.to));if(i!=2&&!r.every(s=>s))return{changes:t.changes(e.map((s,o)=>r[o]?[]:[{from:s.from,insert:n[o].open+" "},{from:s.to,insert:" "+n[o].close}]))};if(i!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=n[o],{open:c,close:h}=l;s.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:h.pos-h.margin,to:h.pos+a.close.length})}return{changes:s}}return null}function wQ(i,t,e=t.selection.ranges){let n=[],r=-1;t:for(let{from:s,to:o}of e){let l=n.length,a=1e9,c;for(let h=s;h<=o;){let u=t.doc.lineAt(h);if(c==null&&(c=Gf(t,u.from).line,!c))continue t;if(u.from>r&&(s==o||o>u.from)){r=u.from;let f=/^\s*/.exec(u.text)[0].length,d=f==u.length,O=u.text.slice(f,f+c.length)==c?f:-1;f<u.text.length&&f<a&&(a=f),n.push({line:u,comment:O,token:c,indent:f,empty:d,single:!1})}h=u.to+1}if(a<1e9)for(let h=l;h<n.length;h++)n[h].indent<n[h].line.text.length&&(n[h].indent=a);n.length==l+1&&(n[l].single=!0)}if(i!=2&&n.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:c,empty:h,single:u}of n)(u||!h)&&s.push({from:l.from+c,insert:a+" "});let o=t.changes(s);return{changes:o,selection:t.selection.map(o,1)}}else if(i!=1&&n.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of n)if(l>=0){let c=o.from+l,h=c+a.length;o.text[h-o.from]==" "&&h++,s.push({from:c,to:h})}return{changes:s}}return null}const Lu=Ke.define(),SQ=Ke.define(),w0=V.define(),S0=V.define({combine(i){return eb(i,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(n,r)=>t(n,r)||e(n,r)})}}),Uf=bi.define({create(){return zi.empty},update(i,t){let e=t.state.facet(S0),n=t.annotation(Lu);if(n){let a=ye.fromTransaction(t,n.selection),c=n.side,h=c==0?i.undone:i.done;return a?h=Ga(h,h.length,e.minDepth,a):h=y0(h,t.startState.selection),new zi(c==0?n.rest:h,c==0?h:n.rest)}let r=t.annotation(SQ);if((r=="full"||r=="before")&&(i=i.isolate()),t.annotation(Pt.addToHistory)===!1)return t.changes.empty?i:i.addMapping(t.changes.desc);let s=ye.fromTransaction(t),o=t.annotation(Pt.time),l=t.annotation(Pt.userEvent);return s?i=i.addChanges(s,o,l,e,t):t.selection&&(i=i.addSelection(t.startState.selection,o,l,e.newGroupDelay)),(r=="full"||r=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(t=>t.toJSON()),undone:i.undone.map(t=>t.toJSON())}},fromJSON(i){return new zi(i.done.map(ye.fromJSON),i.undone.map(ye.fromJSON))}});function vQ(i={}){return[Uf,S0.of(i),z.domEventHandlers({beforeinput(t,e){let n=t.inputType=="historyUndo"?Hf:t.inputType=="historyRedo"?Na:null;return n?(t.preventDefault(),n(e)):!1}})]}function Zc(i,t){return function({state:e,dispatch:n}){if(!t&&e.readOnly)return!1;let r=e.field(Uf,!1);if(!r)return!1;let s=r.pop(i,e,t);return s?(n(s),!0):!1}}const Hf=Zc(0,!1),Na=Zc(1,!1),xQ=Zc(0,!0),yQ=Zc(1,!0);function v0(i){return function(t){let e=t.field(Uf,!1);if(!e)return 0;let n=i==0?e.done:e.undone;return n.length-(n.length&&!n[0].changes?1:0)}}const kQ=v0(0),QQ=v0(1);class ye{constructor(t,e,n,r,s){this.changes=t,this.effects=e,this.mapped=n,this.startSelection=r,this.selectionsAfter=s}setSelAfter(t){return new ye(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,n;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(e=this.mapped)===null||e===void 0?void 0:e.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(t){return new ye(t.changes&&Lt.fromJSON(t.changes),[],t.mapped&&Ii.fromJSON(t.mapped),t.startSelection&&C.fromJSON(t.startSelection),t.selectionsAfter.map(C.fromJSON))}static fromTransaction(t,e){let n=Ne;for(let r of t.startState.facet(w0)){let s=r(t);s.length&&(n=n.concat(s))}return!n.length&&t.changes.empty?null:new ye(t.changes.invert(t.startState.doc),n,void 0,e||t.startState.selection,Ne)}static selection(t){return new ye(void 0,Ne,void 0,void 0,t)}}function Ga(i,t,e,n){let r=t+1>e+20?t-e-1:0,s=i.slice(r,t);return s.push(n),s}function $Q(i,t){let e=[],n=!1;return i.iterChangedRanges((r,s)=>e.push(r,s)),t.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<e.length;){let c=e[a++],h=e[a++];l>=c&&o<=h&&(n=!0)}}),n}function CQ(i,t){return i.ranges.length==t.ranges.length&&i.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function x0(i,t){return i.length?t.length?i.concat(t):i:t}const Ne=[],PQ=200;function y0(i,t){if(i.length){let e=i[i.length-1],n=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-PQ));return n.length&&n[n.length-1].eq(t)?i:(n.push(t),Ga(i,i.length-1,1e9,e.setSelAfter(n)))}else return[ye.selection([t])]}function TQ(i){let t=i[i.length-1],e=i.slice();return e[i.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),e}function wh(i,t){if(!i.length)return i;let e=i.length,n=Ne;for(;e;){let r=AQ(i[e-1],t,n);if(r.changes&&!r.changes.empty||r.effects.length){let s=i.slice(0,e);return s[e-1]=r,s}else t=r.mapped,e--,n=r.selectionsAfter}return n.length?[ye.selection(n)]:Ne}function AQ(i,t,e){let n=x0(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(t)):Ne,e);if(!i.changes)return ye.selection(n);let r=i.changes.map(t),s=t.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(s):s;return new ye(r,Ct.mapEffects(i.effects,t),o,i.startSelection.map(s),n)}const RQ=/^(input\.type|delete)($|\.)/;class zi{constructor(t,e,n=0,r=void 0){this.done=t,this.undone=e,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new zi(this.done,this.undone):this}addChanges(t,e,n,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&t.changes&&(!n||RQ.test(n))&&(!l.selectionsAfter.length&&e-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,$Q(l.changes,t.changes))||n=="input.type.compose")?o=Ga(o,o.length-1,r.minDepth,new ye(t.changes.compose(l.changes),x0(Ct.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,Ne)):o=Ga(o,o.length,r.minDepth,t),new zi(o,Ne,e,n)}addSelection(t,e,n,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Ne;return s.length>0&&e-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&CQ(s[s.length-1],t)?this:new zi(y0(this.done,t),this.undone,e,n)}addMapping(t){return new zi(wh(this.done,t),wh(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,n){let r=t==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):e.selection);if(n&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Lu.of({side:t,rest:TQ(r),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Ne:r.slice(0,r.length-1);return s.mapped&&(l=wh(l,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Lu.of({side:t,rest:l,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}zi.empty=new zi(Ne,Ne);const k0=[{key:"Mod-z",run:Hf,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Na,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Na,preventDefault:!0},{key:"Mod-u",run:xQ,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:yQ,preventDefault:!0}];function fo(i,t){return C.create(i.ranges.map(t),i.mainIndex)}function wi(i,t){return i.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Si({state:i,dispatch:t},e){let n=fo(i.selection,e);return n.eq(i.selection,!0)?!1:(t(wi(i,n)),!0)}function Xc(i,t){return C.cursor(t?i.to:i.from)}function Q0(i,t){return Si(i,e=>e.empty?i.moveByChar(e,t):Xc(e,t))}function ue(i){return i.textDirectionAt(i.state.selection.main.head)==Tt.LTR}const $0=i=>Q0(i,!ue(i)),C0=i=>Q0(i,ue(i));function P0(i,t){return Si(i,e=>e.empty?i.moveByGroup(e,t):Xc(e,t))}const ZQ=i=>P0(i,!ue(i)),XQ=i=>P0(i,ue(i));function EQ(i,t,e){if(t.type.prop(e))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(t.from,t.to)))||t.firstChild}function Ec(i,t,e){let n=St(i).resolveInner(t.head),r=e?N.closedBy:N.openedBy;for(let a=t.head;;){let c=e?n.childAfter(a):n.childBefore(a);if(!c)break;EQ(i,c,r)?n=c:a=e?c.to:c.from}let s=n.type.prop(r),o,l;return s&&(o=e?Er(i,n.from,1):Er(i,n.to,-1))&&o.matched?l=e?o.end.to:o.end.from:l=e?n.to:n.from,C.cursor(l,e?-1:1)}const LQ=i=>Si(i,t=>Ec(i.state,t,!ue(i))),MQ=i=>Si(i,t=>Ec(i.state,t,ue(i)));function T0(i,t){return Si(i,e=>{if(!e.empty)return Xc(e,t);let n=i.moveVertically(e,t);return n.head!=e.head?n:i.moveToLineBoundary(e,t)})}const A0=i=>T0(i,!1),R0=i=>T0(i,!0);function Z0(i){let t=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,e=0,n=0,r;if(t){for(let s of i.state.facet(z.scrollMargins)){let o=s(i);o!=null&&o.top&&(e=Math.max(o==null?void 0:o.top,e)),o!=null&&o.bottom&&(n=Math.max(o==null?void 0:o.bottom,n))}r=i.scrollDOM.clientHeight-e-n}else r=(i.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:n,selfScroll:t,height:Math.max(i.defaultLineHeight,r-5)}}function X0(i,t){let e=Z0(i),{state:n}=i,r=fo(n.selection,o=>o.empty?i.moveVertically(o,t,e.height):Xc(o,t));if(r.eq(n.selection))return!1;let s;if(e.selfScroll){let o=i.coordsAtPos(n.selection.main.head),l=i.scrollDOM.getBoundingClientRect(),a=l.top+e.marginTop,c=l.bottom-e.marginBottom;o&&o.top>a&&o.bottom<c&&(s=z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return i.dispatch(wi(n,r),{effects:s}),!0}const fp=i=>X0(i,!1),Mu=i=>X0(i,!0);function Vn(i,t,e){let n=i.lineBlockAt(t.head),r=i.moveToLineBoundary(t,e);if(r.head==t.head&&r.head!=(e?n.to:n.from)&&(r=i.moveToLineBoundary(t,e,!1)),!e&&r.head==n.from&&n.length){let s=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;s&&t.head!=n.from+s&&(r=C.cursor(n.from+s))}return r}const zQ=i=>Si(i,t=>Vn(i,t,!0)),_Q=i=>Si(i,t=>Vn(i,t,!1)),IQ=i=>Si(i,t=>Vn(i,t,!ue(i))),jQ=i=>Si(i,t=>Vn(i,t,ue(i))),DQ=i=>Si(i,t=>C.cursor(i.lineBlockAt(t.head).from,1)),VQ=i=>Si(i,t=>C.cursor(i.lineBlockAt(t.head).to,-1));function BQ(i,t,e){let n=!1,r=fo(i.selection,s=>{let o=Er(i,s.head,-1)||Er(i,s.head,1)||s.head>0&&Er(i,s.head-1,1)||s.head<i.doc.length&&Er(i,s.head+1,-1);if(!o||!o.end)return s;n=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return C.cursor(l)});return n?(t(wi(i,r)),!0):!1}const WQ=({state:i,dispatch:t})=>BQ(i,t);function Je(i,t){let e=fo(i.state.selection,n=>{let r=t(n);return C.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return e.eq(i.state.selection)?!1:(i.dispatch(wi(i.state,e)),!0)}function E0(i,t){return Je(i,e=>i.moveByChar(e,t))}const L0=i=>E0(i,!ue(i)),M0=i=>E0(i,ue(i));function z0(i,t){return Je(i,e=>i.moveByGroup(e,t))}const YQ=i=>z0(i,!ue(i)),qQ=i=>z0(i,ue(i)),NQ=i=>Je(i,t=>Ec(i.state,t,!ue(i))),GQ=i=>Je(i,t=>Ec(i.state,t,ue(i)));function _0(i,t){return Je(i,e=>i.moveVertically(e,t))}const I0=i=>_0(i,!1),j0=i=>_0(i,!0);function D0(i,t){return Je(i,e=>i.moveVertically(e,t,Z0(i).height))}const dp=i=>D0(i,!1),Op=i=>D0(i,!0),UQ=i=>Je(i,t=>Vn(i,t,!0)),HQ=i=>Je(i,t=>Vn(i,t,!1)),FQ=i=>Je(i,t=>Vn(i,t,!ue(i))),KQ=i=>Je(i,t=>Vn(i,t,ue(i))),JQ=i=>Je(i,t=>C.cursor(i.lineBlockAt(t.head).from)),t$=i=>Je(i,t=>C.cursor(i.lineBlockAt(t.head).to)),pp=({state:i,dispatch:t})=>(t(wi(i,{anchor:0})),!0),mp=({state:i,dispatch:t})=>(t(wi(i,{anchor:i.doc.length})),!0),gp=({state:i,dispatch:t})=>(t(wi(i,{anchor:i.selection.main.anchor,head:0})),!0),bp=({state:i,dispatch:t})=>(t(wi(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),e$=({state:i,dispatch:t})=>(t(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),i$=({state:i,dispatch:t})=>{let e=Lc(i).map(({from:n,to:r})=>C.range(n,Math.min(r+1,i.doc.length)));return t(i.update({selection:C.create(e),userEvent:"select"})),!0},n$=({state:i,dispatch:t})=>{let e=fo(i.selection,n=>{let r=St(i),s=r.resolveStack(n.from,1);if(n.empty){let o=r.resolveStack(n.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&o.next)return C.range(l.to,l.from)}return n});return e.eq(i.selection)?!1:(t(wi(i,e)),!0)};function V0(i,t){let{state:e}=i,n=e.selection,r=e.selection.ranges.slice();for(let s of e.selection.ranges){let o=e.doc.lineAt(s.head);if(t?o.to<i.state.doc.length:o.from>0)for(let l=s;;){let a=i.moveVertically(l,t);if(a.head<o.from||a.head>o.to){r.some(c=>c.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==n.ranges.length?!1:(i.dispatch(wi(e,C.create(r,r.length-1))),!0)}const r$=i=>V0(i,!1),s$=i=>V0(i,!0),o$=({state:i,dispatch:t})=>{let e=i.selection,n=null;return e.ranges.length>1?n=C.create([e.main]):e.main.empty||(n=C.create([C.cursor(e.main.head)])),n?(t(wi(i,n)),!0):!1};function Pl(i,t){if(i.state.readOnly)return!1;let e="delete.selection",{state:n}=i,r=n.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=t(s);a<o?(e="delete.backward",a=ea(i,a,!1)):a>o&&(e="delete.forward",a=ea(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=ea(i,o,!1),l=ea(i,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:C.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(i.dispatch(n.update(r,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?z.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function ea(i,t,e){if(i instanceof z)for(let n of i.state.facet(z.atomicRanges).map(r=>r(i)))n.between(t,t,(r,s)=>{r<t&&s>t&&(t=e?s:r)});return t}const B0=(i,t,e)=>Pl(i,n=>{let r=n.from,{state:s}=i,o=s.doc.lineAt(r),l,a;if(e&&!t&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]==" ")return r-1;let c=an(l,s.tabSize),h=c%Ya(s)||Ya(s);for(let u=0;u<h&&l[l.length-1-u]==" ";u++)r--;a=r}else a=ae(o.text,r-o.from,t,t)+o.from,a==r&&o.number!=(t?s.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=ae(o.text,a-o.from,!1,!1)+o.from);return a}),zu=i=>B0(i,!1,!0),W0=i=>B0(i,!0,!1),Y0=(i,t)=>Pl(i,e=>{let n=e.head,{state:r}=i,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let l=null;;){if(n==(t?s.to:s.from)){n==e.head&&s.number!=(t?r.doc.lines:1)&&(n+=t?1:-1);break}let a=ae(s.text,n-s.from,t)+s.from,c=s.text.slice(Math.min(n,a)-s.from,Math.max(n,a)-s.from),h=o(c);if(l!=null&&h!=l)break;(c!=" "||n!=e.head)&&(l=h),n=a}return n}),q0=i=>Y0(i,!1),l$=i=>Y0(i,!0),a$=i=>Pl(i,t=>{let e=i.lineBlockAt(t.head).to;return t.head<e?e:Math.min(i.state.doc.length,t.head+1)}),c$=i=>Pl(i,t=>{let e=i.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),h$=i=>Pl(i,t=>{let e=i.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(i.state.doc.length,t.head+1)}),u$=({state:i,dispatch:t})=>{if(i.readOnly)return!1;let e=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:Y.of(["",""])},range:C.cursor(n.from)}));return t(i.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},f$=({state:i,dispatch:t})=>{if(i.readOnly)return!1;let e=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let r=n.from,s=i.doc.lineAt(r),o=r==s.from?r-1:ae(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:ae(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:i.doc.slice(r,l).append(i.doc.slice(o,r))},range:C.cursor(l)}});return e.changes.empty?!1:(t(i.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Lc(i){let t=[],e=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.from),s=i.doc.lineAt(n.to);if(!n.empty&&n.to==s.from&&(s=i.doc.lineAt(n.to-1)),e>=r.number){let o=t[t.length-1];o.to=s.to,o.ranges.push(n)}else t.push({from:r.from,to:s.to,ranges:[n]});e=s.number+1}return t}function N0(i,t,e){if(i.readOnly)return!1;let n=[],r=[];for(let s of Lc(i)){if(e?s.to==i.doc.length:s.from==0)continue;let o=i.doc.lineAt(e?s.to+1:s.from-1),l=o.length+1;if(e){n.push({from:s.to,to:o.to},{from:s.from,insert:o.text+i.lineBreak});for(let a of s.ranges)r.push(C.range(Math.min(i.doc.length,a.anchor+l),Math.min(i.doc.length,a.head+l)))}else{n.push({from:o.from,to:s.from},{from:s.to,insert:i.lineBreak+o.text});for(let a of s.ranges)r.push(C.range(a.anchor-l,a.head-l))}}return n.length?(t(i.update({changes:n,scrollIntoView:!0,selection:C.create(r,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const d$=({state:i,dispatch:t})=>N0(i,t,!1),O$=({state:i,dispatch:t})=>N0(i,t,!0);function G0(i,t,e){if(i.readOnly)return!1;let n=[];for(let s of Lc(i))e?n.push({from:s.from,insert:i.doc.slice(s.from,s.to)+i.lineBreak}):n.push({from:s.to,insert:i.lineBreak+i.doc.slice(s.from,s.to)});let r=i.changes(n);return t(i.update({changes:r,selection:i.selection.map(r,e?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const p$=({state:i,dispatch:t})=>G0(i,t,!1),m$=({state:i,dispatch:t})=>G0(i,t,!0),g$=i=>{if(i.state.readOnly)return!1;let{state:t}=i,e=t.changes(Lc(t).map(({from:r,to:s})=>(r>0?r--:s<t.doc.length&&s++,{from:r,to:s}))),n=fo(t.selection,r=>{let s;if(i.lineWrapping){let o=i.lineBlockAt(r.head),l=i.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+i.documentTop-l.bottom+i.defaultLineHeight/2)}return i.moveVertically(r,!0,s)}).map(e);return i.dispatch({changes:e,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function b$(i,t){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=St(i).resolveInner(t),n=e.childBefore(t),r=e.childAfter(t),s;return n&&r&&n.to<=t&&r.from>=t&&(s=n.type.prop(N.closedBy))&&s.indexOf(r.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(r.from).from&&!/\S/.test(i.sliceDoc(n.to,r.from))?{from:n.to,to:r.from}:null}const wp=U0(!1),w$=U0(!0);function U0(i){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{let{from:s,to:o}=r,l=t.doc.lineAt(s),a=!i&&s==o&&b$(t,s);i&&(s=o=(o<=l.to?l:t.doc.lineAt(o)).to);let c=new Ac(t,{simulateBreak:s,simulateDoubleBreak:!!a}),h=f0(c,s);for(h==null&&(h=an(/^\s*/.exec(t.doc.lineAt(s).text)[0],t.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let u=["",qa(t,h)];return a&&u.push(qa(t,c.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:Y.of(u)},range:C.cursor(s+1+u[1].length)}});return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ff(i,t){let e=-1;return i.changeByRange(n=>{let r=[];for(let o=n.from;o<=n.to;){let l=i.doc.lineAt(o);l.number>e&&(n.empty||n.to>l.from)&&(t(l,r,n),e=l.number),o=l.to+1}let s=i.changes(r);return{changes:r,range:C.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}const S$=({state:i,dispatch:t})=>{if(i.readOnly)return!1;let e=Object.create(null),n=new Ac(i,{overrideIndentation:s=>{let o=e[s];return o??-1}}),r=Ff(i,(s,o,l)=>{let a=f0(n,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let c=/^\s*/.exec(s.text)[0],h=qa(i,a);(c!=h||l.from<s.from+c.length)&&(e[s.from]=a,o.push({from:s.from,to:s.from+c.length,insert:h}))});return r.changes.empty||t(i.update(r,{userEvent:"indent"})),!0},H0=({state:i,dispatch:t})=>i.readOnly?!1:(t(i.update(Ff(i,(e,n)=>{n.push({from:e.from,insert:i.facet(uo)})}),{userEvent:"input.indent"})),!0),F0=({state:i,dispatch:t})=>i.readOnly?!1:(t(i.update(Ff(i,(e,n)=>{let r=/^\s*/.exec(e.text)[0];if(!r)return;let s=an(r,i.tabSize),o=0,l=qa(i,Math.max(0,s-Ya(i)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;n.push({from:e.from+o,to:e.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),v$=i=>(i.setTabFocusMode(),!0),x$=[{key:"Ctrl-b",run:$0,shift:L0,preventDefault:!0},{key:"Ctrl-f",run:C0,shift:M0},{key:"Ctrl-p",run:A0,shift:I0},{key:"Ctrl-n",run:R0,shift:j0},{key:"Ctrl-a",run:DQ,shift:JQ},{key:"Ctrl-e",run:VQ,shift:t$},{key:"Ctrl-d",run:W0},{key:"Ctrl-h",run:zu},{key:"Ctrl-k",run:a$},{key:"Ctrl-Alt-h",run:q0},{key:"Ctrl-o",run:u$},{key:"Ctrl-t",run:f$},{key:"Ctrl-v",run:Mu}],y$=[{key:"ArrowLeft",run:$0,shift:L0,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ZQ,shift:YQ,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:IQ,shift:FQ,preventDefault:!0},{key:"ArrowRight",run:C0,shift:M0,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:XQ,shift:qQ,preventDefault:!0},{mac:"Cmd-ArrowRight",run:jQ,shift:KQ,preventDefault:!0},{key:"ArrowUp",run:A0,shift:I0,preventDefault:!0},{mac:"Cmd-ArrowUp",run:pp,shift:gp},{mac:"Ctrl-ArrowUp",run:fp,shift:dp},{key:"ArrowDown",run:R0,shift:j0,preventDefault:!0},{mac:"Cmd-ArrowDown",run:mp,shift:bp},{mac:"Ctrl-ArrowDown",run:Mu,shift:Op},{key:"PageUp",run:fp,shift:dp},{key:"PageDown",run:Mu,shift:Op},{key:"Home",run:_Q,shift:HQ,preventDefault:!0},{key:"Mod-Home",run:pp,shift:gp},{key:"End",run:zQ,shift:UQ,preventDefault:!0},{key:"Mod-End",run:mp,shift:bp},{key:"Enter",run:wp,shift:wp},{key:"Mod-a",run:e$},{key:"Backspace",run:zu,shift:zu,preventDefault:!0},{key:"Delete",run:W0,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:q0,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:l$,preventDefault:!0},{mac:"Mod-Backspace",run:c$,preventDefault:!0},{mac:"Mod-Delete",run:h$,preventDefault:!0}].concat(x$.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),K0=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:LQ,shift:NQ},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:MQ,shift:GQ},{key:"Alt-ArrowUp",run:d$},{key:"Shift-Alt-ArrowUp",run:p$},{key:"Alt-ArrowDown",run:O$},{key:"Shift-Alt-ArrowDown",run:m$},{key:"Mod-Alt-ArrowUp",run:r$},{key:"Mod-Alt-ArrowDown",run:s$},{key:"Escape",run:o$},{key:"Mod-Enter",run:w$},{key:"Alt-l",mac:"Ctrl-l",run:i$},{key:"Mod-i",run:n$,preventDefault:!0},{key:"Mod-[",run:F0},{key:"Mod-]",run:H0},{key:"Mod-Alt-\\",run:S$},{key:"Shift-Mod-k",run:g$},{key:"Shift-Mod-\\",run:WQ},{key:"Mod-/",run:dQ},{key:"Alt-A",run:pQ},{key:"Ctrl-m",mac:"Shift-Alt-m",run:v$}].concat(y$),k$={key:"Tab",run:H0,shift:F0};class Q${constructor(t,e,n,r){this.state=t,this.pos=e,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=St(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),r=e.text.slice(n-e.from,this.pos-e.from),s=r.search(T$(t));return s<0?null:{from:n+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(t,e,n){t=="abort"&&this.abortListeners&&(this.abortListeners.push(e),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Sp(i){let t=Object.keys(i).join(""),e=/\w/.test(t);return e&&(t=t.replace(/\w/g,"")),`[${e?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function $$(i){let t=Object.create(null),e=Object.create(null);for(let{label:r}of i){t[r[0]]=!0;for(let s=1;s<r.length;s++)e[r[s]]=!0}let n=Sp(t)+Sp(e)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function C$(i){let t=i.map(r=>typeof r=="string"?{label:r}:r),[e,n]=t.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:$$(t);return r=>{let s=r.matchBefore(n);return s||r.explicit?{from:s?s.from:r.pos,options:t,validFor:e}:null}}function P$(i,t){return e=>{for(let n=St(e.state).resolveInner(e.pos,-1);n;n=n.parent){if(i.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return t(e)}}function T$(i,t){var e;let{source:n}=i,r=n[n.length-1]!="$";return r?new RegExp(`(?:${n})${r?"$":""}`,(e=i.flags)!==null&&e!==void 0?e:i.ignoreCase?"i":""):i}const A$=Ke.define(),R$=z.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Z${constructor(t,e,n,r){this.field=t,this.line=e,this.from=n,this.to=r}}class Kf{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,Oe.TrackDel),n=t.mapPos(this.to,1,Oe.TrackDel);return e==null||n==null?null:new Kf(this.field,e,n)}}class Jf{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],r=[e],s=t.doc.lineAt(e),o=/^\s*/.exec(s.text)[0];for(let a of this.lines){if(n.length){let c=o,h=/^\t*/.exec(a)[0].length;for(let u=0;u<h;u++)c+=t.facet(uo);r.push(e+c.length-h),a=c+a.slice(h)}n.push(a),e+=a.length+1}let l=this.fieldPositions.map(a=>new Kf(a.field,r[a.line]+a.from,r[a.line]+a.to));return{text:n,ranges:l}}static parse(t){let e=[],n=[],r=[],s;for(let o of t.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=s[1]?+s[1]:null,a=s[2]||s[3]||"",c=-1,h=a.replace(/\\[{}]/g,u=>u[1]);for(let u=0;u<e.length;u++)(l!=null?e[u].seq==l:h&&e[u].name==h)&&(c=u);if(c<0){let u=0;for(;u<e.length&&(l==null||e[u].seq!=null&&e[u].seq<l);)u++;e.splice(u,0,{seq:l,name:h}),c=u;for(let f of r)f.field>=c&&f.field++}for(let u of r)if(u.line==n.length&&u.from>s.index){let f=s[2]?3+(s[1]||"").length:2;u.from-=f,u.to-=f}r.push(new Z$(c,n.length,s.index,s.index+h.length)),o=o.slice(0,s.index)+a+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(l,a,c)=>{for(let h of r)h.line==n.length&&h.from>c&&(h.from--,h.to--);return a}),n.push(o)}return new Jf(n,r)}}let X$=J.widget({widget:new class extends jn{toDOM(){let i=document.createElement("span");return i.className="cm-snippetFieldPosition",i}ignoreEvent(){return!1}}}),E$=J.mark({class:"cm-snippetField"});class Oo{constructor(t,e){this.ranges=t,this.active=e,this.deco=J.set(t.map(n=>(n.from==n.to?X$:E$).range(n.from,n.to)),!0)}map(t){let e=[];for(let n of this.ranges){let r=n.map(t);if(!r)return null;e.push(r)}return new Oo(e,this.active)}selectionInsideField(t){return t.ranges.every(e=>this.ranges.some(n=>n.field==this.active&&n.from<=e.from&&n.to>=e.to))}}const Tl=Ct.define({map(i,t){return i&&i.map(t)}}),L$=Ct.define(),nl=bi.define({create(){return null},update(i,t){for(let e of t.effects){if(e.is(Tl))return e.value;if(e.is(L$)&&i)return new Oo(i.ranges,e.value)}return i&&t.docChanged&&(i=i.map(t.changes)),i&&t.selection&&!i.selectionInsideField(t.selection)&&(i=null),i},provide:i=>z.decorations.from(i,t=>t?t.deco:J.none)});function td(i,t){return C.create(i.filter(e=>e.field==t).map(e=>C.range(e.from,e.to)))}function M$(i){let t=Jf.parse(i);return(e,n,r,s)=>{let{text:o,ranges:l}=t.instantiate(e.state,r),{main:a}=e.state.selection,c={changes:{from:r,to:s==a.from?a.to:s,insert:Y.of(o)},scrollIntoView:!0,annotations:n?[A$.of(n),Pt.userEvent.of("input.complete")]:void 0};if(l.length&&(c.selection=td(l,0)),l.some(h=>h.field>0)){let h=new Oo(l,0),u=c.effects=[Tl.of(h)];e.state.field(nl,!1)===void 0&&u.push(Ct.appendConfig.of([nl,D$,V$,R$]))}e.dispatch(e.state.update(c))}}function J0(i){return({state:t,dispatch:e})=>{let n=t.field(nl,!1);if(!n||i<0&&n.active==0)return!1;let r=n.active+i,s=i>0&&!n.ranges.some(o=>o.field==r+i);return e(t.update({selection:td(n.ranges,r),effects:Tl.of(s?null:new Oo(n.ranges,r)),scrollIntoView:!0})),!0}}const z$=({state:i,dispatch:t})=>i.field(nl,!1)?(t(i.update({effects:Tl.of(null)})),!0):!1,_$=J0(1),I$=J0(-1),j$=[{key:"Tab",run:_$,shift:I$},{key:"Escape",run:z$}],vp=V.define({combine(i){return i.length?i[0]:j$}}),D$=hn.highest(Dn.compute([vp],i=>i.facet(vp)));function we(i,t){return{...t,apply:M$(i)}}const V$=z.domEventHandlers({mousedown(i,t){let e=t.state.field(nl,!1),n;if(!e||(n=t.posAtCoords({x:i.clientX,y:i.clientY}))==null)return!1;let r=e.ranges.find(s=>s.from<=n&&s.to>=n);return!r||r.field==e.active?!1:(t.dispatch({selection:td(e.ranges,r.field),effects:Tl.of(e.ranges.some(s=>s.field>r.field)?new Oo(e.ranges,r.field):null),scrollIntoView:!0}),!0)}}),tw=new class extends Zn{};tw.startSide=1;tw.endSide=-1;class Ua{static create(t,e,n,r,s){let o=r+(r<<8)+t+(e<<4)|0;return new Ua(t,e,n,o,s,[],[])}constructor(t,e,n,r,s,o,l){this.type=t,this.value=e,this.from=n,this.hash=r,this.end=s,this.children=o,this.positions=l,this.hashProp=[[N.contextHash,r]]}addChild(t,e){t.prop(N.contextHash)!=this.hash&&(t=new ht(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(e)}toTree(t,e=this.end){let n=this.children.length-1;return n>=0&&(e=Math.max(e,this.positions[n]+this.children[n].length+this.from)),new ht(t.types[this.type],this.children,this.positions,e-this.from).balance({makeTree:(r,s,o)=>new ht(qt.none,r,s,o,this.hashProp)})}}var T;(function(i){i[i.Document=1]="Document",i[i.CodeBlock=2]="CodeBlock",i[i.FencedCode=3]="FencedCode",i[i.Blockquote=4]="Blockquote",i[i.HorizontalRule=5]="HorizontalRule",i[i.BulletList=6]="BulletList",i[i.OrderedList=7]="OrderedList",i[i.ListItem=8]="ListItem",i[i.ATXHeading1=9]="ATXHeading1",i[i.ATXHeading2=10]="ATXHeading2",i[i.ATXHeading3=11]="ATXHeading3",i[i.ATXHeading4=12]="ATXHeading4",i[i.ATXHeading5=13]="ATXHeading5",i[i.ATXHeading6=14]="ATXHeading6",i[i.SetextHeading1=15]="SetextHeading1",i[i.SetextHeading2=16]="SetextHeading2",i[i.HTMLBlock=17]="HTMLBlock",i[i.LinkReference=18]="LinkReference",i[i.Paragraph=19]="Paragraph",i[i.CommentBlock=20]="CommentBlock",i[i.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",i[i.Escape=22]="Escape",i[i.Entity=23]="Entity",i[i.HardBreak=24]="HardBreak",i[i.Emphasis=25]="Emphasis",i[i.StrongEmphasis=26]="StrongEmphasis",i[i.Link=27]="Link",i[i.Image=28]="Image",i[i.InlineCode=29]="InlineCode",i[i.HTMLTag=30]="HTMLTag",i[i.Comment=31]="Comment",i[i.ProcessingInstruction=32]="ProcessingInstruction",i[i.Autolink=33]="Autolink",i[i.HeaderMark=34]="HeaderMark",i[i.QuoteMark=35]="QuoteMark",i[i.ListMark=36]="ListMark",i[i.LinkMark=37]="LinkMark",i[i.EmphasisMark=38]="EmphasisMark",i[i.CodeMark=39]="CodeMark",i[i.CodeText=40]="CodeText",i[i.CodeInfo=41]="CodeInfo",i[i.LinkTitle=42]="LinkTitle",i[i.LinkLabel=43]="LinkLabel",i[i.URL=44]="URL"})(T||(T={}));class B${constructor(t,e){this.start=t,this.content=e,this.marks=[],this.parsers=[]}}class W${constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return Vo(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,e=0,n=0){for(let r=e;r<t;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(t){let e=0;for(let n=0;e<this.text.length&&n<t;e++)n+=this.text.charCodeAt(e)==9?4-n%4:1;return e}scrub(){if(!this.baseIndent)return this.text;let t="";for(let e=0;e<this.basePos;e++)t+=" ";return t+this.text.slice(this.basePos)}}function xp(i,t,e){if(e.pos==e.text.length||i!=t.block&&e.indent>=t.stack[e.depth+1].value+e.baseIndent)return!0;if(e.indent>=e.baseIndent+4)return!1;let n=(i.type==T.OrderedList?nd:id)(e,t,!1);return n>0&&(i.type!=T.BulletList||ed(e,t,!1)<0)&&e.text.charCodeAt(e.pos+n-1)==i.value}const ew={[T.Blockquote](i,t,e){return e.next!=62?!1:(e.markers.push(st(T.QuoteMark,t.lineStart+e.pos,t.lineStart+e.pos+1)),e.moveBase(e.pos+(ti(e.text.charCodeAt(e.pos+1))?2:1)),i.end=t.lineStart+e.text.length,!0)},[T.ListItem](i,t,e){return e.indent<e.baseIndent+i.value&&e.next>-1?!1:(e.moveBaseColumn(e.baseIndent+i.value),!0)},[T.OrderedList]:xp,[T.BulletList]:xp,[T.Document](){return!0}};function ti(i){return i==32||i==9||i==10||i==13}function Vo(i,t=0){for(;t<i.length&&ti(i.charCodeAt(t));)t++;return t}function yp(i,t,e){for(;t>e&&ti(i.charCodeAt(t-1));)t--;return t}function iw(i){if(i.next!=96&&i.next!=126)return-1;let t=i.pos+1;for(;t<i.text.length&&i.text.charCodeAt(t)==i.next;)t++;if(t<i.pos+3)return-1;if(i.next==96){for(let e=t;e<i.text.length;e++)if(i.text.charCodeAt(e)==96)return-1}return t}function nw(i){return i.next!=62?-1:i.text.charCodeAt(i.pos+1)==32?2:1}function ed(i,t,e){if(i.next!=42&&i.next!=45&&i.next!=95)return-1;let n=1;for(let r=i.pos+1;r<i.text.length;r++){let s=i.text.charCodeAt(r);if(s==i.next)n++;else if(!ti(s))return-1}return e&&i.next==45&&ow(i)>-1&&i.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(hw.SetextHeading)>-1||n<3?-1:1}function rw(i,t){for(let e=i.stack.length-1;e>=0;e--)if(i.stack[e].type==t)return!0;return!1}function id(i,t,e){return(i.next==45||i.next==43||i.next==42)&&(i.pos==i.text.length-1||ti(i.text.charCodeAt(i.pos+1)))&&(!e||rw(t,T.BulletList)||i.skipSpace(i.pos+2)<i.text.length)?1:-1}function nd(i,t,e){let n=i.pos,r=i.next;for(;r>=48&&r<=57;){n++;if(n==i.text.length)return-1;r=i.text.charCodeAt(n)}return n==i.pos||n>i.pos+9||r!=46&&r!=41||n<i.text.length-1&&!ti(i.text.charCodeAt(n+1))||e&&!rw(t,T.OrderedList)&&(i.skipSpace(n+1)==i.text.length||n>i.pos+1||i.next!=49)?-1:n+1-i.pos}function sw(i){if(i.next!=35)return-1;let t=i.pos+1;for(;t<i.text.length&&i.text.charCodeAt(t)==35;)t++;if(t<i.text.length&&i.text.charCodeAt(t)!=32)return-1;let e=t-i.pos;return e>6?-1:e}function ow(i){if(i.next!=45&&i.next!=61||i.indent>=i.baseIndent+4)return-1;let t=i.pos+1;for(;t<i.text.length&&i.text.charCodeAt(t)==i.next;)t++;let e=t;for(;t<i.text.length&&ti(i.text.charCodeAt(t));)t++;return t==i.text.length?e:-1}const _u=/^[ \t]*$/,lw=/-->/,aw=/\?>/,Iu=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,lw],[/^\s*<\?/,aw],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,_u],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,_u]];function cw(i,t,e){if(i.next!=60)return-1;let n=i.text.slice(i.pos);for(let r=0,s=Iu.length-(e?1:0);r<s;r++)if(Iu[r][0].test(n))return r;return-1}function kp(i,t){let e=i.countIndent(t,i.pos,i.indent),n=i.countIndent(i.skipSpace(t),t,e);return n>=e+5?e+1:n}function On(i,t,e){let n=i.length-1;n>=0&&i[n].to==t&&i[n].type==T.CodeText?i[n].to=e:i.push(st(T.CodeText,t,e))}const ia={LinkReference:void 0,IndentedCode(i,t){let e=t.baseIndent+4;if(t.indent<e)return!1;let n=t.findColumn(e),r=i.lineStart+n,s=i.lineStart+t.text.length,o=[],l=[];for(On(o,r,s);i.nextLine()&&t.depth>=i.stack.length;)if(t.pos==t.text.length){On(l,i.lineStart-1,i.lineStart);for(let a of t.markers)l.push(a)}else{if(t.indent<e)break;{if(l.length){for(let c of l)c.type==T.CodeText?On(o,c.from,c.to):o.push(c);l=[]}On(o,i.lineStart-1,i.lineStart);for(let c of t.markers)o.push(c);s=i.lineStart+t.text.length;let a=i.lineStart+t.findColumn(t.baseIndent+4);a<s&&On(o,a,s)}}return l.length&&(l=l.filter(a=>a.type!=T.CodeText),l.length&&(t.markers=l.concat(t.markers))),i.addNode(i.buffer.writeElements(o,-r).finish(T.CodeBlock,s-r),r),!0},FencedCode(i,t){let e=iw(t);if(e<0)return!1;let n=i.lineStart+t.pos,r=t.next,s=e-t.pos,o=t.skipSpace(e),l=yp(t.text,t.text.length,o),a=[st(T.CodeMark,n,n+s)];o<l&&a.push(st(T.CodeInfo,i.lineStart+o,i.lineStart+l));for(let c=!0,h=!0,u=!1;i.nextLine()&&t.depth>=i.stack.length;c=!1){let f=t.pos;if(t.indent-t.baseIndent<4)for(;f<t.text.length&&t.text.charCodeAt(f)==r;)f++;if(f-t.pos>=s&&t.skipSpace(f)==t.text.length){for(let d of t.markers)a.push(d);h&&u&&On(a,i.lineStart-1,i.lineStart),a.push(st(T.CodeMark,i.lineStart+t.pos,i.lineStart+f)),i.nextLine();break}else{u=!0,c||(On(a,i.lineStart-1,i.lineStart),h=!1);for(let p of t.markers)a.push(p);let d=i.lineStart+t.basePos,O=i.lineStart+t.text.length;d<O&&(On(a,d,O),h=!1)}}return i.addNode(i.buffer.writeElements(a,-n).finish(T.FencedCode,i.prevLineEnd()-n),n),!0},Blockquote(i,t){let e=nw(t);return e<0?!1:(i.startContext(T.Blockquote,t.pos),i.addNode(T.QuoteMark,i.lineStart+t.pos,i.lineStart+t.pos+1),t.moveBase(t.pos+e),null)},HorizontalRule(i,t){if(ed(t,i,!1)<0)return!1;let e=i.lineStart+t.pos;return i.nextLine(),i.addNode(T.HorizontalRule,e),!0},BulletList(i,t){let e=id(t,i,!1);if(e<0)return!1;i.block.type!=T.BulletList&&i.startContext(T.BulletList,t.basePos,t.next);let n=kp(t,t.pos+1);return i.startContext(T.ListItem,t.basePos,n-t.baseIndent),i.addNode(T.ListMark,i.lineStart+t.pos,i.lineStart+t.pos+e),t.moveBaseColumn(n),null},OrderedList(i,t){let e=nd(t,i,!1);if(e<0)return!1;i.block.type!=T.OrderedList&&i.startContext(T.OrderedList,t.basePos,t.text.charCodeAt(t.pos+e-1));let n=kp(t,t.pos+e);return i.startContext(T.ListItem,t.basePos,n-t.baseIndent),i.addNode(T.ListMark,i.lineStart+t.pos,i.lineStart+t.pos+e),t.moveBaseColumn(n),null},ATXHeading(i,t){let e=sw(t);if(e<0)return!1;let n=t.pos,r=i.lineStart+n,s=yp(t.text,t.text.length,n),o=s;for(;o>n&&t.text.charCodeAt(o-1)==t.next;)o--;(o==s||o==n||!ti(t.text.charCodeAt(o-1)))&&(o=t.text.length);let l=i.buffer.write(T.HeaderMark,0,e).writeElements(i.parser.parseInline(t.text.slice(n+e+1,o),r+e+1),-r);o<t.text.length&&l.write(T.HeaderMark,o-n,s-n);let a=l.finish(T.ATXHeading1-1+e,t.text.length-n);return i.nextLine(),i.addNode(a,r),!0},HTMLBlock(i,t){let e=cw(t,i,!1);if(e<0)return!1;let n=i.lineStart+t.pos,r=Iu[e][1],s=[],o=r!=_u;for(;!r.test(t.text)&&i.nextLine();){if(t.depth<i.stack.length){o=!1;break}for(let c of t.markers)s.push(c)}o&&i.nextLine();let l=r==lw?T.CommentBlock:r==aw?T.ProcessingInstructionBlock:T.HTMLBlock,a=i.prevLineEnd();return i.addNode(i.buffer.writeElements(s,-n).finish(l,a-n),n),!0},SetextHeading:void 0};class Y${constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,e,n){if(this.stage==-1)return!1;let r=n.content+`
39
39
  `+e.scrub(),s=this.advance(r);return s>-1&&s<r.length?this.complete(t,n,s):!1}finish(t,e){return(this.stage==2||this.stage==3)&&Vo(e.content,this.pos)==e.content.length?this.complete(t,e,e.content.length):!1}complete(t,e,n){return t.addLeafElement(e,st(T.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(t){return t?(this.pos=t.to-this.start,this.elts.push(t),this.stage++,!0):(t===!1&&(this.stage=-1),!1)}advance(t){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(ww(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(st(T.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(gw(t,Vo(t,this.pos),this.start)))return-1}else if(this.stage==2){let e=Vo(t,this.pos),n=0;if(e>this.pos){let r=bw(t,e,this.start);if(r){let s=Sh(t,r.to-this.start);s>0&&(this.nextStage(r),n=s)}}return n||(n=Sh(t,this.pos)),n>0&&n<t.length?n:-1}else return Sh(t,this.pos)}}}function Sh(i,t){for(;t<i.length;t++){let e=i.charCodeAt(t);if(e==10)break;if(!ti(e))return-1}return t}class q${nextLine(t,e,n){let r=e.depth<t.stack.length?-1:ow(e),s=e.next;if(r<0)return!1;let o=st(T.HeaderMark,t.lineStart+e.pos,t.lineStart+r);return t.nextLine(),t.addLeafElement(n,st(s==61?T.SetextHeading1:T.SetextHeading2,n.start,t.prevLineEnd(),[...t.parser.parseInline(n.content,n.start),o])),!0}finish(){return!1}}const hw={LinkReference(i,t){return t.content.charCodeAt(0)==91?new Y$(t):null},SetextHeading(){return new q$}},N$=[(i,t)=>sw(t)>=0,(i,t)=>iw(t)>=0,(i,t)=>nw(t)>=0,(i,t)=>id(t,i,!0)>=0,(i,t)=>nd(t,i,!0)>=0,(i,t)=>ed(t,i,!0)>=0,(i,t)=>cw(t,i,!0)>=0],G$={text:"",end:0};class U${constructor(t,e,n,r){this.parser=t,this.input=e,this.ranges=r,this.line=new W$,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=Ua.create(T.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new K$(n,e):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:t}=this;for(;;){for(let n=0;;){let r=t.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;n<t.markers.length&&(!r||t.markers[n].from<r.end);){let s=t.markers[n++];this.addNode(s.type,s.from,s.to)}if(!r)break;this.finishContext()}if(t.pos<t.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(t.basePos))return null;t:for(;;){for(let n of this.parser.blockParsers)if(n){let r=n(this,t);if(r!=!1){if(r==!0)return null;t.forward();continue t}}break}let e=new B$(this.lineStart+t.pos,t.text.slice(t.pos));for(let n of this.parser.leafBlockParsers)if(n){let r=n(this,e);r&&e.parsers.push(r)}t:for(;this.nextLine()&&t.pos!=t.text.length;){if(t.indent<t.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,t,e))break t}for(let n of e.parsers)if(n.nextLine(this,t,e))return null;e.content+=`
40
40
  `+t.scrub();for(let n of t.markers)e.marks.push(n)}return this.finishLeaf(e),null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}reuseFragment(t){if(!this.fragments.moveTo(this.absoluteLineStart+t,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let e=this.fragments.takeNodes(this);return e?(this.absoluteLineStart+=e,this.lineStart=Sw(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(t=this.depth-1){return this.parser.nodeSet.types[this.stack[t].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(t){let e=G$;if(e.end=t,t>=this.to)e.text="";else if(e.text=this.lineChunkAt(t),e.end+=e.text.length,this.ranges.length>1){let n=this.absoluteLineStart,r=this.rangeI;for(;this.ranges[r].to<e.end;){r++;let s=this.ranges[r].from,o=this.lineChunkAt(s);e.end=s+o.length,e.text=e.text.slice(0,this.ranges[r-1].to-n)+o,n=e.end-e.text.length}}return e}readLine(){let{line:t}=this,{text:e,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,t.reset(e);t.depth<this.stack.length;t.depth++){let r=this.stack[t.depth],s=this.parser.skipContextMarkup[r.type];if(!s)throw new Error("Unhandled block context "+T[r.type]);let o=this.line.markers.length;if(!s(r,this,t)){this.line.markers.length>o&&(r.end=this.line.markers[this.line.markers.length-1].to),t.forward();break}t.forward()}}lineChunkAt(t){let e=this.input.chunk(t),n;if(this.input.lineChunks)n=e==`
41
41
  `?"":e;else{let r=e.indexOf(`
@@ -52,13 +52,13 @@
52
52
  constructor(\${params}) {
53
53
  \${}
54
54
  }
55
- }`,{label:"class",detail:"definition",type:"keyword"}),we('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),we('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],b2=Vw.concat([we("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),we("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),we("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),em=new o0,Bw=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Qo(i){return(t,e)=>{let n=t.node.getChild("VariableDefinition");return n&&e(n,i),!0}}const w2=["FunctionDeclaration"],S2={FunctionDeclaration:Qo("function"),ClassDeclaration:Qo("class"),ClassExpression:()=>!0,EnumDeclaration:Qo("constant"),TypeAliasDeclaration:Qo("type"),NamespaceDeclaration:Qo("namespace"),VariableDefinition(i,t){i.matchContext(w2)||t(i,"variable")},TypeDefinition(i,t){t(i,"type")},__proto__:null};function Ww(i,t){let e=em.get(t);if(e)return e;let n=[],r=!0;function s(o,l){let a=i.sliceString(o.from,o.to);n.push({label:a,type:l})}return t.cursor(ft.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let l=S2[o.name];if(l&&l(o,s)||Bw.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of Ww(i,o.node))n.push(l);return!1}}),em.set(t,n),n}const im=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Yw=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function v2(i){let t=St(i.state).resolveInner(i.pos,-1);if(Yw.indexOf(t.name)>-1)return null;let e=t.name=="VariableName"||t.to-t.from<20&&im.test(i.state.sliceDoc(t.from,t.to));if(!e&&!i.explicit)return null;let n=[];for(let r=t;r;r=r.parent)Bw.has(r.name)&&(n=n.concat(Ww(i.state.doc,r)));return{options:n,from:e?t.from:i.pos,validFor:im}}const ji=Hs.define({name:"javascript",parser:g2.configure({props:[$l.add({IfStatement:va({except:/^\s*({|else\b)/}),TryStatement:va({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:tQ,SwitchBody:i=>{let t=i.textAfter,e=/^\s*\}/.test(t),n=/^\s*(case|default)\b/.test(t);return i.baseIndent+(e?0:n?1:2)*i.unit},Block:Jk({closing:"}"}),ArrowFunction:i=>i.baseIndent+i.unit,"TemplateString BlockComment":()=>null,"Statement Property":va({except:/^\s*{/}),JSXElement(i){let t=/^\s*<\//.test(i.textAfter);return i.lineIndent(i.node.from)+(t?0:i.unit)},JSXEscape(i){let t=/\s*\}/.test(i.textAfter);return i.lineIndent(i.node.from)+(t?0:i.unit)},"JSXOpenTag JSXSelfClosingTag"(i){return i.column(i.node.from)+i.unit}}),Cl.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":p0,BlockComment(i){return{from:i.from+2,to:i.to-2}},JSXElement(i){let t=i.firstChild;if(!t||t.name=="JSXSelfClosingTag")return null;let e=i.lastChild;return{from:t.to,to:e.type.isError?i.to:e.from}},"JSXSelfClosingTag JSXOpenTag"(i){var t;let e=(t=i.firstChild)===null||t===void 0?void 0:t.nextSibling,n=i.lastChild;return!e||e.type.isError?null:{from:e.to,to:n.type.isError?i.to:n.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),qw={test:i=>/^JSX/.test(i.name),facet:Wf({commentTokens:{block:{open:"{/*",close:"*/}"}}})},Nw=ji.configure({dialect:"ts"},"typescript"),Gw=ji.configure({dialect:"jsx",props:[Yf.add(i=>i.isTop?[qw]:void 0)]}),Uw=ji.configure({dialect:"jsx ts",props:[Yf.add(i=>i.isTop?[qw]:void 0)]},"typescript");let Hw=i=>({label:i,type:"keyword"});const Fw="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Hw),x2=Fw.concat(["declare","implements","private","protected","public"].map(Hw));function y2(i={}){let t=i.jsx?i.typescript?Uw:Gw:i.typescript?Nw:ji,e=i.typescript?b2.concat(x2):Vw.concat(Fw);return new il(t,[ji.data.of({autocomplete:P$(Yw,C$(e))}),ji.data.of({autocomplete:v2}),i.jsx?$2:[]])}function k2(i){for(;;){if(i.name=="JSXOpenTag"||i.name=="JSXSelfClosingTag"||i.name=="JSXFragmentTag")return i;if(i.name=="JSXEscape"||!i.parent)return null;i=i.parent}}function nm(i,t,e=i.length){for(let n=t==null?void 0:t.firstChild;n;n=n.nextSibling)if(n.name=="JSXIdentifier"||n.name=="JSXBuiltin"||n.name=="JSXNamespacedName"||n.name=="JSXMemberExpression")return i.sliceString(n.from,Math.min(n.to,e));return""}const Q2=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),$2=z.inputHandler.of((i,t,e,n,r)=>{if((Q2?i.composing:i.compositionStarted)||i.state.readOnly||t!=e||n!=">"&&n!="/"||!ji.isActiveAt(i.state,t,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(a=>{var c;let{head:h}=a,u=St(o).resolveInner(h-1,-1),f;if(u.name=="JSXStartTag"&&(u=u.parent),!(o.doc.sliceString(h-1,h)!=n||u.name=="JSXAttributeValue"&&u.to>h)){if(n==">"&&u.name=="JSXFragmentTag")return{range:a,changes:{from:h,insert:"</>"}};if(n=="/"&&u.name=="JSXStartCloseTag"){let d=u.parent,O=d.parent;if(O&&d.from==h-2&&((f=nm(o.doc,O.firstChild,h))||((c=O.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let p=`${f}>`;return{range:C.cursor(h+p.length,-1),changes:{from:h,insert:p}}}}else if(n==">"){let d=k2(u);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(h,h+2))&&(f=nm(o.doc,d,h)))return{range:a,changes:{from:h,insert:`</${f}>`}}}}return{range:a}});return l.changes.empty?!1:(i.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),$o=["_blank","_self","_top","_parent"],Th=["ascii","utf-8","utf-16","latin1","latin1"],Ah=["get","post","put","delete"],Rh=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Pe=["true","false"],j={},C2={a:{attrs:{href:null,ping:null,type:null,media:null,target:$o,hreflang:null}},abbr:j,address:j,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:j,aside:j,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:j,base:{attrs:{href:null,target:$o}},bdi:j,bdo:j,blockquote:{attrs:{cite:null}},body:j,br:j,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:Rh,formmethod:Ah,formnovalidate:["novalidate"],formtarget:$o,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:j,center:j,cite:j,code:j,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:j,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:j,div:j,dl:j,dt:j,em:j,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:j,figure:j,footer:j,form:{attrs:{action:null,name:null,"accept-charset":Th,autocomplete:["on","off"],enctype:Rh,method:Ah,novalidate:["novalidate"],target:$o}},h1:j,h2:j,h3:j,h4:j,h5:j,h6:j,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:j,hgroup:j,hr:j,html:{attrs:{manifest:null}},i:j,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:Rh,formmethod:Ah,formnovalidate:["novalidate"],formtarget:$o,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:j,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:j,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:j,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:Th,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:j,noscript:j,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:j,param:{attrs:{name:null,value:null}},pre:j,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:j,rt:j,ruby:j,samp:j,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:Th}},section:j,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:j,source:{attrs:{src:null,type:null,media:null}},span:j,strong:j,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:j,summary:j,sup:j,table:j,tbody:j,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:j,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:j,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:j,time:{attrs:{datetime:null}},title:j,tr:j,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:j,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:j},Kw={accesskey:null,class:null,contenteditable:Pe,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Pe,autocorrect:Pe,autocapitalize:Pe,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Pe,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Pe,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Pe,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Pe,"aria-hidden":Pe,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Pe,"aria-multiselectable":Pe,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Pe,"aria-relevant":null,"aria-required":Pe,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Jw="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(i=>"on"+i);for(let i of Jw)Kw[i]=null;class ll{constructor(t,e){this.tags={...C2,...t},this.globalAttrs={...Kw,...e},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}ll.default=new ll;function eo(i,t,e=i.length){if(!t)return"";let n=t.firstChild,r=n&&n.getChild("TagName");return r?i.sliceString(r.from,Math.min(r.to,e)):""}function io(i,t=!1){for(;i;i=i.parent)if(i.name=="Element")if(t)t=!1;else return i;return null}function t1(i,t,e){let n=e.tags[eo(i,io(t))];return(n==null?void 0:n.children)||e.allTags}function hd(i,t){let e=[];for(let n=io(t);n&&!n.type.isTop;n=io(n.parent)){let r=eo(i,n);if(r&&n.lastChild.name=="CloseTag")break;r&&e.indexOf(r)<0&&(t.name=="EndTag"||t.from>=n.firstChild.to)&&e.push(r)}return e}const e1=/^[:\-\.\w\u00b7-\uffff]*$/;function rm(i,t,e,n,r){let s=/\s*>/.test(i.sliceDoc(r,r+5))?"":">",o=io(e,e.name=="StartTag"||e.name=="TagName");return{from:n,to:r,options:t1(i.doc,o,t).map(l=>({label:l,type:"type"})).concat(hd(i.doc,e).map((l,a)=>({label:"/"+l,apply:"/"+l+s,type:"type",boost:99-a}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function sm(i,t,e,n){let r=/\s*>/.test(i.sliceDoc(n,n+5))?"":">";return{from:e,to:n,options:hd(i.doc,t).map((s,o)=>({label:s,apply:s+r,type:"type",boost:99-o})),validFor:e1}}function P2(i,t,e,n){let r=[],s=0;for(let o of t1(i.doc,e,t))r.push({label:"<"+o,type:"type"});for(let o of hd(i.doc,e))r.push({label:"</"+o+">",type:"type",boost:99-s++});return{from:n,to:n,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function T2(i,t,e,n,r){let s=io(e),o=s?t.tags[eo(i.doc,s)]:null,l=o&&o.attrs?Object.keys(o.attrs):[],a=o&&o.globalAttrs===!1?l:l.length?l.concat(t.globalAttrNames):t.globalAttrNames;return{from:n,to:r,options:a.map(c=>({label:c,type:"property"})),validFor:e1}}function A2(i,t,e,n,r){var s;let o=(s=e.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),l=[],a;if(o){let c=i.sliceDoc(o.from,o.to),h=t.globalAttrs[c];if(!h){let u=io(e),f=u?t.tags[eo(i.doc,u)]:null;h=(f==null?void 0:f.attrs)&&f.attrs[c]}if(h){let u=i.sliceDoc(n,r).toLowerCase(),f='"',d='"';/^['"]/.test(u)?(a=u[0]=='"'?/^[^"]*$/:/^[^']*$/,f="",d=i.sliceDoc(r,r+1)==u[0]?"":u[0],u=u.slice(1),n++):a=/^[^\s<>='"]*$/;for(let O of h)l.push({label:O,apply:f+O+d,type:"constant"})}}return{from:n,to:r,options:l,validFor:a}}function i1(i,t){let{state:e,pos:n}=t,r=St(e).resolveInner(n,-1),s=r.resolve(n);for(let o=n,l;s==r&&(l=r.childBefore(o));){let a=l.lastChild;if(!a||!a.type.isError||a.from<a.to)break;s=r=l,o=a.from}return r.name=="TagName"?r.parent&&/CloseTag$/.test(r.parent.name)?sm(e,r,r.from,n):rm(e,i,r,r.from,n):r.name=="StartTag"||r.name=="IncompleteTag"?rm(e,i,r,n,n):r.name=="StartCloseTag"||r.name=="IncompleteCloseTag"?sm(e,r,n,n):r.name=="OpenTag"||r.name=="SelfClosingTag"||r.name=="AttributeName"?T2(e,i,r,r.name=="AttributeName"?r.from:n,n):r.name=="Is"||r.name=="AttributeValue"||r.name=="UnquotedAttributeValue"?A2(e,i,r,r.name=="Is"?n:r.from,n):t.explicit&&(s.name=="Element"||s.name=="Text"||s.name=="Document")?P2(e,i,r,n):null}function R2(i){return i1(ll.default,i)}function Z2(i){let{extraTags:t,extraGlobalAttributes:e}=i,n=e||t?new ll(t,e):ll.default;return r=>i1(n,r)}const X2=ji.parser.configure({top:"SingleExpression"}),n1=[{tag:"script",attrs:i=>i.type=="text/typescript"||i.lang=="ts",parser:Nw.parser},{tag:"script",attrs:i=>i.type=="text/babel"||i.type=="text/jsx",parser:Gw.parser},{tag:"script",attrs:i=>i.type=="text/typescript-jsx",parser:Uw.parser},{tag:"script",attrs(i){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(i.type)},parser:X2},{tag:"script",attrs(i){return!i.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(i.type)},parser:ji.parser},{tag:"style",attrs(i){return(!i.lang||i.lang=="css")&&(!i.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(i.type))},parser:ec.parser}],r1=[{name:"style",parser:ec.parser.configure({top:"Styles"})}].concat(Jw.map(i=>({name:i,parser:ji.parser}))),s1=Hs.define({name:"html",parser:rP.configure({props:[$l.add({Element(i){let t=/^(\s*)(<\/)?/.exec(i.textAfter);return i.node.to<=i.pos+t[0].length?i.continue():i.lineIndent(i.node.from)+(t[2]?0:i.unit)},"OpenTag CloseTag SelfClosingTag"(i){return i.column(i.node.from)+i.unit},Document(i){if(i.pos+/\s*/.exec(i.textAfter)[0].length<i.node.to)return i.continue();let t=null,e;for(let n=i.node;;){let r=n.lastChild;if(!r||r.name!="Element"||r.to!=n.to)break;t=n=r}return t&&!((e=t.lastChild)&&(e.name=="CloseTag"||e.name=="SelfClosingTag"))?i.lineIndent(t.from)+i.unit:null}}),Cl.add({Element(i){let t=i.firstChild,e=i.lastChild;return!t||t.name!="OpenTag"?null:{from:t.to,to:e.name=="CloseTag"?e.from:i.to}}}),g0.add({"OpenTag CloseTag":i=>i.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),Qa=s1.configure({wrap:Lw(n1,r1)});function E2(i={}){let t="",e;i.matchClosingTags===!1&&(t="noMatch"),i.selfClosingTags===!0&&(t=(t?t+" ":"")+"selfClosing"),(i.nestedLanguages&&i.nestedLanguages.length||i.nestedAttributes&&i.nestedAttributes.length)&&(e=Lw((i.nestedLanguages||[]).concat(n1),(i.nestedAttributes||[]).concat(r1)));let n=e?s1.configure({wrap:e,dialect:t}):t?Qa.configure({dialect:t}):Qa;return new il(n,[Qa.data.of({autocomplete:Z2(i)}),i.autoCloseTags!==!1?L2:[],y2().support,jP().support])}const om=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),L2=z.inputHandler.of((i,t,e,n,r)=>{if(i.composing||i.state.readOnly||t!=e||n!=">"&&n!="/"||!Qa.isActiveAt(i.state,t,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(a=>{var c,h,u;let f=o.doc.sliceString(a.from-1,a.to)==n,{head:d}=a,O=St(o).resolveInner(d,-1),p;if(f&&n==">"&&O.name=="EndTag"){let m=O.parent;if(((h=(c=m.parent)===null||c===void 0?void 0:c.lastChild)===null||h===void 0?void 0:h.name)!="CloseTag"&&(p=eo(o.doc,m.parent,d))&&!om.has(p)){let g=d+(o.doc.sliceString(d,d+1)===">"?1:0),b=`</${p}>`;return{range:a,changes:{from:d,to:g,insert:b}}}}else if(f&&n=="/"&&O.name=="IncompleteCloseTag"){let m=O.parent;if(O.from==d-2&&((u=m.lastChild)===null||u===void 0?void 0:u.name)!="CloseTag"&&(p=eo(o.doc,m,d))&&!om.has(p)){let g=d+(o.doc.sliceString(d,d+1)===">"?1:0),b=`${p}>`;return{range:C.cursor(d+b.length,-1),changes:{from:d,to:g,insert:b}}}}return{range:a}});return l.changes.empty?!1:(i.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),o1=Wf({commentTokens:{block:{open:"<!--",close:"-->"}}}),l1=new N,a1=tC.configure({props:[Cl.add(i=>!i.is("Block")||i.is("Document")||qu(i)!=null||M2(i)?void 0:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})),l1.add(qu),$l.add({Document:()=>null}),rr.add({Document:o1})]});function qu(i){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(i.name);return t?+t[1]:void 0}function M2(i){return i.name=="OrderedList"||i.name=="BulletList"}function z2(i,t){let e=i;for(;;){let n=e.nextSibling,r;if(!n||(r=qu(n.type))!=null&&r<=t)break;e=n}return e.to}const _2=eQ.of((i,t,e)=>{for(let n=St(i).resolveInner(e,-1);n&&!(n.from<t);n=n.parent){let r=n.type.prop(l1);if(r==null)continue;let s=z2(n,r);if(s>e)return{from:e,to:s}}return null});function ud(i){return new Ie(o1,i,[],"markdown")}const I2=ud(a1),j2=a1.configure([cC,uC,hC,fC,{props:[Cl.add({Table:(i,t)=>({from:t.doc.lineAt(i.from).to,to:i.to})})]}]),ic=ud(j2);function D2(i,t){return e=>{if(e&&i){let n=null;if(e=/\S*/.exec(e)[0],typeof i=="function"?n=i(e):n=Wa.matchLanguageName(i,e,!0),n instanceof Wa)return n.support?n.support.language.parser:el.getSkippingParser(n.load());if(n)return n.parser}return t?t.parser:null}}class Zh{constructor(t,e,n,r,s,o,l){this.node=t,this.from=e,this.to=n,this.spaceBefore=r,this.spaceAfter=s,this.type=o,this.item=l}blank(t,e=!0){let n=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(t!=null){for(;n.length<t;)n+=" ";return n}else{for(let r=this.to-this.from-n.length-this.spaceAfter.length;r>0;r--)n+=" ";return n+(e?this.spaceAfter:"")}}marker(t,e){let n=this.node.name=="OrderedList"?String(+h1(this.item,t)[2]+e):"";return this.spaceBefore+n+this.type+this.spaceAfter}}function c1(i,t){let e=[],n=[];for(let r=i;r;r=r.parent){if(r.name=="FencedCode")return n;(r.name=="ListItem"||r.name=="Blockquote")&&e.push(r)}for(let r=e.length-1;r>=0;r--){let s=e[r],o,l=t.lineAt(s.from),a=s.from-l.from;if(s.name=="Blockquote"&&(o=/^ *>( ?)/.exec(l.text.slice(a))))n.push(new Zh(s,a,a+o[0].length,"",o[1],">",null));else if(s.name=="ListItem"&&s.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(l.text.slice(a)))){let c=o[3],h=o[0].length;c.length>=4&&(c=c.slice(0,c.length-4),h-=4),n.push(new Zh(s.parent,a,a+h,o[1],c,o[2],s))}else if(s.name=="ListItem"&&s.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(a)))){let c=o[4],h=o[0].length;c.length>4&&(c=c.slice(0,c.length-4),h-=4);let u=o[2];o[3]&&(u+=o[3].replace(/[xX]/," ")),n.push(new Zh(s.parent,a,a+h,o[1],c,u,s))}}return n}function h1(i,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(i.from,i.from+10))}function Xh(i,t,e,n=0){for(let r=-1,s=i;;){if(s.name=="ListItem"){let l=h1(s,t),a=+l[2];if(r>=0){if(a!=r+1)return;e.push({from:s.from+l[1].length,to:s.from+l[0].length,insert:String(r+2+n)})}r=a}let o=s.nextSibling;if(!o)break;s=o}}function fd(i,t){let e=/^[ \t]*/.exec(i)[0].length;if(!e||t.facet(uo)!=" ")return i;let n=an(i,4,e),r="";for(let s=n;s>0;)s>=4?(r+=" ",s-=4):(r+=" ",s--);return r+i.slice(e)}const u1=(i={})=>({state:t,dispatch:e})=>{let n=St(t),{doc:r}=t,s=null,o=t.changeByRange(l=>{if(!l.empty||!ic.isActiveAt(t,l.from,-1)&&!ic.isActiveAt(t,l.from,1))return s={range:l};let a=l.from,c=r.lineAt(a),h=c1(n.resolveInner(a,-1),r);for(;h.length&&h[h.length-1].from>a-c.from;)h.pop();if(!h.length)return s={range:l};let u=h[h.length-1];if(u.to-u.spaceAfter.length>a-c.from)return s={range:l};let f=a>=u.to-u.spaceAfter.length&&!/\S/.test(c.text.slice(u.to));if(u.item&&f){let g=u.node.firstChild,b=u.node.getChild("ListItem","ListItem");if(g.to>=a||b&&b.to<a||c.from>0&&!/[^\s>]/.test(r.lineAt(c.from-1).text)||i.nonTightLists===!1){let S=h.length>1?h[h.length-2]:null,x,y="";S&&S.item?(x=c.from+S.from,y=S.marker(r,1)):x=c.from+(S?S.to:0);let k=[{from:x,to:a,insert:y}];return u.node.name=="OrderedList"&&Xh(u.item,r,k,-2),S&&S.node.name=="OrderedList"&&Xh(S.item,r,k),{range:C.cursor(x+y.length),changes:k}}else{let S=am(h,t,c);return{range:C.cursor(a+S.length+1),changes:{from:c.from,insert:S+t.lineBreak}}}}if(u.node.name=="Blockquote"&&f&&c.from){let g=r.lineAt(c.from-1),b=/>\s*$/.exec(g.text);if(b&&b.index==u.from){let S=t.changes([{from:g.from+b.index,to:g.to},{from:c.from+u.from,to:c.to}]);return{range:l.map(S),changes:S}}}let d=[];u.node.name=="OrderedList"&&Xh(u.item,r,d);let O=u.item&&u.item.from<c.from,p="";if(!O||/^[\s\d.)\-+*>]*/.exec(c.text)[0].length>=u.to)for(let g=0,b=h.length-1;g<=b;g++)p+=g==b&&!O?h[g].marker(r,1):h[g].blank(g<b?an(c.text,4,h[g+1].from)-p.length:null);let m=a;for(;m>c.from&&/\s/.test(c.text.charAt(m-c.from-1));)m--;return p=fd(p,t),B2(u.node,t.doc)&&(p=am(h,t,c)+t.lineBreak+p),d.push({from:m,to:a,insert:t.lineBreak+p}),{range:C.cursor(m+p.length+1),changes:d}});return s?!1:(e(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},V2=u1();function lm(i){return i.name=="QuoteMark"||i.name=="ListMark"}function B2(i,t){if(i.name!="OrderedList"&&i.name!="BulletList")return!1;let e=i.firstChild,n=i.getChild("ListItem","ListItem");if(!n)return!1;let r=t.lineAt(e.to),s=t.lineAt(n.from),o=/^[\s>]*$/.test(r.text);return r.number+(o?0:1)<s.number}function am(i,t,e){let n="";for(let r=0,s=i.length-2;r<=s;r++)n+=i[r].blank(r<s?an(e.text,4,i[r+1].from)-n.length:null,r<s);return fd(n,t)}function W2(i,t){let e=i.resolveInner(t,-1),n=t;lm(e)&&(n=e.from,e=e.parent);for(let r;r=e.childBefore(n);)if(lm(r))n=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")e=r.lastChild,n=e.to;else break;return e}const Y2=({state:i,dispatch:t})=>{let e=St(i),n=null,r=i.changeByRange(s=>{let o=s.from,{doc:l}=i;if(s.empty&&ic.isActiveAt(i,s.from)){let a=l.lineAt(o),c=c1(W2(e,o),l);if(c.length){let h=c[c.length-1],u=h.to-h.spaceAfter.length+(h.spaceAfter?1:0);if(o-a.from>u&&!/\S/.test(a.text.slice(u,o-a.from)))return{range:C.cursor(a.from+u),changes:{from:a.from+u,to:o}};if(o-a.from==u&&(!h.item||a.from<=h.item.from||!/\S/.test(a.text.slice(0,h.to)))){let f=a.from+h.from;if(h.item&&h.node.from<h.item.from&&/\S/.test(a.text.slice(h.from,h.to))){let d=h.blank(an(a.text,4,h.to)-an(a.text,4,h.from));return f==a.from&&(d=fd(d,i)),{range:C.cursor(f+d.length),changes:{from:f,to:a.from+h.to,insert:d}}}if(f<o)return{range:C.cursor(f),changes:{from:f,to:o}}}}}return n={range:s}});return n?!1:(t(i.update(r,{scrollIntoView:!0,userEvent:"delete"})),!0)},q2=[{key:"Enter",run:V2},{key:"Backspace",run:Y2}],f1=E2({matchClosingTags:!1});function zc(i={}){let{codeLanguages:t,defaultCodeLanguage:e,addKeymap:n=!0,base:{parser:r}=I2,completeHTMLTags:s=!0,pasteURLAsLink:o=!0,htmlTagLanguage:l=f1}=i;if(!(r instanceof Mc))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let a=i.extensions?[i.extensions]:[],c=[l.support,_2],h;o&&c.push(H2),e instanceof il?(c.push(e.support),h=e.language):e&&(h=e);let u=t||h?D2(t,h):void 0;a.push(iC({codeParser:u,htmlParser:l.language.parser})),n&&c.push(hn.high(Dn.of(q2)));let f=ud(r.configure(a));return s&&c.push(f.data.of({autocomplete:N2})),new il(f,c)}function N2(i){let{state:t,pos:e}=i,n=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(e-25,e));if(!n)return null;let r=St(t).resolveInner(e,-1);for(;r&&!r.type.isTop;){if(r.name=="CodeBlock"||r.name=="FencedCode"||r.name=="ProcessingInstructionBlock"||r.name=="CommentBlock"||r.name=="Link"||r.name=="Image")return null;r=r.parent}return{from:e-n[0].length,to:e,options:G2(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let Eh=null;function G2(){if(Eh)return Eh;let i=R2(new Q$(K.create({extensions:f1}),0,!0));return Eh=i?i.options:[]}const U2=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,H2=z.domEventHandlers({paste:(i,t)=>{var e;let{main:n}=t.state.selection;if(n.empty)return!1;let r=(e=i.clipboardData)===null||e===void 0?void 0:e.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!ic.isActiveAt(t.state,n.from,1)))return!1;let s=St(t.state),o=!1;return s.iterate({from:n.from,to:n.to,enter:l=>{(l.from>n.from||U2.test(l.name))&&(o=!0)},leave:l=>{l.to<n.to&&(o=!0)}}),o?!1:(t.dispatch({changes:[{from:n.from,insert:"["},{from:n.to,insert:`](${r})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}});function F2(i,t){return i>t?i:t}function K2(i,t){if(i<=0)return[];for(var e=new Array(i),n=0;n<i;++n)e[n]=t;return e}function J2(i,t){for(var e=i.length,n=t<0?F2(e+t|0,0):t,r=e-n|0,s=new Array(r),o=0;o<r;++o)s[o]=i[n+o|0];return s}function tT(i,t,e,n,r){for(;;){var s=e;if(s===r)return!0;if(!n(i[s],t[s]))return!1;e=s+1|0}}function eT(i,t,e){var n=i.length,r=t.length;return n===r?tT(i,t,0,e,n):!1}var cm=K2;function dd(){if(arguments.length===1){const i=arguments;return function(e){return cm(e,i[0])}}return cm(arguments[0],arguments[1])}function iT(i){var t=i.length;if(t===1)return[];if(t!==0){var e=J2(i,1);if(e.length!==0)return e}}function nT(i){var t=iT(i);return t!==void 0?t:[]}var hm=eT;function rT(){if(arguments.length===2){const i=arguments;return function(e){return hm(e,i[0],i[1])}}return hm(arguments[0],arguments[1],arguments[2])}function sT(i){return typeof i=="string"}function oT(i){return i==null}function lT(i){return i!=null}const aT=Object.freeze(Object.defineProperty({__proto__:null,isNotNullable:lT,isNullable:oT,isString:sT},Symbol.toStringTag,{value:"Module"}));function um(i,t){return i.repeat(t)}function cT(){if(arguments.length===1){const i=arguments;return function(e){return um(e,i[0])}}return um(arguments[0],arguments[1])}function d1(i){for(var t={},e=i.length,n=0;n<e;++n){var r=i[n];t[r[0]]=r[1]}return t}function hT(i,t){for(var e=i.length,n=t.length,r=new Array(e+n|0),s=0;s<e;++s)r[s]=i[s];for(var o=0;o<n;++o)r[e+o|0]=t[o];return r}function O1(i,t,e){for(var n=t,r=0,s=i.length;r<s;++r)n=e(n,i[r]);return n}function fm(i,t){return hT(i,[t])}function p1(){if(arguments.length===1){const i=arguments;return function(e){return fm(e,i[0])}}return fm(arguments[0],arguments[1])}function dm(i,t){return d1(O1(Object.keys(i),[],function(e,n){var r=i[n];return t(r)?p1(e,[n,r]):e}))}function uT(){if(arguments.length===1){const i=arguments;return function(e){return dm(e,i[0])}}return dm(arguments[0],arguments[1])}function Om(i,t){return d1(O1(Object.keys(i),[],function(e,n){var r=i[n];return t(n,r)?p1(e,[n,r]):e}))}function fT(){if(arguments.length===1){const i=arguments;return function(e){return Om(e,i[0])}}return Om(arguments[0],arguments[1])}function pm(i,t){return fT(i,function(e,n){return t.includes(e)})}function dT(){if(arguments.length===1){const i=arguments;return function(e){return pm(e,i[0])}}return pm(arguments[0],arguments[1])}function m1(i){var t,e,n="";if(typeof i=="string"||typeof i=="number")n+=i;else if(typeof i=="object")if(Array.isArray(i)){var r=i.length;for(t=0;t<r;t++)i[t]&&(e=m1(i[t]))&&(n&&(n+=" "),n+=e)}else for(e in i)i[e]&&(n&&(n+=" "),n+=e);return n}function OT(){for(var i,t,e=0,n="",r=arguments.length;e<r;e++)(i=arguments[e])&&(t=m1(i))&&(n&&(n+=" "),n+=t);return n}const pT=["top","right","bottom","left"],mm=["start","end"],gm=pT.reduce((i,t)=>i.concat(t,t+"-"+mm[0],t+"-"+mm[1]),[]),Nu=Math.min,Br=Math.max,nc=Math.round,Di=i=>({x:i,y:i}),mT={left:"right",right:"left",bottom:"top",top:"bottom"};function bm(i,t,e){return Br(i,Nu(t,e))}function Od(i,t){return typeof i=="function"?i(t):i}function Al(i){return i.split("-")[0]}function pr(i){return i.split("-")[1]}function g1(i){return i==="x"?"y":"x"}function b1(i){return i==="y"?"height":"width"}function pd(i){const t=i[0];return t==="t"||t==="b"?"y":"x"}function w1(i){return g1(pd(i))}function gT(i,t,e){e===void 0&&(e=!1);const n=pr(i),r=w1(i),s=b1(r);let o=r==="x"?n===(e?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=wm(o)),[o,wm(o)]}function bT(i){return i.includes("start")?i.replace("start","end"):i.replace("end","start")}function wm(i){const t=Al(i);return mT[t]+i.slice(t.length)}function wT(i){return{top:0,right:0,bottom:0,left:0,...i}}function ST(i){return typeof i!="number"?wT(i):{top:i,right:i,bottom:i,left:i}}function rc(i){const{x:t,y:e,width:n,height:r}=i;return{width:n,height:r,top:e,left:t,right:t+n,bottom:e+r,x:t,y:e}}function Sm(i,t,e){let{reference:n,floating:r}=i;const s=pd(t),o=w1(t),l=b1(o),a=Al(t),c=s==="y",h=n.x+n.width/2-r.width/2,u=n.y+n.height/2-r.height/2,f=n[l]/2-r[l]/2;let d;switch(a){case"top":d={x:h,y:n.y-r.height};break;case"bottom":d={x:h,y:n.y+n.height};break;case"right":d={x:n.x+n.width,y:u};break;case"left":d={x:n.x-r.width,y:u};break;default:d={x:n.x,y:n.y}}switch(pr(t)){case"start":d[o]-=f*(e&&c?-1:1);break;case"end":d[o]+=f*(e&&c?-1:1);break}return d}async function vT(i,t){var e;t===void 0&&(t={});const{x:n,y:r,platform:s,rects:o,elements:l,strategy:a}=i,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:f=!1,padding:d=0}=Od(t,i),O=ST(d),m=l[f?u==="floating"?"reference":"floating":u],g=rc(await s.getClippingRect({element:(e=await(s.isElement==null?void 0:s.isElement(m)))==null||e?m:m.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:h,strategy:a})),b=u==="floating"?{x:n,y:r,width:o.floating.width,height:o.floating.height}:o.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),x=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},y=rc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:S,strategy:a}):b);return{top:(g.top-y.top+O.top)/x.y,bottom:(y.bottom-g.bottom+O.bottom)/x.y,left:(g.left-y.left+O.left)/x.x,right:(y.right-g.right+O.right)/x.x}}const xT=50,yT=async(i,t,e)=>{const{placement:n="bottom",strategy:r="absolute",middleware:s=[],platform:o}=e,l=o.detectOverflow?o:{...o,detectOverflow:vT},a=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:i,floating:t,strategy:r}),{x:h,y:u}=Sm(c,n,a),f=n,d=0;const O={};for(let p=0;p<s.length;p++){const m=s[p];if(!m)continue;const{name:g,fn:b}=m,{x:S,y:x,data:y,reset:k}=await b({x:h,y:u,initialPlacement:n,placement:f,strategy:r,middlewareData:O,rects:c,platform:l,elements:{reference:i,floating:t}});h=S??h,u=x??u,O[g]={...O[g],...y},k&&d<xT&&(d++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(c=k.rects===!0?await o.getElementRects({reference:i,floating:t,strategy:r}):k.rects),{x:h,y:u}=Sm(c,f,a)),p=-1)}return{x:h,y:u,placement:f,strategy:r,middlewareData:O}};function kT(i,t,e){return(i?[...e.filter(r=>pr(r)===i),...e.filter(r=>pr(r)!==i)]:e.filter(r=>Al(r)===r)).filter(r=>i?pr(r)===i||(t?bT(r)!==r:!1):!0)}const QT=function(i){return i===void 0&&(i={}),{name:"autoPlacement",options:i,async fn(t){var e,n,r;const{rects:s,middlewareData:o,placement:l,platform:a,elements:c}=t,{crossAxis:h=!1,alignment:u,allowedPlacements:f=gm,autoAlignment:d=!0,...O}=Od(i,t),p=u!==void 0||f===gm?kT(u||null,d,f):f,m=await a.detectOverflow(t,O),g=((e=o.autoPlacement)==null?void 0:e.index)||0,b=p[g];if(b==null)return{};const S=gT(b,s,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==b)return{reset:{placement:p[0]}};const x=[m[Al(b)],m[S[0]],m[S[1]]],y=[...((n=o.autoPlacement)==null?void 0:n.overflows)||[],{placement:b,overflows:x}],k=p[g+1];if(k)return{data:{index:g+1,overflows:y},reset:{placement:k}};const Q=y.map(L=>{const V=pr(L.placement);return[L.placement,V&&h?L.overflows.slice(0,2).reduce((_,G)=>_+G,0):L.overflows[0],L.overflows]}).sort((L,V)=>L[1]-V[1]),B=((r=Q.filter(L=>L[2].slice(0,pr(L[0])?2:3).every(V=>V<=0))[0])==null?void 0:r[0])||Q[0][0];return B!==l?{data:{index:g+1,overflows:y},reset:{placement:B}}:{}}}},$T=function(i){return i===void 0&&(i={}),{name:"shift",options:i,async fn(t){const{x:e,y:n,placement:r,platform:s}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:a={fn:g=>{let{x:b,y:S}=g;return{x:b,y:S}}},...c}=Od(i,t),h={x:e,y:n},u=await s.detectOverflow(t,c),f=pd(Al(r)),d=g1(f);let O=h[d],p=h[f];if(o){const g=d==="y"?"top":"left",b=d==="y"?"bottom":"right",S=O+u[g],x=O-u[b];O=bm(S,O,x)}if(l){const g=f==="y"?"top":"left",b=f==="y"?"bottom":"right",S=p+u[g],x=p-u[b];p=bm(S,p,x)}const m=a.fn({...t,[d]:O,[f]:p});return{...m,data:{x:m.x-e,y:m.y-n,enabled:{[d]:o,[f]:l}}}}}};function _c(){return typeof window<"u"}function po(i){return S1(i)?(i.nodeName||"").toLowerCase():"#document"}function je(i){var t;return(i==null||(t=i.ownerDocument)==null?void 0:t.defaultView)||window}function un(i){var t;return(t=(S1(i)?i.ownerDocument:i.document)||window.document)==null?void 0:t.documentElement}function S1(i){return _c()?i instanceof Node||i instanceof je(i).Node:!1}function di(i){return _c()?i instanceof Element||i instanceof je(i).Element:!1}function fn(i){return _c()?i instanceof HTMLElement||i instanceof je(i).HTMLElement:!1}function vm(i){return!_c()||typeof ShadowRoot>"u"?!1:i instanceof ShadowRoot||i instanceof je(i).ShadowRoot}function Rl(i){const{overflow:t,overflowX:e,overflowY:n,display:r}=Oi(i);return/auto|scroll|overlay|hidden|clip/.test(t+n+e)&&r!=="inline"&&r!=="contents"}function CT(i){return/^(table|td|th)$/.test(po(i))}function Ic(i){try{if(i.matches(":popover-open"))return!0}catch{}try{return i.matches(":modal")}catch{return!1}}const PT=/transform|translate|scale|rotate|perspective|filter/,TT=/paint|layout|strict|content/,Nn=i=>!!i&&i!=="none";let Lh;function md(i){const t=di(i)?Oi(i):i;return Nn(t.transform)||Nn(t.translate)||Nn(t.scale)||Nn(t.rotate)||Nn(t.perspective)||!gd()&&(Nn(t.backdropFilter)||Nn(t.filter))||PT.test(t.willChange||"")||TT.test(t.contain||"")}function AT(i){let t=zn(i);for(;fn(t)&&!no(t);){if(md(t))return t;if(Ic(t))return null;t=zn(t)}return null}function gd(){return Lh==null&&(Lh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Lh}function no(i){return/^(html|body|#document)$/.test(po(i))}function Oi(i){return je(i).getComputedStyle(i)}function jc(i){return di(i)?{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}:{scrollLeft:i.scrollX,scrollTop:i.scrollY}}function zn(i){if(po(i)==="html")return i;const t=i.assignedSlot||i.parentNode||vm(i)&&i.host||un(i);return vm(t)?t.host:t}function v1(i){const t=zn(i);return no(t)?i.ownerDocument?i.ownerDocument.body:i.body:fn(t)&&Rl(t)?t:v1(t)}function x1(i,t,e){var n;t===void 0&&(t=[]);const r=v1(i),s=r===((n=i.ownerDocument)==null?void 0:n.body),o=je(r);return s?(Gu(o),t.concat(o,o.visualViewport||[],Rl(r)?r:[],[])):t.concat(r,x1(r,[]))}function Gu(i){return i.parent&&Object.getPrototypeOf(i.parent)?i.frameElement:null}function y1(i){const t=Oi(i);let e=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const r=fn(i),s=r?i.offsetWidth:e,o=r?i.offsetHeight:n,l=nc(e)!==s||nc(n)!==o;return l&&(e=s,n=o),{width:e,height:n,$:l}}function k1(i){return di(i)?i:i.contextElement}function Wr(i){const t=k1(i);if(!fn(t))return Di(1);const e=t.getBoundingClientRect(),{width:n,height:r,$:s}=y1(t);let o=(s?nc(e.width):e.width)/n,l=(s?nc(e.height):e.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const RT=Di(0);function Q1(i){const t=je(i);return!gd()||!t.visualViewport?RT:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ZT(i,t,e){return t===void 0&&(t=!1),!e||t&&e!==je(i)?!1:t}function al(i,t,e,n){t===void 0&&(t=!1),e===void 0&&(e=!1);const r=i.getBoundingClientRect(),s=k1(i);let o=Di(1);t&&(n?di(n)&&(o=Wr(n)):o=Wr(i));const l=ZT(s,e,n)?Q1(s):Di(0);let a=(r.left+l.x)/o.x,c=(r.top+l.y)/o.y,h=r.width/o.x,u=r.height/o.y;if(s){const f=je(s),d=n&&di(n)?je(n):n;let O=f,p=Gu(O);for(;p&&n&&d!==O;){const m=Wr(p),g=p.getBoundingClientRect(),b=Oi(p),S=g.left+(p.clientLeft+parseFloat(b.paddingLeft))*m.x,x=g.top+(p.clientTop+parseFloat(b.paddingTop))*m.y;a*=m.x,c*=m.y,h*=m.x,u*=m.y,a+=S,c+=x,O=je(p),p=Gu(O)}}return rc({width:h,height:u,x:a,y:c})}function Dc(i,t){const e=jc(i).scrollLeft;return t?t.left+e:al(un(i)).left+e}function $1(i,t){const e=i.getBoundingClientRect(),n=e.left+t.scrollLeft-Dc(i,e),r=e.top+t.scrollTop;return{x:n,y:r}}function XT(i){let{elements:t,rect:e,offsetParent:n,strategy:r}=i;const s=r==="fixed",o=un(n),l=t?Ic(t.floating):!1;if(n===o||l&&s)return e;let a={scrollLeft:0,scrollTop:0},c=Di(1);const h=Di(0),u=fn(n);if((u||!u&&!s)&&((po(n)!=="body"||Rl(o))&&(a=jc(n)),u)){const d=al(n);c=Wr(n),h.x=d.x+n.clientLeft,h.y=d.y+n.clientTop}const f=o&&!u&&!s?$1(o,a):Di(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-a.scrollLeft*c.x+h.x+f.x,y:e.y*c.y-a.scrollTop*c.y+h.y+f.y}}function ET(i){return Array.from(i.getClientRects())}function LT(i){const t=un(i),e=jc(i),n=i.ownerDocument.body,r=Br(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=Br(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let o=-e.scrollLeft+Dc(i);const l=-e.scrollTop;return Oi(n).direction==="rtl"&&(o+=Br(t.clientWidth,n.clientWidth)-r),{width:r,height:s,x:o,y:l}}const xm=25;function MT(i,t){const e=je(i),n=un(i),r=e.visualViewport;let s=n.clientWidth,o=n.clientHeight,l=0,a=0;if(r){s=r.width,o=r.height;const h=gd();(!h||h&&t==="fixed")&&(l=r.offsetLeft,a=r.offsetTop)}const c=Dc(n);if(c<=0){const h=n.ownerDocument,u=h.body,f=getComputedStyle(u),d=h.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,O=Math.abs(n.clientWidth-u.clientWidth-d);O<=xm&&(s-=O)}else c<=xm&&(s+=c);return{width:s,height:o,x:l,y:a}}function zT(i,t){const e=al(i,!0,t==="fixed"),n=e.top+i.clientTop,r=e.left+i.clientLeft,s=fn(i)?Wr(i):Di(1),o=i.clientWidth*s.x,l=i.clientHeight*s.y,a=r*s.x,c=n*s.y;return{width:o,height:l,x:a,y:c}}function ym(i,t,e){let n;if(t==="viewport")n=MT(i,e);else if(t==="document")n=LT(un(i));else if(di(t))n=zT(t,e);else{const r=Q1(i);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return rc(n)}function C1(i,t){const e=zn(i);return e===t||!di(e)||no(e)?!1:Oi(e).position==="fixed"||C1(e,t)}function _T(i,t){const e=t.get(i);if(e)return e;let n=x1(i,[]).filter(l=>di(l)&&po(l)!=="body"),r=null;const s=Oi(i).position==="fixed";let o=s?zn(i):i;for(;di(o)&&!no(o);){const l=Oi(o),a=md(o);!a&&l.position==="fixed"&&(r=null),(s?!a&&!r:!a&&l.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||Rl(o)&&!a&&C1(i,o))?n=n.filter(h=>h!==o):r=l,o=zn(o)}return t.set(i,n),n}function IT(i){let{element:t,boundary:e,rootBoundary:n,strategy:r}=i;const o=[...e==="clippingAncestors"?Ic(t)?[]:_T(t,this._c):[].concat(e),n],l=ym(t,o[0],r);let a=l.top,c=l.right,h=l.bottom,u=l.left;for(let f=1;f<o.length;f++){const d=ym(t,o[f],r);a=Br(d.top,a),c=Nu(d.right,c),h=Nu(d.bottom,h),u=Br(d.left,u)}return{width:c-u,height:h-a,x:u,y:a}}function jT(i){const{width:t,height:e}=y1(i);return{width:t,height:e}}function DT(i,t,e){const n=fn(t),r=un(t),s=e==="fixed",o=al(i,!0,s,t);let l={scrollLeft:0,scrollTop:0};const a=Di(0);function c(){a.x=Dc(r)}if(n||!n&&!s)if((po(t)!=="body"||Rl(r))&&(l=jc(t)),n){const d=al(t,!0,s,t);a.x=d.x+t.clientLeft,a.y=d.y+t.clientTop}else r&&c();s&&!n&&r&&c();const h=r&&!n&&!s?$1(r,l):Di(0),u=o.left+l.scrollLeft-a.x-h.x,f=o.top+l.scrollTop-a.y-h.y;return{x:u,y:f,width:o.width,height:o.height}}function Mh(i){return Oi(i).position==="static"}function km(i,t){if(!fn(i)||Oi(i).position==="fixed")return null;if(t)return t(i);let e=i.offsetParent;return un(i)===e&&(e=e.ownerDocument.body),e}function P1(i,t){const e=je(i);if(Ic(i))return e;if(!fn(i)){let r=zn(i);for(;r&&!no(r);){if(di(r)&&!Mh(r))return r;r=zn(r)}return e}let n=km(i,t);for(;n&&CT(n)&&Mh(n);)n=km(n,t);return n&&no(n)&&Mh(n)&&!md(n)?e:n||AT(i)||e}const VT=async function(i){const t=this.getOffsetParent||P1,e=this.getDimensions,n=await e(i.floating);return{reference:DT(i.reference,await t(i.floating),i.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function BT(i){return Oi(i).direction==="rtl"}const WT={convertOffsetParentRelativeRectToViewportRelativeRect:XT,getDocumentElement:un,getClippingRect:IT,getOffsetParent:P1,getElementRects:VT,getClientRects:ET,getDimensions:jT,getScale:Wr,isElement:di,isRTL:BT},YT=QT,qT=$T,NT=(i,t,e)=>{const n=new Map,r={platform:WT,...e},s={...r.platform,_c:n};return yT(i,t,{...r,platform:s})},{isNotNullable:GT,isNullable:UT,isString:HT}=aT,E=GT,W=UT;function T1(i){return uT(i,t=>E(t))}function FT(i,t){const e=new Array;for(const[n,r]of Object.entries(i))e.push(t(n,r));return e}function A1(i,t){return dT(i,t)}const KT=["--tbl-style-font-family","--tbl-style-font-size","--tbl-style-menu-font-family","--tbl-style-menu-font-size","--tbl-style-default-header-alignment"],tr=class tr{constructor(t){P(this,"props");this.props=t}with(t){return W(t)?tr.of({...this.props}):tr.of({...this.props,...T1(A1(t,KT))})}static of(t){return new tr(t)}};P(tr,"default",tr.of({"--tbl-style-font-family":"system-ui","--tbl-style-font-size":"inherit","--tbl-style-menu-font-family":"system-ui","--tbl-style-menu-font-size":"inherit","--tbl-style-default-header-alignment":"left"}));let sc=tr;const JT=["--tbl-theme-row-background","--tbl-theme-header-row-background","--tbl-theme-even-row-background","--tbl-theme-odd-row-background","--tbl-theme-border-color","--tbl-theme-border-hover-color","--tbl-theme-border-active-color","--tbl-theme-outline-color","--tbl-theme-text-color","--tbl-theme-menu-border-color","--tbl-theme-menu-background","--tbl-theme-menu-hover-background","--tbl-theme-menu-text-color","--tbl-theme-menu-hover-text-color","--tbl-theme-select-all-focus-overlay","--tbl-theme-select-all-blur-overlay"],Ht=class Ht{constructor(t){P(this,"props");this.props=t}with(t){return W(t)?Ht.of({...this.props}):Ht.of({...this.props,...T1(A1(t,JT))})}static of(t){return new Ht(t)}};P(Ht,"light",Ht.of({"--tbl-theme-row-background":"#ffffff","--tbl-theme-header-row-background":"var(--tbl-theme-row-background)","--tbl-theme-even-row-background":"var(--tbl-theme-row-background)","--tbl-theme-odd-row-background":"var(--tbl-theme-row-background)","--tbl-theme-border-color":"#dcdcdc","--tbl-theme-border-hover-color":"color-mix(in srgb, var(--tbl-theme-border-color), #000000 10%)","--tbl-theme-border-active-color":"color-mix(in srgb, var(--tbl-theme-border-color), #000000 20%)","--tbl-theme-outline-color":"#2483e2","--tbl-theme-text-color":"inherit","--tbl-theme-menu-border-color":"var(--tbl-theme-border-color)","--tbl-theme-menu-background":"var(--tbl-theme-header-row-background)","--tbl-theme-menu-hover-background":"var(--tbl-theme-outline-color)","--tbl-theme-menu-text-color":"#000000","--tbl-theme-menu-hover-text-color":"#ffffff","--tbl-theme-select-all-focus-overlay":"rgb(20 2 167 / 17%)","--tbl-theme-select-all-blur-overlay":"rgb(2 2 2 / 15%)"})),P(Ht,"dark",Ht.of({"--tbl-theme-row-background":"#1d2024","--tbl-theme-header-row-background":"var(--tbl-theme-row-background)","--tbl-theme-even-row-background":"var(--tbl-theme-row-background)","--tbl-theme-odd-row-background":"var(--tbl-theme-row-background)","--tbl-theme-border-color":"#464646","--tbl-theme-border-hover-color":"color-mix(in srgb, var(--tbl-theme-border-color), #708499 25%)","--tbl-theme-border-active-color":"color-mix(in srgb, var(--tbl-theme-border-color), #708499 65%)","--tbl-theme-outline-color":"#2483e2","--tbl-theme-text-color":"inherit","--tbl-theme-menu-border-color":"var(--tbl-theme-border-color)","--tbl-theme-menu-background":"color-mix(in srgb, var(--tbl-theme-header-row-background), #ffffff 5%)","--tbl-theme-menu-hover-background":"var(--tbl-theme-outline-color)","--tbl-theme-menu-text-color":"color-mix(in srgb, var(--tbl-theme-header-row-background), #ffffff 90%)","--tbl-theme-menu-hover-text-color":"var(--tbl-theme-menu-text-color)","--tbl-theme-select-all-focus-overlay":"rgb(252 246 239 / 35%)","--tbl-theme-select-all-blur-overlay":"rgb(246 232 214 / 18%)"})),P(Ht,"githubLight",Ht.light.with({"--tbl-theme-header-row-background":"#ffffff","--tbl-theme-even-row-background":"#ffffff","--tbl-theme-odd-row-background":"#f6f8fa","--tbl-theme-border-color":"#d1d9e0","--tbl-theme-menu-text-color":"color-mix(in srgb, var(--tbl-theme-header-row-background), #000000 90%)"})),P(Ht,"githubDark",Ht.dark.with({"--tbl-theme-header-row-background":"#0d1117","--tbl-theme-even-row-background":"#0d1117","--tbl-theme-odd-row-background":"#151b23","--tbl-theme-border-color":"#3d444d","--tbl-theme-select-all-focus-overlay":"rgb(254 248 238 / 39%)","--tbl-theme-select-all-blur-overlay":"rgb(252 239 219 / 23%)"})),P(Ht,"githubSoftDark",Ht.dark.with({"--tbl-theme-header-row-background":"#212830","--tbl-theme-even-row-background":"#212830","--tbl-theme-odd-row-background":"#262c36","--tbl-theme-border-color":"#3d444d","--tbl-theme-select-all-focus-overlay":"rgb(251 237 222 / 34%)","--tbl-theme-select-all-blur-overlay":"rgb(252 215 173 / 16%)"})),P(Ht,"oneDark",Ht.dark.with({"--tbl-theme-row-background":"#282c34","--tbl-theme-border-color":"#3b4048","--tbl-theme-outline-color":"#568af2","--tbl-theme-menu-background":"#21252b","--tbl-theme-menu-hover-background":"#2c313a","--tbl-theme-menu-text-color":"#abb2bf","--tbl-theme-select-all-focus-overlay":"rgb(187 204 245 / 15%)","--tbl-theme-select-all-blur-overlay":"rgb(187 204 245 / 15%)"}));let cl=Ht;function R1(i){var t,e,n,r;return{theme:(i==null?void 0:i.theme)??{light:cl.light,dark:cl.dark},style:(i==null?void 0:i.style)??sc.default,selectionType:(i==null?void 0:i.selectionType)??"codemirror",handlePosition:(i==null?void 0:i.handlePosition)??"outside",lineWrapping:(i==null?void 0:i.lineWrapping)??"wrap",markdownConfig:{extensions:((t=i==null?void 0:i.markdownConfig)==null?void 0:t.extensions)??void 0,completeHTMLTags:((e=i==null?void 0:i.markdownConfig)==null?void 0:e.completeHTMLTags)??void 0,pasteURLAsLink:((n=i==null?void 0:i.markdownConfig)==null?void 0:n.pasteURLAsLink)??void 0,htmlTagLanguage:((r=i==null?void 0:i.markdownConfig)==null?void 0:r.htmlTagLanguage)??void 0},extensions:(i==null?void 0:i.extensions)??[],globalKeyBindings:(i==null?void 0:i.globalKeyBindings)??[]}}function Z1(i){return i.ranges.length===1}function oc(i){return Z1(i)&&i.main.empty}function tA({pos:i,assoc:t,bidiLevel:e,goalColumn:n}){return C.create([C.cursor(i,t,e,n)])}function vt(i,{start:t,endExclusive:e}){}function sr({start:i,endExclusive:t},{within:e}={}){}function bd(i){sr({start:i.span.from,endExclusive:i.span.to},{within:{endExclusive:i.doc.length}});const t=eA(i),e=iA(i),n=[];return E(t)&&n.push({from:t.at,insert:t.insert}),E(e)&&n.push({from:e.at,insert:e.insert}),{before:t,after:e,changes:n}}function eA({doc:i,span:{from:t},lineBreak:e}){let n;if(t===0)n=1;else if(t===1)n=i.sliceString(t-1,t)===e?0:2;else{const r=i.sliceString(t-1,t),s=i.sliceString(t-2,t-1);r===e?n=s===e?0:1:n=2}return n===0?void 0:{at:t===0?0:t-1,insert:e.repeat(n),count:n}}function iA({doc:i,span:{to:t},lineBreak:e}){let n;if(t===i.length)n=1;else if(t===i.length-1)n=i.sliceString(t,t+1)===e?0:2;else{const r=i.sliceString(t,t+1),s=i.sliceString(t+1,t+2);r===e?n=s===e?0:1:n=2}return n===0?void 0:{at:t===i.length?i.length:t+1,insert:e.repeat(n),count:n}}const nA=["ATXHeading","Blockquote","BulletList","FencedCode","HTMLBlock","HorizontalRule","IndentedCode","LinkReference","OrderedList","SetextHeading"],rA={remove:nA},X1=[rA];function sA(){return zc({extensions:X1,completeHTMLTags:!1,addKeymap:!1}).language.parser}function oA(){return zc({extensions:sd,completeHTMLTags:!1,addKeymap:!1}).language.parser}function Cn({start:i,endExclusive:t}){return Iterator.from(i<=t?{*[Symbol.iterator](){for(let e=i;e<t;e++)yield e}}:{*[Symbol.iterator](){for(let e=i;e>t;e--)yield e}})}function lc(i,t){const e=new Array(i);for(let n=0;n<i;n++)e[n]=t(n);return e}function Lr(i,t){for(let e=0;e<i;e++)t(e)}function Tr(i,t){return Cn(i).map(e=>t(e)).toArray()}function $i(i,t){return Cn(i).forEach(e=>t(e))}const ac=Y.of(["",""]);function lA(i,{text:t,at:e,prependNewline:n=!1,appendNewline:r=!1}){return dA({needle:Vc(t,{prependNewline:n,appendNewline:r}),haystack:i,at:e})}function aA(i,{text:t,prependNewline:e=!1,appendNewline:n=!1}){return i.append(Vc(t,{prependNewline:e,appendNewline:n}))}function cA(i,{location:t,removeLeadingNewline:e=!1,removeTrailingNewline:n=!1}){const r=e?t.from-1:t.from,s=n?t.to+1:t.to;return r===s?i:i.replace(r,s,Y.empty)}function hA(i,{span:{from:t,to:e},text:n,prependNewline:r=!1,appendNewline:s=!1}){return i.replace(t,e,Vc(n,{prependNewline:r,appendNewline:s}))}function le(i){return Y.of([i])}function uA(i){return i.eq(Y.empty)}function fA(i,t){const e=i.lines;if(e===1){t(i,1);return}Lr(e,n=>{const r=i.line(n+1);t(i.slice(r.from,r.to),n+1)})}function zh(i,{from:t,to:e}){return i.slice(t,e)}function _h(i,t){if(t===0)return Y.empty;if(t===1)return i;let e=i;return Lr(t-1,()=>{e=e.append(i)}),e}function dA({needle:i,haystack:t,at:e}){return t.slice(0,e).append(i).append(t.slice(e))}function Vc(i,{prependNewline:t=!1,appendNewline:e=!1}){let n=i;return t&&(n=ac.append(n)),e&&(n=n.append(ac)),n}function OA(i){return i.name==="Document"}function cc(i){return i.firstChild(),i}function pA(i){return i.nextSibling(),i}function mA(i,t){const e=[];for(;i.nextSibling();)e.push(t(i));return e}function gA(i,t){const e=i.cursor();for(let n=e.next(!0);n;n=e.next(OA(e)))t(e)}function E1(i){return i.name==="Table"}function bA(i){return i.name==="TableDelimiter"}function wA(i){return i[0]}function SA(i){return i[i.length-1]}function vA(i,t){for(const e of i)t(e);return i}function Qm(i,t){const e=[];for(const n of i){const r=[];for(const s of n)r.push(t(s));e.push(r)}return e}function xA(i,t){return i.length<t.min?i.toSpliced(i.length,0,...dd(t.min-i.length,t.fillWith)):i.length>t.max?i.toSpliced(t.max,i.length-t.max):[...i]}function $m(i,{start:t,endExclusive:e}={start:0,endExclusive:i.length}){sr({start:t,endExclusive:e},{within:{endExclusive:i.length}});let n=0;for(let r=t;r<e;r++)n+=i[r];return n}function Ih(i,{start:t,endExclusive:e}={start:0,endExclusive:i.length}){return sr({start:t,endExclusive:e},{within:{endExclusive:i.length}}),i.slice(t,e)}function yA(i){if(i.length===0)return[];const t=new Array(i.length);t[0]=i[0];for(let e=1;e<i.length;e++)t[e]=t[e-1]+i[e];return t}function jh(i){return i.length===0?void 0:i}function kA(i,t){let e=i[0];for(let n=1;n<i.length;n++)t(i[n],e)<0&&(e=i[n]);return e}function ra(i,{count:t}){return dd(t,i)}function Cm(i,{rows:t,cols:e}){const n=[];for(let r=0;r<t;r++)n.push(dd(e,i));return n}function sa(i,t){if(t===0)return[];if(t===1)return[...i];const e=new Array(t*i.length);for(let n=0;n<t;n++){const r=n*i.length;for(let s=0;s<i.length;s++)e[r+s]=i[s]}return e}function QA(i){return i.filter(t=>E(t))}function Bc(i){return i.length===0}function $A(i){return nT(i)}function Pm(i){return{start:0,endExclusive:i.length}}function Ar(i,{fromIndex:t,toIndex:e}){if(vt(t,Pm(i)),vt(e,Pm(i)),t===e)return;const n=i[t];if(t<e)for(let r=t;r<e;r++)i[r]=i[r+1];else for(let r=t;r>e;r--)i[r]=i[r-1];i[e]=n}function bn(i,t,e){return W(i)||W(t)?i===t:rT(i,t,e)}function CA(i,t,e){return i.some(n=>e(n,t))}function ce(i,{min:t,max:e}){return E(t)&&i<=t?t:E(e)&&i>=e?e:i}const Uu=Math.abs,PA=Math.ceil,Tm=Math.floor,wd=Math.max,hc=Math.min,TA=Math.round,AA=Math.trunc,Am=globalThis.parseInt,L1=cT;function RA(i){return i===""?void 0:i}const ZA=new RegExp(new RegExp("(?<!\\\\)(\\\\\\\\)*\\|","g")),XA=[new RegExp(/^(\s|<br>)+/g),new RegExp(new RegExp("(?<=^\\u0000)(\\s|<br>)+","g")),new RegExp(new RegExp("(?<=^\\u0000\\u0000)(\\s|<br>)+","g"))],EA=[new RegExp(/(\s|<br>)+$/g),new RegExp(/(\s|<br>)+(?=\u0000$)/g),new RegExp(/(\s|<br>)+(?=\u0000\u0000$)/g)],LA=new RegExp(/\r\n|\n|\r/g);function Sd(i,t){return le(MA(i.toString(),t))}function uc(i){return Y.of(zA(i.toString()).split(`
55
+ }`,{label:"class",detail:"definition",type:"keyword"}),we('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),we('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],b2=Vw.concat([we("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),we("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),we("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),em=new o0,Bw=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Qo(i){return(t,e)=>{let n=t.node.getChild("VariableDefinition");return n&&e(n,i),!0}}const w2=["FunctionDeclaration"],S2={FunctionDeclaration:Qo("function"),ClassDeclaration:Qo("class"),ClassExpression:()=>!0,EnumDeclaration:Qo("constant"),TypeAliasDeclaration:Qo("type"),NamespaceDeclaration:Qo("namespace"),VariableDefinition(i,t){i.matchContext(w2)||t(i,"variable")},TypeDefinition(i,t){t(i,"type")},__proto__:null};function Ww(i,t){let e=em.get(t);if(e)return e;let n=[],r=!0;function s(o,l){let a=i.sliceString(o.from,o.to);n.push({label:a,type:l})}return t.cursor(ft.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let l=S2[o.name];if(l&&l(o,s)||Bw.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of Ww(i,o.node))n.push(l);return!1}}),em.set(t,n),n}const im=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Yw=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function v2(i){let t=St(i.state).resolveInner(i.pos,-1);if(Yw.indexOf(t.name)>-1)return null;let e=t.name=="VariableName"||t.to-t.from<20&&im.test(i.state.sliceDoc(t.from,t.to));if(!e&&!i.explicit)return null;let n=[];for(let r=t;r;r=r.parent)Bw.has(r.name)&&(n=n.concat(Ww(i.state.doc,r)));return{options:n,from:e?t.from:i.pos,validFor:im}}const ji=Hs.define({name:"javascript",parser:g2.configure({props:[$l.add({IfStatement:va({except:/^\s*({|else\b)/}),TryStatement:va({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:tQ,SwitchBody:i=>{let t=i.textAfter,e=/^\s*\}/.test(t),n=/^\s*(case|default)\b/.test(t);return i.baseIndent+(e?0:n?1:2)*i.unit},Block:Jk({closing:"}"}),ArrowFunction:i=>i.baseIndent+i.unit,"TemplateString BlockComment":()=>null,"Statement Property":va({except:/^\s*{/}),JSXElement(i){let t=/^\s*<\//.test(i.textAfter);return i.lineIndent(i.node.from)+(t?0:i.unit)},JSXEscape(i){let t=/\s*\}/.test(i.textAfter);return i.lineIndent(i.node.from)+(t?0:i.unit)},"JSXOpenTag JSXSelfClosingTag"(i){return i.column(i.node.from)+i.unit}}),Cl.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":p0,BlockComment(i){return{from:i.from+2,to:i.to-2}},JSXElement(i){let t=i.firstChild;if(!t||t.name=="JSXSelfClosingTag")return null;let e=i.lastChild;return{from:t.to,to:e.type.isError?i.to:e.from}},"JSXSelfClosingTag JSXOpenTag"(i){var t;let e=(t=i.firstChild)===null||t===void 0?void 0:t.nextSibling,n=i.lastChild;return!e||e.type.isError?null:{from:e.to,to:n.type.isError?i.to:n.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),qw={test:i=>/^JSX/.test(i.name),facet:Wf({commentTokens:{block:{open:"{/*",close:"*/}"}}})},Nw=ji.configure({dialect:"ts"},"typescript"),Gw=ji.configure({dialect:"jsx",props:[Yf.add(i=>i.isTop?[qw]:void 0)]}),Uw=ji.configure({dialect:"jsx ts",props:[Yf.add(i=>i.isTop?[qw]:void 0)]},"typescript");let Hw=i=>({label:i,type:"keyword"});const Fw="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Hw),x2=Fw.concat(["declare","implements","private","protected","public"].map(Hw));function y2(i={}){let t=i.jsx?i.typescript?Uw:Gw:i.typescript?Nw:ji,e=i.typescript?b2.concat(x2):Vw.concat(Fw);return new il(t,[ji.data.of({autocomplete:P$(Yw,C$(e))}),ji.data.of({autocomplete:v2}),i.jsx?$2:[]])}function k2(i){for(;;){if(i.name=="JSXOpenTag"||i.name=="JSXSelfClosingTag"||i.name=="JSXFragmentTag")return i;if(i.name=="JSXEscape"||!i.parent)return null;i=i.parent}}function nm(i,t,e=i.length){for(let n=t==null?void 0:t.firstChild;n;n=n.nextSibling)if(n.name=="JSXIdentifier"||n.name=="JSXBuiltin"||n.name=="JSXNamespacedName"||n.name=="JSXMemberExpression")return i.sliceString(n.from,Math.min(n.to,e));return""}const Q2=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),$2=z.inputHandler.of((i,t,e,n,r)=>{if((Q2?i.composing:i.compositionStarted)||i.state.readOnly||t!=e||n!=">"&&n!="/"||!ji.isActiveAt(i.state,t,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(a=>{var c;let{head:h}=a,u=St(o).resolveInner(h-1,-1),f;if(u.name=="JSXStartTag"&&(u=u.parent),!(o.doc.sliceString(h-1,h)!=n||u.name=="JSXAttributeValue"&&u.to>h)){if(n==">"&&u.name=="JSXFragmentTag")return{range:a,changes:{from:h,insert:"</>"}};if(n=="/"&&u.name=="JSXStartCloseTag"){let d=u.parent,O=d.parent;if(O&&d.from==h-2&&((f=nm(o.doc,O.firstChild,h))||((c=O.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let p=`${f}>`;return{range:C.cursor(h+p.length,-1),changes:{from:h,insert:p}}}}else if(n==">"){let d=k2(u);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(h,h+2))&&(f=nm(o.doc,d,h)))return{range:a,changes:{from:h,insert:`</${f}>`}}}}return{range:a}});return l.changes.empty?!1:(i.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),$o=["_blank","_self","_top","_parent"],Th=["ascii","utf-8","utf-16","latin1","latin1"],Ah=["get","post","put","delete"],Rh=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Pe=["true","false"],j={},C2={a:{attrs:{href:null,ping:null,type:null,media:null,target:$o,hreflang:null}},abbr:j,address:j,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:j,aside:j,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:j,base:{attrs:{href:null,target:$o}},bdi:j,bdo:j,blockquote:{attrs:{cite:null}},body:j,br:j,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:Rh,formmethod:Ah,formnovalidate:["novalidate"],formtarget:$o,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:j,center:j,cite:j,code:j,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:j,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:j,div:j,dl:j,dt:j,em:j,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:j,figure:j,footer:j,form:{attrs:{action:null,name:null,"accept-charset":Th,autocomplete:["on","off"],enctype:Rh,method:Ah,novalidate:["novalidate"],target:$o}},h1:j,h2:j,h3:j,h4:j,h5:j,h6:j,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:j,hgroup:j,hr:j,html:{attrs:{manifest:null}},i:j,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:Rh,formmethod:Ah,formnovalidate:["novalidate"],formtarget:$o,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:j,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:j,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:j,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:Th,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:j,noscript:j,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:j,param:{attrs:{name:null,value:null}},pre:j,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:j,rt:j,ruby:j,samp:j,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:Th}},section:j,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:j,source:{attrs:{src:null,type:null,media:null}},span:j,strong:j,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:j,summary:j,sup:j,table:j,tbody:j,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:j,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:j,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:j,time:{attrs:{datetime:null}},title:j,tr:j,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:j,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:j},Kw={accesskey:null,class:null,contenteditable:Pe,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Pe,autocorrect:Pe,autocapitalize:Pe,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Pe,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Pe,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Pe,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Pe,"aria-hidden":Pe,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Pe,"aria-multiselectable":Pe,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Pe,"aria-relevant":null,"aria-required":Pe,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Jw="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(i=>"on"+i);for(let i of Jw)Kw[i]=null;class ll{constructor(t,e){this.tags={...C2,...t},this.globalAttrs={...Kw,...e},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}ll.default=new ll;function eo(i,t,e=i.length){if(!t)return"";let n=t.firstChild,r=n&&n.getChild("TagName");return r?i.sliceString(r.from,Math.min(r.to,e)):""}function io(i,t=!1){for(;i;i=i.parent)if(i.name=="Element")if(t)t=!1;else return i;return null}function t1(i,t,e){let n=e.tags[eo(i,io(t))];return(n==null?void 0:n.children)||e.allTags}function hd(i,t){let e=[];for(let n=io(t);n&&!n.type.isTop;n=io(n.parent)){let r=eo(i,n);if(r&&n.lastChild.name=="CloseTag")break;r&&e.indexOf(r)<0&&(t.name=="EndTag"||t.from>=n.firstChild.to)&&e.push(r)}return e}const e1=/^[:\-\.\w\u00b7-\uffff]*$/;function rm(i,t,e,n,r){let s=/\s*>/.test(i.sliceDoc(r,r+5))?"":">",o=io(e,e.name=="StartTag"||e.name=="TagName");return{from:n,to:r,options:t1(i.doc,o,t).map(l=>({label:l,type:"type"})).concat(hd(i.doc,e).map((l,a)=>({label:"/"+l,apply:"/"+l+s,type:"type",boost:99-a}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function sm(i,t,e,n){let r=/\s*>/.test(i.sliceDoc(n,n+5))?"":">";return{from:e,to:n,options:hd(i.doc,t).map((s,o)=>({label:s,apply:s+r,type:"type",boost:99-o})),validFor:e1}}function P2(i,t,e,n){let r=[],s=0;for(let o of t1(i.doc,e,t))r.push({label:"<"+o,type:"type"});for(let o of hd(i.doc,e))r.push({label:"</"+o+">",type:"type",boost:99-s++});return{from:n,to:n,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function T2(i,t,e,n,r){let s=io(e),o=s?t.tags[eo(i.doc,s)]:null,l=o&&o.attrs?Object.keys(o.attrs):[],a=o&&o.globalAttrs===!1?l:l.length?l.concat(t.globalAttrNames):t.globalAttrNames;return{from:n,to:r,options:a.map(c=>({label:c,type:"property"})),validFor:e1}}function A2(i,t,e,n,r){var s;let o=(s=e.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),l=[],a;if(o){let c=i.sliceDoc(o.from,o.to),h=t.globalAttrs[c];if(!h){let u=io(e),f=u?t.tags[eo(i.doc,u)]:null;h=(f==null?void 0:f.attrs)&&f.attrs[c]}if(h){let u=i.sliceDoc(n,r).toLowerCase(),f='"',d='"';/^['"]/.test(u)?(a=u[0]=='"'?/^[^"]*$/:/^[^']*$/,f="",d=i.sliceDoc(r,r+1)==u[0]?"":u[0],u=u.slice(1),n++):a=/^[^\s<>='"]*$/;for(let O of h)l.push({label:O,apply:f+O+d,type:"constant"})}}return{from:n,to:r,options:l,validFor:a}}function i1(i,t){let{state:e,pos:n}=t,r=St(e).resolveInner(n,-1),s=r.resolve(n);for(let o=n,l;s==r&&(l=r.childBefore(o));){let a=l.lastChild;if(!a||!a.type.isError||a.from<a.to)break;s=r=l,o=a.from}return r.name=="TagName"?r.parent&&/CloseTag$/.test(r.parent.name)?sm(e,r,r.from,n):rm(e,i,r,r.from,n):r.name=="StartTag"||r.name=="IncompleteTag"?rm(e,i,r,n,n):r.name=="StartCloseTag"||r.name=="IncompleteCloseTag"?sm(e,r,n,n):r.name=="OpenTag"||r.name=="SelfClosingTag"||r.name=="AttributeName"?T2(e,i,r,r.name=="AttributeName"?r.from:n,n):r.name=="Is"||r.name=="AttributeValue"||r.name=="UnquotedAttributeValue"?A2(e,i,r,r.name=="Is"?n:r.from,n):t.explicit&&(s.name=="Element"||s.name=="Text"||s.name=="Document")?P2(e,i,r,n):null}function R2(i){return i1(ll.default,i)}function Z2(i){let{extraTags:t,extraGlobalAttributes:e}=i,n=e||t?new ll(t,e):ll.default;return r=>i1(n,r)}const X2=ji.parser.configure({top:"SingleExpression"}),n1=[{tag:"script",attrs:i=>i.type=="text/typescript"||i.lang=="ts",parser:Nw.parser},{tag:"script",attrs:i=>i.type=="text/babel"||i.type=="text/jsx",parser:Gw.parser},{tag:"script",attrs:i=>i.type=="text/typescript-jsx",parser:Uw.parser},{tag:"script",attrs(i){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(i.type)},parser:X2},{tag:"script",attrs(i){return!i.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(i.type)},parser:ji.parser},{tag:"style",attrs(i){return(!i.lang||i.lang=="css")&&(!i.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(i.type))},parser:ec.parser}],r1=[{name:"style",parser:ec.parser.configure({top:"Styles"})}].concat(Jw.map(i=>({name:i,parser:ji.parser}))),s1=Hs.define({name:"html",parser:rP.configure({props:[$l.add({Element(i){let t=/^(\s*)(<\/)?/.exec(i.textAfter);return i.node.to<=i.pos+t[0].length?i.continue():i.lineIndent(i.node.from)+(t[2]?0:i.unit)},"OpenTag CloseTag SelfClosingTag"(i){return i.column(i.node.from)+i.unit},Document(i){if(i.pos+/\s*/.exec(i.textAfter)[0].length<i.node.to)return i.continue();let t=null,e;for(let n=i.node;;){let r=n.lastChild;if(!r||r.name!="Element"||r.to!=n.to)break;t=n=r}return t&&!((e=t.lastChild)&&(e.name=="CloseTag"||e.name=="SelfClosingTag"))?i.lineIndent(t.from)+i.unit:null}}),Cl.add({Element(i){let t=i.firstChild,e=i.lastChild;return!t||t.name!="OpenTag"?null:{from:t.to,to:e.name=="CloseTag"?e.from:i.to}}}),g0.add({"OpenTag CloseTag":i=>i.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),Qa=s1.configure({wrap:Lw(n1,r1)});function E2(i={}){let t="",e;i.matchClosingTags===!1&&(t="noMatch"),i.selfClosingTags===!0&&(t=(t?t+" ":"")+"selfClosing"),(i.nestedLanguages&&i.nestedLanguages.length||i.nestedAttributes&&i.nestedAttributes.length)&&(e=Lw((i.nestedLanguages||[]).concat(n1),(i.nestedAttributes||[]).concat(r1)));let n=e?s1.configure({wrap:e,dialect:t}):t?Qa.configure({dialect:t}):Qa;return new il(n,[Qa.data.of({autocomplete:Z2(i)}),i.autoCloseTags!==!1?L2:[],y2().support,jP().support])}const om=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),L2=z.inputHandler.of((i,t,e,n,r)=>{if(i.composing||i.state.readOnly||t!=e||n!=">"&&n!="/"||!Qa.isActiveAt(i.state,t,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(a=>{var c,h,u;let f=o.doc.sliceString(a.from-1,a.to)==n,{head:d}=a,O=St(o).resolveInner(d,-1),p;if(f&&n==">"&&O.name=="EndTag"){let m=O.parent;if(((h=(c=m.parent)===null||c===void 0?void 0:c.lastChild)===null||h===void 0?void 0:h.name)!="CloseTag"&&(p=eo(o.doc,m.parent,d))&&!om.has(p)){let g=d+(o.doc.sliceString(d,d+1)===">"?1:0),b=`</${p}>`;return{range:a,changes:{from:d,to:g,insert:b}}}}else if(f&&n=="/"&&O.name=="IncompleteCloseTag"){let m=O.parent;if(O.from==d-2&&((u=m.lastChild)===null||u===void 0?void 0:u.name)!="CloseTag"&&(p=eo(o.doc,m,d))&&!om.has(p)){let g=d+(o.doc.sliceString(d,d+1)===">"?1:0),b=`${p}>`;return{range:C.cursor(d+b.length,-1),changes:{from:d,to:g,insert:b}}}}return{range:a}});return l.changes.empty?!1:(i.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),o1=Wf({commentTokens:{block:{open:"<!--",close:"-->"}}}),l1=new N,a1=tC.configure({props:[Cl.add(i=>!i.is("Block")||i.is("Document")||qu(i)!=null||M2(i)?void 0:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})),l1.add(qu),$l.add({Document:()=>null}),rr.add({Document:o1})]});function qu(i){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(i.name);return t?+t[1]:void 0}function M2(i){return i.name=="OrderedList"||i.name=="BulletList"}function z2(i,t){let e=i;for(;;){let n=e.nextSibling,r;if(!n||(r=qu(n.type))!=null&&r<=t)break;e=n}return e.to}const _2=eQ.of((i,t,e)=>{for(let n=St(i).resolveInner(e,-1);n&&!(n.from<t);n=n.parent){let r=n.type.prop(l1);if(r==null)continue;let s=z2(n,r);if(s>e)return{from:e,to:s}}return null});function ud(i){return new Ie(o1,i,[],"markdown")}const I2=ud(a1),j2=a1.configure([cC,uC,hC,fC,{props:[Cl.add({Table:(i,t)=>({from:t.doc.lineAt(i.from).to,to:i.to})})]}]),ic=ud(j2);function D2(i,t){return e=>{if(e&&i){let n=null;if(e=/\S*/.exec(e)[0],typeof i=="function"?n=i(e):n=Wa.matchLanguageName(i,e,!0),n instanceof Wa)return n.support?n.support.language.parser:el.getSkippingParser(n.load());if(n)return n.parser}return t?t.parser:null}}class Zh{constructor(t,e,n,r,s,o,l){this.node=t,this.from=e,this.to=n,this.spaceBefore=r,this.spaceAfter=s,this.type=o,this.item=l}blank(t,e=!0){let n=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(t!=null){for(;n.length<t;)n+=" ";return n}else{for(let r=this.to-this.from-n.length-this.spaceAfter.length;r>0;r--)n+=" ";return n+(e?this.spaceAfter:"")}}marker(t,e){let n=this.node.name=="OrderedList"?String(+h1(this.item,t)[2]+e):"";return this.spaceBefore+n+this.type+this.spaceAfter}}function c1(i,t){let e=[],n=[];for(let r=i;r;r=r.parent){if(r.name=="FencedCode")return n;(r.name=="ListItem"||r.name=="Blockquote")&&e.push(r)}for(let r=e.length-1;r>=0;r--){let s=e[r],o,l=t.lineAt(s.from),a=s.from-l.from;if(s.name=="Blockquote"&&(o=/^ *>( ?)/.exec(l.text.slice(a))))n.push(new Zh(s,a,a+o[0].length,"",o[1],">",null));else if(s.name=="ListItem"&&s.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(l.text.slice(a)))){let c=o[3],h=o[0].length;c.length>=4&&(c=c.slice(0,c.length-4),h-=4),n.push(new Zh(s.parent,a,a+h,o[1],c,o[2],s))}else if(s.name=="ListItem"&&s.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(a)))){let c=o[4],h=o[0].length;c.length>4&&(c=c.slice(0,c.length-4),h-=4);let u=o[2];o[3]&&(u+=o[3].replace(/[xX]/," ")),n.push(new Zh(s.parent,a,a+h,o[1],c,u,s))}}return n}function h1(i,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(i.from,i.from+10))}function Xh(i,t,e,n=0){for(let r=-1,s=i;;){if(s.name=="ListItem"){let l=h1(s,t),a=+l[2];if(r>=0){if(a!=r+1)return;e.push({from:s.from+l[1].length,to:s.from+l[0].length,insert:String(r+2+n)})}r=a}let o=s.nextSibling;if(!o)break;s=o}}function fd(i,t){let e=/^[ \t]*/.exec(i)[0].length;if(!e||t.facet(uo)!=" ")return i;let n=an(i,4,e),r="";for(let s=n;s>0;)s>=4?(r+=" ",s-=4):(r+=" ",s--);return r+i.slice(e)}const u1=(i={})=>({state:t,dispatch:e})=>{let n=St(t),{doc:r}=t,s=null,o=t.changeByRange(l=>{if(!l.empty||!ic.isActiveAt(t,l.from,-1)&&!ic.isActiveAt(t,l.from,1))return s={range:l};let a=l.from,c=r.lineAt(a),h=c1(n.resolveInner(a,-1),r);for(;h.length&&h[h.length-1].from>a-c.from;)h.pop();if(!h.length)return s={range:l};let u=h[h.length-1];if(u.to-u.spaceAfter.length>a-c.from)return s={range:l};let f=a>=u.to-u.spaceAfter.length&&!/\S/.test(c.text.slice(u.to));if(u.item&&f){let g=u.node.firstChild,b=u.node.getChild("ListItem","ListItem");if(g.to>=a||b&&b.to<a||c.from>0&&!/[^\s>]/.test(r.lineAt(c.from-1).text)||i.nonTightLists===!1){let S=h.length>1?h[h.length-2]:null,x,y="";S&&S.item?(x=c.from+S.from,y=S.marker(r,1)):x=c.from+(S?S.to:0);let k=[{from:x,to:a,insert:y}];return u.node.name=="OrderedList"&&Xh(u.item,r,k,-2),S&&S.node.name=="OrderedList"&&Xh(S.item,r,k),{range:C.cursor(x+y.length),changes:k}}else{let S=am(h,t,c);return{range:C.cursor(a+S.length+1),changes:{from:c.from,insert:S+t.lineBreak}}}}if(u.node.name=="Blockquote"&&f&&c.from){let g=r.lineAt(c.from-1),b=/>\s*$/.exec(g.text);if(b&&b.index==u.from){let S=t.changes([{from:g.from+b.index,to:g.to},{from:c.from+u.from,to:c.to}]);return{range:l.map(S),changes:S}}}let d=[];u.node.name=="OrderedList"&&Xh(u.item,r,d);let O=u.item&&u.item.from<c.from,p="";if(!O||/^[\s\d.)\-+*>]*/.exec(c.text)[0].length>=u.to)for(let g=0,b=h.length-1;g<=b;g++)p+=g==b&&!O?h[g].marker(r,1):h[g].blank(g<b?an(c.text,4,h[g+1].from)-p.length:null);let m=a;for(;m>c.from&&/\s/.test(c.text.charAt(m-c.from-1));)m--;return p=fd(p,t),B2(u.node,t.doc)&&(p=am(h,t,c)+t.lineBreak+p),d.push({from:m,to:a,insert:t.lineBreak+p}),{range:C.cursor(m+p.length+1),changes:d}});return s?!1:(e(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},V2=u1();function lm(i){return i.name=="QuoteMark"||i.name=="ListMark"}function B2(i,t){if(i.name!="OrderedList"&&i.name!="BulletList")return!1;let e=i.firstChild,n=i.getChild("ListItem","ListItem");if(!n)return!1;let r=t.lineAt(e.to),s=t.lineAt(n.from),o=/^[\s>]*$/.test(r.text);return r.number+(o?0:1)<s.number}function am(i,t,e){let n="";for(let r=0,s=i.length-2;r<=s;r++)n+=i[r].blank(r<s?an(e.text,4,i[r+1].from)-n.length:null,r<s);return fd(n,t)}function W2(i,t){let e=i.resolveInner(t,-1),n=t;lm(e)&&(n=e.from,e=e.parent);for(let r;r=e.childBefore(n);)if(lm(r))n=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")e=r.lastChild,n=e.to;else break;return e}const Y2=({state:i,dispatch:t})=>{let e=St(i),n=null,r=i.changeByRange(s=>{let o=s.from,{doc:l}=i;if(s.empty&&ic.isActiveAt(i,s.from)){let a=l.lineAt(o),c=c1(W2(e,o),l);if(c.length){let h=c[c.length-1],u=h.to-h.spaceAfter.length+(h.spaceAfter?1:0);if(o-a.from>u&&!/\S/.test(a.text.slice(u,o-a.from)))return{range:C.cursor(a.from+u),changes:{from:a.from+u,to:o}};if(o-a.from==u&&(!h.item||a.from<=h.item.from||!/\S/.test(a.text.slice(0,h.to)))){let f=a.from+h.from;if(h.item&&h.node.from<h.item.from&&/\S/.test(a.text.slice(h.from,h.to))){let d=h.blank(an(a.text,4,h.to)-an(a.text,4,h.from));return f==a.from&&(d=fd(d,i)),{range:C.cursor(f+d.length),changes:{from:f,to:a.from+h.to,insert:d}}}if(f<o)return{range:C.cursor(f),changes:{from:f,to:o}}}}}return n={range:s}});return n?!1:(t(i.update(r,{scrollIntoView:!0,userEvent:"delete"})),!0)},q2=[{key:"Enter",run:V2},{key:"Backspace",run:Y2}],f1=E2({matchClosingTags:!1});function zc(i={}){let{codeLanguages:t,defaultCodeLanguage:e,addKeymap:n=!0,base:{parser:r}=I2,completeHTMLTags:s=!0,pasteURLAsLink:o=!0,htmlTagLanguage:l=f1}=i;if(!(r instanceof Mc))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let a=i.extensions?[i.extensions]:[],c=[l.support,_2],h;o&&c.push(H2),e instanceof il?(c.push(e.support),h=e.language):e&&(h=e);let u=t||h?D2(t,h):void 0;a.push(iC({codeParser:u,htmlParser:l.language.parser})),n&&c.push(hn.high(Dn.of(q2)));let f=ud(r.configure(a));return s&&c.push(f.data.of({autocomplete:N2})),new il(f,c)}function N2(i){let{state:t,pos:e}=i,n=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(e-25,e));if(!n)return null;let r=St(t).resolveInner(e,-1);for(;r&&!r.type.isTop;){if(r.name=="CodeBlock"||r.name=="FencedCode"||r.name=="ProcessingInstructionBlock"||r.name=="CommentBlock"||r.name=="Link"||r.name=="Image")return null;r=r.parent}return{from:e-n[0].length,to:e,options:G2(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let Eh=null;function G2(){if(Eh)return Eh;let i=R2(new Q$(K.create({extensions:f1}),0,!0));return Eh=i?i.options:[]}const U2=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,H2=z.domEventHandlers({paste:(i,t)=>{var e;let{main:n}=t.state.selection;if(n.empty)return!1;let r=(e=i.clipboardData)===null||e===void 0?void 0:e.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!ic.isActiveAt(t.state,n.from,1)))return!1;let s=St(t.state),o=!1;return s.iterate({from:n.from,to:n.to,enter:l=>{(l.from>n.from||U2.test(l.name))&&(o=!0)},leave:l=>{l.to<n.to&&(o=!0)}}),o?!1:(t.dispatch({changes:[{from:n.from,insert:"["},{from:n.to,insert:`](${r})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}});function F2(i,t){return i>t?i:t}function K2(i,t){if(i<=0)return[];for(var e=new Array(i),n=0;n<i;++n)e[n]=t;return e}function J2(i,t){for(var e=i.length,n=t<0?F2(e+t|0,0):t,r=e-n|0,s=new Array(r),o=0;o<r;++o)s[o]=i[n+o|0];return s}function tT(i,t,e,n,r){for(;;){var s=e;if(s===r)return!0;if(!n(i[s],t[s]))return!1;e=s+1|0}}function eT(i,t,e){var n=i.length,r=t.length;return n===r?tT(i,t,0,e,n):!1}var cm=K2;function dd(){if(arguments.length===1){const i=arguments;return function(e){return cm(e,i[0])}}return cm(arguments[0],arguments[1])}function iT(i){var t=i.length;if(t===1)return[];if(t!==0){var e=J2(i,1);if(e.length!==0)return e}}function nT(i){var t=iT(i);return t!==void 0?t:[]}var hm=eT;function rT(){if(arguments.length===2){const i=arguments;return function(e){return hm(e,i[0],i[1])}}return hm(arguments[0],arguments[1],arguments[2])}function sT(i){return typeof i=="string"}function oT(i){return i==null}function lT(i){return i!=null}const aT=Object.freeze(Object.defineProperty({__proto__:null,isNotNullable:lT,isNullable:oT,isString:sT},Symbol.toStringTag,{value:"Module"}));function um(i,t){return i.repeat(t)}function cT(){if(arguments.length===1){const i=arguments;return function(e){return um(e,i[0])}}return um(arguments[0],arguments[1])}function d1(i){for(var t={},e=i.length,n=0;n<e;++n){var r=i[n];t[r[0]]=r[1]}return t}function hT(i,t){for(var e=i.length,n=t.length,r=new Array(e+n|0),s=0;s<e;++s)r[s]=i[s];for(var o=0;o<n;++o)r[e+o|0]=t[o];return r}function O1(i,t,e){for(var n=t,r=0,s=i.length;r<s;++r)n=e(n,i[r]);return n}function fm(i,t){return hT(i,[t])}function p1(){if(arguments.length===1){const i=arguments;return function(e){return fm(e,i[0])}}return fm(arguments[0],arguments[1])}function dm(i,t){return d1(O1(Object.keys(i),[],function(e,n){var r=i[n];return t(r)?p1(e,[n,r]):e}))}function uT(){if(arguments.length===1){const i=arguments;return function(e){return dm(e,i[0])}}return dm(arguments[0],arguments[1])}function Om(i,t){return d1(O1(Object.keys(i),[],function(e,n){var r=i[n];return t(n,r)?p1(e,[n,r]):e}))}function fT(){if(arguments.length===1){const i=arguments;return function(e){return Om(e,i[0])}}return Om(arguments[0],arguments[1])}function pm(i,t){return fT(i,function(e,n){return t.includes(e)})}function dT(){if(arguments.length===1){const i=arguments;return function(e){return pm(e,i[0])}}return pm(arguments[0],arguments[1])}function m1(i){var t,e,n="";if(typeof i=="string"||typeof i=="number")n+=i;else if(typeof i=="object")if(Array.isArray(i)){var r=i.length;for(t=0;t<r;t++)i[t]&&(e=m1(i[t]))&&(n&&(n+=" "),n+=e)}else for(e in i)i[e]&&(n&&(n+=" "),n+=e);return n}function OT(){for(var i,t,e=0,n="",r=arguments.length;e<r;e++)(i=arguments[e])&&(t=m1(i))&&(n&&(n+=" "),n+=t);return n}const pT=["top","right","bottom","left"],mm=["start","end"],gm=pT.reduce((i,t)=>i.concat(t,t+"-"+mm[0],t+"-"+mm[1]),[]),Nu=Math.min,Br=Math.max,nc=Math.round,Di=i=>({x:i,y:i}),mT={left:"right",right:"left",bottom:"top",top:"bottom"};function bm(i,t,e){return Br(i,Nu(t,e))}function Od(i,t){return typeof i=="function"?i(t):i}function Al(i){return i.split("-")[0]}function pr(i){return i.split("-")[1]}function g1(i){return i==="x"?"y":"x"}function b1(i){return i==="y"?"height":"width"}function pd(i){const t=i[0];return t==="t"||t==="b"?"y":"x"}function w1(i){return g1(pd(i))}function gT(i,t,e){e===void 0&&(e=!1);const n=pr(i),r=w1(i),s=b1(r);let o=r==="x"?n===(e?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=wm(o)),[o,wm(o)]}function bT(i){return i.includes("start")?i.replace("start","end"):i.replace("end","start")}function wm(i){const t=Al(i);return mT[t]+i.slice(t.length)}function wT(i){return{top:0,right:0,bottom:0,left:0,...i}}function ST(i){return typeof i!="number"?wT(i):{top:i,right:i,bottom:i,left:i}}function rc(i){const{x:t,y:e,width:n,height:r}=i;return{width:n,height:r,top:e,left:t,right:t+n,bottom:e+r,x:t,y:e}}function Sm(i,t,e){let{reference:n,floating:r}=i;const s=pd(t),o=w1(t),l=b1(o),a=Al(t),c=s==="y",h=n.x+n.width/2-r.width/2,u=n.y+n.height/2-r.height/2,f=n[l]/2-r[l]/2;let d;switch(a){case"top":d={x:h,y:n.y-r.height};break;case"bottom":d={x:h,y:n.y+n.height};break;case"right":d={x:n.x+n.width,y:u};break;case"left":d={x:n.x-r.width,y:u};break;default:d={x:n.x,y:n.y}}switch(pr(t)){case"start":d[o]-=f*(e&&c?-1:1);break;case"end":d[o]+=f*(e&&c?-1:1);break}return d}async function vT(i,t){var e;t===void 0&&(t={});const{x:n,y:r,platform:s,rects:o,elements:l,strategy:a}=i,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:f=!1,padding:d=0}=Od(t,i),O=ST(d),m=l[f?u==="floating"?"reference":"floating":u],g=rc(await s.getClippingRect({element:(e=await(s.isElement==null?void 0:s.isElement(m)))==null||e?m:m.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:h,strategy:a})),b=u==="floating"?{x:n,y:r,width:o.floating.width,height:o.floating.height}:o.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),x=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},y=rc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:S,strategy:a}):b);return{top:(g.top-y.top+O.top)/x.y,bottom:(y.bottom-g.bottom+O.bottom)/x.y,left:(g.left-y.left+O.left)/x.x,right:(y.right-g.right+O.right)/x.x}}const xT=50,yT=async(i,t,e)=>{const{placement:n="bottom",strategy:r="absolute",middleware:s=[],platform:o}=e,l=o.detectOverflow?o:{...o,detectOverflow:vT},a=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:i,floating:t,strategy:r}),{x:h,y:u}=Sm(c,n,a),f=n,d=0;const O={};for(let p=0;p<s.length;p++){const m=s[p];if(!m)continue;const{name:g,fn:b}=m,{x:S,y:x,data:y,reset:k}=await b({x:h,y:u,initialPlacement:n,placement:f,strategy:r,middlewareData:O,rects:c,platform:l,elements:{reference:i,floating:t}});h=S??h,u=x??u,O[g]={...O[g],...y},k&&d<xT&&(d++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(c=k.rects===!0?await o.getElementRects({reference:i,floating:t,strategy:r}):k.rects),{x:h,y:u}=Sm(c,f,a)),p=-1)}return{x:h,y:u,placement:f,strategy:r,middlewareData:O}};function kT(i,t,e){return(i?[...e.filter(r=>pr(r)===i),...e.filter(r=>pr(r)!==i)]:e.filter(r=>Al(r)===r)).filter(r=>i?pr(r)===i||(t?bT(r)!==r:!1):!0)}const QT=function(i){return i===void 0&&(i={}),{name:"autoPlacement",options:i,async fn(t){var e,n,r;const{rects:s,middlewareData:o,placement:l,platform:a,elements:c}=t,{crossAxis:h=!1,alignment:u,allowedPlacements:f=gm,autoAlignment:d=!0,...O}=Od(i,t),p=u!==void 0||f===gm?kT(u||null,d,f):f,m=await a.detectOverflow(t,O),g=((e=o.autoPlacement)==null?void 0:e.index)||0,b=p[g];if(b==null)return{};const S=gT(b,s,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==b)return{reset:{placement:p[0]}};const x=[m[Al(b)],m[S[0]],m[S[1]]],y=[...((n=o.autoPlacement)==null?void 0:n.overflows)||[],{placement:b,overflows:x}],k=p[g+1];if(k)return{data:{index:g+1,overflows:y},reset:{placement:k}};const Q=y.map(L=>{const B=pr(L.placement);return[L.placement,B&&h?L.overflows.slice(0,2).reduce((_,G)=>_+G,0):L.overflows[0],L.overflows]}).sort((L,B)=>L[1]-B[1]),D=((r=Q.filter(L=>L[2].slice(0,pr(L[0])?2:3).every(B=>B<=0))[0])==null?void 0:r[0])||Q[0][0];return D!==l?{data:{index:g+1,overflows:y},reset:{placement:D}}:{}}}},$T=function(i){return i===void 0&&(i={}),{name:"shift",options:i,async fn(t){const{x:e,y:n,placement:r,platform:s}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:a={fn:g=>{let{x:b,y:S}=g;return{x:b,y:S}}},...c}=Od(i,t),h={x:e,y:n},u=await s.detectOverflow(t,c),f=pd(Al(r)),d=g1(f);let O=h[d],p=h[f];if(o){const g=d==="y"?"top":"left",b=d==="y"?"bottom":"right",S=O+u[g],x=O-u[b];O=bm(S,O,x)}if(l){const g=f==="y"?"top":"left",b=f==="y"?"bottom":"right",S=p+u[g],x=p-u[b];p=bm(S,p,x)}const m=a.fn({...t,[d]:O,[f]:p});return{...m,data:{x:m.x-e,y:m.y-n,enabled:{[d]:o,[f]:l}}}}}};function _c(){return typeof window<"u"}function po(i){return S1(i)?(i.nodeName||"").toLowerCase():"#document"}function je(i){var t;return(i==null||(t=i.ownerDocument)==null?void 0:t.defaultView)||window}function un(i){var t;return(t=(S1(i)?i.ownerDocument:i.document)||window.document)==null?void 0:t.documentElement}function S1(i){return _c()?i instanceof Node||i instanceof je(i).Node:!1}function di(i){return _c()?i instanceof Element||i instanceof je(i).Element:!1}function fn(i){return _c()?i instanceof HTMLElement||i instanceof je(i).HTMLElement:!1}function vm(i){return!_c()||typeof ShadowRoot>"u"?!1:i instanceof ShadowRoot||i instanceof je(i).ShadowRoot}function Rl(i){const{overflow:t,overflowX:e,overflowY:n,display:r}=Oi(i);return/auto|scroll|overlay|hidden|clip/.test(t+n+e)&&r!=="inline"&&r!=="contents"}function CT(i){return/^(table|td|th)$/.test(po(i))}function Ic(i){try{if(i.matches(":popover-open"))return!0}catch{}try{return i.matches(":modal")}catch{return!1}}const PT=/transform|translate|scale|rotate|perspective|filter/,TT=/paint|layout|strict|content/,Nn=i=>!!i&&i!=="none";let Lh;function md(i){const t=di(i)?Oi(i):i;return Nn(t.transform)||Nn(t.translate)||Nn(t.scale)||Nn(t.rotate)||Nn(t.perspective)||!gd()&&(Nn(t.backdropFilter)||Nn(t.filter))||PT.test(t.willChange||"")||TT.test(t.contain||"")}function AT(i){let t=zn(i);for(;fn(t)&&!no(t);){if(md(t))return t;if(Ic(t))return null;t=zn(t)}return null}function gd(){return Lh==null&&(Lh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Lh}function no(i){return/^(html|body|#document)$/.test(po(i))}function Oi(i){return je(i).getComputedStyle(i)}function jc(i){return di(i)?{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}:{scrollLeft:i.scrollX,scrollTop:i.scrollY}}function zn(i){if(po(i)==="html")return i;const t=i.assignedSlot||i.parentNode||vm(i)&&i.host||un(i);return vm(t)?t.host:t}function v1(i){const t=zn(i);return no(t)?i.ownerDocument?i.ownerDocument.body:i.body:fn(t)&&Rl(t)?t:v1(t)}function x1(i,t,e){var n;t===void 0&&(t=[]);const r=v1(i),s=r===((n=i.ownerDocument)==null?void 0:n.body),o=je(r);return s?(Gu(o),t.concat(o,o.visualViewport||[],Rl(r)?r:[],[])):t.concat(r,x1(r,[]))}function Gu(i){return i.parent&&Object.getPrototypeOf(i.parent)?i.frameElement:null}function y1(i){const t=Oi(i);let e=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const r=fn(i),s=r?i.offsetWidth:e,o=r?i.offsetHeight:n,l=nc(e)!==s||nc(n)!==o;return l&&(e=s,n=o),{width:e,height:n,$:l}}function k1(i){return di(i)?i:i.contextElement}function Wr(i){const t=k1(i);if(!fn(t))return Di(1);const e=t.getBoundingClientRect(),{width:n,height:r,$:s}=y1(t);let o=(s?nc(e.width):e.width)/n,l=(s?nc(e.height):e.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const RT=Di(0);function Q1(i){const t=je(i);return!gd()||!t.visualViewport?RT:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ZT(i,t,e){return t===void 0&&(t=!1),!e||t&&e!==je(i)?!1:t}function al(i,t,e,n){t===void 0&&(t=!1),e===void 0&&(e=!1);const r=i.getBoundingClientRect(),s=k1(i);let o=Di(1);t&&(n?di(n)&&(o=Wr(n)):o=Wr(i));const l=ZT(s,e,n)?Q1(s):Di(0);let a=(r.left+l.x)/o.x,c=(r.top+l.y)/o.y,h=r.width/o.x,u=r.height/o.y;if(s){const f=je(s),d=n&&di(n)?je(n):n;let O=f,p=Gu(O);for(;p&&n&&d!==O;){const m=Wr(p),g=p.getBoundingClientRect(),b=Oi(p),S=g.left+(p.clientLeft+parseFloat(b.paddingLeft))*m.x,x=g.top+(p.clientTop+parseFloat(b.paddingTop))*m.y;a*=m.x,c*=m.y,h*=m.x,u*=m.y,a+=S,c+=x,O=je(p),p=Gu(O)}}return rc({width:h,height:u,x:a,y:c})}function Dc(i,t){const e=jc(i).scrollLeft;return t?t.left+e:al(un(i)).left+e}function $1(i,t){const e=i.getBoundingClientRect(),n=e.left+t.scrollLeft-Dc(i,e),r=e.top+t.scrollTop;return{x:n,y:r}}function XT(i){let{elements:t,rect:e,offsetParent:n,strategy:r}=i;const s=r==="fixed",o=un(n),l=t?Ic(t.floating):!1;if(n===o||l&&s)return e;let a={scrollLeft:0,scrollTop:0},c=Di(1);const h=Di(0),u=fn(n);if((u||!u&&!s)&&((po(n)!=="body"||Rl(o))&&(a=jc(n)),u)){const d=al(n);c=Wr(n),h.x=d.x+n.clientLeft,h.y=d.y+n.clientTop}const f=o&&!u&&!s?$1(o,a):Di(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-a.scrollLeft*c.x+h.x+f.x,y:e.y*c.y-a.scrollTop*c.y+h.y+f.y}}function ET(i){return Array.from(i.getClientRects())}function LT(i){const t=un(i),e=jc(i),n=i.ownerDocument.body,r=Br(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=Br(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let o=-e.scrollLeft+Dc(i);const l=-e.scrollTop;return Oi(n).direction==="rtl"&&(o+=Br(t.clientWidth,n.clientWidth)-r),{width:r,height:s,x:o,y:l}}const xm=25;function MT(i,t){const e=je(i),n=un(i),r=e.visualViewport;let s=n.clientWidth,o=n.clientHeight,l=0,a=0;if(r){s=r.width,o=r.height;const h=gd();(!h||h&&t==="fixed")&&(l=r.offsetLeft,a=r.offsetTop)}const c=Dc(n);if(c<=0){const h=n.ownerDocument,u=h.body,f=getComputedStyle(u),d=h.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,O=Math.abs(n.clientWidth-u.clientWidth-d);O<=xm&&(s-=O)}else c<=xm&&(s+=c);return{width:s,height:o,x:l,y:a}}function zT(i,t){const e=al(i,!0,t==="fixed"),n=e.top+i.clientTop,r=e.left+i.clientLeft,s=fn(i)?Wr(i):Di(1),o=i.clientWidth*s.x,l=i.clientHeight*s.y,a=r*s.x,c=n*s.y;return{width:o,height:l,x:a,y:c}}function ym(i,t,e){let n;if(t==="viewport")n=MT(i,e);else if(t==="document")n=LT(un(i));else if(di(t))n=zT(t,e);else{const r=Q1(i);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return rc(n)}function C1(i,t){const e=zn(i);return e===t||!di(e)||no(e)?!1:Oi(e).position==="fixed"||C1(e,t)}function _T(i,t){const e=t.get(i);if(e)return e;let n=x1(i,[]).filter(l=>di(l)&&po(l)!=="body"),r=null;const s=Oi(i).position==="fixed";let o=s?zn(i):i;for(;di(o)&&!no(o);){const l=Oi(o),a=md(o);!a&&l.position==="fixed"&&(r=null),(s?!a&&!r:!a&&l.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||Rl(o)&&!a&&C1(i,o))?n=n.filter(h=>h!==o):r=l,o=zn(o)}return t.set(i,n),n}function IT(i){let{element:t,boundary:e,rootBoundary:n,strategy:r}=i;const o=[...e==="clippingAncestors"?Ic(t)?[]:_T(t,this._c):[].concat(e),n],l=ym(t,o[0],r);let a=l.top,c=l.right,h=l.bottom,u=l.left;for(let f=1;f<o.length;f++){const d=ym(t,o[f],r);a=Br(d.top,a),c=Nu(d.right,c),h=Nu(d.bottom,h),u=Br(d.left,u)}return{width:c-u,height:h-a,x:u,y:a}}function jT(i){const{width:t,height:e}=y1(i);return{width:t,height:e}}function DT(i,t,e){const n=fn(t),r=un(t),s=e==="fixed",o=al(i,!0,s,t);let l={scrollLeft:0,scrollTop:0};const a=Di(0);function c(){a.x=Dc(r)}if(n||!n&&!s)if((po(t)!=="body"||Rl(r))&&(l=jc(t)),n){const d=al(t,!0,s,t);a.x=d.x+t.clientLeft,a.y=d.y+t.clientTop}else r&&c();s&&!n&&r&&c();const h=r&&!n&&!s?$1(r,l):Di(0),u=o.left+l.scrollLeft-a.x-h.x,f=o.top+l.scrollTop-a.y-h.y;return{x:u,y:f,width:o.width,height:o.height}}function Mh(i){return Oi(i).position==="static"}function km(i,t){if(!fn(i)||Oi(i).position==="fixed")return null;if(t)return t(i);let e=i.offsetParent;return un(i)===e&&(e=e.ownerDocument.body),e}function P1(i,t){const e=je(i);if(Ic(i))return e;if(!fn(i)){let r=zn(i);for(;r&&!no(r);){if(di(r)&&!Mh(r))return r;r=zn(r)}return e}let n=km(i,t);for(;n&&CT(n)&&Mh(n);)n=km(n,t);return n&&no(n)&&Mh(n)&&!md(n)?e:n||AT(i)||e}const VT=async function(i){const t=this.getOffsetParent||P1,e=this.getDimensions,n=await e(i.floating);return{reference:DT(i.reference,await t(i.floating),i.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function BT(i){return Oi(i).direction==="rtl"}const WT={convertOffsetParentRelativeRectToViewportRelativeRect:XT,getDocumentElement:un,getClippingRect:IT,getOffsetParent:P1,getElementRects:VT,getClientRects:ET,getDimensions:jT,getScale:Wr,isElement:di,isRTL:BT},YT=QT,qT=$T,NT=(i,t,e)=>{const n=new Map,r={platform:WT,...e},s={...r.platform,_c:n};return yT(i,t,{...r,platform:s})},{isNotNullable:GT,isNullable:UT,isString:HT}=aT,E=GT,W=UT;function T1(i){return uT(i,t=>E(t))}function FT(i,t){const e=new Array;for(const[n,r]of Object.entries(i))e.push(t(n,r));return e}function A1(i,t){return dT(i,t)}const KT=["--tbl-style-font-family","--tbl-style-font-size","--tbl-style-menu-font-family","--tbl-style-menu-font-size","--tbl-style-default-header-alignment"],tr=class tr{constructor(t){P(this,"props");this.props=t}with(t){return W(t)?tr.of({...this.props}):tr.of({...this.props,...T1(A1(t,KT))})}static of(t){return new tr(t)}};P(tr,"default",tr.of({"--tbl-style-font-family":"system-ui","--tbl-style-font-size":"inherit","--tbl-style-menu-font-family":"system-ui","--tbl-style-menu-font-size":"inherit","--tbl-style-default-header-alignment":"left"}));let sc=tr;const JT=["--tbl-theme-row-background","--tbl-theme-header-row-background","--tbl-theme-even-row-background","--tbl-theme-odd-row-background","--tbl-theme-border-color","--tbl-theme-border-hover-color","--tbl-theme-border-active-color","--tbl-theme-outline-color","--tbl-theme-text-color","--tbl-theme-menu-border-color","--tbl-theme-menu-background","--tbl-theme-menu-hover-background","--tbl-theme-menu-text-color","--tbl-theme-menu-hover-text-color","--tbl-theme-select-all-focus-overlay","--tbl-theme-select-all-blur-overlay"],Ht=class Ht{constructor(t){P(this,"props");this.props=t}with(t){return W(t)?Ht.of({...this.props}):Ht.of({...this.props,...T1(A1(t,JT))})}static of(t){return new Ht(t)}};P(Ht,"light",Ht.of({"--tbl-theme-row-background":"#ffffff","--tbl-theme-header-row-background":"var(--tbl-theme-row-background)","--tbl-theme-even-row-background":"var(--tbl-theme-row-background)","--tbl-theme-odd-row-background":"var(--tbl-theme-row-background)","--tbl-theme-border-color":"#dcdcdc","--tbl-theme-border-hover-color":"color-mix(in srgb, var(--tbl-theme-border-color), #000000 10%)","--tbl-theme-border-active-color":"color-mix(in srgb, var(--tbl-theme-border-color), #000000 20%)","--tbl-theme-outline-color":"#2483e2","--tbl-theme-text-color":"inherit","--tbl-theme-menu-border-color":"var(--tbl-theme-border-color)","--tbl-theme-menu-background":"var(--tbl-theme-header-row-background)","--tbl-theme-menu-hover-background":"var(--tbl-theme-outline-color)","--tbl-theme-menu-text-color":"#000000","--tbl-theme-menu-hover-text-color":"#ffffff","--tbl-theme-select-all-focus-overlay":"rgb(20 2 167 / 17%)","--tbl-theme-select-all-blur-overlay":"rgb(2 2 2 / 15%)"})),P(Ht,"dark",Ht.of({"--tbl-theme-row-background":"#1d2024","--tbl-theme-header-row-background":"var(--tbl-theme-row-background)","--tbl-theme-even-row-background":"var(--tbl-theme-row-background)","--tbl-theme-odd-row-background":"var(--tbl-theme-row-background)","--tbl-theme-border-color":"#464646","--tbl-theme-border-hover-color":"color-mix(in srgb, var(--tbl-theme-border-color), #708499 25%)","--tbl-theme-border-active-color":"color-mix(in srgb, var(--tbl-theme-border-color), #708499 65%)","--tbl-theme-outline-color":"#2483e2","--tbl-theme-text-color":"inherit","--tbl-theme-menu-border-color":"var(--tbl-theme-border-color)","--tbl-theme-menu-background":"color-mix(in srgb, var(--tbl-theme-header-row-background), #ffffff 5%)","--tbl-theme-menu-hover-background":"var(--tbl-theme-outline-color)","--tbl-theme-menu-text-color":"color-mix(in srgb, var(--tbl-theme-header-row-background), #ffffff 90%)","--tbl-theme-menu-hover-text-color":"var(--tbl-theme-menu-text-color)","--tbl-theme-select-all-focus-overlay":"rgb(252 246 239 / 35%)","--tbl-theme-select-all-blur-overlay":"rgb(246 232 214 / 18%)"})),P(Ht,"githubLight",Ht.light.with({"--tbl-theme-header-row-background":"#ffffff","--tbl-theme-even-row-background":"#ffffff","--tbl-theme-odd-row-background":"#f6f8fa","--tbl-theme-border-color":"#d1d9e0","--tbl-theme-menu-text-color":"color-mix(in srgb, var(--tbl-theme-header-row-background), #000000 90%)"})),P(Ht,"githubDark",Ht.dark.with({"--tbl-theme-header-row-background":"#0d1117","--tbl-theme-even-row-background":"#0d1117","--tbl-theme-odd-row-background":"#151b23","--tbl-theme-border-color":"#3d444d","--tbl-theme-select-all-focus-overlay":"rgb(254 248 238 / 39%)","--tbl-theme-select-all-blur-overlay":"rgb(252 239 219 / 23%)"})),P(Ht,"githubSoftDark",Ht.dark.with({"--tbl-theme-header-row-background":"#212830","--tbl-theme-even-row-background":"#212830","--tbl-theme-odd-row-background":"#262c36","--tbl-theme-border-color":"#3d444d","--tbl-theme-select-all-focus-overlay":"rgb(251 237 222 / 34%)","--tbl-theme-select-all-blur-overlay":"rgb(252 215 173 / 16%)"})),P(Ht,"oneDark",Ht.dark.with({"--tbl-theme-row-background":"#282c34","--tbl-theme-border-color":"#3b4048","--tbl-theme-outline-color":"#568af2","--tbl-theme-menu-background":"#21252b","--tbl-theme-menu-hover-background":"#2c313a","--tbl-theme-menu-text-color":"#abb2bf","--tbl-theme-select-all-focus-overlay":"rgb(187 204 245 / 15%)","--tbl-theme-select-all-blur-overlay":"rgb(187 204 245 / 15%)"}));let cl=Ht;function R1(i){var t,e,n,r;return{theme:(i==null?void 0:i.theme)??{light:cl.light,dark:cl.dark},style:(i==null?void 0:i.style)??sc.default,selectionType:(i==null?void 0:i.selectionType)??"codemirror",handlePosition:(i==null?void 0:i.handlePosition)??"outside",lineWrapping:(i==null?void 0:i.lineWrapping)??"wrap",markdownConfig:{extensions:((t=i==null?void 0:i.markdownConfig)==null?void 0:t.extensions)??void 0,completeHTMLTags:((e=i==null?void 0:i.markdownConfig)==null?void 0:e.completeHTMLTags)??void 0,pasteURLAsLink:((n=i==null?void 0:i.markdownConfig)==null?void 0:n.pasteURLAsLink)??void 0,htmlTagLanguage:((r=i==null?void 0:i.markdownConfig)==null?void 0:r.htmlTagLanguage)??void 0},extensions:(i==null?void 0:i.extensions)??[],globalKeyBindings:(i==null?void 0:i.globalKeyBindings)??[]}}function Z1(i){return i.ranges.length===1}function oc(i){return Z1(i)&&i.main.empty}function tA({pos:i,assoc:t,bidiLevel:e,goalColumn:n}){return C.create([C.cursor(i,t,e,n)])}function vt(i,{start:t,endExclusive:e}){}function sr({start:i,endExclusive:t},{within:e}={}){}function bd(i){sr({start:i.span.from,endExclusive:i.span.to},{within:{endExclusive:i.doc.length}});const t=eA(i),e=iA(i),n=[];return E(t)&&n.push({from:t.at,insert:t.insert}),E(e)&&n.push({from:e.at,insert:e.insert}),{before:t,after:e,changes:n}}function eA({doc:i,span:{from:t},lineBreak:e}){let n;if(t===0)n=1;else if(t===1)n=i.sliceString(t-1,t)===e?0:2;else{const r=i.sliceString(t-1,t),s=i.sliceString(t-2,t-1);r===e?n=s===e?0:1:n=2}return n===0?void 0:{at:t===0?0:t-1,insert:e.repeat(n),count:n}}function iA({doc:i,span:{to:t},lineBreak:e}){let n;if(t===i.length)n=1;else if(t===i.length-1)n=i.sliceString(t,t+1)===e?0:2;else{const r=i.sliceString(t,t+1),s=i.sliceString(t+1,t+2);r===e?n=s===e?0:1:n=2}return n===0?void 0:{at:t===i.length?i.length:t+1,insert:e.repeat(n),count:n}}const nA=["ATXHeading","Blockquote","BulletList","FencedCode","HTMLBlock","HorizontalRule","IndentedCode","LinkReference","OrderedList","SetextHeading"],rA={remove:nA},X1=[rA];function sA(){return zc({extensions:X1,completeHTMLTags:!1,addKeymap:!1}).language.parser}function oA(){return zc({extensions:sd,completeHTMLTags:!1,addKeymap:!1}).language.parser}function Cn({start:i,endExclusive:t}){return Iterator.from(i<=t?{*[Symbol.iterator](){for(let e=i;e<t;e++)yield e}}:{*[Symbol.iterator](){for(let e=i;e>t;e--)yield e}})}function lc(i,t){const e=new Array(i);for(let n=0;n<i;n++)e[n]=t(n);return e}function Lr(i,t){for(let e=0;e<i;e++)t(e)}function Tr(i,t){return Cn(i).map(e=>t(e)).toArray()}function $i(i,t){return Cn(i).forEach(e=>t(e))}const ac=Y.of(["",""]);function lA(i,{text:t,at:e,prependNewline:n=!1,appendNewline:r=!1}){return dA({needle:Vc(t,{prependNewline:n,appendNewline:r}),haystack:i,at:e})}function aA(i,{text:t,prependNewline:e=!1,appendNewline:n=!1}){return i.append(Vc(t,{prependNewline:e,appendNewline:n}))}function cA(i,{location:t,removeLeadingNewline:e=!1,removeTrailingNewline:n=!1}){const r=e?t.from-1:t.from,s=n?t.to+1:t.to;return r===s?i:i.replace(r,s,Y.empty)}function hA(i,{span:{from:t,to:e},text:n,prependNewline:r=!1,appendNewline:s=!1}){return i.replace(t,e,Vc(n,{prependNewline:r,appendNewline:s}))}function le(i){return Y.of([i])}function uA(i){return i.eq(Y.empty)}function fA(i,t){const e=i.lines;if(e===1){t(i,1);return}Lr(e,n=>{const r=i.line(n+1);t(i.slice(r.from,r.to),n+1)})}function zh(i,{from:t,to:e}){return i.slice(t,e)}function _h(i,t){if(t===0)return Y.empty;if(t===1)return i;let e=i;return Lr(t-1,()=>{e=e.append(i)}),e}function dA({needle:i,haystack:t,at:e}){return t.slice(0,e).append(i).append(t.slice(e))}function Vc(i,{prependNewline:t=!1,appendNewline:e=!1}){let n=i;return t&&(n=ac.append(n)),e&&(n=n.append(ac)),n}function OA(i){return i.name==="Document"}function cc(i){return i.firstChild(),i}function pA(i){return i.nextSibling(),i}function mA(i,t){const e=[];for(;i.nextSibling();)e.push(t(i));return e}function gA(i,t){const e=i.cursor();for(let n=e.next(!0);n;n=e.next(OA(e)))t(e)}function E1(i){return i.name==="Table"}function bA(i){return i.name==="TableDelimiter"}function wA(i){return i[0]}function SA(i){return i[i.length-1]}function vA(i,t){for(const e of i)t(e);return i}function Qm(i,t){const e=[];for(const n of i){const r=[];for(const s of n)r.push(t(s));e.push(r)}return e}function xA(i,t){return i.length<t.min?i.toSpliced(i.length,0,...dd(t.min-i.length,t.fillWith)):i.length>t.max?i.toSpliced(t.max,i.length-t.max):[...i]}function $m(i,{start:t,endExclusive:e}={start:0,endExclusive:i.length}){sr({start:t,endExclusive:e},{within:{endExclusive:i.length}});let n=0;for(let r=t;r<e;r++)n+=i[r];return n}function Ih(i,{start:t,endExclusive:e}={start:0,endExclusive:i.length}){return sr({start:t,endExclusive:e},{within:{endExclusive:i.length}}),i.slice(t,e)}function yA(i){if(i.length===0)return[];const t=new Array(i.length);t[0]=i[0];for(let e=1;e<i.length;e++)t[e]=t[e-1]+i[e];return t}function jh(i){return i.length===0?void 0:i}function kA(i,t){let e=i[0];for(let n=1;n<i.length;n++)t(i[n],e)<0&&(e=i[n]);return e}function ra(i,{count:t}){return dd(t,i)}function Cm(i,{rows:t,cols:e}){const n=[];for(let r=0;r<t;r++)n.push(dd(e,i));return n}function sa(i,t){if(t===0)return[];if(t===1)return[...i];const e=new Array(t*i.length);for(let n=0;n<t;n++){const r=n*i.length;for(let s=0;s<i.length;s++)e[r+s]=i[s]}return e}function QA(i){return i.filter(t=>E(t))}function Bc(i){return i.length===0}function $A(i){return nT(i)}function Pm(i){return{start:0,endExclusive:i.length}}function Ar(i,{fromIndex:t,toIndex:e}){if(vt(t,Pm(i)),vt(e,Pm(i)),t===e)return;const n=i[t];if(t<e)for(let r=t;r<e;r++)i[r]=i[r+1];else for(let r=t;r>e;r--)i[r]=i[r-1];i[e]=n}function bn(i,t,e){return W(i)||W(t)?i===t:rT(i,t,e)}function CA(i,t,e){return i.some(n=>e(n,t))}function ce(i,{min:t,max:e}){return E(t)&&i<=t?t:E(e)&&i>=e?e:i}const Uu=Math.abs,PA=Math.ceil,Tm=Math.floor,wd=Math.max,hc=Math.min,TA=Math.round,AA=Math.trunc,Am=globalThis.parseInt,L1=cT;function RA(i){return i===""?void 0:i}const ZA=new RegExp(new RegExp("(?<!\\\\)(\\\\\\\\)*\\|","g")),XA=[new RegExp(/^(\s|<br>)+/g),new RegExp(new RegExp("(?<=^\\u0000)(\\s|<br>)+","g")),new RegExp(new RegExp("(?<=^\\u0000\\u0000)(\\s|<br>)+","g"))],EA=[new RegExp(/(\s|<br>)+$/g),new RegExp(/(\s|<br>)+(?=\u0000$)/g),new RegExp(/(\s|<br>)+(?=\u0000\u0000$)/g)],LA=new RegExp(/\r\n|\n|\r/g);function Sd(i,t){return le(MA(i.toString(),t))}function uc(i){return Y.of(zA(i.toString()).split(`
56
56
  `))}function MA(i,{trim:t}){return(t?_A(i):i).replaceAll(LA,"<br>").replaceAll(ZA,"\\$&")}function zA(i){return i.replaceAll("<br>",`
57
- `).replaceAll("\\|","|")}function _A(i){let t=i;for(const e of XA)t=t.replaceAll(e,"");for(const e of EA)t=t.replaceAll(e,"");return t}const fc="|",M1=" ",z1=" ",IA=1,jA=1,DA=new Map([["none",1],["left",2],["center",3],["right",2]]),VA=new Map([["none",""],["left",":"],["center",":"],["right",""]]),BA=new Map([["none",""],["left",""],["center",":"],["right",":"]]);function _1(i,t){t.length;const e=Qm(i,O=>Sd(O,{trim:!0})).map(O=>O.map(p=>p.toString())),n=wA(e),r=$A(e),s=e.length,o=n.length,l=lc(o,O=>lc(s,p=>e[p][O])).map((O,p)=>HA(O,t[p])),a=Rm(n,l),c=WA(t,l),h=r.map(O=>Rm(O,l)),u=Y.of([a,c,...h]),f=l.map(O=>IA+O+jA),d=Qm(e,O=>O.length);return{text:u,colSizes:f,alignments:[...t],contentSizes:d}}function Rm(i,t){const e=[fc];return i.forEach((n,r)=>{e.push(M1,n,YA(t[r]-n.length),z1,fc)}),e.join("")}function WA(i,t){const e=[fc];return i.forEach((n,r)=>{const s=GA(n),o=UA(n),l=qA(t[r]-s.length-o.length);e.push(M1,s,l,o,z1,fc)}),e.join("")}function YA(i){return L1(" ",i)}function qA(i){return L1("-",i)}function NA(i){return DA.get(i)}function GA(i){return VA.get(i)}function UA(i){return BA.get(i)}function HA(i,t){return wd(NA(t),...i.map(e=>e.length))}const I1=oA();function Hu(i){const t=I1.parse(new Tc(i));if(!V1(t))throw new Error("Text is not a table");return D1(i,t)}function j1(i){const t=I1.parse(new Tc(i));if(V1(t))return D1(i,t)}function D1(i,t){const e=t.cursor(),n=cc(e),r=cc(n),s=Zm(r).map(O=>zh(i,O)),o=s.length,l=pA(r),a=FA(zh(i,l)),c=mA(l,O=>xA(Zm(O).map(p=>zh(i,p)),{min:o,max:o,fillWith:Y.empty})),h=[s,...c],{text:u,colSizes:f,contentSizes:d}=_1(h,a);return{text:u,colSizes:f,alignments:a,contentSizes:d}}function Zm(i){const t=i;i.firstChild();const e=t,n=[];let r;do{const{from:s,to:o}=e;if(bA(e)){r==="delimiter"&&n.push({from:s,to:s}),r="delimiter";continue}r="cell",n.push({from:s,to:o})}while(e.nextSibling());return e.parent(),n}function FA(i){const t=i.toString().split("|"),e=[];for(const n of t){if(!n.includes("-"))continue;const r=n.includes(":-"),s=n.includes("-:");r?s?e.push("center"):e.push("left"):s?e.push("right"):e.push("none")}return e}function V1(i){const t=i.cursor(),e=cc(t);return E1(e)&&!e.nextSibling()}const KA=(i,{selection:t,doc:e,lineBreak:n})=>{if(!Z1(t))return i;const r=j1(Y.of(i.split(/\r\n|\n|\r/)));if(W(r))return i;const{from:s,to:o}=t.main,{before:l,after:a}=bd({doc:e,lineBreak:n,span:{from:s,to:o}});return`${(l==null?void 0:l.insert)??""}${r.text.toString()}${(a==null?void 0:a.insert)??""}`},JA={combine:i=>Bc(i)?R1():SA(i)},Fu=D.define(JA);function Wc(i){return!i.matchMedia("(any-hover: none)").matches}function tR(i){return/Mac|iPod|iPhone|iPad/.test(i.navigator.platform)?"metaKey":"ctrlKey"}function B1(i,t){return(i==null?void 0:i.from)===(t==null?void 0:t.from)&&(i==null?void 0:i.to)===(t==null?void 0:t.to)}function Xm({needle:i,haystack:t}){const e=i.from<=i.to?i:{from:i.to,to:i.from},n=t.from<=t.to?t:{from:t.to,to:t.from};return e.from>=n.from&&e.to<=n.to}const eR=1,iR=2,W1=4,nR=8,rR=16,sR=1,oR=2,lR=4,aR=8,cR=16,hR=1,uR=2,Kt=Symbol(),Y1="http://www.w3.org/1999/xhtml",fR=!1;var vd=Array.isArray,dR=Array.prototype.indexOf,ro=Array.prototype.includes,Yc=Array.from,OR=Object.defineProperty,Yr=Object.getOwnPropertyDescriptor,pR=Object.getOwnPropertyDescriptors,q1=Object.prototype,mR=Array.prototype,xd=Object.getPrototypeOf,Em=Object.isExtensible;const N1=()=>{};function gR(i){for(var t=0;t<i.length;t++)i[t]()}function G1(){var i,t,e=new Promise((n,r)=>{i=n,t=r});return{promise:e,resolve:i,reject:t}}const ie=2,hl=4,Zl=8,U1=1<<24,dn=16,vi=32,Bn=64,Ku=128,Ge=512,Gt=1024,ne=2048,pi=4096,De=8192,sn=16384,Xl=32768,xr=65536,Lm=1<<17,H1=1<<18,Pr=1<<19,F1=1<<20,en=1<<25,yr=65536,Ju=1<<21,yd=1<<22,Pn=1<<23,Wo=Symbol("$state"),bR=Symbol("legacy props"),wR=Symbol(""),or=new class extends Error{constructor(){super(...arguments);P(this,"name","StaleReactionError");P(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};function K1(i){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function SR(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function vR(i,t,e){throw new Error("https://svelte.dev/e/each_key_duplicate")}function xR(i){throw new Error("https://svelte.dev/e/effect_in_teardown")}function yR(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function kR(i){throw new Error("https://svelte.dev/e/effect_orphan")}function QR(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function $R(i){throw new Error("https://svelte.dev/e/props_invalid_value")}function CR(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function PR(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function TR(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function AR(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function RR(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function J1(i){return i===this.v}function ZR(i,t){return i!=i?t==t:i!==t||i!==null&&typeof i=="object"||typeof i=="function"}function tS(i){return!ZR(i,this.v)}let mo=!1,XR=!1;function ER(){mo=!0}const LR=[];function Dh(i,t=!1,e=!1){return $a(i,new Map,"",LR,null,e)}function $a(i,t,e,n,r=null,s=!1){if(typeof i=="object"&&i!==null){var o=t.get(i);if(o!==void 0)return o;if(i instanceof Map)return new Map(i);if(i instanceof Set)return new Set(i);if(vd(i)){var l=Array(i.length);t.set(i,l),r!==null&&t.set(r,l);for(var a=0;a<i.length;a+=1){var c=i[a];a in i&&(l[a]=$a(c,t,e,n,null,s))}return l}if(xd(i)===q1){l={},t.set(i,l),r!==null&&t.set(r,l);for(var h in i)l[h]=$a(i[h],t,e,n,null,s);return l}if(i instanceof Date)return structuredClone(i);if(typeof i.toJSON=="function"&&!s)return $a(i.toJSON(),t,e,n,i)}if(i instanceof EventTarget)return i;try{return structuredClone(i)}catch{return i}}let $t=null;function so(i){$t=i}function MR(){return zR()}function Wn(i,t=!1,e){$t={p:$t,i:!1,c:null,e:null,s:i,x:null,l:mo&&!t?{s:null,u:null,$:[]}:null}}function Yn(i){var t=$t,e=t.e;if(e!==null){t.e=null;for(var n of e)wS(n)}return t.i=!0,$t=t.p,{}}function El(){return!mo||$t!==null&&$t.l===null}function zR(i){return $t===null&&K1(),$t.c??($t.c=new Map(_R($t)||void 0))}function _R(i){let t=i.p;for(;t!==null;){const e=t.c;if(e!==null)return e;t=t.p}return null}let Mr=[];function IR(){var i=Mr;Mr=[],gR(i)}function on(i){if(Mr.length===0){var t=Mr;queueMicrotask(()=>{t===Mr&&IR()})}Mr.push(i)}function eS(i){var t=at;if(t===null)return it.f|=Pn,i;if(!(t.f&Xl)&&!(t.f&hl))throw i;oo(i,t)}function oo(i,t){for(;t!==null;){if(t.f&Ku){if(!(t.f&Xl))throw i;try{t.b.error(i);return}catch(e){i=e}}t=t.parent}throw i}const jR=-7169;function Dt(i,t){i.f=i.f&jR|t}function kd(i){i.f&Ge||i.deps===null?Dt(i,Gt):Dt(i,pi)}function iS(i){if(i!==null)for(const t of i)!(t.f&ie)||!(t.f&yr)||(t.f^=yr,iS(t.deps))}function nS(i,t,e){i.f&ne?t.add(i):i.f&pi&&e.add(i),iS(i.deps),Dt(i,Gt)}const oa=new Set;let dt=null,te=null,We=[],Qd=null,tf=!1;var Hr,Fr,cr,Kr,bl,wl,hr,Gi,Jr,Bi,ef,nf,rS;const Jd=class Jd{constructor(){A(this,Bi);P(this,"committed",!1);P(this,"current",new Map);P(this,"previous",new Map);A(this,Hr,new Set);A(this,Fr,new Set);A(this,cr,0);A(this,Kr,0);A(this,bl,null);A(this,wl,new Set);A(this,hr,new Set);A(this,Gi,new Map);P(this,"is_fork",!1);A(this,Jr,!1)}is_deferred(){return this.is_fork||w(this,Kr)>0}skip_effect(t){w(this,Gi).has(t)||w(this,Gi).set(t,{d:[],m:[]})}unskip_effect(t){var e=w(this,Gi).get(t);if(e){w(this,Gi).delete(t);for(var n of e.d)Dt(n,ne),ci(n);for(n of e.m)Dt(n,pi),ci(n)}}process(t){var r;We=[],this.apply();var e=[],n=[];for(const s of t)Zt(this,Bi,ef).call(this,s,e,n);if(this.is_deferred()){Zt(this,Bi,nf).call(this,n),Zt(this,Bi,nf).call(this,e);for(const[s,o]of w(this,Gi))lS(s,o)}else{for(const s of w(this,Hr))s();w(this,Hr).clear(),w(this,cr)===0&&Zt(this,Bi,rS).call(this),dt=null,Mm(n),Mm(e),(r=w(this,bl))==null||r.resolve()}te=null}capture(t,e){e!==Kt&&!this.previous.has(t)&&this.previous.set(t,e),!(t.f&Pn)&&(this.current.set(t,t.v),te==null||te.set(t,t.v))}activate(){dt=this,this.apply()}deactivate(){dt===this&&(dt=null,te=null)}flush(){if(this.activate(),We.length>0){if(DR(),dt!==null&&dt!==this)return}else w(this,cr)===0&&this.process([]);this.deactivate()}discard(){for(const t of w(this,Fr))t(this);w(this,Fr).clear()}increment(t){R(this,cr,w(this,cr)+1),t&&R(this,Kr,w(this,Kr)+1)}decrement(t){R(this,cr,w(this,cr)-1),t&&R(this,Kr,w(this,Kr)-1),!w(this,Jr)&&(R(this,Jr,!0),on(()=>{R(this,Jr,!1),this.is_deferred()?We.length>0&&this.flush():this.revive()}))}revive(){for(const t of w(this,wl))w(this,hr).delete(t),Dt(t,ne),ci(t);for(const t of w(this,hr))Dt(t,pi),ci(t);this.flush()}oncommit(t){w(this,Hr).add(t)}ondiscard(t){w(this,Fr).add(t)}settled(){return(w(this,bl)??R(this,bl,G1())).promise}static ensure(){if(dt===null){const t=dt=new Jd;oa.add(dt),on(()=>{dt===t&&t.flush()})}return dt}apply(){}};Hr=new WeakMap,Fr=new WeakMap,cr=new WeakMap,Kr=new WeakMap,bl=new WeakMap,wl=new WeakMap,hr=new WeakMap,Gi=new WeakMap,Jr=new WeakMap,Bi=new WeakSet,ef=function(t,e,n){t.f^=Gt;for(var r=t.first,s=null;r!==null;){var o=r.f,l=(o&(vi|Bn))!==0,a=l&&(o&Gt)!==0,c=a||(o&De)!==0||w(this,Gi).has(r);if(!c&&r.fn!==null){l?r.f^=Gt:s!==null&&o&(hl|Zl|U1)?s.b.defer_effect(r):o&hl?e.push(r):Ml(r)&&(o&dn&&w(this,hr).add(r),ao(r));var h=r.first;if(h!==null){r=h;continue}}for(;r!==null;){r===s&&(s=null);var u=r.next;if(u!==null){r=u;break}r=r.parent}}},nf=function(t){for(var e=0;e<t.length;e+=1)nS(t[e],w(this,wl),w(this,hr))},rS=function(){var r;if(oa.size>1){this.previous.clear();var t=te,e=!0;for(const s of oa){if(s===this){e=!1;continue}const o=[];for(const[a,c]of this.current){if(s.current.has(a))if(e&&c!==s.current.get(a))s.current.set(a,c);else continue;o.push(a)}if(o.length===0)continue;const l=[...s.current.keys()].filter(a=>!this.current.has(a));if(l.length>0){var n=We;We=[];const a=new Set,c=new Map;for(const h of o)sS(h,l,a,c);if(We.length>0){dt=s,s.apply();for(const h of We)Zt(r=s,Bi,ef).call(r,h,[],[]);s.deactivate()}We=n}}dt=null,te=t}this.committed=!0,oa.delete(this)};let ln=Jd;function DR(){tf=!0;try{for(var i=0;We.length>0;){var t=ln.ensure();if(i++>1e3){var e,n;VR()}t.process(We),Tn.clear()}}finally{We=[],tf=!1,Qd=null}}function VR(){try{QR()}catch(i){oo(i,Qd)}}let ni=null;function Mm(i){var t=i.length;if(t!==0){for(var e=0;e<t;){var n=i[e++];if(!(n.f&(sn|De))&&Ml(n)&&(ni=new Set,ao(n),n.deps===null&&n.first===null&&n.nodes===null&&n.teardown===null&&n.ac===null&&yS(n),(ni==null?void 0:ni.size)>0)){Tn.clear();for(const r of ni){if(r.f&(sn|De))continue;const s=[r];let o=r.parent;for(;o!==null;)ni.has(o)&&(ni.delete(o),s.push(o)),o=o.parent;for(let l=s.length-1;l>=0;l--){const a=s[l];!(a.f&(sn|De))&&ao(a)}}ni.clear()}}ni=null}}function sS(i,t,e,n){if(!e.has(i)&&(e.add(i),i.reactions!==null))for(const r of i.reactions){const s=r.f;s&ie?sS(r,t,e,n):s&(yd|dn)&&!(s&ne)&&oS(r,t,n)&&(Dt(r,ne),ci(r))}}function oS(i,t,e){const n=e.get(i);if(n!==void 0)return n;if(i.deps!==null)for(const r of i.deps){if(ro.call(t,r))return!0;if(r.f&ie&&oS(r,t,e))return e.set(r,!0),!0}return e.set(i,!1),!1}function ci(i){for(var t=Qd=i;t.parent!==null;){t=t.parent;var e=t.f;if(tf&&t===at&&e&dn&&!(e&H1))return;if(e&(Bn|vi)){if(!(e&Gt))return;t.f^=Gt}}We.push(t)}function lS(i,t){if(!(i.f&vi&&i.f&Gt)){i.f&ne?t.d.push(i):i.f&pi&&t.m.push(i),Dt(i,Gt);for(var e=i.first;e!==null;)lS(e,t),e=e.next}}function aS(i){let t=0,e=kr(0),n;return()=>{Td()&&($(e),SS(()=>(t===0&&(n=zl(()=>i(()=>Yo(e)))),t+=1,()=>{on(()=>{t-=1,t===0&&(n==null||n(),n=void 0,Yo(e))})})))}}var BR=xr|Pr;function WR(i,t,e){new YR(i,t,e)}var ri,yf,Ui,ur,Pi,Ti,Le,Ai,Hi,fr,yn,ts,es,is,Fi,vc,ke,qR,NR,rf,Ca,sf;class YR{constructor(t,e,n){A(this,ke);P(this,"parent");P(this,"is_pending",!1);A(this,ri);A(this,yf,null);A(this,Ui);A(this,ur);A(this,Pi);A(this,Ti,null);A(this,Le,null);A(this,Ai,null);A(this,Hi,null);A(this,fr,0);A(this,yn,0);A(this,ts,!1);A(this,es,new Set);A(this,is,new Set);A(this,Fi,null);A(this,vc,aS(()=>(R(this,Fi,kr(w(this,fr))),()=>{R(this,Fi,null)})));R(this,ri,t),R(this,Ui,e),R(this,ur,r=>{var s=at;s.b=this,s.f|=Ku,n(r)}),this.parent=at.b,R(this,Pi,Gc(()=>{Zt(this,ke,rf).call(this)},BR))}defer_effect(t){nS(t,w(this,es),w(this,is))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!w(this,Ui).pending}update_pending_count(t){Zt(this,ke,sf).call(this,t),R(this,fr,w(this,fr)+t),!(!w(this,Fi)||w(this,ts))&&(R(this,ts,!0),on(()=>{R(this,ts,!1),w(this,Fi)&&lo(w(this,Fi),w(this,fr))}))}get_effect_pending(){return w(this,vc).call(this),$(w(this,Fi))}error(t){var e=w(this,Ui).onerror;let n=w(this,Ui).failed;if(!e&&!n)throw t;w(this,Ti)&&(ge(w(this,Ti)),R(this,Ti,null)),w(this,Le)&&(ge(w(this,Le)),R(this,Le,null)),w(this,Ai)&&(ge(w(this,Ai)),R(this,Ai,null));var r=!1,s=!1;const o=()=>{if(r){RR();return}r=!0,s&&AR(),w(this,Ai)!==null&&mr(w(this,Ai),()=>{R(this,Ai,null)}),Zt(this,ke,Ca).call(this,()=>{ln.ensure(),Zt(this,ke,rf).call(this)})};on(()=>{try{s=!0,e==null||e(t,o),s=!1}catch(l){oo(l,w(this,Pi)&&w(this,Pi).parent)}n&&R(this,Ai,Zt(this,ke,Ca).call(this,()=>{ln.ensure();try{return Ri(()=>{var l=at;l.b=this,l.f|=Ku,n(w(this,ri),()=>t,()=>o)})}catch(l){return oo(l,w(this,Pi).parent),null}}))})}}ri=new WeakMap,yf=new WeakMap,Ui=new WeakMap,ur=new WeakMap,Pi=new WeakMap,Ti=new WeakMap,Le=new WeakMap,Ai=new WeakMap,Hi=new WeakMap,fr=new WeakMap,yn=new WeakMap,ts=new WeakMap,es=new WeakMap,is=new WeakMap,Fi=new WeakMap,vc=new WeakMap,ke=new WeakSet,qR=function(){try{R(this,Ti,Ri(()=>w(this,ur).call(this,w(this,ri))))}catch(t){this.error(t)}},NR=function(){const t=w(this,Ui).pending;t&&(this.is_pending=!0,R(this,Le,Ri(()=>t(w(this,ri)))),on(()=>{var e=R(this,Hi,document.createDocumentFragment()),n=An();e.append(n),R(this,Ti,Zt(this,ke,Ca).call(this,()=>(ln.ensure(),Ri(()=>w(this,ur).call(this,n))))),w(this,yn)===0&&(w(this,ri).before(e),R(this,Hi,null),mr(w(this,Le),()=>{R(this,Le,null)}),this.is_pending=!1)}))},rf=function(){try{if(this.is_pending=this.has_pending_snippet(),R(this,yn,0),R(this,fr,0),R(this,Ti,Ri(()=>{w(this,ur).call(this,w(this,ri))})),w(this,yn)>0){var t=R(this,Hi,document.createDocumentFragment());$S(w(this,Ti),t);const e=w(this,Ui).pending;R(this,Le,Ri(()=>e(w(this,ri))))}else this.is_pending=!1}catch(e){this.error(e)}},Ca=function(t){var e=at,n=it,r=$t;Vi(w(this,Pi)),Fe(w(this,Pi)),so(w(this,Pi).ctx);try{return t()}catch(s){return eS(s),null}finally{Vi(e),Fe(n),so(r)}},sf=function(t){var e;if(!this.has_pending_snippet()){this.parent&&Zt(e=this.parent,ke,sf).call(e,t);return}if(R(this,yn,w(this,yn)+t),w(this,yn)===0){this.is_pending=!1;for(const n of w(this,es))Dt(n,ne),ci(n);for(const n of w(this,is))Dt(n,pi),ci(n);w(this,es).clear(),w(this,is).clear(),w(this,Le)&&mr(w(this,Le),()=>{R(this,Le,null)}),w(this,Hi)&&(w(this,ri).before(w(this,Hi)),R(this,Hi,null))}};function GR(i,t,e,n){const r=El()?qc:$d;var s=i.filter(f=>!f.settled);if(e.length===0&&s.length===0){n(t.map(r));return}var o=dt,l=at,a=UR(),c=s.length===1?s[0].promise:s.length>1?Promise.all(s.map(f=>f.promise)):null;function h(f){a();try{n(f)}catch(d){!(l.f&sn)&&oo(d,l)}o==null||o.deactivate(),of()}if(e.length===0){c.then(()=>h(t.map(r)));return}function u(){a(),Promise.all(e.map(f=>HR(f))).then(f=>h([...t.map(r),...f])).catch(f=>oo(f,l))}c?c.then(u):u()}function UR(){var i=at,t=it,e=$t,n=dt;return function(r=!0){Vi(i),Fe(t),so(e),r&&(n==null||n.activate())}}function of(){Vi(null),Fe(null),so(null)}function qc(i){var t=ie|ne,e=it!==null&&it.f&ie?it:null;return at!==null&&(at.f|=Pr),{ctx:$t,deps:null,effects:null,equals:J1,f:t,fn:i,reactions:null,rv:0,v:Kt,wv:0,parent:e??at,ac:null}}function HR(i,t,e){let n=at;n===null&&SR();var r=n.b,s=void 0,o=kr(Kt),l=!it,a=new Map;return h5(()=>{var d;var c=G1();s=c.promise;try{Promise.resolve(i()).then(c.resolve,c.reject).then(()=>{h===dt&&h.committed&&h.deactivate(),of()})}catch(O){c.reject(O),of()}var h=dt;if(l){var u=r.is_rendered();r.update_pending_count(1),h.increment(u),(d=a.get(h))==null||d.reject(or),a.delete(h),a.set(h,c)}const f=(O,p=void 0)=>{if(h.activate(),p)p!==or&&(o.f|=Pn,lo(o,p));else{o.f&Pn&&(o.f^=Pn),lo(o,O);for(const[m,g]of a){if(a.delete(m),m===h)break;g.reject(or)}}l&&(r.update_pending_count(-1),h.decrement(u))};c.promise.then(f,O=>f(null,O||"unknown"))}),bS(()=>{for(const c of a.values())c.reject(or)}),new Promise(c=>{function h(u){function f(){u===s?c(o):h(s)}u.then(f,f)}h(s)})}function F(i){const t=qc(i);return CS(t),t}function $d(i){const t=qc(i);return t.equals=tS,t}function FR(i){var t=i.effects;if(t!==null){i.effects=null;for(var e=0;e<t.length;e+=1)ge(t[e])}}function KR(i){for(var t=i.parent;t!==null;){if(!(t.f&ie))return t.f&sn?null:t;t=t.parent}return null}function Cd(i){var t,e=at;Vi(KR(i));try{i.f&=~yr,FR(i),t=RS(i)}finally{Vi(e)}return t}function cS(i){var t=Cd(i);if(!i.equals(t)&&(i.wv=TS(),(!(dt!=null&&dt.is_fork)||i.deps===null)&&(i.v=t,i.deps===null))){Dt(i,Gt);return}_n||(te!==null?(Td()||dt!=null&&dt.is_fork)&&te.set(i,t):kd(i))}function JR(i){var t,e;if(i.effects!==null)for(const n of i.effects)(n.teardown||n.ac)&&((t=n.teardown)==null||t.call(n),(e=n.ac)==null||e.abort(or),n.teardown=N1,n.ac=null,ul(n,0),Ad(n))}function hS(i){if(i.effects!==null)for(const t of i.effects)t.teardown&&ao(t)}let lf=new Set;const Tn=new Map;let uS=!1;function kr(i,t){var e={f:0,v:i,reactions:null,equals:J1,rv:0,wv:0};return e}function ct(i,t){const e=kr(i);return CS(e),e}function t5(i,t=!1,e=!0){var r;const n=kr(i);return t||(n.equals=tS),mo&&e&&$t!==null&&$t.l!==null&&((r=$t.l).s??(r.s=[])).push(n),n}function q(i,t,e=!1){it!==null&&(!hi||it.f&Lm)&&El()&&it.f&(ie|dn|yd|Lm)&&(He===null||!ro.call(He,i))&&TR();let n=e?xe(t):t;return lo(i,n)}function lo(i,t){if(!i.equals(t)){var e=i.v;_n?Tn.set(i,t):Tn.set(i,e),i.v=t;var n=ln.ensure();if(n.capture(i,e),(i.f&ie)!==0){const r=i;i.f&ne&&Cd(r),kd(r)}i.wv=TS(),fS(i,ne),El()&&at!==null&&at.f&Gt&&!(at.f&(vi|Bn))&&(Be===null?f5([i]):Be.push(i)),!n.is_fork&&lf.size>0&&!uS&&e5()}return t}function e5(){uS=!1;for(const i of lf)i.f&Gt&&Dt(i,pi),Ml(i)&&ao(i);lf.clear()}function Yo(i){q(i,i.v+1)}function fS(i,t){var e=i.reactions;if(e!==null)for(var n=El(),r=e.length,s=0;s<r;s++){var o=e[s],l=o.f;if(!(!n&&o===at)){var a=(l&ne)===0;if(a&&Dt(o,t),(l&ie)!==0){var c=o;te==null||te.delete(c),!(l&yr)&&(l&Ge&&(o.f|=yr),fS(c,pi))}else a&&(l&dn&&ni!==null&&ni.add(o),ci(o))}}}function xe(i){if(typeof i!="object"||i===null||Wo in i)return i;const t=xd(i);if(t!==q1&&t!==mR)return i;var e=new Map,n=vd(i),r=ct(0),s=gr,o=l=>{if(gr===s)return l();var a=it,c=gr;Fe(null),Im(s);var h=l();return Fe(a),Im(c),h};return n&&e.set("length",ct(i.length)),new Proxy(i,{defineProperty(l,a,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&CR();var h=e.get(a);return h===void 0?o(()=>{var u=ct(c.value);return e.set(a,u),u}):q(h,c.value,!0),!0},deleteProperty(l,a){var c=e.get(a);if(c===void 0){if(a in l){const h=o(()=>ct(Kt));e.set(a,h),Yo(r)}}else q(c,Kt),Yo(r);return!0},get(l,a,c){var d;if(a===Wo)return i;var h=e.get(a),u=a in l;if(h===void 0&&(!u||(d=Yr(l,a))!=null&&d.writable)&&(h=o(()=>{var O=xe(u?l[a]:Kt),p=ct(O);return p}),e.set(a,h)),h!==void 0){var f=$(h);return f===Kt?void 0:f}return Reflect.get(l,a,c)},getOwnPropertyDescriptor(l,a){var c=Reflect.getOwnPropertyDescriptor(l,a);if(c&&"value"in c){var h=e.get(a);h&&(c.value=$(h))}else if(c===void 0){var u=e.get(a),f=u==null?void 0:u.v;if(u!==void 0&&f!==Kt)return{enumerable:!0,configurable:!0,value:f,writable:!0}}return c},has(l,a){var f;if(a===Wo)return!0;var c=e.get(a),h=c!==void 0&&c.v!==Kt||Reflect.has(l,a);if(c!==void 0||at!==null&&(!h||(f=Yr(l,a))!=null&&f.writable)){c===void 0&&(c=o(()=>{var d=h?xe(l[a]):Kt,O=ct(d);return O}),e.set(a,c));var u=$(c);if(u===Kt)return!1}return h},set(l,a,c,h){var S;var u=e.get(a),f=a in l;if(n&&a==="length")for(var d=c;d<u.v;d+=1){var O=e.get(d+"");O!==void 0?q(O,Kt):d in l&&(O=o(()=>ct(Kt)),e.set(d+"",O))}if(u===void 0)(!f||(S=Yr(l,a))!=null&&S.writable)&&(u=o(()=>ct(void 0)),q(u,xe(c)),e.set(a,u));else{f=u.v!==Kt;var p=o(()=>xe(c));q(u,p)}var m=Reflect.getOwnPropertyDescriptor(l,a);if(m!=null&&m.set&&m.set.call(h,c),!f){if(n&&typeof a=="string"){var g=e.get("length"),b=Number(a);Number.isInteger(b)&&b>=g.v&&q(g,b+1)}Yo(r)}return!0},ownKeys(l){$(r);var a=Reflect.ownKeys(l).filter(u=>{var f=e.get(u);return f===void 0||f.v!==Kt});for(var[c,h]of e)h.v!==Kt&&!(c in l)&&a.push(c);return a},setPrototypeOf(){PR()}})}var zm,dS,OS,pS;function i5(){if(zm===void 0){zm=window,dS=/Firefox/.test(navigator.userAgent);var i=Element.prototype,t=Node.prototype,e=Text.prototype;OS=Yr(t,"firstChild").get,pS=Yr(t,"nextSibling").get,Em(i)&&(i.__click=void 0,i.__className=void 0,i.__attributes=null,i.__style=void 0,i.__e=void 0),Em(e)&&(e.__t=void 0)}}function An(i=""){return document.createTextNode(i)}function _i(i){return OS.call(i)}function Ll(i){return pS.call(i)}function Ue(i,t){return _i(i)}function Et(i,t=!1){{var e=_i(i);return e instanceof Comment&&e.data===""?Ll(e):e}}function et(i,t=1,e=!1){let n=i;for(;t--;)n=Ll(n);return n}function n5(i){i.textContent=""}function mS(){return!1}function r5(i,t,e){return document.createElementNS(Y1,i,void 0)}function Pd(i){var t=it,e=at;Fe(null),Vi(null);try{return i()}finally{Fe(t),Vi(e)}}function gS(i){at===null&&(it===null&&kR(),yR()),_n&&xR()}function s5(i,t){var e=t.last;e===null?t.last=t.first=i:(e.next=i,i.prev=e,t.last=i)}function xi(i,t,e){var n=at;n!==null&&n.f&De&&(i|=De);var r={ctx:$t,deps:null,nodes:null,f:i|ne|Ge,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};if(e)try{ao(r)}catch(l){throw ge(r),l}else t!==null&&ci(r);var s=r;if(e&&s.deps===null&&s.teardown===null&&s.nodes===null&&s.first===s.last&&!(s.f&Pr)&&(s=s.first,i&dn&&i&xr&&s!==null&&(s.f|=xr)),s!==null&&(s.parent=n,n!==null&&s5(s,n),it!==null&&(it.f&ie)!==0&&(i&Bn)===0)){var o=it;(o.effects??(o.effects=[])).push(s)}return r}function Td(){return it!==null&&!hi}function bS(i){const t=xi(Zl,null,!1);return Dt(t,Gt),t.teardown=i,t}function Nc(i){gS();var t=at.f,e=!it&&(t&vi)!==0&&(t&Xl)===0;if(e){var n=$t;(n.e??(n.e=[])).push(i)}else return wS(i)}function wS(i){return xi(hl|F1,i,!1)}function o5(i){return gS(),xi(Zl|F1,i,!0)}function l5(i){ln.ensure();const t=xi(Bn|Pr,i,!0);return()=>{ge(t)}}function a5(i){ln.ensure();const t=xi(Bn|Pr,i,!0);return(e={})=>new Promise(n=>{e.outro?mr(t,()=>{ge(t),n(void 0)}):(ge(t),n(void 0))})}function c5(i){return xi(hl,i,!1)}function h5(i){return xi(yd|Pr,i,!0)}function SS(i,t=0){return xi(Zl|t,i,!0)}function se(i,t=[],e=[],n=[]){GR(n,t,e,r=>{xi(Zl,()=>i(...r.map($)),!0)})}function Gc(i,t=0){var e=xi(dn|t,i,!0);return e}function Ri(i){return xi(vi|Pr,i,!0)}function vS(i){var t=i.teardown;if(t!==null){const e=_n,n=it;_m(!0),Fe(null);try{t.call(null)}finally{_m(e),Fe(n)}}}function Ad(i,t=!1){var e=i.first;for(i.first=i.last=null;e!==null;){const r=e.ac;r!==null&&Pd(()=>{r.abort(or)});var n=e.next;e.f&Bn?e.parent=null:ge(e,t),e=n}}function u5(i){for(var t=i.first;t!==null;){var e=t.next;!(t.f&vi)&&ge(t),t=e}}function ge(i,t=!0){var e=!1;(t||i.f&H1)&&i.nodes!==null&&i.nodes.end!==null&&(xS(i.nodes.start,i.nodes.end),e=!0),Ad(i,t&&!e),ul(i,0),Dt(i,sn);var n=i.nodes&&i.nodes.t;if(n!==null)for(const s of n)s.stop();vS(i);var r=i.parent;r!==null&&r.first!==null&&yS(i),i.next=i.prev=i.teardown=i.ctx=i.deps=i.fn=i.nodes=i.ac=null}function xS(i,t){for(;i!==null;){var e=i===t?null:Ll(i);i.remove(),i=e}}function yS(i){var t=i.parent,e=i.prev,n=i.next;e!==null&&(e.next=n),n!==null&&(n.prev=e),t!==null&&(t.first===i&&(t.first=n),t.last===i&&(t.last=e))}function mr(i,t,e=!0){var n=[];kS(i,n,!0);var r=()=>{e&&ge(i),t&&t()},s=n.length;if(s>0){var o=()=>--s||r();for(var l of n)l.out(o)}else r()}function kS(i,t,e){if(!(i.f&De)){i.f^=De;var n=i.nodes&&i.nodes.t;if(n!==null)for(const l of n)(l.is_global||e)&&t.push(l);for(var r=i.first;r!==null;){var s=r.next,o=(r.f&xr)!==0||(r.f&vi)!==0&&(i.f&dn)!==0;kS(r,t,o?e:!1),r=s}}}function Rd(i){QS(i,!0)}function QS(i,t){if(i.f&De){i.f^=De,!(i.f&Gt)&&(Dt(i,ne),ci(i));for(var e=i.first;e!==null;){var n=e.next,r=(e.f&xr)!==0||(e.f&vi)!==0;QS(e,r?t:!1),e=n}var s=i.nodes&&i.nodes.t;if(s!==null)for(const o of s)(o.is_global||t)&&o.in()}}function $S(i,t){if(i.nodes)for(var e=i.nodes.start,n=i.nodes.end;e!==null;){var r=e===n?null:Ll(e);t.append(e),e=r}}let Pa=!1,_n=!1;function _m(i){_n=i}let it=null,hi=!1;function Fe(i){it=i}let at=null;function Vi(i){at=i}let He=null;function CS(i){it!==null&&(He===null?He=[i]:He.push(i))}let Se=null,Ee=0,Be=null;function f5(i){Be=i}let PS=1,lr=0,gr=lr;function Im(i){gr=i}function TS(){return++PS}function Ml(i){var t=i.f;if(t&ne)return!0;if(t&ie&&(i.f&=~yr),(t&pi)!==0){for(var e=i.deps,n=e.length,r=0;r<n;r++){var s=e[r];if(Ml(s)&&cS(s),s.wv>i.wv)return!0}t&Ge&&te===null&&Dt(i,Gt)}return!1}function AS(i,t,e=!0){var n=i.reactions;if(n!==null&&!(He!==null&&ro.call(He,i)))for(var r=0;r<n.length;r++){var s=n[r];s.f&ie?AS(s,t,!1):t===s&&(e?Dt(s,ne):s.f&Gt&&Dt(s,pi),ci(s))}}function RS(i){var p;var t=Se,e=Ee,n=Be,r=it,s=He,o=$t,l=hi,a=gr,c=i.f;Se=null,Ee=0,Be=null,it=c&(vi|Bn)?null:i,He=null,so(i.ctx),hi=!1,gr=++lr,i.ac!==null&&(Pd(()=>{i.ac.abort(or)}),i.ac=null);try{i.f|=Ju;var h=i.fn,u=h();i.f|=Xl;var f=i.deps,d=dt==null?void 0:dt.is_fork;if(Se!==null){var O;if(d||ul(i,Ee),f!==null&&Ee>0)for(f.length=Ee+Se.length,O=0;O<Se.length;O++)f[Ee+O]=Se[O];else i.deps=f=Se;if(Td()&&i.f&Ge)for(O=Ee;O<f.length;O++)((p=f[O]).reactions??(p.reactions=[])).push(i)}else!d&&f!==null&&Ee<f.length&&(ul(i,Ee),f.length=Ee);if(El()&&Be!==null&&!hi&&f!==null&&!(i.f&(ie|pi|ne)))for(O=0;O<Be.length;O++)AS(Be[O],i);if(r!==null&&r!==i){if(lr++,r.deps!==null)for(let m=0;m<e;m+=1)r.deps[m].rv=lr;if(t!==null)for(const m of t)m.rv=lr;Be!==null&&(n===null?n=Be:n.push(...Be))}return i.f&Pn&&(i.f^=Pn),u}catch(m){return eS(m)}finally{i.f^=Ju,Se=t,Ee=e,Be=n,it=r,He=s,so(o),hi=l,gr=a}}function d5(i,t){let e=t.reactions;if(e!==null){var n=dR.call(e,i);if(n!==-1){var r=e.length-1;r===0?e=t.reactions=null:(e[n]=e[r],e.pop())}}if(e===null&&t.f&ie&&(Se===null||!ro.call(Se,t))){var s=t;s.f&Ge&&(s.f^=Ge,s.f&=~yr),kd(s),JR(s),ul(s,0)}}function ul(i,t){var e=i.deps;if(e!==null)for(var n=t;n<e.length;n++)d5(i,e[n])}function ao(i){var t=i.f;if(!(t&sn)){Dt(i,Gt);var e=at,n=Pa;at=i,Pa=!0;try{t&(dn|U1)?u5(i):Ad(i),vS(i);var r=RS(i);i.teardown=typeof r=="function"?r:null,i.wv=PS;var s;fR&&XR&&i.f&ne&&i.deps}finally{Pa=n,at=e}}}function $(i){var t=i.f,e=(t&ie)!==0;if(it!==null&&!hi){var n=at!==null&&(at.f&sn)!==0;if(!n&&(He===null||!ro.call(He,i))){var r=it.deps;if(it.f&Ju)i.rv<lr&&(i.rv=lr,Se===null&&r!==null&&r[Ee]===i?Ee++:Se===null?Se=[i]:Se.push(i));else{(it.deps??(it.deps=[])).push(i);var s=i.reactions;s===null?i.reactions=[it]:ro.call(s,it)||s.push(it)}}}if(_n&&Tn.has(i))return Tn.get(i);if(e){var o=i;if(_n){var l=o.v;return(!(o.f&Gt)&&o.reactions!==null||XS(o))&&(l=Cd(o)),Tn.set(o,l),l}var a=(o.f&Ge)===0&&!hi&&it!==null&&(Pa||(it.f&Ge)!==0),c=(o.f&Xl)===0;Ml(o)&&(a&&(o.f|=Ge),cS(o)),a&&!c&&(hS(o),ZS(o))}if(te!=null&&te.has(i))return te.get(i);if(i.f&Pn)throw i.v;return i.v}function ZS(i){if(i.f|=Ge,i.deps!==null)for(const t of i.deps)(t.reactions??(t.reactions=[])).push(i),t.f&ie&&!(t.f&Ge)&&(hS(t),ZS(t))}function XS(i){if(i.v===Kt)return!0;if(i.deps===null)return!1;for(const t of i.deps)if(Tn.has(t)||t.f&ie&&XS(t))return!0;return!1}function zl(i){var t=hi;try{return hi=!0,i()}finally{hi=t}}const ar=Symbol("events"),ES=new Set,af=new Set;function LS(i,t,e,n={}){function r(s){if(n.capture||cf.call(t,s),!s.cancelBubble)return Pd(()=>e==null?void 0:e.call(this,s))}return i.startsWith("pointer")||i.startsWith("touch")||i==="wheel"?on(()=>{t.addEventListener(i,r,n)}):t.addEventListener(i,r,n),r}function Mt(i,t,e,n={}){var r=LS(t,i,e,n);return()=>{i.removeEventListener(t,r,n)}}function la(i,t,e,n,r){var s={capture:n,passive:r},o=LS(i,t,e,s);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&bS(()=>{t.removeEventListener(i,o,s)})}function Eo(i,t,e){(t[ar]??(t[ar]={}))[i]=e}function MS(i){for(var t=0;t<i.length;t++)ES.add(i[t]);for(var e of af)e(i)}let jm=null;function cf(i){var m,g;var t=this,e=t.ownerDocument,n=i.type,r=((m=i.composedPath)==null?void 0:m.call(i))||[],s=r[0]||i.target;jm=i;var o=0,l=jm===i&&i[ar];if(l){var a=r.indexOf(l);if(a!==-1&&(t===document||t===window)){i[ar]=t;return}var c=r.indexOf(t);if(c===-1)return;a<=c&&(o=a)}if(s=r[o]||i.target,s!==t){OR(i,"currentTarget",{configurable:!0,get(){return s||e}});var h=it,u=at;Fe(null),Vi(null);try{for(var f,d=[];s!==null;){var O=s.assignedSlot||s.parentNode||s.host||null;try{var p=(g=s[ar])==null?void 0:g[n];p!=null&&(!s.disabled||i.target===s)&&p.call(s,i)}catch(b){f?d.push(b):f=b}if(i.cancelBubble||O===t||O===null)break;s=O}if(f){for(let b of d)queueMicrotask(()=>{throw b});throw f}}finally{i[ar]=t,delete i.currentTarget,Fe(h),Vi(u)}}}var xg;const Vh=((xg=globalThis==null?void 0:globalThis.window)==null?void 0:xg.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:i=>i});function O5(i){return(Vh==null?void 0:Vh.createHTML(i))??i}function Zd(i,t=!1){var e=r5("template");return i=i.replaceAll("<!>","<!---->"),e.innerHTML=t?O5(i):i,e.content}function co(i,t){var e=at;e.nodes===null&&(e.nodes={start:i,end:t,a:null,t:null})}function ot(i,t){var e=(t&hR)!==0,n=(t&uR)!==0,r,s=!i.startsWith("<!>");return()=>{r===void 0&&(r=Zd(s?i:"<!>"+i,!0),e||(r=_i(r)));var o=n||dS?document.importNode(r,!0):r.cloneNode(!0);if(e){var l=_i(o),a=o.lastChild;co(l,a)}else co(o,o);return o}}function p5(i,t,e="svg"){var n=!i.startsWith("<!>"),r=`<${e}>${n?i:"<!>"+i}</${e}>`,s;return()=>{if(!s){var o=Zd(r,!0),l=_i(o);s=_i(l)}var a=s.cloneNode(!0);return co(a,a),a}}function ei(i,t){return p5(i,t,"svg")}function Te(i=""){{var t=An(i+"");return co(t,t),t}}function Xd(){var i=document.createDocumentFragment(),t=document.createComment(""),e=An();return i.append(t,e),co(t,e),i}function I(i,t){i!==null&&i.before(t)}const m5=["touchstart","touchmove"];function g5(i){return m5.includes(i)}function qi(i,t){var e=t==null?"":typeof t=="object"?t+"":t;e!==(i.__t??(i.__t=i.nodeValue))&&(i.__t=e,i.nodeValue=e+"")}function zS(i,t){return b5(i,t)}const aa=new Map;function b5(i,{target:t,anchor:e,props:n={},events:r,context:s,intro:o=!0}){i5();var l=void 0,a=a5(()=>{var c=e??t.appendChild(An());WR(c,{pending:()=>{}},f=>{Wn({});var d=$t;s&&(d.c=s),r&&(n.$$events=r),l=i(f,n)||{},Yn()});var h=new Set,u=f=>{for(var d=0;d<f.length;d++){var O=f[d];if(!h.has(O)){h.add(O);var p=g5(O);for(const b of[t,document]){var m=aa.get(b);m===void 0&&(m=new Map,aa.set(b,m));var g=m.get(O);g===void 0?(b.addEventListener(O,cf,{passive:p}),m.set(O,1)):m.set(O,g+1)}}}};return u(Yc(ES)),af.add(u),()=>{var p;for(var f of h)for(const m of[t,document]){var d=aa.get(m),O=d.get(f);--O==0?(m.removeEventListener(f,cf),d.delete(f),d.size===0&&aa.delete(m)):d.set(f,O)}af.delete(u),c!==e&&((p=c.parentNode)==null||p.removeChild(c))}});return hf.set(l,a),l}let hf=new WeakMap;function _S(i,t){const e=hf.get(i);return e?(hf.delete(i),e(t)):Promise.resolve()}var si,Ki,oi,dr,Sl,xc,kf;class IS{constructor(t,e=!0){P(this,"anchor");A(this,si,new Map);A(this,Ki,new Map);A(this,oi,new Map);A(this,dr,new Set);A(this,Sl,!0);A(this,xc,()=>{var t=dt;if(w(this,si).has(t)){var e=w(this,si).get(t),n=w(this,Ki).get(e);if(n)Rd(n),w(this,dr).delete(e);else{var r=w(this,oi).get(e);r&&(w(this,Ki).set(e,r.effect),w(this,oi).delete(e),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(const[s,o]of w(this,si)){if(w(this,si).delete(s),s===t)break;const l=w(this,oi).get(o);l&&(ge(l.effect),w(this,oi).delete(o))}for(const[s,o]of w(this,Ki)){if(s===e||w(this,dr).has(s))continue;const l=()=>{if(Array.from(w(this,si).values()).includes(s)){var a=document.createDocumentFragment();$S(o,a),a.append(An()),w(this,oi).set(s,{effect:o,fragment:a})}else ge(o);w(this,dr).delete(s),w(this,Ki).delete(s)};w(this,Sl)||!n?(w(this,dr).add(s),mr(o,l,!1)):l()}}});A(this,kf,t=>{w(this,si).delete(t);const e=Array.from(w(this,si).values());for(const[n,r]of w(this,oi))e.includes(n)||(ge(r.effect),w(this,oi).delete(n))});this.anchor=t,R(this,Sl,e)}ensure(t,e){var n=dt,r=mS();e&&!w(this,Ki).has(t)&&!w(this,oi).has(t)&&w(this,Ki).set(t,Ri(()=>e(this.anchor))),w(this,si).set(n,t),r||w(this,xc).call(this)}}si=new WeakMap,Ki=new WeakMap,oi=new WeakMap,dr=new WeakMap,Sl=new WeakMap,xc=new WeakMap,kf=new WeakMap;function Qr(i,t,...e){var n=new IS(i);Gc(()=>{const r=t()??null;n.ensure(r,r&&(s=>r(s,...e)))},xr)}function Uc(i){$t===null&&K1(),mo&&$t.l!==null?w5($t).m.push(i):Nc(()=>{const t=zl(i);if(typeof t=="function")return t})}function w5(i){var t=i.l;return t.u??(t.u={a:[],b:[],m:[]})}function Ft(i,t,e=!1){var n=new IS(i),r=e?xr:0;function s(o,l){n.ensure(o,l)}Gc(()=>{var o=!1;t((l,a=0)=>{o=!0,s(a,l)}),o||s(!1,null)},r)}function S5(i,t,e){for(var n=[],r=t.length,s,o=t.length,l=0;l<r;l++){let u=t[l];mr(u,()=>{if(s){if(s.pending.delete(u),s.done.add(u),s.pending.size===0){var f=i.outrogroups;uf(Yc(s.done)),f.delete(s),f.size===0&&(i.outrogroups=null)}}else o-=1},!1)}if(o===0){var a=n.length===0&&e!==null;if(a){var c=e,h=c.parentNode;n5(h),h.append(c),i.items.clear()}uf(t,!a)}else s={pending:new Set(t),done:new Set},(i.outrogroups??(i.outrogroups=new Set)).add(s)}function uf(i,t=!0){for(var e=0;e<i.length;e++)ge(i[e],t)}var Dm;function ca(i,t,e,n,r,s=null){var o=i,l=new Map,a=(t&W1)!==0;if(a){var c=i;o=c.appendChild(An())}var h=null,u=$d(()=>{var g=e();return vd(g)?g:g==null?[]:Yc(g)}),f,d=!0;function O(){m.fallback=h,v5(m,f,o,t,n),h!==null&&(f.length===0?h.f&en?(h.f^=en,Lo(h,null,o)):Rd(h):mr(h,()=>{h=null}))}var p=Gc(()=>{f=$(u);for(var g=f.length,b=new Set,S=dt,x=mS(),y=0;y<g;y+=1){var k=f[y],Q=n(k,y),X=d?null:l.get(Q);X?(X.v&&lo(X.v,k),X.i&&lo(X.i,y),x&&S.unskip_effect(X.e)):(X=x5(l,d?o:Dm??(Dm=An()),k,Q,y,r,t,e),d||(X.e.f|=en),l.set(Q,X)),b.add(Q)}if(g===0&&s&&!h&&(d?h=Ri(()=>s(o)):(h=Ri(()=>s(Dm??(Dm=An()))),h.f|=en)),g>b.size&&vR(),!d)if(x){for(const[B,L]of l)b.has(B)||S.skip_effect(L.e);S.oncommit(O),S.ondiscard(()=>{})}else O();$(u)}),m={effect:p,items:l,outrogroups:null,fallback:h};d=!1}function Co(i){for(;i!==null&&!(i.f&vi);)i=i.next;return i}function v5(i,t,e,n,r){var L,V,_,G,U,H,Xt,_t,Yt;var s=(n&nR)!==0,o=t.length,l=i.items,a=Co(i.effect.first),c,h=null,u,f=[],d=[],O,p,m,g;if(s)for(g=0;g<o;g+=1)O=t[g],p=r(O,g),m=l.get(p).e,!(m.f&en)&&((V=(L=m.nodes)==null?void 0:L.a)==null||V.measure(),(u??(u=new Set)).add(m));for(g=0;g<o;g+=1){if(O=t[g],p=r(O,g),m=l.get(p).e,i.outrogroups!==null)for(const lt of i.outrogroups)lt.pending.delete(m),lt.done.delete(m);if(m.f&en)if(m.f^=en,m===a)Lo(m,null,e);else{var b=h?h.next:a;m===i.effect.last&&(i.effect.last=m.prev),m.prev&&(m.prev.next=m.next),m.next&&(m.next.prev=m.prev),pn(i,h,m),pn(i,m,b),Lo(m,b,e),h=m,f=[],d=[],a=Co(h.next);continue}if(m.f&De&&(Rd(m),s&&((G=(_=m.nodes)==null?void 0:_.a)==null||G.unfix(),(u??(u=new Set)).delete(m))),m!==a){if(c!==void 0&&c.has(m)){if(f.length<d.length){var S=d[0],x;h=S.prev;var y=f[0],k=f[f.length-1];for(x=0;x<f.length;x+=1)Lo(f[x],S,e);for(x=0;x<d.length;x+=1)c.delete(d[x]);pn(i,y.prev,k.next),pn(i,h,y),pn(i,k,S),a=S,h=k,g-=1,f=[],d=[]}else c.delete(m),Lo(m,a,e),pn(i,m.prev,m.next),pn(i,m,h===null?i.effect.first:h.next),pn(i,h,m),h=m;continue}for(f=[],d=[];a!==null&&a!==m;)(c??(c=new Set)).add(a),d.push(a),a=Co(a.next);if(a===null)continue}!(m.f&en)&&f.push(m),h=m,a=Co(m.next)}if(i.outrogroups!==null){for(const lt of i.outrogroups)lt.pending.size===0&&(uf(Yc(lt.done)),(U=i.outrogroups)==null||U.delete(lt));i.outrogroups.size===0&&(i.outrogroups=null)}if(a!==null||c!==void 0){var Q=[];if(c!==void 0)for(m of c)!(m.f&De)&&Q.push(m);for(;a!==null;)!(a.f&De)&&a!==i.fallback&&Q.push(a),a=Co(a.next);var X=Q.length;if(X>0){var B=n&W1&&o===0?e:null;if(s){for(g=0;g<X;g+=1)(Xt=(H=Q[g].nodes)==null?void 0:H.a)==null||Xt.measure();for(g=0;g<X;g+=1)(Yt=(_t=Q[g].nodes)==null?void 0:_t.a)==null||Yt.fix()}S5(i,Q,B)}}s&&on(()=>{var lt,Vt;if(u!==void 0)for(m of u)(Vt=(lt=m.nodes)==null?void 0:lt.a)==null||Vt.apply()})}function x5(i,t,e,n,r,s,o,l){var a=o&eR?o&rR?kr(e):t5(e,!1,!1):null,c=o&iR?kr(r):null;return{v:a,i:c,e:Ri(()=>(s(t,a??e,c??r,l),()=>{i.delete(n)}))}}function Lo(i,t,e){if(i.nodes)for(var n=i.nodes.start,r=i.nodes.end,s=t&&!(t.f&en)?t.nodes.start:e;n!==null;){var o=Ll(n);if(s.before(n),n===r)return;n=o}}function pn(i,t,e){t===null?i.effect.first=e:t.next=e,e===null?i.effect.last=t:e.prev=t}function y5(i,t,e=!1,n=!1,r=!1){var s=i,o="";se(()=>{var l=at;if(o!==(o=t()??"")&&(l.nodes!==null&&(xS(l.nodes.start,l.nodes.end),l.nodes=null),o!=="")){var a=o+"";e?a=`<svg>${a}</svg>`:n&&(a=`<math>${a}</math>`);var c=Zd(a);if((e||n)&&(c=_i(c)),co(_i(c),c.lastChild),e||n)for(;_i(c);)s.before(_i(c));else s.before(c)}})}function Vm(i,t=!1){var e=t?" !important;":";",n="";for(var r in i){var s=i[r];s!=null&&s!==""&&(n+=" "+r+": "+s+e)}return n}function k5(i,t){if(t){var e="",n,r;return Array.isArray(t)?(n=t[0],r=t[1]):n=t,n&&(e+=Vm(n)),r&&(e+=Vm(r,!0)),e=e.trim(),e===""?null:e}return String(i)}function Bh(i,t={},e,n){for(var r in e){var s=e[r];t[r]!==s&&(e[r]==null?i.style.removeProperty(r):i.style.setProperty(r,s,n))}}function dc(i,t,e,n){var r=i.__style;if(r!==t){var s=k5(t,n);s==null?i.removeAttribute("style"):i.style.cssText=s,i.__style=t}else n&&(Array.isArray(n)?(Bh(i,e==null?void 0:e[0],n[0]),Bh(i,e==null?void 0:e[1],n[1],"important")):Bh(i,e,n));return n}const Q5=Symbol("is custom element"),$5=Symbol("is html");function Qt(i,t,e,n){var r=C5(i);r[t]!==(r[t]=e)&&(t==="loading"&&(i[wR]=e),e==null?i.removeAttribute(t):typeof e!="string"&&P5(i).includes(t)?i[t]=e:i.setAttribute(t,e))}function C5(i){return i.__attributes??(i.__attributes={[Q5]:i.nodeName.includes("-"),[$5]:i.namespaceURI===Y1})}var Bm=new Map;function P5(i){var t=i.getAttribute("is")||i.nodeName,e=Bm.get(t);if(e)return e;Bm.set(t,e=[]);for(var n,r=i,s=Element.prototype;s!==r;){n=pR(r);for(var o in n)n[o].set&&e.push(o);r=xd(r)}return e}function Wm(i,t){return i===t||(i==null?void 0:i[Wo])===t}function Oc(i={},t,e,n){return c5(()=>{var r,s;return SS(()=>{r=s,s=[],zl(()=>{i!==e(...s)&&(t(i,...s),r&&Wm(e(...r),i)&&t(null,...r))})}),()=>{on(()=>{s&&Wm(e(...s),i)&&t(null,...s)})}}),i}let ha=!1;function T5(i){var t=ha;try{return ha=!1,[i(),ha]}finally{ha=t}}function ff(i,t,e,n){var S;var r=!mo||(e&oR)!==0,s=(e&aR)!==0,o=(e&cR)!==0,l=n,a=!0,c=()=>(a&&(a=!1,l=o?zl(n):n),l),h;if(s){var u=Wo in i||bR in i;h=((S=Yr(i,t))==null?void 0:S.set)??(u&&t in i?x=>i[t]=x:void 0)}var f,d=!1;s?[f,d]=T5(()=>i[t]):f=i[t],f===void 0&&n!==void 0&&(f=c(),h&&(r&&$R(),h(f)));var O;if(r?O=()=>{var x=i[t];return x===void 0?c():(a=!0,x)}:O=()=>{var x=i[t];return x!==void 0&&(l=void 0),x===void 0?l:x},r&&(e&lR)===0)return O;if(h){var p=i.$$legacy;return function(x,y){return arguments.length>0?((!r||!y||p||d)&&h(y?O():x),x):O()}}var m=!1,g=(e&sR?qc:$d)(()=>(m=!1,O()));s&&$(g);var b=at;return function(x,y){if(arguments.length>0){const k=y?$(g):r&&s?xe(x):x;return q(g,k),m=!0,l!==void 0&&(l=k),x}return _n&&m||b.f&sn?g.v:$(g)}}function go(i){var t;return"ownerDocument"in i?((t=i.ownerDocument)==null?void 0:t.defaultView)??window:window}function fl(i){return"ownerDocument"in i?i.ownerDocument:document}function jS(i){return i instanceof Node||i instanceof go(i).Node}function A5(i){return i instanceof HTMLBRElement||i instanceof go(i).HTMLBRElement}function DS(i){return i instanceof Element||i instanceof go(i).Element}function R5(i){return i instanceof HTMLElement||i instanceof go(i).HTMLElement}function Ed(i){if(W(i)||!R5(i))throw new Error("Target is not an HTMLElement");return i}function VS(i,t){return jS(t)?i.contains(t):!1}function BS(i){if(jS(i))return DS(i)?i:i.parentElement??void 0}function WS(i,t){var e;return((e=BS(i))==null?void 0:e.querySelector(Ld(t)))??void 0}function YS(i,t){var e;return((e=BS(i))==null?void 0:e.closest(Ld(t)))??void 0}function qS(i,t){return DS(i)&&i.matches(Ld(t))}function Z5({ancestor:i,descendent:t,getText:e}){const n=[];for(let r=t;r!==i;r=r.parentNode){const s=[];for(let o=r.parentNode.firstChild;o!==r;o=o.nextSibling)s.push((e==null?void 0:e(o))??o.textContent??"");n.unshift(s.join(""))}return n.join("")}function Ld(i){return FT(i,(t,e)=>`[data-${t}="${e}"]`).join("")}const Ym=-1;function X5(i,t){const e=document.createElement("div");e.className="cm-content",e.appendChild(t);const n=document.createElement("div");n.className="cm-scroller",n.appendChild(e);const r=document.createElement("div");r.className=`cm-editor ${i.themeClasses}`,r.appendChild(n),r.style="visibility: hidden;",fl(i.dom).body.appendChild(r);const{height:s}=t.getBoundingClientRect();return fl(i.dom).body.removeChild(r),s}function E5(i,t){const e=go(i),n=new e.ResizeObserver(([r],s)=>{const{borderBoxSize:[o]}=r;t({height:o.blockSize})});return n.observe(i,{box:"border-box"}),()=>n.disconnect()}async function L5({millis:i}){return await new Promise(t=>setTimeout(t,i))}function $r(...i){return()=>i.forEach(t=>t())}function M5({delayMillis:i}){let t=!1;return L5({millis:i}).then(()=>t=!0),()=>t}const qr=["table.correct","table.delete","table.edit","table.focus","table.format","table.navigate","table.select"],z5=qr.map(i=>`${i}.undo`),_5=qr.map(i=>`${i}.redo`),I5=new Map([...qr.map(i=>[i,`${i}.undo`]),...qr.map(i=>[`${i}.undo`,`${i}.redo`]),...qr.map(i=>[`${i}.redo`,`${i}.undo`])]),j5=new Set(["table.correct.undo","table.delete.undo","table.format.undo"]),D5=new Set(["table.edit.undo","table.edit.redo"]),NS=[...qr,...z5,..._5];function V5(i){return I5.get(i)}function B5(i){return j5.has(i)}function W5(i){return D5.has(i)}const Md=Ke.define(),Y5=new Map(NS.map(i=>[i,Md.of(i)]));function Rn(i){return Y5.get(i)}function zd(i){return E(Hc(i))}function q5(i){const t=Hc(i);return E(t)&&B5(t)}function N5(i){const t=Hc(i);return E(t)&&t==="table.focus"}function G5(i){const t=Hc(i);return E(t)&&W5(t)}function Hc(i){return i.annotation(Md)}function Qn(i,{start:t,endExclusive:e}){return t<=e?i>=t&&i<e:i<=t&&i>e}function qm({start:i,endExclusive:t}){return i===t}function Nm(i,t){return(i==null?void 0:i.start)===(t==null?void 0:t.start)&&(i==null?void 0:i.endExclusive)===(t==null?void 0:t.endExclusive)}function U5(i,t){if(i.length===0)return-1;let e=0,n=i.length-1;for(;e!==n;){const r=e+PA((n-e)/2);i[r]>t?n=r-1:e=r}return i[e]<=t?e:-1}class rt{constructor({row:t,col:e}){P(this,"row");P(this,"col");this.row=t,this.col=e}rowOrCol(t){return t==="row"?this.row:this.col}get startRow(){return this.row.start}get startCol(){return this.col.start}startRowOrCol(t){return t==="row"?this.startRow:this.startCol}get endRow(){return this.row.endExclusive-1}get endCol(){return this.col.endExclusive-1}endRowOrCol(t){return t==="row"?this.endRow:this.endCol}get rowRange(){return this.row}get colRange(){return this.col}rowOrColRange(t){return t==="row"?this.rowRange:this.colRange}get rowCount(){return this.row.endExclusive-this.row.start}get colCount(){return this.col.endExclusive-this.col.start}get topLeftCell(){return{row:this.startRow,col:this.startCol}}get topRightCell(){return{row:this.startRow,col:this.endCol}}get bottomRightCell(){return{row:this.endRow,col:this.endCol}}get bottomLeftCell(){return{row:this.endRow,col:this.startCol}}cornerCellAt(t){switch(t){case"top-left":return this.topLeftCell;case"top-right":return this.topRightCell;case"bottom-right":return this.bottomRightCell;case"bottom-left":return this.bottomLeftCell}}containsRow(t){return Qn(t,this.rowRange)}containsCol(t){return Qn(t,this.colRange)}containsCell({row:t,col:e}){return this.containsRow(t)&&this.containsCol(e)}containsOnEdge({row:t,col:e}){return this.containsCell({row:t,col:e})?{top:t===this.startRow,right:e===this.endCol,bottom:t===this.endRow,left:e===this.startCol}:{top:!1,right:!1,bottom:!1,left:!1}}isSingleCell(){return this.rowCount===1&&this.colCount===1}shiftUp(){return rt.of({row:{start:this.row.start-1,endExclusive:this.row.endExclusive-1},col:{...this.col}})}shiftRight(){return rt.of({row:{...this.row},col:{start:this.col.start+1,endExclusive:this.col.endExclusive+1}})}shiftDown(){return rt.of({row:{start:this.row.start+1,endExclusive:this.row.endExclusive+1},col:{...this.col}})}shiftLeft(){return rt.of({row:{...this.row},col:{start:this.col.start-1,endExclusive:this.col.endExclusive-1}})}shift(t,e){return t==="row"?e==="backward"?this.shiftUp():this.shiftDown():e==="backward"?this.shiftLeft():this.shiftRight()}expandUp(){return rt.of({row:{start:this.row.start-1,endExclusive:this.row.endExclusive},col:{...this.col}})}expandRight(){return rt.of({row:{...this.row},col:{start:this.col.start,endExclusive:this.col.endExclusive+1}})}expandDown(){return rt.of({row:{start:this.row.start,endExclusive:this.row.endExclusive+1},col:{...this.col}})}expandLeft(){return rt.of({row:{...this.row},col:{start:this.col.start-1,endExclusive:this.col.endExclusive}})}contractUp(){return rt.of({row:{start:this.row.start,endExclusive:this.row.endExclusive-1},col:{...this.col}})}contractRight(){return rt.of({row:{...this.row},col:{start:this.col.start+1,endExclusive:this.col.endExclusive}})}contractDown(){return rt.of({row:{start:this.row.start+1,endExclusive:this.row.endExclusive},col:{...this.col}})}contractLeft(){return rt.of({row:{...this.row},col:{start:this.col.start,endExclusive:this.col.endExclusive-1}})}addForwardsByRowOrCol(t,{start:e,count:n}){if(e>this.endRowOrCol(t))return this;const r=e<=this.startRowOrCol(t)?n:0,s=n;return this.withRowOrCol(t,{start:this.startRowOrCol(t)+r,endExclusive:this.endRowOrCol(t)+s+1})}subtractBackwardsByRowOrCol(t,{start:e,count:n,min:r}){if(e-n-1>=this.endRowOrCol(t))return this;if(e<=this.startRowOrCol(t)){const u={start:ce(this.rowOrCol(t).start-n,{min:r}),endExclusive:ce(this.rowOrCol(t).endExclusive-n,{min:r})};return qm(u)?void 0:this.withRowOrCol(t,u)}const s=this.rowOrColRange(t),o={start:e-n,endExclusive:e},l={start:wd(s.start,o.start),endExclusive:hc(s.endExclusive,o.endExclusive)},a=l.endExclusive-l.start,c=e>s.endExclusive?0:n-a,h={start:ce(s.start-c,{min:r}),endExclusive:ce(s.endExclusive-c-a,{min:r})};return qm(h)?void 0:this.withRowOrCol(t,h)}withRowOrCol(t,e){return t==="row"?rt.of({row:e,col:{...this.col}}):rt.of({row:{...this.row},col:e})}static of(t){return new rt(t)}static ofCell(t){return new rt({row:{start:t.row,endExclusive:t.row+1},col:{start:t.col,endExclusive:t.col+1}})}}const GS=le(" "),Gm=GS,H5=GS;function F5(i,{hyphens:t=0}={}){return i==="none"?le("-").append(Mo(t)):i==="left"?le(":-").append(Mo(t)):i==="center"?le(":-").append(Mo(t)).append(le(":")):Mo(t).append(le("-:"))}function Mo(i){return le("-".repeat(i))}function Wh(i){return le(" ".repeat(i))}var dl;(i=>{function t(n){return pc.of(n)}i.of=t;function e(n){return pc.maybeOf(n)}i.maybeOf=e})(dl||(dl={}));const nt=1,df=1,Gn=df,Yh=1,Um=df+df,Hm=2,K5=new Map([["none",1],["left",2],["center",3],["right",2]]);function Fm(i){return K5.get(i)}function ua(i,t){const e=i.from;return{from:e+t.from,to:e+t.to}}function Po(i,t){return i.from+t}var ns,rs,ss,os,ls;const qo=class qo{constructor({text:t,colSizes:e,alignments:n,contentSizes:r}){A(this,ns);A(this,rs);A(this,ss);A(this,os);A(this,ls);P(this,"firstRowIndex",0);P(this,"firstColIndex",0);P(this,"headerRowIndex",0);P(this,"firstDataRowIndex",1);P(this,"firstCellLocation",{row:this.firstRowIndex,col:this.firstColIndex});R(this,ns,ct(xe(t))),R(this,rs,ct(xe(e))),R(this,ss,ct(xe(n))),R(this,os,ct(xe(r))),R(this,ls,ct(xe(this.parseCells())))}get text(){return $(w(this,ns))}set text(t){q(w(this,ns),t,!0)}get colSizes(){return $(w(this,rs))}set colSizes(t){q(w(this,rs),t,!0)}get alignments(){return $(w(this,ss))}set alignments(t){q(w(this,ss),t,!0)}get contentSizes(){return $(w(this,os))}set contentSizes(t){q(w(this,os),t,!0)}get cells(){return $(w(this,ls))}set cells(t){q(w(this,ls),t,!0)}cellAt({row:t,col:e}){return vt(t,this.rowRange),vt(e,this.colRange),this.cells[t][e]}get firstCellSpan(){return this.cellSpan(this.firstCellLocation)}get lastCellSpan(){return this.cellSpan(this.lastCellLocation)}cellSpan(t){return vt(t.row,this.rowRange),vt(t.col,this.colRange),this.absoluteCellContentSpan(t)}closestCellAtPosition(t){if(t>this.text.length)return this.lastCellLocation;const{number:e,from:n}=this.text.lineAt(t);if(e===Hm)return this.hasDataRows()?{row:this.firstDataRowIndex,col:this.firstColIndex}:{row:this.headerRowIndex,col:this.lastColIndex};const r=t-n,s=e===1?this.headerRowIndex:e-2;let o=nt;const l=this.mapEachCol(c=>{const h=o;return o+=this.colSizes[c]+nt,h}),a=U5(l,r);return a===-1?{row:s,col:this.firstColIndex}:{row:s,col:a}}firstRowOrColIndex(t){return 0}get lastRowIndex(){return this.rowCount-1}get lastColIndex(){return this.colCount-1}lastRowOrColIndex(t){return t==="row"?this.lastRowIndex:this.lastColIndex}get rowCount(){return this.contentSizes.length}get colCount(){return this.colSizes.length}rowOrColCount(t){return t==="row"?this.rowCount:this.colCount}get rowRange(){return{start:this.firstRowIndex,endExclusive:this.lastRowIndex+1}}get colRange(){return{start:this.firstColIndex,endExclusive:this.lastColIndex+1}}rowOrColRange(t){return t==="row"?this.rowRange:this.colRange}get rowIndices(){return Tr(this.rowRange,t=>t)}get colIndices(){return Tr(this.colRange,t=>t)}get dataRowIndices(){return this.hasDataRows()?Tr({start:this.firstDataRowIndex,endExclusive:this.lastRowIndex+1},t=>t):[]}get lastCellLocation(){return{row:this.lastRowIndex,col:this.lastColIndex}}get rowCellCount(){return this.colCount}get colCellCount(){return this.rowCount}rowOrColCellCount(t){return t==="row"?this.rowCellCount:this.colCellCount}hasSingleRow(){return this.rowCount===1}hasSingleCol(){return this.colCount===1}hasSingleRowOrCol(t){return t==="row"?this.hasSingleRow():this.hasSingleCol()}hasDataRows(){return this.rowCount>1}hasRowAt(t){return Qn(t,this.rowRange)}hasColAt(t){return Qn(t,this.colRange)}hasRowOrColAt(t,e){return t==="row"?this.hasRowAt(e):this.hasColAt(e)}hasEmptyRowAt(t){return this.hasRowAt(t)&&this.contentSizes[t].every(e=>e===0)}hasEmptyColAt(t){return this.hasColAt(t)&&this.contentSizes.every(e=>e[t]===0)}hasEmptyRowOrColAt(t,e){return t==="row"?this.hasEmptyRowAt(e):this.hasEmptyColAt(e)}forEachRow(t){$i(this.rowRange,t)}forEachCol(t){$i(this.colRange,t)}mapEachRow(t){return Tr(this.rowRange,t)}mapEachCol(t){return Tr(this.colRange,t)}equals(t){const e=t._asInternal();return this.text.eq(e.text)&&bn(this.alignments,e.alignments,(n,r)=>n===r)&&bn(this.cells,e.cells,(n,r)=>bn(n,r,(s,o)=>s.eq(o)))&&bn(this.colSizes,e.colSizes,(n,r)=>n===r)&&bn(this.contentSizes,e.contentSizes,(n,r)=>bn(n,r,(s,o)=>s===o))}sliceSectionAt({rowRange:t,colRange:e,startRow:n,startCol:r,endCol:s}){sr(t,{within:this.rowRange}),sr(e,{within:this.colRange});const o=Ih(this.colSizes,e),l=Ih(this.alignments,e),a=[];let c=Y.empty;$i(t,u=>{a.push(Ih(this.contentSizes[u],e));const f=this.absoluteCellStart({row:u,col:r})-nt,d=this.absoluteCellEnd({row:u,col:s})+nt;if(u===n){c=c.append(this.sliceTextAt({from:f,to:d})),c=c.append(ac);const O=this.absoluteAlignmentStart(r)-nt,p=this.absoluteAlignmentEnd(s)+nt;c=c.append(this.sliceTextAt({from:O,to:p}))}else c=c.append(ac),c=c.append(this.sliceTextAt({from:f,to:d}))});const h=new qo({text:c,colSizes:o,contentSizes:a,alignments:l});return h.forEachCol(u=>{const f=h.calculateColSize(u),d=f-h.colSizes[u];h.forEachRow(O=>{h.addOrRemoveCellPadding({row:O,col:u},d)}),h.addOrRemoveAlignmentHyphens({col:u,diff:d}),h.colSizes[u]=f}),h.cells=h.parseCells(),h}setCellAt(t,e){vt(t.row,this.rowRange),vt(t.col,this.colRange);const n=this.absoluteCellSpan(t),r=e.length;this.contentSizes[t.row][t.col]=r;const s=this.calculateColSize(t.col),o=s-Gn-r;this.replaceTextAt(n,Gm.append(e).append(Wh(o)));const l=s-this.colSizes[t.col];this.forEachRow(a=>{a!==t.row&&this.addOrRemoveCellPadding({row:a,col:t.col},l)}),this.addOrRemoveAlignmentHyphens({col:t.col,diff:l}),this.colSizes[t.col]=s,this.cells[t.row][t.col]=e}setAlignmentAt(t,e){vt(t,this.colRange);const n=this.absoluteAlignmentSpan(t),r=Fm(e);this.alignments[t]=e;const s=this.calculateColSize(t),o=s-Um-r,l=F5(e,{hyphens:o});this.replaceTextAt(n,Gm.append(l).append(H5));const a=s-this.colSizes[t];this.forEachRow(c=>{this.addOrRemoveCellPadding({row:c,col:t},a)}),this.colSizes[t]=s}clearRow(t){vt(t,this.rowRange),this.clearSection(rt.of({row:{start:t,endExclusive:t+1},col:this.colRange}))}clearCol(t){vt(t,this.colRange),this.clearSection(rt.of({row:this.rowRange,col:{start:t,endExclusive:t+1}}))}clearRowOrCol(t,e){t==="row"?this.clearRow(e):this.clearCol(e)}clearSection({rowRange:t,colRange:e}){sr(t,{within:this.rowRange}),sr(e,{within:this.colRange}),$i(e,n=>{$i(t,o=>{this.contentSizes[o][n]=0,this.cells[o][n]=Y.empty});const r=this.calculateColSize(n);$i(t,o=>{const l=this.absoluteCellSpan({row:o,col:n});this.replaceTextAt(l,Wh(r))});const s=r-this.colSizes[n];this.forEachRow(o=>{Qn(o,t)||this.addOrRemoveCellPadding({row:o,col:n},s)}),this.addOrRemoveAlignmentHyphens({col:n,diff:s}),this.colSizes[n]=r})}prependEmptyRows(t){this.addEmptyRowsAt({row:this.firstRowIndex,count:t})}prependEmptyCols(t){this.addEmptyColsAt({col:this.firstColIndex,count:t})}addEmptyRowsAt({row:t,count:e}){if(vt(t,{start:this.firstRowIndex,endExclusive:this.rowCount+1}),e===0)return;const n=this.colSizes.map(s=>`|${" ".repeat(s)}`);n.push("|");const r=le(n.join(""));if(t===this.headerRowIndex){const s=this.headerRowLine(),o=this.sliceTextAt(s);this.replaceTextAt(s,r);const l=this.alignmentLine().to;this.addTextAt(o,l,{prependNewline:!0}),Lr(e-1,()=>this.addTextAt(r,l,{prependNewline:!0}))}else if(t===this.rowCount){const s=(this.hasSingleRow()?this.alignmentLine():this.rowLine(this.lastRowIndex)).to;Lr(e,()=>this.addTextAt(r,s,{prependNewline:!0}))}else{const s=this.rowLine(t).from;Lr(e,()=>this.addTextAt(r,s,{appendNewline:!0}))}this.contentSizes.splice(t,0,...Cm(0,{rows:e,cols:this.colCount})),this.cells.splice(t,0,...Cm(Y.empty,{rows:e,cols:this.colCount}))}addEmptyColsAt({col:t,count:e}){if(vt(t,{start:this.firstColIndex,endExclusive:this.lastColIndex+2}),e!==0){if(t===this.firstColIndex){const n=le("| ".repeat(e)),r=le("| - ".repeat(e));this.forEachRow(s=>{this.addTextAt(n,this.absoluteCellStart({row:s,col:t})-nt)}),this.addTextAt(r,this.absoluteAlignmentStart(t)-nt)}else{const n=le(" |".repeat(e)),r=le(" - |".repeat(e));this.forEachRow(s=>{this.addTextAt(n,this.absoluteCellEnd({row:s,col:t-1})+nt)}),this.addTextAt(r,this.absoluteAlignmentEnd(t-1)+nt)}this.colSizes.splice(t,0,...ra(3,{count:e})),this.alignments.splice(t,0,...ra("none",{count:e})),this.contentSizes.forEach(n=>n.splice(t,0,...ra(0,{count:e}))),this.cells.forEach(n=>n.splice(t,0,...ra(Y.empty,{count:e})))}}addEmptyRowsOrColsAt(t,{index:e,count:n}){t==="row"?this.addEmptyRowsAt({row:e,count:n}):this.addEmptyColsAt({col:e,count:n})}appendEmptyRows(t){this.addEmptyRowsAt({row:this.lastRowIndex+1,count:t})}appendEmptyCols(t){this.addEmptyColsAt({col:this.lastColIndex+1,count:t})}duplicateRowAt(t){if(vt(t,this.rowRange),t===this.headerRowIndex){const e=this.sliceTextAt(this.rowLine(t));this.addTextAt(e,this.alignmentLine().to,{prependNewline:!0})}else{const e=this.rowLine(t),n=this.sliceTextAt(e);this.addTextAt(n,e.to,{prependNewline:!0})}this.contentSizes.splice(t+1,0,[...this.contentSizes[t]]),this.cells.splice(t+1,0,[...this.cells[t]])}duplicateColAt(t){vt(t,this.colRange),this.forEachRow(r=>{const{from:s,to:o}=this.absoluteCellSpan({row:r,col:t});this.addTextAt(this.sliceTextAt({from:s,to:o+nt}),o+nt)});const{from:e,to:n}=this.absoluteAlignmentSpan(t);this.addTextAt(this.sliceTextAt({from:e,to:n+nt}),n+nt),this.colSizes.splice(t+1,0,this.colSizes[t]),this.alignments.splice(t+1,0,this.alignments[t]),this.contentSizes.forEach(r=>r.splice(t+1,0,r[t])),this.cells.forEach(r=>r.splice(t+1,0,r[t]))}duplicateRowOrColAt(t,e){t==="row"?this.duplicateRowAt(e):this.duplicateColAt(e)}moveRowAt({fromIndex:t,toIndex:e}){if(vt(t,this.rowRange),vt(e,this.rowRange),t!==e){if(Uu(t-e)===1){const[n,r]=t<e?[t,e]:[e,t],s=this.rowLine(n),o=this.sliceTextAt(s),l=this.rowLine(r),a=this.sliceTextAt(l);this.replaceTextAt(l,o),this.replaceTextAt(s,a)}else if(t===this.headerRowIndex){const n=this.headerRowLine(),r=this.sliceTextAt(n),s=this.rowLine(this.firstDataRowIndex),o=this.sliceTextAt(s),l=this.rowLine(e);this.addTextAt(r,l.to,{prependNewline:!0}),this.removeTextAt(s,{removeLeadingNewline:!0}),this.replaceTextAt(n,o)}else if(e===this.headerRowIndex){const n=this.rowLine(t),r=this.sliceTextAt(n),s=this.headerRowLine(),o=this.sliceTextAt(s);this.removeTextAt(n,{removeLeadingNewline:!0}),this.addTextAt(o,this.alignmentLine().to,{prependNewline:!0}),this.replaceTextAt(s,r)}else if(e<t){const n=this.rowLine(t),r=this.sliceTextAt(n),s=this.rowLine(e);this.removeTextAt(n,{removeLeadingNewline:!0}),this.addTextAt(r,s.from,{appendNewline:!0})}else if(e>t){const n=this.rowLine(t),r=this.sliceTextAt(n),s=this.rowLine(e);this.addTextAt(r,s.to,{prependNewline:!0}),this.removeTextAt(n,{removeTrailingNewline:!0})}Ar(this.contentSizes,{fromIndex:t,toIndex:e}),Ar(this.cells,{fromIndex:t,toIndex:e})}}moveColAt({fromIndex:t,toIndex:e}){if(vt(t,this.colRange),vt(e,this.colRange),t===e)return;e<t?this.forEachRow(r=>{const s=this.absoluteCellSpan({row:r,col:t}),o=this.sliceTextAt({from:s.from,to:s.to+nt}),l=this.absoluteCellStart({row:r,col:e});this.removeTextAt({from:s.from,to:s.to+nt}),this.addTextAt(o,l)}):this.forEachRow(r=>{const s=this.absoluteCellSpan({row:r,col:t}),o=this.sliceTextAt({from:s.from-nt,to:s.to}),l=this.absoluteCellEnd({row:r,col:e});this.addTextAt(o,l),this.removeTextAt({from:s.from-nt,to:s.to})});const n=this.absoluteAlignmentSpan(t);if(e<t){const r=this.sliceTextAt({from:n.from,to:n.to+nt}),s=this.absoluteAlignmentStart(e);this.removeTextAt({from:n.from,to:n.to+nt}),this.addTextAt(r,s)}else{const r=this.sliceTextAt({from:n.from-nt,to:n.to}),s=this.absoluteAlignmentEnd(e);this.addTextAt(r,s),this.removeTextAt({from:n.from-nt,to:n.to})}Ar(this.colSizes,{fromIndex:t,toIndex:e}),Ar(this.alignments,{fromIndex:t,toIndex:e}),this.contentSizes.forEach(r=>Ar(r,{fromIndex:t,toIndex:e})),this.cells.forEach(r=>Ar(r,{fromIndex:t,toIndex:e}))}moveRowOrColAt(t,e){t==="row"?this.moveRowAt(e):this.moveColAt(e)}removeRowsAt({row:t,count:e}){if(vt(t,this.rowRange),vt(e,{start:0,endExclusive:this.rowCount}),e!==0){if(t===this.headerRowIndex){const n=this.rowLine(e),r=this.sliceTextAt(n),{from:s}=this.rowLine(this.firstDataRowIndex),{to:o}=n;this.removeTextAt({from:s,to:o},{removeLeadingNewline:!0}),this.replaceTextAt(this.headerRowLine(),r)}else{const{from:n}=this.rowLine(t),{to:r}=this.rowLine(t+e-1);this.removeTextAt({from:n,to:r},{removeLeadingNewline:!0})}this.contentSizes.splice(t,e),this.cells.splice(t,e),this.forEachCol(n=>{const r=this.calculateColSize(n),s=r-this.colSizes[n];this.forEachRow(o=>{this.addOrRemoveCellPadding({row:o,col:n},s)}),this.addOrRemoveAlignmentHyphens({col:n,diff:s}),this.colSizes[n]=r})}}removeColsAt({col:t,count:e}){if(vt(t,this.colRange),vt(e,{start:0,endExclusive:this.colCount}),e===0)return;this.forEachRow(s=>{this.removeTextAt({from:this.absoluteCellStart({row:s,col:t}),to:this.absoluteCellEnd({row:s,col:t+e-1})+nt})});const{from:n}=this.absoluteAlignmentSpan(t),{to:r}=this.absoluteAlignmentSpan(t+e-1);this.removeTextAt({from:n,to:r+nt}),this.colSizes.splice(t,e),this.alignments.splice(t,e),this.contentSizes.forEach(s=>s.splice(t,e)),this.cells.forEach(s=>s.splice(t,e))}removeRowsOrColsAt(t,{index:e,count:n}){t==="row"?this.removeRowsAt({row:e,count:n}):this.removeColsAt({col:e,count:n})}merge(t,{row:e,col:n}){vt(e,this.rowRange),vt(n,this.colRange);const r=e===this.headerRowIndex,s=ce(e+t.rowCount-this.rowCount,{min:0}),o=ce(n+t.colCount-this.colCount,{min:0}),l={start:e,endExclusive:e+t.rowCount},a={start:n,endExclusive:n+t.colCount};this.appendEmptyRows(s),this.appendEmptyCols(o);const c=t._asInternal();if($i(l,h=>{this.contentSizes[h].splice(n,c.colCount,...c.contentSizes[h-e]),this.cells[h].splice(n,c.colCount,...c.cells[h-e]);const u={from:this.absoluteCellStart({row:h,col:a.start})-nt,to:this.absoluteCellEnd({row:h,col:a.endExclusive-1})+nt},f=c.sliceTextAt(c.rowLine(h-e));this.replaceTextAt(u,f)}),r){this.alignments.splice(n,c.colCount,...c.alignments);const h={from:this.absoluteAlignmentStart(a.start)-nt,to:this.absoluteAlignmentEnd(a.endExclusive-1)+nt},u=c.sliceTextAt(c.alignmentLine());this.replaceTextAt(h,u)}$i(a,h=>{const u=this.calculateColSize(h),f=u-this.colSizes[h],d=u-c.colSizes[h-n];this.forEachRow(O=>{this.addOrRemoveCellPadding({row:O,col:h},Qn(O,l)?d:f)}),this.addOrRemoveAlignmentHyphens({col:h,diff:r?d:f}),this.colSizes[h]=u})}tile({rowRepeat:t,colRepeat:e}){if(!(t===0&&e===0)){if(e>=1){this.forEachRow(o=>{const{from:l,to:a}=this.rowLine(o),c=this.sliceTextAt({from:l+nt,to:a});this.addTextAt(_h(c,e),a)});const{from:n,to:r}=this.alignmentLine(),s=this.sliceTextAt({from:n+nt,to:r});this.addTextAt(_h(s,e),r),this.alignments=sa(this.alignments,e+1),this.colSizes=sa(this.colSizes,e+1),this.forEachRow(o=>{this.contentSizes[o]=sa(this.contentSizes[o],e+1),this.cells[o]=sa(this.cells[o],e+1)})}if(t>=1){const{from:n,to:r}=this.alignmentLine(),s=this.text.replace(n-nt,r,Y.empty);this.appendText(_h(Vc(s,{prependNewline:!0}),t));const o=this.rowRange;Lr(t,()=>{$i(o,l=>{this.contentSizes.push([...this.contentSizes[l]]),this.cells.push([...this.cells[l]])})})}}}sortByColAt(t,e){if(vt(t,this.colRange),this.rowCount===1)return;const n={start:this.firstDataRowIndex,endExclusive:this.lastRowIndex+1},r=Tr(n,c=>c).sort((c,h)=>e(this.cellAt({row:c,col:t}),this.cellAt({row:h,col:t}))),s=this.rowLines(),o=s.map(({from:c,to:h})=>this.sliceTextAt({from:c,to:h})),l=[...this.contentSizes],a=[...this.cells];$i(n,c=>{const h=r[c-this.firstDataRowIndex];c!==h&&(this.replaceTextAt(s[c],o[h]),this.contentSizes[c]=l[h],this.cells[c]=a[h])})}reset(t){const{text:e,colSizes:n,alignments:r,contentSizes:s}=Hu(t);this.text=e,this.colSizes=n,this.alignments=r,this.contentSizes=s,this.cells=this.parseCells()}_asInternal(){return this}toJSON(){return{text:this.text.toString(),colSizes:Dh(this.colSizes),alignments:Dh(this.alignments),contentSizes:Dh(this.contentSizes),cells:this.cells.map(t=>t.map(e=>e.toString()))}}addTextAt(t,e,{prependNewline:n=!1,appendNewline:r=!1}={}){this.text=lA(this.text,{text:t,at:e,prependNewline:n,appendNewline:r})}appendText(t,{prependNewline:e=!1,appendNewline:n=!1}={}){this.text=aA(this.text,{text:t,prependNewline:e,appendNewline:n})}removeTextAt(t,{removeLeadingNewline:e=!1,removeTrailingNewline:n=!1}={}){this.text=cA(this.text,{location:t,removeLeadingNewline:e,removeTrailingNewline:n})}replaceTextAt(t,e,{prependNewline:n=!1,appendNewline:r=!1}={}){this.text=hA(this.text,{span:t,text:e,prependNewline:n,appendNewline:r})}sliceTextAt({from:t,to:e}){return this.text.slice(t,e)}addAlignmentHyphens({col:t,count:e}){this.addTextAt(Mo(e),this.absoluteAlignmentStart(t)+Gn+Yh)}removeAlignmentHyphens({col:t,count:e}){const n=this.absoluteAlignmentStart(t);this.removeTextAt({from:n+Gn+Yh,to:n+Gn+Yh+e})}addOrRemoveAlignmentHyphens({col:t,diff:e}){e<0?this.removeAlignmentHyphens({col:t,count:-e}):e>0&&this.addAlignmentHyphens({col:t,count:e})}addCellPadding(t,e){this.addTextAt(Wh(e),this.absoluteCellContentEnd(t)+1)}removeCellPadding(t,e){const n=this.absoluteCellContentEnd(t);this.removeTextAt({from:n,to:n+e})}addOrRemoveCellPadding(t,e){e<0?this.removeCellPadding(t,-e):e>0&&this.addCellPadding(t,e)}alignmentLine(){return this.text.line(Hm)}headerRowLine(){return this.text.line(1)}rowLine(t){return this.text.line(t===this.headerRowIndex?t+1:t+2)}rowLines(){return lc(this.text.lines-1,t=>this.text.line(t===this.headerRowIndex?t+1:t+2))}relativeCellStart(t){const e=(t+1)*nt,n=$m(this.colSizes,{start:0,endExclusive:t});return e+n}relativeCellStarts(){const t=yA(this.colSizes);return this.mapEachCol(e=>{const n=(e+1)*nt,r=e===this.firstColIndex?0:t[e-1];return n+r})}relativeCellContentStart(t){return this.relativeCellStart(t)+Gn}relativeCellContentStarts(){return this.relativeCellStarts().map(t=>t+Gn)}relativeCellEnd(t){const e=(t+1)*nt,n=$m(this.colSizes,{start:0,endExclusive:t+1});return e+n}relativeCellSpan(t){const e=this.relativeCellStart(t);return{from:e,to:e+this.colSizes[t]}}relativeAlignmentStart(t){return this.relativeCellStart(t)}relativeAlignmentEnd(t){return this.relativeCellEnd(t)}relativeAlignmentSpan(t){return this.relativeCellSpan(t)}absoluteCellStart({row:t,col:e}){return Po(this.rowLine(t),this.relativeCellStart(e))}absoluteCellContentSpan({row:t,col:e}){const n=this.relativeCellStart(e)+Gn,r=n+this.contentSizes[t][e];return ua(this.rowLine(t),{from:n,to:r})}absoluteCellContentEnd(t){return Po(this.rowLine(t.row),this.relativeCellContentStart(t.col)+this.contentSizes[t.row][t.col])}absoluteCellEnd({row:t,col:e}){return Po(this.rowLine(t),this.relativeCellEnd(e))}absoluteCellSpan({row:t,col:e}){return ua(this.rowLine(t),this.relativeCellSpan(e))}absoluteAlignmentStart(t){return Po(this.alignmentLine(),this.relativeAlignmentStart(t))}absoluteAlignmentEnd(t){return Po(this.alignmentLine(),this.relativeAlignmentEnd(t))}absoluteAlignmentSpan(t){return ua(this.alignmentLine(),this.relativeAlignmentSpan(t))}calculateColSize(t){const e=lc(this.rowCount,r=>this.contentSizes[r][t]),n=Fm(this.alignments[t]);return wd(...e,n)+Um}parseCells(){const t=this.rowLines(),e=this.relativeCellContentStarts();return this.mapEachRow(n=>this.mapEachCol(r=>{const s={from:e[r],to:e[r]+this.contentSizes[n][r]},{from:o,to:l}=ua(t[n],s);return this.text.slice(o,l)}))}static of(t){return new qo(Hu(t))}static maybeOf(t){const e=j1(t);return E(e)?new qo(e):void 0}};ns=new WeakMap,rs=new WeakMap,ss=new WeakMap,os=new WeakMap,ls=new WeakMap;let pc=qo;function Cr(i,t){return(i==null?void 0:i.row)===(t==null?void 0:t.row)&&(i==null?void 0:i.col)===(t==null?void 0:t.col)}function US({row:i,col:t}){return{row:i-1,col:t}}function HS({row:i,col:t}){return{row:i,col:t+1}}function FS({row:i,col:t}){return{row:i+1,col:t}}function KS({row:i,col:t}){return{row:i,col:t-1}}function qh(i,t,e){return i==="row"?e==="backward"?US(t):FS(t):e==="backward"?KS(t):HS(t)}function Km(i,t,{start:e,count:n}){return Of(i,t,e<=t[i]?t[i]+n:t[i])}function Jm(i,t,{start:e,count:n,boundary:r}){return E(r)&&(r.min,r.max),e-n-1>=t[i]?t:e<=t[i]?Of(i,t,t[i]-n):E(r)?Of(i,t,ce(t[i],{min:r.min,max:r.max})):void 0}function Of(i,t,e){return i==="row"?{row:e,col:t.col}:{row:t.row,col:e}}function JS(i,t){return(i==null?void 0:i.anchor)===(t==null?void 0:t.anchor)&&(i==null?void 0:i.head)===(t==null?void 0:t.head)}function tv({anchor:i,head:t}){return i<=t?{from:i,to:t}:{from:t,to:i}}function ev({anchor:i,head:t}){return i<=t}function J5(i,t){return Cr(i==null?void 0:i.cell,t==null?void 0:t.cell)&&JS(i==null?void 0:i.section,t==null?void 0:t.section)}function tZ(i){return i==="hidden"}function eZ(i){return i==="all"}function iZ(i){return i==="none"}function Ta(i){return!HT(i)}function Fc(i,t){return Ta(i)?Ta(t)&&J5(i,t):!Ta(t)&&i===t}var as;const tO=class tO{constructor(t){A(this,as);R(this,as,ct(xe(t)))}get value(){return $(w(this,as))}set value(t){q(w(this,as),t,!0)}isHidden(){return tZ(this.value)}isAll(){return eZ(this.value)}isNone(){return iZ(this.value)}isCell(){return Ta(this.value)}get cell(){return this.isCell()?this.value.cell:void 0}get cellSection(){return this.isCell()?this.value.section:void 0}equals(t){return Fc(this.value,t.value)}toJSON(){return this.isCell()?{value:{cell:this.cell,section:this.cellSection}}:{value:this.value}}static of(t){return new tO(t)}};as=new WeakMap;let pf=tO;var cs,hs;const eO=class eO{constructor({span:t,doc:e,selection:n}){A(this,cs);A(this,hs);P(this,"_span");P(this,"table");P(this,"selection");this._span=t,this.table=dl.of(e.slice(this.from,this.to)),this.selection=pf.of(this.computeSelection(n)),R(this,cs,ct(xe(this.table.text))),R(this,hs,ct(xe(this.selection.value)))}get _editorTableText(){return $(w(this,cs))}set _editorTableText(t){q(w(this,cs),t,!0)}get _editorSelectionValue(){return $(w(this,hs))}set _editorSelectionValue(t){q(w(this,hs),t,!0)}get editorTableText(){return this._editorTableText}get editorSelectionValue(){return this._editorSelectionValue}get span(){return this._span}set span(t){this._span=t}get from(){return this._span.from}get to(){return this._span.to}get isValid(){return this.from<this.to}containsSelection(){return this.selection.isCell()||this.selection.isHidden()}markSynchronized(){this._editorTableText=this.table.text,this._editorSelectionValue=this.selection.value}applyTransaction(t){t.docChanged?this.applyStateChange(t):this.applySelectionChange(t)}applyStateChange(t){const{from:e,to:n}=this.span;if(this.span={from:t.changes.mapPos(this.from,1),to:t.changes.mapPos(this.to)},!!this.isValid&&(this.applySelectionChange(t),G5(t)&&t.changes.touchesRange(e,n)!==!1)){const r=t.newDoc.slice(this.from,this.to);this.table.reset(r),this._editorTableText=r}}applySelectionChange(t){if(!this.isValid)return;const e=this.computeSelection(t.newSelection);!Fc(this.selection.value,e)&&(this.selection.value=e,this._editorSelectionValue=e)}computeSelection(t){if(t.main.head===this.from+1&&t.main.anchor===this.from+1)return"hidden";if(Xm({needle:this.span,haystack:t.main}))return"all";if(Xm({needle:t.main,haystack:this.span})){const e=this.table.closestCellAtPosition(t.main.anchor-this.from),{from:n,to:r}=this.table.cellSpan(e);return{cell:e,section:{anchor:ce(t.main.anchor-this.from,{min:n,max:r})-n,head:ce(t.main.head-this.from,{min:n,max:r})-n}}}else return"none"}static of(t){return new eO(t)}};cs=new WeakMap,hs=new WeakMap;let mf=eO;const nZ={top:0,right:0,bottom:0,left:0},iv={pos:0,clip:!1,create(i){const t=fl(i.dom).createElement("div");return t.className="tbl-menu-tooltip",{dom:t,overlap:!0,resize:!1,getCoords:()=>nZ}}},Ol="Cell";function _l(i){return YS(i,{component:Ol})}function mc(i,{row:t,col:e}){return WS(i,{component:Ol,row:`${t}`,col:`${e}`})}function Kc(i){if(!qS(i,{component:Ol}))return;const t=Ed(i);return{row:Am(t.dataset.row),col:Am(t.dataset.col)}}const rZ="5";var yg;typeof window<"u"&&((yg=window.__svelte??(window.__svelte={})).v??(yg.v=new Set)).add(rZ);const sZ=typeof window<"u"?window:void 0;function oZ(i){let t=i.activeElement;for(;t!=null&&t.shadowRoot;){const e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}var us,vl;class lZ{constructor(t={}){A(this,us);A(this,vl);const{window:e=sZ,document:n=e==null?void 0:e.document}=t;e!==void 0&&(R(this,us,n),R(this,vl,aS(r=>{const s=Mt(e,"focusin",r),o=Mt(e,"focusout",r);return()=>{s(),o()}})))}get current(){var t;return(t=w(this,vl))==null||t.call(this),w(this,us)?oZ(w(this,us)):null}}us=new WeakMap,vl=new WeakMap;new lZ;function aZ(i,t){switch(i){case"post":Nc(t);break;case"pre":o5(t);break}}function nv(i,t,e,n={}){const{lazy:r=!1}=n;let s=!r,o=Array.isArray(i)?[]:void 0;aZ(t,()=>{const l=Array.isArray(i)?i.map(c=>c()):i();if(!s){s=!0,o=l;return}const a=zl(()=>e(l,o));return o=l,a})}function _d(i,t,e){nv(i,"post",t,e)}function cZ(i,t,e){nv(i,"pre",t,e)}_d.pre=cZ;function br(i){return i?"":void 0}function tg(i){return i.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function eg(...i){return RA(OT(...i))}const hZ=sA();function uZ(i,t){const e=uc(i),n=t.style([])??void 0,r=[];return fA(e,s=>{if(uA(s)){r.push([]);return}const o=hZ.parse(new Tc(s)).cursor(),l=cc(o),a=[];gf({cursor:l,from:0,to:l.to,text:s,classes:E(n)?n.split(" "):[],highlighter:t,elementLine:a}),r.push(a)}),r}function gf({cursor:i,from:t,to:e,text:n,classes:r,passedClasses:s=[],highlighter:o,textOffset:l=0,elementLine:a}){var h,u;if(!i.firstChild()){const f=(u=(h=i.tree)==null?void 0:h.prop(N.mounted))==null?void 0:u.tree;if(E(f)){const d=f.cursor();gf({cursor:d,from:d.from,to:d.to,text:n,classes:r,passedClasses:s,highlighter:o,textOffset:l+t,elementLine:a})}else a.push({textContent:n.sliceString(l+t,l+e),classes:jh(r)});return}let c=t;do{i.from>c&&a.push({textContent:n.sliceString(l+c,l+i.from),classes:jh(r)}),c=i.to;const f=h0(i),d=o.style((f==null?void 0:f.tags)??[]),O=E(d)?d.split(" "):[];gf({cursor:i,from:i.from,to:i.to,text:n,classes:[...s,...O],passedClasses:(f==null?void 0:f.inherit)??!1?[...s,...O]:s,highlighter:o,textOffset:l,elementLine:a})}while(i.nextSibling());c<e&&a.push({textContent:n.sliceString(l+c,l+e),classes:jh(r)}),i.parent()}function fZ(i,t){return dZ(uZ(i,t))}function dZ(i){return i.map(t=>t.map(OZ).join("")).join(`<span data-br>
57
+ `).replaceAll("\\|","|")}function _A(i){let t=i;for(const e of XA)t=t.replaceAll(e,"");for(const e of EA)t=t.replaceAll(e,"");return t}const fc="|",M1=" ",z1=" ",IA=1,jA=1,DA=new Map([["none",1],["left",2],["center",3],["right",2]]),VA=new Map([["none",""],["left",":"],["center",":"],["right",""]]),BA=new Map([["none",""],["left",""],["center",":"],["right",":"]]);function _1(i,t){t.length;const e=Qm(i,O=>Sd(O,{trim:!0})).map(O=>O.map(p=>p.toString())),n=wA(e),r=$A(e),s=e.length,o=n.length,l=lc(o,O=>lc(s,p=>e[p][O])).map((O,p)=>HA(O,t[p])),a=Rm(n,l),c=WA(t,l),h=r.map(O=>Rm(O,l)),u=Y.of([a,c,...h]),f=l.map(O=>IA+O+jA),d=Qm(e,O=>O.length);return{text:u,colSizes:f,alignments:[...t],contentSizes:d}}function Rm(i,t){const e=[fc];return i.forEach((n,r)=>{e.push(M1,n,YA(t[r]-n.length),z1,fc)}),e.join("")}function WA(i,t){const e=[fc];return i.forEach((n,r)=>{const s=GA(n),o=UA(n),l=qA(t[r]-s.length-o.length);e.push(M1,s,l,o,z1,fc)}),e.join("")}function YA(i){return L1(" ",i)}function qA(i){return L1("-",i)}function NA(i){return DA.get(i)}function GA(i){return VA.get(i)}function UA(i){return BA.get(i)}function HA(i,t){return wd(NA(t),...i.map(e=>e.length))}const I1=oA();function Hu(i){const t=I1.parse(new Tc(i));if(!V1(t))throw new Error("Text is not a table");return D1(i,t)}function j1(i){const t=I1.parse(new Tc(i));if(V1(t))return D1(i,t)}function D1(i,t){const e=t.cursor(),n=cc(e),r=cc(n),s=Zm(r).map(O=>zh(i,O)),o=s.length,l=pA(r),a=FA(zh(i,l)),c=mA(l,O=>xA(Zm(O).map(p=>zh(i,p)),{min:o,max:o,fillWith:Y.empty})),h=[s,...c],{text:u,colSizes:f,contentSizes:d}=_1(h,a);return{text:u,colSizes:f,alignments:a,contentSizes:d}}function Zm(i){const t=i;i.firstChild();const e=t,n=[];let r;do{const{from:s,to:o}=e;if(bA(e)){r==="delimiter"&&n.push({from:s,to:s}),r="delimiter";continue}r="cell",n.push({from:s,to:o})}while(e.nextSibling());return e.parent(),n}function FA(i){const t=i.toString().split("|"),e=[];for(const n of t){if(!n.includes("-"))continue;const r=n.includes(":-"),s=n.includes("-:");r?s?e.push("center"):e.push("left"):s?e.push("right"):e.push("none")}return e}function V1(i){const t=i.cursor(),e=cc(t);return E1(e)&&!e.nextSibling()}const KA=(i,{selection:t,doc:e,lineBreak:n})=>{if(!Z1(t))return i;const r=j1(Y.of(i.split(/\r\n|\n|\r/)));if(W(r))return i;const{from:s,to:o}=t.main,{before:l,after:a}=bd({doc:e,lineBreak:n,span:{from:s,to:o}});return`${(l==null?void 0:l.insert)??""}${r.text.toString()}${(a==null?void 0:a.insert)??""}`},JA={combine:i=>Bc(i)?R1():SA(i)},Fu=V.define(JA);function Wc(i){return!i.matchMedia("(any-hover: none)").matches}function tR(i){return/Mac|iPod|iPhone|iPad/.test(i.navigator.platform)?"metaKey":"ctrlKey"}function B1(i,t){return(i==null?void 0:i.from)===(t==null?void 0:t.from)&&(i==null?void 0:i.to)===(t==null?void 0:t.to)}function Xm({needle:i,haystack:t}){const e=i.from<=i.to?i:{from:i.to,to:i.from},n=t.from<=t.to?t:{from:t.to,to:t.from};return e.from>=n.from&&e.to<=n.to}const eR=1,iR=2,W1=4,nR=8,rR=16,sR=1,oR=2,lR=4,aR=8,cR=16,hR=1,uR=2,Kt=Symbol(),Y1="http://www.w3.org/1999/xhtml",fR=!1;var vd=Array.isArray,dR=Array.prototype.indexOf,ro=Array.prototype.includes,Yc=Array.from,OR=Object.defineProperty,Yr=Object.getOwnPropertyDescriptor,pR=Object.getOwnPropertyDescriptors,q1=Object.prototype,mR=Array.prototype,xd=Object.getPrototypeOf,Em=Object.isExtensible;const N1=()=>{};function gR(i){for(var t=0;t<i.length;t++)i[t]()}function G1(){var i,t,e=new Promise((n,r)=>{i=n,t=r});return{promise:e,resolve:i,reject:t}}const ie=2,hl=4,Zl=8,U1=1<<24,dn=16,vi=32,Bn=64,Ku=128,Ge=512,Gt=1024,ne=2048,pi=4096,De=8192,sn=16384,Xl=32768,xr=65536,Lm=1<<17,H1=1<<18,Pr=1<<19,F1=1<<20,en=1<<25,yr=65536,Ju=1<<21,yd=1<<22,Pn=1<<23,Wo=Symbol("$state"),bR=Symbol("legacy props"),wR=Symbol(""),or=new class extends Error{constructor(){super(...arguments);P(this,"name","StaleReactionError");P(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};function K1(i){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function SR(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function vR(i,t,e){throw new Error("https://svelte.dev/e/each_key_duplicate")}function xR(i){throw new Error("https://svelte.dev/e/effect_in_teardown")}function yR(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function kR(i){throw new Error("https://svelte.dev/e/effect_orphan")}function QR(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function $R(i){throw new Error("https://svelte.dev/e/props_invalid_value")}function CR(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function PR(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function TR(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function AR(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function RR(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function J1(i){return i===this.v}function ZR(i,t){return i!=i?t==t:i!==t||i!==null&&typeof i=="object"||typeof i=="function"}function tS(i){return!ZR(i,this.v)}let mo=!1,XR=!1;function ER(){mo=!0}const LR=[];function Dh(i,t=!1,e=!1){return $a(i,new Map,"",LR,null,e)}function $a(i,t,e,n,r=null,s=!1){if(typeof i=="object"&&i!==null){var o=t.get(i);if(o!==void 0)return o;if(i instanceof Map)return new Map(i);if(i instanceof Set)return new Set(i);if(vd(i)){var l=Array(i.length);t.set(i,l),r!==null&&t.set(r,l);for(var a=0;a<i.length;a+=1){var c=i[a];a in i&&(l[a]=$a(c,t,e,n,null,s))}return l}if(xd(i)===q1){l={},t.set(i,l),r!==null&&t.set(r,l);for(var h in i)l[h]=$a(i[h],t,e,n,null,s);return l}if(i instanceof Date)return structuredClone(i);if(typeof i.toJSON=="function"&&!s)return $a(i.toJSON(),t,e,n,i)}if(i instanceof EventTarget)return i;try{return structuredClone(i)}catch{return i}}let $t=null;function so(i){$t=i}function MR(){return zR()}function Wn(i,t=!1,e){$t={p:$t,i:!1,c:null,e:null,s:i,x:null,l:mo&&!t?{s:null,u:null,$:[]}:null}}function Yn(i){var t=$t,e=t.e;if(e!==null){t.e=null;for(var n of e)wS(n)}return t.i=!0,$t=t.p,{}}function El(){return!mo||$t!==null&&$t.l===null}function zR(i){return $t===null&&K1(),$t.c??($t.c=new Map(_R($t)||void 0))}function _R(i){let t=i.p;for(;t!==null;){const e=t.c;if(e!==null)return e;t=t.p}return null}let Mr=[];function IR(){var i=Mr;Mr=[],gR(i)}function on(i){if(Mr.length===0){var t=Mr;queueMicrotask(()=>{t===Mr&&IR()})}Mr.push(i)}function eS(i){var t=at;if(t===null)return it.f|=Pn,i;if(!(t.f&Xl)&&!(t.f&hl))throw i;oo(i,t)}function oo(i,t){for(;t!==null;){if(t.f&Ku){if(!(t.f&Xl))throw i;try{t.b.error(i);return}catch(e){i=e}}t=t.parent}throw i}const jR=-7169;function Dt(i,t){i.f=i.f&jR|t}function kd(i){i.f&Ge||i.deps===null?Dt(i,Gt):Dt(i,pi)}function iS(i){if(i!==null)for(const t of i)!(t.f&ie)||!(t.f&yr)||(t.f^=yr,iS(t.deps))}function nS(i,t,e){i.f&ne?t.add(i):i.f&pi&&e.add(i),iS(i.deps),Dt(i,Gt)}const oa=new Set;let dt=null,te=null,We=[],Qd=null,tf=!1;var Hr,Fr,cr,Kr,bl,wl,hr,Gi,Jr,Bi,ef,nf,rS;const Jd=class Jd{constructor(){A(this,Bi);P(this,"committed",!1);P(this,"current",new Map);P(this,"previous",new Map);A(this,Hr,new Set);A(this,Fr,new Set);A(this,cr,0);A(this,Kr,0);A(this,bl,null);A(this,wl,new Set);A(this,hr,new Set);A(this,Gi,new Map);P(this,"is_fork",!1);A(this,Jr,!1)}is_deferred(){return this.is_fork||w(this,Kr)>0}skip_effect(t){w(this,Gi).has(t)||w(this,Gi).set(t,{d:[],m:[]})}unskip_effect(t){var e=w(this,Gi).get(t);if(e){w(this,Gi).delete(t);for(var n of e.d)Dt(n,ne),ci(n);for(n of e.m)Dt(n,pi),ci(n)}}process(t){var r;We=[],this.apply();var e=[],n=[];for(const s of t)Zt(this,Bi,ef).call(this,s,e,n);if(this.is_deferred()){Zt(this,Bi,nf).call(this,n),Zt(this,Bi,nf).call(this,e);for(const[s,o]of w(this,Gi))lS(s,o)}else{for(const s of w(this,Hr))s();w(this,Hr).clear(),w(this,cr)===0&&Zt(this,Bi,rS).call(this),dt=null,Mm(n),Mm(e),(r=w(this,bl))==null||r.resolve()}te=null}capture(t,e){e!==Kt&&!this.previous.has(t)&&this.previous.set(t,e),!(t.f&Pn)&&(this.current.set(t,t.v),te==null||te.set(t,t.v))}activate(){dt=this,this.apply()}deactivate(){dt===this&&(dt=null,te=null)}flush(){if(this.activate(),We.length>0){if(DR(),dt!==null&&dt!==this)return}else w(this,cr)===0&&this.process([]);this.deactivate()}discard(){for(const t of w(this,Fr))t(this);w(this,Fr).clear()}increment(t){R(this,cr,w(this,cr)+1),t&&R(this,Kr,w(this,Kr)+1)}decrement(t){R(this,cr,w(this,cr)-1),t&&R(this,Kr,w(this,Kr)-1),!w(this,Jr)&&(R(this,Jr,!0),on(()=>{R(this,Jr,!1),this.is_deferred()?We.length>0&&this.flush():this.revive()}))}revive(){for(const t of w(this,wl))w(this,hr).delete(t),Dt(t,ne),ci(t);for(const t of w(this,hr))Dt(t,pi),ci(t);this.flush()}oncommit(t){w(this,Hr).add(t)}ondiscard(t){w(this,Fr).add(t)}settled(){return(w(this,bl)??R(this,bl,G1())).promise}static ensure(){if(dt===null){const t=dt=new Jd;oa.add(dt),on(()=>{dt===t&&t.flush()})}return dt}apply(){}};Hr=new WeakMap,Fr=new WeakMap,cr=new WeakMap,Kr=new WeakMap,bl=new WeakMap,wl=new WeakMap,hr=new WeakMap,Gi=new WeakMap,Jr=new WeakMap,Bi=new WeakSet,ef=function(t,e,n){t.f^=Gt;for(var r=t.first,s=null;r!==null;){var o=r.f,l=(o&(vi|Bn))!==0,a=l&&(o&Gt)!==0,c=a||(o&De)!==0||w(this,Gi).has(r);if(!c&&r.fn!==null){l?r.f^=Gt:s!==null&&o&(hl|Zl|U1)?s.b.defer_effect(r):o&hl?e.push(r):Ml(r)&&(o&dn&&w(this,hr).add(r),ao(r));var h=r.first;if(h!==null){r=h;continue}}for(;r!==null;){r===s&&(s=null);var u=r.next;if(u!==null){r=u;break}r=r.parent}}},nf=function(t){for(var e=0;e<t.length;e+=1)nS(t[e],w(this,wl),w(this,hr))},rS=function(){var r;if(oa.size>1){this.previous.clear();var t=te,e=!0;for(const s of oa){if(s===this){e=!1;continue}const o=[];for(const[a,c]of this.current){if(s.current.has(a))if(e&&c!==s.current.get(a))s.current.set(a,c);else continue;o.push(a)}if(o.length===0)continue;const l=[...s.current.keys()].filter(a=>!this.current.has(a));if(l.length>0){var n=We;We=[];const a=new Set,c=new Map;for(const h of o)sS(h,l,a,c);if(We.length>0){dt=s,s.apply();for(const h of We)Zt(r=s,Bi,ef).call(r,h,[],[]);s.deactivate()}We=n}}dt=null,te=t}this.committed=!0,oa.delete(this)};let ln=Jd;function DR(){tf=!0;try{for(var i=0;We.length>0;){var t=ln.ensure();if(i++>1e3){var e,n;VR()}t.process(We),Tn.clear()}}finally{We=[],tf=!1,Qd=null}}function VR(){try{QR()}catch(i){oo(i,Qd)}}let ni=null;function Mm(i){var t=i.length;if(t!==0){for(var e=0;e<t;){var n=i[e++];if(!(n.f&(sn|De))&&Ml(n)&&(ni=new Set,ao(n),n.deps===null&&n.first===null&&n.nodes===null&&n.teardown===null&&n.ac===null&&yS(n),(ni==null?void 0:ni.size)>0)){Tn.clear();for(const r of ni){if(r.f&(sn|De))continue;const s=[r];let o=r.parent;for(;o!==null;)ni.has(o)&&(ni.delete(o),s.push(o)),o=o.parent;for(let l=s.length-1;l>=0;l--){const a=s[l];!(a.f&(sn|De))&&ao(a)}}ni.clear()}}ni=null}}function sS(i,t,e,n){if(!e.has(i)&&(e.add(i),i.reactions!==null))for(const r of i.reactions){const s=r.f;s&ie?sS(r,t,e,n):s&(yd|dn)&&!(s&ne)&&oS(r,t,n)&&(Dt(r,ne),ci(r))}}function oS(i,t,e){const n=e.get(i);if(n!==void 0)return n;if(i.deps!==null)for(const r of i.deps){if(ro.call(t,r))return!0;if(r.f&ie&&oS(r,t,e))return e.set(r,!0),!0}return e.set(i,!1),!1}function ci(i){for(var t=Qd=i;t.parent!==null;){t=t.parent;var e=t.f;if(tf&&t===at&&e&dn&&!(e&H1))return;if(e&(Bn|vi)){if(!(e&Gt))return;t.f^=Gt}}We.push(t)}function lS(i,t){if(!(i.f&vi&&i.f&Gt)){i.f&ne?t.d.push(i):i.f&pi&&t.m.push(i),Dt(i,Gt);for(var e=i.first;e!==null;)lS(e,t),e=e.next}}function aS(i){let t=0,e=kr(0),n;return()=>{Td()&&($(e),SS(()=>(t===0&&(n=zl(()=>i(()=>Yo(e)))),t+=1,()=>{on(()=>{t-=1,t===0&&(n==null||n(),n=void 0,Yo(e))})})))}}var BR=xr|Pr;function WR(i,t,e){new YR(i,t,e)}var ri,yf,Ui,ur,Pi,Ti,Le,Ai,Hi,fr,yn,ts,es,is,Fi,vc,ke,qR,NR,rf,Ca,sf;class YR{constructor(t,e,n){A(this,ke);P(this,"parent");P(this,"is_pending",!1);A(this,ri);A(this,yf,null);A(this,Ui);A(this,ur);A(this,Pi);A(this,Ti,null);A(this,Le,null);A(this,Ai,null);A(this,Hi,null);A(this,fr,0);A(this,yn,0);A(this,ts,!1);A(this,es,new Set);A(this,is,new Set);A(this,Fi,null);A(this,vc,aS(()=>(R(this,Fi,kr(w(this,fr))),()=>{R(this,Fi,null)})));R(this,ri,t),R(this,Ui,e),R(this,ur,r=>{var s=at;s.b=this,s.f|=Ku,n(r)}),this.parent=at.b,R(this,Pi,Gc(()=>{Zt(this,ke,rf).call(this)},BR))}defer_effect(t){nS(t,w(this,es),w(this,is))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!w(this,Ui).pending}update_pending_count(t){Zt(this,ke,sf).call(this,t),R(this,fr,w(this,fr)+t),!(!w(this,Fi)||w(this,ts))&&(R(this,ts,!0),on(()=>{R(this,ts,!1),w(this,Fi)&&lo(w(this,Fi),w(this,fr))}))}get_effect_pending(){return w(this,vc).call(this),$(w(this,Fi))}error(t){var e=w(this,Ui).onerror;let n=w(this,Ui).failed;if(!e&&!n)throw t;w(this,Ti)&&(ge(w(this,Ti)),R(this,Ti,null)),w(this,Le)&&(ge(w(this,Le)),R(this,Le,null)),w(this,Ai)&&(ge(w(this,Ai)),R(this,Ai,null));var r=!1,s=!1;const o=()=>{if(r){RR();return}r=!0,s&&AR(),w(this,Ai)!==null&&mr(w(this,Ai),()=>{R(this,Ai,null)}),Zt(this,ke,Ca).call(this,()=>{ln.ensure(),Zt(this,ke,rf).call(this)})};on(()=>{try{s=!0,e==null||e(t,o),s=!1}catch(l){oo(l,w(this,Pi)&&w(this,Pi).parent)}n&&R(this,Ai,Zt(this,ke,Ca).call(this,()=>{ln.ensure();try{return Ri(()=>{var l=at;l.b=this,l.f|=Ku,n(w(this,ri),()=>t,()=>o)})}catch(l){return oo(l,w(this,Pi).parent),null}}))})}}ri=new WeakMap,yf=new WeakMap,Ui=new WeakMap,ur=new WeakMap,Pi=new WeakMap,Ti=new WeakMap,Le=new WeakMap,Ai=new WeakMap,Hi=new WeakMap,fr=new WeakMap,yn=new WeakMap,ts=new WeakMap,es=new WeakMap,is=new WeakMap,Fi=new WeakMap,vc=new WeakMap,ke=new WeakSet,qR=function(){try{R(this,Ti,Ri(()=>w(this,ur).call(this,w(this,ri))))}catch(t){this.error(t)}},NR=function(){const t=w(this,Ui).pending;t&&(this.is_pending=!0,R(this,Le,Ri(()=>t(w(this,ri)))),on(()=>{var e=R(this,Hi,document.createDocumentFragment()),n=An();e.append(n),R(this,Ti,Zt(this,ke,Ca).call(this,()=>(ln.ensure(),Ri(()=>w(this,ur).call(this,n))))),w(this,yn)===0&&(w(this,ri).before(e),R(this,Hi,null),mr(w(this,Le),()=>{R(this,Le,null)}),this.is_pending=!1)}))},rf=function(){try{if(this.is_pending=this.has_pending_snippet(),R(this,yn,0),R(this,fr,0),R(this,Ti,Ri(()=>{w(this,ur).call(this,w(this,ri))})),w(this,yn)>0){var t=R(this,Hi,document.createDocumentFragment());$S(w(this,Ti),t);const e=w(this,Ui).pending;R(this,Le,Ri(()=>e(w(this,ri))))}else this.is_pending=!1}catch(e){this.error(e)}},Ca=function(t){var e=at,n=it,r=$t;Vi(w(this,Pi)),Fe(w(this,Pi)),so(w(this,Pi).ctx);try{return t()}catch(s){return eS(s),null}finally{Vi(e),Fe(n),so(r)}},sf=function(t){var e;if(!this.has_pending_snippet()){this.parent&&Zt(e=this.parent,ke,sf).call(e,t);return}if(R(this,yn,w(this,yn)+t),w(this,yn)===0){this.is_pending=!1;for(const n of w(this,es))Dt(n,ne),ci(n);for(const n of w(this,is))Dt(n,pi),ci(n);w(this,es).clear(),w(this,is).clear(),w(this,Le)&&mr(w(this,Le),()=>{R(this,Le,null)}),w(this,Hi)&&(w(this,ri).before(w(this,Hi)),R(this,Hi,null))}};function GR(i,t,e,n){const r=El()?qc:$d;var s=i.filter(f=>!f.settled);if(e.length===0&&s.length===0){n(t.map(r));return}var o=dt,l=at,a=UR(),c=s.length===1?s[0].promise:s.length>1?Promise.all(s.map(f=>f.promise)):null;function h(f){a();try{n(f)}catch(d){!(l.f&sn)&&oo(d,l)}o==null||o.deactivate(),of()}if(e.length===0){c.then(()=>h(t.map(r)));return}function u(){a(),Promise.all(e.map(f=>HR(f))).then(f=>h([...t.map(r),...f])).catch(f=>oo(f,l))}c?c.then(u):u()}function UR(){var i=at,t=it,e=$t,n=dt;return function(r=!0){Vi(i),Fe(t),so(e),r&&(n==null||n.activate())}}function of(){Vi(null),Fe(null),so(null)}function qc(i){var t=ie|ne,e=it!==null&&it.f&ie?it:null;return at!==null&&(at.f|=Pr),{ctx:$t,deps:null,effects:null,equals:J1,f:t,fn:i,reactions:null,rv:0,v:Kt,wv:0,parent:e??at,ac:null}}function HR(i,t,e){let n=at;n===null&&SR();var r=n.b,s=void 0,o=kr(Kt),l=!it,a=new Map;return h5(()=>{var d;var c=G1();s=c.promise;try{Promise.resolve(i()).then(c.resolve,c.reject).then(()=>{h===dt&&h.committed&&h.deactivate(),of()})}catch(O){c.reject(O),of()}var h=dt;if(l){var u=r.is_rendered();r.update_pending_count(1),h.increment(u),(d=a.get(h))==null||d.reject(or),a.delete(h),a.set(h,c)}const f=(O,p=void 0)=>{if(h.activate(),p)p!==or&&(o.f|=Pn,lo(o,p));else{o.f&Pn&&(o.f^=Pn),lo(o,O);for(const[m,g]of a){if(a.delete(m),m===h)break;g.reject(or)}}l&&(r.update_pending_count(-1),h.decrement(u))};c.promise.then(f,O=>f(null,O||"unknown"))}),bS(()=>{for(const c of a.values())c.reject(or)}),new Promise(c=>{function h(u){function f(){u===s?c(o):h(s)}u.then(f,f)}h(s)})}function F(i){const t=qc(i);return CS(t),t}function $d(i){const t=qc(i);return t.equals=tS,t}function FR(i){var t=i.effects;if(t!==null){i.effects=null;for(var e=0;e<t.length;e+=1)ge(t[e])}}function KR(i){for(var t=i.parent;t!==null;){if(!(t.f&ie))return t.f&sn?null:t;t=t.parent}return null}function Cd(i){var t,e=at;Vi(KR(i));try{i.f&=~yr,FR(i),t=RS(i)}finally{Vi(e)}return t}function cS(i){var t=Cd(i);if(!i.equals(t)&&(i.wv=TS(),(!(dt!=null&&dt.is_fork)||i.deps===null)&&(i.v=t,i.deps===null))){Dt(i,Gt);return}_n||(te!==null?(Td()||dt!=null&&dt.is_fork)&&te.set(i,t):kd(i))}function JR(i){var t,e;if(i.effects!==null)for(const n of i.effects)(n.teardown||n.ac)&&((t=n.teardown)==null||t.call(n),(e=n.ac)==null||e.abort(or),n.teardown=N1,n.ac=null,ul(n,0),Ad(n))}function hS(i){if(i.effects!==null)for(const t of i.effects)t.teardown&&ao(t)}let lf=new Set;const Tn=new Map;let uS=!1;function kr(i,t){var e={f:0,v:i,reactions:null,equals:J1,rv:0,wv:0};return e}function ct(i,t){const e=kr(i);return CS(e),e}function t5(i,t=!1,e=!0){var r;const n=kr(i);return t||(n.equals=tS),mo&&e&&$t!==null&&$t.l!==null&&((r=$t.l).s??(r.s=[])).push(n),n}function q(i,t,e=!1){it!==null&&(!hi||it.f&Lm)&&El()&&it.f&(ie|dn|yd|Lm)&&(He===null||!ro.call(He,i))&&TR();let n=e?xe(t):t;return lo(i,n)}function lo(i,t){if(!i.equals(t)){var e=i.v;_n?Tn.set(i,t):Tn.set(i,e),i.v=t;var n=ln.ensure();if(n.capture(i,e),(i.f&ie)!==0){const r=i;i.f&ne&&Cd(r),kd(r)}i.wv=TS(),fS(i,ne),El()&&at!==null&&at.f&Gt&&!(at.f&(vi|Bn))&&(Be===null?f5([i]):Be.push(i)),!n.is_fork&&lf.size>0&&!uS&&e5()}return t}function e5(){uS=!1;for(const i of lf)i.f&Gt&&Dt(i,pi),Ml(i)&&ao(i);lf.clear()}function Yo(i){q(i,i.v+1)}function fS(i,t){var e=i.reactions;if(e!==null)for(var n=El(),r=e.length,s=0;s<r;s++){var o=e[s],l=o.f;if(!(!n&&o===at)){var a=(l&ne)===0;if(a&&Dt(o,t),(l&ie)!==0){var c=o;te==null||te.delete(c),!(l&yr)&&(l&Ge&&(o.f|=yr),fS(c,pi))}else a&&(l&dn&&ni!==null&&ni.add(o),ci(o))}}}function xe(i){if(typeof i!="object"||i===null||Wo in i)return i;const t=xd(i);if(t!==q1&&t!==mR)return i;var e=new Map,n=vd(i),r=ct(0),s=gr,o=l=>{if(gr===s)return l();var a=it,c=gr;Fe(null),Im(s);var h=l();return Fe(a),Im(c),h};return n&&e.set("length",ct(i.length)),new Proxy(i,{defineProperty(l,a,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&CR();var h=e.get(a);return h===void 0?o(()=>{var u=ct(c.value);return e.set(a,u),u}):q(h,c.value,!0),!0},deleteProperty(l,a){var c=e.get(a);if(c===void 0){if(a in l){const h=o(()=>ct(Kt));e.set(a,h),Yo(r)}}else q(c,Kt),Yo(r);return!0},get(l,a,c){var d;if(a===Wo)return i;var h=e.get(a),u=a in l;if(h===void 0&&(!u||(d=Yr(l,a))!=null&&d.writable)&&(h=o(()=>{var O=xe(u?l[a]:Kt),p=ct(O);return p}),e.set(a,h)),h!==void 0){var f=$(h);return f===Kt?void 0:f}return Reflect.get(l,a,c)},getOwnPropertyDescriptor(l,a){var c=Reflect.getOwnPropertyDescriptor(l,a);if(c&&"value"in c){var h=e.get(a);h&&(c.value=$(h))}else if(c===void 0){var u=e.get(a),f=u==null?void 0:u.v;if(u!==void 0&&f!==Kt)return{enumerable:!0,configurable:!0,value:f,writable:!0}}return c},has(l,a){var f;if(a===Wo)return!0;var c=e.get(a),h=c!==void 0&&c.v!==Kt||Reflect.has(l,a);if(c!==void 0||at!==null&&(!h||(f=Yr(l,a))!=null&&f.writable)){c===void 0&&(c=o(()=>{var d=h?xe(l[a]):Kt,O=ct(d);return O}),e.set(a,c));var u=$(c);if(u===Kt)return!1}return h},set(l,a,c,h){var S;var u=e.get(a),f=a in l;if(n&&a==="length")for(var d=c;d<u.v;d+=1){var O=e.get(d+"");O!==void 0?q(O,Kt):d in l&&(O=o(()=>ct(Kt)),e.set(d+"",O))}if(u===void 0)(!f||(S=Yr(l,a))!=null&&S.writable)&&(u=o(()=>ct(void 0)),q(u,xe(c)),e.set(a,u));else{f=u.v!==Kt;var p=o(()=>xe(c));q(u,p)}var m=Reflect.getOwnPropertyDescriptor(l,a);if(m!=null&&m.set&&m.set.call(h,c),!f){if(n&&typeof a=="string"){var g=e.get("length"),b=Number(a);Number.isInteger(b)&&b>=g.v&&q(g,b+1)}Yo(r)}return!0},ownKeys(l){$(r);var a=Reflect.ownKeys(l).filter(u=>{var f=e.get(u);return f===void 0||f.v!==Kt});for(var[c,h]of e)h.v!==Kt&&!(c in l)&&a.push(c);return a},setPrototypeOf(){PR()}})}var zm,dS,OS,pS;function i5(){if(zm===void 0){zm=window,dS=/Firefox/.test(navigator.userAgent);var i=Element.prototype,t=Node.prototype,e=Text.prototype;OS=Yr(t,"firstChild").get,pS=Yr(t,"nextSibling").get,Em(i)&&(i.__click=void 0,i.__className=void 0,i.__attributes=null,i.__style=void 0,i.__e=void 0),Em(e)&&(e.__t=void 0)}}function An(i=""){return document.createTextNode(i)}function _i(i){return OS.call(i)}function Ll(i){return pS.call(i)}function Ue(i,t){return _i(i)}function Et(i,t=!1){{var e=_i(i);return e instanceof Comment&&e.data===""?Ll(e):e}}function et(i,t=1,e=!1){let n=i;for(;t--;)n=Ll(n);return n}function n5(i){i.textContent=""}function mS(){return!1}function r5(i,t,e){return document.createElementNS(Y1,i,void 0)}function Pd(i){var t=it,e=at;Fe(null),Vi(null);try{return i()}finally{Fe(t),Vi(e)}}function gS(i){at===null&&(it===null&&kR(),yR()),_n&&xR()}function s5(i,t){var e=t.last;e===null?t.last=t.first=i:(e.next=i,i.prev=e,t.last=i)}function xi(i,t,e){var n=at;n!==null&&n.f&De&&(i|=De);var r={ctx:$t,deps:null,nodes:null,f:i|ne|Ge,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};if(e)try{ao(r)}catch(l){throw ge(r),l}else t!==null&&ci(r);var s=r;if(e&&s.deps===null&&s.teardown===null&&s.nodes===null&&s.first===s.last&&!(s.f&Pr)&&(s=s.first,i&dn&&i&xr&&s!==null&&(s.f|=xr)),s!==null&&(s.parent=n,n!==null&&s5(s,n),it!==null&&(it.f&ie)!==0&&(i&Bn)===0)){var o=it;(o.effects??(o.effects=[])).push(s)}return r}function Td(){return it!==null&&!hi}function bS(i){const t=xi(Zl,null,!1);return Dt(t,Gt),t.teardown=i,t}function Nc(i){gS();var t=at.f,e=!it&&(t&vi)!==0&&(t&Xl)===0;if(e){var n=$t;(n.e??(n.e=[])).push(i)}else return wS(i)}function wS(i){return xi(hl|F1,i,!1)}function o5(i){return gS(),xi(Zl|F1,i,!0)}function l5(i){ln.ensure();const t=xi(Bn|Pr,i,!0);return()=>{ge(t)}}function a5(i){ln.ensure();const t=xi(Bn|Pr,i,!0);return(e={})=>new Promise(n=>{e.outro?mr(t,()=>{ge(t),n(void 0)}):(ge(t),n(void 0))})}function c5(i){return xi(hl,i,!1)}function h5(i){return xi(yd|Pr,i,!0)}function SS(i,t=0){return xi(Zl|t,i,!0)}function se(i,t=[],e=[],n=[]){GR(n,t,e,r=>{xi(Zl,()=>i(...r.map($)),!0)})}function Gc(i,t=0){var e=xi(dn|t,i,!0);return e}function Ri(i){return xi(vi|Pr,i,!0)}function vS(i){var t=i.teardown;if(t!==null){const e=_n,n=it;_m(!0),Fe(null);try{t.call(null)}finally{_m(e),Fe(n)}}}function Ad(i,t=!1){var e=i.first;for(i.first=i.last=null;e!==null;){const r=e.ac;r!==null&&Pd(()=>{r.abort(or)});var n=e.next;e.f&Bn?e.parent=null:ge(e,t),e=n}}function u5(i){for(var t=i.first;t!==null;){var e=t.next;!(t.f&vi)&&ge(t),t=e}}function ge(i,t=!0){var e=!1;(t||i.f&H1)&&i.nodes!==null&&i.nodes.end!==null&&(xS(i.nodes.start,i.nodes.end),e=!0),Ad(i,t&&!e),ul(i,0),Dt(i,sn);var n=i.nodes&&i.nodes.t;if(n!==null)for(const s of n)s.stop();vS(i);var r=i.parent;r!==null&&r.first!==null&&yS(i),i.next=i.prev=i.teardown=i.ctx=i.deps=i.fn=i.nodes=i.ac=null}function xS(i,t){for(;i!==null;){var e=i===t?null:Ll(i);i.remove(),i=e}}function yS(i){var t=i.parent,e=i.prev,n=i.next;e!==null&&(e.next=n),n!==null&&(n.prev=e),t!==null&&(t.first===i&&(t.first=n),t.last===i&&(t.last=e))}function mr(i,t,e=!0){var n=[];kS(i,n,!0);var r=()=>{e&&ge(i),t&&t()},s=n.length;if(s>0){var o=()=>--s||r();for(var l of n)l.out(o)}else r()}function kS(i,t,e){if(!(i.f&De)){i.f^=De;var n=i.nodes&&i.nodes.t;if(n!==null)for(const l of n)(l.is_global||e)&&t.push(l);for(var r=i.first;r!==null;){var s=r.next,o=(r.f&xr)!==0||(r.f&vi)!==0&&(i.f&dn)!==0;kS(r,t,o?e:!1),r=s}}}function Rd(i){QS(i,!0)}function QS(i,t){if(i.f&De){i.f^=De,!(i.f&Gt)&&(Dt(i,ne),ci(i));for(var e=i.first;e!==null;){var n=e.next,r=(e.f&xr)!==0||(e.f&vi)!==0;QS(e,r?t:!1),e=n}var s=i.nodes&&i.nodes.t;if(s!==null)for(const o of s)(o.is_global||t)&&o.in()}}function $S(i,t){if(i.nodes)for(var e=i.nodes.start,n=i.nodes.end;e!==null;){var r=e===n?null:Ll(e);t.append(e),e=r}}let Pa=!1,_n=!1;function _m(i){_n=i}let it=null,hi=!1;function Fe(i){it=i}let at=null;function Vi(i){at=i}let He=null;function CS(i){it!==null&&(He===null?He=[i]:He.push(i))}let Se=null,Ee=0,Be=null;function f5(i){Be=i}let PS=1,lr=0,gr=lr;function Im(i){gr=i}function TS(){return++PS}function Ml(i){var t=i.f;if(t&ne)return!0;if(t&ie&&(i.f&=~yr),(t&pi)!==0){for(var e=i.deps,n=e.length,r=0;r<n;r++){var s=e[r];if(Ml(s)&&cS(s),s.wv>i.wv)return!0}t&Ge&&te===null&&Dt(i,Gt)}return!1}function AS(i,t,e=!0){var n=i.reactions;if(n!==null&&!(He!==null&&ro.call(He,i)))for(var r=0;r<n.length;r++){var s=n[r];s.f&ie?AS(s,t,!1):t===s&&(e?Dt(s,ne):s.f&Gt&&Dt(s,pi),ci(s))}}function RS(i){var p;var t=Se,e=Ee,n=Be,r=it,s=He,o=$t,l=hi,a=gr,c=i.f;Se=null,Ee=0,Be=null,it=c&(vi|Bn)?null:i,He=null,so(i.ctx),hi=!1,gr=++lr,i.ac!==null&&(Pd(()=>{i.ac.abort(or)}),i.ac=null);try{i.f|=Ju;var h=i.fn,u=h();i.f|=Xl;var f=i.deps,d=dt==null?void 0:dt.is_fork;if(Se!==null){var O;if(d||ul(i,Ee),f!==null&&Ee>0)for(f.length=Ee+Se.length,O=0;O<Se.length;O++)f[Ee+O]=Se[O];else i.deps=f=Se;if(Td()&&i.f&Ge)for(O=Ee;O<f.length;O++)((p=f[O]).reactions??(p.reactions=[])).push(i)}else!d&&f!==null&&Ee<f.length&&(ul(i,Ee),f.length=Ee);if(El()&&Be!==null&&!hi&&f!==null&&!(i.f&(ie|pi|ne)))for(O=0;O<Be.length;O++)AS(Be[O],i);if(r!==null&&r!==i){if(lr++,r.deps!==null)for(let m=0;m<e;m+=1)r.deps[m].rv=lr;if(t!==null)for(const m of t)m.rv=lr;Be!==null&&(n===null?n=Be:n.push(...Be))}return i.f&Pn&&(i.f^=Pn),u}catch(m){return eS(m)}finally{i.f^=Ju,Se=t,Ee=e,Be=n,it=r,He=s,so(o),hi=l,gr=a}}function d5(i,t){let e=t.reactions;if(e!==null){var n=dR.call(e,i);if(n!==-1){var r=e.length-1;r===0?e=t.reactions=null:(e[n]=e[r],e.pop())}}if(e===null&&t.f&ie&&(Se===null||!ro.call(Se,t))){var s=t;s.f&Ge&&(s.f^=Ge,s.f&=~yr),kd(s),JR(s),ul(s,0)}}function ul(i,t){var e=i.deps;if(e!==null)for(var n=t;n<e.length;n++)d5(i,e[n])}function ao(i){var t=i.f;if(!(t&sn)){Dt(i,Gt);var e=at,n=Pa;at=i,Pa=!0;try{t&(dn|U1)?u5(i):Ad(i),vS(i);var r=RS(i);i.teardown=typeof r=="function"?r:null,i.wv=PS;var s;fR&&XR&&i.f&ne&&i.deps}finally{Pa=n,at=e}}}function $(i){var t=i.f,e=(t&ie)!==0;if(it!==null&&!hi){var n=at!==null&&(at.f&sn)!==0;if(!n&&(He===null||!ro.call(He,i))){var r=it.deps;if(it.f&Ju)i.rv<lr&&(i.rv=lr,Se===null&&r!==null&&r[Ee]===i?Ee++:Se===null?Se=[i]:Se.push(i));else{(it.deps??(it.deps=[])).push(i);var s=i.reactions;s===null?i.reactions=[it]:ro.call(s,it)||s.push(it)}}}if(_n&&Tn.has(i))return Tn.get(i);if(e){var o=i;if(_n){var l=o.v;return(!(o.f&Gt)&&o.reactions!==null||XS(o))&&(l=Cd(o)),Tn.set(o,l),l}var a=(o.f&Ge)===0&&!hi&&it!==null&&(Pa||(it.f&Ge)!==0),c=(o.f&Xl)===0;Ml(o)&&(a&&(o.f|=Ge),cS(o)),a&&!c&&(hS(o),ZS(o))}if(te!=null&&te.has(i))return te.get(i);if(i.f&Pn)throw i.v;return i.v}function ZS(i){if(i.f|=Ge,i.deps!==null)for(const t of i.deps)(t.reactions??(t.reactions=[])).push(i),t.f&ie&&!(t.f&Ge)&&(hS(t),ZS(t))}function XS(i){if(i.v===Kt)return!0;if(i.deps===null)return!1;for(const t of i.deps)if(Tn.has(t)||t.f&ie&&XS(t))return!0;return!1}function zl(i){var t=hi;try{return hi=!0,i()}finally{hi=t}}const ar=Symbol("events"),ES=new Set,af=new Set;function LS(i,t,e,n={}){function r(s){if(n.capture||cf.call(t,s),!s.cancelBubble)return Pd(()=>e==null?void 0:e.call(this,s))}return i.startsWith("pointer")||i.startsWith("touch")||i==="wheel"?on(()=>{t.addEventListener(i,r,n)}):t.addEventListener(i,r,n),r}function Mt(i,t,e,n={}){var r=LS(t,i,e,n);return()=>{i.removeEventListener(t,r,n)}}function la(i,t,e,n,r){var s={capture:n,passive:r},o=LS(i,t,e,s);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&bS(()=>{t.removeEventListener(i,o,s)})}function Eo(i,t,e){(t[ar]??(t[ar]={}))[i]=e}function MS(i){for(var t=0;t<i.length;t++)ES.add(i[t]);for(var e of af)e(i)}let jm=null;function cf(i){var m,g;var t=this,e=t.ownerDocument,n=i.type,r=((m=i.composedPath)==null?void 0:m.call(i))||[],s=r[0]||i.target;jm=i;var o=0,l=jm===i&&i[ar];if(l){var a=r.indexOf(l);if(a!==-1&&(t===document||t===window)){i[ar]=t;return}var c=r.indexOf(t);if(c===-1)return;a<=c&&(o=a)}if(s=r[o]||i.target,s!==t){OR(i,"currentTarget",{configurable:!0,get(){return s||e}});var h=it,u=at;Fe(null),Vi(null);try{for(var f,d=[];s!==null;){var O=s.assignedSlot||s.parentNode||s.host||null;try{var p=(g=s[ar])==null?void 0:g[n];p!=null&&(!s.disabled||i.target===s)&&p.call(s,i)}catch(b){f?d.push(b):f=b}if(i.cancelBubble||O===t||O===null)break;s=O}if(f){for(let b of d)queueMicrotask(()=>{throw b});throw f}}finally{i[ar]=t,delete i.currentTarget,Fe(h),Vi(u)}}}var xg;const Vh=((xg=globalThis==null?void 0:globalThis.window)==null?void 0:xg.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:i=>i});function O5(i){return(Vh==null?void 0:Vh.createHTML(i))??i}function Zd(i,t=!1){var e=r5("template");return i=i.replaceAll("<!>","<!---->"),e.innerHTML=t?O5(i):i,e.content}function co(i,t){var e=at;e.nodes===null&&(e.nodes={start:i,end:t,a:null,t:null})}function ot(i,t){var e=(t&hR)!==0,n=(t&uR)!==0,r,s=!i.startsWith("<!>");return()=>{r===void 0&&(r=Zd(s?i:"<!>"+i,!0),e||(r=_i(r)));var o=n||dS?document.importNode(r,!0):r.cloneNode(!0);if(e){var l=_i(o),a=o.lastChild;co(l,a)}else co(o,o);return o}}function p5(i,t,e="svg"){var n=!i.startsWith("<!>"),r=`<${e}>${n?i:"<!>"+i}</${e}>`,s;return()=>{if(!s){var o=Zd(r,!0),l=_i(o);s=_i(l)}var a=s.cloneNode(!0);return co(a,a),a}}function ei(i,t){return p5(i,t,"svg")}function Te(i=""){{var t=An(i+"");return co(t,t),t}}function Xd(){var i=document.createDocumentFragment(),t=document.createComment(""),e=An();return i.append(t,e),co(t,e),i}function I(i,t){i!==null&&i.before(t)}const m5=["touchstart","touchmove"];function g5(i){return m5.includes(i)}function qi(i,t){var e=t==null?"":typeof t=="object"?t+"":t;e!==(i.__t??(i.__t=i.nodeValue))&&(i.__t=e,i.nodeValue=e+"")}function zS(i,t){return b5(i,t)}const aa=new Map;function b5(i,{target:t,anchor:e,props:n={},events:r,context:s,intro:o=!0}){i5();var l=void 0,a=a5(()=>{var c=e??t.appendChild(An());WR(c,{pending:()=>{}},f=>{Wn({});var d=$t;s&&(d.c=s),r&&(n.$$events=r),l=i(f,n)||{},Yn()});var h=new Set,u=f=>{for(var d=0;d<f.length;d++){var O=f[d];if(!h.has(O)){h.add(O);var p=g5(O);for(const b of[t,document]){var m=aa.get(b);m===void 0&&(m=new Map,aa.set(b,m));var g=m.get(O);g===void 0?(b.addEventListener(O,cf,{passive:p}),m.set(O,1)):m.set(O,g+1)}}}};return u(Yc(ES)),af.add(u),()=>{var p;for(var f of h)for(const m of[t,document]){var d=aa.get(m),O=d.get(f);--O==0?(m.removeEventListener(f,cf),d.delete(f),d.size===0&&aa.delete(m)):d.set(f,O)}af.delete(u),c!==e&&((p=c.parentNode)==null||p.removeChild(c))}});return hf.set(l,a),l}let hf=new WeakMap;function _S(i,t){const e=hf.get(i);return e?(hf.delete(i),e(t)):Promise.resolve()}var si,Ki,oi,dr,Sl,xc,kf;class IS{constructor(t,e=!0){P(this,"anchor");A(this,si,new Map);A(this,Ki,new Map);A(this,oi,new Map);A(this,dr,new Set);A(this,Sl,!0);A(this,xc,()=>{var t=dt;if(w(this,si).has(t)){var e=w(this,si).get(t),n=w(this,Ki).get(e);if(n)Rd(n),w(this,dr).delete(e);else{var r=w(this,oi).get(e);r&&(w(this,Ki).set(e,r.effect),w(this,oi).delete(e),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(const[s,o]of w(this,si)){if(w(this,si).delete(s),s===t)break;const l=w(this,oi).get(o);l&&(ge(l.effect),w(this,oi).delete(o))}for(const[s,o]of w(this,Ki)){if(s===e||w(this,dr).has(s))continue;const l=()=>{if(Array.from(w(this,si).values()).includes(s)){var a=document.createDocumentFragment();$S(o,a),a.append(An()),w(this,oi).set(s,{effect:o,fragment:a})}else ge(o);w(this,dr).delete(s),w(this,Ki).delete(s)};w(this,Sl)||!n?(w(this,dr).add(s),mr(o,l,!1)):l()}}});A(this,kf,t=>{w(this,si).delete(t);const e=Array.from(w(this,si).values());for(const[n,r]of w(this,oi))e.includes(n)||(ge(r.effect),w(this,oi).delete(n))});this.anchor=t,R(this,Sl,e)}ensure(t,e){var n=dt,r=mS();e&&!w(this,Ki).has(t)&&!w(this,oi).has(t)&&w(this,Ki).set(t,Ri(()=>e(this.anchor))),w(this,si).set(n,t),r||w(this,xc).call(this)}}si=new WeakMap,Ki=new WeakMap,oi=new WeakMap,dr=new WeakMap,Sl=new WeakMap,xc=new WeakMap,kf=new WeakMap;function Qr(i,t,...e){var n=new IS(i);Gc(()=>{const r=t()??null;n.ensure(r,r&&(s=>r(s,...e)))},xr)}function Uc(i){$t===null&&K1(),mo&&$t.l!==null?w5($t).m.push(i):Nc(()=>{const t=zl(i);if(typeof t=="function")return t})}function w5(i){var t=i.l;return t.u??(t.u={a:[],b:[],m:[]})}function Ft(i,t,e=!1){var n=new IS(i),r=e?xr:0;function s(o,l){n.ensure(o,l)}Gc(()=>{var o=!1;t((l,a=0)=>{o=!0,s(a,l)}),o||s(!1,null)},r)}function S5(i,t,e){for(var n=[],r=t.length,s,o=t.length,l=0;l<r;l++){let u=t[l];mr(u,()=>{if(s){if(s.pending.delete(u),s.done.add(u),s.pending.size===0){var f=i.outrogroups;uf(Yc(s.done)),f.delete(s),f.size===0&&(i.outrogroups=null)}}else o-=1},!1)}if(o===0){var a=n.length===0&&e!==null;if(a){var c=e,h=c.parentNode;n5(h),h.append(c),i.items.clear()}uf(t,!a)}else s={pending:new Set(t),done:new Set},(i.outrogroups??(i.outrogroups=new Set)).add(s)}function uf(i,t=!0){for(var e=0;e<i.length;e++)ge(i[e],t)}var Dm;function ca(i,t,e,n,r,s=null){var o=i,l=new Map,a=(t&W1)!==0;if(a){var c=i;o=c.appendChild(An())}var h=null,u=$d(()=>{var g=e();return vd(g)?g:g==null?[]:Yc(g)}),f,d=!0;function O(){m.fallback=h,v5(m,f,o,t,n),h!==null&&(f.length===0?h.f&en?(h.f^=en,Lo(h,null,o)):Rd(h):mr(h,()=>{h=null}))}var p=Gc(()=>{f=$(u);for(var g=f.length,b=new Set,S=dt,x=mS(),y=0;y<g;y+=1){var k=f[y],Q=n(k,y),Z=d?null:l.get(Q);Z?(Z.v&&lo(Z.v,k),Z.i&&lo(Z.i,y),x&&S.unskip_effect(Z.e)):(Z=x5(l,d?o:Dm??(Dm=An()),k,Q,y,r,t,e),d||(Z.e.f|=en),l.set(Q,Z)),b.add(Q)}if(g===0&&s&&!h&&(d?h=Ri(()=>s(o)):(h=Ri(()=>s(Dm??(Dm=An()))),h.f|=en)),g>b.size&&vR(),!d)if(x){for(const[D,L]of l)b.has(D)||S.skip_effect(L.e);S.oncommit(O),S.ondiscard(()=>{})}else O();$(u)}),m={effect:p,items:l,outrogroups:null,fallback:h};d=!1}function Co(i){for(;i!==null&&!(i.f&vi);)i=i.next;return i}function v5(i,t,e,n,r){var L,B,_,G,U,H,Xt,_t,Yt;var s=(n&nR)!==0,o=t.length,l=i.items,a=Co(i.effect.first),c,h=null,u,f=[],d=[],O,p,m,g;if(s)for(g=0;g<o;g+=1)O=t[g],p=r(O,g),m=l.get(p).e,!(m.f&en)&&((B=(L=m.nodes)==null?void 0:L.a)==null||B.measure(),(u??(u=new Set)).add(m));for(g=0;g<o;g+=1){if(O=t[g],p=r(O,g),m=l.get(p).e,i.outrogroups!==null)for(const lt of i.outrogroups)lt.pending.delete(m),lt.done.delete(m);if(m.f&en)if(m.f^=en,m===a)Lo(m,null,e);else{var b=h?h.next:a;m===i.effect.last&&(i.effect.last=m.prev),m.prev&&(m.prev.next=m.next),m.next&&(m.next.prev=m.prev),pn(i,h,m),pn(i,m,b),Lo(m,b,e),h=m,f=[],d=[],a=Co(h.next);continue}if(m.f&De&&(Rd(m),s&&((G=(_=m.nodes)==null?void 0:_.a)==null||G.unfix(),(u??(u=new Set)).delete(m))),m!==a){if(c!==void 0&&c.has(m)){if(f.length<d.length){var S=d[0],x;h=S.prev;var y=f[0],k=f[f.length-1];for(x=0;x<f.length;x+=1)Lo(f[x],S,e);for(x=0;x<d.length;x+=1)c.delete(d[x]);pn(i,y.prev,k.next),pn(i,h,y),pn(i,k,S),a=S,h=k,g-=1,f=[],d=[]}else c.delete(m),Lo(m,a,e),pn(i,m.prev,m.next),pn(i,m,h===null?i.effect.first:h.next),pn(i,h,m),h=m;continue}for(f=[],d=[];a!==null&&a!==m;)(c??(c=new Set)).add(a),d.push(a),a=Co(a.next);if(a===null)continue}!(m.f&en)&&f.push(m),h=m,a=Co(m.next)}if(i.outrogroups!==null){for(const lt of i.outrogroups)lt.pending.size===0&&(uf(Yc(lt.done)),(U=i.outrogroups)==null||U.delete(lt));i.outrogroups.size===0&&(i.outrogroups=null)}if(a!==null||c!==void 0){var Q=[];if(c!==void 0)for(m of c)!(m.f&De)&&Q.push(m);for(;a!==null;)!(a.f&De)&&a!==i.fallback&&Q.push(a),a=Co(a.next);var Z=Q.length;if(Z>0){var D=n&W1&&o===0?e:null;if(s){for(g=0;g<Z;g+=1)(Xt=(H=Q[g].nodes)==null?void 0:H.a)==null||Xt.measure();for(g=0;g<Z;g+=1)(Yt=(_t=Q[g].nodes)==null?void 0:_t.a)==null||Yt.fix()}S5(i,Q,D)}}s&&on(()=>{var lt,Vt;if(u!==void 0)for(m of u)(Vt=(lt=m.nodes)==null?void 0:lt.a)==null||Vt.apply()})}function x5(i,t,e,n,r,s,o,l){var a=o&eR?o&rR?kr(e):t5(e,!1,!1):null,c=o&iR?kr(r):null;return{v:a,i:c,e:Ri(()=>(s(t,a??e,c??r,l),()=>{i.delete(n)}))}}function Lo(i,t,e){if(i.nodes)for(var n=i.nodes.start,r=i.nodes.end,s=t&&!(t.f&en)?t.nodes.start:e;n!==null;){var o=Ll(n);if(s.before(n),n===r)return;n=o}}function pn(i,t,e){t===null?i.effect.first=e:t.next=e,e===null?i.effect.last=t:e.prev=t}function y5(i,t,e=!1,n=!1,r=!1){var s=i,o="";se(()=>{var l=at;if(o!==(o=t()??"")&&(l.nodes!==null&&(xS(l.nodes.start,l.nodes.end),l.nodes=null),o!=="")){var a=o+"";e?a=`<svg>${a}</svg>`:n&&(a=`<math>${a}</math>`);var c=Zd(a);if((e||n)&&(c=_i(c)),co(_i(c),c.lastChild),e||n)for(;_i(c);)s.before(_i(c));else s.before(c)}})}function Vm(i,t=!1){var e=t?" !important;":";",n="";for(var r in i){var s=i[r];s!=null&&s!==""&&(n+=" "+r+": "+s+e)}return n}function k5(i,t){if(t){var e="",n,r;return Array.isArray(t)?(n=t[0],r=t[1]):n=t,n&&(e+=Vm(n)),r&&(e+=Vm(r,!0)),e=e.trim(),e===""?null:e}return String(i)}function Bh(i,t={},e,n){for(var r in e){var s=e[r];t[r]!==s&&(e[r]==null?i.style.removeProperty(r):i.style.setProperty(r,s,n))}}function dc(i,t,e,n){var r=i.__style;if(r!==t){var s=k5(t,n);s==null?i.removeAttribute("style"):i.style.cssText=s,i.__style=t}else n&&(Array.isArray(n)?(Bh(i,e==null?void 0:e[0],n[0]),Bh(i,e==null?void 0:e[1],n[1],"important")):Bh(i,e,n));return n}const Q5=Symbol("is custom element"),$5=Symbol("is html");function Qt(i,t,e,n){var r=C5(i);r[t]!==(r[t]=e)&&(t==="loading"&&(i[wR]=e),e==null?i.removeAttribute(t):typeof e!="string"&&P5(i).includes(t)?i[t]=e:i.setAttribute(t,e))}function C5(i){return i.__attributes??(i.__attributes={[Q5]:i.nodeName.includes("-"),[$5]:i.namespaceURI===Y1})}var Bm=new Map;function P5(i){var t=i.getAttribute("is")||i.nodeName,e=Bm.get(t);if(e)return e;Bm.set(t,e=[]);for(var n,r=i,s=Element.prototype;s!==r;){n=pR(r);for(var o in n)n[o].set&&e.push(o);r=xd(r)}return e}function Wm(i,t){return i===t||(i==null?void 0:i[Wo])===t}function Oc(i={},t,e,n){return c5(()=>{var r,s;return SS(()=>{r=s,s=[],zl(()=>{i!==e(...s)&&(t(i,...s),r&&Wm(e(...r),i)&&t(null,...r))})}),()=>{on(()=>{s&&Wm(e(...s),i)&&t(null,...s)})}}),i}let ha=!1;function T5(i){var t=ha;try{return ha=!1,[i(),ha]}finally{ha=t}}function ff(i,t,e,n){var S;var r=!mo||(e&oR)!==0,s=(e&aR)!==0,o=(e&cR)!==0,l=n,a=!0,c=()=>(a&&(a=!1,l=o?zl(n):n),l),h;if(s){var u=Wo in i||bR in i;h=((S=Yr(i,t))==null?void 0:S.set)??(u&&t in i?x=>i[t]=x:void 0)}var f,d=!1;s?[f,d]=T5(()=>i[t]):f=i[t],f===void 0&&n!==void 0&&(f=c(),h&&(r&&$R(),h(f)));var O;if(r?O=()=>{var x=i[t];return x===void 0?c():(a=!0,x)}:O=()=>{var x=i[t];return x!==void 0&&(l=void 0),x===void 0?l:x},r&&(e&lR)===0)return O;if(h){var p=i.$$legacy;return function(x,y){return arguments.length>0?((!r||!y||p||d)&&h(y?O():x),x):O()}}var m=!1,g=(e&sR?qc:$d)(()=>(m=!1,O()));s&&$(g);var b=at;return function(x,y){if(arguments.length>0){const k=y?$(g):r&&s?xe(x):x;return q(g,k),m=!0,l!==void 0&&(l=k),x}return _n&&m||b.f&sn?g.v:$(g)}}function go(i){var t;return"ownerDocument"in i?((t=i.ownerDocument)==null?void 0:t.defaultView)??window:window}function fl(i){return"ownerDocument"in i?i.ownerDocument:document}function jS(i){return i instanceof Node||i instanceof go(i).Node}function A5(i){return i instanceof HTMLBRElement||i instanceof go(i).HTMLBRElement}function DS(i){return i instanceof Element||i instanceof go(i).Element}function R5(i){return i instanceof HTMLElement||i instanceof go(i).HTMLElement}function Ed(i){if(W(i)||!R5(i))throw new Error("Target is not an HTMLElement");return i}function VS(i,t){return jS(t)?i.contains(t):!1}function BS(i){if(jS(i))return DS(i)?i:i.parentElement??void 0}function WS(i,t){var e;return((e=BS(i))==null?void 0:e.querySelector(Ld(t)))??void 0}function YS(i,t){var e;return((e=BS(i))==null?void 0:e.closest(Ld(t)))??void 0}function qS(i,t){return DS(i)&&i.matches(Ld(t))}function Z5({ancestor:i,descendent:t,getText:e}){const n=[];for(let r=t;r!==i;r=r.parentNode){const s=[];for(let o=r.parentNode.firstChild;o!==r;o=o.nextSibling)s.push((e==null?void 0:e(o))??o.textContent??"");n.unshift(s.join(""))}return n.join("")}function Ld(i){return FT(i,(t,e)=>`[data-${t}="${e}"]`).join("")}const Ym=-1;function X5(i,t){const e=document.createElement("div");e.className="cm-content",e.appendChild(t);const n=document.createElement("div");n.className="cm-scroller",n.appendChild(e);const r=document.createElement("div");r.className=`cm-editor ${i.themeClasses}`,r.appendChild(n),r.style="visibility: hidden;",fl(i.dom).body.appendChild(r);const{height:s}=t.getBoundingClientRect();return fl(i.dom).body.removeChild(r),s}function E5(i,t){const e=go(i),n=new e.ResizeObserver(([r],s)=>{const{borderBoxSize:[o]}=r;t({height:o.blockSize})});return n.observe(i,{box:"border-box"}),()=>n.disconnect()}async function L5({millis:i}){return await new Promise(t=>setTimeout(t,i))}function $r(...i){return()=>i.forEach(t=>t())}function M5({delayMillis:i}){let t=!1;return L5({millis:i}).then(()=>t=!0),()=>t}const qr=["table.correct","table.delete","table.edit","table.focus","table.format","table.navigate","table.select"],z5=qr.map(i=>`${i}.undo`),_5=qr.map(i=>`${i}.redo`),I5=new Map([...qr.map(i=>[i,`${i}.undo`]),...qr.map(i=>[`${i}.undo`,`${i}.redo`]),...qr.map(i=>[`${i}.redo`,`${i}.undo`])]),j5=new Set(["table.correct.undo","table.delete.undo","table.format.undo"]),D5=new Set(["table.edit.undo","table.edit.redo"]),NS=[...qr,...z5,..._5];function V5(i){return I5.get(i)}function B5(i){return j5.has(i)}function W5(i){return D5.has(i)}const Md=Ke.define(),Y5=new Map(NS.map(i=>[i,Md.of(i)]));function Rn(i){return Y5.get(i)}function zd(i){return E(Hc(i))}function q5(i){const t=Hc(i);return E(t)&&B5(t)}function N5(i){const t=Hc(i);return E(t)&&t==="table.focus"}function G5(i){const t=Hc(i);return E(t)&&W5(t)}function Hc(i){return i.annotation(Md)}function Qn(i,{start:t,endExclusive:e}){return t<=e?i>=t&&i<e:i<=t&&i>e}function qm({start:i,endExclusive:t}){return i===t}function Nm(i,t){return(i==null?void 0:i.start)===(t==null?void 0:t.start)&&(i==null?void 0:i.endExclusive)===(t==null?void 0:t.endExclusive)}function U5(i,t){if(i.length===0)return-1;let e=0,n=i.length-1;for(;e!==n;){const r=e+PA((n-e)/2);i[r]>t?n=r-1:e=r}return i[e]<=t?e:-1}class rt{constructor({row:t,col:e}){P(this,"row");P(this,"col");this.row=t,this.col=e}rowOrCol(t){return t==="row"?this.row:this.col}get startRow(){return this.row.start}get startCol(){return this.col.start}startRowOrCol(t){return t==="row"?this.startRow:this.startCol}get endRow(){return this.row.endExclusive-1}get endCol(){return this.col.endExclusive-1}endRowOrCol(t){return t==="row"?this.endRow:this.endCol}get rowRange(){return this.row}get colRange(){return this.col}rowOrColRange(t){return t==="row"?this.rowRange:this.colRange}get rowCount(){return this.row.endExclusive-this.row.start}get colCount(){return this.col.endExclusive-this.col.start}get topLeftCell(){return{row:this.startRow,col:this.startCol}}get topRightCell(){return{row:this.startRow,col:this.endCol}}get bottomRightCell(){return{row:this.endRow,col:this.endCol}}get bottomLeftCell(){return{row:this.endRow,col:this.startCol}}cornerCellAt(t){switch(t){case"top-left":return this.topLeftCell;case"top-right":return this.topRightCell;case"bottom-right":return this.bottomRightCell;case"bottom-left":return this.bottomLeftCell}}containsRow(t){return Qn(t,this.rowRange)}containsCol(t){return Qn(t,this.colRange)}containsCell({row:t,col:e}){return this.containsRow(t)&&this.containsCol(e)}containsOnEdge({row:t,col:e}){return this.containsCell({row:t,col:e})?{top:t===this.startRow,right:e===this.endCol,bottom:t===this.endRow,left:e===this.startCol}:{top:!1,right:!1,bottom:!1,left:!1}}isSingleCell(){return this.rowCount===1&&this.colCount===1}shiftUp(){return rt.of({row:{start:this.row.start-1,endExclusive:this.row.endExclusive-1},col:{...this.col}})}shiftRight(){return rt.of({row:{...this.row},col:{start:this.col.start+1,endExclusive:this.col.endExclusive+1}})}shiftDown(){return rt.of({row:{start:this.row.start+1,endExclusive:this.row.endExclusive+1},col:{...this.col}})}shiftLeft(){return rt.of({row:{...this.row},col:{start:this.col.start-1,endExclusive:this.col.endExclusive-1}})}shift(t,e){return t==="row"?e==="backward"?this.shiftUp():this.shiftDown():e==="backward"?this.shiftLeft():this.shiftRight()}expandUp(){return rt.of({row:{start:this.row.start-1,endExclusive:this.row.endExclusive},col:{...this.col}})}expandRight(){return rt.of({row:{...this.row},col:{start:this.col.start,endExclusive:this.col.endExclusive+1}})}expandDown(){return rt.of({row:{start:this.row.start,endExclusive:this.row.endExclusive+1},col:{...this.col}})}expandLeft(){return rt.of({row:{...this.row},col:{start:this.col.start-1,endExclusive:this.col.endExclusive}})}contractUp(){return rt.of({row:{start:this.row.start,endExclusive:this.row.endExclusive-1},col:{...this.col}})}contractRight(){return rt.of({row:{...this.row},col:{start:this.col.start+1,endExclusive:this.col.endExclusive}})}contractDown(){return rt.of({row:{start:this.row.start+1,endExclusive:this.row.endExclusive},col:{...this.col}})}contractLeft(){return rt.of({row:{...this.row},col:{start:this.col.start,endExclusive:this.col.endExclusive-1}})}addForwardsByRowOrCol(t,{start:e,count:n}){if(e>this.endRowOrCol(t))return this;const r=e<=this.startRowOrCol(t)?n:0,s=n;return this.withRowOrCol(t,{start:this.startRowOrCol(t)+r,endExclusive:this.endRowOrCol(t)+s+1})}subtractBackwardsByRowOrCol(t,{start:e,count:n,min:r}){if(e-n-1>=this.endRowOrCol(t))return this;if(e<=this.startRowOrCol(t)){const u={start:ce(this.rowOrCol(t).start-n,{min:r}),endExclusive:ce(this.rowOrCol(t).endExclusive-n,{min:r})};return qm(u)?void 0:this.withRowOrCol(t,u)}const s=this.rowOrColRange(t),o={start:e-n,endExclusive:e},l={start:wd(s.start,o.start),endExclusive:hc(s.endExclusive,o.endExclusive)},a=l.endExclusive-l.start,c=e>s.endExclusive?0:n-a,h={start:ce(s.start-c,{min:r}),endExclusive:ce(s.endExclusive-c-a,{min:r})};return qm(h)?void 0:this.withRowOrCol(t,h)}withRowOrCol(t,e){return t==="row"?rt.of({row:e,col:{...this.col}}):rt.of({row:{...this.row},col:e})}static of(t){return new rt(t)}static ofCell(t){return new rt({row:{start:t.row,endExclusive:t.row+1},col:{start:t.col,endExclusive:t.col+1}})}}const GS=le(" "),Gm=GS,H5=GS;function F5(i,{hyphens:t=0}={}){return i==="none"?le("-").append(Mo(t)):i==="left"?le(":-").append(Mo(t)):i==="center"?le(":-").append(Mo(t)).append(le(":")):Mo(t).append(le("-:"))}function Mo(i){return le("-".repeat(i))}function Wh(i){return le(" ".repeat(i))}var dl;(i=>{function t(n){return pc.of(n)}i.of=t;function e(n){return pc.maybeOf(n)}i.maybeOf=e})(dl||(dl={}));const nt=1,df=1,Gn=df,Yh=1,Um=df+df,Hm=2,K5=new Map([["none",1],["left",2],["center",3],["right",2]]);function Fm(i){return K5.get(i)}function ua(i,t){const e=i.from;return{from:e+t.from,to:e+t.to}}function Po(i,t){return i.from+t}var ns,rs,ss,os,ls;const qo=class qo{constructor({text:t,colSizes:e,alignments:n,contentSizes:r}){A(this,ns);A(this,rs);A(this,ss);A(this,os);A(this,ls);P(this,"firstRowIndex",0);P(this,"firstColIndex",0);P(this,"headerRowIndex",0);P(this,"firstDataRowIndex",1);P(this,"firstCellLocation",{row:this.firstRowIndex,col:this.firstColIndex});R(this,ns,ct(xe(t))),R(this,rs,ct(xe(e))),R(this,ss,ct(xe(n))),R(this,os,ct(xe(r))),R(this,ls,ct(xe(this.parseCells())))}get text(){return $(w(this,ns))}set text(t){q(w(this,ns),t,!0)}get colSizes(){return $(w(this,rs))}set colSizes(t){q(w(this,rs),t,!0)}get alignments(){return $(w(this,ss))}set alignments(t){q(w(this,ss),t,!0)}get contentSizes(){return $(w(this,os))}set contentSizes(t){q(w(this,os),t,!0)}get cells(){return $(w(this,ls))}set cells(t){q(w(this,ls),t,!0)}cellAt({row:t,col:e}){return vt(t,this.rowRange),vt(e,this.colRange),this.cells[t][e]}get firstCellSpan(){return this.cellSpan(this.firstCellLocation)}get lastCellSpan(){return this.cellSpan(this.lastCellLocation)}cellSpan(t){return vt(t.row,this.rowRange),vt(t.col,this.colRange),this.absoluteCellContentSpan(t)}closestCellAtPosition(t){if(t>this.text.length)return this.lastCellLocation;const{number:e,from:n}=this.text.lineAt(t);if(e===Hm)return this.hasDataRows()?{row:this.firstDataRowIndex,col:this.firstColIndex}:{row:this.headerRowIndex,col:this.lastColIndex};const r=t-n,s=e===1?this.headerRowIndex:e-2;let o=nt;const l=this.mapEachCol(c=>{const h=o;return o+=this.colSizes[c]+nt,h}),a=U5(l,r);return a===-1?{row:s,col:this.firstColIndex}:{row:s,col:a}}firstRowOrColIndex(t){return 0}get lastRowIndex(){return this.rowCount-1}get lastColIndex(){return this.colCount-1}lastRowOrColIndex(t){return t==="row"?this.lastRowIndex:this.lastColIndex}get rowCount(){return this.contentSizes.length}get colCount(){return this.colSizes.length}rowOrColCount(t){return t==="row"?this.rowCount:this.colCount}get rowRange(){return{start:this.firstRowIndex,endExclusive:this.lastRowIndex+1}}get colRange(){return{start:this.firstColIndex,endExclusive:this.lastColIndex+1}}rowOrColRange(t){return t==="row"?this.rowRange:this.colRange}get rowIndices(){return Tr(this.rowRange,t=>t)}get colIndices(){return Tr(this.colRange,t=>t)}get dataRowIndices(){return this.hasDataRows()?Tr({start:this.firstDataRowIndex,endExclusive:this.lastRowIndex+1},t=>t):[]}get lastCellLocation(){return{row:this.lastRowIndex,col:this.lastColIndex}}get rowCellCount(){return this.colCount}get colCellCount(){return this.rowCount}rowOrColCellCount(t){return t==="row"?this.rowCellCount:this.colCellCount}hasSingleRow(){return this.rowCount===1}hasSingleCol(){return this.colCount===1}hasSingleRowOrCol(t){return t==="row"?this.hasSingleRow():this.hasSingleCol()}hasDataRows(){return this.rowCount>1}hasRowAt(t){return Qn(t,this.rowRange)}hasColAt(t){return Qn(t,this.colRange)}hasRowOrColAt(t,e){return t==="row"?this.hasRowAt(e):this.hasColAt(e)}hasEmptyRowAt(t){return this.hasRowAt(t)&&this.contentSizes[t].every(e=>e===0)}hasEmptyColAt(t){return this.hasColAt(t)&&this.contentSizes.every(e=>e[t]===0)}hasEmptyRowOrColAt(t,e){return t==="row"?this.hasEmptyRowAt(e):this.hasEmptyColAt(e)}forEachRow(t){$i(this.rowRange,t)}forEachCol(t){$i(this.colRange,t)}mapEachRow(t){return Tr(this.rowRange,t)}mapEachCol(t){return Tr(this.colRange,t)}equals(t){const e=t._asInternal();return this.text.eq(e.text)&&bn(this.alignments,e.alignments,(n,r)=>n===r)&&bn(this.cells,e.cells,(n,r)=>bn(n,r,(s,o)=>s.eq(o)))&&bn(this.colSizes,e.colSizes,(n,r)=>n===r)&&bn(this.contentSizes,e.contentSizes,(n,r)=>bn(n,r,(s,o)=>s===o))}sliceSectionAt({rowRange:t,colRange:e,startRow:n,startCol:r,endCol:s}){sr(t,{within:this.rowRange}),sr(e,{within:this.colRange});const o=Ih(this.colSizes,e),l=Ih(this.alignments,e),a=[];let c=Y.empty;$i(t,u=>{a.push(Ih(this.contentSizes[u],e));const f=this.absoluteCellStart({row:u,col:r})-nt,d=this.absoluteCellEnd({row:u,col:s})+nt;if(u===n){c=c.append(this.sliceTextAt({from:f,to:d})),c=c.append(ac);const O=this.absoluteAlignmentStart(r)-nt,p=this.absoluteAlignmentEnd(s)+nt;c=c.append(this.sliceTextAt({from:O,to:p}))}else c=c.append(ac),c=c.append(this.sliceTextAt({from:f,to:d}))});const h=new qo({text:c,colSizes:o,contentSizes:a,alignments:l});return h.forEachCol(u=>{const f=h.calculateColSize(u),d=f-h.colSizes[u];h.forEachRow(O=>{h.addOrRemoveCellPadding({row:O,col:u},d)}),h.addOrRemoveAlignmentHyphens({col:u,diff:d}),h.colSizes[u]=f}),h.cells=h.parseCells(),h}setCellAt(t,e){vt(t.row,this.rowRange),vt(t.col,this.colRange);const n=this.absoluteCellSpan(t),r=e.length;this.contentSizes[t.row][t.col]=r;const s=this.calculateColSize(t.col),o=s-Gn-r;this.replaceTextAt(n,Gm.append(e).append(Wh(o)));const l=s-this.colSizes[t.col];this.forEachRow(a=>{a!==t.row&&this.addOrRemoveCellPadding({row:a,col:t.col},l)}),this.addOrRemoveAlignmentHyphens({col:t.col,diff:l}),this.colSizes[t.col]=s,this.cells[t.row][t.col]=e}setAlignmentAt(t,e){vt(t,this.colRange);const n=this.absoluteAlignmentSpan(t),r=Fm(e);this.alignments[t]=e;const s=this.calculateColSize(t),o=s-Um-r,l=F5(e,{hyphens:o});this.replaceTextAt(n,Gm.append(l).append(H5));const a=s-this.colSizes[t];this.forEachRow(c=>{this.addOrRemoveCellPadding({row:c,col:t},a)}),this.colSizes[t]=s}clearRow(t){vt(t,this.rowRange),this.clearSection(rt.of({row:{start:t,endExclusive:t+1},col:this.colRange}))}clearCol(t){vt(t,this.colRange),this.clearSection(rt.of({row:this.rowRange,col:{start:t,endExclusive:t+1}}))}clearRowOrCol(t,e){t==="row"?this.clearRow(e):this.clearCol(e)}clearSection({rowRange:t,colRange:e}){sr(t,{within:this.rowRange}),sr(e,{within:this.colRange}),$i(e,n=>{$i(t,o=>{this.contentSizes[o][n]=0,this.cells[o][n]=Y.empty});const r=this.calculateColSize(n);$i(t,o=>{const l=this.absoluteCellSpan({row:o,col:n});this.replaceTextAt(l,Wh(r))});const s=r-this.colSizes[n];this.forEachRow(o=>{Qn(o,t)||this.addOrRemoveCellPadding({row:o,col:n},s)}),this.addOrRemoveAlignmentHyphens({col:n,diff:s}),this.colSizes[n]=r})}prependEmptyRows(t){this.addEmptyRowsAt({row:this.firstRowIndex,count:t})}prependEmptyCols(t){this.addEmptyColsAt({col:this.firstColIndex,count:t})}addEmptyRowsAt({row:t,count:e}){if(vt(t,{start:this.firstRowIndex,endExclusive:this.rowCount+1}),e===0)return;const n=this.colSizes.map(s=>`|${" ".repeat(s)}`);n.push("|");const r=le(n.join(""));if(t===this.headerRowIndex){const s=this.headerRowLine(),o=this.sliceTextAt(s);this.replaceTextAt(s,r);const l=this.alignmentLine().to;this.addTextAt(o,l,{prependNewline:!0}),Lr(e-1,()=>this.addTextAt(r,l,{prependNewline:!0}))}else if(t===this.rowCount){const s=(this.hasSingleRow()?this.alignmentLine():this.rowLine(this.lastRowIndex)).to;Lr(e,()=>this.addTextAt(r,s,{prependNewline:!0}))}else{const s=this.rowLine(t).from;Lr(e,()=>this.addTextAt(r,s,{appendNewline:!0}))}this.contentSizes.splice(t,0,...Cm(0,{rows:e,cols:this.colCount})),this.cells.splice(t,0,...Cm(Y.empty,{rows:e,cols:this.colCount}))}addEmptyColsAt({col:t,count:e}){if(vt(t,{start:this.firstColIndex,endExclusive:this.lastColIndex+2}),e!==0){if(t===this.firstColIndex){const n=le("| ".repeat(e)),r=le("| - ".repeat(e));this.forEachRow(s=>{this.addTextAt(n,this.absoluteCellStart({row:s,col:t})-nt)}),this.addTextAt(r,this.absoluteAlignmentStart(t)-nt)}else{const n=le(" |".repeat(e)),r=le(" - |".repeat(e));this.forEachRow(s=>{this.addTextAt(n,this.absoluteCellEnd({row:s,col:t-1})+nt)}),this.addTextAt(r,this.absoluteAlignmentEnd(t-1)+nt)}this.colSizes.splice(t,0,...ra(3,{count:e})),this.alignments.splice(t,0,...ra("none",{count:e})),this.contentSizes.forEach(n=>n.splice(t,0,...ra(0,{count:e}))),this.cells.forEach(n=>n.splice(t,0,...ra(Y.empty,{count:e})))}}addEmptyRowsOrColsAt(t,{index:e,count:n}){t==="row"?this.addEmptyRowsAt({row:e,count:n}):this.addEmptyColsAt({col:e,count:n})}appendEmptyRows(t){this.addEmptyRowsAt({row:this.lastRowIndex+1,count:t})}appendEmptyCols(t){this.addEmptyColsAt({col:this.lastColIndex+1,count:t})}duplicateRowAt(t){if(vt(t,this.rowRange),t===this.headerRowIndex){const e=this.sliceTextAt(this.rowLine(t));this.addTextAt(e,this.alignmentLine().to,{prependNewline:!0})}else{const e=this.rowLine(t),n=this.sliceTextAt(e);this.addTextAt(n,e.to,{prependNewline:!0})}this.contentSizes.splice(t+1,0,[...this.contentSizes[t]]),this.cells.splice(t+1,0,[...this.cells[t]])}duplicateColAt(t){vt(t,this.colRange),this.forEachRow(r=>{const{from:s,to:o}=this.absoluteCellSpan({row:r,col:t});this.addTextAt(this.sliceTextAt({from:s,to:o+nt}),o+nt)});const{from:e,to:n}=this.absoluteAlignmentSpan(t);this.addTextAt(this.sliceTextAt({from:e,to:n+nt}),n+nt),this.colSizes.splice(t+1,0,this.colSizes[t]),this.alignments.splice(t+1,0,this.alignments[t]),this.contentSizes.forEach(r=>r.splice(t+1,0,r[t])),this.cells.forEach(r=>r.splice(t+1,0,r[t]))}duplicateRowOrColAt(t,e){t==="row"?this.duplicateRowAt(e):this.duplicateColAt(e)}moveRowAt({fromIndex:t,toIndex:e}){if(vt(t,this.rowRange),vt(e,this.rowRange),t!==e){if(Uu(t-e)===1){const[n,r]=t<e?[t,e]:[e,t],s=this.rowLine(n),o=this.sliceTextAt(s),l=this.rowLine(r),a=this.sliceTextAt(l);this.replaceTextAt(l,o),this.replaceTextAt(s,a)}else if(t===this.headerRowIndex){const n=this.headerRowLine(),r=this.sliceTextAt(n),s=this.rowLine(this.firstDataRowIndex),o=this.sliceTextAt(s),l=this.rowLine(e);this.addTextAt(r,l.to,{prependNewline:!0}),this.removeTextAt(s,{removeLeadingNewline:!0}),this.replaceTextAt(n,o)}else if(e===this.headerRowIndex){const n=this.rowLine(t),r=this.sliceTextAt(n),s=this.headerRowLine(),o=this.sliceTextAt(s);this.removeTextAt(n,{removeLeadingNewline:!0}),this.addTextAt(o,this.alignmentLine().to,{prependNewline:!0}),this.replaceTextAt(s,r)}else if(e<t){const n=this.rowLine(t),r=this.sliceTextAt(n),s=this.rowLine(e);this.removeTextAt(n,{removeLeadingNewline:!0}),this.addTextAt(r,s.from,{appendNewline:!0})}else if(e>t){const n=this.rowLine(t),r=this.sliceTextAt(n),s=this.rowLine(e);this.addTextAt(r,s.to,{prependNewline:!0}),this.removeTextAt(n,{removeTrailingNewline:!0})}Ar(this.contentSizes,{fromIndex:t,toIndex:e}),Ar(this.cells,{fromIndex:t,toIndex:e})}}moveColAt({fromIndex:t,toIndex:e}){if(vt(t,this.colRange),vt(e,this.colRange),t===e)return;e<t?this.forEachRow(r=>{const s=this.absoluteCellSpan({row:r,col:t}),o=this.sliceTextAt({from:s.from,to:s.to+nt}),l=this.absoluteCellStart({row:r,col:e});this.removeTextAt({from:s.from,to:s.to+nt}),this.addTextAt(o,l)}):this.forEachRow(r=>{const s=this.absoluteCellSpan({row:r,col:t}),o=this.sliceTextAt({from:s.from-nt,to:s.to}),l=this.absoluteCellEnd({row:r,col:e});this.addTextAt(o,l),this.removeTextAt({from:s.from-nt,to:s.to})});const n=this.absoluteAlignmentSpan(t);if(e<t){const r=this.sliceTextAt({from:n.from,to:n.to+nt}),s=this.absoluteAlignmentStart(e);this.removeTextAt({from:n.from,to:n.to+nt}),this.addTextAt(r,s)}else{const r=this.sliceTextAt({from:n.from-nt,to:n.to}),s=this.absoluteAlignmentEnd(e);this.addTextAt(r,s),this.removeTextAt({from:n.from-nt,to:n.to})}Ar(this.colSizes,{fromIndex:t,toIndex:e}),Ar(this.alignments,{fromIndex:t,toIndex:e}),this.contentSizes.forEach(r=>Ar(r,{fromIndex:t,toIndex:e})),this.cells.forEach(r=>Ar(r,{fromIndex:t,toIndex:e}))}moveRowOrColAt(t,e){t==="row"?this.moveRowAt(e):this.moveColAt(e)}removeRowsAt({row:t,count:e}){if(vt(t,this.rowRange),vt(e,{start:0,endExclusive:this.rowCount}),e!==0){if(t===this.headerRowIndex){const n=this.rowLine(e),r=this.sliceTextAt(n),{from:s}=this.rowLine(this.firstDataRowIndex),{to:o}=n;this.removeTextAt({from:s,to:o},{removeLeadingNewline:!0}),this.replaceTextAt(this.headerRowLine(),r)}else{const{from:n}=this.rowLine(t),{to:r}=this.rowLine(t+e-1);this.removeTextAt({from:n,to:r},{removeLeadingNewline:!0})}this.contentSizes.splice(t,e),this.cells.splice(t,e),this.forEachCol(n=>{const r=this.calculateColSize(n),s=r-this.colSizes[n];this.forEachRow(o=>{this.addOrRemoveCellPadding({row:o,col:n},s)}),this.addOrRemoveAlignmentHyphens({col:n,diff:s}),this.colSizes[n]=r})}}removeColsAt({col:t,count:e}){if(vt(t,this.colRange),vt(e,{start:0,endExclusive:this.colCount}),e===0)return;this.forEachRow(s=>{this.removeTextAt({from:this.absoluteCellStart({row:s,col:t}),to:this.absoluteCellEnd({row:s,col:t+e-1})+nt})});const{from:n}=this.absoluteAlignmentSpan(t),{to:r}=this.absoluteAlignmentSpan(t+e-1);this.removeTextAt({from:n,to:r+nt}),this.colSizes.splice(t,e),this.alignments.splice(t,e),this.contentSizes.forEach(s=>s.splice(t,e)),this.cells.forEach(s=>s.splice(t,e))}removeRowsOrColsAt(t,{index:e,count:n}){t==="row"?this.removeRowsAt({row:e,count:n}):this.removeColsAt({col:e,count:n})}merge(t,{row:e,col:n}){vt(e,this.rowRange),vt(n,this.colRange);const r=e===this.headerRowIndex,s=ce(e+t.rowCount-this.rowCount,{min:0}),o=ce(n+t.colCount-this.colCount,{min:0}),l={start:e,endExclusive:e+t.rowCount},a={start:n,endExclusive:n+t.colCount};this.appendEmptyRows(s),this.appendEmptyCols(o);const c=t._asInternal();if($i(l,h=>{this.contentSizes[h].splice(n,c.colCount,...c.contentSizes[h-e]),this.cells[h].splice(n,c.colCount,...c.cells[h-e]);const u={from:this.absoluteCellStart({row:h,col:a.start})-nt,to:this.absoluteCellEnd({row:h,col:a.endExclusive-1})+nt},f=c.sliceTextAt(c.rowLine(h-e));this.replaceTextAt(u,f)}),r){this.alignments.splice(n,c.colCount,...c.alignments);const h={from:this.absoluteAlignmentStart(a.start)-nt,to:this.absoluteAlignmentEnd(a.endExclusive-1)+nt},u=c.sliceTextAt(c.alignmentLine());this.replaceTextAt(h,u)}$i(a,h=>{const u=this.calculateColSize(h),f=u-this.colSizes[h],d=u-c.colSizes[h-n];this.forEachRow(O=>{this.addOrRemoveCellPadding({row:O,col:h},Qn(O,l)?d:f)}),this.addOrRemoveAlignmentHyphens({col:h,diff:r?d:f}),this.colSizes[h]=u})}tile({rowRepeat:t,colRepeat:e}){if(!(t===0&&e===0)){if(e>=1){this.forEachRow(o=>{const{from:l,to:a}=this.rowLine(o),c=this.sliceTextAt({from:l+nt,to:a});this.addTextAt(_h(c,e),a)});const{from:n,to:r}=this.alignmentLine(),s=this.sliceTextAt({from:n+nt,to:r});this.addTextAt(_h(s,e),r),this.alignments=sa(this.alignments,e+1),this.colSizes=sa(this.colSizes,e+1),this.forEachRow(o=>{this.contentSizes[o]=sa(this.contentSizes[o],e+1),this.cells[o]=sa(this.cells[o],e+1)})}if(t>=1){const{from:n,to:r}=this.alignmentLine(),s=this.text.replace(n-nt,r,Y.empty);this.appendText(_h(Vc(s,{prependNewline:!0}),t));const o=this.rowRange;Lr(t,()=>{$i(o,l=>{this.contentSizes.push([...this.contentSizes[l]]),this.cells.push([...this.cells[l]])})})}}}sortByColAt(t,e){if(vt(t,this.colRange),this.rowCount===1)return;const n={start:this.firstDataRowIndex,endExclusive:this.lastRowIndex+1},r=Tr(n,c=>c).sort((c,h)=>e(this.cellAt({row:c,col:t}),this.cellAt({row:h,col:t}))),s=this.rowLines(),o=s.map(({from:c,to:h})=>this.sliceTextAt({from:c,to:h})),l=[...this.contentSizes],a=[...this.cells];$i(n,c=>{const h=r[c-this.firstDataRowIndex];c!==h&&(this.replaceTextAt(s[c],o[h]),this.contentSizes[c]=l[h],this.cells[c]=a[h])})}reset(t){const{text:e,colSizes:n,alignments:r,contentSizes:s}=Hu(t);this.text=e,this.colSizes=n,this.alignments=r,this.contentSizes=s,this.cells=this.parseCells()}_asInternal(){return this}toJSON(){return{text:this.text.toString(),colSizes:Dh(this.colSizes),alignments:Dh(this.alignments),contentSizes:Dh(this.contentSizes),cells:this.cells.map(t=>t.map(e=>e.toString()))}}addTextAt(t,e,{prependNewline:n=!1,appendNewline:r=!1}={}){this.text=lA(this.text,{text:t,at:e,prependNewline:n,appendNewline:r})}appendText(t,{prependNewline:e=!1,appendNewline:n=!1}={}){this.text=aA(this.text,{text:t,prependNewline:e,appendNewline:n})}removeTextAt(t,{removeLeadingNewline:e=!1,removeTrailingNewline:n=!1}={}){this.text=cA(this.text,{location:t,removeLeadingNewline:e,removeTrailingNewline:n})}replaceTextAt(t,e,{prependNewline:n=!1,appendNewline:r=!1}={}){this.text=hA(this.text,{span:t,text:e,prependNewline:n,appendNewline:r})}sliceTextAt({from:t,to:e}){return this.text.slice(t,e)}addAlignmentHyphens({col:t,count:e}){this.addTextAt(Mo(e),this.absoluteAlignmentStart(t)+Gn+Yh)}removeAlignmentHyphens({col:t,count:e}){const n=this.absoluteAlignmentStart(t);this.removeTextAt({from:n+Gn+Yh,to:n+Gn+Yh+e})}addOrRemoveAlignmentHyphens({col:t,diff:e}){e<0?this.removeAlignmentHyphens({col:t,count:-e}):e>0&&this.addAlignmentHyphens({col:t,count:e})}addCellPadding(t,e){this.addTextAt(Wh(e),this.absoluteCellContentEnd(t)+1)}removeCellPadding(t,e){const n=this.absoluteCellContentEnd(t);this.removeTextAt({from:n,to:n+e})}addOrRemoveCellPadding(t,e){e<0?this.removeCellPadding(t,-e):e>0&&this.addCellPadding(t,e)}alignmentLine(){return this.text.line(Hm)}headerRowLine(){return this.text.line(1)}rowLine(t){return this.text.line(t===this.headerRowIndex?t+1:t+2)}rowLines(){return lc(this.text.lines-1,t=>this.text.line(t===this.headerRowIndex?t+1:t+2))}relativeCellStart(t){const e=(t+1)*nt,n=$m(this.colSizes,{start:0,endExclusive:t});return e+n}relativeCellStarts(){const t=yA(this.colSizes);return this.mapEachCol(e=>{const n=(e+1)*nt,r=e===this.firstColIndex?0:t[e-1];return n+r})}relativeCellContentStart(t){return this.relativeCellStart(t)+Gn}relativeCellContentStarts(){return this.relativeCellStarts().map(t=>t+Gn)}relativeCellEnd(t){const e=(t+1)*nt,n=$m(this.colSizes,{start:0,endExclusive:t+1});return e+n}relativeCellSpan(t){const e=this.relativeCellStart(t);return{from:e,to:e+this.colSizes[t]}}relativeAlignmentStart(t){return this.relativeCellStart(t)}relativeAlignmentEnd(t){return this.relativeCellEnd(t)}relativeAlignmentSpan(t){return this.relativeCellSpan(t)}absoluteCellStart({row:t,col:e}){return Po(this.rowLine(t),this.relativeCellStart(e))}absoluteCellContentSpan({row:t,col:e}){const n=this.relativeCellStart(e)+Gn,r=n+this.contentSizes[t][e];return ua(this.rowLine(t),{from:n,to:r})}absoluteCellContentEnd(t){return Po(this.rowLine(t.row),this.relativeCellContentStart(t.col)+this.contentSizes[t.row][t.col])}absoluteCellEnd({row:t,col:e}){return Po(this.rowLine(t),this.relativeCellEnd(e))}absoluteCellSpan({row:t,col:e}){return ua(this.rowLine(t),this.relativeCellSpan(e))}absoluteAlignmentStart(t){return Po(this.alignmentLine(),this.relativeAlignmentStart(t))}absoluteAlignmentEnd(t){return Po(this.alignmentLine(),this.relativeAlignmentEnd(t))}absoluteAlignmentSpan(t){return ua(this.alignmentLine(),this.relativeAlignmentSpan(t))}calculateColSize(t){const e=lc(this.rowCount,r=>this.contentSizes[r][t]),n=Fm(this.alignments[t]);return wd(...e,n)+Um}parseCells(){const t=this.rowLines(),e=this.relativeCellContentStarts();return this.mapEachRow(n=>this.mapEachCol(r=>{const s={from:e[r],to:e[r]+this.contentSizes[n][r]},{from:o,to:l}=ua(t[n],s);return this.text.slice(o,l)}))}static of(t){return new qo(Hu(t))}static maybeOf(t){const e=j1(t);return E(e)?new qo(e):void 0}};ns=new WeakMap,rs=new WeakMap,ss=new WeakMap,os=new WeakMap,ls=new WeakMap;let pc=qo;function Cr(i,t){return(i==null?void 0:i.row)===(t==null?void 0:t.row)&&(i==null?void 0:i.col)===(t==null?void 0:t.col)}function US({row:i,col:t}){return{row:i-1,col:t}}function HS({row:i,col:t}){return{row:i,col:t+1}}function FS({row:i,col:t}){return{row:i+1,col:t}}function KS({row:i,col:t}){return{row:i,col:t-1}}function qh(i,t,e){return i==="row"?e==="backward"?US(t):FS(t):e==="backward"?KS(t):HS(t)}function Km(i,t,{start:e,count:n}){return Of(i,t,e<=t[i]?t[i]+n:t[i])}function Jm(i,t,{start:e,count:n,boundary:r}){return E(r)&&(r.min,r.max),e-n-1>=t[i]?t:e<=t[i]?Of(i,t,t[i]-n):E(r)?Of(i,t,ce(t[i],{min:r.min,max:r.max})):void 0}function Of(i,t,e){return i==="row"?{row:e,col:t.col}:{row:t.row,col:e}}function JS(i,t){return(i==null?void 0:i.anchor)===(t==null?void 0:t.anchor)&&(i==null?void 0:i.head)===(t==null?void 0:t.head)}function tv({anchor:i,head:t}){return i<=t?{from:i,to:t}:{from:t,to:i}}function ev({anchor:i,head:t}){return i<=t}function J5(i,t){return Cr(i==null?void 0:i.cell,t==null?void 0:t.cell)&&JS(i==null?void 0:i.section,t==null?void 0:t.section)}function tZ(i){return i==="hidden"}function eZ(i){return i==="all"}function iZ(i){return i==="none"}function Ta(i){return!HT(i)}function Fc(i,t){return Ta(i)?Ta(t)&&J5(i,t):!Ta(t)&&i===t}var as;const tO=class tO{constructor(t){A(this,as);R(this,as,ct(xe(t)))}get value(){return $(w(this,as))}set value(t){q(w(this,as),t,!0)}isHidden(){return tZ(this.value)}isAll(){return eZ(this.value)}isNone(){return iZ(this.value)}isCell(){return Ta(this.value)}get cell(){return this.isCell()?this.value.cell:void 0}get cellSection(){return this.isCell()?this.value.section:void 0}equals(t){return Fc(this.value,t.value)}toJSON(){return this.isCell()?{value:{cell:this.cell,section:this.cellSection}}:{value:this.value}}static of(t){return new tO(t)}};as=new WeakMap;let pf=tO;var cs,hs;const eO=class eO{constructor({span:t,doc:e,selection:n}){A(this,cs);A(this,hs);P(this,"_span");P(this,"table");P(this,"selection");this._span=t,this.table=dl.of(e.slice(this.from,this.to)),this.selection=pf.of(this.computeSelection(n)),R(this,cs,ct(xe(this.table.text))),R(this,hs,ct(xe(this.selection.value)))}get _editorTableText(){return $(w(this,cs))}set _editorTableText(t){q(w(this,cs),t,!0)}get _editorSelectionValue(){return $(w(this,hs))}set _editorSelectionValue(t){q(w(this,hs),t,!0)}get editorTableText(){return this._editorTableText}get editorSelectionValue(){return this._editorSelectionValue}get span(){return this._span}set span(t){this._span=t}get from(){return this._span.from}get to(){return this._span.to}get isValid(){return this.from<this.to}containsSelection(){return this.selection.isCell()||this.selection.isHidden()}markSynchronized(){this._editorTableText=this.table.text,this._editorSelectionValue=this.selection.value}applyTransaction(t){t.docChanged?this.applyStateChange(t):this.applySelectionChange(t)}applyStateChange(t){const{from:e,to:n}=this.span;if(this.span={from:t.changes.mapPos(this.from,1),to:t.changes.mapPos(this.to)},!!this.isValid&&(this.applySelectionChange(t),G5(t)&&t.changes.touchesRange(e,n)!==!1)){const r=t.newDoc.slice(this.from,this.to);this.table.reset(r),this._editorTableText=r}}applySelectionChange(t){if(!this.isValid)return;const e=this.computeSelection(t.newSelection);!Fc(this.selection.value,e)&&(this.selection.value=e,this._editorSelectionValue=e)}computeSelection(t){if(t.main.head===this.from+1&&t.main.anchor===this.from+1)return"hidden";if(Xm({needle:this.span,haystack:t.main}))return"all";if(Xm({needle:t.main,haystack:this.span})){const e=this.table.closestCellAtPosition(t.main.anchor-this.from),{from:n,to:r}=this.table.cellSpan(e);return{cell:e,section:{anchor:ce(t.main.anchor-this.from,{min:n,max:r})-n,head:ce(t.main.head-this.from,{min:n,max:r})-n}}}else return"none"}static of(t){return new eO(t)}};cs=new WeakMap,hs=new WeakMap;let mf=eO;const nZ={top:0,right:0,bottom:0,left:0},iv={pos:0,clip:!1,create(i){const t=fl(i.dom).createElement("div");return t.className="tbl-menu-tooltip",{dom:t,overlap:!0,resize:!1,getCoords:()=>nZ}}},Ol="Cell";function _l(i){return YS(i,{component:Ol})}function mc(i,{row:t,col:e}){return WS(i,{component:Ol,row:`${t}`,col:`${e}`})}function Kc(i){if(!qS(i,{component:Ol}))return;const t=Ed(i);return{row:Am(t.dataset.row),col:Am(t.dataset.col)}}const rZ="5";var yg;typeof window<"u"&&((yg=window.__svelte??(window.__svelte={})).v??(yg.v=new Set)).add(rZ);const sZ=typeof window<"u"?window:void 0;function oZ(i){let t=i.activeElement;for(;t!=null&&t.shadowRoot;){const e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}var us,vl;class lZ{constructor(t={}){A(this,us);A(this,vl);const{window:e=sZ,document:n=e==null?void 0:e.document}=t;e!==void 0&&(R(this,us,n),R(this,vl,aS(r=>{const s=Mt(e,"focusin",r),o=Mt(e,"focusout",r);return()=>{s(),o()}})))}get current(){var t;return(t=w(this,vl))==null||t.call(this),w(this,us)?oZ(w(this,us)):null}}us=new WeakMap,vl=new WeakMap;new lZ;function aZ(i,t){switch(i){case"post":Nc(t);break;case"pre":o5(t);break}}function nv(i,t,e,n={}){const{lazy:r=!1}=n;let s=!r,o=Array.isArray(i)?[]:void 0;aZ(t,()=>{const l=Array.isArray(i)?i.map(c=>c()):i();if(!s){s=!0,o=l;return}const a=zl(()=>e(l,o));return o=l,a})}function _d(i,t,e){nv(i,"post",t,e)}function cZ(i,t,e){nv(i,"pre",t,e)}_d.pre=cZ;function br(i){return i?"":void 0}function tg(i){return i.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function eg(...i){return RA(OT(...i))}const hZ=sA();function uZ(i,t){const e=uc(i),n=t.style([])??void 0,r=[];return fA(e,s=>{if(uA(s)){r.push([]);return}const o=hZ.parse(new Tc(s)).cursor(),l=cc(o),a=[];gf({cursor:l,from:0,to:l.to,text:s,classes:E(n)?n.split(" "):[],highlighter:t,elementLine:a}),r.push(a)}),r}function gf({cursor:i,from:t,to:e,text:n,classes:r,passedClasses:s=[],highlighter:o,textOffset:l=0,elementLine:a}){var h,u;if(!i.firstChild()){const f=(u=(h=i.tree)==null?void 0:h.prop(N.mounted))==null?void 0:u.tree;if(E(f)){const d=f.cursor();gf({cursor:d,from:d.from,to:d.to,text:n,classes:r,passedClasses:s,highlighter:o,textOffset:l+t,elementLine:a})}else a.push({textContent:n.sliceString(l+t,l+e),classes:jh(r)});return}let c=t;do{i.from>c&&a.push({textContent:n.sliceString(l+c,l+i.from),classes:jh(r)}),c=i.to;const f=h0(i),d=o.style((f==null?void 0:f.tags)??[]),O=E(d)?d.split(" "):[];gf({cursor:i,from:i.from,to:i.to,text:n,classes:[...s,...O],passedClasses:(f==null?void 0:f.inherit)??!1?[...s,...O]:s,highlighter:o,textOffset:l,elementLine:a})}while(i.nextSibling());c<e&&a.push({textContent:n.sliceString(l+c,l+e),classes:jh(r)}),i.parent()}function fZ(i,t){return dZ(uZ(i,t))}function dZ(i){return i.map(t=>t.map(OZ).join("")).join(`<span data-br>
58
58
  </span>`)}function OZ({textContent:i,classes:t}){return E(t)?`<span class="${t.join(" ")}">${tg(i)}</span>`:tg(i)}const pZ=[{type:"table",location:"bottom-right"},{type:"table",location:"right"},{type:"table",location:"bottom"}];function mZ({row:i,col:t},e){const n=[{type:"header",location:"col",index:t},{type:"border",location:"top",index:i}],r=[{type:"border",location:"col",index:t+1},{type:"border",location:"row",index:i+1}],s=[{type:"header",location:"row",index:i},{type:"border",location:"left",index:i}];return[...e.top?n:[],...r,...e.left?s:[]]}function gZ({location:i,type:t},e){return t==="header"?{location:i,type:t,index:e[i]}:i==="top"?{location:i,type:t,index:e.row}:i==="left"?{location:i,type:t,index:e.col}:{location:i,type:t,index:e[i]+1}}function bf(i,t){return(i==null?void 0:i.type)!==(t==null?void 0:t.type)||(i==null?void 0:i.location)!==(t==null?void 0:t.location)?!1:(i==null?void 0:i.type)==="table"||(t==null?void 0:t.type)==="table"?!0:(i==null?void 0:i.index)===(t==null?void 0:t.index)}class gc{constructor(t,e){P(this,"state");P(this,"extraTags");this.state=t,this.extraTags=e}style(t){return nQ(this.state,E(this.extraTags)?[...t,...this.extraTags]:t)}static of(t,e){return new gc(t,e)}}function rv(i){return Jc(i).type==="None"}function sv(i){return!rv(i)}function ig(i){return sv(i)?Jc(i).getRangeAt(0).startOffset:void 0}function bZ(i){return sv(i)?Jc(i).getRangeAt(0).startContainer:void 0}function wZ(i){Jc(i).empty()}function Jc(i){return i.getSelection()}var fs,ds,Os,ps,ms,gs,bs,ws,Ss,vs,xs,ys,ks,Qs,$s,Cs,Ps,Ts,As,Rs,Zs,Xs,Es,Ls,Ms,zs,_s,Is,js,Ds,Vs;const iO=class iO{constructor({table:t,selection:e,scrollElement:n,rootEditor:r,menuRootElement:s,extensions:o,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h,onUndo:u,onRedo:f,onNavigate:d,onDelete:O}){A(this,fs);A(this,ds);A(this,Os);A(this,ps);A(this,ms);A(this,gs);A(this,bs);A(this,ws);A(this,Ss);A(this,vs);A(this,xs);A(this,ys);A(this,ks);A(this,Qs);A(this,$s);A(this,Cs);A(this,Ps);A(this,Ts);A(this,As);A(this,Rs);A(this,Zs);A(this,Xs);A(this,Es);A(this,Ls);A(this,Ms);A(this,zs);A(this,_s);A(this,Is);A(this,js);A(this,Ds);A(this,Vs);R(this,fs,F(t)),R(this,ds,F(e)),R(this,Os,ct(!1));const p=this.selection.isCell()?this.selection.cell:void 0;R(this,ps,ct(p)),R(this,ms,ct(p)),R(this,gs,ct(E(p)?rt.ofCell(p):void 0)),R(this,bs,F(r)),R(this,ws,F(o)),R(this,Ss,F(l)),R(this,vs,F(a)),R(this,xs,F(c)),R(this,ys,F(h)),R(this,ks,ct(void 0)),R(this,Qs,ct(void 0)),R(this,$s,F(n)),R(this,Cs,F(s)),R(this,Ps,F(()=>gc.of(this.rootEditor.state,[v.heading]))),R(this,Ts,F(()=>gc.of(this.rootEditor.state))),R(this,As,F(u)),R(this,Rs,F(f)),R(this,Zs,F(d)),R(this,Xs,F(O)),R(this,Es,ct(!1)),R(this,Ls,ct(void 0)),R(this,Ms,ct(void 0)),R(this,zs,ct(void 0)),R(this,_s,ct(void 0)),R(this,Is,ct(void 0)),R(this,js,ct(void 0)),R(this,Ds,F(()=>W(this.move)&&W(this.resize)&&W(this.menu)&&W(this.outline))),R(this,Vs,ct(!1));const m=F(()=>{var g;if(Wc(this.window)){if(E(this.menu))return"default";if(E(this.activeHandle)){const{type:b,location:S}=this.activeHandle.handle;if(b==="table"){if(S==="right")return"col-resize";if(S==="bottom-right")return"nwse-resize";if(S==="bottom")return"row-resize"}else{if(b==="border")return S==="top"?"row-resize":S==="left"?"col-resize":`${S}-resize`;if(b==="header")return this.pointerDown?"grabbing":this.activeHandle.state==="hover"?"pointer":void 0}}else{if(((g=this.outline)==null?void 0:g.outlined)??!1)return"cell";if(E(this.hoveredCell))return"text"}}});_d([()=>this.selectionValue],()=>{if(this.selectionChanged){this.selectionChanged=!1;return}this.selection.isCell()?(this.activeCell=this.selection.cell,this.anchorCell=this.selection.cell,this.outlinedSection=rt.ofCell(this.selection.cell)):this.selection.isHidden()?(this.focusTable(),this.activeCell=void 0,this.anchorCell=void 0,this.outlinedSection=void 0):(this.activeTable=!1,this.activeCell=void 0,this.anchorCell=void 0,this.outlinedSection=void 0)}),Nc(()=>{this.document.body.style.cursor=$(m)??""})}get table(){return $(w(this,fs))}set table(t){q(w(this,fs),t)}get _selection(){return $(w(this,ds))}set _selection(t){q(w(this,ds),t)}get selectionChanged(){return $(w(this,Os))}set selectionChanged(t){q(w(this,Os),t,!0)}get activeCell(){return $(w(this,ps))}set activeCell(t){q(w(this,ps),t)}get anchorCell(){return $(w(this,ms))}set anchorCell(t){q(w(this,ms),t)}get outlinedSection(){return $(w(this,gs))}set outlinedSection(t){q(w(this,gs),t)}get rootEditor(){return $(w(this,bs))}set rootEditor(t){q(w(this,bs),t)}get extensions(){return $(w(this,ws))}set extensions(t){q(w(this,ws),t)}get markdownConfig(){return $(w(this,Ss))}set markdownConfig(t){q(w(this,Ss),t)}get globalKeyBindings(){return $(w(this,vs))}set globalKeyBindings(t){q(w(this,vs),t)}get selectionType(){return $(w(this,xs))}set selectionType(t){q(w(this,xs),t)}get lineWrapping(){return $(w(this,ys))}set lineWrapping(t){q(w(this,ys),t)}get wrapperElement(){return $(w(this,ks))}set wrapperElement(t){q(w(this,ks),t)}get tableElement(){return $(w(this,Qs))}set tableElement(t){q(w(this,Qs),t)}get scrollElement(){return $(w(this,$s))}set scrollElement(t){q(w(this,$s),t)}get menuRootElement(){return $(w(this,Cs))}set menuRootElement(t){q(w(this,Cs),t)}get headerCellHighlighter(){return $(w(this,Ps))}set headerCellHighlighter(t){q(w(this,Ps),t)}get dataCellHighlighter(){return $(w(this,Ts))}set dataCellHighlighter(t){q(w(this,Ts),t)}get onUndo(){return $(w(this,As))}set onUndo(t){q(w(this,As),t)}get onRedo(){return $(w(this,Rs))}set onRedo(t){q(w(this,Rs),t)}get onNavigate(){return $(w(this,Zs))}set onNavigate(t){q(w(this,Zs),t)}get onDelete(){return $(w(this,Xs))}set onDelete(t){q(w(this,Xs),t)}get activeTable(){return $(w(this,Es))}set activeTable(t){q(w(this,Es),t)}get hoveredCell(){return $(w(this,Ls))}set hoveredCell(t){q(w(this,Ls),t)}get activeHandle(){return $(w(this,Ms))}set activeHandle(t){q(w(this,Ms),t)}get menu(){return $(w(this,zs))}set menu(t){q(w(this,zs),t)}get move(){return $(w(this,_s))}set move(t){q(w(this,_s),t)}get outline(){return $(w(this,Is))}set outline(t){q(w(this,Is),t)}get resize(){return $(w(this,js))}set resize(t){q(w(this,js),t)}get interactive(){return $(w(this,Ds))}set interactive(t){q(w(this,Ds),t)}get pointerDown(){return $(w(this,Vs))}set pointerDown(t){q(w(this,Vs),t)}static of(t){return new iO(t)}focusTable(){this.activeTable=!0,this.tableElement.focus({preventScroll:!0}),this.selectionValue="hidden",wZ(this.document)}scrollToCell(t){requestAnimationFrame(()=>{var e;(e=mc(this.tableElement,t))==null||e.scrollIntoView({inline:"nearest",block:"nearest"})})}scrollToFirstCell(t,e){requestAnimationFrame(()=>{var n;(n=mc(this.tableElement,{...this.table.firstCellLocation,[t]:e}))==null||n.scrollIntoView({inline:"nearest",block:"nearest"})})}get document(){return this.rootEditor.dom.ownerDocument}get window(){return this.document.defaultView??window}get rootScrollElement(){return this.rootEditor.scrollDOM}get scrollOffsetX(){return this.rootScrollElement.scrollLeft+this.scrollElement.scrollLeft}get scrollOffsetY(){return this.rootScrollElement.scrollTop+this.scrollElement.scrollTop}deleteTable(){this.onDelete()}navigate(t){this.onNavigate(t)}undo(){this.onUndo()}redo(){this.onRedo()}get selection(){return this._selection}get selectionValue(){return this._selection.value}set selectionValue(t){Fc(this._selection.value,t)||(this._selection.value=t,this.selectionChanged=!0)}highlighter({row:t}){return t===this.table.firstRowIndex?this.headerCellHighlighter:this.dataCellHighlighter}cellHandleState(t,e){var n,r,s,o,l;return e.type==="border"||((n=this.activeHandle)==null?void 0:n.state)=="active"?bf((r=this.activeHandle)==null?void 0:r.handle,e)?(s=this.activeHandle)==null?void 0:s.state:void 0:bf((o=this.activeHandle)==null?void 0:o.handle,e)||t[e.location]===((l=this.activeCell)==null?void 0:l[e.location])?"hover":void 0}};fs=new WeakMap,ds=new WeakMap,Os=new WeakMap,ps=new WeakMap,ms=new WeakMap,gs=new WeakMap,bs=new WeakMap,ws=new WeakMap,Ss=new WeakMap,vs=new WeakMap,xs=new WeakMap,ys=new WeakMap,ks=new WeakMap,Qs=new WeakMap,$s=new WeakMap,Cs=new WeakMap,Ps=new WeakMap,Ts=new WeakMap,As=new WeakMap,Rs=new WeakMap,Zs=new WeakMap,Xs=new WeakMap,Es=new WeakMap,Ls=new WeakMap,Ms=new WeakMap,zs=new WeakMap,_s=new WeakMap,Is=new WeakMap,js=new WeakMap,Ds=new WeakMap,Vs=new WeakMap;let wf=iO;function ov({tableState:i,event:t}){if(W(i.outlinedSection))return;t==null||t.preventDefault();const e=Nm(i.outlinedSection.rowRange,i.table.rowRange),n=Nm(i.outlinedSection.colRange,i.table.colRange),r=n&&!e&&Cn(i.outlinedSection.rowRange).every(l=>i.table.hasEmptyRowAt(l)),s=e&&!n&&Cn(i.outlinedSection.colRange).every(l=>i.table.hasEmptyColAt(l)),o=e&&n&&Cn(i.outlinedSection.colRange).every(l=>i.table.hasEmptyColAt(l));if(r){i.table.removeRowsAt({row:i.outlinedSection.startRow,count:i.outlinedSection.rowCount});const l=i.table.hasRowAt(i.outlinedSection.startRow)?i.outlinedSection.startRow:i.table.lastRowIndex,a={row:l,col:i.table.lastColIndex};i.outlinedSection=rt.of({row:{start:l,endExclusive:l+1},col:i.table.colRange}),i.activeCell=a,i.anchorCell=a}else if(s){i.table.removeColsAt({col:i.outlinedSection.startCol,count:i.outlinedSection.colCount});const l=i.table.hasColAt(i.outlinedSection.startCol)?i.outlinedSection.startCol:i.table.lastColIndex,a={row:i.table.lastRowIndex,col:l};i.outlinedSection=rt.of({row:i.table.rowRange,col:{start:l,endExclusive:l+1}}),i.activeCell=a,i.anchorCell=a}else o?i.deleteTable():i.table.clearSection(i.outlinedSection)}function lv(i){cv(i,"copy")}function av(i){cv(i,"cut")}function Id({event:i,tableState:t}){if(W(t.outlinedSection))return;const e=i.clipboardData.getData("text/plain"),n=dl.maybeOf(Y.of(e.split(/\r\n|\n|\r/)));E(n)?(i.preventDefault(),i.stopPropagation(),ng(n,t)):t.selection.isCell()||(i.preventDefault(),i.stopPropagation(),ng(SZ(e),t))}function ng(i,t){const{startRow:e,startCol:n,rowCount:r,colCount:s}=t.outlinedSection,o=Tm(r/i.rowCount),l=Tm(s/i.colCount);i.tile({rowRepeat:ce(o-1,{min:0}),colRepeat:ce(l-1,{min:0})}),t.table.merge(i,{row:e,col:n}),t.outlinedSection=rt.of({row:{start:e,endExclusive:e+i.rowCount},col:{start:n,endExclusive:n+i.colCount}}),W(t.anchorCell)&&(t.anchorCell=t.activeCell);const a=t.anchorCell.row<=t.activeCell.row,c=t.anchorCell.col<=t.activeCell.col;t.anchorCell=t.outlinedSection.cornerCellAt(`${a?"top":"bottom"}-${c?"left":"right"}`),t.activeCell=t.outlinedSection.cornerCellAt(`${a?"bottom":"top"}-${c?"right":"left"}`),t.focusTable()}function SZ(i){const{text:t}=_1([[le(i)]],["none"]);return dl.of(t)}function cv({event:i,tableState:t},e){var r;if(W(t.outlinedSection)||t.selection.isCell())return;i.preventDefault(),i.stopPropagation();const n=t.table.sliceSectionAt(t.outlinedSection);(r=i.clipboardData)==null||r.setData("text/plain",n.text.toString()),e==="cut"&&ov({tableState:t})}function vZ(i){i.pointerDown=!0}function xZ(i){i.pointerDown=!1}function yZ(i){i.pointerDown=!1}function kZ(i,t){t.selection.isCell()||lv({tableState:t,event:i})}function QZ(i,t){t.selection.isCell()||av({tableState:t,event:i})}function $Z(i,t){t.selection.isCell()||Id({tableState:t,event:i})}const jd="CellView";function hv(i){return YS(i,{component:jd})}function CZ(i){return WS(i,{component:jd})}const $n="\0";function uv(i,t,{trim:e}){const n=ev(i),{from:r,to:s}=tv(i),o=t.toString(),l=Y.of(`${o.slice(0,r)}${$n}${o.slice(r,s)}${$n}${o.slice(s)}`.split(`
59
59
  `)),a=Sd(l,{trim:e}).toString(),c=a.indexOf($n),h=a.lastIndexOf($n)-1;return n?{anchor:c,head:h}:{head:c,anchor:h}}function rg(i,t){const e=ev(i),{from:n,to:r}=tv(i),s=t.toString(),o=Y.of(`${s.slice(0,n)}${$n}${s.slice(n,r)}${$n}${s.slice(r)}`.split(`
60
60
  `)),l=uc(o).toString(),a=l.indexOf($n),c=l.lastIndexOf($n)-1;return e?{anchor:a,head:c}:{head:a,anchor:c}}function PZ(i){if(W(i.tableElement)||rv(i.document))return;const t=bZ(i.document);if(W(t)||!VS(i.tableElement,t))return;const e=_l(t);if(W(e))return;const n=Kc(e);i.selection.isCell()&&Cr(i.selection.cell,n)||(i.activeTable=!1,i.selectionValue={cell:n,section:TZ(i.document,t)},i.activeCell=n,i.anchorCell=n,i.outlinedSection=rt.ofCell(n))}function TZ(i,t){const e=hv(t),n=Z5({ancestor:e,descendent:t,getText:l=>A5(l)?`
61
- `:l.textContent??""})??"",r=(t.textContent??"").slice(0,ig(i)),s=le(`${n}${r}`),o=n.length+ig(i);return uv({anchor:o,head:o},s,{trim:!1})}function AZ(i,t){var e=Xd(),n=Et(e);Qr(n,()=>t.children),I(i,e)}function RZ(i,t){Wn(t,!0),Uc(()=>{const e=zS(AZ,{target:t.to,context:MR(),props:{children:t.children}});return()=>{_S(e)}}),Yn()}ER();var ZZ=ot('<div class="tbl-blocking-overlay" aria-hidden="true"></div>');function XZ(i){var t=ZZ();I(i,t)}function bc(i,t){const e=t.devicePixelRatio;return TA(i*e)/e}function EZ({x:i,y:t},e){return{x:bc(i,e),y:bc(t,e)}}var LZ=ot('<th class="tbl-cell tbl-header-cell"><!></th>'),MZ=ot('<td class="tbl-cell tbl-data-cell"><!></td>');function zZ(i,t){Wn(t,!0);const e=F(()=>eg(E(t.movement)?t.movement.border:{top:t.position.top,right:!0,bottom:!0,left:t.position.left})),n=F(()=>eg(t.outline)),r=F(()=>{var u;if(W((u=t.movement)==null?void 0:u.translate))return;const{x:c,y:h}=t.movement.state==="moving"?EZ(t.movement.translate,t.win):t.movement.translate;return`translate3d(${c}px, ${h}px, 0px)`});var s=Xd(),o=Et(s);{var l=c=>{var h=LZ();let u;var f=Ue(h);Qr(f,()=>t.children),se(d=>{var O;Qt(h,"align",t.alignment==="none"?void 0:t.alignment),Qt(h,"data-component",Ol),Qt(h,"data-row",t.location.row),Qt(h,"data-col",t.location.col),Qt(h,"data-border",$(e)),Qt(h,"data-outline",$(n)),Qt(h,"data-selected",d),Qt(h,"data-state",(O=t.movement)==null?void 0:O.state),u=dc(h,"",u,{transform:$(r)})},[()=>br(t.selected)]),I(c,h)},a=c=>{var h=MZ();let u;var f=Ue(h);Qr(f,()=>t.children),se(d=>{var O;Qt(h,"align",t.alignment==="none"?void 0:t.alignment),Qt(h,"data-component",Ol),Qt(h,"data-row",t.location.row),Qt(h,"data-col",t.location.col),Qt(h,"data-border",$(e)),Qt(h,"data-outline",$(n)),Qt(h,"data-selected",d),Qt(h,"data-state",(O=t.movement)==null?void 0:O.state),u=dc(h,"",u,{transform:$(r)})},[()=>br(t.selected)]),I(c,h)};Ft(o,c=>{t.position.top?c(l):c(a,!1)})}I(i,s),Yn()}function fv(i){var t;return E((t=fl(i.dom).activeElement)==null?void 0:t.closest(".cm-panels"))}function sg(i){return i.trim().split(/\s+/)}function _Z({doc:i,selection:t,parent:e,extensions:n,markdownConfig:r,selectionType:s,lineWrapping:o,globalKeyBindings:l,rootEditor:a,highlighter:c,onChange:h,eventHandlers:u}){return new z({doc:i,selection:t,parent:e,extensions:[n,hn.lowest([z.editorAttributes.of(f=>{const d=new Set(sg(a.themeClasses)),O=new Set(sg(f.themeClasses));return{class:[...d.difference(O)].join(" ")}}),Dn.of([...l.map(f=>({...f,run:E(f.run)?()=>f.run(a):void 0,shift:E(f.shift)?()=>f.shift(a):void 0}))]),s==="codemirror"?pk():[],m0(c),zc({extensions:[X1,r.extensions??[]],addKeymap:!1,completeHTMLTags:r.completeHTMLTags,pasteURLAsLink:r.pasteURLAsLink,htmlTagLanguage:r.htmlTagLanguage}),z.domEventObservers(u),o==="wrap"?z.lineWrapping:[]])],dispatchTransactions:(f,d)=>{d.update(f),f.forEach(h)}})}var IZ=ot('<div class="tbl-cell-editor"></div>');function jZ(i,t){Wn(t,!0);let e=ff(t,"text",15),n=ff(t,"selection",15),r,s,o=!1,l=!1;function a(h){const{docChanged:u,newDoc:f,selection:d}=h;if(o)return;const O=E(d);if(u||O){if(u){const p=Sd(f,{trim:!0});p.eq(e())||(e(p),l=!0)}if(O){const{head:p,anchor:m}=d.main,g=uv({head:p,anchor:m},f,{trim:!0});JS(g,n())||(n(g),l=!0)}}}_d([()=>e(),()=>n()],()=>{if(l){l=!1;return}o=!0,s.dispatch({changes:s.state.changes({from:0,to:s.state.doc.length,insert:uc(e())}),selection:rg(n(),e())}),o=!1},{lazy:!0}),Uc(()=>(s=_Z({doc:uc(e()),selection:rg(n(),e()),parent:r,selectionType:t.selectionType,lineWrapping:t.lineWrapping,extensions:t.extensions,markdownConfig:t.markdownConfig,globalKeyBindings:t.globalKeyBindings,rootEditor:t.rootEditor,highlighter:t.highlighter,onChange:a,eventHandlers:{beforeinput:t.onbeforeinput,dragstart:t.ondragstart,keydown:(h,{state:u})=>t.onkeydown(h,u),paste:t.onpaste}}),fv(s)||s.focus(),()=>s.destroy()));var c=IZ();Oc(c,h=>r=h,()=>r),I(i,c),Yn()}class th{constructor({event:t,tableState:e,position:n}){P(this,"event");P(this,"tableState");P(this,"position");this.event=t,this.tableState=e,this.position=n}static navigate(t){new th(t)[`navigate${t.key}`]()}navigateTab(){this.moveRight({createRow:!0,position:"end"})}navigateShiftTab(){this.moveLeft({createRow:!0,position:"end"})}navigateEnter(){this.moveDown({createRow:!0,position:"end"})}navigateArrowLeft(){this.position.left&&this.moveLeft({createRow:!1,position:"end"})}navigateArrowUp(){this.position.top&&this.moveUp({createRow:!1,position:"end"})}navigateArrowRight(){this.position.right&&this.moveRight({createRow:!1,position:"start"})}navigateArrowDown(){this.position.bottom&&this.moveDown({createRow:!1,position:"end"})}navigateShiftArrowLeft(){if(!(!this.position.left||W(this.tableState.outlinedSection)||W(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),W(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.endCol===this.tableState.anchorCell.col){if(this.tableState.outlinedSection.startCol===this.tableState.table.firstColIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandLeft()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractLeft();this.tableState.activeCell=KS(this.tableState.activeCell)}}navigateShiftArrowUp(){if(!(!this.position.top||W(this.tableState.outlinedSection)||W(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),W(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.endRow===this.tableState.anchorCell.row){if(this.tableState.outlinedSection.startRow===this.tableState.table.firstRowIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandUp()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractUp();this.tableState.activeCell=US(this.tableState.activeCell)}}navigateShiftArrowRight(){if(!(!this.position.right||W(this.tableState.outlinedSection)||W(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),W(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.startCol===this.tableState.anchorCell.col){if(this.tableState.outlinedSection.endCol===this.tableState.table.lastColIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandRight()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractRight();this.tableState.activeCell=HS(this.tableState.activeCell)}}navigateShiftArrowDown(){if(!(!this.position.bottom||W(this.tableState.outlinedSection)||W(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),W(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.startRow===this.tableState.anchorCell.row){if(this.tableState.outlinedSection.endRow===this.tableState.table.lastRowIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandDown()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractDown();this.tableState.activeCell=FS(this.tableState.activeCell)}}moveLeft({createRow:t,position:e}){if(!W(this.tableState.activeCell)){if(this.event.preventDefault(),Cr(this.tableState.activeCell,this.tableState.table.firstCellLocation)){if(!t){this.tableState.navigate("before");return}this.tableState.table.prependEmptyRows(1),this.tableState.activeCell={row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col}}this.moveTo(this.tableState.activeCell.col===this.tableState.table.firstColIndex?{row:this.tableState.activeCell.row-1,col:this.tableState.table.lastColIndex}:{row:this.tableState.activeCell.row,col:this.tableState.activeCell.col-1},e)}}moveUp({createRow:t,position:e}){if(!W(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.firstRowIndex){if(!t){this.tableState.navigate("before");return}this.tableState.table.prependEmptyRows(1),this.tableState.activeCell={row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col}}this.moveTo({row:this.tableState.activeCell.row-1,col:this.tableState.activeCell.col},e)}}moveRight({createRow:t,position:e}){if(!W(this.tableState.activeCell)){if(this.event.preventDefault(),Cr(this.tableState.activeCell,this.tableState.table.lastCellLocation)){if(!t){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo(this.tableState.activeCell.col===this.tableState.table.lastColIndex?{row:this.tableState.activeCell.row+1,col:this.tableState.table.firstColIndex}:{row:this.tableState.activeCell.row,col:this.tableState.activeCell.col+1},e)}}moveDown({createRow:t,position:e}){if(!W(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.lastRowIndex){if(!t){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo({row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col},e)}}moveTo(t,e){if(this.tableState.activeCell=t,this.tableState.anchorCell=t,this.tableState.outlinedSection=rt.ofCell(t),this.tableState.selection.isCell()){const n=e==="start"?0:this.tableState.table.cellAt(t).length;this.tableState.selectionValue={cell:t,section:{anchor:n,head:n}}}}}const bt={alt:"Alt",arrowDown:"ArrowDown",arrowLeft:"ArrowLeft",arrowRight:"ArrowRight",arrowUp:"ArrowUp",backspace:"Backspace",c:"c",delete:"Delete",enter:"Enter",escape:"Escape",shift:"Shift",tab:"Tab",v:"v",x:"x"},DZ=[bt.arrowDown,bt.arrowLeft,bt.arrowRight,bt.arrowUp,bt.enter,bt.tab,`${bt.shift}${bt.arrowDown}`,`${bt.shift}${bt.arrowLeft}`,`${bt.shift}${bt.arrowRight}`,`${bt.shift}${bt.arrowUp}`,`${bt.shift}${bt.tab}`],og=new Set(DZ);function dv({key:i,shiftKey:t,altKey:e,metaKey:n,ctrlKey:r}){if(!(e||n||r))return t?og.has(`${bt.shift}${i}`)?`${bt.shift}${i}`:void 0:og.has(i)?i:void 0}function VZ(i,t){i.inputType==="historyUndo"?(t.undo(),i.preventDefault()):i.inputType==="historyRedo"&&(t.redo(),i.preventDefault())}function BZ(i){i.preventDefault()}function WZ(i,t,e){const n=dv(i);if(W(n))return;const r=t.selection.main.head,s=t.doc.lineAt(r).number,o=0,l=t.doc.length,a=1,c=t.doc.lines,h={top:s===a,right:r===l,bottom:s===c,left:r===o};th.navigate({tableState:e,key:n,event:i,position:h})}function YZ(i,t){Id({tableState:t,event:i})}var qZ=ot('<div class="tbl-cell-view" contenteditable="" tabindex="-1"><!></div>');function NZ(i,t){Wn(t,!0);var e=qZ(),n=Ue(e);Qr(n,()=>t.children),se(r=>{Qt(e,"data-component",jd),Qt(e,"data-hidden",r)},[()=>br(t.hidden)]),I(i,e),Yn()}const Ov="Handle";function Dd(i){if(!qS(i,{component:Ov}))return;const{type:t,location:e}=Ed(i).dataset;if(t==="table")return{type:t,location:e};{const n=Kc(_l(i));return gZ({location:e,type:t},n)}}var GZ=ei('<svg class="tbl-handle-grip" width="15" height="3" fill="currentColor" viewBox="0 0 15 3" xmlns="http://www.w3.org/2000/svg"><circle cx="1.5" cy="1.5" r="1.5"></circle><circle cx="7.5" cy="1.5" r="1.5"></circle><circle cx="13.5" cy="1.5" r="1.5"></circle></svg>'),UZ=ei('<svg class="tbl-handle-grip" width="3" height="15" fill="currentColor" viewBox="0 0 3 15" xmlns="http://www.w3.org/2000/svg"><circle cy="1.5" cx="1.5" r="1.5"></circle><circle cy="7.5" cx="1.5" r="1.5"></circle><circle cy="13.5" cx="1.5" r="1.5"></circle></svg>'),HZ=ot('<div class="tbl-handle" role="button" aria-hidden="true"><!></div>');function lg(i,t){Wn(t,!0);let e=ff(t,"toggle",3,!1);const n={table:{right:"vertical",bottom:"horizontal"},header:{row:"vertical",col:"horizontal"}},r=F(()=>{var c;return(c=n[t.of.type])==null?void 0:c[t.of.location]});var s=HZ();dc(s,"",{},{opacity:"var(--tbl-handle-opacity, 0)"});var o=Ue(s);{var l=c=>{var h=GZ();I(c,h)},a=c=>{var h=UZ();I(c,h)};Ft(o,c=>{$(r)==="horizontal"?c(l):$(r)==="vertical"&&c(a,1)})}se((c,h,u)=>{Qt(s,"data-component",Ov),Qt(s,"data-type",t.of.type),Qt(s,"data-location",t.of.location),Qt(s,"data-active",c),Qt(s,"data-hover",h),Qt(s,"data-toggle",u)},[()=>br(t.state==="active"),()=>br(t.state==="hover"),()=>br(e())]),I(i,s),Yn()}var FZ=ot('<div class="tbl-menu"><!></div>');function KZ(i,t){Wn(t,!0);let e,n=ct(void 0);Uc(()=>{t.translate(e).then(l=>q(n,l,!0))});var r=FZ();let s;var o=Ue(r);Qr(o,()=>t.children),Oc(r,l=>e=l,()=>e),se(l=>s=dc(r,"",s,l),[()=>({visibility:E($(n))?void 0:"hidden",transform:E($(n))?`translate3d(${$(n).x}px, ${$(n).y}px, 0px)`:void 0})]),I(i,r),Yn()}var JZ=ot('<div class="tbl-menu-item" role="menuitem" tabindex="-1"><!></div>');function Ae(i,t){var e=JZ(),n=Ue(e);Qr(n,()=>t.children),Eo("click",e,function(...r){var s;(s=t.onclick)==null||s.apply(this,r)}),I(i,e)}MS(["click"]);function Re(i,t){switch(i.action){case"add":return t.menu.clickAdd(i.direction);case"align":return t.menu.clickAlign(i.alignment);case"clear":return t.menu.clickClear();case"duplicate":return t.menu.clickDuplicate();case"move":return t.menu.clickMove(i.direction);case"remove":return t.menu.clickRemove();case"sort":return t.menu.clickSort(i.direction)}}var tX=ei('<path d="M294.6 454.6L214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L89.3 454.6C76.8 442.1 76.8 421.8 89.3 409.3C101.8 396.8 122.1 396.8 134.6 409.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L249.4 409.3C261.9 396.8 282.2 396.8 294.7 409.3C307.2 421.8 307.2 442.1 294.7 454.6zM476.6 113.7C527.3 215 553.9 268.4 556.6 273.7C564.5 289.5 558.1 308.7 542.3 316.6C526.5 324.5 507.3 318.1 499.4 302.3L492.2 288L403.8 288L396.6 302.3C388.7 318.1 369.5 324.5 353.7 316.6C337.9 308.7 331.5 289.5 339.4 273.7C342.1 268.4 368.7 215 419.4 113.7C424.8 102.9 435.9 96 448 96C460.1 96 471.2 102.8 476.6 113.7zM448 199.6L427.8 240L468.2 240L448 199.6zM352 384C352 366.3 366.3 352 384 352L512 352C524.9 352 536.6 359.8 541.6 371.8C546.6 383.8 543.8 397.5 534.7 406.7L461.3 480L512 480C529.7 480 544 494.3 544 512C544 529.7 529.7 544 512 544L384 544C371.1 544 359.4 536.2 354.4 524.2C349.4 512.2 352.2 498.5 361.3 489.3L434.7 415.9L384 415.9C366.3 415.9 352 401.6 352 383.9z"></path>'),eX=ei('<path d="M294.6 454.6L214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L89.3 454.6C76.8 442.1 76.8 421.8 89.3 409.3C101.8 396.8 122.1 396.8 134.6 409.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L249.4 409.3C261.9 396.8 282.2 396.8 294.7 409.3C307.2 421.8 307.2 442.1 294.7 454.6zM352 128C352 110.3 366.3 96 384 96L512 96C524.9 96 536.6 103.8 541.6 115.8C546.6 127.8 543.8 141.5 534.7 150.7L461.3 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L384 288C371.1 288 359.4 280.2 354.4 268.2C349.4 256.2 352.2 242.5 361.3 233.3L434.8 160L384 160C366.3 160 352 145.7 352 128zM476.6 337.7L556.6 497.7C564.5 513.5 558.1 532.7 542.3 540.6C526.5 548.5 507.3 542.1 499.4 526.3L492.2 512L403.8 512L396.6 526.3C388.7 542.1 369.5 548.5 353.7 540.6C337.9 532.7 331.5 513.5 339.4 497.7L419.4 337.7C424.8 326.9 435.9 320 448 320C460.1 320 471.2 326.8 476.6 337.7zM448 423.6L427.8 464L468.2 464L448 423.6z"></path>'),iX=ei('<path d="M384 128C384 145.7 369.7 160 352 160L128 160C110.3 160 96 145.7 96 128C96 110.3 110.3 96 128 96L352 96C369.7 96 384 110.3 384 128zM384 384C384 401.7 369.7 416 352 416L128 416C110.3 416 96 401.7 96 384C96 366.3 110.3 352 128 352L352 352C369.7 352 384 366.3 384 384zM96 256C96 238.3 110.3 224 128 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L128 288C110.3 288 96 273.7 96 256zM544 512C544 529.7 529.7 544 512 544L128 544C110.3 544 96 529.7 96 512C96 494.3 110.3 480 128 480L512 480C529.7 480 544 494.3 544 512z"></path>'),nX=ei('<path d="M448 128C448 110.3 433.7 96 416 96L224 96C206.3 96 192 110.3 192 128C192 145.7 206.3 160 224 160L416 160C433.7 160 448 145.7 448 128zM544 256C544 238.3 529.7 224 512 224L128 224C110.3 224 96 238.3 96 256C96 273.7 110.3 288 128 288L512 288C529.7 288 544 273.7 544 256zM96 512C96 529.7 110.3 544 128 544L512 544C529.7 544 544 529.7 544 512C544 494.3 529.7 480 512 480L128 480C110.3 480 96 494.3 96 512zM448 384C448 366.3 433.7 352 416 352L224 352C206.3 352 192 366.3 192 384C192 401.7 206.3 416 224 416L416 416C433.7 416 448 401.7 448 384z"></path>'),rX=ei('<path d="M544 128C544 145.7 529.7 160 512 160L288 160C270.3 160 256 145.7 256 128C256 110.3 270.3 96 288 96L512 96C529.7 96 544 110.3 544 128zM544 384C544 401.7 529.7 416 512 416L288 416C270.3 416 256 401.7 256 384C256 366.3 270.3 352 288 352L512 352C529.7 352 544 366.3 544 384zM96 256C96 238.3 110.3 224 128 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L128 288C110.3 288 96 273.7 96 256zM544 512C544 529.7 529.7 544 512 544L128 544C110.3 544 96 529.7 96 512C96 494.3 110.3 480 128 480L512 480C529.7 480 544 494.3 544 512z"></path>'),sX=ei('<path d="M342.6 81.4C330.1 68.9 309.8 68.9 297.3 81.4L137.3 241.4C124.8 253.9 124.8 274.2 137.3 286.7C149.8 299.2 170.1 299.2 182.6 286.7L288 181.3L288 552C288 569.7 302.3 584 320 584C337.7 584 352 569.7 352 552L352 181.3L457.4 286.7C469.9 299.2 490.2 299.2 502.7 286.7C515.2 274.2 515.2 253.9 502.7 241.4L342.7 81.4z"></path>'),oX=ei('<path d="M566.6 342.6C579.1 330.1 579.1 309.8 566.6 297.3L406.6 137.3C394.1 124.8 373.8 124.8 361.3 137.3C348.8 149.8 348.8 170.1 361.3 182.6L466.7 288L96 288C78.3 288 64 302.3 64 320C64 337.7 78.3 352 96 352L466.7 352L361.3 457.4C348.8 469.9 348.8 490.2 361.3 502.7C373.8 515.2 394.1 515.2 406.6 502.7L566.6 342.7z"></path>'),lX=ei('<path d="M297.4 566.6C309.9 579.1 330.2 579.1 342.7 566.6L502.7 406.6C515.2 394.1 515.2 373.8 502.7 361.3C490.2 348.8 469.9 348.8 457.4 361.3L352 466.7L352 96C352 78.3 337.7 64 320 64C302.3 64 288 78.3 288 96L288 466.7L182.6 361.3C170.1 348.8 149.8 348.8 137.3 361.3C124.8 373.8 124.8 394.1 137.3 406.6L297.3 566.6z"></path>'),aX=ei('<path d="M73.4 297.4C60.9 309.9 60.9 330.2 73.4 342.7L233.4 502.7C245.9 515.2 266.2 515.2 278.7 502.7C291.2 490.2 291.2 469.9 278.7 457.4L173.3 352L544 352C561.7 352 576 337.7 576 320C576 302.3 561.7 288 544 288L173.3 288L278.7 182.6C291.2 170.1 291.2 149.8 278.7 137.3C266.2 124.8 245.9 124.8 233.4 137.3L73.4 297.3z"></path>'),cX=ei('<path d="M262.2 48C248.9 48 236.9 56.3 232.2 68.8L216 112L120 112C106.7 112 96 122.7 96 136C96 149.3 106.7 160 120 160L520 160C533.3 160 544 149.3 544 136C544 122.7 533.3 112 520 112L424 112L407.8 68.8C403.1 56.3 391.2 48 377.8 48L262.2 48zM128 208L128 512C128 547.3 156.7 576 192 576L448 576C483.3 576 512 547.3 512 512L512 208L464 208L464 512C464 520.8 456.8 528 448 528L192 528C183.2 528 176 520.8 176 512L176 208L128 208zM288 280C288 266.7 277.3 256 264 256C250.7 256 240 266.7 240 280L240 456C240 469.3 250.7 480 264 480C277.3 480 288 469.3 288 456L288 280zM400 280C400 266.7 389.3 256 376 256C362.7 256 352 266.7 352 280L352 456C352 469.3 362.7 480 376 480C389.3 480 400 469.3 400 456L400 280z"></path>'),hX=ot('<div class="tbl-menu-item-icon"><svg xmlns="http://www.w3.org/2000/svg" height="14" width="14" viewBox="0 0 640 640" fill="currentColor"><!></svg></div>');function Ze(i,t){var e=hX(),n=Ue(e),r=Ue(n);{var s=b=>{var S=tX();I(b,S)},o=b=>{var S=eX();I(b,S)},l=b=>{},a=b=>{var S=iX();I(b,S)},c=b=>{var S=nX();I(b,S)},h=b=>{var S=rX();I(b,S)},u=b=>{var S=sX();I(b,S)},f=b=>{var S=oX();I(b,S)},d=b=>{var S=lX();I(b,S)},O=b=>{var S=aX();I(b,S)},p=b=>{},m=b=>{},g=b=>{var S=cX();I(b,S)};Ft(r,b=>{t.name==="sort-ascending"?b(s):t.name==="sort-descending"?b(o,1):t.name==="align-none"?b(l,2):t.name==="align-left"?b(a,3):t.name==="align-center"?b(c,4):t.name==="align-right"?b(h,5):t.name==="move-up"?b(u,6):t.name==="move-right"?b(f,7):t.name==="move-down"?b(d,8):t.name==="move-left"?b(O,9):t.name==="duplicate"?b(p,10):t.name==="clear"?b(m,11):t.name==="remove"&&b(g,12)})}I(i,e)}var uX=ot('<div class="tbl-menu-item-text"><!></div>');function Xe(i,t){var e=uX(),n=Ue(e);Qr(n,()=>t.children),I(i,e)}var fX=ot('<div class="tbl-menu-separator"></div>');function fa(i){var t=fX();I(i,t)}var dX=ot('<div class="tbl-select-all-overlay" aria-hidden="true"></div>');function OX(i){var t=dX();I(i,t)}const pX=new Set([bt.c,bt.v,bt.x]);function mX(i,t){return pX.has(i.key)&&i[tR(t)]}const gX=[bt.backspace,bt.delete],bX=new Set(gX);function wX({key:i}){return bX.has(i)?i:void 0}function SX(i){return/^F\d+$/.test(i)}const vX=new Set([bt.alt,bt.escape,bt.enter,bt.shift]);function xX({metaKey:i,ctrlKey:t,key:e}){return!t&&!i&&!vX.has(e)&&!SX(e)}function yX(i,t){t.selection.isCell()||lv({tableState:t,event:i})}function kX(i,t){t.selection.isCell()||av({tableState:t,event:i})}function QX(i,t){t.selection.isCell()||Id({tableState:t,event:i})}function $X(i,t){if(E(i.target)&&E(hv(i.target))){i.preventDefault();return}if(!t.interactive||t.selection.isCell())return;const e=dv(i);if(E(e)){th.navigate({tableState:t,key:e,event:i,position:{left:!0,top:!0,right:!0,bottom:!0}});return}const n=wX(i);if(E(n)){ov({tableState:t,event:i});return}if(t.activeTable&&E(t.activeCell)&&xX(i)){t.activeTable=!1,t.anchorCell=t.activeCell;const r=t.table.cellAt(t.activeCell).length;t.selectionValue={cell:t.activeCell,section:{head:r,anchor:r}},t.outlinedSection=rt.ofCell(t.activeCell);return}mX(i,t.window)||ck(t.rootEditor,i,"editor")&&i.preventDefault()}function Vd(i){return i.buttons===1}function pv(i,t){return t.setPointerCapture(i.pointerId),()=>t.releasePointerCapture(i.pointerId)}class eh{constructor({offset:t,maxScroll:e,boundaryElement:n,scrollElement:r}){P(this,"offset");P(this,"maxScroll");P(this,"boundaryElement");P(this,"scrollElement");P(this,"scroll");P(this,"handle");P(this,"xAmount");P(this,"yAmount");const s=this.scrollInternal.bind(this);this.scroll=()=>{this.handle=requestAnimationFrame(s)},this.xAmount=0,this.yAmount=0,this.offset=t??0,this.maxScroll=e,this.boundaryElement=n,this.scrollElement=r}updatePosition(t,e){const n=this.boundaryElement.x.getBoundingClientRect();t<n.left+this.offset?this.xAmount=-ce(this.offset+(n.left-t),{max:this.maxScroll}):t>n.right-this.offset?this.xAmount=ce(this.offset-(n.right-t),{max:this.maxScroll}):this.xAmount=0;const r=this.boundaryElement.y.getBoundingClientRect();e<r.top+this.offset?this.yAmount=-ce(this.offset+(r.top-e),{max:this.maxScroll}):e>r.bottom-this.offset?this.yAmount=ce(this.offset-(r.bottom-e),{max:this.maxScroll}):this.yAmount=0,W(this.handle)&&(this.xAmount!==0||this.yAmount!==0)&&this.scroll()}destroy(){E(this.handle)&&cancelAnimationFrame(this.handle)}scrollInternal(){if(this.xAmount===0&&this.yAmount===0){this.scroll();return}this.scrollElement.x.scrollBy({left:this.xAmount}),this.scrollElement.y.scrollBy({top:this.yAmount}),this.scroll()}static of(t){return new eh(t)}}class wc{constructor({start:t,size:e}){P(this,"start");P(this,"size");this.start=t,this.size=e}get mid(){return this.start+this.size/2}get end(){return this.start+this.size}static of(t){return new wc(t)}}var Sc;(i=>{function t(e,n){return Bd.of(e,n)}i.of=t})(Sc||(Sc={}));class Bd{constructor(t,e){P(this,"rows");P(this,"cols");P(this,"firstRowIndex",0);P(this,"firstColIndex",0);const n=[...t.querySelectorAll("tr:first-child > th")],r=[...t.querySelectorAll("tr > th:first-child,tr > td:first-child")];this.rows=r.map((s,o)=>{const{top:l,height:a}=ag(s,e),c=0;return wc.of({start:l+c,size:a-c})}),this.cols=n.map((s,o)=>{const{left:l,width:a}=ag(s,e),c=o===0?1:0;return wc.of({start:l+c,size:a-c})})}rowsOrCols(t){return t==="row"?this.rows:this.cols}rowAt(t){return this.rows[t]}colAt(t){return this.cols[t]}rowOrColAt(t,e){return t==="row"?this.rowAt(e):this.colAt(e)}get firstRow(){return this.rows[this.firstRowIndex]}get firstCol(){return this.cols[this.firstColIndex]}firstRowOrCol(t){return t==="row"?this.firstRow:this.firstCol}get lastRow(){return this.rows[this.lastRowIndex]}get lastCol(){return this.cols[this.lastColIndex]}lastRowOrCol(t){return t==="row"?this.lastRow:this.lastCol}firstRowOrColIndex(t){return 0}get lastRowIndex(){return this.rowCount-1}get lastColIndex(){return this.colCount-1}lastRowOrColIndex(t){return t==="row"?this.lastRowIndex:this.lastColIndex}get rowCount(){return this.rows.length}get colCount(){return this.cols.length}get minRowSize(){return hc(...this.rows.map(t=>t.size))}get minColSize(){return hc(...this.cols.map(t=>t.size))}moveRowOrColAt(t,{fromIndex:e,toIndex:n}){if(e===n)return;const r=this.rowsOrCols(t),s=r[e];if(e<n){for(const o of Cn({start:e,endExclusive:n}))r[o]=r[o+1],r[o].start-=s.size;s.start=r[n].start+r[n].size}else{for(const o of Cn({start:e,endExclusive:n}))r[o]=r[o-1],r[o].start+=s.size;s.start=r[n].start-s.size}r[n]=s}lastCellBeforePosition(t){const e=this.rows.map(r=>r.start).findLastIndex(r=>r<t.y),n=this.cols.map(r=>r.start).findLastIndex(r=>r<t.x);return{row:e===-1?0:e,col:n===-1?0:n}}static of(t,e){return new Bd(t,e)}}function ag(i,t){const{top:e,left:n,width:r,height:s}=i.getBoundingClientRect();return{top:e+t.y,left:n+t.x,width:r,height:s}}class pl{constructor({tableState:t,cellLocation:e}){P(this,"tableState");P(this,"tableMeasurement");P(this,"autoScroller");P(this,"shouldAutoScroll");P(this,"removeEventListeners");P(this,"currentCell");this.tableState=t,this.currentCell=e,this.autoScroller=eh.of({offset:10,maxScroll:32,boundaryElement:{x:t.scrollElement,y:t.rootScrollElement},scrollElement:{x:t.scrollElement,y:t.rootScrollElement}}),this.shouldAutoScroll=M5({delayMillis:500}),this.tableMeasurement=Sc.of(t.tableElement,{x:t.scrollOffsetX,y:t.scrollOffsetY})}start(){this.tableState.activeCell=this.currentCell,this.tableState.anchorCell=this.currentCell,this.tableState.outlinedSection=rt.ofCell(this.currentCell),this.tableState.outline={outlined:!1},this.removeEventListeners=$r(Mt(this.tableState.window,"pointermove",t=>this.drag(t)),Mt(this.tableState.window,"pointerup",()=>this.end()),Mt(this.tableState.window,"pointerleave",()=>this.end()))}resizeAndContinue(t){t.preventDefault(),W(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.currentCell),this.expandOrContract(this.currentCell),this.tableState.outline={outlined:!0},this.removeEventListeners=$r(Mt(this.tableState.window,"pointermove",e=>this.drag(e)),Mt(this.tableState.window,"pointerup",()=>this.end()),Mt(this.tableState.window,"pointerleave",()=>this.end()))}drag(t){if(!Vd(t)){this.end();return}t.preventDefault(),this.shouldAutoScroll()&&this.autoScroller.updatePosition(t.clientX,t.clientY);const e=this.tableMeasurement.lastCellBeforePosition({x:t.clientX+this.tableState.scrollOffsetX,y:t.clientY+this.tableState.scrollOffsetY});Cr(e,this.currentCell)||(this.currentCell=e,this.tableState.outline={outlined:!0},this.expandOrContract(e))}end(){var t;(t=this.removeEventListeners)==null||t.call(this),this.autoScroller.destroy(),this.tableState.outline=void 0}expandOrContract(t){this.tableState.focusTable();const[e,n]=t.row<=this.tableState.anchorCell.row?[t.row,this.tableState.anchorCell.row]:[this.tableState.anchorCell.row,t.row],[r,s]=t.col<=this.tableState.anchorCell.col?[t.col,this.tableState.anchorCell.col]:[this.tableState.anchorCell.col,t.col];this.tableState.outlinedSection=rt.of({row:{start:e,endExclusive:n+1},col:{start:r,endExclusive:s+1}}),this.tableState.activeCell=t}static startOutline(t){new pl(t).start()}static resizeAndContinueOutline(t){new pl(t).resizeAndContinue(t.event)}}function CX(i,t){Wc(t.window)&&(t.hoveredCell=i)}function PX(i){Wc(i.window)&&(i.hoveredCell=void 0)}function TX(i,t,e){if(!(!e.interactive||!Vd(i)))if(i.shiftKey){if(e.selection.isCell()&&Cr(t,e.selection.cell))return;pl.resizeAndContinueOutline({event:i,tableState:e,cellLocation:t})}else pl.startOutline({event:i,tableState:e,cellLocation:t})}const AX=new Intl.Collator(navigator.language,{numeric:!0,sensitivity:"base"});function cg(i,t){return AX.compare(i,t)}function RX({metaKey:i,shiftKey:t,altKey:e,ctrlKey:n,key:r}){return r===bt.escape&&!t&&!e&&!i&&!n}class Wd{constructor({tableState:t,handle:e,point:n}){P(this,"tableState");P(this,"handle");P(this,"point");P(this,"removeEventListeners");this.tableState=t,this.handle=e,this.point=n}get rowOrCol(){return this.handle.location}get index(){return this.handle.index}open(){const t=this.tableState.document.body;this.removeEventListeners=$r(Mt(t,"pointerdown",o=>{o.preventDefault(),(W(o.target)||!VS(this.tableState.menuRootElement,o.target))&&this.close()}),Mt(t,"wheel",o=>o.preventDefault(),{passive:!1}),Mt(t,"keydown",o=>{o.preventDefault(),RX(o)&&this.close()})),this.tableState.focusTable(),this.tableState.activeHandle={state:"active",handle:this.handle},this.tableState.outlinedSection=rt.of(this.rowOrCol==="row"?{row:{start:this.index,endExclusive:this.index+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:this.index,endExclusive:this.index+1}});const e=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=e,this.tableState.anchorCell=e;const n=this.index!==this.tableState.table.firstRowOrColIndex(this.rowOrCol),r=this.index!==this.tableState.table.lastRowOrColIndex(this.rowOrCol);let s=!1;n?s=r?!0:"backward":r&&(s="forward"),this.tableState.menu={type:this.rowOrCol,capabilities:{addable:!0,alignable:this.rowOrCol==="col",clearable:!0,duplicatable:!0,moveable:s,removable:!this.tableState.table.hasSingleRowOrCol(this.rowOrCol),sortable:this.rowOrCol==="col"},clickAdd:o=>this.clickAdd(o),clickAlign:o=>this.clickAlign(o),clickClear:()=>this.clickClear(),clickDuplicate:()=>this.clickDuplicate(),clickMove:o=>this.clickMove(o),clickRemove:()=>this.clickRemove(),clickSort:o=>this.clickSort(o),computeTranslation:o=>this.computeTranslation(o)}}close(){var t;(t=this.removeEventListeners)==null||t.call(this),this.tableState.menu=void 0,this.tableState.activeHandle=void 0}async computeTranslation(t){const e=await NT({getBoundingClientRect:()=>({x:this.point.x,y:this.point.y,top:this.point.y,right:this.point.x,bottom:this.point.y,left:this.point.x,width:0,height:0})},t,{middleware:[YT({allowedPlacements:this.rowOrCol==="row"?["right-start","right-end"]:["right-start","right"]}),qT({crossAxis:!0})]}),n=go(t);return{x:bc(e.x,n),y:bc(e.y,n)}}clickAdd(t){var e;if(this.tableState.table.addEmptyRowsOrColsAt(this.rowOrCol,{index:t==="before"?this.index:this.index+1,count:1}),t==="after"){this.tableState.outlinedSection=(e=this.tableState.outlinedSection)==null?void 0:e.shift(this.rowOrCol,"forward");const n=qh(this.rowOrCol,this.tableState.activeCell,"forward");this.tableState.activeCell=n,this.tableState.anchorCell=n}this.close()}clickAlign(t){this.tableState.table.setAlignmentAt(this.index,t),this.close()}clickClear(){this.tableState.table.clearRowOrCol(this.rowOrCol,this.index),this.close()}clickDuplicate(){this.tableState.table.duplicateRowOrColAt(this.rowOrCol,this.index),this.close()}clickMove(t){var n;this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:t==="backward"?this.index-1:this.index+1}),this.tableState.outlinedSection=(n=this.tableState.outlinedSection)==null?void 0:n.shift(this.rowOrCol,t);const e=qh(this.rowOrCol,this.tableState.activeCell,t);this.tableState.activeCell=e,this.tableState.anchorCell=e,this.close()}clickRemove(){var t;if(this.tableState.table.removeRowsOrColsAt(this.rowOrCol,{index:this.index,count:1}),!this.tableState.table.hasRowOrColAt(this.rowOrCol,this.index)){this.tableState.outlinedSection=(t=this.tableState.outlinedSection)==null?void 0:t.shift(this.rowOrCol,"backward");const e=qh(this.rowOrCol,this.tableState.activeCell,"backward");this.tableState.activeCell=e,this.tableState.anchorCell=e}this.close()}clickSort(t){this.tableState.table.sortByColAt(this.index,t==="ascending"?(e,n)=>cg(e.toString(),n.toString()):(e,n)=>cg(n.toString(),e.toString())),this.close()}static showMenu(t){new Wd(t).open()}}class Yd{constructor({rowOrCol:t,index:e,position:n,subject:r,tableElement:s,scrollOffsetX:o,scrollOffsetY:l}){P(this,"coordinate");P(this,"initialIndex");P(this,"size");P(this,"initialPosition");P(this,"minBound");P(this,"maxBound");P(this,"scrollOffsetX");P(this,"scrollOffsetY");P(this,"subject");P(this,"rowOrCol");P(this,"tableMeasurement");P(this,"currentIndex");P(this,"currentPosition");P(this,"dragged");this.scrollOffsetX=o,this.scrollOffsetY=l;const a=Sc.of(s,{x:this.scrollOffsetX(),y:this.scrollOffsetY()});this.rowOrCol=t,this.coordinate=t==="row"?"y":"x",this.initialIndex=e,this.initialPosition=n[this.coordinate],this.minBound=a.firstRowOrCol(this.rowOrCol).start-a.rowOrColAt(this.rowOrCol,e).start,this.maxBound=a.lastRowOrCol(this.rowOrCol).end-a.rowOrColAt(this.rowOrCol,e).end,this.size=a.rowOrColAt(this.rowOrCol,e).size,this.subject=r,this.dragged=!1,this.tableMeasurement=a,this.currentIndex=e,this.currentPosition=n[this.coordinate]}start(){return{cellMovement:t=>this.cellMovement(t)}}drag(t){this.currentPosition=t[this.coordinate];const{currentIndex:e,move:n}=this.calculateDrag();return this.currentIndex=e,this.initialIndex!==this.currentIndex&&(this.dragged=!0),E(n)&&this.tableMeasurement.moveRowOrColAt(this.rowOrCol,n),{cellMovement:r=>this.cellMovement(r)}}end(){return this.initialIndex===this.currentIndex?{moved:!1,dragged:this.dragged}:{moved:!0,toIndex:this.currentIndex}}cellMovement(t){return{border:this.cellBorder(t),state:this.cellState(t),translate:this.cellTranslate(t)}}cellBorder(t){const e=this.isRowOrColExposed(t[this.rowOrCol]),n=this.subject.containsCell(t);return this.rowOrCol==="row"?{top:e,right:!0,bottom:!n||t.row===this.tableMeasurement.lastRowIndex,left:this.tableMeasurement.firstColIndex===t.col}:{top:this.tableMeasurement.firstRowIndex===t.row,right:!n||t.col===this.tableMeasurement.lastColIndex,bottom:!0,left:e}}cellState(t){return this.subject.containsCell(t)?"moving":"shiftable"}cellTranslate(t){const e=this.rowOrColTranslate(t[this.rowOrCol]);return this.rowOrCol==="row"?{x:0,y:e}:{x:e,y:0}}isRowOrColExposed(t){const e=this.reorderIndex(t),n=e===this.tableMeasurement.firstRowOrColIndex(this.rowOrCol),r=e===this.currentIndex+1;return n||r}get rowOrColShift(){if(this.currentIndex!==this.initialIndex)return this.currentIndex<this.initialIndex?{direction:"forwards",range:{start:this.currentIndex,endExclusive:this.initialIndex},indexDiff:1,positionDiff:this.size-1}:{direction:"backwards",range:{start:this.initialIndex+1,endExclusive:this.currentIndex+1},indexDiff:-1,positionDiff:1-this.size}}rowOrColTranslate(t){if(t===this.initialIndex)return ce(this.currentPosition-this.initialPosition,{min:this.minBound,max:this.maxBound});const e=this.rowOrColShift;return W(e)?0:Qn(t,e.range)?e.positionDiff:0}reorderIndex(t){const e=this.rowOrColShift;return W(e)?t:t===this.initialIndex?this.currentIndex:Qn(t,e.range)?t+e.indexDiff:t}calculateDrag(){const t=this.tableMeasurement.rowsOrCols(this.rowOrCol),e={name:"current",index:this.currentIndex,mid:t[this.currentIndex].mid},n=this.currentIndex!==this.tableMeasurement.firstRowOrColIndex(this.rowOrCol)?{name:"left",index:this.currentIndex-1,mid:t[this.currentIndex-1].start+t[this.currentIndex].size/2}:void 0,r=this.currentIndex!==this.tableMeasurement.lastRowOrColIndex(this.rowOrCol)?{name:"right",index:this.currentIndex+1,mid:t[this.currentIndex].start+t[this.currentIndex+1].size+t[this.currentIndex].size/2}:void 0,s=kA(QA([e,n,r]),(o,l)=>Uu(this.currentPosition-o.mid)-Uu(this.currentPosition-l.mid));return s.name==="current"?{currentIndex:this.currentIndex,move:void 0}:{currentIndex:s.index,move:{fromIndex:this.currentIndex,toIndex:s.index}}}static of(t){return new Yd(t)}}class qd{constructor({event:t,tableState:e,rowOrCol:n,index:r,onClick:s}){P(this,"tableState");P(this,"rowOrCol");P(this,"index");P(this,"onClick");P(this,"moveTracker");P(this,"subject");P(this,"autoScroller");P(this,"removeEventListeners");this.tableState=e,this.rowOrCol=n,this.index=r,this.subject=rt.of(n==="row"?{row:{start:r,endExclusive:r+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:r,endExclusive:r+1}}),this.onClick=s,this.autoScroller=eh.of({offset:16,maxScroll:32,boundaryElement:{x:e.scrollElement,y:e.rootScrollElement},scrollElement:{x:e.scrollElement,y:e.rootScrollElement}}),this.moveTracker=Yd.of({subject:this.subject,rowOrCol:n,index:r,position:{x:t.clientX+e.scrollOffsetX,y:t.clientY+e.scrollOffsetY},tableElement:e.tableElement,scrollOffsetX:()=>this.tableState.scrollOffsetX,scrollOffsetY:()=>this.tableState.scrollOffsetY})}start(t){t.preventDefault();const e=this.moveTracker.start();this.tableState.outlinedSection=this.subject,this.tableState.move=e,this.tableState.activeHandle={state:"active",handle:{type:"header",index:this.index,location:this.rowOrCol}};const n=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=n,this.tableState.anchorCell=n,this.tableState.focusTable();const r=Ed(t.target);this.removeEventListeners=$r(pv(t,r),Mt(r,"pointermove",s=>this.drag(s)),Mt(r,"pointerup",()=>this.end()))}drag(t){t.preventDefault(),this.autoScroller.updatePosition(t.clientX,t.clientY),this.tableState.move=this.moveTracker.drag({x:t.clientX+this.tableState.scrollOffsetX,y:t.clientY+this.tableState.scrollOffsetY})}end(){var e;(e=this.removeEventListeners)==null||e.call(this),this.autoScroller.destroy();const t=this.moveTracker.end();if(t.moved){this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:t.toIndex}),this.tableState.outlinedSection=rt.of(this.rowOrCol==="row"?{row:{start:t.toIndex,endExclusive:t.toIndex+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:t.toIndex,endExclusive:t.toIndex+1}});const n=this.rowOrCol==="row"?{row:t.toIndex,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:t.toIndex};this.tableState.activeCell=n,this.tableState.anchorCell=n}this.tableState.move=void 0,this.tableState.activeHandle=void 0,!t.moved&&!t.dragged&&this.onClick()}static startMove(t){new qd(t).start(t.event)}}function ZX(i){return i==="row"?"y":"x"}class Nd{constructor({tableState:t,handle:e,position:n,cellSizePixels:r,dragThresholdPixels:s}){P(this,"tableState");P(this,"type");P(this,"initialHandle");P(this,"initialRowOrColCount");P(this,"initialPosition");P(this,"initialOutlinedSection");P(this,"initialActiveCell");P(this,"initialAnchorCell");P(this,"cellSizePixels");P(this,"dragThresholdPixels");P(this,"dragged");this.tableState=t,this.type=this.handleToType(e),this.initialHandle=e,this.initialPosition=n,this.initialRowOrColCount={row:t.table.rowCount,col:t.table.colCount},this.initialActiveCell=t.activeCell,this.initialAnchorCell=t.anchorCell,this.initialOutlinedSection=t.outlinedSection,this.cellSizePixels=r,this.dragThresholdPixels=s,this.dragged=!1}start(){return{activeHandle:{state:"active",handle:this.initialHandle}}}drag(t){return this.dragged=!0,this.calculateDrag(t)}end(){return this.dragged?{activeHandle:void 0}:this.calculateClick()}calculateClick(){if(this.type!=="table")return this.calculateClickRowOrCol(this.type);if(this.initialHandle.location==="right")return this.calculateClickRowOrCol("col");if(this.initialHandle.location==="bottom")return this.calculateClickRowOrCol("row");const t=this.calculateClickRowOrCol("row"),e=this.calculateClickRowOrCol("col");return{operation:{row:t.operation.row,col:e.operation.col},activeHandle:t.activeHandle,activeCell:E(t.activeCell)&&E(e.activeCell)?{row:t.activeCell.row,col:e.activeCell.col}:void 0,anchorCell:E(t.anchorCell)&&E(e.anchorCell)?{row:t.anchorCell.row,col:e.anchorCell.col}:void 0,outlinedSection:E(t.outlinedSection)&&E(e.outlinedSection)?rt.of({row:t.outlinedSection.row,col:e.outlinedSection.col}):void 0}}calculateClickRowOrCol(t){const e=this.type==="table"?this.tableState.table.lastRowOrColIndex(t)+1:this.initialHandle.index;return{operation:{[t]:{action:"add",index:e,count:1}},activeHandle:this.type==="table"?void 0:{state:"hover",handle:{type:"border",location:this.handleLocationAt(e),index:e}},...this.calculateCellMovement(t,1)}}calculateDrag(t){if(this.type!=="table")return this.calculateDragRowOrCol(this.type,t);if(this.initialHandle.location==="right")return this.calculateDragRowOrCol("col",t);if(this.initialHandle.location==="bottom")return this.calculateDragRowOrCol("row",t);const e=this.calculateDragRowOrCol("row",t),n=this.calculateDragRowOrCol("col",t);if(W(e)&&W(n))return;const r=e??this.calculateCellMovement("row",this.rowOrColDiff("row")),s=n??this.calculateCellMovement("col",this.rowOrColDiff("col"));return{operation:{row:e==null?void 0:e.operation.row,col:n==null?void 0:n.operation.col},activeHandle:(e==null?void 0:e.activeHandle)??(n==null?void 0:n.activeHandle),activeCell:E(r.activeCell)&&E(s.activeCell)?{row:r.activeCell.row,col:s.activeCell.col}:void 0,anchorCell:E(r.anchorCell)&&E(s.anchorCell)?{row:r.anchorCell.row,col:s.anchorCell.col}:void 0,outlinedSection:E(r.outlinedSection)&&E(s.outlinedSection)?rt.of({row:r.outlinedSection.row,col:s.outlinedSection.col}):void 0}}calculateDragRowOrCol(t,e){const n=ZX(t),r=e.position[n]-this.initialPosition[n],s=AA(r/this.cellSizePixels[t]),o=r%this.cellSizePixels[t]>=this.dragThresholdPixels[t]?1:0,l=this.tableState.table.rowOrColCount(t)-this.initialRowOrColCount[t],a=s+o-l,c=this.type==="table"?this.tableState.table.lastRowOrColIndex(t)+1:this.initialHandle.index+l;if(a!==0)return a>0?this.calculateDragRowOrColMore({rowOrCol:t,start:c,length:a}):this.calculateDragRowOrColLess({rowOrCol:t,start:c,length:hc(-a,c,this.tableState.table.lastRowOrColIndex(t))})}calculateDragRowOrColLess({rowOrCol:t,start:e,length:n}){let r=0;for(const o of Cn({start:e-1,endExclusive:e-n-1})){if(!this.tableState.table.hasEmptyRowOrColAt(t,o))break;r++}if(r===0)return;const s=e-(r-1)-1;return{operation:{[t]:{action:"remove",index:e-r,count:r}},activeHandle:this.type==="table"?{state:"active",handle:this.initialHandle}:{state:"active",handle:{type:"border",location:this.handleLocationAt(s),index:s}},...this.calculateCellMovement(t,this.rowOrColDiff(t)-r)}}calculateDragRowOrColMore({rowOrCol:t,start:e,length:n}){return{operation:{[t]:{action:"add",index:e,count:n}},activeHandle:{state:"active",handle:this.type==="table"?this.initialHandle:{type:"border",location:this.handleLocationAt(e+n),index:e+n}},...this.calculateCellMovement(t,this.rowOrColDiff(t)+n)}}calculateCellMovement(t,e){var r,s;const n=this.type==="table"?this.initialRowOrColCount[t]:this.initialHandle.index;if(e>=0)return{outlinedSection:(r=this.initialOutlinedSection)==null?void 0:r.addForwardsByRowOrCol(t,{start:n,count:e}),activeCell:E(this.initialActiveCell)?Km(t,this.initialActiveCell,{start:n,count:e}):void 0,anchorCell:E(this.initialAnchorCell)?Km(t,this.initialAnchorCell,{start:n,count:e}):void 0};{const o=-e,l=(s=this.initialOutlinedSection)==null?void 0:s.subtractBackwardsByRowOrCol(t,{start:n,count:o,min:this.tableState.table.firstRowOrColIndex(t)}),a=E(l)?{min:l.startRowOrCol(t),max:l.endRowOrCol(t)}:void 0,c=E(this.initialActiveCell)?Jm(t,this.initialActiveCell,{start:n,count:o,boundary:a}):void 0,h=E(this.initialAnchorCell)?Jm(t,this.initialAnchorCell,{start:n,count:o,boundary:a}):void 0;return{outlinedSection:l,activeCell:c,anchorCell:h}}}rowOrColDiff(t){return this.tableState.table.rowOrColCount(t)-this.initialRowOrColCount[t]}handleLocationAt(t){if(this.type!=="table")return this.type==="row"&&t===this.tableState.table.firstRowIndex?"top":this.type==="col"&&t===this.tableState.table.firstColIndex?"left":this.type}handleToType(t){return t.type==="table"?"table":t.location==="top"?"row":t.location==="left"?"col":t.location}static of(t){return new Nd(t)}}function XX(i){const t=mc(i.tableElement,i.table.firstCellLocation),e=CZ(t),{minWidth:n}=getComputedStyle(t),{lineHeight:r,paddingTop:s,paddingBottom:o}=getComputedStyle(e),l=parseFloat(n)+1,a=parseFloat(r)+parseFloat(s)+parseFloat(o)+1;return{width:l,height:a}}class Gd{constructor({event:t,tableState:e,handle:n}){P(this,"tableState");P(this,"resizeTracker");P(this,"removeEventListeners");this.tableState=e;const{width:r,height:s}=XX(e);this.resizeTracker=Nd.of({tableState:this.tableState,handle:n,position:{x:t.clientX,y:t.clientY},cellSizePixels:{row:s,col:r},dragThresholdPixels:{row:s/2,col:r/2}})}start(t){t.preventDefault();const e=this.resizeTracker.start();this.tableState.resize={},this.tableState.activeHandle=e.activeHandle,this.tableState.focusTable(),this.removeEventListeners=$r(pv(t,this.tableState.tableElement),Mt(this.tableState.tableElement,"pointermove",n=>this.drag(n)),Mt(this.tableState.tableElement,"pointerup",()=>this.end()))}drag(t){t.preventDefault();const e=this.resizeTracker.drag({position:{x:t.clientX,y:t.clientY}});E(e)&&(this.resizeTable(e.operation),this.tableState.activeHandle=e.activeHandle,this.tableState.activeCell=e.activeCell,this.tableState.anchorCell=e.anchorCell,this.tableState.outlinedSection=e.outlinedSection)}end(){var e;(e=this.removeEventListeners)==null||e.call(this);const t=this.resizeTracker.end();"operation"in t&&(this.resizeTable(t.operation),this.tableState.activeCell=t.activeCell,this.tableState.anchorCell=t.anchorCell,this.tableState.outlinedSection=t.outlinedSection),this.tableState.activeHandle=t.activeHandle,this.tableState.resize=void 0}resizeTable({row:t,col:e}){if(E(t)){const{action:n,index:r,count:s}=t;n==="add"?this.tableState.table.addEmptyRowsAt({row:r,count:s}):this.tableState.table.removeRowsAt({row:r,count:s})}if(E(e)){const{action:n,index:r,count:s}=e;n==="add"?this.tableState.table.addEmptyColsAt({col:r,count:s}):this.tableState.table.removeColsAt({col:r,count:s})}}static startResize(t){new Gd(t).start(t.event)}}function EX(i,t){t.interactive&&(t.activeHandle={state:"hover",handle:i})}function LX(i){i.interactive&&(i.activeHandle=void 0)}function MX(i,t,e){if(e.interactive){if(!Vd(i)){i.preventDefault();return}t.type==="table"||t.type==="border"?Gd.startResize({event:i,handle:t,tableState:e}):t.type==="header"&&qd.startMove({event:i,rowOrCol:t.location,index:t.index,tableState:e,onClick:()=>Wd.showMenu({handle:t,point:{x:i.clientX,y:i.clientY},tableState:e})})}}function zX(i,t){const e=i.target;if(W(e))return;const n=Dd(e);if(E(n)){EX(n,t);return}const r=_l(e);if(E(r)){CX(Kc(r),t);return}}function _X(i,t){const e=i.target;if(W(e))return;const n=Dd(e);if(E(n)){LX(t);return}const r=_l(e);if(E(r)){PX(t);return}}function IX(i,t){const e=i.target;if(W(e))return;const n=Dd(e);if(E(n)){MX(i,n,t);return}const r=_l(e);if(E(r)){TX(i,Kc(r),t);return}i.preventDefault()}function jX(i){i.preventDefault()}var DX=ot("<!> <!> <!>",1),VX=ot('<tr class="tbl-table-row"></tr>'),BX=ot('<tbody class="tbl-table-body"></tbody>'),WX=ot("<!> <!>",1),YX=ot("<!> <!>",1),qX=ot("<!> <!> <!>",1),NX=ot("<!> <!>",1),GX=ot("<!> <!>",1),UX=ot("<!> <!>",1),HX=ot("<!> <!>",1),FX=ot("<!> <!> <!> <!> <!>",1),KX=ot("<!> <!>",1),JX=ot("<!> <!>",1),tE=ot("<!> <!> <!>",1),eE=ot("<!> <!>",1),iE=ot("<!> <!>",1),nE=ot("<!> <!> <!>",1),rE=ot("<!> <!>",1),sE=ot("<!> <!>",1),oE=ot("<!> <!>",1),lE=ot("<!> <!> <!> <!> <!> <!> <!>",1),aE=ot('<div class="tbl-table-wrapper"><table class="tbl-table" role="grid" tabindex="-1"><thead class="tbl-table-head"><!></thead><!></table> <!> <!> <!> <!></div>');function cE(i,t){Wn(t,!0);const e=wf.of({table:()=>t.table,selection:()=>t.selection,scrollElement:()=>t.scrollElement,rootEditor:()=>t.rootEditor,menuRootElement:()=>t.menuRootElement,extensions:()=>t.extensions,markdownConfig:()=>t.markdownConfig,globalKeyBindings:()=>t.globalKeyBindings,selectionType:()=>t.selectionType,lineWrapping:()=>t.lineWrapping,onUndo:()=>t.onUndo,onRedo:()=>t.onRedo,onNavigate:()=>t.onNavigate,onDelete:()=>t.onDelete});Uc(()=>$r(Mt(e.document,"selectionchange",()=>PZ(e)),Mt(e.document.body,"pointerdown",()=>vZ(e),{capture:!0,passive:!0}),Mt(e.document.body,"pointerup",()=>xZ(e),{capture:!0,passive:!0}),Mt(e.document.body,"pointerleave",()=>yZ(e),{capture:!0,passive:!0}),Mt(e.document.body,"copy",x=>kZ(x,e)),Mt(e.document.body,"cut",x=>QZ(x,e)),Mt(e.document.body,"paste",x=>$Z(x,e))));var n=aE(),r=Ue(n);{const x=(y,k=N1)=>{var Q=VX();ca(Q,20,()=>e.table.colIndices,X=>X,(X,B)=>{const L=F(()=>({row:k(),col:B})),V=F(()=>({top:k()===e.table.firstRowIndex,left:B===e.table.firstColIndex})),_=F(()=>e.selection.isCell()&&Cr($(L),e.selection.cell));{let G=F(()=>{var H;return((H=e.outlinedSection)==null?void 0:H.containsOnEdge($(L)))??{top:!1,right:!1,bottom:!1,left:!1}}),U=F(()=>{var H;return(H=e.move)==null?void 0:H.cellMovement($(L))});zZ(X,{get location(){return $(L)},get alignment(){return e.table.alignments[B]},get selected(){return $(_)},get position(){return $(V)},get outline(){return $(G)},get movement(){return $(U)},get win(){return e.window},children:(H,Xt)=>{var _t=DX(),Yt=Et(_t);ca(Yt,16,()=>mZ($(L),$(V)),yt=>yt,(yt,Nt)=>{{let re=F(()=>e.cellHandleState($(L),Nt)),be=F(()=>E(e.resize));lg(yt,{get of(){return Nt},get state(){return $(re)},get toggle(){return $(be)}})}});var lt=et(Yt,2);NZ(lt,{get hidden(){return $(_)},children:(yt,Nt)=>{var re=Xd(),be=Et(re);y5(be,()=>fZ(e.table.cellAt($(L)),e.highlighter($(L)))),I(yt,re)},$$slots:{default:!0}});var Vt=et(lt,2);{var $e=yt=>{var Nt=()=>e.table.cellAt($(L)),re=pt=>e.table.setCellAt($(L),pt),be=()=>e.selection.cellSection,tt=pt=>{e.selectionValue={cell:$(L),section:pt}};{let pt=F(()=>e.highlighter($(L)));jZ(yt,{get text(){return Nt()},set text(mt){re(mt)},get selection(){return be()},set selection(mt){tt(mt)},get selectionType(){return e.selectionType},get lineWrapping(){return e.lineWrapping},get extensions(){return e.extensions},get markdownConfig(){return e.markdownConfig},get rootEditor(){return e.rootEditor},get globalKeyBindings(){return e.globalKeyBindings},get highlighter(){return $(pt)},onbeforeinput:mt=>VZ(mt,e),ondragstart:mt=>BZ(mt),onkeydown:(mt,At)=>WZ(mt,At,e),onpaste:mt=>YZ(mt,e)})}};Ft(Vt,yt=>{$(_)&&yt($e)})}I(H,_t)},$$slots:{default:!0}})}}),I(y,Q)};var s=Ue(r),o=Ue(s);x(o,()=>e.table.headerRowIndex);var l=et(s);{var a=y=>{var k=BX();ca(k,20,()=>e.table.dataRowIndices,Q=>Q,(Q,X)=>{x(Q,()=>X)}),I(y,k)},c=F(()=>e.table.hasDataRows());Ft(l,y=>{$(c)&&y(a)})}Oc(r,y=>e.tableElement=y,()=>e==null?void 0:e.tableElement)}var h=et(r,2);{var u=x=>{const y=F(()=>e.menu.type==="row"?"row":"column");RZ(x,{get to(){return e.menuRootElement},children:(k,Q)=>{KZ(k,{translate:X=>e.menu.computeTranslation(X),children:(X,B)=>{const L=F(()=>{const{addable:tt,alignable:pt,clearable:mt,duplicatable:At,moveable:Bt,removable:Wt,sortable:fe}=e.menu.capabilities;return{addable:tt,alignable:pt,clearable:mt,duplicatable:At,moveable:Bt,removable:Wt,sortable:fe}});var V=lE(),_=Et(V);{var G=tt=>{var pt=qX(),mt=Et(pt);Ae(mt,{onclick:()=>Re({action:"sort",direction:"ascending"},e),children:(Wt,fe)=>{var ut=WX(),gt=Et(ut);Ze(gt,{name:"sort-ascending"});var It=et(gt,2);Xe(It,{children:(kt,Ut)=>{var Rt=Te();se(()=>qi(Rt,`Sort by ${$(y)??""} (A-Z)`)),I(kt,Rt)}}),I(Wt,ut)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"sort",direction:"descending"},e),children:(Wt,fe)=>{var ut=YX(),gt=Et(ut);Ze(gt,{name:"sort-descending"});var It=et(gt,2);Xe(It,{children:(kt,Ut)=>{var Rt=Te();se(()=>qi(Rt,`Sort by ${$(y)??""} (Z-A)`)),I(kt,Rt)}}),I(Wt,ut)}});var Bt=et(At,2);fa(Bt),I(tt,pt)};Ft(_,tt=>{$(L).sortable&&tt(G)})}var U=et(_,2);{var H=tt=>{var pt=FX(),mt=Et(pt);Ae(mt,{onclick:()=>Re({action:"align",alignment:"none"},e),children:(ut,gt)=>{var It=NX(),kt=Et(It);Ze(kt,{name:"align-none"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,ii)=>{var Wi=Te("Align none");I(Rt,Wi)}}),I(ut,It)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"align",alignment:"left"},e),children:(ut,gt)=>{var It=GX(),kt=Et(It);Ze(kt,{name:"align-left"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,ii)=>{var Wi=Te("Align left");I(Rt,Wi)}}),I(ut,It)}});var Bt=et(At,2);Ae(Bt,{onclick:()=>Re({action:"align",alignment:"center"},e),children:(ut,gt)=>{var It=UX(),kt=Et(It);Ze(kt,{name:"align-center"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,ii)=>{var Wi=Te("Align center");I(Rt,Wi)}}),I(ut,It)}});var Wt=et(Bt,2);Ae(Wt,{onclick:()=>Re({action:"align",alignment:"right"},e),children:(ut,gt)=>{var It=HX(),kt=Et(It);Ze(kt,{name:"align-right"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,ii)=>{var Wi=Te("Align right");I(Rt,Wi)}}),I(ut,It)}});var fe=et(Wt,2);fa(fe),I(tt,pt)};Ft(U,tt=>{$(L).alignable&&tt(H)})}var Xt=et(U,2);{var _t=tt=>{var pt=tE(),mt=Et(pt);Ae(mt,{onclick:()=>Re({action:"add",direction:"before"},e),children:(Wt,fe)=>{var ut=KX(),gt=Et(ut);Ze(gt,{name:"add-before"});var It=et(gt,2);Xe(It,{children:(kt,Ut)=>{var Rt=Te();se(()=>qi(Rt,`Add ${$(y)??""} ${$(y)==="row"?"above":"before"}`)),I(kt,Rt)}}),I(Wt,ut)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"add",direction:"after"},e),children:(Wt,fe)=>{var ut=JX(),gt=Et(ut);Ze(gt,{name:"add-after"});var It=et(gt,2);Xe(It,{children:(kt,Ut)=>{var Rt=Te();se(()=>qi(Rt,`Add ${$(y)??""} ${$(y)==="row"?"below":"after"}`)),I(kt,Rt)}}),I(Wt,ut)}});var Bt=et(At,2);fa(Bt),I(tt,pt)};Ft(Xt,tt=>{$(L).addable&&tt(_t)})}var Yt=et(Xt,2);{var lt=tt=>{var pt=nE(),mt=Et(pt);{var At=ut=>{Ae(ut,{onclick:()=>Re({action:"move",direction:"backward"},e),children:(gt,It)=>{var kt=eE(),Ut=Et(kt);{let ii=F(()=>`move-${$(y)==="row"?"up":"left"}`);Ze(Ut,{get name(){return $(ii)}})}var Rt=et(Ut,2);Xe(Rt,{children:(ii,Wi)=>{var bo=Te();se(()=>qi(bo,`Move ${$(y)??""} ${$(y)==="row"?"up":"left"}`)),I(ii,bo)}}),I(gt,kt)}})};Ft(mt,ut=>{($(L).moveable==="backward"||$(L).moveable===!0)&&ut(At)})}var Bt=et(mt,2);{var Wt=ut=>{Ae(ut,{onclick:()=>Re({action:"move",direction:"forward"},e),children:(gt,It)=>{var kt=iE(),Ut=Et(kt);{let ii=F(()=>`move-${$(y)==="row"?"down":"right"}`);Ze(Ut,{get name(){return $(ii)}})}var Rt=et(Ut,2);Xe(Rt,{children:(ii,Wi)=>{var bo=Te();se(()=>qi(bo,`Move ${$(y)??""} ${$(y)==="row"?"down":"right"}`)),I(ii,bo)}}),I(gt,kt)}})};Ft(Bt,ut=>{($(L).moveable==="forward"||$(L).moveable===!0)&&ut(Wt)})}var fe=et(Bt,2);fa(fe),I(tt,pt)};Ft(Yt,tt=>{$(L).moveable!==!1&&tt(lt)})}var Vt=et(Yt,2);{var $e=tt=>{Ae(tt,{onclick:()=>Re({action:"duplicate"},e),children:(pt,mt)=>{var At=rE(),Bt=Et(At);Ze(Bt,{name:"duplicate"});var Wt=et(Bt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>qi(gt,`Duplicate ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(Vt,tt=>{$(L).duplicatable&&tt($e)})}var yt=et(Vt,2);{var Nt=tt=>{Ae(tt,{onclick:()=>Re({action:"clear"},e),children:(pt,mt)=>{var At=sE(),Bt=Et(At);Ze(Bt,{name:"clear"});var Wt=et(Bt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>qi(gt,`Clear ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(yt,tt=>{$(L).clearable&&tt(Nt)})}var re=et(yt,2);{var be=tt=>{Ae(tt,{onclick:()=>Re({action:"remove"},e),children:(pt,mt)=>{var At=oE(),Bt=Et(At);Ze(Bt,{name:"remove"});var Wt=et(Bt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>qi(gt,`Delete ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(re,tt=>{$(L).removable&&tt(be)})}I(X,V)},$$slots:{default:!0}})},$$slots:{default:!0}})},f=F(()=>E(e.menu));Ft(h,x=>{$(f)&&x(u)})}var d=et(h,2);ca(d,16,()=>pZ,x=>x,(x,y)=>{{let k=F(()=>{var Q;return bf((Q=e.activeHandle)==null?void 0:Q.handle,y)?e.activeHandle.state:void 0});lg(x,{get of(){return y},get state(){return $(k)}})}});var O=et(d,2);{var p=x=>{XZ(x)},m=F(()=>!e.interactive&&W(e.outline));Ft(O,x=>{$(m)&&x(p)})}var g=et(O,2);{var b=x=>{OX(x)},S=F(()=>e.selection.isAll());Ft(g,x=>{$(S)&&x(b)})}Oc(n,x=>e.wrapperElement=x,()=>e==null?void 0:e.wrapperElement),se(x=>Qt(n,"data-select-all",x),[()=>br(e.selection.isAll())]),Eo("mouseover",n,x=>zX(x,e)),Eo("mouseout",n,x=>_X(x,e)),Eo("pointerdown",n,x=>IX(x,e)),la("dragover",n,x=>jX(x)),Eo("keydown",r,x=>$X(x,e)),la("copy",r,x=>yX(x,e)),la("cut",r,x=>kX(x,e)),la("paste",r,x=>QX(x,e)),I(i,n),Yn()}MS(["mouseover","mouseout","pointerdown","keydown"]);class Ud extends jn{constructor(e,n){super();P(this,"tableDescription");P(this,"widgetElement");P(this,"height");P(this,"destroyWidgetElement");this.tableDescription=e;const r=vE(n);if(E(r)){const{widgetElement:s,destroyWidgetElement:o}=this.create(r);this.widgetElement=s,this.destroyWidgetElement=o,this.height=X5(r,s)}else this.widgetElement=void 0,this.destroyWidgetElement=void 0,this.height=Ym}get estimatedHeight(){return this.height}coordsAt(e,n,r){const s=this.tableDescription.table.closestCellAtPosition(n),o=mc(e,s);if(W(o))return null;const l=o.getBoundingClientRect();return{top:l.top,right:l.right,bottom:l.bottom,left:l.left}}toDOM(e){if(E(this.widgetElement))return this.widgetElement;const{widgetElement:n,destroyWidgetElement:r}=this.create(e);return this.widgetElement=n,this.destroyWidgetElement=r,e.requestMeasure({read:()=>{this.height=n.getBoundingClientRect().height}}),n}destroy(e){var n;(n=this.destroyWidgetElement)==null||n.call(this),this.destroyWidgetElement=void 0,this.widgetElement=void 0,this.height=Ym}create(e){const n=fl(e.dom).createElement("div");n.className="tbl-table-widget",n.tabIndex=-1,n.addEventListener("pointerdown",O=>{(O==null?void 0:O.target)===n&&O.preventDefault()});const r=this.tableDescription,s=l5(()=>{Nc(()=>{const O=!r.table.text.eq(r.editorTableText),p=!Fc(r.selection.value,r.editorSelectionValue);if(!O&&!p)return;let m;if(r.selection.isCell()){const{from:b}=r.table.cellSpan(r.selection.cell);m={anchor:r.from+b+r.selection.cellSection.anchor,head:r.from+b+r.selection.cellSection.head}}else r.selection.isAll()?m={anchor:r.from,head:r.to}:r.selection.isHidden()&&(m={anchor:r.from+1,head:r.from+1});const g=O?{from:r.from,to:r.to,insert:r.table.text}:void 0;r.markSynchronized(),e.dispatch({annotations:Rn("table.edit"),changes:g,selection:m})})}),{extensions:o,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h}=bv(e.state),u=zS(cE,{target:n,props:{table:r.table,selection:r.selection,scrollElement:n,rootEditor:e,extensions:o,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h,menuRootElement:yk(e,iv).dom,onUndo:()=>Hf(e),onRedo:()=>Na(e),onNavigate:O=>{e.dispatch({annotations:Rn("table.navigate"),selection:{anchor:O==="before"?r.from-1:r.to+1}}),e.focus()},onDelete:()=>{e.dispatch({annotations:Rn("table.delete"),changes:{from:r.from,to:r.to},selection:e.state.selection}),e.focus()}}}),f=()=>{_S(u)},d=E5(n,({height:O})=>{this.height=O});return{widgetElement:n,destroyWidgetElement:$r(s,f,d)}}static of(e,n){return new Ud(e,n)}}function hE(i,t){return{widget:Ud.of(i,t),block:!0,inclusive:!0}}function uE(i,t){return J.replace(hE(i,t))}function fE(i,t){const e=new Ws;for(const n of i)e.add(n.from,n.to,uE(n,t));return e.finish()}function dE(i){return mv(i)}function OE(i,t){return mv(i,t)}function mv(i,t=[]){const e=[];gA(St(i),s=>{E1(s)&&e.push({from:i.doc.lineAt(s.from).from,to:i.doc.lineAt(s.to).to})});const n=[],r=[];for(const s of e){if(CA(t,s,B1)){n.push(s);continue}const o=pE(s,i);Bc(o)?n.push(s):r.push(...o)}return{spans:n,formatting:r,complete:Wk(i)}}function pE(i,t){return[...mE(i,t),...gE(i,t)]}function mE(i,{doc:t,lineBreak:e}){return bd({doc:t,lineBreak:e,span:i}).changes}function gE({from:i,to:t},{doc:e}){const n=e.slice(i,t),{text:r}=Hu(n);return n.eq(r)?[]:[{from:i,to:t,insert:r}]}const bE={create(i){return da(i)},update(i,t){if(N5(t))return da(t.state);if(!t.docChanged&&W(t.selection)&&i.complete)return i;const{tables:e,formatting:n,decorations:r}=i;if(!t.docChanged&&i.complete)return{tables:hg(e,t),formatting:n,decorations:r.map(t.changes),complete:!0};if(q5(t)||wE(t,e))return da(t.state);const s=hg(e,t).map(c=>c.span),{complete:o,spans:l,formatting:a}=OE(t.state,s);return bn(s,l,B1)?{complete:o,tables:e,formatting:a,decorations:r.map(t.changes)}:da(t.state)},provide(i){return z.decorations.from(i,t=>t.decorations)}},gv=bi.define(bE);function da(i){const{spans:t,formatting:e,complete:n}=dE(i),{doc:r,selection:s}=i,o=t.map(l=>mf.of({span:l,doc:r,selection:s}));return{complete:n,tables:o,formatting:e,decorations:fE(o,i)}}function wE(i,t){return!zd(i)&&t.some(e=>i.changes.touchesRange(e.from,e.to)!==!1)}function hg(i,t){return vA(i,e=>e.applyTransaction(t))}const SE={create(){return{view:void 0}},update(i){return i}},Hd=bi.define(SE);function bv(i){return i.facet(Fu)}function In(i){return i.field(gv)}function vE(i){return i.field(Hd).view}function xE(i){const{handlePosition:t,selectionType:e,lineWrapping:n}=bv(i);return{...Wc(window)?{"data-tbl-hoverable":""}:{},"data-tbl-theme-mode":i.facet(z.darkTheme)?"dark":"light","data-tbl-handle-position":t,"data-tbl-selection-type":e,"data-tbl-line-wrapping":n}}const yE=["undo","redo","select.undo","select.redo"];function kE(i){return yE.some(t=>i.isUserEvent(t))}function QE(i){return wv(i,"select.search")}function $E(i){return wv(i,"select")}function CE(i){return i.isUserEvent("delete.forward")}function PE(i){return i.isUserEvent("delete.backward")}function wv(i,t){return i.annotation(Pt.userEvent)===t}const TE=({state:i,view:t,transactions:e})=>{t.hasFocus||In(i).tables.some(n=>n.containsSelection())||e.some(n=>kE(n)||QE(n)&&!fv(t))&&t.focus()},Sv=Ct.define(),AE=new Map(NS.map(i=>[i,Sv.of(i)]));function vv(i){return AE.get(i)}const RE=(i,t)=>!t||!In(i).tables.some(e=>e.containsSelection())?null:vv("table.focus"),ZE=i=>{const{selection:t,startState:e,docChanged:n}=i;if(W(t)||n||!$E(i)||!oc(t)||!oc(e.selection))return i;const r=e.selection.main,s=t.main;for(const o of In(e).tables){const l=o.from===s.head,a=o.to===s.head,c=o.from===r.head+1&&o.to===s.head-1,h=o.from===s.head+1&&o.to===r.head-1;let u;if(l?u=o.table.firstCellSpan.from:c?u=o.table.firstCellSpan.to:(a||h)&&(u=o.table.lastCellSpan.to),E(u))return[i,{annotation:Rn("table.navigate"),selection:tA({pos:o.from+u})}]}return i},XE=i=>{const{selection:t,startState:e}=i;if(W(t)||!oc(t))return i;const n=e.selection.main;if(CE(i)){for(const r of In(e).tables)if(n.head===r.from-1){const s=r.table.firstCellSpan.from;return[{selection:{anchor:r.from+s,head:r.from+s}}]}return i}else if(PE(i)){for(const r of In(e).tables)if(n.head===r.to+1){const s=r.table.lastCellSpan.to;return[{selection:{anchor:r.from+s,head:r.from+s}}]}return i}else return i};function EE(i){return kQ(i)>0||QQ(i)>0}const LE=({state:i,docChanged:t,selectionSet:e,transactions:n,view:r})=>{if(!t&&!e&&EE(i)||n.some(a=>zd(a)))return;const{formatting:s}=In(i);if(Bc(s))return;const o=Lt.of(s,i.doc.length,i.lineBreak),l=i.selection.map(o);r.dispatch({annotations:Rn("table.format"),changes:o,selection:l})},ME=i=>{if(!i.docChanged||zd(i))return i;const t=i.changes,{tables:e}=In(i.startState),n=[];for(const o of e)if(t.touchesRange(o.from-1,o.from)!==!1||t.touchesRange(o.to,o.to+1)!==!1){const l={from:t.mapPos(o.from,1),to:t.mapPos(o.to)};if(l.from>=l.to)continue;n.push(bd({doc:i.newDoc,lineBreak:i.startState.lineBreak,span:l}).changes)}if(Bc(n))return i;const r=Lt.of(n,i.changes.newLength,i.startState.lineBreak),s=i.newSelection.map(r);return[i,{annotation:Rn("table.correct"),changes:r,selection:s,sequential:!0}]};function zE(i,{anchor:t,head:e,goalColumn:n,bidiLevel:r}={}){return C.range(t??i.anchor,e??i.head,n??i.goalColumn,r??i.bidiLevel??void 0)}const _E=i=>{const{selection:t,startState:e,docChanged:n}=i;if(W(t)||n||oc(t))return i;const r=t.ranges.map(s=>{if(s.empty)return s;const o=In(e).tables,l=ug(s.anchor,o),a=ug(s.head,o);return E(l)||E(a)?zE(s,{anchor:l,head:a}):s});return bn(t.ranges,r,(s,o)=>s===o)?i:[i,{annotations:Rn("table.select"),selection:C.create(r,t.mainIndex)}]};function ug(i,t){for(const e of t){const n=e.from,r=e.to,s=e.from+1,o=e.to-1;if(i===n||i===s)return n-1;if(i===r||i===o)return r+1}}const IE={"& .cm-tooltip.cm-tooltip-autocomplete:has(.cm-completionIcon-table)":{border:"1px solid var(--tbl-theme-menu-border-color)","box-shadow":"2px 2px 0 0 rgb(0 0 0 / 10%)","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)"},"& .cm-tooltip.cm-tooltip-autocomplete > ul:has(.cm-completionIcon-table)":{"min-width":"auto",display:"flex","flex-direction":"column","justify-content":"center",padding:"0.25em 0","line-height":1,"font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)",background:"var(--tbl-theme-menu-background)"},"& .cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]:has(.cm-completionIcon-table)":{color:"var(--tbl-theme-menu-hover-text-color)","&::before":{background:"var(--tbl-theme-menu-hover-background)"}},"& .cm-tooltip.cm-tooltip-autocomplete ul li:not([aria-selected]):has(.cm-completionIcon-table)":{color:"var(--tbl-theme-menu-text-color)"},"& .cm-tooltip.cm-tooltip-autocomplete ul li:not([aria-selected]):has(.cm-completionIcon-table), & .cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]:has(.cm-completionIcon-table)":{position:"relative",padding:"0.5em 0.75em",background:"var(--tbl-theme-menu-background)",display:"flex",gap:"0.75em","align-items":"center","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)","line-height":1,"&::before":{position:"absolute",height:"100%",width:"calc(100% - 0.5em)",left:"0.25em",top:0,content:'""',"pointer-events":"none"}},"& .cm-completionIcon.cm-completionIcon-table":{opacity:1,"mask-image":`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='14' width='12.25' viewBox='0 0 448 512'%3E%3C!--!Font Awesome Free v7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--%3E%3Cpath d='M384 96l-128 0 0 128 128 0 0-128zm64 128l0 192c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96C0 60.7 28.7 32 64 32l320 0c35.3 0 64 28.7 64 64l0 128zM64 288l0 128 128 0 0-128-128 0zm128-64l0-128-128 0 0 128 128 0zm64 64l0 128 128 0 0-128-128 0z'/%3E%3C/svg%3E")`,"mask-position":"center","mask-repeat":"no-repeat",padding:0,background:"currentColor",position:"relative",width:"1em",height:"1em","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)","line-height":1},"& :has(.cm-completionIcon.cm-completionIcon-table) .cm-completionLabel":{position:"relative"}},jE={'&[data-tbl-handle-position="inside"] .tbl-table-widget':{"padding-left":"6px","margin-left":0},".tbl-table-widget":{contain:"paint","padding-top":"16px","padding-right":"16px","padding-bottom":"16px","padding-left":"16px","margin-left":"-10px","overflow-x":"auto","overflow-y":"hidden","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}},"&.cm-editor .cm-content div.tbl-table-widget::selection, & .cm-content div.tbl-table-widget ::selection, & .cm-content div.tbl-table-widget:focus::selection, & .cm-content div.tbl-table-widget :focus::selection":{"background-color":"transparent !important","caret-color":"transparent !important"}},DE={".cm-tooltip.tbl-menu-tooltip":{border:"none","user-select":"none","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}}},VE={".tbl-blocking-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"transparent",width:"100%",height:"100%"}},BE={"& .cm-content div.tbl-table-widget .tbl-cell-editor ::selection, & .cm-content div.tbl-table-widget .tbl-cell-editor :focus::selection":{"background-color":"Highlight !important","caret-color":"initial !important"},"&[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content":{"caret-color":"transparent !important"},"&[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content ::selection, &[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content :focus::selection":{"background-color":"transparent !important","caret-color":"transparent !important"},"&[data-tbl-line-wrapping='wrap'] .tbl-cell-editor .cm-editor .cm-content":{"word-break":"normal","overflow-wrap":"break-word"},".tbl-cell-editor":{height:"100%"},".tbl-cell-editor .cm-editor":{margin:0,padding:0,outline:"none",height:"100%",background:"unset",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-scroller":{margin:0,padding:0,overflow:"hidden","line-height":1.5,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-content":{margin:0,padding:"7px 9px","line-height":1.5,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-line":{margin:0,padding:"0 1px","line-height":1.5,"touch-action":"none","font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"}},WE={".tbl-cell":{"box-sizing":"content-box",position:"relative","vertical-align":"top","background-color":"var(--tbl-row-background)",padding:0,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)","min-width":"calc(4ch + 20px)",height:"inherit","user-select":"none",border:"none","scroll-margin-right":"1px","scroll-margin-left":"1px","&:first-child":{"scroll-margin-left":"16px"},"&:last-child":{"scroll-margin-right":"16px"},'&[align="left"]':{"text-align":"left"},'&[align="center"]':{"text-align":"center"},'&[align="right"]':{"text-align":"right"},'&[data-border~="top"]':{"border-top":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="right"]':{"border-right":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="bottom"]':{"border-bottom":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="left"]':{"border-left":"1px solid var(--tbl-theme-border-color)"},'&[data-state="moving"]':{"z-index":200,"background-color":"color-mix(in srgb, var(--tbl-row-background), transparent 15%)"},'&[data-state="shiftable"]':{transform:"translate3d(0, 0, 0)",transition:"transform 150ms ease"},"&[data-outline]":{"&::after":{display:"block",position:"absolute",top:"-1px",left:"-1px",border:"none",width:"calc(100% + 2px)",height:"calc(100% + 2px)","pointer-events":"none",content:'""'},'&[data-outline~="top"]::after':{"border-top":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="right"]::after':{"border-right":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="bottom"]::after':{"border-bottom":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="left"]::after':{"border-left":"2px solid var(--tbl-theme-outline-color)"}}},".tbl-header-cell:not([align])":{"text-align":"var(--tbl-style-default-header-alignment)"}},YE={'&[data-tbl-line-wrapping="wrap"] .tbl-cell-view':{"word-break":"normal","overflow-wrap":"break-word"},'&[data-tbl-line-wrapping="nowrap"] .tbl-cell-view':{"white-space":"pre"},".tbl-cell-view":{margin:0,outline:"none",padding:"7px 10px",height:"100%","line-height":1.5,"white-space-collapse":"break-spaces","font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)","&[data-hidden]":{display:"none"}},".tbl-cell-view [data-br]":{"white-space":"pre"}},qE={".tbl-handle":{display:"flex",position:"absolute","justify-content":"center","align-items":"center","z-index":200,transition:"opacity 150ms ease 50ms","touch-action":"none"},".tbl-handle[data-hover], .tbl-handle[data-active]":{"--tbl-handle-opacity":1},'&:not([data-tbl-hoverable]) .tbl-handle[data-type="border"], &:not([data-tbl-hoverable]) .tbl-handle[data-type="table"]':{display:"none"},'.tbl-handle[data-type="border"]':{"background-color":"var(--tbl-theme-border-hover-color)"},'.tbl-handle[data-type="border"][data-active]':{"background-color":"var(--tbl-theme-border-active-color)"},'.tbl-handle[data-type="border"][data-toggle]':{transition:"none"},'.tbl-handle[data-type="border"][data-location="top"]':{top:"-1px",left:"-1px",width:"calc(100% + 2px)",height:"2px"},'.tbl-handle[data-type="border"][data-location="left"]':{top:"-1px",left:"-1px",width:"2px",height:"calc(100% + 2px)"},'.tbl-handle[data-type="border"][data-location="col"]':{top:"-1px",right:"-2px",width:"3px",height:"calc(100% + 2px)"},'.tbl-handle[data-type="border"][data-location="row"]':{bottom:"-2px",left:"-1px",width:"calc(100% + 2px)",height:"3px"},'.tbl-handle[data-type="table"]':{"box-sizing":"content-box",color:"var(--tbl-theme-border-hover-color)","background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)"},'.tbl-handle[data-type="table"][data-location="right"]':{top:0,left:"100%",width:"15px",height:"calc(100% - 2px)",border:"1px solid var(--tbl-theme-border-color)","border-left":"none","&::before":{position:"absolute",top:"-1px",left:"-2px",width:"2px",height:"calc(100% + 2px)",content:'""'},"&::after":{position:"absolute","z-index":366,top:"-1px",left:0,content:'""',width:"calc(100% + 1px)",height:"calc(100% + 2px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom-right"]':{left:"calc(100% - 1px)",top:"calc(100% - 1px)","z-index":250,width:"15px",height:"15px",border:"1px solid var(--tbl-theme-border-color)","border-top-style":"dashed","border-left-style":"dashed","&::after":{position:"absolute","z-index":366,top:"-1px",left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 2px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom"]':{top:"100%",left:"0",width:"calc(100% - 2px)",height:"15px",border:"1px solid var(--tbl-theme-border-color)","border-top":"none","&::before":{position:"absolute",top:"-2px",left:"-1px",width:"calc(100% + 2px)",height:"2px",content:'""'},"&::after":{position:"absolute","z-index":366,top:0,left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 1px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="bottom"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"--tbl-handle-opacity":1},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"]':{"border-bottom":"none"},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="bottom"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"border-right":"none"},'.tbl-handle[data-type="table"][data-active], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)",color:"var(--tbl-theme-border-active-color)"},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"]':{"box-sizing":"content-box",transition:"none","z-index":300,color:"var(--tbl-theme-border-hover-color)",border:"1px solid transparent","&:hover":{"border-color":"var(--tbl-theme-border-color)","background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)"},"&[data-active]":{"background-color":"var(--tbl-theme-outline-color)","border-color":"var(--tbl-theme-outline-color)",color:"#ffffff"}},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"][data-location="row"]':{top:"-1px",left:"-17px",width:"15px",height:"100%","border-right":"none"},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"][data-location="col"]':{top:"-17px",left:"-1px",width:"100%",height:"15px","border-bottom":"none","&:hover::after":{position:"absolute","z-index":366,top:"-1px",left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 1px)","background-color":"var(--tbl-overlay)"}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"]':{transition:"none","z-index":300,color:"var(--tbl-theme-border-hover-color)","&:hover":{color:"var(--tbl-theme-border-active-color)"},"&[data-active]":{color:"var(--tbl-theme-outline-color)"}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"][data-location="row"]':{top:"calc(50% - 13px)",left:"-1px",width:"3px",height:"26px","border-top":"4px solid var(--tbl-row-background)","border-bottom":"4px solid var(--tbl-row-background)","background-color":"var(--tbl-row-background)","&:hover::after, &[data-active]::after":{position:"absolute",top:"-6px",left:0,"box-sizing":"content-box","border-top":"2px solid transparent","border-bottom":"2px solid transparent",width:"calc(100% + 6px)",height:"calc(100% + 8px)",content:'""'}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"][data-location="col"]':{top:"-1px",left:"calc(50% - 11.5px)",width:"23px",height:"3px","border-right":"4px solid var(--tbl-row-background)","border-left":"4px solid var(--tbl-row-background)","background-color":"var(--tbl-row-background)","&:hover::after, &[data-active]::after":{position:"absolute",top:0,left:"-6px","box-sizing":"content-box","border-right":"2px solid transparent","border-left":"2px solid transparent",width:"calc(100% + 8px)",height:"calc(100% + 6px)",content:'""'}},".tbl-handle-grip":{"pointer-events":"none","z-index":333}},NE={".tbl-menu-item-icon":{"z-index":200,width:"1em",height:"1em","pointer-events":"none","font-size":"var(--tbl-style-menu-font-size)"}},GE={".tbl-menu-item-text":{"z-index":200,"pointer-events":"none","user-select":"none","font-size":"var(--tbl-style-menu-font-size)"}},UE={".tbl-menu-item":{display:"flex",position:"relative","align-items":"center",gap:"0.75em",padding:"0.5em 0.75em",color:"var(--tbl-theme-menu-text-color)","user-select":"none","line-height":1,"font-size":"var(--tbl-style-menu-font-size)","&:active":{cursor:"pointer",color:"var(--tbl-theme-menu-hover-text-color)","&::after":{"background-color":"var(--tbl-theme-menu-hover-background)"}},"&::after":{position:"absolute",left:"0.25em",width:"calc(100% - 0.5em)",height:"100%",content:'""'}},"&[data-tbl-hoverable] .tbl-menu-item:hover":{cursor:"pointer",color:"var(--tbl-theme-menu-hover-text-color)","&::after":{"background-color":"var(--tbl-theme-menu-hover-background)"}}},HE={".tbl-menu-separator":{margin:"0.25em 0.5em","background-color":"var(--tbl-theme-menu-border-color)",height:"1px","font-size":"var(--tbl-style-menu-font-size)"}},FE={".tbl-menu":{position:"absolute",top:0,left:0,"z-index":900,"box-shadow":"2px 2px 0 0 rgb(0 0 0 / 10%)",border:"1px solid var(--tbl-theme-menu-border-color)","background-color":"var(--tbl-theme-menu-background)",padding:"0.25em 0",width:"max-content","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)"}},KE={".tbl-select-all-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"var(--tbl-overlay)",width:"100%",height:"100%","pointer-events":"none"}},JE={"& .tbl-table-wrapper[data-select-all]":{"--tbl-select-all-overlay":"var(--tbl-theme-select-all-blur-overlay)"},"&.cm-focused .tbl-table-wrapper[data-select-all]":{"--tbl-select-all-overlay":"var(--tbl-theme-select-all-focus-overlay)"},".tbl-table-wrapper":{"--tbl-overlay":"var(--tbl-select-all-overlay, transparent)",position:"relative",width:"fit-content","white-space-collapse":"collapse","touch-action":"none"},".tbl-table":{"border-collapse":"separate","border-spacing":0,overflow:"visible","touch-action":"none","&:focus-visible":{outline:"none"}},".tbl-table-head, .tbl-table-body":{height:"100%"},".tbl-table-row":{height:0},"@supports (-moz-appearance: none) /* TableTheme */":{".tbl-table-row":{height:"fit-content"}},".tbl-table-head .tbl-table-row":{"--tbl-row-background":"var(--tbl-theme-header-row-background)"},".tbl-table-body .tbl-table-row:nth-child(2n + 1)":{"--tbl-row-background":"var(--tbl-theme-even-row-background)"},".tbl-table-body .tbl-table-row:nth-child(2n)":{"--tbl-row-background":"var(--tbl-theme-odd-row-background)"}},tL={...IE,...DE,...jE,...JE,...VE,...WE,...BE,...YE,...qE,...FE,...UE,...NE,...GE,...HE,...KE},eL=i=>{var e;const t=(e=i.effects.find(n=>n.is(Sv)))==null?void 0:e.value;return E(t)?{annotations:Rn(t)}:null},iL=i=>{const t=i.annotation(Md);return E(t)?[vv(V5(t))]:[]};class Fd{static of(t){return t.state.field(Hd).view=t,new Fd}constructor(){}}function nL(i){return[Fu.of(i),gv,Hd,ui.define(t=>Fd.of(t)),z.editorAttributes.compute([Fu,z.darkTheme],xE),z.baseTheme(tL),z.theme("light"in i.theme?{':where(:root:has(&[data-tbl-theme-mode="light"]))':i.theme.light.props,':where(:root:has(&[data-tbl-theme-mode="dark"]))':i.theme.dark.props}:{":where(:root:has(&))":i.theme.props}),z.theme({":where(:root:has(&))":i.style.props}),w0.of(iL),e0.of(iv),K.transactionExtender.of(eL),K.transactionFilter.of(ME),K.transactionFilter.of(XE),K.transactionFilter.of(ZE),K.transactionFilter.of(_E),z.updateListener.of(LE),z.updateListener.of(TE),z.clipboardInputFilter.of(KA),z.focusChangeEffect.of(RE)]}function rL(i){return nL(R1(i))}const xv="cm-md-mark",yv="cm-md-inline-code",Sf="cm-md-list-item",vf="cm-md-list-bullet",kv="cm-md-blockquote-line",Qv="cm-md-fenced-line",$v="cm-md-hr",Cv="cm-md-task-checkbox",Pv="cm-md-heading-1",Tv="cm-md-heading-2",Kd="cm-md-link",Av="cm-md-tag",Rv="cm-md-list-indent-source",fg="1.2em",sL="0.62em",To=J.replace({}),Un=J.mark({class:xv}),oL=J.mark({class:Rv}),lL=J.mark({class:yv}),aL=J.line({class:vf}),cL=J.line({class:kv}),hL=J.line({class:Qv}),uL=J.line({class:Pv}),fL=J.line({class:Tv}),dL=J.mark({class:Av});class OL extends jn{toDOM(){const t=document.createElement("hr");return t.className=$v,t}eq(t){return!0}ignoreEvent(){return!0}}const pL=J.replace({widget:new OL});class mL extends jn{constructor(e,n,r){super();P(this,"checked");P(this,"from");P(this,"to");this.checked=e,this.from=n,this.to=r}eq(e){return e.checked===this.checked&&e.from===this.from&&e.to===this.to}toDOM(e){const n=document.createElement("input");return n.type="checkbox",n.checked=this.checked,n.className=Cv,n.tabIndex=-1,n.addEventListener("mousedown",r=>{r.preventDefault()}),n.addEventListener("change",()=>{const r=this.checked?"[ ]":"[x]";e.dispatch({changes:{from:this.from,to:this.to,insert:r}})}),n}ignoreEvent(e){return e.type!=="click"&&e.type!=="change"&&e.type!=="mousedown"}}const gL=new Set(["EmphasisMark","LinkMark","URL"]),bL=new Set(["HeaderMark","QuoteMark"]),dg=/(^|\s)(#[\p{L}\p{N}_/-]+)/gu,wL=/[/.,;:!?]+$/u,SL=new RegExp("\\p{L}","u"),vL=new Set(["InlineCode","FencedCode","URL","Link"]);function xL(i,t,e,n,r,s){return bL.has(i)?{kind:"block",contextFrom:r,contextTo:s}:i==="CodeMark"?t==="InlineCode"&&e!==null&&n!==null?{kind:"inline",contextFrom:e,contextTo:n}:null:gL.has(i)?e===null||n===null?null:{kind:"inline",contextFrom:e,contextTo:n}:null}function wn(i,t,e,n){return i<=n&&t>=e}function yL(i,t,e,n){const r=i.doc.lineAt(n);return wn(t,e,r.from,r.to)}function kL(i,t,e,n){return t.kind==="inline"?!wn(e,n,t.contextFrom,t.contextTo):!yL(i,e,n,t.contextFrom)}function QL(i){let t=i.firstChild;for(;t;){if(t.name==="TaskMarker")return!0;if(t.name==="Task"){let e=t.firstChild;for(;e;){if(e.name==="TaskMarker")return!0;e=e.nextSibling}}t=t.nextSibling}return!1}function $L(i){let t=i.parent;for(;t;){if(t.name==="ListItem")return t;t=t.parent}return null}function Jn(i,t){let e=i.firstChild;for(;e;){if(e.name===t)return e;e=e.nextSibling}return null}function Og(i,t){const e=[];let n=t.firstChild;for(;n;)n.name==="CodeMark"&&e.push(n),n=n.nextSibling;if(e.length>=2)return{from:t.from,to:e[e.length-1].to,closed:!0};const r=i.doc.lineAt(t.from);return{from:r.from,to:r.to,closed:!1}}function Zv(i,t){let e=t.to;for(;e<i.doc.length&&i.doc.sliceString(e,e+1)===" ";)e+=1;return{from:t.from,to:e}}function Nh(i,t){return{from:i.doc.lineAt(t.from).from,to:Zv(i,t).to}}function Gh(i,t){return Zv(i,t)}function pg(i,t,e){const n=Jn(t,"ListMark"),r=n?i.doc.lineAt(n.from).from:e.from;let s=e.to;for(;s<i.doc.length&&i.doc.sliceString(s,s+1)===" ";)s+=1;return{from:r,to:s}}function Uh(i,t,e){const n=i.doc.lineAt(t.from);n.from<t.from&&e.push(oL.range(n.from,t.from))}function CL(i,t,e){let n=0;for(let r=t;r<e;r+=1)n+=i.doc.sliceString(r,r+1)===" "?2:1;return n}function PL(i){return J.line({class:Sf,attributes:{style:`--cm-md-list-indent: ${i.prefixRevealed?0:i.indentColumns};`}})}function mg(i,t,e,n,r){let s=t;for(;s<=e;){const o=i.doc.lineAt(s);if(r.push(n.range(o.from)),o.to>=e)break;s=o.to+1}}function TL(i,t,e,n){const r=Jn(t,"ListMark"),s=i.doc.lineAt(r?r.from:t.from).from,o=r?CL(i,s,r.from):0;let l=t.from;for(;l<=t.to;){const a=i.doc.lineAt(l),c=a.from===s,h=/^\s/.test(a.text);if(c||h){const u=e.get(a.from),f={indentColumns:o,prefixRevealed:c&&n};u===void 0||o>u.indentColumns?e.set(a.from,f):o===u.indentColumns&&f.prefixRevealed&&e.set(a.from,{...u,prefixRevealed:!0})}if(a.to>=t.to)break;l=a.to+1}}function AL(i,t){let e=i.resolveInner(t,1);for(;e;){if(vL.has(e.name)||e.name.startsWith("Table"))return!0;e=e.parent}return!1}function RL(i,t){const e=/^( {0,3})(#{1,6})(?:\s|$)/.exec(i);if(!e)return!1;const n=e[1]??"",r=e[2]??"",s=n.length,o=s+r.length;return t>=s&&t<o}function ZL(i,t,e){for(let n=1;n<=i.doc.lines;n+=1){const r=i.doc.line(n);dg.lastIndex=0;let s;for(;(s=dg.exec(r.text))!==null;){const o=s[1]??"",a=(s[2]??"").replace(wL,"");if(a.length<=1||!SL.test(a))continue;const c=r.from+s.index+o.length,h=c+a.length;RL(r.text,c-r.from)||AL(t,c)||e.push(dL.range(c,h))}}}function gg(i,t,e,n){const r=[],s=new Map,o=new Set,l=i.selection.main,a=n?Math.min(l.from,l.to):-1,c=n?Math.max(l.from,l.to):-1;e.iterate({from:0,to:i.doc.length,enter:h=>{var p,m;if(h.name==="Table"||h.name.startsWith("Table"))return!1;const u=h.node.parent,f=(u==null?void 0:u.name)??null;let d=h.to;(h.name==="HeaderMark"||h.name==="QuoteMark")&&i.doc.sliceString(d,d+1)===" "&&(d+=1);const O=xL(h.name,f,(u==null?void 0:u.from)??null,(u==null?void 0:u.to)??null,h.from,d);if(O){const g=kL(i,O,a,c)?To:Un;r.push(g.range(h.from,d))}if(h.name==="ListMark"){const g=h.node.parent;if(g&&g.name==="ListItem"){const b=QL(g),S=((p=g.parent)==null?void 0:p.name)==="OrderedList";if(!b&&!S){const x=Nh(i,h.node),y=Gh(i,h.node);wn(a,c,x.from,x.to)?(Uh(i,h.node,r),r.push(Un.range(y.from,y.to))):r.push(To.range(x.from,x.to))}else if(S){const x=i.doc.lineAt(h.node.from),y=Nh(i,h.node);x.from<h.node.from&&(wn(a,c,y.from,y.to)?Uh(i,h.node,r):r.push(To.range(x.from,h.node.from))),r.push(Un.range(h.node.from,h.node.to))}}}if(h.name==="InlineCode"){const g=h.node.firstChild,b=h.node.lastChild;g&&b&&g!==b&&g.name==="CodeMark"&&b.name==="CodeMark"&&g.to<b.from&&r.push(lL.range(g.to,b.from))}if(h.name==="ListItem"){const g=Jn(h.node,"ListMark"),b=Jn(h.node,"Task"),S=Jn(h.node,"TaskMarker")??(b?Jn(b,"TaskMarker"):null),x=S!==null,y=((m=h.node.parent)==null?void 0:m.name)==="OrderedList";let k=!1;if(g){const Q=S?pg(i,h.node,S):Nh(i,g);k=wn(a,c,Q.from,Q.to)}if(TL(i,h.node,s,k),!x&&!y&&g&&!k){const Q=i.doc.lineAt(h.from);o.add(Q.from)}}else if(h.name==="Blockquote")mg(i,h.from,h.to,cL,r);else if(h.name==="ATXHeading1"){const g=i.doc.lineAt(h.from);r.push(uL.range(g.from))}else if(h.name==="ATXHeading2"){const g=i.doc.lineAt(h.from);r.push(fL.range(g.from))}else if(h.name==="FencedCode"){const g=Og(i,h.node);mg(i,g.from,g.to,hL,r)}if(h.name==="Link"){let g=null,b=null,S=null,x=h.node.firstChild;for(;x;)x.name==="LinkMark"?g===null?g=x:b=x:x.name==="URL"&&(S=x),x=x.nextSibling;if(g&&b&&S&&g.to<b.from){const y=i.doc.sliceString(S.from,S.to),k=J.mark({class:Kd,tagName:"a",attributes:{"data-href":y}});r.push(k.range(g.to,b.from))}}if(h.name==="CodeMark"&&f==="FencedCode"){const g=h.node.parent;if(g){const b=Og(i,g);if(b.closed){const S=wn(a,c,b.from,b.to)?Un:To;r.push(S.range(h.from,h.to))}else r.push(Un.range(h.from,h.to))}}if(h.name==="HorizontalRule"){const g=i.doc.lineAt(h.from);g.to>g.from&&!wn(a,c,g.from,g.to)&&r.push(pL.range(g.from,g.to))}if(h.name==="TaskMarker"){const g=$L(h.node),b=g?Jn(g,"ListMark"):null,S=g?pg(i,g,h.node):{from:h.from,to:h.to};if(wn(a,c,S.from,S.to)){if(b){const y=Gh(i,b);Uh(i,b,r),r.push(Un.range(y.from,y.to))}r.push(Un.range(h.from,h.to))}else{if(b){const X=Gh(i,b),B=i.doc.lineAt(b.from).from;r.push(To.range(B,X.to))}const y=i.doc.sliceString(h.from,h.to),k=y==="[x]"||y==="[X]",Q=J.replace({widget:new mL(k,h.from,h.to)});r.push(Q.range(h.from,h.to))}}}});for(const[h,u]of s)r.push(PL(u).range(h));for(const h of o)r.push(aL.range(h));return ZL(i,e,r),J.set(r,!0)}const XL=ui.fromClass(class{constructor(i){P(this,"decorations");this.decorations=gg(i.state,i.visibleRanges,St(i.state),i.hasFocus)}update(i){(i.docChanged||i.selectionSet||i.viewportChanged||i.focusChanged||St(i.state)!==St(i.startState))&&(this.decorations=gg(i.state,i.view.visibleRanges,St(i.state),i.view.hasFocus))}},{decorations:i=>i.decorations}),EL=z.theme({"&":{fontFamily:"var(--font-sans)",fontSize:"calc(var(--text-base) + 0.5px)",lineHeight:"var(--leading-base)"},".cm-scroller":{fontFamily:"inherit",fontSize:"inherit",lineHeight:"inherit"},".cm-content":{fontFamily:"inherit",fontSize:"inherit",lineHeight:"inherit",padding:"1.5rem 1rem"},[`.${Rv}`]:{fontFamily:"var(--font-mono)"},[`.${xv}`]:{fontFamily:"var(--font-mono)",fontSize:"0.9em",color:"rgba(0, 0, 0, 0.4)"},[`.${Pv}`]:{fontSize:"1.3em"},[`.${Tv}`]:{fontSize:"1.1em"},[`.${yv}`]:{fontFamily:"var(--font-mono)",fontSize:"0.92em",backgroundColor:"rgba(0, 0, 0, 0.06)",padding:"1px 4px",borderRadius:"3px"},[`.${Av}`]:{color:"var(--color-primary)",backgroundColor:"var(--tint-100)",borderRadius:"var(--radius-full)",padding:"0 0.35em",fontWeight:"600",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone"},[`.${Sf}`]:{paddingLeft:`calc(0.5rem + var(--cm-md-list-indent, 0) * ${sL})`},[`.${Sf}.${vf}`]:{borderLeft:`${fg} solid transparent`},[`.${vf}::before`]:{content:"'•'",marginLeft:`calc(-1 * ${fg})`,fontFamily:"var(--font-mono)",fontSize:"0.9em",color:"rgba(0, 0, 0, 0.4)",paddingRight:"0.5rem"},[`.${kv}`]:{borderLeft:"3px solid rgba(0, 0, 0, 0.2)",paddingLeft:"1rem",marginLeft:"0.25rem",color:"rgba(0, 0, 0, 0.55)"},[`.${Qv}`]:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"0.92em",backgroundColor:"rgba(0, 0, 0, 0.04)",paddingLeft:"0.75em"},[`.${$v}`]:{display:"inline-block",verticalAlign:"middle",border:"none",borderTop:"1px solid rgba(0, 0, 0, 0.2)",margin:0,width:"100%"},[`.${Cv}`]:{margin:"0 0.4em 0 0",cursor:"default",verticalAlign:"middle"},[`a.${Kd}`]:{textDecoration:"underline",color:"rgba(0, 0, 0, 0.55)",cursor:"pointer"}}),LL=4;function bg(i){return i instanceof Element?i.closest(`a.${Kd}`):null}function ML(i){const t=i.getAttribute("data-href");if(t===null)return null;try{return new URL(t,window.document.baseURI).href}catch{return null}}function zL(i){const t={type:"navigation-request",url:i},e=window.__televisionContentBridge;if(e){e.postToHost(t);return}window.parent.postMessage(t,"*")}function _L(i,t){return Math.hypot(t.clientX-i.x,t.clientY-i.y)>LL}let Rr=null;const IL=z.domEventHandlers({mousedown(i){const t=bg(i.target);if(Rr=null,!t||i.button!==0||i.altKey)return!1;const e=ML(t);return e===null?!1:(Rr={anchor:t,url:e,openExternally:i.metaKey||i.ctrlKey,x:i.clientX,y:i.clientY},i.preventDefault(),!0)},click(i){const t=bg(i.target);if(!t||i.altKey)return Rr=null,!1;const e=Rr;return Rr=null,!e||e.anchor!==t?!1:(i.preventDefault(),_L(e,i)||(e.openExternally?window.open(e.url,"_blank","noopener,noreferrer"):zL(e.url)),!0)}}),jL=/^(\d+)([.)])(\s|$)/;function DL(i){const t=[];let e=!1,n=1;for(let r=1;r<=i.doc.lines;r+=1){const s=i.doc.line(r),o=jL.exec(s.text);o?(e||(e=!0,n=1),parseInt(o[1],10)!==n&&t.push({from:s.from,to:s.from+o[1].length,insert:String(n)}),n+=1):s.text===""&&(e=!1)}return t}const wg=Ke.define(),VL=K.transactionFilter.of(i=>{if(!i.docChanged||i.annotation(wg))return i;const t=i.annotation(Pt.userEvent);if(t==="undo"||t==="redo")return i;const e=DL(i.state);if(e.length===0)return i;const n=Lt.of(e,i.state.doc.length),r=i.changes.compose(n);return i.startState.update({changes:r,selection:i.selection,scrollIntoView:i.scrollIntoView,effects:i.effects,annotations:[wg.of(!0),...t?[Pt.userEvent.of(t)]:[]],filter:!1})}),BL=/^(\s*)([-*]|\d+[.)])(\s\[[ xX]\])?\s$/,WL=i=>{const{state:t}=i,e=t.selection.main;if(e.from!==e.to)return!1;const n=t.doc.lineAt(e.from),r=n.text.slice(0,e.from-n.from);return BL.test(r)?(i.dispatch({changes:{from:e.from-1,to:e.from,insert:""},selection:{anchor:e.from-1},userEvent:"delete.backward",scrollIntoView:!0}),!0):!1},YL=hn.highest(Dn.of([{key:"Backspace",run:WL}])),qL=[XL,EL,VL,YL,IL],NL=500,Sg=Ke.define(),GL=Rc.define([{tag:v.heading,fontWeight:"600"},{tag:v.strong,fontWeight:"600"},{tag:v.emphasis,fontStyle:"italic"},{tag:v.strikethrough,textDecoration:"line-through"}]);function vg(i){const t=i.length;return({state:e,dispatch:n})=>{const r=e.changeByRange(s=>{if(s.empty)return{changes:{from:s.from,insert:i+i},range:C.cursor(s.from+t)};const o=e.sliceDoc(s.from,s.to);if(o.length>=t*2&&o.startsWith(i)&&o.endsWith(i))return{changes:[{from:s.from,to:s.from+t},{from:s.to-t,to:s.to}],range:C.range(s.from,s.to-t*2)};const l=s.from>=t&&e.sliceDoc(s.from-t,s.from)===i,a=s.to+t<=e.doc.length&&e.sliceDoc(s.to,s.to+t)===i;return l&&a?{changes:[{from:s.from-t,to:s.from},{from:s.to,to:s.to+t}],range:C.range(s.from-t,s.to-t)}:{changes:[{from:s.from,insert:i},{from:s.to,insert:i}],range:C.range(s.from+t,s.to+t)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}const UL=hn.highest(Dn.of([{key:"Mod-b",run:vg("**")},{key:"Mod-i",run:vg("*")},{key:"Enter",run:u1({nonTightLists:!1})}])),HL=cl.light.with({"--tbl-theme-row-background":"transparent","--tbl-theme-header-row-background":"var(--tint-50)","--tbl-theme-even-row-background":"transparent","--tbl-theme-odd-row-background":"transparent","--tbl-theme-border-color":"var(--tint-150)","--tbl-theme-border-hover-color":"var(--tint-300)","--tbl-theme-border-active-color":"var(--tint-500)","--tbl-theme-outline-color":"var(--color-primary)","--tbl-theme-text-color":"currentColor","--tbl-theme-menu-border-color":"var(--tint-150)","--tbl-theme-menu-background":"var(--color-surface)","--tbl-theme-menu-hover-background":"var(--color-overlay-hover)","--tbl-theme-menu-text-color":"var(--color-text)","--tbl-theme-menu-hover-text-color":"var(--color-text)","--tbl-theme-select-all-focus-overlay":"var(--tint-200)","--tbl-theme-select-all-blur-overlay":"var(--tint-100)"}),FL=sc.default.with({"--tbl-style-font-family":"var(--font-sans)","--tbl-style-font-size":"inherit","--tbl-style-menu-font-family":"var(--font-sans)","--tbl-style-menu-font-size":"var(--text-sm, 0.875rem)","--tbl-style-default-header-alignment":"left"}),KL=rL({theme:HL,style:FL,selectionType:"native",handlePosition:"outside",lineWrapping:"wrap",extensions:[Dn.of(K0)],globalKeyBindings:[...k0]}),Xv=[vQ(),uo.of(" "),UL,Dn.of([...K0,...k0,k$]),zc({extensions:[xw,sd,{remove:["SetextHeading"]}]}),m0(GL),z.lineWrapping,qL,KL];function JL(i){const{parent:t,ctx:e}=i,n=i.debounceMs??NL;let r=null,s=null,o=null;const l=f=>{h.state.doc.toString()!==f&&h.dispatch({changes:{from:0,to:h.state.doc.length,insert:f},annotations:[Sg.of(!0),Pt.addToHistory.of(!1)]})},a=async()=>{o=null;const f=h.state.doc.toString();r=f;try{await e.updateContent(f),s=f}catch{const d=s??"";l(d),r=d}},c=z.updateListener.of(f=>{!f.docChanged||f.transactions.some(O=>O.annotation(Sg))||(o!==null&&clearTimeout(o),o=setTimeout(()=>{a()},n))}),h=new z({parent:t,state:K.create({doc:"",extensions:[Xv,c]})}),u=f=>{const d=f.content;r!==null&&d===r||(l(d),s=d)};return e.addEventListener("content-updated",u),{view:h,dispose(){o!==null&&(clearTimeout(o),o=null),e.removeEventListener("content-updated",u),h.destroy()}}}const t3=`# Heading 1
61
+ `:l.textContent??""})??"",r=(t.textContent??"").slice(0,ig(i)),s=le(`${n}${r}`),o=n.length+ig(i);return uv({anchor:o,head:o},s,{trim:!1})}function AZ(i,t){var e=Xd(),n=Et(e);Qr(n,()=>t.children),I(i,e)}function RZ(i,t){Wn(t,!0),Uc(()=>{const e=zS(AZ,{target:t.to,context:MR(),props:{children:t.children}});return()=>{_S(e)}}),Yn()}ER();var ZZ=ot('<div class="tbl-blocking-overlay" aria-hidden="true"></div>');function XZ(i){var t=ZZ();I(i,t)}function bc(i,t){const e=t.devicePixelRatio;return TA(i*e)/e}function EZ({x:i,y:t},e){return{x:bc(i,e),y:bc(t,e)}}var LZ=ot('<th class="tbl-cell tbl-header-cell"><!></th>'),MZ=ot('<td class="tbl-cell tbl-data-cell"><!></td>');function zZ(i,t){Wn(t,!0);const e=F(()=>eg(E(t.movement)?t.movement.border:{top:t.position.top,right:!0,bottom:!0,left:t.position.left})),n=F(()=>eg(t.outline)),r=F(()=>{var u;if(W((u=t.movement)==null?void 0:u.translate))return;const{x:c,y:h}=t.movement.state==="moving"?EZ(t.movement.translate,t.win):t.movement.translate;return`translate3d(${c}px, ${h}px, 0px)`});var s=Xd(),o=Et(s);{var l=c=>{var h=LZ();let u;var f=Ue(h);Qr(f,()=>t.children),se(d=>{var O;Qt(h,"align",t.alignment==="none"?void 0:t.alignment),Qt(h,"data-component",Ol),Qt(h,"data-row",t.location.row),Qt(h,"data-col",t.location.col),Qt(h,"data-border",$(e)),Qt(h,"data-outline",$(n)),Qt(h,"data-selected",d),Qt(h,"data-state",(O=t.movement)==null?void 0:O.state),u=dc(h,"",u,{transform:$(r)})},[()=>br(t.selected)]),I(c,h)},a=c=>{var h=MZ();let u;var f=Ue(h);Qr(f,()=>t.children),se(d=>{var O;Qt(h,"align",t.alignment==="none"?void 0:t.alignment),Qt(h,"data-component",Ol),Qt(h,"data-row",t.location.row),Qt(h,"data-col",t.location.col),Qt(h,"data-border",$(e)),Qt(h,"data-outline",$(n)),Qt(h,"data-selected",d),Qt(h,"data-state",(O=t.movement)==null?void 0:O.state),u=dc(h,"",u,{transform:$(r)})},[()=>br(t.selected)]),I(c,h)};Ft(o,c=>{t.position.top?c(l):c(a,!1)})}I(i,s),Yn()}function fv(i){var t;return E((t=fl(i.dom).activeElement)==null?void 0:t.closest(".cm-panels"))}function sg(i){return i.trim().split(/\s+/)}function _Z({doc:i,selection:t,parent:e,extensions:n,markdownConfig:r,selectionType:s,lineWrapping:o,globalKeyBindings:l,rootEditor:a,highlighter:c,onChange:h,eventHandlers:u}){return new z({doc:i,selection:t,parent:e,extensions:[n,hn.lowest([z.editorAttributes.of(f=>{const d=new Set(sg(a.themeClasses)),O=new Set(sg(f.themeClasses));return{class:[...d.difference(O)].join(" ")}}),Dn.of([...l.map(f=>({...f,run:E(f.run)?()=>f.run(a):void 0,shift:E(f.shift)?()=>f.shift(a):void 0}))]),s==="codemirror"?pk():[],m0(c),zc({extensions:[X1,r.extensions??[]],addKeymap:!1,completeHTMLTags:r.completeHTMLTags,pasteURLAsLink:r.pasteURLAsLink,htmlTagLanguage:r.htmlTagLanguage}),z.domEventObservers(u),o==="wrap"?z.lineWrapping:[]])],dispatchTransactions:(f,d)=>{d.update(f),f.forEach(h)}})}var IZ=ot('<div class="tbl-cell-editor"></div>');function jZ(i,t){Wn(t,!0);let e=ff(t,"text",15),n=ff(t,"selection",15),r,s,o=!1,l=!1;function a(h){const{docChanged:u,newDoc:f,selection:d}=h;if(o)return;const O=E(d);if(u||O){if(u){const p=Sd(f,{trim:!0});p.eq(e())||(e(p),l=!0)}if(O){const{head:p,anchor:m}=d.main,g=uv({head:p,anchor:m},f,{trim:!0});JS(g,n())||(n(g),l=!0)}}}_d([()=>e(),()=>n()],()=>{if(l){l=!1;return}o=!0,s.dispatch({changes:s.state.changes({from:0,to:s.state.doc.length,insert:uc(e())}),selection:rg(n(),e())}),o=!1},{lazy:!0}),Uc(()=>(s=_Z({doc:uc(e()),selection:rg(n(),e()),parent:r,selectionType:t.selectionType,lineWrapping:t.lineWrapping,extensions:t.extensions,markdownConfig:t.markdownConfig,globalKeyBindings:t.globalKeyBindings,rootEditor:t.rootEditor,highlighter:t.highlighter,onChange:a,eventHandlers:{beforeinput:t.onbeforeinput,dragstart:t.ondragstart,keydown:(h,{state:u})=>t.onkeydown(h,u),paste:t.onpaste}}),fv(s)||s.focus(),()=>s.destroy()));var c=IZ();Oc(c,h=>r=h,()=>r),I(i,c),Yn()}class th{constructor({event:t,tableState:e,position:n}){P(this,"event");P(this,"tableState");P(this,"position");this.event=t,this.tableState=e,this.position=n}static navigate(t){new th(t)[`navigate${t.key}`]()}navigateTab(){this.moveRight({createRow:!0,position:"end"})}navigateShiftTab(){this.moveLeft({createRow:!0,position:"end"})}navigateEnter(){this.moveDown({createRow:!0,position:"end"})}navigateArrowLeft(){this.position.left&&this.moveLeft({createRow:!1,position:"end"})}navigateArrowUp(){this.position.top&&this.moveUp({createRow:!1,position:"end"})}navigateArrowRight(){this.position.right&&this.moveRight({createRow:!1,position:"start"})}navigateArrowDown(){this.position.bottom&&this.moveDown({createRow:!1,position:"end"})}navigateShiftArrowLeft(){if(!(!this.position.left||W(this.tableState.outlinedSection)||W(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),W(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.endCol===this.tableState.anchorCell.col){if(this.tableState.outlinedSection.startCol===this.tableState.table.firstColIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandLeft()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractLeft();this.tableState.activeCell=KS(this.tableState.activeCell)}}navigateShiftArrowUp(){if(!(!this.position.top||W(this.tableState.outlinedSection)||W(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),W(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.endRow===this.tableState.anchorCell.row){if(this.tableState.outlinedSection.startRow===this.tableState.table.firstRowIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandUp()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractUp();this.tableState.activeCell=US(this.tableState.activeCell)}}navigateShiftArrowRight(){if(!(!this.position.right||W(this.tableState.outlinedSection)||W(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),W(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.startCol===this.tableState.anchorCell.col){if(this.tableState.outlinedSection.endCol===this.tableState.table.lastColIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandRight()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractRight();this.tableState.activeCell=HS(this.tableState.activeCell)}}navigateShiftArrowDown(){if(!(!this.position.bottom||W(this.tableState.outlinedSection)||W(this.tableState.activeCell))){if(this.event.preventDefault(),this.tableState.focusTable(),W(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.tableState.activeCell),this.tableState.outlinedSection.startRow===this.tableState.anchorCell.row){if(this.tableState.outlinedSection.endRow===this.tableState.table.lastRowIndex)return;this.tableState.outlinedSection=this.tableState.outlinedSection.expandDown()}else this.tableState.outlinedSection=this.tableState.outlinedSection.contractDown();this.tableState.activeCell=FS(this.tableState.activeCell)}}moveLeft({createRow:t,position:e}){if(!W(this.tableState.activeCell)){if(this.event.preventDefault(),Cr(this.tableState.activeCell,this.tableState.table.firstCellLocation)){if(!t){this.tableState.navigate("before");return}this.tableState.table.prependEmptyRows(1),this.tableState.activeCell={row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col}}this.moveTo(this.tableState.activeCell.col===this.tableState.table.firstColIndex?{row:this.tableState.activeCell.row-1,col:this.tableState.table.lastColIndex}:{row:this.tableState.activeCell.row,col:this.tableState.activeCell.col-1},e)}}moveUp({createRow:t,position:e}){if(!W(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.firstRowIndex){if(!t){this.tableState.navigate("before");return}this.tableState.table.prependEmptyRows(1),this.tableState.activeCell={row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col}}this.moveTo({row:this.tableState.activeCell.row-1,col:this.tableState.activeCell.col},e)}}moveRight({createRow:t,position:e}){if(!W(this.tableState.activeCell)){if(this.event.preventDefault(),Cr(this.tableState.activeCell,this.tableState.table.lastCellLocation)){if(!t){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo(this.tableState.activeCell.col===this.tableState.table.lastColIndex?{row:this.tableState.activeCell.row+1,col:this.tableState.table.firstColIndex}:{row:this.tableState.activeCell.row,col:this.tableState.activeCell.col+1},e)}}moveDown({createRow:t,position:e}){if(!W(this.tableState.activeCell)){if(this.event.preventDefault(),this.tableState.activeCell.row===this.tableState.table.lastRowIndex){if(!t){this.tableState.navigate("after");return}this.tableState.table.appendEmptyRows(1)}this.moveTo({row:this.tableState.activeCell.row+1,col:this.tableState.activeCell.col},e)}}moveTo(t,e){if(this.tableState.activeCell=t,this.tableState.anchorCell=t,this.tableState.outlinedSection=rt.ofCell(t),this.tableState.selection.isCell()){const n=e==="start"?0:this.tableState.table.cellAt(t).length;this.tableState.selectionValue={cell:t,section:{anchor:n,head:n}}}}}const bt={alt:"Alt",arrowDown:"ArrowDown",arrowLeft:"ArrowLeft",arrowRight:"ArrowRight",arrowUp:"ArrowUp",backspace:"Backspace",c:"c",delete:"Delete",enter:"Enter",escape:"Escape",shift:"Shift",tab:"Tab",v:"v",x:"x"},DZ=[bt.arrowDown,bt.arrowLeft,bt.arrowRight,bt.arrowUp,bt.enter,bt.tab,`${bt.shift}${bt.arrowDown}`,`${bt.shift}${bt.arrowLeft}`,`${bt.shift}${bt.arrowRight}`,`${bt.shift}${bt.arrowUp}`,`${bt.shift}${bt.tab}`],og=new Set(DZ);function dv({key:i,shiftKey:t,altKey:e,metaKey:n,ctrlKey:r}){if(!(e||n||r))return t?og.has(`${bt.shift}${i}`)?`${bt.shift}${i}`:void 0:og.has(i)?i:void 0}function VZ(i,t){i.inputType==="historyUndo"?(t.undo(),i.preventDefault()):i.inputType==="historyRedo"&&(t.redo(),i.preventDefault())}function BZ(i){i.preventDefault()}function WZ(i,t,e){const n=dv(i);if(W(n))return;const r=t.selection.main.head,s=t.doc.lineAt(r).number,o=0,l=t.doc.length,a=1,c=t.doc.lines,h={top:s===a,right:r===l,bottom:s===c,left:r===o};th.navigate({tableState:e,key:n,event:i,position:h})}function YZ(i,t){Id({tableState:t,event:i})}var qZ=ot('<div class="tbl-cell-view" contenteditable="" tabindex="-1"><!></div>');function NZ(i,t){Wn(t,!0);var e=qZ(),n=Ue(e);Qr(n,()=>t.children),se(r=>{Qt(e,"data-component",jd),Qt(e,"data-hidden",r)},[()=>br(t.hidden)]),I(i,e),Yn()}const Ov="Handle";function Dd(i){if(!qS(i,{component:Ov}))return;const{type:t,location:e}=Ed(i).dataset;if(t==="table")return{type:t,location:e};{const n=Kc(_l(i));return gZ({location:e,type:t},n)}}var GZ=ei('<svg class="tbl-handle-grip" width="15" height="3" fill="currentColor" viewBox="0 0 15 3" xmlns="http://www.w3.org/2000/svg"><circle cx="1.5" cy="1.5" r="1.5"></circle><circle cx="7.5" cy="1.5" r="1.5"></circle><circle cx="13.5" cy="1.5" r="1.5"></circle></svg>'),UZ=ei('<svg class="tbl-handle-grip" width="3" height="15" fill="currentColor" viewBox="0 0 3 15" xmlns="http://www.w3.org/2000/svg"><circle cy="1.5" cx="1.5" r="1.5"></circle><circle cy="7.5" cx="1.5" r="1.5"></circle><circle cy="13.5" cx="1.5" r="1.5"></circle></svg>'),HZ=ot('<div class="tbl-handle" role="button" aria-hidden="true"><!></div>');function lg(i,t){Wn(t,!0);let e=ff(t,"toggle",3,!1);const n={table:{right:"vertical",bottom:"horizontal"},header:{row:"vertical",col:"horizontal"}},r=F(()=>{var c;return(c=n[t.of.type])==null?void 0:c[t.of.location]});var s=HZ();dc(s,"",{},{opacity:"var(--tbl-handle-opacity, 0)"});var o=Ue(s);{var l=c=>{var h=GZ();I(c,h)},a=c=>{var h=UZ();I(c,h)};Ft(o,c=>{$(r)==="horizontal"?c(l):$(r)==="vertical"&&c(a,1)})}se((c,h,u)=>{Qt(s,"data-component",Ov),Qt(s,"data-type",t.of.type),Qt(s,"data-location",t.of.location),Qt(s,"data-active",c),Qt(s,"data-hover",h),Qt(s,"data-toggle",u)},[()=>br(t.state==="active"),()=>br(t.state==="hover"),()=>br(e())]),I(i,s),Yn()}var FZ=ot('<div class="tbl-menu"><!></div>');function KZ(i,t){Wn(t,!0);let e,n=ct(void 0);Uc(()=>{t.translate(e).then(l=>q(n,l,!0))});var r=FZ();let s;var o=Ue(r);Qr(o,()=>t.children),Oc(r,l=>e=l,()=>e),se(l=>s=dc(r,"",s,l),[()=>({visibility:E($(n))?void 0:"hidden",transform:E($(n))?`translate3d(${$(n).x}px, ${$(n).y}px, 0px)`:void 0})]),I(i,r),Yn()}var JZ=ot('<div class="tbl-menu-item" role="menuitem" tabindex="-1"><!></div>');function Ae(i,t){var e=JZ(),n=Ue(e);Qr(n,()=>t.children),Eo("click",e,function(...r){var s;(s=t.onclick)==null||s.apply(this,r)}),I(i,e)}MS(["click"]);function Re(i,t){switch(i.action){case"add":return t.menu.clickAdd(i.direction);case"align":return t.menu.clickAlign(i.alignment);case"clear":return t.menu.clickClear();case"duplicate":return t.menu.clickDuplicate();case"move":return t.menu.clickMove(i.direction);case"remove":return t.menu.clickRemove();case"sort":return t.menu.clickSort(i.direction)}}var tX=ei('<path d="M294.6 454.6L214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L89.3 454.6C76.8 442.1 76.8 421.8 89.3 409.3C101.8 396.8 122.1 396.8 134.6 409.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L249.4 409.3C261.9 396.8 282.2 396.8 294.7 409.3C307.2 421.8 307.2 442.1 294.7 454.6zM476.6 113.7C527.3 215 553.9 268.4 556.6 273.7C564.5 289.5 558.1 308.7 542.3 316.6C526.5 324.5 507.3 318.1 499.4 302.3L492.2 288L403.8 288L396.6 302.3C388.7 318.1 369.5 324.5 353.7 316.6C337.9 308.7 331.5 289.5 339.4 273.7C342.1 268.4 368.7 215 419.4 113.7C424.8 102.9 435.9 96 448 96C460.1 96 471.2 102.8 476.6 113.7zM448 199.6L427.8 240L468.2 240L448 199.6zM352 384C352 366.3 366.3 352 384 352L512 352C524.9 352 536.6 359.8 541.6 371.8C546.6 383.8 543.8 397.5 534.7 406.7L461.3 480L512 480C529.7 480 544 494.3 544 512C544 529.7 529.7 544 512 544L384 544C371.1 544 359.4 536.2 354.4 524.2C349.4 512.2 352.2 498.5 361.3 489.3L434.7 415.9L384 415.9C366.3 415.9 352 401.6 352 383.9z"></path>'),eX=ei('<path d="M294.6 454.6L214.6 534.6C202.1 547.1 181.8 547.1 169.3 534.6L89.3 454.6C76.8 442.1 76.8 421.8 89.3 409.3C101.8 396.8 122.1 396.8 134.6 409.3L160 434.7L160 128C160 110.3 174.3 96 192 96C209.7 96 224 110.3 224 128L224 434.7L249.4 409.3C261.9 396.8 282.2 396.8 294.7 409.3C307.2 421.8 307.2 442.1 294.7 454.6zM352 128C352 110.3 366.3 96 384 96L512 96C524.9 96 536.6 103.8 541.6 115.8C546.6 127.8 543.8 141.5 534.7 150.7L461.3 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L384 288C371.1 288 359.4 280.2 354.4 268.2C349.4 256.2 352.2 242.5 361.3 233.3L434.8 160L384 160C366.3 160 352 145.7 352 128zM476.6 337.7L556.6 497.7C564.5 513.5 558.1 532.7 542.3 540.6C526.5 548.5 507.3 542.1 499.4 526.3L492.2 512L403.8 512L396.6 526.3C388.7 542.1 369.5 548.5 353.7 540.6C337.9 532.7 331.5 513.5 339.4 497.7L419.4 337.7C424.8 326.9 435.9 320 448 320C460.1 320 471.2 326.8 476.6 337.7zM448 423.6L427.8 464L468.2 464L448 423.6z"></path>'),iX=ei('<path d="M384 128C384 145.7 369.7 160 352 160L128 160C110.3 160 96 145.7 96 128C96 110.3 110.3 96 128 96L352 96C369.7 96 384 110.3 384 128zM384 384C384 401.7 369.7 416 352 416L128 416C110.3 416 96 401.7 96 384C96 366.3 110.3 352 128 352L352 352C369.7 352 384 366.3 384 384zM96 256C96 238.3 110.3 224 128 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L128 288C110.3 288 96 273.7 96 256zM544 512C544 529.7 529.7 544 512 544L128 544C110.3 544 96 529.7 96 512C96 494.3 110.3 480 128 480L512 480C529.7 480 544 494.3 544 512z"></path>'),nX=ei('<path d="M448 128C448 110.3 433.7 96 416 96L224 96C206.3 96 192 110.3 192 128C192 145.7 206.3 160 224 160L416 160C433.7 160 448 145.7 448 128zM544 256C544 238.3 529.7 224 512 224L128 224C110.3 224 96 238.3 96 256C96 273.7 110.3 288 128 288L512 288C529.7 288 544 273.7 544 256zM96 512C96 529.7 110.3 544 128 544L512 544C529.7 544 544 529.7 544 512C544 494.3 529.7 480 512 480L128 480C110.3 480 96 494.3 96 512zM448 384C448 366.3 433.7 352 416 352L224 352C206.3 352 192 366.3 192 384C192 401.7 206.3 416 224 416L416 416C433.7 416 448 401.7 448 384z"></path>'),rX=ei('<path d="M544 128C544 145.7 529.7 160 512 160L288 160C270.3 160 256 145.7 256 128C256 110.3 270.3 96 288 96L512 96C529.7 96 544 110.3 544 128zM544 384C544 401.7 529.7 416 512 416L288 416C270.3 416 256 401.7 256 384C256 366.3 270.3 352 288 352L512 352C529.7 352 544 366.3 544 384zM96 256C96 238.3 110.3 224 128 224L512 224C529.7 224 544 238.3 544 256C544 273.7 529.7 288 512 288L128 288C110.3 288 96 273.7 96 256zM544 512C544 529.7 529.7 544 512 544L128 544C110.3 544 96 529.7 96 512C96 494.3 110.3 480 128 480L512 480C529.7 480 544 494.3 544 512z"></path>'),sX=ei('<path d="M342.6 81.4C330.1 68.9 309.8 68.9 297.3 81.4L137.3 241.4C124.8 253.9 124.8 274.2 137.3 286.7C149.8 299.2 170.1 299.2 182.6 286.7L288 181.3L288 552C288 569.7 302.3 584 320 584C337.7 584 352 569.7 352 552L352 181.3L457.4 286.7C469.9 299.2 490.2 299.2 502.7 286.7C515.2 274.2 515.2 253.9 502.7 241.4L342.7 81.4z"></path>'),oX=ei('<path d="M566.6 342.6C579.1 330.1 579.1 309.8 566.6 297.3L406.6 137.3C394.1 124.8 373.8 124.8 361.3 137.3C348.8 149.8 348.8 170.1 361.3 182.6L466.7 288L96 288C78.3 288 64 302.3 64 320C64 337.7 78.3 352 96 352L466.7 352L361.3 457.4C348.8 469.9 348.8 490.2 361.3 502.7C373.8 515.2 394.1 515.2 406.6 502.7L566.6 342.7z"></path>'),lX=ei('<path d="M297.4 566.6C309.9 579.1 330.2 579.1 342.7 566.6L502.7 406.6C515.2 394.1 515.2 373.8 502.7 361.3C490.2 348.8 469.9 348.8 457.4 361.3L352 466.7L352 96C352 78.3 337.7 64 320 64C302.3 64 288 78.3 288 96L288 466.7L182.6 361.3C170.1 348.8 149.8 348.8 137.3 361.3C124.8 373.8 124.8 394.1 137.3 406.6L297.3 566.6z"></path>'),aX=ei('<path d="M73.4 297.4C60.9 309.9 60.9 330.2 73.4 342.7L233.4 502.7C245.9 515.2 266.2 515.2 278.7 502.7C291.2 490.2 291.2 469.9 278.7 457.4L173.3 352L544 352C561.7 352 576 337.7 576 320C576 302.3 561.7 288 544 288L173.3 288L278.7 182.6C291.2 170.1 291.2 149.8 278.7 137.3C266.2 124.8 245.9 124.8 233.4 137.3L73.4 297.3z"></path>'),cX=ei('<path d="M262.2 48C248.9 48 236.9 56.3 232.2 68.8L216 112L120 112C106.7 112 96 122.7 96 136C96 149.3 106.7 160 120 160L520 160C533.3 160 544 149.3 544 136C544 122.7 533.3 112 520 112L424 112L407.8 68.8C403.1 56.3 391.2 48 377.8 48L262.2 48zM128 208L128 512C128 547.3 156.7 576 192 576L448 576C483.3 576 512 547.3 512 512L512 208L464 208L464 512C464 520.8 456.8 528 448 528L192 528C183.2 528 176 520.8 176 512L176 208L128 208zM288 280C288 266.7 277.3 256 264 256C250.7 256 240 266.7 240 280L240 456C240 469.3 250.7 480 264 480C277.3 480 288 469.3 288 456L288 280zM400 280C400 266.7 389.3 256 376 256C362.7 256 352 266.7 352 280L352 456C352 469.3 362.7 480 376 480C389.3 480 400 469.3 400 456L400 280z"></path>'),hX=ot('<div class="tbl-menu-item-icon"><svg xmlns="http://www.w3.org/2000/svg" height="14" width="14" viewBox="0 0 640 640" fill="currentColor"><!></svg></div>');function Ze(i,t){var e=hX(),n=Ue(e),r=Ue(n);{var s=b=>{var S=tX();I(b,S)},o=b=>{var S=eX();I(b,S)},l=b=>{},a=b=>{var S=iX();I(b,S)},c=b=>{var S=nX();I(b,S)},h=b=>{var S=rX();I(b,S)},u=b=>{var S=sX();I(b,S)},f=b=>{var S=oX();I(b,S)},d=b=>{var S=lX();I(b,S)},O=b=>{var S=aX();I(b,S)},p=b=>{},m=b=>{},g=b=>{var S=cX();I(b,S)};Ft(r,b=>{t.name==="sort-ascending"?b(s):t.name==="sort-descending"?b(o,1):t.name==="align-none"?b(l,2):t.name==="align-left"?b(a,3):t.name==="align-center"?b(c,4):t.name==="align-right"?b(h,5):t.name==="move-up"?b(u,6):t.name==="move-right"?b(f,7):t.name==="move-down"?b(d,8):t.name==="move-left"?b(O,9):t.name==="duplicate"?b(p,10):t.name==="clear"?b(m,11):t.name==="remove"&&b(g,12)})}I(i,e)}var uX=ot('<div class="tbl-menu-item-text"><!></div>');function Xe(i,t){var e=uX(),n=Ue(e);Qr(n,()=>t.children),I(i,e)}var fX=ot('<div class="tbl-menu-separator"></div>');function fa(i){var t=fX();I(i,t)}var dX=ot('<div class="tbl-select-all-overlay" aria-hidden="true"></div>');function OX(i){var t=dX();I(i,t)}const pX=new Set([bt.c,bt.v,bt.x]);function mX(i,t){return pX.has(i.key)&&i[tR(t)]}const gX=[bt.backspace,bt.delete],bX=new Set(gX);function wX({key:i}){return bX.has(i)?i:void 0}function SX(i){return/^F\d+$/.test(i)}const vX=new Set([bt.alt,bt.escape,bt.enter,bt.shift]);function xX({metaKey:i,ctrlKey:t,key:e}){return!t&&!i&&!vX.has(e)&&!SX(e)}function yX(i,t){t.selection.isCell()||lv({tableState:t,event:i})}function kX(i,t){t.selection.isCell()||av({tableState:t,event:i})}function QX(i,t){t.selection.isCell()||Id({tableState:t,event:i})}function $X(i,t){if(E(i.target)&&E(hv(i.target))){i.preventDefault();return}if(!t.interactive||t.selection.isCell())return;const e=dv(i);if(E(e)){th.navigate({tableState:t,key:e,event:i,position:{left:!0,top:!0,right:!0,bottom:!0}});return}const n=wX(i);if(E(n)){ov({tableState:t,event:i});return}if(t.activeTable&&E(t.activeCell)&&xX(i)){t.activeTable=!1,t.anchorCell=t.activeCell;const r=t.table.cellAt(t.activeCell).length;t.selectionValue={cell:t.activeCell,section:{head:r,anchor:r}},t.outlinedSection=rt.ofCell(t.activeCell);return}mX(i,t.window)||ck(t.rootEditor,i,"editor")&&i.preventDefault()}function Vd(i){return i.buttons===1}function pv(i,t){return t.setPointerCapture(i.pointerId),()=>t.releasePointerCapture(i.pointerId)}class eh{constructor({offset:t,maxScroll:e,boundaryElement:n,scrollElement:r}){P(this,"offset");P(this,"maxScroll");P(this,"boundaryElement");P(this,"scrollElement");P(this,"scroll");P(this,"handle");P(this,"xAmount");P(this,"yAmount");const s=this.scrollInternal.bind(this);this.scroll=()=>{this.handle=requestAnimationFrame(s)},this.xAmount=0,this.yAmount=0,this.offset=t??0,this.maxScroll=e,this.boundaryElement=n,this.scrollElement=r}updatePosition(t,e){const n=this.boundaryElement.x.getBoundingClientRect();t<n.left+this.offset?this.xAmount=-ce(this.offset+(n.left-t),{max:this.maxScroll}):t>n.right-this.offset?this.xAmount=ce(this.offset-(n.right-t),{max:this.maxScroll}):this.xAmount=0;const r=this.boundaryElement.y.getBoundingClientRect();e<r.top+this.offset?this.yAmount=-ce(this.offset+(r.top-e),{max:this.maxScroll}):e>r.bottom-this.offset?this.yAmount=ce(this.offset-(r.bottom-e),{max:this.maxScroll}):this.yAmount=0,W(this.handle)&&(this.xAmount!==0||this.yAmount!==0)&&this.scroll()}destroy(){E(this.handle)&&cancelAnimationFrame(this.handle)}scrollInternal(){if(this.xAmount===0&&this.yAmount===0){this.scroll();return}this.scrollElement.x.scrollBy({left:this.xAmount}),this.scrollElement.y.scrollBy({top:this.yAmount}),this.scroll()}static of(t){return new eh(t)}}class wc{constructor({start:t,size:e}){P(this,"start");P(this,"size");this.start=t,this.size=e}get mid(){return this.start+this.size/2}get end(){return this.start+this.size}static of(t){return new wc(t)}}var Sc;(i=>{function t(e,n){return Bd.of(e,n)}i.of=t})(Sc||(Sc={}));class Bd{constructor(t,e){P(this,"rows");P(this,"cols");P(this,"firstRowIndex",0);P(this,"firstColIndex",0);const n=[...t.querySelectorAll("tr:first-child > th")],r=[...t.querySelectorAll("tr > th:first-child,tr > td:first-child")];this.rows=r.map((s,o)=>{const{top:l,height:a}=ag(s,e),c=0;return wc.of({start:l+c,size:a-c})}),this.cols=n.map((s,o)=>{const{left:l,width:a}=ag(s,e),c=o===0?1:0;return wc.of({start:l+c,size:a-c})})}rowsOrCols(t){return t==="row"?this.rows:this.cols}rowAt(t){return this.rows[t]}colAt(t){return this.cols[t]}rowOrColAt(t,e){return t==="row"?this.rowAt(e):this.colAt(e)}get firstRow(){return this.rows[this.firstRowIndex]}get firstCol(){return this.cols[this.firstColIndex]}firstRowOrCol(t){return t==="row"?this.firstRow:this.firstCol}get lastRow(){return this.rows[this.lastRowIndex]}get lastCol(){return this.cols[this.lastColIndex]}lastRowOrCol(t){return t==="row"?this.lastRow:this.lastCol}firstRowOrColIndex(t){return 0}get lastRowIndex(){return this.rowCount-1}get lastColIndex(){return this.colCount-1}lastRowOrColIndex(t){return t==="row"?this.lastRowIndex:this.lastColIndex}get rowCount(){return this.rows.length}get colCount(){return this.cols.length}get minRowSize(){return hc(...this.rows.map(t=>t.size))}get minColSize(){return hc(...this.cols.map(t=>t.size))}moveRowOrColAt(t,{fromIndex:e,toIndex:n}){if(e===n)return;const r=this.rowsOrCols(t),s=r[e];if(e<n){for(const o of Cn({start:e,endExclusive:n}))r[o]=r[o+1],r[o].start-=s.size;s.start=r[n].start+r[n].size}else{for(const o of Cn({start:e,endExclusive:n}))r[o]=r[o-1],r[o].start+=s.size;s.start=r[n].start-s.size}r[n]=s}lastCellBeforePosition(t){const e=this.rows.map(r=>r.start).findLastIndex(r=>r<t.y),n=this.cols.map(r=>r.start).findLastIndex(r=>r<t.x);return{row:e===-1?0:e,col:n===-1?0:n}}static of(t,e){return new Bd(t,e)}}function ag(i,t){const{top:e,left:n,width:r,height:s}=i.getBoundingClientRect();return{top:e+t.y,left:n+t.x,width:r,height:s}}class pl{constructor({tableState:t,cellLocation:e}){P(this,"tableState");P(this,"tableMeasurement");P(this,"autoScroller");P(this,"shouldAutoScroll");P(this,"removeEventListeners");P(this,"currentCell");this.tableState=t,this.currentCell=e,this.autoScroller=eh.of({offset:10,maxScroll:32,boundaryElement:{x:t.scrollElement,y:t.rootScrollElement},scrollElement:{x:t.scrollElement,y:t.rootScrollElement}}),this.shouldAutoScroll=M5({delayMillis:500}),this.tableMeasurement=Sc.of(t.tableElement,{x:t.scrollOffsetX,y:t.scrollOffsetY})}start(){this.tableState.activeCell=this.currentCell,this.tableState.anchorCell=this.currentCell,this.tableState.outlinedSection=rt.ofCell(this.currentCell),this.tableState.outline={outlined:!1},this.removeEventListeners=$r(Mt(this.tableState.window,"pointermove",t=>this.drag(t)),Mt(this.tableState.window,"pointerup",()=>this.end()),Mt(this.tableState.window,"pointerleave",()=>this.end()))}resizeAndContinue(t){t.preventDefault(),W(this.tableState.anchorCell)&&(this.tableState.anchorCell=this.currentCell),this.expandOrContract(this.currentCell),this.tableState.outline={outlined:!0},this.removeEventListeners=$r(Mt(this.tableState.window,"pointermove",e=>this.drag(e)),Mt(this.tableState.window,"pointerup",()=>this.end()),Mt(this.tableState.window,"pointerleave",()=>this.end()))}drag(t){if(!Vd(t)){this.end();return}t.preventDefault(),this.shouldAutoScroll()&&this.autoScroller.updatePosition(t.clientX,t.clientY);const e=this.tableMeasurement.lastCellBeforePosition({x:t.clientX+this.tableState.scrollOffsetX,y:t.clientY+this.tableState.scrollOffsetY});Cr(e,this.currentCell)||(this.currentCell=e,this.tableState.outline={outlined:!0},this.expandOrContract(e))}end(){var t;(t=this.removeEventListeners)==null||t.call(this),this.autoScroller.destroy(),this.tableState.outline=void 0}expandOrContract(t){this.tableState.focusTable();const[e,n]=t.row<=this.tableState.anchorCell.row?[t.row,this.tableState.anchorCell.row]:[this.tableState.anchorCell.row,t.row],[r,s]=t.col<=this.tableState.anchorCell.col?[t.col,this.tableState.anchorCell.col]:[this.tableState.anchorCell.col,t.col];this.tableState.outlinedSection=rt.of({row:{start:e,endExclusive:n+1},col:{start:r,endExclusive:s+1}}),this.tableState.activeCell=t}static startOutline(t){new pl(t).start()}static resizeAndContinueOutline(t){new pl(t).resizeAndContinue(t.event)}}function CX(i,t){Wc(t.window)&&(t.hoveredCell=i)}function PX(i){Wc(i.window)&&(i.hoveredCell=void 0)}function TX(i,t,e){if(!(!e.interactive||!Vd(i)))if(i.shiftKey){if(e.selection.isCell()&&Cr(t,e.selection.cell))return;pl.resizeAndContinueOutline({event:i,tableState:e,cellLocation:t})}else pl.startOutline({event:i,tableState:e,cellLocation:t})}const AX=new Intl.Collator(navigator.language,{numeric:!0,sensitivity:"base"});function cg(i,t){return AX.compare(i,t)}function RX({metaKey:i,shiftKey:t,altKey:e,ctrlKey:n,key:r}){return r===bt.escape&&!t&&!e&&!i&&!n}class Wd{constructor({tableState:t,handle:e,point:n}){P(this,"tableState");P(this,"handle");P(this,"point");P(this,"removeEventListeners");this.tableState=t,this.handle=e,this.point=n}get rowOrCol(){return this.handle.location}get index(){return this.handle.index}open(){const t=this.tableState.document.body;this.removeEventListeners=$r(Mt(t,"pointerdown",o=>{o.preventDefault(),(W(o.target)||!VS(this.tableState.menuRootElement,o.target))&&this.close()}),Mt(t,"wheel",o=>o.preventDefault(),{passive:!1}),Mt(t,"keydown",o=>{o.preventDefault(),RX(o)&&this.close()})),this.tableState.focusTable(),this.tableState.activeHandle={state:"active",handle:this.handle},this.tableState.outlinedSection=rt.of(this.rowOrCol==="row"?{row:{start:this.index,endExclusive:this.index+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:this.index,endExclusive:this.index+1}});const e=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=e,this.tableState.anchorCell=e;const n=this.index!==this.tableState.table.firstRowOrColIndex(this.rowOrCol),r=this.index!==this.tableState.table.lastRowOrColIndex(this.rowOrCol);let s=!1;n?s=r?!0:"backward":r&&(s="forward"),this.tableState.menu={type:this.rowOrCol,capabilities:{addable:!0,alignable:this.rowOrCol==="col",clearable:!0,duplicatable:!0,moveable:s,removable:!this.tableState.table.hasSingleRowOrCol(this.rowOrCol),sortable:this.rowOrCol==="col"},clickAdd:o=>this.clickAdd(o),clickAlign:o=>this.clickAlign(o),clickClear:()=>this.clickClear(),clickDuplicate:()=>this.clickDuplicate(),clickMove:o=>this.clickMove(o),clickRemove:()=>this.clickRemove(),clickSort:o=>this.clickSort(o),computeTranslation:o=>this.computeTranslation(o)}}close(){var t;(t=this.removeEventListeners)==null||t.call(this),this.tableState.menu=void 0,this.tableState.activeHandle=void 0}async computeTranslation(t){const e=await NT({getBoundingClientRect:()=>({x:this.point.x,y:this.point.y,top:this.point.y,right:this.point.x,bottom:this.point.y,left:this.point.x,width:0,height:0})},t,{middleware:[YT({allowedPlacements:this.rowOrCol==="row"?["right-start","right-end"]:["right-start","right"]}),qT({crossAxis:!0})]}),n=go(t);return{x:bc(e.x,n),y:bc(e.y,n)}}clickAdd(t){var e;if(this.tableState.table.addEmptyRowsOrColsAt(this.rowOrCol,{index:t==="before"?this.index:this.index+1,count:1}),t==="after"){this.tableState.outlinedSection=(e=this.tableState.outlinedSection)==null?void 0:e.shift(this.rowOrCol,"forward");const n=qh(this.rowOrCol,this.tableState.activeCell,"forward");this.tableState.activeCell=n,this.tableState.anchorCell=n}this.close()}clickAlign(t){this.tableState.table.setAlignmentAt(this.index,t),this.close()}clickClear(){this.tableState.table.clearRowOrCol(this.rowOrCol,this.index),this.close()}clickDuplicate(){this.tableState.table.duplicateRowOrColAt(this.rowOrCol,this.index),this.close()}clickMove(t){var n;this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:t==="backward"?this.index-1:this.index+1}),this.tableState.outlinedSection=(n=this.tableState.outlinedSection)==null?void 0:n.shift(this.rowOrCol,t);const e=qh(this.rowOrCol,this.tableState.activeCell,t);this.tableState.activeCell=e,this.tableState.anchorCell=e,this.close()}clickRemove(){var t;if(this.tableState.table.removeRowsOrColsAt(this.rowOrCol,{index:this.index,count:1}),!this.tableState.table.hasRowOrColAt(this.rowOrCol,this.index)){this.tableState.outlinedSection=(t=this.tableState.outlinedSection)==null?void 0:t.shift(this.rowOrCol,"backward");const e=qh(this.rowOrCol,this.tableState.activeCell,"backward");this.tableState.activeCell=e,this.tableState.anchorCell=e}this.close()}clickSort(t){this.tableState.table.sortByColAt(this.index,t==="ascending"?(e,n)=>cg(e.toString(),n.toString()):(e,n)=>cg(n.toString(),e.toString())),this.close()}static showMenu(t){new Wd(t).open()}}class Yd{constructor({rowOrCol:t,index:e,position:n,subject:r,tableElement:s,scrollOffsetX:o,scrollOffsetY:l}){P(this,"coordinate");P(this,"initialIndex");P(this,"size");P(this,"initialPosition");P(this,"minBound");P(this,"maxBound");P(this,"scrollOffsetX");P(this,"scrollOffsetY");P(this,"subject");P(this,"rowOrCol");P(this,"tableMeasurement");P(this,"currentIndex");P(this,"currentPosition");P(this,"dragged");this.scrollOffsetX=o,this.scrollOffsetY=l;const a=Sc.of(s,{x:this.scrollOffsetX(),y:this.scrollOffsetY()});this.rowOrCol=t,this.coordinate=t==="row"?"y":"x",this.initialIndex=e,this.initialPosition=n[this.coordinate],this.minBound=a.firstRowOrCol(this.rowOrCol).start-a.rowOrColAt(this.rowOrCol,e).start,this.maxBound=a.lastRowOrCol(this.rowOrCol).end-a.rowOrColAt(this.rowOrCol,e).end,this.size=a.rowOrColAt(this.rowOrCol,e).size,this.subject=r,this.dragged=!1,this.tableMeasurement=a,this.currentIndex=e,this.currentPosition=n[this.coordinate]}start(){return{cellMovement:t=>this.cellMovement(t)}}drag(t){this.currentPosition=t[this.coordinate];const{currentIndex:e,move:n}=this.calculateDrag();return this.currentIndex=e,this.initialIndex!==this.currentIndex&&(this.dragged=!0),E(n)&&this.tableMeasurement.moveRowOrColAt(this.rowOrCol,n),{cellMovement:r=>this.cellMovement(r)}}end(){return this.initialIndex===this.currentIndex?{moved:!1,dragged:this.dragged}:{moved:!0,toIndex:this.currentIndex}}cellMovement(t){return{border:this.cellBorder(t),state:this.cellState(t),translate:this.cellTranslate(t)}}cellBorder(t){const e=this.isRowOrColExposed(t[this.rowOrCol]),n=this.subject.containsCell(t);return this.rowOrCol==="row"?{top:e,right:!0,bottom:!n||t.row===this.tableMeasurement.lastRowIndex,left:this.tableMeasurement.firstColIndex===t.col}:{top:this.tableMeasurement.firstRowIndex===t.row,right:!n||t.col===this.tableMeasurement.lastColIndex,bottom:!0,left:e}}cellState(t){return this.subject.containsCell(t)?"moving":"shiftable"}cellTranslate(t){const e=this.rowOrColTranslate(t[this.rowOrCol]);return this.rowOrCol==="row"?{x:0,y:e}:{x:e,y:0}}isRowOrColExposed(t){const e=this.reorderIndex(t),n=e===this.tableMeasurement.firstRowOrColIndex(this.rowOrCol),r=e===this.currentIndex+1;return n||r}get rowOrColShift(){if(this.currentIndex!==this.initialIndex)return this.currentIndex<this.initialIndex?{direction:"forwards",range:{start:this.currentIndex,endExclusive:this.initialIndex},indexDiff:1,positionDiff:this.size-1}:{direction:"backwards",range:{start:this.initialIndex+1,endExclusive:this.currentIndex+1},indexDiff:-1,positionDiff:1-this.size}}rowOrColTranslate(t){if(t===this.initialIndex)return ce(this.currentPosition-this.initialPosition,{min:this.minBound,max:this.maxBound});const e=this.rowOrColShift;return W(e)?0:Qn(t,e.range)?e.positionDiff:0}reorderIndex(t){const e=this.rowOrColShift;return W(e)?t:t===this.initialIndex?this.currentIndex:Qn(t,e.range)?t+e.indexDiff:t}calculateDrag(){const t=this.tableMeasurement.rowsOrCols(this.rowOrCol),e={name:"current",index:this.currentIndex,mid:t[this.currentIndex].mid},n=this.currentIndex!==this.tableMeasurement.firstRowOrColIndex(this.rowOrCol)?{name:"left",index:this.currentIndex-1,mid:t[this.currentIndex-1].start+t[this.currentIndex].size/2}:void 0,r=this.currentIndex!==this.tableMeasurement.lastRowOrColIndex(this.rowOrCol)?{name:"right",index:this.currentIndex+1,mid:t[this.currentIndex].start+t[this.currentIndex+1].size+t[this.currentIndex].size/2}:void 0,s=kA(QA([e,n,r]),(o,l)=>Uu(this.currentPosition-o.mid)-Uu(this.currentPosition-l.mid));return s.name==="current"?{currentIndex:this.currentIndex,move:void 0}:{currentIndex:s.index,move:{fromIndex:this.currentIndex,toIndex:s.index}}}static of(t){return new Yd(t)}}class qd{constructor({event:t,tableState:e,rowOrCol:n,index:r,onClick:s}){P(this,"tableState");P(this,"rowOrCol");P(this,"index");P(this,"onClick");P(this,"moveTracker");P(this,"subject");P(this,"autoScroller");P(this,"removeEventListeners");this.tableState=e,this.rowOrCol=n,this.index=r,this.subject=rt.of(n==="row"?{row:{start:r,endExclusive:r+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:r,endExclusive:r+1}}),this.onClick=s,this.autoScroller=eh.of({offset:16,maxScroll:32,boundaryElement:{x:e.scrollElement,y:e.rootScrollElement},scrollElement:{x:e.scrollElement,y:e.rootScrollElement}}),this.moveTracker=Yd.of({subject:this.subject,rowOrCol:n,index:r,position:{x:t.clientX+e.scrollOffsetX,y:t.clientY+e.scrollOffsetY},tableElement:e.tableElement,scrollOffsetX:()=>this.tableState.scrollOffsetX,scrollOffsetY:()=>this.tableState.scrollOffsetY})}start(t){t.preventDefault();const e=this.moveTracker.start();this.tableState.outlinedSection=this.subject,this.tableState.move=e,this.tableState.activeHandle={state:"active",handle:{type:"header",index:this.index,location:this.rowOrCol}};const n=this.rowOrCol==="row"?{row:this.index,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:this.index};this.tableState.activeCell=n,this.tableState.anchorCell=n,this.tableState.focusTable();const r=Ed(t.target);this.removeEventListeners=$r(pv(t,r),Mt(r,"pointermove",s=>this.drag(s)),Mt(r,"pointerup",()=>this.end()))}drag(t){t.preventDefault(),this.autoScroller.updatePosition(t.clientX,t.clientY),this.tableState.move=this.moveTracker.drag({x:t.clientX+this.tableState.scrollOffsetX,y:t.clientY+this.tableState.scrollOffsetY})}end(){var e;(e=this.removeEventListeners)==null||e.call(this),this.autoScroller.destroy();const t=this.moveTracker.end();if(t.moved){this.tableState.table.moveRowOrColAt(this.rowOrCol,{fromIndex:this.index,toIndex:t.toIndex}),this.tableState.outlinedSection=rt.of(this.rowOrCol==="row"?{row:{start:t.toIndex,endExclusive:t.toIndex+1},col:this.tableState.table.colRange}:{row:this.tableState.table.rowRange,col:{start:t.toIndex,endExclusive:t.toIndex+1}});const n=this.rowOrCol==="row"?{row:t.toIndex,col:this.tableState.table.lastColIndex}:{row:this.tableState.table.lastRowIndex,col:t.toIndex};this.tableState.activeCell=n,this.tableState.anchorCell=n}this.tableState.move=void 0,this.tableState.activeHandle=void 0,!t.moved&&!t.dragged&&this.onClick()}static startMove(t){new qd(t).start(t.event)}}function ZX(i){return i==="row"?"y":"x"}class Nd{constructor({tableState:t,handle:e,position:n,cellSizePixels:r,dragThresholdPixels:s}){P(this,"tableState");P(this,"type");P(this,"initialHandle");P(this,"initialRowOrColCount");P(this,"initialPosition");P(this,"initialOutlinedSection");P(this,"initialActiveCell");P(this,"initialAnchorCell");P(this,"cellSizePixels");P(this,"dragThresholdPixels");P(this,"dragged");this.tableState=t,this.type=this.handleToType(e),this.initialHandle=e,this.initialPosition=n,this.initialRowOrColCount={row:t.table.rowCount,col:t.table.colCount},this.initialActiveCell=t.activeCell,this.initialAnchorCell=t.anchorCell,this.initialOutlinedSection=t.outlinedSection,this.cellSizePixels=r,this.dragThresholdPixels=s,this.dragged=!1}start(){return{activeHandle:{state:"active",handle:this.initialHandle}}}drag(t){return this.dragged=!0,this.calculateDrag(t)}end(){return this.dragged?{activeHandle:void 0}:this.calculateClick()}calculateClick(){if(this.type!=="table")return this.calculateClickRowOrCol(this.type);if(this.initialHandle.location==="right")return this.calculateClickRowOrCol("col");if(this.initialHandle.location==="bottom")return this.calculateClickRowOrCol("row");const t=this.calculateClickRowOrCol("row"),e=this.calculateClickRowOrCol("col");return{operation:{row:t.operation.row,col:e.operation.col},activeHandle:t.activeHandle,activeCell:E(t.activeCell)&&E(e.activeCell)?{row:t.activeCell.row,col:e.activeCell.col}:void 0,anchorCell:E(t.anchorCell)&&E(e.anchorCell)?{row:t.anchorCell.row,col:e.anchorCell.col}:void 0,outlinedSection:E(t.outlinedSection)&&E(e.outlinedSection)?rt.of({row:t.outlinedSection.row,col:e.outlinedSection.col}):void 0}}calculateClickRowOrCol(t){const e=this.type==="table"?this.tableState.table.lastRowOrColIndex(t)+1:this.initialHandle.index;return{operation:{[t]:{action:"add",index:e,count:1}},activeHandle:this.type==="table"?void 0:{state:"hover",handle:{type:"border",location:this.handleLocationAt(e),index:e}},...this.calculateCellMovement(t,1)}}calculateDrag(t){if(this.type!=="table")return this.calculateDragRowOrCol(this.type,t);if(this.initialHandle.location==="right")return this.calculateDragRowOrCol("col",t);if(this.initialHandle.location==="bottom")return this.calculateDragRowOrCol("row",t);const e=this.calculateDragRowOrCol("row",t),n=this.calculateDragRowOrCol("col",t);if(W(e)&&W(n))return;const r=e??this.calculateCellMovement("row",this.rowOrColDiff("row")),s=n??this.calculateCellMovement("col",this.rowOrColDiff("col"));return{operation:{row:e==null?void 0:e.operation.row,col:n==null?void 0:n.operation.col},activeHandle:(e==null?void 0:e.activeHandle)??(n==null?void 0:n.activeHandle),activeCell:E(r.activeCell)&&E(s.activeCell)?{row:r.activeCell.row,col:s.activeCell.col}:void 0,anchorCell:E(r.anchorCell)&&E(s.anchorCell)?{row:r.anchorCell.row,col:s.anchorCell.col}:void 0,outlinedSection:E(r.outlinedSection)&&E(s.outlinedSection)?rt.of({row:r.outlinedSection.row,col:s.outlinedSection.col}):void 0}}calculateDragRowOrCol(t,e){const n=ZX(t),r=e.position[n]-this.initialPosition[n],s=AA(r/this.cellSizePixels[t]),o=r%this.cellSizePixels[t]>=this.dragThresholdPixels[t]?1:0,l=this.tableState.table.rowOrColCount(t)-this.initialRowOrColCount[t],a=s+o-l,c=this.type==="table"?this.tableState.table.lastRowOrColIndex(t)+1:this.initialHandle.index+l;if(a!==0)return a>0?this.calculateDragRowOrColMore({rowOrCol:t,start:c,length:a}):this.calculateDragRowOrColLess({rowOrCol:t,start:c,length:hc(-a,c,this.tableState.table.lastRowOrColIndex(t))})}calculateDragRowOrColLess({rowOrCol:t,start:e,length:n}){let r=0;for(const o of Cn({start:e-1,endExclusive:e-n-1})){if(!this.tableState.table.hasEmptyRowOrColAt(t,o))break;r++}if(r===0)return;const s=e-(r-1)-1;return{operation:{[t]:{action:"remove",index:e-r,count:r}},activeHandle:this.type==="table"?{state:"active",handle:this.initialHandle}:{state:"active",handle:{type:"border",location:this.handleLocationAt(s),index:s}},...this.calculateCellMovement(t,this.rowOrColDiff(t)-r)}}calculateDragRowOrColMore({rowOrCol:t,start:e,length:n}){return{operation:{[t]:{action:"add",index:e,count:n}},activeHandle:{state:"active",handle:this.type==="table"?this.initialHandle:{type:"border",location:this.handleLocationAt(e+n),index:e+n}},...this.calculateCellMovement(t,this.rowOrColDiff(t)+n)}}calculateCellMovement(t,e){var r,s;const n=this.type==="table"?this.initialRowOrColCount[t]:this.initialHandle.index;if(e>=0)return{outlinedSection:(r=this.initialOutlinedSection)==null?void 0:r.addForwardsByRowOrCol(t,{start:n,count:e}),activeCell:E(this.initialActiveCell)?Km(t,this.initialActiveCell,{start:n,count:e}):void 0,anchorCell:E(this.initialAnchorCell)?Km(t,this.initialAnchorCell,{start:n,count:e}):void 0};{const o=-e,l=(s=this.initialOutlinedSection)==null?void 0:s.subtractBackwardsByRowOrCol(t,{start:n,count:o,min:this.tableState.table.firstRowOrColIndex(t)}),a=E(l)?{min:l.startRowOrCol(t),max:l.endRowOrCol(t)}:void 0,c=E(this.initialActiveCell)?Jm(t,this.initialActiveCell,{start:n,count:o,boundary:a}):void 0,h=E(this.initialAnchorCell)?Jm(t,this.initialAnchorCell,{start:n,count:o,boundary:a}):void 0;return{outlinedSection:l,activeCell:c,anchorCell:h}}}rowOrColDiff(t){return this.tableState.table.rowOrColCount(t)-this.initialRowOrColCount[t]}handleLocationAt(t){if(this.type!=="table")return this.type==="row"&&t===this.tableState.table.firstRowIndex?"top":this.type==="col"&&t===this.tableState.table.firstColIndex?"left":this.type}handleToType(t){return t.type==="table"?"table":t.location==="top"?"row":t.location==="left"?"col":t.location}static of(t){return new Nd(t)}}function XX(i){const t=mc(i.tableElement,i.table.firstCellLocation),e=CZ(t),{minWidth:n}=getComputedStyle(t),{lineHeight:r,paddingTop:s,paddingBottom:o}=getComputedStyle(e),l=parseFloat(n)+1,a=parseFloat(r)+parseFloat(s)+parseFloat(o)+1;return{width:l,height:a}}class Gd{constructor({event:t,tableState:e,handle:n}){P(this,"tableState");P(this,"resizeTracker");P(this,"removeEventListeners");this.tableState=e;const{width:r,height:s}=XX(e);this.resizeTracker=Nd.of({tableState:this.tableState,handle:n,position:{x:t.clientX,y:t.clientY},cellSizePixels:{row:s,col:r},dragThresholdPixels:{row:s/2,col:r/2}})}start(t){t.preventDefault();const e=this.resizeTracker.start();this.tableState.resize={},this.tableState.activeHandle=e.activeHandle,this.tableState.focusTable(),this.removeEventListeners=$r(pv(t,this.tableState.tableElement),Mt(this.tableState.tableElement,"pointermove",n=>this.drag(n)),Mt(this.tableState.tableElement,"pointerup",()=>this.end()))}drag(t){t.preventDefault();const e=this.resizeTracker.drag({position:{x:t.clientX,y:t.clientY}});E(e)&&(this.resizeTable(e.operation),this.tableState.activeHandle=e.activeHandle,this.tableState.activeCell=e.activeCell,this.tableState.anchorCell=e.anchorCell,this.tableState.outlinedSection=e.outlinedSection)}end(){var e;(e=this.removeEventListeners)==null||e.call(this);const t=this.resizeTracker.end();"operation"in t&&(this.resizeTable(t.operation),this.tableState.activeCell=t.activeCell,this.tableState.anchorCell=t.anchorCell,this.tableState.outlinedSection=t.outlinedSection),this.tableState.activeHandle=t.activeHandle,this.tableState.resize=void 0}resizeTable({row:t,col:e}){if(E(t)){const{action:n,index:r,count:s}=t;n==="add"?this.tableState.table.addEmptyRowsAt({row:r,count:s}):this.tableState.table.removeRowsAt({row:r,count:s})}if(E(e)){const{action:n,index:r,count:s}=e;n==="add"?this.tableState.table.addEmptyColsAt({col:r,count:s}):this.tableState.table.removeColsAt({col:r,count:s})}}static startResize(t){new Gd(t).start(t.event)}}function EX(i,t){t.interactive&&(t.activeHandle={state:"hover",handle:i})}function LX(i){i.interactive&&(i.activeHandle=void 0)}function MX(i,t,e){if(e.interactive){if(!Vd(i)){i.preventDefault();return}t.type==="table"||t.type==="border"?Gd.startResize({event:i,handle:t,tableState:e}):t.type==="header"&&qd.startMove({event:i,rowOrCol:t.location,index:t.index,tableState:e,onClick:()=>Wd.showMenu({handle:t,point:{x:i.clientX,y:i.clientY},tableState:e})})}}function zX(i,t){const e=i.target;if(W(e))return;const n=Dd(e);if(E(n)){EX(n,t);return}const r=_l(e);if(E(r)){CX(Kc(r),t);return}}function _X(i,t){const e=i.target;if(W(e))return;const n=Dd(e);if(E(n)){LX(t);return}const r=_l(e);if(E(r)){PX(t);return}}function IX(i,t){const e=i.target;if(W(e))return;const n=Dd(e);if(E(n)){MX(i,n,t);return}const r=_l(e);if(E(r)){TX(i,Kc(r),t);return}i.preventDefault()}function jX(i){i.preventDefault()}var DX=ot("<!> <!> <!>",1),VX=ot('<tr class="tbl-table-row"></tr>'),BX=ot('<tbody class="tbl-table-body"></tbody>'),WX=ot("<!> <!>",1),YX=ot("<!> <!>",1),qX=ot("<!> <!> <!>",1),NX=ot("<!> <!>",1),GX=ot("<!> <!>",1),UX=ot("<!> <!>",1),HX=ot("<!> <!>",1),FX=ot("<!> <!> <!> <!> <!>",1),KX=ot("<!> <!>",1),JX=ot("<!> <!>",1),tE=ot("<!> <!> <!>",1),eE=ot("<!> <!>",1),iE=ot("<!> <!>",1),nE=ot("<!> <!> <!>",1),rE=ot("<!> <!>",1),sE=ot("<!> <!>",1),oE=ot("<!> <!>",1),lE=ot("<!> <!> <!> <!> <!> <!> <!>",1),aE=ot('<div class="tbl-table-wrapper"><table class="tbl-table" role="grid" tabindex="-1"><thead class="tbl-table-head"><!></thead><!></table> <!> <!> <!> <!></div>');function cE(i,t){Wn(t,!0);const e=wf.of({table:()=>t.table,selection:()=>t.selection,scrollElement:()=>t.scrollElement,rootEditor:()=>t.rootEditor,menuRootElement:()=>t.menuRootElement,extensions:()=>t.extensions,markdownConfig:()=>t.markdownConfig,globalKeyBindings:()=>t.globalKeyBindings,selectionType:()=>t.selectionType,lineWrapping:()=>t.lineWrapping,onUndo:()=>t.onUndo,onRedo:()=>t.onRedo,onNavigate:()=>t.onNavigate,onDelete:()=>t.onDelete});Uc(()=>$r(Mt(e.document,"selectionchange",()=>PZ(e)),Mt(e.document.body,"pointerdown",()=>vZ(e),{capture:!0,passive:!0}),Mt(e.document.body,"pointerup",()=>xZ(e),{capture:!0,passive:!0}),Mt(e.document.body,"pointerleave",()=>yZ(e),{capture:!0,passive:!0}),Mt(e.document.body,"copy",x=>kZ(x,e)),Mt(e.document.body,"cut",x=>QZ(x,e)),Mt(e.document.body,"paste",x=>$Z(x,e))));var n=aE(),r=Ue(n);{const x=(y,k=N1)=>{var Q=VX();ca(Q,20,()=>e.table.colIndices,Z=>Z,(Z,D)=>{const L=F(()=>({row:k(),col:D})),B=F(()=>({top:k()===e.table.firstRowIndex,left:D===e.table.firstColIndex})),_=F(()=>e.selection.isCell()&&Cr($(L),e.selection.cell));{let G=F(()=>{var H;return((H=e.outlinedSection)==null?void 0:H.containsOnEdge($(L)))??{top:!1,right:!1,bottom:!1,left:!1}}),U=F(()=>{var H;return(H=e.move)==null?void 0:H.cellMovement($(L))});zZ(Z,{get location(){return $(L)},get alignment(){return e.table.alignments[D]},get selected(){return $(_)},get position(){return $(B)},get outline(){return $(G)},get movement(){return $(U)},get win(){return e.window},children:(H,Xt)=>{var _t=DX(),Yt=Et(_t);ca(Yt,16,()=>mZ($(L),$(B)),yt=>yt,(yt,Nt)=>{{let re=F(()=>e.cellHandleState($(L),Nt)),be=F(()=>E(e.resize));lg(yt,{get of(){return Nt},get state(){return $(re)},get toggle(){return $(be)}})}});var lt=et(Yt,2);NZ(lt,{get hidden(){return $(_)},children:(yt,Nt)=>{var re=Xd(),be=Et(re);y5(be,()=>fZ(e.table.cellAt($(L)),e.highlighter($(L)))),I(yt,re)},$$slots:{default:!0}});var Vt=et(lt,2);{var $e=yt=>{var Nt=()=>e.table.cellAt($(L)),re=pt=>e.table.setCellAt($(L),pt),be=()=>e.selection.cellSection,tt=pt=>{e.selectionValue={cell:$(L),section:pt}};{let pt=F(()=>e.highlighter($(L)));jZ(yt,{get text(){return Nt()},set text(mt){re(mt)},get selection(){return be()},set selection(mt){tt(mt)},get selectionType(){return e.selectionType},get lineWrapping(){return e.lineWrapping},get extensions(){return e.extensions},get markdownConfig(){return e.markdownConfig},get rootEditor(){return e.rootEditor},get globalKeyBindings(){return e.globalKeyBindings},get highlighter(){return $(pt)},onbeforeinput:mt=>VZ(mt,e),ondragstart:mt=>BZ(mt),onkeydown:(mt,At)=>WZ(mt,At,e),onpaste:mt=>YZ(mt,e)})}};Ft(Vt,yt=>{$(_)&&yt($e)})}I(H,_t)},$$slots:{default:!0}})}}),I(y,Q)};var s=Ue(r),o=Ue(s);x(o,()=>e.table.headerRowIndex);var l=et(s);{var a=y=>{var k=BX();ca(k,20,()=>e.table.dataRowIndices,Q=>Q,(Q,Z)=>{x(Q,()=>Z)}),I(y,k)},c=F(()=>e.table.hasDataRows());Ft(l,y=>{$(c)&&y(a)})}Oc(r,y=>e.tableElement=y,()=>e==null?void 0:e.tableElement)}var h=et(r,2);{var u=x=>{const y=F(()=>e.menu.type==="row"?"row":"column");RZ(x,{get to(){return e.menuRootElement},children:(k,Q)=>{KZ(k,{translate:Z=>e.menu.computeTranslation(Z),children:(Z,D)=>{const L=F(()=>{const{addable:tt,alignable:pt,clearable:mt,duplicatable:At,moveable:Bt,removable:Wt,sortable:fe}=e.menu.capabilities;return{addable:tt,alignable:pt,clearable:mt,duplicatable:At,moveable:Bt,removable:Wt,sortable:fe}});var B=lE(),_=Et(B);{var G=tt=>{var pt=qX(),mt=Et(pt);Ae(mt,{onclick:()=>Re({action:"sort",direction:"ascending"},e),children:(Wt,fe)=>{var ut=WX(),gt=Et(ut);Ze(gt,{name:"sort-ascending"});var It=et(gt,2);Xe(It,{children:(kt,Ut)=>{var Rt=Te();se(()=>qi(Rt,`Sort by ${$(y)??""} (A-Z)`)),I(kt,Rt)}}),I(Wt,ut)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"sort",direction:"descending"},e),children:(Wt,fe)=>{var ut=YX(),gt=Et(ut);Ze(gt,{name:"sort-descending"});var It=et(gt,2);Xe(It,{children:(kt,Ut)=>{var Rt=Te();se(()=>qi(Rt,`Sort by ${$(y)??""} (Z-A)`)),I(kt,Rt)}}),I(Wt,ut)}});var Bt=et(At,2);fa(Bt),I(tt,pt)};Ft(_,tt=>{$(L).sortable&&tt(G)})}var U=et(_,2);{var H=tt=>{var pt=FX(),mt=Et(pt);Ae(mt,{onclick:()=>Re({action:"align",alignment:"none"},e),children:(ut,gt)=>{var It=NX(),kt=Et(It);Ze(kt,{name:"align-none"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,ii)=>{var Wi=Te("Align none");I(Rt,Wi)}}),I(ut,It)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"align",alignment:"left"},e),children:(ut,gt)=>{var It=GX(),kt=Et(It);Ze(kt,{name:"align-left"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,ii)=>{var Wi=Te("Align left");I(Rt,Wi)}}),I(ut,It)}});var Bt=et(At,2);Ae(Bt,{onclick:()=>Re({action:"align",alignment:"center"},e),children:(ut,gt)=>{var It=UX(),kt=Et(It);Ze(kt,{name:"align-center"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,ii)=>{var Wi=Te("Align center");I(Rt,Wi)}}),I(ut,It)}});var Wt=et(Bt,2);Ae(Wt,{onclick:()=>Re({action:"align",alignment:"right"},e),children:(ut,gt)=>{var It=HX(),kt=Et(It);Ze(kt,{name:"align-right"});var Ut=et(kt,2);Xe(Ut,{children:(Rt,ii)=>{var Wi=Te("Align right");I(Rt,Wi)}}),I(ut,It)}});var fe=et(Wt,2);fa(fe),I(tt,pt)};Ft(U,tt=>{$(L).alignable&&tt(H)})}var Xt=et(U,2);{var _t=tt=>{var pt=tE(),mt=Et(pt);Ae(mt,{onclick:()=>Re({action:"add",direction:"before"},e),children:(Wt,fe)=>{var ut=KX(),gt=Et(ut);Ze(gt,{name:"add-before"});var It=et(gt,2);Xe(It,{children:(kt,Ut)=>{var Rt=Te();se(()=>qi(Rt,`Add ${$(y)??""} ${$(y)==="row"?"above":"before"}`)),I(kt,Rt)}}),I(Wt,ut)}});var At=et(mt,2);Ae(At,{onclick:()=>Re({action:"add",direction:"after"},e),children:(Wt,fe)=>{var ut=JX(),gt=Et(ut);Ze(gt,{name:"add-after"});var It=et(gt,2);Xe(It,{children:(kt,Ut)=>{var Rt=Te();se(()=>qi(Rt,`Add ${$(y)??""} ${$(y)==="row"?"below":"after"}`)),I(kt,Rt)}}),I(Wt,ut)}});var Bt=et(At,2);fa(Bt),I(tt,pt)};Ft(Xt,tt=>{$(L).addable&&tt(_t)})}var Yt=et(Xt,2);{var lt=tt=>{var pt=nE(),mt=Et(pt);{var At=ut=>{Ae(ut,{onclick:()=>Re({action:"move",direction:"backward"},e),children:(gt,It)=>{var kt=eE(),Ut=Et(kt);{let ii=F(()=>`move-${$(y)==="row"?"up":"left"}`);Ze(Ut,{get name(){return $(ii)}})}var Rt=et(Ut,2);Xe(Rt,{children:(ii,Wi)=>{var bo=Te();se(()=>qi(bo,`Move ${$(y)??""} ${$(y)==="row"?"up":"left"}`)),I(ii,bo)}}),I(gt,kt)}})};Ft(mt,ut=>{($(L).moveable==="backward"||$(L).moveable===!0)&&ut(At)})}var Bt=et(mt,2);{var Wt=ut=>{Ae(ut,{onclick:()=>Re({action:"move",direction:"forward"},e),children:(gt,It)=>{var kt=iE(),Ut=Et(kt);{let ii=F(()=>`move-${$(y)==="row"?"down":"right"}`);Ze(Ut,{get name(){return $(ii)}})}var Rt=et(Ut,2);Xe(Rt,{children:(ii,Wi)=>{var bo=Te();se(()=>qi(bo,`Move ${$(y)??""} ${$(y)==="row"?"down":"right"}`)),I(ii,bo)}}),I(gt,kt)}})};Ft(Bt,ut=>{($(L).moveable==="forward"||$(L).moveable===!0)&&ut(Wt)})}var fe=et(Bt,2);fa(fe),I(tt,pt)};Ft(Yt,tt=>{$(L).moveable!==!1&&tt(lt)})}var Vt=et(Yt,2);{var $e=tt=>{Ae(tt,{onclick:()=>Re({action:"duplicate"},e),children:(pt,mt)=>{var At=rE(),Bt=Et(At);Ze(Bt,{name:"duplicate"});var Wt=et(Bt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>qi(gt,`Duplicate ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(Vt,tt=>{$(L).duplicatable&&tt($e)})}var yt=et(Vt,2);{var Nt=tt=>{Ae(tt,{onclick:()=>Re({action:"clear"},e),children:(pt,mt)=>{var At=sE(),Bt=Et(At);Ze(Bt,{name:"clear"});var Wt=et(Bt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>qi(gt,`Clear ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(yt,tt=>{$(L).clearable&&tt(Nt)})}var re=et(yt,2);{var be=tt=>{Ae(tt,{onclick:()=>Re({action:"remove"},e),children:(pt,mt)=>{var At=oE(),Bt=Et(At);Ze(Bt,{name:"remove"});var Wt=et(Bt,2);Xe(Wt,{children:(fe,ut)=>{var gt=Te();se(()=>qi(gt,`Delete ${$(y)??""}`)),I(fe,gt)}}),I(pt,At)}})};Ft(re,tt=>{$(L).removable&&tt(be)})}I(Z,B)},$$slots:{default:!0}})},$$slots:{default:!0}})},f=F(()=>E(e.menu));Ft(h,x=>{$(f)&&x(u)})}var d=et(h,2);ca(d,16,()=>pZ,x=>x,(x,y)=>{{let k=F(()=>{var Q;return bf((Q=e.activeHandle)==null?void 0:Q.handle,y)?e.activeHandle.state:void 0});lg(x,{get of(){return y},get state(){return $(k)}})}});var O=et(d,2);{var p=x=>{XZ(x)},m=F(()=>!e.interactive&&W(e.outline));Ft(O,x=>{$(m)&&x(p)})}var g=et(O,2);{var b=x=>{OX(x)},S=F(()=>e.selection.isAll());Ft(g,x=>{$(S)&&x(b)})}Oc(n,x=>e.wrapperElement=x,()=>e==null?void 0:e.wrapperElement),se(x=>Qt(n,"data-select-all",x),[()=>br(e.selection.isAll())]),Eo("mouseover",n,x=>zX(x,e)),Eo("mouseout",n,x=>_X(x,e)),Eo("pointerdown",n,x=>IX(x,e)),la("dragover",n,x=>jX(x)),Eo("keydown",r,x=>$X(x,e)),la("copy",r,x=>yX(x,e)),la("cut",r,x=>kX(x,e)),la("paste",r,x=>QX(x,e)),I(i,n),Yn()}MS(["mouseover","mouseout","pointerdown","keydown"]);class Ud extends jn{constructor(e,n){super();P(this,"tableDescription");P(this,"widgetElement");P(this,"height");P(this,"destroyWidgetElement");this.tableDescription=e;const r=vE(n);if(E(r)){const{widgetElement:s,destroyWidgetElement:o}=this.create(r);this.widgetElement=s,this.destroyWidgetElement=o,this.height=X5(r,s)}else this.widgetElement=void 0,this.destroyWidgetElement=void 0,this.height=Ym}get estimatedHeight(){return this.height}coordsAt(e,n,r){const s=this.tableDescription.table.closestCellAtPosition(n),o=mc(e,s);if(W(o))return null;const l=o.getBoundingClientRect();return{top:l.top,right:l.right,bottom:l.bottom,left:l.left}}toDOM(e){if(E(this.widgetElement))return this.widgetElement;const{widgetElement:n,destroyWidgetElement:r}=this.create(e);return this.widgetElement=n,this.destroyWidgetElement=r,e.requestMeasure({read:()=>{this.height=n.getBoundingClientRect().height}}),n}destroy(e){var n;(n=this.destroyWidgetElement)==null||n.call(this),this.destroyWidgetElement=void 0,this.widgetElement=void 0,this.height=Ym}create(e){const n=fl(e.dom).createElement("div");n.className="tbl-table-widget",n.tabIndex=-1,n.addEventListener("pointerdown",O=>{(O==null?void 0:O.target)===n&&O.preventDefault()});const r=this.tableDescription,s=l5(()=>{Nc(()=>{const O=!r.table.text.eq(r.editorTableText),p=!Fc(r.selection.value,r.editorSelectionValue);if(!O&&!p)return;let m;if(r.selection.isCell()){const{from:b}=r.table.cellSpan(r.selection.cell);m={anchor:r.from+b+r.selection.cellSection.anchor,head:r.from+b+r.selection.cellSection.head}}else r.selection.isAll()?m={anchor:r.from,head:r.to}:r.selection.isHidden()&&(m={anchor:r.from+1,head:r.from+1});const g=O?{from:r.from,to:r.to,insert:r.table.text}:void 0;r.markSynchronized(),e.dispatch({annotations:Rn("table.edit"),changes:g,selection:m})})}),{extensions:o,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h}=bv(e.state),u=zS(cE,{target:n,props:{table:r.table,selection:r.selection,scrollElement:n,rootEditor:e,extensions:o,markdownConfig:l,globalKeyBindings:a,selectionType:c,lineWrapping:h,menuRootElement:yk(e,iv).dom,onUndo:()=>Hf(e),onRedo:()=>Na(e),onNavigate:O=>{e.dispatch({annotations:Rn("table.navigate"),selection:{anchor:O==="before"?r.from-1:r.to+1}}),e.focus()},onDelete:()=>{e.dispatch({annotations:Rn("table.delete"),changes:{from:r.from,to:r.to},selection:e.state.selection}),e.focus()}}}),f=()=>{_S(u)},d=E5(n,({height:O})=>{this.height=O});return{widgetElement:n,destroyWidgetElement:$r(s,f,d)}}static of(e,n){return new Ud(e,n)}}function hE(i,t){return{widget:Ud.of(i,t),block:!0,inclusive:!0}}function uE(i,t){return J.replace(hE(i,t))}function fE(i,t){const e=new Ws;for(const n of i)e.add(n.from,n.to,uE(n,t));return e.finish()}function dE(i){return mv(i)}function OE(i,t){return mv(i,t)}function mv(i,t=[]){const e=[];gA(St(i),s=>{E1(s)&&e.push({from:i.doc.lineAt(s.from).from,to:i.doc.lineAt(s.to).to})});const n=[],r=[];for(const s of e){if(CA(t,s,B1)){n.push(s);continue}const o=pE(s,i);Bc(o)?n.push(s):r.push(...o)}return{spans:n,formatting:r,complete:Wk(i)}}function pE(i,t){return[...mE(i,t),...gE(i,t)]}function mE(i,{doc:t,lineBreak:e}){return bd({doc:t,lineBreak:e,span:i}).changes}function gE({from:i,to:t},{doc:e}){const n=e.slice(i,t),{text:r}=Hu(n);return n.eq(r)?[]:[{from:i,to:t,insert:r}]}const bE={create(i){return da(i)},update(i,t){if(N5(t))return da(t.state);if(!t.docChanged&&W(t.selection)&&i.complete)return i;const{tables:e,formatting:n,decorations:r}=i;if(!t.docChanged&&i.complete)return{tables:hg(e,t),formatting:n,decorations:r.map(t.changes),complete:!0};if(q5(t)||wE(t,e))return da(t.state);const s=hg(e,t).map(c=>c.span),{complete:o,spans:l,formatting:a}=OE(t.state,s);return bn(s,l,B1)?{complete:o,tables:e,formatting:a,decorations:r.map(t.changes)}:da(t.state)},provide(i){return z.decorations.from(i,t=>t.decorations)}},gv=bi.define(bE);function da(i){const{spans:t,formatting:e,complete:n}=dE(i),{doc:r,selection:s}=i,o=t.map(l=>mf.of({span:l,doc:r,selection:s}));return{complete:n,tables:o,formatting:e,decorations:fE(o,i)}}function wE(i,t){return!zd(i)&&t.some(e=>i.changes.touchesRange(e.from,e.to)!==!1)}function hg(i,t){return vA(i,e=>e.applyTransaction(t))}const SE={create(){return{view:void 0}},update(i){return i}},Hd=bi.define(SE);function bv(i){return i.facet(Fu)}function In(i){return i.field(gv)}function vE(i){return i.field(Hd).view}function xE(i){const{handlePosition:t,selectionType:e,lineWrapping:n}=bv(i);return{...Wc(window)?{"data-tbl-hoverable":""}:{},"data-tbl-theme-mode":i.facet(z.darkTheme)?"dark":"light","data-tbl-handle-position":t,"data-tbl-selection-type":e,"data-tbl-line-wrapping":n}}const yE=["undo","redo","select.undo","select.redo"];function kE(i){return yE.some(t=>i.isUserEvent(t))}function QE(i){return wv(i,"select.search")}function $E(i){return wv(i,"select")}function CE(i){return i.isUserEvent("delete.forward")}function PE(i){return i.isUserEvent("delete.backward")}function wv(i,t){return i.annotation(Pt.userEvent)===t}const TE=({state:i,view:t,transactions:e})=>{t.hasFocus||In(i).tables.some(n=>n.containsSelection())||e.some(n=>kE(n)||QE(n)&&!fv(t))&&t.focus()},Sv=Ct.define(),AE=new Map(NS.map(i=>[i,Sv.of(i)]));function vv(i){return AE.get(i)}const RE=(i,t)=>!t||!In(i).tables.some(e=>e.containsSelection())?null:vv("table.focus"),ZE=i=>{const{selection:t,startState:e,docChanged:n}=i;if(W(t)||n||!$E(i)||!oc(t)||!oc(e.selection))return i;const r=e.selection.main,s=t.main;for(const o of In(e).tables){const l=o.from===s.head,a=o.to===s.head,c=o.from===r.head+1&&o.to===s.head-1,h=o.from===s.head+1&&o.to===r.head-1;let u;if(l?u=o.table.firstCellSpan.from:c?u=o.table.firstCellSpan.to:(a||h)&&(u=o.table.lastCellSpan.to),E(u))return[i,{annotation:Rn("table.navigate"),selection:tA({pos:o.from+u})}]}return i},XE=i=>{const{selection:t,startState:e}=i;if(W(t)||!oc(t))return i;const n=e.selection.main;if(CE(i)){for(const r of In(e).tables)if(n.head===r.from-1){const s=r.table.firstCellSpan.from;return[{selection:{anchor:r.from+s,head:r.from+s}}]}return i}else if(PE(i)){for(const r of In(e).tables)if(n.head===r.to+1){const s=r.table.lastCellSpan.to;return[{selection:{anchor:r.from+s,head:r.from+s}}]}return i}else return i};function EE(i){return kQ(i)>0||QQ(i)>0}const LE=({state:i,docChanged:t,selectionSet:e,transactions:n,view:r})=>{if(!t&&!e&&EE(i)||n.some(a=>zd(a)))return;const{formatting:s}=In(i);if(Bc(s))return;const o=Lt.of(s,i.doc.length,i.lineBreak),l=i.selection.map(o);r.dispatch({annotations:Rn("table.format"),changes:o,selection:l})},ME=i=>{if(!i.docChanged||zd(i))return i;const t=i.changes,{tables:e}=In(i.startState),n=[];for(const o of e)if(t.touchesRange(o.from-1,o.from)!==!1||t.touchesRange(o.to,o.to+1)!==!1){const l={from:t.mapPos(o.from,1),to:t.mapPos(o.to)};if(l.from>=l.to)continue;n.push(bd({doc:i.newDoc,lineBreak:i.startState.lineBreak,span:l}).changes)}if(Bc(n))return i;const r=Lt.of(n,i.changes.newLength,i.startState.lineBreak),s=i.newSelection.map(r);return[i,{annotation:Rn("table.correct"),changes:r,selection:s,sequential:!0}]};function zE(i,{anchor:t,head:e,goalColumn:n,bidiLevel:r}={}){return C.range(t??i.anchor,e??i.head,n??i.goalColumn,r??i.bidiLevel??void 0)}const _E=i=>{const{selection:t,startState:e,docChanged:n}=i;if(W(t)||n||oc(t))return i;const r=t.ranges.map(s=>{if(s.empty)return s;const o=In(e).tables,l=ug(s.anchor,o),a=ug(s.head,o);return E(l)||E(a)?zE(s,{anchor:l,head:a}):s});return bn(t.ranges,r,(s,o)=>s===o)?i:[i,{annotations:Rn("table.select"),selection:C.create(r,t.mainIndex)}]};function ug(i,t){for(const e of t){const n=e.from,r=e.to,s=e.from+1,o=e.to-1;if(i===n||i===s)return n-1;if(i===r||i===o)return r+1}}const IE={"& .cm-tooltip.cm-tooltip-autocomplete:has(.cm-completionIcon-table)":{border:"1px solid var(--tbl-theme-menu-border-color)","box-shadow":"2px 2px 0 0 rgb(0 0 0 / 10%)","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)"},"& .cm-tooltip.cm-tooltip-autocomplete > ul:has(.cm-completionIcon-table)":{"min-width":"auto",display:"flex","flex-direction":"column","justify-content":"center",padding:"0.25em 0","line-height":1,"font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)",background:"var(--tbl-theme-menu-background)"},"& .cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]:has(.cm-completionIcon-table)":{color:"var(--tbl-theme-menu-hover-text-color)","&::before":{background:"var(--tbl-theme-menu-hover-background)"}},"& .cm-tooltip.cm-tooltip-autocomplete ul li:not([aria-selected]):has(.cm-completionIcon-table)":{color:"var(--tbl-theme-menu-text-color)"},"& .cm-tooltip.cm-tooltip-autocomplete ul li:not([aria-selected]):has(.cm-completionIcon-table), & .cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]:has(.cm-completionIcon-table)":{position:"relative",padding:"0.5em 0.75em",background:"var(--tbl-theme-menu-background)",display:"flex",gap:"0.75em","align-items":"center","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)","line-height":1,"&::before":{position:"absolute",height:"100%",width:"calc(100% - 0.5em)",left:"0.25em",top:0,content:'""',"pointer-events":"none"}},"& .cm-completionIcon.cm-completionIcon-table":{opacity:1,"mask-image":`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='14' width='12.25' viewBox='0 0 448 512'%3E%3C!--!Font Awesome Free v7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--%3E%3Cpath d='M384 96l-128 0 0 128 128 0 0-128zm64 128l0 192c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96C0 60.7 28.7 32 64 32l320 0c35.3 0 64 28.7 64 64l0 128zM64 288l0 128 128 0 0-128-128 0zm128-64l0-128-128 0 0 128 128 0zm64 64l0 128 128 0 0-128-128 0z'/%3E%3C/svg%3E")`,"mask-position":"center","mask-repeat":"no-repeat",padding:0,background:"currentColor",position:"relative",width:"1em",height:"1em","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)","line-height":1},"& :has(.cm-completionIcon.cm-completionIcon-table) .cm-completionLabel":{position:"relative"}},jE={'&[data-tbl-handle-position="inside"] .tbl-table-widget':{"padding-left":"6px","margin-left":0},".tbl-table-widget":{contain:"paint","padding-top":"16px","padding-right":"16px","padding-bottom":"16px","padding-left":"16px","margin-left":"-10px","overflow-x":"auto","overflow-y":"hidden","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}},"&.cm-editor .cm-content div.tbl-table-widget::selection, & .cm-content div.tbl-table-widget ::selection, & .cm-content div.tbl-table-widget:focus::selection, & .cm-content div.tbl-table-widget :focus::selection":{"background-color":"transparent !important","caret-color":"transparent !important"}},DE={".cm-tooltip.tbl-menu-tooltip":{border:"none","user-select":"none","&, &::before, &::after, & *, & *::before, & *::after":{"box-sizing":"border-box"}}},VE={".tbl-blocking-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"transparent",width:"100%",height:"100%"}},BE={"& .cm-content div.tbl-table-widget .tbl-cell-editor ::selection, & .cm-content div.tbl-table-widget .tbl-cell-editor :focus::selection":{"background-color":"Highlight !important","caret-color":"initial !important"},"&[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content":{"caret-color":"transparent !important"},"&[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content ::selection, &[data-tbl-selection-type='codemirror'] .tbl-cell-editor .cm-editor .cm-content :focus::selection":{"background-color":"transparent !important","caret-color":"transparent !important"},"&[data-tbl-line-wrapping='wrap'] .tbl-cell-editor .cm-editor .cm-content":{"word-break":"normal","overflow-wrap":"break-word"},".tbl-cell-editor":{height:"100%"},".tbl-cell-editor .cm-editor":{margin:0,padding:0,outline:"none",height:"100%",background:"unset",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-scroller":{margin:0,padding:0,overflow:"hidden","line-height":1.5,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-content":{margin:0,padding:"7px 9px","line-height":1.5,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"},".tbl-cell-editor .cm-editor .cm-line":{margin:0,padding:"0 1px","line-height":1.5,"touch-action":"none","font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)"}},WE={".tbl-cell":{"box-sizing":"content-box",position:"relative","vertical-align":"top","background-color":"var(--tbl-row-background)",padding:0,"font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)","min-width":"calc(4ch + 20px)",height:"inherit","user-select":"none",border:"none","scroll-margin-right":"1px","scroll-margin-left":"1px","&:first-child":{"scroll-margin-left":"16px"},"&:last-child":{"scroll-margin-right":"16px"},'&[align="left"]':{"text-align":"left"},'&[align="center"]':{"text-align":"center"},'&[align="right"]':{"text-align":"right"},'&[data-border~="top"]':{"border-top":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="right"]':{"border-right":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="bottom"]':{"border-bottom":"1px solid var(--tbl-theme-border-color)"},'&[data-border~="left"]':{"border-left":"1px solid var(--tbl-theme-border-color)"},'&[data-state="moving"]':{"z-index":200,"background-color":"color-mix(in srgb, var(--tbl-row-background), transparent 15%)"},'&[data-state="shiftable"]':{transform:"translate3d(0, 0, 0)",transition:"transform 150ms ease"},"&[data-outline]":{"&::after":{display:"block",position:"absolute",top:"-1px",left:"-1px",border:"none",width:"calc(100% + 2px)",height:"calc(100% + 2px)","pointer-events":"none",content:'""'},'&[data-outline~="top"]::after':{"border-top":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="right"]::after':{"border-right":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="bottom"]::after':{"border-bottom":"2px solid var(--tbl-theme-outline-color)"},'&[data-outline~="left"]::after':{"border-left":"2px solid var(--tbl-theme-outline-color)"}}},".tbl-header-cell:not([align])":{"text-align":"var(--tbl-style-default-header-alignment)"}},YE={'&[data-tbl-line-wrapping="wrap"] .tbl-cell-view':{"word-break":"normal","overflow-wrap":"break-word"},'&[data-tbl-line-wrapping="nowrap"] .tbl-cell-view':{"white-space":"pre"},".tbl-cell-view":{margin:0,outline:"none",padding:"7px 10px",height:"100%","line-height":1.5,"white-space-collapse":"break-spaces","font-family":"var(--tbl-style-font-family)","font-size":"var(--tbl-style-font-size)",color:"var(--tbl-theme-text-color)","&[data-hidden]":{display:"none"}},".tbl-cell-view [data-br]":{"white-space":"pre"}},qE={".tbl-handle":{display:"flex",position:"absolute","justify-content":"center","align-items":"center","z-index":200,transition:"opacity 150ms ease 50ms","touch-action":"none"},".tbl-handle[data-hover], .tbl-handle[data-active]":{"--tbl-handle-opacity":1},'&:not([data-tbl-hoverable]) .tbl-handle[data-type="border"], &:not([data-tbl-hoverable]) .tbl-handle[data-type="table"]':{display:"none"},'.tbl-handle[data-type="border"]':{"background-color":"var(--tbl-theme-border-hover-color)"},'.tbl-handle[data-type="border"][data-active]':{"background-color":"var(--tbl-theme-border-active-color)"},'.tbl-handle[data-type="border"][data-toggle]':{transition:"none"},'.tbl-handle[data-type="border"][data-location="top"]':{top:"-1px",left:"-1px",width:"calc(100% + 2px)",height:"2px"},'.tbl-handle[data-type="border"][data-location="left"]':{top:"-1px",left:"-1px",width:"2px",height:"calc(100% + 2px)"},'.tbl-handle[data-type="border"][data-location="col"]':{top:"-1px",right:"-2px",width:"3px",height:"calc(100% + 2px)"},'.tbl-handle[data-type="border"][data-location="row"]':{bottom:"-2px",left:"-1px",width:"calc(100% + 2px)",height:"3px"},'.tbl-handle[data-type="table"]':{"box-sizing":"content-box",color:"var(--tbl-theme-border-hover-color)","background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)"},'.tbl-handle[data-type="table"][data-location="right"]':{top:0,left:"100%",width:"15px",height:"calc(100% - 2px)",border:"1px solid var(--tbl-theme-border-color)","border-left":"none","&::before":{position:"absolute",top:"-1px",left:"-2px",width:"2px",height:"calc(100% + 2px)",content:'""'},"&::after":{position:"absolute","z-index":366,top:"-1px",left:0,content:'""',width:"calc(100% + 1px)",height:"calc(100% + 2px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom-right"]':{left:"calc(100% - 1px)",top:"calc(100% - 1px)","z-index":250,width:"15px",height:"15px",border:"1px solid var(--tbl-theme-border-color)","border-top-style":"dashed","border-left-style":"dashed","&::after":{position:"absolute","z-index":366,top:"-1px",left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 2px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom"]':{top:"100%",left:"0",width:"calc(100% - 2px)",height:"15px",border:"1px solid var(--tbl-theme-border-color)","border-top":"none","&::before":{position:"absolute",top:"-2px",left:"-1px",width:"calc(100% + 2px)",height:"2px",content:'""'},"&::after":{position:"absolute","z-index":366,top:0,left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 1px)","background-color":"var(--tbl-overlay)"}},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="bottom"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"--tbl-handle-opacity":1},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"]':{"border-bottom":"none"},'.tbl-handle[data-type="table"][data-location="bottom-right"][data-hover] ~ .tbl-handle[data-type="table"][data-location="bottom"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"border-right":"none"},'.tbl-handle[data-type="table"][data-active], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="right"], .tbl-handle[data-type="table"][data-location="bottom-right"][data-active] ~ .tbl-handle[data-type="table"][data-location="bottom"]':{"background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)",color:"var(--tbl-theme-border-active-color)"},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"]':{"box-sizing":"content-box",transition:"none","z-index":300,color:"var(--tbl-theme-border-hover-color)",border:"1px solid transparent","&:hover":{"border-color":"var(--tbl-theme-border-color)","background-color":"color-mix(in srgb, var(--tbl-theme-border-color), var(--tbl-theme-header-row-background) 80%)"},"&[data-active]":{"background-color":"var(--tbl-theme-outline-color)","border-color":"var(--tbl-theme-outline-color)",color:"#ffffff"}},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"][data-location="row"]':{top:"-1px",left:"-17px",width:"15px",height:"100%","border-right":"none"},'&[data-tbl-handle-position="outside"] .tbl-handle[data-type="header"][data-location="col"]':{top:"-17px",left:"-1px",width:"100%",height:"15px","border-bottom":"none","&:hover::after":{position:"absolute","z-index":366,top:"-1px",left:"-1px",content:'""',width:"calc(100% + 2px)",height:"calc(100% + 1px)","background-color":"var(--tbl-overlay)"}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"]':{transition:"none","z-index":300,color:"var(--tbl-theme-border-hover-color)","&:hover":{color:"var(--tbl-theme-border-active-color)"},"&[data-active]":{color:"var(--tbl-theme-outline-color)"}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"][data-location="row"]':{top:"calc(50% - 13px)",left:"-1px",width:"3px",height:"26px","border-top":"4px solid var(--tbl-row-background)","border-bottom":"4px solid var(--tbl-row-background)","background-color":"var(--tbl-row-background)","&:hover::after, &[data-active]::after":{position:"absolute",top:"-6px",left:0,"box-sizing":"content-box","border-top":"2px solid transparent","border-bottom":"2px solid transparent",width:"calc(100% + 6px)",height:"calc(100% + 8px)",content:'""'}},'&[data-tbl-handle-position="inside"] .tbl-handle[data-type="header"][data-location="col"]':{top:"-1px",left:"calc(50% - 11.5px)",width:"23px",height:"3px","border-right":"4px solid var(--tbl-row-background)","border-left":"4px solid var(--tbl-row-background)","background-color":"var(--tbl-row-background)","&:hover::after, &[data-active]::after":{position:"absolute",top:0,left:"-6px","box-sizing":"content-box","border-right":"2px solid transparent","border-left":"2px solid transparent",width:"calc(100% + 8px)",height:"calc(100% + 6px)",content:'""'}},".tbl-handle-grip":{"pointer-events":"none","z-index":333}},NE={".tbl-menu-item-icon":{"z-index":200,width:"1em",height:"1em","pointer-events":"none","font-size":"var(--tbl-style-menu-font-size)"}},GE={".tbl-menu-item-text":{"z-index":200,"pointer-events":"none","user-select":"none","font-size":"var(--tbl-style-menu-font-size)"}},UE={".tbl-menu-item":{display:"flex",position:"relative","align-items":"center",gap:"0.75em",padding:"0.5em 0.75em",color:"var(--tbl-theme-menu-text-color)","user-select":"none","line-height":1,"font-size":"var(--tbl-style-menu-font-size)","&:active":{cursor:"pointer",color:"var(--tbl-theme-menu-hover-text-color)","&::after":{"background-color":"var(--tbl-theme-menu-hover-background)"}},"&::after":{position:"absolute",left:"0.25em",width:"calc(100% - 0.5em)",height:"100%",content:'""'}},"&[data-tbl-hoverable] .tbl-menu-item:hover":{cursor:"pointer",color:"var(--tbl-theme-menu-hover-text-color)","&::after":{"background-color":"var(--tbl-theme-menu-hover-background)"}}},HE={".tbl-menu-separator":{margin:"0.25em 0.5em","background-color":"var(--tbl-theme-menu-border-color)",height:"1px","font-size":"var(--tbl-style-menu-font-size)"}},FE={".tbl-menu":{position:"absolute",top:0,left:0,"z-index":900,"box-shadow":"2px 2px 0 0 rgb(0 0 0 / 10%)",border:"1px solid var(--tbl-theme-menu-border-color)","background-color":"var(--tbl-theme-menu-background)",padding:"0.25em 0",width:"max-content","font-family":"var(--tbl-style-menu-font-family)","font-size":"var(--tbl-style-menu-font-size)"}},KE={".tbl-select-all-overlay":{position:"absolute",top:0,left:0,"z-index":900,"background-color":"var(--tbl-overlay)",width:"100%",height:"100%","pointer-events":"none"}},JE={"& .tbl-table-wrapper[data-select-all]":{"--tbl-select-all-overlay":"var(--tbl-theme-select-all-blur-overlay)"},"&.cm-focused .tbl-table-wrapper[data-select-all]":{"--tbl-select-all-overlay":"var(--tbl-theme-select-all-focus-overlay)"},".tbl-table-wrapper":{"--tbl-overlay":"var(--tbl-select-all-overlay, transparent)",position:"relative",width:"fit-content","white-space-collapse":"collapse","touch-action":"none"},".tbl-table":{"border-collapse":"separate","border-spacing":0,overflow:"visible","touch-action":"none","&:focus-visible":{outline:"none"}},".tbl-table-head, .tbl-table-body":{height:"100%"},".tbl-table-row":{height:0},"@supports (-moz-appearance: none) /* TableTheme */":{".tbl-table-row":{height:"fit-content"}},".tbl-table-head .tbl-table-row":{"--tbl-row-background":"var(--tbl-theme-header-row-background)"},".tbl-table-body .tbl-table-row:nth-child(2n + 1)":{"--tbl-row-background":"var(--tbl-theme-even-row-background)"},".tbl-table-body .tbl-table-row:nth-child(2n)":{"--tbl-row-background":"var(--tbl-theme-odd-row-background)"}},tL={...IE,...DE,...jE,...JE,...VE,...WE,...BE,...YE,...qE,...FE,...UE,...NE,...GE,...HE,...KE},eL=i=>{var e;const t=(e=i.effects.find(n=>n.is(Sv)))==null?void 0:e.value;return E(t)?{annotations:Rn(t)}:null},iL=i=>{const t=i.annotation(Md);return E(t)?[vv(V5(t))]:[]};class Fd{static of(t){return t.state.field(Hd).view=t,new Fd}constructor(){}}function nL(i){return[Fu.of(i),gv,Hd,ui.define(t=>Fd.of(t)),z.editorAttributes.compute([Fu,z.darkTheme],xE),z.baseTheme(tL),z.theme("light"in i.theme?{':where(:root:has(&[data-tbl-theme-mode="light"]))':i.theme.light.props,':where(:root:has(&[data-tbl-theme-mode="dark"]))':i.theme.dark.props}:{":where(:root:has(&))":i.theme.props}),z.theme({":where(:root:has(&))":i.style.props}),w0.of(iL),e0.of(iv),K.transactionExtender.of(eL),K.transactionFilter.of(ME),K.transactionFilter.of(XE),K.transactionFilter.of(ZE),K.transactionFilter.of(_E),z.updateListener.of(LE),z.updateListener.of(TE),z.clipboardInputFilter.of(KA),z.focusChangeEffect.of(RE)]}function rL(i){return nL(R1(i))}const xv="cm-md-mark",yv="cm-md-inline-code",Sf="cm-md-list-item",vf="cm-md-list-bullet",kv="cm-md-blockquote-line",Qv="cm-md-fenced-line",$v="cm-md-hr",Cv="cm-md-task-checkbox",Pv="cm-md-heading-1",Tv="cm-md-heading-2",Kd="cm-md-link",Av="cm-md-tag",Rv="cm-md-list-indent-source",fg="1.2em",sL="0.62em",To=J.replace({}),Un=J.mark({class:xv}),oL=J.mark({class:Rv}),lL=J.mark({class:yv}),aL=J.line({class:vf}),cL=J.line({class:kv}),hL=J.line({class:Qv}),uL=J.line({class:Pv}),fL=J.line({class:Tv}),dL=J.mark({class:Av});class OL extends jn{toDOM(){const t=document.createElement("hr");return t.className=$v,t}eq(t){return!0}ignoreEvent(){return!0}}const pL=J.replace({widget:new OL});class mL extends jn{constructor(e,n,r){super();P(this,"checked");P(this,"from");P(this,"to");this.checked=e,this.from=n,this.to=r}eq(e){return e.checked===this.checked&&e.from===this.from&&e.to===this.to}toDOM(e){const n=document.createElement("input");return n.type="checkbox",n.checked=this.checked,n.className=Cv,n.tabIndex=-1,n.addEventListener("mousedown",r=>{r.preventDefault()}),n.addEventListener("change",()=>{const r=this.checked?"[ ]":"[x]";e.dispatch({changes:{from:this.from,to:this.to,insert:r}})}),n}ignoreEvent(e){return e.type!=="click"&&e.type!=="change"&&e.type!=="mousedown"}}const gL=new Set(["EmphasisMark","LinkMark","URL"]),bL=new Set(["HeaderMark","QuoteMark"]),dg=/(^|\s)(#[\p{L}\p{N}_/-]+)/gu,wL=/[/.,;:!?]+$/u,SL=new RegExp("\\p{L}","u"),vL=new Set(["InlineCode","FencedCode","URL","Link"]);function xL(i,t,e,n,r,s){return bL.has(i)?{kind:"block",contextFrom:r,contextTo:s}:i==="CodeMark"?t==="InlineCode"&&e!==null&&n!==null?{kind:"inline",contextFrom:e,contextTo:n}:null:gL.has(i)?e===null||n===null?null:{kind:"inline",contextFrom:e,contextTo:n}:null}function wn(i,t,e,n){return i<=n&&t>=e}function yL(i,t,e,n){const r=i.doc.lineAt(n);return wn(t,e,r.from,r.to)}function kL(i,t,e,n){return t.kind==="inline"?!wn(e,n,t.contextFrom,t.contextTo):!yL(i,e,n,t.contextFrom)}function QL(i){let t=i.firstChild;for(;t;){if(t.name==="TaskMarker")return!0;if(t.name==="Task"){let e=t.firstChild;for(;e;){if(e.name==="TaskMarker")return!0;e=e.nextSibling}}t=t.nextSibling}return!1}function $L(i){let t=i.parent;for(;t;){if(t.name==="ListItem")return t;t=t.parent}return null}function Jn(i,t){let e=i.firstChild;for(;e;){if(e.name===t)return e;e=e.nextSibling}return null}function Og(i,t){const e=[];let n=t.firstChild;for(;n;)n.name==="CodeMark"&&e.push(n),n=n.nextSibling;if(e.length>=2)return{from:t.from,to:e[e.length-1].to,closed:!0};const r=i.doc.lineAt(t.from);return{from:r.from,to:r.to,closed:!1}}function Zv(i,t){let e=t.to;for(;e<i.doc.length&&i.doc.sliceString(e,e+1)===" ";)e+=1;return{from:t.from,to:e}}function Nh(i,t){return{from:i.doc.lineAt(t.from).from,to:Zv(i,t).to}}function Gh(i,t){return Zv(i,t)}function pg(i,t,e){const n=Jn(t,"ListMark"),r=n?i.doc.lineAt(n.from).from:e.from;let s=e.to;for(;s<i.doc.length&&i.doc.sliceString(s,s+1)===" ";)s+=1;return{from:r,to:s}}function Uh(i,t,e){const n=i.doc.lineAt(t.from);n.from<t.from&&e.push(oL.range(n.from,t.from))}function CL(i,t,e){let n=0;for(let r=t;r<e;r+=1)n+=i.doc.sliceString(r,r+1)===" "?2:1;return n}function PL(i){return J.line({class:Sf,attributes:{style:`--cm-md-list-indent: ${i.prefixRevealed?0:i.indentColumns};`}})}function mg(i,t,e,n,r){let s=t;for(;s<=e;){const o=i.doc.lineAt(s);if(r.push(n.range(o.from)),o.to>=e)break;s=o.to+1}}function TL(i,t,e,n){const r=Jn(t,"ListMark"),s=i.doc.lineAt(r?r.from:t.from).from,o=r?CL(i,s,r.from):0;let l=t.from;for(;l<=t.to;){const a=i.doc.lineAt(l),c=a.from===s,h=/^\s/.test(a.text);if(c||h){const u=e.get(a.from),f={indentColumns:o,prefixRevealed:c&&n};u===void 0||o>u.indentColumns?e.set(a.from,f):o===u.indentColumns&&f.prefixRevealed&&e.set(a.from,{...u,prefixRevealed:!0})}if(a.to>=t.to)break;l=a.to+1}}function AL(i,t){let e=i.resolveInner(t,1);for(;e;){if(vL.has(e.name)||e.name.startsWith("Table"))return!0;e=e.parent}return!1}function RL(i,t){const e=/^( {0,3})(#{1,6})(?:\s|$)/.exec(i);if(!e)return!1;const n=e[1]??"",r=e[2]??"",s=n.length,o=s+r.length;return t>=s&&t<o}function ZL(i,t,e){for(let n=1;n<=i.doc.lines;n+=1){const r=i.doc.line(n);dg.lastIndex=0;let s;for(;(s=dg.exec(r.text))!==null;){const o=s[1]??"",a=(s[2]??"").replace(wL,"");if(a.length<=1||!SL.test(a))continue;const c=r.from+s.index+o.length,h=c+a.length;RL(r.text,c-r.from)||AL(t,c)||e.push(dL.range(c,h))}}}function gg(i,t,e,n){const r=[],s=new Map,o=new Set,l=i.selection.main,a=n?Math.min(l.from,l.to):-1,c=n?Math.max(l.from,l.to):-1;e.iterate({from:0,to:i.doc.length,enter:h=>{var p,m;if(h.name==="Table"||h.name.startsWith("Table"))return!1;const u=h.node.parent,f=(u==null?void 0:u.name)??null;let d=h.to;(h.name==="HeaderMark"||h.name==="QuoteMark")&&i.doc.sliceString(d,d+1)===" "&&(d+=1);const O=xL(h.name,f,(u==null?void 0:u.from)??null,(u==null?void 0:u.to)??null,h.from,d);if(O){const g=kL(i,O,a,c)?To:Un;r.push(g.range(h.from,d))}if(h.name==="ListMark"){const g=h.node.parent;if(g&&g.name==="ListItem"){const b=QL(g),S=((p=g.parent)==null?void 0:p.name)==="OrderedList";if(!b&&!S){const x=Nh(i,h.node),y=Gh(i,h.node);wn(a,c,x.from,x.to)?(Uh(i,h.node,r),r.push(Un.range(y.from,y.to))):r.push(To.range(x.from,x.to))}else if(S){const x=i.doc.lineAt(h.node.from),y=Nh(i,h.node);x.from<h.node.from&&(wn(a,c,y.from,y.to)?Uh(i,h.node,r):r.push(To.range(x.from,h.node.from))),r.push(Un.range(h.node.from,h.node.to))}}}if(h.name==="InlineCode"){const g=h.node.firstChild,b=h.node.lastChild;g&&b&&g!==b&&g.name==="CodeMark"&&b.name==="CodeMark"&&g.to<b.from&&r.push(lL.range(g.to,b.from))}if(h.name==="ListItem"){const g=Jn(h.node,"ListMark"),b=Jn(h.node,"Task"),S=Jn(h.node,"TaskMarker")??(b?Jn(b,"TaskMarker"):null),x=S!==null,y=((m=h.node.parent)==null?void 0:m.name)==="OrderedList";let k=!1;if(g){const Q=S?pg(i,h.node,S):Nh(i,g);k=wn(a,c,Q.from,Q.to)}if(TL(i,h.node,s,k),!x&&!y&&g&&!k){const Q=i.doc.lineAt(h.from);o.add(Q.from)}}else if(h.name==="Blockquote")mg(i,h.from,h.to,cL,r);else if(h.name==="ATXHeading1"){const g=i.doc.lineAt(h.from);r.push(uL.range(g.from))}else if(h.name==="ATXHeading2"){const g=i.doc.lineAt(h.from);r.push(fL.range(g.from))}else if(h.name==="FencedCode"){const g=Og(i,h.node);mg(i,g.from,g.to,hL,r)}if(h.name==="Link"){let g=null,b=null,S=null,x=h.node.firstChild;for(;x;)x.name==="LinkMark"?g===null?g=x:b=x:x.name==="URL"&&(S=x),x=x.nextSibling;if(g&&b&&S&&g.to<b.from){const y=i.doc.sliceString(S.from,S.to),k=J.mark({class:Kd,tagName:"a",attributes:{"data-href":y}});r.push(k.range(g.to,b.from))}}if(h.name==="CodeMark"&&f==="FencedCode"){const g=h.node.parent;if(g){const b=Og(i,g);if(b.closed){const S=wn(a,c,b.from,b.to)?Un:To;r.push(S.range(h.from,h.to))}else r.push(Un.range(h.from,h.to))}}if(h.name==="HorizontalRule"){const g=i.doc.lineAt(h.from);g.to>g.from&&!wn(a,c,g.from,g.to)&&r.push(pL.range(g.from,g.to))}if(h.name==="TaskMarker"){const g=$L(h.node),b=g?Jn(g,"ListMark"):null,S=g?pg(i,g,h.node):{from:h.from,to:h.to};if(wn(a,c,S.from,S.to)){if(b){const y=Gh(i,b);Uh(i,b,r),r.push(Un.range(y.from,y.to))}r.push(Un.range(h.from,h.to))}else{if(b){const Z=Gh(i,b),D=i.doc.lineAt(b.from).from;r.push(To.range(D,Z.to))}const y=i.doc.sliceString(h.from,h.to),k=y==="[x]"||y==="[X]",Q=J.replace({widget:new mL(k,h.from,h.to)});r.push(Q.range(h.from,h.to))}}}});for(const[h,u]of s)r.push(PL(u).range(h));for(const h of o)r.push(aL.range(h));return ZL(i,e,r),J.set(r,!0)}const XL=ui.fromClass(class{constructor(i){P(this,"decorations");this.decorations=gg(i.state,i.visibleRanges,St(i.state),i.hasFocus)}update(i){(i.docChanged||i.selectionSet||i.viewportChanged||i.focusChanged||St(i.state)!==St(i.startState))&&(this.decorations=gg(i.state,i.view.visibleRanges,St(i.state),i.view.hasFocus))}},{decorations:i=>i.decorations}),EL=z.theme({"&":{fontFamily:"var(--font-sans)",fontSize:"calc(var(--text-base) + 0.5px)",lineHeight:"var(--leading-base)"},".cm-scroller":{fontFamily:"inherit",fontSize:"inherit",lineHeight:"inherit"},".cm-content":{fontFamily:"inherit",fontSize:"inherit",lineHeight:"inherit",padding:"1.5rem 1rem"},[`.${Rv}`]:{fontFamily:"var(--font-mono)"},[`.${xv}`]:{fontFamily:"var(--font-mono)",fontSize:"0.9em",color:"rgba(0, 0, 0, 0.4)"},[`.${Pv}`]:{fontSize:"1.3em"},[`.${Tv}`]:{fontSize:"1.1em"},[`.${yv}`]:{fontFamily:"var(--font-mono)",fontSize:"0.92em",backgroundColor:"rgba(0, 0, 0, 0.06)",padding:"1px 4px",borderRadius:"3px"},[`.${Av}`]:{color:"var(--color-primary)",backgroundColor:"var(--tint-100)",borderRadius:"var(--radius-full)",padding:"0 0.35em",fontWeight:"600",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone"},[`.${Sf}`]:{paddingLeft:`calc(0.5rem + var(--cm-md-list-indent, 0) * ${sL})`},[`.${Sf}.${vf}`]:{borderLeft:`${fg} solid transparent`},[`.${vf}::before`]:{content:"'•'",marginLeft:`calc(-1 * ${fg})`,fontFamily:"var(--font-mono)",fontSize:"0.9em",color:"rgba(0, 0, 0, 0.4)",paddingRight:"0.5rem"},[`.${kv}`]:{borderLeft:"3px solid rgba(0, 0, 0, 0.2)",paddingLeft:"1rem",marginLeft:"0.25rem",color:"rgba(0, 0, 0, 0.55)"},[`.${Qv}`]:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"0.92em",backgroundColor:"rgba(0, 0, 0, 0.04)",paddingLeft:"0.75em"},[`.${$v}`]:{display:"inline-block",verticalAlign:"middle",border:"none",borderTop:"1px solid rgba(0, 0, 0, 0.2)",margin:0,width:"100%"},[`.${Cv}`]:{margin:"0 0.4em 0 0",cursor:"default",verticalAlign:"middle"},[`a.${Kd}`]:{textDecoration:"underline",color:"rgba(0, 0, 0, 0.55)",cursor:"pointer"}}),LL=4;function bg(i){return i instanceof Element?i.closest(`a.${Kd}`):null}function ML(i){const t=i.getAttribute("data-href");if(t===null)return null;try{return new URL(t,window.document.baseURI).href}catch{return null}}function zL(i){const t={type:"navigation-request",url:i},e=window.__televisionContentBridge;if(e){e.postToHost(t);return}window.parent.postMessage(t,"*")}function _L(i,t){return Math.hypot(t.clientX-i.x,t.clientY-i.y)>LL}let Rr=null;const IL=z.domEventHandlers({mousedown(i){const t=bg(i.target);if(Rr=null,!t||i.button!==0||i.altKey)return!1;const e=ML(t);return e===null?!1:(Rr={anchor:t,url:e,openExternally:i.metaKey||i.ctrlKey,x:i.clientX,y:i.clientY},i.preventDefault(),!0)},click(i){const t=bg(i.target);if(!t||i.altKey)return Rr=null,!1;const e=Rr;return Rr=null,!e||e.anchor!==t?!1:(i.preventDefault(),_L(e,i)||(e.openExternally?window.open(e.url,"_blank","noopener,noreferrer"):zL(e.url)),!0)}}),jL=/^(\d+)([.)])(\s|$)/;function DL(i){const t=[];let e=!1,n=1;for(let r=1;r<=i.doc.lines;r+=1){const s=i.doc.line(r),o=jL.exec(s.text);o?(e||(e=!0,n=1),parseInt(o[1],10)!==n&&t.push({from:s.from,to:s.from+o[1].length,insert:String(n)}),n+=1):s.text===""&&(e=!1)}return t}const wg=Ke.define(),VL=K.transactionFilter.of(i=>{if(!i.docChanged||i.annotation(wg))return i;const t=i.annotation(Pt.userEvent);if(t==="undo"||t==="redo")return i;const e=DL(i.state);if(e.length===0)return i;const n=Lt.of(e,i.state.doc.length),r=i.changes.compose(n);return i.startState.update({changes:r,selection:i.selection,scrollIntoView:i.scrollIntoView,effects:i.effects,annotations:[wg.of(!0),...t?[Pt.userEvent.of(t)]:[]],filter:!1})}),BL=/^(\s*)([-*]|\d+[.)])(\s\[[ xX]\])?\s$/,WL=i=>{const{state:t}=i,e=t.selection.main;if(e.from!==e.to)return!1;const n=t.doc.lineAt(e.from),r=n.text.slice(0,e.from-n.from);return BL.test(r)?(i.dispatch({changes:{from:e.from-1,to:e.from,insert:""},selection:{anchor:e.from-1},userEvent:"delete.backward",scrollIntoView:!0}),!0):!1},YL=hn.highest(Dn.of([{key:"Backspace",run:WL}])),qL=[XL,EL,VL,YL,IL],NL=500,Sg=Ke.define(),GL=Rc.define([{tag:v.heading,fontWeight:"600"},{tag:v.strong,fontWeight:"600"},{tag:v.emphasis,fontStyle:"italic"},{tag:v.strikethrough,textDecoration:"line-through"}]);function vg(i){const t=i.length;return({state:e,dispatch:n})=>{const r=e.changeByRange(s=>{if(s.empty)return{changes:{from:s.from,insert:i+i},range:C.cursor(s.from+t)};const o=e.sliceDoc(s.from,s.to);if(o.length>=t*2&&o.startsWith(i)&&o.endsWith(i))return{changes:[{from:s.from,to:s.from+t},{from:s.to-t,to:s.to}],range:C.range(s.from,s.to-t*2)};const l=s.from>=t&&e.sliceDoc(s.from-t,s.from)===i,a=s.to+t<=e.doc.length&&e.sliceDoc(s.to,s.to+t)===i;return l&&a?{changes:[{from:s.from-t,to:s.from},{from:s.to,to:s.to+t}],range:C.range(s.from-t,s.to-t)}:{changes:[{from:s.from,insert:i},{from:s.to,insert:i}],range:C.range(s.from+t,s.to+t)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}const UL=hn.highest(Dn.of([{key:"Mod-b",run:vg("**")},{key:"Mod-i",run:vg("*")},{key:"Enter",run:u1({nonTightLists:!1})}])),HL=cl.light.with({"--tbl-theme-row-background":"transparent","--tbl-theme-header-row-background":"var(--tint-50)","--tbl-theme-even-row-background":"transparent","--tbl-theme-odd-row-background":"transparent","--tbl-theme-border-color":"var(--tint-150)","--tbl-theme-border-hover-color":"var(--tint-300)","--tbl-theme-border-active-color":"var(--tint-500)","--tbl-theme-outline-color":"var(--color-primary)","--tbl-theme-text-color":"currentColor","--tbl-theme-menu-border-color":"var(--tint-150)","--tbl-theme-menu-background":"var(--color-surface)","--tbl-theme-menu-hover-background":"var(--color-overlay-hover)","--tbl-theme-menu-text-color":"var(--color-text)","--tbl-theme-menu-hover-text-color":"var(--color-text)","--tbl-theme-select-all-focus-overlay":"var(--tint-200)","--tbl-theme-select-all-blur-overlay":"var(--tint-100)"}),FL=sc.default.with({"--tbl-style-font-family":"var(--font-sans)","--tbl-style-font-size":"inherit","--tbl-style-menu-font-family":"var(--font-sans)","--tbl-style-menu-font-size":"var(--text-sm, 0.875rem)","--tbl-style-default-header-alignment":"left"}),KL=rL({theme:HL,style:FL,selectionType:"native",handlePosition:"outside",lineWrapping:"wrap",extensions:[Dn.of(K0)],globalKeyBindings:[...k0]}),Xv=[vQ(),uo.of(" "),UL,Dn.of([...K0,...k0,k$]),zc({extensions:[xw,sd,{remove:["SetextHeading"]}]}),m0(GL),z.lineWrapping,qL,KL];function JL(i){const{parent:t,ctx:e}=i,n=i.debounceMs??NL;let r=null,s=null,o=null;const l=f=>{h.state.doc.toString()!==f&&h.dispatch({changes:{from:0,to:h.state.doc.length,insert:f},annotations:[Sg.of(!0),Pt.addToHistory.of(!1)]})},a=async()=>{o=null;const f=h.state.doc.toString();r=f;try{await e.updateContent(f),s=f}catch{const d=s??"";l(d),r=d}},c=z.updateListener.of(f=>{!f.docChanged||f.transactions.some(O=>O.annotation(Sg))||(o!==null&&clearTimeout(o),o=setTimeout(()=>{a()},n))}),h=new z({parent:t,state:K.create({doc:"",extensions:[Xv,c]})}),u=f=>{const d=f.content;r!==null&&d===r||(l(d),s=d)};return e.addEventListener("content-updated",u),{view:h,dispose(){o!==null&&(clearTimeout(o),o=null),e.removeEventListener("content-updated",u),h.destroy()}}}const t3=`# Heading 1
62
62
 
63
63
  Some paragraph text with **bold**, *italic*, \`inline code\`, and an [inline link](https://example.com).
64
64