@inkeep/open-knowledge 0.0.0-dev-20260422210111 → 0.0.0-dev-20260422220204

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/cli.mjs +5 -5
  2. package/dist/constants-CHT12XZp.mjs +2 -0
  3. package/dist/index.mjs +1 -1
  4. package/dist/init-CXaRylVg.mjs +1 -0
  5. package/dist/{init-CnpwEFdK.mjs → init-ChedNIKj.mjs} +3 -3
  6. package/dist/init-D7kYDEjN.mjs +1 -0
  7. package/dist/{init-B8Xnbhhn.mjs → init-DwqNi94-.mjs} +2 -2
  8. package/dist/loader-1WxP37M7.mjs +1 -0
  9. package/dist/{loader-CrnVpSji.mjs → loader-DO1AY7O1.mjs} +2 -2
  10. package/dist/paths-B2A9ndTW.mjs +1 -0
  11. package/dist/paths-BI8i0L8y.mjs +2 -0
  12. package/dist/preview-CF_VU9En.mjs +1 -0
  13. package/dist/{preview-uvtKxu1o.mjs → preview-ktbHbdeY.mjs} +2 -2
  14. package/dist/public/assets/{GraphPanel-CtPBcypT.js → GraphPanel-DW_Dc6tS.js} +2 -2
  15. package/dist/public/assets/{SourceEditor-3D1gs8jR.js → SourceEditor-BKyWQ7mW.js} +3 -3
  16. package/dist/public/assets/{clipboard-DLkbuX0Y.js → clipboard-CdKkyvy1.js} +8 -8
  17. package/dist/public/assets/{dist-BixLmXN7.js → dist-B2YW_ZWG.js} +1 -1
  18. package/dist/public/assets/{dist-DKlym6RD.js → dist-Bx72hMUu.js} +1 -1
  19. package/dist/public/assets/{dist-DZ-UOMpP.js → dist-CQbn9Fxc.js} +1 -1
  20. package/dist/public/assets/{dist-BL9mEocg.js → dist-DVEMi7bH.js} +1 -1
  21. package/dist/public/assets/{dist-BoNTyP8X.js → dist-Dm75HY2n.js} +1 -1
  22. package/dist/public/assets/{dist-C2luWP3Z.js → dist-X189qk_S.js} +1 -1
  23. package/dist/public/assets/{dist-BRU9Z8nb.js → dist-k7VFO_3K.js} +1 -1
  24. package/dist/public/assets/index-C80QVNFN.js +21 -0
  25. package/dist/public/assets/index-CPyMCk-k.css +1 -0
  26. package/dist/public/assets/{panel-C8Asv8L6.js → panel-DTlG8EiB.js} +1 -1
  27. package/dist/public/assets/toggle-group-kvG9skOM.js +1 -0
  28. package/dist/public/index.html +8 -8
  29. package/dist/src-6Cuk2tbm.mjs +1 -0
  30. package/dist/src-BmCYyMng.mjs +91 -0
  31. package/dist/src-C6-SC_kR.mjs +1 -0
  32. package/dist/{src-CdcLi3q2.mjs → src-CQw-HNNM.mjs} +2 -2
  33. package/dist/{start-DeV2jvfm.mjs → start-BFzbVJbr.mjs} +2 -2
  34. package/dist/start-iA5xm-Va.mjs +1 -0
  35. package/package.json +1 -1
  36. package/dist/constants-CiZgq6zT.mjs +0 -2
  37. package/dist/init-C1HljSB5.mjs +0 -1
  38. package/dist/init-DhXIUBvg.mjs +0 -1
  39. package/dist/loader-OQS9ACNm.mjs +0 -1
  40. package/dist/paths-B5Xymv2W.mjs +0 -2
  41. package/dist/paths-CUf-odRI.mjs +0 -1
  42. package/dist/preview-B22xjLsP.mjs +0 -1
  43. package/dist/public/assets/index-CpGPsUWx.css +0 -1
  44. package/dist/public/assets/index-QecScGij.js +0 -21
  45. package/dist/public/assets/toggle-group-DWj1iQFr.js +0 -1
  46. package/dist/src-DAd92e3U.mjs +0 -1
  47. package/dist/src-DSnJWc-y.mjs +0 -1
  48. package/dist/src-DkmdJZsK.mjs +0 -91
  49. package/dist/start-B9GVxmFS.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{$t as e,A as t,At as n,B as r,Bt as i,Ct as a,D as o,Dt as s,E as c,Et as l,F as u,Ft as d,Gt as f,Hn as p,I as m,It as h,Jt as g,K as _,M as v,Mt as y,N as b,Nt as x,O as S,Ot as C,P as w,Pt as T,Qt as E,St as D,T as O,Tt as k,U as A,V as j,Vt as M,Wn as N,X as P,Xt as F,Yt as I,Z as L,Zt as R,_ as z,_n as ee,_t as B,a as V,at as te,bn as ne,bt as re,ct as H,dt as ie,f as ae,fn as U,ft as oe,g as se,h as ce,i as le,in as ue,it as de,j as fe,jt as pe,k as me,kt as he,l as ge,lt as _e,mn as ve,mt as ye,n as be,nn as xe,o as Se,ot as Ce,p as we,pn as Te,pt as Ee,qt as De,r as Oe,rn as ke,s as Ae,sn as je,t as Me,tn as Ne,u as Pe,un as Fe,ut as Ie,v as Le,vt as Re,w as ze,wt as Be,xn as Ve,y as He,yn as Ue,z as We,zt as Ge}from"./panel-C8Asv8L6.js";import{$ as Ke,A as qe,B as Je,Bt as Ye,Ct as Xe,D as Ze,Dt as Qe,E as $e,Et as et,Ft as tt,G as nt,H as rt,Ht as it,I as at,It as ot,J as st,K as ct,L as W,Lt as lt,M as ut,N as dt,Nt as ft,P as pt,Pt as mt,Q as ht,Rt as gt,S as _t,St as vt,T as yt,Tt as G,U as bt,V as xt,Vt as St,W as Ct,Y as wt,Z as Tt,_ as Et,a as Dt,at as Ot,b as kt,bt as At,c as jt,ct as Mt,d as Nt,et as Pt,f as Ft,g as It,gt as Lt,h as Rt,ht as zt,i as Bt,j as Vt,jt as Ht,k as Ut,kt as Wt,l as Gt,lt as Kt,mt as qt,n as Jt,nt as Yt,o as Xt,ot as Zt,p as Qt,pt as $t,q as en,r as tn,s as nn,st as rn,t as an,tt as on,u as sn,ut as cn,v as ln,vt as un,w as dn,x as fn,xt as pn,y as mn,z as hn,zt as gn}from"./dist-BixLmXN7.js";import{a as _n,c as vn,i as yn,n as bn,o as xn,r as Sn,s as Cn,t as wn}from"./dist-BRU9Z8nb.js";import{i as Tn,n as En,r as Dn,t as On}from"./dist-DZ-UOMpP.js";var kn=U(`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`}]]),An=U(`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`}]]),jn=U(`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`}]]),Mn=U(`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`}]]),Nn=U(`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`}]]),Pn=U(`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`}]]),Fn=U(`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`}]]),In=U(`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`}]]),Ln=U(`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`}]]),Rn=U(`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=U(`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`}]]),Bn=U(`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`}]]),Vn=U(`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`}]]),Hn=U(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Un=U(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Wn=U(`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`}]]),Gn=U(`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`}]]),Kn=U(`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`}]]),qn=U(`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`}]]),Jn=U(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),K=ne(),Yn=Te(),q=N(Ve(),1),Xn=N(ve(),1);function Zn(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var Qn=e=>{switch(e){case`success`:return tr;case`info`:return rr;case`warning`:return nr;case`error`:return ir;default:return null}},$n=Array(12).fill(0),er=({visible:e,className:t})=>q.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},q.createElement(`div`,{className:`sonner-spinner`},$n.map((e,t)=>q.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),tr=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},q.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),nr=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},q.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),rr=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},q.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),ir=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},q.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),ar=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},q.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),q.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),or=()=>{let[e,t]=q.useState(document.hidden);return q.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},sr=1,cr=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:sr++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],q.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(ur(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||sr++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},lr=(e,t)=>{let n=t?.id||sr++;return cr.addToast({title:e,...t,id:n}),n},ur=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,dr=Object.assign(lr,{success:cr.success,info:cr.info,warning:cr.warning,error:cr.error,custom:cr.custom,message:cr.message,promise:cr.promise,dismiss:cr.dismiss,loading:cr.loading},{getHistory:()=>cr.toasts,getToasts:()=>cr.getActiveToasts()});Zn(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function fr(e){return e.label!==void 0}var pr=3,mr=`24px`,hr=`16px`,gr=4e3,_r=356,vr=14,yr=45,br=200;function xr(...e){return e.filter(Boolean).join(` `)}function Sr(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var Cr=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=q.useState(null),[O,k]=q.useState(null),[A,j]=q.useState(!1),[M,N]=q.useState(!1),[P,F]=q.useState(!1),[I,L]=q.useState(!1),[R,z]=q.useState(!1),[ee,B]=q.useState(0),[V,te]=q.useState(0),ne=q.useRef(n.duration||y||gr),re=q.useRef(null),H=q.useRef(null),ie=c===0,ae=c+1<=o,U=n.type,oe=n.dismissible!==!1,se=n.className||``,ce=n.descriptionClassName||``,le=q.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),ue=q.useMemo(()=>n.closeButton??p,[n.closeButton,p]),de=q.useMemo(()=>n.duration||y||gr,[n.duration,y]),fe=q.useRef(0),pe=q.useRef(0),me=q.useRef(0),he=q.useRef(null),[ge,_e]=b.split(`-`),ve=q.useMemo(()=>s.reduce((e,t,n)=>n>=le?e:e+t.height,0),[s,le]),ye=or(),be=n.invert||t,xe=U===`loading`;pe.current=q.useMemo(()=>le*x+ve,[le,ve]),q.useEffect(()=>{ne.current=de},[de]),q.useEffect(()=>{j(!0)},[]),q.useEffect(()=>{let e=H.current;if(e){let t=e.getBoundingClientRect().height;return te(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),q.useLayoutEffect(()=>{if(!A)return;let e=H.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,te(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let Se=q.useCallback(()=>{N(!0),B(pe.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},br)},[n,d,a,pe]);q.useEffect(()=>{if(n.promise&&U===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||ye?(()=>{if(me.current<fe.current){let e=new Date().getTime()-fe.current;ne.current-=e}me.current=new Date().getTime()})():ne.current!==1/0&&(fe.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),Se()},ne.current)),()=>clearTimeout(e)},[u,i,n,U,ye,Se]),q.useEffect(()=>{n.delete&&(Se(),n.onDismiss==null||n.onDismiss.call(n,n))},[Se,n.delete]);function Ce(){return w?.loading?q.createElement(`div`,{className:xr(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":U===`loading`},w.loading):q.createElement(er,{className:xr(C?.loader,n?.classNames?.loader),visible:U===`loading`})}let we=n.icon||w?.[U]||Qn(U);return q.createElement(`li`,{tabIndex:0,ref:H,className:xr(_,se,C?.toast,n?.classNames?.toast,C?.default,C?.[U],n?.classNames?.[U]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":R,"data-removed":M,"data-visible":ae,"data-y-position":ge,"data-x-position":_e,"data-index":c,"data-front":ie,"data-swiping":P,"data-dismissible":oe,"data-type":U,"data-invert":be,"data-swipe-out":I,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?ee:pe.current}px`,"--initial-height":S?`auto`:`${V}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),he.current=null},onPointerDown:e=>{e.button!==2&&(xe||!oe||(re.current=new Date,B(pe.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),he.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(I||!oe)return;he.current=null;let e=Number(H.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(H.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-re.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=yr||a>.11){B(pe.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),Se(),L(!0);return}else{var o,s;(o=H.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=H.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}z(!1),F(!1),D(null)},onPointerMove:t=>{var n,r;if(!he.current||!oe||window.getSelection()?.toString().length>0)return;let i=t.clientY-he.current.y,a=t.clientX-he.current.x,o=e.swipeDirections??Sr(b);!E&&(Math.abs(a)>1||Math.abs(i)>1)&&D(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(E===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&z(!0),(n=H.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=H.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},ue&&!n.jsx&&U!==`loading`?q.createElement(`button`,{"aria-label":T,"data-disabled":xe,"data-close-button":!0,onClick:xe||!oe?()=>{}:()=>{Se(),n.onDismiss==null||n.onDismiss.call(n,n)},className:xr(C?.closeButton,n?.classNames?.closeButton)},w?.close??ar):null,(U||n.icon||n.promise)&&n.icon!==null&&(w?.[U]!==null||n.icon)?q.createElement(`div`,{"data-icon":``,className:xr(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Ce():null,n.type===`loading`?null:we):null,q.createElement(`div`,{"data-content":``,className:xr(C?.content,n?.classNames?.content)},q.createElement(`div`,{"data-title":``,className:xr(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?q.createElement(`div`,{"data-description":``,className:xr(v,ce,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),q.isValidElement(n.cancel)?n.cancel:n.cancel&&fr(n.cancel)?q.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{fr(n.cancel)&&oe&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),Se())},className:xr(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,q.isValidElement(n.action)?n.action:n.action&&fr(n.action)?q.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{fr(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&Se())},className:xr(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function wr(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function Tr(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?hr:mr;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var Er=q.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=pr,toastOptions:g,dir:_=wr(),gap:v=vr,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=q.useState([]),C=q.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),w=q.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[T,E]=q.useState([]),[D,O]=q.useState(!1),[k,A]=q.useState(!1),[j,M]=q.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),N=q.useRef(null),P=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),F=q.useRef(null),I=q.useRef(!1),L=q.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||cr.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return q.useEffect(()=>cr.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{Xn.flushSync(()=>{S(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[x]),q.useEffect(()=>{if(d!==`system`){M(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?M(`dark`):M(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{M(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{M(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),q.useEffect(()=>{x.length<=1&&O(!1)},[x]),q.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;O(!0),(t=N.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===N.current||N.current?.contains(document.activeElement))&&O(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),q.useEffect(()=>{if(N.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,I.current=!1)}},[N.current]),q.createElement(`section`,{ref:t,"aria-label":`${b} ${P}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,n)=>{let[i,a]=t.split(`-`);return C.length?q.createElement(`ol`,{key:t,dir:_===`auto`?wr():_,tabIndex:-1,ref:N,className:c,"data-sonner-toaster":!0,"data-sonner-theme":j,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`${_r}px`,"--gap":`${v}px`,...m,...Tr(l,u)},onBlur:e=>{I.current&&!e.currentTarget.contains(e.relatedTarget)&&(I.current=!1,F.current&&=(F.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||I.current||(I.current=!0,F.current=e.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{k||O(!1)},onDragEnd:()=>O(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||A(!0)},onPointerUp:()=>A(!1)},C.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>q.createElement(Cr,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:k,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:L,toasts:C.filter(e=>e.position==n.position),heights:T.filter(e=>e.position==n.position),setHeights:E,expandByDefault:o,gap:v,expanded:D,swipeDirections:e.swipeDirections}))):null}))}),Dr=`focusScope.autoFocusOnMount`,Or=`focusScope.autoFocusOnUnmount`,kr={bubbles:!1,cancelable:!0},Ar=`FocusScope`,jr=q.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=q.useState(null),l=F(i),u=F(a),d=q.useRef(null),f=Fe(t,e=>c(e)),p=q.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;q.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Rr(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Rr(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Rr(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),q.useEffect(()=>{if(s){zr.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Dr,kr);s.addEventListener(Dr,l),s.dispatchEvent(t),t.defaultPrevented||(Mr(Hr(Pr(s)),{select:!0}),document.activeElement===e&&Rr(s))}return()=>{s.removeEventListener(Dr,l),setTimeout(()=>{let t=new CustomEvent(Or,kr);s.addEventListener(Or,u),s.dispatchEvent(t),t.defaultPrevented||Rr(e??document.body,{select:!0}),s.removeEventListener(Or,u),zr.remove(p)},0)}}},[s,l,u,p]);let m=q.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Nr(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Rr(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Rr(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,K.jsx)(ue.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});jr.displayName=Ar;function Mr(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Rr(r,{select:t}),document.activeElement!==n)return}function Nr(e){let t=Pr(e);return[Fr(t,e),Fr(t.reverse(),e)]}function Pr(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Fr(e,t){for(let n of e)if(!Ir(n,{upTo:t}))return n}function Ir(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Lr(e){return e instanceof HTMLInputElement&&`select`in e}function Rr(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Lr(e)&&t&&e.select()}}var zr=Br();function Br(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Vr(e,t),e.unshift(t)},remove(t){e=Vr(e,t),e[0]?.resume()}}}function Vr(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Hr(e){return e.filter(e=>e.tagName!==`A`)}var Ur=0;function Wr(){q.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Gr()),document.body.insertAdjacentElement(`beforeend`,e[1]??Gr()),Ur++,()=>{Ur===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Ur--}},[])}function Gr(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Kr=function(){return Kr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Kr.apply(this,arguments)};function qr(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Jr(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Yr=`right-scroll-bar-position`,Xr=`width-before-scroll-bar`,Zr=`with-scroll-bars-hidden`,Qr=`--removed-body-scroll-bar-size`;function $r(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function ei(e,t){var n=(0,q.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var ti=typeof window<`u`?q.useLayoutEffect:q.useEffect,ni=new WeakMap;function ri(e,t){var n=ei(t||null,function(t){return e.forEach(function(e){return $r(e,t)})});return ti(function(){var t=ni.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||$r(e,null)}),i.forEach(function(e){r.has(e)||$r(e,a)})}ni.set(n,e)},[e]),n}function ii(e){return e}function ai(e,t){t===void 0&&(t=ii);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function oi(e){e===void 0&&(e={});var t=ai(null);return t.options=Kr({async:!0,ssr:!1},e),t}var si=function(e){var t=e.sideCar,n=qr(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return q.createElement(r,Kr({},n))};si.isSideCarExport=!0;function ci(e,t){return e.useMedium(t),si}var li=oi(),ui=function(){},di=q.forwardRef(function(e,t){var n=q.useRef(null),r=q.useState({onScrollCapture:ui,onWheelCapture:ui,onTouchMoveCapture:ui}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=qr(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=ri([n,t]),C=Kr(Kr({},b),i);return q.createElement(q.Fragment,null,u&&q.createElement(x,{sideCar:li,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?q.cloneElement(q.Children.only(s),Kr(Kr({},C),{ref:S})):q.createElement(v,Kr({},C,{className:c,ref:S}),s))});di.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},di.classNames={fullWidth:Xr,zeroRight:Yr};var fi,pi=function(){if(fi)return fi;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function mi(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=pi();return t&&e.setAttribute(`nonce`,t),e}function hi(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function gi(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var _i=function(){var e=0,t=null;return{add:function(n){e==0&&(t=mi())&&(hi(t,n),gi(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},vi=function(){var e=_i();return function(t,n){q.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},yi=function(){var e=vi();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},bi={left:0,top:0,right:0,gap:0},xi=function(e){return parseInt(e||``,10)||0},Si=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[xi(n),xi(r),xi(i)]},Ci=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return bi;var t=Si(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},wi=yi(),Ti=`data-scroll-locked`,Ei=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
1
+ import{$ as e,$t as t,A as n,At as r,Cn as i,D as a,Dt as o,E as s,Et as c,F as l,Ft as u,G as d,H as f,Ht as p,I as m,It as h,J as g,Kn as _,L as v,Lt as y,M as b,Mt as x,N as S,Nt as C,O as w,Ot as T,P as E,Pt as D,Q as O,Qt as k,R as A,Rt as j,Sn as M,St as N,Tt as P,U as F,Ut as I,V as L,Vt as R,Wn as z,Xt as B,Yt as V,Zt as H,_ as ee,a as te,an as ne,bt as re,ct as ie,dt as ae,en as U,f as oe,fn as se,ft as ce,g as le,gn as ue,gt as de,h as fe,hn as pe,ht as me,i as he,in as ge,j as _e,jt as ve,k as ye,kt as be,l as xe,ln as Se,mn as Ce,mt as we,n as Te,o as Ee,on as De,ot as Oe,p as ke,pt as Ae,qt as je,r as Me,rn as Ne,s as Pe,st as Fe,t as Ie,tn as Le,u as Re,ut as ze,v as Be,wt as Ve,xn as He,y as Ue,yn as We,yt as Ge}from"./panel-DTlG8EiB.js";import{$ as Ke,A as qe,B as Je,Bt as Ye,Ct as Xe,D as Ze,Dt as Qe,E as $e,Et as et,Ft as tt,G as nt,H as rt,Ht as it,I as at,It as ot,J as st,K as ct,L as W,Lt as lt,M as ut,N as dt,Nt as ft,P as pt,Pt as mt,Q as ht,Rt as gt,S as _t,St as vt,T as yt,Tt as G,U as bt,V as xt,Vt as St,W as Ct,Y as wt,Z as Tt,_ as Et,a as Dt,at as Ot,b as kt,bt as At,c as jt,ct as Mt,d as Nt,et as Pt,f as Ft,g as It,gt as Lt,h as Rt,ht as zt,i as Bt,j as Vt,jt as Ht,k as Ut,kt as Wt,l as Gt,lt as Kt,mt as qt,n as Jt,nt as Yt,o as Xt,ot as Zt,p as Qt,pt as $t,q as en,r as tn,s as nn,st as rn,t as an,tt as on,u as sn,ut as cn,v as ln,vt as un,w as dn,x as fn,xt as pn,y as mn,z as hn,zt as gn}from"./dist-B2YW_ZWG.js";import{a as _n,c as vn,i as yn,n as bn,o as xn,r as Sn,s as Cn,t as wn}from"./dist-k7VFO_3K.js";import{i as Tn,n as En,r as Dn,t as On}from"./dist-CQbn9Fxc.js";var kn=Ce(`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`}]]),An=Ce(`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`}]]),jn=Ce(`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`}]]),Mn=Ce(`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`}]]),Nn=Ce(`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`}]]),Pn=Ce(`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`}]]),Fn=Ce(`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`}]]),In=Ce(`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`}]]),Ln=Ce(`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`}]]),Rn=Ce(`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=Ce(`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`}]]),Bn=Ce(`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`}]]),Vn=Ce(`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`}]]),Hn=Ce(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Un=Ce(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Wn=Ce(`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`}]]),Gn=Ce(`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`}]]),Kn=Ce(`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`}]]),qn=Ce(`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`}]]),Jn=Ce(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),K=M(),Yn=pe(),q=_(i(),1),Xn=_(ue(),1);function Zn(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var Qn=e=>{switch(e){case`success`:return tr;case`info`:return rr;case`warning`:return nr;case`error`:return ir;default:return null}},$n=Array(12).fill(0),er=({visible:e,className:t})=>q.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},q.createElement(`div`,{className:`sonner-spinner`},$n.map((e,t)=>q.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),tr=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},q.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),nr=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},q.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),rr=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},q.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),ir=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},q.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),ar=q.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},q.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),q.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),or=()=>{let[e,t]=q.useState(document.hidden);return q.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},sr=1,cr=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:sr++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],q.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(ur(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!q.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||sr++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},lr=(e,t)=>{let n=t?.id||sr++;return cr.addToast({title:e,...t,id:n}),n},ur=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,dr=Object.assign(lr,{success:cr.success,info:cr.info,warning:cr.warning,error:cr.error,custom:cr.custom,message:cr.message,promise:cr.promise,dismiss:cr.dismiss,loading:cr.loading},{getHistory:()=>cr.toasts,getToasts:()=>cr.getActiveToasts()});Zn(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function fr(e){return e.label!==void 0}var pr=3,mr=`24px`,hr=`16px`,gr=4e3,_r=356,vr=14,yr=45,br=200;function xr(...e){return e.filter(Boolean).join(` `)}function Sr(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var Cr=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=q.useState(null),[O,k]=q.useState(null),[A,j]=q.useState(!1),[M,N]=q.useState(!1),[P,F]=q.useState(!1),[I,L]=q.useState(!1),[R,z]=q.useState(!1),[B,V]=q.useState(0),[H,ee]=q.useState(0),te=q.useRef(n.duration||y||gr),ne=q.useRef(null),re=q.useRef(null),ie=c===0,ae=c+1<=o,U=n.type,oe=n.dismissible!==!1,se=n.className||``,ce=n.descriptionClassName||``,le=q.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),ue=q.useMemo(()=>n.closeButton??p,[n.closeButton,p]),de=q.useMemo(()=>n.duration||y||gr,[n.duration,y]),fe=q.useRef(0),pe=q.useRef(0),me=q.useRef(0),he=q.useRef(null),[ge,_e]=b.split(`-`),ve=q.useMemo(()=>s.reduce((e,t,n)=>n>=le?e:e+t.height,0),[s,le]),ye=or(),be=n.invert||t,xe=U===`loading`;pe.current=q.useMemo(()=>le*x+ve,[le,ve]),q.useEffect(()=>{te.current=de},[de]),q.useEffect(()=>{j(!0)},[]),q.useEffect(()=>{let e=re.current;if(e){let t=e.getBoundingClientRect().height;return ee(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),q.useLayoutEffect(()=>{if(!A)return;let e=re.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ee(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let Se=q.useCallback(()=>{N(!0),V(pe.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},br)},[n,d,a,pe]);q.useEffect(()=>{if(n.promise&&U===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||ye?(()=>{if(me.current<fe.current){let e=new Date().getTime()-fe.current;te.current-=e}me.current=new Date().getTime()})():te.current!==1/0&&(fe.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),Se()},te.current)),()=>clearTimeout(e)},[u,i,n,U,ye,Se]),q.useEffect(()=>{n.delete&&(Se(),n.onDismiss==null||n.onDismiss.call(n,n))},[Se,n.delete]);function Ce(){return w?.loading?q.createElement(`div`,{className:xr(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":U===`loading`},w.loading):q.createElement(er,{className:xr(C?.loader,n?.classNames?.loader),visible:U===`loading`})}let we=n.icon||w?.[U]||Qn(U);return q.createElement(`li`,{tabIndex:0,ref:re,className:xr(_,se,C?.toast,n?.classNames?.toast,C?.default,C?.[U],n?.classNames?.[U]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":R,"data-removed":M,"data-visible":ae,"data-y-position":ge,"data-x-position":_e,"data-index":c,"data-front":ie,"data-swiping":P,"data-dismissible":oe,"data-type":U,"data-invert":be,"data-swipe-out":I,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?B:pe.current}px`,"--initial-height":S?`auto`:`${H}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),he.current=null},onPointerDown:e=>{e.button!==2&&(xe||!oe||(ne.current=new Date,V(pe.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),he.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(I||!oe)return;he.current=null;let e=Number(re.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(re.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-ne.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=yr||a>.11){V(pe.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),Se(),L(!0);return}else{var o,s;(o=re.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=re.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}z(!1),F(!1),D(null)},onPointerMove:t=>{var n,r;if(!he.current||!oe||window.getSelection()?.toString().length>0)return;let i=t.clientY-he.current.y,a=t.clientX-he.current.x,o=e.swipeDirections??Sr(b);!E&&(Math.abs(a)>1||Math.abs(i)>1)&&D(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(E===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&z(!0),(n=re.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=re.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},ue&&!n.jsx&&U!==`loading`?q.createElement(`button`,{"aria-label":T,"data-disabled":xe,"data-close-button":!0,onClick:xe||!oe?()=>{}:()=>{Se(),n.onDismiss==null||n.onDismiss.call(n,n)},className:xr(C?.closeButton,n?.classNames?.closeButton)},w?.close??ar):null,(U||n.icon||n.promise)&&n.icon!==null&&(w?.[U]!==null||n.icon)?q.createElement(`div`,{"data-icon":``,className:xr(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Ce():null,n.type===`loading`?null:we):null,q.createElement(`div`,{"data-content":``,className:xr(C?.content,n?.classNames?.content)},q.createElement(`div`,{"data-title":``,className:xr(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?q.createElement(`div`,{"data-description":``,className:xr(v,ce,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),q.isValidElement(n.cancel)?n.cancel:n.cancel&&fr(n.cancel)?q.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{fr(n.cancel)&&oe&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),Se())},className:xr(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,q.isValidElement(n.action)?n.action:n.action&&fr(n.action)?q.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{fr(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&Se())},className:xr(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function wr(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function Tr(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?hr:mr;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var Er=q.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=pr,toastOptions:g,dir:_=wr(),gap:v=vr,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=q.useState([]),C=q.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),w=q.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[T,E]=q.useState([]),[D,O]=q.useState(!1),[k,A]=q.useState(!1),[j,M]=q.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),N=q.useRef(null),P=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),F=q.useRef(null),I=q.useRef(!1),L=q.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||cr.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return q.useEffect(()=>cr.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{Xn.flushSync(()=>{S(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[x]),q.useEffect(()=>{if(d!==`system`){M(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?M(`dark`):M(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{M(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{M(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),q.useEffect(()=>{x.length<=1&&O(!1)},[x]),q.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;O(!0),(t=N.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===N.current||N.current?.contains(document.activeElement))&&O(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),q.useEffect(()=>{if(N.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,I.current=!1)}},[N.current]),q.createElement(`section`,{ref:t,"aria-label":`${b} ${P}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,n)=>{let[i,a]=t.split(`-`);return C.length?q.createElement(`ol`,{key:t,dir:_===`auto`?wr():_,tabIndex:-1,ref:N,className:c,"data-sonner-toaster":!0,"data-sonner-theme":j,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`${_r}px`,"--gap":`${v}px`,...m,...Tr(l,u)},onBlur:e=>{I.current&&!e.currentTarget.contains(e.relatedTarget)&&(I.current=!1,F.current&&=(F.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||I.current||(I.current=!0,F.current=e.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{k||O(!1)},onDragEnd:()=>O(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||A(!0)},onPointerUp:()=>A(!1)},C.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>q.createElement(Cr,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:k,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:L,toasts:C.filter(e=>e.position==n.position),heights:T.filter(e=>e.position==n.position),setHeights:E,expandByDefault:o,gap:v,expanded:D,swipeDirections:e.swipeDirections}))):null}))}),Dr=`focusScope.autoFocusOnMount`,Or=`focusScope.autoFocusOnUnmount`,kr={bubbles:!1,cancelable:!0},Ar=`FocusScope`,jr=q.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=q.useState(null),l=k(i),u=k(a),d=q.useRef(null),f=se(t,e=>c(e)),p=q.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;q.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Rr(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Rr(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Rr(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),q.useEffect(()=>{if(s){zr.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Dr,kr);s.addEventListener(Dr,l),s.dispatchEvent(t),t.defaultPrevented||(Mr(Hr(Pr(s)),{select:!0}),document.activeElement===e&&Rr(s))}return()=>{s.removeEventListener(Dr,l),setTimeout(()=>{let t=new CustomEvent(Or,kr);s.addEventListener(Or,u),s.dispatchEvent(t),t.defaultPrevented||Rr(e??document.body,{select:!0}),s.removeEventListener(Or,u),zr.remove(p)},0)}}},[s,l,u,p]);let m=q.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Nr(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Rr(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Rr(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,K.jsx)(De.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});jr.displayName=Ar;function Mr(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Rr(r,{select:t}),document.activeElement!==n)return}function Nr(e){let t=Pr(e);return[Fr(t,e),Fr(t.reverse(),e)]}function Pr(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Fr(e,t){for(let n of e)if(!Ir(n,{upTo:t}))return n}function Ir(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Lr(e){return e instanceof HTMLInputElement&&`select`in e}function Rr(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Lr(e)&&t&&e.select()}}var zr=Br();function Br(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Vr(e,t),e.unshift(t)},remove(t){e=Vr(e,t),e[0]?.resume()}}}function Vr(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Hr(e){return e.filter(e=>e.tagName!==`A`)}var Ur=0;function Wr(){q.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Gr()),document.body.insertAdjacentElement(`beforeend`,e[1]??Gr()),Ur++,()=>{Ur===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Ur--}},[])}function Gr(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Kr=function(){return Kr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Kr.apply(this,arguments)};function qr(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Jr(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Yr=`right-scroll-bar-position`,Xr=`width-before-scroll-bar`,Zr=`with-scroll-bars-hidden`,Qr=`--removed-body-scroll-bar-size`;function $r(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function ei(e,t){var n=(0,q.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var ti=typeof window<`u`?q.useLayoutEffect:q.useEffect,ni=new WeakMap;function ri(e,t){var n=ei(t||null,function(t){return e.forEach(function(e){return $r(e,t)})});return ti(function(){var t=ni.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||$r(e,null)}),i.forEach(function(e){r.has(e)||$r(e,a)})}ni.set(n,e)},[e]),n}function ii(e){return e}function ai(e,t){t===void 0&&(t=ii);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function oi(e){e===void 0&&(e={});var t=ai(null);return t.options=Kr({async:!0,ssr:!1},e),t}var si=function(e){var t=e.sideCar,n=qr(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return q.createElement(r,Kr({},n))};si.isSideCarExport=!0;function ci(e,t){return e.useMedium(t),si}var li=oi(),ui=function(){},di=q.forwardRef(function(e,t){var n=q.useRef(null),r=q.useState({onScrollCapture:ui,onWheelCapture:ui,onTouchMoveCapture:ui}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=qr(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=ri([n,t]),C=Kr(Kr({},b),i);return q.createElement(q.Fragment,null,u&&q.createElement(x,{sideCar:li,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?q.cloneElement(q.Children.only(s),Kr(Kr({},C),{ref:S})):q.createElement(v,Kr({},C,{className:c,ref:S}),s))});di.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},di.classNames={fullWidth:Xr,zeroRight:Yr};var fi,pi=function(){if(fi)return fi;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function mi(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=pi();return t&&e.setAttribute(`nonce`,t),e}function hi(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function gi(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var _i=function(){var e=0,t=null;return{add:function(n){e==0&&(t=mi())&&(hi(t,n),gi(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},vi=function(){var e=_i();return function(t,n){q.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},yi=function(){var e=vi();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},bi={left:0,top:0,right:0,gap:0},xi=function(e){return parseInt(e||``,10)||0},Si=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[xi(n),xi(r),xi(i)]},Ci=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return bi;var t=Si(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},wi=yi(),Ti=`data-scroll-locked`,Ei=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
2
2
  .${Zr} {
3
3
  overflow: hidden ${r};
4
4
  padding-right: ${s}px ${r};
@@ -38,15 +38,15 @@ import{$t as e,A as t,At as n,B as r,Bt as i,Ct as a,D as o,Dt as s,E as c,Et as
38
38
  `},Di=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Oi=function(){q.useEffect(function(){return document.body.setAttribute(Ti,(Di()+1).toString()),function(){var e=Di()-1;e<=0?document.body.removeAttribute(Ti):document.body.setAttribute(Ti,e.toString())}},[])},ki=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Oi();var a=q.useMemo(function(){return Ci(i)},[i]);return q.createElement(wi,{styles:Ei(a,!t,i,n?``:`!important`)})},Ai=!1;if(typeof window<`u`)try{var ji=Object.defineProperty({},`passive`,{get:function(){return Ai=!0,!0}});window.addEventListener(`test`,ji,ji),window.removeEventListener(`test`,ji,ji)}catch{Ai=!1}var Mi=Ai?{passive:!1}:!1,Ni=function(e){return e.tagName===`TEXTAREA`},Pi=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Ni(e)&&n[t]===`visible`)},Fi=function(e){return Pi(e,`overflowY`)},Ii=function(e){return Pi(e,`overflowX`)},Li=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Bi(e,r)){var i=Vi(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ri=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},zi=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Bi=function(e,t){return e===`v`?Fi(t):Ii(t)},Vi=function(e,t){return e===`v`?Ri(t):zi(t)},Hi=function(e,t){return e===`h`&&t===`rtl`?-1:1},Ui=function(e,t,n,r,i){var a=Hi(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Vi(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Bi(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Wi=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Gi=function(e){return[e.deltaX,e.deltaY]},Ki=function(e){return e&&`current`in e?e.current:e},qi=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ji=function(e){return`
39
39
  .block-interactivity-${e} {pointer-events: none;}
40
40
  .allow-interactivity-${e} {pointer-events: all;}
41
- `},Yi=0,Xi=[];function Zi(e){var t=q.useRef([]),n=q.useRef([0,0]),r=q.useRef(),i=q.useState(Yi++)[0],a=q.useState(yi)[0],o=q.useRef(e);q.useEffect(function(){o.current=e},[e]),q.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Jr([e.lockRef.current],(e.shards||[]).map(Ki),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=q.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Wi(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Li(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Li(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Ui(h,t,e,h===`h`?s:c,!0)},[]),c=q.useCallback(function(e){var n=e;if(!(!Xi.length||Xi[Xi.length-1]!==a)){var r=`deltaY`in n?Gi(n):Wi(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&qi(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Ki).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=q.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Qi(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=q.useCallback(function(e){n.current=Wi(e),r.current=void 0},[]),d=q.useCallback(function(t){l(t.type,Gi(t),t.target,s(t,e.lockRef.current))},[]),f=q.useCallback(function(t){l(t.type,Wi(t),t.target,s(t,e.lockRef.current))},[]);q.useEffect(function(){return Xi.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Mi),document.addEventListener(`touchmove`,c,Mi),document.addEventListener(`touchstart`,u,Mi),function(){Xi=Xi.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Mi),document.removeEventListener(`touchmove`,c,Mi),document.removeEventListener(`touchstart`,u,Mi)}},[]);var p=e.removeScrollBar,m=e.inert;return q.createElement(q.Fragment,null,m?q.createElement(a,{styles:Ji(i)}):null,p?q.createElement(ki,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Qi(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var $i=ci(li,Zi),ea=q.forwardRef(function(e,t){return q.createElement(di,Kr({},e,{ref:t,sideCar:$i}))});ea.classNames=di.classNames;var ta=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},na=new WeakMap,ra=new WeakMap,ia={},aa=0,oa=function(e){return e&&(e.host||oa(e.parentNode))},sa=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=oa(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},ca=function(e,t,n,r){var i=sa(t,Array.isArray(e)?e:[e]);ia[n]||(ia[n]=new WeakMap);var a=ia[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(na.get(e)||0)+1,l=(a.get(e)||0)+1;na.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ra.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),aa++,function(){o.forEach(function(e){var t=na.get(e)-1,i=a.get(e)-1;na.set(e,t),a.set(e,i),t||(ra.has(e)||e.removeAttribute(r),ra.delete(e)),i||e.removeAttribute(n)}),aa--,aa||(na=new WeakMap,na=new WeakMap,ra=new WeakMap,ia={})}},la=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||ta(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),ca(r,i,n,`aria-hidden`)):function(){return null}},ua=`Dialog`,[da,fa]=ke(ua),[pa,ma]=da(ua),ha=t=>{let{__scopeDialog:n,children:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=t,c=q.useRef(null),l=q.useRef(null),[u,d]=e({prop:i,defaultProp:a??!1,onChange:o,caller:ua});return(0,K.jsx)(pa,{scope:n,triggerRef:c,contentRef:l,contentId:R(),titleId:R(),descriptionId:R(),open:u,onOpenChange:d,onOpenToggle:q.useCallback(()=>d(e=>!e),[d]),modal:s,children:r})};ha.displayName=ua;var ga=`DialogTrigger`,_a=q.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ma(ga,n),a=Fe(t,i.triggerRef);return(0,K.jsx)(ue.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":La(i.open),...r,ref:a,onClick:Ne(e.onClick,i.onOpenToggle)})});_a.displayName=ga;var va=`DialogPortal`,[ya,ba]=da(va,{forceMount:void 0}),xa=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=ma(va,t);return(0,K.jsx)(ya,{scope:t,forceMount:n,children:q.Children.map(r,e=>(0,K.jsx)(E,{present:n||a.open,children:(0,K.jsx)(g,{asChild:!0,container:i,children:e})}))})};xa.displayName=va;var Sa=`DialogOverlay`,Ca=q.forwardRef((e,t)=>{let n=ba(Sa,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ma(Sa,e.__scopeDialog);return a.modal?(0,K.jsx)(E,{present:r||a.open,children:(0,K.jsx)(Ta,{...i,ref:t})}):null});Ca.displayName=Sa;var wa=je(`DialogOverlay.RemoveScroll`),Ta=q.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ma(Sa,n);return(0,K.jsx)(ea,{as:wa,allowPinchZoom:!0,shards:[i.contentRef],children:(0,K.jsx)(ue.div,{"data-state":La(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),Ea=`DialogContent`,Da=q.forwardRef((e,t)=>{let n=ba(Ea,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ma(Ea,e.__scopeDialog);return(0,K.jsx)(E,{present:r||a.open,children:a.modal?(0,K.jsx)(Oa,{...i,ref:t}):(0,K.jsx)(ka,{...i,ref:t})})});Da.displayName=Ea;var Oa=q.forwardRef((e,t)=>{let n=ma(Ea,e.__scopeDialog),r=q.useRef(null),i=Fe(t,n.contentRef,r);return q.useEffect(()=>{let e=r.current;if(e)return la(e)},[]),(0,K.jsx)(Aa,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ne(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ne(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Ne(e.onFocusOutside,e=>e.preventDefault())})}),ka=q.forwardRef((e,t)=>{let n=ma(Ea,e.__scopeDialog),r=q.useRef(!1),i=q.useRef(!1);return(0,K.jsx)(Aa,{...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()}})}),Aa=q.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=ma(Ea,n),c=q.useRef(null),l=Fe(t,c);return Wr(),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jr,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,K.jsx)(I,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":La(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Va,{titleId:s.titleId}),(0,K.jsx)(Ua,{contentRef:c,descriptionId:s.descriptionId})]})]})}),ja=`DialogTitle`,Ma=q.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ma(ja,n);return(0,K.jsx)(ue.h2,{id:i.titleId,...r,ref:t})});Ma.displayName=ja;var Na=`DialogDescription`,Pa=q.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ma(Na,n);return(0,K.jsx)(ue.p,{id:i.descriptionId,...r,ref:t})});Pa.displayName=Na;var Fa=`DialogClose`,Ia=q.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ma(Fa,n);return(0,K.jsx)(ue.button,{type:`button`,...r,ref:t,onClick:Ne(e.onClick,()=>i.onOpenChange(!1))})});Ia.displayName=Fa;function La(e){return e?`open`:`closed`}var Ra=`DialogTitleWarning`,[za,Ba]=xe(Ra,{contentName:Ea,titleName:ja,docsSlug:`dialog`}),Va=({titleId:e})=>{let t=Ba(Ra),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
41
+ `},Yi=0,Xi=[];function Zi(e){var t=q.useRef([]),n=q.useRef([0,0]),r=q.useRef(),i=q.useState(Yi++)[0],a=q.useState(yi)[0],o=q.useRef(e);q.useEffect(function(){o.current=e},[e]),q.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Jr([e.lockRef.current],(e.shards||[]).map(Ki),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=q.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Wi(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Li(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Li(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Ui(h,t,e,h===`h`?s:c,!0)},[]),c=q.useCallback(function(e){var n=e;if(!(!Xi.length||Xi[Xi.length-1]!==a)){var r=`deltaY`in n?Gi(n):Wi(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&qi(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Ki).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=q.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Qi(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=q.useCallback(function(e){n.current=Wi(e),r.current=void 0},[]),d=q.useCallback(function(t){l(t.type,Gi(t),t.target,s(t,e.lockRef.current))},[]),f=q.useCallback(function(t){l(t.type,Wi(t),t.target,s(t,e.lockRef.current))},[]);q.useEffect(function(){return Xi.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Mi),document.addEventListener(`touchmove`,c,Mi),document.addEventListener(`touchstart`,u,Mi),function(){Xi=Xi.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Mi),document.removeEventListener(`touchmove`,c,Mi),document.removeEventListener(`touchstart`,u,Mi)}},[]);var p=e.removeScrollBar,m=e.inert;return q.createElement(q.Fragment,null,m?q.createElement(a,{styles:Ji(i)}):null,p?q.createElement(ki,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Qi(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var $i=ci(li,Zi),ea=q.forwardRef(function(e,t){return q.createElement(di,Kr({},e,{ref:t,sideCar:$i}))});ea.classNames=di.classNames;var ta=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},na=new WeakMap,ra=new WeakMap,ia={},aa=0,oa=function(e){return e&&(e.host||oa(e.parentNode))},sa=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=oa(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},ca=function(e,t,n,r){var i=sa(t,Array.isArray(e)?e:[e]);ia[n]||(ia[n]=new WeakMap);var a=ia[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(na.get(e)||0)+1,l=(a.get(e)||0)+1;na.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ra.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),aa++,function(){o.forEach(function(e){var t=na.get(e)-1,i=a.get(e)-1;na.set(e,t),a.set(e,i),t||(ra.has(e)||e.removeAttribute(r),ra.delete(e)),i||e.removeAttribute(n)}),aa--,aa||(na=new WeakMap,na=new WeakMap,ra=new WeakMap,ia={})}},la=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||ta(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),ca(r,i,n,`aria-hidden`)):function(){return null}},ua=`Dialog`,[da,fa]=ne(ua),[pa,ma]=da(ua),ha=e=>{let{__scopeDialog:n,children:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=q.useRef(null),l=q.useRef(null),[u,d]=Le({prop:i,defaultProp:a??!1,onChange:o,caller:ua});return(0,K.jsx)(pa,{scope:n,triggerRef:c,contentRef:l,contentId:t(),titleId:t(),descriptionId:t(),open:u,onOpenChange:d,onOpenToggle:q.useCallback(()=>d(e=>!e),[d]),modal:s,children:r})};ha.displayName=ua;var ga=`DialogTrigger`,_a=q.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ma(ga,n),a=se(t,i.triggerRef);return(0,K.jsx)(De.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":La(i.open),...r,ref:a,onClick:Ne(e.onClick,i.onOpenToggle)})});_a.displayName=ga;var va=`DialogPortal`,[ya,ba]=da(va,{forceMount:void 0}),xa=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=ma(va,t);return(0,K.jsx)(ya,{scope:t,forceMount:n,children:q.Children.map(r,e=>(0,K.jsx)(U,{present:n||a.open,children:(0,K.jsx)(B,{asChild:!0,container:i,children:e})}))})};xa.displayName=va;var Sa=`DialogOverlay`,Ca=q.forwardRef((e,t)=>{let n=ba(Sa,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ma(Sa,e.__scopeDialog);return a.modal?(0,K.jsx)(U,{present:r||a.open,children:(0,K.jsx)(Ta,{...i,ref:t})}):null});Ca.displayName=Sa;var wa=Se(`DialogOverlay.RemoveScroll`),Ta=q.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ma(Sa,n);return(0,K.jsx)(ea,{as:wa,allowPinchZoom:!0,shards:[i.contentRef],children:(0,K.jsx)(De.div,{"data-state":La(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),Ea=`DialogContent`,Da=q.forwardRef((e,t)=>{let n=ba(Ea,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ma(Ea,e.__scopeDialog);return(0,K.jsx)(U,{present:r||a.open,children:a.modal?(0,K.jsx)(Oa,{...i,ref:t}):(0,K.jsx)(ka,{...i,ref:t})})});Da.displayName=Ea;var Oa=q.forwardRef((e,t)=>{let n=ma(Ea,e.__scopeDialog),r=q.useRef(null),i=se(t,n.contentRef,r);return q.useEffect(()=>{let e=r.current;if(e)return la(e)},[]),(0,K.jsx)(Aa,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ne(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ne(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Ne(e.onFocusOutside,e=>e.preventDefault())})}),ka=q.forwardRef((e,t)=>{let n=ma(Ea,e.__scopeDialog),r=q.useRef(!1),i=q.useRef(!1);return(0,K.jsx)(Aa,{...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()}})}),Aa=q.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=ma(Ea,n),c=q.useRef(null),l=se(t,c);return Wr(),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jr,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,K.jsx)(H,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":La(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Va,{titleId:s.titleId}),(0,K.jsx)(Ua,{contentRef:c,descriptionId:s.descriptionId})]})]})}),ja=`DialogTitle`,Ma=q.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ma(ja,n);return(0,K.jsx)(De.h2,{id:i.titleId,...r,ref:t})});Ma.displayName=ja;var Na=`DialogDescription`,Pa=q.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ma(Na,n);return(0,K.jsx)(De.p,{id:i.descriptionId,...r,ref:t})});Pa.displayName=Na;var Fa=`DialogClose`,Ia=q.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ma(Fa,n);return(0,K.jsx)(De.button,{type:`button`,...r,ref:t,onClick:Ne(e.onClick,()=>i.onOpenChange(!1))})});Ia.displayName=Fa;function La(e){return e?`open`:`closed`}var Ra=`DialogTitleWarning`,[za,Ba]=ge(Ra,{contentName:Ea,titleName:ja,docsSlug:`dialog`}),Va=({titleId:e})=>{let t=Ba(Ra),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
42
42
 
43
43
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
44
44
 
45
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return q.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Ha=`DialogDescriptionWarning`,Ua=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ba(Ha).contentName}}.`;return q.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Wa=ha,Ga=xa,Ka=Ca,qa=Da,Ja=Ma,Ya=Pa,Xa=Ia,Za=p((e=>{var t=Ve();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,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),Qa=p(((e,t)=>{t.exports=Za()}));function $a(e){let t=e.split(`/`);return t.length<2?`ok`:`${t[0]}/${t[1]}`}function eo(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 J(e,t,n){if(typeof performance>`u`||!performance.measure)return;let r=$a(e),i=eo(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 to(e){let t=(0,Yn.c)(3),{name:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,K.jsx)(q.Profiler,{id:n,onRender:no,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var no=(e,t,n,r,i,a)=>{J(`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)})},ro=`modulepreload`,io=function(e){return`/`+e},ao={},oo=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=io(t,n),t in ao)return;ao[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:ro,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},so=Qa(),{getOwnPropertyNames:co,getOwnPropertySymbols:lo}=Object,{hasOwnProperty:uo}=Object.prototype;function fo(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function po(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 mo(e){return e?.[Symbol.toStringTag]}function ho(e){return co(e).concat(lo(e))}var go=Object.hasOwn||((e,t)=>uo.call(e,t));function _o(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var vo=`__v`,yo=`__o`,bo=`_owner`,{getOwnPropertyDescriptor:xo,keys:So}=Object;function Co(e,t){return e.byteLength===t.byteLength&&Io(new Uint8Array(e),new Uint8Array(t))}function wo(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 To(e,t){return e.byteLength===t.byteLength&&Io(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function Eo(e,t){return _o(e.getTime(),t.getTime())}function Do(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function Oo(e,t){return e===t}function ko(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 Ao=_o;function jo(e,t,n){let r=So(e),i=r.length;if(So(t).length!==i)return!1;for(;i-- >0;)if(!Ro(e,t,n,r[i]))return!1;return!0}function Mo(e,t,n){let r=ho(e),i=r.length;if(ho(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!Ro(e,t,n,a)||(o=xo(e,a),s=xo(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function No(e,t){return _o(e.valueOf(),t.valueOf())}function Po(e,t){return e.source===t.source&&e.flags===t.flags}function Fo(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 Io(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 Lo(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 Ro(e,t,n,r){return(r===bo||r===yo||r===vo)&&(e.$$typeof||t.$$typeof)?!0:go(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var zo=`[object ArrayBuffer]`,Bo=`[object Arguments]`,Vo=`[object Boolean]`,Ho=`[object DataView]`,Uo=`[object Date]`,Wo=`[object Error]`,Go=`[object Map]`,Ko=`[object Number]`,qo=`[object Object]`,Jo=`[object RegExp]`,Yo=`[object Set]`,Xo=`[object String]`,Zo={"[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},Qo=`[object URL]`,$o=Object.prototype.toString;function es({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=$o.call(h);if(b===Uo)return r(h,g,_);if(b===Jo)return u(h,g,_);if(b===Go)return o(h,g,_);if(b===Yo)return d(h,g,_);if(b===qo)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===Qo)return p(h,g,_);if(b===Wo)return i(h,g,_);if(b===Bo)return c(h,g,_);if(Zo[b])return f(h,g,_);if(b===zo)return e(h,g,_);if(b===Ho)return n(h,g,_);if(b===Vo||b===Ko||b===Xo)return l(h,g,_);if(m){let e=m[b];if(!e){let t=mo(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function ts({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Co,areArraysEqual:n?Mo:wo,areDataViewsEqual:To,areDatesEqual:Eo,areErrorsEqual:Do,areFunctionsEqual:Oo,areMapsEqual:n?fo(ko,Mo):ko,areNumbersEqual:Ao,areObjectsEqual:n?Mo:jo,arePrimitiveWrappersEqual:No,areRegExpsEqual:Po,areSetsEqual:n?fo(Fo,Mo):Fo,areTypedArraysEqual:n?fo(Io,Mo):Io,areUrlsEqual:Lo,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=po(r.areArraysEqual),t=po(r.areMapsEqual),n=po(r.areObjectsEqual),i=po(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function ns(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function rs({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 is=as();as({strict:!0}),as({circular:!0}),as({circular:!0,strict:!0}),as({createInternalComparator:()=>_o}),as({strict:!0,createInternalComparator:()=>_o}),as({circular:!0,createInternalComparator:()=>_o}),as({circular:!0,createInternalComparator:()=>_o,strict:!0});function as(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=es(ts(e));return rs({circular:t,comparator:a,createState:r,equals:n?n(a):ns(a),strict:i})}var os=p((e=>{var t=Ve(),n=Qa();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,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),ss=p(((e,t)=>{t.exports=os()}))(),cs=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},ls=({contentComponent:e})=>{let t=(0,so.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,K.jsx)(K.Fragment,{children:Object.values(t)})};function us(){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]:Xn.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 ds=class extends q.Component{constructor(e){super(e),this.editorContentRef=q.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=us(),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,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{ref:cs(t,this.editorContentRef),...n}),e?.contentComponent&&(0,K.jsx)(ls,{contentComponent:e.contentComponent})]})}},fs=(0,q.forwardRef)((e,t)=>{let n=q.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return q.createElement(ds,{key:n,innerRef:t,...e})}),ps=q.memo(fs),ms=typeof window<`u`?q.useLayoutEffect:q.useEffect,hs=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 gs(e){let[t]=(0,q.useState)(()=>new hs(e.editor)),n=(0,ss.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??is);return ms(()=>t.watch(e.editor),[e.editor,t]),(0,q.useDebugValue)(n),n}typeof window>`u`||typeof window<`u`&&window.next;var _s=(0,q.createContext)({editor:null});_s.Consumer;var vs=()=>(0,q.useContext)(_s),ys=(0,q.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),bs=()=>(0,q.useContext)(ys),xs=q.forwardRef((e,t)=>{let{onDragStart:n}=bs();return(0,K.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function Ss(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function Cs(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.forward_ref)`||e.$$typeof.description===`react.forward_ref`))}function ws(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.memo)`||e.$$typeof.description===`react.memo`))}function Ts(e){if(Ss(e)||Cs(e))return!0;if(ws(e)){let t=e.type;if(t)return Ss(t)||Cs(t)}return!1}function Es(){try{if(q.version)return parseInt(q.version.split(`.`)[0],10)>=19}catch{}return!1}var Ds=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,Xn.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=Es(),a=Ts(t),o={...n};o.ref&&!(i||a)&&delete o.ref,!o.ref&&(i||a)&&(o.ref=e=>{this.ref=e}),this.reactElement=(0,K.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])})}};q.createContext({markViewContentRef:()=>{}});var Os=class extends Ie{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,q.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,q.memo)(e=>(0,K.jsx)(ys.Provider,{value:t,children:(0,q.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 Ds(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())},D(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&&=(ie(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=Ee(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function ks(e,t){return n=>n.editor.contentComponent?new Os(e,n,t):{}}var As=(0,q.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});As.displayName=`TiptapContext`;var js=()=>(0,q.useContext)(As);function Ms({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,q.useMemo)(()=>({editor:r}),[r]),a=(0,q.useMemo)(()=>({editor:r}),[r]);return(0,K.jsx)(_s.Provider,{value:a,children:(0,K.jsx)(As.Provider,{value:i,children:n})})}Ms.displayName=`Tiptap`;function Ns({...e}){let{editor:t}=js();return(0,K.jsx)(ps,{editor:t,...e})}Ns.displayName=`Tiptap.Content`,Object.assign(Ms,{Content:Ns});var Ps=()=>new Map,Fs=e=>{let t=Ps();return e.forEach((e,n)=>{t.set(n,e)}),t},Is=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Ls=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Rs=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},zs=()=>new Set,Bs=e=>e[e.length-1],Vs=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Hs=Array.from,Us=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Ws=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Gs=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Ks=Array.isArray,qs=class{constructor(){this._observers=Ps()}on(e,t){return Is(this._observers,e,zs).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 Hs((this._observers.get(e)||Ps()).values()).forEach(e=>e(...t))}destroy(){this._observers=Ps()}},Js=Math.floor,Ys=Math.abs,Xs=(e,t)=>e<t?e:t,Zs=(e,t)=>e>t?e:t;Number.isNaN;var Qs=e=>e===0?1/e<0:e<0,$s=1<<17,ec=1<<18,tc=1<<19,nc=1<<20,rc=1<<21,ic=1<<22,ac=1<<23,oc=1<<24,sc=1<<25,cc=1<<26,lc=1<<27,uc=1<<28,dc=1<<29;$s-1,ec-1,tc-1,nc-1,rc-1,ic-1,ac-1,oc-1,sc-1,cc-1,lc-1,uc-1,dc-1;var fc=2**53-1,pc=-(2**53-1),mc=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&Js(e)===e);Number.isNaN,Number.parseInt;var hc=String.fromCharCode;String.fromCodePoint,hc(65535);var gc=e=>e.toLowerCase(),_c=/^\s*/g,vc=e=>e.replace(_c,``),yc=/([A-Z])/g,bc=(e,t)=>vc(e.replace(yc,e=>`${t}${gc(e)}`)),xc=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},Sc=typeof TextEncoder<`u`?new TextEncoder:null,Cc=Sc?e=>Sc.encode(e):xc,wc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});wc&&wc.decode(new Uint8Array).length===1&&(wc=null);var Tc=(e,t)=>Gs(t,()=>e).join(``),Ec=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Dc=()=>new Ec,Oc=e=>{let t=Dc();return e(t),Ac(t)},kc=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Ac=e=>{let t=new Uint8Array(kc(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},jc=(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(Zs(n,t)*2),e.cpos=0)},Mc=(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},Nc=Mc,Y=(e,t)=>{for(;t>127;)Mc(e,128|127&t),t=Js(t/128);Mc(e,127&t)},Pc=(e,t)=>{let n=Qs(t);for(n&&(t=-t),Mc(e,(t>63?128:0)|(n?64:0)|63&t),t=Js(t/64);t>0;)Mc(e,(t>127?128:0)|127&t),t=Js(t/128)},Fc=new Uint8Array(3e4),Ic=Fc.length/3,Lc=Sc&&Sc.encodeInto?(e,t)=>{if(t.length<Ic){let n=Sc.encodeInto(t,Fc).written||0;Y(e,n);for(let t=0;t<n;t++)Mc(e,Fc[t])}else zc(e,Cc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Y(e,r);for(let t=0;t<r;t++)Mc(e,n.codePointAt(t))},Rc=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Xs(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(Zs(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},zc=(e,t)=>{Y(e,t.byteLength),Rc(e,t)},Bc=(e,t)=>{jc(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Vc=(e,t)=>Bc(e,4).setFloat32(0,t,!1),Hc=(e,t)=>Bc(e,8).setFloat64(0,t,!1),Uc=(e,t)=>Bc(e,8).setBigInt64(0,t,!1),Wc=new DataView(new ArrayBuffer(4)),Gc=e=>(Wc.setFloat32(0,e),Wc.getFloat32(0)===e),Kc=(e,t)=>{switch(typeof t){case`string`:Mc(e,119),Lc(e,t);break;case`number`:mc(t)&&Ys(t)<=2147483647?(Mc(e,125),Pc(e,t)):Gc(t)?(Mc(e,124),Vc(e,t)):(Mc(e,123),Hc(e,t));break;case`bigint`:Mc(e,122),Uc(e,t);break;case`object`:if(t===null)Mc(e,126);else if(Ks(t)){Mc(e,117),Y(e,t.length);for(let n=0;n<t.length;n++)Kc(e,t[n])}else if(t instanceof Uint8Array)Mc(e,116),zc(e,t);else{Mc(e,118);let n=Object.keys(t);Y(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];Lc(e,i),Kc(e,t[i])}}break;case`boolean`:Mc(e,t?120:121);break;default:Mc(e,127)}},qc=class extends Ec{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Y(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Jc=e=>{e.count>0&&(Pc(e.encoder,e.count===1?e.s:-e.s),e.count>1&&Y(e.encoder,e.count-2))},Yc=class{constructor(){this.encoder=new Ec,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Jc(this),this.count=1,this.s=e)}toUint8Array(){return Jc(this),Ac(this.encoder)}},Xc=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Pc(e.encoder,t),e.count>1&&Y(e.encoder,e.count-2)}},Zc=class{constructor(){this.encoder=new Ec,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Xc(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Xc(this),Ac(this.encoder)}},Qc=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Yc}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 Ec;return this.sarr.push(this.s),this.s=``,Lc(e,this.sarr.join(``)),Rc(e,this.lensE.toUint8Array()),Ac(e)}},$c=e=>Error(e),el=()=>{throw $c(`Method unimplemented`)},tl=()=>{throw $c(`Unexpected case`)},nl=$c(`Unexpected end of array`),rl=$c(`Integer out of Range`),il=class{constructor(e){this.arr=e,this.pos=0}},al=e=>new il(e),ol=e=>e.pos!==e.arr.length,sl=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},cl=e=>sl(e,X(e)),ll=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>fc)throw rl}throw nl},ul=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>fc)throw rl}throw nl},dl=wc?e=>wc.decode(cl(e)):e=>{let t=X(e);if(t===0)return``;{let n=String.fromCodePoint(ll(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(ll(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))}},fl=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},pl=[e=>void 0,e=>null,ul,e=>fl(e,4).getFloat32(0,!1),e=>fl(e,8).getFloat64(0,!1),e=>fl(e,8).getBigInt64(0,!1),e=>!1,e=>!0,dl,e=>{let t=X(e),n={};for(let r=0;r<t;r++){let t=dl(e);n[t]=ml(e)}return n},e=>{let t=X(e),n=[];for(let r=0;r<t;r++)n.push(ml(e));return n},cl],ml=e=>pl[127-ll(e)](e),hl=class extends il{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),ol(this)?this.count=X(this)+1:this.count=-1),this.count--,this.s}},gl=class extends il{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=ul(this);let e=Qs(this.s);this.count=1,e&&(this.s=-this.s,this.count=X(this)+2)}return this.count--,this.s}},_l=class extends il{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=ul(this),t=e&1;this.diff=Js(e/2),this.count=1,t&&(this.count=X(this)+2)}return this.s+=this.diff,this.count--,this.s}},vl=class{constructor(e){this.decoder=new gl(e),this.str=dl(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 yl=crypto.getRandomValues.bind(crypto),bl=Math.random,xl=()=>yl(new Uint32Array(1))[0],Sl=e=>e[Js(bl()*e.length)],Cl=`10000000-1000-4000-8000-100000000000`,wl=()=>Cl.replace(/[018]/g,e=>(e^xl()&15>>e/4).toString(16)),Tl=Date.now,El=e=>new Promise(e);Promise.all.bind(Promise);var Dl=e=>e===void 0?null:e,Ol=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&&(Ol=localStorage)}catch{}var kl=Ol,Al=Symbol(`Equality`),jl=(e,t)=>e===t||!!e?.[Al]?.(t)||!1,Ml=e=>typeof e==`object`,Nl=Object.assign,Pl=Object.keys,Fl=(e,t)=>{for(let n in e)t(e[n],n)},Il=e=>Pl(e).length,Ll=e=>{for(let t in e)return!1;return!0},Rl=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},zl=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Bl=(e,t)=>e===t||Il(e)===Il(t)&&Rl(e,(e,n)=>(e!==void 0||zl(t,n))&&jl(t[n],e)),Vl=Object.freeze,Hl=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Hl(e[t])}return Vl(e)},Ul=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Ul(e,t,n+1)}},Wl=e=>e,Gl=(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[Al]!=null)return e[Al](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)||!Gl(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Il(e)!==Il(t))return!1;for(let n in e)if(!zl(e,n)||!Gl(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(!Gl(e[n],t[n]))return!1;break;default:return!1}return!0},Kl=(e,t)=>t.includes(e),ql=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Jl=typeof window<`u`&&typeof document<`u`&&!ql;typeof navigator<`u`&&/Mac/.test(navigator.platform);var Yl,Xl=[],Zl=()=>{if(Yl===void 0)if(ql){Yl=Ps();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&Yl.set(t,``),t=r):t===null?Xl.push(r):(Yl.set(t,r),t=null)}t!==null&&Yl.set(t,``)}else typeof location==`object`?(Yl=Ps(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);Yl.set(`--${bc(t,`-`)}`,n),Yl.set(`-${bc(t,`-`)}`,n)}})):Yl=Ps();return Yl},Ql=e=>Zl().has(e),$l=e=>Dl(ql?{}[e.toUpperCase().replaceAll(`-`,`_`)]:kl.getItem(e)),eu=e=>Ql(`--`+e)||$l(e)!==null,tu=eu(`production`),nu=ql&&Kl({}.FORCE_COLOR,[`true`,`1`,`2`])||!Ql(`--no-colors`)&&!eu(`no-color`)&&(!ql||process.stdout.isTTY)&&(!ql||Ql(`--color`)||$l(`COLORTERM`)!==null||($l(`TERM`)||``).includes(`color`)),ru=e=>new Uint8Array(e),iu=Jl?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=hc(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),au=e=>{let t=ru(e.byteLength);return t.set(e),t},ou=e=>Oc(t=>Kc(t,e)),su=class{constructor(e,t){this.left=e,this.right=t}},cu=(e,t)=>new su(e,t),lu=(e,t)=>e.forEach(e=>t(e.left,e.right)),uu=e=>e.next()>=.5,du=(e,t,n)=>Js(e.next()*(n+1-t)+t),fu=(e,t,n)=>Js(e.next()*(n+1-t)+t),pu=(e,t,n)=>fu(e,t,n),mu=e=>hc(pu(e,97,122)),hu=(e,t=0,n=20)=>{let r=pu(e,t,n),i=``;for(let t=0;t<r;t++)i+=mu(e);return i},gu=(e,t)=>t[pu(e,0,t.length-1)],_u=Symbol(`0schema`),vu=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(Tc(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
45
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return q.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Ha=`DialogDescriptionWarning`,Ua=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ba(Ha).contentName}}.`;return q.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Wa=ha,Ga=xa,Ka=Ca,qa=Da,Ja=Ma,Ya=Pa,Xa=Ia,Za=z((e=>{var t=i();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,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[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})),Qa=z(((e,t)=>{t.exports=Za()}));function $a(e){let t=e.split(`/`);return t.length<2?`ok`:`${t[0]}/${t[1]}`}function eo(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 J(e,t,n){if(typeof performance>`u`||!performance.measure)return;let r=$a(e),i=eo(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 to(e){let t=(0,Yn.c)(3),{name:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,K.jsx)(q.Profiler,{id:n,onRender:no,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var no=(e,t,n,r,i,a)=>{J(`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)})},ro=`modulepreload`,io=function(e){return`/`+e},ao={},oo=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=io(t,n),t in ao)return;ao[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:ro,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},so=Qa(),{getOwnPropertyNames:co,getOwnPropertySymbols:lo}=Object,{hasOwnProperty:uo}=Object.prototype;function fo(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function po(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 mo(e){return e?.[Symbol.toStringTag]}function ho(e){return co(e).concat(lo(e))}var go=Object.hasOwn||((e,t)=>uo.call(e,t));function _o(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var vo=`__v`,yo=`__o`,bo=`_owner`,{getOwnPropertyDescriptor:xo,keys:So}=Object;function Co(e,t){return e.byteLength===t.byteLength&&Io(new Uint8Array(e),new Uint8Array(t))}function wo(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 To(e,t){return e.byteLength===t.byteLength&&Io(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function Eo(e,t){return _o(e.getTime(),t.getTime())}function Do(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function Oo(e,t){return e===t}function ko(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 Ao=_o;function jo(e,t,n){let r=So(e),i=r.length;if(So(t).length!==i)return!1;for(;i-- >0;)if(!Ro(e,t,n,r[i]))return!1;return!0}function Mo(e,t,n){let r=ho(e),i=r.length;if(ho(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!Ro(e,t,n,a)||(o=xo(e,a),s=xo(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function No(e,t){return _o(e.valueOf(),t.valueOf())}function Po(e,t){return e.source===t.source&&e.flags===t.flags}function Fo(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 Io(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 Lo(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 Ro(e,t,n,r){return(r===bo||r===yo||r===vo)&&(e.$$typeof||t.$$typeof)?!0:go(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var zo=`[object ArrayBuffer]`,Bo=`[object Arguments]`,Vo=`[object Boolean]`,Ho=`[object DataView]`,Uo=`[object Date]`,Wo=`[object Error]`,Go=`[object Map]`,Ko=`[object Number]`,qo=`[object Object]`,Jo=`[object RegExp]`,Yo=`[object Set]`,Xo=`[object String]`,Zo={"[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},Qo=`[object URL]`,$o=Object.prototype.toString;function es({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=$o.call(h);if(b===Uo)return r(h,g,_);if(b===Jo)return u(h,g,_);if(b===Go)return o(h,g,_);if(b===Yo)return d(h,g,_);if(b===qo)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===Qo)return p(h,g,_);if(b===Wo)return i(h,g,_);if(b===Bo)return c(h,g,_);if(Zo[b])return f(h,g,_);if(b===zo)return e(h,g,_);if(b===Ho)return n(h,g,_);if(b===Vo||b===Ko||b===Xo)return l(h,g,_);if(m){let e=m[b];if(!e){let t=mo(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function ts({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Co,areArraysEqual:n?Mo:wo,areDataViewsEqual:To,areDatesEqual:Eo,areErrorsEqual:Do,areFunctionsEqual:Oo,areMapsEqual:n?fo(ko,Mo):ko,areNumbersEqual:Ao,areObjectsEqual:n?Mo:jo,arePrimitiveWrappersEqual:No,areRegExpsEqual:Po,areSetsEqual:n?fo(Fo,Mo):Fo,areTypedArraysEqual:n?fo(Io,Mo):Io,areUrlsEqual:Lo,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=po(r.areArraysEqual),t=po(r.areMapsEqual),n=po(r.areObjectsEqual),i=po(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function ns(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function rs({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 is=as();as({strict:!0}),as({circular:!0}),as({circular:!0,strict:!0}),as({createInternalComparator:()=>_o}),as({strict:!0,createInternalComparator:()=>_o}),as({circular:!0,createInternalComparator:()=>_o}),as({circular:!0,createInternalComparator:()=>_o,strict:!0});function as(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=es(ts(e));return rs({circular:t,comparator:a,createState:r,equals:n?n(a):ns(a),strict:i})}var os=z((e=>{var t=i(),n=Qa();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=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,i){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),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(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,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),ss=z(((e,t)=>{t.exports=os()}))(),cs=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},ls=({contentComponent:e})=>{let t=(0,so.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,K.jsx)(K.Fragment,{children:Object.values(t)})};function us(){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]:Xn.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 ds=class extends q.Component{constructor(e){super(e),this.editorContentRef=q.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=us(),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,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{ref:cs(t,this.editorContentRef),...n}),e?.contentComponent&&(0,K.jsx)(ls,{contentComponent:e.contentComponent})]})}},fs=(0,q.forwardRef)((e,t)=>{let n=q.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return q.createElement(ds,{key:n,innerRef:t,...e})}),ps=q.memo(fs),ms=typeof window<`u`?q.useLayoutEffect:q.useEffect,hs=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 gs(e){let[t]=(0,q.useState)(()=>new hs(e.editor)),n=(0,ss.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??is);return ms(()=>t.watch(e.editor),[e.editor,t]),(0,q.useDebugValue)(n),n}typeof window>`u`||typeof window<`u`&&window.next;var _s=(0,q.createContext)({editor:null});_s.Consumer;var vs=()=>(0,q.useContext)(_s),ys=(0,q.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),bs=()=>(0,q.useContext)(ys),xs=q.forwardRef((e,t)=>{let{onDragStart:n}=bs();return(0,K.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function Ss(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function Cs(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.forward_ref)`||e.$$typeof.description===`react.forward_ref`))}function ws(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.memo)`||e.$$typeof.description===`react.memo`))}function Ts(e){if(Ss(e)||Cs(e))return!0;if(ws(e)){let t=e.type;if(t)return Ss(t)||Cs(t)}return!1}function Es(){try{if(q.version)return parseInt(q.version.split(`.`)[0],10)>=19}catch{}return!1}var Ds=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,Xn.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=Es(),a=Ts(t),o={...n};o.ref&&!(i||a)&&delete o.ref,!o.ref&&(i||a)&&(o.ref=e=>{this.ref=e}),this.reactElement=(0,K.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])})}};q.createContext({markViewContentRef:()=>{}});var Os=class extends ce{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,q.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,q.memo)(e=>(0,K.jsx)(ys.Provider,{value:t,children:(0,q.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 Ds(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())},Ve(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&&=(Ae(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=me(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function ks(e,t){return n=>n.editor.contentComponent?new Os(e,n,t):{}}var As=(0,q.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});As.displayName=`TiptapContext`;var js=()=>(0,q.useContext)(As);function Ms({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,q.useMemo)(()=>({editor:r}),[r]),a=(0,q.useMemo)(()=>({editor:r}),[r]);return(0,K.jsx)(_s.Provider,{value:a,children:(0,K.jsx)(As.Provider,{value:i,children:n})})}Ms.displayName=`Tiptap`;function Ns({...e}){let{editor:t}=js();return(0,K.jsx)(ps,{editor:t,...e})}Ns.displayName=`Tiptap.Content`,Object.assign(Ms,{Content:Ns});var Ps=()=>new Map,Fs=e=>{let t=Ps();return e.forEach((e,n)=>{t.set(n,e)}),t},Is=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Ls=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Rs=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},zs=()=>new Set,Bs=e=>e[e.length-1],Vs=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Hs=Array.from,Us=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Ws=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Gs=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Ks=Array.isArray,qs=class{constructor(){this._observers=Ps()}on(e,t){return Is(this._observers,e,zs).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 Hs((this._observers.get(e)||Ps()).values()).forEach(e=>e(...t))}destroy(){this._observers=Ps()}},Js=Math.floor,Ys=Math.abs,Xs=(e,t)=>e<t?e:t,Zs=(e,t)=>e>t?e:t;Number.isNaN;var Qs=e=>e===0?1/e<0:e<0,$s=1<<17,ec=1<<18,tc=1<<19,nc=1<<20,rc=1<<21,ic=1<<22,ac=1<<23,oc=1<<24,sc=1<<25,cc=1<<26,lc=1<<27,uc=1<<28,dc=1<<29;$s-1,ec-1,tc-1,nc-1,rc-1,ic-1,ac-1,oc-1,sc-1,cc-1,lc-1,uc-1,dc-1;var fc=2**53-1,pc=-(2**53-1),mc=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&Js(e)===e);Number.isNaN,Number.parseInt;var hc=String.fromCharCode;String.fromCodePoint,hc(65535);var gc=e=>e.toLowerCase(),_c=/^\s*/g,vc=e=>e.replace(_c,``),yc=/([A-Z])/g,bc=(e,t)=>vc(e.replace(yc,e=>`${t}${gc(e)}`)),xc=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},Sc=typeof TextEncoder<`u`?new TextEncoder:null,Cc=Sc?e=>Sc.encode(e):xc,wc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});wc&&wc.decode(new Uint8Array).length===1&&(wc=null);var Tc=(e,t)=>Gs(t,()=>e).join(``),Ec=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Dc=()=>new Ec,Oc=e=>{let t=Dc();return e(t),Ac(t)},kc=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Ac=e=>{let t=new Uint8Array(kc(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},jc=(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(Zs(n,t)*2),e.cpos=0)},Mc=(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},Nc=Mc,Y=(e,t)=>{for(;t>127;)Mc(e,128|127&t),t=Js(t/128);Mc(e,127&t)},Pc=(e,t)=>{let n=Qs(t);for(n&&(t=-t),Mc(e,(t>63?128:0)|(n?64:0)|63&t),t=Js(t/64);t>0;)Mc(e,(t>127?128:0)|127&t),t=Js(t/128)},Fc=new Uint8Array(3e4),Ic=Fc.length/3,Lc=Sc&&Sc.encodeInto?(e,t)=>{if(t.length<Ic){let n=Sc.encodeInto(t,Fc).written||0;Y(e,n);for(let t=0;t<n;t++)Mc(e,Fc[t])}else zc(e,Cc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Y(e,r);for(let t=0;t<r;t++)Mc(e,n.codePointAt(t))},Rc=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Xs(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(Zs(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},zc=(e,t)=>{Y(e,t.byteLength),Rc(e,t)},Bc=(e,t)=>{jc(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Vc=(e,t)=>Bc(e,4).setFloat32(0,t,!1),Hc=(e,t)=>Bc(e,8).setFloat64(0,t,!1),Uc=(e,t)=>Bc(e,8).setBigInt64(0,t,!1),Wc=new DataView(new ArrayBuffer(4)),Gc=e=>(Wc.setFloat32(0,e),Wc.getFloat32(0)===e),Kc=(e,t)=>{switch(typeof t){case`string`:Mc(e,119),Lc(e,t);break;case`number`:mc(t)&&Ys(t)<=2147483647?(Mc(e,125),Pc(e,t)):Gc(t)?(Mc(e,124),Vc(e,t)):(Mc(e,123),Hc(e,t));break;case`bigint`:Mc(e,122),Uc(e,t);break;case`object`:if(t===null)Mc(e,126);else if(Ks(t)){Mc(e,117),Y(e,t.length);for(let n=0;n<t.length;n++)Kc(e,t[n])}else if(t instanceof Uint8Array)Mc(e,116),zc(e,t);else{Mc(e,118);let n=Object.keys(t);Y(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];Lc(e,i),Kc(e,t[i])}}break;case`boolean`:Mc(e,t?120:121);break;default:Mc(e,127)}},qc=class extends Ec{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Y(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Jc=e=>{e.count>0&&(Pc(e.encoder,e.count===1?e.s:-e.s),e.count>1&&Y(e.encoder,e.count-2))},Yc=class{constructor(){this.encoder=new Ec,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Jc(this),this.count=1,this.s=e)}toUint8Array(){return Jc(this),Ac(this.encoder)}},Xc=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Pc(e.encoder,t),e.count>1&&Y(e.encoder,e.count-2)}},Zc=class{constructor(){this.encoder=new Ec,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Xc(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Xc(this),Ac(this.encoder)}},Qc=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Yc}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 Ec;return this.sarr.push(this.s),this.s=``,Lc(e,this.sarr.join(``)),Rc(e,this.lensE.toUint8Array()),Ac(e)}},$c=e=>Error(e),el=()=>{throw $c(`Method unimplemented`)},tl=()=>{throw $c(`Unexpected case`)},nl=$c(`Unexpected end of array`),rl=$c(`Integer out of Range`),il=class{constructor(e){this.arr=e,this.pos=0}},al=e=>new il(e),ol=e=>e.pos!==e.arr.length,sl=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},cl=e=>sl(e,X(e)),ll=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>fc)throw rl}throw nl},ul=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>fc)throw rl}throw nl},dl=wc?e=>wc.decode(cl(e)):e=>{let t=X(e);if(t===0)return``;{let n=String.fromCodePoint(ll(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(ll(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))}},fl=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},pl=[e=>void 0,e=>null,ul,e=>fl(e,4).getFloat32(0,!1),e=>fl(e,8).getFloat64(0,!1),e=>fl(e,8).getBigInt64(0,!1),e=>!1,e=>!0,dl,e=>{let t=X(e),n={};for(let r=0;r<t;r++){let t=dl(e);n[t]=ml(e)}return n},e=>{let t=X(e),n=[];for(let r=0;r<t;r++)n.push(ml(e));return n},cl],ml=e=>pl[127-ll(e)](e),hl=class extends il{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),ol(this)?this.count=X(this)+1:this.count=-1),this.count--,this.s}},gl=class extends il{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=ul(this);let e=Qs(this.s);this.count=1,e&&(this.s=-this.s,this.count=X(this)+2)}return this.count--,this.s}},_l=class extends il{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=ul(this),t=e&1;this.diff=Js(e/2),this.count=1,t&&(this.count=X(this)+2)}return this.s+=this.diff,this.count--,this.s}},vl=class{constructor(e){this.decoder=new gl(e),this.str=dl(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 yl=crypto.getRandomValues.bind(crypto),bl=Math.random,xl=()=>yl(new Uint32Array(1))[0],Sl=e=>e[Js(bl()*e.length)],Cl=`10000000-1000-4000-8000-100000000000`,wl=()=>Cl.replace(/[018]/g,e=>(e^xl()&15>>e/4).toString(16)),Tl=Date.now,El=e=>new Promise(e);Promise.all.bind(Promise);var Dl=e=>e===void 0?null:e,Ol=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&&(Ol=localStorage)}catch{}var kl=Ol,Al=Symbol(`Equality`),jl=(e,t)=>e===t||!!e?.[Al]?.(t)||!1,Ml=e=>typeof e==`object`,Nl=Object.assign,Pl=Object.keys,Fl=(e,t)=>{for(let n in e)t(e[n],n)},Il=e=>Pl(e).length,Ll=e=>{for(let t in e)return!1;return!0},Rl=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},zl=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Bl=(e,t)=>e===t||Il(e)===Il(t)&&Rl(e,(e,n)=>(e!==void 0||zl(t,n))&&jl(t[n],e)),Vl=Object.freeze,Hl=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Hl(e[t])}return Vl(e)},Ul=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Ul(e,t,n+1)}},Wl=e=>e,Gl=(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[Al]!=null)return e[Al](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)||!Gl(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Il(e)!==Il(t))return!1;for(let n in e)if(!zl(e,n)||!Gl(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(!Gl(e[n],t[n]))return!1;break;default:return!1}return!0},Kl=(e,t)=>t.includes(e),ql=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Jl=typeof window<`u`&&typeof document<`u`&&!ql;typeof navigator<`u`&&/Mac/.test(navigator.platform);var Yl,Xl=[],Zl=()=>{if(Yl===void 0)if(ql){Yl=Ps();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&Yl.set(t,``),t=r):t===null?Xl.push(r):(Yl.set(t,r),t=null)}t!==null&&Yl.set(t,``)}else typeof location==`object`?(Yl=Ps(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);Yl.set(`--${bc(t,`-`)}`,n),Yl.set(`-${bc(t,`-`)}`,n)}})):Yl=Ps();return Yl},Ql=e=>Zl().has(e),$l=e=>Dl(ql?{}[e.toUpperCase().replaceAll(`-`,`_`)]:kl.getItem(e)),eu=e=>Ql(`--`+e)||$l(e)!==null,tu=eu(`production`),nu=ql&&Kl({}.FORCE_COLOR,[`true`,`1`,`2`])||!Ql(`--no-colors`)&&!eu(`no-color`)&&(!ql||process.stdout.isTTY)&&(!ql||Ql(`--color`)||$l(`COLORTERM`)!==null||($l(`TERM`)||``).includes(`color`)),ru=e=>new Uint8Array(e),iu=Jl?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=hc(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),au=e=>{let t=ru(e.byteLength);return t.set(e),t},ou=e=>Oc(t=>Kc(t,e)),su=class{constructor(e,t){this.left=e,this.right=t}},cu=(e,t)=>new su(e,t),lu=(e,t)=>e.forEach(e=>t(e.left,e.right)),uu=e=>e.next()>=.5,du=(e,t,n)=>Js(e.next()*(n+1-t)+t),fu=(e,t,n)=>Js(e.next()*(n+1-t)+t),pu=(e,t,n)=>fu(e,t,n),mu=e=>hc(pu(e,97,122)),hu=(e,t=0,n=20)=>{let r=pu(e,t,n),i=``;for(let t=0;t<r;t++)i+=mu(e);return i},gu=(e,t)=>t[pu(e,0,t.length-1)],_u=Symbol(`0schema`),vu=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(Tc(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
46
46
  `)}},yu=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Al]?jl(e,t):Ks(e)?Us(e,e=>Ws(t,t=>yu(e,t))):Ml(e)?Rl(e,(e,n)=>yu(e,t[n])):!1,bu=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),yu(t,n)}equals(e){return this.constructor===e.constructor&&Gl(this.shape,e.shape)}[_u](){return!0}[Al](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){el()}get nullable(){return $u(this,md)}get optional(){return new ju(this)}cast(e){return vd(e,this),e}expect(e){return vd(e,this),e}},xu=class extends bu{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}},Su=(e,t=null)=>new xu(e,t);Su(xu);var Cu=class extends bu{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}},wu=e=>new Cu(e);Su(Cu);var Tu=class extends bu{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}},Eu=(...e)=>new Tu(e),Du=Su(Tu),Ou=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),ku=e=>{if(ld.check(e))return[Ou(e)];if(Du.check(e))return e.shape.map(e=>e+``);if(cd.check(e))return[`[+-]?\\d+.?\\d*`];if(ud.check(e))return[`.*`];if(ed.check(e))return e.shape.map(ku).flat(1);tl()};Su(class extends bu{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(ku).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 Au=Symbol(`optional`),ju=class extends bu{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[Au](){return!0}},Mu=Su(ju),Nu=class extends bu{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Nu,Su(Nu);var Pu=class e extends bu{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):Rl(this.shape,(n,r)=>{let i=this._isPartial&&!zl(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Fu=e=>new Pu(e),Iu=Su(Pu),Lu=wu(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Ru=class extends bu{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Rl(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)})}},zu=(e,t)=>new Ru(e,t),Bu=Su(Ru),Vu=class extends bu{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Rl(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},Hu=(...e)=>new Vu(e);Su(Vu);var Uu=class extends bu{constructor(e){super(),this.shape=e.length===1?e[0]:new Qu(e)}check(e,t){let n=Ks(e)&&Us(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},Wu=(...e)=>new Uu(e),Gu=Su(Uu),Ku=wu(e=>Ks(e)),qu=class extends bu{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}},Ju=(e,t=null)=>new qu(e,t);Su(qu);var Yu=Ju(bu),Xu=Su(class extends bu{constructor(e){super(),this.len=e.length-1,this.args=Hu(...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}}),Zu=wu(e=>typeof e==`function`);Su(class extends bu{constructor(e){super(),this.shape=e}check(e,t){let n=Us(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Qu=class extends bu{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Ws(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},$u=(...e)=>e.findIndex(e=>ed.check(e))>=0?$u(...e.map(e=>_d(e)).map(e=>ed.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Qu(e),ed=Su(Qu),td=()=>!0,nd=wu(td),rd=Su(Cu,e=>e.shape===td),id=wu(e=>typeof e==`bigint`),ad=wu(e=>e===id),od=wu(e=>typeof e==`symbol`);wu(e=>e===od);var sd=wu(e=>typeof e==`number`),cd=wu(e=>e===sd),ld=wu(e=>typeof e==`string`),ud=wu(e=>e===ld),dd=wu(e=>typeof e==`boolean`),fd=wu(e=>e===dd),pd=Eu(void 0);Su(Tu,e=>e.shape.length===1&&e.shape[0]===void 0),Eu(void 0);var md=Eu(null),hd=Su(Tu,e=>e.shape.length===1&&e.shape[0]===null);Su(Uint8Array),Su(xu,e=>e.shape===Uint8Array);var gd=$u(sd,ld,md,pd,id,dd,od);(()=>{let e=Wu(nd),t=zu(ld,nd),n=$u(sd,ld,md,dd,e,t);return e.shape=n,t.shape.values=n,n})();var _d=e=>{if(Yu.check(e))return e;if(Lu.check(e)){let t={};for(let n in e)t[n]=_d(e[n]);return Fu(t)}else if(Ku.check(e))return $u(...e.map(_d));else if(gd.check(e))return Eu(e);else if(Zu.check(e))return Su(e);tl()},vd=tu?()=>{}:(e,t)=>{let n=new vu;if(!t.check(e,n))throw $c(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},yd=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:_d(e),h:t}),this}else(e){return this.if(nd,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 $c(`Unhandled pattern`)}}},bd=(e=>new yd(e))(nd).if(cd,(e,t)=>du(t,pc,fc)).if(ud,(e,t)=>hu(t)).if(fd,(e,t)=>uu(t)).if(ad,(e,t)=>BigInt(du(t,pc,fc))).if(ed,(e,t)=>xd(t,gu(t,e.shape))).if(Iu,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Mu.check(i)){if(uu(t))continue;i=i.shape}n[r]=bd(i,t)}return n}).if(Gu,(e,t)=>{let n=[],r=fu(t,0,42);for(let i=0;i<r;i++)n.push(xd(t,e.shape));return n}).if(Du,(e,t)=>gu(t,e.shape)).if(hd,(e,t)=>null).if(Xu,(e,t)=>{let n=xd(t,e.res);return()=>n}).if(rd,(e,t)=>xd(t,gu(t,[sd,ld,md,pd,id,dd,Wu(sd),zu($u(`a`,`b`,`c`),sd)]))).if(Bu,(e,t)=>{let n={},r=du(t,0,3);for(let i=0;i<r;i++){let r=xd(t,e.shape.keys);n[r]=xd(t,e.shape.values)}return n}).done(),xd=(e,t)=>bd(_d(t),e),Sd=typeof document<`u`?document:{},Cd=e=>Sd.createElement(e),wd=()=>Sd.createDocumentFragment();wu(e=>e.nodeType===Id);var Td=e=>Sd.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Ed=(e,t)=>(lu(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),Dd=e=>{let t=wd();for(let n=0;n<e.length;n++)Md(t,e[n]);return t},Od=(e,t)=>(Md(e,Dd(t)),e),kd=(e,t=[],n=[])=>Od(Ed(Cd(e),t),n);wu(e=>e.nodeType===Nd);var Ad=Td;wu(e=>e.nodeType===Pd);var jd=e=>Ls(e,(e,t)=>`${t}:${e};`).join(``),Md=(e,t)=>e.appendChild(t),Nd=Sd.ELEMENT_NODE,Pd=Sd.TEXT_NODE;Sd.CDATA_SECTION_NODE,Sd.COMMENT_NODE;var Fd=Sd.DOCUMENT_NODE;Sd.DOCUMENT_TYPE_NODE;var Id=Sd.DOCUMENT_FRAGMENT_NODE;wu(e=>e.nodeType===Fd);var Ld=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),Rd=(e,t)=>new Ld(setTimeout(t,e)),zd=Symbol,Bd=zd(),Vd=zd(),Hd=zd(),Ud=zd(),Wd=zd(),Gd=zd(),Kd=zd(),qd=zd(),Jd=zd(),Yd=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};Tl();var Xd={[Bd]:cu(`font-weight`,`bold`),[Vd]:cu(`font-weight`,`normal`),[Hd]:cu(`color`,`blue`),[Wd]:cu(`color`,`green`),[Ud]:cu(`color`,`grey`),[Gd]:cu(`color`,`red`),[Kd]:cu(`color`,`purple`),[qd]:cu(`color`,`orange`),[Jd]:cu(`color`,`black`)},Zd=nu?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=Ps(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=Xd[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=jd(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}:Yd,Qd=(...e)=>{console.log(...Zd(e)),ef.forEach(t=>t.print(e))},$d=(...e)=>{console.warn(...Zd(e)),e.unshift(qd),ef.forEach(t=>t.print(e))},ef=zs(),tf=e=>({[Symbol.iterator](){return this},next:e}),nf=(e,t)=>tf(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),rf=(e,t)=>tf(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),af=class{constructor(e,t){this.clock=e,this.len=t}},of=class{constructor(){this.clients=new Map}},sf=(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])Tp(e,i,o.clock,o.len,n)}}),cf=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=Js((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},lf=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&cf(n,t.clock)!==null},uf=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 af(r.clock,Zs(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},df=e=>{let t=new of;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++)Vs(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return uf(t),t},ff=(e,t,n,r)=>{Is(e.clients,t,()=>[]).push(new af(n,r))},pf=()=>new of,mf=e=>{let t=pf();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 af(i,a))}}r.length>0&&t.clients.set(n,r)}),t},hf=(e,t)=>{Y(e.restEncoder,t.clients.size),Hs(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),Y(e.restEncoder,t);let r=n.length;Y(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},gf=e=>{let t=new of,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=Is(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new af(e.readDsClock(),e.readDsLen()))}}return t},_f=(e,t,n)=>{let r=new of,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=_p(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&ff(r,i,s,a-s);let e=yp(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Hh(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,Hh(t,c,a-c.id.clock)),c.delete(t))}else ff(r,i,n,a-n)}}if(r.clients.size>0){let e=new Df;return Y(e.restEncoder,0),hf(e,r),e.toUint8Array()}return null},vf=xl,yf=class e extends qs{constructor({guid:e=wl(),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=vf(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new hp,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=El(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>El(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&&Np(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Hs(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Np(this,e,t)}get(e,t=lm){let n=Is(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==lm&&r!==t)if(r===lm){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,Am)}getText(e=``){return this.get(e,Zm)}getMap(e=``){return this.get(e,Nm)}getXmlElement(e=``){return this.get(e,nh)}getXmlFragment(e=``){return this.get(e,eh)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,Hs(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,Np(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()}},bf=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return X(this.restDecoder)}readDsLen(){return X(this.restDecoder)}},xf=class extends bf{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 ll(this.restDecoder)}readString(){return dl(this.restDecoder)}readParentInfo(){return X(this.restDecoder)===1}readTypeRef(){return X(this.restDecoder)}readLen(){return X(this.restDecoder)}readAny(){return ml(this.restDecoder)}readBuf(){return au(cl(this.restDecoder))}readJSON(){return JSON.parse(dl(this.restDecoder))}readKey(){return dl(this.restDecoder)}},Sf=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}},Cf=class extends Sf{constructor(e){super(e),this.keys=[],X(e),this.keyClockDecoder=new _l(cl(e)),this.clientDecoder=new gl(cl(e)),this.leftClockDecoder=new _l(cl(e)),this.rightClockDecoder=new _l(cl(e)),this.infoDecoder=new hl(cl(e),ll),this.stringDecoder=new vl(cl(e)),this.parentInfoDecoder=new hl(cl(e),ll),this.typeRefDecoder=new gl(cl(e)),this.lenDecoder=new gl(cl(e))}readLeftID(){return new Xf(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Xf(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 ml(this.restDecoder)}readBuf(){return cl(this.restDecoder)}readJSON(){return ml(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}}},wf=class{constructor(){this.restEncoder=Dc()}toUint8Array(){return Ac(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Y(this.restEncoder,e)}writeDsLen(e){Y(this.restEncoder,e)}},Tf=class extends wf{writeLeftID(e){Y(this.restEncoder,e.client),Y(this.restEncoder,e.clock)}writeRightID(e){Y(this.restEncoder,e.client),Y(this.restEncoder,e.clock)}writeClient(e){Y(this.restEncoder,e)}writeInfo(e){Nc(this.restEncoder,e)}writeString(e){Lc(this.restEncoder,e)}writeParentInfo(e){Y(this.restEncoder,+!!e)}writeTypeRef(e){Y(this.restEncoder,e)}writeLen(e){Y(this.restEncoder,e)}writeAny(e){Kc(this.restEncoder,e)}writeBuf(e){zc(this.restEncoder,e)}writeJSON(e){Lc(this.restEncoder,JSON.stringify(e))}writeKey(e){Lc(this.restEncoder,e)}},Ef=class{constructor(){this.restEncoder=Dc(),this.dsCurrVal=0}toUint8Array(){return Ac(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,Y(this.restEncoder,t)}writeDsLen(e){e===0&&tl(),Y(this.restEncoder,e-1),this.dsCurrVal+=e}},Df=class extends Ef{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Zc,this.clientEncoder=new Yc,this.leftClockEncoder=new Zc,this.rightClockEncoder=new Zc,this.infoEncoder=new qc(Nc),this.stringEncoder=new Qc,this.parentInfoEncoder=new qc(Nc),this.typeRefEncoder=new Yc,this.lenEncoder=new Yc}toUint8Array(){let e=Dc();return Y(e,0),zc(e,this.keyClockEncoder.toUint8Array()),zc(e,this.clientEncoder.toUint8Array()),zc(e,this.leftClockEncoder.toUint8Array()),zc(e,this.rightClockEncoder.toUint8Array()),zc(e,Ac(this.infoEncoder)),zc(e,this.stringEncoder.toUint8Array()),zc(e,Ac(this.parentInfoEncoder)),zc(e,this.typeRefEncoder.toUint8Array()),zc(e,this.lenEncoder.toUint8Array()),Rc(e,Ac(this.restEncoder)),Ac(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){Kc(this.restEncoder,e)}writeBuf(e){zc(this.restEncoder,e)}writeJSON(e){Kc(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)}},Of=(e,t,n,r)=>{r=Zs(r,t[0].id.clock);let i=yp(t,r);Y(e.restEncoder,t.length-i),e.writeClient(n),Y(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)},kf=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{_p(t,n)>e&&r.set(n,e)}),gp(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),Y(e.restEncoder,r.size),Hs(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Of(e,t.clients.get(n),n,r)})},Af=(e,t)=>{let n=Ps(),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 dh(Z(a,o),t),o+=t;break}case 10:{let t=X(e.restDecoder);i[n]=new Yh(Z(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new Gh(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,Kh(e,r));i[n]=c,o+=c.length}}}}return n},jf=(e,t,n)=>{let r=[],i=Hs(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 hp,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!==Yh){let i=Is(d,u.id.client,()=>_p(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,_p(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 Df;return kf(e,s,new Map),Y(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Mf=(e,t)=>kf(e,t.doc.store,t.beforeState),Nf=(e,t,n,r=new Cf(e))=>Np(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=jf(e,i,Af(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<_p(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=Up([o.update,a.update])}}else i.pendingStructs=a;let s=_f(r,e,i);if(i.pendingDs){let t=new Cf(al(i.pendingDs));X(t.restDecoder);let n=_f(t,e,i);s&&n?i.pendingDs=Up([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Pf(e.doc,t)}},n,!1),Pf=(e,t,n,r=Cf)=>{let i=al(t);Nf(i,e,n,new r(i))},Ff=(e,t,n)=>Pf(e,t,n,xf),If=(e,t,n=new Map)=>{kf(e,t.store,n),hf(e,mf(t.store))},Lf=(e,t=new Uint8Array([0]),n=new Df)=>{If(n,e,Bf(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Wp(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Tf)return Vp(r.map((e,t)=>t===0?e:Yp(e)));if(n.constructor===Df)return Up(r)}return r[0]},Rf=(e,t)=>Lf(e,t,new Tf),zf=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},Bf=e=>zf(new bf(al(e))),Vf=(e,t)=>(Y(e.restEncoder,t.size),Hs(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{Y(e.restEncoder,t),Y(e.restEncoder,n)}),e),Hf=(e,t)=>Vf(e,gp(t.store)),Uf=(e,t=new Ef)=>(e instanceof Map?Vf(t,e):Hf(t,e),t.toUint8Array()),Wf=e=>Uf(e,new wf),Gf=class{constructor(){this.l=[]}},Kf=()=>new Gf,qf=(e,t)=>e.l.push(t),Jf=(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.`)},Yf=(e,t,n)=>Ul(e.l,[t,n]),Xf=class{constructor(e,t){this.client=e,this.clock=t}},Zf=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,Z=(e,t)=>new Xf(e,t),Qf=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw tl()},$f=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},ep=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},tp=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},np=e=>new ep(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),rp=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},ip=(e,t,n=0)=>new rp(e,t,n),ap=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Qf(e):r=Z(e._item.id.client,e._item.id.clock),new ep(r,i,t,n)},op=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return ap(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return ap(e,Z(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return ap(e,r.lastId,n);r=r.right}return ap(e,null,n)},sp=(e,t)=>{let n=bp(e,t);return{item:n,diff:t.clock-n.id.clock}},cp=(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(_p(r,i.client)<=i.clock)return null;let e=n?Bh(r,i):sp(r,i),t=e.item;if(!(t instanceof Gh))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(_p(r,a.client)<=a.clock)return null;let{item:e}=n?Bh(r,a):{item:bp(r,a)};if(e instanceof Gh&&e.content instanceof Rh)c=e.content.type;else return null}else throw tl();l=s>=0?c._length:0}return ip(c,l,e.assoc)},lp=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Zf(e.item,t.item)&&Zf(e.type,t.type)&&e.assoc===t.assoc,up=class{constructor(e,t){this.ds=e,this.sv=t}},dp=(e,t)=>new up(e,t);dp(pf(),new Map);var fp=e=>dp(mf(e.store),gp(e.store)),pp=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!lf(t.ds,e.id),mp=(e,t)=>{let n=Is(e.meta,mp,zs),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<_p(r,n)&&Sp(e,Z(n,t))}),sf(e,t.ds,e=>{}),n.add(t))},hp=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},gp=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},_p=(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},vp=(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 tl()}n.push(t)},yp=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=Js(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=Js((n+r)/2)}throw tl()},bp=(e,t)=>{let n=e.clients.get(t.client);return n[yp(n,t.clock)]},xp=(e,t,n)=>{let r=yp(t,n),i=t[r];return i.id.clock<n&&i instanceof Gh?(t.splice(r+1,0,Hh(e,i,n-i.id.clock)),r+1):r},Sp=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[xp(e,n,t.clock)]},Cp=(e,t,n)=>{let r=t.clients.get(n.client),i=yp(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==dh&&r.splice(i+1,0,Hh(e,a,n.clock-a.id.clock+1)),a},wp=(e,t,n)=>{let r=e.clients.get(t.id.client);r[yp(r,t.id.clock)]=n},Tp=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=xp(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&xp(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Ep=class{constructor(e,t,n){this.doc=e,this.deleteSet=new of,this.beforeState=gp(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}},Dp=(e,t)=>t.deleteSet.clients.size===0&&!Rs(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(uf(t.deleteSet),Mf(e,t),hf(e,t.deleteSet),!0),Op=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Is(e.changed,t,zs).add(n)},kp=(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 Gh&&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},Ap=(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=yp(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 Gh&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},jp=(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=Xs(r.length-1,1+yp(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+kp(r,e)}})},Mp=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{uf(a),n.afterState=gp(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(()=>{Yf(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Jm(n)})}),Ul(e,[])}finally{r.gc&&Ap(a,i,r.gcFilter),jp(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=Zs(yp(e,r),1);for(let t=e.length-1;t>=n;)t-=1+kp(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=yp(r,n);a+1<r.length&&kp(r,a+1)>1||a>0&&kp(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Qd(qd,Bd,`[yjs] `,Vd,Gd,`Changed the client-id because another client seems to be using it.`),r.clientID=vf()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Tf;Dp(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Df;Dp(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])):Mp(e,t+1)}}},Np=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Ep(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&&Mp(i,0)}}return o},Pp=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Fp=(e,t,n)=>{sf(e,n.deletions,n=>{n instanceof Gh&&t.scope.some(t=>t===e.doc||$f(t,n))&&Vh(n,!1)})},Ip=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;Np(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;sf(n,o.insertions,e=>{if(e instanceof Gh){if(e.redone!==null){let{item:t,diff:i}=Bh(r,e.id);i>0&&(t=Sp(n,Z(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||$f(t,e))&&c.push(e)}}),sf(n,o.deletions,e=>{e instanceof Gh&&a.some(t=>t===n.doc||$f(t,e))&&!lf(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Wh(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},Lp=class extends qs{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=Ks(e)?e[0].doc:e instanceof yf?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 of;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&ff(i,n,r,a)});let a=Tl(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=df([t.deletions,e.deleteSet]),t.insertions=df([t.insertions,i])}else r.push(new Pp(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),sf(e,e.deleteSet,t=>{t instanceof Gh&&this.scope.some(n=>n===e.doc||$f(n,t))&&Vh(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=Ks(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof lm?e.doc!==this.doc:e!==this.doc)&&$d(`[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=>Fp(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Fp(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=Ip(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Ip(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*Rp(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 Yh(Z(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new Gh(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,Kh(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new dh(Z(n,r),t),r+=t}}}}var zp=class{constructor(e,t){this.gen=Rp(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===Yh);return this.curr}},Bp=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Vp=e=>Up(e,xf,Tf),Hp=(e,t)=>{if(e.constructor===dh){let{client:n,clock:r}=e.id;return new dh(Z(n,r+t),e.length-t)}else if(e.constructor===Yh){let{client:n,clock:r}=e.id;return new Yh(Z(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new Gh(Z(r,i+t),null,Z(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Up=(e,t=Cf,n=Df)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(al(e))),i=r.map(e=>new zp(e,!0)),a=null,o=new n,s=new Bp(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===Yh?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)Kp(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===Yh)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Kp(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Yh(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===Yh?a.struct.length-=t:n=Hp(n,t)),a.struct.mergeWith(n)||(Kp(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!==Yh;n=e.next())Kp(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Kp(s,a.struct,a.offset),a=null),qp(s),hf(o,df(r.map(e=>gf(e)))),o.toUint8Array()},Wp=(e,t,n=Cf,r=Df)=>{let i=Bf(t),a=new r,o=new Bp(a),s=new n(al(e)),c=new zp(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Yh){c.next();continue}if(e.id.clock+e.length>n)for(Kp(o,e,Zs(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Kp(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 qp(o),hf(a,gf(s)),a.toUint8Array()},Gp=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Ac(e.encoder.restEncoder)}),e.encoder.restEncoder=Dc(),e.written=0)},Kp=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Gp(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Y(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},qp=e=>{Gp(e);let t=e.encoder.restEncoder;Y(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];Y(t,r.written),Rc(t,r.restEncoder)}},Jp=(e,t,n,r)=>{let i=new n(al(e)),a=new zp(i,!1),o=new r,s=new Bp(o);for(let e=a.curr;e!==null;e=a.next())Kp(s,t(e),0);return qp(s),hf(o,gf(i)),o.toUint8Array()},Yp=e=>Jp(e,Wl,Cf,Tf),Xp=`You must not compute changes after the event-handler fired.`,Zp=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||=Qp(this.currentTarget,this.target)}deletes(e){return lf(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw $c(Xp);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=Bs(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=Bs(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=Bs(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 $c(Xp);let t=this.target,n=zs(),r=zs(),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}},Qp=(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},$p=()=>{$d(`Invalid access: Add Yjs type to a document before reading data.`)},em=80,tm=0,nm=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=tm++}},rm=e=>{e.timestamp=tm++},im=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=tm++},am=(e,t,n)=>{if(e.length>=em){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return im(r,t,n),r}else{let r=new nm(t,n);return e.push(r),r}},om=(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)=>Ys(t-e.index)<Ys(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,rm(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&&Ys(n.index-i)<r.parent.length/em?(im(n,r,i),n):am(e._searchMarker,r,i)},sm=(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=Zs(t,i.index+n))}},cm=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;Is(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Yf(r._eH,n,t)},lm=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Kf(),this._dEH=Kf(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw el()}clone(){throw el()}_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){qf(this._eH,e)}observeDeep(e){qf(this._dEH,e)}unobserve(e){Jf(this._eH,e)}unobserveDeep(e){Jf(this._dEH,e)}toJSON(){}},um=(e,t,n)=>{e.doc??$p(),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},dm=e=>{e.doc??$p();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},fm=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&pp(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},pm=(e,t)=>{let n=0,r=e._start;for(e.doc??$p();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}},mm=(e,t)=>{let n=[];return pm(e,(r,i)=>{n.push(t(r,i,e))}),n},hm=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}}}},gm=(e,t)=>{e.doc??$p();let n=om(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}},_m=(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 Gh(Z(o,_p(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Eh(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 Gh(Z(o,_p(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new fh(new Uint8Array(n))),i.integrate(e,0);break;case yf:i=new Gh(Z(o,_p(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new _h(n)),i.integrate(e,0);break;default:if(n instanceof lm)i=new Gh(Z(o,_p(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Rh(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},vm=()=>$c(`Length exceeded!`),ym=(e,t,n,r)=>{if(n>t._length)throw vm();if(n===0)return t._searchMarker&&sm(t._searchMarker,n,r.length),_m(e,t,null,r);let i=n,a=om(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&&Sp(e,Z(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&sm(t._searchMarker,i,r.length),_m(e,t,o,r)},bm=(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 _m(e,t,r,n)},xm=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=om(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&&Sp(e,Z(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&Sp(e,Z(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw vm();t._searchMarker&&sm(t._searchMarker,i,-a+r)},Sm=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Cm=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Eh([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Eh([r]);break;case Uint8Array:s=new fh(r);break;case yf:s=new _h(r);break;default:if(r instanceof lm)s=new Rh(r);else throw Error(`Unexpected content type`)}new Gh(Z(o,_p(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},wm=(e,t)=>{e.doc??$p();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Tm=e=>{let t={};return e.doc??$p(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Em=(e,t)=>{e.doc??$p();let n=e._map.get(t);return n!==void 0&&!n.deleted},Dm=(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&&pp(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Om=e=>(e.doc??$p(),nf(e._map.entries(),e=>!e[1].deleted)),km=class extends Zp{},Am=class e extends lm{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 lm?e.clone():e)),t}get length(){return this.doc??$p(),this._length}_callObserver(e,t){super._callObserver(e,t),cm(this,e,new km(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Np(this.doc,n=>{ym(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):Np(this.doc,t=>{bm(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Np(this.doc,n=>{xm(n,this,e,t)})}get(e){return gm(this,e)}toArray(){return dm(this)}slice(e=0,t=this.length){return um(this,e,t)}toJSON(){return this.map(e=>e instanceof lm?e.toJSON():e)}map(e){return mm(this,e)}forEach(e){pm(this,e)}[Symbol.iterator](){return hm(this)}_write(e){e.writeTypeRef(jh)}},jm=e=>new Am,Mm=class extends Zp{constructor(e,t,n){super(e,t),this.keysChanged=n}},Nm=class e extends lm{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 lm?e.clone():e)}),t}_callObserver(e,t){cm(this,e,new Mm(this,e,t))}toJSON(){this.doc??$p();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof lm?r.toJSON():r}}),e}get size(){return[...Om(this)].length}keys(){return rf(Om(this),e=>e[0])}values(){return rf(Om(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return rf(Om(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??$p(),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):Np(this.doc,t=>{Sm(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):Np(this.doc,n=>{Cm(n,this,e,t)}),t}get(e){return wm(this,e)}has(e){return Em(this,e)}clear(){this.doc===null?this._prelimContent.clear():Np(this.doc,e=>{this.forEach(function(t,n,r){Sm(e,r,n)})})}_write(e){e.writeTypeRef(Mh)}},Pm=e=>new Nm,Fm=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&Bl(e,t),Im=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&tl(),this.right.content.constructor){case xh:this.right.deleted||Bm(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}},Lm=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case xh:t.right.deleted||Bm(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&Sp(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},Rm=(e,t,n,r)=>{let i=new Map,a=r?om(t,n):null;return a?Lm(e,new Im(a.p.left,a.p,a.index,i),n-a.index):Lm(e,new Im(null,t._start,0,i),n)},zm=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===xh&&Fm(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 Gh(Z(a,_p(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new xh(o,r));l.integrate(e,0),n.right=l,n.forward()})},Bm=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Vm=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===xh&&Fm(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Hm=(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(!Fm(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Gh(Z(a,_p(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new xh(s,c)),n.right.integrate(e,0),n.forward()}}return o},Um=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Vm(n,i);let s=Hm(e,t,n,i),c=r.constructor===String?new Oh(r):r instanceof lm?new Rh(r):new yh(r),{left:l,right:u,index:d}=n;t._searchMarker&&sm(t._searchMarker,n.index,c.getLength()),u=new Gh(Z(o,_p(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(),zm(e,t,n,s)},Wm=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Vm(n,i);let s=Hm(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===xh));){if(!n.right.deleted)switch(n.right.content.constructor){case xh:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Fm(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&&Sp(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+=`
47
47
  `;n.right=new Gh(Z(o,_p(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Oh(i)),n.right.integrate(e,0),n.forward()}zm(e,t,n,s)},Gm=(e,t,n,r,i)=>{let a=t,o=Ps();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===xh){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 xh:{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&&Bm(i,n);break}}}t=t.right}return s},Km=(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===xh){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},qm=e=>{let t=0;return Np(e.doc,n=>{let r=e._start,i=e._start,a=Ps(),o=Fs(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case xh:Bm(o,i.content);break;default:t+=Gm(n,r,i,a,o),a=Fs(o),r=i;break}i=i.right}}),t},Jm=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&&Tp(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===xh&&e.constructor!==dh&&t.add(e.parent)})}Np(n,n=>{sf(e,e.deleteSet,e=>{if(e instanceof dh||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===xh?t.add(r):Km(n,e)});for(let e of t)qm(e)})},Ym=(e,t,n)=>{let r=n,i=Fs(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Rh:case yh:case Oh:n<t.right.length&&Sp(e,Z(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&Gm(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&sm(o._searchMarker,t.index,-r+n),t},Xm=class extends Zp{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=[];Np(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},Ll(o)||(e.attributes=Nl({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Rh:case yh: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 Oh: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 xh:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Fm(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Fm(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;Fm(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Fm(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Bm(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}},Zm=class e extends lm{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??$p(),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 Xm(this,e,t);cm(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??$p();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Oh&&(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)):Np(this.doc,n=>{let r=new Im(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)===`
48
- `?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Um(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&Ym(n,r,a.delete):Wm(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??$p();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(pp(s,e)||t!==void 0&&pp(s,t))switch(s.content.constructor){case Oh:{let r=i.get(`ychange`);e!==void 0&&!pp(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&&!pp(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 Rh:case yh:{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 xh:pp(s,e)&&(c(),Bm(i,s.content));break}s=s.right}c()};return e||t?Np(a,n=>{e&&mp(n,e),t&&mp(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)):Np(r,r=>{let i=Rm(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Um(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Np(r,r=>{let i=Rm(r,this,e,!n);Um(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)):Np(n,n=>{Ym(n,Rm(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)):Np(r,r=>{let i=Rm(r,this,e,!1);i.right!==null&&Wm(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Np(this.doc,t=>{Sm(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Np(this.doc,n=>{Cm(n,this,e,t)})}getAttribute(e){return wm(this,e)}getAttributes(){return Tm(this)}_write(e){e.writeTypeRef(Nh)}},Qm=e=>new Zm,$m=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??$p()}[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===nh||t.constructor===eh)&&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})}},eh=class e extends lm{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 lm?e.clone():e)),t}get length(){return this.doc??$p(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new $m(this,e)}querySelector(e){e=e.toUpperCase();let t=new $m(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Hs(new $m(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){cm(this,e,new ih(this,t,e))}toString(){return mm(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),pm(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Np(this.doc,n=>{ym(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Np(this.doc,n=>{let r=e&&e instanceof lm?e._item:e;_m(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 $c(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Np(this.doc,n=>{xm(n,this,e,t)})}toArray(){return dm(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return gm(this,e)}slice(e=0,t=this.length){return um(this,e,t)}forEach(e){pm(this,e)}_write(e){e.writeTypeRef(Fh)}},th=e=>new eh,nh=class e extends eh{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 Fl(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof lm?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):Np(this.doc,t=>{Sm(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Np(this.doc,n=>{Cm(n,this,e,t)})}getAttribute(e){return wm(this,e)}hasAttribute(e){return Em(this,e)}getAttributes(e){return e?Dm(this,e):Tm(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 pm(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ph),e.writeKey(this.nodeName)}},rh=e=>new nh(e.readKey()),ih=class extends Zp{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)})}},ah=class e extends Nm{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(Ih),e.writeKey(this.hookName)}},oh=e=>new ah(e.readKey()),sh=class e extends Zm{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(Lh)}},ch=e=>new sh,lh=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw el()}mergeWith(e){return!1}write(e,t,n){throw el()}integrate(e,t){throw el()}},uh=0,dh=class extends lh{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),vp(e.doc.store,this)}write(e,t){e.writeInfo(uh),e.writeLen(this.length-t)}getMissing(e,t){return null}},fh=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 el()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},ph=e=>new fh(e.readBuf()),mh=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){ff(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}},hh=e=>new mh(e.readLen()),gh=(e,t)=>new yf({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),_h=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(gh(this.doc.guid,this.opts))}splice(e){throw el()}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}},vh=e=>new _h(gh(e.readString(),e.readAny())),yh=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 el()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},bh=e=>new yh(e.readJSON()),xh=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 el()}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}},Sh=e=>new xh(e.readKey(),e.readJSON()),Ch=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}},wh=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 Ch(n)},Th=$l(`node_env`)===`development`,Eh=class e{constructor(e){this.arr=e,Th&&Hl(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}},Dh=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Eh(n)},Oh=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}},kh=e=>new Oh(e.readString()),Ah=[jm,Pm,Qm,rh,th,oh,ch],jh=0,Mh=1,Nh=2,Ph=3,Fh=4,Ih=5,Lh=6,Rh=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 el()}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}},zh=e=>new Rh(Ah[e.readTypeRef()](e)),Bh=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Z(n.client,n.clock+r)),i=bp(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Gh);return{item:i,diff:r}},Vh=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Hh=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Gh(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},Uh=(e,t)=>Ws(e,e=>lf(e.deletions,t)),Wh=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Sp(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Wh(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Sp(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:Sp(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:Sp(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||lf(r,d.right.id)||Uh(a.undoStack,d.right.id)||Uh(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Sp(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=Z(c,_p(s,c)),h=new Gh(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,Vh(h,!0),h.integrate(e,0),h},Gh=class e extends lh{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>=_p(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=_p(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Xf&&this.id.client!==this.parent.client&&this.parent.clock>=_p(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Cp(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Sp(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===dh||this.right&&this.right.constructor===dh)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===Xf){let e=bp(n,this.parent);e.constructor===dh?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Cp(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),Zf(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(Zf(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(bp(e.doc.store,n.origin)))r.has(bp(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),vp(e.doc.store,this),this.content.integrate(e,this),Op(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new dh(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&&Zf(e.origin,this.lastId)&&this.right===e&&Zf(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(),ff(e.deleteSet,this.id.client,this.id.clock,this.length),Op(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw tl();this.content.gc(e),t?wp(e,this,new dh(this.id,this.length)):this.content=new mh(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=Qf(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===Xf?(e.writeParentInfo(!1),e.writeLeftID(t)):tl();i!==null&&e.writeString(i)}this.content.write(e,t)}},Kh=(e,t)=>qh[t&31](e),qh=[()=>{tl()},hh,wh,ph,kh,bh,Sh,zh,Dh,vh,()=>{tl()}],Jh=10,Yh=class extends lh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){tl()}write(e,t){e.writeInfo(Jh),Y(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Xh=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Zh=`__ $YJS$ __`;Xh[Zh]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Xh[Zh]=!0;var Qh=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},$h=/[\uD800-\uDBFF]/,eg=/[\uDC00-\uDFFF]/,tg=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&$h.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&&eg.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},ng=(e,t)=>e>>>t|e<<32-t,rg=e=>ng(e,2)^ng(e,13)^ng(e,22),ig=e=>ng(e,6)^ng(e,11)^ng(e,25),ag=e=>ng(e,7)^ng(e,18)^e>>>3,og=e=>ng(e,17)^ng(e,19)^e>>>10,sg=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]),cg=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),lg=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(cg),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=og(t[e-2])+t[e-7]+ag(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+ig(o)+(o&s^~o&c)+sg[e]+t[e]>>>0,d=rg(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/dc,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}},ug=e=>new lg().digest(e),dg=new C(`y-sync`),fg=new C(`y-undo`),pg=new C(`yjs-cursor`),mg=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},hg=e=>iu(mg(ug(ou(e)))),gg=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!lf(t.ds,e.id),_g=[{light:`#ecd44433`,dark:`#ecd444`}],vg=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=zs();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Sl(t))}return e.get(n)},yg=(e,{colors:t=_g,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,c=new Cg(e,a),l=new s({props:{editable:e=>{let t=dg.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:dg,state:{init:(i,a)=>({type:e,doc:e.doc,binding:c,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(dg);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,c.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&Rd(0,()=>{c.prosemirrorView!=null&&(n.restore==null?c._renderSnapshot(n.snapshot,n.prevSnapshot,t):(c._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,c.mux(()=>{c._prosemirrorChanged(c.prosemirrorView.state.doc)})))}),t}},view:e=>(c.initView(e),a??c._forceRerender(),i(),{update:()=>{let t=l.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=fg.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}c.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),c._prosemirrorChanged(e.state.doc)},dg)})}},destroy:()=>{c.destroy()}})});return l},bg=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new k(e.doc));else if(t.type===`node`){let r=Qg(n.doc,n.type,t.anchor,n.mapping);e.setSelection(xg(e,r))}else{let r=Qg(n.doc,n.type,t.anchor,n.mapping),i=Qg(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(pe.between(e.doc.resolve(r),e.doc.resolve(i)))}},xg=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?l.create(e.doc,t):pe.near(n)},Sg=(e,t)=>({type:t.selection.jsonID,anchor:Xg(t.selection.anchor,e.type,e.mapping),head:Xg(t.selection.head,e.type,e.mapping)}),Cg=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=Qh(),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=Sg(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()?(Jl&&this._domSelectionInView===null&&(Rd(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=Sd.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||=dp(pf(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(dg,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>Tg(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new d(x.from(e),0,0));t.setMeta(dg,{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=>Tg(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new d(x.from(t),0,0));if(e){let t=Xs(Zs(e.anchor,0),n.doc.content.size),r=Xs(Zs(e.head,0),n.doc.content.size);n.setSelection(pe.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(dg,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=fp(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&tl(),r=new yf({gc:!1}),Pf(r,t),t=fp(r),Pf(r,e),e=fp(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[yp(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{sf(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:vg(n.colorMapping,n.colors,r)}},s=fm(i,new up(t.ds,e.sv)).map(n=>!n._item.deleted||gg(n._item,e)||gg(n._item,t)?Tg(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 d(x.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(dg,{isChangeOrigin:!0}))},dg)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=dg.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);sf(t,t.deleteSet,e=>{if(e.constructor===Gh){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=>wg(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new d(x.from(n),0,0));bg(r,this.beforeTransactionSelection,this),r=r.setMeta(dg,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof Lp}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{Ug(this.doc,this.type,e,this),this.beforeTransactionSelection=Sg(this,this.prosemirrorView.state)},dg)}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))}},wg=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof nh)return Tg(e,t,n,r,i,a);throw el()}return o},Tg=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof nh){let s=wg(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof Zm&&!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=Eg(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):fm(e,new up(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(gg(e._item,r)?gg(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}},Eg=(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,Vg(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},Dg=(e,t)=>{let n=new sh,r=e.map(e=>({insert:e.text,attributes:Hg(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},Og=(e,t)=>{let n=new nh(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,Mg(e).map(e=>kg(e,t))),t.mapping.set(n,e),n},kg=(e,t)=>e instanceof Array?Dg(e,t):Og(e,t),Ag=e=>typeof e==`object`&&!!e,jg=(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||Ag(o)&&Ag(s)&&jg(o,s)}return r},Mg=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},Ng=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&Pl(e.attributes||{}).length===t[n].marks.length&&Rl(e.attributes,(e,r)=>{let i=Bg(r),a=t[n].marks;return a.find(e=>e.type.name===i)?jg(e,a.find(e=>e.type.name===i)?.attrs):!1}))},Pg=(e,t)=>{if(e instanceof nh&&!(t instanceof Array)&&Wg(e,t)){let n=Mg(t);return e._length===n.length&&jg(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>Pg(e,n[t]))}return e instanceof sh&&t instanceof Array&&Ng(e,t)},Fg=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),Ig=(e,t,n)=>{let r=e.toArray(),i=Mg(t),a=i.length,o=r.length,s=Xs(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(Fg(n.mapping.get(e),t))u=!0;else if(!Pg(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(Fg(n.mapping.get(e),t))u=!0;else if(!Pg(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},Lg=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Oh?t+=n.content.str:n.content instanceof xh&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},Rg=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=Lg(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,Hg(e.marks,n))})),{insert:o,remove:s,index:c}=tg(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})))},zg=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Bg=e=>zg.exec(e)?.[1]??e,Vg=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(Bg(r),e[r]));return n},Hg=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=Is(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${hg(e.toJSON())}`:e.type.name]=e.attrs}}),n},Ug=(e,t,n,r)=>{if(t instanceof nh&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof nh){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=Mg(n),a=i.length,o=t.toArray(),s=o.length,c=Xs(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!Fg(r.mapping.get(e),t))if(Pg(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(!Fg(r.mapping.get(e),t))if(Pg(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 sh&&c instanceof Array)Ng(n,c)||Rg(n,c,r),l+=1;else{let i=n instanceof nh&&Wg(n,c),a=d instanceof nh&&Wg(d,f);if(i&&a){let e=Ig(n,c,r),t=Ig(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(Ug(e,n,c,r),l+=1):a?(Ug(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[kg(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof sh?(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(kg(i[t],r));t.insert(l,e)}},dg)},Wg=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,Gg=null,Kg=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=dg.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)}}},qg=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=Gg;Gg=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new Kg(t,r,e))})}),new e(n)}},Jg=(e=qg.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()||Rd(0,()=>Jg(e,!0));return}throw r}n=!1,e.dequeueFirst()}},Yg=(e,t,n)=>{Gg||(Gg=new Map,Rd(0,Jg)),Is(Gg,e,Ps).set(t,n)},Xg=(e,t,n)=>{if(e===0)return op(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof sh){if(r._length>=e)return op(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 ep(r._item===null?null:r._item.id,r._item===null?Qf(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 ep(r._item===null?null:r._item.id,r._item===null?Qf(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 tl();if(e===0&&r.constructor!==sh&&r!==t)return Zg(r._item.parent,r._item)}return op(t,t._length,-1)},Zg=(e,t)=>{let n=null,r=null;return e._item===null?r=Qf(e):n=Z(e._item.id.client,e._item.id.clock),new ep(n,r,t.id)},Qg=(e,t,n,r)=>{let i=cp(n,e);if(i===null||i.type!==t&&!$f(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===sh)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 sh?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 sh?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},$g=(e,t,n)=>e!==t,e_=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},t_=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),n_=/^#[0-9a-fA-F]{6}$/,r_=(e,t,n,r,i)=>{let o=dg.getState(e);if(o==null||o.doc==null||o.binding==null)return Be.create(e.doc,[]);let s=o.doc,c=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?Be.create(e.doc,[]):(t.getStates().forEach((t,l)=>{if(n(s.clientID,l,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:n_.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${l}`;let u=Qg(s,o.type,np(t.cursor.anchor),o.binding.mapping),d=Qg(s,o.type,np(t.cursor.head),o.binding.mapping);if(u!==null&&d!==null){let t=Zs(e.doc.content.size-1,0);u=Xs(u,t),d=Xs(d,t),c.push(a.widget(d,()=>r(n,l),{key:l+``,side:10}));let o=Xs(u,d),s=Zs(u,d);c.push(a.inline(o,s,i(n,l),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),Be.create(e.doc,c))},i_=(e,{awarenessStateFilter:t=$g,cursorBuilder:n=e_,selectionBuilder:r=t_,getSelection:i=e=>e.selection}={},a=`cursor`)=>new s({key:pg,state:{init(i,a){return r_(a,e,t,n,r)},apply(i,a,o,s){let c=dg.getState(s),l=i.getMeta(pg);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?r_(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>pg.getState(e)},view:t=>{let n=()=>{t.docView&&Yg(t,pg,{awarenessUpdated:!0})},r=()=>{let n=dg.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=Xg(o.anchor,n.type,n.binding.mapping),c=Xg(o.head,n.type,n.binding.mapping);(r.cursor==null||!lp(np(r.cursor.anchor),s)||!lp(np(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&Qg(n.doc,n.type,np(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)}}}}),a_=e=>{let t=fg.getState(e).undoManager;if(t!=null)return t.undo(),!0},o_=e=>{let t=fg.getState(e).undoManager;if(t!=null)return t.redo(),!0},s_=new Set([`paragraph`]),c_=(e,t)=>!(e instanceof Gh)||!(e.content instanceof Rh)||!(e.content.type instanceof Zm||e.content.type instanceof nh&&t.has(e.content.type.nodeName))||e.content.type._length===0,l_=({protectedNodes:e=s_,trackedOrigins:t=[],undoManager:n=null}={})=>new s({key:fg,state:{init:(r,i)=>{let a=dg.getState(i),o=n||new Lp(a.type,{trackedOrigins:new Set([dg].concat(t)),deleteFilter:t=>c_(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=dg.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:Sg(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=dg.getState(e.state),n=fg.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,fg.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()}}}});function u_(e){let t=(0,Yn.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,K.jsx)(Wa,{"data-slot":`dialog`,...n}),t[2]=n,t[3]=r),r}function d_(e){let t=(0,Yn.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,K.jsx)(Ga,{"data-slot":`dialog-portal`,...n}),t[2]=n,t[3]=r),r}function f_(e){let t=(0,Yn.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,K.jsx)(Xa,{"data-slot":`dialog-close`,className:`font-mono uppercase`,...n}),t[2]=n,t[3]=r),r}function p_(e){let t=(0,Yn.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=h(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(Ka,{"data-slot":`dialog-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function m_(e){let t=(0,Yn.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,showCloseButton:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?!0:a,s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,K.jsx)(p_,{}),t[5]=s):s=t[5];let c;t[6]===r?c=t[7]:(c=h(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,r),t[6]=r,t[7]=c);let l;t[8]===o?l=t[9]:(l=o&&(0,K.jsx)(Xa,{"data-slot":`dialog-close`,asChild:!0,children:(0,K.jsxs)(Ce,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,K.jsx)(Jn,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Close`})]})}),t[8]=o,t[9]=l);let u;return t[10]!==n||t[11]!==i||t[12]!==c||t[13]!==l?(u=(0,K.jsxs)(d_,{children:[s,(0,K.jsxs)(qa,{"data-slot":`dialog-content`,className:c,...i,children:[n,l]})]}),t[10]=n,t[11]=i,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function h_(e){let t=(0,Yn.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=h(`flex flex-col gap-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(`div`,{"data-slot":`dialog-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function g_(e){let t=(0,Yn.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,showCloseButton:a,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?!1:a,s;t[5]===r?s=t[6]:(s=h(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,r),t[5]=r,t[6]=s);let c;t[7]===o?c=t[8]:(c=o&&(0,K.jsx)(Xa,{asChild:!0,children:(0,K.jsx)(Ce,{variant:`outline`,children:`Close`})}),t[7]=o,t[8]=c);let l;return t[9]!==n||t[10]!==i||t[11]!==s||t[12]!==c?(l=(0,K.jsxs)(`div`,{"data-slot":`dialog-footer`,className:s,...i,children:[n,c]}),t[9]=n,t[10]=i,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function __(e){let t=(0,Yn.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=h(`font-heading text-base leading-none font-medium`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(Ja,{"data-slot":`dialog-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function v_(e){let t=(0,Yn.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=h(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(Ya,{"data-slot":`dialog-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function y_(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 b_(e){return typeof e==`object`&&!!e}function x_(e){return e===`files`||e===`backlinks`||e===`graph`||e===`sync-status`}function S_(e){let t;try{t=JSON.parse(e)}catch{return null}return!b_(t)||t.v!==1||!x_(t.ch)||typeof t.seq!=`number`?null:{v:1,ch:t.ch,seq:t.seq}}function C_(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function w_(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function T_(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var E_=2e3,D_=15e3;function O_(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??E_,r=e.maxDelayMs??D_,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 k_(){let e=(0,Yn.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,q.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,q.useRef)(i),[o,s]=(0,q.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=w_(typeof window<`u`?window:void 0);if(t){r(T_(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(T_(t))});return()=>{n()}}let n=O_({fetchConfig:y_,fallbackUrl:C_,now:Date.now,setTimeout:N_,clearTimeout:M_,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,q.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(j_),s(A_)},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 A_(e){return e+1}function j_(e){return{...e,terminal:!1,lastError:null}}function M_(e){return globalThis.clearTimeout(e)}function N_(e,t){return globalThis.setTimeout(e,t)}var P_=Math.floor,F_=(e,t)=>e<t?e:t,I_=(e,t)=>e>t?e:t;Number.isNaN;var L_=128,R_=1<<17,z_=1<<18,B_=1<<19,V_=1<<20,H_=1<<21,U_=1<<22,W_=1<<23,G_=1<<24,K_=1<<25,q_=1<<26,J_=1<<27,Y_=1<<28,X_=1<<29,Z_=1<<30,Q_=127;R_-1,z_-1,B_-1,V_-1,H_-1,U_-1,W_-1,G_-1,K_-1,q_-1,J_-1,Y_-1,X_-1,Z_-1;var $_=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var ev=String.fromCharCode;String.fromCodePoint,ev(65535);var tv=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},nv=typeof TextEncoder<`u`?new TextEncoder:null,rv=nv?e=>nv.encode(e):tv,iv=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});iv&&iv.decode(new Uint8Array).length===1&&(iv=null);var av=(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},ov=(e,t)=>{for(;t>Q_;)av(e,L_|Q_&t),t=P_(t/128);av(e,Q_&t)},sv=new Uint8Array(3e4),cv=sv.length/3,lv=nv&&nv.encodeInto?(e,t)=>{if(t.length<cv){let n=nv.encodeInto(t,sv).written||0;ov(e,n);for(let t=0;t<n;t++)av(e,sv[t])}else dv(e,rv(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;ov(e,r);for(let t=0;t<r;t++)av(e,n.codePointAt(t))},uv=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=F_(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(I_(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},dv=(e,t)=>{ov(e,t.byteLength),uv(e,t)},fv=e=>Error(e),pv=fv(`Unexpected end of array`),mv=fv(`Integer out of Range`),hv=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},gv=e=>hv(e,vv(e)),_v=e=>e.arr[e.pos++],vv=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<L_)return t;if(t>$_)throw mv}throw pv},yv=iv?e=>iv.decode(gv(e)):e=>{let t=vv(e);if(t===0)return``;{let n=String.fromCodePoint(_v(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(_v(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))}},bv=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),xv=(e,t)=>{ov(e,bv.Token),lv(e,t)},Sv=(e,t,n,r)=>{switch(vv(e)){case bv.Token:t();break;case bv.PermissionDenied:n(yv(e));break;case bv.Authenticated:r(yv(e));break;default:}},Cv=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),wv=`\0`;function Tv(e,t){return e+wv+t}function Ev(e){let t=e.indexOf(wv);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Dv=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 Ov(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 kv(e){return new Promise(t=>setTimeout(t,e))}function Av(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 jv(e,t){let n=Ov(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||Av;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 kv(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 kv(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await kv(e)}return a()}var Mv=Math.floor,Nv=(e,t)=>e<t?e:t,Pv=(e,t)=>e>t?e:t;Number.isNaN;var Fv=64,Iv=128,Lv=1<<17,Rv=1<<18,zv=1<<19,Bv=1<<20,Vv=1<<21,Hv=1<<22,Uv=1<<23,Wv=1<<24,Gv=1<<25,Kv=1<<26,qv=1<<27,Jv=1<<28,Yv=1<<29,Xv=1<<30,Zv=63,Qv=127;Lv-1,Rv-1,zv-1,Bv-1,Vv-1,Hv-1,Uv-1,Wv-1,Gv-1,Kv-1,qv-1,Jv-1,Yv-1,Xv-1;var $v=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var ey=()=>new Set,ty=Array.from;Array.isArray;var ny=String.fromCharCode;String.fromCodePoint,ny(65535);var ry=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},iy=typeof TextEncoder<`u`?new TextEncoder:null,ay=iy?e=>iy.encode(e):ry,oy=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});oy&&oy.decode(new Uint8Array).length===1&&(oy=null);var sy=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},cy=()=>new sy,ly=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},uy=e=>{let t=new Uint8Array(ly(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},dy=(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},fy=(e,t)=>{for(;t>Qv;)dy(e,Iv|Qv&t),t=Mv(t/128);dy(e,Qv&t)},py=new Uint8Array(3e4),my=py.length/3,hy=iy&&iy.encodeInto?(e,t)=>{if(t.length<my){let n=iy.encodeInto(t,py).written||0;fy(e,n);for(let t=0;t<n;t++)dy(e,py[t])}else _y(e,ay(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;fy(e,r);for(let t=0;t<r;t++)dy(e,n.codePointAt(t))},gy=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Nv(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(Pv(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},_y=(e,t)=>{fy(e,t.byteLength),gy(e,t)},vy=e=>Error(e),yy=vy(`Unexpected end of array`),by=vy(`Integer out of Range`),xy=class{constructor(e){this.arr=e,this.pos=0}},Sy=e=>new xy(e),Cy=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},wy=e=>Cy(e,Ey(e)),Ty=e=>e.arr[e.pos++],Ey=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&Qv)*n,n*=128,r<Iv)return t;if(t>$v)throw by}throw yy},Dy=e=>{let t=e.arr[e.pos++],n=t&Zv,r=64,i=(t&Fv)>0?-1:1;if((t&Iv)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&Qv)*r,r*=128,t<Iv)return i*n;if(n>$v)throw by}throw yy},Oy=oy?e=>oy.decode(wy(e)):e=>{let t=Ey(e);if(t===0)return``;{let n=String.fromCodePoint(Ty(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Ty(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))}},ky=e=>{let t=e.pos,n=Oy(e);return e.pos=t,n},Ay=Date.now,jy=()=>new Map,My=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Ny=class{constructor(){this._observers=jy()}on(e,t){My(this._observers,e,ey).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 ty((this._observers.get(e)||jy()).values()).forEach(e=>e(...t))}destroy(){this._observers=jy()}},Py=Symbol(`Equality`),Fy=Object.keys,Iy=e=>Fy(e).length,Ly=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Ry=(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[Py]!=null)return e[Py](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)||!Ry(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Iy(e)!==Iy(t))return!1;for(let n in e)if(!Ly(e,n)||!Ry(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(!Ry(e[n],t[n]))return!1;break;default:return!1}return!0},zy=3e4,By=class extends Ny{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Ay();this.getLocalState()!==null&&zy/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&zy<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&Vy(this,t,`timeout`)},Mv(zy/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:Ay()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Ry(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}},Vy=(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:Ay()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},Hy=(e,t,n=e.states)=>{let r=t.length,i=cy();fy(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;fy(i,r),fy(i,s),hy(i,JSON.stringify(o))}return uy(i)},Uy=(e,t,n)=>{let r=Sy(t),i=Ay(),a=[],o=[],s=[],c=[],l=Ey(r);for(let t=0;t<l;t++){let t=Ey(r),n=Ey(r),l=JSON.parse(Oy(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&&(Ry(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])},Wy=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={}}},Gy=class{constructor(e){this.data=e,this.encoder=cy(),this.decoder=Sy(new Uint8Array(this.data))}peekVarString(){return ky(this.decoder)}readVarUint(){return Ey(this.decoder)}readVarString(){return Oy(this.decoder)}readVarUint8Array(){return wy(this.decoder)}writeVarUint(e){return fy(this.encoder,e)}writeVarString(e){return hy(this.encoder,e)}writeVarUint8Array(e){return _y(this.encoder,e)}length(){return ly(this.encoder)}},Ky=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}({}),qy=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),Jy=class{constructor(){this.encoder=cy()}get(e){return e.encoder}toUint8Array(){return uy(this.encoder)}},Yy=class extends Jy{constructor(...e){super(...e),this.type=Ky.CLOSE,this.description=`Ask the server to close the connection`}get(e){return hy(this.encoder,e.documentName),fy(this.encoder,this.type),this.encoder}},Xy=class e extends Wy{static{this.DEDUPLICATABLE_TYPES=new Set([Ky.Awareness,Ky.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=qy.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=qy.Connected,this.emit(`status`,{status:qy.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===qy.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===qy.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(Yy,{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===qy.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:jv(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=qy.Connecting,this.emit(`status`,{status:qy.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Ay();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Ky.Ping){this.sendPong();return}let n=new Gy(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=cy();fy(e,Ky.Pong),this.send(uy(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=qy.Connected,this.emit(`status`,{status:qy.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===qy.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Ay()-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=Sy(e);return{documentName:Oy(t),messageType:Ey(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===Dv.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=qy.Disconnected,this.emit(`status`,{status:qy.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()}},Zy=0,Qy=1,$y=2,eb=(e,t)=>{fy(e,Zy),_y(e,Wf(t))},tb=(e,t,n)=>{fy(e,Qy),_y(e,Rf(t,n))},nb=(e,t,n)=>tb(t,n,wy(e)),rb=(e,t,n,r)=>{try{Ff(t,wy(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},ib=(e,t)=>{fy(e,$y),_y(e,t)},ab=rb,ob=(e,t,n,r,i)=>{let a=Ey(e);switch(a){case Zy:nb(e,t,n);break;case Qy:rb(e,n,r,i);break;case $y:ab(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},sb=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case Ky.Sync:this.applySyncMessage(e,t);break;case Ky.Awareness:this.applyAwarenessMessage(e);break;case Ky.Auth:this.applyAuthMessage(e);break;case Ky.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Ky.Stateless:e.receiveStateless(Oy(n.decoder));break;case Ky.SyncStatus:this.applySyncStatusMessage(e,Dy(n.decoder)===1);break;case Ky.CLOSE:let i={code:1e3,reason:Oy(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(Jy,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Ky.Sync);let r=ob(n.decoder,n.encoder,e.document,e);t&&r===Qy&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;Uy(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;Sv(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(Ky.Awareness),t.writeVarUint8Array(Hy(e.awareness,Array.from(e.awareness.getStates().keys())))}},cb=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return uy(this.encoder)}send(e){e?.send(this.create())}},lb=`4.0.0-rc.1`,ub=class extends Jy{constructor(...e){super(...e),this.type=Ky.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return hy(this.encoder,e.documentName),fy(this.encoder,this.type),xv(this.encoder,e.token),hy(this.encoder,lb),this.encoder}},db=class extends Jy{constructor(...e){super(...e),this.type=Ky.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`);hy(this.encoder,e.documentName),fy(this.encoder,this.type);let t;return t=e.states===void 0?Hy(e.awareness,e.clients):Hy(e.awareness,e.clients,e.states),_y(this.encoder,t),this.encoder}},fb=class extends Jy{constructor(...e){super(...e),this.type=Ky.Stateless,this.description=`A stateless message`}get(e){return hy(this.encoder,e.documentName),fy(this.encoder,this.type),hy(this.encoder,e.payload??``),this.encoder}},pb=class extends Jy{constructor(...e){super(...e),this.type=Ky.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 hy(this.encoder,e.documentName),fy(this.encoder,this.type),eb(this.encoder,e.document),this.encoder}},mb=class extends Jy{constructor(...e){super(...e),this.type=Ky.Sync,this.description=`A document update`}get(e){return hy(this.encoder,e.documentName),fy(this.encoder,this.type),ib(this.encoder,e.update),this.encoder}},hb=class extends Error{constructor(...e){super(...e),this.code=1001}},gb=class extends Wy{get effectiveName(){return this.configuration.sessionAwareness?Tv(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 yf,this.configuration.awareness=e.awareness===void 0?new By(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:Cv(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:Cv(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 Xy(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(pb,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&Vy(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(fb,{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(ub,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(mb,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(db,{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(pb,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(db,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new cb(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new Gy(e.data),{documentName:n}=Ev(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new Gy(e.data)}),new sb(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Vy(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&&(Vy(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 hb(`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)}};function _b(e){return!(e.viewCount>0&&e.viewCount>=50||e.bytes>5e5)}var vb=new Map,yb=new Map,bb=[],xb=[],Sb=new Set,Cb=null;function wb(){if(Cb)return Cb;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`,Cb=e,e}function Tb(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!_b(i)){let e=r(n);return J(`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=vb.get(t);if(a){if(Nb(a,n),a.activeMountKey=t,Fb(bb,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return J(`ok/cache/hit`,{docName:t,kind:`tiptap`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;vb.size>=10;){let e=Ib(bb,t);if(!e)break;Db(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 vb.set(t,s),Fb(bb,t),J(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function Eb(e){if(e.__uncached){try{e.editor.destroy()}catch{}e.activeMountKey=null;return}let t=jb(e.editor);if(t){e.hadFocus=Mb(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=wb();r&&r.appendChild(t.dom)}e.activeMountKey=null}function Db(e){let t=vb.get(e);if(!t)return!1;try{t.editor.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}vb.delete(e);let n=bb.indexOf(e);return n!==-1&&bb.splice(n,1),J(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function Ob(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!_b(i)){let e=r(n);return J(`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=yb.get(t);if(a){if(Pb(a,n),a.activeMountKey=t,Fb(xb,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return J(`ok/cache/hit`,{docName:t,kind:`cm`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;yb.size>=10;){let e=Ib(xb,t);if(!e)break;Ab(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 yb.set(t,s),Fb(xb,t),J(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function kb(e){if(e.__uncached){try{e.view.destroy()}catch{}e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=Mb(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t);let r=wb();r&&r.appendChild(t),e.activeMountKey=null}function Ab(e){let t=yb.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}yb.delete(e);let n=xb.indexOf(e);return n!==-1&&xb.splice(n,1),J(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function jb(e){return e.editorView??null}function Mb(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function Nb(e,t){let n=jb(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 Pb(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function Fb(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function Ib(e,t){for(let n of e)if(n!==t&&!Sb.has(n))return n;J(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:Sb.size});for(let n of e)if(n!==t)return n;return null}function Lb(e){let t=Sb,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=Rb(e);if(t)try{t.disconnect(),J(`ok/cache/disconnect`,{docName:e})}catch(t){J(`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=Rb(e);if(!n)continue;let r=t=>{J(`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(()=>J(`ok/cache/connect`,{docName:e}),e=>r(e)):J(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}Sb=n}function Rb(e){let t=vb.get(e);if(t)return t.provider;let n=yb.get(e);return n?n.provider:null}var zb=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new s({key:e||new C(`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))}}}),Bb=H.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[zb({key:new C(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),Vb=new C(`imageUpload`);function Hb(){let e=document.createElement(`div`);return e.className=`image-upload-skeleton w-full h-40 rounded-md bg-muted animate-pulse motion-reduce:animate-none my-2`,e.setAttribute(`data-upload-widget`,`loading`),e.setAttribute(`role`,`status`),e.setAttribute(`aria-label`,`Uploading image...`),e}var Ub=new s({key:Vb,state:{init(){return{decorations:Be.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(Vb);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=a.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),o=n.add(e.doc,[t]),s=new Map(r);return s.set(i.id,e.mapping.map(i.pos)),{decorations:o,uploads:s}}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 Vb.getState(e)?.decorations??Be.empty}}}),Wb=null;function Gb(e){Wb=e}async function Kb(e,t,n){let r=Wb?`${Wb}.md`:``;if(!r){dr.error(`Cannot upload: no document is open`);return}let i=crypto.randomUUID(),a=Hb();t.view.dispatch(t.state.tr.setMeta(Vb,{type:`add`,id:i,pos:n,widget:a}));let o=new FormData;o.append(`file`,e),o.append(`parentDocName`,r);let s;try{s=await fetch(`/api/upload-image`,{method:`POST`,body:o})}catch(e){console.error(`[uploadAndInsert] Network error:`,e),qb(t,i);return}if(!s.ok){let e=`Upload failed (${s.status})`;try{let t=await s.json();t.error&&(e=t.error)}catch{}console.error(`[uploadAndInsert] Server error:`,e),qb(t,i,e);return}let c;try{let e=await s.json();if(typeof e.src!=`string`)throw Error(`missing src in response`);c=e.src}catch(e){console.error(`[uploadAndInsert] Response parse error:`,e),qb(t,i);return}let l=e.name.replace(/\.[^.]+$/,``),{state:u}=t,d=Vb.getState(u)?.uploads.get(i)??n,f=u.schema.nodes.image;if(!f){console.error(`[uploadAndInsert] Image node type not found in schema`),qb(t,i);return}let p=u.tr.setMeta(Vb,{type:`remove`,id:i}).insert(d,f.create({src:c,alt:l}));t.view.dispatch(p)}function qb(e,t,n){e.view.dispatch(e.state.tr.setMeta(Vb,{type:`remove`,id:t})),dr.error(n??`Upload failed`)}function Jb(e){let{$from:t}=e.selection;return t.depth===0?null:{from:t.before(1),to:t.after(1)}}function Yb(e,t){let n=Jb(e);if(!n)return!1;let{from:r,to:i}=n;if(r===0)return!1;let a=e.doc.resolve(r-1);if(a.depth===0)return!1;let o=a.before(1),s=e.doc.slice(r,i).content,c=e.doc.slice(o,r).content;if(!t)return!0;let l=e.tr;l.replaceWith(o,i,s.append(c));let u=o+1,d=o+s.size,f=e.selection.from-r,p=Math.min(u+f,d);return l.setSelection(pe.near(l.doc.resolve(p))),l.scrollIntoView(),t(l),!0}function Xb(e,t){let n=Jb(e);if(!n)return!1;let{from:r,to:i}=n;if(i>=e.doc.content.size)return!1;let a=e.doc.resolve(i+1);if(a.depth===0)return!1;let o=a.after(1),s=e.doc.slice(r,i).content,c=e.doc.slice(i,o).content;if(!t)return!0;let l=e.tr;l.replaceWith(r,o,c.append(s));let u=r+c.size+1,d=r+c.size+s.size,f=e.selection.from-r,p=Math.min(u+f,d);return l.setSelection(pe.near(l.doc.resolve(p))),l.scrollIntoView(),t(l),!0}var Zb=H.create({name:`blockMover`,addKeyboardShortcuts(){return{"Mod-Shift-ArrowUp":({editor:e})=>Yb(e.state,e.view.dispatch),"Mod-Shift-ArrowDown":({editor:e})=>Xb(e.state,e.view.dispatch)}}});function Qb(e){return!!e.getMeta(dg)}function $b(e,t){let n=dg.getState(e);return Qg(n.doc,n.type,t,n.binding.mapping)||0}function ex(e,t){let n=dg.getState(e);return Xg(t,n.type,n.binding.mapping)}var tx=class e extends _e{constructor(e,t){super(e),this.yRelativePosition=t}static fromJSON(t){return new e(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function nx(e,t){return new tx(e,ex(t,e))}function rx(e,t,n){let r=e instanceof tx?e.yRelativePosition:null;if(Qb(t)&&r)return{position:new tx($b(n,r),r),mapResult:null};let i=B(e,t),a=i.position.position;return{position:new tx(a,r??ex(n,a)),mapResult:i.mapResult}}var ix=H.create({name:`collaboration`,priority:1e3,addOptions(){return{document:null,field:`default`,fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name===`undoRedo`)&&console.warn(`[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".`)},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>rx(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>nx(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),fg.getState(t).undoManager.undoStack.length===0?!1:n?a_(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),fg.getState(t).undoManager.redoStack.length===0?!1:n?o_(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){let e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=l_(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let{undoManager:t}=fg.getState(e.state);t.restore&&=(t.restore(),()=>{});let r=n?n(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),n=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on(`afterTransaction`,t.afterTransactionHandler),t._observers=n},r?.destroy&&r.destroy()}}},[yg(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new s({key:new C(`filterInvalidContent`),filterTransaction:t=>{if(!Qb(t))return!0;if(this.storage.isDisabled)return!1;if(!t.docChanged)return!0;try{return t.doc.check(),!0}catch(t){return this.storage.isDisabled=!0,this.editor.emit(`contentError`,{error:t,editor:this.editor,disableCollaboration:()=>{var t;(t=e.doc)==null||t.destroy()}}),!1}}})].filter(Boolean)}});function ax(e){if(!e.length)return Be.empty;let t=[],n=e[0].$from.node(0);return e.forEach(e=>{let n=e.$from.pos,r=e.$from.nodeAfter;r&&t.push(a.node(n,n+r.nodeSize,{class:`ProseMirror-selectednoderange`}))}),Be.create(n,t)}function ox(e,t,n){let r=n.isText||n.isAtom?0:1;return{start:e+r,end:e+t-r}}function sx(e,t,r,i={}){let a=[],o=e.node(0),{extendOnBoundaryOverlap:s=!0}=i;typeof r==`number`&&r>=0||(r=e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos));let c=new T(e,t,r),l=c.depth===0?0:o.resolve(c.start).posAtIndex(0);return c.parent.forEach((r,i)=>{let u=l+i,d=u+r.nodeSize,f=ox(u,r.nodeSize,r),p=s?t.pos>=f.start&&e.pos<=f.end:t.pos>f.start&&e.pos<f.end;if(u<c.start||u>=c.end||!p)return;let m=new n(o.resolve(u),o.resolve(d));a.push(m)}),a}var cx=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return new lx(e.resolve(this.anchor),e.resolve(this.head))}},lx=class e extends he{constructor(e,t,n,r=1){let{doc:i}=e,a=e===t,o=e.pos===i.content.size&&t.pos===i.content.size,s=a&&!o?i.resolve(t.pos+(r>0?1:-1)):t,c=a&&o?i.resolve(e.pos-(r>0?1:-1)):e,l=sx(c.min(s),c.max(s),n),u=s.pos>=e.pos?l[0].$from:l[l.length-1].$to,d=s.pos>=e.pos?l[l.length-1].$to:l[0].$from;super(u,d,l),this.depth=n}get $to(){return this.ranges[this.ranges.length-1].$to}eq(t){return t instanceof e&&t.$from.pos===this.$from.pos&&t.$to.pos===this.$to.pos}map(t,n){return new e(t.resolve(n.map(this.anchor)),t.resolve(n.map(this.head)))}toJSON(){return{type:`nodeRange`,anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){let{doc:t}=this.$from;if(this.isForwards&&this.ranges.length>1){let t=this.ranges.slice(0,-1),n=t[0].$from,r=t[t.length-1].$to;return new e(n,r,this.depth)}let n=this.ranges[0],r=t.resolve(Math.max(0,n.$from.pos-1));return new e(this.$anchor,r,this.depth)}extendForwards(){let{doc:t}=this.$from;if(this.isBackwards&&this.ranges.length>1){let t=this.ranges.slice(1),n=t[0].$from,r=t[t.length-1].$to;return new e(r,n,this.depth)}let n=this.ranges[this.ranges.length-1],r=t.resolve(Math.min(t.content.size,n.$to.pos+1));return new e(this.$anchor,r,this.depth)}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n,r,i=1){return new this(e.resolve(t),e.resolve(n),r,i)}getBookmark(){return new cx(this.anchor,this.head)}};lx.prototype.visible=!1;function ux(e){return e instanceof lx}H.create({name:`nodeRange`,addOptions(){return{depth:void 0,key:`Mod`}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,selection:a,tr:o}=r,{anchor:s,head:c}=a;if(!ux(a)){let e=lx.create(i,s,c,t,-1);return o.setSelection(e),n.dispatch(o),!0}let l=a.extendBackwards();return o.setSelection(l),n.dispatch(o),!0},"Shift-ArrowDown":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,selection:a,tr:o}=r,{anchor:s,head:c}=a;if(!ux(a)){let e=lx.create(i,s,c,t);return o.setSelection(e),n.dispatch(o),!0}let l=a.extendForwards();return o.setSelection(l),n.dispatch(o),!0},"Mod-a":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,tr:a}=r,o=lx.create(i,0,i.content.size,t);return a.setSelection(o),n.dispatch(a),!0}}},onSelectionUpdate(){let{selection:e}=this.editor.state;ux(e)&&this.editor.view.dom.classList.add(`ProseMirror-noderangeselection`)},addProseMirrorPlugins(){let e=!1,t=!1;return[new s({key:new C(`nodeRange`),props:{attributes:()=>e?{class:`ProseMirror-noderangeselection`}:{class:``},handleDOMEvents:{mousedown:(e,n)=>{let{key:r}=this.options,i=/Mac/.test(navigator.platform),a=!!n.shiftKey,o=!!n.ctrlKey,s=!!n.altKey,c=!!n.metaKey;return(r==null||r===`Shift`&&a||r===`Control`&&o||r===`Alt`&&s||r===`Meta`&&c||r===`Mod`&&(i?c:o))&&(t=!0),t&&document.addEventListener(`mouseup`,()=>{t=!1;let{state:n}=e,{doc:r,selection:i,tr:a}=n,{$anchor:o,$head:s}=i;if(o.sameParent(s))return;let c=lx.create(r,o.pos,s.pos,this.options.depth);a.setSelection(c),e.dispatch(a)},{once:!0}),!1}},decorations:n=>{let{selection:r}=n,i=ux(r);if(e=!1,!t)return i?(e=!0,ax(r.ranges)):null;let{$from:a,$to:o}=r;if(!i&&a.sameParent(o))return null;let s=sx(a,o,this.options.depth);return s.length?(e=!0,ax(s)):null}}})]}});function dx(e){let t=``,n=getComputedStyle(e);for(let e=0;e<n.length;e+=1)t+=`${n[e]}:${n.getPropertyValue(n[e])};`;return t}function fx(e){let t=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName(`*`))],r=[t,...Array.from(t.getElementsByTagName(`*`))];return n.forEach((e,t)=>{r[t].style.cssText=dx(e)}),t}var px=[{id:`listItemFirstChild`,evaluate:({parent:e,isFirst:t})=>t&&e&&[`listItem`,`taskItem`].includes(e.type.name)?1e3:0},{id:`listWrapperDeprioritize`,evaluate:({node:e})=>{let t=[`listItem`,`taskItem`],n=e.firstChild;return n&&t.includes(n.type.name)?1e3:0}},{id:`tableStructure`,evaluate:({node:e,parent:t})=>[`tableRow`,`tableCell`,`tableHeader`].includes(e.type.name)||t&&t.type.name===`tableHeader`?1e3:0},{id:`inlineContent`,evaluate:({node:e})=>e.isInline||e.isText?1e3:0}],mx={edges:[`left`,`top`],threshold:12,strength:500};function hx(e){return e===void 0||e===`left`?{...mx}:e===`right`?{edges:[`right`,`top`],threshold:12,strength:500}:e===`both`?{edges:[`left`,`right`,`top`],threshold:12,strength:500}:e===`none`?{edges:[],threshold:0,strength:0}:{...mx,...e}}function gx(e,t,n){if(n.edges.length===0)return!1;let r=t.getBoundingClientRect(),{threshold:i,edges:a}=n;return a.some(t=>t===`left`?e.x-r.left<i:t===`right`?r.right-e.x<i:t===`top`?e.y-r.top<i:t===`bottom`?r.bottom-e.y<i:!1)}function _x(e,t,n,r){return!t||n.edges.length===0?0:gx(e,t,n)?n.strength*r:0}var vx=1e3;function yx(e,t,n,r){let i=vx,a=!1;if(t.every(t=>{let n=t.evaluate(e);return i-=n,i<=0?(a=!0,!1):!0}),a)return-1;let o=e.view.nodeDOM(e.pos);return i-=_x(r,o,n,e.depth),i<=0?-1:i}function bx(e,t,n){return Array.from({length:t},(e,n)=>t-1-n).some(t=>n.includes(e.node(t).type.name))}function xx(e,t,n){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))return null;let r=e.posAtCoords({left:t.x,top:t.y});if(!r)return null;let{doc:i}=e.state,a=i.resolve(r.pos),o=[];n.defaultRules&&o.push(...px),o.push(...n.rules);let s=Array.from({length:a.depth},(e,t)=>a.depth-t).map(r=>{let i=a.node(r),s=a.before(r);if(n.allowedContainers&&r>0&&!bx(a,r,n.allowedContainers))return null;let c=r>0?a.node(r-1):null,l=r>0?a.index(r-1):0,u=c?c.childCount:1,d=yx({node:i,pos:s,depth:r,parent:c,index:l,isFirst:l===0,isLast:l===u-1,$pos:a,view:e},o,n.edgeDetection,t);return d<0?null:{node:i,pos:s,depth:r,score:d,dom:e.nodeDOM(s)}}).filter(e=>e!==null),c=a.nodeAfter;if(c&&c.isAtom&&!c.isInline){let i=r.pos,l=a.depth+1,u=a.parent,d=a.index(),f=u.childCount,p=!0;if(n.allowedContainers&&(p=bx(a,l,n.allowedContainers)),p){let r=yx({node:c,pos:i,depth:l,parent:u,index:d,isFirst:d===0,isLast:d===f-1,$pos:a,view:e},o,n.edgeDetection,t);if(r>=0){let t=e.nodeDOM(i);t&&s.push({node:c,pos:i,depth:l,score:r,dom:t})}}}if(s.length===0)return null;s.sort((e,t)=>t.score===e.score?t.depth-e.depth:t.score-e.score);let l=s[0];return l.dom?{node:l.node,pos:l.pos,dom:l.dom}:null}function Sx(e,t){let n=e;for(;n?.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return n?.parentElement===t.dom?n:void 0}function Cx(e){return Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&e.width>0&&e.height>0}function wx(e,t,n,r=5){if(!Number.isFinite(t)||!Number.isFinite(n))return null;let i=e.dom,a=i.firstElementChild,o=i.lastElementChild;if(!a||!o)return null;let s=a.getBoundingClientRect(),c=o.getBoundingClientRect();if(!Cx(s)||!Cx(c))return null;let l=Math.min(Math.max(s.top+r,n),c.bottom-r),u=.5,d=Math.abs(s.left-c.left)<u,f=Math.abs(s.right-c.right)<u,p=s;d&&f&&(p=s);let m=Math.min(Math.max(p.left+r,t),p.right-r);return!Number.isFinite(m)||!Number.isFinite(l)?null:{x:m,y:l}}var Tx=e=>{let{x:t,y:n,editor:r,nestedOptions:i}=e,{view:a,state:o}=r,s=wx(a,t,n,5);if(!s)return{resultElement:null,resultNode:null,pos:null};let{x:c,y:l}=s;if(i?.enabled){let e=xx(a,{x:c,y:l},i);return e?{resultElement:e.dom,resultNode:e.node,pos:e.pos}:{resultElement:null,resultNode:null,pos:null}}let u=a.root.elementsFromPoint(c,l),d;if(Array.prototype.some.call(u,e=>{if(!a.dom.contains(e))return!1;let t=Sx(e,a);return t?(d=t,!0):!1}),!d){let e=a.posAtCoords({left:c,top:l});if(e){let t=o.doc.resolve(e.pos),n=Math.min(t.depth,1),r=n>0?t.before(n):t.pos,i=o.doc.nodeAt(r);if(i){let e=a.nodeDOM(r);return{resultElement:e instanceof HTMLElement?e:null,resultNode:i,pos:r}}}return{resultElement:null,resultNode:null,pos:null}}let f;try{f=a.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}let p=o.doc.nodeAt(f);if(!p){let e=o.doc.resolve(f),t=e.parent;return{resultElement:d,resultNode:t,pos:e.start()}}return{resultElement:d,resultNode:p,pos:f}};function Ex(e,t){let n=null,r=e.nodeDOM(t);if(r instanceof Element)n=r;else{let{node:r,offset:i}=e.domAtPos(t),a=r.childNodes[i];a instanceof Element?n=a:r instanceof Element?n=r:r.nodeType===Node.TEXT_NODE&&r.parentElement&&(n=r.parentElement)}return(n?getComputedStyle(n).direction:getComputedStyle(e.dom).direction)||`ltr`}function Dx(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function Ox(e,t,n,r){let{doc:i}=t.view.state;if(n?.enabled&&r?.node&&r.pos>=0){let e=r.pos,t=r.pos+r.node.nodeSize;return[{$from:i.resolve(e),$to:i.resolve(t)}]}let a=Tx({editor:t,x:e.clientX,y:e.clientY,direction:`right`,nestedOptions:n});if(!a.resultNode||a.pos===null)return[];let o=a.resultNode.isText||a.resultNode.isAtom?0:-1;return sx(i.resolve(a.pos),i.resolve(a.pos+a.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}function kx(e,t,n,r){let{view:i}=t;if(!e.dataTransfer)return;let{empty:a,$from:o,$to:s}=i.state.selection,c=Ox(e,t,n,r),u=sx(o,s,0,{extendOnBoundaryOverlap:!1}),d=u.some(e=>c.find(t=>t.$from===e.$from&&t.$to===e.$to)),f=a||!d?c:u;if(!f.length)return;let{tr:p}=i.state,m=document.createElement(`div`),h=f[0].$from.pos,g=f[f.length-1].$to.pos;m.setAttribute(`dir`,Ex(i,h));let _=n?.enabled&&r?.node,v,y;_?(v=i.state.doc.slice(h,g),y=l.create(i.state.doc,h)):(y=lx.create(i.state.doc,h,g),v=y.content()),f.forEach(e=>{let t=fx(i.nodeDOM(e.$from.pos));m.append(t)}),m.style.position=`absolute`,m.style.top=`-10000px`,document.body.append(m),e.dataTransfer.clearData();let b=m.getBoundingClientRect(),x=e.clientX-b.left;e.dataTransfer.setDragImage(m,Math.max(0,Math.min(x,b.width)),0);let S=!1,C=()=>{S||(S=!0,Dx(m),document.removeEventListener(`drop`,C),document.removeEventListener(`dragend`,C))},w=y instanceof l?y:void 0;i.dragging={slice:v,move:!0,node:w},p.setSelection(y),i.dispatch(p),document.addEventListener(`drop`,C),document.addEventListener(`dragend`,C)}var Ax=(e,t)=>{let n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},jx=(e,t)=>{let n=e.nodeAt(t),r=e.resolve(t),{depth:i}=r,a=n;for(;i>0;){let e=r.node(i);--i,i===0&&(a=e)}return a},Mx=(e,t)=>{let n=dg.getState(e);return n?Xg(t,n.type,n.binding.mapping):null},Nx=(e,t)=>{let n=dg.getState(e);return n?Qg(n.doc,n.type,t,n.binding.mapping)||0:-1},Px=(e,t)=>{let n=t;for(;n?.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},Fx=new C(`dragHandle`),Ix=({pluginKey:e=Fx,element:t,editor:n,computePositionConfig:r,getReferencedVirtualElement:a,onNodeChange:o,onElementDragStart:c,onElementDragEnd:l,nestedOptions:u})=>{let d=document.createElement(`div`),f=!1,p=null,m=-1,h,g=null,_=null;function v(){t&&(t.style.visibility=`hidden`,t.style.pointerEvents=`none`)}function y(){if(t){if(!n.isEditable){v();return}t.style.visibility=``,t.style.pointerEvents=`auto`}}function b(e){i(a?.()||{getBoundingClientRect:()=>e.getBoundingClientRect()},t,r).then(e=>{Object.assign(t.style,{position:e.strategy,left:`${e.x}px`,top:`${e.y}px`})})}function x(e){c?.(e),kx(e,n,u,{node:p,pos:m}),t&&(t.dataset.dragging=`true`),setTimeout(()=>{t&&(t.style.pointerEvents=`none`)},0)}function S(e){l?.(e),v(),t&&(t.style.pointerEvents=`auto`,t.dataset.dragging=`false`)}function w(){if(Re()){let e=n.view.dom;requestAnimationFrame(()=>{e.isContentEditable&&(e.contentEditable=`false`,e.contentEditable=`true`)})}}return d.appendChild(t),{unbind(){t.removeEventListener(`dragstart`,x),t.removeEventListener(`dragend`,S),document.removeEventListener(`drop`,w),g&&(cancelAnimationFrame(g),g=null,_=null)},plugin:new s({key:typeof e==`string`?new C(e):e,state:{init(){return{locked:!1}},apply(e,r,i,a){let s=e.getMeta(`lockDragHandle`),c=e.getMeta(`hideDragHandle`);if(s!==void 0&&(f=s),c)return v(),f=!1,p=null,m=-1,o?.({editor:n,node:null,pos:-1}),r;if(e.docChanged&&m!==-1&&t)if(Qb(e)){let e=Nx(a,h);e!==m&&(m=e)}else{let t=e.mapping.map(m);t!==m&&(m=t,h=Mx(a,m))}return r}},view:e=>{var r;return t.draggable=!0,t.style.pointerEvents=`auto`,t.dataset.dragging=`false`,(r=n.view.dom.parentElement)==null||r.appendChild(d),d.style.pointerEvents=`none`,d.style.position=`absolute`,d.style.top=`0`,d.style.left=`0`,t.addEventListener(`dragstart`,x),t.addEventListener(`dragend`,S),document.addEventListener(`drop`,w),{update(r,i){if(!t)return;if(!n.isEditable){v();return}if(f?t.draggable=!1:t.draggable=!0,e.state.doc.eq(i.doc)||m===-1)return;let a=e.nodeDOM(m);if(a=Px(e,a),a===e.dom||a?.nodeType!==1)return;let s=e.posAtDOM(a,0),c=jx(n.state.doc,s),l=Ax(n.state.doc,s);p=c,m=l,h=Mx(e.state,m),o?.({editor:n,node:p,pos:m}),b(a)},destroy(){t.removeEventListener(`dragstart`,x),t.removeEventListener(`dragend`,S),document.removeEventListener(`drop`,w),g&&(cancelAnimationFrame(g),g=null,_=null),t&&Dx(d)}}},props:{handleDOMEvents:{keydown(e){return!t||f?!1:e.hasFocus()?(v(),p=null,m=-1,o?.({editor:n,node:null,pos:-1}),!1):!1},mouseleave(e,t){return f||t.target&&!d.contains(t.relatedTarget)&&(v(),p=null,m=-1,o?.({editor:n,node:null,pos:-1})),!1},mousemove(e,r){return!t||f||(_={x:r.clientX,y:r.clientY},g)||(g=requestAnimationFrame(()=>{if(g=null,!_)return;let{x:t,y:r}=_;_=null;let i=Tx({x:t,y:r,direction:`right`,editor:n,nestedOptions:u});if(!i.resultElement)return;let a=i.resultElement,s=i.resultNode,c=i.pos;if(!u?.enabled){if(a=Px(e,a),a===e.dom||a?.nodeType!==1)return;let t=e.posAtDOM(a,0);s=jx(n.state.doc,t),c=Ax(n.state.doc,t)}s!==p&&(p=s,m=c??-1,h=Mx(e.state,m),o?.({editor:n,node:p,pos:m}),b(a),y())})),!1}}}})}};function Lx(e){return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:hx(`none`)}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:hx(`left`)}:{enabled:!0,rules:e.rules??[],defaultRules:e.defaultRules??!0,allowedContainers:e.allowedContainers,edgeDetection:hx(e.edgeDetection)}}var Rx={placement:`left-start`,strategy:`absolute`};H.create({name:`dragHandle`,addOptions(){return{render(){let e=document.createElement(`div`);return e.classList.add(`drag-handle`),e},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1}},addCommands(){return{lockDragHandle:()=>({editor:e})=>(this.options.locked=!0,e.commands.setMeta(`lockDragHandle`,this.options.locked)),unlockDragHandle:()=>({editor:e})=>(this.options.locked=!1,e.commands.setMeta(`lockDragHandle`,this.options.locked)),toggleDragHandle:()=>({editor:e})=>(this.options.locked=!this.options.locked,e.commands.setMeta(`lockDragHandle`,this.options.locked))}},addProseMirrorPlugins(){let e=this.options.render(),t=Lx(this.options.nested);return[Ix({computePositionConfig:{...Rx,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:e,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:t}).plugin]}});var zx=20,Bx=44,Vx=28;function Hx(){let e=document.createElement(`div`);e.className=`ok-block-controls`,e.style.visibility=`hidden`;let t=document.createElement(`button`);t.className=`ok-add-block-btn`,t.setAttribute(`aria-label`,`Add block below`),t.setAttribute(`type`,`button`),t.innerHTML=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus"><path d="M5 12h14"/><path d="M12 5v14"/></svg>`,t.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()});let n=document.createElement(`div`);return n.className=`ok-drag-grip`,n.setAttribute(`aria-hidden`,`true`),n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-grip-vertical-icon lucide-grip-vertical"><circle cx="9" cy="12" r="1"/><circle cx="9" cy="5" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="19" r="1"/></svg>`,e.appendChild(t),e.appendChild(n),{container:e,addBtn:t}}function Ux(e,t,n){let{state:r,view:i}=e,a=t+n.nodeSize;if(a>r.doc.content.size)return;let{tr:o}=r,s=r.schema.nodes.paragraph?.create();if(!s)return;o.insert(a,s);let c=pe.near(o.doc.resolve(a+1));o.setSelection(c).scrollIntoView(),i.dispatch(o),i.focus(),e.commands.insertContent(`/`)}var Wx=H.create({name:`blockDragHandle`,addProseMirrorPlugins(){let e=this.editor,t=null,n=-1,{container:r,addBtn:i}=Hx();return i.addEventListener(`click`,()=>{t&&n>=0&&Ux(e,n,t)}),[Ix({element:r,editor:e,onNodeChange({node:e,pos:r}){t=e,n=r??-1},computePositionConfig:{placement:`left-start`,strategy:`absolute`,middleware:[f(({rects:e})=>({mainAxis:10,crossAxis:((e.reference.height<=Bx?e.reference.height:Vx)-zx)/2}))]},nestedOptions:Lx(!1)}).plugin]}});function Gx(e){let t=e.trim();if(!t)return null;let n=S(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function Kx(e){let t=e.trim();if(!t)return[];let n=S(t);return n.length>0&&n!==t?[n]:[]}function qx(e,t){let n=e.trim();return n?t.has(n)?!0:Kx(n).some(e=>t.has(e)):!1}var Jx=H.create({name:`headingAnchors`,addProseMirrorPlugins(){return[new s({props:{decorations(e){let t=[],n=new Map;return e.doc.descendants((e,r)=>{if(e.type.name===`heading`){let i=o(e.textContent,n);if(!i)return;t.push(a.node(r,r+e.nodeSize,{id:i}))}}),Be.create(e.doc,t)}}})]}}),Yx=new Set([`http:`,`https:`,`mailto:`,`tel:`]);function Xx(e){try{let t=new URL(e);return Yx.has(t.protocol)}catch{return!1}}function Zx(e=window.location.hash){let t=e.match(/^#\/([^?#]+)/);return t?decodeURIComponent(t[1]):``}function Qx(e,t=window.location.hash){return z(e,Zx(t))}function $x({docName:e,anchor:t}){return t?`#/${e}?anchor=${encodeURIComponent(t)}`:`#/${e}`}function eS(e){e.startsWith(`#`)||Xx(e)?window.open(e,`_blank`,`noopener,noreferrer`):console.warn(`[safe-nav] blocked non-safe scheme:`,e)}function tS(e){window.location.assign($x(e))}function nS(e){eS($x(e))}function rS(e){return e.metaKey||e.ctrlKey}function iS(e,t=window.location.hash){let n=Zx(t);if(!n)return;let r=document.getElementById(e);r&&r.scrollIntoView({behavior:`smooth`,block:`start`}),window.location.assign(ce(n,e))}function aS(e,t=window.location.hash){if(e.kind===`doc`){tS(e);return}if(e.kind===`anchor`){iS(e.anchor,t);return}eS(e.url)}function oS(e,t,n=window.location.hash){return se(Zx(n),e,t)}var sS=e=>{let t=(0,Yn.c)(13),{kind:n,ariaLabel:r,onDeactivate:i,children:a,layout:o,className:s,"data-slot":c}=e,l=(o===void 0?`standard`:o)===`wide`?`w-[min(720px,calc(100%-1rem))]`:`w-80`,u;t[0]!==s||t[1]!==l?(u=h(`ok-interaction-prop-panel pointer-events-auto absolute left-1/2 top-2 z-40 -translate-x-1/2 rounded-md border border-border bg-popover p-3 shadow-lg`,l,s),t[0]=s,t[1]=l,t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,K.jsx)(Jn,{className:`size-3.5`,"aria-hidden":`true`}),t[3]=d):d=t[3];let f;t[4]===i?f=t[5]:(f=(0,K.jsx)(Ce,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:i,className:`absolute right-1 top-1 size-7`,children:d}),t[4]=i,t[5]=f);let p;return t[6]!==r||t[7]!==a||t[8]!==c||t[9]!==n||t[10]!==u||t[11]!==f?(p=(0,K.jsxs)(`div`,{role:`dialog`,"aria-label":r,"data-ok-prop-panel":n,"data-slot":c,className:u,children:[a,f]}),t[6]=r,t[7]=a,t[8]=c,t[9]=n,t[10]=u,t[11]=f,t[12]=p):p=t[12],p};function cS(e,t){let n=[e,...t.fallbackTargets??[]],r=new Set,i=null;for(let e of n){if(r.has(e))continue;r.add(e);let n=L(e,{pages:t.pages,folderPaths:t.folderPaths});if(n.kind===`missing`){i??=n;continue}return{kind:`navigate`,displayState:n.kind===`folder`?`folder`:`resolved`,resolvedTarget:n,hashDocName:n.target}}let a=i??L(e,{pages:t.pages,folderPaths:t.folderPaths});if(a.kind!==`missing`)return{kind:`navigate`,displayState:a.kind===`folder`?`folder`:`resolved`,resolvedTarget:a,hashDocName:a.target};let o=t.createDialogSeed??de(a.target);return{kind:`create`,displayState:`missing`,resolvedTarget:a,initialDir:o.initialDir,suggestedName:o.suggestedName}}function lS(e){if(e.kind!==`navigate`||e.displayState!==`folder`)return null;let t=e.resolvedTarget;return`folderPath`in t?{initialDir:t.folderPath,suggestedName:`index.md`}:null}function uS(e){let t=(0,Yn.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,type:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=h(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a||t[8]!==i?(o=(0,K.jsx)(`input`,{type:i,"data-slot":`input`,className:a,...r}),t[6]=r,t[7]=a,t[8]=i,t[9]=o):o=t[9],o}function dS(e){return e.trim()?e.includes(`..`)?`Path cannot contain ".."`:e.startsWith(`/`)?`Path cannot start with "/"`:e.includes(`\\`)?`Path cannot contain backslashes`:e.includes(`\0`)?`Path cannot contain null bytes`:null:`Name cannot be empty`}function fS(e){return e.endsWith(`.md`)?e:`${e}.md`}function pS(e){let t=fS(e.fileName.trim());if(e.kind===`folder`){let n=(e.folderName??``).trim();return`${e.initialDir?`${e.initialDir}/${n}`:n}/${t}`}return e.initialDir?`${e.initialDir}/${t}`:t}function mS(e){let t=e.target;return t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable?!1:!!((e.metaKey||e.ctrlKey)&&e.altKey&&e.key.toLowerCase()===`n`)}function hS(e){let t=e.value.lastIndexOf(`.`);t>0?e.setSelectionRange(0,t):e.select()}function gS(e){let t=(0,Yn.c)(87),{open:n,onOpenChange:r,kind:i,initialDir:a,suggestedName:o,description:s,onCreated:c}=e,{addPage:l}=ge(),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(null),b=(0,q.useId)(),x=(0,q.useId)(),S=(0,q.useId)(),C=(0,q.useRef)(null),w=(0,q.useRef)(null),T,E;t[0]!==i||t[1]!==n||t[2]!==o?(T=()=>{n&&(h(null),y(null),_(!1),p(``),d(i===`file`?o??`untitled.md`:`index.md`))},E=[n,i,o],t[0]=i,t[1]=n,t[2]=o,t[3]=T,t[4]=E):(T=t[3],E=t[4]),(0,q.useEffect)(T,E);let D;t[5]!==u||t[6]!==f||t[7]!==a||t[8]!==i?(D=function(){return pS({kind:i,initialDir:a,fileName:u,folderName:f})},t[5]=u,t[6]=f,t[7]=a,t[8]=i,t[9]=D):D=t[9];let O=D,k;t[10]!==u||t[11]!==f||t[12]!==i?(k=function(){if(i===`folder`){let e=dS(f.trim());if(e)return{message:`Folder name: ${e}`,field:`folder`}}let e=dS(u.trim());return e?{message:e,field:`file`}:null},t[10]=u,t[11]=f,t[12]=i,t[13]=k):k=t[13];let A=k,j;t[14]!==g||t[15]!==u||t[16]!==f||t[17]!==i?(j=g||!u.trim()||i===`folder`&&!f.trim(),t[14]=g,t[15]=u,t[16]=f,t[17]=i,t[18]=j):j=t[18];let M=j,N;t[19]!==l||t[20]!==O||t[21]!==A||t[22]!==i||t[23]!==c||t[24]!==r?(N=async function(){let e=A();if(e){h(e.message),y(e.field);return}_(!0),h(null),y(null);let t=O();try{let e=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!e.ok){let t=`Server error (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=n.error)}catch{}_(!1),h(t),y(`form`);return}let n=await e.json();if(_(!1),!n.ok){h(n.error??`Failed to create ${i}`),y(`form`);return}let a=n.docName??t.replace(/\.md$/,``);r(!1),window.location.hash=`#/${a}`,l(a),Pe([`files`,`backlinks`,`graph`]),c?.(a)}catch(e){console.warn(`[NewItemDialog] create failed:`,e),_(!1),h(`Network error — please try again`),y(`form`)}},t[19]=l,t[20]=O,t[21]=A,t[22]=i,t[23]=c,t[24]=r,t[25]=N):N=t[25];let P=N,F=a||`(root)`,I=i===`file`?`New file`:`New folder`,L;t[26]===I?L=t[27]:(L=(0,K.jsx)(__,{children:I}),t[26]=I,t[27]=L);let R;t[28]!==s||t[29]!==F?(R=s??(0,K.jsxs)(K.Fragment,{children:[`Create in `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:F})]}),t[28]=s,t[29]=F,t[30]=R):R=t[30];let z;t[31]===R?z=t[32]:(z=(0,K.jsx)(v_,{children:R}),t[31]=R,t[32]=z);let ee;t[33]!==L||t[34]!==z?(ee=(0,K.jsxs)(h_,{children:[L,z]}),t[33]=L,t[34]=z,t[35]=ee):ee=t[35];let B;t[36]!==m||t[37]!==v||t[38]!==b||t[39]!==x||t[40]!==f||t[41]!==i?(B=i===`folder`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:x,children:`Folder name`}),(0,K.jsx)(uS,{ref:w,id:x,value:f,onChange:e=>{p(e.target.value),h(null)},placeholder:`folder-name`,autoFocus:!0,"aria-describedby":m&&(v===`folder`||v===`form`)?b:void 0,"aria-invalid":m&&(v===`folder`||v===`form`)?!0:void 0,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=dS(f.trim());if(t){h(`Folder name: ${t}`),y(`folder`);return}C.current?.focus()}}})]}),t[36]=m,t[37]=v,t[38]=b,t[39]=x,t[40]=f,t[41]=i,t[42]=B):B=t[42];let V=i===`folder`?`First file name`:`File name`,te;t[43]!==S||t[44]!==V?(te=(0,K.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:S,children:V}),t[43]=S,t[44]=V,t[45]=te):te=t[45];let ne;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>{d(e.target.value),h(null)},t[46]=ne):ne=t[46];let re=i===`file`,H=m&&(v===`file`||v===`form`)?b:void 0,ie=m&&(v===`file`||v===`form`)?!0:void 0,ae;t[47]!==P||t[48]!==M?(ae=e=>{e.key===`Enter`&&!M&&P()},t[47]=P,t[48]=M,t[49]=ae):ae=t[49];let U;t[50]!==S||t[51]!==u||t[52]!==re||t[53]!==H||t[54]!==ie||t[55]!==ae?(U=(0,K.jsx)(uS,{ref:C,id:S,value:u,onChange:ne,placeholder:`my-note.md`,autoFocus:re,"aria-describedby":H,"aria-invalid":ie,onFocus:_S,onKeyDown:ae}),t[50]=S,t[51]=u,t[52]=re,t[53]=H,t[54]=ie,t[55]=ae,t[56]=U):U=t[56];let oe;t[57]!==te||t[58]!==U?(oe=(0,K.jsxs)(`div`,{children:[te,U]}),t[57]=te,t[58]=U,t[59]=oe):oe=t[59];let se;t[60]!==m||t[61]!==b?(se=m&&(0,K.jsx)(`p`,{id:b,role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:m}),t[60]=m,t[61]=b,t[62]=se):se=t[62];let ce;t[63]!==B||t[64]!==oe||t[65]!==se?(ce=(0,K.jsxs)(`div`,{className:`space-y-3`,children:[B,oe,se]}),t[63]=B,t[64]=oe,t[65]=se,t[66]=ce):ce=t[66];let le;t[67]===r?le=t[68]:(le=()=>r(!1),t[67]=r,t[68]=le);let ue;t[69]!==g||t[70]!==le?(ue=(0,K.jsx)(Ce,{variant:`outline`,className:`font-mono uppercase`,onClick:le,disabled:g,children:`Cancel`}),t[69]=g,t[70]=le,t[71]=ue):ue=t[71];let de=g?`Creating...`:`Create`,fe;t[72]!==P||t[73]!==M||t[74]!==de?(fe=(0,K.jsx)(Ce,{onClick:P,disabled:M,children:de}),t[72]=P,t[73]=M,t[74]=de,t[75]=fe):fe=t[75];let pe;t[76]!==ue||t[77]!==fe?(pe=(0,K.jsxs)(g_,{children:[ue,fe]}),t[76]=ue,t[77]=fe,t[78]=pe):pe=t[78];let me;t[79]!==ee||t[80]!==ce||t[81]!==pe?(me=(0,K.jsxs)(m_,{className:`sm:max-w-md`,"data-ok-layer-spawned":``,children:[ee,ce,pe]}),t[79]=ee,t[80]=ce,t[81]=pe,t[82]=me):me=t[82];let he;return t[83]!==r||t[84]!==n||t[85]!==me?(he=(0,K.jsx)(u_,{open:n,onOpenChange:r,children:me}),t[83]=r,t[84]=n,t[85]=me,t[86]=he):he=t[86],he}function _S(e){return hS(e.currentTarget)}var vS=class{registry=new Map;_activeNodeId=null;listeners=new Set;_snapshot={activeNodeId:null,active:null};register(e){this.registry.set(e.nodeId,e),this._activeNodeId===e.nodeId&&this.refreshSnapshot()}deregister(e){this.registry.delete(e)&&this._activeNodeId===e&&(this._activeNodeId=null,this.refreshSnapshot())}setActiveNode(e){this._activeNodeId!==e&&(e!==null&&!this.registry.has(e)||(this._activeNodeId=e,this.refreshSnapshot()))}getActiveNode(){return this._activeNodeId}getRegistration(e){return this.registry.get(e)}hasRegistration(e){return this.registry.has(e)}clear(){this.registry.clear(),this._activeNodeId=null,this.refreshSnapshot()}getSnapshot=()=>this._snapshot;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});refreshSnapshot(){let e=this._activeNodeId==null?null:this.registry.get(this._activeNodeId)??null;this._snapshot={activeNodeId:this._activeNodeId,active:e};for(let e of this.listeners)e()}};function yS(e,t){let n=e??null;for(;n&&typeof n==`object`;){let e=n.getAttribute;if(typeof e==`function`){let r=e.call(n,`data-mark-id`);if(r&&t.hasRegistration(r))return r;let i=e.call(n,`data-node-id`);if(i&&t.hasRegistration(i))return i}n=n.parentElement??null}return null}var bS=e=>{let t=(0,Yn.c)(18),{store:n}=e,r;t[0]===n?r=t[1]:(r=()=>n.getSnapshot(),t[0]=n,t[1]=r);let[i,a]=(0,q.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>(a(n.getSnapshot()),n.subscribe(()=>{a(n.getSnapshot())})),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,q.useEffect)(o,s);let{active:c}=i;if(!c)return null;let l;t[5]===n?l=t[6]:(l=()=>n.setActiveNode(null),t[5]=n,t[6]=l);let u,d,f;if(t[7]!==c.controls||t[8]!==c.nodeId||t[9]!==c.type||t[10]!==l){let e={nodeId:c.nodeId,type:c.type,deactivate:l};u=c.controls.propPanel?.(e),d=c.controls.toolbar?.(e),f=c.controls.breadcrumb?.(e),t[7]=c.controls,t[8]=c.nodeId,t[9]=c.type,t[10]=l,t[11]=u,t[12]=d,t[13]=f}else u=t[11],d=t[12],f=t[13];let p;return t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,K.jsxs)(K.Fragment,{children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17],p};function xS(e){return e.editorView?.dom??e.view?.dom??null}function SS(e,t){let n=e;for(;n;){if(n.getAttribute?.(`data-mark-id`)===t||n.getAttribute?.(`data-node-id`)===t)return!0;n=n.parentElement}return!1}function CS(e){let{editor:t}=e,n=new vS,r=xS(t),i=!1,a=null,o=n.subscribe(()=>{let e=n.getActiveNode();if(e!==null){if(typeof document<`u`){let t=document.activeElement;a=t&&SS(t,e)?t:null}return}if(typeof document>`u`)return;let i=a;if(a=null,i&&document.contains(i)&&typeof i.focus==`function`){try{i.focus({preventScroll:!0})}catch{}return}let o=r??xS(t);if(o&&typeof o.focus==`function`)try{o.focus({preventScroll:!0})}catch{}}),s=e=>{let t=e;if(t.button===2)return;if(t.metaKey||t.ctrlKey||t.button===1){t.button===1&&t.preventDefault?.();return}let r=yS(e.target,n);if(r===null)return;let i=n.getRegistration(r);i?.handlePrimary&&i.handlePrimary({nodeId:r,type:i.type,newTab:!1})||n.setActiveNode(r)},c=e=>{let t=e;if(t.button===2||t.type===`click`&&t.button===1||!(t.metaKey||t.ctrlKey||t.button===1))return;let r=yS(e.target,n);if(r===null)return;let i=n.getRegistration(r);i?.handlePrimary&&i.handlePrimary({nodeId:r,type:i.type,newTab:!0})&&t.preventDefault?.()},l=e=>{let t=e;if(t.key===`Escape`){n.getActiveNode()!==null&&(n.setActiveNode(null),t.preventDefault?.());return}if(t.key!==`Enter`&&t.key!==` `&&t.key!==`Spacebar`)return;let r=yS(e.target,n);if(r===null)return;let i=n.getRegistration(r);t.preventDefault?.(),!(i?.handlePrimary&&i.handlePrimary({nodeId:r,type:i.type,newTab:!1}))&&n.setActiveNode(r)},u=e=>{if(n.getActiveNode()===null)return;let t=e.target;t&&(r?.contains(t)||t instanceof Element&&(t.closest(`[data-ok-interaction-layer]`)||t.closest(`[data-ok-prop-panel]`)||t.closest(`[data-ok-layer-spawned]`))||n.setActiveNode(null))},d=()=>{i||(r=xS(t),r&&(r.addEventListener(`pointerdown`,s,!0),r.addEventListener(`click`,c,!0),r.addEventListener(`auxclick`,c,!0),r.addEventListener(`keydown`,l,!0),typeof document<`u`&&document.addEventListener(`pointerdown`,u,!0),i=!0))},f=()=>{i&&=(r?.removeEventListener(`pointerdown`,s,!0),r?.removeEventListener(`click`,c,!0),r?.removeEventListener(`auxclick`,c,!0),r?.removeEventListener(`keydown`,l,!0),typeof document<`u`&&document.removeEventListener(`pointerdown`,u,!0),!1)};return d(),{register(e){n.register(e),i||d()},deregister(e){n.deregister(e)},setActiveNode(e){n.setActiveNode(e)},getActiveNode(){return n.getActiveNode()},getRegistration(e){return n.getRegistration(e)},destroy(){f(),o(),n.clear()},store:n}}var wS=e=>{let t=(0,Yn.c)(2),{store:n}=e,r;return t[0]===n?r=t[1]:(r=(0,K.jsx)(`div`,{"data-ok-interaction-layer":``,className:`contents`,children:(0,K.jsx)(bS,{store:n})}),t[0]=n,t[1]=r),r},TS=new WeakMap;function ES(e){let t=TS.get(e);if(t)return t;let n=CS({editor:e});return TS.set(e,n),e.on(`destroy`,()=>{n.destroy(),TS.delete(e)}),n}var DS=new C(`markIdentity`);function OS(){return{byId:new Map,counter:0}}function kS(e,t,n,r,i){let a=[];for(let e of t.byId.values()){let t=i?i.map(e.from,-1):e.from,n=i?i.map(e.to,1):e.to;n<=t||a.push({id:e.id,markType:e.markType,attrs:e.attrs,from:t,to:n})}let o=new Map,s=new Set,c=t.counter;return e.descendants((e,t)=>{if(!(!e.isInline||e.marks.length===0))for(let i of e.marks){if(!n.has(i.type.name)||r&&!r(i))continue;let l=null;for(let e of a)if(!s.has(e.id)&&e.markType===i.type.name&&AS(e.attrs,i.attrs)&&!(t<e.from||t>=e.to)){l=e.id;break}let u=l??`m${++c}`;s.add(u);let d=t,f=t+e.nodeSize,p=o.get(u);p?p.to=Math.max(p.to,f):o.set(u,{id:u,markType:i.type.name,attrs:i.attrs,from:d,to:f})}}),{byId:o,counter:c}}function AS(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i&&!(typeof n==`object`&&n&&typeof i==`object`&&i&&AS(n,i)))return!1}return!0}function jS(e,t,n,r){let i=new Set(t.byId.keys());for(let[r,i]of t.byId)e.has(r)||n?.(i);for(let t of e)i.has(t)||r?.(t);return i}function MS(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new s({key:DS,state:{init(e,t){return kS(t.doc,OS(),a,n)},apply(e,t,r,i){return e.docChanged?kS(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=DS.getState(t.state);n&&(e=jS(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}function NS(e,t){return DS.getState(e)?.byId.get(t)??null}function PS(e){let{editor:t,layer:n,renderPropPanel:r,handlePrimary:i}=e;return{onRegister:e=>{n.register({type:e.markType,nodeId:e.id,controls:{propPanel:e=>r({editor:t,nodeId:e.nodeId,deactivate:e.deactivate})},handlePrimary:i?e=>i({editor:t,nodeId:e.nodeId,newTab:e.newTab}):void 0})},onDeregister:e=>{n.deregister(e)}}}function FS(e){let{editor:t,layer:n,markTypes:r,predicate:i,renderPropPanel:a,handlePrimary:o}=e,s=PS({editor:t,layer:n,renderPropPanel:a,handlePrimary:o});return MS({markTypes:[...r],predicate:i,onRegister:s.onRegister,onDeregister:s.onDeregister})}function IS(e){let t=ES(e.editor);return FS({...e,layer:t})}function LS(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=oe(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function RS(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
49
- `);return/\s/.test(n)}):!1}var zS=new C(`suggestion`);function BS({pluginKey:e=zS,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:o=[` `],startOfLine:c=!1,decorationTag:l=`span`,decorationClass:u=`suggestion`,decorationContent:d=``,decorationEmptyClass:f=`is-empty`,command:p=()=>null,items:m=()=>[],render:h=()=>({}),allow:g=()=>!0,findSuggestionMatch:_=LS,shouldShow:v,shouldResetDismissed:y}){let b,x=h?.(),S=r&&!i,C=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},w=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:C,T=({match:e,dismissedRange:n,state:r,transaction:i})=>y?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:S})?!1:S?e.range.from===n.from:e.range.from===n.from&&!RS(i);function E(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>p({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:w(n,a)};(i=x?.onExit)==null||i.call(x,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let D=new s({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,d=!c.active&&l.active,f=c.active&&!l.active,h=!d&&!f&&c.query!==l.query,g=d||u&&h,_=h||u,v=f||u&&h;if(!g&&!_&&!v)return;let y=v&&!g?c:l,S=e.dom.querySelector(`[data-decoration-id="${y.decorationId}"]`);b={editor:t,range:y.range,query:y.query,text:y.text,items:[],command:e=>p({editor:t,range:y.range,props:e}),decorationNode:S,clientRect:w(e,S)},g&&((r=x?.onBeforeStart)==null||r.call(x,b)),_&&((i=x?.onBeforeUpdate)==null||i.call(x,b)),(_||g)&&(b.items=await m({editor:t,query:y.query})),v&&((a=x?.onExit)==null||a.call(x,b)),_&&((o=x?.onUpdate)==null||o.call(x,b)),g&&((s=x?.onStart)==null||s.call(x,b))},destroy:()=>{var e;b&&((e=x?.onExit)==null||e.call(x,b))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(a,s,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=a,{empty:m,from:h}=p,y={...s},b=a.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=s.active?{...s.range}:s.dismissedRange,y;if(y.composing=f,a.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:a.mapping.map(y.dismissedRange.from),to:a.mapping.map(y.dismissedRange.to)}),d&&(m||t.view.composing)){(h<s.range.from||h>s.range.to)&&!f&&!s.composing&&(y.active=!1);let e=_({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:c,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&g({editor:t,state:u,range:e.range,isActive:s.active})&&(!v||v({editor:t,range:e.range,query:e.query,text:e.text,transaction:a}))?(y.dismissedRange!==null&&!T({match:e,dismissedRange:y.dismissedRange,state:u,transaction:a})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=s.decorationId?s.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=D.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=D.getState(t.state);return(r=x?.onKeyDown)==null||r.call(x,{view:t,event:n,range:i.range}),E(t,e),!0}return(x?.onKeyDown)?.call(x,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=D.getState(e);if(!t)return null;let o=!i?.length,s=[u];return o&&s.push(f),Be.create(e.doc,[a.inline(n.from,n.to,{nodeName:l,class:s.join(` `),"data-decoration-id":r,"data-decoration-content":d})])}}});return D}var VS=BS,HS=N(p(((e,t)=>{((e,n)=>{typeof define==`function`&&define.amd?define([],n):typeof t==`object`&&t.exports?t.exports=n():e.fuzzysort=n()})(e,e=>{var t=(e,t)=>{if(!e||!t)return F;var n=p(e);j(t)||(t=f(t));var r=n.bitflags;return(r&t._bitflags)===r?h(n,t):F},n=(e,t,n)=>{if(!e)return n?.all?m(t,n):P;var r=p(e),i=r.bitflags,a=r.containsSpace,o=u(n?.threshold||0),c=n?.limit||M,l=0,d=0,g=t.length;function _(e){l<c?(L.add(e),++l):(++d,e._score>L.peek()._score&&L.replaceTop(e))}if(n?.key)for(var v=n.key,y=0;y<g;++y){var b=t[y],x=A(b,v);if(x&&(j(x)||(x=f(x)),(i&x._bitflags)===i)){var S=h(r,x);S!==F&&(S._score<o||(S.obj=b,_(S)))}}else if(n?.keys){var C=n.keys,w=C.length;outer:for(var y=0;y<g;++y){for(var b=t[y],T=0,R=0;R<w;++R){var v=C[R],x=A(b,v);if(!x){O[R]=I;continue}j(x)||(x=f(x)),O[R]=x,T|=x._bitflags}if((i&T)===i){if(a)for(let e=0;e<r.spaceSearches.length;e++)E[e]=N;for(var R=0;R<w;++R){if(x=O[R],x===I){k[R]=I;continue}if(k[R]=h(r,x,!1,a),k[R]===F){k[R]=I;continue}if(a)for(let e=0;e<r.spaceSearches.length;e++){if(D[e]>-1e3&&E[e]>N){var z=(E[e]+D[e])/4;z>E[e]&&(E[e]=z)}D[e]>E[e]&&(E[e]=D[e])}}if(a){for(let e=0;e<r.spaceSearches.length;e++)if(E[e]===N)continue outer}else{var ee=!1;for(let e=0;e<w;e++)if(k[e]._score!==N){ee=!0;break}if(!ee)continue}var B=new s(w);for(let e=0;e<w;e++)B[e]=k[e];if(a){var V=0;for(let e=0;e<r.spaceSearches.length;e++)V+=E[e]}else{var V=N;for(let e=0;e<w;e++){var S=B[e];if(S._score>-1e3&&V>N){var z=(V+S._score)/4;z>V&&(V=z)}S._score>V&&(V=S._score)}}if(B.obj=b,B._score=V,n?.scoreFn){if(V=n.scoreFn(B),!V)continue;V=u(V),B._score=V}V<o||_(B)}}}else for(var y=0;y<g;++y){var x=t[y];if(x&&(j(x)||(x=f(x)),(i&x._bitflags)===i)){var S=h(r,x);S!==F&&(S._score<o||_(S))}}if(l===0)return P;for(var te=Array(l),y=l-1;y>=0;--y)te[y]=L.poll();return te.total=l+d,te},r=(e,t=`<b>`,n=`</b>`)=>{for(var r=typeof t==`function`?t:void 0,i=e.target,a=i.length,o=e.indexes,s=``,c=0,l=0,u=!1,d=[],f=0;f<a;++f){var p=i[f];if(o[l]===f){if(++l,u||(u=!0,r?(d.push(s),s=``):s+=t),l===o.length){r?(s+=p,d.push(r(s,c++)),s=``,d.push(i.substr(f+1))):s+=p+n+i.substr(f+1);break}}else u&&(u=!1,r?(d.push(r(s,c++)),s=``):s+=n);s+=p}return r?d:s},i=e=>{typeof e==`number`?e=``+e:typeof e!=`string`&&(e=``);var t=v(e);return c(e,{_targetLower:t._lower,_targetLowerCodes:t.lowerCodes,_bitflags:t.bitflags})},a=()=>{x.clear(),S.clear()};class o{get indexes(){return this._indexes.slice(0,this._indexes.len).sort((e,t)=>e-t)}set indexes(e){return this._indexes=e}highlight(e,t){return r(this,e,t)}get score(){return l(this._score)}set score(e){this._score=u(e)}}class s extends Array{get score(){return l(this._score)}set score(e){this._score=u(e)}}var c=(e,t)=>{let n=new o;return n.target=e,n.obj=t.obj??F,n._score=t._score??N,n._indexes=t._indexes??[],n._targetLower=t._targetLower??``,n._targetLowerCodes=t._targetLowerCodes??F,n._nextBeginningIndexes=t._nextBeginningIndexes??F,n._bitflags=t._bitflags??0,n},l=e=>e===N?0:e>1?e:Math.E**(((-e+1)**.04307-1)*-2),u=e=>e===0?N:e>1?e:1-(Math.log(e)/-2+1)**(1/.04307),d=e=>{typeof e==`number`?e=``+e:typeof e!=`string`&&(e=``),e=e.trim();var t=v(e),n=[];if(t.containsSpace){var r=e.split(/\s+/);r=[...new Set(r)];for(var i=0;i<r.length;i++)if(r[i]!==``){var a=v(r[i]);n.push({lowerCodes:a.lowerCodes,_lower:r[i].toLowerCase(),containsSpace:!1})}}return{lowerCodes:t.lowerCodes,_lower:t._lower,containsSpace:t.containsSpace,bitflags:t.bitflags,spaceSearches:n}},f=e=>{if(e.length>999)return i(e);var t=x.get(e);return t===void 0?(t=i(e),x.set(e,t),t):t},p=e=>{if(e.length>999)return d(e);var t=S.get(e);return t===void 0?(t=d(e),S.set(e,t),t):t},m=(e,t)=>{var n=[];n.total=e.length;var r=t?.limit||M;if(t?.key)for(var i=0;i<e.length;i++){var a=e[i],o=A(a,t.key);if(o!=F){j(o)||(o=f(o));var l=c(o.target,{_score:o._score,obj:a});if(n.push(l),n.length>=r)return n}}else if(t?.keys)for(var i=0;i<e.length;i++){for(var a=e[i],u=new s(t.keys.length),d=t.keys.length-1;d>=0;--d){var o=A(a,t.keys[d]);if(!o){u[d]=I;continue}j(o)||(o=f(o)),o._score=N,o._indexes.len=0,u[d]=o}if(u.obj=a,u._score=N,n.push(u),n.length>=r)return n}else for(var i=0;i<e.length;i++){var o=e[i];if(o!=F&&(j(o)||(o=f(o)),o._score=N,o._indexes.len=0,n.push(o),n.length>=r))return n}return n},h=(e,t,n=!1,r=!1)=>{if(n===!1&&e.containsSpace)return g(e,t,r);for(var i=e._lower,a=e.lowerCodes,s=a[0],c=t._targetLowerCodes,l=a.length,u=c.length,d=0,f=0,p=0;;){var m=s===c[f];if(m){if(C[p++]=f,++d,d===l)break;s=a[d]}if(++f,f>=u)return F}var d=0,h=!1,_=0,v=t._nextBeginningIndexes;v===F&&(v=t._nextBeginningIndexes=b(t.target)),f=C[0]===0?0:v[C[0]-1];var y=0;if(f!==u)for(;;)if(f>=u){if(d<=0||(++y,y>200))break;--d;var x=w[--_];f=v[x]}else{var m=a[d]===c[f];if(m){if(w[_++]=f,++d,d===l){h=!0;break}++f}else f=v[f]}var S=l<=1?-1:t._targetLower.indexOf(i,C[0]),T=!!~S,E=T?S===0||t._nextBeginningIndexes[S-1]===S:!1;if(T&&!E){for(var D=0;D<v.length;D=v[D])if(!(D<=S)){for(var O=0;O<l&&a[O]===t._targetLowerCodes[D+O];O++);if(O===l){S=D,E=!0;break}}}var k=e=>{for(var t=0,n=0,r=1;r<l;++r)e[r]-e[r-1]!==1&&(t-=e[r],++n);var i=e[l-1]-e[0]-(l-1);if(t-=(12+i)*n,e[0]!==0&&(t-=e[0]*e[0]*.2),!h)t*=1e3;else{for(var a=1,r=v[0];r<u;r=v[r])++a;a>24&&(t*=(a-24)*10)}return t-=(u-l)/2,T&&(t/=1+l*l*1),E&&(t/=1+l*l*1),t-=(u-l)/2,t};if(!h){if(T)for(var D=0;D<l;++D)C[D]=S+D;var A=C,j=k(A)}else if(E){for(var D=0;D<l;++D)C[D]=S+D;var A=C,j=k(C)}else var A=w,j=k(w);t._score=j;for(var D=0;D<l;++D)t._indexes[D]=A[D];t._indexes.len=l;let M=new o;return M.target=t.target,M._score=t._score,M._indexes=t._indexes,M},g=(e,t,n)=>{for(var r=new Set,i=0,a=F,o=0,s=e.spaceSearches,c=s.length,l=0,u=()=>{for(let e=l-1;e>=0;e--)t._nextBeginningIndexes[T[e*2+0]]=T[e*2+1]},d=!1,f=0;f<c;++f){D[f]=N;var p=s[f];if(a=h(p,t),n){if(a===F)continue;d=!0}else if(a===F)return u(),F;if(f!==c-1){var m=a._indexes,g=!0;for(let e=0;e<m.len-1;e++)if(m[e+1]-m[e]!==1){g=!1;break}if(g){var _=m[m.len-1]+1,v=t._nextBeginningIndexes[_-1];for(let e=_-1;e>=0&&v===t._nextBeginningIndexes[e];e--)t._nextBeginningIndexes[e]=_,T[l*2+0]=e,T[l*2+1]=v,l++}}i+=a._score/c,D[f]=a._score/c,a._indexes[0]<o&&(i-=(o-a._indexes[0])*2),o=a._indexes[0];for(var y=0;y<a._indexes.len;++y)r.add(a._indexes[y])}if(n&&!d)return F;u();var b=h(e,t,!0);if(b!==F&&b._score>i){if(n)for(var f=0;f<c;++f)D[f]=b._score/c;return b}n&&(a=t),a._score=i;var f=0;for(let e of r)a._indexes[f++]=e;return a._indexes.len=f,a},_=e=>e.replace(/\p{Script=Latin}+/gu,e=>e.normalize(`NFD`)).replace(/[\u0300-\u036f]/g,``),v=e=>{e=_(e);for(var t=e.length,n=e.toLowerCase(),r=[],i=0,a=!1,o=0;o<t;++o){var s=r[o]=n.charCodeAt(o);if(s===32){a=!0;continue}var c=s>=97&&s<=122?s-97:s>=48&&s<=57?26:s<=127?30:31;i|=1<<c}return{lowerCodes:r,bitflags:i,containsSpace:a,_lower:n}},y=e=>{for(var t=e.length,n=[],r=0,i=!1,a=!1,o=0;o<t;++o){var s=e.charCodeAt(o),c=s>=65&&s<=90,l=c||s>=97&&s<=122||s>=48&&s<=57,u=c&&!i||!a||!l;i=c,a=l,u&&(n[r++]=o)}return n},b=e=>{e=_(e);for(var t=e.length,n=y(e),r=[],i=n[0],a=0,o=0;o<t;++o)i>o?r[o]=i:(i=n[++a],r[o]=i===void 0?t:i);return r},x=new Map,S=new Map,C=[],w=[],T=[],E=[],D=[],O=[],k=[],A=(e,t)=>{var n=e[t];if(n!==void 0)return n;if(typeof t==`function`)return t(e);var r=t;Array.isArray(t)||(r=t.split(`.`));for(var i=r.length,a=-1;e&&++a<i;)e=e[r[a]];return e},j=e=>typeof e==`object`&&typeof e._bitflags==`number`,M=1/0,N=-M,P=[];P.total=0;var F=null,I=i(``),L=(e=>{var t=[],n=0,r={},i=e=>{for(var r=0,i=t[r],a=1;a<n;){var o=a+1;r=a,o<n&&t[o]._score<t[a]._score&&(r=o),t[r-1>>1]=t[r],a=1+(r<<1)}for(var s=r-1>>1;r>0&&i._score<t[s]._score;s=(r=s)-1>>1)t[r]=t[s];t[r]=i};return r.add=(e=>{var r=n;t[n++]=e;for(var i=r-1>>1;r>0&&e._score<t[i]._score;i=(r=i)-1>>1)t[r]=t[i];t[r]=e}),r.poll=(e=>{if(n!==0){var r=t[0];return t[0]=t[--n],i(),r}}),r.peek=(e=>{if(n!==0)return t[0]}),r.replaceTop=(e=>{t[0]=e,i()}),r})();return{single:t,go:n,prepare:i,cleanup:a}})}))(),1);function US(e){return e.kind===`anchor`?`${e.docName}#${e.slug}`:e.docName}function WS(e){return e.kind===`anchor`?`Heading H${e.level}: ${e.text}`:e.kind===`create`?e.actionLabel:e.title}function GS(e){let t=(0,Yn.c)(41),{items:n,query:r,selectedIndex:i,onSelect:a,loading:o,error:s,mode:c,pageTarget:l,anchorQuery:u}=e,d=o===void 0?!1:o,f=s===void 0?null:s,p=c===void 0?`page`:c,m=l===void 0?``:l,h=u===void 0?``:u,g=(0,q.useRef)(null),_=(0,q.useId)(),v=i>=0&&i<n.length?`${_}-option-${i}`:void 0,y,b;t[0]===i?(y=t[1],b=t[2]):(y=()=>{let e=g.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(i);t&&t.scrollIntoView({block:`nearest`})},b=[i],t[0]=i,t[1]=y,t[2]=b),(0,q.useEffect)(y,b);let x=KS;if(d){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n=p===`anchor`?`Loading headings for ${m}…`:`Loading pages…`,r;return t[4]===n?r=t[5]:(r=(0,K.jsx)(`div`,{ref:g,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:x,children:n}),t[4]=n,t[5]=r),r}if(n.length===0){let e;t[6]!==h||t[7]!==f||t[8]!==p||t[9]!==m||t[10]!==r?(e=f??(p===`anchor`?h.trim()?`No headings match "${h.trim()}"`:`No headings in ${m}`:r.trim()?`No pages found for "${r.trim()}"`:`No pages found`),t[6]=h,t[7]=f,t[8]=p,t[9]=m,t[10]=r,t[11]=e):e=t[11];let n=e,i;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(i={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[12]=i):i=t[12];let a;return t[13]===n?a=t[14]:(a=(0,K.jsx)(`div`,{ref:g,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:i,onMouseDown:x,children:n}),t[13]=n,t[14]=a),a}let S=i>=0&&i<n.length?n[i]:null,C=p===`anchor`?`Heading suggestions`:`Wiki link suggestions`,w;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(w={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[15]=w):w=t[15];let T;t[16]===S?T=t[17]:(T=S?WS(S):``,t[16]=S,t[17]=T);let E;t[18]===T?E=t[19]:(E=(0,K.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:T}),t[18]=T,t[19]=E);let D;t[20]===f?D=t[21]:(D=f&&(0,K.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300`,children:f}),t[20]=f,t[21]=D);let O;t[22]!==p||t[23]!==m?(O=p===`anchor`&&(0,K.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:m}),t[22]=p,t[23]=m,t[24]=O):O=t[24];let k;if(t[25]!==n||t[26]!==_||t[27]!==a||t[28]!==i){let e;t[30]!==_||t[31]!==a||t[32]!==i?(e=(e,t)=>{let n=t===i,r=US(e);return e.kind===`anchor`?(0,K.jsxs)(`button`,{id:`${_}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,style:{paddingLeft:`${(e.level-1)*10+8}px`},onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,K.jsxs)(`span`,{className:`w-6 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,K.jsx)(`span`,{className:`truncate font-medium`,children:e.text})]},r):(0,K.jsxs)(`button`,{id:`${_}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full flex-col rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:e.kind===`create`?e.actionLabel:e.title}),e.kind===`page`&&e.title!==e.docName&&(0,K.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.docName}),e.kind===`create`&&(0,K.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[e.docName,`.md`]})]},r)},t[30]=_,t[31]=a,t[32]=i,t[33]=e):e=t[33],k=n.map(e),t[25]=n,t[26]=_,t[27]=a,t[28]=i,t[29]=k}else k=t[29];let A;return t[34]!==v||t[35]!==E||t[36]!==D||t[37]!==O||t[38]!==k||t[39]!==C?(A=(0,K.jsxs)(`div`,{ref:g,role:`listbox`,"aria-label":C,"aria-activedescendant":v,tabIndex:-1,onMouseDown:x,className:`w-64 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:w,children:[E,D,O,k]}),t[34]=v,t[35]=E,t[36]=D,t[37]=O,t[38]=k,t[39]=C,t[40]=A):A=t[40],A}function KS(e){return e.preventDefault()}function qS(e,t){let n=document.createElement(`div`);n.style.position=`fixed`,n.style.zIndex=`50`,n.style.visibility=`hidden`,document.body.appendChild(n);let r={getBoundingClientRect:()=>e()?.clientRect?.()??new DOMRect,get contextElement(){return e()?.editor.view.dom}},a=!1,o=!1,s=()=>{n.isConnected&&(n.style.removeProperty(`--suggestion-menu-max-height`),i(r,n,{placement:`bottom-start`,middleware:[f(4),M(),De({apply({availableHeight:e}){n.isConnected&&n.style.setProperty(`--suggestion-menu-max-height`,`${Math.min(e,window.innerHeight*.4)}px`)}})]}).then(({x:e,y:t})=>{n.isConnected&&(n.style.left=`${e}px`,n.style.top=`${t}px`,a&&!o&&(n.style.removeProperty(`visibility`),o=!0))}).catch(e=>{n.isConnected&&console.warn(`[${t}] computePosition failed`,e)}))};return{popup:n,doPosition:s,startAutoUpdate:()=>Ge(r,n,s),reveal:()=>{o||(a=!0,s())}}}function JS(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var YS=new C(`wikiLinkSuggestion`),XS=8;function ZS(e){let t=e.indexOf(`#`);return t>0?{mode:`anchor`,pageTarget:e.slice(0,t),anchorQuery:e.slice(t+1)}:{mode:`page`,pageTarget:``,anchorQuery:``}}function QS(e,t){return t?HS.default.go(t,e,{keys:[`title`,`docName`],threshold:-1e4}).map(e=>e.obj).slice(0,XS):e.slice(0,XS)}function $S(e,t){return t?HS.default.go(t,e,{key:`text`,threshold:-1e4}).map(e=>e.obj).slice(0,XS):e.slice(0,XS)}function eC(e,t){let n=QS(e,t);if(n.length>0)return n.map(e=>({kind:`page`,...e}));let r=Gx(t);return r?[{kind:`create`,docName:r.target,title:t.trim(),actionLabel:`Insert unresolved link "${t.trim()}"`}]:[]}function tC(e,t,n){return $S(t,n).map(t=>({kind:`anchor`,docName:e,level:t.level,text:t.text,slug:t.slug}))}function nC(e){let{mode:t,pageTarget:n,anchorQuery:r}=ZS(e);return t===`anchor`&&n?{target:n,alias:null,anchor:r.trim()||null}:Gx(e)}function rC(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``),r=n.match(/\[\[([^\]]*)$/);if(!r)return null;let i=r[1];return{range:{from:t.start()+n.lastIndexOf(`[[`),to:t.pos},query:i,text:r[0]}}async function iC(){let e=await fetch(`/api/pages`);if(!e.ok)throw Error(`/api/pages responded with ${e.status}`);let t=await e.json();return Array.isArray(t.pages)?t.pages:[]}async function aC(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`/api/page-headings responded with ${t.status}`);let n=await t.json();return n.ok&&Array.isArray(n.headings)?n.headings:[]}function oC(e){let t=[],n=!1,r=!1,i=new Map,a=null,o=null,s=null;return VS({editor:e,pluginKey:YS,char:`[[`,allowedPrefixes:null,findSuggestionMatch:rC,items:async({query:e})=>{let{mode:c,pageTarget:l,anchorQuery:u}=ZS(e);if(c===`anchor`){if(!i.has(l)&&a!==l){a=l;try{let e=await aC(l);i.set(l,e),s=null}catch(e){console.error(`[wiki-link-suggestion] Failed to fetch headings:`,e),i.set(l,[]),s=`Failed to load headings for ${l}. Press Escape and type [[ again to retry.`}finally{a=null}}return tC(l,i.get(l)??[],u)}if(!n&&!r){r=!0;try{t=await iC(),o=null}catch(e){console.error(`[wiki-link-suggestion] Failed to fetch pages:`,e),o=`Failed to load pages. Press Escape and type [[ again to retry, or continue typing to insert an unresolved link.`,t=[]}finally{n=!0,r=!1}}return eC(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=null;if(n.kind===`page`?r={target:n.docName,alias:null,anchor:null}:n.kind===`anchor`?r={target:n.docName,alias:null,anchor:n.slug}:n.kind===`create`&&(r=Gx(n.title)),!r)return;e.chain().focus().deleteRange(t).insertContent({type:`wikiLink`,attrs:r}).run()}catch(e){console.error(`[wiki-link-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,c=null,l=0,u={popup:null,stopAutoUpdate:null},d=null,f=null,p=e=>{c?.command(e)};function m(e,t,r){let{mode:a,pageTarget:c,anchorQuery:u}=ZS(e.query??``),d=t===null?a===`anchor`?!i.has(c):!n:t;return{items:e.items,query:e.query??``,selectedIndex:l,onSelect:r,loading:d,error:a===`page`?o:s,mode:a,pageTarget:c,anchorQuery:u}}let h=t=>{!e||!c||e.updateProps(m(c,t,p))},g=()=>{if(!c)return;let{editor:e,range:t}=c,n=nC(c.query??``);if(n)try{e.chain().focus().deleteRange(t).insertContent({type:`wikiLink`,attrs:n}).run()}catch(e){console.error(`[wiki-link-suggestion] fallback insert error:`,e)}};return{onBeforeStart(t){c=t,l=0;let n=qS(()=>c,`wiki-link-suggestion`);u.popup=n.popup,d=n.doPosition,f=n.reveal,e=new Ds(GS,{props:m(t,!0,p),editor:t.editor}),n.popup.appendChild(e.element),u.stopAutoUpdate=n.startAutoUpdate()},onBeforeUpdate(e){let t=c?ZS(c.query??``).mode:null,n=ZS(e.query??``).mode;c=e,t!==n&&(l=0,h(!0))},onStart(e){c=e,l=0,h(null),f?.()},onUpdate(e){c=e,l=Math.min(l,Math.max(0,e.items.length-1)),h(null),d?.()},onKeyDown({event:e}){if(!c)return!1;let t=c.items;if(e.key===`ArrowDown`)return t.length===0?!1:(l=(l+1)%t.length,h(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(l=(l-1+t.length)%t.length,h(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[l];return e?c.command(e):g(),!0}return e.key,!1},onExit(){JS(u),d=null,f=null,e?.destroy(),e=null,c=null,l=0,t=[],i=new Map,o=null,s=null,n=!1,r=!1,a=null}}}})}function sC(e,t){let n=(0,Yn.c)(4),[r,i]=(0,q.useState)(null),a,o;return n[0]!==e||n[1]!==t?(a=()=>{if(!t||!e){i(null);return}let n=!1;return i(null),aC(e).then(e=>{n||i(e)}).catch(()=>{n||i([])}),()=>{n=!0}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,q.useEffect)(a,o),r}function cC(e,t){let n=e.trim();return n?n.startsWith(`#`)?`anchor`:n.startsWith(`/`)||He(n)?`external`:`doc`:t}function lC(e){return e?.kind===`doc`?`doc`:e?.kind===`anchor`?`anchor`:`external`}function uC(e){let t=(0,Yn.c)(64),{open:n,href:r,pages:i,onOpenChange:a,onSave:o}=e,[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(`doc`),p=(0,q.useId)(),m=(0,q.useId)(),g=(0,q.useId)(),_,v;t[0]!==r||t[1]!==n?(_=()=>{if(!n)return;let e=Qx(r);if(f(lC(e)),e?.kind===`doc`){c(e.docName),u(e.anchor??``);return}if(e?.kind===`anchor`){c(`#${e.anchor}`),u(``);return}c(e?.kind===`external`?e.url:r),u(``)},v=[r,n],t[0]=r,t[1]=n,t[2]=_,t[3]=v):(_=t[2],v=t[3]),(0,q.useEffect)(_,v);let y,b,x;t[4]!==d||t[5]!==s||t[6]!==i?(y=te(s),b=d===`doc`,x=b&&qx(y,i),t[4]=d,t[5]=s,t[6]=i,t[7]=y,t[8]=b,t[9]=x):(y=t[7],b=t[8],x=t[9]);let S=sC(y,x&&n),C=!!S?.length,w;t[10]!==y||t[11]!==b||t[12]!==l||t[13]!==s||t[14]!==a||t[15]!==o?(w=function(){let e=s.trim();e&&(o(b?oS(y,l.trim()||null):e),a(!1))},t[10]=y,t[11]=b,t[12]=l,t[13]=s,t[14]=a,t[15]=o,t[16]=w):w=t[16];let T=w,E;t[17]===T?E=t[18]:(E=function(e){e.key===`Enter`&&(e.preventDefault(),T())},t[17]=T,t[18]=E);let D=E,O;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,K.jsx)(Ka,{className:`fixed inset-0 z-50 bg-black/40 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`}),t[19]=O):O=t[19];let k,A;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,K.jsx)(Ja,{className:`mb-1 text-base font-semibold`,children:`Edit markdown link`}),A=(0,K.jsx)(Ya,{className:`mb-4 text-sm text-muted-foreground`,children:`Update the destination and optional section anchor.`}),t[20]=k,t[21]=A):(k=t[20],A=t[21]);let j=b?`Page`:`Link target`,M;t[22]!==j||t[23]!==p?(M=(0,K.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:p,children:j}),t[22]=j,t[23]=p,t[24]=M):M=t[24];let N;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{let t=e.target.value;c(t),f(e=>cC(t,e))},t[25]=N):N=t[25];let P;t[26]!==s||t[27]!==D||t[28]!==p?(P=(0,K.jsx)(uS,{id:p,value:s,onChange:N,placeholder:`guides/install or https://example.com`,autoFocus:!0,onKeyDown:D}),t[26]=s,t[27]=D,t[28]=p,t[29]=P):P=t[29];let F;t[30]===b?F=t[31]:(F=b?(0,K.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`This changes the destination page. The visible link text stays editable inline in the document.`}):null,t[30]=b,t[31]=F);let I;t[32]!==M||t[33]!==P||t[34]!==F?(I=(0,K.jsxs)(`div`,{children:[M,P,F]}),t[32]=M,t[33]=P,t[34]=F,t[35]=I):I=t[35];let L;t[36]!==m||t[37]!==b||t[38]!==l||t[39]!==D||t[40]!==g||t[41]!==S||t[42]!==C?(L=b?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:m,children:[`Section`,` `,(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional heading anchor)`})]}),(0,K.jsx)(uS,{id:m,value:l,onChange:e=>u(e.target.value),placeholder:`heading-slug`,"aria-controls":C?g:void 0,"aria-expanded":C?!0:void 0,"aria-haspopup":C?`listbox`:void 0,onKeyDown:D}),C?(0,K.jsx)(`div`,{role:`listbox`,id:g,"aria-label":`Heading anchors`,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:S.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":l===e.slug,className:h(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,l===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>u(l===e.slug?``:e.slug),children:[(0,K.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,K.jsx)(`span`,{className:`truncate`,children:e.text})]},`${e.slug}-${e.level}-${e.text}`))}):null]}):null,t[36]=m,t[37]=b,t[38]=l,t[39]=D,t[40]=g,t[41]=S,t[42]=C,t[43]=L):L=t[43];let R;t[44]!==I||t[45]!==L?(R=(0,K.jsxs)(`div`,{className:`mb-4 space-y-6`,children:[I,L]}),t[44]=I,t[45]=L,t[46]=R):R=t[46];let z;t[47]===a?z=t[48]:(z=(0,K.jsx)(Ce,{variant:`outline`,onClick:()=>a(!1),children:`Cancel`}),t[47]=a,t[48]=z);let ee;t[49]===s?ee=t[50]:(ee=s.trim(),t[49]=s,t[50]=ee);let B=!ee,V;t[51]!==T||t[52]!==B?(V=(0,K.jsx)(Ce,{onClick:T,disabled:B,children:`Save`}),t[51]=T,t[52]=B,t[53]=V):V=t[53];let ne;t[54]!==z||t[55]!==V?(ne=(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[z,V]}),t[54]=z,t[55]=V,t[56]=ne):ne=t[56];let re;t[57]!==R||t[58]!==ne?(re=(0,K.jsxs)(Ga,{children:[O,(0,K.jsxs)(qa,{"data-slot":`dialog-content`,"data-ok-layer-spawned":``,className:`fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-lg border border-border bg-background p-6 shadow-xl data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,children:[k,A,R,ne]})]}),t[57]=R,t[58]=ne,t[59]=re):re=t[59];let H;return t[60]!==a||t[61]!==n||t[62]!==re?(H=(0,K.jsx)(Wa,{open:n,onOpenChange:a,children:re}),t[60]=a,t[61]=n,t[62]=re,t[63]=H):H=t[63],H}function dC(e){let t=(0,Yn.c)(81),{editor:n,nodeId:r,sourceDocName:i,onClose:a}=e,o=NS(n.state,r),s=o?.attrs?.href??``,[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(null),{folderPaths:f,pages:p,loading:m}=ge();if(!o||!s)return null;let g=z(s,i),_;t[0]!==n||t[1]!==r?(_=function(e){let t=NS(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:e}).run()},t[0]=n,t[1]=r,t[2]=_):_=t[2];let v=_,y;t[3]!==n||t[4]!==r||t[5]!==a?(y=function(){let e=NS(n.state,r);e&&(n.chain().focus().setTextSelection({from:e.from,to:e.to}).extendMarkRange(`link`).unsetLink().run(),a())},t[3]=n,t[4]=r,t[5]=a,t[6]=y):y=t[6];let b=y,x=function(e){if(g){if(g.kind===`external`){aS(g);return}if(g.kind===`anchor`||g.kind===`doc`){let t=g.kind===`doc`?g.docName:i,n=g.anchor??null;e.newTab?nS({docName:t,anchor:n}):window.location.assign($x({docName:t,anchor:n}))}}},S=function(e){if(u!==`missing`)return;let t=NS(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:oS(e,g?.kind===`doc`?g.anchor??null:null)}).run()},C,w=!1,T=!1,E=null;if(m){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Hn,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[7]=e):e=t[7],C={icon:e,text:`Loading…`,className:`text-muted-foreground`}}else if(g?.kind===`external`){let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(jn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[8]=e):e=t[8],C={icon:e,text:`External link`,className:`text-foreground`}}else if(g?.kind===`anchor`){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Nn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[9]=e):e=t[9],C={icon:e,text:`Anchor in this page`,className:`text-foreground`}}else if(g?.kind===`doc`){let e=cS(g.docName,{pages:p,folderPaths:f});if(E=lS(e),T=e.kind===`navigate`&&e.displayState===`folder`,w=e.kind===`create`,T){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Pn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[10]=e):e=t[10],C={icon:e,text:`Folder (no index)`,className:`text-foreground`}}else if(w){let e;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(kn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[11]=e):e=t[11],C={icon:e,text:`Page not found`,className:`text-red-700 dark:text-red-300`}}else{let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Nn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[12]=e):e=t[12],C={icon:e,text:`Page link`,className:`text-foreground`}}}else{let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(kn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[13]=e):e=t[13],C={icon:e,text:`Unrecognized link`,className:`text-muted-foreground`}}let D=h(`text-sm font-medium`,C.className),O;t[14]!==C.text||t[15]!==D?(O=(0,K.jsx)(`div`,{className:D,children:C.text}),t[14]=C.text,t[15]=D,t[16]=O):O=t[16];let k;t[17]===s?k=t[18]:(k=(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,title:s,children:s}),t[17]=s,t[18]=k);let A;t[19]!==O||t[20]!==k?(A=(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[O,k]}),t[19]=O,t[20]=k,t[21]=A):A=t[21];let j;t[22]!==x||t[23]!==w||t[24]!==a||t[25]!==g?.kind?(j=w?null:(0,K.jsx)(Ce,{size:`sm`,variant:`default`,onClick:()=>{x({}),a()},children:g?.kind===`external`?`Open in new tab`:`Open`}),t[22]=x,t[23]=w,t[24]=a,t[25]=g?.kind,t[26]=j):j=t[26];let M;t[27]!==w||t[28]!==d?(M=w?(0,K.jsx)(Ce,{size:`sm`,variant:`default`,onClick:()=>d(`missing`),children:`Create page`}):null,t[27]=w,t[28]=d,t[29]=M):M=t[29];let N;t[30]!==E||t[31]!==T||t[32]!==d?(N=T&&E?(0,K.jsxs)(Ce,{size:`sm`,variant:`outline`,onClick:()=>d(`folder-index`),children:[(0,K.jsx)(Mn,{className:`size-3.5`,"aria-hidden":`true`}),`Create index`]}):null,t[30]=E,t[31]=T,t[32]=d,t[33]=N):N=t[33];let P;t[34]===l?P=t[35]:(P=()=>l(!0),t[34]=l,t[35]=P);let F;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,K.jsx)(Wn,{className:`size-3.5`,"aria-hidden":`true`}),t[36]=F):F=t[36];let I;t[37]===P?I=t[38]:(I=(0,K.jsxs)(Ce,{size:`sm`,variant:`outline`,onClick:P,children:[F,`Edit`]}),t[37]=P,t[38]=I);let L;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,K.jsx)(qn,{className:`size-3.5`,"aria-hidden":`true`}),t[39]=L):L=t[39];let R;t[40]===b?R=t[41]:(R=(0,K.jsxs)(Ce,{size:`sm`,variant:`outline`,className:`text-red-700 hover:bg-red-50 hover:text-red-800 dark:text-red-300 dark:hover:bg-red-100/10 dark:hover:text-red-200`,onClick:b,children:[L,`Remove`]}),t[40]=b,t[41]=R);let ee;t[42]!==N||t[43]!==I||t[44]!==R||t[45]!==j||t[46]!==M?(ee=(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[j,M,N,I,R]}),t[42]=N,t[43]=I,t[44]=R,t[45]=j,t[46]=M,t[47]=ee):ee=t[47];let B=u!==null,V;t[48]===d?V=t[49]:(V=e=>{e||d(null)},t[48]=d,t[49]=V);let te;t[50]!==u||t[51]!==E||t[52]!==f||t[53]!==w||t[54]!==p||t[55]!==g?(te=u===`folder-index`&&E?E.initialDir:w&&g?.kind===`doc`&&cS(g.docName,{pages:p,folderPaths:f}).kind===`create`?cS(g.docName,{pages:p,folderPaths:f}).initialDir:``,t[50]=u,t[51]=E,t[52]=f,t[53]=w,t[54]=p,t[55]=g,t[56]=te):te=t[56];let ne;t[57]!==u||t[58]!==E||t[59]!==f||t[60]!==w||t[61]!==p||t[62]!==g?(ne=u===`folder-index`&&E?E.suggestedName:w&&g?.kind===`doc`&&cS(g.docName,{pages:p,folderPaths:f}).kind===`create`?cS(g.docName,{pages:p,folderPaths:f}).suggestedName:void 0,t[57]=u,t[58]=E,t[59]=f,t[60]=w,t[61]=p,t[62]=g,t[63]=ne):ne=t[63];let re;t[64]!==u||t[65]!==E||t[66]!==g?(re=u===`folder-index`&&E?(0,K.jsxs)(K.Fragment,{children:[`Create an index note for`,` `,(0,K.jsxs)(`span`,{className:`font-medium text-foreground`,children:[E.initialDir,`/`]})]}):(0,K.jsxs)(K.Fragment,{children:[`Create a page for`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:g?.kind===`doc`?g.docName:``})]}),t[64]=u,t[65]=E,t[66]=g,t[67]=re):re=t[67];let H;t[68]!==S||t[69]!==B||t[70]!==V||t[71]!==te||t[72]!==ne||t[73]!==re?(H=(0,K.jsx)(gS,{open:B,onOpenChange:V,kind:`file`,initialDir:te,suggestedName:ne,description:re,onCreated:S}),t[68]=S,t[69]=B,t[70]=V,t[71]=te,t[72]=ne,t[73]=re,t[74]=H):H=t[74];let ie;return t[75]!==c||t[76]!==v||t[77]!==s||t[78]!==p||t[79]!==l?(ie=(0,K.jsx)(uC,{open:c,href:s,pages:p,onOpenChange:l,onSave:v}),t[75]=c,t[76]=v,t[77]=s,t[78]=p,t[79]=l,t[80]=ie):ie=t[80],(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(sS,{kind:`internal-link`,ariaLabel:`Link options`,onDeactivate:a,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-start gap-2 pr-8`,children:[(0,K.jsx)(`div`,{className:h(`mt-0.5 flex shrink-0`,C.className),children:C.icon}),A]}),ee]}),H,ie]})}function fC(e,t,n){let r=z(e,t);if(!r)return`unresolved`;if(r.kind===`external`)return`external`;if(r.kind===`anchor`)return`anchor`;if(n===null)return`loading`;let i=cS(r.docName,{pages:n.pages,folderPaths:n.folderPaths});return i.kind===`create`?`unresolved`:i.displayState}function pC(e,t,n){let r=e.attrs?.href;return typeof r!=`string`||r.length===0?null:{"data-resolution-state":fC(r,n,t)}}function mC(e){return(t,n)=>pC(t,n,e)}var hC=new C(`linkResolutionDecoration`);function gC(e,t,n,r,i){if(t.size===0)return null;let o=[];for(let e of t.values()){if(!n.has(e.markType))continue;let t=r(e,i);t!==null&&o.push(a.inline(e.from,e.to,t))}return o.length===0?null:Be.create(e,o)}function _C(e){let t=new Set(e.markTypes),{computeAttrs:n}=e;return new s({key:hC,state:{init:()=>({version:0}),apply(e,t){let n=e.getMeta(hC);return n&&typeof n==`object`&&n.refresh?{version:t.version+1}:t}},props:{decorations(e){let r=DS.getState(e);if(!r)return null;let i=ae();return gC(e.doc,r.byId,t,n,i)}},view(e){let t=we(()=>{e.dispatch(e.state.tr.setMeta(hC,{refresh:!0}))});return{destroy(){t()}}}})}var vC=new C(`markIdentityDecoration`),yC=`data-mark-id`;function bC(){return new s({key:vC,props:{decorations(e){let t=DS.getState(e);if(!t||t.byId.size===0)return null;let n=[];for(let e of t.byId.values())n.push(a.inline(e.from,e.to,{[yC]:e.id}));return Be.create(e.doc,n)}}})}var xC=r.extend({addOptions(){return{...this.parent?.(),docName:``}},renderHTML({HTMLAttributes:e}){let t=typeof e.href==`string`?e.href:``;return[`span`,re(e,{"data-link":``,role:`link`,tabindex:`0`,"aria-label":t?`Link: ${t}`:`Link`,style:`touch-action: manipulation;`}),0]},addProseMirrorPlugins(){let e=this.options.docName??``;return[IS({editor:this.editor,markTypes:[`link`],renderPropPanel:({editor:t,nodeId:n,deactivate:r})=>(0,q.createElement)(dC,{editor:t,nodeId:n,sourceDocName:e,onClose:r}),handlePrimary:({editor:t,nodeId:n,newTab:r})=>{if(!r)return!1;let i=NS(t.state,n)?.attrs?.href;if(typeof i!=`string`||!i)return!1;let a=z(i,e);return a?a.kind===`doc`?(nS({docName:a.docName,anchor:a.anchor}),!0):a.kind===`anchor`?(nS({docName:e,anchor:a.anchor}),!0):Xx(a.url)?(eS(a.url),!0):!1:!1}}),bC(),_C({markTypes:[`link`],computeAttrs:mC(e)})]}}),SC={warning:`bg-amber-100 text-amber-900 dark:bg-amber-900/40 dark:text-amber-200`,info:`bg-sky-100 text-sky-900 dark:bg-sky-900/40 dark:text-sky-200`,error:`bg-red-100 text-red-900 dark:bg-red-900/40 dark:text-red-200`},CC={warning:`alert`,error:`alert`,info:`note`};function wC(e){let t=(0,Yn.c)(11),{type:n,children:r}=e,i=CC[n]||`note`,a=SC[n]||`bg-muted text-foreground`,o;t[0]===a?o=t[1]:(o=h(`p-3 px-4 rounded-md`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=n.toUpperCase(),t[2]=n,t[3]=s);let c;t[4]===s?c=t[5]:(c=(0,K.jsx)(`strong`,{children:s}),t[4]=s,t[5]=c);let l;return t[6]!==r||t[7]!==i||t[8]!==o||t[9]!==c?(l=(0,K.jsxs)(`div`,{role:i,className:o,children:[c,`: `,r]}),t[6]=r,t[7]=i,t[8]=o,t[9]=c,t[10]=l):l=t[10],l}function TC(e){let t=e.match(/<(\w+)/);return t?t[1]:`Unknown`}function EC(e){let t=(0,Yn.c)(19),{editor:n,getPos:r,onDismiss:i}=e,a;if(t[0]!==n||t[1]!==r){let e=r();a=TC((typeof e==`number`?n.state.doc.nodeAt(e):null)?.attrs.content??``),t[0]=n,t[1]=r,t[2]=a}else a=t[2];let o=a,s;t[3]!==n||t[4]!==r||t[5]!==i?(s=function(){let e=r();if(typeof e!=`number`)return;let t=n.state.doc.nodeAt(e);t&&(n.chain().focus().deleteRange({from:e,to:e+t.nodeSize}).run(),i())},t[3]=n,t[4]=r,t[5]=i,t[6]=s):s=t[6];let c=s,l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Component`}),t[7]=l):l=t[7];let u;t[8]===o?u=t[9]:(u=(0,K.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs font-mono`,children:o}),t[8]=o,t[9]=u);let d;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,K.jsx)(`div`,{className:`flex-1`}),t[10]=d):d=t[10];let f;t[11]===c?f=t[12]:(f=(0,K.jsx)(Ce,{variant:`outline`,size:`sm`,onClick:c,children:`Delete`}),t[11]=c,t[12]=f);let p;t[13]!==u||t[14]!==f?(p=(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pr-8`,children:[l,u,d,f]}),t[13]=u,t[14]=f,t[15]=p):p=t[15];let m;return t[16]!==i||t[17]!==p?(m=(0,K.jsx)(sS,{kind:`jsx-component`,ariaLabel:`Component properties`,onDeactivate:i,children:p}),t[16]=i,t[17]=p,t[18]=m):m=t[18],m}var DC=0;function OC(){return`jsx-${++DC}`}function kC(e){let t=e.match(/<(\w+)\s+type="([^"]*)">([\s\S]*?)<\/\1>/);return t?{component:t[1],type:t[2],children:t[3].trim()}:{component:`Unknown`,type:`info`,children:e.trim()}}function AC(e){let t=(0,Yn.c)(17),{node:n,editor:r,getPos:i}=e,a=n.attrs.content||``,o;t[0]===a?o=t[1]:(o=kC(a),t[0]=a,t[1]=o);let s=o,[c]=(0,q.useState)(OC),l=(0,q.useRef)(i),u,d;t[2]===i?(u=t[3],d=t[4]):(u=()=>{l.current=i},d=[i],t[2]=i,t[3]=u,t[4]=d),(0,q.useEffect)(u,d);let f,p;t[5]!==r||t[6]!==c?(f=()=>{let e=ES(r),t=()=>{let e=l.current();return typeof e==`number`?e:void 0};return e.register({type:`jsxComponent`,nodeId:c,getPos:t,controls:{propPanel:e=>(0,K.jsx)(EC,{editor:r,getPos:t,onDismiss:e.deactivate})}}),()=>{e.deregister(c)}},p=[r,c],t[5]=r,t[6]=c,t[7]=f,t[8]=p):(f=t[7],p=t[8]),(0,q.useEffect)(f,p);let m;t[9]!==a||t[10]!==s.children||t[11]!==s.component||t[12]!==s.type?(m=s.component===`Callout`?(0,K.jsx)(wC,{type:s.type,children:s.children}):(0,K.jsxs)(`div`,{className:`bg-muted dark:bg-muted/40 p-3 px-4 rounded-md font-mono text-[13px]`,children:[(0,K.jsxs)(`strong`,{children:[`<`,s.component,`>`]}),(0,K.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap`,children:a})]}),t[9]=a,t[10]=s.children,t[11]=s.component,t[12]=s.type,t[13]=m):m=t[13];let h;return t[14]!==c||t[15]!==m?(h=(0,K.jsx)(xs,{className:`jsx-component-wrapper`,contentEditable:!1,"data-node-id":c,children:m}),t[14]=c,t[15]=m,t[16]=h):h=t[16],h}var jC=j.extend({addNodeView(){return ks(AC)}}),MC=`raw-mdx-nav`,NC=0;function PC(){return`raw-mdx-${++NC}`}function FC(e){let t=e.doc??(typeof document<`u`?document:{createElement:null}),n=t.createElement(`div`);n.setAttribute(`data-raw-mdx-fallback`,``),n.setAttribute(`data-raw-badge`,`raw`),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`${e.reason??`Parse failed`} — click to edit`),n.classList.add(`raw-mdx-fallback-wrapper`),e.reason&&n.setAttribute(`data-reason`,e.reason);let r=t.createElement(`span`);r.classList.add(`raw-mdx-fallback-badge`),r.textContent=`raw`,r.setAttribute(`aria-hidden`,`true`),n.appendChild(r);let i=t.createElement(`pre`);return i.classList.add(`raw-mdx-fallback-content`),i.setAttribute(`contenteditable`,`false`),n.appendChild(i),{dom:n,contentDOM:i}}var IC=We.extend({addNodeView(){return({editor:e,node:t,getPos:n,HTMLAttributes:r})=>{let i=PC(),{dom:a,contentDOM:o}=FC({nodeId:i,reason:r.reason??t.attrs.reason}),s=()=>{let e=n();return typeof e==`number`?e:void 0},c=ES(e);return c.register({type:`rawMdxFallback`,nodeId:i,getPos:s,controls:{},handlePrimary:()=>{let t=s();if(typeof t!=`number`)return!1;let n=e.state.doc.nodeAt(t)?.attrs.originalSpan??{start:0,end:0};return window.dispatchEvent(new CustomEvent(MC,{detail:{offset:n.start}})),!0}}),{dom:a,contentDOM:o,ignoreMutation:()=>!0,destroy:()=>{c.deregister(i)}}}}}),LC=[{name:`heading1`,label:`Heading 1`,icon:Fn,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:1}).run(),aliases:[`h1`]},{name:`heading2`,label:`Heading 2`,icon:In,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:2}).run(),aliases:[`h2`]},{name:`heading3`,label:`Heading 3`,icon:Ln,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:3}).run(),aliases:[`h3`]},{name:`bulletList`,label:`Bullet List`,icon:Vn,category:`basic`,command:e=>e.chain().focus().toggleBulletList().run(),aliases:[`ul`,`unordered`]},{name:`orderedList`,label:`Ordered List`,icon:zn,category:`basic`,command:e=>e.chain().focus().toggleOrderedList().run(),aliases:[`ol`,`numbered`]},{name:`taskList`,label:`Task List`,icon:Bn,category:`basic`,command:e=>e.chain().focus().toggleTaskList().run(),aliases:[`todo`,`checklist`,`checkbox`]},{name:`blockquote`,label:`Quote`,icon:Gn,category:`basic`,command:e=>e.chain().focus().toggleBlockquote().run(),aliases:[`quote`]},{name:`codeBlock`,label:`Code Block`,icon:An,category:`basic`,command:e=>e.chain().focus().toggleCodeBlock().run(),aliases:[`code`,`fence`]},{name:`table`,label:`Table`,icon:Kn,category:`insert`,command:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),aliases:[`grid`]},{name:`separator`,label:`Separator`,icon:Un,category:`insert`,command:e=>e.chain().focus().setHorizontalRule().run(),aliases:[`hr`,`divider`,`rule`]},{name:`image`,label:`Image`,icon:Rn,category:`insert`,aliases:[`img`,`photo`],command:e=>{let t=document.createElement(`input`);t.type=`file`,t.accept=A.join(`,`),t.onchange=()=>{let n=t.files?.[0];if(n){let t=e.state.selection.from;Kb(n,e,t)}},t.click()}}];function RC(e,t){if(!t)return e;let n=t.toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)||e.aliases?.some(e=>e.toLowerCase().includes(n)))}function zC(e){let t=(0,Yn.c)(14),{items:n,selectedIndex:r,categoryLabels:i,onSelect:a}=e,o=(0,q.useRef)(null),s=(0,q.useId)(),c=r>=0&&r<n.length?`${s}-option-${r}`:void 0,l=BC,u,d;if(t[0]===r?(u=t[1],d=t[2]):(u=()=>{let e=o.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(r);t&&t.scrollIntoView({block:`nearest`})},d=[r],t[0]=r,t[1]=u,t[2]=d),(0,q.useEffect)(u,d),n.length===0){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(`div`,{ref:o,role:`status`,"aria-live":`polite`,className:`w-56 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:{maxHeight:`var(--suggestion-menu-max-height, 40vh)`},onMouseDown:l,children:`No results`}),t[3]=e):e=t[3],e}let f;if(t[4]!==c||t[5]!==i||t[6]!==n||t[7]!==s||t[8]!==a||t[9]!==r){let e=[],u=0,d=new Map;for(let t of n){d.set(t,u++);let n=e.find(e=>e.key===t.category);n?n.items.push(t):e.push({key:t.category,items:[t]})}let p=r>=0&&r<n.length?n[r]:null,m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[11]=m):m=t[11];let h=p?p.label:``,g;t[12]===h?g=t[13]:(g=(0,K.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:h}),t[12]=h,t[13]=g),f=(0,K.jsxs)(`div`,{ref:o,role:`listbox`,"aria-label":`Slash commands`,"aria-activedescendant":c,tabIndex:-1,onMouseDown:l,className:`w-56 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:m,children:[g,e.map(e=>(0,K.jsxs)(`div`,{role:`group`,"aria-labelledby":`${s}-group-${e.key}`,children:[(0,K.jsx)(`div`,{id:`${s}-group-${e.key}`,className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground`,children:i[e.key]??e.key}),e.items.map(e=>{let t=d.get(e)??0,n=t===r,i=e.icon;return(0,K.jsxs)(`button`,{id:`${s}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,K.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`div`,{className:`flex flex-col min-w-0`,children:(0,K.jsx)(`span`,{className:`truncate`,children:e.label})})]},e.name)})]},e.key))]}),t[4]=c,t[5]=i,t[6]=n,t[7]=s,t[8]=a,t[9]=r,t[10]=f}else f=t[10];return f}function BC(e){return e.preventDefault()}var VC=new C(`slashCommand`),HC=H.create({name:`slashCommand`,addOptions(){return{itemsSources:[()=>LC],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[VS({editor:this.editor,pluginKey:VC,char:`/`,startOfLine:!1,items:({query:t})=>RC(e.options.itemsSources.flatMap(e=>{try{return e()}catch(e){return console.error(`[slash-command] item source threw an error`,e),[]}}),t),command:({editor:e,range:t,props:n})=>{try{e.chain().focus().deleteRange(t).run()}catch(e){console.error(`[slash-command] deleteRange failed for "${n.name}"`,e);return}try{n.command(e)}catch(e){console.error(`[slash-command] command "${n.name}" threw an error`,e)}},render:()=>{let t=null,n=null,r=0,i={popup:null,stopAutoUpdate:null},a=null,o=()=>{!t||!n||t.updateProps({items:n.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:n.command})};return{onStart(o){n=o,r=0;let s=qS(()=>n,`slash-command`);i.popup=s.popup,a=s.doPosition,t=new Ds(zC,{props:{items:o.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:o.command},editor:o.editor}),s.popup.appendChild(t.element),i.stopAutoUpdate=s.startAutoUpdate(),s.reveal()},onUpdate(e){n=e,r=Math.min(r,Math.max(0,e.items.length-1)),o(),a?.()},onKeyDown({event:e}){if(!n||n.items.length===0)return!1;let t=n.items;if(e.key===`ArrowDown`)return r=(r+1)%t.length,o(),!0;if(e.key===`ArrowUp`)return r=(r-1+t.length)%t.length,o(),!0;if(e.key===`Enter`||e.key===`Tab`){let e=t[r];return e&&n.command(e),!0}return e.key,!1},onExit(){JS(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}});function UC(e){let t=(0,Yn.c)(112),{open:n,target:r,alias:i,anchor:a,pages:o,onOpenChange:s,onSave:c}=e,[l,u]=(0,q.useState)(r),[d,f]=(0,q.useState)(i??``),[p,m]=(0,q.useState)(a??``),g=(0,q.useId)(),_=(0,q.useId)(),v=(0,q.useId)(),y=(0,q.useId)(),b;t[0]!==l||t[1]!==o?(b=qx(l,o),t[0]=l,t[1]=o,t[2]=b):b=t[2];let x=sC(l,b&&n),S,C;t[3]!==i||t[4]!==a||t[5]!==n||t[6]!==r?(S=()=>{n&&(u(r),f(i??``),m(a??``))},C=[n,r,i,a],t[3]=i,t[4]=a,t[5]=n,t[6]=r,t[7]=S,t[8]=C):(S=t[7],C=t[8]),(0,q.useEffect)(S,C);let w;t[9]!==d||t[10]!==p||t[11]!==l||t[12]!==s||t[13]!==c?(w=function(){let e=l.trim();e&&(c(e,d.trim()||null,p.trim()||null),s(!1))},t[9]=d,t[10]=p,t[11]=l,t[12]=s,t[13]=c,t[14]=w):w=t[14];let T=w,E;t[15]===T?E=t[16]:(E=function(e){e.key===`Enter`&&T()},t[15]=T,t[16]=E);let D=E,O,k,A,j,M,N,P,F,I,L,R,z,ee,B,V,te;if(t[17]!==_||t[18]!==p||t[19]!==l||t[20]!==D||t[21]!==y||t[22]!==x||t[23]!==s||t[24]!==n||t[25]!==g){let e=new Map,r=x?.map(t=>{let n=e.get(t.slug)??0;e.set(t.slug,n+1);let r=n===0?t.slug:`${t.slug}-${n}`;return{...t,reactKey:r}}),i=!!r?.length;A=Wa,R=n,z=s,k=Ga,t[42]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,K.jsx)(Ka,{className:`fixed inset-0 z-50 bg-black/40 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`}),t[42]=L):L=t[42],O=qa,M=`dialog-content`,N=``,P=`fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-lg border border-border bg-background p-6 shadow-xl data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,t[43]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,K.jsx)(Ja,{className:`mb-1 text-base font-semibold`,children:`Edit wiki link`}),I=(0,K.jsx)(Ya,{className:`mb-4 text-sm text-muted-foreground`,children:`Modify the link target, anchor, and display label.`}),t[43]=F,t[44]=I):(F=t[43],I=t[44]),te=`mb-4 space-y-6`;let a;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,K.jsx)(`span`,{className:`text-red-500`,children:`*`}),t[45]=a):a=t[45];let o;t[46]===g?o=t[47]:(o=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:g,children:[`Page `,a]}),t[46]=g,t[47]=o);let c;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>u(e.target.value),t[48]=c):c=t[48];let d;t[49]!==l||t[50]!==D||t[51]!==g?(d=(0,K.jsx)(uS,{id:g,value:l,onChange:c,placeholder:`page-name`,autoFocus:!0,"aria-required":`true`,onKeyDown:D}),t[49]=l,t[50]=D,t[51]=g,t[52]=d):d=t[52],t[53]!==o||t[54]!==d?(j=(0,K.jsxs)(`div`,{children:[o,d]}),t[53]=o,t[54]=d,t[55]=j):j=t[55];let f;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional heading anchor)`}),t[56]=f):f=t[56],t[57]===_?ee=t[58]:(ee=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:_,children:[`Section`,` `,f]}),t[57]=_,t[58]=ee);let v;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>m(e.target.value),t[59]=v):v=t[59],t[60]!==_||t[61]!==p||t[62]!==D?(B=(0,K.jsx)(uS,{id:_,value:p,onChange:v,placeholder:`heading-slug`,onKeyDown:D}),t[60]=_,t[61]=p,t[62]=D,t[63]=B):B=t[63],V=i&&(0,K.jsx)(`div`,{role:`listbox`,id:y,"aria-label":`Heading anchors`,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:r.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":p===e.slug,className:h(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,p===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>m(p===e.slug?``:e.slug),children:[(0,K.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,K.jsx)(`span`,{className:`truncate`,children:e.text})]},e.reactKey))}),t[17]=_,t[18]=p,t[19]=l,t[20]=D,t[21]=y,t[22]=x,t[23]=s,t[24]=n,t[25]=g,t[26]=O,t[27]=k,t[28]=A,t[29]=j,t[30]=M,t[31]=N,t[32]=P,t[33]=F,t[34]=I,t[35]=L,t[36]=R,t[37]=z,t[38]=ee,t[39]=B,t[40]=V,t[41]=te}else O=t[26],k=t[27],A=t[28],j=t[29],M=t[30],N=t[31],P=t[32],F=t[33],I=t[34],L=t[35],R=t[36],z=t[37],ee=t[38],B=t[39],V=t[40],te=t[41];let ne;t[64]!==ee||t[65]!==B||t[66]!==V?(ne=(0,K.jsxs)(`div`,{children:[ee,B,V]}),t[64]=ee,t[65]=B,t[66]=V,t[67]=ne):ne=t[67];let re;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional display text)`}),t[68]=re):re=t[68];let H;t[69]===v?H=t[70]:(H=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:v,children:[`Label`,` `,re]}),t[69]=v,t[70]=H);let ie;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>f(e.target.value),t[71]=ie):ie=t[71];let ae;t[72]!==v||t[73]!==d||t[74]!==D?(ae=(0,K.jsx)(uS,{id:v,value:d,onChange:ie,placeholder:`Custom display text`,onKeyDown:D}),t[72]=v,t[73]=d,t[74]=D,t[75]=ae):ae=t[75];let U;t[76]!==H||t[77]!==ae?(U=(0,K.jsxs)(`div`,{children:[H,ae]}),t[76]=H,t[77]=ae,t[78]=U):U=t[78];let oe;t[79]!==j||t[80]!==ne||t[81]!==U||t[82]!==te?(oe=(0,K.jsxs)(`div`,{className:te,children:[j,ne,U]}),t[79]=j,t[80]=ne,t[81]=U,t[82]=te,t[83]=oe):oe=t[83];let se;t[84]===s?se=t[85]:(se=(0,K.jsx)(Ce,{variant:`outline`,onClick:()=>s(!1),children:`Cancel`}),t[84]=s,t[85]=se);let ce;t[86]===l?ce=t[87]:(ce=l.trim(),t[86]=l,t[87]=ce);let le=!ce,ue;t[88]!==T||t[89]!==le?(ue=(0,K.jsx)(Ce,{onClick:T,disabled:le,children:`Save`}),t[88]=T,t[89]=le,t[90]=ue):ue=t[90];let de;t[91]!==se||t[92]!==ue?(de=(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[se,ue]}),t[91]=se,t[92]=ue,t[93]=de):de=t[93];let fe;t[94]!==O||t[95]!==M||t[96]!==N||t[97]!==P||t[98]!==F||t[99]!==I||t[100]!==oe||t[101]!==de?(fe=(0,K.jsxs)(O,{"data-slot":M,"data-ok-layer-spawned":N,className:P,children:[F,I,oe,de]}),t[94]=O,t[95]=M,t[96]=N,t[97]=P,t[98]=F,t[99]=I,t[100]=oe,t[101]=de,t[102]=fe):fe=t[102];let pe;t[103]!==k||t[104]!==L||t[105]!==fe?(pe=(0,K.jsxs)(k,{children:[L,fe]}),t[103]=k,t[104]=L,t[105]=fe,t[106]=pe):pe=t[106];let me;return t[107]!==A||t[108]!==R||t[109]!==z||t[110]!==pe?(me=(0,K.jsx)(A,{open:R,onOpenChange:z,children:pe}),t[107]=A,t[108]=R,t[109]=z,t[110]=pe,t[111]=me):me=t[111],me}function WC(e){let t=(0,Yn.c)(112),{editor:n,getPos:r,onClose:i}=e,a=r(),o=a==null?null:n.state.doc.nodeAt(a),s=String(o?.attrs.target??``),c=m(o?.attrs.alias),l=m(o?.attrs.anchor),d=u({target:s,alias:c,anchor:l}),{folderPaths:f,pages:p,loading:g}=ge(),_=Le(s,l),v=_?.kind===`external`?_:null,y=cS(s,{pages:p,folderPaths:f,fallbackTargets:Kx(s)}),[b,x]=(0,q.useState)(!1),[S,C]=(0,q.useState)(null),w=lS(y);if(!o)return null;let T;t[0]!==n||t[1]!==r?(T=function(e,t,i){let a=r();a!=null&&n.view.dispatch(n.state.tr.setNodeMarkup(a,void 0,{...n.state.doc.nodeAt(a)?.attrs,target:e,alias:t,anchor:i}))},t[0]=n,t[1]=r,t[2]=T):T=t[2];let E=T,D;t[3]!==n||t[4]!==r||t[5]!==i?(D=function(){let e=r();if(e==null)return;let t=n.state.doc.nodeAt(e);t&&(n.view.dispatch(n.state.tr.delete(e,e+t.nodeSize)),i())},t[3]=n,t[4]=r,t[5]=i,t[6]=D):D=t[6];let O=D,k;t[7]!==l||t[8]!==v||t[9]!==y||t[10]!==C?(k=function(e){if(v){Xx(v.url)?window.open(v.url,`_blank`,`noopener,noreferrer`):console.warn(`[safe-nav] blocked non-safe scheme:`,v.url);return}if(y.kind===`create`){C(`missing`);return}let t=y.hashDocName;if(e.newTab){nS({docName:t,anchor:l});return}if(l){let e=window.location.hash.match(/^#\/([^?#/]+)/);if((e?decodeURIComponent(e[1]):null)===t){let e=document.getElementById(l);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})}window.location.hash=`#/${t}?anchor=${encodeURIComponent(l)}`;return}window.location.hash=`#/${t}`},t[7]=l,t[8]=v,t[9]=y,t[10]=C,t[11]=k):k=t[11];let A=k,j;t[12]!==c||t[13]!==S||t[14]!==n||t[15]!==r||t[16]!==d||t[17]!==s?(j=function(e){if(S===`missing`&&e!==s){let t=r();if(t==null)return;n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...n.state.doc.nodeAt(t)?.attrs,target:e,alias:c??d}))}},t[12]=c,t[13]=S,t[14]=n,t[15]=r,t[16]=d,t[17]=s,t[18]=j):j=t[18];let M=j,N=!v&&!g&&y.kind===`navigate`&&y.displayState===`resolved`,P=!v&&!g&&y.kind===`navigate`&&y.displayState===`folder`,F=!v&&!g&&y.kind===`create`,I,L,R,z,ee,B,V,te,ne;if(t[19]!==v||t[20]!==P||t[21]!==N||t[22]!==F||t[23]!==g||t[24]!==i){if(g){let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Hn,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[34]=e):e=t[34],L={icon:e,text:`Loading…`,className:`text-muted-foreground`}}else if(v){let e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(jn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[35]=e):e=t[35],L={icon:e,text:`External wiki link`,className:`text-foreground`}}else if(P){let e;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Pn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[36]=e):e=t[36],L={icon:e,text:`Folder (no index)`,className:`text-foreground`}}else if(F){let e;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(kn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[37]=e):e=t[37],L={icon:e,text:`Page not found`,className:`text-red-700 dark:text-red-300`}}else if(N){let e;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Nn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[38]=e):e=t[38],L={icon:e,text:`Wiki link`,className:`text-foreground`}}else{let e;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(kn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[39]=e):e=t[39],L={icon:e,text:`Unrecognized wiki link`,className:`text-muted-foreground`}}I=sS,ne=`wiki-link`,R=`Wiki link options`,z=i,V=`mb-2 flex items-start gap-2 pr-8`,te=(0,K.jsx)(`div`,{className:h(`mt-0.5 flex shrink-0`,L.className),children:L.icon}),B=`flex-1 min-w-0`,ee=h(`text-sm font-medium`,L.className),t[19]=v,t[20]=P,t[21]=N,t[22]=F,t[23]=g,t[24]=i,t[25]=I,t[26]=L,t[27]=R,t[28]=z,t[29]=ee,t[30]=B,t[31]=V,t[32]=te,t[33]=ne}else I=t[25],L=t[26],R=t[27],z=t[28],ee=t[29],B=t[30],V=t[31],te=t[32],ne=t[33];let re;t[40]!==L.text||t[41]!==ee?(re=(0,K.jsx)(`div`,{className:ee,children:L.text}),t[40]=L.text,t[41]=ee,t[42]=re):re=t[42];let H=v?v.url:`[[${s}${l?`#${l}`:``}]]`,ie=v?v.url:`[[${s}${l?`#${l}`:``}]]`,ae;t[43]!==H||t[44]!==ie?(ae=(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,title:H,children:ie}),t[43]=H,t[44]=ie,t[45]=ae):ae=t[45];let U;t[46]!==re||t[47]!==ae||t[48]!==B?(U=(0,K.jsxs)(`div`,{className:B,children:[re,ae]}),t[46]=re,t[47]=ae,t[48]=B,t[49]=U):U=t[49];let oe;t[50]!==U||t[51]!==V||t[52]!==te?(oe=(0,K.jsxs)(`div`,{className:V,children:[te,U]}),t[50]=U,t[51]=V,t[52]=te,t[53]=oe):oe=t[53];let se;t[54]!==v||t[55]!==A||t[56]!==F||t[57]!==i?(se=F?null:(0,K.jsx)(Ce,{size:`sm`,variant:`default`,onClick:()=>{A({}),i()},children:v?`Open in new tab`:`Open`}),t[54]=v,t[55]=A,t[56]=F,t[57]=i,t[58]=se):se=t[58];let ce;t[59]!==F||t[60]!==C?(ce=F?(0,K.jsx)(Ce,{size:`sm`,variant:`default`,onClick:()=>C(`missing`),children:`Create page`}):null,t[59]=F,t[60]=C,t[61]=ce):ce=t[61];let le;t[62]!==w||t[63]!==P||t[64]!==C?(le=P&&w?(0,K.jsxs)(Ce,{size:`sm`,variant:`outline`,onClick:()=>C(`folder-index`),children:[(0,K.jsx)(Mn,{className:`size-3.5`,"aria-hidden":`true`}),`Create index`]}):null,t[62]=w,t[63]=P,t[64]=C,t[65]=le):le=t[65];let ue;t[66]===x?ue=t[67]:(ue=()=>x(!0),t[66]=x,t[67]=ue);let de;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,K.jsx)(Wn,{className:`size-3.5`,"aria-hidden":`true`}),t[68]=de):de=t[68];let fe;t[69]===ue?fe=t[70]:(fe=(0,K.jsxs)(Ce,{size:`sm`,variant:`outline`,onClick:ue,children:[de,`Edit`]}),t[69]=ue,t[70]=fe);let pe;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,K.jsx)(qn,{className:`size-3.5`,"aria-hidden":`true`}),t[71]=pe):pe=t[71];let me;t[72]===O?me=t[73]:(me=(0,K.jsxs)(Ce,{size:`sm`,variant:`outline`,className:`text-red-700 hover:bg-red-50 hover:text-red-800 dark:text-red-300 dark:hover:bg-red-100/10 dark:hover:text-red-200`,onClick:O,children:[pe,`Remove`]}),t[72]=O,t[73]=me);let he;t[74]!==se||t[75]!==ce||t[76]!==le||t[77]!==fe||t[78]!==me?(he=(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[se,ce,le,fe,me]}),t[74]=se,t[75]=ce,t[76]=le,t[77]=fe,t[78]=me,t[79]=he):he=t[79];let _e;t[80]!==I||t[81]!==R||t[82]!==z||t[83]!==oe||t[84]!==he||t[85]!==ne?(_e=(0,K.jsxs)(I,{kind:ne,ariaLabel:R,onDeactivate:z,children:[oe,he]}),t[80]=I,t[81]=R,t[82]=z,t[83]=oe,t[84]=he,t[85]=ne,t[86]=_e):_e=t[86];let ve=S!==null,ye;t[87]===C?ye=t[88]:(ye=e=>{e||C(null)},t[87]=C,t[88]=ye);let be=S===`folder-index`&&w?w.initialDir:y.kind===`create`?y.initialDir:``,xe=S===`folder-index`&&w?w.suggestedName:y.kind===`create`?y.suggestedName:void 0,Se;t[89]!==S||t[90]!==w||t[91]!==s?(Se=S===`folder-index`&&w?(0,K.jsxs)(K.Fragment,{children:[`Create an index note for`,` `,(0,K.jsxs)(`span`,{className:`font-medium text-foreground`,children:[w.initialDir,`/`]})]}):(0,K.jsxs)(K.Fragment,{children:[`Create a page for `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:s})]}),t[89]=S,t[90]=w,t[91]=s,t[92]=Se):Se=t[92];let we;t[93]!==M||t[94]!==ve||t[95]!==ye||t[96]!==be||t[97]!==xe||t[98]!==Se?(we=(0,K.jsx)(gS,{open:ve,onOpenChange:ye,kind:`file`,initialDir:be,suggestedName:xe,description:Se,onCreated:M}),t[93]=M,t[94]=ve,t[95]=ye,t[96]=be,t[97]=xe,t[98]=Se,t[99]=we):we=t[99];let Te;t[100]!==c||t[101]!==l||t[102]!==b||t[103]!==E||t[104]!==p||t[105]!==x||t[106]!==s?(Te=(0,K.jsx)(UC,{open:b,target:s,alias:c,anchor:l,pages:p,onOpenChange:x,onSave:E}),t[100]=c,t[101]=l,t[102]=b,t[103]=E,t[104]=p,t[105]=x,t[106]=s,t[107]=Te):Te=t[107];let Ee;return t[108]!==_e||t[109]!==we||t[110]!==Te?(Ee=(0,K.jsxs)(K.Fragment,{children:[_e,we,Te]}),t[108]=_e,t[109]=we,t[110]=Te,t[111]=Ee):Ee=t[111],Ee}var GC=0;function KC(){return`wiki-link-${++GC}`}function qC(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`span`);n.setAttribute(`data-wiki-link`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Wiki link: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-chip`),n.style.touchAction=`manipulation`;let r=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,i=t.createTextNode(r);return n.appendChild(i),{dom:n}}var JC=w.extend({priority:200,addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=KC(),{dom:i}=qC({nodeId:r,target:String(t.attrs.target??``),alias:t.attrs.alias==null?null:String(t.attrs.alias),anchor:t.attrs.anchor==null?null:String(t.attrs.anchor)}),a=t,o=()=>{let e=n();return typeof e==`number`?e:void 0},s=ES(e);return s.register({type:`wikiLink`,nodeId:r,getPos:o,controls:{propPanel:t=>(0,q.createElement)(WC,{editor:e,getPos:o,onClose:t.deactivate})},handlePrimary:({newTab:e})=>{if(!e)return!1;let t=a.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=Le(n,typeof t.anchor==`string`?t.anchor:null);return r?r.kind===`doc`?(nS({docName:r.docName,anchor:r.anchor}),!0):Xx(r.url)?(eS(r.url),!0):!1:!1}}),{dom:i,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLink`)return!1;a=e;let t=String(e.attrs.target??``),n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor);return i.setAttribute(`data-target`,t),i.setAttribute(`data-alias`,n??``),i.setAttribute(`data-anchor`,r??``),i.setAttribute(`aria-label`,`Wiki link: ${t}${r?`#${r}`:``}`),i.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{s.deregister(r)}}}},addKeyboardShortcuts(){return{Backspace:()=>{if(YS.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(YS.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[oC(this.editor)]}}),YC=[...b.map(e=>e.name===`jsxComponent`?jC:e.name===`rawMdxFallback`?IC:e.name===`wikiLink`?JC:e.name===`link`?xC:e),HC,Bb.configure({allowedMimeTypes:[...A],onDrop(e,t,n){for(let r of t)Kb(r,e,n)},onPaste(e,t,n){for(let n of t)Kb(n,e,e.state.selection.from)}}),Jx,Wx,Zb];function XC(e){return e===_}var ZC=0;function QC(){return ZC}function $C(){ZC=Date.now()}function ew(e){let{xmlFragment:t,ytext:n}=e,r=(e,t)=>{},i=(e,t)=>{};return t.observeDeep(r),n.observe(i),()=>{t.unobserveDeep(r),n.unobserve(i)}}var tw=3e4,nw=class extends Error{docName;elapsedMs;constructor(e,t){super(`Sync timed out for "${e}" after ${t}ms`),this.name=`SyncTimeoutError`,this.docName=e,this.elapsedMs=t}},rw=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},iw=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},aw=class extends Error{docName;cause;constructor(e,t){let n=t instanceof Error?t.message:String(t??`unknown`);super(`Bridge setup failed for "${e}": ${n}`),this.name=`BridgeSetupError`,this.docName=e,this.cause=t}},ow=new Map,sw=!1;function cw(){for(let e of ow.values())if(!e.settled)return!0;return!1}function lw(){typeof document>`u`||document.visibilityState===`visible`&&uw(Date.now())}function uw(e){let t=[];for(let[n,r]of ow){if(r.settled)continue;let i=e-r.createdAt;if(i<3e4)continue;r.settled=!0;let a=new nw(n,i);mw(r),r.reject(a),t.push({docName:n,elapsedMs:i})}if(t.length>0){let e=t.map(e=>`${e.docName} (${e.elapsedMs}ms)`).join(`, `);console.warn(`[syncPromise] reaped ${t.length} timed-out ${t.length===1?`entry`:`entries`} on visibility restore (tab-sleep recovered): ${e}`)}return cw()||fw(),t.length}function dw(){sw||typeof document>`u`||(document.addEventListener(`visibilitychange`,lw),sw=!0)}function fw(){sw&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,lw),sw=!1))}var pw=new Map;function mw(e){e.detached||(e.detached=!0,e.timeoutHandle!==null&&clearTimeout(e.timeoutHandle),e.provider.off(`synced`,e.onSynced),e.provider.off(`close`,e.onClose))}function hw(e,t){let n=ow.get(e);if(n)return n.promise;let r=pw.get(e);if(r!==void 0){pw.delete(e);let n=r===`timeout`?new nw(e,0):new rw(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),J(`ok/sync/create`,{docName:e,warm:!1,armed:r}),J(`ok/sync/reject`,{docName:e,reason:`armed-${r}`});let i=_w(n);return ow.set(e,vw(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`),J(`ok/sync/create`,{docName:e,warm:!0}),J(`ok/sync/resolve`,{docName:e,elapsedMs:0,warm:!0});let n=Promise.resolve();return ow.set(e,gw(n,t)),n}let i=Date.now(),a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=()=>{let t=ow.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt;console.log(`[syncPromise] ${e} resolved in ${n}ms`),J(`ok/sync/resolve`,{docName:e,elapsedMs:n,warm:!1}),mw(t),cw()||fw(),t.resolve()},l=t=>{let n=ow.get(e);if(!n||n.settled)return;n.settled=!0;let r=new rw(e);console.warn(`[syncPromise] ${e} rejected: ${r.message}`),J(`ok/sync/reject`,{docName:e,reason:`pre-sync-disconnect`}),mw(n),cw()||fw(),n.reject(r)},u=setTimeout(()=>{let t=ow.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new nw(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`),J(`ok/sync/reject`,{docName:e,reason:`timeout`,elapsedMs:n}),mw(t),cw()||fw(),t.reject(r)},tw),d={promise:s,resolve:a,reject:o,createdAt:i,timeoutHandle:u,provider:t,onSynced:c,onClose:l,settled:!1,detached:!1};return ow.set(e,d),t.on(`synced`,c),t.on(`close`,l),dw(),J(`ok/sync/create`,{docName:e,warm:!1}),s}function gw(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,detached:!0}}function _w(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function vw(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,detached:!0}}function yw(e){let t=ow.get(e);t&&(t.settled=!0,mw(t),ow.delete(e),cw()||fw())}function bw(e,t){let n=ow.get(e);return!n||n.settled?!1:(n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),mw(n),cw()||fw(),n.reject(t),!0)}var xw=ye(YC),Sw=4e3,Cw=5e3,ww=class{entries=new Map;lruOrder=[];activeDocName=null;maxSize;wsUrl;recycleDebounceMs;onChange=null;tabIdentity=null;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n??Sw}setTabIdentity(e){this.tabIdentity=e}setOnChange(e){this.onChange=e}notify(){this.onChange?.()}touch(e){let t=this.lruOrder.indexOf(e);t!==-1&&this.lruOrder.splice(t,1),this.lruOrder.push(e)}open(e){if(XC(e))return null;let t=this.entries.get(e);if(t)return t.lastAccessedAt=Date.now(),this.touch(e),this.notify(),t;this.entries.size>=this.maxSize&&this.evictLru();let n=new gb({url:this.wsUrl,name:e,forceSyncInterval:Cw,...this.tabIdentity===null?{}:{token:JSON.stringify(this.tabIdentity)}}),r={provider:n,observerCleanup:null,syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),hasSynced:!1,tearingDown:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1};return n.on(`status`,({status:t})=>{r.tearingDown||this.entries.get(e)!==r||t===`disconnected`&&(r.syncState=`disconnected`,this.notify())}),n.on(`synced`,()=>{if(!(r.tearingDown||this.entries.get(e)!==r)&&(r.syncState=`synced`,r.hasSynced=!0,r.pendingRecycleTimer&&=(clearTimeout(r.pendingRecycleTimer),null),this.notify(),!r.observerCleanup))try{let t=n.document,i=new me({extensions:YC});r.observerCleanup=ew({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:i,schema:xw,onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),r.bridgeSetupFailed=!0,bw(e,new aw(e,t))}}),n.on(`disconnect`,()=>{r.tearingDown||this.entries.get(e)!==r||(r.syncState=`disconnected`,this.notify(),r.hasSynced&&n.unsyncedChanges===0&&!r.pendingRecycleTimer&&(r.pendingRecycleTimer=setTimeout(()=>{r.pendingRecycleTimer=null,!(r.tearingDown||this.entries.get(e)!==r)&&this.recycleDisconnectedEntry(e)},this.recycleDebounceMs)))}),this.entries.set(e,r),this.touch(e),this.notify(),r}prewarm(e){if(XC(e))return null;let t=this.entries.get(e);if(t)return t;let n=this.open(e);if(!n)return null;let r=this.lruOrder.indexOf(e);return r!==-1&&(this.lruOrder.splice(r,1),this.lruOrder.unshift(e)),n}close(e){let t=this.entries.get(e);t&&(this.destroyEntry(t),this.entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),this.activeDocName===e&&(this.activeDocName=null),this.notify())}setActive(e){let t=this.entries.get(e);if(!t)throw Error(`[ProviderPool] Cannot setActive — "${e}" is not open`);t.lastAccessedAt=Date.now(),this.touch(e),this.activeDocName=e,this.notify()}clearActive(){this.activeDocName!==null&&(this.activeDocName=null,this.notify())}getActive(){return this.activeDocName?this.entries.get(this.activeDocName)??null:null}getActiveDocName(){return this.activeDocName}has(e){return this.entries.has(e)}recycle(e){this.recycleDisconnectedEntry(e)}dispose(){for(let e of this.entries.values())this.destroyEntry(e);this.entries.clear(),this.lruOrder=[],this.activeDocName=null,this.onChange=null}evictLru(){for(let e of this.lruOrder)if(e!==this.activeDocName){J(`ok/pool/evict-lru`,{docName:e}),this.close(e);return}}destroyEntry(e){e.tearingDown=!0,e.pendingRecycleTimer&&=(clearTimeout(e.pendingRecycleTimer),null),yw(e.docName),Db(e.docName),Ab(e.docName),e.observerCleanup?.(),e.observerCleanup=null;try{e.provider.destroy()}catch(t){console.warn(`[ProviderPool] Provider destroy failed for ${e.docName}:`,t)}}recycleDisconnectedEntry(e){let t=this.entries.get(e);if(!t||t.tearingDown)return;let n=this.activeDocName===e;if(J(`ok/pool/recycle-disconnected`,{docName:e,wasActive:n}),this.destroyEntry(t),this.entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),n){this.open(e)&&this.setActive(e);return}this.notify()}},Tw=crypto.randomUUID(),Ew=`ok-pin-v1`,Dw=!1;function Ow(e){Dw||(Dw=!0,console.warn(`[DocumentContext] localStorage unavailable — pinned doc will not persist across tabs/reloads.`,e))}function kw(){if(typeof window>`u`)return null;try{return window.localStorage.getItem(Ew)}catch(e){return Ow(e),null}}function Aw(e){if(!(typeof window>`u`))try{e===null?window.localStorage.removeItem(Ew):window.localStorage.setItem(Ew,e)}catch(e){Ow(e)}}var jw=(0,q.createContext)(null),Mw=null;function Nw(e){return Mw||=new ww(10,e),Mw}var Pw={activeDocName:null,activeProvider:null,syncState:`connecting`,poolEntries:[]};function Fw(e){let t=e.getActive(),n=[];for(let t of e.entries.values())n.push({docName:t.docName,provider:t.provider,lastAccessedAt:t.lastAccessedAt});return n.sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt),{activeDocName:e.getActiveDocName(),activeProvider:t?.provider??null,syncState:t?.syncState??`connecting`,poolEntries:n}}function Iw(e){let t=(0,Yn.c)(40),{children:n}=e,[r,i]=(0,q.useState)(Pw),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),{collabUrl:l,terminal:u,lastError:d,retry:f}=k_(),p,m;t[0]===l?(p=t[1],m=t[2]):(p=()=>{if(l===null)return;let e=Nw(l);i(Fw(e)),e.setOnChange(()=>i(Fw(e)));let t=kw();return t!==null&&c(t),fetch(`/api/principal`).then(Rw).then(t=>{t&&typeof t.id==`string`&&e.setTabIdentity({principalId:t.id,tabSessionId:Tw})}).catch(Lw),()=>{e.setOnChange(null)}},m=[l],t[0]=l,t[1]=p,t[2]=m),(0,q.useEffect)(p,m);let h;t[3]===l?h=t[4]:(h=e=>{if(J(`ok/nav/open-document`,{docName:e,transition:!1}),l===null)return;let t=Nw(l);t.open(e)&&(t.setActive(e),o({kind:`doc`,target:e,docName:e}))},t[3]=l,t[4]=h);let g=h,_;t[5]===g?_=t[6]:(_=e=>{J(`ok/nav/open-document`,{docName:e,transition:!1}),g(e)},t[5]=g,t[6]=_);let v=_,y;t[7]===l?y=t[8]:(y=e=>{if(l===null)return;let t=Nw(l),n=P(e);n?(t.open(n),t.setActive(n)):t.clearActive(),o(e)},t[7]=l,t[8]=y);let b=y,x;t[9]===b?x=t[10]:(x=e=>{J(`ok/nav/open-target`,{docName:P(e),kind:e.kind,transition:!1}),b(e)},t[9]=b,t[10]=x);let S=x,C,w,T,E;t[11]===l?(C=t[12],w=t[13],T=t[14],E=t[15]):(w=()=>{if(l===null){o(null);return}Nw(l).clearActive(),o(null)},T=e=>{l!==null&&(Nw(l).close(e),o(t=>t&&(P(t)===e?null:t)))},E=e=>{l!==null&&Nw(l).recycle(e)},C=e=>{l!==null&&Nw(l).prewarm(e)},t[11]=l,t[12]=C,t[13]=w,t[14]=T,t[15]=E);let D,O;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{c(e),Aw(e)},O=()=>{c(null),Aw(null)},t[16]=D,t[17]=O):(D=t[16],O=t[17]);let k;t[18]!==a||t[19]!==d||t[20]!==u||t[21]!==l||t[22]!==g||t[23]!==v||t[24]!==b||t[25]!==S||t[26]!==s||t[27]!==f||t[28]!==r.activeDocName||t[29]!==r.activeProvider||t[30]!==r.poolEntries||t[31]!==r.syncState||t[32]!==C||t[33]!==w||t[34]!==T||t[35]!==E?(k={activeTarget:a,activeDocName:r.activeDocName,activeProvider:r.activeProvider,syncState:r.syncState,poolEntries:r.poolEntries,openDocument:g,openDocumentTransition:v,openTarget:b,openTargetTransition:S,clearTarget:w,closeDocument:T,recycleDocument:E,prewarm:C,pinnedDoc:s,pin:D,unpin:O,collabUrl:l,collabTerminal:u,collabLastError:d,retryCollab:f},t[18]=a,t[19]=d,t[20]=u,t[21]=l,t[22]=g,t[23]=v,t[24]=b,t[25]=S,t[26]=s,t[27]=f,t[28]=r.activeDocName,t[29]=r.activeProvider,t[30]=r.poolEntries,t[31]=r.syncState,t[32]=C,t[33]=w,t[34]=T,t[35]=E,t[36]=k):k=t[36];let A=k,j;return t[37]!==n||t[38]!==A?(j=(0,K.jsx)(jw,{value:A,children:n}),t[37]=n,t[38]=A,t[39]=j):j=t[39],j}function Lw(){}function Rw(e){return e.ok?e.json():null}function zw(){let e=(0,q.use)(jw);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function Bw(){let e=(0,Yn.c)(3),{openDocumentTransition:t,openTargetTransition:n}=zw(),r;return e[0]!==t||e[1]!==n?(r={openDocumentTransition:t,openTargetTransition:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}var Vw=new Map;function Hw(e,t){Vw.set(e,t)}function Uw(e){let t=Vw.get(e)??null;return Vw.delete(e),t}function Ww(e){Vw.delete(e)}var Gw=class e{static create(t,n,r,i,a){return new e(t,n,r,i+(i<<8)+t+(n<<4)|0,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[Je.contextHash,r]]}addChild(e,t){e.prop(Je.contextHash)!=this.hash&&(e=new nt(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new nt(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new nt(rt.none,e,t,n,this.hashProp)})}},Q;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(Q||={});var Kw=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},qw=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return Zw(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function Jw(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==Q.OrderedList?iT:rT)(n,t,!1);return r>0&&(e.type!=Q.BulletList||tT(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var Yw={[Q.Blockquote](e,t,n){return n.next==62?(n.markers.push(MT(Q.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Xw(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0):!1},[Q.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Q.OrderedList]:Jw,[Q.BulletList]:Jw,[Q.Document](){return!0}};function Xw(e){return e==32||e==9||e==10||e==13}function Zw(e,t=0){for(;t<e.length&&Xw(e.charCodeAt(t));)t++;return t}function Qw(e,t,n){for(;t>n&&Xw(e.charCodeAt(t-1));)t--;return t}function $w(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function eT(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function tT(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!Xw(n))return-1}return n&&e.next==45&&oT(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(vT.SetextHeading)>-1||r<3?-1:1}function nT(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function rT(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Xw(e.text.charCodeAt(e.pos+1)))&&(!n||nT(t,Q.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function iT(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!Xw(e.text.charCodeAt(r+1))||n&&!nT(t,Q.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function aT(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function oT(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&Xw(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var sT=/^[ \t]*$/,cT=/-->/,lT=/\?>/,uT=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,cT],[/^\s*<\?/,lT],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,sT],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,sT]];function dT(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=uT.length-+!!n;e<t;e++)if(uT[e][0].test(r))return e;return-1}function fT(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function pT(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Q.CodeText?e[r].to=n:e.push(MT(Q.CodeText,t,n))}var mT={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(pT(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){pT(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==Q.CodeText?pT(o,e.from,e.to):o.push(e);s=[]}pT(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&pT(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=Q.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Q.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=$w(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=Qw(t.text,t.text.length,o),c=[MT(Q.CodeMark,r,r+a)];o<s&&c.push(MT(Q.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&pT(c,e.lineStart-1,e.lineStart),c.push(MT(Q.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}else{o=!0,n||(pT(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(pT(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(Q.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=eT(t);return n<0?!1:(e.startContext(Q.Blockquote,t.pos),e.addNode(Q.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(tT(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Q.HorizontalRule,n),!0},BulletList(e,t){let n=rT(t,e,!1);if(n<0)return!1;e.block.type!=Q.BulletList&&e.startContext(Q.BulletList,t.basePos,t.next);let r=fT(t,t.pos+1);return e.startContext(Q.ListItem,t.basePos,r-t.baseIndent),e.addNode(Q.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=iT(t,e,!1);if(n<0)return!1;e.block.type!=Q.OrderedList&&e.startContext(Q.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=fT(t,t.pos+n);return e.startContext(Q.ListItem,t.basePos,r-t.baseIndent),e.addNode(Q.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=aT(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=Qw(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!Xw(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Q.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Q.HeaderMark,o-r,a-r);let c=s.finish(Q.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=dT(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=uT[n][1],a=[],o=i!=sT;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==cT?Q.CommentBlock:i==lT?Q.ProcessingInstructionBlock:Q.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},hT=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
48
+ `?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Um(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&Ym(n,r,a.delete):Wm(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??$p();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(pp(s,e)||t!==void 0&&pp(s,t))switch(s.content.constructor){case Oh:{let r=i.get(`ychange`);e!==void 0&&!pp(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&&!pp(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 Rh:case yh:{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 xh:pp(s,e)&&(c(),Bm(i,s.content));break}s=s.right}c()};return e||t?Np(a,n=>{e&&mp(n,e),t&&mp(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)):Np(r,r=>{let i=Rm(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Um(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Np(r,r=>{let i=Rm(r,this,e,!n);Um(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)):Np(n,n=>{Ym(n,Rm(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)):Np(r,r=>{let i=Rm(r,this,e,!1);i.right!==null&&Wm(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Np(this.doc,t=>{Sm(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Np(this.doc,n=>{Cm(n,this,e,t)})}getAttribute(e){return wm(this,e)}getAttributes(){return Tm(this)}_write(e){e.writeTypeRef(Nh)}},Qm=e=>new Zm,$m=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??$p()}[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===nh||t.constructor===eh)&&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})}},eh=class e extends lm{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 lm?e.clone():e)),t}get length(){return this.doc??$p(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new $m(this,e)}querySelector(e){e=e.toUpperCase();let t=new $m(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Hs(new $m(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){cm(this,e,new ih(this,t,e))}toString(){return mm(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),pm(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Np(this.doc,n=>{ym(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Np(this.doc,n=>{let r=e&&e instanceof lm?e._item:e;_m(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 $c(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Np(this.doc,n=>{xm(n,this,e,t)})}toArray(){return dm(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return gm(this,e)}slice(e=0,t=this.length){return um(this,e,t)}forEach(e){pm(this,e)}_write(e){e.writeTypeRef(Fh)}},th=e=>new eh,nh=class e extends eh{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 Fl(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof lm?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):Np(this.doc,t=>{Sm(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Np(this.doc,n=>{Cm(n,this,e,t)})}getAttribute(e){return wm(this,e)}hasAttribute(e){return Em(this,e)}getAttributes(e){return e?Dm(this,e):Tm(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 pm(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ph),e.writeKey(this.nodeName)}},rh=e=>new nh(e.readKey()),ih=class extends Zp{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)})}},ah=class e extends Nm{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(Ih),e.writeKey(this.hookName)}},oh=e=>new ah(e.readKey()),sh=class e extends Zm{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(Lh)}},ch=e=>new sh,lh=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw el()}mergeWith(e){return!1}write(e,t,n){throw el()}integrate(e,t){throw el()}},uh=0,dh=class extends lh{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),vp(e.doc.store,this)}write(e,t){e.writeInfo(uh),e.writeLen(this.length-t)}getMissing(e,t){return null}},fh=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 el()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},ph=e=>new fh(e.readBuf()),mh=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){ff(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}},hh=e=>new mh(e.readLen()),gh=(e,t)=>new yf({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),_h=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(gh(this.doc.guid,this.opts))}splice(e){throw el()}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}},vh=e=>new _h(gh(e.readString(),e.readAny())),yh=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 el()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},bh=e=>new yh(e.readJSON()),xh=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 el()}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}},Sh=e=>new xh(e.readKey(),e.readJSON()),Ch=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}},wh=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 Ch(n)},Th=$l(`node_env`)===`development`,Eh=class e{constructor(e){this.arr=e,Th&&Hl(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}},Dh=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Eh(n)},Oh=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}},kh=e=>new Oh(e.readString()),Ah=[jm,Pm,Qm,rh,th,oh,ch],jh=0,Mh=1,Nh=2,Ph=3,Fh=4,Ih=5,Lh=6,Rh=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 el()}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}},zh=e=>new Rh(Ah[e.readTypeRef()](e)),Bh=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Z(n.client,n.clock+r)),i=bp(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Gh);return{item:i,diff:r}},Vh=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Hh=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Gh(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},Uh=(e,t)=>Ws(e,e=>lf(e.deletions,t)),Wh=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Sp(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Wh(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Sp(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:Sp(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:Sp(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||lf(r,d.right.id)||Uh(a.undoStack,d.right.id)||Uh(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Sp(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=Z(c,_p(s,c)),h=new Gh(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,Vh(h,!0),h.integrate(e,0),h},Gh=class e extends lh{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>=_p(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=_p(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Xf&&this.id.client!==this.parent.client&&this.parent.clock>=_p(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Cp(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Sp(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===dh||this.right&&this.right.constructor===dh)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===Xf){let e=bp(n,this.parent);e.constructor===dh?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Cp(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),Zf(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(Zf(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(bp(e.doc.store,n.origin)))r.has(bp(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),vp(e.doc.store,this),this.content.integrate(e,this),Op(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new dh(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&&Zf(e.origin,this.lastId)&&this.right===e&&Zf(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(),ff(e.deleteSet,this.id.client,this.id.clock,this.length),Op(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw tl();this.content.gc(e),t?wp(e,this,new dh(this.id,this.length)):this.content=new mh(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=Qf(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===Xf?(e.writeParentInfo(!1),e.writeLeftID(t)):tl();i!==null&&e.writeString(i)}this.content.write(e,t)}},Kh=(e,t)=>qh[t&31](e),qh=[()=>{tl()},hh,wh,ph,kh,bh,Sh,zh,Dh,vh,()=>{tl()}],Jh=10,Yh=class extends lh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){tl()}write(e,t){e.writeInfo(Jh),Y(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Xh=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Zh=`__ $YJS$ __`;Xh[Zh]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Xh[Zh]=!0;var Qh=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},$h=/[\uD800-\uDBFF]/,eg=/[\uDC00-\uDFFF]/,tg=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&$h.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&&eg.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},ng=(e,t)=>e>>>t|e<<32-t,rg=e=>ng(e,2)^ng(e,13)^ng(e,22),ig=e=>ng(e,6)^ng(e,11)^ng(e,25),ag=e=>ng(e,7)^ng(e,18)^e>>>3,og=e=>ng(e,17)^ng(e,19)^e>>>10,sg=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]),cg=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),lg=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(cg),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=og(t[e-2])+t[e-7]+ag(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+ig(o)+(o&s^~o&c)+sg[e]+t[e]>>>0,d=rg(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/dc,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}},ug=e=>new lg().digest(e),dg=new r(`y-sync`),fg=new r(`y-undo`),pg=new r(`yjs-cursor`),mg=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},hg=e=>iu(mg(ug(ou(e)))),gg=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!lf(t.ds,e.id),_g=[{light:`#ecd44433`,dark:`#ecd444`}],vg=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=zs();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Sl(t))}return e.get(n)},yg=(e,{colors:t=_g,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new Cg(e,a),c=new be({props:{editable:e=>{let t=dg.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:dg,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(dg);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)&&Rd(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=fg.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)},dg)})}},destroy:()=>{s.destroy()}})});return c},bg=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new o(e.doc));else if(t.type===`node`){let r=Qg(n.doc,n.type,t.anchor,n.mapping);e.setSelection(xg(e,r))}else{let r=Qg(n.doc,n.type,t.anchor,n.mapping),i=Qg(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(C.between(e.doc.resolve(r),e.doc.resolve(i)))}},xg=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?T.create(e.doc,t):C.near(n)},Sg=(e,t)=>({type:t.selection.jsonID,anchor:Xg(t.selection.anchor,e.type,e.mapping),head:Xg(t.selection.head,e.type,e.mapping)}),Cg=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=Qh(),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=Sg(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()?(Jl&&this._domSelectionInView===null&&(Rd(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=Sd.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||=dp(pf(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(dg,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>Tg(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new y(u.from(e),0,0));t.setMeta(dg,{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=>Tg(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new y(u.from(t),0,0));if(e){let t=Xs(Zs(e.anchor,0),n.doc.content.size),r=Xs(Zs(e.head,0),n.doc.content.size);n.setSelection(C.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(dg,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=fp(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&tl(),r=new yf({gc:!1}),Pf(r,t),t=fp(r),Pf(r,e),e=fp(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[yp(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{sf(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:vg(n.colorMapping,n.colors,r)}},s=fm(i,new up(t.ds,e.sv)).map(n=>!n._item.deleted||gg(n._item,e)||gg(n._item,t)?Tg(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 y(u.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(dg,{isChangeOrigin:!0}))},dg)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=dg.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);sf(t,t.deleteSet,e=>{if(e.constructor===Gh){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=>wg(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new y(u.from(n),0,0));bg(r,this.beforeTransactionSelection,this),r=r.setMeta(dg,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof Lp}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{Ug(this.doc,this.type,e,this),this.beforeTransactionSelection=Sg(this,this.prosemirrorView.state)},dg)}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))}},wg=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof nh)return Tg(e,t,n,r,i,a);throw el()}return o},Tg=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof nh){let s=wg(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof Zm&&!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=Eg(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):fm(e,new up(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(gg(e._item,r)?gg(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}},Eg=(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,Vg(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},Dg=(e,t)=>{let n=new sh,r=e.map(e=>({insert:e.text,attributes:Hg(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},Og=(e,t)=>{let n=new nh(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,Mg(e).map(e=>kg(e,t))),t.mapping.set(n,e),n},kg=(e,t)=>e instanceof Array?Dg(e,t):Og(e,t),Ag=e=>typeof e==`object`&&!!e,jg=(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||Ag(o)&&Ag(s)&&jg(o,s)}return r},Mg=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},Ng=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&Pl(e.attributes||{}).length===t[n].marks.length&&Rl(e.attributes,(e,r)=>{let i=Bg(r),a=t[n].marks;return a.find(e=>e.type.name===i)?jg(e,a.find(e=>e.type.name===i)?.attrs):!1}))},Pg=(e,t)=>{if(e instanceof nh&&!(t instanceof Array)&&Wg(e,t)){let n=Mg(t);return e._length===n.length&&jg(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>Pg(e,n[t]))}return e instanceof sh&&t instanceof Array&&Ng(e,t)},Fg=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),Ig=(e,t,n)=>{let r=e.toArray(),i=Mg(t),a=i.length,o=r.length,s=Xs(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(Fg(n.mapping.get(e),t))u=!0;else if(!Pg(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(Fg(n.mapping.get(e),t))u=!0;else if(!Pg(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},Lg=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Oh?t+=n.content.str:n.content instanceof xh&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},Rg=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=Lg(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,Hg(e.marks,n))})),{insert:o,remove:s,index:c}=tg(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})))},zg=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Bg=e=>zg.exec(e)?.[1]??e,Vg=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(Bg(r),e[r]));return n},Hg=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=Is(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${hg(e.toJSON())}`:e.type.name]=e.attrs}}),n},Ug=(e,t,n,r)=>{if(t instanceof nh&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof nh){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=Mg(n),a=i.length,o=t.toArray(),s=o.length,c=Xs(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!Fg(r.mapping.get(e),t))if(Pg(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(!Fg(r.mapping.get(e),t))if(Pg(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 sh&&c instanceof Array)Ng(n,c)||Rg(n,c,r),l+=1;else{let i=n instanceof nh&&Wg(n,c),a=d instanceof nh&&Wg(d,f);if(i&&a){let e=Ig(n,c,r),t=Ig(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(Ug(e,n,c,r),l+=1):a?(Ug(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[kg(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof sh?(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(kg(i[t],r));t.insert(l,e)}},dg)},Wg=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,Gg=null,Kg=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=dg.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)}}},qg=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=Gg;Gg=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new Kg(t,r,e))})}),new e(n)}},Jg=(e=qg.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()||Rd(0,()=>Jg(e,!0));return}throw r}n=!1,e.dequeueFirst()}},Yg=(e,t,n)=>{Gg||(Gg=new Map,Rd(0,Jg)),Is(Gg,e,Ps).set(t,n)},Xg=(e,t,n)=>{if(e===0)return op(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof sh){if(r._length>=e)return op(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 ep(r._item===null?null:r._item.id,r._item===null?Qf(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 ep(r._item===null?null:r._item.id,r._item===null?Qf(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 tl();if(e===0&&r.constructor!==sh&&r!==t)return Zg(r._item.parent,r._item)}return op(t,t._length,-1)},Zg=(e,t)=>{let n=null,r=null;return e._item===null?r=Qf(e):n=Z(e._item.id.client,e._item.id.clock),new ep(n,r,t.id)},Qg=(e,t,n,r)=>{let i=cp(n,e);if(i===null||i.type!==t&&!$f(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===sh)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 sh?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 sh?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},$g=(e,t,n)=>e!==t,e_=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},t_=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),n_=/^#[0-9a-fA-F]{6}$/,r_=(e,t,n,r,i)=>{let a=dg.getState(e);if(a==null||a.doc==null||a.binding==null)return c.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?c.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`:n_.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=Qg(o,a.type,np(t.cursor.anchor),a.binding.mapping),u=Qg(o,a.type,np(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=Zs(e.doc.content.size-1,0);l=Xs(l,t),u=Xs(u,t),s.push(P.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=Xs(l,u),o=Zs(l,u);s.push(P.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),c.create(e.doc,s))},i_=(e,{awarenessStateFilter:t=$g,cursorBuilder:n=e_,selectionBuilder:r=t_,getSelection:i=e=>e.selection}={},a=`cursor`)=>new be({key:pg,state:{init(i,a){return r_(a,e,t,n,r)},apply(i,a,o,s){let c=dg.getState(s),l=i.getMeta(pg);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?r_(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>pg.getState(e)},view:t=>{let n=()=>{t.docView&&Yg(t,pg,{awarenessUpdated:!0})},r=()=>{let n=dg.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=Xg(o.anchor,n.type,n.binding.mapping),c=Xg(o.head,n.type,n.binding.mapping);(r.cursor==null||!lp(np(r.cursor.anchor),s)||!lp(np(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&Qg(n.doc,n.type,np(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)}}}}),a_=e=>{let t=fg.getState(e).undoManager;if(t!=null)return t.undo(),!0},o_=e=>{let t=fg.getState(e).undoManager;if(t!=null)return t.redo(),!0},s_=new Set([`paragraph`]),c_=(e,t)=>!(e instanceof Gh)||!(e.content instanceof Rh)||!(e.content.type instanceof Zm||e.content.type instanceof nh&&t.has(e.content.type.nodeName))||e.content.type._length===0,l_=({protectedNodes:e=s_,trackedOrigins:t=[],undoManager:n=null}={})=>new be({key:fg,state:{init:(r,i)=>{let a=dg.getState(i),o=n||new Lp(a.type,{trackedOrigins:new Set([dg].concat(t)),deleteFilter:t=>c_(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=dg.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:Sg(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=dg.getState(e.state),n=fg.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,fg.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()}}}});function u_(e){let t=(0,Yn.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,K.jsx)(Wa,{"data-slot":`dialog`,...n}),t[2]=n,t[3]=r),r}function d_(e){let t=(0,Yn.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,K.jsx)(Ga,{"data-slot":`dialog-portal`,...n}),t[2]=n,t[3]=r),r}function f_(e){let t=(0,Yn.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,K.jsx)(Xa,{"data-slot":`dialog-close`,className:`font-mono uppercase`,...n}),t[2]=n,t[3]=r),r}function p_(e){let t=(0,Yn.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(Ka,{"data-slot":`dialog-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function m_(e){let t=(0,Yn.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,showCloseButton:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?!0:a,s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,K.jsx)(p_,{}),t[5]=s):s=t[5];let c;t[6]===r?c=t[7]:(c=j(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,r),t[6]=r,t[7]=c);let l;t[8]===o?l=t[9]:(l=o&&(0,K.jsx)(Xa,{"data-slot":`dialog-close`,asChild:!0,children:(0,K.jsxs)(ie,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,K.jsx)(Jn,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Close`})]})}),t[8]=o,t[9]=l);let u;return t[10]!==n||t[11]!==i||t[12]!==c||t[13]!==l?(u=(0,K.jsxs)(d_,{children:[s,(0,K.jsxs)(qa,{"data-slot":`dialog-content`,className:c,...i,children:[n,l]})]}),t[10]=n,t[11]=i,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function h_(e){let t=(0,Yn.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`flex flex-col gap-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(`div`,{"data-slot":`dialog-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function g_(e){let t=(0,Yn.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,showCloseButton:a,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?!1:a,s;t[5]===r?s=t[6]:(s=j(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,r),t[5]=r,t[6]=s);let c;t[7]===o?c=t[8]:(c=o&&(0,K.jsx)(Xa,{asChild:!0,children:(0,K.jsx)(ie,{variant:`outline`,children:`Close`})}),t[7]=o,t[8]=c);let l;return t[9]!==n||t[10]!==i||t[11]!==s||t[12]!==c?(l=(0,K.jsxs)(`div`,{"data-slot":`dialog-footer`,className:s,...i,children:[n,c]}),t[9]=n,t[10]=i,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function __(e){let t=(0,Yn.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`font-heading text-base leading-none font-medium`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(Ja,{"data-slot":`dialog-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function v_(e){let t=(0,Yn.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,K.jsx)(Ya,{"data-slot":`dialog-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function y_(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 b_(e){return typeof e==`object`&&!!e}function x_(e){return e===`files`||e===`backlinks`||e===`graph`||e===`sync-status`}function S_(e){let t;try{t=JSON.parse(e)}catch{return null}return!b_(t)||t.v!==1||!x_(t.ch)||typeof t.seq!=`number`?null:{v:1,ch:t.ch,seq:t.seq}}function C_(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function w_(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function T_(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var E_=2e3,D_=15e3;function O_(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??E_,r=e.maxDelayMs??D_,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 k_(){let e=(0,Yn.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,q.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,q.useRef)(i),[o,s]=(0,q.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=w_(typeof window<`u`?window:void 0);if(t){r(T_(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(T_(t))});return()=>{n()}}let n=O_({fetchConfig:y_,fallbackUrl:C_,now:Date.now,setTimeout:N_,clearTimeout:M_,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,q.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(j_),s(A_)},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 A_(e){return e+1}function j_(e){return{...e,terminal:!1,lastError:null}}function M_(e){return globalThis.clearTimeout(e)}function N_(e,t){return globalThis.setTimeout(e,t)}var P_=Math.floor,F_=(e,t)=>e<t?e:t,I_=(e,t)=>e>t?e:t;Number.isNaN;var L_=128,R_=1<<17,z_=1<<18,B_=1<<19,V_=1<<20,H_=1<<21,U_=1<<22,W_=1<<23,G_=1<<24,K_=1<<25,q_=1<<26,J_=1<<27,Y_=1<<28,X_=1<<29,Z_=1<<30,Q_=127;R_-1,z_-1,B_-1,V_-1,H_-1,U_-1,W_-1,G_-1,K_-1,q_-1,J_-1,Y_-1,X_-1,Z_-1;var $_=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var ev=String.fromCharCode;String.fromCodePoint,ev(65535);var tv=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},nv=typeof TextEncoder<`u`?new TextEncoder:null,rv=nv?e=>nv.encode(e):tv,iv=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});iv&&iv.decode(new Uint8Array).length===1&&(iv=null);var av=(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},ov=(e,t)=>{for(;t>Q_;)av(e,L_|Q_&t),t=P_(t/128);av(e,Q_&t)},sv=new Uint8Array(3e4),cv=sv.length/3,lv=nv&&nv.encodeInto?(e,t)=>{if(t.length<cv){let n=nv.encodeInto(t,sv).written||0;ov(e,n);for(let t=0;t<n;t++)av(e,sv[t])}else dv(e,rv(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;ov(e,r);for(let t=0;t<r;t++)av(e,n.codePointAt(t))},uv=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=F_(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(I_(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},dv=(e,t)=>{ov(e,t.byteLength),uv(e,t)},fv=e=>Error(e),pv=fv(`Unexpected end of array`),mv=fv(`Integer out of Range`),hv=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},gv=e=>hv(e,vv(e)),_v=e=>e.arr[e.pos++],vv=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<L_)return t;if(t>$_)throw mv}throw pv},yv=iv?e=>iv.decode(gv(e)):e=>{let t=vv(e);if(t===0)return``;{let n=String.fromCodePoint(_v(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(_v(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))}},bv=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),xv=(e,t)=>{ov(e,bv.Token),lv(e,t)},Sv=(e,t,n,r)=>{switch(vv(e)){case bv.Token:t();break;case bv.PermissionDenied:n(yv(e));break;case bv.Authenticated:r(yv(e));break;default:}},Cv=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),wv=`\0`;function Tv(e,t){return e+wv+t}function Ev(e){let t=e.indexOf(wv);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var Dv=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 Ov(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 kv(e){return new Promise(t=>setTimeout(t,e))}function Av(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 jv(e,t){let n=Ov(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||Av;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 kv(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 kv(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await kv(e)}return a()}var Mv=Math.floor,Nv=(e,t)=>e<t?e:t,Pv=(e,t)=>e>t?e:t;Number.isNaN;var Fv=64,Iv=128,Lv=1<<17,Rv=1<<18,zv=1<<19,Bv=1<<20,Vv=1<<21,Hv=1<<22,Uv=1<<23,Wv=1<<24,Gv=1<<25,Kv=1<<26,qv=1<<27,Jv=1<<28,Yv=1<<29,Xv=1<<30,Zv=63,Qv=127;Lv-1,Rv-1,zv-1,Bv-1,Vv-1,Hv-1,Uv-1,Wv-1,Gv-1,Kv-1,qv-1,Jv-1,Yv-1,Xv-1;var $v=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var ey=()=>new Set,ty=Array.from;Array.isArray;var ny=String.fromCharCode;String.fromCodePoint,ny(65535);var ry=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},iy=typeof TextEncoder<`u`?new TextEncoder:null,ay=iy?e=>iy.encode(e):ry,oy=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});oy&&oy.decode(new Uint8Array).length===1&&(oy=null);var sy=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},cy=()=>new sy,ly=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},uy=e=>{let t=new Uint8Array(ly(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},dy=(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},fy=(e,t)=>{for(;t>Qv;)dy(e,Iv|Qv&t),t=Mv(t/128);dy(e,Qv&t)},py=new Uint8Array(3e4),my=py.length/3,hy=iy&&iy.encodeInto?(e,t)=>{if(t.length<my){let n=iy.encodeInto(t,py).written||0;fy(e,n);for(let t=0;t<n;t++)dy(e,py[t])}else _y(e,ay(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;fy(e,r);for(let t=0;t<r;t++)dy(e,n.codePointAt(t))},gy=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Nv(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(Pv(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},_y=(e,t)=>{fy(e,t.byteLength),gy(e,t)},vy=e=>Error(e),yy=vy(`Unexpected end of array`),by=vy(`Integer out of Range`),xy=class{constructor(e){this.arr=e,this.pos=0}},Sy=e=>new xy(e),Cy=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},wy=e=>Cy(e,Ey(e)),Ty=e=>e.arr[e.pos++],Ey=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&Qv)*n,n*=128,r<Iv)return t;if(t>$v)throw by}throw yy},Dy=e=>{let t=e.arr[e.pos++],n=t&Zv,r=64,i=(t&Fv)>0?-1:1;if((t&Iv)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&Qv)*r,r*=128,t<Iv)return i*n;if(n>$v)throw by}throw yy},Oy=oy?e=>oy.decode(wy(e)):e=>{let t=Ey(e);if(t===0)return``;{let n=String.fromCodePoint(Ty(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Ty(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))}},ky=e=>{let t=e.pos,n=Oy(e);return e.pos=t,n},Ay=Date.now,jy=()=>new Map,My=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Ny=class{constructor(){this._observers=jy()}on(e,t){My(this._observers,e,ey).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 ty((this._observers.get(e)||jy()).values()).forEach(e=>e(...t))}destroy(){this._observers=jy()}},Py=Symbol(`Equality`),Fy=Object.keys,Iy=e=>Fy(e).length,Ly=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Ry=(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[Py]!=null)return e[Py](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)||!Ry(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Iy(e)!==Iy(t))return!1;for(let n in e)if(!Ly(e,n)||!Ry(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(!Ry(e[n],t[n]))return!1;break;default:return!1}return!0},zy=3e4,By=class extends Ny{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=Ay();this.getLocalState()!==null&&zy/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&zy<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&Vy(this,t,`timeout`)},Mv(zy/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:Ay()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Ry(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}},Vy=(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:Ay()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},Hy=(e,t,n=e.states)=>{let r=t.length,i=cy();fy(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;fy(i,r),fy(i,s),hy(i,JSON.stringify(o))}return uy(i)},Uy=(e,t,n)=>{let r=Sy(t),i=Ay(),a=[],o=[],s=[],c=[],l=Ey(r);for(let t=0;t<l;t++){let t=Ey(r),n=Ey(r),l=JSON.parse(Oy(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&&(Ry(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])},Wy=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={}}},Gy=class{constructor(e){this.data=e,this.encoder=cy(),this.decoder=Sy(new Uint8Array(this.data))}peekVarString(){return ky(this.decoder)}readVarUint(){return Ey(this.decoder)}readVarString(){return Oy(this.decoder)}readVarUint8Array(){return wy(this.decoder)}writeVarUint(e){return fy(this.encoder,e)}writeVarString(e){return hy(this.encoder,e)}writeVarUint8Array(e){return _y(this.encoder,e)}length(){return ly(this.encoder)}},Ky=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}({}),qy=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),Jy=class{constructor(){this.encoder=cy()}get(e){return e.encoder}toUint8Array(){return uy(this.encoder)}},Yy=class extends Jy{constructor(...e){super(...e),this.type=Ky.CLOSE,this.description=`Ask the server to close the connection`}get(e){return hy(this.encoder,e.documentName),fy(this.encoder,this.type),this.encoder}},Xy=class e extends Wy{static{this.DEDUPLICATABLE_TYPES=new Set([Ky.Awareness,Ky.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=qy.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=qy.Connected,this.emit(`status`,{status:qy.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===qy.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===qy.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(Yy,{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===qy.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:jv(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=qy.Connecting,this.emit(`status`,{status:qy.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=Ay();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Ky.Ping){this.sendPong();return}let n=new Gy(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=cy();fy(e,Ky.Pong),this.send(uy(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=qy.Connected,this.emit(`status`,{status:qy.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===qy.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Ay()-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=Sy(e);return{documentName:Oy(t),messageType:Ey(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===Dv.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=qy.Disconnected,this.emit(`status`,{status:qy.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()}},Zy=0,Qy=1,$y=2,eb=(e,t)=>{fy(e,Zy),_y(e,Wf(t))},tb=(e,t,n)=>{fy(e,Qy),_y(e,Rf(t,n))},nb=(e,t,n)=>tb(t,n,wy(e)),rb=(e,t,n,r)=>{try{Ff(t,wy(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},ib=(e,t)=>{fy(e,$y),_y(e,t)},ab=rb,ob=(e,t,n,r,i)=>{let a=Ey(e);switch(a){case Zy:nb(e,t,n);break;case Qy:rb(e,n,r,i);break;case $y:ab(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},sb=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case Ky.Sync:this.applySyncMessage(e,t);break;case Ky.Awareness:this.applyAwarenessMessage(e);break;case Ky.Auth:this.applyAuthMessage(e);break;case Ky.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Ky.Stateless:e.receiveStateless(Oy(n.decoder));break;case Ky.SyncStatus:this.applySyncStatusMessage(e,Dy(n.decoder)===1);break;case Ky.CLOSE:let i={code:1e3,reason:Oy(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(Jy,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Ky.Sync);let r=ob(n.decoder,n.encoder,e.document,e);t&&r===Qy&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;Uy(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;Sv(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(Ky.Awareness),t.writeVarUint8Array(Hy(e.awareness,Array.from(e.awareness.getStates().keys())))}},cb=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return uy(this.encoder)}send(e){e?.send(this.create())}},lb=`4.0.0-rc.1`,ub=class extends Jy{constructor(...e){super(...e),this.type=Ky.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return hy(this.encoder,e.documentName),fy(this.encoder,this.type),xv(this.encoder,e.token),hy(this.encoder,lb),this.encoder}},db=class extends Jy{constructor(...e){super(...e),this.type=Ky.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`);hy(this.encoder,e.documentName),fy(this.encoder,this.type);let t;return t=e.states===void 0?Hy(e.awareness,e.clients):Hy(e.awareness,e.clients,e.states),_y(this.encoder,t),this.encoder}},fb=class extends Jy{constructor(...e){super(...e),this.type=Ky.Stateless,this.description=`A stateless message`}get(e){return hy(this.encoder,e.documentName),fy(this.encoder,this.type),hy(this.encoder,e.payload??``),this.encoder}},pb=class extends Jy{constructor(...e){super(...e),this.type=Ky.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 hy(this.encoder,e.documentName),fy(this.encoder,this.type),eb(this.encoder,e.document),this.encoder}},mb=class extends Jy{constructor(...e){super(...e),this.type=Ky.Sync,this.description=`A document update`}get(e){return hy(this.encoder,e.documentName),fy(this.encoder,this.type),ib(this.encoder,e.update),this.encoder}},hb=class extends Error{constructor(...e){super(...e),this.code=1001}},gb=class extends Wy{get effectiveName(){return this.configuration.sessionAwareness?Tv(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 yf,this.configuration.awareness=e.awareness===void 0?new By(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:Cv(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:Cv(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 Xy(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(pb,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&Vy(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(fb,{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(ub,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(mb,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(db,{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(pb,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(db,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new cb(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new Gy(e.data),{documentName:n}=Ev(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new Gy(e.data)}),new sb(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Vy(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&&(Vy(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 hb(`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)}};function _b(e){return!(e.viewCount>0&&e.viewCount>=50||e.bytes>5e5)}var vb=new Map,yb=new Map,bb=[],xb=[],Sb=new Set,Cb=null;function wb(){if(Cb)return Cb;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`,Cb=e,e}function Tb(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!_b(i)){let e=r(n);return J(`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=vb.get(t);if(a){if(Nb(a,n),a.activeMountKey=t,Fb(bb,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return J(`ok/cache/hit`,{docName:t,kind:`tiptap`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;vb.size>=10;){let e=Ib(bb,t);if(!e)break;Db(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 vb.set(t,s),Fb(bb,t),J(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function Eb(e){if(e.__uncached){try{e.editor.destroy()}catch{}e.activeMountKey=null;return}let t=jb(e.editor);if(t){e.hadFocus=Mb(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=wb();r&&r.appendChild(t.dom)}e.activeMountKey=null}function Db(e){let t=vb.get(e);if(!t)return!1;try{t.editor.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}vb.delete(e);let n=bb.indexOf(e);return n!==-1&&bb.splice(n,1),J(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function Ob(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!_b(i)){let e=r(n);return J(`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=yb.get(t);if(a){if(Pb(a,n),a.activeMountKey=t,Fb(xb,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return J(`ok/cache/hit`,{docName:t,kind:`cm`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;yb.size>=10;){let e=Ib(xb,t);if(!e)break;Ab(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 yb.set(t,s),Fb(xb,t),J(`ok/cache/miss`,{docName:t,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&J(`ok/cold/editor-mount-stats`,{docName:t,viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function kb(e){if(e.__uncached){try{e.view.destroy()}catch{}e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=Mb(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t);let r=wb();r&&r.appendChild(t),e.activeMountKey=null}function Ab(e){let t=yb.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){J(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}yb.delete(e);let n=xb.indexOf(e);return n!==-1&&xb.splice(n,1),J(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function jb(e){return e.editorView??null}function Mb(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function Nb(e,t){let n=jb(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 Pb(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function Fb(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function Ib(e,t){for(let n of e)if(n!==t&&!Sb.has(n))return n;J(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:Sb.size});for(let n of e)if(n!==t)return n;return null}function Lb(e){let t=Sb,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=Rb(e);if(t)try{t.disconnect(),J(`ok/cache/disconnect`,{docName:e})}catch(t){J(`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=Rb(e);if(!n)continue;let r=t=>{J(`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(()=>J(`ok/cache/connect`,{docName:e}),e=>r(e)):J(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}Sb=n}function Rb(e){let t=vb.get(e);if(t)return t.provider;let n=yb.get(e);return n?n.provider:null}var zb=({key:e,editor:t,onPaste:n,onDrop:i,allowedMimeTypes:a})=>new be({key:e||new r(`fileHandler`),props:{handleDrop(e,n){if(!i||!n.dataTransfer?.files.length)return!1;let r=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return a&&(o=o.filter(e=>a.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),i(t,o,r?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let i=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return a&&(i=i.filter(e=>a.includes(e.type))),!(i.length===0||(r.preventDefault(),r.stopPropagation(),n(t,i,o),o.length>0))}}}),Bb=ze.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[zb({key:new r(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),Vb=new r(`imageUpload`);function Hb(){let e=document.createElement(`div`);return e.className=`image-upload-skeleton w-full h-40 rounded-md bg-muted animate-pulse motion-reduce:animate-none my-2`,e.setAttribute(`data-upload-widget`,`loading`),e.setAttribute(`role`,`status`),e.setAttribute(`aria-label`,`Uploading image...`),e}var Ub=new be({key:Vb,state:{init(){return{decorations:c.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(Vb);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=P.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 Vb.getState(e)?.decorations??c.empty}}}),Wb=null;function Gb(e){Wb=e}async function Kb(e,t,n){let r=Wb?`${Wb}.md`:``;if(!r){dr.error(`Cannot upload: no document is open`);return}let i=crypto.randomUUID(),a=Hb();t.view.dispatch(t.state.tr.setMeta(Vb,{type:`add`,id:i,pos:n,widget:a}));let o=new FormData;o.append(`file`,e),o.append(`parentDocName`,r);let s;try{s=await fetch(`/api/upload-image`,{method:`POST`,body:o})}catch(e){console.error(`[uploadAndInsert] Network error:`,e),qb(t,i);return}if(!s.ok){let e=`Upload failed (${s.status})`;try{let t=await s.json();t.error&&(e=t.error)}catch{}console.error(`[uploadAndInsert] Server error:`,e),qb(t,i,e);return}let c;try{let e=await s.json();if(typeof e.src!=`string`)throw Error(`missing src in response`);c=e.src}catch(e){console.error(`[uploadAndInsert] Response parse error:`,e),qb(t,i);return}let l=e.name.replace(/\.[^.]+$/,``),{state:u}=t,d=Vb.getState(u)?.uploads.get(i)??n,f=u.schema.nodes.image;if(!f){console.error(`[uploadAndInsert] Image node type not found in schema`),qb(t,i);return}let p=u.tr.setMeta(Vb,{type:`remove`,id:i}).insert(d,f.create({src:c,alt:l}));t.view.dispatch(p)}function qb(e,t,n){e.view.dispatch(e.state.tr.setMeta(Vb,{type:`remove`,id:t})),dr.error(n??`Upload failed`)}function Jb(e){let{$from:t}=e.selection;return t.depth===0?null:{from:t.before(1),to:t.after(1)}}function Yb(e,t){let n=Jb(e);if(!n)return!1;let{from:r,to:i}=n;if(r===0)return!1;let a=e.doc.resolve(r-1);if(a.depth===0)return!1;let o=a.before(1),s=e.doc.slice(r,i).content,c=e.doc.slice(o,r).content;if(!t)return!0;let l=e.tr;l.replaceWith(o,i,s.append(c));let u=o+1,d=o+s.size,f=e.selection.from-r,p=Math.min(u+f,d);return l.setSelection(C.near(l.doc.resolve(p))),l.scrollIntoView(),t(l),!0}function Xb(e,t){let n=Jb(e);if(!n)return!1;let{from:r,to:i}=n;if(i>=e.doc.content.size)return!1;let a=e.doc.resolve(i+1);if(a.depth===0)return!1;let o=a.after(1),s=e.doc.slice(r,i).content,c=e.doc.slice(i,o).content;if(!t)return!0;let l=e.tr;l.replaceWith(r,o,c.append(s));let u=r+c.size+1,d=r+c.size+s.size,f=e.selection.from-r,p=Math.min(u+f,d);return l.setSelection(C.near(l.doc.resolve(p))),l.scrollIntoView(),t(l),!0}var Zb=ze.create({name:`blockMover`,addKeyboardShortcuts(){return{"Mod-Shift-ArrowUp":({editor:e})=>Yb(e.state,e.view.dispatch),"Mod-Shift-ArrowDown":({editor:e})=>Xb(e.state,e.view.dispatch)}}});function Qb(e){return!!e.getMeta(dg)}function $b(e,t){let n=dg.getState(e);return Qg(n.doc,n.type,t,n.binding.mapping)||0}function ex(e,t){let n=dg.getState(e);return Xg(t,n.type,n.binding.mapping)}var tx=class e extends ae{constructor(e,t){super(e),this.yRelativePosition=t}static fromJSON(t){return new e(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function nx(e,t){return new tx(e,ex(t,e))}function rx(e,t,n){let r=e instanceof tx?e.yRelativePosition:null;if(Qb(t)&&r)return{position:new tx($b(n,r),r),mapResult:null};let i=Ge(e,t),a=i.position.position;return{position:new tx(a,r??ex(n,a)),mapResult:i.mapResult}}var ix=ze.create({name:`collaboration`,priority:1e3,addOptions(){return{document:null,field:`default`,fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name===`undoRedo`)&&console.warn(`[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".`)},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>rx(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>nx(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),fg.getState(t).undoManager.undoStack.length===0?!1:n?a_(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),fg.getState(t).undoManager.redoStack.length===0?!1:n?o_(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){let e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=l_(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let{undoManager:t}=fg.getState(e.state);t.restore&&=(t.restore(),()=>{});let r=n?n(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),n=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on(`afterTransaction`,t.afterTransactionHandler),t._observers=n},r?.destroy&&r.destroy()}}},[yg(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new be({key:new r(`filterInvalidContent`),filterTransaction:t=>{if(!Qb(t))return!0;if(this.storage.isDisabled)return!1;if(!t.docChanged)return!0;try{return t.doc.check(),!0}catch(t){return this.storage.isDisabled=!0,this.editor.emit(`contentError`,{error:t,editor:this.editor,disableCollaboration:()=>{var t;(t=e.doc)==null||t.destroy()}}),!1}}})].filter(Boolean)}});function ax(e){if(!e.length)return c.empty;let t=[],n=e[0].$from.node(0);return e.forEach(e=>{let n=e.$from.pos,r=e.$from.nodeAfter;r&&t.push(P.node(n,n+r.nodeSize,{class:`ProseMirror-selectednoderange`}))}),c.create(n,t)}function ox(e,t,n){let r=n.isText||n.isAtom?0:1;return{start:e+r,end:e+t-r}}function sx(e,t,n,r={}){let i=[],a=e.node(0),{extendOnBoundaryOverlap:o=!0}=r;typeof n==`number`&&n>=0||(n=e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos));let s=new h(e,t,n),c=s.depth===0?0:a.resolve(s.start).posAtIndex(0);return s.parent.forEach((n,r)=>{let l=c+r,u=l+n.nodeSize,d=ox(l,n.nodeSize,n),f=o?t.pos>=d.start&&e.pos<=d.end:t.pos>d.start&&e.pos<d.end;if(l<s.start||l>=s.end||!f)return;let p=new x(a.resolve(l),a.resolve(u));i.push(p)}),i}var cx=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return new lx(e.resolve(this.anchor),e.resolve(this.head))}},lx=class e extends ve{constructor(e,t,n,r=1){let{doc:i}=e,a=e===t,o=e.pos===i.content.size&&t.pos===i.content.size,s=a&&!o?i.resolve(t.pos+(r>0?1:-1)):t,c=a&&o?i.resolve(e.pos-(r>0?1:-1)):e,l=sx(c.min(s),c.max(s),n),u=s.pos>=e.pos?l[0].$from:l[l.length-1].$to,d=s.pos>=e.pos?l[l.length-1].$to:l[0].$from;super(u,d,l),this.depth=n}get $to(){return this.ranges[this.ranges.length-1].$to}eq(t){return t instanceof e&&t.$from.pos===this.$from.pos&&t.$to.pos===this.$to.pos}map(t,n){return new e(t.resolve(n.map(this.anchor)),t.resolve(n.map(this.head)))}toJSON(){return{type:`nodeRange`,anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){let{doc:t}=this.$from;if(this.isForwards&&this.ranges.length>1){let t=this.ranges.slice(0,-1),n=t[0].$from,r=t[t.length-1].$to;return new e(n,r,this.depth)}let n=this.ranges[0],r=t.resolve(Math.max(0,n.$from.pos-1));return new e(this.$anchor,r,this.depth)}extendForwards(){let{doc:t}=this.$from;if(this.isBackwards&&this.ranges.length>1){let t=this.ranges.slice(1),n=t[0].$from,r=t[t.length-1].$to;return new e(r,n,this.depth)}let n=this.ranges[this.ranges.length-1],r=t.resolve(Math.min(t.content.size,n.$to.pos+1));return new e(this.$anchor,r,this.depth)}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n,r,i=1){return new this(e.resolve(t),e.resolve(n),r,i)}getBookmark(){return new cx(this.anchor,this.head)}};lx.prototype.visible=!1;function ux(e){return e instanceof lx}ze.create({name:`nodeRange`,addOptions(){return{depth:void 0,key:`Mod`}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,selection:a,tr:o}=r,{anchor:s,head:c}=a;if(!ux(a)){let e=lx.create(i,s,c,t,-1);return o.setSelection(e),n.dispatch(o),!0}let l=a.extendBackwards();return o.setSelection(l),n.dispatch(o),!0},"Shift-ArrowDown":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,selection:a,tr:o}=r,{anchor:s,head:c}=a;if(!ux(a)){let e=lx.create(i,s,c,t);return o.setSelection(e),n.dispatch(o),!0}let l=a.extendForwards();return o.setSelection(l),n.dispatch(o),!0},"Mod-a":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,tr:a}=r,o=lx.create(i,0,i.content.size,t);return a.setSelection(o),n.dispatch(a),!0}}},onSelectionUpdate(){let{selection:e}=this.editor.state;ux(e)&&this.editor.view.dom.classList.add(`ProseMirror-noderangeselection`)},addProseMirrorPlugins(){let e=!1,t=!1;return[new be({key:new r(`nodeRange`),props:{attributes:()=>e?{class:`ProseMirror-noderangeselection`}:{class:``},handleDOMEvents:{mousedown:(e,n)=>{let{key:r}=this.options,i=/Mac/.test(navigator.platform),a=!!n.shiftKey,o=!!n.ctrlKey,s=!!n.altKey,c=!!n.metaKey;return(r==null||r===`Shift`&&a||r===`Control`&&o||r===`Alt`&&s||r===`Meta`&&c||r===`Mod`&&(i?c:o))&&(t=!0),t&&document.addEventListener(`mouseup`,()=>{t=!1;let{state:n}=e,{doc:r,selection:i,tr:a}=n,{$anchor:o,$head:s}=i;if(o.sameParent(s))return;let c=lx.create(r,o.pos,s.pos,this.options.depth);a.setSelection(c),e.dispatch(a)},{once:!0}),!1}},decorations:n=>{let{selection:r}=n,i=ux(r);if(e=!1,!t)return i?(e=!0,ax(r.ranges)):null;let{$from:a,$to:o}=r;if(!i&&a.sameParent(o))return null;let s=sx(a,o,this.options.depth);return s.length?(e=!0,ax(s)):null}}})]}});function dx(e){let t=``,n=getComputedStyle(e);for(let e=0;e<n.length;e+=1)t+=`${n[e]}:${n.getPropertyValue(n[e])};`;return t}function fx(e){let t=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName(`*`))],r=[t,...Array.from(t.getElementsByTagName(`*`))];return n.forEach((e,t)=>{r[t].style.cssText=dx(e)}),t}var px=[{id:`listItemFirstChild`,evaluate:({parent:e,isFirst:t})=>t&&e&&[`listItem`,`taskItem`].includes(e.type.name)?1e3:0},{id:`listWrapperDeprioritize`,evaluate:({node:e})=>{let t=[`listItem`,`taskItem`],n=e.firstChild;return n&&t.includes(n.type.name)?1e3:0}},{id:`tableStructure`,evaluate:({node:e,parent:t})=>[`tableRow`,`tableCell`,`tableHeader`].includes(e.type.name)||t&&t.type.name===`tableHeader`?1e3:0},{id:`inlineContent`,evaluate:({node:e})=>e.isInline||e.isText?1e3:0}],mx={edges:[`left`,`top`],threshold:12,strength:500};function hx(e){return e===void 0||e===`left`?{...mx}:e===`right`?{edges:[`right`,`top`],threshold:12,strength:500}:e===`both`?{edges:[`left`,`right`,`top`],threshold:12,strength:500}:e===`none`?{edges:[],threshold:0,strength:0}:{...mx,...e}}function gx(e,t,n){if(n.edges.length===0)return!1;let r=t.getBoundingClientRect(),{threshold:i,edges:a}=n;return a.some(t=>t===`left`?e.x-r.left<i:t===`right`?r.right-e.x<i:t===`top`?e.y-r.top<i:t===`bottom`?r.bottom-e.y<i:!1)}function _x(e,t,n,r){return!t||n.edges.length===0?0:gx(e,t,n)?n.strength*r:0}var vx=1e3;function yx(e,t,n,r){let i=vx,a=!1;if(t.every(t=>{let n=t.evaluate(e);return i-=n,i<=0?(a=!0,!1):!0}),a)return-1;let o=e.view.nodeDOM(e.pos);return i-=_x(r,o,n,e.depth),i<=0?-1:i}function bx(e,t,n){return Array.from({length:t},(e,n)=>t-1-n).some(t=>n.includes(e.node(t).type.name))}function xx(e,t,n){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))return null;let r=e.posAtCoords({left:t.x,top:t.y});if(!r)return null;let{doc:i}=e.state,a=i.resolve(r.pos),o=[];n.defaultRules&&o.push(...px),o.push(...n.rules);let s=Array.from({length:a.depth},(e,t)=>a.depth-t).map(r=>{let i=a.node(r),s=a.before(r);if(n.allowedContainers&&r>0&&!bx(a,r,n.allowedContainers))return null;let c=r>0?a.node(r-1):null,l=r>0?a.index(r-1):0,u=c?c.childCount:1,d=yx({node:i,pos:s,depth:r,parent:c,index:l,isFirst:l===0,isLast:l===u-1,$pos:a,view:e},o,n.edgeDetection,t);return d<0?null:{node:i,pos:s,depth:r,score:d,dom:e.nodeDOM(s)}}).filter(e=>e!==null),c=a.nodeAfter;if(c&&c.isAtom&&!c.isInline){let i=r.pos,l=a.depth+1,u=a.parent,d=a.index(),f=u.childCount,p=!0;if(n.allowedContainers&&(p=bx(a,l,n.allowedContainers)),p){let r=yx({node:c,pos:i,depth:l,parent:u,index:d,isFirst:d===0,isLast:d===f-1,$pos:a,view:e},o,n.edgeDetection,t);if(r>=0){let t=e.nodeDOM(i);t&&s.push({node:c,pos:i,depth:l,score:r,dom:t})}}}if(s.length===0)return null;s.sort((e,t)=>t.score===e.score?t.depth-e.depth:t.score-e.score);let l=s[0];return l.dom?{node:l.node,pos:l.pos,dom:l.dom}:null}function Sx(e,t){let n=e;for(;n?.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return n?.parentElement===t.dom?n:void 0}function Cx(e){return Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&e.width>0&&e.height>0}function wx(e,t,n,r=5){if(!Number.isFinite(t)||!Number.isFinite(n))return null;let i=e.dom,a=i.firstElementChild,o=i.lastElementChild;if(!a||!o)return null;let s=a.getBoundingClientRect(),c=o.getBoundingClientRect();if(!Cx(s)||!Cx(c))return null;let l=Math.min(Math.max(s.top+r,n),c.bottom-r),u=.5,d=Math.abs(s.left-c.left)<u,f=Math.abs(s.right-c.right)<u,p=s;d&&f&&(p=s);let m=Math.min(Math.max(p.left+r,t),p.right-r);return!Number.isFinite(m)||!Number.isFinite(l)?null:{x:m,y:l}}var Tx=e=>{let{x:t,y:n,editor:r,nestedOptions:i}=e,{view:a,state:o}=r,s=wx(a,t,n,5);if(!s)return{resultElement:null,resultNode:null,pos:null};let{x:c,y:l}=s;if(i?.enabled){let e=xx(a,{x:c,y:l},i);return e?{resultElement:e.dom,resultNode:e.node,pos:e.pos}:{resultElement:null,resultNode:null,pos:null}}let u=a.root.elementsFromPoint(c,l),d;if(Array.prototype.some.call(u,e=>{if(!a.dom.contains(e))return!1;let t=Sx(e,a);return t?(d=t,!0):!1}),!d){let e=a.posAtCoords({left:c,top:l});if(e){let t=o.doc.resolve(e.pos),n=Math.min(t.depth,1),r=n>0?t.before(n):t.pos,i=o.doc.nodeAt(r);if(i){let e=a.nodeDOM(r);return{resultElement:e instanceof HTMLElement?e:null,resultNode:i,pos:r}}}return{resultElement:null,resultNode:null,pos:null}}let f;try{f=a.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}let p=o.doc.nodeAt(f);if(!p){let e=o.doc.resolve(f),t=e.parent;return{resultElement:d,resultNode:t,pos:e.start()}}return{resultElement:d,resultNode:p,pos:f}};function Ex(e,t){let n=null,r=e.nodeDOM(t);if(r instanceof Element)n=r;else{let{node:r,offset:i}=e.domAtPos(t),a=r.childNodes[i];a instanceof Element?n=a:r instanceof Element?n=r:r.nodeType===Node.TEXT_NODE&&r.parentElement&&(n=r.parentElement)}return(n?getComputedStyle(n).direction:getComputedStyle(e.dom).direction)||`ltr`}function Dx(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function Ox(e,t,n,r){let{doc:i}=t.view.state;if(n?.enabled&&r?.node&&r.pos>=0){let e=r.pos,t=r.pos+r.node.nodeSize;return[{$from:i.resolve(e),$to:i.resolve(t)}]}let a=Tx({editor:t,x:e.clientX,y:e.clientY,direction:`right`,nestedOptions:n});if(!a.resultNode||a.pos===null)return[];let o=a.resultNode.isText||a.resultNode.isAtom?0:-1;return sx(i.resolve(a.pos),i.resolve(a.pos+a.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}function kx(e,t,n,r){let{view:i}=t;if(!e.dataTransfer)return;let{empty:a,$from:o,$to:s}=i.state.selection,c=Ox(e,t,n,r),l=sx(o,s,0,{extendOnBoundaryOverlap:!1}),u=l.some(e=>c.find(t=>t.$from===e.$from&&t.$to===e.$to)),d=a||!u?c:l;if(!d.length)return;let{tr:f}=i.state,p=document.createElement(`div`),m=d[0].$from.pos,h=d[d.length-1].$to.pos;p.setAttribute(`dir`,Ex(i,m));let g=n?.enabled&&r?.node,_,v;g?(_=i.state.doc.slice(m,h),v=T.create(i.state.doc,m)):(v=lx.create(i.state.doc,m,h),_=v.content()),d.forEach(e=>{let t=fx(i.nodeDOM(e.$from.pos));p.append(t)}),p.style.position=`absolute`,p.style.top=`-10000px`,document.body.append(p),e.dataTransfer.clearData();let y=p.getBoundingClientRect(),b=e.clientX-y.left;e.dataTransfer.setDragImage(p,Math.max(0,Math.min(b,y.width)),0);let x=!1,S=()=>{x||(x=!0,Dx(p),document.removeEventListener(`drop`,S),document.removeEventListener(`dragend`,S))},C=v instanceof T?v:void 0;i.dragging={slice:_,move:!0,node:C},f.setSelection(v),i.dispatch(f),document.addEventListener(`drop`,S),document.addEventListener(`dragend`,S)}var Ax=(e,t)=>{let n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},jx=(e,t)=>{let n=e.nodeAt(t),r=e.resolve(t),{depth:i}=r,a=n;for(;i>0;){let e=r.node(i);--i,i===0&&(a=e)}return a},Mx=(e,t)=>{let n=dg.getState(e);return n?Xg(t,n.type,n.binding.mapping):null},Nx=(e,t)=>{let n=dg.getState(e);return n?Qg(n.doc,n.type,t,n.binding.mapping)||0:-1},Px=(e,t)=>{let n=t;for(;n?.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},Fx=new r(`dragHandle`),Ix=({pluginKey:e=Fx,element:t,editor:n,computePositionConfig:i,getReferencedVirtualElement:a,onNodeChange:o,onElementDragStart:s,onElementDragEnd:c,nestedOptions:l})=>{let u=document.createElement(`div`),d=!1,f=null,m=-1,h,g=null,_=null;function v(){t&&(t.style.visibility=`hidden`,t.style.pointerEvents=`none`)}function y(){if(t){if(!n.isEditable){v();return}t.style.visibility=``,t.style.pointerEvents=`auto`}}function b(e){p(a?.()||{getBoundingClientRect:()=>e.getBoundingClientRect()},t,i).then(e=>{Object.assign(t.style,{position:e.strategy,left:`${e.x}px`,top:`${e.y}px`})})}function x(e){s?.(e),kx(e,n,l,{node:f,pos:m}),t&&(t.dataset.dragging=`true`),setTimeout(()=>{t&&(t.style.pointerEvents=`none`)},0)}function S(e){c?.(e),v(),t&&(t.style.pointerEvents=`auto`,t.dataset.dragging=`false`)}function C(){if(re()){let e=n.view.dom;requestAnimationFrame(()=>{e.isContentEditable&&(e.contentEditable=`false`,e.contentEditable=`true`)})}}return u.appendChild(t),{unbind(){t.removeEventListener(`dragstart`,x),t.removeEventListener(`dragend`,S),document.removeEventListener(`drop`,C),g&&(cancelAnimationFrame(g),g=null,_=null)},plugin:new be({key:typeof e==`string`?new r(e):e,state:{init(){return{locked:!1}},apply(e,r,i,a){let s=e.getMeta(`lockDragHandle`),c=e.getMeta(`hideDragHandle`);if(s!==void 0&&(d=s),c)return v(),d=!1,f=null,m=-1,o?.({editor:n,node:null,pos:-1}),r;if(e.docChanged&&m!==-1&&t)if(Qb(e)){let e=Nx(a,h);e!==m&&(m=e)}else{let t=e.mapping.map(m);t!==m&&(m=t,h=Mx(a,m))}return r}},view:e=>{var r;return t.draggable=!0,t.style.pointerEvents=`auto`,t.dataset.dragging=`false`,(r=n.view.dom.parentElement)==null||r.appendChild(u),u.style.pointerEvents=`none`,u.style.position=`absolute`,u.style.top=`0`,u.style.left=`0`,t.addEventListener(`dragstart`,x),t.addEventListener(`dragend`,S),document.addEventListener(`drop`,C),{update(r,i){if(!t)return;if(!n.isEditable){v();return}if(d?t.draggable=!1:t.draggable=!0,e.state.doc.eq(i.doc)||m===-1)return;let a=e.nodeDOM(m);if(a=Px(e,a),a===e.dom||a?.nodeType!==1)return;let s=e.posAtDOM(a,0),c=jx(n.state.doc,s),l=Ax(n.state.doc,s);f=c,m=l,h=Mx(e.state,m),o?.({editor:n,node:f,pos:m}),b(a)},destroy(){t.removeEventListener(`dragstart`,x),t.removeEventListener(`dragend`,S),document.removeEventListener(`drop`,C),g&&(cancelAnimationFrame(g),g=null,_=null),t&&Dx(u)}}},props:{handleDOMEvents:{keydown(e){return!t||d?!1:e.hasFocus()?(v(),f=null,m=-1,o?.({editor:n,node:null,pos:-1}),!1):!1},mouseleave(e,t){return d||t.target&&!u.contains(t.relatedTarget)&&(v(),f=null,m=-1,o?.({editor:n,node:null,pos:-1})),!1},mousemove(e,r){return!t||d||(_={x:r.clientX,y:r.clientY},g)||(g=requestAnimationFrame(()=>{if(g=null,!_)return;let{x:t,y:r}=_;_=null;let i=Tx({x:t,y:r,direction:`right`,editor:n,nestedOptions:l});if(!i.resultElement)return;let a=i.resultElement,s=i.resultNode,c=i.pos;if(!l?.enabled){if(a=Px(e,a),a===e.dom||a?.nodeType!==1)return;let t=e.posAtDOM(a,0);s=jx(n.state.doc,t),c=Ax(n.state.doc,t)}s!==f&&(f=s,m=c??-1,h=Mx(e.state,m),o?.({editor:n,node:f,pos:m}),b(a),y())})),!1}}}})}};function Lx(e){return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:hx(`none`)}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:hx(`left`)}:{enabled:!0,rules:e.rules??[],defaultRules:e.defaultRules??!0,allowedContainers:e.allowedContainers,edgeDetection:hx(e.edgeDetection)}}var Rx={placement:`left-start`,strategy:`absolute`};ze.create({name:`dragHandle`,addOptions(){return{render(){let e=document.createElement(`div`);return e.classList.add(`drag-handle`),e},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1}},addCommands(){return{lockDragHandle:()=>({editor:e})=>(this.options.locked=!0,e.commands.setMeta(`lockDragHandle`,this.options.locked)),unlockDragHandle:()=>({editor:e})=>(this.options.locked=!1,e.commands.setMeta(`lockDragHandle`,this.options.locked)),toggleDragHandle:()=>({editor:e})=>(this.options.locked=!this.options.locked,e.commands.setMeta(`lockDragHandle`,this.options.locked))}},addProseMirrorPlugins(){let e=this.options.render(),t=Lx(this.options.nested);return[Ix({computePositionConfig:{...Rx,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:e,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:t}).plugin]}});var zx=20,Bx=44,Vx=28;function Hx(){let e=document.createElement(`div`);e.className=`ok-block-controls`,e.style.visibility=`hidden`;let t=document.createElement(`button`);t.className=`ok-add-block-btn`,t.setAttribute(`aria-label`,`Add block below`),t.setAttribute(`type`,`button`),t.innerHTML=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus"><path d="M5 12h14"/><path d="M12 5v14"/></svg>`,t.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()});let n=document.createElement(`div`);return n.className=`ok-drag-grip`,n.setAttribute(`aria-hidden`,`true`),n.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-grip-vertical-icon lucide-grip-vertical"><circle cx="9" cy="12" r="1"/><circle cx="9" cy="5" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="19" r="1"/></svg>`,e.appendChild(t),e.appendChild(n),{container:e,addBtn:t}}function Ux(e,t,n){let{state:r,view:i}=e,a=t+n.nodeSize;if(a>r.doc.content.size)return;let{tr:o}=r,s=r.schema.nodes.paragraph?.create();if(!s)return;o.insert(a,s);let c=C.near(o.doc.resolve(a+1));o.setSelection(c).scrollIntoView(),i.dispatch(o),i.focus(),e.commands.insertContent(`/`)}var Wx=ze.create({name:`blockDragHandle`,addProseMirrorPlugins(){let e=this.editor,t=null,n=-1,{container:r,addBtn:i}=Hx();return i.addEventListener(`click`,()=>{t&&n>=0&&Ux(e,n,t)}),[Ix({element:r,editor:e,onNodeChange({node:e,pos:r}){t=e,n=r??-1},computePositionConfig:{placement:`left-start`,strategy:`absolute`,middleware:[je(({rects:e})=>({mainAxis:10,crossAxis:((e.reference.height<=Bx?e.reference.height:Vx)-zx)/2}))]},nestedOptions:Lx(!1)}).plugin]}});function Gx(e){let t=e.trim();if(!t)return null;let r=n(t);return r?{target:r,alias:r===t?null:t,anchor:null}:null}function Kx(e){let t=e.trim();if(!t)return[];let r=n(t);return r.length>0&&r!==t?[r]:[]}function qx(e,t){let n=e.trim();return n?t.has(n)?!0:Kx(n).some(e=>t.has(e)):!1}var Jx=ze.create({name:`headingAnchors`,addProseMirrorPlugins(){return[new be({props:{decorations(e){let t=[],n=new Map;return e.doc.descendants((e,r)=>{if(e.type.name===`heading`){let i=ye(e.textContent,n);if(!i)return;t.push(P.node(r,r+e.nodeSize,{id:i}))}}),c.create(e.doc,t)}}})]}}),Yx=new Set([`http:`,`https:`,`mailto:`,`tel:`]);function Xx(e){try{let t=new URL(e);return Yx.has(t.protocol)}catch{return!1}}function Zx(e=window.location.hash){let t=e.match(/^#\/([^?#]+)/);return t?decodeURIComponent(t[1]):``}function Qx(e,t=window.location.hash){return ee(e,Zx(t))}function $x({docName:e,anchor:t}){return t?`#/${e}?anchor=${encodeURIComponent(t)}`:`#/${e}`}function eS(e){e.startsWith(`#`)||Xx(e)?window.open(e,`_blank`,`noopener,noreferrer`):console.warn(`[safe-nav] blocked non-safe scheme:`,e)}function tS(e){window.location.assign($x(e))}function nS(e){eS($x(e))}function rS(e){return e.metaKey||e.ctrlKey}function iS(e,t=window.location.hash){let n=Zx(t);if(!n)return;let r=document.getElementById(e);r&&r.scrollIntoView({behavior:`smooth`,block:`start`}),window.location.assign(fe(n,e))}function aS(e,t=window.location.hash){if(e.kind===`doc`){tS(e);return}if(e.kind===`anchor`){iS(e.anchor,t);return}eS(e.url)}function oS(e,t,n=window.location.hash){return le(Zx(n),e,t)}var sS=e=>{let t=(0,Yn.c)(13),{kind:n,ariaLabel:r,onDeactivate:i,children:a,layout:o,className:s,"data-slot":c}=e,l=(o===void 0?`standard`:o)===`wide`?`w-[min(720px,calc(100%-1rem))]`:`w-80`,u;t[0]!==s||t[1]!==l?(u=j(`ok-interaction-prop-panel pointer-events-auto absolute left-1/2 top-2 z-40 -translate-x-1/2 rounded-md border border-border bg-popover p-3 shadow-lg`,l,s),t[0]=s,t[1]=l,t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,K.jsx)(Jn,{className:`size-3.5`,"aria-hidden":`true`}),t[3]=d):d=t[3];let f;t[4]===i?f=t[5]:(f=(0,K.jsx)(ie,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:i,className:`absolute right-1 top-1 size-7`,children:d}),t[4]=i,t[5]=f);let p;return t[6]!==r||t[7]!==a||t[8]!==c||t[9]!==n||t[10]!==u||t[11]!==f?(p=(0,K.jsxs)(`div`,{role:`dialog`,"aria-label":r,"data-ok-prop-panel":n,"data-slot":c,className:u,children:[a,f]}),t[6]=r,t[7]=a,t[8]=c,t[9]=n,t[10]=u,t[11]=f,t[12]=p):p=t[12],p};function cS(t,n){let r=[t,...n.fallbackTargets??[]],i=new Set,a=null;for(let t of r){if(i.has(t))continue;i.add(t);let r=e(t,{pages:n.pages,folderPaths:n.folderPaths});if(r.kind===`missing`){a??=r;continue}return{kind:`navigate`,displayState:r.kind===`folder`?`folder`:`resolved`,resolvedTarget:r,hashDocName:r.target}}let o=a??e(t,{pages:n.pages,folderPaths:n.folderPaths});if(o.kind!==`missing`)return{kind:`navigate`,displayState:o.kind===`folder`?`folder`:`resolved`,resolvedTarget:o,hashDocName:o.target};let s=n.createDialogSeed??Oe(o.target);return{kind:`create`,displayState:`missing`,resolvedTarget:o,initialDir:s.initialDir,suggestedName:s.suggestedName}}function lS(e){if(e.kind!==`navigate`||e.displayState!==`folder`)return null;let t=e.resolvedTarget;return`folderPath`in t?{initialDir:t.folderPath,suggestedName:`index.md`}:null}function uS(e){let t=(0,Yn.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,type:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=j(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a||t[8]!==i?(o=(0,K.jsx)(`input`,{type:i,"data-slot":`input`,className:a,...r}),t[6]=r,t[7]=a,t[8]=i,t[9]=o):o=t[9],o}function dS(e){return e.trim()?e.includes(`..`)?`Path cannot contain ".."`:e.startsWith(`/`)?`Path cannot start with "/"`:e.includes(`\\`)?`Path cannot contain backslashes`:e.includes(`\0`)?`Path cannot contain null bytes`:null:`Name cannot be empty`}function fS(e){return e.endsWith(`.md`)?e:`${e}.md`}function pS(e){let t=fS(e.fileName.trim());if(e.kind===`folder`){let n=(e.folderName??``).trim();return`${e.initialDir?`${e.initialDir}/${n}`:n}/${t}`}return e.initialDir?`${e.initialDir}/${t}`:t}function mS(e){let t=e.target;return t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable?!1:!!((e.metaKey||e.ctrlKey)&&e.altKey&&e.key.toLowerCase()===`n`)}function hS(e){let t=e.value.lastIndexOf(`.`);t>0?e.setSelectionRange(0,t):e.select()}function gS(e){let t=(0,Yn.c)(87),{open:n,onOpenChange:r,kind:i,initialDir:a,suggestedName:o,description:s,onCreated:c}=e,{addPage:l}=xe(),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(null),b=(0,q.useId)(),x=(0,q.useId)(),S=(0,q.useId)(),C=(0,q.useRef)(null),w=(0,q.useRef)(null),T,E;t[0]!==i||t[1]!==n||t[2]!==o?(T=()=>{n&&(h(null),y(null),_(!1),p(``),d(i===`file`?o??`untitled.md`:`index.md`))},E=[n,i,o],t[0]=i,t[1]=n,t[2]=o,t[3]=T,t[4]=E):(T=t[3],E=t[4]),(0,q.useEffect)(T,E);let D;t[5]!==u||t[6]!==f||t[7]!==a||t[8]!==i?(D=function(){return pS({kind:i,initialDir:a,fileName:u,folderName:f})},t[5]=u,t[6]=f,t[7]=a,t[8]=i,t[9]=D):D=t[9];let O=D,k;t[10]!==u||t[11]!==f||t[12]!==i?(k=function(){if(i===`folder`){let e=dS(f.trim());if(e)return{message:`Folder name: ${e}`,field:`folder`}}let e=dS(u.trim());return e?{message:e,field:`file`}:null},t[10]=u,t[11]=f,t[12]=i,t[13]=k):k=t[13];let A=k,j;t[14]!==g||t[15]!==u||t[16]!==f||t[17]!==i?(j=g||!u.trim()||i===`folder`&&!f.trim(),t[14]=g,t[15]=u,t[16]=f,t[17]=i,t[18]=j):j=t[18];let M=j,N;t[19]!==l||t[20]!==O||t[21]!==A||t[22]!==i||t[23]!==c||t[24]!==r?(N=async function(){let e=A();if(e){h(e.message),y(e.field);return}_(!0),h(null),y(null);let t=O();try{let e=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!e.ok){let t=`Server error (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=n.error)}catch{}_(!1),h(t),y(`form`);return}let n=await e.json();if(_(!1),!n.ok){h(n.error??`Failed to create ${i}`),y(`form`);return}let a=n.docName??t.replace(/\.md$/,``);r(!1),window.location.hash=`#/${a}`,l(a),Re([`files`,`backlinks`,`graph`]),c?.(a)}catch(e){console.warn(`[NewItemDialog] create failed:`,e),_(!1),h(`Network error — please try again`),y(`form`)}},t[19]=l,t[20]=O,t[21]=A,t[22]=i,t[23]=c,t[24]=r,t[25]=N):N=t[25];let P=N,F=a||`(root)`,I=i===`file`?`New file`:`New folder`,L;t[26]===I?L=t[27]:(L=(0,K.jsx)(__,{children:I}),t[26]=I,t[27]=L);let R;t[28]!==s||t[29]!==F?(R=s??(0,K.jsxs)(K.Fragment,{children:[`Create in `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:F})]}),t[28]=s,t[29]=F,t[30]=R):R=t[30];let z;t[31]===R?z=t[32]:(z=(0,K.jsx)(v_,{children:R}),t[31]=R,t[32]=z);let B;t[33]!==L||t[34]!==z?(B=(0,K.jsxs)(h_,{children:[L,z]}),t[33]=L,t[34]=z,t[35]=B):B=t[35];let V;t[36]!==m||t[37]!==v||t[38]!==b||t[39]!==x||t[40]!==f||t[41]!==i?(V=i===`folder`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:x,children:`Folder name`}),(0,K.jsx)(uS,{ref:w,id:x,value:f,onChange:e=>{p(e.target.value),h(null)},placeholder:`folder-name`,autoFocus:!0,"aria-describedby":m&&(v===`folder`||v===`form`)?b:void 0,"aria-invalid":m&&(v===`folder`||v===`form`)?!0:void 0,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=dS(f.trim());if(t){h(`Folder name: ${t}`),y(`folder`);return}C.current?.focus()}}})]}),t[36]=m,t[37]=v,t[38]=b,t[39]=x,t[40]=f,t[41]=i,t[42]=V):V=t[42];let H=i===`folder`?`First file name`:`File name`,ee;t[43]!==S||t[44]!==H?(ee=(0,K.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:S,children:H}),t[43]=S,t[44]=H,t[45]=ee):ee=t[45];let te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>{d(e.target.value),h(null)},t[46]=te):te=t[46];let ne=i===`file`,re=m&&(v===`file`||v===`form`)?b:void 0,ae=m&&(v===`file`||v===`form`)?!0:void 0,U;t[47]!==P||t[48]!==M?(U=e=>{e.key===`Enter`&&!M&&P()},t[47]=P,t[48]=M,t[49]=U):U=t[49];let oe;t[50]!==S||t[51]!==u||t[52]!==ne||t[53]!==re||t[54]!==ae||t[55]!==U?(oe=(0,K.jsx)(uS,{ref:C,id:S,value:u,onChange:te,placeholder:`my-note.md`,autoFocus:ne,"aria-describedby":re,"aria-invalid":ae,onFocus:_S,onKeyDown:U}),t[50]=S,t[51]=u,t[52]=ne,t[53]=re,t[54]=ae,t[55]=U,t[56]=oe):oe=t[56];let se;t[57]!==ee||t[58]!==oe?(se=(0,K.jsxs)(`div`,{children:[ee,oe]}),t[57]=ee,t[58]=oe,t[59]=se):se=t[59];let ce;t[60]!==m||t[61]!==b?(ce=m&&(0,K.jsx)(`p`,{id:b,role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:m}),t[60]=m,t[61]=b,t[62]=ce):ce=t[62];let le;t[63]!==V||t[64]!==se||t[65]!==ce?(le=(0,K.jsxs)(`div`,{className:`space-y-3`,children:[V,se,ce]}),t[63]=V,t[64]=se,t[65]=ce,t[66]=le):le=t[66];let ue;t[67]===r?ue=t[68]:(ue=()=>r(!1),t[67]=r,t[68]=ue);let de;t[69]!==g||t[70]!==ue?(de=(0,K.jsx)(ie,{variant:`outline`,className:`font-mono uppercase`,onClick:ue,disabled:g,children:`Cancel`}),t[69]=g,t[70]=ue,t[71]=de):de=t[71];let fe=g?`Creating...`:`Create`,pe;t[72]!==P||t[73]!==M||t[74]!==fe?(pe=(0,K.jsx)(ie,{onClick:P,disabled:M,children:fe}),t[72]=P,t[73]=M,t[74]=fe,t[75]=pe):pe=t[75];let me;t[76]!==de||t[77]!==pe?(me=(0,K.jsxs)(g_,{children:[de,pe]}),t[76]=de,t[77]=pe,t[78]=me):me=t[78];let he;t[79]!==B||t[80]!==le||t[81]!==me?(he=(0,K.jsxs)(m_,{className:`sm:max-w-md`,"data-ok-layer-spawned":``,children:[B,le,me]}),t[79]=B,t[80]=le,t[81]=me,t[82]=he):he=t[82];let ge;return t[83]!==r||t[84]!==n||t[85]!==he?(ge=(0,K.jsx)(u_,{open:n,onOpenChange:r,children:he}),t[83]=r,t[84]=n,t[85]=he,t[86]=ge):ge=t[86],ge}function _S(e){return hS(e.currentTarget)}var vS=class{registry=new Map;_activeNodeId=null;listeners=new Set;_snapshot={activeNodeId:null,active:null};register(e){this.registry.set(e.nodeId,e),this._activeNodeId===e.nodeId&&this.refreshSnapshot()}deregister(e){this.registry.delete(e)&&this._activeNodeId===e&&(this._activeNodeId=null,this.refreshSnapshot())}setActiveNode(e){this._activeNodeId!==e&&(e!==null&&!this.registry.has(e)||(this._activeNodeId=e,this.refreshSnapshot()))}getActiveNode(){return this._activeNodeId}getRegistration(e){return this.registry.get(e)}hasRegistration(e){return this.registry.has(e)}clear(){this.registry.clear(),this._activeNodeId=null,this.refreshSnapshot()}getSnapshot=()=>this._snapshot;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});refreshSnapshot(){let e=this._activeNodeId==null?null:this.registry.get(this._activeNodeId)??null;this._snapshot={activeNodeId:this._activeNodeId,active:e};for(let e of this.listeners)e()}};function yS(e,t){let n=e??null;for(;n&&typeof n==`object`;){let e=n.getAttribute;if(typeof e==`function`){let r=e.call(n,`data-mark-id`);if(r&&t.hasRegistration(r))return r;let i=e.call(n,`data-node-id`);if(i&&t.hasRegistration(i))return i}n=n.parentElement??null}return null}var bS=e=>{let t=(0,Yn.c)(18),{store:n}=e,r;t[0]===n?r=t[1]:(r=()=>n.getSnapshot(),t[0]=n,t[1]=r);let[i,a]=(0,q.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>(a(n.getSnapshot()),n.subscribe(()=>{a(n.getSnapshot())})),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,q.useEffect)(o,s);let{active:c}=i;if(!c)return null;let l;t[5]===n?l=t[6]:(l=()=>n.setActiveNode(null),t[5]=n,t[6]=l);let u,d,f;if(t[7]!==c.controls||t[8]!==c.nodeId||t[9]!==c.type||t[10]!==l){let e={nodeId:c.nodeId,type:c.type,deactivate:l};u=c.controls.propPanel?.(e),d=c.controls.toolbar?.(e),f=c.controls.breadcrumb?.(e),t[7]=c.controls,t[8]=c.nodeId,t[9]=c.type,t[10]=l,t[11]=u,t[12]=d,t[13]=f}else u=t[11],d=t[12],f=t[13];let p;return t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,K.jsxs)(K.Fragment,{children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17],p};function xS(e){return e.editorView?.dom??e.view?.dom??null}function SS(e,t){let n=e;for(;n;){if(n.getAttribute?.(`data-mark-id`)===t||n.getAttribute?.(`data-node-id`)===t)return!0;n=n.parentElement}return!1}function CS(e){let{editor:t}=e,n=new vS,r=xS(t),i=!1,a=null,o=n.subscribe(()=>{let e=n.getActiveNode();if(e!==null){if(typeof document<`u`){let t=document.activeElement;a=t&&SS(t,e)?t:null}return}if(typeof document>`u`)return;let i=a;if(a=null,i&&document.contains(i)&&typeof i.focus==`function`){try{i.focus({preventScroll:!0})}catch{}return}let o=r??xS(t);if(o&&typeof o.focus==`function`)try{o.focus({preventScroll:!0})}catch{}}),s=e=>{let t=e;if(t.button===2)return;if(t.metaKey||t.ctrlKey||t.button===1){t.button===1&&t.preventDefault?.();return}let r=yS(e.target,n);if(r===null)return;let i=n.getRegistration(r);i?.handlePrimary&&i.handlePrimary({nodeId:r,type:i.type,newTab:!1})||n.setActiveNode(r)},c=e=>{let t=e;if(t.button===2||t.type===`click`&&t.button===1||!(t.metaKey||t.ctrlKey||t.button===1))return;let r=yS(e.target,n);if(r===null)return;let i=n.getRegistration(r);i?.handlePrimary&&i.handlePrimary({nodeId:r,type:i.type,newTab:!0})&&t.preventDefault?.()},l=e=>{let t=e;if(t.key===`Escape`){n.getActiveNode()!==null&&(n.setActiveNode(null),t.preventDefault?.());return}if(t.key!==`Enter`&&t.key!==` `&&t.key!==`Spacebar`)return;let r=yS(e.target,n);if(r===null)return;let i=n.getRegistration(r);t.preventDefault?.(),!(i?.handlePrimary&&i.handlePrimary({nodeId:r,type:i.type,newTab:!1}))&&n.setActiveNode(r)},u=e=>{if(n.getActiveNode()===null)return;let t=e.target;t&&(r?.contains(t)||t instanceof Element&&(t.closest(`[data-ok-interaction-layer]`)||t.closest(`[data-ok-prop-panel]`)||t.closest(`[data-ok-layer-spawned]`))||n.setActiveNode(null))},d=()=>{i||(r=xS(t),r&&(r.addEventListener(`pointerdown`,s,!0),r.addEventListener(`click`,c,!0),r.addEventListener(`auxclick`,c,!0),r.addEventListener(`keydown`,l,!0),typeof document<`u`&&document.addEventListener(`pointerdown`,u,!0),i=!0))},f=()=>{i&&=(r?.removeEventListener(`pointerdown`,s,!0),r?.removeEventListener(`click`,c,!0),r?.removeEventListener(`auxclick`,c,!0),r?.removeEventListener(`keydown`,l,!0),typeof document<`u`&&document.removeEventListener(`pointerdown`,u,!0),!1)};return d(),{register(e){n.register(e),i||d()},deregister(e){n.deregister(e)},setActiveNode(e){n.setActiveNode(e)},getActiveNode(){return n.getActiveNode()},getRegistration(e){return n.getRegistration(e)},destroy(){f(),o(),n.clear()},store:n}}var wS=e=>{let t=(0,Yn.c)(2),{store:n}=e,r;return t[0]===n?r=t[1]:(r=(0,K.jsx)(`div`,{"data-ok-interaction-layer":``,className:`contents`,children:(0,K.jsx)(bS,{store:n})}),t[0]=n,t[1]=r),r},TS=new WeakMap;function ES(e){let t=TS.get(e);if(t)return t;let n=CS({editor:e});return TS.set(e,n),e.on(`destroy`,()=>{n.destroy(),TS.delete(e)}),n}var DS=new r(`markIdentity`);function OS(){return{byId:new Map,counter:0}}function kS(e,t,n,r,i){let a=[];for(let e of t.byId.values()){let t=i?i.map(e.from,-1):e.from,n=i?i.map(e.to,1):e.to;n<=t||a.push({id:e.id,markType:e.markType,attrs:e.attrs,from:t,to:n})}let o=new Map,s=new Set,c=t.counter;return e.descendants((e,t)=>{if(!(!e.isInline||e.marks.length===0))for(let i of e.marks){if(!n.has(i.type.name)||r&&!r(i))continue;let l=null;for(let e of a)if(!s.has(e.id)&&e.markType===i.type.name&&AS(e.attrs,i.attrs)&&!(t<e.from||t>=e.to)){l=e.id;break}let u=l??`m${++c}`;s.add(u);let d=t,f=t+e.nodeSize,p=o.get(u);p?p.to=Math.max(p.to,f):o.set(u,{id:u,markType:i.type.name,attrs:i.attrs,from:d,to:f})}}),{byId:o,counter:c}}function AS(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i&&!(typeof n==`object`&&n&&typeof i==`object`&&i&&AS(n,i)))return!1}return!0}function jS(e,t,n,r){let i=new Set(t.byId.keys());for(let[r,i]of t.byId)e.has(r)||n?.(i);for(let t of e)i.has(t)||r?.(t);return i}function MS(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new be({key:DS,state:{init(e,t){return kS(t.doc,OS(),a,n)},apply(e,t,r,i){return e.docChanged?kS(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=DS.getState(t.state);n&&(e=jS(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}function NS(e,t){return DS.getState(e)?.byId.get(t)??null}function PS(e){let{editor:t,layer:n,renderPropPanel:r,handlePrimary:i}=e;return{onRegister:e=>{n.register({type:e.markType,nodeId:e.id,controls:{propPanel:e=>r({editor:t,nodeId:e.nodeId,deactivate:e.deactivate})},handlePrimary:i?e=>i({editor:t,nodeId:e.nodeId,newTab:e.newTab}):void 0})},onDeregister:e=>{n.deregister(e)}}}function FS(e){let{editor:t,layer:n,markTypes:r,predicate:i,renderPropPanel:a,handlePrimary:o}=e,s=PS({editor:t,layer:n,renderPropPanel:a,handlePrimary:o});return MS({markTypes:[...r],predicate:i,onRegister:s.onRegister,onDeregister:s.onDeregister})}function IS(e){let t=ES(e.editor);return FS({...e,layer:t})}function LS(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=we(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function RS(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
49
+ `);return/\s/.test(n)}):!1}var zS=new r(`suggestion`);function BS({pluginKey:e=zS,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:l=`suggestion`,decorationContent:u=``,decorationEmptyClass:d=`is-empty`,command:f=()=>null,items:p=()=>[],render:m=()=>({}),allow:h=()=>!0,findSuggestionMatch:g=LS,shouldShow:_,shouldResetDismissed:v}){let y,b=m?.(),x=r&&!i,S=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},C=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:S,w=({match:e,dismissedRange:n,state:r,transaction:i})=>v?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:x})?!1:x?e.range.from===n.from:e.range.from===n.from&&!RS(i);function T(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>f({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:C(n,a)};(i=b?.onExit)==null||i.call(b,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let E=new be({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,d=!c.active&&l.active,m=c.active&&!l.active,h=!d&&!m&&c.query!==l.query,g=d||u&&h,_=h||u,v=m||u&&h;if(!g&&!_&&!v)return;let x=v&&!g?c:l,S=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);y={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>f({editor:t,range:x.range,props:e}),decorationNode:S,clientRect:C(e,S)},g&&((r=b?.onBeforeStart)==null||r.call(b,y)),_&&((i=b?.onBeforeUpdate)==null||i.call(b,y)),(_||g)&&(y.items=await p({editor:t,query:x.query})),v&&((a=b?.onExit)==null||a.call(b,y)),_&&((o=b?.onUpdate)==null||o.call(b,y)),g&&((s=b?.onStart)==null||s.call(b,y))},destroy:()=>{var e;y&&((e=b?.onExit)==null||e.call(b,y))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(s,c,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=s,{empty:m,from:v}=p,y={...c},b=s.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=c.active?{...c.range}:c.dismissedRange,y;if(y.composing=f,s.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:s.mapping.map(y.dismissedRange.from),to:s.mapping.map(y.dismissedRange.to)}),d&&(m||t.view.composing)){(v<c.range.from||v>c.range.to)&&!f&&!c.composing&&(y.active=!1);let e=g({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&h({editor:t,state:u,range:e.range,isActive:c.active})&&(!_||_({editor:t,range:e.range,query:e.query,text:e.text,transaction:s}))?(y.dismissedRange!==null&&!w({match:e,dismissedRange:y.dismissedRange,state:u,transaction:s})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=c.decorationId?c.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=E.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=E.getState(t.state);return(r=b?.onKeyDown)==null||r.call(b,{view:t,event:n,range:i.range}),T(t,e),!0}return(b?.onKeyDown)?.call(b,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=E.getState(e);if(!t)return null;let a=!i?.length,o=[l];return a&&o.push(d),c.create(e.doc,[P.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":u})])}}});return E}var VS=BS,HS=_(z(((e,t)=>{((e,n)=>{typeof define==`function`&&define.amd?define([],n):typeof t==`object`&&t.exports?t.exports=n():e.fuzzysort=n()})(e,e=>{var t=(e,t)=>{if(!e||!t)return F;var n=p(e);j(t)||(t=f(t));var r=n.bitflags;return(r&t._bitflags)===r?h(n,t):F},n=(e,t,n)=>{if(!e)return n?.all?m(t,n):P;var r=p(e),i=r.bitflags,a=r.containsSpace,o=u(n?.threshold||0),c=n?.limit||M,l=0,d=0,g=t.length;function _(e){l<c?(L.add(e),++l):(++d,e._score>L.peek()._score&&L.replaceTop(e))}if(n?.key)for(var v=n.key,y=0;y<g;++y){var b=t[y],x=A(b,v);if(x&&(j(x)||(x=f(x)),(i&x._bitflags)===i)){var S=h(r,x);S!==F&&(S._score<o||(S.obj=b,_(S)))}}else if(n?.keys){var C=n.keys,w=C.length;outer:for(var y=0;y<g;++y){for(var b=t[y],T=0,R=0;R<w;++R){var v=C[R],x=A(b,v);if(!x){O[R]=I;continue}j(x)||(x=f(x)),O[R]=x,T|=x._bitflags}if((i&T)===i){if(a)for(let e=0;e<r.spaceSearches.length;e++)E[e]=N;for(var R=0;R<w;++R){if(x=O[R],x===I){k[R]=I;continue}if(k[R]=h(r,x,!1,a),k[R]===F){k[R]=I;continue}if(a)for(let e=0;e<r.spaceSearches.length;e++){if(D[e]>-1e3&&E[e]>N){var z=(E[e]+D[e])/4;z>E[e]&&(E[e]=z)}D[e]>E[e]&&(E[e]=D[e])}}if(a){for(let e=0;e<r.spaceSearches.length;e++)if(E[e]===N)continue outer}else{var B=!1;for(let e=0;e<w;e++)if(k[e]._score!==N){B=!0;break}if(!B)continue}var V=new s(w);for(let e=0;e<w;e++)V[e]=k[e];if(a){var H=0;for(let e=0;e<r.spaceSearches.length;e++)H+=E[e]}else{var H=N;for(let e=0;e<w;e++){var S=V[e];if(S._score>-1e3&&H>N){var z=(H+S._score)/4;z>H&&(H=z)}S._score>H&&(H=S._score)}}if(V.obj=b,V._score=H,n?.scoreFn){if(H=n.scoreFn(V),!H)continue;H=u(H),V._score=H}H<o||_(V)}}}else for(var y=0;y<g;++y){var x=t[y];if(x&&(j(x)||(x=f(x)),(i&x._bitflags)===i)){var S=h(r,x);S!==F&&(S._score<o||_(S))}}if(l===0)return P;for(var ee=Array(l),y=l-1;y>=0;--y)ee[y]=L.poll();return ee.total=l+d,ee},r=(e,t=`<b>`,n=`</b>`)=>{for(var r=typeof t==`function`?t:void 0,i=e.target,a=i.length,o=e.indexes,s=``,c=0,l=0,u=!1,d=[],f=0;f<a;++f){var p=i[f];if(o[l]===f){if(++l,u||(u=!0,r?(d.push(s),s=``):s+=t),l===o.length){r?(s+=p,d.push(r(s,c++)),s=``,d.push(i.substr(f+1))):s+=p+n+i.substr(f+1);break}}else u&&(u=!1,r?(d.push(r(s,c++)),s=``):s+=n);s+=p}return r?d:s},i=e=>{typeof e==`number`?e=``+e:typeof e!=`string`&&(e=``);var t=v(e);return c(e,{_targetLower:t._lower,_targetLowerCodes:t.lowerCodes,_bitflags:t.bitflags})},a=()=>{x.clear(),S.clear()};class o{get indexes(){return this._indexes.slice(0,this._indexes.len).sort((e,t)=>e-t)}set indexes(e){return this._indexes=e}highlight(e,t){return r(this,e,t)}get score(){return l(this._score)}set score(e){this._score=u(e)}}class s extends Array{get score(){return l(this._score)}set score(e){this._score=u(e)}}var c=(e,t)=>{let n=new o;return n.target=e,n.obj=t.obj??F,n._score=t._score??N,n._indexes=t._indexes??[],n._targetLower=t._targetLower??``,n._targetLowerCodes=t._targetLowerCodes??F,n._nextBeginningIndexes=t._nextBeginningIndexes??F,n._bitflags=t._bitflags??0,n},l=e=>e===N?0:e>1?e:Math.E**(((-e+1)**.04307-1)*-2),u=e=>e===0?N:e>1?e:1-(Math.log(e)/-2+1)**(1/.04307),d=e=>{typeof e==`number`?e=``+e:typeof e!=`string`&&(e=``),e=e.trim();var t=v(e),n=[];if(t.containsSpace){var r=e.split(/\s+/);r=[...new Set(r)];for(var i=0;i<r.length;i++)if(r[i]!==``){var a=v(r[i]);n.push({lowerCodes:a.lowerCodes,_lower:r[i].toLowerCase(),containsSpace:!1})}}return{lowerCodes:t.lowerCodes,_lower:t._lower,containsSpace:t.containsSpace,bitflags:t.bitflags,spaceSearches:n}},f=e=>{if(e.length>999)return i(e);var t=x.get(e);return t===void 0?(t=i(e),x.set(e,t),t):t},p=e=>{if(e.length>999)return d(e);var t=S.get(e);return t===void 0?(t=d(e),S.set(e,t),t):t},m=(e,t)=>{var n=[];n.total=e.length;var r=t?.limit||M;if(t?.key)for(var i=0;i<e.length;i++){var a=e[i],o=A(a,t.key);if(o!=F){j(o)||(o=f(o));var l=c(o.target,{_score:o._score,obj:a});if(n.push(l),n.length>=r)return n}}else if(t?.keys)for(var i=0;i<e.length;i++){for(var a=e[i],u=new s(t.keys.length),d=t.keys.length-1;d>=0;--d){var o=A(a,t.keys[d]);if(!o){u[d]=I;continue}j(o)||(o=f(o)),o._score=N,o._indexes.len=0,u[d]=o}if(u.obj=a,u._score=N,n.push(u),n.length>=r)return n}else for(var i=0;i<e.length;i++){var o=e[i];if(o!=F&&(j(o)||(o=f(o)),o._score=N,o._indexes.len=0,n.push(o),n.length>=r))return n}return n},h=(e,t,n=!1,r=!1)=>{if(n===!1&&e.containsSpace)return g(e,t,r);for(var i=e._lower,a=e.lowerCodes,s=a[0],c=t._targetLowerCodes,l=a.length,u=c.length,d=0,f=0,p=0;;){var m=s===c[f];if(m){if(C[p++]=f,++d,d===l)break;s=a[d]}if(++f,f>=u)return F}var d=0,h=!1,_=0,v=t._nextBeginningIndexes;v===F&&(v=t._nextBeginningIndexes=b(t.target)),f=C[0]===0?0:v[C[0]-1];var y=0;if(f!==u)for(;;)if(f>=u){if(d<=0||(++y,y>200))break;--d;var x=w[--_];f=v[x]}else{var m=a[d]===c[f];if(m){if(w[_++]=f,++d,d===l){h=!0;break}++f}else f=v[f]}var S=l<=1?-1:t._targetLower.indexOf(i,C[0]),T=!!~S,E=T?S===0||t._nextBeginningIndexes[S-1]===S:!1;if(T&&!E){for(var D=0;D<v.length;D=v[D])if(!(D<=S)){for(var O=0;O<l&&a[O]===t._targetLowerCodes[D+O];O++);if(O===l){S=D,E=!0;break}}}var k=e=>{for(var t=0,n=0,r=1;r<l;++r)e[r]-e[r-1]!==1&&(t-=e[r],++n);var i=e[l-1]-e[0]-(l-1);if(t-=(12+i)*n,e[0]!==0&&(t-=e[0]*e[0]*.2),!h)t*=1e3;else{for(var a=1,r=v[0];r<u;r=v[r])++a;a>24&&(t*=(a-24)*10)}return t-=(u-l)/2,T&&(t/=1+l*l*1),E&&(t/=1+l*l*1),t-=(u-l)/2,t};if(!h){if(T)for(var D=0;D<l;++D)C[D]=S+D;var A=C,j=k(A)}else if(E){for(var D=0;D<l;++D)C[D]=S+D;var A=C,j=k(C)}else var A=w,j=k(w);t._score=j;for(var D=0;D<l;++D)t._indexes[D]=A[D];t._indexes.len=l;let M=new o;return M.target=t.target,M._score=t._score,M._indexes=t._indexes,M},g=(e,t,n)=>{for(var r=new Set,i=0,a=F,o=0,s=e.spaceSearches,c=s.length,l=0,u=()=>{for(let e=l-1;e>=0;e--)t._nextBeginningIndexes[T[e*2+0]]=T[e*2+1]},d=!1,f=0;f<c;++f){D[f]=N;var p=s[f];if(a=h(p,t),n){if(a===F)continue;d=!0}else if(a===F)return u(),F;if(f!==c-1){var m=a._indexes,g=!0;for(let e=0;e<m.len-1;e++)if(m[e+1]-m[e]!==1){g=!1;break}if(g){var _=m[m.len-1]+1,v=t._nextBeginningIndexes[_-1];for(let e=_-1;e>=0&&v===t._nextBeginningIndexes[e];e--)t._nextBeginningIndexes[e]=_,T[l*2+0]=e,T[l*2+1]=v,l++}}i+=a._score/c,D[f]=a._score/c,a._indexes[0]<o&&(i-=(o-a._indexes[0])*2),o=a._indexes[0];for(var y=0;y<a._indexes.len;++y)r.add(a._indexes[y])}if(n&&!d)return F;u();var b=h(e,t,!0);if(b!==F&&b._score>i){if(n)for(var f=0;f<c;++f)D[f]=b._score/c;return b}n&&(a=t),a._score=i;var f=0;for(let e of r)a._indexes[f++]=e;return a._indexes.len=f,a},_=e=>e.replace(/\p{Script=Latin}+/gu,e=>e.normalize(`NFD`)).replace(/[\u0300-\u036f]/g,``),v=e=>{e=_(e);for(var t=e.length,n=e.toLowerCase(),r=[],i=0,a=!1,o=0;o<t;++o){var s=r[o]=n.charCodeAt(o);if(s===32){a=!0;continue}var c=s>=97&&s<=122?s-97:s>=48&&s<=57?26:s<=127?30:31;i|=1<<c}return{lowerCodes:r,bitflags:i,containsSpace:a,_lower:n}},y=e=>{for(var t=e.length,n=[],r=0,i=!1,a=!1,o=0;o<t;++o){var s=e.charCodeAt(o),c=s>=65&&s<=90,l=c||s>=97&&s<=122||s>=48&&s<=57,u=c&&!i||!a||!l;i=c,a=l,u&&(n[r++]=o)}return n},b=e=>{e=_(e);for(var t=e.length,n=y(e),r=[],i=n[0],a=0,o=0;o<t;++o)i>o?r[o]=i:(i=n[++a],r[o]=i===void 0?t:i);return r},x=new Map,S=new Map,C=[],w=[],T=[],E=[],D=[],O=[],k=[],A=(e,t)=>{var n=e[t];if(n!==void 0)return n;if(typeof t==`function`)return t(e);var r=t;Array.isArray(t)||(r=t.split(`.`));for(var i=r.length,a=-1;e&&++a<i;)e=e[r[a]];return e},j=e=>typeof e==`object`&&typeof e._bitflags==`number`,M=1/0,N=-M,P=[];P.total=0;var F=null,I=i(``),L=(e=>{var t=[],n=0,r={},i=e=>{for(var r=0,i=t[r],a=1;a<n;){var o=a+1;r=a,o<n&&t[o]._score<t[a]._score&&(r=o),t[r-1>>1]=t[r],a=1+(r<<1)}for(var s=r-1>>1;r>0&&i._score<t[s]._score;s=(r=s)-1>>1)t[r]=t[s];t[r]=i};return r.add=(e=>{var r=n;t[n++]=e;for(var i=r-1>>1;r>0&&e._score<t[i]._score;i=(r=i)-1>>1)t[r]=t[i];t[r]=e}),r.poll=(e=>{if(n!==0){var r=t[0];return t[0]=t[--n],i(),r}}),r.peek=(e=>{if(n!==0)return t[0]}),r.replaceTop=(e=>{t[0]=e,i()}),r})();return{single:t,go:n,prepare:i,cleanup:a}})}))(),1);function US(e){return e.kind===`anchor`?`${e.docName}#${e.slug}`:e.docName}function WS(e){return e.kind===`anchor`?`Heading H${e.level}: ${e.text}`:e.kind===`create`?e.actionLabel:e.title}function GS(e){let t=(0,Yn.c)(41),{items:n,query:r,selectedIndex:i,onSelect:a,loading:o,error:s,mode:c,pageTarget:l,anchorQuery:u}=e,d=o===void 0?!1:o,f=s===void 0?null:s,p=c===void 0?`page`:c,m=l===void 0?``:l,h=u===void 0?``:u,g=(0,q.useRef)(null),_=(0,q.useId)(),v=i>=0&&i<n.length?`${_}-option-${i}`:void 0,y,b;t[0]===i?(y=t[1],b=t[2]):(y=()=>{let e=g.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(i);t&&t.scrollIntoView({block:`nearest`})},b=[i],t[0]=i,t[1]=y,t[2]=b),(0,q.useEffect)(y,b);let x=KS;if(d){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n=p===`anchor`?`Loading headings for ${m}…`:`Loading pages…`,r;return t[4]===n?r=t[5]:(r=(0,K.jsx)(`div`,{ref:g,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:x,children:n}),t[4]=n,t[5]=r),r}if(n.length===0){let e;t[6]!==h||t[7]!==f||t[8]!==p||t[9]!==m||t[10]!==r?(e=f??(p===`anchor`?h.trim()?`No headings match "${h.trim()}"`:`No headings in ${m}`:r.trim()?`No pages found for "${r.trim()}"`:`No pages found`),t[6]=h,t[7]=f,t[8]=p,t[9]=m,t[10]=r,t[11]=e):e=t[11];let n=e,i;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(i={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[12]=i):i=t[12];let a;return t[13]===n?a=t[14]:(a=(0,K.jsx)(`div`,{ref:g,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:i,onMouseDown:x,children:n}),t[13]=n,t[14]=a),a}let S=i>=0&&i<n.length?n[i]:null,C=p===`anchor`?`Heading suggestions`:`Wiki link suggestions`,w;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(w={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[15]=w):w=t[15];let T;t[16]===S?T=t[17]:(T=S?WS(S):``,t[16]=S,t[17]=T);let E;t[18]===T?E=t[19]:(E=(0,K.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:T}),t[18]=T,t[19]=E);let D;t[20]===f?D=t[21]:(D=f&&(0,K.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300`,children:f}),t[20]=f,t[21]=D);let O;t[22]!==p||t[23]!==m?(O=p===`anchor`&&(0,K.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:m}),t[22]=p,t[23]=m,t[24]=O):O=t[24];let k;if(t[25]!==n||t[26]!==_||t[27]!==a||t[28]!==i){let e;t[30]!==_||t[31]!==a||t[32]!==i?(e=(e,t)=>{let n=t===i,r=US(e);return e.kind===`anchor`?(0,K.jsxs)(`button`,{id:`${_}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,style:{paddingLeft:`${(e.level-1)*10+8}px`},onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,K.jsxs)(`span`,{className:`w-6 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,K.jsx)(`span`,{className:`truncate font-medium`,children:e.text})]},r):(0,K.jsxs)(`button`,{id:`${_}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full flex-col rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:e.kind===`create`?e.actionLabel:e.title}),e.kind===`page`&&e.title!==e.docName&&(0,K.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.docName}),e.kind===`create`&&(0,K.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[e.docName,`.md`]})]},r)},t[30]=_,t[31]=a,t[32]=i,t[33]=e):e=t[33],k=n.map(e),t[25]=n,t[26]=_,t[27]=a,t[28]=i,t[29]=k}else k=t[29];let A;return t[34]!==v||t[35]!==E||t[36]!==D||t[37]!==O||t[38]!==k||t[39]!==C?(A=(0,K.jsxs)(`div`,{ref:g,role:`listbox`,"aria-label":C,"aria-activedescendant":v,tabIndex:-1,onMouseDown:x,className:`w-64 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:w,children:[E,D,O,k]}),t[34]=v,t[35]=E,t[36]=D,t[37]=O,t[38]=k,t[39]=C,t[40]=A):A=t[40],A}function KS(e){return e.preventDefault()}function qS(e,t){let n=document.createElement(`div`);n.style.position=`fixed`,n.style.zIndex=`50`,n.style.visibility=`hidden`,document.body.appendChild(n);let r={getBoundingClientRect:()=>e()?.clientRect?.()??new DOMRect,get contextElement(){return e()?.editor.view.dom}},i=!1,a=!1,o=()=>{n.isConnected&&(n.style.removeProperty(`--suggestion-menu-max-height`),p(r,n,{placement:`bottom-start`,middleware:[je(4),I(),V({apply({availableHeight:e}){n.isConnected&&n.style.setProperty(`--suggestion-menu-max-height`,`${Math.min(e,window.innerHeight*.4)}px`)}})]}).then(({x:e,y:t})=>{n.isConnected&&(n.style.left=`${e}px`,n.style.top=`${t}px`,i&&!a&&(n.style.removeProperty(`visibility`),a=!0))}).catch(e=>{n.isConnected&&console.warn(`[${t}] computePosition failed`,e)}))};return{popup:n,doPosition:o,startAutoUpdate:()=>R(r,n,o),reveal:()=>{a||(i=!0,o())}}}function JS(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var YS=new r(`wikiLinkSuggestion`),XS=8;function ZS(e){let t=e.indexOf(`#`);return t>0?{mode:`anchor`,pageTarget:e.slice(0,t),anchorQuery:e.slice(t+1)}:{mode:`page`,pageTarget:``,anchorQuery:``}}function QS(e,t){return t?HS.default.go(t,e,{keys:[`title`,`docName`],threshold:-1e4}).map(e=>e.obj).slice(0,XS):e.slice(0,XS)}function $S(e,t){return t?HS.default.go(t,e,{key:`text`,threshold:-1e4}).map(e=>e.obj).slice(0,XS):e.slice(0,XS)}function eC(e,t){let n=QS(e,t);if(n.length>0)return n.map(e=>({kind:`page`,...e}));let r=Gx(t);return r?[{kind:`create`,docName:r.target,title:t.trim(),actionLabel:`Insert unresolved link "${t.trim()}"`}]:[]}function tC(e,t,n){return $S(t,n).map(t=>({kind:`anchor`,docName:e,level:t.level,text:t.text,slug:t.slug}))}function nC(e){let{mode:t,pageTarget:n,anchorQuery:r}=ZS(e);return t===`anchor`&&n?{target:n,alias:null,anchor:r.trim()||null}:Gx(e)}function rC(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``),r=n.match(/\[\[([^\]]*)$/);if(!r)return null;let i=r[1];return{range:{from:t.start()+n.lastIndexOf(`[[`),to:t.pos},query:i,text:r[0]}}async function iC(){let e=await fetch(`/api/pages`);if(!e.ok)throw Error(`/api/pages responded with ${e.status}`);let t=await e.json();return Array.isArray(t.pages)?t.pages:[]}async function aC(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`/api/page-headings responded with ${t.status}`);let n=await t.json();return n.ok&&Array.isArray(n.headings)?n.headings:[]}function oC(e){let t=[],n=!1,r=!1,i=new Map,a=null,o=null,s=null;return VS({editor:e,pluginKey:YS,char:`[[`,allowedPrefixes:null,findSuggestionMatch:rC,items:async({query:e})=>{let{mode:c,pageTarget:l,anchorQuery:u}=ZS(e);if(c===`anchor`){if(!i.has(l)&&a!==l){a=l;try{let e=await aC(l);i.set(l,e),s=null}catch(e){console.error(`[wiki-link-suggestion] Failed to fetch headings:`,e),i.set(l,[]),s=`Failed to load headings for ${l}. Press Escape and type [[ again to retry.`}finally{a=null}}return tC(l,i.get(l)??[],u)}if(!n&&!r){r=!0;try{t=await iC(),o=null}catch(e){console.error(`[wiki-link-suggestion] Failed to fetch pages:`,e),o=`Failed to load pages. Press Escape and type [[ again to retry, or continue typing to insert an unresolved link.`,t=[]}finally{n=!0,r=!1}}return eC(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=null;if(n.kind===`page`?r={target:n.docName,alias:null,anchor:null}:n.kind===`anchor`?r={target:n.docName,alias:null,anchor:n.slug}:n.kind===`create`&&(r=Gx(n.title)),!r)return;e.chain().focus().deleteRange(t).insertContent({type:`wikiLink`,attrs:r}).run()}catch(e){console.error(`[wiki-link-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,c=null,l=0,u={popup:null,stopAutoUpdate:null},d=null,f=null,p=e=>{c?.command(e)};function m(e,t,r){let{mode:a,pageTarget:c,anchorQuery:u}=ZS(e.query??``),d=t===null?a===`anchor`?!i.has(c):!n:t;return{items:e.items,query:e.query??``,selectedIndex:l,onSelect:r,loading:d,error:a===`page`?o:s,mode:a,pageTarget:c,anchorQuery:u}}let h=t=>{!e||!c||e.updateProps(m(c,t,p))},g=()=>{if(!c)return;let{editor:e,range:t}=c,n=nC(c.query??``);if(n)try{e.chain().focus().deleteRange(t).insertContent({type:`wikiLink`,attrs:n}).run()}catch(e){console.error(`[wiki-link-suggestion] fallback insert error:`,e)}};return{onBeforeStart(t){c=t,l=0;let n=qS(()=>c,`wiki-link-suggestion`);u.popup=n.popup,d=n.doPosition,f=n.reveal,e=new Ds(GS,{props:m(t,!0,p),editor:t.editor}),n.popup.appendChild(e.element),u.stopAutoUpdate=n.startAutoUpdate()},onBeforeUpdate(e){let t=c?ZS(c.query??``).mode:null,n=ZS(e.query??``).mode;c=e,t!==n&&(l=0,h(!0))},onStart(e){c=e,l=0,h(null),f?.()},onUpdate(e){c=e,l=Math.min(l,Math.max(0,e.items.length-1)),h(null),d?.()},onKeyDown({event:e}){if(!c)return!1;let t=c.items;if(e.key===`ArrowDown`)return t.length===0?!1:(l=(l+1)%t.length,h(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(l=(l-1+t.length)%t.length,h(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[l];return e?c.command(e):g(),!0}return e.key,!1},onExit(){JS(u),d=null,f=null,e?.destroy(),e=null,c=null,l=0,t=[],i=new Map,o=null,s=null,n=!1,r=!1,a=null}}}})}function sC(e,t){let n=(0,Yn.c)(4),[r,i]=(0,q.useState)(null),a,o;return n[0]!==e||n[1]!==t?(a=()=>{if(!t||!e){i(null);return}let n=!1;return i(null),aC(e).then(e=>{n||i(e)}).catch(()=>{n||i([])}),()=>{n=!0}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,q.useEffect)(a,o),r}function cC(e,t){let n=e.trim();return n?n.startsWith(`#`)?`anchor`:n.startsWith(`/`)||Ue(n)?`external`:`doc`:t}function lC(e){return e?.kind===`doc`?`doc`:e?.kind===`anchor`?`anchor`:`external`}function uC(e){let t=(0,Yn.c)(64),{open:n,href:r,pages:i,onOpenChange:a,onSave:o}=e,[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(`doc`),p=(0,q.useId)(),m=(0,q.useId)(),h=(0,q.useId)(),g,_;t[0]!==r||t[1]!==n?(g=()=>{if(!n)return;let e=Qx(r);if(f(lC(e)),e?.kind===`doc`){c(e.docName),u(e.anchor??``);return}if(e?.kind===`anchor`){c(`#${e.anchor}`),u(``);return}c(e?.kind===`external`?e.url:r),u(``)},_=[r,n],t[0]=r,t[1]=n,t[2]=g,t[3]=_):(g=t[2],_=t[3]),(0,q.useEffect)(g,_);let v,y,b;t[4]!==d||t[5]!==s||t[6]!==i?(v=Fe(s),y=d===`doc`,b=y&&qx(v,i),t[4]=d,t[5]=s,t[6]=i,t[7]=v,t[8]=y,t[9]=b):(v=t[7],y=t[8],b=t[9]);let x=sC(v,b&&n),S=!!x?.length,C;t[10]!==v||t[11]!==y||t[12]!==l||t[13]!==s||t[14]!==a||t[15]!==o?(C=function(){let e=s.trim();e&&(o(y?oS(v,l.trim()||null):e),a(!1))},t[10]=v,t[11]=y,t[12]=l,t[13]=s,t[14]=a,t[15]=o,t[16]=C):C=t[16];let w=C,T;t[17]===w?T=t[18]:(T=function(e){e.key===`Enter`&&(e.preventDefault(),w())},t[17]=w,t[18]=T);let E=T,D;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,K.jsx)(Ka,{className:`fixed inset-0 z-50 bg-black/40 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`}),t[19]=D):D=t[19];let O,k;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,K.jsx)(Ja,{className:`mb-1 text-base font-semibold`,children:`Edit markdown link`}),k=(0,K.jsx)(Ya,{className:`mb-4 text-sm text-muted-foreground`,children:`Update the destination and optional section anchor.`}),t[20]=O,t[21]=k):(O=t[20],k=t[21]);let A=y?`Page`:`Link target`,M;t[22]!==A||t[23]!==p?(M=(0,K.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:p,children:A}),t[22]=A,t[23]=p,t[24]=M):M=t[24];let N;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{let t=e.target.value;c(t),f(e=>cC(t,e))},t[25]=N):N=t[25];let P;t[26]!==s||t[27]!==E||t[28]!==p?(P=(0,K.jsx)(uS,{id:p,value:s,onChange:N,placeholder:`guides/install or https://example.com`,autoFocus:!0,onKeyDown:E}),t[26]=s,t[27]=E,t[28]=p,t[29]=P):P=t[29];let F;t[30]===y?F=t[31]:(F=y?(0,K.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`This changes the destination page. The visible link text stays editable inline in the document.`}):null,t[30]=y,t[31]=F);let I;t[32]!==M||t[33]!==P||t[34]!==F?(I=(0,K.jsxs)(`div`,{children:[M,P,F]}),t[32]=M,t[33]=P,t[34]=F,t[35]=I):I=t[35];let L;t[36]!==m||t[37]!==y||t[38]!==l||t[39]!==E||t[40]!==h||t[41]!==x||t[42]!==S?(L=y?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:m,children:[`Section`,` `,(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional heading anchor)`})]}),(0,K.jsx)(uS,{id:m,value:l,onChange:e=>u(e.target.value),placeholder:`heading-slug`,"aria-controls":S?h:void 0,"aria-expanded":S?!0:void 0,"aria-haspopup":S?`listbox`:void 0,onKeyDown:E}),S?(0,K.jsx)(`div`,{role:`listbox`,id:h,"aria-label":`Heading anchors`,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:x.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":l===e.slug,className:j(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,l===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>u(l===e.slug?``:e.slug),children:[(0,K.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,K.jsx)(`span`,{className:`truncate`,children:e.text})]},`${e.slug}-${e.level}-${e.text}`))}):null]}):null,t[36]=m,t[37]=y,t[38]=l,t[39]=E,t[40]=h,t[41]=x,t[42]=S,t[43]=L):L=t[43];let R;t[44]!==I||t[45]!==L?(R=(0,K.jsxs)(`div`,{className:`mb-4 space-y-6`,children:[I,L]}),t[44]=I,t[45]=L,t[46]=R):R=t[46];let z;t[47]===a?z=t[48]:(z=(0,K.jsx)(ie,{variant:`outline`,onClick:()=>a(!1),children:`Cancel`}),t[47]=a,t[48]=z);let B;t[49]===s?B=t[50]:(B=s.trim(),t[49]=s,t[50]=B);let V=!B,H;t[51]!==w||t[52]!==V?(H=(0,K.jsx)(ie,{onClick:w,disabled:V,children:`Save`}),t[51]=w,t[52]=V,t[53]=H):H=t[53];let ee;t[54]!==z||t[55]!==H?(ee=(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[z,H]}),t[54]=z,t[55]=H,t[56]=ee):ee=t[56];let te;t[57]!==R||t[58]!==ee?(te=(0,K.jsxs)(Ga,{children:[D,(0,K.jsxs)(qa,{"data-slot":`dialog-content`,"data-ok-layer-spawned":``,className:`fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-lg border border-border bg-background p-6 shadow-xl data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,children:[O,k,R,ee]})]}),t[57]=R,t[58]=ee,t[59]=te):te=t[59];let ne;return t[60]!==a||t[61]!==n||t[62]!==te?(ne=(0,K.jsx)(Wa,{open:n,onOpenChange:a,children:te}),t[60]=a,t[61]=n,t[62]=te,t[63]=ne):ne=t[63],ne}function dC(e){let t=(0,Yn.c)(81),{editor:n,nodeId:r,sourceDocName:i,onClose:a}=e,o=NS(n.state,r),s=o?.attrs?.href??``,[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(null),{folderPaths:f,pages:p,loading:m}=xe();if(!o||!s)return null;let h=ee(s,i),g;t[0]!==n||t[1]!==r?(g=function(e){let t=NS(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:e}).run()},t[0]=n,t[1]=r,t[2]=g):g=t[2];let _=g,v;t[3]!==n||t[4]!==r||t[5]!==a?(v=function(){let e=NS(n.state,r);e&&(n.chain().focus().setTextSelection({from:e.from,to:e.to}).extendMarkRange(`link`).unsetLink().run(),a())},t[3]=n,t[4]=r,t[5]=a,t[6]=v):v=t[6];let y=v,b=function(e){if(h){if(h.kind===`external`){aS(h);return}if(h.kind===`anchor`||h.kind===`doc`){let t=h.kind===`doc`?h.docName:i,n=h.anchor??null;e.newTab?nS({docName:t,anchor:n}):window.location.assign($x({docName:t,anchor:n}))}}},x=function(e){if(u!==`missing`)return;let t=NS(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:oS(e,h?.kind===`doc`?h.anchor??null:null)}).run()},S,C=!1,w=!1,T=null;if(m){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Hn,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[7]=e):e=t[7],S={icon:e,text:`Loading…`,className:`text-muted-foreground`}}else if(h?.kind===`external`){let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(jn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[8]=e):e=t[8],S={icon:e,text:`External link`,className:`text-foreground`}}else if(h?.kind===`anchor`){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Nn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[9]=e):e=t[9],S={icon:e,text:`Anchor in this page`,className:`text-foreground`}}else if(h?.kind===`doc`){let e=cS(h.docName,{pages:p,folderPaths:f});if(T=lS(e),w=e.kind===`navigate`&&e.displayState===`folder`,C=e.kind===`create`,w){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Pn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[10]=e):e=t[10],S={icon:e,text:`Folder (no index)`,className:`text-foreground`}}else if(C){let e;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(kn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[11]=e):e=t[11],S={icon:e,text:`Page not found`,className:`text-red-700 dark:text-red-300`}}else{let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Nn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[12]=e):e=t[12],S={icon:e,text:`Page link`,className:`text-foreground`}}}else{let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(kn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[13]=e):e=t[13],S={icon:e,text:`Unrecognized link`,className:`text-muted-foreground`}}let E=j(`text-sm font-medium`,S.className),D;t[14]!==S.text||t[15]!==E?(D=(0,K.jsx)(`div`,{className:E,children:S.text}),t[14]=S.text,t[15]=E,t[16]=D):D=t[16];let O;t[17]===s?O=t[18]:(O=(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,title:s,children:s}),t[17]=s,t[18]=O);let k;t[19]!==D||t[20]!==O?(k=(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[D,O]}),t[19]=D,t[20]=O,t[21]=k):k=t[21];let A;t[22]!==b||t[23]!==C||t[24]!==a||t[25]!==h?.kind?(A=C?null:(0,K.jsx)(ie,{size:`sm`,variant:`default`,onClick:()=>{b({}),a()},children:h?.kind===`external`?`Open in new tab`:`Open`}),t[22]=b,t[23]=C,t[24]=a,t[25]=h?.kind,t[26]=A):A=t[26];let M;t[27]!==C||t[28]!==d?(M=C?(0,K.jsx)(ie,{size:`sm`,variant:`default`,onClick:()=>d(`missing`),children:`Create page`}):null,t[27]=C,t[28]=d,t[29]=M):M=t[29];let N;t[30]!==T||t[31]!==w||t[32]!==d?(N=w&&T?(0,K.jsxs)(ie,{size:`sm`,variant:`outline`,onClick:()=>d(`folder-index`),children:[(0,K.jsx)(Mn,{className:`size-3.5`,"aria-hidden":`true`}),`Create index`]}):null,t[30]=T,t[31]=w,t[32]=d,t[33]=N):N=t[33];let P;t[34]===l?P=t[35]:(P=()=>l(!0),t[34]=l,t[35]=P);let F;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,K.jsx)(Wn,{className:`size-3.5`,"aria-hidden":`true`}),t[36]=F):F=t[36];let I;t[37]===P?I=t[38]:(I=(0,K.jsxs)(ie,{size:`sm`,variant:`outline`,onClick:P,children:[F,`Edit`]}),t[37]=P,t[38]=I);let L;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,K.jsx)(qn,{className:`size-3.5`,"aria-hidden":`true`}),t[39]=L):L=t[39];let R;t[40]===y?R=t[41]:(R=(0,K.jsxs)(ie,{size:`sm`,variant:`outline`,className:`text-red-700 hover:bg-red-50 hover:text-red-800 dark:text-red-300 dark:hover:bg-red-100/10 dark:hover:text-red-200`,onClick:y,children:[L,`Remove`]}),t[40]=y,t[41]=R);let z;t[42]!==N||t[43]!==I||t[44]!==R||t[45]!==A||t[46]!==M?(z=(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[A,M,N,I,R]}),t[42]=N,t[43]=I,t[44]=R,t[45]=A,t[46]=M,t[47]=z):z=t[47];let B=u!==null,V;t[48]===d?V=t[49]:(V=e=>{e||d(null)},t[48]=d,t[49]=V);let H;t[50]!==u||t[51]!==T||t[52]!==f||t[53]!==C||t[54]!==p||t[55]!==h?(H=u===`folder-index`&&T?T.initialDir:C&&h?.kind===`doc`&&cS(h.docName,{pages:p,folderPaths:f}).kind===`create`?cS(h.docName,{pages:p,folderPaths:f}).initialDir:``,t[50]=u,t[51]=T,t[52]=f,t[53]=C,t[54]=p,t[55]=h,t[56]=H):H=t[56];let te;t[57]!==u||t[58]!==T||t[59]!==f||t[60]!==C||t[61]!==p||t[62]!==h?(te=u===`folder-index`&&T?T.suggestedName:C&&h?.kind===`doc`&&cS(h.docName,{pages:p,folderPaths:f}).kind===`create`?cS(h.docName,{pages:p,folderPaths:f}).suggestedName:void 0,t[57]=u,t[58]=T,t[59]=f,t[60]=C,t[61]=p,t[62]=h,t[63]=te):te=t[63];let ne;t[64]!==u||t[65]!==T||t[66]!==h?(ne=u===`folder-index`&&T?(0,K.jsxs)(K.Fragment,{children:[`Create an index note for`,` `,(0,K.jsxs)(`span`,{className:`font-medium text-foreground`,children:[T.initialDir,`/`]})]}):(0,K.jsxs)(K.Fragment,{children:[`Create a page for`,` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:h?.kind===`doc`?h.docName:``})]}),t[64]=u,t[65]=T,t[66]=h,t[67]=ne):ne=t[67];let re;t[68]!==x||t[69]!==B||t[70]!==V||t[71]!==H||t[72]!==te||t[73]!==ne?(re=(0,K.jsx)(gS,{open:B,onOpenChange:V,kind:`file`,initialDir:H,suggestedName:te,description:ne,onCreated:x}),t[68]=x,t[69]=B,t[70]=V,t[71]=H,t[72]=te,t[73]=ne,t[74]=re):re=t[74];let ae;return t[75]!==c||t[76]!==_||t[77]!==s||t[78]!==p||t[79]!==l?(ae=(0,K.jsx)(uC,{open:c,href:s,pages:p,onOpenChange:l,onSave:_}),t[75]=c,t[76]=_,t[77]=s,t[78]=p,t[79]=l,t[80]=ae):ae=t[80],(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(sS,{kind:`internal-link`,ariaLabel:`Link options`,onDeactivate:a,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-start gap-2 pr-8`,children:[(0,K.jsx)(`div`,{className:j(`mt-0.5 flex shrink-0`,S.className),children:S.icon}),k]}),z]}),re,ae]})}function fC(e,t,n){let r=ee(e,t);if(!r)return`unresolved`;if(r.kind===`external`)return`external`;if(r.kind===`anchor`)return`anchor`;if(n===null)return`loading`;let i=cS(r.docName,{pages:n.pages,folderPaths:n.folderPaths});return i.kind===`create`?`unresolved`:i.displayState}function pC(e,t,n){let r=e.attrs?.href;return typeof r!=`string`||r.length===0?null:{"data-resolution-state":fC(r,n,t)}}function mC(e){return(t,n)=>pC(t,n,e)}var hC=new r(`linkResolutionDecoration`);function gC(e,t,n,r,i){if(t.size===0)return null;let a=[];for(let e of t.values()){if(!n.has(e.markType))continue;let t=r(e,i);t!==null&&a.push(P.inline(e.from,e.to,t))}return a.length===0?null:c.create(e,a)}function _C(e){let t=new Set(e.markTypes),{computeAttrs:n}=e;return new be({key:hC,state:{init:()=>({version:0}),apply(e,t){let n=e.getMeta(hC);return n&&typeof n==`object`&&n.refresh?{version:t.version+1}:t}},props:{decorations(e){let r=DS.getState(e);if(!r)return null;let i=oe();return gC(e.doc,r.byId,t,n,i)}},view(e){let t=ke(()=>{e.dispatch(e.state.tr.setMeta(hC,{refresh:!0}))});return{destroy(){t()}}}})}var vC=new r(`markIdentityDecoration`),yC=`data-mark-id`;function bC(){return new be({key:vC,props:{decorations(e){let t=DS.getState(e);if(!t||t.byId.size===0)return null;let n=[];for(let e of t.byId.values())n.push(P.inline(e.from,e.to,{[yC]:e.id}));return c.create(e.doc,n)}}})}var xC=f.extend({addOptions(){return{...this.parent?.(),docName:``}},renderHTML({HTMLAttributes:e}){let t=typeof e.href==`string`?e.href:``;return[`span`,N(e,{"data-link":``,role:`link`,tabindex:`0`,"aria-label":t?`Link: ${t}`:`Link`,style:`touch-action: manipulation;`}),0]},addProseMirrorPlugins(){let e=this.options.docName??``;return[IS({editor:this.editor,markTypes:[`link`],renderPropPanel:({editor:t,nodeId:n,deactivate:r})=>(0,q.createElement)(dC,{editor:t,nodeId:n,sourceDocName:e,onClose:r}),handlePrimary:({editor:t,nodeId:n,newTab:r})=>{if(!r)return!1;let i=NS(t.state,n)?.attrs?.href;if(typeof i!=`string`||!i)return!1;let a=ee(i,e);return a?a.kind===`doc`?(nS({docName:a.docName,anchor:a.anchor}),!0):a.kind===`anchor`?(nS({docName:e,anchor:a.anchor}),!0):Xx(a.url)?(eS(a.url),!0):!1:!1}}),bC(),_C({markTypes:[`link`],computeAttrs:mC(e)})]}}),SC={warning:`bg-amber-100 text-amber-900 dark:bg-amber-900/40 dark:text-amber-200`,info:`bg-sky-100 text-sky-900 dark:bg-sky-900/40 dark:text-sky-200`,error:`bg-red-100 text-red-900 dark:bg-red-900/40 dark:text-red-200`},CC={warning:`alert`,error:`alert`,info:`note`};function wC(e){let t=(0,Yn.c)(11),{type:n,children:r}=e,i=CC[n]||`note`,a=SC[n]||`bg-muted text-foreground`,o;t[0]===a?o=t[1]:(o=j(`p-3 px-4 rounded-md`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=n.toUpperCase(),t[2]=n,t[3]=s);let c;t[4]===s?c=t[5]:(c=(0,K.jsx)(`strong`,{children:s}),t[4]=s,t[5]=c);let l;return t[6]!==r||t[7]!==i||t[8]!==o||t[9]!==c?(l=(0,K.jsxs)(`div`,{role:i,className:o,children:[c,`: `,r]}),t[6]=r,t[7]=i,t[8]=o,t[9]=c,t[10]=l):l=t[10],l}function TC(e){let t=e.match(/<(\w+)/);return t?t[1]:`Unknown`}function EC(e){let t=(0,Yn.c)(19),{editor:n,getPos:r,onDismiss:i}=e,a;if(t[0]!==n||t[1]!==r){let e=r();a=TC((typeof e==`number`?n.state.doc.nodeAt(e):null)?.attrs.content??``),t[0]=n,t[1]=r,t[2]=a}else a=t[2];let o=a,s;t[3]!==n||t[4]!==r||t[5]!==i?(s=function(){let e=r();if(typeof e!=`number`)return;let t=n.state.doc.nodeAt(e);t&&(n.chain().focus().deleteRange({from:e,to:e+t.nodeSize}).run(),i())},t[3]=n,t[4]=r,t[5]=i,t[6]=s):s=t[6];let c=s,l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Component`}),t[7]=l):l=t[7];let u;t[8]===o?u=t[9]:(u=(0,K.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs font-mono`,children:o}),t[8]=o,t[9]=u);let d;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,K.jsx)(`div`,{className:`flex-1`}),t[10]=d):d=t[10];let f;t[11]===c?f=t[12]:(f=(0,K.jsx)(ie,{variant:`outline`,size:`sm`,onClick:c,children:`Delete`}),t[11]=c,t[12]=f);let p;t[13]!==u||t[14]!==f?(p=(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pr-8`,children:[l,u,d,f]}),t[13]=u,t[14]=f,t[15]=p):p=t[15];let m;return t[16]!==i||t[17]!==p?(m=(0,K.jsx)(sS,{kind:`jsx-component`,ariaLabel:`Component properties`,onDeactivate:i,children:p}),t[16]=i,t[17]=p,t[18]=m):m=t[18],m}var DC=0;function OC(){return`jsx-${++DC}`}function kC(e){let t=e.match(/<(\w+)\s+type="([^"]*)">([\s\S]*?)<\/\1>/);return t?{component:t[1],type:t[2],children:t[3].trim()}:{component:`Unknown`,type:`info`,children:e.trim()}}function AC(e){let t=(0,Yn.c)(17),{node:n,editor:r,getPos:i}=e,a=n.attrs.content||``,o;t[0]===a?o=t[1]:(o=kC(a),t[0]=a,t[1]=o);let s=o,[c]=(0,q.useState)(OC),l=(0,q.useRef)(i),u,d;t[2]===i?(u=t[3],d=t[4]):(u=()=>{l.current=i},d=[i],t[2]=i,t[3]=u,t[4]=d),(0,q.useEffect)(u,d);let f,p;t[5]!==r||t[6]!==c?(f=()=>{let e=ES(r),t=()=>{let e=l.current();return typeof e==`number`?e:void 0};return e.register({type:`jsxComponent`,nodeId:c,getPos:t,controls:{propPanel:e=>(0,K.jsx)(EC,{editor:r,getPos:t,onDismiss:e.deactivate})}}),()=>{e.deregister(c)}},p=[r,c],t[5]=r,t[6]=c,t[7]=f,t[8]=p):(f=t[7],p=t[8]),(0,q.useEffect)(f,p);let m;t[9]!==a||t[10]!==s.children||t[11]!==s.component||t[12]!==s.type?(m=s.component===`Callout`?(0,K.jsx)(wC,{type:s.type,children:s.children}):(0,K.jsxs)(`div`,{className:`bg-muted dark:bg-muted/40 p-3 px-4 rounded-md font-mono text-[13px]`,children:[(0,K.jsxs)(`strong`,{children:[`<`,s.component,`>`]}),(0,K.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap`,children:a})]}),t[9]=a,t[10]=s.children,t[11]=s.component,t[12]=s.type,t[13]=m):m=t[13];let h;return t[14]!==c||t[15]!==m?(h=(0,K.jsx)(xs,{className:`jsx-component-wrapper`,contentEditable:!1,"data-node-id":c,children:m}),t[14]=c,t[15]=m,t[16]=h):h=t[16],h}var jC=F.extend({addNodeView(){return ks(AC)}}),MC=`raw-mdx-nav`,NC=0;function PC(){return`raw-mdx-${++NC}`}function FC(e){let t=e.doc??(typeof document<`u`?document:{createElement:null}),n=t.createElement(`div`);n.setAttribute(`data-raw-mdx-fallback`,``),n.setAttribute(`data-raw-badge`,`raw`),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`${e.reason??`Parse failed`} — click to edit`),n.classList.add(`raw-mdx-fallback-wrapper`),e.reason&&n.setAttribute(`data-reason`,e.reason);let r=t.createElement(`span`);r.classList.add(`raw-mdx-fallback-badge`),r.textContent=`raw`,r.setAttribute(`aria-hidden`,`true`),n.appendChild(r);let i=t.createElement(`pre`);return i.classList.add(`raw-mdx-fallback-content`),i.setAttribute(`contenteditable`,`false`),n.appendChild(i),{dom:n,contentDOM:i}}var IC=L.extend({addNodeView(){return({editor:e,node:t,getPos:n,HTMLAttributes:r})=>{let i=PC(),{dom:a,contentDOM:o}=FC({nodeId:i,reason:r.reason??t.attrs.reason}),s=()=>{let e=n();return typeof e==`number`?e:void 0},c=ES(e);return c.register({type:`rawMdxFallback`,nodeId:i,getPos:s,controls:{},handlePrimary:()=>{let t=s();if(typeof t!=`number`)return!1;let n=e.state.doc.nodeAt(t)?.attrs.originalSpan??{start:0,end:0};return window.dispatchEvent(new CustomEvent(MC,{detail:{offset:n.start}})),!0}}),{dom:a,contentDOM:o,ignoreMutation:()=>!0,destroy:()=>{c.deregister(i)}}}}}),LC=[{name:`heading1`,label:`Heading 1`,icon:Fn,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:1}).run(),aliases:[`h1`]},{name:`heading2`,label:`Heading 2`,icon:In,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:2}).run(),aliases:[`h2`]},{name:`heading3`,label:`Heading 3`,icon:Ln,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:3}).run(),aliases:[`h3`]},{name:`bulletList`,label:`Bullet List`,icon:Vn,category:`basic`,command:e=>e.chain().focus().toggleBulletList().run(),aliases:[`ul`,`unordered`]},{name:`orderedList`,label:`Ordered List`,icon:zn,category:`basic`,command:e=>e.chain().focus().toggleOrderedList().run(),aliases:[`ol`,`numbered`]},{name:`taskList`,label:`Task List`,icon:Bn,category:`basic`,command:e=>e.chain().focus().toggleTaskList().run(),aliases:[`todo`,`checklist`,`checkbox`]},{name:`blockquote`,label:`Quote`,icon:Gn,category:`basic`,command:e=>e.chain().focus().toggleBlockquote().run(),aliases:[`quote`]},{name:`codeBlock`,label:`Code Block`,icon:An,category:`basic`,command:e=>e.chain().focus().toggleCodeBlock().run(),aliases:[`code`,`fence`]},{name:`table`,label:`Table`,icon:Kn,category:`insert`,command:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),aliases:[`grid`]},{name:`separator`,label:`Separator`,icon:Un,category:`insert`,command:e=>e.chain().focus().setHorizontalRule().run(),aliases:[`hr`,`divider`,`rule`]},{name:`image`,label:`Image`,icon:Rn,category:`insert`,aliases:[`img`,`photo`],command:e=>{let t=document.createElement(`input`);t.type=`file`,t.accept=d.join(`,`),t.onchange=()=>{let n=t.files?.[0];if(n){let t=e.state.selection.from;Kb(n,e,t)}},t.click()}}];function RC(e,t){if(!t)return e;let n=t.toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)||e.aliases?.some(e=>e.toLowerCase().includes(n)))}function zC(e){let t=(0,Yn.c)(14),{items:n,selectedIndex:r,categoryLabels:i,onSelect:a}=e,o=(0,q.useRef)(null),s=(0,q.useId)(),c=r>=0&&r<n.length?`${s}-option-${r}`:void 0,l=BC,u,d;if(t[0]===r?(u=t[1],d=t[2]):(u=()=>{let e=o.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(r);t&&t.scrollIntoView({block:`nearest`})},d=[r],t[0]=r,t[1]=u,t[2]=d),(0,q.useEffect)(u,d),n.length===0){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(`div`,{ref:o,role:`status`,"aria-live":`polite`,className:`w-56 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:{maxHeight:`var(--suggestion-menu-max-height, 40vh)`},onMouseDown:l,children:`No results`}),t[3]=e):e=t[3],e}let f;if(t[4]!==c||t[5]!==i||t[6]!==n||t[7]!==s||t[8]!==a||t[9]!==r){let e=[],u=0,d=new Map;for(let t of n){d.set(t,u++);let n=e.find(e=>e.key===t.category);n?n.items.push(t):e.push({key:t.category,items:[t]})}let p=r>=0&&r<n.length?n[r]:null,m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[11]=m):m=t[11];let h=p?p.label:``,g;t[12]===h?g=t[13]:(g=(0,K.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:h}),t[12]=h,t[13]=g),f=(0,K.jsxs)(`div`,{ref:o,role:`listbox`,"aria-label":`Slash commands`,"aria-activedescendant":c,tabIndex:-1,onMouseDown:l,className:`w-56 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:m,children:[g,e.map(e=>(0,K.jsxs)(`div`,{role:`group`,"aria-labelledby":`${s}-group-${e.key}`,children:[(0,K.jsx)(`div`,{id:`${s}-group-${e.key}`,className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground`,children:i[e.key]??e.key}),e.items.map(e=>{let t=d.get(e)??0,n=t===r,i=e.icon;return(0,K.jsxs)(`button`,{id:`${s}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,K.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`div`,{className:`flex flex-col min-w-0`,children:(0,K.jsx)(`span`,{className:`truncate`,children:e.label})})]},e.name)})]},e.key))]}),t[4]=c,t[5]=i,t[6]=n,t[7]=s,t[8]=a,t[9]=r,t[10]=f}else f=t[10];return f}function BC(e){return e.preventDefault()}var VC=new r(`slashCommand`),HC=ze.create({name:`slashCommand`,addOptions(){return{itemsSources:[()=>LC],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[VS({editor:this.editor,pluginKey:VC,char:`/`,startOfLine:!1,items:({query:t})=>RC(e.options.itemsSources.flatMap(e=>{try{return e()}catch(e){return console.error(`[slash-command] item source threw an error`,e),[]}}),t),command:({editor:e,range:t,props:n})=>{try{e.chain().focus().deleteRange(t).run()}catch(e){console.error(`[slash-command] deleteRange failed for "${n.name}"`,e);return}try{n.command(e)}catch(e){console.error(`[slash-command] command "${n.name}" threw an error`,e)}},render:()=>{let t=null,n=null,r=0,i={popup:null,stopAutoUpdate:null},a=null,o=()=>{!t||!n||t.updateProps({items:n.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:n.command})};return{onStart(o){n=o,r=0;let s=qS(()=>n,`slash-command`);i.popup=s.popup,a=s.doPosition,t=new Ds(zC,{props:{items:o.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:o.command},editor:o.editor}),s.popup.appendChild(t.element),i.stopAutoUpdate=s.startAutoUpdate(),s.reveal()},onUpdate(e){n=e,r=Math.min(r,Math.max(0,e.items.length-1)),o(),a?.()},onKeyDown({event:e}){if(!n||n.items.length===0)return!1;let t=n.items;if(e.key===`ArrowDown`)return r=(r+1)%t.length,o(),!0;if(e.key===`ArrowUp`)return r=(r-1+t.length)%t.length,o(),!0;if(e.key===`Enter`||e.key===`Tab`){let e=t[r];return e&&n.command(e),!0}return e.key,!1},onExit(){JS(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}});function UC(e){let t=(0,Yn.c)(112),{open:n,target:r,alias:i,anchor:a,pages:o,onOpenChange:s,onSave:c}=e,[l,u]=(0,q.useState)(r),[d,f]=(0,q.useState)(i??``),[p,m]=(0,q.useState)(a??``),h=(0,q.useId)(),g=(0,q.useId)(),_=(0,q.useId)(),v=(0,q.useId)(),y;t[0]!==l||t[1]!==o?(y=qx(l,o),t[0]=l,t[1]=o,t[2]=y):y=t[2];let b=sC(l,y&&n),x,S;t[3]!==i||t[4]!==a||t[5]!==n||t[6]!==r?(x=()=>{n&&(u(r),f(i??``),m(a??``))},S=[n,r,i,a],t[3]=i,t[4]=a,t[5]=n,t[6]=r,t[7]=x,t[8]=S):(x=t[7],S=t[8]),(0,q.useEffect)(x,S);let C;t[9]!==d||t[10]!==p||t[11]!==l||t[12]!==s||t[13]!==c?(C=function(){let e=l.trim();e&&(c(e,d.trim()||null,p.trim()||null),s(!1))},t[9]=d,t[10]=p,t[11]=l,t[12]=s,t[13]=c,t[14]=C):C=t[14];let w=C,T;t[15]===w?T=t[16]:(T=function(e){e.key===`Enter`&&w()},t[15]=w,t[16]=T);let E=T,D,O,k,A,M,N,P,F,I,L,R,z,B,V,H,ee;if(t[17]!==g||t[18]!==p||t[19]!==l||t[20]!==E||t[21]!==v||t[22]!==b||t[23]!==s||t[24]!==n||t[25]!==h){let e=new Map,r=b?.map(t=>{let n=e.get(t.slug)??0;e.set(t.slug,n+1);let r=n===0?t.slug:`${t.slug}-${n}`;return{...t,reactKey:r}}),i=!!r?.length;k=Wa,R=n,z=s,O=Ga,t[42]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,K.jsx)(Ka,{className:`fixed inset-0 z-50 bg-black/40 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`}),t[42]=L):L=t[42],D=qa,M=`dialog-content`,N=``,P=`fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-lg border border-border bg-background p-6 shadow-xl data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,t[43]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,K.jsx)(Ja,{className:`mb-1 text-base font-semibold`,children:`Edit wiki link`}),I=(0,K.jsx)(Ya,{className:`mb-4 text-sm text-muted-foreground`,children:`Modify the link target, anchor, and display label.`}),t[43]=F,t[44]=I):(F=t[43],I=t[44]),ee=`mb-4 space-y-6`;let a;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,K.jsx)(`span`,{className:`text-red-500`,children:`*`}),t[45]=a):a=t[45];let o;t[46]===h?o=t[47]:(o=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:h,children:[`Page `,a]}),t[46]=h,t[47]=o);let c;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>u(e.target.value),t[48]=c):c=t[48];let d;t[49]!==l||t[50]!==E||t[51]!==h?(d=(0,K.jsx)(uS,{id:h,value:l,onChange:c,placeholder:`page-name`,autoFocus:!0,"aria-required":`true`,onKeyDown:E}),t[49]=l,t[50]=E,t[51]=h,t[52]=d):d=t[52],t[53]!==o||t[54]!==d?(A=(0,K.jsxs)(`div`,{children:[o,d]}),t[53]=o,t[54]=d,t[55]=A):A=t[55];let f;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional heading anchor)`}),t[56]=f):f=t[56],t[57]===g?B=t[58]:(B=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:g,children:[`Section`,` `,f]}),t[57]=g,t[58]=B);let _;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>m(e.target.value),t[59]=_):_=t[59],t[60]!==g||t[61]!==p||t[62]!==E?(V=(0,K.jsx)(uS,{id:g,value:p,onChange:_,placeholder:`heading-slug`,onKeyDown:E}),t[60]=g,t[61]=p,t[62]=E,t[63]=V):V=t[63],H=i&&(0,K.jsx)(`div`,{role:`listbox`,id:v,"aria-label":`Heading anchors`,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:r.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":p===e.slug,className:j(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,p===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>m(p===e.slug?``:e.slug),children:[(0,K.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,K.jsx)(`span`,{className:`truncate`,children:e.text})]},e.reactKey))}),t[17]=g,t[18]=p,t[19]=l,t[20]=E,t[21]=v,t[22]=b,t[23]=s,t[24]=n,t[25]=h,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=M,t[31]=N,t[32]=P,t[33]=F,t[34]=I,t[35]=L,t[36]=R,t[37]=z,t[38]=B,t[39]=V,t[40]=H,t[41]=ee}else D=t[26],O=t[27],k=t[28],A=t[29],M=t[30],N=t[31],P=t[32],F=t[33],I=t[34],L=t[35],R=t[36],z=t[37],B=t[38],V=t[39],H=t[40],ee=t[41];let te;t[64]!==B||t[65]!==V||t[66]!==H?(te=(0,K.jsxs)(`div`,{children:[B,V,H]}),t[64]=B,t[65]=V,t[66]=H,t[67]=te):te=t[67];let ne;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional display text)`}),t[68]=ne):ne=t[68];let re;t[69]===_?re=t[70]:(re=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:_,children:[`Label`,` `,ne]}),t[69]=_,t[70]=re);let ae;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>f(e.target.value),t[71]=ae):ae=t[71];let U;t[72]!==_||t[73]!==d||t[74]!==E?(U=(0,K.jsx)(uS,{id:_,value:d,onChange:ae,placeholder:`Custom display text`,onKeyDown:E}),t[72]=_,t[73]=d,t[74]=E,t[75]=U):U=t[75];let oe;t[76]!==re||t[77]!==U?(oe=(0,K.jsxs)(`div`,{children:[re,U]}),t[76]=re,t[77]=U,t[78]=oe):oe=t[78];let se;t[79]!==A||t[80]!==te||t[81]!==oe||t[82]!==ee?(se=(0,K.jsxs)(`div`,{className:ee,children:[A,te,oe]}),t[79]=A,t[80]=te,t[81]=oe,t[82]=ee,t[83]=se):se=t[83];let ce;t[84]===s?ce=t[85]:(ce=(0,K.jsx)(ie,{variant:`outline`,onClick:()=>s(!1),children:`Cancel`}),t[84]=s,t[85]=ce);let le;t[86]===l?le=t[87]:(le=l.trim(),t[86]=l,t[87]=le);let ue=!le,de;t[88]!==w||t[89]!==ue?(de=(0,K.jsx)(ie,{onClick:w,disabled:ue,children:`Save`}),t[88]=w,t[89]=ue,t[90]=de):de=t[90];let fe;t[91]!==ce||t[92]!==de?(fe=(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[ce,de]}),t[91]=ce,t[92]=de,t[93]=fe):fe=t[93];let pe;t[94]!==D||t[95]!==M||t[96]!==N||t[97]!==P||t[98]!==F||t[99]!==I||t[100]!==se||t[101]!==fe?(pe=(0,K.jsxs)(D,{"data-slot":M,"data-ok-layer-spawned":N,className:P,children:[F,I,se,fe]}),t[94]=D,t[95]=M,t[96]=N,t[97]=P,t[98]=F,t[99]=I,t[100]=se,t[101]=fe,t[102]=pe):pe=t[102];let me;t[103]!==O||t[104]!==L||t[105]!==pe?(me=(0,K.jsxs)(O,{children:[L,pe]}),t[103]=O,t[104]=L,t[105]=pe,t[106]=me):me=t[106];let he;return t[107]!==k||t[108]!==R||t[109]!==z||t[110]!==me?(he=(0,K.jsx)(k,{open:R,onOpenChange:z,children:me}),t[107]=k,t[108]=R,t[109]=z,t[110]=me,t[111]=he):he=t[111],he}function WC(e){let t=(0,Yn.c)(112),{editor:n,getPos:r,onClose:i}=e,a=r(),o=a==null?null:n.state.doc.nodeAt(a),s=String(o?.attrs.target??``),c=A(o?.attrs.alias),l=A(o?.attrs.anchor),u=v({target:s,alias:c,anchor:l}),{folderPaths:d,pages:f,loading:p}=xe(),m=Be(s,l),h=m?.kind===`external`?m:null,g=cS(s,{pages:f,folderPaths:d,fallbackTargets:Kx(s)}),[_,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(null),S=lS(g);if(!o)return null;let C;t[0]!==n||t[1]!==r?(C=function(e,t,i){let a=r();a!=null&&n.view.dispatch(n.state.tr.setNodeMarkup(a,void 0,{...n.state.doc.nodeAt(a)?.attrs,target:e,alias:t,anchor:i}))},t[0]=n,t[1]=r,t[2]=C):C=t[2];let w=C,T;t[3]!==n||t[4]!==r||t[5]!==i?(T=function(){let e=r();if(e==null)return;let t=n.state.doc.nodeAt(e);t&&(n.view.dispatch(n.state.tr.delete(e,e+t.nodeSize)),i())},t[3]=n,t[4]=r,t[5]=i,t[6]=T):T=t[6];let E=T,D;t[7]!==l||t[8]!==h||t[9]!==g||t[10]!==x?(D=function(e){if(h){Xx(h.url)?window.open(h.url,`_blank`,`noopener,noreferrer`):console.warn(`[safe-nav] blocked non-safe scheme:`,h.url);return}if(g.kind===`create`){x(`missing`);return}let t=g.hashDocName;if(e.newTab){nS({docName:t,anchor:l});return}if(l){let e=window.location.hash.match(/^#\/([^?#/]+)/);if((e?decodeURIComponent(e[1]):null)===t){let e=document.getElementById(l);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})}window.location.hash=`#/${t}?anchor=${encodeURIComponent(l)}`;return}window.location.hash=`#/${t}`},t[7]=l,t[8]=h,t[9]=g,t[10]=x,t[11]=D):D=t[11];let O=D,k;t[12]!==c||t[13]!==b||t[14]!==n||t[15]!==r||t[16]!==u||t[17]!==s?(k=function(e){if(b===`missing`&&e!==s){let t=r();if(t==null)return;n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...n.state.doc.nodeAt(t)?.attrs,target:e,alias:c??u}))}},t[12]=c,t[13]=b,t[14]=n,t[15]=r,t[16]=u,t[17]=s,t[18]=k):k=t[18];let M=k,N=!h&&!p&&g.kind===`navigate`&&g.displayState===`resolved`,P=!h&&!p&&g.kind===`navigate`&&g.displayState===`folder`,F=!h&&!p&&g.kind===`create`,I,L,R,z,B,V,H,ee,te;if(t[19]!==h||t[20]!==P||t[21]!==N||t[22]!==F||t[23]!==p||t[24]!==i){if(p){let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Hn,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[34]=e):e=t[34],L={icon:e,text:`Loading…`,className:`text-muted-foreground`}}else if(h){let e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(jn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[35]=e):e=t[35],L={icon:e,text:`External wiki link`,className:`text-foreground`}}else if(P){let e;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Pn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[36]=e):e=t[36],L={icon:e,text:`Folder (no index)`,className:`text-foreground`}}else if(F){let e;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(kn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[37]=e):e=t[37],L={icon:e,text:`Page not found`,className:`text-red-700 dark:text-red-300`}}else if(N){let e;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Nn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[38]=e):e=t[38],L={icon:e,text:`Wiki link`,className:`text-foreground`}}else{let e;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(kn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[39]=e):e=t[39],L={icon:e,text:`Unrecognized wiki link`,className:`text-muted-foreground`}}I=sS,te=`wiki-link`,R=`Wiki link options`,z=i,H=`mb-2 flex items-start gap-2 pr-8`,ee=(0,K.jsx)(`div`,{className:j(`mt-0.5 flex shrink-0`,L.className),children:L.icon}),V=`flex-1 min-w-0`,B=j(`text-sm font-medium`,L.className),t[19]=h,t[20]=P,t[21]=N,t[22]=F,t[23]=p,t[24]=i,t[25]=I,t[26]=L,t[27]=R,t[28]=z,t[29]=B,t[30]=V,t[31]=H,t[32]=ee,t[33]=te}else I=t[25],L=t[26],R=t[27],z=t[28],B=t[29],V=t[30],H=t[31],ee=t[32],te=t[33];let ne;t[40]!==L.text||t[41]!==B?(ne=(0,K.jsx)(`div`,{className:B,children:L.text}),t[40]=L.text,t[41]=B,t[42]=ne):ne=t[42];let re=h?h.url:`[[${s}${l?`#${l}`:``}]]`,ae=h?h.url:`[[${s}${l?`#${l}`:``}]]`,U;t[43]!==re||t[44]!==ae?(U=(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,title:re,children:ae}),t[43]=re,t[44]=ae,t[45]=U):U=t[45];let oe;t[46]!==ne||t[47]!==U||t[48]!==V?(oe=(0,K.jsxs)(`div`,{className:V,children:[ne,U]}),t[46]=ne,t[47]=U,t[48]=V,t[49]=oe):oe=t[49];let se;t[50]!==oe||t[51]!==H||t[52]!==ee?(se=(0,K.jsxs)(`div`,{className:H,children:[ee,oe]}),t[50]=oe,t[51]=H,t[52]=ee,t[53]=se):se=t[53];let ce;t[54]!==h||t[55]!==O||t[56]!==F||t[57]!==i?(ce=F?null:(0,K.jsx)(ie,{size:`sm`,variant:`default`,onClick:()=>{O({}),i()},children:h?`Open in new tab`:`Open`}),t[54]=h,t[55]=O,t[56]=F,t[57]=i,t[58]=ce):ce=t[58];let le;t[59]!==F||t[60]!==x?(le=F?(0,K.jsx)(ie,{size:`sm`,variant:`default`,onClick:()=>x(`missing`),children:`Create page`}):null,t[59]=F,t[60]=x,t[61]=le):le=t[61];let ue;t[62]!==S||t[63]!==P||t[64]!==x?(ue=P&&S?(0,K.jsxs)(ie,{size:`sm`,variant:`outline`,onClick:()=>x(`folder-index`),children:[(0,K.jsx)(Mn,{className:`size-3.5`,"aria-hidden":`true`}),`Create index`]}):null,t[62]=S,t[63]=P,t[64]=x,t[65]=ue):ue=t[65];let de;t[66]===y?de=t[67]:(de=()=>y(!0),t[66]=y,t[67]=de);let fe;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,K.jsx)(Wn,{className:`size-3.5`,"aria-hidden":`true`}),t[68]=fe):fe=t[68];let pe;t[69]===de?pe=t[70]:(pe=(0,K.jsxs)(ie,{size:`sm`,variant:`outline`,onClick:de,children:[fe,`Edit`]}),t[69]=de,t[70]=pe);let me;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,K.jsx)(qn,{className:`size-3.5`,"aria-hidden":`true`}),t[71]=me):me=t[71];let he;t[72]===E?he=t[73]:(he=(0,K.jsxs)(ie,{size:`sm`,variant:`outline`,className:`text-red-700 hover:bg-red-50 hover:text-red-800 dark:text-red-300 dark:hover:bg-red-100/10 dark:hover:text-red-200`,onClick:E,children:[me,`Remove`]}),t[72]=E,t[73]=he);let ge;t[74]!==ce||t[75]!==le||t[76]!==ue||t[77]!==pe||t[78]!==he?(ge=(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[ce,le,ue,pe,he]}),t[74]=ce,t[75]=le,t[76]=ue,t[77]=pe,t[78]=he,t[79]=ge):ge=t[79];let _e;t[80]!==I||t[81]!==R||t[82]!==z||t[83]!==se||t[84]!==ge||t[85]!==te?(_e=(0,K.jsxs)(I,{kind:te,ariaLabel:R,onDeactivate:z,children:[se,ge]}),t[80]=I,t[81]=R,t[82]=z,t[83]=se,t[84]=ge,t[85]=te,t[86]=_e):_e=t[86];let ve=b!==null,ye;t[87]===x?ye=t[88]:(ye=e=>{e||x(null)},t[87]=x,t[88]=ye);let be=b===`folder-index`&&S?S.initialDir:g.kind===`create`?g.initialDir:``,Se=b===`folder-index`&&S?S.suggestedName:g.kind===`create`?g.suggestedName:void 0,Ce;t[89]!==b||t[90]!==S||t[91]!==s?(Ce=b===`folder-index`&&S?(0,K.jsxs)(K.Fragment,{children:[`Create an index note for`,` `,(0,K.jsxs)(`span`,{className:`font-medium text-foreground`,children:[S.initialDir,`/`]})]}):(0,K.jsxs)(K.Fragment,{children:[`Create a page for `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:s})]}),t[89]=b,t[90]=S,t[91]=s,t[92]=Ce):Ce=t[92];let we;t[93]!==M||t[94]!==ve||t[95]!==ye||t[96]!==be||t[97]!==Se||t[98]!==Ce?(we=(0,K.jsx)(gS,{open:ve,onOpenChange:ye,kind:`file`,initialDir:be,suggestedName:Se,description:Ce,onCreated:M}),t[93]=M,t[94]=ve,t[95]=ye,t[96]=be,t[97]=Se,t[98]=Ce,t[99]=we):we=t[99];let Te;t[100]!==c||t[101]!==l||t[102]!==_||t[103]!==w||t[104]!==f||t[105]!==y||t[106]!==s?(Te=(0,K.jsx)(UC,{open:_,target:s,alias:c,anchor:l,pages:f,onOpenChange:y,onSave:w}),t[100]=c,t[101]=l,t[102]=_,t[103]=w,t[104]=f,t[105]=y,t[106]=s,t[107]=Te):Te=t[107];let Ee;return t[108]!==_e||t[109]!==we||t[110]!==Te?(Ee=(0,K.jsxs)(K.Fragment,{children:[_e,we,Te]}),t[108]=_e,t[109]=we,t[110]=Te,t[111]=Ee):Ee=t[111],Ee}var GC=0;function KC(){return`wiki-link-${++GC}`}function qC(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`span`);n.setAttribute(`data-wiki-link`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Wiki link: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-chip`),n.style.touchAction=`manipulation`;let r=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,i=t.createTextNode(r);return n.appendChild(i),{dom:n}}var JC=m.extend({priority:200,addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=KC(),{dom:i}=qC({nodeId:r,target:String(t.attrs.target??``),alias:t.attrs.alias==null?null:String(t.attrs.alias),anchor:t.attrs.anchor==null?null:String(t.attrs.anchor)}),a=t,o=()=>{let e=n();return typeof e==`number`?e:void 0},s=ES(e);return s.register({type:`wikiLink`,nodeId:r,getPos:o,controls:{propPanel:t=>(0,q.createElement)(WC,{editor:e,getPos:o,onClose:t.deactivate})},handlePrimary:({newTab:e})=>{if(!e)return!1;let t=a.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=Be(n,typeof t.anchor==`string`?t.anchor:null);return r?r.kind===`doc`?(nS({docName:r.docName,anchor:r.anchor}),!0):Xx(r.url)?(eS(r.url),!0):!1:!1}}),{dom:i,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLink`)return!1;a=e;let t=String(e.attrs.target??``),n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor);return i.setAttribute(`data-target`,t),i.setAttribute(`data-alias`,n??``),i.setAttribute(`data-anchor`,r??``),i.setAttribute(`aria-label`,`Wiki link: ${t}${r?`#${r}`:``}`),i.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{s.deregister(r)}}}},addKeyboardShortcuts(){return{Backspace:()=>{if(YS.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(YS.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[oC(this.editor)]}}),YC=[...l.map(e=>e.name===`jsxComponent`?jC:e.name===`rawMdxFallback`?IC:e.name===`wikiLink`?JC:e.name===`link`?xC:e),HC,Bb.configure({allowedMimeTypes:[...d],onDrop(e,t,n){for(let r of t)Kb(r,e,n)},onPaste(e,t,n){for(let n of t)Kb(n,e,e.state.selection.from)}}),Jx,Wx,Zb];function XC(e){return e===g}var ZC=0;function QC(){return ZC}function $C(){ZC=Date.now()}function ew(e){let{xmlFragment:t,ytext:n}=e,r=(e,t)=>{},i=(e,t)=>{};return t.observeDeep(r),n.observe(i),()=>{t.unobserveDeep(r),n.unobserve(i)}}var tw=3e4,nw=class extends Error{docName;elapsedMs;constructor(e,t){super(`Sync timed out for "${e}" after ${t}ms`),this.name=`SyncTimeoutError`,this.docName=e,this.elapsedMs=t}},rw=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},iw=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},aw=class extends Error{docName;cause;constructor(e,t){let n=t instanceof Error?t.message:String(t??`unknown`);super(`Bridge setup failed for "${e}": ${n}`),this.name=`BridgeSetupError`,this.docName=e,this.cause=t}},ow=new Map,sw=!1;function cw(){for(let e of ow.values())if(!e.settled)return!0;return!1}function lw(){typeof document>`u`||document.visibilityState===`visible`&&uw(Date.now())}function uw(e){let t=[];for(let[n,r]of ow){if(r.settled)continue;let i=e-r.createdAt;if(i<3e4)continue;r.settled=!0;let a=new nw(n,i);mw(r),r.reject(a),t.push({docName:n,elapsedMs:i})}if(t.length>0){let e=t.map(e=>`${e.docName} (${e.elapsedMs}ms)`).join(`, `);console.warn(`[syncPromise] reaped ${t.length} timed-out ${t.length===1?`entry`:`entries`} on visibility restore (tab-sleep recovered): ${e}`)}return cw()||fw(),t.length}function dw(){sw||typeof document>`u`||(document.addEventListener(`visibilitychange`,lw),sw=!0)}function fw(){sw&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,lw),sw=!1))}var pw=new Map;function mw(e){e.detached||(e.detached=!0,e.timeoutHandle!==null&&clearTimeout(e.timeoutHandle),e.provider.off(`synced`,e.onSynced),e.provider.off(`close`,e.onClose))}function hw(e,t){let n=ow.get(e);if(n)return n.promise;let r=pw.get(e);if(r!==void 0){pw.delete(e);let n=r===`timeout`?new nw(e,0):new rw(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),J(`ok/sync/create`,{docName:e,warm:!1,armed:r}),J(`ok/sync/reject`,{docName:e,reason:`armed-${r}`});let i=_w(n);return ow.set(e,vw(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`),J(`ok/sync/create`,{docName:e,warm:!0}),J(`ok/sync/resolve`,{docName:e,elapsedMs:0,warm:!0});let n=Promise.resolve();return ow.set(e,gw(n,t)),n}let i=Date.now(),a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=()=>{let t=ow.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt;console.log(`[syncPromise] ${e} resolved in ${n}ms`),J(`ok/sync/resolve`,{docName:e,elapsedMs:n,warm:!1}),mw(t),cw()||fw(),t.resolve()},l=t=>{let n=ow.get(e);if(!n||n.settled)return;n.settled=!0;let r=new rw(e);console.warn(`[syncPromise] ${e} rejected: ${r.message}`),J(`ok/sync/reject`,{docName:e,reason:`pre-sync-disconnect`}),mw(n),cw()||fw(),n.reject(r)},u=setTimeout(()=>{let t=ow.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new nw(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`),J(`ok/sync/reject`,{docName:e,reason:`timeout`,elapsedMs:n}),mw(t),cw()||fw(),t.reject(r)},tw),d={promise:s,resolve:a,reject:o,createdAt:i,timeoutHandle:u,provider:t,onSynced:c,onClose:l,settled:!1,detached:!1};return ow.set(e,d),t.on(`synced`,c),t.on(`close`,l),dw(),J(`ok/sync/create`,{docName:e,warm:!1}),s}function gw(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,detached:!0}}function _w(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function vw(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,detached:!0}}function yw(e){let t=ow.get(e);t&&(t.settled=!0,mw(t),ow.delete(e),cw()||fw())}function bw(e,t){let n=ow.get(e);return!n||n.settled?!1:(n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),mw(n),cw()||fw(),n.reject(t),!0)}var xw=de(YC),Sw=4e3,Cw=5e3,ww=class{entries=new Map;lruOrder=[];activeDocName=null;maxSize;wsUrl;recycleDebounceMs;onChange=null;tabIdentity=null;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n??Sw}setTabIdentity(e){this.tabIdentity=e}setOnChange(e){this.onChange=e}notify(){this.onChange?.()}touch(e){let t=this.lruOrder.indexOf(e);t!==-1&&this.lruOrder.splice(t,1),this.lruOrder.push(e)}open(e){if(XC(e))return null;let t=this.entries.get(e);if(t)return t.lastAccessedAt=Date.now(),this.touch(e),this.notify(),t;this.entries.size>=this.maxSize&&this.evictLru();let n=new gb({url:this.wsUrl,name:e,forceSyncInterval:Cw,...this.tabIdentity===null?{}:{token:JSON.stringify(this.tabIdentity)}}),r={provider:n,observerCleanup:null,syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),hasSynced:!1,tearingDown:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1};return n.on(`status`,({status:t})=>{r.tearingDown||this.entries.get(e)!==r||t===`disconnected`&&(r.syncState=`disconnected`,this.notify())}),n.on(`synced`,()=>{if(!(r.tearingDown||this.entries.get(e)!==r)&&(r.syncState=`synced`,r.hasSynced=!0,r.pendingRecycleTimer&&=(clearTimeout(r.pendingRecycleTimer),null),this.notify(),!r.observerCleanup))try{let t=n.document,i=new _e({extensions:YC});r.observerCleanup=ew({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:i,schema:xw,onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),r.bridgeSetupFailed=!0,bw(e,new aw(e,t))}}),n.on(`disconnect`,()=>{r.tearingDown||this.entries.get(e)!==r||(r.syncState=`disconnected`,this.notify(),r.hasSynced&&n.unsyncedChanges===0&&!r.pendingRecycleTimer&&(r.pendingRecycleTimer=setTimeout(()=>{r.pendingRecycleTimer=null,!(r.tearingDown||this.entries.get(e)!==r)&&this.recycleDisconnectedEntry(e)},this.recycleDebounceMs)))}),this.entries.set(e,r),this.touch(e),this.notify(),r}prewarm(e){if(XC(e))return null;let t=this.entries.get(e);if(t)return t;let n=this.open(e);if(!n)return null;let r=this.lruOrder.indexOf(e);return r!==-1&&(this.lruOrder.splice(r,1),this.lruOrder.unshift(e)),n}close(e){let t=this.entries.get(e);t&&(this.destroyEntry(t),this.entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),this.activeDocName===e&&(this.activeDocName=null),this.notify())}setActive(e){let t=this.entries.get(e);if(!t)throw Error(`[ProviderPool] Cannot setActive — "${e}" is not open`);t.lastAccessedAt=Date.now(),this.touch(e),this.activeDocName=e,this.notify()}clearActive(){this.activeDocName!==null&&(this.activeDocName=null,this.notify())}getActive(){return this.activeDocName?this.entries.get(this.activeDocName)??null:null}getActiveDocName(){return this.activeDocName}has(e){return this.entries.has(e)}recycle(e){this.recycleDisconnectedEntry(e)}dispose(){for(let e of this.entries.values())this.destroyEntry(e);this.entries.clear(),this.lruOrder=[],this.activeDocName=null,this.onChange=null}evictLru(){for(let e of this.lruOrder)if(e!==this.activeDocName){J(`ok/pool/evict-lru`,{docName:e}),this.close(e);return}}destroyEntry(e){e.tearingDown=!0,e.pendingRecycleTimer&&=(clearTimeout(e.pendingRecycleTimer),null),yw(e.docName),Db(e.docName),Ab(e.docName),e.observerCleanup?.(),e.observerCleanup=null;try{e.provider.destroy()}catch(t){console.warn(`[ProviderPool] Provider destroy failed for ${e.docName}:`,t)}}recycleDisconnectedEntry(e){let t=this.entries.get(e);if(!t||t.tearingDown)return;let n=this.activeDocName===e;if(J(`ok/pool/recycle-disconnected`,{docName:e,wasActive:n}),this.destroyEntry(t),this.entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),n){this.open(e)&&this.setActive(e);return}this.notify()}},Tw=crypto.randomUUID(),Ew=`ok-pin-v1`,Dw=!1;function Ow(e){Dw||(Dw=!0,console.warn(`[DocumentContext] localStorage unavailable — pinned doc will not persist across tabs/reloads.`,e))}function kw(){if(typeof window>`u`)return null;try{return window.localStorage.getItem(Ew)}catch(e){return Ow(e),null}}function Aw(e){if(!(typeof window>`u`))try{e===null?window.localStorage.removeItem(Ew):window.localStorage.setItem(Ew,e)}catch(e){Ow(e)}}var jw=(0,q.createContext)(null),Mw=null;function Nw(e){return Mw||=new ww(10,e),Mw}var Pw={activeDocName:null,activeProvider:null,syncState:`connecting`,poolEntries:[]};function Fw(e){let t=e.getActive(),n=[];for(let t of e.entries.values())n.push({docName:t.docName,provider:t.provider,lastAccessedAt:t.lastAccessedAt});return n.sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt),{activeDocName:e.getActiveDocName(),activeProvider:t?.provider??null,syncState:t?.syncState??`connecting`,poolEntries:n}}function Iw(e){let t=(0,Yn.c)(43),{children:n}=e,[r,i]=(0,q.useState)(Pw),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(null),{collabUrl:d,terminal:f,lastError:p,retry:m}=k_(),h,g;t[0]===d?(h=t[1],g=t[2]):(h=()=>{if(d===null)return;let e=Nw(d);i(Fw(e)),e.setOnChange(()=>i(Fw(e)));let t=kw();return t!==null&&c(t),fetch(`/api/principal`).then(Rw).then(t=>{t&&typeof t.id==`string`&&e.setTabIdentity({principalId:t.id,tabSessionId:Tw})}).catch(Lw),()=>{e.setOnChange(null)}},g=[d],t[0]=d,t[1]=h,t[2]=g),(0,q.useEffect)(h,g);let _,v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{},v=[],t[3]=_,t[4]=v):(_=t[3],v=t[4]),(0,q.useEffect)(_,v);let y;t[5]===d?y=t[6]:(y=e=>{if(J(`ok/nav/open-document`,{docName:e,transition:!1}),d===null)return;let t=Nw(d);t.open(e)&&(t.setActive(e),o({kind:`doc`,target:e,docName:e}))},t[5]=d,t[6]=y);let b=y,x;t[7]===b?x=t[8]:(x=e=>{J(`ok/nav/open-document`,{docName:e,transition:!1}),b(e)},t[7]=b,t[8]=x);let S=x,C;t[9]===d?C=t[10]:(C=e=>{if(d===null)return;let t=Nw(d),n=O(e);n?(t.open(n),t.setActive(n)):t.clearActive(),o(e)},t[9]=d,t[10]=C);let w=C,T;t[11]===w?T=t[12]:(T=e=>{J(`ok/nav/open-target`,{docName:O(e),kind:e.kind,transition:!1}),w(e)},t[11]=w,t[12]=T);let E=T,D,k,A,j;t[13]===d?(D=t[14],k=t[15],A=t[16],j=t[17]):(j=()=>{if(d===null){o(null);return}Nw(d).clearActive(),o(null)},D=e=>{d!==null&&(Nw(d).close(e),o(t=>t&&(O(t)===e?null:t)))},k=e=>{d!==null&&Nw(d).recycle(e)},A=e=>{d!==null&&Nw(d).prewarm(e)},t[13]=d,t[14]=D,t[15]=k,t[16]=A,t[17]=j);let M,N;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{c(e),Aw(e)},N=()=>{c(null),Aw(null)},t[18]=M,t[19]=N):(M=t[18],N=t[19]);let P;t[20]!==a||t[21]!==p||t[22]!==f||t[23]!==d||t[24]!==b||t[25]!==S||t[26]!==w||t[27]!==E||t[28]!==s||t[29]!==m||t[30]!==r.activeDocName||t[31]!==r.activeProvider||t[32]!==r.poolEntries||t[33]!==r.syncState||t[34]!==l||t[35]!==D||t[36]!==k||t[37]!==A||t[38]!==j?(P={activeTarget:a,activeDocName:r.activeDocName,activeProvider:r.activeProvider,syncState:r.syncState,poolEntries:r.poolEntries,openDocument:b,openDocumentTransition:S,openTarget:w,openTargetTransition:E,clearTarget:j,closeDocument:D,recycleDocument:k,prewarm:A,pinnedDoc:s,pin:M,unpin:N,systemProvider:l,setSystemProvider:u,collabUrl:d,collabTerminal:f,collabLastError:p,retryCollab:m},t[20]=a,t[21]=p,t[22]=f,t[23]=d,t[24]=b,t[25]=S,t[26]=w,t[27]=E,t[28]=s,t[29]=m,t[30]=r.activeDocName,t[31]=r.activeProvider,t[32]=r.poolEntries,t[33]=r.syncState,t[34]=l,t[35]=D,t[36]=k,t[37]=A,t[38]=j,t[39]=P):P=t[39];let F=P,I;return t[40]!==n||t[41]!==F?(I=(0,K.jsx)(jw,{value:F,children:n}),t[40]=n,t[41]=F,t[42]=I):I=t[42],I}function Lw(){}function Rw(e){return e.ok?e.json():null}function zw(){let e=(0,q.use)(jw);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function Bw(){let e=(0,Yn.c)(3),{openDocumentTransition:t,openTargetTransition:n}=zw(),r;return e[0]!==t||e[1]!==n?(r={openDocumentTransition:t,openTargetTransition:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}var Vw=new Map;function Hw(e,t){Vw.set(e,t)}function Uw(e){let t=Vw.get(e)??null;return Vw.delete(e),t}function Ww(e){Vw.delete(e)}var Gw=class e{static create(t,n,r,i,a){return new e(t,n,r,i+(i<<8)+t+(n<<4)|0,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[Je.contextHash,r]]}addChild(e,t){e.prop(Je.contextHash)!=this.hash&&(e=new nt(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new nt(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new nt(rt.none,e,t,n,this.hashProp)})}},Q;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(Q||={});var Kw=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},qw=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return Zw(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function Jw(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==Q.OrderedList?iT:rT)(n,t,!1);return r>0&&(e.type!=Q.BulletList||tT(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var Yw={[Q.Blockquote](e,t,n){return n.next==62?(n.markers.push(MT(Q.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Xw(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0):!1},[Q.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Q.OrderedList]:Jw,[Q.BulletList]:Jw,[Q.Document](){return!0}};function Xw(e){return e==32||e==9||e==10||e==13}function Zw(e,t=0){for(;t<e.length&&Xw(e.charCodeAt(t));)t++;return t}function Qw(e,t,n){for(;t>n&&Xw(e.charCodeAt(t-1));)t--;return t}function $w(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function eT(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function tT(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!Xw(n))return-1}return n&&e.next==45&&oT(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(vT.SetextHeading)>-1||r<3?-1:1}function nT(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function rT(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Xw(e.text.charCodeAt(e.pos+1)))&&(!n||nT(t,Q.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function iT(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!Xw(e.text.charCodeAt(r+1))||n&&!nT(t,Q.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function aT(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function oT(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&Xw(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var sT=/^[ \t]*$/,cT=/-->/,lT=/\?>/,uT=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,cT],[/^\s*<\?/,lT],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,sT],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,sT]];function dT(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=uT.length-+!!n;e<t;e++)if(uT[e][0].test(r))return e;return-1}function fT(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function pT(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Q.CodeText?e[r].to=n:e.push(MT(Q.CodeText,t,n))}var mT={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(pT(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){pT(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==Q.CodeText?pT(o,e.from,e.to):o.push(e);s=[]}pT(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&pT(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=Q.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Q.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=$w(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=Qw(t.text,t.text.length,o),c=[MT(Q.CodeMark,r,r+a)];o<s&&c.push(MT(Q.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&pT(c,e.lineStart-1,e.lineStart),c.push(MT(Q.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}else{o=!0,n||(pT(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(pT(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(Q.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=eT(t);return n<0?!1:(e.startContext(Q.Blockquote,t.pos),e.addNode(Q.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(tT(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Q.HorizontalRule,n),!0},BulletList(e,t){let n=rT(t,e,!1);if(n<0)return!1;e.block.type!=Q.BulletList&&e.startContext(Q.BulletList,t.basePos,t.next);let r=fT(t,t.pos+1);return e.startContext(Q.ListItem,t.basePos,r-t.baseIndent),e.addNode(Q.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=iT(t,e,!1);if(n<0)return!1;e.block.type!=Q.OrderedList&&e.startContext(Q.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=fT(t,t.pos+n);return e.startContext(Q.ListItem,t.basePos,r-t.baseIndent),e.addNode(Q.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=aT(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=Qw(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!Xw(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Q.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Q.HeaderMark,o-r,a-r);let c=s.finish(Q.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=dT(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=uT[n][1],a=[],o=i!=sT;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==cT?Q.CommentBlock:i==lT?Q.ProcessingInstructionBlock:Q.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},hT=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
50
50
  `+t.scrub(),i=this.advance(r);return i>-1&&i<r.length?this.complete(e,n,i):!1}finish(e,t){return(this.stage==2||this.stage==3)&&Zw(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,n){return e.addLeafElement(t,MT(Q.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;)if(this.stage==-1)return-1;else if(this.stage==0){if(!this.nextStage(WT(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(MT(Q.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(HT(e,Zw(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=Zw(e,this.pos),n=0;if(t>this.pos){let r=UT(e,t,this.start);if(r){let t=gT(e,r.to-this.start);t>0&&(this.nextStage(r),n=t)}}return n||=gT(e,this.pos),n>0&&n<e.length?n:-1}else return gT(e,this.pos)}};function gT(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!Xw(n))return-1}return t}var _T=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:oT(t),i=t.next;if(r<0)return!1;let a=MT(Q.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,MT(i==61?Q.SetextHeading1:Q.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),a])),!0}finish(){return!1}},vT={LinkReference(e,t){return t.content.charCodeAt(0)==91?new hT(t):null},SetextHeading(){return new _T}},yT=[(e,t)=>aT(t)>=0,(e,t)=>$w(t)>=0,(e,t)=>eT(t)>=0,(e,t)=>rT(t,e,!0)>=0,(e,t)=>iT(t,e,!0)>=0,(e,t)=>tT(t,e,!0)>=0,(e,t)=>dT(t,e,!0)>=0],bT={text:``,end:0},xT=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new qw,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=Gw.create(Q.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new JT(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let n=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;t<e.markers.length&&(!n||e.markers[t].from<n.end);){let n=e.markers[t++];this.addNode(n.type,n.from,n.to)}if(!n)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;start:for(;;){for(let t of this.parser.blockParsers)if(t){let n=t(this,e);if(n!=0){if(n==1)return null;e.forward();continue start}}break}let t=new Kw(this.lineStart+e.pos,e.text.slice(e.pos));for(let e of this.parser.leafBlockParsers)if(e){let n=e(this,t);n&&t.parsers.push(n)}lines:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,t))break lines}for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+=`
51
51
  `+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=YT(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=bT;if(t.end=e,e>=this.to)t.text=``;else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let e=this.absoluteLineStart,n=this.rangeI;for(;this.ranges[n].to<t.end;){n++;let r=this.ranges[n].from,i=this.lineChunkAt(r);t.end=r+i.length,t.text=t.text.slice(0,this.ranges[n-1].to-e)+i,e=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let t=this.stack[e.depth],n=this.parser.skipContextMarkup[t.type];if(!n)throw Error(`Unhandled block context `+Q[t.type]);let r=this.line.markers.length;if(!n(t,this,e)){this.line.markers.length>r&&(t.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),n;if(this.input.lineChunks)n=t==`
52
52
  `?``:t;else{let e=t.indexOf(`
@@ -74,7 +74,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
74
74
  }`,{label:`interface`,detail:`definition`,type:`keyword`}),vn("type ${name} = ${type}",{label:`type`,detail:`definition`,type:`keyword`}),vn(`enum \${name} {
75
75
  \${}
76
76
  }`,{label:`enum`,detail:`definition`,type:`keyword`})]),mk=new bt,hk=new Set([`Script`,`Block`,`FunctionExpression`,`FunctionDeclaration`,`ArrowFunction`,`MethodDeclaration`,`ForStatement`]);function gk(e){return(t,n)=>{let r=t.node.getChild(`VariableDefinition`);return r&&n(r,e),!0}}var _k=[`FunctionDeclaration`],vk={FunctionDeclaration:gk(`function`),ClassDeclaration:gk(`class`),ClassExpression:()=>!0,EnumDeclaration:gk(`constant`),TypeAliasDeclaration:gk(`type`),NamespaceDeclaration:gk(`namespace`),VariableDefinition(e,t){e.matchContext(_k)||t(e,`variable`)},TypeDefinition(e,t){t(e,`type`)},__proto__:null};function yk(e,t){let n=mk.get(t);if(n)return n;let r=[],i=!0;function a(t,n){let i=e.sliceString(t.from,t.to);r.push({label:i,type:n})}return t.cursor(hn.IncludeAnonymous).iterate(t=>{if(i)i=!1;else if(t.name){let e=vk[t.name];if(e&&e(t,a)||hk.has(t.name))return!1}else if(t.to-t.from>8192){for(let n of yk(e,t.node))r.push(n);return!1}}),mk.set(t,r),r}var bk=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,xk=[`TemplateString`,`String`,`RegExp`,`LineComment`,`BlockComment`,`VariableDefinition`,`TypeDefinition`,`Label`,`PropertyDefinition`,`PropertyName`,`PrivatePropertyDefinition`,`PrivatePropertyName`,`JSXText`,`JSXAttributeValue`,`JSXOpenTag`,`JSXCloseTag`,`JSXSelfClosingTag`,`.`,`?.`];function Sk(e){let t=dt(e.state).resolveInner(e.pos,-1);if(xk.indexOf(t.name)>-1)return null;let n=t.name==`VariableName`||t.to-t.from<20&&bk.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let n=t;n;n=n.parent)hk.has(n.name)&&(r=r.concat(yk(e.state.doc,n)));return{options:r,from:n?t.from:e.pos,validFor:bk}}var Ck=tn.define({name:`javascript`,parser:dk.configure({props:[dn.add({IfStatement:sn({except:/^\s*({|else\b)/}),TryStatement:sn({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Rt,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:Qt({closing:`}`}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":sn({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),mn.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Et,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name==`JSXSelfClosingTag`)return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){let t=e.firstChild?.nextSibling,n=e.lastChild;return!t||t.type.isError?null:{from:t.to,to:n.type.isError?e.to:n.from}}})]}),languageData:{closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]},commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:`$`}}),wk={test:e=>/^JSX/.test(e.name),facet:Ft({commentTokens:{block:{open:`{/*`,close:`*/}`}}})},Tk=Ck.configure({dialect:`ts`},`typescript`),Ek=Ck.configure({dialect:`jsx`,props:[Vt.add(e=>e.isTop?[wk]:void 0)]}),Dk=Ck.configure({dialect:`jsx ts`,props:[Vt.add(e=>e.isTop?[wk]:void 0)]},`typescript`),Ok=e=>({label:e,type:`keyword`}),kk=`break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield`.split(` `).map(Ok),Ak=kk.concat([`declare`,`implements`,`private`,`protected`,`public`].map(Ok));function jk(e={}){let t=e.jsx?e.typescript?Dk:Ek:e.typescript?Tk:Ck,n=e.typescript?pk.concat(Ak):fk.concat(kk);return new Xt(t,[Ck.data.of({autocomplete:Cn(xk,_n(n))}),Ck.data.of({autocomplete:Sk}),e.jsx?Fk:[]])}function Mk(e){for(;;){if(e.name==`JSXOpenTag`||e.name==`JSXSelfClosingTag`||e.name==`JSXFragmentTag`)return e;if(e.name==`JSXEscape`||!e.parent)return null;e=e.parent}}function Nk(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name==`JSXIdentifier`||r.name==`JSXBuiltin`||r.name==`JSXNamespacedName`||r.name==`JSXMemberExpression`)return e.sliceString(r.from,Math.min(r.to,n));return``}var Pk=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),Fk=wt.inputHandler.of((e,t,n,r,i)=>{if((Pk?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!Ck.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let{head:t}=e,n=dt(o).resolveInner(t-1,-1),i;if(n.name==`JSXStartTag`&&(n=n.parent),!(o.doc.sliceString(t-1,t)!=r||n.name==`JSXAttributeValue`&&n.to>t)){if(r==`>`&&n.name==`JSXFragmentTag`)return{range:e,changes:{from:t,insert:`</>`}};if(r==`/`&&n.name==`JSXStartCloseTag`){let e=n.parent,r=e.parent;if(r&&e.from==t-2&&((i=Nk(o.doc,r.firstChild,t))||r.firstChild?.name==`JSXFragmentTag`)){let e=`${i}>`;return{range:G.cursor(t+e.length,-1),changes:{from:t,insert:e}}}}else if(r==`>`){let r=Mk(n);if(r&&r.name==`JSXOpenTag`&&!/^\/?>|^<\//.test(o.doc.sliceString(t,t+2))&&(i=Nk(o.doc,r,t)))return{range:e,changes:{from:t,insert:`</${i}>`}}}}return{range:e}});return s.changes.empty?!1:(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),Ik=[`_blank`,`_self`,`_top`,`_parent`],Lk=[`ascii`,`utf-8`,`utf-16`,`latin1`,`latin1`],Rk=[`get`,`post`,`put`,`delete`],zk=[`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`],Bk=[`true`,`false`],$={},Vk={a:{attrs:{href:null,ping:null,type:null,media:null,target:Ik,hreflang:null}},abbr:$,address:$,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:[`default`,`rect`,`circle`,`poly`]}},article:$,aside:$,audio:{attrs:{src:null,mediagroup:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`none`,`metadata`,`auto`],autoplay:[`autoplay`],loop:[`loop`],controls:[`controls`]}},b:$,base:{attrs:{href:null,target:Ik}},bdi:$,bdo:$,blockquote:{attrs:{cite:null}},body:$,br:$,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:[`autofocus`],disabled:[`autofocus`],formenctype:zk,formmethod:Rk,formnovalidate:[`novalidate`],formtarget:Ik,type:[`submit`,`reset`,`button`]}},canvas:{attrs:{width:null,height:null}},caption:$,center:$,cite:$,code:$,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:[`command`,`checkbox`,`radio`],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:[`disabled`],checked:[`checked`]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:[`disabled`],multiple:[`multiple`]}},datalist:{attrs:{data:null}},dd:$,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:[`open`]}},dfn:$,div:$,dl:$,dt:$,em:$,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:[`disabled`],form:null,name:null}},figcaption:$,figure:$,footer:$,form:{attrs:{action:null,name:null,"accept-charset":Lk,autocomplete:[`on`,`off`],enctype:zk,method:Rk,novalidate:[`novalidate`],target:Ik}},h1:$,h2:$,h3:$,h4:$,h5:$,h6:$,head:{children:[`title`,`base`,`link`,`style`,`meta`,`script`,`noscript`,`command`]},header:$,hgroup:$,hr:$,html:{attrs:{manifest:null}},i:$,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:[`allow-top-navigation`,`allow-same-origin`,`allow-forms`,`allow-scripts`],seamless:[`seamless`]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:[`audio/*`,`video/*`,`image/*`],autocomplete:[`on`,`off`],autofocus:[`autofocus`],checked:[`checked`],disabled:[`disabled`],formenctype:zk,formmethod:Rk,formnovalidate:[`novalidate`],formtarget:Ik,multiple:[`multiple`],readonly:[`readonly`],required:[`required`],type:[`hidden`,`text`,`search`,`tel`,`url`,`email`,`password`,`datetime`,`date`,`month`,`week`,`time`,`datetime-local`,`number`,`range`,`color`,`checkbox`,`radio`,`file`,`submit`,`image`,`reset`,`button`]}},ins:{attrs:{cite:null,datetime:null}},kbd:$,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:[`autofocus`],disabled:[`disabled`],keytype:[`RSA`]}},label:{attrs:{for:null,form:null}},legend:$,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:[`all`,`16x16`,`16x16 32x32`,`16x16 32x32 64x64`]}},map:{attrs:{name:null}},mark:$,menu:{attrs:{label:null,type:[`list`,`context`,`toolbar`]}},meta:{attrs:{content:null,charset:Lk,name:[`viewport`,`application-name`,`author`,`description`,`generator`,`keywords`],"http-equiv":[`content-language`,`content-type`,`default-style`,`refresh`]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:$,noscript:$,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:[`typemustmatch`]}},ol:{attrs:{reversed:[`reversed`],start:null,type:[`1`,`a`,`A`,`i`,`I`]},children:[`li`,`script`,`template`,`ul`,`ol`]},optgroup:{attrs:{disabled:[`disabled`],label:null}},option:{attrs:{disabled:[`disabled`],label:null,selected:[`selected`],value:null}},output:{attrs:{for:null,form:null,name:null}},p:$,param:{attrs:{name:null,value:null}},pre:$,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:$,rt:$,ruby:$,samp:$,script:{attrs:{type:[`text/javascript`],src:null,async:[`async`],defer:[`defer`],charset:Lk}},section:$,select:{attrs:{form:null,name:null,size:null,autofocus:[`autofocus`],disabled:[`disabled`],multiple:[`multiple`]}},slot:{attrs:{name:null}},small:$,source:{attrs:{src:null,type:null,media:null}},span:$,strong:$,style:{attrs:{type:[`text/css`],media:null,scoped:null}},sub:$,summary:$,sup:$,table:$,tbody:$,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:$,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:[`autofocus`],disabled:[`disabled`],readonly:[`readonly`],required:[`required`],wrap:[`soft`,`hard`]}},tfoot:$,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:[`row`,`col`,`rowgroup`,`colgroup`]}},thead:$,time:{attrs:{datetime:null}},title:$,tr:$,track:{attrs:{src:null,label:null,default:null,kind:[`subtitles`,`captions`,`descriptions`,`chapters`,`metadata`],srclang:null}},ul:{children:[`li`,`script`,`template`,`ul`,`ol`]},var:$,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`auto`,`metadata`,`none`],autoplay:[`autoplay`],mediagroup:[`movie`],muted:[`muted`],controls:[`controls`]}},wbr:$},Hk={accesskey:null,class:null,contenteditable:Bk,contextmenu:null,dir:[`ltr`,`rtl`,`auto`],draggable:[`true`,`false`,`auto`],dropzone:[`copy`,`move`,`link`,`string:`,`file:`],hidden:[`hidden`],id:null,inert:[`inert`],itemid:null,itemprop:null,itemref:null,itemscope:[`itemscope`],itemtype:null,lang:[`ar`,`bn`,`de`,`en-GB`,`en-US`,`es`,`fr`,`hi`,`id`,`ja`,`pa`,`pt`,`ru`,`tr`,`zh`],spellcheck:Bk,autocorrect:Bk,autocapitalize:Bk,style:null,tabindex:null,title:null,translate:[`yes`,`no`],rel:[`stylesheet`,`alternate`,`author`,`bookmark`,`help`,`license`,`next`,`nofollow`,`noreferrer`,`prefetch`,`prev`,`search`,`tag`],role:`alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer`.split(` `),"aria-activedescendant":null,"aria-atomic":Bk,"aria-autocomplete":[`inline`,`list`,`both`,`none`],"aria-busy":Bk,"aria-checked":[`true`,`false`,`mixed`,`undefined`],"aria-controls":null,"aria-describedby":null,"aria-disabled":Bk,"aria-dropeffect":null,"aria-expanded":[`true`,`false`,`undefined`],"aria-flowto":null,"aria-grabbed":[`true`,`false`,`undefined`],"aria-haspopup":Bk,"aria-hidden":Bk,"aria-invalid":[`true`,`false`,`grammar`,`spelling`],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":[`off`,`polite`,`assertive`],"aria-multiline":Bk,"aria-multiselectable":Bk,"aria-owns":null,"aria-posinset":null,"aria-pressed":[`true`,`false`,`mixed`,`undefined`],"aria-readonly":Bk,"aria-relevant":null,"aria-required":Bk,"aria-selected":[`true`,`false`,`undefined`],"aria-setsize":null,"aria-sort":[`ascending`,`descending`,`none`,`other`],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Uk=`beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload`.split(` `).map(e=>`on`+e);for(let e of Uk)Hk[e]=null;var Wk=class{constructor(e,t){this.tags={...Vk,...e},this.globalAttrs={...Hk,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};Wk.default=new Wk;function Gk(e,t,n=e.length){if(!t)return``;let r=t.firstChild,i=r&&r.getChild(`TagName`);return i?e.sliceString(i.from,Math.min(i.to,n)):``}function Kk(e,t=!1){for(;e;e=e.parent)if(e.name==`Element`)if(t)t=!1;else return e;return null}function qk(e,t,n){return n.tags[Gk(e,Kk(t))]?.children||n.allTags}function Jk(e,t){let n=[];for(let r=Kk(t);r&&!r.type.isTop;r=Kk(r.parent)){let i=Gk(e,r);if(i&&r.lastChild.name==`CloseTag`)break;i&&n.indexOf(i)<0&&(t.name==`EndTag`||t.from>=r.firstChild.to)&&n.push(i)}return n}var Yk=/^[:\-\.\w\u00b7-\uffff]*$/;function Xk(e,t,n,r,i){let a=/\s*>/.test(e.sliceDoc(i,i+5))?``:`>`,o=Kk(n,n.name==`StartTag`||n.name==`TagName`);return{from:r,to:i,options:qk(e.doc,o,t).map(e=>({label:e,type:`type`})).concat(Jk(e.doc,n).map((e,t)=>({label:`/`+e,apply:`/`+e+a,type:`type`,boost:99-t}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function Zk(e,t,n,r){let i=/\s*>/.test(e.sliceDoc(r,r+5))?``:`>`;return{from:n,to:r,options:Jk(e.doc,t).map((e,t)=>({label:e,apply:e+i,type:`type`,boost:99-t})),validFor:Yk}}function Qk(e,t,n,r){let i=[],a=0;for(let r of qk(e.doc,n,t))i.push({label:`<`+r,type:`type`});for(let t of Jk(e.doc,n))i.push({label:`</`+t+`>`,type:`type`,boost:99-a++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function $k(e,t,n,r,i){let a=Kk(n),o=a?t.tags[Gk(e.doc,a)]:null,s=o&&o.attrs?Object.keys(o.attrs):[];return{from:r,to:i,options:(o&&o.globalAttrs===!1?s:s.length?s.concat(t.globalAttrNames):t.globalAttrNames).map(e=>({label:e,type:`property`})),validFor:Yk}}function eA(e,t,n,r,i){let a=n.parent?.getChild(`AttributeName`),o=[],s;if(a){let c=e.sliceDoc(a.from,a.to),l=t.globalAttrs[c];if(!l){let r=Kk(n),i=r?t.tags[Gk(e.doc,r)]:null;l=i?.attrs&&i.attrs[c]}if(l){let t=e.sliceDoc(r,i).toLowerCase(),n=`"`,a=`"`;/^['"]/.test(t)?(s=t[0]==`"`?/^[^"]*$/:/^[^']*$/,n=``,a=e.sliceDoc(i,i+1)==t[0]?``:t[0],t=t.slice(1),r++):s=/^[^\s<>='"]*$/;for(let e of l)o.push({label:e,apply:n+e+a,type:`constant`})}}return{from:r,to:i,options:o,validFor:s}}function tA(e,t){let{state:n,pos:r}=t,i=dt(n).resolveInner(r,-1),a=i.resolve(r);for(let e=r,t;a==i&&(t=i.childBefore(e));){let n=t.lastChild;if(!n||!n.type.isError||n.from<n.to)break;a=i=t,e=n.from}return i.name==`TagName`?i.parent&&/CloseTag$/.test(i.parent.name)?Zk(n,i,i.from,r):Xk(n,e,i,i.from,r):i.name==`StartTag`||i.name==`IncompleteTag`?Xk(n,e,i,r,r):i.name==`StartCloseTag`||i.name==`IncompleteCloseTag`?Zk(n,i,r,r):i.name==`OpenTag`||i.name==`SelfClosingTag`||i.name==`AttributeName`?$k(n,e,i,i.name==`AttributeName`?i.from:r,r):i.name==`Is`||i.name==`AttributeValue`||i.name==`UnquotedAttributeValue`?eA(n,e,i,i.name==`Is`?r:i.from,r):t.explicit&&(a.name==`Element`||a.name==`Text`||a.name==`Document`)?Qk(n,e,i,r):null}function nA(e){return tA(Wk.default,e)}function rA(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new Wk(t,n):Wk.default;return e=>tA(r,e)}var iA=Ck.parser.configure({top:`SingleExpression`}),aA=[{tag:`script`,attrs:e=>e.type==`text/typescript`||e.lang==`ts`,parser:Tk.parser},{tag:`script`,attrs:e=>e.type==`text/babel`||e.type==`text/jsx`,parser:Ek.parser},{tag:`script`,attrs:e=>e.type==`text/typescript-jsx`,parser:Dk.parser},{tag:`script`,attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:iA},{tag:`script`,attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:Ck.parser},{tag:`style`,attrs(e){return(!e.lang||e.lang==`css`)&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:OO.parser}],oA=[{name:`style`,parser:OO.parser.configure({top:`Styles`})}].concat(Uk.map(e=>({name:e,parser:Ck.parser}))),sA=tn.define({name:`html`,parser:DD.configure({props:[dn.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let n=e.node;;){let e=n.lastChild;if(!e||e.name!=`Element`||e.to!=n.to)break;t=n=e}return t&&!((n=t.lastChild)&&(n.name==`CloseTag`||n.name==`SelfClosingTag`))?e.lineIndent(t.from)+e.unit:null}}),mn.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!=`OpenTag`?null:{from:t.to,to:n.name==`CloseTag`?n.from:e.to}}}),Gt.add({"OpenTag CloseTag":e=>e.getChild(`TagName`)})]}),languageData:{commentTokens:{block:{open:`<!--`,close:`-->`}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:`-_`}}),cA=sA.configure({wrap:jD(aA,oA)});function lA(e={}){let t=``,n;return e.matchClosingTags===!1&&(t=`noMatch`),e.selfClosingTags===!0&&(t=(t?t+` `:``)+`selfClosing`),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=jD((e.nestedLanguages||[]).concat(aA),(e.nestedAttributes||[]).concat(oA))),new Xt(n?sA.configure({wrap:n,dialect:t}):t?cA.configure({dialect:t}):cA,[cA.data.of({autocomplete:rA(e)}),e.autoCloseTags===!1?[]:dA,jk().support,kO().support])}var uA=new Set(`area base br col command embed frame hr img input keygen link meta param source track wbr menuitem`.split(` `)),dA=wt.inputHandler.of((e,t,n,r,i)=>{if(e.composing||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!cA.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let t=o.doc.sliceString(e.from-1,e.to)==r,{head:n}=e,i=dt(o).resolveInner(n,-1),a;if(t&&r==`>`&&i.name==`EndTag`){let t=i.parent;if(t.parent?.lastChild?.name!=`CloseTag`&&(a=Gk(o.doc,t.parent,n))&&!uA.has(a))return{range:e,changes:{from:n,to:n+ +(o.doc.sliceString(n,n+1)===`>`),insert:`</${a}>`}}}else if(t&&r==`/`&&i.name==`IncompleteCloseTag`){let e=i.parent;if(i.from==n-2&&e.lastChild?.name!=`CloseTag`&&(a=Gk(o.doc,e,n))&&!uA.has(a)){let e=n+ +(o.doc.sliceString(n,n+1)===`>`),t=`${a}>`;return{range:G.cursor(n+t.length,-1),changes:{from:n,to:e,insert:t}}}}return{range:e}});return s.changes.empty?!1:(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),fA=Ft({commentTokens:{block:{open:`<!--`,close:`-->`}}}),pA=new Je,mA=ZT.configure({props:[mn.add(e=>!e.is(`Block`)||e.is(`Document`)||hA(e)!=null||gA(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),pA.add(hA),dn.add({Document:()=>null}),Ut.add({Document:fA})]});function hA(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function gA(e){return e.name==`OrderedList`||e.name==`BulletList`}function _A(e,t){let n=e;for(;;){let e=n.nextSibling,r;if(!e||(r=hA(e.type))!=null&&r<=t)break;n=e}return n.to}var vA=kt.of((e,t,n)=>{for(let r=dt(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let e=r.type.prop(pA);if(e==null)continue;let t=_A(r,e);if(t>n)return{from:n,to:t}}return null});function yA(e){return new Bt(fA,e,[],`markdown`)}var bA=yA(mA),xA=yA(mA.configure([_E,bE,yE,xE,{props:[mn.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));function SA(e,t){return n=>{if(n&&e){let t=null;if(n=/\S*/.exec(n)[0],t=typeof e==`function`?e(n):Dt.matchLanguageName(e,n,!0),t instanceof Dt)return t.support?t.support.language.parser:nn.getSkippingParser(t.load());if(t)return t.parser}return t?t.parser:null}}var CA=class{constructor(e,t,n,r,i,a,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=i,this.type=a,this.item=o}blank(e,t=!0){let n=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(e!=null){for(;n.length<e;)n+=` `;return n}else{for(let e=this.to-this.from-n.length-this.spaceAfter.length;e>0;e--)n+=` `;return n+(t?this.spaceAfter:``)}}marker(e,t){let n=this.node.name==`OrderedList`?String(+TA(this.item,e)[2]+t):``;return this.spaceBefore+n+this.type+this.spaceAfter}};function wA(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if(t.name==`FencedCode`)return r;(t.name==`ListItem`||t.name==`Blockquote`)&&n.push(t)}for(let e=n.length-1;e>=0;e--){let i=n[e],a,o=t.lineAt(i.from),s=i.from-o.from;if(i.name==`Blockquote`&&(a=/^ *>( ?)/.exec(o.text.slice(s))))r.push(new CA(i,s,s+a[0].length,``,a[1],`>`,null));else if(i.name==`ListItem`&&i.parent.name==`OrderedList`&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(s)))){let e=a[3],t=a[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new CA(i.parent,s,s+t,a[1],e,a[2],i))}else if(i.name==`ListItem`&&i.parent.name==`BulletList`&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))){let e=a[4],t=a[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=a[2];a[3]&&(n+=a[3].replace(/[xX]/,` `)),r.push(new CA(i.parent,s,s+t,a[1],e,n,i))}}return r}function TA(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function EA(e,t,n,r=0){for(let i=-1,a=e;;){if(a.name==`ListItem`){let e=TA(a,t),o=+e[2];if(i>=0){if(o!=i+1)return;n.push({from:a.from+e[1].length,to:a.from+e[0].length,insert:String(i+2+r)})}i=o}let e=a.nextSibling;if(!e)break;a=e}}function DA(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(Ze)!=` `)return e;let r=Ye(e,4,n),i=``;for(let e=r;e>0;)e>=4?(i+=` `,e-=4):(i+=` `,e--);return i+e.slice(n)}var OA=((e={})=>({state:t,dispatch:n})=>{let r=dt(t),{doc:i}=t,a=null,o=t.changeByRange(n=>{if(!n.empty||!xA.isActiveAt(t,n.from,-1)&&!xA.isActiveAt(t,n.from,1))return a={range:n};let o=n.from,s=i.lineAt(o),c=wA(r.resolveInner(o,-1),i);for(;c.length&&c[c.length-1].from>o-s.from;)c.pop();if(!c.length)return a={range:n};let l=c[c.length-1];if(l.to-l.spaceAfter.length>o-s.from)return a={range:n};let u=o>=l.to-l.spaceAfter.length&&!/\S/.test(s.text.slice(l.to));if(l.item&&u){let n=l.node.firstChild,r=l.node.getChild(`ListItem`,`ListItem`);if(n.to>=o||r&&r.to<o||s.from>0&&!/[^\s>]/.test(i.lineAt(s.from-1).text)||e.nonTightLists===!1){let e=c.length>1?c[c.length-2]:null,t,n=``;e&&e.item?(t=s.from+e.from,n=e.marker(i,1)):t=s.from+(e?e.to:0);let r=[{from:t,to:o,insert:n}];return l.node.name==`OrderedList`&&EA(l.item,i,r,-2),e&&e.node.name==`OrderedList`&&EA(e.item,i,r),{range:G.cursor(t+n.length),changes:r}}else{let e=jA(c,t,s);return{range:G.cursor(o+e.length+1),changes:{from:s.from,insert:e+t.lineBreak}}}}if(l.node.name==`Blockquote`&&u&&s.from){let e=i.lineAt(s.from-1),r=/>\s*$/.exec(e.text);if(r&&r.index==l.from){let i=t.changes([{from:e.from+r.index,to:e.to},{from:s.from+l.from,to:s.to}]);return{range:n.map(i),changes:i}}}let d=[];l.node.name==`OrderedList`&&EA(l.item,i,d);let f=l.item&&l.item.from<s.from,p=``;if(!f||/^[\s\d.)\-+*>]*/.exec(s.text)[0].length>=l.to)for(let e=0,t=c.length-1;e<=t;e++)p+=e==t&&!f?c[e].marker(i,1):c[e].blank(e<t?Ye(s.text,4,c[e+1].from)-p.length:null);let m=o;for(;m>s.from&&/\s/.test(s.text.charAt(m-s.from-1));)m--;return p=DA(p,t),AA(l.node,t.doc)&&(p=jA(c,t,s)+t.lineBreak+p),d.push({from:m,to:o,insert:t.lineBreak+p}),{range:G.cursor(m+p.length+1),changes:d}});return a?!1:(n(t.update(o,{scrollIntoView:!0,userEvent:`input`})),!0)})();function kA(e){return e.name==`QuoteMark`||e.name==`ListMark`}function AA(e,t){if(e.name!=`OrderedList`&&e.name!=`BulletList`)return!1;let n=e.firstChild,r=e.getChild(`ListItem`,`ListItem`);if(!r)return!1;let i=t.lineAt(n.to),a=t.lineAt(r.from),o=/^[\s>]*$/.test(i.text);return i.number+ +!o<a.number}function jA(e,t,n){let r=``;for(let t=0,i=e.length-2;t<=i;t++)r+=e[t].blank(t<i?Ye(n.text,4,e[t+1].from)-r.length:null,t<i);return DA(r,t)}function MA(e,t){let n=e.resolveInner(t,-1),r=t;kA(n)&&(r=n.from,n=n.parent);for(let e;e=n.childBefore(r);)if(kA(e))r=e.from;else if(e.name==`OrderedList`||e.name==`BulletList`)n=e.lastChild,r=n.to;else break;return n}var NA=[{key:`Enter`,run:OA},{key:`Backspace`,run:({state:e,dispatch:t})=>{let n=dt(e),r=null,i=e.changeByRange(t=>{let i=t.from,{doc:a}=e;if(t.empty&&xA.isActiveAt(e,t.from)){let t=a.lineAt(i),r=wA(MA(n,i),a);if(r.length){let n=r[r.length-1],a=n.to-n.spaceAfter.length+ +!!n.spaceAfter;if(i-t.from>a&&!/\S/.test(t.text.slice(a,i-t.from)))return{range:G.cursor(t.from+a),changes:{from:t.from+a,to:i}};if(i-t.from==a&&(!n.item||t.from<=n.item.from||!/\S/.test(t.text.slice(0,n.to)))){let r=t.from+n.from;if(n.item&&n.node.from<n.item.from&&/\S/.test(t.text.slice(n.from,n.to))){let i=n.blank(Ye(t.text,4,n.to)-Ye(t.text,4,n.from));return r==t.from&&(i=DA(i,e)),{range:G.cursor(r+i.length),changes:{from:r,to:t.from+n.to,insert:i}}}if(r<i)return{range:G.cursor(r),changes:{from:r,to:i}}}}}return r={range:t}});return r?!1:(t(e.update(i,{scrollIntoView:!0,userEvent:`delete`})),!0)}}],PA=lA({matchClosingTags:!1});function FA(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:i}=bA,completeHTMLTags:a=!0,pasteURLAsLink:o=!0,htmlTagLanguage:s=PA}=e;if(!(i instanceof CT))throw RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=e.extensions?[e.extensions]:[],l=[s.support,vA],u;o&&l.push(BA),n instanceof Xt?(l.push(n.support),u=n.language):n&&(u=n);let d=t||u?SA(t,u):void 0;c.push($T({codeParser:d,htmlParser:s.language.parser})),r&&l.push(Wt.high(Kt.of(NA)));let f=yA(i.configure(c));return a&&l.push(f.data.of({autocomplete:IA})),new Xt(f,l)}function IA(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let i=dt(t).resolveInner(n,-1);for(;i&&!i.type.isTop;){if(i.name==`CodeBlock`||i.name==`FencedCode`||i.name==`ProcessingInstructionBlock`||i.name==`CommentBlock`||i.name==`Link`||i.name==`Image`)return null;i=i.parent}return{from:n-r[0].length,to:n,options:RA(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}var LA=null;function RA(){if(LA)return LA;let e=nA(new wn(et.create({extensions:PA}),0,!0));return LA=e?e.options:[]}var zA=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,BA=wt.domEventHandlers({paste:(e,t)=>{let{main:n}=t.state.selection;if(n.empty)return!1;let r=e.clipboardData?.getData(`text/plain`);if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r=`https://`+r),!xA.isActiveAt(t.state,n.from,1)))return!1;let i=dt(t.state),a=!1;return i.iterate({from:n.from,to:n.to,enter:e=>{(e.from>n.from||zA.test(e.name))&&(a=!0)},leave:e=>{e.to<n.to&&(a=!0)}}),a?!1:(t.dispatch({changes:[{from:n.from,insert:`[`},{from:n.to,insert:`](${r})`}],userEvent:`input.paste`,scrollIntoView:!0}),!0)}});function VA(){return VA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},VA.apply(null,arguments)}var HA=e=>{var{theme:t,settings:n={},styles:r=[]}=e,i={".cm-gutters":{}},a={};n.background&&(a.backgroundColor=n.background),n.backgroundImage&&(a.backgroundImage=n.backgroundImage),n.foreground&&(a.color=n.foreground),n.fontSize&&(a.fontSize=n.fontSize),(n.background||n.foreground)&&(i[`&`]=a),n.fontFamily&&(i[`&.cm-editor .cm-scroller`]={fontFamily:n.fontFamily}),n.gutterBackground&&(i[`.cm-gutters`].backgroundColor=n.gutterBackground),n.gutterForeground&&(i[`.cm-gutters`].color=n.gutterForeground),n.gutterBorder&&(i[`.cm-gutters`].borderRightColor=n.gutterBorder),n.caret&&(i[`.cm-content`]={caretColor:n.caret},i[`.cm-cursor, .cm-dropCursor`]={borderLeftColor:n.caret});var o={};return n.gutterActiveForeground&&(o.color=n.gutterActiveForeground),n.lineHighlight&&(i[`.cm-activeLine`]={backgroundColor:n.lineHighlight},o.backgroundColor=n.lineHighlight),i[`.cm-activeLineGutter`]=o,n.selection&&(i[`&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection`]={background:n.selection+` !important`}),n.selectionMatch&&(i[`& .cm-selectionMatch`]={backgroundColor:n.selectionMatch}),[wt.theme(i,{dark:t===`dark`}),ut(an.define(r))]},UA={background:`#2E3235`,foreground:`#DDDDDD`,caret:`#DDDDDD`,selection:`#202325`,selectionMatch:`#202325`,gutterBackground:`#292d30`,gutterForeground:`#808080`,gutterBorder:`1px solid #ffffff10`,lineHighlight:`#B9D2FF30`},WA=[{tag:W.keyword,color:`#fda331`},{tag:[W.name,W.deleted,W.character,W.propertyName,W.macroName],color:`#b5bd68`},{tag:[W.variableName],color:`#6fb3d2`},{tag:[W.function(W.variableName)],color:`#fda331`},{tag:[W.labelName],color:`#fc6d24`},{tag:[W.color,W.constant(W.name),W.standard(W.name)],color:`#fda331`},{tag:[W.definition(W.name),W.separator],color:`#cc99cc`},{tag:[W.brace],color:`#cc99cc`},{tag:[W.annotation],color:`#fc6d24`},{tag:[W.number,W.changed,W.annotation,W.modifier,W.self,W.namespace],color:`#fda331`},{tag:[W.typeName,W.className],color:`#6fb3d2`},{tag:[W.operator,W.operatorKeyword],color:`#cc99cc`},{tag:[W.tagName],color:`#fda331`},{tag:[W.squareBracket],color:`#cc99cc`},{tag:[W.angleBracket],color:`#cc99cc`},{tag:[W.attributeName],color:`#6fb3d2`},{tag:[W.regexp],color:`#fda331`},{tag:[W.quote],color:`#DDDDDD`},{tag:[W.string],color:`#b5bd68`},{tag:W.link,color:`#6987AF`,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[W.url,W.escape,W.special(W.string)],color:`#8abeb7`},{tag:[W.meta],color:`#A54543`},{tag:[W.comment],color:`#808080`,fontStyle:`italic`},{tag:W.monospace,color:`#DDDDDD`},{tag:W.strong,fontWeight:`bold`,color:`#fda331`},{tag:W.emphasis,fontStyle:`italic`,color:`#6fb3d2`},{tag:W.strikethrough,textDecoration:`line-through`},{tag:W.heading,fontWeight:`bold`,color:`#DDDDDD`},{tag:W.special(W.heading1),fontWeight:`bold`,color:`#DDDDDD`},{tag:W.heading1,fontWeight:`bold`,color:`#DDDDDD`},{tag:[W.heading2,W.heading3,W.heading4],fontWeight:`bold`,color:`#DDDDDD`},{tag:[W.heading5,W.heading6],color:`#DDDDDD`},{tag:[W.atom,W.bool,W.special(W.variableName)],color:`#8abeb7`},{tag:[W.processingInstruction,W.inserted],color:`#8abeb7`},{tag:[W.contentSeparator],color:`#6fb3d2`},{tag:W.invalid,color:`#B9D2FF`,borderBottom:`1px dotted #fc6d24`}],GA=e=>{var{theme:t=`dark`,settings:n={},styles:r=[]}=e||{};return HA({theme:t,settings:VA({},UA,n),styles:[...WA,...r]})};GA();var KA={background:`#ffffff`,foreground:`#2e3440`,caret:`#3b4252`,selection:`#eceff4`,selectionMatch:`#e5e9f0`,gutterBackground:`#eceff4`,gutterForeground:`#2e3440`,gutterBorder:`none`,lineHighlight:`#02255f11`},qA=[{tag:W.keyword,color:`#5e81ac`},{tag:[W.name,W.deleted,W.character,W.propertyName,W.macroName],color:`#d08770`},{tag:[W.variableName],color:`#d08770`},{tag:[W.function(W.variableName)],color:`#5e81ac`},{tag:[W.labelName],color:`#81a1c1`},{tag:[W.color,W.constant(W.name),W.standard(W.name)],color:`#5e81ac`},{tag:[W.definition(W.name),W.separator],color:`#a3be8c`},{tag:[W.brace],color:`#8fbcbb`},{tag:[W.annotation],color:`#d30102`},{tag:[W.number,W.changed,W.annotation,W.modifier,W.self,W.namespace],color:`#88c0d0`},{tag:[W.typeName,W.className],color:`#ebcb8b`},{tag:[W.operator,W.operatorKeyword],color:`#a3be8c`},{tag:[W.tagName],color:`#b48ead`},{tag:[W.squareBracket],color:`#bf616a`},{tag:[W.angleBracket],color:`#d08770`},{tag:[W.attributeName],color:`#ebcb8b`},{tag:[W.regexp],color:`#5e81ac`},{tag:[W.quote],color:`#3b4252`},{tag:[W.string],color:`#d08770`},{tag:W.link,color:`#8fbcbb`,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[W.url,W.escape,W.special(W.string)],color:`#d08770`},{tag:[W.meta],color:`#88c0d0`},{tag:[W.comment],color:`#434c5e`,fontStyle:`italic`},{tag:W.strong,fontWeight:`bold`,color:`#5e81ac`},{tag:W.emphasis,fontStyle:`italic`,color:`#5e81ac`},{tag:W.strikethrough,textDecoration:`line-through`},{tag:W.heading,fontWeight:`bold`,color:`#5e81ac`},{tag:W.special(W.heading1),fontWeight:`bold`,color:`#5e81ac`},{tag:W.heading1,fontWeight:`bold`,color:`#5e81ac`},{tag:[W.heading2,W.heading3,W.heading4],fontWeight:`bold`,color:`#5e81ac`},{tag:[W.heading5,W.heading6],color:`#5e81ac`},{tag:[W.atom,W.bool,W.special(W.variableName)],color:`#d08770`},{tag:[W.processingInstruction,W.inserted],color:`#8fbcbb`},{tag:[W.contentSeparator],color:`#ebcb8b`},{tag:W.invalid,color:`#434c5e`,borderBottom:`1px dotted #d30102`}],JA=e=>{var{theme:t=`light`,settings:n={},styles:r=[]}=e||{};return HA({theme:t,settings:VA({},KA,n),styles:[...qA,...r]})};JA();var YA=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=ej(e.state,n.from);return r.line?ZA(e):r.block?$A(e):!1};function XA(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var ZA=XA(aj,0),QA=XA(ij,0),$A=XA((e,t)=>ij(e,t,rj(t)),0);function ej(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var tj=50;function nj(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-tj,r),o=e.sliceDoc(i,i+tj),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*tj?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+tj),d=e.sliceDoc(i-tj,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function rj(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function ij(e,t,n=t.selection.ranges){let r=n.map(e=>ej(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>nj(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function aj(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=ej(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var oj=At.define(),sj=At.define(),cj=Qe.define(),lj=Qe.define({combine(e){return gn(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),uj=mt.define({create(){return kj.empty},update(e,t){let n=t.state.facet(lj),r=t.annotation(oj);if(r){let i=_j.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?vj(o,o.length,n.minDepth,i):wj(o,t.startState.selection),new kj(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(sj);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(ot.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=_j.fromTransaction(t),o=t.annotation(ot.time),s=t.annotation(ot.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new kj(e.done.map(_j.fromJSON),e.undone.map(_j.fromJSON))}});function dj(e={}){return[uj,lj.of(e),wt.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?pj:e.inputType==`historyRedo`?mj:null;return n?(e.preventDefault(),n(t)):!1}})]}function fj(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(uj,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var pj=fj(0,!1),mj=fj(1,!1),hj=fj(0,!0),gj=fj(1,!0),_j=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&vt.fromJSON(t.changes),[],t.mapped&&pn.fromJSON(t.mapped),t.startSelection&&G.fromJSON(t.startSelection),t.selectionsAfter.map(G.fromJSON))}static fromTransaction(t,n){let r=Sj;for(let e of t.startState.facet(cj)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Sj)}static selection(t){return new e(void 0,Sj,void 0,void 0,t)}};function vj(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function yj(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function bj(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function xj(e,t){return e.length?t.length?e.concat(t):e:t}var Sj=[],Cj=200;function wj(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Cj));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),vj(e,e.length-1,1e9,n.setSelAfter(r)))}else return[_j.selection([t])]}function Tj(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Ej(e,t){if(!e.length)return e;let n=e.length,r=Sj;for(;n;){let i=Dj(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[_j.selection(r)]:Sj}function Dj(e,t,n){let r=xj(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):Sj,n);if(!e.changes)return _j.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new _j(i,ft.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Oj=/^(input\.type|delete)($|\.)/,kj=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Oj.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,yj(s.changes,t.changes))||r==`input.type.compose`)?vj(o,o.length-1,i.minDepth,new _j(t.changes.compose(s.changes),xj(ft.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,Sj)):vj(o,o.length,i.minDepth,t),new e(o,Sj,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:Sj;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&bj(a[a.length-1],t)?this:new e(wj(this.done,t),this.undone,n,r)}addMapping(t){return new e(Ej(this.done,t),Ej(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:oj.of({side:e,rest:Tj(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?Sj:r.slice(0,r.length-1);return i.mapped&&(n=Ej(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:oj.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};kj.empty=new kj(Sj,Sj);var Aj=[{key:`Mod-z`,run:pj,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:mj,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:mj,preventDefault:!0},{key:`Mod-u`,run:hj,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:gj,preventDefault:!0}];function jj(e,t){return G.create(e.ranges.map(t),e.mainIndex)}function Mj(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function Nj({state:e,dispatch:t},n){let r=jj(e.selection,n);return r.eq(e.selection,!0)?!1:(t(Mj(e,r)),!0)}function Pj(e,t){return G.cursor(t?e.to:e.from)}function Fj(e,t){return Nj(e,n=>n.empty?e.moveByChar(n,t):Pj(n,t))}function Ij(e){return e.textDirectionAt(e.state.selection.main.head)==st.LTR}var Lj=e=>Fj(e,!Ij(e)),Rj=e=>Fj(e,Ij(e));function zj(e,t){return Nj(e,n=>n.empty?e.moveByGroup(n,t):Pj(n,t))}var Bj=e=>zj(e,!Ij(e)),Vj=e=>zj(e,Ij(e));typeof Intl<`u`&&Intl.Segmenter;function Hj(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Uj(e,t,n){let r=dt(e).resolveInner(t.head),i=n?Je.closedBy:Je.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Hj(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?qe(e,r.from,1):qe(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,G.cursor(s,n?-1:1)}var Wj=e=>Nj(e,t=>Uj(e.state,t,!Ij(e))),Gj=e=>Nj(e,t=>Uj(e.state,t,Ij(e)));function Kj(e,t){return Nj(e,n=>{if(!n.empty)return Pj(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var qj=e=>Kj(e,!1),Jj=e=>Kj(e,!0);function Yj(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(wt.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Xj(e,t){let n=Yj(e),{state:r}=e,i=jj(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Pj(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=wt.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(Mj(r,i),{effects:a}),!0}var Zj=e=>Xj(e,!1),Qj=e=>Xj(e,!0);function $j(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=G.cursor(r.from+n))}return i}var eM=e=>Nj(e,t=>$j(e,t,!0)),tM=e=>Nj(e,t=>$j(e,t,!1)),nM=e=>Nj(e,t=>$j(e,t,!Ij(e))),rM=e=>Nj(e,t=>$j(e,t,Ij(e))),iM=e=>Nj(e,t=>G.cursor(e.lineBlockAt(t.head).from,1)),aM=e=>Nj(e,t=>G.cursor(e.lineBlockAt(t.head).to,-1));function oM(e,t,n){let r=!1,i=jj(e.selection,t=>{let i=qe(e,t.head,-1)||qe(e,t.head,1)||t.head>0&&qe(e,t.head-1,1)||t.head<e.doc.length&&qe(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?G.range(t.anchor,a):G.cursor(a)});return r?(t(Mj(e,i)),!0):!1}var sM=({state:e,dispatch:t})=>oM(e,t,!1);function cM(e,t){let n=jj(e.state.selection,e=>{let n=t(e);return G.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(Mj(e.state,n)),!0)}function lM(e,t){return cM(e,n=>e.moveByChar(n,t))}var uM=e=>lM(e,!Ij(e)),dM=e=>lM(e,Ij(e));function fM(e,t){return cM(e,n=>e.moveByGroup(n,t))}var pM=e=>fM(e,!Ij(e)),mM=e=>fM(e,Ij(e)),hM=e=>cM(e,t=>Uj(e.state,t,!Ij(e))),gM=e=>cM(e,t=>Uj(e.state,t,Ij(e)));function _M(e,t){return cM(e,n=>e.moveVertically(n,t))}var vM=e=>_M(e,!1),yM=e=>_M(e,!0);function bM(e,t){return cM(e,n=>e.moveVertically(n,t,Yj(e).height))}var xM=e=>bM(e,!1),SM=e=>bM(e,!0),CM=e=>cM(e,t=>$j(e,t,!0)),wM=e=>cM(e,t=>$j(e,t,!1)),TM=e=>cM(e,t=>$j(e,t,!Ij(e))),EM=e=>cM(e,t=>$j(e,t,Ij(e))),DM=e=>cM(e,t=>G.cursor(e.lineBlockAt(t.head).from)),OM=e=>cM(e,t=>G.cursor(e.lineBlockAt(t.head).to)),kM=({state:e,dispatch:t})=>(t(Mj(e,{anchor:0})),!0),AM=({state:e,dispatch:t})=>(t(Mj(e,{anchor:e.doc.length})),!0),jM=({state:e,dispatch:t})=>(t(Mj(e,{anchor:e.selection.main.anchor,head:0})),!0),MM=({state:e,dispatch:t})=>(t(Mj(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),NM=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),PM=({state:e,dispatch:t})=>{let n=$M(e).map(({from:t,to:n})=>G.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:G.create(n),userEvent:`select`})),!0},FM=({state:e,dispatch:t})=>{let n=jj(e.selection,t=>{let n=dt(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return G.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(Mj(e,n)),!0)};function IM(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(Mj(n,G.create(i,i.length-1))),!0)}var LM=e=>IM(e,!1),RM=e=>IM(e,!0),zM=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=G.create([n.main]):n.main.empty||(r=G.create([G.cursor(n.main.head)])),r?(t(Mj(e,r)),!0):!1};function BM(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=VM(e,o,!1)):o>i&&(n=`delete.forward`,o=VM(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=VM(e,i,!1),a=VM(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:G.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?wt.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function VM(e,t,n){if(e instanceof wt)for(let r of e.state.facet(wt.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var HM=(e,t,n)=>BM(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Ye(s,a.tabSize)%fn(a)||fn(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=St(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=St(o.text,c-o.from,!1,!1)+o.from);return c}),UM=e=>HM(e,!1,!0),WM=e=>HM(e,!0,!1),GM=(e,t)=>BM(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=St(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),KM=e=>GM(e,!1),qM=e=>GM(e,!0),JM=e=>BM(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),YM=e=>BM(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),XM=e=>BM(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),ZM=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:tt.of([``,``])},range:G.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},QM=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:St(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:St(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:G.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function $M(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function eN(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of $M(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(G.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(G.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:G.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var tN=({state:e,dispatch:t})=>eN(e,t,!1),nN=({state:e,dispatch:t})=>eN(e,t,!0);function rN(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of $M(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var iN=({state:e,dispatch:t})=>rN(e,t,!1),aN=({state:e,dispatch:t})=>rN(e,t,!0),oN=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes($M(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=jj(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function sN(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=dt(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Je.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var cN=uN(!1),lN=uN(!0);function uN(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&sN(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Jt(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=_t(s,r);for(c??=Ye(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,$e(t,c)];return o&&l.push($e(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:tt.of(l)},range:G.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function dN(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:G.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var fN=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Jt(e,{overrideIndentation:e=>n[e]??-1}),i=dN(e,(t,i,a)=>{let o=_t(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=$e(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},pN=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(dN(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Ze)})}),{userEvent:`input.indent`})),!0),mN=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(dN(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Ye(r,e.tabSize),a=0,o=$e(e,Math.max(0,i-fn(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),hN=e=>(e.setTabFocusMode(),!0),gN=[{key:`Ctrl-b`,run:Lj,shift:uM,preventDefault:!0},{key:`Ctrl-f`,run:Rj,shift:dM},{key:`Ctrl-p`,run:qj,shift:vM},{key:`Ctrl-n`,run:Jj,shift:yM},{key:`Ctrl-a`,run:iM,shift:DM},{key:`Ctrl-e`,run:aM,shift:OM},{key:`Ctrl-d`,run:WM},{key:`Ctrl-h`,run:UM},{key:`Ctrl-k`,run:JM},{key:`Ctrl-Alt-h`,run:KM},{key:`Ctrl-o`,run:ZM},{key:`Ctrl-t`,run:QM},{key:`Ctrl-v`,run:Qj}],_N=[{key:`ArrowLeft`,run:Lj,shift:uM,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Bj,shift:pM,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:nM,shift:TM,preventDefault:!0},{key:`ArrowRight`,run:Rj,shift:dM,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Vj,shift:mM,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:rM,shift:EM,preventDefault:!0},{key:`ArrowUp`,run:qj,shift:vM,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:kM,shift:jM},{mac:`Ctrl-ArrowUp`,run:Zj,shift:xM},{key:`ArrowDown`,run:Jj,shift:yM,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:AM,shift:MM},{mac:`Ctrl-ArrowDown`,run:Qj,shift:SM},{key:`PageUp`,run:Zj,shift:xM},{key:`PageDown`,run:Qj,shift:SM},{key:`Home`,run:tM,shift:wM,preventDefault:!0},{key:`Mod-Home`,run:kM,shift:jM},{key:`End`,run:eM,shift:CM,preventDefault:!0},{key:`Mod-End`,run:AM,shift:MM},{key:`Enter`,run:cN,shift:cN},{key:`Mod-a`,run:NM},{key:`Backspace`,run:UM,shift:UM,preventDefault:!0},{key:`Delete`,run:WM,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:KM,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:qM,preventDefault:!0},{mac:`Mod-Backspace`,run:YM,preventDefault:!0},{mac:`Mod-Delete`,run:XM,preventDefault:!0}].concat(gN.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),vN=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Wj,shift:hM},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Gj,shift:gM},{key:`Alt-ArrowUp`,run:tN},{key:`Shift-Alt-ArrowUp`,run:iN},{key:`Alt-ArrowDown`,run:nN},{key:`Shift-Alt-ArrowDown`,run:aN},{key:`Mod-Alt-ArrowUp`,run:LM},{key:`Mod-Alt-ArrowDown`,run:RM},{key:`Escape`,run:zM},{key:`Mod-Enter`,run:lN},{key:`Alt-l`,mac:`Ctrl-l`,run:PM},{key:`Mod-i`,run:FM,preventDefault:!0},{key:`Mod-[`,run:mN},{key:`Mod-]`,run:pN},{key:`Mod-Alt-\\`,run:fN},{key:`Shift-Mod-k`,run:oN},{key:`Shift-Mod-\\`,run:sM},{key:`Mod-/`,run:YA},{key:`Alt-A`,run:QA},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:hN}].concat(_N),yN={key:`Tab`,run:pN,shift:mN},bN=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,xN=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(bN(e)):bN,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return lt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=it(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=gt(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(xN.prototype[Symbol.iterator]=function(){return this});var SN={from:-1,to:-1,match:/.*/.exec(``)},CN=`gm`+(/x/.unicode==null?``:`u`),wN=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=SN,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new DN(e,t,n,r,i);this.re=new RegExp(t,CN+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=kN(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=kN(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},TN=new WeakMap,EN=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=TN.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return TN.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),TN.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},DN=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=SN,this.matchPos=kN(e,r),this.re=new RegExp(t,CN+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=EN.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=kN(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=EN.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(wN.prototype[Symbol.iterator]=DN.prototype[Symbol.iterator]=function(){return this});function ON(e){try{return new RegExp(e,CN),!0}catch{return!1}}function kN(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var AN=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=zt(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=G.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,wt.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},jN={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},MN=Qe.define({combine(e){return gn(e,jN,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function NN(e){let t=[zN,RN];return e&&t.push(MN.of(e)),t}var PN=en.mark({class:`cm-selectionMatch`}),FN=en.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function IN(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=Xe.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=Xe.Word)}function LN(e,t,n,r){return e(t.sliceDoc(n,n+1))==Xe.Word&&e(t.sliceDoc(r-1,r))==Xe.Word}var RN=Tt.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(MN),{state:n}=e,r=n.selection;if(r.ranges.length>1)return en.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return en.none;let e=n.wordAt(i.head);if(!e)return en.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return en.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(IN(o,n,i.from,i.to)&&LN(o,n,i.from,i.to)))return en.none}else if(a=n.sliceDoc(i.from,i.to),!a)return en.none}let s=[];for(let r of e.visibleRanges){let e=new xN(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||IN(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(FN.range(r,a)):(r>=i.to||a<=i.from)&&s.push(PN.range(r,a)),s.length>t.maxMatches))return en.none}}return en.set(s)}},{decorations:e=>e.decorations}),zN=wt.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),BN=({state:e,dispatch:t})=>{let{selection:n}=e,r=G.create(n.ranges.map(t=>e.wordAt(t.head)||G.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function VN(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new xN(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new xN(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var HN=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return BN({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=VN(e,r);return i?(t(e.update({selection:e.selection.addRange(G.range(i.from,i.to),!1),effects:wt.scrollIntoView(i.to)})),!0):!1},UN=Qe.define({combine(e){return gn(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new CP(e),scrollToMatch:e=>wt.scrollIntoView(e)})}}),WN=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||ON(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
77
- `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new tP(this):new YN(this)}getCursor(e,t=0,n){let r=e.doc?e:et.create({doc:e});return n??=r.doc.length,this.regexp?ZN(this,r,t,n):qN(this,r,t,n)}},GN=class{constructor(e){this.spec=e}};function KN(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function qN(e,t,n,r){let i;return e.wholeWord&&(i=JN(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=KN(e.test,t,i)),new xN(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function JN(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(QN(i,n-a))!=Xe.Word||t($N(i,n-a))!=Xe.Word)&&(t($N(i,r-a))!=Xe.Word||t(QN(i,r-a))!=Xe.Word))}var YN=class extends GN{constructor(e){super(e)}nextMatch(e,t,n){let r=qN(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=qN(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=qN(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=qN(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=qN(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function XN(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function ZN(e,t,n,r){let i;return e.wholeWord&&(i=eP(t.charCategorizer(t.selection.main.head))),e.test&&(i=XN(e.test,t,i)),new wN(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function QN(e,t){return e.slice(St(e,t,!1),t)}function $N(e,t){return e.slice(t,St(e,t))}function eP(e){return(t,n,r)=>!r[0].length||(e(QN(r.input,r.index))!=Xe.Word||e($N(r.input,r.index))!=Xe.Word)&&(e($N(r.input,r.index+r[0].length))!=Xe.Word||e(QN(r.input,r.index+r[0].length))!=Xe.Word)}var tP=class extends GN{nextMatch(e,t,n){let r=ZN(this.spec,e,n,e.doc.length).next();return r.done&&(r=ZN(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=ZN(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=ZN(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=ZN(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},nP=ft.define(),rP=ft.define(),iP=mt.define({create(e){return new aP(_P(e).create(),null)},update(e,t){for(let n of t.effects)n.is(nP)?e=new aP(n.value.create(),e.panel):n.is(rP)&&(e=new aP(e.query,n.value?gP:null));return e},provide:e=>Lt.from(e,e=>e.panel)}),aP=class{constructor(e,t){this.query=e,this.panel=t}},oP=en.mark({class:`cm-searchMatch`}),sP=en.mark({class:`cm-searchMatch cm-searchMatch-selected`}),cP=Tt.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(iP))}update(e){let t=e.state.field(iP);(t!=e.startState.field(iP)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return en.none;let{view:n}=this,r=new Ht;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?sP:oP)})}return r.finish()}},{decorations:e=>e.decorations});function lP(e){return t=>{let n=t.state.field(iP,!1);return n&&n.query.spec.valid?e(t,n):bP(t)}}var uP=lP((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=G.single(r.from,r.to),a=e.state.facet(UN);return e.dispatch({selection:i,effects:[DP(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),yP(e),!0}),dP=lP((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=G.single(i.from,i.to),o=e.state.facet(UN);return e.dispatch({selection:a,effects:[DP(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),yP(e),!0}),fP=lP((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:G.create(n.map(e=>G.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),pP=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new xN(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(G.range(t.value.from,t.value.to))}return t(e.update({selection:G.create(a,o),userEvent:`select.search.matches`})),!0},mP=lP((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(wt.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=G.single(o.from,o.to).map(d),u.push(DP(e,o)),u.push(n.facet(UN).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),hP=lP((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:wt.announce.of(r),userEvent:`input.replace.all`}),!0});function gP(e){return e.state.facet(UN).createPanel(e)}function _P(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(UN);return new WN({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function vP(e){let t=Yt(e,gP);return t&&t.dom.querySelector(`[main-field]`)}function yP(e){let t=vP(e);t&&t==e.root.activeElement&&t.select()}var bP=e=>{let t=e.state.field(iP,!1);if(t&&t.panel){let n=vP(e);if(n&&n!=e.root.activeElement){let r=_P(e.state,t.query.spec);r.valid&&e.dispatch({effects:nP.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[rP.of(!0),t?nP.of(_P(e.state,t.query.spec)):ft.appendConfig.of(kP)]});return!0},xP=e=>{let t=e.state.field(iP,!1);if(!t||!t.panel)return!1;let n=Yt(e,gP);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:rP.of(!1)}),!0},SP=[{key:`Mod-f`,run:bP,scope:`editor search-panel`},{key:`F3`,run:uP,shift:dP,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:uP,shift:dP,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:xP,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:pP},{key:`Mod-Alt-g`,run:AN},{key:`Mod-d`,run:HN,preventDefault:!0}],CP=class{constructor(e){this.view=e;let t=this.query=e.state.field(iP).query.spec;this.commit=this.commit.bind(this),this.searchField=un(`input`,{value:t.search,placeholder:wP(e,`Find`),"aria-label":wP(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=un(`input`,{value:t.replace,placeholder:wP(e,`Replace`),"aria-label":wP(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=un(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=un(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=un(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return un(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=un(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>uP(e),[wP(e,`next`)]),n(`prev`,()=>dP(e),[wP(e,`previous`)]),n(`select`,()=>fP(e),[wP(e,`all`)]),un(`label`,null,[this.caseField,wP(e,`match case`)]),un(`label`,null,[this.reField,wP(e,`regexp`)]),un(`label`,null,[this.wordField,wP(e,`by word`)]),...e.state.readOnly?[]:[un(`br`),this.replaceField,n(`replace`,()=>mP(e),[wP(e,`replace`)]),n(`replaceAll`,()=>hP(e),[wP(e,`replace all`)])],un(`button`,{name:`close`,onclick:()=>xP(e),"aria-label":wP(e,`close`),type:`button`},[`×`])])}commit(){let e=new WN({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:nP.of(e)}))}keydown(e){qt(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?dP:uP)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),mP(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(nP)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(UN).top}};function wP(e,t){return e.state.phrase(t)}var TP=30,EP=/[\s\.,:;?!]/;function DP(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-TP),o=Math.min(i,n+TP),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<TP;e++)if(!EP.test(s[e+1])&&EP.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-TP;e--)if(!EP.test(s[e-1])&&EP.test(s[e])){s=s.slice(0,e);break}}return wt.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var OP=wt.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),kP=[iP,Wt.low(cP),OP],AP=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},jP=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(GP).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Ht,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=nF(s);if(i)o.add(n,n,en.widget({widget:new YP(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,en.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,MP(f))}};function MP(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new AP(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new AP(r.from,n,r.diagnostic)}),r}function NP(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(GP).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(FP))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function PP(e,t){return e.field(RP,!1)?t:t.concat(ft.appendConfig.of(rF))}var FP=ft.define(),IP=ft.define(),LP=ft.define(),RP=mt.define({create(){return new jP(en.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=MP(n,e.selected.diagnostic,i)||MP(n,null,i)}!n.size&&i&&t.state.facet(GP).autoPanel&&(i=null),e=new jP(n,i,r)}for(let n of t.effects)if(n.is(FP)){let r=t.state.facet(GP).autoPanel?n.value.length?ZP.open:null:e.panel;e=jP.init(n.value,r,t.state)}else n.is(IP)?e=new jP(e.diagnostics,n.value?ZP.open:null,e.selected):n.is(LP)&&(e=new jP(e.diagnostics,e.panel,n.value));return e},provide:e=>[Lt.from(e,e=>e.panel),wt.decorations.from(e,e=>e.diagnostics)]}),zP=en.mark({class:`cm-lintRange cm-lintRange-active`});function BP(e,t,n){let{diagnostics:r}=e.state.field(RP),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(GP).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:VP(e,i)}}}:null}function VP(e,t){return un(`ul`,{class:`cm-tooltip-lint`},t.map(t=>JP(e,t,!1)))}var HP=e=>{let t=e.state.field(RP,!1);(!t||!t.panel)&&e.dispatch({effects:PP(e.state,[IP.of(!0)])});let n=Yt(e,ZP.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},UP=e=>{let t=e.state.field(RP,!1);return!t||!t.panel?!1:(e.dispatch({effects:IP.of(!1)}),!0)},WP=[{key:`Mod-Shift-m`,run:HP,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(RP,!1);if(!t)return!1;let n=e.state.selection.main,r=MP(t.diagnostics,null,n.to+1);return!r&&(r=MP(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],GP=Qe.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...gn(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:KP,tooltipFilter:KP,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function KP(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function qP(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function JP(e,t,n){let r=n?qP(t.actions):[];return un(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},un(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=MP(e.state.field(RP).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),un(`u`,s.slice(c,c+1)),s.slice(c+1)];return un(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&un(`div`,{class:`cm-diagnosticSource`},t.source))}var YP=class extends ht{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return un(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},XP=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=JP(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},ZP=class e{constructor(e){this.view=e,this.items=[],this.list=un(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)UP(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=qP(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=MP(this.view.state.field(RP).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=un(`div`,{class:`cm-panel-lint`},this.list,un(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>UP(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(RP).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(RP),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new XP(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new XP(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=MP(this.view.state.field(RP).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:LP.of(t)})}static open(t){return new e(t)}};function QP(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function $P(e){return QP(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var eF=wt.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:$P(`#d11`)},".cm-lintRange-warning":{backgroundImage:$P(`orange`)},".cm-lintRange-info":{backgroundImage:$P(`#999`)},".cm-lintRange-hint":{backgroundImage:$P(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function tF(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function nF(e){let t=`hint`,n=1;for(let r of e){let e=tF(r.severity);e>n&&(n=e,t=r.severity)}return t}var rF=[RP,wt.decorations.compute([RP],e=>{let{selected:t,panel:n}=e.field(RP);return!t||!n||t.from==t.to?en.none:en.set([zP.range(t.from,t.to)])}),Mt(BP,{hideOn:NP}),eF],iF=[cn(),Zt(),rn(),dj(),It(),Pt(),on(),et.allowMultipleSelections.of(!0),yt(),ut(Nt,{fallback:!0}),jt(),Sn(),bn(),$t(),Ke(),Ot(),NN(),Kt.of([...yn,...vN,...SP,...Aj,...ln,...xn,...WP])];rn(),dj(),Pt(),ut(Nt,{fallback:!0}),Kt.of([...vN,...Aj]);function aF(e,t){let n=(0,Yn.c)(4),r=t===void 0?!1:t,[i,a]=(0,q.useState)(void 0),o=(0,q.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,q.useEffect)(s,c),i}var oF=300;async function sF(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Server error: ${t.status} ${t.statusText}`);let n=await t.json();if(!n.ok)throw Error(n.error??`Failed to load headings`);return n.headings??[]}var cF=32,lF=6,uF=6,dF=8;function fF(e){return(e-1)*dF+.5}function pF(e){if(e.length===0)return``;let t=[];for(let n=0;n<e.length;n++){let r=fF(e[n].level),i=n*cF+lF,a=n*cF+cF-uF;t.push(`${n===0?`M`:`L`}${r} ${i}`),t.push(`L${r} ${a}`)}return t.join(` `)}var mF=`open-knowledge:outline-nav`;function hF(e){let t=(0,Yn.c)(2),n;return t[0]===e?n=t[1]:(n=(0,K.jsx)(to,{name:`outline-panel`,children:(0,K.jsx)(gF,{...e})}),t[0]=e,t[1]=n),n}function gF(e){let t=(0,Yn.c)(54),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{pages:o,loading:s}=ge(),c=Ue(),{activeProvider:l,activeDocName:u}=zw(),d,f;t[0]===n?(d=t[1],f=t[2]):(d=[`page-headings`,n],f=()=>sF(n),t[0]=n,t[1]=d,t[2]=f);let p;t[3]!==n||t[4]!==s||t[5]!==o?(p=!s&&o.has(n),t[3]=n,t[4]=s,t[5]=o,t[6]=p):p=t[6];let m;t[7]!==d||t[8]!==f||t[9]!==p?(m={queryKey:d,queryFn:f,enabled:p,staleTime:1/0},t[7]=d,t[8]=f,t[9]=p,t[10]=m):m=t[10];let{data:g,isLoading:_,error:v}=ee(m),y;t[11]===g?y=t[12]:(y=g===void 0?[]:g,t[11]=g,t[12]=y);let b=y,x,S;t[13]!==u||t[14]!==l||t[15]!==n||t[16]!==c?(x=()=>{if(!l||u!==n)return;let e=l.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,c.invalidateQueries({queryKey:[`page-headings`,n]})},oF)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},S=[l,u,n,c],t[13]=u,t[14]=l,t[15]=n,t[16]=c,t[17]=x,t[18]=S):(x=t[17],S=t[18]),(0,q.useEffect)(x,S);let C;t[19]===b?C=t[20]:(C=b.map(vF),t[19]=b,t[20]=C);let w=aF(C,r),T;t[21]!==w||t[22]!==b?(T=w?b.findIndex(e=>e.slug===w):-1,t[21]=w,t[22]=b,t[23]=T):T=t[23];let E=T,D;t[24]!==n||t[25]!==r?(D=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&Hw(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(mF,{detail:i}))},t[24]=n,t[25]=r,t[26]=D):D=t[26];let O=D,k=(b.reduce(_F,1)-1)*dF+1,A=b.length*cF,j;t[27]===b?j=t[28]:(j=pF(b),t[27]=b,t[28]=j);let M=j,N=M?`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${k} ${A}"><path d="${M}" stroke="black" stroke-width="2" fill="none" /></svg>`)}")`:void 0,P=E>=0?E*cF+lF:0,F=E>=0?cF-lF-uF:0,I;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,K.jsx)(Ae,{children:`Outline`}),t[29]=I):I=t[29];let L;t[30]!==b.length||t[31]!==_?(L=!_&&(0,K.jsx)(Oe,{children:b.length}),t[30]=b.length,t[31]=_,t[32]=L):L=t[32];let R;t[33]===L?R=t[34]:(R=(0,K.jsxs)(Se,{children:[I,L]}),t[33]=L,t[34]=R);let z;t[35]!==w||t[36]!==v||t[37]!==O||t[38]!==b||t[39]!==_||t[40]!==M||t[41]!==N||t[42]!==A||t[43]!==k||t[44]!==F||t[45]!==P?(z=v?(0,K.jsx)(V,{className:`px-2`,children:v instanceof Error?v.message:`Failed to load headings`}):b.length===0&&!_?(0,K.jsx)(le,{className:`px-2`,children:`No headings yet.`}):(0,K.jsxs)(`nav`,{"aria-label":`Document outline`,className:`relative`,children:[(0,K.jsx)(`svg`,{width:k,height:A,className:`pointer-events-none absolute left-0 top-0`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:M,fill:`none`,strokeWidth:`1`,style:{stroke:`var(--border)`}})}),N&&(0,K.jsx)(`div`,{className:`pointer-events-none absolute left-0 top-0`,style:{width:k,height:A,maskImage:N,WebkitMaskImage:N},children:(0,K.jsx)(`div`,{className:`w-full motion-safe:[transition:transform_0.25s_var(--ease-out-strong),height_0.1s_var(--ease-out-strong)]`,style:{transform:`translateY(${P}px)`,height:F,backgroundColor:`var(--primary)`}})}),b.map((e,t)=>{let n=e.slug===w;return(0,K.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>O(t,e.slug),className:h(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*dF+16}px`},title:e.text,children:e.text},t)})]}),t[35]=w,t[36]=v,t[37]=O,t[38]=b,t[39]=_,t[40]=M,t[41]=N,t[42]=A,t[43]=k,t[44]=F,t[45]=P,t[46]=z):z=t[46];let B;t[47]!==_||t[48]!==z?(B=(0,K.jsx)(be,{className:`px-3 py-2`,"aria-busy":_,children:z}),t[47]=_,t[48]=z,t[49]=B):B=t[49];let te;return t[50]!==a||t[51]!==R||t[52]!==B?(te=(0,K.jsxs)(Me,{className:a,children:[R,B]}),t[50]=a,t[51]=R,t[52]=B,t[53]=te):te=t[53],te}function _F(e,t){return Math.max(e,t.level)}function vF(e){return e.slug}function yF(e){if(!e)return`plaintext`;if(e.types.includes(`vscode-editor-data`))return`vscode`;if(e.types.includes(`text/x-gfm`))return`gfm`;let t=e.getData(`text/html`);return t?/data-pm-slice/i.test(t)?`pm-origin`:/docs-internal-guid-/i.test(t)?`gdocs`:/xmlns:o="urn:schemas-microsoft-com:office/i.test(t)||/<meta[^>]*Generator[^>]*Microsoft Word/i.test(t)?`word`:/class="gmail_|class='gmail_/i.test(t)?`gmail`:/notionvc:/i.test(t)?`notion`:/Cocoa HTML Writer/i.test(t)?`apple`:/c-message_kit__|c-message__|c-compose/i.test(t)?`slack`:/google-sheets-html-origin/i.test(t)?`gsheets`:/data-hovercard-type=/i.test(t)?`github`:`generic`:`plaintext`}var bF=250,xF=100;function SF(e,t){let n=performance.now()-e;n<(t.op===`paste`?bF:xF)||console.warn(JSON.stringify({event:`clipboard-slow-op`,op:t.op,view:t.view,elapsedMs:Math.round(n),branch:t.branch,source:t.source,...t.htmlBytes==null?{}:{htmlBytes:t.htmlBytes}}))}function CF(e){console.warn(JSON.stringify({event:`clipboard-source-detected`,view:e.view,source:e.source,branch:e.branch}))}function wF(e){console.warn(JSON.stringify({event:`clipboard-html-conversion-failed`,view:e.view,stage:e.stage,source:e.source,...e.branch==null?{}:{branch:e.branch},reason:e.reason,...e.errorClass==null?{}:{errorClass:e.errorClass},...e.htmlBytes==null?{}:{htmlBytes:e.htmlBytes}}))}function TF(e){console.warn(JSON.stringify({event:`clipboard-serialize-failed`,view:e.view,kind:e.kind,reason:e.reason}))}function EF(e){console.warn(JSON.stringify({event:`clipboard-chunked-insert-failed`,view:e.view,chunksCompleted:e.chunksCompleted,totalChunks:e.totalChunks,bytesWritten:e.bytesWritten,bytesRemaining:e.bytesRemaining,reason:e.reason}))}function DF(e){if(e instanceof t)return`HtmlPayloadTooLargeError`;if(e instanceof ze)return`ChunkedInsertError`;if(e instanceof Error&&e.name&&e.name!==`Error`)return e.name}var OF=/^```/m,kF=/^#{1,6} /m,AF=/^[-*+] /m,jF=/^\d+[.)] /m,MF=/\[[^\]\n]+\]\([^)\n]+\)/,NF=/^\|.*\|$/m,PF=/^\|?\s*(:?-+:?)(\s*\|\s*:?-+:?)+\s*\|?$/m,FF=/\$\$[\s\S]+?\$\$/;function IF(e){if(!e)return!1;let t=0;OF.test(e)&&t++,kF.test(e)&&t++,AF.test(e)&&t++,jF.test(e)&&t++,MF.test(e)&&t++,NF.test(e)&&PF.test(e)&&t++,FF.test(e)&&t++;let n=e.split(`
78
- `).length,r=Math.min(3,Math.floor(n/5));return t>=Math.max(1,r)}var LF=3e3,RF=new Map;function zF(e,t=`Pasted as plain text — some formatting could not be converted.`){let n=Date.now();return n-(RF.get(e)??0)<LF?!1:(RF.set(e,n),dr.error(t),!0)}var BF=!1,VF=!1;function HF(e){BF=e.shiftKey}function UF(e){(e.key===`Shift`||!e.shiftKey)&&(BF=!1)}function WF(){BF=!1}function GF(){VF||typeof window>`u`||(window.addEventListener(`keydown`,HF,!0),window.addEventListener(`keyup`,UF,!0),window.addEventListener(`blur`,WF,!0),VF=!0)}function KF(){GF()}function qF(){return GF(),BF}function JF(e){return qF()?!0:e.shiftKey===!0}function YF(e){return(t,n)=>{let r=n.clipboardData;if(!r||r.types.length===0)return!1;let i=performance.now(),a=yF(r),o=r.getData(`text/plain`),s=r.getData(`text/html`);if(JF(n))return o&&ZF(t,o),CF({view:`wysiwyg`,branch:`shift`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`shift`,source:a}),!0;if(XF(t))return o&&ZF(t,o),CF({view:`wysiwyg`,branch:`codeblock`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`codeblock`,source:a}),!0;let c=r.getData(`vscode-editor-data`);if(c&&o&&$F(t,c,o,a))return CF({view:`wysiwyg`,branch:`A`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`A`,source:a}),!0;let l=r.getData(`text/x-gfm`);return l&&eI(t,l,e,`B`,a)?(CF({view:`wysiwyg`,branch:`B`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`B`,source:a}),!0):s&&/data-pm-slice/i.test(s)?(CF({view:`wysiwyg`,branch:`C`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`C`,source:a}),!1):o&&s&&IF(o)&&eI(t,o,e,`B`,a)?(CF({view:`wysiwyg`,branch:`B`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`B`,source:a}),!0):s&&tI(t,s,e,a)?(CF({view:`wysiwyg`,branch:`D`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`D`,source:a,htmlBytes:s.length}),!0):o?IF(o)&&eI(t,o,e,`E`,`markdown-text`)?(CF({view:`wysiwyg`,branch:`E`,source:`markdown-text`}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`E`,source:`markdown-text`}),!0):(ZF(t,o),CF({view:`wysiwyg`,branch:`E`,source:`plaintext`}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`E`,source:`plaintext`}),!0):!1}}function XF(e){let{$from:t}=e.state.selection;for(let e=t.depth;e>=0;e--)if(t.node(e).type.name===`codeBlock`)return!0;return!1}function ZF(e,t){let{schema:n,tr:r}=e.state;t&&e.dispatch(r.replaceSelectionWith(n.text(t)).scrollIntoView())}var QF=/^[A-Za-z0-9_+-]+$/;function $F(e,t,n,r){try{let r=JSON.parse(t),i=typeof r.mode==`string`?r.mode:``,a=QF.test(i)?i:``,o=e.state.schema.nodes.codeBlock;if(!o)return!1;let s=o.create({language:a},n?e.state.schema.text(n):null);return e.dispatch(e.state.tr.replaceSelectionWith(s).scrollIntoView()),!0}catch(e){return wF({view:`wysiwyg`,stage:`branchA`,source:r,branch:`A`,reason:e?.message??`unknown`,errorClass:DF(e)}),!1}}function eI(e,t,n,r,i){let a;try{a=n.mdManager.parse(t)}catch(e){return wF({view:`wysiwyg`,stage:`mdManagerParse`,source:i,branch:r,reason:e?.message??`unknown`,errorClass:DF(e)}),!1}return nI(e,a,i,r)}function tI(e,t,n,r){let i;try{i=fe(t)}catch(e){return wF({view:`wysiwyg`,stage:`htmlToMdast`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:DF(e),htmlBytes:t.length}),zF(`wysiwyg`),!1}let a;try{a=v(i)}catch(e){return wF({view:`wysiwyg`,stage:`mdastToMarkdown`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:DF(e),htmlBytes:t.length}),zF(`wysiwyg`),!1}let o;try{o=n.mdManager.parse(a)}catch(e){return wF({view:`wysiwyg`,stage:`mdManagerParse`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:DF(e),htmlBytes:t.length}),zF(`wysiwyg`),!1}return nI(e,o,r,`D`,t.length)}function nI(e,t,n,r,i){try{let n=e.state.schema.nodeFromJSON(t);return e.dispatch(e.state.tr.replaceSelection(n.slice(0,n.content.size)).scrollIntoView()),!0}catch(e){return wF({view:`wysiwyg`,stage:`applyJsonSlice`,source:n,branch:r,reason:e?.message??`unknown`,errorClass:DF(e),...i==null?{}:{htmlBytes:i}}),!1}}function rI(e){return(t,n)=>{try{return oI(t,n.state.schema,e.mdManager)}catch(e){return console.warn(`[clipboard] text serialize fell through — PM default textBetween`,e),t.content.textBetween(0,t.content.size,`
77
+ `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new tP(this):new YN(this)}getCursor(e,t=0,n){let r=e.doc?e:et.create({doc:e});return n??=r.doc.length,this.regexp?ZN(this,r,t,n):qN(this,r,t,n)}},GN=class{constructor(e){this.spec=e}};function KN(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function qN(e,t,n,r){let i;return e.wholeWord&&(i=JN(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=KN(e.test,t,i)),new xN(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function JN(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(QN(i,n-a))!=Xe.Word||t($N(i,n-a))!=Xe.Word)&&(t($N(i,r-a))!=Xe.Word||t(QN(i,r-a))!=Xe.Word))}var YN=class extends GN{constructor(e){super(e)}nextMatch(e,t,n){let r=qN(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=qN(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=qN(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=qN(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=qN(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function XN(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function ZN(e,t,n,r){let i;return e.wholeWord&&(i=eP(t.charCategorizer(t.selection.main.head))),e.test&&(i=XN(e.test,t,i)),new wN(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function QN(e,t){return e.slice(St(e,t,!1),t)}function $N(e,t){return e.slice(t,St(e,t))}function eP(e){return(t,n,r)=>!r[0].length||(e(QN(r.input,r.index))!=Xe.Word||e($N(r.input,r.index))!=Xe.Word)&&(e($N(r.input,r.index+r[0].length))!=Xe.Word||e(QN(r.input,r.index+r[0].length))!=Xe.Word)}var tP=class extends GN{nextMatch(e,t,n){let r=ZN(this.spec,e,n,e.doc.length).next();return r.done&&(r=ZN(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=ZN(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=ZN(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=ZN(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},nP=ft.define(),rP=ft.define(),iP=mt.define({create(e){return new aP(_P(e).create(),null)},update(e,t){for(let n of t.effects)n.is(nP)?e=new aP(n.value.create(),e.panel):n.is(rP)&&(e=new aP(e.query,n.value?gP:null));return e},provide:e=>Lt.from(e,e=>e.panel)}),aP=class{constructor(e,t){this.query=e,this.panel=t}},oP=en.mark({class:`cm-searchMatch`}),sP=en.mark({class:`cm-searchMatch cm-searchMatch-selected`}),cP=Tt.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(iP))}update(e){let t=e.state.field(iP);(t!=e.startState.field(iP)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return en.none;let{view:n}=this,r=new Ht;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?sP:oP)})}return r.finish()}},{decorations:e=>e.decorations});function lP(e){return t=>{let n=t.state.field(iP,!1);return n&&n.query.spec.valid?e(t,n):bP(t)}}var uP=lP((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=G.single(r.from,r.to),a=e.state.facet(UN);return e.dispatch({selection:i,effects:[DP(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),yP(e),!0}),dP=lP((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=G.single(i.from,i.to),o=e.state.facet(UN);return e.dispatch({selection:a,effects:[DP(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),yP(e),!0}),fP=lP((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:G.create(n.map(e=>G.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),pP=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new xN(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(G.range(t.value.from,t.value.to))}return t(e.update({selection:G.create(a,o),userEvent:`select.search.matches`})),!0},mP=lP((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(wt.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=G.single(o.from,o.to).map(d),u.push(DP(e,o)),u.push(n.facet(UN).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),hP=lP((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:wt.announce.of(r),userEvent:`input.replace.all`}),!0});function gP(e){return e.state.facet(UN).createPanel(e)}function _P(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(UN);return new WN({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function vP(e){let t=Yt(e,gP);return t&&t.dom.querySelector(`[main-field]`)}function yP(e){let t=vP(e);t&&t==e.root.activeElement&&t.select()}var bP=e=>{let t=e.state.field(iP,!1);if(t&&t.panel){let n=vP(e);if(n&&n!=e.root.activeElement){let r=_P(e.state,t.query.spec);r.valid&&e.dispatch({effects:nP.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[rP.of(!0),t?nP.of(_P(e.state,t.query.spec)):ft.appendConfig.of(kP)]});return!0},xP=e=>{let t=e.state.field(iP,!1);if(!t||!t.panel)return!1;let n=Yt(e,gP);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:rP.of(!1)}),!0},SP=[{key:`Mod-f`,run:bP,scope:`editor search-panel`},{key:`F3`,run:uP,shift:dP,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:uP,shift:dP,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:xP,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:pP},{key:`Mod-Alt-g`,run:AN},{key:`Mod-d`,run:HN,preventDefault:!0}],CP=class{constructor(e){this.view=e;let t=this.query=e.state.field(iP).query.spec;this.commit=this.commit.bind(this),this.searchField=un(`input`,{value:t.search,placeholder:wP(e,`Find`),"aria-label":wP(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=un(`input`,{value:t.replace,placeholder:wP(e,`Replace`),"aria-label":wP(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=un(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=un(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=un(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return un(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=un(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>uP(e),[wP(e,`next`)]),n(`prev`,()=>dP(e),[wP(e,`previous`)]),n(`select`,()=>fP(e),[wP(e,`all`)]),un(`label`,null,[this.caseField,wP(e,`match case`)]),un(`label`,null,[this.reField,wP(e,`regexp`)]),un(`label`,null,[this.wordField,wP(e,`by word`)]),...e.state.readOnly?[]:[un(`br`),this.replaceField,n(`replace`,()=>mP(e),[wP(e,`replace`)]),n(`replaceAll`,()=>hP(e),[wP(e,`replace all`)])],un(`button`,{name:`close`,onclick:()=>xP(e),"aria-label":wP(e,`close`),type:`button`},[`×`])])}commit(){let e=new WN({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:nP.of(e)}))}keydown(e){qt(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?dP:uP)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),mP(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(nP)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(UN).top}};function wP(e,t){return e.state.phrase(t)}var TP=30,EP=/[\s\.,:;?!]/;function DP(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-TP),o=Math.min(i,n+TP),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<TP;e++)if(!EP.test(s[e+1])&&EP.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-TP;e--)if(!EP.test(s[e-1])&&EP.test(s[e])){s=s.slice(0,e);break}}return wt.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var OP=wt.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),kP=[iP,Wt.low(cP),OP],AP=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},jP=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(GP).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Ht,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=nF(s);if(i)o.add(n,n,en.widget({widget:new YP(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,en.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,MP(f))}};function MP(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new AP(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new AP(r.from,n,r.diagnostic)}),r}function NP(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(GP).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(FP))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function PP(e,t){return e.field(RP,!1)?t:t.concat(ft.appendConfig.of(rF))}var FP=ft.define(),IP=ft.define(),LP=ft.define(),RP=mt.define({create(){return new jP(en.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=MP(n,e.selected.diagnostic,i)||MP(n,null,i)}!n.size&&i&&t.state.facet(GP).autoPanel&&(i=null),e=new jP(n,i,r)}for(let n of t.effects)if(n.is(FP)){let r=t.state.facet(GP).autoPanel?n.value.length?ZP.open:null:e.panel;e=jP.init(n.value,r,t.state)}else n.is(IP)?e=new jP(e.diagnostics,n.value?ZP.open:null,e.selected):n.is(LP)&&(e=new jP(e.diagnostics,e.panel,n.value));return e},provide:e=>[Lt.from(e,e=>e.panel),wt.decorations.from(e,e=>e.diagnostics)]}),zP=en.mark({class:`cm-lintRange cm-lintRange-active`});function BP(e,t,n){let{diagnostics:r}=e.state.field(RP),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(GP).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:VP(e,i)}}}:null}function VP(e,t){return un(`ul`,{class:`cm-tooltip-lint`},t.map(t=>JP(e,t,!1)))}var HP=e=>{let t=e.state.field(RP,!1);(!t||!t.panel)&&e.dispatch({effects:PP(e.state,[IP.of(!0)])});let n=Yt(e,ZP.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},UP=e=>{let t=e.state.field(RP,!1);return!t||!t.panel?!1:(e.dispatch({effects:IP.of(!1)}),!0)},WP=[{key:`Mod-Shift-m`,run:HP,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(RP,!1);if(!t)return!1;let n=e.state.selection.main,r=MP(t.diagnostics,null,n.to+1);return!r&&(r=MP(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],GP=Qe.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...gn(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:KP,tooltipFilter:KP,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function KP(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function qP(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function JP(e,t,n){let r=n?qP(t.actions):[];return un(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},un(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=MP(e.state.field(RP).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),un(`u`,s.slice(c,c+1)),s.slice(c+1)];return un(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&un(`div`,{class:`cm-diagnosticSource`},t.source))}var YP=class extends ht{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return un(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},XP=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=JP(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},ZP=class e{constructor(e){this.view=e,this.items=[],this.list=un(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)UP(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=qP(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=MP(this.view.state.field(RP).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=un(`div`,{class:`cm-panel-lint`},this.list,un(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>UP(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(RP).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(RP),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new XP(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new XP(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=MP(this.view.state.field(RP).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:LP.of(t)})}static open(t){return new e(t)}};function QP(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function $P(e){return QP(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var eF=wt.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:$P(`#d11`)},".cm-lintRange-warning":{backgroundImage:$P(`orange`)},".cm-lintRange-info":{backgroundImage:$P(`#999`)},".cm-lintRange-hint":{backgroundImage:$P(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function tF(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function nF(e){let t=`hint`,n=1;for(let r of e){let e=tF(r.severity);e>n&&(n=e,t=r.severity)}return t}var rF=[RP,wt.decorations.compute([RP],e=>{let{selected:t,panel:n}=e.field(RP);return!t||!n||t.from==t.to?en.none:en.set([zP.range(t.from,t.to)])}),Mt(BP,{hideOn:NP}),eF],iF=[cn(),Zt(),rn(),dj(),It(),Pt(),on(),et.allowMultipleSelections.of(!0),yt(),ut(Nt,{fallback:!0}),jt(),Sn(),bn(),$t(),Ke(),Ot(),NN(),Kt.of([...yn,...vN,...SP,...Aj,...ln,...xn,...WP])];rn(),dj(),Pt(),ut(Nt,{fallback:!0}),Kt.of([...vN,...Aj]);function aF(e,t){let n=(0,Yn.c)(4),r=t===void 0?!1:t,[i,a]=(0,q.useState)(void 0),o=(0,q.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,q.useEffect)(s,c),i}var oF=300;async function sF(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Server error: ${t.status} ${t.statusText}`);let n=await t.json();if(!n.ok)throw Error(n.error??`Failed to load headings`);return n.headings??[]}var cF=32,lF=6,uF=6,dF=8;function fF(e){return(e-1)*dF+.5}function pF(e){if(e.length===0)return``;let t=[];for(let n=0;n<e.length;n++){let r=fF(e[n].level),i=n*cF+lF,a=n*cF+cF-uF;t.push(`${n===0?`M`:`L`}${r} ${i}`),t.push(`L${r} ${a}`)}return t.join(` `)}var mF=`open-knowledge:outline-nav`;function hF(e){let t=(0,Yn.c)(2),n;return t[0]===e?n=t[1]:(n=(0,K.jsx)(to,{name:`outline-panel`,children:(0,K.jsx)(gF,{...e})}),t[0]=e,t[1]=n),n}function gF(e){let t=(0,Yn.c)(54),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{pages:o,loading:s}=xe(),c=He(),{activeProvider:l,activeDocName:u}=zw(),d,f;t[0]===n?(d=t[1],f=t[2]):(d=[`page-headings`,n],f=()=>sF(n),t[0]=n,t[1]=d,t[2]=f);let p;t[3]!==n||t[4]!==s||t[5]!==o?(p=!s&&o.has(n),t[3]=n,t[4]=s,t[5]=o,t[6]=p):p=t[6];let m;t[7]!==d||t[8]!==f||t[9]!==p?(m={queryKey:d,queryFn:f,enabled:p,staleTime:1/0},t[7]=d,t[8]=f,t[9]=p,t[10]=m):m=t[10];let{data:h,isLoading:g,error:_}=We(m),v;t[11]===h?v=t[12]:(v=h===void 0?[]:h,t[11]=h,t[12]=v);let y=v,b,x;t[13]!==u||t[14]!==l||t[15]!==n||t[16]!==c?(b=()=>{if(!l||u!==n)return;let e=l.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,c.invalidateQueries({queryKey:[`page-headings`,n]})},oF)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},x=[l,u,n,c],t[13]=u,t[14]=l,t[15]=n,t[16]=c,t[17]=b,t[18]=x):(b=t[17],x=t[18]),(0,q.useEffect)(b,x);let S;t[19]===y?S=t[20]:(S=y.map(vF),t[19]=y,t[20]=S);let C=aF(S,r),w;t[21]!==C||t[22]!==y?(w=C?y.findIndex(e=>e.slug===C):-1,t[21]=C,t[22]=y,t[23]=w):w=t[23];let T=w,E;t[24]!==n||t[25]!==r?(E=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&Hw(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(mF,{detail:i}))},t[24]=n,t[25]=r,t[26]=E):E=t[26];let D=E,O=(y.reduce(_F,1)-1)*dF+1,k=y.length*cF,A;t[27]===y?A=t[28]:(A=pF(y),t[27]=y,t[28]=A);let M=A,N=M?`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O} ${k}"><path d="${M}" stroke="black" stroke-width="2" fill="none" /></svg>`)}")`:void 0,P=T>=0?T*cF+lF:0,F=T>=0?cF-lF-uF:0,I;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,K.jsx)(Pe,{children:`Outline`}),t[29]=I):I=t[29];let L;t[30]!==y.length||t[31]!==g?(L=!g&&(0,K.jsx)(Me,{children:y.length}),t[30]=y.length,t[31]=g,t[32]=L):L=t[32];let R;t[33]===L?R=t[34]:(R=(0,K.jsxs)(Ee,{children:[I,L]}),t[33]=L,t[34]=R);let z;t[35]!==C||t[36]!==_||t[37]!==D||t[38]!==y||t[39]!==g||t[40]!==M||t[41]!==N||t[42]!==k||t[43]!==O||t[44]!==F||t[45]!==P?(z=_?(0,K.jsx)(te,{className:`px-2`,children:_ instanceof Error?_.message:`Failed to load headings`}):y.length===0&&!g?(0,K.jsx)(he,{className:`px-2`,children:`No headings yet.`}):(0,K.jsxs)(`nav`,{"aria-label":`Document outline`,className:`relative`,children:[(0,K.jsx)(`svg`,{width:O,height:k,className:`pointer-events-none absolute left-0 top-0`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:M,fill:`none`,strokeWidth:`1`,style:{stroke:`var(--border)`}})}),N&&(0,K.jsx)(`div`,{className:`pointer-events-none absolute left-0 top-0`,style:{width:O,height:k,maskImage:N,WebkitMaskImage:N},children:(0,K.jsx)(`div`,{className:`w-full motion-safe:[transition:transform_0.25s_var(--ease-out-strong),height_0.1s_var(--ease-out-strong)]`,style:{transform:`translateY(${P}px)`,height:F,backgroundColor:`var(--primary)`}})}),y.map((e,t)=>{let n=e.slug===C;return(0,K.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>D(t,e.slug),className:j(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*dF+16}px`},title:e.text,children:e.text},t)})]}),t[35]=C,t[36]=_,t[37]=D,t[38]=y,t[39]=g,t[40]=M,t[41]=N,t[42]=k,t[43]=O,t[44]=F,t[45]=P,t[46]=z):z=t[46];let B;t[47]!==g||t[48]!==z?(B=(0,K.jsx)(Te,{className:`px-3 py-2`,"aria-busy":g,children:z}),t[47]=g,t[48]=z,t[49]=B):B=t[49];let V;return t[50]!==a||t[51]!==R||t[52]!==B?(V=(0,K.jsxs)(Ie,{className:a,children:[R,B]}),t[50]=a,t[51]=R,t[52]=B,t[53]=V):V=t[53],V}function _F(e,t){return Math.max(e,t.level)}function vF(e){return e.slug}function yF(e){if(!e)return`plaintext`;if(e.types.includes(`vscode-editor-data`))return`vscode`;if(e.types.includes(`text/x-gfm`))return`gfm`;let t=e.getData(`text/html`);return t?/data-pm-slice/i.test(t)?`pm-origin`:/docs-internal-guid-/i.test(t)?`gdocs`:/xmlns:o="urn:schemas-microsoft-com:office/i.test(t)||/<meta[^>]*Generator[^>]*Microsoft Word/i.test(t)?`word`:/class="gmail_|class='gmail_/i.test(t)?`gmail`:/notionvc:/i.test(t)?`notion`:/Cocoa HTML Writer/i.test(t)?`apple`:/c-message_kit__|c-message__|c-compose/i.test(t)?`slack`:/google-sheets-html-origin/i.test(t)?`gsheets`:/data-hovercard-type=/i.test(t)?`github`:`generic`:`plaintext`}var bF=250,xF=100;function SF(e,t){let n=performance.now()-e;n<(t.op===`paste`?bF:xF)||console.warn(JSON.stringify({event:`clipboard-slow-op`,op:t.op,view:t.view,elapsedMs:Math.round(n),branch:t.branch,source:t.source,...t.htmlBytes==null?{}:{htmlBytes:t.htmlBytes}}))}function CF(e){console.warn(JSON.stringify({event:`clipboard-source-detected`,view:e.view,source:e.source,branch:e.branch}))}function wF(e){console.warn(JSON.stringify({event:`clipboard-html-conversion-failed`,view:e.view,stage:e.stage,source:e.source,...e.branch==null?{}:{branch:e.branch},reason:e.reason,...e.errorClass==null?{}:{errorClass:e.errorClass},...e.htmlBytes==null?{}:{htmlBytes:e.htmlBytes}}))}function TF(e){console.warn(JSON.stringify({event:`clipboard-serialize-failed`,view:e.view,kind:e.kind,reason:e.reason}))}function EF(e){console.warn(JSON.stringify({event:`clipboard-chunked-insert-failed`,view:e.view,chunksCompleted:e.chunksCompleted,totalChunks:e.totalChunks,bytesWritten:e.bytesWritten,bytesRemaining:e.bytesRemaining,reason:e.reason}))}function DF(e){if(e instanceof b)return`HtmlPayloadTooLargeError`;if(e instanceof s)return`ChunkedInsertError`;if(e instanceof Error&&e.name&&e.name!==`Error`)return e.name}var OF=/^```/m,kF=/^#{1,6} /m,AF=/^[-*+] /m,jF=/^\d+[.)] /m,MF=/\[[^\]\n]+\]\([^)\n]+\)/,NF=/^\|.*\|$/m,PF=/^\|?\s*(:?-+:?)(\s*\|\s*:?-+:?)+\s*\|?$/m,FF=/\$\$[\s\S]+?\$\$/;function IF(e){if(!e)return!1;let t=0;OF.test(e)&&t++,kF.test(e)&&t++,AF.test(e)&&t++,jF.test(e)&&t++,MF.test(e)&&t++,NF.test(e)&&PF.test(e)&&t++,FF.test(e)&&t++;let n=e.split(`
78
+ `).length,r=Math.min(3,Math.floor(n/5));return t>=Math.max(1,r)}var LF=3e3,RF=new Map;function zF(e,t=`Pasted as plain text — some formatting could not be converted.`){let n=Date.now();return n-(RF.get(e)??0)<LF?!1:(RF.set(e,n),dr.error(t),!0)}var BF=!1,VF=!1;function HF(e){BF=e.shiftKey}function UF(e){(e.key===`Shift`||!e.shiftKey)&&(BF=!1)}function WF(){BF=!1}function GF(){VF||typeof window>`u`||(window.addEventListener(`keydown`,HF,!0),window.addEventListener(`keyup`,UF,!0),window.addEventListener(`blur`,WF,!0),VF=!0)}function KF(){GF()}function qF(){return GF(),BF}function JF(e){return qF()?!0:e.shiftKey===!0}function YF(e){return(t,n)=>{let r=n.clipboardData;if(!r||r.types.length===0)return!1;let i=performance.now(),a=yF(r),o=r.getData(`text/plain`),s=r.getData(`text/html`);if(JF(n))return o&&ZF(t,o),CF({view:`wysiwyg`,branch:`shift`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`shift`,source:a}),!0;if(XF(t))return o&&ZF(t,o),CF({view:`wysiwyg`,branch:`codeblock`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`codeblock`,source:a}),!0;let c=r.getData(`vscode-editor-data`);if(c&&o&&$F(t,c,o,a))return CF({view:`wysiwyg`,branch:`A`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`A`,source:a}),!0;let l=r.getData(`text/x-gfm`);return l&&eI(t,l,e,`B`,a)?(CF({view:`wysiwyg`,branch:`B`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`B`,source:a}),!0):s&&/data-pm-slice/i.test(s)?(CF({view:`wysiwyg`,branch:`C`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`C`,source:a}),!1):o&&s&&IF(o)&&eI(t,o,e,`B`,a)?(CF({view:`wysiwyg`,branch:`B`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`B`,source:a}),!0):s&&tI(t,s,e,a)?(CF({view:`wysiwyg`,branch:`D`,source:a}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`D`,source:a,htmlBytes:s.length}),!0):o?IF(o)&&eI(t,o,e,`E`,`markdown-text`)?(CF({view:`wysiwyg`,branch:`E`,source:`markdown-text`}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`E`,source:`markdown-text`}),!0):(ZF(t,o),CF({view:`wysiwyg`,branch:`E`,source:`plaintext`}),SF(i,{op:`paste`,view:`wysiwyg`,branch:`E`,source:`plaintext`}),!0):!1}}function XF(e){let{$from:t}=e.state.selection;for(let e=t.depth;e>=0;e--)if(t.node(e).type.name===`codeBlock`)return!0;return!1}function ZF(e,t){let{schema:n,tr:r}=e.state;t&&e.dispatch(r.replaceSelectionWith(n.text(t)).scrollIntoView())}var QF=/^[A-Za-z0-9_+-]+$/;function $F(e,t,n,r){try{let r=JSON.parse(t),i=typeof r.mode==`string`?r.mode:``,a=QF.test(i)?i:``,o=e.state.schema.nodes.codeBlock;if(!o)return!1;let s=o.create({language:a},n?e.state.schema.text(n):null);return e.dispatch(e.state.tr.replaceSelectionWith(s).scrollIntoView()),!0}catch(e){return wF({view:`wysiwyg`,stage:`branchA`,source:r,branch:`A`,reason:e?.message??`unknown`,errorClass:DF(e)}),!1}}function eI(e,t,n,r,i){let a;try{a=n.mdManager.parse(t)}catch(e){return wF({view:`wysiwyg`,stage:`mdManagerParse`,source:i,branch:r,reason:e?.message??`unknown`,errorClass:DF(e)}),!1}return nI(e,a,i,r)}function tI(e,t,n,r){let i;try{i=S(t)}catch(e){return wF({view:`wysiwyg`,stage:`htmlToMdast`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:DF(e),htmlBytes:t.length}),zF(`wysiwyg`),!1}let a;try{a=E(i)}catch(e){return wF({view:`wysiwyg`,stage:`mdastToMarkdown`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:DF(e),htmlBytes:t.length}),zF(`wysiwyg`),!1}let o;try{o=n.mdManager.parse(a)}catch(e){return wF({view:`wysiwyg`,stage:`mdManagerParse`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:DF(e),htmlBytes:t.length}),zF(`wysiwyg`),!1}return nI(e,o,r,`D`,t.length)}function nI(e,t,n,r,i){try{let n=e.state.schema.nodeFromJSON(t);return e.dispatch(e.state.tr.replaceSelection(n.slice(0,n.content.size)).scrollIntoView()),!0}catch(e){return wF({view:`wysiwyg`,stage:`applyJsonSlice`,source:n,branch:r,reason:e?.message??`unknown`,errorClass:DF(e),...i==null?{}:{htmlBytes:i}}),!1}}function rI(e){return(t,n)=>{try{return oI(t,n.state.schema,e.mdManager)}catch(e){return console.warn(`[clipboard] text serialize fell through — PM default textBetween`,e),t.content.textBetween(0,t.content.size,`
79
79
 
80
- `)}}}var iI=class extends y{mdManager;constructor(e){super({},{}),this.mdManager=e}serializeFragment(e,t,n){try{let t=e.firstChild?.type.schema;if(!t)return n??document.createDocumentFragment();let r=lI(sI(e,t,this.mdManager));if(n){for(let e of Array.from(r.childNodes))n.appendChild(e);return n}return r}catch(e){return console.warn(`[clipboard] HTML serialize fell through — PM default DOMSerializer`,e),n??document.createDocumentFragment()}}};function aI(e){return new iI(e.mdManager)}function oI(e,t,n){return n.serialize(cI(e,t))}function sI(e,t,n){return c(oI(new d(e,0,0),t,n))}function cI(e,t){let n=t.topNodeType.createAndFill(null,e.content);if(!n){let e=t.topNodeType.createAndFill();if(!e)throw Error(`[clipboard] schema cannot fill topNodeType`);return e.toJSON()}return n.toJSON()}function lI(e){let t=new DOMParser().parseFromString(e,`text/html`),n=document.createDocumentFragment();for(let e of Array.from(t.body.childNodes))n.appendChild(e);return n}function uI(e){return KF(),wt.domEventHandlers({copy:(e,t)=>dI(e,t,`copy`),cut:(e,t)=>dI(e,t,`cut`),paste:(t,n)=>fI(t,n,e)})}function dI(e,t,n){let{from:r,to:i}=t.state.selection.main;if(r===i)return e.preventDefault(),!0;let a=e.clipboardData;if(!a)return!1;let o=performance.now();try{let s=t.state.sliceDoc(r,i);a.setData(`text/plain`,s);try{a.setData(`text/html`,c(s))}catch(e){TF({view:`source`,kind:`html`,reason:e?.message??`unknown`})}return e.preventDefault(),n===`cut`&&t.dispatch({changes:{from:r,to:i,insert:``}}),SF(o,{op:n,view:`source`,branch:`serialize`,source:`local`}),!0}catch(e){return TF({view:`source`,kind:`text`,reason:e?.message??`unknown`}),!1}}function fI(e,t,n){let r=e.clipboardData;if(!r||r.types.length===0)return!1;let i=performance.now(),a=yF(r),o=r.getData(`text/plain`),s=r.getData(`text/html`);if(JF(e))return CF({view:`source`,branch:`shift`,source:a}),SF(i,{op:`paste`,view:`source`,branch:`shift`,source:a}),!1;let c=r.getData(`vscode-editor-data`);return c&&o&&mI(t,c,o,a)?(e.preventDefault(),CF({view:`source`,branch:`A`,source:a}),SF(i,{op:`paste`,view:`source`,branch:`A`,source:a}),!0):s&&/data-pm-slice/i.test(s)?(CF({view:`source`,branch:`C`,source:a}),SF(i,{op:`paste`,view:`source`,branch:`C`,source:a}),!1):s&&hI(t,s,n,a)?(e.preventDefault(),CF({view:`source`,branch:`D`,source:a}),SF(i,{op:`paste`,view:`source`,branch:`D`,source:a,htmlBytes:s.length}),!0):(CF({view:`source`,branch:`E`,source:a}),SF(i,{op:`paste`,view:`source`,branch:`E`,source:a}),!1)}var pI=/^[A-Za-z0-9_+-]+$/;function mI(e,t,n,r){try{let r=JSON.parse(t),i=typeof r.mode==`string`?r.mode:``,a=`\`\`\`${pI.test(i)?i:``}\n${n}\n\`\`\`\n`,{from:o,to:s}=e.state.selection.main;return e.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}}),!0}catch(e){return wF({view:`source`,stage:`branchA`,source:r,branch:`A`,reason:e?.message??`unknown`,errorClass:DF(e)}),!1}}function hI(e,t,n,r){let i;try{i=fe(t)}catch(e){return wF({view:`source`,stage:`htmlToMdast`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:DF(e),htmlBytes:t.length}),!1}let a;try{a=v(i)}catch(e){return wF({view:`source`,stage:`mdastToMarkdown`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:DF(e),htmlBytes:t.length}),!1}let{from:o,to:s}=e.state.selection.main;if(!(a.length>500*1024))return e.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}}),!0;let c=o===s?``:e.state.sliceDoc(o,s);o!==s&&e.dispatch({changes:{from:o,to:s,insert:``}});let l=o,u=op(n.ytext,l);return O(n.ydoc,n.ytext,l,a,{resolveOffset:e=>{let t=cp(u,n.ydoc);return t==null?e:t.index+(e-l)}}).catch(i=>{gI({view:e,source:r,html:t,restoreText:c,anchorIndex:l,anchorRelPos:u,ydoc:n.ydoc,err:i})}),!0}function gI(e){let{view:t,source:n,html:r,restoreText:i,anchorIndex:a,anchorRelPos:o,ydoc:s,err:c}=e;if(c instanceof ze&&c.bytesWritten>0){let e=o&&s?cp(o,s)?.index??a:a,n=Math.min(e+c.bytesWritten,t.state.doc.length);try{t.dispatch({changes:{from:e,to:n,insert:i}})}catch(e){console.warn(`[clipboard] partial-chunk rollback dispatch failed`,e)}}else if(i.length>0)try{t.dispatch({changes:{from:a,to:a,insert:i}})}catch(e){console.warn(`[clipboard] selection-restore dispatch failed`,e)}if(c instanceof ze){EF({view:`source`,chunksCompleted:c.chunksCompleted,totalChunks:c.totalChunks,bytesWritten:c.bytesWritten,bytesRemaining:c.bytesRemaining,reason:c.message}),dr.error(`Paste was incomplete — ${c.chunksCompleted} of ${c.totalChunks} chunks landed. Your selection has been restored.`);return}wF({view:`source`,stage:`chunkedYTextInsert`,source:n,branch:`D`,reason:c?.message??`unknown`,errorClass:DF(c),htmlBytes:r.length}),dr.error(`Paste failed. Your selection has been restored.`)}export{Tb as $,Ln as $t,$C as A,to as At,gS as B,ea as Bt,aw as C,cu as Ct,yw as D,vs as Dt,nw as E,ps as Et,iC as F,Ka as Ft,Qx as G,Jn as Gt,uS as H,jr as Ht,$S as I,Ga as It,rS as J,Wn as Jt,aS as K,qn as Kt,QS as L,Wa as Lt,YC as M,Xa as Mt,MC as N,qa as Nt,hw as O,gs as Ot,aC as P,Ya as Pt,Ob as Q,zn as Qt,ES as R,Ja as Rt,Bw as S,Ad as St,rw as T,Xs as Tt,lS as U,Er as Ut,mS as V,Wr as Vt,cS as W,dr as Wt,Gb as X,Vn as Xt,ix as Y,Hn as Yt,Ub as Z,Bn as Zt,Ww as _,cp as _t,mF as a,u_ as at,Iw as b,tp as bt,yN as c,v_ as ct,FA as d,__ as dt,In as en,kb as et,xA as f,i_ as ft,_E as g,lp as gt,kO as h,Lp as ht,YF as i,Mn as in,S_ as it,XC as j,J as jt,QC as k,oo as kt,JA as l,g_ as lt,jk as m,yf as mt,aI as n,Pn as nn,Lb as nt,hF as o,f_ as ot,lA as p,Qh as pt,nS as q,Gn as qt,rI as r,Nn as rn,gb as rt,iF as s,m_ as st,uI as t,Fn as tn,Eb as tt,GA as u,h_ as ut,Uw as v,np as vt,iw as w,Zs as wt,zw as x,kd as xt,Hw as y,op as yt,wS as z,la as zt};
80
+ `)}}}var iI=class extends D{mdManager;constructor(e){super({},{}),this.mdManager=e}serializeFragment(e,t,n){try{let t=e.firstChild?.type.schema;if(!t)return n??document.createDocumentFragment();let r=lI(sI(e,t,this.mdManager));if(n){for(let e of Array.from(r.childNodes))n.appendChild(e);return n}return r}catch(e){return console.warn(`[clipboard] HTML serialize fell through — PM default DOMSerializer`,e),n??document.createDocumentFragment()}}};function aI(e){return new iI(e.mdManager)}function oI(e,t,n){return n.serialize(cI(e,t))}function sI(e,t,n){return w(oI(new y(e,0,0),t,n))}function cI(e,t){let n=t.topNodeType.createAndFill(null,e.content);if(!n){let e=t.topNodeType.createAndFill();if(!e)throw Error(`[clipboard] schema cannot fill topNodeType`);return e.toJSON()}return n.toJSON()}function lI(e){let t=new DOMParser().parseFromString(e,`text/html`),n=document.createDocumentFragment();for(let e of Array.from(t.body.childNodes))n.appendChild(e);return n}function uI(e){return KF(),wt.domEventHandlers({copy:(e,t)=>dI(e,t,`copy`),cut:(e,t)=>dI(e,t,`cut`),paste:(t,n)=>fI(t,n,e)})}function dI(e,t,n){let{from:r,to:i}=t.state.selection.main;if(r===i)return e.preventDefault(),!0;let a=e.clipboardData;if(!a)return!1;let o=performance.now();try{let s=t.state.sliceDoc(r,i);a.setData(`text/plain`,s);try{a.setData(`text/html`,w(s))}catch(e){TF({view:`source`,kind:`html`,reason:e?.message??`unknown`})}return e.preventDefault(),n===`cut`&&t.dispatch({changes:{from:r,to:i,insert:``}}),SF(o,{op:n,view:`source`,branch:`serialize`,source:`local`}),!0}catch(e){return TF({view:`source`,kind:`text`,reason:e?.message??`unknown`}),!1}}function fI(e,t,n){let r=e.clipboardData;if(!r||r.types.length===0)return!1;let i=performance.now(),a=yF(r),o=r.getData(`text/plain`),s=r.getData(`text/html`);if(JF(e))return CF({view:`source`,branch:`shift`,source:a}),SF(i,{op:`paste`,view:`source`,branch:`shift`,source:a}),!1;let c=r.getData(`vscode-editor-data`);return c&&o&&mI(t,c,o,a)?(e.preventDefault(),CF({view:`source`,branch:`A`,source:a}),SF(i,{op:`paste`,view:`source`,branch:`A`,source:a}),!0):s&&/data-pm-slice/i.test(s)?(CF({view:`source`,branch:`C`,source:a}),SF(i,{op:`paste`,view:`source`,branch:`C`,source:a}),!1):s&&hI(t,s,n,a)?(e.preventDefault(),CF({view:`source`,branch:`D`,source:a}),SF(i,{op:`paste`,view:`source`,branch:`D`,source:a,htmlBytes:s.length}),!0):(CF({view:`source`,branch:`E`,source:a}),SF(i,{op:`paste`,view:`source`,branch:`E`,source:a}),!1)}var pI=/^[A-Za-z0-9_+-]+$/;function mI(e,t,n,r){try{let r=JSON.parse(t),i=typeof r.mode==`string`?r.mode:``,a=`\`\`\`${pI.test(i)?i:``}\n${n}\n\`\`\`\n`,{from:o,to:s}=e.state.selection.main;return e.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}}),!0}catch(e){return wF({view:`source`,stage:`branchA`,source:r,branch:`A`,reason:e?.message??`unknown`,errorClass:DF(e)}),!1}}function hI(e,t,n,r){let i;try{i=S(t)}catch(e){return wF({view:`source`,stage:`htmlToMdast`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:DF(e),htmlBytes:t.length}),!1}let o;try{o=E(i)}catch(e){return wF({view:`source`,stage:`mdastToMarkdown`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:DF(e),htmlBytes:t.length}),!1}let{from:s,to:c}=e.state.selection.main;if(!(o.length>500*1024))return e.dispatch({changes:{from:s,to:c,insert:o},selection:{anchor:s+o.length}}),!0;let l=s===c?``:e.state.sliceDoc(s,c);s!==c&&e.dispatch({changes:{from:s,to:c,insert:``}});let u=s,d=op(n.ytext,u);return a(n.ydoc,n.ytext,u,o,{resolveOffset:e=>{let t=cp(d,n.ydoc);return t==null?e:t.index+(e-u)}}).catch(i=>{gI({view:e,source:r,html:t,restoreText:l,anchorIndex:u,anchorRelPos:d,ydoc:n.ydoc,err:i})}),!0}function gI(e){let{view:t,source:n,html:r,restoreText:i,anchorIndex:a,anchorRelPos:o,ydoc:c,err:l}=e;if(l instanceof s&&l.bytesWritten>0){let e=o&&c?cp(o,c)?.index??a:a,n=Math.min(e+l.bytesWritten,t.state.doc.length);try{t.dispatch({changes:{from:e,to:n,insert:i}})}catch(e){console.warn(`[clipboard] partial-chunk rollback dispatch failed`,e)}}else if(i.length>0)try{t.dispatch({changes:{from:a,to:a,insert:i}})}catch(e){console.warn(`[clipboard] selection-restore dispatch failed`,e)}if(l instanceof s){EF({view:`source`,chunksCompleted:l.chunksCompleted,totalChunks:l.totalChunks,bytesWritten:l.bytesWritten,bytesRemaining:l.bytesRemaining,reason:l.message}),dr.error(`Paste was incomplete — ${l.chunksCompleted} of ${l.totalChunks} chunks landed. Your selection has been restored.`);return}wF({view:`source`,stage:`chunkedYTextInsert`,source:n,branch:`D`,reason:l?.message??`unknown`,errorClass:DF(l),htmlBytes:r.length}),dr.error(`Paste failed. Your selection has been restored.`)}export{Tb as $,Ln as $t,$C as A,to as At,gS as B,ea as Bt,aw as C,cu as Ct,yw as D,vs as Dt,nw as E,ps as Et,iC as F,Ka as Ft,Qx as G,Jn as Gt,uS as H,jr as Ht,$S as I,Ga as It,rS as J,Wn as Jt,aS as K,qn as Kt,QS as L,Wa as Lt,YC as M,Xa as Mt,MC as N,qa as Nt,hw as O,gs as Ot,aC as P,Ya as Pt,Ob as Q,zn as Qt,ES as R,Ja as Rt,Bw as S,Ad as St,rw as T,Xs as Tt,lS as U,Er as Ut,mS as V,Wr as Vt,cS as W,dr as Wt,Gb as X,Vn as Xt,ix as Y,Hn as Yt,Ub as Z,Bn as Zt,Ww as _,cp as _t,mF as a,u_ as at,Iw as b,tp as bt,yN as c,v_ as ct,FA as d,__ as dt,In as en,kb as et,xA as f,i_ as ft,_E as g,lp as gt,kO as h,Lp as ht,YF as i,Mn as in,S_ as it,XC as j,J as jt,QC as k,oo as kt,JA as l,g_ as lt,jk as m,yf as mt,aI as n,Pn as nn,Lb as nt,hF as o,f_ as ot,lA as p,Qh as pt,nS as q,Gn as qt,rI as r,Nn as rn,gb as rt,iF as s,m_ as st,uI as t,Fn as tn,Eb as tt,GA as u,h_ as ut,Uw as v,np as vt,iw as w,Zs as wt,zw as x,kd as xt,Hw as y,op as yt,wS as z,la as zt};