@inkeep/open-knowledge 0.30.0-beta.3 → 0.30.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/cli.mjs +7 -7
  4. package/dist/config-schema.json +24 -0
  5. package/dist/config.project-local.schema.json +24 -0
  6. package/dist/constants-UBjBavXu.mjs +2 -0
  7. package/dist/{dist-DJ0wJimx.mjs → dist-B5JbDwWb.mjs} +1 -1
  8. package/dist/{dist-DAVo_TRx.mjs → dist-DXIG2Jyg.mjs} +7 -7
  9. package/dist/{gh-detect-BxDh8M_E.mjs → gh-detect-BMbpd_Yj.mjs} +2 -2
  10. package/dist/index.mjs +1 -1
  11. package/dist/{init-Cj3rYYNW.mjs → init-CkBE_apM.mjs} +3 -3
  12. package/dist/init-CoL8N4la.mjs +1 -0
  13. package/dist/{launch-json-removal-Bsd2If9V.mjs → launch-json-removal-YtOryh7V.mjs} +2 -2
  14. package/dist/{loader-DBQRSW23.mjs → loader-BOmEZv00.mjs} +2 -2
  15. package/dist/loader-eceKqMkc.mjs +1 -0
  16. package/dist/{open-browser-6ztGUs93.mjs → open-browser-gwoFcjXN.mjs} +2 -2
  17. package/dist/{preview-4_TQ2eLW.mjs → preview-CJm1A1UQ.mjs} +2 -2
  18. package/dist/preview-DHkr2cX1.mjs +1 -0
  19. package/dist/public/assets/{ActivityModeContent-gJPRToqC.js → ActivityModeContent-C0_GSBuC.js} +1 -1
  20. package/dist/public/assets/{CodeMirrorPropInput-A-b7Ox39.js → CodeMirrorPropInput-C2VECyjO.js} +2 -2
  21. package/dist/public/assets/{DocumentContext-Cf3xyIUc.js → DocumentContext-f6XQqg_y.js} +2 -2
  22. package/dist/public/assets/{EnableSyncConfirmDialog-Ds9VzFz7.js → EnableSyncConfirmDialog-BhwhYBFL.js} +1 -1
  23. package/dist/public/assets/{GraphPanel-DticGDW4.js → GraphPanel-ByzLo6-b.js} +1 -1
  24. package/dist/public/assets/{ManagedArtifactProperties-BG7ax3pN.js → ManagedArtifactProperties-DAzdDsOt.js} +1 -1
  25. package/dist/public/assets/{McpConsentDialogBody-jKfEiUIH.js → McpConsentDialogBody-BwDo5LSJ.js} +1 -1
  26. package/dist/public/assets/{MermaidDocEditor-B_WSq6De.js → MermaidDocEditor-BpnOw4CA.js} +1 -1
  27. package/dist/public/assets/{PropertyPanel-JSTiSMvX.js → PropertyPanel-B3wmhQBT.js} +1 -1
  28. package/dist/public/assets/{SettingsDialogBody-C4mvHDJH.js → SettingsDialogBody-DVvKGL9J.js} +1 -1
  29. package/dist/public/assets/{ShareBranchSwitchDialog-2z9NWmqe.js → ShareBranchSwitchDialog-i35Gg8js.js} +1 -1
  30. package/dist/public/assets/{ShareReceiveDialog-CGSDsgBh.js → ShareReceiveDialog-LrK6Us6O.js} +1 -1
  31. package/dist/public/assets/{ShareReceiveMissDialog-D7zjXalK.js → ShareReceiveMissDialog-CEV0ExUm.js} +1 -1
  32. package/dist/public/assets/{SkillEditorActions-CxGse8tc.js → SkillEditorActions-BoEoI6NN.js} +1 -1
  33. package/dist/public/assets/{SourceEditor-B4hGDoTR.js → SourceEditor-DuPpY_T6.js} +1 -1
  34. package/dist/public/assets/{TerminalPanel-B3CcTB8S.js → TerminalPanel-Di7sR9_K.js} +1 -1
  35. package/dist/public/assets/{agent-presence-DJQje6SV.js → agent-presence-DOgDiPgh.js} +1 -1
  36. package/dist/public/assets/{auth-state-cache-DyKWS3xm.js → auth-state-cache-CZRVpVW6.js} +1 -1
  37. package/dist/public/assets/{config-provider-D0CfBIwU.js → config-provider-BnOnKhga.js} +1 -1
  38. package/dist/public/assets/{dist-CJc7OX7s.js → dist-D7PDymSy.js} +2 -2
  39. package/dist/public/assets/{dist-DoFKRM_F.js → dist-xdRBzARh.js} +1 -1
  40. package/dist/public/assets/{doc-hash-B7rSgZqz.js → doc-hash-i5oNLfum.js} +1 -1
  41. package/dist/public/assets/{documents-events-Bit0pJeY.js → documents-events-D26lhbOZ.js} +1 -1
  42. package/dist/public/assets/file-tree-adapter-N1FVhfKw.js +1 -0
  43. package/dist/public/assets/index-KSKNKDpJ.js +2003 -0
  44. package/dist/public/assets/{keyboard-shortcuts-CvYXgqK4.js → keyboard-shortcuts-Bgozgsx2.js} +1 -1
  45. package/dist/public/assets/navigation-targets-D_wZddL9.js +1 -0
  46. package/dist/public/assets/{open-managed-artifact-tab-Da7L5wL4.js → open-managed-artifact-tab-kOn8WHrp.js} +1 -1
  47. package/dist/public/assets/{pending-receive-nav-store-CAm5nHeI.js → pending-receive-nav-store-CDyGvnwD.js} +1 -1
  48. package/dist/public/assets/{prop-types-BwJNmxtq.js → prop-types-BK5m4zFC.js} +1 -1
  49. package/dist/public/assets/{receive-store-C72xSCDE.js → receive-store-Jc3PEGIh.js} +1 -1
  50. package/dist/public/assets/{selection-context-JPA-xW1g.js → selection-context-72mLve4s.js} +1 -1
  51. package/dist/public/assets/{skill-actions-CMd77Yt2.js → skill-actions-CeU8Dbpm.js} +1 -1
  52. package/dist/public/assets/{skills-api-UoasHTUi.js → skills-api-k47WvkqQ.js} +1 -1
  53. package/dist/public/assets/{src-CXdmKAqZ.js → src-B6vksAtW.js} +1 -1
  54. package/dist/public/assets/{target-navigation-intent-C_Y-i35d.js → target-navigation-intent-DEwTup1R.js} +1 -1
  55. package/dist/public/assets/{typing-burst-detector-DLup_S3P.js → typing-burst-detector-BC1YUpwK.js} +1 -1
  56. package/dist/public/assets/{workspace-paths-CYa5l8eZ.js → workspace-paths-D4weWrbA.js} +1 -1
  57. package/dist/public/index.html +25 -25
  58. package/dist/{repair-launch-json-CtA3dzno.mjs → repair-launch-json-DO2QDHDR.mjs} +2 -2
  59. package/dist/{repair-mcp-configs-DP4ZjS6O.mjs → repair-mcp-configs-RYSmTXdj.mjs} +2 -2
  60. package/dist/{repair-skills-zutt1is6.mjs → repair-skills-BrAdfxB-.mjs} +2 -2
  61. package/dist/repair-skills-NtsjF26d.mjs +1 -0
  62. package/dist/schemas/v0/config.project-local.schema.json +24 -0
  63. package/dist/server-lock-GuuouVft-CXM0Fdz7.mjs +1 -0
  64. package/dist/{server-lock-iLcBw_q0-RDMfTH6b.mjs → server-lock-iLcBw_q0-DB1Ahu2b.mjs} +3 -3
  65. package/dist/{src-Z7vZvOn3.mjs → src-2ZRymDy2.mjs} +2 -2
  66. package/dist/{start-B1VS-wwf.mjs → start-CR2-ryWz.mjs} +2 -2
  67. package/dist/start-D2aYJnFK.mjs +1 -0
  68. package/dist/{write-project-skill-BzVHToYO.mjs → write-project-skill-XZCJ5TEZ.mjs} +2 -2
  69. package/package.json +1 -1
  70. package/dist/constants-CgHcIqh6.mjs +0 -2
  71. package/dist/init-CNK7GfhY.mjs +0 -1
  72. package/dist/loader-BkadQueQ.mjs +0 -1
  73. package/dist/preview-4uaPC3tK.mjs +0 -1
  74. package/dist/public/assets/file-tree-adapter--v55j77z.js +0 -1
  75. package/dist/public/assets/index--kgVY3Zd.js +0 -2003
  76. package/dist/public/assets/navigation-targets-D-taKoGj.js +0 -1
  77. package/dist/repair-skills-B0TdudPZ.mjs +0 -1
  78. package/dist/server-lock-GuuouVft-CCnjEa8y.mjs +0 -1
  79. package/dist/start-DGO0EIO_.mjs +0 -1
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./pdf-WLEpkBFf.js","./preload-helper-2ej06EnG.js"])))=>i.map(i=>d[i]);
2
- import{o as e,t}from"./chunk-CFjPhJqf.js";import{t as n}from"./preload-helper-2ej06EnG.js";import{n as r,r as i,t as a}from"./compiler-runtime-CVnuRdak.js";import{n as o,r as s}from"./dist-CQw2y-s3.js";import{n as c}from"./dist-BVOt51sU.js";import{t as l}from"./react-dom-C-oc-P2K.js";import{$ as u,$n as d,$r as f,Ai as p,An as m,At as h,B as g,Bn as _,Br as v,Ci as y,Di as b,Ei as x,En as S,Et as C,Fi as w,Fn as T,G as E,Gn as D,Gr as O,H as k,Hn as A,Ii as j,In as M,J as N,Ji as P,Jn as F,K as I,Kn as L,Kt as R,L as ee,Li as z,Ln as te,Lr as ne,Mn as re,Nn as B,Oi as V,On as H,Pn as U,Pt as W,Q as G,Qr as ie,Ri as K,Rn as ae,Rr as oe,S as q,Si as se,Sn as ce,Ti as J,Tr as le,U as ue,Ur as Y,V as de,Vr as fe,Wi as pe,Wr as me,Wt as he,Xi as ge,Xt as _e,Yi as ve,Yn as ye,Yr as be,Zn as xe,Zr as Se,_i as Ce,_n as we,_r as Te,ai as Ee,ar as De,b as Oe,bi as ke,br as Ae,c as je,cn as Me,ct as Ne,d as Pe,dt as Fe,ei as Ie,er as Le,f as Re,fi as ze,fr as Be,ft as Ve,gr as He,hi as Ue,hn as We,ht as Ge,ir as Ke,it as qe,jn as Je,jt as Ye,kn as Xe,kr as Ze,kt as Qe,l as $e,li as et,ln as tt,lr as nt,mi as rt,mn as it,mt as at,ni as ot,oi as st,q as ct,qt as lt,rn as ut,rr as dt,rt as ft,s as pt,sr as mt,tr as ht,u as gt,ui as _t,un as vt,ut as yt,vi as bt,vn as xt,wi as St,wn as Ct,xi as wt,y as Tt,yi as Et,yr as Dt,z as Ot,zr as kt}from"./dist-CJc7OX7s.js";import{t as At}from"./trace-api-D6fqC5Nw.js";import{n as jt,t as Mt}from"./propagation-api-BHhJitgG.js";import{a as Nt,c as Pt,i as Ft,l as It,o as Lt,r as Rt,t as zt,u as Bt}from"./button-cneJOVxD.js";import{$ as Vt,A as Ht,B as Ut,C as Wt,G as Gt,H as Kt,I as qt,J as Jt,K as Yt,L as Xt,M as Zt,N as Qt,O as $t,P as en,R as tn,S as nn,U as rn,V as an,W as on,X as sn,Y as cn,Z as ln,_ as un,at as dn,b as fn,c as pn,d as mn,dt as hn,ft as gn,g as _n,gt as vn,h as yn,it as bn,j as xn,k as Sn,lt as Cn,m as wn,mt as Tn,n as En,nt as Dn,p as On,pt as kn,r as An,s as jn,t as Mn,tt as Nn,ut as Pn,v as Fn,w as In,y as Ln,yt as Rn,z as zn}from"./CodeMirrorPropInput-A-b7Ox39.js";import{t as Bn}from"./check-DRRCCRSs.js";import{t as Vn}from"./chevron-down-BvNcCN1f.js";import{t as Hn}from"./chevron-right-DSNnH-Vb.js";import{a as Un,i as Wn,o as Gn,r as Kn}from"./prop-types-BwJNmxtq.js";import{a as qn,d as Jn,f as Yn,l as Xn,r as Zn,t as Qn,u as $n}from"./workspace-paths-CYa5l8eZ.js";import{t as er}from"./eye-WB1l5kVb.js";import{t as tr}from"./folder-open-BF5DIykr.js";import{t as nr}from"./git-branch-q0qWPEwd.js";import{t as rr}from"./info-BlYnsVoP.js";import{t as ir}from"./loader-circle-B7Gv_Djz.js";import{t as ar}from"./trash-2-Dcpo0Di-.js";import{t as or}from"./triangle-alert-c3yCucJv.js";import{n as sr,r as cr}from"./dist-CoyydoqN.js";import{a as lr,c as ur,d as dr,i as fr,n as pr,o as mr,r as hr,s as gr,t as _r,u as vr}from"./dist-BSkHa6UR.js";import{a as yr,i as br,n as xr,t as Sr}from"./tooltip-FFg0kVkD.js";import{n as Cr,t as wr}from"./dist-Dkr4jGYv.js";import{n as Tr,r as Er,t as Dr}from"./collapsible-mJvufeMs.js";import{a as Or,c as kr,d as Ar,f as jr,g as Mr,h as Nr,i as Pr,l as Fr,m as Ir,n as Lr,o as Rr,p as zr,r as Br,s as Vr,t as Hr,u as Ur}from"./dialog-DdHaoAGK.js";import{t as Wr}from"./dist-BzWUi0nJ.js";import{a as Gr,i as Kr,n as qr,o as Jr,r as Yr,t as Xr}from"./dist-fpPv-rVb.js";import{a as Zr,d as Qr,i as $r,l as ei,r as ti,u as ni}from"./floating-ui.dom-DVRWCLii.js";import{t as ri}from"./input-tW78aNaR.js";import{t as ii}from"./parse-api-error-CqtA8BcL.js";import{t as ai}from"./dist-BvBijIC5.js";import{t as oi}from"./file-tree-rename-validation-DeKIxKnc.js";import{f as si,n as ci,u as li}from"./navigation-targets-D-taKoGj.js";import{n as ui,t as di}from"./documents-events-Bit0pJeY.js";import{a as X,o as fi,t as pi}from"./startup-marks-DDtA9pbt.js";import{c as mi,f as hi,h as gi,l as _i,n as vi,o as yi,r as bi,s as xi}from"./doc-hash-B7rSgZqz.js";import{$ as Si,A as Ci,C as wi,D as Ti,E as Ei,F as Di,G as Oi,I as ki,J as Ai,K as ji,L as Mi,M as Ni,N as Pi,O as Fi,Q as Ii,R as Li,S as Ri,T as zi,U as Bi,W as Vi,X as Hi,Y as Ui,Z as Wi,_ as Gi,a as Ki,at as qi,b as Ji,c as Yi,d as Xi,et as Zi,f as Qi,g as $i,h as ea,it as ta,j as na,k as ra,l as ia,m as aa,nt as oa,o as sa,ot as ca,p as la,q as ua,r as da,rt as fa,s as pa,tt as ma,u as ha,v as ga,w as _a,x as va,y as ya,z as ba}from"./config-provider-D0CfBIwU.js";import{Dt as xa,E as Sa,N as Ca,X as wa,c as Ta,dt as Ea,f as Da,l as Oa,ut as ka}from"./dist-Dot7Y1W_.js";import{t as Aa}from"./dist-sRKGD4vA.js";import{n as ja}from"./dist-ClYcK7Yq.js";import{n as Ma}from"./dist-DmkgvB1A.js";import{n as Na}from"./dist-COmtpu4e.js";import{n as Pa}from"./dist-Gaq2suxg.js";import{n as Fa}from"./dist-DYyQPSDl.js";import{t as Ia}from"./stex-4t0JIuX_.js";var Z=i();(function(){var e=[`user-blocking`,`user-visible`,`background`];class t{constructor(){this.t=new MessageChannel,this.i=this.t.port2,this.l={},this.o=1,this.t.port1.onmessage=e=>this.h(e)}u(e){var t=this.o++;return this.l[t]=e,this.i.postMessage(t),t}p(e){delete this.l[e]}h(e){var t=e.data;if(t in this.l){var n=this.l[t];delete this.l[t],n()}}}function n(){return n.v||=new t,n.v}class r{constructor(e,t,n){n===void 0&&(n=0),this.k=e,this.T=null,this.C=null,this.m=!1,this._(t,n)}isIdleCallback(){return this.T===0}I(){return this.T===2}cancel(){if(!this.m)switch(this.m=!0,this.T){case 0:cancelIdleCallback(this.C);break;case 1:clearTimeout(this.C);break;case 2:n().p(this.C);break;default:throw TypeError(`Unknown CallbackType`)}}_(t,r){if(r&&r>0)return this.T=1,void(this.C=setTimeout(()=>{this.P()},r));if(!e.includes(t))throw TypeError(`Invalid task priority : `+t);t===`background`&&typeof requestIdleCallback==`function`?(this.T=0,this.C=requestIdleCallback(()=>{this.P()})):typeof MessageChannel==`function`?(this.T=2,this.C=n().u(()=>{this.P()})):(this.T=1,this.C=setTimeout(()=>{this.P()}))}P(){this.m||this.k()}}var i=0;class a{constructor(){this.j=null,this.M=null}isEmpty(){return this.j==null}push(e){if(typeof e!=`object`)throw TypeError(`Task must be an Object`);e.A=i++,this.isEmpty()?(e.N=null,this.j=e):(e.N=this.M,this.M.O=e),e.O=null,this.M=e}takeNextTask(){if(this.isEmpty())return null;var e=this.j;return this.q(e),e}merge(e,t){if(typeof t!=`function`)throw TypeError(`Must provide a selector function.`);if(e==null)throw Error(`sourceQueue cannot be null`);for(var n=this.j,r=null,i=e.j;i;){var a=i;if(i=i.O,t(a)){for(e.q(a);n&&n.A<a.A;)r=n,n=n.O;this.D(a,r),r=a}}}D(e,t){if(t!=this.M){var n=t?t.O:this.j;e.O=n,n.N=e,e.N=t,t==null?this.j=e:t.O=e}else this.push(e)}q(e){if(e==null)throw Error(`Expected task to be non-null`);e===this.j&&(this.j=e.O),e===this.M&&(this.M=this.M.N),e.O&&(e.O.N=e.N),e.N&&(e.N.O=e.O)}}class o extends Event{constructor(t,n){if(!n||!e.includes(n.previousPriority))throw TypeError(`Invalid task priority: '`+n.previousPriority+`'`);super(t),this.previousPriority=n.previousPriority}}class s extends AbortController{constructor(t){if(t===void 0&&(t={}),super(),t??={},typeof t!=`object`)throw TypeError(`'init' is not an object`);var n,r,i=t.priority===void 0?`user-visible`:t.priority;if(!e.includes(i))throw TypeError(`Invalid task priority: '`+i+`'`);this.H=i,this.R=!1,r=(n=this).signal,Object.defineProperties(r,{priority:{get:function(){return n.H},enumerable:!0},onprioritychange:{value:null,writable:!0,enumerable:!0}}),r.addEventListener(`prioritychange`,e=>{r.onprioritychange&&r.onprioritychange(e)})}setPriority(t){if(!e.includes(t))throw TypeError(`Invalid task priority: `+t);if(this.R)throw new DOMException(``,`NotAllowedError`);if(this.signal.priority!==t){this.R=!0;var n=this.H;this.H=t;var r=new o(`prioritychange`,{previousPriority:n});this.signal.dispatchEvent(r),this.R=!1}}}self.scheduler===void 0?(self.scheduler=new class{constructor(){this.S={},e.forEach(e=>{this.S[e]=[new a,new a]}),this.U=null,this.W=new WeakMap}yield(){return this.B(()=>{},{priority:`user-visible`},!0)}postTask(e,t){return this.B(e,t,!1)}B(t,n,r){if((n=Object.assign({},n)).signal!==void 0){if(n.signal===null||!(`aborted`in n.signal)||typeof n.signal.addEventListener!=`function`)return Promise.reject(TypeError(`'signal' is not a valid 'AbortSignal'`));if(n.signal&&n.signal.priority&&!e.includes(n.signal.priority))return Promise.reject(TypeError(`Invalid task priority: '`+n.signal.priority+`'`))}if(n.priority!==void 0&&(n.priority===null||!e.includes(n.priority)))return Promise.reject(TypeError(`Invalid task priority: '`+n.priority+`'`));if(n.delay===void 0&&(n.delay=0),n.delay=Number(n.delay),n.delay<0)return Promise.reject(TypeError(`'delay' must be a positive number.`));var i={callback:t,options:n,resolve:null,reject:null,hostCallback:null,abortCallback:null,onTaskCompleted:function(){this.options.signal&&this.abortCallback&&(this.options.signal.removeEventListener(`abort`,this.abortCallback),this.abortCallback=null)},onTaskAborted:function(){this.hostCallback&&=(this.hostCallback.cancel(),null),this.options.signal.removeEventListener(`abort`,this.abortCallback),this.abortCallback=null,this.reject(this.options.signal.reason)},isAborted:function(){return this.options.signal&&this.options.signal.aborted},isContinuation:r},a=new Promise((e,t)=>{i.resolve=e,i.reject=t});return this._(i),a}_(e){var t=e.options.signal;if(t){if(t.aborted)return void e.reject(t.reason);e.abortCallback=()=>{e.onTaskAborted()},t.addEventListener(`abort`,e.abortCallback)}e.options.delay>0?e.hostCallback=new r(()=>{e.hostCallback=null,this.F(e)},null,e.options.delay):(this.G(e),this.J())}F(e){this.G(e),this.U&&=(this.U.cancel(),null),this.K()}L(e){var t=this.W.get(e);if(t===void 0)throw Error(`Attempting to change priority on an unregistered signal`);if(t!==e.priority){for(var n=0;n<2;n++)this.S[e.priority][n].merge(this.S[t][n],t=>t.options.signal===e);this.W.set(e,e.priority)}}K(){this.U=null,this.V(),this.J()}J(){var{priority:e}=this.X();e!=null&&(e!==`background`&&this.U&&this.U.isIdleCallback()&&(this.U.cancel(),this.U=null),this.U||=new r(()=>{this.K()},e,0))}G(t){var n;if(!e.includes(n=t.options.priority?t.options.priority:t.options.signal&&t.options.signal.priority?t.options.signal.priority:`user-visible`))throw TypeError(`Invalid task priority: `+n);if(t.options.signal&&t.options.signal.priority){var r=t.options.signal;this.W.has(r)||(r.addEventListener(`prioritychange`,()=>{this.L(r)}),this.W.set(r,r.priority))}this.S[n][+!t.isContinuation].push(t)}V(){var e=null;do{var{priority:t,type:n}=this.X();if(t==null)return;e=this.S[t][n].takeNextTask()}while(e.isAborted());try{var r=e.callback();e.resolve(r)}catch(t){e.reject(t)}finally{e.onTaskCompleted()}}X(){for(var t=0;t<e.length;t++)for(var n=e[t],r=0;r<2;r++)if(!this.S[n][r].isEmpty())return{priority:n,type:r};return{priority:null,type:0}}},self.TaskController=s,self.TaskPriorityChangeEvent=o):self.scheduler.yield||(self.scheduler.yield=function(){return self.scheduler.postTask(()=>{},{priority:`user-blocking`})})})();var La=Bt(`app-window`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),Ra=Bt(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),za=Bt(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),Ba=Bt(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),Va=Bt(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Ha=Bt(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Ua=Bt(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Wa=Bt(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ga=Bt(`circle-x`,[[`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`}]]),Ka=Bt(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),qa=Bt(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Ja=Bt(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ya=Bt(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),Xa=Bt(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Za=Bt(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Qa=Bt(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`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`}]]),$a=Bt(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),eo=Bt(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),to=Bt(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),no=Bt(`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`}]]),ro=Bt(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),io=Bt(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),ao=Bt(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),oo=Bt(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),so=Bt(`layout-panel-top`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}]]),co=Bt(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),lo=Bt(`link-2-off`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),uo=[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]],fo=Bt(`link-2`,uo),po=Bt(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),mo=Bt(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),ho=Bt(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),go=Bt(`message-square-warning`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]),_o=Bt(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),vo=Bt(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),yo=Bt(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),bo=Bt(`panel-top`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),xo=Bt(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),So=Bt(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Co=Bt(`quote`,[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]),wo=Bt(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),To=Bt(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Eo=Bt(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),Do=Bt(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Oo=Bt(`sigma`,[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]]),ko=Bt(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Ao=Bt(`square-play`,[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}]]),jo=Bt(`superscript`,[[`path`,{d:`m4 19 8-8`,key:`hr47gm`}],[`path`,{d:`m12 19-8-8`,key:`1dhhmo`}],[`path`,{d:`M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06`,key:`1dfcux`}]]),Mo=Bt(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),No=Bt(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Po=Bt(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),Fo=Bt(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),Q=e(r(),1),Io=e(l(),1);function Lo(e,[t,n]){return Math.min(n,Math.max(t,e))}var Ro=`Popover`,[zo,Bo]=vr(Ro,[Gr]),Vo=Gr(),[Ho,Uo]=zo(Ro),Wo=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Vo(t),c=Q.useRef(null),[l,u]=Q.useState(!1),[d,f]=mr({prop:r,defaultProp:i??!1,onChange:a,caller:Ro});return(0,Z.jsx)(Kr,{...s,children:(0,Z.jsx)(Ho,{scope:t,contentId:fr(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:Q.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:Q.useCallback(()=>u(!0),[]),onCustomAnchorRemove:Q.useCallback(()=>u(!1),[]),modal:o,children:n})})};Wo.displayName=Ro;var Go=`PopoverAnchor`,Ko=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Uo(Go,n),a=Vo(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return Q.useEffect(()=>(o(),()=>s()),[o,s]),(0,Z.jsx)(Xr,{...a,...r,ref:t})});Ko.displayName=Go;var qo=`PopoverTrigger`,Jo=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Uo(qo,n),a=Vo(n),o=It(t,i.triggerRef),s=(0,Z.jsx)(dr.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":ls(i.open),...r,ref:o,onClick:ur(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,Z.jsx)(Xr,{asChild:!0,...a,children:s})});Jo.displayName=qo;var Yo=`PopoverPortal`,[Xo,Zo]=zo(Yo,{forceMount:void 0}),Qo=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Uo(Yo,t);return(0,Z.jsx)(Xo,{scope:t,forceMount:n,children:(0,Z.jsx)(lr,{present:n||a.open,children:(0,Z.jsx)(_r,{asChild:!0,container:i,children:r})})})};Qo.displayName=Yo;var $o=`PopoverContent`,es=Q.forwardRef((e,t)=>{let n=Zo($o,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Uo($o,e.__scopePopover);return(0,Z.jsx)(lr,{present:r||a.open,children:a.modal?(0,Z.jsx)(ns,{...i,ref:t}):(0,Z.jsx)(rs,{...i,ref:t})})});es.displayName=$o;var ts=Lt(`PopoverContent.RemoveScroll`),ns=Q.forwardRef((e,t)=>{let n=Uo($o,e.__scopePopover),r=Q.useRef(null),i=It(t,r),a=Q.useRef(!1);return Q.useEffect(()=>{let e=r.current;if(e)return zr(e)},[]),(0,Z.jsx)(Ir,{as:ts,allowPinchZoom:!0,children:(0,Z.jsx)(is,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ur(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:ur(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:ur(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),rs=Q.forwardRef((e,t)=>{let n=Uo($o,e.__scopePopover),r=Q.useRef(!1),i=Q.useRef(!1);return(0,Z.jsx)(is,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),is=Q.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Uo($o,n),p=Vo(n);return Nr(),(0,Z.jsx)(Mr,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Z.jsx)(pr,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,Z.jsx)(Yr,{"data-state":ls(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),as=`PopoverClose`,os=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Uo(as,n);return(0,Z.jsx)(dr.button,{type:`button`,...r,ref:t,onClick:ur(e.onClick,()=>i.onOpenChange(!1))})});os.displayName=as;var ss=`PopoverArrow`,cs=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Vo(n);return(0,Z.jsx)(qr,{...i,...r,ref:t})});cs.displayName=ss;function ls(e){return e?`open`:`closed`}var us=Wo,ds=Ko,fs=Jo,ps=Qo,ms=es,hs=[` `,`Enter`,`ArrowUp`,`ArrowDown`],gs=[` `,`Enter`],_s=`Select`,[vs,ys,bs]=Cr(_s),[xs,Ss]=vr(_s,[bs,Gr]),Cs=Gr(),[ws,Ts]=xs(_s),[Es,Ds]=xs(_s),Os=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=Cs(t),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S=wr(l),[C,w]=mr({prop:r,defaultProp:i??!1,onChange:a,caller:_s}),[T,E]=mr({prop:o,defaultProp:s,onChange:c,caller:_s}),D=Q.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=Q.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,Z.jsx)(Kr,{...h,children:(0,Z.jsxs)(ws,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:fr(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,Z.jsx)(vs.Provider,{scope:t,children:(0,Z.jsx)(Es,{scope:e.__scopeSelect,onNativeOptionAdd:Q.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:Q.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,Z.jsxs)(Cc,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,Z.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};Os.displayName=_s;var ks=`SelectTrigger`,As=Q.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Cs(n),o=Ts(ks,n),s=o.disabled||r,c=It(t,o.onTriggerChange),l=ys(n),u=Q.useRef(`touch`),[d,f,p]=Tc(e=>{let t=l().filter(e=>!e.disabled),n=Ec(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,Z.jsx)(Xr,{asChild:!0,...a,children:(0,Z.jsx)(dr.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":wc(o.value)?``:void 0,...i,ref:c,onClick:ur(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:ur(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:ur(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&hs.includes(e.key)&&(m(),e.preventDefault())})})})});As.displayName=ks;var js=`SelectValue`,Ms=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Ts(js,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=It(t,c.onValueNodeChange);return gr(()=>{l(u)},[l,u]),(0,Z.jsx)(dr.span,{...s,ref:d,style:{pointerEvents:`none`},children:wc(c.value)?(0,Z.jsx)(Z.Fragment,{children:o}):a})});Ms.displayName=js;var Ns=`SelectIcon`,Ps=Q.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Z.jsx)(dr.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Ps.displayName=Ns;var Fs=`SelectPortal`,Is=e=>(0,Z.jsx)(_r,{asChild:!0,...e});Is.displayName=Fs;var Ls=`SelectContent`,Rs=Q.forwardRef((e,t)=>{let n=Ts(Ls,e.__scopeSelect),[r,i]=Q.useState();if(gr(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Io.createPortal((0,Z.jsx)(Bs,{scope:e.__scopeSelect,children:(0,Z.jsx)(vs.Slot,{scope:e.__scopeSelect,children:(0,Z.jsx)(`div`,{children:e.children})})}),t):null}return(0,Z.jsx)(Ws,{...e,ref:t})});Rs.displayName=Ls;var zs=10,[Bs,Vs]=xs(Ls),Hs=`SelectContentImpl`,Us=Lt(`SelectContent.RemoveScroll`),Ws=Q.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=Ts(Ls,n),[y,b]=Q.useState(null),[x,S]=Q.useState(null),C=It(t,e=>b(e)),[w,T]=Q.useState(null),[E,D]=Q.useState(null),O=ys(n),[k,A]=Q.useState(!1),j=Q.useRef(!1);Q.useEffect(()=>{if(y)return zr(y)},[y]),Nr();let M=Q.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=Q.useCallback(()=>M([w,y]),[M,w,y]);Q.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Q.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),Q.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[I,L]=Tc(e=>{let t=O().filter(e=>!e.disabled),n=Ec(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),R=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),ee=Q.useCallback(()=>y?.focus(),[y]),z=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),te=r===`popper`?Js:Ks,ne=te===Js?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Z.jsx)(Bs,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:R,selectedItem:w,onItemLeave:ee,itemTextRefCallback:z,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,Z.jsx)(Ir,{as:Us,allowPinchZoom:!0,children:(0,Z.jsx)(Mr,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:ur(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Z.jsx)(pr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,Z.jsx)(te,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...ne,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:ur(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&L(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})});Ws.displayName=Hs;var Gs=`SelectItemAlignedPosition`,Ks=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Ts(Ls,n),o=Vs(Ls,n),[s,c]=Q.useState(null),[l,u]=Q.useState(null),d=It(t,e=>u(e)),f=ys(n),p=Q.useRef(!1),m=Q.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Q.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-zs,d=Lo(a,[zs,Math.max(zs,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-zs,d=Lo(a,[zs,Math.max(zs,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-zs*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-zs,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${zs}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);gr(()=>y(),[y]);let[b,x]=Q.useState();return gr(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Z.jsx)(Ys,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Q.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,Z.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,Z.jsx)(dr.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Ks.displayName=Gs;var qs=`SelectPopperPosition`,Js=Q.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=zs,...a}=e,o=Cs(n);return(0,Z.jsx)(Yr,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Js.displayName=qs;var[Ys,Xs]=xs(Ls,{}),Zs=`SelectViewport`,Qs=Q.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Vs(Zs,n),o=Xs(Zs,n),s=It(t,a.onViewportChange),c=Q.useRef(0);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,Z.jsx)(vs.Slot,{scope:n,children:(0,Z.jsx)(dr.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:ur(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-zs*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Qs.displayName=Zs;var $s=`SelectGroup`,[ec,tc]=xs($s),nc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=fr();return(0,Z.jsx)(ec,{scope:n,id:i,children:(0,Z.jsx)(dr.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});nc.displayName=$s;var rc=`SelectLabel`,ic=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=tc(rc,n);return(0,Z.jsx)(dr.div,{id:i.id,...r,ref:t})});ic.displayName=rc;var ac=`SelectItem`,[oc,sc]=xs(ac),cc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Ts(ac,n),c=Vs(ac,n),l=s.value===r,[u,d]=Q.useState(a??``),[f,p]=Q.useState(!1),m=It(t,e=>c.itemRefCallback?.(e,r,i)),h=fr(),g=Q.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,Z.jsx)(oc,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Q.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Z.jsx)(vs.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Z.jsx)(dr.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:ur(o.onFocus,()=>p(!0)),onBlur:ur(o.onBlur,()=>p(!1)),onClick:ur(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:ur(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:ur(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:ur(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ur(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:ur(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(gs.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});cc.displayName=ac;var lc=`SelectItemText`,uc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Ts(lc,n),s=Vs(lc,n),c=sc(lc,n),l=Ds(lc,n),[u,d]=Q.useState(null),f=It(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=Q.useMemo(()=>(0,Z.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return gr(()=>(h(m),()=>g(m)),[h,g,m]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(dr.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Io.createPortal(a.children,o.valueNode):null]})});uc.displayName=lc;var dc=`SelectItemIndicator`,fc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return sc(dc,n).isSelected?(0,Z.jsx)(dr.span,{"aria-hidden":!0,...r,ref:t}):null});fc.displayName=dc;var pc=`SelectScrollUpButton`,mc=Q.forwardRef((e,t)=>{let n=Vs(pc,e.__scopeSelect),r=Xs(pc,e.__scopeSelect),[i,a]=Q.useState(!1),o=It(t,r.onScrollButtonChange);return gr(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Z.jsx)(_c,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});mc.displayName=pc;var hc=`SelectScrollDownButton`,gc=Q.forwardRef((e,t)=>{let n=Vs(hc,e.__scopeSelect),r=Xs(hc,e.__scopeSelect),[i,a]=Q.useState(!1),o=It(t,r.onScrollButtonChange);return gr(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Z.jsx)(_c,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});gc.displayName=hc;var _c=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Vs(`SelectScrollButton`,n),o=Q.useRef(null),s=ys(n),c=Q.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Q.useEffect(()=>()=>c(),[c]),gr(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Z.jsx)(dr.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:ur(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:ur(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:ur(i.onPointerLeave,()=>{c()})})}),vc=`SelectSeparator`,yc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Z.jsx)(dr.div,{"aria-hidden":!0,...r,ref:t})});yc.displayName=vc;var bc=`SelectArrow`,xc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Cs(n),a=Ts(bc,n),o=Vs(bc,n);return a.open&&o.position===`popper`?(0,Z.jsx)(qr,{...i,...r,ref:t}):null});xc.displayName=bc;var Sc=`SelectBubbleInput`,Cc=Q.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Q.useRef(null),a=It(r,i),o=Wr(t);return Q.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,Z.jsx)(dr.select,{...n,style:{...yr,...n.style},ref:a,defaultValue:t})});Cc.displayName=Sc;function wc(e){return e===``||e===void 0}function Tc(e){let t=hr(e),n=Q.useRef(``),r=Q.useRef(0),i=Q.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=Q.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Q.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Ec(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Dc(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Dc(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Oc=Os,kc=As,Ac=Ms,jc=Ps,Mc=Is,Nc=Rs,Pc=Qs,Fc=cc,Ic=uc,Lc=fc,Rc=mc,zc=gc,Bc=`Switch`,[Vc,Hc]=vr(Bc),[Uc,Wc]=Vc(Bc),Gc=Q.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=Q.useState(null),m=It(t,e=>p(e)),h=Q.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=mr({prop:i,defaultProp:a??!1,onChange:l,caller:Bc});return(0,Z.jsxs)(Uc,{scope:n,checked:_,disabled:s,children:[(0,Z.jsx)(dr.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Xc(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:ur(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,Z.jsx)(Yc,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Gc.displayName=Bc;var Kc=`SwitchThumb`,qc=Q.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Wc(Kc,n);return(0,Z.jsx)(dr.span,{"data-state":Xc(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});qc.displayName=Kc;var Jc=`SwitchBubbleInput`,Yc=Q.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=Q.useRef(null),s=It(o,a),c=Wr(n),l=Jr(t);return Q.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,Z.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});Yc.displayName=Jc;function Xc(e){return e?`checked`:`unchecked`}var Zc=Gc,Qc=qc,$=a();function $c(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function el(e){if(e.kind===`create`){let t=e.value;return ai._({id:`XPqe3B`,values:{tagValue:t}})}let t=ai._({id:`pckX1A`,values:{0:e.count}}),n=e.value;return ai._({id:`m2T1Xj`,values:{tagValue:n,uses:t}})}function tl(e){let t=(0,$.c)(38),{items:n,query:r,selectedIndex:i,onSelect:a,onHover:c,loading:l,error:u}=e,d=l===void 0?!1:l,f=u===void 0?null:u,{_:p}=s(),m=(0,Q.useRef)(null),h=(0,Q.useId)(),g=i>=0&&i<n.length?`${h}-option-${i}`:void 0,_,v;t[0]===i?(_=t[1],v=t[2]):(_=()=>{let e=m.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(i);t&&t.scrollIntoView({block:`nearest`})},v=[i],t[0]=i,t[1]=_,t[2]=v),(0,Q.useEffect)(_,v);let y=nl;if(d){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:y,children:(0,Z.jsx)(o,{id:`a_u4ck`})}),t[4]=n):n=t[4],n}if(n.length===0){let e;if(t[5]!==p||t[6]!==f||t[7]!==r){let n=r.trim();e=f??p(n?{id:`9R7pRC`,values:{trimmed:n}}:{id:`KRJ6xh`}),t[5]=p,t[6]=f,t[7]=r,t[8]=e}else e=t[8];let n=e,i;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(i={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[9]=i):i=t[9];let a;return t[10]===n?a=t[11]:(a=(0,Z.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:i,onMouseDown:y,children:n}),t[10]=n,t[11]=a),a}let b=i>=0&&i<n.length?n[i]:null,x;t[12]===p?x=t[13]:(x=p({id:`SCoBBH`}),t[12]=p,t[13]=x);let S;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[14]=S):S=t[14];let C;t[15]===b?C=t[16]:(C=b?el(b):``,t[15]=b,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:C}),t[17]=C,t[18]=w);let T;t[19]===f?T=t[20]:(T=f&&(0,Z.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300`,children:f}),t[19]=f,t[20]=T);let E;if(t[21]!==n||t[22]!==h||t[23]!==c||t[24]!==a||t[25]!==i){let e;t[27]!==h||t[28]!==c||t[29]!==a||t[30]!==i?(e=(e,t)=>{let n=t===i,r=$c(e),s=e.kind===`create`;return(0,Z.jsxs)(`button`,{id:`${h}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,"data-testid":s?`tag-suggestion-create`:`tag-suggestion-tag-${e.value}`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),a(e)},onPointerMove:c?()=>c(t):void 0,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`#`}),(0,Z.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.value}),s?(0,Z.jsx)(`span`,{className:`shrink-0 rounded-sm bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`,children:(0,Z.jsx)(o,{id:`isRobC`})}):(0,Z.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:e.count})]},r)},t[27]=h,t[28]=c,t[29]=a,t[30]=i,t[31]=e):e=t[31],E=n.map(e),t[21]=n,t[22]=h,t[23]=c,t[24]=a,t[25]=i,t[26]=E}else E=t[26];let D;return t[32]!==g||t[33]!==E||t[34]!==x||t[35]!==w||t[36]!==T?(D=(0,Z.jsxs)(`div`,{ref:m,role:`listbox`,"aria-label":x,"aria-activedescendant":g,tabIndex:-1,onMouseDown:y,className:`w-64 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:S,children:[w,T,E]}),t[32]=g,t[33]=E,t[34]=x,t[35]=w,t[36]=T,t[37]=D):D=t[37],D}function nl(e){return e.preventDefault()}var rl=new ke(`tagSuggestion`),il=8,al=/^[a-zA-Z][\w/-]*$/;async function ol(){let e=await fetch(`/api/tags`);if(!e.ok)throw Error(`/api/tags responded with ${e.status}`);let t=await e.json();return Array.isArray(t.tags)?t.tags:[]}function sl(e,t){let n=t.trim(),r=n.toLowerCase(),i=n===``?e.slice():e.filter(e=>e.name.toLowerCase().includes(r));return i.sort((e,t)=>{let n=+!e.name.toLowerCase().startsWith(r),i=+!t.name.toLowerCase().startsWith(r);return n===i?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:n-i}),i}function cl(e,t){let n=sl(e,t).slice(0,il).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&al.test(r)&&!e.some(e=>e.name===r)&&n.push({kind:`create`,value:r}),n}function ll(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``).match(/(^|[\s])#([a-zA-Z][\w/-]*)?$/);if(!n)return null;let r=n[2]??``,i=t.start(),a=n[1].length;return{range:{from:i+((n.index??0)+a),to:t.pos},query:r,text:`#${r}`}}function ul(e){let t=[],n=!1,r=null,i=null;return Vt({editor:e,pluginKey:rl,char:`#`,allowedPrefixes:null,findSuggestionMatch:ll,allow:({editor:e})=>!ln(e),items:async({query:e})=>{if(!n){r||=ol();try{t=await r,i=null}catch(e){console.error(`[tag-suggestion] Failed to fetch tags:`,e),i=`Failed to load tags. Press Escape and type # again to retry, or continue typing to create a new tag.`,t=[]}finally{n=!0,r=null}}return cl(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!al.test(r))return;e.chain().focus().deleteRange(t).insertContent({type:`tag`,attrs:{value:r}}).insertContent(` `).run()}catch(e){console.error(`[tag-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,a=null,o=0,s={popup:null,stopAutoUpdate:null},c=null,l=null,u=e=>{a?.command(e)},d=e=>{o!==e&&(o=e,p(null))};function f(e,t,r){let a=t===null?!n:t;return{items:e.items,query:e.query??``,selectedIndex:o,onSelect:r,onHover:d,loading:a,error:i}}let p=t=>{!e||!a||e.updateProps(f(a,t,u))};return{onBeforeStart(t){a=t,o=0;let n=cn(()=>a,`tag-suggestion`);s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new dn(tl,{props:f(t,!0,u),editor:t.editor}),n.popup.appendChild(e.element),s.stopAutoUpdate=n.startAutoUpdate()},onStart(e){a=e,o=0,p(null),l?.()},onUpdate(e){a=e,o=Math.min(o,Math.max(0,e.items.length-1)),p(null),c?.()},onKeyDown({event:e}){if(!a)return!1;let t=a.items;if(e.key===`ArrowDown`)return t.length===0?!1:(o=(o+1)%t.length,p(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(o=(o-1+t.length)%t.length,p(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[o];if(e)return a.command(e),!0;let n=(a.query??``).trim();return n&&al.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){sn(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var dl=new Map([[tr,`<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>`],[Tn,`<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/>`],[gn,`<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>`],[gn,`<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>`],[eo,`<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/>`],[kn,`<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/>`],[hn,`<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/><path d="M19.364 18.364a9 9 0 0 0 0-12.728"/>`],[cr,`<path d="M18 6 6 18"/><path d="m6 6 12 12"/>`]]),fl=new Map;function pl(e){let t=fl.get(e);if(t!==void 0)return t;let n=`<svg xmlns="http://www.w3.org/2000/svg" width="0.75rem" height="0.75rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${dl.get(e)??dl.get(Tn)}</svg>`;return fl.set(e,n),n}var ml=`0 0 32 32`,hl=`M26.7075 10.2925L19.7075 3.2925C19.6146 3.19967 19.5042 3.12605 19.3829 3.07586C19.2615 3.02568 19.1314 2.9999 19 3H7C6.46957 3 5.96086 3.21071 5.58579 3.58579C5.21071 3.96086 5 4.46957 5 5V14C5 14.2652 5.10536 14.5196 5.29289 14.7071C5.48043 14.8946 5.73478 15 6 15C6.26522 15 6.51957 14.8946 6.70711 14.7071C6.89464 14.5196 7 14.2652 7 14V5H18V11C18 11.2652 18.1054 11.5196 18.2929 11.7071C18.4804 11.8946 18.7348 12 19 12H25V28C25 28.2652 25.1054 28.5196 25.2929 28.7071C25.4804 28.8946 25.7348 29 26 29C26.2652 29 26.5196 28.8946 26.7071 28.7071C26.8946 28.5196 27 28.2652 27 28V11C27.0001 10.8686 26.9743 10.7385 26.9241 10.6172C26.8739 10.4958 26.8003 10.3854 26.7075 10.2925ZM20 6.41375L23.5863 10H20V6.41375ZM18 18H16C15.7348 18 15.4804 18.1054 15.2929 18.2929C15.1054 18.4804 15 18.7348 15 19V26C15 26.2652 15.1054 26.5196 15.2929 26.7071C15.4804 26.8946 15.7348 27 16 27H18C19.1935 27 20.3381 26.5259 21.182 25.682C22.0259 24.8381 22.5 23.6935 22.5 22.5C22.5 21.3065 22.0259 20.1619 21.182 19.318C20.3381 18.4741 19.1935 18 18 18ZM18 25H17V20H18C18.663 20 19.2989 20.2634 19.7678 20.7322C20.2366 21.2011 20.5 21.837 20.5 22.5C20.5 23.163 20.2366 23.7989 19.7678 24.2678C19.2989 24.7366 18.663 25 18 25ZM13 19V26C13 26.2652 12.8946 26.5196 12.7071 26.7071C12.5196 26.8946 12.2652 27 12 27C11.7348 27 11.4804 26.8946 11.2929 26.7071C11.1054 26.5196 11 26.2652 11 26V22.1725L9.31875 24.5737C9.22652 24.7053 9.10396 24.8126 8.96144 24.8868C8.81892 24.9609 8.66064 24.9996 8.5 24.9996C8.33936 24.9996 8.18108 24.9609 8.03856 24.8868C7.89604 24.8126 7.77348 24.7053 7.68125 24.5737L6 22.1725V26C6 26.2652 5.89464 26.5196 5.70711 26.7071C5.51957 26.8946 5.26522 27 5 27C4.73478 27 4.48043 26.8946 4.29289 26.7071C4.10536 26.5196 4 26.2652 4 26V19C4.00009 18.7874 4.06791 18.5804 4.19363 18.409C4.31935 18.2376 4.49642 18.1107 4.69915 18.0467C4.90188 17.9828 5.11971 17.9851 5.32104 18.0533C5.52236 18.1216 5.6967 18.2522 5.81875 18.4263L8.5 22.2563L11.1812 18.4263C11.3033 18.2522 11.4776 18.1216 11.679 18.0533C11.8803 17.9851 12.0981 17.9828 12.3008 18.0467C12.5036 18.1107 12.6807 18.2376 12.8064 18.409C12.9321 18.5804 12.9999 18.7874 13 19Z`;function gl(e){return e===`.md`||e===`.mdx`}function _l(e){switch(pe(e)){case`image`:return pl(gn);case`video`:return pl(kn);case`audio`:return pl(hn);default:return pl(eo)}}function vl(e){let t=(0,$.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{d:hl}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(`svg`,{"aria-hidden":`true`,className:n,fill:`currentColor`,viewBox:ml,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function yl(e){let t=oi(e).toLowerCase();return t?gl(t)?{kind:`file`,path:e}:{kind:`file`,path:e,bodyIndexed:!1}:{kind:`folder`,path:e}}function bl(e){let t=(0,$.c)(6),{path:n,className:r,showExtensionBadge:i}=e,a;t[0]===n?a=t[1]:(a=yl(n),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsx)(Sl,{...a,className:r,showExtensionBadge:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function xl(e){let{kind:t,bodyIndexed:n}=yl(e);if(t===`folder`)return pl(tr);let r=(n===!1?oi(e):oi(e)||`.md`).toLowerCase();return gl(r)?`<svg xmlns="http://www.w3.org/2000/svg" width="0.75rem" height="0.75rem" viewBox="${ml}" fill="currentColor" aria-hidden="true"><path d="${hl}"/></svg>`:_l(r)}function Sl(e){let t=(0,$.c)(25),{kind:n,path:r,docExt:i,bodyIndexed:a,className:o,showExtensionBadge:s}=e,c=s===void 0?!0:s;if(n===`folder`){let e;t[0]===o?e=t[1]:(e=Ft(`shrink-0`,o),t[0]=o,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,Z.jsx)(tr,{"aria-hidden":`true`,className:e,"data-file-entry-icon":`folder`}),t[2]=e,t[3]=n),n}let l;t[4]!==a||t[5]!==i||t[6]!==r?(l=a===!1?oi(r):i??(oi(r)||`.md`),t[4]=a,t[5]=i,t[6]=r,t[7]=l):l=t[7];let u=l,d,f,p,m;if(t[8]!==o||t[9]!==u||t[10]!==c){let e=u.toLowerCase(),n=pe(e);d=c&&u&&e!==`.md`?u.slice(1).toUpperCase():null;let r=n===`image`&&`text-rose-500`,i;t[15]!==o||t[16]!==r?(i=Ft(o,r),t[15]=o,t[16]=r,t[17]=i):i=t[17];let a=i;f=`relative inline-flex shrink-0`,p=e||`file`,m=gl(e)?(0,Z.jsx)(vl,{className:a,"data-testid":`file-entry-icon-markdown`}):n===`image`?(0,Z.jsx)(gn,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-image`}):n===`video`?(0,Z.jsx)(kn,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-video`}):n===`audio`?(0,Z.jsx)(hn,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-audio`}):(0,Z.jsx)(eo,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-file`}),t[8]=o,t[9]=u,t[10]=c,t[11]=d,t[12]=f,t[13]=p,t[14]=m}else d=t[11],f=t[12],p=t[13],m=t[14];let h;t[18]===d?h=t[19]:(h=d?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`-right-1 -bottom-1 absolute rounded-sm bg-background px-0.5 font-medium text-[0.5rem] text-muted-foreground leading-none`,"data-testid":`file-entry-extension-badge`,children:d}):null,t[18]=d,t[19]=h);let g;return t[20]!==f||t[21]!==p||t[22]!==m||t[23]!==h?(g=(0,Z.jsxs)(`span`,{className:f,"data-file-entry-icon":p,children:[m,h]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h,t[24]=g):g=t[24],g}var Cl=Rt(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3! font-mono uppercase`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,warning:`bg-yellow-500/10 text-yellow-600 [a]:hover:bg-yellow-500/20`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`,dashed:`border-dashed border-border text-muted-foreground rounded-sm`,primary:`border border-primary/50 text-primary bg-primary/5 rounded-sm p-0.5 px-1.5 font-mono`,gray:`border border-border text-muted-foreground bg-muted rounded-sm p-0.5 px-1.5 font-mono`}},defaultVariants:{variant:`default`}});function wl(e){let t=(0,$.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,variant:i,asChild:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a!==void 0&&a?Nt:`span`,c;t[5]!==n||t[6]!==o?(c=Ft(Cl({variant:o}),n),t[5]=n,t[6]=o,t[7]=c):c=t[7];let l;return t[8]!==s||t[9]!==r||t[10]!==c||t[11]!==o?(l=(0,Z.jsx)(s,{"data-slot":`badge`,"data-variant":o,className:c,...r}),t[8]=s,t[9]=r,t[10]=c,t[11]=o,t[12]=l):l=t[12],l}var Tl=1,El=.9,Dl=.8,Ol=.17,kl=.1,Al=.999,jl=.9999,Ml=.99,Nl=/[\\\/_+.#"@\[\(\{&]/,Pl=/[\\\/_+.#"@\[\(\{&]/g,Fl=/[\s-]/,Il=/[\s-]/g;function Ll(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Tl:Ml;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=Ll(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Tl:Nl.test(e.charAt(l-1))?(d*=Dl,p=e.slice(i,l-1).match(Pl),p&&i>0&&(d*=Al**+p.length)):Fl.test(e.charAt(l-1))?(d*=El,m=e.slice(i,l-1).match(Il),m&&i>0&&(d*=Al**+m.length)):(d*=Ol,i>0&&(d*=Al**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=jl)),(d<kl&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Ll(e,t,n,r,l+1,a+2,o),f*kl>d&&(d=f*kl)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Rl(e){return e.toLowerCase().replace(Il,` `)}function zl(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Ll(e,t,Rl(e),Rl(t),0,0,{})}var Bl=`[cmdk-group=""]`,Vl=`[cmdk-group-items=""]`,Hl=`[cmdk-group-heading=""]`,Ul=`[cmdk-item=""]`,Wl=`${Ul}:not([aria-disabled="true"])`,Gl=`cmdk-item-select`,Kl=`data-value`,ql=(e,t,n)=>zl(e,t,n),Jl=Q.createContext(void 0),Yl=()=>Q.useContext(Jl),Xl=Q.createContext(void 0),Zl=()=>Q.useContext(Xl),Ql=Q.createContext(void 0),$l=Q.forwardRef((e,t)=>{let n=pu(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=pu(()=>new Set),i=pu(()=>new Map),a=pu(()=>new Map),o=pu(()=>new Set),s=du(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=fr(),y=fr(),b=fr(),x=Q.useRef(null),S=gu();fu(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),fu(()=>{S(6,k)},[]);let C=Q.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Q.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??ql;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Vl);t?t.appendChild(e.parentElement===t?e:e.closest(`${Vl} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Vl} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${Bl}[${Kl}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Kl);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(Bl)?.querySelector(Hl))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Ul}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Wl)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Kl))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Kl))}function P(e){let t=A()?.closest(Bl),n;for(;t&&!n;)t=e>0?lu(t,Bl):uu(t,Bl),n=t?.querySelector(Wl);n?C.setState(`value`,n.getAttribute(Kl)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Q.createElement(dr.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Gl);t.dispatchEvent(e)}}}}},Q.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:yu},c),vu(e,e=>Q.createElement(Xl.Provider,{value:C},Q.createElement(Jl.Provider,{value:w},e))))}),eu=Q.forwardRef((e,t)=>{let n=fr(),r=Q.useRef(null),i=Q.useContext(Ql),a=Yl(),o=du(e),s=o.current?.forceMount??i?.forceMount;fu(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=hu(n,r,[e.value,e.children,r],e.keywords),l=Zl(),u=mu(e=>e.value&&e.value===c.current),d=mu(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Q.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Gl,f),()=>t.removeEventListener(Gl,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Q.createElement(dr.div,{ref:Pt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),tu=Q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=fr(),s=Q.useRef(null),c=Q.useRef(null),l=fr(),u=Yl(),d=mu(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);fu(()=>u.group(o),[]),hu(o,s,[e.value,e.heading,c]);let f=Q.useMemo(()=>({id:o,forceMount:i}),[i]);return Q.createElement(dr.div,{ref:Pt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Q.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),vu(e,e=>Q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Q.createElement(Ql.Provider,{value:f},e))))}),nu=Q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Q.useRef(null),a=mu(e=>!e.search);return!n&&!a?null:Q.createElement(dr.div,{ref:Pt(i,t),...r,"cmdk-separator":``,role:`separator`})}),ru=Q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Zl(),o=mu(e=>e.search),s=mu(e=>e.selectedItemId),c=Yl();return Q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Q.createElement(dr.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),iu=Q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Q.useRef(null),o=Q.useRef(null),s=mu(e=>e.selectedItemId),c=Yl();return Q.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Q.createElement(dr.div,{ref:Pt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},vu(e,e=>Q.createElement(`div`,{ref:Pt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),au=Q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Q.createElement(jr,{open:n,onOpenChange:r},Q.createElement(Ar,{container:o},Q.createElement(Ur,{"cmdk-overlay":``,className:i}),Q.createElement(Fr,{"aria-label":e.label,"cmdk-dialog":``,className:a},Q.createElement($l,{ref:t,...s}))))}),ou=Q.forwardRef((e,t)=>mu(e=>e.filtered.count===0)?Q.createElement(dr.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),su=Q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Q.createElement(dr.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},vu(e,e=>Q.createElement(`div`,{"aria-hidden":!0},e)))}),cu=Object.assign($l,{List:iu,Item:eu,Input:ru,Group:tu,Separator:nu,Dialog:au,Empty:ou,Loading:su});function lu(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function uu(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function du(e){let t=Q.useRef(e);return fu(()=>{t.current=e}),t}var fu=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function pu(e){let t=Q.useRef();return t.current===void 0&&(t.current=e()),t}function mu(e){let t=Zl(),n=()=>e(t.snapshot());return Q.useSyncExternalStore(t.subscribe,n,n)}function hu(e,t,n,r=[]){let i=Q.useRef(),a=Yl();return fu(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Kl,s),i.current=s}),i}var gu=()=>{let[e,t]=Q.useState(),n=pu(()=>new Map);return fu(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function _u(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function vu({asChild:e,children:t},n){return e&&Q.isValidElement(t)?Q.cloneElement(_u(t),{ref:t.ref},n(t.props.children)):n(t)}var yu={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function bu(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(cu,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xu(e){let t=(0,$.c)(36),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({title:s,description:c,children:n,className:r,showCloseButton:l,commandProps:i,onEscapeKeyDown:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=s===void 0?`Command Palette`:s,d=c===void 0?`Search for a command to run`:c,f=l===void 0?!0:l,p;t[9]===i?p=t[10]:(p=i??{},t[9]=i,t[10]=p);let m,h;t[11]===p?(m=t[12],h=t[13]):({className:m,...h}=p,t[11]=p,t[12]=m,t[13]=h);let g;t[14]===r?g=t[15]:(g=Ft(`top-[12vh] translate-y-0 overflow-hidden p-0`,r),t[14]=r,t[15]=g);let _;t[16]===u?_=t[17]:(_=(0,Z.jsx)(kr,{className:`sr-only`,children:u}),t[16]=u,t[17]=_);let v;t[18]===d?v=t[19]:(v=(0,Z.jsx)(Or,{className:`sr-only`,children:d}),t[18]=d,t[19]=v);let y;t[20]===m?y=t[21]:(y=Ft(`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,m),t[20]=m,t[21]=y);let b;t[22]!==n||t[23]!==h||t[24]!==y?(b=(0,Z.jsx)(bu,{className:y,...h,children:n}),t[22]=n,t[23]=h,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==a||t[27]!==f||t[28]!==g||t[29]!==_||t[30]!==v||t[31]!==b?(x=(0,Z.jsxs)(Pr,{className:g,showCloseButton:f,onEscapeKeyDown:a,children:[_,v,b]}),t[26]=a,t[27]=f,t[28]=g,t[29]=_,t[30]=v,t[31]=b,t[32]=x):x=t[32];let S;return t[33]!==o||t[34]!==x?(S=(0,Z.jsx)(Hr,{...o,children:x}),t[33]=o,t[34]=x,t[35]=S):S=t[35],S}function Su(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(wo,{className:`size-4 shrink-0 opacity-50`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=Ft(`flex w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a?(o=(0,Z.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex items-center gap-2 border-b px-3`,children:[i,(0,Z.jsx)(cu.Input,{"data-slot":`command-input`,className:a,...r})]}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Cu(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(cu.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function wu(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(cu.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),t[0]=e,t[1]=n),n}function Tu(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-mono [&_[cmdk-group-heading]]:uppercase **:[[cmdk-group-heading]]:tracking-wider`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(cu.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Eu(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(cu.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Du(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`ml-auto text-muted-foreground text-xs tracking-widest`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`span`,{"data-slot":`command-shortcut`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ou(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(us,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function ku(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(fs,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function Au(e){let t=(0,$.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,align:i,sideOffset:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`center`:i,s=a===void 0?4:a,c;t[5]===n?c=t[6]:(c=Ft(`z-50 w-72 rounded-lg border bg-popover p-4 text-popover-foreground shadow-md outline-hidden origin-(--radix-popover-content-transform-origin) duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0`,n),t[5]=n,t[6]=c);let l;return t[7]!==o||t[8]!==r||t[9]!==s||t[10]!==c?(l=(0,Z.jsx)(ps,{children:(0,Z.jsx)(ms,{"data-slot":`popover-content`,align:o,sideOffset:s,className:c,...r})}),t[7]=o,t[8]=r,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function ju(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(ds,{"data-slot":`popover-anchor`,...n}),t[2]=n,t[3]=r),r}async function Mu(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}if(r instanceof Error&&r.name===`AbortError`)throw r;if(e.ok)return r!==void 0&&console.warn(`[parse-server-response] 2xx response with non-JSON body:`,r instanceof Error?r.message:String(r)),{ok:!0,body:r===void 0?n:null};if(r!==void 0){let t=r instanceof Error?r.message:String(r);return{ok:!1,title:`Server error (HTTP ${e.status}): ${t}`}}return{ok:!1,title:ii(n)??t}}function Nu(e,t,n,r){let i=e.safeParse(t);return i.success?i.data:(console.warn(`[parse-server-response] schema drift:`,n,`bodyShape=`,typeof t==`object`&&t?Object.keys(t):typeof t,`issues=`,i.error.issues),r)}var Pu=new Map,Fu=null;function Iu(){return fi(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function Lu(){if(Fu!==null)return;let e=Math.max(50,Math.floor(Iu()/2));Fu=setTimeout(()=>{Fu=null,Ru(Date.now()),Pu.size>0&&Lu()},e)}function Ru(e){let t=Iu();for(let[n,r]of Pu)e-r.emittedAt>=t&&(Pu.delete(n),X.count(`ok/sidebar/prewarm`,{hit:!1}))}function zu(e,t,n=Date.now()){Pu.has(e)&&X.count(`ok/sidebar/prewarm`,{hit:!1}),Pu.set(e,{poolEventId:t,emittedAt:n}),Lu()}function Bu(e,t,n=Date.now()){let r=Pu.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=Iu()?!1:(Pu.delete(e),X(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),X.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}ve({event:P(`ok-branch-switched-clear-failed`),branch:ge(),docName:ge(),reason:ge()});async function Vu(e,t){let n=[];for(let[r,i]of e.entries)i.kind===`active`&&i.persistence!==null&&n.push(i.persistence.clearData().catch(e=>{let n={event:`ok-branch-switched-clear-failed`,docName:r,branch:t,reason:e instanceof Error?e.message:String(e)};console.warn(JSON.stringify(n))}));await Promise.all(n),e.clearBufferedUpdates(),e.recycleAllEntries()}function Hu(e){let t=!1;return()=>{t?e():t=!0}}function Uu(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Wu(e,t=``){let n;try{n=await fetch(`${t}/api/server-info`,{signal:AbortSignal.timeout(5e3)})}catch{return}if(!n.ok)return;let r;try{r=await n.json()}catch{return}let i=Ge.safeParse(r);if(!i.success){console.warn(JSON.stringify({event:`ok-server-info-schema-mismatch`,issues:i.error.issues}));return}if(e.setExpectedServerInstanceId(i.data.serverInstanceId),ca(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&(Vu(e,i.data.currentBranch),di(i.data.currentBranch)),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=Uu(n)}catch{}e.observeDiskAckBatch(t)}}async function Gu(e){let t;try{t=await fetch(`/api/config`,{signal:e,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return{status:`error`,code:`network`}}if(t.status===404||t.status===501)return{status:`absent`};if(!t.ok)return{status:`error`,code:t.status};let n;try{n=await t.json()}catch{return{status:`error`,code:`invalid-body`}}if(typeof n!=`object`||!n||Array.isArray(n))return{status:`error`,code:`invalid-body`};let r=n;return{status:`ok`,config:{collabUrl:typeof r.collabUrl==`string`?r.collabUrl:null,previewUrl:typeof r.previewUrl==`string`?r.previewUrl:null,port:typeof r.port==`number`?r.port:0,singleFile:r.singleFile===!0}}}function Ku(e){return ed(e,gt)}function qu(e){return ed(e,Re)}function Ju(e){return ed(e,pt)}function Yu(e){return ed(e,$e)}function Xu(e){return ed(e,je)}function Zu(e){let t=ed(e,Pe);if(!t)return null;try{return{docName:t.docName,sv:Qu(t.sv)}}catch{return null}}function Qu(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function $u(e,t){let n=qu(e);if(n){t.onServerInfo?.(n);return}let r=Ju(e);if(r){t.onBranchSwitched?.(r);return}let i=Zu(e);if(i){t.onDiskAck?.(i);return}let a=Ku(e);if(a){t.onDerivedView?.(a);return}let o=Yu(e);if(o){t.onConfigValidationRejected?.(o);return}let s=Xu(e);if(s){t.onConfigIgnoreNestedError?.(s);return}t.onUnknown?.(e)}function ed(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function td(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function nd(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function rd(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var id=2e3,ad=15e3;function od(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??id,r=e.maxDelayMs??ad,i=e.log??{info:console.info,warn:console.warn},a=new AbortController,o=null,s=n,c=0,l=!1,u=!1,d=null,f=e.now(),p=async()=>{c+=1;let n=null;try{let t=await e.fetchConfig(a.signal);t.status===`absent`?(n=e.fallbackUrl(),d=null):t.status===`ok`&&t.config.collabUrl!==null?(n=t.config.collabUrl,d=null):t.status===`ok`?(u||(u=!0,i.info(`[collab-url] ok ui responded but server.lock has no port yet — retrying`)),d={kind:`null-collab`}):t.status===`error`&&(i.warn(`[collab-url] /api/config error (${t.code}) — retrying in ${s}ms`),d={kind:`error`,code:t.code})}catch(e){if(e.name===`AbortError`)return;d={kind:`error`,code:`network`}}if(!l){if(n!==null){e.onStateChange({collabUrl:n,attempts:c,terminal:!1,lastError:null});return}if(e.now()-f>=t){e.onStateChange({collabUrl:null,attempts:c,terminal:!0,lastError:d});return}e.onStateChange({collabUrl:null,attempts:c,terminal:!1,lastError:d}),o=e.setTimeout(()=>{p()},s),s=Math.min(s*2,r)}};return p(),{cancel:()=>{l=!0,a.abort(),o!==null&&(e.clearTimeout(o),o=null)}}}function sd(){let e=(0,$.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,Q.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,Q.useRef)(i),[o,s]=(0,Q.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=nd(window);if(t){r(rd(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(rd(t))});return()=>{n()}}let n=od({fetchConfig:Gu,fallbackUrl:td,now:Date.now,setTimeout:dd,clearTimeout:ud,onStateChange:t=>{e===a.current.token&&r(t)}});return()=>{n.cancel()}},e[2]=c):c=e[2];let l;e[3]===o?l=e[4]:(l=[o],e[3]=o,e[4]=l),(0,Q.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(ld),s(cd)},e[5]=u):u=e[5];let d=u,f;return e[6]===n?f=e[7]:(f={...n,retry:d},e[6]=n,e[7]=f),f}function cd(e){return e+1}function ld(e){return{...e,terminal:!1,lastError:null}}function ud(e){return globalThis.clearTimeout(e)}function dd(e,t){return globalThis.setTimeout(e,t)}var fd=new Map,pd=new Set;function md(){for(let e of pd)e()}function hd(e,t){fd.set(e,t),md()}function gd(e,t){fd.get(e)===t&&(fd.delete(e),md())}function _d(e){return fd.get(e)??null}function vd(e){return pd.add(e),()=>pd.delete(e)}var yd=/[\uD800-\uDBFF]/,bd=/[\uDC00-\uDFFF]/,xd=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&yd.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&bd.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},Sd=(e,t)=>e>>>t|e<<32-t,Cd=e=>Sd(e,2)^Sd(e,13)^Sd(e,22),wd=e=>Sd(e,6)^Sd(e,11)^Sd(e,25),Td=e=>Sd(e,7)^Sd(e,18)^e>>>3,Ed=e=>Sd(e,17)^Sd(e,19)^e>>>10,Dd=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]),Od=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),kd=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Od),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=Ed(t[e-2])+t[e-7]+Td(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+wd(o)+(o&s^~o&c)+Dd[e]+t[e]>>>0,d=Cd(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/Si,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},Ad=e=>new kd().digest(e),jd=new ke(`y-sync`),Md=new ke(`y-undo`),Nd=new ke(`yjs-cursor`),Pd=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},Fd=e=>Vi(Pd(Ad(Bi(e)))),Id=()=>({mapping:new Map,isOMark:new Map}),Ld=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!na(t.ds,e.id),Rd=[{light:`#ecd44433`,dark:`#ecd444`}],zd=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=fa();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Ui(t))}return e.get(n)},Bd=(e,{colors:t=Rd,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new Wd(e,a),c=new Et({props:{editable:e=>{let t=jd.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:jd,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(jd);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&Li(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=Md.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},jd)})}},destroy:()=>{s.destroy()}})});return c},Vd=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new Ce(e.doc));else if(t.type===`node`){let r=bf(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Hd(e,r))}else{let r=bf(n.doc,n.type,t.anchor,n.mapping),i=bf(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(y.between(e.doc.resolve(r),e.doc.resolve(i)))}},Hd=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?bt.create(e.doc,t):y.near(n)},Ud=(e,t)=>({type:t.selection.jsonID,anchor:vf(t.selection.anchor,e.type,e.mapping),head:vf(t.selection.head,e.type,e.mapping)}),Wd=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=Jt(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Ud(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Oi&&this._domSelectionInView===null&&(Li(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=ba.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=zi(va(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(jd,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>Kd(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(x.from(e),0,0));t.setMeta(jd,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>Kd(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(x.from(t),0,0));if(e){let t=ma(Zi(e.anchor,0),n.doc.content.size),r=ma(Zi(e.head,0),n.doc.content.size);n.setSelection(y.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(jd,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=Di(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&Ii(),r=new ia({gc:!1}),ga(r,t),t=Di(r),ga(r,e),e=Di(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[ra(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{Pi(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:zd(n.colorMapping,n.colors,r)}},s=Mi(i,new Qi(t.ds,e.sv)).map(n=>!n._item.deleted||Ld(n._item,e)||Ld(n._item,t)?Kd(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(x.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(jd,{isChangeOrigin:!0}))},jd)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=jd.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);Pi(t,t.deleteSet,e=>{if(e.constructor===ha){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>Gd(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(x.from(n),0,0));Vd(r,this.beforeTransactionSelection,this),r=r.setMeta(jd,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof la}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{df(this.doc,this.type,e,this),this.beforeTransactionSelection=Ud(this,this.prosemirrorView.state)},jd)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},Gd=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof ea)return Kd(e,t,n,r,i,a);throw Wi()}return o},Kd=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof ea){let s=Gd(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof aa&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=qd(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):Mi(e,new Qi(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(Ld(e._item,r)?Ld(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=t.node(e.nodeName,s,o);return n.mapping.set(e,c),c}catch(r){console.warn(`[y-prosemirror] schema.node(`+e.nodeName+`) threw:`,String(r&&r.message||r));let i=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};if(t.nodes[e.nodeName]&&t.nodes[e.nodeName].spec&&t.nodes[e.nodeName].spec.inline)i.inline++;else if(i.block++,t.nodes.rawMdxFallback)try{let i=t.node(`rawMdxFallback`,{reason:String(r&&r.message||r)},[t.text(e.nodeName)]);return n.mapping.set(e,i),i}catch(e){console.warn(`[y-prosemirror] rawMdxFallback substitution also failed:`,String(e&&e.message||e))}return n.mapping.delete(e),null}},qd=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,lf(n.attributes,t)))}}catch(e){console.warn(`[y-prosemirror] schema.text() threw:`,String(e&&e.message||e));let t=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};return t.inline++,null}return o},Jd=(e,t)=>{let n=new $i,r=e.map(e=>({insert:e.text,attributes:uf(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},Yd=(e,t)=>{let n=new ea(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,$d(e).map(e=>Xd(e,t))),t.mapping.set(n,e),n},Xd=(e,t)=>e instanceof Array?Jd(e,t):Yd(e,t),Zd=e=>typeof e==`object`&&!!e,Qd=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||Zd(o)&&Zd(s)&&Qd(o,s)}return r},$d=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},ef=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&ua(e.attributes||{}).length===t[n].marks.length&&ji(e.attributes,(e,r)=>{let i=cf(r),a=t[n].marks;return a.find(e=>e.type.name===i)?Qd(e,a.find(e=>e.type.name===i)?.attrs):!1}))},tf=(e,t)=>{if(e instanceof ea&&!(t instanceof Array)&&ff(e,t)){let n=$d(t);return e._length===n.length&&Qd(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>tf(e,n[t]))}return e instanceof $i&&t instanceof Array&&ef(e,t)},nf=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),rf=(e,t,n)=>{let r=e.toArray(),i=$d(t),a=i.length,o=r.length,s=ma(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(nf(n.mapping.get(e),t))u=!0;else if(!tf(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(nf(n.mapping.get(e),t))u=!0;else if(!tf(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},af=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof pa?t+=n.content.str:n.content instanceof sa&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},of=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=af(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,uf(e.marks,n))})),{insert:o,remove:s,index:c}=xd(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},sf=/(.*)(--[a-zA-Z0-9+/=]{8})$/,cf=e=>sf.exec(e)?.[1]??e,lf=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(cf(r),e[r]));return n},uf=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=qi(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${Fd(e.toJSON())}`:e.type.name]=e.attrs}}),n},df=(e,t,n,r)=>{if(t instanceof ea&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof ea){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=$d(n),a=i.length,o=t.toArray(),s=o.length,c=ma(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!nf(r.mapping.get(e),t))if(tf(e,t))r.mapping.set(e,t);else break}for(;u+l+1<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!nf(r.mapping.get(e),t))if(tf(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof $i&&c instanceof Array)ef(n,c)||of(n,c,r),l+=1;else{let i=n instanceof ea&&ff(n,c),a=d instanceof ea&&ff(d,f);if(i&&a){let e=rf(n,c,r),t=rf(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(df(e,n,c,r),l+=1):a?(df(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[Xd(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof $i?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(Xd(i[t],r));t.insert(l,e)}},jd)},ff=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,pf=null,mf=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=jd.getState(this.view.state);if(e&&e.binding&&!e.binding.isDestroyed){let e=this.view.state.tr;e.setMeta(this.key,this.value),this.view.dispatch(e)}}},hf=class e{constructor(e=[]){this.entries=e}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return this.entries.length===0}static fromViewsToUpdate(){let t=pf;pf=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new mf(t,r,e))})}),new e(n)}},gf=(e=hf.fromViewsToUpdate(),t=!1)=>{let n=!0;for(;!e.isEmpty();){let r=e.getFirst();try{r.apply()}catch(r){if(r instanceof RangeError){t&&n&&e.dequeueFirst(),e.isEmpty()||Li(0,()=>gf(e,!0));return}throw r}n=!1,e.dequeueFirst()}},_f=(e,t,n)=>{pf||(pf=new Map,Li(0,gf)),qi(pf,e,ta).set(t,n)},vf=(e,t,n)=>{if(e===0)return _a(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof $i){if(r._length>=e)return _a(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new Xi(r._item===null?null:r._item.id,r._item===null?Ci(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new Xi(r._item===null?null:r._item.id,r._item===null?Ci(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw Ii();if(e===0&&r.constructor!==$i&&r!==t)return yf(r._item.parent,r._item)}return _a(t,t._length,-1)},yf=(e,t)=>{let n=null,r=null;return e._item===null?r=Ci(e):n=Ri(e._item.id.client,e._item.id.clock),new Xi(n,r,t.id)},bf=(e,t,n,r)=>{let i=Ji(n,e);if(i===null||i.type!==t&&!Ni(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===$i)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;t++,n instanceof $i?o+=n._length:o+=r.get(n).nodeSize}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;t.deleted||(e instanceof $i?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},xf=(e,t)=>{let n=Id(),r=e.toArray().map(e=>Kd(e,t,n)).filter(e=>e!==null);return{doc:t.topNodeType.create(null,x.fromArray(r)),meta:n,mapping:n.mapping}},Sf=(e,t,n)=>e!==t,Cf=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(`⁠`),i=document.createTextNode(`⁠`);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},wf=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),Tf=/^#[0-9a-fA-F]{6}$/,Ef=(e,t,n,r,i)=>{let a=jd.getState(e);if(a==null||a.doc==null||a.binding==null)return Ue.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?Ue.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:Tf.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=bf(o,a.type,wi(t.cursor.anchor),a.binding.mapping),u=bf(o,a.type,wi(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=Zi(e.doc.content.size-1,0);l=ma(l,t),u=ma(u,t),s.push(rt.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=ma(l,u),o=Zi(l,u);s.push(rt.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),Ue.create(e.doc,s))},Df=(e,{awarenessStateFilter:t=Sf,cursorBuilder:n=Cf,selectionBuilder:r=wf,getSelection:i=e=>e.selection}={},a=`cursor`)=>new Et({key:Nd,state:{init(i,a){return Ef(a,e,t,n,r)},apply(i,a,o,s){let c=jd.getState(s),l=i.getMeta(Nd);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?Ef(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>Nd.getState(e)},view:t=>{let n=()=>{t.docView&&_f(t,Nd,{awarenessUpdated:!0})},r=()=>{let n=jd.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=vf(o.anchor,n.type,n.binding.mapping),c=vf(o.head,n.type,n.binding.mapping);(r.cursor==null||!ya(wi(r.cursor.anchor),s)||!ya(wi(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&bf(n.doc,n.type,wi(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),Of=e=>{let t=Md.getState(e).undoManager;if(t!=null)return t.undo(),!0},kf=e=>{let t=Md.getState(e).undoManager;if(t!=null)return t.redo(),!0},Af=new Set([`paragraph`]),jf=(e,t)=>!(e instanceof ha)||!(e.content instanceof Yi)||!(e.content.type instanceof aa||e.content.type instanceof ea&&t.has(e.content.type.nodeName))||e.content.type._length===0,Mf=({protectedNodes:e=Af,trackedOrigins:t=[],undoManager:n=null}={})=>new Et({key:Md,state:{init:(r,i)=>{let a=jd.getState(i),o=n||new la(a.type,{trackedOrigins:new Set([jd].concat(t)),deleteFilter:t=>jf(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=jd.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:Ud(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=jd.getState(e.state),n=Md.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,Md.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}}),Nf=new Map;function Pf(e){return Nf.get(e)}function Ff(e,t){Nf.set(e,t)}function If(e){Nf.delete(e)}var Lf=`open-knowledge-app`,Rf=new Map,zf=new Set,Bf=1024,Vf=1024;function Hf(){return At.getTracer(Lf)}function Uf(e,t,n){if(zf.has(e))return null;let r=Rf.get(e);if(r)return r;if(Rf.size>=Vf){let e=Rf.keys().next().value;if(e!==void 0){let t=Rf.get(e);Rf.delete(e);try{t?.span.end()}catch(e){console.warn(`[otel-spans] eviction span.end failed:`,e instanceof Error?e:String(e))}}}let i={span:Hf().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return Rf.set(e,i),i}function Wf(e,t,n,r,i){try{let a=Uf(e,n,r),o=a?At.setSpan(jt.active(),a.span):jt.active();Hf().startSpan(t,{attributes:{"mount.id":e,...n},startTime:r},o).end(i??Date.now())}catch(e){console.warn(`[otel-spans] emitColdMountChild failed:`,e instanceof Error?e:String(e))}}function Gf(e,t){try{let n=Rf.get(e);if(n&&(Rf.delete(e),n.span.end(t??Date.now())),!zf.has(e)){if(zf.size>=Bf){let e=zf.values().next().value;e!==void 0&&zf.delete(e)}zf.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var Kf=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function qf(){return fi(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function Jf(e){e.stalledHandle!==null&&(clearTimeout(e.stalledHandle),e.stalledHandle=null)}function Yf(e,t,n){if(e.stalledMarkEmitted)return;e.stalledMarkEmitted=!0;let r=n-e.createdAt;X(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var Xf=new Map,Zf=new Set;function Qf(e){Zf.add(e);for(let[t,n]of Xf)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{Zf.delete(e)}}function $f(e,t){for(let n of Zf)try{n(e,t.mountId)}catch{}}var ep=!1;function tp(){typeof document>`u`||document.visibilityState===`visible`&&ip(Date.now())}function np(){ep||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,tp),ep=!0)}function rp(){ep&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,tp),ep=!1))}function ip(e){let t=qf();for(let[n,r]of Xf)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(Yf(r,n,e),$f(n,r))}function ap(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=Xf.get(t);if(a)return a.promise;let o=new AbortController,s=Date.now(),c=()=>{},l=()=>{},u=new Promise((e,t)=>{c=e,l=t}),d={promise:u,rejectFn:l,controller:o,mountId:n,createdAt:s,settled:!1,resolved:!1,preMountEditor:null,stalledHandle:null,stalledMarkEmitted:!1};return d.stalledHandle=setTimeout(()=>{d.settled||(Yf(d,t,Date.now()),$f(t,d))},qf()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,Jf(d),d.preMountEditor&&=(lp(t,d.preMountEditor,`aborted`),null),Xf.delete(t),Xf.size===0&&rp(),X(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),l(new Kf(t)),Gf(d.mountId))}),Xf.set(t,d),np(),X(`ok/mount/create`,{docName:t,mountId:d.mountId}),up({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:c,rejectFn:l}).catch(e=>{if(d.preMountEditor&&=(lp(t,d.preMountEditor,`backstop`),null),d.settled){X(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,Jf(d);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`,message:n.message}),l(n),Gf(d.mountId)}),u}function op(e){return Xf.get(e)?.resolved===!0}function sp(e){return Xf.get(e)?.controller??null}function cp(e){let t=Xf.get(e);t&&(t.settled=!0,Jf(t),t.preMountEditor&&=(lp(e,t.preMountEditor,`aborted`),null),Xf.delete(e),Xf.size===0&&rp(),X(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),Gf(t.mountId),t.controller.abort())}function lp(e,t,n){let r=dp(t);try{t.destroy()}catch(t){X(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function up(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(Gp(t)!==void 0){let e=kp({docName:t,container:s,factory:()=>{throw Error(`mount-promise: V2 cache contract violation — factory invoked on HIT for "${t}"`)}});i.settled=!0,i.resolved=!0,Jf(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,Jf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`,message:n.message}),o(n),Gf(i.mountId);return}if(i.preMountEditor=c.editor,await scheduler.yield(),i.controller.signal.aborted){i.preMountEditor=null;return}try{c.editor.mount(s)}catch(e){lp(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,Jf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`,message:n.message}),o(n),Gf(i.mountId);return}let l;try{l=kp({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){lp(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,Jf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`,message:n.message}),o(n),Gf(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,Jf(i);let u=Date.now()-i.createdAt;X(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),X.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();Wf(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),Gf(i.mountId,d)}function dp(e){try{let t=e.state;return Md.getState(t)?.undoManager??null}catch(e){return X(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var fp=fi(`MAX_CACHE`,10),pp=fi(`VIEW_COUNT_CACHE_THRESHOLD`,50),mp=fi(`BYTES_CACHE_THRESHOLD`,8e6);function hp(e){return!(e.viewCount>0&&e.viewCount>=pp||e.bytes>mp)}var gp=new Map,_p=new Map,vp=new Map;function yp(e,t){if(vp.size>=fp){let e=vp.keys().next().value;e!==void 0&&vp.delete(e)}vp.set(e,t),X(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function bp(e){return vp.get(e)??null}function xp(e){if(!vp.has(e))return;let t=vp.get(e)??null;vp.delete(e),X(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function Sp(){try{return typeof document>`u`?0:document.querySelector(`[data-testid="editor-scroll-container"]`)?.scrollTop??0}catch(e){return X(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function Cp(e){try{let t=e.state.selection;return t instanceof y?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof bt?{type:`node`,from:t.from}:null}catch(e){return X(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function wp(e){for(let t of e)try{let e=Gp(t.fromDocName);if(e&&!e.editor.isDestroyed){if(e.ytext.length===0){X(`ok/cache/snapshot-skipped-empty`,{fromDocName:t.fromDocName});continue}yp(t.toDocName,{html:e.editor.getHTML(),scrollTop:Sp(),selection:Cp(e.editor)})}else X(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){X(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var Tp=[],Ep=[],Dp=new Set;function Op(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-parking`,``),e.style.display=`none`,e.style.position=`absolute`,e.style.left=`-99999px`,e}function kp(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!hp(i)){let e=r(n);return X(`ok/cache/miss`,{docName:t,mountId:Pf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`}),{editor:e.editor,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=gp.get(t);if(a){if(X(`ok/cache/reparent-start`,{docName:t,mountId:Pf(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Lp(a,n),a.activeMountKey=t,zp(Tp,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return X(`ok/cache/reparent-end`,{docName:t,mountId:Pf(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),X(`ok/cache/hit`,{docName:t,mountId:Pf(t),kind:`tiptap`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:Pf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;gp.size>=fp;){let e=Bp(Tp,t);if(!e)break;jp(e)}let o=r(n),s={editor:o.editor,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return gp.set(t,s),zp(Tp,t),X(`ok/cache/miss`,{docName:t,mountId:Pf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:Pf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function Ap(e){let t=e.activeMountKey;if(e.__uncached){t&&cp(t);let n=dp(e.editor);try{e.editor.destroy()}catch(e){X(`ok/cache/park-destroy-failed`,{docName:t??``,kind:`tiptap`,message:e instanceof Error?e.message:String(e)})}n&&(n.restore=void 0),e.activeMountKey=null;return}let n=Fp(e.editor);if(n){e.hadFocus=Ip(n.dom),e.scrollTop=(n.scrollDOM??n.dom.parentElement??n.dom).scrollTop??0;let t=n.dom.parentElement;t&&t.removeChild(n.dom),e.parkingNode||=Op(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function jp(e){cp(e);let t=gp.get(e);if(!t)return!1;let n=dp(t.editor);try{t.editor.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}n&&(n.restore=void 0);try{t.provider.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}gp.delete(e);let r=Tp.indexOf(e);return r!==-1&&Tp.splice(r,1),X(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function Mp(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!hp(i)){let e=r(n);return X(`ok/cache/miss`,{docName:t,mountId:Pf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,themeCompartment:e.themeCompartment,wordWrapCompartment:e.wordWrapCompartment,placeholderCompartment:e.placeholderCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=_p.get(t);if(a){if(X(`ok/cache/reparent-start`,{docName:t,mountId:Pf(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Rp(a,n),a.activeMountKey=t,zp(Ep,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return X(`ok/cache/reparent-end`,{docName:t,mountId:Pf(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),X(`ok/cache/hit`,{docName:t,mountId:Pf(t),kind:`cm`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:Pf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;_p.size>=fp;){let e=Bp(Ep,t);if(!e)break;Pp(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,themeCompartment:o.themeCompartment,wordWrapCompartment:o.wordWrapCompartment,placeholderCompartment:o.placeholderCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return _p.set(t,s),zp(Ep,t),X(`ok/cache/miss`,{docName:t,mountId:Pf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:Pf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function Np(e){if(e.__uncached){try{e.view.destroy()}catch(t){X(`ok/cache/park-destroy-failed`,{docName:e.activeMountKey??``,kind:`cm`,message:t instanceof Error?t.message:String(t)})}e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=Ip(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=Op(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function Pp(e){let t=_p.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}_p.delete(e);let n=Ep.indexOf(e);return n!==-1&&Ep.splice(n,1),X(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function Fp(e){return e.editorView??null}function Ip(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function Lp(e,t){let n=Fp(e.editor);if(!n)return;let r=n.dom,i=r.parentElement;i&&i!==t&&i.removeChild(r),r.parentElement!==t&&t.appendChild(r)}function Rp(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function zp(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function Bp(e,t){for(let n of e)if(n!==t&&!Dp.has(n))return n;X(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:Dp.size});for(let n of e)if(n!==t)return n;return null}function Vp(e){let t=Dp,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=Up(e);if(t)try{t.disconnect(),X(`ok/cache/disconnect`,{docName:e})}catch(t){X(`ok/cache/disconnect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}}for(let e of n){if(t.has(e))continue;let n=Up(e);if(!n)continue;let r=t=>{X(`ok/cache/connect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})};try{let t=n.connect();t&&typeof t.then==`function`?t.then(()=>X(`ok/cache/connect`,{docName:e}),e=>r(e)):X(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}Dp=n}var Hp=null;function Up(e){let t=gp.get(e);if(t)return t.provider;let n=_p.get(e);if(n)return n.provider;if(Hp){let t=Hp.entries.get(e);if(t)return t.provider}return null}function Wp(e){Hp=e;let t=e.onEvict(e=>{jp(e),Pp(e)});return()=>{t(),Hp===e&&(Hp=null)}}function Gp(e){return gp.get(e)}function Kp(e,t){let n=e.replace(/^\/+|\/+$/g,``);return`${E}${n?`${n}/`:``}${t}`}function qp(e,t){return`${Ve}/${e}/${t}`}function Jp(e){let t=`${Ve}/`;if(!e.startsWith(t)||!e.endsWith(`/SKILL`))return null;let n=e.slice(t.length,e.length-6);return n&&!n.includes(`/`)?n:null}function Yp(e){return I.includes(e)}var Xp=`ok-editor-tabs-v1:`,Zp=`\0folder:`,Qp=`\0asset:`,$p=`\0skill-file:`,em=`\0doc-tab:`,tm=/\.(md|mdx)$/i;function nm(e){let t=e.lastIndexOf(em);return t<0?{baseTabId:e,instanceSuffix:``}:{baseTabId:e.slice(0,t),instanceSuffix:e.slice(t)}}function rm(e){return nm(e).baseTabId}function im(e){return tm.test(e)?e.replace(tm,``):null}function am(e){if(typeof e!=`string`||e.length===0)return!1;let t=rm(e);return t.startsWith(Zp)?t.length>8:t.startsWith(Qp)?t.length>7:t.startsWith($p)?sm(t)!==null:!0}function om(e){return`${$p}${e.scope}/${e.name}/${e.path}`}function sm(e){if(!e.startsWith($p))return null;let t=e.slice(12).split(`/`);if(t.length<3)return null;let[n,r,...i]=t,a=i.join(`/`);return!n||!r||!a||!Yp(n)?null:{scope:n,name:r,path:a}}function cm(e){return e}function lm(e){return`${Zp}${e}`}function um(e){return`${Qp}${e}`}function dm(e,t){let n=Jp(e);if(n){let e=qn(n);return{baseName:e,extension:``,label:e,prefix:``}}let r=e.lastIndexOf(`/`),i=r<0?e:e.slice(r+1),a=tm.test(t)&&tm.test(i)?``:t,o=`${i}${a}`;return r<0?{baseName:i,extension:a,label:o,prefix:``}:{baseName:i,extension:a,label:o,prefix:`${e.slice(0,r)}/`}}function fm(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return cm(e.docName);case`folder`:return lm(e.folderPath);case`missing`:return cm(e.target);case`asset`:return um(e.assetPath);case`skill-file`:return om(e)}}function pm(e){let t=rm(e);if(t.startsWith(Zp))return{kind:`folder`,folderPath:t.slice(8)};if(t.startsWith(Qp))return{kind:`asset`,assetPath:t.slice(7)};let n=sm(t);return n?{kind:`skill-file`,...n}:{kind:`doc`,docName:t}}function mm(e){let t=pm(e);return t.kind===`doc`?t.docName:null}function hm(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(am(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function gm(e,t){let n=new Set(hm(t,2**53-1));return hm(e,2**53-1).filter(e=>n.has(e))}function _m(e,t,n){if(t<=0)return[];let r=new Set(hm(n,2**53-1)),i=hm(e,2**53-1);if(r.size===0&&i.length<=t)return i;let a=[],o=0;for(let e=i.length-1;e>=0;e--){let n=i[e];if(r.has(n)){a.push(n);continue}o>=t||(o++,a.push(n))}return a.reverse()}function vm(e,t,n){let r=gm(e,n);return!hm(n,2**53-1).includes(t)||r.includes(t)?r:[...r,t]}function ym(e,t){return hm(e,2**53-1).filter(e=>e!==t)}function bm(e,t){let n=new Set(hm(t,2**53-1));return hm(e,2**53-1).filter(e=>!n.has(e))}function xm(e,t,n){let r=hm(e,2**53-1),i=gm(t,r),a=r.indexOf(n);if(a<0)return i;let o=i.includes(n),s=a<i.length;return o===s?i:s?vm(i,n,r):ym(i,n)}function Sm(e,t,n,r=[]){let i=_m(e,n,r);return!am(t)||i.includes(t)?i:_m([...i,t],n,r)}function Cm(e,t,n,r,i=[]){let a=_m(e,r,i);if(!am(n))return a;if(!t||t===n)return Sm(a,n,r,i);let o=a.filter(e=>e!==n),s=o.indexOf(t);if(s<0)return Sm(o,n,r,i);let c=[...o];return c[s]=n,_m(c,r,i)}function wm(e,t,n){return Tm(e,cm(t),n)}function Tm(e,t,{behavior:n,currentTabId:r,limit:i,pinnedTabIds:a=[]}){let o=_m(e,i,a),s=rm(t);if(r&&o.includes(r)&&rm(r)===s)return{tabs:o,activeTabId:r};let c=o.find(e=>rm(e)===s);return c?{tabs:o,activeTabId:c}:n===`replace-active`?{tabs:Cm(o,r,s,i,a),activeTabId:s}:{tabs:Sm(o,s,i,a),activeTabId:s}}function Em(e,t){return e.filter(e=>e!==t)}function Dm(e,t,n){let r=hm(t,2**53-1),i=new Set(r),a=new Set(n),o=new Set,s=[];for(let t of e)o.has(t)||!i.has(t)&&!a.has(t)||(o.add(t),s.push(t));for(let e of[...r,...n])o.has(e)||(o.add(e),s.push(e));return s}function Om(e,{pages:t,folderPaths:n,assetPaths:r,filePaths:i,keepMissingDocName:a=null,keepHashDocName:o=null}){return hm(e,2**53-1).filter(e=>{let s=pm(e);if(s.kind===`folder`)return n.has(s.folderPath);if(s.kind===`asset`)return r.has(s.assetPath)||i?.has(s.assetPath)===!0;if(s.kind===`skill-file`)return!0;let c=im(s.docName);return t.has(s.docName)||c!==null&&t.has(c)||L(s.docName)||s.docName===a||s.docName===o})}function km(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return hm(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=new Map(a.flatMap(e=>{let t=im(e.fromPath);return t?[[t,e.toPath]]:[]})),c=new Map(a.flatMap(e=>{let t=im(e.toPath);return t?[[e.fromPath,t]]:[]})),l=e=>Mm(jm(e,r),a),u=(e,t)=>{let n=o.get(e);if(n)return n;let r=s.get(e);return r?um(r):t},d=e=>{let t=c.get(e);return t?cm(t):um(l(e))},f=[],p=new Set;for(let t of e){let{instanceSuffix:e}=nm(t),a=pm(t),o=`${a.kind===`doc`?u(a.docName,rm(t)):a.kind===`folder`?lm(jm(a.folderPath,r)):a.kind===`asset`?d(a.assetPath):rm(t)}${e}`;if(!p.has(o)&&(p.add(o),f.push(o),i.length===0&&f.length>=n))break}return i.length===0?f:_m(f,n,i.map(e=>{let t=pm(e);return t.kind===`doc`?u(t.docName,e):t.kind===`folder`?lm(jm(t.folderPath,r)):t.kind===`asset`?d(t.assetPath):rm(e)}))}function Am(e,t,n=[],r=[]){return km(e,t,2**53-1,n,[],r)}function jm(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function Mm(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function Nm(e,t,n){if(t!==n)return t;let r=e.indexOf(n);return r<0?e[0]??null:e[r+1]??e[r-1]??null}function Pm(e,t,n){if(!t)return null;let r=new Set(n);if(!r.has(t))return t;let i=e.indexOf(t);if(i<0)return e.find(e=>!r.has(e))??null;for(let t=i+1;t<e.length;t++)if(!r.has(e[t]))return e[t];for(let t=i-1;t>=0;t--)if(!r.has(e[t]))return e[t];return null}function Fm(e,t){if(typeof e!=`object`||!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};let n=e,r=hm(n.openTabs,2**53-1),i=gm(n.pinnedTabIds,r),a=i.length===0?hm(n.openTabs,t):_m(r,t,i),o=gm(n.pinnedTabIds,a),s=typeof n.activeTabId==`string`&&a.includes(n.activeTabId)?n.activeTabId:typeof n.activeDocName==`string`&&a.includes(n.activeDocName)?n.activeDocName:null,c=s?pm(s):null;return{openTabs:a,pinnedTabIds:o,activeDocName:c?.kind===`doc`?c.docName:null,activeTabId:s,updatedAt:typeof n.updatedAt==`string`?n.updatedAt:null}}function Im(e,t,n=[],r=()=>new Date){let i=hm(e,2**53-1),a=t&&i.includes(t)?t:null,o=a?pm(a):null;return{openTabs:i,pinnedTabIds:gm(n,i),activeDocName:o?.kind===`doc`?o.docName:null,activeTabId:a,updatedAt:r().toISOString()}}function Lm(e){return`${Xp}${e}`}function Rm(e,t,n){if(!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};try{let r=e.getItem(t);return r?Fm(JSON.parse(r),n):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}catch(e){return console.warn(`[editor-tabs] failed to read local tab session:`,e),{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}}function zm(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch(e){console.warn(`[editor-tabs] failed to write local tab session:`,e)}}var Bm=e=>Ai((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),Vm=(e,t)=>Ai((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(Hi(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),Hm=e=>Bm(indexedDB.deleteDatabase(e)),Um=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),Wm=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>th(r,e))},Gm=(e,t)=>Bm(e.count(t)),Km=(e,t)=>Bm(e.get(t)),qm=(e,t)=>Bm(e.delete(t)),Jm=(e,t,n)=>Bm(e.put(t,n)),Ym=(e,t)=>Bm(e.add(t)),Xm=(e,t,n)=>Bm(e.getAll(t,n)),Zm=(e,t,n)=>{let r=null;return eh(e,t,e=>(r=e,!1),n).then(()=>r)},Qm=(e,t=null)=>Zm(e,t,`prev`),$m=(e,t)=>Ai((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),eh=(e,t,n,r=`next`)=>$m(e.openKeyCursor(t,r),e=>n(e.key)),th=(e,t)=>e.objectStore(t),nh=(e,t)=>IDBKeyRange.upperBound(e,t),rh=(e,t)=>IDBKeyRange.lowerBound(e,t),ih=`custom`,ah=`updates`,oh=(e,t=()=>{},n=()=>{})=>{let[r]=Wm(e.db,[ah]);return Xm(r,rh(e._dbref,!1)).then(i=>{e._destroyed||(t(r),ki(e.doc,()=>{i.forEach(t=>Gi(e.doc,t))},e,!1),n(r))}).then(()=>Qm(r).then(t=>{e._dbref=t+1})).then(()=>Gm(r).then(t=>{e._dbsize=t})).then(()=>r)},sh=(e,t=!0)=>oh(e).then(n=>{(t||e._dbsize>=500)&&Ym(n,Ti(e.doc)).then(()=>qm(n,nh(e._dbref,!0))).then(()=>Gm(n).then(t=>{e._dbsize=t}))}),ch=class extends oa{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=Vm(e,e=>Um(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=Ai(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,oh(this,async e=>{await Gm(e)>0&&Ym(e,Ti(t))},()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=Wm(this.db,[ah]);Ym(t,e).catch(e=>{globalThis.__okYdbWriteWarned||(globalThis.__okYdbWriteWarned=!0,console.warn(JSON.stringify({event:`ok-ydb-write-failed`,cause:e?.name??`unknown`,message:e?.message??String(e)})))}),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{sh(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{Hm(this.name)})}get(e){return this._db.then(t=>{let[n]=Wm(t,[ih],`readonly`);return Km(n,e)})}set(e,t){return this._db.then(n=>{let[r]=Wm(n,[ih]);return Jm(r,t,e)})}del(e){return this._db.then(t=>{let[n]=Wm(t,[ih]);return qm(n,e)})}},lh=`updates`,uh=`custom`;function dh(){return!0}var fh=class{_idb;_dbName;whenSynced;constructor({branch:e,serverInstanceId:t,docName:n,doc:r}){if(typeof t!=`string`||t.length===0)throw Error(`createClientPersistence: serverInstanceId is required and must be non-empty`);this._dbName=`ok-ydoc:${e}:${t}:${n}`;let i=dh()?0:performance.now();this._idb=new ch(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!dh()){let e=performance.now();X(`ok/pool/idb-whensynced`,{docName:n,durationMs:Math.round((e-i)*1e3)/1e3},{startTime:i,duration:e-i})}return this})}get synced(){return this._idb.synced}async destroy(){let e=dh()?0:performance.now();try{await this._idb.destroy()}finally{if(!dh()){let t=performance.now();X(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async flushFullState(){this._idb.db===null&&await this.whenSynced;let e=this._idb.db;if(e===null)return;let t=this._idb;await new Promise((n,r)=>{let i=e.transaction(lh,`readwrite`),a=i.objectStore(lh),o=a.getAll();o.onerror=()=>r(o.error??Error(`flushFullState getAll failed`)),o.onsuccess=()=>{try{ki(t.doc,()=>{for(let e of o.result)Gi(t.doc,e)},t,!1);let e=a.add(Ti(t.doc));e.onerror=()=>r(e.error??Error(`flushFullState add failed`)),e.onsuccess=()=>{a.delete(IDBKeyRange.upperBound(e.result,!0))}}catch(e){r(e instanceof Error?e:Error(String(e)));try{i.abort()}catch{}}},i.oncomplete=()=>n(),i.onabort=()=>r(i.error??Error(`flushFullState transaction aborted`))})}async clearData(){let e=dh()?0:performance.now();try{await this._idb.destroy();let e=this._dbName;await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(),r.onerror=()=>n(r.error),r.onblocked=()=>{console.warn(JSON.stringify({event:`ok-client-persistence-clear-blocked`,dbName:e}))}})}finally{if(!dh()){let t=performance.now();X(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function ph(e){return new fh(e)}async function mh(e){if(typeof indexedDB>`u`)return null;let t=`ok-ydoc:${e.branch}:${e.serverInstanceId}:${e.docName}`;if(typeof indexedDB.databases==`function`&&!(await indexedDB.databases()).some(e=>e.name===t))return null;let n=await new Promise((e,n)=>{let r=indexedDB.open(t);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(lh)||e.createObjectStore(lh,{autoIncrement:!0}),e.objectStoreNames.contains(uh)||e.createObjectStore(uh)},r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)});try{if(!n.objectStoreNames.contains(lh))return null;let e=await new Promise((e,t)=>{let r=n.transaction(lh,`readonly`).objectStore(lh).getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)});if(e.length===0)return null;let t=new ia;try{ki(t,()=>{for(let n of e)Gi(t,n)});let n=t.getMap(`lifecycle`).get(k);return typeof n==`string`&&n.length>0?n:null}finally{t.destroy()}}finally{n.close()}}function hh(e){return Fi(e)}function gh(e,t){return t===null?Ti(e):Ti(e,t)}function _h(e,t){if(e===null)return t;if(t===null)return e;let n=Ei(e),r=Ei(t),i=new Map;for(let[e,t]of n)i.set(e,t);for(let[e,t]of r){let n=i.get(e);(n===void 0||t>n)&&i.set(e,t)}return Fi(i)}function vh(e){let t={};if(Mt.inject(jt.active(),t),!t.traceparent)return e;let n=e.includes(`?`)?`&`:`?`,r=[`traceparent=${encodeURIComponent(t.traceparent)}`];return t.tracestate&&r.push(`tracestate=${encodeURIComponent(t.tracestate)}`),`${e}${n}${r.join(`&`)}`}var yh=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new Et({key:e||new ke(`fileHandler`),props:{handleDrop(e,n){if(!r||!n.dataTransfer?.files.length)return!1;let a=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return i&&(o=o.filter(e=>i.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),r(t,o,a?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let a=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return i&&(a=a.filter(e=>i.includes(e.type))),!(a.length===0||(r.preventDefault(),r.stopPropagation(),n(t,a,o),o.length>0))}}}),bh=Y.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[yh({key:new ke(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function xh(e,t){let{state:n,view:r}=e;if(!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount!==0||!bt.isSelectable(o))return!1;try{let t=bt.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Xe(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}function Sh(e){let{state:t,view:n}=e;if(!(t.selection instanceof y)||!t.selection.empty||!n.endOfTextblock(`up`))return!1;let r=t.selection.$head,i=-1;for(let e=r.depth-1;e>=1;e--)if(r.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;for(let e=r.depth;e>i;e--)if(r.index(e-1)!==0)return!1;let a=r.before(i);try{let n=t.doc.resolve(a),r=wt.findFrom(n,-1,!0);return!r||!(r instanceof y)?!1:(e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return Xe(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2c`,reason:e.message.slice(0,500)})),!0}}function Ch(e,t){let{state:n,view:r}=e;if(!(n.selection instanceof y)||!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount===0)return!1;let c=s+o.nodeSize;try{let t=a?s+1:c-1,r=wt.findFrom(n.doc.resolve(t),a?1:-1,!0);return!r||!(r instanceof y)||r.$head.pos<=s||r.$head.pos>=c?!1:(e.view.dispatch(n.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return Xe(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L2d`,reason:e.message.slice(0,500)})),!0}}var wh=Y.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof bt){if(t.selection.$from.depth===0)return e.commands.blur(),!0;let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=y.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof y?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(xh(e,`up`)||Sh(e)||Ch(e,`up`))return!0;let{state:t}=e;if(!(t.selection instanceof bt))return!1;let n=t.selection.from,r=t.doc.resolve(n);if(r.index(r.depth)===0)return!1;let i=r.before(r.depth);if(i<=0)return!1;let a=t.doc.resolve(i-1).nodeBefore;if(!a||i-1-a.nodeSize+1<0)return!1;try{let n=bt.create(t.doc,i-a.nodeSize);return e.view.dispatch(t.tr.setSelection(n).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Xe(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowDown:({editor:e})=>{if(xh(e,`down`)||Ch(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof bt))return!1;let n=t.selection.from+t.selection.node.nodeSize;if(n>=t.doc.content.size)return!1;try{if(!t.doc.nodeAt(n))return!1;let r=bt.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Xe(`down`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`down`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowLeft:({editor:e})=>xh(e,`left`)||Ch(e,`left`),ArrowRight:({editor:e})=>xh(e,`right`)||Ch(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof y)||!t.selection.empty)return!1;let n=t.selection.$from,r=n.parent;if(r.type.name!==`paragraph`||r.textContent!==``||n.depth<2)return!1;let i=-1;for(let e=n.depth-1;e>=1;e--)if(n.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;let a=n.node(i);if(n.index(i)!==a.childCount-1)return!1;let o=n.after(i);if(o>t.doc.content.size)return!1;let s=t.tr,c=n.before(n.depth),l=n.after(n.depth);s.delete(c,l);let u=o-(l-c),d=t.schema.nodes.paragraph.create();s.insert(u,d);let f=u+1;return s.setSelection(y.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),Th={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},Eh=/[A-Za-z0-9_]/;function Dh(e){return e!==void 0&&Eh.test(e)}function Oh(e,t,n){return!Dh(e[t-1])&&!Dh(e[n])}function kh(e,t,n){if(t.length===0)return[];let r=n.caseSensitive?e:e.toLocaleLowerCase(),i=n.caseSensitive?t:t.toLocaleLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let t=r.indexOf(i,o);if(t===-1)break;let s=t+i.length;(!n.wholeWord||Oh(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function Ah(e,t,n){if(t.length===0)return[];let r=[];return e.descendants((e,i)=>{if(!(!e.isText||typeof e.text!=`string`))for(let a of kh(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var jh=new ke(`findReplace`);function Mh(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function Nh(e,t,n,r){let i=Ah(e.doc,t,n);return{query:t,options:n,activeIndex:Mh(r,i.length),matches:i}}function Ph(e,t,n){return t<=0?0:(Mh(e,t)+n+t)%t}function Fh(e,t,n){if(e.length===0)return 0;let r=t+n,i=e.findIndex(e=>e.from>=r);return i===-1?0:i}function Ih(e,t,n){if(t.matches.length===0)return null;let r=e.tr;for(let e of[...t.matches].reverse())r.insertText(n,e.from,e.to);let i=Ah(r.doc,t.query,t.options),a=Mh(0,i.length),o=i[a];return r.setMeta(jh,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(y.create(r.doc,o.from,o.to)),r.scrollIntoView()}function Lh(e,t){let n=jh.getState(e)?.matches[t];return n?e.tr.setMeta(jh,{type:`setActiveIndex`,activeIndex:t}).setSelection(y.create(e.doc,n.from,n.to)).scrollIntoView():null}function Rh(e){return jh.getState(e)??Th}function zh(){return new Et({key:jh,state:{init:()=>Th,apply(e,t,n,r){let i=e.getMeta(jh);if(i?.type===`clear`)return Th;let a=t.query,o=t.options,s=t.activeIndex;if(i?.type===`setQuery`)a=i.query,o={...o,...i.options},s=i.activeIndex??0;else if(i?.type===`setOptions`)o={...o,...i.options},s=i.activeIndex??s;else if(i?.type===`setActiveIndex`)s=i.activeIndex;else if(!e.docChanged)return t;return a.length===0?{query:a,options:o,activeIndex:0,matches:[]}:Nh(r,a,o,s)}},props:{decorations(e){let t=jh.getState(e);return!t||t.matches.length===0?null:Ue.create(e.doc,t.matches.map((e,n)=>rt.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var Bh=Y.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(jh,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(jh,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(jh,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=Rh(e),r=Lh(e,Ph(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=Rh(e),r=Lh(e,Ph(n.activeIndex,n.matches.length,-1));return r?(t?.(r),!0):!1},replaceCurrentFindMatch:e=>({state:t,dispatch:n})=>{let r=Rh(t),i=r.matches[r.activeIndex];if(!i||!n)return!1;let a=t.tr.insertText(e,i.from,i.to),o=Ah(a.doc,r.query,r.options),s=Fh(o,i.from,e.length),c=o[s];return a.setMeta(jh,{type:`setActiveIndex`,activeIndex:s}),c&&a.setSelection(y.create(a.doc,c.from,c.to)),a.scrollIntoView(),n(a),!0},replaceAllFindMatches:e=>({state:t,dispatch:n})=>{let r=Rh(t);if(!n)return!1;let i=Ih(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(jh,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[zh()]}}),Vh=/^(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/i,Hh=/^([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/,Uh=/[-\d_]$/,Wh=yt.map(e=>`${e}:`);function Gh(e){let t=e.toLowerCase();return Wh.some(e=>t.startsWith(e))}function Kh(e,t){let n=0;for(let r of e)r===t&&n++;return n}function qh(e){let t=e.split(`.`),n=t[t.length-1],r=t[t.length-2];return!(n&&(/_/.test(n)||!/[a-zA-Z\d]/.test(n))||r&&(/_/.test(r)||!/[a-zA-Z\d]/.test(r)))}function Jh(e){return e.split(`.`).length>=2&&qh(e)}function Yh(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,``];let n=e.slice(0,t.index),r=t[0],i=r.indexOf(`)`),a=Kh(n,`(`),o=Kh(n,`)`);for(;i!==-1&&a>o;)n+=r.slice(0,i+1),r=r.slice(i+1),i=r.indexOf(`)`),o++;return[n,r]}function Xh(e){let t=Vh.exec(e);if(!t)return null;let n=t[1],r=t[2],i=t[3],a=``,o=/^w/i.test(n);if(o&&(r=n+r,n=``,a=`http://`),o?!Jh(r):!qh(r))return null;let[s]=Yh(r+i);if(!s)return null;let c=n+s,l=a+n+s;return Gh(l)?{href:l,text:c}:null}function Zh(e){let t=Hh.exec(e);if(!t)return null;let n=t[1],r=t[2];if(Uh.test(r))return null;let i=`${n}@${r}`,a=`mailto:${i}`;return Gh(a)?{href:a,text:i}:null}function Qh(e){return e?Xh(e)??Zh(e):null}function $h(e,t){let n=Md.getState(e.state)?.undoManager;n?.stopCapturing();try{e.dispatch(t)}finally{n?.stopCapturing()}}var eg=`\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000`,tg=RegExp(`[${eg}]`),ng=RegExp(`[${eg}]$`),rg=`link`,ig=`gfm-autolink`,ag=`preventAutolink`,og=new ke(`gfmAutolink`);function sg(e,t,n){let r=e.state.schema.marks.code;return r?e.state.doc.rangeHasMark(t,n,r):!1}function cg(e,t,n){let r=[],i=f(be(e.doc,[...n]));for(let{newRange:e}of i){let n=ie(t.doc,e,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=t.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length===1){let r=t.doc.textBetween(e.from,e.to,` `,` `);if(!ng.test(r))continue;i=n[0],a=t.doc.textBetween(i.pos,e.to,void 0,` `)}if(!i||!a||i.node.type.spec.code)continue;let o=a.split(tg).filter(Boolean),s=o[o.length-1];if(!s)continue;let c=Qh(s);if(!c)continue;let l=i.pos+a.lastIndexOf(s)+1,u=l+c.text.length;r.push({from:l,to:u,href:c.href,text:c.text})}return r}function lg(e={}){let t=e.isActiveEditor??(e=>e.hasFocus()),n=null,r=!1,i=[],a=()=>{r=!1;let e=n,a=i.splice(0,i.length);if(!e||e.isDestroyed||e.composing||!t(e))return;let o=e.state.schema.marks[rg];if(!o)return;let s=e.state.tr,c=!1,l=e.state.doc.content.size;for(let t of a){let{from:n,to:r,href:i,text:a}=t;n<0||r>l||n>=r||e.state.doc.textBetween(n,r)===a&&(Ie(n,r,e.state.doc).some(e=>e.mark.type===o)||sg(e,n,r)||(s=s.addMark(n,r,o.create({href:i,linkStyle:ig})),c=!0))}if(c){s=s.setMeta(ag,!0);try{$h(e,s)}catch(e){console.warn(`[gfm-autolink] linkify dispatch failed`,{candidates:a.map(e=>({from:e.from,to:e.to,href:e.href}))},e)}}};return new Et({key:og,view(e){return n=e,{destroy(){n=null,i.length=0,r=!1}}},appendTransaction(e,o,s){if(e.some(e=>e.getMeta(jd))||e.some(e=>e.getMeta(`preventAutolink`))||!(e.some(e=>e.docChanged)&&!o.doc.eq(s.doc))||!n||!t(n))return null;let c=cg(o,s,e);return c.length===0?null:(i.push(...c),r||(r=!0,queueMicrotask(a)),null)}})}var ug=Y.create({name:`gfmAutolink`,addOptions(){return{isActiveEditor:void 0}},addProseMirrorPlugins(){return[lg({isActiveEditor:this.options.isActiveEditor})]}}),dg=new ke(`imageUpload`);function fg(e){let t=document.createElement(`div`);t.className=`image-upload-skeleton w-full h-40 rounded-md bg-muted animate-pulse motion-reduce:animate-none my-2`,t.setAttribute(`data-upload-widget`,`loading`),t.setAttribute(`role`,`status`);let n=e?.name;return t.setAttribute(`aria-label`,n?ai._({id:`KDuPiY`,values:{fileName:n}}):ai._({id:`bGa3Fk`})),t}var pg=new Et({key:dg,state:{init(){return{decorations:Ue.empty,uploads:new Map}},apply(e,t){let n=t.decorations.map(e.mapping,e.doc),r=new Map;for(let[n,i]of t.uploads)r.set(n,e.mapping.map(i));let i=e.getMeta(dg);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=rt.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),a=n.add(e.doc,[t]),o=new Map(r);return o.set(i.id,e.mapping.map(i.pos)),{decorations:a,uploads:o}}if(i.type===`remove`){let e=n.find(void 0,void 0,e=>e.id===i.id),t=n.remove(e),a=new Map(r);return a.delete(i.id),{decorations:t,uploads:a}}return{decorations:n,uploads:r}}},props:{decorations(e){return dg.getState(e)?.decorations??Ue.empty}}});function mg(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function hg(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function gg(e){return e.split(`/`).filter(e=>e!==``)}function _g(e,t){let n=mg(e),r=mg(t),i=hg(e);if(n===r)return i;let a=gg(r),o=gg(n),s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s++;let c=a.length-s,l=o.slice(s);return c===0?`./${[...l,i].join(`/`)}`:[...Array(c).fill(`..`),...l,i].join(`/`)}function vg(e){return Yt(e)}function yg(e,t){return{type:`jsxComponent`,attrs:{componentName:e===`jsx-img`?`img`:e===`jsx-video`?`video`:`audio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:e===`jsx-img`?{src:t}:{src:t,controls:!0}}}}function bg(e){let t=it(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:j.has(t)?{kind:`jsx-img`,ext:t}:z.has(t)?{kind:`jsx-video`,ext:t}:p.has(t)?{kind:`jsx-audio`,ext:t}:w.has(t)?{kind:`jsx-file`,ext:t}:K.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function xg(e,t,n){let r=vg(t),i=r?`${r}.md`:``;if(!i){sr.error(ai._({id:`z5pqI8`}));return}let a=crypto.randomUUID(),o=fg(e);t.view.dispatch(t.state.tr.setMeta(dg,{type:`add`,id:a,pos:n,widget:o}));let s=new FormData;s.append(`file`,e),s.append(`parentDocName`,i);let c;try{c=await fetch(`/api/upload`,{method:`POST`,body:s})}catch(e){console.error(`[uploadAndInsert] Network error:`,e),Sg(t,a);return}let l;try{l=await c.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),Sg(t,a);return}if(!c.ok){let e=qe.safeParse(l);if(!e.success){let n=new Ut(`Upload response did not match ProblemDetails.`,{cause:e.error,status:c.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),Sg(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),Sg(t,a,e.data.title);return}let u=Qe.safeParse(l);if(!u.success){let e=new Ut(`Upload success response did not match UploadAssetSuccess.`,{cause:u.error,status:c.status});console.error(`[uploadAndInsert] Response missing src:`,e),Sg(t,a);return}let d=u.data,f=d.src,p=d.deduped===!0,m=mg(i),h=typeof d.path==`string`&&d.path.length>0?d.path:m?`${m}/${f}`:f;p&&sr.info(ai._({id:`VbqhBI`,values:{assetContentPath:h}}));let g=bg(e.name),{state:_}=t,v=dg.getState(_)?.uploads.get(a)??n,y=_.tr.setMeta(dg,{type:`remove`,id:a}),b=_g(h,i),x=`/${h}`;if(g.kind===`jsx-file`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),Sg(t,a);return}let n={type:`jsxComponent`,attrs:{componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:{src:x,target:f,alias:null,anchor:null,size:xt(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(dg,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,n).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(bt.create(e.doc,n)),!0}).run();return}if(g.kind===`jsx-img`||g.kind===`jsx-video`||g.kind===`jsx-audio`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),Sg(t,a);return}let e=yg(g.kind,x);t.chain().command(({tr:e})=>(e.setMeta(dg,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,e).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(bt.create(e.doc,n)),!0}).run();return}if(g.kind===`wikiembed`){let e=_.schema.nodes.wikiLinkEmbed;if(!e){console.error(`[uploadAndInsert] wikiLinkEmbed node missing from schema`),Sg(t,a);return}y.insert(v,e.create({target:f,alias:null,anchor:null,resolvedSrc:x}))}else if(g.kind===`wiki-link`){let n=_.schema.nodes.wikiLink;if(!n){console.error(`[uploadAndInsert] wikiLink node missing from schema`),Sg(t,a);return}let r=an(e.name.replace(/\.(md|mdx)$/i,``));r?y.insert(v,n.create(r)):y.insert(v,_.schema.text(e.name))}else{let t=_.schema.marks.link;if(t){let n=_.schema.text(e.name,[t.create({href:b})]);y.insert(v,n)}else y.insert(v,_.schema.text(e.name))}t.view.dispatch(y)}function Sg(e,t,n){e.view.dispatch(e.state.tr.setMeta(dg,{type:`remove`,id:t})),sr.error(n??ai._({id:`b3Thhd`}))}var Cg=/\[([^\]]+)\]\(([^)\s]+)\)$/,wg=`link`;function Tg(e,t,n,r,i){if(e.isDestroyed||e.composing)return;let{state:a}=e,o=a.schema.marks[wg];if(!o)return;let s=t+n.length;if(t<0||s>a.doc.content.size||a.doc.textBetween(t,s)!==n||a.doc.rangeHasMark(t,s,o))return;let c=a.schema.text(r,[o.create({href:i})]);try{$h(e,a.tr.replaceRangeWith(t,s,c))}catch(e){console.warn(`[inline-link-rule] collapse dispatch failed`,{from:t,text:r,href:i},e)}}var Eg=Y.create({name:`inlineLinkInputRule`,addInputRules(){let e=this.editor;return[new me({find:Cg,handler:({state:t,range:n,match:r})=>{let i=r[1],a=r[2];if(!i||!a||!_(a))return null;let o=t.schema.marks[wg];if(!o||t.doc.rangeHasMark(n.from,n.to,o))return null;let s=n.from,c=r[0],l=e.view;return queueMicrotask(()=>Tg(l,s,c,i,a)),null}})]}}),Dg=new Set;function Og(e){Dg.add(e)}function kg(e){return Dg.delete(e)}var Ag=new ke(`markIdentity`);function jg(){return{byId:new Map,counter:0}}function Mg(e,t,n,r,i){let a=[];for(let e of t.byId.values()){let t=i?i.map(e.from,-1):e.from,n=i?i.map(e.to,1):e.to;n<=t||a.push({id:e.id,markType:e.markType,attrs:e.attrs,from:t,to:n})}let o=new Map,s=new Set,c=t.counter;return e.descendants((e,t)=>{if(!(!e.isInline||e.marks.length===0))for(let i of e.marks){if(!n.has(i.type.name)||r&&!r(i))continue;let l=null;for(let e of a)if(!s.has(e.id)&&e.markType===i.type.name&&Ng(e.attrs,i.attrs)&&!(t<e.from||t>=e.to)){l=e.id;break}let u=l??`m${++c}`;s.add(u);let d=t,f=t+e.nodeSize,p=o.get(u);p?p.to=Math.max(p.to,f):o.set(u,{id:u,markType:i.type.name,attrs:i.attrs,from:d,to:f})}}),{byId:o,counter:c}}function Ng(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i&&(typeof n!=`object`||!n||typeof i!=`object`||!i||!((Array.isArray(n)&&Array.isArray(i)||!Array.isArray(n)&&!Array.isArray(i)&&Object.getPrototypeOf(n)===Object.prototype&&Object.getPrototypeOf(i)===Object.prototype)&&Ng(n,i))))return!1}return!0}function Pg(e,t,n,r){let i=new Set(t.byId.keys());for(let[r,i]of t.byId)e.has(r)||n?.(i);for(let t of e)i.has(t)||r?.(t);return i}function Fg(e,t,n){let r=Ag.getState(e);if(!r)return null;for(let e of r.byId.values())if(e.markType===n&&e.from<=t&&t<e.to)return e.id;return null}function Ig(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new Et({key:Ag,state:{init(e,t){return Mg(t.doc,jg(),a,n)},apply(e,t,r,i){return e.docChanged?Mg(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=Ag.getState(t.state);n&&(e=Pg(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}var Lg=300,Rg=150,zg=500,Bg=class{registry=new Map;_activeNodeId=null;listeners=new Set;_snapshot={activeNodeId:null,active:null};register(e){this.registry.set(e.nodeId,e),this._activeNodeId===e.nodeId&&this.refreshSnapshot()}deregister(e){this.registry.delete(e)&&this._activeNodeId===e&&(this._activeNodeId=null,this.refreshSnapshot())}setActiveNode(e){this._activeNodeId!==e&&(e!==null&&!this.registry.has(e)||(this._activeNodeId=e,this.refreshSnapshot()))}getActiveNode(){return this._activeNodeId}getRegistration(e){return this.registry.get(e)}hasRegistration(e){return this.registry.has(e)}clear(){this.registry.clear(),this._activeNodeId=null,this.refreshSnapshot()}getSnapshot=()=>this._snapshot;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});refreshSnapshot(){let e=this._activeNodeId==null?null:this.registry.get(this._activeNodeId)??null;this._snapshot={activeNodeId:this._activeNodeId,active:e};for(let e of this.listeners)e()}};function Vg(e,t){let n=e??null;for(;n&&typeof n==`object`;){let e=n.getAttribute;if(typeof e==`function`){let r=e.call(n,`data-mark-id`);if(r&&t.hasRegistration(r))return r;let i=e.call(n,`data-node-id`);if(i&&t.hasRegistration(i))return i}n=n.parentElement??null}return null}function Hg(e){return e?e.closest(`[data-ok-prop-panel]`)!==null:!1}function Ug(){return typeof document>`u`?!1:document.querySelector(`[data-ok-layer-spawned]`)!==null}var Wg=e=>{let t=(0,$.c)(18),{store:n}=e,r;t[0]===n?r=t[1]:(r=()=>n.getSnapshot(),t[0]=n,t[1]=r);let[i,a]=(0,Q.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>(a(n.getSnapshot()),n.subscribe(()=>{a(n.getSnapshot())})),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let{active:c}=i;if(!c)return null;let l;t[5]===n?l=t[6]:(l=()=>n.setActiveNode(null),t[5]=n,t[6]=l);let u,d,f;if(t[7]!==c.controls||t[8]!==c.nodeId||t[9]!==c.type||t[10]!==l){let e={nodeId:c.nodeId,type:c.type,deactivate:l};u=c.controls.propPanel?.(e),d=c.controls.toolbar?.(e),f=c.controls.breadcrumb?.(e),t[7]=c.controls,t[8]=c.nodeId,t[9]=c.type,t[10]=l,t[11]=u,t[12]=d,t[13]=f}else u=t[11],d=t[12],f=t[13];let p;return t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,Z.jsxs)(Z.Fragment,{children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17],p};function Gg(e){return e.editorView?.dom??null}function Kg(e,t){let n=e;for(;n;){if(n.getAttribute?.(`data-mark-id`)===t||n.getAttribute?.(`data-node-id`)===t)return!0;n=n.parentElement}return!1}function qg(e){let{editor:t}=e,n=new Bg,r=Gg(t),i=!1,a=null,o=null,s=null,c=null,l=null,u=()=>{a!==null&&(clearTimeout(a),a=null),s=null},d=()=>{o!==null&&(clearTimeout(o),o=null)},f=()=>{c!==null&&(clearTimeout(c),c=null)},p=e=>{if(n.getActiveNode()===e){d();return}s===e&&a!==null||(u(),d(),s=e,a=setTimeout(()=>{a=null,s=null,n.setActiveNode(e)},Lg))},m=()=>{n.getActiveNode()!==null&&o===null&&(o=setTimeout(()=>{o=null,!Ug()&&n.setActiveNode(null)},Rg))},h=null,g=!1,_=e=>{try{g=!0,e.focus({preventScroll:!0})}catch{}finally{g=!1}},v=n.subscribe(()=>{let e=n.getActiveNode();if(e!==null){if(typeof document<`u`){let t=document.activeElement;h=t&&Kg(t,e)?t:null}return}if(typeof document>`u`)return;let i=h;if(h=null,i&&document.contains(i)&&typeof i.focus==`function`){_(i);return}let a=r??Gg(t);a&&typeof a.focus==`function`&&_(a)}),y=e=>{let t=e;if(t.button!==2){if(t.metaKey||t.ctrlKey||t.button===1){u(),t.button===1&&t.preventDefault?.();return}if(t.pointerType===`touch`){let t=Vg(e.target,n);if(t===null)return;f(),c=setTimeout(()=>{c=null,l=t,n.setActiveNode(t)},zg);return}u()}},b=()=>{f()},x=e=>{e.pointerType===`touch`&&c!==null&&f()},S=e=>{let t=e;if(t.button===2||t.type===`click`&&t.button===1)return;let r=Vg(e.target,n);if(r===null)return;if(l!==null){let e=l===r;if(l=null,e){t.preventDefault?.();return}}let i=t.metaKey||t.ctrlKey||t.button===1,a=n.getRegistration(r);if(a?.handlePrimary&&a.handlePrimary({nodeId:r,type:a.type,newTab:i})){t.preventDefault?.(),i||(u(),d(),n.getActiveNode()===r&&n.setActiveNode(null));return}i||(u(),d(),n.setActiveNode(r))},C=e=>{let t=e;if(t.key===`Escape`){n.getActiveNode()!==null&&(u(),d(),n.setActiveNode(null),t.preventDefault?.());return}if(t.key===`Tab`&&!t.shiftKey&&!t.altKey&&!t.metaKey&&!t.ctrlKey){let r=Vg(e.target,n);if(r!==null&&n.getActiveNode()===r){let e=document.querySelector(`[data-ok-prop-panel]`);if(e){let n=e.querySelector(`button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(n){t.preventDefault?.(),n.focus();return}}}return}let r=t.key===`Enter`,i=t.key===` `||t.key===`Spacebar`;if(!r&&!i)return;let a=Vg(e.target,n);if(a===null||i&&((e.target instanceof Element?e.target:null)?.closest(`[data-mark-id], [data-node-id]`)??null)?.getAttribute(`role`)===`link`)return;let o=n.getRegistration(a);if(t.preventDefault?.(),o?.handlePrimary&&o.handlePrimary({nodeId:a,type:o.type,newTab:!1})){u(),d(),n.getActiveNode()===a&&n.setActiveNode(null);return}n.setActiveNode(a)},w=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target;if(!(r instanceof Element))return;if(Hg(r)){d();return}let i=Vg(r,n);i!==null&&p(i)},T=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target,i=t.relatedTarget;if(!(r instanceof Element))return;let a=i instanceof Element?i:null,o=Vg(r,n);if(o!==null){if(a&&Hg(a)){d();return}if(a&&Vg(a,n)===o)return;s===o&&u(),m();return}if(Hg(r)){if(a&&Hg(a))return;let e=n.getActiveNode();if(e!==null&&a&&Vg(a,n)===e)return;m()}},E=e=>{if(g)return;let t=e.target;if(!(t instanceof Element))return;let r=Vg(t,n);r!==null&&(u(),d(),n.setActiveNode(r))},D=e=>{let t=e;if(n.getActiveNode()===null)return;let r=t.relatedTarget,i=r instanceof Element?r:null;i&&Hg(i)||i&&Vg(i,n)!==null||m()},O=e=>{if(n.getActiveNode()===null)return;let t=e.target;t&&(r?.contains(t)||t instanceof Element&&(t.closest(`[data-ok-interaction-layer]`)||t.closest(`[data-ok-prop-panel]`)||t.closest(`[data-ok-layer-spawned]`))||(u(),d(),n.setActiveNode(null)))},k=()=>{i||(r=Gg(t),r&&(r.addEventListener(`pointerdown`,y,!0),r.addEventListener(`pointerup`,b,!0),r.addEventListener(`pointercancel`,b,!0),r.addEventListener(`pointermove`,x,!0),r.addEventListener(`click`,S,!0),r.addEventListener(`auxclick`,S,!0),r.addEventListener(`keydown`,C,!0),typeof document<`u`&&(document.addEventListener(`pointerover`,w,!0),document.addEventListener(`pointerout`,T,!0),document.addEventListener(`focusin`,E,!0),document.addEventListener(`focusout`,D,!0),document.addEventListener(`pointerdown`,O,!0)),i=!0))},A=()=>{i&&=(r?.removeEventListener(`pointerdown`,y,!0),r?.removeEventListener(`pointerup`,b,!0),r?.removeEventListener(`pointercancel`,b,!0),r?.removeEventListener(`pointermove`,x,!0),r?.removeEventListener(`click`,S,!0),r?.removeEventListener(`auxclick`,S,!0),r?.removeEventListener(`keydown`,C,!0),typeof document<`u`&&(document.removeEventListener(`pointerover`,w,!0),document.removeEventListener(`pointerout`,T,!0),document.removeEventListener(`focusin`,E,!0),document.removeEventListener(`focusout`,D,!0),document.removeEventListener(`pointerdown`,O,!0)),!1)};return k(),{register(e){n.register(e),i||k()},deregister(e){n.deregister(e)},setActiveNode(e){n.setActiveNode(e)},getActiveNode(){return n.getActiveNode()},getRegistration(e){return n.getRegistration(e)},destroy(){A(),u(),d(),f(),v(),n.clear()},store:n}}var Jg=e=>{let t=(0,$.c)(2),{store:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{"data-ok-interaction-layer":``,className:`contents`,children:(0,Z.jsx)(Wg,{store:n})}),t[0]=n,t[1]=r),r},Yg=new WeakMap;function Xg(e){let t=Yg.get(e);if(t)return t;let n=qg({editor:e});return Yg.set(e,n),e.on(`destroy`,()=>{n.destroy(),Yg.delete(e)}),n}var Zg={AppWindow:La,ChevronRight:Hn,CopyPlus:Yn,FileText:Tn,Film:kn,GitBranch:nr,Image:gn,LayoutPanelTop:so,MessageSquareWarning:go,PanelTop:bo,Paperclip:xo,Sigma:Oo,SquarePlay:Ao,Volume2:hn,Workflow:Po,ZoomIn:Pn};function Qg(e){return e&&Object.hasOwn(Zg,e)?Zg[e]:za}var $g={Info:rr,Lightbulb:co,MessageSquareWarning:go,AlertTriangle:or,AlertOctagon:vo,ClipboardList:Ka,BookOpen:Ra,ListTodo:mo,CircleCheck:Gn,CircleHelp:Wa,CircleX:Ga,Zap:Fo,Bug:Ba,FlaskConical:to,Quote:Co,ChevronRight:Hn},e_=Object.entries($g).sort(([e],[t])=>e.localeCompare(t));function t_(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn($g,t)?$g[t]??null:null}function n_(e){let t=(0,$.c)(24),n;t[0]===e.icon?n=t[1]:(n=t_(e.icon),t[0]=e.icon,t[1]=n);let r=n,i=r?`custom`:void 0,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Hn,{size:14,className:`accordion-chevron`,"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=r?(0,Z.jsx)(r,{size:16,className:`accordion-icon`,"aria-hidden":`true`}):null,t[3]=r,t[4]=o);let s=e.title??`Accordion`,c;t[5]===s?c=t[6]:(c=(0,Z.jsx)(`span`,{className:`accordion-title`,children:s}),t[5]=s,t[6]=c);let l;t[7]===e.description?l=t[8]:(l=e.description?(0,Z.jsx)(`span`,{className:`accordion-description`,children:e.description}):null,t[7]=e.description,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,Z.jsxs)(`span`,{className:`accordion-title-group`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==u?(d=(0,Z.jsxs)(`summary`,{className:`accordion-summary`,contentEditable:!1,children:[a,o,u]}),t[12]=o,t[13]=u,t[14]=d):d=t[14];let f;t[15]===e.children?f=t[16]:(f=(0,Z.jsx)(`div`,{className:`accordion-body`,children:e.children}),t[15]=e.children,t[16]=f);let p;return t[17]!==e.defaultOpen||t[18]!==e.id||t[19]!==e.name||t[20]!==i||t[21]!==d||t[22]!==f?(p=(0,Z.jsxs)(`details`,{className:`accordion`,"data-accordion-icon":i,open:e.defaultOpen,id:e.id,name:e.name,children:[d,f]}),t[17]=e.defaultOpen,t[18]=e.id,t[19]=e.name,t[20]=i,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function r_(e){return e!==!1}function i_(e){let t=(0,$.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:le(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=r_(e.controls),t[2]=e.controls,t[3]=i);let a;return t[4]!==e.autoplay||t[5]!==e.loop||t[6]!==e.muted||t[7]!==e.preload||t[8]!==e.title||t[9]!==n||t[10]!==i?(a=(0,Z.jsx)(`audio`,{className:`ok-audio`,src:n,title:r,controls:i,autoPlay:e.autoplay,loop:e.loop,muted:e.muted,preload:e.preload}),t[4]=e.autoplay,t[5]=e.loop,t[6]=e.muted,t[7]=e.preload,t[8]=e.title,t[9]=n,t[10]=i,t[11]=a):a=t[11],a}var a_={note:rr,tip:co,important:go,warning:or,caution:vo,abstract:Ka,info:Ra,todo:mo,success:Gn,question:Wa,failure:Ga,danger:Fo,bug:Ba,example:to,quote:Co};function o_(e,t){return t_(e)??a_[t]}var s_=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function c_(e){return typeof e==`string`&&s_.has(e)?e:`note`}function l_(e){let t=(0,$.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=c_(e.type),n=o_(e.icon,r),t[0]=e.icon,t[1]=e.type,t[2]=n,t[3]=r):(n=t[2],r=t[3]);let i=n,a;t[4]===e.color?a=t[5]:(a=e.color?{"--callout-type-color":e.color}:{},t[4]=e.color,t[5]=a);let s=a,c;t[6]!==i||t[7]!==e.title?(c=e.title||i?(0,Z.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,Z.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,Z.jsx)(`span`,{className:`callout-title`,children:e.title}):null]}):null,t[6]=i,t[7]=e.title,t[8]=c):c=t[8];let l=c;if(e.collapsible){let n=e.defaultOpen??!0,i;t[9]===l?i=t[10]:(i=l??(0,Z.jsx)(`span`,{className:`callout-title`,children:(0,Z.jsx)(o,{id:`URmyfc`})}),t[9]=l,t[10]=i);let a;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Vn,{size:16,className:`callout-chevron`,"aria-hidden":`true`}),t[11]=a):a=t[11];let c;t[12]===i?c=t[13]:(c=(0,Z.jsxs)(`summary`,{className:`callout-summary`,contentEditable:!1,children:[i,a]}),t[12]=i,t[13]=c);let u;t[14]===e.children?u=t[15]:(u=(0,Z.jsx)(`div`,{className:`callout-body`,children:e.children}),t[14]=e.children,t[15]=u);let d;return t[16]!==n||t[17]!==s||t[18]!==c||t[19]!==u||t[20]!==r?(d=(0,Z.jsxs)(`details`,{className:`callout callout-collapsible`,"data-callout-type":r,open:n,style:s,children:[c,u]}),t[16]=n,t[17]=s,t[18]=c,t[19]=u,t[20]=r,t[21]=d):d=t[21],d}let u;t[22]===e.children?u=t[23]:(u=(0,Z.jsx)(`div`,{className:`callout-body`,children:e.children}),t[22]=e.children,t[23]=u);let d;return t[24]!==l||t[25]!==s||t[26]!==u||t[27]!==r?(d=(0,Z.jsxs)(`div`,{className:`callout callout-static`,"data-callout-type":r,style:s,children:[l,u]}),t[24]=l,t[25]=s,t[26]=u,t[27]=r,t[28]=d):d=t[28],d}var u_=[{key:`tl`,dx:-1,dy:-1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--tl`},{key:`t`,dx:0,dy:-1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--t`},{key:`tr`,dx:1,dy:-1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--tr`},{key:`r`,dx:1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--r`},{key:`br`,dx:1,dy:1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--br`},{key:`b`,dx:0,dy:1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--b`},{key:`bl`,dx:-1,dy:1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--bl`},{key:`l`,dx:-1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--l`}];function d_(e){let t=(0,$.c)(7),{targetRef:n,onResize:r,onResizeEnd:i,bounds:a}=e,{_:o}=s(),c=(0,Q.useRef)(null),l;t[0]!==a?.maxHeight||t[1]!==a?.maxWidth||t[2]!==a?.minHeight||t[3]!==a?.minWidth?(l=function(e,t){let n=t===`w`?a?.minWidth??64:a?.minHeight??64,r=t===`w`?a?.maxWidth??1/0:a?.maxHeight??1/0;return Math.max(n,Math.min(r,e))},t[0]=a?.maxHeight,t[1]=a?.maxWidth,t[2]=a?.minHeight,t[3]=a?.minWidth,t[4]=l):l=t[4];let u=l,d=function(e,t){let a=n.current;if(!a)return;e.preventDefault(),e.stopPropagation();let o=a.getBoundingClientRect();c.current={handle:t,startX:e.clientX,startY:e.clientY,startWidth:o.width,startHeight:o.height,latestWidth:o.width,latestHeight:o.height,hasMoved:!1};let s=e.currentTarget;try{s.setPointerCapture(e.pointerId)}catch{}document.body.style.setProperty(`cursor`,t.cursor),document.body.style.setProperty(`user-select`,`none`);let l=function(e){let t=c.current;if(!t)return;let n=(e.clientX-t.startX)*t.handle.dx,i=(e.clientY-t.startY)*t.handle.dy,a=t.handle.dx===0?t.startWidth:u(t.startWidth+n,`w`),o=t.handle.dy===0?t.startHeight:u(t.startHeight+i,`h`);t.latestWidth=a,t.latestHeight=o,t.hasMoved=!0,r({width:a,height:o})};function d(){let e=c.current;if(!e)return;let t={width:e.latestWidth,height:e.latestHeight},n=e.hasMoved;c.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),n&&i?.(t)}window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},f=u_.map(e=>{let t=e.key;return(0,Z.jsx)(`button`,{type:`button`,className:Ft(e.className),"aria-label":o({id:`NxW-md`,values:{handleKey:t}}),tabIndex:-1,style:{cursor:e.cursor},onPointerDown:t=>d(t,e)},t)}),p;return t[5]===f?p=t[6]:(p=(0,Z.jsx)(`div`,{className:`ok-resize-overlay`,contentEditable:!1,"aria-hidden":`true`,children:f}),t[5]=f,t[6]=p),p}var f_=`26rem`,p_=`Embedded content`,m_=/^https?:\/\//i;function h_(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function g_(e){return!(typeof e!=`string`||!m_.test(e)||!h_(e))}function __(e){let t=(0,$.c)(24),{src:n,title:r,width:i,height:a}=e,o=(0,Q.useRef)(null),s=zn(),c=i||void 0,l=a||f_,u;t[0]!==c||t[1]!==l?(u={width:c,height:l},t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,f,p;if(t[3]!==a||t[4]!==i?(f=()=>{let e=o.current;e&&(e.style.width=i||``,e.style.height=a||f_)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Q.useEffect)(f,p),!g_(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=m_.test(n)?`Embed only supports cross-origin URLs`:`URL must start with http:// or https://`);let r;return t[7]===e?r=t[8]:(r=(0,Z.jsx)(`div`,{className:`ok-embed ok-embed--placeholder`,contentEditable:!1,children:(0,Z.jsx)(`span`,{children:e})}),t[7]=e,t[8]=r),r}let m;t[9]===s?m=t[10]:(m=e=>{if(!s)return;let{editor:t,getPos:n}=s,r=n();if(typeof r==`number`)try{let n=t.state.doc.nodeAt(r);if(!n||n.type.name!==`jsxComponent`)return;let i={...n.attrs.props??{},width:`${Math.round(e.width)}px`,height:`${Math.round(e.height)}px`};t.view.dispatch(t.state.tr.setNodeMarkup(r,null,{...n.attrs,props:i,sourceDirty:!0}))}catch(e){let t=e;if(t instanceof RangeError)return;throw t}},t[9]=s,t[10]=m);let h=m,g;t[11]===n?g=t[12]:(g=Te(n),t[11]=n,t[12]=g);let _=g,v=_===n?`no-referrer`:`strict-origin-when-cross-origin`,y=r||p_,b;t[13]!==_||t[14]!==v||t[15]!==y?(b=(0,Z.jsx)(`iframe`,{title:y,src:_,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:v,loading:`lazy`,className:`ok-embed-frame`}),t[13]=_,t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==s||t[18]!==h?(x=s?(0,Z.jsx)(d_,{targetRef:o,bounds:{minWidth:192,maxWidth:2e3,minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=o.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:h}):null,t[17]=s,t[18]=h,t[19]=x):x=t[19];let S;return t[20]!==d||t[21]!==x||t[22]!==b?(S=(0,Z.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[b,x]}),t[20]=d,t[21]=x,t[22]=b,t[23]=S):S=t[23],S}function v_(e){if(!e)return``;let t,n=null;try{let r=new URL(e,`https://placeholder.local`);n=r.protocol,t=r.pathname}catch{t=e.split(`?`)[0]??e}if(n===`data:`||n===`blob:`)return``;let r=t.split(`/`),i=r[r.length-1]??``;try{return decodeURIComponent(i)}catch{return i}}function y_(e){let t=(0,$.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||v_(e.src)||`Untitled file`,t[0]=e.name,t[1]=e.src,t[2]=n):n=t[2];let r=n,i=e.size?.trim()?e.size:null,a;t[3]===e.src?a=t[4]:(a=e.src?le(e.src):void 0,t[3]=e.src,t[4]=a);let o=a,s;t[5]===o?s=t[6]:(s=e=>{e.stopPropagation(),e.preventDefault(),o&&window.open(o,`_blank`,`noopener,noreferrer`)},t[5]=o,t[6]=s);let c=s,l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)($a,{className:`ok-file-icon`,"aria-hidden":`true`}),t[7]=l):l=t[7];let u;t[8]===r?u=t[9]:(u=(0,Z.jsx)(`span`,{className:`ok-file-name`,children:r}),t[8]=r,t[9]=u);let d;t[10]===i?d=t[11]:(d=i?(0,Z.jsx)(`span`,{className:`ok-file-size`,children:i}):null,t[10]=i,t[11]=d);let f;return t[12]!==c||t[13]!==o||t[14]!==e.title||t[15]!==u||t[16]!==d?(f=(0,Z.jsxs)(`a`,{href:o,title:e.title,className:`ok-file-attachment`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:b_,onClick:c,children:[l,u,d]}),t[12]=c,t[13]=o,t[14]=e.title,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function b_(e){return e.stopPropagation()}function x_(){return Q.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Q.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function S_(){return Q.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Q.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function C_(e){return typeof Element>`u`?!1:e instanceof Element}var w_=(e,t)=>C_(t)&&t.tagName.toUpperCase()===e,T_=e=>w_(`DIV`,e)||w_(`SPAN`,e),E_=e=>w_(`IMG`,e),D_=e=>e.complete&&e.naturalHeight!==0,O_=e=>w_(`SVG`,e),k_=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),A_=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=k_({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},j_=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?A_({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):k_({height:e,offset:r,width:t}),M_=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,N_=e=>{if(e!==null){if(E_(e))return e.currentSrc===``?void 0:e.currentSrc;if(T_(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return M_.exec(t)?.[1]}}},P_=e=>{if(e!==null)return E_(e)?e.alt:e.getAttribute(`aria-label`)??void 0},F_=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=j_({containerHeight:e,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s});return{top:n,left:t,width:r*c,height:e*c,transform:`translate(0,0) scale(${1/c})`}},I_=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},L_=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,objectFit:a,objectPosition:o,offset:s,targetHeight:c,targetWidth:l})=>{let u=a;if(u===`scale-down`&&(u=l<=r&&c<=e?`none`:`contain`),u===`cover`||u===`contain`){let a=r/l,d=e/c,f=u===`cover`?Math.max(a,d):Math.min(a,d),[p=`50%`,m=`50%`]=o.split(` `),h=I_({position:p,relativeNum:r-l*f}),g=I_({position:m,relativeNum:e-c*f}),_=j_({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+g,left:t+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(u===`none`){let[a=`50%`,u=`50%`]=o.split(` `),d=I_({position:a,relativeNum:r-l}),f=I_({position:u,relativeNum:e-c}),p=j_({containerHeight:c,containerWidth:l,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+f,left:t+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else if(u===`fill`){let t=r/l,n=e/c,a=Math.max(t,n),o=j_({containerHeight:c*a,containerWidth:l*a,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{width:r*o,height:e*o,transform:`translate(0,0) scale(${1/o})`}}else return{}},R_=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:i,containerWidth:a,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l})=>{if(t===`cover`||t===`contain`){let u=a/l,d=n/c,f=t===`cover`?Math.max(u,d):Math.min(u,d),[p=`50%`,m=`50%`]=e.split(` `),h=I_({position:p,relativeNum:a-l*f}),g=I_({position:m,relativeNum:n-c*f}),_=j_({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+g,left:r+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(t===`auto`){let[t=`50%`,u=`50%`]=e.split(` `),d=I_({position:t,relativeNum:a-l}),f=I_({position:u,relativeNum:n-c}),p=j_({containerHeight:c,containerWidth:l,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+f,left:r+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else{let[u=`50%`,d=`50%`]=t.split(` `),f=I_({position:u,relativeNum:a}),p=I_({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=I_({position:_,relativeNum:a-l*g}),b=I_({position:v,relativeNum:n-c*g}),x=j_({containerHeight:c*g,containerWidth:l*g,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+b,left:r+y,width:l*g*x,height:c*g*x,transform:`translate(0,0) scale(${1/x})`}}},z_=/\.svg$/i,B_=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:i,offset:a,shouldRefresh:o,targetEl:s})=>{let c=n||t?.slice(0,18)===`data:image/svg+xml`||e||t!==void 0&&z_.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&T_(s),f=i!=null&&!d,p=i!=null&&i.naturalHeight!==0?i.naturalHeight:l.height,m=i!=null&&i.naturalWidth!==0?i.naturalWidth:l.width,h=F_({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?L_({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:a,targetHeight:p,targetWidth:m}):void 0,_=d?R_({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}):void 0,v={...h,...g,..._};if(r){let e=window.innerWidth/2,t=window.innerHeight/2,n=parseFloat(String(v.left??0))+parseFloat(String(v.width??0))/2,r=parseFloat(String(v.top??0))+parseFloat(String(v.height??0))/2,i=e-n,a=t-r;o&&(v.transitionDuration=`0.01ms`),v.transform=`translate(${i}px,${a}px) scale(1)`}return v},V_=e=>{if(e==null)return{};if(O_(e)){let{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{let e=t.getBoundingClientRect();return{height:n.height,left:e.left-n.left,top:e.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},H_=e=>{let t=`-zoom`,n=[`clip-path`,`fill`,`mask`,`marker-start`,`marker-mid`,`marker-end`],r=new Map;if(e.hasAttribute(`id`)){let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}e.querySelectorAll(`[id]`).forEach(e=>{let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}),r.forEach((t,r)=>{let i=`url(#${r})`,a=`url(#${t})`,o=n.map(e=>`[${e}="${i}"]`).join(`, `);e.querySelectorAll(o).forEach(e=>{n.forEach(t=>{e.getAttribute(t)===i&&e.setAttribute(t,a)})})}),e.querySelectorAll(`style`).forEach(e=>{r.forEach((t,n)=>{let{textContent:r}=e;if(r!==``){let i=e;i.textContent=r.replaceAll(`#${n}`,`#${t}`)}})})},U_=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),W_={overflow:``,width:``};function G_(){let e=document.querySelector(`[data-rmiz-portal]`);if(e!=null)return e;let t=document.createElement(`div`);return t.setAttribute(`data-rmiz-portal`,``),document.body.appendChild(t),t}function K_(e){e.preventDefault()}function q_(e){return Q.createElement(J_,{...e})}var J_=class extends Q.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Q.createRef(),this.refDialog=Q.createRef(),this.refModalContent=Q.createRef(),this.refModalImg=Q.createRef(),this.refWrap=Q.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=W_,this.styleModalImg={},this.handleModalStateChange=e=>{let{state:{modalState:t}}=this;e!==`LOADING`&&t===`LOADING`?(this.loadZoomImg(),window.addEventListener(`resize`,this.handleResize,{passive:!0}),window.addEventListener(`touchstart`,this.handleTouchStart,{passive:!0}),window.addEventListener(`touchmove`,this.handleTouchMove,{passive:!0}),window.addEventListener(`touchend`,this.handleTouchEnd,{passive:!0}),window.addEventListener(`touchcancel`,this.handleTouchCancel,{passive:!0}),document.addEventListener(`keydown`,this.handleKeyDown,!0)):e!==`LOADED`&&t===`LOADED`?window.addEventListener(`wheel`,this.handleWheel,{passive:!0}):e!==`UNLOADING`&&t===`UNLOADING`?(this.ensureImgTransitionEnd(),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),document.removeEventListener(`keydown`,this.handleKeyDown,!0)):e!==`UNLOADED`&&t===`UNLOADED`&&(this.bodyScrollEnable(),window.removeEventListener(`resize`,this.handleResize),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{let e=()=>Math.random().toString(16).slice(-4);this.setState({id:e()+e()+e()})},this.setAndTrackImg=()=>{let{refContent:{current:e}}=this;e!=null&&(this.imgEl=e.querySelector(U_),this.imgEl===null?this.contentNotFoundChangeObserver??(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(e,{childList:!0,subtree:!0})):(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener(`load`,this.handleImgLoad),this.imgEl.addEventListener(`click`,this.handleZoom),this.state.loadedImgEl??this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(e=>{let[t]=e;t?.target!==void 0&&(this.imgEl=t.target,this.setState({styleGhost:V_(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:V_(this.imgEl)})}),this.contentChangeObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}))))},this.handleIfZoomChanged=e=>{let{props:{isZoomed:t}}=this;!e&&t?this.zoom():e&&!t&&this.unzoom()},this.handleImgLoad=()=>{let e=N_(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(E_(n)){let{sizes:e,srcset:r,crossOrigin:i}=n;t.sizes=e,t.srcset=r,t.crossOrigin=i}t.src=e;let r=()=>{this.setState({loadedImgEl:t,styleGhost:V_(this.imgEl)})};t.decode().then(r).catch(()=>{if(D_(t)){r();return}t.onload=r})},this.handleZoom=e=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:e})},this.handleUnzoom=e=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:e})},this.handleBtnUnzoomClick=e=>{e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e)},this.handleDialogClick=e=>{(e.target===this.refModalContent.current||e.target===this.refModalImg.current)&&(e.stopPropagation(),this.handleUnzoom(e))},this.handleDialogClose=e=>{e.stopPropagation(),this.handleUnzoom(e)},this.handleKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e))},this.handleWheel=e=>{e.ctrlKey||(e.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(e)}))},this.handleTouchStart=e=>{if(e.touches.length>1){this.isScaling=!0;return}let{changedTouches:t}=e,[n]=t;if(t.length===1&&n!==void 0){let{screenY:e}=n;this.touchYStart=e}},this.handleTouchMove=e=>{let t=window.visualViewport?.scale??1,{changedTouches:n}=e,[r]=n;if(this.props.canSwipeToUnzoom&&!this.isScaling&&t<=1&&this.touchYStart!=null&&r!==void 0){let{screenY:t}=r;this.touchYEnd=t;let n=Math.max(this.touchYStart,this.touchYEnd),i=Math.min(this.touchYStart,this.touchYEnd);Math.abs(n-i)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(e))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||O_(this.imgEl))&&window.getComputedStyle(this.imgEl).display!==`none`,this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener(`transitionend`,this.handleImgTransitionEnd),this.setState({modalState:`LOADING`})},this.unzoom=()=>{this.setState({modalState:`UNLOADING`})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState===`LOADING`?this.setState({modalState:`LOADED`}):this.state.modalState===`UNLOADING`&&this.setState({shouldRefresh:!1,modalState:`UNLOADED`})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){let{transitionDuration:e}=window.getComputedStyle(this.refModalImg.current),t=parseFloat(e);if(t!==0&&!Number.isNaN(t)){let n=t*(e.endsWith(`ms`)?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,n)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};let{body:{clientWidth:e}}=document;document.body.style.overflow=`hidden`,document.body.style.width=`${e}px`},this.bodyScrollEnable=()=>{let{prevBodyAttrs:{overflow:e,width:t}}=this;document.body.style.width=t,document.body.style.overflow=e,this.prevBodyAttrs=W_},this.loadZoomImg=()=>{let{props:{zoomImg:e}}=this;if(e==null)return;let{src:t}=e;if(t!==void 0&&t!==``){let n=new Image;n.sizes=e.sizes??``,n.srcset=e.srcSet??``,n.crossOrigin=e.crossOrigin??void 0,n.src=t;let r=()=>{this.setState({isZoomImgLoaded:!0})};n.decode().then(r).catch(()=>{if(D_(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(O_(e)){let r=e.cloneNode(!0);H_(r),r.style.width=`${n.width??0}px`,r.style.height=`${n.height??0}px`,r.addEventListener(`click`,this.handleUnzoom),t.current?.firstChild?.remove(),t.current?.appendChild(r)}}}render(){let{handleBtnUnzoomClick:e,handleDialogClick:t,handleDialogClose:n,handleUnzoom:r,handleZoom:i,imgEl:a,props:{a11yNameButtonUnzoom:o,a11yNameButtonZoom:s,children:c,classDialog:l,IconUnzoom:u,IconZoom:d,isZoomed:f,wrapElement:p,ZoomContent:m,zoomImg:h,zoomMargin:g},refContent:_,refDialog:v,refModalContent:y,refModalImg:b,refWrap:x,state:{id:S,isZoomImgLoaded:C,loadedImgEl:w,modalState:T,shouldRefresh:E,styleGhost:D}}=this,O=`rmiz-modal-${S}`,k=`rmiz-modal-img-${S}`,A=T_(a),j=E_(a),M=O_(a),N=P_(a),P=N_(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,R=h?.src!==void 0&&h.src!==``,ee=this.hasImage(),z=N!==void 0&&N!==``?`${s}: ${N}`:s,te=T===`LOADING`||T===`LOADED`,ne=ee?`found`:`not-found`,re=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,B={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=ee&&a!==null?B_({hasZoomImg:R,imgSrc:P,isSvg:M,isZoomed:f&&te,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let V=null;if(ee){let t=j||A?Q.createElement(`img`,{alt:N,crossOrigin:L,sizes:F,src:P,srcSet:I,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?Q.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Q.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Q.createElement(u,null));V=m==null?Q.createElement(Q.Fragment,null,t,n):Q.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Q.createElement(p,{"aria-owns":ee?O:void 0,"data-rmiz":``,ref:x},Q.createElement(p,{"data-rmiz-content":ne,ref:_,style:B},c),ee&&Q.createElement(p,{"data-rmiz-ghost":``,style:D},Q.createElement(`button`,{"aria-label":z,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Q.createElement(d,null))),ee&&Io.createPortal(Q.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:K_,ref:v,role:`dialog`},Q.createElement(`div`,{"data-rmiz-modal-overlay":re}),Q.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},V)),G_()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!==`UNLOADED`&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener(`load`,this.handleImgLoad),this.imgEl?.removeEventListener(`click`,this.handleZoom),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),window.removeEventListener(`resize`,this.handleResize),document.removeEventListener(`keydown`,this.handleKeyDown,!0)}componentDidUpdate(e,t){this.handleModalStateChange(t.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(e.isZoomed)}};J_.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:x_,IconZoom:S_,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function Y_({onZoomChange:e,...t}){let[n,r]=Q.useState(!1),i=Q.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Q.createElement(q_,{...t,isZoomed:n,onZoomChange:i})}function X_(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function Z_(e,t,n){return X_(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function Q_(e){let t=(0,$.c)(52),n,r,i,a,o,c,l,u,d,f,p,m;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12]):({width:m,height:r,loadingTestId:d,slotTestId:f,slotClassName:c,className:n,onLoad:o,onError:a,src:l,style:u,alt:p,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m);let h=d===void 0?`image-loading-skeleton`:d,g=f===void 0?`image-slot`:f,_=p===void 0?``:p,{_:v}=s(),y=(0,Q.useRef)(null),[b,x]=(0,Q.useState)(!1),S;t[13]!==r||t[14]!==m?(S=X_(m,r),t[13]=r,t[14]=m,t[15]=S):S=t[15];let C=S,w;t[16]!==r||t[17]!==u||t[18]!==m?(w=Z_(m,r,u),t[16]=r,t[17]=u,t[18]=m,t[19]=w):w=t[19];let T=w,E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{y.current?.complete?x(!0):x(!1)},t[20]=E):E=t[20];let D;t[21]===l?D=t[22]:(D=[l],t[21]=l,t[22]=D),(0,Q.useLayoutEffect)(E,D);let O=!C&&!b&&`aspect-[16/9] w-full max-w-full`,k;t[23]!==c||t[24]!==O?(k=Ft(`relative inline-block overflow-hidden`,O,c),t[23]=c,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==v||t[27]!==b||t[28]!==h?(A=!b&&(0,Z.jsx)(`span`,{"data-testid":h,role:`status`,"aria-busy":`true`,"aria-label":v({id:`N1YYa7`}),className:`absolute inset-0 animate-pulse rounded-md bg-muted motion-reduce:animate-none`}),t[26]=v,t[27]=b,t[28]=h,t[29]=A):A=t[29];let j=b?`opacity-100`:`opacity-0`,M;t[30]!==n||t[31]!==j?(M=Ft(`block max-w-full transition-opacity motion-reduce:transition-none`,j,n),t[30]=n,t[31]=j,t[32]=M):M=t[32];let N;t[33]===o?N=t[34]:(N=e=>{x(!0),o?.(e)},t[33]=o,t[34]=N);let P;t[35]===a?P=t[36]:(P=e=>{x(!0),a?.(e)},t[35]=a,t[36]=P);let F;t[37]!==_||t[38]!==r||t[39]!==i||t[40]!==l||t[41]!==M||t[42]!==N||t[43]!==P||t[44]!==m?(F=(0,Z.jsx)(`img`,{...i,ref:y,src:l,alt:_,width:m,height:r,className:M,onLoad:N,onError:P}),t[37]=_,t[38]=r,t[39]=i,t[40]=l,t[41]=M,t[42]=N,t[43]=P,t[44]=m,t[45]=F):F=t[45];let I;return t[46]!==T||t[47]!==g||t[48]!==A||t[49]!==F||t[50]!==k?(I=(0,Z.jsxs)(`span`,{"data-testid":g,className:k,style:T,children:[A,F]}),t[46]=T,t[47]=g,t[48]=A,t[49]=F,t[50]=k,t[51]=I):I=t[51],I}function $_(e){return e??`lazy`}function ev(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function tv(e){let t=(0,$.c)(21),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:le(e.src),t[0]=e.src,t[1]=n);let r=e.alt??``,i;t[2]===e.width?i=t[3]:(i=ev(e.width),t[2]=e.width,t[3]=i);let a;t[4]===e.height?a=t[5]:(a=ev(e.height),t[4]=e.height,t[5]=a);let o=e.title,s;t[6]===e.loading?s=t[7]:(s=$_(e.loading),t[6]=e.loading,t[7]=s);let c;return t[8]!==e.crossorigin||t[9]!==e.decoding||t[10]!==e.fetchpriority||t[11]!==e.referrerpolicy||t[12]!==e.sizes||t[13]!==e.srcset||t[14]!==e.title||t[15]!==n||t[16]!==r||t[17]!==i||t[18]!==a||t[19]!==s?(c=(0,Z.jsx)(Q_,{src:n,alt:r,width:i,height:a,title:o,loading:s,srcSet:e.srcset,sizes:e.sizes,decoding:e.decoding,fetchPriority:e.fetchpriority,crossOrigin:e.crossorigin,referrerPolicy:e.referrerpolicy}),t[8]=e.crossorigin,t[9]=e.decoding,t[10]=e.fetchpriority,t[11]=e.referrerpolicy,t[12]=e.sizes,t[13]=e.srcset,t[14]=e.title,t[15]=n,t[16]=r,t[17]=i,t[18]=a,t[19]=s,t[20]=c):c=t[20],c}function nv(e){let t=(0,$.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,Z.jsx)(Y_,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,Z.jsx)(tv,{...e})}),t[1]=e,t[2]=r),r}var rv=(0,Q.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-BunQWEOH.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,$.c)(7),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!0,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={__html:i},n[2]=i,n[3]=a);let o;return n[4]!==t.id||n[5]!==a?(o=(0,Z.jsx)(`div`,{className:`math math-display`,"data-component-type":`math`,id:t.id,dangerouslySetInnerHTML:a}),n[4]=t.id,n[5]=a,n[6]=o):o=n[6],o}return{default:t}});function iv(e){let t=(0,$.c)(3),n=e.formula||`\xA0`,r;return t[0]!==e.id||t[1]!==n?(r=(0,Z.jsx)(`div`,{className:`math math-placeholder`,"data-component-type":`math`,id:e.id,children:n}),t[0]=e.id,t[1]=n,t[2]=r):r=t[2],r}function av(e){let t=(0,$.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,Z.jsx)(iv,{formula:n,id:e.id}),t[0]=n,t[1]=e.id,t[2]=r):r=t[2],r}let r;return t[3]!==n||t[4]!==e.id?(r=(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(iv,{formula:n,id:e.id}),children:(0,Z.jsx)(rv,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}function ov(e,t){if(e.type===`mdxJsxFlowElement`){let n=e;if(n.name===`MirrorSource`){for(let e of n.attributes??[])if(e.type===`mdxJsxAttribute`&&e.name===`id`&&typeof e.value==`string`&&e.value===t)return n}}let n=e.children;if(Array.isArray(n))for(let e of n){let n=ov(e,t);if(n)return n}return null}function sv(e){return Le({type:`root`,children:e.children??[]})}var cv=new Map,lv=30,uv=150,dv=1e4;function fv(e,t){let n=`${e}|${t}`,r=cv.get(n);if(r)return r.refcount+=1,r;let i=new ia,a=new Ki({url:e,name:t,document:i}),o=new Set,s={provider:a,ySource:i.getText(`source`),refcount:1,synced:!1,subscribers:o};return a.on(`synced`,()=>{s.synced=!0;for(let e of o)e.onSynced()}),s.ySource.observe(()=>{for(let e of o)e.onUpdate()}),cv.set(n,s),cv.size>lv&&console.warn(`[Mirror] provider pool exceeded ${lv} entries (current=${cv.size}). Many Mirrors pointing at distinct source docs — investigate if this is a runaway pattern.`),s}function pv(e,t){let n=`${e}|${t}`,r=cv.get(n);if(r&&(--r.refcount,r.refcount<=0)){try{r.provider.destroy()}catch(e){console.warn(`[Mirror] provider.destroy() failed during release`,{src:t,err:e})}cv.delete(n)}}function mv(e,t){let n=(0,$.c)(8),{collabUrl:r}=sd(),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={kind:`loading`},n[0]=i):i=n[0];let[a,o]=(0,Q.useState)(i),s=(0,Q.useRef)(t),c=(0,Q.useRef)(null),l,u;n[1]!==r||n[2]!==e?(l=()=>{if(!e){o({kind:`empty-props`});return}if(!r){o({kind:`loading`});return}let t=fv(r,e),n=()=>{let n=s.current;if(!n){o({kind:`empty-props`});return}let r=t.ySource.toString();if(!r){o(t.synced?{kind:`source-removed`}:{kind:`loading`});return}let i;try{i=qt().parseToMdast(r)}catch(t){console.warn(`[Mirror] parseToMdast failed`,{src:e,anchor:n,err:t}),o({kind:`source-removed`});return}let a=ov(i,n);if(!a){o({kind:`anchor-not-found`});return}let c;try{c=sv(a)}catch(t){console.warn(`[Mirror] renderMirrorSubtree failed`,{src:e,anchor:n,err:t}),o({kind:`anchor-not-found`});return}o({kind:`ready`,html:c})},i=null,a={onUpdate:()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,n()},uv)},onSynced:()=>{i&&=(clearTimeout(i),null),n()}};t.subscribers.add(a),c.current=n;let l=setTimeout(()=>{t.synced||o({kind:`source-removed`})},dv);return n(),()=>{clearTimeout(l),i&&clearTimeout(i),t.subscribers.delete(a),c.current=null,pv(r,e)}},u=[r,e],n[1]=r,n[2]=e,n[3]=l,n[4]=u):(l=n[3],u=n[4]),(0,Q.useEffect)(l,u);let d,f;return n[5]===t?(d=n[6],f=n[7]):(d=()=>{s.current=t,c.current?.()},f=[t],n[5]=t,n[6]=d,n[7]=f),(0,Q.useEffect)(d,f),a}function hv(e){let t=(0,$.c)(8),n=`ok-mirror-state flex items-start gap-2 rounded-md border border-dashed px-3 py-2 text-sm ${e.tone===`error`?`border-destructive/40 text-destructive`:`border-border text-muted-foreground`}`,r;t[0]===e.tone?r=t[1]:(r=e.tone===`error`?(0,Z.jsx)(lo,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,Z.jsx)(fo,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}),t[0]=e.tone,t[1]=r);let i;t[2]===e.children?i=t[3]:(i=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),t[2]=e.children,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,Z.jsxs)(`div`,{className:n,children:[r,i]}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function gv(e){let t=(0,$.c)(30),n=e.src??``,r=e.anchor??``,i=mv(n,r);if(i.kind===`empty-props`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(hv,{tone:`placeholder`,children:(0,Z.jsx)(o,{id:`3SDfZl`,components:{0:(0,Z.jsx)(`span`,{className:`font-medium`}),1:(0,Z.jsx)(`code`,{}),2:(0,Z.jsx)(`code`,{}),3:(0,Z.jsx)(`code`,{})}})}),t[0]=e):e=t[0],e}if(i.kind===`loading`){let e=n&&r?`${n}#${r}`:``,i;t[1]===e?i=t[2]:(i={mirrorRef:e},t[1]=e,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a={0:(0,Z.jsx)(`code`,{})},t[3]=a):a=t[3];let s;return t[4]===i?s=t[5]:(s=(0,Z.jsx)(hv,{tone:`placeholder`,children:(0,Z.jsx)(o,{id:`92rbk2`,values:i,components:a})}),t[4]=i,t[5]=s),s}if(i.kind===`source-removed`){let e;t[6]===n?e=t[7]:(e={src:n},t[6]=n,t[7]=e);let r;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium`}),1:(0,Z.jsx)(`code`,{})},t[8]=r):r=t[8];let i;return t[9]===e?i=t[10]:(i=(0,Z.jsx)(hv,{tone:`error`,children:(0,Z.jsx)(o,{id:`Ud0Pj9`,values:e,components:r})}),t[9]=e,t[10]=i),i}if(i.kind===`anchor-not-found`){let e=`<MirrorSource id="${r}">`,i;t[11]!==e||t[12]!==n?(i={mirrorSourceTag:e,src:n},t[11]=e,t[12]=n,t[13]=i):i=t[13];let a;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(a={0:(0,Z.jsx)(`span`,{className:`font-medium`}),1:(0,Z.jsx)(`code`,{}),2:(0,Z.jsx)(`code`,{})},t[14]=a):a=t[14];let s;return t[15]===i?s=t[16]:(s=(0,Z.jsx)(hv,{tone:`error`,children:(0,Z.jsx)(o,{id:`mqSwZH`,values:i,components:a})}),t[15]=i,t[16]=s),s}let a;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Jn,{className:`size-3`,"aria-hidden":`true`}),t[17]=a):a=t[17];let s;t[18]===n?s=t[19]:(s={src:n},t[18]=n,t[19]=s);let c;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(c={0:(0,Z.jsx)(`code`,{className:`font-mono`})},t[20]=c):c=t[20];let l;t[21]===s?l=t[22]:(l=(0,Z.jsxs)(`div`,{className:`ok-mirror-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,"aria-hidden":`true`,children:[a,(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`wQp1V3`,values:s,components:c})})]}),t[21]=s,t[22]=l);let u;t[23]===i.html?u=t[24]:(u=(0,Z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:i.html}}),t[23]=i.html,t[24]=u);let d;return t[25]!==r||t[26]!==n||t[27]!==l||t[28]!==u?(d=(0,Z.jsxs)(`div`,{className:`ok-mirror-resolved relative -mx-3 prose-no-margin rounded-md border border-dashed border-transparent px-3 py-2 transition-colors [.jsx-component-wrapper:hover_&]:border-border/40 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/40`,"data-mirror-src":n,"data-mirror-anchor":r,children:[l,u]}),t[25]=r,t[26]=n,t[27]=l,t[28]=u,t[29]=d):d=t[29],d}function _v(e){let t=(0,$.c)(15),{_:n}=s(),r=e.id??``,i;t[0]!==n||t[1]!==r?(i=r||n({id:`12F9WL`}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Yn,{className:`size-3`,"aria-hidden":`true`}),t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l={label:a},t[4]=a,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={0:(0,Z.jsx)(`code`,{className:`font-mono`})},t[6]=u):u=t[6];let d;t[7]===l?d=t[8]:(d=(0,Z.jsxs)(`div`,{className:`ok-mirror-source-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,children:[c,(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`Zon_qG`,values:l,components:u})})]}),t[7]=l,t[8]=d);let f;t[9]===e.children?f=t[10]:(f=(0,Z.jsx)(`div`,{children:e.children}),t[9]=e.children,t[10]=f);let p;return t[11]!==r||t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`div`,{className:`ok-mirror-source relative -mx-3 rounded-md border border-dashed border-transparent px-3 py-1 transition-colors [.jsx-component-wrapper:hover_&]:border-border/50 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/50`,"data-mirror-source-id":r,children:[d,f]}),t[11]=r,t[12]=d,t[13]=f,t[14]=p):p=t[14],p}var vv=24,yv=24,bv=12,xv=.1;function Sv(e,t,n,r){if(n<=0&&(e===`fit-width`||e===`two-odd`||e===`two-even`)||r<=0&&e===`fit-height`)return 1;switch(e){case`fit-width`:return Math.max(xv,(n-vv)/t.naturalWidth);case`fit-height`:return Math.max(xv,(r-yv)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(xv,((n-vv)/2-bv)/t.naturalWidth)}}var Cv=600,wv=.5,Tv=3,Ev=.25,Dv=null;function Ov(){return Dv||(Dv=(async()=>{let e=await n(()=>import(`./pdf-WLEpkBFf.js`),__vite__mapDeps([0,1]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-BZkygqjt.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),Dv.catch(()=>{Dv=null})),Dv}function kv(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function Av(e){let t=(0,$.c)(96),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=nt(e.anchor);n=i===null?e.fillContainer?`100%`:`${Cv}px`:`${i}px`,r=Iv(a),t[0]=e.anchor,t[1]=e.fillContainer,t[2]=n,t[3]=r}else n=t[2],r=t[3];let i=r,a=(0,Q.useRef)(null),c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[4]=c):c=t[4];let l=(0,Q.useRef)(c),u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[5]=u):u=t[5];let d=(0,Q.useRef)(u),f=(0,Q.useRef)(null),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[6]=p):p=t[6];let[m,h]=(0,Q.useState)(p),[g,_]=(0,Q.useState)(!0),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(i??1),[S,C]=(0,Q.useState)(String(i??1)),[w,T]=(0,Q.useState)(1),[E,D]=(0,Q.useState)(`fit-width`),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(0),[P,F]=(0,Q.useState)(0),{_:I}=s(),L=m.length,R,ee;t[7]!==I||t[8]!==e.src?(R=()=>{if(!e.src){_(!1);return}let t=le(e.src),n=!1,r=null;return _(!0),y(null),(async()=>{try{let e=await(await Ov()).getDocument({url:t,isEvalSupported:!1}).promise;if(n){await e.destroy();return}r=e,f.current=e;let i=[];for(let t=1;t<=e.numPages;t++){if(n)return;let r=(await e.getPage(t)).getViewport({scale:1});i.push({pageNumber:t,naturalWidth:r.width,naturalHeight:r.height})}if(n)return;h(i)}catch(e){let t=e;if(n)return;y(t instanceof Error?t.message:I({id:`jRHdCz`})),_(!1)}})(),()=>{n=!0,r&&=(r.destroy(),null),f.current=null}},ee=[e.src,I],t[7]=I,t[8]=e.src,t[9]=R,t[10]=ee):(R=t[9],ee=t[10]),(0,Q.useEffect)(R,ee);let z,te;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>{let e=a.current;if(!e)return;let t=()=>{N(e.clientWidth),F(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},te=[],t[11]=z,t[12]=te):(z=t[11],te=t[12]),(0,Q.useEffect)(z,te);let ne,re;t[13]!==I||t[14]!==P||t[15]!==M||t[16]!==E||t[17]!==m||t[18]!==w?(ne=()=>{let e=f.current;if(!e||m.length===0||M===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=l.current[i.pageNumber-1];if(!a)continue;let o=Sv(E,i,M,P)*w,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:u,viewport:c}),await n.promise,n=null)}t||_(!1)}catch(e){let n=e;if(t||kv(n))return;console.warn(`[Pdf] page render failed:`,n),y(n instanceof Error?n.message:I({id:`_TF8ep`})),_(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},re=[m,E,w,M,P,I],t[13]=I,t[14]=P,t[15]=M,t[16]=E,t[17]=m,t[18]=w,t[19]=ne,t[20]=re):(ne=t[19],re=t[20]),(0,Q.useEffect)(ne,re);let B,V;t[21]!==m||t[22]!==O?(B=()=>{if(!O)return;let e=f.current;if(!e||m.length===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=d.current[i.pageNumber-1];if(!a)continue;let o=120/i.naturalWidth,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let l=a.getContext(`2d`);l&&(l.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:l,viewport:c}),await n.promise,n=null)}}catch(e){let t=e;kv(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},V=[O,m],t[21]=m,t[22]=O,t[23]=B,t[24]=V):(B=t[23],V=t[24]),(0,Q.useEffect)(B,V);let H,U;t[25]!==g||t[26]!==i?(H=()=>{if(g||!i)return;let e=a.current,t=l.current[i-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},U=[g,i],t[25]=g,t[26]=i,t[27]=H,t[28]=U):(H=t[27],U=t[28]),(0,Q.useEffect)(H,U);let W,G;t[29]===m?(W=t[30],G=t[31]):(W=()=>{let e=a.current;if(!e||m.length===0)return;let t=!1,n=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let n=e.scrollTop,r=1;for(let t of m){let i=l.current[t.pageNumber-1];i&&i.offsetTop-e.offsetTop<=n+40&&(r=t.pageNumber)}x(r),C(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},G=[m],t[29]=m,t[30]=W,t[31]=G),(0,Q.useEffect)(W,G);let ie,K;t[32]===A?(ie=t[33],K=t[34]):(ie=()=>{if(!A)return;let e=e=>{let t=e.target,n=a.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){j(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&j(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},K=[A],t[32]=A,t[33]=ie,t[34]=K),(0,Q.useEffect)(ie,K);let ae;t[35]===L?ae=t[36]:(ae=e=>{let t=Math.max(1,Math.min(L||1,e));x(t),C(String(t));let n=a.current,r=l.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[35]=L,t[36]=ae);let oe=ae,q;t[37]!==b||t[38]!==oe||t[39]!==S?(q=()=>{let e=Number.parseInt(S,10);if(Number.isNaN(e)){C(String(b));return}oe(e)},t[37]=b,t[38]=oe,t[39]=S,t[40]=q):q=t[40];let se=q,ce;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>T(Pv),t[41]=ce):ce=t[41];let J=ce,ue;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>T(Nv),t[42]=ue):ue=t[42];let Y=ue,de;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>{D(e),j(!1),T(1)},t[43]=de):de=t[43];let fe=de,pe;t[44]===n?pe=t[45]:(pe={height:n},t[44]=n,t[45]=pe);let me;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>k(Mv),t[46]=me):me=t[46];let he;t[47]!==I||t[48]!==O?(he=I(O?{id:`JK-Ave`}:{id:`iEYxO4`}),t[47]=I,t[48]=O,t[49]=he):he=t[49];let ge;t[50]===I?ge=t[51]:(ge=I({id:`zo3Dl7`}),t[50]=I,t[51]=ge);let _e;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(yo,{size:14,"aria-hidden":`true`}),t[52]=_e):_e=t[52];let ve;t[53]!==O||t[54]!==he||t[55]!==ge?(ve=(0,Z.jsx)(`button`,{type:`button`,onClick:me,"aria-label":he,"aria-pressed":O,className:`ok-pdf-btn`,title:ge,children:_e}),t[53]=O,t[54]=he,t[55]=ge,t[56]=ve):ve=t[56];let ye=e.title??`PDF`,be;t[57]===ye?be=t[58]:(be=(0,Z.jsx)(`span`,{className:`ok-pdf-title`,children:ye}),t[57]=ye,t[58]=be);let xe;t[59]!==I||t[60]!==A||t[61]!==E||t[62]!==S||t[63]!==se||t[64]!==L||t[65]!==w?(xe=L>0&&(0,Z.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,Z.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),se()},children:(0,Z.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:S,onChange:e=>C(e.target.value.replace(/[^0-9]/g,``)),onBlur:se,"aria-label":I({id:`xsZhu-`})})}),(0,Z.jsx)(`span`,{className:`ok-pdf-page-of`,children:(0,Z.jsx)(o,{id:`1GhYxC`,values:{totalPages:L}})}),(0,Z.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,Z.jsx)(`button`,{type:`button`,onClick:Y,disabled:w<=wv,"aria-label":I({id:`FjkaiT`}),className:`ok-pdf-btn`,title:I({id:`FjkaiT`}),children:(0,Z.jsx)(Cn,{size:14,"aria-hidden":`true`})}),(0,Z.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(w*100),`%`]}),(0,Z.jsx)(`button`,{type:`button`,onClick:J,disabled:w>=Tv,"aria-label":I({id:`AWOSPo`}),className:`ok-pdf-btn`,title:I({id:`AWOSPo`}),children:(0,Z.jsx)(Pn,{size:14,"aria-hidden":`true`})}),(0,Z.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`ok-pdf-layout-menu`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>j(jv),"aria-label":I({id:`GQDSBN`}),"aria-haspopup":`menu`,"aria-expanded":A,className:`ok-pdf-btn`,title:I({id:`rdU729`}),children:(0,Z.jsx)(Vn,{size:14,"aria-hidden":`true`})}),A&&(0,Z.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,Z.jsx)(Fv,{label:I({id:`vIxrEk`}),active:E===`fit-width`,onSelect:()=>fe(`fit-width`)}),(0,Z.jsx)(Fv,{label:I({id:`YlDuro`}),active:E===`fit-height`,onSelect:()=>fe(`fit-height`)}),(0,Z.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,Z.jsx)(Fv,{label:I({id:`BGHHtQ`}),active:E===`single`,onSelect:()=>fe(`single`)}),(0,Z.jsx)(Fv,{label:I({id:`xK291b`}),active:E===`two-odd`,onSelect:()=>fe(`two-odd`)}),(0,Z.jsx)(Fv,{label:I({id:`NSnIUP`}),active:E===`two-even`,onSelect:()=>fe(`two-even`)})]})]})]}),t[59]=I,t[60]=A,t[61]=E,t[62]=S,t[63]=se,t[64]=L,t[65]=w,t[66]=xe):xe=t[66];let Se;t[67]!==ve||t[68]!==be||t[69]!==xe?(Se=(0,Z.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[ve,be,xe]}),t[67]=ve,t[68]=be,t[69]=xe,t[70]=Se):Se=t[70];let Ce;t[71]!==I||t[72]!==b||t[73]!==oe||t[74]!==m||t[75]!==O?(Ce=O&&(0,Z.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":I({id:`nzaV6Q`}),children:m.map((e,t)=>{let{pageNumber:n}=e;return(0,Z.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":b===n||void 0,onClick:()=>oe(n),"aria-label":I({id:`qioCwA`,values:{pageNumber:n}}),children:[(0,Z.jsx)(`canvas`,{ref:e=>{d.current[t]=e},className:`ok-pdf-thumb-canvas`}),(0,Z.jsx)(`span`,{className:`ok-pdf-thumb-num`,children:n})]},n)})}),t[71]=I,t[72]=b,t[73]=oe,t[74]=m,t[75]=O,t[76]=Ce):Ce=t[76];let we;t[77]===g?we=t[78]:(we=g&&(0,Z.jsx)(`div`,{className:`ok-pdf-loading`,children:(0,Z.jsx)(o,{id:`T-654M`})}),t[77]=g,t[78]=we);let Te;t[79]===v?Te=t[80]:(Te=v&&(0,Z.jsx)(`div`,{className:`ok-pdf-error`,children:(0,Z.jsx)(o,{id:`WamGNs`,values:{error:v}})}),t[79]=v,t[80]=Te);let Ee;t[81]!==I||t[82]!==L?(Ee=Array.from({length:L},(e,t)=>{let n=t+1;return(0,Z.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-page`,"aria-label":I({id:`XtRoxT`,values:{pageNumber:n}})},n)}),t[81]=I,t[82]=L,t[83]=Ee):Ee=t[83];let De;t[84]!==E||t[85]!==we||t[86]!==Te||t[87]!==Ee?(De=(0,Z.jsxs)(`div`,{className:`ok-pdf-pages`,ref:a,"data-layout":E,children:[we,Te,Ee]}),t[84]=E,t[85]=we,t[86]=Te,t[87]=Ee,t[88]=De):De=t[88];let Oe;t[89]!==Ce||t[90]!==De?(Oe=(0,Z.jsxs)(`div`,{className:`ok-pdf-body`,children:[Ce,De]}),t[89]=Ce,t[90]=De,t[91]=Oe):Oe=t[91];let ke;return t[92]!==pe||t[93]!==Se||t[94]!==Oe?(ke=(0,Z.jsxs)(`div`,{className:`ok-pdf`,style:pe,children:[Se,Oe]}),t[92]=pe,t[93]=Se,t[94]=Oe,t[95]=ke):ke=t[95],ke}function jv(e){return!e}function Mv(e){return!e}function Nv(e){return Math.max(wv,+(e-Ev).toFixed(2))}function Pv(e){return Math.min(Tv,+(e+Ev).toFixed(2))}function Fv(e){let t=(0,$.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,Z.jsx)(Bn,{size:14}),t[0]=e.active,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,Z.jsx)(`span`,{className:`ok-pdf-menu-check`,"aria-hidden":`true`,children:r}),t[2]=r,t[3]=i);let a;return t[4]!==e.active||t[5]!==e.label||t[6]!==e.onSelect||t[7]!==n||t[8]!==i?(a=(0,Z.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.active,className:`ok-pdf-menu-item`,"data-active":n,onClick:e.onSelect,children:[i,e.label]}),t[4]=e.active,t[5]=e.label,t[6]=e.onSelect,t[7]=n,t[8]=i,t[9]=a):a=t[9],a}function Iv(e){if(!e)return null;for(let t of e.split(`&`)){let e=t.indexOf(`=`);if(!(e<0)&&t.slice(0,e)===`page`){let n=Number.parseInt(t.slice(e+1),10);if(!Number.isNaN(n)&&n>=1)return n}}return null}function Lv(e){let t=(0,$.c)(10),{label:n,id:r,children:i}=e,a=(0,Q.useId)(),o;t[0]!==r||t[1]!==a?(o=r||`tab-panel-${a.replace(/:/g,``)}`,t[0]=r,t[1]=a,t[2]=o):o=t[2];let s=o,c=`${s}-tab`,l;t[3]===n?l=t[4]:(l=n?.trim()||`Tab`,t[3]=n,t[4]=l);let u=l,d;return t[5]!==i||t[6]!==s||t[7]!==u||t[8]!==c?(d=(0,Z.jsx)(`section`,{className:`tab-panel`,id:s,role:`tabpanel`,"aria-labelledby":c,"data-tab-label":u,"data-tab-id":s,children:i}),t[5]=i,t[6]=s,t[7]=u,t[8]=c,t[9]=d):d=t[9],d}var Rv=`:scope > .component-children > [data-node-view-content-react] > .react-renderer`;function zv(e){return Array.from(e.querySelectorAll(Rv)).map((e,t)=>{let n=e.querySelector(`[data-tab-label]`);return{index:t,label:(n?.getAttribute(`data-tab-label`))?.trim()||`Tab ${t+1}`,panelId:n?.getAttribute(`data-tab-id`)??null}})}function Bv(e,t){let n=Array.from(e.querySelectorAll(Rv))[t];return n?n.querySelector(`[data-jsx-gear]`):null}function Vv(e){let t=(0,$.c)(31),{id:n,children:r}=e,[i,a]=(0,Q.useState)(0),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0];let[c,l]=(0,Q.useState)(o),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(0),p=zn(),m=p?.addChild!=null,{_:h}=s(),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=u.current;if(!e)return;let t=zv(e);l(e=>{if(e.length!==t.length)return t;for(let n=0;n<e.length;n++)if(e[n].label!==t[n].label||e[n].panelId!==t[n].panelId)return t;return e})},t[1]=g):g=t[1],(0,Q.useLayoutEffect)(g);let _,v;t[2]===c.length?(_=t[3],v=t[4]):(_=()=>{c.length>f.current&&c.length>0&&a(c.length-1),f.current=c.length},v=[c.length],t[2]=c.length,t[3]=_,t[4]=v),(0,Q.useLayoutEffect)(_,v);let y;t[5]===n?y=t[6]:(y=()=>{let e=()=>{let e=window.location.hash.slice(1);if(!e)return;if(n&&e===n){a(0);return}let t=u.current;if(!t)return;let r=zv(t).findIndex(t=>t.panelId===e);r<0||(a(r),queueMicrotask(()=>{t.ownerDocument.getElementById(e)?.scrollIntoView({block:`start`,behavior:`auto`})}))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},t[5]=n,t[6]=y),(0,Q.useLayoutEffect)(y);let b=c.length===0?0:Math.min(Math.max(i,0),c.length-1),x;t[7]!==c.length||t[8]!==b?(x=e=>{if(c.length===0)return;let t=null;e.key===`ArrowRight`?t=(b+1)%c.length:e.key===`ArrowLeft`?t=(b-1+c.length)%c.length:e.key===`Home`?t=0:e.key===`End`&&(t=c.length-1),t!==null&&(e.preventDefault(),a(t),(d.current?.querySelectorAll(`[role="tab"]`))?.[t]?.focus())},t[7]=c.length,t[8]=b,t[9]=x):x=t[9];let S=x,C=n?`Tabs: ${n}`:`Tabs`,w;t[10]!==c||t[11]!==b?(w=c.map(e=>(0,Z.jsx)(`button`,{id:e.panelId?`${e.panelId}-tab`:void 0,type:`button`,role:`tab`,className:`tabs-strip-pill`,"data-active":e.index===b,"aria-selected":e.index===b,"aria-controls":e.panelId??void 0,tabIndex:e.index===b?0:-1,onMouseDown:Uv,onClick:()=>{if(e.index!==b){a(e.index);return}let t=u.current;t&&Bv(t,e.index)?.click()},children:e.label},e.index)),t[10]=c,t[11]=b,t[12]=w):w=t[12];let T;t[13]!==S||t[14]!==C||t[15]!==w?(T=(0,Z.jsx)(`div`,{ref:d,role:`tablist`,"aria-label":C,className:`tabs-tablist`,onKeyDown:S,children:w}),t[13]=S,t[14]=C,t[15]=w,t[16]=T):T=t[16];let E;t[17]!==h||t[18]!==m||t[19]!==p?(E=m&&(0,Z.jsx)(`button`,{type:`button`,className:`tabs-strip-add`,"aria-label":h({id:`hjO0Mq`}),title:h({id:`hjO0Mq`}),onMouseDown:Hv,onClick:()=>p?.addChild?.(),"data-tabs-strip-add":``,children:`+`}),t[17]=h,t[18]=m,t[19]=p,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==T?(D=(0,Z.jsxs)(`div`,{className:`tabs-strip`,contentEditable:!1,children:[T,E]}),t[21]=E,t[22]=T,t[23]=D):D=t[23];let O;t[24]!==r||t[25]!==b?(O=(0,Z.jsx)(`div`,{ref:u,className:`tabs-content`,"data-active-index":b,children:r}),t[24]=r,t[25]=b,t[26]=O):O=t[26];let k;return t[27]!==n||t[28]!==D||t[29]!==O?(k=(0,Z.jsxs)(`div`,{className:`tabs`,id:n,children:[D,O]}),t[27]=n,t[28]=D,t[29]=O,t[30]=k):k=t[30],k}function Hv(e){return e.preventDefault()}function Uv(e){return e.preventDefault()}var Wv=typeof global<`u`&&{}.toString.call(global)===`[object global]`,Gv=typeof Bun<`u`,Kv=typeof Deno<`u`,qv=typeof WebSocketPair==`function`&&caches?.default!==void 0,Jv=Wv||Gv||Kv||qv;function Yv(e,t){return e.indexOf(t.toLowerCase())===0?e:`${t.toLowerCase()}${e.substr(0,1).toUpperCase()}${e.substr(1)}`}function Xv(e){return!!(e&&e.nodeType===1&&`nodeName`in e&&e.ownerDocument&&e.ownerDocument.defaultView)}function Zv(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function Qv(e){return/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))(?=$|\/)/.test(e)}function $v(e){return/^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))\/video\/\d+/.test(e)}function ey(e){let t=(e||``).match(/^(?:https?:)?(?:\/\/)?([^/?]+)/),n=(t&&t[1]||``).replace(`player.`,``);for(let e of[`.videoji.hk`,`.vimeo.work`,`.videoji.cn`])if(n.endsWith(e))return n;return`vimeo.com`}function ty(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.id,n=e.url,r=t||n;if(!r)throw Error(`An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.`);if(Zv(r))return`https://vimeo.com/${r}`;if(Qv(r))return r.replace(`http:`,`https:`);throw TypeError(t?`“${t}” is not a valid video id.`:`“${r}” is not a vimeo.com url.`)}var ny=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`addEventListener`,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`removeEventListener`,a=typeof t==`string`?[t]:t;return a.forEach(t=>{e[r](t,n)}),{cancel:()=>a.forEach(t=>e[i](t,n))}};function ry(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:document;if(!e||!t||typeof t.querySelectorAll!=`function`)return null;let n=t.querySelectorAll(`iframe`);for(let t=0;t<n.length;t++)if(n[t]&&n[t].contentWindow===e)return n[t];return null}var iy=Array.prototype.indexOf!==void 0,ay=typeof window<`u`&&window.postMessage!==void 0;if(!Jv&&(!iy||!ay))throw Error(`Sorry, the Vimeo Player API is not available in this browser.`);var oy=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function sy(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e){if(e.WeakMap)return;var t=Object.prototype.hasOwnProperty,n=Object.defineProperty&&function(){try{return Object.defineProperty({},`x`,{value:1}).x===1}catch{}}(),r=function(e,t,r){n?Object.defineProperty(e,t,{configurable:!0,writable:!0,value:r}):e[t]=r};e.WeakMap=function(){function e(){if(this===void 0)throw TypeError(`Constructor WeakMap requires 'new'`);if(r(this,`_id`,a(`_WeakMap`)),arguments.length>0)throw TypeError(`WeakMap iterable is not supported`)}r(e.prototype,`delete`,function(e){if(n(this,`delete`),!i(e))return!1;var t=e[this._id];return t&&t[0]===e?(delete e[this._id],!0):!1}),r(e.prototype,`get`,function(e){if(n(this,`get`),i(e)){var t=e[this._id];if(t&&t[0]===e)return t[1]}}),r(e.prototype,`has`,function(e){if(n(this,`has`),!i(e))return!1;var t=e[this._id];return!!(t&&t[0]===e)}),r(e.prototype,`set`,function(e,t){if(n(this,`set`),!i(e))throw TypeError(`Invalid value used as weak map key`);var a=e[this._id];return a&&a[0]===e?(a[1]=t,this):(r(e,this._id,[e,t]),this)});function n(e,n){if(!i(e)||!t.call(e,`_id`))throw TypeError(n+` method called on incompatible receiver `+typeof e)}function a(e){return e+`_`+o()+`.`+o()}function o(){return Math.random().toString().substring(2)}return r(e,`_polyfill`,!0),e}();function i(e){return Object(e)===e}})(typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:oy);var cy=sy(function(e){(function(t,n,r){n[t]=n[t]||r(),e.exports&&=n[t]})(`Promise`,oy,function(){var e,t,n,r=Object.prototype.toString,i=typeof setImmediate<`u`?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},`x`,{}),e=function(e,t,n,r){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:r!==!1})}}catch{e=function(e,t,n){return e[t]=n,e}}n=function(){var e,n,r;function i(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(t,a){r=new i(t,a),n?n.next=r:e=r,n=r,r=void 0},drain:function(){var r=e;for(e=n=t=void 0;r;)r.fn.call(r.self),r=r.next}}}();function a(e,r){n.add(e,r),t||=i(n.drain)}function o(e){var t,n=typeof e;return e!=null&&(n==`object`||n==`function`)&&(t=e.then),typeof t==`function`?t:!1}function s(){for(var e=0;e<this.chain.length;e++)c(this,this.state===1?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function c(e,t,n){var r,i;try{t===!1?n.reject(e.msg):(r=t===!0?e.msg:t.call(void 0,e.msg),r===n.promise?n.reject(TypeError(`Promise-chain cycle`)):(i=o(r))?i.call(r,n.resolve,n.reject):n.resolve(r))}catch(e){n.reject(e)}}function l(e){var t,n=this;if(!n.triggered){n.triggered=!0,n.def&&(n=n.def);try{(t=o(e))?a(function(){var r=new f(n);try{t.call(e,function(){l.apply(r,arguments)},function(){u.apply(r,arguments)})}catch(e){u.call(r,e)}}):(n.msg=e,n.state=1,n.chain.length>0&&a(s,n))}catch(e){u.call(new f(n),e)}}}function u(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&a(s,t))}function d(e,t,n,r){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){n(i,e)},r)})(i)}function f(e){this.def=e,this.triggered=!1}function p(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function m(e){if(typeof e!=`function`)throw TypeError(`Not a function`);if(this.__NPO__!==0)throw TypeError(`Not a promise`);this.__NPO__=1;var t=new p(this);this.then=function(e,n){var r={success:typeof e==`function`?e:!0,failure:typeof n==`function`?n:!1};return r.promise=new this.constructor(function(e,t){if(typeof e!=`function`||typeof t!=`function`)throw TypeError(`Not a function`);r.resolve=e,r.reject=t}),t.chain.push(r),t.state!==0&&a(s,t),r.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){l.call(t,e)},function(e){u.call(t,e)})}catch(e){u.call(t,e)}}var h=e({},`constructor`,m,!1);return m.prototype=h,e(h,`__NPO__`,0,!1),e(m,`resolve`,function(e){var t=this;return e&&typeof e==`object`&&e.__NPO__===1?e:new t(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);t(e)})}),e(m,`reject`,function(e){return new this(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);n(e)})}),e(m,`all`,function(e){var t=this;return r.call(e)==`[object Array]`?e.length===0?t.resolve([]):new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);var i=e.length,a=Array(i),o=0;d(t,e,function(e,t){a[e]=t,++o===i&&n(a)},r)}):t.reject(TypeError(`Not an array`))}),e(m,`race`,function(e){var t=this;return r.call(e)==`[object Array]`?new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);d(t,e,function(e,t){n(t)},r)}):t.reject(TypeError(`Not an array`))}),m})}),ly=new WeakMap;function uy(e,t,n){let r=ly.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),ly.set(e.element,r)}function dy(e,t){return(ly.get(e.element)||{})[t]||[]}function fy(e,t,n){let r=ly.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],ly.set(e.element,r),!0;let i=r[t].indexOf(n);return i!==-1&&r[t].splice(i,1),ly.set(e.element,r),r[t]&&r[t].length===0}function py(e,t){let n=dy(e,t);if(n.length<1)return!1;let r=n.shift();return fy(e,t,r),r}function my(e,t){let n=ly.get(e);ly.set(t,n),ly.delete(e)}function hy(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){return console.warn(e),{}}return e}function gy(e,t,n){if(!e.element.contentWindow||!e.element.contentWindow.postMessage)return;let r={method:t};n!==void 0&&(r.value=n);let i=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,`$1`));i>=8&&i<10&&(r=JSON.stringify(r)),e.element.contentWindow.postMessage(r,e.origin)}function _y(e,t){t=hy(t);let n=[],r;if(t.event)t.event===`error`&&dy(e,t.data.method).forEach(n=>{let r=Error(t.data.message);r.name=t.data.name,n.reject(r),fy(e,t.data.method,n)}),n=dy(e,`event:${t.event}`),r=t.data;else if(t.method){let i=py(e,t.method);i&&(n.push(i),r=t.value)}n.forEach(t=>{try{if(typeof t==`function`){t.call(e,r);return}t.resolve(r)}catch{}})}var vy=`airplay.audio_tracks.audiotrack.autopause.autoplay.background.byline.cc.chapter_id.chapters.chromecast.color.colors.controls.disable_context_menu.dnt.end_time.fullscreen.height.id.initial_quality.interactive_params.keyboard.loop.maxheight.max_quality.maxwidth.min_quality.muted.play_button_position.playsinline.portrait.preload.progress_bar.quality.quality_selector.responsive.skipping_forward.speed.start_time.texttrack.thumbnail_id.title.transcript.transparent.unmute_button.url.vimeo_logo.volume.watch_full_video.width`.split(`.`);function yy(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return vy.reduce((t,n)=>{let r=e.getAttribute(`data-vimeo-${n}`);return(r||r===``)&&(t[n]=r===``?1:r),t},t)}function by(e,t){let{html:n}=e;if(!t)throw TypeError(`An element must be provided`);if(t.getAttribute(`data-vimeo-initialized`)!==null)return t.querySelector(`iframe`);let r=document.createElement(`div`);return r.innerHTML=n,t.appendChild(r.firstChild),t.setAttribute(`data-vimeo-initialized`,`true`),t.querySelector(`iframe`)}function xy(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((r,i)=>{if(!Qv(e))throw TypeError(`“${e}” is not a vimeo.com url.`);let a=`https://${ey(e)}/api/oembed.json?url=${encodeURIComponent(e)}`;for(let e in t)t.hasOwnProperty(e)&&(a+=`&${e}=${encodeURIComponent(t[e])}`);let o=`XDomainRequest`in window?new XDomainRequest:new XMLHttpRequest;o.open(`GET`,a,!0),o.onload=function(){if(o.status===404){i(Error(`“${e}” was not found.`));return}if(o.status===403){i(Error(`“${e}” is not embeddable.`));return}try{let t=JSON.parse(o.responseText);if(t.domain_status_code===403){by(t,n),i(Error(`“${e}” is not embeddable.`));return}r(t)}catch(e){i(e)}},o.onerror=function(){let e=o.status?` (${o.status})`:``;i(Error(`There was an error fetching the embed code from Vimeo${e}.`))},o.send()})}function Sy(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document,t=[].slice.call(e.querySelectorAll(`[data-vimeo-id], [data-vimeo-url]`)),n=e=>{`console`in window&&console.error&&console.error(`There was an error creating an embed: ${e}`)};t.forEach(e=>{try{if(e.getAttribute(`data-vimeo-defer`)!==null)return;let t=yy(e);xy(ty(t),t,e).then(t=>by(t,e)).catch(n)}catch(e){n(e)}})}function Cy(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoPlayerResizeEmbeds_||(window.VimeoPlayerResizeEmbeds_=!0,window.addEventListener(`message`,t=>{if(!Qv(t.origin)||!t.data||t.data.event!==`spacechange`)return;let n=t.source?ry(t.source,e):null;if(n){let e=n.parentElement;e.style.paddingBottom=`${t.data.data[0].bottom}px`}}))}function wy(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener(`message`,t=>{if(!Qv(t.origin))return;let n=hy(t.data);if(!n||n.event!==`ready`)return;let r=t.source?ry(t.source,e):null;r&&$v(r.src)&&new Ny(r).callMethod(`appendVideoMetadata`,window.location.href)}))}function Ty(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;if(window.VimeoCheckedUrlTimeParam)return;window.VimeoCheckedUrlTimeParam=!0;let t=e=>{`console`in window&&console.error&&console.error(`There was an error getting video Id: ${e}`)};window.addEventListener(`message`,n=>{if(!Qv(n.origin))return;let r=hy(n.data);if(!r||r.event!==`ready`)return;let i=n.source?ry(n.source,e):null;if(i&&$v(i.src)){let e=new Ny(i);e.getVideoId().then(t=>{let n=RegExp(`[?&]vimeo_t_${t}=([^&#]*)`).exec(window.location.href);if(n&&n[1]){let t=decodeURI(n[1]);e.setCurrentTime(t)}}).catch(t)}})}function Ey(){window.VimeoDRMEmbedsUpdated||(window.VimeoDRMEmbedsUpdated=!0,window.addEventListener(`message`,e=>{if(!Qv(e.origin))return;let t=hy(e.data);if(!t||t.event!==`drminitfailed`)return;let n=e.source?ry(e.source):null;if(!n)return;let r=n.getAttribute(`allow`)||``;if(!r.includes(`encrypted-media`)){n.setAttribute(`allow`,`${r}; encrypted-media`);let e=new URL(n.getAttribute(`src`));e.searchParams.set(`forcereload`,`drm`),n.setAttribute(`src`,e.toString());return}}))}function Dy(){let e=function(){let e,t=[[`requestFullscreen`,`exitFullscreen`,`fullscreenElement`,`fullscreenEnabled`,`fullscreenchange`,`fullscreenerror`],[`webkitRequestFullscreen`,`webkitExitFullscreen`,`webkitFullscreenElement`,`webkitFullscreenEnabled`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`webkitRequestFullScreen`,`webkitCancelFullScreen`,`webkitCurrentFullScreenElement`,`webkitCancelFullScreen`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`mozRequestFullScreen`,`mozCancelFullScreen`,`mozFullScreenElement`,`mozFullScreenEnabled`,`mozfullscreenchange`,`mozfullscreenerror`],[`msRequestFullscreen`,`msExitFullscreen`,`msFullscreenElement`,`msFullscreenEnabled`,`MSFullscreenChange`,`MSFullscreenError`]],n=0,r=t.length,i={};for(;n<r;n++)if(e=t[n],e&&e[1]in document){for(n=0;n<e.length;n++)i[t[0][n]]=e[n];return i}return!1}(),t={fullscreenchange:e.fullscreenchange,fullscreenerror:e.fullscreenerror},n={request(t){return new Promise((r,i)=>{let a=function(){n.off(`fullscreenchange`,a),r()};n.on(`fullscreenchange`,a),t||=document.documentElement;let o=t[e.requestFullscreen]();o instanceof Promise&&o.then(a).catch(i)})},exit(){return new Promise((t,r)=>{if(!n.isFullscreen){t();return}let i=function(){n.off(`fullscreenchange`,i),t()};n.on(`fullscreenchange`,i);let a=document[e.exitFullscreen]();a instanceof Promise&&a.then(i).catch(r)})},on(e,n){let r=t[e];r&&document.addEventListener(r,n)},off(e,n){let r=t[e];r&&document.removeEventListener(r,n)}};return Object.defineProperties(n,{isFullscreen:{get(){return!!document[e.fullscreenElement]}},element:{enumerable:!0,get(){return document[e.fullscreenElement]}},isEnabled:{enumerable:!0,get(){return!!document[e.fullscreenEnabled]}}}),n}var Oy={role:`viewer`,autoPlayMuted:!0,allowedDrift:.3,maxAllowedDrift:1,minCheckInterval:.1,maxRateAdjustment:.2,maxTimeToCatchUp:1},ky=class extends EventTarget{logger;constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;super(),this.logger=r,this.init(t,e,{...Oy,...n})}disconnect(){this.dispatchEvent(new Event(`disconnect`))}async init(e,t,n){if(await this.waitForTOReadyState(e,`open`),n.role===`viewer`){await this.updatePlayer(e,t,n);let r=ny(e,`change`,()=>this.updatePlayer(e,t,n)),i=this.maintainPlaybackPosition(e,t,n);this.addEventListener(`disconnect`,()=>{i.cancel(),r.cancel()})}else{await this.updateTimingObject(e,t);let n=ny(t,[`seeked`,`play`,`pause`,`ratechange`],()=>this.updateTimingObject(e,t),`on`,`off`);this.addEventListener(`disconnect`,()=>n.cancel())}}async updateTimingObject(e,t){let[n,r,i]=await Promise.all([t.getCurrentTime(),t.getPaused(),t.getPlaybackRate()]);e.update({position:n,velocity:r?0:i})}async updatePlayer(e,t,n){let{position:r,velocity:i}=e.query();typeof r==`number`&&t.setCurrentTime(r),typeof i==`number`&&(i===0?await t.getPaused()===!1&&t.pause():i>0&&(await t.getPaused()===!0&&(await t.play().catch(async e=>{e.name===`NotAllowedError`&&n.autoPlayMuted&&(await t.setMuted(!0),await t.play().catch(e=>console.error(`Couldn't play the video from TimingSrcConnector. Error:`,e)))}),this.updatePlayer(e,t,n)),await t.getPlaybackRate()!==i&&t.setPlaybackRate(i)))}maintainPlaybackPosition(e,t,n){let{allowedDrift:r,maxAllowedDrift:i,minCheckInterval:a,maxRateAdjustment:o,maxTimeToCatchUp:s}=n,c=Math.min(s,Math.max(a,i))*1e3,l=async()=>{if(e.query().velocity===0||await t.getPaused()===!0)return;let n=e.query().position-await t.getCurrentTime(),a=Math.abs(n);if(this.log(`Drift: ${n}`),a>i)await this.adjustSpeed(t,0),t.setCurrentTime(e.query().position),this.log(`Resync by currentTime`);else if(a>r){let e=a/s,r=o,i=e<r?(r-e)/2:r;await this.adjustSpeed(t,i*Math.sign(n)),this.log(`Resync by playbackRate`)}},u=setInterval(()=>l(),c);return{cancel:()=>clearInterval(u)}}log(e){this.logger?.(`TimingSrcConnector: ${e}`)}speedAdjustment=0;adjustSpeed=async(e,t)=>{if(this.speedAdjustment===t)return;let n=await e.getPlaybackRate()-this.speedAdjustment+t;this.log(`New playbackRate: ${n}`),await e.setPlaybackRate(n),this.speedAdjustment=t};waitForTOReadyState(e,t){return new Promise(n=>{let r=()=>{e.readyState===t?n():e.addEventListener(`readystatechange`,r,{once:!0})};r()})}},Ay=new WeakMap,jy=new WeakMap,My={},Ny=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(window.jQuery&&e instanceof jQuery&&(e.length>1&&window.console&&console.warn&&console.warn(`A jQuery object with multiple elements was passed, using the first element.`),e=e[0]),typeof document<`u`&&typeof e==`string`&&(e=document.getElementById(e)),!Xv(e))throw TypeError(`You must pass either a valid element or a valid id.`);if(e.nodeName!==`IFRAME`){let t=e.querySelector(`iframe`);t&&(e=t)}if(e.nodeName===`IFRAME`&&!Qv(e.getAttribute(`src`)||``))throw Error(`The player element passed isn’t a Vimeo embed.`);if(Ay.has(e))return Ay.get(e);this._window=e.ownerDocument.defaultView,this.element=e,this.origin=`*`;let n=new cy((n,r)=>{if(this._onMessage=e=>{if(!Qv(e.origin)||this.element.contentWindow!==e.source)return;this.origin===`*`&&(this.origin=e.origin);let t=hy(e.data);if(t&&t.event===`error`&&t.data&&t.data.method===`ready`){let e=Error(t.data.message);e.name=t.data.name,r(e);return}let i=t&&t.event===`ready`,a=t&&t.method===`ping`;if(i||a){this.element.setAttribute(`data-ready`,`true`),n();return}_y(this,t)},this._window.addEventListener(`message`,this._onMessage),this.element.nodeName!==`IFRAME`){let n=yy(e,t);xy(ty(n),n,e).then(t=>{let n=by(t,e);return this.element=n,this._originalElement=e,my(e,n),Ay.set(this.element,this),t}).catch(r)}});if(jy.set(this,n),Ay.set(this.element,this),this.element.nodeName===`IFRAME`&&gy(this,`ping`),My.isEnabled){let e=()=>My.exit();this.fullscreenchangeHandler=()=>{My.isFullscreen?uy(this,`event:exitFullscreen`,e):fy(this,`event:exitFullscreen`,e),this.ready().then(()=>{gy(this,`fullscreenchange`,My.isFullscreen)})},My.on(`fullscreenchange`,this.fullscreenchangeHandler)}return this}static isVimeoUrl(e){return Qv(e)}callMethod(e){var t=[...arguments].slice(1);if(e==null)throw TypeError(`You must pass a method name.`);return new cy((n,r)=>this.ready().then(()=>{uy(this,e,{resolve:n,reject:r}),t.length===0?t={}:t.length===1&&(t=t[0]),gy(this,e,t)}).catch(r))}get(e){return new cy((t,n)=>(e=Yv(e,`get`),this.ready().then(()=>{uy(this,e,{resolve:t,reject:n}),gy(this,e)}).catch(n)))}set(e,t){return new cy((n,r)=>{if(e=Yv(e,`set`),t==null)throw TypeError(`There must be a value to set.`);return this.ready().then(()=>{uy(this,e,{resolve:n,reject:r}),gy(this,e,t)}).catch(r)})}on(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(!t)throw TypeError(`You must pass a callback function.`);if(typeof t!=`function`)throw TypeError(`The callback must be a function.`);dy(this,`event:${e}`).length===0&&this.callMethod(`addEventListener`,e).catch(()=>{}),uy(this,`event:${e}`,t)}off(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(t&&typeof t!=`function`)throw TypeError(`The callback must be a function.`);fy(this,`event:${e}`,t)&&this.callMethod(`removeEventListener`,e).catch(e=>{})}loadVideo(e){return this.callMethod(`loadVideo`,e)}ready(){let e=jy.get(this)||new cy((e,t)=>{t(Error(`Unknown player. Probably unloaded.`))});return cy.resolve(e)}addCuePoint(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.callMethod(`addCuePoint`,{time:e,data:t})}removeCuePoint(e){return this.callMethod(`removeCuePoint`,e)}enableTextTrack(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`enableTextTrack`,{language:e,kind:t,showing:n})}disableTextTrack(){return this.callMethod(`disableTextTrack`)}selectAudioTrack(e,t){if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`selectAudioTrack`,{language:e,kind:t})}selectDefaultAudioTrack(){return this.callMethod(`selectDefaultAudioTrack`)}pause(){return this.callMethod(`pause`)}play(){return this.callMethod(`play`)}requestFullscreen(){return My.isEnabled?My.request(this.element):this.callMethod(`requestFullscreen`)}exitFullscreen(){return My.isEnabled?My.exit():this.callMethod(`exitFullscreen`)}getFullscreen(){return My.isEnabled?cy.resolve(My.isFullscreen):this.get(`fullscreen`)}requestPictureInPicture(){return this.callMethod(`requestPictureInPicture`)}exitPictureInPicture(){return this.callMethod(`exitPictureInPicture`)}getPictureInPicture(){return this.get(`pictureInPicture`)}remotePlaybackPrompt(){return this.callMethod(`remotePlaybackPrompt`)}unload(){return this.callMethod(`unload`)}destroy(){return new cy(e=>{if(jy.delete(this),Ay.delete(this.element),this._originalElement&&(Ay.delete(this._originalElement),this._originalElement.removeAttribute(`data-vimeo-initialized`)),this.element&&this.element.nodeName===`IFRAME`&&this.element.parentNode&&(this.element.parentNode.parentNode&&this._originalElement&&this._originalElement!==this.element.parentNode?this.element.parentNode.parentNode.removeChild(this.element.parentNode):this.element.parentNode.removeChild(this.element)),this.element&&this.element.nodeName===`DIV`&&this.element.parentNode){this.element.removeAttribute(`data-vimeo-initialized`);let e=this.element.querySelector(`iframe`);e&&e.parentNode&&(e.parentNode.parentNode&&this._originalElement&&this._originalElement!==e.parentNode?e.parentNode.parentNode.removeChild(e.parentNode):e.parentNode.removeChild(e))}this._window.removeEventListener(`message`,this._onMessage),My.isEnabled&&My.off(`fullscreenchange`,this.fullscreenchangeHandler),e()})}getAutopause(){return this.get(`autopause`)}setAutopause(e){return this.set(`autopause`,e)}getBuffered(){return this.get(`buffered`)}getCameraProps(){return this.get(`cameraProps`)}setCameraProps(e){return this.set(`cameraProps`,e)}getChapters(){return this.get(`chapters`)}getCurrentChapter(){return this.get(`currentChapter`)}getColor(){return this.get(`color`)}getColors(){return cy.all([this.get(`colorOne`),this.get(`colorTwo`),this.get(`colorThree`),this.get(`colorFour`)])}setColor(e){return this.set(`color`,e)}setColors(e){if(!Array.isArray(e))return new cy((e,t)=>t(TypeError(`Argument must be an array.`)));let t=new cy(e=>e(null)),n=[e[0]?this.set(`colorOne`,e[0]):t,e[1]?this.set(`colorTwo`,e[1]):t,e[2]?this.set(`colorThree`,e[2]):t,e[3]?this.set(`colorFour`,e[3]):t];return cy.all(n)}getCuePoints(){return this.get(`cuePoints`)}getCurrentTime(){return this.get(`currentTime`)}setCurrentTime(e){return this.set(`currentTime`,e)}getDuration(){return this.get(`duration`)}getEnded(){return this.get(`ended`)}getLoop(){return this.get(`loop`)}setLoop(e){return this.set(`loop`,e)}setMuted(e){return this.set(`muted`,e)}getMuted(){return this.get(`muted`)}getPaused(){return this.get(`paused`)}getPlaybackRate(){return this.get(`playbackRate`)}setPlaybackRate(e){return this.set(`playbackRate`,e)}getPlayed(){return this.get(`played`)}getQualities(){return this.get(`qualities`)}getQuality(){return this.get(`quality`)}setQuality(e){return this.set(`quality`,e)}getRemotePlaybackAvailability(){return this.get(`remotePlaybackAvailability`)}getRemotePlaybackState(){return this.get(`remotePlaybackState`)}getSeekable(){return this.get(`seekable`)}getSeeking(){return this.get(`seeking`)}getTextTracks(){return this.get(`textTracks`)}getAudioTracks(){return this.get(`audioTracks`)}getEnabledAudioTrack(){return this.get(`enabledAudioTrack`)}getDefaultAudioTrack(){return this.get(`defaultAudioTrack`)}getVideoEmbedCode(){return this.get(`videoEmbedCode`)}getVideoId(){return this.get(`videoId`)}getVideoTitle(){return this.get(`videoTitle`)}getVideoWidth(){return this.get(`videoWidth`)}getVideoHeight(){return this.get(`videoHeight`)}getVideoUrl(){return this.get(`videoUrl`)}getVolume(){return this.get(`volume`)}setVolume(e){return this.set(`volume`,e)}async setTimingSrc(e,t){if(!e)throw TypeError(`A Timing Object must be provided.`);await this.ready();let n=new ky(this,e,t);return gy(this,`notifyTimingObjectConnect`),n.addEventListener(`disconnect`,()=>gy(this,`notifyTimingObjectDisconnect`)),n}};Jv||(My=Dy(),Sy(),Cy(),wy(),Ty(),Ey());function Py(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Fy(e,t)}function Fy(e,t){return Fy=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Fy(e,t)}var Iy={play:`onPlay`,playing:`onPlaying`,pause:`onPause`,ended:`onEnd`,timeupdate:`onTimeUpdate`,progress:`onProgress`,seeked:`onSeeked`,texttrackchange:`onTextTrackChange`,cuechange:`onCueChange`,cuepoint:`onCuePoint`,volumechange:`onVolumeChange`,playbackratechange:`onPlaybackRateChange`,error:`onError`,loaded:`onLoaded`},Ly=function(e){function t(t){var n=e.call(this,t)||this;return n.refContainer=n.refContainer.bind(n),n}Py(t,e);var n=t.prototype;return n.componentDidMount=function(){this.createPlayer()},n.componentDidUpdate=function(e){var t=this,n=Object.keys(this.props).filter(function(n){return t.props[n]!==e[n]});this.updateProps(n)},n.componentWillUnmount=function(){this.player.destroy()},n.getInitialOptions=function(){var e,t=this.props.video,n=/^https?:/i.test(t)?`url`:`id`;return e={},e[n]=t,e.width=this.props.width,e.height=this.props.height,e.autopause=this.props.autopause,e.autoplay=this.props.autoplay,e.byline=this.props.showByline,e.color=this.props.color,e.controls=this.props.controls,e.loop=this.props.loop,e.portrait=this.props.showPortrait,e.title=this.props.showTitle,e.muted=this.props.muted,e.background=this.props.background,e.responsive=this.props.responsive,e.dnt=this.props.dnt,e.speed=this.props.speed,e.keyboard=this.props.keyboard,e.pip=this.props.pip,e.playsinline=this.props.playsInline,e.quality=this.props.quality,e.texttrack=this.props.textTrack,e.transparent=this.props.transparent,e},n.updateProps=function(e){var t=this,n=this.player;e.forEach(function(e){var r=t.props[e];switch(e){case`autopause`:n.setAutopause(r);break;case`color`:n.setColor(r);break;case`loop`:n.setLoop(r);break;case`volume`:n.setVolume(r);break;case`paused`:n.getPaused().then(function(e){return r&&!e?n.pause():!r&&e?n.play():null});break;case`width`:case`height`:n.element[e]=r;break;case`video`:if(r){var i=t.props.start,a=n.loadVideo(r);typeof i==`number`&&a.then(function(){n.setCurrentTime(i)})}else n.unload();break;case`playbackRate`:n.setPlaybackRate(r);break;case`quality`:n.setQuality(r);break}})},n.createPlayer=function(){var e=this,t=this.props,n=t.start,r=t.volume,i=t.playbackRate;this.player=new Ny(this.container,this.getInitialOptions()),Object.keys(Iy).forEach(function(t){var n=Iy[t];e.player.on(t,function(t){var r=e.props[n];r&&r(t)})});var a=this.props,o=a.onError,s=a.onReady;this.player.ready().then(function(){s&&s(e.player)},function(e){if(o)o(e);else throw e}),typeof n==`number`&&this.player.setCurrentTime(n),typeof r==`number`&&this.updateProps([`volume`]),typeof i==`number`&&this.updateProps([`playbackRate`])},n.refContainer=function(e){this.container=e},n.render=function(){var e=this.props,t=e.id,n=e.className,r=e.style;return Q.createElement(`div`,{id:t,className:n,style:r,ref:this.refContainer})},t}(Q.Component);Ly.defaultProps={autopause:!0,autoplay:!1,showByline:!0,controls:!0,loop:!1,showPortrait:!0,showTitle:!0,muted:!1,background:!1,responsive:!1,dnt:!1,speed:!1,keyboard:!0,pip:!1,playsInline:!0,transparent:!0};var Ry={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},zy=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Q.useState)(``);return(0,Q.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=Ry[r],c=new Image;c.onload=()=>{c.width<s?a(o):a(i)},c.onerror=()=>a(o),c.src=i},[e,t,n,r]),i};function By(e,t,n,r,i){let a={"@context":`https://schema.org`,"@type":`VideoObject`,name:i?.name||t,thumbnailUrl:[i?.thumbnailUrl||n],embedUrl:i?.embedUrl||`${r}/embed/${e}`,contentUrl:i?.contentUrl||`https://www.youtube.com/watch?v=${e}`,...i?.description&&{description:i.description},...i?.uploadDate&&{uploadDate:i.uploadDate},...i?.duration&&{duration:i.duration}};return JSON.stringify(a)}function Vy(e,t){let[n,r]=Q.useState(!1),[i,a]=Q.useState(e.alwaysLoadIframe||!1),o=encodeURIComponent(e.id),s=typeof e.playlistCoverId==`string`?encodeURIComponent(e.playlistCoverId):null,c=e.title,l=e.poster||`hqdefault`,u=e.announce||`Watch`,d=e.alwaysLoadIframe?e.autoplay&&e.muted:!0,f=Q.useMemo(()=>{let t=new URLSearchParams({...e.muted?{mute:`1`}:{},...d?{autoplay:`1`}:{},...e.enableJsApi?{enablejsapi:`1`}:{},...e.enableJsApi&&typeof window<`u`?{origin:window.location.origin}:{},...e.playlist?{list:o}:{}});return e.params&&new URLSearchParams(e.params.startsWith(`&`)?e.params.slice(1):e.params).forEach((e,n)=>{t.append(n,e)}),t},[e.muted,d,e.enableJsApi,e.playlist,o,e.params]),p=Q.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Q.useMemo(()=>e.playlist?`${p}/embed/videoseries?${f.toString()}`:`${p}/embed/${o}?${f.toString()}`,[e.playlist,p,o,f]),h=!e.thumbnail&&!e.playlist&&l===`maxresdefault`,g=e.webp?`webp`:`jpg`,_=e.webp?`vi_webp`:`vi`,v=h?zy(e.id,_,g,l):null,y=Q.useMemo(()=>e.thumbnail||v||`https://i.ytimg.com/${_}/${e.playlist?s:o}/${l}.${g}`,[e.thumbnail,v,_,e.playlist,s,o,l,g]),b=e.activatedClass||`lyt-activated`,x=e.adNetwork||!1,S=e.aspectHeight||9,C=e.aspectWidth||16,w=e.iframeClass||``,T=e.playerClass||`lty-playbtn`,E=e.wrapperClass||`yt-lite`,D=Q.useCallback(e.onIframeAdded||function(){},[e.onIframeAdded]),O=e.rel?`prefetch`:`preload`,k=e.containerElement||`article`,A=e.noscriptFallback!==!1,j=()=>{n||r(!0)},M=()=>{i||a(!0)};return Q.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Q.useEffect(()=>{if(!i||!e.enableJsApi||!(e.onReady||e.onStateChange||e.onError||e.onPlay||e.onPause||e.onEnd||e.onBuffering||e.onPlaybackRateChange||e.onPlaybackQualityChange))return;let n=!1,r=!1,a=r=>{if(r.origin!==`https://www.youtube.com`&&r.origin!==`https://www.youtube-nocookie.com`)return;let i;try{i=typeof r.data==`string`?JSON.parse(r.data):r.data}catch{return}switch(i.event){case`onReady`:n||(n=!0,e.onReady&&e.onReady({videoId:e.id,title:c}));break;case`infoDelivery`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate),i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break;case`onStateChange`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}break;case`onError`:if(i.info&&`errorCode`in i.info){let t=i.info.errorCode;e.onError&&e.onError(t)}break;case`onPlaybackRateChange`:i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate);break;case`onPlaybackQualityChange`:i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break}};window.addEventListener(`message`,a);let s=[],l=()=>{typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"listening","id":"`+o+`"}`,`*`)},u=()=>{r||(r=!0,l(),[100,300,600,1200,2400].forEach(e=>{s.push(setTimeout(l,e))}))};return typeof t==`object`&&t?.current?(t.current.addEventListener(`load`,u),t.current.contentDocument?.readyState===`complete`&&u()):[200,500,1e3,2e3,3e3].forEach(e=>{s.push(setTimeout(l,e))}),()=>{window.removeEventListener(`message`,a),s.forEach(clearTimeout),typeof t==`object`&&t?.current&&t.current.removeEventListener(`load`,u)}},[i,e.enableJsApi,e.onReady,e.onStateChange,e.onError,e.onPlay,e.onPause,e.onEnd,e.onBuffering,e.onPlaybackRateChange,e.onPlaybackQualityChange,e.stopOnEnd,e.id,o,c,t]),(0,Z.jsxs)(Z.Fragment,{children:[!e.lazyLoad&&(0,Z.jsx)(`link`,{rel:O,href:y,as:`image`}),(0,Z.jsx)(Z.Fragment,{children:n&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`link`,{rel:`preconnect`,href:p}),(0,Z.jsx)(`link`,{rel:`preconnect`,href:`https://www.google.com`}),x&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`link`,{rel:`preconnect`,href:`https://static.doubleclick.net`}),(0,Z.jsx)(`link`,{rel:`preconnect`,href:`https://googleads.g.doubleclick.net`})]})]})}),e.seo&&!e.playlist&&(0,Z.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:By(e.id,c,y,p,e.seo)}}),A&&!e.playlist&&(0,Z.jsx)(`noscript`,{children:(0,Z.jsxs)(`a`,{href:`https://www.youtube.com/watch?v=${e.id}`,"aria-label":`Watch ${c} on YouTube`,children:[`Watch "`,c,`" on YouTube`]})}),(0,Z.jsxs)(k,{onPointerOver:j,onClick:M,className:`${E} ${i?b:``}`,"data-title":c,role:!i&&!e.lazyLoad?`img`:void 0,"aria-label":i?void 0:`${c} - YouTube video preview`,style:{...!e.lazyLoad&&{backgroundImage:`url(${y})`},"--aspect-ratio":`${S/C*100}%`,...e.style||{}},children:[e.lazyLoad&&!i&&(0,Z.jsx)(`img`,{src:y,alt:`${c} - YouTube thumbnail`,className:`lty-thumbnail`,loading:`lazy`}),e.playlist&&!i&&(0,Z.jsx)(`div`,{className:`lty-playlist-icon`,"aria-hidden":`true`}),!(e.hideButtonOnActivate&&i)&&(0,Z.jsx)(`button`,{type:`button`,className:T,"aria-label":`${u} ${c}`,"aria-hidden":i||void 0,tabIndex:i?-1:0,onClick:M,children:(0,Z.jsx)(`span`,{className:`lty-visually-hidden`,children:u})}),i&&(0,Z.jsx)(`iframe`,{ref:t,className:w,title:c,width:`560`,height:`315`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,src:m,referrerPolicy:e.referrerPolicy||`strict-origin-when-cross-origin`})]})]})}var Hy=Q.forwardRef(Vy);function Uy(e){return e!==!1}function Wy(e,t){let n=[];return t.startSeconds!==null&&n.push(`start=${t.startSeconds}`),e.controls===!1&&n.push(`controls=0`),e.loop===!0&&n.push(`loop=1`,`playlist=${t.id}`),e.playsinline===!0&&n.push(`playsinline=1`),n.length>0?n.join(`&`):void 0}function Gy(e){if(e.width!==void 0)return{width:e.width}}function Ky(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function qy(e){let t=(0,$.c)(23),n=(0,Q.useRef)(null),r=e.title??`Vimeo video player`,i;t[0]===r?i=t[1]:(i=e=>{let t=e;n.current=t,t.element&&(t.element.title=r)},t[0]=r,t[1]=i);let a=i,o,s;t[2]===r?(o=t[3],s=t[4]):(o=()=>{let e=n.current;e?.element&&(e.element.title=r)},s=[r],t[2]=r,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let c;t[5]===e?c=t[6]:(c=Gy(e),t[5]=e,t[6]=c);let l=e.width===void 0,u=e.autoplay===!0,d=e.muted===!0,f=e.muted===!0?0:1,p=e.loop===!0,m=e.controls!==!1,h=e.playsinline!==!1,g;t[7]!==a||t[8]!==e.height||t[9]!==e.src||t[10]!==e.width||t[11]!==h||t[12]!==l||t[13]!==u||t[14]!==d||t[15]!==f||t[16]!==p||t[17]!==m?(g=(0,Z.jsx)(Ly,{video:e.src,responsive:l,width:e.width,height:e.height,autoplay:u,muted:d,volume:f,loop:p,controls:m,playsInline:h,onReady:a}),t[7]=a,t[8]=e.height,t[9]=e.src,t[10]=e.width,t[11]=h,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=g):g=t[18];let _;return t[19]!==e.title||t[20]!==g||t[21]!==c?(_=(0,Z.jsx)(`div`,{className:`ok-video ok-video-vimeo`,style:c,title:e.title,children:g}),t[19]=e.title,t[20]=g,t[21]=c,t[22]=_):_=t[22],_}function Jy(e){let t=(0,$.c)(17),n;t[0]===e.src?n=t[1]:(n=mt(e.src),t[0]=e.src,t[1]=n);let r=n;if(!r)return null;let i;t[2]!==r.startRaw||t[3]!==e.autoplay||t[4]!==e.muted?(i=[],r.startRaw!==null&&i.push(`t=${r.startRaw}`),e.autoplay===!0&&i.push(`autoplay=true`),e.muted===!0&&i.push(`muted=true`),t[2]=r.startRaw,t[3]=e.autoplay,t[4]=e.muted,t[5]=i):i=t[5];let a=i.length>0?`https://www.loom.com/embed/${r.id}?${i.join(`&`)}`:`https://www.loom.com/embed/${r.id}`,o;t[6]===e?o=t[7]:(o=Gy(e),t[6]=e,t[7]=o);let s=e.title??`Loom video player`,c;t[8]!==a||t[9]!==e.height||t[10]!==e.width||t[11]!==s?(c=(0,Z.jsx)(`iframe`,{className:`ok-video-loom-iframe`,src:a,title:s,width:e.width,height:e.height,allow:`autoplay; fullscreen`,referrerPolicy:`strict-origin-when-cross-origin`,allowFullScreen:!0}),t[8]=a,t[9]=e.height,t[10]=e.width,t[11]=s,t[12]=c):c=t[12];let l;return t[13]!==e.title||t[14]!==o||t[15]!==c?(l=(0,Z.jsx)(`div`,{className:`ok-video ok-video-loom`,style:o,title:e.title,children:c}),t[13]=e.title,t[14]=o,t[15]=c,t[16]=l):l=t[16],l}function Yy(e){let t=(0,$.c)(29);if(e.src!==void 0&&D(e.src)){let n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Jy,{...e,src:e.src}),t[0]=e,t[1]=n),n}if(e.src!==void 0&&xe(e.src)){let n;return t[2]===e?n=t[3]:(n=(0,Z.jsx)(qy,{...e,src:e.src}),t[2]=e,t[3]=n),n}let n;if(t[4]!==e){n=Symbol.for(`react.early_return_sentinel`);bb0:{let r=e.src===void 0?null:Be(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=Gy(e),s;t[6]===e.poster?s=t[7]:(s=e.poster===void 0?void 0:le(e.poster),t[6]=e.poster,t[7]=s);let c=(0,Z.jsx)(Hy,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:Wy(e,r),muted:e.muted===!0,autoplay:e.autoplay===!0,alwaysLoadIframe:i,thumbnail:s,aspectWidth:a?Number(e.width):void 0,aspectHeight:a?Number(e.height):void 0,style:Ky(e)}),l;t[8]!==o||t[9]!==c?(l=(0,Z.jsx)(`div`,{className:`ok-video ok-video-youtube`,style:o,children:c}),t[8]=o,t[9]=c,t[10]=l):l=t[10],n=l;break bb0}}t[4]=e,t[5]=n}else n=t[5];if(n!==Symbol.for(`react.early_return_sentinel`))return n;let r;t[11]===e.src?r=t[12]:(r=e.src===void 0?void 0:le(e.src),t[11]=e.src,t[12]=r);let i=e.title,a;t[13]===e.controls?a=t[14]:(a=Uy(e.controls),t[13]=e.controls,t[14]=a);let o;t[15]===e.poster?o=t[16]:(o=e.poster===void 0?void 0:le(e.poster),t[15]=e.poster,t[16]=o);let s;return t[17]!==e.autoplay||t[18]!==e.height||t[19]!==e.loop||t[20]!==e.muted||t[21]!==e.playsinline||t[22]!==e.preload||t[23]!==e.title||t[24]!==e.width||t[25]!==r||t[26]!==a||t[27]!==o?(s=(0,Z.jsx)(`video`,{className:`ok-video`,src:r,title:i,controls:a,autoPlay:e.autoplay,muted:e.muted,loop:e.loop,playsInline:e.playsinline,poster:o,preload:e.preload,width:e.width,height:e.height}),t[17]=e.autoplay,t[18]=e.height,t[19]=e.loop,t[20]=e.muted,t[21]=e.playsinline,t[22]=e.preload,t[23]=e.title,t[24]=e.width,t[25]=r,t[26]=a,t[27]=o,t[28]=s):s=t[28],s}function Xy(e){let t=(0,$.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,Z.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var Zy={Callout:l_,img:nv,video:Yy,audio:i_,Pdf:Av,File:y_,Embed:__,Accordion:n_,Tabs:Vv,Tab:Lv,Math:av,MermaidFence:Xt,Mirror:gv,MirrorSource:_v,"*":Xy};function Qy(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var $y=Me(),eb=new Map;function tb(e){if(e.surface===`compat`){let t=Zy[e.rendersAs];if(!t)throw Error(`Compat descriptor '${e.name}' declares rendersAs: '${e.rendersAs}', but no React component is registered under that name in componentMap. Add the canonical component before registering the compat descriptor.`);return{Component:t,reactNodePropNames:Qy(e.props)}}let t=Zy[e.name];return t?{Component:t,reactNodePropNames:Qy(e.props)}:null}for(let[e,t]of $y.entries()){let n=tb(t);n&&eb.set(e,n)}function nb(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function rb(e){let t=$y.getOrWildcard(e),n=eb.get(t.name)??eb.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return nb(t,n)}function ib(){let e=[];for(let[t,n]of $y.entries()){if(t===`*`)continue;let r=eb.get(t);r&&e.push(nb(n,r))}return e}var ab=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,ob=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,sb={Callout:{description:{id:`322lyb`},props:{type:`note`,title:`Heads up`},children:`Callouts draw attention to key information.`},Accordion:{description:{id:`mWVJRX`},props:{title:`Click to expand`,defaultOpen:!0},children:`Hidden content goes here.`},img:{description:{id:`VUijjF`},props:{src:ab,alt:`Sample image`}},video:{description:{id:`e1hptq`},props:{controls:!0,poster:ob}},audio:{description:{id:`9jnjV0`},props:{controls:!0}},Math:{description:{id:`Y-Urt2`},props:{formula:`c = \\pm\\sqrt{a^2 + b^2}`}},Embed:{description:{id:`jTLWxh`},render:()=>(0,Z.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Z.jsx)(`span`,{className:`ml-1.5 flex-1 truncate rounded-sm bg-background px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:`https://example.com/embed`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-full rounded-sm bg-muted-foreground/20`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-5/6 rounded-sm bg-muted-foreground/20`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]})]})},Pdf:{description:{id:`Fqr8BP`},render:()=>(0,Z.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/40 px-1.5 py-1`,children:[(0,Z.jsxs)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 text-muted-foreground`,"aria-hidden":`true`,children:[(0,Z.jsx)(`title`,{children:`Thumbnails`}),(0,Z.jsx)(`rect`,{x:`1`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,Z.jsx)(`rect`,{x:`7`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,Z.jsx)(`rect`,{x:`1`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,Z.jsx)(`rect`,{x:`7`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`})]}),(0,Z.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5 font-mono`,children:`2`}),(0,Z.jsx)(`span`,{children:`/ 12`})]}),(0,Z.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] font-mono text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`−`}),(0,Z.jsx)(`span`,{children:`100%`}),(0,Z.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`+`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 gap-1 p-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex w-6 flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`}),(0,Z.jsx)(`span`,{className:`h-3 rounded-sm border border-foreground/60 bg-background`}),(0,Z.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 rounded-sm bg-background p-1.5`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1/2 rounded-sm bg-foreground/50`}),(0,Z.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`h-1 w-5/6 rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`h-1 w-2/3 rounded-sm bg-muted-foreground/30`})]})]})]})},MermaidFence:{description:{id:`z0a2EA`},render:()=>(0,Z.jsxs)(`svg`,{viewBox:`0 0 200 120`,className:`h-full w-full text-foreground`,"aria-hidden":`true`,preserveAspectRatio:`xMidYMid meet`,children:[(0,Z.jsx)(`title`,{children:`Mermaid flowchart preview`}),(0,Z.jsx)(`defs`,{children:(0,Z.jsx)(`marker`,{id:`mermaid-preview-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,Z.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`currentColor`})})}),(0,Z.jsx)(`rect`,{x:`14`,y:`20`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,Z.jsx)(`text`,{x:`42`,y:`38`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Start`}),(0,Z.jsx)(`polygon`,{points:`100,18 140,50 100,82 60,50`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,Z.jsx)(`text`,{x:`100`,y:`54`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Ready?`}),(0,Z.jsx)(`rect`,{x:`130`,y:`84`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,Z.jsx)(`text`,{x:`158`,y:`102`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`End`}),(0,Z.jsx)(`line`,{x1:`70`,y1:`34`,x2:`80`,y2:`40`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,Z.jsx)(`line`,{x1:`124`,y1:`62`,x2:`138`,y2:`82`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,Z.jsx)(`text`,{x:`138`,y:`74`,fontSize:`8`,fill:`currentColor`,opacity:`0.6`,children:`yes`})]})},Tabs:{description:{id:`75Y1dk`},render:()=>(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-1 border-b border-border pb-1`,children:[(0,Z.jsx)(`span`,{className:`rounded-md bg-foreground/10 px-2 py-0.5 text-xs font-medium text-foreground`,children:`Tab 1`}),(0,Z.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs text-muted-foreground`,children:`Tab 2`})]}),(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:(0,Z.jsx)(o,{id:`m6YGpY`})})]})},Mirror:{description:{id:`_WPP7e`},render:()=>(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/40 px-2 py-1.5`,children:[(0,Z.jsxs)(`span`,{className:`absolute -top-2 right-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(Xa,{className:`size-2.5`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`EL_YRd`,components:{0:(0,Z.jsx)(`code`,{className:`font-mono`})}})})]}),(0,Z.jsx)(`span`,{className:`block h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`mt-1 block h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]}),(0,Z.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,Z.jsx)(o,{id:`qNOgUu`})})]})},MirrorSource:{description:{id:`epuNYK`},render:()=>(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/50 px-2 py-1.5`,children:[(0,Z.jsxs)(`span`,{className:`absolute -top-2 left-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(Yn,{className:`size-2.5`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`maDWIB`,components:{0:(0,Z.jsx)(`code`,{className:`font-mono`})}})})]}),(0,Z.jsx)(`span`,{className:`block h-1.5 w-4/5 rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`mt-1 block h-1.5 w-3/5 rounded-sm bg-muted-foreground/20`})]}),(0,Z.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,Z.jsx)(o,{id:`emgiet`})})]})}};function cb(e){let t={};for(let n of e.props)n.type!==`reactnode`&&`defaultValue`in n&&n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function lb(e){let t=rb(e),n=cb(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var ub=new Set;function db(e){ub.add(e)}function fb(e){if(typeof e==`number`)return ub.delete(e);let t=ub.values().next();return t.done?!1:(ub.delete(t.value),!0)}function pb(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(db(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function mb(e){return t=>{let n=new WeakSet;t.state.doc.descendants(t=>{t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&n.add(t)});let r=lb(e.name);if(e.name===`Tabs`){let e=lb(`Tab`),t=lb(`Tab`),n=e.attrs,i=t.attrs;n.props={...n.props,label:`Tab 1`},i.props={...i.props,label:`Tab 2`},r.content=[e,t]}t.chain().focus().insertContent(r).run();let i=-1;t.state.doc.descendants((t,r)=>{if(i>=0)return!1;t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&!n.has(t)&&(i=r)}),!(i<0)&&pb(t,i,e)}}var hb=new Set([`File`,`Tab`]);function gb(){return[{name:`component-File`,label:ai._({id:`J2eKUI`}),icon:$a,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",command:vb,preview:{description:ai._({id:`t-JXbf`}),render:()=>(0,Z.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5`,children:[(0,Z.jsx)($a,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:`quarterly-report.pdf`}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`1.4 MB`})]})}}]}function _b(){return[...ib().filter(e=>e.surface===`canonical`&&!hb.has(e.name)).map(e=>{let t=sb[e.name],n=e.Component,r=t?{description:ai._(t.description),render:t.render??(()=>(0,Z.jsx)(n,{...t.props,children:t.children}))}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:Qg(e.icon),category:e.category??`content`,command:mb(e),aliases:e.searchTerms,description:e.description,preview:r}}),...gb()]}function vb(e){let t=document.createElement(`input`);t.type=`file`,t.accept=`*/*`,t.style.display=`none`,t.addEventListener(`change`,()=>{let n=t.files?.[0];if(n){let t=e.state.selection.from;xg(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function yb(){return[{name:`link`,label:ai._({id:`yzF66j`}),icon:fo,category:`insert`,aliases:[`url`,`href`,`external`,`web`,`hyperlink`,`wiki`,`wikilink`,`[[`,`internal`,`page`,`backlink`,`cross-link`],description:`Link to a page or external URL`,preview:{description:ai._({id:`5WDhAk`}),render:()=>(0,Z.jsx)(`p`,{className:`leading-7 text-sm`,children:(0,Z.jsx)(o,{id:`u-9fWA`,components:{0:(0,Z.jsx)(`span`,{className:`font-medium text-azure-blue underline underline-offset-2 dark:text-sky-blue`})}})})},command:e=>{let t=e.state.selection.from;e.chain().focus().insertContent({type:`text`,text:`link`,marks:[{type:`link`,attrs:{href:``}}]}).run();let n=Fg(e.state,t,`link`);n&&(Og(n),requestAnimationFrame(()=>{Xg(e).setActiveNode(n)}))}},{name:`component-Tag`,label:ai._({id:`UL8A9w`}),icon:no,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:ai._({id:`5ClEAu`}),render:()=>(0,Z.jsx)(`p`,{className:`text-sm leading-7`,children:(0,Z.jsx)(o,{id:`KZLdgR`,components:{0:(0,Z.jsx)(`a`,{className:`tag pointer-events-none`})}})})},command:e=>{e.chain().insertTag(``).run()}}]}function bb(e,t){e.chain().focus().insertContent({type:`codeBlock`,attrs:{language:`html`,meta:`preview`},content:[{type:`text`,text:t}]}).run()}var xb=`<div style="padding:20px;font-family:system-ui,sans-serif;color:var(--foreground)">
2
+ import{o as e,t}from"./chunk-CFjPhJqf.js";import{t as n}from"./preload-helper-2ej06EnG.js";import{n as r,r as i,t as a}from"./compiler-runtime-CVnuRdak.js";import{n as o,r as s}from"./dist-CQw2y-s3.js";import{n as c}from"./dist-BVOt51sU.js";import{t as l}from"./react-dom-C-oc-P2K.js";import{$ as u,$n as d,$r as f,Ai as p,An as m,At as h,B as g,Bn as _,Br as v,Ci as y,Di as b,Ei as x,En as S,Et as C,Fi as w,Fn as T,G as E,Gn as D,Gr as O,H as k,Hn as A,Ii as j,In as M,J as N,Ji as P,Jn as F,K as I,Kn as L,Kt as R,L as ee,Li as z,Ln as te,Lr as ne,Mn as re,Nn as B,Oi as V,On as H,Pn as U,Pt as W,Q as G,Qr as ie,Ri as K,Rn as ae,Rr as oe,S as q,Si as se,Sn as ce,Ti as J,Tr as le,U as ue,Ur as Y,V as de,Vr as fe,Wi as pe,Wr as me,Wt as he,Xi as ge,Xt as _e,Yi as ve,Yn as ye,Yr as be,Zn as xe,Zr as Se,_i as Ce,_n as we,_r as Te,ai as Ee,ar as De,b as Oe,bi as ke,br as Ae,c as je,cn as Me,ct as Ne,d as Pe,dt as Fe,ei as Ie,er as Le,f as Re,fi as ze,fr as Be,ft as Ve,gr as He,hi as Ue,hn as We,ht as Ge,ir as Ke,it as qe,jn as Je,jt as Ye,kn as Xe,kr as Ze,kt as Qe,l as $e,li as et,ln as tt,lr as nt,mi as rt,mn as it,mt as at,ni as ot,oi as st,q as ct,qt as lt,rn as ut,rr as dt,rt as ft,s as pt,sr as mt,tr as ht,u as gt,ui as _t,un as vt,ut as yt,vi as bt,vn as xt,wi as St,wn as Ct,xi as wt,y as Tt,yi as Et,yr as Dt,z as Ot,zr as kt}from"./dist-D7PDymSy.js";import{t as At}from"./trace-api-D6fqC5Nw.js";import{n as jt,t as Mt}from"./propagation-api-BHhJitgG.js";import{a as Nt,c as Pt,i as Ft,l as It,o as Lt,r as Rt,t as zt,u as Bt}from"./button-cneJOVxD.js";import{$ as Vt,A as Ht,B as Ut,C as Wt,G as Gt,H as Kt,I as qt,J as Jt,K as Yt,L as Xt,M as Zt,N as Qt,O as $t,P as en,R as tn,S as nn,U as rn,V as an,W as on,X as sn,Y as cn,Z as ln,_ as un,at as dn,b as fn,c as pn,d as mn,dt as hn,ft as gn,g as _n,gt as vn,h as yn,it as bn,j as xn,k as Sn,lt as Cn,m as wn,mt as Tn,n as En,nt as Dn,p as On,pt as kn,r as An,s as jn,t as Mn,tt as Nn,ut as Pn,v as Fn,w as In,y as Ln,yt as Rn,z as zn}from"./CodeMirrorPropInput-C2VECyjO.js";import{t as Bn}from"./check-DRRCCRSs.js";import{t as Vn}from"./chevron-down-BvNcCN1f.js";import{t as Hn}from"./chevron-right-DSNnH-Vb.js";import{a as Un,i as Wn,o as Gn,r as Kn}from"./prop-types-BK5m4zFC.js";import{a as qn,d as Jn,f as Yn,l as Xn,r as Zn,t as Qn,u as $n}from"./workspace-paths-D4weWrbA.js";import{t as er}from"./eye-WB1l5kVb.js";import{t as tr}from"./folder-open-BF5DIykr.js";import{t as nr}from"./git-branch-q0qWPEwd.js";import{t as rr}from"./info-BlYnsVoP.js";import{t as ir}from"./loader-circle-B7Gv_Djz.js";import{t as ar}from"./trash-2-Dcpo0Di-.js";import{t as or}from"./triangle-alert-c3yCucJv.js";import{n as sr,r as cr}from"./dist-CoyydoqN.js";import{a as lr,c as ur,d as dr,i as fr,n as pr,o as mr,r as hr,s as gr,t as _r,u as vr}from"./dist-BSkHa6UR.js";import{a as yr,i as br,n as xr,t as Sr}from"./tooltip-FFg0kVkD.js";import{n as Cr,t as wr}from"./dist-Dkr4jGYv.js";import{n as Tr,r as Er,t as Dr}from"./collapsible-mJvufeMs.js";import{a as Or,c as kr,d as Ar,f as jr,g as Mr,h as Nr,i as Pr,l as Fr,m as Ir,n as Lr,o as Rr,p as zr,r as Br,s as Vr,t as Hr,u as Ur}from"./dialog-DdHaoAGK.js";import{t as Wr}from"./dist-BzWUi0nJ.js";import{a as Gr,i as Kr,n as qr,o as Jr,r as Yr,t as Xr}from"./dist-fpPv-rVb.js";import{a as Zr,d as Qr,i as $r,l as ei,r as ti,u as ni}from"./floating-ui.dom-DVRWCLii.js";import{t as ri}from"./input-tW78aNaR.js";import{t as ii}from"./parse-api-error-CqtA8BcL.js";import{t as ai}from"./dist-BvBijIC5.js";import{t as oi}from"./file-tree-rename-validation-DeKIxKnc.js";import{d as si,n as ci,p as li}from"./navigation-targets-D_wZddL9.js";import{n as ui,t as di}from"./documents-events-D26lhbOZ.js";import{a as X,o as fi,t as pi}from"./startup-marks-DDtA9pbt.js";import{c as mi,f as hi,h as gi,l as _i,n as vi,o as yi,r as bi,s as xi}from"./doc-hash-i5oNLfum.js";import{$ as Si,A as Ci,C as wi,D as Ti,E as Ei,F as Di,G as Oi,I as ki,J as Ai,K as ji,L as Mi,M as Ni,N as Pi,O as Fi,Q as Ii,R as Li,S as Ri,T as zi,U as Bi,W as Vi,X as Hi,Y as Ui,Z as Wi,_ as Gi,a as Ki,at as qi,b as Ji,c as Yi,d as Xi,et as Zi,f as Qi,g as $i,h as ea,it as ta,j as na,k as ra,l as ia,m as aa,nt as oa,o as sa,ot as ca,p as la,q as ua,r as da,rt as fa,s as pa,tt as ma,u as ha,v as ga,w as _a,x as va,y as ya,z as ba}from"./config-provider-BnOnKhga.js";import{Dt as xa,E as Sa,N as Ca,X as wa,c as Ta,dt as Ea,f as Da,l as Oa,ut as ka}from"./dist-Dot7Y1W_.js";import{t as Aa}from"./dist-sRKGD4vA.js";import{n as ja}from"./dist-ClYcK7Yq.js";import{n as Ma}from"./dist-DmkgvB1A.js";import{n as Na}from"./dist-COmtpu4e.js";import{n as Pa}from"./dist-Gaq2suxg.js";import{n as Fa}from"./dist-DYyQPSDl.js";import{t as Ia}from"./stex-4t0JIuX_.js";var Z=i();(function(){var e=[`user-blocking`,`user-visible`,`background`];class t{constructor(){this.t=new MessageChannel,this.i=this.t.port2,this.l={},this.o=1,this.t.port1.onmessage=e=>this.h(e)}u(e){var t=this.o++;return this.l[t]=e,this.i.postMessage(t),t}p(e){delete this.l[e]}h(e){var t=e.data;if(t in this.l){var n=this.l[t];delete this.l[t],n()}}}function n(){return n.v||=new t,n.v}class r{constructor(e,t,n){n===void 0&&(n=0),this.k=e,this.T=null,this.C=null,this.m=!1,this._(t,n)}isIdleCallback(){return this.T===0}I(){return this.T===2}cancel(){if(!this.m)switch(this.m=!0,this.T){case 0:cancelIdleCallback(this.C);break;case 1:clearTimeout(this.C);break;case 2:n().p(this.C);break;default:throw TypeError(`Unknown CallbackType`)}}_(t,r){if(r&&r>0)return this.T=1,void(this.C=setTimeout(()=>{this.P()},r));if(!e.includes(t))throw TypeError(`Invalid task priority : `+t);t===`background`&&typeof requestIdleCallback==`function`?(this.T=0,this.C=requestIdleCallback(()=>{this.P()})):typeof MessageChannel==`function`?(this.T=2,this.C=n().u(()=>{this.P()})):(this.T=1,this.C=setTimeout(()=>{this.P()}))}P(){this.m||this.k()}}var i=0;class a{constructor(){this.j=null,this.M=null}isEmpty(){return this.j==null}push(e){if(typeof e!=`object`)throw TypeError(`Task must be an Object`);e.A=i++,this.isEmpty()?(e.N=null,this.j=e):(e.N=this.M,this.M.O=e),e.O=null,this.M=e}takeNextTask(){if(this.isEmpty())return null;var e=this.j;return this.q(e),e}merge(e,t){if(typeof t!=`function`)throw TypeError(`Must provide a selector function.`);if(e==null)throw Error(`sourceQueue cannot be null`);for(var n=this.j,r=null,i=e.j;i;){var a=i;if(i=i.O,t(a)){for(e.q(a);n&&n.A<a.A;)r=n,n=n.O;this.D(a,r),r=a}}}D(e,t){if(t!=this.M){var n=t?t.O:this.j;e.O=n,n.N=e,e.N=t,t==null?this.j=e:t.O=e}else this.push(e)}q(e){if(e==null)throw Error(`Expected task to be non-null`);e===this.j&&(this.j=e.O),e===this.M&&(this.M=this.M.N),e.O&&(e.O.N=e.N),e.N&&(e.N.O=e.O)}}class o extends Event{constructor(t,n){if(!n||!e.includes(n.previousPriority))throw TypeError(`Invalid task priority: '`+n.previousPriority+`'`);super(t),this.previousPriority=n.previousPriority}}class s extends AbortController{constructor(t){if(t===void 0&&(t={}),super(),t??={},typeof t!=`object`)throw TypeError(`'init' is not an object`);var n,r,i=t.priority===void 0?`user-visible`:t.priority;if(!e.includes(i))throw TypeError(`Invalid task priority: '`+i+`'`);this.H=i,this.R=!1,r=(n=this).signal,Object.defineProperties(r,{priority:{get:function(){return n.H},enumerable:!0},onprioritychange:{value:null,writable:!0,enumerable:!0}}),r.addEventListener(`prioritychange`,e=>{r.onprioritychange&&r.onprioritychange(e)})}setPriority(t){if(!e.includes(t))throw TypeError(`Invalid task priority: `+t);if(this.R)throw new DOMException(``,`NotAllowedError`);if(this.signal.priority!==t){this.R=!0;var n=this.H;this.H=t;var r=new o(`prioritychange`,{previousPriority:n});this.signal.dispatchEvent(r),this.R=!1}}}self.scheduler===void 0?(self.scheduler=new class{constructor(){this.S={},e.forEach(e=>{this.S[e]=[new a,new a]}),this.U=null,this.W=new WeakMap}yield(){return this.B(()=>{},{priority:`user-visible`},!0)}postTask(e,t){return this.B(e,t,!1)}B(t,n,r){if((n=Object.assign({},n)).signal!==void 0){if(n.signal===null||!(`aborted`in n.signal)||typeof n.signal.addEventListener!=`function`)return Promise.reject(TypeError(`'signal' is not a valid 'AbortSignal'`));if(n.signal&&n.signal.priority&&!e.includes(n.signal.priority))return Promise.reject(TypeError(`Invalid task priority: '`+n.signal.priority+`'`))}if(n.priority!==void 0&&(n.priority===null||!e.includes(n.priority)))return Promise.reject(TypeError(`Invalid task priority: '`+n.priority+`'`));if(n.delay===void 0&&(n.delay=0),n.delay=Number(n.delay),n.delay<0)return Promise.reject(TypeError(`'delay' must be a positive number.`));var i={callback:t,options:n,resolve:null,reject:null,hostCallback:null,abortCallback:null,onTaskCompleted:function(){this.options.signal&&this.abortCallback&&(this.options.signal.removeEventListener(`abort`,this.abortCallback),this.abortCallback=null)},onTaskAborted:function(){this.hostCallback&&=(this.hostCallback.cancel(),null),this.options.signal.removeEventListener(`abort`,this.abortCallback),this.abortCallback=null,this.reject(this.options.signal.reason)},isAborted:function(){return this.options.signal&&this.options.signal.aborted},isContinuation:r},a=new Promise((e,t)=>{i.resolve=e,i.reject=t});return this._(i),a}_(e){var t=e.options.signal;if(t){if(t.aborted)return void e.reject(t.reason);e.abortCallback=()=>{e.onTaskAborted()},t.addEventListener(`abort`,e.abortCallback)}e.options.delay>0?e.hostCallback=new r(()=>{e.hostCallback=null,this.F(e)},null,e.options.delay):(this.G(e),this.J())}F(e){this.G(e),this.U&&=(this.U.cancel(),null),this.K()}L(e){var t=this.W.get(e);if(t===void 0)throw Error(`Attempting to change priority on an unregistered signal`);if(t!==e.priority){for(var n=0;n<2;n++)this.S[e.priority][n].merge(this.S[t][n],t=>t.options.signal===e);this.W.set(e,e.priority)}}K(){this.U=null,this.V(),this.J()}J(){var{priority:e}=this.X();e!=null&&(e!==`background`&&this.U&&this.U.isIdleCallback()&&(this.U.cancel(),this.U=null),this.U||=new r(()=>{this.K()},e,0))}G(t){var n;if(!e.includes(n=t.options.priority?t.options.priority:t.options.signal&&t.options.signal.priority?t.options.signal.priority:`user-visible`))throw TypeError(`Invalid task priority: `+n);if(t.options.signal&&t.options.signal.priority){var r=t.options.signal;this.W.has(r)||(r.addEventListener(`prioritychange`,()=>{this.L(r)}),this.W.set(r,r.priority))}this.S[n][+!t.isContinuation].push(t)}V(){var e=null;do{var{priority:t,type:n}=this.X();if(t==null)return;e=this.S[t][n].takeNextTask()}while(e.isAborted());try{var r=e.callback();e.resolve(r)}catch(t){e.reject(t)}finally{e.onTaskCompleted()}}X(){for(var t=0;t<e.length;t++)for(var n=e[t],r=0;r<2;r++)if(!this.S[n][r].isEmpty())return{priority:n,type:r};return{priority:null,type:0}}},self.TaskController=s,self.TaskPriorityChangeEvent=o):self.scheduler.yield||(self.scheduler.yield=function(){return self.scheduler.postTask(()=>{},{priority:`user-blocking`})})})();var La=Bt(`app-window`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),Ra=Bt(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),za=Bt(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),Ba=Bt(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),Va=Bt(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Ha=Bt(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Ua=Bt(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Wa=Bt(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ga=Bt(`circle-x`,[[`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`}]]),Ka=Bt(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),qa=Bt(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Ja=Bt(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ya=Bt(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),Xa=Bt(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Za=Bt(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Qa=Bt(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`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`}]]),$a=Bt(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),eo=Bt(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),to=Bt(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),no=Bt(`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`}]]),ro=Bt(`heading-1`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`m17 12 3-2v8`,key:`1hhhft`}]]),io=Bt(`heading-2`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`,key:`9jr5yi`}]]),ao=Bt(`heading-3`,[[`path`,{d:`M4 12h8`,key:`17cfdx`}],[`path`,{d:`M4 18V6`,key:`1rz3zl`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`,key:`68ncm8`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`,key:`1ejuhz`}]]),oo=Bt(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),so=Bt(`layout-panel-top`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}]]),co=Bt(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),lo=Bt(`link-2-off`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),uo=[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]],fo=Bt(`link-2`,uo),po=Bt(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),mo=Bt(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),ho=Bt(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),go=Bt(`message-square-warning`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]),_o=Bt(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),vo=Bt(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),yo=Bt(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),bo=Bt(`panel-top`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),xo=Bt(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),So=Bt(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Co=Bt(`quote`,[[`path`,{d:`M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`rib7q0`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z`,key:`1ymkrd`}]]),wo=Bt(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),To=Bt(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Eo=Bt(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),Do=Bt(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Oo=Bt(`sigma`,[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]]),ko=Bt(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Ao=Bt(`square-play`,[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}]]),jo=Bt(`superscript`,[[`path`,{d:`m4 19 8-8`,key:`hr47gm`}],[`path`,{d:`m12 19-8-8`,key:`1dhhmo`}],[`path`,{d:`M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06`,key:`1dfcux`}]]),Mo=Bt(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),No=Bt(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Po=Bt(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),Fo=Bt(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),Q=e(r(),1),Io=e(l(),1);function Lo(e,[t,n]){return Math.min(n,Math.max(t,e))}var Ro=`Popover`,[zo,Bo]=vr(Ro,[Gr]),Vo=Gr(),[Ho,Uo]=zo(Ro),Wo=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Vo(t),c=Q.useRef(null),[l,u]=Q.useState(!1),[d,f]=mr({prop:r,defaultProp:i??!1,onChange:a,caller:Ro});return(0,Z.jsx)(Kr,{...s,children:(0,Z.jsx)(Ho,{scope:t,contentId:fr(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:Q.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:Q.useCallback(()=>u(!0),[]),onCustomAnchorRemove:Q.useCallback(()=>u(!1),[]),modal:o,children:n})})};Wo.displayName=Ro;var Go=`PopoverAnchor`,Ko=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Uo(Go,n),a=Vo(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return Q.useEffect(()=>(o(),()=>s()),[o,s]),(0,Z.jsx)(Xr,{...a,...r,ref:t})});Ko.displayName=Go;var qo=`PopoverTrigger`,Jo=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Uo(qo,n),a=Vo(n),o=It(t,i.triggerRef),s=(0,Z.jsx)(dr.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":ls(i.open),...r,ref:o,onClick:ur(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,Z.jsx)(Xr,{asChild:!0,...a,children:s})});Jo.displayName=qo;var Yo=`PopoverPortal`,[Xo,Zo]=zo(Yo,{forceMount:void 0}),Qo=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Uo(Yo,t);return(0,Z.jsx)(Xo,{scope:t,forceMount:n,children:(0,Z.jsx)(lr,{present:n||a.open,children:(0,Z.jsx)(_r,{asChild:!0,container:i,children:r})})})};Qo.displayName=Yo;var $o=`PopoverContent`,es=Q.forwardRef((e,t)=>{let n=Zo($o,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Uo($o,e.__scopePopover);return(0,Z.jsx)(lr,{present:r||a.open,children:a.modal?(0,Z.jsx)(ns,{...i,ref:t}):(0,Z.jsx)(rs,{...i,ref:t})})});es.displayName=$o;var ts=Lt(`PopoverContent.RemoveScroll`),ns=Q.forwardRef((e,t)=>{let n=Uo($o,e.__scopePopover),r=Q.useRef(null),i=It(t,r),a=Q.useRef(!1);return Q.useEffect(()=>{let e=r.current;if(e)return zr(e)},[]),(0,Z.jsx)(Ir,{as:ts,allowPinchZoom:!0,children:(0,Z.jsx)(is,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ur(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:ur(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:ur(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),rs=Q.forwardRef((e,t)=>{let n=Uo($o,e.__scopePopover),r=Q.useRef(!1),i=Q.useRef(!1);return(0,Z.jsx)(is,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),is=Q.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Uo($o,n),p=Vo(n);return Nr(),(0,Z.jsx)(Mr,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Z.jsx)(pr,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,Z.jsx)(Yr,{"data-state":ls(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),as=`PopoverClose`,os=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Uo(as,n);return(0,Z.jsx)(dr.button,{type:`button`,...r,ref:t,onClick:ur(e.onClick,()=>i.onOpenChange(!1))})});os.displayName=as;var ss=`PopoverArrow`,cs=Q.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Vo(n);return(0,Z.jsx)(qr,{...i,...r,ref:t})});cs.displayName=ss;function ls(e){return e?`open`:`closed`}var us=Wo,ds=Ko,fs=Jo,ps=Qo,ms=es,hs=[` `,`Enter`,`ArrowUp`,`ArrowDown`],gs=[` `,`Enter`],_s=`Select`,[vs,ys,bs]=Cr(_s),[xs,Ss]=vr(_s,[bs,Gr]),Cs=Gr(),[ws,Ts]=xs(_s),[Es,Ds]=xs(_s),Os=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=Cs(t),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S=wr(l),[C,w]=mr({prop:r,defaultProp:i??!1,onChange:a,caller:_s}),[T,E]=mr({prop:o,defaultProp:s,onChange:c,caller:_s}),D=Q.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=Q.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,Z.jsx)(Kr,{...h,children:(0,Z.jsxs)(ws,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:fr(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,Z.jsx)(vs.Provider,{scope:t,children:(0,Z.jsx)(Es,{scope:e.__scopeSelect,onNativeOptionAdd:Q.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:Q.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,Z.jsxs)(Cc,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,Z.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};Os.displayName=_s;var ks=`SelectTrigger`,As=Q.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Cs(n),o=Ts(ks,n),s=o.disabled||r,c=It(t,o.onTriggerChange),l=ys(n),u=Q.useRef(`touch`),[d,f,p]=Tc(e=>{let t=l().filter(e=>!e.disabled),n=Ec(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,Z.jsx)(Xr,{asChild:!0,...a,children:(0,Z.jsx)(dr.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":wc(o.value)?``:void 0,...i,ref:c,onClick:ur(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:ur(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:ur(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&hs.includes(e.key)&&(m(),e.preventDefault())})})})});As.displayName=ks;var js=`SelectValue`,Ms=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Ts(js,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=It(t,c.onValueNodeChange);return gr(()=>{l(u)},[l,u]),(0,Z.jsx)(dr.span,{...s,ref:d,style:{pointerEvents:`none`},children:wc(c.value)?(0,Z.jsx)(Z.Fragment,{children:o}):a})});Ms.displayName=js;var Ns=`SelectIcon`,Ps=Q.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Z.jsx)(dr.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Ps.displayName=Ns;var Fs=`SelectPortal`,Is=e=>(0,Z.jsx)(_r,{asChild:!0,...e});Is.displayName=Fs;var Ls=`SelectContent`,Rs=Q.forwardRef((e,t)=>{let n=Ts(Ls,e.__scopeSelect),[r,i]=Q.useState();if(gr(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Io.createPortal((0,Z.jsx)(Bs,{scope:e.__scopeSelect,children:(0,Z.jsx)(vs.Slot,{scope:e.__scopeSelect,children:(0,Z.jsx)(`div`,{children:e.children})})}),t):null}return(0,Z.jsx)(Ws,{...e,ref:t})});Rs.displayName=Ls;var zs=10,[Bs,Vs]=xs(Ls),Hs=`SelectContentImpl`,Us=Lt(`SelectContent.RemoveScroll`),Ws=Q.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=Ts(Ls,n),[y,b]=Q.useState(null),[x,S]=Q.useState(null),C=It(t,e=>b(e)),[w,T]=Q.useState(null),[E,D]=Q.useState(null),O=ys(n),[k,A]=Q.useState(!1),j=Q.useRef(!1);Q.useEffect(()=>{if(y)return zr(y)},[y]),Nr();let M=Q.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=Q.useCallback(()=>M([w,y]),[M,w,y]);Q.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Q.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),Q.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[I,L]=Tc(e=>{let t=O().filter(e=>!e.disabled),n=Ec(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),R=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),ee=Q.useCallback(()=>y?.focus(),[y]),z=Q.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),te=r===`popper`?Js:Ks,ne=te===Js?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Z.jsx)(Bs,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:R,selectedItem:w,onItemLeave:ee,itemTextRefCallback:z,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,Z.jsx)(Ir,{as:Us,allowPinchZoom:!0,children:(0,Z.jsx)(Mr,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:ur(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Z.jsx)(pr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,Z.jsx)(te,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...ne,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:ur(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&L(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})});Ws.displayName=Hs;var Gs=`SelectItemAlignedPosition`,Ks=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Ts(Ls,n),o=Vs(Ls,n),[s,c]=Q.useState(null),[l,u]=Q.useState(null),d=It(t,e=>u(e)),f=ys(n),p=Q.useRef(!1),m=Q.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Q.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-zs,d=Lo(a,[zs,Math.max(zs,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-zs,d=Lo(a,[zs,Math.max(zs,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-zs*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-zs,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${zs}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);gr(()=>y(),[y]);let[b,x]=Q.useState();return gr(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Z.jsx)(Ys,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Q.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,Z.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,Z.jsx)(dr.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Ks.displayName=Gs;var qs=`SelectPopperPosition`,Js=Q.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=zs,...a}=e,o=Cs(n);return(0,Z.jsx)(Yr,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Js.displayName=qs;var[Ys,Xs]=xs(Ls,{}),Zs=`SelectViewport`,Qs=Q.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Vs(Zs,n),o=Xs(Zs,n),s=It(t,a.onViewportChange),c=Q.useRef(0);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,Z.jsx)(vs.Slot,{scope:n,children:(0,Z.jsx)(dr.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:ur(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-zs*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Qs.displayName=Zs;var $s=`SelectGroup`,[ec,tc]=xs($s),nc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=fr();return(0,Z.jsx)(ec,{scope:n,id:i,children:(0,Z.jsx)(dr.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});nc.displayName=$s;var rc=`SelectLabel`,ic=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=tc(rc,n);return(0,Z.jsx)(dr.div,{id:i.id,...r,ref:t})});ic.displayName=rc;var ac=`SelectItem`,[oc,sc]=xs(ac),cc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Ts(ac,n),c=Vs(ac,n),l=s.value===r,[u,d]=Q.useState(a??``),[f,p]=Q.useState(!1),m=It(t,e=>c.itemRefCallback?.(e,r,i)),h=fr(),g=Q.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,Z.jsx)(oc,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Q.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Z.jsx)(vs.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Z.jsx)(dr.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:ur(o.onFocus,()=>p(!0)),onBlur:ur(o.onBlur,()=>p(!1)),onClick:ur(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:ur(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:ur(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:ur(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ur(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:ur(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(gs.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});cc.displayName=ac;var lc=`SelectItemText`,uc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Ts(lc,n),s=Vs(lc,n),c=sc(lc,n),l=Ds(lc,n),[u,d]=Q.useState(null),f=It(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=Q.useMemo(()=>(0,Z.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return gr(()=>(h(m),()=>g(m)),[h,g,m]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(dr.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Io.createPortal(a.children,o.valueNode):null]})});uc.displayName=lc;var dc=`SelectItemIndicator`,fc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return sc(dc,n).isSelected?(0,Z.jsx)(dr.span,{"aria-hidden":!0,...r,ref:t}):null});fc.displayName=dc;var pc=`SelectScrollUpButton`,mc=Q.forwardRef((e,t)=>{let n=Vs(pc,e.__scopeSelect),r=Xs(pc,e.__scopeSelect),[i,a]=Q.useState(!1),o=It(t,r.onScrollButtonChange);return gr(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Z.jsx)(_c,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});mc.displayName=pc;var hc=`SelectScrollDownButton`,gc=Q.forwardRef((e,t)=>{let n=Vs(hc,e.__scopeSelect),r=Xs(hc,e.__scopeSelect),[i,a]=Q.useState(!1),o=It(t,r.onScrollButtonChange);return gr(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Z.jsx)(_c,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});gc.displayName=hc;var _c=Q.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Vs(`SelectScrollButton`,n),o=Q.useRef(null),s=ys(n),c=Q.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Q.useEffect(()=>()=>c(),[c]),gr(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Z.jsx)(dr.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:ur(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:ur(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:ur(i.onPointerLeave,()=>{c()})})}),vc=`SelectSeparator`,yc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Z.jsx)(dr.div,{"aria-hidden":!0,...r,ref:t})});yc.displayName=vc;var bc=`SelectArrow`,xc=Q.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Cs(n),a=Ts(bc,n),o=Vs(bc,n);return a.open&&o.position===`popper`?(0,Z.jsx)(qr,{...i,...r,ref:t}):null});xc.displayName=bc;var Sc=`SelectBubbleInput`,Cc=Q.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Q.useRef(null),a=It(r,i),o=Wr(t);return Q.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,Z.jsx)(dr.select,{...n,style:{...yr,...n.style},ref:a,defaultValue:t})});Cc.displayName=Sc;function wc(e){return e===``||e===void 0}function Tc(e){let t=hr(e),n=Q.useRef(``),r=Q.useRef(0),i=Q.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=Q.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Q.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Ec(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Dc(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Dc(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Oc=Os,kc=As,Ac=Ms,jc=Ps,Mc=Is,Nc=Rs,Pc=Qs,Fc=cc,Ic=uc,Lc=fc,Rc=mc,zc=gc,Bc=`Switch`,[Vc,Hc]=vr(Bc),[Uc,Wc]=Vc(Bc),Gc=Q.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=Q.useState(null),m=It(t,e=>p(e)),h=Q.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=mr({prop:i,defaultProp:a??!1,onChange:l,caller:Bc});return(0,Z.jsxs)(Uc,{scope:n,checked:_,disabled:s,children:[(0,Z.jsx)(dr.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":Xc(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:ur(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,Z.jsx)(Yc,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});Gc.displayName=Bc;var Kc=`SwitchThumb`,qc=Q.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=Wc(Kc,n);return(0,Z.jsx)(dr.span,{"data-state":Xc(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});qc.displayName=Kc;var Jc=`SwitchBubbleInput`,Yc=Q.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=Q.useRef(null),s=It(o,a),c=Wr(n),l=Jr(t);return Q.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,Z.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});Yc.displayName=Jc;function Xc(e){return e?`checked`:`unchecked`}var Zc=Gc,Qc=qc,$=a();function $c(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function el(e){if(e.kind===`create`){let t=e.value;return ai._({id:`XPqe3B`,values:{tagValue:t}})}let t=ai._({id:`pckX1A`,values:{0:e.count}}),n=e.value;return ai._({id:`m2T1Xj`,values:{tagValue:n,uses:t}})}function tl(e){let t=(0,$.c)(38),{items:n,query:r,selectedIndex:i,onSelect:a,onHover:c,loading:l,error:u}=e,d=l===void 0?!1:l,f=u===void 0?null:u,{_:p}=s(),m=(0,Q.useRef)(null),h=(0,Q.useId)(),g=i>=0&&i<n.length?`${h}-option-${i}`:void 0,_,v;t[0]===i?(_=t[1],v=t[2]):(_=()=>{let e=m.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(i);t&&t.scrollIntoView({block:`nearest`})},v=[i],t[0]=i,t[1]=_,t[2]=v),(0,Q.useEffect)(_,v);let y=nl;if(d){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:y,children:(0,Z.jsx)(o,{id:`a_u4ck`})}),t[4]=n):n=t[4],n}if(n.length===0){let e;if(t[5]!==p||t[6]!==f||t[7]!==r){let n=r.trim();e=f??p(n?{id:`9R7pRC`,values:{trimmed:n}}:{id:`KRJ6xh`}),t[5]=p,t[6]=f,t[7]=r,t[8]=e}else e=t[8];let n=e,i;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(i={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[9]=i):i=t[9];let a;return t[10]===n?a=t[11]:(a=(0,Z.jsx)(`div`,{ref:m,role:`status`,"aria-live":`polite`,className:`w-64 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:i,onMouseDown:y,children:n}),t[10]=n,t[11]=a),a}let b=i>=0&&i<n.length?n[i]:null,x;t[12]===p?x=t[13]:(x=p({id:`SCoBBH`}),t[12]=p,t[13]=x);let S;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[14]=S):S=t[14];let C;t[15]===b?C=t[16]:(C=b?el(b):``,t[15]=b,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:C}),t[17]=C,t[18]=w);let T;t[19]===f?T=t[20]:(T=f&&(0,Z.jsx)(`div`,{className:`rounded-md px-2 py-1.5 text-xs text-amber-700 dark:text-amber-300`,children:f}),t[19]=f,t[20]=T);let E;if(t[21]!==n||t[22]!==h||t[23]!==c||t[24]!==a||t[25]!==i){let e;t[27]!==h||t[28]!==c||t[29]!==a||t[30]!==i?(e=(e,t)=>{let n=t===i,r=$c(e),s=e.kind===`create`;return(0,Z.jsxs)(`button`,{id:`${h}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,"data-testid":s?`tag-suggestion-create`:`tag-suggestion-tag-${e.value}`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseDown:t=>{t.preventDefault(),a(e)},onPointerMove:c?()=>c(t):void 0,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`#`}),(0,Z.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.value}),s?(0,Z.jsx)(`span`,{className:`shrink-0 rounded-sm bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary`,children:(0,Z.jsx)(o,{id:`isRobC`})}):(0,Z.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:e.count})]},r)},t[27]=h,t[28]=c,t[29]=a,t[30]=i,t[31]=e):e=t[31],E=n.map(e),t[21]=n,t[22]=h,t[23]=c,t[24]=a,t[25]=i,t[26]=E}else E=t[26];let D;return t[32]!==g||t[33]!==E||t[34]!==x||t[35]!==w||t[36]!==T?(D=(0,Z.jsxs)(`div`,{ref:m,role:`listbox`,"aria-label":x,"aria-activedescendant":g,tabIndex:-1,onMouseDown:y,className:`w-64 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,style:S,children:[w,T,E]}),t[32]=g,t[33]=E,t[34]=x,t[35]=w,t[36]=T,t[37]=D):D=t[37],D}function nl(e){return e.preventDefault()}var rl=new ke(`tagSuggestion`),il=8,al=/^[a-zA-Z][\w/-]*$/;async function ol(){let e=await fetch(`/api/tags`);if(!e.ok)throw Error(`/api/tags responded with ${e.status}`);let t=await e.json();return Array.isArray(t.tags)?t.tags:[]}function sl(e,t){let n=t.trim(),r=n.toLowerCase(),i=n===``?e.slice():e.filter(e=>e.name.toLowerCase().includes(r));return i.sort((e,t)=>{let n=+!e.name.toLowerCase().startsWith(r),i=+!t.name.toLowerCase().startsWith(r);return n===i?t.count===e.count?e.name.localeCompare(t.name):t.count-e.count:n-i}),i}function cl(e,t){let n=sl(e,t).slice(0,il).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&al.test(r)&&!e.some(e=>e.name===r)&&n.push({kind:`create`,value:r}),n}function ll(e){let{$position:t}=e,n=t.parent.textBetween(0,t.parentOffset,void 0,``).match(/(^|[\s])#([a-zA-Z][\w/-]*)?$/);if(!n)return null;let r=n[2]??``,i=t.start(),a=n[1].length;return{range:{from:i+((n.index??0)+a),to:t.pos},query:r,text:`#${r}`}}function ul(e){let t=[],n=!1,r=null,i=null;return Vt({editor:e,pluginKey:rl,char:`#`,allowedPrefixes:null,findSuggestionMatch:ll,allow:({editor:e})=>!ln(e),items:async({query:e})=>{if(!n){r||=ol();try{t=await r,i=null}catch(e){console.error(`[tag-suggestion] Failed to fetch tags:`,e),i=`Failed to load tags. Press Escape and type # again to retry, or continue typing to create a new tag.`,t=[]}finally{n=!0,r=null}}return cl(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!al.test(r))return;e.chain().focus().deleteRange(t).insertContent({type:`tag`,attrs:{value:r}}).insertContent(` `).run()}catch(e){console.error(`[tag-suggestion] command failed`,{item:n,range:t},e)}},render:()=>{let e=null,a=null,o=0,s={popup:null,stopAutoUpdate:null},c=null,l=null,u=e=>{a?.command(e)},d=e=>{o!==e&&(o=e,p(null))};function f(e,t,r){let a=t===null?!n:t;return{items:e.items,query:e.query??``,selectedIndex:o,onSelect:r,onHover:d,loading:a,error:i}}let p=t=>{!e||!a||e.updateProps(f(a,t,u))};return{onBeforeStart(t){a=t,o=0;let n=cn(()=>a,`tag-suggestion`);s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new dn(tl,{props:f(t,!0,u),editor:t.editor}),n.popup.appendChild(e.element),s.stopAutoUpdate=n.startAutoUpdate()},onStart(e){a=e,o=0,p(null),l?.()},onUpdate(e){a=e,o=Math.min(o,Math.max(0,e.items.length-1)),p(null),c?.()},onKeyDown({event:e}){if(!a)return!1;let t=a.items;if(e.key===`ArrowDown`)return t.length===0?!1:(o=(o+1)%t.length,p(null),!0);if(e.key===`ArrowUp`)return t.length===0?!1:(o=(o-1+t.length)%t.length,p(null),!0);if(e.key===`Enter`||e.key===`Tab`){let e=t[o];if(e)return a.command(e),!0;let n=(a.query??``).trim();return n&&al.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){sn(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var dl=new Map([[tr,`<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>`],[Tn,`<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/>`],[gn,`<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>`],[gn,`<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>`],[eo,`<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/>`],[kn,`<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/>`],[hn,`<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/><path d="M19.364 18.364a9 9 0 0 0 0-12.728"/>`],[cr,`<path d="M18 6 6 18"/><path d="m6 6 12 12"/>`]]),fl=new Map;function pl(e){let t=fl.get(e);if(t!==void 0)return t;let n=`<svg xmlns="http://www.w3.org/2000/svg" width="0.75rem" height="0.75rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${dl.get(e)??dl.get(Tn)}</svg>`;return fl.set(e,n),n}var ml=`0 0 32 32`,hl=`M26.7075 10.2925L19.7075 3.2925C19.6146 3.19967 19.5042 3.12605 19.3829 3.07586C19.2615 3.02568 19.1314 2.9999 19 3H7C6.46957 3 5.96086 3.21071 5.58579 3.58579C5.21071 3.96086 5 4.46957 5 5V14C5 14.2652 5.10536 14.5196 5.29289 14.7071C5.48043 14.8946 5.73478 15 6 15C6.26522 15 6.51957 14.8946 6.70711 14.7071C6.89464 14.5196 7 14.2652 7 14V5H18V11C18 11.2652 18.1054 11.5196 18.2929 11.7071C18.4804 11.8946 18.7348 12 19 12H25V28C25 28.2652 25.1054 28.5196 25.2929 28.7071C25.4804 28.8946 25.7348 29 26 29C26.2652 29 26.5196 28.8946 26.7071 28.7071C26.8946 28.5196 27 28.2652 27 28V11C27.0001 10.8686 26.9743 10.7385 26.9241 10.6172C26.8739 10.4958 26.8003 10.3854 26.7075 10.2925ZM20 6.41375L23.5863 10H20V6.41375ZM18 18H16C15.7348 18 15.4804 18.1054 15.2929 18.2929C15.1054 18.4804 15 18.7348 15 19V26C15 26.2652 15.1054 26.5196 15.2929 26.7071C15.4804 26.8946 15.7348 27 16 27H18C19.1935 27 20.3381 26.5259 21.182 25.682C22.0259 24.8381 22.5 23.6935 22.5 22.5C22.5 21.3065 22.0259 20.1619 21.182 19.318C20.3381 18.4741 19.1935 18 18 18ZM18 25H17V20H18C18.663 20 19.2989 20.2634 19.7678 20.7322C20.2366 21.2011 20.5 21.837 20.5 22.5C20.5 23.163 20.2366 23.7989 19.7678 24.2678C19.2989 24.7366 18.663 25 18 25ZM13 19V26C13 26.2652 12.8946 26.5196 12.7071 26.7071C12.5196 26.8946 12.2652 27 12 27C11.7348 27 11.4804 26.8946 11.2929 26.7071C11.1054 26.5196 11 26.2652 11 26V22.1725L9.31875 24.5737C9.22652 24.7053 9.10396 24.8126 8.96144 24.8868C8.81892 24.9609 8.66064 24.9996 8.5 24.9996C8.33936 24.9996 8.18108 24.9609 8.03856 24.8868C7.89604 24.8126 7.77348 24.7053 7.68125 24.5737L6 22.1725V26C6 26.2652 5.89464 26.5196 5.70711 26.7071C5.51957 26.8946 5.26522 27 5 27C4.73478 27 4.48043 26.8946 4.29289 26.7071C4.10536 26.5196 4 26.2652 4 26V19C4.00009 18.7874 4.06791 18.5804 4.19363 18.409C4.31935 18.2376 4.49642 18.1107 4.69915 18.0467C4.90188 17.9828 5.11971 17.9851 5.32104 18.0533C5.52236 18.1216 5.6967 18.2522 5.81875 18.4263L8.5 22.2563L11.1812 18.4263C11.3033 18.2522 11.4776 18.1216 11.679 18.0533C11.8803 17.9851 12.0981 17.9828 12.3008 18.0467C12.5036 18.1107 12.6807 18.2376 12.8064 18.409C12.9321 18.5804 12.9999 18.7874 13 19Z`;function gl(e){return e===`.md`||e===`.mdx`}function _l(e){switch(pe(e)){case`image`:return pl(gn);case`video`:return pl(kn);case`audio`:return pl(hn);default:return pl(eo)}}function vl(e){let t=(0,$.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`path`,{d:hl}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,Z.jsx)(`svg`,{"aria-hidden":`true`,className:n,fill:`currentColor`,viewBox:ml,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function yl(e){let t=oi(e).toLowerCase();return t?gl(t)?{kind:`file`,path:e}:{kind:`file`,path:e,bodyIndexed:!1}:{kind:`folder`,path:e}}function bl(e){let t=(0,$.c)(6),{path:n,className:r,showExtensionBadge:i}=e,a;t[0]===n?a=t[1]:(a=yl(n),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsx)(Sl,{...a,className:r,showExtensionBadge:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function xl(e){let{kind:t,bodyIndexed:n}=yl(e);if(t===`folder`)return pl(tr);let r=(n===!1?oi(e):oi(e)||`.md`).toLowerCase();return gl(r)?`<svg xmlns="http://www.w3.org/2000/svg" width="0.75rem" height="0.75rem" viewBox="${ml}" fill="currentColor" aria-hidden="true"><path d="${hl}"/></svg>`:_l(r)}function Sl(e){let t=(0,$.c)(25),{kind:n,path:r,docExt:i,bodyIndexed:a,className:o,showExtensionBadge:s}=e,c=s===void 0?!0:s;if(n===`folder`){let e;t[0]===o?e=t[1]:(e=Ft(`shrink-0`,o),t[0]=o,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,Z.jsx)(tr,{"aria-hidden":`true`,className:e,"data-file-entry-icon":`folder`}),t[2]=e,t[3]=n),n}let l;t[4]!==a||t[5]!==i||t[6]!==r?(l=a===!1?oi(r):i??(oi(r)||`.md`),t[4]=a,t[5]=i,t[6]=r,t[7]=l):l=t[7];let u=l,d,f,p,m;if(t[8]!==o||t[9]!==u||t[10]!==c){let e=u.toLowerCase(),n=pe(e);d=c&&u&&e!==`.md`?u.slice(1).toUpperCase():null;let r=n===`image`&&`text-rose-500`,i;t[15]!==o||t[16]!==r?(i=Ft(o,r),t[15]=o,t[16]=r,t[17]=i):i=t[17];let a=i;f=`relative inline-flex shrink-0`,p=e||`file`,m=gl(e)?(0,Z.jsx)(vl,{className:a,"data-testid":`file-entry-icon-markdown`}):n===`image`?(0,Z.jsx)(gn,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-image`}):n===`video`?(0,Z.jsx)(kn,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-video`}):n===`audio`?(0,Z.jsx)(hn,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-audio`}):(0,Z.jsx)(eo,{"aria-hidden":`true`,className:a,"data-testid":`file-entry-icon-file`}),t[8]=o,t[9]=u,t[10]=c,t[11]=d,t[12]=f,t[13]=p,t[14]=m}else d=t[11],f=t[12],p=t[13],m=t[14];let h;t[18]===d?h=t[19]:(h=d?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`-right-1 -bottom-1 absolute rounded-sm bg-background px-0.5 font-medium text-[0.5rem] text-muted-foreground leading-none`,"data-testid":`file-entry-extension-badge`,children:d}):null,t[18]=d,t[19]=h);let g;return t[20]!==f||t[21]!==p||t[22]!==m||t[23]!==h?(g=(0,Z.jsxs)(`span`,{className:f,"data-file-entry-icon":p,children:[m,h]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h,t[24]=g):g=t[24],g}var Cl=Rt(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3! font-mono uppercase`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,warning:`bg-yellow-500/10 text-yellow-600 [a]:hover:bg-yellow-500/20`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`,dashed:`border-dashed border-border text-muted-foreground rounded-sm`,primary:`border border-primary/50 text-primary bg-primary/5 rounded-sm p-0.5 px-1.5 font-mono`,gray:`border border-border text-muted-foreground bg-muted rounded-sm p-0.5 px-1.5 font-mono`}},defaultVariants:{variant:`default`}});function wl(e){let t=(0,$.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,variant:i,asChild:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a!==void 0&&a?Nt:`span`,c;t[5]!==n||t[6]!==o?(c=Ft(Cl({variant:o}),n),t[5]=n,t[6]=o,t[7]=c):c=t[7];let l;return t[8]!==s||t[9]!==r||t[10]!==c||t[11]!==o?(l=(0,Z.jsx)(s,{"data-slot":`badge`,"data-variant":o,className:c,...r}),t[8]=s,t[9]=r,t[10]=c,t[11]=o,t[12]=l):l=t[12],l}var Tl=1,El=.9,Dl=.8,Ol=.17,kl=.1,Al=.999,jl=.9999,Ml=.99,Nl=/[\\\/_+.#"@\[\(\{&]/,Pl=/[\\\/_+.#"@\[\(\{&]/g,Fl=/[\s-]/,Il=/[\s-]/g;function Ll(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Tl:Ml;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=Ll(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Tl:Nl.test(e.charAt(l-1))?(d*=Dl,p=e.slice(i,l-1).match(Pl),p&&i>0&&(d*=Al**+p.length)):Fl.test(e.charAt(l-1))?(d*=El,m=e.slice(i,l-1).match(Il),m&&i>0&&(d*=Al**+m.length)):(d*=Ol,i>0&&(d*=Al**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=jl)),(d<kl&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Ll(e,t,n,r,l+1,a+2,o),f*kl>d&&(d=f*kl)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Rl(e){return e.toLowerCase().replace(Il,` `)}function zl(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Ll(e,t,Rl(e),Rl(t),0,0,{})}var Bl=`[cmdk-group=""]`,Vl=`[cmdk-group-items=""]`,Hl=`[cmdk-group-heading=""]`,Ul=`[cmdk-item=""]`,Wl=`${Ul}:not([aria-disabled="true"])`,Gl=`cmdk-item-select`,Kl=`data-value`,ql=(e,t,n)=>zl(e,t,n),Jl=Q.createContext(void 0),Yl=()=>Q.useContext(Jl),Xl=Q.createContext(void 0),Zl=()=>Q.useContext(Xl),Ql=Q.createContext(void 0),$l=Q.forwardRef((e,t)=>{let n=pu(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=pu(()=>new Set),i=pu(()=>new Map),a=pu(()=>new Map),o=pu(()=>new Set),s=du(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=fr(),y=fr(),b=fr(),x=Q.useRef(null),S=gu();fu(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),fu(()=>{S(6,k)},[]);let C=Q.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Q.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??ql;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Vl);t?t.appendChild(e.parentElement===t?e:e.closest(`${Vl} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Vl} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${Bl}[${Kl}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Kl);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(Bl)?.querySelector(Hl))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Ul}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Wl)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Kl))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Kl))}function P(e){let t=A()?.closest(Bl),n;for(;t&&!n;)t=e>0?lu(t,Bl):uu(t,Bl),n=t?.querySelector(Wl);n?C.setState(`value`,n.getAttribute(Kl)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Q.createElement(dr.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Gl);t.dispatchEvent(e)}}}}},Q.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:yu},c),vu(e,e=>Q.createElement(Xl.Provider,{value:C},Q.createElement(Jl.Provider,{value:w},e))))}),eu=Q.forwardRef((e,t)=>{let n=fr(),r=Q.useRef(null),i=Q.useContext(Ql),a=Yl(),o=du(e),s=o.current?.forceMount??i?.forceMount;fu(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=hu(n,r,[e.value,e.children,r],e.keywords),l=Zl(),u=mu(e=>e.value&&e.value===c.current),d=mu(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Q.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Gl,f),()=>t.removeEventListener(Gl,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Q.createElement(dr.div,{ref:Pt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),tu=Q.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=fr(),s=Q.useRef(null),c=Q.useRef(null),l=fr(),u=Yl(),d=mu(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);fu(()=>u.group(o),[]),hu(o,s,[e.value,e.heading,c]);let f=Q.useMemo(()=>({id:o,forceMount:i}),[i]);return Q.createElement(dr.div,{ref:Pt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Q.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),vu(e,e=>Q.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Q.createElement(Ql.Provider,{value:f},e))))}),nu=Q.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Q.useRef(null),a=mu(e=>!e.search);return!n&&!a?null:Q.createElement(dr.div,{ref:Pt(i,t),...r,"cmdk-separator":``,role:`separator`})}),ru=Q.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Zl(),o=mu(e=>e.search),s=mu(e=>e.selectedItemId),c=Yl();return Q.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Q.createElement(dr.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),iu=Q.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Q.useRef(null),o=Q.useRef(null),s=mu(e=>e.selectedItemId),c=Yl();return Q.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Q.createElement(dr.div,{ref:Pt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},vu(e,e=>Q.createElement(`div`,{ref:Pt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),au=Q.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Q.createElement(jr,{open:n,onOpenChange:r},Q.createElement(Ar,{container:o},Q.createElement(Ur,{"cmdk-overlay":``,className:i}),Q.createElement(Fr,{"aria-label":e.label,"cmdk-dialog":``,className:a},Q.createElement($l,{ref:t,...s}))))}),ou=Q.forwardRef((e,t)=>mu(e=>e.filtered.count===0)?Q.createElement(dr.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),su=Q.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Q.createElement(dr.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},vu(e,e=>Q.createElement(`div`,{"aria-hidden":!0},e)))}),cu=Object.assign($l,{List:iu,Item:eu,Input:ru,Group:tu,Separator:nu,Dialog:au,Empty:ou,Loading:su});function lu(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function uu(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function du(e){let t=Q.useRef(e);return fu(()=>{t.current=e}),t}var fu=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function pu(e){let t=Q.useRef();return t.current===void 0&&(t.current=e()),t}function mu(e){let t=Zl(),n=()=>e(t.snapshot());return Q.useSyncExternalStore(t.subscribe,n,n)}function hu(e,t,n,r=[]){let i=Q.useRef(),a=Yl();return fu(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Kl,s),i.current=s}),i}var gu=()=>{let[e,t]=Q.useState(),n=pu(()=>new Map);return fu(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function _u(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function vu({asChild:e,children:t},n){return e&&Q.isValidElement(t)?Q.cloneElement(_u(t),{ref:t.ref},n(t.props.children)):n(t)}var yu={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function bu(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(cu,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xu(e){let t=(0,$.c)(36),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({title:s,description:c,children:n,className:r,showCloseButton:l,commandProps:i,onEscapeKeyDown:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=s===void 0?`Command Palette`:s,d=c===void 0?`Search for a command to run`:c,f=l===void 0?!0:l,p;t[9]===i?p=t[10]:(p=i??{},t[9]=i,t[10]=p);let m,h;t[11]===p?(m=t[12],h=t[13]):({className:m,...h}=p,t[11]=p,t[12]=m,t[13]=h);let g;t[14]===r?g=t[15]:(g=Ft(`top-[12vh] translate-y-0 overflow-hidden p-0`,r),t[14]=r,t[15]=g);let _;t[16]===u?_=t[17]:(_=(0,Z.jsx)(kr,{className:`sr-only`,children:u}),t[16]=u,t[17]=_);let v;t[18]===d?v=t[19]:(v=(0,Z.jsx)(Or,{className:`sr-only`,children:d}),t[18]=d,t[19]=v);let y;t[20]===m?y=t[21]:(y=Ft(`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,m),t[20]=m,t[21]=y);let b;t[22]!==n||t[23]!==h||t[24]!==y?(b=(0,Z.jsx)(bu,{className:y,...h,children:n}),t[22]=n,t[23]=h,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==a||t[27]!==f||t[28]!==g||t[29]!==_||t[30]!==v||t[31]!==b?(x=(0,Z.jsxs)(Pr,{className:g,showCloseButton:f,onEscapeKeyDown:a,children:[_,v,b]}),t[26]=a,t[27]=f,t[28]=g,t[29]=_,t[30]=v,t[31]=b,t[32]=x):x=t[32];let S;return t[33]!==o||t[34]!==x?(S=(0,Z.jsx)(Hr,{...o,children:x}),t[33]=o,t[34]=x,t[35]=S):S=t[35],S}function Su(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(wo,{className:`size-4 shrink-0 opacity-50`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=Ft(`flex w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a?(o=(0,Z.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex items-center gap-2 border-b px-3`,children:[i,(0,Z.jsx)(cu.Input,{"data-slot":`command-input`,className:a,...r})]}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Cu(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(cu.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function wu(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(cu.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),t[0]=e,t[1]=n),n}function Tu(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-mono [&_[cmdk-group-heading]]:uppercase **:[[cmdk-group-heading]]:tracking-wider`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(cu.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Eu(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(cu.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Du(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`ml-auto text-muted-foreground text-xs tracking-widest`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`span`,{"data-slot":`command-shortcut`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ou(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(us,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function ku(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(fs,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function Au(e){let t=(0,$.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,align:i,sideOffset:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`center`:i,s=a===void 0?4:a,c;t[5]===n?c=t[6]:(c=Ft(`z-50 w-72 rounded-lg border bg-popover p-4 text-popover-foreground shadow-md outline-hidden origin-(--radix-popover-content-transform-origin) duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0`,n),t[5]=n,t[6]=c);let l;return t[7]!==o||t[8]!==r||t[9]!==s||t[10]!==c?(l=(0,Z.jsx)(ps,{children:(0,Z.jsx)(ms,{"data-slot":`popover-content`,align:o,sideOffset:s,className:c,...r})}),t[7]=o,t[8]=r,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function ju(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(ds,{"data-slot":`popover-anchor`,...n}),t[2]=n,t[3]=r),r}async function Mu(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}if(r instanceof Error&&r.name===`AbortError`)throw r;if(e.ok)return r!==void 0&&console.warn(`[parse-server-response] 2xx response with non-JSON body:`,r instanceof Error?r.message:String(r)),{ok:!0,body:r===void 0?n:null};if(r!==void 0){let t=r instanceof Error?r.message:String(r);return{ok:!1,title:`Server error (HTTP ${e.status}): ${t}`}}return{ok:!1,title:ii(n)??t}}function Nu(e,t,n,r){let i=e.safeParse(t);return i.success?i.data:(console.warn(`[parse-server-response] schema drift:`,n,`bodyShape=`,typeof t==`object`&&t?Object.keys(t):typeof t,`issues=`,i.error.issues),r)}var Pu=new Map,Fu=null;function Iu(){return fi(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function Lu(){if(Fu!==null)return;let e=Math.max(50,Math.floor(Iu()/2));Fu=setTimeout(()=>{Fu=null,Ru(Date.now()),Pu.size>0&&Lu()},e)}function Ru(e){let t=Iu();for(let[n,r]of Pu)e-r.emittedAt>=t&&(Pu.delete(n),X.count(`ok/sidebar/prewarm`,{hit:!1}))}function zu(e,t,n=Date.now()){Pu.has(e)&&X.count(`ok/sidebar/prewarm`,{hit:!1}),Pu.set(e,{poolEventId:t,emittedAt:n}),Lu()}function Bu(e,t,n=Date.now()){let r=Pu.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=Iu()?!1:(Pu.delete(e),X(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),X.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}ve({event:P(`ok-branch-switched-clear-failed`),branch:ge(),docName:ge(),reason:ge()});async function Vu(e,t){let n=[];for(let[r,i]of e.entries)i.kind===`active`&&i.persistence!==null&&n.push(i.persistence.clearData().catch(e=>{let n={event:`ok-branch-switched-clear-failed`,docName:r,branch:t,reason:e instanceof Error?e.message:String(e)};console.warn(JSON.stringify(n))}));await Promise.all(n),e.clearBufferedUpdates(),e.recycleAllEntries()}function Hu(e){let t=!1;return()=>{t?e():t=!0}}function Uu(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Wu(e,t=``){let n;try{n=await fetch(`${t}/api/server-info`,{signal:AbortSignal.timeout(5e3)})}catch{return}if(!n.ok)return;let r;try{r=await n.json()}catch{return}let i=Ge.safeParse(r);if(!i.success){console.warn(JSON.stringify({event:`ok-server-info-schema-mismatch`,issues:i.error.issues}));return}if(e.setExpectedServerInstanceId(i.data.serverInstanceId),ca(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&(Vu(e,i.data.currentBranch),di(i.data.currentBranch)),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=Uu(n)}catch{}e.observeDiskAckBatch(t)}}async function Gu(e){let t;try{t=await fetch(`/api/config`,{signal:e,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return{status:`error`,code:`network`}}if(t.status===404||t.status===501)return{status:`absent`};if(!t.ok)return{status:`error`,code:t.status};let n;try{n=await t.json()}catch{return{status:`error`,code:`invalid-body`}}if(typeof n!=`object`||!n||Array.isArray(n))return{status:`error`,code:`invalid-body`};let r=n;return{status:`ok`,config:{collabUrl:typeof r.collabUrl==`string`?r.collabUrl:null,previewUrl:typeof r.previewUrl==`string`?r.previewUrl:null,port:typeof r.port==`number`?r.port:0,singleFile:r.singleFile===!0}}}function Ku(e){return ed(e,gt)}function qu(e){return ed(e,Re)}function Ju(e){return ed(e,pt)}function Yu(e){return ed(e,$e)}function Xu(e){return ed(e,je)}function Zu(e){let t=ed(e,Pe);if(!t)return null;try{return{docName:t.docName,sv:Qu(t.sv)}}catch{return null}}function Qu(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function $u(e,t){let n=qu(e);if(n){t.onServerInfo?.(n);return}let r=Ju(e);if(r){t.onBranchSwitched?.(r);return}let i=Zu(e);if(i){t.onDiskAck?.(i);return}let a=Ku(e);if(a){t.onDerivedView?.(a);return}let o=Yu(e);if(o){t.onConfigValidationRejected?.(o);return}let s=Xu(e);if(s){t.onConfigIgnoreNestedError?.(s);return}t.onUnknown?.(e)}function ed(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function td(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function nd(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function rd(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var id=2e3,ad=15e3;function od(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??id,r=e.maxDelayMs??ad,i=e.log??{info:console.info,warn:console.warn},a=new AbortController,o=null,s=n,c=0,l=!1,u=!1,d=null,f=e.now(),p=async()=>{c+=1;let n=null;try{let t=await e.fetchConfig(a.signal);t.status===`absent`?(n=e.fallbackUrl(),d=null):t.status===`ok`&&t.config.collabUrl!==null?(n=t.config.collabUrl,d=null):t.status===`ok`?(u||(u=!0,i.info(`[collab-url] ok ui responded but server.lock has no port yet — retrying`)),d={kind:`null-collab`}):t.status===`error`&&(i.warn(`[collab-url] /api/config error (${t.code}) — retrying in ${s}ms`),d={kind:`error`,code:t.code})}catch(e){if(e.name===`AbortError`)return;d={kind:`error`,code:`network`}}if(!l){if(n!==null){e.onStateChange({collabUrl:n,attempts:c,terminal:!1,lastError:null});return}if(e.now()-f>=t){e.onStateChange({collabUrl:null,attempts:c,terminal:!0,lastError:d});return}e.onStateChange({collabUrl:null,attempts:c,terminal:!1,lastError:d}),o=e.setTimeout(()=>{p()},s),s=Math.min(s*2,r)}};return p(),{cancel:()=>{l=!0,a.abort(),o!==null&&(e.clearTimeout(o),o=null)}}}function sd(){let e=(0,$.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,Q.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,Q.useRef)(i),[o,s]=(0,Q.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=nd(window);if(t){r(rd(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(rd(t))});return()=>{n()}}let n=od({fetchConfig:Gu,fallbackUrl:td,now:Date.now,setTimeout:dd,clearTimeout:ud,onStateChange:t=>{e===a.current.token&&r(t)}});return()=>{n.cancel()}},e[2]=c):c=e[2];let l;e[3]===o?l=e[4]:(l=[o],e[3]=o,e[4]=l),(0,Q.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(ld),s(cd)},e[5]=u):u=e[5];let d=u,f;return e[6]===n?f=e[7]:(f={...n,retry:d},e[6]=n,e[7]=f),f}function cd(e){return e+1}function ld(e){return{...e,terminal:!1,lastError:null}}function ud(e){return globalThis.clearTimeout(e)}function dd(e,t){return globalThis.setTimeout(e,t)}var fd=new Map,pd=new Set;function md(){for(let e of pd)e()}function hd(e,t){fd.set(e,t),md()}function gd(e,t){fd.get(e)===t&&(fd.delete(e),md())}function _d(e){return fd.get(e)??null}function vd(e){return pd.add(e),()=>pd.delete(e)}var yd=/[\uD800-\uDBFF]/,bd=/[\uDC00-\uDFFF]/,xd=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&yd.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&bd.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},Sd=(e,t)=>e>>>t|e<<32-t,Cd=e=>Sd(e,2)^Sd(e,13)^Sd(e,22),wd=e=>Sd(e,6)^Sd(e,11)^Sd(e,25),Td=e=>Sd(e,7)^Sd(e,18)^e>>>3,Ed=e=>Sd(e,17)^Sd(e,19)^e>>>10,Dd=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]),Od=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),kd=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Od),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=Ed(t[e-2])+t[e-7]+Td(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+wd(o)+(o&s^~o&c)+Dd[e]+t[e]>>>0,d=Cd(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/Si,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},Ad=e=>new kd().digest(e),jd=new ke(`y-sync`),Md=new ke(`y-undo`),Nd=new ke(`yjs-cursor`),Pd=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},Fd=e=>Vi(Pd(Ad(Bi(e)))),Id=()=>({mapping:new Map,isOMark:new Map}),Ld=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!na(t.ds,e.id),Rd=[{light:`#ecd44433`,dark:`#ecd444`}],zd=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=fa();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Ui(t))}return e.get(n)},Bd=(e,{colors:t=Rd,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new Wd(e,a),c=new Et({props:{editable:e=>{let t=jd.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:jd,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(jd);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&Li(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=Md.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},jd)})}},destroy:()=>{s.destroy()}})});return c},Vd=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new Ce(e.doc));else if(t.type===`node`){let r=bf(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Hd(e,r))}else{let r=bf(n.doc,n.type,t.anchor,n.mapping),i=bf(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(y.between(e.doc.resolve(r),e.doc.resolve(i)))}},Hd=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?bt.create(e.doc,t):y.near(n)},Ud=(e,t)=>({type:t.selection.jsonID,anchor:vf(t.selection.anchor,e.type,e.mapping),head:vf(t.selection.head,e.type,e.mapping)}),Wd=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=Jt(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Ud(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta(`addToHistory`,!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Oi&&this._domSelectionInView===null&&(Li(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=ba.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=zi(va(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(jd,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>Kd(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(x.from(e),0,0));t.setMeta(jd,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>Kd(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(x.from(t),0,0));if(e){let t=ma(Zi(e.anchor,0),n.doc.content.size),r=ma(Zi(e.head,0),n.doc.content.size);n.setSelection(y.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(jd,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=Di(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&Ii(),r=new ia({gc:!1}),ga(r,t),t=Di(r),ga(r,e),e=Di(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[ra(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{Pi(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:zd(n.colorMapping,n.colors,r)}},s=Mi(i,new Qi(t.ds,e.sv)).map(n=>!n._item.deleted||Ld(n._item,e)||Ld(n._item,t)?Kd(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(x.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(jd,{isChangeOrigin:!0}))},jd)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=jd.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);Pi(t,t.deleteSet,e=>{if(e.constructor===ha){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>Gd(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new V(x.from(n),0,0));Vd(r,this.beforeTransactionSelection,this),r=r.setMeta(jd,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof la}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{df(this.doc,this.type,e,this),this.beforeTransactionSelection=Ud(this,this.prosemirrorView.state)},jd)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.on(`afterAllTransactions`,this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off(`beforeAllTransactions`,this.beforeAllTransactions),this.doc.off(`afterAllTransactions`,this.afterAllTransactions))}},Gd=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof ea)return Kd(e,t,n,r,i,a);throw Wi()}return o},Kd=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof ea){let s=Gd(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof aa&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=qd(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):Mi(e,new Qi(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(Ld(e._item,r)?Ld(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=t.node(e.nodeName,s,o);return n.mapping.set(e,c),c}catch(r){console.warn(`[y-prosemirror] schema.node(`+e.nodeName+`) threw:`,String(r&&r.message||r));let i=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};if(t.nodes[e.nodeName]&&t.nodes[e.nodeName].spec&&t.nodes[e.nodeName].spec.inline)i.inline++;else if(i.block++,t.nodes.rawMdxFallback)try{let i=t.node(`rawMdxFallback`,{reason:String(r&&r.message||r)},[t.text(e.nodeName)]);return n.mapping.set(e,i),i}catch(e){console.warn(`[y-prosemirror] rawMdxFallback substitution also failed:`,String(e&&e.message||e))}return n.mapping.delete(e),null}},qd=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,lf(n.attributes,t)))}}catch(e){console.warn(`[y-prosemirror] schema.text() threw:`,String(e&&e.message||e));let t=globalThis.__okYpsCounters=globalThis.__okYpsCounters||{block:0,inline:0};return t.inline++,null}return o},Jd=(e,t)=>{let n=new $i,r=e.map(e=>({insert:e.text,attributes:uf(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},Yd=(e,t)=>{let n=new ea(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,$d(e).map(e=>Xd(e,t))),t.mapping.set(n,e),n},Xd=(e,t)=>e instanceof Array?Jd(e,t):Yd(e,t),Zd=e=>typeof e==`object`&&!!e,Qd=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===Object.keys(t).filter(e=>t[e]!==null).length;for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||Zd(o)&&Zd(s)&&Qd(o,s)}return r},$d=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},ef=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&ua(e.attributes||{}).length===t[n].marks.length&&ji(e.attributes,(e,r)=>{let i=cf(r),a=t[n].marks;return a.find(e=>e.type.name===i)?Qd(e,a.find(e=>e.type.name===i)?.attrs):!1}))},tf=(e,t)=>{if(e instanceof ea&&!(t instanceof Array)&&ff(e,t)){let n=$d(t);return e._length===n.length&&Qd(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>tf(e,n[t]))}return e instanceof $i&&t instanceof Array&&ef(e,t)},nf=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),rf=(e,t,n)=>{let r=e.toArray(),i=$d(t),a=i.length,o=r.length,s=ma(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(nf(n.mapping.get(e),t))u=!0;else if(!tf(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(nf(n.mapping.get(e),t))u=!0;else if(!tf(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},af=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof pa?t+=n.content.str:n.content instanceof sa&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},of=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=af(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,uf(e.marks,n))})),{insert:o,remove:s,index:c}=xd(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},sf=/(.*)(--[a-zA-Z0-9+/=]{8})$/,cf=e=>sf.exec(e)?.[1]??e,lf=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(cf(r),e[r]));return n},uf=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=qi(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${Fd(e.toJSON())}`:e.type.name]=e.attrs}}),n},df=(e,t,n,r)=>{if(t instanceof ea&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof ea){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=$d(n),a=i.length,o=t.toArray(),s=o.length,c=ma(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!nf(r.mapping.get(e),t))if(tf(e,t))r.mapping.set(e,t);else break}for(;u+l+1<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!nf(r.mapping.get(e),t))if(tf(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof $i&&c instanceof Array)ef(n,c)||of(n,c,r),l+=1;else{let i=n instanceof ea&&ff(n,c),a=d instanceof ea&&ff(d,f);if(i&&a){let e=rf(n,c,r),t=rf(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(df(e,n,c,r),l+=1):a?(df(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[Xd(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof $i?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(Xd(i[t],r));t.insert(l,e)}},jd)},ff=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,pf=null,mf=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=jd.getState(this.view.state);if(e&&e.binding&&!e.binding.isDestroyed){let e=this.view.state.tr;e.setMeta(this.key,this.value),this.view.dispatch(e)}}},hf=class e{constructor(e=[]){this.entries=e}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return this.entries.length===0}static fromViewsToUpdate(){let t=pf;pf=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new mf(t,r,e))})}),new e(n)}},gf=(e=hf.fromViewsToUpdate(),t=!1)=>{let n=!0;for(;!e.isEmpty();){let r=e.getFirst();try{r.apply()}catch(r){if(r instanceof RangeError){t&&n&&e.dequeueFirst(),e.isEmpty()||Li(0,()=>gf(e,!0));return}throw r}n=!1,e.dequeueFirst()}},_f=(e,t,n)=>{pf||(pf=new Map,Li(0,gf)),qi(pf,e,ta).set(t,n)},vf=(e,t,n)=>{if(e===0)return _a(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof $i){if(r._length>=e)return _a(r,e,-1);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new Xi(r._item===null?null:r._item.id,r._item===null?Ci(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new Xi(r._item===null?null:r._item.id,r._item===null?Ci(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw Ii();if(e===0&&r.constructor!==$i&&r!==t)return yf(r._item.parent,r._item)}return _a(t,t._length,-1)},yf=(e,t)=>{let n=null,r=null;return e._item===null?r=Ci(e):n=Ri(e._item.id.client,e._item.id.clock),new Xi(n,r,t.id)},bf=(e,t,n,r)=>{let i=Ji(n,e);if(i===null||i.type!==t&&!Ni(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===$i)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;t++,n instanceof $i?o+=n._length:o+=r.get(n).nodeSize}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;t.deleted||(e instanceof $i?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},xf=(e,t)=>{let n=Id(),r=e.toArray().map(e=>Kd(e,t,n)).filter(e=>e!==null);return{doc:t.topNodeType.create(null,x.fromArray(r)),meta:n,mapping:n.mapping}},Sf=(e,t,n)=>e!==t,Cf=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(`⁠`),i=document.createTextNode(`⁠`);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},wf=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),Tf=/^#[0-9a-fA-F]{6}$/,Ef=(e,t,n,r,i)=>{let a=jd.getState(e);if(a==null||a.doc==null||a.binding==null)return Ue.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?Ue.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:Tf.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=bf(o,a.type,wi(t.cursor.anchor),a.binding.mapping),u=bf(o,a.type,wi(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=Zi(e.doc.content.size-1,0);l=ma(l,t),u=ma(u,t),s.push(rt.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=ma(l,u),o=Zi(l,u);s.push(rt.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),Ue.create(e.doc,s))},Df=(e,{awarenessStateFilter:t=Sf,cursorBuilder:n=Cf,selectionBuilder:r=wf,getSelection:i=e=>e.selection}={},a=`cursor`)=>new Et({key:Nd,state:{init(i,a){return Ef(a,e,t,n,r)},apply(i,a,o,s){let c=jd.getState(s),l=i.getMeta(Nd);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?Ef(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>Nd.getState(e)},view:t=>{let n=()=>{t.docView&&_f(t,Nd,{awarenessUpdated:!0})},r=()=>{let n=jd.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=vf(o.anchor,n.type,n.binding.mapping),c=vf(o.head,n.type,n.binding.mapping);(r.cursor==null||!ya(wi(r.cursor.anchor),s)||!ya(wi(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&bf(n.doc,n.type,wi(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),Of=e=>{let t=Md.getState(e).undoManager;if(t!=null)return t.undo(),!0},kf=e=>{let t=Md.getState(e).undoManager;if(t!=null)return t.redo(),!0},Af=new Set([`paragraph`]),jf=(e,t)=>!(e instanceof ha)||!(e.content instanceof Yi)||!(e.content.type instanceof aa||e.content.type instanceof ea&&t.has(e.content.type.nodeName))||e.content.type._length===0,Mf=({protectedNodes:e=Af,trackedOrigins:t=[],undoManager:n=null}={})=>new Et({key:Md,state:{init:(r,i)=>{let a=jd.getState(i),o=n||new la(a.type,{trackedOrigins:new Set([jd].concat(t)),deleteFilter:t=>jf(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=jd.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:Ud(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=jd.getState(e.state),n=Md.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,Md.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}}),Nf=new Map;function Pf(e){return Nf.get(e)}function Ff(e,t){Nf.set(e,t)}function If(e){Nf.delete(e)}var Lf=`open-knowledge-app`,Rf=new Map,zf=new Set,Bf=1024,Vf=1024;function Hf(){return At.getTracer(Lf)}function Uf(e,t,n){if(zf.has(e))return null;let r=Rf.get(e);if(r)return r;if(Rf.size>=Vf){let e=Rf.keys().next().value;if(e!==void 0){let t=Rf.get(e);Rf.delete(e);try{t?.span.end()}catch(e){console.warn(`[otel-spans] eviction span.end failed:`,e instanceof Error?e:String(e))}}}let i={span:Hf().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return Rf.set(e,i),i}function Wf(e,t,n,r,i){try{let a=Uf(e,n,r),o=a?At.setSpan(jt.active(),a.span):jt.active();Hf().startSpan(t,{attributes:{"mount.id":e,...n},startTime:r},o).end(i??Date.now())}catch(e){console.warn(`[otel-spans] emitColdMountChild failed:`,e instanceof Error?e:String(e))}}function Gf(e,t){try{let n=Rf.get(e);if(n&&(Rf.delete(e),n.span.end(t??Date.now())),!zf.has(e)){if(zf.size>=Bf){let e=zf.values().next().value;e!==void 0&&zf.delete(e)}zf.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var Kf=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function qf(){return fi(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function Jf(e){e.stalledHandle!==null&&(clearTimeout(e.stalledHandle),e.stalledHandle=null)}function Yf(e,t,n){if(e.stalledMarkEmitted)return;e.stalledMarkEmitted=!0;let r=n-e.createdAt;X(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var Xf=new Map,Zf=new Set;function Qf(e){Zf.add(e);for(let[t,n]of Xf)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{Zf.delete(e)}}function $f(e,t){for(let n of Zf)try{n(e,t.mountId)}catch{}}var ep=!1;function tp(){typeof document>`u`||document.visibilityState===`visible`&&ip(Date.now())}function np(){ep||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,tp),ep=!0)}function rp(){ep&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,tp),ep=!1))}function ip(e){let t=qf();for(let[n,r]of Xf)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(Yf(r,n,e),$f(n,r))}function ap(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=Xf.get(t);if(a)return a.promise;let o=new AbortController,s=Date.now(),c=()=>{},l=()=>{},u=new Promise((e,t)=>{c=e,l=t}),d={promise:u,rejectFn:l,controller:o,mountId:n,createdAt:s,settled:!1,resolved:!1,preMountEditor:null,stalledHandle:null,stalledMarkEmitted:!1};return d.stalledHandle=setTimeout(()=>{d.settled||(Yf(d,t,Date.now()),$f(t,d))},qf()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,Jf(d),d.preMountEditor&&=(lp(t,d.preMountEditor,`aborted`),null),Xf.delete(t),Xf.size===0&&rp(),X(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),l(new Kf(t)),Gf(d.mountId))}),Xf.set(t,d),np(),X(`ok/mount/create`,{docName:t,mountId:d.mountId}),up({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:c,rejectFn:l}).catch(e=>{if(d.preMountEditor&&=(lp(t,d.preMountEditor,`backstop`),null),d.settled){X(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,Jf(d);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`,message:n.message}),l(n),Gf(d.mountId)}),u}function op(e){return Xf.get(e)?.resolved===!0}function sp(e){return Xf.get(e)?.controller??null}function cp(e){let t=Xf.get(e);t&&(t.settled=!0,Jf(t),t.preMountEditor&&=(lp(e,t.preMountEditor,`aborted`),null),Xf.delete(e),Xf.size===0&&rp(),X(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),Gf(t.mountId),t.controller.abort())}function lp(e,t,n){let r=dp(t);try{t.destroy()}catch(t){X(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function up(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(Gp(t)!==void 0){let e=kp({docName:t,container:s,factory:()=>{throw Error(`mount-promise: V2 cache contract violation — factory invoked on HIT for "${t}"`)}});i.settled=!0,i.resolved=!0,Jf(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,Jf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`,message:n.message}),o(n),Gf(i.mountId);return}if(i.preMountEditor=c.editor,await scheduler.yield(),i.controller.signal.aborted){i.preMountEditor=null;return}try{c.editor.mount(s)}catch(e){lp(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,Jf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`,message:n.message}),o(n),Gf(i.mountId);return}let l;try{l=kp({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){lp(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,Jf(i);let n=e instanceof Error?e:Error(String(e));X(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`,message:n.message}),o(n),Gf(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,Jf(i);let u=Date.now()-i.createdAt;X(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),X.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();Wf(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),Gf(i.mountId,d)}function dp(e){try{let t=e.state;return Md.getState(t)?.undoManager??null}catch(e){return X(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var fp=fi(`MAX_CACHE`,10),pp=fi(`VIEW_COUNT_CACHE_THRESHOLD`,50),mp=fi(`BYTES_CACHE_THRESHOLD`,8e6);function hp(e){return!(e.viewCount>0&&e.viewCount>=pp||e.bytes>mp)}var gp=new Map,_p=new Map,vp=new Map;function yp(e,t){if(vp.size>=fp){let e=vp.keys().next().value;e!==void 0&&vp.delete(e)}vp.set(e,t),X(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function bp(e){return vp.get(e)??null}function xp(e){if(!vp.has(e))return;let t=vp.get(e)??null;vp.delete(e),X(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function Sp(){try{return typeof document>`u`?0:document.querySelector(`[data-testid="editor-scroll-container"]`)?.scrollTop??0}catch(e){return X(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function Cp(e){try{let t=e.state.selection;return t instanceof y?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof bt?{type:`node`,from:t.from}:null}catch(e){return X(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function wp(e){for(let t of e)try{let e=Gp(t.fromDocName);if(e&&!e.editor.isDestroyed){if(e.ytext.length===0){X(`ok/cache/snapshot-skipped-empty`,{fromDocName:t.fromDocName});continue}yp(t.toDocName,{html:e.editor.getHTML(),scrollTop:Sp(),selection:Cp(e.editor)})}else X(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){X(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var Tp=[],Ep=[],Dp=new Set;function Op(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-parking`,``),e.style.display=`none`,e.style.position=`absolute`,e.style.left=`-99999px`,e}function kp(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!hp(i)){let e=r(n);return X(`ok/cache/miss`,{docName:t,mountId:Pf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`}),{editor:e.editor,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=gp.get(t);if(a){if(X(`ok/cache/reparent-start`,{docName:t,mountId:Pf(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Lp(a,n),a.activeMountKey=t,zp(Tp,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return X(`ok/cache/reparent-end`,{docName:t,mountId:Pf(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),X(`ok/cache/hit`,{docName:t,mountId:Pf(t),kind:`tiptap`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:Pf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;gp.size>=fp;){let e=Bp(Tp,t);if(!e)break;jp(e)}let o=r(n),s={editor:o.editor,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return gp.set(t,s),zp(Tp,t),X(`ok/cache/miss`,{docName:t,mountId:Pf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:Pf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function Ap(e){let t=e.activeMountKey;if(e.__uncached){t&&cp(t);let n=dp(e.editor);try{e.editor.destroy()}catch(e){X(`ok/cache/park-destroy-failed`,{docName:t??``,kind:`tiptap`,message:e instanceof Error?e.message:String(e)})}n&&(n.restore=void 0),e.activeMountKey=null;return}let n=Fp(e.editor);if(n){e.hadFocus=Ip(n.dom),e.scrollTop=(n.scrollDOM??n.dom.parentElement??n.dom).scrollTop??0;let t=n.dom.parentElement;t&&t.removeChild(n.dom),e.parkingNode||=Op(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function jp(e){cp(e);let t=gp.get(e);if(!t)return!1;let n=dp(t.editor);try{t.editor.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`editor`,message:t instanceof Error?t.message:String(t)})}n&&(n.restore=void 0);try{t.provider.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}gp.delete(e);let r=Tp.indexOf(e);return r!==-1&&Tp.splice(r,1),X(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function Mp(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!hp(i)){let e=r(n);return X(`ok/cache/miss`,{docName:t,mountId:Pf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,themeCompartment:e.themeCompartment,wordWrapCompartment:e.wordWrapCompartment,placeholderCompartment:e.placeholderCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=_p.get(t);if(a){if(X(`ok/cache/reparent-start`,{docName:t,mountId:Pf(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Rp(a,n),a.activeMountKey=t,zp(Ep,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return X(`ok/cache/reparent-end`,{docName:t,mountId:Pf(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),X(`ok/cache/hit`,{docName:t,mountId:Pf(t),kind:`cm`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:Pf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;_p.size>=fp;){let e=Bp(Ep,t);if(!e)break;Pp(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,themeCompartment:o.themeCompartment,wordWrapCompartment:o.wordWrapCompartment,placeholderCompartment:o.placeholderCompartment,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return _p.set(t,s),zp(Ep,t),X(`ok/cache/miss`,{docName:t,mountId:Pf(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&X(`ok/cold/editor-mount-stats`,{docName:t,mountId:Pf(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function Np(e){if(e.__uncached){try{e.view.destroy()}catch(t){X(`ok/cache/park-destroy-failed`,{docName:e.activeMountKey??``,kind:`cm`,message:t instanceof Error?t.message:String(t)})}e.activeMountKey=null;return}let t=e.view.dom;e.hadFocus=Ip(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=Op(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function Pp(e){let t=_p.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){X(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}_p.delete(e);let n=Ep.indexOf(e);return n!==-1&&Ep.splice(n,1),X(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function Fp(e){return e.editorView??null}function Ip(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function Lp(e,t){let n=Fp(e.editor);if(!n)return;let r=n.dom,i=r.parentElement;i&&i!==t&&i.removeChild(r),r.parentElement!==t&&t.appendChild(r)}function Rp(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function zp(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function Bp(e,t){for(let n of e)if(n!==t&&!Dp.has(n))return n;X(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:Dp.size});for(let n of e)if(n!==t)return n;return null}function Vp(e){let t=Dp,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=Up(e);if(t)try{t.disconnect(),X(`ok/cache/disconnect`,{docName:e})}catch(t){X(`ok/cache/disconnect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}}for(let e of n){if(t.has(e))continue;let n=Up(e);if(!n)continue;let r=t=>{X(`ok/cache/connect-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})};try{let t=n.connect();t&&typeof t.then==`function`?t.then(()=>X(`ok/cache/connect`,{docName:e}),e=>r(e)):X(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}Dp=n}var Hp=null;function Up(e){let t=gp.get(e);if(t)return t.provider;let n=_p.get(e);if(n)return n.provider;if(Hp){let t=Hp.entries.get(e);if(t)return t.provider}return null}function Wp(e){Hp=e;let t=e.onEvict(e=>{jp(e),Pp(e)});return()=>{t(),Hp===e&&(Hp=null)}}function Gp(e){return gp.get(e)}function Kp(e,t){let n=e.replace(/^\/+|\/+$/g,``);return`${E}${n?`${n}/`:``}${t}`}function qp(e,t){return`${Ve}/${e}/${t}`}function Jp(e){let t=`${Ve}/`;if(!e.startsWith(t)||!e.endsWith(`/SKILL`))return null;let n=e.slice(t.length,e.length-6);return n&&!n.includes(`/`)?n:null}function Yp(e){return I.includes(e)}var Xp=`ok-editor-tabs-v1:`,Zp=`\0folder:`,Qp=`\0asset:`,$p=`\0skill-file:`,em=`\0doc-tab:`,tm=/\.(md|mdx)$/i;function nm(e){let t=e.lastIndexOf(em);return t<0?{baseTabId:e,instanceSuffix:``}:{baseTabId:e.slice(0,t),instanceSuffix:e.slice(t)}}function rm(e){return nm(e).baseTabId}function im(e){return tm.test(e)?e.replace(tm,``):null}function am(e){if(typeof e!=`string`||e.length===0)return!1;let t=rm(e);return t.startsWith(Zp)?t.length>8:t.startsWith(Qp)?t.length>7:t.startsWith($p)?sm(t)!==null:!0}function om(e){return`${$p}${e.scope}/${e.name}/${e.path}`}function sm(e){if(!e.startsWith($p))return null;let t=e.slice(12).split(`/`);if(t.length<3)return null;let[n,r,...i]=t,a=i.join(`/`);return!n||!r||!a||!Yp(n)?null:{scope:n,name:r,path:a}}function cm(e){return e}function lm(e){return`${Zp}${e}`}function um(e){return`${Qp}${e}`}function dm(e,t){let n=Jp(e);if(n){let e=qn(n);return{baseName:e,extension:``,label:e,prefix:``}}let r=e.lastIndexOf(`/`),i=r<0?e:e.slice(r+1),a=tm.test(t)&&tm.test(i)?``:t,o=`${i}${a}`;return r<0?{baseName:i,extension:a,label:o,prefix:``}:{baseName:i,extension:a,label:o,prefix:`${e.slice(0,r)}/`}}function fm(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return cm(e.docName);case`folder`:return lm(e.folderPath);case`missing`:return cm(e.target);case`asset`:return um(e.assetPath);case`skill-file`:return om(e)}}function pm(e){let t=rm(e);if(t.startsWith(Zp))return{kind:`folder`,folderPath:t.slice(8)};if(t.startsWith(Qp))return{kind:`asset`,assetPath:t.slice(7)};let n=sm(t);return n?{kind:`skill-file`,...n}:{kind:`doc`,docName:t}}function mm(e){let t=pm(e);return t.kind===`doc`?t.docName:null}function hm(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(am(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function gm(e,t){let n=new Set(hm(t,2**53-1));return hm(e,2**53-1).filter(e=>n.has(e))}function _m(e,t,n){if(t<=0)return[];let r=new Set(hm(n,2**53-1)),i=hm(e,2**53-1);if(r.size===0&&i.length<=t)return i;let a=[],o=0;for(let e=i.length-1;e>=0;e--){let n=i[e];if(r.has(n)){a.push(n);continue}o>=t||(o++,a.push(n))}return a.reverse()}function vm(e,t,n){let r=gm(e,n);return!hm(n,2**53-1).includes(t)||r.includes(t)?r:[...r,t]}function ym(e,t){return hm(e,2**53-1).filter(e=>e!==t)}function bm(e,t){let n=new Set(hm(t,2**53-1));return hm(e,2**53-1).filter(e=>!n.has(e))}function xm(e,t,n){let r=hm(e,2**53-1),i=gm(t,r),a=r.indexOf(n);if(a<0)return i;let o=i.includes(n),s=a<i.length;return o===s?i:s?vm(i,n,r):ym(i,n)}function Sm(e,t,n,r=[]){let i=_m(e,n,r);return!am(t)||i.includes(t)?i:_m([...i,t],n,r)}function Cm(e,t,n,r,i=[]){let a=_m(e,r,i);if(!am(n))return a;if(!t||t===n)return Sm(a,n,r,i);let o=a.filter(e=>e!==n),s=o.indexOf(t);if(s<0)return Sm(o,n,r,i);let c=[...o];return c[s]=n,_m(c,r,i)}function wm(e,t,n){return Tm(e,cm(t),n)}function Tm(e,t,{behavior:n,currentTabId:r,limit:i,pinnedTabIds:a=[]}){let o=_m(e,i,a),s=rm(t);if(r&&o.includes(r)&&rm(r)===s)return{tabs:o,activeTabId:r};let c=o.find(e=>rm(e)===s);return c?{tabs:o,activeTabId:c}:n===`replace-active`?{tabs:Cm(o,r,s,i,a),activeTabId:s}:{tabs:Sm(o,s,i,a),activeTabId:s}}function Em(e,t){return e.filter(e=>e!==t)}function Dm(e,t,n){let r=hm(t,2**53-1),i=new Set(r),a=new Set(n),o=new Set,s=[];for(let t of e)o.has(t)||!i.has(t)&&!a.has(t)||(o.add(t),s.push(t));for(let e of[...r,...n])o.has(e)||(o.add(e),s.push(e));return s}function Om(e,{pages:t,folderPaths:n,assetPaths:r,filePaths:i,keepMissingDocName:a=null,keepHashDocName:o=null}){return hm(e,2**53-1).filter(e=>{let s=pm(e);if(s.kind===`folder`)return n.has(s.folderPath);if(s.kind===`asset`)return r.has(s.assetPath)||i?.has(s.assetPath)===!0;if(s.kind===`skill-file`)return!0;let c=im(s.docName);return t.has(s.docName)||c!==null&&t.has(c)||L(s.docName)||s.docName===a||s.docName===o})}function km(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return hm(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=new Map(a.flatMap(e=>{let t=im(e.fromPath);return t?[[t,e.toPath]]:[]})),c=new Map(a.flatMap(e=>{let t=im(e.toPath);return t?[[e.fromPath,t]]:[]})),l=e=>Mm(jm(e,r),a),u=(e,t)=>{let n=o.get(e);if(n)return n;let r=s.get(e);return r?um(r):t},d=e=>{let t=c.get(e);return t?cm(t):um(l(e))},f=[],p=new Set;for(let t of e){let{instanceSuffix:e}=nm(t),a=pm(t),o=`${a.kind===`doc`?u(a.docName,rm(t)):a.kind===`folder`?lm(jm(a.folderPath,r)):a.kind===`asset`?d(a.assetPath):rm(t)}${e}`;if(!p.has(o)&&(p.add(o),f.push(o),i.length===0&&f.length>=n))break}return i.length===0?f:_m(f,n,i.map(e=>{let t=pm(e);return t.kind===`doc`?u(t.docName,e):t.kind===`folder`?lm(jm(t.folderPath,r)):t.kind===`asset`?d(t.assetPath):rm(e)}))}function Am(e,t,n=[],r=[]){return km(e,t,2**53-1,n,[],r)}function jm(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function Mm(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function Nm(e,t,n){if(t!==n)return t;let r=e.indexOf(n);return r<0?e[0]??null:e[r+1]??e[r-1]??null}function Pm(e,t,n){if(!t)return null;let r=new Set(n);if(!r.has(t))return t;let i=e.indexOf(t);if(i<0)return e.find(e=>!r.has(e))??null;for(let t=i+1;t<e.length;t++)if(!r.has(e[t]))return e[t];for(let t=i-1;t>=0;t--)if(!r.has(e[t]))return e[t];return null}function Fm(e,t){if(typeof e!=`object`||!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};let n=e,r=hm(n.openTabs,2**53-1),i=gm(n.pinnedTabIds,r),a=i.length===0?hm(n.openTabs,t):_m(r,t,i),o=gm(n.pinnedTabIds,a),s=typeof n.activeTabId==`string`&&a.includes(n.activeTabId)?n.activeTabId:typeof n.activeDocName==`string`&&a.includes(n.activeDocName)?n.activeDocName:null,c=s?pm(s):null;return{openTabs:a,pinnedTabIds:o,activeDocName:c?.kind===`doc`?c.docName:null,activeTabId:s,updatedAt:typeof n.updatedAt==`string`?n.updatedAt:null}}function Im(e,t,n=[],r=()=>new Date){let i=hm(e,2**53-1),a=t&&i.includes(t)?t:null,o=a?pm(a):null;return{openTabs:i,pinnedTabIds:gm(n,i),activeDocName:o?.kind===`doc`?o.docName:null,activeTabId:a,updatedAt:r().toISOString()}}function Lm(e){return`${Xp}${e}`}function Rm(e,t,n){if(!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};try{let r=e.getItem(t);return r?Fm(JSON.parse(r),n):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}catch(e){return console.warn(`[editor-tabs] failed to read local tab session:`,e),{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null}}}function zm(e,t,n){if(e)try{e.setItem(t,JSON.stringify(n))}catch(e){console.warn(`[editor-tabs] failed to write local tab session:`,e)}}var Bm=e=>Ai((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),Vm=(e,t)=>Ai((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(Hi(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),Hm=e=>Bm(indexedDB.deleteDatabase(e)),Um=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),Wm=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>th(r,e))},Gm=(e,t)=>Bm(e.count(t)),Km=(e,t)=>Bm(e.get(t)),qm=(e,t)=>Bm(e.delete(t)),Jm=(e,t,n)=>Bm(e.put(t,n)),Ym=(e,t)=>Bm(e.add(t)),Xm=(e,t,n)=>Bm(e.getAll(t,n)),Zm=(e,t,n)=>{let r=null;return eh(e,t,e=>(r=e,!1),n).then(()=>r)},Qm=(e,t=null)=>Zm(e,t,`prev`),$m=(e,t)=>Ai((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),eh=(e,t,n,r=`next`)=>$m(e.openKeyCursor(t,r),e=>n(e.key)),th=(e,t)=>e.objectStore(t),nh=(e,t)=>IDBKeyRange.upperBound(e,t),rh=(e,t)=>IDBKeyRange.lowerBound(e,t),ih=`custom`,ah=`updates`,oh=(e,t=()=>{},n=()=>{})=>{let[r]=Wm(e.db,[ah]);return Xm(r,rh(e._dbref,!1)).then(i=>{e._destroyed||(t(r),ki(e.doc,()=>{i.forEach(t=>Gi(e.doc,t))},e,!1),n(r))}).then(()=>Qm(r).then(t=>{e._dbref=t+1})).then(()=>Gm(r).then(t=>{e._dbsize=t})).then(()=>r)},sh=(e,t=!0)=>oh(e).then(n=>{(t||e._dbsize>=500)&&Ym(n,Ti(e.doc)).then(()=>qm(n,nh(e._dbref,!0))).then(()=>Gm(n).then(t=>{e._dbsize=t}))}),ch=class extends oa{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=Vm(e,e=>Um(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=Ai(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,oh(this,async e=>{await Gm(e)>0&&Ym(e,Ti(t))},()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=Wm(this.db,[ah]);Ym(t,e).catch(e=>{globalThis.__okYdbWriteWarned||(globalThis.__okYdbWriteWarned=!0,console.warn(JSON.stringify({event:`ok-ydb-write-failed`,cause:e?.name??`unknown`,message:e?.message??String(e)})))}),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{sh(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{Hm(this.name)})}get(e){return this._db.then(t=>{let[n]=Wm(t,[ih],`readonly`);return Km(n,e)})}set(e,t){return this._db.then(n=>{let[r]=Wm(n,[ih]);return Jm(r,t,e)})}del(e){return this._db.then(t=>{let[n]=Wm(t,[ih]);return qm(n,e)})}},lh=`updates`,uh=`custom`;function dh(){return!0}var fh=class{_idb;_dbName;whenSynced;constructor({branch:e,serverInstanceId:t,docName:n,doc:r}){if(typeof t!=`string`||t.length===0)throw Error(`createClientPersistence: serverInstanceId is required and must be non-empty`);this._dbName=`ok-ydoc:${e}:${t}:${n}`;let i=dh()?0:performance.now();this._idb=new ch(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!dh()){let e=performance.now();X(`ok/pool/idb-whensynced`,{docName:n,durationMs:Math.round((e-i)*1e3)/1e3},{startTime:i,duration:e-i})}return this})}get synced(){return this._idb.synced}async destroy(){let e=dh()?0:performance.now();try{await this._idb.destroy()}finally{if(!dh()){let t=performance.now();X(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async flushFullState(){this._idb.db===null&&await this.whenSynced;let e=this._idb.db;if(e===null)return;let t=this._idb;await new Promise((n,r)=>{let i=e.transaction(lh,`readwrite`),a=i.objectStore(lh),o=a.getAll();o.onerror=()=>r(o.error??Error(`flushFullState getAll failed`)),o.onsuccess=()=>{try{ki(t.doc,()=>{for(let e of o.result)Gi(t.doc,e)},t,!1);let e=a.add(Ti(t.doc));e.onerror=()=>r(e.error??Error(`flushFullState add failed`)),e.onsuccess=()=>{a.delete(IDBKeyRange.upperBound(e.result,!0))}}catch(e){r(e instanceof Error?e:Error(String(e)));try{i.abort()}catch{}}},i.oncomplete=()=>n(),i.onabort=()=>r(i.error??Error(`flushFullState transaction aborted`))})}async clearData(){let e=dh()?0:performance.now();try{await this._idb.destroy();let e=this._dbName;await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(),r.onerror=()=>n(r.error),r.onblocked=()=>{console.warn(JSON.stringify({event:`ok-client-persistence-clear-blocked`,dbName:e}))}})}finally{if(!dh()){let t=performance.now();X(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function ph(e){return new fh(e)}async function mh(e){if(typeof indexedDB>`u`)return null;let t=`ok-ydoc:${e.branch}:${e.serverInstanceId}:${e.docName}`;if(typeof indexedDB.databases==`function`&&!(await indexedDB.databases()).some(e=>e.name===t))return null;let n=await new Promise((e,n)=>{let r=indexedDB.open(t);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(lh)||e.createObjectStore(lh,{autoIncrement:!0}),e.objectStoreNames.contains(uh)||e.createObjectStore(uh)},r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)});try{if(!n.objectStoreNames.contains(lh))return null;let e=await new Promise((e,t)=>{let r=n.transaction(lh,`readonly`).objectStore(lh).getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)});if(e.length===0)return null;let t=new ia;try{ki(t,()=>{for(let n of e)Gi(t,n)});let n=t.getMap(`lifecycle`).get(k);return typeof n==`string`&&n.length>0?n:null}finally{t.destroy()}}finally{n.close()}}function hh(e){return Fi(e)}function gh(e,t){return t===null?Ti(e):Ti(e,t)}function _h(e,t){if(e===null)return t;if(t===null)return e;let n=Ei(e),r=Ei(t),i=new Map;for(let[e,t]of n)i.set(e,t);for(let[e,t]of r){let n=i.get(e);(n===void 0||t>n)&&i.set(e,t)}return Fi(i)}function vh(e){let t={};if(Mt.inject(jt.active(),t),!t.traceparent)return e;let n=e.includes(`?`)?`&`:`?`,r=[`traceparent=${encodeURIComponent(t.traceparent)}`];return t.tracestate&&r.push(`tracestate=${encodeURIComponent(t.tracestate)}`),`${e}${n}${r.join(`&`)}`}var yh=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new Et({key:e||new ke(`fileHandler`),props:{handleDrop(e,n){if(!r||!n.dataTransfer?.files.length)return!1;let a=e.posAtCoords({left:n.clientX,top:n.clientY}),o=Array.from(n.dataTransfer.files);return i&&(o=o.filter(e=>i.includes(e.type))),o.length===0?!1:(n.preventDefault(),n.stopPropagation(),r(t,o,a?.pos||0),!0)},handlePaste(e,r){if(!n||!r.clipboardData?.files.length)return!1;let a=Array.from(r.clipboardData.files),o=r.clipboardData.getData(`text/html`);return i&&(a=a.filter(e=>i.includes(e.type))),!(a.length===0||(r.preventDefault(),r.stopPropagation(),n(t,a,o),o.length>0))}}}),bh=Y.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[yh({key:new ke(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function xh(e,t){let{state:n,view:r}=e;if(!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount!==0||!bt.isSelectable(o))return!1;try{let t=bt.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Xe(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}function Sh(e){let{state:t,view:n}=e;if(!(t.selection instanceof y)||!t.selection.empty||!n.endOfTextblock(`up`))return!1;let r=t.selection.$head,i=-1;for(let e=r.depth-1;e>=1;e--)if(r.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;for(let e=r.depth;e>i;e--)if(r.index(e-1)!==0)return!1;let a=r.before(i);try{let n=t.doc.resolve(a),r=wt.findFrom(n,-1,!0);return!r||!(r instanceof y)?!1:(e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return Xe(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2c`,reason:e.message.slice(0,500)})),!0}}function Ch(e,t){let{state:n,view:r}=e;if(!(n.selection instanceof y)||!n.selection.empty||!r.endOfTextblock(t))return!1;let i=n.selection.$head,a=t===`down`||t===`right`,o=null,s=-1;if(a){let e=i.after();if(e>=n.doc.content.size)return!1;o=n.doc.nodeAt(e),s=e}else{let e=i.before();if(e<=0||(o=n.doc.resolve(e).nodeBefore,!o))return!1;s=e-o.nodeSize}if(!o||o.type.name!==`jsxComponent`||o.childCount===0)return!1;let c=s+o.nodeSize;try{let t=a?s+1:c-1,r=wt.findFrom(n.doc.resolve(t),a?1:-1,!0);return!r||!(r instanceof y)||r.$head.pos<=s||r.$head.pos>=c?!1:(e.view.dispatch(n.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return Xe(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L2d`,reason:e.message.slice(0,500)})),!0}}var wh=Y.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof bt){if(t.selection.$from.depth===0)return e.commands.blur(),!0;let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=y.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof y?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(xh(e,`up`)||Sh(e)||Ch(e,`up`))return!0;let{state:t}=e;if(!(t.selection instanceof bt))return!1;let n=t.selection.from,r=t.doc.resolve(n);if(r.index(r.depth)===0)return!1;let i=r.before(r.depth);if(i<=0)return!1;let a=t.doc.resolve(i-1).nodeBefore;if(!a||i-1-a.nodeSize+1<0)return!1;try{let n=bt.create(t.doc,i-a.nodeSize);return e.view.dispatch(t.tr.setSelection(n).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Xe(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowDown:({editor:e})=>{if(xh(e,`down`)||Ch(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof bt))return!1;let n=t.selection.from+t.selection.node.nodeSize;if(n>=t.doc.content.size)return!1;try{if(!t.doc.nodeAt(n))return!1;let r=bt.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return Xe(`down`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`down`,tier:`L2`,reason:e.message.slice(0,500)})),!1}},ArrowLeft:({editor:e})=>xh(e,`left`)||Ch(e,`left`),ArrowRight:({editor:e})=>xh(e,`right`)||Ch(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof y)||!t.selection.empty)return!1;let n=t.selection.$from,r=n.parent;if(r.type.name!==`paragraph`||r.textContent!==``||n.depth<2)return!1;let i=-1;for(let e=n.depth-1;e>=1;e--)if(n.node(e).type.name===`jsxComponent`){i=e;break}if(i<0)return!1;let a=n.node(i);if(n.index(i)!==a.childCount-1)return!1;let o=n.after(i);if(o>t.doc.content.size)return!1;let s=t.tr,c=n.before(n.depth),l=n.after(n.depth);s.delete(c,l);let u=o-(l-c),d=t.schema.nodes.paragraph.create();s.insert(u,d);let f=u+1;return s.setSelection(y.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),Th={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},Eh=/[A-Za-z0-9_]/;function Dh(e){return e!==void 0&&Eh.test(e)}function Oh(e,t,n){return!Dh(e[t-1])&&!Dh(e[n])}function kh(e,t,n){if(t.length===0)return[];let r=n.caseSensitive?e:e.toLocaleLowerCase(),i=n.caseSensitive?t:t.toLocaleLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let t=r.indexOf(i,o);if(t===-1)break;let s=t+i.length;(!n.wholeWord||Oh(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function Ah(e,t,n){if(t.length===0)return[];let r=[];return e.descendants((e,i)=>{if(!(!e.isText||typeof e.text!=`string`))for(let a of kh(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var jh=new ke(`findReplace`);function Mh(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function Nh(e,t,n,r){let i=Ah(e.doc,t,n);return{query:t,options:n,activeIndex:Mh(r,i.length),matches:i}}function Ph(e,t,n){return t<=0?0:(Mh(e,t)+n+t)%t}function Fh(e,t,n){if(e.length===0)return 0;let r=t+n,i=e.findIndex(e=>e.from>=r);return i===-1?0:i}function Ih(e,t,n){if(t.matches.length===0)return null;let r=e.tr;for(let e of[...t.matches].reverse())r.insertText(n,e.from,e.to);let i=Ah(r.doc,t.query,t.options),a=Mh(0,i.length),o=i[a];return r.setMeta(jh,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(y.create(r.doc,o.from,o.to)),r.scrollIntoView()}function Lh(e,t){let n=jh.getState(e)?.matches[t];return n?e.tr.setMeta(jh,{type:`setActiveIndex`,activeIndex:t}).setSelection(y.create(e.doc,n.from,n.to)).scrollIntoView():null}function Rh(e){return jh.getState(e)??Th}function zh(){return new Et({key:jh,state:{init:()=>Th,apply(e,t,n,r){let i=e.getMeta(jh);if(i?.type===`clear`)return Th;let a=t.query,o=t.options,s=t.activeIndex;if(i?.type===`setQuery`)a=i.query,o={...o,...i.options},s=i.activeIndex??0;else if(i?.type===`setOptions`)o={...o,...i.options},s=i.activeIndex??s;else if(i?.type===`setActiveIndex`)s=i.activeIndex;else if(!e.docChanged)return t;return a.length===0?{query:a,options:o,activeIndex:0,matches:[]}:Nh(r,a,o,s)}},props:{decorations(e){let t=jh.getState(e);return!t||t.matches.length===0?null:Ue.create(e.doc,t.matches.map((e,n)=>rt.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var Bh=Y.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(jh,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(jh,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(jh,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=Rh(e),r=Lh(e,Ph(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=Rh(e),r=Lh(e,Ph(n.activeIndex,n.matches.length,-1));return r?(t?.(r),!0):!1},replaceCurrentFindMatch:e=>({state:t,dispatch:n})=>{let r=Rh(t),i=r.matches[r.activeIndex];if(!i||!n)return!1;let a=t.tr.insertText(e,i.from,i.to),o=Ah(a.doc,r.query,r.options),s=Fh(o,i.from,e.length),c=o[s];return a.setMeta(jh,{type:`setActiveIndex`,activeIndex:s}),c&&a.setSelection(y.create(a.doc,c.from,c.to)),a.scrollIntoView(),n(a),!0},replaceAllFindMatches:e=>({state:t,dispatch:n})=>{let r=Rh(t);if(!n)return!1;let i=Ih(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(jh,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[zh()]}}),Vh=/^(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/i,Hh=/^([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/,Uh=/[-\d_]$/,Wh=yt.map(e=>`${e}:`);function Gh(e){let t=e.toLowerCase();return Wh.some(e=>t.startsWith(e))}function Kh(e,t){let n=0;for(let r of e)r===t&&n++;return n}function qh(e){let t=e.split(`.`),n=t[t.length-1],r=t[t.length-2];return!(n&&(/_/.test(n)||!/[a-zA-Z\d]/.test(n))||r&&(/_/.test(r)||!/[a-zA-Z\d]/.test(r)))}function Jh(e){return e.split(`.`).length>=2&&qh(e)}function Yh(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,``];let n=e.slice(0,t.index),r=t[0],i=r.indexOf(`)`),a=Kh(n,`(`),o=Kh(n,`)`);for(;i!==-1&&a>o;)n+=r.slice(0,i+1),r=r.slice(i+1),i=r.indexOf(`)`),o++;return[n,r]}function Xh(e){let t=Vh.exec(e);if(!t)return null;let n=t[1],r=t[2],i=t[3],a=``,o=/^w/i.test(n);if(o&&(r=n+r,n=``,a=`http://`),o?!Jh(r):!qh(r))return null;let[s]=Yh(r+i);if(!s)return null;let c=n+s,l=a+n+s;return Gh(l)?{href:l,text:c}:null}function Zh(e){let t=Hh.exec(e);if(!t)return null;let n=t[1],r=t[2];if(Uh.test(r))return null;let i=`${n}@${r}`,a=`mailto:${i}`;return Gh(a)?{href:a,text:i}:null}function Qh(e){return e?Xh(e)??Zh(e):null}function $h(e,t){let n=Md.getState(e.state)?.undoManager;n?.stopCapturing();try{e.dispatch(t)}finally{n?.stopCapturing()}}var eg=`\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000`,tg=RegExp(`[${eg}]`),ng=RegExp(`[${eg}]$`),rg=`link`,ig=`gfm-autolink`,ag=`preventAutolink`,og=new ke(`gfmAutolink`);function sg(e,t,n){let r=e.state.schema.marks.code;return r?e.state.doc.rangeHasMark(t,n,r):!1}function cg(e,t,n){let r=[],i=f(be(e.doc,[...n]));for(let{newRange:e}of i){let n=ie(t.doc,e,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=t.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length===1){let r=t.doc.textBetween(e.from,e.to,` `,` `);if(!ng.test(r))continue;i=n[0],a=t.doc.textBetween(i.pos,e.to,void 0,` `)}if(!i||!a||i.node.type.spec.code)continue;let o=a.split(tg).filter(Boolean),s=o[o.length-1];if(!s)continue;let c=Qh(s);if(!c)continue;let l=i.pos+a.lastIndexOf(s)+1,u=l+c.text.length;r.push({from:l,to:u,href:c.href,text:c.text})}return r}function lg(e={}){let t=e.isActiveEditor??(e=>e.hasFocus()),n=null,r=!1,i=[],a=()=>{r=!1;let e=n,a=i.splice(0,i.length);if(!e||e.isDestroyed||e.composing||!t(e))return;let o=e.state.schema.marks[rg];if(!o)return;let s=e.state.tr,c=!1,l=e.state.doc.content.size;for(let t of a){let{from:n,to:r,href:i,text:a}=t;n<0||r>l||n>=r||e.state.doc.textBetween(n,r)===a&&(Ie(n,r,e.state.doc).some(e=>e.mark.type===o)||sg(e,n,r)||(s=s.addMark(n,r,o.create({href:i,linkStyle:ig})),c=!0))}if(c){s=s.setMeta(ag,!0);try{$h(e,s)}catch(e){console.warn(`[gfm-autolink] linkify dispatch failed`,{candidates:a.map(e=>({from:e.from,to:e.to,href:e.href}))},e)}}};return new Et({key:og,view(e){return n=e,{destroy(){n=null,i.length=0,r=!1}}},appendTransaction(e,o,s){if(e.some(e=>e.getMeta(jd))||e.some(e=>e.getMeta(`preventAutolink`))||!(e.some(e=>e.docChanged)&&!o.doc.eq(s.doc))||!n||!t(n))return null;let c=cg(o,s,e);return c.length===0?null:(i.push(...c),r||(r=!0,queueMicrotask(a)),null)}})}var ug=Y.create({name:`gfmAutolink`,addOptions(){return{isActiveEditor:void 0}},addProseMirrorPlugins(){return[lg({isActiveEditor:this.options.isActiveEditor})]}}),dg=new ke(`imageUpload`);function fg(e){let t=document.createElement(`div`);t.className=`image-upload-skeleton w-full h-40 rounded-md bg-muted animate-pulse motion-reduce:animate-none my-2`,t.setAttribute(`data-upload-widget`,`loading`),t.setAttribute(`role`,`status`);let n=e?.name;return t.setAttribute(`aria-label`,n?ai._({id:`KDuPiY`,values:{fileName:n}}):ai._({id:`bGa3Fk`})),t}var pg=new Et({key:dg,state:{init(){return{decorations:Ue.empty,uploads:new Map}},apply(e,t){let n=t.decorations.map(e.mapping,e.doc),r=new Map;for(let[n,i]of t.uploads)r.set(n,e.mapping.map(i));let i=e.getMeta(dg);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=rt.widget(i.pos,i.widget,{id:i.id,stopEvent:()=>!0}),a=n.add(e.doc,[t]),o=new Map(r);return o.set(i.id,e.mapping.map(i.pos)),{decorations:a,uploads:o}}if(i.type===`remove`){let e=n.find(void 0,void 0,e=>e.id===i.id),t=n.remove(e),a=new Map(r);return a.delete(i.id),{decorations:t,uploads:a}}return{decorations:n,uploads:r}}},props:{decorations(e){return dg.getState(e)?.decorations??Ue.empty}}});function mg(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function hg(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function gg(e){return e.split(`/`).filter(e=>e!==``)}function _g(e,t){let n=mg(e),r=mg(t),i=hg(e);if(n===r)return i;let a=gg(r),o=gg(n),s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s++;let c=a.length-s,l=o.slice(s);return c===0?`./${[...l,i].join(`/`)}`:[...Array(c).fill(`..`),...l,i].join(`/`)}function vg(e){return Yt(e)}function yg(e,t){return{type:`jsxComponent`,attrs:{componentName:e===`jsx-img`?`img`:e===`jsx-video`?`video`:`audio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:e===`jsx-img`?{src:t}:{src:t,controls:!0}}}}function bg(e){let t=it(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:j.has(t)?{kind:`jsx-img`,ext:t}:z.has(t)?{kind:`jsx-video`,ext:t}:p.has(t)?{kind:`jsx-audio`,ext:t}:w.has(t)?{kind:`jsx-file`,ext:t}:K.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function xg(e,t,n){let r=vg(t),i=r?`${r}.md`:``;if(!i){sr.error(ai._({id:`z5pqI8`}));return}let a=crypto.randomUUID(),o=fg(e);t.view.dispatch(t.state.tr.setMeta(dg,{type:`add`,id:a,pos:n,widget:o}));let s=new FormData;s.append(`file`,e),s.append(`parentDocName`,i);let c;try{c=await fetch(`/api/upload`,{method:`POST`,body:s})}catch(e){console.error(`[uploadAndInsert] Network error:`,e),Sg(t,a);return}let l;try{l=await c.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),Sg(t,a);return}if(!c.ok){let e=qe.safeParse(l);if(!e.success){let n=new Ut(`Upload response did not match ProblemDetails.`,{cause:e.error,status:c.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),Sg(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),Sg(t,a,e.data.title);return}let u=Qe.safeParse(l);if(!u.success){let e=new Ut(`Upload success response did not match UploadAssetSuccess.`,{cause:u.error,status:c.status});console.error(`[uploadAndInsert] Response missing src:`,e),Sg(t,a);return}let d=u.data,f=d.src,p=d.deduped===!0,m=mg(i),h=typeof d.path==`string`&&d.path.length>0?d.path:m?`${m}/${f}`:f;p&&sr.info(ai._({id:`VbqhBI`,values:{assetContentPath:h}}));let g=bg(e.name),{state:_}=t,v=dg.getState(_)?.uploads.get(a)??n,y=_.tr.setMeta(dg,{type:`remove`,id:a}),b=_g(h,i),x=`/${h}`;if(g.kind===`jsx-file`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),Sg(t,a);return}let n={type:`jsxComponent`,attrs:{componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:{src:x,target:f,alias:null,anchor:null,size:xt(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(dg,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,n).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(bt.create(e.doc,n)),!0}).run();return}if(g.kind===`jsx-img`||g.kind===`jsx-video`||g.kind===`jsx-audio`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),Sg(t,a);return}let e=yg(g.kind,x);t.chain().command(({tr:e})=>(e.setMeta(dg,{type:`remove`,id:a}),!0)).focus().insertContentAt(v,e).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=e.mapping.map(v);return e.doc.nodeAt(n)?.type.name===`jsxComponent`&&e.setSelection(bt.create(e.doc,n)),!0}).run();return}if(g.kind===`wikiembed`){let e=_.schema.nodes.wikiLinkEmbed;if(!e){console.error(`[uploadAndInsert] wikiLinkEmbed node missing from schema`),Sg(t,a);return}y.insert(v,e.create({target:f,alias:null,anchor:null,resolvedSrc:x}))}else if(g.kind===`wiki-link`){let n=_.schema.nodes.wikiLink;if(!n){console.error(`[uploadAndInsert] wikiLink node missing from schema`),Sg(t,a);return}let r=an(e.name.replace(/\.(md|mdx)$/i,``));r?y.insert(v,n.create(r)):y.insert(v,_.schema.text(e.name))}else{let t=_.schema.marks.link;if(t){let n=_.schema.text(e.name,[t.create({href:b})]);y.insert(v,n)}else y.insert(v,_.schema.text(e.name))}t.view.dispatch(y)}function Sg(e,t,n){e.view.dispatch(e.state.tr.setMeta(dg,{type:`remove`,id:t})),sr.error(n??ai._({id:`b3Thhd`}))}var Cg=/\[([^\]]+)\]\(([^)\s]+)\)$/,wg=`link`;function Tg(e,t,n,r,i){if(e.isDestroyed||e.composing)return;let{state:a}=e,o=a.schema.marks[wg];if(!o)return;let s=t+n.length;if(t<0||s>a.doc.content.size||a.doc.textBetween(t,s)!==n||a.doc.rangeHasMark(t,s,o))return;let c=a.schema.text(r,[o.create({href:i})]);try{$h(e,a.tr.replaceRangeWith(t,s,c))}catch(e){console.warn(`[inline-link-rule] collapse dispatch failed`,{from:t,text:r,href:i},e)}}var Eg=Y.create({name:`inlineLinkInputRule`,addInputRules(){let e=this.editor;return[new me({find:Cg,handler:({state:t,range:n,match:r})=>{let i=r[1],a=r[2];if(!i||!a||!_(a))return null;let o=t.schema.marks[wg];if(!o||t.doc.rangeHasMark(n.from,n.to,o))return null;let s=n.from,c=r[0],l=e.view;return queueMicrotask(()=>Tg(l,s,c,i,a)),null}})]}}),Dg=new Set;function Og(e){Dg.add(e)}function kg(e){return Dg.delete(e)}var Ag=new ke(`markIdentity`);function jg(){return{byId:new Map,counter:0}}function Mg(e,t,n,r,i){let a=[];for(let e of t.byId.values()){let t=i?i.map(e.from,-1):e.from,n=i?i.map(e.to,1):e.to;n<=t||a.push({id:e.id,markType:e.markType,attrs:e.attrs,from:t,to:n})}let o=new Map,s=new Set,c=t.counter;return e.descendants((e,t)=>{if(!(!e.isInline||e.marks.length===0))for(let i of e.marks){if(!n.has(i.type.name)||r&&!r(i))continue;let l=null;for(let e of a)if(!s.has(e.id)&&e.markType===i.type.name&&Ng(e.attrs,i.attrs)&&!(t<e.from||t>=e.to)){l=e.id;break}let u=l??`m${++c}`;s.add(u);let d=t,f=t+e.nodeSize,p=o.get(u);p?p.to=Math.max(p.to,f):o.set(u,{id:u,markType:i.type.name,attrs:i.attrs,from:d,to:f})}}),{byId:o,counter:c}}function Ng(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i&&(typeof n!=`object`||!n||typeof i!=`object`||!i||!((Array.isArray(n)&&Array.isArray(i)||!Array.isArray(n)&&!Array.isArray(i)&&Object.getPrototypeOf(n)===Object.prototype&&Object.getPrototypeOf(i)===Object.prototype)&&Ng(n,i))))return!1}return!0}function Pg(e,t,n,r){let i=new Set(t.byId.keys());for(let[r,i]of t.byId)e.has(r)||n?.(i);for(let t of e)i.has(t)||r?.(t);return i}function Fg(e,t,n){let r=Ag.getState(e);if(!r)return null;for(let e of r.byId.values())if(e.markType===n&&e.from<=t&&t<e.to)return e.id;return null}function Ig(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new Et({key:Ag,state:{init(e,t){return Mg(t.doc,jg(),a,n)},apply(e,t,r,i){return e.docChanged?Mg(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=Ag.getState(t.state);n&&(e=Pg(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}var Lg=300,Rg=150,zg=500,Bg=class{registry=new Map;_activeNodeId=null;listeners=new Set;_snapshot={activeNodeId:null,active:null};register(e){this.registry.set(e.nodeId,e),this._activeNodeId===e.nodeId&&this.refreshSnapshot()}deregister(e){this.registry.delete(e)&&this._activeNodeId===e&&(this._activeNodeId=null,this.refreshSnapshot())}setActiveNode(e){this._activeNodeId!==e&&(e!==null&&!this.registry.has(e)||(this._activeNodeId=e,this.refreshSnapshot()))}getActiveNode(){return this._activeNodeId}getRegistration(e){return this.registry.get(e)}hasRegistration(e){return this.registry.has(e)}clear(){this.registry.clear(),this._activeNodeId=null,this.refreshSnapshot()}getSnapshot=()=>this._snapshot;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});refreshSnapshot(){let e=this._activeNodeId==null?null:this.registry.get(this._activeNodeId)??null;this._snapshot={activeNodeId:this._activeNodeId,active:e};for(let e of this.listeners)e()}};function Vg(e,t){let n=e??null;for(;n&&typeof n==`object`;){let e=n.getAttribute;if(typeof e==`function`){let r=e.call(n,`data-mark-id`);if(r&&t.hasRegistration(r))return r;let i=e.call(n,`data-node-id`);if(i&&t.hasRegistration(i))return i}n=n.parentElement??null}return null}function Hg(e){return e?e.closest(`[data-ok-prop-panel]`)!==null:!1}function Ug(){return typeof document>`u`?!1:document.querySelector(`[data-ok-layer-spawned]`)!==null}var Wg=e=>{let t=(0,$.c)(18),{store:n}=e,r;t[0]===n?r=t[1]:(r=()=>n.getSnapshot(),t[0]=n,t[1]=r);let[i,a]=(0,Q.useState)(r),o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>(a(n.getSnapshot()),n.subscribe(()=>{a(n.getSnapshot())})),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let{active:c}=i;if(!c)return null;let l;t[5]===n?l=t[6]:(l=()=>n.setActiveNode(null),t[5]=n,t[6]=l);let u,d,f;if(t[7]!==c.controls||t[8]!==c.nodeId||t[9]!==c.type||t[10]!==l){let e={nodeId:c.nodeId,type:c.type,deactivate:l};u=c.controls.propPanel?.(e),d=c.controls.toolbar?.(e),f=c.controls.breadcrumb?.(e),t[7]=c.controls,t[8]=c.nodeId,t[9]=c.type,t[10]=l,t[11]=u,t[12]=d,t[13]=f}else u=t[11],d=t[12],f=t[13];let p;return t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,Z.jsxs)(Z.Fragment,{children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17],p};function Gg(e){return e.editorView?.dom??null}function Kg(e,t){let n=e;for(;n;){if(n.getAttribute?.(`data-mark-id`)===t||n.getAttribute?.(`data-node-id`)===t)return!0;n=n.parentElement}return!1}function qg(e){let{editor:t}=e,n=new Bg,r=Gg(t),i=!1,a=null,o=null,s=null,c=null,l=null,u=()=>{a!==null&&(clearTimeout(a),a=null),s=null},d=()=>{o!==null&&(clearTimeout(o),o=null)},f=()=>{c!==null&&(clearTimeout(c),c=null)},p=e=>{if(n.getActiveNode()===e){d();return}s===e&&a!==null||(u(),d(),s=e,a=setTimeout(()=>{a=null,s=null,n.setActiveNode(e)},Lg))},m=()=>{n.getActiveNode()!==null&&o===null&&(o=setTimeout(()=>{o=null,!Ug()&&n.setActiveNode(null)},Rg))},h=null,g=!1,_=e=>{try{g=!0,e.focus({preventScroll:!0})}catch{}finally{g=!1}},v=n.subscribe(()=>{let e=n.getActiveNode();if(e!==null){if(typeof document<`u`){let t=document.activeElement;h=t&&Kg(t,e)?t:null}return}if(typeof document>`u`)return;let i=h;if(h=null,i&&document.contains(i)&&typeof i.focus==`function`){_(i);return}let a=r??Gg(t);a&&typeof a.focus==`function`&&_(a)}),y=e=>{let t=e;if(t.button!==2){if(t.metaKey||t.ctrlKey||t.button===1){u(),t.button===1&&t.preventDefault?.();return}if(t.pointerType===`touch`){let t=Vg(e.target,n);if(t===null)return;f(),c=setTimeout(()=>{c=null,l=t,n.setActiveNode(t)},zg);return}u()}},b=()=>{f()},x=e=>{e.pointerType===`touch`&&c!==null&&f()},S=e=>{let t=e;if(t.button===2||t.type===`click`&&t.button===1)return;let r=Vg(e.target,n);if(r===null)return;if(l!==null){let e=l===r;if(l=null,e){t.preventDefault?.();return}}let i=t.metaKey||t.ctrlKey||t.button===1,a=n.getRegistration(r);if(a?.handlePrimary&&a.handlePrimary({nodeId:r,type:a.type,newTab:i})){t.preventDefault?.(),i||(u(),d(),n.getActiveNode()===r&&n.setActiveNode(null));return}i||(u(),d(),n.setActiveNode(r))},C=e=>{let t=e;if(t.key===`Escape`){n.getActiveNode()!==null&&(u(),d(),n.setActiveNode(null),t.preventDefault?.());return}if(t.key===`Tab`&&!t.shiftKey&&!t.altKey&&!t.metaKey&&!t.ctrlKey){let r=Vg(e.target,n);if(r!==null&&n.getActiveNode()===r){let e=document.querySelector(`[data-ok-prop-panel]`);if(e){let n=e.querySelector(`button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(n){t.preventDefault?.(),n.focus();return}}}return}let r=t.key===`Enter`,i=t.key===` `||t.key===`Spacebar`;if(!r&&!i)return;let a=Vg(e.target,n);if(a===null||i&&((e.target instanceof Element?e.target:null)?.closest(`[data-mark-id], [data-node-id]`)??null)?.getAttribute(`role`)===`link`)return;let o=n.getRegistration(a);if(t.preventDefault?.(),o?.handlePrimary&&o.handlePrimary({nodeId:a,type:o.type,newTab:!1})){u(),d(),n.getActiveNode()===a&&n.setActiveNode(null);return}n.setActiveNode(a)},w=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target;if(!(r instanceof Element))return;if(Hg(r)){d();return}let i=Vg(r,n);i!==null&&p(i)},T=e=>{let t=e;if(t.pointerType!==`mouse`)return;let r=t.target,i=t.relatedTarget;if(!(r instanceof Element))return;let a=i instanceof Element?i:null,o=Vg(r,n);if(o!==null){if(a&&Hg(a)){d();return}if(a&&Vg(a,n)===o)return;s===o&&u(),m();return}if(Hg(r)){if(a&&Hg(a))return;let e=n.getActiveNode();if(e!==null&&a&&Vg(a,n)===e)return;m()}},E=e=>{if(g)return;let t=e.target;if(!(t instanceof Element))return;let r=Vg(t,n);r!==null&&(u(),d(),n.setActiveNode(r))},D=e=>{let t=e;if(n.getActiveNode()===null)return;let r=t.relatedTarget,i=r instanceof Element?r:null;i&&Hg(i)||i&&Vg(i,n)!==null||m()},O=e=>{if(n.getActiveNode()===null)return;let t=e.target;t&&(r?.contains(t)||t instanceof Element&&(t.closest(`[data-ok-interaction-layer]`)||t.closest(`[data-ok-prop-panel]`)||t.closest(`[data-ok-layer-spawned]`))||(u(),d(),n.setActiveNode(null)))},k=()=>{i||(r=Gg(t),r&&(r.addEventListener(`pointerdown`,y,!0),r.addEventListener(`pointerup`,b,!0),r.addEventListener(`pointercancel`,b,!0),r.addEventListener(`pointermove`,x,!0),r.addEventListener(`click`,S,!0),r.addEventListener(`auxclick`,S,!0),r.addEventListener(`keydown`,C,!0),typeof document<`u`&&(document.addEventListener(`pointerover`,w,!0),document.addEventListener(`pointerout`,T,!0),document.addEventListener(`focusin`,E,!0),document.addEventListener(`focusout`,D,!0),document.addEventListener(`pointerdown`,O,!0)),i=!0))},A=()=>{i&&=(r?.removeEventListener(`pointerdown`,y,!0),r?.removeEventListener(`pointerup`,b,!0),r?.removeEventListener(`pointercancel`,b,!0),r?.removeEventListener(`pointermove`,x,!0),r?.removeEventListener(`click`,S,!0),r?.removeEventListener(`auxclick`,S,!0),r?.removeEventListener(`keydown`,C,!0),typeof document<`u`&&(document.removeEventListener(`pointerover`,w,!0),document.removeEventListener(`pointerout`,T,!0),document.removeEventListener(`focusin`,E,!0),document.removeEventListener(`focusout`,D,!0),document.removeEventListener(`pointerdown`,O,!0)),!1)};return k(),{register(e){n.register(e),i||k()},deregister(e){n.deregister(e)},setActiveNode(e){n.setActiveNode(e)},getActiveNode(){return n.getActiveNode()},getRegistration(e){return n.getRegistration(e)},destroy(){A(),u(),d(),f(),v(),n.clear()},store:n}}var Jg=e=>{let t=(0,$.c)(2),{store:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{"data-ok-interaction-layer":``,className:`contents`,children:(0,Z.jsx)(Wg,{store:n})}),t[0]=n,t[1]=r),r},Yg=new WeakMap;function Xg(e){let t=Yg.get(e);if(t)return t;let n=qg({editor:e});return Yg.set(e,n),e.on(`destroy`,()=>{n.destroy(),Yg.delete(e)}),n}var Zg={AppWindow:La,ChevronRight:Hn,CopyPlus:Yn,FileText:Tn,Film:kn,GitBranch:nr,Image:gn,LayoutPanelTop:so,MessageSquareWarning:go,PanelTop:bo,Paperclip:xo,Sigma:Oo,SquarePlay:Ao,Volume2:hn,Workflow:Po,ZoomIn:Pn};function Qg(e){return e&&Object.hasOwn(Zg,e)?Zg[e]:za}var $g={Info:rr,Lightbulb:co,MessageSquareWarning:go,AlertTriangle:or,AlertOctagon:vo,ClipboardList:Ka,BookOpen:Ra,ListTodo:mo,CircleCheck:Gn,CircleHelp:Wa,CircleX:Ga,Zap:Fo,Bug:Ba,FlaskConical:to,Quote:Co,ChevronRight:Hn},e_=Object.entries($g).sort(([e],[t])=>e.localeCompare(t));function t_(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn($g,t)?$g[t]??null:null}function n_(e){let t=(0,$.c)(24),n;t[0]===e.icon?n=t[1]:(n=t_(e.icon),t[0]=e.icon,t[1]=n);let r=n,i=r?`custom`:void 0,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Hn,{size:14,className:`accordion-chevron`,"aria-hidden":`true`}),t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=r?(0,Z.jsx)(r,{size:16,className:`accordion-icon`,"aria-hidden":`true`}):null,t[3]=r,t[4]=o);let s=e.title??`Accordion`,c;t[5]===s?c=t[6]:(c=(0,Z.jsx)(`span`,{className:`accordion-title`,children:s}),t[5]=s,t[6]=c);let l;t[7]===e.description?l=t[8]:(l=e.description?(0,Z.jsx)(`span`,{className:`accordion-description`,children:e.description}):null,t[7]=e.description,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,Z.jsxs)(`span`,{className:`accordion-title-group`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==u?(d=(0,Z.jsxs)(`summary`,{className:`accordion-summary`,contentEditable:!1,children:[a,o,u]}),t[12]=o,t[13]=u,t[14]=d):d=t[14];let f;t[15]===e.children?f=t[16]:(f=(0,Z.jsx)(`div`,{className:`accordion-body`,children:e.children}),t[15]=e.children,t[16]=f);let p;return t[17]!==e.defaultOpen||t[18]!==e.id||t[19]!==e.name||t[20]!==i||t[21]!==d||t[22]!==f?(p=(0,Z.jsxs)(`details`,{className:`accordion`,"data-accordion-icon":i,open:e.defaultOpen,id:e.id,name:e.name,children:[d,f]}),t[17]=e.defaultOpen,t[18]=e.id,t[19]=e.name,t[20]=i,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function r_(e){return e!==!1}function i_(e){let t=(0,$.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:le(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=r_(e.controls),t[2]=e.controls,t[3]=i);let a;return t[4]!==e.autoplay||t[5]!==e.loop||t[6]!==e.muted||t[7]!==e.preload||t[8]!==e.title||t[9]!==n||t[10]!==i?(a=(0,Z.jsx)(`audio`,{className:`ok-audio`,src:n,title:r,controls:i,autoPlay:e.autoplay,loop:e.loop,muted:e.muted,preload:e.preload}),t[4]=e.autoplay,t[5]=e.loop,t[6]=e.muted,t[7]=e.preload,t[8]=e.title,t[9]=n,t[10]=i,t[11]=a):a=t[11],a}var a_={note:rr,tip:co,important:go,warning:or,caution:vo,abstract:Ka,info:Ra,todo:mo,success:Gn,question:Wa,failure:Ga,danger:Fo,bug:Ba,example:to,quote:Co};function o_(e,t){return t_(e)??a_[t]}var s_=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function c_(e){return typeof e==`string`&&s_.has(e)?e:`note`}function l_(e){let t=(0,$.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=c_(e.type),n=o_(e.icon,r),t[0]=e.icon,t[1]=e.type,t[2]=n,t[3]=r):(n=t[2],r=t[3]);let i=n,a;t[4]===e.color?a=t[5]:(a=e.color?{"--callout-type-color":e.color}:{},t[4]=e.color,t[5]=a);let s=a,c;t[6]!==i||t[7]!==e.title?(c=e.title||i?(0,Z.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,Z.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,Z.jsx)(`span`,{className:`callout-title`,children:e.title}):null]}):null,t[6]=i,t[7]=e.title,t[8]=c):c=t[8];let l=c;if(e.collapsible){let n=e.defaultOpen??!0,i;t[9]===l?i=t[10]:(i=l??(0,Z.jsx)(`span`,{className:`callout-title`,children:(0,Z.jsx)(o,{id:`URmyfc`})}),t[9]=l,t[10]=i);let a;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Vn,{size:16,className:`callout-chevron`,"aria-hidden":`true`}),t[11]=a):a=t[11];let c;t[12]===i?c=t[13]:(c=(0,Z.jsxs)(`summary`,{className:`callout-summary`,contentEditable:!1,children:[i,a]}),t[12]=i,t[13]=c);let u;t[14]===e.children?u=t[15]:(u=(0,Z.jsx)(`div`,{className:`callout-body`,children:e.children}),t[14]=e.children,t[15]=u);let d;return t[16]!==n||t[17]!==s||t[18]!==c||t[19]!==u||t[20]!==r?(d=(0,Z.jsxs)(`details`,{className:`callout callout-collapsible`,"data-callout-type":r,open:n,style:s,children:[c,u]}),t[16]=n,t[17]=s,t[18]=c,t[19]=u,t[20]=r,t[21]=d):d=t[21],d}let u;t[22]===e.children?u=t[23]:(u=(0,Z.jsx)(`div`,{className:`callout-body`,children:e.children}),t[22]=e.children,t[23]=u);let d;return t[24]!==l||t[25]!==s||t[26]!==u||t[27]!==r?(d=(0,Z.jsxs)(`div`,{className:`callout callout-static`,"data-callout-type":r,style:s,children:[l,u]}),t[24]=l,t[25]=s,t[26]=u,t[27]=r,t[28]=d):d=t[28],d}var u_=[{key:`tl`,dx:-1,dy:-1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--tl`},{key:`t`,dx:0,dy:-1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--t`},{key:`tr`,dx:1,dy:-1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--tr`},{key:`r`,dx:1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--r`},{key:`br`,dx:1,dy:1,cursor:`nwse-resize`,className:`ok-resize-handle ok-resize-handle--br`},{key:`b`,dx:0,dy:1,cursor:`ns-resize`,className:`ok-resize-handle ok-resize-handle--b`},{key:`bl`,dx:-1,dy:1,cursor:`nesw-resize`,className:`ok-resize-handle ok-resize-handle--bl`},{key:`l`,dx:-1,dy:0,cursor:`ew-resize`,className:`ok-resize-handle ok-resize-handle--l`}];function d_(e){let t=(0,$.c)(7),{targetRef:n,onResize:r,onResizeEnd:i,bounds:a}=e,{_:o}=s(),c=(0,Q.useRef)(null),l;t[0]!==a?.maxHeight||t[1]!==a?.maxWidth||t[2]!==a?.minHeight||t[3]!==a?.minWidth?(l=function(e,t){let n=t===`w`?a?.minWidth??64:a?.minHeight??64,r=t===`w`?a?.maxWidth??1/0:a?.maxHeight??1/0;return Math.max(n,Math.min(r,e))},t[0]=a?.maxHeight,t[1]=a?.maxWidth,t[2]=a?.minHeight,t[3]=a?.minWidth,t[4]=l):l=t[4];let u=l,d=function(e,t){let a=n.current;if(!a)return;e.preventDefault(),e.stopPropagation();let o=a.getBoundingClientRect();c.current={handle:t,startX:e.clientX,startY:e.clientY,startWidth:o.width,startHeight:o.height,latestWidth:o.width,latestHeight:o.height,hasMoved:!1};let s=e.currentTarget;try{s.setPointerCapture(e.pointerId)}catch{}document.body.style.setProperty(`cursor`,t.cursor),document.body.style.setProperty(`user-select`,`none`);let l=function(e){let t=c.current;if(!t)return;let n=(e.clientX-t.startX)*t.handle.dx,i=(e.clientY-t.startY)*t.handle.dy,a=t.handle.dx===0?t.startWidth:u(t.startWidth+n,`w`),o=t.handle.dy===0?t.startHeight:u(t.startHeight+i,`h`);t.latestWidth=a,t.latestHeight=o,t.hasMoved=!0,r({width:a,height:o})};function d(){let e=c.current;if(!e)return;let t={width:e.latestWidth,height:e.latestHeight},n=e.hasMoved;c.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`),window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),n&&i?.(t)}window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},f=u_.map(e=>{let t=e.key;return(0,Z.jsx)(`button`,{type:`button`,className:Ft(e.className),"aria-label":o({id:`NxW-md`,values:{handleKey:t}}),tabIndex:-1,style:{cursor:e.cursor},onPointerDown:t=>d(t,e)},t)}),p;return t[5]===f?p=t[6]:(p=(0,Z.jsx)(`div`,{className:`ok-resize-overlay`,contentEditable:!1,"aria-hidden":`true`,children:f}),t[5]=f,t[6]=p),p}var f_=`26rem`,p_=`Embedded content`,m_=/^https?:\/\//i;function h_(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function g_(e){return!(typeof e!=`string`||!m_.test(e)||!h_(e))}function __(e){let t=(0,$.c)(24),{src:n,title:r,width:i,height:a}=e,o=(0,Q.useRef)(null),s=zn(),c=i||void 0,l=a||f_,u;t[0]!==c||t[1]!==l?(u={width:c,height:l},t[0]=c,t[1]=l,t[2]=u):u=t[2];let d=u,f,p;if(t[3]!==a||t[4]!==i?(f=()=>{let e=o.current;e&&(e.style.width=i||``,e.style.height=a||f_)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Q.useEffect)(f,p),!g_(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=m_.test(n)?`Embed only supports cross-origin URLs`:`URL must start with http:// or https://`);let r;return t[7]===e?r=t[8]:(r=(0,Z.jsx)(`div`,{className:`ok-embed ok-embed--placeholder`,contentEditable:!1,children:(0,Z.jsx)(`span`,{children:e})}),t[7]=e,t[8]=r),r}let m;t[9]===s?m=t[10]:(m=e=>{if(!s)return;let{editor:t,getPos:n}=s,r=n();if(typeof r==`number`)try{let n=t.state.doc.nodeAt(r);if(!n||n.type.name!==`jsxComponent`)return;let i={...n.attrs.props??{},width:`${Math.round(e.width)}px`,height:`${Math.round(e.height)}px`};t.view.dispatch(t.state.tr.setNodeMarkup(r,null,{...n.attrs,props:i,sourceDirty:!0}))}catch(e){let t=e;if(t instanceof RangeError)return;throw t}},t[9]=s,t[10]=m);let h=m,g;t[11]===n?g=t[12]:(g=Te(n),t[11]=n,t[12]=g);let _=g,v=_===n?`no-referrer`:`strict-origin-when-cross-origin`,y=r||p_,b;t[13]!==_||t[14]!==v||t[15]!==y?(b=(0,Z.jsx)(`iframe`,{title:y,src:_,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:v,loading:`lazy`,className:`ok-embed-frame`}),t[13]=_,t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==s||t[18]!==h?(x=s?(0,Z.jsx)(d_,{targetRef:o,bounds:{minWidth:192,maxWidth:2e3,minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=o.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:h}):null,t[17]=s,t[18]=h,t[19]=x):x=t[19];let S;return t[20]!==d||t[21]!==x||t[22]!==b?(S=(0,Z.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[b,x]}),t[20]=d,t[21]=x,t[22]=b,t[23]=S):S=t[23],S}function v_(e){if(!e)return``;let t,n=null;try{let r=new URL(e,`https://placeholder.local`);n=r.protocol,t=r.pathname}catch{t=e.split(`?`)[0]??e}if(n===`data:`||n===`blob:`)return``;let r=t.split(`/`),i=r[r.length-1]??``;try{return decodeURIComponent(i)}catch{return i}}function y_(e){let t=(0,$.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||v_(e.src)||`Untitled file`,t[0]=e.name,t[1]=e.src,t[2]=n):n=t[2];let r=n,i=e.size?.trim()?e.size:null,a;t[3]===e.src?a=t[4]:(a=e.src?le(e.src):void 0,t[3]=e.src,t[4]=a);let o=a,s;t[5]===o?s=t[6]:(s=e=>{e.stopPropagation(),e.preventDefault(),o&&window.open(o,`_blank`,`noopener,noreferrer`)},t[5]=o,t[6]=s);let c=s,l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)($a,{className:`ok-file-icon`,"aria-hidden":`true`}),t[7]=l):l=t[7];let u;t[8]===r?u=t[9]:(u=(0,Z.jsx)(`span`,{className:`ok-file-name`,children:r}),t[8]=r,t[9]=u);let d;t[10]===i?d=t[11]:(d=i?(0,Z.jsx)(`span`,{className:`ok-file-size`,children:i}):null,t[10]=i,t[11]=d);let f;return t[12]!==c||t[13]!==o||t[14]!==e.title||t[15]!==u||t[16]!==d?(f=(0,Z.jsxs)(`a`,{href:o,title:e.title,className:`ok-file-attachment`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:b_,onClick:c,children:[l,u,d]}),t[12]=c,t[13]=o,t[14]=e.title,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function b_(e){return e.stopPropagation()}function x_(){return Q.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-unzoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Q.createElement(`path`,{d:`M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z`}))}function S_(){return Q.createElement(`svg`,{"aria-hidden":`true`,"data-rmiz-btn-zoom-icon":!0,fill:`currentColor`,focusable:`false`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`},Q.createElement(`path`,{d:`M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z`}))}function C_(e){return typeof Element>`u`?!1:e instanceof Element}var w_=(e,t)=>C_(t)&&t.tagName.toUpperCase()===e,T_=e=>w_(`DIV`,e)||w_(`SPAN`,e),E_=e=>w_(`IMG`,e),D_=e=>e.complete&&e.naturalHeight!==0,O_=e=>w_(`SVG`,e),k_=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),A_=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=k_({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},j_=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?A_({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):k_({height:e,offset:r,width:t}),M_=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,N_=e=>{if(e!==null){if(E_(e))return e.currentSrc===``?void 0:e.currentSrc;if(T_(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return M_.exec(t)?.[1]}}},P_=e=>{if(e!==null)return E_(e)?e.alt:e.getAttribute(`aria-label`)??void 0},F_=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=j_({containerHeight:e,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s});return{top:n,left:t,width:r*c,height:e*c,transform:`translate(0,0) scale(${1/c})`}},I_=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},L_=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,objectFit:a,objectPosition:o,offset:s,targetHeight:c,targetWidth:l})=>{let u=a;if(u===`scale-down`&&(u=l<=r&&c<=e?`none`:`contain`),u===`cover`||u===`contain`){let a=r/l,d=e/c,f=u===`cover`?Math.max(a,d):Math.min(a,d),[p=`50%`,m=`50%`]=o.split(` `),h=I_({position:p,relativeNum:r-l*f}),g=I_({position:m,relativeNum:e-c*f}),_=j_({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+g,left:t+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(u===`none`){let[a=`50%`,u=`50%`]=o.split(` `),d=I_({position:a,relativeNum:r-l}),f=I_({position:u,relativeNum:e-c}),p=j_({containerHeight:c,containerWidth:l,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{top:n+f,left:t+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else if(u===`fill`){let t=r/l,n=e/c,a=Math.max(t,n),o=j_({containerHeight:c*a,containerWidth:l*a,hasScalableSrc:i,offset:s,targetHeight:c,targetWidth:l});return{width:r*o,height:e*o,transform:`translate(0,0) scale(${1/o})`}}else return{}},R_=({backgroundPosition:e,backgroundSize:t,containerHeight:n,containerLeft:r,containerTop:i,containerWidth:a,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l})=>{if(t===`cover`||t===`contain`){let u=a/l,d=n/c,f=t===`cover`?Math.max(u,d):Math.min(u,d),[p=`50%`,m=`50%`]=e.split(` `),h=I_({position:p,relativeNum:a-l*f}),g=I_({position:m,relativeNum:n-c*f}),_=j_({containerHeight:c*f,containerWidth:l*f,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+g,left:r+h,width:l*f*_,height:c*f*_,transform:`translate(0,0) scale(${1/_})`}}else if(t===`auto`){let[t=`50%`,u=`50%`]=e.split(` `),d=I_({position:t,relativeNum:a-l}),f=I_({position:u,relativeNum:n-c}),p=j_({containerHeight:c,containerWidth:l,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+f,left:r+d,width:l*p,height:c*p,transform:`translate(0,0) scale(${1/p})`}}else{let[u=`50%`,d=`50%`]=t.split(` `),f=I_({position:u,relativeNum:a}),p=I_({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=I_({position:_,relativeNum:a-l*g}),b=I_({position:v,relativeNum:n-c*g}),x=j_({containerHeight:c*g,containerWidth:l*g,hasScalableSrc:o,offset:s,targetHeight:c,targetWidth:l});return{top:i+b,left:r+y,width:l*g*x,height:c*g*x,transform:`translate(0,0) scale(${1/x})`}}},z_=/\.svg$/i,B_=({hasZoomImg:e,imgSrc:t,isSvg:n,isZoomed:r,loadedImgEl:i,offset:a,shouldRefresh:o,targetEl:s})=>{let c=n||t?.slice(0,18)===`data:image/svg+xml`||e||t!==void 0&&z_.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&T_(s),f=i!=null&&!d,p=i!=null&&i.naturalHeight!==0?i.naturalHeight:l.height,m=i!=null&&i.naturalWidth!==0?i.naturalWidth:l.width,h=F_({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?L_({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:a,targetHeight:p,targetWidth:m}):void 0,_=d?R_({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}):void 0,v={...h,...g,..._};if(r){let e=window.innerWidth/2,t=window.innerHeight/2,n=parseFloat(String(v.left??0))+parseFloat(String(v.width??0))/2,r=parseFloat(String(v.top??0))+parseFloat(String(v.height??0))/2,i=e-n,a=t-r;o&&(v.transitionDuration=`0.01ms`),v.transform=`translate(${i}px,${a}px) scale(1)`}return v},V_=e=>{if(e==null)return{};if(O_(e)){let{parentElement:t}=e,n=e.getBoundingClientRect();if(t==null)return{height:n.height,left:n.left,width:n.width,top:n.top};{let e=t.getBoundingClientRect();return{height:n.height,left:e.left-n.left,top:e.top-n.top,width:n.width}}}else return{height:e.offsetHeight,left:e.offsetLeft,width:e.offsetWidth,top:e.offsetTop}},H_=e=>{let t=`-zoom`,n=[`clip-path`,`fill`,`mask`,`marker-start`,`marker-mid`,`marker-end`],r=new Map;if(e.hasAttribute(`id`)){let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}e.querySelectorAll(`[id]`).forEach(e=>{let{id:n}=e,i=n+t;r.set(n,i);let a=e;a.id=i}),r.forEach((t,r)=>{let i=`url(#${r})`,a=`url(#${t})`,o=n.map(e=>`[${e}="${i}"]`).join(`, `);e.querySelectorAll(o).forEach(e=>{n.forEach(t=>{e.getAttribute(t)===i&&e.setAttribute(t,a)})})}),e.querySelectorAll(`style`).forEach(e=>{r.forEach((t,n)=>{let{textContent:r}=e;if(r!==``){let i=e;i.textContent=r.replaceAll(`#${n}`,`#${t}`)}})})},U_=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),W_={overflow:``,width:``};function G_(){let e=document.querySelector(`[data-rmiz-portal]`);if(e!=null)return e;let t=document.createElement(`div`);return t.setAttribute(`data-rmiz-portal`,``),document.body.appendChild(t),t}function K_(e){e.preventDefault()}function q_(e){return Q.createElement(J_,{...e})}var J_=class extends Q.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Q.createRef(),this.refDialog=Q.createRef(),this.refModalContent=Q.createRef(),this.refModalImg=Q.createRef(),this.refWrap=Q.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=W_,this.styleModalImg={},this.handleModalStateChange=e=>{let{state:{modalState:t}}=this;e!==`LOADING`&&t===`LOADING`?(this.loadZoomImg(),window.addEventListener(`resize`,this.handleResize,{passive:!0}),window.addEventListener(`touchstart`,this.handleTouchStart,{passive:!0}),window.addEventListener(`touchmove`,this.handleTouchMove,{passive:!0}),window.addEventListener(`touchend`,this.handleTouchEnd,{passive:!0}),window.addEventListener(`touchcancel`,this.handleTouchCancel,{passive:!0}),document.addEventListener(`keydown`,this.handleKeyDown,!0)):e!==`LOADED`&&t===`LOADED`?window.addEventListener(`wheel`,this.handleWheel,{passive:!0}):e!==`UNLOADING`&&t===`UNLOADING`?(this.ensureImgTransitionEnd(),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),document.removeEventListener(`keydown`,this.handleKeyDown,!0)):e!==`UNLOADED`&&t===`UNLOADED`&&(this.bodyScrollEnable(),window.removeEventListener(`resize`,this.handleResize),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),this.refDialog.current?.close())},this.setId=()=>{let e=()=>Math.random().toString(16).slice(-4);this.setState({id:e()+e()+e()})},this.setAndTrackImg=()=>{let{refContent:{current:e}}=this;e!=null&&(this.imgEl=e.querySelector(U_),this.imgEl===null?this.contentNotFoundChangeObserver??(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(e,{childList:!0,subtree:!0})):(this.contentNotFoundChangeObserver?.disconnect(),this.imgEl.addEventListener(`load`,this.handleImgLoad),this.imgEl.addEventListener(`click`,this.handleZoom),this.state.loadedImgEl??this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(e=>{let[t]=e;t?.target!==void 0&&(this.imgEl=t.target,this.setState({styleGhost:V_(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:V_(this.imgEl)})}),this.contentChangeObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}))))},this.handleIfZoomChanged=e=>{let{props:{isZoomed:t}}=this;!e&&t?this.zoom():e&&!t&&this.unzoom()},this.handleImgLoad=()=>{let e=N_(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(E_(n)){let{sizes:e,srcset:r,crossOrigin:i}=n;t.sizes=e,t.srcset=r,t.crossOrigin=i}t.src=e;let r=()=>{this.setState({loadedImgEl:t,styleGhost:V_(this.imgEl)})};t.decode().then(r).catch(()=>{if(D_(t)){r();return}t.onload=r})},this.handleZoom=e=>{this.props.isDisabled!==!0&&this.hasImage()&&this.props.onZoomChange?.(!0,{event:e})},this.handleUnzoom=e=>{this.props.isDisabled!==!0&&this.props.onZoomChange?.(!1,{event:e})},this.handleBtnUnzoomClick=e=>{e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e)},this.handleDialogClick=e=>{(e.target===this.refModalContent.current||e.target===this.refModalImg.current)&&(e.stopPropagation(),this.handleUnzoom(e))},this.handleDialogClose=e=>{e.stopPropagation(),this.handleUnzoom(e)},this.handleKeyDown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.handleUnzoom(e))},this.handleWheel=e=>{e.ctrlKey||(e.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(e)}))},this.handleTouchStart=e=>{if(e.touches.length>1){this.isScaling=!0;return}let{changedTouches:t}=e,[n]=t;if(t.length===1&&n!==void 0){let{screenY:e}=n;this.touchYStart=e}},this.handleTouchMove=e=>{let t=window.visualViewport?.scale??1,{changedTouches:n}=e,[r]=n;if(this.props.canSwipeToUnzoom&&!this.isScaling&&t<=1&&this.touchYStart!=null&&r!==void 0){let{screenY:t}=r;this.touchYEnd=t;let n=Math.max(this.touchYStart,this.touchYEnd),i=Math.min(this.touchYStart,this.touchYEnd);Math.abs(n-i)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(e))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl!==null&&(this.state.loadedImgEl!==void 0||O_(this.imgEl))&&window.getComputedStyle(this.imgEl).display!==`none`,this.zoom=()=>{this.bodyScrollDisable(),this.refDialog.current?.showModal(),this.refModalImg.current?.addEventListener(`transitionend`,this.handleImgTransitionEnd),this.setState({modalState:`LOADING`})},this.unzoom=()=>{this.setState({modalState:`UNLOADING`})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState===`LOADING`?this.setState({modalState:`LOADED`}):this.state.modalState===`UNLOADING`&&this.setState({shouldRefresh:!1,modalState:`UNLOADED`})},this.ensureImgTransitionEnd=()=>{if(this.refModalImg.current!==null){let{transitionDuration:e}=window.getComputedStyle(this.refModalImg.current),t=parseFloat(e);if(t!==0&&!Number.isNaN(t)){let n=t*(e.endsWith(`ms`)?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,n)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};let{body:{clientWidth:e}}=document;document.body.style.overflow=`hidden`,document.body.style.width=`${e}px`},this.bodyScrollEnable=()=>{let{prevBodyAttrs:{overflow:e,width:t}}=this;document.body.style.width=t,document.body.style.overflow=e,this.prevBodyAttrs=W_},this.loadZoomImg=()=>{let{props:{zoomImg:e}}=this;if(e==null)return;let{src:t}=e;if(t!==void 0&&t!==``){let n=new Image;n.sizes=e.sizes??``,n.srcset=e.srcSet??``,n.crossOrigin=e.crossOrigin??void 0,n.src=t;let r=()=>{this.setState({isZoomImgLoaded:!0})};n.decode().then(r).catch(()=>{if(D_(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(O_(e)){let r=e.cloneNode(!0);H_(r),r.style.width=`${n.width??0}px`,r.style.height=`${n.height??0}px`,r.addEventListener(`click`,this.handleUnzoom),t.current?.firstChild?.remove(),t.current?.appendChild(r)}}}render(){let{handleBtnUnzoomClick:e,handleDialogClick:t,handleDialogClose:n,handleUnzoom:r,handleZoom:i,imgEl:a,props:{a11yNameButtonUnzoom:o,a11yNameButtonZoom:s,children:c,classDialog:l,IconUnzoom:u,IconZoom:d,isZoomed:f,wrapElement:p,ZoomContent:m,zoomImg:h,zoomMargin:g},refContent:_,refDialog:v,refModalContent:y,refModalImg:b,refWrap:x,state:{id:S,isZoomImgLoaded:C,loadedImgEl:w,modalState:T,shouldRefresh:E,styleGhost:D}}=this,O=`rmiz-modal-${S}`,k=`rmiz-modal-img-${S}`,A=T_(a),j=E_(a),M=O_(a),N=P_(a),P=N_(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,R=h?.src!==void 0&&h.src!==``,ee=this.hasImage(),z=N!==void 0&&N!==``?`${s}: ${N}`:s,te=T===`LOADING`||T===`LOADED`,ne=ee?`found`:`not-found`,re=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,B={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=ee&&a!==null?B_({hasZoomImg:R,imgSrc:P,isSvg:M,isZoomed:f&&te,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let V=null;if(ee){let t=j||A?Q.createElement(`img`,{alt:N,crossOrigin:L,sizes:F,src:P,srcSet:I,...C&&T===`LOADED`?h:{},"data-rmiz-modal-img":``,height:this.styleModalImg.height??void 0,id:k,ref:b,style:this.styleModalImg,width:this.styleModalImg.width??void 0}):M?Q.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Q.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Q.createElement(u,null));V=m==null?Q.createElement(Q.Fragment,null,t,n):Q.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Q.createElement(p,{"aria-owns":ee?O:void 0,"data-rmiz":``,ref:x},Q.createElement(p,{"data-rmiz-content":ne,ref:_,style:B},c),ee&&Q.createElement(p,{"data-rmiz-ghost":``,style:D},Q.createElement(`button`,{"aria-label":z,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Q.createElement(d,null))),ee&&Io.createPortal(Q.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:K_,ref:v,role:`dialog`},Q.createElement(`div`,{"data-rmiz-modal-overlay":re}),Q.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},V)),G_()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){this.state.modalState!==`UNLOADED`&&this.bodyScrollEnable(),this.contentChangeObserver?.disconnect(),this.contentNotFoundChangeObserver?.disconnect(),this.imgElResizeObserver?.disconnect(),this.imgEl?.removeEventListener(`load`,this.handleImgLoad),this.imgEl?.removeEventListener(`click`,this.handleZoom),this.refModalImg.current?.removeEventListener(`transitionend`,this.handleImgTransitionEnd),window.removeEventListener(`wheel`,this.handleWheel),window.removeEventListener(`touchstart`,this.handleTouchStart),window.removeEventListener(`touchmove`,this.handleTouchMove),window.removeEventListener(`touchend`,this.handleTouchEnd),window.removeEventListener(`touchcancel`,this.handleTouchCancel),window.removeEventListener(`resize`,this.handleResize),document.removeEventListener(`keydown`,this.handleKeyDown,!0)}componentDidUpdate(e,t){this.handleModalStateChange(t.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(e.isZoomed)}};J_.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:x_,IconZoom:S_,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function Y_({onZoomChange:e,...t}){let[n,r]=Q.useState(!1),i=Q.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Q.createElement(q_,{...t,isZoomed:n,onZoomChange:i})}function X_(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function Z_(e,t,n){return X_(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function Q_(e){let t=(0,$.c)(52),n,r,i,a,o,c,l,u,d,f,p,m;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12]):({width:m,height:r,loadingTestId:d,slotTestId:f,slotClassName:c,className:n,onLoad:o,onError:a,src:l,style:u,alt:p,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m);let h=d===void 0?`image-loading-skeleton`:d,g=f===void 0?`image-slot`:f,_=p===void 0?``:p,{_:v}=s(),y=(0,Q.useRef)(null),[b,x]=(0,Q.useState)(!1),S;t[13]!==r||t[14]!==m?(S=X_(m,r),t[13]=r,t[14]=m,t[15]=S):S=t[15];let C=S,w;t[16]!==r||t[17]!==u||t[18]!==m?(w=Z_(m,r,u),t[16]=r,t[17]=u,t[18]=m,t[19]=w):w=t[19];let T=w,E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{y.current?.complete?x(!0):x(!1)},t[20]=E):E=t[20];let D;t[21]===l?D=t[22]:(D=[l],t[21]=l,t[22]=D),(0,Q.useLayoutEffect)(E,D);let O=!C&&!b&&`aspect-[16/9] w-full max-w-full`,k;t[23]!==c||t[24]!==O?(k=Ft(`relative inline-block overflow-hidden`,O,c),t[23]=c,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==v||t[27]!==b||t[28]!==h?(A=!b&&(0,Z.jsx)(`span`,{"data-testid":h,role:`status`,"aria-busy":`true`,"aria-label":v({id:`N1YYa7`}),className:`absolute inset-0 animate-pulse rounded-md bg-muted motion-reduce:animate-none`}),t[26]=v,t[27]=b,t[28]=h,t[29]=A):A=t[29];let j=b?`opacity-100`:`opacity-0`,M;t[30]!==n||t[31]!==j?(M=Ft(`block max-w-full transition-opacity motion-reduce:transition-none`,j,n),t[30]=n,t[31]=j,t[32]=M):M=t[32];let N;t[33]===o?N=t[34]:(N=e=>{x(!0),o?.(e)},t[33]=o,t[34]=N);let P;t[35]===a?P=t[36]:(P=e=>{x(!0),a?.(e)},t[35]=a,t[36]=P);let F;t[37]!==_||t[38]!==r||t[39]!==i||t[40]!==l||t[41]!==M||t[42]!==N||t[43]!==P||t[44]!==m?(F=(0,Z.jsx)(`img`,{...i,ref:y,src:l,alt:_,width:m,height:r,className:M,onLoad:N,onError:P}),t[37]=_,t[38]=r,t[39]=i,t[40]=l,t[41]=M,t[42]=N,t[43]=P,t[44]=m,t[45]=F):F=t[45];let I;return t[46]!==T||t[47]!==g||t[48]!==A||t[49]!==F||t[50]!==k?(I=(0,Z.jsxs)(`span`,{"data-testid":g,className:k,style:T,children:[A,F]}),t[46]=T,t[47]=g,t[48]=A,t[49]=F,t[50]=k,t[51]=I):I=t[51],I}function $_(e){return e??`lazy`}function ev(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function tv(e){let t=(0,$.c)(21),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:le(e.src),t[0]=e.src,t[1]=n);let r=e.alt??``,i;t[2]===e.width?i=t[3]:(i=ev(e.width),t[2]=e.width,t[3]=i);let a;t[4]===e.height?a=t[5]:(a=ev(e.height),t[4]=e.height,t[5]=a);let o=e.title,s;t[6]===e.loading?s=t[7]:(s=$_(e.loading),t[6]=e.loading,t[7]=s);let c;return t[8]!==e.crossorigin||t[9]!==e.decoding||t[10]!==e.fetchpriority||t[11]!==e.referrerpolicy||t[12]!==e.sizes||t[13]!==e.srcset||t[14]!==e.title||t[15]!==n||t[16]!==r||t[17]!==i||t[18]!==a||t[19]!==s?(c=(0,Z.jsx)(Q_,{src:n,alt:r,width:i,height:a,title:o,loading:s,srcSet:e.srcset,sizes:e.sizes,decoding:e.decoding,fetchPriority:e.fetchpriority,crossOrigin:e.crossorigin,referrerPolicy:e.referrerpolicy}),t[8]=e.crossorigin,t[9]=e.decoding,t[10]=e.fetchpriority,t[11]=e.referrerpolicy,t[12]=e.sizes,t[13]=e.srcset,t[14]=e.title,t[15]=n,t[16]=r,t[17]=i,t[18]=a,t[19]=s,t[20]=c):c=t[20],c}function nv(e){let t=(0,$.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,Z.jsx)(Y_,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,Z.jsx)(tv,{...e})}),t[1]=e,t[2]=r),r}var rv=(0,Q.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-BunQWEOH.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,$.c)(7),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!0,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;n[2]===i?a=n[3]:(a={__html:i},n[2]=i,n[3]=a);let o;return n[4]!==t.id||n[5]!==a?(o=(0,Z.jsx)(`div`,{className:`math math-display`,"data-component-type":`math`,id:t.id,dangerouslySetInnerHTML:a}),n[4]=t.id,n[5]=a,n[6]=o):o=n[6],o}return{default:t}});function iv(e){let t=(0,$.c)(3),n=e.formula||`\xA0`,r;return t[0]!==e.id||t[1]!==n?(r=(0,Z.jsx)(`div`,{className:`math math-placeholder`,"data-component-type":`math`,id:e.id,children:n}),t[0]=e.id,t[1]=n,t[2]=r):r=t[2],r}function av(e){let t=(0,$.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,Z.jsx)(iv,{formula:n,id:e.id}),t[0]=n,t[1]=e.id,t[2]=r):r=t[2],r}let r;return t[3]!==n||t[4]!==e.id?(r=(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(iv,{formula:n,id:e.id}),children:(0,Z.jsx)(rv,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}function ov(e,t){if(e.type===`mdxJsxFlowElement`){let n=e;if(n.name===`MirrorSource`){for(let e of n.attributes??[])if(e.type===`mdxJsxAttribute`&&e.name===`id`&&typeof e.value==`string`&&e.value===t)return n}}let n=e.children;if(Array.isArray(n))for(let e of n){let n=ov(e,t);if(n)return n}return null}function sv(e){return Le({type:`root`,children:e.children??[]})}var cv=new Map,lv=30,uv=150,dv=1e4;function fv(e,t){let n=`${e}|${t}`,r=cv.get(n);if(r)return r.refcount+=1,r;let i=new ia,a=new Ki({url:e,name:t,document:i}),o=new Set,s={provider:a,ySource:i.getText(`source`),refcount:1,synced:!1,subscribers:o};return a.on(`synced`,()=>{s.synced=!0;for(let e of o)e.onSynced()}),s.ySource.observe(()=>{for(let e of o)e.onUpdate()}),cv.set(n,s),cv.size>lv&&console.warn(`[Mirror] provider pool exceeded ${lv} entries (current=${cv.size}). Many Mirrors pointing at distinct source docs — investigate if this is a runaway pattern.`),s}function pv(e,t){let n=`${e}|${t}`,r=cv.get(n);if(r&&(--r.refcount,r.refcount<=0)){try{r.provider.destroy()}catch(e){console.warn(`[Mirror] provider.destroy() failed during release`,{src:t,err:e})}cv.delete(n)}}function mv(e,t){let n=(0,$.c)(8),{collabUrl:r}=sd(),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={kind:`loading`},n[0]=i):i=n[0];let[a,o]=(0,Q.useState)(i),s=(0,Q.useRef)(t),c=(0,Q.useRef)(null),l,u;n[1]!==r||n[2]!==e?(l=()=>{if(!e){o({kind:`empty-props`});return}if(!r){o({kind:`loading`});return}let t=fv(r,e),n=()=>{let n=s.current;if(!n){o({kind:`empty-props`});return}let r=t.ySource.toString();if(!r){o(t.synced?{kind:`source-removed`}:{kind:`loading`});return}let i;try{i=qt().parseToMdast(r)}catch(t){console.warn(`[Mirror] parseToMdast failed`,{src:e,anchor:n,err:t}),o({kind:`source-removed`});return}let a=ov(i,n);if(!a){o({kind:`anchor-not-found`});return}let c;try{c=sv(a)}catch(t){console.warn(`[Mirror] renderMirrorSubtree failed`,{src:e,anchor:n,err:t}),o({kind:`anchor-not-found`});return}o({kind:`ready`,html:c})},i=null,a={onUpdate:()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,n()},uv)},onSynced:()=>{i&&=(clearTimeout(i),null),n()}};t.subscribers.add(a),c.current=n;let l=setTimeout(()=>{t.synced||o({kind:`source-removed`})},dv);return n(),()=>{clearTimeout(l),i&&clearTimeout(i),t.subscribers.delete(a),c.current=null,pv(r,e)}},u=[r,e],n[1]=r,n[2]=e,n[3]=l,n[4]=u):(l=n[3],u=n[4]),(0,Q.useEffect)(l,u);let d,f;return n[5]===t?(d=n[6],f=n[7]):(d=()=>{s.current=t,c.current?.()},f=[t],n[5]=t,n[6]=d,n[7]=f),(0,Q.useEffect)(d,f),a}function hv(e){let t=(0,$.c)(8),n=`ok-mirror-state flex items-start gap-2 rounded-md border border-dashed px-3 py-2 text-sm ${e.tone===`error`?`border-destructive/40 text-destructive`:`border-border text-muted-foreground`}`,r;t[0]===e.tone?r=t[1]:(r=e.tone===`error`?(0,Z.jsx)(lo,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,Z.jsx)(fo,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}),t[0]=e.tone,t[1]=r);let i;t[2]===e.children?i=t[3]:(i=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children}),t[2]=e.children,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,Z.jsxs)(`div`,{className:n,children:[r,i]}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function gv(e){let t=(0,$.c)(30),n=e.src??``,r=e.anchor??``,i=mv(n,r);if(i.kind===`empty-props`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(hv,{tone:`placeholder`,children:(0,Z.jsx)(o,{id:`3SDfZl`,components:{0:(0,Z.jsx)(`span`,{className:`font-medium`}),1:(0,Z.jsx)(`code`,{}),2:(0,Z.jsx)(`code`,{}),3:(0,Z.jsx)(`code`,{})}})}),t[0]=e):e=t[0],e}if(i.kind===`loading`){let e=n&&r?`${n}#${r}`:``,i;t[1]===e?i=t[2]:(i={mirrorRef:e},t[1]=e,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a={0:(0,Z.jsx)(`code`,{})},t[3]=a):a=t[3];let s;return t[4]===i?s=t[5]:(s=(0,Z.jsx)(hv,{tone:`placeholder`,children:(0,Z.jsx)(o,{id:`92rbk2`,values:i,components:a})}),t[4]=i,t[5]=s),s}if(i.kind===`source-removed`){let e;t[6]===n?e=t[7]:(e={src:n},t[6]=n,t[7]=e);let r;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(r={0:(0,Z.jsx)(`span`,{className:`font-medium`}),1:(0,Z.jsx)(`code`,{})},t[8]=r):r=t[8];let i;return t[9]===e?i=t[10]:(i=(0,Z.jsx)(hv,{tone:`error`,children:(0,Z.jsx)(o,{id:`Ud0Pj9`,values:e,components:r})}),t[9]=e,t[10]=i),i}if(i.kind===`anchor-not-found`){let e=`<MirrorSource id="${r}">`,i;t[11]!==e||t[12]!==n?(i={mirrorSourceTag:e,src:n},t[11]=e,t[12]=n,t[13]=i):i=t[13];let a;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(a={0:(0,Z.jsx)(`span`,{className:`font-medium`}),1:(0,Z.jsx)(`code`,{}),2:(0,Z.jsx)(`code`,{})},t[14]=a):a=t[14];let s;return t[15]===i?s=t[16]:(s=(0,Z.jsx)(hv,{tone:`error`,children:(0,Z.jsx)(o,{id:`mqSwZH`,values:i,components:a})}),t[15]=i,t[16]=s),s}let a;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Jn,{className:`size-3`,"aria-hidden":`true`}),t[17]=a):a=t[17];let s;t[18]===n?s=t[19]:(s={src:n},t[18]=n,t[19]=s);let c;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(c={0:(0,Z.jsx)(`code`,{className:`font-mono`})},t[20]=c):c=t[20];let l;t[21]===s?l=t[22]:(l=(0,Z.jsxs)(`div`,{className:`ok-mirror-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,"aria-hidden":`true`,children:[a,(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`wQp1V3`,values:s,components:c})})]}),t[21]=s,t[22]=l);let u;t[23]===i.html?u=t[24]:(u=(0,Z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:i.html}}),t[23]=i.html,t[24]=u);let d;return t[25]!==r||t[26]!==n||t[27]!==l||t[28]!==u?(d=(0,Z.jsxs)(`div`,{className:`ok-mirror-resolved relative -mx-3 prose-no-margin rounded-md border border-dashed border-transparent px-3 py-2 transition-colors [.jsx-component-wrapper:hover_&]:border-border/40 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/40`,"data-mirror-src":n,"data-mirror-anchor":r,children:[l,u]}),t[25]=r,t[26]=n,t[27]=l,t[28]=u,t[29]=d):d=t[29],d}function _v(e){let t=(0,$.c)(15),{_:n}=s(),r=e.id??``,i;t[0]!==n||t[1]!==r?(i=r||n({id:`12F9WL`}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(Yn,{className:`size-3`,"aria-hidden":`true`}),t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l={label:a},t[4]=a,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={0:(0,Z.jsx)(`code`,{className:`font-mono`})},t[6]=u):u=t[6];let d;t[7]===l?d=t[8]:(d=(0,Z.jsxs)(`div`,{className:`ok-mirror-source-badge pointer-events-none absolute -top-2.5 left-2 flex items-center gap-1 rounded-md bg-background px-1.5 text-xs text-muted-foreground opacity-0 transition-opacity [.jsx-component-wrapper:hover_&]:opacity-100 [.jsx-component-wrapper[data-selected="true"]_&]:opacity-100`,children:[c,(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`Zon_qG`,values:l,components:u})})]}),t[7]=l,t[8]=d);let f;t[9]===e.children?f=t[10]:(f=(0,Z.jsx)(`div`,{children:e.children}),t[9]=e.children,t[10]=f);let p;return t[11]!==r||t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`div`,{className:`ok-mirror-source relative -mx-3 rounded-md border border-dashed border-transparent px-3 py-1 transition-colors [.jsx-component-wrapper:hover_&]:border-border/50 [.jsx-component-wrapper[data-selected="true"]_&]:border-border/50`,"data-mirror-source-id":r,children:[d,f]}),t[11]=r,t[12]=d,t[13]=f,t[14]=p):p=t[14],p}var vv=24,yv=24,bv=12,xv=.1;function Sv(e,t,n,r){if(n<=0&&(e===`fit-width`||e===`two-odd`||e===`two-even`)||r<=0&&e===`fit-height`)return 1;switch(e){case`fit-width`:return Math.max(xv,(n-vv)/t.naturalWidth);case`fit-height`:return Math.max(xv,(r-yv)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(xv,((n-vv)/2-bv)/t.naturalWidth)}}var Cv=600,wv=.5,Tv=3,Ev=.25,Dv=null;function Ov(){return Dv||(Dv=(async()=>{let e=await n(()=>import(`./pdf-WLEpkBFf.js`),__vite__mapDeps([0,1]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-BZkygqjt.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),Dv.catch(()=>{Dv=null})),Dv}function kv(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function Av(e){let t=(0,$.c)(96),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=nt(e.anchor);n=i===null?e.fillContainer?`100%`:`${Cv}px`:`${i}px`,r=Iv(a),t[0]=e.anchor,t[1]=e.fillContainer,t[2]=n,t[3]=r}else n=t[2],r=t[3];let i=r,a=(0,Q.useRef)(null),c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[4]=c):c=t[4];let l=(0,Q.useRef)(c),u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[5]=u):u=t[5];let d=(0,Q.useRef)(u),f=(0,Q.useRef)(null),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[6]=p):p=t[6];let[m,h]=(0,Q.useState)(p),[g,_]=(0,Q.useState)(!0),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(i??1),[S,C]=(0,Q.useState)(String(i??1)),[w,T]=(0,Q.useState)(1),[E,D]=(0,Q.useState)(`fit-width`),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(0),[P,F]=(0,Q.useState)(0),{_:I}=s(),L=m.length,R,ee;t[7]!==I||t[8]!==e.src?(R=()=>{if(!e.src){_(!1);return}let t=le(e.src),n=!1,r=null;return _(!0),y(null),(async()=>{try{let e=await(await Ov()).getDocument({url:t,isEvalSupported:!1}).promise;if(n){await e.destroy();return}r=e,f.current=e;let i=[];for(let t=1;t<=e.numPages;t++){if(n)return;let r=(await e.getPage(t)).getViewport({scale:1});i.push({pageNumber:t,naturalWidth:r.width,naturalHeight:r.height})}if(n)return;h(i)}catch(e){let t=e;if(n)return;y(t instanceof Error?t.message:I({id:`jRHdCz`})),_(!1)}})(),()=>{n=!0,r&&=(r.destroy(),null),f.current=null}},ee=[e.src,I],t[7]=I,t[8]=e.src,t[9]=R,t[10]=ee):(R=t[9],ee=t[10]),(0,Q.useEffect)(R,ee);let z,te;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>{let e=a.current;if(!e)return;let t=()=>{N(e.clientWidth),F(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},te=[],t[11]=z,t[12]=te):(z=t[11],te=t[12]),(0,Q.useEffect)(z,te);let ne,re;t[13]!==I||t[14]!==P||t[15]!==M||t[16]!==E||t[17]!==m||t[18]!==w?(ne=()=>{let e=f.current;if(!e||m.length===0||M===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=l.current[i.pageNumber-1];if(!a)continue;let o=Sv(E,i,M,P)*w,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let u=a.getContext(`2d`);u&&(u.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:u,viewport:c}),await n.promise,n=null)}t||_(!1)}catch(e){let n=e;if(t||kv(n))return;console.warn(`[Pdf] page render failed:`,n),y(n instanceof Error?n.message:I({id:`_TF8ep`})),_(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},re=[m,E,w,M,P,I],t[13]=I,t[14]=P,t[15]=M,t[16]=E,t[17]=m,t[18]=w,t[19]=ne,t[20]=re):(ne=t[19],re=t[20]),(0,Q.useEffect)(ne,re);let B,V;t[21]!==m||t[22]!==O?(B=()=>{if(!O)return;let e=f.current;if(!e||m.length===0)return;let t=!1,n=null;return(async()=>{try{let r=window.devicePixelRatio||1;for(let i of m){if(t)return;let a=d.current[i.pageNumber-1];if(!a)continue;let o=120/i.naturalWidth,s=await e.getPage(i.pageNumber);if(t)return;let c=s.getViewport({scale:o});a.width=Math.floor(c.width*r),a.height=Math.floor(c.height*r),a.style.width=`${c.width}px`,a.style.height=`${c.height}px`;let l=a.getContext(`2d`);l&&(l.setTransform(r,0,0,r,0,0),n=s.render({canvas:a,canvasContext:l,viewport:c}),await n.promise,n=null)}}catch(e){let t=e;kv(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},V=[O,m],t[21]=m,t[22]=O,t[23]=B,t[24]=V):(B=t[23],V=t[24]),(0,Q.useEffect)(B,V);let H,U;t[25]!==g||t[26]!==i?(H=()=>{if(g||!i)return;let e=a.current,t=l.current[i-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},U=[g,i],t[25]=g,t[26]=i,t[27]=H,t[28]=U):(H=t[27],U=t[28]),(0,Q.useEffect)(H,U);let W,G;t[29]===m?(W=t[30],G=t[31]):(W=()=>{let e=a.current;if(!e||m.length===0)return;let t=!1,n=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let n=e.scrollTop,r=1;for(let t of m){let i=l.current[t.pageNumber-1];i&&i.offsetTop-e.offsetTop<=n+40&&(r=t.pageNumber)}x(r),C(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},G=[m],t[29]=m,t[30]=W,t[31]=G),(0,Q.useEffect)(W,G);let ie,K;t[32]===A?(ie=t[33],K=t[34]):(ie=()=>{if(!A)return;let e=e=>{let t=e.target,n=a.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){j(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&j(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},K=[A],t[32]=A,t[33]=ie,t[34]=K),(0,Q.useEffect)(ie,K);let ae;t[35]===L?ae=t[36]:(ae=e=>{let t=Math.max(1,Math.min(L||1,e));x(t),C(String(t));let n=a.current,r=l.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[35]=L,t[36]=ae);let oe=ae,q;t[37]!==b||t[38]!==oe||t[39]!==S?(q=()=>{let e=Number.parseInt(S,10);if(Number.isNaN(e)){C(String(b));return}oe(e)},t[37]=b,t[38]=oe,t[39]=S,t[40]=q):q=t[40];let se=q,ce;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>T(Pv),t[41]=ce):ce=t[41];let J=ce,ue;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>T(Nv),t[42]=ue):ue=t[42];let Y=ue,de;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>{D(e),j(!1),T(1)},t[43]=de):de=t[43];let fe=de,pe;t[44]===n?pe=t[45]:(pe={height:n},t[44]=n,t[45]=pe);let me;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>k(Mv),t[46]=me):me=t[46];let he;t[47]!==I||t[48]!==O?(he=I(O?{id:`JK-Ave`}:{id:`iEYxO4`}),t[47]=I,t[48]=O,t[49]=he):he=t[49];let ge;t[50]===I?ge=t[51]:(ge=I({id:`zo3Dl7`}),t[50]=I,t[51]=ge);let _e;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(yo,{size:14,"aria-hidden":`true`}),t[52]=_e):_e=t[52];let ve;t[53]!==O||t[54]!==he||t[55]!==ge?(ve=(0,Z.jsx)(`button`,{type:`button`,onClick:me,"aria-label":he,"aria-pressed":O,className:`ok-pdf-btn`,title:ge,children:_e}),t[53]=O,t[54]=he,t[55]=ge,t[56]=ve):ve=t[56];let ye=e.title??`PDF`,be;t[57]===ye?be=t[58]:(be=(0,Z.jsx)(`span`,{className:`ok-pdf-title`,children:ye}),t[57]=ye,t[58]=be);let xe;t[59]!==I||t[60]!==A||t[61]!==E||t[62]!==S||t[63]!==se||t[64]!==L||t[65]!==w?(xe=L>0&&(0,Z.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,Z.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),se()},children:(0,Z.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:S,onChange:e=>C(e.target.value.replace(/[^0-9]/g,``)),onBlur:se,"aria-label":I({id:`xsZhu-`})})}),(0,Z.jsx)(`span`,{className:`ok-pdf-page-of`,children:(0,Z.jsx)(o,{id:`1GhYxC`,values:{totalPages:L}})}),(0,Z.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,Z.jsx)(`button`,{type:`button`,onClick:Y,disabled:w<=wv,"aria-label":I({id:`FjkaiT`}),className:`ok-pdf-btn`,title:I({id:`FjkaiT`}),children:(0,Z.jsx)(Cn,{size:14,"aria-hidden":`true`})}),(0,Z.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(w*100),`%`]}),(0,Z.jsx)(`button`,{type:`button`,onClick:J,disabled:w>=Tv,"aria-label":I({id:`AWOSPo`}),className:`ok-pdf-btn`,title:I({id:`AWOSPo`}),children:(0,Z.jsx)(Pn,{size:14,"aria-hidden":`true`})}),(0,Z.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`ok-pdf-layout-menu`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>j(jv),"aria-label":I({id:`GQDSBN`}),"aria-haspopup":`menu`,"aria-expanded":A,className:`ok-pdf-btn`,title:I({id:`rdU729`}),children:(0,Z.jsx)(Vn,{size:14,"aria-hidden":`true`})}),A&&(0,Z.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,Z.jsx)(Fv,{label:I({id:`vIxrEk`}),active:E===`fit-width`,onSelect:()=>fe(`fit-width`)}),(0,Z.jsx)(Fv,{label:I({id:`YlDuro`}),active:E===`fit-height`,onSelect:()=>fe(`fit-height`)}),(0,Z.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,Z.jsx)(Fv,{label:I({id:`BGHHtQ`}),active:E===`single`,onSelect:()=>fe(`single`)}),(0,Z.jsx)(Fv,{label:I({id:`xK291b`}),active:E===`two-odd`,onSelect:()=>fe(`two-odd`)}),(0,Z.jsx)(Fv,{label:I({id:`NSnIUP`}),active:E===`two-even`,onSelect:()=>fe(`two-even`)})]})]})]}),t[59]=I,t[60]=A,t[61]=E,t[62]=S,t[63]=se,t[64]=L,t[65]=w,t[66]=xe):xe=t[66];let Se;t[67]!==ve||t[68]!==be||t[69]!==xe?(Se=(0,Z.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[ve,be,xe]}),t[67]=ve,t[68]=be,t[69]=xe,t[70]=Se):Se=t[70];let Ce;t[71]!==I||t[72]!==b||t[73]!==oe||t[74]!==m||t[75]!==O?(Ce=O&&(0,Z.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":I({id:`nzaV6Q`}),children:m.map((e,t)=>{let{pageNumber:n}=e;return(0,Z.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":b===n||void 0,onClick:()=>oe(n),"aria-label":I({id:`qioCwA`,values:{pageNumber:n}}),children:[(0,Z.jsx)(`canvas`,{ref:e=>{d.current[t]=e},className:`ok-pdf-thumb-canvas`}),(0,Z.jsx)(`span`,{className:`ok-pdf-thumb-num`,children:n})]},n)})}),t[71]=I,t[72]=b,t[73]=oe,t[74]=m,t[75]=O,t[76]=Ce):Ce=t[76];let we;t[77]===g?we=t[78]:(we=g&&(0,Z.jsx)(`div`,{className:`ok-pdf-loading`,children:(0,Z.jsx)(o,{id:`T-654M`})}),t[77]=g,t[78]=we);let Te;t[79]===v?Te=t[80]:(Te=v&&(0,Z.jsx)(`div`,{className:`ok-pdf-error`,children:(0,Z.jsx)(o,{id:`WamGNs`,values:{error:v}})}),t[79]=v,t[80]=Te);let Ee;t[81]!==I||t[82]!==L?(Ee=Array.from({length:L},(e,t)=>{let n=t+1;return(0,Z.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-page`,"aria-label":I({id:`XtRoxT`,values:{pageNumber:n}})},n)}),t[81]=I,t[82]=L,t[83]=Ee):Ee=t[83];let De;t[84]!==E||t[85]!==we||t[86]!==Te||t[87]!==Ee?(De=(0,Z.jsxs)(`div`,{className:`ok-pdf-pages`,ref:a,"data-layout":E,children:[we,Te,Ee]}),t[84]=E,t[85]=we,t[86]=Te,t[87]=Ee,t[88]=De):De=t[88];let Oe;t[89]!==Ce||t[90]!==De?(Oe=(0,Z.jsxs)(`div`,{className:`ok-pdf-body`,children:[Ce,De]}),t[89]=Ce,t[90]=De,t[91]=Oe):Oe=t[91];let ke;return t[92]!==pe||t[93]!==Se||t[94]!==Oe?(ke=(0,Z.jsxs)(`div`,{className:`ok-pdf`,style:pe,children:[Se,Oe]}),t[92]=pe,t[93]=Se,t[94]=Oe,t[95]=ke):ke=t[95],ke}function jv(e){return!e}function Mv(e){return!e}function Nv(e){return Math.max(wv,+(e-Ev).toFixed(2))}function Pv(e){return Math.min(Tv,+(e+Ev).toFixed(2))}function Fv(e){let t=(0,$.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,Z.jsx)(Bn,{size:14}),t[0]=e.active,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,Z.jsx)(`span`,{className:`ok-pdf-menu-check`,"aria-hidden":`true`,children:r}),t[2]=r,t[3]=i);let a;return t[4]!==e.active||t[5]!==e.label||t[6]!==e.onSelect||t[7]!==n||t[8]!==i?(a=(0,Z.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.active,className:`ok-pdf-menu-item`,"data-active":n,onClick:e.onSelect,children:[i,e.label]}),t[4]=e.active,t[5]=e.label,t[6]=e.onSelect,t[7]=n,t[8]=i,t[9]=a):a=t[9],a}function Iv(e){if(!e)return null;for(let t of e.split(`&`)){let e=t.indexOf(`=`);if(!(e<0)&&t.slice(0,e)===`page`){let n=Number.parseInt(t.slice(e+1),10);if(!Number.isNaN(n)&&n>=1)return n}}return null}function Lv(e){let t=(0,$.c)(10),{label:n,id:r,children:i}=e,a=(0,Q.useId)(),o;t[0]!==r||t[1]!==a?(o=r||`tab-panel-${a.replace(/:/g,``)}`,t[0]=r,t[1]=a,t[2]=o):o=t[2];let s=o,c=`${s}-tab`,l;t[3]===n?l=t[4]:(l=n?.trim()||`Tab`,t[3]=n,t[4]=l);let u=l,d;return t[5]!==i||t[6]!==s||t[7]!==u||t[8]!==c?(d=(0,Z.jsx)(`section`,{className:`tab-panel`,id:s,role:`tabpanel`,"aria-labelledby":c,"data-tab-label":u,"data-tab-id":s,children:i}),t[5]=i,t[6]=s,t[7]=u,t[8]=c,t[9]=d):d=t[9],d}var Rv=`:scope > .component-children > [data-node-view-content-react] > .react-renderer`;function zv(e){return Array.from(e.querySelectorAll(Rv)).map((e,t)=>{let n=e.querySelector(`[data-tab-label]`);return{index:t,label:(n?.getAttribute(`data-tab-label`))?.trim()||`Tab ${t+1}`,panelId:n?.getAttribute(`data-tab-id`)??null}})}function Bv(e,t){let n=Array.from(e.querySelectorAll(Rv))[t];return n?n.querySelector(`[data-jsx-gear]`):null}function Vv(e){let t=(0,$.c)(31),{id:n,children:r}=e,[i,a]=(0,Q.useState)(0),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0];let[c,l]=(0,Q.useState)(o),u=(0,Q.useRef)(null),d=(0,Q.useRef)(null),f=(0,Q.useRef)(0),p=zn(),m=p?.addChild!=null,{_:h}=s(),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=u.current;if(!e)return;let t=zv(e);l(e=>{if(e.length!==t.length)return t;for(let n=0;n<e.length;n++)if(e[n].label!==t[n].label||e[n].panelId!==t[n].panelId)return t;return e})},t[1]=g):g=t[1],(0,Q.useLayoutEffect)(g);let _,v;t[2]===c.length?(_=t[3],v=t[4]):(_=()=>{c.length>f.current&&c.length>0&&a(c.length-1),f.current=c.length},v=[c.length],t[2]=c.length,t[3]=_,t[4]=v),(0,Q.useLayoutEffect)(_,v);let y;t[5]===n?y=t[6]:(y=()=>{let e=()=>{let e=window.location.hash.slice(1);if(!e)return;if(n&&e===n){a(0);return}let t=u.current;if(!t)return;let r=zv(t).findIndex(t=>t.panelId===e);r<0||(a(r),queueMicrotask(()=>{t.ownerDocument.getElementById(e)?.scrollIntoView({block:`start`,behavior:`auto`})}))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},t[5]=n,t[6]=y),(0,Q.useLayoutEffect)(y);let b=c.length===0?0:Math.min(Math.max(i,0),c.length-1),x;t[7]!==c.length||t[8]!==b?(x=e=>{if(c.length===0)return;let t=null;e.key===`ArrowRight`?t=(b+1)%c.length:e.key===`ArrowLeft`?t=(b-1+c.length)%c.length:e.key===`Home`?t=0:e.key===`End`&&(t=c.length-1),t!==null&&(e.preventDefault(),a(t),(d.current?.querySelectorAll(`[role="tab"]`))?.[t]?.focus())},t[7]=c.length,t[8]=b,t[9]=x):x=t[9];let S=x,C=n?`Tabs: ${n}`:`Tabs`,w;t[10]!==c||t[11]!==b?(w=c.map(e=>(0,Z.jsx)(`button`,{id:e.panelId?`${e.panelId}-tab`:void 0,type:`button`,role:`tab`,className:`tabs-strip-pill`,"data-active":e.index===b,"aria-selected":e.index===b,"aria-controls":e.panelId??void 0,tabIndex:e.index===b?0:-1,onMouseDown:Uv,onClick:()=>{if(e.index!==b){a(e.index);return}let t=u.current;t&&Bv(t,e.index)?.click()},children:e.label},e.index)),t[10]=c,t[11]=b,t[12]=w):w=t[12];let T;t[13]!==S||t[14]!==C||t[15]!==w?(T=(0,Z.jsx)(`div`,{ref:d,role:`tablist`,"aria-label":C,className:`tabs-tablist`,onKeyDown:S,children:w}),t[13]=S,t[14]=C,t[15]=w,t[16]=T):T=t[16];let E;t[17]!==h||t[18]!==m||t[19]!==p?(E=m&&(0,Z.jsx)(`button`,{type:`button`,className:`tabs-strip-add`,"aria-label":h({id:`hjO0Mq`}),title:h({id:`hjO0Mq`}),onMouseDown:Hv,onClick:()=>p?.addChild?.(),"data-tabs-strip-add":``,children:`+`}),t[17]=h,t[18]=m,t[19]=p,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==T?(D=(0,Z.jsxs)(`div`,{className:`tabs-strip`,contentEditable:!1,children:[T,E]}),t[21]=E,t[22]=T,t[23]=D):D=t[23];let O;t[24]!==r||t[25]!==b?(O=(0,Z.jsx)(`div`,{ref:u,className:`tabs-content`,"data-active-index":b,children:r}),t[24]=r,t[25]=b,t[26]=O):O=t[26];let k;return t[27]!==n||t[28]!==D||t[29]!==O?(k=(0,Z.jsxs)(`div`,{className:`tabs`,id:n,children:[D,O]}),t[27]=n,t[28]=D,t[29]=O,t[30]=k):k=t[30],k}function Hv(e){return e.preventDefault()}function Uv(e){return e.preventDefault()}var Wv=typeof global<`u`&&{}.toString.call(global)===`[object global]`,Gv=typeof Bun<`u`,Kv=typeof Deno<`u`,qv=typeof WebSocketPair==`function`&&caches?.default!==void 0,Jv=Wv||Gv||Kv||qv;function Yv(e,t){return e.indexOf(t.toLowerCase())===0?e:`${t.toLowerCase()}${e.substr(0,1).toUpperCase()}${e.substr(1)}`}function Xv(e){return!!(e&&e.nodeType===1&&`nodeName`in e&&e.ownerDocument&&e.ownerDocument.defaultView)}function Zv(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function Qv(e){return/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))(?=$|\/)/.test(e)}function $v(e){return/^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))\/video\/\d+/.test(e)}function ey(e){let t=(e||``).match(/^(?:https?:)?(?:\/\/)?([^/?]+)/),n=(t&&t[1]||``).replace(`player.`,``);for(let e of[`.videoji.hk`,`.vimeo.work`,`.videoji.cn`])if(n.endsWith(e))return n;return`vimeo.com`}function ty(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.id,n=e.url,r=t||n;if(!r)throw Error(`An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.`);if(Zv(r))return`https://vimeo.com/${r}`;if(Qv(r))return r.replace(`http:`,`https:`);throw TypeError(t?`“${t}” is not a valid video id.`:`“${r}” is not a vimeo.com url.`)}var ny=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`addEventListener`,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:`removeEventListener`,a=typeof t==`string`?[t]:t;return a.forEach(t=>{e[r](t,n)}),{cancel:()=>a.forEach(t=>e[i](t,n))}};function ry(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:document;if(!e||!t||typeof t.querySelectorAll!=`function`)return null;let n=t.querySelectorAll(`iframe`);for(let t=0;t<n.length;t++)if(n[t]&&n[t].contentWindow===e)return n[t];return null}var iy=Array.prototype.indexOf!==void 0,ay=typeof window<`u`&&window.postMessage!==void 0;if(!Jv&&(!iy||!ay))throw Error(`Sorry, the Vimeo Player API is not available in this browser.`);var oy=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function sy(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e){if(e.WeakMap)return;var t=Object.prototype.hasOwnProperty,n=Object.defineProperty&&function(){try{return Object.defineProperty({},`x`,{value:1}).x===1}catch{}}(),r=function(e,t,r){n?Object.defineProperty(e,t,{configurable:!0,writable:!0,value:r}):e[t]=r};e.WeakMap=function(){function e(){if(this===void 0)throw TypeError(`Constructor WeakMap requires 'new'`);if(r(this,`_id`,a(`_WeakMap`)),arguments.length>0)throw TypeError(`WeakMap iterable is not supported`)}r(e.prototype,`delete`,function(e){if(n(this,`delete`),!i(e))return!1;var t=e[this._id];return t&&t[0]===e?(delete e[this._id],!0):!1}),r(e.prototype,`get`,function(e){if(n(this,`get`),i(e)){var t=e[this._id];if(t&&t[0]===e)return t[1]}}),r(e.prototype,`has`,function(e){if(n(this,`has`),!i(e))return!1;var t=e[this._id];return!!(t&&t[0]===e)}),r(e.prototype,`set`,function(e,t){if(n(this,`set`),!i(e))throw TypeError(`Invalid value used as weak map key`);var a=e[this._id];return a&&a[0]===e?(a[1]=t,this):(r(e,this._id,[e,t]),this)});function n(e,n){if(!i(e)||!t.call(e,`_id`))throw TypeError(n+` method called on incompatible receiver `+typeof e)}function a(e){return e+`_`+o()+`.`+o()}function o(){return Math.random().toString().substring(2)}return r(e,`_polyfill`,!0),e}();function i(e){return Object(e)===e}})(typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:oy);var cy=sy(function(e){(function(t,n,r){n[t]=n[t]||r(),e.exports&&=n[t]})(`Promise`,oy,function(){var e,t,n,r=Object.prototype.toString,i=typeof setImmediate<`u`?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},`x`,{}),e=function(e,t,n,r){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:r!==!1})}}catch{e=function(e,t,n){return e[t]=n,e}}n=function(){var e,n,r;function i(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(t,a){r=new i(t,a),n?n.next=r:e=r,n=r,r=void 0},drain:function(){var r=e;for(e=n=t=void 0;r;)r.fn.call(r.self),r=r.next}}}();function a(e,r){n.add(e,r),t||=i(n.drain)}function o(e){var t,n=typeof e;return e!=null&&(n==`object`||n==`function`)&&(t=e.then),typeof t==`function`?t:!1}function s(){for(var e=0;e<this.chain.length;e++)c(this,this.state===1?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function c(e,t,n){var r,i;try{t===!1?n.reject(e.msg):(r=t===!0?e.msg:t.call(void 0,e.msg),r===n.promise?n.reject(TypeError(`Promise-chain cycle`)):(i=o(r))?i.call(r,n.resolve,n.reject):n.resolve(r))}catch(e){n.reject(e)}}function l(e){var t,n=this;if(!n.triggered){n.triggered=!0,n.def&&(n=n.def);try{(t=o(e))?a(function(){var r=new f(n);try{t.call(e,function(){l.apply(r,arguments)},function(){u.apply(r,arguments)})}catch(e){u.call(r,e)}}):(n.msg=e,n.state=1,n.chain.length>0&&a(s,n))}catch(e){u.call(new f(n),e)}}}function u(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&a(s,t))}function d(e,t,n,r){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){n(i,e)},r)})(i)}function f(e){this.def=e,this.triggered=!1}function p(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function m(e){if(typeof e!=`function`)throw TypeError(`Not a function`);if(this.__NPO__!==0)throw TypeError(`Not a promise`);this.__NPO__=1;var t=new p(this);this.then=function(e,n){var r={success:typeof e==`function`?e:!0,failure:typeof n==`function`?n:!1};return r.promise=new this.constructor(function(e,t){if(typeof e!=`function`||typeof t!=`function`)throw TypeError(`Not a function`);r.resolve=e,r.reject=t}),t.chain.push(r),t.state!==0&&a(s,t),r.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){l.call(t,e)},function(e){u.call(t,e)})}catch(e){u.call(t,e)}}var h=e({},`constructor`,m,!1);return m.prototype=h,e(h,`__NPO__`,0,!1),e(m,`resolve`,function(e){var t=this;return e&&typeof e==`object`&&e.__NPO__===1?e:new t(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);t(e)})}),e(m,`reject`,function(e){return new this(function(t,n){if(typeof t!=`function`||typeof n!=`function`)throw TypeError(`Not a function`);n(e)})}),e(m,`all`,function(e){var t=this;return r.call(e)==`[object Array]`?e.length===0?t.resolve([]):new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);var i=e.length,a=Array(i),o=0;d(t,e,function(e,t){a[e]=t,++o===i&&n(a)},r)}):t.reject(TypeError(`Not an array`))}),e(m,`race`,function(e){var t=this;return r.call(e)==`[object Array]`?new t(function(n,r){if(typeof n!=`function`||typeof r!=`function`)throw TypeError(`Not a function`);d(t,e,function(e,t){n(t)},r)}):t.reject(TypeError(`Not an array`))}),m})}),ly=new WeakMap;function uy(e,t,n){let r=ly.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),ly.set(e.element,r)}function dy(e,t){return(ly.get(e.element)||{})[t]||[]}function fy(e,t,n){let r=ly.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],ly.set(e.element,r),!0;let i=r[t].indexOf(n);return i!==-1&&r[t].splice(i,1),ly.set(e.element,r),r[t]&&r[t].length===0}function py(e,t){let n=dy(e,t);if(n.length<1)return!1;let r=n.shift();return fy(e,t,r),r}function my(e,t){let n=ly.get(e);ly.set(t,n),ly.delete(e)}function hy(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){return console.warn(e),{}}return e}function gy(e,t,n){if(!e.element.contentWindow||!e.element.contentWindow.postMessage)return;let r={method:t};n!==void 0&&(r.value=n);let i=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,`$1`));i>=8&&i<10&&(r=JSON.stringify(r)),e.element.contentWindow.postMessage(r,e.origin)}function _y(e,t){t=hy(t);let n=[],r;if(t.event)t.event===`error`&&dy(e,t.data.method).forEach(n=>{let r=Error(t.data.message);r.name=t.data.name,n.reject(r),fy(e,t.data.method,n)}),n=dy(e,`event:${t.event}`),r=t.data;else if(t.method){let i=py(e,t.method);i&&(n.push(i),r=t.value)}n.forEach(t=>{try{if(typeof t==`function`){t.call(e,r);return}t.resolve(r)}catch{}})}var vy=`airplay.audio_tracks.audiotrack.autopause.autoplay.background.byline.cc.chapter_id.chapters.chromecast.color.colors.controls.disable_context_menu.dnt.end_time.fullscreen.height.id.initial_quality.interactive_params.keyboard.loop.maxheight.max_quality.maxwidth.min_quality.muted.play_button_position.playsinline.portrait.preload.progress_bar.quality.quality_selector.responsive.skipping_forward.speed.start_time.texttrack.thumbnail_id.title.transcript.transparent.unmute_button.url.vimeo_logo.volume.watch_full_video.width`.split(`.`);function yy(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return vy.reduce((t,n)=>{let r=e.getAttribute(`data-vimeo-${n}`);return(r||r===``)&&(t[n]=r===``?1:r),t},t)}function by(e,t){let{html:n}=e;if(!t)throw TypeError(`An element must be provided`);if(t.getAttribute(`data-vimeo-initialized`)!==null)return t.querySelector(`iframe`);let r=document.createElement(`div`);return r.innerHTML=n,t.appendChild(r.firstChild),t.setAttribute(`data-vimeo-initialized`,`true`),t.querySelector(`iframe`)}function xy(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((r,i)=>{if(!Qv(e))throw TypeError(`“${e}” is not a vimeo.com url.`);let a=`https://${ey(e)}/api/oembed.json?url=${encodeURIComponent(e)}`;for(let e in t)t.hasOwnProperty(e)&&(a+=`&${e}=${encodeURIComponent(t[e])}`);let o=`XDomainRequest`in window?new XDomainRequest:new XMLHttpRequest;o.open(`GET`,a,!0),o.onload=function(){if(o.status===404){i(Error(`“${e}” was not found.`));return}if(o.status===403){i(Error(`“${e}” is not embeddable.`));return}try{let t=JSON.parse(o.responseText);if(t.domain_status_code===403){by(t,n),i(Error(`“${e}” is not embeddable.`));return}r(t)}catch(e){i(e)}},o.onerror=function(){let e=o.status?` (${o.status})`:``;i(Error(`There was an error fetching the embed code from Vimeo${e}.`))},o.send()})}function Sy(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document,t=[].slice.call(e.querySelectorAll(`[data-vimeo-id], [data-vimeo-url]`)),n=e=>{`console`in window&&console.error&&console.error(`There was an error creating an embed: ${e}`)};t.forEach(e=>{try{if(e.getAttribute(`data-vimeo-defer`)!==null)return;let t=yy(e);xy(ty(t),t,e).then(t=>by(t,e)).catch(n)}catch(e){n(e)}})}function Cy(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoPlayerResizeEmbeds_||(window.VimeoPlayerResizeEmbeds_=!0,window.addEventListener(`message`,t=>{if(!Qv(t.origin)||!t.data||t.data.event!==`spacechange`)return;let n=t.source?ry(t.source,e):null;if(n){let e=n.parentElement;e.style.paddingBottom=`${t.data.data[0].bottom}px`}}))}function wy(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener(`message`,t=>{if(!Qv(t.origin))return;let n=hy(t.data);if(!n||n.event!==`ready`)return;let r=t.source?ry(t.source,e):null;r&&$v(r.src)&&new Ny(r).callMethod(`appendVideoMetadata`,window.location.href)}))}function Ty(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;if(window.VimeoCheckedUrlTimeParam)return;window.VimeoCheckedUrlTimeParam=!0;let t=e=>{`console`in window&&console.error&&console.error(`There was an error getting video Id: ${e}`)};window.addEventListener(`message`,n=>{if(!Qv(n.origin))return;let r=hy(n.data);if(!r||r.event!==`ready`)return;let i=n.source?ry(n.source,e):null;if(i&&$v(i.src)){let e=new Ny(i);e.getVideoId().then(t=>{let n=RegExp(`[?&]vimeo_t_${t}=([^&#]*)`).exec(window.location.href);if(n&&n[1]){let t=decodeURI(n[1]);e.setCurrentTime(t)}}).catch(t)}})}function Ey(){window.VimeoDRMEmbedsUpdated||(window.VimeoDRMEmbedsUpdated=!0,window.addEventListener(`message`,e=>{if(!Qv(e.origin))return;let t=hy(e.data);if(!t||t.event!==`drminitfailed`)return;let n=e.source?ry(e.source):null;if(!n)return;let r=n.getAttribute(`allow`)||``;if(!r.includes(`encrypted-media`)){n.setAttribute(`allow`,`${r}; encrypted-media`);let e=new URL(n.getAttribute(`src`));e.searchParams.set(`forcereload`,`drm`),n.setAttribute(`src`,e.toString());return}}))}function Dy(){let e=function(){let e,t=[[`requestFullscreen`,`exitFullscreen`,`fullscreenElement`,`fullscreenEnabled`,`fullscreenchange`,`fullscreenerror`],[`webkitRequestFullscreen`,`webkitExitFullscreen`,`webkitFullscreenElement`,`webkitFullscreenEnabled`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`webkitRequestFullScreen`,`webkitCancelFullScreen`,`webkitCurrentFullScreenElement`,`webkitCancelFullScreen`,`webkitfullscreenchange`,`webkitfullscreenerror`],[`mozRequestFullScreen`,`mozCancelFullScreen`,`mozFullScreenElement`,`mozFullScreenEnabled`,`mozfullscreenchange`,`mozfullscreenerror`],[`msRequestFullscreen`,`msExitFullscreen`,`msFullscreenElement`,`msFullscreenEnabled`,`MSFullscreenChange`,`MSFullscreenError`]],n=0,r=t.length,i={};for(;n<r;n++)if(e=t[n],e&&e[1]in document){for(n=0;n<e.length;n++)i[t[0][n]]=e[n];return i}return!1}(),t={fullscreenchange:e.fullscreenchange,fullscreenerror:e.fullscreenerror},n={request(t){return new Promise((r,i)=>{let a=function(){n.off(`fullscreenchange`,a),r()};n.on(`fullscreenchange`,a),t||=document.documentElement;let o=t[e.requestFullscreen]();o instanceof Promise&&o.then(a).catch(i)})},exit(){return new Promise((t,r)=>{if(!n.isFullscreen){t();return}let i=function(){n.off(`fullscreenchange`,i),t()};n.on(`fullscreenchange`,i);let a=document[e.exitFullscreen]();a instanceof Promise&&a.then(i).catch(r)})},on(e,n){let r=t[e];r&&document.addEventListener(r,n)},off(e,n){let r=t[e];r&&document.removeEventListener(r,n)}};return Object.defineProperties(n,{isFullscreen:{get(){return!!document[e.fullscreenElement]}},element:{enumerable:!0,get(){return document[e.fullscreenElement]}},isEnabled:{enumerable:!0,get(){return!!document[e.fullscreenEnabled]}}}),n}var Oy={role:`viewer`,autoPlayMuted:!0,allowedDrift:.3,maxAllowedDrift:1,minCheckInterval:.1,maxRateAdjustment:.2,maxTimeToCatchUp:1},ky=class extends EventTarget{logger;constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;super(),this.logger=r,this.init(t,e,{...Oy,...n})}disconnect(){this.dispatchEvent(new Event(`disconnect`))}async init(e,t,n){if(await this.waitForTOReadyState(e,`open`),n.role===`viewer`){await this.updatePlayer(e,t,n);let r=ny(e,`change`,()=>this.updatePlayer(e,t,n)),i=this.maintainPlaybackPosition(e,t,n);this.addEventListener(`disconnect`,()=>{i.cancel(),r.cancel()})}else{await this.updateTimingObject(e,t);let n=ny(t,[`seeked`,`play`,`pause`,`ratechange`],()=>this.updateTimingObject(e,t),`on`,`off`);this.addEventListener(`disconnect`,()=>n.cancel())}}async updateTimingObject(e,t){let[n,r,i]=await Promise.all([t.getCurrentTime(),t.getPaused(),t.getPlaybackRate()]);e.update({position:n,velocity:r?0:i})}async updatePlayer(e,t,n){let{position:r,velocity:i}=e.query();typeof r==`number`&&t.setCurrentTime(r),typeof i==`number`&&(i===0?await t.getPaused()===!1&&t.pause():i>0&&(await t.getPaused()===!0&&(await t.play().catch(async e=>{e.name===`NotAllowedError`&&n.autoPlayMuted&&(await t.setMuted(!0),await t.play().catch(e=>console.error(`Couldn't play the video from TimingSrcConnector. Error:`,e)))}),this.updatePlayer(e,t,n)),await t.getPlaybackRate()!==i&&t.setPlaybackRate(i)))}maintainPlaybackPosition(e,t,n){let{allowedDrift:r,maxAllowedDrift:i,minCheckInterval:a,maxRateAdjustment:o,maxTimeToCatchUp:s}=n,c=Math.min(s,Math.max(a,i))*1e3,l=async()=>{if(e.query().velocity===0||await t.getPaused()===!0)return;let n=e.query().position-await t.getCurrentTime(),a=Math.abs(n);if(this.log(`Drift: ${n}`),a>i)await this.adjustSpeed(t,0),t.setCurrentTime(e.query().position),this.log(`Resync by currentTime`);else if(a>r){let e=a/s,r=o,i=e<r?(r-e)/2:r;await this.adjustSpeed(t,i*Math.sign(n)),this.log(`Resync by playbackRate`)}},u=setInterval(()=>l(),c);return{cancel:()=>clearInterval(u)}}log(e){this.logger?.(`TimingSrcConnector: ${e}`)}speedAdjustment=0;adjustSpeed=async(e,t)=>{if(this.speedAdjustment===t)return;let n=await e.getPlaybackRate()-this.speedAdjustment+t;this.log(`New playbackRate: ${n}`),await e.setPlaybackRate(n),this.speedAdjustment=t};waitForTOReadyState(e,t){return new Promise(n=>{let r=()=>{e.readyState===t?n():e.addEventListener(`readystatechange`,r,{once:!0})};r()})}},Ay=new WeakMap,jy=new WeakMap,My={},Ny=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(window.jQuery&&e instanceof jQuery&&(e.length>1&&window.console&&console.warn&&console.warn(`A jQuery object with multiple elements was passed, using the first element.`),e=e[0]),typeof document<`u`&&typeof e==`string`&&(e=document.getElementById(e)),!Xv(e))throw TypeError(`You must pass either a valid element or a valid id.`);if(e.nodeName!==`IFRAME`){let t=e.querySelector(`iframe`);t&&(e=t)}if(e.nodeName===`IFRAME`&&!Qv(e.getAttribute(`src`)||``))throw Error(`The player element passed isn’t a Vimeo embed.`);if(Ay.has(e))return Ay.get(e);this._window=e.ownerDocument.defaultView,this.element=e,this.origin=`*`;let n=new cy((n,r)=>{if(this._onMessage=e=>{if(!Qv(e.origin)||this.element.contentWindow!==e.source)return;this.origin===`*`&&(this.origin=e.origin);let t=hy(e.data);if(t&&t.event===`error`&&t.data&&t.data.method===`ready`){let e=Error(t.data.message);e.name=t.data.name,r(e);return}let i=t&&t.event===`ready`,a=t&&t.method===`ping`;if(i||a){this.element.setAttribute(`data-ready`,`true`),n();return}_y(this,t)},this._window.addEventListener(`message`,this._onMessage),this.element.nodeName!==`IFRAME`){let n=yy(e,t);xy(ty(n),n,e).then(t=>{let n=by(t,e);return this.element=n,this._originalElement=e,my(e,n),Ay.set(this.element,this),t}).catch(r)}});if(jy.set(this,n),Ay.set(this.element,this),this.element.nodeName===`IFRAME`&&gy(this,`ping`),My.isEnabled){let e=()=>My.exit();this.fullscreenchangeHandler=()=>{My.isFullscreen?uy(this,`event:exitFullscreen`,e):fy(this,`event:exitFullscreen`,e),this.ready().then(()=>{gy(this,`fullscreenchange`,My.isFullscreen)})},My.on(`fullscreenchange`,this.fullscreenchangeHandler)}return this}static isVimeoUrl(e){return Qv(e)}callMethod(e){var t=[...arguments].slice(1);if(e==null)throw TypeError(`You must pass a method name.`);return new cy((n,r)=>this.ready().then(()=>{uy(this,e,{resolve:n,reject:r}),t.length===0?t={}:t.length===1&&(t=t[0]),gy(this,e,t)}).catch(r))}get(e){return new cy((t,n)=>(e=Yv(e,`get`),this.ready().then(()=>{uy(this,e,{resolve:t,reject:n}),gy(this,e)}).catch(n)))}set(e,t){return new cy((n,r)=>{if(e=Yv(e,`set`),t==null)throw TypeError(`There must be a value to set.`);return this.ready().then(()=>{uy(this,e,{resolve:n,reject:r}),gy(this,e,t)}).catch(r)})}on(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(!t)throw TypeError(`You must pass a callback function.`);if(typeof t!=`function`)throw TypeError(`The callback must be a function.`);dy(this,`event:${e}`).length===0&&this.callMethod(`addEventListener`,e).catch(()=>{}),uy(this,`event:${e}`,t)}off(e,t){if(!e)throw TypeError(`You must pass an event name.`);if(t&&typeof t!=`function`)throw TypeError(`The callback must be a function.`);fy(this,`event:${e}`,t)&&this.callMethod(`removeEventListener`,e).catch(e=>{})}loadVideo(e){return this.callMethod(`loadVideo`,e)}ready(){let e=jy.get(this)||new cy((e,t)=>{t(Error(`Unknown player. Probably unloaded.`))});return cy.resolve(e)}addCuePoint(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.callMethod(`addCuePoint`,{time:e,data:t})}removeCuePoint(e){return this.callMethod(`removeCuePoint`,e)}enableTextTrack(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`enableTextTrack`,{language:e,kind:t,showing:n})}disableTextTrack(){return this.callMethod(`disableTextTrack`)}selectAudioTrack(e,t){if(!e)throw TypeError(`You must pass a language.`);return this.callMethod(`selectAudioTrack`,{language:e,kind:t})}selectDefaultAudioTrack(){return this.callMethod(`selectDefaultAudioTrack`)}pause(){return this.callMethod(`pause`)}play(){return this.callMethod(`play`)}requestFullscreen(){return My.isEnabled?My.request(this.element):this.callMethod(`requestFullscreen`)}exitFullscreen(){return My.isEnabled?My.exit():this.callMethod(`exitFullscreen`)}getFullscreen(){return My.isEnabled?cy.resolve(My.isFullscreen):this.get(`fullscreen`)}requestPictureInPicture(){return this.callMethod(`requestPictureInPicture`)}exitPictureInPicture(){return this.callMethod(`exitPictureInPicture`)}getPictureInPicture(){return this.get(`pictureInPicture`)}remotePlaybackPrompt(){return this.callMethod(`remotePlaybackPrompt`)}unload(){return this.callMethod(`unload`)}destroy(){return new cy(e=>{if(jy.delete(this),Ay.delete(this.element),this._originalElement&&(Ay.delete(this._originalElement),this._originalElement.removeAttribute(`data-vimeo-initialized`)),this.element&&this.element.nodeName===`IFRAME`&&this.element.parentNode&&(this.element.parentNode.parentNode&&this._originalElement&&this._originalElement!==this.element.parentNode?this.element.parentNode.parentNode.removeChild(this.element.parentNode):this.element.parentNode.removeChild(this.element)),this.element&&this.element.nodeName===`DIV`&&this.element.parentNode){this.element.removeAttribute(`data-vimeo-initialized`);let e=this.element.querySelector(`iframe`);e&&e.parentNode&&(e.parentNode.parentNode&&this._originalElement&&this._originalElement!==e.parentNode?e.parentNode.parentNode.removeChild(e.parentNode):e.parentNode.removeChild(e))}this._window.removeEventListener(`message`,this._onMessage),My.isEnabled&&My.off(`fullscreenchange`,this.fullscreenchangeHandler),e()})}getAutopause(){return this.get(`autopause`)}setAutopause(e){return this.set(`autopause`,e)}getBuffered(){return this.get(`buffered`)}getCameraProps(){return this.get(`cameraProps`)}setCameraProps(e){return this.set(`cameraProps`,e)}getChapters(){return this.get(`chapters`)}getCurrentChapter(){return this.get(`currentChapter`)}getColor(){return this.get(`color`)}getColors(){return cy.all([this.get(`colorOne`),this.get(`colorTwo`),this.get(`colorThree`),this.get(`colorFour`)])}setColor(e){return this.set(`color`,e)}setColors(e){if(!Array.isArray(e))return new cy((e,t)=>t(TypeError(`Argument must be an array.`)));let t=new cy(e=>e(null)),n=[e[0]?this.set(`colorOne`,e[0]):t,e[1]?this.set(`colorTwo`,e[1]):t,e[2]?this.set(`colorThree`,e[2]):t,e[3]?this.set(`colorFour`,e[3]):t];return cy.all(n)}getCuePoints(){return this.get(`cuePoints`)}getCurrentTime(){return this.get(`currentTime`)}setCurrentTime(e){return this.set(`currentTime`,e)}getDuration(){return this.get(`duration`)}getEnded(){return this.get(`ended`)}getLoop(){return this.get(`loop`)}setLoop(e){return this.set(`loop`,e)}setMuted(e){return this.set(`muted`,e)}getMuted(){return this.get(`muted`)}getPaused(){return this.get(`paused`)}getPlaybackRate(){return this.get(`playbackRate`)}setPlaybackRate(e){return this.set(`playbackRate`,e)}getPlayed(){return this.get(`played`)}getQualities(){return this.get(`qualities`)}getQuality(){return this.get(`quality`)}setQuality(e){return this.set(`quality`,e)}getRemotePlaybackAvailability(){return this.get(`remotePlaybackAvailability`)}getRemotePlaybackState(){return this.get(`remotePlaybackState`)}getSeekable(){return this.get(`seekable`)}getSeeking(){return this.get(`seeking`)}getTextTracks(){return this.get(`textTracks`)}getAudioTracks(){return this.get(`audioTracks`)}getEnabledAudioTrack(){return this.get(`enabledAudioTrack`)}getDefaultAudioTrack(){return this.get(`defaultAudioTrack`)}getVideoEmbedCode(){return this.get(`videoEmbedCode`)}getVideoId(){return this.get(`videoId`)}getVideoTitle(){return this.get(`videoTitle`)}getVideoWidth(){return this.get(`videoWidth`)}getVideoHeight(){return this.get(`videoHeight`)}getVideoUrl(){return this.get(`videoUrl`)}getVolume(){return this.get(`volume`)}setVolume(e){return this.set(`volume`,e)}async setTimingSrc(e,t){if(!e)throw TypeError(`A Timing Object must be provided.`);await this.ready();let n=new ky(this,e,t);return gy(this,`notifyTimingObjectConnect`),n.addEventListener(`disconnect`,()=>gy(this,`notifyTimingObjectDisconnect`)),n}};Jv||(My=Dy(),Sy(),Cy(),wy(),Ty(),Ey());function Py(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Fy(e,t)}function Fy(e,t){return Fy=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Fy(e,t)}var Iy={play:`onPlay`,playing:`onPlaying`,pause:`onPause`,ended:`onEnd`,timeupdate:`onTimeUpdate`,progress:`onProgress`,seeked:`onSeeked`,texttrackchange:`onTextTrackChange`,cuechange:`onCueChange`,cuepoint:`onCuePoint`,volumechange:`onVolumeChange`,playbackratechange:`onPlaybackRateChange`,error:`onError`,loaded:`onLoaded`},Ly=function(e){function t(t){var n=e.call(this,t)||this;return n.refContainer=n.refContainer.bind(n),n}Py(t,e);var n=t.prototype;return n.componentDidMount=function(){this.createPlayer()},n.componentDidUpdate=function(e){var t=this,n=Object.keys(this.props).filter(function(n){return t.props[n]!==e[n]});this.updateProps(n)},n.componentWillUnmount=function(){this.player.destroy()},n.getInitialOptions=function(){var e,t=this.props.video,n=/^https?:/i.test(t)?`url`:`id`;return e={},e[n]=t,e.width=this.props.width,e.height=this.props.height,e.autopause=this.props.autopause,e.autoplay=this.props.autoplay,e.byline=this.props.showByline,e.color=this.props.color,e.controls=this.props.controls,e.loop=this.props.loop,e.portrait=this.props.showPortrait,e.title=this.props.showTitle,e.muted=this.props.muted,e.background=this.props.background,e.responsive=this.props.responsive,e.dnt=this.props.dnt,e.speed=this.props.speed,e.keyboard=this.props.keyboard,e.pip=this.props.pip,e.playsinline=this.props.playsInline,e.quality=this.props.quality,e.texttrack=this.props.textTrack,e.transparent=this.props.transparent,e},n.updateProps=function(e){var t=this,n=this.player;e.forEach(function(e){var r=t.props[e];switch(e){case`autopause`:n.setAutopause(r);break;case`color`:n.setColor(r);break;case`loop`:n.setLoop(r);break;case`volume`:n.setVolume(r);break;case`paused`:n.getPaused().then(function(e){return r&&!e?n.pause():!r&&e?n.play():null});break;case`width`:case`height`:n.element[e]=r;break;case`video`:if(r){var i=t.props.start,a=n.loadVideo(r);typeof i==`number`&&a.then(function(){n.setCurrentTime(i)})}else n.unload();break;case`playbackRate`:n.setPlaybackRate(r);break;case`quality`:n.setQuality(r);break}})},n.createPlayer=function(){var e=this,t=this.props,n=t.start,r=t.volume,i=t.playbackRate;this.player=new Ny(this.container,this.getInitialOptions()),Object.keys(Iy).forEach(function(t){var n=Iy[t];e.player.on(t,function(t){var r=e.props[n];r&&r(t)})});var a=this.props,o=a.onError,s=a.onReady;this.player.ready().then(function(){s&&s(e.player)},function(e){if(o)o(e);else throw e}),typeof n==`number`&&this.player.setCurrentTime(n),typeof r==`number`&&this.updateProps([`volume`]),typeof i==`number`&&this.updateProps([`playbackRate`])},n.refContainer=function(e){this.container=e},n.render=function(){var e=this.props,t=e.id,n=e.className,r=e.style;return Q.createElement(`div`,{id:t,className:n,style:r,ref:this.refContainer})},t}(Q.Component);Ly.defaultProps={autopause:!0,autoplay:!1,showByline:!0,controls:!0,loop:!1,showPortrait:!0,showTitle:!0,muted:!1,background:!1,responsive:!1,dnt:!1,speed:!1,keyboard:!0,pip:!1,playsInline:!0,transparent:!0};var Ry={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},zy=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Q.useState)(``);return(0,Q.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=Ry[r],c=new Image;c.onload=()=>{c.width<s?a(o):a(i)},c.onerror=()=>a(o),c.src=i},[e,t,n,r]),i};function By(e,t,n,r,i){let a={"@context":`https://schema.org`,"@type":`VideoObject`,name:i?.name||t,thumbnailUrl:[i?.thumbnailUrl||n],embedUrl:i?.embedUrl||`${r}/embed/${e}`,contentUrl:i?.contentUrl||`https://www.youtube.com/watch?v=${e}`,...i?.description&&{description:i.description},...i?.uploadDate&&{uploadDate:i.uploadDate},...i?.duration&&{duration:i.duration}};return JSON.stringify(a)}function Vy(e,t){let[n,r]=Q.useState(!1),[i,a]=Q.useState(e.alwaysLoadIframe||!1),o=encodeURIComponent(e.id),s=typeof e.playlistCoverId==`string`?encodeURIComponent(e.playlistCoverId):null,c=e.title,l=e.poster||`hqdefault`,u=e.announce||`Watch`,d=e.alwaysLoadIframe?e.autoplay&&e.muted:!0,f=Q.useMemo(()=>{let t=new URLSearchParams({...e.muted?{mute:`1`}:{},...d?{autoplay:`1`}:{},...e.enableJsApi?{enablejsapi:`1`}:{},...e.enableJsApi&&typeof window<`u`?{origin:window.location.origin}:{},...e.playlist?{list:o}:{}});return e.params&&new URLSearchParams(e.params.startsWith(`&`)?e.params.slice(1):e.params).forEach((e,n)=>{t.append(n,e)}),t},[e.muted,d,e.enableJsApi,e.playlist,o,e.params]),p=Q.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Q.useMemo(()=>e.playlist?`${p}/embed/videoseries?${f.toString()}`:`${p}/embed/${o}?${f.toString()}`,[e.playlist,p,o,f]),h=!e.thumbnail&&!e.playlist&&l===`maxresdefault`,g=e.webp?`webp`:`jpg`,_=e.webp?`vi_webp`:`vi`,v=h?zy(e.id,_,g,l):null,y=Q.useMemo(()=>e.thumbnail||v||`https://i.ytimg.com/${_}/${e.playlist?s:o}/${l}.${g}`,[e.thumbnail,v,_,e.playlist,s,o,l,g]),b=e.activatedClass||`lyt-activated`,x=e.adNetwork||!1,S=e.aspectHeight||9,C=e.aspectWidth||16,w=e.iframeClass||``,T=e.playerClass||`lty-playbtn`,E=e.wrapperClass||`yt-lite`,D=Q.useCallback(e.onIframeAdded||function(){},[e.onIframeAdded]),O=e.rel?`prefetch`:`preload`,k=e.containerElement||`article`,A=e.noscriptFallback!==!1,j=()=>{n||r(!0)},M=()=>{i||a(!0)};return Q.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Q.useEffect(()=>{if(!i||!e.enableJsApi||!(e.onReady||e.onStateChange||e.onError||e.onPlay||e.onPause||e.onEnd||e.onBuffering||e.onPlaybackRateChange||e.onPlaybackQualityChange))return;let n=!1,r=!1,a=r=>{if(r.origin!==`https://www.youtube.com`&&r.origin!==`https://www.youtube-nocookie.com`)return;let i;try{i=typeof r.data==`string`?JSON.parse(r.data):r.data}catch{return}switch(i.event){case`onReady`:n||(n=!0,e.onReady&&e.onReady({videoId:e.id,title:c}));break;case`infoDelivery`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate),i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break;case`onStateChange`:if(i.info?.playerState!==void 0){let n=i.info.playerState;switch(e.onStateChange&&e.onStateChange({state:n,currentTime:i.info.currentTime,duration:i.info.duration}),n){case 1:e.onPlay?.();break;case 2:e.onPause?.();break;case 0:e.onEnd?.(),e.stopOnEnd&&typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"command","func":"stopVideo","args":""}`,`*`);break;case 3:e.onBuffering?.();break}}break;case`onError`:if(i.info&&`errorCode`in i.info){let t=i.info.errorCode;e.onError&&e.onError(t)}break;case`onPlaybackRateChange`:i.info?.playbackRate!==void 0&&e.onPlaybackRateChange?.(i.info.playbackRate);break;case`onPlaybackQualityChange`:i.info?.playbackQuality!==void 0&&e.onPlaybackQualityChange?.(i.info.playbackQuality);break}};window.addEventListener(`message`,a);let s=[],l=()=>{typeof t==`object`&&t?.current?.contentWindow&&t.current.contentWindow.postMessage(`{"event":"listening","id":"`+o+`"}`,`*`)},u=()=>{r||(r=!0,l(),[100,300,600,1200,2400].forEach(e=>{s.push(setTimeout(l,e))}))};return typeof t==`object`&&t?.current?(t.current.addEventListener(`load`,u),t.current.contentDocument?.readyState===`complete`&&u()):[200,500,1e3,2e3,3e3].forEach(e=>{s.push(setTimeout(l,e))}),()=>{window.removeEventListener(`message`,a),s.forEach(clearTimeout),typeof t==`object`&&t?.current&&t.current.removeEventListener(`load`,u)}},[i,e.enableJsApi,e.onReady,e.onStateChange,e.onError,e.onPlay,e.onPause,e.onEnd,e.onBuffering,e.onPlaybackRateChange,e.onPlaybackQualityChange,e.stopOnEnd,e.id,o,c,t]),(0,Z.jsxs)(Z.Fragment,{children:[!e.lazyLoad&&(0,Z.jsx)(`link`,{rel:O,href:y,as:`image`}),(0,Z.jsx)(Z.Fragment,{children:n&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`link`,{rel:`preconnect`,href:p}),(0,Z.jsx)(`link`,{rel:`preconnect`,href:`https://www.google.com`}),x&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`link`,{rel:`preconnect`,href:`https://static.doubleclick.net`}),(0,Z.jsx)(`link`,{rel:`preconnect`,href:`https://googleads.g.doubleclick.net`})]})]})}),e.seo&&!e.playlist&&(0,Z.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:By(e.id,c,y,p,e.seo)}}),A&&!e.playlist&&(0,Z.jsx)(`noscript`,{children:(0,Z.jsxs)(`a`,{href:`https://www.youtube.com/watch?v=${e.id}`,"aria-label":`Watch ${c} on YouTube`,children:[`Watch "`,c,`" on YouTube`]})}),(0,Z.jsxs)(k,{onPointerOver:j,onClick:M,className:`${E} ${i?b:``}`,"data-title":c,role:!i&&!e.lazyLoad?`img`:void 0,"aria-label":i?void 0:`${c} - YouTube video preview`,style:{...!e.lazyLoad&&{backgroundImage:`url(${y})`},"--aspect-ratio":`${S/C*100}%`,...e.style||{}},children:[e.lazyLoad&&!i&&(0,Z.jsx)(`img`,{src:y,alt:`${c} - YouTube thumbnail`,className:`lty-thumbnail`,loading:`lazy`}),e.playlist&&!i&&(0,Z.jsx)(`div`,{className:`lty-playlist-icon`,"aria-hidden":`true`}),!(e.hideButtonOnActivate&&i)&&(0,Z.jsx)(`button`,{type:`button`,className:T,"aria-label":`${u} ${c}`,"aria-hidden":i||void 0,tabIndex:i?-1:0,onClick:M,children:(0,Z.jsx)(`span`,{className:`lty-visually-hidden`,children:u})}),i&&(0,Z.jsx)(`iframe`,{ref:t,className:w,title:c,width:`560`,height:`315`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,src:m,referrerPolicy:e.referrerPolicy||`strict-origin-when-cross-origin`})]})]})}var Hy=Q.forwardRef(Vy);function Uy(e){return e!==!1}function Wy(e,t){let n=[];return t.startSeconds!==null&&n.push(`start=${t.startSeconds}`),e.controls===!1&&n.push(`controls=0`),e.loop===!0&&n.push(`loop=1`,`playlist=${t.id}`),e.playsinline===!0&&n.push(`playsinline=1`),n.length>0?n.join(`&`):void 0}function Gy(e){if(e.width!==void 0)return{width:e.width}}function Ky(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function qy(e){let t=(0,$.c)(23),n=(0,Q.useRef)(null),r=e.title??`Vimeo video player`,i;t[0]===r?i=t[1]:(i=e=>{let t=e;n.current=t,t.element&&(t.element.title=r)},t[0]=r,t[1]=i);let a=i,o,s;t[2]===r?(o=t[3],s=t[4]):(o=()=>{let e=n.current;e?.element&&(e.element.title=r)},s=[r],t[2]=r,t[3]=o,t[4]=s),(0,Q.useEffect)(o,s);let c;t[5]===e?c=t[6]:(c=Gy(e),t[5]=e,t[6]=c);let l=e.width===void 0,u=e.autoplay===!0,d=e.muted===!0,f=e.muted===!0?0:1,p=e.loop===!0,m=e.controls!==!1,h=e.playsinline!==!1,g;t[7]!==a||t[8]!==e.height||t[9]!==e.src||t[10]!==e.width||t[11]!==h||t[12]!==l||t[13]!==u||t[14]!==d||t[15]!==f||t[16]!==p||t[17]!==m?(g=(0,Z.jsx)(Ly,{video:e.src,responsive:l,width:e.width,height:e.height,autoplay:u,muted:d,volume:f,loop:p,controls:m,playsInline:h,onReady:a}),t[7]=a,t[8]=e.height,t[9]=e.src,t[10]=e.width,t[11]=h,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=g):g=t[18];let _;return t[19]!==e.title||t[20]!==g||t[21]!==c?(_=(0,Z.jsx)(`div`,{className:`ok-video ok-video-vimeo`,style:c,title:e.title,children:g}),t[19]=e.title,t[20]=g,t[21]=c,t[22]=_):_=t[22],_}function Jy(e){let t=(0,$.c)(17),n;t[0]===e.src?n=t[1]:(n=mt(e.src),t[0]=e.src,t[1]=n);let r=n;if(!r)return null;let i;t[2]!==r.startRaw||t[3]!==e.autoplay||t[4]!==e.muted?(i=[],r.startRaw!==null&&i.push(`t=${r.startRaw}`),e.autoplay===!0&&i.push(`autoplay=true`),e.muted===!0&&i.push(`muted=true`),t[2]=r.startRaw,t[3]=e.autoplay,t[4]=e.muted,t[5]=i):i=t[5];let a=i.length>0?`https://www.loom.com/embed/${r.id}?${i.join(`&`)}`:`https://www.loom.com/embed/${r.id}`,o;t[6]===e?o=t[7]:(o=Gy(e),t[6]=e,t[7]=o);let s=e.title??`Loom video player`,c;t[8]!==a||t[9]!==e.height||t[10]!==e.width||t[11]!==s?(c=(0,Z.jsx)(`iframe`,{className:`ok-video-loom-iframe`,src:a,title:s,width:e.width,height:e.height,allow:`autoplay; fullscreen`,referrerPolicy:`strict-origin-when-cross-origin`,allowFullScreen:!0}),t[8]=a,t[9]=e.height,t[10]=e.width,t[11]=s,t[12]=c):c=t[12];let l;return t[13]!==e.title||t[14]!==o||t[15]!==c?(l=(0,Z.jsx)(`div`,{className:`ok-video ok-video-loom`,style:o,title:e.title,children:c}),t[13]=e.title,t[14]=o,t[15]=c,t[16]=l):l=t[16],l}function Yy(e){let t=(0,$.c)(29);if(e.src!==void 0&&D(e.src)){let n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Jy,{...e,src:e.src}),t[0]=e,t[1]=n),n}if(e.src!==void 0&&xe(e.src)){let n;return t[2]===e?n=t[3]:(n=(0,Z.jsx)(qy,{...e,src:e.src}),t[2]=e,t[3]=n),n}let n;if(t[4]!==e){n=Symbol.for(`react.early_return_sentinel`);bb0:{let r=e.src===void 0?null:Be(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=Gy(e),s;t[6]===e.poster?s=t[7]:(s=e.poster===void 0?void 0:le(e.poster),t[6]=e.poster,t[7]=s);let c=(0,Z.jsx)(Hy,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:Wy(e,r),muted:e.muted===!0,autoplay:e.autoplay===!0,alwaysLoadIframe:i,thumbnail:s,aspectWidth:a?Number(e.width):void 0,aspectHeight:a?Number(e.height):void 0,style:Ky(e)}),l;t[8]!==o||t[9]!==c?(l=(0,Z.jsx)(`div`,{className:`ok-video ok-video-youtube`,style:o,children:c}),t[8]=o,t[9]=c,t[10]=l):l=t[10],n=l;break bb0}}t[4]=e,t[5]=n}else n=t[5];if(n!==Symbol.for(`react.early_return_sentinel`))return n;let r;t[11]===e.src?r=t[12]:(r=e.src===void 0?void 0:le(e.src),t[11]=e.src,t[12]=r);let i=e.title,a;t[13]===e.controls?a=t[14]:(a=Uy(e.controls),t[13]=e.controls,t[14]=a);let o;t[15]===e.poster?o=t[16]:(o=e.poster===void 0?void 0:le(e.poster),t[15]=e.poster,t[16]=o);let s;return t[17]!==e.autoplay||t[18]!==e.height||t[19]!==e.loop||t[20]!==e.muted||t[21]!==e.playsinline||t[22]!==e.preload||t[23]!==e.title||t[24]!==e.width||t[25]!==r||t[26]!==a||t[27]!==o?(s=(0,Z.jsx)(`video`,{className:`ok-video`,src:r,title:i,controls:a,autoPlay:e.autoplay,muted:e.muted,loop:e.loop,playsInline:e.playsinline,poster:o,preload:e.preload,width:e.width,height:e.height}),t[17]=e.autoplay,t[18]=e.height,t[19]=e.loop,t[20]=e.muted,t[21]=e.playsinline,t[22]=e.preload,t[23]=e.title,t[24]=e.width,t[25]=r,t[26]=a,t[27]=o,t[28]=s):s=t[28],s}function Xy(e){let t=(0,$.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,Z.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var Zy={Callout:l_,img:nv,video:Yy,audio:i_,Pdf:Av,File:y_,Embed:__,Accordion:n_,Tabs:Vv,Tab:Lv,Math:av,MermaidFence:Xt,Mirror:gv,MirrorSource:_v,"*":Xy};function Qy(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var $y=Me(),eb=new Map;function tb(e){if(e.surface===`compat`){let t=Zy[e.rendersAs];if(!t)throw Error(`Compat descriptor '${e.name}' declares rendersAs: '${e.rendersAs}', but no React component is registered under that name in componentMap. Add the canonical component before registering the compat descriptor.`);return{Component:t,reactNodePropNames:Qy(e.props)}}let t=Zy[e.name];return t?{Component:t,reactNodePropNames:Qy(e.props)}:null}for(let[e,t]of $y.entries()){let n=tb(t);n&&eb.set(e,n)}function nb(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function rb(e){let t=$y.getOrWildcard(e),n=eb.get(t.name)??eb.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return nb(t,n)}function ib(){let e=[];for(let[t,n]of $y.entries()){if(t===`*`)continue;let r=eb.get(t);r&&e.push(nb(n,r))}return e}var ab=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,ob=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,sb={Callout:{description:{id:`322lyb`},props:{type:`note`,title:`Heads up`},children:`Callouts draw attention to key information.`},Accordion:{description:{id:`mWVJRX`},props:{title:`Click to expand`,defaultOpen:!0},children:`Hidden content goes here.`},img:{description:{id:`VUijjF`},props:{src:ab,alt:`Sample image`}},video:{description:{id:`e1hptq`},props:{controls:!0,poster:ob}},audio:{description:{id:`9jnjV0`},props:{controls:!0}},Math:{description:{id:`Y-Urt2`},props:{formula:`c = \\pm\\sqrt{a^2 + b^2}`}},Embed:{description:{id:`jTLWxh`},render:()=>(0,Z.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Z.jsx)(`span`,{className:`ml-1.5 flex-1 truncate rounded-sm bg-background px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:`https://example.com/embed`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-full rounded-sm bg-muted-foreground/20`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-5/6 rounded-sm bg-muted-foreground/20`}),(0,Z.jsx)(`span`,{className:`h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]})]})},Pdf:{description:{id:`Fqr8BP`},render:()=>(0,Z.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/40 px-1.5 py-1`,children:[(0,Z.jsxs)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 text-muted-foreground`,"aria-hidden":`true`,children:[(0,Z.jsx)(`title`,{children:`Thumbnails`}),(0,Z.jsx)(`rect`,{x:`1`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,Z.jsx)(`rect`,{x:`7`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,Z.jsx)(`rect`,{x:`1`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,Z.jsx)(`rect`,{x:`7`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`})]}),(0,Z.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5 font-mono`,children:`2`}),(0,Z.jsx)(`span`,{children:`/ 12`})]}),(0,Z.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] font-mono text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`−`}),(0,Z.jsx)(`span`,{children:`100%`}),(0,Z.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`+`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 gap-1 p-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex w-6 flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`}),(0,Z.jsx)(`span`,{className:`h-3 rounded-sm border border-foreground/60 bg-background`}),(0,Z.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 rounded-sm bg-background p-1.5`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1/2 rounded-sm bg-foreground/50`}),(0,Z.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`h-1 w-5/6 rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`h-1 w-2/3 rounded-sm bg-muted-foreground/30`})]})]})]})},MermaidFence:{description:{id:`z0a2EA`},render:()=>(0,Z.jsxs)(`svg`,{viewBox:`0 0 200 120`,className:`h-full w-full text-foreground`,"aria-hidden":`true`,preserveAspectRatio:`xMidYMid meet`,children:[(0,Z.jsx)(`title`,{children:`Mermaid flowchart preview`}),(0,Z.jsx)(`defs`,{children:(0,Z.jsx)(`marker`,{id:`mermaid-preview-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,Z.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`currentColor`})})}),(0,Z.jsx)(`rect`,{x:`14`,y:`20`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,Z.jsx)(`text`,{x:`42`,y:`38`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Start`}),(0,Z.jsx)(`polygon`,{points:`100,18 140,50 100,82 60,50`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,Z.jsx)(`text`,{x:`100`,y:`54`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Ready?`}),(0,Z.jsx)(`rect`,{x:`130`,y:`84`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,Z.jsx)(`text`,{x:`158`,y:`102`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`End`}),(0,Z.jsx)(`line`,{x1:`70`,y1:`34`,x2:`80`,y2:`40`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,Z.jsx)(`line`,{x1:`124`,y1:`62`,x2:`138`,y2:`82`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,Z.jsx)(`text`,{x:`138`,y:`74`,fontSize:`8`,fill:`currentColor`,opacity:`0.6`,children:`yes`})]})},Tabs:{description:{id:`75Y1dk`},render:()=>(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-1 border-b border-border pb-1`,children:[(0,Z.jsx)(`span`,{className:`rounded-md bg-foreground/10 px-2 py-0.5 text-xs font-medium text-foreground`,children:`Tab 1`}),(0,Z.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs text-muted-foreground`,children:`Tab 2`})]}),(0,Z.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:(0,Z.jsx)(o,{id:`m6YGpY`})})]})},Mirror:{description:{id:`_WPP7e`},render:()=>(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/40 px-2 py-1.5`,children:[(0,Z.jsxs)(`span`,{className:`absolute -top-2 right-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(Xa,{className:`size-2.5`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`EL_YRd`,components:{0:(0,Z.jsx)(`code`,{className:`font-mono`})}})})]}),(0,Z.jsx)(`span`,{className:`block h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`mt-1 block h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]}),(0,Z.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,Z.jsx)(o,{id:`qNOgUu`})})]})},MirrorSource:{description:{id:`epuNYK`},render:()=>(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/50 px-2 py-1.5`,children:[(0,Z.jsxs)(`span`,{className:`absolute -top-2 left-1.5 flex items-center gap-1 rounded-md bg-background px-1 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(Yn,{className:`size-2.5`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`maDWIB`,components:{0:(0,Z.jsx)(`code`,{className:`font-mono`})}})})]}),(0,Z.jsx)(`span`,{className:`block h-1.5 w-4/5 rounded-sm bg-muted-foreground/30`}),(0,Z.jsx)(`span`,{className:`mt-1 block h-1.5 w-3/5 rounded-sm bg-muted-foreground/20`})]}),(0,Z.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,Z.jsx)(o,{id:`emgiet`})})]})}};function cb(e){let t={};for(let n of e.props)n.type!==`reactnode`&&`defaultValue`in n&&n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function lb(e){let t=rb(e),n=cb(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var ub=new Set;function db(e){ub.add(e)}function fb(e){if(typeof e==`number`)return ub.delete(e);let t=ub.values().next();return t.done?!1:(ub.delete(t.value),!0)}function pb(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(db(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function mb(e){return t=>{let n=new WeakSet;t.state.doc.descendants(t=>{t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&n.add(t)});let r=lb(e.name);if(e.name===`Tabs`){let e=lb(`Tab`),t=lb(`Tab`),n=e.attrs,i=t.attrs;n.props={...n.props,label:`Tab 1`},i.props={...i.props,label:`Tab 2`},r.content=[e,t]}t.chain().focus().insertContent(r).run();let i=-1;t.state.doc.descendants((t,r)=>{if(i>=0)return!1;t.type.name===`jsxComponent`&&t.attrs.componentName===e.name&&!n.has(t)&&(i=r)}),!(i<0)&&pb(t,i,e)}}var hb=new Set([`File`,`Tab`]);function gb(){return[{name:`component-File`,label:ai._({id:`J2eKUI`}),icon:$a,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",command:vb,preview:{description:ai._({id:`t-JXbf`}),render:()=>(0,Z.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5`,children:[(0,Z.jsx)($a,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:`quarterly-report.pdf`}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`1.4 MB`})]})}}]}function _b(){return[...ib().filter(e=>e.surface===`canonical`&&!hb.has(e.name)).map(e=>{let t=sb[e.name],n=e.Component,r=t?{description:ai._(t.description),render:t.render??(()=>(0,Z.jsx)(n,{...t.props,children:t.children}))}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:Qg(e.icon),category:e.category??`content`,command:mb(e),aliases:e.searchTerms,description:e.description,preview:r}}),...gb()]}function vb(e){let t=document.createElement(`input`);t.type=`file`,t.accept=`*/*`,t.style.display=`none`,t.addEventListener(`change`,()=>{let n=t.files?.[0];if(n){let t=e.state.selection.from;xg(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function yb(){return[{name:`link`,label:ai._({id:`yzF66j`}),icon:fo,category:`insert`,aliases:[`url`,`href`,`external`,`web`,`hyperlink`,`wiki`,`wikilink`,`[[`,`internal`,`page`,`backlink`,`cross-link`],description:`Link to a page or external URL`,preview:{description:ai._({id:`5WDhAk`}),render:()=>(0,Z.jsx)(`p`,{className:`leading-7 text-sm`,children:(0,Z.jsx)(o,{id:`u-9fWA`,components:{0:(0,Z.jsx)(`span`,{className:`font-medium text-azure-blue underline underline-offset-2 dark:text-sky-blue`})}})})},command:e=>{let t=e.state.selection.from;e.chain().focus().insertContent({type:`text`,text:`link`,marks:[{type:`link`,attrs:{href:``}}]}).run();let n=Fg(e.state,t,`link`);n&&(Og(n),requestAnimationFrame(()=>{Xg(e).setActiveNode(n)}))}},{name:`component-Tag`,label:ai._({id:`UL8A9w`}),icon:no,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:ai._({id:`5ClEAu`}),render:()=>(0,Z.jsx)(`p`,{className:`text-sm leading-7`,children:(0,Z.jsx)(o,{id:`KZLdgR`,components:{0:(0,Z.jsx)(`a`,{className:`tag pointer-events-none`})}})})},command:e=>{e.chain().insertTag(``).run()}}]}function bb(e,t){e.chain().focus().insertContent({type:`codeBlock`,attrs:{language:`html`,meta:`preview`},content:[{type:`text`,text:t}]}).run()}var xb=`<div style="padding:20px;font-family:system-ui,sans-serif;color:var(--foreground)">
3
3
  <h1 style="margin:0 0 8px;font-size:20px;font-weight:600">Hello, world!</h1>
4
4
  <p style="margin:0;color:var(--muted-foreground)">Edit this HTML — the preview updates live.</p>
5
5
  </div>`,Sb={chart:{icon:Va,aliases:[`chart`,`bar`,`graph`,`plot`,`viz`,`data`,`embed`,`preview`],render:()=>(0,Z.jsxs)(`div`,{className:`flex h-20 w-full items-end gap-1.5`,children:[(0,Z.jsx)(`div`,{className:`h-[45%] flex-1 rounded-t-sm bg-chart-1`}),(0,Z.jsx)(`div`,{className:`h-[70%] flex-1 rounded-t-sm bg-chart-2`}),(0,Z.jsx)(`div`,{className:`h-[90%] flex-1 rounded-t-sm bg-chart-3`}),(0,Z.jsx)(`div`,{className:`h-[60%] flex-1 rounded-t-sm bg-chart-4`}),(0,Z.jsx)(`div`,{className:`h-[80%] flex-1 rounded-t-sm bg-chart-5`})]})},"stat-cards":{icon:oo,aliases:[`stat`,`stats`,`metric`,`metrics`,`cards`,`kpi`,`embed`,`preview`],render:()=>(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 rounded-md border border-border bg-card p-2`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Users`}),(0,Z.jsx)(`div`,{className:`text-sm font-bold text-card-foreground`,children:`12.4k`}),(0,Z.jsx)(`div`,{className:`text-[10px] font-semibold text-chart-2`,children:`+8.2%`})]}),(0,Z.jsxs)(`div`,{className:`flex-1 rounded-md border border-border bg-card p-2`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Revenue`}),(0,Z.jsx)(`div`,{className:`text-sm font-bold text-card-foreground`,children:`$48k`}),(0,Z.jsx)(`div`,{className:`text-[10px] font-semibold text-chart-1`,children:`+3.1%`})]})]})},"custom-svg":{icon:Eo,aliases:[`svg`,`vector`,`graphic`,`illustration`,`ring`,`embed`,`preview`],render:()=>(0,Z.jsx)(`div`,{className:`flex items-center justify-center text-chart-1`,children:(0,Z.jsxs)(`svg`,{width:`72`,height:`72`,viewBox:`0 0 72 72`,"aria-hidden":`true`,children:[(0,Z.jsx)(`circle`,{cx:`36`,cy:`36`,r:`28`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.15`,strokeWidth:`9`}),(0,Z.jsx)(`circle`,{cx:`36`,cy:`36`,r:`28`,fill:`none`,stroke:`currentColor`,strokeWidth:`9`,strokeLinecap:`round`,strokeDasharray:`176`,strokeDashoffset:`53`,transform:`rotate(-90 36 36)`})]})})},"interactive-control":{icon:ko,aliases:[`interactive`,`slider`,`control`,`widget`,`input`,`embed`,`preview`],render:()=>(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-bold text-chart-1`,children:`$2,500`}),(0,Z.jsxs)(`div`,{className:`relative h-1.5 rounded-full bg-muted`,children:[(0,Z.jsx)(`div`,{className:`absolute inset-y-0 left-0 w-1/3 rounded-full bg-primary`}),(0,Z.jsx)(`div`,{className:`-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/3 size-3 rounded-full bg-primary`})]}),(0,Z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Drag to adjust`})]})}};function Cb(){return{name:`embed-starter-html`,label:ai._({id:`FBknns`}),icon:Ja,category:`embed`,aliases:[`html`,`embed`,`preview`,`iframe`,`sandbox`,`web`,`snippet`],description:ai._({id:`4niEzY`}),command:e=>bb(e,xb),preview:{description:ai._({id:`rageVb`}),render:()=>(0,Z.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,Z.jsx)(`span`,{className:`ml-1.5 flex-1 truncate rounded-sm bg-background px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:`sandbox`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-3`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-foreground text-sm`,children:(0,Z.jsx)(o,{id:`3HNlwb`})}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:(0,Z.jsx)(o,{id:`bH382I`})})]})]})}}}function wb(){let e=G.map(e=>{let t=Sb[e.id];return{name:`embed-starter-${e.id}`,label:e.title,icon:t.icon,category:`embed`,command:t=>bb(t,e.html),aliases:t.aliases,description:e.description,preview:{description:e.description,render:t.render}}});return[Cb(),...e]}function Tb(){return[{name:`heading1`,label:ai._({id:`lXKZGw`}),icon:ro,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:1}).run(),aliases:[`h1`],preview:{description:ai._({id:`3J7d2N`}),render:()=>(0,Z.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:(0,Z.jsx)(o,{id:`lXKZGw`})})}},{name:`heading2`,label:ai._({id:`El7NbA`}),icon:io,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:2}).run(),aliases:[`h2`],preview:{description:ai._({id:`LXdWeS`}),render:()=>(0,Z.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:(0,Z.jsx)(o,{id:`El7NbA`})})}},{name:`heading3`,label:ai._({id:`SFN6dN`}),icon:ao,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:3}).run(),aliases:[`h3`],preview:{description:ai._({id:`g4XBm0`}),render:()=>(0,Z.jsx)(`h3`,{className:`text-base font-semibold tracking-tight`,children:(0,Z.jsx)(o,{id:`SFN6dN`})})}},{name:`bulletList`,label:ai._({id:`s1c0ja`}),icon:ho,category:`basic`,command:e=>e.chain().focus().toggleBulletList().run(),aliases:[`ul`,`unordered`],preview:{description:ai._({id:`fYjgXu`}),render:()=>(0,Z.jsxs)(`ul`,{className:`list-disc pl-5 text-sm leading-7`,children:[(0,Z.jsx)(`li`,{children:(0,Z.jsx)(o,{id:`FCxvG5`})}),(0,Z.jsx)(`li`,{children:(0,Z.jsx)(o,{id:`saIASg`})})]})}},{name:`orderedList`,label:ai._({id:`Uci-Ph`}),icon:po,category:`basic`,command:e=>e.chain().focus().toggleOrderedList().run(),aliases:[`ol`,`numbered`],preview:{description:ai._({id:`rXz97P`}),render:()=>(0,Z.jsxs)(`ol`,{className:`list-decimal pl-5 text-sm leading-7`,children:[(0,Z.jsx)(`li`,{children:(0,Z.jsx)(o,{id:`FCxvG5`})}),(0,Z.jsx)(`li`,{children:(0,Z.jsx)(o,{id:`saIASg`})})]})}},{name:`taskList`,label:ai._({id:`G_686w`}),icon:mo,category:`basic`,command:e=>e.chain().focus().toggleTaskList().run(),aliases:[`todo`,`checklist`,`checkbox`],preview:{description:ai._({id:`yutJKi`}),render:()=>(0,Z.jsxs)(`ul`,{className:`space-y-1.5 text-sm`,children:[(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:!0,readOnly:!0,className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground line-through`,children:(0,Z.jsx)(o,{id:`DPfwMq`})})]}),(0,Z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,readOnly:!0,className:`size-3.5`}),(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`rZ9HZq`})})]})]})}},{name:`blockquote`,label:ai._({id:`ZhhOwV`}),icon:Co,category:`basic`,command:e=>e.chain().focus().toggleBlockquote().run(),aliases:[`quote`],preview:{description:ai._({id:`w7nm4K`}),render:()=>(0,Z.jsx)(`blockquote`,{className:`border-l-2 border-muted-foreground/40 pl-3 text-sm italic text-muted-foreground`,children:(0,Z.jsx)(o,{id:`74-bX-`})})}},{name:`codeBlock`,label:ai._({id:`N2eHWq`}),icon:qa,category:`basic`,command:e=>e.chain().focus().toggleCodeBlock({language:`js`}).run(),aliases:[`code`,`fence`],preview:{description:ai._({id:`XpIZmv`}),render:()=>(0,Z.jsx)(`pre`,{className:`rounded-md bg-muted px-2.5 py-2 font-mono text-xs leading-5`,children:(0,Z.jsx)(`code`,{children:`const greeting = "Hello";
@@ -32,4 +32,4 @@ body{background:var(--background);color:var(--foreground)}
32
32
  </style>`}function IE(e){return`<script>(function(){var d=document.documentElement;${e===`dark`?`d.classList.add('dark');`:``}addEventListener('message',function(e){if(e.source!==parent)return;var t=e&&e.data&&e.data.${DE};if(t==='dark'){d.classList.add('dark');}else if(t==='light'){d.classList.remove('dark');}});var raf;function report(){var b=document.body;if(!b)return;var r=b.getBoundingClientRect();var mb=parseFloat(getComputedStyle(b).marginBottom)||0;parent.postMessage({${kE}:Math.ceil(r.bottom+mb)},'*');}function schedule(){if(raf){cancelAnimationFrame(raf);}raf=requestAnimationFrame(report);}function init(){schedule();addEventListener('load',schedule);if(window.ResizeObserver){try{new ResizeObserver(schedule).observe(document.body);}catch(_e){}}}if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',init);}else{init();}var cspSeen=new Set();var cspList=[];var cspTrunc=false;var cspTimer;function cspFlush(){parent.postMessage({${jE}:{blocked:cspList.slice(),truncated:cspTrunc}},'*');}addEventListener('securitypolicyviolation',function(e){if(cspTrunc)return;var dir=(e&&(e.effectiveDirective||e.violatedDirective))||'';var uri=(e&&e.blockedURI)||'';var k=dir+' '+uri;if(cspSeen.has(k))return;cspSeen.add(k);if(cspList.length<20){cspList.push({directive:dir,uri:uri});}else{cspTrunc=true;}if(cspTimer){clearTimeout(cspTimer);}cspTimer=setTimeout(cspFlush,250);});})();<\/script>`}var LE=`default-src 'none'; script-src 'unsafe-inline' https:; style-src 'unsafe-inline' https: data:; img-src https: data: blob:; font-src https: data:; connect-src https: wss: data: blob:; media-src https: data: blob:; frame-src https:; child-src https:; form-action 'none'; base-uri 'none';`;function RE(e){return`<meta http-equiv="Content-Security-Policy" content="${LE}">
33
33
  ${FE()}
34
34
  ${NE}
35
- ${IE(e)}`}var zE=`plaintext`;function BE(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?`dark`:`light`}function VE(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(!1),a,o;return n[0]!==e||n[1]!==t?(a=()=>{let n=()=>{let n=typeof t==`function`?t():void 0;if(typeof n!=`number`)return;let r=e.state.doc.nodeAt(n);if(!r)return;let{from:a,to:o}=e.state.selection,s=n,c=a<n+r.nodeSize&&o>s;i(e=>e===c?e:c)};return n(),e.on(`selectionUpdate`,n),()=>{e.isDestroyed||e.off(`selectionUpdate`,n)}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function HE(e){let t=(0,$.c)(185),{node:n,updateAttributes:r,editor:i,getPos:a,selected:l}=e,{_:u}=s(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),{resolvedTheme:S}=c(),C;t[0]===S?C=t[1]:(C=S===`dark`||S===`light`?S:BE(),t[0]=S,t[1]=C);let w=C,[T]=(0,Q.useState)(BE),E=n.attrs.language??null,D=n.attrs.meta??null,O;t[2]===D?O=t[3]:(O=wE(D),t[2]=D,t[3]=O);let k=O,[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(!1),P=Zn(),[F,I]=(0,Q.useState)(!1),L=(0,Q.useId)(),R=`${L}-title-input`,ee=`${L}-title-help`,z=(0,Q.useRef)(D),te,ne;t[4]===D?(te=t[5],ne=t[6]):(te=()=>{z.current=D},ne=[D],t[4]=D,t[5]=te,t[6]=ne),(0,Q.useEffect)(te,ne);let re,B,V,H,U;if(t[7]!==u||t[8]!==E||t[9]!==D){B=sE(E),re=E?aE.find(e=>e.value===B)?.label??E:u({id:`LpB85N`});let e;t[15]===D?e=t[16]:(e=dE(D,`preview`),t[15]=D,t[16]=e),H=e,V=B?mE.has(B):!1,U=hE(B,D),t[7]=u,t[8]=E,t[9]=D,t[10]=re,t[11]=B,t[12]=V,t[13]=H,t[14]=U}else re=t[10],B=t[11],V=t[12],H=t[13],U=t[14];let W=U,G;t[17]!==W||t[18]!==D?(G=W?bE(D):null,t[17]=W,t[18]=D,t[19]=G):G=t[19];let ie=G,K;t[20]!==W||t[21]!==D?(K=W?xE(D):null,t[20]=W,t[21]=D,t[22]=K):K=t[22];let ae=K,oe=ie??(v===null?void 0:`${v}px`),q=!W,se,ce;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>()=>{h.current!==null&&window.clearTimeout(h.current)},ce=[],t[23]=se,t[24]=ce):(se=t[23],ce=t[24]),(0,Q.useEffect)(se,ce);let J=i.isEditable,le=VE(i,a),ue,Y;t[25]===w?(ue=t[26],Y=t[27]):(ue=()=>{_.current?.contentWindow?.postMessage(OE(w),`*`)},Y=[w],t[25]=w,t[26]=ue,t[27]=Y),(0,Q.useEffect)(ue,Y);let de,fe;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>{let e=function(e){if(e.source!==_.current?.contentWindow)return;let t=AE(e.data);if(t!==null){y(e=>e!==null&&Math.abs(e-t)<=2?e:t);return}let n=ME(e.data);n!==null&&x(n)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},fe=[],t[28]=de,t[29]=fe):(de=t[28],fe=t[29]),(0,Q.useEffect)(de,fe);let pe;t[30]===n.textContent?pe=t[31]:(pe=()=>{let e=n.textContent,t=()=>{m(!0),h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>m(!1),1200)};try{typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e).then(t,qE)}catch{}},t[30]=n.textContent,t[31]=pe);let me=pe,he;t[32]!==i||t[33]!==a?(he=()=>{let e=typeof a==`function`?a():void 0;if(typeof e==`number`)try{i.chain().focus().setNodeSelection(e).deleteSelection().run()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;console.warn(`[CodeBlockView] delete failed — position race`,t)}},t[32]=i,t[33]=a,t[34]=he):he=t[34];let ge=he,_e;t[35]!==H||t[36]!==D||t[37]!==r?(_e=()=>{r({meta:H?pE(D,`preview`):fE(D,`preview`)})},t[35]=H,t[36]=D,t[37]=r,t[38]=_e):_e=t[38];let ve=_e,ye;t[39]!==D||t[40]!==r?(ye=e=>{let t=TE(D,e.length>0?e:null);t!==D&&r({meta:t})},t[39]=D,t[40]=r,t[41]=ye):ye=t[41];let be=ye,xe;t[42]!==i.state||t[43]!==i.view||t[44]!==a||t[45]!==n.attrs||t[46]!==n.nodeSize||t[47]!==n.type?(xe=e=>{let t=typeof a==`function`?a():void 0;if(typeof t==`number`)try{let{schema:r,tr:a}=i.state,o=n.type.create(n.attrs,e.length>0?r.text(e):null);a.replaceWith(t,t+n.nodeSize,o),i.view.dispatch(a)}catch(e){let t=e;if(!(t instanceof RangeError))throw t;console.warn(`[CodeBlockView] edit-save failed — position race`,t)}},t[42]=i.state,t[43]=i.view,t[44]=a,t[45]=n.attrs,t[46]=n.nodeSize,t[47]=n.type,t[48]=xe):xe=t[48];let Se=xe,Ce;t[49]===r?Ce=t[50]:(Ce=e=>{let t=`${Math.round(e.width)}px`,n=`${Math.round(e.height)}px`;r({meta:yE(yE(z.current,`h`,n),`w`,t)})},t[49]=r,t[50]=Ce);let we=Ce,Te=E??void 0,Ee=le?`true`:void 0,De=l?`true`:void 0,Oe=W?`true`:void 0,ke=q?`true`:`false`,Ae=F?`true`:void 0,je,Me;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(je=()=>I(!0),Me=()=>I(!1),t[51]=je,t[52]=Me):(je=t[51],Me=t[52]);let Ne;t[53]!==u||t[54]!==w||t[55]!==T||t[56]!==q||t[57]!==oe||t[58]!==we||t[59]!==n.textContent||t[60]!==W||t[61]!==ae?(Ne=W?(0,Z.jsxs)(`div`,{ref:g,className:Ft(`ok-codeblock-preview`,q?`ok-codeblock-preview--with-code`:`ok-codeblock-preview--solo`),contentEditable:!1,style:{...oe?{height:oe}:{},...ae?{width:ae}:{}},onMouseDown:KE,children:[(0,Z.jsx)(`iframe`,{title:u({id:`G7cMuO`}),ref:_,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:RE(T)+n.textContent,className:`ok-codeblock-preview-frame`,onLoad:()=>{x(null),_.current?.contentWindow?.postMessage(OE(w),`*`)}}),(0,Z.jsx)(d_,{targetRef:g,bounds:{minWidth:192,maxWidth:Math.round(window.innerWidth*.9),minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=g.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:we})]}):null,t[53]=u,t[54]=w,t[55]=T,t[56]=q,t[57]=oe,t[58]=we,t[59]=n.textContent,t[60]=W,t[61]=ae,t[62]=Ne):Ne=t[62];let Pe;t[63]!==b||t[64]!==W?(Pe=W&&b?(0,Z.jsx)(iE,{blocked:b.blocked,truncated:b.truncated,onDismiss:()=>x(null)}):null,t[63]=b,t[64]=W,t[65]=Pe):Pe=t[65];let Fe;t[66]===k?Fe=t[67]:(Fe=k?(0,Z.jsx)(`div`,{className:`ok-codeblock-title`,contentEditable:!1,"data-testid":`ok-codeblock-title`,title:k,children:(0,Z.jsx)(`span`,{className:`ok-codeblock-title-text`,children:k})}):null,t[66]=k,t[67]=Fe);let Ie=W&&q?`rounded-b-lg`:null,Le=W?null:`rounded-lg`,Re;t[68]!==Ie||t[69]!==Le?(Re=Ft(`ok-codeblock-pre m-0 overflow-x-auto px-5 py-4 font-mono text-sm leading-relaxed`,Ie,Le),t[68]=Ie,t[69]=Le,t[70]=Re):Re=t[70];let ze=!q||void 0,Be=E?`language-${E}`:void 0,Ve;t[71]===Be?Ve=t[72]:(Ve=Ft(`hljs block whitespace-pre bg-transparent p-0`,Be),t[71]=Be,t[72]=Ve);let He;t[73]===Ve?He=t[74]:(He=(0,Z.jsx)(Nn,{as:`code`,className:Ve}),t[73]=Ve,t[74]=He);let Ue;t[75]!==Re||t[76]!==ze||t[77]!==He?(Ue=(0,Z.jsx)(`pre`,{className:Re,"aria-hidden":ze,children:He}),t[75]=Re,t[76]=ze,t[77]=He,t[78]=Ue):Ue=t[78];let We;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(We={[dC]:`true`},t[79]=We):We=t[79];let Ge=!J,Ke;t[80]!==u||t[81]!==re?(Ke=u({id:`c5f7sm`,values:{currentLabel:re}}),t[80]=u,t[81]=re,t[82]=Ke):Ke=t[82];let qe;t[83]===re?qe=t[84]:(qe=(0,Z.jsx)(`span`,{children:re}),t[83]=re,t[84]=qe);let Je;t[85]===J?Je=t[86]:(Je=J?(0,Z.jsx)(Vn,{className:`size-3 opacity-60`,"aria-hidden":`true`}):null,t[85]=J,t[86]=Je);let Ye;t[87]!==Ge||t[88]!==Ke||t[89]!==qe||t[90]!==Je?(Ye=(0,Z.jsx)(ku,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:Ge,className:`ok-codeblock-chrome-btn ok-codeblock-chrome-lang`,"aria-label":Ke,children:[qe,Je]})}),t[87]=Ge,t[88]=Ke,t[89]=qe,t[90]=Je,t[91]=Ye):Ye=t[91];let Xe;t[92]===u?Xe=t[93]:(Xe=u({id:`G_mWXb`}),t[92]=u,t[93]=Xe);let Ze;t[94]===Xe?Ze=t[95]:(Ze=(0,Z.jsx)(Su,{placeholder:Xe}),t[94]=Xe,t[95]=Ze);let Qe;t[96]===u?Qe=t[97]:(Qe=u({id:`ETyvvg`}),t[96]=u,t[97]=Qe);let $e;t[98]===Qe?$e=t[99]:($e=(0,Z.jsx)(wu,{children:Qe}),t[98]=Qe,t[99]=$e);let et;t[100]!==i.commands||t[101]!==B||t[102]!==E||t[103]!==r?(et=aE.map(e=>{let t=e.value===zE?!E||B===zE:B===e.value;return(0,Z.jsxs)(Eu,{value:`${e.label} ${e.value} ${e.aliases?.join(` `)??``}`,onSelect:()=>{r({language:e.value===zE?null:e.value}),f(!1),i.commands.focus()},children:[(0,Z.jsx)(`span`,{className:`flex-1`,children:e.label}),t?(0,Z.jsx)(Bn,{className:`size-3.5`,"aria-hidden":`true`}):null]},e.value)}),t[100]=i.commands,t[101]=B,t[102]=E,t[103]=r,t[104]=et):et=t[104];let tt;t[105]===et?tt=t[106]:(tt=(0,Z.jsx)(Tu,{children:et}),t[105]=et,t[106]=tt);let nt;t[107]!==$e||t[108]!==tt?(nt=(0,Z.jsxs)(Cu,{children:[$e,tt]}),t[107]=$e,t[108]=tt,t[109]=nt):nt=t[109];let rt;t[110]!==Ze||t[111]!==nt?(rt=(0,Z.jsx)(Au,{align:`end`,sideOffset:6,className:`w-56 p-0`,children:(0,Z.jsxs)(bu,{filter:WE,children:[Ze,nt]})}),t[110]=Ze,t[111]=nt,t[112]=rt):rt=t[112];let it;t[113]!==d||t[114]!==Ye||t[115]!==rt?(it=(0,Z.jsxs)(Ou,{open:d,onOpenChange:f,children:[Ye,rt]}),t[113]=d,t[114]=Ye,t[115]=rt,t[116]=it):it=t[116];let at;t[117]!==u||t[118]!==J||t[119]!==W?(at=J&&W?(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":u({id:`R3y75Z`}),"data-testid":`ok-codeblock-edit-btn`,onClick:()=>N(!0),children:(0,Z.jsx)($n,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[117]=u,t[118]=J,t[119]=W,t[120]=at):at=t[120];let ot;t[121]!==u||t[122]!==J||t[123]!==ve||t[124]!==V||t[125]!==H?(ot=J&&V?(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"data-active":H?`true`:void 0,"aria-pressed":H,"aria-label":u(H?{id:`xHGM4U`}:{id:`7OwvEL`}),onClick:ve,children:H?(0,Z.jsx)(Za,{className:`size-3.5`}):(0,Z.jsx)(er,{className:`size-3.5`})}):null,t[121]=u,t[122]=J,t[123]=ve,t[124]=V,t[125]=H,t[126]=ot):ot=t[126];let st;t[127]!==u||t[128]!==J||t[129]!==be||t[130]!==A||t[131]!==k||t[132]!==ee||t[133]!==R?(st=J?(0,Z.jsxs)(Ou,{open:A,onOpenChange:j,children:[(0,Z.jsx)(ku,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"data-active":k?`true`:void 0,"aria-label":u({id:`DDTdLl`}),children:(0,Z.jsx)(To,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Z.jsx)(Au,{align:`end`,sideOffset:6,className:`w-64 p-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:R,className:`text-2xs font-mono uppercase tracking-wide text-muted-foreground`,children:(0,Z.jsx)(o,{id:`MHrjPM`})}),(0,Z.jsx)(ri,{id:R,type:`text`,value:k??``,placeholder:u({id:`mk2poV`}),"data-testid":`ok-codeblock-title-input`,"aria-describedby":ee,onChange:e=>be(e.target.value),onKeyDown:e=>{(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),j(!1))},className:`h-8`}),(0,Z.jsx)(`p`,{id:ee,className:`text-2xs text-muted-foreground`,children:(0,Z.jsx)(o,{id:`lond3p`})})]})})]}):null,t[127]=u,t[128]=J,t[129]=be,t[130]=A,t[131]=k,t[132]=ee,t[133]=R,t[134]=st):st=t[134];let ct;t[135]!==u||t[136]!==i||t[137]!==P||t[138]!==n.textContent||t[139]!==E||t[140]!==D?(ct=P?null:(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":u({id:`00c7t0`}),"data-testid":`ok-codeblock-ask-ai-btn`,onClick:()=>{let e=Yt(i),t=E??``,r=D?`${t} ${D}`.trim():t,a=n.textContent,o=(a.match(/`+/g)??[]).reduce(UE,0),s="`".repeat(Math.max(3,o+1)),c=`${s}${r}\n${a}\n${s}`;requestAnimationFrame(()=>{if(e===null||a.trim()===``){$S();return}nC(ut({relativePath:Qn(e),instruction:``,selectionMarkdown:c,target:`claude-code`}))})},children:(0,Z.jsx)(Xn,{className:`size-3.5`,"aria-hidden":`true`})}),t[135]=u,t[136]=i,t[137]=P,t[138]=n.textContent,t[139]=E,t[140]=D,t[141]=ct):ct=t[141];let lt;t[142]!==u||t[143]!==p?(lt=u(p?{id:`6V3Ea3`}:{id:`NmPNJJ`}),t[142]=u,t[143]=p,t[144]=lt):lt=t[144];let dt;t[145]===p?dt=t[146]:(dt=p?(0,Z.jsx)(Bn,{className:`size-3.5`,"aria-hidden":`true`}):(0,Z.jsx)(Jn,{className:`size-3.5`,"aria-hidden":`true`}),t[145]=p,t[146]=dt);let ft;t[147]!==me||t[148]!==lt||t[149]!==dt?(ft=(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":lt,onClick:me,children:dt}),t[147]=me,t[148]=lt,t[149]=dt,t[150]=ft):ft=t[150];let pt;t[151]!==u||t[152]!==J||t[153]!==ge?(pt=J?(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn ok-codeblock-chrome-btn--delete`,"aria-label":u({id:`oBXkm2`}),onClick:ge,children:(0,Z.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[151]=u,t[152]=J,t[153]=ge,t[154]=pt):pt=t[154];let mt;t[155]!==it||t[156]!==at||t[157]!==ot||t[158]!==st||t[159]!==ct||t[160]!==ft||t[161]!==pt?(mt=(0,Z.jsxs)(`div`,{className:`ok-codeblock-chrome`,contentEditable:!1,onMouseDown:GE,...We,children:[it,at,ot,st,ct,ft,pt]}),t[155]=it,t[156]=at,t[157]=ot,t[158]=st,t[159]=ct,t[160]=ft,t[161]=pt,t[162]=mt):mt=t[162];let ht;t[163]!==u||t[164]!==T||t[165]!==M||t[166]!==J||t[167]!==Se||t[168]!==n.textContent||t[169]!==B||t[170]!==W?(ht=J&&W?(0,Z.jsx)(nE,{open:M,onOpenChange:N,initialValue:n.textContent,language:B===`xml`?`html`:`plain`,title:u({id:`R3y75Z`}),renderPreview:e=>(0,Z.jsx)(`iframe`,{title:u({id:`G7cMuO`}),sandbox:`allow-scripts`,className:`size-full border-0`,srcDoc:RE(T)+e}),onSave:Se}):null,t[163]=u,t[164]=T,t[165]=M,t[166]=J,t[167]=Se,t[168]=n.textContent,t[169]=B,t[170]=W,t[171]=ht):ht=t[171];let gt;return t[172]!==Te||t[173]!==Ee||t[174]!==De||t[175]!==Oe||t[176]!==ke||t[177]!==Ae||t[178]!==Ne||t[179]!==Pe||t[180]!==Fe||t[181]!==Ue||t[182]!==mt||t[183]!==ht?(gt=(0,Z.jsxs)(Dn,{className:`ok-codeblock relative my-3`,"data-language":Te,"data-cursor-inside":Ee,"data-selected":De,"data-preview":Oe,"data-code-visible":ke,"data-hovered":Ae,onMouseEnter:je,onMouseLeave:Me,children:[Ne,Pe,Fe,Ue,mt,ht]}),t[172]=Te,t[173]=Ee,t[174]=De,t[175]=Oe,t[176]=ke,t[177]=Ae,t[178]=Ne,t[179]=Pe,t[180]=Fe,t[181]=Ue,t[182]=mt,t[183]=ht,t[184]=gt):gt=t[184],gt}function UE(e,t){return Math.max(e,t.length)}function WE(e,t){return t?+!!e.toLowerCase().includes(t.toLowerCase()):1}function GE(e){return e.stopPropagation()}function KE(e){return e.stopPropagation()}function qE(){}function JE(e,t=[]){return e.flatMap(e=>{if(e.type===`text`)return[{text:e.value,classes:t}];let n=[...t,...e.properties?.className??[]];return JE(e.children,n)})}function YE(e){let{doc:t,name:n,lowlight:r,defaultLanguage:i}=e,a=[],o=r.listLanguages();return Se(t,e=>e.type.name===n).forEach(e=>{let t=e.pos+1,n=e.node.attrs.language||i;if(!n||!(o.includes(n)||(r.registered?.(n)??!1)))return;let s;try{s=r.highlight(n,e.node.textContent)}catch{return}let c=s.children??[];for(let e of JE(c)){let n=t+e.text.length;e.classes.length>0&&a.push(rt.inline(t,n,{class:e.classes.join(` `)})),t=n}}),Ue.create(t,a)}function XE(e){let{name:t,lowlight:n,defaultLanguage:r}=e,i=new Et({key:new ke(`codeBlockLowlight`),state:{init:(e,{doc:i})=>YE({doc:i,name:t,lowlight:n,defaultLanguage:r}),apply:(e,i,a,o)=>{if(!e.docChanged)return i.map(e.mapping,e.doc);let s=a.selection.$head.parent.type.name,c=o.selection.$head.parent.type.name,l=Se(a.doc,e=>e.type.name===t),u=Se(o.doc,e=>e.type.name===t);return[s,c].includes(t)||u.length!==l.length||e.steps.some(e=>{let t=e;return t.from===void 0||t.to===void 0?!1:l.some(e=>t.from<e.pos+e.node.nodeSize&&t.to>e.pos)})?YE({doc:e.doc,name:t,lowlight:n,defaultLanguage:r}):i.map(e.mapping,e.doc)}},props:{decorations(e){return i.getState(e)}}});return i}var ZE=XS(KS),QE=Oe.extend({addOptions(){return{...this.parent?.(),enableTabIndentation:!0,tabSize:2}},addNodeView(){return bn(HE)},addProseMirrorPlugins(){return[...this.parent?.()??[],XE({name:this.name,lowlight:ZE,defaultLanguage:null})]},addInputRules(){return[...this.parent?.()??[],ze({find:/^```$/,type:this.type,getAttributes:()=>({language:`js`})})]}});function $E(e){return!!e.getMeta(jd)}function eD(e,t){let n=jd.getState(e);return bf(n.doc,n.type,t,n.binding.mapping)||0}function tD(e,t){let n=jd.getState(e);return vf(t,n.type,n.binding.mapping)}var nD=class e extends O{constructor(e,t){super(e),this.yRelativePosition=t}static fromJSON(t){return new e(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function rD(e,t){return new nD(e,tD(t,e))}function iD(e,t,n){let r=e instanceof nD?e.yRelativePosition:null;if($E(t)&&r)return{position:new nD(eD(n,r),r),mapResult:null};let i=Ee(e,t),a=i.position.position;return{position:new nD(a,r??tD(n,a)),mapResult:i.mapResult}}var aD=Y.create({name:`collaboration`,priority:1e3,addOptions(){return{document:null,field:`default`,fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name===`undoRedo`)&&console.warn(`[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".`)},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>iD(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>rD(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Md.getState(t).undoManager.undoStack.length===0?!1:n?Of(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Md.getState(t).undoManager.redoStack.length===0?!1:n?kf(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){let e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=Mf(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let{undoManager:t}=Md.getState(e.state);t.restore&&=(t.restore(),()=>{});let r=n?n(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),n=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on(`afterTransaction`,t.afterTransactionHandler),t._observers=n},r?.destroy&&r.destroy()}}},[Bd(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new Et({key:new ke(`filterInvalidContent`),filterTransaction:t=>{if(!$E(t))return!0;if(this.storage.isDisabled)return!1;if(!t.docChanged)return!0;try{return t.doc.check(),!0}catch(t){return this.storage.isDisabled=!0,this.editor.emit(`contentError`,{error:t,editor:this.editor,disableCollaboration:()=>{var t;(t=e.doc)==null||t.destroy()}}),!1}}})].filter(Boolean)}});function oD(e){if(!e.length)return Ue.empty;let t=[],n=e[0].$from.node(0);return e.forEach(e=>{let n=e.$from.pos,r=e.$from.nodeAfter;r&&t.push(rt.node(n,n+r.nodeSize,{class:`ProseMirror-selectednoderange`}))}),Ue.create(n,t)}function sD(e,t,n){let r=n.isText||n.isAtom?0:1;return{start:e+r,end:e+t-r}}function cD(e,t,n,r={}){let i=[],a=e.node(0),{extendOnBoundaryOverlap:o=!0}=r;typeof n==`number`&&n>=0||(n=e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos));let s=new b(e,t,n),c=s.depth===0?0:a.resolve(s.start).posAtIndex(0);return s.parent.forEach((n,r)=>{let l=c+r,u=l+n.nodeSize,d=sD(l,n.nodeSize,n),f=o?t.pos>=d.start&&e.pos<=d.end:t.pos>d.start&&e.pos<d.end;if(l<s.start||l>=s.end||!f)return;let p=new se(a.resolve(l),a.resolve(u));i.push(p)}),i}var lD=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return new uD(e.resolve(this.anchor),e.resolve(this.head))}},uD=class e extends wt{constructor(e,t,n,r=1){let{doc:i}=e,a=e===t,o=e.pos===i.content.size&&t.pos===i.content.size,s=a&&!o?i.resolve(t.pos+(r>0?1:-1)):t,c=a&&o?i.resolve(e.pos-(r>0?1:-1)):e,l=cD(c.min(s),c.max(s),n),u=s.pos>=e.pos?l[0].$from:l[l.length-1].$to,d=s.pos>=e.pos?l[l.length-1].$to:l[0].$from;super(u,d,l),this.depth=n}get $to(){return this.ranges[this.ranges.length-1].$to}eq(t){return t instanceof e&&t.$from.pos===this.$from.pos&&t.$to.pos===this.$to.pos}map(t,n){return new e(t.resolve(n.map(this.anchor)),t.resolve(n.map(this.head)))}toJSON(){return{type:`nodeRange`,anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){let{doc:t}=this.$from;if(this.isForwards&&this.ranges.length>1){let t=this.ranges.slice(0,-1),n=t[0].$from,r=t[t.length-1].$to;return new e(n,r,this.depth)}let n=this.ranges[0],r=t.resolve(Math.max(0,n.$from.pos-1));return new e(this.$anchor,r,this.depth)}extendForwards(){let{doc:t}=this.$from;if(this.isBackwards&&this.ranges.length>1){let t=this.ranges.slice(1),n=t[0].$from,r=t[t.length-1].$to;return new e(r,n,this.depth)}let n=this.ranges[this.ranges.length-1],r=t.resolve(Math.min(t.content.size,n.$to.pos+1));return new e(this.$anchor,r,this.depth)}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n,r,i=1){return new this(e.resolve(t),e.resolve(n),r,i)}getBookmark(){return new lD(this.anchor,this.head)}};uD.prototype.visible=!1;function dD(e){return e instanceof uD}Y.create({name:`nodeRange`,addOptions(){return{depth:void 0,key:`Mod`}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,selection:a,tr:o}=r,{anchor:s,head:c}=a;if(!dD(a)){let e=uD.create(i,s,c,t,-1);return o.setSelection(e),n.dispatch(o),!0}let l=a.extendBackwards();return o.setSelection(l),n.dispatch(o),!0},"Shift-ArrowDown":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,selection:a,tr:o}=r,{anchor:s,head:c}=a;if(!dD(a)){let e=uD.create(i,s,c,t);return o.setSelection(e),n.dispatch(o),!0}let l=a.extendForwards();return o.setSelection(l),n.dispatch(o),!0},"Mod-a":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,tr:a}=r,o=uD.create(i,0,i.content.size,t);return a.setSelection(o),n.dispatch(a),!0}}},onSelectionUpdate(){let{selection:e}=this.editor.state;dD(e)&&this.editor.view.dom.classList.add(`ProseMirror-noderangeselection`)},addProseMirrorPlugins(){let e=!1,t=!1;return[new Et({key:new ke(`nodeRange`),props:{attributes:()=>e?{class:`ProseMirror-noderangeselection`}:{class:``},handleDOMEvents:{mousedown:(e,n)=>{let{key:r}=this.options,i=/Mac/.test(navigator.platform),a=!!n.shiftKey,o=!!n.ctrlKey,s=!!n.altKey,c=!!n.metaKey;return(r==null||r===`Shift`&&a||r===`Control`&&o||r===`Alt`&&s||r===`Meta`&&c||r===`Mod`&&(i?c:o))&&(t=!0),t&&document.addEventListener(`mouseup`,()=>{t=!1;let{state:n}=e,{doc:r,selection:i,tr:a}=n,{$anchor:o,$head:s}=i;if(o.sameParent(s))return;let c=uD.create(r,o.pos,s.pos,this.options.depth);a.setSelection(c),e.dispatch(a)},{once:!0}),!1}},decorations:n=>{let{selection:r}=n,i=dD(r);if(e=!1,!t)return i?(e=!0,oD(r.ranges)):null;let{$from:a,$to:o}=r;if(!i&&a.sameParent(o))return null;let s=cD(a,o,this.options.depth);return s.length?(e=!0,oD(s)):null}}})]}});function fD(e){let t=``,n=getComputedStyle(e);for(let e=0;e<n.length;e+=1)t+=`${n[e]}:${n.getPropertyValue(n[e])};`;return t}function pD(e){let t=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName(`*`))],r=[t,...Array.from(t.getElementsByTagName(`*`))];return n.forEach((e,t)=>{r[t].style.cssText=fD(e)}),t}var mD=[{id:`listItemFirstChild`,evaluate:({parent:e,isFirst:t})=>t&&e&&[`listItem`,`taskItem`].includes(e.type.name)?1e3:0},{id:`listWrapperDeprioritize`,evaluate:({node:e})=>{let t=[`listItem`,`taskItem`],n=e.firstChild;return n&&t.includes(n.type.name)?1e3:0}},{id:`tableStructure`,evaluate:({node:e,parent:t})=>[`tableRow`,`tableCell`,`tableHeader`].includes(e.type.name)||t&&t.type.name===`tableHeader`?1e3:0},{id:`inlineContent`,evaluate:({node:e})=>e.isInline||e.isText?1e3:0}],hD={edges:[`left`,`top`],threshold:12,strength:500};function gD(e){return e===void 0||e===`left`?{...hD}:e===`right`?{edges:[`right`,`top`],threshold:12,strength:500}:e===`both`?{edges:[`left`,`right`,`top`],threshold:12,strength:500}:e===`none`?{edges:[],threshold:0,strength:0}:{...hD,...e}}function _D(e,t,n){if(n.edges.length===0)return!1;let r=t.getBoundingClientRect(),{threshold:i,edges:a}=n;return a.some(t=>t===`left`?e.x-r.left<i:t===`right`?r.right-e.x<i:t===`top`?e.y-r.top<i:t===`bottom`?r.bottom-e.y<i:!1)}function vD(e,t,n,r){return!t||n.edges.length===0?0:_D(e,t,n)?n.strength*r:0}var yD=1e3;function bD(e,t,n,r){let i=yD,a=!1;if(t.every(t=>{let n=t.evaluate(e);return i-=n,i<=0?(a=!0,!1):!0}),a)return-1;let o=e.view.nodeDOM(e.pos);return i-=vD(r,o,n,e.depth),i<=0?-1:i}function xD(e,t,n){return Array.from({length:t},(e,n)=>t-1-n).some(t=>n.includes(e.node(t).type.name))}function SD(e,t,n){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))return null;let r=e.posAtCoords({left:t.x,top:t.y});if(!r)return null;let{doc:i}=e.state,a=i.resolve(r.pos),o=[];n.defaultRules&&o.push(...mD),o.push(...n.rules);let s=Array.from({length:a.depth},(e,t)=>a.depth-t).map(r=>{let i=a.node(r),s=a.before(r);if(n.allowedContainers&&r>0&&!xD(a,r,n.allowedContainers))return null;let c=r>0?a.node(r-1):null,l=r>0?a.index(r-1):0,u=c?c.childCount:1,d=bD({node:i,pos:s,depth:r,parent:c,index:l,isFirst:l===0,isLast:l===u-1,$pos:a,view:e},o,n.edgeDetection,t);return d<0?null:{node:i,pos:s,depth:r,score:d,dom:e.nodeDOM(s)}}).filter(e=>e!==null),c=a.nodeAfter;if(c&&c.isAtom&&!c.isInline){let i=r.pos,l=a.depth+1,u=a.parent,d=a.index(),f=u.childCount,p=!0;if(n.allowedContainers&&(p=xD(a,l,n.allowedContainers)),p){let r=bD({node:c,pos:i,depth:l,parent:u,index:d,isFirst:d===0,isLast:d===f-1,$pos:a,view:e},o,n.edgeDetection,t);if(r>=0){let t=e.nodeDOM(i);t&&s.push({node:c,pos:i,depth:l,score:r,dom:t})}}}if(s.length===0)return null;s.sort((e,t)=>t.score===e.score?t.depth-e.depth:t.score-e.score);let l=s[0];return l.dom?{node:l.node,pos:l.pos,dom:l.dom}:null}function CD(e,t){let n=e;for(;n?.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return n?.parentElement===t.dom?n:void 0}function wD(e){return Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&e.width>0&&e.height>0}function TD(e,t,n,r=5){if(!Number.isFinite(t)||!Number.isFinite(n))return null;let i=e.dom,a=i.firstElementChild,o=i.lastElementChild;if(!a||!o)return null;let s=a.getBoundingClientRect(),c=o.getBoundingClientRect();if(!wD(s)||!wD(c))return null;let l=Math.min(Math.max(s.top+r,n),c.bottom-r),u=.5,d=Math.abs(s.left-c.left)<u,f=Math.abs(s.right-c.right)<u,p=s;d&&f&&(p=s);let m=Math.min(Math.max(p.left+r,t),p.right-r);return!Number.isFinite(m)||!Number.isFinite(l)?null:{x:m,y:l}}var ED=e=>{let{x:t,y:n,editor:r,nestedOptions:i}=e,{view:a,state:o}=r,s=TD(a,t,n,5);if(!s)return{resultElement:null,resultNode:null,pos:null};let{x:c,y:l}=s;if(i?.enabled){let e=SD(a,{x:c,y:l},i);return e?{resultElement:e.dom,resultNode:e.node,pos:e.pos}:{resultElement:null,resultNode:null,pos:null}}let u=a.root.elementsFromPoint(c,l),d;if(Array.prototype.some.call(u,e=>{if(!a.dom.contains(e))return!1;let t=CD(e,a);return t?(d=t,!0):!1}),!d){let e=a.posAtCoords({left:c,top:l});if(e){let t=o.doc.resolve(e.pos),n=Math.min(t.depth,1),r=n>0?t.before(n):t.pos,i=o.doc.nodeAt(r);if(i){let e=a.nodeDOM(r);return{resultElement:e instanceof HTMLElement?e:null,resultNode:i,pos:r}}}return{resultElement:null,resultNode:null,pos:null}}let f;try{f=a.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}let p=o.doc.nodeAt(f);if(!p){let e=o.doc.resolve(f),t=e.parent;return{resultElement:d,resultNode:t,pos:e.start()}}return{resultElement:d,resultNode:p,pos:f}};function DD(e,t){let n=null,r=e.nodeDOM(t);if(r instanceof Element)n=r;else{let{node:r,offset:i}=e.domAtPos(t),a=r.childNodes[i];a instanceof Element?n=a:r instanceof Element?n=r:r.nodeType===Node.TEXT_NODE&&r.parentElement&&(n=r.parentElement)}return(n?getComputedStyle(n).direction:getComputedStyle(e.dom).direction)||`ltr`}function OD(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function kD(e,t,n,r){let{doc:i}=t.view.state;if(n?.enabled&&r?.node&&r.pos>=0){let e=r.pos,t=r.pos+r.node.nodeSize;return[{$from:i.resolve(e),$to:i.resolve(t)}]}let a=ED({editor:t,x:e.clientX,y:e.clientY,direction:`right`,nestedOptions:n});if(!a.resultNode||a.pos===null)return[];let o=a.resultNode.isText||a.resultNode.isAtom?0:-1;return cD(i.resolve(a.pos),i.resolve(a.pos+a.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}function AD(e,t,n,r){let{view:i}=t;if(!e.dataTransfer)return;let{empty:a,$from:o,$to:s}=i.state.selection,c=kD(e,t,n,r),l=cD(o,s,0,{extendOnBoundaryOverlap:!1}),u=l.some(e=>c.find(t=>t.$from===e.$from&&t.$to===e.$to)),d=a||!u?c:l;if(!d.length)return;let{tr:f}=i.state,p=document.createElement(`div`),m=d[0].$from.pos,h=d[d.length-1].$to.pos;p.setAttribute(`dir`,DD(i,m));let g=n?.enabled&&r?.node,_,v;g?(_=i.state.doc.slice(m,h),v=bt.create(i.state.doc,m)):(v=uD.create(i.state.doc,m,h),_=v.content()),d.forEach(e=>{let t=pD(i.nodeDOM(e.$from.pos));p.append(t)}),p.style.position=`absolute`,p.style.top=`-10000px`,p.style.contentVisibility=`visible`,document.body.append(p);for(let e of p.querySelectorAll(`*`))e.style&&e.style.contentVisibility===`auto`&&(e.style.contentVisibility=`visible`);e.dataTransfer.clearData();let y=p.getBoundingClientRect(),b=i.nodeDOM(m),x=b&&b.nodeType===1?b.getBoundingClientRect():null,S=x?Math.min(e.clientX-x.left,y.width):Math.max(0,Math.min(e.clientX-y.left,y.width)),C=x?Math.min(Math.max(e.clientY-x.top,0),y.height):0;e.dataTransfer.setDragImage(p,S,C);let w=!1,T=()=>{w||(w=!0,OD(p),document.removeEventListener(`drop`,T),document.removeEventListener(`dragend`,T))},E=v instanceof bt?v:void 0;i.dragging={slice:_,move:!0,node:E},f.setSelection(v),i.dispatch(f),document.addEventListener(`drop`,T),document.addEventListener(`dragend`,T)}var jD=(e,t)=>{let n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},MD=(e,t)=>{let n=e.nodeAt(t),r=e.resolve(t),{depth:i}=r,a=n;for(;i>0;){let e=r.node(i);--i,i===0&&(a=e)}return a},ND=(e,t)=>{let n=jd.getState(e);return n?vf(t,n.type,n.binding.mapping):null},PD=(e,t)=>{let n=jd.getState(e);return n?bf(n.doc,n.type,t,n.binding.mapping)||0:-1},FD=(e,t)=>{let n=t;for(;n?.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},ID=new ke(`dragHandle`),LD=({pluginKey:e=ID,element:t,editor:n,computePositionConfig:r,getReferencedVirtualElement:i,onNodeChange:a,onElementDragStart:o,onElementDragEnd:s,nestedOptions:c})=>{let l=document.createElement(`div`),u=!1,d=null,f=-1,p,m=null,h=null;function g(){t&&(t.style.visibility=`hidden`,t.style.pointerEvents=`none`)}function _(){if(t){if(!n.isEditable){g();return}t.style.visibility=``,t.style.pointerEvents=`auto`}}function v(e){$r(i?.()||{getBoundingClientRect:()=>e.getBoundingClientRect()},t,r).then(e=>{Object.assign(t.style,{position:e.strategy,left:`${e.x}px`,top:`${e.y}px`})})}function y(e){o?.(e),AD(e,n,c,{node:d,pos:f}),t&&(t.dataset.dragging=`true`),setTimeout(()=>{t&&(t.style.pointerEvents=`none`)},0)}function b(e){s?.(e),g(),t&&(t.style.pointerEvents=`auto`,t.dataset.dragging=`false`)}function x(){if(st()){let e=n.view.dom;requestAnimationFrame(()=>{e.isContentEditable&&(e.contentEditable=`false`,e.contentEditable=`true`)})}}return l.appendChild(t),{unbind(){t.removeEventListener(`dragstart`,y),t.removeEventListener(`dragend`,b),document.removeEventListener(`drop`,x),m&&(cancelAnimationFrame(m),m=null,h=null)},plugin:new Et({key:typeof e==`string`?new ke(e):e,state:{init(){return{locked:!1}},apply(e,r,i,o){let s=e.getMeta(`lockDragHandle`),c=e.getMeta(`hideDragHandle`);if(s!==void 0&&(u=s),c)return g(),u=!1,d=null,f=-1,a?.({editor:n,node:null,pos:-1}),r;if(e.docChanged&&f!==-1&&t)if($E(e)){let e=PD(o,p);e!==f&&(f=e)}else{let t=e.mapping.map(f);t!==f&&(f=t,p=ND(o,f))}return r}},view:e=>{var r;return t.draggable=!0,t.style.pointerEvents=`auto`,t.dataset.dragging=`false`,(r=n.view.dom.parentElement)==null||r.appendChild(l),l.style.pointerEvents=`none`,l.style.position=`absolute`,l.style.top=`0`,l.style.left=`0`,t.addEventListener(`dragstart`,y),t.addEventListener(`dragend`,b),document.addEventListener(`drop`,x),{update(r,i){if(!t)return;if(!n.isEditable){g();return}if(u?t.draggable=!1:t.draggable=!0,e.state.doc.eq(i.doc)||f===-1)return;let o=e.nodeDOM(f);if(o=FD(e,o),o===e.dom||o?.nodeType!==1)return;let s=e.posAtDOM(o,0),c=MD(n.state.doc,s),l=jD(n.state.doc,s);d=c,f=l,p=ND(e.state,f),a?.({editor:n,node:d,pos:f}),v(o)},destroy(){t.removeEventListener(`dragstart`,y),t.removeEventListener(`dragend`,b),document.removeEventListener(`drop`,x),m&&(cancelAnimationFrame(m),m=null,h=null),t&&OD(l)}}},props:{handleDOMEvents:{keydown(e){return!t||u?!1:e.hasFocus()?(g(),d=null,f=-1,a?.({editor:n,node:null,pos:-1}),!1):!1},mouseleave(e,t){return u||t.target&&!l.contains(t.relatedTarget)&&(g(),d=null,f=-1,a?.({editor:n,node:null,pos:-1})),!1},mousemove(e,r){return!t||u||(h={x:r.clientX,y:r.clientY},m)||(m=requestAnimationFrame(()=>{if(m=null,!h)return;let{x:t,y:r}=h;h=null;let i=ED({x:t,y:r,direction:`right`,editor:n,nestedOptions:c});if(!i.resultElement)return;let o=i.resultElement,s=i.resultNode,l=i.pos;if(!c?.enabled){if(o=FD(e,o),o===e.dom||o?.nodeType!==1)return;let t=e.posAtDOM(o,0);s=MD(n.state.doc,t),l=jD(n.state.doc,t)}s!==d&&(d=s,f=l??-1,p=ND(e.state,f),a?.({editor:n,node:d,pos:f}),v(o),_())})),!1}}}})}};function RD(e){return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:gD(`none`)}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:gD(`left`)}:{enabled:!0,rules:e.rules??[],defaultRules:e.defaultRules??!0,allowedContainers:e.allowedContainers,edgeDetection:gD(e.edgeDetection)}}var zD={placement:`left-start`,strategy:`absolute`};Y.create({name:`dragHandle`,addOptions(){return{render(){let e=document.createElement(`div`);return e.classList.add(`drag-handle`),e},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1}},addCommands(){return{lockDragHandle:()=>({editor:e})=>(this.options.locked=!0,e.commands.setMeta(`lockDragHandle`,this.options.locked)),unlockDragHandle:()=>({editor:e})=>(this.options.locked=!1,e.commands.setMeta(`lockDragHandle`,this.options.locked)),toggleDragHandle:()=>({editor:e})=>(this.options.locked=!this.options.locked,e.commands.setMeta(`lockDragHandle`,this.options.locked))}},addProseMirrorPlugins(){let e=this.options.render(),t=RD(this.options.nested);return[LD({computePositionConfig:{...zD,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:e,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:t}).plugin]}});var BD=20,VD=44,HD=28;function UD(e){if(!e)return`Select block`;if(e.type.name===`jsxComponent`){let t=e.attrs.componentName??``;if(t){let e=rb(t),n=e.name===`*`?t:e.displayName??e.name;if(n)return`Select ${n}`}}return`Select ${e.type.name}`}function WD(){let e=document.createElement(`div`);e.className=`ok-block-controls`,e.setAttribute(dC,`true`),e.style.visibility=`hidden`;let t=document.createElement(`button`);t.className=`ok-add-block-btn`,t.setAttribute(`aria-label`,`Add block below`),t.setAttribute(`type`,`button`),t.innerHTML=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus"><path d="M5 12h14"/><path d="M12 5v14"/></svg>`,t.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()});let n=document.createElement(`button`);return n.className=`ok-drag-grip`,n.setAttribute(`type`,`button`),n.setAttribute(`aria-label`,`Select block`),n.setAttribute(`tabindex`,`-1`),n.innerHTML=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-grip-vertical-icon lucide-grip-vertical"><circle cx="9" cy="12" r="1"/><circle cx="9" cy="5" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="19" r="1"/></svg>`,e.appendChild(t),e.appendChild(n),{container:e,addBtn:t,grip:n}}function GD(e,t,n){let{state:r,view:i}=e;if(n.type.name===`jsxComponent`){let i=n.attrs.componentName??``;if(i){let a=rb(i);if(a.emptyChildName){let i=t+1+n.content.size;if(i>r.doc.content.size)return;let o=a.emptyChildName;e.chain().focus().insertContentAt(i,lb(o)).run(),pb(e,i,rb(o));return}}}let a=t+n.nodeSize;if(a>r.doc.content.size)return;let{tr:o}=r,s=r.schema.nodes.paragraph?.create();if(!s)return;o.insert(a,s);let c=y.near(o.doc.resolve(a+1));o.setSelection(c).scrollIntoView(),i.dispatch(o),i.focus(),e.commands.insertContent(`/`)}var KD=Y.create({name:`blockDragHandle`,addProseMirrorPlugins(){let e=this.editor,t=null,n=-1,{container:r,addBtn:i,grip:a}=WD();return i.addEventListener(`click`,()=>{t&&n>=0&&GD(e,n,t)}),a.addEventListener(`click`,()=>{if(n<0)return;let r=t,i=r?.type.name??`unknown`;try{e.chain().focus().setNodeSelection(n).run()||(H(i),console.warn(JSON.stringify({event:`block-grip-click-select-failed`,nodeType:i,componentName:String(r?.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){if(!(e instanceof RangeError))throw e;H(i),console.warn(JSON.stringify({event:`block-grip-click-select-failed`,nodeType:i,componentName:String(r?.attrs.componentName??``).slice(0,200),reason:e.message.slice(0,500)}))}}),[LD({element:r,editor:e,onNodeChange({node:e,pos:r}){t=e,n=r??-1,a.setAttribute(`aria-label`,UD(e))},computePositionConfig:{placement:`left-start`,strategy:`absolute`,middleware:[ei(({rects:e})=>({mainAxis:10,crossAxis:((e.reference.height<=VD?e.reference.height:HD)-BD)/2}))]},nestedOptions:RD(!1)}).plugin]}}),qD=/^#fn(?:ref)?-/,JD=Y.create({name:`footnoteAnchorScroll`,addProseMirrorPlugins(){return[new Et({props:{handleDOMEvents:{click(e,t){let n=t.target;if(!(n instanceof Element))return!1;let r=n.closest(`a[href^="#fn"]`);if(!(r instanceof HTMLAnchorElement))return!1;let i=r.getAttribute(`href`)??``;if(!qD.test(i))return!1;let a=i.slice(1);t.preventDefault();let o=e.dom.ownerDocument.getElementById(a);return o&&o.scrollIntoView({behavior:`smooth`,block:`start`}),!0}}}})]}}),YD=Y.create({name:`formattingShortcuts`,addKeyboardShortcuts(){return{"Mod-Shift-x":()=>this.editor.commands.toggleStrike()}}}),XD=Y.create({name:`headingAnchors`,addProseMirrorPlugins(){return[new Et({props:{decorations(e){let t=[],n=new Map;return e.doc.descendants((e,r)=>{if(e.type.name===`heading`){let i=ce(e.textContent,n);if(!i)return;t.push(rt.node(r,r+e.nodeSize,{id:i}))}}),Ue.create(e.doc,t)}}})]}});function ZD(e){let t=(0,$.c)(8),{node:n,editor:r}=e,i=n.attrs.src,a=n.attrs.alt,o=n.attrs.title,s;if(t[0]!==r||t[1]!==i){let e=r?Yt(r)??void 0:void 0;s=typeof i==`string`?le(Ke(i,e)):void 0,t[0]=r,t[1]=i,t[2]=s}else s=t[2];let c=s,l=typeof a==`string`?a:``,u=typeof o==`string`?o:void 0,d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d={sizes:void 0},t[3]=d):d=t[3];let f;return t[4]!==l||t[5]!==c||t[6]!==u?(f=(0,Z.jsx)(Dn,{as:`span`,"data-image-inline-zoom":!0,"data-clipboard-inline-leaf":`image`,children:(0,Z.jsx)(Y_,{wrapElement:`span`,zoomMargin:20,zoomImg:d,children:(0,Z.jsx)(`img`,{src:c,alt:l,title:u})})}),t[4]=l,t[5]=c,t[6]=u,t[7]=f):f=t[7],f}var QD=g.extend({addNodeView(){return bn(ZD)}});function $D(e,t){let n=e;for(;n&&typeof n.hasAttribute==`function`;){if(n.hasAttribute(`data-wiki-embed`)){let e=n.getAttribute(`data-target`)??``;if(!e)return null;let r=He(e,t);return r?{kind:n.tagName===`IMG`?`image`:`asset`,relPath:r,title:r.split(`/`).pop()??e}:null}if(n.hasAttribute(`data-wiki-link`)){let e=n.getAttribute(`data-target`)??``;return e?{kind:`wiki-link`,relPath:`${e}.md`,title:e}:null}if(n.tagName===`A`&&n.hasAttribute(`href`)){let e=R(n.getAttribute(`href`)??``,t);if(e?.kind===`asset`){let n=He(e.url,t);return n?{kind:`asset`,relPath:n,title:n.split(`/`).pop()??e.url}:null}}if(n.tagName===`IMG`){let e=n.getAttribute(`src`)??``;if(e){let n=R(e,t);if(n?.kind===`asset`){let e=He(n.url,t);return e?{kind:`image`,relPath:e,title:e.split(`/`).pop()??n.url}:null}}}n=n.parentElement}return null}var eO=new ke(`asset-context-menu`);function tO(e){return new Et({key:eO,view(t){let n=e.showAssetMenu??(e=>{let t=globalThis.window?.okDesktop;return t?t.shell.showAssetMenu({relPath:e.relPath,title:e.title,kind:e.kind}):Promise.resolve()}),r=t=>{if(!(t.target instanceof Element))return;let r=$D(t.target,e.sourceDocName);r&&(t.preventDefault(),n(r))};return t.dom.addEventListener(`contextmenu`,r),{destroy(){t.dom.removeEventListener(`contextmenu`,r)}}}})}var nO=e=>{let t=(0,$.c)(18),{kind:n,ariaLabel:r,onDeactivate:i,children:a,triggerReference:o,layout:s,className:c,"data-slot":l}=e,u=s===void 0?`standard`:s,d=(0,Q.useRef)(null),f,p;t[0]===o?(f=t[1],p=t[2]):(f=()=>{let e=d.current;if(e)return ti(o,e,()=>{let t=o.getBoundingClientRect();e.isConnected&&(e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`)})},p=[o],t[0]=o,t[1]=f,t[2]=p),(0,Q.useLayoutEffect)(f,p);let m;t[3]===i?m=t[4]:(m=e=>{e||i()},t[3]=i,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(ju,{asChild:!0,children:(0,Z.jsx)(`span`,{ref:d,"aria-hidden":`true`,style:{position:`fixed`,pointerEvents:`none`,left:`-9999px`,top:`-9999px`,width:0,height:0}})}),t[5]=h):h=t[5];let g=u===`wide`?`w-[min(720px,calc(100%-1rem))]`:`w-80`,_;t[6]!==c||t[7]!==g?(_=Ft(`ok-interaction-prop-panel pointer-events-auto p-3`,g,c),t[6]=c,t[7]=g,t[8]=_):_=t[8];let v;t[9]!==r||t[10]!==a||t[11]!==l||t[12]!==n||t[13]!==_?(v=(0,Z.jsx)(Au,{side:`bottom`,align:`start`,sideOffset:8,collisionPadding:8,"aria-label":r,"data-ok-prop-panel":n,"data-slot":l,onOpenAutoFocus:rO,onCloseAutoFocus:iO,onPointerDownOutside:aO,onFocusOutside:oO,onInteractOutside:sO,className:_,children:a}),t[9]=r,t[10]=a,t[11]=l,t[12]=n,t[13]=_,t[14]=v):v=t[14];let y;return t[15]!==m||t[16]!==v?(y=(0,Z.jsxs)(Ou,{open:!0,onOpenChange:m,children:[h,v]}),t[15]=m,t[16]=v,t[17]=y):y=t[17],y};function rO(e){return e.preventDefault()}function iO(e){return e.preventDefault()}function aO(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function oO(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function sO(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function cO(e){let t=e.trim();return/\.(md|mdx)$/i.test(t)?t:`${t}.md`}function lO(e){let t=e.initialDir.trim().replace(/^\/+|\/+$/g,``),n=cO(e.suggestedName);return t?`${t}/${n}`:n}async function uO(e){let t=await Mu(await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),`Failed to create page`);if(!t.ok)throw Error(t.title);let n=e.replace(/\.(mdx|md)$/i,``);return{docName:Nu(q,t.body,`create-page`,{docName:n}).docName}}async function dO(e){return uO(lO(e))}async function fO(e,t){let{docName:n}=await dO(e);return t.addPage(n),ui([`files`,`backlinks`,`graph`]),t.onCreated?.(n),{docName:n}}var pO=8;function mO(e){return e.trim().replace(/^\/+/,``).replace(/\.mdx?$/i,``).replace(/\/+$/g,``)}function hO(e){return gO(e)?mO(e.slice(1)).toLowerCase():null}function gO(e){return e.startsWith(`/`)&&!e.startsWith(`//`)}function _O(e){return e.split(`/`).at(-1)??e}function vO(e,t){if(!t)return 0;let n=e.toLowerCase(),r=_O(e).toLowerCase();return n===t?0:r===t?1:n.startsWith(t)?2:r.startsWith(t)?3:r.includes(t)?4:n.includes(t)?5:null}function yO(e){switch(e){case`page`:return 0;case`folder`:return 1;case`asset`:return 2}}function bO(e){let t=[],n=new Set;function r(e,r){let i=mO(r);if(!i)return;let a=`${e}:${i.toLowerCase()}`;n.has(a)||(n.add(a),t.push({kind:e,path:i}))}for(let t of e.pages)r(`page`,t);for(let t of e.folderPaths??[])r(`folder`,t);if(e.includeAssets)for(let t of e.assetPaths??[])r(`asset`,t);return t}function xO(e){let t=hO(e.value);if(t===null)return[];let n=[];for(let r of bO(e)){let e=vO(r.path,t);e!==null&&n.push({suggestion:r,score:e})}return n.sort((e,t)=>{if(e.score!==t.score)return e.score-t.score;let n=yO(e.suggestion.kind)-yO(t.suggestion.kind);return n===0?e.suggestion.path.localeCompare(t.suggestion.path):n}),n.slice(0,e.limit??pO).map(e=>e.suggestion)}var SO=`[data-ok-link-path-suggestion-panel]`;function CO(e){return e instanceof Element&&e.closest(SO)!==null}function wO(e){CO(e.target)&&e.preventDefault()}function TO(e){switch(e.kind){case`page`:return(0,Z.jsx)(Sl,{className:`size-3.5`,docExt:`.md`,kind:`file`,path:e.path});case`folder`:return(0,Z.jsx)(Sl,{className:`size-3.5`,kind:`folder`,path:e.path});case`asset`:return(0,Z.jsx)(Sl,{bodyIndexed:!1,className:`size-3.5`,kind:`file`,path:e.path})}}function EO(e,t){if(e){if(typeof e==`function`){e(t);return}e.current=t}}function DO(e){let t=(0,$.c)(54),n,r,i,a,o,c,l,u,d,f,p,m,h,g;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14]):({value:g,pages:f,folderPaths:i,assetPaths:n,includeAssets:m,loading:h,onValueChange:d,onKeyDown:l,onSuggestionSelect:u,onFocus:c,onBlur:o,className:r,ref:p,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g);let _=m===void 0?!1:m,v=h===void 0?!1:h,{_:y}=s(),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=(0,Q.useId)(),k;t[15]===g?k=t[16]:(k=g.trim(),t[15]=g,t[16]=k);let A=k===``,j=xO({value:A?`/`:g,pages:f,folderPaths:i,assetPaths:n,includeAssets:_}),M=j.map(MO).join(`\0`),N;t[17]===g?N=t[18]:(N=gO(g),t[17]=g,t[18]=N);let P=A||N,F=j.length>0,I=b&&!S&&P&&(F||v),L=I||b&&!S&&P&&!v&&!F,R=Math.min(w,Math.max(j.length-1,0)),ee=F?`${O}-option-${R}`:void 0,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>{T(0)},t[19]=z):z=t[19],(0,Q.useEffect)(z,[M]);let te,ne;t[20]!==ee||t[21]!==L?(te=()=>{!L||!ee||document.getElementById(ee)?.scrollIntoView?.({block:`nearest`})},ne=[ee,L],t[20]=ee,t[21]=L,t[22]=te,t[23]=ne):(te=t[22],ne=t[23]),(0,Q.useEffect)(te,ne);let re,B;t[24]===L?(re=t[25],B=t[26]):(re=()=>{if(!L)return;let e=E.current,t=D.current;if(!e||!t)return;let n=e,r=t,i=function(){$r(n,r,{placement:`bottom-start`,strategy:`fixed`,middleware:[ei(4),Zr({padding:8}),ni({padding:8}),Qr({padding:8,apply(e){let{availableHeight:t,availableWidth:n,elements:r}=e;Object.assign(r.floating.style,{width:`${Math.min(480,n)}px`,maxHeight:`${Math.min(208,Math.max(96,t))}px`})}})]}).then(e=>{let{x:t,y:n}=e;r.isConnected&&Object.assign(r.style,{left:`${t}px`,top:`${n}px`})}).catch(e=>{r.isConnected&&console.warn(`[LinkPathSuggestionInput] computePosition failed`,e)})},a=ti(n,r,i);return i(),a},B=[L],t[24]=L,t[25]=re,t[26]=B),(0,Q.useLayoutEffect)(re,B);let V;t[27]===p?V=t[28]:(V=function(e){E.current=e,EO(p,e)},t[27]=p,t[28]=V);let H=V,U=function(e){u?u(e):d(e.path),C(!0),requestAnimationFrame(()=>E.current?.focus())},W=function(e){if(I&&F){if(e.key===`ArrowDown`){e.preventDefault(),T(e=>Math.min(e+1,j.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),T(jO);return}if(e.key===`Enter`){e.preventDefault();let t=j[R];t&&U(t);return}if(e.key===`Escape`){e.preventDefault(),C(!0);return}}if(L&&e.key===`Escape`){e.preventDefault(),C(!0);return}l?.(e)},G;t[29]===y?G=t[30]:(G=function(e){switch(e){case`page`:return y({id:`6WdDG7`});case`folder`:return y({id:`kNqMMd`});case`asset`:return y({id:`bUUVED`})}},t[29]=y,t[30]=G);let ie=G,K=L?(0,Z.jsx)(`div`,{ref:D,id:O,role:`listbox`,"aria-label":y({id:`mBltnd`}),"data-ok-layer-spawned":``,"data-ok-link-path-suggestion-panel":``,className:`fixed z-70 max-h-52 overflow-y-auto overscroll-y-contain rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md subtle-scrollbar pointer-events-auto`,onWheel:AO,onTouchMove:kO,children:F?j.map((e,t)=>{let n=t===R,r=ie(e.kind);return(0,Z.jsxs)(zt,{id:`${O}-option-${t}`,type:`button`,role:`option`,"aria-label":`/${e.path} ${r}`,"aria-selected":n,variant:`ghost`,className:Ft(`h-auto w-full justify-start gap-2 rounded-sm px-2 py-1.5 text-left font-normal`,n&&`bg-accent text-accent-foreground`),onMouseDown:OO,onClick:()=>U(e),children:[TO(e),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`/`,e.path]}),(0,Z.jsx)(`span`,{className:`shrink-0 text-muted-foreground text-xs`,children:r})]},`${e.kind}:${e.path}`)}):(0,Z.jsx)(`div`,{role:`status`,className:`px-2 py-1.5 text-muted-foreground text-sm`,children:y(v?{id:`sxTdZI`}:{id:`_QwkMu`})})}):null,ae;t[31]===d?ae=t[32]:(ae=e=>{C(!1),d(e.target.value)},t[31]=d,t[32]=ae);let oe;t[33]===c?oe=t[34]:(oe=e=>{x(!0),c?.(e)},t[33]=c,t[34]=oe);let q;t[35]===o?q=t[36]:(q=e=>{x(!1),o?.(e)},t[35]=o,t[36]=q);let se=L?O:void 0,ce;t[37]!==ee||t[38]!==r||t[39]!==W||t[40]!==a||t[41]!==H||t[42]!==L||t[43]!==ae||t[44]!==oe||t[45]!==q||t[46]!==se||t[47]!==g?(ce=(0,Z.jsx)(ri,{...a,ref:H,value:g,onChange:ae,onFocus:oe,onBlur:q,onKeyDown:W,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":L,"aria-controls":se,"aria-activedescendant":ee,autoComplete:`off`,className:r}),t[37]=ee,t[38]=r,t[39]=W,t[40]=a,t[41]=H,t[42]=L,t[43]=ae,t[44]=oe,t[45]=q,t[46]=se,t[47]=g,t[48]=ce):ce=t[48];let J;t[49]===K?J=t[50]:(J=K&&(0,Io.createPortal)(K,document.body),t[49]=K,t[50]=J);let le;return t[51]!==ce||t[52]!==J?(le=(0,Z.jsxs)(`div`,{className:`relative`,children:[ce,J]}),t[51]=ce,t[52]=J,t[53]=le):le=t[53],le}function OO(e){return e.preventDefault()}function kO(e){e.stopPropagation()}function AO(e){e.stopPropagation()}function jO(e){return Math.max(e-1,0)}function MO(e){return`${e.kind}:${e.path}`}var NO=1500;async function PO(e){if(typeof navigator>`u`||!navigator.clipboard?.writeText)throw Error(`clipboard unavailable`);await navigator.clipboard.writeText(e)}function FO(e){let t=(0,$.c)(20),{copyContent:n,clipboardWrite:r,initialCopied:i}=e,a=r===void 0?PO:r,o=i===void 0?!1:i,{_:c}=s(),[l,u]=(0,Q.useState)(+!!o),d=l>0,f,p;t[0]===l?(f=t[1],p=t[2]):(f=()=>{if(l===0)return;let e=setTimeout(()=>u(0),NO);return()=>clearTimeout(e)},p=[l],t[0]=l,t[1]=f,t[2]=p),(0,Q.useEffect)(f,p);let m;t[3]!==a||t[4]!==n?(m=()=>{Promise.resolve().then(()=>a(n)).then(()=>u(LO),IO)},t[3]=a,t[4]=n,t[5]=m):m=t[5];let h=m,g;t[6]!==c||t[7]!==d?(g=c(d?{id:`PiH3UR`}:{id:`he3ygx`}),t[6]=c,t[7]=d,t[8]=g):g=t[8];let _=g,v;t[9]===d?v=t[10]:(v=d?(0,Z.jsx)(Bn,{className:`size-3.5`,"aria-hidden":`true`}):(0,Z.jsx)(Jn,{className:`size-3.5`,"aria-hidden":`true`}),t[9]=d,t[10]=v);let y;t[11]!==h||t[12]!==_||t[13]!==v?(y=(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":_,onClick:h,children:v})}),t[11]=h,t[12]=_,t[13]=v,t[14]=y):y=t[14];let b;t[15]===_?b=t[16]:(b=(0,Z.jsx)(xr,{children:_}),t[15]=_,t[16]=b);let x;return t[17]!==y||t[18]!==b?(x=(0,Z.jsxs)(Sr,{children:[y,b]}),t[17]=y,t[18]=b,t[19]=x):x=t[19],x}function IO(){}function LO(e){return e+1}function RO(e,t){return Ag.getState(e)?.byId.get(t)??null}function zO(e){let{editor:t,layer:n,renderPropPanel:r,handlePrimary:i}=e;return{onRegister:e=>{n.register({type:e.markType,nodeId:e.id,controls:{propPanel:e=>r({editor:t,nodeId:e.nodeId,deactivate:e.deactivate})},handlePrimary:i?e=>i({editor:t,nodeId:e.nodeId,newTab:e.newTab}):void 0})},onDeregister:e=>{n.deregister(e)}}}function BO(e){let{editor:t,layer:n,markTypes:r,predicate:i,renderPropPanel:a,handlePrimary:o}=e,s=zO({editor:t,layer:n,renderPropPanel:a,handlePrimary:o});return Ig({markTypes:[...r],predicate:i,onRegister:s.onRegister,onDeregister:s.onDeregister})}function VO(e){let t=Xg(e.editor);return BO({...e,layer:t})}function HO(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(null),a,o;return n[0]!==e||n[1]!==t?(a=()=>{if(!t||!e){i(null);return}let n=!1;return i(null),pn(e).then(e=>{n||i(e)}).catch(()=>{n||i([])}),()=>{n=!0}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function UO(e,t){let n=e.trim();return n?n.startsWith(`#`)?`anchor`:A(n)?`external`:`doc`:t}function WO(e){return e?.kind===`doc`?`doc`:e?.kind===`anchor`?`anchor`:`external`}function GO(e){let t=(0,$.c)(84),{open:n,href:r,text:i,pages:a,folderPaths:c,loading:l,onOpenChange:u,onSave:d}=e,[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(`doc`),b=(0,Q.useId)(),x=(0,Q.useId)(),S=(0,Q.useId)(),C=(0,Q.useId)(),{_:w}=s(),T=(0,Q.useRef)(!1),E=(0,Q.useRef)(``),D,O;t[0]!==r||t[1]!==n||t[2]!==i?(D=()=>{if(!n){T.current=!1;return}if(T.current)return;T.current=!0,E.current=i,_(i);let e=yn(r);if(y(WO(e)),e?.kind===`doc`){p(e.docName),h(e.anchor??``);return}if(e?.kind===`anchor`){p(`#${e.anchor}`),h(``);return}p(e?.kind===`external`?e.url:r),h(``)},O=[n,r,i],t[0]=r,t[1]=n,t[2]=i,t[3]=D,t[4]=O):(D=t[3],O=t[4]),(0,Q.useEffect)(D,O);let k,A,j;t[5]!==v||t[6]!==f||t[7]!==a?(k=gi(f),A=v===`doc`,j=A&&rn(k,a),t[5]=v,t[6]=f,t[7]=a,t[8]=k,t[9]=A,t[10]=j):(k=t[8],A=t[9],j=t[10]);let M=HO(k,j&&n),N=!!M?.length,P;t[11]!==k||t[12]!==A||t[13]!==m||t[14]!==g||t[15]!==f||t[16]!==u||t[17]!==d?(P=function(){let e=f.trim();e&&(d(A?wn(k,m.trim()||null):e,g,g.trim()!==E.current.trim()),u(!1))},t[11]=k,t[12]=A,t[13]=m,t[14]=g,t[15]=f,t[16]=u,t[17]=d,t[18]=P):P=t[18];let F=P,I;t[19]===F?I=t[20]:(I=function(e){e.key===`Enter`&&(e.preventDefault(),F())},t[19]=F,t[20]=I);let L=I,R;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(R=function(e){p(e.path),y(`doc`),h(``)},t[21]=R):R=t[21];let ee=R,z;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(kr,{children:(0,Z.jsx)(o,{id:`B11p-O`})}),t[22]=z):z=t[22];let te;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsxs)(Vr,{children:[z,(0,Z.jsx)(Or,{children:(0,Z.jsx)(o,{id:`RobAKV`})})]}),t[23]=te):te=t[23];let ne;t[24]===A?ne=t[25]:(ne=A?(0,Z.jsx)(o,{id:`6WdDG7`}):(0,Z.jsx)(o,{id:`6vEr3W`}),t[24]=A,t[25]=ne);let re;t[26]!==ne||t[27]!==b?(re=(0,Z.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:b,children:ne}),t[26]=ne,t[27]=b,t[28]=re):re=t[28];let B;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{p(e),y(t=>UO(e,t))},t[29]=B):B=t[29];let V;t[30]===w?V=t[31]:(V=w({id:`Xl-UUg`}),t[30]=w,t[31]=V);let H;t[32]!==f||t[33]!==c||t[34]!==L||t[35]!==l||t[36]!==a||t[37]!==V||t[38]!==b?(H=(0,Z.jsx)(DO,{id:b,value:f,pages:a,folderPaths:c,loading:l,onValueChange:B,onSuggestionSelect:ee,placeholder:V,autoFocus:!0,onKeyDown:L}),t[32]=f,t[33]=c,t[34]=L,t[35]=l,t[36]=a,t[37]=V,t[38]=b,t[39]=H):H=t[39];let U;t[40]!==re||t[41]!==H?(U=(0,Z.jsxs)(`div`,{children:[re,H]}),t[40]=re,t[41]=H,t[42]=U):U=t[42];let W;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(o,{id:`QqBQu1`,components:{0:(0,Z.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[43]=W):W=t[43];let G;t[44]===S?G=t[45]:(G=(0,Z.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:S,children:W}),t[44]=S,t[45]=G);let ie;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>_(e.target.value),t[46]=ie):ie=t[46];let K;t[47]===w?K=t[48]:(K=w({id:`yYR6za`}),t[47]=w,t[48]=K);let ae;t[49]!==g||t[50]!==L||t[51]!==S||t[52]!==K?(ae=(0,Z.jsx)(ri,{id:S,value:g,onChange:ie,placeholder:K,onKeyDown:L}),t[49]=g,t[50]=L,t[51]=S,t[52]=K,t[53]=ae):ae=t[53];let oe;t[54]!==G||t[55]!==ae?(oe=(0,Z.jsxs)(`div`,{children:[G,ae]}),t[54]=G,t[55]=ae,t[56]=oe):oe=t[56];let q;t[57]!==w||t[58]!==x||t[59]!==A||t[60]!==m||t[61]!==L||t[62]!==C||t[63]!==M||t[64]!==N?(q=A?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:x,children:(0,Z.jsx)(o,{id:`Tjc1pH`,components:{0:(0,Z.jsx)(`span`,{className:`font-normal text-muted-foreground`})}})}),(0,Z.jsx)(ri,{id:x,value:m,onChange:e=>h(e.target.value),placeholder:w({id:`W-ntoW`}),onKeyDown:L}),N?(0,Z.jsx)(`div`,{id:C,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:M.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":m===e.slug,className:Ft(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,m===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>h(m===e.slug?``:e.slug),children:[(0,Z.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.text})]},`${e.slug}-${e.level}-${e.text}`))}):null]}):null,t[57]=w,t[58]=x,t[59]=A,t[60]=m,t[61]=L,t[62]=C,t[63]=M,t[64]=N,t[65]=q):q=t[65];let se;t[66]!==U||t[67]!==oe||t[68]!==q?(se=(0,Z.jsxs)(Lr,{className:`space-y-6 pb-1`,children:[U,oe,q]}),t[66]=U,t[67]=oe,t[68]=q,t[69]=se):se=t[69];let ce;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(Br,{asChild:!0,children:(0,Z.jsx)(zt,{variant:`outline`,children:(0,Z.jsx)(o,{id:`dEgA5A`})})}),t[70]=ce):ce=t[70];let J;t[71]===f?J=t[72]:(J=f.trim(),t[71]=f,t[72]=J);let le=!J,ue;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Z.jsx)(o,{id:`tfDRzk`}),t[73]=ue):ue=t[73];let Y;t[74]!==F||t[75]!==le?(Y=(0,Z.jsxs)(Rr,{children:[ce,(0,Z.jsx)(zt,{onClick:F,disabled:le,children:ue})]}),t[74]=F,t[75]=le,t[76]=Y):Y=t[76];let de;t[77]!==se||t[78]!==Y?(de=(0,Z.jsxs)(Pr,{className:`sm:max-w-xl`,"data-ok-layer-spawned":``,onPointerDownOutside:wO,onFocusOutside:wO,onInteractOutside:wO,children:[te,se,Y]}),t[77]=se,t[78]=Y,t[79]=de):de=t[79];let fe;return t[80]!==u||t[81]!==n||t[82]!==de?(fe=(0,Z.jsx)(Hr,{open:n,onOpenChange:u,children:de}),t[80]=u,t[81]=n,t[82]=de,t[83]=fe):fe=t[83],fe}function KO(e){let t=(0,$.c)(99),{editor:n,nodeId:r,sourceDocName:i,onClose:a,onNavigate:c}=e,l=RO(n.state,r),u=l?.attrs?.href??``,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h;t[0]!==r||t[1]!==f?(h=()=>{kg(r)&&f(!0)},t[0]=r,t[1]=f,t[2]=h):h=t[2];let g;t[3]===r?g=t[4]:(g=[r],t[3]=r,t[4]=g),(0,Q.useEffect)(h,g);let{addPage:_,folderPaths:v,pages:y,loading:b}=Wn(),{_:x}=s();if(!l)return null;let S=n.state.doc.textBetween(l.from,l.to),C=u?R(u,i):null,w;t[5]!==n||t[6]!==r?(w=function(e,t,i){let a=RO(n.state,r);if(!a)return;let o=t.trim();if(!i||!o){n.chain().setTextSelection({from:a.from,to:a.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:e}).run();return}let s=n.schema.marks.link;if(!s)return;let c=s.create({href:e}),l=n.schema.text(o,[c]);n.view.dispatch(n.state.tr.replaceWith(a.from,a.to,l))},t[5]=n,t[6]=r,t[7]=w):w=t[7];let T=w,E;t[8]!==n||t[9]!==r||t[10]!==a?(E=function(){let e=RO(n.state,r);e&&(n.chain().focus().setTextSelection({from:e.from,to:e.to}).extendMarkRange(`link`).unsetLink().run(),a())},t[8]=n,t[9]=r,t[10]=a,t[11]=E):E=t[11];let D=E,O;t[12]!==n||t[13]!==r||t[14]!==a||t[15]!==f?(O=function(e){if(e){f(!0);return}let t=RO(n.state,r);if(t?.attrs?.href??``){f(!1);return}t&&n.chain().focus().deleteRange({from:t.from,to:t.to}).run(),a()},t[12]=n,t[13]=r,t[14]=a,t[15]=f,t[16]=O):O=t[16];let k=(0,Z.jsx)(GO,{open:d,href:u,text:S,pages:y,folderPaths:v,loading:b,onOpenChange:u?f:O,onSave:T});if(!u)return(0,Z.jsx)(Z.Fragment,{children:k});let A=C?.kind===`doc`?`${C.docName}${C.anchor?`#${C.anchor}`:``}`:C?.kind===`anchor`?`#${C.anchor}`:C?.kind===`external`?C.url:u,j=function(e){let t=RO(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:wn(e,C?.kind===`doc`?C.anchor??null:null)}).run()},M,N=!1,P=!1,F=null;if(b){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ir,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[17]=e):e=t[17],M={icon:e,text:x({id:`yQE2r9`}),className:`text-muted-foreground/80`}}else if(C?.kind===`asset`){let e;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(eo,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[18]=e):e=t[18],M={icon:e,text:x({id:`yWWThY`}),className:`text-muted-foreground`}}else if(C?.kind===`external`){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Un,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[19]=e):e=t[19],M={icon:e,text:x({id:`zgSFyG`}),className:`text-muted-foreground`}}else if(C?.kind===`anchor`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(eo,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[20]=e):e=t[20],M={icon:e,text:x({id:`dprWmL`}),className:`text-muted-foreground`}}else if(C?.kind===`doc`){let e=In(C.docName,{pages:y,folderPaths:v});if(P=e.kind===`navigate`&&e.displayState===`folder`,N=e.kind===`create`,F=e.kind===`create`?{initialDir:e.initialDir,suggestedName:e.suggestedName}:null,P){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(tr,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[21]=e):e=t[21],M={icon:e,text:x({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(N){let e;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ua,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[22]=e):e=t[22],M={icon:e,text:x({id:`8F1i42`}),className:`text-red-700 dark:text-red-300`}}else{let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(eo,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[23]=e):e=t[23],M={icon:e,text:x({id:`JtD-Br`}),className:`text-muted-foreground`}}}else{let e;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ua,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[24]=e):e=t[24],M={icon:e,text:x({id:`-g6KIS`}),className:`text-muted-foreground/80`}}let I=C?.kind===`external`,L=C?.kind===`doc`?Ln({docName:C.docName,anchor:C.anchor}):C?.kind===`anchor`?Ln({docName:i,anchor:C.anchor}):C?.kind===`external`&&fn(C.url)?C.url:null,ee=!b&&L!==null&&(C?.kind===`anchor`||C?.kind===`external`||C?.kind===`doc`&&!N&&!P),z;t[25]!==n.state||t[26]!==n.view||t[27]!==r?(z=()=>{let e=RO(n.state,r);if(!e)return new DOMRect;try{return _t(n.view,e.from,e.to)}catch{return new DOMRect}},t[25]=n.state,t[26]=n.view,t[27]=r,t[28]=z):z=t[28];let te;t[29]!==n.view.dom||t[30]!==z?(te={getBoundingClientRect:z,contextElement:n.view.dom},t[29]=n.view.dom,t[30]=z,t[31]=te):te=t[31];let ne=te,re;t[32]!==x||t[33]!==_||t[34]!==p||t[35]!==F||t[36]!==a||t[37]!==j?(re=async function(){if(!(!F||p)){m(!0);try{await fO(F,{addPage:_,onCreated(e){j(e),window.location.hash=`#/${e}`,a()}}),m(!1)}catch(e){let t=e;sr.error(t instanceof Error?t.message:x({id:`tfi40B`})),m(!1)}}},t[32]=x,t[33]=_,t[34]=p,t[35]=F,t[36]=a,t[37]=j,t[38]=re):re=t[38];let B=re,V=Ft(`flex shrink-0`,M.className),H;t[39]!==M.icon||t[40]!==V?(H=(0,Z.jsx)(`span`,{className:V,children:M.icon}),t[39]=M.icon,t[40]=V,t[41]=H):H=t[41];let U=H,W;t[42]!==U||t[43]!==N||t[44]!==M.text?(W=N?(0,Z.jsxs)(Sr,{children:[(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`internal-link-prop-panel-icon-trigger`,children:U})}),(0,Z.jsx)(xr,{children:M.text})]}):U,t[42]=U,t[43]=N,t[44]=M.text,t[45]=W):W=t[45];let G=W,ie=`${M.text}: ${A}`,K;t[46]!==A||t[47]!==I||t[48]!==N||t[49]!==L||t[50]!==ee||t[51]!==a||t[52]!==c?(K=(0,Z.jsx)(br,{asChild:!0,children:ee?(0,Z.jsx)(`a`,{href:L??void 0,...I?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>_n(e,c,a),"data-slot":`internal-link-prop-panel-text`,className:`block truncate text-sm font-medium text-foreground underline-offset-2 hover:underline focus-visible:underline`,children:A}):(0,Z.jsx)(`span`,{"data-slot":`internal-link-prop-panel-text`,className:Ft(`block truncate text-sm font-medium`,N?`text-muted-foreground`:`text-foreground`),children:A})}),t[46]=A,t[47]=I,t[48]=N,t[49]=L,t[50]=ee,t[51]=a,t[52]=c,t[53]=K):K=t[53];let ae;t[54]===A?ae=t[55]:(ae=(0,Z.jsx)(xr,{className:`max-w-80 break-all`,children:A}),t[54]=A,t[55]=ae);let oe;t[56]!==K||t[57]!==ae?(oe=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsxs)(Sr,{children:[K,ae]})}),t[56]=K,t[57]=ae,t[58]=oe):oe=t[58];let q;t[59]!==B||t[60]!==p||t[61]!==N?(q=N?(0,Z.jsxs)(zt,{type:`button`,size:`sm`,variant:`link`,disabled:p,onClick:()=>void B(),"data-slot":`internal-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,Z.jsx)(So,{className:`size-3.5`,"aria-hidden":`true`}),p?(0,Z.jsx)(o,{id:`HM56Bx`}):(0,Z.jsx)(o,{id:`XRuL0i`})]}):null,t[59]=B,t[60]=p,t[61]=N,t[62]=q):q=t[62];let se;t[63]===x?se=t[64]:(se=x({id:`ePK91l`}),t[63]=x,t[64]=se);let ce;t[65]===f?ce=t[66]:(ce=()=>f(!0),t[65]=f,t[66]=ce);let J;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)($n,{className:`size-3.5`,"aria-hidden":`true`}),t[67]=J):J=t[67];let le;t[68]!==se||t[69]!==ce?(le=(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":se,onClick:ce,"data-slot":`internal-link-prop-panel-edit`,children:J})}),t[68]=se,t[69]=ce,t[70]=le):le=t[70];let ue;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Z.jsx)(xr,{children:(0,Z.jsx)(o,{id:`ePK91l`})}),t[71]=ue):ue=t[71];let Y;t[72]===le?Y=t[73]:(Y=(0,Z.jsxs)(Sr,{children:[le,ue]}),t[72]=le,t[73]=Y);let de;t[74]===u?de=t[75]:(de=(0,Z.jsx)(FO,{copyContent:u}),t[74]=u,t[75]=de);let fe;t[76]===x?fe=t[77]:(fe=x({id:`t_YqKh`}),t[76]=x,t[77]=fe);let pe;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`}),t[78]=pe):pe=t[78];let me;t[79]!==D||t[80]!==fe?(me=(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":fe,onClick:D,"data-slot":`internal-link-prop-panel-remove`,children:pe})}),t[79]=D,t[80]=fe,t[81]=me):me=t[81];let he;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Z.jsx)(xr,{children:(0,Z.jsx)(o,{id:`t_YqKh`})}),t[82]=he):he=t[82];let ge;t[83]===me?ge=t[84]:(ge=(0,Z.jsxs)(Sr,{children:[me,he]}),t[83]=me,t[84]=ge);let _e;t[85]!==q||t[86]!==Y||t[87]!==de||t[88]!==ge?(_e=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[q,Y,de,ge]}),t[85]=q,t[86]=Y,t[87]=de,t[88]=ge,t[89]=_e):_e=t[89];let ve;t[90]!==G||t[91]!==oe||t[92]!==_e?(ve=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[G,oe,_e]}),t[90]=G,t[91]=oe,t[92]=_e,t[93]=ve):ve=t[93];let ye;return t[94]!==a||t[95]!==ie||t[96]!==ve||t[97]!==ne?(ye=(0,Z.jsx)(nO,{kind:`internal-link`,ariaLabel:ie,onDeactivate:a,triggerReference:ne,className:`w-96`,children:ve}),t[94]=a,t[95]=ie,t[96]=ve,t[97]=ne,t[98]=ye):ye=t[98],(0,Z.jsxs)(Z.Fragment,{children:[k,ye]})}new ke(`markIdentityDecoration`);var qO=`data-mark-id`,JO=new ke(`linkResolutionDecoration`);function YO(e,t,n,r,i){if(t.size===0)return null;let a=[];for(let e of t.values()){if(!n.has(e.markType))continue;let t=r(e,i),o={[qO]:e.id};t!==null&&Object.assign(o,t),a.push(rt.inline(e.from,e.to,o))}return a.length===0?null:Ue.create(e,a)}function XO(e){let t=new Set(e.markTypes),{computeAttrs:n}=e;return new Et({key:JO,state:{init:()=>({version:0}),apply(e,t){let n=e.getMeta(JO);return n&&typeof n==`object`&&n.refresh?{version:t.version+1}:t}},props:{decorations(e){let r=Ag.getState(e);if(!r)return null;let i=li();return YO(e.doc,r.byId,t,n,i)}},view(e){X(`ok/render/decoration-merge`,{markTypes:Array.from(t).join(`,`)},{startTime:performance.now(),duration:0});let n=si(()=>{e.dispatch(e.state.tr.setMeta(JO,{refresh:!0}))});return{destroy(){n()}}}})}var ZO=ue.extend({addOptions(){return{...this.parent?.(),docName:``}},renderHTML({HTMLAttributes:e}){let t=typeof e.href==`string`?e.href:``;return[`span`,et(e,{"data-link":``,role:`link`,tabindex:`0`,"aria-label":t?`Link: ${t}`:`Link`,style:`touch-action: manipulation;`}),0]},addProseMirrorPlugins(){let e=this.options.docName??``,t=({editor:t,nodeId:n,newTab:r})=>{let i=RO(t.state,n),a=i?.attrs?.href;if(typeof a!=`string`||!a)return!1;let o=i?.attrs?.sourceForm,s=R(a,e),c=We(a);if(s?.kind===`asset`||o===`wikiembed`&&c!==null){let t=s?.kind===`asset`?s.url:a,n=s?.kind===`asset`?s.ext:c??``,i=He(t,e);if(!i)return!1;let o=li();return o===null||(o.assetPaths!==void 0||o.filePaths!==void 0)&&!nn(t,e,o.assetPaths,o.filePaths)?!1:(On({url:t,projectRelPath:i,ext:n,title:i.split(`/`).pop()??t,newTab:r}),!0)}if(!s)return!1;switch(s.kind){case`doc`:{let e=li(),t=In(s.docName,{pages:e?.pages??new Set,folderPaths:e?.folderPaths??new Set});return t.kind===`create`||t.kind===`navigate`&&t.displayState===`folder`?!1:(r?Fn({docName:s.docName,anchor:s.anchor}):window.location.assign(Ln({docName:s.docName,anchor:s.anchor})),!0)}case`anchor`:return r?Fn({docName:e,anchor:s.anchor}):window.location.assign(Ln({docName:e,anchor:s.anchor})),!0;case`external`:return fn(s.url)?(un(s.url),!0):!1;default:return W(s)}};return[VO({editor:this.editor,markTypes:[`link`],renderPropPanel:({editor:n,nodeId:r,deactivate:i})=>(0,Q.createElement)(KO,{editor:n,nodeId:r,sourceDocName:e,onClose:i,onNavigate:e=>t({editor:n,nodeId:r,newTab:e})}),handlePrimary:t}),XO({markTypes:[`link`],computeAttrs:Wt(e)}),tO({sourceDocName:e})]}}),QO=(0,Q.createContext)(null),$O={didCatch:!1,error:null},ek=class extends Q.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=$O}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;t!==null&&(this.props.onReset?.({args:e,reason:`imperative-api`}),this.setState($O))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&tk(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState($O))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,Q.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,Q.createElement)(QO.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function tk(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}function nk(e){let t=(0,$.c)(23),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({label:i,Icon:n,onClick:a,selected:s,className:r,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s?`true`:void 0,l;t[7]===a?l=t[8]:(l=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},t[7]=a,t[8]=l);let u;t[9]===r?u=t[10]:(u=Ft(`flex w-full items-center justify-center gap-2 rounded-md border border-dashed border-border bg-transparent px-3 py-2 text-center text-sm text-muted-foreground transition-colors hover:bg-muted/50 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,r),t[9]=r,t[10]=u);let d;t[11]===n?d=t[12]:(d=(0,Z.jsx)(n,{size:16,"aria-hidden":`true`}),t[11]=n,t[12]=d);let f;t[13]===i?f=t[14]:(f=(0,Z.jsx)(`span`,{children:i}),t[13]=i,t[14]=f);let p;return t[15]!==a||t[16]!==o||t[17]!==c||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==f?(p=(0,Z.jsxs)(`div`,{...o,role:`button`,tabIndex:-1,contentEditable:!1,"data-descriptor-placeholder":``,"data-selected":c,onClick:a,onMouseDown:rk,onKeyDown:l,className:u,children:[d,f]}),t[15]=a,t[16]=o,t[17]=c,t[18]=l,t[19]=u,t[20]=d,t[21]=f,t[22]=p):p=t[22],p}function rk(e){e.preventDefault(),e.stopPropagation()}function ik(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(Oc,{"data-slot":`select`,...n}),t[2]=n,t[3]=r),r}function ak(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(Ac,{"data-slot":`select-value`,...n}),t[2]=n,t[3]=r),r}function ok(e){let t=(0,$.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,size:a,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===r?s=t[6]:(s=Ft(`flex w-full items-center justify-between gap-2 rounded-lg border border-input bg-background text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=default]:px-2.5 data-[size=sm]:px-2 data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,r),t[5]=r,t[6]=s);let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(jc,{asChild:!0,children:(0,Z.jsx)(Vn,{className:`size-4 opacity-50`})}),t[7]=c):c=t[7];let l;return t[8]!==n||t[9]!==i||t[10]!==o||t[11]!==s?(l=(0,Z.jsxs)(kc,{"data-slot":`select-trigger`,"data-size":o,className:s,...i,children:[n,c]}),t[8]=n,t[9]=i,t[10]=o,t[11]=s,t[12]=l):l=t[12],l}function sk(e){let t=(0,$.c)(20),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,position:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`popper`:a,s=o===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,c;t[5]!==r||t[6]!==s?(c=Ft(`relative z-50 max-h-(--radix-select-content-available-height) min-w-32 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border bg-popover text-popover-foreground shadow-md outline-hidden duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[align-trigger=true]:animate-none motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0`,s,r),t[5]=r,t[6]=s,t[7]=c):c=t[7];let l;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(lk,{}),t[8]=l):l=t[8];let u=o===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`,d;t[9]===u?d=t[10]:(d=Ft(`p-1`,u),t[9]=u,t[10]=d);let f;t[11]!==n||t[12]!==d?(f=(0,Z.jsx)(Pc,{className:d,children:n}),t[11]=n,t[12]=d,t[13]=f):f=t[13];let p;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(uk,{}),t[14]=p):p=t[14];let m;return t[15]!==o||t[16]!==i||t[17]!==c||t[18]!==f?(m=(0,Z.jsx)(Mc,{children:(0,Z.jsxs)(Nc,{"data-slot":`select-content`,"data-ok-layer-spawned":``,position:o,className:c,...i,children:[l,f,p]})}),t[15]=o,t[16]=i,t[17]=c,t[18]=f,t[19]=m):m=t[19],m}function ck(e){let t=(0,$.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Ft(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,Z.jsx)(Lc,{children:(0,Z.jsx)(Bn,{className:`size-4`})})}),t[6]=o):o=t[6];let s;t[7]===n?s=t[8]:(s=(0,Z.jsx)(Ic,{children:n}),t[7]=n,t[8]=s);let c;return t[9]!==i||t[10]!==a||t[11]!==s?(c=(0,Z.jsxs)(Fc,{"data-slot":`select-item`,className:a,...i,children:[o,s]}),t[9]=i,t[10]=a,t[11]=s,t[12]=c):c=t[12],c}function lk(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`flex cursor-default items-center justify-center py-1`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Ha,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Z.jsx)(Rc,{"data-slot":`select-scroll-up-button`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function uk(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`flex cursor-default items-center justify-center py-1`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Vn,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Z.jsx)(zc,{"data-slot":`select-scroll-down-button`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function dk(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,size:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]===n?o=t[5]:(o=Ft(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,n),t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(Qc,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`}),t[6]=s):s=t[6];let c;return t[7]!==r||t[8]!==a||t[9]!==o?(c=(0,Z.jsx)(Zc,{"data-slot":`switch`,"data-size":a,className:o,...r,children:s}),t[7]=r,t[8]=a,t[9]=o,t[10]=c):c=t[10],c}function fk(e){let t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t.toLowerCase();if(/^#[0-9a-fA-F]{3}$/.test(t)){let[,e,n,r]=t.match(/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/)??[];return`#${e}${e}${n}${n}${r}${r}`.toLowerCase()}return`#000000`}function pk(e){let t=(0,$.c)(36),{id:n,value:r,onChange:i,autoFocus:a}=e,o=(0,Q.useRef)(null),s;t[0]===i?s=t[1]:(s=e=>i(e.target.value),t[0]=i,t[1]=s);let c=a?``:void 0,l=r?`pl-7`:void 0,u;t[2]===l?u=t[3]:(u=Ft(`h-7 text-sm`,l),t[2]=l,t[3]=u);let d;t[4]!==a||t[5]!==n||t[6]!==s||t[7]!==c||t[8]!==u||t[9]!==r?(d=(0,Z.jsx)(ri,{id:n,type:`text`,value:r,placeholder:`#F05032 or rgb(240,80,50)`,onChange:s,autoFocus:a,"data-prop-autofocus":c,className:u,"data-color-picker-input":``}),t[4]=a,t[5]=n,t[6]=s,t[7]=c,t[8]=u,t[9]=r,t[10]=d):d=t[10];let f;t[11]===r?f=t[12]:(f=r&&(0,Z.jsx)(`span`,{style:{backgroundColor:r},className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 rounded-sm border border-border`,"aria-hidden":`true`,"data-color-picker-swatch":``}),t[11]=r,t[12]=f);let p;t[13]!==d||t[14]!==f?(p=(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15];let m;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>o.current?.click(),t[16]=m):m=t[16];let h=r||`transparent`,g;t[17]===h?g=t[18]:(g=(0,Z.jsx)(zt,{type:`button`,variant:`outline`,size:`xs`,"aria-label":`Choose color`,"data-color-picker-trigger":``,className:`h-7 gap-1 px-2`,onClick:m,children:(0,Z.jsx)(`span`,{style:{backgroundColor:h},className:`size-3.5 rounded-sm border border-border`,"aria-hidden":`true`})}),t[17]=h,t[18]=g);let _;t[19]===r?_=t[20]:(_=fk(r),t[19]=r,t[20]=_);let v;t[21]===i?v=t[22]:(v=e=>i(e.target.value),t[21]=i,t[22]=v);let y;t[23]!==_||t[24]!==v?(y=(0,Z.jsx)(`input`,{ref:o,type:`color`,value:_,onChange:v,tabIndex:-1,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 size-7 opacity-0`,"data-color-picker-native":``}),t[23]=_,t[24]=v,t[25]=y):y=t[25];let b;t[26]!==g||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`relative`,children:[g,y]}),t[26]=g,t[27]=y,t[28]=b):b=t[28];let x;t[29]!==i||t[30]!==r?(x=r&&(0,Z.jsx)(zt,{type:`button`,variant:`ghost`,size:`xs`,"aria-label":`Clear color`,"data-color-picker-clear":``,className:`h-7 px-1.5`,onClick:()=>i(``),children:(0,Z.jsx)(Ya,{className:`size-3`,"aria-hidden":`true`})}),t[29]=i,t[30]=r,t[31]=x):x=t[31];let S;return t[32]!==b||t[33]!==x||t[34]!==p?(S=(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[p,b,x]}),t[32]=b,t[33]=x,t[34]=p,t[35]=S):S=t[35],S}function mk(e){let t=(0,$.c)(43),{id:n,value:r,onChange:i,autoFocus:a}=e,[o,s]=(0,Q.useState)(!1),c;t[0]===r?c=t[1]:(c=t_(r),t[0]=r,t[1]=c);let l=c,u;t[2]===r?u=t[3]:(u=r.startsWith(`lucide:`)?r.slice(7):null,t[2]=r,t[3]=u);let d=u,f;t[4]===i?f=t[5]:(f=e=>i(e.target.value),t[4]=i,t[5]=f);let p=a?``:void 0,m=l?`pl-7`:void 0,h;t[6]===m?h=t[7]:(h=Ft(`h-7 text-sm`,m),t[6]=m,t[7]=h);let g;t[8]!==a||t[9]!==n||t[10]!==f||t[11]!==p||t[12]!==h||t[13]!==r?(g=(0,Z.jsx)(ri,{id:n,type:`text`,value:r,placeholder:`lucide:Lightbulb or 📘`,onChange:f,autoFocus:a,"data-prop-autofocus":p,className:h,"data-icon-picker-input":``}),t[8]=a,t[9]=n,t[10]=f,t[11]=p,t[12]=h,t[13]=r,t[14]=g):g=t[14];let _;t[15]===l?_=t[16]:(_=l&&(0,Z.jsx)(l,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),t[15]=l,t[16]=_);let v;t[17]!==g||t[18]!==_?(v=(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(Vn,{className:`size-3`,"aria-hidden":`true`}),t[20]=y):y=t[20];let b;t[21]===o?b=t[22]:(b=(0,Z.jsx)(ku,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,variant:`outline`,size:`xs`,"aria-label":`Choose icon`,"aria-haspopup":`listbox`,"aria-expanded":o,"data-icon-picker-trigger":``,className:`h-7 gap-1 px-2`,children:y})}),t[21]=o,t[22]=b);let x;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(Su,{placeholder:`Search icons...`,className:`h-8 text-sm`}),t[23]=x):x=t[23];let S;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(wu,{children:`No icons match.`}),t[24]=S):S=t[24];let C;t[25]!==i||t[26]!==r.length?(C=r.length>0&&(0,Z.jsx)(Tu,{children:(0,Z.jsxs)(Eu,{value:`__clear__`,onSelect:()=>{i(``),s(!1)},className:`gap-2 text-muted-foreground`,"data-icon-picker-clear":``,children:[(0,Z.jsx)(cr,{className:`size-3.5`,"aria-hidden":`true`}),`Clear icon`]})}),t[25]=i,t[26]=r.length,t[27]=C):C=t[27];let w;t[28]!==i||t[29]!==d?(w=e_.map(e=>{let[t,n]=e,r=t===d;return(0,Z.jsx)(Eu,{value:t,onSelect:()=>{i(`lucide:${t}`),s(!1)},title:t,"aria-label":t,"data-icon-picker-item":t,"data-icon-picker-selected":r?``:void 0,className:Ft(`flex aspect-square items-center justify-center rounded-md p-0`,r?`bg-foreground/10 text-foreground ring-1 ring-foreground/30`:`text-muted-foreground hover:bg-muted`),children:(0,Z.jsx)(n,{className:`size-4`,"aria-hidden":`true`})},t)}),t[28]=i,t[29]=d,t[30]=w):w=t[30];let T;t[31]===w?T=t[32]:(T=(0,Z.jsx)(Tu,{heading:`Lucide`,children:(0,Z.jsx)(cu.Group,{className:`[&_[cmdk-group-items]]:grid [&_[cmdk-group-items]]:grid-cols-6 [&_[cmdk-group-items]]:gap-1 [&_[cmdk-group-items]]:p-1`,children:w})}),t[31]=w,t[32]=T);let E;t[33]!==C||t[34]!==T?(E=(0,Z.jsx)(Au,{align:`end`,className:`z-70 w-72 p-0`,onOpenAutoFocus:hk,children:(0,Z.jsxs)(bu,{label:`Icon picker`,children:[x,(0,Z.jsxs)(Cu,{className:`max-h-64`,children:[S,C,T]})]})}),t[33]=C,t[34]=T,t[35]=E):E=t[35];let D;t[36]!==o||t[37]!==b||t[38]!==E?(D=(0,Z.jsxs)(Ou,{open:o,onOpenChange:s,children:[b,E]}),t[36]=o,t[37]=b,t[38]=E,t[39]=D):D=t[39];let O;return t[40]!==D||t[41]!==v?(O=(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[v,D]}),t[40]=D,t[41]=v,t[42]=O):O=t[42],O}function hk(e){return e.preventDefault()}function gk(e){let[t]=e.split(`/`);switch(t){case`image`:return`image`;case`video`:return`video`;case`audio`:return`audio`;case`application`:return e===`application/pdf`?`pdf`:null;case`text`:return`text`;default:return null}}function _k(e){if(e.length===1&&e[0]===`*/*`)return`all`;let t=new Set;for(let n of e){if(n===`*/*`)return`all`;let e=gk(n);e&&t.add(e)}return t}function vk(e){let t=e.lastIndexOf(`.`);return t<0||t<e.lastIndexOf(`/`)?``:e.slice(t+1).toLowerCase()}function yk(e,t){let n=_k(t),r=[];for(let t of e){if(n===`all`){r.push(t);continue}let e=pe(vk(t));e&&n.has(e)&&r.push(t)}return r}var bk=8,xk=new Set,Sk=null;function Ck(e){return{path:e,basename:e.split(`/`).pop()??e}}function wk(e){let t=e.map(e=>e.path).join(``);return Sk?.fingerprint===t||(Sk={fingerprint:t,byPath:new Map(e.map(e=>[e.path,e])),itemsInOrder:e,corpus:tt(e.map(e=>vt({kind:`page`,path:e.path,title:e.basename})))}),Sk}function Tk(e){let t=e.trim();return t.startsWith(`/`)?t.slice(1):t}function Ek(e,t){let n=Tk(t);return n?Dt(e.corpus,n,{intent:`autocomplete`,limit:bk}).map(t=>e.byPath.get(t.document.path)).filter(e=>!!e):e.itemsInOrder.slice(0,bk)}function Dk(e){let t=(0,$.c)(52),{value:n,onChange:r,accept:i,id:a,placeholder:o,autoFocus:s,ariaInvalid:c,ariaDescribedBy:l,dataPropAutofocus:u,className:d,onSubmit:f}=e,p=Kn()?.assetPaths??xk,m;t[0]!==i||t[1]!==p||t[2]!==n?(m=Ek(wk(yk(p,i).map(Ck)),n),t[0]=i,t[1]=p,t[2]=n,t[3]=m):m=t[3];let h=m,[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(0),b,x;t[4]!==v||t[5]!==h.length?(b=()=>{v>=h.length&&y(0)},x=[v,h.length],t[4]=v,t[5]=h.length,t[6]=b,t[7]=x):(b=t[6],x=t[7]),(0,Q.useEffect)(b,x);let S=(0,Q.useId)(),C=(0,Q.useRef)(null),w=g&&h.length>0,T;t[8]===r?T=t[9]:(T=e=>{r(`/${e.path}`),_(!1),y(0),C.current?.focus()},t[8]=r,t[9]=T);let E=T,D;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>_(e),t[10]=D):D=t[10];let O=w?S:void 0,k=w&&h[v]?`${S}-opt-${v}`:void 0,A;t[11]===r?A=t[12]:(A=e=>{r(e.target.value),_(!0),y(0)},t[11]=r,t[12]=A);let j,M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{_(!0)},j=()=>{_(!0)},t[13]=j,t[14]=M):(j=t[13],M=t[14]);let N;t[15]!==v||t[16]!==f||t[17]!==E||t[18]!==h||t[19]!==w?(N=e=>{if(e.key===`ArrowDown`){if(h.length===0)return;e.preventDefault(),_(!0),y(e=>(e+1)%h.length);return}if(e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),_(!0),y(e=>(e-1+h.length)%h.length);return}if(e.key===`Enter`){if(w){let t=h[v];if(t){e.preventDefault(),E(t);return}}f&&(e.preventDefault(),f());return}if(e.key===`Escape`){if(!w)return;e.preventDefault(),e.stopPropagation(),_(!1);return}e.key===`Tab`&&_(!1)},t[15]=v,t[16]=f,t[17]=E,t[18]=h,t[19]=w,t[20]=N):N=t[20];let P;t[21]!==l||t[22]!==c||t[23]!==s||t[24]!==d||t[25]!==u||t[26]!==a||t[27]!==o||t[28]!==N||t[29]!==O||t[30]!==k||t[31]!==A||t[32]!==n||t[33]!==w?(P=(0,Z.jsx)(ju,{asChild:!0,children:(0,Z.jsx)(ri,{ref:C,id:a,type:`text`,value:n,placeholder:o,autoFocus:s,"data-prop-autofocus":u,"aria-invalid":c,"aria-describedby":l,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":O,"aria-activedescendant":k,className:d,onChange:A,onFocus:M,onClick:j,onKeyDown:N})}),t[21]=l,t[22]=c,t[23]=s,t[24]=d,t[25]=u,t[26]=a,t[27]=o,t[28]=N,t[29]=O,t[30]=k,t[31]=A,t[32]=n,t[33]=w,t[34]=P):P=t[34];let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{let t=e.target;t instanceof Node&&C.current?.contains(t)&&e.preventDefault()},t[35]=F):F=t[35];let I;if(t[36]!==v||t[37]!==S||t[38]!==E||t[39]!==h){let e;t[41]!==v||t[42]!==S||t[43]!==E?(e=(e,t)=>{let n=`${S}-opt-${t}`,r=t===v;return(0,Z.jsxs)(`button`,{id:n,type:`button`,role:`option`,"aria-selected":r,"data-testid":`src-autocomplete-option`,"data-highlighted":r?``:void 0,className:Ft(`flex w-full flex-col items-start gap-0.5 rounded-sm px-2 py-1 text-left text-xs`,`transition-colors`,r?`bg-accent text-accent-foreground`:`hover:bg-accent/50`),onMouseEnter:()=>y(t),onMouseDown:t=>{t.preventDefault(),E(e)},children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:e.basename}),e.basename!==e.path&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/70`,children:e.path})]},e.path)},t[41]=v,t[42]=S,t[43]=E,t[44]=e):e=t[44],I=h.map(e),t[36]=v,t[37]=S,t[38]=E,t[39]=h,t[40]=I}else I=t[40];let L;t[45]!==S||t[46]!==I?(L=(0,Z.jsx)(Au,{align:`start`,sideOffset:4,className:`z-70 w-(--radix-popover-trigger-width) p-1`,onOpenAutoFocus:kk,onCloseAutoFocus:Ok,onInteractOutside:F,children:(0,Z.jsx)(`div`,{id:S,role:`listbox`,"aria-label":`Asset suggestions`,className:`flex flex-col gap-px`,children:I})}),t[45]=S,t[46]=I,t[47]=L):L=t[47];let R;return t[48]!==P||t[49]!==L||t[50]!==w?(R=(0,Z.jsxs)(Ou,{open:w,onOpenChange:D,children:[P,L]}),t[48]=P,t[49]=L,t[50]=w,t[51]=R):R=t[51],R}function Ok(e){e.preventDefault()}function kk(e){e.preventDefault()}function Ak(){if(typeof window>`u`)return null;let e=window.location.hash.match(/^#\/([^?#]+)/);return e?decodeURIComponent(e[1]):null}var jk=`/api/upload`;async function Mk(e,t,n={}){let r=n.fetch??globalThis.fetch,i=n.docName===void 0?Ak():n.docName;if(!i)throw Error(`No document is open`);let a=new FormData;a.append(`file`,e),a.append(`parentDocName`,i);let o;try{o=await r(jk,{method:`POST`,body:a})}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Upload failed: ${t}`)}let s;try{s=await o.json()}catch(e){throw new Ut(`Upload response is not JSON.`,{cause:e,status:o.status})}if(!o.ok){let e=qe.safeParse(s);throw e.success?Error(e.data.title):new Ut(`Upload error response did not match ProblemDetails.`,{cause:e.error,status:o.status})}let c=Qe.safeParse(s);if(!c.success)throw new Ut(`Upload success response did not match UploadAssetSuccess.`,{cause:c.error,status:o.status});let l=c.data.path??c.data.src;return{url:l.startsWith(`/`)?l:`/${l}`}}var Nk=new Intl.PluralRules(`en-US`);function Pk(e,t,n){return n<=0?`${e} (empty)`:`${e} with ${n} ${Nk.select(n)===`one`?`item`:`items`}`}function Fk(e){for(let t of e)if(t.type===`string`&&t.hidden!==!0&&t.advanced!==!0&&t.autoFocus===!0)return t.name;return null}function Ik(e){if(!e)return e;let t=e.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1)}var Lk=new Set([`auto`,`inherit`,`initial`,`unset`]),Rk=new Set([`px`,`%`,`rem`,`em`,`vh`,`vw`,`ch`,`ex`,`fr`]),zk=/^(-?\d+(?:\.\d+)?)([a-z%]*)$/i;function Bk(e){let t=e.trim();if(!t)return{valid:!1,reason:`empty`};if(Lk.has(t.toLowerCase()))return{valid:!0};let n=t.match(zk);if(!n)return{valid:!1,reason:`malformed-syntax`};let r=(n[2]??``).toLowerCase();return r===``||Rk.has(r)?{valid:!0}:{valid:!1,reason:`unknown-unit`}}function Vk(e){if(e.valid)return null;switch(e.reason){case`empty`:return null;case`malformed-syntax`:return`Enter a number (e.g. 100), a number with a CSS unit (e.g. 100px, 50%, 26rem), or one of: auto, inherit, initial, unset.`;case`unknown-unit`:return`Unknown CSS unit. Use px, %, rem, em, vh, vw, ch, ex, or fr.`}}var Hk={video:z,audio:p,image:j},Uk={youtube:[`youtube.com`,`youtu.be`,`youtube-nocookie.com`],vimeo:[`vimeo.com`],loom:[`loom.com`]};function Wk(e){let t=e.toLowerCase();for(let e of Object.keys(Uk)){let n=Uk[e];for(let r of n)if(t===r||t.endsWith(`.${r}`))return e}return null}function Gk(e){let t=e.lastIndexOf(`/`),n=t>=0?e.slice(t+1):e,r=n.lastIndexOf(`.`);return r>0?n.slice(r+1).toLowerCase():``}var Kk=`https://placeholder.invalid`;function qk(e,t){let n=e.trim();if(n.length===0)return{valid:!0};let r,i=!0;try{r=new URL(n)}catch{try{r=new URL(n,Kk),i=!1}catch{return{valid:!1,reason:`invalid-url`}}}if(t===`video`&&Be(n)!==null||t===`video`&&xe(n)||t===`video`&&D(n))return{valid:!0};let a=i?Wk(r.hostname):null;if(a!==null)return{valid:!1,reason:`embed-provider`,provider:a};if(r.protocol===`data:`)return{valid:!1,reason:`data-uri`};let o=Gk(r.pathname),s=Hk[t];return o===``?i?{valid:!0}:{valid:!1,reason:`wrong-extension`,extension:``}:s.has(o)?{valid:!0}:{valid:!1,reason:`wrong-extension`,extension:o}}function Jk(e){if(e.length===0)return;let t=e[0]?.toLowerCase()??``;if(t.startsWith(`video/`))return`video`;if(t.startsWith(`audio/`))return`audio`;if(t.startsWith(`image/`))return`image`}function Yk(e){return`Direct ${e} file URL — ${Array.from(Hk[e]).map(e=>`.${e}`).join(`, `)}`}var Xk={youtube:`YouTube`,vimeo:`Vimeo`,loom:`Loom`};function Zk(e,t){if(e.valid)return``;if(e.reason===`invalid-url`)return`Not a valid URL.`;if(e.reason===`data-uri`)return`Data URIs are not supported for media fields. Use a hosted file URL.`;if(e.reason===`embed-provider`){let n=Xk[e.provider];return t===`video`?`Unrecognized ${n} URL. Paste a valid ${n} share or embed link, or a direct ${t} file URL.`:`${n} URLs are not direct ${t} files. Paste a direct ${t} file URL.`}let n=Array.from(Hk[t]).map(e=>`.${e}`).join(`, `);return e.extension===``?`Missing file extension. Accepts: ${n}.`:`Unsupported extension .${e.extension}. Accepts: ${n}.`}function Qk(e){return`ok.propPanel.advanced.${e}`}function $k(e){try{return typeof localStorage>`u`?!1:localStorage.getItem(Qk(e))===`true`}catch{return!1}}function eA(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(Qk(e),t?`true`:`false`)}catch{}}function tA(e,t){let n=0;for(let r of e){let e=t[r.name],i=`defaultValue`in r?r.defaultValue:void 0;e!==void 0&&e!==i&&(n+=1)}return n}async function nA(e,t,n){try{let{url:r}=await Mk(e,t);n(r)}catch(e){let t=e instanceof Error?e.message:String(e);sr.error(ai._({id:`02P3hL`,values:{message:t}}))}}function rA(e){let t=(0,$.c)(14),{descriptor:n,values:r,onChange:i,onDismiss:a}=e,s;t[0]===r?s=t[1]:(s=e=>!(`hidden`in e&&e.hidden)&&e.hideWhen?.(r)!==!0&&e.type!==`reactnode`,t[0]=r,t[1]=s);let c=n.props.filter(s),l=c.filter(aA),u=c.filter(iA),d=tA(u,r),f;t[2]===n.props?f=t[3]:(f=Fk(n.props),t[2]=n.props,t[3]=f);let p=f,m;t[4]===n.name?m=t[5]:(m=()=>$k(n.name),t[4]=n.name,t[5]=m);let[h,g]=(0,Q.useState)(m);if(c.length===0)return null;let _;t[6]!==p||t[7]!==i||t[8]!==a||t[9]!==r?(_=e=>(0,Z.jsx)(sA,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),onDismiss:a,isAutoFocused:e.name===p},e.name),t[6]=p,t[7]=i,t[8]=a,t[9]=r,t[10]=_):_=t[10];let v=l.map(_),y=u.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,Z.jsxs)(Dr,{open:h,onOpenChange:e=>{g(e),eA(n.name,e)},children:[(0,Z.jsxs)(Er,{"data-prop-panel-advanced-trigger":``,className:`group flex w-full items-center justify-between rounded px-1 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground uppercase font-mono`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(Vn,{className:`size-3 transition-transform group-data-[state=closed]:-rotate-90`}),(0,Z.jsx)(o,{id:`sxkWRg`})]}),d>0&&(0,Z.jsx)(wl,{variant:`secondary`,"data-prop-panel-advanced-count":``,children:d})]}),(0,Z.jsx)(Tr,{className:`flex flex-col gap-4 pt-2`,children:u.map(e=>(0,Z.jsx)(sA,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),onDismiss:a,isAutoFocused:e.name===p},e.name))})]})]}),b;return t[11]!==v||t[12]!==y?(b=(0,Z.jsxs)(`div`,{"data-prop-panel":``,className:`flex flex-col gap-4 py-2 text-sm`,children:[v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13],b}function iA(e){return`advanced`in e&&e.advanced}function aA(e){return!(`advanced`in e&&e.advanced)}function oA(e){throw Error(`PropPanel: unhandled PropDef type ${JSON.stringify(e)}`)}function sA(e){let t=(0,$.c)(165),{propDef:n,value:r,onChange:i,onDismiss:a,isAutoFocused:o}=e,s;t[0]===a?s=t[1]:(s=a?e=>{e.key===`Enter`&&(e.preventDefault(),a())}:void 0,t[0]=a,t[1]=s);let c=s;switch(n.type){case`reactnode`:return null;case`string`:{let e=`prop-${n.name}`,s=n.accept,l=s!==void 0&&s.length>0,u=!n.required&&n.defaultValue===void 0;if(n.language){let a=`${e}-label`,s;t[2]===n.name?s=t[3]:(s=Ik(n.name),t[2]=n.name,t[3]=s);let c;t[4]!==a||t[5]!==e||t[6]!==s?(c=(0,Z.jsx)(`label`,{id:a,htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[4]=a,t[5]=e,t[6]=s,t[7]=c):c=t[7];let l=r??``,d;t[8]!==i||t[9]!==u?(d=e=>{if(e===``&&u){i(void 0);return}i(e)},t[8]=i,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==o||t[12]!==a||t[13]!==n.language||t[14]!==e||t[15]!==l||t[16]!==d?(f=(0,Z.jsx)(Mn,{id:e,ariaLabelledBy:a,value:l,language:n.language,onChange:d,autoFocus:o}),t[11]=o,t[12]=a,t[13]=n.language,t[14]=e,t[15]=l,t[16]=d,t[17]=f):f=t[17];let p;return t[18]!==c||t[19]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,f]}),t[18]=c,t[19]=f,t[20]=p):p=t[20],p}if(n.iconPicker){let a=r??``,s;t[21]===n.name?s=t[22]:(s=Ik(n.name),t[21]=n.name,t[22]=s);let c;t[23]!==e||t[24]!==s?(c=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[23]=e,t[24]=s,t[25]=c):c=t[25];let l;t[26]!==i||t[27]!==u?(l=e=>{if(e===``&&u){i(void 0);return}i(e)},t[26]=i,t[27]=u,t[28]=l):l=t[28];let d;t[29]!==a||t[30]!==o||t[31]!==e||t[32]!==l?(d=(0,Z.jsx)(mk,{id:e,value:a,onChange:l,autoFocus:o}),t[29]=a,t[30]=o,t[31]=e,t[32]=l,t[33]=d):d=t[33];let f;return t[34]!==c||t[35]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,d]}),t[34]=c,t[35]=d,t[36]=f):f=t[36],f}if(n.colorPicker){let a=r??``,s;t[37]===n.name?s=t[38]:(s=Ik(n.name),t[37]=n.name,t[38]=s);let c;t[39]!==e||t[40]!==s?(c=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[39]=e,t[40]=s,t[41]=c):c=t[41];let l;t[42]!==i||t[43]!==u?(l=e=>{if(e===``&&u){i(void 0);return}i(e)},t[42]=i,t[43]=u,t[44]=l):l=t[44];let d;t[45]!==a||t[46]!==o||t[47]!==e||t[48]!==l?(d=(0,Z.jsx)(pk,{id:e,value:a,onChange:l,autoFocus:o}),t[45]=a,t[46]=o,t[47]=e,t[48]=l,t[49]=d):d=t[49];let f;return t[50]!==c||t[51]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,d]}),t[50]=c,t[51]=d,t[52]=f):f=t[52],f}if(n.cssLengthInput){let a=r??``,s;if(t[53]!==a){let e=Bk(a);s=e.valid?null:Vk(e),t[53]=a,t[54]=s}else s=t[54];let l=s,d;t[55]===n.name?d=t[56]:(d=Ik(n.name),t[55]=n.name,t[56]=d);let f;t[57]!==e||t[58]!==d?(f=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:d}),t[57]=e,t[58]=d,t[59]=f):f=t[59];let p;t[60]!==i||t[61]!==u?(p=e=>{let t=e.target.value;if(t===``&&u){i(void 0);return}i(t)},t[60]=i,t[61]=u,t[62]=p):p=t[62];let m=o?``:void 0,h=l===null?void 0:!0,g=l===null?void 0:`${e}-error`,_;t[63]!==a||t[64]!==c||t[65]!==o||t[66]!==e||t[67]!==p||t[68]!==m||t[69]!==h||t[70]!==g?(_=(0,Z.jsx)(ri,{id:e,type:`text`,value:a,placeholder:`100px, 50%, 26rem, auto`,onChange:p,onKeyDown:c,autoFocus:o,"data-prop-autofocus":m,"aria-invalid":h,"aria-describedby":g,className:`h-7 text-sm`,"data-prop-css-length-input":``}),t[63]=a,t[64]=c,t[65]=o,t[66]=e,t[67]=p,t[68]=m,t[69]=h,t[70]=g,t[71]=_):_=t[71];let v;t[72]!==l||t[73]!==e?(v=l!==null&&(0,Z.jsx)(`p`,{id:`${e}-error`,"data-prop-css-length-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:l}),t[72]=l,t[73]=e,t[74]=v):v=t[74];let y;return t[75]!==v||t[76]!==f||t[77]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[f,_,v]}),t[75]=v,t[76]=f,t[77]=_,t[78]=y):y=t[78],y}let d,f,p;if(t[79]!==s||t[80]!==r){let e=s===void 0?void 0:Jk(s);d=r??``;let n=e===void 0?null:qk(d,e);f=n!==null&&!n.valid&&e!==void 0&&d.trim().length>0?Zk(n,e):null,p=e===void 0?void 0:Yk(e),t[79]=s,t[80]=r,t[81]=d,t[82]=f,t[83]=p}else d=t[81],f=t[82],p=t[83];let m=p,h;t[84]===n.name?h=t[85]:(h=Ik(n.name),t[84]=n.name,t[85]=h);let g;t[86]!==e||t[87]!==h?(g=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:h}),t[86]=e,t[87]=h,t[88]=g):g=t[88];let _;t[89]!==s||t[90]!==d||t[91]!==c||t[92]!==o||t[93]!==f||t[94]!==m||t[95]!==i||t[96]!==a||t[97]!==e||t[98]!==u?(_=s===void 0?(0,Z.jsx)(ri,{id:e,type:`text`,value:d,placeholder:m,onChange:e=>{let t=e.target.value;if(t===``&&u){i(void 0);return}i(t)},onKeyDown:c,autoFocus:o,"data-prop-autofocus":o?``:void 0,"aria-invalid":f===null?void 0:!0,"aria-describedby":f===null?void 0:`${e}-error`,className:`h-7 text-sm`}):(0,Z.jsx)(Dk,{id:e,value:d,onChange:e=>{if(e===``&&u){i(void 0);return}i(e)},onSubmit:a,accept:s,placeholder:m,autoFocus:o,dataPropAutofocus:o?``:void 0,ariaInvalid:f===null?void 0:!0,ariaDescribedBy:f===null?void 0:`${e}-error`,className:`h-7 text-sm`}),t[89]=s,t[90]=d,t[91]=c,t[92]=o,t[93]=f,t[94]=m,t[95]=i,t[96]=a,t[97]=e,t[98]=u,t[99]=_):_=t[99];let v;t[100]!==s||t[101]!==i||t[102]!==l?(v=l&&(0,Z.jsx)(lA,{accept:s,onUploaded:e=>i(e)}),t[100]=s,t[101]=i,t[102]=l,t[103]=v):v=t[103];let y;t[104]!==_||t[105]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[_,v]}),t[104]=_,t[105]=v,t[106]=y):y=t[106];let b;t[107]!==f||t[108]!==e?(b=f!==null&&(0,Z.jsx)(`p`,{id:`${e}-error`,"data-prop-media-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:f}),t[107]=f,t[108]=e,t[109]=b):b=t[109];let x;return t[110]!==g||t[111]!==y||t[112]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[g,y,b]}),t[110]=g,t[111]=y,t[112]=b,t[113]=x):x=t[113],x}case`boolean`:{let e=`prop-${n.name}`,a;t[114]===n.name?a=t[115]:(a=Ik(n.name),t[114]=n.name,t[115]=a);let o=a,s;t[116]!==e||t[117]!==o?(s=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[116]=e,t[117]=o,t[118]=s):s=t[118];let c=!!r,l;t[119]===i?l=t[120]:(l=e=>i(e),t[119]=i,t[120]=l);let u;t[121]!==e||t[122]!==c||t[123]!==l?(u=(0,Z.jsx)(dk,{id:e,checked:c,onCheckedChange:l}),t[121]=e,t[122]=c,t[123]=l,t[124]=u):u=t[124];let d;return t[125]!==s||t[126]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s,u]}),t[125]=s,t[126]=u,t[127]=d):d=t[127],d}case`enum`:{let e=`prop-${n.name}`,a=r??n.enumValues[0]??``,o;t[128]===n.name?o=t[129]:(o=Ik(n.name),t[128]=n.name,t[129]=o);let s;t[130]!==e||t[131]!==o?(s=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[130]=e,t[131]=o,t[132]=s):s=t[132];let c;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(ak,{}),t[133]=c):c=t[133];let l;t[134]===e?l=t[135]:(l=(0,Z.jsx)(ok,{id:e,size:`sm`,children:c}),t[134]=e,t[135]=l);let u;t[136]===n.enumValues?u=t[137]:(u=n.enumValues.map(cA),t[136]=n.enumValues,t[137]=u);let d;t[138]===u?d=t[139]:(d=(0,Z.jsx)(sk,{className:`z-70`,children:u}),t[138]=u,t[139]=d);let f;t[140]!==a||t[141]!==i||t[142]!==l||t[143]!==d?(f=(0,Z.jsxs)(ik,{value:a,onValueChange:i,children:[l,d]}),t[140]=a,t[141]=i,t[142]=l,t[143]=d,t[144]=f):f=t[144];let p;return t[145]!==s||t[146]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,f]}),t[145]=s,t[146]=f,t[147]=p):p=t[147],p}case`number`:{let e=`prop-${n.name}`,a;t[148]===n.name?a=t[149]:(a=Ik(n.name),t[148]=n.name,t[149]=a);let o;t[150]!==e||t[151]!==a?(o=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:a}),t[150]=e,t[151]=a,t[152]=o):o=t[152];let s=r==null?``:String(r),l;t[153]===i?l=t[154]:(l=e=>{let t=e.target.value;if(t===``){i(void 0);return}if(t===`-`)return;let n=Number(t);Number.isNaN(n)||i(n)},t[153]=i,t[154]=l);let u;t[155]!==c||t[156]!==e||t[157]!==s||t[158]!==l?(u=(0,Z.jsx)(ri,{id:e,type:`number`,inputMode:`numeric`,value:s,onChange:l,onKeyDown:c,className:`h-7 text-sm`}),t[155]=c,t[156]=e,t[157]=s,t[158]=l,t[159]=u):u=t[159];let d;return t[160]!==o||t[161]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[o,u]}),t[160]=o,t[161]=u,t[162]=d):d=t[162],d}default:{let e;return t[163]===n?e=t[164]:(e=oA(n),t[163]=n,t[164]=e),e}}}function cA(e){return(0,Z.jsx)(ck,{value:e,children:e},e)}function lA(e){let t=(0,$.c)(17),{accept:n,onUploaded:r}=e,[i,a]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c;t[0]===n?c=t[1]:(c=n.join(`,`),t[0]=n,t[1]=c);let l;t[2]!==n||t[3]!==r?(l=async e=>{let t=e.target.files?.[0];if(t){a(!0);try{await nA(t,n,r)}catch{}a(!1),s.current&&(s.current.value=``)}},t[2]=n,t[3]=r,t[4]=l):l=t[4];let u;t[5]!==c||t[6]!==l?(u=(0,Z.jsx)(`input`,{ref:s,type:`file`,accept:c,className:`hidden`,"data-prop-upload-input":``,onChange:l}),t[5]=c,t[6]=l,t[7]=u):u=t[7];let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>s.current?.click(),t[8]=d):d=t[8];let f;t[9]===i?f=t[10]:(f=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ir,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),(0,Z.jsx)(o,{id:`_eguJc`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(No,{className:`size-3.5`,"aria-hidden":`true`}),(0,Z.jsx)(o,{id:`eJitUk`})]}),t[9]=i,t[10]=f);let p;t[11]!==f||t[12]!==i?(p=(0,Z.jsx)(zt,{type:`button`,variant:`outline`,size:`sm`,disabled:i,"data-prop-upload-trigger":``,className:`h-7 w-full justify-center gap-1.5 px-2 text-xs`,onClick:d,children:f}),t[11]=f,t[12]=i,t[13]=p):p=t[13];let m;return t[14]!==u||t[15]!==p?(m=(0,Z.jsxs)(Z.Fragment,{children:[u,p]}),t[14]=u,t[15]=p,t[16]=m):m=t[16],m}var uA=new Set([`img`,`CommonMarkImage`,`video`,`audio`,`Pdf`,`File`]);function dA(e,t,n){if(!uA.has(e)||!n)return t;let r=t.src;if(typeof r!=`string`)return t;let i=Ke(r,n);return i===r?t:{...t,src:i}}var fA=`selectionStatePlugin/origin`,pA=`selectionStatePlugin/refresh`,mA=new ke(`selectionState`),hA=new Set,gA={selectedBlockId:null,ancestorChain:[],selectionOrigin:`programmatic`,isDragging:!1,rangeEncompassedBlockIds:hA};function _A(e){return mA.getState(e.state)??gA}function vA(e,t){let n=[],{$from:r}=t;for(let t=1;t<=r.depth;t++){let i=r.node(t);if(i.type.name!==`jsxComponent`)continue;let a=r.before(t);n.push(yA(e,i,a))}if(t instanceof bt){let r=t.node;r.type.name===`jsxComponent`&&n.push(yA(e,r,t.from))}return n}function yA(e,t,n){let r=t.attrs.componentName??`unknown`;return{bridgeId:bA(e,n),componentName:r,pos:n}}function bA(e,t){return jb.getState(e)?.posToId.get(t)??`pos-${t}`}function xA(e,t){if(t instanceof bt)return hA;let{from:n,to:r}=t;if(n>=r)return hA;let i=jb.getState(e)?.posToId;if(!i)return hA;let a=null;for(let[t,o]of i){if(t<n)continue;let i=e.doc.nodeAt(t);i&&(t+i.nodeSize>r||(a||=new Set,a.add(o)))}return a??hA}function SA(e,t,n={}){let r=vA(e,e.selection),i=r[r.length-1],a=xA(e,e.selection),o={selectedBlockId:i?.bridgeId??null,ancestorChain:r,selectionOrigin:n.origin??t.selectionOrigin,isDragging:n.isDragging??t.isDragging,rangeEncompassedBlockIds:a};return CA(t,o)?t:o}function CA(e,t){if(e===t)return!0;if(e.selectedBlockId!==t.selectedBlockId||e.selectionOrigin!==t.selectionOrigin||e.isDragging!==t.isDragging||e.ancestorChain.length!==t.ancestorChain.length)return!1;for(let n=0;n<e.ancestorChain.length;n++){let r=e.ancestorChain[n],i=t.ancestorChain[n];if(r.bridgeId!==i.bridgeId||r.componentName!==i.componentName||r.pos!==i.pos)return!1}if(e.rangeEncompassedBlockIds.size!==t.rangeEncompassedBlockIds.size)return!1;for(let n of e.rangeEncompassedBlockIds)if(!t.rangeEncompassedBlockIds.has(n))return!1;return!0}var wA=new WeakMap;function TA(e,t,n,r){let i=r?.isDragging??t.isDragging,a=!!e.getMeta(pA),o=e.selectionSet&&!a,s=e.getMeta(fA),c=o?r?.pendingOrigin??null:null,l=s??c??t.selectionOrigin;return o&&r&&(r.pendingOrigin=null),SA(n,t,{origin:l,isDragging:i})}var EA=Y.create({name:`selectionStatePlugin`,addProseMirrorPlugins(){let e=this.editor,t=new Et({key:mA,state:{init(e,t){return SA(t,gA)},apply(e,n,r,i){return TA(e,n,i,wA.get(t))}},props:{handleDOMEvents:{mousedown:()=>{let e=wA.get(t);return e&&(e.pendingOrigin=`pointer`),!1},pointerdown:()=>{let e=wA.get(t);return e&&(e.pendingOrigin=`pointer`),!1}},handleKeyDown:(e,n)=>{if(DA(n.key)){let e=wA.get(t);e&&(e.pendingOrigin=`keyboard`)}return!1}},view(n){wA.set(t,{pendingOrigin:null,isDragging:!1});let r=n.dom.parentElement??n.dom,i=()=>{let n=wA.get(t);n&&(n.isDragging=!0,OA(e))},a=()=>{let n=wA.get(t);n&&(n.isDragging=!1,OA(e))};return r.addEventListener(`dragstart`,i,!0),r.addEventListener(`dragend`,a,!0),r.addEventListener(`drop`,a,!0),{destroy:()=>{r.removeEventListener(`dragstart`,i,!0),r.removeEventListener(`dragend`,a,!0),r.removeEventListener(`drop`,a,!0),wA.delete(t)}}}});return[t]}});function DA(e){return e===`ArrowUp`||e===`ArrowDown`||e===`ArrowLeft`||e===`ArrowRight`||e===`Tab`||e===`Escape`||e===`Enter`||e===`Home`||e===`End`||e===`PageUp`||e===`PageDown`}function OA(e){queueMicrotask(()=>{if(!e.isDestroyed)try{let t=e.state.tr.setMeta(pA,!0);e.view.dispatch(t)}catch{}})}function kA(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=()=>e?_A(e):null,t[0]=e,t[1]=n);let[r,i]=(0,Q.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(!e){i(null);return}i(_A(e));let t=()=>{i(_A(e))};return e.on(`transaction`,t),e.on(`selectionUpdate`,t),()=>{e.off(`transaction`,t),e.off(`selectionUpdate`,t)}},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,Q.useEffect)(a,o),r}function AA(e,t){if(e.hasChildren)return!1;let n=Fk(e.props);return n===null?!1:t[n]===``}function jA(e){let t=e.placeholder?.label,n=`Add ${(e.displayName??e.name).toLowerCase()}`;return{label:t??n,Icon:Qg(e.placeholder?.icon??e.icon)}}var MA=new Set([`img`,`CommonMarkImage`,`Embed`,`video`]);function NA(e){if(!e.attrs.sourceDirty&&e.attrs.sourceRaw)return e.attrs.sourceRaw;let t=qt(),n=e.type.schema.node(`doc`,null,[e]);return t.serialize(n.toJSON()).trim()}var PA=new Set(yt.map(e=>`${e}:`)),FA=6e4,IA=10,LA=new Map;function RA(e,t){let n=t.toLowerCase();T(n);let r=Date.now(),i=LA.get(n);if(!i||r-i.windowStart>=FA)LA.set(n,{windowStart:r,count:1});else if(i.count+=1,i.count>IA)return;typeof console<`u`&&typeof console.warn==`function`&&console.warn(JSON.stringify({event:`jsx-prop-dropped`,reason:e,prop:t}))}var zA=new Set([`href`,`src`,`action`,`formaction`,`poster`,`cite`,`data`,`manifest`,`background`,`ping`,`xlinkhref`,`xlinkactuate`,`xlinkrole`,`xlinkarcrole`,`xlinkshow`,`url`,`link`]),BA=new Set([`dangerouslysetinnerhtml`,`ref`,`key`,`defaultvalue`,`defaultchecked`,`__proto__`,`constructor`,`prototype`]),VA=1e4;function HA(e){let t=e.toLowerCase();return!!(BA.has(t)||t.length>=3&&t.startsWith(`on`))}function UA(e){return zA.has(e.toLowerCase())}function WA(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`//`)||F(t))return e;let n=t.indexOf(`:`),r=t.slice(0,n+1).toLowerCase();return PA.has(r)?e:`#`}function GA(e){if(e.length>VA)return``;let t=e.toLowerCase();return/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/.test(t)||/\bexpression\s*\(/.test(t)?``:e}function KA(e){if(e==null)return e;if(Array.isArray(e)){let t=!1,n=Array(e.length);for(let r=0;r<e.length;r++){let i=KA(e[r]);n[r]=i,i!==e[r]&&(t=!0)}return t?n:e}if(typeof e!=`object`)return e;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=e,r=!1,i={};for(let[e,t]of Object.entries(n)){if(HA(e)){RA(`dangerous-prop-name-nested`,e),r=!0;continue}if(UA(e)&&typeof t==`string`){let n=WA(t);n!==t&&(r=!0),i[e]=n}else{let n=KA(t);n!==t&&(r=!0),i[e]=n}}return r?i:e}function qA(e){let t=!1,n={};for(let[r,i]of Object.entries(e)){if(HA(r)){RA(`dangerous-prop-name`,r),t=!0;continue}if(UA(r)){let e=WA(i);e!==i&&(t=!0),n[r]=e;continue}if(r===`style`){if(typeof i==`string`){let e=GA(i);e!==i&&(t=!0),n[r]=e}else t=!0;continue}let e=KA(i);e!==i&&(t=!0),n[r]=e}return t?n:e}function JA(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`jsx-component-error-fallback`,children:n}),t[0]=n,t[1]=r),r}function YA(e){let t=(0,$.c)(13),{children:n,resetKey:r,onError:i,descriptorName:a,rawComponentName:o}=e,s;t[0]===r?s=t[1]:(s=[r],t[0]=r,t[1]=s);let c;t[2]!==a||t[3]!==i||t[4]!==o?(c=(e,t)=>{let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:a,rawComponentName:String(o??``).slice(0,200),error:String(n),stack:t.componentStack})),M(a),i(n)},t[2]=a,t[3]=i,t[4]=o,t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=e=>(0,Z.jsx)(JA,{...e,children:n}),t[6]=n,t[7]=l);let u;return t[8]!==n||t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,Z.jsx)(ek,{resetKeys:s,onError:c,fallbackRender:l,children:n}),t[8]=n,t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u}function XA(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(XA).join(`,`)}]`;let t=Object.entries(e);return t.sort(([e],[t])=>e<t?-1:+(e>t)),`{${t.map(([e,t])=>`${JSON.stringify(e)}:${XA(t)}`).join(`,`)}}`}function ZA(e,t){let n=e.props??{},r={};for(let[e,i]of Object.entries(n))t.has(e)||(r[e]=i);return qA(r)}function QA(e){return e.kind===`element`?e:null}var $A=3;function ej(e){let t=(0,$.c)(162),{node:n,editor:r,extension:i,getPos:a,selected:c}=e,{_:l}=s(),u=rb(n.attrs.componentName),[d,f]=(0,Q.useState)(null),[p,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(!1),_=typeof a==`function`?a():void 0,v=!1,b=0,x=1;try{if(_!==void 0){let e=r.state.doc.resolve(_);e.depth>0&&e.parent.type.name===`jsxComponent`&&(v=!0,b=e.index(e.depth),x=e.parent.childCount)}}catch(e){let t=e;if(!(t instanceof RangeError))throw t}let S=v&&b>0,C=v&&b<x-1,w=kA(r),T=typeof _==`number`?bA(r.state,_):null,E=T!==null&&(w?.rangeEncompassedBlockIds.has(T)??!1),D;t[0]===w?.ancestorChain?D=t[1]:(D=w?.ancestorChain.at(-1)?.bridgeId??null,t[0]=w?.ancestorChain,t[1]=D);let O=T!==null&&D===T,k=c&&!E&&O,A=T!==null&&!O&&(w?.ancestorChain.some(e=>e.bridgeId===T)??!1),j=k&&w?w.selectionOrigin:void 0,M=k&&(w?.isDragging??!1),N=u.props.some(oj),P=n.attrs.props??{},F=N&&u.props.some(e=>e.type!==`string`||!e.required||`hidden`in e&&e.hidden?!1:!Object.hasOwn(P,e.name)),I=AA(u,P),L=I?jA(u):null,R=!u.hasChildren||!!u.isSelfClosing,ee=MA.has(u.name),z=u.name===`MermaidFence`?{propName:`chart`,language:`mermaid`}:u.name===`Math`||u.name===`DollarMath`||u.name===`MathFence`?{propName:`formula`,language:`latex`}:null,[ne,V]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{c&&!g.current&&N&&fb(_)&&h(!0),g.current=c},[c,N,_]);let H=ZA(n.attrs,u.reactNodePropNames),W=u.surface===`compat`?u.translateProps(H):H,G=i.options.docName,ie=typeof G==`string`&&G?G:Yt(r),K=dA(u.name,W,ie),oe=`${u.name}::${XA(H)}`,q;t[2]!==a||t[3]!==n.content.size?(q=()=>(typeof a==`function`?a()??0:0)+1+n.content.size,t[2]=a,t[3]=n.content.size,t[4]=q):q=t[4];let se=q,ce=u.name===`*`||d!==null,J=(0,Q.useRef)(!1),le=(0,Q.useRef)(0),[ue,Y]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!ce||J.current||ue)return;let e=typeof a==`function`?a():void 0;if(typeof e!=`number`)return;let t=NA(n),i=u.name===`*`?`Unregistered component: ${n.attrs.componentName}`:`Render error in <${u.displayName??u.name}>: ${d?.message??`unknown`}`,o=n.type.schema.nodes.rawMdxFallback.create({reason:i},n.type.schema.text(t)),s=!1,c,l=()=>{if(!s)try{r.view.dispatch(r.state.tr.replaceWith(e,e+n.nodeSize,o)),J.current=!0,Je(u.name===`*`?`wildcard`:u.name)}catch(e){let t=e,r=u.name===`*`?`wildcard`:u.name;if(console.warn(JSON.stringify({event:`jsx-component-auto-convert-failed`,component:r,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t instanceof Error?t.message.slice(0,500):String(t).slice(0,500),retry:le.current})),m(r),le.current+=1,le.current<$A){let e=50*(2**le.current-1);c=setTimeout(()=>{s||l()},e)}else s||Y(!0)}},f=requestAnimationFrame(l);return()=>{s=!0,cancelAnimationFrame(f),c!==void 0&&clearTimeout(c)}},[ce,n,r,a,u,d,ue]),ue){let e=n.attrs.componentName,i=u.displayName??u.name,o=u.name===`*`?l({id:`Kh1n4a`,values:{componentName:e}}):l({id:`g58Kwy`,values:{descriptorLabel:i}}),s=()=>{try{let e=NA(n);typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e)}catch(e){let t=e;te(u.name),console.warn(JSON.stringify({event:`jsx-component-stuck-copy-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t instanceof Error?t.message.slice(0,500):String(t).slice(0,500)}))}},c=()=>{let e=typeof a==`function`?a():void 0;if(typeof e==`number`)try{r.chain().focus().setNodeSelection(e).deleteSelection().run()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;ae(u.name),console.warn(JSON.stringify({event:`jsx-component-stuck-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={[dC]:`true`},t[5]=d):d=t[5];let f;t[6]===o?f=t[7]:(f=(0,Z.jsx)(`span`,{className:`flex-1`,children:o}),t[6]=o,t[7]=f);let p;t[8]===l?p=t[9]:(p=l({id:`E2Mv-X`}),t[8]=l,t[9]=p);let m;t[10]!==s||t[11]!==p?(m=(0,Z.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:s,children:p}),t[10]=s,t[11]=p,t[12]=m):m=t[12];let h;t[13]===l?h=t[14]:(h=l({id:`cnGeoo`}),t[13]=l,t[14]=h);let g;t[15]!==c||t[16]!==h?(g=(0,Z.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:c,children:h}),t[15]=c,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==m||t[19]!==g||t[20]!==f?(_=(0,Z.jsxs)(`div`,{className:`text-xs font-mono text-muted-foreground px-2 py-2 border border-destructive/40 rounded bg-destructive/5 flex items-center gap-2`,contentEditable:!1,...d,children:[f,m,g]}),t[18]=m,t[19]=g,t[20]=f,t[21]=_):_=t[21];let v;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Nn,{className:`component-children`}),t[22]=v):v=t[22];let y;return t[23]===_?y=t[24]:(y=(0,Z.jsxs)(Dn,{className:`jsx-component-wrapper my-2`,children:[_,v]}),t[23]=_,t[24]=y),y}if(ce){let e=n.attrs.componentName,r=u.displayName??u.name,i=u.name===`*`?l({id:`oJl7eO`,values:{componentName:e}}):l({id:`bcDHUM`,values:{descriptorLabel:r}}),a;t[25]===i?a=t[26]:(a=(0,Z.jsx)(`div`,{className:`text-xs font-mono text-muted-foreground px-2 py-1`,contentEditable:!1,children:i}),t[25]=i,t[26]=a);let o;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Nn,{className:`component-children`}),t[27]=o):o=t[27];let s;return t[28]===a?s=t[29]:(s=(0,Z.jsxs)(Dn,{className:`jsx-component-wrapper my-2`,children:[a,o]}),t[28]=a,t[29]=s),s}let de=u.Component,fe=u.displayName??u.name,pe=u.displayName??u.name,me=u.displayName??u.name,he=e=>{if(I||!R)return;let t=e.target;if(!e.currentTarget.contains(t)||t.closest(`.jsx-component-chrome`)||t.closest(`.jsx-add-child-pill, .jsx-empty-child-placeholder`)||t.closest(`a[href]`)||typeof _!=`number`)return;let n=r.state.doc.nodeAt(_);if(!n)return;let i=_+n.nodeSize,a=r.state.selection.from;a<_||a>=i||r.chain().focus().setNodeSelection(_).run()},ge;t[30]!==r||t[31]!==a||t[32]!==h?(ge=()=>{let e=typeof a==`function`?a():void 0;typeof e==`number`&&(r.chain().focus().setNodeSelection(e).run(),h(!0))},t[30]=r,t[31]=a,t[32]=h,t[33]=ge):ge=t[33];let _e=ge,ve=u.displayName??u.name,ye=!!u.emptyChildName,be=ye?Pk(ve,u.emptyChildName,n.childCount):void 0,xe=e=>{let t=e.target;if(e.key===`Backspace`||e.key===`Delete`){if(!k||!e.currentTarget.contains(t)||t.matches(`input, textarea`))return;let i=typeof a==`function`?a():void 0;if(typeof i!=`number`)return;e.preventDefault();try{r.chain().focus().setNodeSelection(i).deleteSelection().run()||(re(u.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){let t=e;if(!(t instanceof RangeError))throw t;re(u.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}return}e.key!==`Enter`&&e.key!==` `||c&&N&&(t.closest(`.jsx-component-chrome`)||t.closest(`input, textarea, select, button`)||(e.preventDefault(),h(!0)))},Se=e=>{h(e),!e&&requestAnimationFrame(()=>{let e=typeof a==`function`?a():void 0;if(typeof e==`number`)try{let t=r.state.doc.nodeAt(e);if(!t)return;let n=e+t.nodeSize,i=r.state.selection.from;if(i<e||i>=n)return;if(R){let e=r.state.doc.resolve(Math.min(n,r.state.doc.content.size)),t=y.near(e,1);r.view.dispatch(r.state.tr.setSelection(t).scrollIntoView())}else r.chain().setNodeSelection(e).run()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;U(u.name),console.warn(JSON.stringify({event:`jsx-component-popover-close-restore-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}})},Ce=Ou,we=Dn,Te;t[34]===u.name?Te=t[35]:(Te=u.name.toLowerCase(),t[34]=u.name,t[35]=Te);let Ee;bb0:{let e=P.align;if(e===`left`||e===`right`||e===`center`){Ee=e;break bb0}if(ee){Ee=`center`;break bb0}Ee=void 0}let De=k?`true`:void 0,Oe=A?`true`:void 0,ke=E?`true`:void 0,Ae=M?`true`:void 0,je=F?`true`:void 0,Me=ye?`group`:void 0,Ne=k?0:-1,Pe;t[36]===v?Pe=t[37]:(Pe=v?{draggable:`false`,onDragStart:aj}:{"data-drag-handle":``,draggable:`true`},t[36]=v,t[37]=Pe);let Fe=u.name,Ie=ij,Le;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(Le={[dC]:`true`},t[38]=Le):Le=t[38];let Re=u.name===`Embed`&&typeof H.src==`string`&&/^https?:\/\//i.test(H.src)&&(0,Z.jsx)(`a`,{href:H.src,target:`_blank`,rel:`noopener noreferrer`,className:`jsx-chrome-btn`,"aria-label":l({id:`iOHg1t`}),onMouseDown:rj,children:(0,Z.jsx)(Xa,{size:12,"aria-hidden":`true`})}),ze=u.name===`Mirror`&&typeof H.src==`string`&&H.src.length>0&&(()=>{let e=H.src;return(0,Z.jsx)(`a`,{href:xi(e,typeof H.anchor==`string`&&H.anchor.length>0?H.anchor:null),className:`jsx-chrome-btn`,"aria-label":l({id:`3a_Bd7`,values:{mirrorSrc:e}}),title:l({id:`0kTAXe`,values:{mirrorSrc:e}}),onMouseDown:nj,children:(0,Z.jsx)(Xa,{size:12,"aria-hidden":`true`})})})(),Be;t[39]!==l||t[40]!==S||t[41]!==u.name||t[42]!==r||t[43]!==n.attrs.componentName||t[44]!==n.nodeSize||t[45]!==_?(Be=S&&(0,Z.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`QyioBP`}),onClick:()=>{try{if(typeof _!=`number`)return;let e=r.state.doc.resolve(_),t=e.index(e.depth);if(t===0)return;let i=_-e.node(e.depth).child(t-1).nodeSize,a=_+n.nodeSize,o=r.state.tr,s=r.state.doc.slice(_,_+n.nodeSize),c=r.state.doc.slice(i,_);o.replaceWith(i,a,s.content.append(c.content)),r.view.dispatch(o.scrollIntoView())}catch(e){let t=e;if(!(t instanceof RangeError))throw t;B(`up`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`up`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,Z.jsx)(vn,{size:12,"aria-hidden":`true`})}),t[39]=l,t[40]=S,t[41]=u.name,t[42]=r,t[43]=n.attrs.componentName,t[44]=n.nodeSize,t[45]=_,t[46]=Be):Be=t[46];let Ve;t[47]!==l||t[48]!==C||t[49]!==u.name||t[50]!==r||t[51]!==n.attrs.componentName||t[52]!==n.nodeSize||t[53]!==_?(Ve=C&&(0,Z.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`3Ib6FN`}),onClick:()=>{try{if(typeof _!=`number`)return;let e=r.state.doc.resolve(_),t=e.index(e.depth),i=e.node(e.depth);if(t>=i.childCount-1)return;let a=i.child(t+1),o=_,s=_+n.nodeSize+a.nodeSize,c=r.state.tr,l=r.state.doc.slice(_,_+n.nodeSize),u=r.state.doc.slice(_+n.nodeSize,s);c.replaceWith(o,s,u.content.append(l.content)),r.view.dispatch(c.scrollIntoView())}catch(e){let t=e;if(!(t instanceof RangeError))throw t;B(`down`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`down`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,Z.jsx)(Rn,{size:12,"aria-hidden":`true`})}),t[47]=l,t[48]=C,t[49]=u.name,t[50]=r,t[51]=n.attrs.componentName,t[52]=n.nodeSize,t[53]=_,t[54]=Ve):Ve=t[54];let He;t[55]!==l||t[56]!==u.displayName||t[57]!==u.name||t[58]!==z||t[59]!==_||t[60]!==V?(He=z&&typeof _==`number`?(0,Z.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`ky9Tuc`,values:{0:u.displayName??u.name}}),"data-testid":`jsx-component-edit-btn`,onClick:()=>V(!0),children:(0,Z.jsx)($n,{size:12,"aria-hidden":`true`})}):null,t[55]=l,t[56]=u.displayName,t[57]=u.name,t[58]=z,t[59]=_,t[60]=V,t[61]=He):He=t[61];let Ue;t[62]!==l||t[63]!==fe?(Ue=l({id:`MCjC9A`,values:{deleteDescriptorLabel:fe}}),t[62]=l,t[63]=fe,t[64]=Ue):Ue=t[64];let We;t[65]!==u.name||t[66]!==r||t[67]!==n.attrs.componentName||t[68]!==_?(We=()=>{if(typeof _==`number`)try{r.chain().focus().setNodeSelection(_).deleteSelection().run()||(re(u.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){let t=e;if(!(t instanceof RangeError))throw t;re(u.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},t[65]=u.name,t[66]=r,t[67]=n.attrs.componentName,t[68]=_,t[69]=We):We=t[69];let Ge;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,Z.jsx)(ar,{size:12,"aria-hidden":`true`}),t[70]=Ge):Ge=t[70];let Ke;t[71]!==Ue||t[72]!==We?(Ke=(0,Z.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":Ue,onClick:We,children:Ge}),t[71]=Ue,t[72]=We,t[73]=Ke):Ke=t[73];let qe;t[74]!==l||t[75]!==N||t[76]!==pe?(qe=N&&(0,Z.jsx)(ku,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"data-jsx-gear":``,"aria-label":l({id:`XPJ0sN`,values:{settingsDescriptorLabel:pe}}),children:(0,Z.jsx)(To,{size:12,"aria-hidden":`true`})})}),t[74]=l,t[75]=N,t[76]=pe,t[77]=qe):qe=t[77];let Ye;t[78]!==Ie||t[79]!==Le||t[80]!==Re||t[81]!==ze||t[82]!==Be||t[83]!==Ve||t[84]!==He||t[85]!==Ke||t[86]!==qe?(Ye=(0,Z.jsxs)(`div`,{className:`jsx-component-chrome`,contentEditable:!1,onMouseDown:Ie,...Le,children:[Re,ze,Be,Ve,He,Ke,qe]}),t[78]=Ie,t[79]=Le,t[80]=Re,t[81]=ze,t[82]=Be,t[83]=Ve,t[84]=He,t[85]=Ke,t[86]=qe,t[87]=Ye):Ye=t[87];let Xe;t[88]!==de||t[89]!==u.emptyChildName||t[90]!==u.hasChildren||t[91]!==u.isSelfClosing||t[92]!==u.name||t[93]!==r||t[94]!==a||t[95]!==se||t[96]!==k||t[97]!==n.attrs.componentName||t[98]!==n.childCount||t[99]!==_e||t[100]!==K||t[101]!==oe||t[102]!==L||t[103]!==f||t[104]!==I?(Xe=I&&L?(0,Z.jsx)(ju,{asChild:!0,children:(0,Z.jsx)(nk,{label:L.label,Icon:L.Icon,onClick:_e,selected:k})}):(0,Z.jsx)(YA,{resetKey:oe,onError:f,descriptorName:u.name===`*`?`wildcard`:u.name,rawComponentName:n.attrs.componentName??``,children:(0,Z.jsx)(tn,{value:typeof a==`function`?{editor:r,getPos:()=>{let e=a();return typeof e==`number`?e:void 0},addChild:u.emptyChildName?()=>{let e=u.emptyChildName,t=lb(e),n=se();r.chain().focus().insertContentAt(n,t).run(),pb(r,n,rb(e))}:null}:null,children:(0,Z.jsx)(de,{...K,children:(0,Z.jsx)(Nn,{className:`component-children ${!u.hasChildren&&n.childCount===0?`min-h-0 m-0 p-0`:``}`,...!u.hasChildren||u.isSelfClosing?{contentEditable:!1}:{}})})})}),t[88]=de,t[89]=u.emptyChildName,t[90]=u.hasChildren,t[91]=u.isSelfClosing,t[92]=u.name,t[93]=r,t[94]=a,t[95]=se,t[96]=k,t[97]=n.attrs.componentName,t[98]=n.childCount,t[99]=_e,t[100]=K,t[101]=oe,t[102]=L,t[103]=f,t[104]=I,t[105]=Xe):Xe=t[105];let Ze;t[106]!==u.emptyChildName||t[107]!==u.name||t[108]!==r||t[109]!==se||t[110]!==n.childCount?(Ze=u.emptyChildName&&!(u.name===`Tabs`&&n.childCount>0)&&(()=>{let e=u.emptyChildName;return(0,Z.jsx)(`button`,{type:`button`,contentEditable:!1,className:n.childCount===0?`jsx-empty-child-placeholder`:`jsx-add-child-pill`,onMouseDown:tj,onClick:()=>{let e=u.emptyChildName,t=lb(e),n=se();r.chain().focus().insertContentAt(n,t).run(),pb(r,n,rb(e))},"data-clipboard-omit":`true`,children:(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`7Fkcej`,values:{addChildName:e}})})})})(),t[106]=u.emptyChildName,t[107]=u.name,t[108]=r,t[109]=se,t[110]=n.childCount,t[111]=Ze):Ze=t[111];let Qe;t[112]!==we||t[113]!==u.name||t[114]!==be||t[115]!==he||t[116]!==xe||t[117]!==j||t[118]!==Te||t[119]!==Ee||t[120]!==De||t[121]!==Oe||t[122]!==ke||t[123]!==Ae||t[124]!==je||t[125]!==Me||t[126]!==Ne||t[127]!==Pe||t[128]!==Ye||t[129]!==Xe||t[130]!==Ze?(Qe=(0,Z.jsxs)(we,{className:`jsx-component-wrapper my-2`,"data-jsx-component":``,"data-component-type":Te,"data-align":Ee,"data-selected":De,"data-has-child-selected":Oe,"data-range-selected":ke,"data-selection-origin":j,"data-dragging":Ae,"data-needs-config":je,role:Me,"aria-label":be,tabIndex:Ne,...Pe,"data-component-name":Fe,onClick:he,onKeyDown:xe,children:[Ye,Xe,Ze]}),t[112]=we,t[113]=u.name,t[114]=be,t[115]=he,t[116]=xe,t[117]=j,t[118]=Te,t[119]=Ee,t[120]=De,t[121]=Oe,t[122]=ke,t[123]=Ae,t[124]=je,t[125]=Me,t[126]=Ne,t[127]=Pe,t[128]=Ye,t[129]=Xe,t[130]=Ze,t[131]=Qe):Qe=t[131];let $e;t[132]!==l||t[133]!==P||t[134]!==u.Component||t[135]!==u.displayName||t[136]!==u.name||t[137]!==ne||t[138]!==z||t[139]!==r||t[140]!==a||t[141]!==_||t[142]!==K||t[143]!==V?($e=z&&typeof _==`number`?(0,Z.jsx)(nE,{open:ne,onOpenChange:V,initialValue:typeof P[z.propName]==`string`?P[z.propName]:``,language:z.language,title:l({id:`ky9Tuc`,values:{0:u.displayName??u.name}}),renderPreview:e=>{let t=u.Component;return(0,Z.jsx)(`div`,{className:`flex h-full w-full items-center justify-center p-4`,children:(0,Z.jsx)(t,{...K,[z.propName]:e,...u.name===`MermaidFence`&&{className:`border-0 bg-transparent rounded-none`}})})},onSave:e=>{let t=typeof a==`function`?a():void 0;if(typeof t!=`number`)return;let n=r.state.doc.nodeAt(t);if(!n)return;let i=QA(n.attrs);if(i)try{let n={...i.props,[z.propName]:e},a={...i,props:n,sourceDirty:!0};r.view.dispatch(r.state.tr.setNodeMarkup(t,null,a)),$t()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;console.warn(`[JsxComponentView] edit-save failed — position race`,t)}}}):null,t[132]=l,t[133]=P,t[134]=u.Component,t[135]=u.displayName,t[136]=u.name,t[137]=ne,t[138]=z,t[139]=r,t[140]=a,t[141]=_,t[142]=K,t[143]=V,t[144]=$e):$e=t[144];let et;t[145]!==u||t[146]!==r||t[147]!==a||t[148]!==N||t[149]!==R||t[150]!==H||t[151]!==me||t[152]!==h||t[153]!==I?(et=N&&(0,Z.jsxs)(Au,{side:I?`bottom`:`right`,align:I?`center`:`start`,sideOffset:I?-4:8,className:`w-64 p-3 z-60 overflow-y-auto subtle-scrollbar max-h-(--radix-popper-available-height) overscroll-contain`,onCloseAutoFocus:R?e=>{e.preventDefault(),r.view.focus()}:void 0,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,Z.jsx)(o,{id:`Mnavhe`,values:{propPanelDescriptorLabel:me}})}),(0,Z.jsx)(rA,{descriptor:u,values:H,onDismiss:()=>h(!1),onChange:(e,t)=>{let n=typeof a==`function`?a():void 0;if(typeof n!=`number`)return;let i=r.state.doc.nodeAt(n);if(!i)return;let o=QA(i.attrs);if(!o)return;let s={...o.props},c=Array.isArray(i.attrs.attributes)?i.attrs.attributes:[],l=c;t===void 0?(delete s[e],l=c.filter(t=>!(typeof t==`object`&&t&&t.type===`mdxJsxAttribute`&&t.name===e))):s[e]=t,r.view.dispatch(r.state.tr.setNodeMarkup(n,null,{...o,attributes:l,props:s,sourceDirty:!0})),$t()}}),(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-border pt-2`,children:(0,Z.jsx)(zt,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>h(!1),className:`h-7 px-3 text-xs`,children:(0,Z.jsx)(o,{id:`DPfwMq`})})})]}),t[145]=u,t[146]=r,t[147]=a,t[148]=N,t[149]=R,t[150]=H,t[151]=me,t[152]=h,t[153]=I,t[154]=et):et=t[154];let tt;return t[155]!==Ce||t[156]!==Se||t[157]!==p||t[158]!==Qe||t[159]!==$e||t[160]!==et?(tt=(0,Z.jsxs)(Ce,{open:p,onOpenChange:Se,children:[Qe,$e,et]}),t[155]=Ce,t[156]=Se,t[157]=p,t[158]=Qe,t[159]=$e,t[160]=et,t[161]=tt):tt=t[161],tt}function tj(e){return e.stopPropagation()}function nj(e){return e.stopPropagation()}function rj(e){return e.stopPropagation()}function ij(e){return e.stopPropagation()}function aj(e){return e.preventDefault()}function oj(e){return!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`}var sj=de.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return bn(ej)}}),cj={name:`InlineMath`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,category:`content`,description:`Inline math`,props:[{name:`formula`,type:`string`,required:!0,autoFocus:!0,description:`LaTeX inline math source`}]},lj=(0,Q.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-BunQWEOH.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,$.c)(4),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!1,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;return n[2]===i?a=n[3]:(a=(0,Z.jsx)(`span`,{className:`math math-inline`,dangerouslySetInnerHTML:{__html:i}}),n[2]=i,n[3]=a),a}return{default:t}});function uj(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`math math-inline math-placeholder math-placeholder-empty inline-flex items-center gap-1 rounded-sm border border-dashed border-muted-foreground/40 bg-muted/30 px-1.5 py-0.5 text-xs italic text-muted-foreground hover:bg-muted/60 cursor-pointer`,"data-component-type":`math-inline`,children:`f(x)`}),e[0]=t):t=e[0],t}function dj(e){let t=(0,$.c)(2),n;return t[0]===e.formula?n=t[1]:(n=(0,Z.jsx)(`span`,{className:`math math-inline math-placeholder`,"data-component-type":`math-inline`,children:e.formula}),t[0]=e.formula,t[1]=n),n}function fj(e){let t=(0,$.c)(38),{node:n,selected:r,getPos:i,editor:a}=e,s=typeof n.attrs.formula==`string`?n.attrs.formula:``,c=typeof n.attrs.id==`string`?n.attrs.id:void 0,[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(!1),f;t[0]!==a.state||t[1]!==i||t[2]!==r?(f=()=>{let e=r&&a.state.selection instanceof bt;e&&!d.current?(fb(typeof i==`function`?i()??0:0),u(!0)):!e&&d.current&&u(!1),d.current=e},t[0]=a.state,t[1]=i,t[2]=r,t[3]=f):f=t[3];let p;t[4]!==a||t[5]!==i||t[6]!==r?(p=[r,i,a],t[4]=a,t[5]=i,t[6]=r,t[7]=p):p=t[7],(0,Q.useEffect)(f,p);let m=r?`math-inline-selected`:void 0,h;t[8]===c?h=t[9]:(h=c?{id:c}:{},t[8]=c,t[9]=h);let g;t[10]===s?g=t[11]:(g=s?(0,Z.jsx)(ek,{resetKeys:[s],onError:mj,fallbackRender:()=>(0,Z.jsx)(`span`,{className:`math math-inline math-error`,children:s}),children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(dj,{formula:s}),children:(0,Z.jsx)(lj,{formula:s})})}):(0,Z.jsx)(uj,{}),t[10]=s,t[11]=g);let _;t[12]!==s||t[13]!==h||t[14]!==g?(_=(0,Z.jsx)(ku,{asChild:!0,children:(0,Z.jsx)(`span`,{className:`math-inline-trigger`,"data-component-type":`math-inline`,"data-formula":s,...h,children:g})}),t[12]=s,t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===a.view?v=t[17]:(v=e=>{e.preventDefault(),a.view.focus()},t[16]=a.view,t[17]=v);let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground px-3 pt-2`,children:(0,Z.jsx)(o,{id:`EOjU5V`})}),t[18]=y):y=t[18];let b;t[19]===s?b=t[20]:(b={formula:s},t[19]=s,t[20]=b);let x;t[21]!==a.state||t[22]!==a.view||t[23]!==i?(x=(e,t)=>{let n=typeof i==`function`?i():void 0;if(typeof n!=`number`)return;let r=a.state.doc.nodeAt(n);if(!r||r.type.name!==`mathInline`)return;let o=a.state.tr.setNodeMarkup(n,null,{...r.attrs,[e]:t??``});o.setSelection(bt.create(o.doc,n)),a.view.dispatch(o)},t[21]=a.state,t[22]=a.view,t[23]=i,t[24]=x):x=t[24];let S;t[25]!==x||t[26]!==b?(S=(0,Z.jsx)(rA,{descriptor:cj,values:b,onChange:x}),t[25]=x,t[26]=b,t[27]=S):S=t[27];let C;t[28]!==S||t[29]!==v?(C=(0,Z.jsxs)(Au,{className:`z-[60] w-72 p-0`,side:`bottom`,align:`start`,onOpenAutoFocus:pj,onCloseAutoFocus:v,children:[y,S]}),t[28]=S,t[29]=v,t[30]=C):C=t[30];let w;t[31]!==l||t[32]!==C||t[33]!==_?(w=(0,Z.jsxs)(Ou,{open:l,onOpenChange:u,children:[_,C]}),t[31]=l,t[32]=C,t[33]=_,t[34]=w):w=t[34];let T;return t[35]!==w||t[36]!==m?(T=(0,Z.jsx)(Dn,{as:`span`,className:m,children:w}),t[35]=w,t[36]=m,t[37]=T):T=t[37],T}function pj(e){e.preventDefault()}function mj(e,t){let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:`mathInline`,rawComponentName:`mathInline`,error:String(n),stack:t.componentStack})),M(`mathInline`)}var hj=N.extend({addNodeView(){return bn(fj)}});function gj(e,t){if(!e.selection.empty)return null;let n=t===`up`||t===`left`?-1:1,r=e.selection.$head,i=n>0?r.after():r.before();if(typeof i!=`number`)return null;let a=wt.near(e.doc.resolve(i),n);return a.$head?.parent.type.name===`rawMdxFallback`?a:null}function _j(e,t){let{state:n,view:r}=e;if(!r.endOfTextblock(t))return!1;let i=gj(n,t);return i?(r.dispatch(n.tr.setSelection(i)),!0):!1}var vj=Ne.extend({addKeyboardShortcuts(){return{ArrowLeft:({editor:e})=>_j(e,`left`),ArrowRight:({editor:e})=>_j(e,`right`),ArrowUp:({editor:e})=>_j(e,`up`),ArrowDown:({editor:e})=>_j(e,`down`)}},addNodeView(){return bn(An,{stopEvent:()=>!0,ignoreMutation:()=>!0})}});function yj(e){let t=(0,$.c)(51),{items:n,selectedIndex:r,categoryLabels:i,onSelect:a,onHoverIndex:c}=e,l=(0,Q.useRef)(null),u=(0,Q.useId)(),{_:d}=s(),f=r>=0&&r<n.length?`${u}-option-${r}`:void 0,p=xj,m,h;if(t[0]===r?(m=t[1],h=t[2]):(m=()=>{let e=l.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(r);t&&t.scrollIntoView({block:`nearest`})},h=[r],t[0]=r,t[1]=m,t[2]=h),(0,Q.useEffect)(m,h),n.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`div`,{ref:l,role:`status`,"aria-live":`polite`,className:`w-56 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:p,children:(0,Z.jsx)(o,{id:`Ev2r9A`})}),t[4]=n):n=t[4],n}let g,_,v,y,b,x,S,C,w,T,E,D,O;if(t[5]!==d||t[6]!==f||t[7]!==i||t[8]!==n||t[9]!==u||t[10]!==c||t[11]!==a||t[12]!==r){let e=[],o=0,s=new Map;for(let t of n){s.set(t,o++);let n=e.find(e=>e.key===t.category);n?n.items.push(t):e.push({key:t.category,items:[t]})}_=r>=0&&r<n.length?n[r]:null;let m;t[26]===n?m=t[27]:(m=n.some(bj),t[26]=n,t[27]=m),g=m,x=`flex items-start gap-2`,S=l,C=`listbox`,t[28]===d?w=t[29]:(w=d({id:`RlCInP`}),t[28]=d,t[29]=w),T=f,E=-1,D=p,O=`w-56 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(v={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[30]=v):v=t[30];let h=_?`${_.label}${_.preview?`. ${_.preview.description}`:``}`:``;t[31]===h?y=t[32]:(y=(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:h}),t[31]=h,t[32]=y),b=e.map(e=>(0,Z.jsxs)(`div`,{role:`group`,"aria-labelledby":`${u}-group-${e.key}`,children:[(0,Z.jsx)(`div`,{id:`${u}-group-${e.key}`,className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground`,children:i[e.key]??e.key}),e.items.map(e=>{let t=s.get(e)??0,n=t===r,i=e.icon;return(0,Z.jsxs)(`button`,{id:`${u}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseEnter:()=>c?.(t),onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,Z.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`flex flex-col min-w-0`,children:(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})})]},e.name)})]},e.key)),t[5]=d,t[6]=f,t[7]=i,t[8]=n,t[9]=u,t[10]=c,t[11]=a,t[12]=r,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=O}else g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21],T=t[22],E=t[23],D=t[24],O=t[25];let k;t[33]!==v||t[34]!==y||t[35]!==b||t[36]!==S||t[37]!==C||t[38]!==w||t[39]!==T||t[40]!==E||t[41]!==D||t[42]!==O?(k=(0,Z.jsxs)(`div`,{ref:S,role:C,"aria-label":w,"aria-activedescendant":T,tabIndex:E,onMouseDown:D,className:O,style:v,children:[y,b]}),t[33]=v,t[34]=y,t[35]=b,t[36]=S,t[37]=C,t[38]=w,t[39]=T,t[40]=E,t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]!==g||t[45]!==_?(A=g?(0,Z.jsx)(`aside`,{"aria-hidden":`true`,onMouseDown:p,className:`w-64 rounded-lg border bg-popover p-2 shadow-md ${_?.preview?``:`invisible`}`,children:_?.preview?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mb-2 flex aspect-5/3 items-center justify-center overflow-hidden rounded-md bg-muted/40 p-3 *:max-h-full *:max-w-full [&_img]:size-full [&_img]:rounded-md [&_img]:object-contain`,children:_.preview.render()}),(0,Z.jsx)(`p`,{className:`line-clamp-3 px-1 pb-1 text-xs text-muted-foreground`,children:_.preview.description})]}):null}):null,t[44]=g,t[45]=_,t[46]=A):A=t[46];let j;return t[47]!==x||t[48]!==k||t[49]!==A?(j=(0,Z.jsxs)(`div`,{className:x,children:[k,A]}),t[47]=x,t[48]=k,t[49]=A,t[50]=j):j=t[50],j}function bj(e){return e.preview}function xj(e){return e.preventDefault()}var Sj=new ke(`slashCommand`),Cj=Y.create({name:`slashCommand`,addOptions(){return{itemsSources:[Tb],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[Vt({editor:this.editor,pluginKey:Sj,char:`/`,startOfLine:!1,allow:({editor:e})=>!ln(e),items:({query:t})=>{let n=e.options.itemsSources.flatMap(e=>{try{return e()}catch(e){return console.error(`[slash-command] item source threw an error`,e),[]}}),r=Object.keys(e.options.categoryLabels),i=e=>{let t=r.indexOf(e);return t===-1?1/0:t};return Eb(n.map((e,t)=>({item:e,i:t})).sort((e,t)=>{let n=i(e.item.category)-i(t.item.category);return n===0?e.i-t.i:n}).map(e=>e.item),t)},command:({editor:e,range:t,props:n})=>{try{e.chain().focus().deleteRange(t).run()}catch(e){console.error(`[slash-command] deleteRange failed for "${n.name}"`,e);return}try{n.command(e)}catch(e){console.error(`[slash-command] command "${n.name}" threw an error`,e)}},render:()=>{let t=null,n=null,r=0,i={popup:null,stopAutoUpdate:null},a=null,o=e=>{e!==r&&(r=e,s())},s=()=>{!t||!n||t.updateProps({items:n.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:n.command,onHoverIndex:o})};return{onStart(s){n=s,r=0;let c=cn(()=>n,`slash-command`);i.popup=c.popup,a=c.doPosition,t=new dn(yj,{props:{items:s.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:s.command,onHoverIndex:o},editor:s.editor}),c.popup.appendChild(t.element),i.stopAutoUpdate=c.startAutoUpdate(),c.reveal()},onUpdate(e){n=e,r=Math.min(r,Math.max(0,e.items.length-1)),s(),a?.()},onKeyDown({event:e}){if(!n||n.items.length===0)return!1;let t=n.items;if(e.key===`ArrowDown`)return r=(r+1)%t.length,s(),!0;if(e.key===`ArrowUp`)return r=(r-1+t.length)%t.length,s(),!0;if(e.key===`Enter`||e.key===`Tab`){let e=t[r];return e&&n.command(e),!0}return e.key,!1},onExit(){sn(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}}),wj=new ke(`sourceDirty`),Tj=Y.create({name:`sourceDirtyObserver`,addProseMirrorPlugins(){return[new Et({key:wj,appendTransaction(e,t,n){if(!e.some(e=>!e.getMeta(jd))||!e.some(e=>e.docChanged))return null;let r=new St;for(let t of e)r.appendMapping(t.mapping);let i=r.invert(),a=[];if(n.doc.descendants((e,n)=>{if(e.type.name!==`jsxComponent`||e.attrs.sourceDirty)return;let r=i.map(n),o=t.doc.nodeAt(r),s=!o||o.type.name!==`jsxComponent`,c=typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0;if(s&&c)return;if(!o){(e.content.size>0||Object.keys(e.attrs.props??{}).length>0)&&a.push({pos:n});return}if(o.type.name!==`jsxComponent`){a.push({pos:n});return}let l=!Ej(o.attrs.props,e.attrs.props),u=!o.content.eq(e.content);(l||u)&&a.push({pos:n})}),a.length===0)return null;let o=n.tr;for(let{pos:e}of a)o.setNodeAttribute(e,`sourceDirty`,!0);return o}})]}});function Ej(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!=`object`)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ej(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Ej(e[r],t[r]))return!1;return!0}var Dj=Y.create({name:`tabFocusTrap`,priority:1,addKeyboardShortcuts(){return{Tab:()=>!0,"Shift-Tab":()=>!0}}});function Oj(e,t){let n=e.doc.nodeAt(t);if(!n||n.type.name!==`table`)return null;let r=oe.get(n);return{map:r,tableStart:t+1,table:n,left:0,top:0,right:r.width,bottom:r.height}}function kj(e,t){let n=Oj(e,t);return n?kt(e.tr,n,n.map.width):null}function Aj(e,t){let n=Oj(e,t);return n?v(e.tr,n,n.map.height):null}function jj(e,t){if(!e.dom.contains(t))return null;let n;try{n=e.posAtDOM(t,0)}catch{return null}return n<0?null:fe(e.state.doc.resolve(n))?.pos??null}var Mj=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="M12 5v14"/></svg>`;function Nj(e,t){let n=document.createElement(`button`);return n.type=`button`,n.className=`ok-table-insert-bar ok-table-insert-${e}`,n.setAttribute(`aria-label`,t),n.tabIndex=-1,n.setAttribute(dC,`true`),n.innerHTML=Mj,n.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()}),n}var Pj=class{overlays=new Map;mount;lastEditable;constructor(e,t){this.view=e,this.editor=t,this.mount=e.dom.parentElement??e.dom,this.lastEditable=t.isEditable,this.reconcile()}update(e,t){let n=this.editor.isEditable!==this.lastEditable;this.lastEditable=this.editor.isEditable,!(!n&&t.doc.eq(this.view.state.doc))&&this.reconcile()}destroy(){for(let e of this.overlays.keys())this.removeOverlay(e)}reconcile(){if(!this.editor.isEditable){this.destroy();return}let e=new Set(this.view.dom.querySelectorAll(`.tableWrapper`));for(let t of this.overlays.keys())e.has(t)||this.removeOverlay(t);for(let t of e)this.overlays.has(t)||this.addOverlay(t)}addOverlay(e){let t=document.createElement(`div`);t.className=`ok-table-insert-controls`,t.setAttribute(dC,`true`);let n=Nj(`column`,`Add column`),r=Nj(`row`,`Add row`);n.addEventListener(`click`,()=>this.insert(e,kj)),r.addEventListener(`click`,()=>this.insert(e,Aj)),t.append(n,r),this.mount.appendChild(t);let i=ti(e,t,()=>{let{width:t,height:i}=e.getBoundingClientRect();$r(e,n,{strategy:`absolute`,placement:`right-start`}).then(({x:e,y:t})=>{n.style.left=`${e}px`,n.style.top=`${t}px`,n.style.height=`${i}px`}).catch(()=>{}),$r(e,r,{strategy:`absolute`,placement:`bottom-start`}).then(({x:e,y:n})=>{r.style.left=`${e}px`,r.style.top=`${n}px`,r.style.width=`${t}px`}).catch(()=>{})}),a=e=>{let t=e.target instanceof Element?e.target.closest(`td, th`):null,i=t?.parentElement;n.classList.toggle(`is-active`,!!t&&t===i?.lastElementChild),r.classList.toggle(`is-active`,!!i&&i===i.parentElement?.lastElementChild)},o=()=>{n.classList.remove(`is-active`),r.classList.remove(`is-active`)};e.addEventListener(`pointerover`,a),e.addEventListener(`pointerleave`,o),this.overlays.set(e,{container:t,cleanup:()=>{i(),e.removeEventListener(`pointerover`,a),e.removeEventListener(`pointerleave`,o),t.remove()}})}removeOverlay(e){let t=this.overlays.get(e);t&&(t.cleanup(),this.overlays.delete(e))}insert(e,t){let n=e.querySelector(`table`);if(!n)return;let r=jj(this.view,n);if(r===null)return;let i=t(this.view.state,r);i&&(this.view.dispatch(i),this.view.focus())}},Fj=Y.create({name:`tableInsertControls`,addProseMirrorPlugins(){let e=this.editor;return[new Et({key:new ke(`tableInsertControls`),view:t=>new Pj(t,e)})]}}),Ij=`ok:tag-click`;function Lj(e){if(typeof document>`u`)return;let t={value:e};document.dispatchEvent(new CustomEvent(Ij,{detail:t}))}function Rj(e){return e instanceof Element?e.closest(`a[data-tag]`):null}var zj=Y.create({name:`tagClick`,addProseMirrorPlugins(){return[new Et({props:{handleDOMEvents:{click(e,t){let n=Rj(t.target);if(!n)return!1;let r=n.getAttribute(`data-tag`);return r?(t.preventDefault(),t.stopPropagation(),Lj(r),!0):!1}}}})]}});function Bj(e,t,n){if(typeof t!=`number`||!n||!Ot.test(n))return!1;let{state:r,view:i}=e,a=r.doc.nodeAt(t);if(!a||a.type.name!==`tag`)return!1;let o=r.tr.setNodeMarkup(t,null,{...a.attrs,value:n}),s=t+a.nodeSize;return o.insertText(` `,s),o.setSelection(y.create(o.doc,s+1)),i.dispatch(o),i.focus(),!0}function Vj(e,t){if(typeof t!=`number`)return;let{state:n,view:r}=e,i=n.doc.nodeAt(t);if(!i||i.type.name!==`tag`)return;let a=n.tr.delete(t,t+i.nodeSize);r.dispatch(a),r.focus()}function Hj(e){let t=(0,$.c)(3),{value:n}=e,r=`#tag/${n}`,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsxs)(`a`,{className:`tag`,"data-tag":n,href:r,children:[`#`,n]}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function Uj(e){let t=(0,$.c)(20),{initialDraft:n,onCommit:r,onCancel:i}=e,{_:a}=s(),o=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(n),u=(0,Q.useRef)(!1),d,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=requestAnimationFrame(()=>{o.current?.focus()});return()=>cancelAnimationFrame(e)},f=[],t[0]=d,t[1]=f):(d=t[0],f=t[1]),(0,Q.useEffect)(d,f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono`,children:`#`}),t[2]=p):p=t[2];let m=Math.max(c.length,8),h;t[3]===a?h=t[4]:(h=a({id:`U2pMtf`}),t[3]=a,t[4]=h);let g;t[5]===a?g=t[6]:(g=a({id:`knjOzA`}),t[5]=a,t[6]=g);let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{let t=e.target.value;(t===``||Ot.test(t))&&l(t)},t[7]=_):_=t[7];let v,y;t[8]!==c||t[9]!==i||t[10]!==r?(v=e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),u.current=!0,r(c)||(u.current=!1,i())):(e.key===`Escape`||e.key===`Backspace`&&c===``)&&(e.preventDefault(),i())},y=()=>{if(!u.current){if(c===``){i();return}Ot.test(c)?r(c):i()}},t[8]=c,t[9]=i,t[10]=r,t[11]=v,t[12]=y):(v=t[11],y=t[12]);let b;return t[13]!==c||t[14]!==m||t[15]!==h||t[16]!==g||t[17]!==v||t[18]!==y?(b=(0,Z.jsxs)(`span`,{className:`tag tag-placeholder inline-flex items-center rounded-sm border border-dashed border-muted-foreground/40 bg-muted/30 px-1.5 py-0.5 text-xs text-muted-foreground`,"data-component-type":`tag-placeholder`,children:[p,(0,Z.jsx)(`input`,{ref:o,type:`text`,value:c,size:m,placeholder:h,"aria-label":g,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,className:`bg-transparent border-0 p-0 outline-none focus:outline-none focus:ring-0 text-inherit font-inherit`,onChange:_,onKeyDown:v,onBlur:y})]}),t[13]=c,t[14]=m,t[15]=h,t[16]=g,t[17]=v,t[18]=y,t[19]=b):b=t[19],b}function Wj(e){let t=(0,$.c)(5),{node:n,getPos:r,editor:i}=e,a=typeof n.attrs.value==`string`?n.attrs.value:``;if(a===``){let e;return t[0]!==i||t[1]!==r?(e=(0,Z.jsx)(Dn,{as:`span`,children:(0,Z.jsx)(Uj,{initialDraft:``,onCommit:e=>Bj(i,typeof r==`function`?r():void 0,e),onCancel:()=>Vj(i,typeof r==`function`?r():void 0)})}),t[0]=i,t[1]=r,t[2]=e):e=t[2],e}let o;return t[3]===a?o=t[4]:(o=(0,Z.jsx)(Dn,{as:`span`,children:(0,Z.jsx)(Hj,{value:a})}),t[3]=a,t[4]=o),o}var Gj=C.extend({priority:200,addNodeView(){return bn(Wj)},addKeyboardShortcuts(){return{Backspace:()=>{if(rl.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`tag`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(rl.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`tag`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[ul(this.editor)]}}),Kj=2048,qj=24;function Jj(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>Kj)return{kind:`unsupported`,value:``};if(Zj(t))return{kind:`emoji`,value:t};let n=Qj(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:le(`/api/asset?path=${encodeURIComponent(Xj(t))}`)}:{kind:`unsupported`,value:``}}function Yj(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>Kj)return{kind:`unsupported`,value:``};let n=Qj(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:le(`/api/asset?path=${encodeURIComponent(Xj(t))}`)}:{kind:`unsupported`,value:``}}function Xj(e){return e.startsWith(`/`)?e.slice(1):e}function Zj(e){if(/\p{L}/u.test(e)||e.includes(`/`))return!1;let t=0;for(let n of e)t++;if(t>qj)return!1;let n=e.lastIndexOf(`.`);if(n>-1){let t=e.slice(n+1).toLowerCase();if(j.has(t))return!1}return!0}function Qj(e){let t=$j(e);if(!t||!j.has(t))return`unsupported`;let n=e.indexOf(`:`),r=e.indexOf(`/`);return n>-1&&(r===-1||n<r)?ye(e)?`url`:`unsupported`:e.startsWith(`//`)||e.includes(`?`)||e.includes(`#`)||e.startsWith(`../`)||e.includes(`/../`)?`unsupported`:`path`}function $j(e){let t=e.lastIndexOf(`/`),n=t>-1?e.slice(t+1):e,r=n.search(/[?#]/),i=r>-1?n.slice(0,r):n,a=i.lastIndexOf(`.`);return a<=0||a===i.length-1?null:i.slice(a+1).toLowerCase()}function eM(e){let t=(0,$.c)(133),{open:n,target:r,alias:i,anchor:a,pages:c,assetPaths:l,filePaths:u,loading:d,onOpenChange:f,onSave:p}=e,[m,h]=(0,Q.useState)(r),[g,_]=(0,Q.useState)(i??``),[v,y]=(0,Q.useState)(a??``),b=(0,Q.useId)(),x=(0,Q.useId)(),S=(0,Q.useId)(),C=(0,Q.useId)(),{_:w}=s(),T;t[0]!==l||t[1]!==m||t[2]!==u?(T=on(m,l,u),t[0]=l,t[1]=m,t[2]=u,t[3]=T):T=t[3];let E=T,D;t[4]!==l||t[5]!==m||t[6]!==u||t[7]!==c?(D=rn(m,c,l,u),t[4]=l,t[5]=m,t[6]=u,t[7]=c,t[8]=D):D=t[8];let O=HO(m,D&&!E&&n),k=(0,Q.useRef)(!1),A,j;t[9]!==i||t[10]!==a||t[11]!==n||t[12]!==r?(A=()=>{if(!n){k.current=!1;return}k.current||(k.current=!0,h(r),_(i??``),y(a??``))},j=[n,r,i,a],t[9]=i,t[10]=a,t[11]=n,t[12]=r,t[13]=A,t[14]=j):(A=t[13],j=t[14]),(0,Q.useEffect)(A,j);let M;t[15]!==g||t[16]!==v||t[17]!==m||t[18]!==f||t[19]!==p?(M=function(){let e=m.trim();e&&(p(e,g.trim()||null,v.trim()||null),f(!1))},t[15]=g,t[16]=v,t[17]=m,t[18]=f,t[19]=p,t[20]=M):M=t[20];let N=M,P;t[21]===N?P=t[22]:(P=function(e){e.key===`Enter`&&(e.preventDefault(),N())},t[21]=N,t[22]=P);let F=P,I;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(I=function(e){h(e.path),y(``)},t[23]=I):I=t[23];let L=I,R,ee,z,te,ne,re,B,V,H,U,W,G,ie,K,ae,oe,q;if(t[24]!==w||t[25]!==S||t[26]!==x||t[27]!==l||t[28]!==g||t[29]!==v||t[30]!==m||t[31]!==F||t[32]!==C||t[33]!==O||t[34]!==d||t[35]!==f||t[36]!==n||t[37]!==c||t[38]!==b){let e=new Map,r=O?.map(t=>{let n=e.get(t.slug)??0;e.set(t.slug,n+1);let r=n===0?t.slug:`${t.slug}-${n}`;return{...t,reactKey:r}}),i=!!r?.length;z=Hr,K=n,ae=f,ee=Pr,V=`sm:max-w-xl`,H=``,U=wO,W=wO,G=wO;let a;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(kr,{children:(0,Z.jsx)(o,{id:`xzktOa`})}),t[56]=a):a=t[56],t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsxs)(Vr,{children:[a,(0,Z.jsx)(Or,{children:(0,Z.jsx)(o,{id:`Jhj_lh`})})]}),t[57]=ie):ie=t[57],R=Lr,ne=`space-y-6`;let s;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(o,{id:`lGs_bQ`,components:{0:(0,Z.jsx)(`span`,{className:`text-red-500`})}}),t[58]=s):s=t[58];let u;t[59]===b?u=t[60]:(u=(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:b,children:s}),t[59]=b,t[60]=u);let p;t[61]===w?p=t[62]:(p=w({id:`aM23Wr`}),t[61]=w,t[62]=p);let T;t[63]!==l||t[64]!==m||t[65]!==F||t[66]!==d||t[67]!==c||t[68]!==p||t[69]!==b?(T=(0,Z.jsx)(DO,{id:b,value:m,pages:c,assetPaths:l,includeAssets:!0,loading:d,onValueChange:h,onSuggestionSelect:L,placeholder:p,autoFocus:!0,"aria-required":`true`,onKeyDown:F}),t[63]=l,t[64]=m,t[65]=F,t[66]=d,t[67]=c,t[68]=p,t[69]=b,t[70]=T):T=t[70],t[71]!==u||t[72]!==T?(re=(0,Z.jsxs)(`div`,{children:[u,T]}),t[71]=u,t[72]=T,t[73]=re):re=t[73];let E;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(o,{id:`OTF92M`,components:{0:(0,Z.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[74]=E):E=t[74];let D;t[75]===S?D=t[76]:(D=(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:S,children:E}),t[75]=S,t[76]=D);let k;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>_(e.target.value),t[77]=k):k=t[77];let A;t[78]===w?A=t[79]:(A=w({id:`BH56dn`}),t[78]=w,t[79]=A);let j;t[80]!==S||t[81]!==g||t[82]!==F||t[83]!==A?(j=(0,Z.jsx)(ri,{id:S,value:g,onChange:k,placeholder:A,onKeyDown:F}),t[80]=S,t[81]=g,t[82]=F,t[83]=A,t[84]=j):j=t[84],t[85]!==D||t[86]!==j?(B=(0,Z.jsxs)(`div`,{children:[D,j]}),t[85]=D,t[86]=j,t[87]=B):B=t[87];let M;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(o,{id:`Tjc1pH`,components:{0:(0,Z.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[88]=M):M=t[88],t[89]===x?oe=t[90]:(oe=(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:x,children:M}),t[89]=x,t[90]=oe);let N;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>y(e.target.value),t[91]=N):N=t[91];let P;t[92]===w?P=t[93]:(P=w({id:`W-ntoW`}),t[92]=w,t[93]=P),t[94]!==x||t[95]!==v||t[96]!==F||t[97]!==P?(q=(0,Z.jsx)(ri,{id:x,value:v,onChange:N,placeholder:P,onKeyDown:F}),t[94]=x,t[95]=v,t[96]=F,t[97]=P,t[98]=q):q=t[98],te=i&&(0,Z.jsx)(`div`,{id:C,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:r.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":v===e.slug,className:Ft(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,v===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>y(v===e.slug?``:e.slug),children:[(0,Z.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.text})]},e.reactKey))}),t[24]=w,t[25]=S,t[26]=x,t[27]=l,t[28]=g,t[29]=v,t[30]=m,t[31]=F,t[32]=C,t[33]=O,t[34]=d,t[35]=f,t[36]=n,t[37]=c,t[38]=b,t[39]=R,t[40]=ee,t[41]=z,t[42]=te,t[43]=ne,t[44]=re,t[45]=B,t[46]=V,t[47]=H,t[48]=U,t[49]=W,t[50]=G,t[51]=ie,t[52]=K,t[53]=ae,t[54]=oe,t[55]=q}else R=t[39],ee=t[40],z=t[41],te=t[42],ne=t[43],re=t[44],B=t[45],V=t[46],H=t[47],U=t[48],W=t[49],G=t[50],ie=t[51],K=t[52],ae=t[53],oe=t[54],q=t[55];let se;t[99]!==te||t[100]!==oe||t[101]!==q?(se=(0,Z.jsxs)(`div`,{children:[oe,q,te]}),t[99]=te,t[100]=oe,t[101]=q,t[102]=se):se=t[102];let ce;t[103]!==ne||t[104]!==re||t[105]!==B||t[106]!==se?(ce=(0,Z.jsxs)(`div`,{className:ne,children:[re,B,se]}),t[103]=ne,t[104]=re,t[105]=B,t[106]=se,t[107]=ce):ce=t[107];let J;t[108]!==R||t[109]!==ce?(J=(0,Z.jsx)(R,{children:ce}),t[108]=R,t[109]=ce,t[110]=J):J=t[110];let le;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Z.jsx)(Br,{asChild:!0,children:(0,Z.jsx)(zt,{variant:`outline`,children:(0,Z.jsx)(o,{id:`dEgA5A`})})}),t[111]=le):le=t[111];let ue;t[112]===m?ue=t[113]:(ue=m.trim(),t[112]=m,t[113]=ue);let Y=!ue,de;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Z.jsx)(o,{id:`tfDRzk`}),t[114]=de):de=t[114];let fe;t[115]!==N||t[116]!==Y?(fe=(0,Z.jsxs)(Rr,{children:[le,(0,Z.jsx)(zt,{onClick:N,disabled:Y,children:de})]}),t[115]=N,t[116]=Y,t[117]=fe):fe=t[117];let pe;t[118]!==ee||t[119]!==V||t[120]!==H||t[121]!==U||t[122]!==W||t[123]!==G||t[124]!==ie||t[125]!==J||t[126]!==fe?(pe=(0,Z.jsxs)(ee,{className:V,"data-ok-layer-spawned":H,onPointerDownOutside:U,onFocusOutside:W,onInteractOutside:G,children:[ie,J,fe]}),t[118]=ee,t[119]=V,t[120]=H,t[121]=U,t[122]=W,t[123]=G,t[124]=ie,t[125]=J,t[126]=fe,t[127]=pe):pe=t[127];let me;return t[128]!==z||t[129]!==K||t[130]!==ae||t[131]!==pe?(me=(0,Z.jsx)(z,{open:K,onOpenChange:ae,children:pe}),t[128]=z,t[129]=K,t[130]=ae,t[131]=pe,t[132]=me):me=t[132],me}function tM(e){let t=(0,$.c)(116),{editor:n,getPos:r,onClose:i,onNavigate:a}=e,c=r(),l=c==null?null:n.state.doc.nodeAt(c),u=String(l?.attrs.target??``),d=De(l?.attrs.alias),f=De(l?.attrs.anchor),p=Ct({target:u,alias:d,anchor:f}),{addPage:m,assetPaths:h,filePaths:g,folderPaths:_,pages:v,pagesBySlug:y,pagesByBasename:b,loading:x}=Wn(),S=lt(u,f),C=S?.kind===`external`?S:null,w=S?.kind===`asset`?on(S.url,h,g)??S.url.replace(/^\//,``):null,T=w?null:In(u,{pages:v,folderPaths:_,pagesBySlug:y,pagesByBasename:b,fallbackTargets:Kt(u)}),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(!1),{_:A}=s();if(!l)return null;let j;t[0]!==n.state||t[1]!==n.view||t[2]!==r?(j=function(e,t,i){let a=r();a!=null&&n.view.dispatch(n.state.tr.setNodeMarkup(a,void 0,{...n.state.doc.nodeAt(a)?.attrs,target:e,alias:t,anchor:i}))},t[0]=n.state,t[1]=n.view,t[2]=r,t[3]=j):j=t[3];let M=j,N;t[4]!==n.state||t[5]!==n.view||t[6]!==r||t[7]!==i?(N=function(){let e=r();if(e==null)return;let t=n.state.doc.nodeAt(e);t&&(n.view.dispatch(n.state.tr.delete(e,e+t.nodeSize)),i())},t[4]=n.state,t[5]=n.view,t[6]=r,t[7]=i,t[8]=N):N=t[8];let P=N,F=function(e){if(e!==u){let t=r();if(t==null)return;n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...n.state.doc.nodeAt(t)?.attrs,target:e,alias:d??p}))}},I=function(){return T?.kind===`create`?{initialDir:T.initialDir,suggestedName:T.suggestedName}:null},L=async function(){let e=I();if(!(!e||O)){k(!0);try{await fO(e,{addPage:m,onCreated(e){F(e),window.location.hash=`#/${e}`,i()}}),k(!1)}catch(e){let t=e;sr.error(t instanceof Error?t.message:A({id:`tfi40B`})),k(!1)}}},R=!C&&!x&&w!==null,ee=!C&&!x&&T?.kind===`navigate`&&T.displayState===`resolved`,z=!C&&!x&&T?.kind===`navigate`&&T.displayState===`folder`,te=!C&&!x&&!w&&T?.kind===`create`,ne=!!C,re=C?fn(C.url)?C.url:null:R&&w?yi(w):ee&&T?.kind===`navigate`?Ln({docName:T.hashDocName,anchor:f}):null,B=!x&&re!==null&&(ne||R||ee),V,H,U,W,G;if(t[9]!==A||t[10]!==d||t[11]!==f||t[12]!==w||t[13]!==n.state||t[14]!==n.view||t[15]!==C||t[16]!==r||t[17]!==R||t[18]!==z||t[19]!==ee||t[20]!==te||t[21]!==x||t[22]!==u){if(x){let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ir,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[28]=e):e=t[28],U={icon:e,text:A({id:`yQE2r9`}),className:`text-muted-foreground/80`}}else if(C){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Un,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[29]=e):e=t[29],U={icon:e,text:A({id:`hpDtUm`}),className:`text-muted-foreground`}}else if(R){let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Qa,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[30]=e):e=t[30],U={icon:e,text:A({id:`bUUVED`}),className:`text-muted-foreground`}}else if(z){let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(tr,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[31]=e):e=t[31],U={icon:e,text:A({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(te){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ua,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[32]=e):e=t[32],U={icon:e,text:A({id:`8F1i42`}),className:`text-red-700 dark:text-red-300`}}else if(ee){let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(eo,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[33]=e):e=t[33],U={icon:e,text:A({id:`Hrz9NY`}),className:`text-muted-foreground`}}else{let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ua,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[34]=e):e=t[34],U={icon:e,text:A({id:`DeDYLr`}),className:`text-muted-foreground/80`}}let e;t[35]!==n.state||t[36]!==n.view||t[37]!==r?(e=()=>{let e=r();if(typeof e!=`number`)return new DOMRect;let t=n.state.doc.nodeAt(e);if(!t)return new DOMRect;try{return _t(n.view,e,e+t.nodeSize)}catch{return new DOMRect}},t[35]=n.state,t[36]=n.view,t[37]=r,t[38]=e):e=t[38];let i;t[39]!==n.view.dom||t[40]!==e?(i={getBoundingClientRect:e,contextElement:n.view.dom},t[39]=n.view.dom,t[40]=e,t[41]=i):i=t[41],G=i,H=w??(C?C.url:`${u}${f?`#${f}`:``}`);let a=f?`${u}#${f}`:u;V=d?`[[${a}|${d}]]`:`[[${a}]]`,W=Ft(`flex shrink-0`,U.className),t[9]=A,t[10]=d,t[11]=f,t[12]=w,t[13]=n.state,t[14]=n.view,t[15]=C,t[16]=r,t[17]=R,t[18]=z,t[19]=ee,t[20]=te,t[21]=x,t[22]=u,t[23]=V,t[24]=H,t[25]=U,t[26]=W,t[27]=G}else V=t[23],H=t[24],U=t[25],W=t[26],G=t[27];let ie;t[42]!==U.icon||t[43]!==W?(ie=(0,Z.jsx)(`span`,{className:W,children:U.icon}),t[42]=U.icon,t[43]=W,t[44]=ie):ie=t[44];let K=ie,ae;t[45]!==K||t[46]!==te||t[47]!==U.text?(ae=te?(0,Z.jsxs)(Sr,{children:[(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`wiki-link-prop-panel-icon-trigger`,children:K})}),(0,Z.jsx)(xr,{children:U.text})]}):K,t[45]=K,t[46]=te,t[47]=U.text,t[48]=ae):ae=t[48];let oe=ae,q=`${U.text}: ${H}`,se;t[49]!==H||t[50]!==ne||t[51]!==te||t[52]!==re||t[53]!==B||t[54]!==i||t[55]!==a?(se=(0,Z.jsx)(br,{asChild:!0,children:B?(0,Z.jsx)(`a`,{href:re??void 0,...ne?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>_n(e,a,i),"data-slot":`wiki-link-prop-panel-text`,className:`block truncate text-sm font-medium text-foreground underline-offset-2 hover:underline focus-visible:underline`,children:H}):(0,Z.jsx)(`span`,{"data-slot":`wiki-link-prop-panel-text`,className:Ft(`block truncate text-sm font-medium`,te?`text-muted-foreground`:`text-foreground`),children:H})}),t[49]=H,t[50]=ne,t[51]=te,t[52]=re,t[53]=B,t[54]=i,t[55]=a,t[56]=se):se=t[56];let ce;t[57]===H?ce=t[58]:(ce=(0,Z.jsx)(xr,{className:`max-w-80 break-all`,children:H}),t[57]=H,t[58]=ce);let J;t[59]!==se||t[60]!==ce?(J=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsxs)(Sr,{children:[se,ce]})}),t[59]=se,t[60]=ce,t[61]=J):J=t[61];let le;t[62]!==L||t[63]!==O||t[64]!==te?(le=te?(0,Z.jsxs)(zt,{type:`button`,size:`sm`,variant:`link`,disabled:O,onClick:()=>void L(),"data-slot":`wiki-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,Z.jsx)(So,{className:`size-3.5`,"aria-hidden":`true`}),O?(0,Z.jsx)(o,{id:`HM56Bx`}):(0,Z.jsx)(o,{id:`XRuL0i`})]}):null,t[62]=L,t[63]=O,t[64]=te,t[65]=le):le=t[65];let ue;t[66]===A?ue=t[67]:(ue=A({id:`ePK91l`}),t[66]=A,t[67]=ue);let Y;t[68]===D?Y=t[69]:(Y=()=>D(!0),t[68]=D,t[69]=Y);let de;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Z.jsx)($n,{className:`size-3.5`,"aria-hidden":`true`}),t[70]=de):de=t[70];let fe;t[71]!==ue||t[72]!==Y?(fe=(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":ue,onClick:Y,"data-slot":`wiki-link-prop-panel-edit`,children:de})}),t[71]=ue,t[72]=Y,t[73]=fe):fe=t[73];let pe;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(xr,{children:(0,Z.jsx)(o,{id:`ePK91l`})}),t[74]=pe):pe=t[74];let me;t[75]===fe?me=t[76]:(me=(0,Z.jsxs)(Sr,{children:[fe,pe]}),t[75]=fe,t[76]=me);let he;t[77]===V?he=t[78]:(he=(0,Z.jsx)(FO,{copyContent:V}),t[77]=V,t[78]=he);let ge;t[79]===A?ge=t[80]:(ge=A({id:`t_YqKh`}),t[79]=A,t[80]=ge);let _e;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`}),t[81]=_e):_e=t[81];let ve;t[82]!==P||t[83]!==ge?(ve=(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":ge,onClick:P,"data-slot":`wiki-link-prop-panel-remove`,children:_e})}),t[82]=P,t[83]=ge,t[84]=ve):ve=t[84];let ye;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Z.jsx)(xr,{children:(0,Z.jsx)(o,{id:`t_YqKh`})}),t[85]=ye):ye=t[85];let be;t[86]===ve?be=t[87]:(be=(0,Z.jsxs)(Sr,{children:[ve,ye]}),t[86]=ve,t[87]=be);let xe;t[88]!==le||t[89]!==me||t[90]!==he||t[91]!==be?(xe=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[le,me,he,be]}),t[88]=le,t[89]=me,t[90]=he,t[91]=be,t[92]=xe):xe=t[92];let Se;t[93]!==oe||t[94]!==J||t[95]!==xe?(Se=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[oe,J,xe]}),t[93]=oe,t[94]=J,t[95]=xe,t[96]=Se):Se=t[96];let Ce;t[97]!==i||t[98]!==Se||t[99]!==q||t[100]!==G?(Ce=(0,Z.jsx)(nO,{kind:`wiki-link`,ariaLabel:q,onDeactivate:i,triggerReference:G,className:`w-96`,children:Se}),t[97]=i,t[98]=Se,t[99]=q,t[100]=G,t[101]=Ce):Ce=t[101];let we;t[102]!==d||t[103]!==f||t[104]!==h||t[105]!==E||t[106]!==g||t[107]!==M||t[108]!==x||t[109]!==v||t[110]!==D||t[111]!==u?(we=(0,Z.jsx)(eM,{open:E,target:u,alias:d,anchor:f,pages:v,assetPaths:h,filePaths:g,loading:x,onOpenChange:D,onSave:M}),t[102]=d,t[103]=f,t[104]=h,t[105]=E,t[106]=g,t[107]=M,t[108]=x,t[109]=v,t[110]=D,t[111]=u,t[112]=we):we=t[112];let Te;return t[113]!==Ce||t[114]!==we?(Te=(0,Z.jsxs)(Z.Fragment,{children:[Ce,we]}),t[113]=Ce,t[114]=we,t[115]=Te):Te=t[115],Te}var nM=0;function rM(){return`wiki-link-${++nM}`}function iM(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`span`);n.setAttribute(`data-wiki-link`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Wiki link: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-chip`),n.style.touchAction=`manipulation`;let r=t.createElement(`span`);r.setAttribute(`data-wiki-link-icon`,``),r.setAttribute(`aria-hidden`,`true`),n.appendChild(r);let i=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,a=t.createTextNode(i);return n.appendChild(a),{dom:n,iconSpan:r}}function aM(e,t){if(!t||!e)return null;let n=Gt(e,t);if(!n)return null;let r=t.pageIcons?.get(n);if(!r)return null;let i=Jj(r);return i.kind===`unsupported`?null:i}function oM(e,t,n=document){let r=t?.kind??``,i=t?.value??``;if(e.getAttribute(`data-kind`)===r&&e.getAttribute(`data-value`)===i)return;for(e.setAttribute(`data-kind`,r),e.setAttribute(`data-value`,i);e.firstChild;)e.removeChild(e.firstChild);if(!t)return;if(t.kind===`emoji`){e.appendChild(n.createTextNode(t.value));return}let a=n.createElement(`img`);a.setAttribute(`src`,t.value),a.setAttribute(`alt`,``),a.setAttribute(`draggable`,`false`),a.setAttribute(`referrerpolicy`,`no-referrer`),e.appendChild(a)}var sM=h.extend({priority:200,addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=rM(),{dom:i,iconSpan:a}=iM({nodeId:r,target:String(t.attrs.target??``),alias:t.attrs.alias==null?null:String(t.attrs.alias),anchor:t.attrs.anchor==null?null:String(t.attrs.anchor)}),o=t,s=()=>{oM(a,aM(String(o.attrs.target??``),li()))};s();let c=si(s),l=()=>{let e=n();return typeof e==`number`?e:void 0},u=Xg(e),d=({newTab:e})=>{let t=o.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=lt(n,typeof t.anchor==`string`?t.anchor:null);if(!r)return!1;if(r.kind===`doc`){let t=li(),i=In(n,{pages:t?.pages??new Set,folderPaths:t?.folderPaths??new Set,pagesBySlug:t?.pagesBySlug,pagesByBasename:t?.pagesByBasename,fallbackTargets:Kt(n)});if(i.kind===`create`||i.kind===`navigate`&&i.displayState===`folder`)return!1;let a=i.kind===`navigate`?i.hashDocName:r.docName;return e?Fn({docName:a,anchor:r.anchor}):window.location.assign(Ln({docName:a,anchor:r.anchor})),!0}if(r.kind===`asset`){let t=li(),n=on(r.url,t?.assetPaths??new Set,t?.filePaths)??r.url.replace(/^\//,``);return e?un(yi(n)):window.location.hash=yi(n),!0}return fn(r.url)?(un(r.url),!0):!1};return u.register({type:`wikiLink`,nodeId:r,getPos:l,controls:{propPanel:t=>(0,Q.createElement)(tM,{editor:e,getPos:l,onClose:t.deactivate,onNavigate:e=>d({newTab:e})})},handlePrimary:d}),{dom:i,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLink`)return!1;o=e;let t=String(e.attrs.target??``),n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor);i.setAttribute(`data-target`,t),i.setAttribute(`data-alias`,n??``),i.setAttribute(`data-anchor`,r??``),i.setAttribute(`aria-label`,`Wiki link: ${t}${r?`#${r}`:``}`);let a=n??`${t}${r?`#${r}`:``}`,c=i.lastChild;return c&&c.nodeType===3?c.nodeValue=a:i.appendChild(i.ownerDocument.createTextNode(a)),s(),!0},destroy:()=>{u.deregister(r),c()}}}},addKeyboardShortcuts(){return{Backspace:()=>{if(mn.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(mn.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[jn(this.editor)]}}),cM=0;function lM(){return`wiki-link-embed-${++cM}`}function uM(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`a`);n.setAttribute(`data-wiki-embed`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`href`,e.href),n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Embed: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-embed-chip`),n.style.touchAction=`manipulation`;let r=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,i=t.createTextNode(r);return n.appendChild(i),{dom:n}}function dM(e){let t=(e.doc??(typeof document<`u`?document:{createElement:null})).createElement(`img`);return t.setAttribute(`data-wiki-embed`,``),t.setAttribute(`data-node-id`,e.nodeId),t.setAttribute(`data-target`,e.target),t.setAttribute(`data-alias`,e.alias??``),t.setAttribute(`src`,le(e.src)),t.setAttribute(`alt`,e.alias??e.target),{dom:t}}function fM(e){let t=We(e);return t!==null&&j.has(t)}var pM=Ye.extend({addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=lM(),i=t,a=String(t.attrs.target??``),o=t.attrs.alias==null?null:String(t.attrs.alias),s=t.attrs.anchor==null?null:String(t.attrs.anchor),c=t.attrs.resolvedSrc==null?null:String(t.attrs.resolvedSrc);if(fM(a)){let{dom:e}=dM({nodeId:r,target:a,alias:o,src:c??a});return{dom:e,ignoreMutation:()=>!0,update:t=>{if(t.type.name!==`wikiLinkEmbed`)return!1;i=t;let n=String(t.attrs.target??``),r=t.attrs.alias==null?null:String(t.attrs.alias),a=t.attrs.resolvedSrc==null?null:String(t.attrs.resolvedSrc);if(!fM(n))return!1;let o=a??n;return e.setAttribute(`data-target`,n),e.setAttribute(`data-alias`,r??``),e.setAttribute(`src`,le(o)),e.setAttribute(`alt`,r??n),!0}}}let{dom:l}=uM({nodeId:r,target:a,alias:o,anchor:s,href:c??a});l.addEventListener(`click`,e=>{e.preventDefault()});let u=()=>{let e=n();return typeof e==`number`?e:void 0},d=Xg(e);return d.register({type:`wikiLinkEmbed`,nodeId:r,getPos:u,controls:{},handlePrimary:({newTab:e})=>{let t=i.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=(typeof t.resolvedSrc==`string`&&t.resolvedSrc.length>0?t.resolvedSrc:null)??n,a=We(n);if(a===null)return!1;let o=He(r,``)??n;return On({url:r,projectRelPath:o,ext:a,title:o.split(`/`).pop()??r,newTab:e}),!0}}),{dom:l,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let t=String(e.attrs.target??``);if(fM(t))return!1;let n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor),a=(e.attrs.resolvedSrc==null?null:String(e.attrs.resolvedSrc))??t;return l.setAttribute(`data-target`,t),l.setAttribute(`data-alias`,n??``),l.setAttribute(`data-anchor`,r??``),l.setAttribute(`href`,a),l.setAttribute(`aria-label`,`Embed: ${t}${r?`#${r}`:``}`),l.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{d.deregister(r)}}}}}),mM=[...Ae.map(e=>{if(e.name===`jsxComponent`)return sj;if(e.name===`image`){let t=e.options??{};return QD.configure({...t,inline:!0})}return e.name===`rawMdxFallback`?vj:e.name===`wikiLink`?sM:e.name===`wikiLinkEmbed`?pM:e.name===`link`?ZO:e.name===`mathInline`?hj:e.name===`tag`?Gj:e.name===`codeBlock`?QE:e}),Cj.configure({itemsSources:[Tb,_b,wb,yb],categoryLabels:{content:`Components`,layout:`Layout`,media:`Media`,data:`Data`,embed:`Embeds`}}),YD,Dj,bh.configure({onDrop(e,t,n){for(let r of t)xg(r,e,n)},onPaste(e,t,n){for(let n of t)xg(n,e,e.state.selection.from)}}),XD,Bh,zj,JD,KD,Ab,Fj,Tj,ug,Eg,wh,Fb,EA,Y.create({name:`chunkWrapperDecoration`,addProseMirrorPlugins(){return[Vb()]}})];function hM(e){return e===at}function gM(){return fi(`SYNC_TIMEOUT_MS`,3e4)}var _M=class extends Error{docName;elapsedMs;constructor(e,t){super(`Sync timed out for "${e}" after ${t}ms`),this.name=`SyncTimeoutError`,this.docName=e,this.elapsedMs=t}},vM=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},yM=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},bM=class extends Error{docName;cause;constructor(e,t){let n=t instanceof Error?t.message:String(t??`unknown`);super(`Bridge setup failed for "${e}": ${n}`),this.name=`BridgeSetupError`,this.docName=e,this.cause=t}},xM=class extends Error{docName;missingCapability;constructor(e,t){super(`Server is missing capability "${t}" required to open "${e}".`),this.name=`ServerCapabilityMismatchError`,this.docName=e,this.missingCapability=t}},SM=new Map,CM=!1;function wM(){for(let e of SM.values())if(!e.settled)return!0;return!1}function TM(){typeof document>`u`||document.visibilityState===`visible`&&EM(Date.now())}function EM(e){let t=[];for(let[n,r]of SM){if(r.settled)continue;let i=e-r.createdAt;if(i<gM())continue;r.settled=!0;let a=new _M(n,i);AM(r),r.reject(a);let o=Pf(n);o!==void 0&&Gf(o),t.push({docName:n,elapsedMs:i})}if(t.length>0){let e=t.map(e=>`${e.docName} (${e.elapsedMs}ms)`).join(`, `);console.warn(`[syncPromise] reaped ${t.length} timed-out ${t.length===1?`entry`:`entries`} on visibility restore (tab-sleep recovered): ${e}`)}return wM()||OM(),t.length}function DM(){CM||typeof document>`u`||(document.addEventListener(`visibilitychange`,TM),CM=!0)}function OM(){CM&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,TM),CM=!1))}var kM=new Map;function AM(e){e.detached||(e.detached=!0,e.timeoutHandle!==null&&clearTimeout(e.timeoutHandle),e.provider.off(`synced`,e.onSynced),e.provider.off(`close`,e.onClose))}function jM(e,t){let n=SM.get(e);if(n)return n.promise;let r=kM.get(e);if(r!==void 0){kM.delete(e);let n=r===`timeout`?new _M(e,0):new vM(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),X(`ok/sync/create`,{docName:e,mountId:Pf(e),warm:!1,armed:r}),X(`ok/sync/reject`,{docName:e,mountId:Pf(e),reason:`armed-${r}`});let i=NM(n);return SM.set(e,PM(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`);let n=Pf(e);X(`ok/sync/create`,{docName:e,mountId:n,warm:!0}),X(`ok/sync/resolve`,{docName:e,mountId:n,elapsedMs:0,warm:!0}),X.histogram(`ok/sync/resolve-elapsed-ms`,n===void 0?{docName:e,warm:!0}:{docName:e,mountId:n,warm:!0},0);let r=Promise.resolve();return SM.set(e,MM(r,t)),r}let i=Date.now(),a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=()=>{let t=SM.get(e);if(!t||t.settled)return;t.settled=!0,t.resolved=!0;let n=Date.now()-t.createdAt;console.log(`[syncPromise] ${e} resolved in ${n}ms`);let r=Pf(e);if(X(`ok/sync/resolve`,{docName:e,mountId:r,elapsedMs:n,warm:!1}),X.histogram(`ok/sync/resolve-elapsed-ms`,r===void 0?{docName:e}:{docName:e,mountId:r},n),AM(t),wM()||OM(),t.resolve(),pi(),r!==void 0){let i=Date.now();Wf(r,`ok.sync-promise`,{"doc.name":e,elapsed_ms:n},t.createdAt,i),Gf(r,i)}},l=t=>{let n=SM.get(e);if(!n||n.settled)return;n.settled=!0;let r=new vM(e);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=Pf(e);X(`ok/sync/reject`,{docName:e,mountId:i,reason:`pre-sync-disconnect`}),AM(n),wM()||OM(),n.reject(r),i!==void 0&&Gf(i)},u=setTimeout(()=>{let t=SM.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new _M(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=Pf(e);X(`ok/sync/reject`,{docName:e,mountId:i,reason:`timeout`,elapsedMs:n}),AM(t),wM()||OM(),t.reject(r),i!==void 0&&Gf(i)},gM()),d={promise:s,resolve:a,reject:o,createdAt:i,timeoutHandle:u,provider:t,onSynced:c,onClose:l,settled:!1,resolved:!1,detached:!1};return SM.set(e,d),t.on(`synced`,c),t.on(`close`,l),DM(),X(`ok/sync/create`,{docName:e,mountId:Pf(e),warm:!1}),s}function MM(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!0,detached:!0}}function NM(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function PM(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!1,detached:!0}}function FM(e){return SM.get(e)?.resolved===!0}function IM(e){let t=SM.get(e);t&&(t.settled=!0,AM(t),SM.delete(e),wM()||OM())}function LM(e,t){let n=SM.get(e);if(!n||n.settled)return!1;n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),AM(n),wM()||OM(),n.reject(t);let r=Pf(e);return r!==void 0&&Gf(r),!0}var RM=Object.freeze({kind:`tab-replay`}),zM=Object.freeze({kind:`idle`});function BM(e,t){return()=>{}}var VM=null;function HM(){return VM??=ot(mM),VM}var UM=4e3,WM=1e4,GM=class extends Error{constructor(e,t){super(`client persistence clearData timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`ClientPersistenceClearTimeoutError`}},KM=class extends Error{constructor(e,t){super(`stored-state epoch peek timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`StoredEpochPeekTimeoutError`}},qM=`ok-last-observed-branch`,JM=`ok-doc-lineage-epochs`,YM=5e3,XM=fi(`MAX_BUFFER_BYTES`,1*1024*1024),ZM=fi(`MAX_POOL`,10),QM=class{_entries=new Map;get entries(){return this._entries}lruOrder=[];activeDocName=null;maxSize;wsUrl;recycleDebounceMs;clearDataTimeoutMs;onChange=null;tabIdentity=null;serverRestartRecoveryState=zM;cachedServerInstanceId=null;pendingServerInstanceKnown=null;recoveryMismatchStaleClaim;bufferedUpdates=new Map;pendingClears=new Map;clearFailures=new Set;persistenceFactory;peekStoredEpoch;storage;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n?.recycleDebounceMs??UM,this.clearDataTimeoutMs=n?.clearDataTimeoutMs??WM,this.persistenceFactory=n?.persistenceFactory??ph,this.peekStoredEpoch=n?.peekStoredLineageEpoch??mh,n?.storage===void 0?this.storage=globalThis.localStorage===void 0?null:globalThis.localStorage:this.storage=n.storage}setTabIdentity(e){this.tabIdentity=e}setExpectedServerInstanceId(e){if(this.cachedServerInstanceId=e,!(e===null||e.length===0)){if(this.pendingServerInstanceKnown!==null){let t=this.pendingServerInstanceKnown;this.pendingServerInstanceKnown=null,t.resolve(e)}this.attachDeferredPersistence(e)}}whenServerInstanceKnown(){if(this.cachedServerInstanceId!==null&&this.cachedServerInstanceId.length>0)return Promise.resolve(this.cachedServerInstanceId);if(this.pendingServerInstanceKnown!==null)return this.pendingServerInstanceKnown.promise;let e,t=new Promise(t=>{e=t});return this.pendingServerInstanceKnown={promise:t,resolve:e},t}buildPersistence(e,t,n){return this.persistenceFactory({branch:this.normalizedObservedBranch(),serverInstanceId:e,docName:t,doc:n})}async validateStoredStateThenAttach(e,t){if(e.persistenceAttachOwned)return;e.persistenceAttachOwned=!0;let n=e.docName,r=()=>this._entries.get(n)===e&&e.kind===`active`&&e.persistence===null&&!this.pendingClears.has(n);if(!r())return;let i;try{i=await new Promise((e,r)=>{let i=setTimeout(()=>{r(new KM(n,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);this.peekStoredEpoch({branch:this.normalizedObservedBranch(),serverInstanceId:t,docName:n}).then(t=>{clearTimeout(i),e(t)},e=>{clearTimeout(i),r(e)})})}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`peek`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)});return}if(!r())return;if(i===null){this.attachValidatedPersistence(e,t);return}if(!e.hasSynced&&(await this.awaitFirstSyncOrDestroy(e),!r()||!e.hasSynced))return;let a=e.provider.document.getMap(`lifecycle`).get(k),o=typeof a==`string`&&a.length>0?a:null;if(o===i){this.attachValidatedPersistence(e,t);return}this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`stored-state-validation`,staleEpoch:i,liveEpoch:o??`<absent>`});let s=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&s&&this.setActive(n)}attachValidatedPersistence(e,t){let n=e.docName;try{let r=this.buildPersistence(t,n,e.provider.document);e.persistence=r,this.notify(),this.backfillCacheAfterFirstSync(e,r).catch(e=>{this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`backfill`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)})})}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`attach`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)})}}async backfillCacheAfterFirstSync(e,t){await t.whenSynced,e.hasSynced||await this.awaitFirstSyncOrDestroy(e),!(this._entries.get(e.docName)!==e||e.kind!==`active`||e.persistence!==t||!e.hasSynced)&&await t.flushFullState()}async awaitFirstSyncOrDestroy(e){e.hasSynced||await new Promise(t=>{let n=()=>{e.provider.off(`synced`,n),e.provider.off(`destroy`,n),t()};e.provider.on(`synced`,n),e.provider.on(`destroy`,n)})}attachDeferredPersistence(e){for(let t of Array.from(this._entries.values()))if(t.kind===`active`&&t.persistence===null&&this._entries.get(t.docName)===t){if(t.hasSynced&&t.lineageEpochRecordAtOpen!==null){let e=t.provider.document.getMap(`lifecycle`).get(k);if(typeof e==`string`&&e.length>0&&e!==t.lineageEpochRecordAtOpen){let n=t.docName;this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`deferred-attach`,staleEpoch:t.lineageEpochRecordAtOpen,liveEpoch:e});let r=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&r&&this.setActive(n);continue}}this.validateStoredStateThenAttach(t,e)}}getServerRestartRecoveryState(){return this.serverRestartRecoveryState}observeDiskAck(e,t){let n=this.entries.get(e);!n||n.kind!==`active`||(n.lastDiskAckedSV=_h(n.lastDiskAckedSV,t))}observeDiskAckBatch(e){for(let[t,n]of Object.entries(e))this.observeDiskAck(t,n)}lastObservedBranch=null;lastObservedBranchInitialized=!1;getOrInitObservedBranch(){if(this.lastObservedBranchInitialized)return this.lastObservedBranch;this.lastObservedBranchInitialized=!0;try{let e=this.storage?.getItem(qM)??null;e!==null&&e.length>0&&(this.lastObservedBranch=e)}catch{}return this.lastObservedBranch}persistObservedBranch(e){this.lastObservedBranch=e,this.lastObservedBranchInitialized=!0;try{e===null||e.length===0?this.storage?.removeItem(qM):this.storage?.setItem(qM,e)}catch{}}docLineageEpochs=new Map;docLineageEpochsEnvelopeConsumed=!1;normalizedObservedBranch(){return this.getOrInitObservedBranch()??`_unknown_`}consumeLineageEpochEnvelopeIfValid(){if(this.docLineageEpochsEnvelopeConsumed)return;let e=this.cachedServerInstanceId;if(!(e===null||e.length===0)){this.docLineageEpochsEnvelopeConsumed=!0;try{let t=this.storage?.getItem(JM)??null;if(t===null)return;let n=JSON.parse(t);if(typeof n!=`object`||!n)return;let r=n;if(r.branch!==this.normalizedObservedBranch()||r.serverInstanceId!==e||typeof r.epochs!=`object`||r.epochs===null)return;for(let[e,t]of Object.entries(r.epochs))typeof t==`string`&&t.length>0&&!this.docLineageEpochs.has(e)&&this.docLineageEpochs.set(e,t)}catch(e){e instanceof DOMException||console.warn(JSON.stringify({event:`ok-lineage-epoch-envelope-read-error`,errorName:e instanceof Error?e.name:typeof e,message:e instanceof Error?e.message:String(e)}))}}}getRecordedLineageEpoch(e){let t=this.docLineageEpochs.get(e);return t===void 0?(this.consumeLineageEpochEnvelopeIfValid(),this.docLineageEpochs.get(e)??null):t}persistLineageEpochEnvelope(){let e=this.cachedServerInstanceId;if(!(e===null||e.length===0))try{this.storage?.setItem(JM,JSON.stringify({branch:this.normalizedObservedBranch(),serverInstanceId:e,epochs:Object.fromEntries(this.docLineageEpochs)}))}catch{}}recordLineageEpoch(e,t){this.docLineageEpochs.get(e)!==t&&(this.docLineageEpochs.set(e,t),this.persistLineageEpochEnvelope())}deleteLineageEpochRecord(e){this.docLineageEpochs.delete(e)&&this.persistLineageEpochEnvelope()}withClearDataTimeout(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(new GM(e,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);t.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e)})})}recoveryTelemetryBase(e,t){let n={docName:e,branch:this.normalizedObservedBranch()},r=t===void 0?this.recoveryMismatchStaleClaim:t;return r!==void 0&&r.length>0&&(n.serverInstanceId=r),n}emitStructuredClientRecoveryEvent(e){console.warn(JSON.stringify(e))}clearRecoveryMismatchStaleClaimIfTerminal(){let e=this.serverRestartRecoveryState.kind;(e===`idle`||e===`failed`)&&(this.recoveryMismatchStaleClaim=void 0)}beginServerRestartRecovery(e,t){this.serverRestartRecoveryState={kind:`recovering`,phase:`clearing-local-cache`,docNames:e,failedDocNames:[],startedAt:t};for(let t of e)IM(t);this.notify()}enterServerRestartReconnect(e,t,n,r){if(e.length===0){this.serverRestartRecoveryState=t.length===0?zM:{kind:`failed`,reason:r,docNames:t,failedDocNames:t,startedAt:n},this.clearRecoveryMismatchStaleClaimIfTerminal(),this.notify();return}this.serverRestartRecoveryState={kind:`recovering`,phase:`reconnecting`,docNames:e,failedDocNames:t,startedAt:n,...t.length>0?{clearFailureReason:r}:{}},this.notify()}markServerRestartRecoverySynced(e){let t=this.serverRestartRecoveryState;if(t.kind!==`recovering`||t.phase!==`reconnecting`||!t.docNames.includes(e))return;let n=t.docNames.filter(t=>t!==e);if(n.length>0){this.serverRestartRecoveryState={...t,docNames:n};return}if(t.failedDocNames.length>0){this.serverRestartRecoveryState={kind:`failed`,reason:t.clearFailureReason??`clear-data-failed`,docNames:t.failedDocNames,failedDocNames:t.failedDocNames,startedAt:t.startedAt},this.clearRecoveryMismatchStaleClaimIfTerminal();return}this.serverRestartRecoveryState=zM,this.clearRecoveryMismatchStaleClaimIfTerminal()}setObservedBranch(e){this.persistObservedBranch(e)}compareAndUpdateObservedBranch(e){let t=this.getOrInitObservedBranch();return this.persistObservedBranch(e),t!==null&&t!==e}onBranchMismatch=null;branchMismatchInFlight=null;mismatchInFlight=null;setOnBranchMismatch(e){if(e===null){this.onBranchMismatch=null;return}this.onBranchMismatch=()=>{if(this.branchMismatchInFlight!==null)return;let t=Promise.resolve().then(e).finally(()=>{this.branchMismatchInFlight===t&&(this.branchMismatchInFlight=null)});this.branchMismatchInFlight=t}}onRenameRedirect=null;onDocDeleted=null;setOnRenameRedirect(e){this.onRenameRedirect=e}setOnDocDeleted(e){this.onDocDeleted=e}setOnChange(e){this.onChange=e}notify(){this.onChange?.()}evictListeners=new Set;onEvict(e){return this.evictListeners.add(e),()=>{this.evictListeners.delete(e)}}fireEvict(e){for(let t of this.evictListeners)try{t(e)}catch(t){console.warn(`[ProviderPool] evict listener threw for ${e}:`,t)}}touch(e){let t=this.lruOrder.indexOf(e);t!==-1&&this.lruOrder.splice(t,1),this.lruOrder.push(e)}open(e){if(hM(e))return null;let t=this.entries.get(e);if(t){let n=t.lastAccessedAt;return t.lastAccessedAt=Date.now(),this.touch(e),this.notify(),X(`ok/pool/open`,{docName:e,hit:!0,lastAccessedAt:n,poolEventId:t.poolEventId}),X.count(`ok/pool/open`,{hit:!0}),t}let n=Date.now();this.entries.size>=this.maxSize&&this.evictLru();let r=this.cachedServerInstanceId,i=this.getRecordedLineageEpoch(e),a=da(this.tabIdentity,r,this.getOrInitObservedBranch(),r!==null&&r.length>0?i:null),o=new Ki({url:vh(this.wsUrl),name:e,forceSyncInterval:YM,token:a}),s=this.cachedServerInstanceId;this.clearFailures.has(e)&&this.runCloseAndClearPersistence(e);let c=this.pendingClears.get(e),l=s!==null&&s.length>0&&c===void 0&&i!==null?this.buildPersistence(s,e,o.document):null,u=crypto.randomUUID(),d={kind:`active`,provider:o,persistence:l,lastServerSyncedSV:null,lastDiskAckedSV:null,observerCleanup:null,observerFireCounterCleanup:BM(o.document,e),syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),poolEventId:u,hasSynced:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1,serverDrivenCloseReauthInFlight:!1,persistenceAttachOwned:!1,lineageEpochRecordAtOpen:i};if(X(`ok/pool/open`,{docName:e,hit:!1,poolEventId:u}),X.count(`ok/pool/open`,{hit:!1}),o.on(`status`,({status:t})=>{d.kind!==`active`||this.entries.get(e)!==d||t===`disconnected`&&(d.syncState=`disconnected`,this.notify())}),o.on(`synced`,()=>{if(d.kind!==`active`||this.entries.get(e)!==d)return;d.syncState=`synced`,d.hasSynced=!0,d.lastServerSyncedSV=hh(o.document);let t=o.document.getMap(`lifecycle`).get(k);if(typeof t==`string`&&t.length>0&&this.recordLineageEpoch(e,t),d.pendingRecycleTimer&&=(clearTimeout(d.pendingRecycleTimer),null),this.markServerRestartRecoverySynced(e),this.notify(),!d.observerCleanup)try{let t=o.document,n=new ct({extensions:mM});d.observerCleanup=Sn({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:n,schema:HM(),onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),d.bridgeSetupFailed=!0,LM(e,new bM(e,t))}}),o.on(`disconnect`,()=>{d.kind!==`active`||this.entries.get(e)!==d||(d.syncState=`disconnected`,this.notify(),d.hasSynced&&o.unsyncedChanges===0&&!d.pendingRecycleTimer&&(d.pendingRecycleTimer=setTimeout(()=>{d.kind===`active`&&(d.pendingRecycleTimer=null,this.entries.get(e)===d&&this.recycleDisconnectedEntry(e))},this.recycleDebounceMs)))}),o.on(`authenticationFailed`,({reason:t})=>{let n=[`server-instance-mismatch`,`branch-mismatch`,`rename-redirect`,`doc-deleted`,`doc-lineage-mismatch`],i=t.indexOf(`:`),a=i===-1?t:t.slice(0,i);if(!n.includes(a)){console.warn(JSON.stringify({event:`ok-auth-failed-unknown-reason`,reason:t}));return}let o=i===-1?``:t.slice(i+1),s=o.length>0?o:void 0,c=a;if(c===`server-instance-mismatch`){if(r===null||this.cachedServerInstanceId!==r)return;let e=r;this.cachedServerInstanceId=null,this.handleServerInstanceMismatch(e);return}if(c===`branch-mismatch`){this.onBranchMismatch?.();return}if(c===`rename-redirect`){if(s===void 0||s.length===0){console.warn(JSON.stringify({event:`rename-redirect-missing-payload`,fromDocName:e}));return}let t=e,n=s;this.deleteLineageEpochRecord(t);let r=this.entries.get(t),i=r!==void 0&&r.kind===`active`;this.onRenameRedirect?.({fromDocName:t,toDocName:n,hadOpenProvider:i});return}if(c===`doc-deleted`){this.deleteLineageEpochRecord(e);let t=this.entries.get(e),n=t!==void 0&&t.kind===`active`;this.onDocDeleted?.({docName:e,hadOpenProvider:n});return}if(c===`doc-lineage-mismatch`){if(d.kind!==`active`||this.entries.get(e)!==d)return;this.deleteLineageEpochRecord(e),this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(e),via:`auth-rejection`,staleEpoch:d.lineageEpochRecordAtOpen??``});let t=this.activeDocName===e;this.runCloseAndClearPersistence(e),this.open(e)!==null&&t&&this.setActive(e);return}}),o.on(`close`,({event:t})=>{if(d.kind!==`active`||this.entries.get(e)!==d||d.serverDrivenCloseReauthInFlight)return;d.serverDrivenCloseReauthInFlight=!0,o.sendToken().catch(t=>{console.warn(JSON.stringify({event:`ok-provider-server-driven-close-reauth-failed`,docName:e,message:t instanceof Error?t.message:String(t)}))}).finally(()=>{d.kind===`active`&&this.entries.get(e)===d&&(d.serverDrivenCloseReauthInFlight=!1)});let n=t?.reason??`<unknown>`;console.info(JSON.stringify({event:`ok-provider-server-driven-close-reauth`,docName:e,reason:n}))}),this.bufferedUpdates.get(e)!==void 0){let t=this.recoveryMismatchStaleClaim,n=()=>{if(o.off(`synced`,n),d.kind!==`active`||this.entries.get(e)!==d)return;let r=this.bufferedUpdates.get(e);if(r!==void 0){this.bufferedUpdates.delete(e);try{Gi(o.document,r,RM)}catch(n){let i=n instanceof Error?n.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-failed`,...this.recoveryTelemetryBase(e,t),replayByteLength:r.byteLength,errorName:i,errorMessage:n instanceof Error?n.message:String(n)})}}};o.on(`synced`,n)}if(this._entries.set(e,d),this.touch(e),this.notify(),l===null&&s!==null&&s.length>0&&c===void 0&&this.validateStoredStateThenAttach(d,s),c!==void 0&&s!==null&&s.length>0){let t=s;c.then(()=>{this.attachDeferredPersistenceForEntry(d,t)},t=>{console.warn(JSON.stringify({event:`ok-pool-deferred-persistence-attach-skipped`,docName:e,reason:`pending-clear-failed`,message:t instanceof Error?t.message:String(t)}))})}let f=Pf(e);return f!==void 0&&Wf(f,`ok.provider-pool.open`,{"doc.name":e},n,Date.now()),d}attachDeferredPersistenceForEntry(e,t){let n=this._entries.get(e.docName);n!==e||n.kind!==`active`||n.persistence!==null||this.validateStoredStateThenAttach(n,t)}handleServerInstanceMismatch(e){this.recoveryMismatchStaleClaim=e.length>0?e:void 0;let t=Array.from(this.entries.entries()),n=Date.now(),r=this.activeDocName,i=r!==null&&t.some(([e,t])=>e===r&&t.kind===`active`)?[r]:[],a=r??t.find(([,e])=>e.kind===`active`)?.[0]??``;a.length>0&&this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-epoch-mismatch`,...this.recoveryTelemetryBase(a)}),this.beginServerRestartRecovery(i,n);for(let[e,n]of t)n.kind===`active`&&!i.includes(e)&&IM(e);for(let[e,n]of t){if(n.kind!==`active`)continue;let t=n.lastDiskAckedSV??n.lastServerSyncedSV;if(t===null){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-skipped-no-baseline`,...this.recoveryTelemetryBase(e),reason:`no-disk-ack-or-server-sync-vector`});continue}let r=gh(n.provider.document,t);if(r.byteLength>XM){X(`ok/pool/buffer-overflow`,{docName:e,bytes:r.byteLength});continue}r.byteLength>0&&this.bufferedUpdates.set(e,r)}let o=[];for(let[e,n]of t)n.kind===`active`&&n.persistence!==null&&o.push({docName:e,promise:this.withClearDataTimeout(e,n.persistence.clearData())});let s=Promise.allSettled(o.map(e=>e.promise)).then(e=>{let t=[],i=[],a=!1;e.forEach((e,n)=>{let r=o[n];if(!r)return;let s=r.docName;if(e.status===`rejected`){t.push(s);let n=e.reason instanceof GM;if(n&&(a=!0),n)this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`timeout`});else{let t=e.reason instanceof Error?e.reason.name:`unknown`;this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`rejected`,errorName:t,errorMessage:e.reason instanceof Error?e.reason.message:String(e.reason)})}}else i.push(s)});let s=i.filter(e=>e===r);if(t.length>0){let e=a?`clear-data-timeout`:`clear-data-failed`;console.warn(JSON.stringify({event:`ok-mismatch-recycle-partial-clears-failed`,failedDocs:t,clearedDocs:i})),this.enterServerRestartReconnect(s,t,n,e);for(let e of i)this.recycleDisconnectedEntry(e);return}this.enterServerRestartReconnect(s,[],n,`clear-data-failed`),this.recycleAllEntries()}).finally(()=>{this.mismatchInFlight===s&&(this.mismatchInFlight=null)});this.mismatchInFlight=s}awaitMismatchSettled(){return this.mismatchInFlight??Promise.resolve()}recycleAllEntries(){let e=Array.from(this.entries.keys());for(let t of e)this.recycleDisconnectedEntry(t)}prewarm(e){if(hM(e))return null;let t=this.entries.get(e);if(t)return t;let n=this.open(e);if(!n)return null;let r=this.lruOrder.indexOf(e);return r!==-1&&(this.lruOrder.splice(r,1),this.lruOrder.unshift(e)),n}close(e){let t=this.entries.get(e);t&&(this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),this.bufferedUpdates.delete(e),this.activeDocName===e&&(this.activeDocName=null),this.notify())}async closeAndClearPersistence(e){try{await this.runCloseAndClearPersistence(e)}catch{}}runCloseAndClearPersistence(e){let t=this.pendingClears.get(e);if(t!==void 0)return t;let n=()=>{},r=()=>{},i=new Promise((e,t)=>{n=e,r=t});this.pendingClears.set(e,i);let a=()=>{this.pendingClears.get(e)===i&&this.pendingClears.delete(e)};return i.then(a,a),this.executeCloseAndClearPersistence(e).then(n,r),i}async executeCloseAndClearPersistence(e){this.clearFailures.delete(e);let t=this.entries.get(e);if(t?.kind===`active`&&t.persistence!==null){let n=t.persistence;try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before clearData threw for ${e}:`,t)}try{await this.withClearDataTimeout(e,n.clearData())}catch(t){throw console.warn(`[ProviderPool] clearData on rename failed for ${e}:`,t),this.clearFailures.add(e),t}return}if(t)try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before IDB-by-name delete threw for ${e}:`,t)}let n=this.normalizedObservedBranch(),r=this.cachedServerInstanceId;if(r===null)return;let i=`ok-ydoc:${n}:${r}:${e}`;try{await this.withClearDataTimeout(e,new Promise((e,t)=>{let n=indexedDB.deleteDatabase(i);n.onsuccess=()=>e(),n.onerror=()=>t(n.error),n.onblocked=()=>{console.warn(`[ProviderPool] IDB delete blocked for ${i}`)}}))}catch(t){throw console.warn(`[ProviderPool] IDB delete on rename failed for ${i}:`,t),this.clearFailures.add(e),t}}clearBufferedUpdates(){this.bufferedUpdates.clear()}__test_seedBufferedUpdate(e,t){this.bufferedUpdates.set(e,t)}__test_bufferedUpdatesSize(){return this.bufferedUpdates.size}__test_hasBufferedUpdate(e){return this.bufferedUpdates.has(e)}__test_getBufferedUpdate(e){return this.bufferedUpdates.get(e)}setActive(e){let t=this.entries.get(e);if(!t)throw Error(`[ProviderPool] Cannot setActive — "${e}" is not open`);t.lastAccessedAt=Date.now(),this.touch(e),this.activeDocName=e,this.notify()}clearActive(){this.activeDocName!==null&&(this.activeDocName=null,this.notify())}getActive(){return this.activeDocName?this.entries.get(this.activeDocName)??null:null}getActiveDocName(){return this.activeDocName}has(e){return this.entries.has(e)}peek(e){return this.entries.get(e)??null}recycle(e){this.recycleDisconnectedEntry(e)}dispose(){for(let e of this._entries.values())this.destroyEntry(e);this._entries.clear(),this.lruOrder=[],this.activeDocName=null,this.onChange=null,this.bufferedUpdates.clear(),this.pendingClears.clear(),this.clearFailures.clear(),this.docLineageEpochs.clear(),this.docLineageEpochsEnvelopeConsumed=!1,this.onBranchMismatch=null,this.branchMismatchInFlight=null,this.onRenameRedirect=null,this.onDocDeleted=null,this.evictListeners.clear(),this.serverRestartRecoveryState=zM,this.cachedServerInstanceId=null,this.pendingServerInstanceKnown=null,this.tabIdentity=null,this.recoveryMismatchStaleClaim=void 0}evictLru(){for(let e of this.lruOrder)if(e!==this.activeDocName){X(`ok/pool/evict-lru`,{docName:e}),this.close(e);return}}destroyEntry(e){if(e.kind===`tearing-down`)return;let t=e.observerCleanup,n=e.observerFireCounterCleanup,r=e.persistence,i=e.pendingRecycleTimer,a=e.docName,o=e;o.kind=`tearing-down`,o.persistence=null,o.observerCleanup=null,o.observerFireCounterCleanup=null,o.pendingRecycleTimer=null,o.serverDrivenCloseReauthInFlight=!1,i&&clearTimeout(i),IM(a),this.fireEvict(a);try{t?.()}catch(e){console.warn(`[ProviderPool] observer cleanup threw for ${a}:`,e)}try{n?.()}catch(e){console.warn(`[ProviderPool] observer-fire-counter cleanup threw for ${a}:`,e)}r!==null&&r.destroy().catch(e=>{console.warn(`[ProviderPool] persistence destroy failed for ${a}:`,e)});try{o.provider.destroy()}catch(e){console.warn(`[ProviderPool] Provider destroy failed for ${a}:`,e)}}recycleDisconnectedEntry(e){let t=this.entries.get(e);if(!t||t.kind!==`active`)return;let n=this.activeDocName===e;if(X(`ok/pool/recycle-disconnected`,{docName:e,wasActive:n}),this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),n){this.open(e)&&this.setActive(e);return}this.notify()}},$M=crypto.randomUUID(),eN=!1;function tN(e){eN||(eN=!0,console.warn(`[principal-fetch] failed to resolve principal — falling back to random identity.`,e))}var nN=(0,Q.createContext)(null),rN=/\.(md|mdx)$/i,iN=null;function aN(e){return iN||(iN=new QM(ZM,e),Wp(iN)),iN}var oN={activeDocName:null,activeProvider:null,syncState:`connecting`,serverRestartRecovery:{kind:`idle`},poolEntries:[]};function sN(){if(typeof window>`u`)return null;let e=window.okDesktop;return e?.config.mode===`editor`?e:null}function cN(){return typeof window>`u`||window.okDesktop?.config.mode===`editor`?null:Lm(window.location.origin)}function lN(){if(typeof window>`u`)return Fm(null,ZM);let e=cN();return e?Rm(window.localStorage===void 0?null:window.localStorage,e,ZM):Fm(null,ZM)}function uN(){return lN().openTabs}function dN(){return lN().pinnedTabIds}function fN(){if(typeof window>`u`||window.location.hash.length>0)return null;let e=lN();return e.activeTabId??(e.activeDocName?cm(e.activeDocName):null)??e.openTabs[0]??null}function pN(e){let t=pm(e);switch(t.kind){case`doc`:return xi(t.docName);case`folder`:return mi(t.folderPath);case`asset`:return yi(t.assetPath);case`skill-file`:return _i({scope:t.scope,name:t.name,path:t.path})}}function mN(e){let t=vi(e);if(t)return um(t);let n=hi(e);if(n)return om(n);let r=bi(e);if(!r)return null;let i=r.trim();if(/\/+$/.test(i)){let e=i.replace(/\/+$/g,``);return e?lm(e):null}return cm(r)}function hN(e,t,n){return!e||!n||t!==xi(e)||rN.test(e)||!rN.test(n)?!1:n.replace(rN,``)===e}function gN(e){return{kind:`asset`,target:e,assetPath:e,mediaKind:pe(e.split(`.`).pop()??``)}}function _N(e,t){return e?fm(e):t?cm(t):null}function vN(e,t,n){return e.some(e=>!n.has(e)&&mm(e)===t)}function yN(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function bN(e){switch(e.kind){case`doc`:return`doc:${e.docName}`;case`folder-index`:return`folder-index:${e.docName}:${e.folderPath}:${e.noteKind}`;case`folder`:return`folder:${e.folderPath}`;case`asset`:return`asset:${e.assetPath}:${e.mediaKind??``}`;case`skill-file`:return`skill-file:${e.scope}:${e.name}:${e.path}`;case`large-file`:return`large-file:${e.docName}:${e.size}:${e.limit}`;case`missing`:return`missing:${e.target}`}}function xN(e,t){return e===t?!0:!e||!t?!1:bN(e)===bN(t)}function SN(e){let t=e.getActive(),n=[];for(let t of e.entries.values())n.push({docName:t.docName,provider:t.provider,lastAccessedAt:t.lastAccessedAt,poolEventId:t.poolEventId});return n.sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt),{activeDocName:e.getActiveDocName(),activeProvider:t?.provider??null,syncState:t?.syncState??`connecting`,serverRestartRecovery:e.getServerRestartRecoveryState(),poolEntries:n}}function CN(e){let t=(0,$.c)(183),{children:n}=e,[r,i]=(0,Q.useState)(oN),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(fN),[l,u]=(0,Q.useState)(uN),[d,f]=(0,Q.useState)(dN),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[0]=p):p=t[0];let[m,h]=(0,Q.useState)(p),[g,_]=(0,Q.useState)(l),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(s),C=(0,Q.useRef)(l),w=(0,Q.useRef)(d),T=(0,Q.useRef)(v),E=(0,Q.useRef)(m),D=(0,Q.useRef)(g),O=(0,Q.useRef)(1),k;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(k=[],t[1]=k):k=t[1];let A=(0,Q.useRef)(k),j=(0,Q.useRef)(!1),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),[R,ee]=(0,Q.useState)(`doc`),[z,te]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(0),{collabUrl:B,terminal:V,lastError:H,retry:U}=sd(),W;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(W=function(e){S.current=e,c(e)},t[2]=W):W=t[2];let G=W,ie;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(ie=function(e){T.current=e,y(e)},t[3]=ie):ie=t[3];let K=ie,ae;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ae=function(e){D.current=e,_(t=>yN(t,e)?t:e)},t[4]=ae):ae=t[4];let oe=ae,q;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(q=function(e){w.current=e,f(t=>yN(t,e)?t:e)},t[5]=q):q=t[5];let se=q,ce;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(ce=function(e,t){let n=gm(t,e);C.current=e,w.current=n,u(t=>yN(t,e)?t:e),f(e=>yN(e,n)?e:n),oe(Dm(D.current,e,E.current))},t[6]=ce):ce=t[6];let J=ce,le;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(le=function(e){J(e,w.current)},t[7]=le):le=t[7];let ue=le,Y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(Y=function(e){ue(e(C.current))},t[8]=Y):Y=t[8];let de=Y,fe;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(fe=function(e){E.current=e,h(t=>yN(t,e)?t:e),oe(Dm(D.current,C.current,e))},t[9]=fe):fe=t[9];let pe=fe,me;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(me=function(e){let t=T.current;if(!t)return;let n=E.current.filter(e=>e!==t);E.current=n,h(e=>yN(e,n)?e:n),K(null);let r=[],i=new Set;for(let n of D.current){let a=n===t?e:n;!a||i.has(a)||(i.add(a),r.push(a))}oe(Dm(r,C.current,n))},t[10]=me):me=t[10];let he=me,ge,_e;t[11]===s?(ge=t[12],_e=t[13]):(ge=()=>{S.current=s},_e=[s],t[11]=s,t[12]=ge,t[13]=_e),(0,Q.useEffect)(ge,_e);let ve,ye;t[14]===l?(ve=t[15],ye=t[16]):(ve=()=>{C.current=l},ye=[l],t[14]=l,t[15]=ve,t[16]=ye),(0,Q.useEffect)(ve,ye);let be,xe;t[17]===d?(be=t[18],xe=t[19]):(be=()=>{w.current=d},xe=[d],t[17]=d,t[18]=be,t[19]=xe),(0,Q.useEffect)(be,xe);let Se,Ce;t[20]===v?(Se=t[21],Ce=t[22]):(Se=()=>{T.current=v},Ce=[v],t[20]=v,t[21]=Se,t[22]=Ce),(0,Q.useEffect)(Se,Ce);let we,Te;t[23]===m?(we=t[24],Te=t[25]):(we=()=>{E.current=m},Te=[m],t[23]=m,t[24]=we,t[25]=Te),(0,Q.useEffect)(we,Te);let Ee,De;t[26]===g?(Ee=t[27],De=t[28]):(Ee=()=>{D.current=g},De=[g],t[26]=g,t[27]=Ee,t[28]=De),(0,Q.useEffect)(Ee,De);let Oe=v!==null,ke,Ae;t[29]!==B||t[30]!==M||t[31]!==b?(ke=()=>{if(B===null||b||!M)return;let e=!1,t=sN(),n=cN(),r=typeof localStorage<`u`?localStorage:null;return(t?t.project.getSessionState():Promise.resolve(n?Rm(r,n,ZM):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null})).then(t=>{if(e)return;let n=Fm(t,ZM);if(j.current)return;let r=aN(B);for(let e of n.openTabs){let t=mm(e);t&&r.open(t)}let i=[...n.pinnedTabIds,...w.current],a=n.openTabs;for(let e of C.current)a=Sm(a,e,ZM,i);let o=gm(i,a);C.current=a,w.current=o,u(e=>yN(e,a)?e:a),f(e=>yN(e,o)?e:o);let s=Dm(n.openTabs.length>0?a:D.current,a,E.current);D.current=s,_(e=>yN(e,s)?e:s);let l=bi(window.location.hash),d=n.activeTabId??(n.activeDocName?cm(n.activeDocName):null)??n.openTabs[0]??null,p=d?pN(d):null,m=d?mm(d):null;if((l===null&&window.location.hash.length===0||p!==null&&p===window.location.hash||hN(l,window.location.hash,m))&&d){S.current=d,c(d);let e=pN(d);window.location.hash!==e&&(window.location.hash=e)}}).catch(NN).finally(()=>{e||x(!0)}),()=>{e=!0}},Ae=[B,M,b],t[29]=B,t[30]=M,t[31]=b,t[32]=ke,t[33]=Ae):(ke=t[32],Ae=t[33]),(0,Q.useEffect)(ke,Ae);let je,Me;t[34]!==s||t[35]!==a||t[36]!==l||t[37]!==d||t[38]!==r.activeDocName||t[39]!==b?(je=()=>{if(!b)return;let e=Im(l,s??_N(a,r.activeDocName),d),t=sN();if(t){t.project.setSessionState(e).catch(MN);return}let n=cN();n&&zm(typeof localStorage<`u`?localStorage:null,n,e)},Me=[s,a,l,d,r.activeDocName,b],t[34]=s,t[35]=a,t[36]=l,t[37]=d,t[38]=r.activeDocName,t[39]=b,t[40]=je,t[41]=Me):(je=t[40],Me=t[41]),(0,Q.useEffect)(je,Me);let Ne;t[42]===b?Ne=t[43]:(Ne=function(){b||(j.current=!0)},t[42]=b,t[43]=Ne);let Pe=Ne,Fe,Ie;t[44]===B?(Fe=t[45],Ie=t[46]):(Fe=()=>{if(B===null)return;let e=!1;N(!1);let t=aN(B);i(SN(t));let n=function(e,t){let n=gm(t,e);C.current=e,w.current=n,u(t=>yN(t,e)?t:e),f(e=>yN(e,n)?e:n);let r=Dm(D.current,e,E.current);D.current=r,_(e=>yN(e,r)?e:r)};return t.setOnBranchMismatch(()=>Wu(t)),t.setOnRenameRedirect(e=>{let{fromDocName:r,toDocName:i,hadOpenProvider:a}=e;(async()=>{let e,s=t.getActiveDocName()===r;wp([{fromDocName:r,toDocName:i}]);try{await Promise.all([t.closeAndClearPersistence(r),t.closeAndClearPersistence(i)]),s&&(t.open(i),t.setActive(i));let e=km(C.current,[{fromDocName:r,toDocName:i}],ZM,[],w.current),a=gm(km(w.current,[{fromDocName:r,toDocName:i}],2**53-1),e);D.current=Am(D.current,[{fromDocName:r,toDocName:i}]),n(e,a),o(e=>e&&(ci(e)===r?{kind:`doc`,target:i,docName:i}:e)),s&&(window.location.hash=xi(i))}catch(t){let n=t;e=n,console.warn(JSON.stringify({event:`removal-cleanup-error`,kind:`renamed`,fromDocName:r,toDocName:i,message:String(n instanceof Error?n.message:n)}))}console.info(JSON.stringify({event:`removal.cleanup`,kind:`renamed`,fromDocName:r,toDocName:i,hadOpenProvider:a,hadStaleIdb:!a,source:`auth-rejection`,errored:e!==void 0}))})()}),t.setOnDocDeleted(e=>{let{docName:r,hadOpenProvider:i}=e;(async()=>{let e;try{await t.closeAndClearPersistence(r),n(Em(C.current,r),w.current),o(e=>e&&(ci(e)===r?null:e)),t.getActiveDocName()===r&&(window.location.hash=``)}catch(t){let n=t;e=n,console.warn(JSON.stringify({event:`removal-cleanup-error`,kind:`deleted`,docName:r,message:String(n instanceof Error?n.message:n)}))}console.info(JSON.stringify({event:`removal.cleanup`,kind:`deleted`,fromDocName:r,hadOpenProvider:i,hadStaleIdb:!i,source:`auth-rejection`,errored:e!==void 0}))})()}),t.setOnChange(()=>i(SN(t))),fetch(`/api/principal`).then(jN).then(n=>{if(e)return;let r=ft.safeParse(n);r.success?(t.setTabIdentity({principalId:r.data.id,tabSessionId:$M}),F(r.data)):tN(r.error)}).catch(t=>{e||tN(t)}).finally(()=>{e||N(!0)}),Wu(t),()=>{e=!0,t.setOnChange(null),t.setOnRenameRedirect(null),t.setOnDocDeleted(null)}},Ie=[B],t[44]=B,t[45]=Fe,t[46]=Ie),(0,Q.useEffect)(Fe,Ie);let Le;t[47]===B?Le=t[48]:(Le=e=>{if(X(`ok/nav/open-document`,{docName:e,transition:!1}),B===null)return;let t=aN(B),n=t.open(e);if(!n)return;Bu(e,n.poolEventId);let r=cm(e);de(e=>Sm(e,r,ZM,w.current)),he(r),G(r),t.setActive(e),o({kind:`doc`,target:e,docName:e})},t[47]=B,t[48]=Le);let Re=Le,ze;t[49]===Re?ze=t[50]:(ze=e=>{X(`ok/nav/open-document`,{docName:e,transition:!1}),Re(e)},t[49]=Re,t[50]=ze);let Be=ze,Ve;t[51]!==a||t[52]!==B||t[53]!==Pe||t[54]!==r.activeDocName?(Ve=(e,t)=>{let n=t===void 0?{}:t;if(B===null)return;n.tabBehavior===`replace-active`&&Pe();let i=aN(B),s=ci(e),c=T.current,l=c!==null&&n.tabBehavior===`replace-active`,u=c?null:S.current??_N(a,r.activeDocName),d=u!==null&&C.current.includes(u),f=u!==null&&w.current.includes(u),p=n.tabBehavior===`replace-active`&&f||n.tabBehavior===`replace-active`&&!l&&!d?`append`:n.tabBehavior??`append`;if(s&&e.kind!==`large-file`){let e=i.open(s);if(!e)return;Bu(s,e.poolEventId);let t=wm(C.current,s,{behavior:p,currentTabId:u,limit:ZM,pinnedTabIds:w.current});ue(t.tabs),he(t.activeTabId),G(t.activeTabId),i.setActive(s)}else{i.clearActive();let t=fm(e);if(t){let e=Tm(C.current,t,{behavior:p,currentTabId:u,limit:ZM,pinnedTabIds:w.current});ue(e.tabs),G(e.activeTabId),he(e.activeTabId)}else he(t)}o(t=>xN(t,e)?t:e)},t[51]=a,t[52]=B,t[53]=Pe,t[54]=r.activeDocName,t[55]=Ve):Ve=t[55];let He=Ve,Ue;t[56]===He?Ue=t[57]:(Ue=(e,t)=>{He(e,t===void 0?{}:t)},t[56]=He,t[57]=Ue);let We=Ue,Ge;t[58]===He?Ge=t[59]:(Ge=(e,t)=>{let n=t===void 0?{}:t;X(`ok/nav/open-target`,{docName:ci(e),kind:e.kind,transition:!1}),He(e,n)},t[58]=He,t[59]=Ge);let Ke=Ge,qe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(qe=function(e){e.length!==0&&(A.current=[...A.current,...e].slice(-50))},t[60]=qe):qe=t[60];let Je=qe,Ye;t[61]===B?Ye=t[62]:(Ye=e=>{let t=pm(e);if(K(null),G(e),t.kind===`doc`){if(B!==null){let e=aN(B);if(!e.open(t.docName))return;e.setActive(t.docName)}o({kind:`doc`,target:t.docName,docName:t.docName});let e=xi(t.docName);window.location.hash!==e&&(window.location.hash=e);return}if(B!==null&&aN(B).clearActive(),t.kind===`asset`){o(gN(t.assetPath));let e=yi(t.assetPath);window.location.hash!==e&&(window.location.hash=e);return}if(t.kind===`skill-file`){o({kind:`skill-file`,target:`${t.scope}/${t.name}/${t.path}`,scope:t.scope,name:t.name,path:t.path});let e=_i({scope:t.scope,name:t.name,path:t.path});window.location.hash!==e&&(window.location.hash=e);return}o({kind:`folder`,target:t.folderPath,folderPath:t.folderPath});let n=mi(t.folderPath);window.location.hash!==n&&(window.location.hash=n)},t[61]=B,t[62]=Ye);let Xe=Ye,Ze;t[63]===B?Ze=t[64]:(Ze=()=>{let e=`new-tab:${O.current}`;O.current+=1,pe([...E.current,e]),K(e),B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash!==``&&(window.location.hash=``)},t[63]=B,t[64]=Ze);let Qe=Ze,$e;t[65]!==s||t[66]!==a||t[67]!==B||t[68]!==Pe||t[69]!==r.activeDocName?($e=e=>{if(w.current.includes(e)||!C.current.includes(e))return;Pe();let t=null,n=mm(e);if(Je([e]),B!==null){let t=aN(B);n&&!vN(C.current,n,new Set([e]))&&t.close(n)}let i=s??_N(a,r.activeDocName);if(de(n=>(t=Nm(n,i,e),Em(n,e))),i===e){if(t){G(t),window.location.hash=pN(t);return}B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash=``}},t[65]=s,t[66]=a,t[67]=B,t[68]=Pe,t[69]=r.activeDocName,t[70]=$e):$e=t[70];let et=$e,tt;t[71]!==B||t[72]!==Pe?(tt=e=>{Pe();let t=E.current;if(!t.includes(e))return;let n=t.filter(t=>t!==e);if(pe(n),T.current!==e)return;let r=t.indexOf(e),i=n[r]??n[r-1]??null;if(i){K(i),B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash!==``&&(window.location.hash=``);return}K(null);let a=C.current[C.current.length-1]??null;if(a){G(a),window.location.hash=pN(a);return}B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash=``},t[71]=B,t[72]=Pe,t[73]=tt):tt=t[73];let nt=tt,rt;t[74]!==nt||t[75]!==et?(rt=()=>{let e=T.current;if(e)return nt(e),!0;let t=new Set(w.current),n=new Set(C.current.filter(e=>!t.has(e))),r=(S.current&&n.has(S.current)?S.current:null)??D.current.find(e=>n.has(e));if(r)return et(r),!0;let i=new Set(E.current),a=D.current.find(e=>i.has(e));return a?(nt(a),!0):!1},t[74]=nt,t[75]=et,t[76]=rt):rt=t[76];let it=rt,at,ot;t[77]===it?(at=t[78],ot=t[79]):(at=()=>{let e=sN();if(e)return e.onMenuAction(e=>{e===`close-active-tab-or-window`&&(it()||window.close())})},ot=[it],t[77]=it,t[78]=at,t[79]=ot),(0,Q.useEffect)(at,ot);let st;t[80]===B?st=t[81]:(st=()=>{if(B===null){o(AN),S.current=null,c(kN);return}let e=aN(B);e.getActiveDocName()!==null&&e.clearActive(),o(ON),S.current=null,c(DN)},t[80]=B,t[81]=st);let ct;t[82]!==B||t[83]!==Pe?(ct=e=>{B!==null&&(Pe(),aN(B).close(e),de(t=>Em(t,cm(e))),c(t=>{let n=t&&mm(t)===e?null:t;return S.current=n,n}),o(t=>t&&(ci(t)===e?null:t)))},t[82]=B,t[83]=Pe,t[84]=ct):ct=t[84];let lt;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(lt=e=>{let t=vm(w.current,e,C.current);yN(w.current,t)||se(t)},t[85]=lt):lt=t[85];let ut;t[86]===Pe?ut=t[87]:(ut=e=>{let t=ym(w.current,e);yN(w.current,t)||(Pe(),se(t))},t[86]=Pe,t[87]=ut);let dt;t[88]===Xe?dt=t[89]:(dt=e=>{Xe(e)},t[88]=Xe,t[89]=dt);let pt;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(pt=(e,t)=>{let n=new Set(C.current),r=new Set(E.current),i=new Set,a=[],o=[],s=[];for(let t of e)i.has(t)||(n.has(t)?(a.push(t),s.push(t),i.add(t)):r.has(t)&&(o.push(t),s.push(t),i.add(t)));for(let e of C.current)i.has(e)||(a.push(e),s.push(e),i.add(e));for(let e of E.current)i.has(e)||(o.push(e),s.push(e),i.add(e));let c=yN(C.current,a),l=yN(E.current,o),u=yN(D.current,s);c&&l&&u||(D.current=s,l||(E.current=o,h(e=>yN(e,o)?e:o)),J(a,xm(a,w.current,t)))},t[90]=pt):pt=t[90];let mt;t[91]===B?mt=t[92]:(mt=e=>{E.current.includes(e)&&(B!==null&&aN(B).clearActive(),o(null),G(null),K(e),window.location.hash!==``&&(window.location.hash=``))},t[91]=B,t[92]=mt);let ht;t[93]===Xe?ht=t[94]:(ht=()=>{let e=[...A.current];for(;e.length>0;){let t=e.pop();if(!t)continue;if(C.current.includes(t)){A.current=e;continue}let n=Sm(C.current,t,ZM,w.current);if(!n.includes(t))return;A.current=e,ue(n),Xe(t);return}A.current=[]},t[93]=Xe,t[94]=ht);let gt;t[95]!==s||t[96]!==a||t[97]!==B||t[98]!==Pe||t[99]!==r.activeDocName?(gt=(e,t)=>{let n=t===void 0?{}:t,i=e.filter(EN),c=new Set(n.force?i:bm(i,w.current));if(c.size===0)return;if(Pe(),n.force||Je(C.current.filter(e=>c.has(e))),B!==null){let e=aN(B),t=new Map;for(let e of c){let n=mm(e);if(!n)continue;let r=t.get(n)??new Set;r.add(e),t.set(n,r)}for(let[n,r]of t)vN(C.current,n,r)||e.close(n)}let l=null,u=s??_N(a,r.activeDocName);if(de(e=>(l=Pm(e,u,c),e.filter(e=>!c.has(e)))),!u||!c.has(u)){u||o(e=>{if(!e)return e;let t=fm(e);return t&&c.has(t)?null:e});return}if(l){G(l),window.location.hash=pN(l);return}B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash=``},t[95]=s,t[96]=a,t[97]=B,t[98]=Pe,t[99]=r.activeDocName,t[100]=gt):gt=t[100];let _t;t[101]!==s||t[102]!==a||t[103]!==B||t[104]!==Pe||t[105]!==l||t[106]!==r.activeDocName?(_t=e=>{let{pages:t,folderPaths:n,assetPaths:i,filePaths:c}=e,u=Om(l,{pages:t,folderPaths:n,assetPaths:i,filePaths:c,keepMissingDocName:a?.kind===`missing`?a.target:null,keepHashDocName:typeof window<`u`?bi(window.location.hash):null});if(u.length===l.length)return;let d=new Set(u),f=l.filter(e=>!d.has(e)),p=new Set(f);if(Pe(),B!==null){let e=aN(B);for(let t of f){let n=mm(t);n&&e.close(n)}}ue(u);let m=typeof window<`u`?mN(window.location.hash):null,h=s??_N(a,r.activeDocName),g=m&&p.has(m)?m:h&&p.has(h)?h:null;if(!g){o(e=>{if(!e)return e;let t=fm(e);return t&&p.has(t)?null:e});return}let _=Pm(l,g,f);if(_){G(_),window.location.hash=pN(_);return}B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash=``},t[101]=s,t[102]=a,t[103]=B,t[104]=Pe,t[105]=l,t[106]=r.activeDocName,t[107]=_t):_t=t[107];let vt;t[108]!==B||t[109]!==Pe?(vt=(e,t,n)=>{let r=t===void 0?[]:t,i=n===void 0?[]:n;Pe();let a=km(C.current,e,ZM,r,w.current,i),o=gm(km(w.current,e,2**53-1,r,[],i),a);if(B!==null){let e=aN(B);for(let t of a){let n=mm(t);n&&e.open(n)}}D.current=Am(D.current,e,r,i),J(a,o);let s=S.current;if(s){let t=km([s],e,1,r,[],i)[0];t&&a.includes(t)&&G(t)}},t[108]=B,t[109]=Pe,t[110]=vt):vt=t[110];let yt,bt,xt,St,Ct;t[111]===B?(yt=t[112],bt=t[113],xt=t[114],St=t[115],Ct=t[116]):(yt=async e=>{B!==null&&(await aN(B).closeAndClearPersistence(e),o(t=>t&&(ci(t)===e?null:t)))},bt=()=>B===null?null:aN(B).getActiveDocName(),xt=e=>B===null?!1:aN(B).has(e),St=e=>{B!==null&&aN(B).recycle(e)},Ct=e=>B===null?null:aN(B).prewarm(e)?.poolEventId??null,t[111]=B,t[112]=yt,t[113]=bt,t[114]=xt,t[115]=St,t[116]=Ct);let wt,Tt,Et,Dt,Ot;t[117]===B?(wt=t[118],Tt=t[119],Et=t[120],Dt=t[121],Ot=t[122]):(wt=e=>{B!==null&&aN(B).setExpectedServerInstanceId(e)},Tt=async e=>{if(B===null)return;let t=aN(B);t.setObservedBranch(e),await Vu(t,e),ui([`files`,`backlinks`,`graph`]),di(e)},Et=async e=>{if(B===null)return;let t=aN(B);t.compareAndUpdateObservedBranch(e)&&(await Vu(t,e),ui([`files`,`backlinks`,`graph`]),di(e))},Dt=(e,t)=>{B!==null&&aN(B).observeDiskAck(e,t)},Ot=async()=>{B!==null&&await Wu(aN(B))},t[117]=B,t[118]=wt,t[119]=Tt,t[120]=Et,t[121]=Dt,t[122]=Ot);let kt;t[123]!==z||t[124]!==R||t[125]!==r.activeDocName?(kt=(e,t)=>{if(!r.activeDocName&&t){window.location.hash=xi(t),te(e),ee(`agent`),re(TN);return}if(R===`agent`&&z===e){ee(`doc`);return}te(e),ee(`agent`),re(wN)},t[123]=z,t[124]=R,t[125]=r.activeDocName,t[126]=kt):kt=t[126];let At;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(At=()=>{ee(`doc`),te(null)},t[127]=At):At=t[127];let jt;t[128]!==v||t[129]!==s||t[130]!==a||t[131]!==it||t[132]!==nt||t[133]!==et||t[134]!==H||t[135]!==V||t[136]!==B||t[137]!==z||t[138]!==ne||t[139]!==R||t[140]!==Oe||t[141]!==m||t[142]!==Re||t[143]!==Be||t[144]!==Qe||t[145]!==l||t[146]!==We||t[147]!==Ke||t[148]!==d||t[149]!==P||t[150]!==U||t[151]!==r.activeDocName||t[152]!==r.activeProvider||t[153]!==r.poolEntries||t[154]!==r.serverRestartRecovery||t[155]!==r.syncState||t[156]!==I||t[157]!==st||t[158]!==ct||t[159]!==ut||t[160]!==dt||t[161]!==mt||t[162]!==ht||t[163]!==gt||t[164]!==_t||t[165]!==vt||t[166]!==yt||t[167]!==bt||t[168]!==xt||t[169]!==St||t[170]!==Ct||t[171]!==wt||t[172]!==Tt||t[173]!==Et||t[174]!==Dt||t[175]!==Ot||t[176]!==kt||t[177]!==b||t[178]!==g?(jt={principal:P,activeTarget:a,activeTabId:s,activeDocName:r.activeDocName,activeProvider:r.activeProvider,openTabs:l,pinnedTabIds:d,visibleTabIds:g,tabSessionLoaded:b,syncState:r.syncState,serverRestartRecovery:r.serverRestartRecovery,poolEntries:r.poolEntries,openDocument:Re,openDocumentTransition:Be,openTarget:We,openTargetTransition:Ke,clearTarget:st,closeDocument:ct,closeActiveTabOrWindow:it,closeTab:et,pinTab:lt,unpinTab:ut,activateTab:dt,reorderTabs:pt,newTabIds:m,activeNewTabId:v,isNewTabActive:Oe,openNewTab:Qe,activateNewTab:mt,closeNewTab:nt,reopenClosedTab:ht,closeTabs:gt,syncOpenTabsWithKnownTargets:_t,remapTabsForRename:vt,closeAndClearForRename:yt,getPoolActiveDocName:bt,poolHas:xt,recycleDocument:St,prewarm:Ct,systemProvider:I,setSystemProvider:L,updateServerInstanceId:wt,onBranchSwitched:Tt,observeBranch:Et,observeDiskAck:Dt,refreshServerInfo:Ot,collabUrl:B,collabTerminal:V,collabLastError:H,retryCollab:U,docPanelMode:R,docPanelAgentId:z,docPanelExpandSignal:ne,openActivityPanel:kt,closeActivityPanel:At},t[128]=v,t[129]=s,t[130]=a,t[131]=it,t[132]=nt,t[133]=et,t[134]=H,t[135]=V,t[136]=B,t[137]=z,t[138]=ne,t[139]=R,t[140]=Oe,t[141]=m,t[142]=Re,t[143]=Be,t[144]=Qe,t[145]=l,t[146]=We,t[147]=Ke,t[148]=d,t[149]=P,t[150]=U,t[151]=r.activeDocName,t[152]=r.activeProvider,t[153]=r.poolEntries,t[154]=r.serverRestartRecovery,t[155]=r.syncState,t[156]=I,t[157]=st,t[158]=ct,t[159]=ut,t[160]=dt,t[161]=mt,t[162]=ht,t[163]=gt,t[164]=_t,t[165]=vt,t[166]=yt,t[167]=bt,t[168]=xt,t[169]=St,t[170]=Ct,t[171]=wt,t[172]=Tt,t[173]=Et,t[174]=Dt,t[175]=Ot,t[176]=kt,t[177]=b,t[178]=g,t[179]=jt):jt=t[179];let Mt=jt,Nt;return t[180]!==n||t[181]!==Mt?(Nt=(0,Z.jsx)(nN,{value:Mt,children:n}),t[180]=n,t[181]=Mt,t[182]=Nt):Nt=t[182],Nt}function wN(e){return e+1}function TN(e){return e+1}function EN(e){return e.length>0}function DN(e){return e===null?e:null}function ON(e){return e===null?e:null}function kN(e){return e===null?e:null}function AN(e){return e===null?e:null}function jN(e){return e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))}function MN(e){console.warn(`[editor-tabs] failed to persist tab session:`,e)}function NN(e){console.warn(`[editor-tabs] failed to restore tab session:`,e)}function PN(){let e=(0,Q.use)(nN);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function FN(){let e=(0,$.c)(3),{openDocumentTransition:t,openTargetTransition:n}=PN(),r;return e[0]!==t||e[1]!==n?(r={openDocumentTransition:t,openTargetTransition:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}export{Rh as $,wl as $t,fO as A,Wa as An,_d as At,nC as B,Nu as Bt,sk as C,ro as Cn,If as Ct,ek as D,Xa as Dn,xf as Dt,ak as E,Za as En,Wd as Et,NT as F,$u as Ft,Av as G,bu as Gt,$S as H,ju as Ht,UT as I,Gu as It,Xg as J,Tu as Jt,Q_ as K,xu as Kt,Mw as L,Hu as Lt,eE as M,Ha as Mn,vd as Mt,KT as N,Ra as Nn,gd as Nt,FO as O,Ja as On,Df as Ot,RT as P,nd as Pt,pg as Q,Du as Qt,jw as R,zu as Rt,ik as S,io as Sn,Qf as St,ok as T,eo as Tn,Ff as Tt,eC as U,Au as Ut,rC as V,Ou as Vt,rb as W,ku as Wt,Fg as X,Eu as Xt,Jg as Y,Su as Yt,Og as Z,Cu as Zt,Lj as _,po as _n,Vp as _t,yM as a,pl as an,jm as at,Mk as b,oo as bn,op as bt,_M as c,Po as cn,Jp as ct,FM as d,wo as dn,wp as dt,Sl as en,um as et,hM as f,Co as fn,xp as ft,Ij as g,mo as gn,bp as gt,Jj as h,ho as hn,Ap as ht,bM as i,xl as in,pm as it,aD as j,Ua as jn,hd as jt,DO as k,Ga as kn,jd as kt,IM as l,No as ln,qp as lt,Yj as m,yo as mn,Np as mt,PN as n,hl as nn,bm as nt,vM as o,ol as on,fm as ot,mM as p,So as pn,Mp as pt,v_ as q,wu as qt,FN as r,ml as rn,lm as rt,xM as s,sl as sn,dm as st,CN as t,bl as tn,cm as tt,jM as u,jo as un,Kp as ut,MA as v,fo as vn,Kf as vt,ck as w,no as wn,Pf as wt,dk as x,ao as xn,ap as xt,kA as y,uo as yn,sp as yt,vw as z,Mu as zt};
35
+ ${IE(e)}`}var zE=`plaintext`;function BE(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?`dark`:`light`}function VE(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(!1),a,o;return n[0]!==e||n[1]!==t?(a=()=>{let n=()=>{let n=typeof t==`function`?t():void 0;if(typeof n!=`number`)return;let r=e.state.doc.nodeAt(n);if(!r)return;let{from:a,to:o}=e.state.selection,s=n,c=a<n+r.nodeSize&&o>s;i(e=>e===c?e:c)};return n(),e.on(`selectionUpdate`,n),()=>{e.isDestroyed||e.off(`selectionUpdate`,n)}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function HE(e){let t=(0,$.c)(185),{node:n,updateAttributes:r,editor:i,getPos:a,selected:l}=e,{_:u}=s(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),{resolvedTheme:S}=c(),C;t[0]===S?C=t[1]:(C=S===`dark`||S===`light`?S:BE(),t[0]=S,t[1]=C);let w=C,[T]=(0,Q.useState)(BE),E=n.attrs.language??null,D=n.attrs.meta??null,O;t[2]===D?O=t[3]:(O=wE(D),t[2]=D,t[3]=O);let k=O,[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(!1),P=Zn(),[F,I]=(0,Q.useState)(!1),L=(0,Q.useId)(),R=`${L}-title-input`,ee=`${L}-title-help`,z=(0,Q.useRef)(D),te,ne;t[4]===D?(te=t[5],ne=t[6]):(te=()=>{z.current=D},ne=[D],t[4]=D,t[5]=te,t[6]=ne),(0,Q.useEffect)(te,ne);let re,B,V,H,U;if(t[7]!==u||t[8]!==E||t[9]!==D){B=sE(E),re=E?aE.find(e=>e.value===B)?.label??E:u({id:`LpB85N`});let e;t[15]===D?e=t[16]:(e=dE(D,`preview`),t[15]=D,t[16]=e),H=e,V=B?mE.has(B):!1,U=hE(B,D),t[7]=u,t[8]=E,t[9]=D,t[10]=re,t[11]=B,t[12]=V,t[13]=H,t[14]=U}else re=t[10],B=t[11],V=t[12],H=t[13],U=t[14];let W=U,G;t[17]!==W||t[18]!==D?(G=W?bE(D):null,t[17]=W,t[18]=D,t[19]=G):G=t[19];let ie=G,K;t[20]!==W||t[21]!==D?(K=W?xE(D):null,t[20]=W,t[21]=D,t[22]=K):K=t[22];let ae=K,oe=ie??(v===null?void 0:`${v}px`),q=!W,se,ce;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>()=>{h.current!==null&&window.clearTimeout(h.current)},ce=[],t[23]=se,t[24]=ce):(se=t[23],ce=t[24]),(0,Q.useEffect)(se,ce);let J=i.isEditable,le=VE(i,a),ue,Y;t[25]===w?(ue=t[26],Y=t[27]):(ue=()=>{_.current?.contentWindow?.postMessage(OE(w),`*`)},Y=[w],t[25]=w,t[26]=ue,t[27]=Y),(0,Q.useEffect)(ue,Y);let de,fe;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>{let e=function(e){if(e.source!==_.current?.contentWindow)return;let t=AE(e.data);if(t!==null){y(e=>e!==null&&Math.abs(e-t)<=2?e:t);return}let n=ME(e.data);n!==null&&x(n)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},fe=[],t[28]=de,t[29]=fe):(de=t[28],fe=t[29]),(0,Q.useEffect)(de,fe);let pe;t[30]===n.textContent?pe=t[31]:(pe=()=>{let e=n.textContent,t=()=>{m(!0),h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>m(!1),1200)};try{typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e).then(t,qE)}catch{}},t[30]=n.textContent,t[31]=pe);let me=pe,he;t[32]!==i||t[33]!==a?(he=()=>{let e=typeof a==`function`?a():void 0;if(typeof e==`number`)try{i.chain().focus().setNodeSelection(e).deleteSelection().run()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;console.warn(`[CodeBlockView] delete failed — position race`,t)}},t[32]=i,t[33]=a,t[34]=he):he=t[34];let ge=he,_e;t[35]!==H||t[36]!==D||t[37]!==r?(_e=()=>{r({meta:H?pE(D,`preview`):fE(D,`preview`)})},t[35]=H,t[36]=D,t[37]=r,t[38]=_e):_e=t[38];let ve=_e,ye;t[39]!==D||t[40]!==r?(ye=e=>{let t=TE(D,e.length>0?e:null);t!==D&&r({meta:t})},t[39]=D,t[40]=r,t[41]=ye):ye=t[41];let be=ye,xe;t[42]!==i.state||t[43]!==i.view||t[44]!==a||t[45]!==n.attrs||t[46]!==n.nodeSize||t[47]!==n.type?(xe=e=>{let t=typeof a==`function`?a():void 0;if(typeof t==`number`)try{let{schema:r,tr:a}=i.state,o=n.type.create(n.attrs,e.length>0?r.text(e):null);a.replaceWith(t,t+n.nodeSize,o),i.view.dispatch(a)}catch(e){let t=e;if(!(t instanceof RangeError))throw t;console.warn(`[CodeBlockView] edit-save failed — position race`,t)}},t[42]=i.state,t[43]=i.view,t[44]=a,t[45]=n.attrs,t[46]=n.nodeSize,t[47]=n.type,t[48]=xe):xe=t[48];let Se=xe,Ce;t[49]===r?Ce=t[50]:(Ce=e=>{let t=`${Math.round(e.width)}px`,n=`${Math.round(e.height)}px`;r({meta:yE(yE(z.current,`h`,n),`w`,t)})},t[49]=r,t[50]=Ce);let we=Ce,Te=E??void 0,Ee=le?`true`:void 0,De=l?`true`:void 0,Oe=W?`true`:void 0,ke=q?`true`:`false`,Ae=F?`true`:void 0,je,Me;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(je=()=>I(!0),Me=()=>I(!1),t[51]=je,t[52]=Me):(je=t[51],Me=t[52]);let Ne;t[53]!==u||t[54]!==w||t[55]!==T||t[56]!==q||t[57]!==oe||t[58]!==we||t[59]!==n.textContent||t[60]!==W||t[61]!==ae?(Ne=W?(0,Z.jsxs)(`div`,{ref:g,className:Ft(`ok-codeblock-preview`,q?`ok-codeblock-preview--with-code`:`ok-codeblock-preview--solo`),contentEditable:!1,style:{...oe?{height:oe}:{},...ae?{width:ae}:{}},onMouseDown:KE,children:[(0,Z.jsx)(`iframe`,{title:u({id:`G7cMuO`}),ref:_,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:RE(T)+n.textContent,className:`ok-codeblock-preview-frame`,onLoad:()=>{x(null),_.current?.contentWindow?.postMessage(OE(w),`*`)}}),(0,Z.jsx)(d_,{targetRef:g,bounds:{minWidth:192,maxWidth:Math.round(window.innerWidth*.9),minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=g.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:we})]}):null,t[53]=u,t[54]=w,t[55]=T,t[56]=q,t[57]=oe,t[58]=we,t[59]=n.textContent,t[60]=W,t[61]=ae,t[62]=Ne):Ne=t[62];let Pe;t[63]!==b||t[64]!==W?(Pe=W&&b?(0,Z.jsx)(iE,{blocked:b.blocked,truncated:b.truncated,onDismiss:()=>x(null)}):null,t[63]=b,t[64]=W,t[65]=Pe):Pe=t[65];let Fe;t[66]===k?Fe=t[67]:(Fe=k?(0,Z.jsx)(`div`,{className:`ok-codeblock-title`,contentEditable:!1,"data-testid":`ok-codeblock-title`,title:k,children:(0,Z.jsx)(`span`,{className:`ok-codeblock-title-text`,children:k})}):null,t[66]=k,t[67]=Fe);let Ie=W&&q?`rounded-b-lg`:null,Le=W?null:`rounded-lg`,Re;t[68]!==Ie||t[69]!==Le?(Re=Ft(`ok-codeblock-pre m-0 overflow-x-auto px-5 py-4 font-mono text-sm leading-relaxed`,Ie,Le),t[68]=Ie,t[69]=Le,t[70]=Re):Re=t[70];let ze=!q||void 0,Be=E?`language-${E}`:void 0,Ve;t[71]===Be?Ve=t[72]:(Ve=Ft(`hljs block whitespace-pre bg-transparent p-0`,Be),t[71]=Be,t[72]=Ve);let He;t[73]===Ve?He=t[74]:(He=(0,Z.jsx)(Nn,{as:`code`,className:Ve}),t[73]=Ve,t[74]=He);let Ue;t[75]!==Re||t[76]!==ze||t[77]!==He?(Ue=(0,Z.jsx)(`pre`,{className:Re,"aria-hidden":ze,children:He}),t[75]=Re,t[76]=ze,t[77]=He,t[78]=Ue):Ue=t[78];let We;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(We={[dC]:`true`},t[79]=We):We=t[79];let Ge=!J,Ke;t[80]!==u||t[81]!==re?(Ke=u({id:`c5f7sm`,values:{currentLabel:re}}),t[80]=u,t[81]=re,t[82]=Ke):Ke=t[82];let qe;t[83]===re?qe=t[84]:(qe=(0,Z.jsx)(`span`,{children:re}),t[83]=re,t[84]=qe);let Je;t[85]===J?Je=t[86]:(Je=J?(0,Z.jsx)(Vn,{className:`size-3 opacity-60`,"aria-hidden":`true`}):null,t[85]=J,t[86]=Je);let Ye;t[87]!==Ge||t[88]!==Ke||t[89]!==qe||t[90]!==Je?(Ye=(0,Z.jsx)(ku,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,disabled:Ge,className:`ok-codeblock-chrome-btn ok-codeblock-chrome-lang`,"aria-label":Ke,children:[qe,Je]})}),t[87]=Ge,t[88]=Ke,t[89]=qe,t[90]=Je,t[91]=Ye):Ye=t[91];let Xe;t[92]===u?Xe=t[93]:(Xe=u({id:`G_mWXb`}),t[92]=u,t[93]=Xe);let Ze;t[94]===Xe?Ze=t[95]:(Ze=(0,Z.jsx)(Su,{placeholder:Xe}),t[94]=Xe,t[95]=Ze);let Qe;t[96]===u?Qe=t[97]:(Qe=u({id:`ETyvvg`}),t[96]=u,t[97]=Qe);let $e;t[98]===Qe?$e=t[99]:($e=(0,Z.jsx)(wu,{children:Qe}),t[98]=Qe,t[99]=$e);let et;t[100]!==i.commands||t[101]!==B||t[102]!==E||t[103]!==r?(et=aE.map(e=>{let t=e.value===zE?!E||B===zE:B===e.value;return(0,Z.jsxs)(Eu,{value:`${e.label} ${e.value} ${e.aliases?.join(` `)??``}`,onSelect:()=>{r({language:e.value===zE?null:e.value}),f(!1),i.commands.focus()},children:[(0,Z.jsx)(`span`,{className:`flex-1`,children:e.label}),t?(0,Z.jsx)(Bn,{className:`size-3.5`,"aria-hidden":`true`}):null]},e.value)}),t[100]=i.commands,t[101]=B,t[102]=E,t[103]=r,t[104]=et):et=t[104];let tt;t[105]===et?tt=t[106]:(tt=(0,Z.jsx)(Tu,{children:et}),t[105]=et,t[106]=tt);let nt;t[107]!==$e||t[108]!==tt?(nt=(0,Z.jsxs)(Cu,{children:[$e,tt]}),t[107]=$e,t[108]=tt,t[109]=nt):nt=t[109];let rt;t[110]!==Ze||t[111]!==nt?(rt=(0,Z.jsx)(Au,{align:`end`,sideOffset:6,className:`w-56 p-0`,children:(0,Z.jsxs)(bu,{filter:WE,children:[Ze,nt]})}),t[110]=Ze,t[111]=nt,t[112]=rt):rt=t[112];let it;t[113]!==d||t[114]!==Ye||t[115]!==rt?(it=(0,Z.jsxs)(Ou,{open:d,onOpenChange:f,children:[Ye,rt]}),t[113]=d,t[114]=Ye,t[115]=rt,t[116]=it):it=t[116];let at;t[117]!==u||t[118]!==J||t[119]!==W?(at=J&&W?(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":u({id:`R3y75Z`}),"data-testid":`ok-codeblock-edit-btn`,onClick:()=>N(!0),children:(0,Z.jsx)($n,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[117]=u,t[118]=J,t[119]=W,t[120]=at):at=t[120];let ot;t[121]!==u||t[122]!==J||t[123]!==ve||t[124]!==V||t[125]!==H?(ot=J&&V?(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"data-active":H?`true`:void 0,"aria-pressed":H,"aria-label":u(H?{id:`xHGM4U`}:{id:`7OwvEL`}),onClick:ve,children:H?(0,Z.jsx)(Za,{className:`size-3.5`}):(0,Z.jsx)(er,{className:`size-3.5`})}):null,t[121]=u,t[122]=J,t[123]=ve,t[124]=V,t[125]=H,t[126]=ot):ot=t[126];let st;t[127]!==u||t[128]!==J||t[129]!==be||t[130]!==A||t[131]!==k||t[132]!==ee||t[133]!==R?(st=J?(0,Z.jsxs)(Ou,{open:A,onOpenChange:j,children:[(0,Z.jsx)(ku,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"data-active":k?`true`:void 0,"aria-label":u({id:`DDTdLl`}),children:(0,Z.jsx)(To,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Z.jsx)(Au,{align:`end`,sideOffset:6,className:`w-64 p-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:R,className:`text-2xs font-mono uppercase tracking-wide text-muted-foreground`,children:(0,Z.jsx)(o,{id:`MHrjPM`})}),(0,Z.jsx)(ri,{id:R,type:`text`,value:k??``,placeholder:u({id:`mk2poV`}),"data-testid":`ok-codeblock-title-input`,"aria-describedby":ee,onChange:e=>be(e.target.value),onKeyDown:e=>{(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),j(!1))},className:`h-8`}),(0,Z.jsx)(`p`,{id:ee,className:`text-2xs text-muted-foreground`,children:(0,Z.jsx)(o,{id:`lond3p`})})]})})]}):null,t[127]=u,t[128]=J,t[129]=be,t[130]=A,t[131]=k,t[132]=ee,t[133]=R,t[134]=st):st=t[134];let ct;t[135]!==u||t[136]!==i||t[137]!==P||t[138]!==n.textContent||t[139]!==E||t[140]!==D?(ct=P?null:(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":u({id:`00c7t0`}),"data-testid":`ok-codeblock-ask-ai-btn`,onClick:()=>{let e=Yt(i),t=E??``,r=D?`${t} ${D}`.trim():t,a=n.textContent,o=(a.match(/`+/g)??[]).reduce(UE,0),s="`".repeat(Math.max(3,o+1)),c=`${s}${r}\n${a}\n${s}`;requestAnimationFrame(()=>{if(e===null||a.trim()===``){$S();return}nC(ut({relativePath:Qn(e),instruction:``,selectionMarkdown:c,target:`claude-code`}))})},children:(0,Z.jsx)(Xn,{className:`size-3.5`,"aria-hidden":`true`})}),t[135]=u,t[136]=i,t[137]=P,t[138]=n.textContent,t[139]=E,t[140]=D,t[141]=ct):ct=t[141];let lt;t[142]!==u||t[143]!==p?(lt=u(p?{id:`6V3Ea3`}:{id:`NmPNJJ`}),t[142]=u,t[143]=p,t[144]=lt):lt=t[144];let dt;t[145]===p?dt=t[146]:(dt=p?(0,Z.jsx)(Bn,{className:`size-3.5`,"aria-hidden":`true`}):(0,Z.jsx)(Jn,{className:`size-3.5`,"aria-hidden":`true`}),t[145]=p,t[146]=dt);let ft;t[147]!==me||t[148]!==lt||t[149]!==dt?(ft=(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":lt,onClick:me,children:dt}),t[147]=me,t[148]=lt,t[149]=dt,t[150]=ft):ft=t[150];let pt;t[151]!==u||t[152]!==J||t[153]!==ge?(pt=J?(0,Z.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn ok-codeblock-chrome-btn--delete`,"aria-label":u({id:`oBXkm2`}),onClick:ge,children:(0,Z.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[151]=u,t[152]=J,t[153]=ge,t[154]=pt):pt=t[154];let mt;t[155]!==it||t[156]!==at||t[157]!==ot||t[158]!==st||t[159]!==ct||t[160]!==ft||t[161]!==pt?(mt=(0,Z.jsxs)(`div`,{className:`ok-codeblock-chrome`,contentEditable:!1,onMouseDown:GE,...We,children:[it,at,ot,st,ct,ft,pt]}),t[155]=it,t[156]=at,t[157]=ot,t[158]=st,t[159]=ct,t[160]=ft,t[161]=pt,t[162]=mt):mt=t[162];let ht;t[163]!==u||t[164]!==T||t[165]!==M||t[166]!==J||t[167]!==Se||t[168]!==n.textContent||t[169]!==B||t[170]!==W?(ht=J&&W?(0,Z.jsx)(nE,{open:M,onOpenChange:N,initialValue:n.textContent,language:B===`xml`?`html`:`plain`,title:u({id:`R3y75Z`}),renderPreview:e=>(0,Z.jsx)(`iframe`,{title:u({id:`G7cMuO`}),sandbox:`allow-scripts`,className:`size-full border-0`,srcDoc:RE(T)+e}),onSave:Se}):null,t[163]=u,t[164]=T,t[165]=M,t[166]=J,t[167]=Se,t[168]=n.textContent,t[169]=B,t[170]=W,t[171]=ht):ht=t[171];let gt;return t[172]!==Te||t[173]!==Ee||t[174]!==De||t[175]!==Oe||t[176]!==ke||t[177]!==Ae||t[178]!==Ne||t[179]!==Pe||t[180]!==Fe||t[181]!==Ue||t[182]!==mt||t[183]!==ht?(gt=(0,Z.jsxs)(Dn,{className:`ok-codeblock relative my-3`,"data-language":Te,"data-cursor-inside":Ee,"data-selected":De,"data-preview":Oe,"data-code-visible":ke,"data-hovered":Ae,onMouseEnter:je,onMouseLeave:Me,children:[Ne,Pe,Fe,Ue,mt,ht]}),t[172]=Te,t[173]=Ee,t[174]=De,t[175]=Oe,t[176]=ke,t[177]=Ae,t[178]=Ne,t[179]=Pe,t[180]=Fe,t[181]=Ue,t[182]=mt,t[183]=ht,t[184]=gt):gt=t[184],gt}function UE(e,t){return Math.max(e,t.length)}function WE(e,t){return t?+!!e.toLowerCase().includes(t.toLowerCase()):1}function GE(e){return e.stopPropagation()}function KE(e){return e.stopPropagation()}function qE(){}function JE(e,t=[]){return e.flatMap(e=>{if(e.type===`text`)return[{text:e.value,classes:t}];let n=[...t,...e.properties?.className??[]];return JE(e.children,n)})}function YE(e){let{doc:t,name:n,lowlight:r,defaultLanguage:i}=e,a=[],o=r.listLanguages();return Se(t,e=>e.type.name===n).forEach(e=>{let t=e.pos+1,n=e.node.attrs.language||i;if(!n||!(o.includes(n)||(r.registered?.(n)??!1)))return;let s;try{s=r.highlight(n,e.node.textContent)}catch{return}let c=s.children??[];for(let e of JE(c)){let n=t+e.text.length;e.classes.length>0&&a.push(rt.inline(t,n,{class:e.classes.join(` `)})),t=n}}),Ue.create(t,a)}function XE(e){let{name:t,lowlight:n,defaultLanguage:r}=e,i=new Et({key:new ke(`codeBlockLowlight`),state:{init:(e,{doc:i})=>YE({doc:i,name:t,lowlight:n,defaultLanguage:r}),apply:(e,i,a,o)=>{if(!e.docChanged)return i.map(e.mapping,e.doc);let s=a.selection.$head.parent.type.name,c=o.selection.$head.parent.type.name,l=Se(a.doc,e=>e.type.name===t),u=Se(o.doc,e=>e.type.name===t);return[s,c].includes(t)||u.length!==l.length||e.steps.some(e=>{let t=e;return t.from===void 0||t.to===void 0?!1:l.some(e=>t.from<e.pos+e.node.nodeSize&&t.to>e.pos)})?YE({doc:e.doc,name:t,lowlight:n,defaultLanguage:r}):i.map(e.mapping,e.doc)}},props:{decorations(e){return i.getState(e)}}});return i}var ZE=XS(KS),QE=Oe.extend({addOptions(){return{...this.parent?.(),enableTabIndentation:!0,tabSize:2}},addNodeView(){return bn(HE)},addProseMirrorPlugins(){return[...this.parent?.()??[],XE({name:this.name,lowlight:ZE,defaultLanguage:null})]},addInputRules(){return[...this.parent?.()??[],ze({find:/^```$/,type:this.type,getAttributes:()=>({language:`js`})})]}});function $E(e){return!!e.getMeta(jd)}function eD(e,t){let n=jd.getState(e);return bf(n.doc,n.type,t,n.binding.mapping)||0}function tD(e,t){let n=jd.getState(e);return vf(t,n.type,n.binding.mapping)}var nD=class e extends O{constructor(e,t){super(e),this.yRelativePosition=t}static fromJSON(t){return new e(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function rD(e,t){return new nD(e,tD(t,e))}function iD(e,t,n){let r=e instanceof nD?e.yRelativePosition:null;if($E(t)&&r)return{position:new nD(eD(n,r),r),mapResult:null};let i=Ee(e,t),a=i.position.position;return{position:new nD(a,r??tD(n,a)),mapResult:i.mapResult}}var aD=Y.create({name:`collaboration`,priority:1e3,addOptions(){return{document:null,field:`default`,fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name===`undoRedo`)&&console.warn(`[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".`)},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>iD(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>rD(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Md.getState(t).undoManager.undoStack.length===0?!1:n?Of(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Md.getState(t).undoManager.redoStack.length===0?!1:n?kf(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){let e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=Mf(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let{undoManager:t}=Md.getState(e.state);t.restore&&=(t.restore(),()=>{});let r=n?n(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),n=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on(`afterTransaction`,t.afterTransactionHandler),t._observers=n},r?.destroy&&r.destroy()}}},[Bd(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new Et({key:new ke(`filterInvalidContent`),filterTransaction:t=>{if(!$E(t))return!0;if(this.storage.isDisabled)return!1;if(!t.docChanged)return!0;try{return t.doc.check(),!0}catch(t){return this.storage.isDisabled=!0,this.editor.emit(`contentError`,{error:t,editor:this.editor,disableCollaboration:()=>{var t;(t=e.doc)==null||t.destroy()}}),!1}}})].filter(Boolean)}});function oD(e){if(!e.length)return Ue.empty;let t=[],n=e[0].$from.node(0);return e.forEach(e=>{let n=e.$from.pos,r=e.$from.nodeAfter;r&&t.push(rt.node(n,n+r.nodeSize,{class:`ProseMirror-selectednoderange`}))}),Ue.create(n,t)}function sD(e,t,n){let r=n.isText||n.isAtom?0:1;return{start:e+r,end:e+t-r}}function cD(e,t,n,r={}){let i=[],a=e.node(0),{extendOnBoundaryOverlap:o=!0}=r;typeof n==`number`&&n>=0||(n=e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos));let s=new b(e,t,n),c=s.depth===0?0:a.resolve(s.start).posAtIndex(0);return s.parent.forEach((n,r)=>{let l=c+r,u=l+n.nodeSize,d=sD(l,n.nodeSize,n),f=o?t.pos>=d.start&&e.pos<=d.end:t.pos>d.start&&e.pos<d.end;if(l<s.start||l>=s.end||!f)return;let p=new se(a.resolve(l),a.resolve(u));i.push(p)}),i}var lD=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return new uD(e.resolve(this.anchor),e.resolve(this.head))}},uD=class e extends wt{constructor(e,t,n,r=1){let{doc:i}=e,a=e===t,o=e.pos===i.content.size&&t.pos===i.content.size,s=a&&!o?i.resolve(t.pos+(r>0?1:-1)):t,c=a&&o?i.resolve(e.pos-(r>0?1:-1)):e,l=cD(c.min(s),c.max(s),n),u=s.pos>=e.pos?l[0].$from:l[l.length-1].$to,d=s.pos>=e.pos?l[l.length-1].$to:l[0].$from;super(u,d,l),this.depth=n}get $to(){return this.ranges[this.ranges.length-1].$to}eq(t){return t instanceof e&&t.$from.pos===this.$from.pos&&t.$to.pos===this.$to.pos}map(t,n){return new e(t.resolve(n.map(this.anchor)),t.resolve(n.map(this.head)))}toJSON(){return{type:`nodeRange`,anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){let{doc:t}=this.$from;if(this.isForwards&&this.ranges.length>1){let t=this.ranges.slice(0,-1),n=t[0].$from,r=t[t.length-1].$to;return new e(n,r,this.depth)}let n=this.ranges[0],r=t.resolve(Math.max(0,n.$from.pos-1));return new e(this.$anchor,r,this.depth)}extendForwards(){let{doc:t}=this.$from;if(this.isBackwards&&this.ranges.length>1){let t=this.ranges.slice(1),n=t[0].$from,r=t[t.length-1].$to;return new e(r,n,this.depth)}let n=this.ranges[this.ranges.length-1],r=t.resolve(Math.min(t.content.size,n.$to.pos+1));return new e(this.$anchor,r,this.depth)}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n,r,i=1){return new this(e.resolve(t),e.resolve(n),r,i)}getBookmark(){return new lD(this.anchor,this.head)}};uD.prototype.visible=!1;function dD(e){return e instanceof uD}Y.create({name:`nodeRange`,addOptions(){return{depth:void 0,key:`Mod`}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,selection:a,tr:o}=r,{anchor:s,head:c}=a;if(!dD(a)){let e=uD.create(i,s,c,t,-1);return o.setSelection(e),n.dispatch(o),!0}let l=a.extendBackwards();return o.setSelection(l),n.dispatch(o),!0},"Shift-ArrowDown":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,selection:a,tr:o}=r,{anchor:s,head:c}=a;if(!dD(a)){let e=uD.create(i,s,c,t);return o.setSelection(e),n.dispatch(o),!0}let l=a.extendForwards();return o.setSelection(l),n.dispatch(o),!0},"Mod-a":({editor:e})=>{let{depth:t}=this.options,{view:n,state:r}=e,{doc:i,tr:a}=r,o=uD.create(i,0,i.content.size,t);return a.setSelection(o),n.dispatch(a),!0}}},onSelectionUpdate(){let{selection:e}=this.editor.state;dD(e)&&this.editor.view.dom.classList.add(`ProseMirror-noderangeselection`)},addProseMirrorPlugins(){let e=!1,t=!1;return[new Et({key:new ke(`nodeRange`),props:{attributes:()=>e?{class:`ProseMirror-noderangeselection`}:{class:``},handleDOMEvents:{mousedown:(e,n)=>{let{key:r}=this.options,i=/Mac/.test(navigator.platform),a=!!n.shiftKey,o=!!n.ctrlKey,s=!!n.altKey,c=!!n.metaKey;return(r==null||r===`Shift`&&a||r===`Control`&&o||r===`Alt`&&s||r===`Meta`&&c||r===`Mod`&&(i?c:o))&&(t=!0),t&&document.addEventListener(`mouseup`,()=>{t=!1;let{state:n}=e,{doc:r,selection:i,tr:a}=n,{$anchor:o,$head:s}=i;if(o.sameParent(s))return;let c=uD.create(r,o.pos,s.pos,this.options.depth);a.setSelection(c),e.dispatch(a)},{once:!0}),!1}},decorations:n=>{let{selection:r}=n,i=dD(r);if(e=!1,!t)return i?(e=!0,oD(r.ranges)):null;let{$from:a,$to:o}=r;if(!i&&a.sameParent(o))return null;let s=cD(a,o,this.options.depth);return s.length?(e=!0,oD(s)):null}}})]}});function fD(e){let t=``,n=getComputedStyle(e);for(let e=0;e<n.length;e+=1)t+=`${n[e]}:${n.getPropertyValue(n[e])};`;return t}function pD(e){let t=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName(`*`))],r=[t,...Array.from(t.getElementsByTagName(`*`))];return n.forEach((e,t)=>{r[t].style.cssText=fD(e)}),t}var mD=[{id:`listItemFirstChild`,evaluate:({parent:e,isFirst:t})=>t&&e&&[`listItem`,`taskItem`].includes(e.type.name)?1e3:0},{id:`listWrapperDeprioritize`,evaluate:({node:e})=>{let t=[`listItem`,`taskItem`],n=e.firstChild;return n&&t.includes(n.type.name)?1e3:0}},{id:`tableStructure`,evaluate:({node:e,parent:t})=>[`tableRow`,`tableCell`,`tableHeader`].includes(e.type.name)||t&&t.type.name===`tableHeader`?1e3:0},{id:`inlineContent`,evaluate:({node:e})=>e.isInline||e.isText?1e3:0}],hD={edges:[`left`,`top`],threshold:12,strength:500};function gD(e){return e===void 0||e===`left`?{...hD}:e===`right`?{edges:[`right`,`top`],threshold:12,strength:500}:e===`both`?{edges:[`left`,`right`,`top`],threshold:12,strength:500}:e===`none`?{edges:[],threshold:0,strength:0}:{...hD,...e}}function _D(e,t,n){if(n.edges.length===0)return!1;let r=t.getBoundingClientRect(),{threshold:i,edges:a}=n;return a.some(t=>t===`left`?e.x-r.left<i:t===`right`?r.right-e.x<i:t===`top`?e.y-r.top<i:t===`bottom`?r.bottom-e.y<i:!1)}function vD(e,t,n,r){return!t||n.edges.length===0?0:_D(e,t,n)?n.strength*r:0}var yD=1e3;function bD(e,t,n,r){let i=yD,a=!1;if(t.every(t=>{let n=t.evaluate(e);return i-=n,i<=0?(a=!0,!1):!0}),a)return-1;let o=e.view.nodeDOM(e.pos);return i-=vD(r,o,n,e.depth),i<=0?-1:i}function xD(e,t,n){return Array.from({length:t},(e,n)=>t-1-n).some(t=>n.includes(e.node(t).type.name))}function SD(e,t,n){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))return null;let r=e.posAtCoords({left:t.x,top:t.y});if(!r)return null;let{doc:i}=e.state,a=i.resolve(r.pos),o=[];n.defaultRules&&o.push(...mD),o.push(...n.rules);let s=Array.from({length:a.depth},(e,t)=>a.depth-t).map(r=>{let i=a.node(r),s=a.before(r);if(n.allowedContainers&&r>0&&!xD(a,r,n.allowedContainers))return null;let c=r>0?a.node(r-1):null,l=r>0?a.index(r-1):0,u=c?c.childCount:1,d=bD({node:i,pos:s,depth:r,parent:c,index:l,isFirst:l===0,isLast:l===u-1,$pos:a,view:e},o,n.edgeDetection,t);return d<0?null:{node:i,pos:s,depth:r,score:d,dom:e.nodeDOM(s)}}).filter(e=>e!==null),c=a.nodeAfter;if(c&&c.isAtom&&!c.isInline){let i=r.pos,l=a.depth+1,u=a.parent,d=a.index(),f=u.childCount,p=!0;if(n.allowedContainers&&(p=xD(a,l,n.allowedContainers)),p){let r=bD({node:c,pos:i,depth:l,parent:u,index:d,isFirst:d===0,isLast:d===f-1,$pos:a,view:e},o,n.edgeDetection,t);if(r>=0){let t=e.nodeDOM(i);t&&s.push({node:c,pos:i,depth:l,score:r,dom:t})}}}if(s.length===0)return null;s.sort((e,t)=>t.score===e.score?t.depth-e.depth:t.score-e.score);let l=s[0];return l.dom?{node:l.node,pos:l.pos,dom:l.dom}:null}function CD(e,t){let n=e;for(;n?.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return n?.parentElement===t.dom?n:void 0}function wD(e){return Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&e.width>0&&e.height>0}function TD(e,t,n,r=5){if(!Number.isFinite(t)||!Number.isFinite(n))return null;let i=e.dom,a=i.firstElementChild,o=i.lastElementChild;if(!a||!o)return null;let s=a.getBoundingClientRect(),c=o.getBoundingClientRect();if(!wD(s)||!wD(c))return null;let l=Math.min(Math.max(s.top+r,n),c.bottom-r),u=.5,d=Math.abs(s.left-c.left)<u,f=Math.abs(s.right-c.right)<u,p=s;d&&f&&(p=s);let m=Math.min(Math.max(p.left+r,t),p.right-r);return!Number.isFinite(m)||!Number.isFinite(l)?null:{x:m,y:l}}var ED=e=>{let{x:t,y:n,editor:r,nestedOptions:i}=e,{view:a,state:o}=r,s=TD(a,t,n,5);if(!s)return{resultElement:null,resultNode:null,pos:null};let{x:c,y:l}=s;if(i?.enabled){let e=SD(a,{x:c,y:l},i);return e?{resultElement:e.dom,resultNode:e.node,pos:e.pos}:{resultElement:null,resultNode:null,pos:null}}let u=a.root.elementsFromPoint(c,l),d;if(Array.prototype.some.call(u,e=>{if(!a.dom.contains(e))return!1;let t=CD(e,a);return t?(d=t,!0):!1}),!d){let e=a.posAtCoords({left:c,top:l});if(e){let t=o.doc.resolve(e.pos),n=Math.min(t.depth,1),r=n>0?t.before(n):t.pos,i=o.doc.nodeAt(r);if(i){let e=a.nodeDOM(r);return{resultElement:e instanceof HTMLElement?e:null,resultNode:i,pos:r}}}return{resultElement:null,resultNode:null,pos:null}}let f;try{f=a.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}let p=o.doc.nodeAt(f);if(!p){let e=o.doc.resolve(f),t=e.parent;return{resultElement:d,resultNode:t,pos:e.start()}}return{resultElement:d,resultNode:p,pos:f}};function DD(e,t){let n=null,r=e.nodeDOM(t);if(r instanceof Element)n=r;else{let{node:r,offset:i}=e.domAtPos(t),a=r.childNodes[i];a instanceof Element?n=a:r instanceof Element?n=r:r.nodeType===Node.TEXT_NODE&&r.parentElement&&(n=r.parentElement)}return(n?getComputedStyle(n).direction:getComputedStyle(e.dom).direction)||`ltr`}function OD(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function kD(e,t,n,r){let{doc:i}=t.view.state;if(n?.enabled&&r?.node&&r.pos>=0){let e=r.pos,t=r.pos+r.node.nodeSize;return[{$from:i.resolve(e),$to:i.resolve(t)}]}let a=ED({editor:t,x:e.clientX,y:e.clientY,direction:`right`,nestedOptions:n});if(!a.resultNode||a.pos===null)return[];let o=a.resultNode.isText||a.resultNode.isAtom?0:-1;return cD(i.resolve(a.pos),i.resolve(a.pos+a.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}function AD(e,t,n,r){let{view:i}=t;if(!e.dataTransfer)return;let{empty:a,$from:o,$to:s}=i.state.selection,c=kD(e,t,n,r),l=cD(o,s,0,{extendOnBoundaryOverlap:!1}),u=l.some(e=>c.find(t=>t.$from===e.$from&&t.$to===e.$to)),d=a||!u?c:l;if(!d.length)return;let{tr:f}=i.state,p=document.createElement(`div`),m=d[0].$from.pos,h=d[d.length-1].$to.pos;p.setAttribute(`dir`,DD(i,m));let g=n?.enabled&&r?.node,_,v;g?(_=i.state.doc.slice(m,h),v=bt.create(i.state.doc,m)):(v=uD.create(i.state.doc,m,h),_=v.content()),d.forEach(e=>{let t=pD(i.nodeDOM(e.$from.pos));p.append(t)}),p.style.position=`absolute`,p.style.top=`-10000px`,p.style.contentVisibility=`visible`,document.body.append(p);for(let e of p.querySelectorAll(`*`))e.style&&e.style.contentVisibility===`auto`&&(e.style.contentVisibility=`visible`);e.dataTransfer.clearData();let y=p.getBoundingClientRect(),b=i.nodeDOM(m),x=b&&b.nodeType===1?b.getBoundingClientRect():null,S=x?Math.min(e.clientX-x.left,y.width):Math.max(0,Math.min(e.clientX-y.left,y.width)),C=x?Math.min(Math.max(e.clientY-x.top,0),y.height):0;e.dataTransfer.setDragImage(p,S,C);let w=!1,T=()=>{w||(w=!0,OD(p),document.removeEventListener(`drop`,T),document.removeEventListener(`dragend`,T))},E=v instanceof bt?v:void 0;i.dragging={slice:_,move:!0,node:E},f.setSelection(v),i.dispatch(f),document.addEventListener(`drop`,T),document.addEventListener(`dragend`,T)}var jD=(e,t)=>{let n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},MD=(e,t)=>{let n=e.nodeAt(t),r=e.resolve(t),{depth:i}=r,a=n;for(;i>0;){let e=r.node(i);--i,i===0&&(a=e)}return a},ND=(e,t)=>{let n=jd.getState(e);return n?vf(t,n.type,n.binding.mapping):null},PD=(e,t)=>{let n=jd.getState(e);return n?bf(n.doc,n.type,t,n.binding.mapping)||0:-1},FD=(e,t)=>{let n=t;for(;n?.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},ID=new ke(`dragHandle`),LD=({pluginKey:e=ID,element:t,editor:n,computePositionConfig:r,getReferencedVirtualElement:i,onNodeChange:a,onElementDragStart:o,onElementDragEnd:s,nestedOptions:c})=>{let l=document.createElement(`div`),u=!1,d=null,f=-1,p,m=null,h=null;function g(){t&&(t.style.visibility=`hidden`,t.style.pointerEvents=`none`)}function _(){if(t){if(!n.isEditable){g();return}t.style.visibility=``,t.style.pointerEvents=`auto`}}function v(e){$r(i?.()||{getBoundingClientRect:()=>e.getBoundingClientRect()},t,r).then(e=>{Object.assign(t.style,{position:e.strategy,left:`${e.x}px`,top:`${e.y}px`})})}function y(e){o?.(e),AD(e,n,c,{node:d,pos:f}),t&&(t.dataset.dragging=`true`),setTimeout(()=>{t&&(t.style.pointerEvents=`none`)},0)}function b(e){s?.(e),g(),t&&(t.style.pointerEvents=`auto`,t.dataset.dragging=`false`)}function x(){if(st()){let e=n.view.dom;requestAnimationFrame(()=>{e.isContentEditable&&(e.contentEditable=`false`,e.contentEditable=`true`)})}}return l.appendChild(t),{unbind(){t.removeEventListener(`dragstart`,y),t.removeEventListener(`dragend`,b),document.removeEventListener(`drop`,x),m&&(cancelAnimationFrame(m),m=null,h=null)},plugin:new Et({key:typeof e==`string`?new ke(e):e,state:{init(){return{locked:!1}},apply(e,r,i,o){let s=e.getMeta(`lockDragHandle`),c=e.getMeta(`hideDragHandle`);if(s!==void 0&&(u=s),c)return g(),u=!1,d=null,f=-1,a?.({editor:n,node:null,pos:-1}),r;if(e.docChanged&&f!==-1&&t)if($E(e)){let e=PD(o,p);e!==f&&(f=e)}else{let t=e.mapping.map(f);t!==f&&(f=t,p=ND(o,f))}return r}},view:e=>{var r;return t.draggable=!0,t.style.pointerEvents=`auto`,t.dataset.dragging=`false`,(r=n.view.dom.parentElement)==null||r.appendChild(l),l.style.pointerEvents=`none`,l.style.position=`absolute`,l.style.top=`0`,l.style.left=`0`,t.addEventListener(`dragstart`,y),t.addEventListener(`dragend`,b),document.addEventListener(`drop`,x),{update(r,i){if(!t)return;if(!n.isEditable){g();return}if(u?t.draggable=!1:t.draggable=!0,e.state.doc.eq(i.doc)||f===-1)return;let o=e.nodeDOM(f);if(o=FD(e,o),o===e.dom||o?.nodeType!==1)return;let s=e.posAtDOM(o,0),c=MD(n.state.doc,s),l=jD(n.state.doc,s);d=c,f=l,p=ND(e.state,f),a?.({editor:n,node:d,pos:f}),v(o)},destroy(){t.removeEventListener(`dragstart`,y),t.removeEventListener(`dragend`,b),document.removeEventListener(`drop`,x),m&&(cancelAnimationFrame(m),m=null,h=null),t&&OD(l)}}},props:{handleDOMEvents:{keydown(e){return!t||u?!1:e.hasFocus()?(g(),d=null,f=-1,a?.({editor:n,node:null,pos:-1}),!1):!1},mouseleave(e,t){return u||t.target&&!l.contains(t.relatedTarget)&&(g(),d=null,f=-1,a?.({editor:n,node:null,pos:-1})),!1},mousemove(e,r){return!t||u||(h={x:r.clientX,y:r.clientY},m)||(m=requestAnimationFrame(()=>{if(m=null,!h)return;let{x:t,y:r}=h;h=null;let i=ED({x:t,y:r,direction:`right`,editor:n,nestedOptions:c});if(!i.resultElement)return;let o=i.resultElement,s=i.resultNode,l=i.pos;if(!c?.enabled){if(o=FD(e,o),o===e.dom||o?.nodeType!==1)return;let t=e.posAtDOM(o,0);s=MD(n.state.doc,t),l=jD(n.state.doc,t)}s!==d&&(d=s,f=l??-1,p=ND(e.state,f),a?.({editor:n,node:d,pos:f}),v(o),_())})),!1}}}})}};function RD(e){return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:gD(`none`)}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:gD(`left`)}:{enabled:!0,rules:e.rules??[],defaultRules:e.defaultRules??!0,allowedContainers:e.allowedContainers,edgeDetection:gD(e.edgeDetection)}}var zD={placement:`left-start`,strategy:`absolute`};Y.create({name:`dragHandle`,addOptions(){return{render(){let e=document.createElement(`div`);return e.classList.add(`drag-handle`),e},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1}},addCommands(){return{lockDragHandle:()=>({editor:e})=>(this.options.locked=!0,e.commands.setMeta(`lockDragHandle`,this.options.locked)),unlockDragHandle:()=>({editor:e})=>(this.options.locked=!1,e.commands.setMeta(`lockDragHandle`,this.options.locked)),toggleDragHandle:()=>({editor:e})=>(this.options.locked=!this.options.locked,e.commands.setMeta(`lockDragHandle`,this.options.locked))}},addProseMirrorPlugins(){let e=this.options.render(),t=RD(this.options.nested);return[LD({computePositionConfig:{...zD,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:e,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:t}).plugin]}});var BD=20,VD=44,HD=28;function UD(e){if(!e)return`Select block`;if(e.type.name===`jsxComponent`){let t=e.attrs.componentName??``;if(t){let e=rb(t),n=e.name===`*`?t:e.displayName??e.name;if(n)return`Select ${n}`}}return`Select ${e.type.name}`}function WD(){let e=document.createElement(`div`);e.className=`ok-block-controls`,e.setAttribute(dC,`true`),e.style.visibility=`hidden`;let t=document.createElement(`button`);t.className=`ok-add-block-btn`,t.setAttribute(`aria-label`,`Add block below`),t.setAttribute(`type`,`button`),t.innerHTML=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus"><path d="M5 12h14"/><path d="M12 5v14"/></svg>`,t.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()});let n=document.createElement(`button`);return n.className=`ok-drag-grip`,n.setAttribute(`type`,`button`),n.setAttribute(`aria-label`,`Select block`),n.setAttribute(`tabindex`,`-1`),n.innerHTML=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-grip-vertical-icon lucide-grip-vertical"><circle cx="9" cy="12" r="1"/><circle cx="9" cy="5" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="19" r="1"/></svg>`,e.appendChild(t),e.appendChild(n),{container:e,addBtn:t,grip:n}}function GD(e,t,n){let{state:r,view:i}=e;if(n.type.name===`jsxComponent`){let i=n.attrs.componentName??``;if(i){let a=rb(i);if(a.emptyChildName){let i=t+1+n.content.size;if(i>r.doc.content.size)return;let o=a.emptyChildName;e.chain().focus().insertContentAt(i,lb(o)).run(),pb(e,i,rb(o));return}}}let a=t+n.nodeSize;if(a>r.doc.content.size)return;let{tr:o}=r,s=r.schema.nodes.paragraph?.create();if(!s)return;o.insert(a,s);let c=y.near(o.doc.resolve(a+1));o.setSelection(c).scrollIntoView(),i.dispatch(o),i.focus(),e.commands.insertContent(`/`)}var KD=Y.create({name:`blockDragHandle`,addProseMirrorPlugins(){let e=this.editor,t=null,n=-1,{container:r,addBtn:i,grip:a}=WD();return i.addEventListener(`click`,()=>{t&&n>=0&&GD(e,n,t)}),a.addEventListener(`click`,()=>{if(n<0)return;let r=t,i=r?.type.name??`unknown`;try{e.chain().focus().setNodeSelection(n).run()||(H(i),console.warn(JSON.stringify({event:`block-grip-click-select-failed`,nodeType:i,componentName:String(r?.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){if(!(e instanceof RangeError))throw e;H(i),console.warn(JSON.stringify({event:`block-grip-click-select-failed`,nodeType:i,componentName:String(r?.attrs.componentName??``).slice(0,200),reason:e.message.slice(0,500)}))}}),[LD({element:r,editor:e,onNodeChange({node:e,pos:r}){t=e,n=r??-1,a.setAttribute(`aria-label`,UD(e))},computePositionConfig:{placement:`left-start`,strategy:`absolute`,middleware:[ei(({rects:e})=>({mainAxis:10,crossAxis:((e.reference.height<=VD?e.reference.height:HD)-BD)/2}))]},nestedOptions:RD(!1)}).plugin]}}),qD=/^#fn(?:ref)?-/,JD=Y.create({name:`footnoteAnchorScroll`,addProseMirrorPlugins(){return[new Et({props:{handleDOMEvents:{click(e,t){let n=t.target;if(!(n instanceof Element))return!1;let r=n.closest(`a[href^="#fn"]`);if(!(r instanceof HTMLAnchorElement))return!1;let i=r.getAttribute(`href`)??``;if(!qD.test(i))return!1;let a=i.slice(1);t.preventDefault();let o=e.dom.ownerDocument.getElementById(a);return o&&o.scrollIntoView({behavior:`smooth`,block:`start`}),!0}}}})]}}),YD=Y.create({name:`formattingShortcuts`,addKeyboardShortcuts(){return{"Mod-Shift-x":()=>this.editor.commands.toggleStrike()}}}),XD=Y.create({name:`headingAnchors`,addProseMirrorPlugins(){return[new Et({props:{decorations(e){let t=[],n=new Map;return e.doc.descendants((e,r)=>{if(e.type.name===`heading`){let i=ce(e.textContent,n);if(!i)return;t.push(rt.node(r,r+e.nodeSize,{id:i}))}}),Ue.create(e.doc,t)}}})]}});function ZD(e){let t=(0,$.c)(8),{node:n,editor:r}=e,i=n.attrs.src,a=n.attrs.alt,o=n.attrs.title,s;if(t[0]!==r||t[1]!==i){let e=r?Yt(r)??void 0:void 0;s=typeof i==`string`?le(Ke(i,e)):void 0,t[0]=r,t[1]=i,t[2]=s}else s=t[2];let c=s,l=typeof a==`string`?a:``,u=typeof o==`string`?o:void 0,d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d={sizes:void 0},t[3]=d):d=t[3];let f;return t[4]!==l||t[5]!==c||t[6]!==u?(f=(0,Z.jsx)(Dn,{as:`span`,"data-image-inline-zoom":!0,"data-clipboard-inline-leaf":`image`,children:(0,Z.jsx)(Y_,{wrapElement:`span`,zoomMargin:20,zoomImg:d,children:(0,Z.jsx)(`img`,{src:c,alt:l,title:u})})}),t[4]=l,t[5]=c,t[6]=u,t[7]=f):f=t[7],f}var QD=g.extend({addNodeView(){return bn(ZD)}});function $D(e,t){let n=e;for(;n&&typeof n.hasAttribute==`function`;){if(n.hasAttribute(`data-wiki-embed`)){let e=n.getAttribute(`data-target`)??``;if(!e)return null;let r=He(e,t);return r?{kind:n.tagName===`IMG`?`image`:`asset`,relPath:r,title:r.split(`/`).pop()??e}:null}if(n.hasAttribute(`data-wiki-link`)){let e=n.getAttribute(`data-target`)??``;return e?{kind:`wiki-link`,relPath:`${e}.md`,title:e}:null}if(n.tagName===`A`&&n.hasAttribute(`href`)){let e=R(n.getAttribute(`href`)??``,t);if(e?.kind===`asset`){let n=He(e.url,t);return n?{kind:`asset`,relPath:n,title:n.split(`/`).pop()??e.url}:null}}if(n.tagName===`IMG`){let e=n.getAttribute(`src`)??``;if(e){let n=R(e,t);if(n?.kind===`asset`){let e=He(n.url,t);return e?{kind:`image`,relPath:e,title:e.split(`/`).pop()??n.url}:null}}}n=n.parentElement}return null}var eO=new ke(`asset-context-menu`);function tO(e){return new Et({key:eO,view(t){let n=e.showAssetMenu??(e=>{let t=globalThis.window?.okDesktop;return t?t.shell.showAssetMenu({relPath:e.relPath,title:e.title,kind:e.kind}):Promise.resolve()}),r=t=>{if(!(t.target instanceof Element))return;let r=$D(t.target,e.sourceDocName);r&&(t.preventDefault(),n(r))};return t.dom.addEventListener(`contextmenu`,r),{destroy(){t.dom.removeEventListener(`contextmenu`,r)}}}})}var nO=e=>{let t=(0,$.c)(18),{kind:n,ariaLabel:r,onDeactivate:i,children:a,triggerReference:o,layout:s,className:c,"data-slot":l}=e,u=s===void 0?`standard`:s,d=(0,Q.useRef)(null),f,p;t[0]===o?(f=t[1],p=t[2]):(f=()=>{let e=d.current;if(e)return ti(o,e,()=>{let t=o.getBoundingClientRect();e.isConnected&&(e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`)})},p=[o],t[0]=o,t[1]=f,t[2]=p),(0,Q.useLayoutEffect)(f,p);let m;t[3]===i?m=t[4]:(m=e=>{e||i()},t[3]=i,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(ju,{asChild:!0,children:(0,Z.jsx)(`span`,{ref:d,"aria-hidden":`true`,style:{position:`fixed`,pointerEvents:`none`,left:`-9999px`,top:`-9999px`,width:0,height:0}})}),t[5]=h):h=t[5];let g=u===`wide`?`w-[min(720px,calc(100%-1rem))]`:`w-80`,_;t[6]!==c||t[7]!==g?(_=Ft(`ok-interaction-prop-panel pointer-events-auto p-3`,g,c),t[6]=c,t[7]=g,t[8]=_):_=t[8];let v;t[9]!==r||t[10]!==a||t[11]!==l||t[12]!==n||t[13]!==_?(v=(0,Z.jsx)(Au,{side:`bottom`,align:`start`,sideOffset:8,collisionPadding:8,"aria-label":r,"data-ok-prop-panel":n,"data-slot":l,onOpenAutoFocus:rO,onCloseAutoFocus:iO,onPointerDownOutside:aO,onFocusOutside:oO,onInteractOutside:sO,className:_,children:a}),t[9]=r,t[10]=a,t[11]=l,t[12]=n,t[13]=_,t[14]=v):v=t[14];let y;return t[15]!==m||t[16]!==v?(y=(0,Z.jsxs)(Ou,{open:!0,onOpenChange:m,children:[h,v]}),t[15]=m,t[16]=v,t[17]=y):y=t[17],y};function rO(e){return e.preventDefault()}function iO(e){return e.preventDefault()}function aO(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function oO(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function sO(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function cO(e){let t=e.trim();return/\.(md|mdx)$/i.test(t)?t:`${t}.md`}function lO(e){let t=e.initialDir.trim().replace(/^\/+|\/+$/g,``),n=cO(e.suggestedName);return t?`${t}/${n}`:n}async function uO(e){let t=await Mu(await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),`Failed to create page`);if(!t.ok)throw Error(t.title);let n=e.replace(/\.(mdx|md)$/i,``);return{docName:Nu(q,t.body,`create-page`,{docName:n}).docName}}async function dO(e){return uO(lO(e))}async function fO(e,t){let{docName:n}=await dO(e);return t.addPage(n),ui([`files`,`backlinks`,`graph`]),t.onCreated?.(n),{docName:n}}var pO=8;function mO(e){return e.trim().replace(/^\/+/,``).replace(/\.mdx?$/i,``).replace(/\/+$/g,``)}function hO(e){return gO(e)?mO(e.slice(1)).toLowerCase():null}function gO(e){return e.startsWith(`/`)&&!e.startsWith(`//`)}function _O(e){return e.split(`/`).at(-1)??e}function vO(e,t){if(!t)return 0;let n=e.toLowerCase(),r=_O(e).toLowerCase();return n===t?0:r===t?1:n.startsWith(t)?2:r.startsWith(t)?3:r.includes(t)?4:n.includes(t)?5:null}function yO(e){switch(e){case`page`:return 0;case`folder`:return 1;case`asset`:return 2}}function bO(e){let t=[],n=new Set;function r(e,r){let i=mO(r);if(!i)return;let a=`${e}:${i.toLowerCase()}`;n.has(a)||(n.add(a),t.push({kind:e,path:i}))}for(let t of e.pages)r(`page`,t);for(let t of e.folderPaths??[])r(`folder`,t);if(e.includeAssets)for(let t of e.assetPaths??[])r(`asset`,t);return t}function xO(e){let t=hO(e.value);if(t===null)return[];let n=[];for(let r of bO(e)){let e=vO(r.path,t);e!==null&&n.push({suggestion:r,score:e})}return n.sort((e,t)=>{if(e.score!==t.score)return e.score-t.score;let n=yO(e.suggestion.kind)-yO(t.suggestion.kind);return n===0?e.suggestion.path.localeCompare(t.suggestion.path):n}),n.slice(0,e.limit??pO).map(e=>e.suggestion)}var SO=`[data-ok-link-path-suggestion-panel]`;function CO(e){return e instanceof Element&&e.closest(SO)!==null}function wO(e){CO(e.target)&&e.preventDefault()}function TO(e){switch(e.kind){case`page`:return(0,Z.jsx)(Sl,{className:`size-3.5`,docExt:`.md`,kind:`file`,path:e.path});case`folder`:return(0,Z.jsx)(Sl,{className:`size-3.5`,kind:`folder`,path:e.path});case`asset`:return(0,Z.jsx)(Sl,{bodyIndexed:!1,className:`size-3.5`,kind:`file`,path:e.path})}}function EO(e,t){if(e){if(typeof e==`function`){e(t);return}e.current=t}}function DO(e){let t=(0,$.c)(54),n,r,i,a,o,c,l,u,d,f,p,m,h,g;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14]):({value:g,pages:f,folderPaths:i,assetPaths:n,includeAssets:m,loading:h,onValueChange:d,onKeyDown:l,onSuggestionSelect:u,onFocus:c,onBlur:o,className:r,ref:p,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g);let _=m===void 0?!1:m,v=h===void 0?!1:h,{_:y}=s(),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=(0,Q.useId)(),k;t[15]===g?k=t[16]:(k=g.trim(),t[15]=g,t[16]=k);let A=k===``,j=xO({value:A?`/`:g,pages:f,folderPaths:i,assetPaths:n,includeAssets:_}),M=j.map(MO).join(`\0`),N;t[17]===g?N=t[18]:(N=gO(g),t[17]=g,t[18]=N);let P=A||N,F=j.length>0,I=b&&!S&&P&&(F||v),L=I||b&&!S&&P&&!v&&!F,R=Math.min(w,Math.max(j.length-1,0)),ee=F?`${O}-option-${R}`:void 0,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>{T(0)},t[19]=z):z=t[19],(0,Q.useEffect)(z,[M]);let te,ne;t[20]!==ee||t[21]!==L?(te=()=>{!L||!ee||document.getElementById(ee)?.scrollIntoView?.({block:`nearest`})},ne=[ee,L],t[20]=ee,t[21]=L,t[22]=te,t[23]=ne):(te=t[22],ne=t[23]),(0,Q.useEffect)(te,ne);let re,B;t[24]===L?(re=t[25],B=t[26]):(re=()=>{if(!L)return;let e=E.current,t=D.current;if(!e||!t)return;let n=e,r=t,i=function(){$r(n,r,{placement:`bottom-start`,strategy:`fixed`,middleware:[ei(4),Zr({padding:8}),ni({padding:8}),Qr({padding:8,apply(e){let{availableHeight:t,availableWidth:n,elements:r}=e;Object.assign(r.floating.style,{width:`${Math.min(480,n)}px`,maxHeight:`${Math.min(208,Math.max(96,t))}px`})}})]}).then(e=>{let{x:t,y:n}=e;r.isConnected&&Object.assign(r.style,{left:`${t}px`,top:`${n}px`})}).catch(e=>{r.isConnected&&console.warn(`[LinkPathSuggestionInput] computePosition failed`,e)})},a=ti(n,r,i);return i(),a},B=[L],t[24]=L,t[25]=re,t[26]=B),(0,Q.useLayoutEffect)(re,B);let V;t[27]===p?V=t[28]:(V=function(e){E.current=e,EO(p,e)},t[27]=p,t[28]=V);let H=V,U=function(e){u?u(e):d(e.path),C(!0),requestAnimationFrame(()=>E.current?.focus())},W=function(e){if(I&&F){if(e.key===`ArrowDown`){e.preventDefault(),T(e=>Math.min(e+1,j.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),T(jO);return}if(e.key===`Enter`){e.preventDefault();let t=j[R];t&&U(t);return}if(e.key===`Escape`){e.preventDefault(),C(!0);return}}if(L&&e.key===`Escape`){e.preventDefault(),C(!0);return}l?.(e)},G;t[29]===y?G=t[30]:(G=function(e){switch(e){case`page`:return y({id:`6WdDG7`});case`folder`:return y({id:`kNqMMd`});case`asset`:return y({id:`bUUVED`})}},t[29]=y,t[30]=G);let ie=G,K=L?(0,Z.jsx)(`div`,{ref:D,id:O,role:`listbox`,"aria-label":y({id:`mBltnd`}),"data-ok-layer-spawned":``,"data-ok-link-path-suggestion-panel":``,className:`fixed z-70 max-h-52 overflow-y-auto overscroll-y-contain rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md subtle-scrollbar pointer-events-auto`,onWheel:AO,onTouchMove:kO,children:F?j.map((e,t)=>{let n=t===R,r=ie(e.kind);return(0,Z.jsxs)(zt,{id:`${O}-option-${t}`,type:`button`,role:`option`,"aria-label":`/${e.path} ${r}`,"aria-selected":n,variant:`ghost`,className:Ft(`h-auto w-full justify-start gap-2 rounded-sm px-2 py-1.5 text-left font-normal`,n&&`bg-accent text-accent-foreground`),onMouseDown:OO,onClick:()=>U(e),children:[TO(e),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`/`,e.path]}),(0,Z.jsx)(`span`,{className:`shrink-0 text-muted-foreground text-xs`,children:r})]},`${e.kind}:${e.path}`)}):(0,Z.jsx)(`div`,{role:`status`,className:`px-2 py-1.5 text-muted-foreground text-sm`,children:y(v?{id:`sxTdZI`}:{id:`_QwkMu`})})}):null,ae;t[31]===d?ae=t[32]:(ae=e=>{C(!1),d(e.target.value)},t[31]=d,t[32]=ae);let oe;t[33]===c?oe=t[34]:(oe=e=>{x(!0),c?.(e)},t[33]=c,t[34]=oe);let q;t[35]===o?q=t[36]:(q=e=>{x(!1),o?.(e)},t[35]=o,t[36]=q);let se=L?O:void 0,ce;t[37]!==ee||t[38]!==r||t[39]!==W||t[40]!==a||t[41]!==H||t[42]!==L||t[43]!==ae||t[44]!==oe||t[45]!==q||t[46]!==se||t[47]!==g?(ce=(0,Z.jsx)(ri,{...a,ref:H,value:g,onChange:ae,onFocus:oe,onBlur:q,onKeyDown:W,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":L,"aria-controls":se,"aria-activedescendant":ee,autoComplete:`off`,className:r}),t[37]=ee,t[38]=r,t[39]=W,t[40]=a,t[41]=H,t[42]=L,t[43]=ae,t[44]=oe,t[45]=q,t[46]=se,t[47]=g,t[48]=ce):ce=t[48];let J;t[49]===K?J=t[50]:(J=K&&(0,Io.createPortal)(K,document.body),t[49]=K,t[50]=J);let le;return t[51]!==ce||t[52]!==J?(le=(0,Z.jsxs)(`div`,{className:`relative`,children:[ce,J]}),t[51]=ce,t[52]=J,t[53]=le):le=t[53],le}function OO(e){return e.preventDefault()}function kO(e){e.stopPropagation()}function AO(e){e.stopPropagation()}function jO(e){return Math.max(e-1,0)}function MO(e){return`${e.kind}:${e.path}`}var NO=1500;async function PO(e){if(typeof navigator>`u`||!navigator.clipboard?.writeText)throw Error(`clipboard unavailable`);await navigator.clipboard.writeText(e)}function FO(e){let t=(0,$.c)(20),{copyContent:n,clipboardWrite:r,initialCopied:i}=e,a=r===void 0?PO:r,o=i===void 0?!1:i,{_:c}=s(),[l,u]=(0,Q.useState)(+!!o),d=l>0,f,p;t[0]===l?(f=t[1],p=t[2]):(f=()=>{if(l===0)return;let e=setTimeout(()=>u(0),NO);return()=>clearTimeout(e)},p=[l],t[0]=l,t[1]=f,t[2]=p),(0,Q.useEffect)(f,p);let m;t[3]!==a||t[4]!==n?(m=()=>{Promise.resolve().then(()=>a(n)).then(()=>u(LO),IO)},t[3]=a,t[4]=n,t[5]=m):m=t[5];let h=m,g;t[6]!==c||t[7]!==d?(g=c(d?{id:`PiH3UR`}:{id:`he3ygx`}),t[6]=c,t[7]=d,t[8]=g):g=t[8];let _=g,v;t[9]===d?v=t[10]:(v=d?(0,Z.jsx)(Bn,{className:`size-3.5`,"aria-hidden":`true`}):(0,Z.jsx)(Jn,{className:`size-3.5`,"aria-hidden":`true`}),t[9]=d,t[10]=v);let y;t[11]!==h||t[12]!==_||t[13]!==v?(y=(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":_,onClick:h,children:v})}),t[11]=h,t[12]=_,t[13]=v,t[14]=y):y=t[14];let b;t[15]===_?b=t[16]:(b=(0,Z.jsx)(xr,{children:_}),t[15]=_,t[16]=b);let x;return t[17]!==y||t[18]!==b?(x=(0,Z.jsxs)(Sr,{children:[y,b]}),t[17]=y,t[18]=b,t[19]=x):x=t[19],x}function IO(){}function LO(e){return e+1}function RO(e,t){return Ag.getState(e)?.byId.get(t)??null}function zO(e){let{editor:t,layer:n,renderPropPanel:r,handlePrimary:i}=e;return{onRegister:e=>{n.register({type:e.markType,nodeId:e.id,controls:{propPanel:e=>r({editor:t,nodeId:e.nodeId,deactivate:e.deactivate})},handlePrimary:i?e=>i({editor:t,nodeId:e.nodeId,newTab:e.newTab}):void 0})},onDeregister:e=>{n.deregister(e)}}}function BO(e){let{editor:t,layer:n,markTypes:r,predicate:i,renderPropPanel:a,handlePrimary:o}=e,s=zO({editor:t,layer:n,renderPropPanel:a,handlePrimary:o});return Ig({markTypes:[...r],predicate:i,onRegister:s.onRegister,onDeregister:s.onDeregister})}function VO(e){let t=Xg(e.editor);return BO({...e,layer:t})}function HO(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(null),a,o;return n[0]!==e||n[1]!==t?(a=()=>{if(!t||!e){i(null);return}let n=!1;return i(null),pn(e).then(e=>{n||i(e)}).catch(()=>{n||i([])}),()=>{n=!0}},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function UO(e,t){let n=e.trim();return n?n.startsWith(`#`)?`anchor`:A(n)?`external`:`doc`:t}function WO(e){return e?.kind===`doc`?`doc`:e?.kind===`anchor`?`anchor`:`external`}function GO(e){let t=(0,$.c)(84),{open:n,href:r,text:i,pages:a,folderPaths:c,loading:l,onOpenChange:u,onSave:d}=e,[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(`doc`),b=(0,Q.useId)(),x=(0,Q.useId)(),S=(0,Q.useId)(),C=(0,Q.useId)(),{_:w}=s(),T=(0,Q.useRef)(!1),E=(0,Q.useRef)(``),D,O;t[0]!==r||t[1]!==n||t[2]!==i?(D=()=>{if(!n){T.current=!1;return}if(T.current)return;T.current=!0,E.current=i,_(i);let e=yn(r);if(y(WO(e)),e?.kind===`doc`){p(e.docName),h(e.anchor??``);return}if(e?.kind===`anchor`){p(`#${e.anchor}`),h(``);return}p(e?.kind===`external`?e.url:r),h(``)},O=[n,r,i],t[0]=r,t[1]=n,t[2]=i,t[3]=D,t[4]=O):(D=t[3],O=t[4]),(0,Q.useEffect)(D,O);let k,A,j;t[5]!==v||t[6]!==f||t[7]!==a?(k=gi(f),A=v===`doc`,j=A&&rn(k,a),t[5]=v,t[6]=f,t[7]=a,t[8]=k,t[9]=A,t[10]=j):(k=t[8],A=t[9],j=t[10]);let M=HO(k,j&&n),N=!!M?.length,P;t[11]!==k||t[12]!==A||t[13]!==m||t[14]!==g||t[15]!==f||t[16]!==u||t[17]!==d?(P=function(){let e=f.trim();e&&(d(A?wn(k,m.trim()||null):e,g,g.trim()!==E.current.trim()),u(!1))},t[11]=k,t[12]=A,t[13]=m,t[14]=g,t[15]=f,t[16]=u,t[17]=d,t[18]=P):P=t[18];let F=P,I;t[19]===F?I=t[20]:(I=function(e){e.key===`Enter`&&(e.preventDefault(),F())},t[19]=F,t[20]=I);let L=I,R;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(R=function(e){p(e.path),y(`doc`),h(``)},t[21]=R):R=t[21];let ee=R,z;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(kr,{children:(0,Z.jsx)(o,{id:`B11p-O`})}),t[22]=z):z=t[22];let te;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsxs)(Vr,{children:[z,(0,Z.jsx)(Or,{children:(0,Z.jsx)(o,{id:`RobAKV`})})]}),t[23]=te):te=t[23];let ne;t[24]===A?ne=t[25]:(ne=A?(0,Z.jsx)(o,{id:`6WdDG7`}):(0,Z.jsx)(o,{id:`6vEr3W`}),t[24]=A,t[25]=ne);let re;t[26]!==ne||t[27]!==b?(re=(0,Z.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:b,children:ne}),t[26]=ne,t[27]=b,t[28]=re):re=t[28];let B;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{p(e),y(t=>UO(e,t))},t[29]=B):B=t[29];let V;t[30]===w?V=t[31]:(V=w({id:`Xl-UUg`}),t[30]=w,t[31]=V);let H;t[32]!==f||t[33]!==c||t[34]!==L||t[35]!==l||t[36]!==a||t[37]!==V||t[38]!==b?(H=(0,Z.jsx)(DO,{id:b,value:f,pages:a,folderPaths:c,loading:l,onValueChange:B,onSuggestionSelect:ee,placeholder:V,autoFocus:!0,onKeyDown:L}),t[32]=f,t[33]=c,t[34]=L,t[35]=l,t[36]=a,t[37]=V,t[38]=b,t[39]=H):H=t[39];let U;t[40]!==re||t[41]!==H?(U=(0,Z.jsxs)(`div`,{children:[re,H]}),t[40]=re,t[41]=H,t[42]=U):U=t[42];let W;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.jsx)(o,{id:`QqBQu1`,components:{0:(0,Z.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[43]=W):W=t[43];let G;t[44]===S?G=t[45]:(G=(0,Z.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:S,children:W}),t[44]=S,t[45]=G);let ie;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>_(e.target.value),t[46]=ie):ie=t[46];let K;t[47]===w?K=t[48]:(K=w({id:`yYR6za`}),t[47]=w,t[48]=K);let ae;t[49]!==g||t[50]!==L||t[51]!==S||t[52]!==K?(ae=(0,Z.jsx)(ri,{id:S,value:g,onChange:ie,placeholder:K,onKeyDown:L}),t[49]=g,t[50]=L,t[51]=S,t[52]=K,t[53]=ae):ae=t[53];let oe;t[54]!==G||t[55]!==ae?(oe=(0,Z.jsxs)(`div`,{children:[G,ae]}),t[54]=G,t[55]=ae,t[56]=oe):oe=t[56];let q;t[57]!==w||t[58]!==x||t[59]!==A||t[60]!==m||t[61]!==L||t[62]!==C||t[63]!==M||t[64]!==N?(q=A?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:x,children:(0,Z.jsx)(o,{id:`Tjc1pH`,components:{0:(0,Z.jsx)(`span`,{className:`font-normal text-muted-foreground`})}})}),(0,Z.jsx)(ri,{id:x,value:m,onChange:e=>h(e.target.value),placeholder:w({id:`W-ntoW`}),onKeyDown:L}),N?(0,Z.jsx)(`div`,{id:C,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:M.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":m===e.slug,className:Ft(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,m===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>h(m===e.slug?``:e.slug),children:[(0,Z.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.text})]},`${e.slug}-${e.level}-${e.text}`))}):null]}):null,t[57]=w,t[58]=x,t[59]=A,t[60]=m,t[61]=L,t[62]=C,t[63]=M,t[64]=N,t[65]=q):q=t[65];let se;t[66]!==U||t[67]!==oe||t[68]!==q?(se=(0,Z.jsxs)(Lr,{className:`space-y-6 pb-1`,children:[U,oe,q]}),t[66]=U,t[67]=oe,t[68]=q,t[69]=se):se=t[69];let ce;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(Br,{asChild:!0,children:(0,Z.jsx)(zt,{variant:`outline`,children:(0,Z.jsx)(o,{id:`dEgA5A`})})}),t[70]=ce):ce=t[70];let J;t[71]===f?J=t[72]:(J=f.trim(),t[71]=f,t[72]=J);let le=!J,ue;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Z.jsx)(o,{id:`tfDRzk`}),t[73]=ue):ue=t[73];let Y;t[74]!==F||t[75]!==le?(Y=(0,Z.jsxs)(Rr,{children:[ce,(0,Z.jsx)(zt,{onClick:F,disabled:le,children:ue})]}),t[74]=F,t[75]=le,t[76]=Y):Y=t[76];let de;t[77]!==se||t[78]!==Y?(de=(0,Z.jsxs)(Pr,{className:`sm:max-w-xl`,"data-ok-layer-spawned":``,onPointerDownOutside:wO,onFocusOutside:wO,onInteractOutside:wO,children:[te,se,Y]}),t[77]=se,t[78]=Y,t[79]=de):de=t[79];let fe;return t[80]!==u||t[81]!==n||t[82]!==de?(fe=(0,Z.jsx)(Hr,{open:n,onOpenChange:u,children:de}),t[80]=u,t[81]=n,t[82]=de,t[83]=fe):fe=t[83],fe}function KO(e){let t=(0,$.c)(99),{editor:n,nodeId:r,sourceDocName:i,onClose:a,onNavigate:c}=e,l=RO(n.state,r),u=l?.attrs?.href??``,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h;t[0]!==r||t[1]!==f?(h=()=>{kg(r)&&f(!0)},t[0]=r,t[1]=f,t[2]=h):h=t[2];let g;t[3]===r?g=t[4]:(g=[r],t[3]=r,t[4]=g),(0,Q.useEffect)(h,g);let{addPage:_,folderPaths:v,pages:y,loading:b}=Wn(),{_:x}=s();if(!l)return null;let S=n.state.doc.textBetween(l.from,l.to),C=u?R(u,i):null,w;t[5]!==n||t[6]!==r?(w=function(e,t,i){let a=RO(n.state,r);if(!a)return;let o=t.trim();if(!i||!o){n.chain().setTextSelection({from:a.from,to:a.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:e}).run();return}let s=n.schema.marks.link;if(!s)return;let c=s.create({href:e}),l=n.schema.text(o,[c]);n.view.dispatch(n.state.tr.replaceWith(a.from,a.to,l))},t[5]=n,t[6]=r,t[7]=w):w=t[7];let T=w,E;t[8]!==n||t[9]!==r||t[10]!==a?(E=function(){let e=RO(n.state,r);e&&(n.chain().focus().setTextSelection({from:e.from,to:e.to}).extendMarkRange(`link`).unsetLink().run(),a())},t[8]=n,t[9]=r,t[10]=a,t[11]=E):E=t[11];let D=E,O;t[12]!==n||t[13]!==r||t[14]!==a||t[15]!==f?(O=function(e){if(e){f(!0);return}let t=RO(n.state,r);if(t?.attrs?.href??``){f(!1);return}t&&n.chain().focus().deleteRange({from:t.from,to:t.to}).run(),a()},t[12]=n,t[13]=r,t[14]=a,t[15]=f,t[16]=O):O=t[16];let k=(0,Z.jsx)(GO,{open:d,href:u,text:S,pages:y,folderPaths:v,loading:b,onOpenChange:u?f:O,onSave:T});if(!u)return(0,Z.jsx)(Z.Fragment,{children:k});let A=C?.kind===`doc`?`${C.docName}${C.anchor?`#${C.anchor}`:``}`:C?.kind===`anchor`?`#${C.anchor}`:C?.kind===`external`?C.url:u,j=function(e){let t=RO(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:wn(e,C?.kind===`doc`?C.anchor??null:null)}).run()},M,N=!1,P=!1,F=null;if(b){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ir,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[17]=e):e=t[17],M={icon:e,text:x({id:`yQE2r9`}),className:`text-muted-foreground/80`}}else if(C?.kind===`asset`){let e;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(eo,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[18]=e):e=t[18],M={icon:e,text:x({id:`yWWThY`}),className:`text-muted-foreground`}}else if(C?.kind===`external`){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Un,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[19]=e):e=t[19],M={icon:e,text:x({id:`zgSFyG`}),className:`text-muted-foreground`}}else if(C?.kind===`anchor`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(eo,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[20]=e):e=t[20],M={icon:e,text:x({id:`dprWmL`}),className:`text-muted-foreground`}}else if(C?.kind===`doc`){let e=In(C.docName,{pages:y,folderPaths:v});if(P=e.kind===`navigate`&&e.displayState===`folder`,N=e.kind===`create`,F=e.kind===`create`?{initialDir:e.initialDir,suggestedName:e.suggestedName}:null,P){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(tr,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[21]=e):e=t[21],M={icon:e,text:x({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(N){let e;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ua,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[22]=e):e=t[22],M={icon:e,text:x({id:`8F1i42`}),className:`text-red-700 dark:text-red-300`}}else{let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(eo,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[23]=e):e=t[23],M={icon:e,text:x({id:`JtD-Br`}),className:`text-muted-foreground`}}}else{let e;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ua,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[24]=e):e=t[24],M={icon:e,text:x({id:`-g6KIS`}),className:`text-muted-foreground/80`}}let I=C?.kind===`external`,L=C?.kind===`doc`?Ln({docName:C.docName,anchor:C.anchor}):C?.kind===`anchor`?Ln({docName:i,anchor:C.anchor}):C?.kind===`external`&&fn(C.url)?C.url:null,ee=!b&&L!==null&&(C?.kind===`anchor`||C?.kind===`external`||C?.kind===`doc`&&!N&&!P),z;t[25]!==n.state||t[26]!==n.view||t[27]!==r?(z=()=>{let e=RO(n.state,r);if(!e)return new DOMRect;try{return _t(n.view,e.from,e.to)}catch{return new DOMRect}},t[25]=n.state,t[26]=n.view,t[27]=r,t[28]=z):z=t[28];let te;t[29]!==n.view.dom||t[30]!==z?(te={getBoundingClientRect:z,contextElement:n.view.dom},t[29]=n.view.dom,t[30]=z,t[31]=te):te=t[31];let ne=te,re;t[32]!==x||t[33]!==_||t[34]!==p||t[35]!==F||t[36]!==a||t[37]!==j?(re=async function(){if(!(!F||p)){m(!0);try{await fO(F,{addPage:_,onCreated(e){j(e),window.location.hash=`#/${e}`,a()}}),m(!1)}catch(e){let t=e;sr.error(t instanceof Error?t.message:x({id:`tfi40B`})),m(!1)}}},t[32]=x,t[33]=_,t[34]=p,t[35]=F,t[36]=a,t[37]=j,t[38]=re):re=t[38];let B=re,V=Ft(`flex shrink-0`,M.className),H;t[39]!==M.icon||t[40]!==V?(H=(0,Z.jsx)(`span`,{className:V,children:M.icon}),t[39]=M.icon,t[40]=V,t[41]=H):H=t[41];let U=H,W;t[42]!==U||t[43]!==N||t[44]!==M.text?(W=N?(0,Z.jsxs)(Sr,{children:[(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`internal-link-prop-panel-icon-trigger`,children:U})}),(0,Z.jsx)(xr,{children:M.text})]}):U,t[42]=U,t[43]=N,t[44]=M.text,t[45]=W):W=t[45];let G=W,ie=`${M.text}: ${A}`,K;t[46]!==A||t[47]!==I||t[48]!==N||t[49]!==L||t[50]!==ee||t[51]!==a||t[52]!==c?(K=(0,Z.jsx)(br,{asChild:!0,children:ee?(0,Z.jsx)(`a`,{href:L??void 0,...I?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>_n(e,c,a),"data-slot":`internal-link-prop-panel-text`,className:`block truncate text-sm font-medium text-foreground underline-offset-2 hover:underline focus-visible:underline`,children:A}):(0,Z.jsx)(`span`,{"data-slot":`internal-link-prop-panel-text`,className:Ft(`block truncate text-sm font-medium`,N?`text-muted-foreground`:`text-foreground`),children:A})}),t[46]=A,t[47]=I,t[48]=N,t[49]=L,t[50]=ee,t[51]=a,t[52]=c,t[53]=K):K=t[53];let ae;t[54]===A?ae=t[55]:(ae=(0,Z.jsx)(xr,{className:`max-w-80 break-all`,children:A}),t[54]=A,t[55]=ae);let oe;t[56]!==K||t[57]!==ae?(oe=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsxs)(Sr,{children:[K,ae]})}),t[56]=K,t[57]=ae,t[58]=oe):oe=t[58];let q;t[59]!==B||t[60]!==p||t[61]!==N?(q=N?(0,Z.jsxs)(zt,{type:`button`,size:`sm`,variant:`link`,disabled:p,onClick:()=>void B(),"data-slot":`internal-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,Z.jsx)(So,{className:`size-3.5`,"aria-hidden":`true`}),p?(0,Z.jsx)(o,{id:`HM56Bx`}):(0,Z.jsx)(o,{id:`XRuL0i`})]}):null,t[59]=B,t[60]=p,t[61]=N,t[62]=q):q=t[62];let se;t[63]===x?se=t[64]:(se=x({id:`ePK91l`}),t[63]=x,t[64]=se);let ce;t[65]===f?ce=t[66]:(ce=()=>f(!0),t[65]=f,t[66]=ce);let J;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)($n,{className:`size-3.5`,"aria-hidden":`true`}),t[67]=J):J=t[67];let le;t[68]!==se||t[69]!==ce?(le=(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":se,onClick:ce,"data-slot":`internal-link-prop-panel-edit`,children:J})}),t[68]=se,t[69]=ce,t[70]=le):le=t[70];let ue;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Z.jsx)(xr,{children:(0,Z.jsx)(o,{id:`ePK91l`})}),t[71]=ue):ue=t[71];let Y;t[72]===le?Y=t[73]:(Y=(0,Z.jsxs)(Sr,{children:[le,ue]}),t[72]=le,t[73]=Y);let de;t[74]===u?de=t[75]:(de=(0,Z.jsx)(FO,{copyContent:u}),t[74]=u,t[75]=de);let fe;t[76]===x?fe=t[77]:(fe=x({id:`t_YqKh`}),t[76]=x,t[77]=fe);let pe;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`}),t[78]=pe):pe=t[78];let me;t[79]!==D||t[80]!==fe?(me=(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":fe,onClick:D,"data-slot":`internal-link-prop-panel-remove`,children:pe})}),t[79]=D,t[80]=fe,t[81]=me):me=t[81];let he;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Z.jsx)(xr,{children:(0,Z.jsx)(o,{id:`t_YqKh`})}),t[82]=he):he=t[82];let ge;t[83]===me?ge=t[84]:(ge=(0,Z.jsxs)(Sr,{children:[me,he]}),t[83]=me,t[84]=ge);let _e;t[85]!==q||t[86]!==Y||t[87]!==de||t[88]!==ge?(_e=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[q,Y,de,ge]}),t[85]=q,t[86]=Y,t[87]=de,t[88]=ge,t[89]=_e):_e=t[89];let ve;t[90]!==G||t[91]!==oe||t[92]!==_e?(ve=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[G,oe,_e]}),t[90]=G,t[91]=oe,t[92]=_e,t[93]=ve):ve=t[93];let ye;return t[94]!==a||t[95]!==ie||t[96]!==ve||t[97]!==ne?(ye=(0,Z.jsx)(nO,{kind:`internal-link`,ariaLabel:ie,onDeactivate:a,triggerReference:ne,className:`w-96`,children:ve}),t[94]=a,t[95]=ie,t[96]=ve,t[97]=ne,t[98]=ye):ye=t[98],(0,Z.jsxs)(Z.Fragment,{children:[k,ye]})}new ke(`markIdentityDecoration`);var qO=`data-mark-id`,JO=new ke(`linkResolutionDecoration`);function YO(e,t,n,r,i){if(t.size===0)return null;let a=[];for(let e of t.values()){if(!n.has(e.markType))continue;let t=r(e,i),o={[qO]:e.id};t!==null&&Object.assign(o,t),a.push(rt.inline(e.from,e.to,o))}return a.length===0?null:Ue.create(e,a)}function XO(e){let t=new Set(e.markTypes),{computeAttrs:n}=e;return new Et({key:JO,state:{init:()=>({version:0}),apply(e,t){let n=e.getMeta(JO);return n&&typeof n==`object`&&n.refresh?{version:t.version+1}:t}},props:{decorations(e){let r=Ag.getState(e);if(!r)return null;let i=si();return YO(e.doc,r.byId,t,n,i)}},view(e){X(`ok/render/decoration-merge`,{markTypes:Array.from(t).join(`,`)},{startTime:performance.now(),duration:0});let n=li(()=>{e.dispatch(e.state.tr.setMeta(JO,{refresh:!0}))});return{destroy(){n()}}}})}var ZO=ue.extend({addOptions(){return{...this.parent?.(),docName:``}},renderHTML({HTMLAttributes:e}){let t=typeof e.href==`string`?e.href:``;return[`span`,et(e,{"data-link":``,role:`link`,tabindex:`0`,"aria-label":t?`Link: ${t}`:`Link`,style:`touch-action: manipulation;`}),0]},addProseMirrorPlugins(){let e=this.options.docName??``,t=({editor:t,nodeId:n,newTab:r})=>{let i=RO(t.state,n),a=i?.attrs?.href;if(typeof a!=`string`||!a)return!1;let o=i?.attrs?.sourceForm,s=R(a,e),c=We(a);if(s?.kind===`asset`||o===`wikiembed`&&c!==null){let t=s?.kind===`asset`?s.url:a,n=s?.kind===`asset`?s.ext:c??``,i=He(t,e);if(!i)return!1;let o=si();return o===null||(o.assetPaths!==void 0||o.filePaths!==void 0)&&!nn(t,e,o.assetPaths,o.filePaths)?!1:(On({url:t,projectRelPath:i,ext:n,title:i.split(`/`).pop()??t,newTab:r}),!0)}if(!s)return!1;switch(s.kind){case`doc`:{let e=si(),t=In(s.docName,{pages:e?.pages??new Set,folderPaths:e?.folderPaths??new Set});return t.kind===`create`||t.kind===`navigate`&&t.displayState===`folder`?!1:(r?Fn({docName:s.docName,anchor:s.anchor}):window.location.assign(Ln({docName:s.docName,anchor:s.anchor})),!0)}case`anchor`:return r?Fn({docName:e,anchor:s.anchor}):window.location.assign(Ln({docName:e,anchor:s.anchor})),!0;case`external`:return fn(s.url)?(un(s.url),!0):!1;default:return W(s)}};return[VO({editor:this.editor,markTypes:[`link`],renderPropPanel:({editor:n,nodeId:r,deactivate:i})=>(0,Q.createElement)(KO,{editor:n,nodeId:r,sourceDocName:e,onClose:i,onNavigate:e=>t({editor:n,nodeId:r,newTab:e})}),handlePrimary:t}),XO({markTypes:[`link`],computeAttrs:Wt(e)}),tO({sourceDocName:e})]}}),QO=(0,Q.createContext)(null),$O={didCatch:!1,error:null},ek=class extends Q.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=$O}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;t!==null&&(this.props.onReset?.({args:e,reason:`imperative-api`}),this.setState($O))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&tk(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState($O))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,Q.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,Q.createElement)(QO.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function tk(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}function nk(e){let t=(0,$.c)(23),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({label:i,Icon:n,onClick:a,selected:s,className:r,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s?`true`:void 0,l;t[7]===a?l=t[8]:(l=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},t[7]=a,t[8]=l);let u;t[9]===r?u=t[10]:(u=Ft(`flex w-full items-center justify-center gap-2 rounded-md border border-dashed border-border bg-transparent px-3 py-2 text-center text-sm text-muted-foreground transition-colors hover:bg-muted/50 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,r),t[9]=r,t[10]=u);let d;t[11]===n?d=t[12]:(d=(0,Z.jsx)(n,{size:16,"aria-hidden":`true`}),t[11]=n,t[12]=d);let f;t[13]===i?f=t[14]:(f=(0,Z.jsx)(`span`,{children:i}),t[13]=i,t[14]=f);let p;return t[15]!==a||t[16]!==o||t[17]!==c||t[18]!==l||t[19]!==u||t[20]!==d||t[21]!==f?(p=(0,Z.jsxs)(`div`,{...o,role:`button`,tabIndex:-1,contentEditable:!1,"data-descriptor-placeholder":``,"data-selected":c,onClick:a,onMouseDown:rk,onKeyDown:l,className:u,children:[d,f]}),t[15]=a,t[16]=o,t[17]=c,t[18]=l,t[19]=u,t[20]=d,t[21]=f,t[22]=p):p=t[22],p}function rk(e){e.preventDefault(),e.stopPropagation()}function ik(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(Oc,{"data-slot":`select`,...n}),t[2]=n,t[3]=r),r}function ak(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(Ac,{"data-slot":`select-value`,...n}),t[2]=n,t[3]=r),r}function ok(e){let t=(0,$.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,size:a,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===r?s=t[6]:(s=Ft(`flex w-full items-center justify-between gap-2 rounded-lg border border-input bg-background text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=default]:px-2.5 data-[size=sm]:px-2 data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,r),t[5]=r,t[6]=s);let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(jc,{asChild:!0,children:(0,Z.jsx)(Vn,{className:`size-4 opacity-50`})}),t[7]=c):c=t[7];let l;return t[8]!==n||t[9]!==i||t[10]!==o||t[11]!==s?(l=(0,Z.jsxs)(kc,{"data-slot":`select-trigger`,"data-size":o,className:s,...i,children:[n,c]}),t[8]=n,t[9]=i,t[10]=o,t[11]=s,t[12]=l):l=t[12],l}function sk(e){let t=(0,$.c)(20),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,position:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`popper`:a,s=o===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,c;t[5]!==r||t[6]!==s?(c=Ft(`relative z-50 max-h-(--radix-select-content-available-height) min-w-32 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border bg-popover text-popover-foreground shadow-md outline-hidden duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[align-trigger=true]:animate-none motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0`,s,r),t[5]=r,t[6]=s,t[7]=c):c=t[7];let l;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(lk,{}),t[8]=l):l=t[8];let u=o===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`,d;t[9]===u?d=t[10]:(d=Ft(`p-1`,u),t[9]=u,t[10]=d);let f;t[11]!==n||t[12]!==d?(f=(0,Z.jsx)(Pc,{className:d,children:n}),t[11]=n,t[12]=d,t[13]=f):f=t[13];let p;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(uk,{}),t[14]=p):p=t[14];let m;return t[15]!==o||t[16]!==i||t[17]!==c||t[18]!==f?(m=(0,Z.jsx)(Mc,{children:(0,Z.jsxs)(Nc,{"data-slot":`select-content`,"data-ok-layer-spawned":``,position:o,className:c,...i,children:[l,f,p]})}),t[15]=o,t[16]=i,t[17]=c,t[18]=f,t[19]=m):m=t[19],m}function ck(e){let t=(0,$.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=Ft(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,Z.jsx)(Lc,{children:(0,Z.jsx)(Bn,{className:`size-4`})})}),t[6]=o):o=t[6];let s;t[7]===n?s=t[8]:(s=(0,Z.jsx)(Ic,{children:n}),t[7]=n,t[8]=s);let c;return t[9]!==i||t[10]!==a||t[11]!==s?(c=(0,Z.jsxs)(Fc,{"data-slot":`select-item`,className:a,...i,children:[o,s]}),t[9]=i,t[10]=a,t[11]=s,t[12]=c):c=t[12],c}function lk(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`flex cursor-default items-center justify-center py-1`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Ha,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Z.jsx)(Rc,{"data-slot":`select-scroll-up-button`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function uk(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=Ft(`flex cursor-default items-center justify-center py-1`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Vn,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Z.jsx)(zc,{"data-slot":`select-scroll-down-button`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function dk(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,size:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]===n?o=t[5]:(o=Ft(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,n),t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(Qc,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`}),t[6]=s):s=t[6];let c;return t[7]!==r||t[8]!==a||t[9]!==o?(c=(0,Z.jsx)(Zc,{"data-slot":`switch`,"data-size":a,className:o,...r,children:s}),t[7]=r,t[8]=a,t[9]=o,t[10]=c):c=t[10],c}function fk(e){let t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t.toLowerCase();if(/^#[0-9a-fA-F]{3}$/.test(t)){let[,e,n,r]=t.match(/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/)??[];return`#${e}${e}${n}${n}${r}${r}`.toLowerCase()}return`#000000`}function pk(e){let t=(0,$.c)(36),{id:n,value:r,onChange:i,autoFocus:a}=e,o=(0,Q.useRef)(null),s;t[0]===i?s=t[1]:(s=e=>i(e.target.value),t[0]=i,t[1]=s);let c=a?``:void 0,l=r?`pl-7`:void 0,u;t[2]===l?u=t[3]:(u=Ft(`h-7 text-sm`,l),t[2]=l,t[3]=u);let d;t[4]!==a||t[5]!==n||t[6]!==s||t[7]!==c||t[8]!==u||t[9]!==r?(d=(0,Z.jsx)(ri,{id:n,type:`text`,value:r,placeholder:`#F05032 or rgb(240,80,50)`,onChange:s,autoFocus:a,"data-prop-autofocus":c,className:u,"data-color-picker-input":``}),t[4]=a,t[5]=n,t[6]=s,t[7]=c,t[8]=u,t[9]=r,t[10]=d):d=t[10];let f;t[11]===r?f=t[12]:(f=r&&(0,Z.jsx)(`span`,{style:{backgroundColor:r},className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 rounded-sm border border-border`,"aria-hidden":`true`,"data-color-picker-swatch":``}),t[11]=r,t[12]=f);let p;t[13]!==d||t[14]!==f?(p=(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15];let m;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>o.current?.click(),t[16]=m):m=t[16];let h=r||`transparent`,g;t[17]===h?g=t[18]:(g=(0,Z.jsx)(zt,{type:`button`,variant:`outline`,size:`xs`,"aria-label":`Choose color`,"data-color-picker-trigger":``,className:`h-7 gap-1 px-2`,onClick:m,children:(0,Z.jsx)(`span`,{style:{backgroundColor:h},className:`size-3.5 rounded-sm border border-border`,"aria-hidden":`true`})}),t[17]=h,t[18]=g);let _;t[19]===r?_=t[20]:(_=fk(r),t[19]=r,t[20]=_);let v;t[21]===i?v=t[22]:(v=e=>i(e.target.value),t[21]=i,t[22]=v);let y;t[23]!==_||t[24]!==v?(y=(0,Z.jsx)(`input`,{ref:o,type:`color`,value:_,onChange:v,tabIndex:-1,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 size-7 opacity-0`,"data-color-picker-native":``}),t[23]=_,t[24]=v,t[25]=y):y=t[25];let b;t[26]!==g||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`relative`,children:[g,y]}),t[26]=g,t[27]=y,t[28]=b):b=t[28];let x;t[29]!==i||t[30]!==r?(x=r&&(0,Z.jsx)(zt,{type:`button`,variant:`ghost`,size:`xs`,"aria-label":`Clear color`,"data-color-picker-clear":``,className:`h-7 px-1.5`,onClick:()=>i(``),children:(0,Z.jsx)(Ya,{className:`size-3`,"aria-hidden":`true`})}),t[29]=i,t[30]=r,t[31]=x):x=t[31];let S;return t[32]!==b||t[33]!==x||t[34]!==p?(S=(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[p,b,x]}),t[32]=b,t[33]=x,t[34]=p,t[35]=S):S=t[35],S}function mk(e){let t=(0,$.c)(43),{id:n,value:r,onChange:i,autoFocus:a}=e,[o,s]=(0,Q.useState)(!1),c;t[0]===r?c=t[1]:(c=t_(r),t[0]=r,t[1]=c);let l=c,u;t[2]===r?u=t[3]:(u=r.startsWith(`lucide:`)?r.slice(7):null,t[2]=r,t[3]=u);let d=u,f;t[4]===i?f=t[5]:(f=e=>i(e.target.value),t[4]=i,t[5]=f);let p=a?``:void 0,m=l?`pl-7`:void 0,h;t[6]===m?h=t[7]:(h=Ft(`h-7 text-sm`,m),t[6]=m,t[7]=h);let g;t[8]!==a||t[9]!==n||t[10]!==f||t[11]!==p||t[12]!==h||t[13]!==r?(g=(0,Z.jsx)(ri,{id:n,type:`text`,value:r,placeholder:`lucide:Lightbulb or 📘`,onChange:f,autoFocus:a,"data-prop-autofocus":p,className:h,"data-icon-picker-input":``}),t[8]=a,t[9]=n,t[10]=f,t[11]=p,t[12]=h,t[13]=r,t[14]=g):g=t[14];let _;t[15]===l?_=t[16]:(_=l&&(0,Z.jsx)(l,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),t[15]=l,t[16]=_);let v;t[17]!==g||t[18]!==_?(v=(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(Vn,{className:`size-3`,"aria-hidden":`true`}),t[20]=y):y=t[20];let b;t[21]===o?b=t[22]:(b=(0,Z.jsx)(ku,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,variant:`outline`,size:`xs`,"aria-label":`Choose icon`,"aria-haspopup":`listbox`,"aria-expanded":o,"data-icon-picker-trigger":``,className:`h-7 gap-1 px-2`,children:y})}),t[21]=o,t[22]=b);let x;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(Su,{placeholder:`Search icons...`,className:`h-8 text-sm`}),t[23]=x):x=t[23];let S;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(wu,{children:`No icons match.`}),t[24]=S):S=t[24];let C;t[25]!==i||t[26]!==r.length?(C=r.length>0&&(0,Z.jsx)(Tu,{children:(0,Z.jsxs)(Eu,{value:`__clear__`,onSelect:()=>{i(``),s(!1)},className:`gap-2 text-muted-foreground`,"data-icon-picker-clear":``,children:[(0,Z.jsx)(cr,{className:`size-3.5`,"aria-hidden":`true`}),`Clear icon`]})}),t[25]=i,t[26]=r.length,t[27]=C):C=t[27];let w;t[28]!==i||t[29]!==d?(w=e_.map(e=>{let[t,n]=e,r=t===d;return(0,Z.jsx)(Eu,{value:t,onSelect:()=>{i(`lucide:${t}`),s(!1)},title:t,"aria-label":t,"data-icon-picker-item":t,"data-icon-picker-selected":r?``:void 0,className:Ft(`flex aspect-square items-center justify-center rounded-md p-0`,r?`bg-foreground/10 text-foreground ring-1 ring-foreground/30`:`text-muted-foreground hover:bg-muted`),children:(0,Z.jsx)(n,{className:`size-4`,"aria-hidden":`true`})},t)}),t[28]=i,t[29]=d,t[30]=w):w=t[30];let T;t[31]===w?T=t[32]:(T=(0,Z.jsx)(Tu,{heading:`Lucide`,children:(0,Z.jsx)(cu.Group,{className:`[&_[cmdk-group-items]]:grid [&_[cmdk-group-items]]:grid-cols-6 [&_[cmdk-group-items]]:gap-1 [&_[cmdk-group-items]]:p-1`,children:w})}),t[31]=w,t[32]=T);let E;t[33]!==C||t[34]!==T?(E=(0,Z.jsx)(Au,{align:`end`,className:`z-70 w-72 p-0`,onOpenAutoFocus:hk,children:(0,Z.jsxs)(bu,{label:`Icon picker`,children:[x,(0,Z.jsxs)(Cu,{className:`max-h-64`,children:[S,C,T]})]})}),t[33]=C,t[34]=T,t[35]=E):E=t[35];let D;t[36]!==o||t[37]!==b||t[38]!==E?(D=(0,Z.jsxs)(Ou,{open:o,onOpenChange:s,children:[b,E]}),t[36]=o,t[37]=b,t[38]=E,t[39]=D):D=t[39];let O;return t[40]!==D||t[41]!==v?(O=(0,Z.jsxs)(`div`,{className:`flex gap-1`,children:[v,D]}),t[40]=D,t[41]=v,t[42]=O):O=t[42],O}function hk(e){return e.preventDefault()}function gk(e){let[t]=e.split(`/`);switch(t){case`image`:return`image`;case`video`:return`video`;case`audio`:return`audio`;case`application`:return e===`application/pdf`?`pdf`:null;case`text`:return`text`;default:return null}}function _k(e){if(e.length===1&&e[0]===`*/*`)return`all`;let t=new Set;for(let n of e){if(n===`*/*`)return`all`;let e=gk(n);e&&t.add(e)}return t}function vk(e){let t=e.lastIndexOf(`.`);return t<0||t<e.lastIndexOf(`/`)?``:e.slice(t+1).toLowerCase()}function yk(e,t){let n=_k(t),r=[];for(let t of e){if(n===`all`){r.push(t);continue}let e=pe(vk(t));e&&n.has(e)&&r.push(t)}return r}var bk=8,xk=new Set,Sk=null;function Ck(e){return{path:e,basename:e.split(`/`).pop()??e}}function wk(e){let t=e.map(e=>e.path).join(``);return Sk?.fingerprint===t||(Sk={fingerprint:t,byPath:new Map(e.map(e=>[e.path,e])),itemsInOrder:e,corpus:tt(e.map(e=>vt({kind:`page`,path:e.path,title:e.basename})))}),Sk}function Tk(e){let t=e.trim();return t.startsWith(`/`)?t.slice(1):t}function Ek(e,t){let n=Tk(t);return n?Dt(e.corpus,n,{intent:`autocomplete`,limit:bk}).map(t=>e.byPath.get(t.document.path)).filter(e=>!!e):e.itemsInOrder.slice(0,bk)}function Dk(e){let t=(0,$.c)(52),{value:n,onChange:r,accept:i,id:a,placeholder:o,autoFocus:s,ariaInvalid:c,ariaDescribedBy:l,dataPropAutofocus:u,className:d,onSubmit:f}=e,p=Kn()?.assetPaths??xk,m;t[0]!==i||t[1]!==p||t[2]!==n?(m=Ek(wk(yk(p,i).map(Ck)),n),t[0]=i,t[1]=p,t[2]=n,t[3]=m):m=t[3];let h=m,[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(0),b,x;t[4]!==v||t[5]!==h.length?(b=()=>{v>=h.length&&y(0)},x=[v,h.length],t[4]=v,t[5]=h.length,t[6]=b,t[7]=x):(b=t[6],x=t[7]),(0,Q.useEffect)(b,x);let S=(0,Q.useId)(),C=(0,Q.useRef)(null),w=g&&h.length>0,T;t[8]===r?T=t[9]:(T=e=>{r(`/${e.path}`),_(!1),y(0),C.current?.focus()},t[8]=r,t[9]=T);let E=T,D;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>_(e),t[10]=D):D=t[10];let O=w?S:void 0,k=w&&h[v]?`${S}-opt-${v}`:void 0,A;t[11]===r?A=t[12]:(A=e=>{r(e.target.value),_(!0),y(0)},t[11]=r,t[12]=A);let j,M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{_(!0)},j=()=>{_(!0)},t[13]=j,t[14]=M):(j=t[13],M=t[14]);let N;t[15]!==v||t[16]!==f||t[17]!==E||t[18]!==h||t[19]!==w?(N=e=>{if(e.key===`ArrowDown`){if(h.length===0)return;e.preventDefault(),_(!0),y(e=>(e+1)%h.length);return}if(e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),_(!0),y(e=>(e-1+h.length)%h.length);return}if(e.key===`Enter`){if(w){let t=h[v];if(t){e.preventDefault(),E(t);return}}f&&(e.preventDefault(),f());return}if(e.key===`Escape`){if(!w)return;e.preventDefault(),e.stopPropagation(),_(!1);return}e.key===`Tab`&&_(!1)},t[15]=v,t[16]=f,t[17]=E,t[18]=h,t[19]=w,t[20]=N):N=t[20];let P;t[21]!==l||t[22]!==c||t[23]!==s||t[24]!==d||t[25]!==u||t[26]!==a||t[27]!==o||t[28]!==N||t[29]!==O||t[30]!==k||t[31]!==A||t[32]!==n||t[33]!==w?(P=(0,Z.jsx)(ju,{asChild:!0,children:(0,Z.jsx)(ri,{ref:C,id:a,type:`text`,value:n,placeholder:o,autoFocus:s,"data-prop-autofocus":u,"aria-invalid":c,"aria-describedby":l,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":O,"aria-activedescendant":k,className:d,onChange:A,onFocus:M,onClick:j,onKeyDown:N})}),t[21]=l,t[22]=c,t[23]=s,t[24]=d,t[25]=u,t[26]=a,t[27]=o,t[28]=N,t[29]=O,t[30]=k,t[31]=A,t[32]=n,t[33]=w,t[34]=P):P=t[34];let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{let t=e.target;t instanceof Node&&C.current?.contains(t)&&e.preventDefault()},t[35]=F):F=t[35];let I;if(t[36]!==v||t[37]!==S||t[38]!==E||t[39]!==h){let e;t[41]!==v||t[42]!==S||t[43]!==E?(e=(e,t)=>{let n=`${S}-opt-${t}`,r=t===v;return(0,Z.jsxs)(`button`,{id:n,type:`button`,role:`option`,"aria-selected":r,"data-testid":`src-autocomplete-option`,"data-highlighted":r?``:void 0,className:Ft(`flex w-full flex-col items-start gap-0.5 rounded-sm px-2 py-1 text-left text-xs`,`transition-colors`,r?`bg-accent text-accent-foreground`:`hover:bg-accent/50`),onMouseEnter:()=>y(t),onMouseDown:t=>{t.preventDefault(),E(e)},children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:e.basename}),e.basename!==e.path&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/70`,children:e.path})]},e.path)},t[41]=v,t[42]=S,t[43]=E,t[44]=e):e=t[44],I=h.map(e),t[36]=v,t[37]=S,t[38]=E,t[39]=h,t[40]=I}else I=t[40];let L;t[45]!==S||t[46]!==I?(L=(0,Z.jsx)(Au,{align:`start`,sideOffset:4,className:`z-70 w-(--radix-popover-trigger-width) p-1`,onOpenAutoFocus:kk,onCloseAutoFocus:Ok,onInteractOutside:F,children:(0,Z.jsx)(`div`,{id:S,role:`listbox`,"aria-label":`Asset suggestions`,className:`flex flex-col gap-px`,children:I})}),t[45]=S,t[46]=I,t[47]=L):L=t[47];let R;return t[48]!==P||t[49]!==L||t[50]!==w?(R=(0,Z.jsxs)(Ou,{open:w,onOpenChange:D,children:[P,L]}),t[48]=P,t[49]=L,t[50]=w,t[51]=R):R=t[51],R}function Ok(e){e.preventDefault()}function kk(e){e.preventDefault()}function Ak(){if(typeof window>`u`)return null;let e=window.location.hash.match(/^#\/([^?#]+)/);return e?decodeURIComponent(e[1]):null}var jk=`/api/upload`;async function Mk(e,t,n={}){let r=n.fetch??globalThis.fetch,i=n.docName===void 0?Ak():n.docName;if(!i)throw Error(`No document is open`);let a=new FormData;a.append(`file`,e),a.append(`parentDocName`,i);let o;try{o=await r(jk,{method:`POST`,body:a})}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Upload failed: ${t}`)}let s;try{s=await o.json()}catch(e){throw new Ut(`Upload response is not JSON.`,{cause:e,status:o.status})}if(!o.ok){let e=qe.safeParse(s);throw e.success?Error(e.data.title):new Ut(`Upload error response did not match ProblemDetails.`,{cause:e.error,status:o.status})}let c=Qe.safeParse(s);if(!c.success)throw new Ut(`Upload success response did not match UploadAssetSuccess.`,{cause:c.error,status:o.status});let l=c.data.path??c.data.src;return{url:l.startsWith(`/`)?l:`/${l}`}}var Nk=new Intl.PluralRules(`en-US`);function Pk(e,t,n){return n<=0?`${e} (empty)`:`${e} with ${n} ${Nk.select(n)===`one`?`item`:`items`}`}function Fk(e){for(let t of e)if(t.type===`string`&&t.hidden!==!0&&t.advanced!==!0&&t.autoFocus===!0)return t.name;return null}function Ik(e){if(!e)return e;let t=e.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1)}var Lk=new Set([`auto`,`inherit`,`initial`,`unset`]),Rk=new Set([`px`,`%`,`rem`,`em`,`vh`,`vw`,`ch`,`ex`,`fr`]),zk=/^(-?\d+(?:\.\d+)?)([a-z%]*)$/i;function Bk(e){let t=e.trim();if(!t)return{valid:!1,reason:`empty`};if(Lk.has(t.toLowerCase()))return{valid:!0};let n=t.match(zk);if(!n)return{valid:!1,reason:`malformed-syntax`};let r=(n[2]??``).toLowerCase();return r===``||Rk.has(r)?{valid:!0}:{valid:!1,reason:`unknown-unit`}}function Vk(e){if(e.valid)return null;switch(e.reason){case`empty`:return null;case`malformed-syntax`:return`Enter a number (e.g. 100), a number with a CSS unit (e.g. 100px, 50%, 26rem), or one of: auto, inherit, initial, unset.`;case`unknown-unit`:return`Unknown CSS unit. Use px, %, rem, em, vh, vw, ch, ex, or fr.`}}var Hk={video:z,audio:p,image:j},Uk={youtube:[`youtube.com`,`youtu.be`,`youtube-nocookie.com`],vimeo:[`vimeo.com`],loom:[`loom.com`]};function Wk(e){let t=e.toLowerCase();for(let e of Object.keys(Uk)){let n=Uk[e];for(let r of n)if(t===r||t.endsWith(`.${r}`))return e}return null}function Gk(e){let t=e.lastIndexOf(`/`),n=t>=0?e.slice(t+1):e,r=n.lastIndexOf(`.`);return r>0?n.slice(r+1).toLowerCase():``}var Kk=`https://placeholder.invalid`;function qk(e,t){let n=e.trim();if(n.length===0)return{valid:!0};let r,i=!0;try{r=new URL(n)}catch{try{r=new URL(n,Kk),i=!1}catch{return{valid:!1,reason:`invalid-url`}}}if(t===`video`&&Be(n)!==null||t===`video`&&xe(n)||t===`video`&&D(n))return{valid:!0};let a=i?Wk(r.hostname):null;if(a!==null)return{valid:!1,reason:`embed-provider`,provider:a};if(r.protocol===`data:`)return{valid:!1,reason:`data-uri`};let o=Gk(r.pathname),s=Hk[t];return o===``?i?{valid:!0}:{valid:!1,reason:`wrong-extension`,extension:``}:s.has(o)?{valid:!0}:{valid:!1,reason:`wrong-extension`,extension:o}}function Jk(e){if(e.length===0)return;let t=e[0]?.toLowerCase()??``;if(t.startsWith(`video/`))return`video`;if(t.startsWith(`audio/`))return`audio`;if(t.startsWith(`image/`))return`image`}function Yk(e){return`Direct ${e} file URL — ${Array.from(Hk[e]).map(e=>`.${e}`).join(`, `)}`}var Xk={youtube:`YouTube`,vimeo:`Vimeo`,loom:`Loom`};function Zk(e,t){if(e.valid)return``;if(e.reason===`invalid-url`)return`Not a valid URL.`;if(e.reason===`data-uri`)return`Data URIs are not supported for media fields. Use a hosted file URL.`;if(e.reason===`embed-provider`){let n=Xk[e.provider];return t===`video`?`Unrecognized ${n} URL. Paste a valid ${n} share or embed link, or a direct ${t} file URL.`:`${n} URLs are not direct ${t} files. Paste a direct ${t} file URL.`}let n=Array.from(Hk[t]).map(e=>`.${e}`).join(`, `);return e.extension===``?`Missing file extension. Accepts: ${n}.`:`Unsupported extension .${e.extension}. Accepts: ${n}.`}function Qk(e){return`ok.propPanel.advanced.${e}`}function $k(e){try{return typeof localStorage>`u`?!1:localStorage.getItem(Qk(e))===`true`}catch{return!1}}function eA(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(Qk(e),t?`true`:`false`)}catch{}}function tA(e,t){let n=0;for(let r of e){let e=t[r.name],i=`defaultValue`in r?r.defaultValue:void 0;e!==void 0&&e!==i&&(n+=1)}return n}async function nA(e,t,n){try{let{url:r}=await Mk(e,t);n(r)}catch(e){let t=e instanceof Error?e.message:String(e);sr.error(ai._({id:`02P3hL`,values:{message:t}}))}}function rA(e){let t=(0,$.c)(14),{descriptor:n,values:r,onChange:i,onDismiss:a}=e,s;t[0]===r?s=t[1]:(s=e=>!(`hidden`in e&&e.hidden)&&e.hideWhen?.(r)!==!0&&e.type!==`reactnode`,t[0]=r,t[1]=s);let c=n.props.filter(s),l=c.filter(aA),u=c.filter(iA),d=tA(u,r),f;t[2]===n.props?f=t[3]:(f=Fk(n.props),t[2]=n.props,t[3]=f);let p=f,m;t[4]===n.name?m=t[5]:(m=()=>$k(n.name),t[4]=n.name,t[5]=m);let[h,g]=(0,Q.useState)(m);if(c.length===0)return null;let _;t[6]!==p||t[7]!==i||t[8]!==a||t[9]!==r?(_=e=>(0,Z.jsx)(sA,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),onDismiss:a,isAutoFocused:e.name===p},e.name),t[6]=p,t[7]=i,t[8]=a,t[9]=r,t[10]=_):_=t[10];let v=l.map(_),y=u.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,Z.jsxs)(Dr,{open:h,onOpenChange:e=>{g(e),eA(n.name,e)},children:[(0,Z.jsxs)(Er,{"data-prop-panel-advanced-trigger":``,className:`group flex w-full items-center justify-between rounded px-1 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground uppercase font-mono`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(Vn,{className:`size-3 transition-transform group-data-[state=closed]:-rotate-90`}),(0,Z.jsx)(o,{id:`sxkWRg`})]}),d>0&&(0,Z.jsx)(wl,{variant:`secondary`,"data-prop-panel-advanced-count":``,children:d})]}),(0,Z.jsx)(Tr,{className:`flex flex-col gap-4 pt-2`,children:u.map(e=>(0,Z.jsx)(sA,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),onDismiss:a,isAutoFocused:e.name===p},e.name))})]})]}),b;return t[11]!==v||t[12]!==y?(b=(0,Z.jsxs)(`div`,{"data-prop-panel":``,className:`flex flex-col gap-4 py-2 text-sm`,children:[v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13],b}function iA(e){return`advanced`in e&&e.advanced}function aA(e){return!(`advanced`in e&&e.advanced)}function oA(e){throw Error(`PropPanel: unhandled PropDef type ${JSON.stringify(e)}`)}function sA(e){let t=(0,$.c)(165),{propDef:n,value:r,onChange:i,onDismiss:a,isAutoFocused:o}=e,s;t[0]===a?s=t[1]:(s=a?e=>{e.key===`Enter`&&(e.preventDefault(),a())}:void 0,t[0]=a,t[1]=s);let c=s;switch(n.type){case`reactnode`:return null;case`string`:{let e=`prop-${n.name}`,s=n.accept,l=s!==void 0&&s.length>0,u=!n.required&&n.defaultValue===void 0;if(n.language){let a=`${e}-label`,s;t[2]===n.name?s=t[3]:(s=Ik(n.name),t[2]=n.name,t[3]=s);let c;t[4]!==a||t[5]!==e||t[6]!==s?(c=(0,Z.jsx)(`label`,{id:a,htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[4]=a,t[5]=e,t[6]=s,t[7]=c):c=t[7];let l=r??``,d;t[8]!==i||t[9]!==u?(d=e=>{if(e===``&&u){i(void 0);return}i(e)},t[8]=i,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==o||t[12]!==a||t[13]!==n.language||t[14]!==e||t[15]!==l||t[16]!==d?(f=(0,Z.jsx)(Mn,{id:e,ariaLabelledBy:a,value:l,language:n.language,onChange:d,autoFocus:o}),t[11]=o,t[12]=a,t[13]=n.language,t[14]=e,t[15]=l,t[16]=d,t[17]=f):f=t[17];let p;return t[18]!==c||t[19]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,f]}),t[18]=c,t[19]=f,t[20]=p):p=t[20],p}if(n.iconPicker){let a=r??``,s;t[21]===n.name?s=t[22]:(s=Ik(n.name),t[21]=n.name,t[22]=s);let c;t[23]!==e||t[24]!==s?(c=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[23]=e,t[24]=s,t[25]=c):c=t[25];let l;t[26]!==i||t[27]!==u?(l=e=>{if(e===``&&u){i(void 0);return}i(e)},t[26]=i,t[27]=u,t[28]=l):l=t[28];let d;t[29]!==a||t[30]!==o||t[31]!==e||t[32]!==l?(d=(0,Z.jsx)(mk,{id:e,value:a,onChange:l,autoFocus:o}),t[29]=a,t[30]=o,t[31]=e,t[32]=l,t[33]=d):d=t[33];let f;return t[34]!==c||t[35]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,d]}),t[34]=c,t[35]=d,t[36]=f):f=t[36],f}if(n.colorPicker){let a=r??``,s;t[37]===n.name?s=t[38]:(s=Ik(n.name),t[37]=n.name,t[38]=s);let c;t[39]!==e||t[40]!==s?(c=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[39]=e,t[40]=s,t[41]=c):c=t[41];let l;t[42]!==i||t[43]!==u?(l=e=>{if(e===``&&u){i(void 0);return}i(e)},t[42]=i,t[43]=u,t[44]=l):l=t[44];let d;t[45]!==a||t[46]!==o||t[47]!==e||t[48]!==l?(d=(0,Z.jsx)(pk,{id:e,value:a,onChange:l,autoFocus:o}),t[45]=a,t[46]=o,t[47]=e,t[48]=l,t[49]=d):d=t[49];let f;return t[50]!==c||t[51]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,d]}),t[50]=c,t[51]=d,t[52]=f):f=t[52],f}if(n.cssLengthInput){let a=r??``,s;if(t[53]!==a){let e=Bk(a);s=e.valid?null:Vk(e),t[53]=a,t[54]=s}else s=t[54];let l=s,d;t[55]===n.name?d=t[56]:(d=Ik(n.name),t[55]=n.name,t[56]=d);let f;t[57]!==e||t[58]!==d?(f=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:d}),t[57]=e,t[58]=d,t[59]=f):f=t[59];let p;t[60]!==i||t[61]!==u?(p=e=>{let t=e.target.value;if(t===``&&u){i(void 0);return}i(t)},t[60]=i,t[61]=u,t[62]=p):p=t[62];let m=o?``:void 0,h=l===null?void 0:!0,g=l===null?void 0:`${e}-error`,_;t[63]!==a||t[64]!==c||t[65]!==o||t[66]!==e||t[67]!==p||t[68]!==m||t[69]!==h||t[70]!==g?(_=(0,Z.jsx)(ri,{id:e,type:`text`,value:a,placeholder:`100px, 50%, 26rem, auto`,onChange:p,onKeyDown:c,autoFocus:o,"data-prop-autofocus":m,"aria-invalid":h,"aria-describedby":g,className:`h-7 text-sm`,"data-prop-css-length-input":``}),t[63]=a,t[64]=c,t[65]=o,t[66]=e,t[67]=p,t[68]=m,t[69]=h,t[70]=g,t[71]=_):_=t[71];let v;t[72]!==l||t[73]!==e?(v=l!==null&&(0,Z.jsx)(`p`,{id:`${e}-error`,"data-prop-css-length-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:l}),t[72]=l,t[73]=e,t[74]=v):v=t[74];let y;return t[75]!==v||t[76]!==f||t[77]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[f,_,v]}),t[75]=v,t[76]=f,t[77]=_,t[78]=y):y=t[78],y}let d,f,p;if(t[79]!==s||t[80]!==r){let e=s===void 0?void 0:Jk(s);d=r??``;let n=e===void 0?null:qk(d,e);f=n!==null&&!n.valid&&e!==void 0&&d.trim().length>0?Zk(n,e):null,p=e===void 0?void 0:Yk(e),t[79]=s,t[80]=r,t[81]=d,t[82]=f,t[83]=p}else d=t[81],f=t[82],p=t[83];let m=p,h;t[84]===n.name?h=t[85]:(h=Ik(n.name),t[84]=n.name,t[85]=h);let g;t[86]!==e||t[87]!==h?(g=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:h}),t[86]=e,t[87]=h,t[88]=g):g=t[88];let _;t[89]!==s||t[90]!==d||t[91]!==c||t[92]!==o||t[93]!==f||t[94]!==m||t[95]!==i||t[96]!==a||t[97]!==e||t[98]!==u?(_=s===void 0?(0,Z.jsx)(ri,{id:e,type:`text`,value:d,placeholder:m,onChange:e=>{let t=e.target.value;if(t===``&&u){i(void 0);return}i(t)},onKeyDown:c,autoFocus:o,"data-prop-autofocus":o?``:void 0,"aria-invalid":f===null?void 0:!0,"aria-describedby":f===null?void 0:`${e}-error`,className:`h-7 text-sm`}):(0,Z.jsx)(Dk,{id:e,value:d,onChange:e=>{if(e===``&&u){i(void 0);return}i(e)},onSubmit:a,accept:s,placeholder:m,autoFocus:o,dataPropAutofocus:o?``:void 0,ariaInvalid:f===null?void 0:!0,ariaDescribedBy:f===null?void 0:`${e}-error`,className:`h-7 text-sm`}),t[89]=s,t[90]=d,t[91]=c,t[92]=o,t[93]=f,t[94]=m,t[95]=i,t[96]=a,t[97]=e,t[98]=u,t[99]=_):_=t[99];let v;t[100]!==s||t[101]!==i||t[102]!==l?(v=l&&(0,Z.jsx)(lA,{accept:s,onUploaded:e=>i(e)}),t[100]=s,t[101]=i,t[102]=l,t[103]=v):v=t[103];let y;t[104]!==_||t[105]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[_,v]}),t[104]=_,t[105]=v,t[106]=y):y=t[106];let b;t[107]!==f||t[108]!==e?(b=f!==null&&(0,Z.jsx)(`p`,{id:`${e}-error`,"data-prop-media-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:f}),t[107]=f,t[108]=e,t[109]=b):b=t[109];let x;return t[110]!==g||t[111]!==y||t[112]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[g,y,b]}),t[110]=g,t[111]=y,t[112]=b,t[113]=x):x=t[113],x}case`boolean`:{let e=`prop-${n.name}`,a;t[114]===n.name?a=t[115]:(a=Ik(n.name),t[114]=n.name,t[115]=a);let o=a,s;t[116]!==e||t[117]!==o?(s=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[116]=e,t[117]=o,t[118]=s):s=t[118];let c=!!r,l;t[119]===i?l=t[120]:(l=e=>i(e),t[119]=i,t[120]=l);let u;t[121]!==e||t[122]!==c||t[123]!==l?(u=(0,Z.jsx)(dk,{id:e,checked:c,onCheckedChange:l}),t[121]=e,t[122]=c,t[123]=l,t[124]=u):u=t[124];let d;return t[125]!==s||t[126]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s,u]}),t[125]=s,t[126]=u,t[127]=d):d=t[127],d}case`enum`:{let e=`prop-${n.name}`,a=r??n.enumValues[0]??``,o;t[128]===n.name?o=t[129]:(o=Ik(n.name),t[128]=n.name,t[129]=o);let s;t[130]!==e||t[131]!==o?(s=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[130]=e,t[131]=o,t[132]=s):s=t[132];let c;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(ak,{}),t[133]=c):c=t[133];let l;t[134]===e?l=t[135]:(l=(0,Z.jsx)(ok,{id:e,size:`sm`,children:c}),t[134]=e,t[135]=l);let u;t[136]===n.enumValues?u=t[137]:(u=n.enumValues.map(cA),t[136]=n.enumValues,t[137]=u);let d;t[138]===u?d=t[139]:(d=(0,Z.jsx)(sk,{className:`z-70`,children:u}),t[138]=u,t[139]=d);let f;t[140]!==a||t[141]!==i||t[142]!==l||t[143]!==d?(f=(0,Z.jsxs)(ik,{value:a,onValueChange:i,children:[l,d]}),t[140]=a,t[141]=i,t[142]=l,t[143]=d,t[144]=f):f=t[144];let p;return t[145]!==s||t[146]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,f]}),t[145]=s,t[146]=f,t[147]=p):p=t[147],p}case`number`:{let e=`prop-${n.name}`,a;t[148]===n.name?a=t[149]:(a=Ik(n.name),t[148]=n.name,t[149]=a);let o;t[150]!==e||t[151]!==a?(o=(0,Z.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:a}),t[150]=e,t[151]=a,t[152]=o):o=t[152];let s=r==null?``:String(r),l;t[153]===i?l=t[154]:(l=e=>{let t=e.target.value;if(t===``){i(void 0);return}if(t===`-`)return;let n=Number(t);Number.isNaN(n)||i(n)},t[153]=i,t[154]=l);let u;t[155]!==c||t[156]!==e||t[157]!==s||t[158]!==l?(u=(0,Z.jsx)(ri,{id:e,type:`number`,inputMode:`numeric`,value:s,onChange:l,onKeyDown:c,className:`h-7 text-sm`}),t[155]=c,t[156]=e,t[157]=s,t[158]=l,t[159]=u):u=t[159];let d;return t[160]!==o||t[161]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[o,u]}),t[160]=o,t[161]=u,t[162]=d):d=t[162],d}default:{let e;return t[163]===n?e=t[164]:(e=oA(n),t[163]=n,t[164]=e),e}}}function cA(e){return(0,Z.jsx)(ck,{value:e,children:e},e)}function lA(e){let t=(0,$.c)(17),{accept:n,onUploaded:r}=e,[i,a]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),c;t[0]===n?c=t[1]:(c=n.join(`,`),t[0]=n,t[1]=c);let l;t[2]!==n||t[3]!==r?(l=async e=>{let t=e.target.files?.[0];if(t){a(!0);try{await nA(t,n,r)}catch{}a(!1),s.current&&(s.current.value=``)}},t[2]=n,t[3]=r,t[4]=l):l=t[4];let u;t[5]!==c||t[6]!==l?(u=(0,Z.jsx)(`input`,{ref:s,type:`file`,accept:c,className:`hidden`,"data-prop-upload-input":``,onChange:l}),t[5]=c,t[6]=l,t[7]=u):u=t[7];let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>s.current?.click(),t[8]=d):d=t[8];let f;t[9]===i?f=t[10]:(f=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ir,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),(0,Z.jsx)(o,{id:`_eguJc`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(No,{className:`size-3.5`,"aria-hidden":`true`}),(0,Z.jsx)(o,{id:`eJitUk`})]}),t[9]=i,t[10]=f);let p;t[11]!==f||t[12]!==i?(p=(0,Z.jsx)(zt,{type:`button`,variant:`outline`,size:`sm`,disabled:i,"data-prop-upload-trigger":``,className:`h-7 w-full justify-center gap-1.5 px-2 text-xs`,onClick:d,children:f}),t[11]=f,t[12]=i,t[13]=p):p=t[13];let m;return t[14]!==u||t[15]!==p?(m=(0,Z.jsxs)(Z.Fragment,{children:[u,p]}),t[14]=u,t[15]=p,t[16]=m):m=t[16],m}var uA=new Set([`img`,`CommonMarkImage`,`video`,`audio`,`Pdf`,`File`]);function dA(e,t,n){if(!uA.has(e)||!n)return t;let r=t.src;if(typeof r!=`string`)return t;let i=Ke(r,n);return i===r?t:{...t,src:i}}var fA=`selectionStatePlugin/origin`,pA=`selectionStatePlugin/refresh`,mA=new ke(`selectionState`),hA=new Set,gA={selectedBlockId:null,ancestorChain:[],selectionOrigin:`programmatic`,isDragging:!1,rangeEncompassedBlockIds:hA};function _A(e){return mA.getState(e.state)??gA}function vA(e,t){let n=[],{$from:r}=t;for(let t=1;t<=r.depth;t++){let i=r.node(t);if(i.type.name!==`jsxComponent`)continue;let a=r.before(t);n.push(yA(e,i,a))}if(t instanceof bt){let r=t.node;r.type.name===`jsxComponent`&&n.push(yA(e,r,t.from))}return n}function yA(e,t,n){let r=t.attrs.componentName??`unknown`;return{bridgeId:bA(e,n),componentName:r,pos:n}}function bA(e,t){return jb.getState(e)?.posToId.get(t)??`pos-${t}`}function xA(e,t){if(t instanceof bt)return hA;let{from:n,to:r}=t;if(n>=r)return hA;let i=jb.getState(e)?.posToId;if(!i)return hA;let a=null;for(let[t,o]of i){if(t<n)continue;let i=e.doc.nodeAt(t);i&&(t+i.nodeSize>r||(a||=new Set,a.add(o)))}return a??hA}function SA(e,t,n={}){let r=vA(e,e.selection),i=r[r.length-1],a=xA(e,e.selection),o={selectedBlockId:i?.bridgeId??null,ancestorChain:r,selectionOrigin:n.origin??t.selectionOrigin,isDragging:n.isDragging??t.isDragging,rangeEncompassedBlockIds:a};return CA(t,o)?t:o}function CA(e,t){if(e===t)return!0;if(e.selectedBlockId!==t.selectedBlockId||e.selectionOrigin!==t.selectionOrigin||e.isDragging!==t.isDragging||e.ancestorChain.length!==t.ancestorChain.length)return!1;for(let n=0;n<e.ancestorChain.length;n++){let r=e.ancestorChain[n],i=t.ancestorChain[n];if(r.bridgeId!==i.bridgeId||r.componentName!==i.componentName||r.pos!==i.pos)return!1}if(e.rangeEncompassedBlockIds.size!==t.rangeEncompassedBlockIds.size)return!1;for(let n of e.rangeEncompassedBlockIds)if(!t.rangeEncompassedBlockIds.has(n))return!1;return!0}var wA=new WeakMap;function TA(e,t,n,r){let i=r?.isDragging??t.isDragging,a=!!e.getMeta(pA),o=e.selectionSet&&!a,s=e.getMeta(fA),c=o?r?.pendingOrigin??null:null,l=s??c??t.selectionOrigin;return o&&r&&(r.pendingOrigin=null),SA(n,t,{origin:l,isDragging:i})}var EA=Y.create({name:`selectionStatePlugin`,addProseMirrorPlugins(){let e=this.editor,t=new Et({key:mA,state:{init(e,t){return SA(t,gA)},apply(e,n,r,i){return TA(e,n,i,wA.get(t))}},props:{handleDOMEvents:{mousedown:()=>{let e=wA.get(t);return e&&(e.pendingOrigin=`pointer`),!1},pointerdown:()=>{let e=wA.get(t);return e&&(e.pendingOrigin=`pointer`),!1}},handleKeyDown:(e,n)=>{if(DA(n.key)){let e=wA.get(t);e&&(e.pendingOrigin=`keyboard`)}return!1}},view(n){wA.set(t,{pendingOrigin:null,isDragging:!1});let r=n.dom.parentElement??n.dom,i=()=>{let n=wA.get(t);n&&(n.isDragging=!0,OA(e))},a=()=>{let n=wA.get(t);n&&(n.isDragging=!1,OA(e))};return r.addEventListener(`dragstart`,i,!0),r.addEventListener(`dragend`,a,!0),r.addEventListener(`drop`,a,!0),{destroy:()=>{r.removeEventListener(`dragstart`,i,!0),r.removeEventListener(`dragend`,a,!0),r.removeEventListener(`drop`,a,!0),wA.delete(t)}}}});return[t]}});function DA(e){return e===`ArrowUp`||e===`ArrowDown`||e===`ArrowLeft`||e===`ArrowRight`||e===`Tab`||e===`Escape`||e===`Enter`||e===`Home`||e===`End`||e===`PageUp`||e===`PageDown`}function OA(e){queueMicrotask(()=>{if(!e.isDestroyed)try{let t=e.state.tr.setMeta(pA,!0);e.view.dispatch(t)}catch{}})}function kA(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=()=>e?_A(e):null,t[0]=e,t[1]=n);let[r,i]=(0,Q.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(!e){i(null);return}i(_A(e));let t=()=>{i(_A(e))};return e.on(`transaction`,t),e.on(`selectionUpdate`,t),()=>{e.off(`transaction`,t),e.off(`selectionUpdate`,t)}},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,Q.useEffect)(a,o),r}function AA(e,t){if(e.hasChildren)return!1;let n=Fk(e.props);return n===null?!1:t[n]===``}function jA(e){let t=e.placeholder?.label,n=`Add ${(e.displayName??e.name).toLowerCase()}`;return{label:t??n,Icon:Qg(e.placeholder?.icon??e.icon)}}var MA=new Set([`img`,`CommonMarkImage`,`Embed`,`video`]);function NA(e){if(!e.attrs.sourceDirty&&e.attrs.sourceRaw)return e.attrs.sourceRaw;let t=qt(),n=e.type.schema.node(`doc`,null,[e]);return t.serialize(n.toJSON()).trim()}var PA=new Set(yt.map(e=>`${e}:`)),FA=6e4,IA=10,LA=new Map;function RA(e,t){let n=t.toLowerCase();T(n);let r=Date.now(),i=LA.get(n);if(!i||r-i.windowStart>=FA)LA.set(n,{windowStart:r,count:1});else if(i.count+=1,i.count>IA)return;typeof console<`u`&&typeof console.warn==`function`&&console.warn(JSON.stringify({event:`jsx-prop-dropped`,reason:e,prop:t}))}var zA=new Set([`href`,`src`,`action`,`formaction`,`poster`,`cite`,`data`,`manifest`,`background`,`ping`,`xlinkhref`,`xlinkactuate`,`xlinkrole`,`xlinkarcrole`,`xlinkshow`,`url`,`link`]),BA=new Set([`dangerouslysetinnerhtml`,`ref`,`key`,`defaultvalue`,`defaultchecked`,`__proto__`,`constructor`,`prototype`]),VA=1e4;function HA(e){let t=e.toLowerCase();return!!(BA.has(t)||t.length>=3&&t.startsWith(`on`))}function UA(e){return zA.has(e.toLowerCase())}function WA(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`//`)||F(t))return e;let n=t.indexOf(`:`),r=t.slice(0,n+1).toLowerCase();return PA.has(r)?e:`#`}function GA(e){if(e.length>VA)return``;let t=e.toLowerCase();return/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/.test(t)||/\bexpression\s*\(/.test(t)?``:e}function KA(e){if(e==null)return e;if(Array.isArray(e)){let t=!1,n=Array(e.length);for(let r=0;r<e.length;r++){let i=KA(e[r]);n[r]=i,i!==e[r]&&(t=!0)}return t?n:e}if(typeof e!=`object`)return e;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=e,r=!1,i={};for(let[e,t]of Object.entries(n)){if(HA(e)){RA(`dangerous-prop-name-nested`,e),r=!0;continue}if(UA(e)&&typeof t==`string`){let n=WA(t);n!==t&&(r=!0),i[e]=n}else{let n=KA(t);n!==t&&(r=!0),i[e]=n}}return r?i:e}function qA(e){let t=!1,n={};for(let[r,i]of Object.entries(e)){if(HA(r)){RA(`dangerous-prop-name`,r),t=!0;continue}if(UA(r)){let e=WA(i);e!==i&&(t=!0),n[r]=e;continue}if(r===`style`){if(typeof i==`string`){let e=GA(i);e!==i&&(t=!0),n[r]=e}else t=!0;continue}let e=KA(i);e!==i&&(t=!0),n[r]=e}return t?n:e}function JA(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`jsx-component-error-fallback`,children:n}),t[0]=n,t[1]=r),r}function YA(e){let t=(0,$.c)(13),{children:n,resetKey:r,onError:i,descriptorName:a,rawComponentName:o}=e,s;t[0]===r?s=t[1]:(s=[r],t[0]=r,t[1]=s);let c;t[2]!==a||t[3]!==i||t[4]!==o?(c=(e,t)=>{let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:a,rawComponentName:String(o??``).slice(0,200),error:String(n),stack:t.componentStack})),M(a),i(n)},t[2]=a,t[3]=i,t[4]=o,t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=e=>(0,Z.jsx)(JA,{...e,children:n}),t[6]=n,t[7]=l);let u;return t[8]!==n||t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,Z.jsx)(ek,{resetKeys:s,onError:c,fallbackRender:l,children:n}),t[8]=n,t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u}function XA(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(XA).join(`,`)}]`;let t=Object.entries(e);return t.sort(([e],[t])=>e<t?-1:+(e>t)),`{${t.map(([e,t])=>`${JSON.stringify(e)}:${XA(t)}`).join(`,`)}}`}function ZA(e,t){let n=e.props??{},r={};for(let[e,i]of Object.entries(n))t.has(e)||(r[e]=i);return qA(r)}function QA(e){return e.kind===`element`?e:null}var $A=3;function ej(e){let t=(0,$.c)(162),{node:n,editor:r,extension:i,getPos:a,selected:c}=e,{_:l}=s(),u=rb(n.attrs.componentName),[d,f]=(0,Q.useState)(null),[p,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(!1),_=typeof a==`function`?a():void 0,v=!1,b=0,x=1;try{if(_!==void 0){let e=r.state.doc.resolve(_);e.depth>0&&e.parent.type.name===`jsxComponent`&&(v=!0,b=e.index(e.depth),x=e.parent.childCount)}}catch(e){let t=e;if(!(t instanceof RangeError))throw t}let S=v&&b>0,C=v&&b<x-1,w=kA(r),T=typeof _==`number`?bA(r.state,_):null,E=T!==null&&(w?.rangeEncompassedBlockIds.has(T)??!1),D;t[0]===w?.ancestorChain?D=t[1]:(D=w?.ancestorChain.at(-1)?.bridgeId??null,t[0]=w?.ancestorChain,t[1]=D);let O=T!==null&&D===T,k=c&&!E&&O,A=T!==null&&!O&&(w?.ancestorChain.some(e=>e.bridgeId===T)??!1),j=k&&w?w.selectionOrigin:void 0,M=k&&(w?.isDragging??!1),N=u.props.some(oj),P=n.attrs.props??{},F=N&&u.props.some(e=>e.type!==`string`||!e.required||`hidden`in e&&e.hidden?!1:!Object.hasOwn(P,e.name)),I=AA(u,P),L=I?jA(u):null,R=!u.hasChildren||!!u.isSelfClosing,ee=MA.has(u.name),z=u.name===`MermaidFence`?{propName:`chart`,language:`mermaid`}:u.name===`Math`||u.name===`DollarMath`||u.name===`MathFence`?{propName:`formula`,language:`latex`}:null,[ne,V]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{c&&!g.current&&N&&fb(_)&&h(!0),g.current=c},[c,N,_]);let H=ZA(n.attrs,u.reactNodePropNames),W=u.surface===`compat`?u.translateProps(H):H,G=i.options.docName,ie=typeof G==`string`&&G?G:Yt(r),K=dA(u.name,W,ie),oe=`${u.name}::${XA(H)}`,q;t[2]!==a||t[3]!==n.content.size?(q=()=>(typeof a==`function`?a()??0:0)+1+n.content.size,t[2]=a,t[3]=n.content.size,t[4]=q):q=t[4];let se=q,ce=u.name===`*`||d!==null,J=(0,Q.useRef)(!1),le=(0,Q.useRef)(0),[ue,Y]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{if(!ce||J.current||ue)return;let e=typeof a==`function`?a():void 0;if(typeof e!=`number`)return;let t=NA(n),i=u.name===`*`?`Unregistered component: ${n.attrs.componentName}`:`Render error in <${u.displayName??u.name}>: ${d?.message??`unknown`}`,o=n.type.schema.nodes.rawMdxFallback.create({reason:i},n.type.schema.text(t)),s=!1,c,l=()=>{if(!s)try{r.view.dispatch(r.state.tr.replaceWith(e,e+n.nodeSize,o)),J.current=!0,Je(u.name===`*`?`wildcard`:u.name)}catch(e){let t=e,r=u.name===`*`?`wildcard`:u.name;if(console.warn(JSON.stringify({event:`jsx-component-auto-convert-failed`,component:r,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t instanceof Error?t.message.slice(0,500):String(t).slice(0,500),retry:le.current})),m(r),le.current+=1,le.current<$A){let e=50*(2**le.current-1);c=setTimeout(()=>{s||l()},e)}else s||Y(!0)}},f=requestAnimationFrame(l);return()=>{s=!0,cancelAnimationFrame(f),c!==void 0&&clearTimeout(c)}},[ce,n,r,a,u,d,ue]),ue){let e=n.attrs.componentName,i=u.displayName??u.name,o=u.name===`*`?l({id:`Kh1n4a`,values:{componentName:e}}):l({id:`g58Kwy`,values:{descriptorLabel:i}}),s=()=>{try{let e=NA(n);typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e)}catch(e){let t=e;te(u.name),console.warn(JSON.stringify({event:`jsx-component-stuck-copy-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t instanceof Error?t.message.slice(0,500):String(t).slice(0,500)}))}},c=()=>{let e=typeof a==`function`?a():void 0;if(typeof e==`number`)try{r.chain().focus().setNodeSelection(e).deleteSelection().run()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;ae(u.name),console.warn(JSON.stringify({event:`jsx-component-stuck-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={[dC]:`true`},t[5]=d):d=t[5];let f;t[6]===o?f=t[7]:(f=(0,Z.jsx)(`span`,{className:`flex-1`,children:o}),t[6]=o,t[7]=f);let p;t[8]===l?p=t[9]:(p=l({id:`E2Mv-X`}),t[8]=l,t[9]=p);let m;t[10]!==s||t[11]!==p?(m=(0,Z.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:s,children:p}),t[10]=s,t[11]=p,t[12]=m):m=t[12];let h;t[13]===l?h=t[14]:(h=l({id:`cnGeoo`}),t[13]=l,t[14]=h);let g;t[15]!==c||t[16]!==h?(g=(0,Z.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:c,children:h}),t[15]=c,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==m||t[19]!==g||t[20]!==f?(_=(0,Z.jsxs)(`div`,{className:`text-xs font-mono text-muted-foreground px-2 py-2 border border-destructive/40 rounded bg-destructive/5 flex items-center gap-2`,contentEditable:!1,...d,children:[f,m,g]}),t[18]=m,t[19]=g,t[20]=f,t[21]=_):_=t[21];let v;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Nn,{className:`component-children`}),t[22]=v):v=t[22];let y;return t[23]===_?y=t[24]:(y=(0,Z.jsxs)(Dn,{className:`jsx-component-wrapper my-2`,children:[_,v]}),t[23]=_,t[24]=y),y}if(ce){let e=n.attrs.componentName,r=u.displayName??u.name,i=u.name===`*`?l({id:`oJl7eO`,values:{componentName:e}}):l({id:`bcDHUM`,values:{descriptorLabel:r}}),a;t[25]===i?a=t[26]:(a=(0,Z.jsx)(`div`,{className:`text-xs font-mono text-muted-foreground px-2 py-1`,contentEditable:!1,children:i}),t[25]=i,t[26]=a);let o;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Nn,{className:`component-children`}),t[27]=o):o=t[27];let s;return t[28]===a?s=t[29]:(s=(0,Z.jsxs)(Dn,{className:`jsx-component-wrapper my-2`,children:[a,o]}),t[28]=a,t[29]=s),s}let de=u.Component,fe=u.displayName??u.name,pe=u.displayName??u.name,me=u.displayName??u.name,he=e=>{if(I||!R)return;let t=e.target;if(!e.currentTarget.contains(t)||t.closest(`.jsx-component-chrome`)||t.closest(`.jsx-add-child-pill, .jsx-empty-child-placeholder`)||t.closest(`a[href]`)||typeof _!=`number`)return;let n=r.state.doc.nodeAt(_);if(!n)return;let i=_+n.nodeSize,a=r.state.selection.from;a<_||a>=i||r.chain().focus().setNodeSelection(_).run()},ge;t[30]!==r||t[31]!==a||t[32]!==h?(ge=()=>{let e=typeof a==`function`?a():void 0;typeof e==`number`&&(r.chain().focus().setNodeSelection(e).run(),h(!0))},t[30]=r,t[31]=a,t[32]=h,t[33]=ge):ge=t[33];let _e=ge,ve=u.displayName??u.name,ye=!!u.emptyChildName,be=ye?Pk(ve,u.emptyChildName,n.childCount):void 0,xe=e=>{let t=e.target;if(e.key===`Backspace`||e.key===`Delete`){if(!k||!e.currentTarget.contains(t)||t.matches(`input, textarea`))return;let i=typeof a==`function`?a():void 0;if(typeof i!=`number`)return;e.preventDefault();try{r.chain().focus().setNodeSelection(i).deleteSelection().run()||(re(u.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){let t=e;if(!(t instanceof RangeError))throw t;re(u.name),console.warn(JSON.stringify({event:`jsx-component-keyboard-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}return}e.key!==`Enter`&&e.key!==` `||c&&N&&(t.closest(`.jsx-component-chrome`)||t.closest(`input, textarea, select, button`)||(e.preventDefault(),h(!0)))},Se=e=>{h(e),!e&&requestAnimationFrame(()=>{let e=typeof a==`function`?a():void 0;if(typeof e==`number`)try{let t=r.state.doc.nodeAt(e);if(!t)return;let n=e+t.nodeSize,i=r.state.selection.from;if(i<e||i>=n)return;if(R){let e=r.state.doc.resolve(Math.min(n,r.state.doc.content.size)),t=y.near(e,1);r.view.dispatch(r.state.tr.setSelection(t).scrollIntoView())}else r.chain().setNodeSelection(e).run()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;U(u.name),console.warn(JSON.stringify({event:`jsx-component-popover-close-restore-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}})},Ce=Ou,we=Dn,Te;t[34]===u.name?Te=t[35]:(Te=u.name.toLowerCase(),t[34]=u.name,t[35]=Te);let Ee;bb0:{let e=P.align;if(e===`left`||e===`right`||e===`center`){Ee=e;break bb0}if(ee){Ee=`center`;break bb0}Ee=void 0}let De=k?`true`:void 0,Oe=A?`true`:void 0,ke=E?`true`:void 0,Ae=M?`true`:void 0,je=F?`true`:void 0,Me=ye?`group`:void 0,Ne=k?0:-1,Pe;t[36]===v?Pe=t[37]:(Pe=v?{draggable:`false`,onDragStart:aj}:{"data-drag-handle":``,draggable:`true`},t[36]=v,t[37]=Pe);let Fe=u.name,Ie=ij,Le;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(Le={[dC]:`true`},t[38]=Le):Le=t[38];let Re=u.name===`Embed`&&typeof H.src==`string`&&/^https?:\/\//i.test(H.src)&&(0,Z.jsx)(`a`,{href:H.src,target:`_blank`,rel:`noopener noreferrer`,className:`jsx-chrome-btn`,"aria-label":l({id:`iOHg1t`}),onMouseDown:rj,children:(0,Z.jsx)(Xa,{size:12,"aria-hidden":`true`})}),ze=u.name===`Mirror`&&typeof H.src==`string`&&H.src.length>0&&(()=>{let e=H.src;return(0,Z.jsx)(`a`,{href:xi(e,typeof H.anchor==`string`&&H.anchor.length>0?H.anchor:null),className:`jsx-chrome-btn`,"aria-label":l({id:`3a_Bd7`,values:{mirrorSrc:e}}),title:l({id:`0kTAXe`,values:{mirrorSrc:e}}),onMouseDown:nj,children:(0,Z.jsx)(Xa,{size:12,"aria-hidden":`true`})})})(),Be;t[39]!==l||t[40]!==S||t[41]!==u.name||t[42]!==r||t[43]!==n.attrs.componentName||t[44]!==n.nodeSize||t[45]!==_?(Be=S&&(0,Z.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`QyioBP`}),onClick:()=>{try{if(typeof _!=`number`)return;let e=r.state.doc.resolve(_),t=e.index(e.depth);if(t===0)return;let i=_-e.node(e.depth).child(t-1).nodeSize,a=_+n.nodeSize,o=r.state.tr,s=r.state.doc.slice(_,_+n.nodeSize),c=r.state.doc.slice(i,_);o.replaceWith(i,a,s.content.append(c.content)),r.view.dispatch(o.scrollIntoView())}catch(e){let t=e;if(!(t instanceof RangeError))throw t;B(`up`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`up`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,Z.jsx)(vn,{size:12,"aria-hidden":`true`})}),t[39]=l,t[40]=S,t[41]=u.name,t[42]=r,t[43]=n.attrs.componentName,t[44]=n.nodeSize,t[45]=_,t[46]=Be):Be=t[46];let Ve;t[47]!==l||t[48]!==C||t[49]!==u.name||t[50]!==r||t[51]!==n.attrs.componentName||t[52]!==n.nodeSize||t[53]!==_?(Ve=C&&(0,Z.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`3Ib6FN`}),onClick:()=>{try{if(typeof _!=`number`)return;let e=r.state.doc.resolve(_),t=e.index(e.depth),i=e.node(e.depth);if(t>=i.childCount-1)return;let a=i.child(t+1),o=_,s=_+n.nodeSize+a.nodeSize,c=r.state.tr,l=r.state.doc.slice(_,_+n.nodeSize),u=r.state.doc.slice(_+n.nodeSize,s);c.replaceWith(o,s,u.content.append(l.content)),r.view.dispatch(c.scrollIntoView())}catch(e){let t=e;if(!(t instanceof RangeError))throw t;B(`down`),console.warn(JSON.stringify({event:`jsx-component-move-failed`,direction:`down`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},children:(0,Z.jsx)(Rn,{size:12,"aria-hidden":`true`})}),t[47]=l,t[48]=C,t[49]=u.name,t[50]=r,t[51]=n.attrs.componentName,t[52]=n.nodeSize,t[53]=_,t[54]=Ve):Ve=t[54];let He;t[55]!==l||t[56]!==u.displayName||t[57]!==u.name||t[58]!==z||t[59]!==_||t[60]!==V?(He=z&&typeof _==`number`?(0,Z.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`ky9Tuc`,values:{0:u.displayName??u.name}}),"data-testid":`jsx-component-edit-btn`,onClick:()=>V(!0),children:(0,Z.jsx)($n,{size:12,"aria-hidden":`true`})}):null,t[55]=l,t[56]=u.displayName,t[57]=u.name,t[58]=z,t[59]=_,t[60]=V,t[61]=He):He=t[61];let Ue;t[62]!==l||t[63]!==fe?(Ue=l({id:`MCjC9A`,values:{deleteDescriptorLabel:fe}}),t[62]=l,t[63]=fe,t[64]=Ue):Ue=t[64];let We;t[65]!==u.name||t[66]!==r||t[67]!==n.attrs.componentName||t[68]!==_?(We=()=>{if(typeof _==`number`)try{r.chain().focus().setNodeSelection(_).deleteSelection().run()||(re(u.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:`chain-dispatch-returned-false`})))}catch(e){let t=e;if(!(t instanceof RangeError))throw t;re(u.name),console.warn(JSON.stringify({event:`jsx-component-chrome-delete-failed`,component:u.name,rawComponentName:String(n.attrs.componentName??``).slice(0,200),reason:t.message.slice(0,500)}))}},t[65]=u.name,t[66]=r,t[67]=n.attrs.componentName,t[68]=_,t[69]=We):We=t[69];let Ge;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,Z.jsx)(ar,{size:12,"aria-hidden":`true`}),t[70]=Ge):Ge=t[70];let Ke;t[71]!==Ue||t[72]!==We?(Ke=(0,Z.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":Ue,onClick:We,children:Ge}),t[71]=Ue,t[72]=We,t[73]=Ke):Ke=t[73];let qe;t[74]!==l||t[75]!==N||t[76]!==pe?(qe=N&&(0,Z.jsx)(ku,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"data-jsx-gear":``,"aria-label":l({id:`XPJ0sN`,values:{settingsDescriptorLabel:pe}}),children:(0,Z.jsx)(To,{size:12,"aria-hidden":`true`})})}),t[74]=l,t[75]=N,t[76]=pe,t[77]=qe):qe=t[77];let Ye;t[78]!==Ie||t[79]!==Le||t[80]!==Re||t[81]!==ze||t[82]!==Be||t[83]!==Ve||t[84]!==He||t[85]!==Ke||t[86]!==qe?(Ye=(0,Z.jsxs)(`div`,{className:`jsx-component-chrome`,contentEditable:!1,onMouseDown:Ie,...Le,children:[Re,ze,Be,Ve,He,Ke,qe]}),t[78]=Ie,t[79]=Le,t[80]=Re,t[81]=ze,t[82]=Be,t[83]=Ve,t[84]=He,t[85]=Ke,t[86]=qe,t[87]=Ye):Ye=t[87];let Xe;t[88]!==de||t[89]!==u.emptyChildName||t[90]!==u.hasChildren||t[91]!==u.isSelfClosing||t[92]!==u.name||t[93]!==r||t[94]!==a||t[95]!==se||t[96]!==k||t[97]!==n.attrs.componentName||t[98]!==n.childCount||t[99]!==_e||t[100]!==K||t[101]!==oe||t[102]!==L||t[103]!==f||t[104]!==I?(Xe=I&&L?(0,Z.jsx)(ju,{asChild:!0,children:(0,Z.jsx)(nk,{label:L.label,Icon:L.Icon,onClick:_e,selected:k})}):(0,Z.jsx)(YA,{resetKey:oe,onError:f,descriptorName:u.name===`*`?`wildcard`:u.name,rawComponentName:n.attrs.componentName??``,children:(0,Z.jsx)(tn,{value:typeof a==`function`?{editor:r,getPos:()=>{let e=a();return typeof e==`number`?e:void 0},addChild:u.emptyChildName?()=>{let e=u.emptyChildName,t=lb(e),n=se();r.chain().focus().insertContentAt(n,t).run(),pb(r,n,rb(e))}:null}:null,children:(0,Z.jsx)(de,{...K,children:(0,Z.jsx)(Nn,{className:`component-children ${!u.hasChildren&&n.childCount===0?`min-h-0 m-0 p-0`:``}`,...!u.hasChildren||u.isSelfClosing?{contentEditable:!1}:{}})})})}),t[88]=de,t[89]=u.emptyChildName,t[90]=u.hasChildren,t[91]=u.isSelfClosing,t[92]=u.name,t[93]=r,t[94]=a,t[95]=se,t[96]=k,t[97]=n.attrs.componentName,t[98]=n.childCount,t[99]=_e,t[100]=K,t[101]=oe,t[102]=L,t[103]=f,t[104]=I,t[105]=Xe):Xe=t[105];let Ze;t[106]!==u.emptyChildName||t[107]!==u.name||t[108]!==r||t[109]!==se||t[110]!==n.childCount?(Ze=u.emptyChildName&&!(u.name===`Tabs`&&n.childCount>0)&&(()=>{let e=u.emptyChildName;return(0,Z.jsx)(`button`,{type:`button`,contentEditable:!1,className:n.childCount===0?`jsx-empty-child-placeholder`:`jsx-add-child-pill`,onMouseDown:tj,onClick:()=>{let e=u.emptyChildName,t=lb(e),n=se();r.chain().focus().insertContentAt(n,t).run(),pb(r,n,rb(e))},"data-clipboard-omit":`true`,children:(0,Z.jsx)(`span`,{children:(0,Z.jsx)(o,{id:`7Fkcej`,values:{addChildName:e}})})})})(),t[106]=u.emptyChildName,t[107]=u.name,t[108]=r,t[109]=se,t[110]=n.childCount,t[111]=Ze):Ze=t[111];let Qe;t[112]!==we||t[113]!==u.name||t[114]!==be||t[115]!==he||t[116]!==xe||t[117]!==j||t[118]!==Te||t[119]!==Ee||t[120]!==De||t[121]!==Oe||t[122]!==ke||t[123]!==Ae||t[124]!==je||t[125]!==Me||t[126]!==Ne||t[127]!==Pe||t[128]!==Ye||t[129]!==Xe||t[130]!==Ze?(Qe=(0,Z.jsxs)(we,{className:`jsx-component-wrapper my-2`,"data-jsx-component":``,"data-component-type":Te,"data-align":Ee,"data-selected":De,"data-has-child-selected":Oe,"data-range-selected":ke,"data-selection-origin":j,"data-dragging":Ae,"data-needs-config":je,role:Me,"aria-label":be,tabIndex:Ne,...Pe,"data-component-name":Fe,onClick:he,onKeyDown:xe,children:[Ye,Xe,Ze]}),t[112]=we,t[113]=u.name,t[114]=be,t[115]=he,t[116]=xe,t[117]=j,t[118]=Te,t[119]=Ee,t[120]=De,t[121]=Oe,t[122]=ke,t[123]=Ae,t[124]=je,t[125]=Me,t[126]=Ne,t[127]=Pe,t[128]=Ye,t[129]=Xe,t[130]=Ze,t[131]=Qe):Qe=t[131];let $e;t[132]!==l||t[133]!==P||t[134]!==u.Component||t[135]!==u.displayName||t[136]!==u.name||t[137]!==ne||t[138]!==z||t[139]!==r||t[140]!==a||t[141]!==_||t[142]!==K||t[143]!==V?($e=z&&typeof _==`number`?(0,Z.jsx)(nE,{open:ne,onOpenChange:V,initialValue:typeof P[z.propName]==`string`?P[z.propName]:``,language:z.language,title:l({id:`ky9Tuc`,values:{0:u.displayName??u.name}}),renderPreview:e=>{let t=u.Component;return(0,Z.jsx)(`div`,{className:`flex h-full w-full items-center justify-center p-4`,children:(0,Z.jsx)(t,{...K,[z.propName]:e,...u.name===`MermaidFence`&&{className:`border-0 bg-transparent rounded-none`}})})},onSave:e=>{let t=typeof a==`function`?a():void 0;if(typeof t!=`number`)return;let n=r.state.doc.nodeAt(t);if(!n)return;let i=QA(n.attrs);if(i)try{let n={...i.props,[z.propName]:e},a={...i,props:n,sourceDirty:!0};r.view.dispatch(r.state.tr.setNodeMarkup(t,null,a)),$t()}catch(e){let t=e;if(!(t instanceof RangeError))throw t;console.warn(`[JsxComponentView] edit-save failed — position race`,t)}}}):null,t[132]=l,t[133]=P,t[134]=u.Component,t[135]=u.displayName,t[136]=u.name,t[137]=ne,t[138]=z,t[139]=r,t[140]=a,t[141]=_,t[142]=K,t[143]=V,t[144]=$e):$e=t[144];let et;t[145]!==u||t[146]!==r||t[147]!==a||t[148]!==N||t[149]!==R||t[150]!==H||t[151]!==me||t[152]!==h||t[153]!==I?(et=N&&(0,Z.jsxs)(Au,{side:I?`bottom`:`right`,align:I?`center`:`start`,sideOffset:I?-4:8,className:`w-64 p-3 z-60 overflow-y-auto subtle-scrollbar max-h-(--radix-popper-available-height) overscroll-contain`,onCloseAutoFocus:R?e=>{e.preventDefault(),r.view.focus()}:void 0,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,Z.jsx)(o,{id:`Mnavhe`,values:{propPanelDescriptorLabel:me}})}),(0,Z.jsx)(rA,{descriptor:u,values:H,onDismiss:()=>h(!1),onChange:(e,t)=>{let n=typeof a==`function`?a():void 0;if(typeof n!=`number`)return;let i=r.state.doc.nodeAt(n);if(!i)return;let o=QA(i.attrs);if(!o)return;let s={...o.props},c=Array.isArray(i.attrs.attributes)?i.attrs.attributes:[],l=c;t===void 0?(delete s[e],l=c.filter(t=>!(typeof t==`object`&&t&&t.type===`mdxJsxAttribute`&&t.name===e))):s[e]=t,r.view.dispatch(r.state.tr.setNodeMarkup(n,null,{...o,attributes:l,props:s,sourceDirty:!0})),$t()}}),(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-border pt-2`,children:(0,Z.jsx)(zt,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>h(!1),className:`h-7 px-3 text-xs`,children:(0,Z.jsx)(o,{id:`DPfwMq`})})})]}),t[145]=u,t[146]=r,t[147]=a,t[148]=N,t[149]=R,t[150]=H,t[151]=me,t[152]=h,t[153]=I,t[154]=et):et=t[154];let tt;return t[155]!==Ce||t[156]!==Se||t[157]!==p||t[158]!==Qe||t[159]!==$e||t[160]!==et?(tt=(0,Z.jsxs)(Ce,{open:p,onOpenChange:Se,children:[Qe,$e,et]}),t[155]=Ce,t[156]=Se,t[157]=p,t[158]=Qe,t[159]=$e,t[160]=et,t[161]=tt):tt=t[161],tt}function tj(e){return e.stopPropagation()}function nj(e){return e.stopPropagation()}function rj(e){return e.stopPropagation()}function ij(e){return e.stopPropagation()}function aj(e){return e.preventDefault()}function oj(e){return!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`}var sj=de.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return bn(ej)}}),cj={name:`InlineMath`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,category:`content`,description:`Inline math`,props:[{name:`formula`,type:`string`,required:!0,autoFocus:!0,description:`LaTeX inline math source`}]},lj=(0,Q.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-BunQWEOH.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,$.c)(4),r;n[0]===t.formula?r=n[1]:(r=e.renderToString(t.formula,{displayMode:!1,throwOnError:!1,strict:`ignore`,trust:!1}),n[0]=t.formula,n[1]=r);let i=r,a;return n[2]===i?a=n[3]:(a=(0,Z.jsx)(`span`,{className:`math math-inline`,dangerouslySetInnerHTML:{__html:i}}),n[2]=i,n[3]=a),a}return{default:t}});function uj(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`span`,{className:`math math-inline math-placeholder math-placeholder-empty inline-flex items-center gap-1 rounded-sm border border-dashed border-muted-foreground/40 bg-muted/30 px-1.5 py-0.5 text-xs italic text-muted-foreground hover:bg-muted/60 cursor-pointer`,"data-component-type":`math-inline`,children:`f(x)`}),e[0]=t):t=e[0],t}function dj(e){let t=(0,$.c)(2),n;return t[0]===e.formula?n=t[1]:(n=(0,Z.jsx)(`span`,{className:`math math-inline math-placeholder`,"data-component-type":`math-inline`,children:e.formula}),t[0]=e.formula,t[1]=n),n}function fj(e){let t=(0,$.c)(38),{node:n,selected:r,getPos:i,editor:a}=e,s=typeof n.attrs.formula==`string`?n.attrs.formula:``,c=typeof n.attrs.id==`string`?n.attrs.id:void 0,[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(!1),f;t[0]!==a.state||t[1]!==i||t[2]!==r?(f=()=>{let e=r&&a.state.selection instanceof bt;e&&!d.current?(fb(typeof i==`function`?i()??0:0),u(!0)):!e&&d.current&&u(!1),d.current=e},t[0]=a.state,t[1]=i,t[2]=r,t[3]=f):f=t[3];let p;t[4]!==a||t[5]!==i||t[6]!==r?(p=[r,i,a],t[4]=a,t[5]=i,t[6]=r,t[7]=p):p=t[7],(0,Q.useEffect)(f,p);let m=r?`math-inline-selected`:void 0,h;t[8]===c?h=t[9]:(h=c?{id:c}:{},t[8]=c,t[9]=h);let g;t[10]===s?g=t[11]:(g=s?(0,Z.jsx)(ek,{resetKeys:[s],onError:mj,fallbackRender:()=>(0,Z.jsx)(`span`,{className:`math math-inline math-error`,children:s}),children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(dj,{formula:s}),children:(0,Z.jsx)(lj,{formula:s})})}):(0,Z.jsx)(uj,{}),t[10]=s,t[11]=g);let _;t[12]!==s||t[13]!==h||t[14]!==g?(_=(0,Z.jsx)(ku,{asChild:!0,children:(0,Z.jsx)(`span`,{className:`math-inline-trigger`,"data-component-type":`math-inline`,"data-formula":s,...h,children:g})}),t[12]=s,t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===a.view?v=t[17]:(v=e=>{e.preventDefault(),a.view.focus()},t[16]=a.view,t[17]=v);let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground px-3 pt-2`,children:(0,Z.jsx)(o,{id:`EOjU5V`})}),t[18]=y):y=t[18];let b;t[19]===s?b=t[20]:(b={formula:s},t[19]=s,t[20]=b);let x;t[21]!==a.state||t[22]!==a.view||t[23]!==i?(x=(e,t)=>{let n=typeof i==`function`?i():void 0;if(typeof n!=`number`)return;let r=a.state.doc.nodeAt(n);if(!r||r.type.name!==`mathInline`)return;let o=a.state.tr.setNodeMarkup(n,null,{...r.attrs,[e]:t??``});o.setSelection(bt.create(o.doc,n)),a.view.dispatch(o)},t[21]=a.state,t[22]=a.view,t[23]=i,t[24]=x):x=t[24];let S;t[25]!==x||t[26]!==b?(S=(0,Z.jsx)(rA,{descriptor:cj,values:b,onChange:x}),t[25]=x,t[26]=b,t[27]=S):S=t[27];let C;t[28]!==S||t[29]!==v?(C=(0,Z.jsxs)(Au,{className:`z-[60] w-72 p-0`,side:`bottom`,align:`start`,onOpenAutoFocus:pj,onCloseAutoFocus:v,children:[y,S]}),t[28]=S,t[29]=v,t[30]=C):C=t[30];let w;t[31]!==l||t[32]!==C||t[33]!==_?(w=(0,Z.jsxs)(Ou,{open:l,onOpenChange:u,children:[_,C]}),t[31]=l,t[32]=C,t[33]=_,t[34]=w):w=t[34];let T;return t[35]!==w||t[36]!==m?(T=(0,Z.jsx)(Dn,{as:`span`,className:m,children:w}),t[35]=w,t[36]=m,t[37]=T):T=t[37],T}function pj(e){e.preventDefault()}function mj(e,t){let n=e instanceof Error?e:Error(String(e));console.warn(JSON.stringify({event:`jsx-render-failure`,component:`mathInline`,rawComponentName:`mathInline`,error:String(n),stack:t.componentStack})),M(`mathInline`)}var hj=N.extend({addNodeView(){return bn(fj)}});function gj(e,t){if(!e.selection.empty)return null;let n=t===`up`||t===`left`?-1:1,r=e.selection.$head,i=n>0?r.after():r.before();if(typeof i!=`number`)return null;let a=wt.near(e.doc.resolve(i),n);return a.$head?.parent.type.name===`rawMdxFallback`?a:null}function _j(e,t){let{state:n,view:r}=e;if(!r.endOfTextblock(t))return!1;let i=gj(n,t);return i?(r.dispatch(n.tr.setSelection(i)),!0):!1}var vj=Ne.extend({addKeyboardShortcuts(){return{ArrowLeft:({editor:e})=>_j(e,`left`),ArrowRight:({editor:e})=>_j(e,`right`),ArrowUp:({editor:e})=>_j(e,`up`),ArrowDown:({editor:e})=>_j(e,`down`)}},addNodeView(){return bn(An,{stopEvent:()=>!0,ignoreMutation:()=>!0})}});function yj(e){let t=(0,$.c)(51),{items:n,selectedIndex:r,categoryLabels:i,onSelect:a,onHoverIndex:c}=e,l=(0,Q.useRef)(null),u=(0,Q.useId)(),{_:d}=s(),f=r>=0&&r<n.length?`${u}-option-${r}`:void 0,p=xj,m,h;if(t[0]===r?(m=t[1],h=t[2]):(m=()=>{let e=l.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(r);t&&t.scrollIntoView({block:`nearest`})},h=[r],t[0]=r,t[1]=m,t[2]=h),(0,Q.useEffect)(m,h),n.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[3]=e):e=t[3];let n;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`div`,{ref:l,role:`status`,"aria-live":`polite`,className:`w-56 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:e,onMouseDown:p,children:(0,Z.jsx)(o,{id:`Ev2r9A`})}),t[4]=n):n=t[4],n}let g,_,v,y,b,x,S,C,w,T,E,D,O;if(t[5]!==d||t[6]!==f||t[7]!==i||t[8]!==n||t[9]!==u||t[10]!==c||t[11]!==a||t[12]!==r){let e=[],o=0,s=new Map;for(let t of n){s.set(t,o++);let n=e.find(e=>e.key===t.category);n?n.items.push(t):e.push({key:t.category,items:[t]})}_=r>=0&&r<n.length?n[r]:null;let m;t[26]===n?m=t[27]:(m=n.some(bj),t[26]=n,t[27]=m),g=m,x=`flex items-start gap-2`,S=l,C=`listbox`,t[28]===d?w=t[29]:(w=d({id:`RlCInP`}),t[28]=d,t[29]=w),T=f,E=-1,D=p,O=`w-56 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(v={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[30]=v):v=t[30];let h=_?`${_.label}${_.preview?`. ${_.preview.description}`:``}`:``;t[31]===h?y=t[32]:(y=(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:h}),t[31]=h,t[32]=y),b=e.map(e=>(0,Z.jsxs)(`div`,{role:`group`,"aria-labelledby":`${u}-group-${e.key}`,children:[(0,Z.jsx)(`div`,{id:`${u}-group-${e.key}`,className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground`,children:i[e.key]??e.key}),e.items.map(e=>{let t=s.get(e)??0,n=t===r,i=e.icon;return(0,Z.jsxs)(`button`,{id:`${u}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseEnter:()=>c?.(t),onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,Z.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`flex flex-col min-w-0`,children:(0,Z.jsx)(`span`,{className:`truncate`,children:e.label})})]},e.name)})]},e.key)),t[5]=d,t[6]=f,t[7]=i,t[8]=n,t[9]=u,t[10]=c,t[11]=a,t[12]=r,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=O}else g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21],T=t[22],E=t[23],D=t[24],O=t[25];let k;t[33]!==v||t[34]!==y||t[35]!==b||t[36]!==S||t[37]!==C||t[38]!==w||t[39]!==T||t[40]!==E||t[41]!==D||t[42]!==O?(k=(0,Z.jsxs)(`div`,{ref:S,role:C,"aria-label":w,"aria-activedescendant":T,tabIndex:E,onMouseDown:D,className:O,style:v,children:[y,b]}),t[33]=v,t[34]=y,t[35]=b,t[36]=S,t[37]=C,t[38]=w,t[39]=T,t[40]=E,t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]!==g||t[45]!==_?(A=g?(0,Z.jsx)(`aside`,{"aria-hidden":`true`,onMouseDown:p,className:`w-64 rounded-lg border bg-popover p-2 shadow-md ${_?.preview?``:`invisible`}`,children:_?.preview?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mb-2 flex aspect-5/3 items-center justify-center overflow-hidden rounded-md bg-muted/40 p-3 *:max-h-full *:max-w-full [&_img]:size-full [&_img]:rounded-md [&_img]:object-contain`,children:_.preview.render()}),(0,Z.jsx)(`p`,{className:`line-clamp-3 px-1 pb-1 text-xs text-muted-foreground`,children:_.preview.description})]}):null}):null,t[44]=g,t[45]=_,t[46]=A):A=t[46];let j;return t[47]!==x||t[48]!==k||t[49]!==A?(j=(0,Z.jsxs)(`div`,{className:x,children:[k,A]}),t[47]=x,t[48]=k,t[49]=A,t[50]=j):j=t[50],j}function bj(e){return e.preview}function xj(e){return e.preventDefault()}var Sj=new ke(`slashCommand`),Cj=Y.create({name:`slashCommand`,addOptions(){return{itemsSources:[Tb],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[Vt({editor:this.editor,pluginKey:Sj,char:`/`,startOfLine:!1,allow:({editor:e})=>!ln(e),items:({query:t})=>{let n=e.options.itemsSources.flatMap(e=>{try{return e()}catch(e){return console.error(`[slash-command] item source threw an error`,e),[]}}),r=Object.keys(e.options.categoryLabels),i=e=>{let t=r.indexOf(e);return t===-1?1/0:t};return Eb(n.map((e,t)=>({item:e,i:t})).sort((e,t)=>{let n=i(e.item.category)-i(t.item.category);return n===0?e.i-t.i:n}).map(e=>e.item),t)},command:({editor:e,range:t,props:n})=>{try{e.chain().focus().deleteRange(t).run()}catch(e){console.error(`[slash-command] deleteRange failed for "${n.name}"`,e);return}try{n.command(e)}catch(e){console.error(`[slash-command] command "${n.name}" threw an error`,e)}},render:()=>{let t=null,n=null,r=0,i={popup:null,stopAutoUpdate:null},a=null,o=e=>{e!==r&&(r=e,s())},s=()=>{!t||!n||t.updateProps({items:n.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:n.command,onHoverIndex:o})};return{onStart(s){n=s,r=0;let c=cn(()=>n,`slash-command`);i.popup=c.popup,a=c.doPosition,t=new dn(yj,{props:{items:s.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:s.command,onHoverIndex:o},editor:s.editor}),c.popup.appendChild(t.element),i.stopAutoUpdate=c.startAutoUpdate(),c.reveal()},onUpdate(e){n=e,r=Math.min(r,Math.max(0,e.items.length-1)),s(),a?.()},onKeyDown({event:e}){if(!n||n.items.length===0)return!1;let t=n.items;if(e.key===`ArrowDown`)return r=(r+1)%t.length,s(),!0;if(e.key===`ArrowUp`)return r=(r-1+t.length)%t.length,s(),!0;if(e.key===`Enter`||e.key===`Tab`){let e=t[r];return e&&n.command(e),!0}return e.key,!1},onExit(){sn(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}}),wj=new ke(`sourceDirty`),Tj=Y.create({name:`sourceDirtyObserver`,addProseMirrorPlugins(){return[new Et({key:wj,appendTransaction(e,t,n){if(!e.some(e=>!e.getMeta(jd))||!e.some(e=>e.docChanged))return null;let r=new St;for(let t of e)r.appendMapping(t.mapping);let i=r.invert(),a=[];if(n.doc.descendants((e,n)=>{if(e.type.name!==`jsxComponent`||e.attrs.sourceDirty)return;let r=i.map(n),o=t.doc.nodeAt(r),s=!o||o.type.name!==`jsxComponent`,c=typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0;if(s&&c)return;if(!o){(e.content.size>0||Object.keys(e.attrs.props??{}).length>0)&&a.push({pos:n});return}if(o.type.name!==`jsxComponent`){a.push({pos:n});return}let l=!Ej(o.attrs.props,e.attrs.props),u=!o.content.eq(e.content);(l||u)&&a.push({pos:n})}),a.length===0)return null;let o=n.tr;for(let{pos:e}of a)o.setNodeAttribute(e,`sourceDirty`,!0);return o}})]}});function Ej(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!=`object`)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ej(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Ej(e[r],t[r]))return!1;return!0}var Dj=Y.create({name:`tabFocusTrap`,priority:1,addKeyboardShortcuts(){return{Tab:()=>!0,"Shift-Tab":()=>!0}}});function Oj(e,t){let n=e.doc.nodeAt(t);if(!n||n.type.name!==`table`)return null;let r=oe.get(n);return{map:r,tableStart:t+1,table:n,left:0,top:0,right:r.width,bottom:r.height}}function kj(e,t){let n=Oj(e,t);return n?kt(e.tr,n,n.map.width):null}function Aj(e,t){let n=Oj(e,t);return n?v(e.tr,n,n.map.height):null}function jj(e,t){if(!e.dom.contains(t))return null;let n;try{n=e.posAtDOM(t,0)}catch{return null}return n<0?null:fe(e.state.doc.resolve(n))?.pos??null}var Mj=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="M12 5v14"/></svg>`;function Nj(e,t){let n=document.createElement(`button`);return n.type=`button`,n.className=`ok-table-insert-bar ok-table-insert-${e}`,n.setAttribute(`aria-label`,t),n.tabIndex=-1,n.setAttribute(dC,`true`),n.innerHTML=Mj,n.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()}),n}var Pj=class{overlays=new Map;mount;lastEditable;constructor(e,t){this.view=e,this.editor=t,this.mount=e.dom.parentElement??e.dom,this.lastEditable=t.isEditable,this.reconcile()}update(e,t){let n=this.editor.isEditable!==this.lastEditable;this.lastEditable=this.editor.isEditable,!(!n&&t.doc.eq(this.view.state.doc))&&this.reconcile()}destroy(){for(let e of this.overlays.keys())this.removeOverlay(e)}reconcile(){if(!this.editor.isEditable){this.destroy();return}let e=new Set(this.view.dom.querySelectorAll(`.tableWrapper`));for(let t of this.overlays.keys())e.has(t)||this.removeOverlay(t);for(let t of e)this.overlays.has(t)||this.addOverlay(t)}addOverlay(e){let t=document.createElement(`div`);t.className=`ok-table-insert-controls`,t.setAttribute(dC,`true`);let n=Nj(`column`,`Add column`),r=Nj(`row`,`Add row`);n.addEventListener(`click`,()=>this.insert(e,kj)),r.addEventListener(`click`,()=>this.insert(e,Aj)),t.append(n,r),this.mount.appendChild(t);let i=ti(e,t,()=>{let{width:t,height:i}=e.getBoundingClientRect();$r(e,n,{strategy:`absolute`,placement:`right-start`}).then(({x:e,y:t})=>{n.style.left=`${e}px`,n.style.top=`${t}px`,n.style.height=`${i}px`}).catch(()=>{}),$r(e,r,{strategy:`absolute`,placement:`bottom-start`}).then(({x:e,y:n})=>{r.style.left=`${e}px`,r.style.top=`${n}px`,r.style.width=`${t}px`}).catch(()=>{})}),a=e=>{let t=e.target instanceof Element?e.target.closest(`td, th`):null,i=t?.parentElement;n.classList.toggle(`is-active`,!!t&&t===i?.lastElementChild),r.classList.toggle(`is-active`,!!i&&i===i.parentElement?.lastElementChild)},o=()=>{n.classList.remove(`is-active`),r.classList.remove(`is-active`)};e.addEventListener(`pointerover`,a),e.addEventListener(`pointerleave`,o),this.overlays.set(e,{container:t,cleanup:()=>{i(),e.removeEventListener(`pointerover`,a),e.removeEventListener(`pointerleave`,o),t.remove()}})}removeOverlay(e){let t=this.overlays.get(e);t&&(t.cleanup(),this.overlays.delete(e))}insert(e,t){let n=e.querySelector(`table`);if(!n)return;let r=jj(this.view,n);if(r===null)return;let i=t(this.view.state,r);i&&(this.view.dispatch(i),this.view.focus())}},Fj=Y.create({name:`tableInsertControls`,addProseMirrorPlugins(){let e=this.editor;return[new Et({key:new ke(`tableInsertControls`),view:t=>new Pj(t,e)})]}}),Ij=`ok:tag-click`;function Lj(e){if(typeof document>`u`)return;let t={value:e};document.dispatchEvent(new CustomEvent(Ij,{detail:t}))}function Rj(e){return e instanceof Element?e.closest(`a[data-tag]`):null}var zj=Y.create({name:`tagClick`,addProseMirrorPlugins(){return[new Et({props:{handleDOMEvents:{click(e,t){let n=Rj(t.target);if(!n)return!1;let r=n.getAttribute(`data-tag`);return r?(t.preventDefault(),t.stopPropagation(),Lj(r),!0):!1}}}})]}});function Bj(e,t,n){if(typeof t!=`number`||!n||!Ot.test(n))return!1;let{state:r,view:i}=e,a=r.doc.nodeAt(t);if(!a||a.type.name!==`tag`)return!1;let o=r.tr.setNodeMarkup(t,null,{...a.attrs,value:n}),s=t+a.nodeSize;return o.insertText(` `,s),o.setSelection(y.create(o.doc,s+1)),i.dispatch(o),i.focus(),!0}function Vj(e,t){if(typeof t!=`number`)return;let{state:n,view:r}=e,i=n.doc.nodeAt(t);if(!i||i.type.name!==`tag`)return;let a=n.tr.delete(t,t+i.nodeSize);r.dispatch(a),r.focus()}function Hj(e){let t=(0,$.c)(3),{value:n}=e,r=`#tag/${n}`,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsxs)(`a`,{className:`tag`,"data-tag":n,href:r,children:[`#`,n]}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function Uj(e){let t=(0,$.c)(20),{initialDraft:n,onCommit:r,onCancel:i}=e,{_:a}=s(),o=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(n),u=(0,Q.useRef)(!1),d,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=requestAnimationFrame(()=>{o.current?.focus()});return()=>cancelAnimationFrame(e)},f=[],t[0]=d,t[1]=f):(d=t[0],f=t[1]),(0,Q.useEffect)(d,f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono`,children:`#`}),t[2]=p):p=t[2];let m=Math.max(c.length,8),h;t[3]===a?h=t[4]:(h=a({id:`U2pMtf`}),t[3]=a,t[4]=h);let g;t[5]===a?g=t[6]:(g=a({id:`knjOzA`}),t[5]=a,t[6]=g);let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{let t=e.target.value;(t===``||Ot.test(t))&&l(t)},t[7]=_):_=t[7];let v,y;t[8]!==c||t[9]!==i||t[10]!==r?(v=e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),u.current=!0,r(c)||(u.current=!1,i())):(e.key===`Escape`||e.key===`Backspace`&&c===``)&&(e.preventDefault(),i())},y=()=>{if(!u.current){if(c===``){i();return}Ot.test(c)?r(c):i()}},t[8]=c,t[9]=i,t[10]=r,t[11]=v,t[12]=y):(v=t[11],y=t[12]);let b;return t[13]!==c||t[14]!==m||t[15]!==h||t[16]!==g||t[17]!==v||t[18]!==y?(b=(0,Z.jsxs)(`span`,{className:`tag tag-placeholder inline-flex items-center rounded-sm border border-dashed border-muted-foreground/40 bg-muted/30 px-1.5 py-0.5 text-xs text-muted-foreground`,"data-component-type":`tag-placeholder`,children:[p,(0,Z.jsx)(`input`,{ref:o,type:`text`,value:c,size:m,placeholder:h,"aria-label":g,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,className:`bg-transparent border-0 p-0 outline-none focus:outline-none focus:ring-0 text-inherit font-inherit`,onChange:_,onKeyDown:v,onBlur:y})]}),t[13]=c,t[14]=m,t[15]=h,t[16]=g,t[17]=v,t[18]=y,t[19]=b):b=t[19],b}function Wj(e){let t=(0,$.c)(5),{node:n,getPos:r,editor:i}=e,a=typeof n.attrs.value==`string`?n.attrs.value:``;if(a===``){let e;return t[0]!==i||t[1]!==r?(e=(0,Z.jsx)(Dn,{as:`span`,children:(0,Z.jsx)(Uj,{initialDraft:``,onCommit:e=>Bj(i,typeof r==`function`?r():void 0,e),onCancel:()=>Vj(i,typeof r==`function`?r():void 0)})}),t[0]=i,t[1]=r,t[2]=e):e=t[2],e}let o;return t[3]===a?o=t[4]:(o=(0,Z.jsx)(Dn,{as:`span`,children:(0,Z.jsx)(Hj,{value:a})}),t[3]=a,t[4]=o),o}var Gj=C.extend({priority:200,addNodeView(){return bn(Wj)},addKeyboardShortcuts(){return{Backspace:()=>{if(rl.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`tag`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(rl.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`tag`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[ul(this.editor)]}}),Kj=2048,qj=24;function Jj(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>Kj)return{kind:`unsupported`,value:``};if(Zj(t))return{kind:`emoji`,value:t};let n=Qj(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:le(`/api/asset?path=${encodeURIComponent(Xj(t))}`)}:{kind:`unsupported`,value:``}}function Yj(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>Kj)return{kind:`unsupported`,value:``};let n=Qj(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:le(`/api/asset?path=${encodeURIComponent(Xj(t))}`)}:{kind:`unsupported`,value:``}}function Xj(e){return e.startsWith(`/`)?e.slice(1):e}function Zj(e){if(/\p{L}/u.test(e)||e.includes(`/`))return!1;let t=0;for(let n of e)t++;if(t>qj)return!1;let n=e.lastIndexOf(`.`);if(n>-1){let t=e.slice(n+1).toLowerCase();if(j.has(t))return!1}return!0}function Qj(e){let t=$j(e);if(!t||!j.has(t))return`unsupported`;let n=e.indexOf(`:`),r=e.indexOf(`/`);return n>-1&&(r===-1||n<r)?ye(e)?`url`:`unsupported`:e.startsWith(`//`)||e.includes(`?`)||e.includes(`#`)||e.startsWith(`../`)||e.includes(`/../`)?`unsupported`:`path`}function $j(e){let t=e.lastIndexOf(`/`),n=t>-1?e.slice(t+1):e,r=n.search(/[?#]/),i=r>-1?n.slice(0,r):n,a=i.lastIndexOf(`.`);return a<=0||a===i.length-1?null:i.slice(a+1).toLowerCase()}function eM(e){let t=(0,$.c)(133),{open:n,target:r,alias:i,anchor:a,pages:c,assetPaths:l,filePaths:u,loading:d,onOpenChange:f,onSave:p}=e,[m,h]=(0,Q.useState)(r),[g,_]=(0,Q.useState)(i??``),[v,y]=(0,Q.useState)(a??``),b=(0,Q.useId)(),x=(0,Q.useId)(),S=(0,Q.useId)(),C=(0,Q.useId)(),{_:w}=s(),T;t[0]!==l||t[1]!==m||t[2]!==u?(T=on(m,l,u),t[0]=l,t[1]=m,t[2]=u,t[3]=T):T=t[3];let E=T,D;t[4]!==l||t[5]!==m||t[6]!==u||t[7]!==c?(D=rn(m,c,l,u),t[4]=l,t[5]=m,t[6]=u,t[7]=c,t[8]=D):D=t[8];let O=HO(m,D&&!E&&n),k=(0,Q.useRef)(!1),A,j;t[9]!==i||t[10]!==a||t[11]!==n||t[12]!==r?(A=()=>{if(!n){k.current=!1;return}k.current||(k.current=!0,h(r),_(i??``),y(a??``))},j=[n,r,i,a],t[9]=i,t[10]=a,t[11]=n,t[12]=r,t[13]=A,t[14]=j):(A=t[13],j=t[14]),(0,Q.useEffect)(A,j);let M;t[15]!==g||t[16]!==v||t[17]!==m||t[18]!==f||t[19]!==p?(M=function(){let e=m.trim();e&&(p(e,g.trim()||null,v.trim()||null),f(!1))},t[15]=g,t[16]=v,t[17]=m,t[18]=f,t[19]=p,t[20]=M):M=t[20];let N=M,P;t[21]===N?P=t[22]:(P=function(e){e.key===`Enter`&&(e.preventDefault(),N())},t[21]=N,t[22]=P);let F=P,I;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(I=function(e){h(e.path),y(``)},t[23]=I):I=t[23];let L=I,R,ee,z,te,ne,re,B,V,H,U,W,G,ie,K,ae,oe,q;if(t[24]!==w||t[25]!==S||t[26]!==x||t[27]!==l||t[28]!==g||t[29]!==v||t[30]!==m||t[31]!==F||t[32]!==C||t[33]!==O||t[34]!==d||t[35]!==f||t[36]!==n||t[37]!==c||t[38]!==b){let e=new Map,r=O?.map(t=>{let n=e.get(t.slug)??0;e.set(t.slug,n+1);let r=n===0?t.slug:`${t.slug}-${n}`;return{...t,reactKey:r}}),i=!!r?.length;z=Hr,K=n,ae=f,ee=Pr,V=`sm:max-w-xl`,H=``,U=wO,W=wO,G=wO;let a;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(kr,{children:(0,Z.jsx)(o,{id:`xzktOa`})}),t[56]=a):a=t[56],t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsxs)(Vr,{children:[a,(0,Z.jsx)(Or,{children:(0,Z.jsx)(o,{id:`Jhj_lh`})})]}),t[57]=ie):ie=t[57],R=Lr,ne=`space-y-6`;let s;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(o,{id:`lGs_bQ`,components:{0:(0,Z.jsx)(`span`,{className:`text-red-500`})}}),t[58]=s):s=t[58];let u;t[59]===b?u=t[60]:(u=(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:b,children:s}),t[59]=b,t[60]=u);let p;t[61]===w?p=t[62]:(p=w({id:`aM23Wr`}),t[61]=w,t[62]=p);let T;t[63]!==l||t[64]!==m||t[65]!==F||t[66]!==d||t[67]!==c||t[68]!==p||t[69]!==b?(T=(0,Z.jsx)(DO,{id:b,value:m,pages:c,assetPaths:l,includeAssets:!0,loading:d,onValueChange:h,onSuggestionSelect:L,placeholder:p,autoFocus:!0,"aria-required":`true`,onKeyDown:F}),t[63]=l,t[64]=m,t[65]=F,t[66]=d,t[67]=c,t[68]=p,t[69]=b,t[70]=T):T=t[70],t[71]!==u||t[72]!==T?(re=(0,Z.jsxs)(`div`,{children:[u,T]}),t[71]=u,t[72]=T,t[73]=re):re=t[73];let E;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(o,{id:`OTF92M`,components:{0:(0,Z.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[74]=E):E=t[74];let D;t[75]===S?D=t[76]:(D=(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:S,children:E}),t[75]=S,t[76]=D);let k;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>_(e.target.value),t[77]=k):k=t[77];let A;t[78]===w?A=t[79]:(A=w({id:`BH56dn`}),t[78]=w,t[79]=A);let j;t[80]!==S||t[81]!==g||t[82]!==F||t[83]!==A?(j=(0,Z.jsx)(ri,{id:S,value:g,onChange:k,placeholder:A,onKeyDown:F}),t[80]=S,t[81]=g,t[82]=F,t[83]=A,t[84]=j):j=t[84],t[85]!==D||t[86]!==j?(B=(0,Z.jsxs)(`div`,{children:[D,j]}),t[85]=D,t[86]=j,t[87]=B):B=t[87];let M;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(o,{id:`Tjc1pH`,components:{0:(0,Z.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[88]=M):M=t[88],t[89]===x?oe=t[90]:(oe=(0,Z.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:x,children:M}),t[89]=x,t[90]=oe);let N;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>y(e.target.value),t[91]=N):N=t[91];let P;t[92]===w?P=t[93]:(P=w({id:`W-ntoW`}),t[92]=w,t[93]=P),t[94]!==x||t[95]!==v||t[96]!==F||t[97]!==P?(q=(0,Z.jsx)(ri,{id:x,value:v,onChange:N,placeholder:P,onKeyDown:F}),t[94]=x,t[95]=v,t[96]=F,t[97]=P,t[98]=q):q=t[98],te=i&&(0,Z.jsx)(`div`,{id:C,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:r.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":v===e.slug,className:Ft(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,v===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>y(v===e.slug?``:e.slug),children:[(0,Z.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.text})]},e.reactKey))}),t[24]=w,t[25]=S,t[26]=x,t[27]=l,t[28]=g,t[29]=v,t[30]=m,t[31]=F,t[32]=C,t[33]=O,t[34]=d,t[35]=f,t[36]=n,t[37]=c,t[38]=b,t[39]=R,t[40]=ee,t[41]=z,t[42]=te,t[43]=ne,t[44]=re,t[45]=B,t[46]=V,t[47]=H,t[48]=U,t[49]=W,t[50]=G,t[51]=ie,t[52]=K,t[53]=ae,t[54]=oe,t[55]=q}else R=t[39],ee=t[40],z=t[41],te=t[42],ne=t[43],re=t[44],B=t[45],V=t[46],H=t[47],U=t[48],W=t[49],G=t[50],ie=t[51],K=t[52],ae=t[53],oe=t[54],q=t[55];let se;t[99]!==te||t[100]!==oe||t[101]!==q?(se=(0,Z.jsxs)(`div`,{children:[oe,q,te]}),t[99]=te,t[100]=oe,t[101]=q,t[102]=se):se=t[102];let ce;t[103]!==ne||t[104]!==re||t[105]!==B||t[106]!==se?(ce=(0,Z.jsxs)(`div`,{className:ne,children:[re,B,se]}),t[103]=ne,t[104]=re,t[105]=B,t[106]=se,t[107]=ce):ce=t[107];let J;t[108]!==R||t[109]!==ce?(J=(0,Z.jsx)(R,{children:ce}),t[108]=R,t[109]=ce,t[110]=J):J=t[110];let le;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Z.jsx)(Br,{asChild:!0,children:(0,Z.jsx)(zt,{variant:`outline`,children:(0,Z.jsx)(o,{id:`dEgA5A`})})}),t[111]=le):le=t[111];let ue;t[112]===m?ue=t[113]:(ue=m.trim(),t[112]=m,t[113]=ue);let Y=!ue,de;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Z.jsx)(o,{id:`tfDRzk`}),t[114]=de):de=t[114];let fe;t[115]!==N||t[116]!==Y?(fe=(0,Z.jsxs)(Rr,{children:[le,(0,Z.jsx)(zt,{onClick:N,disabled:Y,children:de})]}),t[115]=N,t[116]=Y,t[117]=fe):fe=t[117];let pe;t[118]!==ee||t[119]!==V||t[120]!==H||t[121]!==U||t[122]!==W||t[123]!==G||t[124]!==ie||t[125]!==J||t[126]!==fe?(pe=(0,Z.jsxs)(ee,{className:V,"data-ok-layer-spawned":H,onPointerDownOutside:U,onFocusOutside:W,onInteractOutside:G,children:[ie,J,fe]}),t[118]=ee,t[119]=V,t[120]=H,t[121]=U,t[122]=W,t[123]=G,t[124]=ie,t[125]=J,t[126]=fe,t[127]=pe):pe=t[127];let me;return t[128]!==z||t[129]!==K||t[130]!==ae||t[131]!==pe?(me=(0,Z.jsx)(z,{open:K,onOpenChange:ae,children:pe}),t[128]=z,t[129]=K,t[130]=ae,t[131]=pe,t[132]=me):me=t[132],me}function tM(e){let t=(0,$.c)(116),{editor:n,getPos:r,onClose:i,onNavigate:a}=e,c=r(),l=c==null?null:n.state.doc.nodeAt(c),u=String(l?.attrs.target??``),d=De(l?.attrs.alias),f=De(l?.attrs.anchor),p=Ct({target:u,alias:d,anchor:f}),{addPage:m,assetPaths:h,filePaths:g,folderPaths:_,pages:v,pagesBySlug:y,pagesByBasename:b,loading:x}=Wn(),S=lt(u,f),C=S?.kind===`external`?S:null,w=S?.kind===`asset`?on(S.url,h,g)??S.url.replace(/^\//,``):null,T=w?null:In(u,{pages:v,folderPaths:_,pagesBySlug:y,pagesByBasename:b,fallbackTargets:Kt(u)}),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(!1),{_:A}=s();if(!l)return null;let j;t[0]!==n.state||t[1]!==n.view||t[2]!==r?(j=function(e,t,i){let a=r();a!=null&&n.view.dispatch(n.state.tr.setNodeMarkup(a,void 0,{...n.state.doc.nodeAt(a)?.attrs,target:e,alias:t,anchor:i}))},t[0]=n.state,t[1]=n.view,t[2]=r,t[3]=j):j=t[3];let M=j,N;t[4]!==n.state||t[5]!==n.view||t[6]!==r||t[7]!==i?(N=function(){let e=r();if(e==null)return;let t=n.state.doc.nodeAt(e);t&&(n.view.dispatch(n.state.tr.delete(e,e+t.nodeSize)),i())},t[4]=n.state,t[5]=n.view,t[6]=r,t[7]=i,t[8]=N):N=t[8];let P=N,F=function(e){if(e!==u){let t=r();if(t==null)return;n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...n.state.doc.nodeAt(t)?.attrs,target:e,alias:d??p}))}},I=function(){return T?.kind===`create`?{initialDir:T.initialDir,suggestedName:T.suggestedName}:null},L=async function(){let e=I();if(!(!e||O)){k(!0);try{await fO(e,{addPage:m,onCreated(e){F(e),window.location.hash=`#/${e}`,i()}}),k(!1)}catch(e){let t=e;sr.error(t instanceof Error?t.message:A({id:`tfi40B`})),k(!1)}}},R=!C&&!x&&w!==null,ee=!C&&!x&&T?.kind===`navigate`&&T.displayState===`resolved`,z=!C&&!x&&T?.kind===`navigate`&&T.displayState===`folder`,te=!C&&!x&&!w&&T?.kind===`create`,ne=!!C,re=C?fn(C.url)?C.url:null:R&&w?yi(w):ee&&T?.kind===`navigate`?Ln({docName:T.hashDocName,anchor:f}):null,B=!x&&re!==null&&(ne||R||ee),V,H,U,W,G;if(t[9]!==A||t[10]!==d||t[11]!==f||t[12]!==w||t[13]!==n.state||t[14]!==n.view||t[15]!==C||t[16]!==r||t[17]!==R||t[18]!==z||t[19]!==ee||t[20]!==te||t[21]!==x||t[22]!==u){if(x){let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(ir,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[28]=e):e=t[28],U={icon:e,text:A({id:`yQE2r9`}),className:`text-muted-foreground/80`}}else if(C){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Un,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[29]=e):e=t[29],U={icon:e,text:A({id:`hpDtUm`}),className:`text-muted-foreground`}}else if(R){let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Qa,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[30]=e):e=t[30],U={icon:e,text:A({id:`bUUVED`}),className:`text-muted-foreground`}}else if(z){let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(tr,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[31]=e):e=t[31],U={icon:e,text:A({id:`kNqMMd`}),className:`text-muted-foreground`}}else if(te){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ua,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[32]=e):e=t[32],U={icon:e,text:A({id:`8F1i42`}),className:`text-red-700 dark:text-red-300`}}else if(ee){let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(eo,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[33]=e):e=t[33],U={icon:e,text:A({id:`Hrz9NY`}),className:`text-muted-foreground`}}else{let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ua,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[34]=e):e=t[34],U={icon:e,text:A({id:`DeDYLr`}),className:`text-muted-foreground/80`}}let e;t[35]!==n.state||t[36]!==n.view||t[37]!==r?(e=()=>{let e=r();if(typeof e!=`number`)return new DOMRect;let t=n.state.doc.nodeAt(e);if(!t)return new DOMRect;try{return _t(n.view,e,e+t.nodeSize)}catch{return new DOMRect}},t[35]=n.state,t[36]=n.view,t[37]=r,t[38]=e):e=t[38];let i;t[39]!==n.view.dom||t[40]!==e?(i={getBoundingClientRect:e,contextElement:n.view.dom},t[39]=n.view.dom,t[40]=e,t[41]=i):i=t[41],G=i,H=w??(C?C.url:`${u}${f?`#${f}`:``}`);let a=f?`${u}#${f}`:u;V=d?`[[${a}|${d}]]`:`[[${a}]]`,W=Ft(`flex shrink-0`,U.className),t[9]=A,t[10]=d,t[11]=f,t[12]=w,t[13]=n.state,t[14]=n.view,t[15]=C,t[16]=r,t[17]=R,t[18]=z,t[19]=ee,t[20]=te,t[21]=x,t[22]=u,t[23]=V,t[24]=H,t[25]=U,t[26]=W,t[27]=G}else V=t[23],H=t[24],U=t[25],W=t[26],G=t[27];let ie;t[42]!==U.icon||t[43]!==W?(ie=(0,Z.jsx)(`span`,{className:W,children:U.icon}),t[42]=U.icon,t[43]=W,t[44]=ie):ie=t[44];let K=ie,ae;t[45]!==K||t[46]!==te||t[47]!==U.text?(ae=te?(0,Z.jsxs)(Sr,{children:[(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`wiki-link-prop-panel-icon-trigger`,children:K})}),(0,Z.jsx)(xr,{children:U.text})]}):K,t[45]=K,t[46]=te,t[47]=U.text,t[48]=ae):ae=t[48];let oe=ae,q=`${U.text}: ${H}`,se;t[49]!==H||t[50]!==ne||t[51]!==te||t[52]!==re||t[53]!==B||t[54]!==i||t[55]!==a?(se=(0,Z.jsx)(br,{asChild:!0,children:B?(0,Z.jsx)(`a`,{href:re??void 0,...ne?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>_n(e,a,i),"data-slot":`wiki-link-prop-panel-text`,className:`block truncate text-sm font-medium text-foreground underline-offset-2 hover:underline focus-visible:underline`,children:H}):(0,Z.jsx)(`span`,{"data-slot":`wiki-link-prop-panel-text`,className:Ft(`block truncate text-sm font-medium`,te?`text-muted-foreground`:`text-foreground`),children:H})}),t[49]=H,t[50]=ne,t[51]=te,t[52]=re,t[53]=B,t[54]=i,t[55]=a,t[56]=se):se=t[56];let ce;t[57]===H?ce=t[58]:(ce=(0,Z.jsx)(xr,{className:`max-w-80 break-all`,children:H}),t[57]=H,t[58]=ce);let J;t[59]!==se||t[60]!==ce?(J=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsxs)(Sr,{children:[se,ce]})}),t[59]=se,t[60]=ce,t[61]=J):J=t[61];let le;t[62]!==L||t[63]!==O||t[64]!==te?(le=te?(0,Z.jsxs)(zt,{type:`button`,size:`sm`,variant:`link`,disabled:O,onClick:()=>void L(),"data-slot":`wiki-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,Z.jsx)(So,{className:`size-3.5`,"aria-hidden":`true`}),O?(0,Z.jsx)(o,{id:`HM56Bx`}):(0,Z.jsx)(o,{id:`XRuL0i`})]}):null,t[62]=L,t[63]=O,t[64]=te,t[65]=le):le=t[65];let ue;t[66]===A?ue=t[67]:(ue=A({id:`ePK91l`}),t[66]=A,t[67]=ue);let Y;t[68]===D?Y=t[69]:(Y=()=>D(!0),t[68]=D,t[69]=Y);let de;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Z.jsx)($n,{className:`size-3.5`,"aria-hidden":`true`}),t[70]=de):de=t[70];let fe;t[71]!==ue||t[72]!==Y?(fe=(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":ue,onClick:Y,"data-slot":`wiki-link-prop-panel-edit`,children:de})}),t[71]=ue,t[72]=Y,t[73]=fe):fe=t[73];let pe;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(xr,{children:(0,Z.jsx)(o,{id:`ePK91l`})}),t[74]=pe):pe=t[74];let me;t[75]===fe?me=t[76]:(me=(0,Z.jsxs)(Sr,{children:[fe,pe]}),t[75]=fe,t[76]=me);let he;t[77]===V?he=t[78]:(he=(0,Z.jsx)(FO,{copyContent:V}),t[77]=V,t[78]=he);let ge;t[79]===A?ge=t[80]:(ge=A({id:`t_YqKh`}),t[79]=A,t[80]=ge);let _e;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`}),t[81]=_e):_e=t[81];let ve;t[82]!==P||t[83]!==ge?(ve=(0,Z.jsx)(br,{asChild:!0,children:(0,Z.jsx)(zt,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":ge,onClick:P,"data-slot":`wiki-link-prop-panel-remove`,children:_e})}),t[82]=P,t[83]=ge,t[84]=ve):ve=t[84];let ye;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Z.jsx)(xr,{children:(0,Z.jsx)(o,{id:`t_YqKh`})}),t[85]=ye):ye=t[85];let be;t[86]===ve?be=t[87]:(be=(0,Z.jsxs)(Sr,{children:[ve,ye]}),t[86]=ve,t[87]=be);let xe;t[88]!==le||t[89]!==me||t[90]!==he||t[91]!==be?(xe=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[le,me,he,be]}),t[88]=le,t[89]=me,t[90]=he,t[91]=be,t[92]=xe):xe=t[92];let Se;t[93]!==oe||t[94]!==J||t[95]!==xe?(Se=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[oe,J,xe]}),t[93]=oe,t[94]=J,t[95]=xe,t[96]=Se):Se=t[96];let Ce;t[97]!==i||t[98]!==Se||t[99]!==q||t[100]!==G?(Ce=(0,Z.jsx)(nO,{kind:`wiki-link`,ariaLabel:q,onDeactivate:i,triggerReference:G,className:`w-96`,children:Se}),t[97]=i,t[98]=Se,t[99]=q,t[100]=G,t[101]=Ce):Ce=t[101];let we;t[102]!==d||t[103]!==f||t[104]!==h||t[105]!==E||t[106]!==g||t[107]!==M||t[108]!==x||t[109]!==v||t[110]!==D||t[111]!==u?(we=(0,Z.jsx)(eM,{open:E,target:u,alias:d,anchor:f,pages:v,assetPaths:h,filePaths:g,loading:x,onOpenChange:D,onSave:M}),t[102]=d,t[103]=f,t[104]=h,t[105]=E,t[106]=g,t[107]=M,t[108]=x,t[109]=v,t[110]=D,t[111]=u,t[112]=we):we=t[112];let Te;return t[113]!==Ce||t[114]!==we?(Te=(0,Z.jsxs)(Z.Fragment,{children:[Ce,we]}),t[113]=Ce,t[114]=we,t[115]=Te):Te=t[115],Te}var nM=0;function rM(){return`wiki-link-${++nM}`}function iM(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`span`);n.setAttribute(`data-wiki-link`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Wiki link: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-chip`),n.style.touchAction=`manipulation`;let r=t.createElement(`span`);r.setAttribute(`data-wiki-link-icon`,``),r.setAttribute(`aria-hidden`,`true`),n.appendChild(r);let i=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,a=t.createTextNode(i);return n.appendChild(a),{dom:n,iconSpan:r}}function aM(e,t){if(!t||!e)return null;let n=Gt(e,t);if(!n)return null;let r=t.pageIcons?.get(n);if(!r)return null;let i=Jj(r);return i.kind===`unsupported`?null:i}function oM(e,t,n=document){let r=t?.kind??``,i=t?.value??``;if(e.getAttribute(`data-kind`)===r&&e.getAttribute(`data-value`)===i)return;for(e.setAttribute(`data-kind`,r),e.setAttribute(`data-value`,i);e.firstChild;)e.removeChild(e.firstChild);if(!t)return;if(t.kind===`emoji`){e.appendChild(n.createTextNode(t.value));return}let a=n.createElement(`img`);a.setAttribute(`src`,t.value),a.setAttribute(`alt`,``),a.setAttribute(`draggable`,`false`),a.setAttribute(`referrerpolicy`,`no-referrer`),e.appendChild(a)}var sM=h.extend({priority:200,addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=rM(),{dom:i,iconSpan:a}=iM({nodeId:r,target:String(t.attrs.target??``),alias:t.attrs.alias==null?null:String(t.attrs.alias),anchor:t.attrs.anchor==null?null:String(t.attrs.anchor)}),o=t,s=()=>{oM(a,aM(String(o.attrs.target??``),si()))};s();let c=li(s),l=()=>{let e=n();return typeof e==`number`?e:void 0},u=Xg(e),d=({newTab:e})=>{let t=o.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=lt(n,typeof t.anchor==`string`?t.anchor:null);if(!r)return!1;if(r.kind===`doc`){let t=si(),i=In(n,{pages:t?.pages??new Set,folderPaths:t?.folderPaths??new Set,pagesBySlug:t?.pagesBySlug,pagesByBasename:t?.pagesByBasename,fallbackTargets:Kt(n)});if(i.kind===`create`||i.kind===`navigate`&&i.displayState===`folder`)return!1;let a=i.kind===`navigate`?i.hashDocName:r.docName;return e?Fn({docName:a,anchor:r.anchor}):window.location.assign(Ln({docName:a,anchor:r.anchor})),!0}if(r.kind===`asset`){let t=si(),n=on(r.url,t?.assetPaths??new Set,t?.filePaths)??r.url.replace(/^\//,``);return e?un(yi(n)):window.location.hash=yi(n),!0}return fn(r.url)?(un(r.url),!0):!1};return u.register({type:`wikiLink`,nodeId:r,getPos:l,controls:{propPanel:t=>(0,Q.createElement)(tM,{editor:e,getPos:l,onClose:t.deactivate,onNavigate:e=>d({newTab:e})})},handlePrimary:d}),{dom:i,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLink`)return!1;o=e;let t=String(e.attrs.target??``),n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor);i.setAttribute(`data-target`,t),i.setAttribute(`data-alias`,n??``),i.setAttribute(`data-anchor`,r??``),i.setAttribute(`aria-label`,`Wiki link: ${t}${r?`#${r}`:``}`);let a=n??`${t}${r?`#${r}`:``}`,c=i.lastChild;return c&&c.nodeType===3?c.nodeValue=a:i.appendChild(i.ownerDocument.createTextNode(a)),s(),!0},destroy:()=>{u.deregister(r),c()}}}},addKeyboardShortcuts(){return{Backspace:()=>{if(mn.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(mn.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[jn(this.editor)]}}),cM=0;function lM(){return`wiki-link-embed-${++cM}`}function uM(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`a`);n.setAttribute(`data-wiki-embed`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`href`,e.href),n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Embed: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-embed-chip`),n.style.touchAction=`manipulation`;let r=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,i=t.createTextNode(r);return n.appendChild(i),{dom:n}}function dM(e){let t=(e.doc??(typeof document<`u`?document:{createElement:null})).createElement(`img`);return t.setAttribute(`data-wiki-embed`,``),t.setAttribute(`data-node-id`,e.nodeId),t.setAttribute(`data-target`,e.target),t.setAttribute(`data-alias`,e.alias??``),t.setAttribute(`src`,le(e.src)),t.setAttribute(`alt`,e.alias??e.target),{dom:t}}function fM(e){let t=We(e);return t!==null&&j.has(t)}var pM=Ye.extend({addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=lM(),i=t,a=String(t.attrs.target??``),o=t.attrs.alias==null?null:String(t.attrs.alias),s=t.attrs.anchor==null?null:String(t.attrs.anchor),c=t.attrs.resolvedSrc==null?null:String(t.attrs.resolvedSrc);if(fM(a)){let{dom:e}=dM({nodeId:r,target:a,alias:o,src:c??a});return{dom:e,ignoreMutation:()=>!0,update:t=>{if(t.type.name!==`wikiLinkEmbed`)return!1;i=t;let n=String(t.attrs.target??``),r=t.attrs.alias==null?null:String(t.attrs.alias),a=t.attrs.resolvedSrc==null?null:String(t.attrs.resolvedSrc);if(!fM(n))return!1;let o=a??n;return e.setAttribute(`data-target`,n),e.setAttribute(`data-alias`,r??``),e.setAttribute(`src`,le(o)),e.setAttribute(`alt`,r??n),!0}}}let{dom:l}=uM({nodeId:r,target:a,alias:o,anchor:s,href:c??a});l.addEventListener(`click`,e=>{e.preventDefault()});let u=()=>{let e=n();return typeof e==`number`?e:void 0},d=Xg(e);return d.register({type:`wikiLinkEmbed`,nodeId:r,getPos:u,controls:{},handlePrimary:({newTab:e})=>{let t=i.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=(typeof t.resolvedSrc==`string`&&t.resolvedSrc.length>0?t.resolvedSrc:null)??n,a=We(n);if(a===null)return!1;let o=He(r,``)??n;return On({url:r,projectRelPath:o,ext:a,title:o.split(`/`).pop()??r,newTab:e}),!0}}),{dom:l,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let t=String(e.attrs.target??``);if(fM(t))return!1;let n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor),a=(e.attrs.resolvedSrc==null?null:String(e.attrs.resolvedSrc))??t;return l.setAttribute(`data-target`,t),l.setAttribute(`data-alias`,n??``),l.setAttribute(`data-anchor`,r??``),l.setAttribute(`href`,a),l.setAttribute(`aria-label`,`Embed: ${t}${r?`#${r}`:``}`),l.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{d.deregister(r)}}}}}),mM=[...Ae.map(e=>{if(e.name===`jsxComponent`)return sj;if(e.name===`image`){let t=e.options??{};return QD.configure({...t,inline:!0})}return e.name===`rawMdxFallback`?vj:e.name===`wikiLink`?sM:e.name===`wikiLinkEmbed`?pM:e.name===`link`?ZO:e.name===`mathInline`?hj:e.name===`tag`?Gj:e.name===`codeBlock`?QE:e}),Cj.configure({itemsSources:[Tb,_b,wb,yb],categoryLabels:{content:`Components`,layout:`Layout`,media:`Media`,data:`Data`,embed:`Embeds`}}),YD,Dj,bh.configure({onDrop(e,t,n){for(let r of t)xg(r,e,n)},onPaste(e,t,n){for(let n of t)xg(n,e,e.state.selection.from)}}),XD,Bh,zj,JD,KD,Ab,Fj,Tj,ug,Eg,wh,Fb,EA,Y.create({name:`chunkWrapperDecoration`,addProseMirrorPlugins(){return[Vb()]}})];function hM(e){return e===at}function gM(){return fi(`SYNC_TIMEOUT_MS`,3e4)}var _M=class extends Error{docName;elapsedMs;constructor(e,t){super(`Sync timed out for "${e}" after ${t}ms`),this.name=`SyncTimeoutError`,this.docName=e,this.elapsedMs=t}},vM=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},yM=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},bM=class extends Error{docName;cause;constructor(e,t){let n=t instanceof Error?t.message:String(t??`unknown`);super(`Bridge setup failed for "${e}": ${n}`),this.name=`BridgeSetupError`,this.docName=e,this.cause=t}},xM=class extends Error{docName;missingCapability;constructor(e,t){super(`Server is missing capability "${t}" required to open "${e}".`),this.name=`ServerCapabilityMismatchError`,this.docName=e,this.missingCapability=t}},SM=new Map,CM=!1;function wM(){for(let e of SM.values())if(!e.settled)return!0;return!1}function TM(){typeof document>`u`||document.visibilityState===`visible`&&EM(Date.now())}function EM(e){let t=[];for(let[n,r]of SM){if(r.settled)continue;let i=e-r.createdAt;if(i<gM())continue;r.settled=!0;let a=new _M(n,i);AM(r),r.reject(a);let o=Pf(n);o!==void 0&&Gf(o),t.push({docName:n,elapsedMs:i})}if(t.length>0){let e=t.map(e=>`${e.docName} (${e.elapsedMs}ms)`).join(`, `);console.warn(`[syncPromise] reaped ${t.length} timed-out ${t.length===1?`entry`:`entries`} on visibility restore (tab-sleep recovered): ${e}`)}return wM()||OM(),t.length}function DM(){CM||typeof document>`u`||(document.addEventListener(`visibilitychange`,TM),CM=!0)}function OM(){CM&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,TM),CM=!1))}var kM=new Map;function AM(e){e.detached||(e.detached=!0,e.timeoutHandle!==null&&clearTimeout(e.timeoutHandle),e.provider.off(`synced`,e.onSynced),e.provider.off(`close`,e.onClose))}function jM(e,t){let n=SM.get(e);if(n)return n.promise;let r=kM.get(e);if(r!==void 0){kM.delete(e);let n=r===`timeout`?new _M(e,0):new vM(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),X(`ok/sync/create`,{docName:e,mountId:Pf(e),warm:!1,armed:r}),X(`ok/sync/reject`,{docName:e,mountId:Pf(e),reason:`armed-${r}`});let i=NM(n);return SM.set(e,PM(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`);let n=Pf(e);X(`ok/sync/create`,{docName:e,mountId:n,warm:!0}),X(`ok/sync/resolve`,{docName:e,mountId:n,elapsedMs:0,warm:!0}),X.histogram(`ok/sync/resolve-elapsed-ms`,n===void 0?{docName:e,warm:!0}:{docName:e,mountId:n,warm:!0},0);let r=Promise.resolve();return SM.set(e,MM(r,t)),r}let i=Date.now(),a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=()=>{let t=SM.get(e);if(!t||t.settled)return;t.settled=!0,t.resolved=!0;let n=Date.now()-t.createdAt;console.log(`[syncPromise] ${e} resolved in ${n}ms`);let r=Pf(e);if(X(`ok/sync/resolve`,{docName:e,mountId:r,elapsedMs:n,warm:!1}),X.histogram(`ok/sync/resolve-elapsed-ms`,r===void 0?{docName:e}:{docName:e,mountId:r},n),AM(t),wM()||OM(),t.resolve(),pi(),r!==void 0){let i=Date.now();Wf(r,`ok.sync-promise`,{"doc.name":e,elapsed_ms:n},t.createdAt,i),Gf(r,i)}},l=t=>{let n=SM.get(e);if(!n||n.settled)return;n.settled=!0;let r=new vM(e);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=Pf(e);X(`ok/sync/reject`,{docName:e,mountId:i,reason:`pre-sync-disconnect`}),AM(n),wM()||OM(),n.reject(r),i!==void 0&&Gf(i)},u=setTimeout(()=>{let t=SM.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new _M(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=Pf(e);X(`ok/sync/reject`,{docName:e,mountId:i,reason:`timeout`,elapsedMs:n}),AM(t),wM()||OM(),t.reject(r),i!==void 0&&Gf(i)},gM()),d={promise:s,resolve:a,reject:o,createdAt:i,timeoutHandle:u,provider:t,onSynced:c,onClose:l,settled:!1,resolved:!1,detached:!1};return SM.set(e,d),t.on(`synced`,c),t.on(`close`,l),DM(),X(`ok/sync/create`,{docName:e,mountId:Pf(e),warm:!1}),s}function MM(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!0,detached:!0}}function NM(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function PM(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!1,detached:!0}}function FM(e){return SM.get(e)?.resolved===!0}function IM(e){let t=SM.get(e);t&&(t.settled=!0,AM(t),SM.delete(e),wM()||OM())}function LM(e,t){let n=SM.get(e);if(!n||n.settled)return!1;n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),AM(n),wM()||OM(),n.reject(t);let r=Pf(e);return r!==void 0&&Gf(r),!0}var RM=Object.freeze({kind:`tab-replay`}),zM=Object.freeze({kind:`idle`});function BM(e,t){return()=>{}}var VM=null;function HM(){return VM??=ot(mM),VM}var UM=4e3,WM=1e4,GM=class extends Error{constructor(e,t){super(`client persistence clearData timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`ClientPersistenceClearTimeoutError`}},KM=class extends Error{constructor(e,t){super(`stored-state epoch peek timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`StoredEpochPeekTimeoutError`}},qM=`ok-last-observed-branch`,JM=`ok-doc-lineage-epochs`,YM=5e3,XM=fi(`MAX_BUFFER_BYTES`,1*1024*1024),ZM=fi(`MAX_POOL`,10),QM=class{_entries=new Map;get entries(){return this._entries}lruOrder=[];activeDocName=null;maxSize;wsUrl;recycleDebounceMs;clearDataTimeoutMs;onChange=null;tabIdentity=null;serverRestartRecoveryState=zM;cachedServerInstanceId=null;pendingServerInstanceKnown=null;recoveryMismatchStaleClaim;bufferedUpdates=new Map;pendingClears=new Map;clearFailures=new Set;persistenceFactory;peekStoredEpoch;storage;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n?.recycleDebounceMs??UM,this.clearDataTimeoutMs=n?.clearDataTimeoutMs??WM,this.persistenceFactory=n?.persistenceFactory??ph,this.peekStoredEpoch=n?.peekStoredLineageEpoch??mh,n?.storage===void 0?this.storage=globalThis.localStorage===void 0?null:globalThis.localStorage:this.storage=n.storage}setTabIdentity(e){this.tabIdentity=e}setExpectedServerInstanceId(e){if(this.cachedServerInstanceId=e,!(e===null||e.length===0)){if(this.pendingServerInstanceKnown!==null){let t=this.pendingServerInstanceKnown;this.pendingServerInstanceKnown=null,t.resolve(e)}this.attachDeferredPersistence(e)}}whenServerInstanceKnown(){if(this.cachedServerInstanceId!==null&&this.cachedServerInstanceId.length>0)return Promise.resolve(this.cachedServerInstanceId);if(this.pendingServerInstanceKnown!==null)return this.pendingServerInstanceKnown.promise;let e,t=new Promise(t=>{e=t});return this.pendingServerInstanceKnown={promise:t,resolve:e},t}buildPersistence(e,t,n){return this.persistenceFactory({branch:this.normalizedObservedBranch(),serverInstanceId:e,docName:t,doc:n})}async validateStoredStateThenAttach(e,t){if(e.persistenceAttachOwned)return;e.persistenceAttachOwned=!0;let n=e.docName,r=()=>this._entries.get(n)===e&&e.kind===`active`&&e.persistence===null&&!this.pendingClears.has(n);if(!r())return;let i;try{i=await new Promise((e,r)=>{let i=setTimeout(()=>{r(new KM(n,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);this.peekStoredEpoch({branch:this.normalizedObservedBranch(),serverInstanceId:t,docName:n}).then(t=>{clearTimeout(i),e(t)},e=>{clearTimeout(i),r(e)})})}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`peek`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)});return}if(!r())return;if(i===null){this.attachValidatedPersistence(e,t);return}if(!e.hasSynced&&(await this.awaitFirstSyncOrDestroy(e),!r()||!e.hasSynced))return;let a=e.provider.document.getMap(`lifecycle`).get(k),o=typeof a==`string`&&a.length>0?a:null;if(o===i){this.attachValidatedPersistence(e,t);return}this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`stored-state-validation`,staleEpoch:i,liveEpoch:o??`<absent>`});let s=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&s&&this.setActive(n)}attachValidatedPersistence(e,t){let n=e.docName;try{let r=this.buildPersistence(t,n,e.provider.document);e.persistence=r,this.notify(),this.backfillCacheAfterFirstSync(e,r).catch(e=>{this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`backfill`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)})})}catch(e){this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n),phase:`attach`,errorName:e instanceof Error?e.name:`non-error-throw`,errorMessage:e instanceof Error?e.message:String(e)})}}async backfillCacheAfterFirstSync(e,t){await t.whenSynced,e.hasSynced||await this.awaitFirstSyncOrDestroy(e),!(this._entries.get(e.docName)!==e||e.kind!==`active`||e.persistence!==t||!e.hasSynced)&&await t.flushFullState()}async awaitFirstSyncOrDestroy(e){e.hasSynced||await new Promise(t=>{let n=()=>{e.provider.off(`synced`,n),e.provider.off(`destroy`,n),t()};e.provider.on(`synced`,n),e.provider.on(`destroy`,n)})}attachDeferredPersistence(e){for(let t of Array.from(this._entries.values()))if(t.kind===`active`&&t.persistence===null&&this._entries.get(t.docName)===t){if(t.hasSynced&&t.lineageEpochRecordAtOpen!==null){let e=t.provider.document.getMap(`lifecycle`).get(k);if(typeof e==`string`&&e.length>0&&e!==t.lineageEpochRecordAtOpen){let n=t.docName;this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(n),via:`deferred-attach`,staleEpoch:t.lineageEpochRecordAtOpen,liveEpoch:e});let r=this.activeDocName===n;this.runCloseAndClearPersistence(n),this.open(n)!==null&&r&&this.setActive(n);continue}}this.validateStoredStateThenAttach(t,e)}}getServerRestartRecoveryState(){return this.serverRestartRecoveryState}observeDiskAck(e,t){let n=this.entries.get(e);!n||n.kind!==`active`||(n.lastDiskAckedSV=_h(n.lastDiskAckedSV,t))}observeDiskAckBatch(e){for(let[t,n]of Object.entries(e))this.observeDiskAck(t,n)}lastObservedBranch=null;lastObservedBranchInitialized=!1;getOrInitObservedBranch(){if(this.lastObservedBranchInitialized)return this.lastObservedBranch;this.lastObservedBranchInitialized=!0;try{let e=this.storage?.getItem(qM)??null;e!==null&&e.length>0&&(this.lastObservedBranch=e)}catch{}return this.lastObservedBranch}persistObservedBranch(e){this.lastObservedBranch=e,this.lastObservedBranchInitialized=!0;try{e===null||e.length===0?this.storage?.removeItem(qM):this.storage?.setItem(qM,e)}catch{}}docLineageEpochs=new Map;docLineageEpochsEnvelopeConsumed=!1;normalizedObservedBranch(){return this.getOrInitObservedBranch()??`_unknown_`}consumeLineageEpochEnvelopeIfValid(){if(this.docLineageEpochsEnvelopeConsumed)return;let e=this.cachedServerInstanceId;if(!(e===null||e.length===0)){this.docLineageEpochsEnvelopeConsumed=!0;try{let t=this.storage?.getItem(JM)??null;if(t===null)return;let n=JSON.parse(t);if(typeof n!=`object`||!n)return;let r=n;if(r.branch!==this.normalizedObservedBranch()||r.serverInstanceId!==e||typeof r.epochs!=`object`||r.epochs===null)return;for(let[e,t]of Object.entries(r.epochs))typeof t==`string`&&t.length>0&&!this.docLineageEpochs.has(e)&&this.docLineageEpochs.set(e,t)}catch(e){e instanceof DOMException||console.warn(JSON.stringify({event:`ok-lineage-epoch-envelope-read-error`,errorName:e instanceof Error?e.name:typeof e,message:e instanceof Error?e.message:String(e)}))}}}getRecordedLineageEpoch(e){let t=this.docLineageEpochs.get(e);return t===void 0?(this.consumeLineageEpochEnvelopeIfValid(),this.docLineageEpochs.get(e)??null):t}persistLineageEpochEnvelope(){let e=this.cachedServerInstanceId;if(!(e===null||e.length===0))try{this.storage?.setItem(JM,JSON.stringify({branch:this.normalizedObservedBranch(),serverInstanceId:e,epochs:Object.fromEntries(this.docLineageEpochs)}))}catch{}}recordLineageEpoch(e,t){this.docLineageEpochs.get(e)!==t&&(this.docLineageEpochs.set(e,t),this.persistLineageEpochEnvelope())}deleteLineageEpochRecord(e){this.docLineageEpochs.delete(e)&&this.persistLineageEpochEnvelope()}withClearDataTimeout(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(new GM(e,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);t.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e)})})}recoveryTelemetryBase(e,t){let n={docName:e,branch:this.normalizedObservedBranch()},r=t===void 0?this.recoveryMismatchStaleClaim:t;return r!==void 0&&r.length>0&&(n.serverInstanceId=r),n}emitStructuredClientRecoveryEvent(e){console.warn(JSON.stringify(e))}clearRecoveryMismatchStaleClaimIfTerminal(){let e=this.serverRestartRecoveryState.kind;(e===`idle`||e===`failed`)&&(this.recoveryMismatchStaleClaim=void 0)}beginServerRestartRecovery(e,t){this.serverRestartRecoveryState={kind:`recovering`,phase:`clearing-local-cache`,docNames:e,failedDocNames:[],startedAt:t};for(let t of e)IM(t);this.notify()}enterServerRestartReconnect(e,t,n,r){if(e.length===0){this.serverRestartRecoveryState=t.length===0?zM:{kind:`failed`,reason:r,docNames:t,failedDocNames:t,startedAt:n},this.clearRecoveryMismatchStaleClaimIfTerminal(),this.notify();return}this.serverRestartRecoveryState={kind:`recovering`,phase:`reconnecting`,docNames:e,failedDocNames:t,startedAt:n,...t.length>0?{clearFailureReason:r}:{}},this.notify()}markServerRestartRecoverySynced(e){let t=this.serverRestartRecoveryState;if(t.kind!==`recovering`||t.phase!==`reconnecting`||!t.docNames.includes(e))return;let n=t.docNames.filter(t=>t!==e);if(n.length>0){this.serverRestartRecoveryState={...t,docNames:n};return}if(t.failedDocNames.length>0){this.serverRestartRecoveryState={kind:`failed`,reason:t.clearFailureReason??`clear-data-failed`,docNames:t.failedDocNames,failedDocNames:t.failedDocNames,startedAt:t.startedAt},this.clearRecoveryMismatchStaleClaimIfTerminal();return}this.serverRestartRecoveryState=zM,this.clearRecoveryMismatchStaleClaimIfTerminal()}setObservedBranch(e){this.persistObservedBranch(e)}compareAndUpdateObservedBranch(e){let t=this.getOrInitObservedBranch();return this.persistObservedBranch(e),t!==null&&t!==e}onBranchMismatch=null;branchMismatchInFlight=null;mismatchInFlight=null;setOnBranchMismatch(e){if(e===null){this.onBranchMismatch=null;return}this.onBranchMismatch=()=>{if(this.branchMismatchInFlight!==null)return;let t=Promise.resolve().then(e).finally(()=>{this.branchMismatchInFlight===t&&(this.branchMismatchInFlight=null)});this.branchMismatchInFlight=t}}onRenameRedirect=null;onDocDeleted=null;setOnRenameRedirect(e){this.onRenameRedirect=e}setOnDocDeleted(e){this.onDocDeleted=e}setOnChange(e){this.onChange=e}notify(){this.onChange?.()}evictListeners=new Set;onEvict(e){return this.evictListeners.add(e),()=>{this.evictListeners.delete(e)}}fireEvict(e){for(let t of this.evictListeners)try{t(e)}catch(t){console.warn(`[ProviderPool] evict listener threw for ${e}:`,t)}}touch(e){let t=this.lruOrder.indexOf(e);t!==-1&&this.lruOrder.splice(t,1),this.lruOrder.push(e)}open(e){if(hM(e))return null;let t=this.entries.get(e);if(t){let n=t.lastAccessedAt;return t.lastAccessedAt=Date.now(),this.touch(e),this.notify(),X(`ok/pool/open`,{docName:e,hit:!0,lastAccessedAt:n,poolEventId:t.poolEventId}),X.count(`ok/pool/open`,{hit:!0}),t}let n=Date.now();this.entries.size>=this.maxSize&&this.evictLru();let r=this.cachedServerInstanceId,i=this.getRecordedLineageEpoch(e),a=da(this.tabIdentity,r,this.getOrInitObservedBranch(),r!==null&&r.length>0?i:null),o=new Ki({url:vh(this.wsUrl),name:e,forceSyncInterval:YM,token:a}),s=this.cachedServerInstanceId;this.clearFailures.has(e)&&this.runCloseAndClearPersistence(e);let c=this.pendingClears.get(e),l=s!==null&&s.length>0&&c===void 0&&i!==null?this.buildPersistence(s,e,o.document):null,u=crypto.randomUUID(),d={kind:`active`,provider:o,persistence:l,lastServerSyncedSV:null,lastDiskAckedSV:null,observerCleanup:null,observerFireCounterCleanup:BM(o.document,e),syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),poolEventId:u,hasSynced:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1,serverDrivenCloseReauthInFlight:!1,persistenceAttachOwned:!1,lineageEpochRecordAtOpen:i};if(X(`ok/pool/open`,{docName:e,hit:!1,poolEventId:u}),X.count(`ok/pool/open`,{hit:!1}),o.on(`status`,({status:t})=>{d.kind!==`active`||this.entries.get(e)!==d||t===`disconnected`&&(d.syncState=`disconnected`,this.notify())}),o.on(`synced`,()=>{if(d.kind!==`active`||this.entries.get(e)!==d)return;d.syncState=`synced`,d.hasSynced=!0,d.lastServerSyncedSV=hh(o.document);let t=o.document.getMap(`lifecycle`).get(k);if(typeof t==`string`&&t.length>0&&this.recordLineageEpoch(e,t),d.pendingRecycleTimer&&=(clearTimeout(d.pendingRecycleTimer),null),this.markServerRestartRecoverySynced(e),this.notify(),!d.observerCleanup)try{let t=o.document,n=new ct({extensions:mM});d.observerCleanup=Sn({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:n,schema:HM(),onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),d.bridgeSetupFailed=!0,LM(e,new bM(e,t))}}),o.on(`disconnect`,()=>{d.kind!==`active`||this.entries.get(e)!==d||(d.syncState=`disconnected`,this.notify(),d.hasSynced&&o.unsyncedChanges===0&&!d.pendingRecycleTimer&&(d.pendingRecycleTimer=setTimeout(()=>{d.kind===`active`&&(d.pendingRecycleTimer=null,this.entries.get(e)===d&&this.recycleDisconnectedEntry(e))},this.recycleDebounceMs)))}),o.on(`authenticationFailed`,({reason:t})=>{let n=[`server-instance-mismatch`,`branch-mismatch`,`rename-redirect`,`doc-deleted`,`doc-lineage-mismatch`],i=t.indexOf(`:`),a=i===-1?t:t.slice(0,i);if(!n.includes(a)){console.warn(JSON.stringify({event:`ok-auth-failed-unknown-reason`,reason:t}));return}let o=i===-1?``:t.slice(i+1),s=o.length>0?o:void 0,c=a;if(c===`server-instance-mismatch`){if(r===null||this.cachedServerInstanceId!==r)return;let e=r;this.cachedServerInstanceId=null,this.handleServerInstanceMismatch(e);return}if(c===`branch-mismatch`){this.onBranchMismatch?.();return}if(c===`rename-redirect`){if(s===void 0||s.length===0){console.warn(JSON.stringify({event:`rename-redirect-missing-payload`,fromDocName:e}));return}let t=e,n=s;this.deleteLineageEpochRecord(t);let r=this.entries.get(t),i=r!==void 0&&r.kind===`active`;this.onRenameRedirect?.({fromDocName:t,toDocName:n,hadOpenProvider:i});return}if(c===`doc-deleted`){this.deleteLineageEpochRecord(e);let t=this.entries.get(e),n=t!==void 0&&t.kind===`active`;this.onDocDeleted?.({docName:e,hadOpenProvider:n});return}if(c===`doc-lineage-mismatch`){if(d.kind!==`active`||this.entries.get(e)!==d)return;this.deleteLineageEpochRecord(e),this.emitStructuredClientRecoveryEvent({event:`ok-doc-lineage-mismatch`,...this.recoveryTelemetryBase(e),via:`auth-rejection`,staleEpoch:d.lineageEpochRecordAtOpen??``});let t=this.activeDocName===e;this.runCloseAndClearPersistence(e),this.open(e)!==null&&t&&this.setActive(e);return}}),o.on(`close`,({event:t})=>{if(d.kind!==`active`||this.entries.get(e)!==d||d.serverDrivenCloseReauthInFlight)return;d.serverDrivenCloseReauthInFlight=!0,o.sendToken().catch(t=>{console.warn(JSON.stringify({event:`ok-provider-server-driven-close-reauth-failed`,docName:e,message:t instanceof Error?t.message:String(t)}))}).finally(()=>{d.kind===`active`&&this.entries.get(e)===d&&(d.serverDrivenCloseReauthInFlight=!1)});let n=t?.reason??`<unknown>`;console.info(JSON.stringify({event:`ok-provider-server-driven-close-reauth`,docName:e,reason:n}))}),this.bufferedUpdates.get(e)!==void 0){let t=this.recoveryMismatchStaleClaim,n=()=>{if(o.off(`synced`,n),d.kind!==`active`||this.entries.get(e)!==d)return;let r=this.bufferedUpdates.get(e);if(r!==void 0){this.bufferedUpdates.delete(e);try{Gi(o.document,r,RM)}catch(n){let i=n instanceof Error?n.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-failed`,...this.recoveryTelemetryBase(e,t),replayByteLength:r.byteLength,errorName:i,errorMessage:n instanceof Error?n.message:String(n)})}}};o.on(`synced`,n)}if(this._entries.set(e,d),this.touch(e),this.notify(),l===null&&s!==null&&s.length>0&&c===void 0&&this.validateStoredStateThenAttach(d,s),c!==void 0&&s!==null&&s.length>0){let t=s;c.then(()=>{this.attachDeferredPersistenceForEntry(d,t)},t=>{console.warn(JSON.stringify({event:`ok-pool-deferred-persistence-attach-skipped`,docName:e,reason:`pending-clear-failed`,message:t instanceof Error?t.message:String(t)}))})}let f=Pf(e);return f!==void 0&&Wf(f,`ok.provider-pool.open`,{"doc.name":e},n,Date.now()),d}attachDeferredPersistenceForEntry(e,t){let n=this._entries.get(e.docName);n!==e||n.kind!==`active`||n.persistence!==null||this.validateStoredStateThenAttach(n,t)}handleServerInstanceMismatch(e){this.recoveryMismatchStaleClaim=e.length>0?e:void 0;let t=Array.from(this.entries.entries()),n=Date.now(),r=this.activeDocName,i=r!==null&&t.some(([e,t])=>e===r&&t.kind===`active`)?[r]:[],a=r??t.find(([,e])=>e.kind===`active`)?.[0]??``;a.length>0&&this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-epoch-mismatch`,...this.recoveryTelemetryBase(a)}),this.beginServerRestartRecovery(i,n);for(let[e,n]of t)n.kind===`active`&&!i.includes(e)&&IM(e);for(let[e,n]of t){if(n.kind!==`active`)continue;let t=n.lastDiskAckedSV??n.lastServerSyncedSV;if(t===null){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-skipped-no-baseline`,...this.recoveryTelemetryBase(e),reason:`no-disk-ack-or-server-sync-vector`});continue}let r=gh(n.provider.document,t);if(r.byteLength>XM){X(`ok/pool/buffer-overflow`,{docName:e,bytes:r.byteLength});continue}r.byteLength>0&&this.bufferedUpdates.set(e,r)}let o=[];for(let[e,n]of t)n.kind===`active`&&n.persistence!==null&&o.push({docName:e,promise:this.withClearDataTimeout(e,n.persistence.clearData())});let s=Promise.allSettled(o.map(e=>e.promise)).then(e=>{let t=[],i=[],a=!1;e.forEach((e,n)=>{let r=o[n];if(!r)return;let s=r.docName;if(e.status===`rejected`){t.push(s);let n=e.reason instanceof GM;if(n&&(a=!0),n)this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`timeout`});else{let t=e.reason instanceof Error?e.reason.name:`unknown`;this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`rejected`,errorName:t,errorMessage:e.reason instanceof Error?e.reason.message:String(e.reason)})}}else i.push(s)});let s=i.filter(e=>e===r);if(t.length>0){let e=a?`clear-data-timeout`:`clear-data-failed`;console.warn(JSON.stringify({event:`ok-mismatch-recycle-partial-clears-failed`,failedDocs:t,clearedDocs:i})),this.enterServerRestartReconnect(s,t,n,e);for(let e of i)this.recycleDisconnectedEntry(e);return}this.enterServerRestartReconnect(s,[],n,`clear-data-failed`),this.recycleAllEntries()}).finally(()=>{this.mismatchInFlight===s&&(this.mismatchInFlight=null)});this.mismatchInFlight=s}awaitMismatchSettled(){return this.mismatchInFlight??Promise.resolve()}recycleAllEntries(){let e=Array.from(this.entries.keys());for(let t of e)this.recycleDisconnectedEntry(t)}prewarm(e){if(hM(e))return null;let t=this.entries.get(e);if(t)return t;let n=this.open(e);if(!n)return null;let r=this.lruOrder.indexOf(e);return r!==-1&&(this.lruOrder.splice(r,1),this.lruOrder.unshift(e)),n}close(e){let t=this.entries.get(e);t&&(this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),this.bufferedUpdates.delete(e),this.activeDocName===e&&(this.activeDocName=null),this.notify())}async closeAndClearPersistence(e){try{await this.runCloseAndClearPersistence(e)}catch{}}runCloseAndClearPersistence(e){let t=this.pendingClears.get(e);if(t!==void 0)return t;let n=()=>{},r=()=>{},i=new Promise((e,t)=>{n=e,r=t});this.pendingClears.set(e,i);let a=()=>{this.pendingClears.get(e)===i&&this.pendingClears.delete(e)};return i.then(a,a),this.executeCloseAndClearPersistence(e).then(n,r),i}async executeCloseAndClearPersistence(e){this.clearFailures.delete(e);let t=this.entries.get(e);if(t?.kind===`active`&&t.persistence!==null){let n=t.persistence;try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before clearData threw for ${e}:`,t)}try{await this.withClearDataTimeout(e,n.clearData())}catch(t){throw console.warn(`[ProviderPool] clearData on rename failed for ${e}:`,t),this.clearFailures.add(e),t}return}if(t)try{this.close(e)}catch(t){console.warn(`[ProviderPool] close before IDB-by-name delete threw for ${e}:`,t)}let n=this.normalizedObservedBranch(),r=this.cachedServerInstanceId;if(r===null)return;let i=`ok-ydoc:${n}:${r}:${e}`;try{await this.withClearDataTimeout(e,new Promise((e,t)=>{let n=indexedDB.deleteDatabase(i);n.onsuccess=()=>e(),n.onerror=()=>t(n.error),n.onblocked=()=>{console.warn(`[ProviderPool] IDB delete blocked for ${i}`)}}))}catch(t){throw console.warn(`[ProviderPool] IDB delete on rename failed for ${i}:`,t),this.clearFailures.add(e),t}}clearBufferedUpdates(){this.bufferedUpdates.clear()}__test_seedBufferedUpdate(e,t){this.bufferedUpdates.set(e,t)}__test_bufferedUpdatesSize(){return this.bufferedUpdates.size}__test_hasBufferedUpdate(e){return this.bufferedUpdates.has(e)}__test_getBufferedUpdate(e){return this.bufferedUpdates.get(e)}setActive(e){let t=this.entries.get(e);if(!t)throw Error(`[ProviderPool] Cannot setActive — "${e}" is not open`);t.lastAccessedAt=Date.now(),this.touch(e),this.activeDocName=e,this.notify()}clearActive(){this.activeDocName!==null&&(this.activeDocName=null,this.notify())}getActive(){return this.activeDocName?this.entries.get(this.activeDocName)??null:null}getActiveDocName(){return this.activeDocName}has(e){return this.entries.has(e)}peek(e){return this.entries.get(e)??null}recycle(e){this.recycleDisconnectedEntry(e)}dispose(){for(let e of this._entries.values())this.destroyEntry(e);this._entries.clear(),this.lruOrder=[],this.activeDocName=null,this.onChange=null,this.bufferedUpdates.clear(),this.pendingClears.clear(),this.clearFailures.clear(),this.docLineageEpochs.clear(),this.docLineageEpochsEnvelopeConsumed=!1,this.onBranchMismatch=null,this.branchMismatchInFlight=null,this.onRenameRedirect=null,this.onDocDeleted=null,this.evictListeners.clear(),this.serverRestartRecoveryState=zM,this.cachedServerInstanceId=null,this.pendingServerInstanceKnown=null,this.tabIdentity=null,this.recoveryMismatchStaleClaim=void 0}evictLru(){for(let e of this.lruOrder)if(e!==this.activeDocName){X(`ok/pool/evict-lru`,{docName:e}),this.close(e);return}}destroyEntry(e){if(e.kind===`tearing-down`)return;let t=e.observerCleanup,n=e.observerFireCounterCleanup,r=e.persistence,i=e.pendingRecycleTimer,a=e.docName,o=e;o.kind=`tearing-down`,o.persistence=null,o.observerCleanup=null,o.observerFireCounterCleanup=null,o.pendingRecycleTimer=null,o.serverDrivenCloseReauthInFlight=!1,i&&clearTimeout(i),IM(a),this.fireEvict(a);try{t?.()}catch(e){console.warn(`[ProviderPool] observer cleanup threw for ${a}:`,e)}try{n?.()}catch(e){console.warn(`[ProviderPool] observer-fire-counter cleanup threw for ${a}:`,e)}r!==null&&r.destroy().catch(e=>{console.warn(`[ProviderPool] persistence destroy failed for ${a}:`,e)});try{o.provider.destroy()}catch(e){console.warn(`[ProviderPool] Provider destroy failed for ${a}:`,e)}}recycleDisconnectedEntry(e){let t=this.entries.get(e);if(!t||t.kind!==`active`)return;let n=this.activeDocName===e;if(X(`ok/pool/recycle-disconnected`,{docName:e,wasActive:n}),this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),n){this.open(e)&&this.setActive(e);return}this.notify()}},$M=crypto.randomUUID(),eN=!1;function tN(e){eN||(eN=!0,console.warn(`[principal-fetch] failed to resolve principal — falling back to random identity.`,e))}var nN=(0,Q.createContext)(null),rN=/\.(md|mdx)$/i,iN=null;function aN(e){return iN||(iN=new QM(ZM,e),Wp(iN)),iN}var oN={activeDocName:null,activeProvider:null,syncState:`connecting`,serverRestartRecovery:{kind:`idle`},poolEntries:[]};function sN(){if(typeof window>`u`)return null;let e=window.okDesktop;return e?.config.mode===`editor`?e:null}function cN(){return typeof window>`u`||window.okDesktop?.config.mode===`editor`?null:Lm(window.location.origin)}function lN(){if(typeof window>`u`)return Fm(null,ZM);let e=cN();return e?Rm(window.localStorage===void 0?null:window.localStorage,e,ZM):Fm(null,ZM)}function uN(){return lN().openTabs}function dN(){return lN().pinnedTabIds}function fN(){if(typeof window>`u`||window.location.hash.length>0)return null;let e=lN();return e.activeTabId??(e.activeDocName?cm(e.activeDocName):null)??e.openTabs[0]??null}function pN(e){let t=pm(e);switch(t.kind){case`doc`:return xi(t.docName);case`folder`:return mi(t.folderPath);case`asset`:return yi(t.assetPath);case`skill-file`:return _i({scope:t.scope,name:t.name,path:t.path})}}function mN(e){let t=vi(e);if(t)return um(t);let n=hi(e);if(n)return om(n);let r=bi(e);if(!r)return null;let i=r.trim();if(/\/+$/.test(i)){let e=i.replace(/\/+$/g,``);return e?lm(e):null}return cm(r)}function hN(e,t,n){return!e||!n||t!==xi(e)||rN.test(e)||!rN.test(n)?!1:n.replace(rN,``)===e}function gN(e){return{kind:`asset`,target:e,assetPath:e,mediaKind:pe(e.split(`.`).pop()??``)}}function _N(e,t){return e?fm(e):t?cm(t):null}function vN(e,t,n){return e.some(e=>!n.has(e)&&mm(e)===t)}function yN(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function bN(e){switch(e.kind){case`doc`:return`doc:${e.docName}`;case`folder-index`:return`folder-index:${e.docName}:${e.folderPath}:${e.noteKind}`;case`folder`:return`folder:${e.folderPath}`;case`asset`:return`asset:${e.assetPath}:${e.mediaKind??``}`;case`skill-file`:return`skill-file:${e.scope}:${e.name}:${e.path}`;case`large-file`:return`large-file:${e.docName}:${e.size}:${e.limit}`;case`missing`:return`missing:${e.target}`}}function xN(e,t){return e===t?!0:!e||!t?!1:bN(e)===bN(t)}function SN(e){let t=e.getActive(),n=[];for(let t of e.entries.values())n.push({docName:t.docName,provider:t.provider,lastAccessedAt:t.lastAccessedAt,poolEventId:t.poolEventId});return n.sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt),{activeDocName:e.getActiveDocName(),activeProvider:t?.provider??null,syncState:t?.syncState??`connecting`,serverRestartRecovery:e.getServerRestartRecoveryState(),poolEntries:n}}function CN(e){let t=(0,$.c)(183),{children:n}=e,[r,i]=(0,Q.useState)(oN),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(fN),[l,u]=(0,Q.useState)(uN),[d,f]=(0,Q.useState)(dN),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[0]=p):p=t[0];let[m,h]=(0,Q.useState)(p),[g,_]=(0,Q.useState)(l),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(s),C=(0,Q.useRef)(l),w=(0,Q.useRef)(d),T=(0,Q.useRef)(v),E=(0,Q.useRef)(m),D=(0,Q.useRef)(g),O=(0,Q.useRef)(1),k;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(k=[],t[1]=k):k=t[1];let A=(0,Q.useRef)(k),j=(0,Q.useRef)(!1),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),[R,ee]=(0,Q.useState)(`doc`),[z,te]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(0),{collabUrl:B,terminal:V,lastError:H,retry:U}=sd(),W;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(W=function(e){S.current=e,c(e)},t[2]=W):W=t[2];let G=W,ie;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(ie=function(e){T.current=e,y(e)},t[3]=ie):ie=t[3];let K=ie,ae;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(ae=function(e){D.current=e,_(t=>yN(t,e)?t:e)},t[4]=ae):ae=t[4];let oe=ae,q;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(q=function(e){w.current=e,f(t=>yN(t,e)?t:e)},t[5]=q):q=t[5];let se=q,ce;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(ce=function(e,t){let n=gm(t,e);C.current=e,w.current=n,u(t=>yN(t,e)?t:e),f(e=>yN(e,n)?e:n),oe(Dm(D.current,e,E.current))},t[6]=ce):ce=t[6];let J=ce,le;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(le=function(e){J(e,w.current)},t[7]=le):le=t[7];let ue=le,Y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(Y=function(e){ue(e(C.current))},t[8]=Y):Y=t[8];let de=Y,fe;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(fe=function(e){E.current=e,h(t=>yN(t,e)?t:e),oe(Dm(D.current,C.current,e))},t[9]=fe):fe=t[9];let pe=fe,me;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(me=function(e){let t=T.current;if(!t)return;let n=E.current.filter(e=>e!==t);E.current=n,h(e=>yN(e,n)?e:n),K(null);let r=[],i=new Set;for(let n of D.current){let a=n===t?e:n;!a||i.has(a)||(i.add(a),r.push(a))}oe(Dm(r,C.current,n))},t[10]=me):me=t[10];let he=me,ge,_e;t[11]===s?(ge=t[12],_e=t[13]):(ge=()=>{S.current=s},_e=[s],t[11]=s,t[12]=ge,t[13]=_e),(0,Q.useEffect)(ge,_e);let ve,ye;t[14]===l?(ve=t[15],ye=t[16]):(ve=()=>{C.current=l},ye=[l],t[14]=l,t[15]=ve,t[16]=ye),(0,Q.useEffect)(ve,ye);let be,xe;t[17]===d?(be=t[18],xe=t[19]):(be=()=>{w.current=d},xe=[d],t[17]=d,t[18]=be,t[19]=xe),(0,Q.useEffect)(be,xe);let Se,Ce;t[20]===v?(Se=t[21],Ce=t[22]):(Se=()=>{T.current=v},Ce=[v],t[20]=v,t[21]=Se,t[22]=Ce),(0,Q.useEffect)(Se,Ce);let we,Te;t[23]===m?(we=t[24],Te=t[25]):(we=()=>{E.current=m},Te=[m],t[23]=m,t[24]=we,t[25]=Te),(0,Q.useEffect)(we,Te);let Ee,De;t[26]===g?(Ee=t[27],De=t[28]):(Ee=()=>{D.current=g},De=[g],t[26]=g,t[27]=Ee,t[28]=De),(0,Q.useEffect)(Ee,De);let Oe=v!==null,ke,Ae;t[29]!==B||t[30]!==M||t[31]!==b?(ke=()=>{if(B===null||b||!M)return;let e=!1,t=sN(),n=cN(),r=typeof localStorage<`u`?localStorage:null;return(t?t.project.getSessionState():Promise.resolve(n?Rm(r,n,ZM):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null})).then(t=>{if(e)return;let n=Fm(t,ZM);if(j.current)return;let r=aN(B);for(let e of n.openTabs){let t=mm(e);t&&r.open(t)}let i=[...n.pinnedTabIds,...w.current],a=n.openTabs;for(let e of C.current)a=Sm(a,e,ZM,i);let o=gm(i,a);C.current=a,w.current=o,u(e=>yN(e,a)?e:a),f(e=>yN(e,o)?e:o);let s=Dm(n.openTabs.length>0?a:D.current,a,E.current);D.current=s,_(e=>yN(e,s)?e:s);let l=bi(window.location.hash),d=n.activeTabId??(n.activeDocName?cm(n.activeDocName):null)??n.openTabs[0]??null,p=d?pN(d):null,m=d?mm(d):null;if((l===null&&window.location.hash.length===0||p!==null&&p===window.location.hash||hN(l,window.location.hash,m))&&d){S.current=d,c(d);let e=pN(d);window.location.hash!==e&&(window.location.hash=e)}}).catch(NN).finally(()=>{e||x(!0)}),()=>{e=!0}},Ae=[B,M,b],t[29]=B,t[30]=M,t[31]=b,t[32]=ke,t[33]=Ae):(ke=t[32],Ae=t[33]),(0,Q.useEffect)(ke,Ae);let je,Me;t[34]!==s||t[35]!==a||t[36]!==l||t[37]!==d||t[38]!==r.activeDocName||t[39]!==b?(je=()=>{if(!b)return;let e=Im(l,s??_N(a,r.activeDocName),d),t=sN();if(t){t.project.setSessionState(e).catch(MN);return}let n=cN();n&&zm(typeof localStorage<`u`?localStorage:null,n,e)},Me=[s,a,l,d,r.activeDocName,b],t[34]=s,t[35]=a,t[36]=l,t[37]=d,t[38]=r.activeDocName,t[39]=b,t[40]=je,t[41]=Me):(je=t[40],Me=t[41]),(0,Q.useEffect)(je,Me);let Ne;t[42]===b?Ne=t[43]:(Ne=function(){b||(j.current=!0)},t[42]=b,t[43]=Ne);let Pe=Ne,Fe,Ie;t[44]===B?(Fe=t[45],Ie=t[46]):(Fe=()=>{if(B===null)return;let e=!1;N(!1);let t=aN(B);i(SN(t));let n=function(e,t){let n=gm(t,e);C.current=e,w.current=n,u(t=>yN(t,e)?t:e),f(e=>yN(e,n)?e:n);let r=Dm(D.current,e,E.current);D.current=r,_(e=>yN(e,r)?e:r)};return t.setOnBranchMismatch(()=>Wu(t)),t.setOnRenameRedirect(e=>{let{fromDocName:r,toDocName:i,hadOpenProvider:a}=e;(async()=>{let e,s=t.getActiveDocName()===r;wp([{fromDocName:r,toDocName:i}]);try{await Promise.all([t.closeAndClearPersistence(r),t.closeAndClearPersistence(i)]),s&&(t.open(i),t.setActive(i));let e=km(C.current,[{fromDocName:r,toDocName:i}],ZM,[],w.current),a=gm(km(w.current,[{fromDocName:r,toDocName:i}],2**53-1),e);D.current=Am(D.current,[{fromDocName:r,toDocName:i}]),n(e,a),o(e=>e&&(ci(e)===r?{kind:`doc`,target:i,docName:i}:e)),s&&(window.location.hash=xi(i))}catch(t){let n=t;e=n,console.warn(JSON.stringify({event:`removal-cleanup-error`,kind:`renamed`,fromDocName:r,toDocName:i,message:String(n instanceof Error?n.message:n)}))}console.info(JSON.stringify({event:`removal.cleanup`,kind:`renamed`,fromDocName:r,toDocName:i,hadOpenProvider:a,hadStaleIdb:!a,source:`auth-rejection`,errored:e!==void 0}))})()}),t.setOnDocDeleted(e=>{let{docName:r,hadOpenProvider:i}=e;(async()=>{let e;try{await t.closeAndClearPersistence(r),n(Em(C.current,r),w.current),o(e=>e&&(ci(e)===r?null:e)),t.getActiveDocName()===r&&(window.location.hash=``)}catch(t){let n=t;e=n,console.warn(JSON.stringify({event:`removal-cleanup-error`,kind:`deleted`,docName:r,message:String(n instanceof Error?n.message:n)}))}console.info(JSON.stringify({event:`removal.cleanup`,kind:`deleted`,fromDocName:r,hadOpenProvider:i,hadStaleIdb:!i,source:`auth-rejection`,errored:e!==void 0}))})()}),t.setOnChange(()=>i(SN(t))),fetch(`/api/principal`).then(jN).then(n=>{if(e)return;let r=ft.safeParse(n);r.success?(t.setTabIdentity({principalId:r.data.id,tabSessionId:$M}),F(r.data)):tN(r.error)}).catch(t=>{e||tN(t)}).finally(()=>{e||N(!0)}),Wu(t),()=>{e=!0,t.setOnChange(null),t.setOnRenameRedirect(null),t.setOnDocDeleted(null)}},Ie=[B],t[44]=B,t[45]=Fe,t[46]=Ie),(0,Q.useEffect)(Fe,Ie);let Le;t[47]===B?Le=t[48]:(Le=e=>{if(X(`ok/nav/open-document`,{docName:e,transition:!1}),B===null)return;let t=aN(B),n=t.open(e);if(!n)return;Bu(e,n.poolEventId);let r=cm(e);de(e=>Sm(e,r,ZM,w.current)),he(r),G(r),t.setActive(e),o({kind:`doc`,target:e,docName:e})},t[47]=B,t[48]=Le);let Re=Le,ze;t[49]===Re?ze=t[50]:(ze=e=>{X(`ok/nav/open-document`,{docName:e,transition:!1}),Re(e)},t[49]=Re,t[50]=ze);let Be=ze,Ve;t[51]!==a||t[52]!==B||t[53]!==Pe||t[54]!==r.activeDocName?(Ve=(e,t)=>{let n=t===void 0?{}:t;if(B===null)return;n.tabBehavior===`replace-active`&&Pe();let i=aN(B),s=ci(e),c=T.current,l=c!==null&&n.tabBehavior===`replace-active`,u=c?null:S.current??_N(a,r.activeDocName),d=u!==null&&C.current.includes(u),f=u!==null&&w.current.includes(u),p=n.tabBehavior===`replace-active`&&f||n.tabBehavior===`replace-active`&&!l&&!d?`append`:n.tabBehavior??`append`;if(s&&e.kind!==`large-file`){let e=i.open(s);if(!e)return;Bu(s,e.poolEventId);let t=wm(C.current,s,{behavior:p,currentTabId:u,limit:ZM,pinnedTabIds:w.current});ue(t.tabs),he(t.activeTabId),G(t.activeTabId),i.setActive(s)}else{i.clearActive();let t=fm(e);if(t){let e=Tm(C.current,t,{behavior:p,currentTabId:u,limit:ZM,pinnedTabIds:w.current});ue(e.tabs),G(e.activeTabId),he(e.activeTabId)}else he(t)}o(t=>xN(t,e)?t:e)},t[51]=a,t[52]=B,t[53]=Pe,t[54]=r.activeDocName,t[55]=Ve):Ve=t[55];let He=Ve,Ue;t[56]===He?Ue=t[57]:(Ue=(e,t)=>{He(e,t===void 0?{}:t)},t[56]=He,t[57]=Ue);let We=Ue,Ge;t[58]===He?Ge=t[59]:(Ge=(e,t)=>{let n=t===void 0?{}:t;X(`ok/nav/open-target`,{docName:ci(e),kind:e.kind,transition:!1}),He(e,n)},t[58]=He,t[59]=Ge);let Ke=Ge,qe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(qe=function(e){e.length!==0&&(A.current=[...A.current,...e].slice(-50))},t[60]=qe):qe=t[60];let Je=qe,Ye;t[61]===B?Ye=t[62]:(Ye=e=>{let t=pm(e);if(K(null),G(e),t.kind===`doc`){if(B!==null){let e=aN(B);if(!e.open(t.docName))return;e.setActive(t.docName)}o({kind:`doc`,target:t.docName,docName:t.docName});let e=xi(t.docName);window.location.hash!==e&&(window.location.hash=e);return}if(B!==null&&aN(B).clearActive(),t.kind===`asset`){o(gN(t.assetPath));let e=yi(t.assetPath);window.location.hash!==e&&(window.location.hash=e);return}if(t.kind===`skill-file`){o({kind:`skill-file`,target:`${t.scope}/${t.name}/${t.path}`,scope:t.scope,name:t.name,path:t.path});let e=_i({scope:t.scope,name:t.name,path:t.path});window.location.hash!==e&&(window.location.hash=e);return}o({kind:`folder`,target:t.folderPath,folderPath:t.folderPath});let n=mi(t.folderPath);window.location.hash!==n&&(window.location.hash=n)},t[61]=B,t[62]=Ye);let Xe=Ye,Ze;t[63]===B?Ze=t[64]:(Ze=()=>{let e=`new-tab:${O.current}`;O.current+=1,pe([...E.current,e]),K(e),B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash!==``&&(window.location.hash=``)},t[63]=B,t[64]=Ze);let Qe=Ze,$e;t[65]!==s||t[66]!==a||t[67]!==B||t[68]!==Pe||t[69]!==r.activeDocName?($e=e=>{if(w.current.includes(e)||!C.current.includes(e))return;Pe();let t=null,n=mm(e);if(Je([e]),B!==null){let t=aN(B);n&&!vN(C.current,n,new Set([e]))&&t.close(n)}let i=s??_N(a,r.activeDocName);if(de(n=>(t=Nm(n,i,e),Em(n,e))),i===e){if(t){G(t),window.location.hash=pN(t);return}B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash=``}},t[65]=s,t[66]=a,t[67]=B,t[68]=Pe,t[69]=r.activeDocName,t[70]=$e):$e=t[70];let et=$e,tt;t[71]!==B||t[72]!==Pe?(tt=e=>{Pe();let t=E.current;if(!t.includes(e))return;let n=t.filter(t=>t!==e);if(pe(n),T.current!==e)return;let r=t.indexOf(e),i=n[r]??n[r-1]??null;if(i){K(i),B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash!==``&&(window.location.hash=``);return}K(null);let a=C.current[C.current.length-1]??null;if(a){G(a),window.location.hash=pN(a);return}B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash=``},t[71]=B,t[72]=Pe,t[73]=tt):tt=t[73];let nt=tt,rt;t[74]!==nt||t[75]!==et?(rt=()=>{let e=T.current;if(e)return nt(e),!0;let t=new Set(w.current),n=new Set(C.current.filter(e=>!t.has(e))),r=(S.current&&n.has(S.current)?S.current:null)??D.current.find(e=>n.has(e));if(r)return et(r),!0;let i=new Set(E.current),a=D.current.find(e=>i.has(e));return a?(nt(a),!0):!1},t[74]=nt,t[75]=et,t[76]=rt):rt=t[76];let it=rt,at,ot;t[77]===it?(at=t[78],ot=t[79]):(at=()=>{let e=sN();if(e)return e.onMenuAction(e=>{e===`close-active-tab-or-window`&&(it()||window.close())})},ot=[it],t[77]=it,t[78]=at,t[79]=ot),(0,Q.useEffect)(at,ot);let st;t[80]===B?st=t[81]:(st=()=>{if(B===null){o(AN),S.current=null,c(kN);return}let e=aN(B);e.getActiveDocName()!==null&&e.clearActive(),o(ON),S.current=null,c(DN)},t[80]=B,t[81]=st);let ct;t[82]!==B||t[83]!==Pe?(ct=e=>{B!==null&&(Pe(),aN(B).close(e),de(t=>Em(t,cm(e))),c(t=>{let n=t&&mm(t)===e?null:t;return S.current=n,n}),o(t=>t&&(ci(t)===e?null:t)))},t[82]=B,t[83]=Pe,t[84]=ct):ct=t[84];let lt;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(lt=e=>{let t=vm(w.current,e,C.current);yN(w.current,t)||se(t)},t[85]=lt):lt=t[85];let ut;t[86]===Pe?ut=t[87]:(ut=e=>{let t=ym(w.current,e);yN(w.current,t)||(Pe(),se(t))},t[86]=Pe,t[87]=ut);let dt;t[88]===Xe?dt=t[89]:(dt=e=>{Xe(e)},t[88]=Xe,t[89]=dt);let pt;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(pt=(e,t)=>{let n=new Set(C.current),r=new Set(E.current),i=new Set,a=[],o=[],s=[];for(let t of e)i.has(t)||(n.has(t)?(a.push(t),s.push(t),i.add(t)):r.has(t)&&(o.push(t),s.push(t),i.add(t)));for(let e of C.current)i.has(e)||(a.push(e),s.push(e),i.add(e));for(let e of E.current)i.has(e)||(o.push(e),s.push(e),i.add(e));let c=yN(C.current,a),l=yN(E.current,o),u=yN(D.current,s);c&&l&&u||(D.current=s,l||(E.current=o,h(e=>yN(e,o)?e:o)),J(a,xm(a,w.current,t)))},t[90]=pt):pt=t[90];let mt;t[91]===B?mt=t[92]:(mt=e=>{E.current.includes(e)&&(B!==null&&aN(B).clearActive(),o(null),G(null),K(e),window.location.hash!==``&&(window.location.hash=``))},t[91]=B,t[92]=mt);let ht;t[93]===Xe?ht=t[94]:(ht=()=>{let e=[...A.current];for(;e.length>0;){let t=e.pop();if(!t)continue;if(C.current.includes(t)){A.current=e;continue}let n=Sm(C.current,t,ZM,w.current);if(!n.includes(t))return;A.current=e,ue(n),Xe(t);return}A.current=[]},t[93]=Xe,t[94]=ht);let gt;t[95]!==s||t[96]!==a||t[97]!==B||t[98]!==Pe||t[99]!==r.activeDocName?(gt=(e,t)=>{let n=t===void 0?{}:t,i=e.filter(EN),c=new Set(n.force?i:bm(i,w.current));if(c.size===0)return;if(Pe(),n.force||Je(C.current.filter(e=>c.has(e))),B!==null){let e=aN(B),t=new Map;for(let e of c){let n=mm(e);if(!n)continue;let r=t.get(n)??new Set;r.add(e),t.set(n,r)}for(let[n,r]of t)vN(C.current,n,r)||e.close(n)}let l=null,u=s??_N(a,r.activeDocName);if(de(e=>(l=Pm(e,u,c),e.filter(e=>!c.has(e)))),!u||!c.has(u)){u||o(e=>{if(!e)return e;let t=fm(e);return t&&c.has(t)?null:e});return}if(l){G(l),window.location.hash=pN(l);return}B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash=``},t[95]=s,t[96]=a,t[97]=B,t[98]=Pe,t[99]=r.activeDocName,t[100]=gt):gt=t[100];let _t;t[101]!==s||t[102]!==a||t[103]!==B||t[104]!==Pe||t[105]!==l||t[106]!==r.activeDocName?(_t=e=>{let{pages:t,folderPaths:n,assetPaths:i,filePaths:c}=e,u=Om(l,{pages:t,folderPaths:n,assetPaths:i,filePaths:c,keepMissingDocName:a?.kind===`missing`?a.target:null,keepHashDocName:typeof window<`u`?bi(window.location.hash):null});if(u.length===l.length)return;let d=new Set(u),f=l.filter(e=>!d.has(e)),p=new Set(f);if(Pe(),B!==null){let e=aN(B);for(let t of f){let n=mm(t);n&&e.close(n)}}ue(u);let m=typeof window<`u`?mN(window.location.hash):null,h=s??_N(a,r.activeDocName),g=m&&p.has(m)?m:h&&p.has(h)?h:null;if(!g){o(e=>{if(!e)return e;let t=fm(e);return t&&p.has(t)?null:e});return}let _=Pm(l,g,f);if(_){G(_),window.location.hash=pN(_);return}B!==null&&aN(B).clearActive(),o(null),G(null),window.location.hash=``},t[101]=s,t[102]=a,t[103]=B,t[104]=Pe,t[105]=l,t[106]=r.activeDocName,t[107]=_t):_t=t[107];let vt;t[108]!==B||t[109]!==Pe?(vt=(e,t,n)=>{let r=t===void 0?[]:t,i=n===void 0?[]:n;Pe();let a=km(C.current,e,ZM,r,w.current,i),o=gm(km(w.current,e,2**53-1,r,[],i),a);if(B!==null){let e=aN(B);for(let t of a){let n=mm(t);n&&e.open(n)}}D.current=Am(D.current,e,r,i),J(a,o);let s=S.current;if(s){let t=km([s],e,1,r,[],i)[0];t&&a.includes(t)&&G(t)}},t[108]=B,t[109]=Pe,t[110]=vt):vt=t[110];let yt,bt,xt,St,Ct;t[111]===B?(yt=t[112],bt=t[113],xt=t[114],St=t[115],Ct=t[116]):(yt=async e=>{B!==null&&(await aN(B).closeAndClearPersistence(e),o(t=>t&&(ci(t)===e?null:t)))},bt=()=>B===null?null:aN(B).getActiveDocName(),xt=e=>B===null?!1:aN(B).has(e),St=e=>{B!==null&&aN(B).recycle(e)},Ct=e=>B===null?null:aN(B).prewarm(e)?.poolEventId??null,t[111]=B,t[112]=yt,t[113]=bt,t[114]=xt,t[115]=St,t[116]=Ct);let wt,Tt,Et,Dt,Ot;t[117]===B?(wt=t[118],Tt=t[119],Et=t[120],Dt=t[121],Ot=t[122]):(wt=e=>{B!==null&&aN(B).setExpectedServerInstanceId(e)},Tt=async e=>{if(B===null)return;let t=aN(B);t.setObservedBranch(e),await Vu(t,e),ui([`files`,`backlinks`,`graph`]),di(e)},Et=async e=>{if(B===null)return;let t=aN(B);t.compareAndUpdateObservedBranch(e)&&(await Vu(t,e),ui([`files`,`backlinks`,`graph`]),di(e))},Dt=(e,t)=>{B!==null&&aN(B).observeDiskAck(e,t)},Ot=async()=>{B!==null&&await Wu(aN(B))},t[117]=B,t[118]=wt,t[119]=Tt,t[120]=Et,t[121]=Dt,t[122]=Ot);let kt;t[123]!==z||t[124]!==R||t[125]!==r.activeDocName?(kt=(e,t)=>{if(!r.activeDocName&&t){window.location.hash=xi(t),te(e),ee(`agent`),re(TN);return}if(R===`agent`&&z===e){ee(`doc`);return}te(e),ee(`agent`),re(wN)},t[123]=z,t[124]=R,t[125]=r.activeDocName,t[126]=kt):kt=t[126];let At;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(At=()=>{ee(`doc`),te(null)},t[127]=At):At=t[127];let jt;t[128]!==v||t[129]!==s||t[130]!==a||t[131]!==it||t[132]!==nt||t[133]!==et||t[134]!==H||t[135]!==V||t[136]!==B||t[137]!==z||t[138]!==ne||t[139]!==R||t[140]!==Oe||t[141]!==m||t[142]!==Re||t[143]!==Be||t[144]!==Qe||t[145]!==l||t[146]!==We||t[147]!==Ke||t[148]!==d||t[149]!==P||t[150]!==U||t[151]!==r.activeDocName||t[152]!==r.activeProvider||t[153]!==r.poolEntries||t[154]!==r.serverRestartRecovery||t[155]!==r.syncState||t[156]!==I||t[157]!==st||t[158]!==ct||t[159]!==ut||t[160]!==dt||t[161]!==mt||t[162]!==ht||t[163]!==gt||t[164]!==_t||t[165]!==vt||t[166]!==yt||t[167]!==bt||t[168]!==xt||t[169]!==St||t[170]!==Ct||t[171]!==wt||t[172]!==Tt||t[173]!==Et||t[174]!==Dt||t[175]!==Ot||t[176]!==kt||t[177]!==b||t[178]!==g?(jt={principal:P,activeTarget:a,activeTabId:s,activeDocName:r.activeDocName,activeProvider:r.activeProvider,openTabs:l,pinnedTabIds:d,visibleTabIds:g,tabSessionLoaded:b,syncState:r.syncState,serverRestartRecovery:r.serverRestartRecovery,poolEntries:r.poolEntries,openDocument:Re,openDocumentTransition:Be,openTarget:We,openTargetTransition:Ke,clearTarget:st,closeDocument:ct,closeActiveTabOrWindow:it,closeTab:et,pinTab:lt,unpinTab:ut,activateTab:dt,reorderTabs:pt,newTabIds:m,activeNewTabId:v,isNewTabActive:Oe,openNewTab:Qe,activateNewTab:mt,closeNewTab:nt,reopenClosedTab:ht,closeTabs:gt,syncOpenTabsWithKnownTargets:_t,remapTabsForRename:vt,closeAndClearForRename:yt,getPoolActiveDocName:bt,poolHas:xt,recycleDocument:St,prewarm:Ct,systemProvider:I,setSystemProvider:L,updateServerInstanceId:wt,onBranchSwitched:Tt,observeBranch:Et,observeDiskAck:Dt,refreshServerInfo:Ot,collabUrl:B,collabTerminal:V,collabLastError:H,retryCollab:U,docPanelMode:R,docPanelAgentId:z,docPanelExpandSignal:ne,openActivityPanel:kt,closeActivityPanel:At},t[128]=v,t[129]=s,t[130]=a,t[131]=it,t[132]=nt,t[133]=et,t[134]=H,t[135]=V,t[136]=B,t[137]=z,t[138]=ne,t[139]=R,t[140]=Oe,t[141]=m,t[142]=Re,t[143]=Be,t[144]=Qe,t[145]=l,t[146]=We,t[147]=Ke,t[148]=d,t[149]=P,t[150]=U,t[151]=r.activeDocName,t[152]=r.activeProvider,t[153]=r.poolEntries,t[154]=r.serverRestartRecovery,t[155]=r.syncState,t[156]=I,t[157]=st,t[158]=ct,t[159]=ut,t[160]=dt,t[161]=mt,t[162]=ht,t[163]=gt,t[164]=_t,t[165]=vt,t[166]=yt,t[167]=bt,t[168]=xt,t[169]=St,t[170]=Ct,t[171]=wt,t[172]=Tt,t[173]=Et,t[174]=Dt,t[175]=Ot,t[176]=kt,t[177]=b,t[178]=g,t[179]=jt):jt=t[179];let Mt=jt,Nt;return t[180]!==n||t[181]!==Mt?(Nt=(0,Z.jsx)(nN,{value:Mt,children:n}),t[180]=n,t[181]=Mt,t[182]=Nt):Nt=t[182],Nt}function wN(e){return e+1}function TN(e){return e+1}function EN(e){return e.length>0}function DN(e){return e===null?e:null}function ON(e){return e===null?e:null}function kN(e){return e===null?e:null}function AN(e){return e===null?e:null}function jN(e){return e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))}function MN(e){console.warn(`[editor-tabs] failed to persist tab session:`,e)}function NN(e){console.warn(`[editor-tabs] failed to restore tab session:`,e)}function PN(){let e=(0,Q.use)(nN);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function FN(){let e=(0,$.c)(3),{openDocumentTransition:t,openTargetTransition:n}=PN(),r;return e[0]!==t||e[1]!==n?(r={openDocumentTransition:t,openTargetTransition:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}export{Rh as $,wl as $t,fO as A,Wa as An,_d as At,nC as B,Nu as Bt,sk as C,ro as Cn,If as Ct,ek as D,Xa as Dn,xf as Dt,ak as E,Za as En,Wd as Et,NT as F,$u as Ft,Av as G,bu as Gt,$S as H,ju as Ht,UT as I,Gu as It,Xg as J,Tu as Jt,Q_ as K,xu as Kt,Mw as L,Hu as Lt,eE as M,Ha as Mn,vd as Mt,KT as N,Ra as Nn,gd as Nt,FO as O,Ja as On,Df as Ot,RT as P,nd as Pt,pg as Q,Du as Qt,jw as R,zu as Rt,ik as S,io as Sn,Qf as St,ok as T,eo as Tn,Ff as Tt,eC as U,Au as Ut,rC as V,Ou as Vt,rb as W,ku as Wt,Fg as X,Eu as Xt,Jg as Y,Su as Yt,Og as Z,Cu as Zt,Lj as _,po as _n,Vp as _t,yM as a,pl as an,jm as at,Mk as b,oo as bn,op as bt,_M as c,Po as cn,Jp as ct,FM as d,wo as dn,wp as dt,Sl as en,um as et,hM as f,Co as fn,xp as ft,Ij as g,mo as gn,bp as gt,Jj as h,ho as hn,Ap as ht,bM as i,xl as in,pm as it,aD as j,Ua as jn,hd as jt,DO as k,Ga as kn,jd as kt,IM as l,No as ln,qp as lt,Yj as m,yo as mn,Np as mt,PN as n,hl as nn,bm as nt,vM as o,ol as on,fm as ot,mM as p,So as pn,Mp as pt,v_ as q,wu as qt,FN as r,ml as rn,lm as rt,xM as s,sl as sn,dm as st,CN as t,bl as tn,cm as tt,jM as u,jo as un,Kp as ut,MA as v,fo as vn,Kf as vt,ck as w,no as wn,Pf as wt,dk as x,ao as xn,ap as xt,kA as y,uo as yn,sp as yt,vw as z,Mu as zt};