texlite 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +64 -12
- package/dist/client/assets/AdminUsers-CfKlKMUu.js +1 -0
- package/dist/client/assets/{CitationLibraryDialog-tVD3i2gg.js → CitationLibraryDialog-BpnX28Le.js} +1 -1
- package/dist/client/assets/Dashboard-nbu54S0M.js +2 -0
- package/dist/client/assets/GitDialog-CrLMkNSh.js +3 -0
- package/dist/client/assets/GitHubAccountDialog-Bt0c8yBQ.js +1 -0
- package/dist/client/assets/HistoryDialog-CNEHivv5.js +7 -0
- package/dist/client/assets/LatexEditor-Dq9cqkpP.js +138 -0
- package/dist/client/assets/{PdfPreview-CMkO72I5.js → PdfPreview-xiB5Piyv.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-BSdiBwtv.js +1 -0
- package/dist/client/assets/{ProjectNavigationDialogs-isGMXCfG.js → ProjectNavigationDialogs-C7cD7PvT.js} +1 -1
- package/dist/client/assets/ProjectSettings-CRHG-jAZ.js +1 -0
- package/dist/client/assets/ProjectWorkspace-BdmKRaK2.js +32 -0
- package/dist/client/assets/{SelectionHistoryDialog-ZvAhIJMy.js → SelectionHistoryDialog-JL_2qLGf.js} +1 -1
- package/dist/client/assets/SystemMetricsDialog-BIWJwsxD.js +1 -0
- package/dist/client/assets/{TagManagementDialog-qhZfHgTr.js → TagManagementDialog-CJXWtqXN.js} +1 -1
- package/dist/client/assets/{WordCountDialog-tFhMCGyn.js → WordCountDialog-sr21g-ex.js} +1 -1
- package/dist/client/assets/check-CzfkSYah.js +1 -0
- package/dist/client/assets/{chktex-tM1XXPk2.js → chktex-BEVGf49u.js} +1 -1
- package/dist/client/assets/{editor-B9HNwtsd.js → editor-taw1iptB.js} +1 -1
- package/dist/client/assets/external-link-DuxFggPh.js +1 -0
- package/dist/client/assets/github-D805ABUR.js +1 -0
- package/dist/client/assets/{hard-drive-CkIPwUSV.js → hard-drive-De8wdQpw.js} +1 -1
- package/dist/client/assets/index-BYAZKPNO.js +10 -0
- package/dist/client/assets/{index-DTYEGzB7.js → index-CXWzCgcU.js} +1 -1
- package/dist/client/assets/index-Cc9-JFj7.css +1 -0
- package/dist/client/assets/{minimize-2-CLuDohEf.js → minimize-2-DP0ZJHGp.js} +1 -1
- package/dist/client/assets/{minus-BpuvzV2m.js → minus-BDK-NFbs.js} +1 -1
- package/dist/client/assets/{plus-BFr75l91.js → plus-GB_3iSP8.js} +1 -1
- package/dist/client/assets/{refresh-cw-DyA4NKh7.js → refresh-cw-DwUVAz9L.js} +1 -1
- package/dist/client/assets/{search-Nu4OcY_n.js → search-BJ0HR5pC.js} +1 -1
- package/dist/client/assets/{sigma-B-wjepsY.js → sigma-DOfd27T4.js} +1 -1
- package/dist/client/assets/{spellCheck-C-bNJsIU.js → spellCheck-CRN7y5Qf.js} +1 -1
- package/dist/client/assets/{tags-BSA08jK3.js → tags-BdjO5Lmr.js} +1 -1
- package/dist/client/assets/{type-BCdIbDmF.js → type-qV4gbXDh.js} +1 -1
- package/dist/client/assets/{user-plus-gFwY-NA3.js → user-plus-CPne6OnV.js} +1 -1
- package/dist/client/assets/x-DPtqmVM9.js +1 -0
- package/dist/client/index.html +3 -3
- package/dist/server/db.js +30 -1
- package/dist/server/git.js +64 -29
- package/dist/server/harper.js +14 -0
- package/dist/server/history.js +14 -5
- package/dist/server/i18n.js +2 -2
- package/dist/server/routes/projectGit.js +10 -11
- package/dist/server/routes/projectHistory.js +32 -5
- package/dist/server/routes/projectMembers.js +0 -5
- package/dist/server/routes/projects.js +10 -0
- package/dist/server/routes/users.js +0 -2
- package/dist/shared/historyFiles.js +6 -0
- package/package.json +3 -1
- package/dist/client/assets/AdminUsers-BExOMZsW.js +0 -1
- package/dist/client/assets/Dashboard-DRt4rjKP.js +0 -2
- package/dist/client/assets/GitDialog-CjDCi1uh.js +0 -3
- package/dist/client/assets/HistoryDialog-Pa9mK3Ky.js +0 -7
- package/dist/client/assets/LatexEditor-8r486VeG.js +0 -138
- package/dist/client/assets/ProjectIconPickerDialog-B52xbSyr.js +0 -1
- package/dist/client/assets/ProjectSettings-Br_kJ113.js +0 -1
- package/dist/client/assets/ProjectWorkspace-CcbrdCy8.js +0 -32
- package/dist/client/assets/SystemMetricsDialog-D4ouU4HI.js +0 -1
- package/dist/client/assets/check-DKIW1zpR.js +0 -1
- package/dist/client/assets/index-90X2GUd_.css +0 -1
- package/dist/client/assets/index-CqBmQAzW.js +0 -10
- package/dist/client/assets/key-round-BEnQo7IM.js +0 -1
- package/dist/client/assets/x-Cspw_pa4.js +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./spellCheck-CRN7y5Qf.js","./index-BYAZKPNO.js","./react-BVUjbTTn.js","./index-Cc9-JFj7.css","./check-CzfkSYah.js","./x-DPtqmVM9.js","./search-BJ0HR5pC.js","./user-plus-CPne6OnV.js","./refresh-cw-DwUVAz9L.js","./chktex-BEVGf49u.js","./LatexEditor-Dq9cqkpP.js","./editor-taw1iptB.js","./CitationLibraryDialog-BpnX28Le.js","./citationLibrary-ZeQPCv5O.js","./plus-GB_3iSP8.js","./tags-BdjO5Lmr.js","./GitDialog-CrLMkNSh.js","./github-D805ABUR.js","./external-link-DuxFggPh.js","./minus-BDK-NFbs.js","./minimize-2-DP0ZJHGp.js","./HistoryDialog-CNEHivv5.js","./index-CXWzCgcU.js","./hard-drive-De8wdQpw.js","./SelectionHistoryDialog-JL_2qLGf.js","./ProjectNavigationDialogs-C7cD7PvT.js","./ProjectSettings-CRHG-jAZ.js","./type-qV4gbXDh.js","./sigma-DOfd27T4.js","./WordCountDialog-sr21g-ex.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as Le,s as cr,g as ye,h as ge,a as as,A as Mc,n as Rw,l as Dw,r as jw,_ as Nt,S as _w,d as gt,i as Rs,k as nf,u as ze,m as br,o as _t,p as Te,q as Lt,t as Br,v as Da,w as rf,x as sf,C as _s,M as On,e as of,y as Pw}from"./index-BYAZKPNO.js";import{r as u,u as tt,j as a,P as oi,d as ja,R as xr,a as qn,b as cf,e as Aw}from"./react-BVUjbTTn.js";import{C as Tw}from"./check-CzfkSYah.js";import{f as Ow,U as No,B as Lw,M as Nw,G as Mw,X as In,e as ii,j as Fc,b as Fw,c as _u,N as Iw,d as af,F as $w,g as Pu,h as Uw,k as Vt,C as _a,a as zw,T as fr,L as Bw,S as Ic,D as Mo,A as Ps,E as Ww,P as Vw,i as Hw}from"./x-DPtqmVM9.js";import{S as qw}from"./search-BJ0HR5pC.js";import{U as Kw}from"./user-plus-CPne6OnV.js";import{R as Gw}from"./refresh-cw-DwUVAz9L.js";const Jw=Le("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);const Yw=Le("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);const Xw=Le("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);const ci=Le("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const lf=Le("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const Pa=Le("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const Au=Le("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);const $c=Le("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);const Zw=Le("FileAudio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]);const Qw=Le("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);const eb=Le("FileCog",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]]);const tb=Le("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);const nb=Le("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);const rb=Le("FileType2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 13v-1h6v1",key:"1dh9dg"}],["path",{d:"M5 12v6",key:"150t9c"}],["path",{d:"M4 18h2",key:"1xrofg"}]]);const sb=Le("FileVideo",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]]);const ob=Le("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);const uf=Le("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);const Tu=Le("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);const ib=Le("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);const cb=Le("LibraryBig",[["rect",{width:"8",height:"18",x:"3",y:"3",rx:"1",key:"oynpb5"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z",key:"1qboyk"}]]);const Ou=Le("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);const df=Le("PackageOpen",[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]);const ff=Le("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const ab=Le("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const lb=Le("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);const ub=Le("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const db=Le("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const fb=Le("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);const hb=Le("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const Lu=Le("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const pb=Le("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);const mb=Le("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),gb="wrap = false",Uc=[{id:"jetbrains",labelKey:"projectSettings.fontJetBrains",stack:'"JetBrains Mono", ui-monospace, monospace'},{id:"source-code",labelKey:"projectSettings.fontSourceCode",stack:'"Source Code Pro", ui-monospace, monospace'},{id:"ibm-plex",labelKey:"projectSettings.fontIbmPlex",stack:'"IBM Plex Mono", ui-monospace, monospace'},{id:"fira-code",labelKey:"projectSettings.fontFiraCode",stack:'"Fira Code", ui-monospace, monospace'},{id:"iosevka",labelKey:"projectSettings.fontIosevka",stack:'"Iosevka", ui-monospace, monospace'}],At={font:"jetbrains",fontSize:14,lineHeight:1.65,lineWrapping:!0,showTooltips:!1,spellCheck:!0,mathPreviewOnHover:!1,vimMode:!1,formatOnCompile:!1,texFmtConfig:gb,texFmtConfigInitialized:!0,openFilesInTabs:!1},yb="texlite-editor-preferences";function hf(t,e){return cr(`${yb}:${encodeURIComponent(t)}:${encodeURIComponent(e)}`)}function ej(t){return Uc.find(e=>e.id===t)?.stack??Uc[0].stack}function Nu(t,e){try{const n=JSON.parse(localStorage.getItem(hf(t,e))??"{}"),r=typeof n.texFmtConfig=="string"&&n.texFmtConfig.length<=16*1024?n.texFmtConfig:null,s=r!==null&&(n.texFmtConfigInitialized===!0||r.trim().length>0)?r:At.texFmtConfig;return{font:Uc.some(o=>o.id===n.font)?n.font:At.font,fontSize:[12,13,14,15,16,18,20].includes(Number(n.fontSize))?Number(n.fontSize):At.fontSize,lineHeight:[1.45,1.65,1.85].includes(Number(n.lineHeight))?Number(n.lineHeight):At.lineHeight,lineWrapping:typeof n.lineWrapping=="boolean"?n.lineWrapping:At.lineWrapping,showTooltips:typeof n.showTooltips=="boolean"?n.showTooltips:At.showTooltips,spellCheck:typeof n.spellCheck=="boolean"?n.spellCheck:At.spellCheck,mathPreviewOnHover:typeof n.mathPreviewOnHover=="boolean"?n.mathPreviewOnHover:At.mathPreviewOnHover,vimMode:typeof n.vimMode=="boolean"?n.vimMode:At.vimMode,formatOnCompile:typeof n.formatOnCompile=="boolean"?n.formatOnCompile:At.formatOnCompile,texFmtConfig:s,texFmtConfigInitialized:!0,openFilesInTabs:typeof n.openFilesInTabs=="boolean"?n.openFilesInTabs:At.openFilesInTabs}}catch{return At}}function wb(t,e,n){localStorage.setItem(hf(t,e),JSON.stringify(n))}function bb(){let t={status:"loading",error:""};const e=new Set,n=(r,s="")=>{if(!(t.status===r&&t.error===s)){t={status:r,error:s};for(const o of e)o()}};return{getSnapshot:()=>t,subscribe:r=>(e.add(r),()=>e.delete(r)),loading:()=>n("loading"),working:()=>n("working"),failed:r=>n("error",r instanceof Error?r.message:String(r))}}const Nn=bb(),xb=/\.(?:tex|bib|cls|sty)$/i,pf=3e4;let Wt=null,Fo=!1,ar=null,vb=1;const hr=new Map,Io=[];let Wr=null,Es=null;class jt extends Error{constructor(e,n){super(n),this.kind=e,this.name="TexFmtError"}kind}function sc(t){return t instanceof jt}function yn(t){Wt?.terminate(),Wt=null,Fo=!1,ar!==null&&window.clearTimeout(ar),ar=null,Wr=null,Io.length=0,Es=null,Nn.failed(t);for(const e of hr.values())e.timeout!==null&&window.clearTimeout(e.timeout),e.reject(t);hr.clear()}function Ds(){if(Wr!==null||Io.length===0)return;let t;try{t=Sb()}catch(r){yn(r instanceof jt?r:new jt("load","The bundled tex-fmt formatter could not be loaded."));return}if(!Fo)return;const e=Io.shift();if(e===void 0)return;const n=hr.get(e);if(!n){Ds();return}Wr=e,n.timeout=window.setTimeout(()=>{Wr===e&&yn(new jt("result","The formatter did not respond within 30 seconds."))},pf);try{t.postMessage({...n.request,id:e})}catch{yn(new jt("load","The formatter worker could not receive the source."))}}function Sb(){if(Wt)return Wt;if(typeof Worker>"u"){const t=new jt("load","This browser does not support formatter workers.");throw Nn.failed(t),t}Nn.loading();try{Wt=new Worker(new URL(""+new URL("latexFormatterWorker-BRmsns8a.js",import.meta.url).href,import.meta.url),{type:"module",name:"texlite-latex-formatter"}),ar=window.setTimeout(()=>{Fo||yn(new jt("load","The formatter did not finish loading within 30 seconds."))},pf)}catch{const t=new jt("load","The bundled tex-fmt formatter could not be loaded.");throw Nn.failed(t),t}return Wt.onmessage=t=>{const e=t.data;if(e&&"type"in e){e.type==="ready"&&(Fo=!0,ar!==null&&window.clearTimeout(ar),ar=null,Ds());return}if(!e||typeof e.id!="number"){yn(new jt("result","The formatter worker returned an invalid response."));return}const n=hr.get(e.id);if(n)if(hr.delete(e.id),n.timeout!==null&&window.clearTimeout(n.timeout),Wr===e.id&&(Wr=null),e.ok)Nn.working(),n.resolve(e.result),Ds();else{const r=new jt(e.kind,e.message);e.kind==="format"?(Nn.working(),n.reject(r),Ds()):(n.reject(r),yn(r))}},Wt.onerror=()=>{yn(new jt("load","The bundled tex-fmt formatter could not be loaded."))},Wt.onmessageerror=()=>{yn(new jt("result","The formatter worker returned an unreadable response."))},Wt}function Aa(t){const e=vb++;return new Promise((n,r)=>{hr.set(e,{request:t,resolve:n,reject:r,timeout:null}),Io.push(e),Ds()})}function Cb(t,e=""){return Aa({action:"format",source:t,config:e})}async function Eb(){Wt&&Nn.getSnapshot().status==="working"||(Es||(Es=Aa({action:"probe"}).then(()=>{}).finally(()=>{Es=null})),await Es)}async function tj(){(Wt||hr.size)&&yn(new jt("load","The formatter runtime was reloaded.")),Nn.loading(),await Eb()}function go(t){return xb.test(t)}function kb(t){return t.match(/(?:\r?\n)+$/)?.[0]??""}function Rb(t,e){const n=kb(t),i=(n?t.slice(0,-n.length):t).split(/\r?\n/).find(d=>d.trim())?.match(/^[\t ]*/)?.[0]??"",c=e.replace(/(?:\r?\n)+$/,"");return`${i?c.split(`
|
|
3
|
+
`).map(d=>d&&`${i}${d}`).join(`
|
|
4
|
+
`):c}${n}`}async function oc(t,e,n=0){return Aa({action:"diff",source:t,formatted:e,baseOffset:n})}function Db(t,e=null){const n=Mu(t),s=e==="succeeded"||e===null&&_b(t)?[]:Fu(n.filter(Iu)),o=Mu(jb(t));return{warnings:Fu(o.filter(c=>!Iu(c)&&Pb(c))),errors:s}}function Mu(t){return t.split(`
|
|
5
|
+
`).map(e=>e.trim()).filter(Boolean)}function Fu(t){return[...new Set(t)]}function jb(t){const e=/^Running ['"][^\n]*(?:pdf|xe|lua)latex(?:\s|['"])[^\n]*$/gim;let n=-1;for(const r of t.matchAll(e))n=r.index;return n>=0?t.slice(n):t}function _b(t){return/Latexmk: All targets .* are up-to-date/i.test(t)&&/Output written on .*\.pdf/i.test(t)}function Iu(t){return/^!\s/.test(t)||/(?:^|:\s)(?:LaTeX|Package|Class|pdfTeX|XeTeX|LuaTeX)?\s*Error:/i.test(t)||/^Latexmk:.*(?:\bErrors?,|did not complete making targets|failure)/i.test(t)||/^Collected error summary/i.test(t)||/\b(?:fatal error|emergency stop|undefined control sequence|no output pdf|no pages of output)\b/i.test(t)||/\b(?:bibtex|biber) errors?:/i.test(t)||/^error, and then rerun latexmk/i.test(t)}function Pb(t){return/\bwarnings?\b|overfull|underfull|badness/i.test(t)}const $u=1,Uu=2,ic=4,cc=8,As=32,wn=64,xt=128,Ab=1<<29,ai=31,zc=63,dr=127,Tb=2147483647,Qt=(t,e)=>t>>>e|t<<32-e,Ob=t=>Qt(t,2)^Qt(t,13)^Qt(t,22),Lb=t=>Qt(t,6)^Qt(t,11)^Qt(t,25),Nb=t=>Qt(t,7)^Qt(t,18)^t>>>3,Mb=t=>Qt(t,17)^Qt(t,19)^t>>>10,Fb=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]),Ib=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class $b{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Ib),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let f=16;f<64;f++)n[f]=Mb(n[f-2])+n[f-7]+Nb(n[f-15])+n[f-16];let r=e[0],s=e[1],o=e[2],i=e[3],c=e[4],l=e[5],d=e[6],h=e[7];for(let f=0,p,g;f<64;f++)p=h+Lb(c)+(c&l^~c&d)+Fb[f]+n[f]>>>0,g=Ob(r)+(r&s^r&o^s&o)>>>0,h=d,d=l,l=c,c=i+p>>>0,i=o,o=s,s=r,r=p+g>>>0;e[0]+=r,e[1]+=s,e[2]+=o,e[3]+=i,e[4]+=c,e[5]+=l,e[6]+=d,e[7]+=h}digest(e){let n=0;for(;n+56<=e.length;){let i=0;for(;i<16&&n+3<e.length;i++)this._W[i]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,i,16);n<e.length;)this._W[i]|=e[n]<<(3-n%4)*8,n++;this._W[i]|=xt<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<e.length;s++)for(let i=3;i>=0&&n<e.length;i--)this._W[s]|=e[n++]<<i*8;r||(this._W[s-(n%4===0?0:1)]|=xt<<(3-n%4)*8),this._W[14]=e.byteLength/Ab,this._W[15]=e.byteLength*8,this._updateHash();const o=new Uint8Array(32);for(let i=0;i<this._H.length;i++)for(let c=0;c<4;c++)o[i*4+c]=this._H[i]>>>(3-c)*8;return o}}const Ub=t=>new $b().digest(t);function zb(t){return Array.from(Ub(new TextEncoder().encode(t)),e=>e.toString(16).padStart(2,"0")).join("")}function zu(t){return t instanceof Error&&t.name==="AbortError"}function Bb({projectId:t,activeFile:e,content:n,permission:r,revision:s,selection:o,save:i,saveFailureMessage:c,onError:l,onAdded:d,onChanged:h}){const[f,p]=u.useState({filePath:"",comments:[],loading:!1}),[g,m]=u.useState([]),[b,S]=u.useState(!1),[C,D]=u.useState(""),[y,w]=u.useState("file"),[k,v]=u.useState(null),[R,A]=u.useState(!1),[N,U]=u.useState(""),[K,T]=u.useState(null),[q,B]=u.useState(!1),[W,z]=u.useState(""),Z=u.useRef(null),I=u.useRef(null),V=u.useRef(!1),G=u.useRef(e),Q=u.useRef(y),Ce=u.useRef(i),te=u.useRef(l),ue=u.useRef(d),ke=u.useRef(h);G.current=e,Q.current=y,Ce.current=i,te.current=l,ue.current=d,ke.current=h;const j=f.filePath===e?f.comments:[],Y=f.filePath,le=Y===e&&!f.loading,Re=async X=>{Z.current?.abort();const ne=new AbortController;Z.current=ne,G.current===X&&p(be=>be.filePath===X?{...be,loading:!0}:{filePath:"",comments:[],loading:!0});try{const be=await ye(`/api/projects/${t}/comments?path=${encodeURIComponent(X)}`,{signal:ne.signal});Z.current===ne&&G.current===X&&p({filePath:X,comments:be.comments,loading:!1})}catch(be){!zu(be)&&Z.current===ne&&G.current===X&&p({filePath:X,comments:[],loading:!1})}finally{Z.current===ne&&(Z.current=null)}},re=async()=>{I.current?.abort();const X=new AbortController;I.current=X,Q.current==="project"&&(S(!0),D(""));try{const ne=await ye(`/api/projects/${t}/comments?scope=project`,{signal:X.signal});I.current===X&&Q.current==="project"&&m(ne.comments)}catch(ne){!zu(ne)&&I.current===X&&Q.current==="project"&&D(ge(ne))}finally{I.current===X&&(I.current=null,Q.current==="project"&&S(!1))}};u.useEffect(()=>{Z.current?.abort(),Z.current=null,I.current?.abort(),I.current=null,v(null),p({filePath:"",comments:[],loading:!1}),m([]),S(!1),D(""),w("file"),A(!1),T(null),z("")},[t]),u.useEffect(()=>{A(!1),T(null),z("")},[e]),u.useEffect(()=>(e?Re(e):p({filePath:"",comments:[],loading:!1}),()=>{Z.current?.abort(),Z.current=null}),[t,e,s]),u.useEffect(()=>{if(y!=="project"){I.current?.abort(),I.current=null,m([]),S(!1),D("");return}return re(),()=>{I.current?.abort(),I.current=null}},[t,y,s]);const we=async X=>{const ne=[];G.current===X&&ne.push(Re(X)),Q.current==="project"&&ne.push(re()),await Promise.all(ne)},Ee=(X,ne)=>{e&&(z(""),T({filePath:e,selection:{...X??o},sourceHash:zb(ne??n)}),A(!0))},J=()=>{V.current||(A(!1),T(null),z(""))},ce=async()=>{const X=K;if(!(!N.trim()||!X||V.current)){V.current=!0,B(!0),z("");try{if(r!=="read"&&!await Ce.current()){z(c);return}await ye(`/api/projects/${t}/comments`,{method:"POST",body:JSON.stringify({path:X.filePath,content:N,...X.selection,sourceHash:X.sourceHash})}),await we(X.filePath),A(!1),T(null),U(""),ue.current(),ke.current?.()}catch(ne){z(ge(ne))}finally{V.current=!1,B(!1)}}},L=async X=>{try{await ye(`/api/projects/${t}/comments/${X.id}`,{method:"PATCH",body:JSON.stringify({resolved:!X.resolved})}),await we(X.filePath),ke.current?.()}catch(ne){te.current(ge(ne))}},_e=async(X,ne)=>{try{return await ye(`/api/projects/${t}/comments/${X.id}/replies`,{method:"POST",body:JSON.stringify({content:ne})}),await we(X.filePath),ke.current?.(),!0}catch(be){return te.current(ge(be)),!1}},Ne=async(X,ne)=>{try{return await ye(`/api/projects/${t}/comments/${X.id}`,{method:"PATCH",body:JSON.stringify({content:ne})}),await we(X.filePath),ke.current?.(),!0}catch(be){return te.current(ge(be)),!1}},pe=async X=>{try{return await ye(`/api/projects/${t}/comments/${X.id}`,{method:"DELETE"}),await we(X.filePath),v(ne=>ne?.id===X.id?null:ne),ke.current?.(),!0}catch(ne){return te.current(ge(ne)),!1}},Oe=async(X,ne,be)=>{try{return await ye(`/api/projects/${t}/comments/${X.id}/replies/${ne}`,{method:"PATCH",body:JSON.stringify({content:be})}),await we(X.filePath),ke.current?.(),!0}catch(Ae){return te.current(ge(Ae)),!1}},de=async(X,ne)=>{try{return await ye(`/api/projects/${t}/comments/${X.id}/replies/${ne}`,{method:"DELETE"}),await we(X.filePath),ke.current?.(),!0}catch(be){return te.current(ge(be)),!1}};return{comments:j,commentsFilePath:Y,commentsReady:le,reviewComments:y==="file"?j:g,reviewCommentsLoading:y==="project"&&b,reviewCommentsError:y==="project"?C:"",retryReviewComments:re,commentScope:y,setCommentScope:w,focusComment:k,setFocusComment:v,commentOpen:R,openComment:Ee,closeComment:J,commentText:N,setCommentText:U,commentSelection:K?.selection??o,commentSubmitting:q,commentError:W,addComment:ce,toggleComment:L,replyToComment:_e,editComment:Ne,deleteComment:pe,editCommentReply:Oe,deleteCommentReply:de}}function Wb(t){const e=new Map;for(const n of t)for(const r of[n,...n.replies])e.has(r.authorId)||e.set(r.authorId,{authorId:r.authorId,authorUsername:r.authorUsername,authorDisplayName:r.authorDisplayName});return[...e.values()].sort((n,r)=>(n.authorDisplayName??n.authorUsername??"").localeCompare(r.authorDisplayName??r.authorUsername??""))}function mf(t,e){const n=e.participantIds;return n?.size?n.has(t.authorId)||!e.topLevelOnly&&t.replies.some(r=>n.has(r.authorId)):!0}function Vb(t,e="source"){return[...t].sort((n,r)=>e==="time"?Date.parse(r.createdAt)-Date.parse(n.createdAt):n.filePath.localeCompare(r.filePath,"en",{numeric:!0})||n.startLine-r.startLine||n.startOffset-r.startOffset)}function gf(t,e){return e.scope==="project"||t.filePath===e.activeFile}function Ta(t,e){return e==="unresolved"?!t.resolved:t.resolved}function yf(t,e){return e.some(n=>n.commentId===t.id&&n.readAt===null)}function ac(t,e){return t.filter(n=>gf(n,e)&&mf(n,e)&&Ta(n,e.filter)&&(!e.unreadMentionsOnly||yf(n,e.unreadMentions)))}function Hb(t,e,n=[]){const r=new Set(n.filter(s=>!!s));return Vb(t.filter(s=>gf(s,e)?r.has(s.id)||mf(s,e)&&Ta(s,e.filter)&&(!e.unreadMentionsOnly||yf(s,e.unreadMentions)):!1),e.sort)}function qb(t,e){return t.filter(n=>n.filePath===e)}function Kb(t,e,n){return!t||t.filePath!==e||n!==e?null:t}function Gb(t,e,n,r,s,o){return!t||t.filePath!==e||n!==e||r!==e||!s?null:o.find(i=>i.id===t.id&&i.filePath===e)??null}function Jb(t,e){return!Ta({...t,resolved:!t.resolved},e)}function Yb(t,e){if(!e)return 0;const n=t.findIndex(r=>r.id===e);return n<0?0:n+1}function Xb(t,e,n){if(!t.length)return null;const r=e?t.findIndex(o=>o.id===e):-1;if(r<0)return n===1?t[0]:null;const s=r+n;return s>=0&&s<t.length?t[s]:null}function Zb(t){return t instanceof Error&&t.name==="AbortError"}function Qb(t,e,n){const[r,s]=u.useState([]),o=u.useRef(null),i=u.useRef(n);i.current=n;const c=u.useCallback(async(h=!1)=>{o.current?.abort();const f=new AbortController;o.current=f;try{const p=await ye(`/api/projects/${t}/mentions?unread=1&limit=100`,{signal:f.signal});o.current===f&&s(p.mentions)}catch(p){o.current===f&&!Zb(p)&&(s([]),h&&i.current(ge(p)))}finally{o.current===f&&(o.current=null)}},[t]);return u.useEffect(()=>(c(),()=>{o.current?.abort(),o.current=null}),[c,e]),{unreadMentions:r,refresh:c,markMentionRead:async h=>{try{return await ye(`/api/projects/${t}/mentions/${encodeURIComponent(h)}/read`,{method:"POST"}),s(f=>f.filter(p=>p.id!==h)),!0}catch(f){return i.current(ge(f)),!1}},markAllMentionsRead:async()=>{if(!r.length)return!0;try{return await ye(`/api/projects/${t}/mentions/read-all`,{method:"POST"}),s([]),!0}catch(h){return i.current(ge(h)),!1}}}}const Et=()=>new Map,Bc=t=>{const e=Et();return t.forEach((n,r)=>{e.set(r,n)}),e},sn=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},ex=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},tx=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},zn=()=>new Set,lc=t=>t[t.length-1],nx=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},vn=Array.from,Oa=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},La=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},rx=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},Qr=Array.isArray;class Na{constructor(){this._observers=Et()}on(e,n){return sn(this._observers,e,zn).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return vn((this._observers.get(e)||Et()).values()).forEach(r=>r(...n))}destroy(){this._observers=Et()}}class wf{constructor(){this._observers=Et()}on(e,n){sn(this._observers,e,zn).add(n)}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return vn((this._observers.get(e)||Et()).values()).forEach(r=>r(...n))}destroy(){this._observers=Et()}}const qt=Math.floor,jo=Math.abs,Ma=(t,e)=>t<e?t:e,vr=(t,e)=>t>e?t:e,sx=Math.pow,bf=t=>t!==0?t<0:1/t<0,$o=Number.MAX_SAFE_INTEGER,Bu=Number.MIN_SAFE_INTEGER,ox=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&qt(t)===t),xf=String.fromCharCode,ix=t=>t.toLowerCase(),cx=/^\s*/g,ax=t=>t.replace(cx,""),lx=/([A-Z])/g,Wu=(t,e)=>ax(t.replace(lx,n=>`${e}${ix(n)}`)),ux=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},Ts=typeof TextEncoder<"u"?new TextEncoder:null,dx=t=>Ts.encode(t),fx=Ts?dx:ux;let js=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});js&&js.decode(new Uint8Array).length===1&&(js=null);const hx=(t,e)=>rx(e,()=>t).join("");class qs{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const qe=()=>new qs,Fa=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Ie=t=>{const e=new Uint8Array(Fa(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},px=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(vr(n,e)*2),t.cpos=0)},ot=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Wc=ot,se=(t,e)=>{for(;e>dr;)ot(t,xt|dr&e),e=qt(e/128);ot(t,dr&e)},Ia=(t,e)=>{const n=bf(e);for(n&&(e=-e),ot(t,(e>zc?xt:0)|(n?wn:0)|zc&e),e=qt(e/64);e>0;)ot(t,(e>dr?xt:0)|dr&e),e=qt(e/128)},Vc=new Uint8Array(3e4),mx=Vc.length/3,gx=(t,e)=>{if(e.length<mx){const n=Ts.encodeInto(e,Vc).written||0;se(t,n);for(let r=0;r<n;r++)ot(t,Vc[r])}else He(t,fx(e))},yx=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;se(t,r);for(let s=0;s<r;s++)ot(t,n.codePointAt(s))},ft=Ts&&Ts.encodeInto?gx:yx,li=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=Ma(n-r,e.length),o=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(vr(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o)},He=(t,e)=>{se(t,e.byteLength),li(t,e)},$a=(t,e)=>{px(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},wx=(t,e)=>$a(t,4).setFloat32(0,e,!1),bx=(t,e)=>$a(t,8).setFloat64(0,e,!1),xx=(t,e)=>$a(t,8).setBigInt64(0,e,!1),Vu=new DataView(new ArrayBuffer(4)),vx=t=>(Vu.setFloat32(0,t),Vu.getFloat32(0)===t),Os=(t,e)=>{switch(typeof e){case"string":ot(t,119),ft(t,e);break;case"number":ox(e)&&jo(e)<=Tb?(ot(t,125),Ia(t,e)):vx(e)?(ot(t,124),wx(t,e)):(ot(t,123),bx(t,e));break;case"bigint":ot(t,122),xx(t,e);break;case"object":if(e===null)ot(t,126);else if(Qr(e)){ot(t,117),se(t,e.length);for(let n=0;n<e.length;n++)Os(t,e[n])}else if(e instanceof Uint8Array)ot(t,116),He(t,e);else{ot(t,118);const n=Object.keys(e);se(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];ft(t,s),Os(t,e[s])}}break;case"boolean":ot(t,e?120:121);break;default:ot(t,127)}};class Hu extends qs{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&se(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const qu=t=>{t.count>0&&(Ia(t.encoder,t.count===1?t.s:-t.s),t.count>1&&se(t.encoder,t.count-2))};class _o{constructor(){this.encoder=new qs,this.s=0,this.count=0}write(e){this.s===e?this.count++:(qu(this),this.count=1,this.s=e)}toUint8Array(){return qu(this),Ie(this.encoder)}}const Ku=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Ia(t.encoder,e),t.count>1&&se(t.encoder,t.count-2)}};class uc{constructor(){this.encoder=new qs,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ku(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ku(this),Ie(this.encoder)}}class Sx{constructor(){this.sarr=[],this.s="",this.lensE=new _o}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new qs;return this.sarr.push(this.s),this.s="",ft(e,this.sarr.join("")),li(e,this.lensE.toUint8Array()),Ie(e)}}const Kt=t=>new Error(t),Ht=()=>{throw Kt("Method unimplemented")},Pt=()=>{throw Kt("Unexpected case")},vf=Kt("Unexpected end of array"),Sf=Kt("Integer out of Range");class ui{constructor(e){this.arr=e,this.pos=0}}const Kn=t=>new ui(t),Hc=t=>t.pos!==t.arr.length,Cx=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},mt=t=>Cx(t,me(t)),es=t=>t.arr[t.pos++],me=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&dr)*n,n*=128,s<xt)return e;if(e>$o)throw Sf}throw vf},Ua=t=>{let e=t.arr[t.pos++],n=e&zc,r=64;const s=(e&wn)>0?-1:1;if((e&xt)===0)return s*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&dr)*r,r*=128,e<xt)return s*n;if(n>$o)throw Sf}throw vf},Ex=t=>{let e=me(t);if(e===0)return"";{let n=String.fromCodePoint(es(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(es(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},kx=t=>js.decode(mt(t)),Ve=js?kx:Ex,za=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Rx=t=>za(t,4).getFloat32(0,!1),Dx=t=>za(t,8).getFloat64(0,!1),jx=t=>za(t,8).getBigInt64(0,!1),_x=[t=>{},t=>null,Ua,Rx,Dx,jx,t=>!1,t=>!0,Ve,t=>{const e=me(t),n={};for(let r=0;r<e;r++){const s=Ve(t);n[s]=Ls(t)}return n},t=>{const e=me(t),n=[];for(let r=0;r<e;r++)n.push(Ls(t));return n},mt],Ls=t=>_x[127-es(t)](t);class Gu extends ui{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Hc(this)?this.count=me(this)+1:this.count=-1),this.count--,this.s}}class Po extends ui{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ua(this);const e=bf(this.s);this.count=1,e&&(this.s=-this.s,this.count=me(this)+2)}return this.count--,this.s}}class dc extends ui{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Ua(this),n=e&1;this.diff=qt(e/2),this.count=1,n&&(this.count=me(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Px{constructor(e){this.decoder=new Po(e),this.str=Ve(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const Ax=crypto.getRandomValues.bind(crypto),Cf=()=>Ax(new Uint32Array(1))[0],Tx="10000000-1000-4000-8000"+-1e11,Ox=()=>Tx.replace(/[018]/g,t=>(t^Cf()&15>>t/4).toString(16)),Bn=Date.now,ts=t=>new Promise(t);Promise.all.bind(Promise);const Ju=t=>t===void 0?null:t;class Lx{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let Ef=new Lx,Ba=!0;try{typeof localStorage<"u"&&localStorage&&(Ef=localStorage,Ba=!1)}catch{}const kf=Ef,Nx=t=>Ba||addEventListener("storage",t),Mx=t=>Ba||removeEventListener("storage",t),Ns=Symbol("Equality"),Rf=(t,e)=>t===e||!!t?.[Ns]?.(e)||!1,Fx=t=>typeof t=="object",Ix=Object.assign,$x=Object.keys,Ux=(t,e)=>{for(const n in t)e(t[n],n)},zx=(t,e)=>{const n=[];for(const r in t)n.push(e(t[r],r));return n},Uo=t=>$x(t).length,Bx=t=>{for(const e in t)return!1;return!0},Ks=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Wa=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Wx=(t,e)=>t===e||Uo(t)===Uo(e)&&Ks(t,(n,r)=>(n!==void 0||Wa(e,r))&&Rf(e[r],n)),Vx=Object.freeze,Df=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&Df(t[e])}return Vx(t)},Va=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&Va(t,e,n+1)}},Hx=t=>t,Vr=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[Ns]!=null)return t[Ns](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Vr(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(Uo(t)!==Uo(e))return!1;for(const n in t)if(!Wa(t,n)||!Vr(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Vr(t[n],e[n]))return!1;break;default:return!1}return!0},qx=(t,e)=>e.includes(t);var jf={};const Wn=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",_f=typeof window<"u"&&typeof document<"u"&&!Wn;let Xt;const Kx=()=>{if(Xt===void 0)if(Wn){Xt=Et();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&Xt.set(e,""),e=r):e!==null&&(Xt.set(e,r),e=null)}e!==null&&Xt.set(e,"")}else typeof location=="object"?(Xt=Et(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");Xt.set(`--${Wu(e,"-")}`,n),Xt.set(`-${Wu(e,"-")}`,n)}})):Xt=Et();return Xt},qc=t=>Kx().has(t),zo=t=>Ju(Wn?jf[t.toUpperCase().replaceAll("-","_")]:kf.getItem(t)),Pf=t=>qc("--"+t)||zo(t)!==null,Gx=Pf("production"),Jx=Wn&&qx(jf.FORCE_COLOR,["true","1","2"]),Yx=Jx||!qc("--no-colors")&&!Pf("no-color")&&(!Wn||process.stdout.isTTY)&&(!Wn||qc("--color")||zo("COLORTERM")!==null||(zo("TERM")||"").includes("color")),Af=t=>new Uint8Array(t),Xx=(t,e,n)=>new Uint8Array(t,e,n),Zx=t=>new Uint8Array(t),Qx=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=xf(t[n]);return btoa(e)},ev=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),tv=t=>{const e=atob(t),n=Af(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n},nv=t=>{const e=Buffer.from(t,"base64");return Xx(e.buffer,e.byteOffset,e.byteLength)},rv=_f?Qx:ev,sv=_f?tv:nv,ov=t=>{const e=Af(t.byteLength);return e.set(t),e};class iv{constructor(e,n){this.left=e,this.right=n}}const hn=(t,e)=>new iv(t,e),cv=(t,e)=>t.forEach(n=>e(n.left,n.right)),Yu=t=>t.next()>=.5,fc=(t,e,n)=>qt(t.next()*(n+1-e)+e),Tf=(t,e,n)=>qt(t.next()*(n+1-e)+e),Ha=(t,e,n)=>Tf(t,e,n),av=t=>xf(Ha(t,97,122)),lv=(t,e=0,n=20)=>{const r=Ha(t,e,n);let s="";for(let o=0;o<r;o++)s+=av(t);return s},hc=(t,e)=>e[Ha(t,0,e.length-1)],uv=Symbol("0schema");class dv{constructor(){this._rerrs=[]}extend(e,n,r,s=null){this._rerrs.push({path:e,expected:n,has:r,message:s})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(hx(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
6
|
+
`)}}const Kc=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[Ns]?Rf(t,e):Qr(t)?Oa(t,n=>La(e,r=>Kc(n,r))):Fx(t)?Ks(t,(n,r)=>Kc(n,e[r])):!1;class vt{static _dilutes=!1;extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),Kc(n,r)}equals(e){return this.constructor===e.constructor&&Vr(this.shape,e.shape)}[uv](){return!0}[Ns](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Ht()}get nullable(){return ls(this,mi)}get optional(){return new Nf(this)}cast(e){return Xu(e,this),e}expect(e){return Xu(e,this),e}}class qa extends vt{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&n?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}const nt=(t,e=null)=>new qa(t,e);nt(qa);class Ka extends vt{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape(e);return!r&&n?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),r}}const ut=t=>new Ka(t);nt(Ka);class di extends vt{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape.some(s=>s===e);return!r&&n?.extend(null,this.shape.join(" | "),e.toString()),r}}const fi=(...t)=>new di(t),Of=nt(di),fv=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Lf=t=>{if(ns.check(t))return[fv(t)];if(Of.check(t))return t.shape.map(e=>e+"");if(Vf.check(t))return["[+-]?\\d+.?\\d*"];if(Hf.check(t))return[".*"];if(Bo.check(t))return t.shape.map(Lf).flat(1);Pt()};class hv extends vt{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Lf).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const r=this._r.exec(e)!=null;return!r&&n?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),r}}nt(hv);const pv=Symbol("optional");class Nf extends vt{constructor(e){super(),this.shape=e}check(e,n){const r=e===void 0||this.shape.check(e);return!r&&n?.extend(null,"undefined (optional)","()"),r}get[pv](){return!0}}const mv=nt(Nf);class gv extends vt{check(e,n){return n?.extend(null,"never",typeof e),!1}}nt(gv);class hi extends vt{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}static _dilutes=!0;get partial(){return new hi(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):Ks(this.shape,(r,s)=>{const o=this._isPartial&&!Wa(e,s)||r.check(e[s],n);return!o&&n?.extend(s.toString(),r.toString(),typeof e[s],"Object property does not match"),o})}}const yv=t=>new hi(t),wv=nt(hi),bv=ut(t=>t!=null&&(t.constructor===Object||t.constructor==null));class Mf extends vt{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&Ks(e,(r,s)=>{const o=this.shape.keys.check(s,n);return!o&&n?.extend(s+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value"),o&&this.shape.values.check(r,n)})}}const Ff=(t,e)=>new Mf(t,e),xv=nt(Mf);class If extends vt{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&Ks(this.shape,(r,s)=>{const o=r.check(e[s],n);return!o&&n?.extend(s.toString(),"Tuple",typeof r),o})}}const vv=(...t)=>new If(t);nt(If);class $f extends vt{constructor(e){super(),this.shape=e.length===1?e[0]:new Ga(e)}check(e,n){const r=Qr(e)&&Oa(e,s=>this.shape.check(s));return!r&&n?.extend(null,"Array",""),r}}const Uf=(...t)=>new $f(t),Sv=nt($f),Cv=ut(t=>Qr(t));class zf extends vt{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&n?.extend(null,this.shape.name,e?.constructor.name),r}}const Ev=(t,e=null)=>new zf(t,e);nt(zf);const kv=Ev(vt);class Rv extends vt{constructor(e){super(),this.len=e.length-1,this.args=vv(...e.slice(-1)),this.res=e[this.len]}check(e,n){const r=e.constructor===Function&&e.length<=this.len;return!r&&n?.extend(null,"function",typeof e),r}}const Dv=nt(Rv),jv=ut(t=>typeof t=="function");class _v extends vt{constructor(e){super(),this.shape=e}check(e,n){const r=Oa(this.shape,s=>s.check(e,n));return!r&&n?.extend(null,"Intersectinon",typeof e),r}}nt(_v,t=>t.shape.length>0);class Ga extends vt{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,n){const r=La(this.shape,s=>s.check(e,n));return n?.extend(null,"Union",typeof e),r}}const ls=(...t)=>t.findIndex(e=>Bo.check(e))>=0?ls(...t.map(e=>Ms(e)).map(e=>Bo.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Ga(t),Bo=nt(Ga),Bf=()=>!0,Wo=ut(Bf),Pv=nt(Ka,t=>t.shape===Bf),Ja=ut(t=>typeof t=="bigint"),Av=ut(t=>t===Ja),Wf=ut(t=>typeof t=="symbol");ut(t=>t===Wf);const Hr=ut(t=>typeof t=="number"),Vf=ut(t=>t===Hr),ns=ut(t=>typeof t=="string"),Hf=ut(t=>t===ns),pi=ut(t=>typeof t=="boolean"),Tv=ut(t=>t===pi),qf=fi(void 0);nt(di,t=>t.shape.length===1&&t.shape[0]===void 0);fi(void 0);const mi=fi(null),Ov=nt(di,t=>t.shape.length===1&&t.shape[0]===null);nt(Uint8Array);nt(qa,t=>t.shape===Uint8Array);const Lv=ls(Hr,ns,mi,qf,Ja,pi,Wf);(()=>{const t=Uf(Wo),e=Ff(ns,Wo),n=ls(Hr,ns,mi,pi,t,e);return t.shape=n,e.shape.values=n,n})();const Ms=t=>{if(kv.check(t))return t;if(bv.check(t)){const e={};for(const n in t)e[n]=Ms(t[n]);return yv(e)}else{if(Cv.check(t))return ls(...t.map(Ms));if(Lv.check(t))return fi(t);if(jv.check(t))return nt(t)}Pt()},Xu=Gx?()=>{}:(t,e)=>{const n=new dv;if(!e.check(t,n))throw Kt(`Expected value to be of type ${e.constructor.name}.
|
|
7
|
+
${n.toString()}`)};class Nv{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:Ms(e),h:n}),this}else(e){return this.if(Wo,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const s=this.patterns[r];if(s.if.check(e))return s.h(e,n)}throw Kt("Unhandled pattern")}}}const Mv=t=>new Nv(t),Kf=Mv(Wo).if(Vf,(t,e)=>fc(e,Bu,$o)).if(Hf,(t,e)=>lv(e)).if(Tv,(t,e)=>Yu(e)).if(Av,(t,e)=>BigInt(fc(e,Bu,$o))).if(Bo,(t,e)=>Mr(e,hc(e,t.shape))).if(wv,(t,e)=>{const n={};for(const r in t.shape){let s=t.shape[r];if(mv.check(s)){if(Yu(e))continue;s=s.shape}n[r]=Kf(s,e)}return n}).if(Sv,(t,e)=>{const n=[],r=Tf(e,0,42);for(let s=0;s<r;s++)n.push(Mr(e,t.shape));return n}).if(Of,(t,e)=>hc(e,t.shape)).if(Ov,(t,e)=>null).if(Dv,(t,e)=>{const n=Mr(e,t.res);return()=>n}).if(Pv,(t,e)=>Mr(e,hc(e,[Hr,ns,mi,qf,Ja,pi,Uf(Hr),Ff(ls("a","b","c"),Hr)]))).if(xv,(t,e)=>{const n={},r=fc(e,0,3);for(let s=0;s<r;s++){const o=Mr(e,t.shape.keys),i=Mr(e,t.shape.values);n[o]=i}return n}).done(),Mr=(t,e)=>Kf(Ms(e),t),on=typeof document<"u"?document:{},Fv=t=>on.createElement(t),Iv=()=>on.createDocumentFragment();ut(t=>t.nodeType===Kv);const $v=t=>on.createTextNode(t);typeof DOMParser<"u"&&new DOMParser;const Uv=(t,e)=>(cv(e,(n,r)=>{r===!1?t.removeAttribute(n):r===!0?t.setAttribute(n,""):t.setAttribute(n,r)}),t),zv=t=>{const e=Iv();for(let n=0;n<t.length;n++)Gf(e,t[n]);return e},Bv=(t,e)=>(Gf(t,zv(e)),t),nj=(t,e=[],n=[])=>Bv(Uv(Fv(t),e),n);ut(t=>t.nodeType===Vv);const rj=$v;ut(t=>t.nodeType===Hv);const Wv=t=>ex(t,(e,n)=>`${n}:${e};`).join(""),Gf=(t,e)=>t.appendChild(e),Vv=on.ELEMENT_NODE,Hv=on.TEXT_NODE;on.CDATA_SECTION_NODE;on.COMMENT_NODE;const qv=on.DOCUMENT_NODE;on.DOCUMENT_TYPE_NODE;const Kv=on.DOCUMENT_FRAGMENT_NODE;ut(t=>t.nodeType===qv);const kn=Symbol,Jf=kn(),Yf=kn(),Gv=kn(),Jv=kn(),Yv=kn(),Xf=kn(),Xv=kn(),Ya=kn(),Zv=kn(),Qv=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const s=t[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const s=t[r];s instanceof Symbol||n.push(s)}return n},eS={[Jf]:hn("font-weight","bold"),[Yf]:hn("font-weight","normal"),[Gv]:hn("color","blue"),[Yv]:hn("color","green"),[Jv]:hn("color","grey"),[Xf]:hn("color","red"),[Xv]:hn("color","purple"),[Ya]:hn("color","orange"),[Zv]:hn("color","black")},tS=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],r=Et();let s=[],o=0;for(;o<t.length;o++){const i=t[o],c=eS[i];if(c!==void 0)r.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){const l=Wv(r);o>0||l.length>0?(e.push("%c"+i),n.push(l)):e.push(i)}else break}}for(o>0&&(s=n,s.unshift(e.join("")));o<t.length;o++){const i=t[o];i instanceof Symbol||s.push(i)}return s},Zf=Yx?tS:Qv,nS=(...t)=>{console.log(...Zf(t)),eh.forEach(e=>e.print(t))},Qf=(...t)=>{console.warn(...Zf(t)),t.unshift(Ya),eh.forEach(e=>e.print(t))},eh=zn(),th=t=>({[Symbol.iterator](){return this},next:t}),rS=(t,e)=>th(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),pc=(t,e)=>th(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class gi{constructor(e,n){this.clock=e,this.len=n}}class us{constructor(){this.clients=new Map}}const rs=(t,e,n)=>e.clients.forEach((r,s)=>{const o=t.doc.store.clients.get(s);if(o!=null){const i=o[o.length-1],c=i.id.clock+i.length;for(let l=0,d=r[l];l<r.length&&d.clock<c;d=r[++l])gh(t,o,d.clock,d.len,n)}}),sS=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=qt((n+r)/2),o=t[s],i=o.clock;if(i<=e){if(e<i+o.len)return s;n=s+1}else r=s-1}return null},Gs=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&sS(n,e.clock)!==null},Xa=t=>{t.clients.forEach(e=>{e.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],o=e[n];s.clock+s.len>=o.clock?e[r-1]=new gi(s.clock,vr(s.len,o.clock+o.len-s.clock)):(r<n&&(e[r]=o),r++)}e.length=r})},Gc=t=>{const e=new us;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const o=r.slice();for(let i=n+1;i<t.length;i++)nx(o,t[i].clients.get(s)||[]);e.clients.set(s,o)}});return Xa(e),e},Fs=(t,e,n,r)=>{sn(t.clients,e,()=>[]).push(new gi(n,r))},oS=()=>new us,iS=t=>{const e=oS();return t.clients.forEach((n,r)=>{const s=[];for(let o=0;o<n.length;o++){const i=n[o];if(i.deleted){const c=i.id.clock;let l=i.length;if(o+1<n.length)for(let d=n[o+1];o+1<n.length&&d.deleted;d=n[++o+1])l+=d.length;s.push(new gi(c,l))}}s.length>0&&e.clients.set(r,s)}),e},ds=(t,e)=>{se(t.restEncoder,e.clients.size),vn(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),se(t.restEncoder,n);const s=r.length;se(t.restEncoder,s);for(let o=0;o<s;o++){const i=r[o];t.writeDsClock(i.clock),t.writeDsLen(i.len)}})},Za=t=>{const e=new us,n=me(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=me(t.restDecoder),o=me(t.restDecoder);if(o>0){const i=sn(e.clients,s,()=>[]);for(let c=0;c<o;c++)i.push(new gi(t.readDsClock(),t.readDsLen()))}}return e},Zu=(t,e,n)=>{const r=new us,s=me(t.restDecoder);for(let o=0;o<s;o++){t.resetDsCurVal();const i=me(t.restDecoder),c=me(t.restDecoder),l=n.clients.get(i)||[],d=Ge(n,i);for(let h=0;h<c;h++){const f=t.readDsClock(),p=f+t.readDsLen();if(f<d){d<p&&Fs(r,i,d,p-d);let g=en(l,f),m=l[g];for(!m.deleted&&m.id.clock<f&&(l.splice(g+1,0,Xo(e,m,f-m.id.clock)),g++);g<l.length&&(m=l[g++],m.id.clock<p);)m.deleted||(p<m.id.clock+m.length&&l.splice(g,0,Xo(e,m,p-m.id.clock)),m.delete(e))}else Fs(r,i,f,p-f)}}if(r.clients.size>0){const o=new pr;return se(o.restEncoder,0),ds(o,r),o.toUint8Array()}return null},nh=Cf;class Sr extends Na{constructor({guid:e=Ox(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:o=null,autoLoad:i=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=nh(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new ph,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=i,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=ts(d=>{this.on("load",()=>{this.isLoaded=!0,d(this)})});const l=()=>ts(d=>{const h=f=>{(f===void 0||f===!0)&&(this.off("sync",h),d())};this.on("sync",h)});this.on("sync",d=>{d===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=d===void 0||d===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&$e(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(vn(this.subdocs).map(e=>e.guid))}transact(e,n=null){return $e(this,e,n)}get(e,n=lt){const r=sn(this.share,e,()=>{const o=new n;return o._integrate(this,null),o}),s=r.constructor;if(n!==lt&&s!==n)if(s===lt){const o=new n;o._map=r._map,r._map.forEach(i=>{for(;i!==null;i=i.left)i.parent=o}),o._start=r._start;for(let i=o._start;i!==null;i=i.right)i.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,Gr)}getText(e=""){return this.get(e,is)}getMap(e=""){return this.get(e,os)}getXmlElement(e=""){return this.get(e,cs)}getXmlFragment(e=""){return this.get(e,mr)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,vn(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Sr({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,$e(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class rh{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return me(this.restDecoder)}readDsLen(){return me(this.restDecoder)}}class sh extends rh{readLeftID(){return Se(me(this.restDecoder),me(this.restDecoder))}readRightID(){return Se(me(this.restDecoder),me(this.restDecoder))}readClient(){return me(this.restDecoder)}readInfo(){return es(this.restDecoder)}readString(){return Ve(this.restDecoder)}readParentInfo(){return me(this.restDecoder)===1}readTypeRef(){return me(this.restDecoder)}readLen(){return me(this.restDecoder)}readAny(){return Ls(this.restDecoder)}readBuf(){return ov(mt(this.restDecoder))}readJSON(){return JSON.parse(Ve(this.restDecoder))}readKey(){return Ve(this.restDecoder)}}class cS{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=me(this.restDecoder),this.dsCurrVal}readDsLen(){const e=me(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class ss extends cS{constructor(e){super(e),this.keys=[],me(e),this.keyClockDecoder=new dc(mt(e)),this.clientDecoder=new Po(mt(e)),this.leftClockDecoder=new dc(mt(e)),this.rightClockDecoder=new dc(mt(e)),this.infoDecoder=new Gu(mt(e),es),this.stringDecoder=new Px(mt(e)),this.parentInfoDecoder=new Gu(mt(e),es),this.typeRefDecoder=new Po(mt(e)),this.lenDecoder=new Po(mt(e))}readLeftID(){return new qr(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new qr(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 Ls(this.restDecoder)}readBuf(){return mt(this.restDecoder)}readJSON(){return Ls(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class oh{constructor(){this.restEncoder=qe()}toUint8Array(){return Ie(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){se(this.restEncoder,e)}writeDsLen(e){se(this.restEncoder,e)}}class Js extends oh{writeLeftID(e){se(this.restEncoder,e.client),se(this.restEncoder,e.clock)}writeRightID(e){se(this.restEncoder,e.client),se(this.restEncoder,e.clock)}writeClient(e){se(this.restEncoder,e)}writeInfo(e){Wc(this.restEncoder,e)}writeString(e){ft(this.restEncoder,e)}writeParentInfo(e){se(this.restEncoder,e?1:0)}writeTypeRef(e){se(this.restEncoder,e)}writeLen(e){se(this.restEncoder,e)}writeAny(e){Os(this.restEncoder,e)}writeBuf(e){He(this.restEncoder,e)}writeJSON(e){ft(this.restEncoder,JSON.stringify(e))}writeKey(e){ft(this.restEncoder,e)}}class ih{constructor(){this.restEncoder=qe(),this.dsCurrVal=0}toUint8Array(){return Ie(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,se(this.restEncoder,n)}writeDsLen(e){e===0&&Pt(),se(this.restEncoder,e-1),this.dsCurrVal+=e}}class pr extends ih{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new uc,this.clientEncoder=new _o,this.leftClockEncoder=new uc,this.rightClockEncoder=new uc,this.infoEncoder=new Hu(Wc),this.stringEncoder=new Sx,this.parentInfoEncoder=new Hu(Wc),this.typeRefEncoder=new _o,this.lenEncoder=new _o}toUint8Array(){const e=qe();return se(e,0),He(e,this.keyClockEncoder.toUint8Array()),He(e,this.clientEncoder.toUint8Array()),He(e,this.leftClockEncoder.toUint8Array()),He(e,this.rightClockEncoder.toUint8Array()),He(e,Ie(this.infoEncoder)),He(e,this.stringEncoder.toUint8Array()),He(e,Ie(this.parentInfoEncoder)),He(e,this.typeRefEncoder.toUint8Array()),He(e,this.lenEncoder.toUint8Array()),li(e,Ie(this.restEncoder)),Ie(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?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Os(this.restEncoder,e)}writeBuf(e){He(this.restEncoder,e)}writeJSON(e){Os(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const aS=(t,e,n,r)=>{r=vr(r,e[0].id.clock);const s=en(e,r);se(t.restEncoder,e.length-s),t.writeClient(n),se(t.restEncoder,r);const o=e[s];o.write(t,r-o.id.clock);for(let i=s+1;i<e.length;i++)e[i].write(t,0)},Qa=(t,e,n)=>{const r=new Map;n.forEach((s,o)=>{Ge(e,o)>s&&r.set(o,s)}),yi(e).forEach((s,o)=>{n.has(o)||r.set(o,0)}),se(t.restEncoder,r.size),vn(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{aS(t,e.clients.get(s),s,o)})},lS=(t,e)=>{const n=Et(),r=me(t.restDecoder);for(let s=0;s<r;s++){const o=me(t.restDecoder),i=new Array(o),c=t.readClient();let l=me(t.restDecoder);n.set(c,{i:0,refs:i});for(let d=0;d<o;d++){const h=t.readInfo();switch(ai&h){case 0:{const f=t.readLen();i[d]=new Tt(Se(c,l),f),l+=f;break}case 10:{const f=me(t.restDecoder);i[d]=new Ot(Se(c,l),f),l+=f;break}default:{const f=(h&(wn|xt))===0,p=new Ue(Se(c,l),null,(h&xt)===xt?t.readLeftID():null,null,(h&wn)===wn?t.readRightID():null,f?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,f&&(h&As)===As?t.readString():null,Mh(t,h));i[d]=p,l+=p.length}}}}return n},uS=(t,e,n)=>{const r=[];let s=vn(n.keys()).sort((g,m)=>g-m);if(s.length===0)return null;const o=()=>{if(s.length===0)return null;let g=n.get(s[s.length-1]);for(;g.refs.length===g.i;)if(s.pop(),s.length>0)g=n.get(s[s.length-1]);else return null;return g};let i=o();if(i===null)return null;const c=new ph,l=new Map,d=(g,m)=>{const b=l.get(g);(b==null||b>m)&&l.set(g,m)};let h=i.refs[i.i++];const f=new Map,p=()=>{for(const g of r){const m=g.id.client,b=n.get(m);b?(b.i--,c.clients.set(m,b.refs.slice(b.i)),n.delete(m),b.i=0,b.refs=[]):c.clients.set(m,[g]),s=s.filter(S=>S!==m)}r.length=0};for(;;){if(h.constructor!==Ot){const m=sn(f,h.id.client,()=>Ge(e,h.id.client))-h.id.clock;if(m<0)r.push(h),d(h.id.client,h.id.clock-1),p();else{const b=h.getMissing(t,e);if(b!==null){r.push(h);const S=n.get(b)||{refs:[],i:0};if(S.refs.length===S.i)d(b,Ge(e,b)),p();else{h=S.refs[S.i++];continue}}else(m===0||m<h.length)&&(h.integrate(t,m),f.set(h.id.client,h.id.clock+h.length))}}if(r.length>0)h=r.pop();else if(i!==null&&i.i<i.refs.length)h=i.refs[i.i++];else{if(i=o(),i===null)break;h=i.refs[i.i++]}}if(c.clients.size>0){const g=new pr;return Qa(g,c,new Map),se(g.restEncoder,0),{missing:l,update:g.toUint8Array()}}return null},dS=(t,e)=>Qa(t,e.doc.store,e.beforeState),fS=(t,e,n,r=new ss(t))=>$e(e,s=>{s.local=!1;let o=!1;const i=s.doc,c=i.store,l=lS(r,i),d=uS(s,c,l),h=c.pendingStructs;if(h){for(const[p,g]of h.missing)if(g<Ge(c,p)){o=!0;break}if(d){for(const[p,g]of d.missing){const m=h.missing.get(p);(m==null||m>g)&&h.missing.set(p,g)}h.update=Ho([h.update,d.update])}}else c.pendingStructs=d;const f=Zu(r,s,c);if(c.pendingDs){const p=new ss(Kn(c.pendingDs));me(p.restDecoder);const g=Zu(p,s,c);f&&g?c.pendingDs=Ho([f,g]):c.pendingDs=f||g}else c.pendingDs=f;if(o){const p=c.pendingStructs.update;c.pendingStructs=null,ch(s.doc,p)}},n,!1),ch=(t,e,n,r=ss)=>{const s=Kn(e);fS(s,t,n,new r(s))},ah=(t,e,n)=>ch(t,e,n,sh),hS=(t,e,n=new Map)=>{Qa(t,e.store,n),ds(t,iS(e.store))},pS=(t,e=new Uint8Array([0]),n=new pr)=>{const r=lh(e);hS(n,t,r);const s=[n.toUint8Array()];if(t.store.pendingDs&&s.push(t.store.pendingDs),t.store.pendingStructs&&s.push(OS(t.store.pendingStructs.update,e)),s.length>1){if(n.constructor===Js)return AS(s.map((o,i)=>i===0?o:NS(o)));if(n.constructor===pr)return Ho(s)}return s[0]},el=(t,e)=>pS(t,e,new Js),mS=t=>{const e=new Map,n=me(t.restDecoder);for(let r=0;r<n;r++){const s=me(t.restDecoder),o=me(t.restDecoder);e.set(s,o)}return e},lh=t=>mS(new rh(Kn(t))),uh=(t,e)=>(se(t.restEncoder,e.size),vn(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{se(t.restEncoder,n),se(t.restEncoder,r)}),t),gS=(t,e)=>uh(t,yi(e.store)),yS=(t,e=new ih)=>(t instanceof Map?uh(e,t):gS(e,t),e.toUint8Array()),wS=t=>yS(t,new oh);class bS{constructor(){this.l=[]}}const Qu=()=>new bS,ed=(t,e)=>t.l.push(e),td=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},dh=(t,e,n)=>Va(t.l,[e,n]);class qr{constructor(e,n){this.client=e,this.clock=n}}const zr=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,Se=(t,e)=>new qr(t,e),fh=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Pt()},Vo=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class hh{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}const sj=t=>{const e={};return t.type&&(e.type=t.type),t.tname&&(e.tname=t.tname),t.item&&(e.item=t.item),t.assoc!=null&&(e.assoc=t.assoc),e},oj=t=>new hh(t.type==null?null:Se(t.type.client,t.type.clock),t.tname??null,t.item==null?null:Se(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class xS{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const vS=(t,e,n=0)=>new xS(t,e,n),yo=(t,e,n)=>{let r=null,s=null;return t._item===null?s=fh(t):r=Se(t._item.id.client,t._item.id.clock),new hh(r,s,e,n)},ij=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return yo(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return yo(t,Se(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return yo(t,r.lastId,n);r=r.right}return yo(t,null,n)},SS=(t,e)=>{const n=Kr(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},cj=(t,e,n=!0)=>{const r=e.store,s=t.item,o=t.type,i=t.tname,c=t.assoc;let l=null,d=0;if(s!==null){if(Ge(r,s.client)<=s.clock)return null;const h=n?Zc(r,s):SS(r,s),f=h.item;if(!(f instanceof Ue))return null;if(l=f.parent,l._item===null||!l._item.deleted){d=f.deleted||!f.countable?0:h.diff+(c>=0?0:1);let p=f.left;for(;p!==null;)!p.deleted&&p.countable&&(d+=p.length),p=p.left}}else{if(i!==null)l=e.get(i);else if(o!==null){if(Ge(r,o.client)<=o.clock)return null;const{item:h}=n?Zc(r,o):{item:Kr(r,o)};if(h instanceof Ue&&h.content instanceof cn)l=h.content.type;else return null}else throw Pt();c>=0?d=l._length:d=0}return vS(l,d,t.assoc)},aj=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&zr(t.item,e.item)&&zr(t.type,e.type)&&t.assoc===e.assoc,Fr=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Gs(e.ds,t.id),Jc=(t,e)=>{const n=sn(t.meta,Jc,zn),r=t.doc.store;n.has(e)||(e.sv.forEach((s,o)=>{s<Ge(r,o)&&Ct(t,Se(o,s))}),rs(t,e.ds,s=>{}),n.add(e))};class ph{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const yi=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},Ge=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},mh=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Pt()}n.push(e)},en=(t,e)=>{let n=0,r=t.length-1,s=t[r],o=s.id.clock;if(o===e)return r;let i=qt(e/(o+s.length-1)*r);for(;n<=r;){if(s=t[i],o=s.id.clock,o<=e){if(e<o+s.length)return i;n=i+1}else r=i-1;i=qt((n+r)/2)}throw Pt()},CS=(t,e)=>{const n=t.clients.get(e.client);return n[en(n,e.clock)]},Kr=CS,Yc=(t,e,n)=>{const r=en(e,n),s=e[r];return s.id.clock<n&&s instanceof Ue?(e.splice(r+1,0,Xo(t,s,n-s.id.clock)),r+1):r},Ct=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Yc(t,n,e.clock)]},nd=(t,e,n)=>{const r=e.clients.get(n.client),s=en(r,n.clock),o=r[s];return n.clock!==o.id.clock+o.length-1&&o.constructor!==Tt&&r.splice(s+1,0,Xo(t,o,n.clock-o.id.clock+1)),o},ES=(t,e,n)=>{const r=t.clients.get(e.id.client);r[en(r,e.id.clock)]=n},gh=(t,e,n,r,s)=>{if(r===0)return;const o=n+r;let i=Yc(t,e,n),c;do c=e[i++],o<c.id.clock+c.length&&Yc(t,e,o),s(c);while(i<e.length&&e[i].id.clock<o)};class kS{constructor(e,n,r){this.doc=e,this.deleteSet=new us,this.beforeState=yi(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const rd=(t,e)=>e.deleteSet.clients.size===0&&!tx(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(Xa(e.deleteSet),dS(t,e),ds(t,e.deleteSet),!0),sd=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&sn(t.changed,e,zn).add(n)},Ao=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Ue&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const o=e-s;return o&&t.splice(e+1-o,o),o},RS=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const o=e.clients.get(r);for(let i=s.length-1;i>=0;i--){const c=s[i],l=c.clock+c.len;for(let d=en(o,c.clock),h=o[d];d<o.length&&h.id.clock<l;h=o[++d]){const f=o[d];if(c.clock+c.len<=f.id.clock)break;f instanceof Ue&&f.deleted&&!f.keep&&n(f)&&f.gc(e,!1)}}}},DS=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let o=n.length-1;o>=0;o--){const i=n[o],c=Ma(s.length-1,1+en(s,i.clock+i.len-1));for(let l=c,d=s[l];l>0&&d.id.clock>=i.clock;d=s[l])l-=1+Ao(s,l)}})},yh=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,o=n.deleteSet,i=n._mergeStructs;try{Xa(o),n.afterState=yi(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const c=[];n.changed.forEach((l,d)=>c.push(()=>{(d._item===null||!d._item.deleted)&&d._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,d)=>{d._dEH.l.length>0&&(d._item===null||!d._item.deleted)&&(l=l.filter(h=>h.target._item===null||!h.target._item.deleted),l.forEach(h=>{h.currentTarget=d,h._path=null}),l.sort((h,f)=>h.path.length-f.path.length),c.push(()=>{dh(d._dEH,l,n)}))}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{n._needFormattingCleanup&&JS(n)})}),Va(c,[])}finally{r.gc&&RS(o,s,r.gcFilter),DS(o,s),n.afterState.forEach((h,f)=>{const p=n.beforeState.get(f)||0;if(p!==h){const g=s.clients.get(f),m=vr(en(g,p),1);for(let b=g.length-1;b>=m;)b-=1+Ao(g,b)}});for(let h=i.length-1;h>=0;h--){const{client:f,clock:p}=i[h].id,g=s.clients.get(f),m=en(g,p);m+1<g.length&&Ao(g,m+1)>1||m>0&&Ao(g,m)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(nS(Ya,Jf,"[yjs] ",Yf,Xf,"Changed the client-id because another client seems to be using it."),r.clientID=nh()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const h=new Js;rd(h,n)&&r.emit("update",[h.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const h=new pr;rd(h,n)&&r.emit("updateV2",[h.toUint8Array(),n.origin,r,n])}const{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:d}=n;(c.size>0||d.size>0||l.size>0)&&(c.forEach(h=>{h.clientID=r.clientID,h.collectionid==null&&(h.collectionid=r.collectionid),r.subdocs.add(h)}),d.forEach(h=>r.subdocs.delete(h)),r.emit("subdocs",[{loaded:l,added:c,removed:d},r,n]),d.forEach(h=>h.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):yh(t,e+1)}}},$e=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let o=!1,i=null;t._transaction===null&&(o=!0,t._transaction=new kS(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{i=e(t._transaction)}finally{if(o){const c=t._transaction===s[0];t._transaction=null,c&&yh(s,0)}}return i};class jS{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const od=(t,e,n)=>{rs(t,n.deletions,r=>{r instanceof Ue&&e.scope.some(s=>s===t.doc||Vo(s,r))&&al(r,!1)})},id=(t,e,n)=>{let r=null;const s=t.doc,o=t.scope;$e(s,c=>{for(;e.length>0&&t.currStackItem===null;){const l=s.store,d=e.pop(),h=new Set,f=[];let p=!1;rs(c,d.insertions,g=>{if(g instanceof Ue){if(g.redone!==null){let{item:m,diff:b}=Zc(l,g.id);b>0&&(m=Ct(c,Se(m.id.client,m.id.clock+b))),g=m}!g.deleted&&o.some(m=>m===c.doc||Vo(m,g))&&f.push(g)}}),rs(c,d.deletions,g=>{g instanceof Ue&&o.some(m=>m===c.doc||Vo(m,g))&&!Gs(d.insertions,g.id)&&h.add(g)}),h.forEach(g=>{p=Nh(c,g,h,d.insertions,t.ignoreRemoteMapChanges,t)!==null||p});for(let g=f.length-1;g>=0;g--){const m=f[g];t.deleteFilter(m)&&(m.delete(c),p=!0)}t.currStackItem=p?d:null}c.changed.forEach((l,d)=>{l.has(null)&&d._searchMarker&&(d._searchMarker.length=0)}),r=c},t);const i=t.currStackItem;if(i!=null){const c=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:c,origin:t},t]),t.currStackItem=null}return i};class _S extends Na{constructor(e,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:c=Qr(e)?e[0].doc:e instanceof Sr?e:e.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(e),this.deleteFilter=s,o.add(this),this.trackedOrigins=o,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(S=>l.changedParentTypes.has(S)||S===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const d=this.undoing,h=this.redoing,f=d?this.redoStack:this.undoStack;d?this.stopCapturing():h||this.clear(!1,!0);const p=new us;l.afterState.forEach((S,C)=>{const D=l.beforeState.get(C)||0,y=S-D;y>0&&Fs(p,C,D,y)});const g=Bn();let m=!1;if(this.lastChange>0&&g-this.lastChange<this.captureTimeout&&f.length>0&&!d&&!h){const S=f[f.length-1];S.deletions=Gc([S.deletions,l.deleteSet]),S.insertions=Gc([S.insertions,p])}else f.push(new jS(l.deleteSet,p)),m=!0;!d&&!h&&(this.lastChange=g),rs(l,l.deleteSet,S=>{S instanceof Ue&&this.scope.some(C=>C===l.doc||Vo(C,S))&&al(S,!0)});const b=[{stackItem:f[f.length-1],origin:l.origin,type:d?"redo":"undo",changedParentTypes:l.changedParentTypes},this];m?this.emit("stack-item-added",b):this.emit("stack-item-updated",b)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=Qr(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof lt?r.doc!==this.doc:r!==this.doc)&&Qf("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>od(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>od(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=id(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=id(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*PS(t){const e=me(t.restDecoder);for(let n=0;n<e;n++){const r=me(t.restDecoder),s=t.readClient();let o=me(t.restDecoder);for(let i=0;i<r;i++){const c=t.readInfo();if(c===10){const l=me(t.restDecoder);yield new Ot(Se(s,o),l),o+=l}else if((ai&c)!==0){const l=(c&(wn|xt))===0,d=new Ue(Se(s,o),null,(c&xt)===xt?t.readLeftID():null,null,(c&wn)===wn?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(c&As)===As?t.readString():null,Mh(t,c));yield d,o+=d.length}else{const l=t.readLen();yield new Tt(Se(s,o),l),o+=l}}}}class tl{constructor(e,n){this.gen=PS(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Ot);return this.curr}}class nl{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const AS=t=>Ho(t,sh,Js),TS=(t,e)=>{if(t.constructor===Tt){const{client:n,clock:r}=t.id;return new Tt(Se(n,r+e),t.length-e)}else if(t.constructor===Ot){const{client:n,clock:r}=t.id;return new Ot(Se(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new Ue(Se(r,s+e),null,Se(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},Ho=(t,e=ss,n=pr)=>{if(t.length===1)return t[0];const r=t.map(h=>new e(Kn(h)));let s=r.map(h=>new tl(h,!0)),o=null;const i=new n,c=new nl(i);for(;s=s.filter(p=>p.curr!==null),s.sort((p,g)=>{if(p.curr.id.client===g.curr.id.client){const m=p.curr.id.clock-g.curr.id.clock;return m===0?p.curr.constructor===g.curr.constructor?0:p.curr.constructor===Ot?1:-1:m}else return g.curr.id.client-p.curr.id.client}),s.length!==0;){const h=s[0],f=h.curr.id.client;if(o!==null){let p=h.curr,g=!1;for(;p!==null&&p.id.clock+p.length<=o.struct.id.clock+o.struct.length&&p.id.client>=o.struct.id.client;)p=h.next(),g=!0;if(p===null||p.id.client!==f||g&&p.id.clock>o.struct.id.clock+o.struct.length)continue;if(f!==o.struct.id.client)Mn(c,o.struct,o.offset),o={struct:p,offset:0},h.next();else if(o.struct.id.clock+o.struct.length<p.id.clock)if(o.struct.constructor===Ot)o.struct.length=p.id.clock+p.length-o.struct.id.clock;else{Mn(c,o.struct,o.offset);const m=p.id.clock-o.struct.id.clock-o.struct.length;o={struct:new Ot(Se(f,o.struct.id.clock+o.struct.length),m),offset:0}}else{const m=o.struct.id.clock+o.struct.length-p.id.clock;m>0&&(o.struct.constructor===Ot?o.struct.length-=m:p=TS(p,m)),o.struct.mergeWith(p)||(Mn(c,o.struct,o.offset),o={struct:p,offset:0},h.next())}}else o={struct:h.curr,offset:0},h.next();for(let p=h.curr;p!==null&&p.id.client===f&&p.id.clock===o.struct.id.clock+o.struct.length&&p.constructor!==Ot;p=h.next())Mn(c,o.struct,o.offset),o={struct:p,offset:0}}o!==null&&(Mn(c,o.struct,o.offset),o=null),rl(c);const l=r.map(h=>Za(h)),d=Gc(l);return ds(i,d),i.toUint8Array()},OS=(t,e,n=ss,r=pr)=>{const s=lh(e),o=new r,i=new nl(o),c=new n(Kn(t)),l=new tl(c,!1);for(;l.curr;){const h=l.curr,f=h.id.client,p=s.get(f)||0;if(l.curr.constructor===Ot){l.next();continue}if(h.id.clock+h.length>p)for(Mn(i,h,vr(p-h.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)Mn(i,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=p;)l.next()}rl(i);const d=Za(c);return ds(o,d),o.toUint8Array()},wh=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Ie(t.encoder.restEncoder)}),t.encoder.restEncoder=qe(),t.written=0)},Mn=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&wh(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),se(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},rl=t=>{wh(t);const e=t.encoder.restEncoder;se(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];se(e,r.written),li(e,r.restEncoder)}},LS=(t,e,n,r)=>{const s=new n(Kn(t)),o=new tl(s,!1),i=new r,c=new nl(i);for(let d=o.curr;d!==null;d=o.next())Mn(c,e(d),0);rl(c);const l=Za(s);return ds(i,l),i.toUint8Array()},NS=t=>LS(t,Hx,ss,Js),cd="You must not compute changes after the event-handler fired.";class wi{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=MS(this.currentTarget,this.target))}deletes(e){return Gs(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Kt(cd);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const o=n._map.get(s);let i,c;if(this.adds(o)){let l=o.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(o))if(l!==null&&this.deletes(l))i="delete",c=lc(l.content.getContent());else return;else l!==null&&this.deletes(l)?(i="update",c=lc(l.content.getContent())):(i="add",c=void 0)}else if(this.deletes(o))i="delete",c=lc(o.content.getContent());else return;e.set(s,{action:i,oldValue:c})}}),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 Kt(cd);const n=this.target,r=zn(),s=zn(),o=[];if(e={added:r,deleted:s,delta:o,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null;const l=()=>{c&&o.push(c)};for(let d=n._start;d!==null;d=d.right)d.deleted?this.deletes(d)&&!this.adds(d)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=d.length,s.add(d)):this.adds(d)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(d.content.getContent()),r.add(d)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=d.length);c!==null&&c.retain===void 0&&l()}this._changes=e}return e}}const MS=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},yt=()=>{Qf("Invalid access: Add Yjs type to a document before reading data.")},bh=80;let sl=0;class FS{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=sl++}}const IS=t=>{t.timestamp=sl++},xh=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=sl++},$S=(t,e,n)=>{if(t.length>=bh){const r=t.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return xh(r,e,n),r}else{const r=new FS(e,n);return t.push(r),r}},bi=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,i)=>jo(e-o.index)<jo(e-i.index)?o:i);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,IS(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=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&&(s-=r.length);return n!==null&&jo(n.index-s)<r.parent.length/bh?(xh(n,r,s),n):$S(t._searchMarker,r,s)},Is=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let o=s.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(s.index-=o.length);if(o===null||o.marker===!0){t.splice(r,1);continue}s.p=o,o.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=vr(e,s.index+n))}},xi=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;sn(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;dh(r._eH,n,e)};class lt{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Qu(),this._dEH=Qu(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Ht()}clone(){throw Ht()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){ed(this._eH,e)}observeDeep(e){ed(this._dEH,e)}unobserve(e){td(this._eH,e)}unobserveDeep(e){td(this._dEH,e)}toJSON(){}}const vh=(t,e,n)=>{t.doc??yt(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let o=t._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){const i=o.content.getContent();if(i.length<=e)e-=i.length;else{for(let c=e;c<i.length&&r>0;c++)s.push(i[c]),r--;e=0}}o=o.right}return s},Sh=t=>{t.doc??yt();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},$s=(t,e)=>{let n=0,r=t._start;for(t.doc??yt();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let o=0;o<s.length;o++)e(s[o],n++,t)}r=r.right}},Ch=(t,e)=>{const n=[];return $s(t,(r,s)=>{n.push(e(r,s,t))}),n},US=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},Eh=(t,e)=>{t.doc??yt();const n=bi(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},qo=(t,e,n,r)=>{let s=n;const o=t.doc,i=o.clientID,c=o.store,l=n===null?e._start:n.right;let d=[];const h=()=>{d.length>0&&(s=new Ue(Se(i,Ge(c,i)),s,s&&s.lastId,l,l&&l.id,e,null,new gr(d)),s.integrate(t,0),d=[])};r.forEach(f=>{if(f===null)d.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:d.push(f);break;default:switch(h(),f.constructor){case Uint8Array:case ArrayBuffer:s=new Ue(Se(i,Ge(c,i)),s,s&&s.lastId,l,l&&l.id,e,null,new Ys(new Uint8Array(f))),s.integrate(t,0);break;case Sr:s=new Ue(Se(i,Ge(c,i)),s,s&&s.lastId,l,l&&l.id,e,null,new Xs(f)),s.integrate(t,0);break;default:if(f instanceof lt)s=new Ue(Se(i,Ge(c,i)),s,s&&s.lastId,l,l&&l.id,e,null,new cn(f)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},kh=()=>Kt("Length exceeded!"),Rh=(t,e,n,r)=>{if(n>e._length)throw kh();if(n===0)return e._searchMarker&&Is(e._searchMarker,n,r.length),qo(t,e,null,r);const s=n,o=bi(e,n);let i=e._start;for(o!==null&&(i=o.p,n-=o.index,n===0&&(i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0));i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){n<i.length&&Ct(t,Se(i.id.client,i.id.clock+n));break}n-=i.length}return e._searchMarker&&Is(e._searchMarker,s,r.length),qo(t,e,i,r)},zS=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return qo(t,e,s,n)},Dh=(t,e,n,r)=>{if(r===0)return;const s=n,o=r,i=bi(e,n);let c=e._start;for(i!==null&&(c=i.p,n-=i.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&Ct(t,Se(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&Ct(t,Se(c.id.client,c.id.clock+r)),c.delete(t),r-=c.length),c=c.right;if(r>0)throw kh();e._searchMarker&&Is(e._searchMarker,s,-o+r)},Ko=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},ol=(t,e,n,r)=>{const s=e._map.get(n)||null,o=t.doc,i=o.clientID;let c;if(r==null)c=new gr([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new gr([r]);break;case Uint8Array:c=new Ys(r);break;case Sr:c=new Xs(r);break;default:if(r instanceof lt)c=new cn(r);else throw new Error("Unexpected content type")}new Ue(Se(i,Ge(o.store,i)),s,s&&s.lastId,null,null,e,n,c).integrate(t,0)},il=(t,e)=>{t.doc??yt();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},jh=t=>{const e={};return t.doc??yt(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},_h=(t,e)=>{t.doc??yt();const n=t._map.get(e);return n!==void 0&&!n.deleted},BS=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let o=r;for(;o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0));)o=o.left;o!==null&&Fr(o,e)&&(n[s]=o.content.getContent()[o.length-1])}),n},wo=t=>(t.doc??yt(),rS(t._map.entries(),e=>!e[1].deleted));class WS extends wi{}class Gr extends lt{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new Gr;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Gr}clone(){const e=new Gr;return e.insert(0,this.toArray().map(n=>n instanceof lt?n.clone():n)),e}get length(){return this.doc??yt(),this._length}_callObserver(e,n){super._callObserver(e,n),xi(this,e,new WS(this,e))}insert(e,n){this.doc!==null?$e(this.doc,r=>{Rh(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?$e(this.doc,n=>{zS(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?$e(this.doc,r=>{Dh(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return Eh(this,e)}toArray(){return Sh(this)}slice(e=0,n=this.length){return vh(this,e,n)}toJSON(){return this.map(e=>e instanceof lt?e.toJSON():e)}map(e){return Ch(this,e)}forEach(e){$s(this,e)}[Symbol.iterator](){return US(this)}_write(e){e.writeTypeRef(pC)}}const VS=t=>new Gr;class HS extends wi{constructor(e,n,r){super(e,n),this.keysChanged=r}}class os extends lt{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new os}clone(){const e=new os;return this.forEach((n,r)=>{e.set(r,n instanceof lt?n.clone():n)}),e}_callObserver(e,n){xi(this,e,new HS(this,e,n))}toJSON(){this.doc??yt();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof lt?s.toJSON():s}}),e}get size(){return[...wo(this)].length}keys(){return pc(wo(this),e=>e[0])}values(){return pc(wo(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return pc(wo(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??yt(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?$e(this.doc,n=>{Ko(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?$e(this.doc,r=>{ol(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return il(this,e)}has(e){return _h(this,e)}clear(){this.doc!==null?$e(this.doc,e=>{this.forEach(function(n,r,s){Ko(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(mC)}}const qS=t=>new os,Fn=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Wx(t,e);class Xc{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){this.right===null&&Pt(),this.right.content.constructor===st?this.right.deleted||fs(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const ad=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===st?e.right.deleted||fs(e.currentAttributes,e.right.content):e.right.deleted||(n<e.right.length&&Ct(t,Se(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length),e.left=e.right,e.right=e.right.right;return e},bo=(t,e,n,r)=>{const s=new Map,o=r?bi(e,n):null;if(o){const i=new Xc(o.p.left,o.p,o.index,s);return ad(t,i,n-o.index)}else{const i=new Xc(null,e._start,0,s);return ad(t,i,n)}},Ph=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===st&&Fn(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,o=s.clientID;r.forEach((i,c)=>{const l=n.left,d=n.right,h=new Ue(Se(o,Ge(s.store,o)),l,l&&l.lastId,d,d&&d.id,e,null,new st(c,i));h.integrate(t,0),n.right=h,n.forward()})},fs=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},Ah=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===st&&Fn(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},Th=(t,e,n,r)=>{const s=t.doc,o=s.clientID,i=new Map;for(const c in r){const l=r[c],d=n.currentAttributes.get(c)??null;if(!Fn(d,l)){i.set(c,d);const{left:h,right:f}=n;n.right=new Ue(Se(o,Ge(s.store,o)),h,h&&h.lastId,f,f&&f.id,e,null,new st(c,l)),n.right.integrate(t,0),n.forward()}}return i},mc=(t,e,n,r,s)=>{n.currentAttributes.forEach((p,g)=>{s[g]===void 0&&(s[g]=null)});const o=t.doc,i=o.clientID;Ah(n,s);const c=Th(t,e,n,s),l=r.constructor===String?new tn(r):r instanceof lt?new cn(r):new Cr(r);let{left:d,right:h,index:f}=n;e._searchMarker&&Is(e._searchMarker,n.index,l.getLength()),h=new Ue(Se(i,Ge(o.store,i)),d,d&&d.lastId,h,h&&h.id,e,null,l),h.integrate(t,0),n.right=h,n.index=f,n.forward(),Ph(t,e,n,c)},ld=(t,e,n,r,s)=>{const o=t.doc,i=o.clientID;Ah(n,s);const c=Th(t,e,n,s);e:for(;n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===st));){if(!n.right.deleted)switch(n.right.content.constructor){case st:{const{key:l,value:d}=n.right.content,h=s[l];if(h!==void 0){if(Fn(h,d))c.delete(l);else{if(r===0)break e;c.set(l,d)}n.right.delete(t)}else n.currentAttributes.set(l,d);break}default:r<n.right.length&&Ct(t,Se(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
8
|
+
`;n.right=new Ue(Se(i,Ge(o.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new tn(l)),n.right.integrate(t,0),n.forward()}Ph(t,e,n,c)},Oh=(t,e,n,r,s)=>{let o=e;const i=Et();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===st){const d=o.content;i.set(d.key,d)}o=o.right}let c=0,l=!1;for(;e!==o;){if(n===e&&(l=!0),!e.deleted){const d=e.content;if(d.constructor===st){const{key:h,value:f}=d,p=r.get(h)??null;(i.get(h)!==d||p===f)&&(e.delete(t),c++,!l&&(s.get(h)??null)===f&&p!==f&&(p===null?s.delete(h):s.set(h,p))),!l&&!e.deleted&&fs(s,d)}}e=e.right}return c},KS=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===st){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},GS=t=>{let e=0;return $e(t.doc,n=>{let r=t._start,s=t._start,o=Et();const i=Bc(o);for(;s;)s.deleted===!1&&(s.content.constructor===st?fs(i,s.content):(e+=Oh(n,r,s,o,i),o=Bc(i),r=s)),s=s.right}),e},JS=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const o=t.beforeState.get(r)||0;s!==o&&gh(t,n.store.clients.get(r),o,s,i=>{!i.deleted&&i.content.constructor===st&&i.constructor!==Tt&&e.add(i.parent)})}$e(n,r=>{rs(t,t.deleteSet,s=>{if(s instanceof Tt||!s.parent._hasFormatting||e.has(s.parent))return;const o=s.parent;s.content.constructor===st?e.add(o):KS(r,s)});for(const s of e)GS(s)})},ud=(t,e,n)=>{const r=n,s=Bc(e.currentAttributes),o=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case cn:case Cr:case tn:n<e.right.length&&Ct(t,Se(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}o&&Oh(t,o,e.right,s,e.currentAttributes);const i=(e.left||e.right).parent;return i._searchMarker&&Is(i._searchMarker,e.index,-r+n),e};class YS extends wi{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];$e(e,r=>{const s=new Map,o=new Map;let i=this.target._start,c=null;const l={};let d="",h=0,f=0;const p=()=>{if(c!==null){let g=null;switch(c){case"delete":f>0&&(g={delete:f}),f=0;break;case"insert":(typeof d=="object"||d.length>0)&&(g={insert:d},s.size>0&&(g.attributes={},s.forEach((m,b)=>{m!==null&&(g.attributes[b]=m)}))),d="";break;case"retain":h>0&&(g={retain:h},Bx(l)||(g.attributes=Ix({},l))),h=0;break}g&&n.push(g),c=null}};for(;i!==null;){switch(i.content.constructor){case cn:case Cr:this.adds(i)?this.deletes(i)||(p(),c="insert",d=i.content.getContent()[0],p()):this.deletes(i)?(c!=="delete"&&(p(),c="delete"),f+=1):i.deleted||(c!=="retain"&&(p(),c="retain"),h+=1);break;case tn:this.adds(i)?this.deletes(i)||(c!=="insert"&&(p(),c="insert"),d+=i.content.str):this.deletes(i)?(c!=="delete"&&(p(),c="delete"),f+=i.length):i.deleted||(c!=="retain"&&(p(),c="retain"),h+=i.length);break;case st:{const{key:g,value:m}=i.content;if(this.adds(i)){if(!this.deletes(i)){const b=s.get(g)??null;Fn(b,m)?m!==null&&i.delete(r):(c==="retain"&&p(),Fn(m,o.get(g)??null)?delete l[g]:l[g]=m)}}else if(this.deletes(i)){o.set(g,m);const b=s.get(g)??null;Fn(b,m)||(c==="retain"&&p(),l[g]=b)}else if(!i.deleted){o.set(g,m);const b=l[g];b!==void 0&&(Fn(b,m)?b!==null&&i.delete(r):(c==="retain"&&p(),m===null?delete l[g]:l[g]=m))}i.deleted||(c==="insert"&&p(),fs(s,i.content));break}}i=i.right}for(p();n.length>0;){const g=n[n.length-1];if(g.retain!==void 0&&g.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class is extends lt{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??yt(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new is}clone(){const e=new is;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new YS(this,e,n);xi(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??yt();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===tn&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?$e(this.doc,r=>{const s=new Xc(null,this._start,0,new Map);for(let o=0;o<e.length;o++){const i=e[o];if(i.insert!==void 0){const c=!n&&typeof i.insert=="string"&&o===e.length-1&&s.right===null&&i.insert.slice(-1)===`
|
|
9
|
+
`?i.insert.slice(0,-1):i.insert;(typeof c!="string"||c.length>0)&&mc(r,this,s,c,i.attributes||{})}else i.retain!==void 0?ld(r,this,s,i.retain,i.attributes||{}):i.delete!==void 0&&ud(r,s,i.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??yt();const s=[],o=new Map,i=this.doc;let c="",l=this._start;function d(){if(c.length>0){const f={};let p=!1;o.forEach((m,b)=>{p=!0,f[b]=m});const g={insert:c};p&&(g.attributes=f),s.push(g),c=""}}const h=()=>{for(;l!==null;){if(Fr(l,e)||n!==void 0&&Fr(l,n))switch(l.content.constructor){case tn:{const f=o.get("ychange");e!==void 0&&!Fr(l,e)?(f===void 0||f.user!==l.id.client||f.type!=="removed")&&(d(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!Fr(l,n)?(f===void 0||f.user!==l.id.client||f.type!=="added")&&(d(),o.set("ychange",r?r("added",l.id):{type:"added"})):f!==void 0&&(d(),o.delete("ychange")),c+=l.content.str;break}case cn:case Cr:{d();const f={insert:l.content.getContent()[0]};if(o.size>0){const p={};f.attributes=p,o.forEach((g,m)=>{p[m]=g})}s.push(f);break}case st:Fr(l,e)&&(d(),fs(o,l.content));break}l=l.right}d()};return e||n?$e(i,f=>{e&&Jc(f,e),n&&Jc(f,n),h()},"cleanup"):h(),s}insert(e,n,r){if(n.length<=0)return;const s=this.doc;s!==null?$e(s,o=>{const i=bo(o,this,e,!r);r||(r={},i.currentAttributes.forEach((c,l)=>{r[l]=c})),mc(o,this,i,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const s=this.doc;s!==null?$e(s,o=>{const i=bo(o,this,e,!r);mc(o,this,i,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?$e(r,s=>{ud(s,bo(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const s=this.doc;s!==null?$e(s,o=>{const i=bo(o,this,e,!1);i.right!==null&&ld(o,this,i,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?$e(this.doc,n=>{Ko(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?$e(this.doc,r=>{ol(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return il(this,e)}getAttributes(){return jh(this)}_write(e){e.writeTypeRef(gC)}}const XS=t=>new is;class gc{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??yt()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===cs||n.constructor===mr)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=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})}}class mr extends lt{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new mr}clone(){const e=new mr;return e.insert(0,this.toArray().map(n=>n instanceof lt?n.clone():n)),e}get length(){return this.doc??yt(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new gc(this,e)}querySelector(e){e=e.toUpperCase();const r=new gc(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),vn(new gc(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){xi(this,e,new eC(this,n,e))}toString(){return Ch(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),$s(this,o=>{s.insertBefore(o.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?$e(this.doc,r=>{Rh(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)$e(this.doc,r=>{const s=e&&e instanceof lt?e._item:e;qo(r,this,s,n)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(o=>o===e)+1;if(s===0&&e!==null)throw Kt("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?$e(this.doc,r=>{Dh(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return Sh(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Eh(this,e)}slice(e=0,n=this.length){return vh(this,e,n)}forEach(e){$s(this,e)}_write(e){e.writeTypeRef(wC)}}const ZS=t=>new mr;class cs extends mr{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new cs(this.nodeName)}clone(){const e=new cs(this.nodeName),n=this.getAttributes();return Ux(n,(r,s)=>{e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof lt?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const c in e)r.push(c);r.sort();const s=r.length;for(let c=0;c<s;c++){const l=r[c];n.push(l+'="'+e[l]+'"')}const o=this.nodeName.toLocaleLowerCase(),i=n.length>0?" "+n.join(" "):"";return`<${o}${i}>${super.toString()}</${o}>`}removeAttribute(e){this.doc!==null?$e(this.doc,n=>{Ko(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?$e(this.doc,r=>{ol(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return il(this,e)}hasAttribute(e){return _h(this,e)}getAttributes(e){return e?BS(this,e):jh(this)}toDOM(e=document,n={},r){const s=e.createElement(this.nodeName),o=this.getAttributes();for(const i in o){const c=o[i];typeof c=="string"&&s.setAttribute(i,c)}return $s(this,i=>{s.appendChild(i.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(yC),e.writeKey(this.nodeName)}}const QS=t=>new cs(t.readKey());class eC extends wi{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class Go extends os{constructor(e){super(),this.hookName=e}_copy(){return new Go(this.hookName)}clone(){const e=new Go(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const s=n[this.hookName];let o;return s!==void 0?o=s.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(bC),e.writeKey(this.hookName)}}const tC=t=>new Go(t.readKey());class Jo extends is{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Jo}clone(){const e=new Jo;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const n=[];for(const s in e.attributes){const o=[];for(const i in e.attributes[s])o.push({key:i,value:e.attributes[s][i]});o.sort((i,c)=>i.key<c.key?-1:1),n.push({nodeName:s,attrs:o})}n.sort((s,o)=>s.nodeName<o.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const o=n[s];r+=`<${o.nodeName}`;for(let i=0;i<o.attrs.length;i++){const c=o.attrs[i];r+=` ${c.key}="${c.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(xC)}}const nC=t=>new Jo;class cl{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Ht()}mergeWith(e){return!1}write(e,n,r){throw Ht()}integrate(e,n){throw Ht()}}const rC=0;class Tt extends cl{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),mh(e.doc.store,this)}write(e,n){e.writeInfo(rC),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Ys{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ys(this.content)}splice(e){throw Ht()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const sC=t=>new Ys(t.readBuf());class Us{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Us(this.len)}splice(e){const n=new Us(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Fs(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const oC=t=>new Us(t.readLen()),Lh=(t,e)=>new Sr({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Xs{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;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Xs(Lh(this.doc.guid,this.opts))}splice(e){throw Ht()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,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,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const iC=t=>new Xs(Lh(t.readString(),t.readAny()));class Cr{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Cr(this.embed)}splice(e){throw Ht()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const cC=t=>new Cr(t.readJSON());class st{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new st(this.key,this.value)}splice(e){throw Ht()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const aC=t=>new st(t.readKey(),t.readJSON());class Yo{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Yo(this.arr)}splice(e){const n=new Yo(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const o=this.arr[s];e.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}const lC=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new Yo(n)},uC=zo("node_env")==="development";class gr{constructor(e){this.arr=e,uC&&Df(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new gr(this.arr)}splice(e){const n=new gr(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const o=this.arr[s];e.writeAny(o)}}getRef(){return 8}}const dC=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new gr(n)};class tn{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new tn(this.str)}splice(e){const n=new tn(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const fC=t=>new tn(t.readString()),hC=[VS,qS,XS,QS,ZS,tC,nC],pC=0,mC=1,gC=2,yC=3,wC=4,bC=5,xC=6;class cn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new cn(this.type._copy())}splice(e){throw Ht()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const vC=t=>new cn(hC[t.readTypeRef()](t)),Zc=(t,e)=>{let n=e,r=0,s;do r>0&&(n=Se(n.client,n.clock+r)),s=Kr(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof Ue);return{item:s,diff:r}},al=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Xo=(t,e,n)=>{const{client:r,clock:s}=e.id,o=new Ue(Se(r,s+n),e,Se(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&o.markDeleted(),e.keep&&(o.keep=!0),e.redone!==null&&(o.redone=Se(e.redone.client,e.redone.clock+n)),e.right=o,o.right!==null&&(o.right.left=o),t._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),e.length=n,o},dd=(t,e)=>La(t,n=>Gs(n.deletions,e)),Nh=(t,e,n,r,s,o)=>{const i=t.doc,c=i.store,l=i.clientID,d=e.redone;if(d!==null)return Ct(t,d);let h=e.parent._item,f=null,p;if(h!==null&&h.deleted===!0){if(h.redone===null&&(!n.has(h)||Nh(t,h,n,r,s,o)===null))return null;for(;h.redone!==null;)h=Ct(t,h.redone)}const g=h===null?e.parent:h.content.type;if(e.parentSub===null){for(f=e.left,p=e;f!==null;){let C=f;for(;C!==null&&C.parent._item!==h;)C=C.redone===null?null:Ct(t,C.redone);if(C!==null&&C.parent._item===h){f=C;break}f=f.left}for(;p!==null;){let C=p;for(;C!==null&&C.parent._item!==h;)C=C.redone===null?null:Ct(t,C.redone);if(C!==null&&C.parent._item===h){p=C;break}p=p.right}}else{if(p=null,e.right&&!s){for(f=e;f!==null&&f.right!==null&&(f.right.redone||Gs(r,f.right.id)||dd(o.undoStack,f.right.id)||dd(o.redoStack,f.right.id));)for(f=f.right;f.redone;)f=Ct(t,f.redone);if(f&&f.right!==null)return null}else f=g._map.get(e.parentSub)||null;f!==null&&f.parent._item!==h&&(f=g._map.get(e.parentSub)||null)}const m=Ge(c,l),b=Se(l,m),S=new Ue(b,f,f&&f.lastId,p,p&&p.id,g,e.parentSub,e.content.copy());return e.redone=b,al(S,!0),S.integrate(t,0),S};class Ue extends cl{constructor(e,n,r,s,o,i,c,l){super(e,l.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=o,this.parent=i,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?Uu:0}set marker(e){(this.info&cc)>0!==e&&(this.info^=cc)}get marker(){return(this.info&cc)>0}get keep(){return(this.info&$u)>0}set keep(e){this.keep!==e&&(this.info^=$u)}get countable(){return(this.info&Uu)>0}get deleted(){return(this.info&ic)>0}set deleted(e){this.deleted!==e&&(this.info^=ic)}markDeleted(){this.info|=ic}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ge(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ge(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===qr&&this.id.client!==this.parent.client&&this.parent.clock>=Ge(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=nd(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Ct(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Tt||this.right&&this.right.constructor===Tt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Ue?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Ue&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===qr){const r=Kr(n,this.parent);r.constructor===Tt?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=nd(e,e.doc.store,Se(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const o=new Set,i=new Set;for(;s!==null&&s!==this.right;){if(i.add(s),o.add(s),zr(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,o.clear();else if(zr(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&i.has(Kr(e.doc.store,s.origin)))o.has(Kr(e.doc.store,s.origin))||(r=s,o.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),mh(e.doc.store,this),this.content.integrate(e,this),sd(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Tt(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:Se(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&zr(e.origin,this.lastId)&&this.right===e&&zr(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)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.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){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Fs(e.deleteSet,this.id.client,this.id.clock,this.length),sd(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Pt();this.content.gc(e),n?ES(e,this,new Tt(this.id,this.length)):this.content=new Us(this.length)}write(e,n){const r=n>0?Se(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,o=this.parentSub,i=this.content.getRef()&ai|(r===null?0:xt)|(s===null?0:wn)|(o===null?0:As);if(e.writeInfo(i),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const c=this.parent;if(c._item!==void 0){const l=c._item;if(l===null){const d=fh(c);e.writeParentInfo(!0),e.writeString(d)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else c.constructor===String?(e.writeParentInfo(!0),e.writeString(c)):c.constructor===qr?(e.writeParentInfo(!1),e.writeLeftID(c)):Pt();o!==null&&e.writeString(o)}this.content.write(e,n)}}const Mh=(t,e)=>SC[e&ai](t),SC=[()=>{Pt()},oC,lC,sC,fC,cC,aC,vC,dC,iC,()=>{Pt()}],CC=10;class Ot extends cl{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Pt()}write(e,n){e.writeInfo(CC),se(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Fh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Ih="__ $YJS$ __";Fh[Ih]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Fh[Ih]=!0;function EC(t){for(let e=0;e<t.length;e+=1)t[e]=Math.floor(Math.random()*256);return t}function kC(t){t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,n=>n.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function Qc(t=globalThis.crypto){if(typeof t?.randomUUID=="function")return t.randomUUID();const e=new Uint8Array(16),n=typeof t?.getRandomValues=="function"?t.getRandomValues(e):EC(e);return kC(n)}const $h=new Map;class RC{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:sv(n.newValue||"")}),Nx(this._onChange)}postMessage(e){kf.setItem(this.room,rv(Zx(e)))}close(){Mx(this._onChange)}}const DC=typeof BroadcastChannel>"u"?RC:BroadcastChannel,ll=t=>sn($h,t,()=>{const e=zn(),n=new DC(t);return n.onmessage=r=>e.forEach(s=>s(r.data,"broadcastchannel")),{bc:n,subs:e}}),jC=(t,e)=>(ll(t).subs.add(e),e),_C=(t,e)=>{const n=ll(t),r=n.subs.delete(e);return r&&n.subs.size===0&&(n.bc.close(),$h.delete(t)),r},Ir=(t,e,n=null)=>{const r=ll(t);r.bc.postMessage(e),r.subs.forEach(s=>s(e,n))},Uh=0,ul=1,zh=2,Zo=(t,e)=>{se(t,Uh);const n=wS(e);He(t,n)},Bh=(t,e,n)=>{se(t,ul),He(t,el(e,n))},PC=(t,e,n)=>Bh(e,n,mt(t)),Wh=(t,e,n,r)=>{try{ah(e,mt(t),n)}catch(s){r?.(s),console.error("Caught error while handling a Yjs update",s)}},AC=(t,e)=>{se(t,zh),He(t,e)},TC=Wh,OC=(t,e,n,r,s)=>{const o=me(t);switch(o){case Uh:PC(t,e,n);break;case ul:Wh(t,n,r,s);break;case zh:TC(t,n,r,s);break;default:throw new Error("Unknown message type")}return o},LC=0,NC=(t,e,n)=>{me(t)===LC&&n(e,Ve(t))},yc=3e4;class MC extends wf{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=Bn();this.getLocalState()!==null&&yc/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((s,o)=>{o!==this.clientID&&yc<=n-s.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&dl(this,r,"timeout")},qt(yc/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){const n=this.clientID,r=this.meta.get(n),s=r===void 0?0:r.clock+1,o=this.states.get(n);e===null?this.states.delete(n):this.states.set(n,e),this.meta.set(n,{clock:s,lastUpdated:Bn()});const i=[],c=[],l=[],d=[];e===null?d.push(n):o==null?e!=null&&i.push(n):(c.push(n),Vr(o,e)||l.push(n)),(i.length>0||l.length>0||d.length>0)&&this.emit("change",[{added:i,updated:l,removed:d},"local"]),this.emit("update",[{added:i,updated:c,removed:d},"local"])}setLocalStateField(e,n){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:n})}getStates(){return this.states}}const dl=(t,e,n)=>{const r=[];for(let s=0;s<e.length;s++){const o=e[s];if(t.states.has(o)){if(t.states.delete(o),o===t.clientID){const i=t.meta.get(o);t.meta.set(o,{clock:i.clock+1,lastUpdated:Bn()})}r.push(o)}}r.length>0&&(t.emit("change",[{added:[],updated:[],removed:r},n]),t.emit("update",[{added:[],updated:[],removed:r},n]))},Jr=(t,e,n=t.states)=>{const r=e.length,s=qe();se(s,r);for(let o=0;o<r;o++){const i=e[o],c=n.get(i)||null,l=t.meta.get(i).clock;se(s,i),se(s,l),ft(s,JSON.stringify(c))}return Ie(s)},FC=(t,e,n)=>{const r=Kn(e),s=Bn(),o=[],i=[],c=[],l=[],d=me(r);for(let h=0;h<d;h++){const f=me(r);let p=me(r);const g=JSON.parse(Ve(r)),m=t.meta.get(f),b=t.states.get(f),S=m===void 0?0:m.clock;(S<p||S===p&&g===null&&t.states.has(f))&&(g===null?f===t.clientID&&t.getLocalState()!=null?p++:t.states.delete(f):t.states.set(f,g),t.meta.set(f,{clock:p,lastUpdated:s}),m===void 0&&g!==null?o.push(f):m!==void 0&&g===null?l.push(f):g!==null&&(Vr(g,b)||c.push(f),i.push(f)))}(o.length>0||c.length>0||l.length>0)&&t.emit("change",[{added:o,updated:c,removed:l},n]),(o.length>0||i.length>0||l.length>0)&&t.emit("update",[{added:o,updated:i,removed:l},n])},IC=t=>zx(t,(e,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(e)}`).join("&"),lr=0,Vh=3,Yr=1,$C=2,Zs=[];Zs[lr]=(t,e,n,r,s)=>{se(t,lr);const o=OC(e,t,n.doc,n);r&&o===ul&&!n.synced&&(n.synced=!0)};Zs[Vh]=(t,e,n,r,s)=>{se(t,Yr),He(t,Jr(n.awareness,Array.from(n.awareness.getStates().keys())))};Zs[Yr]=(t,e,n,r,s)=>{FC(n.awareness,mt(e),n)};Zs[$C]=(t,e,n,r,s)=>{NC(e,n.doc,(o,i)=>UC(n,i))};const fd=3e4,UC=(t,e)=>console.warn(`Permission denied to access ${t.url}.
|
|
10
|
+
${e}`),Hh=(t,e,n)=>{const r=Kn(e),s=qe(),o=me(r),i=t.messageHandlers[o];return i?i(s,r,t,n,o):console.error("Unable to compute message"),s},ea=(t,e,n)=>{e===t.ws&&(t.emit("connection-close",[n,t]),t.ws=null,e.close(),t.wsconnecting=!1,t.wsconnected?(t.wsconnected=!1,t.synced=!1,dl(t.awareness,Array.from(t.awareness.getStates().keys()).filter(r=>r!==t.doc.clientID),t),t.emit("status",[{status:"disconnected"}])):t.wsUnsuccessfulReconnects++,setTimeout(qh,Ma(sx(2,t.wsUnsuccessfulReconnects)*100,t.maxBackoffTime),t))},qh=t=>{if(t.shouldConnect&&t.ws===null){const e=new t._WS(t.url,t.protocols);e.binaryType="arraybuffer",t.ws=e,t.wsconnecting=!0,t.wsconnected=!1,t.synced=!1,e.onmessage=n=>{t.wsLastMessageReceived=Bn();const r=Hh(t,new Uint8Array(n.data),!0);Fa(r)>1&&e.send(Ie(r))},e.onerror=n=>{t.emit("connection-error",[n,t])},e.onclose=n=>{ea(t,e,n)},e.onopen=()=>{t.wsLastMessageReceived=Bn(),t.wsconnecting=!1,t.wsconnected=!0,t.wsUnsuccessfulReconnects=0,t.emit("status",[{status:"connected"}]);const n=qe();if(se(n,lr),Zo(n,t.doc),e.send(Ie(n)),t.awareness.getLocalState()!==null){const r=qe();se(r,Yr),He(r,Jr(t.awareness,[t.doc.clientID])),e.send(Ie(r))}},t.emit("status",[{status:"connecting"}])}},wc=(t,e)=>{const n=t.ws;t.wsconnected&&n&&n.readyState===n.OPEN&&n.send(e),t.bcconnected&&Ir(t.bcChannel,e,t)};class zC extends Na{constructor(e,n,r,{connect:s=!0,awareness:o=new MC(r),params:i={},protocols:c=[],WebSocketPolyfill:l=WebSocket,resyncInterval:d=-1,maxBackoffTime:h=2500,disableBc:f=!1}={}){for(super();e[e.length-1]==="/";)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+"/"+n,this.maxBackoffTime=h,this.params=i,this.protocols=c,this.roomname=n,this.doc=r,this._WS=l,this.awareness=o,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=f,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Zs.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=s,this._resyncInterval=0,d>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const p=qe();se(p,lr),Zo(p,r),this.ws.send(Ie(p))}},d)),this._bcSubscriber=(p,g)=>{if(g!==this){const m=Hh(this,new Uint8Array(p),!1);Fa(m)>1&&Ir(this.bcChannel,Ie(m),this)}},this._updateHandler=(p,g)=>{if(g!==this){const m=qe();se(m,lr),AC(m,p),wc(this,Ie(m))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:p,updated:g,removed:m},b)=>{const S=p.concat(g).concat(m),C=qe();se(C,Yr),He(C,Jr(o,S)),wc(this,Ie(C))},this._exitHandler=()=>{dl(this.awareness,[r.clientID],"app closed")},Wn&&typeof process<"u"&&process.on("exit",this._exitHandler),o.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&fd<Bn()-this.wsLastMessageReceived&&ea(this,this.ws,null)},fd/10),s&&this.connect()}get url(){const e=IC(this.params);return this.serverUrl+"/"+this.roomname+(e.length===0?"":"?"+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),Wn&&typeof process<"u"&&process.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(jC(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=qe();se(e,lr),Zo(e,this.doc),Ir(this.bcChannel,Ie(e),this);const n=qe();se(n,lr),Bh(n,this.doc),Ir(this.bcChannel,Ie(n),this);const r=qe();se(r,Vh),Ir(this.bcChannel,Ie(r),this);const s=qe();se(s,Yr),He(s,Jr(this.awareness,[this.doc.clientID])),Ir(this.bcChannel,Ie(s),this)}disconnectBc(){const e=qe();se(e,Yr),He(e,Jr(this.awareness,[this.doc.clientID],new Map)),wc(this,Ie(e)),this.bcconnected&&(_C(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&ea(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(qh(this),this.connectBc())}}const Er=t=>ts((e,n)=>{t.onerror=r=>n(new Error(r.target.error)),t.onsuccess=r=>e(r.target.result)}),BC=(t,e)=>ts((n,r)=>{const s=indexedDB.open(t);s.onupgradeneeded=o=>e(o.target.result),s.onerror=o=>r(Kt(o.target.error)),s.onsuccess=o=>{const i=o.target.result;i.onversionchange=()=>{i.close()},n(i)}}),WC=t=>Er(indexedDB.deleteDatabase(t)),VC=(t,e)=>e.forEach(n=>t.createObjectStore.apply(t,n)),ks=(t,e,n="readwrite")=>{const r=t.transaction(e,n);return e.map(s=>ZC(r,s))},Kh=(t,e)=>Er(t.count(e)),HC=(t,e)=>Er(t.get(e)),Gh=(t,e)=>Er(t.delete(e)),qC=(t,e,n)=>Er(t.put(e,n)),ta=(t,e)=>Er(t.add(e)),KC=(t,e,n)=>Er(t.getAll(e,n)),GC=(t,e,n)=>{let r=null;return XC(t,e,s=>(r=s,!1),n).then(()=>r)},JC=(t,e=null)=>GC(t,e,"prev"),YC=(t,e)=>ts((n,r)=>{t.onerror=r,t.onsuccess=async s=>{const o=s.target.result;if(o===null||await e(o)===!1)return n();o.continue()}}),XC=(t,e,n,r="next")=>YC(t.openKeyCursor(e,r),s=>n(s.key)),ZC=(t,e)=>t.objectStore(e),QC=(t,e)=>IDBKeyRange.upperBound(t,e),e0=(t,e)=>IDBKeyRange.lowerBound(t,e),bc="custom",Jh="updates",Yh=500,Xh=(t,e=()=>{},n=()=>{})=>{const[r]=ks(t.db,[Jh]);return KC(r,e0(t._dbref,!1)).then(s=>{t._destroyed||(e(r),$e(t.doc,()=>{s.forEach(o=>ah(t.doc,o))},t,!1),n(r))}).then(()=>JC(r).then(s=>{t._dbref=s+1})).then(()=>Kh(r).then(s=>{t._dbsize=s})).then(()=>r)},t0=(t,e=!0)=>Xh(t).then(n=>{(e||t._dbsize>=Yh)&&ta(n,el(t.doc)).then(()=>Gh(n,QC(t._dbref,!0))).then(()=>Kh(n).then(r=>{t._dbsize=r}))});class n0 extends wf{constructor(e,n){super(),this.doc=n,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=BC(e,r=>VC(r,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=ts(r=>this.on("synced",()=>r(this))),this._db.then(r=>{this.db=r,Xh(this,i=>ta(i,el(n)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(r,s)=>{if(this.db&&s!==this){const[o]=ks(this.db,[Jh]);ta(o,r),++this._dbsize>=Yh&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{t0(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},n.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),n.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{WC(this.name)})}get(e){return this._db.then(n=>{const[r]=ks(n,[bc],"readonly");return HC(r,e)})}set(e,n){return this._db.then(r=>{const[s]=ks(r,[bc]);return qC(s,n,e)})}del(e){return this._db.then(n=>{const[r]=ks(n,[bc]);return Gh(r,e)})}}const r0={Sync:0,Awareness:1,Flush:4,Protocol:5,Maintenance:6,Permission:7,CompileStates:8,FormatLease:9},xc=3,s0=["queued","running","succeeded","failed","cleaned"],o0=["cache","artifacts"];function i0(t){return typeof t=="string"&&s0.includes(t)}function c0(t){return typeof t=="string"&&o0.includes(t)}const hd=[["#1677c8","#1677c833"],["#d65745","#d6574533"],["#16866a","#16866a33"],["#9a58b5","#9a58b533"],["#d27b18","#d27b1833"],["#3f7d20","#3f7d2033"],["#be3e7b","#be3e7b33"],["#4964c6","#4964c633"],["#8a6a14","#8a6a1433"],["#087f8c","#087f8c33"]],{Sync:a0,Awareness:l0,Flush:pd,Protocol:md,Maintenance:u0,Permission:d0,CompileStates:f0,FormatLease:vc}=r0,h0=6e4,p0=720*60*60*1e3,m0=15e3,g0=5*6e4;function y0(t){if(!t||typeof t!="object")return null;const e=t,n=e.requestedBy;return typeof e.mainFile!="string"||typeof e.runId!="string"||!i0(e.status)||e.status==="cleaned"&&!c0(e.cleanMode)||e.stale!==void 0&&typeof e.stale!="boolean"||typeof e.updatedAt!="string"||!n||typeof n.id!="string"||typeof n.username!="string"||typeof n.name!="string"?null:e}function gd(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,r]of Object.entries(t)){const s=y0(r);s&&s.mainFile===n&&(e[n]=s)}return e}function w0(t,e,n){return t<=n&&e<=n}function yd(t,e,n){const r=s=>s>0&&n-s<=g0;return{recoverable:t.some(s=>s.tabId===e||!r(s.activeAt)),otherActive:t.some(s=>s.tabId!==e&&r(s.activeAt))}}class b0{constructor(e,n){this.projectId=e,this.user=n;const r=window.location.protocol==="https:"?"wss:":"ws:";this.draftTabId=C0(cr(`texlite:collaboration-tab:${n.id}:${e}`));const s=this.readOwnWritableDraftMarker();this.draftGeneration=s?.generation??0,this.draftUpdatedAt=s?.updatedAt??0,this.draftMarkerPresent=s!==null,this.markDraftTabInactive=()=>this.setOwnDraftActivity(!1),this.markDraftTabActive=()=>this.resumeOwnDraftActivity(),window.addEventListener("pagehide",this.markDraftTabInactive),window.addEventListener("pageshow",this.markDraftTabActive),s&&(this.setOwnDraftActivity(!0),this.startDraftHeartbeat()),this.persistence=new n0(cr(`texlite:${n.id}:${e}`),this.doc),this.localDraftTransactionObserver=i=>{if(i.local){for(const[c,l]of this.doc.share)if(c.startsWith("source:")&&(i.changed.has(l)||i.changedParentTypes.has(l))){this.markWritableDraft();return}}},this.doc.on("afterTransaction",this.localDraftTransactionObserver),this.persistence.on("synced",()=>{this.localDraftReady=!0;for(const i of this.draftListeners)i()}),this.provider=new zC(`${r}//${window.location.host}${as("/api/collaboration")}`,e,this.doc,{connect:!1,disableBc:!0,maxBackoffTime:2500}),this.awareness=this.provider.awareness;const o=this.doc.getMap("texlite:meta");this.metaObserver=(i,c)=>{c.origin===this.provider&&i.keysChanged.has("compileStates")&&(this.authoritativeCompileStates=null,this.notifyCompileStateListeners())},o.observe(this.metaObserver),this.provider.messageHandlers[pd]=(i,c)=>{const l=Ve(c),d=this.flushRequests.get(l);if(!d)return;const h=me(c)===1,f=me(c),p=Ve(c),g=me(c),m=[];for(let b=0;b<g;b++)m.push(Ve(c));if(window.clearTimeout(d.timer),this.flushRequests.delete(l),h)this.clearOwnWritableDraftMarker(d.draftGeneration),d.resolve({revision:f,persistedAt:p,ok:!0,failedPaths:[]});else{const b=Object.assign(new Error(m.length?`保存失败:${m.join(", ")}`:"源码保存到服务器磁盘失败"),{failedPaths:m});d.reject(b)}},this.provider.messageHandlers[md]=(i,c)=>{const l=Ve(c),d=this.epochStorageKey(),h=wd(d),f=/^([0-9]+):/.exec(l)?.[1]??null,p=h?/^([0-9]+):/.exec(h)?.[1]??null:null,g=!this.epoch&&f===String(xc)&&p!==null&&p!==f;if((this.epoch&&this.epoch!==l||h&&h!==l)&&!g){this.provider.disconnect(),this.rejectFlushes(new Error("Collaboration state changed"));const D=l.endsWith(":reload")||f!==null&&f!==String(xc),y=()=>{Sc(d,l.replace(/:reload$/,"")),window.location.reload()};if(D)for(const w of this.protocolUpgradeListeners)w();else this.persistence.clearData().then(()=>{this.clearWritableDraftMarkers(),y()});return}this.epoch=l,Sc(d,l);const m=this.provider.ws;if(!m||m.readyState!==WebSocket.OPEN)return;const b=qe();se(b,md),ft(b,l),se(b,xc),m.send(Ie(b));const S=qe();se(S,a0),Zo(S,this.doc),m.send(Ie(S));const C=qe();se(C,l0),He(C,Jr(this.awareness,[this.doc.clientID])),m.send(Ie(C))},this.provider.messageHandlers[d0]=(i,c)=>{const l=Ve(c),d=Ve(c);if(l!==this.user.id)return;if(d==="revoked"){this.rejectFlushes(new Error("Project access revoked")),this.provider.disconnect();for(const f of this.permissionListeners)f("revoked",this.permission);return}if(d!=="read"&&d!=="edit"&&d!=="owner")return;const h=this.permission;if(this.setPermission(d),h!==d){d==="read"&&this.rejectFlushes(new Error("Project permission changed to read-only"));for(const f of this.permissionListeners)f(d,h)}},this.provider.messageHandlers[u0]=(i,c)=>{Ve(c)},this.provider.messageHandlers[f0]=(i,c)=>{let l={};try{l=gd(JSON.parse(Ve(c)))}catch{}this.authoritativeCompileStates=l,this.notifyCompileStateListeners()},this.provider.messageHandlers[vc]=(i,c)=>{const l=Ve(c),d=Ve(c),h=Ve(c),f=Ve(c),p=Ve(c),g=Ve(c);if(l==="state"){const b=Hc(c)?Ve(c):"",S=Hc(c)?Ve(c):"",C=Number(p);if(!b||!Number.isFinite(C)||C<=Date.now())this.removeFormatLeaseState(h),this.notifyFormatLeaseListeners(null);else{const D={path:h,holderUserId:b,holderName:S,expiresAt:C};this.formatLeaseStatesByPath.set(h,D);const y=this.formatLeaseExpiryTimers.get(h);y!==void 0&&window.clearTimeout(y);const w=window.setTimeout(()=>{const k=this.formatLeaseStatesByPath.get(h);!k||k.expiresAt>Date.now()||(this.removeFormatLeaseState(h),this.notifyFormatLeaseListeners(null))},Math.max(0,C-Date.now())+25);this.formatLeaseExpiryTimers.set(h,w),this.notifyFormatLeaseListeners(D)}return}const m=this.formatLeaseRequests.get(d);m&&(window.clearTimeout(m.timer),this.formatLeaseRequests.delete(d),l==="denied"?m.reject(new Error(g||"Format lease request was denied")):m.resolve({status:l,filePath:h,token:f,expiresAt:Number(p)}))},this.provider.on("status",({status:i})=>{i==="disconnected"&&(this.authoritativeCompileStates=null,this.notifyCompileStateListeners(),this.rejectFlushes(new Error("Collaboration connection closed")),this.rejectFormatLeaseRequests(new Error("Collaboration connection closed")),this.clearFormatLeaseStates())}),this.updateLocalAwareness()}projectId;user;doc=new Sr;provider;awareness;persistence;permission="read";activeFile="";epoch=null;destroyed=!1;localDraftReady=!1;draftListeners=new Set;permissionListeners=new Set;protocolUpgradeListeners=new Set;compileStateListeners=new Set;flushRequests=new Map;formatLeaseRequests=new Map;formatLeaseListeners=new Set;formatLeaseStatesByPath=new Map;formatLeaseExpiryTimers=new Map;draftTabId;draftGeneration=0;draftUpdatedAt=0;draftMarkerPresent=!1;draftHeartbeatTimer=null;markDraftTabInactive;markDraftTabActive;undoManagers=new Map;authoritativeCompileStates=null;metaObserver;localDraftTransactionObserver;connect(){this.destroyed||(this.provider.connect(),this.updateLocalAwareness())}getText(e){return this.doc.getText(`source:${e}`)}getUndoManager(e){const n=this.undoManagers.get(e);if(n)return n;const r=new _S(this.getText(e));return this.undoManagers.set(e,r),r}applyTextEdits(e,n){if(this.permission==="read")throw new Error("Read-only collaborators cannot edit source files");const r=this.getText(e);let s=0;for(const o of n){if(!Number.isInteger(o.from)||!Number.isInteger(o.to)||o.from<s||o.to<o.from||o.to>r.length)throw new RangeError("Invalid collaborative text edits");s=o.to}this.doc.transact(()=>{for(let o=n.length-1;o>=0;o-=1){const i=n[o];i.to>i.from&&r.delete(i.from,i.to-i.from),i.replacement&&r.insert(i.from,i.replacement)}})}get meta(){return this.doc.getMap("texlite:meta")}compileStates(){return this.authoritativeCompileStates??gd(this.meta.get("compileStates"))}onCompileStates(e){return this.compileStateListeners.add(e),()=>this.compileStateListeners.delete(e)}get synced(){return this.provider.synced}get connected(){return this.provider.wsconnected}get draftReady(){return this.localDraftReady}get currentPermission(){return this.permission}onDraftReady(e){return this.draftListeners.add(e),this.localDraftReady&&e(),()=>this.draftListeners.delete(e)}onPermissionChanged(e){return this.permissionListeners.add(e),()=>this.permissionListeners.delete(e)}onProtocolUpgrade(e){return this.protocolUpgradeListeners.add(e),()=>this.protocolUpgradeListeners.delete(e)}async discardLocalDraft(){return this.hasOtherWritableDraft?!1:(await this.persistence.clearData(),this.localDraftReady=!1,this.clearWritableDraftMarkers(),!0)}get hasWritableDraft(){const e=this.readWritableDraftMarkers();return yd(e.map(({tabId:n,marker:r})=>({tabId:n,activeAt:r.activeAt})),this.draftTabId,Date.now()).recoverable}get hasOtherWritableDraft(){const e=this.readWritableDraftMarkers();return yd(e.map(({tabId:n,marker:r})=>({tabId:n,activeAt:r.activeAt})),this.draftTabId,Date.now()).otherActive}setPermission(e,n=!1){const r=this.permission;if(this.permission=e,e==="read"&&(r!=="read"&&this.rejectFlushes(new Error("Project permission changed to read-only")),this.destroyUndoManagers(),this.clearFormatLeaseStates()),this.updateLocalAwareness(),n&&r!==e)for(const s of this.permissionListeners)s(e,r)}setActiveFile(e){this.activeFile!==e&&(this.activeFile=e,this.awareness.setLocalStateField("cursor",null),this.updateLocalAwareness())}sessions(){const e=[];return this.awareness.getStates().forEach((n,r)=>{const s=n?.user;!s||typeof s.id!="string"||typeof s.name!="string"||e.push({clientId:r,userId:s.id,username:typeof s.username=="string"?s.username:s.name,name:s.name,color:typeof s.color=="string"?s.color:"#1677c8",colorLight:typeof s.colorLight=="string"?s.colorLight:"#1677c833",permission:s.permission==="owner"||s.permission==="edit"?s.permission:"read",filePath:typeof n.filePath=="string"?n.filePath:"",editing:!!n.cursor,local:r===this.doc.clientID})}),e.sort((n,r)=>Number(r.local)-Number(n.local)||n.name.localeCompare(r.name))}flush(){const e=this.provider.ws;if(!this.provider.synced||!e||e.readyState!==WebSocket.OPEN)return Promise.reject(new Error("Collaboration connection is unavailable"));const n=Qc(),r=this.draftGeneration,s=qe();return se(s,pd),ft(s,n),new Promise((o,i)=>{const c=window.setTimeout(()=>{this.flushRequests.delete(n),i(new Error("Collaboration save timed out"))},5e3);this.flushRequests.set(n,{resolve:o,reject:i,timer:c,draftGeneration:r}),e.send(Ie(s))})}onFormatLeaseState(e){this.formatLeaseListeners.add(e);for(const n of this.formatLeaseStatesByPath.values())e(n);return()=>this.formatLeaseListeners.delete(e)}formatLeaseStates(){const e=Date.now();for(const[n,r]of this.formatLeaseStatesByPath)r.expiresAt<=e&&this.removeFormatLeaseState(n);return[...this.formatLeaseStatesByPath.values()]}async acquireFormatLease(e){if(this.permission==="read")throw new Error("Formatting requires write permission");const n=await this.requestFormatLease("acquire",e);if(n.status!=="grant"||!n.token||!Number.isFinite(n.expiresAt))throw new Error("Format lease was not granted");let r=n.token,s=n.expiresAt,o=!1;const i=async()=>{if(o)throw new Error("Format lease has already been released");const l=await this.requestFormatLease("renew",e,r);if(l.status!=="renewed"||!Number.isFinite(l.expiresAt))throw new Error("Format lease renewal failed");r=l.token||r,s=l.expiresAt};return{path:e,get token(){return r},get expiresAt(){return s},confirm:i,renew:i,release:async()=>{if(o)return;o=!0;const l=this.provider.ws;if(!(!l||l.readyState!==WebSocket.OPEN))try{await this.requestFormatLease("release",e,r)}catch{}}}}reconnect(){this.destroyed||(this.rejectFlushes(new Error("Collaboration connection reset")),this.provider.disconnect(),this.provider.connect(),this.updateLocalAwareness())}destroy(){this.destroyed=!0,this.setOwnDraftActivity(!1),this.stopDraftHeartbeat(),window.removeEventListener("pagehide",this.markDraftTabInactive),window.removeEventListener("pageshow",this.markDraftTabActive),this.rejectFlushes(new Error("Collaboration connection closed")),this.provider.destroy(),this.persistence.destroy(),this.draftListeners.clear(),this.protocolUpgradeListeners.clear(),this.compileStateListeners.clear(),this.rejectFormatLeaseRequests(new Error("Collaboration connection closed")),this.clearFormatLeaseStates(),this.formatLeaseListeners.clear(),this.meta.unobserve(this.metaObserver),this.doc.off("afterTransaction",this.localDraftTransactionObserver),this.destroyUndoManagers(),this.doc.destroy()}destroyUndoManagers(){for(const e of this.undoManagers.values())e.destroy();this.undoManagers.clear()}notifyCompileStateListeners(){for(const e of this.compileStateListeners)e()}rejectFlushes(e){for(const n of this.flushRequests.values())window.clearTimeout(n.timer),n.reject(e);this.flushRequests.clear()}requestFormatLease(e,n,r=""){const s=this.provider.ws;if(!this.provider.synced||!s||s.readyState!==WebSocket.OPEN)return Promise.reject(new Error("Collaboration connection is unavailable"));const o=Qc(),i=qe();return se(i,vc),ft(i,e),ft(i,o),ft(i,n),ft(i,r),new Promise((c,l)=>{const d=window.setTimeout(()=>{if(this.formatLeaseRequests.delete(o),e==="acquire"){const h=this.provider.ws;if(h?.readyState===WebSocket.OPEN){const f=qe();se(f,vc),ft(f,"cancel"),ft(f,o),ft(f,n),ft(f,""),h.send(Ie(f))}}l(new Error("Format lease request timed out"))},e==="acquire"?h0:5e3);this.formatLeaseRequests.set(o,{resolve:c,reject:l,timer:d}),s.send(Ie(i))})}rejectFormatLeaseRequests(e){for(const n of this.formatLeaseRequests.values())window.clearTimeout(n.timer),n.reject(e);this.formatLeaseRequests.clear()}clearFormatLeaseStates(){for(const e of this.formatLeaseExpiryTimers.values())window.clearTimeout(e);this.formatLeaseExpiryTimers.clear(),this.formatLeaseStatesByPath.size&&(this.formatLeaseStatesByPath.clear(),this.notifyFormatLeaseListeners(null))}removeFormatLeaseState(e){const n=this.formatLeaseExpiryTimers.get(e);n!==void 0&&window.clearTimeout(n),this.formatLeaseExpiryTimers.delete(e),this.formatLeaseStatesByPath.delete(e)}notifyFormatLeaseListeners(e){for(const n of this.formatLeaseListeners)n(e)}updateLocalAwareness(){const[e,n]=hd[Math.abs(this.doc.clientID)%hd.length];this.awareness.setLocalStateField("user",{id:this.user.id,username:this.user.username,name:this.user.displayName,color:e,colorLight:n,permission:this.permission,sessionId:String(this.doc.clientID)}),this.awareness.setLocalStateField("filePath",this.activeFile)}epochStorageKey(){return cr(`texlite:collaboration-epoch:${this.user.id}:${this.projectId}`)}writableDraftStoragePrefix(){return`${cr(`texlite:collaboration-writable:${this.user.id}:${this.projectId}`)}:`}ownWritableDraftStorageKey(){return`${this.writableDraftStoragePrefix()}${this.draftTabId}`}markWritableDraft(){this.draftGeneration+=1,this.draftUpdatedAt=Date.now(),this.draftMarkerPresent||this.writeOwnWritableDraftMarker(!0),this.startDraftHeartbeat()}clearWritableDraftMarkers(){for(const{key:e}of this.readWritableDraftMarkers())Cs(e);this.draftMarkerPresent=!1,this.stopDraftHeartbeat(),Cs(this.writableDraftStoragePrefix().slice(0,-1))}clearOwnWritableDraftMarker(e){const n=this.readOwnWritableDraftMarker();!n||!w0(n.generation,this.draftGeneration,e)||(Cs(this.ownWritableDraftStorageKey()),this.draftMarkerPresent=!1,this.stopDraftHeartbeat())}readOwnWritableDraftMarker(){return this.readWritableDraftMarker(this.ownWritableDraftStorageKey())}readWritableDraftMarkers(){const e=this.writableDraftStoragePrefix(),n=[];for(const r of x0()){if(!r.startsWith(e))continue;const s=this.readWritableDraftMarker(r);s&&n.push({key:r,tabId:r.slice(e.length),marker:s})}return n}readWritableDraftMarker(e){const n=wd(e);if(!n)return null;try{const r=JSON.parse(n);if(!r||typeof r!="object"||Array.isArray(r))return null;const s=r,o=Date.now();if(!Number.isInteger(s.generation)||(s.generation??0)<0||typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt)||s.updatedAt<=0||o-s.updatedAt>p0)return Cs(e),null;const i=typeof s.activeAt=="number"&&Number.isFinite(s.activeAt)?Math.max(0,s.activeAt):0;return{generation:s.generation,updatedAt:s.updatedAt,activeAt:i}}catch{return Cs(e),null}}writeOwnWritableDraftMarker(e){if(!this.draftMarkerPresent&&this.draftUpdatedAt<=0)return;const n={generation:this.draftGeneration,updatedAt:this.draftUpdatedAt||Date.now(),activeAt:e?Date.now():0};Sc(this.ownWritableDraftStorageKey(),JSON.stringify(n)),this.draftMarkerPresent=!0}setOwnDraftActivity(e){this.draftMarkerPresent&&(this.writeOwnWritableDraftMarker(e),e?this.startDraftHeartbeat():this.stopDraftHeartbeat())}resumeOwnDraftActivity(){const e=this.readOwnWritableDraftMarker();if(!e){this.draftMarkerPresent=!1,this.stopDraftHeartbeat();return}this.draftGeneration=Math.max(this.draftGeneration,e.generation),this.draftUpdatedAt=e.updatedAt,this.draftMarkerPresent=!0,this.setOwnDraftActivity(!0)}startDraftHeartbeat(){this.draftHeartbeatTimer!==null||!this.draftMarkerPresent||(this.draftHeartbeatTimer=window.setInterval(()=>{this.writeOwnWritableDraftMarker(!0)},m0))}stopDraftHeartbeat(){this.draftHeartbeatTimer!==null&&(window.clearInterval(this.draftHeartbeatTimer),this.draftHeartbeatTimer=null)}}function wd(t){try{return window.localStorage.getItem(t)}catch{return null}}function Sc(t,e){try{window.localStorage.setItem(t,e)}catch{}}function Cs(t){try{window.localStorage.removeItem(t)}catch{}}function x0(){try{const t=[];for(let e=0;e<window.localStorage.length;e+=1){const n=window.localStorage.key(e);n&&t.push(n)}return t}catch{return[]}}function v0(t){try{return window.sessionStorage.getItem(t)}catch{return null}}function S0(t,e){try{window.sessionStorage.setItem(t,e)}catch{}}function C0(t){const e=v0(t);if(e)return e;const n=Qc();return S0(t,n),n}function E0(t,e){return Array.from(t.trim()||e.trim()||"?")[0]?.toLocaleUpperCase()??"?"}function k0(t){if(!t||typeof t!="object")return!1;const e=t;return(e.kind==="update"||e.kind==="move"||e.kind==="delete")&&typeof e.revision=="string"}function R0(t,e,n,r,s,o){const[i]=u.useState(()=>new b0(t,e)),[c,l]=u.useState("connecting"),[d,h]=u.useState(!1),[f,p]=u.useState([]),[g,m]=u.useState(null),[b,S]=u.useState(null),[C,D]=u.useState(""),[y,w]=u.useState(!1),[k,v]=u.useState(""),[R,A]=u.useState(""),[N,U]=u.useState([]),[K,T]=u.useState(!1),[q,B]=u.useState(r),[W,z]=u.useState(null),[Z,I]=u.useState(!1),V=u.useRef(n),G=u.useRef(o),Q=u.useRef(s);V.current=n,G.current=o,Q.current=s,u.useEffect(()=>{const j=i.compileStates();m(j[n]??null)},[n,i]),u.useEffect(()=>{const j=()=>p(i.sessions()),Y=()=>{h(!1),p([]),m(null),S(null),D(""),w(!1),v(""),A(""),U([]),G.current()},le=({status:de})=>{l(de),de!=="connected"&&Y()},Re=de=>{h(de),de||Y()},re=()=>{l("disconnected"),Y()},we=()=>{w(i.meta.get("historyWarning")===!0);const de=i.meta.get("filesEvent");k0(de)&&S(de);const X=i.meta.get("commentsRevision");typeof X=="string"&&D(X);const ne=i.meta.get("dictionaryRevision");typeof ne=="string"&&v(ne);const be=i.meta.get("chktexSettingsRevision");typeof be=="string"&&A(be);const Ae=i.compileStates();m(Ae[V.current]??null)},Ee=()=>{const de=i.compileStates();m(de[V.current]??null)};i.awareness.on("change",j),i.provider.on("status",le),i.provider.on("sync",Re),i.provider.on("connection-close",re),i.provider.on("connection-error",re),i.meta.observe(we);const J=i.onCompileStates(Ee),ce=i.onProtocolUpgrade(()=>{I(!0),l("disconnected"),Y()}),L=()=>U(i.formatLeaseStates()),_e=i.onFormatLeaseState(L),Ne=()=>{if(!Q.current||i.currentPermission!=="read")return;const de=i.hasWritableDraft,X=i.hasOtherWritableDraft;!de&&!X||z({previous:"edit",localDraftReady:de,otherTabDraft:X})},pe=i.onDraftReady(()=>{T(!0),Ne()}),Oe=i.onPermissionChanged((de,X)=>{if(de==="revoked"){l("disconnected"),h(!1),G.current();return}B(de),de==="read"&&X!=="read"?z({previous:X,localDraftReady:i.hasWritableDraft,otherTabDraft:i.hasOtherWritableDraft}):de!=="read"&&z(null)});return j(),we(),l(i.connected?"connected":"connecting"),h(i.synced),()=>{i.awareness.off("change",j),i.provider.off("status",le),i.provider.off("sync",Re),i.provider.off("connection-close",re),i.provider.off("connection-error",re),i.meta.unobserve(we),J(),ce(),_e(),pe(),Oe(),i.destroy()}},[i]),u.useEffect(()=>{s&&i.connect()},[i,s]),u.useEffect(()=>{i.setPermission(r),B(r),s&&r==="read"&&(i.hasWritableDraft||i.hasOtherWritableDraft)?z({previous:"edit",localDraftReady:i.hasWritableDraft,otherTabDraft:i.hasOtherWritableDraft}):r!=="read"&&z(null)},[i,r,s]);const Ce=W!==null;return u.useEffect(()=>{if(!Ce)return;const j=()=>{if(i.currentPermission!=="read")return;const le=i.hasWritableDraft,Re=i.hasOtherWritableDraft;z(re=>!re||re.localDraftReady===le&&re.otherTabDraft===Re?re:{...re,localDraftReady:le,otherTabDraft:Re})};j();const Y=window.setInterval(j,2e3);return()=>window.clearInterval(Y)},[i,Ce]),{collaboration:i,status:c,synced:d,activeSessions:f,compileState:g,setCompileState:m,formatLeaseStates:N,filesEvent:b,commentsRevision:C,historyWarning:y,dictionaryRevision:k,chktexSettingsRevision:R,localDraftReady:K,permission:q,protocolUpgradeRequired:Z,reconnect:()=>{Z||(l("connecting"),h(!1),p([]),m(null),U([]),i.reconnect())},permissionDowngrade:W,dismissPermissionDowngrade:()=>z(null),discardLocalDraft:async()=>await i.discardLocalDraft()?(z(null),window.location.reload(),!0):(z(Y=>Y&&{...Y,otherTabDraft:!0}),!1)}}function bd(t){return t?.status==="succeeded"?"succeeded":t?.log.includes("Compilation was cancelled.")?"cancelled":t?.status==="failed"?"failed":null}function rr(t){return t instanceof Error&&t.name==="AbortError"}function D0(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}function j0(t){return t instanceof Element&&!!t.closest('[role="dialog"], [role="alertdialog"]')}function _0({projectId:t,project:e,mainFile:n,resolveCompileMainFile:r,getCurrentMainFile:s,initialLatest:o,collaborationSynced:i,sharedState:c,onSharedState:l,save:d,loadOutline:h,onPreviewTab:f,onError:p,onCompileStart:g,onCompileSuccess:m,onPdfChanged:b}){const{t:S}=tt(),[C,D]=u.useState(""),[y,w]=u.useState(!0),[k,v]=u.useState(null),[R,A]=u.useState(null),[N,U]=u.useState("full"),[K,T]=u.useState(""),[q,B]=u.useState(null),[W,z]=u.useState(null),[Z,I]=u.useState([]),[V,G]=u.useState(null),[Q,Ce]=u.useState(!1),[te,ue]=u.useState(!1),[ke,j]=u.useState(()=>new Set),[Y,le]=u.useState(()=>new Set),[Re,re]=u.useState(""),[we,Ee]=u.useState({projectId:t,mainFile:n}),J=u.useRef(n),ce=u.useRef(""),L=u.useRef(""),_e=u.useRef({projectId:t,mainFile:n}),Ne=u.useRef(!0),pe=u.useRef(null),Oe=u.useRef(null),de=u.useRef(null),X=u.useRef(o),ne=u.useRef(!1),be=u.useRef(null),Ae=u.useRef(null),$=u.useRef(new Set),Pe=u.useRef(new Map),Je=u.useRef(null),wt=u.useRef(()=>{}),xe=u.useRef({onSharedState:l,save:d,loadOutline:h,onPreviewTab:f,onError:p,onCompileStart:g,onCompileSuccess:m,onPdfChanged:b,resolveCompileMainFile:r,getCurrentMainFile:s});J.current=n,xe.current={onSharedState:l,save:d,loadOutline:h,onPreviewTab:f,onError:p,onCompileStart:g,onCompileSuccess:m,onPdfChanged:b,resolveCompileMainFile:r,getCurrentMainFile:s};const _=()=>xe.current.getCurrentMainFile?.()||J.current,H=we.projectId===t&&we.mainFile===n,ae=ee=>{Je.current!==ee&&(Je.current=ee,xe.current.onCompileSuccess())},De=(ee,O,P,oe,ht)=>{(L.current!==O||ce.current!==ee)&&xe.current.onPdfChanged(),L.current=O,ce.current=ee,D(O),v(P),A(oe),U(ht??"full")},Me=async(ee,O)=>{O||(be.current?.abort(),be.current=new AbortController,O=be.current.signal);try{const P=ee?`?mainFile=${encodeURIComponent(ee)}`:"",oe=await ye(`/api/projects/${t}/compile/artifacts${P}`,{signal:O});J.current===ee&&(I(oe.artifacts),G(null))}catch(P){!rr(P)&&J.current===ee&&(I([]),G(null))}finally{be.current?.signal===O&&(be.current=null)}};u.useEffect(()=>{pe.current?.abort(),pe.current=null;const ee=_e.current,O=ee.projectId===t,P=O&&!!ee.mainFile&&!!n&&ee.mainFile!==n;if(_e.current={projectId:t,mainFile:n},Ee(je=>je.projectId===t&&je.mainFile===n?je:{projectId:t,mainFile:n}),O||(X.current=o,ne.current=!1,de.current=null,ce.current="",L.current=""),!n){w(!1),L.current="",D(""),v(null),A(null),U("full"),T(""),B(null),z(null),I([]),G(null),Ce(!1),re(""),de.current=null,xe.current.onPdfChanged();return}if(de.current?.mainFile!==n&&(de.current=null),T(""),B(null),z(null),P){Ne.current=!1,Oe.current?.abort(),be.current?.abort(),Ae.current?.abort(),ce.current="",L.current="",D(""),v(null),A(null),U("full"),w(!1),I([]),G(null),Ce(!1),re(""),xe.current.onPdfChanged(),xe.current.onPreviewTab("pdf");const je=new AbortController;return xe.current.loadOutline(je.signal,n).catch(()=>{}),()=>je.abort()}Ne.current=!0;const oe=new AbortController;pe.current=oe,w(!0),O&&C&&n&&ce.current===n||(L.current="",D(""),v(null),A(null),U("full")),I([]),G(null),xe.current.onPdfChanged();let bt=null;const Dn=`?mainFile=${encodeURIComponent(n)}`,ln=ne.current?null:X.current;ln&&(ne.current=!0);const Jt=()=>ye(`/api/projects/${t}/compile/latest${Dn}`,{signal:oe.signal}),jr=ln?ln.then(je=>je.mainFile!==n?Jt():je,()=>Jt()):Jt();let Rt=!1;const Ai=()=>{if(Rt||oe.signal.aborted||!n)return;Rt=!0;const je=new AbortController;$.current.add(je),Me(n,je.signal).finally(()=>{$.current.delete(je)}),xe.current.loadOutline(oe.signal,n).catch(()=>{})};return jr.then(je=>{if(oe.signal.aborted||n&&je.mainFile!==J.current)return;const Jn=de.current;Jn&&Jn.mainFile===n&&je.latestRun?.id!==Jn.runId||(T(je.latestRun?.log??""),B(je.latestRun?.diagnostics??null),z(bd(je.latestRun)),n&&je.latestRun?.requestedBy&&(je.latestRun.status==="queued"||je.latestRun.status==="running")&&xe.current.onSharedState({mainFile:n,runId:je.latestRun.id,status:je.latestRun.status,requestedBy:je.latestRun.requestedBy,updatedAt:new Date().toISOString()}),je.pdfUrl&&(De(je.mainFile,je.pdfUrl,je.pdfCompiledAt,je.pdfSizeBytes,je.pdfLoadingMode),xe.current.onPreviewTab("pdf")))}).catch(je=>{!rr(je)&&J.current===n&&xe.current.onError(ge(je))}).finally(()=>{pe.current===oe&&(pe.current=null),oe.signal.aborted||(w(!1),bt=window.setTimeout(Ai,0))}),()=>{bt!==null&&window.clearTimeout(bt),oe.abort(),Ae.current?.abort();for(const je of $.current)je.abort();$.current.clear()}},[t,n]),u.useEffect(()=>{if(!(!c||c.mainFile!==n||c.status!=="cleaned"||!c.cleanMode)){pe.current?.abort(),Oe.current?.abort(),be.current?.abort(),Ae.current?.abort();for(const ee of $.current)ee.abort();$.current.clear(),c.cleanMode==="artifacts"?(de.current=null,T(""),B(null),z(null),L.current="",D(""),v(null),A(null),U("full"),I([]),G(null),xe.current.onPdfChanged(),xe.current.onPreviewTab("pdf"),re(S("editor.cleanArtifactsComplete"))):re(S("editor.cleanCacheComplete"))}},[c?.runId,c?.status,c?.cleanMode,c?.mainFile,n,S]),u.useEffect(()=>{!n||c?.mainFile===n&&(c.status==="queued"||c.status==="running")||le(ee=>{if(!ee.has(n))return ee;const O=new Set(ee);return O.delete(n),O})},[n,c?.mainFile,c?.status]),u.useEffect(()=>{c?.mainFile===n&&(c.status==="queued"||c.status==="running")&&(Ne.current=!0)},[n,c?.mainFile,c?.status,c?.runId]),u.useEffect(()=>{if(!c||c.mainFile!==n||c.status!=="succeeded"&&c.status!=="failed"||!Ne.current)return;let ee=!1;Oe.current?.abort(),Ae.current?.abort();const O=new AbortController;return Oe.current=O,w(!0),ye(`/api/projects/${t}/compile/latest?mainFile=${encodeURIComponent(n)}`,{signal:O.signal}).then(P=>{ee||P.mainFile!==J.current||P.latestRun?.id!==c.runId||(T(P.latestRun.log),B(P.latestRun.diagnostics),z(bd(P.latestRun)),c.status==="succeeded"&&c.stale&&re(S("editor.compileSnapshotStale")),c.status==="succeeded"&&P.pdfUrl?(de.current={mainFile:n,runId:c.runId},De(n,P.pdfUrl,P.pdfCompiledAt,P.pdfSizeBytes,P.pdfLoadingMode),xe.current.onPreviewTab("pdf"),ae(c.runId),Me(n)):c.status==="failed"&&xe.current.onPreviewTab(P.latestRun.diagnostics.errors.length?"errors":"log"))}).catch(P=>{!rr(P)&&!ee&&xe.current.onError(ge(P))}).finally(()=>{Oe.current===O&&(Oe.current=null),ee||w(!1)}),()=>{ee=!0,O.abort(),Oe.current===O&&(Oe.current=null)}},[c?.runId,c?.status,c?.mainFile,c?.stale,n,t,S]);const rt=async()=>{if(!e||e.permission==="read"||!i)return;const ee=xe.current.resolveCompileMainFile?.()||_();if(!ee||Pe.current.has(ee)||c?.mainFile===ee&&(c.status==="queued"||c.status==="running"))return;j(P=>new Set([...P,ee])),xe.current.onCompileStart(),re(""),Ae.current?.abort(),Ae.current=null,T(""),B(null),z(null),xe.current.onPreviewTab(H&&C?"pdf":"log");const O=new AbortController;Pe.current.set(ee,O);try{if(!await xe.current.save())return;Ne.current=!0;const P=await ye(`/api/projects/${t}/compile`,{method:"POST",signal:O.signal,body:JSON.stringify({mainFile:ee})});if(P.mainFile!==ee||_()!==ee)return;T(P.log),B(P.diagnostics),z(P.cancelled?"cancelled":P.ok?"succeeded":"failed"),P.cancelled&&re(S("compileControls.cancelled")),P.skipped&&re(S("editor.upToDate")),P.ok&&P.stale&&re(S("editor.compileSnapshotStale")),P.pdfUrl?(P.ok&&(de.current={mainFile:ee,runId:P.runId}),De(ee,P.pdfUrl,P.pdfCompiledAt,P.pdfSizeBytes,P.pdfLoadingMode),xe.current.onPreviewTab("pdf"),P.ok&&(P.skipped?xe.current.onCompileSuccess():ae(P.runId))):xe.current.onPreviewTab(P.diagnostics.errors.length?"errors":"log")}catch(P){!rr(P)&&_()===ee&&xe.current.onError(ge(P))}finally{Pe.current.get(ee)===O&&(Pe.current.delete(ee),j(P=>{const oe=new Set(P);return oe.delete(ee),oe}),le(P=>{if(!P.has(ee))return P;const oe=new Set(P);return oe.delete(ee),oe}))}},Ke=async()=>{if(!e||e.permission==="read"||!i)return;const ee=_();if(ee){le(O=>new Set([...O,ee]));try{(await ye(`/api/projects/${t}/compile/cancel`,{method:"POST",body:JSON.stringify({mainFile:ee})})).cancelled||le(P=>{const oe=new Set(P);return oe.delete(ee),oe})}catch(O){le(P=>{const oe=new Set(P);return oe.delete(ee),oe}),!rr(O)&&_()===ee&&xe.current.onError(ge(O))}}},ve=async ee=>{if(!e||e.permission==="read"||!i||te)return;const O=_();if(!(!O||Pe.current.has(O)||c?.mainFile===O&&(c.status==="queued"||c.status==="running"))){ue(!0),pe.current?.abort(),Oe.current?.abort(),be.current?.abort(),Ae.current?.abort();try{if((await ye(`/api/projects/${t}/compile/clean`,{method:"POST",body:JSON.stringify({mainFile:O,mode:ee})})).mainFile!==O||_()!==O)return;xe.current.onSharedState(null),ee==="artifacts"&&(de.current=null,T(""),B(null),z(null),L.current="",D(""),v(null),A(null),U("full"),I([]),G(null),xe.current.onPdfChanged()),re(S(ee==="cache"?"editor.cleanCacheComplete":"editor.cleanArtifactsComplete"))}catch(P){!rr(P)&&_()===O&&xe.current.onError(ge(P))}finally{ue(!1)}}};wt.current=()=>{rt()},u.useEffect(()=>{if(!Re)return;const ee=window.setTimeout(()=>re(""),3e3);return()=>window.clearTimeout(ee)},[Re]),u.useEffect(()=>{const ee=O=>{if(!(!(O.ctrlKey||O.metaKey)||O.key.toLocaleLowerCase()!=="s")){if(D0(O.target)||j0(O.target)){O.preventDefault();return}O.preventDefault(),O.stopPropagation(),O.repeat||wt.current()}};return window.addEventListener("keydown",ee,!0),()=>window.removeEventListener("keydown",ee,!0)},[]),u.useEffect(()=>()=>{pe.current?.abort(),Oe.current?.abort(),be.current?.abort(),Ae.current?.abort();for(const ee of $.current)ee.abort();$.current.clear();for(const ee of Pe.current.values())ee.abort();Pe.current.clear()},[]);const Gt=async ee=>{if(!ee.viewable)return;Ae.current?.abort();const O=new AbortController;Ae.current=O,Ce(!0);try{const P=await ye(`/api/projects/${t}/compile/artifacts?mainFile=${encodeURIComponent(n)}&path=${encodeURIComponent(ee.path)}`,{signal:O.signal});!O.signal.aborted&&Ae.current===O&&J.current===n&&G(P)}catch(P){rr(P)||xe.current.onError(ge(P))}finally{Ae.current===O&&(Ae.current=null,Ce(!1))}};return{pdfUrl:H?C:"",pdfCompiledAt:H?k:null,pdfSizeBytes:H?R:null,pdfLoadingMode:N,pdfLoading:H?y:!1,compileLog:H?K:"",compileDiagnostics:H?q:null,compileOutcome:H?W:null,artifacts:H?Z:[],artifactPreview:H?V:null,artifactLoading:H&&Q,editorNotice:H?Re:"",localCompiling:ke.has(n),cancelling:Y.has(n),cleaning:te,compile:rt,cancelCompile:Ke,cleanCompile:ve,viewArtifact:Gt}}const na=10*1024*1024,P0=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif",".pdf",".zip",".gz",".bz2",".xz",".tar",".rar",".7z",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".odt",".ods",".odp",".mp3",".mp4",".wav",".ogg",".webm",".mov",".avi",".wasm",".exe",".bin",".so",".dll",".class",".jar"]);function xd(t){return t instanceof Error&&t.name==="AbortError"}function ur(t){const e=t.split("/").filter(Boolean);return e.pop(),e.map((n,r)=>e.slice(0,r+1).join("/"))}function sr(t,e){return!!(t&&e)&&(e===t||e.startsWith(`${t}/`))}function A0(t){const e=`.${t.split(".").at(-1)?.toLocaleLowerCase()??""}`;return!P0.has(e)}function Xr(t){return/(?:\.(?:tex|bib|bst|sty|cls|txt|md)|latexmkrc)$/i.test(t)}function vd(t){const e=t.split(".").at(-1)?.toLocaleLowerCase()??"";return e==="pdf"?"pdf":["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"].includes(e)?"image":A0(t)?"text":"unsupported"}function T0(t,e){return as(`/api/projects/${t}/file/raw?path=${encodeURIComponent(e)}`)}function O0({projectId:t,site:e,activeFile:n,dirty:r,save:s,onError:o,onProject:i,onActiveFile:c,onActiveMainFile:l}){const{t:d}=tt(),[h,f]=u.useState([]),[p,g]=u.useState(!1),[m,b]=u.useState(""),[S,C]=u.useState(null),[D,y]=u.useState(!1),[w,k]=u.useState(!1),[v,R]=u.useState(""),[A,N]=u.useState(""),[U,K]=u.useState(null),[T,q]=u.useState(""),[B,W]=u.useState(new Set),[z,Z]=u.useState(null),[I,V]=u.useState(""),[G,Q]=u.useState(""),[Ce,te]=u.useState(null),[ue,ke]=u.useState(!1),[j,Y]=u.useState(null),[le,Re]=u.useState(!1),[re,we]=u.useState(null),Ee=u.useRef(!1),J=u.useRef(null),ce=u.useRef(null),L=u.useRef(null),_e=async(_={})=>{ce.current?.abort(),ce.current=null;const H=_.signal?null:new AbortController;H&&(ce.current=H);try{const ae=await ye(`/api/projects/${t}/files`,{signal:_.signal??H?.signal});return(!_.isCurrent||_.isCurrent())&&f(ae.files),ae.files}catch(ae){if(!xd(ae))throw ae;return}finally{H&&ce.current===H&&(ce.current=null)}},Ne=async()=>{if(!(!m.trim()||m.trim().endsWith("/"))){N("");try{await ye(`/api/projects/${t}/file`,{method:"POST",body:JSON.stringify({path:m,content:""})}),await _e(),c(m),K(null),W(_=>new Set([..._,...ur(m)])),g(!1),b("")}catch(_){N(ge(_))}}},pe=async()=>{if(!v.trim())return;N("");const _=U?`${U}/${v.trim()}`:v.trim();try{const H=await ye(`/api/projects/${t}/folders`,{method:"POST",body:JSON.stringify({path:_})});await _e(),W(ae=>new Set([...ae,...ur(H.path),H.path])),K(H.path),k(!1),R("")}catch(H){N(ge(H))}},Oe=async(_,H=new Set,ae=U)=>{if(!_.length||Ee.current)return;const De=e.maxUploadSizeMB;if(_.find(oe=>oe.size>De*1024*1024)){we({kind:"error",message:d("errors.fileTooLarge",{size:De})});return}const rt=ae??"",Ke=_.map(oe=>rt?`${rt}/${oe.name}`:oe.name),ve=new Map;for(const oe of Ke)ve.set(oe,(ve.get(oe)??0)+1);const Gt=[...ve.entries()].filter(([,oe])=>oe>1).map(([oe])=>oe);if(Gt.length){we({kind:"error",message:d("errors.duplicateUploadNames",{files:Gt.join(", ")})});return}const ee=new Set(h.map(oe=>oe.path)),O=[...new Set(Ke.filter(oe=>ee.has(oe)&&!H.has(oe)))];if(O.length){we(null),Y({files:_,directory:rt,collisions:O});return}Y(null),J.current!==null&&window.clearTimeout(J.current),J.current=null,we(null),Ee.current=!0,Re(!0);let P=0;try{const oe=new URLSearchParams;rt&&oe.set("directory",rt);let ht="";for(const[bt,Dn]of _.entries()){const ln=Ke[bt];oe.delete("overwrite"),H.has(ln)&&oe.set("overwrite","1");const Jt=oe.toString()?`?${oe.toString()}`:"",jr=new FormData;jr.append("file",Dn);try{we({kind:"uploading",fileName:Dn.name,current:bt+1,total:_.length});const Rt=await ye(`/api/projects/${t}/upload${Jt}`,{method:"POST",body:jr});P+=1,typeof Rt.path=="string"&&Xr(Rt.path)&&(ht=Rt.path)}catch(Rt){if(Rt instanceof Mc&&Rt.status===409&&!H.has(ln)&&Rt.code==="FILE_EXISTS"){if(we(null),bt>0)try{await _e()}catch{}Y({files:_.slice(bt),directory:rt,collisions:[ln]});return}throw Rt}}try{await _e()}catch(bt){we({kind:"error",message:d("editor.uploadSucceededRefreshFailed",{message:ge(bt)})});return}ht&&(c(ht),K(null)),we({kind:"success",count:P}),J.current=window.setTimeout(()=>{we(bt=>bt?.kind==="success"?null:bt),J.current=null},3e3)}catch(oe){try{await _e()}catch{}const ht=P>0?d("editor.uploadFailedPartial",{uploaded:P,total:_.length,message:ge(oe)}):d("editor.uploadFailed",{message:ge(oe)});we({kind:"error",message:ht})}finally{Ee.current=!1,Re(!1)}},de=()=>{J.current!==null&&window.clearTimeout(J.current),J.current=null,we(null)},X=async _=>{await Oe(Array.from(_.target.files??[])),_.target.value=""},ne=async _=>{L.current?.abort(),L.current=null,y(!1);const H=T0(t,_.path);if((_.size??0)>na){C({path:_.path,kind:"large",size:_.size??0,url:H});return}const ae=vd(_.path);if(ae!=="text"){C({path:_.path,kind:ae,size:_.size??0,url:H});return}C({path:_.path,kind:ae,size:_.size??0,url:H,content:""}),y(!0);const De=new AbortController;L.current=De;try{let Me;try{Me=await fetch(H,{signal:De.signal})}catch(ve){throw Rw(ve)}const rt=Me.headers.get("content-type")??"";if(!Me.ok){let ve=null;try{ve=rt.includes("application/json")?await Me.json():await Me.text()}catch{}throw new Mc(Dw(ve,Me.status),Me.status,jw(ve))}const Ke=await Me.text();C(ve=>ve?.path===_.path?{...ve,content:Ke}:ve)}catch(Me){xd(Me)||(C(null),o(ge(Me)))}finally{L.current===De&&(L.current=null,y(!1))}},be=_=>{K(null),q(_.path);const H=vd(_.path),ae=e.maxCollaborativeFileSizeMB*1024*1024;(_.size??0)>na||Xr(_.path)&&(_.size??0)>ae||H!=="text"||!Xr(_.path)?ne(_):c(_.path)},Ae=async(_,H,ae)=>{if(!await s())return null;const De=await ye(`/api/projects/${t}/path`,{method:"PATCH",body:JSON.stringify({source:_.path,destinationDirectory:H,destinationName:ae})}),Me=ve=>ve===_.path?De.path:ve.startsWith(`${_.path}/`)?`${De.path}${ve.slice(_.path.length)}`:ve;c(ve=>Me(ve)),l(ve=>Me(ve)),K(ve=>ve&&Me(ve)),q(ve=>ve&&Me(ve));const[rt,Ke]=await Promise.all([ye(`/api/projects/${t}/files`),ye(`/api/projects/${t}`)]);return f(rt.files),i(Ke.project),W(ve=>new Set([...ve,...ur(De.path),H].filter(Boolean))),De.path},$=async()=>{if(!z)return;const _=I.trim();if(_){N("");try{if(!await Ae(z,G,_))return;Z(null),V(""),Q("")}catch(H){N(ge(H))}}},Pe=async(_,H)=>{if(L0(_.path)!==H&&!(_.type==="directory"&&(H===_.path||H.startsWith(`${_.path}/`))))try{await Ae(_,H,_.path.split("/").at(-1)??_.path)}catch(ae){o(ge(ae))}},Je=async()=>{if(Ce){N("");try{if(r&&!await s())return;await ye(`/api/projects/${t}/file?path=${encodeURIComponent(Ce.path)}`,{method:"DELETE"}),te(null)}catch(_){N(ge(_))}}};u.useEffect(()=>()=>{ce.current?.abort(),L.current?.abort(),J.current!==null&&window.clearTimeout(J.current)},[]),u.useEffect(()=>{L.current?.abort(),L.current=null,y(!1)},[n]),u.useEffect(()=>{n&&q(n)},[n]);const wt=h.filter(_=>_.type==="directory"),xe=h.filter(_=>ur(_.path).every(H=>B.has(H)));return{files:h,setFiles:f,loadFiles:_e,newFileOpen:p,setNewFileOpen:g,newFilePath:m,setNewFilePath:b,resourcePreview:S,setResourcePreview:C,resourcePreviewLoading:D,setResourcePreviewLoading:y,newFolderOpen:w,setNewFolderOpen:k,newFolderName:v,setNewFolderName:R,fileDialogError:A,setFileDialogError:N,selectedFolder:U,setSelectedFolder:K,selectedFile:T,setSelectedFile:q,expandedFolders:B,setExpandedFolders:W,moveEntry:z,setMoveEntry:Z,moveName:I,setMoveName:V,moveDestination:G,setMoveDestination:Q,deleteEntry:Ce,setDeleteEntry:te,fileDragActive:ue,setFileDragActive:ke,uploadConflict:j,setUploadConflict:Y,uploadingFiles:le,uploadFeedback:re,dismissUploadFeedback:de,directoryEntries:wt,visibleEntries:xe,createFile:Ne,createFolder:pe,uploadFiles:Oe,upload:X,openFile:be,movePath:$,movePathToFolder:Pe,removePath:Je}}function L0(t){const e=t.lastIndexOf("/");return e<0?"":t.slice(0,e)}function N0({active:t,harperEnabled:e=!0,projectId:n,activeFile:r,content:s,dictionaryWords:o,additionalIssues:i=[],additionalIssuesReady:c=!0}){const[l,d]=u.useState([]),[h,f]=u.useState(""),[p,g]=u.useState(""),[m,b]=u.useState(0),[S,C]=u.useState(null),[D,y]=u.useState(null),[w,k]=u.useState(!1),[v,R]=u.useState(0),A=u.useRef(0),N=u.useRef(!1),U=u.useRef(!1),K=u.useRef(s),T=u.useRef(r),q=u.useRef(0);K.current=s,T.current=r,U.current=w,u.useEffect(()=>{d([]),f(""),g(""),C(null),y(null),k(!1)},[r,o,e]),u.useEffect(()=>{y(null),k(!1)},[n]),u.useEffect(()=>{const I=++A.current;if(!t||!r){d([]),f(""),g(""),C(null);return}if(!e){d([]),f(""),g("");return}if(D){d([]),f(""),g("");return}const V=s,G=r;let Q=!1;const Ce=window.setTimeout(()=>{y(null),(async()=>{try{const{lintLatex:te,isHarperLintSupersededError:ue}=await Nt(async()=>{const{lintLatex:j,isHarperLintSupersededError:Y}=await import("./spellCheck-CRN7y5Qf.js");return{lintLatex:j,isHarperLintSupersededError:Y}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url);if(Q||I!==A.current||K.current!==V||T.current!==G)return;let ke;try{ke=await te(n,G,V,o)}catch(j){if(ue(j))return;throw j}if(Q||I!==A.current||K.current!==V||T.current!==G)return;N.current=!1,k(!1),d(ke),f(V),g(G),b(0),C(null)}catch(te){if(Q||I!==A.current||K.current!==V||T.current!==G)return;d([]),f(""),g(""),y(te instanceof Error?te.message:String(te));const ue=N.current;N.current=!1,k(ue?U.current:!1)}})()},700);return()=>{Q=!0,window.clearTimeout(Ce)}},[t,e,n,r,s,o,v,D]),u.useEffect(()=>{if(!D||!t||!e)return;let I=!1;const V=()=>{I||(I=!0,N.current=!0,y(null),R(Q=>Q+1))},G=window.setTimeout(V,15e3);return window.addEventListener("online",V,{once:!0}),()=>{window.clearTimeout(G),window.removeEventListener("online",V)}},[D,t,e]);const B=e&&t&&p===r&&h===s,W=u.useMemo(()=>{if(!t)return[];const I=[...B?l:[],...i].sort((G,Q)=>G.from-Q.from||G.to-Q.to),V=new Set;return I.filter(G=>{const Q=`${G.from}:${G.to}:${G.kind}:${G.message}`;return V.has(Q)?!1:(V.add(Q),!0)})},[t,i,B,l]),z=u.useMemo(()=>t&&(!e||B)&&c?{total:W.length,unique:new Set(W.map(I=>`${I.kind}:${I.word.toLocaleLowerCase("en-US")}`)).size}:null,[t,c,e,B,W]);return u.useEffect(()=>{b(I=>W.length?Math.min(I,W.length-1):0)},[W]),{issues:W,jump:t?S:null,index:m,summary:z,jumpToIssue:I=>{if(!W.length)return;const V=Math.max(0,Math.min(I,W.length-1)),G=W[V];b(V),C({from:G.from,to:G.to,nonce:++q.current})},error:t&&e&&!w?D:null,nativeFallback:t&&e&&!!D,retry:()=>{N.current=!1,y(null),k(!1),R(I=>I+1)},dismissError:()=>{N.current=!1,k(!0)}}}function M0({active:t,projectId:e,activeFile:n,content:r}){const[s,o]=u.useState([]),[i,c]=u.useState(""),[l,d]=u.useState(""),[h,f]=u.useState(null),[p,g]=u.useState(!1),[m,b]=u.useState(0),S=u.useRef(0),C=u.useRef(r),D=u.useRef(n);C.current=r,D.current=n,u.useEffect(()=>{o([]),c(""),d(""),f(null),g(!1)},[e,n]),u.useEffect(()=>{const w=++S.current;if(!t||!n){o([]),c(""),d("");return}const k=r,v=n;let R=!1;const A=window.setTimeout(()=>{(async()=>{try{const{lintChktex:N,isChktexLintSupersededError:U}=await Nt(async()=>{const{lintChktex:T,isChktexLintSupersededError:q}=await import("./chktex-BEVGf49u.js");return{lintChktex:T,isChktexLintSupersededError:q}},__vite__mapDeps([9,1,2,3,4,5,6,7,8]),import.meta.url);if(R||w!==S.current||C.current!==k||D.current!==v)return;let K;try{K=await N(e,v,k)}catch(T){if(U(T))return;throw T}if(R||w!==S.current||C.current!==k||D.current!==v)return;o(K),c(k),d(v),f(null),g(!1)}catch(N){if(R||w!==S.current||C.current!==k||D.current!==v)return;o([]),c(""),d(""),f(N instanceof Error?N.message:String(N))}})()},2e3);return()=>{R=!0,window.clearTimeout(A)}},[t,e,n,r,m]);const y=t&&l===n&&i===r;return{issues:y?s:[],checked:y,error:t&&!p?h:null,retry:()=>{f(null),g(!1),b(w=>w+1)},dismissError:()=>g(!0)}}function Sd(t){return t instanceof Error&&t.name==="AbortError"}function F0({projectId:t,mainFile:e,activeFile:n,onOpenSourceFile:r,onError:s,onShowPdf:o,onShowEditor:i}){const[c,l]=u.useState(null),[d,h]=u.useState(null),[f,p]=u.useState(null),g=u.useRef(null),m=u.useRef(0),b=u.useRef(n),S=u.useRef(r),C=u.useRef(s),D=u.useRef(o),y=u.useRef(i),w=U=>U===e&&/\.tex$/i.test(U);b.current=n,S.current=r,C.current=s,D.current=o,y.current=i,u.useEffect(()=>(g.current?.abort(),g.current=null,l(null),h(null),p(null),()=>g.current?.abort()),[t,e]);const k=(U,K,T)=>{p({path:U,line:K,column:T,nonce:++m.current}),S.current(U)},v=async(U,K,T,q={})=>{if(!w(U))return;g.current?.abort();const B=new AbortController;g.current=B;try{const W=await ye(`/api/projects/${t}/sync/pdf?mainFile=${encodeURIComponent(e)}&path=${encodeURIComponent(U)}&line=${K}&column=${T}`,{signal:B.signal});if(g.current!==B||!W)return;l({...W,nonce:++m.current}),D.current()}catch(W){!Sd(W)&&!q.silent&&C.current(ge(W))}finally{g.current===B&&(g.current=null)}},R=async(U,K,T)=>{const q=b.current;g.current?.abort();const B=new AbortController;g.current=B;try{const W=await ye(`/api/projects/${t}/sync/source?mainFile=${encodeURIComponent(e)}&page=${U}&x=${K}&y=${T}`,{signal:B.signal});if(g.current!==B||b.current!==q)return;y.current(),k(W.path,W.line,W.column)}catch(W){Sd(W)||C.current(ge(W))}finally{g.current===B&&(g.current=null)}};return{pdfTarget:c,pdfViewport:d,sourceJump:f,setPdfViewport:h,resetPdfViewport:()=>h(null),clearPdfViewport:()=>{g.current?.abort(),g.current=null,h(null),l(null)},jumpToSource:k,syncSourceToPdf:v,syncPdfToSource:R,syncVisiblePdfToSource:()=>{d&&R(d.page,d.x,d.y)}}}function Zh(t,e){return cr(`texlite.workspaceLayout:${encodeURIComponent(t)}:${encodeURIComponent(e)}`)}function Cd(t,e){try{const n=window.localStorage.getItem(Zh(t,e));if(n==="editor-pdf"||n==="editor-only"||n==="pdf-only")return n}catch{}return"editor-pdf"}function I0(t,e){const[n,r]=u.useState(()=>Cd(t,e));return u.useEffect(()=>{r(Cd(t,e))},[t,e]),{workspaceLayout:n,setWorkspaceLayout:o=>{r(o);try{window.localStorage.setItem(Zh(t,e),o)}catch{}}}}function $0(t){return!/\.(?:bib|bst)$/i.test(t.trim())}function Ed(t){return/\.(?:tex|sty|cls)$/i.test(t.trim())}const Qh=["verbatim","verbatim*","Verbatim","BVerbatim","LVerbatim","SaveVerbatim","VerbatimOut","bverbatim","bverbatim*","lverbatim","lverbatim*","saveverbatim","saveverbatim*","verbatimout","verbatimwrite","lstlisting","lstlisting*","minted","minted*","tcblisting","tcblisting*","pygmented","alltt","filecontents","filecontents*","luacode","luacodestar","comment"],U0=new Set(Qh);function z0(t){return U0.has(t)}function B0(t,e,n){if(t[e]!=="[")return e;let r=1;for(let s=e+1;s<n;s+=1){if(t[s]==="\\"){s+=1;continue}if(t[s]==="["&&(r+=1),t[s]==="]"&&(r-=1,r===0))return s+1}return null}function kd(t,e,n){if(t[e]!=="{")return null;let r=1;for(let s=e+1;s<n;s+=1){if(t[s]==="\\"){s+=1;continue}if(t[s]==="{"&&(r+=1),t[s]==="}"&&(r-=1,r===0))return s+1}return null}function ep(t,e,n=t.length){const r=t.indexOf(`
|
|
11
|
+
`,e);r>=0&&(n=Math.min(n,r));const s=/^\\(verb\*?|Verb\*?|lstinline\*?|mintinline\*?)(?![A-Za-z@])/.exec(t.slice(e,n));if(!s)return null;const o=s[1].replace(/\*$/,"");let i=e+s[0].length;if(o!=="verb"){const d=B0(t,i,n);if(d===null)return null;i=d}if(o==="mintinline"){const d=kd(t,i,n);if(d===null)return null;i=d}const c=t[i];if(!c||/\s/.test(c))return null;if(c==="{"&&o!=="verb"){const d=kd(t,i,n);return{end:d??n,closed:d!==null}}const l=t.indexOf(c,i+1);return l<0||l>=n?{end:n,closed:!1}:{end:l+1,closed:!0}}function tp(t,e,n=t.length){return ep(t,e,n)?.end??null}function fl(t,e,n){const r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(String.raw`\\end\s*\{\s*${r}\s*\}`,"g");s.lastIndex=e;const o=s.exec(t);return o?{from:o.index,to:o.index+o[0].length}:null}function zs(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function W0(t,e){let n=e+1;if(/[A-Za-z@]/.test(t[n]??"")){for(;/[A-Za-z@]/.test(t[n]??"");)n+=1;return t[n]==="*"&&(n+=1),n}return Math.min(t.length,n+1)}function np(t,e){const n=/^\\begin\s*\{\s*([A-Za-z0-9@:_*.\-]+)\s*\}/.exec(t.slice(e));return!n||!z0(n[1])?null:{name:n[1],to:e+n[0].length}}function lj(t,e){const n=Math.max(0,Math.min(t.length,e));for(let r=0;r<n;){if(t[r]==="%"&&!zs(t,r)){const i=t.indexOf(`
|
|
12
|
+
`,r),c=i<0?t.length:i;if(n<=c)return"comment";r=c+1;continue}if(t[r]!=="\\"||zs(t,r)){r+=1;continue}const s=ep(t,r);if(s!==null){if(n<s.end||!s.closed&&n<=s.end)return"literal";r=s.end;continue}const o=np(t,r);if(o){const i=fl(t,o.to,o.name),c=i?.to??t.length;if(n<c||!i&&n<=c)return"literal";r=c;continue}r=W0(t,r)}return null}function Rd(t,e,n){return t.slice(e,n).replace(/[^\r\n]/g," ")}function V0(t){const e=t.split("");for(let n=0;n<t.length;n+=1){if(t[n]!=="%"||zs(t,n))continue;const r=t.indexOf(`
|
|
13
|
+
`,n),s=r<0?t.length:r;for(let o=n;o<s;o+=1)e[o]=" ";n=s}return e.join("")}function H0(t){let e="",n=0;for(;n<t.length;){if(t[n]==="%"&&!zs(t,n)){const o=t.indexOf(`
|
|
14
|
+
`,n),i=o<0?t.length:o;e+=t.slice(n,i),n=i;continue}if(t[n]!=="\\"||zs(t,n)){e+=t[n],n+=1;continue}const r=tp(t,n);if(r!==null){e+=Rd(t,n,r),n=r;continue}const s=np(t,n);if(s){const i=fl(t,s.to,s.name)?.to??t.length;e+=Rd(t,n,i),n=i;continue}e+=t[n],n+=1}return e}function q0(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function Dd(t){const e=V0(H0(t)),n=/\\documentclass(?![A-Za-z@])\s*(?:\[[^\]]*\]\s*)?\{/g;for(const r of e.matchAll(n))if(r.index!==void 0&&!q0(e,r.index))return!0;return!1}const K0=new Set(Qh);function G0(t){return/[A-Za-z@0-9:_-]/.test(t)}function J0(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function hs(t,e){return t[e]==="%"&&!J0(t,e)}function Qs(t,e){const n=t.indexOf(`
|
|
15
|
+
`,e);return n===-1?t.length:n}function Qo(t,e){let n=e;for(;n<t.length;){if(/\s/.test(t[n])){n+=1;continue}if(hs(t,n)){n=Qs(t,n);continue}break}return n}function ra(t,e,n,r){if(t[e]!==n)return null;let s=0,o=0;for(let i=e;i<t.length;i+=1){const c=t[i];if(c==="\\"&&i+1<t.length){i+=1;continue}if(hs(t,i)){i=Qs(t,i)-1;continue}if(n==="["){if(c==="{"){o+=1;continue}if(c==="}"&&o>0){o-=1;continue}if(o>0)continue}if(c===n){s+=1;continue}if(c===r&&(s-=1,s===0))return{from:e,to:i+1,contentFrom:e+1,contentTo:i}}return null}function sa(t,e,n){const r=[];let s=e;for(;r.length<n;){for(s=Qo(t,s);t[s]==="[";){const i=ra(t,s,"[","]");if(!i)return r;s=Qo(t,i.to)}if(t[s]!=="{")break;const o=ra(t,s,"{","}");if(!o)break;r.push(o),s=o.to}return r}function uj(t,e,n){const r=[];let s=e;for(;r.length<n&&(s=Qo(t,s),t[s]==="[");){const o=ra(t,s,"[","]");if(!o)break;r.push(o),s=o.to}return r}function Y0(t,e){if(t[e]!=="\\"||e+1>=t.length)return null;let n=e+1;if(!/[A-Za-z@]/.test(t[n]))return{name:t[n],from:e,to:n+1};for(;n<t.length&&G0(t[n]);)n+=1;const r=t.slice(e+1,n);return t[n]==="*"&&(n+=1),{name:r,from:e,to:n}}function X0(t,e){if(e.name!=="begin")return e.to;const n=sa(t,e.to,1)[0];if(!n)return e.to;const r=t.slice(n.contentFrom,n.contentTo).trim();return K0.has(r)?fl(t,n.to,r)?.to??t.length:e.to}function Z0(t,e){let n=0;for(;n<t.length;){if(hs(t,n)){n=Qs(t,n);continue}if(t[n]!=="\\"){n+=1;continue}const r=Y0(t,n);if(!r){n+=1;continue}const s=tp(t,r.from);if(s!==null&&s>r.to){n=s;continue}const o=X0(t,r);if(o>r.to){n=o;continue}e(r),n=r.to}}function Cc(t,e,n){const r=[];let s=e.contentFrom,o=e.contentFrom;for(;o<=e.contentTo;){if(o<e.contentTo&&hs(t,o)){o=Qs(t,o),t[o]===`
|
|
16
|
+
`&&(o+=1);continue}if(o!==e.contentTo){o+=1;continue}const i=Q0(t,s,o);i&&r.push(i),s=o+1,o+=1}return r}function Q0(t,e,n){const r=[];let s=e;for(;s<n;){if(hs(t,s)){s=Qs(t,s),t[s]===`
|
|
17
|
+
`&&(s+=1);continue}r.push({character:t[s],index:s}),s+=1}let o=0,i=r.length;for(;o<i&&/\s/.test(r[o].character);)o+=1;for(;i>o&&/\s/.test(r[i-1].character);)i-=1;return o===i?null:{path:r.slice(o,i).map(c=>c.character).join(""),command:"",from:r[o].index,to:r[i-1].index+1}}function eE(t,e){const n=Qo(t,e);if(n>=t.length||/[\\{}\[\]#~]/.test(t[n]))return null;let r=n;for(;r<t.length&&!/\s/.test(t[r])&&!hs(t,r)&&!/[\\{}\[\]#~]/.test(t[r]);)r+=1;return r===n?null:{path:t.slice(n,r),command:"",from:n,to:r}}function jd(t){const e=[];return Z0(t,n=>{const r=n.name.toLowerCase();if(r==="input"||r==="include"||r==="subfile"){const l=sa(t,n.to,1)[0];if(l)for(const d of Cc(t,l))e.push({...d,command:n.name});else if(r==="input"){const d=eE(t,n.to);d&&e.push({...d,command:n.name})}return}if(r!=="import"&&r!=="subimport"&&r!=="includefrom"&&r!=="inputfrom"&&r!=="subinputfrom"&&r!=="subincludefrom")return;const s=sa(t,n.to,2);if(s.length!==2)return;const o=Cc(t,s[0])[0]?.path??"",i=Cc(t,s[1])[0];if(!i)return;const c=o&&!o.endsWith("/")?"/":"";e.push({path:o+c+i.path,command:n.name,from:i.from,to:i.to,directory:o})}),e}function tE({sessions:t,status:e}){const{t:n}=tt(),[r,s]=u.useState(!1),o=Math.max(0,t.length-5),i=r&&o>0,c=i?t:t.slice(0,5);return u.useEffect(()=>{t.length<=5&&s(!1)},[t.length]),t.length<=1?null:a.jsxs("div",{className:`collaboration-presence collaboration-${e}`,children:[a.jsx("span",{className:"collaboration-status-dot","data-tooltip":n(`editor.collaboration.${e}`),"aria-label":n(`editor.collaboration.${e}`)}),a.jsxs("div",{className:"collaboration-avatars","aria-label":n("editor.collaboration.activeSessions",{count:t.length}),children:[c.map(l=>{const d=l.editing?n("editor.collaboration.editing"):n("editor.collaboration.viewing"),h=l.permission==="read"?n("common.readOnly"):n("common.readWrite"),f=n("editor.collaboration.sessionTooltip",{name:l.name,username:l.username,file:l.filePath||n("editor.collaboration.joining"),activity:d,permission:h});return a.jsxs("span",{className:`collaboration-avatar${l.editing?" editing":""}${l.local?" local":""}`,style:{"--session-color":l.color},"aria-label":f,tabIndex:0,children:[E0(l.name,l.username),a.jsxs("span",{className:"collaboration-avatar-tooltip",role:"tooltip",children:[a.jsx("strong",{children:l.name}),a.jsxs("span",{children:["@",l.username]}),a.jsxs("small",{children:[l.filePath||n("editor.collaboration.joining")," · ",d," · ",h]})]})]},l.clientId)}),o>0&&a.jsx("button",{type:"button",className:"collaboration-avatar collaboration-avatar-overflow","aria-expanded":i,"aria-label":i?n("editor.collaboration.showFewerSessions"):n("editor.collaboration.showMoreSessions",{count:o}),title:i?n("editor.collaboration.showFewerSessions"):n("editor.collaboration.showMoreSessions",{count:o}),onClick:()=>s(l=>!l),children:i?"−":`+${o}`})]})]})}function nE({value:t,onChange:e}){const{t:n}=tt(),[r,s]=u.useState(!1),o=u.useRef(null),i=[{value:"editor-pdf",icon:Au},{value:"editor-only",icon:lb},{value:"pdf-only",icon:ub}];return u.useEffect(()=>{if(!r)return;const c=d=>{o.current?.contains(d.target)||s(!1)},l=d=>{d.key==="Escape"&&s(!1)};return document.addEventListener("pointerdown",c),document.addEventListener("keydown",l),()=>{document.removeEventListener("pointerdown",c),document.removeEventListener("keydown",l)}},[r]),a.jsxs("div",{className:"layout-menu",ref:o,children:[a.jsxs("button",{type:"button",className:`layout-trigger${r?" active":""}`,"aria-haspopup":"menu","aria-expanded":r,title:n("editor.layout.current",{layout:n(`editor.layout.${t}.name`)}),onClick:()=>s(c=>!c),children:[a.jsx(Au,{size:15}),a.jsxs("span",{children:[a.jsx("small",{children:n("editor.layout.label")}),n(`editor.layout.${t}.name`)]}),a.jsx(ci,{size:13})]}),r&&a.jsxs("div",{className:"layout-popover",role:"menu","aria-label":n("editor.layout.label"),children:[a.jsx("div",{className:"layout-popover-title",children:n("editor.layout.choose")}),i.map(c=>{const l=c.icon,d=c.value===t;return a.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":d,className:`layout-option${d?" selected":""}`,onClick:()=>{e(c.value),s(!1)},children:[a.jsx(l,{size:19}),a.jsxs("span",{children:[a.jsx("strong",{children:n(`editor.layout.${c.value}.name`)}),a.jsx("small",{children:n(`editor.layout.${c.value}.description`)})]}),d&&a.jsx(Tw,{size:16})]},c.value)})]})]})}function rE({site:t,project:e,activeFile:n,saveStateLabel:r,editorPreferences:s,activeSessions:o,collaborationStatus:i,reconnectCollaboration:c,protocolUpgradeRequired:l,showEditor:d,filesCollapsed:h,toggleFilesPanel:f,workspaceLayout:p,changeWorkspaceLayout:g,onBack:m,onShare:b,showCitationLibrary:S,citationLibraryOpen:C,onCitationLibrary:D,onHistory:y,onGit:w,canManageGit:k,formatting:v,readOnly:R,collaborationSynced:A,onToggleComments:N,commentsOpen:U,unresolvedCommentCount:K,onToggleSettings:T,settingsOpen:q,compileBusy:B,sharedCompiling:W,localCompiling:z,cancelling:Z,compileState:I,onCompile:V,onCancelCompile:G}){const{t:Q}=tt();return a.jsxs("header",{className:"editor-topbar",children:[a.jsx("button",{className:"back",title:Q("editor.backToProjects"),"aria-label":Q("editor.backToProjects"),onClick:m,children:a.jsx(Ow,{size:18})}),a.jsx("a",{className:"brand-link compact-brand-link",href:as("/"),"aria-label":t.siteName,onClick:Ce=>{Ce.preventDefault(),m()},children:a.jsx(_w,{siteName:t.siteName,compact:!0})}),a.jsxs("div",{className:"project-heading",children:[a.jsx("strong",{children:e.name}),a.jsxs("small",{children:[n," · ",r]})]}),s.vimMode&&a.jsxs("span",{className:"vim-status-badge",title:Q("editor.vimOnHint"),children:[a.jsx(ib,{size:14}),Q("editor.vimOn")]}),a.jsx(tE,{sessions:o,status:i}),i==="disconnected"&&!l&&a.jsxs("div",{className:"collaboration-recovery",role:"status",children:[a.jsx("span",{children:Q("editor.collaboration.disconnected")}),a.jsx("button",{type:"button",onClick:c,children:Q("editor.collaboration.reconnect")})]}),a.jsxs("div",{className:"editor-actions",children:[d&&a.jsxs("button",{className:h?"":"active",onClick:f,children:[h?a.jsx(ab,{size:15}):a.jsx(ff,{size:15}),Q("common.files")]}),a.jsx(nE,{value:p,onChange:g}),a.jsxs("button",{onClick:b,children:[a.jsx(No,{size:15}),Q("projectSettings.share")]}),S&&a.jsxs("button",{className:C?"active":"",onClick:D,children:[a.jsx(Lw,{size:15}),Q("citationLibrary.title")]}),a.jsxs("button",{type:"button",className:"snapshots-action",title:Q("history.projectSnapshots"),onClick:y,children:[a.jsx(Qw,{size:15}),Q("history.projectSnapshotsButton")]}),a.jsxs("button",{type:"button",className:`comments-action${U?" active":""}`,title:Q("editor.commentsAll"),"aria-label":K>0?`${Q("common.comments")} (${K})`:Q("common.comments"),onClick:N,children:[a.jsx(Nw,{size:15}),a.jsx("span",{children:Q("common.comments")}),K>0&&a.jsx("sup",{className:"comments-action-count",children:K})]}),a.jsxs("button",{className:"git-action",title:Q(k?"git.title":"git.ownerOnly"),disabled:!k,onClick:w,children:[a.jsx(Mw,{size:15}),"Git"]}),a.jsxs("button",{className:q?"active":"",onClick:T,children:[a.jsx(mb,{size:15}),Q("common.settings")]}),W||z?a.jsxs("button",{className:"compile cancel-compile",title:Q("compileControls.cancel"),onClick:G,disabled:Z||v||R||!A,children:[Z?a.jsx(gt,{className:"spin",size:15}):a.jsx(In,{size:15}),Q(Z?"compileControls.cancelling":"compileControls.cancel")]}):a.jsxs("button",{className:"compile",title:Q("editor.compileShortcut"),onClick:V,disabled:B||v||R||!A,children:[B?a.jsx(gt,{className:"spin",size:15}):a.jsx(db,{size:15}),Q("editor.compile",{engine:e.engine})]})]})]})}function sE(t){return`${t.path}\0${t.line}`}function oE(t){const e=[],n=[];for(const r of t){for(;n.length&&n.at(-1).level>=r.level;)n.pop();const s=n.at(-1);s&&(e[s.index].hasChildren=!0),e.push({item:r,key:sE(r),ancestorKeys:n.map(({index:o})=>e[o].key),hasChildren:!1}),n.push({level:r.level,index:e.length-1})}return e}function iE(t,e){return t.filter(n=>!n.ancestorKeys.some(r=>e.has(r)))}const cE=new Set(["avif","bmp","gif","ico","jpeg","jpg","png","svg","webp","eps"]),aE=new Set(["latex","ltx","tex"]),lE=new Set(["aux","blg","bbl","bst","c","cc","cls","cpp","css","dtx","go","h","hpp","html","idx","ilg","ind","ins","java","js","json","jsx","lof","log","lot","lua","ltx","nav","out","php","py","r","rs","sh","snm","sql","sty","tex","toc","ts","tsx","vrb","xml","yaml","yml"]),uE=new Set(["cfg","conf","dat","env","ini","text","toml","txt"]),dE=new Set(["csv","ods","tsv","xls","xlsx"]),fE=new Set(["7z","bz2","gz","rar","tar","xz","zip"]),hE=new Set(["m4a","mp3","ogg","wav"]),pE=new Set(["avi","mkv","mov","mp4","webm"]);function mE(t){const e=t.split("/").at(-1)?.toLocaleLowerCase()??"";if(e===".latexmkrc"||e==="latexmkrc")return"latexmkrc";if(e==="makefile"||e==="dockerfile")return"code";if(e==="readme"||e.startsWith("readme."))return"markdown";const n=e.includes(".")?e.slice(e.lastIndexOf(".")+1):"";return n==="pdf"?"pdf":cE.has(n)?"image":n==="md"||n==="markdown"||n==="mdown"||n==="mkdn"?"markdown":aE.has(n)?"tex":n==="bib"||n==="bibtex"?"bib":lE.has(n)?"code":uE.has(n)?"text":dE.has(n)?"spreadsheet":fE.has(n)?"archive":hE.has(n)?"audio":pE.has(n)?"video":"file"}const gE={pdf:rb,tex:_u,bib:cb,latexmkrc:eb,image:tb,markdown:af,text:Iw,code:_u,spreadsheet:Fw,archive:Fc,audio:Zw,video:sb,file:ii};function rp({path:t,size:e=13}){const n=mE(t);if(n==="pdf"||n==="tex")return a.jsx("img",{className:`file-type-icon file-type-icon-${n}`,src:as(`/${n==="pdf"?"pdf-file":"tex-file"}.svg`),width:e,height:e,alt:"","aria-hidden":"true"});const r=gE[n]??ob;return a.jsx(r,{className:`file-type-icon file-type-icon-${n}`,size:e,"aria-hidden":"true"})}const sp="application/x-texlite-project-path",op="texlite-path:";function yE({project:t,filesPanel:e,files:n,visibleEntries:r,activeFile:s,activeMainFile:o,selectedFile:i,selectedFolder:c,expandedFolders:l,fileDragActive:d,uploadingFiles:h,uploadFeedback:f,readOnly:p,formatting:g,canFormat:m,activeFormatLease:b,collaborationSynced:S,editorFontSize:C,outline:D,sourceCursorStore:y,wordCountBusy:w,hasSelection:k,hasFormatSelection:v,uploadInput:R,setSelectedFolder:A,setExpandedFolders:N,setMoveEntry:U,setMoveName:K,setMoveDestination:T,setDeleteEntry:q,setFileDialogError:B,setNewFolderName:W,setNewFolderOpen:z,setNewFilePath:Z,setNewFileOpen:I,setQuickOpen:V,setProjectSearchOpen:G,setFileDragActive:Q,dismissUploadFeedback:Ce,setFilesCollapsed:te,toggleFilesPanel:ue,uploadFiles:ke,upload:j,openFile:Y,movePathToFolder:le,onError:Re,onFormatFile:re,onFormatSelection:we,jumpToSource:Ee,syncSourceToPdf:J,onWordCount:ce}){const{t:L}=tt(),[_e,Ne]=u.useState(!1),[pe,Oe]=u.useState(null),[de,X]=u.useState(null),ne=u.useRef(0),be=($,Pe)=>bE($.path)!==Pe&&($.type!=="directory"||Pe!==$.path&&!Pe.startsWith(`${$.path}/`)),Ae=()=>{Oe(null),X(null)};return a.jsx(oi,{id:"files",order:1,ref:e,defaultSize:16,minSize:12,maxSize:30,collapsible:!0,collapsedSize:0,onCollapse:()=>te(!0),onExpand:()=>te(!1),children:a.jsxs("aside",{className:"left-panel",children:[a.jsxs("section",{className:`files-panel${d?" drop-active":""}`,onDragEnter:$=>{if(or($.dataTransfer)){$.preventDefault();return}$.dataTransfer.types.includes("Files")&&($.preventDefault(),!p&&!h&&Q(!0))},onDragOver:$=>{if(or($.dataTransfer)){$.preventDefault(),$.dataTransfer.dropEffect="move";return}$.dataTransfer.types.includes("Files")&&($.preventDefault(),$.dataTransfer.dropEffect=p||h?"none":"copy")},onDragLeave:$=>{$.currentTarget.contains($.relatedTarget)||Q(!1)},onDrop:$=>{if(or($.dataTransfer)){$.preventDefault(),$.stopPropagation();return}if($.preventDefault(),Q(!1),p||h)return;const Pe=Array.from($.dataTransfer.files);if(wE($.dataTransfer)||Pe.length===0){Re(L("editor.dropFoldersUnsupported"));return}ke(Pe)},children:[a.jsxs("div",{className:"panel-title",children:[a.jsx("button",{className:"file-size-toggle",type:"button","aria-pressed":_e,title:L(_e?"editor.hideFileSizes":"editor.showFileSizes"),onClick:()=>Ne($=>!$),children:L("common.files")}),a.jsxs("span",{className:"file-tools",children:[a.jsx("button",{type:"button","aria-label":L("navigation.quickOpen"),title:`${L("navigation.quickOpen")} (Ctrl/Cmd+P)`,onClick:()=>V(!0),children:a.jsx($w,{size:15})}),a.jsx("button",{type:"button","aria-label":L("navigation.projectSearch"),title:`${L("navigation.projectSearch")} (Ctrl/Cmd+Shift+F)`,onClick:()=>G(!0),children:a.jsx(qw,{size:15})}),!p&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",disabled:h,"aria-label":L("editor.uploadAttachment"),title:L("editor.uploadTo",{folder:c||L("editor.projectRoot")}),onClick:()=>R.current?.click(),children:a.jsx(Pu,{size:15})}),a.jsx("button",{type:"button","aria-label":L("editor.newFolder"),title:L("editor.newFolder"),onClick:()=>{W(""),z(!0)},children:a.jsx(Uw,{size:15})}),a.jsx("button",{type:"button","aria-label":L("editor.newFile"),title:L("editor.newFile"),onClick:()=>{Z(c?`${c}/`:""),I(!0)},children:a.jsx(nb,{size:15})}),a.jsx("input",{ref:R,type:"file",multiple:!0,hidden:!0,onChange:$=>{j($)}})]}),a.jsx("button",{type:"button","aria-label":L("editor.collapseFiles"),title:L("editor.collapseFiles"),onClick:ue,children:a.jsx(ff,{size:15})})]})]}),f&&a.jsxs("div",{className:`file-upload-feedback ${f.kind}`,role:f.kind==="error"?"alert":"status","aria-live":f.kind==="error"?"assertive":"polite","aria-busy":f.kind==="uploading",children:[f.kind==="uploading"?a.jsx(gt,{className:"spin",size:14}):f.kind==="success"?a.jsx(lf,{size:14}):a.jsx(Vt,{size:14}),a.jsxs("span",{className:"file-upload-feedback-text",children:[f.kind==="uploading"&&L("editor.uploadingFile",{file:f.fileName,current:f.current,total:f.total}),f.kind==="success"&&L("editor.uploadSucceeded",{count:f.count}),f.kind==="error"&&f.message]}),f.kind!=="uploading"&&a.jsx("button",{type:"button",className:"file-upload-feedback-dismiss","aria-label":L("common.close"),title:L("common.close"),onClick:Ce,children:a.jsx(In,{size:13})})]}),d&&a.jsxs("div",{className:"file-drop-overlay",children:[a.jsx(Pu,{size:24}),a.jsx("strong",{children:L("editor.dropFiles")}),a.jsx("span",{children:L("editor.uploadTo",{folder:c||L("editor.projectRoot")})})]}),a.jsx("div",{className:`file-list${c!==null?" folder-selected":""}${de===""?" root-drop-target":""}`,style:{fontSize:`${C}px`},onDragOver:$=>{if(!(!pe&&!or($.dataTransfer))&&($.preventDefault(),$.stopPropagation(),!!pe)){if(!be(pe,"")){$.dataTransfer.dropEffect="none";return}$.dataTransfer.dropEffect="move",X("")}},onDragLeave:$=>{$.currentTarget.contains($.relatedTarget)||X(Pe=>Pe===""?null:Pe)},onDrop:$=>{if(!pe&&!or($.dataTransfer)||($.preventDefault(),$.stopPropagation(),!pe))return;const Pe=pe;Ae(),be(Pe,"")&&le(Pe,"")},children:r.map($=>{const Pe=$.path.split("/").length-1,Je=$.path.split("/").at(-1),wt=l.has($.path),xe=t.mainFile===$.path,_=$.path!==t.mainFile&&!t.mainFile.startsWith(`${$.path}/`);return $.type==="directory"?a.jsxs("div",{className:`file-entry folder-entry${c===$.path?" selected":""}${de===$.path?" move-drop-target":""}`,style:{paddingLeft:`${Pe*13+5}px`},onDragOver:H=>{if(!(!pe&&!or(H.dataTransfer))&&(H.preventDefault(),H.stopPropagation(),!!pe)){if(!be(pe,$.path)){H.dataTransfer.dropEffect="none";return}H.dataTransfer.dropEffect="move",X($.path)}},onDragLeave:H=>{H.currentTarget.contains(H.relatedTarget)||X(ae=>ae===$.path?null:ae)},onDrop:H=>{if(!pe&&!or(H.dataTransfer)||(H.preventDefault(),H.stopPropagation(),!pe))return;const ae=pe;Ae(),be(ae,$.path)&&le(ae,$.path)},children:[a.jsxs("button",{type:"button",className:"file-entry-main",onClick:()=>{A($.path),N(H=>{const ae=new Set(H);return ae.has($.path)?ae.delete($.path):ae.add($.path),ae})},children:[wt?a.jsx(ci,{size:13}):a.jsx(_a,{size:13}),a.jsx(zw,{size:14}),a.jsx("span",{children:Je})]}),!p&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"file-entry-action","data-texlite-tooltip-always":!0,title:L("editor.move"),"aria-label":L("editor.move"),onClick:()=>{U($),K(Je??""),T("")},children:a.jsx(Ou,{size:13})}),_&&a.jsx("button",{type:"button",className:"file-entry-action danger-text",title:L("editor.deletePath"),"aria-label":L("editor.deletePath"),onClick:()=>{q($),B("")},children:a.jsx(fr,{size:13})})]})]},$.path):a.jsxs("div",{className:`file-entry${c===null&&i===$.path?" active":""}${pe?.path===$.path?" move-drag-source":""}`,style:{paddingLeft:`${Pe*13+18}px`},children:[a.jsxs("button",{type:"button",className:"file-entry-main",draggable:!p,onDragStart:H=>{ne.current=Date.now()+500,xE(H,$,Oe)},onDragEnd:Ae,onClick:()=>{if(ne.current>Date.now()){ne.current=0;return}Y($)},children:[a.jsx(rp,{path:$.path}),a.jsx("span",{children:Je}),xe&&a.jsx("small",{children:L("editor.currentMainShort")})]}),_e&&typeof $.size=="number"&&a.jsx("span",{className:"file-entry-size",children:SE($.size)}),!p&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"file-entry-action","data-texlite-tooltip-always":!0,title:L("editor.move"),"aria-label":L("editor.move"),onClick:()=>{U($),K(Je??""),T("")},children:a.jsx(Ou,{size:13})}),_&&a.jsx("button",{type:"button",className:"file-entry-action danger-text",title:L("editor.deletePath"),"aria-label":L("editor.deletePath"),onClick:()=>{q($),B("")},children:a.jsx(fr,{size:13})})]})]},$.path)})}),!p&&m&&a.jsxs("div",{className:"file-format-footer",role:"group","aria-label":L("editor.format"),"aria-busy":g,children:[a.jsxs("div",{className:"file-format-label",children:[a.jsx(Jw,{size:13}),L("editor.format")]}),a.jsxs("div",{className:"file-format-actions",children:[a.jsx("button",{className:v?"":"active",type:"button",title:L("editor.formatFileHint"),onMouseDown:$=>$.preventDefault(),onClick:re,disabled:g||b||!S,children:L("editor.formatFile")}),a.jsx("button",{className:v?"active":"",type:"button",title:L(v?"editor.formatSelection":"editor.formatSelectionHint"),onMouseDown:$=>$.preventDefault(),onClick:we,disabled:g||b||!S||!v,children:L("editor.formatSelected")})]})]})]}),a.jsx(vE,{outline:D,activeFile:s,activeMainFile:o,sourceCursorStore:y,wordCountBusy:w,hasSelection:k,jumpToSource:Ee,syncSourceToPdf:J,onWordCount:ce})]})})}function wE(t){return Array.from(t.items).some(e=>e.webkitGetAsEntry?.()?.isDirectory===!0)}function or(t){return Array.from(t.types).includes(sp)?!0:Array.from(t.types).includes("text/plain")&&t.getData("text/plain").startsWith(op)}function bE(t){const e=t.lastIndexOf("/");return e<0?"":t.slice(0,e)}function xE(t,e,n){t.dataTransfer.effectAllowed="move",t.dataTransfer.setData(sp,e.path),t.dataTransfer.setData("text/plain",`${op}${e.path}`),n(e)}function vE({outline:t,activeFile:e,activeMainFile:n,sourceCursorStore:r,wordCountBusy:s,hasSelection:o,jumpToSource:i,syncSourceToPdf:c,onWordCount:l}){const{t:d}=tt(),h=u.useSyncExternalStore(r.subscribe,r.getOutlineLine,r.getOutlineLine),f=u.useMemo(()=>oE(t),[t]),p=u.useMemo(()=>f.filter(y=>y.hasChildren).map(y=>y.key),[f]),[g,m]=u.useState(()=>new Set);u.useEffect(()=>{const y=new Set(p);m(w=>{const k=new Set([...w].filter(v=>y.has(v)));return k.size===w.size?w:k})},[p]);const b=p.length>0&&p.every(y=>g.has(y)),S=u.useMemo(()=>iE(f,g),[f,g]),C=()=>m(y=>b?new Set([...y].filter(w=>!p.includes(w))):new Set([...y,...p])),D=y=>m(w=>{const k=new Set(w);return k.has(y)?k.delete(y):k.add(y),k});return a.jsxs("section",{className:"outline-panel",children:[a.jsxs("div",{className:"panel-title",children:[a.jsxs("button",{className:"outline-heading",type:"button","aria-expanded":!b,title:d(b?"editor.expandOutline":"editor.collapseOutline"),onClick:C,disabled:p.length===0,children:[a.jsx(Bw,{size:14}),d("common.outline")]}),a.jsxs("span",{className:"word-count-actions",role:"group","aria-label":d("editor.wordCountTitle"),children:[a.jsxs("button",{type:"button",title:d("editor.wordCountFullHint"),onClick:()=>l("full"),disabled:s||!n,children:[s?a.jsx(gt,{className:"spin",size:12}):a.jsx(Tu,{size:12}),d("editor.wordCountFull")]}),a.jsxs("button",{type:"button",title:d("editor.wordCountSelectionHint"),onClick:()=>l("selection"),disabled:s||!o,children:[s?a.jsx(gt,{className:"spin",size:12}):a.jsx(Tu,{size:12}),d("editor.wordCountSelection")]})]})]}),a.jsxs("div",{className:"outline",children:[S.map(y=>{const{item:w}=y,k=g.has(y.key),v=e===w.path&&h===w.line,R=w.path===n||w.path===e;return a.jsxs("div",{className:`outline-row${v?" current":""}`,children:[a.jsx("span",{className:"outline-guides","aria-hidden":!0,style:{width:`${w.level*12}px`}}),y.hasChildren?a.jsx("button",{className:"outline-toggle",type:"button","aria-label":d(k?"editor.expandOutlineItem":"editor.collapseOutlineItem",{title:w.title}),"aria-expanded":!k,onClick:()=>D(y.key),children:k?a.jsx(_a,{size:13}):a.jsx(ci,{size:13})}):a.jsx("span",{className:"outline-toggle-spacer","aria-hidden":!0}),a.jsxs("button",{className:"outline-item",type:"button",onClick:()=>{i(w.path,w.line,1),c(w.path,w.line,1)},children:[a.jsx("small",{children:R?w.line:w.path.split("/").at(-1)}),a.jsx("span",{className:"outline-title",children:w.title})]})]},y.key)}),t.length===0&&a.jsx("p",{className:"muted padded",children:d("editor.noOutline")})]})]})}function SE(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/1024/1024).toFixed(1)} MB`:`${(t/1024/1024/1024).toFixed(1)} GB`}const CE=u.lazy(()=>Nt(()=>import("./LatexEditor-Dq9cqkpP.js"),__vite__mapDeps([10,2,11,1,3,4,5,6,7,8]),import.meta.url).then(t=>({default:t.LatexEditor})));function EE({project:t,activeFile:e,openTabs:n,content:r,loadedFile:s,readOnly:o,comments:i,focusComment:c,editorPreferences:l,completionIndex:d,nativeSpellCheck:h,spellCheckIssues:f,spellCheckJump:p,sourceJump:g,collaborativeText:m,collaborationAwareness:b,undoManager:S,editorNotice:C,activateTab:D,closeTab:y,handleTabKeyDown:w,updateEditorContent:k,setSelection:v,onAddComment:R,onSelectionHistory:A,onCommentClick:N,onSpellCheckReplace:U,onReferenceNavigate:K,onCursor:T}){const{t:q}=tt(),B=qb(i,e),W=Kb(c,e,s);return a.jsx(oi,{id:"source",order:2,defaultSize:42,minSize:22,children:a.jsxs("main",{className:"source-panel",children:[l.openFilesInTabs&&n.length>0&&a.jsx("div",{className:"editor-tabs-bar",role:"tablist","aria-label":q("editor.openFiles"),children:a.jsx("div",{className:"editor-tabs-scroll",children:n.map((z,Z)=>{const I=z===e,V=z===t.mainFile,G=z.split("/").at(-1)||z;return a.jsxs("div",{className:`editor-tab-item${I?" active":""}`,role:"presentation",children:[a.jsxs("button",{id:`editor-tab-${encodeURIComponent(z)}`,type:"button",role:"tab","aria-selected":I,"aria-controls":"editor-source-content",tabIndex:I?0:-1,className:`editor-tab${I?" active":""}${V?" main-tab":""}`,onClick:()=>D(z),onKeyDown:Q=>w(Q,Z),title:z,children:[a.jsx("span",{className:"editor-tab-icon",children:V?a.jsx(af,{size:13}):a.jsx(ii,{size:13})}),a.jsx("span",{className:"editor-tab-title",children:G}),V&&a.jsx("small",{className:"editor-tab-badge",children:q("editor.currentMainShort")})]}),a.jsx("button",{type:"button",className:"editor-tab-close",title:q("common.close"),"aria-label":`${q("common.close")} ${G}`,onClick:()=>y(z),children:a.jsx(In,{size:12})})]},z)})})}),a.jsxs("div",{id:"editor-source-content",className:"editor-content-container",children:[a.jsx(u.Suspense,{fallback:a.jsxs("div",{className:"preview-empty",children:[a.jsx(gt,{className:"spin",size:22}),a.jsx("span",{children:q("common.loading")})]}),children:a.jsx(CE,{value:r,filePath:e,readOnly:o,comments:B,focusComment:W,preferences:l,nativeSpellCheck:h,completionIndex:d,spellCheckIssues:f,spellCheckJump:p,jumpTo:s===e&&g?.path===e?g:null,searchRequest:0,collaboration:m?{text:m,awareness:b,undoManager:o?void 0:S}:void 0,onChange:k,onSelection:v,onAddComment:R,onSelectionHistory:A,onCommentClick:N,onSpellCheckReplace:U,onReferenceNavigate:K,onCursor:T},e)}),C&&a.jsx("div",{className:"editor-centered-notice",role:"status","aria-live":"polite",children:C})]})]})})}function _d({diagnostics:t,files:e,empty:n,tone:r,onJump:s}){const{t:o}=tt(),i=r==="error"?Pa:Vt;return t.length?a.jsx("div",{className:`compile-diagnostic-list compile-${r}`,children:t.map((c,l)=>{const d=DE(c.file,e),h=!!(d&&c.line);return a.jsxs("button",{type:"button",disabled:!h,className:"compile-diagnostic-row",onClick:()=>{d&&c.line&&s(d,c.line,c.column??1)},children:[a.jsx(i,{size:15}),a.jsxs("span",{children:[a.jsx("strong",{children:c.message}),a.jsxs("small",{children:[c.phase,d?` · ${d}${c.line?`:${c.line}`:""}`:c.line?` · ${o("editor.lineNumber",{line:c.line})}`:""]})]})]},`${c.phase}-${c.file??""}-${c.line??0}-${l}`)})}):a.jsxs("div",{className:`compile-empty compile-${r}`,children:[a.jsx(i,{size:26}),a.jsx("span",{children:n})]})}function Ec({lines:t,empty:e,tone:n="log"}){const r=n==="error"?Pa:n==="warning"?Vt:Ic;return t.length?a.jsx("pre",{className:`compile-output compile-${n}`,children:t.join(`
|
|
18
|
+
`)}):a.jsxs("div",{className:`compile-empty compile-${n}`,children:[a.jsx(r,{size:26}),a.jsx("span",{children:e})]})}function kE({projectId:t,mainFile:e,artifacts:n,preview:r,loading:s,onView:o}){const{t:i}=tt(),c=l=>as(`/api/projects/${t}/compile/artifacts?mainFile=${encodeURIComponent(e)}&path=${encodeURIComponent(l)}&download=1`);return n.length?a.jsxs("div",{className:"artifact-browser",children:[a.jsx("div",{className:"artifact-list",children:n.map(l=>a.jsxs("div",{className:`artifact-row${r?.path===l.path?" active":""}`,children:[a.jsxs("button",{type:"button",disabled:!l.viewable,title:l.viewable?i("editor.viewArtifact"):i("editor.downloadToView"),onClick:()=>o(l),children:[a.jsx(rp,{path:l.path,size:14}),a.jsxs("span",{children:[a.jsx("strong",{children:l.path}),a.jsx("small",{children:jE(l.size)})]})]}),a.jsx("a",{href:c(l.path),title:i("editor.downloadArtifact"),"aria-label":i("editor.downloadArtifact"),children:a.jsx(Mo,{size:14})})]},l.path))}),a.jsx("div",{className:"artifact-preview",children:s?a.jsxs("div",{className:"compile-empty",children:[a.jsx(gt,{className:"spin",size:24}),a.jsx("span",{children:i("common.loading")})]}):r?a.jsxs(a.Fragment,{children:[a.jsxs("header",{children:[a.jsx("strong",{children:r.path}),a.jsxs("a",{href:c(r.path),children:[a.jsx(Mo,{size:13}),i("projects.download")]})]}),a.jsx("pre",{children:r.content})]}):a.jsxs("div",{className:"compile-empty",children:[a.jsx(ii,{size:24}),a.jsx("span",{children:i("editor.selectArtifact")})]})})]}):a.jsxs("div",{className:"compile-empty",children:[a.jsx(df,{size:26}),a.jsx("span",{children:i("editor.noArtifacts")})]})}function RE({mainFile:t,disabled:e,cleaning:n,onCleanCache:r,onCleanArtifacts:s}){const{t:o}=tt();return a.jsxs("div",{className:"compile-clean-panel",children:[a.jsxs("div",{className:"compile-clean-intro",children:[a.jsx(Vt,{size:28}),a.jsxs("div",{children:[a.jsx("strong",{children:o("editor.cleanTitle")}),a.jsx("p",{children:o("editor.cleanDescription",{file:t})})]})]}),a.jsxs("div",{className:"compile-clean-actions",children:[a.jsxs("article",{children:[a.jsx("div",{className:"compile-clean-action-icon",children:a.jsx($c,{size:19})}),a.jsxs("div",{children:[a.jsx("strong",{children:o("editor.cleanCache")}),a.jsx("p",{children:o("editor.cleanCacheDescription")}),a.jsxs("button",{type:"button",disabled:e||n,onClick:r,children:[n?a.jsx(gt,{className:"spin",size:14}):a.jsx($c,{size:14}),o("editor.cleanCache")]})]})]}),a.jsxs("article",{className:"danger",children:[a.jsx("div",{className:"compile-clean-action-icon",children:a.jsx(fr,{size:19})}),a.jsxs("div",{children:[a.jsx("strong",{children:o("editor.cleanArtifacts")}),a.jsx("p",{children:o("editor.cleanArtifactsDescription")}),a.jsxs("button",{type:"button",className:"danger",disabled:e||n,onClick:s,children:[n?a.jsx(gt,{className:"spin",size:14}):a.jsx(fr,{size:14}),o("editor.cleanArtifacts")]})]})]})]})]})}function DE(t,e){if(!t)return null;const n=e.filter(c=>c.type==="file").map(c=>c.path),r=t.replaceAll("\\","/").replace(/^\.\//,"");if(n.includes(r))return r;const s=n.filter(c=>r.endsWith(`/${c}`));if(s.length===1)return s[0];const o=r.split("/").at(-1),i=n.filter(c=>c.split("/").at(-1)===o);return i.length===1?i[0]:null}function jE(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}const _E=u.lazy(()=>nf().then(t=>({default:t.PdfPreview})));function PE({projectId:t,activeMainFile:e,previewTab:n,diagnosticTab:r,pdfUrl:s,pdfLoadingMode:o,pdfLoading:i,pdfCompiledAt:c,pdfSizeBytes:l,pdfCompiledLabel:d,pdfTargetLabel:h,pdfDownloadUrl:f,pdfTarget:p,pdfViewport:g,activeFile:m,compileBusy:b,compileLog:S,compileDiagnostics:C,compileMessages:D,artifacts:y,artifactPreview:w,artifactLoading:k,cleaning:v,readOnly:R,collaborationSynced:A,workspaceLayout:N,showSyncResize:U,diagnosticCount:K,selectPreviewTab:T,changeWorkspaceLayout:q,onSetNotice:B,onSetPdfViewport:W,onResetPdfViewport:z,syncVisiblePdfToSource:Z,syncCurrentSourceToPdf:I,syncPdfToSource:V,canSyncWithPdf:G,canSyncPdfToSource:Q,files:Ce,jumpToSource:te,onSetCleanMode:ue,cleanCompile:ke,viewArtifact:j}){const{t:Y}=tt(),[le,Re]=u.useState(""),re=u.useRef(""),we=L=>{re.current!==L&&(re.current=L,Re(L),z())},Ee=Q&&!!s&&le===s,ce=[l==null?"":AE(l),d?Y("editor.pdfUpdatedAt",{time:d}):""].filter(Boolean).join(" · ");return a.jsxs(a.Fragment,{children:[U&&a.jsxs(ja,{className:"resize-handle sync-resize-handle",children:[a.jsx(uf,{className:"resize-grip",size:12}),a.jsxs("span",{className:"sync-direction-buttons",onPointerDown:L=>L.stopPropagation(),children:[a.jsx("button",{disabled:!s||!g||!Ee,title:Y(Q?Ee?"editor.showInSource":"editor.syncTexWaitingForPdf":"editor.syncTexOnlyForMain"),"aria-label":Y("editor.showInSource"),onClick:()=>{Ee&&Z()},children:a.jsx("span",{"aria-hidden":!0,children:"←"})}),a.jsx("button",{disabled:!m||!s||!G,title:Y(G?"editor.showInPdf":"editor.syncTexOnlyForMain"),"aria-label":Y("editor.showInPdf"),onClick:()=>{!m||!s||!G||I()},children:a.jsx("span",{"aria-hidden":!0,children:"→"})})]})]}),a.jsx(oi,{id:"preview",order:3,defaultSize:42,minSize:22,children:a.jsxs("section",{className:"preview-panel",children:[a.jsxs("div",{className:"preview-tabs",children:[a.jsxs("div",{className:"preview-tab-list",role:"tablist","aria-label":Y("editor.outputTabs"),children:[a.jsxs("button",{role:"tab","aria-selected":n==="pdf",className:`pdf-tab${n==="pdf"?" active":""}`,onClick:()=>T("pdf"),title:c?Y("editor.pdfCompiledAtFor",{file:e,time:new Date(c).toLocaleString(Rs.resolvedLanguage)}):Y("editor.currentMainDocument",{path:e}),children:[a.jsx("img",{className:"pdf-tab-icon",src:as("/pdf-download.svg"),alt:"","aria-hidden":"true"}),a.jsxs("span",{className:"pdf-tab-label",children:["PDF · ",h,ce&&a.jsx("small",{children:ce})]})]}),a.jsxs("button",{role:"tab","aria-selected":n==="diagnostics",className:`diagnostics-tab${n==="diagnostics"?" active":""}`,onClick:()=>T("diagnostics"),children:[a.jsx(Ic,{size:14}),Y("editor.outputTabs"),a.jsx("span",{children:K})]})]}),f&&a.jsxs("a",{className:"pdf-download-top",href:f,download:!0,title:Y("editor.downloadPdf"),"aria-label":Y("editor.downloadPdf"),children:[a.jsx(Mo,{size:15}),a.jsx("span",{children:Y("editor.downloadPdf")})]})]}),n==="diagnostics"&&a.jsxs("div",{className:"preview-subtabs",role:"tablist","aria-label":Y("editor.outputTabs"),children:[a.jsxs("button",{role:"tab","aria-selected":r==="log",className:r==="log"?"active":"",onClick:()=>T("log"),children:[a.jsx(Ic,{size:13}),Y("editor.log")]}),a.jsxs("button",{role:"tab","aria-selected":r==="warnings",className:r==="warnings"?"active":"",onClick:()=>T("warnings"),children:[a.jsx(Vt,{size:13}),Y("editor.warnings"),a.jsx("span",{children:D.warnings.length})]}),a.jsxs("button",{role:"tab","aria-selected":r==="errors",className:r==="errors"?"active":"",onClick:()=>T("errors"),children:[a.jsx(Pa,{size:13}),Y("editor.errors"),a.jsx("span",{children:D.errors.length})]}),a.jsxs("button",{role:"tab","aria-selected":r==="artifacts",className:r==="artifacts"?"active":"",onClick:()=>T("artifacts"),children:[a.jsx(df,{size:13}),Y("editor.artifacts"),a.jsx("span",{children:y.length})]}),a.jsxs("button",{role:"tab","aria-selected":r==="clean",className:r==="clean"?"active":"",onClick:()=>T("clean"),children:[a.jsx($c,{size:13}),Y("editor.clean")]})]}),a.jsxs("div",{className:`preview-content preview-${n} ${n==="diagnostics"?`preview-${r}`:""}`,children:[n==="pdf"&&(s?a.jsx(u.Suspense,{fallback:a.jsxs("div",{className:"pdf-loading-state",role:"status","aria-live":"polite",children:[a.jsx(gt,{className:"spin",size:24}),a.jsx("span",{children:Y("editor.loadingPdf")})]}),children:a.jsx(_E,{url:s,loadingMode:o,target:p,compiling:b,onDisplayedUrlChange:we,onViewportLocation:(L,_e,Ne)=>{re.current===s&&W({page:L,x:_e,y:Ne})},onDoubleClickLocation:(L,_e,Ne)=>{re.current!==s||!Ee||(W({page:L,x:_e,y:Ne}),V(L,_e,Ne))}})}):i?a.jsxs("div",{className:"pdf-loading-state",role:"status","aria-live":"polite",children:[a.jsx(gt,{className:"spin",size:24}),a.jsx("span",{children:Y("editor.loadingPdf")})]}):a.jsxs("div",{className:"preview-empty",children:[a.jsx(ii,{size:28}),a.jsx("strong",{children:Y("editor.preview")}),a.jsx("span",{children:Y("editor.previewHint")})]})),n==="diagnostics"&&r==="log"&&a.jsx(Ec,{lines:S?S.split(`
|
|
19
|
+
`):[],empty:Y(b?"editor.compiling":"editor.noLog")}),n==="diagnostics"&&r==="warnings"&&(C?a.jsx(_d,{tone:"warning",diagnostics:C.warnings,files:Ce,empty:Y("editor.noWarnings"),onJump:(L,_e,Ne)=>{N==="pdf-only"&&q("editor-pdf"),te(L,_e,Ne)}}):a.jsx(Ec,{tone:"warning",lines:D.warnings,empty:Y("editor.noWarnings")})),n==="diagnostics"&&r==="errors"&&(C?a.jsx(_d,{tone:"error",diagnostics:C.errors,files:Ce,empty:Y("editor.noErrors"),onJump:(L,_e,Ne)=>{N==="pdf-only"&&q("editor-pdf"),te(L,_e,Ne)}}):a.jsx(Ec,{tone:"error",lines:D.errors,empty:Y("editor.noErrors")})),n==="diagnostics"&&r==="artifacts"&&a.jsx(kE,{projectId:t,mainFile:e,artifacts:y,preview:w,loading:k,onView:L=>{j(L)}}),n==="diagnostics"&&r==="clean"&&a.jsx(RE,{mainFile:e,disabled:R||!A||b,cleaning:v,onCleanCache:()=>ue("cache"),onCleanArtifacts:()=>ue("artifacts")})]})]})})]})}function AE(t){return!Number.isFinite(t)||t<0?"":t<1024?`${Math.round(t)} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function TE(t,e){const n=t.slice(0,e),r=/(^|[^\p{L}\p{N}_.-])@([\p{L}\p{N}_.-]*)$/u.exec(n);return r?{start:e-r[2].length-1,end:e,query:r[2]}:null}function To({projectId:t,value:e,onChange:n,onKeyDown:r,onFocus:s,...o}){const{t:i}=tt(),c=u.useRef(null),[l,d]=u.useState(null),[h,f]=u.useState(!1),[p,g]=u.useState(null),[m,b]=u.useState(0),S=u.useMemo(()=>{if(!p||!l)return[];const v=p.query.toLocaleLowerCase();return(v?l.filter(A=>A.username.toLocaleLowerCase().includes(v)||A.displayName.toLocaleLowerCase().includes(v)):l).slice(0,8)},[l,p]),C=!!(p&&S.length),D=async()=>{if(!(l||h)){f(!0);try{const v=await ye(`/api/projects/${t}/mention-candidates`);d(v.users)}catch{d([])}finally{f(!1)}}},y=(v,R)=>{const A=TE(v,R);g(A),b(0),A&&D()},w=v=>{if(!p)return;const R=`@${v.username} `,A=`${e.slice(0,p.start)}${R}${e.slice(p.end)}`,N=p.start+R.length;n(A),g(null),b(0),window.requestAnimationFrame(()=>{c.current?.focus(),c.current?.setSelectionRange(N,N)})},k=v=>{if(!v.nativeEvent.isComposing&&C){if(v.key==="ArrowDown"){v.preventDefault(),b(R=>(R+1)%S.length);return}if(v.key==="ArrowUp"){v.preventDefault(),b(R=>(R-1+S.length)%S.length);return}if(v.key==="Enter"&&!v.ctrlKey&&!v.metaKey&&!v.shiftKey){v.preventDefault(),w(S[m]??S[0]);return}if(v.key==="Escape"){g(null);return}}r?.(v)};return a.jsxs("span",{className:"mention-textarea",children:[a.jsx("textarea",{...o,ref:c,value:e,onFocus:v=>{s?.(v),y(e,v.currentTarget.selectionStart??e.length)},onClick:v=>y(e,v.currentTarget.selectionStart??e.length),onChange:v=>{const R=v.currentTarget.value;n(R),y(R,v.currentTarget.selectionStart??R.length)},onKeyDown:k}),C&&a.jsx("span",{className:"mention-menu",role:"listbox","aria-label":i("editor.mentionUsers"),children:S.map((v,R)=>a.jsxs("button",{type:"button",role:"option","aria-selected":R===m,className:R===m?"active":"",onMouseDown:A=>A.preventDefault(),onClick:()=>w(v),children:[a.jsx(Ps,{"aria-hidden":!0,size:13}),a.jsxs("span",{children:[a.jsx("strong",{children:v.displayName}),a.jsxs("small",{children:["(",v.username,")"]})]})]},v.id))})]})}var OE=Object.defineProperty,Mt=(t,e)=>OE(t,"name",{value:e,configurable:!0});function ip(t){const e=u.forwardRef((n,r)=>{let{children:s,...o}=n,i=null,c=!1;const l=[];oa(s)&&typeof xo=="function"&&(s=xo(s._payload)),u.Children.forEach(s,p=>{if(up(p)){c=!0;const g=p;let m="child"in g.props?g.props.child:g.props.children;oa(m)&&typeof xo=="function"&&(m=xo(m._payload)),i=NE(g,m),l.push(i?.props?.children)}else l.push(p)}),i?i=u.cloneElement(i,void 0,l):!c&&u.Children.count(s)===1&&u.isValidElement(s)&&(i=s);const d=i?lp(i):void 0,h=ze(r,d);if(!i){if(s||s===0)throw new Error(c?IE(t):FE(t));return s}const f=ap(o,i.props??{});return i.type!==u.Fragment&&(f.ref=r?h:d),u.cloneElement(i,f)});return e.displayName=`${t}.Slot`,e}Mt(ip,"createSlot");var cp=Symbol.for("radix.slottable");function LE(t){const e=Mt(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=cp,e}Mt(LE,"createSlottable");var NE=Mt((t,e)=>{if("child"in t.props){const n=t.props.child;return u.isValidElement(n)?u.cloneElement(n,void 0,t.props.children(n.props.children)):null}return u.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function ap(t,e){const n={...e};for(const r in e){const s=t[r],o=e[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...c)=>{const l=o(...c);return s(...c),l}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"?n[r]=[s,o].filter(Boolean).join(" "):r==="aria-describedby"&&(n[r]=fp(o,s))}return{...t,...n}}Mt(ap,"mergeProps");function lp(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}Mt(lp,"getElementRef");function up(t){return u.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===cp}Mt(up,"isSlottable");var ME=Symbol.for("react.lazy");function oa(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===ME&&"_payload"in t&&dp(t._payload)}Mt(oa,"isLazyComponent");function dp(t){return typeof t=="object"&&t!==null&&"then"in t}Mt(dp,"isPromiseLike");function fp(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const r of String(n).trim().split(/\s+/))r&&e.add(r);return e.size>0?Array.from(e).join(" "):void 0}Mt(fp,"concatAriaDescribedby");var FE=Mt(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),IE=Mt(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),xo=xr[" use ".trim().toString()],$E=Object.defineProperty,UE=(t,e)=>$E(t,"name",{value:e,configurable:!0}),zE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],BE=zE.reduce((t,e)=>{const n=ip(`Primitive.${e}`),r=u.forwardRef((s,o)=>{const{asChild:i,...c}=s,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(l,{...c,ref:o})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function WE(t,e){t&&qn.flushSync(()=>t.dispatchEvent(e))}UE(WE,"dispatchDiscreteCustomEvent");var VE=Object.defineProperty,Ft=(t,e)=>VE(t,"name",{value:e,configurable:!0});function Bs(t){const e=u.forwardRef((n,r)=>{let{children:s,...o}=n,i=null,c=!1;const l=[];ia(s)&&typeof vo=="function"&&(s=vo(s._payload)),u.Children.forEach(s,p=>{if(gp(p)){c=!0;const g=p;let m="child"in g.props?g.props.child:g.props.children;ia(m)&&typeof vo=="function"&&(m=vo(m._payload)),i=qE(g,m),l.push(i?.props?.children)}else l.push(p)}),i?i=u.cloneElement(i,void 0,l):!c&&u.Children.count(s)===1&&u.isValidElement(s)&&(i=s);const d=i?mp(i):void 0,h=ze(r,d);if(!i){if(s||s===0)throw new Error(c?JE(t):GE(t));return s}const f=pp(o,i.props??{});return i.type!==u.Fragment&&(f.ref=r?h:d),u.cloneElement(i,f)});return e.displayName=`${t}.Slot`,e}Ft(Bs,"createSlot");var hp=Symbol.for("radix.slottable");function HE(t){const e=Ft(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=hp,e}Ft(HE,"createSlottable");var qE=Ft((t,e)=>{if("child"in t.props){const n=t.props.child;return u.isValidElement(n)?u.cloneElement(n,void 0,t.props.children(n.props.children)):null}return u.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function pp(t,e){const n={...e};for(const r in e){const s=t[r],o=e[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...c)=>{const l=o(...c);return s(...c),l}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"?n[r]=[s,o].filter(Boolean).join(" "):r==="aria-describedby"&&(n[r]=wp(o,s))}return{...t,...n}}Ft(pp,"mergeProps");function mp(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}Ft(mp,"getElementRef");function gp(t){return u.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===hp}Ft(gp,"isSlottable");var KE=Symbol.for("react.lazy");function ia(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===KE&&"_payload"in t&&yp(t._payload)}Ft(ia,"isLazyComponent");function yp(t){return typeof t=="object"&&t!==null&&"then"in t}Ft(yp,"isPromiseLike");function wp(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const r of String(n).trim().split(/\s+/))r&&e.add(r);return e.size>0?Array.from(e).join(" "):void 0}Ft(wp,"concatAriaDescribedby");var GE=Ft(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),JE=Ft(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),vo=xr[" use ".trim().toString()],YE=Object.defineProperty,at=(t,e)=>YE(t,"name",{value:e,configurable:!0});function hl(t){const e=t+"CollectionProvider",[n,r]=br(e),[s,o]=n(e,{collectionRef:{current:null},itemMap:new Map}),i=at(b=>{const{scope:S,children:C}=b,D=u.useRef(null),y=u.useRef(new Map).current;return a.jsx(s,{scope:S,itemMap:y,collectionRef:D,children:C})},"CollectionProvider");i.displayName=e;const c=t+"CollectionSlot",l=Bs(c),d=u.forwardRef((b,S)=>{const{scope:C,children:D}=b,y=o(c,C),w=ze(S,y.collectionRef);return a.jsx(l,{ref:w,children:D})});d.displayName=c;const h=t+"CollectionItemSlot",f="data-radix-collection-item",p=Bs(h),g=u.forwardRef((b,S)=>{const{scope:C,children:D,...y}=b,w=u.useRef(null),k=ze(S,w),v=o(h,C);return u.useEffect(()=>(v.itemMap.set(w,{ref:w,...y}),()=>{v.itemMap.delete(w)})),a.jsx(p,{[f]:"",ref:k,children:D})});g.displayName=h;function m(b){const S=o(t+"CollectionConsumer",b);return u.useCallback(()=>{const D=S.collectionRef.current;if(!D)return[];const y=Array.from(D.querySelectorAll(`[${f}]`));return Array.from(S.itemMap.values()).sort((v,R)=>y.indexOf(v.ref.current)-y.indexOf(R.ref.current))},[S.collectionRef,S.itemMap])}return at(m,"useCollection"),[{Provider:i,Slot:d,ItemSlot:g},m,r]}at(hl,"createCollection");var Pd=new WeakMap,kc=class Ln extends Map{static{at(this,"OrderedDict")}#e;constructor(e){super(e),this.#e=[...super.keys()],Pd.set(this,!0)}set(e,n){return Pd.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,n),this}insert(e,n,r){const s=this.has(n),o=this.#e.length,i=pl(e);let c=i>=0?i:o+i;const l=c<0||c>=o?-1:c;if(l===this.size||s&&l===this.size-1||l===-1)return this.set(n,r),this;const d=this.size+(s?0:1);i<0&&c++;const h=[...this.#e];let f,p=!1;for(let g=c;g<d;g++)if(c===g){let m=h[g];h[g]===n&&(m=h[g+1]),s&&this.delete(n),f=this.get(m),this.set(n,r)}else{!p&&h[g-1]===n&&(p=!0);const m=h[p?g:g-1],b=f;f=this.get(m),this.delete(m),this.set(m,b)}return this}with(e,n,r){const s=new Ln(this);return s.insert(e,n,r),s}before(e){const n=this.#e.indexOf(e)-1;if(!(n<0))return this.entryAt(n)}setBefore(e,n,r){const s=this.#e.indexOf(e);return s===-1?this:this.insert(s,n,r)}after(e){let n=this.#e.indexOf(e);if(n=n===-1||n===this.size-1?-1:n+1,n!==-1)return this.entryAt(n)}setAfter(e,n,r){const s=this.#e.indexOf(e);return s===-1?this:this.insert(s+1,n,r)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){const n=super.delete(e);return n&&this.#e.splice(this.#e.indexOf(e),1),n}deleteAt(e){const n=this.keyAt(e);return n!==void 0?this.delete(n):!1}at(e){const n=Oo(this.#e,e);if(n!==void 0)return this.get(n)}entryAt(e){const n=Oo(this.#e,e);if(n!==void 0)return[n,this.get(n)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Oo(this.#e,e)}from(e,n){const r=this.indexOf(e);if(r===-1)return;let s=r+n;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.at(s)}keyFrom(e,n){const r=this.indexOf(e);if(r===-1)return;let s=r+n;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.keyAt(s)}find(e,n){let r=0;for(const s of this){if(Reflect.apply(e,n,[s,r,this]))return s;r++}}findIndex(e,n){let r=0;for(const s of this){if(Reflect.apply(e,n,[s,r,this]))return r;r++}return-1}filter(e,n){const r=[];let s=0;for(const o of this)Reflect.apply(e,n,[o,s,this])&&r.push(o),s++;return new Ln(r)}map(e,n){const r=[];let s=0;for(const o of this)r.push([o[0],Reflect.apply(e,n,[o,s,this])]),s++;return new Ln(r)}reduce(...e){const[n,r]=e;let s=0,o=r??this.at(0);for(const i of this)s===0&&e.length===1?o=i:o=Reflect.apply(n,this,[o,i,s,this]),s++;return o}reduceRight(...e){const[n,r]=e;let s=r??this.at(-1);for(let o=this.size-1;o>=0;o--){const i=this.at(o);o===this.size-1&&e.length===1?s=i:s=Reflect.apply(n,this,[s,i,o,this])}return s}toSorted(e){const n=[...this.entries()].sort(e);return new Ln(n)}toReversed(){const e=new Ln;for(let n=this.size-1;n>=0;n--){const r=this.keyAt(n),s=this.get(r);e.set(r,s)}return e}toSpliced(...e){const n=[...this.entries()];return n.splice(...e),new Ln(n)}slice(e,n){const r=new Ln;let s=this.size-1;if(e===void 0)return r;e<0&&(e=e+this.size),n!==void 0&&n>0&&(s=n-1);for(let o=e;o<=s;o++){const i=this.keyAt(o),c=this.get(i);r.set(i,c)}return r}every(e,n){let r=0;for(const s of this){if(!Reflect.apply(e,n,[s,r,this]))return!1;r++}return!0}some(e,n){let r=0;for(const s of this){if(Reflect.apply(e,n,[s,r,this]))return!0;r++}return!1}};function Oo(t,e){if("at"in Array.prototype)return Array.prototype.at.call(t,e);const n=bp(t,e);return n===-1?void 0:t[n]}at(Oo,"at");function bp(t,e){const n=t.length,r=pl(e),s=r>=0?r:n+r;return s<0||s>=n?-1:s}at(bp,"toSafeIndex");function pl(t){return t!==t||t===0?0:Math.trunc(t)}at(pl,"toSafeInteger");function XE(t){const e=t+"CollectionProvider",[n,r]=br(e),[s,o]=n(e,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new kc,setItemMap:at(()=>{},"setItemMap")}),i=at(({state:y,...w})=>y?a.jsx(l,{...w,state:y}):a.jsx(c,{...w}),"CollectionProvider");i.displayName=e;const c=at(y=>{const w=S();return a.jsx(l,{...y,state:w})},"CollectionInit");c.displayName=e+"Init";const l=at(y=>{const{scope:w,children:k,state:v}=y,R=u.useRef(null),[A,N]=u.useState(null),U=ze(R,N),[K,T]=v;return u.useEffect(()=>{if(!A)return;const q=Sp(()=>{});return q.observe(A,{childList:!0,subtree:!0}),()=>{q.disconnect()}},[A]),a.jsx(s,{scope:w,itemMap:K,setItemMap:T,collectionRef:U,collectionRefObject:R,collectionElement:A,children:k})},"CollectionProviderImpl");l.displayName=e+"Impl";const d=t+"CollectionSlot",h=Bs(d),f=u.forwardRef((y,w)=>{const{scope:k,children:v}=y,R=o(d,k),A=ze(w,R.collectionRef);return a.jsx(h,{ref:A,children:v})});f.displayName=d;const p=t+"CollectionItemSlot",g="data-radix-collection-item",m=Bs(p),b=u.forwardRef((y,w)=>{const{scope:k,children:v,...R}=y,A=u.useRef(null),[N,U]=u.useState(null),K=ze(w,A,U),T=o(p,k),{setItemMap:q}=T,B=u.useRef(R);xp(B.current,R)||(B.current=R);const W=B.current;return u.useEffect(()=>{const z=W;return q(Z=>N?Z.has(N)?Z.set(N,{...z,element:N}).toSorted(ca):(Z.set(N,{...z,element:N}),Z.toSorted(ca)):Z),()=>{q(Z=>!N||!Z.has(N)?Z:(Z.delete(N),new kc(Z)))}},[N,W,q]),a.jsx(m,{[g]:"",ref:K,children:v})});b.displayName=p;function S(){return u.useState(new kc)}at(S,"useInitCollection");function C(y){const{itemMap:w}=o(t+"CollectionConsumer",y);return w}return at(C,"useCollection"),[{Provider:i,Slot:f,ItemSlot:b},{createCollectionScope:r,useCollection:C,useInitCollection:S}]}at(XE,"createCollection");function xp(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t==null||e==null)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(e,s)||t[s]!==e[s])return!1;return!0}at(xp,"shallowEqual");function vp(t,e){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}at(vp,"isElementPreceding");function ca(t,e){return!t[1].element||!e[1].element?0:vp(t[1].element,e[1].element)?-1:1}at(ca,"sortByDocumentPosition");function Sp(t){return new MutationObserver(n=>{for(const r of n)if(r.type==="childList"){t();return}})}at(Sp,"getChildListObserver");var ZE=Object.defineProperty,QE=(t,e)=>ZE(t,"name",{value:e,configurable:!0}),ek={LTR:"ltr"},tk=u.createContext(void 0);function ml(t){const e=u.useContext(tk);return t||e||ek.LTR}QE(ml,"useDirection");var nk=Object.defineProperty,It=(t,e)=>nk(t,"name",{value:e,configurable:!0});function gl(t){const e=u.forwardRef((n,r)=>{let{children:s,...o}=n,i=null,c=!1;const l=[];aa(s)&&typeof So=="function"&&(s=So(s._payload)),u.Children.forEach(s,p=>{if(Rp(p)){c=!0;const g=p;let m="child"in g.props?g.props.child:g.props.children;aa(m)&&typeof So=="function"&&(m=So(m._payload)),i=sk(g,m),l.push(i?.props?.children)}else l.push(p)}),i?i=u.cloneElement(i,void 0,l):!c&&u.Children.count(s)===1&&u.isValidElement(s)&&(i=s);const d=i?kp(i):void 0,h=ze(r,d);if(!i){if(s||s===0)throw new Error(c?ck(t):ik(t));return s}const f=Ep(o,i.props??{});return i.type!==u.Fragment&&(f.ref=r?h:d),u.cloneElement(i,f)});return e.displayName=`${t}.Slot`,e}It(gl,"createSlot");var Cp=Symbol.for("radix.slottable");function rk(t){const e=It(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=Cp,e}It(rk,"createSlottable");var sk=It((t,e)=>{if("child"in t.props){const n=t.props.child;return u.isValidElement(n)?u.cloneElement(n,void 0,t.props.children(n.props.children)):null}return u.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function Ep(t,e){const n={...e};for(const r in e){const s=t[r],o=e[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...c)=>{const l=o(...c);return s(...c),l}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"?n[r]=[s,o].filter(Boolean).join(" "):r==="aria-describedby"&&(n[r]=jp(o,s))}return{...t,...n}}It(Ep,"mergeProps");function kp(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}It(kp,"getElementRef");function Rp(t){return u.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Cp}It(Rp,"isSlottable");var ok=Symbol.for("react.lazy");function aa(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===ok&&"_payload"in t&&Dp(t._payload)}It(aa,"isLazyComponent");function Dp(t){return typeof t=="object"&&t!==null&&"then"in t}It(Dp,"isPromiseLike");function jp(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const r of String(n).trim().split(/\s+/))r&&e.add(r);return e.size>0?Array.from(e).join(" "):void 0}It(jp,"concatAriaDescribedby");var ik=It(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),ck=It(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),So=xr[" use ".trim().toString()],ak=Object.defineProperty,lk=(t,e)=>ak(t,"name",{value:e,configurable:!0}),uk=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vi=uk.reduce((t,e)=>{const n=gl(`Primitive.${e}`),r=u.forwardRef((s,o)=>{const{asChild:i,...c}=s,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(l,{...c,ref:o})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function yl(t,e){t&&qn.flushSync(()=>t.dispatchEvent(e))}lk(yl,"dispatchDiscreteCustomEvent");var dk=Object.defineProperty,it=(t,e)=>dk(t,"name",{value:e,configurable:!0}),la="dismissableLayer.update",fk="dismissableLayer.pointerDownOutside",hk="dismissableLayer.focusOutside",Ad,_p=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),pk=u.forwardRef(it(function(e,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:c,onInteractOutside:l,onDismiss:d,...h}=e,f=u.useContext(_p),[p,g]=u.useState(null),m=p?.ownerDocument??globalThis?.document,[,b]=u.useState({}),S=ze(n,g),C=Array.from(f.layers),[D]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),y=D?C.indexOf(D):-1,w=p?C.indexOf(p):-1,k=f.layersWithOutsidePointerEventsDisabled.size>0,v=w>=y,R=u.useRef(!1),A=Pp(T=>{i?.(T),l?.(T),T.defaultPrevented||d?.()},{ownerDocument:m,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:R,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:u.useCallback(T=>{if(!(T instanceof Node))return!1;const q=[...f.branches].some(B=>B.contains(T));return v&&!q},[f.branches,v])}),N=Ap(T=>{if(s&&R.current)return;const q=T.target;[...f.branches].some(W=>W.contains(q))||(c?.(T),l?.(T),T.defaultPrevented||d?.())},m),U=p?w===C.length-1:!1,K=_t(T=>{T.key==="Escape"&&(o?.(T),!T.defaultPrevented&&d&&(T.preventDefault(),d()))});return u.useEffect(()=>{if(U)return m.addEventListener("keydown",K,{capture:!0}),()=>m.removeEventListener("keydown",K,{capture:!0})},[m,U,K]),u.useEffect(()=>{if(p)return r&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Ad=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),ua(),()=>{r&&(f.layersWithOutsidePointerEventsDisabled.delete(p),f.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=Ad))}},[p,m,r,f]),u.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),ua())},[p,f]),u.useEffect(()=>{const T=it(()=>b({}),"handleUpdate");return document.addEventListener(la,T),()=>document.removeEventListener(la,T)},[]),a.jsx(vi.div,{...h,ref:S,style:{pointerEvents:k?v?"auto":"none":void 0,...e.style},onFocusCapture:Te(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Te(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Te(e.onPointerDownCapture,A.onPointerDownCapture)})},"DismissableLayer"));function mk(){const t=u.useContext(_p),[e,n]=u.useState(null);return u.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),n}it(mk,"useDismissableLayerSurface");var gk=it(()=>!0,"IS_TRUE");function Pp(t,e){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:s,dismissableSurfaces:o,shouldHandlePointerDownOutside:i=gk}=e,c=_t(t),l=u.useRef(!1),d=u.useRef(!1),h=u.useRef(new Map),f=u.useRef(()=>{});return u.useEffect(()=>{function p(){d.current=!1,s.current=!1,h.current.clear()}it(p,"resetOutsideInteraction");function g(){return Array.from(h.current.values()).some(Boolean)}it(g,"isOutsideInteractionIntercepted");function m(y){if(!d.current)return;const w=y.target;w instanceof Node&&[...o].some(v=>v.contains(w))||h.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{d.current&&f.current()},0)}it(m,"handleInteractionCapture");function b(y){d.current&&h.current.set(y.type,!1)}it(b,"handleInteractionBubble");const S=it(y=>{if(y.target&&!l.current){let w=function(){n.removeEventListener("click",f.current);const v=g();p(),v||wl(fk,c,k,{discrete:!0})};if(it(w,"handleAndDispatchPointerDownOutsideEvent"),!i(y.target)){n.removeEventListener("click",f.current),p(),l.current=!1;return}const k={originalEvent:y};d.current=!0,s.current=r&&y.button===0,h.current.clear(),!r||y.button!==0?w():(n.removeEventListener("click",f.current),f.current=w,n.addEventListener("click",f.current,{once:!0}))}else n.removeEventListener("click",f.current),p();l.current=!1},"handlePointerDown"),C=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of C)n.addEventListener(y,m,!0),n.addEventListener(y,b);const D=window.setTimeout(()=>{n.addEventListener("pointerdown",S)},0);return()=>{window.clearTimeout(D),n.removeEventListener("pointerdown",S),n.removeEventListener("click",f.current);for(const y of C)n.removeEventListener(y,m,!0),n.removeEventListener(y,b)}},[n,c,r,s,o,i]),{onPointerDownCapture:it(()=>l.current=!0,"onPointerDownCapture")}}it(Pp,"usePointerDownOutside");function Ap(t,e=globalThis?.document){const n=_t(t),r=u.useRef(!1);return u.useEffect(()=>{const s=it(o=>{o.target&&!r.current&&wl(hk,n,{originalEvent:o},{discrete:!1})},"handleFocus");return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,n]),{onFocusCapture:it(()=>r.current=!0,"onFocusCapture"),onBlurCapture:it(()=>r.current=!1,"onBlurCapture")}}it(Ap,"useFocusOutside");function ua(){const t=new CustomEvent(la);document.dispatchEvent(t)}it(ua,"dispatchUpdate");function wl(t,e,n,{discrete:r}){const s=n.originalEvent.target,o=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&s.addEventListener(t,e,{once:!0}),r?yl(s,o):s.dispatchEvent(o)}it(wl,"handleAndDispatchCustomEvent");var yk=Object.defineProperty,Qe=(t,e)=>yk(t,"name",{value:e,configurable:!0}),Rc="focusScope.autoFocusOnMount",Dc="focusScope.autoFocusOnUnmount",Td={bubbles:!1,cancelable:!0},wk=u.forwardRef(Qe(function(e,n){const{loop:r=!1,trapped:s=!1,branches:o,onMountAutoFocus:i,onUnmountAutoFocus:c,...l}=e,[d,h]=u.useState(null),f=_t(i),p=_t(c),g=u.useRef(null),m=ze(n,h),b=u.useRef(o);u.useEffect(()=>{b.current=o});const S=u.useCallback(y=>y?d?.contains(y)?!0:!!b.current?.some(w=>w.contains(y)):!1,[d]),C=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(s){let y=function(R){if(C.paused||!d)return;const A=R.target;S(A)?g.current=A:mn(g.current,{select:!0})},w=function(R){if(C.paused||!d)return;const A=R.relatedTarget;A!==null&&(S(A)||mn(g.current,{select:!0}))},k=function(R){if(document.activeElement===document.body)for(const N of R)N.removedNodes.length>0&&mn(d)};Qe(y,"handleFocusIn"),Qe(w,"handleFocusOut"),Qe(k,"handleMutations"),document.addEventListener("focusin",y),document.addEventListener("focusout",w);const v=new MutationObserver(k);return d&&v.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",w),v.disconnect()}}},[s,d,C.paused,S]),u.useEffect(()=>{if(d){Od.add(C);const y=document.activeElement;if(!d.contains(y)){const k=new CustomEvent(Rc,Td);d.addEventListener(Rc,f),d.dispatchEvent(k),k.defaultPrevented||(Mp(zp(bl(d)),{select:!0}),document.activeElement===y&&mn(d))}return()=>{d.removeEventListener(Rc,f),setTimeout(()=>{const k=new CustomEvent(Dc,Td);d.addEventListener(Dc,p),d.dispatchEvent(k),k.defaultPrevented||mn(y??document.body,{select:!0}),d.removeEventListener(Dc,p),Od.remove(C)},0)}}},[d,f,p,C]);const D=u.useCallback(y=>{if(!r&&!s||C.paused)return;const w=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,k=document.activeElement;if(w&&k){const v=y.currentTarget,[R,A]=Fp(v);R&&A?!y.shiftKey&&k===A?(y.preventDefault(),r&&mn(R,{select:!0})):y.shiftKey&&k===R&&(y.preventDefault(),r&&mn(A,{select:!0})):k===v&&y.preventDefault()}},[r,s,C.paused]);return a.jsx(vi.div,{tabIndex:-1,...l,ref:m,onKeyDown:D})},"FocusScope")),Tp=u.createContext(null);function Op({registry:t,children:e}){return t?a.jsx(Tp.Provider,{value:t,children:e}):e}Qe(Op,"FocusScopeBranchProvider");function Lp(){const[t,e]=u.useState([]),n=u.useMemo(()=>({add:Qe(r=>e(s=>s.includes(r)?s:[...s,r]),"add"),remove:Qe(r=>e(s=>s.filter(o=>o!==r)),"remove")}),[]);return{nodes:t,registry:n}}Qe(Lp,"useFocusScopeBranchRegistry");function Np(t){const e=u.useContext(Tp);u.useEffect(()=>{if(!(!t||!e))return e.add(t),()=>e.remove(t)},[t,e])}Qe(Np,"useFocusScopeBranch");function Mp(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(mn(r,{select:e}),document.activeElement!==n)return}Qe(Mp,"focusFirst");function Fp(t){const e=bl(t),n=da(e,t),r=da(e.reverse(),t);return[n,r]}Qe(Fp,"getTabbableEdges");function bl(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:Qe(r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)e.push(n.currentNode);return e}Qe(bl,"getTabbableCandidates");function da(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const r of t)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Ip(r,{upTo:e})))return r}Qe(da,"findVisible");function Ip(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}Qe(Ip,"isHidden");function $p(t){return t instanceof HTMLInputElement&&"select"in t}Qe($p,"isSelectableInput");function mn(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&$p(t)&&e&&t.select()}}Qe(mn,"focus");var Od=Up();function Up(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=fa(t,e),t.unshift(e)},remove(e){t=fa(t,e),t[0]?.resume()}}}Qe(Up,"createFocusScopesStack");function fa(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}Qe(fa,"arrayRemove");function zp(t){return t.filter(e=>e.tagName!=="A")}Qe(zp,"removeLinks");const bk=["top","right","bottom","left"],Vn=Math.min,bn=Math.max,ei=Math.round,Co=Math.floor,xn=t=>({x:t,y:t}),xk={left:"right",right:"left",bottom:"top",top:"bottom"};function Bp(t,e,n){return bn(t,Vn(e,n))}function Sn(t,e){return typeof t=="function"?t(e):t}function Hn(t){return t.split("-")[0]}function ps(t){return t.split("-")[1]}function xl(t){return t==="x"?"y":"x"}function vl(t){return t==="y"?"height":"width"}function Zt(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function Sl(t){return xl(Zt(t))}function vk(t,e,n){n===void 0&&(n=!1);const r=ps(t),s=Sl(t),o=vl(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(i=ti(i)),[i,ti(i)]}function Sk(t){const e=ti(t);return[ha(t),e,ha(e)]}function ha(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const Ld=["left","right"],Nd=["right","left"],Ck=["top","bottom"],Ek=["bottom","top"];function kk(t,e,n){switch(t){case"top":case"bottom":return n?e?Nd:Ld:e?Ld:Nd;case"left":case"right":return e?Ck:Ek;default:return[]}}function Rk(t,e,n,r){const s=ps(t);let o=kk(Hn(t),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),e&&(o=o.concat(o.map(ha)))),o}function ti(t){const e=Hn(t);return xk[e]+t.slice(e.length)}function Dk(t){var e,n,r,s;return{top:(e=t.top)!=null?e:0,right:(n=t.right)!=null?n:0,bottom:(r=t.bottom)!=null?r:0,left:(s=t.left)!=null?s:0}}function Wp(t){return typeof t!="number"?Dk(t):{top:t,right:t,bottom:t,left:t}}function ni(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function Md(t,e,n){let{reference:r,floating:s}=t;const o=Zt(e),i=Sl(e),c=vl(i),l=Hn(e),d=o==="y",h=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[c]/2-s[c]/2;let g;switch(l){case"top":g={x:h,y:r.y-s.height};break;case"bottom":g={x:h,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:f};break;case"left":g={x:r.x-s.width,y:f};break;default:g={x:r.x,y:r.y}}const m=ps(e);return m&&(g[i]+=p*(m==="end"?1:-1)*(n&&d?-1:1)),g}async function jk(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:o,rects:i,elements:c,strategy:l}=t,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:p=!1,padding:g=0}=Sn(e,t),m=Wp(g),S=c[p?f==="floating"?"reference":"floating":f],C=ni(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(S)))==null||n?S:S.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(c.floating)),boundary:d,rootBoundary:h,strategy:l})),D=f==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,y=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c.floating)),w=await(o.isElement==null?void 0:o.isElement(y))&&await(o.getScale==null?void 0:o.getScale(y))||{x:1,y:1},k=ni(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:D,offsetParent:y,strategy:l}):D);return{top:(C.top-k.top+m.top)/w.y,bottom:(k.bottom-C.bottom+m.bottom)/w.y,left:(C.left-k.left+m.left)/w.x,right:(k.right-C.right+m.right)/w.x}}const _k=50,Pk=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:jk},l=await(i.isRTL==null?void 0:i.isRTL(e));let d=await i.getElementRects({reference:t,floating:e,strategy:s}),{x:h,y:f}=Md(d,r,l),p=r,g=0;const m={};for(let b=0;b<o.length;b++){const S=o[b];if(!S)continue;const{name:C,fn:D}=S,{x:y,y:w,data:k,reset:v}=await D({x:h,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:m,rects:d,platform:c,elements:{reference:t,floating:e}});h=y??h,f=w??f,m[C]={...m[C],...k},v&&g<_k&&(g++,typeof v=="object"&&(v.placement&&(p=v.placement),v.rects&&(d=v.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:s}):v.rects),{x:h,y:f}=Md(d,p,l)),b=-1)}return{x:h,y:f,placement:p,strategy:s,middlewareData:m}},Ak=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:o,platform:i,elements:c,middlewareData:l}=e,{element:d,padding:h=0}=Sn(t,e)||{};if(d==null)return{};const f=Wp(h),p={x:n,y:r},g=Sl(s),m=vl(g),b=await i.getDimensions(d),S=g==="y",C=S?"top":"left",D=S?"bottom":"right",y=S?"clientHeight":"clientWidth",w=o.reference[m]+o.reference[g]-p[g]-o.floating[m],k=p[g]-o.reference[g],v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let R=v?v[y]:0;(!R||!await(i.isElement==null?void 0:i.isElement(v)))&&(R=c.floating[y]||o.floating[m]);const A=w/2-k/2,N=R/2-b[m]/2-1,U=Vn(f[C],N),K=Vn(f[D],N),T=R-b[m]-K,q=R/2-b[m]/2+A,B=Bp(U,q,T),W=!l.arrow&&ps(s)!=null&&q!==B&&o.reference[m]/2-(q<U?U:K)-b[m]/2<0,z=W?q<U?q-U:q-T:0;return{[g]:p[g]+z,data:{[g]:B,centerOffset:q-B-z,...W&&{alignmentOffset:z}},reset:W}}}),Tk=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:c,platform:l,elements:d}=e,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:b=!0,...S}=Sn(t,e);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const C=Hn(s),D=Zt(c),y=Hn(c)===c,w=await(l.isRTL==null?void 0:l.isRTL(d.floating)),k=p||(y||!b?[ti(c)]:Sk(c)),v=m!=="none";!p&&v&&k.push(...Rk(c,b,m,w));const R=[c,...k],A=await l.detectOverflow(e,S),N=[];let U=((r=o.flip)==null?void 0:r.overflows)||[];if(h&&N.push(A[C]),f){const B=vk(s,i,w);N.push(A[B[0]],A[B[1]])}if(U=[...U,{placement:s,overflows:N}],!N.every(B=>B<=0)){var K,T;const B=(((K=o.flip)==null?void 0:K.index)||0)+1,W=R[B];if(W&&(!(f==="alignment"?D!==Zt(W):!1)||U.every(I=>Zt(I.placement)===D?I.overflows[0]>0:!0)))return{data:{index:B,overflows:U},reset:{placement:W}};let z=(T=U.filter(Z=>Z.overflows[0]<=0).sort((Z,I)=>Z.overflows[1]-I.overflows[1])[0])==null?void 0:T.placement;if(!z)switch(g){case"bestFit":{var q;const Z=(q=U.filter(I=>{if(v){const V=Zt(I.placement);return V===D||V==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(V=>V>0).reduce((V,G)=>V+G,0)]).sort((I,V)=>I[1]-V[1])[0])==null?void 0:q[0];Z&&(z=Z);break}case"initialPlacement":z=c;break}if(s!==z)return{reset:{placement:z}}}return{}}}};function Fd(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Id(t){return bk.some(e=>t[e]>=0)}const Ok=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:s="referenceHidden",...o}=Sn(t,e);switch(s){case"referenceHidden":{const i=await r.detectOverflow(e,{...o,elementContext:"reference"}),c=Fd(i,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Id(c)}}}case"escaped":{const i=await r.detectOverflow(e,{...o,altBoundary:!0}),c=Fd(i,n.floating);return{data:{escapedOffsets:c,escaped:Id(c)}}}default:return{}}}}},Vp=new Set(["left","top"]);async function Lk(t,e){const{placement:n,platform:r,elements:s}=t,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=Hn(n),c=ps(n),l=Zt(n)==="y",d=Vp.has(i)?-1:1,h=o&&l?-1:1,f=Sn(e,t);let{mainAxis:p,crossAxis:g,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return c&&typeof m=="number"&&(g=c==="end"?m*-1:m),l?{x:g*h,y:p*d}:{x:p*d,y:g*h}}const Nk=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:o,placement:i,middlewareData:c}=e,l=await Lk(e,t);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:i}}}}},Mk=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s,platform:o}=e,{mainAxis:i=!0,crossAxis:c=!1,limiter:l={fn:D=>{let{x:y,y:w}=D;return{x:y,y:w}}},...d}=Sn(t,e),h={x:n,y:r},f=await o.detectOverflow(e,d),p=Zt(s),g=xl(p);let m=h[g],b=h[p];const S=(D,y)=>Bp(y+f[D==="y"?"top":"left"],y,y-f[D==="y"?"bottom":"right"]);i&&(m=S(g,m)),c&&(b=S(p,b));const C=l.fn({...e,[g]:m,[p]:b});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[g]:i,[p]:c}}}}}},Fk=function(t){return t===void 0&&(t={}),{options:t,fn(e){var n,r;const{x:s,y:o,placement:i,rects:c,middlewareData:l}=e,{offset:d=0,mainAxis:h=!0,crossAxis:f=!0}=Sn(t,e),p={x:s,y:o},g=Zt(i),m=xl(g);let b=p[m],S=p[g];const C=Sn(d,e),D=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:(n=C.mainAxis)!=null?n:0,crossAxis:(r=C.crossAxis)!=null?r:0};if(h){const k=m==="y"?"height":"width",v=c.reference[m]-c.floating[k]+D.mainAxis,R=c.reference[m]+c.reference[k]-D.mainAxis;b<v?b=v:b>R&&(b=R)}if(f){var y,w;const k=m==="y"?"width":"height",v=Vp.has(Hn(i)),R=c.reference[g]-c.floating[k]+(v&&((y=l.offset)==null?void 0:y[g])||0)+(v?0:D.crossAxis),A=c.reference[g]+c.reference[k]+(v?0:((w=l.offset)==null?void 0:w[g])||0)-(v?D.crossAxis:0);S<R?S=R:S>A&&(S=A)}return{[m]:b,[g]:S}}}},Ik=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:r,platform:s,elements:o}=e,{apply:i=()=>{},...c}=Sn(t,e),l=await s.detectOverflow(e,c),d=Hn(n),h=ps(n),f=Zt(n)==="y",{width:p,height:g}=r.floating;let m,b;d==="top"||d==="bottom"?(m=d,b=h===(await(s.isRTL==null?void 0:s.isRTL(o.floating))?"start":"end")?"left":"right"):(b=d,m=h==="end"?"top":"bottom");const S=g-l.top-l.bottom,C=p-l.left-l.right,D=Vn(g-l[m],S),y=Vn(p-l[b],C),w=e.middlewareData.shift,k=!w;let v=D,R=y;w!=null&&w.enabled.x&&(R=C),w!=null&&w.enabled.y&&(v=S),k&&!h&&(f?R=p-2*bn(l.left,l.right):v=g-2*bn(l.top,l.bottom)),await i({...e,availableWidth:R,availableHeight:v});const A=await s.getDimensions(o.floating);return p!==A.width||g!==A.height?{reset:{rects:!0}}:{}}}};function Si(){return typeof window<"u"}function ms(t){return Hp(t)?(t.nodeName||"").toLowerCase():"#document"}function kt(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Rn(t){var e;return(e=(Hp(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Hp(t){return Si()?t instanceof Node||t instanceof kt(t).Node:!1}function nn(t){return Si()?t instanceof Element||t instanceof kt(t).Element:!1}function Gn(t){return Si()?t instanceof HTMLElement||t instanceof kt(t).HTMLElement:!1}function $d(t){return!Si()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof kt(t).ShadowRoot}function Ci(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=rn(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&s!=="inline"&&s!=="contents"}function $k(t){return/^(table|td|th)$/.test(ms(t))}function Ei(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const Uk=/transform|translate|scale|rotate|perspective|filter/,zk=/paint|layout|strict|content/,ir=t=>!!t&&t!=="none";let jc;function Cl(t){const e=nn(t)?rn(t):t;return ir(e.transform)||ir(e.translate)||ir(e.scale)||ir(e.rotate)||ir(e.perspective)||!El()&&(ir(e.backdropFilter)||ir(e.filter))||Uk.test(e.willChange||"")||zk.test(e.contain||"")}function Bk(t){let e=yr(t);for(;Gn(e)&&!Ws(e);){if(Cl(e))return e;if(Ei(e))return null;e=yr(e)}return null}function El(){return jc==null&&(jc=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),jc}function Ws(t){return/^(html|body|#document)$/.test(ms(t))}function rn(t){return kt(t).getComputedStyle(t)}function ki(t){return nn(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function yr(t){if(ms(t)==="html")return t;const e=t.assignedSlot||t.parentNode||$d(t)&&t.host||Rn(t);return $d(e)?e.host:e}function qp(t){const e=yr(t);return Ws(e)?(t.ownerDocument||t).body:Gn(e)&&Ci(e)?e:qp(e)}function Vs(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=qp(t),o=s===((r=t.ownerDocument)==null?void 0:r.body),i=kt(s);if(o){const c=pa(i);return e.concat(i,i.visualViewport||[],Ci(s)?s:[],c&&n?Vs(c):[])}else return e.concat(s,Vs(s,[],n))}function pa(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Kp(t){const e=rn(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=Gn(t),o=s?t.offsetWidth:n,i=s?t.offsetHeight:r,c=ei(n)!==o||ei(r)!==i;return c&&(n=o,r=i),{width:n,height:r,$:c}}function kl(t){return nn(t)?t:t.contextElement}function Zr(t){const e=kl(t);if(!Gn(e))return xn(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:o}=Kp(e);let i=(o?ei(n.width):n.width)/r,c=(o?ei(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Wk=xn(0);function Gp(t){const e=kt(t);return!El()||!e.visualViewport?Wk:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Vk(t,e,n){return e===void 0&&(e=!1),!!n&&e&&n===kt(t)}function wr(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),o=kl(t);let i=xn(1);e&&(r?nn(r)&&(i=Zr(r)):i=Zr(t));const c=Vk(o,n,r)?Gp(o):xn(0);let l=(s.left+c.x)/i.x,d=(s.top+c.y)/i.y,h=s.width/i.x,f=s.height/i.y;if(o&&r){const p=kt(o),g=nn(r)?kt(r):r;let m=p,b=pa(m);for(;b&&g!==m;){const S=Zr(b),C=b.getBoundingClientRect(),D=rn(b),y=C.left+(b.clientLeft+parseFloat(D.paddingLeft))*S.x,w=C.top+(b.clientTop+parseFloat(D.paddingTop))*S.y;l*=S.x,d*=S.y,h*=S.x,f*=S.y,l+=y,d+=w,m=kt(b),b=pa(m)}}return ni({width:h,height:f,x:l,y:d})}function Ri(t,e){const n=ki(t).scrollLeft;return e?e.left+n:wr(Rn(t)).left+n}function Jp(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Ri(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function Hk(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const o=s==="fixed",i=Rn(r),c=e?Ei(e.floating):!1;if(r===i||c&&o)return n;let l={scrollLeft:0,scrollTop:0},d=xn(1);const h=xn(0),f=Gn(r);if((f||!o)&&((ms(r)!=="body"||Ci(i))&&(l=ki(r)),f)){const g=wr(r);d=Zr(r),h.x=g.x+r.clientLeft,h.y=g.y+r.clientTop}const p=i&&!f&&!o?Jp(i,l):xn(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-l.scrollLeft*d.x+h.x+p.x,y:n.y*d.y-l.scrollTop*d.y+h.y+p.y}}function qk(t){return t.getClientRects?Array.from(t.getClientRects()):[]}function Kk(t){const e=ki(t),n=t.ownerDocument.body,r=bn(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=bn(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let o=-e.scrollLeft+Ri(t);const i=-e.scrollTop;return rn(n).direction==="rtl"&&(o+=bn(t.clientWidth,n.clientWidth)-r),{width:r,height:s,x:o,y:i}}const Gk=25;function Jk(t,e,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",s=kt(t),o=Rn(t),i=s.visualViewport;let c=o.clientWidth,l=o.clientHeight,d=0,h=0;if(i){const p=!El()||e==="fixed";r?p||(d=-i.offsetLeft,h=-i.offsetTop):(c=i.width,l=i.height,p&&(d=i.offsetLeft,h=i.offsetTop))}if(Ri(o)<=0){const p=o.ownerDocument,g=p.body,m=getComputedStyle(g),b=p.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,S=Math.abs(o.clientWidth-g.clientWidth-b),C=getComputedStyle(o).scrollbarGutter==="stable both-edges"?S/2:S;C<=Gk&&(c-=C)}return{width:c,height:l,x:d,y:h}}function Yk(t,e){const n=wr(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,o=Zr(t),i=t.clientWidth*o.x,c=t.clientHeight*o.y,l=s*o.x,d=r*o.y;return{width:i,height:c,x:l,y:d}}function Ud(t,e,n){let r;if(e==="viewport"||e==="layoutViewport")r=Jk(t,n,e);else if(e==="document")r=Kk(Rn(t));else if(nn(e))r=Yk(e,n);else{const s=Gp(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ni(r)}function Xk(t,e){const n=e.get(t);if(n)return n;let r=Vs(t,[],!1).filter(c=>nn(c)&&ms(c)!=="body"),s=null;const o=rn(t).position==="fixed";let i=o?yr(t):t;for(;nn(i)&&!Ws(i);){const c=rn(i),l=Cl(i),d=s?s.position:o?"fixed":"";!l&&(d==="fixed"||d==="absolute"&&c.position==="static")?r=r.filter(f=>f!==i):s=c,i=yr(i)}return e.set(t,r),r}function Zk(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const i=[...n==="clippingAncestors"?Ei(e)?[]:Xk(e,this._c):[].concat(n),r],c=Ud(e,i[0],s);let l=c.top,d=c.right,h=c.bottom,f=c.left;for(let p=1;p<i.length;p++){const g=Ud(e,i[p],s);l=bn(g.top,l),d=Vn(g.right,d),h=Vn(g.bottom,h),f=bn(g.left,f)}return{width:d-f,height:h-l,x:f,y:l}}function Qk(t){const{width:e,height:n}=Kp(t);return{width:e,height:n}}function e1(t,e,n){const r=Gn(e),s=Rn(e),o=n==="fixed",i=wr(t,!0,o,e);let c={scrollLeft:0,scrollTop:0};const l=xn(0);if((r||!o)&&((ms(e)!=="body"||Ci(s))&&(c=ki(e)),r)){const p=wr(e,!0,o,e);l.x=p.x+e.clientLeft,l.y=p.y+e.clientTop}!r&&s&&(l.x=Ri(s));const d=s&&!r&&!o?Jp(s,c):xn(0),h=i.left+c.scrollLeft-l.x-d.x,f=i.top+c.scrollTop-l.y-d.y;return{x:h,y:f,width:i.width,height:i.height}}function _c(t){return rn(t).position==="static"}function zd(t,e){if(!Gn(t)||rn(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Rn(t)===n&&(n=n.ownerDocument.body),n}function Yp(t,e){const n=kt(t);if(Ei(t))return n;if(!Gn(t)){let s=yr(t);for(;s&&!Ws(s);){if(nn(s)&&!_c(s))return s;s=yr(s)}return n}let r=zd(t,e);for(;r&&$k(r)&&_c(r);)r=zd(r,e);return r&&Ws(r)&&_c(r)&&!Cl(r)?n:r||Bk(t)||n}const t1=async function(t){const e=this.getOffsetParent||Yp,n=this.getDimensions,r=await n(t.floating);return{reference:e1(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function n1(t){return rn(t).direction==="rtl"}const r1={convertOffsetParentRelativeRectToViewportRelativeRect:Hk,getDocumentElement:Rn,getClippingRect:Zk,getOffsetParent:Yp,getElementRects:t1,getClientRects:qk,getDimensions:Qk,getScale:Zr,isElement:nn,isRTL:n1};function Xp(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function s1(t,e,n){let r=null,s;const o=Rn(t);function i(){var h;clearTimeout(s),(h=r)==null||h.disconnect(),r=null}function c(h,f){h===void 0&&(h=!1),f===void 0&&(f=1),i();const p=t.getBoundingClientRect(),{left:g,top:m,width:b,height:S}=p;if(h||e(),!b||!S)return;const C=Co(m),D=Co(o.clientWidth-(g+b)),y=Co(o.clientHeight-(m+S)),w=Co(g),v={rootMargin:-C+"px "+-D+"px "+-y+"px "+-w+"px",threshold:bn(0,Vn(1,f))||1};let R=!0;function A(N){const U=N[0].intersectionRatio;if(!Xp(p,t.getBoundingClientRect()))return c();if(U!==f){if(!R)return c();U?c(!1,U):s=setTimeout(()=>{c(!1,1e-7)},1e3)}R=!1}try{r=new IntersectionObserver(A,{...v,root:o.ownerDocument})}catch{r=new IntersectionObserver(A,v)}r.observe(t)}const l=kt(t),d=()=>c(n);return l.addEventListener("resize",d),c(!0),()=>{l.removeEventListener("resize",d),i()}}function o1(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,d=kl(t),h=s||o?[...d?Vs(d):[],...e?Vs(e):[]]:[];h.forEach(C=>{s&&C.addEventListener("scroll",n),o&&C.addEventListener("resize",n)});const f=d&&c?s1(d,n,o):null;let p=-1,g=null;i&&(g=new ResizeObserver(C=>{let[D]=C;D&&D.target===d&&g&&e&&(g.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var y;(y=g)==null||y.observe(e)})),n()}),d&&!l&&g.observe(d),e&&g.observe(e));let m,b=l?wr(t):null;l&&S();function S(){const C=wr(t);b&&!Xp(b,C)&&n(),b=C,m=requestAnimationFrame(S)}return n(),()=>{var C;h.forEach(D=>{s&&D.removeEventListener("scroll",n),o&&D.removeEventListener("resize",n)}),f?.(),(C=g)==null||C.disconnect(),g=null,l&&cancelAnimationFrame(m)}}const i1=Nk,c1=Mk,a1=Tk,l1=Ik,u1=Ok,Bd=Ak,d1=Fk,f1=(t,e,n)=>{const r=new Map,s=n??{},o={...r1,...s.platform,_c:r};return Pk(t,e,{...s,platform:o})};var h1=typeof document<"u",p1=function(){},Lo=h1?u.useLayoutEffect:p1;function ri(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!ri(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&t.$$typeof)&&!ri(t[o],e[o]))return!1}return!0}return t!==t&&e!==e}function Zp(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Wd(t,e){const n=Zp(t);return Math.round(e*n)/n}function Pc(t){const e=u.useRef(t);return Lo(()=>{e.current=t}),e}function m1(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:i}={},transform:c=!0,whileElementsMounted:l,open:d}=t,[h,f]=u.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[p,g]=u.useState(r);ri(p,r)||g(r);const[m,b]=u.useState(null),[S,C]=u.useState(null),D=u.useCallback(I=>{I!==v.current&&(v.current=I,b(I))},[]),y=u.useCallback(I=>{I!==R.current&&(R.current=I,C(I))},[]),w=o||m,k=i||S,v=u.useRef(null),R=u.useRef(null),A=u.useRef(h),N=l!=null,U=Pc(l),K=Pc(s),T=Pc(d),q=u.useCallback(()=>{if(!v.current||!R.current)return;const I={placement:e,strategy:n,middleware:p};K.current&&(I.platform=K.current),f1(v.current,R.current,I).then(V=>{const G={...V,isPositioned:T.current!==!1};B.current&&!ri(A.current,G)&&(A.current=G,qn.flushSync(()=>{f(G)}))})},[p,e,n,K,T]);Lo(()=>{d===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(I=>({...I,isPositioned:!1})))},[d]);const B=u.useRef(!1);Lo(()=>(B.current=!0,()=>{B.current=!1}),[]),Lo(()=>{if(w&&(v.current=w),k&&(R.current=k),w&&k){if(U.current)return U.current(w,k,q);q()}},[w,k,q,U,N]);const W=u.useMemo(()=>({reference:v,floating:R,setReference:D,setFloating:y}),[D,y]),z=u.useMemo(()=>({reference:w,floating:k}),[w,k]),Z=u.useMemo(()=>{const I={position:n,left:0,top:0};if(!z.floating)return I;const V=Wd(z.floating,h.x),G=Wd(z.floating,h.y);return c?{...I,transform:"translate("+V+"px, "+G+"px)",...Zp(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:G}},[n,c,z.floating,h.x,h.y]);return u.useMemo(()=>({...h,update:q,refs:W,elements:z,floatingStyles:Z}),[h,q,W,z,Z])}const g1=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:s}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Bd({element:r.current,padding:s}).fn(n):{}:r?Bd({element:r,padding:s}).fn(n):{}}}},y1=(t,e)=>{const n=i1(t);return{name:n.name,fn:n.fn,options:[t,e]}},w1=(t,e)=>{const n=c1(t);return{name:n.name,fn:n.fn,options:[t,e]}},b1=(t,e)=>({fn:d1(t).fn,options:[t,e]}),x1=(t,e)=>{const n=a1(t);return{name:n.name,fn:n.fn,options:[t,e]}},v1=(t,e)=>{const n=l1(t);return{name:n.name,fn:n.fn,options:[t,e]}},S1=(t,e)=>{const n=u1(t);return{name:n.name,fn:n.fn,options:[t,e]}},C1=(t,e)=>{const n=g1(t);return{name:n.name,fn:n.fn,options:[t,e]}};var E1=Object.defineProperty,$t=(t,e)=>E1(t,"name",{value:e,configurable:!0});function Qp(t){const e=u.forwardRef((n,r)=>{let{children:s,...o}=n,i=null,c=!1;const l=[];ma(s)&&typeof Eo=="function"&&(s=Eo(s._payload)),u.Children.forEach(s,p=>{if(rm(p)){c=!0;const g=p;let m="child"in g.props?g.props.child:g.props.children;ma(m)&&typeof Eo=="function"&&(m=Eo(m._payload)),i=R1(g,m),l.push(i?.props?.children)}else l.push(p)}),i?i=u.cloneElement(i,void 0,l):!c&&u.Children.count(s)===1&&u.isValidElement(s)&&(i=s);const d=i?nm(i):void 0,h=ze(r,d);if(!i){if(s||s===0)throw new Error(c?_1(t):j1(t));return s}const f=tm(o,i.props??{});return i.type!==u.Fragment&&(f.ref=r?h:d),u.cloneElement(i,f)});return e.displayName=`${t}.Slot`,e}$t(Qp,"createSlot");var em=Symbol.for("radix.slottable");function k1(t){const e=$t(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=em,e}$t(k1,"createSlottable");var R1=$t((t,e)=>{if("child"in t.props){const n=t.props.child;return u.isValidElement(n)?u.cloneElement(n,void 0,t.props.children(n.props.children)):null}return u.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function tm(t,e){const n={...e};for(const r in e){const s=t[r],o=e[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...c)=>{const l=o(...c);return s(...c),l}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"?n[r]=[s,o].filter(Boolean).join(" "):r==="aria-describedby"&&(n[r]=om(o,s))}return{...t,...n}}$t(tm,"mergeProps");function nm(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}$t(nm,"getElementRef");function rm(t){return u.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===em}$t(rm,"isSlottable");var D1=Symbol.for("react.lazy");function ma(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===D1&&"_payload"in t&&sm(t._payload)}$t(ma,"isLazyComponent");function sm(t){return typeof t=="object"&&t!==null&&"then"in t}$t(sm,"isPromiseLike");function om(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const r of String(n).trim().split(/\s+/))r&&e.add(r);return e.size>0?Array.from(e).join(" "):void 0}$t(om,"concatAriaDescribedby");var j1=$t(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),_1=$t(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Eo=xr[" use ".trim().toString()],P1=Object.defineProperty,A1=(t,e)=>P1(t,"name",{value:e,configurable:!0}),T1=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],im=T1.reduce((t,e)=>{const n=Qp(`Primitive.${e}`),r=u.forwardRef((s,o)=>{const{asChild:i,...c}=s,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(l,{...c,ref:o})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function O1(t,e){t&&qn.flushSync(()=>t.dispatchEvent(e))}A1(O1,"dispatchDiscreteCustomEvent");var L1=Object.defineProperty,N1=(t,e)=>L1(t,"name",{value:e,configurable:!0});function cm(t){const[e,n]=u.useState(void 0);return Lt(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});let r=0;const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];window.cancelAnimationFrame(r),r=window.requestAnimationFrame(()=>{let c,l;if("borderBoxSize"in i){const d=i.borderBoxSize,h=Array.isArray(d)?d[0]:d;c=h.inlineSize,l=h.blockSize}else c=t.offsetWidth,l=t.offsetHeight;n({width:c,height:l})})});return s.observe(t,{box:"border-box"}),()=>{window.cancelAnimationFrame(r),s.unobserve(t)}}else n(void 0)},[t]),e}N1(cm,"useSize");var M1=Object.defineProperty,$n=(t,e)=>M1(t,"name",{value:e,configurable:!0}),Vd={Partial:"partial"},Hd={Optimized:"optimized",Always:"always"},am="Popper",[lm,Di]=br(am),[F1,um]=lm(am),dm=$n(t=>{const{__scopePopper:e,children:n}=t,[r,s]=u.useState(null),[o,i]=u.useState(void 0);return a.jsx(F1,{scope:e,anchor:r,onAnchorChange:s,placementState:o,setPlacementState:i,children:n})},"Popper"),I1="PopperAnchor",fm=u.forwardRef($n(function(e,n){const{__scopePopper:r,virtualRef:s,...o}=e,i=um(I1,r),c=u.useRef(null),l=i.onAnchorChange,d=u.useCallback(b=>{c.current=b,b&&l(b)},[l]),h=ze(n,d),f=u.useRef(null);u.useEffect(()=>{if(!s)return;const b=f.current;f.current=s.current,b!==f.current&&l(f.current)});const p=i.placementState&&ji(i.placementState),g=p?.[0],m=p?.[1];return s?null:a.jsx(im.div,{"data-radix-popper-side":g,"data-radix-popper-align":m,...o,ref:h})},"PopperAnchor")),hm="PopperContent",[$1,dj]=lm(hm),pm=u.forwardRef($n(function(e,n){const{__scopePopper:r,side:s="bottom",sideOffset:o=0,align:i="center",alignOffset:c=0,arrowPadding:l=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:p=Vd.Partial,hideWhenDetached:g=!1,updatePositionStrategy:m=Hd.Optimized,onPlaced:b,...S}=e,C=um(hm,r),[D,y]=u.useState(null),w=ze(n,y),[k,v]=u.useState(null),R=cm(k),A=R?.width??0,N=R?.height??0,U=s+(i!=="center"?"-"+i:""),K=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},T=Array.isArray(h)?h:[h],q=T.length>0,B={padding:K,boundary:T.filter(mm),altBoundary:q},{refs:W,floatingStyles:z,placement:Z,isPositioned:I,middlewareData:V}=m1({strategy:"fixed",placement:U,whileElementsMounted:$n((...Re)=>o1(...Re,{animationFrame:m===Hd.Always}),"whileElementsMounted"),elements:{reference:C.anchor},middleware:[y1({mainAxis:o+N,alignmentAxis:c}),d&&w1({mainAxis:!0,crossAxis:!1,limiter:p===Vd.Partial?b1():void 0,...B}),d&&x1({...B}),v1({...B,apply:$n(({elements:Re,rects:re,availableWidth:we,availableHeight:Ee})=>{const{width:J,height:ce}=re.reference,L=Re.floating.style;L.setProperty("--radix-popper-available-width",`${we}px`),L.setProperty("--radix-popper-available-height",`${Ee}px`),L.setProperty("--radix-popper-anchor-width",`${J}px`),L.setProperty("--radix-popper-anchor-height",`${ce}px`)},"apply")}),k&&C1({element:k,padding:l}),U1({arrowWidth:A,arrowHeight:N}),g&&S1({strategy:"referenceHidden",...B,boundary:q?B.boundary:void 0})]}),G=C.setPlacementState;Lt(()=>(G(Z),()=>{G(void 0)}),[Z,G]);const[Q,Ce]=ji(Z),te=_t(b);Lt(()=>{I&&te?.()},[I,te]);const ue=V.arrow?.x,ke=V.arrow?.y,j=V.arrow?.centerOffset!==0,[Y,le]=u.useState();return Lt(()=>{D&&le(window.getComputedStyle(D).zIndex)},[D]),a.jsx("div",{ref:W.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:I?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[V.transformOrigin?.x,V.transformOrigin?.y].join(" "),...V.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:a.jsx($1,{scope:r,placedSide:Q,placedAlign:Ce,onArrowChange:v,arrowX:ue,arrowY:ke,shouldHideArrow:j,children:a.jsx(im.div,{"data-side":Q,"data-align":Ce,...S,ref:w,style:{...S.style,animation:I?S.style?.animation:"none"}})})})},"PopperContent"));function mm(t){return t!==null}$n(mm,"isNotNull");var U1=$n(t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:s}=e,i=s.arrow?.centerOffset!==0,c=i?0:t.arrowWidth,l=i?0:t.arrowHeight,[d,h]=ji(n),f={start:"0%",center:"50%",end:"100%"}[h],p=(s.arrow?.x??0)+c/2,g=(s.arrow?.y??0)+l/2;let m="",b="";return d==="bottom"?(m=i?f:`${p}px`,b=`${-l}px`):d==="top"?(m=i?f:`${p}px`,b=`${r.floating.height+l}px`):d==="right"?(m=`${-l}px`,b=i?f:`${g}px`):d==="left"&&(m=`${r.floating.width+l}px`,b=i?f:`${g}px`),{data:{x:m,y:b}}}}),"transformOrigin");function ji(t){const[e,n="center"]=t.split("-");return[e,n]}$n(ji,"getSideAndAlignFromPlacement");var z1=Object.defineProperty,B1=(t,e)=>z1(t,"name",{value:e,configurable:!0}),W1=u.forwardRef(B1(function(e,n){const{container:r,...s}=e,[o,i]=u.useState(!1);Lt(()=>i(!0),[]);const c=r||o&&globalThis?.document?.body;return c?qn.createPortal(a.jsx(vi.div,{...s,ref:n}),c):null},"Portal")),V1=Object.defineProperty,Cn=(t,e)=>V1(t,"name",{value:e,configurable:!0});function gm(t,e){return u.useReducer((n,r)=>e[n][r]??n,t)}Cn(gm,"useStateMachine");var ym=Cn(t=>{const{present:e,children:n}=t,r=wm(e),s=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),o=bm(r.ref,xm(s));return typeof n=="function"||r.isPresent?u.cloneElement(s,{ref:o}):null},"Presence");function wm(t){const[e,n]=u.useState(),r=u.useRef(null),s=u.useRef(t),o=u.useRef("none"),i=u.useRef(void 0),c=t?"mounted":"unmounted",[l,d]=gm(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{l==="mounted"?(o.current=i.current??$r(r.current),i.current=void 0):o.current="none"},[l]),Lt(()=>{const h=r.current,f=s.current;if(f!==t){const g=o.current,m=$r(h);t?(i.current=m,d("MOUNT")):m==="none"||h?.display==="none"?d("UNMOUNT"):d(f&&g!==m?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,d]),Lt(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,p=Cn(m=>{const S=$r(r.current).includes(CSS.escape(m.animationName));if(m.target===e&&S&&(d("ANIMATION_END"),!s.current)){const C=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=C)})}},"handleAnimationEnd"),g=Cn(m=>{m.target===e&&(o.current=$r(r.current))},"handleAnimationStart");return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",p),e.addEventListener("animationend",p),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",p),e.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[e,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(h=>{if(h){const f=getComputedStyle(h);r.current=f,i.current=$r(f)}else r.current=null;n(h)},[])}}Cn(wm,"usePresence");function ga(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Cn(ga,"setRef");function bm(...t){const e=u.useRef(t);return e.current=t,u.useCallback(n=>{const r=e.current;let s=!1;const o=r.map(i=>{const c=ga(i,n);return!s&&typeof c=="function"&&(s=!0),c});if(s)return()=>{for(let i=0;i<o.length;i++){const c=o[i];typeof c=="function"?c():ga(r[i],null)}}},[])}Cn(bm,"useStableComposedRefs");function $r(t){return t?.animationName||"none"}Cn($r,"getAnimationName");function xm(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}Cn(xm,"getElementRef");var H1=Object.defineProperty,Ut=(t,e)=>H1(t,"name",{value:e,configurable:!0});function vm(t){const e=u.forwardRef((n,r)=>{let{children:s,...o}=n,i=null,c=!1;const l=[];ya(s)&&typeof ko=="function"&&(s=ko(s._payload)),u.Children.forEach(s,p=>{if(km(p)){c=!0;const g=p;let m="child"in g.props?g.props.child:g.props.children;ya(m)&&typeof ko=="function"&&(m=ko(m._payload)),i=K1(g,m),l.push(i?.props?.children)}else l.push(p)}),i?i=u.cloneElement(i,void 0,l):!c&&u.Children.count(s)===1&&u.isValidElement(s)&&(i=s);const d=i?Em(i):void 0,h=ze(r,d);if(!i){if(s||s===0)throw new Error(c?Y1(t):J1(t));return s}const f=Cm(o,i.props??{});return i.type!==u.Fragment&&(f.ref=r?h:d),u.cloneElement(i,f)});return e.displayName=`${t}.Slot`,e}Ut(vm,"createSlot");var Sm=Symbol.for("radix.slottable");function q1(t){const e=Ut(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=Sm,e}Ut(q1,"createSlottable");var K1=Ut((t,e)=>{if("child"in t.props){const n=t.props.child;return u.isValidElement(n)?u.cloneElement(n,void 0,t.props.children(n.props.children)):null}return u.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function Cm(t,e){const n={...e};for(const r in e){const s=t[r],o=e[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...c)=>{const l=o(...c);return s(...c),l}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"?n[r]=[s,o].filter(Boolean).join(" "):r==="aria-describedby"&&(n[r]=Dm(o,s))}return{...t,...n}}Ut(Cm,"mergeProps");function Em(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}Ut(Em,"getElementRef");function km(t){return u.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Sm}Ut(km,"isSlottable");var G1=Symbol.for("react.lazy");function ya(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===G1&&"_payload"in t&&Rm(t._payload)}Ut(ya,"isLazyComponent");function Rm(t){return typeof t=="object"&&t!==null&&"then"in t}Ut(Rm,"isPromiseLike");function Dm(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const r of String(n).trim().split(/\s+/))r&&e.add(r);return e.size>0?Array.from(e).join(" "):void 0}Ut(Dm,"concatAriaDescribedby");var J1=Ut(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),Y1=Ut(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),ko=xr[" use ".trim().toString()],X1=Object.defineProperty,Z1=(t,e)=>X1(t,"name",{value:e,configurable:!0}),Q1=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],jm=Q1.reduce((t,e)=>{const n=vm(`Primitive.${e}`),r=u.forwardRef((s,o)=>{const{asChild:i,...c}=s,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(l,{...c,ref:o})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function eR(t,e){t&&qn.flushSync(()=>t.dispatchEvent(e))}Z1(eR,"dispatchDiscreteCustomEvent");var tR=Object.defineProperty,Rl=(t,e)=>tR(t,"name",{value:e,configurable:!0}),Ac=!1;function _m(){const[t,e]=u.useState(Ac);return u.useEffect(()=>{Ac||(Ac=!0,e(!0))},[]),t}Rl(_m,"useIsHydrated");var Pm=xr[" useSyncExternalStore ".trim().toString()];function Am(){return()=>{}}Rl(Am,"subscribe");function Tm(){return Pm(Am,()=>!0,()=>!1)}Rl(Tm,"useIsHydratedModern");var nR=typeof Pm=="function"?Tm:_m,rR=Object.defineProperty,kr=(t,e)=>rR(t,"name",{value:e,configurable:!0}),Tc="rovingFocusGroup.onEntryFocus",sR={bubbles:!1,cancelable:!0},_i="RovingFocusGroup",[wa,Om,oR]=hl(_i),[iR,Lm]=br(_i,[oR]),qd={Vertical:"vertical",Horizontal:"horizontal"},cR={RTL:"rtl"},[aR,lR]=iR(_i),uR=u.forwardRef(kr(function(e,n){return a.jsx(wa.Provider,{scope:e.__scopeRovingFocusGroup,children:a.jsx(wa.Slot,{scope:e.__scopeRovingFocusGroup,children:a.jsx(dR,{...e,ref:n})})})},"RovingFocusGroup")),dR=u.forwardRef(kr(function(e,n){const{__scopeRovingFocusGroup:r,orientation:s,loop:o=!1,dir:i,currentTabStopId:c,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:d,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...p}=e,g=u.useRef(null),m=ze(n,g),b=ml(i),[S,C]=Da({prop:c,defaultProp:l??null,onChange:d,caller:_i}),[D,y]=u.useState(!1),w=_t(h),k=Om(r),v=u.useRef(!1),[R,A]=u.useState(0);return u.useEffect(()=>{const N=g.current;if(N)return N.addEventListener(Tc,w),()=>N.removeEventListener(Tc,w)},[w]),a.jsx(aR,{scope:r,orientation:s,dir:b,loop:o,currentTabStopId:S,onItemFocus:u.useCallback(N=>C(N),[C]),onItemShiftTab:u.useCallback(()=>y(!0),[]),onFocusableItemAdd:u.useCallback(()=>A(N=>N+1),[]),onFocusableItemRemove:u.useCallback(()=>A(N=>N-1),[]),children:a.jsx(jm.div,{tabIndex:D||R===0?-1:0,"data-orientation":s,...p,ref:m,style:{outline:"none",...e.style},onMouseDown:Te(e.onMouseDown,()=>{v.current=!0}),onFocus:Te(e.onFocus,N=>{const U=!v.current;if(N.target===N.currentTarget&&U&&!D){const K=new CustomEvent(Tc,sR);if(N.currentTarget.dispatchEvent(K),!K.defaultPrevented){const T=k().filter(Z=>Z.focusable),q=T.find(Z=>Z.active),B=T.find(Z=>Z.id===S),z=[q,B,...T].filter(Boolean).map(Z=>Z.ref.current);Dl(z,f)}}v.current=!1}),onBlur:Te(e.onBlur,()=>y(!1))})})},"RovingFocusGroupImpl")),fR="RovingFocusGroupItem",hR=u.forwardRef(kr(function(e,n){const{__scopeRovingFocusGroup:r,focusable:s=!0,active:o=!1,tabStopId:i,children:c,...l}=e,d=Br(),h=i||d,f=lR(fR,r),p=f.currentTabStopId===h,g=Om(r),{onFocusableItemAdd:m,onFocusableItemRemove:b,currentTabStopId:S}=f,C=nR();return Lt(()=>{if(!(!C||!s))return m(),()=>b()},[C,s,m,b]),u.useEffect(()=>{if(!(C||!s))return m(),()=>b()},[C,s,m,b]),a.jsx(wa.ItemSlot,{scope:r,id:h,focusable:s,active:o,children:a.jsx(jm.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...l,ref:n,onMouseDown:Te(e.onMouseDown,D=>{s?f.onItemFocus(h):D.preventDefault()}),onFocus:Te(e.onFocus,()=>f.onItemFocus(h)),onKeyDown:Te(e.onKeyDown,D=>{if(D.key==="Tab"&&D.shiftKey){f.onItemShiftTab();return}if(D.target!==D.currentTarget)return;const y=Mm(D,f.orientation,f.dir);if(y!==void 0){if(D.metaKey||D.ctrlKey||D.altKey||D.shiftKey)return;D.preventDefault();let k=g().filter(v=>v.focusable).map(v=>v.ref.current);if(y==="last")k.reverse();else if(y==="prev"||y==="next"){y==="prev"&&k.reverse();const v=k.indexOf(D.currentTarget);k=f.loop?Fm(k,v+1):k.slice(v+1)}setTimeout(()=>Dl(k))}}),children:typeof c=="function"?c({isCurrentTabStop:p,hasTabStop:S!=null}):c})})},"RovingFocusGroupItem")),pR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Nm(t,e){return e!==cR.RTL?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}kr(Nm,"getDirectionAwareKey");function Mm(t,e,n){const r=Nm(t.key,n);if(!(e===qd.Vertical&&["ArrowLeft","ArrowRight"].includes(r))&&!(e===qd.Horizontal&&["ArrowUp","ArrowDown"].includes(r)))return pR[r]}kr(Mm,"getFocusIntent");function Dl(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}kr(Dl,"focusFirst");function Fm(t,e){return t.map((n,r)=>t[(e+r)%t.length])}kr(Fm,"wrapArray");var mR=Object.defineProperty,We=(t,e)=>mR(t,"name",{value:e,configurable:!0}),gR=["Enter"," "],yR=["ArrowDown","PageUp","Home"],Im=["ArrowUp","PageDown","End"],wR=[...yR,...Im],Pi="Menu",[ba,bR,xR]=hl(Pi),[Rr,$m]=br(Pi,[xR,Di,Lm]),jl=Di(),Um=Lm(),[vR,eo]=Rr(Pi),[SR,_l]=Rr(Pi),CR=We(t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:s,onOpenChange:o,modal:i=!0}=t,c=jl(e),[l,d]=u.useState(null),h=u.useRef(!1),f=_t(o),p=ml(s);return u.useEffect(()=>{const g=We(()=>{h.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},"handleKeyDown"),m=We(()=>h.current=!1,"handlePointer");return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),u.useEffect(()=>{if(!n)return;const g=We(()=>f(!1),"handleBlur");return window.addEventListener("blur",g),()=>window.removeEventListener("blur",g)},[n,f]),a.jsx(dm,{...c,children:a.jsx(vR,{scope:e,open:n,onOpenChange:f,content:l,onContentChange:d,children:a.jsx(SR,{scope:e,onClose:u.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:h,dir:p,modal:i,children:r})})})},"Menu"),ER=u.forwardRef(We(function(e,n){const{__scopeMenu:r,...s}=e,o=jl(r);return a.jsx(fm,{...o,...s,ref:n})},"MenuAnchor")),zm="MenuPortal",[kR,RR]=Rr(zm,{forceMount:void 0}),DR=We(t=>{const{__scopeMenu:e,forceMount:n,children:r,container:s}=t,o=eo(zm,e);return a.jsx(kR,{scope:e,forceMount:n,children:a.jsx(ym,{present:n||o.open,children:a.jsx(W1,{asChild:!0,container:s,children:r})})})},"MenuPortal"),Un="MenuContent",[jR,Bm]=Rr(Un),_R=u.forwardRef(We(function(e,n){const r=RR(Un,e.__scopeMenu),{forceMount:s=r.forceMount,...o}=e,i=eo(Un,e.__scopeMenu),c=_l(Un,e.__scopeMenu);return a.jsx(ba.Provider,{scope:e.__scopeMenu,children:a.jsx(ym,{present:s||i.open,children:a.jsx(ba.Slot,{scope:e.__scopeMenu,children:c.modal?a.jsx(PR,{...o,ref:n}):a.jsx(AR,{...o,ref:n})})})})},"MenuContent")),PR=u.forwardRef(We(function(e,n){const r=eo(Un,e.__scopeMenu),s=u.useRef(null),o=ze(n,s);return u.useEffect(()=>{const i=s.current;if(i)return rf(i)},[]),a.jsx(Wm,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Te(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),AR=u.forwardRef(We(function(e,n){const r=eo(Un,e.__scopeMenu);return a.jsx(Wm,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),TR=gl("MenuContent.ScrollLock"),Wm=u.forwardRef(We(function(e,n){const{__scopeMenu:r,loop:s=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:c,disableOutsidePointerEvents:l,onEntryFocus:d,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:g,onDismiss:m,disableOutsideScroll:b,...S}=e,C=eo(Un,r),D=_l(Un,r),y=jl(r),w=Um(r),k=bR(r),[v,R]=u.useState(null),A=u.useRef(null),[N,U]=u.useState(null);Np(N);const{nodes:K,registry:T}=Lp(),q=!!(o||b),B=ze(n,A,C.onContentChange,U),W=u.useRef(0),z=u.useRef(""),Z=u.useRef(0),I=u.useRef(null),V=u.useRef("right"),G=u.useRef(0),Q=u.useMemo(()=>b?[A,...K.map(j=>({current:j}))]:[],[A,K,b]),Ce=b?cf:u.Fragment,te=b?{as:TR,allowPinchZoom:!0,shards:Q}:void 0,ue=We(j=>{const Y=z.current+j,le=k().filter(ce=>!ce.disabled),Re=document.activeElement,re=le.find(ce=>ce.ref.current===Re)?.textValue,we=le.map(ce=>ce.textValue),Ee=Gm(we,Y,re),J=le.find(ce=>ce.textValue===Ee)?.ref.current;We((function ce(L){z.current=L,window.clearTimeout(W.current),L!==""&&(W.current=window.setTimeout(()=>ce(""),1e3))}),"updateSearch")(Y),J&&setTimeout(()=>J.focus())},"handleTypeaheadSearch");u.useEffect(()=>()=>window.clearTimeout(W.current),[]),sf();const ke=u.useCallback(j=>V.current===I.current?.side&&Ym(j,I.current?.area),[]);return a.jsx(jR,{scope:r,searchRef:z,onItemEnter:u.useCallback(j=>{ke(j)&&j.preventDefault()},[ke]),onItemLeave:u.useCallback(j=>{ke(j)||(A.current?.focus(),R(null))},[ke]),onTriggerLeave:u.useCallback(j=>{ke(j)&&j.preventDefault()},[ke]),pointerGraceTimerRef:Z,onPointerGraceIntentChange:u.useCallback(j=>{I.current=j},[]),children:a.jsx(Op,{registry:q?T:null,children:a.jsx(Ce,{...te,children:a.jsx(wk,{asChild:!0,trapped:o,branches:K,onMountAutoFocus:Te(i,j=>{j.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:a.jsx(pk,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:g,onDismiss:m,children:a.jsx(uR,{asChild:!0,...w,dir:D.dir,orientation:"vertical",loop:s,currentTabStopId:v,onCurrentTabStopIdChange:R,onEntryFocus:Te(d,j=>{D.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:a.jsx(pm,{role:"menu","aria-orientation":"vertical","data-state":Vm(C.open),"data-radix-menu-content":"",dir:D.dir,...y,...S,ref:B,style:{outline:"none",...S.style},onKeyDown:Te(S.onKeyDown,j=>{const le=j.target.closest("[data-radix-menu-content]")===j.currentTarget,Re=j.ctrlKey||j.altKey||j.metaKey,re=j.key.length===1;le&&(j.key==="Tab"&&j.preventDefault(),!Re&&re&&ue(j.key));const we=A.current;if(j.target!==we||!wR.includes(j.key))return;j.preventDefault();const J=k().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);Im.includes(j.key)&&J.reverse(),qm(J)}),onBlur:Te(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(W.current),z.current="")}),onPointerMove:Te(e.onPointerMove,si(j=>{const Y=j.target,le=G.current!==j.clientX;if(j.currentTarget.contains(Y)&&le){const Re=j.clientX>G.current?"right":"left";V.current=Re,G.current=j.clientX}}))})})})})})})})},"MenuContentImpl")),xa="MenuItem",Kd="menu.itemSelect",OR=u.forwardRef(We(function(e,n){const{disabled:r=!1,onSelect:s,...o}=e,i=u.useRef(null),c=_l(xa,e.__scopeMenu),l=Bm(xa,e.__scopeMenu),d=ze(n,i),h=u.useRef(!1),f=We(()=>{const p=i.current;if(!r&&p){const g=new CustomEvent(Kd,{bubbles:!0,cancelable:!0});p.addEventListener(Kd,m=>s?.(m),{once:!0}),yl(p,g),g.defaultPrevented?h.current=!1:c.onClose()}},"handleSelect");return a.jsx(LR,{...o,ref:d,disabled:r,onClick:Te(e.onClick,f),onPointerDown:p=>{e.onPointerDown?.(p),h.current=!0},onPointerUp:Te(e.onPointerUp,p=>{h.current||p.currentTarget?.click()}),onKeyDown:Te(e.onKeyDown,p=>{r||p.target!==p.currentTarget||l.searchRef.current!==""&&p.key===" "||gR.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})},"MenuItem")),LR=u.forwardRef(We(function(e,n){const{__scopeMenu:r,disabled:s=!1,textValue:o,...i}=e,c=Bm(xa,r),l=Um(r),d=u.useRef(null),h=ze(n,d),[f,p]=u.useState(!1),[g,m]=u.useState("");return u.useEffect(()=>{const b=d.current;b&&m((b.textContent??"").trim())},[i.children]),a.jsx(ba.ItemSlot,{scope:r,disabled:s,textValue:o??g,children:a.jsx(hR,{asChild:!0,...l,focusable:!s,children:a.jsx(vi.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...i,ref:h,onPointerMove:Te(e.onPointerMove,si(b=>{s?c.onItemLeave(b):(c.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Te(e.onPointerLeave,si(b=>c.onItemLeave(b))),onFocus:Te(e.onFocus,()=>p(!0)),onBlur:Te(e.onBlur,()=>p(!1))})})})},"MenuItemImpl")),NR="MenuRadioGroup",[fj,hj]=Rr(NR,{value:void 0,onValueChange:We(()=>{},"onValueChange")}),MR="MenuItemIndicator",[pj,mj]=Rr(MR,{checked:!1}),FR="MenuSub",[gj,yj]=Rr(FR);function Vm(t){return t?"open":"closed"}We(Vm,"getOpenState");function Hm(t){return t==="indeterminate"}We(Hm,"isIndeterminate");function IR(t){return Hm(t)?"indeterminate":t?"checked":"unchecked"}We(IR,"getCheckedState");function qm(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}We(qm,"focusFirst");function Km(t,e){return t.map((n,r)=>t[(e+r)%t.length])}We(Km,"wrapArray");function Gm(t,e,n){const s=e.length>1&&Array.from(e).every(d=>d===e[0])?e[0]:e,o=n?t.indexOf(n):-1;let i=Km(t,Math.max(o,0));s.length===1&&(i=i.filter(d=>d!==n));const l=i.find(d=>d.toLowerCase().startsWith(s.toLowerCase()));return l!==n?l:void 0}We(Gm,"getNextMatch");function Jm(t,e){const{x:n,y:r}=t;let s=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){const c=e[o],l=e[i],d=c.x,h=c.y,f=l.x,p=l.y;h>r!=p>r&&n<(f-d)*(r-h)/(p-h)+d&&(s=!s)}return s}We(Jm,"isPointInPolygon");function Ym(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return Jm(n,e)}We(Ym,"isPointerInGraceArea");function si(t){return e=>e.pointerType==="mouse"?t(e):void 0}We(si,"whenMouse");var $R=Object.defineProperty,to=(t,e)=>$R(t,"name",{value:e,configurable:!0}),Pl="DropdownMenu",[UR,wj]=br(Pl,[$m]),no=$m(),[zR,Xm]=UR(Pl),BR=to(t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:s,defaultOpen:o,onOpenChange:i,modal:c=!0}=t,l=no(e),d=u.useRef(null),[h,f]=Da({prop:s,defaultProp:o??!1,onChange:i,caller:Pl});return a.jsx(zR,{scope:e,triggerId:Br(),triggerRef:d,contentId:Br(),open:h,onOpenChange:f,onOpenToggle:u.useCallback(()=>f(p=>!p),[f]),modal:c,children:a.jsx(CR,{...l,open:h,onOpenChange:f,dir:r,modal:c,children:n})})},"DropdownMenu"),WR="DropdownMenuTrigger",VR=u.forwardRef(to(function(e,n){const{__scopeDropdownMenu:r,disabled:s=!1,...o}=e,i=Xm(WR,r),c=no(r),l=ze(n,i.triggerRef);return a.jsx(ER,{asChild:!0,...c,children:a.jsx(BE.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...o,ref:l,onPointerDown:Te(e.onPointerDown,d=>{!s&&d.button===0&&d.ctrlKey===!1&&(i.onOpenToggle(),i.open||d.preventDefault())}),onKeyDown:Te(e.onKeyDown,d=>{s||(["Enter"," "].includes(d.key)&&i.onOpenToggle(),d.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(d.key)&&d.preventDefault())})})})},"DropdownMenuTrigger")),HR=to(t=>{const{__scopeDropdownMenu:e,...n}=t,r=no(e);return a.jsx(DR,{...r,...n})},"DropdownMenuPortal"),qR="DropdownMenuContent",KR=u.forwardRef(to(function(e,n){const{__scopeDropdownMenu:r,...s}=e,o=Xm(qR,r),i=no(r),c=u.useRef(!1);return a.jsx(_R,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...s,ref:n,onCloseAutoFocus:Te(e.onCloseAutoFocus,l=>{c.current||o.triggerRef.current?.focus(),c.current=!1,l.preventDefault()}),onInteractOutside:Te(e.onInteractOutside,l=>{const d=l.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0,f=d.button===2||h;(!o.modal||f)&&(c.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),Gd=u.forwardRef(to(function(e,n){const{__scopeDropdownMenu:r,...s}=e,o=no(r);return a.jsx(OR,{...o,...s,ref:n})},"DropdownMenuItem"));function Jd({kind:t,onEdit:e,onDelete:n}){const{t:r}=tt(),s=u.useRef(!1);return a.jsx("span",{className:"comment-actions-menu",onClick:o=>o.stopPropagation(),children:a.jsxs(BR,{modal:!1,children:[a.jsx(VR,{asChild:!0,children:a.jsx("button",{type:"button",className:"comment-actions-menu-trigger","aria-label":r(t==="comment"?"editor.commentActions":"editor.replyActions"),children:a.jsx(Ww,{size:16,"aria-hidden":!0})})}),a.jsx(HR,{children:a.jsxs(KR,{className:"comment-actions-menu-content",align:"end",sideOffset:4,collisionPadding:8,onCloseAutoFocus:o=>{s.current&&o.preventDefault(),s.current=!1},children:[a.jsxs(Gd,{onSelect:()=>{s.current=!0,e()},children:[a.jsx(Vw,{size:13,"aria-hidden":!0}),r(t==="comment"?"editor.editComment":"editor.editReply")]}),a.jsxs(Gd,{className:"danger-text",onSelect:()=>{s.current=!0,n()},children:[a.jsx(fr,{size:13,"aria-hidden":!0}),r(t==="comment"?"editor.deleteComment":"editor.deleteReply")]})]})})]})})}function Oc(t,e){!(t.ctrlKey||t.metaKey)||t.key!=="Enter"||t.nativeEvent.isComposing||(t.preventDefault(),t.stopPropagation(),e())}function Yd(t){const e=/(^|\s)(@[\p{L}\p{N}_.-]+)/gu,n=[];let r=0;for(const s of t.matchAll(e)){const o=s.index??0,i=s[1],c=s[2],l=o+i.length;l>r&&n.push(t.slice(r,l)),n.push(a.jsx("span",{className:"comment-inline-mention",children:c},`${l}:${c}`)),r=l+c.length}return n.length?(r<t.length&&n.push(t.slice(r)),n):t}function GR({projectId:t,comment:e,currentUserId:n,unreadCommentMentionId:r,unreadReplyMentionIds:s,highlightedComment:o,highlightedReplyId:i,currentComment:c,showFilePath:l,onMarkMentionRead:d,onFocus:h,onToggle:f,onReply:p,onEdit:g,onDelete:m,onEditReply:b,onDeleteReply:S,selectedParticipantIds:C,highlightReplyParticipants:D}){const{t:y}=tt(),[w,k]=u.useState(!1),[v,R]=u.useState(""),[A,N]=u.useState(!1),[U,K]=u.useState(e.content),[T,q]=u.useState(!1),[B,W]=u.useState(null),[z,Z]=u.useState(""),[I,V]=u.useState(null),G=async j=>{j?.preventDefault(),v.trim()&&await p(v)&&(R(""),k(!1))},Q=async j=>{j?.preventDefault(),U.trim()&&await g(U)&&N(!1)},Ce=async j=>{j?.preventDefault(),!(!B||!z.trim())&&await b(B,z)&&W(null)},te=e.authorUsername,ue=j=>new Date(j).toLocaleString(Rs.resolvedLanguage),ke=async(j,Y)=>{Y.stopPropagation(),await d(j)};return a.jsxs(a.Fragment,{children:[a.jsxs("article",{"data-comment-id":e.id,className:`comment-thread${e.resolved?" resolved":""}${e.orphaned?" orphaned":""}${o?" mention-target":""}${c?" review-current":""}`,onClick:()=>{window.getSelection()?.toString()||h()},children:[a.jsxs("header",{className:"comment-header",children:[a.jsxs("span",{className:`comment-author${C?.has(e.authorId)?" participant-match":""}`,children:[a.jsx("strong",{children:e.authorDisplayName??te??y("editor.deletedUser")}),te&&a.jsxs("small",{children:["@",te]})]}),a.jsxs("span",{className:"comment-header-actions",children:[a.jsxs("span",{className:"comment-times",children:[a.jsx("time",{dateTime:e.createdAt,title:new Date(e.createdAt).toISOString(),children:ue(e.createdAt)}),e.editedAt&&a.jsx("small",{children:y("editor.editedAt",{time:ue(e.editedAt)})})]}),e.authorId===n&&!A&&a.jsx(Jd,{kind:"comment",onEdit:()=>{K(e.content),N(!0)},onDelete:()=>q(!0)})]})]}),a.jsx("div",{className:"comment-location",children:e.orphaned?y("editor.orphaned"):l?y("editor.commentLocation",{path:e.filePath,line:e.startLine}):y("editor.line",{line:e.startLine})}),e.selectedText&&a.jsx("blockquote",{className:"comment-selected-text",children:e.selectedText}),A?a.jsxs("form",{className:"comment-reply-form comment-edit-form",onSubmit:j=>{Q(j)},onClick:j=>j.stopPropagation(),children:[a.jsx(To,{projectId:t,autoFocus:!0,rows:4,value:U,onChange:K,onKeyDown:j=>Oc(j,Q)}),a.jsxs("div",{children:[a.jsx("button",{type:"button",onClick:()=>N(!1),children:y("common.cancel")}),a.jsxs("button",{className:"primary",type:"submit",disabled:!U.trim(),children:[a.jsx(Lu,{size:13}),y("editor.saveChanges")]})]})]}):a.jsx("p",{className:"comment-content",children:Yd(e.content)}),r&&a.jsxs("div",{className:"comment-mention",children:[a.jsxs("span",{children:[a.jsx(Ps,{"aria-hidden":!0,size:12}),y("editor.mentionedYou")]}),a.jsx("button",{type:"button",onClick:j=>{ke(r,j)},children:y("editor.markMentionRead")})]}),e.replies.length>0&&a.jsx("div",{className:"comment-replies",children:e.replies.map(j=>{const Y=s?.get(j.id);return a.jsxs("div",{"data-comment-reply-id":j.id,className:`comment-reply${i===j.id?" mention-target":""}`,children:[a.jsxs("header",{children:[a.jsxs("span",{className:`comment-author${D&&C?.has(j.authorId)?" participant-match":""}`,children:[a.jsx("strong",{children:j.authorDisplayName??j.authorUsername??y("editor.deletedUser")}),j.authorUsername&&a.jsxs("small",{children:["@",j.authorUsername]})]}),a.jsxs("span",{className:"comment-header-actions",children:[a.jsxs("span",{className:"comment-times",children:[a.jsx("time",{dateTime:j.createdAt,title:new Date(j.createdAt).toISOString(),children:ue(j.createdAt)}),j.editedAt&&a.jsx("small",{children:y("editor.editedAt",{time:ue(j.editedAt)})})]}),j.authorId===n&&B!==j.id&&a.jsx(Jd,{kind:"reply",onEdit:()=>{W(j.id),Z(j.content)},onDelete:()=>V(j.id)})]})]}),B===j.id?a.jsxs("form",{className:"comment-reply-form comment-edit-form",onSubmit:le=>{Ce(le)},onClick:le=>le.stopPropagation(),children:[a.jsx(To,{projectId:t,autoFocus:!0,rows:3,value:z,onChange:Z,onKeyDown:le=>Oc(le,Ce)}),a.jsxs("div",{children:[a.jsx("button",{type:"button",onClick:()=>W(null),children:y("common.cancel")}),a.jsxs("button",{className:"primary",type:"submit",disabled:!z.trim(),children:[a.jsx(Lu,{size:13}),y("editor.saveChanges")]})]})]}):a.jsx("p",{className:"comment-content",children:Yd(j.content)}),Y&&a.jsxs("div",{className:"comment-mention",children:[a.jsxs("span",{children:[a.jsx(Ps,{"aria-hidden":!0,size:12}),y("editor.mentionedYou")]}),a.jsx("button",{type:"button",onClick:le=>{ke(Y,le)},children:y("editor.markMentionRead")})]})]},j.id)})}),a.jsxs("div",{className:"comment-actions",children:[a.jsxs("button",{className:"resolve",onClick:j=>{j.stopPropagation(),f()},children:[e.resolved?a.jsx(hb,{size:13}):a.jsx(lf,{size:13}),e.resolved?y("editor.reopen"):y("editor.resolve")]}),a.jsxs("button",{className:"reply-action",onClick:j=>{j.stopPropagation(),k(Y=>!Y)},children:[a.jsx(fb,{size:13}),y("editor.reply")]})]}),w&&a.jsxs("form",{className:"comment-reply-form",onSubmit:j=>{G(j)},onClick:j=>j.stopPropagation(),children:[a.jsx(To,{projectId:t,autoFocus:!0,rows:3,value:v,placeholder:y("editor.replyPlaceholder"),onChange:R,onKeyDown:j=>Oc(j,G)}),a.jsxs("div",{children:[a.jsx("button",{type:"button",onClick:()=>{k(!1),R("")},children:y("common.cancel")}),a.jsxs("button",{className:"primary",type:"submit",disabled:!v.trim(),children:[a.jsx(pb,{size:13}),y("editor.sendReply")]})]})]})]}),a.jsx(_s,{open:T,title:y("editor.deleteCommentTitle"),description:y("editor.deleteCommentDescription",{count:e.replies.length}),confirmLabel:y("common.delete"),danger:!0,onCancel:()=>q(!1),onConfirm:()=>{m().then(j=>{j&&q(!1)})}}),a.jsx(_s,{open:!!I,title:y("editor.deleteReplyTitle"),description:y("editor.deleteReplyDescription"),confirmLabel:y("common.delete"),danger:!0,onCancel:()=>V(null),onConfirm:()=>{I&&S(I).then(j=>{j&&V(null)})}})]})}function JR({open:t,onOpenChange:e,project:n,projectId:r}){const{t:s}=tt(),[o,i]=u.useState([]),[c,l]=u.useState([]),[d,h]=u.useState(""),[f,p]=u.useState("read"),[g,m]=u.useState(null),[b,S]=u.useState(""),C=n.permission==="owner",D=async()=>{try{const[R,A]=await Promise.all([ye(`/api/projects/${r}/members`),ye("/api/users")]);i(R.members),l(A.users.filter(N=>N.id!==n.ownerId))}catch(R){S(ge(R))}};u.useEffect(()=>{t&&D()},[t,r]);const y=async()=>{if(d)try{await ye(`/api/projects/${r}/members/${d}`,{method:"PUT",body:JSON.stringify({permission:f})}),h(""),p("read"),await D()}catch(R){S(ge(R))}},w=async(R,A)=>{try{await ye(`/api/projects/${r}/members/${R.id}`,{method:"PUT",body:JSON.stringify({permission:A})}),await D()}catch(N){S(ge(N))}},k=async()=>{if(g)try{await ye(`/api/projects/${r}/members/${g.id}`,{method:"DELETE"}),m(null),await D()}catch(R){S(ge(R))}},v=c.filter(R=>!o.some(A=>A.id===R.id));return a.jsxs(a.Fragment,{children:[a.jsx(On,{open:t,wide:!0,title:s("projectSettings.share"),description:s("projectSettings.shareDescription"),onOpenChange:e,footer:a.jsx("button",{onClick:()=>e(!1),children:s("common.close")}),children:a.jsxs("div",{className:"share-dialog",children:[b&&a.jsx("p",{className:"error",children:b}),a.jsxs("div",{className:"share-owner",children:[a.jsx(No,{size:17}),a.jsxs("span",{children:[a.jsx("small",{children:s("projects.owner")}),a.jsx("strong",{children:n.ownerDisplayName??n.ownerUsername})]})]}),C&&a.jsxs("div",{className:"share-add",children:[a.jsxs("label",{className:"form-field",children:[s("common.user"),a.jsxs("select",{value:d,onChange:R=>h(R.target.value),children:[a.jsx("option",{value:"",children:s("projectSettings.chooseUser")}),v.map(R=>a.jsx("option",{value:R.id,children:R.displayName??R.username},R.id))]})]}),a.jsxs("label",{className:"form-field",children:[s("common.permission"),a.jsxs("select",{value:f,onChange:R=>p(R.target.value),children:[a.jsx("option",{value:"read",children:s("common.readOnly")}),a.jsx("option",{value:"edit",children:s("common.readWrite")})]})]}),a.jsxs("button",{className:"primary icon-button",disabled:!d,onClick:()=>{y()},children:[a.jsx(Kw,{size:15}),s("projectSettings.addMember")]})]}),a.jsxs("div",{className:"shared-members-heading",children:[a.jsx("strong",{children:s("projectSettings.members")}),a.jsx("span",{children:o.length})]}),a.jsxs("div",{className:"shared-members",children:[o.map(R=>a.jsxs("div",{className:"shared-member",children:[a.jsxs("span",{className:"member-identity",children:[a.jsx("span",{className:"member-avatar",children:(R.displayName??R.username).slice(0,1).toLocaleUpperCase()}),a.jsxs("span",{children:[a.jsx("strong",{children:R.displayName??R.username}),a.jsxs("small",{children:["@",R.username]})]})]}),a.jsxs("span",{className:"member-controls",children:[a.jsxs("select",{"aria-label":s("common.permission"),disabled:!C,value:R.permission,onChange:A=>{w(R,A.target.value)},children:[a.jsx("option",{value:"read",children:s("common.readOnly")}),a.jsx("option",{value:"edit",children:s("common.readWrite")})]}),C&&a.jsx("button",{className:"icon-only danger-text",title:s("common.remove"),"aria-label":s("common.remove"),onClick:()=>m(R),children:a.jsx(fr,{size:15})})]})]},R.id)),o.length===0&&a.jsxs("div",{className:"share-empty",children:[a.jsx(No,{size:24}),a.jsx("span",{children:s("projectSettings.noMembers")})]})]})]})}),a.jsx(_s,{open:!!g,title:s("projectSettings.removeTitle"),description:s("projectSettings.removeDescription",{username:g?.username??""}),confirmLabel:s("common.remove"),danger:!0,onCancel:()=>m(null),onConfirm:()=>{k()}})]})}const YR=u.lazy(()=>Nt(()=>import("./CitationLibraryDialog-BpnX28Le.js"),__vite__mapDeps([12,2,1,3,13,5,14,4,6,15]),import.meta.url).then(t=>({default:t.CitationLibraryDialog}))),XR=u.lazy(()=>Nt(()=>import("./GitDialog-CrLMkNSh.js"),__vite__mapDeps([16,2,1,3,5,17,18,19,14,20,4,6,7,8]),import.meta.url).then(t=>({default:t.GitDialog}))),ZR=u.lazy(()=>Nt(()=>import("./HistoryDialog-CNEHivv5.js"),__vite__mapDeps([21,2,1,3,22,23,5,19,14,20,4,6,7,8]),import.meta.url).then(t=>({default:t.HistoryDialog}))),QR=u.lazy(()=>Nt(()=>import("./SelectionHistoryDialog-JL_2qLGf.js"),__vite__mapDeps([24,2,1,3,22,4,5,6,7,8]),import.meta.url).then(t=>({default:t.SelectionHistoryDialog}))),eD=u.lazy(()=>Nt(()=>import("./ProjectNavigationDialogs-C7cD7PvT.js"),__vite__mapDeps([25,2,1,3,6,5,4]),import.meta.url).then(t=>({default:t.ProjectSearchDialog}))),tD=u.lazy(()=>Nt(()=>import("./ProjectNavigationDialogs-C7cD7PvT.js"),__vite__mapDeps([25,2,1,3,6,5,4]),import.meta.url).then(t=>({default:t.QuickOpenDialog})));function nD({user:t,project:e,projectId:n,activeFile:r,content:s,maxCitationBibtexBytes:o,files:i,directoryEntries:c,readOnly:l,workspaceLayout:d,changeWorkspaceLayout:h,resourcePreview:f,resourcePreviewLoading:p,setResourcePreview:g,setResourcePreviewLoading:m,uploadConflict:b,setUploadConflict:S,dismissUploadFeedback:C,uploadFiles:D,cleanMode:y,setCleanMode:w,cleanCompile:k,newFileOpen:v,setNewFileOpen:R,newFilePath:A,setNewFilePath:N,newFolderOpen:U,setNewFolderOpen:K,newFolderName:T,setNewFolderName:q,selectedFolder:B,fileDialogError:W,setFileDialogError:z,createFile:Z,createFolder:I,moveEntry:V,setMoveEntry:G,moveName:Q,setMoveName:Ce,moveDestination:te,setMoveDestination:ue,movePath:ke,deleteEntry:j,setDeleteEntry:Y,deleteActiveSessions:le,removePath:Re,commentOpen:re,closeComment:we,commentSelection:Ee,commentText:J,setCommentText:ce,commentSubmitting:L,commentError:_e,addComment:Ne,shareOpen:pe,setShareOpen:Oe,citationLibraryOpen:de,setCitationLibraryOpen:X,insertCitationAtCursor:ne,quickOpen:be,setQuickOpen:Ae,projectSearchOpen:$,setProjectSearchOpen:Pe,openFile:Je,jumpToSource:wt,selectionHistoryTarget:xe,closeSelectionHistory:_,historyOpen:H,setHistoryOpen:ae,gitOpen:De,setGitOpen:Me,save:rt,permissionDowngrade:Ke,permissionDowngradeBusy:ve,dismissPermissionDowngrade:Gt,discardPermissionDraft:ee}){const{t:O}=tt();return a.jsxs(a.Fragment,{children:[Ke&&a.jsx(On,{open:!0,title:O("editor.collaboration.permissionDowngradeTitle"),description:Ke.localDraftReady&&Ke.otherTabDraft?O("editor.collaboration.permissionDowngradeMultipleDrafts"):Ke.otherTabDraft?O("editor.collaboration.permissionDowngradeOtherTab"):Ke.localDraftReady?O("editor.collaboration.permissionDowngradeDescription",{previous:O("common.readWrite")}):O("editor.collaboration.permissionDowngradeNoDraft"),onOpenChange:P=>{!P&&!ve&&Gt()},footer:a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",disabled:ve,onClick:Gt,children:Ke.localDraftReady?O("editor.collaboration.permissionDowngradeKeep"):O("common.close")}),!Ke.otherTabDraft&&a.jsxs("button",{type:"button",className:"danger",disabled:ve,onClick:()=>{ee()},children:[ve?a.jsx(gt,{className:"spin",size:14}):Ke.localDraftReady?a.jsx(fr,{size:14}):a.jsx(Gw,{size:14}),Ke.localDraftReady?O("editor.collaboration.permissionDowngradeDiscard"):O("editor.collaboration.permissionDowngradeReload")]})]}),children:a.jsx("div",{})}),a.jsxs(On,{open:!!f,extraWide:f?.kind==="image"||f?.kind==="pdf"||f?.kind==="text",title:f?.path??"",description:f?.kind==="large"?O("editor.resourceTooLarge",{size:rD(f.size),limit:`${na/1024/1024} MB`}):O(`editor.resourcePreview.${f?.kind??"text"}`),onOpenChange:P=>{P||(g(null),m(!1))},footer:f&&a.jsxs("a",{className:"primary resource-download",href:`${f.url}&download=1`,download:!0,children:[a.jsx(Mo,{size:14}),O("editor.downloadResource")]}),children:[f?.kind==="large"&&a.jsxs("div",{className:"resource-preview-message",children:[a.jsx(Fc,{size:34}),a.jsx("strong",{children:O("editor.resourceTooLargeTitle")}),a.jsx("span",{children:O("editor.resourceTooLargeDescription")})]}),f?.kind==="unsupported"&&a.jsxs("div",{className:"resource-preview-message",children:[a.jsx(Fc,{size:34}),a.jsx("strong",{children:O("editor.resourceUnsupportedTitle")}),a.jsx("span",{children:O("editor.resourceUnsupportedDescription")})]}),f?.kind==="image"&&a.jsx("div",{className:"resource-image-wrap",children:a.jsx("img",{className:"resource-image",src:f.url,alt:f.path})}),f?.kind==="pdf"&&a.jsx("iframe",{className:"resource-pdf",src:f.url,title:f.path}),f?.kind==="text"&&(p?a.jsxs("div",{className:"resource-preview-message",children:[a.jsx(gt,{className:"spin",size:24}),a.jsx("span",{children:O("common.loading")})]}):a.jsx("pre",{className:"resource-text",children:f.content}))]}),a.jsx(_s,{open:!!b,title:O("editor.uploadOverwriteTitle"),description:O("editor.uploadOverwriteDescription",{files:b?.collisions.join(", ")??""}),confirmLabel:O("editor.uploadOverwrite"),danger:!0,onCancel:()=>{S(null),C()},onConfirm:()=>{const P=b;S(null),P&&D(P.files,new Set(P.collisions),P.directory)}}),a.jsx(_s,{open:!!y,title:O(y==="cache"?"editor.cleanCacheConfirmTitle":"editor.cleanArtifactsConfirmTitle"),description:O(y==="cache"?"editor.cleanCacheConfirmDescription":"editor.cleanArtifactsConfirmDescription"),confirmLabel:O("editor.cleanConfirm"),danger:y==="artifacts",onCancel:()=>w(null),onConfirm:()=>{const P=y;w(null),P&&k(P)}}),a.jsx(On,{open:v,title:O("editor.newFile"),description:O("editor.newFileDescription"),onOpenChange:P=>{R(P),P||z("")},footer:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>R(!1),children:O("common.cancel")}),a.jsx("button",{className:"primary",onClick:()=>{Z()},children:O("common.create")})]}),children:a.jsxs(a.Fragment,{children:[W&&a.jsx("p",{className:"error dialog-error",children:W}),a.jsxs("label",{className:"form-field",children:[O("editor.filePath"),a.jsx("input",{autoFocus:!0,value:A,onChange:P=>N(P.target.value),onKeyDown:P=>{P.key==="Enter"&&!P.nativeEvent.isComposing&&(P.preventDefault(),Z())}})]})]})}),a.jsx(On,{open:U,title:O("editor.newFolder"),description:O("editor.folderDestination",{folder:B||O("editor.projectRoot")}),onOpenChange:P=>{K(P),P||z("")},footer:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>K(!1),children:O("common.cancel")}),a.jsx("button",{className:"primary",onClick:()=>{I()},children:O("common.create")})]}),children:a.jsxs(a.Fragment,{children:[W&&a.jsx("p",{className:"error dialog-error",children:W}),a.jsxs("label",{className:"form-field",children:[O("editor.folderName"),a.jsx("input",{autoFocus:!0,value:T,onChange:P=>q(P.target.value),onKeyDown:P=>{P.key==="Enter"&&I()}})]})]})}),a.jsx(On,{open:!!V,title:O("editor.moveTitle",{name:V?.path.split("/").at(-1)??""}),description:O("editor.moveDescription"),onOpenChange:P=>{P||(G(null),Ce(""),z(""))},footer:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>G(null),children:O("common.cancel")}),a.jsx("button",{className:"primary",disabled:!Q.trim(),onClick:()=>{ke()},children:O("editor.moveApply")})]}),children:a.jsxs(a.Fragment,{children:[W&&a.jsx("p",{className:"error dialog-error",children:W}),a.jsxs("label",{className:"form-field",children:[O("editor.pathName"),a.jsx("input",{autoFocus:!0,value:Q,onChange:P=>Ce(P.target.value),onKeyDown:P=>{P.key==="Enter"&&ke()}})]}),a.jsxs("label",{className:"form-field",children:[O("editor.destinationFolder"),a.jsxs("select",{value:te,onChange:P=>ue(P.target.value),children:[a.jsx("option",{value:"",children:O("editor.projectRoot")}),c.filter(P=>V?.type!=="directory"||P.path!==V.path&&!P.path.startsWith(`${V.path}/`)).map(P=>a.jsx("option",{value:P.path,children:P.path},P.path))]})]})]})}),a.jsx(On,{open:!!j,title:O("editor.deletePathTitle",{name:j?.path.split("/").at(-1)??""}),description:le.length?O("editor.deletePathActiveDescription",{path:j?.path??"",users:[...new Set(le.map(P=>P.name))].join(", ")}):O("editor.deletePathDescription",{path:j?.path??""}),onOpenChange:P=>{P||(Y(null),z(""))},footer:a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>Y(null),children:O("common.cancel")}),a.jsx("button",{className:"danger",onClick:()=>{Re()},children:O("common.delete")})]}),children:a.jsxs(a.Fragment,{children:[W&&a.jsx("p",{className:"error dialog-error",children:W}),le.length>0&&a.jsxs("p",{className:"warning",children:[a.jsx(Vt,{size:15}),O("editor.deletePathWillClose")]})]})}),a.jsxs(On,{open:re,draggable:!0,title:O("editor.addComment"),description:Ee.selectedText?O("editor.commentDescription",{count:Ee.endOffset-Ee.startOffset}):O("editor.pointComment"),onOpenChange:P=>{P||we()},footer:a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",disabled:L,onClick:we,children:O("common.cancel")}),a.jsxs("button",{type:"button",className:"primary",disabled:L||!J.trim(),onClick:()=>{Ne()},children:[L&&a.jsx(gt,{className:"spin",size:14}),O("editor.addComment")]})]}),children:[_e&&a.jsx("p",{className:"error dialog-error",children:_e}),a.jsxs("label",{className:"form-field",children:[O("editor.commentContent"),a.jsx(To,{projectId:n,autoFocus:!0,rows:5,disabled:L,value:J,onChange:ce,onKeyDown:P=>{(P.ctrlKey||P.metaKey)&&P.key==="Enter"&&!P.nativeEvent.isComposing&&(P.preventDefault(),P.stopPropagation(),Ne())}})]}),Ee.selectedText&&a.jsx("blockquote",{className:"selection-preview",children:Ee.selectedText})]}),a.jsx(JR,{open:pe,onOpenChange:Oe,project:e,projectId:n}),de&&a.jsx(of,{title:O("citationLibrary.title"),onClose:()=>X(!1),children:a.jsx(YR,{open:!0,onOpenChange:X,currentFile:r,currentSource:s,readOnly:l,currentUserId:t.id,maxBibtexBytes:o,onInsert:ne})}),be&&a.jsx(u.Suspense,{fallback:null,children:a.jsx(tD,{open:!0,files:i,onOpenChange:Ae,onOpenFile:P=>{const oe=i.find(ht=>ht.path===P);oe&&Je(oe)}})}),$&&a.jsx(u.Suspense,{fallback:null,children:a.jsx(eD,{open:!0,project:e,onOpenChange:Pe,onJump:(P,oe,ht)=>{d==="pdf-only"&&h("editor-pdf"),wt(P,oe,ht)}})}),xe&&a.jsx(u.Suspense,{fallback:null,children:a.jsx(QR,{open:!0,onOpenChange:P=>{P||_()},project:e,filePath:xe.filePath,selection:xe.selection,currentSource:xe.source})}),H&&a.jsx(u.Suspense,{fallback:null,children:a.jsx(ZR,{open:!0,onOpenChange:ae,project:e,onBeforeMutation:e.permission==="read"?async()=>!0:rt})}),e.ownerId===t.id&&De&&a.jsx(u.Suspense,{fallback:null,children:a.jsx(XR,{open:!0,onOpenChange:Me,project:e,onBeforeMutation:rt})})]})}function rD(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}var sD=Object.defineProperty,zt=(t,e)=>sD(t,"name",{value:e,configurable:!0});function Al(t){const e=u.forwardRef((n,r)=>{let{children:s,...o}=n,i=null,c=!1;const l=[];va(s)&&typeof Ro=="function"&&(s=Ro(s._payload)),u.Children.forEach(s,p=>{if(tg(p)){c=!0;const g=p;let m="child"in g.props?g.props.child:g.props.children;va(m)&&typeof Ro=="function"&&(m=Ro(m._payload)),i=iD(g,m),l.push(i?.props?.children)}else l.push(p)}),i?i=u.cloneElement(i,void 0,l):!c&&u.Children.count(s)===1&&u.isValidElement(s)&&(i=s);const d=i?eg(i):void 0,h=ze(r,d);if(!i){if(s||s===0)throw new Error(c?lD(t):aD(t));return s}const f=Qm(o,i.props??{});return i.type!==u.Fragment&&(f.ref=r?h:d),u.cloneElement(i,f)});return e.displayName=`${t}.Slot`,e}zt(Al,"createSlot");var Zm=Symbol.for("radix.slottable");function oD(t){const e=zt(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=Zm,e}zt(oD,"createSlottable");var iD=zt((t,e)=>{if("child"in t.props){const n=t.props.child;return u.isValidElement(n)?u.cloneElement(n,void 0,t.props.children(n.props.children)):null}return u.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function Qm(t,e){const n={...e};for(const r in e){const s=t[r],o=e[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...c)=>{const l=o(...c);return s(...c),l}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"?n[r]=[s,o].filter(Boolean).join(" "):r==="aria-describedby"&&(n[r]=rg(o,s))}return{...t,...n}}zt(Qm,"mergeProps");function eg(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}zt(eg,"getElementRef");function tg(t){return u.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Zm}zt(tg,"isSlottable");var cD=Symbol.for("react.lazy");function va(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===cD&&"_payload"in t&&ng(t._payload)}zt(va,"isLazyComponent");function ng(t){return typeof t=="object"&&t!==null&&"then"in t}zt(ng,"isPromiseLike");function rg(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const r of String(n).trim().split(/\s+/))r&&e.add(r);return e.size>0?Array.from(e).join(" "):void 0}zt(rg,"concatAriaDescribedby");var aD=zt(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),lD=zt(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Ro=xr[" use ".trim().toString()],uD=Object.defineProperty,dD=(t,e)=>uD(t,"name",{value:e,configurable:!0}),fD=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ro=fD.reduce((t,e)=>{const n=Al(`Primitive.${e}`),r=u.forwardRef((s,o)=>{const{asChild:i,...c}=s,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(l,{...c,ref:o})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function sg(t,e){t&&qn.flushSync(()=>t.dispatchEvent(e))}dD(sg,"dispatchDiscreteCustomEvent");var hD=Object.defineProperty,ct=(t,e)=>hD(t,"name",{value:e,configurable:!0}),Sa="dismissableLayer.update",pD="dismissableLayer.pointerDownOutside",mD="dismissableLayer.focusOutside",Xd,og=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),gD=u.forwardRef(ct(function(e,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:c,onInteractOutside:l,onDismiss:d,...h}=e,f=u.useContext(og),[p,g]=u.useState(null),m=p?.ownerDocument??globalThis?.document,[,b]=u.useState({}),S=ze(n,g),C=Array.from(f.layers),[D]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),y=D?C.indexOf(D):-1,w=p?C.indexOf(p):-1,k=f.layersWithOutsidePointerEventsDisabled.size>0,v=w>=y,R=u.useRef(!1),A=ig(T=>{i?.(T),l?.(T),T.defaultPrevented||d?.()},{ownerDocument:m,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:R,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:u.useCallback(T=>{if(!(T instanceof Node))return!1;const q=[...f.branches].some(B=>B.contains(T));return v&&!q},[f.branches,v])}),N=cg(T=>{if(s&&R.current)return;const q=T.target;[...f.branches].some(W=>W.contains(q))||(c?.(T),l?.(T),T.defaultPrevented||d?.())},m),U=p?w===C.length-1:!1,K=_t(T=>{T.key==="Escape"&&(o?.(T),!T.defaultPrevented&&d&&(T.preventDefault(),d()))});return u.useEffect(()=>{if(U)return m.addEventListener("keydown",K,{capture:!0}),()=>m.removeEventListener("keydown",K,{capture:!0})},[m,U,K]),u.useEffect(()=>{if(p)return r&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Xd=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),Ca(),()=>{r&&(f.layersWithOutsidePointerEventsDisabled.delete(p),f.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=Xd))}},[p,m,r,f]),u.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),Ca())},[p,f]),u.useEffect(()=>{const T=ct(()=>b({}),"handleUpdate");return document.addEventListener(Sa,T),()=>document.removeEventListener(Sa,T)},[]),a.jsx(ro.div,{...h,ref:S,style:{pointerEvents:k?v?"auto":"none":void 0,...e.style},onFocusCapture:Te(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Te(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Te(e.onPointerDownCapture,A.onPointerDownCapture)})},"DismissableLayer"));function yD(){const t=u.useContext(og),[e,n]=u.useState(null);return u.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),n}ct(yD,"useDismissableLayerSurface");var wD=ct(()=>!0,"IS_TRUE");function ig(t,e){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:s,dismissableSurfaces:o,shouldHandlePointerDownOutside:i=wD}=e,c=_t(t),l=u.useRef(!1),d=u.useRef(!1),h=u.useRef(new Map),f=u.useRef(()=>{});return u.useEffect(()=>{function p(){d.current=!1,s.current=!1,h.current.clear()}ct(p,"resetOutsideInteraction");function g(){return Array.from(h.current.values()).some(Boolean)}ct(g,"isOutsideInteractionIntercepted");function m(y){if(!d.current)return;const w=y.target;w instanceof Node&&[...o].some(v=>v.contains(w))||h.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{d.current&&f.current()},0)}ct(m,"handleInteractionCapture");function b(y){d.current&&h.current.set(y.type,!1)}ct(b,"handleInteractionBubble");const S=ct(y=>{if(y.target&&!l.current){let w=function(){n.removeEventListener("click",f.current);const v=g();p(),v||Tl(pD,c,k,{discrete:!0})};if(ct(w,"handleAndDispatchPointerDownOutsideEvent"),!i(y.target)){n.removeEventListener("click",f.current),p(),l.current=!1;return}const k={originalEvent:y};d.current=!0,s.current=r&&y.button===0,h.current.clear(),!r||y.button!==0?w():(n.removeEventListener("click",f.current),f.current=w,n.addEventListener("click",f.current,{once:!0}))}else n.removeEventListener("click",f.current),p();l.current=!1},"handlePointerDown"),C=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of C)n.addEventListener(y,m,!0),n.addEventListener(y,b);const D=window.setTimeout(()=>{n.addEventListener("pointerdown",S)},0);return()=>{window.clearTimeout(D),n.removeEventListener("pointerdown",S),n.removeEventListener("click",f.current);for(const y of C)n.removeEventListener(y,m,!0),n.removeEventListener(y,b)}},[n,c,r,s,o,i]),{onPointerDownCapture:ct(()=>l.current=!0,"onPointerDownCapture")}}ct(ig,"usePointerDownOutside");function cg(t,e=globalThis?.document){const n=_t(t),r=u.useRef(!1);return u.useEffect(()=>{const s=ct(o=>{o.target&&!r.current&&Tl(mD,n,{originalEvent:o},{discrete:!1})},"handleFocus");return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,n]),{onFocusCapture:ct(()=>r.current=!0,"onFocusCapture"),onBlurCapture:ct(()=>r.current=!1,"onBlurCapture")}}ct(cg,"useFocusOutside");function Ca(){const t=new CustomEvent(Sa);document.dispatchEvent(t)}ct(Ca,"dispatchUpdate");function Tl(t,e,n,{discrete:r}){const s=n.originalEvent.target,o=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&s.addEventListener(t,e,{once:!0}),r?sg(s,o):s.dispatchEvent(o)}ct(Tl,"handleAndDispatchCustomEvent");var bD=Object.defineProperty,et=(t,e)=>bD(t,"name",{value:e,configurable:!0}),Lc="focusScope.autoFocusOnMount",Nc="focusScope.autoFocusOnUnmount",Zd={bubbles:!1,cancelable:!0},xD=u.forwardRef(et(function(e,n){const{loop:r=!1,trapped:s=!1,branches:o,onMountAutoFocus:i,onUnmountAutoFocus:c,...l}=e,[d,h]=u.useState(null),f=_t(i),p=_t(c),g=u.useRef(null),m=ze(n,h),b=u.useRef(o);u.useEffect(()=>{b.current=o});const S=u.useCallback(y=>y?d?.contains(y)?!0:!!b.current?.some(w=>w.contains(y)):!1,[d]),C=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(s){let y=function(R){if(C.paused||!d)return;const A=R.target;S(A)?g.current=A:gn(g.current,{select:!0})},w=function(R){if(C.paused||!d)return;const A=R.relatedTarget;A!==null&&(S(A)||gn(g.current,{select:!0}))},k=function(R){if(document.activeElement===document.body)for(const N of R)N.removedNodes.length>0&&gn(d)};et(y,"handleFocusIn"),et(w,"handleFocusOut"),et(k,"handleMutations"),document.addEventListener("focusin",y),document.addEventListener("focusout",w);const v=new MutationObserver(k);return d&&v.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",w),v.disconnect()}}},[s,d,C.paused,S]),u.useEffect(()=>{if(d){Qd.add(C);const y=document.activeElement;if(!d.contains(y)){const k=new CustomEvent(Lc,Zd);d.addEventListener(Lc,f),d.dispatchEvent(k),k.defaultPrevented||(fg(yg(Ol(d)),{select:!0}),document.activeElement===y&&gn(d))}return()=>{d.removeEventListener(Lc,f),setTimeout(()=>{const k=new CustomEvent(Nc,Zd);d.addEventListener(Nc,p),d.dispatchEvent(k),k.defaultPrevented||gn(y??document.body,{select:!0}),d.removeEventListener(Nc,p),Qd.remove(C)},0)}}},[d,f,p,C]);const D=u.useCallback(y=>{if(!r&&!s||C.paused)return;const w=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,k=document.activeElement;if(w&&k){const v=y.currentTarget,[R,A]=hg(v);R&&A?!y.shiftKey&&k===A?(y.preventDefault(),r&&gn(R,{select:!0})):y.shiftKey&&k===R&&(y.preventDefault(),r&&gn(A,{select:!0})):k===v&&y.preventDefault()}},[r,s,C.paused]);return a.jsx(ro.div,{tabIndex:-1,...l,ref:m,onKeyDown:D})},"FocusScope")),ag=u.createContext(null);function lg({registry:t,children:e}){return t?a.jsx(ag.Provider,{value:t,children:e}):e}et(lg,"FocusScopeBranchProvider");function ug(){const[t,e]=u.useState([]),n=u.useMemo(()=>({add:et(r=>e(s=>s.includes(r)?s:[...s,r]),"add"),remove:et(r=>e(s=>s.filter(o=>o!==r)),"remove")}),[]);return{nodes:t,registry:n}}et(ug,"useFocusScopeBranchRegistry");function dg(t){const e=u.useContext(ag);u.useEffect(()=>{if(!(!t||!e))return e.add(t),()=>e.remove(t)},[t,e])}et(dg,"useFocusScopeBranch");function fg(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(gn(r,{select:e}),document.activeElement!==n)return}et(fg,"focusFirst");function hg(t){const e=Ol(t),n=Ea(e,t),r=Ea(e.reverse(),t);return[n,r]}et(hg,"getTabbableEdges");function Ol(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:et(r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)e.push(n.currentNode);return e}et(Ol,"getTabbableCandidates");function Ea(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const r of t)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):pg(r,{upTo:e})))return r}et(Ea,"findVisible");function pg(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}et(pg,"isHidden");function mg(t){return t instanceof HTMLInputElement&&"select"in t}et(mg,"isSelectableInput");function gn(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&mg(t)&&e&&t.select()}}et(gn,"focus");var Qd=gg();function gg(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=ka(t,e),t.unshift(e)},remove(e){t=ka(t,e),t[0]?.resume()}}}et(gg,"createFocusScopesStack");function ka(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}et(ka,"arrayRemove");function yg(t){return t.filter(e=>e.tagName!=="A")}et(yg,"removeLinks");var vD=Object.defineProperty,SD=(t,e)=>vD(t,"name",{value:e,configurable:!0}),CD=u.forwardRef(SD(function(e,n){const{container:r,...s}=e,[o,i]=u.useState(!1);Lt(()=>i(!0),[]);const c=r||o&&globalThis?.document?.body;return c?qn.createPortal(a.jsx(ro.div,{...s,ref:n}),c):null},"Portal")),ED=Object.defineProperty,En=(t,e)=>ED(t,"name",{value:e,configurable:!0});function wg(t,e){return u.useReducer((n,r)=>e[n][r]??n,t)}En(wg,"useStateMachine");var bg=En(t=>{const{present:e,children:n}=t,r=xg(e),s=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),o=vg(r.ref,Sg(s));return typeof n=="function"||r.isPresent?u.cloneElement(s,{ref:o}):null},"Presence");function xg(t){const[e,n]=u.useState(),r=u.useRef(null),s=u.useRef(t),o=u.useRef("none"),i=u.useRef(void 0),c=t?"mounted":"unmounted",[l,d]=wg(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{l==="mounted"?(o.current=i.current??Ur(r.current),i.current=void 0):o.current="none"},[l]),Lt(()=>{const h=r.current,f=s.current;if(f!==t){const g=o.current,m=Ur(h);t?(i.current=m,d("MOUNT")):m==="none"||h?.display==="none"?d("UNMOUNT"):d(f&&g!==m?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,d]),Lt(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,p=En(m=>{const S=Ur(r.current).includes(CSS.escape(m.animationName));if(m.target===e&&S&&(d("ANIMATION_END"),!s.current)){const C=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=C)})}},"handleAnimationEnd"),g=En(m=>{m.target===e&&(o.current=Ur(r.current))},"handleAnimationStart");return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",p),e.addEventListener("animationend",p),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",p),e.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[e,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(h=>{if(h){const f=getComputedStyle(h);r.current=f,i.current=Ur(f)}else r.current=null;n(h)},[])}}En(xg,"usePresence");function Ra(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}En(Ra,"setRef");function vg(...t){const e=u.useRef(t);return e.current=t,u.useCallback(n=>{const r=e.current;let s=!1;const o=r.map(i=>{const c=Ra(i,n);return!s&&typeof c=="function"&&(s=!0),c});if(s)return()=>{for(let i=0;i<o.length;i++){const c=o[i];typeof c=="function"?c():Ra(r[i],null)}}},[])}En(vg,"useStableComposedRefs");function Ur(t){return t?.animationName||"none"}En(Ur,"getAnimationName");function Sg(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}En(Sg,"getElementRef");var kD=Object.defineProperty,an=(t,e)=>kD(t,"name",{value:e,configurable:!0}),Ll="Popover",[Cg,bj]=br(Ll,[Di]),Nl=Di(),[RD,Dr]=Cg(Ll),DD=an(t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:s,onOpenChange:o,modal:i=!1}=t,c=Nl(e),l=u.useRef(null),[d,h]=u.useState(!1),[f,p]=u.useState(0),[g,m]=u.useState(0),[b,S]=Da({prop:r,defaultProp:s??!1,onChange:o,caller:Ll});return a.jsx(dm,{...c,children:a.jsx(RD,{scope:e,contentId:Br(),titleId:Br(),descriptionId:Br(),titlePresent:f>0,descriptionPresent:g>0,setTitleCount:p,setDescriptionCount:m,triggerRef:l,open:b,onOpenChange:S,onOpenToggle:u.useCallback(()=>S(C=>!C),[S]),hasCustomAnchor:d,onCustomAnchorAdd:u.useCallback(()=>h(!0),[]),onCustomAnchorRemove:u.useCallback(()=>h(!1),[]),modal:i,children:n})})},"Popover"),jD="PopoverTrigger",_D=u.forwardRef(an(function(e,n){const{__scopePopover:r,...s}=e,o=Dr(jD,r),i=Nl(r),c=ze(n,o.triggerRef),l=a.jsx(ro.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":Ml(o.open),...s,ref:c,onClick:Te(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:a.jsx(fm,{asChild:!0,...i,children:l})},"PopoverTrigger")),Eg="PopoverPortal",[PD,AD]=Cg(Eg,{forceMount:void 0}),TD=an(t=>{const{__scopePopover:e,forceMount:n,children:r,container:s}=t,o=Dr(Eg,e);return a.jsx(PD,{scope:e,forceMount:n,children:a.jsx(bg,{present:n||o.open,children:a.jsx(CD,{asChild:!0,container:s,children:r})})})},"PopoverPortal"),Hs="PopoverContent",OD=u.forwardRef(an(function(e,n){const r=AD(Hs,e.__scopePopover),{forceMount:s=r.forceMount,...o}=e,i=Dr(Hs,e.__scopePopover);return a.jsx(bg,{present:s||i.open,children:i.modal?a.jsx(ND,{...o,ref:n}):a.jsx(MD,{...o,ref:n})})},"PopoverContent")),LD=Al("PopoverContent.RemoveScroll"),ND=u.forwardRef(an(function(e,n){const r=Dr(Hs,e.__scopePopover),s=u.useRef(null),o=ze(n,s),i=u.useRef(!1),{nodes:c,registry:l}=ug();return u.useEffect(()=>{const d=s.current;if(d)return rf(d)},[]),a.jsx(cf,{as:LD,allowPinchZoom:!0,shards:u.useMemo(()=>[s,...c.map(d=>({current:d}))],[s,c]),children:a.jsx(kg,{...e,ref:o,branchNodes:c,branchRegistry:l,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Te(e.onCloseAutoFocus,d=>{d.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Te(e.onPointerDownOutside,d=>{const h=d.detail.originalEvent,f=h.button===0&&h.ctrlKey===!0,p=h.button===2||f;i.current=p},{checkForDefaultPrevented:!1}),onFocusOutside:Te(e.onFocusOutside,d=>d.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),MD=u.forwardRef(an(function(e,n){const r=Dr(Hs,e.__scopePopover),s=u.useRef(!1),o=u.useRef(!1);return a.jsx(kg,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(s.current||r.triggerRef.current?.focus(),i.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=i.target;r.triggerRef.current?.contains(c)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})},"PopoverContentNonModal")),kg=u.forwardRef(an(function(e,n){const{__scopePopover:r,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:f,"aria-describedby":p,branchNodes:g,branchRegistry:m,...b}=e,S=Dr(Hs,r),C=Nl(r),[D,y]=u.useState(null),w=ze(n,y);return dg(D),sf(),a.jsx(lg,{registry:m,children:a.jsx(xD,{asChild:!0,loop:!0,trapped:s,branches:g,onMountAutoFocus:o,onUnmountAutoFocus:i,children:a.jsx(gD,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:h,onDismiss:()=>S.onOpenChange(!1),deferPointerDownOutside:!0,children:a.jsx(pm,{"data-state":Ml(S.open),role:"dialog",id:S.contentId,"aria-labelledby":S.titlePresent?S.titleId:void 0,"aria-describedby":S.descriptionPresent?Rg(p,S.descriptionId):p,...C,...b,ref:w,style:{...b.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})})},"PopoverContentImpl")),FD=u.forwardRef(an(function(e,n){const{__scopePopover:r,...s}=e,o=Dr("PopoverTitle",r),{setTitleCount:i}=o;return Lt(()=>(i(c=>c+1),()=>i(c=>c-1)),[i]),a.jsx(ro.h2,{id:o.titleId,...s,ref:n})},"PopoverTitle"));function Ml(t){return t?"open":"closed"}an(Ml,"getState");function Rg(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const r of String(n).trim().split(/\s+/))r&&e.add(r);return e.size>0?Array.from(e).join(" "):void 0}an(Rg,"concatAriaDescribedby");function ID({participants:t,selectedIds:e,topLevelOnly:n,onToggle:r,onClear:s,onTopLevelOnlyChange:o}){const{t:i}=tt(),[c,l]=u.useState(!1),d=u.useRef(null),h=e.size>0,f=t.find(m=>e.has(m.authorId)),p=m=>m.authorDisplayName??m.authorUsername??i("editor.deletedUser"),g=h?f?e.size===1?p(f):i("editor.commentParticipantsSelected",{name:p(f),count:e.size-1}):i("editor.commentParticipantsCount",{count:e.size}):i("editor.commentParticipantsAll");return a.jsxs("div",{className:"comment-participant-filter",children:[a.jsxs("div",{className:`comment-participants-trigger-group${h?" active":""}`,children:[a.jsxs(DD,{open:c,onOpenChange:l,children:[a.jsx(_D,{asChild:!0,children:a.jsxs("button",{type:"button",className:"comment-participants-toggle","aria-label":`${i("editor.commentParticipants")}: ${g}`,children:[a.jsx(No,{size:13,"aria-hidden":!0}),a.jsx("span",{className:"comment-participants-summary",children:h&&f?p(f):g}),h&&f&&e.size>1&&a.jsxs("span",{className:"comment-participants-extra-count",children:["+",e.size-1]}),a.jsx(ci,{size:12,"aria-hidden":!0,className:c?"expanded":""})]})}),a.jsx(TD,{children:a.jsxs(OD,{ref:d,className:"comment-participants-popover",side:"bottom",align:"end",sideOffset:6,collisionPadding:10,"aria-label":i("editor.commentParticipants"),onOpenAutoFocus:m=>{m.preventDefault();const b=d.current?.querySelector('input[type="checkbox"]:not(:disabled)');b?b.focus():d.current?.focus()},children:[a.jsxs("div",{className:"comment-participants-heading",children:[a.jsx(FD,{children:i("editor.commentParticipants")}),h&&a.jsx("button",{type:"button",onClick:s,children:i("editor.commentParticipantsClear")})]}),a.jsxs("div",{className:"comment-participants-list",children:[t.map(m=>{const b=p(m),S=e.has(m.authorId);return a.jsxs("label",{className:`comment-participant-option${S?" selected":""}`,children:[a.jsx("input",{type:"checkbox",checked:S,onChange:()=>r(m.authorId)}),a.jsx("span",{className:"comment-participant-avatar","aria-hidden":!0,children:Array.from(b.trim())[0]?.toLocaleUpperCase()??"?"}),a.jsxs("span",{className:"comment-participant-identity",children:[a.jsx("strong",{children:b}),m.authorUsername&&a.jsxs("small",{children:["@",m.authorUsername]})]})]},m.authorId??"deleted")}),t.length===0&&a.jsx("p",{className:"comment-participants-empty",children:i("editor.commentNoParticipants")})]}),a.jsxs("label",{className:"comment-participants-root-only",children:[a.jsx("input",{type:"checkbox",checked:n,disabled:!h,onChange:m=>o(m.target.checked)}),i("editor.commentTopLevelOnly")]})]})})]}),h&&a.jsx("button",{type:"button",className:"comment-participants-clear","aria-label":i("editor.commentParticipantsClear"),onClick:s,children:a.jsx(In,{size:12,"aria-hidden":!0})})]}),h&&n&&a.jsx("span",{className:"comment-participants-scope",children:i("editor.commentTopLevelOnly")})]})}const $D=u.lazy(()=>Nt(()=>import("./ProjectSettings-CRHG-jAZ.js"),__vite__mapDeps([26,2,1,3,5,27,28,8,4,6,7]),import.meta.url).then(t=>({default:t.ProjectSettings})));function UD({sidePanel:t,onClose:e,project:n,projectId:r,site:s,files:o,currentUserId:i,comments:c,commentsLoading:l,commentsError:d,onRetryComments:h,unreadMentions:f,activeFile:p,hasProjectCommentsScope:g,commentScope:m,onCommentScopeChange:b,focusedCommentId:S,commentFocusNonce:C,onMarkMentionRead:D,onMarkAllMentionsRead:y,onClearFocusComment:w,targetCommentId:k,targetReplyId:v,onFocusComment:R,onToggleComment:A,onReplyComment:N,onEditComment:U,onDeleteComment:K,onEditCommentReply:T,onDeleteCommentReply:q,dictionaryWords:B,onDictionaryChange:W,editorPreferences:z,onEditorPreferences:Z,spellCheckCount:I,spellCheckUniqueCount:V,spellCheckIndex:G,onSpellCheckNavigate:Q,onProject:Ce}){const{t:te}=tt(),[ue,ke]=u.useState("unresolved"),[j,Y]=u.useState(!1),[le,Re]=u.useState("source"),[re,we]=u.useState(()=>new Set),[Ee,J]=u.useState(!1),[ce,L]=u.useState(null),_e=u.useMemo(()=>Wb(c),[c]),Ne=u.useMemo(()=>{const _={activeFile:p,scope:m,unreadMentions:f,participantIds:re,topLevelOnly:Ee,unreadMentionsOnly:j};return{unresolved:ac(c,{..._,filter:"unresolved"}).length,resolved:ac(c,{..._,filter:"resolved"}).length,mentions:ac(c,{..._,filter:ue,unreadMentionsOnly:!0}).length}},[p,m,c,f,re,Ee,ue,j]),pe=u.useMemo(()=>Hb(c,{activeFile:p,scope:m,filter:ue,unreadMentions:f,sort:le,participantIds:re,topLevelOnly:Ee,unreadMentionsOnly:j},[ce,k,S]),[p,ue,m,c,S,ce,k,f,le,re,Ee,j]),Oe=S&&pe.some(_=>_.id===S)?S:ce&&pe.some(_=>_.id===ce)?ce:k&&pe.some(_=>_.id===k)?k:null,de=Yb(pe,Oe);u.useEffect(()=>{ce&&!c.some(_=>_.id===ce)&&L(null)},[c,ce]),u.useEffect(()=>{!g&&m!=="file"&&(L(null),w(),b("file"))},[m,g,w,b]),u.useEffect(()=>{if(t!=="comments")return;const _=k&&v?`.comments [data-comment-reply-id="${v}"]`:k?`.comments .comment-thread[data-comment-id="${k}"]`:Oe?`.comments .comment-thread[data-comment-id="${Oe}"]`:"";if(!_)return;const H=document.querySelector(_);if(!H)return;const ae=window.requestAnimationFrame(()=>H.scrollIntoView({block:k?"center":"nearest",behavior:"smooth"}));return()=>window.cancelAnimationFrame(ae)},[t,Oe,C,k,v,pe]);const X=_=>{ce!==_.id&&L(null),R(_)},ne=async _=>{R(_),L(Jb(_,ue)?_.id:null),await A(_)},be=_=>{const H=Xb(pe,Oe,_);L(null),H?X(H):w()},Ae=async _=>{const H=await D(_);if(!H||!j)return H;const ae=f.find(Me=>Me.id===_)?.commentId;return ae&&(f.some(Me=>Me.id!==_&&Me.commentId===ae)||(ce===ae&&L(null),(S===ae||k===ae)&&w())),H},$=async()=>{await y()&&j&&(L(null),w())},Pe=_=>{_!==m&&(L(null),w(),b(_))},Je=_=>{_!==ue&&(L(null),w(),ke(_))},wt=()=>{L(null),w()},xe=_=>{wt(),re.size===1&&re.has(_)&&J(!1),we(H=>{const ae=new Set(H);return ae.has(_)?ae.delete(_):ae.add(_),ae})};return t?a.jsxs(a.Fragment,{children:[a.jsx(ja,{className:"resize-handle"}),a.jsx(oi,{id:"context",order:4,defaultSize:20,minSize:15,maxSize:38,children:a.jsxs("aside",{className:"context-panel",children:[t==="comments"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"drawer-title",children:[a.jsx("strong",{children:te("editor.sourceComments")}),a.jsxs("span",{className:"drawer-title-actions",children:[f.length>0&&a.jsxs("button",{className:"drawer-mention-read-all",type:"button",onClick:()=>{$()},title:te("editor.markAllMentionsRead"),children:[a.jsx(Ps,{"aria-hidden":!0,size:13}),a.jsx("span",{children:te("editor.markAllMentionsRead")})]}),a.jsx("button",{"aria-label":te("common.close"),onClick:e,children:a.jsx(In,{size:17})})]})]}),a.jsxs("div",{className:"comment-review-controls",children:[a.jsxs("div",{className:"comment-review-queue-row",children:[g&&a.jsxs("div",{className:"comment-review-group",role:"group","aria-label":te("editor.commentScope"),children:[a.jsx("button",{type:"button",className:m==="file"?"active":"","aria-pressed":m==="file",onClick:()=>Pe("file"),children:te("editor.commentScopeFile")}),a.jsx("button",{type:"button",className:m==="project"?"active":"","aria-pressed":m==="project",onClick:()=>Pe("project"),children:te("editor.commentScopeProject")})]}),a.jsxs("div",{className:"comment-review-group",role:"group","aria-label":te("editor.commentFilter"),children:[a.jsx("button",{type:"button",className:ue==="unresolved"?"active":"","aria-pressed":ue==="unresolved",onClick:()=>Je("unresolved"),children:te("editor.commentFilterUnresolved",{count:Ne.unresolved})}),a.jsx("button",{type:"button",className:ue==="resolved"?"active":"","aria-pressed":ue==="resolved",onClick:()=>Je("resolved"),children:te("editor.commentFilterResolved",{count:Ne.resolved})})]}),a.jsxs("div",{className:"comment-review-navigation",children:[a.jsx("button",{type:"button",disabled:de<=1,"aria-label":te("editor.commentPrevious"),title:te("editor.commentPrevious"),onClick:()=>be(-1),children:a.jsx(Hw,{size:14})}),a.jsx("output",{"aria-live":"polite",children:te("editor.commentPosition",{current:de,total:pe.length})}),a.jsx("button",{type:"button",disabled:pe.length===0||de>0&&de>=pe.length,"aria-label":te("editor.commentNext"),title:te("editor.commentNext"),onClick:()=>be(1),children:a.jsx(_a,{size:14})})]})]}),a.jsxs("div",{className:"comment-review-sort-row",children:[a.jsx(ID,{participants:_e,selectedIds:re,topLevelOnly:Ee,onToggle:xe,onClear:()=>{wt(),we(new Set),J(!1)},onTopLevelOnlyChange:_=>{wt(),J(_)}},`${m}:${m==="file"?p:"project"}`),a.jsxs("button",{type:"button",className:`comment-unread-toggle${j?" active":""}`,"aria-pressed":j,"aria-label":te("editor.commentUnreadMentionsHint"),title:te("editor.commentUnreadMentionsHint"),onClick:()=>{wt(),Y(_=>!_)},children:[a.jsx(Ps,{size:12,"aria-hidden":!0}),te("editor.commentUnreadMentionsOnly"),a.jsx("span",{children:Ne.mentions})]}),a.jsxs("label",{className:"comment-review-sort","data-texlite-tooltip-always":!0,"data-tooltip":te(le==="source"?"editor.commentSortSource":"editor.commentSortTime"),children:[a.jsx("span",{className:"sr-only",children:te("editor.commentSort")}),le==="source"?a.jsx(Yw,{size:12,"aria-hidden":!0}):a.jsx(Xw,{size:12,"aria-hidden":!0}),a.jsxs("select",{value:le,"aria-label":`${te("editor.commentSort")}: ${te(le==="source"?"editor.commentSortSource":"editor.commentSortTime")}`,onChange:_=>Re(_.target.value),children:[a.jsx("option",{value:"source",children:te("editor.commentSortSourceShort")}),a.jsx("option",{value:"time",children:te("editor.commentSortTimeShort")})]})]})]})]}),d&&a.jsxs("div",{className:"comment-review-error",role:"alert",children:[a.jsx("span",{children:d}),a.jsx("button",{type:"button",onClick:()=>{h()},children:te("common.retry")})]}),l&&a.jsx("div",{className:"comment-review-loading",role:"status",children:te("common.loading")}),a.jsxs("div",{className:"comments",children:[pe.map(_=>{const H=f.find(De=>De.commentId===_.id&&!De.replyId)?.id,ae=new Map(f.filter(De=>De.commentId===_.id&&De.replyId).map(De=>[De.replyId,De.id]));return a.jsx(GR,{projectId:r,comment:_,currentUserId:i,unreadCommentMentionId:H,unreadReplyMentionIds:ae,highlightedComment:k===_.id&&!v,highlightedReplyId:k===_.id?v:null,currentComment:Oe===_.id,showFilePath:m==="project",selectedParticipantIds:re,highlightReplyParticipants:!Ee,onMarkMentionRead:Ae,onFocus:()=>X(_),onToggle:()=>{ne(_)},onReply:De=>N(_,De),onEdit:De=>U(_,De),onDelete:()=>K(_),onEditReply:(De,Me)=>T(_,De,Me),onDeleteReply:De=>q(_,De)},_.id)}),pe.length===0&&!l&&!d&&a.jsx("p",{className:"muted padded",children:c.length?te("editor.commentNoMatches"):te("editor.noComments")})]})]}),t==="settings"&&a.jsx(Pw,{onClose:e,children:a.jsx($D,{onClose:e,project:n,projectId:r,site:s,files:o,dictionaryWords:B,onDictionaryChange:W,editorPreferences:z,onEditorPreferences:Z,spellCheckCount:I,spellCheckUniqueCount:V,spellCheckIndex:G,onSpellCheckNavigate:Q,onProject:Ce},r)})]})})]}):null}function zD(t){if(typeof globalThis.requestAnimationFrame=="function"){const n=globalThis.requestAnimationFrame(t);return()=>globalThis.cancelAnimationFrame(n)}const e=globalThis.setTimeout(t,0);return()=>globalThis.clearTimeout(e)}function BD(){let t={line:1,column:1,offset:0},e=t.line,n=null,r=null;const s=new Set,o=()=>{for(const l of s)l()},i=()=>{r=null;const l=n;n=null,!(l===null||l===e)&&(e=l,o())},c=l=>{n=l,r===null&&(r=zD(i))};return{getCursor:()=>t,getOutlineLine:()=>e,subscribe:l=>(s.add(l),()=>s.delete(l)),update:(l,d,h)=>{t.line===l&&t.column===d&&t.offset===h||(t={line:l,column:d,offset:h},(l!==e||r!==null)&&c(l))},reset:()=>{r?.(),r=null,n=null,t={line:1,column:1,offset:0},e!==1&&(e=1,o())},dispose:()=>{r?.(),r=null,n=null}}}function WD(t,e,n){return t.mainFile===e?t.items:!e||n.filePath!==e?[]:VD(n.content).map(r=>({...r,path:e}))}function VD(t){const e=[],n=/^\s*\\(part|chapter|section|subsection|subsubsection)\*?(?:\[[^\]]*\])?\{([^}]*)\}/,r={part:0,chapter:0,section:1,subsection:2,subsubsection:3};return t.split(`
|
|
20
|
+
`).forEach((s,o)=>{const i=s.match(n);i&&e.push({level:r[i[1]],title:i[2],line:o+1})}),e}const HD=u.lazy(()=>Nt(()=>import("./WordCountDialog-sr21g-ex.js"),__vite__mapDeps([29,2,1,3,27,5,4,6,7,8]),import.meta.url).then(t=>({default:t.WordCountDialog})));let Do=null;function ef(){return Do||(Do=Nt(()=>import("./citationLibrary-ZeQPCv5O.js"),[],import.meta.url).catch(t=>{throw Do=null,t})),Do}function pn(t){return t instanceof Error&&t.name==="AbortError"}const tf=300;function qD({site:t,user:e,projectId:n,preload:r,mentionId:s=null,onMentionTargeted:o,onMentionsRead:i,onBack:c}){const{t:l}=tt(),d=u.useRef(n);d.current=n;const[h,f]=u.useState(null);u.useEffect(()=>(document.title=h?.name?`${t.siteName} | ${h.name}`:t.siteName,()=>{document.title=t.siteName}),[h?.name,t.siteName]);const[p,g]=u.useState(!1),[m,b]=u.useState([]),[S,C]=u.useState(null),[D,y]=u.useState({mainFile:"",items:[]}),[w,k]=u.useState(""),[v,R]=u.useState(""),[A,N]=u.useState(""),[U,K]=u.useState({filePath:"",content:""}),[T,q]=u.useState({path:"",hasIncludes:!1}),[B,W]=u.useState(""),[z,Z]=u.useState(!1),[I,V]=u.useState("editor.saved"),[G,Q]=u.useState(null),Ce=u.useRef(G);Ce.current=G;const te=u.useRef(null);te.current||(te.current=BD());const ue=te.current,[ke,j]=u.useState("pdf"),[Y,le]=u.useState("log"),Re=x=>{if(x==="pdf"){j("pdf");return}if(x==="diagnostics"){j("diagnostics");return}le(x),j("diagnostics")},{workspaceLayout:re,setWorkspaceLayout:we}=I0(e.id,n),[Ee,J]=u.useState(""),[ce,L]=u.useState(""),[_e,Ne]=u.useState({selectedText:"",startOffset:0,endOffset:0}),pe=u.useRef({selectedText:"",startOffset:0,endOffset:0}),Oe=x=>{const E=pe.current;E.selectedText===x.selectedText&&E.startOffset===x.startOffset&&E.endOffset===x.endOffset||(pe.current=x,Ne(x))},[de,X]=u.useState(null),[ne,be]=u.useState(null),[Ae,$]=u.useState(null),[Pe,Je]=u.useState(null),[wt,xe]=u.useState(!1),[_,H]=u.useState(!1),[ae,De]=u.useState(!1),[Me,rt]=u.useState(!1),[Ke,ve]=u.useState(null),[Gt,ee]=u.useState(!1),[O,P]=u.useState(null),[oe,ht]=u.useState(!1),[bt,Dn]=u.useState(!1),[ln,Jt]=u.useState(!1),[jr,Rt]=u.useState("full"),[Ai,je]=u.useState(""),[Jn,Ti]=u.useState(!1),[Dg,Oi]=u.useState(""),[jg,Li]=u.useState(null),[gs,_r]=u.useState(!1),[Yn,un]=u.useState(null),[_g,Ni]=u.useState(!1),[dt,Fl]=u.useState(()=>Nu(e.id,n));u.useEffect(()=>{const x=document.documentElement,E=dt.showTooltips?"on":"off";return x.setAttribute("data-texlite-tooltips",E),()=>{x.getAttribute("data-texlite-tooltips")===E&&x.removeAttribute("data-texlite-tooltips")}},[dt.showTooltips]);const[Pr,so]=u.useState([]),jn=u.useRef([]);jn.current=Pr;const Pg=u.useRef(null),oo=u.useRef(null),io=u.useRef(0),Mi=u.useRef(0),Fe=u.useRef(""),pt=u.useRef(""),Il=u.useRef(()=>{}),Fi=u.useRef(re),$l=u.useRef(0),Xn=u.useRef(null),Ul=u.useRef(null),Zn=u.useRef(null),Qn=u.useRef(null),Ar=u.useRef(null),Tr=u.useRef(null),Or=u.useRef(null),_n=u.useRef(null),Ii=u.useRef(null),dn=u.useRef(!1),Pn=u.useRef(null),zl=u.useRef(c),$i=u.useRef(o),Ui=u.useRef(i);zl.current=c,$i.current=o,Ui.current=i,Fe.current=w,pt.current=v,Fi.current=re,u.useEffect(()=>{if(!ce)return;const x=window.setTimeout(()=>L(""),3e3);return()=>window.clearTimeout(x)},[ce]);const Ag=u.useCallback((x,E,M=0)=>{ue.update(x,E,M)},[ue]);u.useEffect(()=>()=>ue.dispose(),[ue]),u.useEffect(()=>()=>{_n.current?.abort(),_n.current=null},[]);const co=x=>{const E=jn.current,M=x(E);M!==E&&(jn.current=M,so(M))};u.useEffect(()=>{jn.current=[],so([]),un(null),ve(null),Tr.current?.abort(),Tr.current=null,Or.current?.abort(),Or.current=null,_n.current?.abort(),_n.current=null,Ii.current=null,be(null),$(null),Je(null),Jt(!1),Ti(!1),Oi(""),Li(null)},[n]);const Bl=x=>{const E=jn.current,M=E.indexOf(x);if(M<0)return;const F=E.filter(ie=>ie!==x);if(jn.current=F,so(F),Fe.current!==x)return;const he=F.length>0?F[Math.min(M,F.length-1)]:h?.mainFile??"";k(he)},{collaboration:Be,status:ao,synced:Ye,activeSessions:Wl,formatLeaseStates:Tg,compileState:er,setCompileState:Vl,filesEvent:Xe,commentsRevision:Hl,historyWarning:Og,dictionaryRevision:ql,chktexSettingsRevision:Kl,localDraftReady:Gl,permission:zi,reconnect:Lg,protocolUpgradeRequired:Jl,permissionDowngrade:Ng,dismissPermissionDowngrade:Mg,discardLocalDraft:Fg}=R0(n,e,v,h?.permission??"read",p,()=>V("editor.offlineDraft")),{unreadMentions:Yl,refresh:Ig,markMentionRead:$g,markAllMentionsRead:Ug}=Qb(n,Hl,J),{pdfTarget:zg,pdfViewport:Bg,sourceJump:Wg,setPdfViewport:Vg,resetPdfViewport:Hg,clearPdfViewport:Xl,jumpToSource:Lr,syncSourceToPdf:Bi,syncPdfToSource:qg,syncVisiblePdfToSource:Kg}=F0({projectId:n,mainFile:v,activeFile:w,onOpenSourceFile:x=>Il.current(x),onError:J,onShowPdf:()=>Re("pdf"),onShowEditor:()=>{Fi.current==="pdf-only"&&we("editor-pdf")}}),Zl=!!(h&&h.chktexEnabled&&w&&Ye&&Ed(w)),tr=M0({active:Zl,projectId:n,activeFile:w,content:A}),Gg=!!(h&&w&&Ye&&$0(w)&&(dt.spellCheck||h.chktexEnabled&&Ed(w))),Dt=N0({active:Gg,harperEnabled:dt.spellCheck,projectId:n,activeFile:w,content:A,dictionaryWords:m,additionalIssues:tr.issues,additionalIssuesReady:!Zl||tr.checked});u.useEffect(()=>{Fl(Nu(e.id,n))},[e.id,n]);const Wi=x=>{N(x)};u.useEffect(()=>{if(!w||B!==w){K(F=>F.filePath||F.content?{filePath:"",content:""}:F);return}const x=w,E=A,M=window.setTimeout(()=>{K(F=>F.filePath===x&&F.content===E?F:{filePath:x,content:E})},tf);return()=>window.clearTimeout(M)},[w,B,A]),u.useEffect(()=>{if(Fe.current=w,ue.reset(),Oe({selectedText:"",startOffset:0,endOffset:0}),!dt.openFilesInTabs){jn.current.length>0&&(jn.current=[],so([]));return}w&&co(x=>x.includes(w)?x:[...x,w])},[w,dt.openFilesInTabs,n,ue]),u.useEffect(()=>{if(!z)return;const x=E=>{E.preventDefault(),E.returnValue=""};return window.addEventListener("beforeunload",x),()=>window.removeEventListener("beforeunload",x)},[z]),u.useEffect(()=>{if(ao!=="disconnected")return;const x=new AbortController;return ye(`/api/projects/${n}`,{signal:x.signal}).then(({project:E})=>{x.signal.aborted||(f(E),J(""))}).catch(E=>{if(!pn(E)){if(E instanceof Mc&&[401,403,404].includes(E.status)){J(ge(E)),zl.current();return}J(l("errors.collaborationUnavailable"))}}),()=>x.abort()},[ao,n,l]);const lo=async(x={},E=pt.current)=>{Xn.current?.abort(),Xn.current=null;const M=x.signal?null:new AbortController;M&&(Xn.current=M);try{const F=E?`?mainFile=${encodeURIComponent(E)}`:"",he=await ye(`/api/projects/${n}/completions${F}`,{signal:x.signal??M?.signal});(!x.isCurrent||x.isCurrent())&&C(he.index)}catch(F){if(pn(F))return;(!x.isCurrent||x.isCurrent())&&C(null)}finally{M&&Xn.current===M&&(Xn.current=null)}},Vi=async(x={},E=pt.current)=>{Zn.current?.abort(),Zn.current=null;const M=x.signal?null:new AbortController;M&&(Zn.current=M);try{const F=E?`?mainFile=${encodeURIComponent(E)}`:"",he=await ye(`/api/projects/${n}/outline${F}`,{signal:x.signal??M?.signal});(!x.isCurrent||x.isCurrent())&&pt.current===E&&y({mainFile:E,items:he.outline})}catch(F){if(pn(F))return}finally{M&&Zn.current===M&&(Zn.current=null)}},Ql=async(x={})=>{Qn.current?.abort(),Qn.current=null;const E=x.signal?null:new AbortController;E&&(Qn.current=E);try{const M=await ye(`/api/projects/${n}/dictionary`,{signal:x.signal??E?.signal});(!x.isCurrent||x.isCurrent())&&b(M.words)}catch(M){if(pn(M))return;(!x.isCurrent||x.isCurrent())&&b([])}finally{E&&Qn.current===E&&(Qn.current=null)}};u.useEffect(()=>{let x=!1;const E=++$l.current,M=new AbortController,F=()=>!x&&$l.current===E;let he=!1,ie="";f(null),nu([]),y({mainFile:"",items:[]}),k(""),R(""),q({path:"",hasIncludes:!1}),N(""),W(""),Vl(null),Xl(),C(null),b([]),nf();const fe=(r?.projectId===n?r.project:ye(`/api/projects/${n}`,{signal:M.signal})).then(Ze=>{F()&&(he=!0,ie=Ze.project.mainFile,f(Ze.project),k(Ze.project.mainFile),pt.current=Ze.project.mainFile,R(Ze.project.mainFile),ho(new Set(ur(Ze.project.mainFile))))}).catch(Ze=>{F()&&J(ge(Ze))}),Yt=ye(`/api/projects/${n}/files`,{signal:M.signal}).then(Ze=>{F()&&nu(Ze.files)}).catch(Ze=>{F()&&J(ge(Ze))});let St=null;return Promise.allSettled([fe,Yt]).then(()=>{!F()||!he||(St=window.setTimeout(()=>{F()&&Promise.all([lo({signal:M.signal,isCurrent:F},pt.current||ie),Ql({signal:M.signal,isCurrent:F})])},0))}),()=>{x=!0,St!==null&&window.clearTimeout(St),M.abort(),Xn.current?.abort(),Xn.current=null,Zn.current?.abort(),Zn.current=null,Qn.current?.abort(),Qn.current=null,Ar.current?.abort(),Ar.current=null}},[n,r]),u.useEffect(()=>{if(!(!h||!v)){if(Ul.current!==n){Ul.current=n;return}lo({},v)}},[v,h?.id,n]),u.useEffect(()=>{if(!s||!h)return;Or.current?.abort();const x=new AbortController;return Or.current=x,ye(`/api/projects/${n}/mentions/${encodeURIComponent(s)}`,{signal:x.signal}).then(({mention:E})=>{x.signal.aborted||(be(E),X("comments"),k(E.filePath),$i.current?.(E.id))}).catch(E=>{pn(E)||x.signal.aborted||(J(ge(E)),$i.current?.(s))}).finally(()=>{Or.current===x&&(Or.current=null)}),()=>x.abort()},[s,h?.id,n]),u.useEffect(()=>{ql&&Ql()},[ql,n]),u.useEffect(()=>{if(!Kl)return;const x=new AbortController;return ye(`/api/projects/${n}`,{signal:x.signal}).then(({project:E})=>{x.signal.aborted||f(M=>M?{...M,chktexEnabled:E.chktexEnabled}:E)}).catch(E=>{pn(E)||J(ge(E))}),()=>x.abort()},[Kl,n]),u.useEffect(()=>{!h||ao!=="connected"||zi===h.permission||f(x=>x&&{...x,permission:zi})},[zi,h?.permission]),u.useEffect(()=>{if(!Xe)return;const x=Xe.kind==="delete"&&!!Xe.path&&sr(Xe.path,Fe.current),E=Xe.kind==="delete"&&!!Xe.path&&sr(Xe.path,pt.current);if(Xe.kind==="move"&&Xe.source&&Xe.destination){const F=Xe.source,he=Xe.destination,ie=fe=>fe===F?he:fe.startsWith(`${F}/`)?`${he}${fe.slice(F.length)}`:fe;k(fe=>ie(fe)),R(fe=>ie(fe)),ws(fe=>fe&&ie(fe)),fo(fe=>fe&&ie(fe)),co(fe=>fe.map(ie))}x&&(k(""),W(""),Wi(""),L(l("editor.fileDeletedByCollaborator",{path:Xe.path}))),Xe.kind==="delete"&&Xe.path&&(ws(F=>F&&sr(Xe.path,F)?null:F),fo(F=>sr(Xe.path,F)?"":F),ou(F=>F&&sr(Xe.path,F.path)?null:F),co(F=>F.filter(he=>!sr(Xe.path,he)))),Ar.current?.abort();const M=new AbortController;Ar.current=M,Promise.all([Qg({signal:M.signal}),ye(`/api/projects/${n}`,{signal:M.signal})]).then(([F,he])=>{if(f(he.project),E&&R(he.project.mainFile),x&&F){const ie=F.find(fe=>fe.type==="file"&&fe.path===he.project.mainFile)??F.find(fe=>fe.type==="file"&&Xr(fe.path));k(ie?.path??"")}lo({signal:M.signal}),Vi({signal:M.signal},E?he.project.mainFile:pt.current)}).catch(F=>{pn(F)}).finally(()=>{Ar.current===M&&(Ar.current=null)})},[Xe?.revision]),u.useEffect(()=>{if(Be.setActiveFile(w),!w)return;W(""),V("editor.loading");const x=Be.getText(w),E=(M,F)=>{Wi(x.toString()),W(w),F?.local&&h?.permission!=="read"?(io.current+=1,Z(!0),V("editor.pending")):io.current<=Mi.current&&V(Ce.current?"editor.savedAt":"editor.saved")};return x.observe(E),(Ye||Gl)&&E(),()=>{x.unobserve(E)}},[w,Be,Ye,Gl,h?.permission]);const uo=async()=>{if(!Ye)throw new Error("Collaboration is not synchronized");const x=io.current,E=await Be.flush();return Mi.current=Math.max(Mi.current,x),Q(E.persistedAt),/\.tex$/i.test(Fe.current)&&Vi(),io.current===x?(Z(!1),V("editor.savedAt")):V("editor.pending"),E};u.useEffect(()=>{if(!z||!w)return;if(!Ye){V("editor.offlineDraft");return}V("editor.pending");const x=window.setTimeout(()=>{V("editor.saving"),uo().catch(()=>{V(Be.connected?"editor.saveFailed":"editor.offlineDraft")})},750);return()=>window.clearTimeout(x)},[A,z,w,Ye]);const ys=async()=>{if(!h||h.permission==="read"||!Ye||!w)return!1;V("editor.saving");try{return await uo(),lo(),!0}catch(x){return V("editor.saveFailed"),J(ge(x)||l("errors.collaborationUnavailable")),!1}},Jg=async x=>{if(!h||Jn)return;const E=x==="full"?pt.current||h.mainFile:Fe.current,M=x==="selection"?pe.current.selectedText:"";if(!E)return;if(x==="selection"&&(!M.trim()||!/\.(?:tex|sty|cls)$/i.test(E))){L(l("editor.wordCountSelectionEmpty"));return}Tr.current?.abort();const F=new AbortController;Tr.current=F,Rt(x),je(E),Li(null),Oi(""),Jt(!0),Ti(!0);try{if(x==="full"&&z&&h.permission!=="read"&&!await ys())throw new Error(l("editor.wordCountSaveRequired"));const he=x==="selection"?{mode:x,path:E,source:M}:{mode:x,mainFile:E},ie=await ye(`/api/projects/${n}/word-count`,{method:"POST",body:JSON.stringify(he),signal:F.signal});if(F.signal.aborted)return;Li(ie)}catch(he){if(pn(he))return;F.signal.aborted||Oi(ge(he))}finally{Tr.current===F&&(Tr.current=null,Ti(!1))}},Hi=async(x,E,M=dt.texFmtConfig)=>{if(/\.bib$/i.test(x)){const he=await ef();try{return{formatted:he.formatBibtex(E,t.maxCitationBibtexBytes)}}catch(ie){throw ie instanceof he.BibtexFormatError?ie.kind==="too-large"?new Error(l("citationLibrary.fileTooLarge",{size:he.citationBibtexLimitLabel(t.maxCitationBibtexBytes)})):new Error(l("citationLibrary.fileInvalid")):ie}}return{formatted:(await Cb(E,M)).output}},eu=async x=>{if(!h||h.permission==="read"||!Ye||dn.current||!go(Fe.current))return;const E=Fe.current,M=Be.getText(E);dn.current=!0,_r(!0);let F=()=>{};const he=new Promise(fe=>{F=fe});Pn.current=he;let ie=null;try{ie=await Be.acquireFormatLease(E);const fe=M.toString(),{formatted:Yt}=await Hi(E,fe,x);if(Fe.current!==E||M.toString()!==fe){J(l("editor.formatSourceChanged"));return}await ie.confirm();const St=await oc(fe,Yt);if(Fe.current!==E||M.toString()!==fe){J(l("editor.formatSourceChanged"));return}if(await ie.confirm(),Fe.current!==E||M.toString()!==fe){J(l("editor.formatSourceChanged"));return}St.length&&Be.applyTextEdits(E,St),St.length&&await uo(),un(null),J(""),L(l("editor.formatFileComplete"))}catch(fe){sc(fe)?(un({action:"file",kind:fe.kind,detail:fe.message}),J("")):J(l("editor.formatFileFailed",{message:ge(fe)}))}finally{ie&&await ie.release(),dn.current=!1,_r(!1),F(),Pn.current===he&&(Pn.current=null)}},Yg=async()=>{if(!dt.formatOnCompile||!h||h.permission==="read"||!Ye||!go(Fe.current)||dn.current)return;const x=Fe.current,E=Be.getText(x);dn.current=!0,_r(!0);let M=null;try{M=await Be.acquireFormatLease(x);const F=E.toString(),{formatted:he}=await Hi(x,F);await M.confirm();const ie=await oc(F,he);if(Fe.current!==x||E.toString()!==F)throw new Error(l("editor.formatSourceChanged"));if(await M.confirm(),Fe.current!==x||E.toString()!==F)throw new Error(l("editor.formatSourceChanged"));ie.length&&Be.applyTextEdits(x,ie),ie.length&&await Be.flush(),un(null)}catch(F){sc(F)?(un({action:"file",kind:F.kind,detail:F.message}),J("")):J(l("editor.formatFailedContinue",{message:ge(F)}))}finally{M&&await M.release(),dn.current=!1,_r(!1)}},Xg=async()=>(Pn.current&&await Pn.current,await Yg(),ys()),tu=async x=>{if(!h||h.permission==="read"||!Ye||dn.current||!go(Fe.current))return;const E=pe.current;if(!E.selectedText.trim()){L(l("editor.formatSelectionRequired"));return}const M=Fe.current,{startOffset:F,endOffset:he,selectedText:ie}=E,fe=Be.getText(M);if(fe.toString().slice(F,he)!==ie){J(l("editor.formatSelectionChanged"));return}dn.current=!0,_r(!0);let Yt=()=>{};const St=new Promise(fn=>{Yt=fn});Pn.current=St;let Ze=null;try{if(Ze=await Be.acquireFormatLease(M),fe.toString().slice(F,he)!==ie){J(l("editor.formatSelectionChanged"));return}const Ss=await Hi(M,ie,x),kw=Rb(ie,Ss.formatted);await Ze.confirm();const rc=await oc(ie,kw,F);if(Fe.current!==M||fe.toString().slice(F,he)!==ie){J(l("editor.formatSelectionChanged"));return}if(await Ze.confirm(),Fe.current!==M||fe.toString().slice(F,he)!==ie){J(l("editor.formatSelectionChanged"));return}rc.length&&Be.applyTextEdits(M,rc),rc.length&&await uo(),un(null),J(""),L(l("editor.formatSelectionComplete"))}catch(fn){sc(fn)?(un({action:"selection",kind:fn.kind,detail:fn.message}),J("")):J(l("editor.formatFailed",{message:ge(fn)}))}finally{Ze&&await Ze.release(),dn.current=!1,_r(!1),Yt(),Pn.current===St&&(Pn.current=null)}},Zg=async x=>{const E=Fe.current;if(!/\.bib$/i.test(E)||h?.permission==="read"||!Ye)return L(l("citationLibrary.importRequiresWrite")),!1;const M=Be.getText(E);let F;try{F=await ef()}catch(Ss){return J(ge(Ss)),!1}if(Fe.current!==E||!Ye)return!1;const he=M.toString(),ie=F.parseBibEntriesResult(he,t.maxCitationBibtexBytes);if(ie.status==="too-large")return L(l("citationLibrary.fileTooLarge",{size:F.citationBibtexLimitLabel(t.maxCitationBibtexBytes)})),!1;if(ie.status==="invalid")return L(l("citationLibrary.fileInvalid")),!1;if(ie.entries.some(Ss=>Ss.citationKey.toLowerCase()===x.citationKey.toLowerCase()))return L(l("citationErrors.alreadyInFile",{key:x.citationKey})),!1;const fe=Math.max(0,Math.min(he.length,ue.getCursor().offset)),Yt=he.slice(0,fe),St=he.slice(fe),Ze=Yt?Yt.endsWith(`
|
|
21
|
+
|
|
22
|
+
`)?"":Yt.endsWith(`
|
|
23
|
+
`)?`
|
|
24
|
+
`:`
|
|
25
|
+
|
|
26
|
+
`:"",fn=St?St.startsWith(`
|
|
27
|
+
|
|
28
|
+
`)?"":St.startsWith(`
|
|
29
|
+
`)?`
|
|
30
|
+
`:`
|
|
31
|
+
|
|
32
|
+
`:"";return Be.applyTextEdits(E,[{from:fe,to:fe,replacement:`${Ze}${x.bibtex.trim()}${fn}`}]),L(l("citationLibrary.imported",{key:x.citationKey})),!0},{files:Bt,setFiles:nu,loadFiles:Qg,newFileOpen:ey,setNewFileOpen:ru,newFilePath:ty,setNewFilePath:su,resourcePreview:ny,setResourcePreview:ou,resourcePreviewLoading:ry,setResourcePreviewLoading:sy,newFolderOpen:oy,setNewFolderOpen:iu,newFolderName:iy,setNewFolderName:cu,fileDialogError:cy,setFileDialogError:au,selectedFolder:lu,setSelectedFolder:ws,selectedFile:ay,setSelectedFile:fo,expandedFolders:ly,setExpandedFolders:ho,moveEntry:uy,setMoveEntry:uu,moveName:dy,setMoveName:du,moveDestination:fy,setMoveDestination:fu,deleteEntry:qi,setDeleteEntry:hu,fileDragActive:hy,setFileDragActive:py,uploadConflict:my,setUploadConflict:gy,uploadingFiles:yy,uploadFeedback:wy,dismissUploadFeedback:pu,directoryEntries:by,visibleEntries:xy,createFile:vy,createFolder:Sy,uploadFiles:mu,upload:Cy,openFile:Ki,movePath:Ey,movePathToFolder:ky,removePath:Ry}=O0({projectId:n,site:t,activeFile:w,dirty:z,save:ys,onError:J,onProject:f,onActiveFile:k,onActiveMainFile:R});Il.current=x=>{ws(null),fo(x),ho(E=>new Set([...E,...ur(x)])),k(x)};const Dy=x=>{if(x.id!==d.current)return;const E=x.mainFile!==h?.mainFile;f(x),E&&(pt.current=x.mainFile,Fe.current=x.mainFile,R(x.mainFile),k(x.mainFile),ws(null),fo(x.mainFile),ho(M=>new Set([...M,...ur(x.mainFile)])))},gu=()=>pt.current||h?.mainFile||"",jy=()=>{const x=gu(),E=Fe.current;if(!E||!/\.tex$/i.test(E))return x;const M=Bt.filter(ie=>ie.type==="file"&&/\.tex$/i.test(ie.path)).length,F=Be.getText(E).toString();return Dd(F)||M===1?(x!==E&&(pt.current=E,R(E)),E):x===E&&h?.mainFile&&h.mainFile!==E?(pt.current=h.mainFile,R(h.mainFile),h.mainFile):x};u.useEffect(()=>{!w||w!==v||B!==w||U.filePath!==w||!w.toLocaleLowerCase().endsWith(".tex")||Bt.filter(E=>E.type==="file"&&/\.tex$/i.test(E.path)).length===0||w===h?.mainFile||!Dd(U.content)&&h?.mainFile&&(pt.current=h.mainFile,R(h.mainFile))},[w,v,B,U,Bt,h?.mainFile]),u.useEffect(()=>{if(!dt.openFilesInTabs||Bt.length===0)return;const x=new Set(Bt.filter(E=>E.type==="file"&&Xr(E.path)).map(E=>E.path));co(E=>{const M=E.filter(F=>x.has(F));return M.length===E.length?E:M})},[Bt,dt.openFilesInTabs]);const{comments:nr,commentsFilePath:Gi,commentsReady:Ji,reviewComments:_y,reviewCommentsLoading:Py,reviewCommentsError:Ay,retryReviewComments:Ty,commentScope:Oy,setCommentScope:Ly,focusComment:yu,setFocusComment:bs,commentOpen:Ny,openComment:My,closeComment:Fy,commentText:Iy,setCommentText:$y,commentSelection:Uy,commentSubmitting:zy,commentError:By,addComment:Wy,toggleComment:Vy,replyToComment:Hy,editComment:qy,deleteComment:Ky,editCommentReply:Gy,deleteCommentReply:Jy}=Bb({projectId:n,activeFile:w,content:A,permission:h?.permission,revision:Hl,selection:_e,save:ys,saveFailureMessage:l("errors.collaborationUnavailable"),onError:J,onAdded:()=>X("comments"),onChanged:()=>{Ig()}});u.useEffect(()=>{if(!v||U.filePath!==v)return;const x=jd(U.content).length>0;q(E=>E.path===v&&E.hasIncludes===x?E:{path:v,hasIncludes:x})},[v,U]),u.useEffect(()=>{if(!v||!Ye||w===v)return;const x=Be.getText(v);let E=null;const M=()=>{const he=jd(x.toString()).length>0;q(ie=>ie.path===v&&ie.hasIncludes===he?ie:{path:v,hasIncludes:he})},F=()=>{E!==null&&window.clearTimeout(E),E=window.setTimeout(()=>{E=null,M()},tf)};return M(),x.observe(F),()=>{E!==null&&window.clearTimeout(E),x.unobserve(F)}},[w,v,Be,Ye]);const Yy=u.useMemo(()=>T.path===v&&T.hasIncludes,[v,T]),wu=x=>{Je(null),X("comments"),bs(null),$(x),Fe.current!==x.filePath&&Lr(x.filePath,x.startLine,1)},Xy=x=>{const E=nr.find(M=>M.id===x&&M.filePath===w);!E||E.resolved||E.orphaned||($(null),bs(null),be(null),Je(M=>({id:E.id,filePath:E.filePath,nonce:(M?.nonce??0)+1})),X("comments"))};u.useEffect(()=>{Je(null)},[w]),u.useEffect(()=>{if(!Ae)return;const x=Gb(Ae,w,B,Gi,Ji,nr);if(x){bs({...x}),$(null);return}Ae.filePath===w&&B===w&&Gi===w&&Ji&&$(null)},[w,nr,Gi,Ji,B,Ae,bs]);const Zy=async x=>{const E=await $g(x);return E&&Ui.current?.(1),E},Qy=async()=>{const x=Yl.length,E=await Ug();return E&&x&&Ui.current?.(x,!0),E};u.useEffect(()=>{if(!ne||w!==ne.filePath||de!=="comments")return;const x=nr.find(M=>M.id===ne.commentId);if(!x||ne.replyId&&!x.replies.some(M=>M.id===ne.replyId)||Ii.current===ne.id)return;Ii.current=ne.id,wu(x);const E=window.setTimeout(()=>be(M=>M?.id===ne.id?null:M),3e3);return()=>window.clearTimeout(E)},[w,nr,de,ne]);const{pdfUrl:An,pdfCompiledAt:xs,pdfSizeBytes:ew,pdfLoadingMode:tw,pdfLoading:Yi,compileLog:Xi,compileDiagnostics:nw,compileOutcome:vs,artifacts:bu,artifactPreview:rw,artifactLoading:sw,editorNotice:ow,localCompiling:xu,cancelling:iw,cleaning:vu,compile:cw,cancelCompile:aw,cleanCompile:Su,viewArtifact:lw}=_0({projectId:n,project:h,mainFile:v,resolveCompileMainFile:jy,getCurrentMainFile:gu,initialLatest:r?.projectId===n?r.latestCompile:null,collaborationSynced:Ye,sharedState:er,onSharedState:Vl,save:Xg,loadOutline:(x,E)=>Vi({signal:x},E),onPreviewTab:Re,onError:J,onCompileStart:()=>{J(""),L("")},onCompileSuccess:()=>{const x=Fe.current;if(x){const E=ue.getCursor();Bi(x,E.line,E.column,{silent:!0})}},onPdfChanged:Xl});u.useEffect(()=>{if(!h||!v||!An&&Yi)return;const x=window.setTimeout(()=>g(!0),An?150:0);return()=>window.clearTimeout(x)},[h,Yi,An]),u.useEffect(()=>{const x=E=>{(E.ctrlKey||E.metaKey)&&(!E.shiftKey&&E.key.toLocaleLowerCase()==="p"?(E.preventDefault(),ht(!0)):E.shiftKey&&E.key.toLocaleLowerCase()==="f"&&(E.preventDefault(),Dn(!0)))};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[]);const Cu=x=>{Fl(x),wb(e.id,n,x)},Eu=(x=!1)=>{const E=Yn;if(!E)return;un(null),J(""),x&&Cu({...dt,texFmtConfig:""});const M=x?"":void 0;E.action==="selection"?tu(M):eu(M)},uw=async()=>{Ni(!0);try{await Fg()||(J(l("editor.collaboration.permissionDowngradeOtherTabBlocked")),Ni(!1))}catch(x){J(ge(x)),Ni(!1)}},ku=()=>{oo.current?.isCollapsed()?oo.current.expand():oo.current?.collapse()},dw=u.useMemo(()=>WD(D,v,U),[D,v,U]),Zi=u.useMemo(()=>Db(Xi,vs),[Xi,vs]),Nr=re!=="pdf-only",Ru=re!=="editor-only",po=x=>{we(x),x==="pdf-only"&&Re("pdf")},fw=u.useCallback(x=>{_n.current?.abort();const E=new AbortController;_n.current=E;const M=Fe.current,F=pt.current,he=new URLSearchParams({kind:x.kind,key:x.key,...M?{path:M}:{},...F?{mainFile:F}:{}});ye(`/api/projects/${n}/references/resolve?${he}`,{signal:E.signal}).then(({target:ie})=>{if(!(E.signal.aborted||Fe.current!==M||pt.current!==F)){if(!ie){J(l(x.kind==="citation"?"editor.citationTargetNotFound":"editor.labelTargetNotFound",{key:x.key}));return}Fi.current==="pdf-only"&&po("editor-pdf"),Lr(ie.path,ie.line,ie.column)}}).catch(ie=>{!E.signal.aborted&&!pn(ie)&&J(ge(ie))}).finally(()=>{_n.current===E&&(_n.current=null)})},[Lr,n,l]),hw=qi?Wl.filter(x=>x.filePath&&sr(qi.path,x.filePath)):[];if(!h)return a.jsxs("div",{className:"center-card",children:[a.jsx("p",{children:Ee||l("common.loading")}),Ee&&a.jsx("button",{className:"primary",onClick:c,children:l("editor.backToProjects")})]});const Tn=h.permission==="read"||!Ye,Qi=Tg.find(x=>x.path===w),ec=Qi&&!gs?Qi:null,pw=(x,E)=>{if(Tn)return;const M=Fe.current;if(!M)return;if(Be.getText(M).toString().slice(x.from,x.to)!==x.word){J(l("editor.spellCheckSourceChanged"));return}try{Be.applyTextEdits(M,[{from:x.from,to:x.to,replacement:E}])}catch(ie){J(ge(ie))}},tc=er?.mainFile===v&&(er.status==="queued"||er.status==="running"),mo=xu||tc||vu,mw=w?Be.getText(w):null,gw=xs?new Date(xs).toLocaleString(Rs.resolvedLanguage,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"",yw=v.split("/").at(-1)??v,ww=Zi.warnings.length+Zi.errors.length+bu.length,bw=An?`${An}${An.includes("?")?"&":"?"}download=1`:"",nc=v||h.mainFile,xw=!!(w&&w===nc&&/\.tex$/i.test(w)),vw=!!(nc&&/\.tex$/i.test(nc)),Du=x=>{const E=Bt.find(M=>M.path===x);E&&Xr(E.path)?Ki(E):Bl(x)},Sw=x=>{document.getElementById(`editor-tab-${encodeURIComponent(x)}`)?.focus()},Cw=(x,E)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(x.key))return;x.preventDefault();const M=x.key==="Home"?0:x.key==="End"?Pr.length-1:(E+(x.key==="ArrowLeft"?-1:1)+Pr.length)%Pr.length,F=Pr[M];F&&(Du(F),window.requestAnimationFrame(()=>Sw(F)))},ju=mo?tc?er?.status==="queued"?l("editor.compileQueued"):l("editor.compilingBy",{name:er?.requestedBy.name??l("common.user")}):l("editor.compiling"):vs==="failed"?An&&xs?l("editor.compileFailedRetained",{time:new Date(xs).toLocaleString(Rs.resolvedLanguage)}):l("editor.compileFailedNoPdf"):vs==="cancelled"?l("compileControls.cancelled"):"",Ew=I==="editor.savedAt"&&G?l("editor.savedAt",{time:new Date(G).toLocaleTimeString(Rs.resolvedLanguage,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}):l(I);return a.jsxs("div",{className:"workspace","data-texlite-tooltips":dt.showTooltips?"on":"off",children:[a.jsx(rE,{site:t,project:h,activeFile:w,saveStateLabel:Ew,editorPreferences:dt,activeSessions:Wl,collaborationStatus:ao,reconnectCollaboration:Lg,protocolUpgradeRequired:Jl,showEditor:Nr,filesCollapsed:wt,toggleFilesPanel:ku,workspaceLayout:re,changeWorkspaceLayout:po,onBack:c,onShare:()=>H(!0),showCitationLibrary:Nr&&/\.bib$/i.test(w),citationLibraryOpen:Gt,onCitationLibrary:()=>ee(!0),onHistory:()=>rt(!0),onGit:()=>De(!0),canManageGit:h.ownerId===e.id,formatting:gs,readOnly:Tn,collaborationSynced:Ye,onToggleComments:()=>X(de==="comments"?null:"comments"),commentsOpen:de==="comments",unresolvedCommentCount:nr.filter(x=>!x.resolved).length,onToggleSettings:()=>X(de==="settings"?null:"settings"),settingsOpen:de==="settings",compileBusy:mo,sharedCompiling:tc,localCompiling:xu,cancelling:iw,compileState:er,onCompile:cw,onCancelCompile:()=>{aw()}}),Jl&&a.jsxs("div",{className:"workspace-update-banner",role:"alert",children:[a.jsx(Vt,{size:15}),a.jsx("span",{children:l("workspaceUpdates.protocolUpgrade")}),a.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:l("common.reload")})]}),ju&&a.jsxs("div",{className:`compile-status-strip${vs==="failed"?" failed":""}`,role:"status","aria-live":"polite",children:[a.jsx(gt,{className:mo?"spin":"",size:14}),a.jsx("span",{children:ju})]}),(Dt.error||tr.error||Yn||ec)&&a.jsxs("div",{className:"client-tool-recoveries",children:[Dt.error&&a.jsxs("div",{className:"client-tool-recovery",role:"alert",title:Dt.error,children:[a.jsx(Vt,{size:15}),a.jsxs("span",{children:[a.jsx("strong",{children:l("editor.harperRecoveryTitle")}),l("editor.harperFallbackHint")]}),a.jsx("div",{className:"client-tool-recovery-actions",children:a.jsx("button",{type:"button",onClick:Dt.retry,children:l("common.retry")})}),a.jsx("button",{type:"button",className:"formatter-diagnostics-dismiss",title:l("common.close"),"aria-label":l("common.close"),onClick:Dt.dismissError,children:a.jsx(In,{size:13})})]}),tr.error&&a.jsxs("div",{className:"client-tool-recovery",role:"alert",title:tr.error,children:[a.jsx(Vt,{size:15}),a.jsxs("span",{children:[a.jsx("strong",{children:l("chktex.recoveryTitle")}),l("chktex.recoveryHint")]}),a.jsx("div",{className:"client-tool-recovery-actions",children:a.jsx("button",{type:"button",onClick:tr.retry,children:l("common.retry")})}),a.jsx("button",{type:"button",className:"formatter-diagnostics-dismiss",title:l("common.close"),"aria-label":l("common.close"),onClick:tr.dismissError,children:a.jsx(In,{size:13})})]}),Yn&&a.jsxs("div",{className:"client-tool-recovery",role:"alert",title:Yn.detail,children:[a.jsx(Vt,{size:15}),a.jsxs("span",{children:[a.jsx("strong",{children:l(Yn.kind==="format"?"editor.texFmtOptionsRecoveryTitle":Yn.kind==="load"?"editor.texFmtRecoveryTitle":"editor.texFmtRuntimeRecoveryTitle")}),l("editor.clientToolRecoveryHint")]}),a.jsxs("div",{className:"client-tool-recovery-actions",children:[a.jsx("button",{type:"button",disabled:gs||Tn,onClick:()=>Eu(),children:l("common.retry")}),Yn.kind==="format"&&dt.texFmtConfig.trim()&&a.jsx("button",{type:"button",disabled:gs||Tn,onClick:()=>Eu(!0),children:l("editor.resetFormatterOptions")}),a.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:l("common.reload")})]}),a.jsx("button",{type:"button",className:"formatter-diagnostics-dismiss",title:l("common.close"),"aria-label":l("common.close"),onClick:()=>un(null),children:a.jsx(In,{size:13})})]}),ec&&a.jsxs("div",{className:"client-tool-recovery format-lease-status",role:"status",children:[a.jsx(gt,{className:"spin",size:15}),a.jsx("span",{children:l("editor.formattingBy",{name:ec.holderName})})]})]}),Og&&a.jsxs("div",{className:"client-tool-recovery",role:"status",children:[a.jsx(Vt,{size:15}),a.jsx("span",{children:l("history.saveWarning")})]}),Ee&&a.jsx("div",{className:"toast",onClick:()=>J(""),children:Ee}),ce&&a.jsx("div",{className:"toast success",onClick:()=>L(""),children:ce}),a.jsxs(Aw,{autoSaveId:cr("texlite-workspace-layout"),direction:"horizontal",className:"work-grid",children:[Nr&&a.jsx(yE,{project:h,filesPanel:oo,files:Bt,visibleEntries:xy,activeFile:w,activeMainFile:v,selectedFile:ay,selectedFolder:lu,expandedFolders:ly,fileDragActive:hy,uploadingFiles:yy,uploadFeedback:wy,readOnly:Tn,formatting:gs,canFormat:go(w),activeFormatLease:!!Qi,collaborationSynced:Ye,editorFontSize:dt.fontSize,outline:dw,sourceCursorStore:ue,wordCountBusy:Jn,hasSelection:!!_e.selectedText.trim()&&/\.(?:tex|sty|cls)$/i.test(w),hasFormatSelection:!!_e.selectedText.trim(),uploadInput:Pg,setSelectedFolder:ws,setExpandedFolders:ho,setMoveEntry:uu,setMoveName:du,setMoveDestination:fu,setDeleteEntry:hu,setFileDialogError:au,setNewFolderName:cu,setNewFolderOpen:iu,setNewFilePath:su,setNewFileOpen:ru,setQuickOpen:ht,setProjectSearchOpen:Dn,setFileDragActive:py,dismissUploadFeedback:pu,setFilesCollapsed:xe,toggleFilesPanel:ku,onError:J,uploadFiles:mu,upload:Cy,openFile:Ki,movePathToFolder:ky,onFormatFile:()=>{eu()},onFormatSelection:()=>{tu()},jumpToSource:Lr,syncSourceToPdf:Bi,onWordCount:x=>{Jg(x)}}),Nr&&a.jsx(ja,{className:"resize-handle",children:a.jsx(uf,{size:12})}),Nr&&a.jsx(EE,{project:h,activeFile:w,openTabs:Pr,content:A,loadedFile:B,readOnly:Tn,comments:nr,focusComment:yu,editorPreferences:dt,completionIndex:S,nativeSpellCheck:Dt.nativeFallback,spellCheckIssues:Dt.issues,spellCheckJump:Dt.jump,sourceJump:Wg,collaborativeText:mw,collaborationAwareness:Be.awareness,undoManager:w?Be.getUndoManager(w):void 0,editorNotice:ow,activateTab:Du,closeTab:Bl,handleTabKeyDown:Cw,updateEditorContent:Wi,setSelection:(x,E,M)=>Oe({selectedText:x,startOffset:E,endOffset:M}),onAddComment:(x,E,M,F)=>My({selectedText:x,startOffset:E,endOffset:M},F),onSelectionHistory:(x,E,M,F)=>{ve({filePath:w,selection:{selectedText:x,startOffset:E,endOffset:M},source:F})},onCommentClick:Xy,onSpellCheckReplace:pw,onReferenceNavigate:fw,onCursor:Ag}),Ru&&a.jsx(PE,{projectId:n,activeMainFile:v,previewTab:ke,diagnosticTab:Y,pdfUrl:An,pdfLoadingMode:tw,pdfLoading:Yi,pdfCompiledAt:xs,pdfSizeBytes:ew,pdfCompiledLabel:gw,pdfTargetLabel:yw,pdfDownloadUrl:bw,pdfTarget:zg,pdfViewport:Bg,activeFile:w,compileBusy:mo,compileLog:Xi,compileDiagnostics:nw,compileMessages:Zi,artifacts:bu,artifactPreview:rw,artifactLoading:sw,cleaning:vu,readOnly:Tn,collaborationSynced:Ye,workspaceLayout:re,showSyncResize:Nr&&Ru,diagnosticCount:ww,selectPreviewTab:Re,changeWorkspaceLayout:po,onSetNotice:L,onSetPdfViewport:Vg,onResetPdfViewport:Hg,syncVisiblePdfToSource:Kg,syncCurrentSourceToPdf:()=>{const x=Fe.current;if(!x)return Promise.resolve();const E=ue.getCursor();return Bi(x,E.line,E.column)},syncPdfToSource:qg,canSyncWithPdf:xw,canSyncPdfToSource:vw,files:Bt,jumpToSource:Lr,onSetCleanMode:P,cleanCompile:Su,viewArtifact:lw}),a.jsx(UD,{sidePanel:de,onClose:()=>X(null),project:h,projectId:n,site:t,files:Bt,currentUserId:e.id,comments:_y,commentsLoading:Py,commentsError:Ay,onRetryComments:Ty,activeFile:w,hasProjectCommentsScope:Yy,commentScope:Oy,onCommentScopeChange:Ly,focusedCommentId:Pe?.filePath===w?Pe.id:yu?.id,commentFocusNonce:Pe?.nonce,onClearFocusComment:()=>{Je(null),bs(null),be(null)},unreadMentions:Yl,onMarkMentionRead:Zy,onMarkAllMentionsRead:Qy,targetCommentId:ne?.commentId,targetReplyId:ne?.replyId,onFocusComment:wu,onToggleComment:Vy,onReplyComment:Hy,onEditComment:qy,onDeleteComment:Ky,onEditCommentReply:Gy,onDeleteCommentReply:Jy,dictionaryWords:m,onDictionaryChange:b,editorPreferences:dt,onEditorPreferences:Cu,spellCheckCount:Dt.summary?.total??null,spellCheckUniqueCount:Dt.summary?.unique??null,spellCheckIndex:Dt.summary?Dt.index:-1,onSpellCheckNavigate:Dt.jumpToIssue,onProject:Dy},n)]}),ln&&a.jsx(of,{title:l("editor.wordCountTitle"),onClose:()=>Jt(!1),children:a.jsx(HD,{open:!0,mode:jr,path:Ai,busy:Jn,error:Dg,result:jg,onOpenChange:Jt})}),a.jsx(nD,{user:e,project:h,projectId:n,activeFile:w,content:A,maxCitationBibtexBytes:t.maxCitationBibtexBytes,files:Bt,directoryEntries:by,readOnly:Tn,workspaceLayout:re,changeWorkspaceLayout:po,resourcePreview:ny,resourcePreviewLoading:ry,setResourcePreview:ou,setResourcePreviewLoading:sy,uploadConflict:my,setUploadConflict:gy,dismissUploadFeedback:pu,uploadFiles:mu,cleanMode:O,setCleanMode:P,cleanCompile:Su,newFileOpen:ey,setNewFileOpen:ru,newFilePath:ty,setNewFilePath:su,newFolderOpen:oy,setNewFolderOpen:iu,newFolderName:iy,setNewFolderName:cu,selectedFolder:lu,fileDialogError:cy,setFileDialogError:au,createFile:vy,createFolder:Sy,moveEntry:uy,setMoveEntry:uu,moveName:dy,setMoveName:du,moveDestination:fy,setMoveDestination:fu,movePath:Ey,deleteEntry:qi,setDeleteEntry:hu,deleteActiveSessions:hw,removePath:Ry,commentOpen:Ny,closeComment:Fy,commentSelection:Uy,commentText:Iy,setCommentText:$y,commentSubmitting:zy,commentError:By,addComment:Wy,shareOpen:_,setShareOpen:H,citationLibraryOpen:Gt,setCitationLibraryOpen:ee,insertCitationAtCursor:Zg,quickOpen:oe,setQuickOpen:ht,projectSearchOpen:bt,setProjectSearchOpen:Dn,openFile:Ki,jumpToSource:Lr,selectionHistoryTarget:Ke,closeSelectionHistory:()=>ve(null),historyOpen:Me,setHistoryOpen:rt,gitOpen:ae,setGitOpen:De,save:ys,permissionDowngrade:Ng,permissionDowngradeBusy:_g,dismissPermissionDowngrade:Mg,discardPermissionDraft:uw})]})}const xj=Object.freeze(Object.defineProperty({__proto__:null,ProjectWorkspace:qD},Symbol.toStringTag,{value:"Module"}));export{ej as A,lf as B,ci as C,zb as D,Nn as E,Qw as F,Eb as G,Tu as H,mb as I,Uc as J,Jw as K,tj as L,xj as P,hb as R,Lu as S,_S as U,Ed as a,oj as b,Qc as c,ij as d,cj as e,aj as f,vr as g,nj as h,hn as i,tp as j,z0 as k,fl as l,Ma as m,lj as n,hs as o,Qs as p,Qo as q,sj as r,$0 as s,rj as t,Z0 as u,uj as v,sa as w,V0 as x,ra as y,H0 as z};
|