@inkeep/open-knowledge 0.0.0-dev-20260501054734 → 0.0.0-dev-20260501071238
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.
- package/dist/assets/skills/open-knowledge/SKILL.md +12 -12
- package/dist/cli.mjs +345 -346
- package/dist/config-schema.json +1 -30
- package/dist/config.project.schema.json +1 -30
- package/dist/constants-Ccx0q5EO.mjs +2 -0
- package/dist/dist-B-uWyCj3.mjs +1 -0
- package/dist/{dist-Bk22-nn7.mjs → dist-CUghvkAf.mjs} +72 -70
- package/dist/{dist-BKxD-v-w.mjs → dist-WQbZIrx7.mjs} +36 -36
- package/dist/index.d.mts +1 -3
- package/dist/index.mjs +1 -1
- package/dist/{init-DEHyWHMa.mjs → init-DMUmlRUV.mjs} +29 -29
- package/dist/{init-DVZtt6e-.mjs → init-DQVmtI8h.mjs} +25 -16
- package/dist/init-Dd-ypqWc.mjs +1 -0
- package/dist/init-jnyR2hTf.mjs +1 -0
- package/dist/loader-IVNXMdm0.mjs +4 -0
- package/dist/loader-dh9DEQFy.mjs +1 -0
- package/dist/paths-Bp5ooOJg.mjs +2 -0
- package/dist/paths-CcnZRq8W.mjs +1 -0
- package/dist/preview-SUAZQ5h2.mjs +1 -0
- package/dist/preview-tSq0pzNL.mjs +3 -0
- package/dist/public/assets/{ActivityModeContent-BSkmKRy4.js → ActivityModeContent-Bj0kOgDy.js} +1 -1
- package/dist/public/assets/{DocumentContext-D3zjM2ax.js → DocumentContext-CDvFNgd7.js} +1 -1
- package/dist/public/assets/{GraphPanel-jbwIk-JX.js → GraphPanel-YIuSwj1X.js} +1 -1
- package/dist/public/assets/{SettingsPane-Bj0EiYda.js → SettingsPane-BYRRZ2yt.js} +1 -1
- package/dist/public/assets/{SourceEditor-Dz2Lc5LE.js → SourceEditor-BkBM9oYb.js} +1 -1
- package/dist/public/assets/{clipboard-i7TzBQ01.js → clipboard-BTbzStNo.js} +1 -1
- package/dist/public/assets/{config-validation-events-DpHbVC_H.js → config-validation-events-gPU2C30Q.js} +1 -1
- package/dist/public/assets/{index-joGKm2Br.js → index-C0JKXDVX.js} +71 -71
- package/dist/public/assets/{target-navigation-intent-CK4Ee17H.js → target-navigation-intent-BeUCdVKa.js} +1 -1
- package/dist/public/assets/{toggle-group-n36XMgMC.js → toggle-group-CyBGhndP.js} +6 -4
- package/dist/public/assets/{tooltip-BM5o_T0o.js → tooltip-FdwzzIbl.js} +1 -1
- package/dist/public/index.html +7 -7
- package/dist/schemas/v0/config.project.schema.json +1 -30
- package/dist/server-Bc0tGxRk.mjs +3 -0
- package/dist/{server-lock-n3Y5JWNv-3o7br8XE.mjs → server-lock-BAi_a4NX-CRPhQdIH.mjs} +1 -1
- package/dist/server-lock-BAi_a4NX-uRxotxS6.mjs +1 -0
- package/dist/src-B-NdiXlJ.mjs +1 -0
- package/dist/start-CUBxPqPc.mjs +2 -0
- package/dist/start-GoM45WVd.mjs +1 -0
- package/package.json +1 -1
- package/scripts/build-config-schema.mjs +2 -2
- package/dist/constants-C_Xn28oM.mjs +0 -2
- package/dist/dist-BuWOuGGO.mjs +0 -1
- package/dist/init-BrZlKzcx.mjs +0 -1
- package/dist/init-gZdio8Wt.mjs +0 -1
- package/dist/loader-CEV6AVlU.mjs +0 -1
- package/dist/loader-DD2NITvw.mjs +0 -2
- package/dist/paths-Dwr32i3p.mjs +0 -1
- package/dist/paths-ajeOK0uP.mjs +0 -2
- package/dist/preview-C86aCB1t.mjs +0 -3
- package/dist/preview-D6fWJCDu.mjs +0 -1
- package/dist/server-CYax-BjV.mjs +0 -3
- package/dist/server-lock-n3Y5JWNv-DXpg9_eU.mjs +0 -1
- package/dist/src-D6R3jg-t.mjs +0 -1
- package/dist/start-D5tAdx92.mjs +0 -2
- package/dist/start-DG0Lr5vX.mjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-C3u7R0q7.js","./dist-dkPJvrfr.js","./chunk-DECur_0Z.js","./w3c-keyname-B5t0fahT.js","./dist-RVD4DzGH.js","./dist-Dtie9-Ui.js","./dist-C82hC0q7.js","./dist-oNAFjGrp.js","./dist-mXs-_OvZ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e,t}from"./chunk-DECur_0Z.js";import{i as n,n as r,t as i}from"./propagation-api-LnD10wq2.js";import{n as a,r as o,t as s}from"./compiler-runtime-Y11fyRVL.js";import{$ as c,$t as l,An as u,B as d,Bn as f,Bt as p,C as m,Cn as h,Ct as g,Dn as _,Et as v,F as y,Fn as b,Gn as x,Gt as S,H as C,Hn as w,In as T,It as E,Kt as D,L as O,M as k,N as A,Nt as j,On as M,Ot as N,P,Pn as F,Qt as I,R as L,Rt as R,S as z,Sn as B,St as V,Tt as H,U,V as ee,Vn as te,W as ne,Xt as re,Yt as W,Z as ie,Zt as ae,_n as oe,a as se,an as ce,at as le,b as ue,bt as de,c as fe,cn as pe,ct as me,d as he,dn as ge,en as _e,et as ve,f as ye,fn as be,ft as xe,gn as Se,gt as Ce,h as we,hn as Te,ht as Ee,i as De,in as Oe,jn as ke,k as Ae,kn as je,ln as Me,lt as Ne,m as Pe,mn as Fe,n as Ie,pn as Le,qn as Re,qt as ze,s as Be,sn as Ve,st as He,t as Ue,tn as We,u as Ge,un as Ke,v as qe,vn as Je,wt as Ye,x as Xe,xn as Ze,xt as Qe,y as $e,yn as et,z as tt,zn as nt}from"./toggle-group-n36XMgMC.js";import{C as rt,S as it,_ as at,a as ot,b as st,c as ct,d as lt,g as ut,i as dt,l as ft,m as pt,p as mt,r as ht,s as gt,t as _t,u as vt,x as yt}from"./button-Dyz7QGIk.js";import{S as bt,_ as xt,a as St,c as Ct,d as wt,f as Tt,g as Et,h as Dt,i as Ot,m as kt,n as At,o as jt,p as Mt,s as Nt,t as Pt,u as Ft,v as It,x as Lt,y as Rt}from"./dialog-FUclf-NK.js";import{B as zt,Bt,D as Vt,Et as Ht,G as Ut,H as Wt,I as Gt,K as Kt,L as G,M as qt,N as Jt,Nt as Yt,P as Xt,Pt as Zt,Tt as Qt,U as $t,V as en,W as tn,Y as nn,Z as rn,_ as an,a as on,b as sn,f as cn,h as ln,i as un,j as dn,jt as fn,k as pn,kt as mn,l as hn,lt as gn,o as _n,p as vn,q as yn,r as bn,s as xn,t as Sn,u as Cn,w as wn,wt as Tn,y as En,z as Dn}from"./dist-dkPJvrfr.js";import{a as On,c as kn,s as An,t as jn}from"./dist-oNAFjGrp.js";import{i as Mn,n as Nn,r as Pn,t as Fn}from"./dist-RVD4DzGH.js";var In=it(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Ln=it(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Rn=it(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),zn=it(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Bn=it(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Vn=it(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Hn=it(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Un=it(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Wn=it(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Gn=it(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Kn=it(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),qn=it(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),Jn=it(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),Yn=it(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),Xn=it(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Zn=it(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Qn=it(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),$n=it(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),er=it(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),tr=it(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),nr=it(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),rr=it(`message-square-warning`,[[`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`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]),ir=it(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),ar=it(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),or=it(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),sr=it(`quote`,[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]),cr=it(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),lr=it(`square-play`,[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}]]),ur=it(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),dr=it(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),fr=it(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),pr=it(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),K=e(a(),1),q=o(),mr=`Collapsible`,[hr,gr]=mt(mr),[_r,vr]=hr(mr),yr=K.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=ft({prop:r,defaultProp:i??!1,onChange:o,caller:mr});return(0,q.jsx)(_r,{scope:n,disabled:a,contentId:gt(),open:c,onOpenToggle:K.useCallback(()=>l(e=>!e),[l]),children:(0,q.jsx)(pt.div,{"data-state":Tr(c),"data-disabled":a?``:void 0,...s,ref:t})})});yr.displayName=mr;var br=`CollapsibleTrigger`,xr=K.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=vr(br,n);return(0,q.jsx)(pt.button,{type:`button`,"aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Tr(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:lt(e.onClick,i.onOpenToggle)})});xr.displayName=br;var Sr=`CollapsibleContent`,Cr=K.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=vr(Sr,e.__scopeCollapsible);return(0,q.jsx)(ct,{present:n||i.open,children:({present:e})=>(0,q.jsx)(wr,{...r,ref:t,present:e})})});Cr.displayName=Sr;var wr=K.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=vr(Sr,n),[s,c]=K.useState(r),l=K.useRef(null),u=st(t,l),d=K.useRef(0),f=d.current,p=K.useRef(0),m=p.current,h=o.open||s,g=K.useRef(h),_=K.useRef(void 0);return K.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),vt(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,q.jsx)(pt.div,{"data-state":Tr(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function Tr(e){return e?`open`:`closed`}var Er=yr,Dr=xr,Or=Cr,kr=t((e=>{var t=a();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),a=r[0].inst,l=r[1];return s(function(){a.value=n,a.getSnapshot=t,u(a)&&l({inst:a})},[e,n,t]),o(function(){return u(a)&&l({inst:a}),e(function(){u(a)&&l({inst:a})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Ar=t(((e,t)=>{t.exports=kr()}));function jr(e){let t=K.useRef({value:e,previous:e});return K.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Mr=`Popover`,[Nr,Pr]=mt(Mr,[ke]),Fr=ke(),[Ir,Lr]=Nr(Mr),Rr=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Fr(t),c=K.useRef(null),[l,d]=K.useState(!1),[f,p]=ft({prop:r,defaultProp:i??!1,onChange:a,caller:Mr});return(0,q.jsx)(u,{...s,children:(0,q.jsx)(Ir,{scope:t,contentId:gt(),triggerRef:c,open:f,onOpenChange:p,onOpenToggle:K.useCallback(()=>p(e=>!e),[p]),hasCustomAnchor:l,onCustomAnchorAdd:K.useCallback(()=>d(!0),[]),onCustomAnchorRemove:K.useCallback(()=>d(!1),[]),modal:o,children:n})})};Rr.displayName=Mr;var zr=`PopoverAnchor`,Br=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Lr(zr,n),a=Fr(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return K.useEffect(()=>(o(),()=>s()),[o,s]),(0,q.jsx)(_,{...a,...r,ref:t})});Br.displayName=zr;var Vr=`PopoverTrigger`,Hr=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Lr(Vr,n),a=Fr(n),o=st(t,i.triggerRef),s=(0,q.jsx)(pt.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":ri(i.open),...r,ref:o,onClick:lt(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,q.jsx)(_,{asChild:!0,...a,children:s})});Hr.displayName=Vr;var Ur=`PopoverPortal`,[Wr,Gr]=Nr(Ur,{forceMount:void 0}),Kr=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Lr(Ur,t);return(0,q.jsx)(Wr,{scope:t,forceMount:n,children:(0,q.jsx)(ct,{present:n||a.open,children:(0,q.jsx)(dt,{asChild:!0,container:i,children:r})})})};Kr.displayName=Ur;var qr=`PopoverContent`,Jr=K.forwardRef((e,t)=>{let n=Gr(qr,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Lr(qr,e.__scopePopover);return(0,q.jsx)(ct,{present:r||a.open,children:a.modal?(0,q.jsx)(Xr,{...i,ref:t}):(0,q.jsx)(Zr,{...i,ref:t})})});Jr.displayName=qr;var Yr=at(`PopoverContent.RemoveScroll`),Xr=K.forwardRef((e,t)=>{let n=Lr(qr,e.__scopePopover),r=K.useRef(null),i=st(t,r),a=K.useRef(!1);return K.useEffect(()=>{let e=r.current;if(e)return Et(e)},[]),(0,q.jsx)(xt,{as:Yr,allowPinchZoom:!0,children:(0,q.jsx)(Qr,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:lt(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:lt(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:lt(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Zr=K.forwardRef((e,t)=>{let n=Lr(qr,e.__scopePopover),r=K.useRef(!1),i=K.useRef(!1);return(0,q.jsx)(Qr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Qr=K.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Lr(qr,n),p=Fr(n);return It(),(0,q.jsx)(Rt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,q.jsx)(ot,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,q.jsx)(je,{"data-state":ri(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),$r=`PopoverClose`,ei=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Lr($r,n);return(0,q.jsx)(pt.button,{type:`button`,...r,ref:t,onClick:lt(e.onClick,()=>i.onOpenChange(!1))})});ei.displayName=$r;var ti=`PopoverArrow`,ni=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Fr(n);return(0,q.jsx)(M,{...i,...r,ref:t})});ni.displayName=ti;function ri(e){return e?`open`:`closed`}var ii=Rr,ai=Br,oi=Hr,si=Kr,ci=Jr,li=`Switch`,[ui,di]=mt(li),[fi,pi]=ui(li),mi=K.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=K.useState(null),m=st(t,e=>p(e)),h=K.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=ft({prop:i,defaultProp:a??!1,onChange:l,caller:li});return(0,q.jsxs)(fi,{scope:n,checked:_,disabled:s,children:[(0,q.jsx)(pt.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":yi(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:lt(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,q.jsx)(vi,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});mi.displayName=li;var hi=`SwitchThumb`,gi=K.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=pi(hi,n);return(0,q.jsx)(pt.span,{"data-state":yi(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});gi.displayName=hi;var _i=`SwitchBubbleInput`,vi=K.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=K.useRef(null),s=st(o,a),c=jr(n),l=w(t);return K.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,q.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});vi.displayName=_i;function yi(e){return e?`checked`:`unchecked`}var bi=mi,xi=gi,Si=e(rt(),1),Ci=Ar(),J=s(),wi=yt(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3! font-mono uppercase`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,warning:`bg-yellow-500/10 text-yellow-600 [a]:hover:bg-yellow-500/20`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`,dashed:`border-dashed border-border text-muted-foreground rounded-sm`}},defaultVariants:{variant:`default`}});function Ti(e){let t=(0,J.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,variant:i,asChild:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a!==void 0&&a?ut:`span`,c;t[5]!==n||t[6]!==o?(c=ht(wi({variant:o}),n),t[5]=n,t[6]=o,t[7]=c):c=t[7];let l;return t[8]!==s||t[9]!==r||t[10]!==c||t[11]!==o?(l=(0,q.jsx)(s,{"data-slot":`badge`,"data-variant":o,className:c,...r}),t[8]=s,t[9]=r,t[10]=c,t[11]=o,t[12]=l):l=t[12],l}function Ei(e){let t=e.split(`/`);return t.length<2?`ok`:`${t[0]}/${t[1]}`}function Di(e){if(!e)return;let t=Object.entries(e);if(t.length!==0)return t.map(([e,t])=>{if(t==null)return[e,String(t)];if(typeof t==`string`)return[e,t];if(typeof t==`number`||typeof t==`boolean`)return[e,String(t)];try{return[e,JSON.stringify(t)]}catch{return[e,`[unserializable]`]}})}function Y(e,t,n){if(typeof performance>`u`||!performance.measure)return;let r=Ei(e),i=Di(t),a={devtools:{dataType:`track-entry`,track:r,...i?{properties:i}:{},...n?.tooltipText?{tooltipText:n.tooltipText}:{}}},o=performance.now(),s=n?.startTime??o,c=n?.duration??Math.max(0,o-s);try{performance.measure(e,{start:s,duration:c,detail:a})}catch{}({...t?{properties:t}:{}})}function Oi(e){let t=(0,J.c)(3),{name:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,q.jsx)(K.Profiler,{id:n,onRender:ki,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var ki=(e,t,n,r,i,a)=>{Y(`ok/render/${e}`,{phase:t,actualDuration:Math.round(n*1e3)/1e3,baseDuration:Math.round(r*1e3)/1e3},{startTime:i,duration:Math.max(0,a-i)})},{getOwnPropertyNames:Ai,getOwnPropertySymbols:ji}=Object,{hasOwnProperty:Mi}=Object.prototype;function Ni(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Pi(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function Fi(e){return e?.[Symbol.toStringTag]}function Ii(e){return Ai(e).concat(ji(e))}var Li=Object.hasOwn||((e,t)=>Mi.call(e,t));function Ri(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var zi=`__v`,Bi=`__o`,Vi=`_owner`,{getOwnPropertyDescriptor:Hi,keys:Ui}=Object;function Wi(e,t){return e.byteLength===t.byteLength&&ra(new Uint8Array(e),new Uint8Array(t))}function Gi(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function Ki(e,t){return e.byteLength===t.byteLength&&ra(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function qi(e,t){return Ri(e.getTime(),t.getTime())}function Ji(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function Yi(e,t){return e===t}function Xi(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var Zi=Ri;function Qi(e,t,n){let r=Ui(e),i=r.length;if(Ui(t).length!==i)return!1;for(;i-- >0;)if(!aa(e,t,n,r[i]))return!1;return!0}function $i(e,t,n){let r=Ii(e),i=r.length;if(Ii(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!aa(e,t,n,a)||(o=Hi(e,a),s=Hi(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function ea(e,t){return Ri(e.valueOf(),t.valueOf())}function ta(e,t){return e.source===t.source&&e.flags===t.flags}function na(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function ra(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function ia(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function aa(e,t,n,r){return(r===Vi||r===Bi||r===zi)&&(e.$$typeof||t.$$typeof)?!0:Li(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var oa=`[object ArrayBuffer]`,sa=`[object Arguments]`,ca=`[object Boolean]`,la=`[object DataView]`,ua=`[object Date]`,da=`[object Error]`,fa=`[object Map]`,pa=`[object Number]`,ma=`[object Object]`,ha=`[object RegExp]`,ga=`[object Set]`,_a=`[object String]`,va={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},ya=`[object URL]`,ba=Object.prototype.toString;function xa({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=ba.call(h);if(b===ua)return r(h,g,_);if(b===ha)return u(h,g,_);if(b===fa)return o(h,g,_);if(b===ga)return d(h,g,_);if(b===ma)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===ya)return p(h,g,_);if(b===da)return i(h,g,_);if(b===sa)return c(h,g,_);if(va[b])return f(h,g,_);if(b===oa)return e(h,g,_);if(b===la)return n(h,g,_);if(b===ca||b===pa||b===_a)return l(h,g,_);if(m){let e=m[b];if(!e){let t=Fi(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function Sa({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Wi,areArraysEqual:n?$i:Gi,areDataViewsEqual:Ki,areDatesEqual:qi,areErrorsEqual:Ji,areFunctionsEqual:Yi,areMapsEqual:n?Ni(Xi,$i):Xi,areNumbersEqual:Zi,areObjectsEqual:n?$i:Qi,arePrimitiveWrappersEqual:ea,areRegExpsEqual:ta,areSetsEqual:n?Ni(na,$i):na,areTypedArraysEqual:n?Ni(ra,$i):ra,areUrlsEqual:ia,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Pi(r.areArraysEqual),t=Pi(r.areMapsEqual),n=Pi(r.areObjectsEqual),i=Pi(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function Ca(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function wa({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var Ta=Ea();Ea({strict:!0}),Ea({circular:!0}),Ea({circular:!0,strict:!0}),Ea({createInternalComparator:()=>Ri}),Ea({strict:!0,createInternalComparator:()=>Ri}),Ea({circular:!0,createInternalComparator:()=>Ri}),Ea({circular:!0,createInternalComparator:()=>Ri,strict:!0});function Ea(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=xa(Sa(e));return wa({circular:t,comparator:a,createState:r,equals:n?n(a):Ca(a),strict:i})}var Da=t((e=>{var t=a(),n=Ar();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,a){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),a!==void 0&&f.hasValue){var t=f.value;if(a(t,e))return c=t}return c=e}if(t=c,i(s,e))return t;var n=r(e);return a!==void 0&&a(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,a]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Oa=t(((e,t)=>{t.exports=Da()}))(),ka=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},Aa=({contentComponent:e})=>{let t=(0,Ci.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,q.jsx)(q.Fragment,{children:Object.values(t)})};function ja(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:Si.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var Ma=class extends K.Component{constructor(e){super(e),this.editorContentRef=K.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=ja(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{ref:ka(t,this.editorContentRef),...n}),e?.contentComponent&&(0,q.jsx)(Aa,{contentComponent:e.contentComponent})]})}},Na=(0,K.forwardRef)((e,t)=>{let n=K.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return K.createElement(Ma,{key:n,innerRef:t,...e})}),Pa=K.memo(Na),Fa=typeof window<`u`?K.useLayoutEffect:K.useEffect,Ia=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function La(e){let[t]=(0,K.useState)(()=>new Ia(e.editor)),n=(0,Oa.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??Ta);return Fa(()=>t.watch(e.editor),[e.editor,t]),(0,K.useDebugValue)(n),n}typeof window>`u`||typeof window<`u`&&window.next;var Ra=(0,K.createContext)({editor:null});Ra.Consumer;var za=()=>(0,K.useContext)(Ra),Ba=(0,K.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Va=()=>(0,K.useContext)(Ba);function Ha({as:e=`div`,...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=Va();return(0,q.jsx)(e,{...t,ref:n,"data-node-view-content":``,style:{whiteSpace:`pre-wrap`,...t.style},children:r})}var Ua=K.forwardRef((e,t)=>{let{onDragStart:n}=Va();return(0,q.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function Wa(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function Ga(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.forward_ref)`||e.$$typeof.description===`react.forward_ref`))}function Ka(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.memo)`||e.$$typeof.description===`react.memo`))}function qa(e){if(Wa(e)||Ga(e))return!0;if(Ka(e)){let t=e.type;if(t)return Wa(t)||Ga(t)}return!1}function Ja(){try{if(K.version)return parseInt(K.version.split(`.`)[0],10)>=19}catch{}return!1}var Ya=class{constructor(e,{editor:t,props:n={},as:r=`div`,className:i=``}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add(`react-renderer`),i&&this.element.classList.add(...i.split(` `)),this.editor.isEditorContentInitialized?(0,Si.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=Ja(),a=qa(t),o={...n};o.ref&&!(i||a)&&delete o.ref,!o.ref&&(i||a)&&(o.ref=e=>{this.ref=e}),this.reactElement=(0,q.jsx)(t,{...o}),(e=r?.contentComponent)==null||e.setRenderer(this.id,this)}updateProps(e={}){this.destroyed||(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0,(e=this.editor?.contentComponent)==null||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};K.createContext({markViewContentRef:()=>{}});var Xa=class extends ae{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.positionCheckCallback=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?`span`:`div`),this.contentDOMElement.dataset.nodeViewContentReact=``,this.contentDOMElement.dataset.nodeViewWrapper=``,this.contentDOMElement.style.whiteSpace=`inherit`;let e=this.dom.querySelector(`[data-node-view-content]`);if(!e)return;e.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,K.createRef)()};if(!this.component.displayName){let e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute(`data-node-view-wrapper`)&&e.removeAttribute(`data-node-view-wrapper`),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,K.memo)(e=>(0,q.jsx)(Ba.Provider,{value:t,children:(0,K.createElement)(n,e)}));r.displayName=`ReactNodeView`;let i=this.node.isInline?`span`:`div`;this.options.as&&(i=this.options.as);let{className:a=``}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Ya(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on(`selectionUpdate`,this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos(),this.positionCheckCallback=()=>{let e=this.getPos();typeof e!=`number`||e===this.currentPos||(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs==`function`&&this.updateElementAttributes())},Me(this.editor,this.positionCheckCallback)}get dom(){if(this.renderer.element.firstElementChild&&!this.renderer.element.firstElementChild?.hasAttribute(`data-node-view-wrapper`))throw Error(`Please use the NodeViewWrapper component for your node view.`);return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;let{from:e,to:t}=this.editor.state.selection,n=this.currentPos;if(typeof n==`number`)if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(e,t,n){let r=e=>{this.renderer.updateProps(e),typeof this.options.attrs==`function`&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update==`function`){let i=this.node,a=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:a,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}let i=this.getPos();return e===this.node&&this.decorations===t&&this.innerDecorations===n?i===this.currentPos?!0:(this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage,getPos:()=>this.getPos()}),!0):(this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage}),!0)}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add(`ProseMirror-selectednode`)}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove(`ProseMirror-selectednode`)}destroy(){this.renderer.destroy(),this.editor.off(`selectionUpdate`,this.handleSelectionUpdate),this.positionCheckCallback&&=(I(this.editor,this.positionCheckCallback),null),this.contentDOMElement=null,this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null)}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs==`function`){let t=this.editor.extensionManager.attributes,n=_e(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function Za(e,t){return n=>n.editor.contentComponent?new Xa(e,n,t):{}}var Qa=(0,K.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});Qa.displayName=`TiptapContext`;var $a=()=>(0,K.useContext)(Qa);function eo({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,K.useMemo)(()=>({editor:r}),[r]),a=(0,K.useMemo)(()=>({editor:r}),[r]);return(0,q.jsx)(Ra.Provider,{value:a,children:(0,q.jsx)(Qa.Provider,{value:i,children:n})})}eo.displayName=`Tiptap`;function to({...e}){let{editor:t}=$a();return(0,q.jsx)(Pa,{editor:t,...e})}to.displayName=`Tiptap.Content`,Object.assign(eo,{Content:to});var no=()=>new Map,ro=e=>{let t=no();return e.forEach((e,n)=>{t.set(n,e)}),t},io=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ao=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},oo=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},so=()=>new Set,co=e=>e[e.length-1],lo=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},uo=Array.from,fo=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},po=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},mo=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},ho=Array.isArray,go=class{constructor(){this._observers=no()}on(e,t){return io(this._observers,e,so).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return uo((this._observers.get(e)||no()).values()).forEach(e=>e(...t))}destroy(){this._observers=no()}},_o=class{constructor(){this._observers=no()}on(e,t){io(this._observers,e,so).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return uo((this._observers.get(e)||no()).values()).forEach(e=>e(...t))}destroy(){this._observers=no()}},vo=Math.floor,yo=Math.abs,bo=(e,t)=>e<t?e:t,xo=(e,t)=>e>t?e:t;Number.isNaN;var So=e=>e===0?1/e<0:e<0,Co=1<<17,wo=1<<18,To=1<<19,Eo=1<<20,Do=1<<21,Oo=1<<22,ko=1<<23,Ao=1<<24,jo=1<<25,Mo=1<<26,No=1<<27,Po=1<<28,Fo=1<<29;Co-1,wo-1,To-1,Eo-1,Do-1,Oo-1,ko-1,Ao-1,jo-1,Mo-1,No-1,Po-1,Fo-1;var Io=2**53-1,Lo=-(2**53-1),Ro=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&vo(e)===e);Number.isNaN,Number.parseInt;var zo=String.fromCharCode;String.fromCodePoint,zo(65535);var Bo=e=>e.toLowerCase(),Vo=/^\s*/g,Ho=e=>e.replace(Vo,``),Uo=/([A-Z])/g,Wo=(e,t)=>Ho(e.replace(Uo,e=>`${t}${Bo(e)}`)),Go=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Ko=typeof TextEncoder<`u`?new TextEncoder:null,qo=Ko?e=>Ko.encode(e):Go,Jo=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Jo&&Jo.decode(new Uint8Array).length===1&&(Jo=null);var Yo=(e,t)=>mo(t,()=>e).join(``),Xo=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Zo=()=>new Xo,Qo=e=>{let t=Zo();return e(t),es(t)},$o=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},es=e=>{let t=new Uint8Array($o(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},ts=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(xo(n,t)*2),e.cpos=0)},ns=(e,t)=>{let 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},rs=ns,is=(e,t)=>{for(;t>127;)ns(e,128|127&t),t=vo(t/128);ns(e,127&t)},as=(e,t)=>{let n=So(t);for(n&&(t=-t),ns(e,(t>63?128:0)|(n?64:0)|63&t),t=vo(t/64);t>0;)ns(e,(t>127?128:0)|127&t),t=vo(t/128)},os=new Uint8Array(3e4),ss=os.length/3,cs=Ko&&Ko.encodeInto?(e,t)=>{if(t.length<ss){let n=Ko.encodeInto(t,os).written||0;is(e,n);for(let t=0;t<n;t++)ns(e,os[t])}else us(e,qo(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;is(e,r);for(let t=0;t<r;t++)ns(e,n.codePointAt(t))},ls=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=bo(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(xo(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},us=(e,t)=>{is(e,t.byteLength),ls(e,t)},ds=(e,t)=>{ts(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},fs=(e,t)=>ds(e,4).setFloat32(0,t,!1),ps=(e,t)=>ds(e,8).setFloat64(0,t,!1),ms=(e,t)=>ds(e,8).setBigInt64(0,t,!1),hs=new DataView(new ArrayBuffer(4)),gs=e=>(hs.setFloat32(0,e),hs.getFloat32(0)===e),_s=(e,t)=>{switch(typeof t){case`string`:ns(e,119),cs(e,t);break;case`number`:Ro(t)&&yo(t)<=2147483647?(ns(e,125),as(e,t)):gs(t)?(ns(e,124),fs(e,t)):(ns(e,123),ps(e,t));break;case`bigint`:ns(e,122),ms(e,t);break;case`object`:if(t===null)ns(e,126);else if(ho(t)){ns(e,117),is(e,t.length);for(let n=0;n<t.length;n++)_s(e,t[n])}else if(t instanceof Uint8Array)ns(e,116),us(e,t);else{ns(e,118);let n=Object.keys(t);is(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];cs(e,i),_s(e,t[i])}}break;case`boolean`:ns(e,t?120:121);break;default:ns(e,127)}},vs=class extends Xo{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&is(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},ys=e=>{e.count>0&&(as(e.encoder,e.count===1?e.s:-e.s),e.count>1&&is(e.encoder,e.count-2))},bs=class{constructor(){this.encoder=new Xo,this.s=0,this.count=0}write(e){this.s===e?this.count++:(ys(this),this.count=1,this.s=e)}toUint8Array(){return ys(this),es(this.encoder)}},xs=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);as(e.encoder,t),e.count>1&&is(e.encoder,e.count-2)}},Ss=class{constructor(){this.encoder=new Xo,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(xs(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return xs(this),es(this.encoder)}},Cs=class{constructor(){this.sarr=[],this.s=``,this.lensE=new bs}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Xo;return this.sarr.push(this.s),this.s=``,cs(e,this.sarr.join(``)),ls(e,this.lensE.toUint8Array()),es(e)}},ws=e=>Error(e),Ts=()=>{throw ws(`Method unimplemented`)},Es=()=>{throw ws(`Unexpected case`)},Ds=ws(`Unexpected end of array`),Os=ws(`Integer out of Range`),ks=class{constructor(e){this.arr=e,this.pos=0}},As=e=>new ks(e),js=e=>e.pos!==e.arr.length,Ms=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Ns=e=>Ms(e,X(e)),Ps=e=>e.arr[e.pos++],X=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Io)throw Os}throw Ds},Fs=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Io)throw Os}throw Ds},Is=Jo?e=>Jo.decode(Ns(e)):e=>{let t=X(e);if(t===0)return``;{let n=String.fromCodePoint(Ps(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Ps(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Ls=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Rs=[e=>void 0,e=>null,Fs,e=>Ls(e,4).getFloat32(0,!1),e=>Ls(e,8).getFloat64(0,!1),e=>Ls(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Is,e=>{let t=X(e),n={};for(let r=0;r<t;r++){let t=Is(e);n[t]=zs(e)}return n},e=>{let t=X(e),n=[];for(let r=0;r<t;r++)n.push(zs(e));return n},Ns],zs=e=>Rs[127-Ps(e)](e),Bs=class extends ks{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),js(this)?this.count=X(this)+1:this.count=-1),this.count--,this.s}},Vs=class extends ks{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Fs(this);let e=So(this.s);this.count=1,e&&(this.s=-this.s,this.count=X(this)+2)}return this.count--,this.s}},Hs=class extends ks{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Fs(this),t=e&1;this.diff=vo(e/2),this.count=1,t&&(this.count=X(this)+2)}return this.s+=this.diff,this.count--,this.s}},Us=class{constructor(e){this.decoder=new Vs(e),this.str=Is(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var Ws=crypto.getRandomValues.bind(crypto),Gs=Math.random,Ks=()=>Ws(new Uint32Array(1))[0],qs=e=>e[vo(Gs()*e.length)],Js=`10000000-1000-4000-8000-100000000000`,Ys=()=>Js.replace(/[018]/g,e=>(e^Ks()&15>>e/4).toString(16)),Xs=Date.now,Zs=e=>new Promise(e);Promise.all.bind(Promise);var Qs=e=>e===void 0?null:e,$s=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&($s=localStorage)}catch{}var ec=$s,tc=Symbol(`Equality`),nc=(e,t)=>e===t||!!e?.[tc]?.(t)||!1,rc=e=>typeof e==`object`,ic=Object.assign,ac=Object.keys,oc=(e,t)=>{for(let n in e)t(e[n],n)},sc=e=>ac(e).length,cc=e=>{for(let t in e)return!1;return!0},lc=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},uc=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),dc=(e,t)=>e===t||sc(e)===sc(t)&&lc(e,(e,n)=>(e!==void 0||uc(t,n))&&nc(t[n],e)),fc=Object.freeze,pc=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&pc(e[t])}return fc(e)},mc=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&mc(e,t,n+1)}},hc=e=>e,gc=(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[tc]!=null)return e[tc](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(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!gc(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(sc(e)!==sc(t))return!1;for(let n in e)if(!uc(e,n)||!gc(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(!gc(e[n],t[n]))return!1;break;default:return!1}return!0},_c=(e,t)=>t.includes(e),vc=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,yc=typeof window<`u`&&typeof document<`u`&&!vc;typeof navigator<`u`&&/Mac/.test(navigator.platform);var bc,xc=[],Sc=()=>{if(bc===void 0)if(vc){bc=no();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&bc.set(t,``),t=r):t===null?xc.push(r):(bc.set(t,r),t=null)}t!==null&&bc.set(t,``)}else typeof location==`object`?(bc=no(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);bc.set(`--${Wo(t,`-`)}`,n),bc.set(`-${Wo(t,`-`)}`,n)}})):bc=no();return bc},Cc=e=>Sc().has(e),wc=e=>Qs(vc?{}[e.toUpperCase().replaceAll(`-`,`_`)]:ec.getItem(e)),Tc=e=>Cc(`--`+e)||wc(e)!==null,Ec=Tc(`production`),Dc=vc&&_c({}.FORCE_COLOR,[`true`,`1`,`2`])||!Cc(`--no-colors`)&&!Tc(`no-color`)&&(!vc||process.stdout.isTTY)&&(!vc||Cc(`--color`)||wc(`COLORTERM`)!==null||(wc(`TERM`)||``).includes(`color`)),Oc=e=>new Uint8Array(e),kc=yc?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=zo(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Ac=e=>{let t=Oc(e.byteLength);return t.set(e),t},jc=e=>Qo(t=>_s(t,e)),Mc=class{constructor(e,t){this.left=e,this.right=t}},Nc=(e,t)=>new Mc(e,t),Pc=(e,t)=>e.forEach(e=>t(e.left,e.right)),Fc=e=>e.next()>=.5,Ic=(e,t,n)=>vo(e.next()*(n+1-t)+t),Lc=(e,t,n)=>vo(e.next()*(n+1-t)+t),Rc=(e,t,n)=>Lc(e,t,n),zc=e=>zo(Rc(e,97,122)),Bc=(e,t=0,n=20)=>{let r=Rc(e,t,n),i=``;for(let t=0;t<r;t++)i+=zc(e);return i},Vc=(e,t)=>t[Rc(e,0,t.length-1)],Hc=Symbol(`0schema`),Uc=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Yo(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
2
|
+
import{r as e,t}from"./chunk-DECur_0Z.js";import{i as n,n as r,t as i}from"./propagation-api-LnD10wq2.js";import{n as a,r as o,t as s}from"./compiler-runtime-Y11fyRVL.js";import{$ as c,$t as l,An as u,B as d,Bn as f,Bt as p,C as m,Cn as h,Ct as g,Dn as _,Et as v,F as y,Fn as b,Gn as x,Gt as S,H as C,Hn as w,In as T,It as E,Kt as D,L as O,M as k,N as A,Nt as j,On as M,Ot as N,P,Pn as F,Qt as I,R as L,Rt as R,S as z,Sn as B,St as V,Tt as H,U,V as ee,Vn as te,W as ne,Xt as re,Yt as W,Z as ie,Zt as ae,_n as oe,a as se,an as ce,at as le,b as ue,bt as de,c as fe,cn as pe,ct as me,d as he,dn as ge,en as _e,et as ve,f as ye,fn as be,ft as xe,gn as Se,gt as Ce,h as we,hn as Te,ht as Ee,i as De,in as Oe,jn as ke,k as Ae,kn as je,ln as Me,lt as Ne,m as Pe,mn as Fe,n as Ie,pn as Le,qn as Re,qt as ze,s as Be,sn as Ve,st as He,t as Ue,tn as We,u as Ge,un as Ke,v as qe,vn as Je,wt as Ye,x as Xe,xn as Ze,xt as Qe,y as $e,yn as et,z as tt,zn as nt}from"./toggle-group-CyBGhndP.js";import{C as rt,S as it,_ as at,a as ot,b as st,c as ct,d as lt,g as ut,i as dt,l as ft,m as pt,p as mt,r as ht,s as gt,t as _t,u as vt,x as yt}from"./button-Dyz7QGIk.js";import{S as bt,_ as xt,a as St,c as Ct,d as wt,f as Tt,g as Et,h as Dt,i as Ot,m as kt,n as At,o as jt,p as Mt,s as Nt,t as Pt,u as Ft,v as It,x as Lt,y as Rt}from"./dialog-FUclf-NK.js";import{B as zt,Bt,D as Vt,Et as Ht,G as Ut,H as Wt,I as Gt,K as Kt,L as G,M as qt,N as Jt,Nt as Yt,P as Xt,Pt as Zt,Tt as Qt,U as $t,V as en,W as tn,Y as nn,Z as rn,_ as an,a as on,b as sn,f as cn,h as ln,i as un,j as dn,jt as fn,k as pn,kt as mn,l as hn,lt as gn,o as _n,p as vn,q as yn,r as bn,s as xn,t as Sn,u as Cn,w as wn,wt as Tn,y as En,z as Dn}from"./dist-dkPJvrfr.js";import{a as On,c as kn,s as An,t as jn}from"./dist-oNAFjGrp.js";import{i as Mn,n as Nn,r as Pn,t as Fn}from"./dist-RVD4DzGH.js";var In=it(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Ln=it(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Rn=it(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),zn=it(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Bn=it(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Vn=it(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Hn=it(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Un=it(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Wn=it(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Gn=it(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Kn=it(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),qn=it(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),Jn=it(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),Yn=it(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),Xn=it(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Zn=it(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Qn=it(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),$n=it(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),er=it(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),tr=it(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),nr=it(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),rr=it(`message-square-warning`,[[`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`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]),ir=it(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),ar=it(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),or=it(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),sr=it(`quote`,[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]),cr=it(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),lr=it(`square-play`,[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}]]),ur=it(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),dr=it(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),fr=it(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),pr=it(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),K=e(a(),1),q=o(),mr=`Collapsible`,[hr,gr]=mt(mr),[_r,vr]=hr(mr),yr=K.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=ft({prop:r,defaultProp:i??!1,onChange:o,caller:mr});return(0,q.jsx)(_r,{scope:n,disabled:a,contentId:gt(),open:c,onOpenToggle:K.useCallback(()=>l(e=>!e),[l]),children:(0,q.jsx)(pt.div,{"data-state":Tr(c),"data-disabled":a?``:void 0,...s,ref:t})})});yr.displayName=mr;var br=`CollapsibleTrigger`,xr=K.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=vr(br,n);return(0,q.jsx)(pt.button,{type:`button`,"aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Tr(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:lt(e.onClick,i.onOpenToggle)})});xr.displayName=br;var Sr=`CollapsibleContent`,Cr=K.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=vr(Sr,e.__scopeCollapsible);return(0,q.jsx)(ct,{present:n||i.open,children:({present:e})=>(0,q.jsx)(wr,{...r,ref:t,present:e})})});Cr.displayName=Sr;var wr=K.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=vr(Sr,n),[s,c]=K.useState(r),l=K.useRef(null),u=st(t,l),d=K.useRef(0),f=d.current,p=K.useRef(0),m=p.current,h=o.open||s,g=K.useRef(h),_=K.useRef(void 0);return K.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),vt(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,q.jsx)(pt.div,{"data-state":Tr(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function Tr(e){return e?`open`:`closed`}var Er=yr,Dr=xr,Or=Cr,kr=t((e=>{var t=a();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),a=r[0].inst,l=r[1];return s(function(){a.value=n,a.getSnapshot=t,u(a)&&l({inst:a})},[e,n,t]),o(function(){return u(a)&&l({inst:a}),e(function(){u(a)&&l({inst:a})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Ar=t(((e,t)=>{t.exports=kr()}));function jr(e){let t=K.useRef({value:e,previous:e});return K.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Mr=`Popover`,[Nr,Pr]=mt(Mr,[ke]),Fr=ke(),[Ir,Lr]=Nr(Mr),Rr=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Fr(t),c=K.useRef(null),[l,d]=K.useState(!1),[f,p]=ft({prop:r,defaultProp:i??!1,onChange:a,caller:Mr});return(0,q.jsx)(u,{...s,children:(0,q.jsx)(Ir,{scope:t,contentId:gt(),triggerRef:c,open:f,onOpenChange:p,onOpenToggle:K.useCallback(()=>p(e=>!e),[p]),hasCustomAnchor:l,onCustomAnchorAdd:K.useCallback(()=>d(!0),[]),onCustomAnchorRemove:K.useCallback(()=>d(!1),[]),modal:o,children:n})})};Rr.displayName=Mr;var zr=`PopoverAnchor`,Br=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Lr(zr,n),a=Fr(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return K.useEffect(()=>(o(),()=>s()),[o,s]),(0,q.jsx)(_,{...a,...r,ref:t})});Br.displayName=zr;var Vr=`PopoverTrigger`,Hr=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Lr(Vr,n),a=Fr(n),o=st(t,i.triggerRef),s=(0,q.jsx)(pt.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":ri(i.open),...r,ref:o,onClick:lt(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,q.jsx)(_,{asChild:!0,...a,children:s})});Hr.displayName=Vr;var Ur=`PopoverPortal`,[Wr,Gr]=Nr(Ur,{forceMount:void 0}),Kr=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Lr(Ur,t);return(0,q.jsx)(Wr,{scope:t,forceMount:n,children:(0,q.jsx)(ct,{present:n||a.open,children:(0,q.jsx)(dt,{asChild:!0,container:i,children:r})})})};Kr.displayName=Ur;var qr=`PopoverContent`,Jr=K.forwardRef((e,t)=>{let n=Gr(qr,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Lr(qr,e.__scopePopover);return(0,q.jsx)(ct,{present:r||a.open,children:a.modal?(0,q.jsx)(Xr,{...i,ref:t}):(0,q.jsx)(Zr,{...i,ref:t})})});Jr.displayName=qr;var Yr=at(`PopoverContent.RemoveScroll`),Xr=K.forwardRef((e,t)=>{let n=Lr(qr,e.__scopePopover),r=K.useRef(null),i=st(t,r),a=K.useRef(!1);return K.useEffect(()=>{let e=r.current;if(e)return Et(e)},[]),(0,q.jsx)(xt,{as:Yr,allowPinchZoom:!0,children:(0,q.jsx)(Qr,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:lt(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:lt(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:lt(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Zr=K.forwardRef((e,t)=>{let n=Lr(qr,e.__scopePopover),r=K.useRef(!1),i=K.useRef(!1);return(0,q.jsx)(Qr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Qr=K.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Lr(qr,n),p=Fr(n);return It(),(0,q.jsx)(Rt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,q.jsx)(ot,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,q.jsx)(je,{"data-state":ri(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),$r=`PopoverClose`,ei=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Lr($r,n);return(0,q.jsx)(pt.button,{type:`button`,...r,ref:t,onClick:lt(e.onClick,()=>i.onOpenChange(!1))})});ei.displayName=$r;var ti=`PopoverArrow`,ni=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Fr(n);return(0,q.jsx)(M,{...i,...r,ref:t})});ni.displayName=ti;function ri(e){return e?`open`:`closed`}var ii=Rr,ai=Br,oi=Hr,si=Kr,ci=Jr,li=`Switch`,[ui,di]=mt(li),[fi,pi]=ui(li),mi=K.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=K.useState(null),m=st(t,e=>p(e)),h=K.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=ft({prop:i,defaultProp:a??!1,onChange:l,caller:li});return(0,q.jsxs)(fi,{scope:n,checked:_,disabled:s,children:[(0,q.jsx)(pt.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":yi(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:lt(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,q.jsx)(vi,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});mi.displayName=li;var hi=`SwitchThumb`,gi=K.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=pi(hi,n);return(0,q.jsx)(pt.span,{"data-state":yi(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});gi.displayName=hi;var _i=`SwitchBubbleInput`,vi=K.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=K.useRef(null),s=st(o,a),c=jr(n),l=w(t);return K.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,q.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});vi.displayName=_i;function yi(e){return e?`checked`:`unchecked`}var bi=mi,xi=gi,Si=e(rt(),1),Ci=Ar(),J=s(),wi=yt(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3! font-mono uppercase`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,warning:`bg-yellow-500/10 text-yellow-600 [a]:hover:bg-yellow-500/20`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`,dashed:`border-dashed border-border text-muted-foreground rounded-sm`}},defaultVariants:{variant:`default`}});function Ti(e){let t=(0,J.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,variant:i,asChild:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a!==void 0&&a?ut:`span`,c;t[5]!==n||t[6]!==o?(c=ht(wi({variant:o}),n),t[5]=n,t[6]=o,t[7]=c):c=t[7];let l;return t[8]!==s||t[9]!==r||t[10]!==c||t[11]!==o?(l=(0,q.jsx)(s,{"data-slot":`badge`,"data-variant":o,className:c,...r}),t[8]=s,t[9]=r,t[10]=c,t[11]=o,t[12]=l):l=t[12],l}function Ei(e){let t=e.split(`/`);return t.length<2?`ok`:`${t[0]}/${t[1]}`}function Di(e){if(!e)return;let t=Object.entries(e);if(t.length!==0)return t.map(([e,t])=>{if(t==null)return[e,String(t)];if(typeof t==`string`)return[e,t];if(typeof t==`number`||typeof t==`boolean`)return[e,String(t)];try{return[e,JSON.stringify(t)]}catch{return[e,`[unserializable]`]}})}function Y(e,t,n){if(typeof performance>`u`||!performance.measure)return;let r=Ei(e),i=Di(t),a={devtools:{dataType:`track-entry`,track:r,...i?{properties:i}:{},...n?.tooltipText?{tooltipText:n.tooltipText}:{}}},o=performance.now(),s=n?.startTime??o,c=n?.duration??Math.max(0,o-s);try{performance.measure(e,{start:s,duration:c,detail:a})}catch{}({...t?{properties:t}:{}})}function Oi(e){let t=(0,J.c)(3),{name:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,q.jsx)(K.Profiler,{id:n,onRender:ki,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var ki=(e,t,n,r,i,a)=>{Y(`ok/render/${e}`,{phase:t,actualDuration:Math.round(n*1e3)/1e3,baseDuration:Math.round(r*1e3)/1e3},{startTime:i,duration:Math.max(0,a-i)})},{getOwnPropertyNames:Ai,getOwnPropertySymbols:ji}=Object,{hasOwnProperty:Mi}=Object.prototype;function Ni(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Pi(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function Fi(e){return e?.[Symbol.toStringTag]}function Ii(e){return Ai(e).concat(ji(e))}var Li=Object.hasOwn||((e,t)=>Mi.call(e,t));function Ri(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var zi=`__v`,Bi=`__o`,Vi=`_owner`,{getOwnPropertyDescriptor:Hi,keys:Ui}=Object;function Wi(e,t){return e.byteLength===t.byteLength&&ra(new Uint8Array(e),new Uint8Array(t))}function Gi(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function Ki(e,t){return e.byteLength===t.byteLength&&ra(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function qi(e,t){return Ri(e.getTime(),t.getTime())}function Ji(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function Yi(e,t){return e===t}function Xi(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var Zi=Ri;function Qi(e,t,n){let r=Ui(e),i=r.length;if(Ui(t).length!==i)return!1;for(;i-- >0;)if(!aa(e,t,n,r[i]))return!1;return!0}function $i(e,t,n){let r=Ii(e),i=r.length;if(Ii(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!aa(e,t,n,a)||(o=Hi(e,a),s=Hi(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function ea(e,t){return Ri(e.valueOf(),t.valueOf())}function ta(e,t){return e.source===t.source&&e.flags===t.flags}function na(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function ra(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function ia(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function aa(e,t,n,r){return(r===Vi||r===Bi||r===zi)&&(e.$$typeof||t.$$typeof)?!0:Li(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var oa=`[object ArrayBuffer]`,sa=`[object Arguments]`,ca=`[object Boolean]`,la=`[object DataView]`,ua=`[object Date]`,da=`[object Error]`,fa=`[object Map]`,pa=`[object Number]`,ma=`[object Object]`,ha=`[object RegExp]`,ga=`[object Set]`,_a=`[object String]`,va={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},ya=`[object URL]`,ba=Object.prototype.toString;function xa({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=ba.call(h);if(b===ua)return r(h,g,_);if(b===ha)return u(h,g,_);if(b===fa)return o(h,g,_);if(b===ga)return d(h,g,_);if(b===ma)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===ya)return p(h,g,_);if(b===da)return i(h,g,_);if(b===sa)return c(h,g,_);if(va[b])return f(h,g,_);if(b===oa)return e(h,g,_);if(b===la)return n(h,g,_);if(b===ca||b===pa||b===_a)return l(h,g,_);if(m){let e=m[b];if(!e){let t=Fi(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function Sa({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Wi,areArraysEqual:n?$i:Gi,areDataViewsEqual:Ki,areDatesEqual:qi,areErrorsEqual:Ji,areFunctionsEqual:Yi,areMapsEqual:n?Ni(Xi,$i):Xi,areNumbersEqual:Zi,areObjectsEqual:n?$i:Qi,arePrimitiveWrappersEqual:ea,areRegExpsEqual:ta,areSetsEqual:n?Ni(na,$i):na,areTypedArraysEqual:n?Ni(ra,$i):ra,areUrlsEqual:ia,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Pi(r.areArraysEqual),t=Pi(r.areMapsEqual),n=Pi(r.areObjectsEqual),i=Pi(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function Ca(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function wa({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var Ta=Ea();Ea({strict:!0}),Ea({circular:!0}),Ea({circular:!0,strict:!0}),Ea({createInternalComparator:()=>Ri}),Ea({strict:!0,createInternalComparator:()=>Ri}),Ea({circular:!0,createInternalComparator:()=>Ri}),Ea({circular:!0,createInternalComparator:()=>Ri,strict:!0});function Ea(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=xa(Sa(e));return wa({circular:t,comparator:a,createState:r,equals:n?n(a):Ca(a),strict:i})}var Da=t((e=>{var t=a(),n=Ar();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,a){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),a!==void 0&&f.hasValue){var t=f.value;if(a(t,e))return c=t}return c=e}if(t=c,i(s,e))return t;var n=r(e);return a!==void 0&&a(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,a]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Oa=t(((e,t)=>{t.exports=Da()}))(),ka=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},Aa=({contentComponent:e})=>{let t=(0,Ci.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,q.jsx)(q.Fragment,{children:Object.values(t)})};function ja(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:Si.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var Ma=class extends K.Component{constructor(e){super(e),this.editorContentRef=K.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=ja(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{ref:ka(t,this.editorContentRef),...n}),e?.contentComponent&&(0,q.jsx)(Aa,{contentComponent:e.contentComponent})]})}},Na=(0,K.forwardRef)((e,t)=>{let n=K.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return K.createElement(Ma,{key:n,innerRef:t,...e})}),Pa=K.memo(Na),Fa=typeof window<`u`?K.useLayoutEffect:K.useEffect,Ia=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function La(e){let[t]=(0,K.useState)(()=>new Ia(e.editor)),n=(0,Oa.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??Ta);return Fa(()=>t.watch(e.editor),[e.editor,t]),(0,K.useDebugValue)(n),n}typeof window>`u`||typeof window<`u`&&window.next;var Ra=(0,K.createContext)({editor:null});Ra.Consumer;var za=()=>(0,K.useContext)(Ra),Ba=(0,K.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Va=()=>(0,K.useContext)(Ba);function Ha({as:e=`div`,...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=Va();return(0,q.jsx)(e,{...t,ref:n,"data-node-view-content":``,style:{whiteSpace:`pre-wrap`,...t.style},children:r})}var Ua=K.forwardRef((e,t)=>{let{onDragStart:n}=Va();return(0,q.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function Wa(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function Ga(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.forward_ref)`||e.$$typeof.description===`react.forward_ref`))}function Ka(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.memo)`||e.$$typeof.description===`react.memo`))}function qa(e){if(Wa(e)||Ga(e))return!0;if(Ka(e)){let t=e.type;if(t)return Wa(t)||Ga(t)}return!1}function Ja(){try{if(K.version)return parseInt(K.version.split(`.`)[0],10)>=19}catch{}return!1}var Ya=class{constructor(e,{editor:t,props:n={},as:r=`div`,className:i=``}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add(`react-renderer`),i&&this.element.classList.add(...i.split(` `)),this.editor.isEditorContentInitialized?(0,Si.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=Ja(),a=qa(t),o={...n};o.ref&&!(i||a)&&delete o.ref,!o.ref&&(i||a)&&(o.ref=e=>{this.ref=e}),this.reactElement=(0,q.jsx)(t,{...o}),(e=r?.contentComponent)==null||e.setRenderer(this.id,this)}updateProps(e={}){this.destroyed||(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0,(e=this.editor?.contentComponent)==null||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};K.createContext({markViewContentRef:()=>{}});var Xa=class extends ae{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.positionCheckCallback=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?`span`:`div`),this.contentDOMElement.dataset.nodeViewContentReact=``,this.contentDOMElement.dataset.nodeViewWrapper=``,this.contentDOMElement.style.whiteSpace=`inherit`;let e=this.dom.querySelector(`[data-node-view-content]`);if(!e)return;e.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,K.createRef)()};if(!this.component.displayName){let e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute(`data-node-view-wrapper`)&&e.removeAttribute(`data-node-view-wrapper`),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,K.memo)(e=>(0,q.jsx)(Ba.Provider,{value:t,children:(0,K.createElement)(n,e)}));r.displayName=`ReactNodeView`;let i=this.node.isInline?`span`:`div`;this.options.as&&(i=this.options.as);let{className:a=``}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Ya(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on(`selectionUpdate`,this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos(),this.positionCheckCallback=()=>{let e=this.getPos();typeof e!=`number`||e===this.currentPos||(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs==`function`&&this.updateElementAttributes())},Me(this.editor,this.positionCheckCallback)}get dom(){if(this.renderer.element.firstElementChild&&!this.renderer.element.firstElementChild?.hasAttribute(`data-node-view-wrapper`))throw Error(`Please use the NodeViewWrapper component for your node view.`);return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;let{from:e,to:t}=this.editor.state.selection,n=this.currentPos;if(typeof n==`number`)if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(e,t,n){let r=e=>{this.renderer.updateProps(e),typeof this.options.attrs==`function`&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update==`function`){let i=this.node,a=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:a,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}let i=this.getPos();return e===this.node&&this.decorations===t&&this.innerDecorations===n?i===this.currentPos?!0:(this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage,getPos:()=>this.getPos()}),!0):(this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage}),!0)}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add(`ProseMirror-selectednode`)}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove(`ProseMirror-selectednode`)}destroy(){this.renderer.destroy(),this.editor.off(`selectionUpdate`,this.handleSelectionUpdate),this.positionCheckCallback&&=(I(this.editor,this.positionCheckCallback),null),this.contentDOMElement=null,this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null)}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs==`function`){let t=this.editor.extensionManager.attributes,n=_e(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function Za(e,t){return n=>n.editor.contentComponent?new Xa(e,n,t):{}}var Qa=(0,K.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});Qa.displayName=`TiptapContext`;var $a=()=>(0,K.useContext)(Qa);function eo({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,K.useMemo)(()=>({editor:r}),[r]),a=(0,K.useMemo)(()=>({editor:r}),[r]);return(0,q.jsx)(Ra.Provider,{value:a,children:(0,q.jsx)(Qa.Provider,{value:i,children:n})})}eo.displayName=`Tiptap`;function to({...e}){let{editor:t}=$a();return(0,q.jsx)(Pa,{editor:t,...e})}to.displayName=`Tiptap.Content`,Object.assign(eo,{Content:to});var no=()=>new Map,ro=e=>{let t=no();return e.forEach((e,n)=>{t.set(n,e)}),t},io=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ao=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},oo=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},so=()=>new Set,co=e=>e[e.length-1],lo=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},uo=Array.from,fo=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},po=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},mo=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},ho=Array.isArray,go=class{constructor(){this._observers=no()}on(e,t){return io(this._observers,e,so).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return uo((this._observers.get(e)||no()).values()).forEach(e=>e(...t))}destroy(){this._observers=no()}},_o=class{constructor(){this._observers=no()}on(e,t){io(this._observers,e,so).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return uo((this._observers.get(e)||no()).values()).forEach(e=>e(...t))}destroy(){this._observers=no()}},vo=Math.floor,yo=Math.abs,bo=(e,t)=>e<t?e:t,xo=(e,t)=>e>t?e:t;Number.isNaN;var So=e=>e===0?1/e<0:e<0,Co=1<<17,wo=1<<18,To=1<<19,Eo=1<<20,Do=1<<21,Oo=1<<22,ko=1<<23,Ao=1<<24,jo=1<<25,Mo=1<<26,No=1<<27,Po=1<<28,Fo=1<<29;Co-1,wo-1,To-1,Eo-1,Do-1,Oo-1,ko-1,Ao-1,jo-1,Mo-1,No-1,Po-1,Fo-1;var Io=2**53-1,Lo=-(2**53-1),Ro=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&vo(e)===e);Number.isNaN,Number.parseInt;var zo=String.fromCharCode;String.fromCodePoint,zo(65535);var Bo=e=>e.toLowerCase(),Vo=/^\s*/g,Ho=e=>e.replace(Vo,``),Uo=/([A-Z])/g,Wo=(e,t)=>Ho(e.replace(Uo,e=>`${t}${Bo(e)}`)),Go=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Ko=typeof TextEncoder<`u`?new TextEncoder:null,qo=Ko?e=>Ko.encode(e):Go,Jo=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Jo&&Jo.decode(new Uint8Array).length===1&&(Jo=null);var Yo=(e,t)=>mo(t,()=>e).join(``),Xo=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Zo=()=>new Xo,Qo=e=>{let t=Zo();return e(t),es(t)},$o=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},es=e=>{let t=new Uint8Array($o(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},ts=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(xo(n,t)*2),e.cpos=0)},ns=(e,t)=>{let 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},rs=ns,is=(e,t)=>{for(;t>127;)ns(e,128|127&t),t=vo(t/128);ns(e,127&t)},as=(e,t)=>{let n=So(t);for(n&&(t=-t),ns(e,(t>63?128:0)|(n?64:0)|63&t),t=vo(t/64);t>0;)ns(e,(t>127?128:0)|127&t),t=vo(t/128)},os=new Uint8Array(3e4),ss=os.length/3,cs=Ko&&Ko.encodeInto?(e,t)=>{if(t.length<ss){let n=Ko.encodeInto(t,os).written||0;is(e,n);for(let t=0;t<n;t++)ns(e,os[t])}else us(e,qo(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;is(e,r);for(let t=0;t<r;t++)ns(e,n.codePointAt(t))},ls=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=bo(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(xo(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},us=(e,t)=>{is(e,t.byteLength),ls(e,t)},ds=(e,t)=>{ts(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},fs=(e,t)=>ds(e,4).setFloat32(0,t,!1),ps=(e,t)=>ds(e,8).setFloat64(0,t,!1),ms=(e,t)=>ds(e,8).setBigInt64(0,t,!1),hs=new DataView(new ArrayBuffer(4)),gs=e=>(hs.setFloat32(0,e),hs.getFloat32(0)===e),_s=(e,t)=>{switch(typeof t){case`string`:ns(e,119),cs(e,t);break;case`number`:Ro(t)&&yo(t)<=2147483647?(ns(e,125),as(e,t)):gs(t)?(ns(e,124),fs(e,t)):(ns(e,123),ps(e,t));break;case`bigint`:ns(e,122),ms(e,t);break;case`object`:if(t===null)ns(e,126);else if(ho(t)){ns(e,117),is(e,t.length);for(let n=0;n<t.length;n++)_s(e,t[n])}else if(t instanceof Uint8Array)ns(e,116),us(e,t);else{ns(e,118);let n=Object.keys(t);is(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];cs(e,i),_s(e,t[i])}}break;case`boolean`:ns(e,t?120:121);break;default:ns(e,127)}},vs=class extends Xo{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&is(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},ys=e=>{e.count>0&&(as(e.encoder,e.count===1?e.s:-e.s),e.count>1&&is(e.encoder,e.count-2))},bs=class{constructor(){this.encoder=new Xo,this.s=0,this.count=0}write(e){this.s===e?this.count++:(ys(this),this.count=1,this.s=e)}toUint8Array(){return ys(this),es(this.encoder)}},xs=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);as(e.encoder,t),e.count>1&&is(e.encoder,e.count-2)}},Ss=class{constructor(){this.encoder=new Xo,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(xs(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return xs(this),es(this.encoder)}},Cs=class{constructor(){this.sarr=[],this.s=``,this.lensE=new bs}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Xo;return this.sarr.push(this.s),this.s=``,cs(e,this.sarr.join(``)),ls(e,this.lensE.toUint8Array()),es(e)}},ws=e=>Error(e),Ts=()=>{throw ws(`Method unimplemented`)},Es=()=>{throw ws(`Unexpected case`)},Ds=ws(`Unexpected end of array`),Os=ws(`Integer out of Range`),ks=class{constructor(e){this.arr=e,this.pos=0}},As=e=>new ks(e),js=e=>e.pos!==e.arr.length,Ms=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Ns=e=>Ms(e,X(e)),Ps=e=>e.arr[e.pos++],X=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Io)throw Os}throw Ds},Fs=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Io)throw Os}throw Ds},Is=Jo?e=>Jo.decode(Ns(e)):e=>{let t=X(e);if(t===0)return``;{let n=String.fromCodePoint(Ps(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Ps(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Ls=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Rs=[e=>void 0,e=>null,Fs,e=>Ls(e,4).getFloat32(0,!1),e=>Ls(e,8).getFloat64(0,!1),e=>Ls(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Is,e=>{let t=X(e),n={};for(let r=0;r<t;r++){let t=Is(e);n[t]=zs(e)}return n},e=>{let t=X(e),n=[];for(let r=0;r<t;r++)n.push(zs(e));return n},Ns],zs=e=>Rs[127-Ps(e)](e),Bs=class extends ks{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),js(this)?this.count=X(this)+1:this.count=-1),this.count--,this.s}},Vs=class extends ks{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Fs(this);let e=So(this.s);this.count=1,e&&(this.s=-this.s,this.count=X(this)+2)}return this.count--,this.s}},Hs=class extends ks{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Fs(this),t=e&1;this.diff=vo(e/2),this.count=1,t&&(this.count=X(this)+2)}return this.s+=this.diff,this.count--,this.s}},Us=class{constructor(e){this.decoder=new Vs(e),this.str=Is(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var Ws=crypto.getRandomValues.bind(crypto),Gs=Math.random,Ks=()=>Ws(new Uint32Array(1))[0],qs=e=>e[vo(Gs()*e.length)],Js=`10000000-1000-4000-8000-100000000000`,Ys=()=>Js.replace(/[018]/g,e=>(e^Ks()&15>>e/4).toString(16)),Xs=Date.now,Zs=e=>new Promise(e);Promise.all.bind(Promise);var Qs=e=>e===void 0?null:e,$s=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&($s=localStorage)}catch{}var ec=$s,tc=Symbol(`Equality`),nc=(e,t)=>e===t||!!e?.[tc]?.(t)||!1,rc=e=>typeof e==`object`,ic=Object.assign,ac=Object.keys,oc=(e,t)=>{for(let n in e)t(e[n],n)},sc=e=>ac(e).length,cc=e=>{for(let t in e)return!1;return!0},lc=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},uc=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),dc=(e,t)=>e===t||sc(e)===sc(t)&&lc(e,(e,n)=>(e!==void 0||uc(t,n))&&nc(t[n],e)),fc=Object.freeze,pc=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&pc(e[t])}return fc(e)},mc=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&mc(e,t,n+1)}},hc=e=>e,gc=(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[tc]!=null)return e[tc](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(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!gc(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(sc(e)!==sc(t))return!1;for(let n in e)if(!uc(e,n)||!gc(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(!gc(e[n],t[n]))return!1;break;default:return!1}return!0},_c=(e,t)=>t.includes(e),vc=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,yc=typeof window<`u`&&typeof document<`u`&&!vc;typeof navigator<`u`&&/Mac/.test(navigator.platform);var bc,xc=[],Sc=()=>{if(bc===void 0)if(vc){bc=no();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&bc.set(t,``),t=r):t===null?xc.push(r):(bc.set(t,r),t=null)}t!==null&&bc.set(t,``)}else typeof location==`object`?(bc=no(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);bc.set(`--${Wo(t,`-`)}`,n),bc.set(`-${Wo(t,`-`)}`,n)}})):bc=no();return bc},Cc=e=>Sc().has(e),wc=e=>Qs(vc?{}[e.toUpperCase().replaceAll(`-`,`_`)]:ec.getItem(e)),Tc=e=>Cc(`--`+e)||wc(e)!==null,Ec=Tc(`production`),Dc=vc&&_c({}.FORCE_COLOR,[`true`,`1`,`2`])||!Cc(`--no-colors`)&&!Tc(`no-color`)&&(!vc||process.stdout.isTTY)&&(!vc||Cc(`--color`)||wc(`COLORTERM`)!==null||(wc(`TERM`)||``).includes(`color`)),Oc=e=>new Uint8Array(e),kc=yc?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=zo(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Ac=e=>{let t=Oc(e.byteLength);return t.set(e),t},jc=e=>Qo(t=>_s(t,e)),Mc=class{constructor(e,t){this.left=e,this.right=t}},Nc=(e,t)=>new Mc(e,t),Pc=(e,t)=>e.forEach(e=>t(e.left,e.right)),Fc=e=>e.next()>=.5,Ic=(e,t,n)=>vo(e.next()*(n+1-t)+t),Lc=(e,t,n)=>vo(e.next()*(n+1-t)+t),Rc=(e,t,n)=>Lc(e,t,n),zc=e=>zo(Rc(e,97,122)),Bc=(e,t=0,n=20)=>{let r=Rc(e,t,n),i=``;for(let t=0;t<r;t++)i+=zc(e);return i},Vc=(e,t)=>t[Rc(e,0,t.length-1)],Hc=Symbol(`0schema`),Uc=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Yo(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
3
3
|
`)}},Wc=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[tc]?nc(e,t):ho(e)?fo(e,e=>po(t,t=>Wc(e,t))):rc(e)?lc(e,(e,n)=>Wc(e,t[n])):!1,Gc=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Wc(t,n)}equals(e){return this.constructor===e.constructor&&gc(this.shape,e.shape)}[Hc](){return!0}[tc](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Ts()}get nullable(){return wl(this,zl)}get optional(){return new nl(this)}cast(e){return Ul(e,this),e}expect(e){return Ul(e,this),e}},Kc=class extends Gc{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},qc=(e,t=null)=>new Kc(e,t);qc(Kc);var Jc=class extends Gc{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},Yc=e=>new Jc(e);qc(Jc);var Xc=class extends Gc{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},Zc=(...e)=>new Xc(e),Qc=qc(Xc),$c=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),el=e=>{if(Pl.check(e))return[$c(e)];if(Qc.check(e))return e.shape.map(e=>e+``);if(Nl.check(e))return[`[+-]?\\d+.?\\d*`];if(Fl.check(e))return[`.*`];if(Tl.check(e))return e.shape.map(el).flat(1);Es()};qc(class extends Gc{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(el).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var tl=Symbol(`optional`),nl=class extends Gc{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[tl](){return!0}},rl=qc(nl),il=class extends Gc{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new il,qc(il);var al=class e extends Gc{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):lc(this.shape,(n,r)=>{let i=this._isPartial&&!uc(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},ol=e=>new al(e),sl=qc(al),cl=Yc(e=>e!=null&&(e.constructor===Object||e.constructor==null)),ll=class extends Gc{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&lc(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},ul=(e,t)=>new ll(e,t),dl=qc(ll),fl=class extends Gc{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&lc(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},pl=(...e)=>new fl(e);qc(fl);var ml=class extends Gc{constructor(e){super(),this.shape=e.length===1?e[0]:new Cl(e)}check(e,t){let n=ho(e)&&fo(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},hl=(...e)=>new ml(e),gl=qc(ml),_l=Yc(e=>ho(e)),vl=class extends Gc{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},yl=(e,t=null)=>new vl(e,t);qc(vl);var bl=yl(Gc),xl=qc(class extends Gc{constructor(e){super(),this.len=e.length-1,this.args=pl(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),Sl=Yc(e=>typeof e==`function`);qc(class extends Gc{constructor(e){super(),this.shape=e}check(e,t){let n=fo(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Cl=class extends Gc{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=po(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},wl=(...e)=>e.findIndex(e=>Tl.check(e))>=0?wl(...e.map(e=>Hl(e)).map(e=>Tl.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Cl(e),Tl=qc(Cl),El=()=>!0,Dl=Yc(El),Ol=qc(Jc,e=>e.shape===El),kl=Yc(e=>typeof e==`bigint`),Al=Yc(e=>e===kl),jl=Yc(e=>typeof e==`symbol`);Yc(e=>e===jl);var Ml=Yc(e=>typeof e==`number`),Nl=Yc(e=>e===Ml),Pl=Yc(e=>typeof e==`string`),Fl=Yc(e=>e===Pl),Il=Yc(e=>typeof e==`boolean`),Ll=Yc(e=>e===Il),Rl=Zc(void 0);qc(Xc,e=>e.shape.length===1&&e.shape[0]===void 0),Zc(void 0);var zl=Zc(null),Bl=qc(Xc,e=>e.shape.length===1&&e.shape[0]===null);qc(Uint8Array),qc(Kc,e=>e.shape===Uint8Array);var Vl=wl(Ml,Pl,zl,Rl,kl,Il,jl);(()=>{let e=hl(Dl),t=ul(Pl,Dl),n=wl(Ml,Pl,zl,Il,e,t);return e.shape=n,t.shape.values=n,n})();var Hl=e=>{if(bl.check(e))return e;if(cl.check(e)){let t={};for(let n in e)t[n]=Hl(e[n]);return ol(t)}else if(_l.check(e))return wl(...e.map(Hl));else if(Vl.check(e))return Zc(e);else if(Sl.check(e))return qc(e);Es()},Ul=Ec?()=>{}:(e,t)=>{let n=new Uc;if(!t.check(e,n))throw ws(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Wl=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Hl(e),h:t}),this}else(e){return this.if(Dl,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw ws(`Unhandled pattern`)}}},Gl=(e=>new Wl(e))(Dl).if(Nl,(e,t)=>Ic(t,Lo,Io)).if(Fl,(e,t)=>Bc(t)).if(Ll,(e,t)=>Fc(t)).if(Al,(e,t)=>BigInt(Ic(t,Lo,Io))).if(Tl,(e,t)=>Kl(t,Vc(t,e.shape))).if(sl,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(rl.check(i)){if(Fc(t))continue;i=i.shape}n[r]=Gl(i,t)}return n}).if(gl,(e,t)=>{let n=[],r=Lc(t,0,42);for(let i=0;i<r;i++)n.push(Kl(t,e.shape));return n}).if(Qc,(e,t)=>Vc(t,e.shape)).if(Bl,(e,t)=>null).if(xl,(e,t)=>{let n=Kl(t,e.res);return()=>n}).if(Ol,(e,t)=>Kl(t,Vc(t,[Ml,Pl,zl,Rl,kl,Il,hl(Ml),ul(wl(`a`,`b`,`c`),Ml)]))).if(dl,(e,t)=>{let n={},r=Ic(t,0,3);for(let i=0;i<r;i++){let r=Kl(t,e.shape.keys);n[r]=Kl(t,e.shape.values)}return n}).done(),Kl=(e,t)=>Gl(Hl(t),e),ql=typeof document<`u`?document:{},Jl=e=>ql.createElement(e),Yl=()=>ql.createDocumentFragment();Yc(e=>e.nodeType===su);var Xl=e=>ql.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Zl=(e,t)=>(Pc(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),Ql=e=>{let t=Yl();for(let n=0;n<e.length;n++)ru(t,e[n]);return t},$l=(e,t)=>(ru(e,Ql(t)),e),eu=(e,t=[],n=[])=>$l(Zl(Jl(e),t),n);Yc(e=>e.nodeType===iu);var tu=Xl;Yc(e=>e.nodeType===au);var nu=e=>ao(e,(e,t)=>`${t}:${e};`).join(``),ru=(e,t)=>e.appendChild(t),iu=ql.ELEMENT_NODE,au=ql.TEXT_NODE;ql.CDATA_SECTION_NODE,ql.COMMENT_NODE;var ou=ql.DOCUMENT_NODE;ql.DOCUMENT_TYPE_NODE;var su=ql.DOCUMENT_FRAGMENT_NODE;Yc(e=>e.nodeType===ou);var cu=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),lu=(e,t)=>new cu(setTimeout(t,e)),uu=Symbol,du=uu(),fu=uu(),pu=uu(),mu=uu(),hu=uu(),gu=uu(),_u=uu(),vu=uu(),yu=uu(),bu=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};Xs();var xu={[du]:Nc(`font-weight`,`bold`),[fu]:Nc(`font-weight`,`normal`),[pu]:Nc(`color`,`blue`),[hu]:Nc(`color`,`green`),[mu]:Nc(`color`,`grey`),[gu]:Nc(`color`,`red`),[_u]:Nc(`color`,`purple`),[vu]:Nc(`color`,`orange`),[yu]:Nc(`color`,`black`)},Su=Dc?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=no(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=xu[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=nu(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:bu,Cu=(...e)=>{console.log(...Su(e)),Tu.forEach(t=>t.print(e))},wu=(...e)=>{console.warn(...Su(e)),e.unshift(vu),Tu.forEach(t=>t.print(e))},Tu=so(),Eu=e=>({[Symbol.iterator](){return this},next:e}),Du=(e,t)=>Eu(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Ou=(e,t)=>Eu(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),ku=class{constructor(e,t){this.clock=e,this.len=t}},Au=class{constructor(){this.clients=new Map}},ju=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Yd(e,i,o.clock,o.len,n)}}),Mu=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=vo((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},Nu=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Mu(n,t.clock)!==null},Pu=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new ku(r.clock,xo(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Fu=e=>{let t=new Au;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)lo(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Pu(t),t},Iu=(e,t,n,r)=>{io(e.clients,t,()=>[]).push(new ku(n,r))},Lu=()=>new Au,Ru=e=>{let t=Lu();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new ku(i,a))}}r.length>0&&t.clients.set(n,r)}),t},zu=(e,t)=>{is(e.restEncoder,t.clients.size),uo(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),is(e.restEncoder,t);let r=n.length;is(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Bu=e=>{let t=new Au,n=X(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=X(e.restDecoder),r=X(e.restDecoder);if(r>0){let i=io(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new ku(e.readDsClock(),e.readDsLen()))}}return t},Vu=(e,t,n)=>{let r=new Au,i=X(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=X(e.restDecoder),a=X(e.restDecoder),o=n.clients.get(i)||[],s=Vd(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&Iu(r,i,s,a-s);let e=Ud(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,pm(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,pm(t,c,a-c.id.clock)),c.delete(t))}else Iu(r,i,n,a-n)}}if(r.clients.size>0){let e=new Zu;return is(e.restEncoder,0),zu(e,r),e.toUint8Array()}return null},Hu=Ks,Uu=class e extends go{constructor({guid:e=Ys(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Hu(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new zd,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Zs(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Zs(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&rf(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(uo(this.subdocs).map(e=>e.guid))}transact(e,t=null){return rf(this,e,t)}get(e,t=Pf){let n=io(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==Pf&&r!==t)if(r===Pf){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,tp)}getText(e=``){return this.get(e,Sp)}getMap(e=``){return this.get(e,ip)}getXmlElement(e=``){return this.get(e,Dp)}getXmlFragment(e=``){return this.get(e,Tp)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,uo(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,rf(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},Wu=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return X(this.restDecoder)}readDsLen(){return X(this.restDecoder)}},Gu=class extends Wu{readLeftID(){return Z(X(this.restDecoder),X(this.restDecoder))}readRightID(){return Z(X(this.restDecoder),X(this.restDecoder))}readClient(){return X(this.restDecoder)}readInfo(){return Ps(this.restDecoder)}readString(){return Is(this.restDecoder)}readParentInfo(){return X(this.restDecoder)===1}readTypeRef(){return X(this.restDecoder)}readLen(){return X(this.restDecoder)}readAny(){return zs(this.restDecoder)}readBuf(){return Ac(Ns(this.restDecoder))}readJSON(){return JSON.parse(Is(this.restDecoder))}readKey(){return Is(this.restDecoder)}},Ku=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=X(this.restDecoder),this.dsCurrVal}readDsLen(){let e=X(this.restDecoder)+1;return this.dsCurrVal+=e,e}},qu=class extends Ku{constructor(e){super(e),this.keys=[],X(e),this.keyClockDecoder=new Hs(Ns(e)),this.clientDecoder=new Vs(Ns(e)),this.leftClockDecoder=new Hs(Ns(e)),this.rightClockDecoder=new Hs(Ns(e)),this.infoDecoder=new Bs(Ns(e),Ps),this.stringDecoder=new Us(Ns(e)),this.parentInfoDecoder=new Bs(Ns(e),Ps),this.typeRefDecoder=new Vs(Ns(e)),this.lenDecoder=new Vs(Ns(e))}readLeftID(){return new bd(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new bd(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 zs(this.restDecoder)}readBuf(){return Ns(this.restDecoder)}readJSON(){return zs(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Ju=class{constructor(){this.restEncoder=Zo()}toUint8Array(){return es(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){is(this.restEncoder,e)}writeDsLen(e){is(this.restEncoder,e)}},Yu=class extends Ju{writeLeftID(e){is(this.restEncoder,e.client),is(this.restEncoder,e.clock)}writeRightID(e){is(this.restEncoder,e.client),is(this.restEncoder,e.clock)}writeClient(e){is(this.restEncoder,e)}writeInfo(e){rs(this.restEncoder,e)}writeString(e){cs(this.restEncoder,e)}writeParentInfo(e){is(this.restEncoder,+!!e)}writeTypeRef(e){is(this.restEncoder,e)}writeLen(e){is(this.restEncoder,e)}writeAny(e){_s(this.restEncoder,e)}writeBuf(e){us(this.restEncoder,e)}writeJSON(e){cs(this.restEncoder,JSON.stringify(e))}writeKey(e){cs(this.restEncoder,e)}},Xu=class{constructor(){this.restEncoder=Zo(),this.dsCurrVal=0}toUint8Array(){return es(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,is(this.restEncoder,t)}writeDsLen(e){e===0&&Es(),is(this.restEncoder,e-1),this.dsCurrVal+=e}},Zu=class extends Xu{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ss,this.clientEncoder=new bs,this.leftClockEncoder=new Ss,this.rightClockEncoder=new Ss,this.infoEncoder=new vs(rs),this.stringEncoder=new Cs,this.parentInfoEncoder=new vs(rs),this.typeRefEncoder=new bs,this.lenEncoder=new bs}toUint8Array(){let e=Zo();return is(e,0),us(e,this.keyClockEncoder.toUint8Array()),us(e,this.clientEncoder.toUint8Array()),us(e,this.leftClockEncoder.toUint8Array()),us(e,this.rightClockEncoder.toUint8Array()),us(e,es(this.infoEncoder)),us(e,this.stringEncoder.toUint8Array()),us(e,es(this.parentInfoEncoder)),us(e,this.typeRefEncoder.toUint8Array()),us(e,this.lenEncoder.toUint8Array()),ls(e,es(this.restEncoder)),es(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){_s(this.restEncoder,e)}writeBuf(e){us(this.restEncoder,e)}writeJSON(e){_s(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},Qu=(e,t,n,r)=>{r=xo(r,t[0].id.clock);let i=Ud(t,r);is(e.restEncoder,t.length-i),e.writeClient(n),is(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},$u=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{Vd(t,n)>e&&r.set(n,e)}),Bd(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),is(e.restEncoder,r.size),uo(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Qu(e,t.clients.get(n),n,r)})},ed=(e,t)=>{let n=no(),r=X(e.restDecoder);for(let i=0;i<r;i++){let r=X(e.restDecoder),i=Array(r),a=e.readClient(),o=X(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new Ip(Z(a,o),t),o+=t;break}case 10:{let t=X(e.restDecoder);i[n]=new bm(Z(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new gm(Z(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,_m(e,r));i[n]=c,o+=c.length}}}}return n},td=(e,t,n)=>{let r=[],i=uo(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new zd,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==bm){let i=io(d,u.id.client,()=>Vd(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,Vd(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new Zu;return $u(e,s,new Map),is(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},nd=(e,t)=>$u(e,t.doc.store,t.beforeState),rd=(e,t,n,r=new qu(e))=>rf(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=td(e,i,ed(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<Vd(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=mf([o.update,a.update])}}else i.pendingStructs=a;let s=Vu(r,e,i);if(i.pendingDs){let t=new qu(As(i.pendingDs));X(t.restDecoder);let n=Vu(t,e,i);s&&n?i.pendingDs=mf([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,id(e.doc,t)}},n,!1),id=(e,t,n,r=qu)=>{let i=As(t);rd(i,e,n,new r(i))},ad=(e,t,n)=>id(e,t,n,Gu),od=(e,t,n=new Map)=>{$u(e,t.store,n),zu(e,Ru(t.store))},sd=(e,t=new Uint8Array([0]),n=new Zu)=>{od(n,e,ud(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(hf(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Yu)return ff(r.map((e,t)=>t===0?e:bf(e)));if(n.constructor===Zu)return mf(r)}return r[0]},cd=(e,t)=>sd(e,t,new Yu),ld=e=>{let t=new Map,n=X(e.restDecoder);for(let r=0;r<n;r++){let n=X(e.restDecoder),r=X(e.restDecoder);t.set(n,r)}return t},ud=e=>ld(new Wu(As(e))),dd=(e,t)=>(is(e.restEncoder,t.size),uo(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{is(e.restEncoder,t),is(e.restEncoder,n)}),e),fd=(e,t)=>dd(e,Bd(t.store)),pd=(e,t=new Xu)=>(e instanceof Map?dd(t,e):fd(t,e),t.toUint8Array()),md=e=>pd(e,new Ju),hd=class{constructor(){this.l=[]}},gd=()=>new hd,_d=(e,t)=>e.l.push(t),vd=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},yd=(e,t,n)=>mc(e.l,[t,n]),bd=class{constructor(e,t){this.client=e,this.clock=t}},xd=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,Z=(e,t)=>new bd(e,t),Sd=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw Es()},Cd=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},wd=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},Td=e=>{let 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},Ed=e=>new wd(e.type==null?null:Z(e.type.client,e.type.clock),e.tname??null,e.item==null?null:Z(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),Dd=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Od=(e,t,n=0)=>new Dd(e,t,n),kd=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Sd(e):r=Z(e._item.id.client,e._item.id.clock),new wd(r,i,t,n)},Ad=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return kd(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return kd(e,Z(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return kd(e,r.lastId,n);r=r.right}return kd(e,null,n)},jd=(e,t)=>{let n=Wd(e,t);return{item:n,diff:t.clock-n.id.clock}},Md=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(Vd(r,i.client)<=i.clock)return null;let e=n?dm(r,i):jd(r,i),t=e.item;if(!(t instanceof gm))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(Vd(r,a.client)<=a.clock)return null;let{item:e}=n?dm(r,a):{item:Wd(r,a)};if(e instanceof gm&&e.content instanceof lm)c=e.content.type;else return null}else throw Es();l=s>=0?c._length:0}return Od(c,l,e.assoc)},Nd=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&xd(e.item,t.item)&&xd(e.type,t.type)&&e.assoc===t.assoc,Pd=class{constructor(e,t){this.ds=e,this.sv=t}},Fd=(e,t)=>new Pd(e,t);Fd(Lu(),new Map);var Id=e=>Fd(Ru(e.store),Bd(e.store)),Ld=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Nu(t.ds,e.id),Rd=(e,t)=>{let n=io(e.meta,Rd,so),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<Vd(r,n)&&Kd(e,Z(n,t))}),ju(e,t.ds,e=>{}),n.add(t))},zd=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Bd=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},Vd=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Hd=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw Es()}n.push(t)},Ud=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=vo(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=vo((n+r)/2)}throw Es()},Wd=(e,t)=>{let n=e.clients.get(t.client);return n[Ud(n,t.clock)]},Gd=(e,t,n)=>{let r=Ud(t,n),i=t[r];return i.id.clock<n&&i instanceof gm?(t.splice(r+1,0,pm(e,i,n-i.id.clock)),r+1):r},Kd=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Gd(e,n,t.clock)]},qd=(e,t,n)=>{let r=t.clients.get(n.client),i=Ud(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==Ip&&r.splice(i+1,0,pm(e,a,n.clock-a.id.clock+1)),a},Jd=(e,t,n)=>{let r=e.clients.get(t.id.client);r[Ud(r,t.id.clock)]=n},Yd=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Gd(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Gd(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Xd=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Au,this.beforeState=Bd(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Zd=(e,t)=>t.deleteSet.clients.size===0&&!oo(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Pu(t.deleteSet),nd(e,t),zu(e,t.deleteSet),!0),Qd=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&io(e.changed,t,so).add(n)},$d=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof gm&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},ef=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=Ud(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof gm&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},tf=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=bo(r.length-1,1+Ud(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+$d(r,e)}})},nf=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Pu(a),n.afterState=Bd(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{yd(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&yp(n)})}),mc(e,[])}finally{r.gc&&ef(a,i,r.gcFilter),tf(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=xo(Ud(e,r),1);for(let t=e.length-1;t>=n;)t-=1+$d(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=Ud(r,n);a+1<r.length&&$d(r,a+1)>1||a>0&&$d(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Cu(vu,du,`[yjs] `,fu,gu,`Changed the client-id because another client seems to be using it.`),r.clientID=Hu()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Yu;Zd(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Zu;Zd(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):nf(e,t+1)}}},rf=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Xd(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&nf(i,0)}}return o},af=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},of=(e,t,n)=>{ju(e,n.deletions,n=>{n instanceof gm&&t.scope.some(t=>t===e.doc||Cd(t,n))&&fm(n,!1)})},sf=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;rf(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;ju(n,o.insertions,e=>{if(e instanceof gm){if(e.redone!==null){let{item:t,diff:i}=dm(r,e.id);i>0&&(t=Kd(n,Z(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||Cd(t,e))&&c.push(e)}}),ju(n,o.deletions,e=>{e instanceof gm&&a.some(t=>t===n.doc||Cd(t,e))&&!Nu(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=hm(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},cf=class extends go{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=ho(e)?e[0].doc:e instanceof Uu?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new Au;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&Iu(i,n,r,a)});let a=Xs(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=Fu([t.deletions,e.deleteSet]),t.insertions=Fu([t.insertions,i])}else r.push(new af(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),ju(e,e.deleteSet,t=>{t instanceof gm&&this.scope.some(n=>n===e.doc||Cd(n,t))&&fm(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=ho(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof Pf?e.doc!==this.doc:e!==this.doc)&&wu(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>of(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>of(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=sf(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=sf(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}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*lf(e){let t=X(e.restDecoder);for(let n=0;n<t;n++){let t=X(e.restDecoder),n=e.readClient(),r=X(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=X(e.restDecoder);yield new bm(Z(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new gm(Z(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,_m(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new Ip(Z(n,r),t),r+=t}}}}var uf=class{constructor(e,t){this.gen=lf(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===bm);return this.curr}},df=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},ff=e=>mf(e,Gu,Yu),pf=(e,t)=>{if(e.constructor===Ip){let{client:n,clock:r}=e.id;return new Ip(Z(n,r+t),e.length-t)}else if(e.constructor===bm){let{client:n,clock:r}=e.id;return new bm(Z(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new gm(Z(r,i+t),null,Z(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},mf=(e,t=qu,n=Zu)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(As(e))),i=r.map(e=>new uf(e,!0)),a=null,o=new n,s=new df(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===bm?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)_f(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===bm)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{_f(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new bm(Z(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===bm?a.struct.length-=t:n=pf(n,t)),a.struct.mergeWith(n)||(_f(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==bm;n=e.next())_f(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(_f(s,a.struct,a.offset),a=null),vf(s),zu(o,Fu(r.map(e=>Bu(e)))),o.toUint8Array()},hf=(e,t,n=qu,r=Zu)=>{let i=ud(t),a=new r,o=new df(a),s=new n(As(e)),c=new uf(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===bm){c.next();continue}if(e.id.clock+e.length>n)for(_f(o,e,xo(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)_f(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return vf(o),zu(a,Bu(s)),a.toUint8Array()},gf=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:es(e.encoder.restEncoder)}),e.encoder.restEncoder=Zo(),e.written=0)},_f=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&gf(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),is(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},vf=e=>{gf(e);let t=e.encoder.restEncoder;is(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];is(t,r.written),ls(t,r.restEncoder)}},yf=(e,t,n,r)=>{let i=new n(As(e)),a=new uf(i,!1),o=new r,s=new df(o);for(let e=a.curr;e!==null;e=a.next())_f(s,t(e),0);return vf(s),zu(o,Bu(i)),o.toUint8Array()},bf=e=>yf(e,hc,qu,Yu),xf=`You must not compute changes after the event-handler fired.`,Sf=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=Cf(this.currentTarget,this.target)}deletes(e){return Nu(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ws(xf);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=co(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=co(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=co(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw ws(xf);let t=this.target,n=so(),r=so(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},Cf=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},wf=()=>{wu(`Invalid access: Add Yjs type to a document before reading data.`)},Tf=80,Ef=0,Df=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Ef++}},Of=e=>{e.timestamp=Ef++},kf=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Ef++},Af=(e,t,n)=>{if(e.length>=Tf){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return kf(r,t,n),r}else{let r=new Df(t,n);return e.push(r),r}},jf=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>yo(t-e.index)<yo(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,Of(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&yo(n.index-i)<r.parent.length/Tf?(kf(n,r,i),n):Af(e._searchMarker,r,i)},Mf=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=xo(t,i.index+n))}},Nf=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;io(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;yd(r._eH,n,t)},Pf=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=gd(),this._dEH=gd(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Ts()}clone(){throw Ts()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){_d(this._eH,e)}observeDeep(e){_d(this._dEH,e)}unobserve(e){vd(this._eH,e)}unobserveDeep(e){vd(this._dEH,e)}toJSON(){}},Ff=(e,t,n)=>{e.doc??wf(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},If=e=>{e.doc??wf();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},Lf=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Ld(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},Rf=(e,t)=>{let n=0,r=e._start;for(e.doc??wf();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},zf=(e,t)=>{let n=[];return Rf(e,(r,i)=>{n.push(t(r,i,e))}),n},Bf=e=>{let t=e._start,n=null,r=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(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},Vf=(e,t)=>{e.doc??wf();let n=jf(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Hf=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new gm(Z(o,Vd(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Zp(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new gm(Z(o,Vd(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Lp(new Uint8Array(n))),i.integrate(e,0);break;case Uu:i=new gm(Z(o,Vd(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Hp(n)),i.integrate(e,0);break;default:if(n instanceof Pf)i=new gm(Z(o,Vd(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new lm(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Uf=()=>ws(`Length exceeded!`),Wf=(e,t,n,r)=>{if(n>t._length)throw Uf();if(n===0)return t._searchMarker&&Mf(t._searchMarker,n,r.length),Hf(e,t,null,r);let i=n,a=jf(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&Kd(e,Z(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Mf(t._searchMarker,i,r.length),Hf(e,t,o,r)},Gf=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return Hf(e,t,r,n)},Kf=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=jf(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&Kd(e,Z(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&Kd(e,Z(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Uf();t._searchMarker&&Mf(t._searchMarker,i,-a+r)},qf=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Jf=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Zp([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Zp([r]);break;case Uint8Array:s=new Lp(r);break;case Uu:s=new Hp(r);break;default:if(r instanceof Pf)s=new lm(r);else throw Error(`Unexpected content type`)}new gm(Z(o,Vd(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Yf=(e,t)=>{e.doc??wf();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Xf=e=>{let t={};return e.doc??wf(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Zf=(e,t)=>{e.doc??wf();let n=e._map.get(t);return n!==void 0&&!n.deleted},Qf=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&Ld(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},$f=e=>(e.doc??wf(),Du(e._map.entries(),e=>!e[1].deleted)),ep=class extends Sf{},tp=class e extends Pf{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Pf?e.clone():e)),t}get length(){return this.doc??wf(),this._length}_callObserver(e,t){super._callObserver(e,t),Nf(this,e,new ep(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):rf(this.doc,n=>{Wf(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):rf(this.doc,t=>{Gf(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):rf(this.doc,n=>{Kf(n,this,e,t)})}get(e){return Vf(this,e)}toArray(){return If(this)}slice(e=0,t=this.length){return Ff(this,e,t)}toJSON(){return this.map(e=>e instanceof Pf?e.toJSON():e)}map(e){return zf(this,e)}forEach(e){Rf(this,e)}[Symbol.iterator](){return Bf(this)}_write(e){e.writeTypeRef(nm)}},np=e=>new tp,rp=class extends Sf{constructor(e,t,n){super(e,t),this.keysChanged=n}},ip=class e extends Pf{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof Pf?e.clone():e)}),t}_callObserver(e,t){Nf(this,e,new rp(this,e,t))}toJSON(){this.doc??wf();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof Pf?r.toJSON():r}}),e}get size(){return[...$f(this)].length}keys(){return Ou($f(this),e=>e[0])}values(){return Ou($f(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Ou($f(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??wf(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):rf(this.doc,t=>{qf(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):rf(this.doc,n=>{Jf(n,this,e,t)}),t}get(e){return Yf(this,e)}has(e){return Zf(this,e)}clear(){this.doc===null?this._prelimContent.clear():rf(this.doc,e=>{this.forEach(function(t,n,r){qf(e,r,n)})})}_write(e){e.writeTypeRef(rm)}},ap=e=>new ip,op=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&dc(e,t),sp=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&Es(),this.right.content.constructor){case Kp:this.right.deleted||dp(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}},cp=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case Kp:t.right.deleted||dp(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&Kd(e,Z(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},lp=(e,t,n,r)=>{let i=new Map,a=r?jf(t,n):null;return a?cp(e,new sp(a.p.left,a.p,a.index,i),n-a.index):cp(e,new sp(null,t._start,0,i),n)},up=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Kp&&op(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new gm(Z(a,Vd(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new Kp(o,r));l.integrate(e,0),n.right=l,n.forward()})},dp=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},fp=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===Kp&&op(t[e.right.content.key]??null,e.right.content.value));)e.forward()},pp=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!op(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new gm(Z(a,Vd(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new Kp(s,c)),n.right.integrate(e,0),n.forward()}}return o},mp=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;fp(n,i);let s=pp(e,t,n,i),c=r.constructor===String?new $p(r):r instanceof Pf?new lm(r):new Wp(r),{left:l,right:u,index:d}=n;t._searchMarker&&Mf(t._searchMarker,n.index,c.getLength()),u=new gm(Z(o,Vd(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),up(e,t,n,s)},hp=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;fp(n,i);let s=pp(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===Kp));){if(!n.right.deleted)switch(n.right.content.constructor){case Kp:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(op(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&Kd(e,Z(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
4
4
|
`;n.right=new gm(Z(o,Vd(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new $p(i)),n.right.integrate(e,0),n.forward()}up(e,t,n,s)},gp=(e,t,n,r,i)=>{let a=t,o=no();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===Kp){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case Kp:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&dp(i,n);break}}}t=t.right}return s},_p=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Kp){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},vp=e=>{let t=0;return rf(e.doc,n=>{let r=e._start,i=e._start,a=no(),o=ro(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Kp:dp(o,i.content);break;default:t+=gp(n,r,i,a,o),a=ro(o),r=i;break}i=i.right}}),t},yp=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Yd(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===Kp&&e.constructor!==Ip&&t.add(e.parent)})}rf(n,n=>{ju(e,e.deleteSet,e=>{if(e instanceof Ip||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===Kp?t.add(r):_p(n,e)});for(let e of t)vp(e)})},bp=(e,t,n)=>{let r=n,i=ro(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case lm:case Wp:case $p:n<t.right.length&&Kd(e,Z(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&gp(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&Mf(o._searchMarker,t.index,-r+n),t},xp=class extends Sf{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){return this._changes===null&&(this._changes={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set}),this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];rf(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},cc(o)||(e.attributes=ic({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case lm:case Wp:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case $p:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case Kp:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(op(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),op(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;op(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(op(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),dp(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},Sp=class e extends Pf{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??wf(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new xp(this,e,t);Nf(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??wf();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===$p&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):rf(this.doc,n=>{let r=new sp(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
5
5
|
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&mp(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&bp(n,r,a.delete):hp(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??wf();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(Ld(s,e)||t!==void 0&&Ld(s,t))switch(s.content.constructor){case $p:{let r=i.get(`ychange`);e!==void 0&&!Ld(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!Ld(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case lm:case Wp:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case Kp:Ld(s,e)&&(c(),dp(i,s.content));break}s=s.right}c()};return e||t?rf(a,n=>{e&&Rd(n,e),t&&Rd(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):rf(r,r=>{let i=lp(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),mp(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):rf(r,r=>{let i=lp(r,this,e,!n);mp(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):rf(n,n=>{bp(n,lp(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):rf(r,r=>{let i=lp(r,this,e,!1);i.right!==null&&hp(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):rf(this.doc,t=>{qf(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):rf(this.doc,n=>{Jf(n,this,e,t)})}getAttribute(e){return Yf(this,e)}getAttributes(){return Xf(this)}_write(e){e.writeTypeRef(im)}},Cp=e=>new Sp,wp=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??wf()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Dp||t.constructor===Tp)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},Tp=class e extends Pf{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Pf?e.clone():e)),t}get length(){return this.doc??wf(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new wp(this,e)}querySelector(e){e=e.toUpperCase();let t=new wp(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),uo(new wp(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Nf(this,e,new kp(this,t,e))}toString(){return zf(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),Rf(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):rf(this.doc,n=>{Wf(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)rf(this.doc,n=>{let r=e&&e instanceof Pf?e._item:e;Hf(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw ws(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):rf(this.doc,n=>{Kf(n,this,e,t)})}toArray(){return If(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Vf(this,e)}slice(e=0,t=this.length){return Ff(this,e,t)}forEach(e){Rf(this,e)}_write(e){e.writeTypeRef(om)}},Ep=e=>new Tp,Dp=class e extends Tp{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return oc(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof Pf?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):rf(this.doc,t=>{qf(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):rf(this.doc,n=>{Jf(n,this,e,t)})}getAttribute(e){return Yf(this,e)}hasAttribute(e){return Zf(this,e)}getAttributes(e){return e?Qf(this,e):Xf(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return Rf(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(am),e.writeKey(this.nodeName)}},Op=e=>new Dp(e.readKey()),kp=class extends Sf{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},Ap=class e extends ip{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(sm),e.writeKey(this.hookName)}},jp=e=>new Ap(e.readKey()),Mp=class e extends Sp{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(cm)}},Np=e=>new Mp,Pp=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ts()}mergeWith(e){return!1}write(e,t,n){throw Ts()}integrate(e,t){throw Ts()}},Fp=0,Ip=class extends Pp{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Hd(e.doc.store,this)}write(e,t){e.writeInfo(Fp),e.writeLen(this.length-t)}getMissing(e,t){return null}},Lp=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw Ts()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},Rp=e=>new Lp(e.readBuf()),zp=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Iu(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},Bp=e=>new zp(e.readLen()),Vp=(e,t)=>new Uu({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Hp=class e{constructor(e){e._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=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(Vp(this.doc.guid,this.opts))}splice(e){throw Ts()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},Up=e=>new Hp(Vp(e.readString(),e.readAny())),Wp=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw Ts()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Gp=e=>new Wp(e.readJSON()),Kp=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw Ts()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},qp=e=>new Kp(e.readKey(),e.readJSON()),Jp=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},Yp=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new Jp(n)},Xp=wc(`node_env`)===`development`,Zp=class e{constructor(e){this.arr=e,Xp&&pc(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},Qp=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Zp(n)},$p=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},em=e=>new $p(e.readString()),tm=[np,ap,Cp,Op,Ep,jp,Np],nm=0,rm=1,im=2,am=3,om=4,sm=5,cm=6,lm=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw Ts()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},um=e=>new lm(tm[e.readTypeRef()](e)),dm=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Z(n.client,n.clock+r)),i=Wd(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof gm);return{item:i,diff:r}},fm=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},pm=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new gm(Z(r,i+n),t,Z(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=Z(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},mm=(e,t)=>po(e,e=>Nu(e.deletions,t)),hm=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Kd(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||hm(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Kd(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Kd(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Kd(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||Nu(r,d.right.id)||mm(a.undoStack,d.right.id)||mm(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Kd(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=Z(c,Vd(s,c)),h=new gm(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,fm(h,!0),h.integrate(e,0),h},gm=class e extends Pp{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Vd(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Vd(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===bd&&this.id.client!==this.parent.client&&this.parent.clock>=Vd(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=qd(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Kd(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===Ip||this.right&&this.right.constructor===Ip)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===bd){let e=Wd(n,this.parent);e.constructor===Ip?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=qd(e,e.doc.store,Z(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),xd(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(xd(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Wd(e.doc.store,n.origin)))r.has(Wd(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Hd(e.doc.store,this),this.content.integrate(e,this),Qd(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Ip(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:Z(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&xd(e.origin,this.lastId)&&this.right===e&&xd(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),Iu(e.deleteSet,this.id.client,this.id.clock,this.length),Qd(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw Es();this.content.gc(e),t?Jd(e,this,new Ip(this.id,this.length)):this.content=new zp(this.length)}write(e,t){let n=t>0?Z(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=Sd(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===bd?(e.writeParentInfo(!1),e.writeLeftID(t)):Es();i!==null&&e.writeString(i)}this.content.write(e,t)}},_m=(e,t)=>vm[t&31](e),vm=[()=>{Es()},Bp,Yp,Rp,em,Gp,qp,um,Qp,Up,()=>{Es()}],ym=10,bm=class extends Pp{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){Es()}write(e,t){e.writeInfo(ym),is(e.restEncoder,this.length-t)}getMissing(e,t){return null}},xm=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Sm=`__ $YJS$ __`;xm[Sm]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),xm[Sm]=!0;var Cm=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},wm=/[\uD800-\uDBFF]/,Tm=/[\uDC00-\uDFFF]/,Em=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&wm.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&Tm.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},Dm=(e,t)=>e>>>t|e<<32-t,Om=e=>Dm(e,2)^Dm(e,13)^Dm(e,22),km=e=>Dm(e,6)^Dm(e,11)^Dm(e,25),Am=e=>Dm(e,7)^Dm(e,18)^e>>>3,jm=e=>Dm(e,17)^Dm(e,19)^e>>>10,Mm=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Nm=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pm=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Nm),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=jm(t[e-2])+t[e-7]+Am(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+km(o)+(o&s^~o&c)+Mm[e]+t[e]>>>0,d=Om(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/Fo,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},Fm=e=>new Pm().digest(e),Im=new Te(`y-sync`),Lm=new Te(`y-undo`),Rm=new Te(`yjs-cursor`),zm=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},Bm=e=>kc(zm(Fm(jc(e)))),Vm=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!Nu(t.ds,e.id),Hm=[{light:`#ecd44433`,dark:`#ecd444`}],Um=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=so();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,qs(t))}return e.get(n)},Wm=(e,{colors:t=Hm,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new Jm(e,a),c=new Fe({props:{editable:e=>{let t=Im.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:Im,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(Im);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&lu(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=Lm.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},Im)})}},destroy:()=>{s.destroy()}})});return c},Gm=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new be(e.doc));else if(t.type===`node`){let r=Ch(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Km(e,r))}else{let r=Ch(n.doc,n.type,t.anchor,n.mapping),i=Ch(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(Je.between(e.doc.resolve(r),e.doc.resolve(i)))}},Km=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?Le.create(e.doc,t):Je.near(n)},qm=(e,t)=>({type:t.selection.jsonID,anchor:xh(t.selection.anchor,e.type,e.mapping),head:xh(t.selection.head,e.type,e.mapping)}),Jm=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=Cm(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=qm(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(yc&&this._domSelectionInView===null&&(lu(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=ql.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=Fd(Lu(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(Im,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>Xm(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new h(Ze.from(e),0,0));t.setMeta(Im,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>Xm(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new h(Ze.from(t),0,0));if(e){let t=bo(xo(e.anchor,0),n.doc.content.size),r=bo(xo(e.head,0),n.doc.content.size);n.setSelection(Je.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(Im,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=Id(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&Es(),r=new Uu({gc:!1}),id(r,t),t=Id(r),id(r,e),e=Id(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[Ud(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{ju(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:Um(n.colorMapping,n.colors,r)}},s=Lf(i,new Pd(t.ds,e.sv)).map(n=>!n._item.deleted||Vm(n._item,e)||Vm(n._item,t)?Xm(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new h(Ze.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(Im,{isChangeOrigin:!0}))},Im)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=Im.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);ju(t,t.deleteSet,e=>{if(e.constructor===gm){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>Ym(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new h(Ze.from(n),0,0));Gm(r,this.beforeTransactionSelection,this),r=r.setMeta(Im,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof cf}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{mh(this.doc,this.type,e,this),this.beforeTransactionSelection=qm(this,this.prosemirrorView.state)},Im)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},Ym=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof Dp)return Xm(e,t,n,r,i,a);throw Ts()}return o},Xm=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof Dp){let s=Ym(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof Sp&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=Zm(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):Lf(e,new Pd(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(Vm(e._item,r)?Vm(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=t.node(e.nodeName,s,o);return n.mapping.set(e,c),c}catch(r){console.warn(`[y-prosemirror] schema.node(`+e.nodeName+`) threw:`,String(r&&r.message||r));let i=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};if(t.nodes[e.nodeName]&&t.nodes[e.nodeName].spec&&t.nodes[e.nodeName].spec.inline)i.inline++;else if(i.block++,t.nodes.rawMdxFallback)try{let i=t.node(`rawMdxFallback`,{reason:String(r&&r.message||r)},[t.text(e.nodeName)]);return n.mapping.set(e,i),i}catch(e){console.warn(`[y-prosemirror] rawMdxFallback substitution also failed:`,String(e&&e.message||e))}return n.mapping.delete(e),null}},Zm=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,fh(n.attributes,t)))}}catch(e){console.warn(`[y-prosemirror] schema.text() threw:`,String(e&&e.message||e));let t=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};return t.inline++,null}return o},Qm=(e,t)=>{let n=new Mp,r=e.map(e=>({insert:e.text,attributes:ph(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},$m=(e,t)=>{let n=new Dp(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,rh(e).map(e=>eh(e,t))),t.mapping.set(n,e),n},eh=(e,t)=>e instanceof Array?Qm(e,t):$m(e,t),th=e=>typeof e==`object`&&!!e,nh=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||th(o)&&th(s)&&nh(o,s)}return r},rh=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},ih=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&ac(e.attributes||{}).length===t[n].marks.length&&lc(e.attributes,(e,r)=>{let i=dh(r),a=t[n].marks;return a.find(e=>e.type.name===i)?nh(e,a.find(e=>e.type.name===i)?.attrs):!1}))},ah=(e,t)=>{if(e instanceof Dp&&!(t instanceof Array)&&hh(e,t)){let n=rh(t);return e._length===n.length&&nh(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>ah(e,n[t]))}return e instanceof Mp&&t instanceof Array&&ih(e,t)},oh=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),sh=(e,t,n)=>{let r=e.toArray(),i=rh(t),a=i.length,o=r.length,s=bo(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(oh(n.mapping.get(e),t))u=!0;else if(!ah(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(oh(n.mapping.get(e),t))u=!0;else if(!ah(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},ch=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof $p?t+=n.content.str:n.content instanceof Kp&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},lh=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=ch(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,ph(e.marks,n))})),{insert:o,remove:s,index:c}=Em(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},uh=/(.*)(--[a-zA-Z0-9+/=]{8})$/,dh=e=>uh.exec(e)?.[1]??e,fh=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(dh(r),e[r]));return n},ph=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=io(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${Bm(e.toJSON())}`:e.type.name]=e.attrs}}),n},mh=(e,t,n,r)=>{if(t instanceof Dp&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof Dp){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=rh(n),a=i.length,o=t.toArray(),s=o.length,c=bo(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!oh(r.mapping.get(e),t))if(ah(e,t))r.mapping.set(e,t);else break}for(;u+l+1<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!oh(r.mapping.get(e),t))if(ah(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof Mp&&c instanceof Array)ih(n,c)||lh(n,c,r),l+=1;else{let i=n instanceof Dp&&hh(n,c),a=d instanceof Dp&&hh(d,f);if(i&&a){let e=sh(n,c,r),t=sh(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(mh(e,n,c,r),l+=1):a?(mh(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[eh(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof Mp?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(eh(i[t],r));t.insert(l,e)}},Im)},hh=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,gh=null,_h=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=Im.getState(this.view.state);if(e&&e.binding&&!e.binding.isDestroyed){let e=this.view.state.tr;e.setMeta(this.key,this.value),this.view.dispatch(e)}}},vh=class e{constructor(e=[]){this.entries=e}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return this.entries.length===0}static fromViewsToUpdate(){let t=gh;gh=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new _h(t,r,e))})}),new e(n)}},yh=(e=vh.fromViewsToUpdate(),t=!1)=>{let n=!0;for(;!e.isEmpty();){let r=e.getFirst();try{r.apply()}catch(r){if(r instanceof RangeError){t&&n&&e.dequeueFirst(),e.isEmpty()||lu(0,()=>yh(e,!0));return}throw r}n=!1,e.dequeueFirst()}},bh=(e,t,n)=>{gh||(gh=new Map,lu(0,yh)),io(gh,e,no).set(t,n)},xh=(e,t,n)=>{if(e===0)return Ad(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof Mp){if(r._length>=e)return Ad(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new wd(r._item===null?null:r._item.id,r._item===null?Sd(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new wd(r._item===null?null:r._item.id,r._item===null?Sd(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw Es();if(e===0&&r.constructor!==Mp&&r!==t)return Sh(r._item.parent,r._item)}return Ad(t,t._length,-1)},Sh=(e,t)=>{let n=null,r=null;return e._item===null?r=Sd(e):n=Z(e._item.id.client,e._item.id.clock),new wd(n,r,t.id)},Ch=(e,t,n,r)=>{let i=Md(n,e);if(i===null||i.type!==t&&!Cd(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===Mp)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;t++,n instanceof Mp?o+=n._length:o+=r.get(n).nodeSize}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;t.deleted||(e instanceof Mp?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},wh=(e,t,n)=>e!==t,Th=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(``),i=document.createTextNode(``);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},Eh=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),Dh=/^#[0-9a-fA-F]{6}$/,Oh=(e,t,n,r,i)=>{let a=Im.getState(e);if(a==null||a.doc==null||a.binding==null)return ge.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?ge.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:Dh.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=Ch(o,a.type,Ed(t.cursor.anchor),a.binding.mapping),u=Ch(o,a.type,Ed(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=xo(e.doc.content.size-1,0);l=bo(l,t),u=bo(u,t),s.push(Ke.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=bo(l,u),o=xo(l,u);s.push(Ke.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),ge.create(e.doc,s))},kh=(e,{awarenessStateFilter:t=wh,cursorBuilder:n=Th,selectionBuilder:r=Eh,getSelection:i=e=>e.selection}={},a=`cursor`)=>new Fe({key:Rm,state:{init(i,a){return Oh(a,e,t,n,r)},apply(i,a,o,s){let c=Im.getState(s),l=i.getMeta(Rm);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?Oh(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>Rm.getState(e)},view:t=>{let n=()=>{t.docView&&bh(t,Rm,{awarenessUpdated:!0})},r=()=>{let n=Im.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=xh(o.anchor,n.type,n.binding.mapping),c=xh(o.head,n.type,n.binding.mapping);(r.cursor==null||!Nd(Ed(r.cursor.anchor),s)||!Nd(Ed(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&Ch(n.doc,n.type,Ed(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),Ah=e=>{let t=Lm.getState(e).undoManager;if(t!=null)return t.undo(),!0},jh=e=>{let t=Lm.getState(e).undoManager;if(t!=null)return t.redo(),!0},Mh=new Set([`paragraph`]),Nh=(e,t)=>!(e instanceof gm)||!(e.content instanceof lm)||!(e.content.type instanceof Sp||e.content.type instanceof Dp&&t.has(e.content.type.nodeName))||e.content.type._length===0,Ph=({protectedNodes:e=Mh,trackedOrigins:t=[],undoManager:n=null}={})=>new Fe({key:Lm,state:{init:(r,i)=>{let a=Im.getState(i),o=n||new cf(a.type,{trackedOrigins:new Set([Im].concat(t)),deleteFilter:t=>Nh(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=Im.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:qm(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=Im.getState(e.state),n=Lm.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,Lm.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}});D({event:S(`ok-branch-switched-clear-failed`),branch:ze(),docName:ze(),reason:ze()});async function Fh(e,t){let n=[];for(let[r,i]of e.entries)i.kind===`active`&&i.persistence!==null&&n.push(i.persistence.clearData().catch(e=>{let n={event:`ok-branch-switched-clear-failed`,docName:r,branch:t,reason:e instanceof Error?e.message:String(e)};console.warn(JSON.stringify(n))}));await Promise.all(n),e.clearBufferedUpdates(),e.recycleAllEntries()}function Ih(e){let t=!1;return()=>{t?e():t=!0}}function Lh(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Rh(e,t=``){let n;try{n=await fetch(`${t}/api/server-info`,{signal:AbortSignal.timeout(5e3)})}catch{return}if(!n.ok)return;let r;try{r=await n.json()}catch{return}let i=d.safeParse(r);if(!i.success){console.warn(JSON.stringify({event:`ok-server-info-schema-mismatch`,issues:i.error.issues}));return}if(e.setExpectedServerInstanceId(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&Fh(e,i.data.currentBranch),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=Lh(n)}catch{}e.observeDiskAckBatch(t)}}async function zh(e){let t;try{t=await fetch(`/api/config`,{signal:e,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return{status:`error`,code:`network`}}if(t.status===404||t.status===501)return{status:`absent`};if(!t.ok)return{status:`error`,code:t.status};let n;try{n=await t.json()}catch{return{status:`error`,code:`invalid-body`}}if(typeof n!=`object`||!n||Array.isArray(n))return{status:`error`,code:`invalid-body`};let r=n;return{status:`ok`,config:{collabUrl:typeof r.collabUrl==`string`?r.collabUrl:null,previewUrl:typeof r.previewUrl==`string`?r.previewUrl:null,port:typeof r.port==`number`?r.port:0}}}function Bh(e){return qh(e,Xe)}function Vh(e){return qh(e,m)}function Hh(e){return qh(e,$e)}function Uh(e){return qh(e,ue)}function Wh(e){let t=qh(e,z);if(!t)return null;try{return{docName:t.docName,sv:Gh(t.sv)}}catch{return null}}function Gh(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Kh(e,t){let n=Vh(e);if(n){t.onServerInfo?.(n);return}let r=Hh(e);if(r){t.onBranchSwitched?.(r);return}let i=Wh(e);if(i){t.onDiskAck?.(i);return}let a=Bh(e);if(a){t.onDerivedView?.(a);return}let o=Uh(e);if(o){t.onConfigValidationRejected?.(o);return}t.onUnknown?.(e)}function qh(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function Jh(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function Yh(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function Xh(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var Zh=2e3,Qh=15e3;function $h(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??Zh,r=e.maxDelayMs??Qh,i=e.log??{info:console.info,warn:console.warn},a=new AbortController,o=null,s=n,c=0,l=!1,u=!1,d=null,f=e.now(),p=async()=>{c+=1;let n=null;try{let t=await e.fetchConfig(a.signal);t.status===`absent`?(n=e.fallbackUrl(),d=null):t.status===`ok`&&t.config.collabUrl!==null?(n=t.config.collabUrl,d=null):t.status===`ok`?(u||(u=!0,i.info(`[collab-url] ok ui responded but server.lock has no port yet — retrying`)),d={kind:`null-collab`}):t.status===`error`&&(i.warn(`[collab-url] /api/config error (${t.code}) — retrying in ${s}ms`),d={kind:`error`,code:t.code})}catch(e){if(e.name===`AbortError`)return;d={kind:`error`,code:`network`}}if(!l){if(n!==null){e.onStateChange({collabUrl:n,attempts:c,terminal:!1,lastError:null});return}if(e.now()-f>=t){e.onStateChange({collabUrl:null,attempts:c,terminal:!0,lastError:d});return}e.onStateChange({collabUrl:null,attempts:c,terminal:!1,lastError:d}),o=e.setTimeout(()=>{p()},s),s=Math.min(s*2,r)}};return p(),{cancel:()=>{l=!0,a.abort(),o!==null&&(e.clearTimeout(o),o=null)}}}function eg(){let e=(0,J.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,K.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,K.useRef)(i),[o,s]=(0,K.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=Yh(typeof window<`u`?window:void 0);if(t){r(Xh(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(Xh(t))});return()=>{n()}}let n=$h({fetchConfig:zh,fallbackUrl:Jh,now:Date.now,setTimeout:ig,clearTimeout:rg,onStateChange:t=>{e===a.current.token&&r(t)}});return()=>{n.cancel()}},e[2]=c):c=e[2];let l;e[3]===o?l=e[4]:(l=[o],e[3]=o,e[4]=l),(0,K.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(ng),s(tg)},e[5]=u):u=e[5];let d=u,f;return e[6]===n?f=e[7]:(f={...n,retry:d},e[6]=n,e[7]=f),f}function tg(e){return e+1}function ng(e){return{...e,terminal:!1,lastError:null}}function rg(e){return globalThis.clearTimeout(e)}function ig(e,t){return globalThis.setTimeout(e,t)}function ag(e){try{let t=e.state;return Lm.getState(t)?.undoManager??null}catch{return null}}function og(e){return!(e.viewCount>0&&e.viewCount>=50||e.bytes>5e5)}var sg=new Map,cg=new Map,lg=[],ug=[],dg=new Set,fg=null;function pg(){if(fg)return fg;if(typeof document>`u`||typeof document.createElement!=`function`)return null;let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-parking`,``),e.style.display=`none`,e.style.position=`absolute`,e.style.left=`-99999px`,fg=e,e}function mg(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!og(i)){let e=r(n);return Y(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`}),{editor:e.editor,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,__uncached:!0}}let a=sg.get(t);if(a){if(Sg(a,n),a.activeMountKey=t,wg(lg,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return Y(`ok/cache/hit`,{docName:t,kind:`tiptap`}),i&&Y(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;sg.size>=10;){let e=Tg(lg,t);if(!e)break;gg(e)}let o=r(n),s={editor:o.editor,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t};return sg.set(t,s),wg(lg,t),Y(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&Y(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function hg(e){if(e.__uncached){let t=ag(e.editor);try{e.editor.destroy()}catch{}t&&(t.restore=void 0),e.activeMountKey=null;return}let t=bg(e.editor);if(t){e.hadFocus=xg(t.dom),e.scrollTop=(t.scrollDOM??t.dom.parentElement??t.dom).scrollTop??0;let n=t.dom.parentElement;n&&n.removeChild(t.dom);let r=pg();r&&r.appendChild(t.dom)}e.activeMountKey=null}function gg(e){let t=sg.get(e);if(!t)return!1;let n=ag(t.editor);try{t.editor.destroy()}catch(t){Y(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}n&&(n.restore=void 0);try{t.provider.destroy()}catch(t){Y(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Y(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}sg.delete(e);let r=lg.indexOf(e);return r!==-1&&lg.splice(r,1),Y(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function _g(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!og(i)){let e=r(n);return Y(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,__uncached:!0}}let a=cg.get(t);if(a){if(Cg(a,n),a.activeMountKey=t,wg(ug,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return Y(`ok/cache/hit`,{docName:t,kind:`cm`}),i&&Y(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;cg.size>=10;){let e=Tg(ug,t);if(!e)break;yg(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t};return cg.set(t,s),wg(ug,t),Y(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&Y(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function vg(e){if(e.__uncached){try{e.view.destroy()}catch{}e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=xg(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t);let r=pg();r&&r.appendChild(t),e.activeMountKey=null}function yg(e){let t=cg.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){Y(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){Y(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Y(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}cg.delete(e);let n=ug.indexOf(e);return n!==-1&&ug.splice(n,1),Y(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function bg(e){return e.editorView??null}function xg(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function Sg(e,t){let n=bg(e.editor);if(!n)return;let r=n.dom,i=r.parentElement;i&&i!==t&&i.removeChild(r),r.parentElement!==t&&t.appendChild(r)}function Cg(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function wg(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function Tg(e,t){for(let n of e)if(n!==t&&!dg.has(n))return n;Y(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:dg.size});for(let n of e)if(n!==t)return n;return null}function Eg(e){let t=dg,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=Dg(e);if(t)try{t.disconnect(),Y(`ok/cache/disconnect`,{docName:e})}catch(t){Y(`ok/cache/disconnect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}}for(let e of n){if(t.has(e))continue;let n=Dg(e);if(!n)continue;let r=t=>{Y(`ok/cache/connect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})};try{let t=n.connect();t&&typeof t.then==`function`?t.then(()=>Y(`ok/cache/connect`,{docName:e}),e=>r(e)):Y(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}dg=n}function Dg(e){let t=sg.get(e);if(t)return t.provider;let n=cg.get(e);return n?n.provider:null}function Og(e){return e.onEvict(e=>{gg(e),yg(e)})}var kg=Math.floor,Ag=(e,t)=>e<t?e:t,jg=(e,t)=>e>t?e:t;Number.isNaN;var Mg=128,Ng=1<<17,Pg=1<<18,Fg=1<<19,Ig=1<<20,Lg=1<<21,Rg=1<<22,zg=1<<23,Bg=1<<24,Vg=1<<25,Hg=1<<26,Ug=1<<27,Wg=1<<28,Gg=1<<29,Kg=1<<30,qg=127;Ng-1,Pg-1,Fg-1,Ig-1,Lg-1,Rg-1,zg-1,Bg-1,Vg-1,Hg-1,Ug-1,Wg-1,Gg-1,Kg-1;var Jg=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Yg=String.fromCharCode;String.fromCodePoint,Yg(65535);var Xg=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Zg=typeof TextEncoder<`u`?new TextEncoder:null,Qg=Zg?e=>Zg.encode(e):Xg,$g=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});$g&&$g.decode(new Uint8Array).length===1&&($g=null);var e_=(e,t)=>{let 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},t_=(e,t)=>{for(;t>qg;)e_(e,Mg|qg&t),t=kg(t/128);e_(e,qg&t)},n_=new Uint8Array(3e4),r_=n_.length/3,i_=Zg&&Zg.encodeInto?(e,t)=>{if(t.length<r_){let n=Zg.encodeInto(t,n_).written||0;t_(e,n);for(let t=0;t<n;t++)e_(e,n_[t])}else o_(e,Qg(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;t_(e,r);for(let t=0;t<r;t++)e_(e,n.codePointAt(t))},a_=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Ag(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(jg(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},o_=(e,t)=>{t_(e,t.byteLength),a_(e,t)},s_=e=>Error(e),c_=s_(`Unexpected end of array`),l_=s_(`Integer out of Range`),u_=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},d_=e=>u_(e,p_(e)),f_=e=>e.arr[e.pos++],p_=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&qg)*n,n*=128,r<Mg)return t;if(t>Jg)throw l_}throw c_},m_=$g?e=>$g.decode(d_(e)):e=>{let t=p_(e);if(t===0)return``;{let n=String.fromCodePoint(f_(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(f_(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},h_=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),g_=(e,t)=>{t_(e,h_.Token),i_(e,t)},__=(e,t,n,r)=>{switch(p_(e)){case h_.Token:t();break;case h_.PermissionDenied:n(m_(e));break;case h_.Authenticated:r(m_(e));break;default:}},v_=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),y_=`\0`;function b_(e,t){return e+y_+t}function x_(e){let t=e.indexOf(y_);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var S_=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function C_(e){return e||={},{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function w_(e){return new Promise(t=>setTimeout(t,e))}function T_(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function E_(e,t){let n=C_(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||T_;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await w_(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await w_(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await w_(e)}return a()}var D_=Math.floor,O_=(e,t)=>e<t?e:t,k_=(e,t)=>e>t?e:t;Number.isNaN;var A_=64,j_=128,M_=1<<17,N_=1<<18,P_=1<<19,F_=1<<20,I_=1<<21,L_=1<<22,R_=1<<23,z_=1<<24,B_=1<<25,V_=1<<26,H_=1<<27,U_=1<<28,W_=1<<29,G_=1<<30,K_=63,q_=127;M_-1,N_-1,P_-1,F_-1,I_-1,L_-1,R_-1,z_-1,B_-1,V_-1,H_-1,U_-1,W_-1,G_-1;var J_=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Y_=()=>new Set,X_=Array.from;Array.isArray;var Z_=String.fromCharCode;String.fromCodePoint,Z_(65535);var Q_=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},$_=typeof TextEncoder<`u`?new TextEncoder:null,ev=$_?e=>$_.encode(e):Q_,tv=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});tv&&tv.decode(new Uint8Array).length===1&&(tv=null);var nv=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},rv=()=>new nv,iv=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},av=e=>{let t=new Uint8Array(iv(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},ov=(e,t)=>{let 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},sv=(e,t)=>{for(;t>q_;)ov(e,j_|q_&t),t=D_(t/128);ov(e,q_&t)},cv=new Uint8Array(3e4),lv=cv.length/3,uv=$_&&$_.encodeInto?(e,t)=>{if(t.length<lv){let n=$_.encodeInto(t,cv).written||0;sv(e,n);for(let t=0;t<n;t++)ov(e,cv[t])}else fv(e,ev(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;sv(e,r);for(let t=0;t<r;t++)ov(e,n.codePointAt(t))},dv=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=O_(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(k_(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},fv=(e,t)=>{sv(e,t.byteLength),dv(e,t)},pv=e=>Error(e),mv=pv(`Unexpected end of array`),hv=pv(`Integer out of Range`),gv=class{constructor(e){this.arr=e,this.pos=0}},_v=e=>new gv(e),vv=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},yv=e=>vv(e,xv(e)),bv=e=>e.arr[e.pos++],xv=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&q_)*n,n*=128,r<j_)return t;if(t>J_)throw hv}throw mv},Sv=e=>{let t=e.arr[e.pos++],n=t&K_,r=64,i=(t&A_)>0?-1:1;if((t&j_)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&q_)*r,r*=128,t<j_)return i*n;if(n>J_)throw hv}throw mv},Cv=tv?e=>tv.decode(yv(e)):e=>{let t=xv(e);if(t===0)return``;{let n=String.fromCodePoint(bv(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(bv(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},wv=e=>{let t=e.pos,n=Cv(e);return e.pos=t,n},Tv=Date.now,Ev=()=>new Map,Dv=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Ov=class{constructor(){this._observers=Ev()}on(e,t){Dv(this._observers,e,Y_).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return X_((this._observers.get(e)||Ev()).values()).forEach(e=>e(...t))}destroy(){this._observers=Ev()}},kv=Symbol(`Equality`),Av=Object.keys,jv=e=>Av(e).length,Mv=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Nv=(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[kv]!=null)return e[kv](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(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Nv(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(jv(e)!==jv(t))return!1;for(let n in e)if(!Mv(e,n)||!Nv(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(!Nv(e[n],t[n]))return!1;break;default:return!1}return!0},Pv=3e4,Fv=class extends Ov{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Tv();this.getLocalState()!==null&&Pv/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&Pv<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&Iv(this,t,`timeout`)},D_(Pv/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:Tv()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Nv(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},Iv=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:Tv()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},Lv=(e,t,n=e.states)=>{let r=t.length,i=rv();sv(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;sv(i,r),sv(i,s),uv(i,JSON.stringify(o))}return av(i)},Rv=(e,t,n)=>{let r=_v(t),i=Tv(),a=[],o=[],s=[],c=[],l=xv(r);for(let t=0;t<l;t++){let t=xv(r),n=xv(r),l=JSON.parse(Cv(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(Nv(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},zv=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},Bv=class{constructor(e){this.data=e,this.encoder=rv(),this.decoder=_v(new Uint8Array(this.data))}peekVarString(){return wv(this.decoder)}readVarUint(){return xv(this.decoder)}readVarString(){return Cv(this.decoder)}readVarUint8Array(){return yv(this.decoder)}writeVarUint(e){return sv(this.encoder,e)}writeVarString(e){return uv(this.encoder,e)}writeVarUint8Array(e){return fv(this.encoder,e)}length(){return iv(this.encoder)}},Vv=function(e){return e[e.Sync=0]=`Sync`,e[e.Awareness=1]=`Awareness`,e[e.Auth=2]=`Auth`,e[e.QueryAwareness=3]=`QueryAwareness`,e[e.Stateless=5]=`Stateless`,e[e.CLOSE=7]=`CLOSE`,e[e.SyncStatus=8]=`SyncStatus`,e[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),Hv=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),Uv=class{constructor(){this.encoder=rv()}get(e){return e.encoder}toUint8Array(){return av(this.encoder)}},Wv=class extends Uv{constructor(...e){super(...e),this.type=Vv.CLOSE,this.description=`Ask the server to close the connection`}get(e){return uv(this.encoder,e.documentName),sv(this.encoder,this.type),this.encoder}},Gv=class e extends zv{static{this.DEDUPLICATABLE_TYPES=new Set([Vv.Awareness,Vv.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=Hv.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on(`open`,this.configuration.onOpen),this.on(`open`,this.onOpen.bind(this)),this.on(`connect`,this.configuration.onConnect),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`status`,this.configuration.onStatus),this.on(`disconnect`,this.configuration.onDisconnect),this.on(`close`,this.configuration.onClose),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`close`,this.onClose.bind(this)),this.on(`message`,this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(e){this.status=Hv.Connected,this.emit(`status`,{status:Hv.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===Hv.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===Hv.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(Wv,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===Hv.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:E_(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=Hv.Connecting,this.emit(`status`,{status:Hv.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Tv();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Vv.Ping){this.sendPong();return}let n=new Bv(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=rv();sv(e,Vv.Pong),this.send(av(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=Hv.Connected,this.emit(`status`,{status:Hv.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===Hv.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Tv()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:`forced`}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=_v(e);return{documentName:Cv(t),messageType:xv(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===S_.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=Hv.Disconnected,this.emit(`status`,{status:Hv.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},Kv=0,qv=1,Jv=2,Yv=(e,t)=>{sv(e,Kv),fv(e,md(t))},Xv=(e,t,n)=>{sv(e,qv),fv(e,cd(t,n))},Zv=(e,t,n)=>Xv(t,n,yv(e)),Qv=(e,t,n,r)=>{try{ad(t,yv(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},$v=(e,t)=>{sv(e,Jv),fv(e,t)},ey=Qv,ty=(e,t,n,r,i)=>{let a=xv(e);switch(a){case Kv:Zv(e,t,n);break;case qv:Qv(e,n,r,i);break;case Jv:ey(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},ny=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case Vv.Sync:this.applySyncMessage(e,t);break;case Vv.Awareness:this.applyAwarenessMessage(e);break;case Vv.Auth:this.applyAuthMessage(e);break;case Vv.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Vv.Stateless:e.receiveStateless(Cv(n.decoder));break;case Vv.SyncStatus:this.applySyncStatusMessage(e,Sv(n.decoder)===1);break;case Vv.CLOSE:let i={code:1e3,reason:Cv(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(Uv,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Vv.Sync);let r=ty(n.decoder,n.encoder,e.document,e);t&&r===qv&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;Rv(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;__(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(Vv.Awareness),t.writeVarUint8Array(Lv(e.awareness,Array.from(e.awareness.getStates().keys())))}},ry=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return av(this.encoder)}send(e){e?.send(this.create())}},iy=`4.0.0-rc.1`,ay=class extends Uv{constructor(...e){super(...e),this.type=Vv.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return uv(this.encoder,e.documentName),sv(this.encoder,this.type),g_(this.encoder,e.token),uv(this.encoder,iy),this.encoder}},oy=class extends Uv{constructor(...e){super(...e),this.type=Vv.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);uv(this.encoder,e.documentName),sv(this.encoder,this.type);let t;return t=e.states===void 0?Lv(e.awareness,e.clients):Lv(e.awareness,e.clients,e.states),fv(this.encoder,t),this.encoder}},sy=class extends Uv{constructor(...e){super(...e),this.type=Vv.Stateless,this.description=`A stateless message`}get(e){return uv(this.encoder,e.documentName),sv(this.encoder,this.type),uv(this.encoder,e.payload??``),this.encoder}},cy=class extends Uv{constructor(...e){super(...e),this.type=Vv.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return uv(this.encoder,e.documentName),sv(this.encoder,this.type),Yv(this.encoder,e.document),this.encoder}},ly=class extends Uv{constructor(...e){super(...e),this.type=Vv.Sync,this.description=`A document update`}get(e){return uv(this.encoder,e.documentName),sv(this.encoder,this.type),$v(this.encoder,e.update),this.encoder}},uy=class extends Error{constructor(...e){super(...e),this.code=1001}},dy=class extends zv{get effectiveName(){return this.configuration.sessionAwareness?b_(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new Uu,this.configuration.awareness=e.awareness===void 0?new Fv(this.document):e.awareness,this.on(`open`,this.configuration.onOpen),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`synced`,this.configuration.onSynced),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`stateless`,this.configuration.onStateless),this.on(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:v_(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:v_(this.awareness.getStates())})}),this.document.on(`update`,this.boundDocumentUpdateHandler),this.awareness?.on(`update`,this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval==`number`&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new Gv(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(cy,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&Iv(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(sy,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(ay,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(ly,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(oy,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(cy,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(oy,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new ry(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new Bv(e.data),{documentName:n}=x_(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new Bv(e.data)}),new ny(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Iv(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(Iv(this.awareness,[this.document.clientID],`provider destroy`),this.awareness.off(`update`,this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off(`update`,this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),this.configuration.websocketProvider.off(`close`,this.boundOnClose),this.configuration.websocketProvider.off(`close`,this.configuration.onClose),this.configuration.websocketProvider.off(`close`,this.forwardClose),this.configuration.websocketProvider.off(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.off(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.off(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.off(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),this.configuration.websocketProvider.on(`close`,this.boundOnClose),this.configuration.websocketProvider.on(`close`,this.configuration.onClose),this.configuration.websocketProvider.on(`close`,this.forwardClose),this.configuration.websocketProvider.on(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.on(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.on(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.on(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new uy(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}},fy=e=>Zs((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),py=(e,t)=>Zs((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(ws(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),my=e=>fy(indexedDB.deleteDatabase(e)),hy=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),gy=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>Dy(r,e))},_y=(e,t)=>fy(e.count(t)),vy=(e,t)=>fy(e.get(t)),yy=(e,t)=>fy(e.delete(t)),by=(e,t,n)=>fy(e.put(t,n)),xy=(e,t)=>fy(e.add(t)),Sy=(e,t,n)=>fy(e.getAll(t,n)),Cy=(e,t,n)=>{let r=null;return Ey(e,t,e=>(r=e,!1),n).then(()=>r)},wy=(e,t=null)=>Cy(e,t,`prev`),Ty=(e,t)=>Zs((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),Ey=(e,t,n,r=`next`)=>Ty(e.openKeyCursor(t,r),e=>n(e.key)),Dy=(e,t)=>e.objectStore(t),Oy=(e,t)=>IDBKeyRange.upperBound(e,t),ky=(e,t)=>IDBKeyRange.lowerBound(e,t),Ay=`custom`,jy=`updates`,My=(e,t=()=>{},n=()=>{})=>{let[r]=gy(e.db,[jy]);return Sy(r,ky(e._dbref,!1)).then(i=>{e._destroyed||(t(r),rf(e.doc,()=>{i.forEach(t=>ad(e.doc,t))},e,!1),n(r))}).then(()=>wy(r).then(t=>{e._dbref=t+1})).then(()=>_y(r).then(t=>{e._dbsize=t})).then(()=>r)},Ny=(e,t=!0)=>My(e).then(n=>{(t||e._dbsize>=500)&&xy(n,cd(e.doc)).then(()=>yy(n,Oy(e._dbref,!0))).then(()=>_y(n).then(t=>{e._dbsize=t}))}),Py=class extends _o{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=py(e,e=>hy(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=Zs(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,My(this,async e=>{await _y(e)>0&&xy(e,cd(t))},()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=gy(this.db,[jy]);xy(t,e).catch(e=>{globalThis.__okYdbWriteWarned||(globalThis.__okYdbWriteWarned=!0,console.warn(JSON.stringify({event:`ok-ydb-write-failed`,cause:e?.name??`unknown`,message:e?.message??String(e)})))}),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{Ny(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{my(this.name)})}get(e){return this._db.then(t=>{let[n]=gy(t,[Ay],`readonly`);return vy(n,e)})}set(e,t){return this._db.then(n=>{let[r]=gy(n,[Ay]);return by(r,t,e)})}del(e){return this._db.then(t=>{let[n]=gy(t,[Ay]);return yy(n,e)})}},Fy=class{_idb;_dbName;whenSynced;constructor({branch:e,serverInstanceId:t,docName:n,doc:r}){if(typeof t!=`string`||t.length===0)throw Error(`createClientPersistence: serverInstanceId is required and must be non-empty`);this._dbName=`ok-ydoc:${e}:${t}:${n}`,this._idb=new Py(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>this)}get synced(){return this._idb.synced}async destroy(){await this._idb.destroy()}async clearData(){await this._idb.destroy();let e=this._dbName;await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(),r.onerror=()=>n(r.error),r.onblocked=()=>{console.warn(JSON.stringify({event:`ok-client-persistence-clear-blocked`,dbName:e})),n(Error(`idb-clear-blocked: ${e}`))}})}};function Iy(e){return new Fy(e)}function Ly(e){return md(e)}function Ry(e,t){return t===null?cd(e):cd(e,t)}function zy(e,t){if(e===null)return t;if(t===null)return e;let n=ud(e),r=ud(t),i=new Map;for(let[e,t]of n)i.set(e,t);for(let[e,t]of r){let n=i.get(e);(n===void 0||t>n)&&i.set(e,t)}return md(i)}function By(e){let t={};if(i.inject(r.active(),t),!t.traceparent)return e;let n=e.includes(`?`)?`&`:`?`,a=[`traceparent=${encodeURIComponent(t.traceparent)}`];return t.tracestate&&a.push(`tracestate=${encodeURIComponent(t.tracestate)}`),`${e}${n}${a.join(`&`)}`}var Vy=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new Fe({key:e||new Te(`fileHandler`),props:{handleDrop(e,n){if(!r||!n.dataTransfer?.files.length)return!1;let a=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return i&&(o=o.filter(e=>i.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),r(t,o,a?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let a=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return i&&(a=a.filter(e=>i.includes(e.type))),!(a.length===0||(r.preventDefault(),r.stopPropagation(),n(t,a,o),o.length>0))}}}),Hy=W.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[Vy({key:new Te(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),Uy=W.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof Le){let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=Je.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof Je?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof Le))return!1;let n=t.selection.from,r=t.doc.resolve(n);if(r.index(r.depth)===0)return!1;let i=r.before(r.depth);if(i<=0)return!1;let a=t.doc.resolve(i-1).nodeBefore;if(!a||i-1-a.nodeSize+1<0)return!1;try{let n=Le.create(t.doc,i-a.nodeSize);return e.view.dispatch(t.tr.setSelection(n).scrollIntoView()),!0}catch{return!1}},ArrowDown:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof Le))return!1;let n=t.selection.from+t.selection.node.nodeSize;if(n>=t.doc.content.size)return!1;try{if(!t.doc.nodeAt(n))return!1;let r=Le.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch{return!1}},Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof Je)||!t.selection.empty)return!1;let n=t.selection.$from,r=n.parent;if(r.type.name!==`paragraph`||r.textContent!==``||n.depth<2)return!1;let i=-1;for(let e=n.depth-1;e>=1;e--)if(n.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;let a=n.node(i);if(n.index(i)!==a.childCount-1)return!1;let o=n.after(i);if(o>t.doc.content.size)return!1;let s=t.tr,c=n.before(n.depth),l=n.after(n.depth);s.delete(c,l);let u=o-(l-c),d=t.schema.nodes.paragraph.create();s.insert(u,d);let f=u+1;return s.setSelection(Je.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),Wy=new WeakMap;function Gy(e,t){if(t===null){Wy.delete(e);return}Wy.set(e,t)}function Ky(e){return Wy.get(e)??null}function qy(e){return`pagesBySlug`in e}function Jy(e){return qy(e)?e.pages:e}function Yy(e,t){let n=p(e);if(n){if(qy(t))return t.pagesBySlug.get(n);for(let e of t)if(p(e)===n)return e}}function Xy(e){let t=e.trim();if(!t)return null;let n=p(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function Zy(e){let t=e.trim();if(!t)return[];let n=p(t);return n.length>0&&n!==t?[n]:[]}function Qy(e,t){let n=e.trim();if(!n)return!1;let r=Jy(t);return r.has(n)||Zy(n).some(e=>r.has(e))?!0:Yy(n,t)!==void 0}var $y={ChevronRight:Bn};function eb(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn($y,t)?$y[t]:null}function tb(e){let t=(0,J.c)(23),n;t[0]===e.icon?n=t[1]:(n=eb(e.icon),t[0]=e.icon,t[1]=n);let r=n,i=r?`custom`:void 0,a;t[2]===r?a=t[3]:(a=r?(0,q.jsx)(r,{size:16,className:`accordion-icon`,"aria-hidden":`true`}):null,t[2]=r,t[3]=a);let o=e.title??`Accordion`,s;t[4]===o?s=t[5]:(s=(0,q.jsx)(`span`,{className:`accordion-title`,children:o}),t[4]=o,t[5]=s);let c;t[6]===e.description?c=t[7]:(c=e.description?(0,q.jsx)(`span`,{className:`accordion-description`,children:e.description}):null,t[6]=e.description,t[7]=c);let l;t[8]!==s||t[9]!==c?(l=(0,q.jsxs)(`span`,{className:`accordion-title-group`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;t[11]!==a||t[12]!==l?(u=(0,q.jsxs)(`summary`,{className:`accordion-summary`,contentEditable:!1,children:[a,l]}),t[11]=a,t[12]=l,t[13]=u):u=t[13];let d;t[14]===e.children?d=t[15]:(d=(0,q.jsx)(`div`,{className:`accordion-body`,children:e.children}),t[14]=e.children,t[15]=d);let f;return t[16]!==e.defaultOpen||t[17]!==e.id||t[18]!==e.name||t[19]!==i||t[20]!==u||t[21]!==d?(f=(0,q.jsxs)(`details`,{className:`accordion`,"data-accordion-icon":i,open:e.defaultOpen,id:e.id,name:e.name,children:[u,d]}),t[16]=e.defaultOpen,t[17]=e.id,t[18]=e.name,t[19]=i,t[20]=u,t[21]=d,t[22]=f):f=t[22],f}function nb(e){return e!==!1}function rb(e){let t=(0,J.c)(10),n=e.src,r=e.title,i;t[0]===e.controls?i=t[1]:(i=nb(e.controls),t[0]=e.controls,t[1]=i);let a;return t[2]!==e.autoplay||t[3]!==e.loop||t[4]!==e.muted||t[5]!==e.preload||t[6]!==e.src||t[7]!==e.title||t[8]!==i?(a=(0,q.jsx)(`audio`,{className:`ok-audio`,src:n,title:r,controls:i,autoPlay:e.autoplay,loop:e.loop,muted:e.muted,preload:e.preload}),t[2]=e.autoplay,t[3]=e.loop,t[4]=e.muted,t[5]=e.preload,t[6]=e.src,t[7]=e.title,t[8]=i,t[9]=a):a=t[9],a}var ib={note:Zn,tip:Qn,important:rr,warning:x,caution:ar},ab={Info:Zn,Lightbulb:Qn,MessageSquareWarning:rr,AlertTriangle:x,AlertOctagon:ar};function ob(e,t){if(!e||!e.startsWith(`lucide:`))return ib[t];let n=e.slice(7);return Object.hasOwn(ab,n)?ab[n]:ib[t]}function sb(e){return e===`note`||e===`tip`||e===`important`||e===`warning`||e===`caution`?e:`note`}function cb(e){let t=(0,J.c)(28),n,r;t[0]!==e.icon||t[1]!==e.type?(r=sb(e.type),n=ob(e.icon,r),t[0]=e.icon,t[1]=e.type,t[2]=n,t[3]=r):(n=t[2],r=t[3]);let i=n,a;t[4]===e.color?a=t[5]:(a=e.color?{"--callout-type-color":e.color}:{},t[4]=e.color,t[5]=a);let o=a,s;t[6]!==i||t[7]!==e.title?(s=e.title||i?(0,q.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,q.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,q.jsx)(`span`,{className:`callout-title`,children:e.title}):null]}):null,t[6]=i,t[7]=e.title,t[8]=s):s=t[8];let c=s;if(e.collapsible){let n=e.defaultOpen??!0,i;t[9]===c?i=t[10]:(i=c??(0,q.jsx)(`span`,{className:`callout-title`,children:`Details`}),t[9]=c,t[10]=i);let a;t[11]===i?a=t[12]:(a=(0,q.jsx)(`summary`,{className:`callout-summary`,contentEditable:!1,children:i}),t[11]=i,t[12]=a);let s;t[13]===e.children?s=t[14]:(s=(0,q.jsx)(`div`,{className:`callout-body`,children:e.children}),t[13]=e.children,t[14]=s);let l;return t[15]!==n||t[16]!==o||t[17]!==a||t[18]!==s||t[19]!==r?(l=(0,q.jsxs)(`details`,{className:`callout callout-collapsible`,"data-callout-type":r,open:n,style:o,children:[a,s]}),t[15]=n,t[16]=o,t[17]=a,t[18]=s,t[19]=r,t[20]=l):l=t[20],l}let l;t[21]===e.children?l=t[22]:(l=(0,q.jsx)(`div`,{className:`callout-body`,children:e.children}),t[21]=e.children,t[22]=l);let u;return t[23]!==c||t[24]!==o||t[25]!==l||t[26]!==r?(u=(0,q.jsxs)(`div`,{className:`callout callout-static`,"data-callout-type":r,style:o,children:[c,l]}),t[23]=c,t[24]=o,t[25]=l,t[26]=r,t[27]=u):u=t[27],u}function lb(){return K.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},K.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function ub(){return K.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},K.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function db(e){return typeof Element>`u`?!1:e instanceof Element}var fb=(e,t)=>db(t)&&t.tagName.toUpperCase()===e,pb=e=>fb(`DIV`,e)||fb(`SPAN`,e),mb=e=>fb(`IMG`,e),hb=e=>e.complete&&e.naturalHeight!==0,gb=e=>fb(`SVG`,e),_b=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),vb=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=_b({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},yb=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?vb({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):_b({height:e,offset:r,width:t}),bb=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,xb=e=>{if(e!==null){if(mb(e))return e.currentSrc===``?void 0:e.currentSrc;if(pb(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return bb.exec(t)?.[1]}}},Sb=e=>{if(e!==null)return mb(e)?e.alt:e.getAttribute(`aria-label`)??void 0},Cb=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=yb({containerHeight:e,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s});return{top:n,left:t,width:r*c,height:e*c,transform:`translate(0,0) scale(${1/c})`}},wb=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},Tb=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,objectFit:a,objectPosition:o,offset:s,targetHeight:c,targetWidth:l})=>{let u=a;if(u===`scale-down`&&(u=l<=r&&c<=e?`none`:`contain`),u===`cover`||u===`contain`){let a=r/l,d=e/c,f=u===`cover`?Math.max(a,d):Math.min(a,d),[p=`50%`,m=`50%`]=o.split(` `),h=wb({position:p,relativeNum:r-l*f}),g=wb({position:m,relativeNum:e-c*f}),_=yb({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+g,left:t+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(u===`none`){let[a=`50%`,u=`50%`]=o.split(` `),d=wb({position:a,relativeNum:r-l}),f=wb({position:u,relativeNum:e-c}),p=yb({containerHeight:c,containerWidth:l,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+f,left:t+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else if(u===`fill`){let t=r/l,n=e/c,a=Math.max(t,n),o=yb({containerHeight:c*a,containerWidth:l*a,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{width:r*o,height:e*o,transform:`translate(0,0) scale(${1/o})`}}else return{}},Eb=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:i,containerWidth:a,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l})=>{if(t===`cover`||t===`contain`){let u=a/l,d=n/c,f=t===`cover`?Math.max(u,d):Math.min(u,d),[p=`50%`,m=`50%`]=e.split(` `),h=wb({position:p,relativeNum:a-l*f}),g=wb({position:m,relativeNum:n-c*f}),_=yb({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+g,left:r+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(t===`auto`){let[t=`50%`,u=`50%`]=e.split(` `),d=wb({position:t,relativeNum:a-l}),f=wb({position:u,relativeNum:n-c}),p=yb({containerHeight:c,containerWidth:l,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+f,left:r+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else{let[u=`50%`,d=`50%`]=t.split(` `),f=wb({position:u,relativeNum:a}),p=wb({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=wb({position:_,relativeNum:a-l*g}),b=wb({position:v,relativeNum:n-c*g}),x=yb({containerHeight:c*g,containerWidth:l*g,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+b,left:r+y,width:l*g*x,height:c*g*x,transform:`translate(0,0) scale(${1/x})`}}},Db=/\.svg$/i,Ob=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:i,offset:a,shouldRefresh:o,targetEl:s})=>{let c=n||t?.slice(0,18)===`data:image/svg+xml`||e||t!==void 0&&Db.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&pb(s),f=i!=null&&!d,p=i!=null&&i.naturalHeight!==0?i.naturalHeight:l.height,m=i!=null&&i.naturalWidth!==0?i.naturalWidth:l.width,h=Cb({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?Tb({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:a,targetHeight:p,targetWidth:m}):void 0,_=d?Eb({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}):void 0,v={...h,...g,..._};if(r){let e=window.innerWidth/2,t=window.innerHeight/2,n=parseFloat(String(v.left??0))+parseFloat(String(v.width??0))/2,r=parseFloat(String(v.top??0))+parseFloat(String(v.height??0))/2,i=e-n,a=t-r;o&&(v.transitionDuration=`0.01ms`),v.transform=`translate(${i}px,${a}px) scale(1)`}return v},kb=e=>{if(e==null)return{};if(gb(e)){let{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{let e=t.getBoundingClientRect();return{height:n.height,left:e.left-n.left,top:e.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},Ab=e=>{let t=`-zoom`,n=[`clip-path`,`fill`,`mask`,`marker-start`,`marker-mid`,`marker-end`],r=new Map;if(e.hasAttribute(`id`)){let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}e.querySelectorAll(`[id]`).forEach(e=>{let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}),r.forEach((t,r)=>{let i=`url(#${r})`,a=`url(#${t})`,o=n.map(e=>`[${e}="${i}"]`).join(`, `);e.querySelectorAll(o).forEach(e=>{n.forEach(t=>{e.getAttribute(t)===i&&e.setAttribute(t,a)})})}),e.querySelectorAll(`style`).forEach(e=>{r.forEach((t,n)=>{let{textContent:r}=e;if(r!==``){let i=e;i.textContent=r.replaceAll(`#${n}`,`#${t}`)}})})},jb=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),Mb={overflow:``,width:``};function Nb(){let e=document.querySelector(`[data-rmiz-portal]`);if(e!=null)return e;let t=document.createElement(`div`);return t.setAttribute(`data-rmiz-portal`,``),document.body.appendChild(t),t}function Pb(e){e.preventDefault()}function Fb(e){return K.createElement(Ib,{...e})}var Ib=class extends K.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=K.createRef(),this.refDialog=K.createRef(),this.refModalContent=K.createRef(),this.refModalImg=K.createRef(),this.refWrap=K.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=Mb,this.styleModalImg={},this.handleModalStateChange=e=>{let{state:{modalState:t}}=this;e!==`LOADING`&&t===`LOADING`?(this.loadZoomImg(),window.addEventListener(`resize`,this.handleResize,{passive:!0}),window.addEventListener(`touchstart`,this.handleTouchStart,{passive:!0}),window.addEventListener(`touchmove`,this.handleTouchMove,{passive:!0}),window.addEventListener(`touchend`,this.handleTouchEnd,{passive:!0}),window.addEventListener(`touchcancel`,this.handleTouchCancel,{passive:!0}),document.addEventListener(`keydown`,this.handleKeyDown,!0)):e!==`LOADED`&&t===`LOADED`?window.addEventListener(`wheel`,this.handleWheel,{passive:!0}):e!==`UNLOADING`&&t===`UNLOADING`?(this.ensureImgTransitionEnd(),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),document.removeEventListener(`keydown`,this.handleKeyDown,!0)):e!==`UNLOADED`&&t===`UNLOADED`&&(this.bodyScrollEnable(),window.removeEventListener(`resize`,this.handleResize),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{let e=()=>Math.random().toString(16).slice(-4);this.setState({id:e()+e()+e()})},this.setAndTrackImg=()=>{let{refContent:{current:e}}=this;e!=null&&(this.imgEl=e.querySelector(jb),this.imgEl===null?this.contentNotFoundChangeObserver??(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(e,{childList:!0,subtree:!0})):(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener(`load`,this.handleImgLoad),this.imgEl.addEventListener(`click`,this.handleZoom),this.state.loadedImgEl??this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(e=>{let[t]=e;t?.target!==void 0&&(this.imgEl=t.target,this.setState({styleGhost:kb(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:kb(this.imgEl)})}),this.contentChangeObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}))))},this.handleIfZoomChanged=e=>{let{props:{isZoomed:t}}=this;!e&&t?this.zoom():e&&!t&&this.unzoom()},this.handleImgLoad=()=>{let e=xb(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(mb(n)){let{sizes:e,srcset:r,crossOrigin:i}=n;t.sizes=e,t.srcset=r,t.crossOrigin=i}t.src=e;let r=()=>{this.setState({loadedImgEl:t,styleGhost:kb(this.imgEl)})};t.decode().then(r).catch(()=>{if(hb(t)){r();return}t.onload=r})},this.handleZoom=e=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:e})},this.handleUnzoom=e=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:e})},this.handleBtnUnzoomClick=e=>{e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e)},this.handleDialogClick=e=>{(e.target===this.refModalContent.current||e.target===this.refModalImg.current)&&(e.stopPropagation(),this.handleUnzoom(e))},this.handleDialogClose=e=>{e.stopPropagation(),this.handleUnzoom(e)},this.handleKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e))},this.handleWheel=e=>{e.ctrlKey||(e.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(e)}))},this.handleTouchStart=e=>{if(e.touches.length>1){this.isScaling=!0;return}let{changedTouches:t}=e,[n]=t;if(t.length===1&&n!==void 0){let{screenY:e}=n;this.touchYStart=e}},this.handleTouchMove=e=>{let t=window.visualViewport?.scale??1,{changedTouches:n}=e,[r]=n;if(this.props.canSwipeToUnzoom&&!this.isScaling&&t<=1&&this.touchYStart!=null&&r!==void 0){let{screenY:t}=r;this.touchYEnd=t;let n=Math.max(this.touchYStart,this.touchYEnd),i=Math.min(this.touchYStart,this.touchYEnd);Math.abs(n-i)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(e))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||gb(this.imgEl))&&window.getComputedStyle(this.imgEl).display!==`none`,this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener(`transitionend`,this.handleImgTransitionEnd),this.setState({modalState:`LOADING`})},this.unzoom=()=>{this.setState({modalState:`UNLOADING`})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState===`LOADING`?this.setState({modalState:`LOADED`}):this.state.modalState===`UNLOADING`&&this.setState({shouldRefresh:!1,modalState:`UNLOADED`})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){let{transitionDuration:e}=window.getComputedStyle(this.refModalImg.current),t=parseFloat(e);if(t!==0&&!Number.isNaN(t)){let n=t*(e.endsWith(`ms`)?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,n)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};let{body:{clientWidth:e}}=document;document.body.style.overflow=`hidden`,document.body.style.width=`${e}px`},this.bodyScrollEnable=()=>{let{prevBodyAttrs:{overflow:e,width:t}}=this;document.body.style.width=t,document.body.style.overflow=e,this.prevBodyAttrs=Mb},this.loadZoomImg=()=>{let{props:{zoomImg:e}}=this;if(e==null)return;let{src:t}=e;if(t!==void 0&&t!==``){let n=new Image;n.sizes=e.sizes??``,n.srcset=e.srcSet??``,n.crossOrigin=e.crossOrigin??void 0,n.src=t;let r=()=>{this.setState({isZoomImgLoaded:!0})};n.decode().then(r).catch(()=>{if(hb(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(gb(e)){let r=e.cloneNode(!0);Ab(r),r.style.width=`${n.width??0}px`,r.style.height=`${n.height??0}px`,r.addEventListener(`click`,this.handleUnzoom),t.current?.firstChild?.remove(),t.current?.appendChild(r)}}}render(){let{handleBtnUnzoomClick:e,handleDialogClick:t,handleDialogClose:n,handleUnzoom:r,handleZoom:i,imgEl:a,props:{a11yNameButtonUnzoom:o,a11yNameButtonZoom:s,children:c,classDialog:l,IconUnzoom:u,IconZoom:d,isZoomed:f,wrapElement:p,ZoomContent:m,zoomImg:h,zoomMargin:g},refContent:_,refDialog:v,refModalContent:y,refModalImg:b,refWrap:x,state:{id:S,isZoomImgLoaded:C,loadedImgEl:w,modalState:T,shouldRefresh:E,styleGhost:D}}=this,O=`rmiz-modal-${S}`,k=`rmiz-modal-img-${S}`,A=pb(a),j=mb(a),M=gb(a),N=Sb(a),P=xb(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,R=h?.src!==void 0&&h.src!==``,z=this.hasImage(),B=N!==void 0&&N!==``?`${s}: ${N}`:s,V=T===`LOADING`||T===`LOADED`,H=z?`found`:`not-found`,U=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,ee={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=z&&a!==null?Ob({hasZoomImg:R,imgSrc:P,isSvg:M,isZoomed:f&&V,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let te=null;if(z){let t=j||A?K.createElement(`img`,{alt:N,crossOrigin:L,sizes:F,src:P,srcSet:I,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?K.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=K.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},K.createElement(u,null));te=m==null?K.createElement(K.Fragment,null,t,n):K.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return K.createElement(p,{"aria-owns":O,"data-rmiz":``,ref:x},K.createElement(p,{"data-rmiz-content":H,ref:_,style:ee},c),z&&K.createElement(p,{"data-rmiz-ghost":``,style:D},K.createElement(`button`,{"aria-label":B,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},K.createElement(d,null))),z&&Si.createPortal(K.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:Pb,ref:v,role:`dialog`},K.createElement(`div`,{"data-rmiz-modal-overlay":U}),K.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},te)),Nb()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!==`UNLOADED`&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener(`load`,this.handleImgLoad),this.imgEl?.removeEventListener(`click`,this.handleZoom),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),window.removeEventListener(`resize`,this.handleResize),document.removeEventListener(`keydown`,this.handleKeyDown,!0)}componentDidUpdate(e,t){this.handleModalStateChange(t.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(e.isZoomed)}};Ib.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:lb,IconZoom:ub,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function Lb({onZoomChange:e,...t}){let[n,r]=K.useState(!1),i=K.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return K.createElement(Fb,{...t,isZoomed:n,onZoomChange:i})}function Rb(e){return e??`lazy`}function zb(e){let t=(0,J.c)(15),n=e.src,r=e.alt??``,i=e.width,a=e.height,o=e.title,s;t[0]===e.loading?s=t[1]:(s=Rb(e.loading),t[0]=e.loading,t[1]=s);let c;return t[2]!==e.crossorigin||t[3]!==e.decoding||t[4]!==e.fetchpriority||t[5]!==e.height||t[6]!==e.referrerpolicy||t[7]!==e.sizes||t[8]!==e.src||t[9]!==e.srcset||t[10]!==e.title||t[11]!==e.width||t[12]!==r||t[13]!==s?(c=(0,q.jsx)(`img`,{src:n,alt:r,width:i,height:a,title:o,loading:s,srcSet:e.srcset,sizes:e.sizes,decoding:e.decoding,fetchPriority:e.fetchpriority,crossOrigin:e.crossorigin,referrerPolicy:e.referrerpolicy}),t[2]=e.crossorigin,t[3]=e.decoding,t[4]=e.fetchpriority,t[5]=e.height,t[6]=e.referrerpolicy,t[7]=e.sizes,t[8]=e.src,t[9]=e.srcset,t[10]=e.title,t[11]=e.width,t[12]=r,t[13]=s,t[14]=c):c=t[14],c}function Bb(e){let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,q.jsx)(Lb,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,q.jsx)(zb,{...e})}),t[1]=e,t[2]=r),r}function Vb(e){return e!==!1}function Hb(e){let t=(0,J.c)(14),n=e.src,r=e.title,i;t[0]===e.controls?i=t[1]:(i=Vb(e.controls),t[0]=e.controls,t[1]=i);let a;return t[2]!==e.autoplay||t[3]!==e.height||t[4]!==e.loop||t[5]!==e.muted||t[6]!==e.playsinline||t[7]!==e.poster||t[8]!==e.preload||t[9]!==e.src||t[10]!==e.title||t[11]!==e.width||t[12]!==i?(a=(0,q.jsx)(`video`,{className:`ok-video`,src:n,title:r,controls:i,autoPlay:e.autoplay,muted:e.muted,loop:e.loop,playsInline:e.playsinline,poster:e.poster,preload:e.preload,width:e.width,height:e.height}),t[2]=e.autoplay,t[3]=e.height,t[4]=e.loop,t[5]=e.muted,t[6]=e.playsinline,t[7]=e.poster,t[8]=e.preload,t[9]=e.src,t[10]=e.title,t[11]=e.width,t[12]=i,t[13]=a):a=t[13],a}function Ub(e){let t=(0,J.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,q.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var Wb={Callout:cb,img:Bb,video:Hb,audio:rb,Accordion:tb,"*":Ub};function Gb(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var Kb=le(),qb=new Map;function Jb(e){if(e.surface===`compat`){let t=Wb[e.rendersAs];if(!t)throw Error(`Compat descriptor '${e.name}' declares rendersAs: '${e.rendersAs}', but no React component is registered under that name in componentMap. Add the canonical component before registering the compat descriptor.`);return{Component:t,reactNodePropNames:Gb(e.props)}}let t=Wb[e.name];return t?{Component:t,reactNodePropNames:Gb(e.props)}:null}for(let[e,t]of Kb.entries()){let n=Jb(t);n&&qb.set(e,n)}function Yb(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function Xb(e){let t=Kb.getOrWildcard(e),n=qb.get(t.name)??qb.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return Yb(t,n)}function Zb(){let e=[];for(let[t,n]of Kb.entries()){if(t===`*`)continue;let r=qb.get(t);r&&e.push(Yb(n,r))}return e}var Qb={ChevronRight:Bn,Image:Xn,MessageSquareWarning:rr,SquarePlay:lr,Volume2:pr};function $b(e){return e&&Object.hasOwn(Qb,e)?Qb[e]:Rn}var ex=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,tx=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,nx={Callout:{description:`Highlight tips, warnings, and notes.`,props:{type:`note`,title:`Heads up`},children:`Callouts draw attention to key information.`},Accordion:{description:`Collapsible section with a clickable summary.`,props:{title:`Click to expand`,defaultOpen:!0},children:`Hidden content goes here.`},img:{description:`Embed an image with optional alt text.`,props:{src:ex,alt:`Sample image`}},video:{description:`Embed a video with native player controls.`,props:{controls:!0,poster:tx}},audio:{description:`Embed an audio file with native player controls.`,props:{controls:!0}}};function rx(e){let t={};for(let n of e.props)n.type!==`reactnode`&&`defaultValue`in n&&n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function ix(e){let t=Xb(e),n=rx(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var ax=new Set;function ox(e){ax.add(e)}function sx(e){if(typeof e==`number`)return ax.delete(e);let t=ax.values().next();return t.done?!1:(ax.delete(t.value),!0)}function cx(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(ox(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function lx(e){return t=>{let n=new WeakSet;t.state.doc.descendants(t=>{t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&n.add(t)}),t.chain().focus().insertContent(ix(e.name)).run();let r=-1;t.state.doc.descendants((t,i)=>{if(r>=0)return!1;t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&!n.has(t)&&(r=i)}),!(r<0)&&cx(t,r,e)}}function ux(){return Zb().filter(e=>e.surface===`canonical`).map(e=>{let t=nx[e.name],n=e.Component,r=t?{description:t.description,render:()=>(0,q.jsx)(n,{...t.props,children:t.children})}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:$b(e.icon),category:e.category??`content`,command:lx(e),aliases:e.searchTerms,description:e.description,preview:r}})}var dx=new Te(`imageUpload`);function fx(e){let t=document.createElement(`div`);return t.className=`image-upload-skeleton w-full h-40 rounded-md bg-muted animate-pulse motion-reduce:animate-none my-2`,t.setAttribute(`data-upload-widget`,`loading`),t.setAttribute(`role`,`status`),t.setAttribute(`aria-label`,e?.name?`Uploading ${e.name}…`:`Uploading file…`),t}var px=new Fe({key:dx,state:{init(){return{decorations:ge.empty,uploads:new Map}},apply(e,t){let n=t.decorations.map(e.mapping,e.doc),r=new Map;for(let[n,i]of t.uploads)r.set(n,e.mapping.map(i));let i=e.getMeta(dx);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=Ke.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),a=n.add(e.doc,[t]),o=new Map(r);return o.set(i.id,e.mapping.map(i.pos)),{decorations:a,uploads:o}}if(i.type===`remove`){let e=n.find(void 0,void 0,e=>e.id===i.id),t=n.remove(e),a=new Map(r);return a.delete(i.id),{decorations:t,uploads:a}}return{decorations:n,uploads:r}}},props:{decorations(e){return dx.getState(e)?.decorations??ge.empty}}});function mx(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function hx(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function gx(e){return e.split(`/`).filter(e=>e!==``)}function _x(e,t){let n=mx(e),r=mx(t),i=hx(e);if(n===r)return i;let a=gx(r),o=gx(n),s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s++;let c=a.length-s,l=o.slice(s);return c===0?`./${[...l,i].join(`/`)}`:[...Array(c).fill(`..`),...l,i].join(`/`)}function vx(e){return Ky(e)}function yx(e,t){return{type:`jsxComponent`,attrs:{componentName:e===`jsx-img`?`img`:e===`jsx-video`?`video`:`audio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:e===`jsx-img`?{src:t,alt:``}:{src:t,controls:!0}}}}function bx(e){let t=me(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:k.has(t)?{kind:`jsx-img`,ext:t}:ee.has(t)?{kind:`jsx-video`,ext:t}:qe.has(t)?{kind:`jsx-audio`,ext:t}:C.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function xx(e,t,n){let r=vx(t),i=r?`${r}.md`:``;if(!i){Lt.error(`Cannot upload: no document is open`);return}let a=crypto.randomUUID(),o=fx(e);t.view.dispatch(t.state.tr.setMeta(dx,{type:`add`,id:a,pos:n,widget:o}));let s=new FormData;s.append(`file`,e),s.append(`parentDocName`,i);let c;try{c=await fetch(`/api/upload`,{method:`POST`,body:s})}catch(e){console.error(`[uploadAndInsert] Network error:`,e),Sx(t,a);return}let l={};try{l=await c.json()}catch{}if(!c.ok){let e=l.message??l.error??`Upload failed (${c.status})`;console.error(`[uploadAndInsert] Server error:`,e),Sx(t,a,e);return}if(typeof l.src!=`string`){console.error(`[uploadAndInsert] Response missing src:`,l),Sx(t,a);return}let u=l.src,d=l.deduped===!0,f=mx(i),p=typeof l.path==`string`&&l.path.length>0?l.path:f?`${f}/${u}`:u;d&&Lt.info(`Already at ${p} — reusing.`);let m=bx(e.name),{state:h}=t,g=dx.getState(h)?.uploads.get(a)??n,_=h.tr.setMeta(dx,{type:`remove`,id:a}),v=_x(p,i),y=`/${p}`;if(m.kind===`jsx-img`||m.kind===`jsx-video`||m.kind===`jsx-audio`){if(!h.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),Sx(t,a);return}let e=yx(m.kind,y),n=e.attrs.componentName;t.chain().command(({tr:e})=>(e.setMeta(dx,{type:`remove`,id:a}),!0)).focus().insertContentAt(g,e).run(),cx(t,g,Xb(n));return}if(m.kind===`wikiembed`){let e=h.schema.nodes.wikiLinkEmbed;if(!e){console.error(`[uploadAndInsert] wikiLinkEmbed node missing from schema`),Sx(t,a);return}_.insert(g,e.create({target:u,alias:null,anchor:null,resolvedSrc:y}))}else if(m.kind===`wiki-link`){let n=h.schema.nodes.wikiLink;if(!n){console.error(`[uploadAndInsert] wikiLink node missing from schema`),Sx(t,a);return}let r=Xy(e.name.replace(/\.(md|mdx)$/i,``));r?_.insert(g,n.create(r)):_.insert(g,h.schema.text(e.name))}else{let t=h.schema.marks.link;if(t){let n=h.schema.text(e.name,[t.create({href:v})]);_.insert(g,n)}else _.insert(g,h.schema.text(e.name))}t.view.dispatch(_)}function Sx(e,t,n){e.view.dispatch(e.state.tr.setMeta(dx,{type:`remove`,id:t})),Lt.error(n??`Upload failed`)}var Cx=[{name:`heading1`,label:`Heading 1`,icon:qn,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:1}).run(),aliases:[`h1`],preview:{description:`Big section heading.`,render:()=>(0,q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Heading 1`})}},{name:`heading2`,label:`Heading 2`,icon:Jn,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:2}).run(),aliases:[`h2`],preview:{description:`Medium section heading.`,render:()=>(0,q.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Heading 2`})}},{name:`heading3`,label:`Heading 3`,icon:Yn,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:3}).run(),aliases:[`h3`],preview:{description:`Small section heading.`,render:()=>(0,q.jsx)(`h3`,{className:`text-base font-semibold tracking-tight`,children:`Heading 3`})}},{name:`bulletList`,label:`Bullet List`,icon:tr,category:`basic`,command:e=>e.chain().focus().toggleBulletList().run(),aliases:[`ul`,`unordered`],preview:{description:`Unordered list of items.`,render:()=>(0,q.jsxs)(`ul`,{className:`list-disc pl-5 text-sm leading-7`,children:[(0,q.jsx)(`li`,{children:`First item`}),(0,q.jsx)(`li`,{children:`Second item`})]})}},{name:`orderedList`,label:`Ordered List`,icon:$n,category:`basic`,command:e=>e.chain().focus().toggleOrderedList().run(),aliases:[`ol`,`numbered`],preview:{description:`Numbered list of items.`,render:()=>(0,q.jsxs)(`ol`,{className:`list-decimal pl-5 text-sm leading-7`,children:[(0,q.jsx)(`li`,{children:`First item`}),(0,q.jsx)(`li`,{children:`Second item`})]})}},{name:`taskList`,label:`Task List`,icon:er,category:`basic`,command:e=>e.chain().focus().toggleTaskList().run(),aliases:[`todo`,`checklist`,`checkbox`],preview:{description:`Checklist with checkboxes.`,render:()=>(0,q.jsxs)(`ul`,{className:`space-y-1.5 text-sm`,children:[(0,q.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:!0,readOnly:!0,className:`size-3.5`}),(0,q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:`Done`})]}),(0,q.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,readOnly:!0,className:`size-3.5`}),(0,q.jsx)(`span`,{children:`To do`})]})]})}},{name:`blockquote`,label:`Quote`,icon:sr,category:`basic`,command:e=>e.chain().focus().toggleBlockquote().run(),aliases:[`quote`],preview:{description:`Indented blockquote for citations.`,render:()=>(0,q.jsx)(`blockquote`,{className:`border-l-2 border-muted-foreground/40 pl-3 text-sm italic text-muted-foreground`,children:`A pull quote stands out from the surrounding text.`})}},{name:`codeBlock`,label:`Code Block`,icon:Hn,category:`basic`,command:e=>e.chain().focus().toggleCodeBlock().run(),aliases:[`code`,`fence`],preview:{description:`Fenced code block with monospace text.`,render:()=>(0,q.jsx)(`pre`,{className:`rounded-md bg-muted px-2.5 py-2 font-mono text-xs leading-5`,children:(0,q.jsx)(`code`,{children:`const greeting = "Hello";
|