@inkeep/open-knowledge 0.4.0-beta.25 → 0.4.0-beta.26

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.
Files changed (38) hide show
  1. package/dist/assets/skills/open-knowledge/SKILL.md +1 -1
  2. package/dist/cli.mjs +37 -37
  3. package/dist/constants-CSmwRAFo.mjs +2 -0
  4. package/dist/{dist-DVNDjpnz.mjs → dist-BaIGvDgD.mjs} +1 -1
  5. package/dist/{dist-JNaknvi7.mjs → dist-C4qQGc8i.mjs} +8 -8
  6. package/dist/{dist-Cl_t5NRm.mjs → dist-DoBoUPet.mjs} +17 -16
  7. package/dist/index.mjs +1 -1
  8. package/dist/init-Cys0YykC.mjs +1 -0
  9. package/dist/{init-uWmRmgCA.mjs → init-Djz7BdtL.mjs} +5 -5
  10. package/dist/{loader-hjhxvSRP.mjs → loader-B64r69-j.mjs} +3 -3
  11. package/dist/loader-DfRJHcOw.mjs +1 -0
  12. package/dist/preview-Chj-AjEC.mjs +1 -0
  13. package/dist/{preview-vq_EvsiP.mjs → preview-nt7uUE2i.mjs} +2 -2
  14. package/dist/public/assets/{ActivityModeContent-C-OqZ3Ro.js → ActivityModeContent-EGGl80pX.js} +1 -1
  15. package/dist/public/assets/{DocumentContext-Ccj8qLzP.js → DocumentContext-Bic6EUm_.js} +1 -1
  16. package/dist/public/assets/{GraphPanel-BKsp7Crh.js → GraphPanel-B42N4CIV.js} +1 -1
  17. package/dist/public/assets/{OutlinePanel-DP5j1Wq1.js → OutlinePanel-CJ2DJN7r.js} +1 -1
  18. package/dist/public/assets/{SettingsDialog-C9FPnh00.js → SettingsDialog-D53RhrjD.js} +2 -2
  19. package/dist/public/assets/{SourceEditor-mNodigv_.js → SourceEditor-CMwexck1.js} +1 -1
  20. package/dist/public/assets/config-validation-events-Bosr96x4.js +10 -0
  21. package/dist/public/assets/{doc-hash-C9Z2AnUu.js → doc-hash-Bg2WkAY_.js} +128 -127
  22. package/dist/public/assets/{index-BDj01myg.js → index-10HZouza.js} +76 -76
  23. package/dist/public/assets/index-EvzmrHLW.css +1 -0
  24. package/dist/public/assets/{target-navigation-intent-FPPCIJIk.js → target-navigation-intent-zW_9xoDt.js} +1 -1
  25. package/dist/public/assets/{toggle-group-CP96D5oH.js → toggle-group-BMp2XgSC.js} +1 -1
  26. package/dist/public/assets/{tooltip-qQkwljHf.js → tooltip-CYfWgpPY.js} +1 -1
  27. package/dist/public/index.html +23 -16
  28. package/dist/{src-jO7GzWRA.mjs → src-DVGh66ju.mjs} +2 -2
  29. package/dist/start-CjvYIfQD.mjs +1 -0
  30. package/dist/{start-BnicFP1K.mjs → start-D6Gr8R62.mjs} +2 -2
  31. package/package.json +1 -1
  32. package/dist/constants-Dlyng5m6.mjs +0 -2
  33. package/dist/init-BKrp4NZQ.mjs +0 -1
  34. package/dist/loader-DqxqwNEe.mjs +0 -1
  35. package/dist/preview-CpmoA4SU.mjs +0 -1
  36. package/dist/public/assets/config-validation-events-BJEehccy.js +0 -10
  37. package/dist/public/assets/index-BzPHdvNz.css +0 -1
  38. package/dist/start-CNyWXmFb.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{o as e,t as n}from"./chunk-CFjPhJqf.js";import{n as r,r as i,t as a}from"./compiler-runtime-CVnuRdak.js";import{a as o,c as s,i as c,n as l,o as u,r as d,s as f,t as p}from"./panel-8fydlQgn.js";import{Ct as m,Dt as h,Fr as g,Ir as _,Mn as v,Rr as y,St as b,ht as x,i as S,p as C,s as w,yt as T}from"./doc-hash-C9Z2AnUu.js";import{C as E,r as D,t as ee}from"./button-C1nwPVFQ.js";import{n as te,r as ne,t as re}from"./target-navigation-intent-FPPCIJIk.js";import{n as ie,t as ae}from"./toggle-group-CP96D5oH.js";import{i as oe,n as se,t as ce}from"./tooltip-qQkwljHf.js";import{n as le}from"./isObjectLike-DFnkciUU.js";import{t as ue}from"./ordinal-BLFwWMHf.js";import{n as de,t as fe}from"./min-BiwsSkbB.js";import{C as pe,S as me,_ as he,b as ge,g as _e,n as O,r as ve,t as ye,v as k,w as A,x as be,y as xe}from"./src-L3wpjxBL.js";import{t as j}from"./colors-D6LRuSY-.js";import{n as Se,t as M}from"./now-D_m-3Vjm.js";var Ce=E(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),we=E(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]);function Te(e,n){let r=0;if(n===void 0)for(let n of e)(n=+n)&&(r+=n);else{let i=-1;for(let a of e)(a=+n(a,++i,e))&&(r+=a)}return r}var Ee=e=>()=>e;function N(e,{sourceEvent:n,subject:r,target:i,identifier:a,active:o,x:s,y:c,dx:l,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}N.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function De(e){return!e.ctrlKey&&!e.button}function Oe(){return this.parentNode}function ke(e,n){return n??{x:e.x,y:e.y}}function Ae(){return navigator.maxTouchPoints||`ontouchstart`in this}function je(){var e=De,n=Oe,r=ke,i=Ae,a={},o=A(`start`,`drag`,`end`),s=0,c,l,u,d,f=0;function p(e){e.on(`mousedown.drag`,m).filter(i).on(`touchstart.drag`,_).on(`touchmove.drag`,v,xe).on(`touchend.drag touchcancel.drag`,y).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function m(r,i){if(!(d||!e.call(this,r,i))){var a=b(this,n.call(this,r,i),r,i,`mouse`);a&&(pe(r.view).on(`mousemove.drag`,h,ge).on(`mouseup.drag`,g,ge),_e(r.view),be(r),u=!1,c=r.clientX,l=r.clientY,a(`start`,r))}}function h(e){if(k(e),!u){var n=e.clientX-c,r=e.clientY-l;u=n*n+r*r>f}a.mouse(`drag`,e)}function g(e){pe(e.view).on(`mousemove.drag mouseup.drag`,null),he(e.view,u),k(e),a.mouse(`end`,e)}function _(r,i){if(e.call(this,r,i)){var a=r.changedTouches,o=n.call(this,r,i),s=a.length,c,l;for(c=0;c<s;++c)(l=b(this,o,r,i,a[c].identifier,a[c]))&&(be(r),l(`start`,r,a[c]))}}function v(e){var n=e.changedTouches,r=n.length,i,o;for(i=0;i<r;++i)(o=a[n[i].identifier])&&(k(e),o(`drag`,e,n[i]))}function y(e){var n=e.changedTouches,r=n.length,i,o;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),i=0;i<r;++i)(o=a[n[i].identifier])&&(be(e),o(`end`,e,n[i]))}function b(e,n,i,c,l,u){var d=o.copy(),f=me(u||i,n),m,h,g;if((g=r.call(e,new N(`beforestart`,{sourceEvent:i,target:p,identifier:l,active:s,x:f[0],y:f[1],dx:0,dy:0,dispatch:d}),c))!=null)return m=g.x-f[0]||0,h=g.y-f[1]||0,function r(i,o,u){var _=f,v;switch(i){case`start`:a[l]=r,v=s++;break;case`end`:delete a[l],--s;case`drag`:f=me(u||o,n),v=s;break}d.call(i,e,new N(i,{sourceEvent:o,subject:g,target:p,identifier:l,active:v,x:f[0]+m,y:f[1]+h,dx:f[0]-_[0],dy:f[1]-_[1],dispatch:d}),c)}}return p.filter=function(n){return arguments.length?(e=typeof n==`function`?n:Ee(!!n),p):e},p.container=function(e){return arguments.length?(n=typeof e==`function`?e:Ee(e),p):n},p.subject=function(e){return arguments.length?(r=typeof e==`function`?e:Ee(e),p):r},p.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:Ee(!!e),p):i},p.on=function(){var e=o.on.apply(o,arguments);return e===o?p:e},p.clickDistance=function(e){return arguments.length?(f=(e=+e)*e,p):Math.sqrt(f)},p}function Me(e){let n=+this._x.call(null,e),r=+this._y.call(null,e);return Ne(this.cover(n,r),n,r,e)}function Ne(e,n,r,i){if(isNaN(n)||isNaN(r))return e;var a,o=e._root,s={data:i},c=e._x0,l=e._y0,u=e._x1,d=e._y1,f,p,m,h,g,_,v,y;if(!o)return e._root=s,e;for(;o.length;)if((g=n>=(f=(c+u)/2))?c=f:u=f,(_=r>=(p=(l+d)/2))?l=p:d=p,a=o,!(o=o[v=_<<1|g]))return a[v]=s,e;if(m=+e._x.call(null,o.data),h=+e._y.call(null,o.data),n===m&&r===h)return s.next=o,a?a[v]=s:e._root=s,e;do a=a?a[v]=[,,,,]:e._root=[,,,,],(g=n>=(f=(c+u)/2))?c=f:u=f,(_=r>=(p=(l+d)/2))?l=p:d=p;while((v=_<<1|g)==(y=(h>=p)<<1|m>=f));return a[y]=o,a[v]=s,e}function Pe(e){var n,r,i=e.length,a,o,s=Array(i),c=Array(i),l=1/0,u=1/0,d=-1/0,f=-1/0;for(r=0;r<i;++r)isNaN(a=+this._x.call(null,n=e[r]))||isNaN(o=+this._y.call(null,n))||(s[r]=a,c[r]=o,a<l&&(l=a),a>d&&(d=a),o<u&&(u=o),o>f&&(f=o));if(l>d||u>f)return this;for(this.cover(l,u).cover(d,f),r=0;r<i;++r)Ne(this,s[r],c[r],e[r]);return this}function Fe(e,n){if(isNaN(e=+e)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,a=this._x1,o=this._y1;if(isNaN(r))a=(r=Math.floor(e))+1,o=(i=Math.floor(n))+1;else{for(var s=a-r||1,c=this._root,l,u;r>e||e>=a||i>n||n>=o;)switch(u=(n<i)<<1|e<r,l=[,,,,],l[u]=c,c=l,s*=2,u){case 0:a=r+s,o=i+s;break;case 1:r=a-s,o=i+s;break;case 2:a=r+s,i=o-s;break;case 3:r=a-s,i=o-s;break}this._root&&this._root.length&&(this._root=c)}return this._x0=r,this._y0=i,this._x1=a,this._y1=o,this}function Ie(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function P(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function F(e,n,r,i,a){this.node=e,this.x0=n,this.y0=r,this.x1=i,this.y1=a}function Le(e,n,r){var i,a=this._x0,o=this._y0,s,c,l,u,d=this._x1,f=this._y1,p=[],m=this._root,h,g;for(m&&p.push(new F(m,a,o,d,f)),r==null?r=1/0:(a=e-r,o=n-r,d=e+r,f=n+r,r*=r);h=p.pop();)if(!(!(m=h.node)||(s=h.x0)>d||(c=h.y0)>f||(l=h.x1)<a||(u=h.y1)<o))if(m.length){var _=(s+l)/2,v=(c+u)/2;p.push(new F(m[3],_,v,l,u),new F(m[2],s,v,_,u),new F(m[1],_,c,l,v),new F(m[0],s,c,_,v)),(g=(n>=v)<<1|e>=_)&&(h=p[p.length-1],p[p.length-1]=p[p.length-1-g],p[p.length-1-g]=h)}else{var y=e-+this._x.call(null,m.data),b=n-+this._y.call(null,m.data),x=y*y+b*b;if(x<r){var S=Math.sqrt(r=x);a=e-S,o=n-S,d=e+S,f=n+S,i=m.data}}return i}function Re(e){if(isNaN(d=+this._x.call(null,e))||isNaN(f=+this._y.call(null,e)))return this;var n,r=this._root,i,a,o,s=this._x0,c=this._y0,l=this._x1,u=this._y1,d,f,p,m,h,g,_,v;if(!r)return this;if(r.length)for(;;){if((h=d>=(p=(s+l)/2))?s=p:l=p,(g=f>=(m=(c+u)/2))?c=m:u=m,n=r,!(r=r[_=g<<1|h]))return this;if(!r.length)break;(n[_+1&3]||n[_+2&3]||n[_+3&3])&&(i=n,v=_)}for(;r.data!==e;)if(a=r,!(r=r.next))return this;return(o=r.next)&&delete r.next,a?(o?a.next=o:delete a.next,this):n?(o?n[_]=o:delete n[_],(r=n[0]||n[1]||n[2]||n[3])&&r===(n[3]||n[2]||n[1]||n[0])&&!r.length&&(i?i[v]=r:this._root=r),this):(this._root=o,this)}function I(e){for(var n=0,r=e.length;n<r;++n)this.remove(e[n]);return this}function ze(){return this._root}function Be(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function Ve(e){var n=[],r,i=this._root,a,o,s,c,l;for(i&&n.push(new F(i,this._x0,this._y0,this._x1,this._y1));r=n.pop();)if(!e(i=r.node,o=r.x0,s=r.y0,c=r.x1,l=r.y1)&&i.length){var u=(o+c)/2,d=(s+l)/2;(a=i[3])&&n.push(new F(a,u,d,c,l)),(a=i[2])&&n.push(new F(a,o,d,u,l)),(a=i[1])&&n.push(new F(a,u,s,c,d)),(a=i[0])&&n.push(new F(a,o,s,u,d))}return this}function He(e){var n=[],r=[],i;for(this._root&&n.push(new F(this._root,this._x0,this._y0,this._x1,this._y1));i=n.pop();){var a=i.node;if(a.length){var o,s=i.x0,c=i.y0,l=i.x1,u=i.y1,d=(s+l)/2,f=(c+u)/2;(o=a[0])&&n.push(new F(o,s,c,d,f)),(o=a[1])&&n.push(new F(o,d,c,l,f)),(o=a[2])&&n.push(new F(o,s,f,d,u)),(o=a[3])&&n.push(new F(o,d,f,l,u))}r.push(i)}for(;i=r.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function L(e){return e[0]}function Ue(e){return arguments.length?(this._x=e,this):this._x}function R(e){return e[1]}function We(e){return arguments.length?(this._y=e,this):this._y}function Ge(e,n,r){var i=new z(n??L,r??R,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function z(e,n,r,i,a,o){this._x=e,this._y=n,this._x0=r,this._y0=i,this._x1=a,this._y1=o,this._root=void 0}function Ke(e){for(var n={data:e.data},r=n;e=e.next;)r=r.next={data:e.data};return n}var B=Ge.prototype=z.prototype;B.copy=function(){var e=new z(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,r,i;if(!n)return e;if(!n.length)return e._root=Ke(n),e;for(r=[{source:n,target:e._root=[,,,,]}];n=r.pop();)for(var a=0;a<4;++a)(i=n.source[a])&&(i.length?r.push({source:i,target:n.target[a]=[,,,,]}):n.target[a]=Ke(i));return e},B.add=Me,B.addAll=Pe,B.cover=Fe,B.data=Ie,B.extent=P,B.find=Le,B.remove=Re,B.removeAll=I,B.root=ze,B.size=Be,B.visit=Ve,B.visitAfter=He,B.x=Ue,B.y=We;var qe=j(`a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928`),V=i(),H=e(r(),1),Je=a(),Ye=`Expected a function`,Xe=Math.max,Ze=Math.min;function Qe(e,n,r){var i,a,o,s,c,l,u=0,d=!1,f=!1,p=!0;if(typeof e!=`function`)throw TypeError(Ye);n=Se(n)||0,le(r)&&(d=!!r.leading,f=`maxWait`in r,o=f?Xe(Se(r.maxWait)||0,n):o,p=`trailing`in r?!!r.trailing:p);function m(n){var r=i,o=a;return i=a=void 0,u=n,s=e.apply(o,r),s}function h(e){return u=e,c=setTimeout(v,n),d?m(e):s}function g(e){var r=e-l,i=e-u,a=n-r;return f?Ze(a,o-i):a}function _(e){var r=e-l,i=e-u;return l===void 0||r>=n||r<0||f&&i>=o}function v(){var e=M();if(_(e))return y(e);c=setTimeout(v,g(e))}function y(e){return c=void 0,p&&i?m(e):(i=a=void 0,s)}function b(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function x(){return c===void 0?s:y(M())}function S(){var e=M(),r=_(e);if(i=arguments,a=this,l=e,r){if(c===void 0)return h(l);if(f)return clearTimeout(c),c=setTimeout(v,n),m(l)}return c===void 0&&(c=setTimeout(v,n)),s}return S.cancel=b,S.flush=x,S}var $e=`Expected a function`;function et(e,n,r){var i=!0,a=!0;if(typeof e!=`function`)throw TypeError($e);return le(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),Qe(e,n,{leading:i,maxWait:n,trailing:a})}var tt=[`#60a5fa`,`#a78bfa`,`#34d399`,`#f472b6`,`#fb923c`,`#22d3ee`,`#c084fc`,`#4ade80`,`#f87171`,`#eab308`,`#ec4899`,`#06b67f`,`#8b5cf6`,`#f43f5e`,`#0ea5e9`,`#a855f7`],nt=[`#1e40af`,`#6b21a8`,`#166534`,`#9f1239`,`#9a3412`,`#164e63`,`#581c87`,`#166534`,`#991b1b`,`#854d0e`,`#831843`,`#0f766e`,`#312e81`,`#9f1239`,`#0c4a6e`,`#6b21a8`];function rt(e){let n=2;for(let r=0;r<e.length;r++)n=Math.imul(n^e.charCodeAt(r),1540483477),n^=n>>>13,n=Math.imul(n,1540483477),n^=n>>>15;return n>>>0}function it(e,n){let r=n?tt:nt;return r[rt(e)%r.length]}var at={fullscreen:{maxEntries:10,containerClassName:`bottom-3 left-3 gap-1 rounded-lg px-3 py-2 text-xs`,titleClassName:`mb-1.5`,rowClassName:`gap-2`,swatchClassName:`size-2.5`,labelClassName:`max-w-[140px]`,overflowClassName:`pl-[18px]`},docked:{maxEntries:6,containerClassName:`bottom-2 left-2 gap-0.5 rounded-md px-2 py-1.5 text-[11px]`,titleClassName:`mb-1`,rowClassName:`gap-1.5`,swatchClassName:`size-2`,labelClassName:`max-w-[112px]`,overflowClassName:`pl-[14px]`}};function ot(e){return at[e]}function st(e){let n=(0,Je.c)(5),{clusters:r,variant:i}=e,a=i===void 0?`fullscreen`:i,{resolvedTheme:o}=y(),s=o===`dark`,c,l;if(n[0]!==r||n[1]!==s||n[2]!==a){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e=ot(a);if(r.length===0){l=null;break bb0}let n=r.slice(0,e.maxEntries),i=r.length-n.length;c=(0,V.jsxs)(`div`,{className:D(`pointer-events-none absolute z-10 flex flex-col backdrop-blur-sm`,e.containerClassName,s?`bg-black/70 text-gray-200`:`bg-white/80 text-gray-800 ring-1 ring-black/5`),children:[(0,V.jsx)(`div`,{className:D(`font-medium`,e.titleClassName,s?`text-slate-300`:`text-slate-700`),children:`Clusters`}),n.map(n=>(0,V.jsxs)(`div`,{className:D(`flex items-center`,e.rowClassName),children:[(0,V.jsx)(`span`,{className:D(`inline-block shrink-0 rounded-full`,e.swatchClassName),style:{backgroundColor:it(n,s)}}),(0,V.jsx)(`span`,{className:D(`truncate`,e.labelClassName),children:n})]},n)),i>0&&(0,V.jsxs)(`div`,{className:D(`text-muted-foreground`,e.overflowClassName),children:[`+ `,i,` more`]})]})}n[0]=r,n[1]=s,n[2]=a,n[3]=c,n[4]=l}else c=n[3],l=n[4];return l===Symbol.for(`react.early_return_sentinel`)?c:l}function ct(e,n){var r=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(r!=null){var i,a,o,s,c=[],l=!0,u=!1;try{if(o=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=o.call(r)).done)&&(c.push(i.value),c.length!==n);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw a}}return c}}function lt(e,n,r){return n=bt(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function ut(e,n){return pt(e)||ct(e,n)||ht(e,n)||vt()}function dt(e){return ft(e)||mt(e)||ht(e)||_t()}function ft(e){if(Array.isArray(e))return gt(e)}function pt(e){if(Array.isArray(e))return e}function mt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function ht(e,n){if(e){if(typeof e==`string`)return gt(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`)return Array.from(e);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gt(e,n)}}function gt(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function _t(){throw TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{o as e,t as n}from"./chunk-CFjPhJqf.js";import{n as r,r as i,t as a}from"./compiler-runtime-CVnuRdak.js";import{a as o,c as s,i as c,n as l,o as u,r as d,s as f,t as p}from"./panel-8fydlQgn.js";import{Ct as m,Dt as h,Fr as g,Ir as _,Mn as v,Rr as y,St as b,ht as x,i as S,p as C,s as w,yt as T}from"./doc-hash-Bg2WkAY_.js";import{C as E,r as D,t as ee}from"./button-C1nwPVFQ.js";import{n as te,r as ne,t as re}from"./target-navigation-intent-zW_9xoDt.js";import{n as ie,t as ae}from"./toggle-group-BMp2XgSC.js";import{i as oe,n as se,t as ce}from"./tooltip-CYfWgpPY.js";import{n as le}from"./isObjectLike-DFnkciUU.js";import{t as ue}from"./ordinal-BLFwWMHf.js";import{n as de,t as fe}from"./min-BiwsSkbB.js";import{C as pe,S as me,_ as he,b as ge,g as _e,n as O,r as ve,t as ye,v as k,w as A,x as be,y as xe}from"./src-L3wpjxBL.js";import{t as j}from"./colors-D6LRuSY-.js";import{n as Se,t as M}from"./now-D_m-3Vjm.js";var Ce=E(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),we=E(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]);function Te(e,n){let r=0;if(n===void 0)for(let n of e)(n=+n)&&(r+=n);else{let i=-1;for(let a of e)(a=+n(a,++i,e))&&(r+=a)}return r}var Ee=e=>()=>e;function N(e,{sourceEvent:n,subject:r,target:i,identifier:a,active:o,x:s,y:c,dx:l,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}N.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function De(e){return!e.ctrlKey&&!e.button}function Oe(){return this.parentNode}function ke(e,n){return n??{x:e.x,y:e.y}}function Ae(){return navigator.maxTouchPoints||`ontouchstart`in this}function je(){var e=De,n=Oe,r=ke,i=Ae,a={},o=A(`start`,`drag`,`end`),s=0,c,l,u,d,f=0;function p(e){e.on(`mousedown.drag`,m).filter(i).on(`touchstart.drag`,_).on(`touchmove.drag`,v,xe).on(`touchend.drag touchcancel.drag`,y).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function m(r,i){if(!(d||!e.call(this,r,i))){var a=b(this,n.call(this,r,i),r,i,`mouse`);a&&(pe(r.view).on(`mousemove.drag`,h,ge).on(`mouseup.drag`,g,ge),_e(r.view),be(r),u=!1,c=r.clientX,l=r.clientY,a(`start`,r))}}function h(e){if(k(e),!u){var n=e.clientX-c,r=e.clientY-l;u=n*n+r*r>f}a.mouse(`drag`,e)}function g(e){pe(e.view).on(`mousemove.drag mouseup.drag`,null),he(e.view,u),k(e),a.mouse(`end`,e)}function _(r,i){if(e.call(this,r,i)){var a=r.changedTouches,o=n.call(this,r,i),s=a.length,c,l;for(c=0;c<s;++c)(l=b(this,o,r,i,a[c].identifier,a[c]))&&(be(r),l(`start`,r,a[c]))}}function v(e){var n=e.changedTouches,r=n.length,i,o;for(i=0;i<r;++i)(o=a[n[i].identifier])&&(k(e),o(`drag`,e,n[i]))}function y(e){var n=e.changedTouches,r=n.length,i,o;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),i=0;i<r;++i)(o=a[n[i].identifier])&&(be(e),o(`end`,e,n[i]))}function b(e,n,i,c,l,u){var d=o.copy(),f=me(u||i,n),m,h,g;if((g=r.call(e,new N(`beforestart`,{sourceEvent:i,target:p,identifier:l,active:s,x:f[0],y:f[1],dx:0,dy:0,dispatch:d}),c))!=null)return m=g.x-f[0]||0,h=g.y-f[1]||0,function r(i,o,u){var _=f,v;switch(i){case`start`:a[l]=r,v=s++;break;case`end`:delete a[l],--s;case`drag`:f=me(u||o,n),v=s;break}d.call(i,e,new N(i,{sourceEvent:o,subject:g,target:p,identifier:l,active:v,x:f[0]+m,y:f[1]+h,dx:f[0]-_[0],dy:f[1]-_[1],dispatch:d}),c)}}return p.filter=function(n){return arguments.length?(e=typeof n==`function`?n:Ee(!!n),p):e},p.container=function(e){return arguments.length?(n=typeof e==`function`?e:Ee(e),p):n},p.subject=function(e){return arguments.length?(r=typeof e==`function`?e:Ee(e),p):r},p.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:Ee(!!e),p):i},p.on=function(){var e=o.on.apply(o,arguments);return e===o?p:e},p.clickDistance=function(e){return arguments.length?(f=(e=+e)*e,p):Math.sqrt(f)},p}function Me(e){let n=+this._x.call(null,e),r=+this._y.call(null,e);return Ne(this.cover(n,r),n,r,e)}function Ne(e,n,r,i){if(isNaN(n)||isNaN(r))return e;var a,o=e._root,s={data:i},c=e._x0,l=e._y0,u=e._x1,d=e._y1,f,p,m,h,g,_,v,y;if(!o)return e._root=s,e;for(;o.length;)if((g=n>=(f=(c+u)/2))?c=f:u=f,(_=r>=(p=(l+d)/2))?l=p:d=p,a=o,!(o=o[v=_<<1|g]))return a[v]=s,e;if(m=+e._x.call(null,o.data),h=+e._y.call(null,o.data),n===m&&r===h)return s.next=o,a?a[v]=s:e._root=s,e;do a=a?a[v]=[,,,,]:e._root=[,,,,],(g=n>=(f=(c+u)/2))?c=f:u=f,(_=r>=(p=(l+d)/2))?l=p:d=p;while((v=_<<1|g)==(y=(h>=p)<<1|m>=f));return a[y]=o,a[v]=s,e}function Pe(e){var n,r,i=e.length,a,o,s=Array(i),c=Array(i),l=1/0,u=1/0,d=-1/0,f=-1/0;for(r=0;r<i;++r)isNaN(a=+this._x.call(null,n=e[r]))||isNaN(o=+this._y.call(null,n))||(s[r]=a,c[r]=o,a<l&&(l=a),a>d&&(d=a),o<u&&(u=o),o>f&&(f=o));if(l>d||u>f)return this;for(this.cover(l,u).cover(d,f),r=0;r<i;++r)Ne(this,s[r],c[r],e[r]);return this}function Fe(e,n){if(isNaN(e=+e)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,a=this._x1,o=this._y1;if(isNaN(r))a=(r=Math.floor(e))+1,o=(i=Math.floor(n))+1;else{for(var s=a-r||1,c=this._root,l,u;r>e||e>=a||i>n||n>=o;)switch(u=(n<i)<<1|e<r,l=[,,,,],l[u]=c,c=l,s*=2,u){case 0:a=r+s,o=i+s;break;case 1:r=a-s,o=i+s;break;case 2:a=r+s,i=o-s;break;case 3:r=a-s,i=o-s;break}this._root&&this._root.length&&(this._root=c)}return this._x0=r,this._y0=i,this._x1=a,this._y1=o,this}function Ie(){var e=[];return this.visit(function(n){if(!n.length)do e.push(n.data);while(n=n.next)}),e}function P(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function F(e,n,r,i,a){this.node=e,this.x0=n,this.y0=r,this.x1=i,this.y1=a}function Le(e,n,r){var i,a=this._x0,o=this._y0,s,c,l,u,d=this._x1,f=this._y1,p=[],m=this._root,h,g;for(m&&p.push(new F(m,a,o,d,f)),r==null?r=1/0:(a=e-r,o=n-r,d=e+r,f=n+r,r*=r);h=p.pop();)if(!(!(m=h.node)||(s=h.x0)>d||(c=h.y0)>f||(l=h.x1)<a||(u=h.y1)<o))if(m.length){var _=(s+l)/2,v=(c+u)/2;p.push(new F(m[3],_,v,l,u),new F(m[2],s,v,_,u),new F(m[1],_,c,l,v),new F(m[0],s,c,_,v)),(g=(n>=v)<<1|e>=_)&&(h=p[p.length-1],p[p.length-1]=p[p.length-1-g],p[p.length-1-g]=h)}else{var y=e-+this._x.call(null,m.data),b=n-+this._y.call(null,m.data),x=y*y+b*b;if(x<r){var S=Math.sqrt(r=x);a=e-S,o=n-S,d=e+S,f=n+S,i=m.data}}return i}function Re(e){if(isNaN(d=+this._x.call(null,e))||isNaN(f=+this._y.call(null,e)))return this;var n,r=this._root,i,a,o,s=this._x0,c=this._y0,l=this._x1,u=this._y1,d,f,p,m,h,g,_,v;if(!r)return this;if(r.length)for(;;){if((h=d>=(p=(s+l)/2))?s=p:l=p,(g=f>=(m=(c+u)/2))?c=m:u=m,n=r,!(r=r[_=g<<1|h]))return this;if(!r.length)break;(n[_+1&3]||n[_+2&3]||n[_+3&3])&&(i=n,v=_)}for(;r.data!==e;)if(a=r,!(r=r.next))return this;return(o=r.next)&&delete r.next,a?(o?a.next=o:delete a.next,this):n?(o?n[_]=o:delete n[_],(r=n[0]||n[1]||n[2]||n[3])&&r===(n[3]||n[2]||n[1]||n[0])&&!r.length&&(i?i[v]=r:this._root=r),this):(this._root=o,this)}function I(e){for(var n=0,r=e.length;n<r;++n)this.remove(e[n]);return this}function ze(){return this._root}function Be(){var e=0;return this.visit(function(n){if(!n.length)do++e;while(n=n.next)}),e}function Ve(e){var n=[],r,i=this._root,a,o,s,c,l;for(i&&n.push(new F(i,this._x0,this._y0,this._x1,this._y1));r=n.pop();)if(!e(i=r.node,o=r.x0,s=r.y0,c=r.x1,l=r.y1)&&i.length){var u=(o+c)/2,d=(s+l)/2;(a=i[3])&&n.push(new F(a,u,d,c,l)),(a=i[2])&&n.push(new F(a,o,d,u,l)),(a=i[1])&&n.push(new F(a,u,s,c,d)),(a=i[0])&&n.push(new F(a,o,s,u,d))}return this}function He(e){var n=[],r=[],i;for(this._root&&n.push(new F(this._root,this._x0,this._y0,this._x1,this._y1));i=n.pop();){var a=i.node;if(a.length){var o,s=i.x0,c=i.y0,l=i.x1,u=i.y1,d=(s+l)/2,f=(c+u)/2;(o=a[0])&&n.push(new F(o,s,c,d,f)),(o=a[1])&&n.push(new F(o,d,c,l,f)),(o=a[2])&&n.push(new F(o,s,f,d,u)),(o=a[3])&&n.push(new F(o,d,f,l,u))}r.push(i)}for(;i=r.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function L(e){return e[0]}function Ue(e){return arguments.length?(this._x=e,this):this._x}function R(e){return e[1]}function We(e){return arguments.length?(this._y=e,this):this._y}function Ge(e,n,r){var i=new z(n??L,r??R,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function z(e,n,r,i,a,o){this._x=e,this._y=n,this._x0=r,this._y0=i,this._x1=a,this._y1=o,this._root=void 0}function Ke(e){for(var n={data:e.data},r=n;e=e.next;)r=r.next={data:e.data};return n}var B=Ge.prototype=z.prototype;B.copy=function(){var e=new z(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,r,i;if(!n)return e;if(!n.length)return e._root=Ke(n),e;for(r=[{source:n,target:e._root=[,,,,]}];n=r.pop();)for(var a=0;a<4;++a)(i=n.source[a])&&(i.length?r.push({source:i,target:n.target[a]=[,,,,]}):n.target[a]=Ke(i));return e},B.add=Me,B.addAll=Pe,B.cover=Fe,B.data=Ie,B.extent=P,B.find=Le,B.remove=Re,B.removeAll=I,B.root=ze,B.size=Be,B.visit=Ve,B.visitAfter=He,B.x=Ue,B.y=We;var qe=j(`a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928`),V=i(),H=e(r(),1),Je=a(),Ye=`Expected a function`,Xe=Math.max,Ze=Math.min;function Qe(e,n,r){var i,a,o,s,c,l,u=0,d=!1,f=!1,p=!0;if(typeof e!=`function`)throw TypeError(Ye);n=Se(n)||0,le(r)&&(d=!!r.leading,f=`maxWait`in r,o=f?Xe(Se(r.maxWait)||0,n):o,p=`trailing`in r?!!r.trailing:p);function m(n){var r=i,o=a;return i=a=void 0,u=n,s=e.apply(o,r),s}function h(e){return u=e,c=setTimeout(v,n),d?m(e):s}function g(e){var r=e-l,i=e-u,a=n-r;return f?Ze(a,o-i):a}function _(e){var r=e-l,i=e-u;return l===void 0||r>=n||r<0||f&&i>=o}function v(){var e=M();if(_(e))return y(e);c=setTimeout(v,g(e))}function y(e){return c=void 0,p&&i?m(e):(i=a=void 0,s)}function b(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function x(){return c===void 0?s:y(M())}function S(){var e=M(),r=_(e);if(i=arguments,a=this,l=e,r){if(c===void 0)return h(l);if(f)return clearTimeout(c),c=setTimeout(v,n),m(l)}return c===void 0&&(c=setTimeout(v,n)),s}return S.cancel=b,S.flush=x,S}var $e=`Expected a function`;function et(e,n,r){var i=!0,a=!0;if(typeof e!=`function`)throw TypeError($e);return le(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),Qe(e,n,{leading:i,maxWait:n,trailing:a})}var tt=[`#60a5fa`,`#a78bfa`,`#34d399`,`#f472b6`,`#fb923c`,`#22d3ee`,`#c084fc`,`#4ade80`,`#f87171`,`#eab308`,`#ec4899`,`#06b67f`,`#8b5cf6`,`#f43f5e`,`#0ea5e9`,`#a855f7`],nt=[`#1e40af`,`#6b21a8`,`#166534`,`#9f1239`,`#9a3412`,`#164e63`,`#581c87`,`#166534`,`#991b1b`,`#854d0e`,`#831843`,`#0f766e`,`#312e81`,`#9f1239`,`#0c4a6e`,`#6b21a8`];function rt(e){let n=2;for(let r=0;r<e.length;r++)n=Math.imul(n^e.charCodeAt(r),1540483477),n^=n>>>13,n=Math.imul(n,1540483477),n^=n>>>15;return n>>>0}function it(e,n){let r=n?tt:nt;return r[rt(e)%r.length]}var at={fullscreen:{maxEntries:10,containerClassName:`bottom-3 left-3 gap-1 rounded-lg px-3 py-2 text-xs`,titleClassName:`mb-1.5`,rowClassName:`gap-2`,swatchClassName:`size-2.5`,labelClassName:`max-w-[140px]`,overflowClassName:`pl-[18px]`},docked:{maxEntries:6,containerClassName:`bottom-2 left-2 gap-0.5 rounded-md px-2 py-1.5 text-[11px]`,titleClassName:`mb-1`,rowClassName:`gap-1.5`,swatchClassName:`size-2`,labelClassName:`max-w-[112px]`,overflowClassName:`pl-[14px]`}};function ot(e){return at[e]}function st(e){let n=(0,Je.c)(5),{clusters:r,variant:i}=e,a=i===void 0?`fullscreen`:i,{resolvedTheme:o}=y(),s=o===`dark`,c,l;if(n[0]!==r||n[1]!==s||n[2]!==a){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e=ot(a);if(r.length===0){l=null;break bb0}let n=r.slice(0,e.maxEntries),i=r.length-n.length;c=(0,V.jsxs)(`div`,{className:D(`pointer-events-none absolute z-10 flex flex-col backdrop-blur-sm`,e.containerClassName,s?`bg-black/70 text-gray-200`:`bg-white/80 text-gray-800 ring-1 ring-black/5`),children:[(0,V.jsx)(`div`,{className:D(`font-medium`,e.titleClassName,s?`text-slate-300`:`text-slate-700`),children:`Clusters`}),n.map(n=>(0,V.jsxs)(`div`,{className:D(`flex items-center`,e.rowClassName),children:[(0,V.jsx)(`span`,{className:D(`inline-block shrink-0 rounded-full`,e.swatchClassName),style:{backgroundColor:it(n,s)}}),(0,V.jsx)(`span`,{className:D(`truncate`,e.labelClassName),children:n})]},n)),i>0&&(0,V.jsxs)(`div`,{className:D(`text-muted-foreground`,e.overflowClassName),children:[`+ `,i,` more`]})]})}n[0]=r,n[1]=s,n[2]=a,n[3]=c,n[4]=l}else c=n[3],l=n[4];return l===Symbol.for(`react.early_return_sentinel`)?c:l}function ct(e,n){var r=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(r!=null){var i,a,o,s,c=[],l=!0,u=!1;try{if(o=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=o.call(r)).done)&&(c.push(i.value),c.length!==n);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw a}}return c}}function lt(e,n,r){return n=bt(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function ut(e,n){return pt(e)||ct(e,n)||ht(e,n)||vt()}function dt(e){return ft(e)||mt(e)||ht(e)||_t()}function ft(e){if(Array.isArray(e))return gt(e)}function pt(e){if(Array.isArray(e))return e}function mt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function ht(e,n){if(e){if(typeof e==`string`)return gt(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`)return Array.from(e);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gt(e,n)}}function gt(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function _t(){throw TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yt(e,n){if(typeof e!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(typeof i!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function bt(e){var n=yt(e,`string`);return typeof n==`symbol`?n:String(n)}var xt=function(e,n){var r=new Set(n);return Object.assign.apply(Object,[{}].concat(dt(Object.entries(e).filter(function(e){var n=ut(e,1)[0];return!r.has(n)}).map(function(e){var n=ut(e,2),r=n[0],i=n[1];return lt({},r,i)}))))};function St(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function Ct(e){if(Array.isArray(e))return e}function wt(e){if(Array.isArray(e))return St(e)}function Tt(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Et(e,n){var r=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(r!=null){var i,a,o,s,c=[],l=!0,u=!1;try{if(o=(r=r.call(e)).next,n!==0)for(;!(l=(i=o.call(r)).done)&&(c.push(i.value),c.length!==n);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw a}}return c}}function Dt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ot(){throw TypeError(`Invalid attempt to spread non-iterable instance.
@@ -1,2 +1,2 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{Q as i,Vt as a,n as o}from"./DocumentContext-Ccj8qLzP.js";import{a as s,c,i as l,n as u,o as d,r as f,s as ee,t as te,u as ne}from"./panel-8fydlQgn.js";import{Dt as re,s as ie,wt as ae}from"./doc-hash-C9Z2AnUu.js";import{r as oe}from"./button-C1nwPVFQ.js";import{$ as se,A as p,B as m,Bt as h,Ct as g,D as _,Dt as v,E as y,Et as b,Ft as x,Ht as ce,It as S,J as C,Lt as w,M as T,N as E,Nt as D,Pt as O,Q as le,Rt as ue,S as de,St as fe,T as pe,Tt as k,Vt as A,Y as j,Z as M,at as N,bt as me,c as he,ct as ge,d as _e,et as ve,g as ye,gt as be,ht as xe,jt as Se,kt as Ce,lt as we,mt as Te,n as Ee,nt as De,ot as Oe,pt as ke,q as P,st as Ae,tt as je,ut as Me,v as Ne,vt as F,x as Pe,xt as Fe,zt as Ie}from"./dist-B-xmnigy.js";import{i as Le,n as Re,o as ze,r as Be}from"./dist-Nw1RXfXU.js";var Ve=e(t(),1),He=r(),Ue=new Map;function We(e,t){Ue.set(e,t)}function Ge(e){let t=Ue.get(e)??null;return Ue.delete(e),t}function Ke(e){Ue.delete(e)}var qe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Qe(e.state,n.from);return r.line?Ye(e):r.block?Ze(e):!1};function Je(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Ye=Je(nt,0),Xe=Je(tt,0),Ze=Je((e,t)=>tt(e,t,et(t)),0);function Qe(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var I=50;function $e(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-I,r),o=e.sliceDoc(i,i+I),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*I?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+I),d=e.sliceDoc(i-I,i));let f=/^\s*/.exec(u)[0].length,ee=/\s*$/.exec(d)[0].length,te=d.length-ee-n.length;return u.slice(f,f+t.length)==t&&d.slice(te,te+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-ee-n.length,margin:+!!/\s/.test(d.charAt(te-1))}}:null}function et(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function tt(e,t,n=t.selection.ranges){let r=n.map(e=>Qe(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>$e(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function nt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Qe(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var rt=me.define(),it=me.define(),at=v.define(),ot=v.define({combine(e){return Ie(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),st=O.define({create(){return wt.empty},update(e,t){let n=t.state.facet(ot),r=t.annotation(rt);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?mt(o,o.length,n.minDepth,i):yt(o,t.startState.selection),new wt(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(it);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(S.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(S.time),s=t.annotation(S.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new wt(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function ct(e={}){return[st,ot.of(e),j.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ut:e.inputType==`historyRedo`?dt:null;return n?(e.preventDefault(),n(t)):!1}})]}function lt(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(st,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var ut=lt(0,!1),dt=lt(1,!1),ft=lt(0,!0),pt=lt(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&fe.fromJSON(t.changes),[],t.mapped&&Fe.fromJSON(t.mapped),t.startSelection&&k.fromJSON(t.startSelection),t.selectionsAfter.map(k.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(at)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function mt(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function ht(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function gt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function _t(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],vt=200;function yt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-vt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),mt(e,e.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([t])]}function bt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function xt(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=St(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function St(e,t,n){let r=_t(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,D.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Ct=/^(input\.type|delete)($|\.)/,wt=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Ct.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,ht(s.changes,t.changes))||r==`input.type.compose`)?mt(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),_t(D.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):mt(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&gt(a[a.length-1],t)?this:new e(yt(this.done,t),this.undone,n,r)}addMapping(t){return new e(xt(this.done,t),xt(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:rt.of({side:e,rest:bt(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=xt(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:rt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};wt.empty=new wt(R,R);var Tt=[{key:`Mod-z`,run:ut,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:dt,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:dt,preventDefault:!0},{key:`Mod-u`,run:ft,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:pt,preventDefault:!0}];function z(e,t){return k.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function V({state:e,dispatch:t},n){let r=z(e.selection,n);return r.eq(e.selection,!0)?!1:(t(B(e,r)),!0)}function Et(e,t){return k.cursor(t?e.to:e.from)}function Dt(e,t){return V(e,n=>n.empty?e.moveByChar(n,t):Et(n,t))}function H(e){return e.textDirectionAt(e.state.selection.main.head)==C.LTR}var Ot=e=>Dt(e,!H(e)),kt=e=>Dt(e,H(e));function At(e,t){return V(e,n=>n.empty?e.moveByGroup(n,t):Et(n,t))}var jt=e=>At(e,!H(e)),Mt=e=>At(e,H(e));typeof Intl<`u`&&Intl.Segmenter;function Nt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Pt(e,t,n){let r=E(e).resolveInner(t.head),i=n?m.closedBy:m.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Nt(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?p(e,r.from,1):p(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,k.cursor(s,n?-1:1)}var Ft=e=>V(e,t=>Pt(e.state,t,!H(e))),It=e=>V(e,t=>Pt(e.state,t,H(e)));function Lt(e,t){return V(e,n=>{if(!n.empty)return Et(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Rt=e=>Lt(e,!1),zt=e=>Lt(e,!0);function Bt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(j.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Vt(e,t){let n=Bt(e),{state:r}=e,i=z(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Et(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=j.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(B(r,i),{effects:a}),!0}var Ht=e=>Vt(e,!1),Ut=e=>Vt(e,!0);function U(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=k.cursor(r.from+n))}return i}var Wt=e=>V(e,t=>U(e,t,!0)),Gt=e=>V(e,t=>U(e,t,!1)),Kt=e=>V(e,t=>U(e,t,!H(e))),qt=e=>V(e,t=>U(e,t,H(e))),Jt=e=>V(e,t=>k.cursor(e.lineBlockAt(t.head).from,1)),Yt=e=>V(e,t=>k.cursor(e.lineBlockAt(t.head).to,-1));function Xt(e,t,n){let r=!1,i=z(e.selection,t=>{let i=p(e,t.head,-1)||p(e,t.head,1)||t.head>0&&p(e,t.head-1,1)||t.head<e.doc.length&&p(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?k.range(t.anchor,a):k.cursor(a)});return r?(t(B(e,i)),!0):!1}var Zt=({state:e,dispatch:t})=>Xt(e,t,!1);function W(e,t){let n=z(e.state.selection,e=>{let n=t(e);return k.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(B(e.state,n)),!0)}function Qt(e,t){return W(e,n=>e.moveByChar(n,t))}var $t=e=>Qt(e,!H(e)),en=e=>Qt(e,H(e));function tn(e,t){return W(e,n=>e.moveByGroup(n,t))}var nn=e=>tn(e,!H(e)),rn=e=>tn(e,H(e)),an=e=>W(e,t=>Pt(e.state,t,!H(e))),on=e=>W(e,t=>Pt(e.state,t,H(e)));function sn(e,t){return W(e,n=>e.moveVertically(n,t))}var cn=e=>sn(e,!1),ln=e=>sn(e,!0);function un(e,t){return W(e,n=>e.moveVertically(n,t,Bt(e).height))}var dn=e=>un(e,!1),fn=e=>un(e,!0),pn=e=>W(e,t=>U(e,t,!0)),mn=e=>W(e,t=>U(e,t,!1)),hn=e=>W(e,t=>U(e,t,!H(e))),gn=e=>W(e,t=>U(e,t,H(e))),_n=e=>W(e,t=>k.cursor(e.lineBlockAt(t.head).from)),vn=e=>W(e,t=>k.cursor(e.lineBlockAt(t.head).to)),yn=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),bn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),xn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),Sn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Cn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),wn=({state:e,dispatch:t})=>{let n=Un(e).map(({from:t,to:n})=>k.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:k.create(n),userEvent:`select`})),!0},Tn=({state:e,dispatch:t})=>{let n=z(e.selection,t=>{let n=E(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return k.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(B(e,n)),!0)};function En(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(B(n,k.create(i,i.length-1))),!0)}var Dn=e=>En(e,!1),On=e=>En(e,!0),kn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=k.create([n.main]):n.main.empty||(r=k.create([k.cursor(n.main.head)])),r?(t(B(e,r)),!0):!1};function An(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=jn(e,o,!1)):o>i&&(n=`delete.forward`,o=jn(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=jn(e,i,!1),a=jn(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:k.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?j.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function jn(e,t,n){if(e instanceof j)for(let r of e.state.facet(j.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var Mn=(e,t,n)=>An(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=h(s,a.tabSize)%Pe(a)||Pe(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=A(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=A(o.text,c-o.from,!1,!1)+o.from);return c}),Nn=e=>Mn(e,!1,!0),Pn=e=>Mn(e,!0,!1),Fn=(e,t)=>An(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=A(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),In=e=>Fn(e,!1),Ln=e=>Fn(e,!0),Rn=e=>An(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),zn=e=>An(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Bn=e=>An(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Vn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:x.of([``,``])},range:k.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Hn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:A(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:A(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:k.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Un(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Wn(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Un(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(k.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(k.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:k.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Gn=({state:e,dispatch:t})=>Wn(e,t,!1),Kn=({state:e,dispatch:t})=>Wn(e,t,!0);function qn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Un(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var Jn=({state:e,dispatch:t})=>qn(e,t,!1),Yn=({state:e,dispatch:t})=>qn(e,t,!0),Xn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Un(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=z(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Zn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=E(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(m.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Qn=er(!1),$n=er(!0);function er(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Zn(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Ee(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=de(s,r);for(c??=h(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,y(t,c)];return o&&l.push(y(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:x.of(l)},range:k.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function tr(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:k.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var nr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ee(e,{overrideIndentation:e=>n[e]??-1}),i=tr(e,(t,i,a)=>{let o=de(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=y(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},rr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(tr(e,(t,n)=>{n.push({from:t.from,insert:e.facet(_)})}),{userEvent:`input.indent`})),!0),ir=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(tr(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=h(r,e.tabSize),a=0,o=y(e,Math.max(0,i-Pe(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),ar=e=>(e.setTabFocusMode(),!0),or=[{key:`Ctrl-b`,run:Ot,shift:$t,preventDefault:!0},{key:`Ctrl-f`,run:kt,shift:en},{key:`Ctrl-p`,run:Rt,shift:cn},{key:`Ctrl-n`,run:zt,shift:ln},{key:`Ctrl-a`,run:Jt,shift:_n},{key:`Ctrl-e`,run:Yt,shift:vn},{key:`Ctrl-d`,run:Pn},{key:`Ctrl-h`,run:Nn},{key:`Ctrl-k`,run:Rn},{key:`Ctrl-Alt-h`,run:In},{key:`Ctrl-o`,run:Vn},{key:`Ctrl-t`,run:Hn},{key:`Ctrl-v`,run:Ut}],sr=[{key:`ArrowLeft`,run:Ot,shift:$t,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:jt,shift:nn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Kt,shift:hn,preventDefault:!0},{key:`ArrowRight`,run:kt,shift:en,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Mt,shift:rn,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:qt,shift:gn,preventDefault:!0},{key:`ArrowUp`,run:Rt,shift:cn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:yn,shift:xn},{mac:`Ctrl-ArrowUp`,run:Ht,shift:dn},{key:`ArrowDown`,run:zt,shift:ln,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:bn,shift:Sn},{mac:`Ctrl-ArrowDown`,run:Ut,shift:fn},{key:`PageUp`,run:Ht,shift:dn},{key:`PageDown`,run:Ut,shift:fn},{key:`Home`,run:Gt,shift:mn,preventDefault:!0},{key:`Mod-Home`,run:yn,shift:xn},{key:`End`,run:Wt,shift:pn,preventDefault:!0},{key:`Mod-End`,run:bn,shift:Sn},{key:`Enter`,run:Qn,shift:Qn},{key:`Mod-a`,run:Cn},{key:`Backspace`,run:Nn,shift:Nn,preventDefault:!0},{key:`Delete`,run:Pn,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:In,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Ln,preventDefault:!0},{mac:`Mod-Backspace`,run:zn,preventDefault:!0},{mac:`Mod-Delete`,run:Bn,preventDefault:!0}].concat(or.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),cr=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Ft,shift:an},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:It,shift:on},{key:`Alt-ArrowUp`,run:Gn},{key:`Shift-Alt-ArrowUp`,run:Jn},{key:`Alt-ArrowDown`,run:Kn},{key:`Shift-Alt-ArrowDown`,run:Yn},{key:`Mod-Alt-ArrowUp`,run:Dn},{key:`Mod-Alt-ArrowDown`,run:On},{key:`Escape`,run:kn},{key:`Mod-Enter`,run:$n},{key:`Alt-l`,mac:`Ctrl-l`,run:wn},{key:`Mod-i`,run:Tn,preventDefault:!0},{key:`Mod-[`,run:ir},{key:`Mod-]`,run:rr},{key:`Mod-Alt-\\`,run:nr},{key:`Shift-Mod-k`,run:Xn},{key:`Shift-Mod-\\`,run:Zt},{key:`Mod-/`,run:qe},{key:`Alt-A`,run:Xe},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:ar}].concat(sr),lr={key:`Tab`,run:rr,shift:ir},ur=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,G=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(ur(e)):ur,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return w(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=ce(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ue(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(G.prototype[Symbol.iterator]=function(){return this});var dr={from:-1,to:-1,match:/.*/.exec(``)},fr=`gm`+(/x/.unicode==null?``:`u`),pr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=dr,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new gr(e,t,n,r,i);this.re=new RegExp(t,fr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=vr(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=vr(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},mr=new WeakMap,hr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=mr.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return mr.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),mr.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},gr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=dr,this.matchPos=vr(e,r),this.re=new RegExp(t,fr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=hr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=vr(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=hr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(pr.prototype[Symbol.iterator]=gr.prototype[Symbol.iterator]=function(){return this});function _r(e){try{return new RegExp(e,fr),!0}catch{return!1}}function vr(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var yr=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=xe(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),ee=k.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,j.scrollIntoView(ee.from,{y:`center`})],selection:ee})}),!0},br={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},xr=v.define({combine(e){return Ie(e,br,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Sr(e){let t=[Or,Dr];return e&&t.push(xr.of(e)),t}var Cr=P.mark({class:`cm-selectionMatch`}),wr=P.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Tr(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=g.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=g.Word)}function Er(e,t,n,r){return e(t.sliceDoc(n,n+1))==g.Word&&e(t.sliceDoc(r-1,r))==g.Word}var Dr=M.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(xr),{state:n}=e,r=n.selection;if(r.ranges.length>1)return P.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return P.none;let e=n.wordAt(i.head);if(!e)return P.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return P.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Tr(o,n,i.from,i.to)&&Er(o,n,i.from,i.to)))return P.none}else if(a=n.sliceDoc(i.from,i.to),!a)return P.none}let s=[];for(let r of e.visibleRanges){let e=new G(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Tr(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(wr.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Cr.range(r,a)),s.length>t.maxMatches))return P.none}}return P.set(s)}},{decorations:e=>e.decorations}),Or=j.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),kr=({state:e,dispatch:t})=>{let{selection:n}=e,r=k.create(n.ranges.map(t=>e.wordAt(t.head)||k.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Ar(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new G(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new G(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var jr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return kr({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Ar(e,r);return i?(t(e.update({selection:e.selection.addRange(k.range(i.from,i.to),!1),effects:j.scrollIntoView(i.to)})),!0):!1},K=v.define({combine(e){return Ie(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ci(e),scrollToMatch:e=>j.scrollIntoView(e)})}}),Mr=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||_r(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
1
+ import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{Q as i,Vt as a,n as o}from"./DocumentContext-Bic6EUm_.js";import{a as s,c,i as l,n as u,o as d,r as f,s as ee,t as te,u as ne}from"./panel-8fydlQgn.js";import{Dt as re,s as ie,wt as ae}from"./doc-hash-Bg2WkAY_.js";import{r as oe}from"./button-C1nwPVFQ.js";import{$ as se,A as p,B as m,Bt as h,Ct as g,D as _,Dt as v,E as y,Et as b,Ft as x,Ht as ce,It as S,J as C,Lt as w,M as T,N as E,Nt as D,Pt as O,Q as le,Rt as ue,S as de,St as fe,T as pe,Tt as k,Vt as A,Y as j,Z as M,at as N,bt as me,c as he,ct as ge,d as _e,et as ve,g as ye,gt as be,ht as xe,jt as Se,kt as Ce,lt as we,mt as Te,n as Ee,nt as De,ot as Oe,pt as ke,q as P,st as Ae,tt as je,ut as Me,v as Ne,vt as F,x as Pe,xt as Fe,zt as Ie}from"./dist-B-xmnigy.js";import{i as Le,n as Re,o as ze,r as Be}from"./dist-Nw1RXfXU.js";var Ve=e(t(),1),He=r(),Ue=new Map;function We(e,t){Ue.set(e,t)}function Ge(e){let t=Ue.get(e)??null;return Ue.delete(e),t}function Ke(e){Ue.delete(e)}var qe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Qe(e.state,n.from);return r.line?Ye(e):r.block?Ze(e):!1};function Je(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Ye=Je(nt,0),Xe=Je(tt,0),Ze=Je((e,t)=>tt(e,t,et(t)),0);function Qe(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var I=50;function $e(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-I,r),o=e.sliceDoc(i,i+I),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*I?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+I),d=e.sliceDoc(i-I,i));let f=/^\s*/.exec(u)[0].length,ee=/\s*$/.exec(d)[0].length,te=d.length-ee-n.length;return u.slice(f,f+t.length)==t&&d.slice(te,te+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-ee-n.length,margin:+!!/\s/.test(d.charAt(te-1))}}:null}function et(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function tt(e,t,n=t.selection.ranges){let r=n.map(e=>Qe(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>$e(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function nt(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Qe(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var rt=me.define(),it=me.define(),at=v.define(),ot=v.define({combine(e){return Ie(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),st=O.define({create(){return wt.empty},update(e,t){let n=t.state.facet(ot),r=t.annotation(rt);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?mt(o,o.length,n.minDepth,i):yt(o,t.startState.selection),new wt(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(it);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(S.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(S.time),s=t.annotation(S.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new wt(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function ct(e={}){return[st,ot.of(e),j.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ut:e.inputType==`historyRedo`?dt:null;return n?(e.preventDefault(),n(t)):!1}})]}function lt(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(st,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var ut=lt(0,!1),dt=lt(1,!1),ft=lt(0,!0),pt=lt(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&fe.fromJSON(t.changes),[],t.mapped&&Fe.fromJSON(t.mapped),t.startSelection&&k.fromJSON(t.startSelection),t.selectionsAfter.map(k.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(at)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function mt(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function ht(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function gt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function _t(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],vt=200;function yt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-vt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),mt(e,e.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([t])]}function bt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function xt(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=St(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function St(e,t,n){let r=_t(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,D.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Ct=/^(input\.type|delete)($|\.)/,wt=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Ct.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,ht(s.changes,t.changes))||r==`input.type.compose`)?mt(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),_t(D.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):mt(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&gt(a[a.length-1],t)?this:new e(yt(this.done,t),this.undone,n,r)}addMapping(t){return new e(xt(this.done,t),xt(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:rt.of({side:e,rest:bt(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=xt(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:rt.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};wt.empty=new wt(R,R);var Tt=[{key:`Mod-z`,run:ut,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:dt,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:dt,preventDefault:!0},{key:`Mod-u`,run:ft,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:pt,preventDefault:!0}];function z(e,t){return k.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function V({state:e,dispatch:t},n){let r=z(e.selection,n);return r.eq(e.selection,!0)?!1:(t(B(e,r)),!0)}function Et(e,t){return k.cursor(t?e.to:e.from)}function Dt(e,t){return V(e,n=>n.empty?e.moveByChar(n,t):Et(n,t))}function H(e){return e.textDirectionAt(e.state.selection.main.head)==C.LTR}var Ot=e=>Dt(e,!H(e)),kt=e=>Dt(e,H(e));function At(e,t){return V(e,n=>n.empty?e.moveByGroup(n,t):Et(n,t))}var jt=e=>At(e,!H(e)),Mt=e=>At(e,H(e));typeof Intl<`u`&&Intl.Segmenter;function Nt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Pt(e,t,n){let r=E(e).resolveInner(t.head),i=n?m.closedBy:m.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Nt(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?p(e,r.from,1):p(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,k.cursor(s,n?-1:1)}var Ft=e=>V(e,t=>Pt(e.state,t,!H(e))),It=e=>V(e,t=>Pt(e.state,t,H(e)));function Lt(e,t){return V(e,n=>{if(!n.empty)return Et(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Rt=e=>Lt(e,!1),zt=e=>Lt(e,!0);function Bt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(j.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Vt(e,t){let n=Bt(e),{state:r}=e,i=z(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Et(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=j.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(B(r,i),{effects:a}),!0}var Ht=e=>Vt(e,!1),Ut=e=>Vt(e,!0);function U(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=k.cursor(r.from+n))}return i}var Wt=e=>V(e,t=>U(e,t,!0)),Gt=e=>V(e,t=>U(e,t,!1)),Kt=e=>V(e,t=>U(e,t,!H(e))),qt=e=>V(e,t=>U(e,t,H(e))),Jt=e=>V(e,t=>k.cursor(e.lineBlockAt(t.head).from,1)),Yt=e=>V(e,t=>k.cursor(e.lineBlockAt(t.head).to,-1));function Xt(e,t,n){let r=!1,i=z(e.selection,t=>{let i=p(e,t.head,-1)||p(e,t.head,1)||t.head>0&&p(e,t.head-1,1)||t.head<e.doc.length&&p(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?k.range(t.anchor,a):k.cursor(a)});return r?(t(B(e,i)),!0):!1}var Zt=({state:e,dispatch:t})=>Xt(e,t,!1);function W(e,t){let n=z(e.state.selection,e=>{let n=t(e);return k.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(B(e.state,n)),!0)}function Qt(e,t){return W(e,n=>e.moveByChar(n,t))}var $t=e=>Qt(e,!H(e)),en=e=>Qt(e,H(e));function tn(e,t){return W(e,n=>e.moveByGroup(n,t))}var nn=e=>tn(e,!H(e)),rn=e=>tn(e,H(e)),an=e=>W(e,t=>Pt(e.state,t,!H(e))),on=e=>W(e,t=>Pt(e.state,t,H(e)));function sn(e,t){return W(e,n=>e.moveVertically(n,t))}var cn=e=>sn(e,!1),ln=e=>sn(e,!0);function un(e,t){return W(e,n=>e.moveVertically(n,t,Bt(e).height))}var dn=e=>un(e,!1),fn=e=>un(e,!0),pn=e=>W(e,t=>U(e,t,!0)),mn=e=>W(e,t=>U(e,t,!1)),hn=e=>W(e,t=>U(e,t,!H(e))),gn=e=>W(e,t=>U(e,t,H(e))),_n=e=>W(e,t=>k.cursor(e.lineBlockAt(t.head).from)),vn=e=>W(e,t=>k.cursor(e.lineBlockAt(t.head).to)),yn=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),bn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),xn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),Sn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Cn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),wn=({state:e,dispatch:t})=>{let n=Un(e).map(({from:t,to:n})=>k.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:k.create(n),userEvent:`select`})),!0},Tn=({state:e,dispatch:t})=>{let n=z(e.selection,t=>{let n=E(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return k.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(B(e,n)),!0)};function En(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(B(n,k.create(i,i.length-1))),!0)}var Dn=e=>En(e,!1),On=e=>En(e,!0),kn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=k.create([n.main]):n.main.empty||(r=k.create([k.cursor(n.main.head)])),r?(t(B(e,r)),!0):!1};function An(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=jn(e,o,!1)):o>i&&(n=`delete.forward`,o=jn(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=jn(e,i,!1),a=jn(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:k.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?j.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function jn(e,t,n){if(e instanceof j)for(let r of e.state.facet(j.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var Mn=(e,t,n)=>An(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=h(s,a.tabSize)%Pe(a)||Pe(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=A(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=A(o.text,c-o.from,!1,!1)+o.from);return c}),Nn=e=>Mn(e,!1,!0),Pn=e=>Mn(e,!0,!1),Fn=(e,t)=>An(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=A(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),In=e=>Fn(e,!1),Ln=e=>Fn(e,!0),Rn=e=>An(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),zn=e=>An(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Bn=e=>An(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Vn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:x.of([``,``])},range:k.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Hn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:A(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:A(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:k.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Un(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Wn(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Un(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(k.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(k.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:k.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Gn=({state:e,dispatch:t})=>Wn(e,t,!1),Kn=({state:e,dispatch:t})=>Wn(e,t,!0);function qn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Un(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var Jn=({state:e,dispatch:t})=>qn(e,t,!1),Yn=({state:e,dispatch:t})=>qn(e,t,!0),Xn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Un(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=z(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Zn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=E(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(m.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Qn=er(!1),$n=er(!0);function er(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Zn(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Ee(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=de(s,r);for(c??=h(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,y(t,c)];return o&&l.push(y(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:x.of(l)},range:k.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function tr(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:k.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var nr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ee(e,{overrideIndentation:e=>n[e]??-1}),i=tr(e,(t,i,a)=>{let o=de(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=y(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},rr=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(tr(e,(t,n)=>{n.push({from:t.from,insert:e.facet(_)})}),{userEvent:`input.indent`})),!0),ir=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(tr(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=h(r,e.tabSize),a=0,o=y(e,Math.max(0,i-Pe(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),ar=e=>(e.setTabFocusMode(),!0),or=[{key:`Ctrl-b`,run:Ot,shift:$t,preventDefault:!0},{key:`Ctrl-f`,run:kt,shift:en},{key:`Ctrl-p`,run:Rt,shift:cn},{key:`Ctrl-n`,run:zt,shift:ln},{key:`Ctrl-a`,run:Jt,shift:_n},{key:`Ctrl-e`,run:Yt,shift:vn},{key:`Ctrl-d`,run:Pn},{key:`Ctrl-h`,run:Nn},{key:`Ctrl-k`,run:Rn},{key:`Ctrl-Alt-h`,run:In},{key:`Ctrl-o`,run:Vn},{key:`Ctrl-t`,run:Hn},{key:`Ctrl-v`,run:Ut}],sr=[{key:`ArrowLeft`,run:Ot,shift:$t,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:jt,shift:nn,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Kt,shift:hn,preventDefault:!0},{key:`ArrowRight`,run:kt,shift:en,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Mt,shift:rn,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:qt,shift:gn,preventDefault:!0},{key:`ArrowUp`,run:Rt,shift:cn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:yn,shift:xn},{mac:`Ctrl-ArrowUp`,run:Ht,shift:dn},{key:`ArrowDown`,run:zt,shift:ln,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:bn,shift:Sn},{mac:`Ctrl-ArrowDown`,run:Ut,shift:fn},{key:`PageUp`,run:Ht,shift:dn},{key:`PageDown`,run:Ut,shift:fn},{key:`Home`,run:Gt,shift:mn,preventDefault:!0},{key:`Mod-Home`,run:yn,shift:xn},{key:`End`,run:Wt,shift:pn,preventDefault:!0},{key:`Mod-End`,run:bn,shift:Sn},{key:`Enter`,run:Qn,shift:Qn},{key:`Mod-a`,run:Cn},{key:`Backspace`,run:Nn,shift:Nn,preventDefault:!0},{key:`Delete`,run:Pn,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:In,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Ln,preventDefault:!0},{mac:`Mod-Backspace`,run:zn,preventDefault:!0},{mac:`Mod-Delete`,run:Bn,preventDefault:!0}].concat(or.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),cr=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Ft,shift:an},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:It,shift:on},{key:`Alt-ArrowUp`,run:Gn},{key:`Shift-Alt-ArrowUp`,run:Jn},{key:`Alt-ArrowDown`,run:Kn},{key:`Shift-Alt-ArrowDown`,run:Yn},{key:`Mod-Alt-ArrowUp`,run:Dn},{key:`Mod-Alt-ArrowDown`,run:On},{key:`Escape`,run:kn},{key:`Mod-Enter`,run:$n},{key:`Alt-l`,mac:`Ctrl-l`,run:wn},{key:`Mod-i`,run:Tn,preventDefault:!0},{key:`Mod-[`,run:ir},{key:`Mod-]`,run:rr},{key:`Mod-Alt-\\`,run:nr},{key:`Shift-Mod-k`,run:Xn},{key:`Shift-Mod-\\`,run:Zt},{key:`Mod-/`,run:qe},{key:`Alt-A`,run:Xe},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:ar}].concat(sr),lr={key:`Tab`,run:rr,shift:ir},ur=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,G=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(ur(e)):ur,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return w(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=ce(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ue(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(G.prototype[Symbol.iterator]=function(){return this});var dr={from:-1,to:-1,match:/.*/.exec(``)},fr=`gm`+(/x/.unicode==null?``:`u`),pr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=dr,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new gr(e,t,n,r,i);this.re=new RegExp(t,fr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=vr(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=vr(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},mr=new WeakMap,hr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=mr.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return mr.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),mr.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},gr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=dr,this.matchPos=vr(e,r),this.re=new RegExp(t,fr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=hr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=vr(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=hr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(pr.prototype[Symbol.iterator]=gr.prototype[Symbol.iterator]=function(){return this});function _r(e){try{return new RegExp(e,fr),!0}catch{return!1}}function vr(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var yr=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=xe(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),ee=k.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,j.scrollIntoView(ee.from,{y:`center`})],selection:ee})}),!0},br={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},xr=v.define({combine(e){return Ie(e,br,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Sr(e){let t=[Or,Dr];return e&&t.push(xr.of(e)),t}var Cr=P.mark({class:`cm-selectionMatch`}),wr=P.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Tr(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=g.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=g.Word)}function Er(e,t,n,r){return e(t.sliceDoc(n,n+1))==g.Word&&e(t.sliceDoc(r-1,r))==g.Word}var Dr=M.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(xr),{state:n}=e,r=n.selection;if(r.ranges.length>1)return P.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return P.none;let e=n.wordAt(i.head);if(!e)return P.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return P.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Tr(o,n,i.from,i.to)&&Er(o,n,i.from,i.to)))return P.none}else if(a=n.sliceDoc(i.from,i.to),!a)return P.none}let s=[];for(let r of e.visibleRanges){let e=new G(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Tr(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(wr.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Cr.range(r,a)),s.length>t.maxMatches))return P.none}}return P.set(s)}},{decorations:e=>e.decorations}),Or=j.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),kr=({state:e,dispatch:t})=>{let{selection:n}=e,r=k.create(n.ranges.map(t=>e.wordAt(t.head)||k.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Ar(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new G(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new G(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var jr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return kr({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Ar(e,r);return i?(t(e.update({selection:e.selection.addRange(k.range(i.from,i.to),!1),effects:j.scrollIntoView(i.to)})),!0):!1},K=v.define({combine(e){return Ie(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ci(e),scrollToMatch:e=>j.scrollIntoView(e)})}}),Mr=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||_r(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
2
  `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Vr(this):new Ir(this)}getCursor(e,t=0,n){let r=e.doc?e:b.create({doc:e});return n??=r.doc.length,this.regexp?J(this,r,t,n):q(this,r,t,n)}},Nr=class{constructor(e){this.spec=e}};function Pr(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function q(e,t,n,r){let i;return e.wholeWord&&(i=Fr(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Pr(e.test,t,i)),new G(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Fr(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(Rr(i,n-a))!=g.Word||t(zr(i,n-a))!=g.Word)&&(t(zr(i,r-a))!=g.Word||t(Rr(i,r-a))!=g.Word))}var Ir=class extends Nr{constructor(e){super(e)}nextMatch(e,t,n){let r=q(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=q(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=q(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=q(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=q(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Lr(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function J(e,t,n,r){let i;return e.wholeWord&&(i=Br(t.charCategorizer(t.selection.main.head))),e.test&&(i=Lr(e.test,t,i)),new pr(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function Rr(e,t){return e.slice(A(e,t,!1),t)}function zr(e,t){return e.slice(t,A(e,t))}function Br(e){return(t,n,r)=>!r[0].length||(e(Rr(r.input,r.index))!=g.Word||e(zr(r.input,r.index))!=g.Word)&&(e(zr(r.input,r.index+r[0].length))!=g.Word||e(Rr(r.input,r.index+r[0].length))!=g.Word)}var Vr=class extends Nr{nextMatch(e,t,n){let r=J(this.spec,e,n,e.doc.length).next();return r.done&&(r=J(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=J(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=J(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=J(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},Hr=D.define(),Ur=D.define(),Y=O.define({create(e){return new Wr(ni(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Hr)?e=new Wr(n.value.create(),e.panel):n.is(Ur)&&(e=new Wr(e.query,n.value?ti:null));return e},provide:e=>be.from(e,e=>e.panel)}),Wr=class{constructor(e,t){this.query=e,this.panel=t}},Gr=P.mark({class:`cm-searchMatch`}),Kr=P.mark({class:`cm-searchMatch cm-searchMatch-selected`}),qr=M.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Y))}update(e){let t=e.state.field(Y);(t!=e.startState.field(Y)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return P.none;let{view:n}=this,r=new Se;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Kr:Gr)})}return r.finish()}},{decorations:e=>e.decorations});function Jr(e){return t=>{let n=t.state.field(Y,!1);return n&&n.query.spec.valid?e(t,n):ai(t)}}var Yr=Jr((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=k.single(r.from,r.to),a=e.state.facet(K);return e.dispatch({selection:i,effects:[di(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),ii(e),!0}),Xr=Jr((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=k.single(i.from,i.to),o=e.state.facet(K);return e.dispatch({selection:a,effects:[di(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),ii(e),!0}),Zr=Jr((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:k.create(n.map(e=>k.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Qr=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new G(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(k.range(t.value.from,t.value.to))}return t(e.update({selection:k.create(a,o),userEvent:`select.search.matches`})),!0},$r=Jr((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(j.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=k.single(o.from,o.to).map(d),u.push(di(e,o)),u.push(n.facet(K).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),ei=Jr((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:j.announce.of(r),userEvent:`input.replace.all`}),!0});function ti(e){return e.state.facet(K).createPanel(e)}function ni(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(K);return new Mr({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function ri(e){let t=De(e,ti);return t&&t.dom.querySelector(`[main-field]`)}function ii(e){let t=ri(e);t&&t==e.root.activeElement&&t.select()}var ai=e=>{let t=e.state.field(Y,!1);if(t&&t.panel){let n=ri(e);if(n&&n!=e.root.activeElement){let r=ni(e.state,t.query.spec);r.valid&&e.dispatch({effects:Hr.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Ur.of(!0),t?Hr.of(ni(e.state,t.query.spec)):D.appendConfig.of(pi)]});return!0},oi=e=>{let t=e.state.field(Y,!1);if(!t||!t.panel)return!1;let n=De(e,ti);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Ur.of(!1)}),!0},si=[{key:`Mod-f`,run:ai,scope:`editor search-panel`},{key:`F3`,run:Yr,shift:Xr,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:Yr,shift:Xr,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:oi,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Qr},{key:`Mod-Alt-g`,run:yr},{key:`Mod-d`,run:jr,preventDefault:!0}],ci=class{constructor(e){this.view=e;let t=this.query=e.state.field(Y).query.spec;this.commit=this.commit.bind(this),this.searchField=F(`input`,{value:t.search,placeholder:X(e,`Find`),"aria-label":X(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=F(`input`,{value:t.replace,placeholder:X(e,`Replace`),"aria-label":X(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=F(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=F(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=F(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return F(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=F(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>Yr(e),[X(e,`next`)]),n(`prev`,()=>Xr(e),[X(e,`previous`)]),n(`select`,()=>Zr(e),[X(e,`all`)]),F(`label`,null,[this.caseField,X(e,`match case`)]),F(`label`,null,[this.reField,X(e,`regexp`)]),F(`label`,null,[this.wordField,X(e,`by word`)]),...e.state.readOnly?[]:[F(`br`),this.replaceField,n(`replace`,()=>$r(e),[X(e,`replace`)]),n(`replaceAll`,()=>ei(e),[X(e,`replace all`)])],F(`button`,{name:`close`,onclick:()=>oi(e),"aria-label":X(e,`close`),type:`button`},[`×`])])}commit(){let e=new Mr({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Hr.of(e)}))}keydown(e){Te(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Xr:Yr)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),$r(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Hr)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(K).top}};function X(e,t){return e.state.phrase(t)}var li=30,ui=/[\s\.,:;?!]/;function di(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-li),o=Math.min(i,n+li),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<li;e++)if(!ui.test(s[e+1])&&ui.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-li;e--)if(!ui.test(s[e-1])&&ui.test(s[e])){s=s.slice(0,e);break}}return j.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var fi=j.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),pi=[Y,Ce.low(qr),fi],mi=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},hi=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Di).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Se,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Ri(s);if(i)o.add(n,n,P.widget({widget:new ji(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,P.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,Z(f))}};function Z(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new mi(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new mi(r.from,n,r.diagnostic)}),r}function gi(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Di).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(vi))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function _i(e,t){return e.field(Q,!1)?t:t.concat(D.appendConfig.of(zi))}var vi=D.define(),yi=D.define(),bi=D.define(),Q=O.define({create(){return new hi(P.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Z(n,e.selected.diagnostic,i)||Z(n,null,i)}!n.size&&i&&t.state.facet(Di).autoPanel&&(i=null),e=new hi(n,i,r)}for(let n of t.effects)if(n.is(vi)){let r=t.state.facet(Di).autoPanel?n.value.length?Ni.open:null:e.panel;e=hi.init(n.value,r,t.state)}else n.is(yi)?e=new hi(e.diagnostics,n.value?Ni.open:null,e.selected):n.is(bi)&&(e=new hi(e.diagnostics,e.panel,n.value));return e},provide:e=>[be.from(e,e=>e.panel),j.decorations.from(e,e=>e.diagnostics)]}),xi=P.mark({class:`cm-lintRange cm-lintRange-active`});function Si(e,t,n){let{diagnostics:r}=e.state.field(Q),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Di).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:Ci(e,i)}}}:null}function Ci(e,t){return F(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Ai(e,t,!1)))}var wi=e=>{let t=e.state.field(Q,!1);(!t||!t.panel)&&e.dispatch({effects:_i(e.state,[yi.of(!0)])});let n=De(e,Ni.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},Ti=e=>{let t=e.state.field(Q,!1);return!t||!t.panel?!1:(e.dispatch({effects:yi.of(!1)}),!0)},Ei=[{key:`Mod-Shift-m`,run:wi,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Q,!1);if(!t)return!1;let n=e.state.selection.main,r=Z(t.diagnostics,null,n.to+1);return!r&&(r=Z(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Di=v.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...Ie(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Oi,tooltipFilter:Oi,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Oi(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function ki(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Ai(e,t,n){let r=n?ki(t.actions):[];return F(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},F(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=Z(e.state.field(Q).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),F(`u`,s.slice(c,c+1)),s.slice(c+1)];return F(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&F(`div`,{class:`cm-diagnosticSource`},t.source))}var ji=class extends le{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return F(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Mi=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Ai(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Ni=class e{constructor(e){this.view=e,this.items=[],this.list=F(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Ti(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=ki(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=Z(this.view.state.field(Q).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=F(`div`,{class:`cm-panel-lint`},this.list,F(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>Ti(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Q).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Q),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new Mi(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Mi(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Z(this.view.state.field(Q).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:bi.of(t)})}static open(t){return new e(t)}};function Pi(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Fi(e){return Pi(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Ii=j.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Fi(`#d11`)},".cm-lintRange-warning":{backgroundImage:Fi(`orange`)},".cm-lintRange-info":{backgroundImage:Fi(`#999`)},".cm-lintRange-hint":{backgroundImage:Fi(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Li(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Ri(e){let t=`hint`,n=1;for(let r of e){let e=Li(r.severity);e>n&&(n=e,t=r.severity)}return t}var zi=[Q,j.decorations.compute([Q],e=>{let{selected:t,panel:n}=e.field(Q);return!t||!n||t.from==t.to?P.none:P.set([xi.range(t.from,t.to)])}),ge(Si,{hideOn:gi}),Ii],Bi=[Me(),Oe(),Ae(),ct(),ye(),ve(),je(),b.allowMultipleSelections.of(!0),pe(),T(_e,{fallback:!0}),he(),Be(),Re(),ke(),se(),N(),Sr(),we.of([...Le,...cr,...si,...Tt,...Ne,...ze,...Ei])];Ae(),ct(),ve(),T(_e,{fallback:!0}),we.of([...cr,...Tt]);function Vi(e,t){let n=(0,He.c)(4),r=t===void 0?!1:t,[i,a]=(0,Ve.useState)(void 0),o=(0,Ve.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,Ve.useEffect)(s,c),i}var $=n(),Hi=300;async function Ui(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new i(`Page headings response was not JSON`,{cause:e,status:t.status})}if(!t.ok){let e=re.safeParse(n);throw e.success?Error(e.data.title):new i(`Page headings error response did not match RFC 9457`,{status:t.status})}let r=ae.safeParse(n);if(!r.success)throw new i(`Page headings response did not match success schema`,{status:t.status});return r.data.headings??[]}var Wi=32,Gi=12,Ki=6,qi=`open-knowledge:outline-nav`;function Ji(e){let t=(0,He.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(a,{name:`outline-panel`,children:(0,$.jsx)(Yi,{...e})}),t[0]=e,t[1]=n),n}function Yi(e){let t=(0,He.c)(49),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{pages:re,loading:ae}=ie(),se=ne(),{activeProvider:p,activeDocName:m}=o(),h,g;t[0]===n?(h=t[1],g=t[2]):(h=[`page-headings`,n],g=()=>Ui(n),t[0]=n,t[1]=h,t[2]=g);let _;t[3]!==n||t[4]!==ae||t[5]!==re?(_=!ae&&re.has(n),t[3]=n,t[4]=ae,t[5]=re,t[6]=_):_=t[6];let v;t[7]!==h||t[8]!==g||t[9]!==_?(v={queryKey:h,queryFn:g,enabled:_,staleTime:1/0},t[7]=h,t[8]=g,t[9]=_,t[10]=v):v=t[10];let{data:y,isLoading:b,error:x}=c(v),ce;t[11]===y?ce=t[12]:(ce=y===void 0?[]:y,t[11]=y,t[12]=ce);let S=ce,C,w;t[13]!==m||t[14]!==p||t[15]!==n||t[16]!==se?(C=()=>{if(!p||m!==n)return;let e=p.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,se.invalidateQueries({queryKey:[`page-headings`,n]})},Hi)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},w=[p,m,n,se],t[13]=m,t[14]=p,t[15]=n,t[16]=se,t[17]=C,t[18]=w):(C=t[17],w=t[18]),(0,Ve.useEffect)(C,w);let T;t[19]===S?T=t[20]:(T=S.map(Xi),t[19]=S,t[20]=T);let E=Vi(T,r),D;t[21]!==E||t[22]!==S?(D=E?S.findIndex(e=>e.slug===E):-1,t[21]=E,t[22]=S,t[23]=D):D=t[23];let O=D,le;t[24]!==n||t[25]!==r?(le=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&We(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(qi,{detail:i}))},t[24]=n,t[25]=r,t[26]=le):le=t[26];let ue=le,de=((O>=0?S[O].level:1)-1)*Gi+(Gi-Ki)/2,fe=O*Wi+(Wi-Ki)/2,pe;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(ee,{children:`Outline`}),t[27]=pe):pe=t[27];let k;t[28]!==S.length||t[29]!==b?(k=!b&&(0,$.jsx)(f,{children:S.length}),t[28]=S.length,t[29]=b,t[30]=k):k=t[30];let A;t[31]===k?A=t[32]:(A=(0,$.jsxs)(d,{children:[pe,k]}),t[31]=k,t[32]=A);let j;t[33]!==O||t[34]!==E||t[35]!==x||t[36]!==ue||t[37]!==S||t[38]!==b||t[39]!==de||t[40]!==fe?(j=x?(0,$.jsx)(s,{className:`px-2`,children:x instanceof Error?x.message:`Failed to load headings`}):S.length===0&&!b?(0,$.jsx)(l,{className:`px-2`,children:`No headings yet.`}):(0,$.jsxs)(`nav`,{"aria-label":`Document outline`,className:`relative`,children:[O>=0&&(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:Ki,height:Ki,transform:`translate(${de}px, ${fe}px)`}}),S.map((e,t)=>{let n=e.slug===E;return(0,$.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>ue(t,e.slug),className:oe(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*Gi+20}px`},title:e.text,children:e.text},t)})]}),t[33]=O,t[34]=E,t[35]=x,t[36]=ue,t[37]=S,t[38]=b,t[39]=de,t[40]=fe,t[41]=j):j=t[41];let M;t[42]!==b||t[43]!==j?(M=(0,$.jsx)(u,{className:`px-3 py-2`,"aria-busy":b,children:j}),t[42]=b,t[43]=j,t[44]=M):M=t[44];let N;return t[45]!==a||t[46]!==A||t[47]!==M?(N=(0,$.jsxs)(te,{className:a,children:[A,M]}),t[45]=a,t[46]=A,t[47]=M,t[48]=N):N=t[48],N}function Xi(e){return e.slug}export{Ke as a,lr as i,Ji as n,Ge as o,Bi as r,We as s,qi as t};