studiograph 1.3.3-next.21 → 1.3.3-next.23

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 (79) hide show
  1. package/dist/cli/commands/serve.js +3 -0
  2. package/dist/cli/commands/serve.js.map +1 -1
  3. package/dist/cli/commands/sync.js +58 -17
  4. package/dist/cli/commands/sync.js.map +1 -1
  5. package/dist/core/workspace.d.ts +6 -0
  6. package/dist/core/workspace.js +47 -0
  7. package/dist/core/workspace.js.map +1 -1
  8. package/dist/server/chrome/chrome.js +23 -252
  9. package/dist/server/collab.d.ts +27 -0
  10. package/dist/server/collab.js +117 -0
  11. package/dist/server/collab.js.map +1 -0
  12. package/dist/server/index.js +11 -6
  13. package/dist/server/index.js.map +1 -1
  14. package/dist/server/routes/collab.d.ts +6 -0
  15. package/dist/server/routes/collab.js +10 -0
  16. package/dist/server/routes/collab.js.map +1 -0
  17. package/dist/server/routes/graph-api.d.ts +2 -2
  18. package/dist/server/routes/graph-api.js +27 -6
  19. package/dist/server/routes/graph-api.js.map +1 -1
  20. package/dist/server/routes/sync-api.d.ts +2 -1
  21. package/dist/server/routes/sync-api.js +13 -1
  22. package/dist/server/routes/sync-api.js.map +1 -1
  23. package/dist/server/routes/ws.js +38 -0
  24. package/dist/server/routes/ws.js.map +1 -1
  25. package/dist/server/session-manager.d.ts +40 -0
  26. package/dist/server/session-manager.js +130 -0
  27. package/dist/server/session-manager.js.map +1 -0
  28. package/dist/server/ws-hub.d.ts +60 -1
  29. package/dist/server/ws-hub.js +113 -2
  30. package/dist/server/ws-hub.js.map +1 -1
  31. package/dist/web/_app/immutable/assets/AppShell.EyPUoNrB.css +1 -0
  32. package/dist/web/_app/immutable/assets/{editor.CaaAjbLg.css → entity.Bjlko8oW.css} +1 -1
  33. package/dist/web/_app/immutable/chunks/1XQG_7uE.js +1 -0
  34. package/dist/web/_app/immutable/chunks/{BDskUnFZ.js → BIQoyk5V.js} +10 -10
  35. package/dist/web/_app/immutable/chunks/{DFSquWcI.js → BV_9Nfp2.js} +1 -1
  36. package/dist/web/_app/immutable/chunks/Bk7i2AGK.js +5 -0
  37. package/dist/web/_app/immutable/chunks/ByFfmBEu.js +2 -0
  38. package/dist/web/_app/immutable/chunks/{BzhnXU6Q.js → C5cMwwSn.js} +1 -1
  39. package/dist/web/_app/immutable/chunks/CICthOLY.js +27 -0
  40. package/dist/web/_app/immutable/chunks/CaITTL5o.js +2 -0
  41. package/dist/web/_app/immutable/chunks/{BfTJ6NzK.js → CjKjQEMp.js} +1 -1
  42. package/dist/web/_app/immutable/chunks/{GRkK54yd.js → D-tW7Byc.js} +1 -1
  43. package/dist/web/_app/immutable/chunks/{Ddy4RvyP.js → DCWeodCf.js} +1 -1
  44. package/dist/web/_app/immutable/chunks/DWSjaG46.js +1 -0
  45. package/dist/web/_app/immutable/chunks/{DRChbfXz.js → DiXzlxx7.js} +1 -1
  46. package/dist/web/_app/immutable/chunks/{BbLYZVsw.js → Dpn7ZAUg.js} +1 -1
  47. package/dist/web/_app/immutable/chunks/EhE2EcYu.js +1 -0
  48. package/dist/web/_app/immutable/chunks/dCvzTHAY.js +1 -0
  49. package/dist/web/_app/immutable/chunks/{BjnErSlK.js → eEhMI0BQ.js} +1 -1
  50. package/dist/web/_app/immutable/chunks/i6t46AUT.js +2 -0
  51. package/dist/web/_app/immutable/chunks/pwrC_shA.js +1 -0
  52. package/dist/web/_app/immutable/entry/app.DjA3G34a.js +2 -0
  53. package/dist/web/_app/immutable/entry/start.DLZQ1-hB.js +1 -0
  54. package/dist/web/_app/immutable/nodes/0.B3dFDaCX.js +2 -0
  55. package/dist/web/_app/immutable/nodes/{1.gy-UNDF3.js → 1.B7XWRWiG.js} +1 -1
  56. package/dist/web/_app/immutable/nodes/{2.CFmJZos9.js → 2.BEOcFuIE.js} +1 -1
  57. package/dist/web/_app/immutable/nodes/3.NxBZXoOo.js +1 -0
  58. package/dist/web/_app/immutable/nodes/4.DyI15z1O.js +17 -0
  59. package/dist/web/_app/immutable/nodes/{5.C7yLiq2I.js → 5.CLl1ihqQ.js} +1 -1
  60. package/dist/web/_app/immutable/nodes/{6.DKaTmAiw.js → 6.DcamPcH8.js} +1 -1
  61. package/dist/web/_app/immutable/nodes/{7.CA3sQ74A.js → 7.C8Ctaz0_.js} +1 -1
  62. package/dist/web/_app/immutable/nodes/8.B5PKapjV.js +2 -0
  63. package/dist/web/_app/immutable/nodes/{9.BVVyKTae.js → 9.CjhBf9vj.js} +1 -1
  64. package/dist/web/_app/version.json +1 -1
  65. package/dist/web/index.html +10 -10
  66. package/package.json +2 -1
  67. package/dist/web/_app/immutable/assets/AppShell.C00jH_aT.css +0 -1
  68. package/dist/web/_app/immutable/chunks/B3v6bkHV.js +0 -27
  69. package/dist/web/_app/immutable/chunks/BQlTvYWB.js +0 -1
  70. package/dist/web/_app/immutable/chunks/CRcLi9EQ.js +0 -1
  71. package/dist/web/_app/immutable/chunks/DL7u7dQi.js +0 -2
  72. package/dist/web/_app/immutable/chunks/m74CvwCG.js +0 -2
  73. package/dist/web/_app/immutable/chunks/trveDs8t.js +0 -1
  74. package/dist/web/_app/immutable/entry/app.3j3I-9SC.js +0 -2
  75. package/dist/web/_app/immutable/entry/start.CYScsHkx.js +0 -1
  76. package/dist/web/_app/immutable/nodes/0.CxCm4CPW.js +0 -2
  77. package/dist/web/_app/immutable/nodes/3.D1yvWsPv.js +0 -1
  78. package/dist/web/_app/immutable/nodes/4.LKUIo9Zg.js +0 -16
  79. package/dist/web/_app/immutable/nodes/8.DEuJARDO.js +0 -2
@@ -1,8 +1,8 @@
1
- import{g as ut,c as F,a as v,f as I,d as es,e as ts,b as ss,s as $e,t as rs}from"./BfTJ6NzK.js";import{v as ie,h as dt,a as gt,ae as ns,aY as as,e as ft,C as is,k as ls,aX as os,aR as cs,c as hs,aJ as ps,aZ as us,a_ as ds,l as Ge,f as X,p as St,m as Rt,n as Tt,q as j,o as R,u as _,t as ze,z as te,S as Ue,y as p,x as S,T as Ve,_ as gs,P as Fe,D as fs,a$ as ks,V as Pe}from"./GRkK54yd.js";import{g as zt,e as xs,B as ee,w as ms}from"./m74CvwCG.js";import{l as xe,s as me,p as bs,i as D,b as ws}from"./trveDs8t.js";import{I as be,s as we,n as C,g as vs,X as ys,e as _e,T as $s,i as Se}from"./CRcLi9EQ.js";import"./BjnErSlK.js";import{b as _s}from"./DFSquWcI.js";import{i as Ss,g as Rs}from"./BzhnXU6Q.js";import{b as Ts}from"./B3v6bkHV.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=F(),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=F(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function zs(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=F(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}var As=I('<span class="toggle-btn active svelte-r6dy5f" aria-current="page"><!><span class="toggle-label">Details</span></span>'),Is=I('<a class="toggle-btn svelte-r6dy5f"><!><span class="toggle-label">Details</span></a>'),Ps=I('<span class="toggle-btn active svelte-r6dy5f" aria-current="page"><!><span class="toggle-label">Graph</span></span>'),Cs=I('<a class="toggle-btn svelte-r6dy5f" href="/graph"><!><span class="toggle-label">Graph</span></a>'),Es=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 Kr(r,e){St(e,!0);let s=bs(e,"activeView",3,"entity");const n=Rt("chat");var t=Es(),i=j(R(t),2),a=R(i);{var o=b=>{var w=As(),u=R(w);xt(u,{size:14}),ze(),_(w),v(b,w)},l=b=>{var w=Is(),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=Ps(),u=R(w);mt(u,{size:14}),ze(),_(w),v(b,w)},d=b=>{var w=Cs(),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=F(),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)=>{zs(w,{size:14})},$$slots:{default:!0}})};D(L,b=>{n.open||b(O)})}_(g),_(t),v(r,t),Tt()}function Ls(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=F(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function qs(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=F(),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=F(),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(q.caret,"$1"),s=s.replace(t,a),n},getRegex:()=>new RegExp(s,e)};return n}var Ms=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),q={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)}}>`)},Ns=/^(?:[ \t]*(?:\n|$))+/,js=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ds=/^ {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+|$)/,Os=/^ {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(),Zs=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]+)*)/,Hs=/^[^\n]+/,nt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Qs=x(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",nt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ws=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]*?(?:-->|$))/,Gs=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(),Us=x(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ct).getRegex(),it={blockquote:Us,code:js,def:Qs,fences:Ds,heading:Os,hr:Ie,html:Gs,lheading:Pt,list:Ws,newline:Ns,paragraph:Ct,table:he,text:Hs},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(),Vs={...it,lheading:Zs,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()},Fs={...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
- ]`).replace("lheading",Pt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Xs=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Js=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Et=/^( {2,}|\\)\n(?!\s*$)/,Ks=/^(`+|[^`])(?:(?= {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,Ys=x(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,lt).getRegex(),qt=/(?!~)[\p{P}\p{S}]/u,er=/(?!~)[\s\p{P}\p{S}]/u,tr=/(?:[^\s\p{P}\p{S}]|~)/u,Bt=/(?![*_])[\p{P}\p{S}]/u,sr=/(?![*_])[\s\p{P}\p{S}]/u,rr=/(?:[^\s\p{P}\p{S}]|[*_])/u,nr=x(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ms?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Mt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ar=x(Mt,"u").replace(/punct/g,je).getRegex(),ir=x(Mt,"u").replace(/punct/g,qt).getRegex(),Nt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",lr=x(Nt,"gu").replace(/notPunctSpace/g,Lt).replace(/punctSpace/g,lt).replace(/punct/g,je).getRegex(),or=x(Nt,"gu").replace(/notPunctSpace/g,tr).replace(/punctSpace/g,er).replace(/punct/g,qt).getRegex(),cr=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(),hr=x(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Bt).getRegex(),pr="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ur=x(pr,"gu").replace(/notPunctSpace/g,rr).replace(/punctSpace/g,sr).replace(/punct/g,Bt).getRegex(),dr=x(/\\(punct)/,"gu").replace(/punct/g,je).getRegex(),gr=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(),fr=x(at).replace("(?:-->|$)","-->").getRegex(),kr=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",fr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qe=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,xr=x(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),jt=x(/^!?\[(label)\]\[(ref)\]/).replace("label",qe).replace("ref",nt).getRegex(),Dt=x(/^!?\[(ref)\](?:\[\])?/).replace("ref",nt).getRegex(),mr=x("reflink|nolink(?!\\()","g").replace("reflink",jt).replace("nolink",Dt).getRegex(),wt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ot={_backpedal:he,anyPunctuation:dr,autolink:gr,blockSkip:nr,br:Et,code:Js,del:he,delLDelim:he,delRDelim:he,emStrongLDelim:ar,emStrongRDelimAst:lr,emStrongRDelimUnd:cr,escape:Xs,link:xr,nolink:Dt,punctuation:Ys,reflink:jt,reflinkSearch:mr,tag:kr,text:Ks,url:he},br={...ot,link:x(/^!?\[(label)\]\((.*?)\)/).replace("label",qe).getRegex(),reflink:x(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qe).getRegex()},Xe={...ot,emStrongRDelimAst:or,emStrongLDelim:ir,delLDelim:hr,delRDelim:ur,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()},wr={...Xe,br:x(Et).replace("{2,}","*").getRegex(),text:x(Xe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ce={normal:it,gfm:Vs,pedantic:Fs},Re={normal:ot,gfm:Xe,breaks:wr,pedantic:br},vr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},vt=r=>vr[r];function V(r,e){if(e){if(q.escapeTest.test(r))return r.replace(q.escapeReplace,vt)}else if(q.escapeTestNoEncode.test(r))return r.replace(q.escapeReplaceNoEncode,vt);return r}function yt(r){try{r=encodeURI(r).replace(q.percentDecode,"%")}catch{return null}return r}function $t(r,e){let s=r.replace(q.findPipe,(i,a,o)=>{let l=!1,h=a;for(;--h>=0&&o[h]==="\\";)l=!l;return l?"|":" |"}),n=s.split(q.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(q.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 yr(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 $r(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(`
1
+ import{g as ut,c as F,a as v,f as I,d as es,e as ts,b as ss,s as $e,t as rs}from"./CjKjQEMp.js";import{v as ie,h as dt,a as gt,ad as ns,aZ as as,e as ft,C as is,k as ls,aY as os,aS as cs,c as hs,aK as ps,a_ as us,a$ as ds,l as Ge,f as X,p as St,m as Rt,n as Tt,q as j,o as R,u as _,t as ze,z as te,S as Ue,y as p,x as S,T as Ve,_ as gs,P as Fe,D as fs,b0 as ks,V as Pe}from"./D-tW7Byc.js";import{g as zt,e as xs,B as ee,w as ms}from"./ByFfmBEu.js";import{l as xe,s as me,p as bs,i as D,b as ws}from"./EhE2EcYu.js";import{I as be,s as we,n as C,X as vs,a as _e,T as ys,i as Se}from"./pwrC_shA.js";import"./eEhMI0BQ.js";import{b as $s}from"./BV_9Nfp2.js";import{i as _s,g as Ss}from"./C5cMwwSn.js";import{b as Rs}from"./CICthOLY.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=F(),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=F(),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=F(),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=F(),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=F(),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=F(),o=X(a);we(o,e,"default",{}),v(t,a)},$$slots:{default:!0}}))}function qs(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=F(),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(q.caret,"$1"),s=s.replace(t,a),n},getRegex:()=>new RegExp(s,e)};return n}var Bs=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),q={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(),Us={...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()},Vs={...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
+ ]`).replace("lheading",Pt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Fs=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,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(),qt=/(?!~)[\p{P}\p{S}]/u,Ys=/(?!~)[\s\p{P}\p{S}]/u,er=/(?:[^\s\p{P}\p{S}]|~)/u,Bt=/(?![*_])[\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-",Bs?"(?<!`)()":"(^^|[^`])").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,qt).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,qt).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,Bt).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,Bt).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(),qe=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,kr=x(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),jt=x(/^!?\[(label)\]\[(ref)\]/).replace("label",qe).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:Fs,link:kr,nolink:Dt,punctuation:Ks,reflink:jt,reflinkSearch:xr,tag:fr,text:Js,url:he},mr={...ot,link:x(/^!?\[(label)\]\((.*?)\)/).replace("label",qe).getRegex(),reflink:x(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qe).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:Us,pedantic:Vs},Re={normal:ot,gfm:Xe,breaks:br,pedantic:mr},wr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},vt=r=>wr[r];function V(r,e){if(e){if(q.escapeTest.test(r))return r.replace(q.escapeReplace,vt)}else if(q.escapeTestNoEncode.test(r))return r.replace(q.escapeReplaceNoEncode,vt);return r}function yt(r){try{r=encodeURI(r).replace(q.percentDecode,"%")}catch{return null}return r}function $t(r,e){let s=r.replace(q.findPipe,(i,a,o)=>{let l=!1,h=a;for(;--h>=0&&o[h]==="\\";)l=!l;return l?"|":" |"}),n=s.split(q.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(q.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 Be=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,`
5
- `)}}}fences(r){let e=this.rules.block.fences.exec(r);if(e){let s=e[0],n=_r(s,e[3]||"",this.rules);return{type:"code",raw:s,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:n}}}heading(r){let e=this.rules.block.heading.exec(r);if(e){let s=e[2].trim();if(this.rules.other.endingHash.test(s)){let n=Te(s,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(s=n.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(r){let e=this.rules.block.hr.exec(r);if(e)return{type:"hr",raw:Te(e[0],`
5
+ `)}}}fences(r){let e=this.rules.block.fences.exec(r);if(e){let s=e[0],n=$r(s,e[3]||"",this.rules);return{type:"code",raw:s,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:n}}}heading(r){let e=this.rules.block.heading.exec(r);if(e){let s=e[2].trim();if(this.rules.other.endingHash.test(s)){let n=Te(s,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(s=n.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(r){let e=this.rules.block.hr.exec(r);if(e)return{type:"hr",raw:Te(e[0],`
6
6
  `)}}blockquote(r){let e=this.rules.block.blockquote.exec(r);if(e){let s=Te(e[0],`
7
7
  `).split(`
8
8
  `),n="",t="",i=[];for(;s.length>0;){let a=!1,o=[],l;for(l=0;l<s.length;l++)if(this.rules.other.blockquoteStart.test(s[l]))o.push(s[l]),a=!0;else if(!a)o.push(s[l]);else break;s=s.slice(l);let h=o.join(`
@@ -14,7 +14,7 @@ ${c}`:c;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
14
14
  `),L=this.blockquote(m);i[i.length-1]=L,n=n.substring(0,n.length-T.raw.length)+L.raw,t=t.substring(0,t.length-T.text.length)+L.text;break}else if(g?.type==="list"){let T=g,m=T.raw+`
15
15
  `+s.join(`
16
16
  `),L=this.list(m);i[i.length-1]=L,n=n.substring(0,n.length-g.raw.length)+L.raw,t=t.substring(0,t.length-T.raw.length)+L.raw,s=m.substring(i.at(-1).raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:n,tokens:i,text:t}}}list(r){let e=this.rules.block.list.exec(r);if(e){let s=e[1].trim(),n=s.length>1,t={type:"list",raw:"",ordered:n,start:n?+s.slice(0,-1):"",loose:!1,items:[]};s=n?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=n?s:"[*+-]");let i=this.rules.other.listItemRegex(s),a=!1;for(;r;){let l=!1,h="",c="";if(!(e=i.exec(r))||this.rules.block.hr.test(r))break;h=e[0],r=r.substring(h.length);let d=$r(e[2].split(`
17
+ `);continue}}return{type:"blockquote",raw:n,tokens:i,text:t}}}list(r){let e=this.rules.block.list.exec(r);if(e){let s=e[1].trim(),n=s.length>1,t={type:"list",raw:"",ordered:n,start:n?+s.slice(0,-1):"",loose:!1,items:[]};s=n?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=n?s:"[*+-]");let i=this.rules.other.listItemRegex(s),a=!1;for(;r;){let l=!1,h="",c="";if(!(e=i.exec(r))||this.rules.block.hr.test(r))break;h=e[0],r=r.substring(h.length);let d=yr(e[2].split(`
18
18
  `,1)[0],e[1].length),g=r.split(`
19
19
  `,1)[0],T=!d.trim(),m=0;if(this.options.pedantic?(m=2,c=d.trimStart()):T?m=e[1].length+1:(m=d.search(this.rules.other.nonSpaceChar),m=m>4?1:m,c=d.slice(m),m+=e[1].length),T&&this.rules.other.blankLine.test(g)&&(h+=g+`
20
20
  `,r=r.substring(g.length+1),l=!0),!l){let L=this.rules.other.nextBulletRegex(m),O=this.rules.other.hrRegex(m),b=this.rules.other.fencesBeginRegex(m),w=this.rules.other.headingBeginRegex(m),u=this.rules.other.htmlBeginRegex(m),z=this.rules.other.blockquoteBeginRegex(m);for(;r;){let P=r.split(`
@@ -23,7 +23,7 @@ ${c}`:c;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
23
23
  `+g}T=!g.trim(),h+=P+`
24
24
  `,r=r.substring(P.length+1),d=A.slice(m)}}t.loose||(a?t.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(a=!0)),t.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),t.raw+=h}let o=t.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;t.raw=t.raw.trimEnd();for(let l of t.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let c=this.lexer.inlineQueue.length-1;c>=0;c--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)){this.lexer.inlineQueue[c].src=this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask,"");break}}let h=this.rules.other.listTaskCheckbox.exec(l.raw);if(h){let c={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};l.checked=c.checked,t.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=c.raw+l.tokens[0].raw,l.tokens[0].text=c.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(c)):l.tokens.unshift({type:"paragraph",raw:c.raw,text:c.raw,tokens:[c]}):l.tokens.unshift(c)}}if(!t.loose){let h=l.tokens.filter(d=>d.type==="space"),c=h.length>0&&h.some(d=>this.rules.other.anyLine.test(d.raw));t.loose=c}}if(t.loose)for(let l of t.items){l.loose=!0;for(let h of l.tokens)h.type==="text"&&(h.type="paragraph")}return t}}html(r){let e=this.rules.block.html.exec(r);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(r){let e=this.rules.block.def.exec(r);if(e){let s=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",t=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:s,raw:e[0],href:n,title:t}}}table(r){let e=this.rules.block.table.exec(r);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let s=$t(e[1]),n=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),t=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
25
  `):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(s.length===n.length){for(let a of n)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<s.length;a++)i.header.push({text:s[a],tokens:this.lexer.inline(s[a]),header:!0,align:i.align[a]});for(let a of t)i.rows.push($t(a,i.header.length).map((o,l)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:i.align[l]})));return i}}lheading(r){let e=this.rules.block.lheading.exec(r);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(r){let e=this.rules.block.paragraph.exec(r);if(e){let s=e[1].charAt(e[1].length-1)===`
26
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:s,tokens:this.lexer.inline(s)}}}text(r){let e=this.rules.block.text.exec(r);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(r){let e=this.rules.inline.escape.exec(r);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(r){let e=this.rules.inline.tag.exec(r);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(r){let e=this.rules.inline.link.exec(r);if(e){let s=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(s)){if(!this.rules.other.endAngleBracket.test(s))return;let i=Te(s.slice(0,-1),"\\");if((s.length-i.length)%2===0)return}else{let i=yr(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let n=e[2],t="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(n);i&&(n=i[1],t=i[3])}else t=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(s)?n=n.slice(1):n=n.slice(1,-1)),_t(e,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:t&&t.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(r,e){let s;if((s=this.rules.inline.reflink.exec(r))||(s=this.rules.inline.nolink.exec(r))){let n=(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," "),t=e[n.toLowerCase()];if(!t){let i=s[0].charAt(0);return{type:"text",raw:i,text:i}}return _t(s,t,s[0],this.lexer,this.rules)}}emStrong(r,e,s=""){let n=this.rules.inline.emStrongLDelim.exec(r);if(!(!n||n[3]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[2])||!s||this.rules.inline.punctuation.exec(s))){let t=[...n[0]].length-1,i,a,o=t,l=0,h=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*r.length+t);(n=h.exec(e))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i)continue;if(a=[...i].length,n[3]||n[4]){o+=a;continue}else if((n[5]||n[6])&&t%3&&!((t+a)%3)){l+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+l);let c=[...n[0]][0].length,d=r.slice(0,t+n.index+c+a);if(Math.min(t,a)%2){let T=d.slice(1,-1);return{type:"em",raw:d,text:T,tokens:this.lexer.inlineTokens(T)}}let g=d.slice(2,-2);return{type:"strong",raw:d,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(r){let e=this.rules.inline.code.exec(r);if(e){let s=e[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(s),t=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return n&&t&&(s=s.substring(1,s.length-1)),{type:"codespan",raw:e[0],text:s}}}br(r){let e=this.rules.inline.br.exec(r);if(e)return{type:"br",raw:e[0]}}del(r,e,s=""){let n=this.rules.inline.delLDelim.exec(r);if(n&&(!n[1]||!s||this.rules.inline.punctuation.exec(s))){let t=[...n[0]].length-1,i,a,o=t,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*r.length+t);(n=l.exec(e))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i||(a=[...i].length,a!==t))continue;if(n[3]||n[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let h=[...n[0]][0].length,c=r.slice(0,t+n.index+h+a),d=c.slice(t,-t);return{type:"del",raw:c,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(r){let e=this.rules.inline.autolink.exec(r);if(e){let s,n;return e[2]==="@"?(s=e[1],n="mailto:"+s):(s=e[1],n=s),{type:"link",raw:e[0],text:s,href:n,tokens:[{type:"text",raw:s,text:s}]}}}url(r){let e;if(e=this.rules.inline.url.exec(r)){let s,n;if(e[2]==="@")s=e[0],n="mailto:"+s;else{let t;do t=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(t!==e[0]);s=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:s,href:n,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(r){let e=this.rules.inline.text.exec(r);if(e){let s=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:s}}}},Q=class Je{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ue,this.options.tokenizer=this.options.tokenizer||new Be,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let s={other:q,block:Ce.normal,inline:Re.normal};this.options.pedantic?(s.block=Ce.pedantic,s.inline=Re.pedantic):this.options.gfm&&(s.block=Ce.gfm,this.options.breaks?s.inline=Re.breaks:s.inline=Re.gfm),this.tokenizer.rules=s}static get rules(){return{block:Ce,inline:Re}}static lex(e,s){return new Je(s).lex(e)}static lexInline(e,s){return new Je(s).inlineTokens(e)}lex(e){e=e.replace(q.carriageReturn,`
26
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:s,tokens:this.lexer.inline(s)}}}text(r){let e=this.rules.block.text.exec(r);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(r){let e=this.rules.inline.escape.exec(r);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(r){let e=this.rules.inline.tag.exec(r);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(r){let e=this.rules.inline.link.exec(r);if(e){let s=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(s)){if(!this.rules.other.endAngleBracket.test(s))return;let i=Te(s.slice(0,-1),"\\");if((s.length-i.length)%2===0)return}else{let i=vr(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let n=e[2],t="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(n);i&&(n=i[1],t=i[3])}else t=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(s)?n=n.slice(1):n=n.slice(1,-1)),_t(e,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:t&&t.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(r,e){let s;if((s=this.rules.inline.reflink.exec(r))||(s=this.rules.inline.nolink.exec(r))){let n=(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," "),t=e[n.toLowerCase()];if(!t){let i=s[0].charAt(0);return{type:"text",raw:i,text:i}}return _t(s,t,s[0],this.lexer,this.rules)}}emStrong(r,e,s=""){let n=this.rules.inline.emStrongLDelim.exec(r);if(!(!n||n[3]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[2])||!s||this.rules.inline.punctuation.exec(s))){let t=[...n[0]].length-1,i,a,o=t,l=0,h=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*r.length+t);(n=h.exec(e))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i)continue;if(a=[...i].length,n[3]||n[4]){o+=a;continue}else if((n[5]||n[6])&&t%3&&!((t+a)%3)){l+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+l);let c=[...n[0]][0].length,d=r.slice(0,t+n.index+c+a);if(Math.min(t,a)%2){let T=d.slice(1,-1);return{type:"em",raw:d,text:T,tokens:this.lexer.inlineTokens(T)}}let g=d.slice(2,-2);return{type:"strong",raw:d,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(r){let e=this.rules.inline.code.exec(r);if(e){let s=e[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(s),t=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return n&&t&&(s=s.substring(1,s.length-1)),{type:"codespan",raw:e[0],text:s}}}br(r){let e=this.rules.inline.br.exec(r);if(e)return{type:"br",raw:e[0]}}del(r,e,s=""){let n=this.rules.inline.delLDelim.exec(r);if(n&&(!n[1]||!s||this.rules.inline.punctuation.exec(s))){let t=[...n[0]].length-1,i,a,o=t,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*r.length+t);(n=l.exec(e))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i||(a=[...i].length,a!==t))continue;if(n[3]||n[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let h=[...n[0]][0].length,c=r.slice(0,t+n.index+h+a),d=c.slice(t,-t);return{type:"del",raw:c,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(r){let e=this.rules.inline.autolink.exec(r);if(e){let s,n;return e[2]==="@"?(s=e[1],n="mailto:"+s):(s=e[1],n=s),{type:"link",raw:e[0],text:s,href:n,tokens:[{type:"text",raw:s,text:s}]}}}url(r){let e;if(e=this.rules.inline.url.exec(r)){let s,n;if(e[2]==="@")s=e[0],n="mailto:"+s;else{let t;do t=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(t!==e[0]);s=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:s,href:n,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(r){let e=this.rules.inline.text.exec(r);if(e){let s=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:s}}}},Q=class Je{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ue,this.options.tokenizer=this.options.tokenizer||new Be,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let s={other:q,block:Ce.normal,inline:Re.normal};this.options.pedantic?(s.block=Ce.pedantic,s.inline=Re.pedantic):this.options.gfm&&(s.block=Ce.gfm,this.options.breaks?s.inline=Re.breaks:s.inline=Re.gfm),this.tokenizer.rules=s}static get rules(){return{block:Ce,inline:Re}}static lex(e,s){return new Je(s).lex(e)}static lexInline(e,s){return new Je(s).inlineTokens(e)}lex(e){e=e.replace(q.carriageReturn,`
27
27
  `),this.blockTokens(e,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){let n=this.inlineQueue[s];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,s=[],n=!1){for(this.options.pedantic&&(e=e.replace(q.tabCharGlobal," ").replace(q.spaceLine,""));e;){let t;if(this.options.extensions?.block?.some(a=>(t=a.call({lexer:this},e,s))?(e=e.substring(t.raw.length),s.push(t),!0):!1))continue;if(t=this.tokenizer.space(e)){e=e.substring(t.raw.length);let a=s.at(-1);t.raw.length===1&&a!==void 0?a.raw+=`
28
28
  `:s.push(t);continue}if(t=this.tokenizer.code(e)){e=e.substring(t.raw.length);let a=s.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
29
29
  `)?"":`
@@ -55,10 +55,10 @@ ${this.parser.parse(r)}</blockquote>
55
55
  `}tablerow({text:r}){return`<tr>
56
56
  ${r}</tr>
57
57
  `}tablecell(r){let e=this.parser.parseInline(r.tokens),s=r.header?"th":"td";return(r.align?`<${s} align="${r.align}">`:`<${s}>`)+e+`</${s}>
58
- `}strong({tokens:r}){return`<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return`<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return`<code>${V(r,!0)}</code>`}br(r){return"<br>"}del({tokens:r}){return`<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:e,tokens:s}){let n=this.parser.parseInline(s),t=yt(r);if(t===null)return n;r=t;let i='<a href="'+r+'"';return e&&(i+=' title="'+V(e)+'"'),i+=">"+n+"</a>",i}image({href:r,title:e,text:s,tokens:n}){n&&(s=this.parser.parseInline(n,this.parser.textRenderer));let t=yt(r);if(t===null)return V(s);r=t;let i=`<img src="${r}" alt="${V(s)}"`;return e&&(i+=` title="${V(e)}"`),i+=">",i}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:V(r.text)}},ct=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}checkbox({raw:r}){return r}},W=class Ke{options;renderer;textRenderer;constructor(e){this.options=e||ue,this.options.renderer=this.options.renderer||new Me,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ct}static parse(e,s){return new Ke(s).parse(e)}static parseInline(e,s){return new Ke(s).parseInline(e)}parse(e){let s="";for(let n=0;n<e.length;n++){let t=e[n];if(this.options.extensions?.renderers?.[t.type]){let a=t,o=this.options.extensions.renderers[a.type].call({parser:this},a);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){s+=o||"";continue}}let i=t;switch(i.type){case"space":{s+=this.renderer.space(i);break}case"hr":{s+=this.renderer.hr(i);break}case"heading":{s+=this.renderer.heading(i);break}case"code":{s+=this.renderer.code(i);break}case"table":{s+=this.renderer.table(i);break}case"blockquote":{s+=this.renderer.blockquote(i);break}case"list":{s+=this.renderer.list(i);break}case"checkbox":{s+=this.renderer.checkbox(i);break}case"html":{s+=this.renderer.html(i);break}case"def":{s+=this.renderer.def(i);break}case"paragraph":{s+=this.renderer.paragraph(i);break}case"text":{s+=this.renderer.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}parseInline(e,s=this.renderer){let n="";for(let t=0;t<e.length;t++){let i=e[t];if(this.options.extensions?.renderers?.[i.type]){let o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=o||"";continue}}let a=i;switch(a.type){case"escape":{n+=s.text(a);break}case"html":{n+=s.html(a);break}case"link":{n+=s.link(a);break}case"image":{n+=s.image(a);break}case"checkbox":{n+=s.checkbox(a);break}case"strong":{n+=s.strong(a);break}case"em":{n+=s.em(a);break}case"codespan":{n+=s.codespan(a);break}case"br":{n+=s.br(a);break}case"del":{n+=s.del(a);break}case"text":{n+=s.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}},Ae=class{options;block;constructor(r){this.options=r||ue}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}emStrongMask(r){return r}provideLexer(){return this.block?Q.lex:Q.lexInline}provideParser(){return this.block?W.parse:W.parseInline}},Sr=class{defaults=tt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=W;Renderer=Me;TextRenderer=ct;Lexer=Q;Tokenizer=Be;Hooks=Ae;constructor(...r){this.use(...r)}walkTokens(r,e){let s=[];for(let n of r)switch(s=s.concat(e.call(this,n)),n.type){case"table":{let t=n;for(let i of t.header)s=s.concat(this.walkTokens(i.tokens,e));for(let i of t.rows)for(let a of i)s=s.concat(this.walkTokens(a.tokens,e));break}case"list":{let t=n;s=s.concat(this.walkTokens(t.items,e));break}default:{let t=n;this.defaults.extensions?.childTokens?.[t.type]?this.defaults.extensions.childTokens[t.type].forEach(i=>{let a=t[i].flat(1/0);s=s.concat(this.walkTokens(a,e))}):t.tokens&&(s=s.concat(this.walkTokens(t.tokens,e)))}}return s}use(...r){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(s=>{let n={...s};if(n.async=this.defaults.async||n.async||!1,s.extensions&&(s.extensions.forEach(t=>{if(!t.name)throw new Error("extension name required");if("renderer"in t){let i=e.renderers[t.name];i?e.renderers[t.name]=function(...a){let o=t.renderer.apply(this,a);return o===!1&&(o=i.apply(this,a)),o}:e.renderers[t.name]=t.renderer}if("tokenizer"in t){if(!t.level||t.level!=="block"&&t.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[t.level];i?i.unshift(t.tokenizer):e[t.level]=[t.tokenizer],t.start&&(t.level==="block"?e.startBlock?e.startBlock.push(t.start):e.startBlock=[t.start]:t.level==="inline"&&(e.startInline?e.startInline.push(t.start):e.startInline=[t.start]))}"childTokens"in t&&t.childTokens&&(e.childTokens[t.name]=t.childTokens)}),n.extensions=e),s.renderer){let t=this.defaults.renderer||new Me(this.defaults);for(let i in s.renderer){if(!(i in t))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,o=s.renderer[a],l=t[a];t[a]=(...h)=>{let c=o.apply(t,h);return c===!1&&(c=l.apply(t,h)),c||""}}n.renderer=t}if(s.tokenizer){let t=this.defaults.tokenizer||new Be(this.defaults);for(let i in s.tokenizer){if(!(i in t))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,o=s.tokenizer[a],l=t[a];t[a]=(...h)=>{let c=o.apply(t,h);return c===!1&&(c=l.apply(t,h)),c}}n.tokenizer=t}if(s.hooks){let t=this.defaults.hooks||new Ae;for(let i in s.hooks){if(!(i in t))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,o=s.hooks[a],l=t[a];Ae.passThroughHooks.has(i)?t[a]=h=>{if(this.defaults.async&&Ae.passThroughHooksRespectAsync.has(i))return(async()=>{let d=await o.call(t,h);return l.call(t,d)})();let c=o.call(t,h);return l.call(t,c)}:t[a]=(...h)=>{if(this.defaults.async)return(async()=>{let d=await o.apply(t,h);return d===!1&&(d=await l.apply(t,h)),d})();let c=o.apply(t,h);return c===!1&&(c=l.apply(t,h)),c}}n.hooks=t}if(s.walkTokens){let t=this.defaults.walkTokens,i=s.walkTokens;n.walkTokens=function(a){let o=[];return o.push(i.call(this,a)),t&&(o=o.concat(t.call(this,a))),o}}this.defaults={...this.defaults,...n}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,e){return Q.lex(r,e??this.defaults)}parser(r,e){return W.parse(r,e??this.defaults)}parseMarkdown(r){return(e,s)=>{let n={...s},t={...this.defaults,...n},i=this.onError(!!t.silent,!!t.async);if(this.defaults.async===!0&&n.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(t.hooks&&(t.hooks.options=t,t.hooks.block=r),t.async)return(async()=>{let a=t.hooks?await t.hooks.preprocess(e):e,o=await(t.hooks?await t.hooks.provideLexer():r?Q.lex:Q.lexInline)(a,t),l=t.hooks?await t.hooks.processAllTokens(o):o;t.walkTokens&&await Promise.all(this.walkTokens(l,t.walkTokens));let h=await(t.hooks?await t.hooks.provideParser():r?W.parse:W.parseInline)(l,t);return t.hooks?await t.hooks.postprocess(h):h})().catch(i);try{t.hooks&&(e=t.hooks.preprocess(e));let a=(t.hooks?t.hooks.provideLexer():r?Q.lex:Q.lexInline)(e,t);t.hooks&&(a=t.hooks.processAllTokens(a)),t.walkTokens&&this.walkTokens(a,t.walkTokens);let o=(t.hooks?t.hooks.provideParser():r?W.parse:W.parseInline)(a,t);return t.hooks&&(o=t.hooks.postprocess(o)),o}catch(a){return i(a)}}}onError(r,e){return s=>{if(s.message+=`
59
- Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error occurred:</p><pre>"+V(s.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(s);throw s}}},pe=new Sr;function y(r,e){return pe.parse(r,e)}y.options=y.setOptions=function(r){return pe.setOptions(r),y.defaults=pe.defaults,At(y.defaults),y};y.getDefaults=tt;y.defaults=ue;y.use=function(...r){return pe.use(...r),y.defaults=pe.defaults,At(y.defaults),y};y.walkTokens=function(r,e){return pe.walkTokens(r,e)};y.parseInline=pe.parseInline;y.Parser=W;y.parser=W.parse;y.Renderer=Me;y.TextRenderer=ct;y.Lexer=Q;y.lexer=Q.lex;y.Tokenizer=Be;y.Hooks=Ae;y.parse=y;y.options;y.setOptions;y.use;y.walkTokens;y.parseInline;W.parse;Q.lex;function Rr(r,e,s){fetch("/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:s}).then(async n=>{if(!n.ok){e({type:"error",message:`HTTP ${n.status}`});return}const t=n.body?.getReader();if(!t){e({type:"error",message:"No response body"});return}const i=new TextDecoder;let a="";for(;;){const{done:o,value:l}=await t.read();if(o)break;a+=i.decode(l,{stream:!0});const h=a.split(`
60
- `);a=h.pop()??"";for(const c of h)if(c.startsWith("data: "))try{const d=JSON.parse(c.slice(6));e(d)}catch{}}}).catch(n=>{n.name!=="AbortError"&&e({type:"error",message:n.message})})}const Ye="sg-chat-sessions",et="sg-chat-version",Tr=14;function ce(){try{const r=localStorage.getItem(Ye);if(!r)return[];if(localStorage.getItem(et)==="2")return JSON.parse(r);const n=JSON.parse(r).map(t=>({id:crypto.randomUUID(),createdAt:t.date+"T00:00:00.000Z",updatedAt:t.date+"T00:00:00.000Z",title:t.messages.find(i=>i.role==="user")?.content.slice(0,50)||"New chat",messages:t.messages}));return localStorage.setItem(Ye,JSON.stringify(n)),localStorage.setItem(et,"2"),n}catch{return[]}}function Le(r){const s=[...r].sort((n,t)=>t.updatedAt.localeCompare(n.updatedAt)).slice(0,Tr);try{localStorage.setItem(Ye,JSON.stringify(s)),localStorage.setItem(et,"2")}catch{}}function Ee(r,e){const s=ce(),n=e.map(({streaming:i,...a})=>a),t=s.findIndex(i=>i.id===r);t>=0&&(s[t].messages=n,s[t].updatedAt=new Date().toISOString()),Le(s)}function zr(){const e=ce().sort((u,z)=>z.updatedAt.localeCompare(u.updatedAt))[0];let s=te(Ue(e?e.messages.map(u=>({...u,streaming:!1})):[])),n=te(Ue(e?.id??null)),t=te(!1),i=te(0),a=te(0),o=te(null),l=null,h=te(Ue(!!e));const c=new Set(["create_entity","update_entity","delete_entity","move_entity"]);function d(){m();const u=crypto.randomUUID();S(n,u,!0),S(s,[],!0),S(h,!1)}function g(){if(p(n)&&p(h))return p(n);const u=p(n)||crypto.randomUUID();S(n,u,!0);const z=new Date().toISOString(),P=ce();return P.push({id:u,createdAt:z,updatedAt:z,title:"New chat",messages:[]}),Le(P),S(h,!0),u}function T(u){if(!u.trim()||p(t))return;S(o,null);const z=g();p(s).push({role:"user",content:u}),p(s).push({role:"agent",content:"",segments:[],streaming:!0}),S(t,!0);const P=ce(),A=P.find(k=>k.id===z);A&&A.title==="New chat"&&(A.title=u.slice(0,50),Le(P)),Ee(z,p(s));let G=!1,J=null;l=new AbortController;const De=C.selectedSubPath?`${C.selectedRepo}/${C.selectedType}/${C.selectedId}/${C.selectedSubPath}`:C.selectedId?`${C.selectedRepo}/${C.selectedType}/${C.selectedId}`:null,se=p(s).slice(0,-2).map(k=>({role:k.role==="agent"?"assistant":k.role,content:k.content})),Oe={message:u,context:De??void 0,sessionId:z,history:se.length>0?se:void 0};Rr(Oe,k=>{const B=p(s)[p(s).length-1];if(!B||B.role!=="agent")return;const Z=B.segments;switch(k.type){case"token":{B.content+=k.text??"";const H=Z[Z.length-1];H&&H.type==="text"?H.content+=k.text??"":Z.push({type:"text",content:k.text??""}),B.segments=Z,Ve(a);break}case"tool_start":if(k.name){c.has(k.name)&&(G=!0);const H=Z[Z.length-1];H&&H.type==="tools"?H.names=[...H.names,k.name]:Z.push({type:"tools",names:[k.name]}),B.segments=Z,Ve(a)}break;case"mutation":G=!0,k.action==="created"&&k.repo&&k.entityType&&k.entityId&&(J={repo:k.repo,entityType:k.entityType,entityId:k.entityId}),window.StudioChrome?.emitMutation?.({action:k.action,repo:k.repo,entityType:k.entityType,entityId:k.entityId});break;case"highlight":S(o,k.entityIds&&k.entityIds.length>0?new Set(k.entityIds):null,!0);break;case"done":k.message&&!B.content&&(B.content=k.message,B.segments=[{type:"text",content:k.message}]),B.streaming=!1,S(t,!1),Ee(z,p(s)),G&&(Ss().then(()=>{Ve(i)}),ms.refreshAll().then(()=>{J&&Rs(`/${J.repo}/${J.entityType}/${J.entityId}`)}),vs.refreshAll());break;case"error":B.content+=`
58
+ `}strong({tokens:r}){return`<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return`<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return`<code>${V(r,!0)}</code>`}br(r){return"<br>"}del({tokens:r}){return`<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:e,tokens:s}){let n=this.parser.parseInline(s),t=yt(r);if(t===null)return n;r=t;let i='<a href="'+r+'"';return e&&(i+=' title="'+V(e)+'"'),i+=">"+n+"</a>",i}image({href:r,title:e,text:s,tokens:n}){n&&(s=this.parser.parseInline(n,this.parser.textRenderer));let t=yt(r);if(t===null)return V(s);r=t;let i=`<img src="${r}" alt="${V(s)}"`;return e&&(i+=` title="${V(e)}"`),i+=">",i}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:V(r.text)}},ct=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}checkbox({raw:r}){return r}},W=class Ke{options;renderer;textRenderer;constructor(e){this.options=e||ue,this.options.renderer=this.options.renderer||new Me,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ct}static parse(e,s){return new Ke(s).parse(e)}static parseInline(e,s){return new Ke(s).parseInline(e)}parse(e){let s="";for(let n=0;n<e.length;n++){let t=e[n];if(this.options.extensions?.renderers?.[t.type]){let a=t,o=this.options.extensions.renderers[a.type].call({parser:this},a);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){s+=o||"";continue}}let i=t;switch(i.type){case"space":{s+=this.renderer.space(i);break}case"hr":{s+=this.renderer.hr(i);break}case"heading":{s+=this.renderer.heading(i);break}case"code":{s+=this.renderer.code(i);break}case"table":{s+=this.renderer.table(i);break}case"blockquote":{s+=this.renderer.blockquote(i);break}case"list":{s+=this.renderer.list(i);break}case"checkbox":{s+=this.renderer.checkbox(i);break}case"html":{s+=this.renderer.html(i);break}case"def":{s+=this.renderer.def(i);break}case"paragraph":{s+=this.renderer.paragraph(i);break}case"text":{s+=this.renderer.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}parseInline(e,s=this.renderer){let n="";for(let t=0;t<e.length;t++){let i=e[t];if(this.options.extensions?.renderers?.[i.type]){let o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=o||"";continue}}let a=i;switch(a.type){case"escape":{n+=s.text(a);break}case"html":{n+=s.html(a);break}case"link":{n+=s.link(a);break}case"image":{n+=s.image(a);break}case"checkbox":{n+=s.checkbox(a);break}case"strong":{n+=s.strong(a);break}case"em":{n+=s.em(a);break}case"codespan":{n+=s.codespan(a);break}case"br":{n+=s.br(a);break}case"del":{n+=s.del(a);break}case"text":{n+=s.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}},Ae=class{options;block;constructor(r){this.options=r||ue}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}emStrongMask(r){return r}provideLexer(){return this.block?Q.lex:Q.lexInline}provideParser(){return this.block?W.parse:W.parseInline}},_r=class{defaults=tt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=W;Renderer=Me;TextRenderer=ct;Lexer=Q;Tokenizer=Be;Hooks=Ae;constructor(...r){this.use(...r)}walkTokens(r,e){let s=[];for(let n of r)switch(s=s.concat(e.call(this,n)),n.type){case"table":{let t=n;for(let i of t.header)s=s.concat(this.walkTokens(i.tokens,e));for(let i of t.rows)for(let a of i)s=s.concat(this.walkTokens(a.tokens,e));break}case"list":{let t=n;s=s.concat(this.walkTokens(t.items,e));break}default:{let t=n;this.defaults.extensions?.childTokens?.[t.type]?this.defaults.extensions.childTokens[t.type].forEach(i=>{let a=t[i].flat(1/0);s=s.concat(this.walkTokens(a,e))}):t.tokens&&(s=s.concat(this.walkTokens(t.tokens,e)))}}return s}use(...r){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(s=>{let n={...s};if(n.async=this.defaults.async||n.async||!1,s.extensions&&(s.extensions.forEach(t=>{if(!t.name)throw new Error("extension name required");if("renderer"in t){let i=e.renderers[t.name];i?e.renderers[t.name]=function(...a){let o=t.renderer.apply(this,a);return o===!1&&(o=i.apply(this,a)),o}:e.renderers[t.name]=t.renderer}if("tokenizer"in t){if(!t.level||t.level!=="block"&&t.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[t.level];i?i.unshift(t.tokenizer):e[t.level]=[t.tokenizer],t.start&&(t.level==="block"?e.startBlock?e.startBlock.push(t.start):e.startBlock=[t.start]:t.level==="inline"&&(e.startInline?e.startInline.push(t.start):e.startInline=[t.start]))}"childTokens"in t&&t.childTokens&&(e.childTokens[t.name]=t.childTokens)}),n.extensions=e),s.renderer){let t=this.defaults.renderer||new Me(this.defaults);for(let i in s.renderer){if(!(i in t))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,o=s.renderer[a],l=t[a];t[a]=(...h)=>{let c=o.apply(t,h);return c===!1&&(c=l.apply(t,h)),c||""}}n.renderer=t}if(s.tokenizer){let t=this.defaults.tokenizer||new Be(this.defaults);for(let i in s.tokenizer){if(!(i in t))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,o=s.tokenizer[a],l=t[a];t[a]=(...h)=>{let c=o.apply(t,h);return c===!1&&(c=l.apply(t,h)),c}}n.tokenizer=t}if(s.hooks){let t=this.defaults.hooks||new Ae;for(let i in s.hooks){if(!(i in t))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,o=s.hooks[a],l=t[a];Ae.passThroughHooks.has(i)?t[a]=h=>{if(this.defaults.async&&Ae.passThroughHooksRespectAsync.has(i))return(async()=>{let d=await o.call(t,h);return l.call(t,d)})();let c=o.call(t,h);return l.call(t,c)}:t[a]=(...h)=>{if(this.defaults.async)return(async()=>{let d=await o.apply(t,h);return d===!1&&(d=await l.apply(t,h)),d})();let c=o.apply(t,h);return c===!1&&(c=l.apply(t,h)),c}}n.hooks=t}if(s.walkTokens){let t=this.defaults.walkTokens,i=s.walkTokens;n.walkTokens=function(a){let o=[];return o.push(i.call(this,a)),t&&(o=o.concat(t.call(this,a))),o}}this.defaults={...this.defaults,...n}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,e){return Q.lex(r,e??this.defaults)}parser(r,e){return W.parse(r,e??this.defaults)}parseMarkdown(r){return(e,s)=>{let n={...s},t={...this.defaults,...n},i=this.onError(!!t.silent,!!t.async);if(this.defaults.async===!0&&n.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(t.hooks&&(t.hooks.options=t,t.hooks.block=r),t.async)return(async()=>{let a=t.hooks?await t.hooks.preprocess(e):e,o=await(t.hooks?await t.hooks.provideLexer():r?Q.lex:Q.lexInline)(a,t),l=t.hooks?await t.hooks.processAllTokens(o):o;t.walkTokens&&await Promise.all(this.walkTokens(l,t.walkTokens));let h=await(t.hooks?await t.hooks.provideParser():r?W.parse:W.parseInline)(l,t);return t.hooks?await t.hooks.postprocess(h):h})().catch(i);try{t.hooks&&(e=t.hooks.preprocess(e));let a=(t.hooks?t.hooks.provideLexer():r?Q.lex:Q.lexInline)(e,t);t.hooks&&(a=t.hooks.processAllTokens(a)),t.walkTokens&&this.walkTokens(a,t.walkTokens);let o=(t.hooks?t.hooks.provideParser():r?W.parse:W.parseInline)(a,t);return t.hooks&&(o=t.hooks.postprocess(o)),o}catch(a){return i(a)}}}onError(r,e){return s=>{if(s.message+=`
59
+ Please report this to https://github.com/markedjs/marked.`,r){let n="<p>An error occurred:</p><pre>"+V(s.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(s);throw s}}},pe=new _r;function y(r,e){return pe.parse(r,e)}y.options=y.setOptions=function(r){return pe.setOptions(r),y.defaults=pe.defaults,At(y.defaults),y};y.getDefaults=tt;y.defaults=ue;y.use=function(...r){return pe.use(...r),y.defaults=pe.defaults,At(y.defaults),y};y.walkTokens=function(r,e){return pe.walkTokens(r,e)};y.parseInline=pe.parseInline;y.Parser=W;y.parser=W.parse;y.Renderer=Me;y.TextRenderer=ct;y.Lexer=Q;y.lexer=Q.lex;y.Tokenizer=Be;y.Hooks=Ae;y.parse=y;y.options;y.setOptions;y.use;y.walkTokens;y.parseInline;W.parse;Q.lex;function Sr(r,e,s){fetch("/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:s}).then(async n=>{if(!n.ok){e({type:"error",message:`HTTP ${n.status}`});return}const t=n.body?.getReader();if(!t){e({type:"error",message:"No response body"});return}const i=new TextDecoder;let a="";for(;;){const{done:o,value:l}=await t.read();if(o)break;a+=i.decode(l,{stream:!0});const h=a.split(`
60
+ `);a=h.pop()??"";for(const c of h)if(c.startsWith("data: "))try{const d=JSON.parse(c.slice(6));e(d)}catch{}}}).catch(n=>{n.name!=="AbortError"&&e({type:"error",message:n.message})})}const Ye="sg-chat-sessions",et="sg-chat-version",Rr=14;function ce(){try{const r=localStorage.getItem(Ye);if(!r)return[];if(localStorage.getItem(et)==="2")return JSON.parse(r);const n=JSON.parse(r).map(t=>({id:crypto.randomUUID(),createdAt:t.date+"T00:00:00.000Z",updatedAt:t.date+"T00:00:00.000Z",title:t.messages.find(i=>i.role==="user")?.content.slice(0,50)||"New chat",messages:t.messages}));return localStorage.setItem(Ye,JSON.stringify(n)),localStorage.setItem(et,"2"),n}catch{return[]}}function Le(r){const s=[...r].sort((n,t)=>t.updatedAt.localeCompare(n.updatedAt)).slice(0,Rr);try{localStorage.setItem(Ye,JSON.stringify(s)),localStorage.setItem(et,"2")}catch{}}function Ee(r,e){const s=ce(),n=e.map(({streaming:i,...a})=>a),t=s.findIndex(i=>i.id===r);t>=0&&(s[t].messages=n,s[t].updatedAt=new Date().toISOString()),Le(s)}function Tr(){const e=ce().sort((u,z)=>z.updatedAt.localeCompare(u.updatedAt))[0];let s=te(Ue(e?e.messages.map(u=>({...u,streaming:!1})):[])),n=te(Ue(e?.id??null)),t=te(!1),i=te(0),a=te(0),o=te(null),l=null,h=te(Ue(!!e));const c=new Set(["create_entity","update_entity","delete_entity","move_entity"]);function d(){m();const u=crypto.randomUUID();S(n,u,!0),S(s,[],!0),S(h,!1)}function g(){if(p(n)&&p(h))return p(n);const u=p(n)||crypto.randomUUID();S(n,u,!0);const z=new Date().toISOString(),P=ce();return P.push({id:u,createdAt:z,updatedAt:z,title:"New chat",messages:[]}),Le(P),S(h,!0),u}function T(u){if(!u.trim()||p(t))return;S(o,null);const z=g();p(s).push({role:"user",content:u}),p(s).push({role:"agent",content:"",segments:[],streaming:!0}),S(t,!0);const P=ce(),A=P.find(k=>k.id===z);A&&A.title==="New chat"&&(A.title=u.slice(0,50),Le(P)),Ee(z,p(s));let G=!1,J=null;l=new AbortController;const De=C.selectedSubPath?`${C.selectedRepo}/${C.selectedType}/${C.selectedId}/${C.selectedSubPath}`:C.selectedId?`${C.selectedRepo}/${C.selectedType}/${C.selectedId}`:null,se=p(s).slice(0,-2).map(k=>({role:k.role==="agent"?"assistant":k.role,content:k.content})),Oe={message:u,context:De??void 0,sessionId:z,history:se.length>0?se:void 0};Sr(Oe,k=>{const B=p(s)[p(s).length-1];if(!B||B.role!=="agent")return;const Z=B.segments;switch(k.type){case"token":{B.content+=k.text??"";const H=Z[Z.length-1];H&&H.type==="text"?H.content+=k.text??"":Z.push({type:"text",content:k.text??""}),B.segments=Z,Ve(a);break}case"tool_start":if(k.name){c.has(k.name)&&(G=!0);const H=Z[Z.length-1];H&&H.type==="tools"?H.names=[...H.names,k.name]:Z.push({type:"tools",names:[k.name]}),B.segments=Z,Ve(a)}break;case"mutation":G=!0,k.action==="created"&&k.repo&&k.entityType&&k.entityId&&(J={repo:k.repo,entityType:k.entityType,entityId:k.entityId}),window.StudioChrome?.emitMutation?.({action:k.action,repo:k.repo,entityType:k.entityType,entityId:k.entityId});break;case"highlight":S(o,k.entityIds&&k.entityIds.length>0?new Set(k.entityIds):null,!0);break;case"done":k.message&&!B.content&&(B.content=k.message,B.segments=[{type:"text",content:k.message}]),B.streaming=!1,S(t,!1),Ee(z,p(s)),G&&(_s().then(()=>{Ve(i)}),ms.refreshAll().then(()=>{J&&Ss(`/${J.repo}/${J.entityType}/${J.entityId}`)}));break;case"error":B.content+=`
61
61
 
62
- Error: ${k.message}`,B.streaming=!1,S(t,!1),Ee(z,p(s));break}},l.signal)}function m(){l?.abort(),S(t,!1);const u=p(s)[p(s).length-1];u?.streaming&&(u.streaming=!1)}function L(){m(),S(s,[],!0),p(n)&&p(h)&&Ee(p(n),p(s))}function O(u){const P=ce().filter(A=>A.id!==u);if(Le(P),p(n)===u){const A=P.sort((G,J)=>J.updatedAt.localeCompare(G.updatedAt));A.length>0?(S(n,A[0].id,!0),S(s,A[0].messages.map(G=>({...G,streaming:!1})),!0),S(h,!0)):(S(n,null),S(s,[],!0),S(h,!1))}}function b(u){const P=ce().find(A=>A.id===u);P&&(m(),S(n,P.id,!0),S(s,P.messages.map(A=>({...A,streaming:!1})),!0),S(h,!0))}function w(){return ce().sort((u,z)=>z.updatedAt.localeCompare(u.updatedAt)).map(u=>({id:u.id,title:u.title,createdAt:u.createdAt,updatedAt:u.updatedAt,preview:u.messages.find(z=>z.role==="user")?.content.slice(0,80)||"",count:u.messages.length,active:u.id===p(n)}))}return{get messages(){return p(s)},get streaming(){return p(t)},get mutationCount(){return p(i)},get scrollTick(){return p(a)},get highlightedIds(){return p(o)},get activeSessionId(){return p(n)},send:T,stop:m,clear:L,newSession:d,deleteSession:O,getSessions:w,loadSession:b}}const M=zr();var Ar=I('<span class="session-title svelte-1xwj6s7"> </span>'),Ir=I('<div class="session-row svelte-1xwj6s7"><!> <!></div>'),Pr=I('<div class="session-dropdown svelte-1xwj6s7"><div class="session-list svelte-1xwj6s7"></div></div>'),Cr=I('<div class="empty-state svelte-1xwj6s7"><div class="seed-prompts svelte-1xwj6s7"></div></div>'),Er=I('<div class="user-bubble svelte-1xwj6s7"> </div>'),Lr=I('<span class="tool-call svelte-1xwj6s7"> </span>'),qr=I('<div class="tool-calls svelte-1xwj6s7"></div>'),Br=I('<div class="agent-text prose svelte-1xwj6s7"><!></div>'),Mr=I('<div class="agent-text prose svelte-1xwj6s7"><!></div>'),Nr=I('<span class="streaming-dot svelte-1xwj6s7"></span>'),jr=I('<div class="agent-content svelte-1xwj6s7"><!> <!></div>'),Dr=I('<div class="message-group svelte-1xwj6s7"><!></div>'),Or=I('<div class="context-chip svelte-1xwj6s7"> </div>'),Zr=I('<aside class="chat-panel svelte-1xwj6s7"><div class="chat-header svelte-1xwj6s7"><div class="chat-header-left svelte-1xwj6s7"><!> <!></div> <!> <!></div> <div class="chat-messages svelte-1xwj6s7"><!></div> <div class="chat-input-area svelte-1xwj6s7"><!> <div class="text-input svelte-1xwj6s7"><textarea class="input-field svelte-1xwj6s7" rows="1"></textarea> <!></div></div></aside>');function Yr(r,e){St(e,!0);const s=/[\p{Emoji_Presentation}\p{Extended_Pictographic}]\uFE0F?/gu,n=/^\|[\s:|-]+\|$/,t=/^[ ]{0,3}([-*_])\s*(\1\s*){2,}$/;function i(f){return f.replace(s,"").replace(/^ +/gm,$=>$.replace(/ +/," ")).split(`
62
+ Error: ${k.message}`,B.streaming=!1,S(t,!1),Ee(z,p(s));break}},l.signal)}function m(){l?.abort(),S(t,!1);const u=p(s)[p(s).length-1];u?.streaming&&(u.streaming=!1)}function L(){m(),S(s,[],!0),p(n)&&p(h)&&Ee(p(n),p(s))}function O(u){const P=ce().filter(A=>A.id!==u);if(Le(P),p(n)===u){const A=P.sort((G,J)=>J.updatedAt.localeCompare(G.updatedAt));A.length>0?(S(n,A[0].id,!0),S(s,A[0].messages.map(G=>({...G,streaming:!1})),!0),S(h,!0)):(S(n,null),S(s,[],!0),S(h,!1))}}function b(u){const P=ce().find(A=>A.id===u);P&&(m(),S(n,P.id,!0),S(s,P.messages.map(A=>({...A,streaming:!1})),!0),S(h,!0))}function w(){return ce().sort((u,z)=>z.updatedAt.localeCompare(u.updatedAt)).map(u=>({id:u.id,title:u.title,createdAt:u.createdAt,updatedAt:u.updatedAt,preview:u.messages.find(z=>z.role==="user")?.content.slice(0,80)||"",count:u.messages.length,active:u.id===p(n)}))}return{get messages(){return p(s)},get streaming(){return p(t)},get mutationCount(){return p(i)},get scrollTick(){return p(a)},get highlightedIds(){return p(o)},get activeSessionId(){return p(n)},send:T,stop:m,clear:L,newSession:d,deleteSession:O,getSessions:w,loadSession:b}}const M=Tr();var zr=I('<span class="session-title svelte-1xwj6s7"> </span>'),Ar=I('<div class="session-row svelte-1xwj6s7"><!> <!></div>'),Ir=I('<div class="session-dropdown svelte-1xwj6s7"><div class="session-list svelte-1xwj6s7"></div></div>'),Pr=I('<div class="empty-state svelte-1xwj6s7"><div class="seed-prompts svelte-1xwj6s7"></div></div>'),Cr=I('<div class="user-bubble svelte-1xwj6s7"> </div>'),Er=I('<span class="tool-call svelte-1xwj6s7"> </span>'),Lr=I('<div class="tool-calls svelte-1xwj6s7"></div>'),qr=I('<div class="agent-text prose svelte-1xwj6s7"><!></div>'),Br=I('<div class="agent-text prose svelte-1xwj6s7"><!></div>'),Mr=I('<span class="streaming-dot svelte-1xwj6s7"></span>'),Nr=I('<div class="agent-content svelte-1xwj6s7"><!> <!></div>'),jr=I('<div class="message-group svelte-1xwj6s7"><!></div>'),Dr=I('<div class="context-chip svelte-1xwj6s7"> </div>'),Or=I('<aside class="chat-panel svelte-1xwj6s7"><div class="chat-header svelte-1xwj6s7"><div class="chat-header-left svelte-1xwj6s7"><!> <!></div> <!> <!></div> <div class="chat-messages svelte-1xwj6s7"><!></div> <div class="chat-input-area svelte-1xwj6s7"><!> <div class="text-input svelte-1xwj6s7"><textarea class="input-field svelte-1xwj6s7" rows="1"></textarea> <!></div></div></aside>');function Kr(r,e){St(e,!0);const s=/[\p{Emoji_Presentation}\p{Extended_Pictographic}]\uFE0F?/gu,n=/^\|[\s:|-]+\|$/,t=/^[ ]{0,3}([-*_])\s*(\1\s*){2,}$/;function i(f){return f.replace(s,"").replace(/^ +/gm,$=>$.replace(/ +/," ")).split(`
63
63
  `).map($=>n.test($)||t.test($)?$:$.replace(/--/g,"—")).join(`
64
- `)}const a=Rt("chat");let o=te(""),l=te(!1);const h=Pe(()=>(M.activeSessionId,M.getSessions().length>0));let c,d=!0;function g(){c&&(d=c.scrollHeight-c.scrollTop-c.clientHeight<40)}const T=Pe(()=>{if(C.selectedSubPath)return["Summarize this document","Extract key points","What actions are here?","What decisions were made?"];if(C.selectedId){const f=C.selectedType??"entity";return[`Summarize this ${f}`,`What's related to this ${f}?`,"What actions should I take?","What decisions were made?"]}return C.activeView==="graph"?["What are the key relationships?","Which entities are most connected?","Find gaps in my graph","What decisions have been made recently?"]:["What's in my graph?","Summarize recent meetings","Who's working on what?","What decisions have been made recently?"]});async function m(){const f=p(o).trim();f&&(S(o,""),d=!0,M.send(f),await Fe(),O())}function L(f){f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),m())}function O(){c&&(c.scrollTop=c.scrollHeight)}gs(()=>{Fe().then(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>O())})})}),fs(()=>{M.scrollTick,d&&O()});var b=Zr(),w=R(b),u=R(w),z=R(u);ee(z,{variant:"ghost",size:"icon",class:"size-6",onclick:()=>M.newSession(),children:(f,$)=>{qs(f,{size:14})},$$slots:{default:!0}});var P=j(z,2);{var A=f=>{{let $=Pe(()=>p(l)?"history-active":"");ee(f,{variant:"ghost",size:"icon",get class(){return`size-6 ${p($)??""}`},onclick:()=>S(l,!p(l)),children:(N,ge)=>{Bs(N,{size:14})},$$slots:{default:!0}})}};D(P,f=>{p(h)&&f(A)})}_(u);var G=j(u,2);ee(G,{variant:"ghost",size:"icon",class:"size-6",get onclick(){return a.close},children:(f,$)=>{ys(f,{size:14})},$$slots:{default:!0}});var J=j(G,2);{var De=f=>{var $=Pr(),N=R($);_e(N,21,()=>M.getSessions(),Se,(ge,E)=>{var K=Ir(),ve=R(K);{let le=Pe(()=>p(E).active?"active":"");ee(ve,{variant:"ghost",get class(){return`session-item ${p(le)??""}`},onclick:()=>{M.loadSession(p(E).id),S(l,!1)},children:(Y,re)=>{var ne=Ar(),Ze=R(ne,!0);_(ne),ie(()=>$e(Ze,p(E).title)),v(Y,ne)},$$slots:{default:!0}})}var fe=j(ve,2);ee(fe,{variant:"ghost",size:"icon",class:"session-delete-btn",title:"Delete session",onclick:le=>{le.stopPropagation(),M.deleteSession(p(E).id)},children:(le,Y)=>{$s(le,{size:12})},$$slots:{default:!0}}),_(K),v(ge,K)}),_(N),_($),v(f,$)};D(J,f=>{p(l)&&f(De)})}_(w);var se=j(w,2),Oe=R(se);{var k=f=>{var $=Cr(),N=R($);_e(N,21,()=>p(T),Se,(ge,E)=>{ee(ge,{variant:"outline",class:"seed-prompt",onclick:()=>{d=!0,M.send(p(E)),Fe().then(()=>O())},children:(K,ve)=>{ze();var fe=rs();ie(()=>$e(fe,p(E))),v(K,fe)},$$slots:{default:!0}})}),_(N),_($),v(f,$)},B=f=>{var $=F(),N=X($);_e(N,17,()=>M.messages,Se,(ge,E)=>{var K=Dr(),ve=R(K);{var fe=Y=>{var re=Er(),ne=R(re,!0);_(re),ie(()=>$e(ne,p(E).content)),v(Y,re)},le=Y=>{var re=jr(),ne=R(re);{var Ze=U=>{var ae=F(),He=X(ae);_e(He,17,()=>p(E).segments,Se,(Vt,ye)=>{var pt=F(),Ft=X(pt);{var Xt=ke=>{var oe=qr();_e(oe,21,()=>p(ye).names,Se,(Qe,Kt)=>{var We=Lr(),Yt=R(We,!0);_(We),ie(()=>$e(Yt,p(Kt))),v(Qe,We)}),_(oe),v(ke,oe)},Jt=ke=>{var oe=Br(),Qe=R(oe);kt(Qe,()=>y.parse(i(p(ye).content))),_(oe),v(ke,oe)};D(Ft,ke=>{p(ye).type==="tools"?ke(Xt):p(ye).type==="text"&&p(ye).content&&ke(Jt,1)})}v(Vt,pt)}),v(U,ae)},Wt=U=>{var ae=Mr(),He=R(ae);kt(He,()=>y.parse(i(p(E).content))),_(ae),v(U,ae)};D(ne,U=>{p(E).segments&&p(E).segments.length>0?U(Ze):p(E).content&&U(Wt,1)})}var Gt=j(ne,2);{var Ut=U=>{var ae=Nr();v(U,ae)};D(Gt,U=>{p(E).streaming&&U(Ut)})}_(re),v(Y,re)};D(ve,Y=>{p(E).role==="user"?Y(fe):Y(le,!1)})}_(K),v(ge,K)}),v(f,$)};D(Oe,f=>{M.messages.length===0?f(k):f(B,!1)})}_(se),ws(se,f=>c=f,()=>c);var Z=j(se,2),H=R(Z);{var Ot=f=>{var $=Or(),N=R($);_($),ie(()=>$e(N,`${C.selectedType??""}/${C.selectedId??""}`)),v(f,$)};D(H,f=>{C.selectedId&&f(Ot)})}var ht=j(H,2),de=R(ht);ks(de);var Zt=j(de,2);{var Ht=f=>{ee(f,{variant:"ghost",size:"icon",class:"size-7 stop-btn send-btn",onclick:()=>M.stop(),children:($,N)=>{Ls($,{size:16})},$$slots:{default:!0}})},Qt=f=>{ee(f,{variant:"ghost",size:"icon",class:"size-7 send-btn",onclick:m,children:($,N)=>{Ts($,{size:14})},$$slots:{default:!0}})};D(Zt,f=>{M.streaming?f(Ht):f(Qt,!1)})}_(ht),_(Z),_(b),ie(()=>{zt(de,"placeholder",C.selectedId?"Ask about this entity...":"Ask about your workspace..."),de.disabled=M.streaming}),ts("scroll",se,g),ss("keydown",de,L),_s(de,()=>p(o),f=>S(o,f)),v(r,b),Tt()}es(["keydown"]);export{Yr as C,Kr as V,M as c};
64
+ `)}const a=Rt("chat");let o=te(""),l=te(!1);const h=Pe(()=>(M.activeSessionId,M.getSessions().length>0));let c,d=!0;function g(){c&&(d=c.scrollHeight-c.scrollTop-c.clientHeight<40)}const T=Pe(()=>{if(C.selectedSubPath)return["Summarize this document","Extract key points","What actions are here?","What decisions were made?"];if(C.selectedId){const f=C.selectedType??"entity";return[`Summarize this ${f}`,`What's related to this ${f}?`,"What actions should I take?","What decisions were made?"]}return C.activeView==="graph"?["What are the key relationships?","Which entities are most connected?","Find gaps in my graph","What decisions have been made recently?"]:["What's in my graph?","Summarize recent meetings","Who's working on what?","What decisions have been made recently?"]});async function m(){const f=p(o).trim();f&&(S(o,""),d=!0,M.send(f),await Fe(),O())}function L(f){f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),m())}function O(){c&&(c.scrollTop=c.scrollHeight)}gs(()=>{Fe().then(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>O())})})}),fs(()=>{M.scrollTick,d&&O()});var b=Or(),w=R(b),u=R(w),z=R(u);ee(z,{variant:"ghost",size:"icon",class:"size-6",onclick:()=>M.newSession(),children:(f,$)=>{Ls(f,{size:14})},$$slots:{default:!0}});var P=j(z,2);{var A=f=>{{let $=Pe(()=>p(l)?"history-active":"");ee(f,{variant:"ghost",size:"icon",get class(){return`size-6 ${p($)??""}`},onclick:()=>S(l,!p(l)),children:(N,ge)=>{qs(N,{size:14})},$$slots:{default:!0}})}};D(P,f=>{p(h)&&f(A)})}_(u);var G=j(u,2);ee(G,{variant:"ghost",size:"icon",class:"size-6",get onclick(){return a.close},children:(f,$)=>{vs(f,{size:14})},$$slots:{default:!0}});var J=j(G,2);{var De=f=>{var $=Ir(),N=R($);_e(N,21,()=>M.getSessions(),Se,(ge,E)=>{var K=Ar(),ve=R(K);{let le=Pe(()=>p(E).active?"active":"");ee(ve,{variant:"ghost",get class(){return`session-item ${p(le)??""}`},onclick:()=>{M.loadSession(p(E).id),S(l,!1)},children:(Y,re)=>{var ne=zr(),Ze=R(ne,!0);_(ne),ie(()=>$e(Ze,p(E).title)),v(Y,ne)},$$slots:{default:!0}})}var fe=j(ve,2);ee(fe,{variant:"ghost",size:"icon",class:"session-delete-btn",title:"Delete session",onclick:le=>{le.stopPropagation(),M.deleteSession(p(E).id)},children:(le,Y)=>{ys(le,{size:12})},$$slots:{default:!0}}),_(K),v(ge,K)}),_(N),_($),v(f,$)};D(J,f=>{p(l)&&f(De)})}_(w);var se=j(w,2),Oe=R(se);{var k=f=>{var $=Pr(),N=R($);_e(N,21,()=>p(T),Se,(ge,E)=>{ee(ge,{variant:"outline",class:"seed-prompt",onclick:()=>{d=!0,M.send(p(E)),Fe().then(()=>O())},children:(K,ve)=>{ze();var fe=rs();ie(()=>$e(fe,p(E))),v(K,fe)},$$slots:{default:!0}})}),_(N),_($),v(f,$)},B=f=>{var $=F(),N=X($);_e(N,17,()=>M.messages,Se,(ge,E)=>{var K=jr(),ve=R(K);{var fe=Y=>{var re=Cr(),ne=R(re,!0);_(re),ie(()=>$e(ne,p(E).content)),v(Y,re)},le=Y=>{var re=Nr(),ne=R(re);{var Ze=U=>{var ae=F(),He=X(ae);_e(He,17,()=>p(E).segments,Se,(Vt,ye)=>{var pt=F(),Ft=X(pt);{var Xt=ke=>{var oe=Lr();_e(oe,21,()=>p(ye).names,Se,(Qe,Kt)=>{var We=Er(),Yt=R(We,!0);_(We),ie(()=>$e(Yt,p(Kt))),v(Qe,We)}),_(oe),v(ke,oe)},Jt=ke=>{var oe=qr(),Qe=R(oe);kt(Qe,()=>y.parse(i(p(ye).content))),_(oe),v(ke,oe)};D(Ft,ke=>{p(ye).type==="tools"?ke(Xt):p(ye).type==="text"&&p(ye).content&&ke(Jt,1)})}v(Vt,pt)}),v(U,ae)},Wt=U=>{var ae=Br(),He=R(ae);kt(He,()=>y.parse(i(p(E).content))),_(ae),v(U,ae)};D(ne,U=>{p(E).segments&&p(E).segments.length>0?U(Ze):p(E).content&&U(Wt,1)})}var Gt=j(ne,2);{var Ut=U=>{var ae=Mr();v(U,ae)};D(Gt,U=>{p(E).streaming&&U(Ut)})}_(re),v(Y,re)};D(ve,Y=>{p(E).role==="user"?Y(fe):Y(le,!1)})}_(K),v(ge,K)}),v(f,$)};D(Oe,f=>{M.messages.length===0?f(k):f(B,!1)})}_(se),ws(se,f=>c=f,()=>c);var Z=j(se,2),H=R(Z);{var Ot=f=>{var $=Dr(),N=R($);_($),ie(()=>$e(N,`${C.selectedType??""}/${C.selectedId??""}`)),v(f,$)};D(H,f=>{C.selectedId&&f(Ot)})}var ht=j(H,2),de=R(ht);ks(de);var Zt=j(de,2);{var Ht=f=>{ee(f,{variant:"ghost",size:"icon",class:"size-7 stop-btn send-btn",onclick:()=>M.stop(),children:($,N)=>{Es($,{size:16})},$$slots:{default:!0}})},Qt=f=>{ee(f,{variant:"ghost",size:"icon",class:"size-7 send-btn",onclick:m,children:($,N)=>{Rs($,{size:14})},$$slots:{default:!0}})};D(Zt,f=>{M.streaming?f(Ht):f(Qt,!1)})}_(ht),_(Z),_(b),ie(()=>{zt(de,"placeholder",C.selectedId?"Ask about this entity...":"Ask about your workspace..."),de.disabled=M.streaming}),ts("scroll",se,g),ss("keydown",de,L),$s(de,()=>p(o),f=>S(o,f)),v(r,b),Tt()}es(["keydown"]);export{Kr as C,Jr as V,M as c};
@@ -1 +1 @@
1
- import{a as b,f as m}from"./BfTJ6NzK.js";import{b as _,c as h}from"./m74CvwCG.js";import{N as y,O as v,P as x,F as k,Q as E,h as S,R as I,p as P,n as V}from"./GRkK54yd.js";import{p as i,b as w,r as F}from"./trveDs8t.js";function M(e,r,o=r){var s=new WeakSet;y(e,"input",async l=>{var a=l?e.defaultValue:e.value;if(a=n(e)?u(a):a,o(a),v!==null&&s.add(v),await x(),a!==(a=r())){var t=e.selectionStart,c=e.selectionEnd,d=e.value.length;if(e.value=a??"",c!==null){var f=e.value.length;t===c&&c===d&&f>d?(e.selectionStart=f,e.selectionEnd=f):(e.selectionStart=t,e.selectionEnd=Math.min(c,f))}}}),(S&&e.defaultValue!==e.value||k(r)==null&&e.value)&&(o(n(e)?u(e.value):e.value),v!==null&&s.add(v)),E(()=>{var l=r();if(e===document.activeElement){var a=I??v;if(s.has(a))return}n(e)&&l===u(e.value)||e.type==="date"&&!l&&!e.value||l!==e.value&&(e.value=l??"")})}function n(e){var r=e.type;return r==="number"||r==="range"}function u(e){return e===""?null:+e}var N=m("<input/>");function g(e,r){P(r,!0);let o=i(r,"ref",15,null),s=i(r,"value",15),l=F(r,["$$slots","$$events","$$legacy","class","ref","value"]);var a=N();_(a,t=>({class:t,...l}),[()=>h("h-8 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-2.5 text-[13px] text-[var(--color-text-primary)] font-[inherit] outline-none transition-colors placeholder:text-[var(--color-text-tertiary)] focus:border-[var(--color-accent,#6e6ee8)] disabled:cursor-not-allowed disabled:opacity-50",r.class)],void 0,void 0,void 0,!0),w(a,t=>o(t),()=>o()),M(a,s),b(e,a),V()}export{g as I,M as b};
1
+ import{a as b,f as m}from"./CjKjQEMp.js";import{b as _,c as h}from"./ByFfmBEu.js";import{N as y,O as v,P as x,F as k,Q as E,h as S,R as I,p as P,n as V}from"./D-tW7Byc.js";import{p as i,b as w,r as F}from"./EhE2EcYu.js";function M(e,r,o=r){var s=new WeakSet;y(e,"input",async l=>{var a=l?e.defaultValue:e.value;if(a=n(e)?u(a):a,o(a),v!==null&&s.add(v),await x(),a!==(a=r())){var t=e.selectionStart,c=e.selectionEnd,d=e.value.length;if(e.value=a??"",c!==null){var f=e.value.length;t===c&&c===d&&f>d?(e.selectionStart=f,e.selectionEnd=f):(e.selectionStart=t,e.selectionEnd=Math.min(c,f))}}}),(S&&e.defaultValue!==e.value||k(r)==null&&e.value)&&(o(n(e)?u(e.value):e.value),v!==null&&s.add(v)),E(()=>{var l=r();if(e===document.activeElement){var a=I??v;if(s.has(a))return}n(e)&&l===u(e.value)||e.type==="date"&&!l&&!e.value||l!==e.value&&(e.value=l??"")})}function n(e){var r=e.type;return r==="number"||r==="range"}function u(e){return e===""?null:+e}var N=m("<input/>");function g(e,r){P(r,!0);let o=i(r,"ref",15,null),s=i(r,"value",15),l=F(r,["$$slots","$$events","$$legacy","class","ref","value"]);var a=N();_(a,t=>({class:t,...l}),[()=>h("h-8 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-2.5 text-[13px] text-[var(--color-text-primary)] font-[inherit] outline-none transition-colors placeholder:text-[var(--color-text-tertiary)] focus:border-[var(--color-accent,#6e6ee8)] disabled:cursor-not-allowed disabled:opacity-50",r.class)],void 0,void 0,void 0,!0),w(a,t=>o(t),()=>o()),M(a,s),b(e,a),V()}export{g as I,M as b};
@@ -0,0 +1,5 @@
1
+ const F=()=>new Map,je=e=>{const t=F();return e.forEach((n,s)=>{t.set(s,n)}),t},tt=(e,t,n)=>{let s=e.get(t);return s===void 0&&e.set(t,s=n()),s},pr=(e,t)=>{const n=[];for(const[s,r]of e)n.push(t(r,s));return n},wr=(e,t)=>{for(const[n,s]of e)if(t(s,n))return!0;return!1},wt=()=>new Set,xe=e=>e[e.length-1],mr=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Q=Array.from,Pe=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Ze=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},kr=(e,t)=>{const n=new Array(e);for(let s=0;s<e;s++)n[s]=t(s,n);return n},mt=Array.isArray;class Zn{constructor(){this._observers=F()}on(t,n){return tt(this._observers,t,wt).add(n),n}once(t,n){const s=(...r)=>{this.off(t,s),n(...r)};this.on(t,s)}off(t,n){const s=this._observers.get(t);s!==void 0&&(s.delete(n),s.size===0&&this._observers.delete(t))}emit(t,n){return Q((this._observers.get(t)||F()).values()).forEach(s=>s(...n))}destroy(){this._observers=F()}}const J=Math.floor,Zt=Math.abs,Qn=(e,t)=>e<t?e:t,it=(e,t)=>e>t?e:t,ts=e=>e!==0?e<0:1/e<0,Dn=1,An=2,Le=4,Ue=8,Ut=32,W=64,R=128,we=31,Be=63,et=127,yr=2147483647,se=Number.MAX_SAFE_INTEGER,In=Number.MIN_SAFE_INTEGER,_r=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&J(e)===e),Sr=String.fromCharCode,br=e=>e.toLowerCase(),Er=/^\s*/g,Cr=e=>e.replace(Er,""),Dr=/([A-Z])/g,Tn=(e,t)=>Cr(e.replace(Dr,n=>`${t}${br(n)}`)),Ar=e=>{const t=unescape(encodeURIComponent(e)),n=t.length,s=new Uint8Array(n);for(let r=0;r<n;r++)s[r]=t.codePointAt(r);return s},Nt=typeof TextEncoder<"u"?new TextEncoder:null,Ir=e=>Nt.encode(e),Tr=Nt?Ir:Ar;let Lt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Lt&&Lt.decode(new Uint8Array).length===1&&(Lt=null);const Or=(e,t)=>kr(t,()=>e).join("");class Gt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const me=()=>new Gt,xr=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},B=e=>{const t=new Uint8Array(xr(e));let n=0;for(let s=0;s<e.bufs.length;s++){const r=e.bufs[s];t.set(r,n),n+=r.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},Lr=(e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(it(n,t)*2),e.cpos=0)},A=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Je=A,k=(e,t)=>{for(;t>et;)A(e,R|et&t),t=J(t/128);A(e,et&t)},Qe=(e,t)=>{const n=ts(t);for(n&&(t=-t),A(e,(t>Be?R:0)|(n?W:0)|Be&t),t=J(t/64);t>0;)A(e,(t>et?R:0)|et&t),t=J(t/128)},Ge=new Uint8Array(3e4),Ur=Ge.length/3,Nr=(e,t)=>{if(t.length<Ur){const n=Nt.encodeInto(t,Ge).written||0;k(e,n);for(let s=0;s<n;s++)A(e,Ge[s])}else U(e,Tr(t))},Rr=(e,t)=>{const n=unescape(encodeURIComponent(t)),s=n.length;k(e,s);for(let r=0;r<s;r++)A(e,n.codePointAt(r))},at=Nt&&Nt.encodeInto?Nr:Rr,ke=(e,t)=>{const n=e.cbuf.length,s=e.cpos,r=Qn(n-s,t.length),i=t.length-r;e.cbuf.set(t.subarray(0,r),s),e.cpos+=r,i>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(it(n*2,i)),e.cbuf.set(t.subarray(r)),e.cpos=i)},U=(e,t)=>{k(e,t.byteLength),ke(e,t)},tn=(e,t)=>{Lr(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Mr=(e,t)=>tn(e,4).setFloat32(0,t,!1),$r=(e,t)=>tn(e,8).setFloat64(0,t,!1),vr=(e,t)=>tn(e,8).setBigInt64(0,t,!1),On=new DataView(new ArrayBuffer(4)),Fr=e=>(On.setFloat32(0,e),On.getFloat32(0)===e),Rt=(e,t)=>{switch(typeof t){case"string":A(e,119),at(e,t);break;case"number":_r(t)&&Zt(t)<=yr?(A(e,125),Qe(e,t)):Fr(t)?(A(e,124),Mr(e,t)):(A(e,123),$r(e,t));break;case"bigint":A(e,122),vr(e,t);break;case"object":if(t===null)A(e,126);else if(mt(t)){A(e,117),k(e,t.length);for(let n=0;n<t.length;n++)Rt(e,t[n])}else if(t instanceof Uint8Array)A(e,116),U(e,t);else{A(e,118);const n=Object.keys(t);k(e,n.length);for(let s=0;s<n.length;s++){const r=n[s];at(e,r),Rt(e,t[r])}}break;case"boolean":A(e,t?120:121);break;default:A(e,127)}};class xn extends Gt{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&k(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}const Ln=e=>{e.count>0&&(Qe(e.encoder,e.count===1?e.s:-e.s),e.count>1&&k(e.encoder,e.count-2))};class Qt{constructor(){this.encoder=new Gt,this.s=0,this.count=0}write(t){this.s===t?this.count++:(Ln(this),this.count=1,this.s=t)}toUint8Array(){return Ln(this),B(this.encoder)}}const Un=e=>{if(e.count>0){const t=e.diff*2+(e.count===1?0:1);Qe(e.encoder,t),e.count>1&&k(e.encoder,e.count-2)}};class Ne{constructor(){this.encoder=new Gt,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Un(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Un(this),B(this.encoder)}}class Vr{constructor(){this.sarr=[],this.s="",this.lensE=new Qt}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){const t=new Gt;return this.sarr.push(this.s),this.s="",at(t,this.sarr.join("")),ke(t,this.lensE.toUint8Array()),B(t)}}const G=e=>new Error(e),V=()=>{throw G("Method unimplemented")},M=()=>{throw G("Unexpected case")},es=G("Unexpected end of array"),ns=G("Integer out of Range");class ye{constructor(t){this.arr=t,this.pos=0}}const Dt=e=>new ye(e),jr=e=>e.pos!==e.arr.length,Br=(e,t)=>{const n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},N=e=>Br(e,m(e)),kt=e=>e.arr[e.pos++],m=e=>{let t=0,n=1;const s=e.arr.length;for(;e.pos<s;){const r=e.arr[e.pos++];if(t=t+(r&et)*n,n*=128,r<R)return t;if(t>se)throw ns}throw es},en=e=>{let t=e.arr[e.pos++],n=t&Be,s=64;const r=(t&W)>0?-1:1;if((t&R)===0)return r*n;const i=e.arr.length;for(;e.pos<i;){if(t=e.arr[e.pos++],n=n+(t&et)*s,s*=128,t<R)return r*n;if(n>se)throw ns}throw es},Jr=e=>{let t=m(e);if(t===0)return"";{let n=String.fromCodePoint(kt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(kt(e));else for(;t>0;){const s=t<1e4?t:1e4,r=e.arr.subarray(e.pos,e.pos+s);e.pos+=s,n+=String.fromCodePoint.apply(null,r),t-=s}return decodeURIComponent(escape(n))}},Gr=e=>Lt.decode(N(e)),ut=Lt?Gr:Jr,nn=(e,t)=>{const n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Yr=e=>nn(e,4).getFloat32(0,!1),Hr=e=>nn(e,8).getFloat64(0,!1),zr=e=>nn(e,8).getBigInt64(0,!1),Kr=[e=>{},e=>null,en,Yr,Hr,zr,e=>!1,e=>!0,ut,e=>{const t=m(e),n={};for(let s=0;s<t;s++){const r=ut(e);n[r]=Mt(e)}return n},e=>{const t=m(e),n=[];for(let s=0;s<t;s++)n.push(Mt(e));return n},N],Mt=e=>Kr[127-kt(e)](e);class Nn extends ye{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),jr(this)?this.count=m(this)+1:this.count=-1),this.count--,this.s}}class te extends ye{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=en(this);const t=ts(this.s);this.count=1,t&&(this.s=-this.s,this.count=m(this)+2)}return this.count--,this.s}}class Re extends ye{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const t=en(this),n=t&1;this.diff=J(t/2),this.count=1,n&&(this.count=m(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Xr{constructor(t){this.decoder=new te(t),this.str=ut(this.decoder),this.spos=0}read(){const t=this.spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}}const Wr=crypto.getRandomValues.bind(crypto),ss=()=>Wr(new Uint32Array(1))[0],qr="10000000-1000-4000-8000"+-1e11,Pr=()=>qr.replace(/[018]/g,e=>(e^ss()&15>>e/4).toString(16)),Zr=Date.now,Rn=e=>new Promise(e);Promise.all.bind(Promise);const Mn=e=>e===void 0?null:e;class Qr{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}}let rs=new Qr,ti=!0;try{typeof localStorage<"u"&&localStorage&&(rs=localStorage,ti=!1)}catch{}const ei=rs,$t=Symbol("Equality"),is=(e,t)=>e===t||!!e?.[$t]?.(t)||!1,ni=e=>typeof e=="object",si=Object.assign,ri=Object.keys,ii=(e,t)=>{for(const n in e)t(e[n],n)},re=e=>ri(e).length,li=e=>{for(const t in e)return!1;return!0},Yt=(e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0},sn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),oi=(e,t)=>e===t||re(e)===re(t)&&Yt(e,(n,s)=>(n!==void 0||sn(t,s))&&is(t[s],n)),ci=Object.freeze,ls=e=>{for(const t in e){const n=e[t];(typeof n=="object"||typeof n=="function")&&ls(e[t])}return ci(e)},rn=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&rn(e,t,n+1)}},hi=e=>e,ee=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[$t]!=null)return e[$t](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(const n of e.keys())if(!t.has(n)||!ee(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(re(e)!==re(t))return!1;for(const n in e)if(!sn(e,n)||!ee(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!ee(e[n],t[n]))return!1;break;default:return!1}return!0},ai=(e,t)=>t.includes(e);var os={};const vt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";let j;const ui=()=>{if(j===void 0)if(vt){j=F();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const s=e[n];s[0]==="-"?(t!==null&&j.set(t,""),t=s):t!==null&&(j.set(t,s),t=null)}t!==null&&j.set(t,"")}else typeof location=="object"?(j=F(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){const[t,n]=e.split("=");j.set(`--${Tn(t,"-")}`,n),j.set(`-${Tn(t,"-")}`,n)}})):j=F();return j},Ye=e=>ui().has(e),ie=e=>Mn(vt?os[e.toUpperCase().replaceAll("-","_")]:ei.getItem(e)),cs=e=>Ye("--"+e)||ie(e)!==null,di=cs("production"),fi=vt&&ai(os.FORCE_COLOR,["true","1","2"]),gi=fi||!Ye("--no-colors")&&!cs("no-color")&&(!vt||process.stdout.isTTY)&&(!vt||Ye("--color")||ie("COLORTERM")!==null||(ie("TERM")||"").includes("color")),pi=e=>new Uint8Array(e),wi=e=>{const t=pi(e.byteLength);return t.set(e),t};class mi{constructor(t,n){this.left=t,this.right=n}}const X=(e,t)=>new mi(e,t),ki=(e,t)=>e.forEach(n=>t(n.left,n.right)),$n=e=>e.next()>=.5,Me=(e,t,n)=>J(e.next()*(n+1-t)+t),hs=(e,t,n)=>J(e.next()*(n+1-t)+t),ln=(e,t,n)=>hs(e,t,n),yi=e=>Sr(ln(e,97,122)),_i=(e,t=0,n=20)=>{const s=ln(e,t,n);let r="";for(let i=0;i<s;i++)r+=yi(e);return r},$e=(e,t)=>t[ln(e,0,t.length-1)],Si=Symbol("0schema");class bi{constructor(){this._rerrs=[]}extend(t,n,s,r=null){this._rerrs.push({path:t,expected:n,has:s,message:r})}toString(){const t=[];for(let n=this._rerrs.length-1;n>0;n--){const s=this._rerrs[n];t.push(Or(" ",(this._rerrs.length-n)*2)+`${s.path!=null?`[${s.path}] `:""}${s.has} doesn't match ${s.expected}. ${s.message}`)}return t.join(`
2
+ `)}}const He=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[$t]?is(e,t):mt(e)?Pe(e,n=>Ze(t,s=>He(n,s))):ni(e)?Yt(e,(n,s)=>He(n,t[s])):!1;class x{static _dilutes=!1;extends(t){let[n,s]=[this.shape,t.shape];return this.constructor._dilutes&&([s,n]=[n,s]),He(n,s)}equals(t){return this.constructor===t.constructor&&ee(this.shape,t.shape)}[Si](){return!0}[$t](t){return this.equals(t)}validate(t){return this.check(t)}check(t,n){V()}get nullable(){return At(this,Ce)}get optional(){return new ds(this)}cast(t){return vn(t,this),t}expect(t){return vn(t,this),t}}class on extends x{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n=void 0){const s=t?.constructor===this.shape&&(this._c==null||this._c(t));return!s&&n?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),s}}const C=(e,t=null)=>new on(e,t);C(on);class cn extends x{constructor(t){super(),this.shape=t}check(t,n){const s=this.shape(t);return!s&&n?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),s}}const T=e=>new cn(e);C(cn);class _e extends x{constructor(t){super(),this.shape=t}check(t,n){const s=this.shape.some(r=>r===t);return!s&&n?.extend(null,this.shape.join(" | "),t.toString()),s}}const Se=(...e)=>new _e(e),as=C(_e),Ei=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),us=e=>{if(yt.check(e))return[Ei(e)];if(as.check(e))return e.shape.map(t=>t+"");if(Ss.check(e))return["[+-]?\\d+.?\\d*"];if(bs.check(e))return[".*"];if(le.check(e))return e.shape.map(us).flat(1);M()};class Ci extends x{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(us).map(n=>`(${n.join("|")})`).join("")+"$")}check(t,n){const s=this._r.exec(t)!=null;return!s&&n?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),s}}C(Ci);const Di=Symbol("optional");class ds extends x{constructor(t){super(),this.shape=t}check(t,n){const s=t===void 0||this.shape.check(t);return!s&&n?.extend(null,"undefined (optional)","()"),s}get[Di](){return!0}}const Ai=C(ds);class Ii extends x{check(t,n){return n?.extend(null,"never",typeof t),!1}}C(Ii);class be extends x{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}static _dilutes=!0;get partial(){return new be(this.shape,!0)}check(t,n){return t==null?(n?.extend(null,"object","null"),!1):Yt(this.shape,(s,r)=>{const i=this._isPartial&&!sn(t,r)||s.check(t[r],n);return!i&&n?.extend(r.toString(),s.toString(),typeof t[r],"Object property does not match"),i})}}const Ti=e=>new be(e),Oi=C(be),xi=T(e=>e!=null&&(e.constructor===Object||e.constructor==null));class fs extends x{constructor(t,n){super(),this.shape={keys:t,values:n}}check(t,n){return t!=null&&Yt(t,(s,r)=>{const i=this.shape.keys.check(r,n);return!i&&n?.extend(r+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(s,n)})}}const gs=(e,t)=>new fs(e,t),Li=C(fs);class ps extends x{constructor(t){super(),this.shape=t}check(t,n){return t!=null&&Yt(this.shape,(s,r)=>{const i=s.check(t[r],n);return!i&&n?.extend(r.toString(),"Tuple",typeof s),i})}}const Ui=(...e)=>new ps(e);C(ps);class ws extends x{constructor(t){super(),this.shape=t.length===1?t[0]:new hn(t)}check(t,n){const s=mt(t)&&Pe(t,r=>this.shape.check(r));return!s&&n?.extend(null,"Array",""),s}}const ms=(...e)=>new ws(e),Ni=C(ws),Ri=T(e=>mt(e));class ks extends x{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n){const s=t instanceof this.shape&&(this._c==null||this._c(t));return!s&&n?.extend(null,this.shape.name,t?.constructor.name),s}}const Mi=(e,t=null)=>new ks(e,t);C(ks);const $i=Mi(x);class vi extends x{constructor(t){super(),this.len=t.length-1,this.args=Ui(...t.slice(-1)),this.res=t[this.len]}check(t,n){const s=t.constructor===Function&&t.length<=this.len;return!s&&n?.extend(null,"function",typeof t),s}}const Fi=C(vi),Vi=T(e=>typeof e=="function");class ji extends x{constructor(t){super(),this.shape=t}check(t,n){const s=Pe(this.shape,r=>r.check(t,n));return!s&&n?.extend(null,"Intersectinon",typeof t),s}}C(ji,e=>e.shape.length>0);class hn extends x{static _dilutes=!0;constructor(t){super(),this.shape=t}check(t,n){const s=Ze(this.shape,r=>r.check(t,n));return n?.extend(null,"Union",typeof t),s}}const At=(...e)=>e.findIndex(t=>le.check(t))>=0?At(...e.map(t=>Ft(t)).map(t=>le.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new hn(e),le=C(hn),ys=()=>!0,oe=T(ys),Bi=C(cn,e=>e.shape===ys),an=T(e=>typeof e=="bigint"),Ji=T(e=>e===an),_s=T(e=>typeof e=="symbol");T(e=>e===_s);const dt=T(e=>typeof e=="number"),Ss=T(e=>e===dt),yt=T(e=>typeof e=="string"),bs=T(e=>e===yt),Ee=T(e=>typeof e=="boolean"),Gi=T(e=>e===Ee),Es=Se(void 0);C(_e,e=>e.shape.length===1&&e.shape[0]===void 0);Se(void 0);const Ce=Se(null),Yi=C(_e,e=>e.shape.length===1&&e.shape[0]===null);C(Uint8Array);C(on,e=>e.shape===Uint8Array);const Hi=At(dt,yt,Ce,Es,an,Ee,_s);(()=>{const e=ms(oe),t=gs(yt,oe),n=At(dt,yt,Ce,Ee,e,t);return e.shape=n,t.shape.values=n,n})();const Ft=e=>{if($i.check(e))return e;if(xi.check(e)){const t={};for(const n in e)t[n]=Ft(e[n]);return Ti(t)}else{if(Ri.check(e))return At(...e.map(Ft));if(Hi.check(e))return Se(e);if(Vi.check(e))return C(e)}M()},vn=di?()=>{}:(e,t)=>{const n=new bi;if(!t.check(e,n))throw G(`Expected value to be of type ${t.constructor.name}.
3
+ ${n.toString()}`)};class zi{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:Ft(t),h:n}),this}else(t){return this.if(oe,t)}done(){return(t,n)=>{for(let s=0;s<this.patterns.length;s++){const r=this.patterns[s];if(r.if.check(t))return r.h(t,n)}throw G("Unhandled pattern")}}}const Ki=e=>new zi(e),Cs=Ki(oe).if(Ss,(e,t)=>Me(t,In,se)).if(bs,(e,t)=>_i(t)).if(Gi,(e,t)=>$n(t)).if(Ji,(e,t)=>BigInt(Me(t,In,se))).if(le,(e,t)=>ot(t,$e(t,e.shape))).if(Oi,(e,t)=>{const n={};for(const s in e.shape){let r=e.shape[s];if(Ai.check(r)){if($n(t))continue;r=r.shape}n[s]=Cs(r,t)}return n}).if(Ni,(e,t)=>{const n=[],s=hs(t,0,42);for(let r=0;r<s;r++)n.push(ot(t,e.shape));return n}).if(as,(e,t)=>$e(t,e.shape)).if(Yi,(e,t)=>null).if(Fi,(e,t)=>{const n=ot(t,e.res);return()=>n}).if(Bi,(e,t)=>ot(t,$e(t,[dt,yt,Ce,Es,an,Ee,ms(dt),gs(At("a","b","c"),dt)]))).if(Li,(e,t)=>{const n={},s=Me(t,0,3);for(let r=0;r<s;r++){const i=ot(t,e.shape.keys),l=ot(t,e.shape.values);n[i]=l}return n}).done(),ot=(e,t)=>Cs(Ft(t),e),z=typeof document<"u"?document:{},Xi=e=>z.createElement(e),Wi=()=>z.createDocumentFragment();T(e=>e.nodeType===rl);const qi=e=>z.createTextNode(e);typeof DOMParser<"u"&&new DOMParser;const Pi=(e,t)=>(ki(t,(n,s)=>{s===!1?e.removeAttribute(n):s===!0?e.setAttribute(n,""):e.setAttribute(n,s)}),e),Zi=e=>{const t=Wi();for(let n=0;n<e.length;n++)Ds(t,e[n]);return t},Qi=(e,t)=>(Ds(e,Zi(t)),e),Ro=(e,t=[],n=[])=>Qi(Pi(Xi(e),t),n);T(e=>e.nodeType===el);const Mo=qi;T(e=>e.nodeType===nl);const tl=e=>pr(e,(t,n)=>`${n}:${t};`).join(""),Ds=(e,t)=>e.appendChild(t),el=z.ELEMENT_NODE,nl=z.TEXT_NODE;z.CDATA_SECTION_NODE;z.COMMENT_NODE;const sl=z.DOCUMENT_NODE;z.DOCUMENT_TYPE_NODE;const rl=z.DOCUMENT_FRAGMENT_NODE;T(e=>e.nodeType===sl);const q=Symbol,As=q(),Is=q(),il=q(),ll=q(),ol=q(),Ts=q(),cl=q(),un=q(),hl=q(),al=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[];let s=0;for(;s<e.length;s++){const r=e[s];if(r===void 0)break;if(r.constructor===String||r.constructor===Number)t.push(r);else if(r.constructor===Object)break}for(s>0&&n.push(t.join(""));s<e.length;s++){const r=e[s];r instanceof Symbol||n.push(r)}return n},ul={[As]:X("font-weight","bold"),[Is]:X("font-weight","normal"),[il]:X("color","blue"),[ol]:X("color","green"),[ll]:X("color","grey"),[Ts]:X("color","red"),[cl]:X("color","purple"),[un]:X("color","orange"),[hl]:X("color","black")},dl=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[],s=F();let r=[],i=0;for(;i<e.length;i++){const l=e[i],o=ul[l];if(o!==void 0)s.set(o.left,o.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){const c=tl(s);i>0||c.length>0?(t.push("%c"+l),n.push(c)):t.push(l)}else break}}for(i>0&&(r=n,r.unshift(t.join("")));i<e.length;i++){const l=e[i];l instanceof Symbol||r.push(l)}return r},Os=gi?dl:al,fl=(...e)=>{console.log(...Os(e)),Ls.forEach(t=>t.print(e))},xs=(...e)=>{console.warn(...Os(e)),e.unshift(un),Ls.forEach(t=>t.print(e))},Ls=wt(),Us=e=>({[Symbol.iterator](){return this},next:e}),gl=(e,t)=>Us(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),ve=(e,t)=>Us(()=>{const{done:n,value:s}=e.next();return{done:n,value:n?void 0:t(s)}});class De{constructor(t,n){this.clock=t,this.len=n}}class It{constructor(){this.clients=new Map}}const _t=(e,t,n)=>t.clients.forEach((s,r)=>{const i=e.doc.store.clients.get(r);if(i!=null){const l=i[i.length-1],o=l.id.clock+l.length;for(let c=0,a=s[c];c<s.length&&a.clock<o;a=s[++c])zs(e,i,a.clock,a.len,n)}}),pl=(e,t)=>{let n=0,s=e.length-1;for(;n<=s;){const r=J((n+s)/2),i=e[r],l=i.clock;if(l<=t){if(t<l+i.len)return r;n=r+1}else s=r-1}return null},Ht=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&pl(n,t.clock)!==null},dn=e=>{e.clients.forEach(t=>{t.sort((r,i)=>r.clock-i.clock);let n,s;for(n=1,s=1;n<t.length;n++){const r=t[s-1],i=t[n];r.clock+r.len>=i.clock?t[s-1]=new De(r.clock,it(r.len,i.clock+i.len-r.clock)):(s<n&&(t[s]=i),s++)}t.length=s})},ze=e=>{const t=new It;for(let n=0;n<e.length;n++)e[n].clients.forEach((s,r)=>{if(!t.clients.has(r)){const i=s.slice();for(let l=n+1;l<e.length;l++)mr(i,e[l].clients.get(r)||[]);t.clients.set(r,i)}});return dn(t),t},Vt=(e,t,n,s)=>{tt(e.clients,t,()=>[]).push(new De(n,s))},wl=()=>new It,ml=e=>{const t=wl();return e.clients.forEach((n,s)=>{const r=[];for(let i=0;i<n.length;i++){const l=n[i];if(l.deleted){const o=l.id.clock;let c=l.length;if(i+1<n.length)for(let a=n[i+1];i+1<n.length&&a.deleted;a=n[++i+1])c+=a.length;r.push(new De(o,c))}}r.length>0&&t.clients.set(s,r)}),t},Tt=(e,t)=>{k(e.restEncoder,t.clients.size),Q(t.clients.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{e.resetDsCurVal(),k(e.restEncoder,n);const r=s.length;k(e.restEncoder,r);for(let i=0;i<r;i++){const l=s[i];e.writeDsClock(l.clock),e.writeDsLen(l.len)}})},fn=e=>{const t=new It,n=m(e.restDecoder);for(let s=0;s<n;s++){e.resetDsCurVal();const r=m(e.restDecoder),i=m(e.restDecoder);if(i>0){const l=tt(t.clients,r,()=>[]);for(let o=0;o<i;o++)l.push(new De(e.readDsClock(),e.readDsLen()))}}return t},Fn=(e,t,n)=>{const s=new It,r=m(e.restDecoder);for(let i=0;i<r;i++){e.resetDsCurVal();const l=m(e.restDecoder),o=m(e.restDecoder),c=n.clients.get(l)||[],a=E(n,l);for(let h=0;h<o;h++){const u=e.readDsClock(),d=u+e.readDsLen();if(u<a){a<d&&Vt(s,l,a,d-a);let f=Y(c,u),g=c[f];for(!g.deleted&&g.id.clock<u&&(c.splice(f+1,0,pe(t,g,u-g.id.clock)),f++);f<c.length&&(g=c[f++],g.id.clock<d);)g.deleted||(d<g.id.clock+g.length&&c.splice(f,0,pe(t,g,d-g.id.clock)),g.delete(t))}else Vt(s,l,u,d-u)}}if(s.clients.size>0){const i=new nt;return k(i.restEncoder,0),Tt(i,s),i.toUint8Array()}return null},Ns=ss;class Ot extends Zn{constructor({guid:t=Pr(),collectionid:n=null,gc:s=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:l=!1,shouldLoad:o=!0}={}){super(),this.gc=s,this.gcFilter=r,this.clientID=Ns(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new Ys,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=l,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Rn(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});const c=()=>Rn(a=>{const h=u=>{(u===void 0||u===!0)&&(this.off("sync",h),a())};this.on("sync",h)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=c()}load(){const t=this._item;t!==null&&!this.shouldLoad&&y(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Q(this.subdocs).map(t=>t.guid))}transact(t,n=null){return y(this,t,n)}get(t,n=I){const s=tt(this.share,t,()=>{const i=new n;return i._integrate(this,null),i}),r=s.constructor;if(n!==I&&r!==n)if(r===I){const i=new n;i._map=s._map,s._map.forEach(l=>{for(;l!==null;l=l.left)l.parent=i}),i._start=s._start;for(let l=i._start;l!==null;l=l.right)l.parent=i;return i._length=s._length,this.share.set(t,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return s}getArray(t=""){return this.get(t,pt)}getText(t=""){return this.get(t,Et)}getMap(t=""){return this.get(t,bt)}getXmlElement(t=""){return this.get(t,Ct)}getXmlFragment(t=""){return this.get(t,st)}toJSON(){const t={};return this.share.forEach((n,s)=>{t[s]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,Q(this.subdocs).forEach(n=>n.destroy());const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new Ot({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,y(t.parent.doc,s=>{const r=n.doc;t.deleted||s.subdocsAdded.add(r),s.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Rs{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return m(this.restDecoder)}readDsLen(){return m(this.restDecoder)}}class Ms extends Rs{readLeftID(){return p(m(this.restDecoder),m(this.restDecoder))}readRightID(){return p(m(this.restDecoder),m(this.restDecoder))}readClient(){return m(this.restDecoder)}readInfo(){return kt(this.restDecoder)}readString(){return ut(this.restDecoder)}readParentInfo(){return m(this.restDecoder)===1}readTypeRef(){return m(this.restDecoder)}readLen(){return m(this.restDecoder)}readAny(){return Mt(this.restDecoder)}readBuf(){return wi(N(this.restDecoder))}readJSON(){return JSON.parse(ut(this.restDecoder))}readKey(){return ut(this.restDecoder)}}class kl{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=m(this.restDecoder),this.dsCurrVal}readDsLen(){const t=m(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class St extends kl{constructor(t){super(t),this.keys=[],m(t),this.keyClockDecoder=new Re(N(t)),this.clientDecoder=new te(N(t)),this.leftClockDecoder=new Re(N(t)),this.rightClockDecoder=new Re(N(t)),this.infoDecoder=new Nn(N(t),kt),this.stringDecoder=new Xr(N(t)),this.parentInfoDecoder=new Nn(N(t),kt),this.typeRefDecoder=new te(N(t)),this.lenDecoder=new te(N(t))}readLeftID(){return new ft(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ft(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Mt(this.restDecoder)}readBuf(){return N(this.restDecoder)}readJSON(){return Mt(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class $s{constructor(){this.restEncoder=me()}toUint8Array(){return B(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){k(this.restEncoder,t)}writeDsLen(t){k(this.restEncoder,t)}}class zt extends $s{writeLeftID(t){k(this.restEncoder,t.client),k(this.restEncoder,t.clock)}writeRightID(t){k(this.restEncoder,t.client),k(this.restEncoder,t.clock)}writeClient(t){k(this.restEncoder,t)}writeInfo(t){Je(this.restEncoder,t)}writeString(t){at(this.restEncoder,t)}writeParentInfo(t){k(this.restEncoder,t?1:0)}writeTypeRef(t){k(this.restEncoder,t)}writeLen(t){k(this.restEncoder,t)}writeAny(t){Rt(this.restEncoder,t)}writeBuf(t){U(this.restEncoder,t)}writeJSON(t){at(this.restEncoder,JSON.stringify(t))}writeKey(t){at(this.restEncoder,t)}}class vs{constructor(){this.restEncoder=me(),this.dsCurrVal=0}toUint8Array(){return B(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const n=t-this.dsCurrVal;this.dsCurrVal=t,k(this.restEncoder,n)}writeDsLen(t){t===0&&M(),k(this.restEncoder,t-1),this.dsCurrVal+=t}}class nt extends vs{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ne,this.clientEncoder=new Qt,this.leftClockEncoder=new Ne,this.rightClockEncoder=new Ne,this.infoEncoder=new xn(Je),this.stringEncoder=new Vr,this.parentInfoEncoder=new xn(Je),this.typeRefEncoder=new Qt,this.lenEncoder=new Qt}toUint8Array(){const t=me();return k(t,0),U(t,this.keyClockEncoder.toUint8Array()),U(t,this.clientEncoder.toUint8Array()),U(t,this.leftClockEncoder.toUint8Array()),U(t,this.rightClockEncoder.toUint8Array()),U(t,B(this.infoEncoder)),U(t,this.stringEncoder.toUint8Array()),U(t,B(this.parentInfoEncoder)),U(t,this.typeRefEncoder.toUint8Array()),U(t,this.lenEncoder.toUint8Array()),ke(t,B(this.restEncoder)),B(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){Rt(this.restEncoder,t)}writeBuf(t){U(this.restEncoder,t)}writeJSON(t){Rt(this.restEncoder,t)}writeKey(t){const n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}}const yl=(e,t,n,s)=>{s=it(s,t[0].id.clock);const r=Y(t,s);k(e.restEncoder,t.length-r),e.writeClient(n),k(e.restEncoder,s);const i=t[r];i.write(e,s-i.id.clock);for(let l=r+1;l<t.length;l++)t[l].write(e,0)},gn=(e,t,n)=>{const s=new Map;n.forEach((r,i)=>{E(t,i)>r&&s.set(i,r)}),Ae(t).forEach((r,i)=>{n.has(i)||s.set(i,0)}),k(e.restEncoder,s.size),Q(s.entries()).sort((r,i)=>i[0]-r[0]).forEach(([r,i])=>{yl(e,t.clients.get(r),r,i)})},_l=(e,t)=>{const n=F(),s=m(e.restDecoder);for(let r=0;r<s;r++){const i=m(e.restDecoder),l=new Array(i),o=e.readClient();let c=m(e.restDecoder);n.set(o,{i:0,refs:l});for(let a=0;a<i;a++){const h=e.readInfo();switch(we&h){case 0:{const u=e.readLen();l[a]=new $(p(o,c),u),c+=u;break}case 10:{const u=m(e.restDecoder);l[a]=new v(p(o,c),u),c+=u;break}default:{const u=(h&(W|R))===0,d=new _(p(o,c),null,(h&R)===R?e.readLeftID():null,null,(h&W)===W?e.readRightID():null,u?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,u&&(h&Ut)===Ut?e.readString():null,dr(e,h));l[a]=d,c+=d.length}}}}return n},Sl=(e,t,n)=>{const s=[];let r=Q(n.keys()).sort((f,g)=>f-g);if(r.length===0)return null;const i=()=>{if(r.length===0)return null;let f=n.get(r[r.length-1]);for(;f.refs.length===f.i;)if(r.pop(),r.length>0)f=n.get(r[r.length-1]);else return null;return f};let l=i();if(l===null)return null;const o=new Ys,c=new Map,a=(f,g)=>{const w=c.get(f);(w==null||w>g)&&c.set(f,g)};let h=l.refs[l.i++];const u=new Map,d=()=>{for(const f of s){const g=f.id.client,w=n.get(g);w?(w.i--,o.clients.set(g,w.refs.slice(w.i)),n.delete(g),w.i=0,w.refs=[]):o.clients.set(g,[f]),r=r.filter(S=>S!==g)}s.length=0};for(;;){if(h.constructor!==v){const g=tt(u,h.id.client,()=>E(t,h.id.client))-h.id.clock;if(g<0)s.push(h),a(h.id.client,h.id.clock-1),d();else{const w=h.getMissing(e,t);if(w!==null){s.push(h);const S=n.get(w)||{refs:[],i:0};if(S.refs.length===S.i)a(w,E(t,w)),d();else{h=S.refs[S.i++];continue}}else(g===0||g<h.length)&&(h.integrate(e,g),u.set(h.id.client,h.id.clock+h.length))}}if(s.length>0)h=s.pop();else if(l!==null&&l.i<l.refs.length)h=l.refs[l.i++];else{if(l=i(),l===null)break;h=l.refs[l.i++]}}if(o.clients.size>0){const f=new nt;return gn(f,o,new Map),k(f.restEncoder,0),{missing:c,update:f.toUint8Array()}}return null},bl=(e,t)=>gn(e,t.doc.store,t.beforeState),El=(e,t,n,s=new St(e))=>y(t,r=>{r.local=!1;let i=!1;const l=r.doc,o=l.store,c=_l(s,l),a=Sl(r,o,c),h=o.pendingStructs;if(h){for(const[d,f]of h.missing)if(f<E(o,d)){i=!0;break}if(a){for(const[d,f]of a.missing){const g=h.missing.get(d);(g==null||g>f)&&h.missing.set(d,f)}h.update=he([h.update,a.update])}}else o.pendingStructs=a;const u=Fn(s,r,o);if(o.pendingDs){const d=new St(Dt(o.pendingDs));m(d.restDecoder);const f=Fn(d,r,o);u&&f?o.pendingDs=he([u,f]):o.pendingDs=u||f}else o.pendingDs=u;if(i){const d=o.pendingStructs.update;o.pendingStructs=null,Fs(r.doc,d)}},n,!1),Fs=(e,t,n,s=St)=>{const r=Dt(t);El(r,e,n,new s(r))},$o=(e,t,n)=>Fs(e,t,n,Ms),Cl=(e,t,n=new Map)=>{gn(e,t.store,n),Tt(e,ml(t.store))},Dl=(e,t=new Uint8Array([0]),n=new nt)=>{const s=Vs(t);Cl(n,e,s);const r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Jl(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===zt)return jl(r.map((i,l)=>l===0?i:Yl(i)));if(n.constructor===nt)return he(r)}return r[0]},vo=(e,t)=>Dl(e,t,new zt),Al=e=>{const t=new Map,n=m(e.restDecoder);for(let s=0;s<n;s++){const r=m(e.restDecoder),i=m(e.restDecoder);t.set(r,i)}return t},Vs=e=>Al(new Rs(Dt(e))),js=(e,t)=>(k(e.restEncoder,t.size),Q(t.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{k(e.restEncoder,n),k(e.restEncoder,s)}),e),Il=(e,t)=>js(e,Ae(t.store)),Tl=(e,t=new vs)=>(e instanceof Map?js(t,e):Il(t,e),t.toUint8Array()),Fo=e=>Tl(e,new $s);class Ol{constructor(){this.l=[]}}const Vn=()=>new Ol,jn=(e,t)=>e.l.push(t),Bn=(e,t)=>{const n=e.l,s=n.length;e.l=n.filter(r=>t!==r),s===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Bs=(e,t,n)=>rn(e.l,[t,n]);class ft{constructor(t,n){this.client=t,this.clock=n}}const ht=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,p=(e,t)=>new ft(e,t),Js=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw M()},ce=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1};class Gs{constructor(t,n,s,r=0){this.type=t,this.tname=n,this.item=s,this.assoc=r}}const Vo=e=>{const t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},jo=e=>new Gs(e.type==null?null:p(e.type.client,e.type.clock),e.tname??null,e.item==null?null:p(e.item.client,e.item.clock),e.assoc==null?0:e.assoc);class xl{constructor(t,n,s=0){this.type=t,this.index=n,this.assoc=s}}const Ll=(e,t,n=0)=>new xl(e,t,n),Wt=(e,t,n)=>{let s=null,r=null;return e._item===null?r=Js(e):s=p(e._item.id.client,e._item.id.clock),new Gs(s,r,t,n)},Bo=(e,t,n=0)=>{let s=e._start;if(n<0){if(t===0)return Wt(e,null,n);t--}for(;s!==null;){if(!s.deleted&&s.countable){if(s.length>t)return Wt(e,p(s.id.client,s.id.clock+t),n);t-=s.length}if(s.right===null&&n<0)return Wt(e,s.lastId,n);s=s.right}return Wt(e,null,n)},Ul=(e,t)=>{const n=gt(e,t),s=t.clock-n.id.clock;return{item:n,diff:s}},Jo=(e,t,n=!0)=>{const s=t.store,r=e.item,i=e.type,l=e.tname,o=e.assoc;let c=null,a=0;if(r!==null){if(E(s,r.client)<=r.clock)return null;const h=n?qe(s,r):Ul(s,r),u=h.item;if(!(u instanceof _))return null;if(c=u.parent,c._item===null||!c._item.deleted){a=u.deleted||!u.countable?0:h.diff+(o>=0?0:1);let d=u.left;for(;d!==null;)!d.deleted&&d.countable&&(a+=d.length),d=d.left}}else{if(l!==null)c=t.get(l);else if(i!==null){if(E(s,i.client)<=i.clock)return null;const{item:h}=n?qe(s,i):{item:gt(s,i)};if(h instanceof _&&h.content instanceof K)c=h.content.type;else return null}else throw M();o>=0?a=c._length:a=0}return Ll(c,a,e.assoc)},Go=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&ht(e.item,t.item)&&ht(e.type,t.type)&&e.assoc===t.assoc,ct=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Ht(t.ds,e.id),Ke=(e,t)=>{const n=tt(e.meta,Ke,wt),s=e.doc.store;n.has(t)||(t.sv.forEach((r,i)=>{r<E(s,i)&&L(e,p(i,r))}),_t(e,t.ds,r=>{}),n.add(t))};class Ys{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Ae=e=>{const t=new Map;return e.clients.forEach((n,s)=>{const r=n[n.length-1];t.set(s,r.id.clock+r.length)}),t},E=(e,t)=>{const n=e.clients.get(t);if(n===void 0)return 0;const s=n[n.length-1];return s.id.clock+s.length},Hs=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{const s=n[n.length-1];if(s.id.clock+s.length!==t.id.clock)throw M()}n.push(t)},Y=(e,t)=>{let n=0,s=e.length-1,r=e[s],i=r.id.clock;if(i===t)return s;let l=J(t/(i+r.length-1)*s);for(;n<=s;){if(r=e[l],i=r.id.clock,i<=t){if(t<i+r.length)return l;n=l+1}else s=l-1;l=J((n+s)/2)}throw M()},Nl=(e,t)=>{const n=e.clients.get(t.client);return n[Y(n,t.clock)]},gt=Nl,Xe=(e,t,n)=>{const s=Y(t,n),r=t[s];return r.id.clock<n&&r instanceof _?(t.splice(s+1,0,pe(e,r,n-r.id.clock)),s+1):s},L=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[Xe(e,n,t.clock)]},Jn=(e,t,n)=>{const s=t.clients.get(n.client),r=Y(s,n.clock),i=s[r];return n.clock!==i.id.clock+i.length-1&&i.constructor!==$&&s.splice(r+1,0,pe(e,i,n.clock-i.id.clock+1)),i},Rl=(e,t,n)=>{const s=e.clients.get(t.id.client);s[Y(s,t.id.clock)]=n},zs=(e,t,n,s,r)=>{if(s===0)return;const i=n+s;let l=Xe(e,t,n),o;do o=t[l++],i<o.id.clock+o.length&&Xe(e,t,i),r(o);while(l<t.length&&t[l].id.clock<i)};class Ml{constructor(t,n,s){this.doc=t,this.deleteSet=new It,this.beforeState=Ae(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=s,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Gn=(e,t)=>t.deleteSet.clients.size===0&&!wr(t.afterState,(n,s)=>t.beforeState.get(s)!==n)?!1:(dn(t.deleteSet),bl(e,t),Tt(e,t.deleteSet),!0),Yn=(e,t,n)=>{const s=t._item;(s===null||s.id.clock<(e.beforeState.get(s.id.client)||0)&&!s.deleted)&&tt(e.changed,t,wt).add(n)},ne=(e,t)=>{let n=e[t],s=e[t-1],r=t;for(;r>0;n=s,s=e[--r-1]){if(s.deleted===n.deleted&&s.constructor===n.constructor&&s.mergeWith(n)){n instanceof _&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,s);continue}break}const i=t-r;return i&&e.splice(t+1-i,i),i},$l=(e,t,n)=>{for(const[s,r]of e.clients.entries()){const i=t.clients.get(s);for(let l=r.length-1;l>=0;l--){const o=r[l],c=o.clock+o.len;for(let a=Y(i,o.clock),h=i[a];a<i.length&&h.id.clock<c;h=i[++a]){const u=i[a];if(o.clock+o.len<=u.id.clock)break;u instanceof _&&u.deleted&&!u.keep&&n(u)&&u.gc(t,!1)}}}},vl=(e,t)=>{e.clients.forEach((n,s)=>{const r=t.clients.get(s);for(let i=n.length-1;i>=0;i--){const l=n[i],o=Qn(r.length-1,1+Y(r,l.clock+l.len-1));for(let c=o,a=r[c];c>0&&a.id.clock>=l.clock;a=r[c])c-=1+ne(r,c)}})},Ks=(e,t)=>{if(t<e.length){const n=e[t],s=n.doc,r=s.store,i=n.deleteSet,l=n._mergeStructs;try{dn(i),n.afterState=Ae(n.doc.store),s.emit("beforeObserverCalls",[n,s]);const o=[];n.changed.forEach((c,a)=>o.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(n,c)})),o.push(()=>{n.changedParentTypes.forEach((c,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(c=c.filter(h=>h.target._item===null||!h.target._item.deleted),c.forEach(h=>{h.currentTarget=a,h._path=null}),c.sort((h,u)=>h.path.length-u.path.length),o.push(()=>{Bs(a._dEH,c,n)}))}),o.push(()=>s.emit("afterTransaction",[n,s])),o.push(()=>{n._needFormattingCleanup&&ro(n)})}),rn(o,[])}finally{s.gc&&$l(i,r,s.gcFilter),vl(i,r),n.afterState.forEach((h,u)=>{const d=n.beforeState.get(u)||0;if(d!==h){const f=r.clients.get(u),g=it(Y(f,d),1);for(let w=f.length-1;w>=g;)w-=1+ne(f,w)}});for(let h=l.length-1;h>=0;h--){const{client:u,clock:d}=l[h].id,f=r.clients.get(u),g=Y(f,d);g+1<f.length&&ne(f,g+1)>1||g>0&&ne(f,g)}if(!n.local&&n.afterState.get(s.clientID)!==n.beforeState.get(s.clientID)&&(fl(un,As,"[yjs] ",Is,Ts,"Changed the client-id because another client seems to be using it."),s.clientID=Ns()),s.emit("afterTransactionCleanup",[n,s]),s._observers.has("update")){const h=new zt;Gn(h,n)&&s.emit("update",[h.toUint8Array(),n.origin,s,n])}if(s._observers.has("updateV2")){const h=new nt;Gn(h,n)&&s.emit("updateV2",[h.toUint8Array(),n.origin,s,n])}const{subdocsAdded:o,subdocsLoaded:c,subdocsRemoved:a}=n;(o.size>0||a.size>0||c.size>0)&&(o.forEach(h=>{h.clientID=s.clientID,h.collectionid==null&&(h.collectionid=s.collectionid),s.subdocs.add(h)}),a.forEach(h=>s.subdocs.delete(h)),s.emit("subdocs",[{loaded:c,added:o,removed:a},s,n]),a.forEach(h=>h.destroy())),e.length<=t+1?(s._transactionCleanups=[],s.emit("afterAllTransactions",[s,e])):Ks(e,t+1)}}},y=(e,t,n=null,s=!0)=>{const r=e._transactionCleanups;let i=!1,l=null;e._transaction===null&&(i=!0,e._transaction=new Ml(e,n,s),r.push(e._transaction),r.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{l=t(e._transaction)}finally{if(i){const o=e._transaction===r[0];e._transaction=null,o&&Ks(r,0)}}return l};class Fl{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}}const Hn=(e,t,n)=>{_t(e,n.deletions,s=>{s instanceof _&&t.scope.some(r=>r===e.doc||ce(r,s))&&bn(s,!1)})},zn=(e,t,n)=>{let s=null;const r=e.doc,i=e.scope;y(r,o=>{for(;t.length>0&&e.currStackItem===null;){const c=r.store,a=t.pop(),h=new Set,u=[];let d=!1;_t(o,a.insertions,f=>{if(f instanceof _){if(f.redone!==null){let{item:g,diff:w}=qe(c,f.id);w>0&&(g=L(o,p(g.id.client,g.id.clock+w))),f=g}!f.deleted&&i.some(g=>g===o.doc||ce(g,f))&&u.push(f)}}),_t(o,a.deletions,f=>{f instanceof _&&i.some(g=>g===o.doc||ce(g,f))&&!Ht(a.insertions,f.id)&&h.add(f)}),h.forEach(f=>{d=ur(o,f,h,a.insertions,e.ignoreRemoteMapChanges,e)!==null||d});for(let f=u.length-1;f>=0;f--){const g=u[f];e.deleteFilter(g)&&(g.delete(o),d=!0)}e.currStackItem=d?a:null}o.changed.forEach((c,a)=>{c.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),s=o},e);const l=e.currStackItem;if(l!=null){const o=s.changedParentTypes;e.emit("stack-item-popped",[{stackItem:l,type:n,changedParentTypes:o,origin:e},e]),e.currStackItem=null}return l};class Yo extends Zn{constructor(t,{captureTimeout:n=500,captureTransaction:s=c=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:l=!1,doc:o=mt(t)?t[0].doc:t instanceof Ot?t:t.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(t),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=s,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=l,this.captureTimeout=n,this.afterTransactionHandler=c=>{if(!this.captureTransaction(c)||!this.scope.some(S=>c.changedParentTypes.has(S)||S===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;const a=this.undoing,h=this.redoing,u=a?this.redoStack:this.undoStack;a?this.stopCapturing():h||this.clear(!1,!0);const d=new It;c.afterState.forEach((S,b)=>{const En=c.beforeState.get(b)||0,Cn=S-En;Cn>0&&Vt(d,b,En,Cn)});const f=Zr();let g=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!a&&!h){const S=u[u.length-1];S.deletions=ze([S.deletions,c.deleteSet]),S.insertions=ze([S.insertions,d])}else u.push(new Fl(c.deleteSet,d)),g=!0;!a&&!h&&(this.lastChange=f),_t(c,c.deleteSet,S=>{S instanceof _&&this.scope.some(b=>b===c.doc||ce(b,S))&&bn(S,!0)});const w=[{stackItem:u[u.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];g?this.emit("stack-item-added",w):this.emit("stack-item-updated",w)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){const n=new Set(this.scope);t=mt(t)?t:[t],t.forEach(s=>{n.has(s)||(n.add(s),(s instanceof I?s.doc!==this.doc:s!==this.doc)&&xs("[yjs#509] Not same Y.Doc"),this.scope.push(s))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(s=>{t&&(this.undoStack.forEach(r=>Hn(s,this,r)),this.undoStack=[]),n&&(this.redoStack.forEach(r=>Hn(s,this,r)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=zn(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=zn(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*Vl(e){const t=m(e.restDecoder);for(let n=0;n<t;n++){const s=m(e.restDecoder),r=e.readClient();let i=m(e.restDecoder);for(let l=0;l<s;l++){const o=e.readInfo();if(o===10){const c=m(e.restDecoder);yield new v(p(r,i),c),i+=c}else if((we&o)!==0){const c=(o&(W|R))===0,a=new _(p(r,i),null,(o&R)===R?e.readLeftID():null,null,(o&W)===W?e.readRightID():null,c?e.readParentInfo()?e.readString():e.readLeftID():null,c&&(o&Ut)===Ut?e.readString():null,dr(e,o));yield a,i+=a.length}else{const c=e.readLen();yield new $(p(r,i),c),i+=c}}}}class pn{constructor(t,n){this.gen=Vl(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===v);return this.curr}}class wn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}const jl=e=>he(e,Ms,zt),Bl=(e,t)=>{if(e.constructor===$){const{client:n,clock:s}=e.id;return new $(p(n,s+t),e.length-t)}else if(e.constructor===v){const{client:n,clock:s}=e.id;return new v(p(n,s+t),e.length-t)}else{const n=e,{client:s,clock:r}=n.id;return new _(p(s,r+t),null,p(s,r+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},he=(e,t=St,n=nt)=>{if(e.length===1)return e[0];const s=e.map(h=>new t(Dt(h)));let r=s.map(h=>new pn(h,!0)),i=null;const l=new n,o=new wn(l);for(;r=r.filter(d=>d.curr!==null),r.sort((d,f)=>{if(d.curr.id.client===f.curr.id.client){const g=d.curr.id.clock-f.curr.id.clock;return g===0?d.curr.constructor===f.curr.constructor?0:d.curr.constructor===v?1:-1:g}else return f.curr.id.client-d.curr.id.client}),r.length!==0;){const h=r[0],u=h.curr.id.client;if(i!==null){let d=h.curr,f=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=h.next(),f=!0;if(d===null||d.id.client!==u||f&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)P(o,i.struct,i.offset),i={struct:d,offset:0},h.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===v)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{P(o,i.struct,i.offset);const g=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new v(p(u,i.struct.id.clock+i.struct.length),g),offset:0}}else{const g=i.struct.id.clock+i.struct.length-d.id.clock;g>0&&(i.struct.constructor===v?i.struct.length-=g:d=Bl(d,g)),i.struct.mergeWith(d)||(P(o,i.struct,i.offset),i={struct:d,offset:0},h.next())}}else i={struct:h.curr,offset:0},h.next();for(let d=h.curr;d!==null&&d.id.client===u&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==v;d=h.next())P(o,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(P(o,i.struct,i.offset),i=null),mn(o);const c=s.map(h=>fn(h)),a=ze(c);return Tt(l,a),l.toUint8Array()},Jl=(e,t,n=St,s=nt)=>{const r=Vs(t),i=new s,l=new wn(i),o=new n(Dt(e)),c=new pn(o,!1);for(;c.curr;){const h=c.curr,u=h.id.client,d=r.get(u)||0;if(c.curr.constructor===v){c.next();continue}if(h.id.clock+h.length>d)for(P(l,h,it(d-h.id.clock,0)),c.next();c.curr&&c.curr.id.client===u;)P(l,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===u&&c.curr.id.clock+c.curr.length<=d;)c.next()}mn(l);const a=fn(o);return Tt(i,a),i.toUint8Array()},Xs=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:B(e.encoder.restEncoder)}),e.encoder.restEncoder=me(),e.written=0)},P=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Xs(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),k(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},mn=e=>{Xs(e);const t=e.encoder.restEncoder;k(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const s=e.clientStructs[n];k(t,s.written),ke(t,s.restEncoder)}},Gl=(e,t,n,s)=>{const r=new n(Dt(e)),i=new pn(r,!1),l=new s,o=new wn(l);for(let a=i.curr;a!==null;a=i.next())P(o,t(a),0);mn(o);const c=fn(r);return Tt(l,c),l.toUint8Array()},Yl=e=>Gl(e,hi,St,zt),Kn="You must not compute changes after the event-handler fired.";class Ie{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Hl(this.currentTarget,this.target))}deletes(t){return Ht(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw G(Kn);const t=new Map,n=this.target;this.transaction.changed.get(n).forEach(r=>{if(r!==null){const i=n._map.get(r);let l,o;if(this.adds(i)){let c=i.left;for(;c!==null&&this.adds(c);)c=c.left;if(this.deletes(i))if(c!==null&&this.deletes(c))l="delete",o=xe(c.content.getContent());else return;else c!==null&&this.deletes(c)?(l="update",o=xe(c.content.getContent())):(l="add",o=void 0)}else if(this.deletes(i))l="delete",o=xe(i.content.getContent());else return;t.set(r,{action:l,oldValue:o})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw G(Kn);const n=this.target,s=wt(),r=wt(),i=[];if(t={added:s,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let o=null;const c=()=>{o&&i.push(o)};for(let a=n._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((o===null||o.delete===void 0)&&(c(),o={delete:0}),o.delete+=a.length,r.add(a)):this.adds(a)?((o===null||o.insert===void 0)&&(c(),o={insert:[]}),o.insert=o.insert.concat(a.content.getContent()),s.add(a)):((o===null||o.retain===void 0)&&(c(),o={retain:0}),o.retain+=a.length);o!==null&&o.retain===void 0&&c()}this._changes=t}return t}}const Hl=(e,t)=>{const n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let s=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(s+=r.length),r=r.right;n.unshift(s)}t=t._item.parent}return n},O=()=>{xs("Invalid access: Add Yjs type to a document before reading data.")},Ws=80;let kn=0;class zl{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=kn++}}const Kl=e=>{e.timestamp=kn++},qs=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=kn++},Xl=(e,t,n)=>{if(e.length>=Ws){const s=e.reduce((r,i)=>r.timestamp<i.timestamp?r:i);return qs(s,t,n),s}else{const s=new zl(t,n);return e.push(s),s}},Te=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;const n=e._searchMarker.length===0?null:e._searchMarker.reduce((i,l)=>Zt(t-i.index)<Zt(t-l.index)?i:l);let s=e._start,r=0;for(n!==null&&(s=n.p,r=n.index,Kl(n));s.right!==null&&r<t;){if(!s.deleted&&s.countable){if(t<r+s.length)break;r+=s.length}s=s.right}for(;s.left!==null&&r>t;)s=s.left,!s.deleted&&s.countable&&(r-=s.length);for(;s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock;)s=s.left,!s.deleted&&s.countable&&(r-=s.length);return n!==null&&Zt(n.index-r)<s.parent.length/Ws?(qs(n,s,r),n):Xl(e._searchMarker,s,r)},jt=(e,t,n)=>{for(let s=e.length-1;s>=0;s--){const r=e[s];if(n>0){let i=r.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(r.index-=i.length);if(i===null||i.marker===!0){e.splice(s,1);continue}r.p=i,i.marker=!0}(t<r.index||n>0&&t===r.index)&&(r.index=it(t,r.index+n))}},Oe=(e,t,n)=>{const s=e,r=t.changedParentTypes;for(;tt(r,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Bs(s._eH,n,t)};class I{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Vn(),this._dEH=Vn(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw V()}clone(){throw V()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){jn(this._eH,t)}observeDeep(t){jn(this._dEH,t)}unobserve(t){Bn(this._eH,t)}unobserveDeep(t){Bn(this._dEH,t)}toJSON(){}}const Ps=(e,t,n)=>{e.doc??O(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let s=n-t;const r=[];let i=e._start;for(;i!==null&&s>0;){if(i.countable&&!i.deleted){const l=i.content.getContent();if(l.length<=t)t-=l.length;else{for(let o=t;o<l.length&&s>0;o++)r.push(l[o]),s--;t=0}}i=i.right}return r},Zs=e=>{e.doc??O();const t=[];let n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){const s=n.content.getContent();for(let r=0;r<s.length;r++)t.push(s[r])}n=n.right}return t},Bt=(e,t)=>{let n=0,s=e._start;for(e.doc??O();s!==null;){if(s.countable&&!s.deleted){const r=s.content.getContent();for(let i=0;i<r.length;i++)t(r[i],n++,e)}s=s.right}},Qs=(e,t)=>{const n=[];return Bt(e,(s,r)=>{n.push(t(s,r,e))}),n},Wl=e=>{let t=e._start,n=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),s=0,t=t.right}const r=n[s++];return n.length<=s&&(n=null),{done:!1,value:r}}}},tr=(e,t)=>{e.doc??O();const n=Te(e,t);let s=e._start;for(n!==null&&(s=n.p,t-=n.index);s!==null;s=s.right)if(!s.deleted&&s.countable){if(t<s.length)return s.content.getContent()[t];t-=s.length}},ae=(e,t,n,s)=>{let r=n;const i=e.doc,l=i.clientID,o=i.store,c=n===null?t._start:n.right;let a=[];const h=()=>{a.length>0&&(r=new _(p(l,E(o,l)),r,r&&r.lastId,c,c&&c.id,t,null,new rt(a)),r.integrate(e,0),a=[])};s.forEach(u=>{if(u===null)a.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(u);break;default:switch(h(),u.constructor){case Uint8Array:case ArrayBuffer:r=new _(p(l,E(o,l)),r,r&&r.lastId,c,c&&c.id,t,null,new Kt(new Uint8Array(u))),r.integrate(e,0);break;case Ot:r=new _(p(l,E(o,l)),r,r&&r.lastId,c,c&&c.id,t,null,new Xt(u)),r.integrate(e,0);break;default:if(u instanceof I)r=new _(p(l,E(o,l)),r,r&&r.lastId,c,c&&c.id,t,null,new K(u)),r.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},er=()=>G("Length exceeded!"),nr=(e,t,n,s)=>{if(n>t._length)throw er();if(n===0)return t._searchMarker&&jt(t._searchMarker,n,s.length),ae(e,t,null,s);const r=n,i=Te(t,n);let l=t._start;for(i!==null&&(l=i.p,n-=i.index,n===0&&(l=l.prev,n+=l&&l.countable&&!l.deleted?l.length:0));l!==null;l=l.right)if(!l.deleted&&l.countable){if(n<=l.length){n<l.length&&L(e,p(l.id.client,l.id.clock+n));break}n-=l.length}return t._searchMarker&&jt(t._searchMarker,r,s.length),ae(e,t,l,s)},ql=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((i,l)=>l.index>i.index?l:i,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return ae(e,t,r,n)},sr=(e,t,n,s)=>{if(s===0)return;const r=n,i=s,l=Te(t,n);let o=t._start;for(l!==null&&(o=l.p,n-=l.index);o!==null&&n>0;o=o.right)!o.deleted&&o.countable&&(n<o.length&&L(e,p(o.id.client,o.id.clock+n)),n-=o.length);for(;s>0&&o!==null;)o.deleted||(s<o.length&&L(e,p(o.id.client,o.id.clock+s)),o.delete(e),s-=o.length),o=o.right;if(s>0)throw er();t._searchMarker&&jt(t._searchMarker,r,-i+s)},ue=(e,t,n)=>{const s=t._map.get(n);s!==void 0&&s.delete(e)},yn=(e,t,n,s)=>{const r=t._map.get(n)||null,i=e.doc,l=i.clientID;let o;if(s==null)o=new rt([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:o=new rt([s]);break;case Uint8Array:o=new Kt(s);break;case Ot:o=new Xt(s);break;default:if(s instanceof I)o=new K(s);else throw new Error("Unexpected content type")}new _(p(l,E(i.store,l)),r,r&&r.lastId,null,null,t,n,o).integrate(e,0)},_n=(e,t)=>{e.doc??O();const n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},rr=e=>{const t={};return e.doc??O(),e._map.forEach((n,s)=>{n.deleted||(t[s]=n.content.getContent()[n.length-1])}),t},ir=(e,t)=>{e.doc??O();const n=e._map.get(t);return n!==void 0&&!n.deleted},Pl=(e,t)=>{const n={};return e._map.forEach((s,r)=>{let i=s;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&ct(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},qt=e=>(e.doc??O(),gl(e._map.entries(),t=>!t[1].deleted));class Zl extends Ie{}class pt extends I{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new pt;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new pt}clone(){const t=new pt;return t.insert(0,this.toArray().map(n=>n instanceof I?n.clone():n)),t}get length(){return this.doc??O(),this._length}_callObserver(t,n){super._callObserver(t,n),Oe(this,t,new Zl(this,t))}insert(t,n){this.doc!==null?y(this.doc,s=>{nr(s,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?y(this.doc,n=>{ql(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?y(this.doc,s=>{sr(s,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return tr(this,t)}toArray(){return Zs(this)}slice(t=0,n=this.length){return Ps(this,t,n)}toJSON(){return this.map(t=>t instanceof I?t.toJSON():t)}map(t){return Qs(this,t)}forEach(t){Bt(this,t)}[Symbol.iterator](){return Wl(this)}_write(t){t.writeTypeRef(Co)}}const Ql=e=>new pt;class to extends Ie{constructor(t,n,s){super(t,n),this.keysChanged=s}}class bt extends I{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((s,r)=>{this.set(r,s)}),this._prelimContent=null}_copy(){return new bt}clone(){const t=new bt;return this.forEach((n,s)=>{t.set(s,n instanceof I?n.clone():n)}),t}_callObserver(t,n){Oe(this,t,new to(this,t,n))}toJSON(){this.doc??O();const t={};return this._map.forEach((n,s)=>{if(!n.deleted){const r=n.content.getContent()[n.length-1];t[s]=r instanceof I?r.toJSON():r}}),t}get size(){return[...qt(this)].length}keys(){return ve(qt(this),t=>t[0])}values(){return ve(qt(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return ve(qt(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??O(),this._map.forEach((n,s)=>{n.deleted||t(n.content.getContent()[n.length-1],s,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?y(this.doc,n=>{ue(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?y(this.doc,s=>{yn(s,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return _n(this,t)}has(t){return ir(this,t)}clear(){this.doc!==null?y(this.doc,t=>{this.forEach(function(n,s,r){ue(t,r,s)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Do)}}const eo=e=>new bt,Z=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&oi(e,t);class We{constructor(t,n,s,r){this.left=t,this.right=n,this.index=s,this.currentAttributes=r}forward(){this.right===null&&M(),this.right.content.constructor===D?this.right.deleted||xt(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const Xn=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===D?t.right.deleted||xt(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&L(e,p(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},Pt=(e,t,n,s)=>{const r=new Map,i=s?Te(t,n):null;if(i){const l=new We(i.p.left,i.p,i.index,r);return Xn(e,l,n-i.index)}else{const l=new We(null,t._start,0,r);return Xn(e,l,n)}},lr=(e,t,n,s)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===D&&Z(s.get(n.right.content.key),n.right.content.value));)n.right.deleted||s.delete(n.right.content.key),n.forward();const r=e.doc,i=r.clientID;s.forEach((l,o)=>{const c=n.left,a=n.right,h=new _(p(i,E(r.store,i)),c,c&&c.lastId,a,a&&a.id,t,null,new D(o,l));h.integrate(e,0),n.right=h,n.forward()})},xt=(e,t)=>{const{key:n,value:s}=t;s===null?e.delete(n):e.set(n,s)},or=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===D&&Z(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},cr=(e,t,n,s)=>{const r=e.doc,i=r.clientID,l=new Map;for(const o in s){const c=s[o],a=n.currentAttributes.get(o)??null;if(!Z(a,c)){l.set(o,a);const{left:h,right:u}=n;n.right=new _(p(i,E(r.store,i)),h,h&&h.lastId,u,u&&u.id,t,null,new D(o,c)),n.right.integrate(e,0),n.forward()}}return l},Fe=(e,t,n,s,r)=>{n.currentAttributes.forEach((d,f)=>{r[f]===void 0&&(r[f]=null)});const i=e.doc,l=i.clientID;or(n,r);const o=cr(e,t,n,r),c=s.constructor===String?new H(s):s instanceof I?new K(s):new lt(s);let{left:a,right:h,index:u}=n;t._searchMarker&&jt(t._searchMarker,n.index,c.getLength()),h=new _(p(l,E(i.store,l)),a,a&&a.lastId,h,h&&h.id,t,null,c),h.integrate(e,0),n.right=h,n.index=u,n.forward(),lr(e,t,n,o)},Wn=(e,t,n,s,r)=>{const i=e.doc,l=i.clientID;or(n,r);const o=cr(e,t,n,r);t:for(;n.right!==null&&(s>0||o.size>0&&(n.right.deleted||n.right.content.constructor===D));){if(!n.right.deleted)switch(n.right.content.constructor){case D:{const{key:c,value:a}=n.right.content,h=r[c];if(h!==void 0){if(Z(h,a))o.delete(c);else{if(s===0)break t;o.set(c,a)}n.right.delete(e)}else n.currentAttributes.set(c,a);break}default:s<n.right.length&&L(e,p(n.right.id.client,n.right.id.clock+s)),s-=n.right.length;break}n.forward()}if(s>0){let c="";for(;s>0;s--)c+=`
4
+ `;n.right=new _(p(l,E(i.store,l)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new H(c)),n.right.integrate(e,0),n.forward()}lr(e,t,n,o)},hr=(e,t,n,s,r)=>{let i=t;const l=F();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===D){const a=i.content;l.set(a.key,a)}i=i.right}let o=0,c=!1;for(;t!==i;){if(n===t&&(c=!0),!t.deleted){const a=t.content;if(a.constructor===D){const{key:h,value:u}=a,d=s.get(h)??null;(l.get(h)!==a||d===u)&&(t.delete(e),o++,!c&&(r.get(h)??null)===u&&d!==u&&(d===null?r.delete(h):r.set(h,d))),!c&&!t.deleted&&xt(r,a)}}t=t.right}return o},no=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===D){const s=t.content.key;n.has(s)?t.delete(e):n.add(s)}t=t.left}},so=e=>{let t=0;return y(e.doc,n=>{let s=e._start,r=e._start,i=F();const l=je(i);for(;r;)r.deleted===!1&&(r.content.constructor===D?xt(l,r.content):(t+=hr(n,s,r,i,l),i=je(l),s=r)),r=r.right}),t},ro=e=>{const t=new Set,n=e.doc;for(const[s,r]of e.afterState.entries()){const i=e.beforeState.get(s)||0;r!==i&&zs(e,n.store.clients.get(s),i,r,l=>{!l.deleted&&l.content.constructor===D&&l.constructor!==$&&t.add(l.parent)})}y(n,s=>{_t(e,e.deleteSet,r=>{if(r instanceof $||!r.parent._hasFormatting||t.has(r.parent))return;const i=r.parent;r.content.constructor===D?t.add(i):no(s,r)});for(const r of t)so(r)})},qn=(e,t,n)=>{const s=n,r=je(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case K:case lt:case H:n<t.right.length&&L(e,p(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&hr(e,i,t.right,r,t.currentAttributes);const l=(t.left||t.right).parent;return l._searchMarker&&jt(l._searchMarker,t.index,-s+n),t};class io extends Ie{constructor(t,n,s){super(t,n),this.childListChanged=!1,this.keysChanged=new Set,s.forEach(r=>{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){if(this._changes===null){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){const t=this.target.doc,n=[];y(t,s=>{const r=new Map,i=new Map;let l=this.target._start,o=null;const c={};let a="",h=0,u=0;const d=()=>{if(o!==null){let f=null;switch(o){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof a=="object"||a.length>0)&&(f={insert:a},r.size>0&&(f.attributes={},r.forEach((g,w)=>{g!==null&&(f.attributes[w]=g)}))),a="";break;case"retain":h>0&&(f={retain:h},li(c)||(f.attributes=si({},c))),h=0;break}f&&n.push(f),o=null}};for(;l!==null;){switch(l.content.constructor){case K:case lt:this.adds(l)?this.deletes(l)||(d(),o="insert",a=l.content.getContent()[0],d()):this.deletes(l)?(o!=="delete"&&(d(),o="delete"),u+=1):l.deleted||(o!=="retain"&&(d(),o="retain"),h+=1);break;case H:this.adds(l)?this.deletes(l)||(o!=="insert"&&(d(),o="insert"),a+=l.content.str):this.deletes(l)?(o!=="delete"&&(d(),o="delete"),u+=l.length):l.deleted||(o!=="retain"&&(d(),o="retain"),h+=l.length);break;case D:{const{key:f,value:g}=l.content;if(this.adds(l)){if(!this.deletes(l)){const w=r.get(f)??null;Z(w,g)?g!==null&&l.delete(s):(o==="retain"&&d(),Z(g,i.get(f)??null)?delete c[f]:c[f]=g)}}else if(this.deletes(l)){i.set(f,g);const w=r.get(f)??null;Z(w,g)||(o==="retain"&&d(),c[f]=w)}else if(!l.deleted){i.set(f,g);const w=c[f];w!==void 0&&(Z(w,g)?w!==null&&l.delete(s):(o==="retain"&&d(),g===null?delete c[f]:c[f]=g))}l.deleted||(o==="insert"&&d(),xt(r,l.content));break}}l=l.right}for(d();n.length>0;){const f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class Et extends I{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??O(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(s=>s())}catch(s){console.error(s)}this._pending=null}_copy(){return new Et}clone(){const t=new Et;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);const s=new io(this,t,n);Oe(this,t,s),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??O();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===H&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?y(this.doc,s=>{const r=new We(null,this._start,0,new Map);for(let i=0;i<t.length;i++){const l=t[i];if(l.insert!==void 0){const o=!n&&typeof l.insert=="string"&&i===t.length-1&&r.right===null&&l.insert.slice(-1)===`
5
+ `?l.insert.slice(0,-1):l.insert;(typeof o!="string"||o.length>0)&&Fe(s,this,r,o,l.attributes||{})}else l.retain!==void 0?Wn(s,this,r,l.retain,l.attributes||{}):l.delete!==void 0&&qn(s,r,l.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,s){this.doc??O();const r=[],i=new Map,l=this.doc;let o="",c=this._start;function a(){if(o.length>0){const u={};let d=!1;i.forEach((g,w)=>{d=!0,u[w]=g});const f={insert:o};d&&(f.attributes=u),r.push(f),o=""}}const h=()=>{for(;c!==null;){if(ct(c,t)||n!==void 0&&ct(c,n))switch(c.content.constructor){case H:{const u=i.get("ychange");t!==void 0&&!ct(c,t)?(u===void 0||u.user!==c.id.client||u.type!=="removed")&&(a(),i.set("ychange",s?s("removed",c.id):{type:"removed"})):n!==void 0&&!ct(c,n)?(u===void 0||u.user!==c.id.client||u.type!=="added")&&(a(),i.set("ychange",s?s("added",c.id):{type:"added"})):u!==void 0&&(a(),i.delete("ychange")),o+=c.content.str;break}case K:case lt:{a();const u={insert:c.content.getContent()[0]};if(i.size>0){const d={};u.attributes=d,i.forEach((f,g)=>{d[g]=f})}r.push(u);break}case D:ct(c,t)&&(a(),xt(i,c.content));break}c=c.right}a()};return t||n?y(l,u=>{t&&Ke(u,t),n&&Ke(u,n),h()},"cleanup"):h(),r}insert(t,n,s){if(n.length<=0)return;const r=this.doc;r!==null?y(r,i=>{const l=Pt(i,this,t,!s);s||(s={},l.currentAttributes.forEach((o,c)=>{s[c]=o})),Fe(i,this,l,n,s)}):this._pending.push(()=>this.insert(t,n,s))}insertEmbed(t,n,s){const r=this.doc;r!==null?y(r,i=>{const l=Pt(i,this,t,!s);Fe(i,this,l,n,s||{})}):this._pending.push(()=>this.insertEmbed(t,n,s||{}))}delete(t,n){if(n===0)return;const s=this.doc;s!==null?y(s,r=>{qn(r,Pt(r,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,s){if(n===0)return;const r=this.doc;r!==null?y(r,i=>{const l=Pt(i,this,t,!1);l.right!==null&&Wn(i,this,l,n,s)}):this._pending.push(()=>this.format(t,n,s))}removeAttribute(t){this.doc!==null?y(this.doc,n=>{ue(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?y(this.doc,s=>{yn(s,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return _n(this,t)}getAttributes(){return rr(this)}_write(t){t.writeTypeRef(Ao)}}const lo=e=>new Et;class Ve{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??O()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===Ct||n.constructor===st)&&n._start!==null)t=n._start;else for(;t!==null;){const s=t.next;if(s!==null){t=s;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class st extends I{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new st}clone(){const t=new st;return t.insert(0,this.toArray().map(n=>n instanceof I?n.clone():n)),t}get length(){return this.doc??O(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Ve(this,t)}querySelector(t){t=t.toUpperCase();const s=new Ve(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return s.done?null:s.value}querySelectorAll(t){return t=t.toUpperCase(),Q(new Ve(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){Oe(this,t,new ho(this,n,t))}toString(){return Qs(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},s){const r=t.createDocumentFragment();return s!==void 0&&s._createAssociation(r,this),Bt(this,i=>{r.insertBefore(i.toDOM(t,n,s),null)}),r}insert(t,n){this.doc!==null?y(this.doc,s=>{nr(s,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)y(this.doc,s=>{const r=t&&t instanceof I?t._item:t;ae(s,this,r,n)});else{const s=this._prelimContent,r=t===null?0:s.findIndex(i=>i===t)+1;if(r===0&&t!==null)throw G("Reference item not found");s.splice(r,0,...n)}}delete(t,n=1){this.doc!==null?y(this.doc,s=>{sr(s,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return Zs(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return tr(this,t)}slice(t=0,n=this.length){return Ps(this,t,n)}forEach(t){Bt(this,t)}_write(t){t.writeTypeRef(To)}}const oo=e=>new st;class Ct extends st{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((s,r)=>{this.setAttribute(r,s)}),this._prelimAttrs=null}_copy(){return new Ct(this.nodeName)}clone(){const t=new Ct(this.nodeName),n=this.getAttributes();return ii(n,(s,r)=>{t.setAttribute(r,s)}),t.insert(0,this.toArray().map(s=>s instanceof I?s.clone():s)),t}toString(){const t=this.getAttributes(),n=[],s=[];for(const o in t)s.push(o);s.sort();const r=s.length;for(let o=0;o<r;o++){const c=s[o];n.push(c+'="'+t[c]+'"')}const i=this.nodeName.toLocaleLowerCase(),l=n.length>0?" "+n.join(" "):"";return`<${i}${l}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?y(this.doc,n=>{ue(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?y(this.doc,s=>{yn(s,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return _n(this,t)}hasAttribute(t){return ir(this,t)}getAttributes(t){return t?Pl(this,t):rr(this)}toDOM(t=document,n={},s){const r=t.createElement(this.nodeName),i=this.getAttributes();for(const l in i){const o=i[l];typeof o=="string"&&r.setAttribute(l,o)}return Bt(this,l=>{r.appendChild(l.toDOM(t,n,s))}),s!==void 0&&s._createAssociation(r,this),r}_write(t){t.writeTypeRef(Io),t.writeKey(this.nodeName)}}const co=e=>new Ct(e.readKey());class ho extends Ie{constructor(t,n,s){super(t,s),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}}class de extends bt{constructor(t){super(),this.hookName=t}_copy(){return new de(this.hookName)}clone(){const t=new de(this.hookName);return this.forEach((n,s)=>{t.set(s,n)}),t}toDOM(t=document,n={},s){const r=n[this.hookName];let i;return r!==void 0?i=r.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),s!==void 0&&s._createAssociation(i,this),i}_write(t){t.writeTypeRef(Oo),t.writeKey(this.hookName)}}const ao=e=>new de(e.readKey());class fe extends Et{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new fe}clone(){const t=new fe;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,s){const r=t.createTextNode(this.toString());return s!==void 0&&s._createAssociation(r,this),r}toString(){return this.toDelta().map(t=>{const n=[];for(const r in t.attributes){const i=[];for(const l in t.attributes[r])i.push({key:l,value:t.attributes[r][l]});i.sort((l,o)=>l.key<o.key?-1:1),n.push({nodeName:r,attrs:i})}n.sort((r,i)=>r.nodeName<i.nodeName?-1:1);let s="";for(let r=0;r<n.length;r++){const i=n[r];s+=`<${i.nodeName}`;for(let l=0;l<i.attrs.length;l++){const o=i.attrs[l];s+=` ${o.key}="${o.value}"`}s+=">"}s+=t.insert;for(let r=n.length-1;r>=0;r--)s+=`</${n[r].nodeName}>`;return s}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(xo)}}const uo=e=>new fe;class Sn{constructor(t,n){this.id=t,this.length=n}get deleted(){throw V()}mergeWith(t){return!1}write(t,n,s){throw V()}integrate(t,n){throw V()}}const fo=0;class $ extends Sn{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),Hs(t.doc.store,this)}write(t,n){t.writeInfo(fo),t.writeLen(this.length-n)}getMissing(t,n){return null}}class Kt{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Kt(this.content)}splice(t){throw V()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}}const go=e=>new Kt(e.readBuf());class Jt{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Jt(this.len)}splice(t){const n=new Jt(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){Vt(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}}const po=e=>new Jt(e.readLen()),ar=(e,t)=>new Ot({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class Xt{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Xt(ar(this.doc.guid,this.opts))}splice(t){throw V()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}const wo=e=>new Xt(ar(e.readString(),e.readAny()));class lt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new lt(this.embed)}splice(t){throw V()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}}const mo=e=>new lt(e.readJSON());class D{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new D(this.key,this.value)}splice(t){throw V()}mergeWith(t){return!1}integrate(t,n){const s=n.parent;s._searchMarker=null,s._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}const ko=e=>new D(e.readKey(),e.readJSON());class ge{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ge(this.arr)}splice(t){const n=new ge(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const s=this.arr.length;t.writeLen(s-n);for(let r=n;r<s;r++){const i=this.arr[r];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const yo=e=>{const t=e.readLen(),n=[];for(let s=0;s<t;s++){const r=e.readString();r==="undefined"?n.push(void 0):n.push(JSON.parse(r))}return new ge(n)},_o=ie("node_env")==="development";class rt{constructor(t){this.arr=t,_o&&ls(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new rt(this.arr)}splice(t){const n=new rt(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const s=this.arr.length;t.writeLen(s-n);for(let r=n;r<s;r++){const i=this.arr[r];t.writeAny(i)}}getRef(){return 8}}const So=e=>{const t=e.readLen(),n=[];for(let s=0;s<t;s++)n.push(e.readAny());return new rt(n)};class H{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new H(this.str)}splice(t){const n=new H(this.str.slice(t));this.str=this.str.slice(0,t);const s=this.str.charCodeAt(t-1);return s>=55296&&s<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const bo=e=>new H(e.readString()),Eo=[Ql,eo,lo,co,oo,ao,uo],Co=0,Do=1,Ao=2,Io=3,To=4,Oo=5,xo=6;class K{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new K(this.type._copy())}splice(t){throw V()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(s=>{s.deleted?s.id.clock<(t.beforeState.get(s.id.client)||0)&&t._mergeStructs.push(s):s.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(s=>{for(;s!==null;)s.gc(t,!0),s=s.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}}const Lo=e=>new K(Eo[e.readTypeRef()](e)),qe=(e,t)=>{let n=t,s=0,r;do s>0&&(n=p(n.client,n.clock+s)),r=gt(e,n),s=n.clock-r.id.clock,n=r.redone;while(n!==null&&r instanceof _);return{item:r,diff:s}},bn=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},pe=(e,t,n)=>{const{client:s,clock:r}=t.id,i=new _(p(s,r+n),t,p(s,r+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=p(t.redone.client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i},Pn=(e,t)=>Ze(e,n=>Ht(n.deletions,t)),ur=(e,t,n,s,r,i)=>{const l=e.doc,o=l.store,c=l.clientID,a=t.redone;if(a!==null)return L(e,a);let h=t.parent._item,u=null,d;if(h!==null&&h.deleted===!0){if(h.redone===null&&(!n.has(h)||ur(e,h,n,s,r,i)===null))return null;for(;h.redone!==null;)h=L(e,h.redone)}const f=h===null?t.parent:h.content.type;if(t.parentSub===null){for(u=t.left,d=t;u!==null;){let b=u;for(;b!==null&&b.parent._item!==h;)b=b.redone===null?null:L(e,b.redone);if(b!==null&&b.parent._item===h){u=b;break}u=u.left}for(;d!==null;){let b=d;for(;b!==null&&b.parent._item!==h;)b=b.redone===null?null:L(e,b.redone);if(b!==null&&b.parent._item===h){d=b;break}d=d.right}}else if(d=null,t.right&&!r){for(u=t;u!==null&&u.right!==null&&(u.right.redone||Ht(s,u.right.id)||Pn(i.undoStack,u.right.id)||Pn(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=L(e,u.redone);if(u&&u.right!==null)return null}else u=f._map.get(t.parentSub)||null;const g=E(o,c),w=p(c,g),S=new _(w,u,u&&u.lastId,d,d&&d.id,f,t.parentSub,t.content.copy());return t.redone=w,bn(S,!0),S.integrate(e,0),S};class _ extends Sn{constructor(t,n,s,r,i,l,o,c){super(t,c.getLength()),this.origin=s,this.left=n,this.right=r,this.rightOrigin=i,this.parent=l,this.parentSub=o,this.redone=null,this.content=c,this.info=this.content.isCountable()?An:0}set marker(t){(this.info&Ue)>0!==t&&(this.info^=Ue)}get marker(){return(this.info&Ue)>0}get keep(){return(this.info&Dn)>0}set keep(t){this.keep!==t&&(this.info^=Dn)}get countable(){return(this.info&An)>0}get deleted(){return(this.info&Le)>0}set deleted(t){this.deleted!==t&&(this.info^=Le)}markDeleted(){this.info|=Le}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=E(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=E(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ft&&this.id.client!==this.parent.client&&this.parent.clock>=E(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Jn(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=L(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===$||this.right&&this.right.constructor===$)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===_?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===_&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ft){const s=gt(n,this.parent);s.constructor===$?this.parent=null:this.parent=s.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=Jn(t,t.doc.store,p(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let s=this.left,r;if(s!==null)r=s.right;else if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start;const i=new Set,l=new Set;for(;r!==null&&r!==this.right;){if(l.add(r),i.add(r),ht(this.origin,r.origin)){if(r.id.client<this.id.client)s=r,i.clear();else if(ht(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&l.has(gt(t.doc.store,r.origin)))i.has(gt(t.doc.store,r.origin))||(s=r,i.clear());else break;r=r.right}this.left=s}if(this.left!==null){const s=this.left.right;this.right=s,this.left.right=this}else{let s;if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start,this.parent._start=this;this.right=s}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Hs(t.doc.store,this),this.content.integrate(t,this),Yn(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new $(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:p(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&ht(t.origin,this.lastId)&&this.right===t&&ht(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(s=>{s.p===t&&(s.p=this,!this.deleted&&this.countable&&(s.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Vt(t.deleteSet,this.id.client,this.id.clock,this.length),Yn(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw M();this.content.gc(t),n?Rl(t,this,new $(this.id,this.length)):this.content=new Jt(this.length)}write(t,n){const s=n>0?p(this.id.client,this.id.clock+n-1):this.origin,r=this.rightOrigin,i=this.parentSub,l=this.content.getRef()&we|(s===null?0:R)|(r===null?0:W)|(i===null?0:Ut);if(t.writeInfo(l),s!==null&&t.writeLeftID(s),r!==null&&t.writeRightID(r),s===null&&r===null){const o=this.parent;if(o._item!==void 0){const c=o._item;if(c===null){const a=Js(o);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(c.id)}else o.constructor===String?(t.writeParentInfo(!0),t.writeString(o)):o.constructor===ft?(t.writeParentInfo(!1),t.writeLeftID(o)):M();i!==null&&t.writeString(i)}this.content.write(t,n)}}const dr=(e,t)=>Uo[t&we](e),Uo=[()=>{M()},po,yo,go,bo,mo,ko,Lo,So,wo,()=>{M()}],No=10;class v extends Sn{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){M()}write(t,n){t.writeInfo(No),k(t.restEncoder,this.length-n)}getMissing(t,n){return null}}const fr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},gr="__ $YJS$ __";fr[gr]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");fr[gr]=!0;export{Ot as D,Yo as U,$o as a,vo as b,jo as c,Bo as d,Fo as e,Jo as f,Go as g,it as h,Ro as i,X as j,Qn as m,Vo as r,Mo as t};