studiograph 1.3.8 → 1.3.10

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 (51) hide show
  1. package/dist/agent/tools/sync-tools.js +4 -7
  2. package/dist/agent/tools/sync-tools.js.map +1 -1
  3. package/dist/cli/commands/sync-collection.js +3 -14
  4. package/dist/cli/commands/sync-collection.js.map +1 -1
  5. package/dist/server/index.js +4 -1
  6. package/dist/server/index.js.map +1 -1
  7. package/dist/server/routes/sync-api.js +14 -20
  8. package/dist/server/routes/sync-api.js.map +1 -1
  9. package/dist/services/sync/collection-sync.d.ts +22 -35
  10. package/dist/services/sync/collection-sync.js +123 -357
  11. package/dist/services/sync/collection-sync.js.map +1 -1
  12. package/dist/services/sync/structured-extractor.d.ts +2 -0
  13. package/dist/services/sync/structured-extractor.js +1 -1
  14. package/dist/services/sync/structured-extractor.js.map +1 -1
  15. package/dist/services/sync/types.d.ts +10 -5
  16. package/dist/web/_app/immutable/chunks/{DCGmlzGM.js → AWihU6Ne.js} +1 -1
  17. package/dist/web/_app/immutable/chunks/B1Cz8BMn.js +1 -0
  18. package/dist/web/_app/immutable/chunks/BqzGUHtY.js +27 -0
  19. package/dist/web/_app/immutable/chunks/{BXuvR8Ks.js → C7VoTosa.js} +1 -1
  20. package/dist/web/_app/immutable/chunks/{BBLgaWN8.js → CTRxNfZk.js} +1 -1
  21. package/dist/web/_app/immutable/chunks/CWQRQXxy.js +1 -0
  22. package/dist/web/_app/immutable/chunks/{Cs5oz2oJ.js → CX_61fY8.js} +1 -1
  23. package/dist/web/_app/immutable/chunks/{BxXlKFyx.js → CfTe44NH.js} +1 -1
  24. package/dist/web/_app/immutable/chunks/{0oxpWEgM.js → CrdV0ttd.js} +1 -1
  25. package/dist/web/_app/immutable/chunks/{B1y7Wy5O.js → CscoF-YL.js} +1 -1
  26. package/dist/web/_app/immutable/chunks/{D2aTbzFm.js → D7ZqAKi9.js} +1 -1
  27. package/dist/web/_app/immutable/chunks/{hnbuI7Nz.js → D9er1L5a.js} +1 -1
  28. package/dist/web/_app/immutable/chunks/DKQjBKyp.js +1 -0
  29. package/dist/web/_app/immutable/chunks/{DEzvDbcy.js → Dkz6p8Jo.js} +1 -1
  30. package/dist/web/_app/immutable/chunks/{BVBRzmeQ.js → DnL9f0lc.js} +2 -2
  31. package/dist/web/_app/immutable/chunks/{BCB5cYCz.js → i9c_RUF6.js} +2 -2
  32. package/dist/web/_app/immutable/entry/{app.DJBDJcSh.js → app.mJ5Araew.js} +2 -2
  33. package/dist/web/_app/immutable/entry/start.DF_0_BfK.js +1 -0
  34. package/dist/web/_app/immutable/nodes/{0.CAcmB7D0.js → 0.BvuYB1gx.js} +3 -3
  35. package/dist/web/_app/immutable/nodes/{1.CTI57h4T.js → 1.DJ_l-bGr.js} +1 -1
  36. package/dist/web/_app/immutable/nodes/{2.DLksu1-5.js → 2.BGwKASX5.js} +1 -1
  37. package/dist/web/_app/immutable/nodes/3.xRAvlc2o.js +11 -0
  38. package/dist/web/_app/immutable/nodes/{4.b6iwPmuI.js → 4.B0ynwCv_.js} +1 -1
  39. package/dist/web/_app/immutable/nodes/{5.BHhKeE_h.js → 5.BfU_Rt3A.js} +1 -1
  40. package/dist/web/_app/immutable/nodes/{6.B3IKA9tf.js → 6.9tzx4cb2.js} +1 -1
  41. package/dist/web/_app/immutable/nodes/7.DExKUmUV.js +2 -0
  42. package/dist/web/_app/immutable/nodes/{8.rJtfXi9L.js → 8.BfIZOncu.js} +1 -1
  43. package/dist/web/_app/version.json +1 -1
  44. package/dist/web/index.html +6 -6
  45. package/package.json +1 -1
  46. package/dist/web/_app/immutable/chunks/BPUy9_sS.js +0 -1
  47. package/dist/web/_app/immutable/chunks/Bt3IOBgW.js +0 -27
  48. package/dist/web/_app/immutable/chunks/C_8lGlxx.js +0 -1
  49. package/dist/web/_app/immutable/entry/start.3Q9lJ-bM.js +0 -1
  50. package/dist/web/_app/immutable/nodes/3.B5xlkeVI.js +0 -11
  51. package/dist/web/_app/immutable/nodes/7.Eq6DAyo_.js +0 -2
@@ -1,4 +1,4 @@
1
- import{Transaction as pa,Text as da,StateEffect as Ae,Annotation as ua,EditorSelection as Y,StateField as fa,Prec as UO,MapMode as nO,Facet as ma,RangeValue as $a,countColumn as K,EditorState as ha}from"./Cs5oz2oJ.js";import{D as me,E,k as MO,W as ga}from"./BVBRzmeQ.js";import{syntaxTree as y,indentUnit as IO,LRLanguage as Ue,indentNodeProp as $e,continuedIndent as se,foldNodeProp as ae,foldInside as BO,LanguageSupport as J,sublanguageProp as NO,flatIndent as Sa,delimitedIndent as Pa,defineLanguageFacet as DO,bracketMatchingHandle as Za,Language as Xa,foldService as ka,languageDataProp as ba,LanguageDescription as lO,ParseContext as xa}from"./D2aTbzFm.js";import{P as wa,a as he,b as G,e as ya,N as KO,s as re,T as j,p as JO,d as o,f as FO,I as HO}from"./BXuvR8Ks.js";import{L as Me,E as w,C as et,a as ze}from"./0oxpWEgM.js";class Ta{constructor(O,t,a,r){this.state=O,this.pos=t,this.explicit=a,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(O){let t=y(this.state).resolveInner(this.pos,-1);for(;t&&O.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(O){let t=this.state.doc.lineAt(this.pos),a=Math.max(t.from,this.pos-250),r=t.text.slice(a-t.from,this.pos-t.from),i=r.search(za(O));return i<0?null:{from:a+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(O,t,a){O=="abort"&&this.abortListeners&&(this.abortListeners.push(t),a&&a.onDocChange&&(this.abortOnDocChange=!0))}}function sO(e){let O=Object.keys(e).join(""),t=/\w/.test(O);return t&&(O=O.replace(/\w/g,"")),`[${t?"\\w":""}${O.replace(/[^\w\s]/g,"\\$&")}]`}function Ya(e){let O=Object.create(null),t=Object.create(null);for(let{label:r}of e){O[r[0]]=!0;for(let i=1;i<r.length;i++)t[r[i]]=!0}let a=sO(O)+sO(t)+"*$";return[new RegExp("^"+a),new RegExp(a)]}function _a(e){let O=e.map(r=>typeof r=="string"?{label:r}:r),[t,a]=O.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:Ya(O);return r=>{let i=r.matchBefore(a);return i||r.explicit?{from:i?i.from:r.pos,options:O,validFor:t}:null}}function va(e,O){return t=>{for(let a=y(t.state).resolveInner(t.pos,-1);a;a=a.parent){if(e.indexOf(a.name)>-1)return null;if(a.type.isTop)break}return O(t)}}function za(e,O){var t;let{source:a}=e,r=a[a.length-1]!="$";return r?new RegExp(`(?:${a})${r?"$":""}`,(t=e.flags)!==null&&t!==void 0?t:e.ignoreCase?"i":""):e}const qa=ua.define(),Ra=E.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Va{constructor(O,t,a,r){this.field=O,this.line=t,this.from=a,this.to=r}}class Ie{constructor(O,t,a){this.field=O,this.from=t,this.to=a}map(O){let t=O.mapPos(this.from,-1,nO.TrackDel),a=O.mapPos(this.to,1,nO.TrackDel);return t==null||a==null?null:new Ie(this.field,t,a)}}class Be{constructor(O,t){this.lines=O,this.fieldPositions=t}instantiate(O,t){let a=[],r=[t],i=O.doc.lineAt(t),n=/^\s*/.exec(i.text)[0];for(let s of this.lines){if(a.length){let c=n,Q=/^\t*/.exec(s)[0].length;for(let p=0;p<Q;p++)c+=O.facet(IO);r.push(t+c.length-Q),s=c+s.slice(Q)}a.push(s),t+=s.length+1}let l=this.fieldPositions.map(s=>new Ie(s.field,r[s.line]+s.from,r[s.line]+s.to));return{text:a,ranges:l}}static parse(O){let t=[],a=[],r=[],i;for(let n of O.split(/\r\n?|\n/)){for(;i=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(n);){let l=i[1]?+i[1]:null,s=i[2]||i[3]||"",c=-1,Q=s.replace(/\\[{}]/g,p=>p[1]);for(let p=0;p<t.length;p++)(l!=null?t[p].seq==l:Q&&t[p].name==Q)&&(c=p);if(c<0){let p=0;for(;p<t.length&&(l==null||t[p].seq!=null&&t[p].seq<l);)p++;t.splice(p,0,{seq:l,name:Q}),c=p;for(let d of r)d.field>=c&&d.field++}for(let p of r)if(p.line==a.length&&p.from>i.index){let d=i[2]?3+(i[1]||"").length:2;p.from-=d,p.to-=d}r.push(new Va(c,a.length,i.index,i.index+Q.length)),n=n.slice(0,i.index)+s+n.slice(i.index+i[0].length)}n=n.replace(/\\([{}])/g,(l,s,c)=>{for(let Q of r)Q.line==a.length&&Q.from>c&&(Q.from--,Q.to--);return s}),a.push(n)}return new Be(a,r)}}let ja=me.widget({widget:new class extends ga{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Ga=me.mark({class:"cm-snippetField"});class A{constructor(O,t){this.ranges=O,this.active=t,this.deco=me.set(O.map(a=>(a.from==a.to?ja:Ga).range(a.from,a.to)),!0)}map(O){let t=[];for(let a of this.ranges){let r=a.map(O);if(!r)return null;t.push(r)}return new A(t,this.active)}selectionInsideField(O){return O.ranges.every(t=>this.ranges.some(a=>a.field==this.active&&a.from<=t.from&&a.to>=t.to))}}const ie=Ae.define({map(e,O){return e&&e.map(O)}}),Wa=Ae.define(),F=fa.define({create(){return null},update(e,O){for(let t of O.effects){if(t.is(ie))return t.value;if(t.is(Wa)&&e)return new A(e.ranges,t.value)}return e&&O.docChanged&&(e=e.map(O.changes)),e&&O.selection&&!e.selectionInsideField(O.selection)&&(e=null),e},provide:e=>E.decorations.from(e,O=>O?O.deco:me.none)});function Ne(e,O){return Y.create(e.filter(t=>t.field==O).map(t=>Y.range(t.from,t.to)))}function La(e){let O=Be.parse(e);return(t,a,r,i)=>{let{text:n,ranges:l}=O.instantiate(t.state,r),{main:s}=t.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:da.of(n)},scrollIntoView:!0,annotations:a?[qa.of(a),pa.userEvent.of("input.complete")]:void 0};if(l.length&&(c.selection=Ne(l,0)),l.some(Q=>Q.field>0)){let Q=new A(l,0),p=c.effects=[ie.of(Q)];t.state.field(F,!1)===void 0&&p.push(Ae.appendConfig.of([F,Ma,Ia,Ra]))}t.dispatch(t.state.update(c))}}function Ot(e){return({state:O,dispatch:t})=>{let a=O.field(F,!1);if(!a||e<0&&a.active==0)return!1;let r=a.active+e,i=e>0&&!a.ranges.some(n=>n.field==r+e);return t(O.update({selection:Ne(a.ranges,r),effects:ie.of(i?null:new A(a.ranges,r)),scrollIntoView:!0})),!0}}const Ca=({state:e,dispatch:O})=>e.field(F,!1)?(O(e.update({effects:ie.of(null)})),!0):!1,Ea=Ot(1),Aa=Ot(-1),Ua=[{key:"Tab",run:Ea,shift:Aa},{key:"Escape",run:Ca}],oO=ma.define({combine(e){return e.length?e[0]:Ua}}),Ma=UO.highest(MO.compute([oO],e=>e.facet(oO)));function k(e,O){return{...O,apply:La(e)}}const Ia=E.domEventHandlers({mousedown(e,O){let t=O.state.field(F,!1),a;if(!t||(a=O.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let r=t.ranges.find(i=>i.from<=a&&i.to>=a);return!r||r.field==t.active?!1:(O.dispatch({selection:Ne(t.ranges,r.field),effects:ie.of(t.ranges.some(i=>i.field>r.field)?new A(t.ranges,r.field):null),scrollIntoView:!0}),!0)}}),tt=new class extends $a{};tt.startSide=1;tt.endSide=-1;class ce{static create(O,t,a,r,i){let n=r+(r<<8)+O+(t<<4)|0;return new ce(O,t,a,n,i,[],[])}constructor(O,t,a,r,i,n,l){this.type=O,this.value=t,this.from=a,this.hash=r,this.end=i,this.children=n,this.positions=l,this.hashProp=[[G.contextHash,r]]}addChild(O,t){O.prop(G.contextHash)!=this.hash&&(O=new j(O.type,O.children,O.positions,O.length,this.hashProp)),this.children.push(O),this.positions.push(t)}toTree(O,t=this.end){let a=this.children.length-1;return a>=0&&(t=Math.max(t,this.positions[a]+this.children[a].length+this.from)),new j(O.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(r,i,n)=>new j(he.none,r,i,n,this.hashProp)})}}var u;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(u||(u={}));class Ba{constructor(O,t){this.start=O,this.content=t,this.marks=[],this.parsers=[]}}class Na{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let O=this.skipSpace(this.basePos);this.indent=this.countIndent(O,this.pos,this.indent),this.pos=O,this.next=O==this.text.length?-1:this.text.charCodeAt(O)}skipSpace(O){return N(this.text,O)}reset(O){for(this.text=O,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(O){this.basePos=O,this.baseIndent=this.countIndent(O,this.pos,this.indent)}moveBaseColumn(O){this.baseIndent=O,this.basePos=this.findColumn(O)}addMarker(O){this.markers.push(O)}countIndent(O,t=0,a=0){for(let r=t;r<O;r++)a+=this.text.charCodeAt(r)==9?4-a%4:1;return a}findColumn(O){let t=0;for(let a=0;t<this.text.length&&a<O;t++)a+=this.text.charCodeAt(t)==9?4-a%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let O="";for(let t=0;t<this.basePos;t++)O+=" ";return O+this.text.slice(this.basePos)}}function QO(e,O,t){if(t.pos==t.text.length||e!=O.block&&t.indent>=O.stack[t.depth+1].value+t.baseIndent)return!0;if(t.indent>=t.baseIndent+4)return!1;let a=(e.type==u.OrderedList?Je:Ke)(t,O,!1);return a>0&&(e.type!=u.BulletList||De(t,O,!1)<0)&&t.text.charCodeAt(t.pos+a-1)==e.value}const at={[u.Blockquote](e,O,t){return t.next!=62?!1:(t.markers.push(g(u.QuoteMark,O.lineStart+t.pos,O.lineStart+t.pos+1)),t.moveBase(t.pos+(T(t.text.charCodeAt(t.pos+1))?2:1)),e.end=O.lineStart+t.text.length,!0)},[u.ListItem](e,O,t){return t.indent<t.baseIndent+e.value&&t.next>-1?!1:(t.moveBaseColumn(t.baseIndent+e.value),!0)},[u.OrderedList]:QO,[u.BulletList]:QO,[u.Document](){return!0}};function T(e){return e==32||e==9||e==10||e==13}function N(e,O=0){for(;O<e.length&&T(e.charCodeAt(O));)O++;return O}function cO(e,O,t){for(;O>t&&T(e.charCodeAt(O-1));)O--;return O}function rt(e){if(e.next!=96&&e.next!=126)return-1;let O=e.pos+1;for(;O<e.text.length&&e.text.charCodeAt(O)==e.next;)O++;if(O<e.pos+3)return-1;if(e.next==96){for(let t=O;t<e.text.length;t++)if(e.text.charCodeAt(t)==96)return-1}return O}function it(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function De(e,O,t){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let a=1;for(let r=e.pos+1;r<e.text.length;r++){let i=e.text.charCodeAt(r);if(i==e.next)a++;else if(!T(i))return-1}return t&&e.next==45&&st(e)>-1&&e.depth==O.stack.length&&O.parser.leafBlockParsers.indexOf(pt.SetextHeading)>-1||a<3?-1:1}function nt(e,O){for(let t=e.stack.length-1;t>=0;t--)if(e.stack[t].type==O)return!0;return!1}function Ke(e,O,t){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||T(e.text.charCodeAt(e.pos+1)))&&(!t||nt(O,u.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Je(e,O,t){let a=e.pos,r=e.next;for(;r>=48&&r<=57;){a++;if(a==e.text.length)return-1;r=e.text.charCodeAt(a)}return a==e.pos||a>e.pos+9||r!=46&&r!=41||a<e.text.length-1&&!T(e.text.charCodeAt(a+1))||t&&!nt(O,u.OrderedList)&&(e.skipSpace(a+1)==e.text.length||a>e.pos+1||e.next!=49)?-1:a+1-e.pos}function lt(e){if(e.next!=35)return-1;let O=e.pos+1;for(;O<e.text.length&&e.text.charCodeAt(O)==35;)O++;if(O<e.text.length&&e.text.charCodeAt(O)!=32)return-1;let t=O-e.pos;return t>6?-1:t}function st(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let O=e.pos+1;for(;O<e.text.length&&e.text.charCodeAt(O)==e.next;)O++;let t=O;for(;O<e.text.length&&T(e.text.charCodeAt(O));)O++;return O==e.text.length?t:-1}const qe=/^[ \t]*$/,ot=/-->/,Qt=/\?>/,Re=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,ot],[/^\s*<\?/,Qt],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,qe],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,qe]];function ct(e,O,t){if(e.next!=60)return-1;let a=e.text.slice(e.pos);for(let r=0,i=Re.length-(t?1:0);r<i;r++)if(Re[r][0].test(a))return r;return-1}function pO(e,O){let t=e.countIndent(O,e.pos,e.indent),a=e.countIndent(e.skipSpace(O),O,t);return a>=t+5?t+1:a}function z(e,O,t){let a=e.length-1;a>=0&&e[a].to==O&&e[a].type==u.CodeText?e[a].to=t:e.push(g(u.CodeText,O,t))}const ne={LinkReference:void 0,IndentedCode(e,O){let t=O.baseIndent+4;if(O.indent<t)return!1;let a=O.findColumn(t),r=e.lineStart+a,i=e.lineStart+O.text.length,n=[],l=[];for(z(n,r,i);e.nextLine()&&O.depth>=e.stack.length;)if(O.pos==O.text.length){z(l,e.lineStart-1,e.lineStart);for(let s of O.markers)l.push(s)}else{if(O.indent<t)break;{if(l.length){for(let c of l)c.type==u.CodeText?z(n,c.from,c.to):n.push(c);l=[]}z(n,e.lineStart-1,e.lineStart);for(let c of O.markers)n.push(c);i=e.lineStart+O.text.length;let s=e.lineStart+O.findColumn(O.baseIndent+4);s<i&&z(n,s,i)}}return l.length&&(l=l.filter(s=>s.type!=u.CodeText),l.length&&(O.markers=l.concat(O.markers))),e.addNode(e.buffer.writeElements(n,-r).finish(u.CodeBlock,i-r),r),!0},FencedCode(e,O){let t=rt(O);if(t<0)return!1;let a=e.lineStart+O.pos,r=O.next,i=t-O.pos,n=O.skipSpace(t),l=cO(O.text,O.text.length,n),s=[g(u.CodeMark,a,a+i)];n<l&&s.push(g(u.CodeInfo,e.lineStart+n,e.lineStart+l));for(let c=!0,Q=!0,p=!1;e.nextLine()&&O.depth>=e.stack.length;c=!1){let d=O.pos;if(O.indent-O.baseIndent<4)for(;d<O.text.length&&O.text.charCodeAt(d)==r;)d++;if(d-O.pos>=i&&O.skipSpace(d)==O.text.length){for(let f of O.markers)s.push(f);Q&&p&&z(s,e.lineStart-1,e.lineStart),s.push(g(u.CodeMark,e.lineStart+O.pos,e.lineStart+d)),e.nextLine();break}else{p=!0,c||(z(s,e.lineStart-1,e.lineStart),Q=!1);for(let $ of O.markers)s.push($);let f=e.lineStart+O.basePos,h=e.lineStart+O.text.length;f<h&&(z(s,f,h),Q=!1)}}return e.addNode(e.buffer.writeElements(s,-a).finish(u.FencedCode,e.prevLineEnd()-a),a),!0},Blockquote(e,O){let t=it(O);return t<0?!1:(e.startContext(u.Blockquote,O.pos),e.addNode(u.QuoteMark,e.lineStart+O.pos,e.lineStart+O.pos+1),O.moveBase(O.pos+t),null)},HorizontalRule(e,O){if(De(O,e,!1)<0)return!1;let t=e.lineStart+O.pos;return e.nextLine(),e.addNode(u.HorizontalRule,t),!0},BulletList(e,O){let t=Ke(O,e,!1);if(t<0)return!1;e.block.type!=u.BulletList&&e.startContext(u.BulletList,O.basePos,O.next);let a=pO(O,O.pos+1);return e.startContext(u.ListItem,O.basePos,a-O.baseIndent),e.addNode(u.ListMark,e.lineStart+O.pos,e.lineStart+O.pos+t),O.moveBaseColumn(a),null},OrderedList(e,O){let t=Je(O,e,!1);if(t<0)return!1;e.block.type!=u.OrderedList&&e.startContext(u.OrderedList,O.basePos,O.text.charCodeAt(O.pos+t-1));let a=pO(O,O.pos+t);return e.startContext(u.ListItem,O.basePos,a-O.baseIndent),e.addNode(u.ListMark,e.lineStart+O.pos,e.lineStart+O.pos+t),O.moveBaseColumn(a),null},ATXHeading(e,O){let t=lt(O);if(t<0)return!1;let a=O.pos,r=e.lineStart+a,i=cO(O.text,O.text.length,a),n=i;for(;n>a&&O.text.charCodeAt(n-1)==O.next;)n--;(n==i||n==a||!T(O.text.charCodeAt(n-1)))&&(n=O.text.length);let l=e.buffer.write(u.HeaderMark,0,t).writeElements(e.parser.parseInline(O.text.slice(a+t+1,n),r+t+1),-r);n<O.text.length&&l.write(u.HeaderMark,n-a,i-a);let s=l.finish(u.ATXHeading1-1+t,O.text.length-a);return e.nextLine(),e.addNode(s,r),!0},HTMLBlock(e,O){let t=ct(O,e,!1);if(t<0)return!1;let a=e.lineStart+O.pos,r=Re[t][1],i=[],n=r!=qe;for(;!r.test(O.text)&&e.nextLine();){if(O.depth<e.stack.length){n=!1;break}for(let c of O.markers)i.push(c)}n&&e.nextLine();let l=r==ot?u.CommentBlock:r==Qt?u.ProcessingInstructionBlock:u.HTMLBlock,s=e.prevLineEnd();return e.addNode(e.buffer.writeElements(i,-a).finish(l,s-a),a),!0},SetextHeading:void 0};class Da{constructor(O){this.stage=0,this.elts=[],this.pos=0,this.start=O.start,this.advance(O.content)}nextLine(O,t,a){if(this.stage==-1)return!1;let r=a.content+`
1
+ import{Transaction as pa,Text as da,StateEffect as Ae,Annotation as ua,EditorSelection as Y,StateField as fa,Prec as UO,MapMode as nO,Facet as ma,RangeValue as $a,countColumn as K,EditorState as ha}from"./CX_61fY8.js";import{a as me,E,k as MO,W as ga}from"./DnL9f0lc.js";import{syntaxTree as y,indentUnit as IO,LRLanguage as Ue,indentNodeProp as $e,continuedIndent as se,foldNodeProp as ae,foldInside as BO,LanguageSupport as J,sublanguageProp as NO,flatIndent as Sa,delimitedIndent as Pa,defineLanguageFacet as DO,bracketMatchingHandle as Za,Language as Xa,foldService as ka,languageDataProp as ba,LanguageDescription as lO,ParseContext as xa}from"./D7ZqAKi9.js";import{P as wa,b as he,N as G,e as ya,a as KO,s as re,T as j,p as JO,d as o,f as FO,I as HO}from"./C7VoTosa.js";import{L as Me,E as w,C as et,a as ze}from"./CrdV0ttd.js";class Ta{constructor(O,t,a,r){this.state=O,this.pos=t,this.explicit=a,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(O){let t=y(this.state).resolveInner(this.pos,-1);for(;t&&O.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(O){let t=this.state.doc.lineAt(this.pos),a=Math.max(t.from,this.pos-250),r=t.text.slice(a-t.from,this.pos-t.from),i=r.search(za(O));return i<0?null:{from:a+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(O,t,a){O=="abort"&&this.abortListeners&&(this.abortListeners.push(t),a&&a.onDocChange&&(this.abortOnDocChange=!0))}}function sO(e){let O=Object.keys(e).join(""),t=/\w/.test(O);return t&&(O=O.replace(/\w/g,"")),`[${t?"\\w":""}${O.replace(/[^\w\s]/g,"\\$&")}]`}function Ya(e){let O=Object.create(null),t=Object.create(null);for(let{label:r}of e){O[r[0]]=!0;for(let i=1;i<r.length;i++)t[r[i]]=!0}let a=sO(O)+sO(t)+"*$";return[new RegExp("^"+a),new RegExp(a)]}function _a(e){let O=e.map(r=>typeof r=="string"?{label:r}:r),[t,a]=O.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:Ya(O);return r=>{let i=r.matchBefore(a);return i||r.explicit?{from:i?i.from:r.pos,options:O,validFor:t}:null}}function va(e,O){return t=>{for(let a=y(t.state).resolveInner(t.pos,-1);a;a=a.parent){if(e.indexOf(a.name)>-1)return null;if(a.type.isTop)break}return O(t)}}function za(e,O){var t;let{source:a}=e,r=a[a.length-1]!="$";return r?new RegExp(`(?:${a})${r?"$":""}`,(t=e.flags)!==null&&t!==void 0?t:e.ignoreCase?"i":""):e}const qa=ua.define(),Ra=E.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Va{constructor(O,t,a,r){this.field=O,this.line=t,this.from=a,this.to=r}}class Ie{constructor(O,t,a){this.field=O,this.from=t,this.to=a}map(O){let t=O.mapPos(this.from,-1,nO.TrackDel),a=O.mapPos(this.to,1,nO.TrackDel);return t==null||a==null?null:new Ie(this.field,t,a)}}class Be{constructor(O,t){this.lines=O,this.fieldPositions=t}instantiate(O,t){let a=[],r=[t],i=O.doc.lineAt(t),n=/^\s*/.exec(i.text)[0];for(let s of this.lines){if(a.length){let c=n,Q=/^\t*/.exec(s)[0].length;for(let p=0;p<Q;p++)c+=O.facet(IO);r.push(t+c.length-Q),s=c+s.slice(Q)}a.push(s),t+=s.length+1}let l=this.fieldPositions.map(s=>new Ie(s.field,r[s.line]+s.from,r[s.line]+s.to));return{text:a,ranges:l}}static parse(O){let t=[],a=[],r=[],i;for(let n of O.split(/\r\n?|\n/)){for(;i=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(n);){let l=i[1]?+i[1]:null,s=i[2]||i[3]||"",c=-1,Q=s.replace(/\\[{}]/g,p=>p[1]);for(let p=0;p<t.length;p++)(l!=null?t[p].seq==l:Q&&t[p].name==Q)&&(c=p);if(c<0){let p=0;for(;p<t.length&&(l==null||t[p].seq!=null&&t[p].seq<l);)p++;t.splice(p,0,{seq:l,name:Q}),c=p;for(let d of r)d.field>=c&&d.field++}for(let p of r)if(p.line==a.length&&p.from>i.index){let d=i[2]?3+(i[1]||"").length:2;p.from-=d,p.to-=d}r.push(new Va(c,a.length,i.index,i.index+Q.length)),n=n.slice(0,i.index)+s+n.slice(i.index+i[0].length)}n=n.replace(/\\([{}])/g,(l,s,c)=>{for(let Q of r)Q.line==a.length&&Q.from>c&&(Q.from--,Q.to--);return s}),a.push(n)}return new Be(a,r)}}let ja=me.widget({widget:new class extends ga{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Ga=me.mark({class:"cm-snippetField"});class A{constructor(O,t){this.ranges=O,this.active=t,this.deco=me.set(O.map(a=>(a.from==a.to?ja:Ga).range(a.from,a.to)),!0)}map(O){let t=[];for(let a of this.ranges){let r=a.map(O);if(!r)return null;t.push(r)}return new A(t,this.active)}selectionInsideField(O){return O.ranges.every(t=>this.ranges.some(a=>a.field==this.active&&a.from<=t.from&&a.to>=t.to))}}const ie=Ae.define({map(e,O){return e&&e.map(O)}}),Wa=Ae.define(),F=fa.define({create(){return null},update(e,O){for(let t of O.effects){if(t.is(ie))return t.value;if(t.is(Wa)&&e)return new A(e.ranges,t.value)}return e&&O.docChanged&&(e=e.map(O.changes)),e&&O.selection&&!e.selectionInsideField(O.selection)&&(e=null),e},provide:e=>E.decorations.from(e,O=>O?O.deco:me.none)});function Ne(e,O){return Y.create(e.filter(t=>t.field==O).map(t=>Y.range(t.from,t.to)))}function La(e){let O=Be.parse(e);return(t,a,r,i)=>{let{text:n,ranges:l}=O.instantiate(t.state,r),{main:s}=t.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:da.of(n)},scrollIntoView:!0,annotations:a?[qa.of(a),pa.userEvent.of("input.complete")]:void 0};if(l.length&&(c.selection=Ne(l,0)),l.some(Q=>Q.field>0)){let Q=new A(l,0),p=c.effects=[ie.of(Q)];t.state.field(F,!1)===void 0&&p.push(Ae.appendConfig.of([F,Ma,Ia,Ra]))}t.dispatch(t.state.update(c))}}function Ot(e){return({state:O,dispatch:t})=>{let a=O.field(F,!1);if(!a||e<0&&a.active==0)return!1;let r=a.active+e,i=e>0&&!a.ranges.some(n=>n.field==r+e);return t(O.update({selection:Ne(a.ranges,r),effects:ie.of(i?null:new A(a.ranges,r)),scrollIntoView:!0})),!0}}const Ca=({state:e,dispatch:O})=>e.field(F,!1)?(O(e.update({effects:ie.of(null)})),!0):!1,Ea=Ot(1),Aa=Ot(-1),Ua=[{key:"Tab",run:Ea,shift:Aa},{key:"Escape",run:Ca}],oO=ma.define({combine(e){return e.length?e[0]:Ua}}),Ma=UO.highest(MO.compute([oO],e=>e.facet(oO)));function k(e,O){return{...O,apply:La(e)}}const Ia=E.domEventHandlers({mousedown(e,O){let t=O.state.field(F,!1),a;if(!t||(a=O.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let r=t.ranges.find(i=>i.from<=a&&i.to>=a);return!r||r.field==t.active?!1:(O.dispatch({selection:Ne(t.ranges,r.field),effects:ie.of(t.ranges.some(i=>i.field>r.field)?new A(t.ranges,r.field):null),scrollIntoView:!0}),!0)}}),tt=new class extends $a{};tt.startSide=1;tt.endSide=-1;class ce{static create(O,t,a,r,i){let n=r+(r<<8)+O+(t<<4)|0;return new ce(O,t,a,n,i,[],[])}constructor(O,t,a,r,i,n,l){this.type=O,this.value=t,this.from=a,this.hash=r,this.end=i,this.children=n,this.positions=l,this.hashProp=[[G.contextHash,r]]}addChild(O,t){O.prop(G.contextHash)!=this.hash&&(O=new j(O.type,O.children,O.positions,O.length,this.hashProp)),this.children.push(O),this.positions.push(t)}toTree(O,t=this.end){let a=this.children.length-1;return a>=0&&(t=Math.max(t,this.positions[a]+this.children[a].length+this.from)),new j(O.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(r,i,n)=>new j(he.none,r,i,n,this.hashProp)})}}var u;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(u||(u={}));class Ba{constructor(O,t){this.start=O,this.content=t,this.marks=[],this.parsers=[]}}class Na{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let O=this.skipSpace(this.basePos);this.indent=this.countIndent(O,this.pos,this.indent),this.pos=O,this.next=O==this.text.length?-1:this.text.charCodeAt(O)}skipSpace(O){return N(this.text,O)}reset(O){for(this.text=O,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(O){this.basePos=O,this.baseIndent=this.countIndent(O,this.pos,this.indent)}moveBaseColumn(O){this.baseIndent=O,this.basePos=this.findColumn(O)}addMarker(O){this.markers.push(O)}countIndent(O,t=0,a=0){for(let r=t;r<O;r++)a+=this.text.charCodeAt(r)==9?4-a%4:1;return a}findColumn(O){let t=0;for(let a=0;t<this.text.length&&a<O;t++)a+=this.text.charCodeAt(t)==9?4-a%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let O="";for(let t=0;t<this.basePos;t++)O+=" ";return O+this.text.slice(this.basePos)}}function QO(e,O,t){if(t.pos==t.text.length||e!=O.block&&t.indent>=O.stack[t.depth+1].value+t.baseIndent)return!0;if(t.indent>=t.baseIndent+4)return!1;let a=(e.type==u.OrderedList?Je:Ke)(t,O,!1);return a>0&&(e.type!=u.BulletList||De(t,O,!1)<0)&&t.text.charCodeAt(t.pos+a-1)==e.value}const at={[u.Blockquote](e,O,t){return t.next!=62?!1:(t.markers.push(g(u.QuoteMark,O.lineStart+t.pos,O.lineStart+t.pos+1)),t.moveBase(t.pos+(T(t.text.charCodeAt(t.pos+1))?2:1)),e.end=O.lineStart+t.text.length,!0)},[u.ListItem](e,O,t){return t.indent<t.baseIndent+e.value&&t.next>-1?!1:(t.moveBaseColumn(t.baseIndent+e.value),!0)},[u.OrderedList]:QO,[u.BulletList]:QO,[u.Document](){return!0}};function T(e){return e==32||e==9||e==10||e==13}function N(e,O=0){for(;O<e.length&&T(e.charCodeAt(O));)O++;return O}function cO(e,O,t){for(;O>t&&T(e.charCodeAt(O-1));)O--;return O}function rt(e){if(e.next!=96&&e.next!=126)return-1;let O=e.pos+1;for(;O<e.text.length&&e.text.charCodeAt(O)==e.next;)O++;if(O<e.pos+3)return-1;if(e.next==96){for(let t=O;t<e.text.length;t++)if(e.text.charCodeAt(t)==96)return-1}return O}function it(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function De(e,O,t){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let a=1;for(let r=e.pos+1;r<e.text.length;r++){let i=e.text.charCodeAt(r);if(i==e.next)a++;else if(!T(i))return-1}return t&&e.next==45&&st(e)>-1&&e.depth==O.stack.length&&O.parser.leafBlockParsers.indexOf(pt.SetextHeading)>-1||a<3?-1:1}function nt(e,O){for(let t=e.stack.length-1;t>=0;t--)if(e.stack[t].type==O)return!0;return!1}function Ke(e,O,t){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||T(e.text.charCodeAt(e.pos+1)))&&(!t||nt(O,u.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Je(e,O,t){let a=e.pos,r=e.next;for(;r>=48&&r<=57;){a++;if(a==e.text.length)return-1;r=e.text.charCodeAt(a)}return a==e.pos||a>e.pos+9||r!=46&&r!=41||a<e.text.length-1&&!T(e.text.charCodeAt(a+1))||t&&!nt(O,u.OrderedList)&&(e.skipSpace(a+1)==e.text.length||a>e.pos+1||e.next!=49)?-1:a+1-e.pos}function lt(e){if(e.next!=35)return-1;let O=e.pos+1;for(;O<e.text.length&&e.text.charCodeAt(O)==35;)O++;if(O<e.text.length&&e.text.charCodeAt(O)!=32)return-1;let t=O-e.pos;return t>6?-1:t}function st(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let O=e.pos+1;for(;O<e.text.length&&e.text.charCodeAt(O)==e.next;)O++;let t=O;for(;O<e.text.length&&T(e.text.charCodeAt(O));)O++;return O==e.text.length?t:-1}const qe=/^[ \t]*$/,ot=/-->/,Qt=/\?>/,Re=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,ot],[/^\s*<\?/,Qt],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,qe],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,qe]];function ct(e,O,t){if(e.next!=60)return-1;let a=e.text.slice(e.pos);for(let r=0,i=Re.length-(t?1:0);r<i;r++)if(Re[r][0].test(a))return r;return-1}function pO(e,O){let t=e.countIndent(O,e.pos,e.indent),a=e.countIndent(e.skipSpace(O),O,t);return a>=t+5?t+1:a}function z(e,O,t){let a=e.length-1;a>=0&&e[a].to==O&&e[a].type==u.CodeText?e[a].to=t:e.push(g(u.CodeText,O,t))}const ne={LinkReference:void 0,IndentedCode(e,O){let t=O.baseIndent+4;if(O.indent<t)return!1;let a=O.findColumn(t),r=e.lineStart+a,i=e.lineStart+O.text.length,n=[],l=[];for(z(n,r,i);e.nextLine()&&O.depth>=e.stack.length;)if(O.pos==O.text.length){z(l,e.lineStart-1,e.lineStart);for(let s of O.markers)l.push(s)}else{if(O.indent<t)break;{if(l.length){for(let c of l)c.type==u.CodeText?z(n,c.from,c.to):n.push(c);l=[]}z(n,e.lineStart-1,e.lineStart);for(let c of O.markers)n.push(c);i=e.lineStart+O.text.length;let s=e.lineStart+O.findColumn(O.baseIndent+4);s<i&&z(n,s,i)}}return l.length&&(l=l.filter(s=>s.type!=u.CodeText),l.length&&(O.markers=l.concat(O.markers))),e.addNode(e.buffer.writeElements(n,-r).finish(u.CodeBlock,i-r),r),!0},FencedCode(e,O){let t=rt(O);if(t<0)return!1;let a=e.lineStart+O.pos,r=O.next,i=t-O.pos,n=O.skipSpace(t),l=cO(O.text,O.text.length,n),s=[g(u.CodeMark,a,a+i)];n<l&&s.push(g(u.CodeInfo,e.lineStart+n,e.lineStart+l));for(let c=!0,Q=!0,p=!1;e.nextLine()&&O.depth>=e.stack.length;c=!1){let d=O.pos;if(O.indent-O.baseIndent<4)for(;d<O.text.length&&O.text.charCodeAt(d)==r;)d++;if(d-O.pos>=i&&O.skipSpace(d)==O.text.length){for(let f of O.markers)s.push(f);Q&&p&&z(s,e.lineStart-1,e.lineStart),s.push(g(u.CodeMark,e.lineStart+O.pos,e.lineStart+d)),e.nextLine();break}else{p=!0,c||(z(s,e.lineStart-1,e.lineStart),Q=!1);for(let $ of O.markers)s.push($);let f=e.lineStart+O.basePos,h=e.lineStart+O.text.length;f<h&&(z(s,f,h),Q=!1)}}return e.addNode(e.buffer.writeElements(s,-a).finish(u.FencedCode,e.prevLineEnd()-a),a),!0},Blockquote(e,O){let t=it(O);return t<0?!1:(e.startContext(u.Blockquote,O.pos),e.addNode(u.QuoteMark,e.lineStart+O.pos,e.lineStart+O.pos+1),O.moveBase(O.pos+t),null)},HorizontalRule(e,O){if(De(O,e,!1)<0)return!1;let t=e.lineStart+O.pos;return e.nextLine(),e.addNode(u.HorizontalRule,t),!0},BulletList(e,O){let t=Ke(O,e,!1);if(t<0)return!1;e.block.type!=u.BulletList&&e.startContext(u.BulletList,O.basePos,O.next);let a=pO(O,O.pos+1);return e.startContext(u.ListItem,O.basePos,a-O.baseIndent),e.addNode(u.ListMark,e.lineStart+O.pos,e.lineStart+O.pos+t),O.moveBaseColumn(a),null},OrderedList(e,O){let t=Je(O,e,!1);if(t<0)return!1;e.block.type!=u.OrderedList&&e.startContext(u.OrderedList,O.basePos,O.text.charCodeAt(O.pos+t-1));let a=pO(O,O.pos+t);return e.startContext(u.ListItem,O.basePos,a-O.baseIndent),e.addNode(u.ListMark,e.lineStart+O.pos,e.lineStart+O.pos+t),O.moveBaseColumn(a),null},ATXHeading(e,O){let t=lt(O);if(t<0)return!1;let a=O.pos,r=e.lineStart+a,i=cO(O.text,O.text.length,a),n=i;for(;n>a&&O.text.charCodeAt(n-1)==O.next;)n--;(n==i||n==a||!T(O.text.charCodeAt(n-1)))&&(n=O.text.length);let l=e.buffer.write(u.HeaderMark,0,t).writeElements(e.parser.parseInline(O.text.slice(a+t+1,n),r+t+1),-r);n<O.text.length&&l.write(u.HeaderMark,n-a,i-a);let s=l.finish(u.ATXHeading1-1+t,O.text.length-a);return e.nextLine(),e.addNode(s,r),!0},HTMLBlock(e,O){let t=ct(O,e,!1);if(t<0)return!1;let a=e.lineStart+O.pos,r=Re[t][1],i=[],n=r!=qe;for(;!r.test(O.text)&&e.nextLine();){if(O.depth<e.stack.length){n=!1;break}for(let c of O.markers)i.push(c)}n&&e.nextLine();let l=r==ot?u.CommentBlock:r==Qt?u.ProcessingInstructionBlock:u.HTMLBlock,s=e.prevLineEnd();return e.addNode(e.buffer.writeElements(i,-a).finish(l,s-a),a),!0},SetextHeading:void 0};class Da{constructor(O){this.stage=0,this.elts=[],this.pos=0,this.start=O.start,this.advance(O.content)}nextLine(O,t,a){if(this.stage==-1)return!1;let r=a.content+`
2
2
  `+t.scrub(),i=this.advance(r);return i>-1&&i<r.length?this.complete(O,a,i):!1}finish(O,t){return(this.stage==2||this.stage==3)&&N(t.content,this.pos)==t.content.length?this.complete(O,t,t.content.length):!1}complete(O,t,a){return O.addLeafElement(t,g(u.LinkReference,this.start,this.start+a,this.elts)),!0}nextStage(O){return O?(this.pos=O.to-this.start,this.elts.push(O),this.stage++,!0):(O===!1&&(this.stage=-1),!1)}advance(O){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(Pt(O,this.pos,this.start,!0)))return-1;if(O.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(g(u.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(gt(O,N(O,this.pos),this.start)))return-1}else if(this.stage==2){let t=N(O,this.pos),a=0;if(t>this.pos){let r=St(O,t,this.start);if(r){let i=Se(O,r.to-this.start);i>0&&(this.nextStage(r),a=i)}}return a||(a=Se(O,this.pos)),a>0&&a<O.length?a:-1}else return Se(O,this.pos)}}}function Se(e,O){for(;O<e.length;O++){let t=e.charCodeAt(O);if(t==10)break;if(!T(t))return-1}return O}class Ka{nextLine(O,t,a){let r=t.depth<O.stack.length?-1:st(t),i=t.next;if(r<0)return!1;let n=g(u.HeaderMark,O.lineStart+t.pos,O.lineStart+r);return O.nextLine(),O.addLeafElement(a,g(i==61?u.SetextHeading1:u.SetextHeading2,a.start,O.prevLineEnd(),[...O.parser.parseInline(a.content,a.start),n])),!0}finish(){return!1}}const pt={LinkReference(e,O){return O.content.charCodeAt(0)==91?new Da(O):null},SetextHeading(){return new Ka}},Ja=[(e,O)=>lt(O)>=0,(e,O)=>rt(O)>=0,(e,O)=>it(O)>=0,(e,O)=>Ke(O,e,!0)>=0,(e,O)=>Je(O,e,!0)>=0,(e,O)=>De(O,e,!0)>=0,(e,O)=>ct(O,e,!0)>=0],Fa={text:"",end:0};class Ha{constructor(O,t,a,r){this.parser=O,this.input=t,this.ranges=r,this.line=new Na,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=ce.create(u.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=a.length?new tr(a,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:O}=this;for(;;){for(let a=0;;){let r=O.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;a<O.markers.length&&(!r||O.markers[a].from<r.end);){let i=O.markers[a++];this.addNode(i.type,i.from,i.to)}if(!r)break;this.finishContext()}if(O.pos<O.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(O.basePos))return null;e:for(;;){for(let a of this.parser.blockParsers)if(a){let r=a(this,O);if(r!=!1){if(r==!0)return null;O.forward();continue e}}break}let t=new Ba(this.lineStart+O.pos,O.text.slice(O.pos));for(let a of this.parser.leafBlockParsers)if(a){let r=a(this,t);r&&t.parsers.push(r)}e:for(;this.nextLine()&&O.pos!=O.text.length;){if(O.indent<O.baseIndent+4){for(let a of this.parser.endLeafBlock)if(a(this,O,t))break e}for(let a of t.parsers)if(a.nextLine(this,O,t))return null;t.content+=`
3
3
  `+O.scrub();for(let a of O.markers)t.marks.push(a)}return this.finishLeaf(t),null}stopAt(O){if(this.stoppedAt!=null&&this.stoppedAt<O)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=O}reuseFragment(O){if(!this.fragments.moveTo(this.absoluteLineStart+O,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=Zt(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(O=this.depth-1){return this.parser.nodeSet.types[this.stack[O].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(O){let t=Fa;if(t.end=O,O>=this.to)t.text="";else if(t.text=this.lineChunkAt(O),t.end+=t.text.length,this.ranges.length>1){let a=this.absoluteLineStart,r=this.rangeI;for(;this.ranges[r].to<t.end;){r++;let i=this.ranges[r].from,n=this.lineChunkAt(i);t.end=i+n.length,t.text=t.text.slice(0,this.ranges[r-1].to-a)+n,a=t.end-t.text.length}}return t}readLine(){let{line:O}=this,{text:t,end:a}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=a,O.reset(t);O.depth<this.stack.length;O.depth++){let r=this.stack[O.depth],i=this.parser.skipContextMarkup[r.type];if(!i)throw new Error("Unhandled block context "+u[r.type]);let n=this.line.markers.length;if(!i(r,this,O)){this.line.markers.length>n&&(r.end=this.line.markers[this.line.markers.length-1].to),O.forward();break}O.forward()}}lineChunkAt(O){let t=this.input.chunk(O),a;if(this.input.lineChunks)a=t==`
4
4
  `?"":t;else{let r=t.indexOf(`
@@ -1,3 +1,3 @@
1
- import{b as y,t as ee,T as g,c as W,P as Tt,d as u,I as ft,a as j,N as ne,s as re,h as se}from"./BXuvR8Ks.js";import{countColumn as ie,EditorState as O,Facet as v,StateEffect as z,RangeSetBuilder as nt,RangeSet as xt,StateField as St,Prec as Pt,combineConfig as Ct}from"./Cs5oz2oJ.js";import{V as R,g as oe,D as p,E as b,S as ut,a as H,G as le,W as At,l as ae}from"./BVBRzmeQ.js";var J;const S=new y;function It(n){return v.define({combine:n?t=>t.concat(n):void 0})}const he=new y;class d{constructor(t,e,r=[],s=""){this.data=t,this.name=s,O.prototype.hasOwnProperty("tree")||Object.defineProperty(O.prototype,"tree",{get(){return m(this)}}),this.parser=e,this.extension=[T.of(this),O.languageData.of((i,o,a)=>{let l=ct(i,o,a),h=l.type.prop(S);if(!h)return[];let f=i.facet(h),c=l.type.prop(he);if(c){let w=l.resolve(o-l.from,a);for(let k of c)if(k.test(w,i)){let P=i.facet(k.facet);return k.type=="replace"?P:P.concat(f)}}return f})].concat(r)}isActiveAt(t,e,r=-1){return ct(t,e,r).type.prop(S)==this.data}findRegions(t){let e=t.facet(T);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],s=(i,o)=>{if(i.prop(S)==this.data){r.push({from:o,to:o+i.length});return}let a=i.prop(y.mounted);if(a){if(a.tree.prop(S)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+i.length});return}else if(a.overlay){let l=r.length;if(s(a.tree,a.overlay[0].from+o),r.length>l)return}}for(let l=0;l<i.children.length;l++){let h=i.children[l];h instanceof g&&s(h,i.positions[l]+o)}};return s(m(t),0),r}get allowsNesting(){return!0}}d.setState=z.define();function ct(n,t,e){let r=n.facet(T),s=m(n).topNode;if(!r||r.allowsNesting)for(let i=s;i;i=i.enter(t,e,ft.ExcludeBuffers|ft.EnterBracketed))i.type.isTop&&(s=i);return s}class X extends d{constructor(t,e,r){super(t,e,[],r),this.parser=e}static define(t){let e=It(t.languageData);return new X(e,t.parser.configure({props:[S.add(r=>r.isTop?e:void 0)]}),t.name)}configure(t,e){return new X(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function m(n){let t=n.field(d.state,!1);return t?t.tree:g.empty}function fe(n,t,e=50){var r;let s=(r=n.field(d.state,!1))===null||r===void 0?void 0:r.context;if(!s)return null;let i=s.viewport;s.updateViewport({from:0,to:t});let o=s.isDone(t)||s.work(e,t)?s.tree:null;return s.updateViewport(i),o}function on(n,t=n.doc.length){var e;return((e=n.field(d.state,!1))===null||e===void 0?void 0:e.context.isDone(t))||!1}function ln(n,t=n.viewport.to,e=100){let r=fe(n.state,t,e);return r!=m(n.state)&&n.dispatch({}),!!r}function an(n){var t;return((t=n.plugin(Mt))===null||t===void 0?void 0:t.isWorking())||!1}class ue{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let M=null;class A{constructor(t,e,r=[],s,i,o,a,l){this.parser=t,this.state=e,this.fragments=r,this.tree=s,this.treeLen=i,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,r){return new A(t,e,[],g.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ue(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=g.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let s=Date.now()+t;t=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(W.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(W.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=M;M=this;try{return t()}finally{M=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=dt(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:s,treeLen:i,viewport:o,skipped:a}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((h,f,c,w)=>l.push({fromA:h,toA:f,fromB:c,toB:w})),r=W.applyChanges(r,l),s=g.empty,i=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){a=[];for(let h of this.skipped){let f=t.mapPos(h.from,1),c=t.mapPos(h.to,-1);f<c&&a.push({from:f,to:c})}}}return new A(this.parser,e,r,s,i,o,a,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:s,to:i}=this.skipped[r];s<t.to&&i>t.from&&(this.fragments=dt(this.fragments,s,i),this.skipped.splice(r--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Tt{createParse(e,r,s){let i=s[0].from,o=s[s.length-1].to;return{parsedPos:i,advance(){let l=M;if(l){for(let h of s)l.tempSkipped.push(h);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new g(j.none,[],[],o-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return M}}function dt(n,t,e){return W.applyChanges(n,[{fromA:t,toA:e,fromB:t,toB:e}])}class I{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new I(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=A.create(t.facet(T).parser,t,{from:0,to:e});return r.work(20,e)||r.takeTree(),new I(r)}}d.state=St.define({create:I.init,update(n,t){for(let e of t.effects)if(e.is(d.setState))return e.value;return t.startState.facet(T)!=t.state.facet(T)?I.init(t.state):n.apply(t)}});let Dt=n=>{let t=setTimeout(()=>n(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Dt=n=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(n,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const _=typeof navigator<"u"&&(!((J=navigator.scheduling)===null||J===void 0)&&J.isInputPending)?()=>navigator.scheduling.isInputPending():null,Mt=R.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(d.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(d.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=Dt(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:s}}=this.view,i=r.field(d.state);if(i.tree==i.context.tree&&i.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!_?Math.max(25,t.timeRemaining()-5):1e9),a=i.context.treeLen<s&&r.doc.length>s+1e3,l=i.context.work(()=>_&&_()||Date.now()>o,s+(a?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:d.setState.of(new I(i.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>ae(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),T=v.define({combine(n){return n.length?n[0]:null},enables:n=>[d.state,Mt,b.contentAttributes.compute([n],t=>{let e=t.facet(n);return e&&e.name?{"data-language":e.name}:{}})]});class fn{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Ot{constructor(t,e,r,s,i,o=void 0){this.name=t,this.alias=e,this.extensions=r,this.filename=s,this.loadFunc=i,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:r}=t;if(!e){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(r)}return new Ot(t.name,(t.alias||[]).concat(t.name).map(s=>s.toLowerCase()),t.extensions||[],t.filename,e,r)}static matchFilename(t,e){for(let s of t)if(s.filename&&s.filename.test(e))return s;let r=/\.([^.]+)$/.exec(e);if(r){for(let s of t)if(s.extensions.indexOf(r[1])>-1)return s}return null}static matchLanguageName(t,e,r=!0){e=e.toLowerCase();for(let s of t)if(s.alias.some(i=>i==e))return s;if(r)for(let s of t)for(let i of s.alias){let o=e.indexOf(i);if(o>-1&&(i.length>2||!/\w/.test(e[o-1])&&!/\w/.test(e[o+i.length])))return s}return null}}const ce=v.define(),Bt=v.define({combine:n=>{if(!n.length)return" ";let t=n[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return t}});function V(n){let t=n.facet(Bt);return t.charCodeAt(0)==9?n.tabSize*t.length:t.length}function Lt(n,t){let e="",r=n.tabSize,s=n.facet(Bt)[0];if(s==" "){for(;t>=r;)e+=" ",t-=r;s=" "}for(let i=0;i<t;i++)e+=s;return e}function Nt(n,t){n instanceof O&&(n=new rt(n));for(let r of n.state.facet(ce)){let s=r(n,t);if(s!==void 0)return s}let e=m(n.state);return e.length>=t?de(n,e,t):null}function un(n,t,e){let r=Object.create(null),s=new rt(n,{overrideIndentation:o=>{var a;return(a=r[o])!==null&&a!==void 0?a:-1}}),i=[];for(let o=t;o<=e;){let a=n.doc.lineAt(o);o=a.to+1;let l=Nt(s,a.from);if(l==null)continue;/\S/.test(a.text)||(l=0);let h=/^\s*/.exec(a.text)[0],f=Lt(n,l);h!=f&&(r[a.from]=l,i.push({from:a.from,to:a.from+h.length,insert:f}))}return n.changes(i)}class rt{constructor(t,e={}){this.state=t,this.options=e,this.unit=V(t)}lineAt(t,e=1){let r=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:i}=this.options;return s!=null&&s>=r.from&&s<=r.to?i&&s==t?{text:"",from:t}:(e<0?s<t:s<=t)?{text:r.text.slice(s-r.from),from:s}:{text:r.text.slice(0,s-r.from),from:r.from}:r}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:s}=this.lineAt(t,e);return r.slice(t-s,Math.min(r.length,t+100-s))}column(t,e=1){let{text:r,from:s}=this.lineAt(t,e),i=this.countColumn(r,t-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(i+=o-this.countColumn(r,r.search(/\S|$/))),i}countColumn(t,e=t.length){return ie(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:r,from:s}=this.lineAt(t,e),i=this.options.overrideIndentation;if(i){let o=i(s);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Rt=new y;function de(n,t,e){let r=t.resolveStack(e),s=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(s!=r.node){let i=[];for(let o=s;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)i.push(o);for(let o=i.length-1;o>=0;o--)r={node:i[o],next:r}}return Et(r,n,e)}function Et(n,t,e){for(let r=n;r;r=r.next){let s=ge(r.node);if(s)return s(st.create(t,e,r))}return 0}function pe(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function ge(n){let t=n.type.prop(Rt);if(t)return t;let e=n.firstChild,r;if(e&&(r=e.type.prop(y.closedBy))){let s=n.lastChild,i=s&&r.indexOf(s.name)>-1;return o=>Ft(o,!0,1,void 0,i&&!pe(o)?s.from:void 0)}return n.parent==null?me:null}function me(){return 0}class st extends rt{constructor(t,e,r){super(t.state,t.options),this.base=t,this.pos=e,this.context=r}get node(){return this.context.node}static create(t,e,r){return new st(t,e,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(ke(r,t))break;e=this.state.doc.lineAt(r.from)}return this.lineIndent(e.from)}continue(){return Et(this.context.next,this.base,this.pos)}}function ke(n,t){for(let e=t;e;e=e.parent)if(n==e)return!0;return!1}function be(n){let t=n.node,e=t.childAfter(t.from),r=t.lastChild;if(!e)return null;let s=n.options.simulateBreak,i=n.state.doc.lineAt(e.from),o=s==null||s<=i.from?i.to:Math.min(i.to,s);for(let a=e.to;;){let l=t.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let h=/^ */.exec(i.text.slice(e.to-i.from))[0].length;return{from:e.from,to:e.to+h}}a=l.to}}function cn({closing:n,align:t=!0,units:e=1}){return r=>Ft(r,t,e,n)}function Ft(n,t,e,r,s){let i=n.textAfter,o=i.match(/^\s*/)[0].length,a=r&&i.slice(o,o+r.length)==r||s==n.pos+o,l=t?be(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*e)}const dn=n=>n.baseIndent;function pn({except:n,units:t=1}={}){return e=>{let r=n&&n.test(e.textAfter);return e.baseIndent+(r?0:t*e.unit)}}const we=200;function gn(){return O.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let t=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!t.length)return n;let e=n.newDoc,{head:r}=n.newSelection.main,s=e.lineAt(r);if(r>s.from+we)return n;let i=e.sliceString(s.from,r);if(!t.some(h=>h.test(i)))return n;let{state:o}=n,a=-1,l=[];for(let{head:h}of o.selection.ranges){let f=o.doc.lineAt(h);if(f.from==a)continue;a=f.from;let c=Nt(o,f.from);if(c==null)continue;let w=/^\s*/.exec(f.text)[0],k=Lt(o,c);w!=k&&l.push({from:f.from,to:f.from+w.length,insert:k})}return l.length?[n,{changes:l,sequential:!0}]:n})}const ye=v.define(),ve=new y;function mn(n){let t=n.firstChild,e=n.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?n.to:e.from}:null}function Te(n,t,e){let r=m(n);if(r.length<e)return null;let s=r.resolveStack(e,1),i=null;for(let o=s;o;o=o.next){let a=o.node;if(a.to<=e||a.from>e)continue;if(i&&a.from<t)break;let l=a.type.prop(ve);if(l&&(a.to<r.length-50||r.length==n.doc.length||!xe(a))){let h=l(a,n);h&&h.from<=e&&h.from>=t&&h.to>e&&(i=h)}}return i}function xe(n){let t=n.lastChild;return t&&t.to==n.to&&t.type.isError}function B(n,t,e){for(let r of n.facet(ye)){let s=r(n,t,e);if(s)return s}return Te(n,t,e)}function Wt(n,t){let e=t.mapPos(n.from,1),r=t.mapPos(n.to,-1);return e>=r?void 0:{from:e,to:r}}const E=z.define({map:Wt}),D=z.define({map:Wt});function it(n){let t=[];for(let{head:e}of n.state.selection.ranges)t.some(r=>r.from<=e&&r.to>=e)||t.push(n.lineBlockAt(e));return t}const x=St.define({create(){return p.none},update(n,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((e,r)=>n=pt(n,e,r)),n=n.map(t.changes);for(let e of t.effects)if(e.is(E)&&!Se(n,e.value.from,e.value.to)){let{preparePlaceholder:r}=t.state.facet(lt),s=r?p.replace({widget:new Oe(r(t.state,e.value))}):gt;n=n.update({add:[s.range(e.value.from,e.value.to)]})}else e.is(D)&&(n=n.update({filter:(r,s)=>e.value.from!=r||e.value.to!=s,filterFrom:e.value.from,filterTo:e.value.to}));return t.selection&&(n=pt(n,t.selection.main.head)),n},provide:n=>b.decorations.from(n),toJSON(n,t){let e=[];return n.between(0,t.doc.length,(r,s)=>{e.push(r,s)}),e},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let e=0;e<n.length;){let r=n[e++],s=n[e++];if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");t.push(gt.range(r,s))}return p.set(t,!0)}});function pt(n,t,e=t){let r=!1;return n.between(t,e,(s,i)=>{s<e&&i>t&&(r=!0)}),r?n.update({filterFrom:t,filterTo:e,filter:(s,i)=>s>=e||i<=t}):n}function kn(n){return n.field(x,!1)||xt.empty}function L(n,t,e){var r;let s=null;return(r=n.field(x,!1))===null||r===void 0||r.between(t,e,(i,o)=>{(!s||s.from>i)&&(s={from:i,to:o})}),s}function Se(n,t,e){let r=!1;return n.between(t,t,(s,i)=>{s==t&&i==e&&(r=!0)}),r}function ot(n,t){return n.field(x,!1)?t:t.concat(z.appendConfig.of(Ut()))}const Pe=n=>{for(let t of it(n)){let e=B(n.state,t.from,t.to);if(e)return n.dispatch({effects:ot(n.state,[E.of(e),$(n,e)])}),!0}return!1},Ce=n=>{if(!n.state.field(x,!1))return!1;let t=[];for(let e of it(n)){let r=L(n.state,e.from,e.to);r&&t.push(D.of(r),$(n,r,!1))}return t.length&&n.dispatch({effects:t}),t.length>0};function $(n,t,e=!0){let r=n.state.doc.lineAt(t.from).number,s=n.state.doc.lineAt(t.to).number;return b.announce.of(`${n.state.phrase(e?"Folded lines":"Unfolded lines")} ${r} ${n.state.phrase("to")} ${s}.`)}const Ae=n=>{let{state:t}=n,e=[];for(let r=0;r<t.doc.length;){let s=n.lineBlockAt(r),i=B(t,s.from,s.to);i&&e.push(E.of(i)),r=(i?n.lineBlockAt(i.to):s).to+1}return e.length&&n.dispatch({effects:ot(n.state,e)}),!!e.length},Ie=n=>{let t=n.state.field(x,!1);if(!t||!t.size)return!1;let e=[];return t.between(0,n.state.doc.length,(r,s)=>{e.push(D.of({from:r,to:s}))}),n.dispatch({effects:e}),!0};function De(n,t){for(let e=t;;){let r=B(n.state,e.from,e.to);if(r&&r.to>t.from)return r;if(!e.from)return null;e=n.lineBlockAt(e.from-1)}}const bn=n=>{let t=[];for(let e of it(n)){let r=L(n.state,e.from,e.to);if(r)t.push(D.of(r),$(n,r,!1));else{let s=De(n,e);s&&t.push(E.of(s),$(n,s))}}return t.length>0&&n.dispatch({effects:ot(n.state,t)}),!!t.length},wn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Pe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Ce},{key:"Ctrl-Alt-[",run:Ae},{key:"Ctrl-Alt-]",run:Ie}],Me={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},lt=v.define({combine(n){return Ct(n,Me)}});function Ut(n){let t=[x,Le];return n&&t.push(lt.of(n)),t}function Ht(n,t){let{state:e}=n,r=e.facet(lt),s=o=>{let a=n.lineBlockAt(n.posAtDOM(o.target)),l=L(n.state,a.from,a.to);l&&n.dispatch({effects:D.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(n,s,t);let i=document.createElement("span");return i.textContent=r.placeholderText,i.setAttribute("aria-label",e.phrase("folded code")),i.title=e.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=s,i}const gt=p.replace({widget:new class extends At{toDOM(n){return Ht(n,null)}}});class Oe extends At{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ht(t,this.value)}}const Be={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class K extends le{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function yn(n={}){let t={...Be,...n},e=new K(t,!0),r=new K(t,!1),s=R.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(T)!=o.state.facet(T)||o.startState.field(x,!1)!=o.state.field(x,!1)||m(o.startState)!=m(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new nt;for(let l of o.viewportLineBlocks){let h=L(o.state,l.from,l.to)?r:B(o.state,l.from,l.to)?e:null;h&&a.add(l.from,l.from,h)}return a.finish()}}),{domEventHandlers:i}=t;return[s,oe({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(s))===null||a===void 0?void 0:a.markers)||xt.empty},initialSpacer(){return new K(t,!1)},domEventHandlers:{...i,click:(o,a,l)=>{if(i.click&&i.click(o,a,l))return!0;let h=L(o.state,a.from,a.to);if(h)return o.dispatch({effects:D.of(h)}),!0;let f=B(o.state,a.from,a.to);return f?(o.dispatch({effects:E.of(f)}),!0):!1}}}),Ut()]}const Le=b.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class G{constructor(t,e){this.specs=t;let r;function s(a){let l=ut.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const i=typeof e.all=="string"?e.all:e.all?s(e.all):void 0,o=e.scope;this.scope=o instanceof d?a=>a.prop(S)==o.data:o?a=>a==o:void 0,this.style=ee(t.map(a=>({tag:a.tag,class:a.class||s(Object.assign({},a,{tag:null}))})),{all:i}).style,this.module=r?new ut(r):null,this.themeType=e.themeType}static define(t,e){return new G(t,e||{})}}const Y=v.define(),Vt=v.define({combine(n){return n.length?[n[0]]:null}});function U(n){let t=n.facet(Y);return t.length?t:n.facet(Vt)}function vn(n,t){let e=[Re],r;return n instanceof G&&(n.module&&e.push(b.styleModule.of(n.module)),r=n.themeType),t?.fallback?e.push(Vt.of(n)):r?e.push(Y.computeN([b.darkTheme],s=>s.facet(b.darkTheme)==(r=="dark")?[n]:[])):e.push(Y.of(n)),e}function Tn(n,t,e){let r=U(n),s=null;if(r){for(let i of r)if(!i.scope||e&&i.scope(e)){let o=i.style(t);o&&(s=s?s+" "+o:o)}}return s}class Ne{constructor(t){this.markCache=Object.create(null),this.tree=m(t.state),this.decorations=this.buildDeco(t,U(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=m(t.state),r=U(t.state),s=r!=U(t.startState),{viewport:i}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<i.to&&!s&&e.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=i.to)}buildDeco(t,e){if(!e||!this.tree.length)return p.none;let r=new nt;for(let{from:s,to:i}of t.visibleRanges)se(this.tree,e,(o,a,l)=>{r.add(o,a,this.markCache[l]||(this.markCache[l]=p.mark({class:l})))},s,i);return r.finish()}}const Re=Pt.high(R.fromClass(Ne,{decorations:n=>n.decorations})),xn=G.define([{tag:u.meta,color:"#404740"},{tag:u.link,textDecoration:"underline"},{tag:u.heading,textDecoration:"underline",fontWeight:"bold"},{tag:u.emphasis,fontStyle:"italic"},{tag:u.strong,fontWeight:"bold"},{tag:u.strikethrough,textDecoration:"line-through"},{tag:u.keyword,color:"#708"},{tag:[u.atom,u.bool,u.url,u.contentSeparator,u.labelName],color:"#219"},{tag:[u.literal,u.inserted],color:"#164"},{tag:[u.string,u.deleted],color:"#a11"},{tag:[u.regexp,u.escape,u.special(u.string)],color:"#e40"},{tag:u.definition(u.variableName),color:"#00f"},{tag:u.local(u.variableName),color:"#30a"},{tag:[u.typeName,u.namespace],color:"#085"},{tag:u.className,color:"#167"},{tag:[u.special(u.variableName),u.macroName],color:"#256"},{tag:u.definition(u.propertyName),color:"#00c"},{tag:u.comment,color:"#940"},{tag:u.invalid,color:"#f00"}]),Ee=b.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),$t=1e4,jt="()[]{}",zt=v.define({combine(n){return Ct(n,{afterCursor:!0,brackets:jt,maxScanDistance:$t,renderMatch:Ue})}}),Fe=p.mark({class:"cm-matchingBracket"}),We=p.mark({class:"cm-nonmatchingBracket"});function Ue(n){let t=[],e=n.matched?Fe:We;return t.push(e.range(n.start.from,n.start.to)),n.end&&t.push(e.range(n.end.from,n.end.to)),t}function mt(n){let t=[],e=n.facet(zt);for(let r of n.selection.ranges){if(!r.empty)continue;let s=F(n,r.head,-1,e)||r.head>0&&F(n,r.head-1,1,e)||e.afterCursor&&(F(n,r.head,1,e)||r.head<n.doc.length&&F(n,r.head+1,-1,e));s&&(t=t.concat(e.renderMatch(s,n)))}return p.set(t,!0)}const He=R.fromClass(class{constructor(n){this.paused=!1,this.decorations=mt(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=mt(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),Ve=[He,Ee];function Sn(n={}){return[zt.of(n),Ve]}const $e=new y;function Z(n,t,e){let r=n.prop(t<0?y.openedBy:y.closedBy);if(r)return r;if(n.name.length==1){let s=e.indexOf(n.name);if(s>-1&&s%2==(t<0?1:0))return[e[s+t]]}return null}function tt(n){let t=n.type.prop($e);return t?t(n.node):n}function F(n,t,e,r={}){let s=r.maxScanDistance||$t,i=r.brackets||jt,o=m(n),a=o.resolveInner(t,e);for(let l=a;l;l=l.parent){let h=Z(l.type,e,i);if(h&&l.from<l.to){let f=tt(l);if(f&&(e>0?t>=f.from&&t<f.to:t>f.from&&t<=f.to))return je(n,t,e,l,f,h,i)}}return ze(n,t,e,o,a.type,s,i)}function je(n,t,e,r,s,i,o){let a=r.parent,l={from:s.from,to:s.to},h=0,f=a?.cursor();if(f&&(e<0?f.childBefore(r.from):f.childAfter(r.to)))do if(e<0?f.to<=r.from:f.from>=r.to){if(h==0&&i.indexOf(f.type.name)>-1&&f.from<f.to){let c=tt(f);return{start:l,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(Z(f.type,e,o))h++;else if(Z(f.type,-e,o)){if(h==0){let c=tt(f);return{start:l,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(e<0?f.prevSibling():f.nextSibling());return{start:l,matched:!1}}function ze(n,t,e,r,s,i,o){let a=e<0?n.sliceDoc(t-1,t):n.sliceDoc(t,t+1),l=o.indexOf(a);if(l<0||l%2==0!=e>0)return null;let h={from:e<0?t-1:t,to:e>0?t+1:t},f=n.doc.iterRange(t,e>0?n.doc.length:0),c=0;for(let w=0;!f.next().done&&w<=i;){let k=f.value;e<0&&(w+=k.length);let P=t+w*e;for(let C=e>0?0:k.length-1,te=e>0?k.length:-1;C!=te;C+=e){let q=o.indexOf(k[C]);if(!(q<0||r.resolveInner(P+C,1).type!=s))if(q%2==0==e>0)c++;else{if(c==1)return{start:h,end:{from:P+C,to:P+C+1},matched:q>>1==l>>1};c--}}e>0&&(w+=k.length)}return f.done?{start:h,matched:!1}:null}function kt(n,t,e,r=0,s=0){t==null&&(t=n.search(/[^\s\u00a0]/),t==-1&&(t=n.length));let i=s;for(let o=r;o<t;o++)n.charCodeAt(o)==9?i+=e-i%e:i++;return i}class Gt{constructor(t,e,r,s){this.string=t,this.tabSize=e,this.indentUnit=r,this.overrideIndent=s,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e=this.string.charAt(this.pos),r;if(typeof t=="string"?r=e==t:r=e&&(t instanceof RegExp?t.test(e):t(e)),r)return++this.pos,e}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=kt(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:kt(this.string,null,this.tabSize)}match(t,e,r){if(typeof t=="string"){let s=o=>r?o.toLowerCase():o,i=this.string.substr(this.pos,t.length);return s(i)==s(t)?(e!==!1&&(this.pos+=t.length),!0):null}else{let s=this.string.slice(this.pos).match(t);return s&&s.index>0?null:(s&&e!==!1&&(this.pos+=s[0].length),s)}}current(){return this.string.slice(this.start,this.pos)}}function Ge(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||qe,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||ht,mergeTokens:n.mergeTokens!==!1}}function qe(n){if(typeof n!="object")return n;let t={};for(let e in n){let r=n[e];t[e]=r instanceof Array?r.slice():r}return t}const bt=new WeakMap;class qt extends d{constructor(t){let e=It(t.languageData),r=Ge(t),s,i=new class extends Tt{createParse(o,a,l){return new _e(s,o,a,l)}};super(e,i,[],t.name),this.topNode=Xe(e,this),s=this,this.streamParser=r,this.stateAfter=new y({perNode:!0}),this.tokenTable=t.tokenTable?new Qt(r.tokenTable):Qe}static define(t){return new qt(t)}getIndent(t){let e,{overrideIndentation:r}=t.options;r&&(e=bt.get(t.state),e!=null&&e<t.pos-1e4&&(e=void 0));let s=at(this,t.node.tree,t.node.from,t.node.from,e??t.pos),i,o;if(s?(o=s.state,i=s.pos+1):(o=this.streamParser.startState(t.unit),i=t.node.from),t.pos-i>1e4)return null;for(;i<t.pos;){let l=t.state.doc.lineAt(i),h=Math.min(t.pos,l.to);if(l.length){let f=r?r(l.from):-1,c=new Gt(l.text,t.state.tabSize,t.unit,f<0?void 0:f);for(;c.pos<h-l.from;)_t(this.streamParser.token,c,o)}else this.streamParser.blankLine(o,t.unit);if(h==t.pos)break;i=l.to+1}let a=t.lineAt(t.pos);return r&&e==null&&bt.set(t.state,a.from),this.streamParser.indent(o,/^\s*(.*)/.exec(a.text)[1],t)}get allowsNesting(){return!1}}function at(n,t,e,r,s){let i=e>=r&&e+t.length<=s&&t.prop(n.stateAfter);if(i)return{state:n.streamParser.copyState(i),pos:e+t.length};for(let o=t.children.length-1;o>=0;o--){let a=t.children[o],l=e+t.positions[o],h=a instanceof g&&l<s&&at(n,a,l,r,s);if(h)return h}return null}function Jt(n,t,e,r,s){if(s&&e<=0&&r>=t.length)return t;!s&&e==0&&t.type==n.topNode&&(s=!0);for(let i=t.children.length-1;i>=0;i--){let o=t.positions[i],a=t.children[i],l;if(o<r&&a instanceof g){if(!(l=Jt(n,a,e-o,r-o,s)))break;return s?new g(t.type,t.children.slice(0,i).concat(l),t.positions.slice(0,i+1),o+l.length):l}}return null}function Je(n,t,e,r,s){for(let i of t){let o=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),l=o<=e&&a>e&&at(n,i.tree,0-i.offset,e,a),h;if(l&&l.pos<=r&&(h=Jt(n,i.tree,e+i.offset,l.pos+i.offset,!1)))return{state:l.state,tree:h}}return{state:n.streamParser.startState(s?V(s):4),tree:g.empty}}class _e{constructor(t,e,r,s){this.lang=t,this.input=e,this.fragments=r,this.ranges=s,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=s[s.length-1].to;let i=A.get(),o=s[0].from,{state:a,tree:l}=Je(t,r,o,this.to,i?.state);this.state=a,this.parsedPos=this.chunkStart=o+l.length;for(let h=0;h<l.children.length;h++)this.chunks.push(l.children[h]),this.chunkPos.push(l.positions[h]);i&&this.parsedPos<i.viewport.from-1e5&&s.some(h=>h.from<=i.viewport.from&&h.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(V(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let t=A.get(),e=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(e,this.chunkStart+512);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)e==`
1
+ import{N as y,t as ee,T as g,c as W,P as Tt,d as u,I as ft,b as j,a as ne,s as re,h as se}from"./C7VoTosa.js";import{countColumn as ie,EditorState as O,Facet as v,StateEffect as z,RangeSetBuilder as nt,RangeSet as xt,StateField as St,Prec as Pt,combineConfig as Ct}from"./CX_61fY8.js";import{V as R,g as oe,a as p,E as b,S as ut,D as H,G as le,W as At,l as ae}from"./DnL9f0lc.js";var J;const S=new y;function It(n){return v.define({combine:n?t=>t.concat(n):void 0})}const he=new y;class d{constructor(t,e,r=[],s=""){this.data=t,this.name=s,O.prototype.hasOwnProperty("tree")||Object.defineProperty(O.prototype,"tree",{get(){return m(this)}}),this.parser=e,this.extension=[T.of(this),O.languageData.of((i,o,a)=>{let l=ct(i,o,a),h=l.type.prop(S);if(!h)return[];let f=i.facet(h),c=l.type.prop(he);if(c){let w=l.resolve(o-l.from,a);for(let k of c)if(k.test(w,i)){let P=i.facet(k.facet);return k.type=="replace"?P:P.concat(f)}}return f})].concat(r)}isActiveAt(t,e,r=-1){return ct(t,e,r).type.prop(S)==this.data}findRegions(t){let e=t.facet(T);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],s=(i,o)=>{if(i.prop(S)==this.data){r.push({from:o,to:o+i.length});return}let a=i.prop(y.mounted);if(a){if(a.tree.prop(S)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+i.length});return}else if(a.overlay){let l=r.length;if(s(a.tree,a.overlay[0].from+o),r.length>l)return}}for(let l=0;l<i.children.length;l++){let h=i.children[l];h instanceof g&&s(h,i.positions[l]+o)}};return s(m(t),0),r}get allowsNesting(){return!0}}d.setState=z.define();function ct(n,t,e){let r=n.facet(T),s=m(n).topNode;if(!r||r.allowsNesting)for(let i=s;i;i=i.enter(t,e,ft.ExcludeBuffers|ft.EnterBracketed))i.type.isTop&&(s=i);return s}class X extends d{constructor(t,e,r){super(t,e,[],r),this.parser=e}static define(t){let e=It(t.languageData);return new X(e,t.parser.configure({props:[S.add(r=>r.isTop?e:void 0)]}),t.name)}configure(t,e){return new X(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function m(n){let t=n.field(d.state,!1);return t?t.tree:g.empty}function fe(n,t,e=50){var r;let s=(r=n.field(d.state,!1))===null||r===void 0?void 0:r.context;if(!s)return null;let i=s.viewport;s.updateViewport({from:0,to:t});let o=s.isDone(t)||s.work(e,t)?s.tree:null;return s.updateViewport(i),o}function on(n,t=n.doc.length){var e;return((e=n.field(d.state,!1))===null||e===void 0?void 0:e.context.isDone(t))||!1}function ln(n,t=n.viewport.to,e=100){let r=fe(n.state,t,e);return r!=m(n.state)&&n.dispatch({}),!!r}function an(n){var t;return((t=n.plugin(Mt))===null||t===void 0?void 0:t.isWorking())||!1}class ue{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let M=null;class A{constructor(t,e,r=[],s,i,o,a,l){this.parser=t,this.state=e,this.fragments=r,this.tree=s,this.treeLen=i,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,r){return new A(t,e,[],g.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ue(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=g.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let s=Date.now()+t;t=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(W.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(W.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=M;M=this;try{return t()}finally{M=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=dt(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:s,treeLen:i,viewport:o,skipped:a}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((h,f,c,w)=>l.push({fromA:h,toA:f,fromB:c,toB:w})),r=W.applyChanges(r,l),s=g.empty,i=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){a=[];for(let h of this.skipped){let f=t.mapPos(h.from,1),c=t.mapPos(h.to,-1);f<c&&a.push({from:f,to:c})}}}return new A(this.parser,e,r,s,i,o,a,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:s,to:i}=this.skipped[r];s<t.to&&i>t.from&&(this.fragments=dt(this.fragments,s,i),this.skipped.splice(r--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Tt{createParse(e,r,s){let i=s[0].from,o=s[s.length-1].to;return{parsedPos:i,advance(){let l=M;if(l){for(let h of s)l.tempSkipped.push(h);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new g(j.none,[],[],o-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return M}}function dt(n,t,e){return W.applyChanges(n,[{fromA:t,toA:e,fromB:t,toB:e}])}class I{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new I(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=A.create(t.facet(T).parser,t,{from:0,to:e});return r.work(20,e)||r.takeTree(),new I(r)}}d.state=St.define({create:I.init,update(n,t){for(let e of t.effects)if(e.is(d.setState))return e.value;return t.startState.facet(T)!=t.state.facet(T)?I.init(t.state):n.apply(t)}});let Dt=n=>{let t=setTimeout(()=>n(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Dt=n=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(n,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const _=typeof navigator<"u"&&(!((J=navigator.scheduling)===null||J===void 0)&&J.isInputPending)?()=>navigator.scheduling.isInputPending():null,Mt=R.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(d.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(d.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=Dt(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:s}}=this.view,i=r.field(d.state);if(i.tree==i.context.tree&&i.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!_?Math.max(25,t.timeRemaining()-5):1e9),a=i.context.treeLen<s&&r.doc.length>s+1e3,l=i.context.work(()=>_&&_()||Date.now()>o,s+(a?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:d.setState.of(new I(i.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>ae(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),T=v.define({combine(n){return n.length?n[0]:null},enables:n=>[d.state,Mt,b.contentAttributes.compute([n],t=>{let e=t.facet(n);return e&&e.name?{"data-language":e.name}:{}})]});class fn{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Ot{constructor(t,e,r,s,i,o=void 0){this.name=t,this.alias=e,this.extensions=r,this.filename=s,this.loadFunc=i,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:r}=t;if(!e){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(r)}return new Ot(t.name,(t.alias||[]).concat(t.name).map(s=>s.toLowerCase()),t.extensions||[],t.filename,e,r)}static matchFilename(t,e){for(let s of t)if(s.filename&&s.filename.test(e))return s;let r=/\.([^.]+)$/.exec(e);if(r){for(let s of t)if(s.extensions.indexOf(r[1])>-1)return s}return null}static matchLanguageName(t,e,r=!0){e=e.toLowerCase();for(let s of t)if(s.alias.some(i=>i==e))return s;if(r)for(let s of t)for(let i of s.alias){let o=e.indexOf(i);if(o>-1&&(i.length>2||!/\w/.test(e[o-1])&&!/\w/.test(e[o+i.length])))return s}return null}}const ce=v.define(),Bt=v.define({combine:n=>{if(!n.length)return" ";let t=n[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return t}});function V(n){let t=n.facet(Bt);return t.charCodeAt(0)==9?n.tabSize*t.length:t.length}function Lt(n,t){let e="",r=n.tabSize,s=n.facet(Bt)[0];if(s==" "){for(;t>=r;)e+=" ",t-=r;s=" "}for(let i=0;i<t;i++)e+=s;return e}function Nt(n,t){n instanceof O&&(n=new rt(n));for(let r of n.state.facet(ce)){let s=r(n,t);if(s!==void 0)return s}let e=m(n.state);return e.length>=t?de(n,e,t):null}function un(n,t,e){let r=Object.create(null),s=new rt(n,{overrideIndentation:o=>{var a;return(a=r[o])!==null&&a!==void 0?a:-1}}),i=[];for(let o=t;o<=e;){let a=n.doc.lineAt(o);o=a.to+1;let l=Nt(s,a.from);if(l==null)continue;/\S/.test(a.text)||(l=0);let h=/^\s*/.exec(a.text)[0],f=Lt(n,l);h!=f&&(r[a.from]=l,i.push({from:a.from,to:a.from+h.length,insert:f}))}return n.changes(i)}class rt{constructor(t,e={}){this.state=t,this.options=e,this.unit=V(t)}lineAt(t,e=1){let r=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:i}=this.options;return s!=null&&s>=r.from&&s<=r.to?i&&s==t?{text:"",from:t}:(e<0?s<t:s<=t)?{text:r.text.slice(s-r.from),from:s}:{text:r.text.slice(0,s-r.from),from:r.from}:r}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:s}=this.lineAt(t,e);return r.slice(t-s,Math.min(r.length,t+100-s))}column(t,e=1){let{text:r,from:s}=this.lineAt(t,e),i=this.countColumn(r,t-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(i+=o-this.countColumn(r,r.search(/\S|$/))),i}countColumn(t,e=t.length){return ie(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:r,from:s}=this.lineAt(t,e),i=this.options.overrideIndentation;if(i){let o=i(s);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Rt=new y;function de(n,t,e){let r=t.resolveStack(e),s=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(s!=r.node){let i=[];for(let o=s;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)i.push(o);for(let o=i.length-1;o>=0;o--)r={node:i[o],next:r}}return Et(r,n,e)}function Et(n,t,e){for(let r=n;r;r=r.next){let s=ge(r.node);if(s)return s(st.create(t,e,r))}return 0}function pe(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function ge(n){let t=n.type.prop(Rt);if(t)return t;let e=n.firstChild,r;if(e&&(r=e.type.prop(y.closedBy))){let s=n.lastChild,i=s&&r.indexOf(s.name)>-1;return o=>Ft(o,!0,1,void 0,i&&!pe(o)?s.from:void 0)}return n.parent==null?me:null}function me(){return 0}class st extends rt{constructor(t,e,r){super(t.state,t.options),this.base=t,this.pos=e,this.context=r}get node(){return this.context.node}static create(t,e,r){return new st(t,e,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(ke(r,t))break;e=this.state.doc.lineAt(r.from)}return this.lineIndent(e.from)}continue(){return Et(this.context.next,this.base,this.pos)}}function ke(n,t){for(let e=t;e;e=e.parent)if(n==e)return!0;return!1}function be(n){let t=n.node,e=t.childAfter(t.from),r=t.lastChild;if(!e)return null;let s=n.options.simulateBreak,i=n.state.doc.lineAt(e.from),o=s==null||s<=i.from?i.to:Math.min(i.to,s);for(let a=e.to;;){let l=t.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let h=/^ */.exec(i.text.slice(e.to-i.from))[0].length;return{from:e.from,to:e.to+h}}a=l.to}}function cn({closing:n,align:t=!0,units:e=1}){return r=>Ft(r,t,e,n)}function Ft(n,t,e,r,s){let i=n.textAfter,o=i.match(/^\s*/)[0].length,a=r&&i.slice(o,o+r.length)==r||s==n.pos+o,l=t?be(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*e)}const dn=n=>n.baseIndent;function pn({except:n,units:t=1}={}){return e=>{let r=n&&n.test(e.textAfter);return e.baseIndent+(r?0:t*e.unit)}}const we=200;function gn(){return O.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let t=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!t.length)return n;let e=n.newDoc,{head:r}=n.newSelection.main,s=e.lineAt(r);if(r>s.from+we)return n;let i=e.sliceString(s.from,r);if(!t.some(h=>h.test(i)))return n;let{state:o}=n,a=-1,l=[];for(let{head:h}of o.selection.ranges){let f=o.doc.lineAt(h);if(f.from==a)continue;a=f.from;let c=Nt(o,f.from);if(c==null)continue;let w=/^\s*/.exec(f.text)[0],k=Lt(o,c);w!=k&&l.push({from:f.from,to:f.from+w.length,insert:k})}return l.length?[n,{changes:l,sequential:!0}]:n})}const ye=v.define(),ve=new y;function mn(n){let t=n.firstChild,e=n.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?n.to:e.from}:null}function Te(n,t,e){let r=m(n);if(r.length<e)return null;let s=r.resolveStack(e,1),i=null;for(let o=s;o;o=o.next){let a=o.node;if(a.to<=e||a.from>e)continue;if(i&&a.from<t)break;let l=a.type.prop(ve);if(l&&(a.to<r.length-50||r.length==n.doc.length||!xe(a))){let h=l(a,n);h&&h.from<=e&&h.from>=t&&h.to>e&&(i=h)}}return i}function xe(n){let t=n.lastChild;return t&&t.to==n.to&&t.type.isError}function B(n,t,e){for(let r of n.facet(ye)){let s=r(n,t,e);if(s)return s}return Te(n,t,e)}function Wt(n,t){let e=t.mapPos(n.from,1),r=t.mapPos(n.to,-1);return e>=r?void 0:{from:e,to:r}}const E=z.define({map:Wt}),D=z.define({map:Wt});function it(n){let t=[];for(let{head:e}of n.state.selection.ranges)t.some(r=>r.from<=e&&r.to>=e)||t.push(n.lineBlockAt(e));return t}const x=St.define({create(){return p.none},update(n,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((e,r)=>n=pt(n,e,r)),n=n.map(t.changes);for(let e of t.effects)if(e.is(E)&&!Se(n,e.value.from,e.value.to)){let{preparePlaceholder:r}=t.state.facet(lt),s=r?p.replace({widget:new Oe(r(t.state,e.value))}):gt;n=n.update({add:[s.range(e.value.from,e.value.to)]})}else e.is(D)&&(n=n.update({filter:(r,s)=>e.value.from!=r||e.value.to!=s,filterFrom:e.value.from,filterTo:e.value.to}));return t.selection&&(n=pt(n,t.selection.main.head)),n},provide:n=>b.decorations.from(n),toJSON(n,t){let e=[];return n.between(0,t.doc.length,(r,s)=>{e.push(r,s)}),e},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let e=0;e<n.length;){let r=n[e++],s=n[e++];if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");t.push(gt.range(r,s))}return p.set(t,!0)}});function pt(n,t,e=t){let r=!1;return n.between(t,e,(s,i)=>{s<e&&i>t&&(r=!0)}),r?n.update({filterFrom:t,filterTo:e,filter:(s,i)=>s>=e||i<=t}):n}function kn(n){return n.field(x,!1)||xt.empty}function L(n,t,e){var r;let s=null;return(r=n.field(x,!1))===null||r===void 0||r.between(t,e,(i,o)=>{(!s||s.from>i)&&(s={from:i,to:o})}),s}function Se(n,t,e){let r=!1;return n.between(t,t,(s,i)=>{s==t&&i==e&&(r=!0)}),r}function ot(n,t){return n.field(x,!1)?t:t.concat(z.appendConfig.of(Ut()))}const Pe=n=>{for(let t of it(n)){let e=B(n.state,t.from,t.to);if(e)return n.dispatch({effects:ot(n.state,[E.of(e),$(n,e)])}),!0}return!1},Ce=n=>{if(!n.state.field(x,!1))return!1;let t=[];for(let e of it(n)){let r=L(n.state,e.from,e.to);r&&t.push(D.of(r),$(n,r,!1))}return t.length&&n.dispatch({effects:t}),t.length>0};function $(n,t,e=!0){let r=n.state.doc.lineAt(t.from).number,s=n.state.doc.lineAt(t.to).number;return b.announce.of(`${n.state.phrase(e?"Folded lines":"Unfolded lines")} ${r} ${n.state.phrase("to")} ${s}.`)}const Ae=n=>{let{state:t}=n,e=[];for(let r=0;r<t.doc.length;){let s=n.lineBlockAt(r),i=B(t,s.from,s.to);i&&e.push(E.of(i)),r=(i?n.lineBlockAt(i.to):s).to+1}return e.length&&n.dispatch({effects:ot(n.state,e)}),!!e.length},Ie=n=>{let t=n.state.field(x,!1);if(!t||!t.size)return!1;let e=[];return t.between(0,n.state.doc.length,(r,s)=>{e.push(D.of({from:r,to:s}))}),n.dispatch({effects:e}),!0};function De(n,t){for(let e=t;;){let r=B(n.state,e.from,e.to);if(r&&r.to>t.from)return r;if(!e.from)return null;e=n.lineBlockAt(e.from-1)}}const bn=n=>{let t=[];for(let e of it(n)){let r=L(n.state,e.from,e.to);if(r)t.push(D.of(r),$(n,r,!1));else{let s=De(n,e);s&&t.push(E.of(s),$(n,s))}}return t.length>0&&n.dispatch({effects:ot(n.state,t)}),!!t.length},wn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Pe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Ce},{key:"Ctrl-Alt-[",run:Ae},{key:"Ctrl-Alt-]",run:Ie}],Me={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},lt=v.define({combine(n){return Ct(n,Me)}});function Ut(n){let t=[x,Le];return n&&t.push(lt.of(n)),t}function Ht(n,t){let{state:e}=n,r=e.facet(lt),s=o=>{let a=n.lineBlockAt(n.posAtDOM(o.target)),l=L(n.state,a.from,a.to);l&&n.dispatch({effects:D.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(n,s,t);let i=document.createElement("span");return i.textContent=r.placeholderText,i.setAttribute("aria-label",e.phrase("folded code")),i.title=e.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=s,i}const gt=p.replace({widget:new class extends At{toDOM(n){return Ht(n,null)}}});class Oe extends At{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ht(t,this.value)}}const Be={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class K extends le{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function yn(n={}){let t={...Be,...n},e=new K(t,!0),r=new K(t,!1),s=R.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(T)!=o.state.facet(T)||o.startState.field(x,!1)!=o.state.field(x,!1)||m(o.startState)!=m(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new nt;for(let l of o.viewportLineBlocks){let h=L(o.state,l.from,l.to)?r:B(o.state,l.from,l.to)?e:null;h&&a.add(l.from,l.from,h)}return a.finish()}}),{domEventHandlers:i}=t;return[s,oe({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(s))===null||a===void 0?void 0:a.markers)||xt.empty},initialSpacer(){return new K(t,!1)},domEventHandlers:{...i,click:(o,a,l)=>{if(i.click&&i.click(o,a,l))return!0;let h=L(o.state,a.from,a.to);if(h)return o.dispatch({effects:D.of(h)}),!0;let f=B(o.state,a.from,a.to);return f?(o.dispatch({effects:E.of(f)}),!0):!1}}}),Ut()]}const Le=b.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class G{constructor(t,e){this.specs=t;let r;function s(a){let l=ut.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const i=typeof e.all=="string"?e.all:e.all?s(e.all):void 0,o=e.scope;this.scope=o instanceof d?a=>a.prop(S)==o.data:o?a=>a==o:void 0,this.style=ee(t.map(a=>({tag:a.tag,class:a.class||s(Object.assign({},a,{tag:null}))})),{all:i}).style,this.module=r?new ut(r):null,this.themeType=e.themeType}static define(t,e){return new G(t,e||{})}}const Y=v.define(),Vt=v.define({combine(n){return n.length?[n[0]]:null}});function U(n){let t=n.facet(Y);return t.length?t:n.facet(Vt)}function vn(n,t){let e=[Re],r;return n instanceof G&&(n.module&&e.push(b.styleModule.of(n.module)),r=n.themeType),t?.fallback?e.push(Vt.of(n)):r?e.push(Y.computeN([b.darkTheme],s=>s.facet(b.darkTheme)==(r=="dark")?[n]:[])):e.push(Y.of(n)),e}function Tn(n,t,e){let r=U(n),s=null;if(r){for(let i of r)if(!i.scope||e&&i.scope(e)){let o=i.style(t);o&&(s=s?s+" "+o:o)}}return s}class Ne{constructor(t){this.markCache=Object.create(null),this.tree=m(t.state),this.decorations=this.buildDeco(t,U(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=m(t.state),r=U(t.state),s=r!=U(t.startState),{viewport:i}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<i.to&&!s&&e.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=i.to)}buildDeco(t,e){if(!e||!this.tree.length)return p.none;let r=new nt;for(let{from:s,to:i}of t.visibleRanges)se(this.tree,e,(o,a,l)=>{r.add(o,a,this.markCache[l]||(this.markCache[l]=p.mark({class:l})))},s,i);return r.finish()}}const Re=Pt.high(R.fromClass(Ne,{decorations:n=>n.decorations})),xn=G.define([{tag:u.meta,color:"#404740"},{tag:u.link,textDecoration:"underline"},{tag:u.heading,textDecoration:"underline",fontWeight:"bold"},{tag:u.emphasis,fontStyle:"italic"},{tag:u.strong,fontWeight:"bold"},{tag:u.strikethrough,textDecoration:"line-through"},{tag:u.keyword,color:"#708"},{tag:[u.atom,u.bool,u.url,u.contentSeparator,u.labelName],color:"#219"},{tag:[u.literal,u.inserted],color:"#164"},{tag:[u.string,u.deleted],color:"#a11"},{tag:[u.regexp,u.escape,u.special(u.string)],color:"#e40"},{tag:u.definition(u.variableName),color:"#00f"},{tag:u.local(u.variableName),color:"#30a"},{tag:[u.typeName,u.namespace],color:"#085"},{tag:u.className,color:"#167"},{tag:[u.special(u.variableName),u.macroName],color:"#256"},{tag:u.definition(u.propertyName),color:"#00c"},{tag:u.comment,color:"#940"},{tag:u.invalid,color:"#f00"}]),Ee=b.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),$t=1e4,jt="()[]{}",zt=v.define({combine(n){return Ct(n,{afterCursor:!0,brackets:jt,maxScanDistance:$t,renderMatch:Ue})}}),Fe=p.mark({class:"cm-matchingBracket"}),We=p.mark({class:"cm-nonmatchingBracket"});function Ue(n){let t=[],e=n.matched?Fe:We;return t.push(e.range(n.start.from,n.start.to)),n.end&&t.push(e.range(n.end.from,n.end.to)),t}function mt(n){let t=[],e=n.facet(zt);for(let r of n.selection.ranges){if(!r.empty)continue;let s=F(n,r.head,-1,e)||r.head>0&&F(n,r.head-1,1,e)||e.afterCursor&&(F(n,r.head,1,e)||r.head<n.doc.length&&F(n,r.head+1,-1,e));s&&(t=t.concat(e.renderMatch(s,n)))}return p.set(t,!0)}const He=R.fromClass(class{constructor(n){this.paused=!1,this.decorations=mt(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=mt(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),Ve=[He,Ee];function Sn(n={}){return[zt.of(n),Ve]}const $e=new y;function Z(n,t,e){let r=n.prop(t<0?y.openedBy:y.closedBy);if(r)return r;if(n.name.length==1){let s=e.indexOf(n.name);if(s>-1&&s%2==(t<0?1:0))return[e[s+t]]}return null}function tt(n){let t=n.type.prop($e);return t?t(n.node):n}function F(n,t,e,r={}){let s=r.maxScanDistance||$t,i=r.brackets||jt,o=m(n),a=o.resolveInner(t,e);for(let l=a;l;l=l.parent){let h=Z(l.type,e,i);if(h&&l.from<l.to){let f=tt(l);if(f&&(e>0?t>=f.from&&t<f.to:t>f.from&&t<=f.to))return je(n,t,e,l,f,h,i)}}return ze(n,t,e,o,a.type,s,i)}function je(n,t,e,r,s,i,o){let a=r.parent,l={from:s.from,to:s.to},h=0,f=a?.cursor();if(f&&(e<0?f.childBefore(r.from):f.childAfter(r.to)))do if(e<0?f.to<=r.from:f.from>=r.to){if(h==0&&i.indexOf(f.type.name)>-1&&f.from<f.to){let c=tt(f);return{start:l,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(Z(f.type,e,o))h++;else if(Z(f.type,-e,o)){if(h==0){let c=tt(f);return{start:l,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(e<0?f.prevSibling():f.nextSibling());return{start:l,matched:!1}}function ze(n,t,e,r,s,i,o){let a=e<0?n.sliceDoc(t-1,t):n.sliceDoc(t,t+1),l=o.indexOf(a);if(l<0||l%2==0!=e>0)return null;let h={from:e<0?t-1:t,to:e>0?t+1:t},f=n.doc.iterRange(t,e>0?n.doc.length:0),c=0;for(let w=0;!f.next().done&&w<=i;){let k=f.value;e<0&&(w+=k.length);let P=t+w*e;for(let C=e>0?0:k.length-1,te=e>0?k.length:-1;C!=te;C+=e){let q=o.indexOf(k[C]);if(!(q<0||r.resolveInner(P+C,1).type!=s))if(q%2==0==e>0)c++;else{if(c==1)return{start:h,end:{from:P+C,to:P+C+1},matched:q>>1==l>>1};c--}}e>0&&(w+=k.length)}return f.done?{start:h,matched:!1}:null}function kt(n,t,e,r=0,s=0){t==null&&(t=n.search(/[^\s\u00a0]/),t==-1&&(t=n.length));let i=s;for(let o=r;o<t;o++)n.charCodeAt(o)==9?i+=e-i%e:i++;return i}class Gt{constructor(t,e,r,s){this.string=t,this.tabSize=e,this.indentUnit=r,this.overrideIndent=s,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e=this.string.charAt(this.pos),r;if(typeof t=="string"?r=e==t:r=e&&(t instanceof RegExp?t.test(e):t(e)),r)return++this.pos,e}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=kt(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:kt(this.string,null,this.tabSize)}match(t,e,r){if(typeof t=="string"){let s=o=>r?o.toLowerCase():o,i=this.string.substr(this.pos,t.length);return s(i)==s(t)?(e!==!1&&(this.pos+=t.length),!0):null}else{let s=this.string.slice(this.pos).match(t);return s&&s.index>0?null:(s&&e!==!1&&(this.pos+=s[0].length),s)}}current(){return this.string.slice(this.start,this.pos)}}function Ge(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||qe,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||ht,mergeTokens:n.mergeTokens!==!1}}function qe(n){if(typeof n!="object")return n;let t={};for(let e in n){let r=n[e];t[e]=r instanceof Array?r.slice():r}return t}const bt=new WeakMap;class qt extends d{constructor(t){let e=It(t.languageData),r=Ge(t),s,i=new class extends Tt{createParse(o,a,l){return new _e(s,o,a,l)}};super(e,i,[],t.name),this.topNode=Xe(e,this),s=this,this.streamParser=r,this.stateAfter=new y({perNode:!0}),this.tokenTable=t.tokenTable?new Qt(r.tokenTable):Qe}static define(t){return new qt(t)}getIndent(t){let e,{overrideIndentation:r}=t.options;r&&(e=bt.get(t.state),e!=null&&e<t.pos-1e4&&(e=void 0));let s=at(this,t.node.tree,t.node.from,t.node.from,e??t.pos),i,o;if(s?(o=s.state,i=s.pos+1):(o=this.streamParser.startState(t.unit),i=t.node.from),t.pos-i>1e4)return null;for(;i<t.pos;){let l=t.state.doc.lineAt(i),h=Math.min(t.pos,l.to);if(l.length){let f=r?r(l.from):-1,c=new Gt(l.text,t.state.tabSize,t.unit,f<0?void 0:f);for(;c.pos<h-l.from;)_t(this.streamParser.token,c,o)}else this.streamParser.blankLine(o,t.unit);if(h==t.pos)break;i=l.to+1}let a=t.lineAt(t.pos);return r&&e==null&&bt.set(t.state,a.from),this.streamParser.indent(o,/^\s*(.*)/.exec(a.text)[1],t)}get allowsNesting(){return!1}}function at(n,t,e,r,s){let i=e>=r&&e+t.length<=s&&t.prop(n.stateAfter);if(i)return{state:n.streamParser.copyState(i),pos:e+t.length};for(let o=t.children.length-1;o>=0;o--){let a=t.children[o],l=e+t.positions[o],h=a instanceof g&&l<s&&at(n,a,l,r,s);if(h)return h}return null}function Jt(n,t,e,r,s){if(s&&e<=0&&r>=t.length)return t;!s&&e==0&&t.type==n.topNode&&(s=!0);for(let i=t.children.length-1;i>=0;i--){let o=t.positions[i],a=t.children[i],l;if(o<r&&a instanceof g){if(!(l=Jt(n,a,e-o,r-o,s)))break;return s?new g(t.type,t.children.slice(0,i).concat(l),t.positions.slice(0,i+1),o+l.length):l}}return null}function Je(n,t,e,r,s){for(let i of t){let o=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),l=o<=e&&a>e&&at(n,i.tree,0-i.offset,e,a),h;if(l&&l.pos<=r&&(h=Jt(n,i.tree,e+i.offset,l.pos+i.offset,!1)))return{state:l.state,tree:h}}return{state:n.streamParser.startState(s?V(s):4),tree:g.empty}}class _e{constructor(t,e,r,s){this.lang=t,this.input=e,this.fragments=r,this.ranges=s,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=s[s.length-1].to;let i=A.get(),o=s[0].from,{state:a,tree:l}=Je(t,r,o,this.to,i?.state);this.state=a,this.parsedPos=this.chunkStart=o+l.length;for(let h=0;h<l.children.length;h++)this.chunks.push(l.children[h]),this.chunkPos.push(l.positions[h]);i&&this.parsedPos<i.viewport.from-1e5&&s.some(h=>h.from<=i.viewport.from&&h.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(V(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let t=A.get(),e=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(e,this.chunkStart+512);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)e==`
2
2
  `&&(e="");else{let r=e.indexOf(`
3
3
  `);r>-1&&(e=e.slice(0,r))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),r=t+e.length;for(let s=this.rangeIndex;;){let i=this.ranges[s].to;if(i>=r||(e=e.slice(0,i-(r-e.length)),s++,s==this.ranges.length))break;let o=this.ranges[s].from,a=this.lineAfter(o);e+=a,r=o+a.length}return{line:e,end:r}}skipGapsTo(t,e,r){for(;;){let s=this.ranges[this.rangeIndex].to,i=t+e;if(r>0?s>i:s>=i)break;let o=this.ranges[++this.rangeIndex].from;e+=o-s}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,r,s){let i=4;if(this.ranges.length>1){s=this.skipGapsTo(e,s,1),e+=s;let a=this.chunk.length;s=this.skipGapsTo(r,s,-1),r+=s,i+=this.chunk.length-a}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==e?this.chunk[o+2]=r:this.chunk.push(t,e,r,i),s}parseLine(t){let{line:e,end:r}=this.nextLine(),s=0,{streamParser:i}=this.lang,o=new Gt(e,t?t.state.tabSize:4,t?V(t.state):2);if(o.eol())i.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let a=_t(i.token,o,this.state);if(a&&(s=this.emitToken(this.lang.tokenTable.resolve(a),this.parsedPos+o.start,this.parsedPos+o.pos,s)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=g.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Ke,topID:0,maxBufferLength:512,reused:this.chunkReused});t=new g(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new g(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function _t(n,t,e){t.start=t.pos;for(let r=0;r<10;r++){let s=n(t,e);if(t.pos>t.start)return s}throw new Error("Stream parser failed to advance stream.")}const ht=Object.create(null),N=[j.none],Ke=new ne(N),wt=[],yt=Object.create(null),Kt=Object.create(null);for(let[n,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Kt[n]=Xt(ht,t);class Qt{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Kt)}resolve(t){return t?this.table[t]||(this.table[t]=Xt(this.extra,t)):0}}const Qe=new Qt(ht);function Q(n,t){wt.indexOf(n)>-1||(wt.push(n),console.warn(t))}function Xt(n,t){let e=[];for(let a of t.split(" ")){let l=[];for(let h of a.split(".")){let f=n[h]||u[h];f?typeof f=="function"?l.length?l=l.map(f):Q(h,`Modifier ${h} used at start of tag`):l.length?Q(h,`Tag ${h} used as modifier`):l=Array.isArray(f)?f:[f]:Q(h,`Unknown highlighting tag ${h}`)}for(let h of l)e.push(h)}if(!e.length)return 0;let r=t.replace(/ /g,"_"),s=r+" "+e.map(a=>a.id),i=yt[s];if(i)return i.id;let o=yt[s]=j.define({id:N.length,name:r,props:[re({[r]:e})]});return N.push(o),o.id}function Xe(n,t){let e=j.define({id:N.length,name:"Document",props:[S.add(()=>n),Rt.add(()=>r=>t.getIndent(r))],top:!0});return N.push(e),e}function Yt(n){return n.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(n)}function Zt(n){for(let t=n.iter();!t.next().done;)if(Yt(t.value))return!0;return!1}function Ye(n){let t=!1;return n.iterChanges((e,r,s,i,o)=>{!t&&Zt(o)&&(t=!0)}),t}const et=v.define({combine:n=>n.some(t=>t)});function Pn(n={}){let t=[Ze];return n.alwaysIsolate&&t.push(et.of(!0)),t}const Ze=R.fromClass(class{constructor(n){this.always=n.state.facet(et)||n.textDirection!=H.LTR||n.state.facet(b.perLineTextDirection),this.hasRTL=!this.always&&Zt(n.state.doc),this.tree=m(n.state),this.decorations=this.always||this.hasRTL?vt(n,this.tree,this.always):p.none}update(n){let t=n.state.facet(et)||n.view.textDirection!=H.LTR||n.state.facet(b.perLineTextDirection);if(!t&&!this.hasRTL&&Ye(n.changes)&&(this.hasRTL=!0),!t&&!this.hasRTL)return;let e=m(n.state);(t!=this.always||e!=this.tree||n.docChanged||n.viewportChanged)&&(this.tree=e,this.always=t,this.decorations=vt(n.view,e,t))}},{provide:n=>{function t(e){var r,s;return(s=(r=e.plugin(n))===null||r===void 0?void 0:r.decorations)!==null&&s!==void 0?s:p.none}return[b.outerDecorations.of(t),Pt.lowest(b.bidiIsolatedRanges.of(t))]}});function vt(n,t,e){let r=new nt,s=n.visibleRanges;e||(s=tn(s,n.state.doc));for(let{from:i,to:o}of s)t.iterate({enter:a=>{let l=a.type.prop(y.isolate);l&&r.add(a.from,a.to,en[l])},from:i,to:o});return r.finish()}function tn(n,t){let e=t.iter(),r=0,s=[],i=null;for(let{from:o,to:a}of n)if(!(i&&i.to>o&&(o=i.to,o>=a)))for(r+e.value.length<o&&(e.next(o-(r+e.value.length)),r=o);;){let l=r,h=r+e.value.length;if(!e.lineBreak&&Yt(e.value)&&(i&&i.to>l-10?i.to=Math.min(a,h):s.push(i={from:l,to:Math.min(a,h)})),h>=a)break;r=h,e.next()}return s}const en={rtl:p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:H.RTL}),ltr:p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:H.LTR}),auto:p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};export{ue as DocInput,G as HighlightStyle,rt as IndentContext,X as LRLanguage,d as Language,Ot as LanguageDescription,fn as LanguageSupport,A as ParseContext,qt as StreamLanguage,Gt as StringStream,st as TreeIndentContext,Pn as bidiIsolates,Sn as bracketMatching,$e as bracketMatchingHandle,Ut as codeFolding,pn as continuedIndent,xn as defaultHighlightStyle,It as defineLanguageFacet,cn as delimitedIndent,fe as ensureSyntaxTree,dn as flatIndent,Ae as foldAll,Pe as foldCode,E as foldEffect,yn as foldGutter,mn as foldInside,wn as foldKeymap,ve as foldNodeProp,ye as foldService,x as foldState,B as foldable,kn as foldedRanges,ln as forceParsing,V as getIndentUnit,Nt as getIndentation,Tn as highlightingFor,Rt as indentNodeProp,gn as indentOnInput,un as indentRange,ce as indentService,Lt as indentString,Bt as indentUnit,T as language,S as languageDataProp,F as matchBrackets,he as sublanguageProp,vn as syntaxHighlighting,an as syntaxParserRunning,m as syntaxTree,on as syntaxTreeAvailable,bn as toggleFold,Ie as unfoldAll,Ce as unfoldCode,D as unfoldEffect};
@@ -1,4 +1,4 @@
1
- import{b as ut,c as V,a as v,f as I,j as es,e as ts,g as ss,s as $e,t as rs}from"./Cs_ROD7H.js";import{I as ie,h as dt,a as gt,a9 as ns,bk as as,e as ft,C as is,w as ls,b6 as os,b3 as cs,c as hs,aA as ps,aB as us,bl as ds,x as Ge,f as X,y as St,z as Rt,A as Tt,D as j,B as R,G as _,F as ze,L as te,a7 as Fe,m as p,K as S,aj as Ue,R as gs,S as Ve,j as fs,bm as ks,T as Pe}from"./BeBar3OL.js";import{g as zt,e as xs,w as ms}from"./DP09rP34.js";import{l as xe,s as me,p as bs,i as D,b as ws}from"./xBRYfpah.js";import{n as C,e as _e,i as Se}from"./DEzvDbcy.js";import{B as ee,b as vs}from"./BuOTIbJu.js";import"./CQCkXCml.js";import{I as be,s as we,X as ys,T as $s,a as _s}from"./Bt3IOBgW.js";import{i as Ss,g as Rs}from"./C_8lGlxx.js";function kt(r,e,s=!1,n=!1,t=!1){var i=r,a="";ie(()=>{var o=ns;if(a===(a=e()??"")){dt&&gt();return}if(o.nodes!==null&&(as(o.nodes.start,o.nodes.end),o.nodes=null),a!==""){if(dt){ft.data;for(var l=gt(),h=l;l!==null&&(l.nodeType!==is||l.data!=="");)h=l,l=ls(l);if(l===null)throw os(),cs;ut(ft,h),i=hs(l);return}var c=s?us:n?ds:void 0,d=ps(s?"svg":n?"math":"template",c);d.innerHTML=a;var g=s||n?d:d.content;if(ut(Ge(g),g.lastChild),s||n)for(;Ge(g);)i.before(Ge(g));else i.before(g)}})}function xt(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["path",{d:"M3 5h.01"}],["path",{d:"M3 12h.01"}],["path",{d:"M3 19h.01"}],["path",{d:"M8 5h13"}],["path",{d:"M8 12h13"}],["path",{d:"M8 19h13"}]];be(r,me({name:"list"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function mt(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["circle",{cx:"18",cy:"5",r:"3"}],["circle",{cx:"6",cy:"12",r:"3"}],["circle",{cx:"18",cy:"19",r:"3"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49"}]];be(r,me({name:"share-2"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function Ts(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"}]];be(r,me({name:"message-square"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}var zs=I('<span class="toggle-btn active svelte-r6dy5f" aria-current="page"><!><span class="toggle-label">Details</span></span>'),As=I('<a class="toggle-btn svelte-r6dy5f"><!><span class="toggle-label">Details</span></a>'),Is=I('<span class="toggle-btn active svelte-r6dy5f" aria-current="page"><!><span class="toggle-label">Graph</span></span>'),Ps=I('<a class="toggle-btn svelte-r6dy5f" href="/graph"><!><span class="toggle-label">Graph</span></a>'),Cs=I('<div class="view-toolbar svelte-r6dy5f"><div></div> <div class="view-toggles svelte-r6dy5f"><!> <!></div> <div class="toolbar-right svelte-r6dy5f"><!> <!></div></div>');function Jr(r,e){St(e,!0);let s=bs(e,"activeView",3,"entity");const n=Rt("chat");var t=Cs(),i=j(R(t),2),a=R(i);{var o=b=>{var w=zs(),u=R(w);xt(u,{size:14}),ze(),_(w),v(b,w)},l=b=>{var w=As(),u=R(w);xt(u,{size:14}),ze(),_(w),ie(()=>zt(w,"href",C.entityPath??"/")),v(b,w)};D(a,b=>{s()==="entity"?b(o):b(l,!1)})}var h=j(a,2);{var c=b=>{var w=Is(),u=R(w);mt(u,{size:14}),ze(),_(w),v(b,w)},d=b=>{var w=Ps(),u=R(w);mt(u,{size:14}),ze(),_(w),v(b,w)};D(h,b=>{s()==="graph"?b(c):b(d,!1)})}_(i);var g=j(i,2),T=R(g);{var m=b=>{var w=V(),u=X(w);xs(u,()=>e.right),v(b,w)};D(T,b=>{e.right&&b(m)})}var L=j(T,2);{var O=b=>{ee(b,{variant:"accent",size:"icon",class:"chat-toggle",title:"Open Agent",get onclick(){return n.toggle},children:(w,u)=>{Ts(w,{size:14})},$$slots:{default:!0}})};D(L,b=>{n.open||b(O)})}_(g),_(t),v(r,t),Tt()}function Es(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["circle",{cx:"12",cy:"12",r:"10"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1"}]];be(r,me({name:"circle-stop"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function Ls(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"}]];be(r,me({name:"square-pen"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function Bs(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];be(r,me({name:"clock"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function tt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ue=tt();function At(r){ue=r}var he={exec:()=>null};function x(r,e=""){let s=typeof r=="string"?r:r.source,n={replace:(t,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(B.caret,"$1"),s=s.replace(t,a),n},getRegex:()=>new RegExp(s,e)};return n}var qs=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),B={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}#`),htmlBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}>`)},Ms=/^(?:[ \t]*(?:\n|$))+/,Ns=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,js=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ie=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ds=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,st=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,It=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Pt=x(It).replace(/bull/g,st).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Os=x(It).replace(/bull/g,st).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),rt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Zs=/^[^\n]+/,nt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Hs=x(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",nt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qs=x(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,st).getRegex(),Ne="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",at=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ws=x("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",at).replace("tag",Ne).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ct=x(rt).replace("hr",Ie).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ne).getRegex(),Gs=x(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ct).getRegex(),it={blockquote:Gs,code:Ns,def:Hs,fences:js,heading:Ds,hr:Ie,html:Ws,lheading:Pt,list:Qs,newline:Ms,paragraph:Ct,table:he,text:Zs},bt=x("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ie).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ne).getRegex(),Fs={...it,lheading:Os,table:bt,paragraph:x(rt).replace("hr",Ie).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",bt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ne).getRegex()},Us={...it,html:x(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",at).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:he,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:x(rt).replace("hr",Ie).replace("heading",` *#{1,6} *[^
1
+ import{b as ut,c as V,a as v,f as I,j as es,e as ts,g as ss,s as $e,t as rs}from"./Cs_ROD7H.js";import{I as ie,h as dt,a as gt,a9 as ns,bk as as,e as ft,C as is,w as ls,b6 as os,b3 as cs,c as hs,aA as ps,aB as us,bl as ds,x as Ge,f as X,y as St,z as Rt,A as Tt,D as j,B as R,G as _,F as ze,L as te,a7 as Fe,m as p,K as S,aj as Ue,R as gs,S as Ve,j as fs,bm as ks,T as Pe}from"./BeBar3OL.js";import{g as zt,e as xs,w as ms}from"./DP09rP34.js";import{l as xe,s as me,p as bs,i as D,b as ws}from"./xBRYfpah.js";import{n as C,e as _e,i as Se}from"./Dkz6p8Jo.js";import{B as ee,b as vs}from"./BuOTIbJu.js";import"./CQCkXCml.js";import{I as be,s as we,X as ys,T as $s,a as _s}from"./BqzGUHtY.js";import{i as Ss,g as Rs}from"./B1Cz8BMn.js";function kt(r,e,s=!1,n=!1,t=!1){var i=r,a="";ie(()=>{var o=ns;if(a===(a=e()??"")){dt&&gt();return}if(o.nodes!==null&&(as(o.nodes.start,o.nodes.end),o.nodes=null),a!==""){if(dt){ft.data;for(var l=gt(),h=l;l!==null&&(l.nodeType!==is||l.data!=="");)h=l,l=ls(l);if(l===null)throw os(),cs;ut(ft,h),i=hs(l);return}var c=s?us:n?ds:void 0,d=ps(s?"svg":n?"math":"template",c);d.innerHTML=a;var g=s||n?d:d.content;if(ut(Ge(g),g.lastChild),s||n)for(;Ge(g);)i.before(Ge(g));else i.before(g)}})}function xt(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["path",{d:"M3 5h.01"}],["path",{d:"M3 12h.01"}],["path",{d:"M3 19h.01"}],["path",{d:"M8 5h13"}],["path",{d:"M8 12h13"}],["path",{d:"M8 19h13"}]];be(r,me({name:"list"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function mt(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["circle",{cx:"18",cy:"5",r:"3"}],["circle",{cx:"6",cy:"12",r:"3"}],["circle",{cx:"18",cy:"19",r:"3"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49"}]];be(r,me({name:"share-2"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function Ts(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"}]];be(r,me({name:"message-square"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}var zs=I('<span class="toggle-btn active svelte-r6dy5f" aria-current="page"><!><span class="toggle-label">Details</span></span>'),As=I('<a class="toggle-btn svelte-r6dy5f"><!><span class="toggle-label">Details</span></a>'),Is=I('<span class="toggle-btn active svelte-r6dy5f" aria-current="page"><!><span class="toggle-label">Graph</span></span>'),Ps=I('<a class="toggle-btn svelte-r6dy5f" href="/graph"><!><span class="toggle-label">Graph</span></a>'),Cs=I('<div class="view-toolbar svelte-r6dy5f"><div></div> <div class="view-toggles svelte-r6dy5f"><!> <!></div> <div class="toolbar-right svelte-r6dy5f"><!> <!></div></div>');function Jr(r,e){St(e,!0);let s=bs(e,"activeView",3,"entity");const n=Rt("chat");var t=Cs(),i=j(R(t),2),a=R(i);{var o=b=>{var w=zs(),u=R(w);xt(u,{size:14}),ze(),_(w),v(b,w)},l=b=>{var w=As(),u=R(w);xt(u,{size:14}),ze(),_(w),ie(()=>zt(w,"href",C.entityPath??"/")),v(b,w)};D(a,b=>{s()==="entity"?b(o):b(l,!1)})}var h=j(a,2);{var c=b=>{var w=Is(),u=R(w);mt(u,{size:14}),ze(),_(w),v(b,w)},d=b=>{var w=Ps(),u=R(w);mt(u,{size:14}),ze(),_(w),v(b,w)};D(h,b=>{s()==="graph"?b(c):b(d,!1)})}_(i);var g=j(i,2),T=R(g);{var m=b=>{var w=V(),u=X(w);xs(u,()=>e.right),v(b,w)};D(T,b=>{e.right&&b(m)})}var L=j(T,2);{var O=b=>{ee(b,{variant:"accent",size:"icon",class:"chat-toggle",title:"Open Agent",get onclick(){return n.toggle},children:(w,u)=>{Ts(w,{size:14})},$$slots:{default:!0}})};D(L,b=>{n.open||b(O)})}_(g),_(t),v(r,t),Tt()}function Es(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["circle",{cx:"12",cy:"12",r:"10"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1"}]];be(r,me({name:"circle-stop"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function Ls(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"}]];be(r,me({name:"square-pen"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function Bs(r,e){const s=xe(e,["children","$$slots","$$events","$$legacy"]);const n=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];be(r,me({name:"clock"},()=>s,{get iconNode(){return n},children:(t,i)=>{var a=V(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function tt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ue=tt();function At(r){ue=r}var he={exec:()=>null};function x(r,e=""){let s=typeof r=="string"?r:r.source,n={replace:(t,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(B.caret,"$1"),s=s.replace(t,a),n},getRegex:()=>new RegExp(s,e)};return n}var qs=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),B={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}#`),htmlBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}>`)},Ms=/^(?:[ \t]*(?:\n|$))+/,Ns=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,js=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ie=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ds=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,st=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,It=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Pt=x(It).replace(/bull/g,st).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Os=x(It).replace(/bull/g,st).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),rt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Zs=/^[^\n]+/,nt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Hs=x(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",nt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qs=x(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,st).getRegex(),Ne="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",at=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ws=x("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",at).replace("tag",Ne).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ct=x(rt).replace("hr",Ie).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ne).getRegex(),Gs=x(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ct).getRegex(),it={blockquote:Gs,code:Ns,def:Hs,fences:js,heading:Ds,hr:Ie,html:Ws,lheading:Pt,list:Qs,newline:Ms,paragraph:Ct,table:he,text:Zs},bt=x("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ie).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ne).getRegex(),Fs={...it,lheading:Os,table:bt,paragraph:x(rt).replace("hr",Ie).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",bt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ne).getRegex()},Us={...it,html:x(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",at).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:he,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:x(rt).replace("hr",Ie).replace("heading",` *#{1,6} *[^
2
2
  ]`).replace("lheading",Pt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Vs=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Xs=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Et=/^( {2,}|\\)\n(?!\s*$)/,Js=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,je=/[\p{P}\p{S}]/u,lt=/[\s\p{P}\p{S}]/u,Lt=/[^\s\p{P}\p{S}]/u,Ks=x(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,lt).getRegex(),Bt=/(?!~)[\p{P}\p{S}]/u,Ys=/(?!~)[\s\p{P}\p{S}]/u,er=/(?:[^\s\p{P}\p{S}]|~)/u,qt=/(?![*_])[\p{P}\p{S}]/u,tr=/(?![*_])[\s\p{P}\p{S}]/u,sr=/(?:[^\s\p{P}\p{S}]|[*_])/u,rr=x(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",qs?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Mt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,nr=x(Mt,"u").replace(/punct/g,je).getRegex(),ar=x(Mt,"u").replace(/punct/g,Bt).getRegex(),Nt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ir=x(Nt,"gu").replace(/notPunctSpace/g,Lt).replace(/punctSpace/g,lt).replace(/punct/g,je).getRegex(),lr=x(Nt,"gu").replace(/notPunctSpace/g,er).replace(/punctSpace/g,Ys).replace(/punct/g,Bt).getRegex(),or=x("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Lt).replace(/punctSpace/g,lt).replace(/punct/g,je).getRegex(),cr=x(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,qt).getRegex(),hr="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",pr=x(hr,"gu").replace(/notPunctSpace/g,sr).replace(/punctSpace/g,tr).replace(/punct/g,qt).getRegex(),ur=x(/\\(punct)/,"gu").replace(/punct/g,je).getRegex(),dr=x(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),gr=x(at).replace("(?:-->|$)","-->").getRegex(),fr=x("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",gr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Be=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,kr=x(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Be).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),jt=x(/^!?\[(label)\]\[(ref)\]/).replace("label",Be).replace("ref",nt).getRegex(),Dt=x(/^!?\[(ref)\](?:\[\])?/).replace("ref",nt).getRegex(),xr=x("reflink|nolink(?!\\()","g").replace("reflink",jt).replace("nolink",Dt).getRegex(),wt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ot={_backpedal:he,anyPunctuation:ur,autolink:dr,blockSkip:rr,br:Et,code:Xs,del:he,delLDelim:he,delRDelim:he,emStrongLDelim:nr,emStrongRDelimAst:ir,emStrongRDelimUnd:or,escape:Vs,link:kr,nolink:Dt,punctuation:Ks,reflink:jt,reflinkSearch:xr,tag:fr,text:Js,url:he},mr={...ot,link:x(/^!?\[(label)\]\((.*?)\)/).replace("label",Be).getRegex(),reflink:x(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Be).getRegex()},Xe={...ot,emStrongRDelimAst:lr,emStrongLDelim:ar,delLDelim:cr,delRDelim:pr,url:x(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",wt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:x(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",wt).getRegex()},br={...Xe,br:x(Et).replace("{2,}","*").getRegex(),text:x(Xe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ce={normal:it,gfm:Fs,pedantic:Us},Re={normal:ot,gfm:Xe,breaks:br,pedantic:mr},wr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},vt=r=>wr[r];function U(r,e){if(e){if(B.escapeTest.test(r))return r.replace(B.escapeReplace,vt)}else if(B.escapeTestNoEncode.test(r))return r.replace(B.escapeReplaceNoEncode,vt);return r}function yt(r){try{r=encodeURI(r).replace(B.percentDecode,"%")}catch{return null}return r}function $t(r,e){let s=r.replace(B.findPipe,(i,a,o)=>{let l=!1,h=a;for(;--h>=0&&o[h]==="\\";)l=!l;return l?"|":" |"}),n=s.split(B.splitPipe),t=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;t<n.length;t++)n[t]=n[t].trim().replace(B.slashPipe,"|");return n}function Te(r,e,s){let n=r.length;if(n===0)return"";let t=0;for(;t<n&&r.charAt(n-t-1)===e;)t++;return r.slice(0,n-t)}function vr(r,e){if(r.indexOf(e[1])===-1)return-1;let s=0;for(let n=0;n<r.length;n++)if(r[n]==="\\")n++;else if(r[n]===e[0])s++;else if(r[n]===e[1]&&(s--,s<0))return n;return s>0?-2:-1}function yr(r,e=0){let s=e,n="";for(let t of r)if(t===" "){let i=4-s%4;n+=" ".repeat(i),s+=i}else n+=t,s++;return n}function _t(r,e,s,n,t){let i=e.href,a=e.title||null,o=r[1].replace(t.other.outputLinkReplace,"$1");n.state.inLink=!0;let l={type:r[0].charAt(0)==="!"?"image":"link",raw:s,href:i,title:a,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=!1,l}function $r(r,e,s){let n=r.match(s.other.indentCodeCompensation);if(n===null)return e;let t=n[1];return e.split(`
3
3
  `).map(i=>{let a=i.match(s.other.beginningSpace);if(a===null)return i;let[o]=a;return o.length>=t.length?i.slice(t.length):i}).join(`
4
4
  `)}var qe=class{options;rules;lexer;constructor(r){this.options=r||ue}space(r){let e=this.rules.block.newline.exec(r);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(r){let e=this.rules.block.code.exec(r);if(e){let s=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?s:Te(s,`
@@ -0,0 +1 @@
1
+ import{E as v,V as w,a,W as g}from"./DnL9f0lc.js";import{syntaxTree as x}from"./D7ZqAKi9.js";class b extends g{toDOM(){const r=document.createElement("span");return r.className="cm-bullet-widget",r.textContent="•",r}}class S extends g{constructor(r){super(),this.num=r}eq(r){return this.num===r.num}toDOM(){const r=document.createElement("span");return r.className="cm-ordered-widget",r.textContent=this.num+" ",r}}class C extends g{toDOM(){const r=document.createElement("div");return r.className="cm-hr-widget",r}}function E(n){return n.doc.lineAt(n.selection.main.head).number}function f(n,r,c){const i=n.selection.main.head;return i>=r&&i<=c}function k(n){const r=n.state,c=E(r),i=[];return x(r).iterate({enter(e){const u=r.doc.lineAt(e.from).number;if(e.name.startsWith("ATXHeading")){const h=`cm-live-heading cm-live-heading-${parseInt(e.name.replace("ATXHeading",""),10)||1}`;if(i.push(a.mark({class:h}).range(e.from,e.to)),u!==c){let o=e.node.firstChild;for(;o;){if(o.name==="HeaderMark"){const p=Math.min(o.to+1,e.to);i.push(a.replace({}).range(o.from,p));break}o=o.nextSibling}}return!1}if(e.name==="HorizontalRule"&&u!==c&&i.push(a.replace({widget:new C}).range(e.from,e.to)),e.name==="ListMark"&&u!==c){const t=Math.min(e.to+1,r.doc.lineAt(e.from).to);if(e.node.parent?.parent?.name==="OrderedList"){const o=r.doc.sliceString(e.from,e.to);i.push(a.replace({widget:new S(o)}).range(e.from,t))}else i.push(a.replace({widget:new b}).range(e.from,t))}if(e.name==="StrongEmphasis"){if(i.push(a.mark({class:"cm-live-strong"}).range(e.from,e.to)),!f(r,e.from,e.to)){let t=e.node.firstChild;for(;t;)t.name==="EmphasisMark"&&i.push(a.replace({}).range(t.from,t.to)),t=t.nextSibling}return!1}if(e.name==="Emphasis"){if(i.push(a.mark({class:"cm-live-em"}).range(e.from,e.to)),!f(r,e.from,e.to)){let t=e.node.firstChild;for(;t;)t.name==="EmphasisMark"&&i.push(a.replace({}).range(t.from,t.to)),t=t.nextSibling}return!1}if(e.name==="InlineCode"){if(i.push(a.mark({class:"cm-live-code"}).range(e.from,e.to)),!f(r,e.from,e.to)){let t=e.node.firstChild;for(;t;)t.name==="CodeMark"&&i.push(a.replace({}).range(t.from,t.to)),t=t.nextSibling}return!1}if(e.name==="Link"){const t=r.doc.sliceString(e.from,e.to),h=e.from>0?r.doc.sliceString(e.from-1,e.from):"",o=e.to<r.doc.length?r.doc.sliceString(e.to,e.to+1):"";if(h==="["&&o==="]"){const s=e.from-1,l=e.to+1;return i.push(a.mark({class:"cm-live-wikilink"}).range(s,l)),f(r,s,l)||(i.push(a.replace({}).range(s,s+2)),i.push(a.replace({}).range(l-2,l))),!1}if(t.includes("](")){let s=e.node.firstChild;const l=[];let m=null;for(;s;)s.name==="LinkMark"&&l.push({from:s.from,to:s.to}),s.name==="URL"&&(m={from:s.from,to:s.to}),s=s.nextSibling;const d=m?r.doc.sliceString(m.from,m.to):"";return i.push(a.mark({class:"cm-live-link",attributes:d?{"data-href":d}:{}}).range(e.from,e.to)),f(r,e.from,e.to)||l.length>=2&&m&&(i.push(a.replace({}).range(l[0].from,l[0].to)),i.push(a.replace({}).range(l[1].from,e.to))),!1}}}}),a.set(i,!0)}const L=w.fromClass(class{decorations;constructor(n){this.decorations=k(n)}update(n){(n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=k(n.view))}},{decorations:n=>n.decorations}),T=v.baseTheme({".cm-live-heading":{fontWeight:"600"},".cm-live-heading-1":{fontSize:"1.5em"},".cm-live-heading-2":{fontSize:"1.2em"},".cm-live-heading-3":{fontSize:"1.05em"},".cm-live-strong":{fontWeight:"600"},".cm-live-em":{fontStyle:"italic"},".cm-live-code":{fontFamily:"monospace",fontSize:"0.9em",padding:"1px 4px",borderRadius:"3px",backgroundColor:"rgba(128,128,128,0.12)"},".cm-live-wikilink":{color:"var(--color-link, #8b8bf0)",cursor:"pointer"},".cm-live-wikilink:hover":{textDecoration:"underline"},".cm-live-link":{color:"var(--color-link, #8b8bf0)",textDecoration:"none",cursor:"pointer"},".cm-live-link:hover":{textDecoration:"underline"},".cm-bullet-widget":{color:"var(--color-text-tertiary)",paddingRight:"6px"},".cm-hr-widget":{borderTop:"1px solid var(--color-border, #333)",margin:"8px 0"}});export{L as livePreviewPlugin,T as livePreviewTheme};
@@ -1 +1 @@
1
- import{q as G,b as fe,m as p,al as te,Y as we,X as K,am as be,_ as Ie,af as $e,an as Ae,ai as ne,ao as xe,ap as Ce,Q as Ne,h as w,c as F,x as de,a as Q,aq as Oe,ar as ee,r as ke,a0 as He,s as se,d as z,e as R,C as Re,as as De,at as N,U as he,W as pe,au as X,av as Me,aw as Pe,V as Be,a2 as Fe,w as Ue,ax as ge,ay as Le,az as Ve,E as ze,aA as We,aB as qe,a9 as Ge,aC as Ye,K as d,L as b,a7 as re,k as ie,T as Je}from"./BeBar3OL.js";import{b as Xe,i as Ke}from"./Cs_ROD7H.js";import{B as Qe}from"./xBRYfpah.js";import{i as Ze}from"./C_8lGlxx.js";import{b as oe,u as ae,w as C,a as je}from"./DP09rP34.js";function Ct(e,t){return t}function et(e,t,n){for(var s=[],i=t.length,a,o=t.length,c=0;c<i;c++){let T=t[c];pe(T,()=>{if(a){if(a.pending.delete(T),a.done.add(T),a.pending.size===0){var h=e.outrogroups;Z(ee(a.done)),h.delete(a),h.size===0&&(e.outrogroups=null)}}else o-=1},!1)}if(o===0){var u=s.length===0&&n!==null;if(u){var E=n,l=E.parentNode;Pe(l),l.append(E),e.items.clear()}Z(t,!u)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function Z(e,t=!0){for(var n=0;n<e.length;n++)Be(e[n],t)}var le;function Nt(e,t,n,s,i,a=null){var o=e,c=new Map,u=(t&ge)!==0;if(u){var E=e;o=w?F(de(E)):E.appendChild(G())}w&&Q();var l=null,T=$e(()=>{var f=n();return Oe(f)?f:f==null?[]:ee(f)}),h,g=!0;function m(){r.fallback=l,tt(r,h,o,t,s),l!==null&&(h.length===0?(l.f&N)===0?he(l):(l.f^=N,V(l,null,o)):pe(l,()=>{l=null}))}var y=fe(()=>{h=p(T);var f=h.length;let x=!1;if(w){var M=ke(o)===He;M!==(f===0)&&(o=se(),F(o),z(!1),x=!0)}for(var $=new Set,k=we,P=Ie(),I=0;I<f;I+=1){w&&R.nodeType===Re&&R.data===De&&(o=R,x=!0,z(!1));var H=h[I],B=s(H,I),v=g?null:c.get(B);v?(v.v&&te(v.v,H),v.i&&te(v.i,I),P&&k.unskip_effect(v.e)):(v=nt(c,g?o:le??=G(),H,B,I,i,t,n),g||(v.e.f|=N),c.set(B,v)),$.add(B)}if(f===0&&a&&!l&&(g?l=K(()=>a(o)):(l=K(()=>a(le??=G())),l.f|=N)),f>$.size&&be(),w&&f>0&&F(se()),!g)if(P){for(const[Se,ve]of c)$.has(Se)||k.skip_effect(ve.e);k.oncommit(m),k.ondiscard(()=>{})}else m();x&&z(!0),p(T)}),r={effect:y,items:c,outrogroups:null,fallback:l};g=!1,w&&(o=R)}function U(e){for(;e!==null&&(e.f&Me)===0;)e=e.next;return e}function tt(e,t,n,s,i){var a=(s&Le)!==0,o=t.length,c=e.items,u=U(e.effect.first),E,l=null,T,h=[],g=[],m,y,r,f;if(a)for(f=0;f<o;f+=1)m=t[f],y=i(m,f),r=c.get(y).e,(r.f&N)===0&&(r.nodes?.a?.measure(),(T??=new Set).add(r));for(f=0;f<o;f+=1){if(m=t[f],y=i(m,f),r=c.get(y).e,e.outrogroups!==null)for(const v of e.outrogroups)v.pending.delete(r),v.done.delete(r);if((r.f&N)!==0)if(r.f^=N,r===u)V(r,null,n);else{var x=l?l.next:u;r===e.effect.last&&(e.effect.last=r.prev),r.prev&&(r.prev.next=r.next),r.next&&(r.next.prev=r.prev),O(e,l,r),O(e,r,x),V(r,x,n),l=r,h=[],g=[],u=U(l.next);continue}if((r.f&X)!==0&&(he(r),a&&(r.nodes?.a?.unfix(),(T??=new Set).delete(r))),r!==u){if(E!==void 0&&E.has(r)){if(h.length<g.length){var M=g[0],$;l=M.prev;var k=h[0],P=h[h.length-1];for($=0;$<h.length;$+=1)V(h[$],M,n);for($=0;$<g.length;$+=1)E.delete(g[$]);O(e,k.prev,P.next),O(e,l,k),O(e,P,M),u=M,l=P,f-=1,h=[],g=[]}else E.delete(r),V(r,u,n),O(e,r.prev,r.next),O(e,r,l===null?e.effect.first:l.next),O(e,l,r),l=r;continue}for(h=[],g=[];u!==null&&u!==r;)(E??=new Set).add(u),g.push(u),u=U(u.next);if(u===null)continue}(r.f&N)===0&&h.push(r),l=r,u=U(r.next)}if(e.outrogroups!==null){for(const v of e.outrogroups)v.pending.size===0&&(Z(ee(v.done)),e.outrogroups?.delete(v));e.outrogroups.size===0&&(e.outrogroups=null)}if(u!==null||E!==void 0){var I=[];if(E!==void 0)for(r of E)(r.f&X)===0&&I.push(r);for(;u!==null;)(u.f&X)===0&&u!==e.fallback&&I.push(u),u=U(u.next);var H=I.length;if(H>0){var B=(s&ge)!==0&&o===0?n:null;if(a){for(f=0;f<H;f+=1)I[f].nodes?.a?.measure();for(f=0;f<H;f+=1)I[f].nodes?.a?.fix()}et(e,I,B)}}a&&Fe(()=>{if(T!==void 0)for(r of T)r.nodes?.a?.apply()})}function nt(e,t,n,s,i,a,o,c){var u=(o&xe)!==0?(o&Ce)===0?Ne(n,!1,!1):ne(n):null,E=(o&Ae)!==0?ne(i):null;return{v:u,i:E,e:K(()=>(a(t,u??n,E??i,c),()=>{e.delete(s)}))}}function V(e,t,n){if(e.nodes)for(var s=e.nodes.start,i=e.nodes.end,a=t&&(t.f&N)===0?t.nodes.start:n;s!==null;){var o=Ue(s);if(a.before(s),s===i)return;s=o}}function O(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function Ot(e,t,n,s,i,a){let o=w;w&&Q();var c=null;w&&R.nodeType===Ve&&(c=R,Q());var u=w?R:e,E=new Qe(u,!1);fe(()=>{const l=t()||null;var T=n||l==="svg"?qe:void 0;if(l===null){E.ensure(null,null);return}return E.ensure(l,h=>{if(l){if(c=w?c:We(l,T),Xe(c,c),s){w&&Ke(l)&&c.append(document.createComment(""));var g=w?de(c):c.appendChild(G());w&&(g===null?z(!1):F(g)),s(c,g)}Ge.nodes.end=c,h.before(c)}w&&F(h)}),()=>{}},ze),Ye(()=>{}),o&&(z(!0),F(u))}function st(){let e=b(null),t=b(null),n=b(null),s=b(null),i=b("entity"),a=b(null),o=b("general");function c(m,y){p(e)&&(p(e)!==m||p(n)!==y)&&oe(p(e)).catch(()=>{})}function u(m,y,r,f){c(m,r),d(e,m,!0),d(t,y,!0),d(n,r,!0),d(s,f??null,!0)}function E(){d(i,"entity")}function l(){d(i,"graph")}function T(){d(i,"settings")}function h(m,y,r){p(n)===r&&p(e)===m?(d(e,null),d(t,null),d(n,null)):(d(e,m,!0),d(t,y,!0),d(n,r,!0)),d(s,null)}function g(){p(e)&&oe(p(e)).catch(()=>{}),d(e,null),d(t,null),d(n,null),d(s,null)}return{get selectedRepo(){return p(e)},get selectedType(){return p(t)},get selectedId(){return p(n)},get selectedSubPath(){return p(s)},get activeView(){return p(i)},get entityPath(){return p(e)&&p(t)&&p(n)?`/${p(e)}/${p(t)}/${p(n)}`:null},get hoveredEntityId(){return p(a)},set hoveredEntityId(m){d(a,m,!0)},get settingsTab(){return p(o)},set settingsTab(m){d(o,m,!0)},select:u,deselect:g,selectOnGraph:h,showEntity:E,showGraph:l,showSettings:T}}const L=st();function kt(...e){return e.filter(Boolean).join(" ")}const rt=typeof document<"u";let ue=0;class it{#e=b(re([]));get toasts(){return p(this.#e)}set toasts(t){d(this.#e,t,!0)}#t=b(re([]));get heights(){return p(this.#t)}set heights(t){d(this.#t,t,!0)}#n=t=>{const n=this.toasts.findIndex(s=>s.id===t);return n===-1?null:n};addToast=t=>{rt&&this.toasts.unshift(t)};updateToast=({id:t,data:n,type:s,message:i})=>{const a=this.toasts.findIndex(c=>c.id===t),o=this.toasts[a];this.toasts[a]={...o,...n,id:t,title:i,type:s,updated:!0}};create=t=>{const{message:n,...s}=t,i=typeof t?.id=="number"||t.id&&t.id?.length>0?t.id:ue++,a=t.dismissible!==void 0?t.dismissible:t.dismissable!==void 0?t.dismissable:!0,o=t.type===void 0?"default":t.type;return ie(()=>{this.toasts.find(u=>u.id===i)?this.updateToast({id:i,data:t,type:o,message:n,dismissible:a}):this.addToast({...s,id:i,title:n,dismissible:a,type:o})}),i};dismiss=t=>(ie(()=>{if(t===void 0){this.toasts=this.toasts.map(s=>({...s,dismiss:!0}));return}const n=this.toasts.findIndex(s=>s.id===t);this.toasts[n]&&(this.toasts[n]={...this.toasts[n],dismiss:!0})}),t);remove=t=>{if(t===void 0){this.toasts=[];return}const n=this.#n(t);if(n!==null)return this.toasts.splice(n,1),t};message=(t,n)=>this.create({...n,type:"default",message:t});error=(t,n)=>this.create({...n,type:"error",message:t});success=(t,n)=>this.create({...n,type:"success",message:t});info=(t,n)=>this.create({...n,type:"info",message:t});warning=(t,n)=>this.create({...n,type:"warning",message:t});loading=(t,n)=>this.create({...n,type:"loading",message:t});promise=(t,n)=>{if(!n)return;let s;n.loading!==void 0&&(s=this.create({...n,promise:t,type:"loading",message:typeof n.loading=="string"?n.loading:n.loading()}));const i=t instanceof Promise?t:t();let a=s!==void 0;return i.then(o=>{if(typeof o=="object"&&o&&"ok"in o&&typeof o.ok=="boolean"&&!o.ok){a=!1;const c=ot(o);this.create({id:s,type:"error",message:c})}else if(n.success!==void 0){a=!1;const c=typeof n.success=="function"?n.success(o):n.success;this.create({id:s,type:"success",message:c})}}).catch(o=>{if(n.error!==void 0){a=!1;const c=typeof n.error=="function"?n.error(o):n.error;this.create({id:s,type:"error",message:c})}}).finally(()=>{a&&(this.dismiss(s),s=void 0),n.finally?.()}),s};custom=(t,n)=>{const s=n?.id||ue++;return this.create({component:t,id:s,...n}),s};removeHeight=t=>{this.heights=this.heights.filter(n=>n.toastId!==t)};setHeight=t=>{const n=this.#n(t.toastId);if(n===null){this.heights.push(t);return}this.heights[n]=t};reset=()=>{this.toasts=[],this.heights=[]}}function ot(e){return e&&typeof e=="object"&&"status"in e?`HTTP error! Status: ${e.status}`:`Error! ${e}`}const A=new it;function at(e,t){return A.create({message:e,...t})}class Ht{#e=Je(()=>A.toasts.filter(t=>!t.dismiss));get toasts(){return p(this.#e)}}const lt=at,S=Object.assign(lt,{success:A.success,info:A.info,warning:A.warning,error:A.error,custom:A.custom,message:A.message,promise:A.promise,dismiss:A.dismiss,loading:A.loading,getActiveToasts:()=>A.toasts.filter(e=>!e.dismiss)}),ut=800;function ct(){let e=b(!1),t=b(null),n=b(null),s=null,i=null,a=!1;function o(h,g,m,y){s&&s.repo===h&&s.type===g&&s.id===m?(y.data!==void 0&&(s.payload.data=y.data),y.content!==void 0&&(s.payload.content=y.content)):s={repo:h,type:g,id:m,payload:{...y}},c()}function c(){i&&clearTimeout(i),i=setTimeout(u,ut)}async function u(){if(i=null,!a&&s){const{repo:h,type:g,id:m,payload:y}=s;s=null,a=!0,d(e,!0),d(n,null);try{if(await ae(h,g,m,y),d(t,new Date,!0),y.data?.name){const f=C.repos.find(x=>x.name===h)?.entities.find(x=>x.id===m);f&&(f.title=y.data.name)}}catch(r){d(n,r.message??"Save failed",!0);const f=r.status??r.statusCode;(!f||f>=500)&&(s={repo:h,type:g,id:m,payload:y})}finally{d(e,!1),a=!1,s&&u()}}}function E(){i&&(clearTimeout(i),i=null),s&&u()}async function l(h,g,m,y){d(e,!0),d(n,null);try{const r=await ae(h,g,m,y);return d(t,new Date,!0),r}catch(r){return d(n,r.message??"Save failed",!0),null}finally{d(e,!1)}}function T(){d(n,null),d(t,null),s=null,i&&(clearTimeout(i),i=null)}return{get saving(){return p(e)},get lastSaved(){return p(t)},get error(){return p(n)},get hasPending(){return!!(s||a)},scheduleAutoSave:o,flush:E,saveEntity:l,reset:T}}const ft=ct();let _=null,me=null,ye=null,Ee=[],Y=null,q=1e3,J=b(!1),Te=b(null);const D=new Map,W={},j={};function ce(e,t){D.delete(e);const n=t.entities.length,s=n===1?`${e} updated ${t.entities[0]}`:`${e} updated ${n} entities`;S(s)}function dt(e){for(const[t,n]of D)n.repo===e&&(clearTimeout(n.timer),D.delete(t))}function ht(e){const t=je.user?.displayName;if(e.type==="sync_progress"){const n=W[e.repo];if(n){const s=e.message.trim(),i=s.match(/^Syncing from source:\s*(.+)$/i);i&&(j[e.repo]=`Syncing ${i[1].trim()}…`);const a=j[e.repo]??`Syncing ${e.repo}…`;S.loading(a,{id:n,description:s,duration:36e5})}return}if(e.type==="entity_change"){if(t&&e.actor===t&&e.source==="api"){C.refreshEntities(e.repo);return}if(C.refreshEntities(e.repo),L.selectedRepo===e.repo&&L.selectedType===e.entityType&&L.selectedId===e.entityId){ft.hasPending?S(`${e.actor} also saved changes to this entity`):Ze();return}const s=D.get(e.actor);if(s)clearTimeout(s.timer),s.entities.includes(e.entityId)||s.entities.push(e.entityId),s.timer=setTimeout(()=>ce(e.actor,s),1e4);else{const i={entities:[e.entityId],repo:e.repo,timer:setTimeout(()=>ce(e.actor,i),1e4)};D.set(e.actor,i)}return}if(e.type==="session_commit"){if(t&&e.actor===t){d(Te,e.timestamp,!0);return}const n=e.entities.length,s=n===1?`${e.actor} saved changes to ${e.entities[0]}`:`${e.actor} saved ${n} changes in ${e.repo}`;S(s),C.refreshEntities(e.repo);return}if(e.type==="sync_complete"){if(dt(e.repo),!W[e.repo]){const n=e.created+e.updated+e.deleted,s=n===0?`Sync complete · no changes in ${e.repo}`:`Sync complete · ${n} ${n===1?"entity":"entities"} from ${e.source}`;S.success(s)}C.refreshEntities(e.repo);return}if(e.type==="collection_created"){S(`${e.actor} created collection ${e.repo}`),C.refreshEntities(e.repo);return}if(e.type==="collection_deleted"){S(`${e.actor} deleted collection ${e.repo}`);return}if(e.type==="repo_sync"){S(`${e.actor} pushed to ${e.repo}`),C.refreshEntities(e.repo);return}if(e.type==="presence"){me?.(e);return}if(e.type==="online"){ye?.(e);return}if(e.type==="access_granted"||e.type==="access_revoked"){e.type==="access_revoked"&&L.selectedRepo===e.repo&&L.deselect(),C.load();return}}function _e(){if(typeof window>"u"||_&&(_.readyState===WebSocket.OPEN||_.readyState===WebSocket.CONNECTING))return;const t=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;_=new WebSocket(t),_.binaryType="arraybuffer",_.onopen=()=>{d(J,!0),q=1e3,C.refreshAll();for(const n of Ee)n()},_.onmessage=n=>{if(!(n.data instanceof ArrayBuffer))try{const s=JSON.parse(n.data);if(s?.type==="ping"){_?.send(JSON.stringify({type:"pong"}));return}const i=s;i.type&&i.type!=="toast"&&ht(i)}catch{}},_.onclose=()=>{d(J,!1),_=null,Y=setTimeout(()=>{q=Math.min(q*2,1e4),_e()},q)},_.onerror=()=>{}}function pt(){Y&&(clearTimeout(Y),Y=null),_&&(_.close(),_=null),d(J,!1);for(const[,e]of D)clearTimeout(e.timer);D.clear()}function gt(e,t=4e3){S(e,{duration:t})}function mt(e,t){const n=crypto.randomUUID();return t?.loading?S.loading(e,{id:n,duration:36e5}):S(e,{id:n}),n}function yt(e,t,n){if(n?.loading){S.loading(t,{id:e});return}/failed|error/i.test(t)?S.error(t,{id:e,duration:n?.duration??6e3}):S.success(t,{id:e,duration:n?.duration??4e3})}function Et(e){const t=crypto.randomUUID();W[e]=t,S.loading(`Syncing ${e}…`,{id:t,duration:36e5})}function Tt(e,t,n){const s=W[e];s&&(delete W[e],delete j[e],n?S.error(t,{id:s,duration:6e3}):S.success(t,{id:s,duration:4e3}))}function _t(e){me=e}function St(e){ye=e}function vt(e){Ee.push(e)}function wt(e){_?.readyState===WebSocket.OPEN&&_.send(JSON.stringify(e))}const Rt={get connected(){return p(J)},get lastAutoSaved(){return p(Te)},get ws(){return _},connect:_e,disconnect:pt,showToast:gt,showPersistentToast:mt,updateToast:yt,startSyncToast:Et,finishSyncToast:Tt,send:wt,setPresenceHandler:_t,setOnlineHandler:St,addConnectHandler:vt};export{Ht as S,ft as a,Ot as b,kt as c,Nt as e,Ct as i,L as n,Rt as r,A as t};
1
+ import{q as G,b as fe,m as p,al as te,Y as we,X as K,am as be,_ as Ie,af as $e,an as Ae,ai as ne,ao as xe,ap as Ce,Q as Ne,h as w,c as F,x as de,a as Q,aq as Oe,ar as ee,r as ke,a0 as He,s as se,d as z,e as R,C as Re,as as De,at as N,U as he,W as pe,au as X,av as Me,aw as Pe,V as Be,a2 as Fe,w as Ue,ax as ge,ay as Le,az as Ve,E as ze,aA as We,aB as qe,a9 as Ge,aC as Ye,K as d,L as b,a7 as re,k as ie,T as Je}from"./BeBar3OL.js";import{b as Xe,i as Ke}from"./Cs_ROD7H.js";import{B as Qe}from"./xBRYfpah.js";import{i as Ze}from"./B1Cz8BMn.js";import{b as oe,u as ae,w as C,a as je}from"./DP09rP34.js";function Ct(e,t){return t}function et(e,t,n){for(var s=[],i=t.length,a,o=t.length,c=0;c<i;c++){let T=t[c];pe(T,()=>{if(a){if(a.pending.delete(T),a.done.add(T),a.pending.size===0){var h=e.outrogroups;Z(ee(a.done)),h.delete(a),h.size===0&&(e.outrogroups=null)}}else o-=1},!1)}if(o===0){var u=s.length===0&&n!==null;if(u){var E=n,l=E.parentNode;Pe(l),l.append(E),e.items.clear()}Z(t,!u)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function Z(e,t=!0){for(var n=0;n<e.length;n++)Be(e[n],t)}var le;function Nt(e,t,n,s,i,a=null){var o=e,c=new Map,u=(t&ge)!==0;if(u){var E=e;o=w?F(de(E)):E.appendChild(G())}w&&Q();var l=null,T=$e(()=>{var f=n();return Oe(f)?f:f==null?[]:ee(f)}),h,g=!0;function m(){r.fallback=l,tt(r,h,o,t,s),l!==null&&(h.length===0?(l.f&N)===0?he(l):(l.f^=N,V(l,null,o)):pe(l,()=>{l=null}))}var y=fe(()=>{h=p(T);var f=h.length;let x=!1;if(w){var M=ke(o)===He;M!==(f===0)&&(o=se(),F(o),z(!1),x=!0)}for(var $=new Set,k=we,P=Ie(),I=0;I<f;I+=1){w&&R.nodeType===Re&&R.data===De&&(o=R,x=!0,z(!1));var H=h[I],B=s(H,I),v=g?null:c.get(B);v?(v.v&&te(v.v,H),v.i&&te(v.i,I),P&&k.unskip_effect(v.e)):(v=nt(c,g?o:le??=G(),H,B,I,i,t,n),g||(v.e.f|=N),c.set(B,v)),$.add(B)}if(f===0&&a&&!l&&(g?l=K(()=>a(o)):(l=K(()=>a(le??=G())),l.f|=N)),f>$.size&&be(),w&&f>0&&F(se()),!g)if(P){for(const[Se,ve]of c)$.has(Se)||k.skip_effect(ve.e);k.oncommit(m),k.ondiscard(()=>{})}else m();x&&z(!0),p(T)}),r={effect:y,items:c,outrogroups:null,fallback:l};g=!1,w&&(o=R)}function U(e){for(;e!==null&&(e.f&Me)===0;)e=e.next;return e}function tt(e,t,n,s,i){var a=(s&Le)!==0,o=t.length,c=e.items,u=U(e.effect.first),E,l=null,T,h=[],g=[],m,y,r,f;if(a)for(f=0;f<o;f+=1)m=t[f],y=i(m,f),r=c.get(y).e,(r.f&N)===0&&(r.nodes?.a?.measure(),(T??=new Set).add(r));for(f=0;f<o;f+=1){if(m=t[f],y=i(m,f),r=c.get(y).e,e.outrogroups!==null)for(const v of e.outrogroups)v.pending.delete(r),v.done.delete(r);if((r.f&N)!==0)if(r.f^=N,r===u)V(r,null,n);else{var x=l?l.next:u;r===e.effect.last&&(e.effect.last=r.prev),r.prev&&(r.prev.next=r.next),r.next&&(r.next.prev=r.prev),O(e,l,r),O(e,r,x),V(r,x,n),l=r,h=[],g=[],u=U(l.next);continue}if((r.f&X)!==0&&(he(r),a&&(r.nodes?.a?.unfix(),(T??=new Set).delete(r))),r!==u){if(E!==void 0&&E.has(r)){if(h.length<g.length){var M=g[0],$;l=M.prev;var k=h[0],P=h[h.length-1];for($=0;$<h.length;$+=1)V(h[$],M,n);for($=0;$<g.length;$+=1)E.delete(g[$]);O(e,k.prev,P.next),O(e,l,k),O(e,P,M),u=M,l=P,f-=1,h=[],g=[]}else E.delete(r),V(r,u,n),O(e,r.prev,r.next),O(e,r,l===null?e.effect.first:l.next),O(e,l,r),l=r;continue}for(h=[],g=[];u!==null&&u!==r;)(E??=new Set).add(u),g.push(u),u=U(u.next);if(u===null)continue}(r.f&N)===0&&h.push(r),l=r,u=U(r.next)}if(e.outrogroups!==null){for(const v of e.outrogroups)v.pending.size===0&&(Z(ee(v.done)),e.outrogroups?.delete(v));e.outrogroups.size===0&&(e.outrogroups=null)}if(u!==null||E!==void 0){var I=[];if(E!==void 0)for(r of E)(r.f&X)===0&&I.push(r);for(;u!==null;)(u.f&X)===0&&u!==e.fallback&&I.push(u),u=U(u.next);var H=I.length;if(H>0){var B=(s&ge)!==0&&o===0?n:null;if(a){for(f=0;f<H;f+=1)I[f].nodes?.a?.measure();for(f=0;f<H;f+=1)I[f].nodes?.a?.fix()}et(e,I,B)}}a&&Fe(()=>{if(T!==void 0)for(r of T)r.nodes?.a?.apply()})}function nt(e,t,n,s,i,a,o,c){var u=(o&xe)!==0?(o&Ce)===0?Ne(n,!1,!1):ne(n):null,E=(o&Ae)!==0?ne(i):null;return{v:u,i:E,e:K(()=>(a(t,u??n,E??i,c),()=>{e.delete(s)}))}}function V(e,t,n){if(e.nodes)for(var s=e.nodes.start,i=e.nodes.end,a=t&&(t.f&N)===0?t.nodes.start:n;s!==null;){var o=Ue(s);if(a.before(s),s===i)return;s=o}}function O(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function Ot(e,t,n,s,i,a){let o=w;w&&Q();var c=null;w&&R.nodeType===Ve&&(c=R,Q());var u=w?R:e,E=new Qe(u,!1);fe(()=>{const l=t()||null;var T=n||l==="svg"?qe:void 0;if(l===null){E.ensure(null,null);return}return E.ensure(l,h=>{if(l){if(c=w?c:We(l,T),Xe(c,c),s){w&&Ke(l)&&c.append(document.createComment(""));var g=w?de(c):c.appendChild(G());w&&(g===null?z(!1):F(g)),s(c,g)}Ge.nodes.end=c,h.before(c)}w&&F(h)}),()=>{}},ze),Ye(()=>{}),o&&(z(!0),F(u))}function st(){let e=b(null),t=b(null),n=b(null),s=b(null),i=b("entity"),a=b(null),o=b("general");function c(m,y){p(e)&&(p(e)!==m||p(n)!==y)&&oe(p(e)).catch(()=>{})}function u(m,y,r,f){c(m,r),d(e,m,!0),d(t,y,!0),d(n,r,!0),d(s,f??null,!0)}function E(){d(i,"entity")}function l(){d(i,"graph")}function T(){d(i,"settings")}function h(m,y,r){p(n)===r&&p(e)===m?(d(e,null),d(t,null),d(n,null)):(d(e,m,!0),d(t,y,!0),d(n,r,!0)),d(s,null)}function g(){p(e)&&oe(p(e)).catch(()=>{}),d(e,null),d(t,null),d(n,null),d(s,null)}return{get selectedRepo(){return p(e)},get selectedType(){return p(t)},get selectedId(){return p(n)},get selectedSubPath(){return p(s)},get activeView(){return p(i)},get entityPath(){return p(e)&&p(t)&&p(n)?`/${p(e)}/${p(t)}/${p(n)}`:null},get hoveredEntityId(){return p(a)},set hoveredEntityId(m){d(a,m,!0)},get settingsTab(){return p(o)},set settingsTab(m){d(o,m,!0)},select:u,deselect:g,selectOnGraph:h,showEntity:E,showGraph:l,showSettings:T}}const L=st();function kt(...e){return e.filter(Boolean).join(" ")}const rt=typeof document<"u";let ue=0;class it{#e=b(re([]));get toasts(){return p(this.#e)}set toasts(t){d(this.#e,t,!0)}#t=b(re([]));get heights(){return p(this.#t)}set heights(t){d(this.#t,t,!0)}#n=t=>{const n=this.toasts.findIndex(s=>s.id===t);return n===-1?null:n};addToast=t=>{rt&&this.toasts.unshift(t)};updateToast=({id:t,data:n,type:s,message:i})=>{const a=this.toasts.findIndex(c=>c.id===t),o=this.toasts[a];this.toasts[a]={...o,...n,id:t,title:i,type:s,updated:!0}};create=t=>{const{message:n,...s}=t,i=typeof t?.id=="number"||t.id&&t.id?.length>0?t.id:ue++,a=t.dismissible!==void 0?t.dismissible:t.dismissable!==void 0?t.dismissable:!0,o=t.type===void 0?"default":t.type;return ie(()=>{this.toasts.find(u=>u.id===i)?this.updateToast({id:i,data:t,type:o,message:n,dismissible:a}):this.addToast({...s,id:i,title:n,dismissible:a,type:o})}),i};dismiss=t=>(ie(()=>{if(t===void 0){this.toasts=this.toasts.map(s=>({...s,dismiss:!0}));return}const n=this.toasts.findIndex(s=>s.id===t);this.toasts[n]&&(this.toasts[n]={...this.toasts[n],dismiss:!0})}),t);remove=t=>{if(t===void 0){this.toasts=[];return}const n=this.#n(t);if(n!==null)return this.toasts.splice(n,1),t};message=(t,n)=>this.create({...n,type:"default",message:t});error=(t,n)=>this.create({...n,type:"error",message:t});success=(t,n)=>this.create({...n,type:"success",message:t});info=(t,n)=>this.create({...n,type:"info",message:t});warning=(t,n)=>this.create({...n,type:"warning",message:t});loading=(t,n)=>this.create({...n,type:"loading",message:t});promise=(t,n)=>{if(!n)return;let s;n.loading!==void 0&&(s=this.create({...n,promise:t,type:"loading",message:typeof n.loading=="string"?n.loading:n.loading()}));const i=t instanceof Promise?t:t();let a=s!==void 0;return i.then(o=>{if(typeof o=="object"&&o&&"ok"in o&&typeof o.ok=="boolean"&&!o.ok){a=!1;const c=ot(o);this.create({id:s,type:"error",message:c})}else if(n.success!==void 0){a=!1;const c=typeof n.success=="function"?n.success(o):n.success;this.create({id:s,type:"success",message:c})}}).catch(o=>{if(n.error!==void 0){a=!1;const c=typeof n.error=="function"?n.error(o):n.error;this.create({id:s,type:"error",message:c})}}).finally(()=>{a&&(this.dismiss(s),s=void 0),n.finally?.()}),s};custom=(t,n)=>{const s=n?.id||ue++;return this.create({component:t,id:s,...n}),s};removeHeight=t=>{this.heights=this.heights.filter(n=>n.toastId!==t)};setHeight=t=>{const n=this.#n(t.toastId);if(n===null){this.heights.push(t);return}this.heights[n]=t};reset=()=>{this.toasts=[],this.heights=[]}}function ot(e){return e&&typeof e=="object"&&"status"in e?`HTTP error! Status: ${e.status}`:`Error! ${e}`}const A=new it;function at(e,t){return A.create({message:e,...t})}class Ht{#e=Je(()=>A.toasts.filter(t=>!t.dismiss));get toasts(){return p(this.#e)}}const lt=at,S=Object.assign(lt,{success:A.success,info:A.info,warning:A.warning,error:A.error,custom:A.custom,message:A.message,promise:A.promise,dismiss:A.dismiss,loading:A.loading,getActiveToasts:()=>A.toasts.filter(e=>!e.dismiss)}),ut=800;function ct(){let e=b(!1),t=b(null),n=b(null),s=null,i=null,a=!1;function o(h,g,m,y){s&&s.repo===h&&s.type===g&&s.id===m?(y.data!==void 0&&(s.payload.data=y.data),y.content!==void 0&&(s.payload.content=y.content)):s={repo:h,type:g,id:m,payload:{...y}},c()}function c(){i&&clearTimeout(i),i=setTimeout(u,ut)}async function u(){if(i=null,!a&&s){const{repo:h,type:g,id:m,payload:y}=s;s=null,a=!0,d(e,!0),d(n,null);try{if(await ae(h,g,m,y),d(t,new Date,!0),y.data?.name){const f=C.repos.find(x=>x.name===h)?.entities.find(x=>x.id===m);f&&(f.title=y.data.name)}}catch(r){d(n,r.message??"Save failed",!0);const f=r.status??r.statusCode;(!f||f>=500)&&(s={repo:h,type:g,id:m,payload:y})}finally{d(e,!1),a=!1,s&&u()}}}function E(){i&&(clearTimeout(i),i=null),s&&u()}async function l(h,g,m,y){d(e,!0),d(n,null);try{const r=await ae(h,g,m,y);return d(t,new Date,!0),r}catch(r){return d(n,r.message??"Save failed",!0),null}finally{d(e,!1)}}function T(){d(n,null),d(t,null),s=null,i&&(clearTimeout(i),i=null)}return{get saving(){return p(e)},get lastSaved(){return p(t)},get error(){return p(n)},get hasPending(){return!!(s||a)},scheduleAutoSave:o,flush:E,saveEntity:l,reset:T}}const ft=ct();let _=null,me=null,ye=null,Ee=[],Y=null,q=1e3,J=b(!1),Te=b(null);const D=new Map,W={},j={};function ce(e,t){D.delete(e);const n=t.entities.length,s=n===1?`${e} updated ${t.entities[0]}`:`${e} updated ${n} entities`;S(s)}function dt(e){for(const[t,n]of D)n.repo===e&&(clearTimeout(n.timer),D.delete(t))}function ht(e){const t=je.user?.displayName;if(e.type==="sync_progress"){const n=W[e.repo];if(n){const s=e.message.trim(),i=s.match(/^Syncing from source:\s*(.+)$/i);i&&(j[e.repo]=`Syncing ${i[1].trim()}…`);const a=j[e.repo]??`Syncing ${e.repo}…`;S.loading(a,{id:n,description:s,duration:36e5})}return}if(e.type==="entity_change"){if(t&&e.actor===t&&e.source==="api"){C.refreshEntities(e.repo);return}if(C.refreshEntities(e.repo),L.selectedRepo===e.repo&&L.selectedType===e.entityType&&L.selectedId===e.entityId){ft.hasPending?S(`${e.actor} also saved changes to this entity`):Ze();return}const s=D.get(e.actor);if(s)clearTimeout(s.timer),s.entities.includes(e.entityId)||s.entities.push(e.entityId),s.timer=setTimeout(()=>ce(e.actor,s),1e4);else{const i={entities:[e.entityId],repo:e.repo,timer:setTimeout(()=>ce(e.actor,i),1e4)};D.set(e.actor,i)}return}if(e.type==="session_commit"){if(t&&e.actor===t){d(Te,e.timestamp,!0);return}const n=e.entities.length,s=n===1?`${e.actor} saved changes to ${e.entities[0]}`:`${e.actor} saved ${n} changes in ${e.repo}`;S(s),C.refreshEntities(e.repo);return}if(e.type==="sync_complete"){if(dt(e.repo),!W[e.repo]){const n=e.created+e.updated+e.deleted,s=n===0?`Sync complete · no changes in ${e.repo}`:`Sync complete · ${n} ${n===1?"entity":"entities"} from ${e.source}`;S.success(s)}C.refreshEntities(e.repo);return}if(e.type==="collection_created"){S(`${e.actor} created collection ${e.repo}`),C.refreshEntities(e.repo);return}if(e.type==="collection_deleted"){S(`${e.actor} deleted collection ${e.repo}`);return}if(e.type==="repo_sync"){S(`${e.actor} pushed to ${e.repo}`),C.refreshEntities(e.repo);return}if(e.type==="presence"){me?.(e);return}if(e.type==="online"){ye?.(e);return}if(e.type==="access_granted"||e.type==="access_revoked"){e.type==="access_revoked"&&L.selectedRepo===e.repo&&L.deselect(),C.load();return}}function _e(){if(typeof window>"u"||_&&(_.readyState===WebSocket.OPEN||_.readyState===WebSocket.CONNECTING))return;const t=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;_=new WebSocket(t),_.binaryType="arraybuffer",_.onopen=()=>{d(J,!0),q=1e3,C.refreshAll();for(const n of Ee)n()},_.onmessage=n=>{if(!(n.data instanceof ArrayBuffer))try{const s=JSON.parse(n.data);if(s?.type==="ping"){_?.send(JSON.stringify({type:"pong"}));return}const i=s;i.type&&i.type!=="toast"&&ht(i)}catch{}},_.onclose=()=>{d(J,!1),_=null,Y=setTimeout(()=>{q=Math.min(q*2,1e4),_e()},q)},_.onerror=()=>{}}function pt(){Y&&(clearTimeout(Y),Y=null),_&&(_.close(),_=null),d(J,!1);for(const[,e]of D)clearTimeout(e.timer);D.clear()}function gt(e,t=4e3){S(e,{duration:t})}function mt(e,t){const n=crypto.randomUUID();return t?.loading?S.loading(e,{id:n,duration:36e5}):S(e,{id:n}),n}function yt(e,t,n){if(n?.loading){S.loading(t,{id:e});return}/failed|error/i.test(t)?S.error(t,{id:e,duration:n?.duration??6e3}):S.success(t,{id:e,duration:n?.duration??4e3})}function Et(e){const t=crypto.randomUUID();W[e]=t,S.loading(`Syncing ${e}…`,{id:t,duration:36e5})}function Tt(e,t,n){const s=W[e];s&&(delete W[e],delete j[e],n?S.error(t,{id:s,duration:6e3}):S.success(t,{id:s,duration:4e3}))}function _t(e){me=e}function St(e){ye=e}function vt(e){Ee.push(e)}function wt(e){_?.readyState===WebSocket.OPEN&&_.send(JSON.stringify(e))}const Rt={get connected(){return p(J)},get lastAutoSaved(){return p(Te)},get ws(){return _},connect:_e,disconnect:pt,showToast:gt,showPersistentToast:mt,updateToast:yt,startSyncToast:Et,finishSyncToast:Tt,send:wt,setPresenceHandler:_t,setOnlineHandler:St,addConnectHandler:vt};export{Ht as S,ft as a,Ot as b,kt as c,Nt as e,Ct as i,L as n,Rt as r,A as t};