@inkeep/open-knowledge 0.10.0-beta.4 → 0.10.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +42 -42
- package/dist/constants--DUPbREL.mjs +2 -0
- package/dist/{dist-dyLf1nW-.mjs → dist-BqtNTXGW.mjs} +11 -11
- package/dist/{dist-DTrrqwCO.mjs → dist-CGW-79-O.mjs} +1 -1
- package/dist/{gh-detect-7CewBTHd.mjs → gh-detect-D1pPqkIR.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{init-DdHidrtv.mjs → init-C1cYSA9D.mjs} +4 -4
- package/dist/init-CMZdzvdW.mjs +1 -0
- package/dist/{loader-Bf5lDOSq.mjs → loader-Dy9SPEsg.mjs} +3 -3
- package/dist/loader-m7runzWF.mjs +1 -0
- package/dist/{preview-DLFMqNAn.mjs → preview-CeRWIHB8.mjs} +2 -2
- package/dist/preview-DuG2Ij54.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-B70RZtoZ.js → ActivityModeContent-D77uMT7q.js} +1 -1
- package/dist/public/assets/{DocumentContext-B0H5i_bU.js → DocumentContext-DvWJMVqj.js} +3 -3
- package/dist/public/assets/{GraphPanel-DWqoIFOB.js → GraphPanel-c-DpLlYh.js} +1 -1
- package/dist/public/assets/{SettingsDialogBody-bwbxduq5.js → SettingsDialogBody-8ASFsPyN.js} +2 -2
- package/dist/public/assets/SourceEditor-CN0C3KYk.js +2 -0
- package/dist/public/assets/{config-validation-events-CDAap8wV.js → config-validation-events-DTdCtBZo.js} +5 -5
- package/dist/public/assets/index-BpgTGN6A.js +1915 -0
- package/dist/public/assets/{keyboard-shortcuts-C6IgDAxF.js → keyboard-shortcuts-Ccg3Soaq.js} +1 -1
- package/dist/public/assets/{prop-types-ClZR0brz.js → prop-types-D0BPBtJk.js} +122 -122
- package/dist/public/assets/{target-navigation-intent-DJ_3bEwP.js → target-navigation-intent-DfSgBKSv.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-Cilqkggt.js → typing-burst-detector--omeHW_D.js} +3 -3
- package/dist/public/index.html +7 -7
- package/dist/{repair-launch-json-DJof9L_4.mjs → repair-launch-json-BiqV7vhS.mjs} +2 -2
- package/dist/{repair-mcp-configs-kmPXzAQA.mjs → repair-mcp-configs-BKdr3dN1.mjs} +2 -2
- package/dist/repair-skills-CSwuXcFV.mjs +1 -0
- package/dist/{repair-skills-CeRN3hNW.mjs → repair-skills-rNUCUplx.mjs} +2 -2
- package/dist/{server-lock-BpjJj3OD-wzz0WNKm.mjs → server-lock-BpjJj3OD-NSLCIeKW.mjs} +27 -27
- package/dist/server-lock-CyhBidkz-BpqW9Pz0.mjs +1 -0
- package/dist/{src-Cezub-n-.mjs → src-BuAflyFg.mjs} +2 -2
- package/dist/start-BojtAZ4x.mjs +1 -0
- package/dist/{start-Bgvhm827.mjs → start-CYRhCS2M.mjs} +2 -2
- package/dist/{write-project-skill-_gdmx7XS.mjs → write-project-skill-D3DP_2xi.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-CXSN-BsG.mjs +0 -2
- package/dist/init-G7zh8Edu.mjs +0 -1
- package/dist/loader-CJkwNnOb.mjs +0 -1
- package/dist/preview-h7eoPZPt.mjs +0 -1
- package/dist/public/assets/SourceEditor-By_0QuiO.js +0 -2
- package/dist/public/assets/index-CgrGK587.js +0 -1915
- package/dist/repair-skills-Dg1YYNHi.mjs +0 -1
- package/dist/server-lock-CyhBidkz-DrsmjbY0.mjs +0 -1
- package/dist/start-DJJ_IAJu.mjs +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-CWYso-V4.js","./preload-helper-2ej06EnG.js","./chunk-U2HBQHQK-DenE4TdD.js","./src-DOAilbaA.js","./chunk-CFjPhJqf.js","./src-L3wpjxBL.js","./chunk-5PVQY5BW-BpceE2BZ.js","./dist-Bog19bCH.js","./chunk-ICPOFSXX-BC5Xd13f.js","./_baseFor-CVV1DSgL.js","./isObjectLike-DFnkciUU.js","./isEmpty-gGVpRSDa.js","./chunk-336JU56O-CtkQ28bg.js","./chunk-5FUZZQ4R-DF0EG1O8.js","./chunk-X2U36JSP-DSyuGkzP.js","./chunk-ZZ45TVLE-DHB0SHUz.js","./rough.esm-DDK-gphn.js","./chunk-ENJZ2VHE-CY9yto8o.js","./line-C59Ezo8Z.js","./path-C-grg3CZ.js","./array-COEOjKUv.js","./chunk-BSJP7CBP-BrRqu__W.js","./chunk-426QAEUC-jRhC4EYv.js","./chunk-XPW4576I-CLO5Bb_q.js","./pdf-CtJiipL_.js","./dist-DsbVHLNy.js","./dist-Du-s1q8P.js","./w3c-keyname-B5t0fahT.js","./dist-BYGzJeLM.js","./dist-Cq1LYbUj.js","./dist-CXGJFbY5.js","./dist-BrsSsfiw.js","./dist-CyaBbyDQ.js","./stex-CzCFWeB9.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{a as r,i,o as a,r as o,t as s}from"./compiler-runtime-Cs91PcD2.js";import{$ as c,$i as l,$n as u,$r as d,$t as f,Ai as p,Ar as m,B as h,Bi as g,Br as _,Ci as v,Cn as y,Cr as b,Ct as x,Di as S,Dr as C,E as w,Ei as T,En as E,Fi as D,Fn as O,Fr as k,Gr as A,H as j,Hr as M,Ht as N,I as P,Ii as F,In as I,Ir as L,It as ee,J as R,Ji as z,Jn as te,Jr as B,Kn as ne,Kt as V,L as re,Li as ie,Ln as H,Lr as ae,M as oe,Mi as U,Mr as se,N as ce,Ni as W,Nn as le,Nr as ue,Nt as de,O as fe,Oi as pe,Or as me,P as he,Pi as ge,Pn as _e,Pr as ve,Pt as ye,Q as be,Qi as xe,Qn as Se,Qt as Ce,Ri as we,Rn as Te,Rr as Ee,St as De,Ti as Oe,Tr as ke,Tt as Ae,U as je,Ut as Me,V as Ne,Vi as Pe,Vt as Fe,W as Ie,Wt as Le,Xi as G,Xr as Re,Xt as ze,Y as Be,Yi as Ve,Zi as He,Zn as Ue,Zr as We,Zt as Ge,_n as Ke,_r as qe,_t as Je,a as Ye,ai as Xe,b as Ze,bi as Qe,bn as $e,br as et,bt as tt,c as nt,cn as rt,cr as it,di as at,dr as ot,dt as st,en as ct,et as lt,f as ut,fi as dt,fr as ft,ft as pt,gi as mt,gr as ht,hi as gt,hr as _t,ht as vt,i as yt,ii as bt,in as xt,ir as St,ji as Ct,jn as wt,jr as Tt,k as Et,li as Dt,ln as Ot,m as kt,mi as At,mn as jt,mr as Mt,mt as Nt,nr as Pt,oi as Ft,on as It,or as Lt,ot as Rt,p as zt,pi as Bt,pr as Vt,pt as Ht,q as Ut,qi as Wt,qn as Gt,qr as Kt,qt,r as Jt,si as Yt,sn as Xt,sr as Zt,ta as Qt,tn as $t,tr as en,tt as tn,u as nn,ui as rn,ur as an,ut as on,vn as sn,vr as cn,vt as ln,wi as un,wn as dn,xn as fn,y as pn,yi as mn,yn as hn,yr as gn,yt as _n,z as vn,zi as yn,zr as bn,zt as xn}from"./prop-types-ClZR0brz.js";import{C as K,S as Sn,_ as Cn,a as wn,b as Tn,c as En,d as Dn,g as On,i as kn,l as An,m as jn,o as Mn,p as Nn,r as Pn,s as Fn,t as In,u as Ln,w as Rn,x as zn,y as Bn}from"./button-DenIdY-r.js";import{_ as Vn,a as Hn,b as Un,c as Wn,d as Gn,f as Kn,g as qn,h as Jn,i as Yn,l as Xn,m as Zn,n as Qn,o as $n,p as er,r as tr,s as nr,t as rr,u as ir,x as ar,y as or}from"./dialog-B1es0EvU.js";import{a as sr,i as cr,n as lr,r as ur,t as dr}from"./collapsible-BhpeB6tu.js";import{t as fr}from"./trace-api-CiCjX4Sz.js";import{n as pr,t as mr}from"./propagation-api-3kmMXRwS.js";import{n as hr,t as gr}from"./dist-DicqJavT.js";import{A as _r,At as vr,B as yr,Bt as br,C as xr,Ct as Sr,D as Cr,Dt as wr,E as Tr,Et as Er,F as Dr,Ft as Or,G as kr,H as Ar,Ht as jr,It as Mr,J as Nr,K as Pr,L as Fr,Lt as Ir,M as Lr,Mt as Rr,N as zr,O as Br,Ot as Vr,P as Hr,Pt as Ur,Q as Wr,R as q,S as Gr,St as Kr,T as qr,Tt as Jr,U as Yr,V as Xr,Vt as Zr,W as Qr,X as $r,Y as ei,a as ti,b as ni,c as ri,d as ii,dt as ai,f as oi,g as si,i as ci,j as li,l as ui,m as di,n as fi,o as pi,p as mi,q as hi,r as gi,s as _i,t as vi,u as yi,ut as bi,v as xi,x as Si,xt as Ci}from"./dist-Du-s1q8P.js";import{i as wi,n as Ti,r as Ei,t as Di}from"./dist-BYGzJeLM.js";import{a as Oi,c as ki,s as Ai,t as ji}from"./dist-BrsSsfiw.js";import{n as Mi}from"./dist-DsbVHLNy.js";import{n as Ni}from"./dist-Cq1LYbUj.js";import{t as Pi}from"./stex-CzCFWeB9.js";(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 Fi=K(`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`}]]),Ii=K(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Li=K(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Ri=K(`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`}]]),zi=K(`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`}]]),Bi=K(`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`}]]),Vi=K(`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`}]]),Hi=K(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Ui=K(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Wi=K(`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`}]]),Gi=K(`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`}]]),Ki=K(`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`}]]),qi=K(`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`}]]),Ji=K(`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`}]]),Yi=K(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Xi=K(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Zi=K(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Qi=K(`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`}]]),$i=K(`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`}]]),ea=K(`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`}]]),ta=K(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),na=K(`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`}]]),ra=K(`file-text`,[[`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:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),ia=K(`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`}]]),aa=K(`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`}]]),oa=K(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),sa=K(`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`}]]),ca=K(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),la=K(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),ua=K(`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`}]]),da=K(`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`}]]),fa=K(`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`}]]),pa=K(`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`}]]),ma=K(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),ha=K(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),ga=K(`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`}]]),_a=K(`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`}]]),va=K(`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`}]]),ya=K(`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`}]]),ba=[[`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`}]],xa=K(`link-2`,ba),Sa=K(`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`}]]),Ca=K(`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`}]]),wa=K(`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`}]]),Ta=K(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Ea=K(`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`}]]),Da=K(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Oa=K(`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`}]]),ka=K(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Aa=K(`panel-top`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),ja=K(`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`}]]),Ma=K(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Na=K(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Pa=K(`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`}]]),Fa=K(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Ia=K(`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`}]]),La=K(`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`}]]),Ra=K(`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`}]]),za=K(`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`}]]),Ba=K(`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`}]]),Va=K(`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`}]]),Ha=K(`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`}]]),Ua=K(`text-align-center`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]]),Wa=K(`text-align-end`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]]),Ga=K(`text-align-start`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]]),Ka=K(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),qa=K(`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`}]]),Ja=K(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),Ya=K(`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`}]]),Xa=K(`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`}]]),Za=K(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),Qa=K(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),J=s(),Y=e(r(),1);function $a(e,t){let n=(0,J.c)(7),r,i;n[0]!==e||n[1]!==t?(r=()=>{if(t!==`light`&&t!==`dark`&&t!==`system`||!e)return;let n=!1;return e.setThemeSource(t).catch(e=>{console.warn(JSON.stringify({event:`theme-source-set-failed`,themeValue:t,error:e instanceof Error?e.message:String(e)}))}).finally(()=>{if(n)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`).matches;e.signalThemeApplied({reducedTransparency:t})}),()=>{n=!0}},i=[e,t],n[0]=e,n[1]=t,n[2]=r,n[3]=i):(r=n[2],i=n[3]),(0,Y.useEffect)(r,i);let a,o;n[4]===e?(a=n[5],o=n[6]):(a=()=>{if(!e)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`),n=t=>{e.signalThemeApplied({reducedTransparency:t.matches})};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},o=[e],n[4]=e,n[5]=a,n[6]=o),(0,Y.useEffect)(a,o)}var eo=t((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),to=t(((e,t)=>{t.exports=eo()})),X=a(),no=e(Rn(),1);function ro(e,[t,n]){return Math.min(n,Math.max(t,e))}var io=`Popover`,[ao,oo]=Nn(io,[Ie]),so=Ie(),[co,lo]=ao(io),uo=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=so(t),c=Y.useRef(null),[l,u]=Y.useState(!1),[d,f]=An({prop:r,defaultProp:i??!1,onChange:a,caller:io});return(0,X.jsx)(je,{...s,children:(0,X.jsx)(co,{scope:t,contentId:Fn(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:Y.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:Y.useCallback(()=>u(!0),[]),onCustomAnchorRemove:Y.useCallback(()=>u(!1),[]),modal:o,children:n})})};uo.displayName=io;var fo=`PopoverAnchor`,po=Y.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=lo(fo,n),a=so(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return Y.useEffect(()=>(o(),()=>s()),[o,s]),(0,X.jsx)(h,{...a,...r,ref:t})});po.displayName=fo;var mo=`PopoverTrigger`,ho=Y.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=lo(mo,n),a=so(n),o=Tn(t,i.triggerRef),s=(0,X.jsx)(jn.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Ao(i.open),...r,ref:o,onClick:Dn(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,X.jsx)(h,{asChild:!0,...a,children:s})});ho.displayName=mo;var go=`PopoverPortal`,[_o,vo]=ao(go,{forceMount:void 0}),yo=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=lo(go,t);return(0,X.jsx)(_o,{scope:t,forceMount:n,children:(0,X.jsx)(En,{present:n||a.open,children:(0,X.jsx)(kn,{asChild:!0,container:i,children:r})})})};yo.displayName=go;var bo=`PopoverContent`,xo=Y.forwardRef((e,t)=>{let n=vo(bo,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=lo(bo,e.__scopePopover);return(0,X.jsx)(En,{present:r||a.open,children:a.modal?(0,X.jsx)(Co,{...i,ref:t}):(0,X.jsx)(wo,{...i,ref:t})})});xo.displayName=bo;var So=Cn(`PopoverContent.RemoveScroll`),Co=Y.forwardRef((e,t)=>{let n=lo(bo,e.__scopePopover),r=Y.useRef(null),i=Tn(t,r),a=Y.useRef(!1);return Y.useEffect(()=>{let e=r.current;if(e)return Zn(e)},[]),(0,X.jsx)(Jn,{as:So,allowPinchZoom:!0,children:(0,X.jsx)(To,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Dn(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Dn(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:Dn(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),wo=Y.forwardRef((e,t)=>{let n=lo(bo,e.__scopePopover),r=Y.useRef(!1),i=Y.useRef(!1);return(0,X.jsx)(To,{...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()}})}),To=Y.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=lo(bo,n),p=so(n);return qn(),(0,X.jsx)(Vn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,X.jsx)(wn,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,X.jsx)(j,{"data-state":Ao(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)`}})})})}),Eo=`PopoverClose`,Do=Y.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=lo(Eo,n);return(0,X.jsx)(jn.button,{type:`button`,...r,ref:t,onClick:Dn(e.onClick,()=>i.onOpenChange(!1))})});Do.displayName=Eo;var Oo=`PopoverArrow`,ko=Y.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=so(n);return(0,X.jsx)(Ne,{...i,...r,ref:t})});ko.displayName=Oo;function Ao(e){return e?`open`:`closed`}var jo=uo,Mo=po,No=ho,Po=yo,Fo=xo,Io=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Lo=[` `,`Enter`],Ro=`Select`,[zo,Bo,Vo]=hr(Ro),[Ho,Uo]=Nn(Ro,[Vo,Ie]),Wo=Ie(),[Go,Ko]=Ho(Ro),[qo,Jo]=Ho(Ro),Yo=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=Wo(t),[g,_]=Y.useState(null),[v,y]=Y.useState(null),[b,x]=Y.useState(!1),S=gr(l),[C,w]=An({prop:r,defaultProp:i??!1,onChange:a,caller:Ro}),[T,E]=An({prop:o,defaultProp:s,onChange:c,caller:Ro}),D=Y.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=Y.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,X.jsx)(je,{...h,children:(0,X.jsxs)(Go,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Fn(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,X.jsx)(zo.Provider,{scope:t,children:(0,X.jsx)(qo,{scope:e.__scopeSelect,onNativeOptionAdd:Y.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:Y.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,X.jsxs)(Ws,{"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,X.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};Yo.displayName=Ro;var Xo=`SelectTrigger`,Zo=Y.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Wo(n),o=Ko(Xo,n),s=o.disabled||r,c=Tn(t,o.onTriggerChange),l=Bo(n),u=Y.useRef(`touch`),[d,f,p]=Ks(e=>{let t=l().filter(e=>!e.disabled),n=qs(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,X.jsx)(h,{asChild:!0,...a,children:(0,X.jsx)(jn.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":Gs(o.value)?``:void 0,...i,ref:c,onClick:Dn(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Dn(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:Dn(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Io.includes(e.key)&&(m(),e.preventDefault())})})})});Zo.displayName=Xo;var Qo=`SelectValue`,$o=Y.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Ko(Qo,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Tn(t,c.onValueNodeChange);return Ln(()=>{l(u)},[l,u]),(0,X.jsx)(jn.span,{...s,ref:d,style:{pointerEvents:`none`},children:Gs(c.value)?(0,X.jsx)(X.Fragment,{children:o}):a})});$o.displayName=Qo;var es=`SelectIcon`,ts=Y.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,X.jsx)(jn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});ts.displayName=es;var ns=`SelectPortal`,rs=e=>(0,X.jsx)(kn,{asChild:!0,...e});rs.displayName=ns;var is=`SelectContent`,as=Y.forwardRef((e,t)=>{let n=Ko(is,e.__scopeSelect),[r,i]=Y.useState();if(Ln(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?no.createPortal((0,X.jsx)(ss,{scope:e.__scopeSelect,children:(0,X.jsx)(zo.Slot,{scope:e.__scopeSelect,children:(0,X.jsx)(`div`,{children:e.children})})}),t):null}return(0,X.jsx)(ds,{...e,ref:t})});as.displayName=is;var os=10,[ss,cs]=Ho(is),ls=`SelectContentImpl`,us=Cn(`SelectContent.RemoveScroll`),ds=Y.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=Ko(is,n),[y,b]=Y.useState(null),[x,S]=Y.useState(null),C=Tn(t,e=>b(e)),[w,T]=Y.useState(null),[E,D]=Y.useState(null),O=Bo(n),[k,A]=Y.useState(!1),j=Y.useRef(!1);Y.useEffect(()=>{if(y)return Zn(y)},[y]),qn();let M=Y.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=Y.useCallback(()=>M([w,y]),[M,w,y]);Y.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Y.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]),Y.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]=Ks(e=>{let t=O().filter(e=>!e.disabled),n=qs(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ee=Y.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]),R=Y.useCallback(()=>y?.focus(),[y]),z=Y.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),te=r===`popper`?hs:ps,B=te===hs?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,X.jsx)(ss,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ee,selectedItem:w,onItemLeave:R,itemTextRefCallback:z,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,X.jsx)(Jn,{as:us,allowPinchZoom:!0,children:(0,X.jsx)(Vn,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Dn(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,X.jsx)(wn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,X.jsx)(te,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...B,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Dn(_.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()}})})})})})})});ds.displayName=ls;var fs=`SelectItemAlignedPosition`,ps=Y.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Ko(is,n),o=cs(is,n),[s,c]=Y.useState(null),[l,u]=Y.useState(null),d=Tn(t,e=>u(e)),f=Bo(n),p=Y.useRef(!1),m=Y.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Y.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-os,d=ro(a,[os,Math.max(os,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-os,d=ro(a,[os,Math.max(os,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-os*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-os,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=`${os}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]);Ln(()=>y(),[y]);let[b,x]=Y.useState();return Ln(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,X.jsx)(gs,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Y.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,X.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,X.jsx)(jn.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});ps.displayName=fs;var ms=`SelectPopperPosition`,hs=Y.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=os,...a}=e,o=Wo(n);return(0,X.jsx)(j,{...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)`}})});hs.displayName=ms;var[gs,_s]=Ho(is,{}),vs=`SelectViewport`,ys=Y.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=cs(vs,n),o=_s(vs,n),s=Tn(t,a.onViewportChange),c=Y.useRef(0);return(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(zo.Slot,{scope:n,children:(0,X.jsx)(jn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Dn(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-os*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})})})]})});ys.displayName=vs;var bs=`SelectGroup`,[xs,Ss]=Ho(bs),Cs=Y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Fn();return(0,X.jsx)(xs,{scope:n,id:i,children:(0,X.jsx)(jn.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Cs.displayName=bs;var ws=`SelectLabel`,Ts=Y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Ss(ws,n);return(0,X.jsx)(jn.div,{id:i.id,...r,ref:t})});Ts.displayName=ws;var Es=`SelectItem`,[Ds,Os]=Ho(Es),ks=Y.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Ko(Es,n),c=cs(Es,n),l=s.value===r,[u,d]=Y.useState(a??``),[f,p]=Y.useState(!1),m=Tn(t,e=>c.itemRefCallback?.(e,r,i)),h=Fn(),g=Y.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,X.jsx)(Ds,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Y.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,X.jsx)(zo.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,X.jsx)(jn.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:Dn(o.onFocus,()=>p(!0)),onBlur:Dn(o.onBlur,()=>p(!1)),onClick:Dn(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Dn(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Dn(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Dn(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Dn(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Dn(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Lo.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});ks.displayName=Es;var As=`SelectItemText`,js=Y.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Ko(As,n),s=cs(As,n),c=Os(As,n),l=Jo(As,n),[u,d]=Y.useState(null),f=Tn(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=Y.useMemo(()=>(0,X.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return Ln(()=>(h(m),()=>g(m)),[h,g,m]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(jn.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?no.createPortal(a.children,o.valueNode):null]})});js.displayName=As;var Ms=`SelectItemIndicator`,Ns=Y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Os(Ms,n).isSelected?(0,X.jsx)(jn.span,{"aria-hidden":!0,...r,ref:t}):null});Ns.displayName=Ms;var Ps=`SelectScrollUpButton`,Fs=Y.forwardRef((e,t)=>{let n=cs(Ps,e.__scopeSelect),r=_s(Ps,e.__scopeSelect),[i,a]=Y.useState(!1),o=Tn(t,r.onScrollButtonChange);return Ln(()=>{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,X.jsx)(Rs,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Fs.displayName=Ps;var Is=`SelectScrollDownButton`,Ls=Y.forwardRef((e,t)=>{let n=cs(Is,e.__scopeSelect),r=_s(Is,e.__scopeSelect),[i,a]=Y.useState(!1),o=Tn(t,r.onScrollButtonChange);return Ln(()=>{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,X.jsx)(Rs,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Ls.displayName=Is;var Rs=Y.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=cs(`SelectScrollButton`,n),o=Y.useRef(null),s=Bo(n),c=Y.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Y.useEffect(()=>()=>c(),[c]),Ln(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,X.jsx)(jn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Dn(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Dn(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Dn(i.onPointerLeave,()=>{c()})})}),zs=`SelectSeparator`,Bs=Y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,X.jsx)(jn.div,{"aria-hidden":!0,...r,ref:t})});Bs.displayName=zs;var Vs=`SelectArrow`,Hs=Y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Wo(n),a=Ko(Vs,n),o=cs(Vs,n);return a.open&&o.position===`popper`?(0,X.jsx)(Ne,{...i,...r,ref:t}):null});Hs.displayName=Vs;var Us=`SelectBubbleInput`,Ws=Y.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Y.useRef(null),a=Tn(r,i),o=Xn(t);return Y.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,X.jsx)(jn.select,{...n,style:{...tn,...n.style},ref:a,defaultValue:t})});Ws.displayName=Us;function Gs(e){return e===``||e===void 0}function Ks(e){let t=Mn(e),n=Y.useRef(``),r=Y.useRef(0),i=Y.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=Y.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Y.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function qs(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=Js(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 Js(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ys=Yo,Xs=Zo,Zs=$o,Qs=ts,$s=rs,ec=as,tc=ys,nc=ks,rc=js,ic=Ns,ac=Fs,oc=Ls,sc=`Switch`,[cc,lc]=Nn(sc),[uc,dc]=cc(sc),fc=Y.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]=Y.useState(null),m=Tn(t,e=>p(e)),h=Y.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=An({prop:i,defaultProp:a??!1,onChange:l,caller:sc});return(0,X.jsxs)(uc,{scope:n,checked:_,disabled:s,children:[(0,X.jsx)(jn.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":_c(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:Dn(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,X.jsx)(gc,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});fc.displayName=sc;var pc=`SwitchThumb`,mc=Y.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=dc(pc,n);return(0,X.jsx)(jn.span,{"data-state":_c(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});mc.displayName=pc;var hc=`SwitchBubbleInput`,gc=Y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=Y.useRef(null),s=Tn(o,a),c=Xn(n),l=Pn(t);return Y.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,X.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}})});gc.displayName=hc;function _c(e){return e?`checked`:`unchecked`}var vc=fc,yc=mc;function bc(e){return e.kind===`doc`?e.docPath:e.folderPath}var xc=zn(`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 Sc(e){let t=(0,J.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,variant:i,asChild:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a!==void 0&&a?On:`span`,c;t[5]!==n||t[6]!==o?(c=Sn(xc({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,X.jsx)(s,{"data-slot":`badge`,"data-variant":o,className:c,...r}),t[8]=s,t[9]=r,t[10]=c,t[11]=o,t[12]=l):l=t[12],l}function Cc(e){let t=(0,J.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,X.jsx)(jo,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function wc(e){let t=(0,J.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,X.jsx)(No,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function Tc(e){let t=(0,J.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=Sn(`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,X.jsx)(Po,{children:(0,X.jsx)(Fo,{"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 Ec(e){let t=(0,J.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,X.jsx)(Mo,{"data-slot":`popover-anchor`,...n}),t[2]=n,t[3]=r),r}var Dc={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.9.1`}?.VITE_APP_VERSION??`0.0.0-unknown`;function Oc(){return I({kind:`web`,runtimeVersion:Dc})}function kc(){return H({kind:`web`,runtimeVersion:Dc})}function Ac(e,t){return t}function jc(e){let t=e.split(`/`);return t.length<2?`ok`:`${t[0]}/${t[1]}`}function Mc(e){if(!e)return;let t=Object.entries(e);if(t.length!==0)return t.map(([e,t])=>{if(t==null)return[e,String(t)];if(typeof t==`string`)return[e,t];if(typeof t==`number`||typeof t==`boolean`)return[e,String(t)];try{return[e,JSON.stringify(t)]}catch{return[e,`[unserializable]`]}})}function Nc(e,t,n){if(typeof performance>`u`||!performance.measure)return;let r=jc(e),i=Mc(t),a={devtools:{dataType:`track-entry`,track:r,...i?{properties:i}:{},...n?.tooltipText?{tooltipText:n.tooltipText}:{}}},o=performance.now(),s=n?.startTime??o,c=n?.duration??Math.max(0,o-s);try{performance.measure(e,{start:s,duration:c,detail:a})}catch{}({...t?{properties:t}:{}})}function Pc(e,t){}function Fc(e,t,n){Nc(e,{...t,durationMs:n},{duration:n})}var Z=Object.assign(Nc,{count:Pc,histogram:Fc});function Ic(e){let t=(0,J.c)(3),{name:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(Y.Profiler,{id:n,onRender:Lc,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var Lc=(e,t,n,r,i,a)=>{Z(`ok/render/${e}`,{phase:t,actualDuration:Math.round(n*1e3)/1e3,baseDuration:Math.round(r*1e3)/1e3},{startTime:i,duration:Math.max(0,a-i)})},{getOwnPropertyNames:Rc,getOwnPropertySymbols:zc}=Object,{hasOwnProperty:Bc}=Object.prototype;function Vc(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Hc(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function Uc(e){return e?.[Symbol.toStringTag]}function Wc(e){return Rc(e).concat(zc(e))}var Gc=Object.hasOwn||((e,t)=>Bc.call(e,t));function Kc(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var qc=`__v`,Jc=`__o`,Yc=`_owner`,{getOwnPropertyDescriptor:Xc,keys:Zc}=Object;function Qc(e,t){return e.byteLength===t.byteLength&&dl(new Uint8Array(e),new Uint8Array(t))}function $c(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function el(e,t){return e.byteLength===t.byteLength&&dl(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function tl(e,t){return Kc(e.getTime(),t.getTime())}function nl(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function rl(e,t){return e===t}function il(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var al=Kc;function ol(e,t,n){let r=Zc(e),i=r.length;if(Zc(t).length!==i)return!1;for(;i-- >0;)if(!pl(e,t,n,r[i]))return!1;return!0}function sl(e,t,n){let r=Wc(e),i=r.length;if(Wc(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!pl(e,t,n,a)||(o=Xc(e,a),s=Xc(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function cl(e,t){return Kc(e.valueOf(),t.valueOf())}function ll(e,t){return e.source===t.source&&e.flags===t.flags}function ul(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function dl(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function fl(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function pl(e,t,n,r){return(r===Yc||r===Jc||r===qc)&&(e.$$typeof||t.$$typeof)?!0:Gc(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var ml=`[object ArrayBuffer]`,hl=`[object Arguments]`,gl=`[object Boolean]`,_l=`[object DataView]`,vl=`[object Date]`,yl=`[object Error]`,bl=`[object Map]`,xl=`[object Number]`,Sl=`[object Object]`,Cl=`[object RegExp]`,wl=`[object Set]`,Tl=`[object String]`,El={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},Dl=`[object URL]`,Ol=Object.prototype.toString;function kl({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=Ol.call(h);if(b===vl)return r(h,g,_);if(b===Cl)return u(h,g,_);if(b===bl)return o(h,g,_);if(b===wl)return d(h,g,_);if(b===Sl)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===Dl)return p(h,g,_);if(b===yl)return i(h,g,_);if(b===hl)return c(h,g,_);if(El[b])return f(h,g,_);if(b===ml)return e(h,g,_);if(b===_l)return n(h,g,_);if(b===gl||b===xl||b===Tl)return l(h,g,_);if(m){let e=m[b];if(!e){let t=Uc(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function Al({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Qc,areArraysEqual:n?sl:$c,areDataViewsEqual:el,areDatesEqual:tl,areErrorsEqual:nl,areFunctionsEqual:rl,areMapsEqual:n?Vc(il,sl):il,areNumbersEqual:al,areObjectsEqual:n?sl:ol,arePrimitiveWrappersEqual:cl,areRegExpsEqual:ll,areSetsEqual:n?Vc(ul,sl):ul,areTypedArraysEqual:n?Vc(dl,sl):dl,areUrlsEqual:fl,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Hc(r.areArraysEqual),t=Hc(r.areMapsEqual),n=Hc(r.areObjectsEqual),i=Hc(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function jl(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function Ml({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var Nl=Pl();Pl({strict:!0}),Pl({circular:!0}),Pl({circular:!0,strict:!0}),Pl({createInternalComparator:()=>Kc}),Pl({strict:!0,createInternalComparator:()=>Kc}),Pl({circular:!0,createInternalComparator:()=>Kc}),Pl({circular:!0,createInternalComparator:()=>Kc,strict:!0});function Pl(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=kl(Al(e));return Ml({circular:t,comparator:a,createState:r,equals:n?n(a):jl(a),strict:i})}var Fl=t((e=>{var t=r(),n=to();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Il=t(((e,t)=>{t.exports=Fl()})),Ll=to(),Rl=Il(),zl=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},Bl=({contentComponent:e})=>{let t=(0,Ll.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,X.jsx)(X.Fragment,{children:Object.values(t)})};function Vl(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:no.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var Hl=class extends Y.Component{constructor(e){super(e),this.editorContentRef=Y.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Vl(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:zl(t,this.editorContentRef),...n}),e?.contentComponent&&(0,X.jsx)(Bl,{contentComponent:e.contentComponent})]})}},Ul=(0,Y.forwardRef)((e,t)=>{let n=Y.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return Y.createElement(Hl,{key:n,innerRef:t,...e})}),Wl=Y.memo(Ul),Gl=typeof window<`u`?Y.useLayoutEffect:Y.useEffect,Kl=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function ql(e){let[t]=(0,Y.useState)(()=>new Kl(e.editor)),n=(0,Rl.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??Nl);return Gl(()=>t.watch(e.editor),[e.editor,t]),(0,Y.useDebugValue)(n),n}typeof window>`u`||typeof window<`u`&&window.next;var Jl=(0,Y.createContext)({editor:null});Jl.Consumer;var Yl=()=>(0,Y.useContext)(Jl),Xl=(0,Y.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Zl=()=>(0,Y.useContext)(Xl);function Ql({as:e=`div`,...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=Zl();return(0,X.jsx)(e,{...t,ref:n,"data-node-view-content":``,style:{whiteSpace:`pre-wrap`,...t.style},children:r})}var $l=Y.forwardRef((e,t)=>{let{onDragStart:n}=Zl();return(0,X.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function eu(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function tu(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.forward_ref)`||e.$$typeof.description===`react.forward_ref`))}function nu(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.memo)`||e.$$typeof.description===`react.memo`))}function ru(e){if(eu(e)||tu(e))return!0;if(nu(e)){let t=e.type;if(t)return eu(t)||tu(t)}return!1}function iu(){try{if(Y.version)return parseInt(Y.version.split(`.`)[0],10)>=19}catch{}return!1}var au=class{constructor(e,{editor:t,props:n={},as:r=`div`,className:i=``}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add(`react-renderer`),i&&this.element.classList.add(...i.split(` `)),this.editor.isEditorContentInitialized?(0,no.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=iu(),a=ru(t),o={...n};o.ref&&!(i||a)&&delete o.ref,!o.ref&&(i||a)&&(o.ref=e=>{this.ref=e}),this.reactElement=(0,X.jsx)(t,{...o}),(e=r?.contentComponent)==null||e.setRenderer(this.id,this)}updateProps(e={}){this.destroyed||(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0,(e=this.editor?.contentComponent)==null||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};Y.createContext({markViewContentRef:()=>{}});var ou=class extends at{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.positionCheckCallback=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?`span`:`div`),this.contentDOMElement.dataset.nodeViewContentReact=``,this.contentDOMElement.dataset.nodeViewWrapper=``,this.contentDOMElement.style.whiteSpace=`inherit`;let e=this.dom.querySelector(`[data-node-view-content]`);if(!e)return;e.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,Y.createRef)()};if(!this.component.displayName){let e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute(`data-node-view-wrapper`)&&e.removeAttribute(`data-node-view-wrapper`),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,Y.memo)(e=>(0,X.jsx)(Xl.Provider,{value:t,children:(0,Y.createElement)(n,e)}));r.displayName=`ReactNodeView`;let i=this.node.isInline?`span`:`div`;this.options.as&&(i=this.options.as);let{className:a=``}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new au(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on(`selectionUpdate`,this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos(),this.positionCheckCallback=()=>{let e=this.getPos();typeof e!=`number`||e===this.currentPos||(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs==`function`&&this.updateElementAttributes())},Oe(this.editor,this.positionCheckCallback)}get dom(){if(this.renderer.element.firstElementChild&&!this.renderer.element.firstElementChild?.hasAttribute(`data-node-view-wrapper`))throw Error(`Please use the NodeViewWrapper component for your node view.`);return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;let{from:e,to:t}=this.editor.state.selection,n=this.currentPos;if(typeof n==`number`)if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(e,t,n){let r=e=>{this.renderer.updateProps(e),typeof this.options.attrs==`function`&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update==`function`){let i=this.node,a=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:a,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}let i=this.getPos();return e===this.node&&this.decorations===t&&this.innerDecorations===n?i===this.currentPos?!0:(this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage,getPos:()=>this.getPos()}),!0):(this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage}),!0)}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add(`ProseMirror-selectednode`)}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove(`ProseMirror-selectednode`)}destroy(){this.renderer.destroy(),this.editor.off(`selectionUpdate`,this.handleSelectionUpdate),this.positionCheckCallback&&=(dt(this.editor,this.positionCheckCallback),null),this.contentDOMElement=null,this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null)}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs==`function`){let t=this.editor.extensionManager.attributes,n=gt(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function su(e,t){return n=>n.editor.contentComponent?new ou(e,n,t):{}}var cu=(0,Y.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});cu.displayName=`TiptapContext`;var lu=()=>(0,Y.useContext)(cu);function uu({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,Y.useMemo)(()=>({editor:r}),[r]),a=(0,Y.useMemo)(()=>({editor:r}),[r]);return(0,X.jsx)(Jl.Provider,{value:a,children:(0,X.jsx)(cu.Provider,{value:i,children:n})})}uu.displayName=`Tiptap`;function du({...e}){let{editor:t}=lu();return(0,X.jsx)(Wl,{editor:t,...e})}du.displayName=`Tiptap.Content`,Object.assign(uu,{Content:du});var fu=()=>new Map,pu=e=>{let t=fu();return e.forEach((e,n)=>{t.set(n,e)}),t},mu=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},hu=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},gu=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},_u=()=>new Set,vu=e=>e[e.length-1],yu=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},bu=Array.from,xu=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Su=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Cu=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},wu=Array.isArray,Tu=class{constructor(){this._observers=fu()}on(e,t){return mu(this._observers,e,_u).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return bu((this._observers.get(e)||fu()).values()).forEach(e=>e(...t))}destroy(){this._observers=fu()}},Eu=class{constructor(){this._observers=fu()}on(e,t){mu(this._observers,e,_u).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return bu((this._observers.get(e)||fu()).values()).forEach(e=>e(...t))}destroy(){this._observers=fu()}},Du=Math.floor,Ou=Math.abs,ku=(e,t)=>e<t?e:t,Au=(e,t)=>e>t?e:t;Number.isNaN;var ju=e=>e===0?1/e<0:e<0,Mu=1<<17,Nu=1<<18,Pu=1<<19,Fu=1<<20,Iu=1<<21,Lu=1<<22,Ru=1<<23,zu=1<<24,Bu=1<<25,Vu=1<<26,Hu=1<<27,Uu=1<<28,Wu=1<<29;Mu-1,Nu-1,Pu-1,Fu-1,Iu-1,Lu-1,Ru-1,zu-1,Bu-1,Vu-1,Hu-1,Uu-1,Wu-1;var Gu=2**53-1,Ku=-(2**53-1),qu=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&Du(e)===e);Number.isNaN,Number.parseInt;var Ju=String.fromCharCode;String.fromCodePoint,Ju(65535);var Yu=e=>e.toLowerCase(),Xu=/^\s*/g,Zu=e=>e.replace(Xu,``),Qu=/([A-Z])/g,$u=(e,t)=>Zu(e.replace(Qu,e=>`${t}${Yu(e)}`)),ed=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},td=typeof TextEncoder<`u`?new TextEncoder:null,nd=td?e=>td.encode(e):ed,rd=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});rd&&rd.decode(new Uint8Array).length===1&&(rd=null);var id=(e,t)=>Cu(t,()=>e).join(``),ad=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},od=()=>new ad,sd=e=>{let t=od();return e(t),ld(t)},cd=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},ld=e=>{let t=new Uint8Array(cd(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},ud=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(Au(n,t)*2),e.cpos=0)},dd=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},fd=dd,pd=(e,t)=>{for(;t>127;)dd(e,128|127&t),t=Du(t/128);dd(e,127&t)},md=(e,t)=>{let n=ju(t);for(n&&(t=-t),dd(e,(t>63?128:0)|(n?64:0)|63&t),t=Du(t/64);t>0;)dd(e,(t>127?128:0)|127&t),t=Du(t/128)},hd=new Uint8Array(3e4),gd=hd.length/3,_d=td&&td.encodeInto?(e,t)=>{if(t.length<gd){let n=td.encodeInto(t,hd).written||0;pd(e,n);for(let t=0;t<n;t++)dd(e,hd[t])}else yd(e,nd(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;pd(e,r);for(let t=0;t<r;t++)dd(e,n.codePointAt(t))},vd=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=ku(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Au(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},yd=(e,t)=>{pd(e,t.byteLength),vd(e,t)},bd=(e,t)=>{ud(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},xd=(e,t)=>bd(e,4).setFloat32(0,t,!1),Sd=(e,t)=>bd(e,8).setFloat64(0,t,!1),Cd=(e,t)=>bd(e,8).setBigInt64(0,t,!1),wd=new DataView(new ArrayBuffer(4)),Td=e=>(wd.setFloat32(0,e),wd.getFloat32(0)===e),Ed=(e,t)=>{switch(typeof t){case`string`:dd(e,119),_d(e,t);break;case`number`:qu(t)&&Ou(t)<=2147483647?(dd(e,125),md(e,t)):Td(t)?(dd(e,124),xd(e,t)):(dd(e,123),Sd(e,t));break;case`bigint`:dd(e,122),Cd(e,t);break;case`object`:if(t===null)dd(e,126);else if(wu(t)){dd(e,117),pd(e,t.length);for(let n=0;n<t.length;n++)Ed(e,t[n])}else if(t instanceof Uint8Array)dd(e,116),yd(e,t);else{dd(e,118);let n=Object.keys(t);pd(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];_d(e,i),Ed(e,t[i])}}break;case`boolean`:dd(e,t?120:121);break;default:dd(e,127)}},Dd=class extends ad{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&pd(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Od=e=>{e.count>0&&(md(e.encoder,e.count===1?e.s:-e.s),e.count>1&&pd(e.encoder,e.count-2))},kd=class{constructor(){this.encoder=new ad,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Od(this),this.count=1,this.s=e)}toUint8Array(){return Od(this),ld(this.encoder)}},Ad=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);md(e.encoder,t),e.count>1&&pd(e.encoder,e.count-2)}},jd=class{constructor(){this.encoder=new ad,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ad(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ad(this),ld(this.encoder)}},Md=class{constructor(){this.sarr=[],this.s=``,this.lensE=new kd}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new ad;return this.sarr.push(this.s),this.s=``,_d(e,this.sarr.join(``)),vd(e,this.lensE.toUint8Array()),ld(e)}},Nd=e=>Error(e),Pd=()=>{throw Nd(`Method unimplemented`)},Fd=()=>{throw Nd(`Unexpected case`)},Id=Nd(`Unexpected end of array`),Ld=Nd(`Integer out of Range`),Rd=class{constructor(e){this.arr=e,this.pos=0}},zd=e=>new Rd(e),Bd=e=>e.pos!==e.arr.length,Vd=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Hd=e=>Vd(e,Wd(e)),Ud=e=>e.arr[e.pos++],Wd=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Gu)throw Ld}throw Id},Gd=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Gu)throw Ld}throw Id},Kd=rd?e=>rd.decode(Hd(e)):e=>{let t=Wd(e);if(t===0)return``;{let n=String.fromCodePoint(Ud(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Ud(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},qd=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Jd=[e=>void 0,e=>null,Gd,e=>qd(e,4).getFloat32(0,!1),e=>qd(e,8).getFloat64(0,!1),e=>qd(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Kd,e=>{let t=Wd(e),n={};for(let r=0;r<t;r++){let t=Kd(e);n[t]=Yd(e)}return n},e=>{let t=Wd(e),n=[];for(let r=0;r<t;r++)n.push(Yd(e));return n},Hd],Yd=e=>Jd[127-Ud(e)](e),Xd=class extends Rd{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Bd(this)?this.count=Wd(this)+1:this.count=-1),this.count--,this.s}},Zd=class extends Rd{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Gd(this);let e=ju(this.s);this.count=1,e&&(this.s=-this.s,this.count=Wd(this)+2)}return this.count--,this.s}},Qd=class extends Rd{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Gd(this),t=e&1;this.diff=Du(e/2),this.count=1,t&&(this.count=Wd(this)+2)}return this.s+=this.diff,this.count--,this.s}},$d=class{constructor(e){this.decoder=new Zd(e),this.str=Kd(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var ef=crypto.getRandomValues.bind(crypto),tf=Math.random,nf=()=>ef(new Uint32Array(1))[0],rf=e=>e[Du(tf()*e.length)],af=`10000000-1000-4000-8000-100000000000`,of=()=>af.replace(/[018]/g,e=>(e^nf()&15>>e/4).toString(16)),sf=Date.now,cf=e=>new Promise(e);Promise.all.bind(Promise);var lf=e=>e===void 0?null:e,uf=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(uf=localStorage)}catch{}var df=uf,ff=Symbol(`Equality`),pf=(e,t)=>e===t||!!e?.[ff]?.(t)||!1,mf=e=>typeof e==`object`,hf=Object.assign,gf=Object.keys,_f=(e,t)=>{for(let n in e)t(e[n],n)},vf=e=>gf(e).length,yf=e=>{for(let t in e)return!1;return!0},bf=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},xf=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Sf=(e,t)=>e===t||vf(e)===vf(t)&&bf(e,(e,n)=>(e!==void 0||xf(t,n))&&pf(t[n],e)),Cf=Object.freeze,wf=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&wf(e[t])}return Cf(e)},Tf=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Tf(e,t,n+1)}},Ef=e=>e,Df=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[ff]!=null)return e[ff](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Df(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(vf(e)!==vf(t))return!1;for(let n in e)if(!xf(e,n)||!Df(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Df(e[n],t[n]))return!1;break;default:return!1}return!0},Of=(e,t)=>t.includes(e),kf=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Af=typeof window<`u`&&typeof document<`u`&&!kf;typeof navigator<`u`&&/Mac/.test(navigator.platform);var jf,Mf=[],Nf=()=>{if(jf===void 0)if(kf){jf=fu();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&jf.set(t,``),t=r):t===null?Mf.push(r):(jf.set(t,r),t=null)}t!==null&&jf.set(t,``)}else typeof location==`object`?(jf=fu(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);jf.set(`--${$u(t,`-`)}`,n),jf.set(`-${$u(t,`-`)}`,n)}})):jf=fu();return jf},Pf=e=>Nf().has(e),Ff=e=>lf(kf?{}[e.toUpperCase().replaceAll(`-`,`_`)]:df.getItem(e)),If=e=>Pf(`--`+e)||Ff(e)!==null,Lf=If(`production`),Rf=kf&&Of({}.FORCE_COLOR,[`true`,`1`,`2`])||!Pf(`--no-colors`)&&!If(`no-color`)&&(!kf||process.stdout.isTTY)&&(!kf||Pf(`--color`)||Ff(`COLORTERM`)!==null||(Ff(`TERM`)||``).includes(`color`)),zf=e=>new Uint8Array(e),Bf=Af?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Ju(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Vf=e=>{let t=zf(e.byteLength);return t.set(e),t},Hf=e=>sd(t=>Ed(t,e)),Uf=class{constructor(e,t){this.left=e,this.right=t}},Wf=(e,t)=>new Uf(e,t),Gf=(e,t)=>e.forEach(e=>t(e.left,e.right)),Kf=e=>e.next()>=.5,qf=(e,t,n)=>Du(e.next()*(n+1-t)+t),Jf=(e,t,n)=>Du(e.next()*(n+1-t)+t),Yf=(e,t,n)=>Jf(e,t,n),Xf=e=>Ju(Yf(e,97,122)),Zf=(e,t=0,n=20)=>{let r=Yf(e,t,n),i=``;for(let t=0;t<r;t++)i+=Xf(e);return i},Qf=(e,t)=>t[Yf(e,0,t.length-1)],$f=Symbol(`0schema`),ep=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(id(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
2
|
+
import{o as e,t}from"./chunk-CFjPhJqf.js";import{t as n}from"./preload-helper-2ej06EnG.js";import{a as r,i,o as a,r as o,t as s}from"./compiler-runtime-Cs91PcD2.js";import{$ as c,$i as l,$n as u,$r as d,$t as f,Ai as p,Ar as m,B as h,Bi as g,Br as _,Ci as v,Cn as y,Cr as b,Ct as x,Di as S,Dr as C,E as w,Ei as T,En as E,Fi as D,Fn as O,Fr as k,Gr as A,H as j,Hr as M,Ht as N,I as P,Ii as F,In as I,Ir as L,It as ee,J as R,Ji as z,Jn as te,Jr as B,Kn as ne,Kt as V,L as re,Li as ie,Ln as H,Lr as ae,M as oe,Mi as U,Mr as se,N as ce,Ni as W,Nn as le,Nr as ue,Nt as de,O as fe,Oi as pe,Or as me,P as he,Pi as ge,Pn as _e,Pr as ve,Pt as ye,Q as be,Qi as xe,Qn as Se,Qt as Ce,Ri as we,Rn as Te,Rr as Ee,St as De,Ti as Oe,Tr as ke,Tt as Ae,U as je,Ut as Me,V as Ne,Vi as Pe,Vt as Fe,W as Ie,Wt as Le,Xi as G,Xr as Re,Xt as ze,Y as Be,Yi as Ve,Zi as He,Zn as Ue,Zr as We,Zt as Ge,_n as Ke,_r as qe,_t as Je,a as Ye,ai as Xe,b as Ze,bi as Qe,bn as $e,br as et,bt as tt,c as nt,cn as rt,cr as it,di as at,dr as ot,dt as st,en as ct,et as lt,f as ut,fi as dt,fr as ft,ft as pt,gi as mt,gr as ht,hi as gt,hr as _t,ht as vt,i as yt,ii as bt,in as xt,ir as St,ji as Ct,jn as wt,jr as Tt,k as Et,li as Dt,ln as Ot,m as kt,mi as At,mn as jt,mr as Mt,mt as Nt,nr as Pt,oi as Ft,on as It,or as Lt,ot as Rt,p as zt,pi as Bt,pr as Vt,pt as Ht,q as Ut,qi as Wt,qn as Gt,qr as Kt,qt,r as Jt,si as Yt,sn as Xt,sr as Zt,ta as Qt,tn as $t,tr as en,tt as tn,u as nn,ui as rn,ur as an,ut as on,vn as sn,vr as cn,vt as ln,wi as un,wn as dn,xn as fn,y as pn,yi as mn,yn as hn,yr as gn,yt as _n,z as vn,zi as yn,zr as bn,zt as xn}from"./prop-types-D0BPBtJk.js";import{C as K,S as Sn,_ as Cn,a as wn,b as Tn,c as En,d as Dn,g as On,i as kn,l as An,m as jn,o as Mn,p as Nn,r as Pn,s as Fn,t as In,u as Ln,w as Rn,x as zn,y as Bn}from"./button-DenIdY-r.js";import{_ as Vn,a as Hn,b as Un,c as Wn,d as Gn,f as Kn,g as qn,h as Jn,i as Yn,l as Xn,m as Zn,n as Qn,o as $n,p as er,r as tr,s as nr,t as rr,u as ir,x as ar,y as or}from"./dialog-B1es0EvU.js";import{a as sr,i as cr,n as lr,r as ur,t as dr}from"./collapsible-BhpeB6tu.js";import{t as fr}from"./trace-api-CiCjX4Sz.js";import{n as pr,t as mr}from"./propagation-api-3kmMXRwS.js";import{n as hr,t as gr}from"./dist-DicqJavT.js";import{A as _r,At as vr,B as yr,Bt as br,C as xr,Ct as Sr,D as Cr,Dt as wr,E as Tr,Et as Er,F as Dr,Ft as Or,G as kr,H as Ar,Ht as jr,It as Mr,J as Nr,K as Pr,L as Fr,Lt as Ir,M as Lr,Mt as Rr,N as zr,O as Br,Ot as Vr,P as Hr,Pt as Ur,Q as Wr,R as q,S as Gr,St as Kr,T as qr,Tt as Jr,U as Yr,V as Xr,Vt as Zr,W as Qr,X as $r,Y as ei,a as ti,b as ni,c as ri,d as ii,dt as ai,f as oi,g as si,i as ci,j as li,l as ui,m as di,n as fi,o as pi,p as mi,q as hi,r as gi,s as _i,t as vi,u as yi,ut as bi,v as xi,x as Si,xt as Ci}from"./dist-Du-s1q8P.js";import{i as wi,n as Ti,r as Ei,t as Di}from"./dist-BYGzJeLM.js";import{a as Oi,c as ki,s as Ai,t as ji}from"./dist-BrsSsfiw.js";import{n as Mi}from"./dist-DsbVHLNy.js";import{n as Ni}from"./dist-Cq1LYbUj.js";import{t as Pi}from"./stex-CzCFWeB9.js";(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 Fi=K(`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`}]]),Ii=K(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Li=K(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Ri=K(`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`}]]),zi=K(`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`}]]),Bi=K(`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`}]]),Vi=K(`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`}]]),Hi=K(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Ui=K(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Wi=K(`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`}]]),Gi=K(`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`}]]),Ki=K(`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`}]]),qi=K(`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`}]]),Ji=K(`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`}]]),Yi=K(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Xi=K(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Zi=K(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Qi=K(`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`}]]),$i=K(`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`}]]),ea=K(`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`}]]),ta=K(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),na=K(`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`}]]),ra=K(`file-text`,[[`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:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),ia=K(`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`}]]),aa=K(`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`}]]),oa=K(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),sa=K(`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`}]]),ca=K(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),la=K(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),ua=K(`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`}]]),da=K(`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`}]]),fa=K(`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`}]]),pa=K(`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`}]]),ma=K(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),ha=K(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),ga=K(`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`}]]),_a=K(`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`}]]),va=K(`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`}]]),ya=K(`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`}]]),ba=[[`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`}]],xa=K(`link-2`,ba),Sa=K(`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`}]]),Ca=K(`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`}]]),wa=K(`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`}]]),Ta=K(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Ea=K(`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`}]]),Da=K(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Oa=K(`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`}]]),ka=K(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Aa=K(`panel-top`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),ja=K(`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`}]]),Ma=K(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Na=K(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Pa=K(`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`}]]),Fa=K(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Ia=K(`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`}]]),La=K(`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`}]]),Ra=K(`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`}]]),za=K(`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`}]]),Ba=K(`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`}]]),Va=K(`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`}]]),Ha=K(`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`}]]),Ua=K(`text-align-center`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]]),Wa=K(`text-align-end`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]]),Ga=K(`text-align-start`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]]),Ka=K(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),qa=K(`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`}]]),Ja=K(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),Ya=K(`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`}]]),Xa=K(`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`}]]),Za=K(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),Qa=K(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),J=s(),Y=e(r(),1);function $a(e,t){let n=(0,J.c)(7),r,i;n[0]!==e||n[1]!==t?(r=()=>{if(t!==`light`&&t!==`dark`&&t!==`system`||!e)return;let n=!1;return e.setThemeSource(t).catch(e=>{console.warn(JSON.stringify({event:`theme-source-set-failed`,themeValue:t,error:e instanceof Error?e.message:String(e)}))}).finally(()=>{if(n)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`).matches;e.signalThemeApplied({reducedTransparency:t})}),()=>{n=!0}},i=[e,t],n[0]=e,n[1]=t,n[2]=r,n[3]=i):(r=n[2],i=n[3]),(0,Y.useEffect)(r,i);let a,o;n[4]===e?(a=n[5],o=n[6]):(a=()=>{if(!e)return;let t=window.matchMedia(`(prefers-reduced-transparency: reduce)`),n=t=>{e.signalThemeApplied({reducedTransparency:t.matches})};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},o=[e],n[4]=e,n[5]=a,n[6]=o),(0,Y.useEffect)(a,o)}var eo=t((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),to=t(((e,t)=>{t.exports=eo()})),X=a(),no=e(Rn(),1);function ro(e,[t,n]){return Math.min(n,Math.max(t,e))}var io=`Popover`,[ao,oo]=Nn(io,[Ie]),so=Ie(),[co,lo]=ao(io),uo=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=so(t),c=Y.useRef(null),[l,u]=Y.useState(!1),[d,f]=An({prop:r,defaultProp:i??!1,onChange:a,caller:io});return(0,X.jsx)(je,{...s,children:(0,X.jsx)(co,{scope:t,contentId:Fn(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:Y.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:Y.useCallback(()=>u(!0),[]),onCustomAnchorRemove:Y.useCallback(()=>u(!1),[]),modal:o,children:n})})};uo.displayName=io;var fo=`PopoverAnchor`,po=Y.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=lo(fo,n),a=so(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return Y.useEffect(()=>(o(),()=>s()),[o,s]),(0,X.jsx)(h,{...a,...r,ref:t})});po.displayName=fo;var mo=`PopoverTrigger`,ho=Y.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=lo(mo,n),a=so(n),o=Tn(t,i.triggerRef),s=(0,X.jsx)(jn.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Ao(i.open),...r,ref:o,onClick:Dn(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,X.jsx)(h,{asChild:!0,...a,children:s})});ho.displayName=mo;var go=`PopoverPortal`,[_o,vo]=ao(go,{forceMount:void 0}),yo=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=lo(go,t);return(0,X.jsx)(_o,{scope:t,forceMount:n,children:(0,X.jsx)(En,{present:n||a.open,children:(0,X.jsx)(kn,{asChild:!0,container:i,children:r})})})};yo.displayName=go;var bo=`PopoverContent`,xo=Y.forwardRef((e,t)=>{let n=vo(bo,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=lo(bo,e.__scopePopover);return(0,X.jsx)(En,{present:r||a.open,children:a.modal?(0,X.jsx)(Co,{...i,ref:t}):(0,X.jsx)(wo,{...i,ref:t})})});xo.displayName=bo;var So=Cn(`PopoverContent.RemoveScroll`),Co=Y.forwardRef((e,t)=>{let n=lo(bo,e.__scopePopover),r=Y.useRef(null),i=Tn(t,r),a=Y.useRef(!1);return Y.useEffect(()=>{let e=r.current;if(e)return Zn(e)},[]),(0,X.jsx)(Jn,{as:So,allowPinchZoom:!0,children:(0,X.jsx)(To,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Dn(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Dn(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:Dn(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),wo=Y.forwardRef((e,t)=>{let n=lo(bo,e.__scopePopover),r=Y.useRef(!1),i=Y.useRef(!1);return(0,X.jsx)(To,{...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()}})}),To=Y.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=lo(bo,n),p=so(n);return qn(),(0,X.jsx)(Vn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,X.jsx)(wn,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,X.jsx)(j,{"data-state":Ao(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)`}})})})}),Eo=`PopoverClose`,Do=Y.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=lo(Eo,n);return(0,X.jsx)(jn.button,{type:`button`,...r,ref:t,onClick:Dn(e.onClick,()=>i.onOpenChange(!1))})});Do.displayName=Eo;var Oo=`PopoverArrow`,ko=Y.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=so(n);return(0,X.jsx)(Ne,{...i,...r,ref:t})});ko.displayName=Oo;function Ao(e){return e?`open`:`closed`}var jo=uo,Mo=po,No=ho,Po=yo,Fo=xo,Io=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Lo=[` `,`Enter`],Ro=`Select`,[zo,Bo,Vo]=hr(Ro),[Ho,Uo]=Nn(Ro,[Vo,Ie]),Wo=Ie(),[Go,Ko]=Ho(Ro),[qo,Jo]=Ho(Ro),Yo=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=Wo(t),[g,_]=Y.useState(null),[v,y]=Y.useState(null),[b,x]=Y.useState(!1),S=gr(l),[C,w]=An({prop:r,defaultProp:i??!1,onChange:a,caller:Ro}),[T,E]=An({prop:o,defaultProp:s,onChange:c,caller:Ro}),D=Y.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=Y.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,X.jsx)(je,{...h,children:(0,X.jsxs)(Go,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Fn(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,X.jsx)(zo.Provider,{scope:t,children:(0,X.jsx)(qo,{scope:e.__scopeSelect,onNativeOptionAdd:Y.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:Y.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,X.jsxs)(Ws,{"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,X.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};Yo.displayName=Ro;var Xo=`SelectTrigger`,Zo=Y.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Wo(n),o=Ko(Xo,n),s=o.disabled||r,c=Tn(t,o.onTriggerChange),l=Bo(n),u=Y.useRef(`touch`),[d,f,p]=Ks(e=>{let t=l().filter(e=>!e.disabled),n=qs(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,X.jsx)(h,{asChild:!0,...a,children:(0,X.jsx)(jn.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":Gs(o.value)?``:void 0,...i,ref:c,onClick:Dn(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Dn(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:Dn(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Io.includes(e.key)&&(m(),e.preventDefault())})})})});Zo.displayName=Xo;var Qo=`SelectValue`,$o=Y.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Ko(Qo,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Tn(t,c.onValueNodeChange);return Ln(()=>{l(u)},[l,u]),(0,X.jsx)(jn.span,{...s,ref:d,style:{pointerEvents:`none`},children:Gs(c.value)?(0,X.jsx)(X.Fragment,{children:o}):a})});$o.displayName=Qo;var es=`SelectIcon`,ts=Y.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,X.jsx)(jn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});ts.displayName=es;var ns=`SelectPortal`,rs=e=>(0,X.jsx)(kn,{asChild:!0,...e});rs.displayName=ns;var is=`SelectContent`,as=Y.forwardRef((e,t)=>{let n=Ko(is,e.__scopeSelect),[r,i]=Y.useState();if(Ln(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?no.createPortal((0,X.jsx)(ss,{scope:e.__scopeSelect,children:(0,X.jsx)(zo.Slot,{scope:e.__scopeSelect,children:(0,X.jsx)(`div`,{children:e.children})})}),t):null}return(0,X.jsx)(ds,{...e,ref:t})});as.displayName=is;var os=10,[ss,cs]=Ho(is),ls=`SelectContentImpl`,us=Cn(`SelectContent.RemoveScroll`),ds=Y.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=Ko(is,n),[y,b]=Y.useState(null),[x,S]=Y.useState(null),C=Tn(t,e=>b(e)),[w,T]=Y.useState(null),[E,D]=Y.useState(null),O=Bo(n),[k,A]=Y.useState(!1),j=Y.useRef(!1);Y.useEffect(()=>{if(y)return Zn(y)},[y]),qn();let M=Y.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=Y.useCallback(()=>M([w,y]),[M,w,y]);Y.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;Y.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]),Y.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]=Ks(e=>{let t=O().filter(e=>!e.disabled),n=qs(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ee=Y.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]),R=Y.useCallback(()=>y?.focus(),[y]),z=Y.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),te=r===`popper`?hs:ps,B=te===hs?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,X.jsx)(ss,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ee,selectedItem:w,onItemLeave:R,itemTextRefCallback:z,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:I,children:(0,X.jsx)(Jn,{as:us,allowPinchZoom:!0,children:(0,X.jsx)(Vn,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Dn(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,X.jsx)(wn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,X.jsx)(te,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...B,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Dn(_.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()}})})})})})})});ds.displayName=ls;var fs=`SelectItemAlignedPosition`,ps=Y.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Ko(is,n),o=cs(is,n),[s,c]=Y.useState(null),[l,u]=Y.useState(null),d=Tn(t,e=>u(e)),f=Bo(n),p=Y.useRef(!1),m=Y.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Y.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-os,d=ro(a,[os,Math.max(os,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-os,d=ro(a,[os,Math.max(os,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-os*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-os,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=`${os}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]);Ln(()=>y(),[y]);let[b,x]=Y.useState();return Ln(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,X.jsx)(gs,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Y.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,X.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,X.jsx)(jn.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});ps.displayName=fs;var ms=`SelectPopperPosition`,hs=Y.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=os,...a}=e,o=Wo(n);return(0,X.jsx)(j,{...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)`}})});hs.displayName=ms;var[gs,_s]=Ho(is,{}),vs=`SelectViewport`,ys=Y.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=cs(vs,n),o=_s(vs,n),s=Tn(t,a.onViewportChange),c=Y.useRef(0);return(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(zo.Slot,{scope:n,children:(0,X.jsx)(jn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Dn(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-os*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})})})]})});ys.displayName=vs;var bs=`SelectGroup`,[xs,Ss]=Ho(bs),Cs=Y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Fn();return(0,X.jsx)(xs,{scope:n,id:i,children:(0,X.jsx)(jn.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Cs.displayName=bs;var ws=`SelectLabel`,Ts=Y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Ss(ws,n);return(0,X.jsx)(jn.div,{id:i.id,...r,ref:t})});Ts.displayName=ws;var Es=`SelectItem`,[Ds,Os]=Ho(Es),ks=Y.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Ko(Es,n),c=cs(Es,n),l=s.value===r,[u,d]=Y.useState(a??``),[f,p]=Y.useState(!1),m=Tn(t,e=>c.itemRefCallback?.(e,r,i)),h=Fn(),g=Y.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,X.jsx)(Ds,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Y.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,X.jsx)(zo.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,X.jsx)(jn.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:Dn(o.onFocus,()=>p(!0)),onBlur:Dn(o.onBlur,()=>p(!1)),onClick:Dn(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Dn(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Dn(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Dn(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Dn(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Dn(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Lo.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});ks.displayName=Es;var As=`SelectItemText`,js=Y.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Ko(As,n),s=cs(As,n),c=Os(As,n),l=Jo(As,n),[u,d]=Y.useState(null),f=Tn(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=Y.useMemo(()=>(0,X.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return Ln(()=>(h(m),()=>g(m)),[h,g,m]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(jn.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?no.createPortal(a.children,o.valueNode):null]})});js.displayName=As;var Ms=`SelectItemIndicator`,Ns=Y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Os(Ms,n).isSelected?(0,X.jsx)(jn.span,{"aria-hidden":!0,...r,ref:t}):null});Ns.displayName=Ms;var Ps=`SelectScrollUpButton`,Fs=Y.forwardRef((e,t)=>{let n=cs(Ps,e.__scopeSelect),r=_s(Ps,e.__scopeSelect),[i,a]=Y.useState(!1),o=Tn(t,r.onScrollButtonChange);return Ln(()=>{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,X.jsx)(Rs,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Fs.displayName=Ps;var Is=`SelectScrollDownButton`,Ls=Y.forwardRef((e,t)=>{let n=cs(Is,e.__scopeSelect),r=_s(Is,e.__scopeSelect),[i,a]=Y.useState(!1),o=Tn(t,r.onScrollButtonChange);return Ln(()=>{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,X.jsx)(Rs,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Ls.displayName=Is;var Rs=Y.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=cs(`SelectScrollButton`,n),o=Y.useRef(null),s=Bo(n),c=Y.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Y.useEffect(()=>()=>c(),[c]),Ln(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,X.jsx)(jn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Dn(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Dn(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Dn(i.onPointerLeave,()=>{c()})})}),zs=`SelectSeparator`,Bs=Y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,X.jsx)(jn.div,{"aria-hidden":!0,...r,ref:t})});Bs.displayName=zs;var Vs=`SelectArrow`,Hs=Y.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Wo(n),a=Ko(Vs,n),o=cs(Vs,n);return a.open&&o.position===`popper`?(0,X.jsx)(Ne,{...i,...r,ref:t}):null});Hs.displayName=Vs;var Us=`SelectBubbleInput`,Ws=Y.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Y.useRef(null),a=Tn(r,i),o=Xn(t);return Y.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,X.jsx)(jn.select,{...n,style:{...tn,...n.style},ref:a,defaultValue:t})});Ws.displayName=Us;function Gs(e){return e===``||e===void 0}function Ks(e){let t=Mn(e),n=Y.useRef(``),r=Y.useRef(0),i=Y.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=Y.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Y.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function qs(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=Js(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 Js(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ys=Yo,Xs=Zo,Zs=$o,Qs=ts,$s=rs,ec=as,tc=ys,nc=ks,rc=js,ic=Ns,ac=Fs,oc=Ls,sc=`Switch`,[cc,lc]=Nn(sc),[uc,dc]=cc(sc),fc=Y.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]=Y.useState(null),m=Tn(t,e=>p(e)),h=Y.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=An({prop:i,defaultProp:a??!1,onChange:l,caller:sc});return(0,X.jsxs)(uc,{scope:n,checked:_,disabled:s,children:[(0,X.jsx)(jn.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":_c(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:Dn(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,X.jsx)(gc,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});fc.displayName=sc;var pc=`SwitchThumb`,mc=Y.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=dc(pc,n);return(0,X.jsx)(jn.span,{"data-state":_c(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});mc.displayName=pc;var hc=`SwitchBubbleInput`,gc=Y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=Y.useRef(null),s=Tn(o,a),c=Xn(n),l=Pn(t);return Y.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,X.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}})});gc.displayName=hc;function _c(e){return e?`checked`:`unchecked`}var vc=fc,yc=mc;function bc(e){return e.kind===`doc`?e.docPath:e.folderPath}var xc=zn(`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 Sc(e){let t=(0,J.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,variant:i,asChild:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a!==void 0&&a?On:`span`,c;t[5]!==n||t[6]!==o?(c=Sn(xc({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,X.jsx)(s,{"data-slot":`badge`,"data-variant":o,className:c,...r}),t[8]=s,t[9]=r,t[10]=c,t[11]=o,t[12]=l):l=t[12],l}function Cc(e){let t=(0,J.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,X.jsx)(jo,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function wc(e){let t=(0,J.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,X.jsx)(No,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function Tc(e){let t=(0,J.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=Sn(`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,X.jsx)(Po,{children:(0,X.jsx)(Fo,{"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 Ec(e){let t=(0,J.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,X.jsx)(Mo,{"data-slot":`popover-anchor`,...n}),t[2]=n,t[3]=r),r}var Dc={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.9.1`}?.VITE_APP_VERSION??`0.0.0-unknown`;function Oc(){return I({kind:`web`,runtimeVersion:Dc})}function kc(){return H({kind:`web`,runtimeVersion:Dc})}function Ac(e,t){return t}function jc(e){let t=e.split(`/`);return t.length<2?`ok`:`${t[0]}/${t[1]}`}function Mc(e){if(!e)return;let t=Object.entries(e);if(t.length!==0)return t.map(([e,t])=>{if(t==null)return[e,String(t)];if(typeof t==`string`)return[e,t];if(typeof t==`number`||typeof t==`boolean`)return[e,String(t)];try{return[e,JSON.stringify(t)]}catch{return[e,`[unserializable]`]}})}function Nc(e,t,n){if(typeof performance>`u`||!performance.measure)return;let r=jc(e),i=Mc(t),a={devtools:{dataType:`track-entry`,track:r,...i?{properties:i}:{},...n?.tooltipText?{tooltipText:n.tooltipText}:{}}},o=performance.now(),s=n?.startTime??o,c=n?.duration??Math.max(0,o-s);try{performance.measure(e,{start:s,duration:c,detail:a})}catch{}({...t?{properties:t}:{}})}function Pc(e,t){}function Fc(e,t,n){Nc(e,{...t,durationMs:n},{duration:n})}var Z=Object.assign(Nc,{count:Pc,histogram:Fc});function Ic(e){let t=(0,J.c)(3),{name:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(Y.Profiler,{id:n,onRender:Lc,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}var Lc=(e,t,n,r,i,a)=>{Z(`ok/render/${e}`,{phase:t,actualDuration:Math.round(n*1e3)/1e3,baseDuration:Math.round(r*1e3)/1e3},{startTime:i,duration:Math.max(0,a-i)})},{getOwnPropertyNames:Rc,getOwnPropertySymbols:zc}=Object,{hasOwnProperty:Bc}=Object.prototype;function Vc(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Hc(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function Uc(e){return e?.[Symbol.toStringTag]}function Wc(e){return Rc(e).concat(zc(e))}var Gc=Object.hasOwn||((e,t)=>Bc.call(e,t));function Kc(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var qc=`__v`,Jc=`__o`,Yc=`_owner`,{getOwnPropertyDescriptor:Xc,keys:Zc}=Object;function Qc(e,t){return e.byteLength===t.byteLength&&dl(new Uint8Array(e),new Uint8Array(t))}function $c(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function el(e,t){return e.byteLength===t.byteLength&&dl(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function tl(e,t){return Kc(e.getTime(),t.getTime())}function nl(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function rl(e,t){return e===t}function il(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var al=Kc;function ol(e,t,n){let r=Zc(e),i=r.length;if(Zc(t).length!==i)return!1;for(;i-- >0;)if(!pl(e,t,n,r[i]))return!1;return!0}function sl(e,t,n){let r=Wc(e),i=r.length;if(Wc(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!pl(e,t,n,a)||(o=Xc(e,a),s=Xc(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function cl(e,t){return Kc(e.valueOf(),t.valueOf())}function ll(e,t){return e.source===t.source&&e.flags===t.flags}function ul(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function dl(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function fl(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function pl(e,t,n,r){return(r===Yc||r===Jc||r===qc)&&(e.$$typeof||t.$$typeof)?!0:Gc(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var ml=`[object ArrayBuffer]`,hl=`[object Arguments]`,gl=`[object Boolean]`,_l=`[object DataView]`,vl=`[object Date]`,yl=`[object Error]`,bl=`[object Map]`,xl=`[object Number]`,Sl=`[object Object]`,Cl=`[object RegExp]`,wl=`[object Set]`,Tl=`[object String]`,El={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},Dl=`[object URL]`,Ol=Object.prototype.toString;function kl({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=Ol.call(h);if(b===vl)return r(h,g,_);if(b===Cl)return u(h,g,_);if(b===bl)return o(h,g,_);if(b===wl)return d(h,g,_);if(b===Sl)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===Dl)return p(h,g,_);if(b===yl)return i(h,g,_);if(b===hl)return c(h,g,_);if(El[b])return f(h,g,_);if(b===ml)return e(h,g,_);if(b===_l)return n(h,g,_);if(b===gl||b===xl||b===Tl)return l(h,g,_);if(m){let e=m[b];if(!e){let t=Uc(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function Al({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:Qc,areArraysEqual:n?sl:$c,areDataViewsEqual:el,areDatesEqual:tl,areErrorsEqual:nl,areFunctionsEqual:rl,areMapsEqual:n?Vc(il,sl):il,areNumbersEqual:al,areObjectsEqual:n?sl:ol,arePrimitiveWrappersEqual:cl,areRegExpsEqual:ll,areSetsEqual:n?Vc(ul,sl):ul,areTypedArraysEqual:n?Vc(dl,sl):dl,areUrlsEqual:fl,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Hc(r.areArraysEqual),t=Hc(r.areMapsEqual),n=Hc(r.areObjectsEqual),i=Hc(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function jl(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function Ml({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var Nl=Pl();Pl({strict:!0}),Pl({circular:!0}),Pl({circular:!0,strict:!0}),Pl({createInternalComparator:()=>Kc}),Pl({strict:!0,createInternalComparator:()=>Kc}),Pl({circular:!0,createInternalComparator:()=>Kc}),Pl({circular:!0,createInternalComparator:()=>Kc,strict:!0});function Pl(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=kl(Al(e));return Ml({circular:t,comparator:a,createState:r,equals:n?n(a):jl(a),strict:i})}var Fl=t((e=>{var t=r(),n=to();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Il=t(((e,t)=>{t.exports=Fl()})),Ll=to(),Rl=Il(),zl=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},Bl=({contentComponent:e})=>{let t=(0,Ll.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,X.jsx)(X.Fragment,{children:Object.values(t)})};function Vl(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:no.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var Hl=class extends Y.Component{constructor(e){super(e),this.editorContentRef=Y.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Vl(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:zl(t,this.editorContentRef),...n}),e?.contentComponent&&(0,X.jsx)(Bl,{contentComponent:e.contentComponent})]})}},Ul=(0,Y.forwardRef)((e,t)=>{let n=Y.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return Y.createElement(Hl,{key:n,innerRef:t,...e})}),Wl=Y.memo(Ul),Gl=typeof window<`u`?Y.useLayoutEffect:Y.useEffect,Kl=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function ql(e){let[t]=(0,Y.useState)(()=>new Kl(e.editor)),n=(0,Rl.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??Nl);return Gl(()=>t.watch(e.editor),[e.editor,t]),(0,Y.useDebugValue)(n),n}typeof window>`u`||typeof window<`u`&&window.next;var Jl=(0,Y.createContext)({editor:null});Jl.Consumer;var Yl=()=>(0,Y.useContext)(Jl),Xl=(0,Y.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Zl=()=>(0,Y.useContext)(Xl);function Ql({as:e=`div`,...t}){let{nodeViewContentRef:n,nodeViewContentChildren:r}=Zl();return(0,X.jsx)(e,{...t,ref:n,"data-node-view-content":``,style:{whiteSpace:`pre-wrap`,...t.style},children:r})}var $l=Y.forwardRef((e,t)=>{let{onDragStart:n}=Zl();return(0,X.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})});function eu(e){return!!(typeof e==`function`&&e.prototype&&e.prototype.isReactComponent)}function tu(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.forward_ref)`||e.$$typeof.description===`react.forward_ref`))}function nu(e){return!!(typeof e==`object`&&e.$$typeof&&(e.$$typeof.toString()===`Symbol(react.memo)`||e.$$typeof.description===`react.memo`))}function ru(e){if(eu(e)||tu(e))return!0;if(nu(e)){let t=e.type;if(t)return eu(t)||tu(t)}return!1}function iu(){try{if(Y.version)return parseInt(Y.version.split(`.`)[0],10)>=19}catch{}return!1}var au=class{constructor(e,{editor:t,props:n={},as:r=`div`,className:i=``}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(r),this.element.classList.add(`react-renderer`),i&&this.element.classList.add(...i.split(` `)),this.editor.isEditorContentInitialized?(0,no.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let t=this.component,n=this.props,r=this.editor,i=iu(),a=ru(t),o={...n};o.ref&&!(i||a)&&delete o.ref,!o.ref&&(i||a)&&(o.ref=e=>{this.ref=e}),this.reactElement=(0,X.jsx)(t,{...o}),(e=r?.contentComponent)==null||e.setRenderer(this.id,this)}updateProps(e={}){this.destroyed||(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0,(e=this.editor?.contentComponent)==null||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(t=>{this.element.setAttribute(t,e[t])})}};Y.createContext({markViewContentRef:()=>{}});var ou=class extends at{constructor(e,t,n){if(super(e,t,n),this.selectionRafId=null,this.positionCheckCallback=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?`span`:`div`),this.contentDOMElement.dataset.nodeViewContentReact=``,this.contentDOMElement.dataset.nodeViewWrapper=``,this.contentDOMElement.style.whiteSpace=`inherit`;let e=this.dom.querySelector(`[data-node-view-content]`);if(!e)return;e.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){let e=this.editor,t=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(t,{get(n,r,i){return r===`storage`?e.storage[t.name]??{}:Reflect.get(n,r,i)}})}return this.cachedExtensionWithSyncedStorage}mount(){let e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode(),ref:(0,Y.createRef)()};if(!this.component.displayName){let e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}let t={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&(e.hasAttribute(`data-node-view-wrapper`)&&e.removeAttribute(`data-node-view-wrapper`),e.appendChild(this.contentDOMElement))}},n=this.component,r=(0,Y.memo)(e=>(0,X.jsx)(Xl.Provider,{value:t,children:(0,Y.createElement)(n,e)}));r.displayName=`ReactNodeView`;let i=this.node.isInline?`span`:`div`;this.options.as&&(i=this.options.as);let{className:a=``}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new au(r,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on(`selectionUpdate`,this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos(),this.positionCheckCallback=()=>{let e=this.getPos();typeof e!=`number`||e===this.currentPos||(this.currentPos=e,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs==`function`&&this.updateElementAttributes())},Oe(this.editor,this.positionCheckCallback)}get dom(){if(this.renderer.element.firstElementChild&&!this.renderer.element.firstElementChild?.hasAttribute(`data-node-view-wrapper`))throw Error(`Please use the NodeViewWrapper component for your node view.`);return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;let{from:e,to:t}=this.editor.state.selection,n=this.currentPos;if(typeof n==`number`)if(e<=n&&t>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(e,t,n){let r=e=>{this.renderer.updateProps(e),typeof this.options.attrs==`function`&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update==`function`){let i=this.node,a=this.decorations,o=this.innerDecorations;return this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:a,newNode:e,newDecorations:t,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}let i=this.getPos();return e===this.node&&this.decorations===t&&this.innerDecorations===n?i===this.currentPos?!0:(this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage,getPos:()=>this.getPos()}),!0):(this.node=e,this.decorations=t,this.innerDecorations=n,this.currentPos=i,r({node:e,decorations:t,innerDecorations:n,extension:this.extensionWithSyncedStorage}),!0)}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add(`ProseMirror-selectednode`)}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove(`ProseMirror-selectednode`)}destroy(){this.renderer.destroy(),this.editor.off(`selectionUpdate`,this.handleSelectionUpdate),this.positionCheckCallback&&=(dt(this.editor,this.positionCheckCallback),null),this.contentDOMElement=null,this.selectionRafId&&=(cancelAnimationFrame(this.selectionRafId),null)}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs==`function`){let t=this.editor.extensionManager.attributes,n=gt(this.node,t);e=this.options.attrs({node:this.node,HTMLAttributes:n})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}};function su(e,t){return n=>n.editor.contentComponent?new ou(e,n,t):{}}var cu=(0,Y.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});cu.displayName=`TiptapContext`;var lu=()=>(0,Y.useContext)(cu);function uu({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,Y.useMemo)(()=>({editor:r}),[r]),a=(0,Y.useMemo)(()=>({editor:r}),[r]);return(0,X.jsx)(Jl.Provider,{value:a,children:(0,X.jsx)(cu.Provider,{value:i,children:n})})}uu.displayName=`Tiptap`;function du({...e}){let{editor:t}=lu();return(0,X.jsx)(Wl,{editor:t,...e})}du.displayName=`Tiptap.Content`,Object.assign(uu,{Content:du});var fu=()=>new Map,pu=e=>{let t=fu();return e.forEach((e,n)=>{t.set(n,e)}),t},mu=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},hu=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},gu=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},_u=()=>new Set,vu=e=>e[e.length-1],yu=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},bu=Array.from,xu=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Su=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Cu=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},wu=Array.isArray,Tu=class{constructor(){this._observers=fu()}on(e,t){return mu(this._observers,e,_u).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return bu((this._observers.get(e)||fu()).values()).forEach(e=>e(...t))}destroy(){this._observers=fu()}},Eu=class{constructor(){this._observers=fu()}on(e,t){mu(this._observers,e,_u).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return bu((this._observers.get(e)||fu()).values()).forEach(e=>e(...t))}destroy(){this._observers=fu()}},Du=Math.floor,Ou=Math.abs,ku=(e,t)=>e<t?e:t,Au=(e,t)=>e>t?e:t;Number.isNaN;var ju=e=>e===0?1/e<0:e<0,Mu=1<<17,Nu=1<<18,Pu=1<<19,Fu=1<<20,Iu=1<<21,Lu=1<<22,Ru=1<<23,zu=1<<24,Bu=1<<25,Vu=1<<26,Hu=1<<27,Uu=1<<28,Wu=1<<29;Mu-1,Nu-1,Pu-1,Fu-1,Iu-1,Lu-1,Ru-1,zu-1,Bu-1,Vu-1,Hu-1,Uu-1,Wu-1;var Gu=2**53-1,Ku=-(2**53-1),qu=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&Du(e)===e);Number.isNaN,Number.parseInt;var Ju=String.fromCharCode;String.fromCodePoint,Ju(65535);var Yu=e=>e.toLowerCase(),Xu=/^\s*/g,Zu=e=>e.replace(Xu,``),Qu=/([A-Z])/g,$u=(e,t)=>Zu(e.replace(Qu,e=>`${t}${Yu(e)}`)),ed=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},td=typeof TextEncoder<`u`?new TextEncoder:null,nd=td?e=>td.encode(e):ed,rd=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});rd&&rd.decode(new Uint8Array).length===1&&(rd=null);var id=(e,t)=>Cu(t,()=>e).join(``),ad=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},od=()=>new ad,sd=e=>{let t=od();return e(t),ld(t)},cd=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},ld=e=>{let t=new Uint8Array(cd(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},ud=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(Au(n,t)*2),e.cpos=0)},dd=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},fd=dd,pd=(e,t)=>{for(;t>127;)dd(e,128|127&t),t=Du(t/128);dd(e,127&t)},md=(e,t)=>{let n=ju(t);for(n&&(t=-t),dd(e,(t>63?128:0)|(n?64:0)|63&t),t=Du(t/64);t>0;)dd(e,(t>127?128:0)|127&t),t=Du(t/128)},hd=new Uint8Array(3e4),gd=hd.length/3,_d=td&&td.encodeInto?(e,t)=>{if(t.length<gd){let n=td.encodeInto(t,hd).written||0;pd(e,n);for(let t=0;t<n;t++)dd(e,hd[t])}else yd(e,nd(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;pd(e,r);for(let t=0;t<r;t++)dd(e,n.codePointAt(t))},vd=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=ku(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Au(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},yd=(e,t)=>{pd(e,t.byteLength),vd(e,t)},bd=(e,t)=>{ud(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},xd=(e,t)=>bd(e,4).setFloat32(0,t,!1),Sd=(e,t)=>bd(e,8).setFloat64(0,t,!1),Cd=(e,t)=>bd(e,8).setBigInt64(0,t,!1),wd=new DataView(new ArrayBuffer(4)),Td=e=>(wd.setFloat32(0,e),wd.getFloat32(0)===e),Ed=(e,t)=>{switch(typeof t){case`string`:dd(e,119),_d(e,t);break;case`number`:qu(t)&&Ou(t)<=2147483647?(dd(e,125),md(e,t)):Td(t)?(dd(e,124),xd(e,t)):(dd(e,123),Sd(e,t));break;case`bigint`:dd(e,122),Cd(e,t);break;case`object`:if(t===null)dd(e,126);else if(wu(t)){dd(e,117),pd(e,t.length);for(let n=0;n<t.length;n++)Ed(e,t[n])}else if(t instanceof Uint8Array)dd(e,116),yd(e,t);else{dd(e,118);let n=Object.keys(t);pd(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];_d(e,i),Ed(e,t[i])}}break;case`boolean`:dd(e,t?120:121);break;default:dd(e,127)}},Dd=class extends ad{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&pd(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Od=e=>{e.count>0&&(md(e.encoder,e.count===1?e.s:-e.s),e.count>1&&pd(e.encoder,e.count-2))},kd=class{constructor(){this.encoder=new ad,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Od(this),this.count=1,this.s=e)}toUint8Array(){return Od(this),ld(this.encoder)}},Ad=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);md(e.encoder,t),e.count>1&&pd(e.encoder,e.count-2)}},jd=class{constructor(){this.encoder=new ad,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ad(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ad(this),ld(this.encoder)}},Md=class{constructor(){this.sarr=[],this.s=``,this.lensE=new kd}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new ad;return this.sarr.push(this.s),this.s=``,_d(e,this.sarr.join(``)),vd(e,this.lensE.toUint8Array()),ld(e)}},Nd=e=>Error(e),Pd=()=>{throw Nd(`Method unimplemented`)},Fd=()=>{throw Nd(`Unexpected case`)},Id=Nd(`Unexpected end of array`),Ld=Nd(`Integer out of Range`),Rd=class{constructor(e){this.arr=e,this.pos=0}},zd=e=>new Rd(e),Bd=e=>e.pos!==e.arr.length,Vd=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Hd=e=>Vd(e,Wd(e)),Ud=e=>e.arr[e.pos++],Wd=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Gu)throw Ld}throw Id},Gd=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Gu)throw Ld}throw Id},Kd=rd?e=>rd.decode(Hd(e)):e=>{let t=Wd(e);if(t===0)return``;{let n=String.fromCodePoint(Ud(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Ud(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},qd=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Jd=[e=>void 0,e=>null,Gd,e=>qd(e,4).getFloat32(0,!1),e=>qd(e,8).getFloat64(0,!1),e=>qd(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Kd,e=>{let t=Wd(e),n={};for(let r=0;r<t;r++){let t=Kd(e);n[t]=Yd(e)}return n},e=>{let t=Wd(e),n=[];for(let r=0;r<t;r++)n.push(Yd(e));return n},Hd],Yd=e=>Jd[127-Ud(e)](e),Xd=class extends Rd{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Bd(this)?this.count=Wd(this)+1:this.count=-1),this.count--,this.s}},Zd=class extends Rd{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Gd(this);let e=ju(this.s);this.count=1,e&&(this.s=-this.s,this.count=Wd(this)+2)}return this.count--,this.s}},Qd=class extends Rd{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Gd(this),t=e&1;this.diff=Du(e/2),this.count=1,t&&(this.count=Wd(this)+2)}return this.s+=this.diff,this.count--,this.s}},$d=class{constructor(e){this.decoder=new Zd(e),this.str=Kd(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var ef=crypto.getRandomValues.bind(crypto),tf=Math.random,nf=()=>ef(new Uint32Array(1))[0],rf=e=>e[Du(tf()*e.length)],af=`10000000-1000-4000-8000-100000000000`,of=()=>af.replace(/[018]/g,e=>(e^nf()&15>>e/4).toString(16)),sf=Date.now,cf=e=>new Promise(e);Promise.all.bind(Promise);var lf=e=>e===void 0?null:e,uf=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(uf=localStorage)}catch{}var df=uf,ff=Symbol(`Equality`),pf=(e,t)=>e===t||!!e?.[ff]?.(t)||!1,mf=e=>typeof e==`object`,hf=Object.assign,gf=Object.keys,_f=(e,t)=>{for(let n in e)t(e[n],n)},vf=e=>gf(e).length,yf=e=>{for(let t in e)return!1;return!0},bf=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},xf=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Sf=(e,t)=>e===t||vf(e)===vf(t)&&bf(e,(e,n)=>(e!==void 0||xf(t,n))&&pf(t[n],e)),Cf=Object.freeze,wf=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&wf(e[t])}return Cf(e)},Tf=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Tf(e,t,n+1)}},Ef=e=>e,Df=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[ff]!=null)return e[ff](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Df(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(vf(e)!==vf(t))return!1;for(let n in e)if(!xf(e,n)||!Df(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Df(e[n],t[n]))return!1;break;default:return!1}return!0},Of=(e,t)=>t.includes(e),kf=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Af=typeof window<`u`&&typeof document<`u`&&!kf;typeof navigator<`u`&&/Mac/.test(navigator.platform);var jf,Mf=[],Nf=()=>{if(jf===void 0)if(kf){jf=fu();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&jf.set(t,``),t=r):t===null?Mf.push(r):(jf.set(t,r),t=null)}t!==null&&jf.set(t,``)}else typeof location==`object`?(jf=fu(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);jf.set(`--${$u(t,`-`)}`,n),jf.set(`-${$u(t,`-`)}`,n)}})):jf=fu();return jf},Pf=e=>Nf().has(e),Ff=e=>lf(kf?{}[e.toUpperCase().replaceAll(`-`,`_`)]:df.getItem(e)),If=e=>Pf(`--`+e)||Ff(e)!==null,Lf=If(`production`),Rf=kf&&Of({}.FORCE_COLOR,[`true`,`1`,`2`])||!Pf(`--no-colors`)&&!If(`no-color`)&&(!kf||process.stdout.isTTY)&&(!kf||Pf(`--color`)||Ff(`COLORTERM`)!==null||(Ff(`TERM`)||``).includes(`color`)),zf=e=>new Uint8Array(e),Bf=Af?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Ju(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Vf=e=>{let t=zf(e.byteLength);return t.set(e),t},Hf=e=>sd(t=>Ed(t,e)),Uf=class{constructor(e,t){this.left=e,this.right=t}},Wf=(e,t)=>new Uf(e,t),Gf=(e,t)=>e.forEach(e=>t(e.left,e.right)),Kf=e=>e.next()>=.5,qf=(e,t,n)=>Du(e.next()*(n+1-t)+t),Jf=(e,t,n)=>Du(e.next()*(n+1-t)+t),Yf=(e,t,n)=>Jf(e,t,n),Xf=e=>Ju(Yf(e,97,122)),Zf=(e,t=0,n=20)=>{let r=Yf(e,t,n),i=``;for(let t=0;t<r;t++)i+=Xf(e);return i},Qf=(e,t)=>t[Yf(e,0,t.length-1)],$f=Symbol(`0schema`),ep=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(id(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
3
3
|
`)}},tp=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[ff]?pf(e,t):wu(e)?xu(e,e=>Su(t,t=>tp(e,t))):mf(e)?bf(e,(e,n)=>tp(e,t[n])):!1,np=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),tp(t,n)}equals(e){return this.constructor===e.constructor&&Df(this.shape,e.shape)}[$f](){return!0}[ff](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Pd()}get nullable(){return Fp(this,Xp)}get optional(){return new pp(this)}cast(e){return em(e,this),e}expect(e){return em(e,this),e}},rp=class extends np{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},ip=(e,t=null)=>new rp(e,t);ip(rp);var ap=class extends np{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},op=e=>new ap(e);ip(ap);var sp=class extends np{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},cp=(...e)=>new sp(e),lp=ip(sp),up=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),dp=e=>{if(Gp.check(e))return[up(e)];if(lp.check(e))return e.shape.map(e=>e+``);if(Wp.check(e))return[`[+-]?\\d+.?\\d*`];if(Kp.check(e))return[`.*`];if(Ip.check(e))return e.shape.map(dp).flat(1);Fd()};ip(class extends np{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(dp).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var fp=Symbol(`optional`),pp=class extends np{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[fp](){return!0}},mp=ip(pp),hp=class extends np{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new hp,ip(hp);var gp=class e extends np{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):bf(this.shape,(n,r)=>{let i=this._isPartial&&!xf(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},_p=e=>new gp(e),vp=ip(gp),yp=op(e=>e!=null&&(e.constructor===Object||e.constructor==null)),bp=class extends np{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&bf(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},xp=(e,t)=>new bp(e,t),Sp=ip(bp),Cp=class extends np{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&bf(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},wp=(...e)=>new Cp(e);ip(Cp);var Tp=class extends np{constructor(e){super(),this.shape=e.length===1?e[0]:new Pp(e)}check(e,t){let n=wu(e)&&xu(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},Ep=(...e)=>new Tp(e),Dp=ip(Tp),Op=op(e=>wu(e)),kp=class extends np{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},Ap=(e,t=null)=>new kp(e,t);ip(kp);var jp=Ap(np),Mp=ip(class extends np{constructor(e){super(),this.len=e.length-1,this.args=wp(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),Np=op(e=>typeof e==`function`);ip(class extends np{constructor(e){super(),this.shape=e}check(e,t){let n=xu(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Pp=class extends np{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Su(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},Fp=(...e)=>e.findIndex(e=>Ip.check(e))>=0?Fp(...e.map(e=>$p(e)).map(e=>Ip.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Pp(e),Ip=ip(Pp),Lp=()=>!0,Rp=op(Lp),zp=ip(ap,e=>e.shape===Lp),Bp=op(e=>typeof e==`bigint`),Vp=op(e=>e===Bp),Hp=op(e=>typeof e==`symbol`);op(e=>e===Hp);var Up=op(e=>typeof e==`number`),Wp=op(e=>e===Up),Gp=op(e=>typeof e==`string`),Kp=op(e=>e===Gp),qp=op(e=>typeof e==`boolean`),Jp=op(e=>e===qp),Yp=cp(void 0);ip(sp,e=>e.shape.length===1&&e.shape[0]===void 0),cp(void 0);var Xp=cp(null),Zp=ip(sp,e=>e.shape.length===1&&e.shape[0]===null);ip(Uint8Array),ip(rp,e=>e.shape===Uint8Array);var Qp=Fp(Up,Gp,Xp,Yp,Bp,qp,Hp);(()=>{let e=Ep(Rp),t=xp(Gp,Rp),n=Fp(Up,Gp,Xp,qp,e,t);return e.shape=n,t.shape.values=n,n})();var $p=e=>{if(jp.check(e))return e;if(yp.check(e)){let t={};for(let n in e)t[n]=$p(e[n]);return _p(t)}else if(Op.check(e))return Fp(...e.map($p));else if(Qp.check(e))return cp(e);else if(Np.check(e))return ip(e);Fd()},em=Lf?()=>{}:(e,t)=>{let n=new ep;if(!t.check(e,n))throw Nd(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},tm=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:$p(e),h:t}),this}else(e){return this.if(Rp,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Nd(`Unhandled pattern`)}}},nm=(e=>new tm(e))(Rp).if(Wp,(e,t)=>qf(t,Ku,Gu)).if(Kp,(e,t)=>Zf(t)).if(Jp,(e,t)=>Kf(t)).if(Vp,(e,t)=>BigInt(qf(t,Ku,Gu))).if(Ip,(e,t)=>rm(t,Qf(t,e.shape))).if(vp,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(mp.check(i)){if(Kf(t))continue;i=i.shape}n[r]=nm(i,t)}return n}).if(Dp,(e,t)=>{let n=[],r=Jf(t,0,42);for(let i=0;i<r;i++)n.push(rm(t,e.shape));return n}).if(lp,(e,t)=>Qf(t,e.shape)).if(Zp,(e,t)=>null).if(Mp,(e,t)=>{let n=rm(t,e.res);return()=>n}).if(zp,(e,t)=>rm(t,Qf(t,[Up,Gp,Xp,Yp,Bp,qp,Ep(Up),xp(Fp(`a`,`b`,`c`),Up)]))).if(Sp,(e,t)=>{let n={},r=qf(t,0,3);for(let i=0;i<r;i++){let r=rm(t,e.shape.keys);n[r]=rm(t,e.shape.values)}return n}).done(),rm=(e,t)=>nm($p(t),e),im=typeof document<`u`?document:{},am=e=>im.createElement(e),om=()=>im.createDocumentFragment();op(e=>e.nodeType===vm);var sm=e=>im.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var cm=(e,t)=>(Gf(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),lm=e=>{let t=om();for(let n=0;n<e.length;n++)mm(t,e[n]);return t},um=(e,t)=>(mm(e,lm(t)),e),dm=(e,t=[],n=[])=>um(cm(am(e),t),n);op(e=>e.nodeType===hm);var fm=sm;op(e=>e.nodeType===gm);var pm=e=>hu(e,(e,t)=>`${t}:${e};`).join(``),mm=(e,t)=>e.appendChild(t),hm=im.ELEMENT_NODE,gm=im.TEXT_NODE;im.CDATA_SECTION_NODE,im.COMMENT_NODE;var _m=im.DOCUMENT_NODE;im.DOCUMENT_TYPE_NODE;var vm=im.DOCUMENT_FRAGMENT_NODE;op(e=>e.nodeType===_m);var ym=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),bm=(e,t)=>new ym(setTimeout(t,e)),xm=Symbol,Sm=xm(),Cm=xm(),wm=xm(),Tm=xm(),Em=xm(),Dm=xm(),Om=xm(),km=xm(),Am=xm(),jm=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};sf();var Mm={[Sm]:Wf(`font-weight`,`bold`),[Cm]:Wf(`font-weight`,`normal`),[wm]:Wf(`color`,`blue`),[Em]:Wf(`color`,`green`),[Tm]:Wf(`color`,`grey`),[Dm]:Wf(`color`,`red`),[Om]:Wf(`color`,`purple`),[km]:Wf(`color`,`orange`),[Am]:Wf(`color`,`black`)},Nm=Rf?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=fu(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=Mm[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=pm(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:jm,Pm=(...e)=>{console.log(...Nm(e)),Im.forEach(t=>t.print(e))},Fm=(...e)=>{console.warn(...Nm(e)),e.unshift(km),Im.forEach(t=>t.print(e))},Im=_u(),Lm=e=>({[Symbol.iterator](){return this},next:e}),Rm=(e,t)=>Lm(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),zm=(e,t)=>Lm(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),Bm=class{constructor(e,t){this.clock=e,this.len=t}},Vm=class{constructor(){this.clients=new Map}},Hm=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])sg(e,i,o.clock,o.len,n)}}),Um=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=Du((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},Wm=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Um(n,t.clock)!==null},Gm=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new Bm(r.clock,Au(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Km=e=>{let t=new Vm;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)yu(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Gm(t),t},qm=(e,t,n,r)=>{mu(e.clients,t,()=>[]).push(new Bm(n,r))},Jm=()=>new Vm,Ym=e=>{let t=Jm();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new Bm(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Xm=(e,t)=>{pd(e.restEncoder,t.clients.size),bu(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),pd(e.restEncoder,t);let r=n.length;pd(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Zm=e=>{let t=new Vm,n=Wd(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=Wd(e.restDecoder),r=Wd(e.restDecoder);if(r>0){let i=mu(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new Bm(e.readDsClock(),e.readDsLen()))}}return t},Qm=(e,t,n)=>{let r=new Vm,i=Wd(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=Wd(e.restDecoder),a=Wd(e.restDecoder),o=n.clients.get(i)||[],s=$h(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&qm(r,i,s,a-s);let e=tg(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,wv(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,wv(t,c,a-c.id.clock)),c.delete(t))}else qm(r,i,n,a-n)}}if(r.clients.size>0){let e=new ch;return pd(e.restEncoder,0),Xm(e,r),e.toUint8Array()}return null},$m=nf,eh=class e extends Tu{constructor({guid:e=of(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=$m(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Zh,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=cf(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>cf(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&hg(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(bu(this.subdocs).map(e=>e.guid))}transact(e,t=null){return hg(this,e,t)}get(e,t=Gg){let n=mu(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==Gg&&r!==t)if(r===Gg){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,f_)}getText(e=``){return this.get(e,N_)}getMap(e=``){return this.get(e,h_)}getXmlElement(e=``){return this.get(e,R_)}getXmlFragment(e=``){return this.get(e,I_)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,bu(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,hg(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},th=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Wd(this.restDecoder)}readDsLen(){return Wd(this.restDecoder)}},nh=class extends th{readLeftID(){return Nh(Wd(this.restDecoder),Wd(this.restDecoder))}readRightID(){return Nh(Wd(this.restDecoder),Wd(this.restDecoder))}readClient(){return Wd(this.restDecoder)}readInfo(){return Ud(this.restDecoder)}readString(){return Kd(this.restDecoder)}readParentInfo(){return Wd(this.restDecoder)===1}readTypeRef(){return Wd(this.restDecoder)}readLen(){return Wd(this.restDecoder)}readAny(){return Yd(this.restDecoder)}readBuf(){return Vf(Hd(this.restDecoder))}readJSON(){return JSON.parse(Kd(this.restDecoder))}readKey(){return Kd(this.restDecoder)}},rh=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Wd(this.restDecoder),this.dsCurrVal}readDsLen(){let e=Wd(this.restDecoder)+1;return this.dsCurrVal+=e,e}},ih=class extends rh{constructor(e){super(e),this.keys=[],Wd(e),this.keyClockDecoder=new Qd(Hd(e)),this.clientDecoder=new Zd(Hd(e)),this.leftClockDecoder=new Qd(Hd(e)),this.rightClockDecoder=new Qd(Hd(e)),this.infoDecoder=new Xd(Hd(e),Ud),this.stringDecoder=new $d(Hd(e)),this.parentInfoDecoder=new Xd(Hd(e),Ud),this.typeRefDecoder=new Zd(Hd(e)),this.lenDecoder=new Zd(Hd(e))}readLeftID(){return new jh(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new jh(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Yd(this.restDecoder)}readBuf(){return Hd(this.restDecoder)}readJSON(){return Yd(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},ah=class{constructor(){this.restEncoder=od()}toUint8Array(){return ld(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){pd(this.restEncoder,e)}writeDsLen(e){pd(this.restEncoder,e)}},oh=class extends ah{writeLeftID(e){pd(this.restEncoder,e.client),pd(this.restEncoder,e.clock)}writeRightID(e){pd(this.restEncoder,e.client),pd(this.restEncoder,e.clock)}writeClient(e){pd(this.restEncoder,e)}writeInfo(e){fd(this.restEncoder,e)}writeString(e){_d(this.restEncoder,e)}writeParentInfo(e){pd(this.restEncoder,+!!e)}writeTypeRef(e){pd(this.restEncoder,e)}writeLen(e){pd(this.restEncoder,e)}writeAny(e){Ed(this.restEncoder,e)}writeBuf(e){yd(this.restEncoder,e)}writeJSON(e){_d(this.restEncoder,JSON.stringify(e))}writeKey(e){_d(this.restEncoder,e)}},sh=class{constructor(){this.restEncoder=od(),this.dsCurrVal=0}toUint8Array(){return ld(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,pd(this.restEncoder,t)}writeDsLen(e){e===0&&Fd(),pd(this.restEncoder,e-1),this.dsCurrVal+=e}},ch=class extends sh{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new jd,this.clientEncoder=new kd,this.leftClockEncoder=new jd,this.rightClockEncoder=new jd,this.infoEncoder=new Dd(fd),this.stringEncoder=new Md,this.parentInfoEncoder=new Dd(fd),this.typeRefEncoder=new kd,this.lenEncoder=new kd}toUint8Array(){let e=od();return pd(e,0),yd(e,this.keyClockEncoder.toUint8Array()),yd(e,this.clientEncoder.toUint8Array()),yd(e,this.leftClockEncoder.toUint8Array()),yd(e,this.rightClockEncoder.toUint8Array()),yd(e,ld(this.infoEncoder)),yd(e,this.stringEncoder.toUint8Array()),yd(e,ld(this.parentInfoEncoder)),yd(e,this.typeRefEncoder.toUint8Array()),yd(e,this.lenEncoder.toUint8Array()),vd(e,ld(this.restEncoder)),ld(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ed(this.restEncoder,e)}writeBuf(e){yd(this.restEncoder,e)}writeJSON(e){Ed(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},lh=(e,t,n,r)=>{r=Au(r,t[0].id.clock);let i=tg(t,r);pd(e.restEncoder,t.length-i),e.writeClient(n),pd(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},uh=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{$h(t,n)>e&&r.set(n,e)}),Qh(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),pd(e.restEncoder,r.size),bu(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{lh(e,t.clients.get(n),n,r)})},dh=(e,t)=>{let n=fu(),r=Wd(e.restDecoder);for(let i=0;i<r;i++){let r=Wd(e.restDecoder),i=Array(r),a=e.readClient(),o=Wd(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new q_(Nh(a,o),t),o+=t;break}case 10:{let t=Wd(e.restDecoder);i[n]=new jv(Nh(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new Dv(Nh(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,Ov(e,r));i[n]=c,o+=c.length}}}}return n},fh=(e,t,n)=>{let r=[],i=bu(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new Zh,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==jv){let i=mu(d,u.id.client,()=>$h(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,$h(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new ch;return uh(e,s,new Map),pd(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},ph=(e,t)=>uh(e,t.doc.store,t.beforeState),mh=(e,t,n,r=new ih(e))=>hg(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=fh(e,i,dh(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<$h(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=Tg([o.update,a.update])}}else i.pendingStructs=a;let s=Qm(r,e,i);if(i.pendingDs){let t=new ih(zd(i.pendingDs));Wd(t.restDecoder);let n=Qm(t,e,i);s&&n?i.pendingDs=Tg([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,hh(e.doc,t)}},n,!1),hh=(e,t,n,r=ih)=>{let i=zd(t);mh(i,e,n,new r(i))},gh=(e,t,n)=>hh(e,t,n,nh),_h=(e,t,n=new Map)=>{uh(e,t.store,n),Xm(e,Ym(t.store))},vh=(e,t=new Uint8Array([0]),n=new ch)=>{_h(n,e,xh(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Eg(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===oh)return Cg(r.map((e,t)=>t===0?e:jg(e)));if(n.constructor===ch)return Tg(r)}return r[0]},yh=(e,t)=>vh(e,t,new oh),bh=e=>{let t=new Map,n=Wd(e.restDecoder);for(let r=0;r<n;r++){let n=Wd(e.restDecoder),r=Wd(e.restDecoder);t.set(n,r)}return t},xh=e=>bh(new th(zd(e))),Sh=(e,t)=>(pd(e.restEncoder,t.size),bu(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{pd(e.restEncoder,t),pd(e.restEncoder,n)}),e),Ch=(e,t)=>Sh(e,Qh(t.store)),wh=(e,t=new sh)=>(e instanceof Map?Sh(t,e):Ch(t,e),t.toUint8Array()),Th=e=>wh(e,new ah),Eh=class{constructor(){this.l=[]}},Dh=()=>new Eh,Oh=(e,t)=>e.l.push(t),kh=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},Ah=(e,t,n)=>Tf(e.l,[t,n]),jh=class{constructor(e,t){this.client=e,this.clock=t}},Mh=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,Nh=(e,t)=>new jh(e,t),Ph=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw Fd()},Fh=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Ih=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},Lh=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},Rh=e=>new Ih(e.type==null?null:Nh(e.type.client,e.type.clock),e.tname??null,e.item==null?null:Nh(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),zh=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Bh=(e,t,n=0)=>new zh(e,t,n),Vh=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Ph(e):r=Nh(e._item.id.client,e._item.id.clock),new Ih(r,i,t,n)},Hh=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Vh(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Vh(e,Nh(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Vh(e,r.lastId,n);r=r.right}return Vh(e,null,n)},Uh=(e,t)=>{let n=ng(e,t);return{item:n,diff:t.clock-n.id.clock}},Wh=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if($h(r,i.client)<=i.clock)return null;let e=n?Sv(r,i):Uh(r,i),t=e.item;if(!(t instanceof Dv))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if($h(r,a.client)<=a.clock)return null;let{item:e}=n?Sv(r,a):{item:ng(r,a)};if(e instanceof Dv&&e.content instanceof bv)c=e.content.type;else return null}else throw Fd();l=s>=0?c._length:0}return Bh(c,l,e.assoc)},Gh=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Mh(e.item,t.item)&&Mh(e.type,t.type)&&e.assoc===t.assoc,Kh=class{constructor(e,t){this.ds=e,this.sv=t}},qh=(e,t)=>new Kh(e,t);qh(Jm(),new Map);var Jh=e=>qh(Ym(e.store),Qh(e.store)),Yh=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Wm(t.ds,e.id),Xh=(e,t)=>{let n=mu(e.meta,Xh,_u),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<$h(r,n)&&ig(e,Nh(n,t))}),Hm(e,t.ds,e=>{}),n.add(t))},Zh=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Qh=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},$h=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},eg=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw Fd()}n.push(t)},tg=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=Du(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=Du((n+r)/2)}throw Fd()},ng=(e,t)=>{let n=e.clients.get(t.client);return n[tg(n,t.clock)]},rg=(e,t,n)=>{let r=tg(t,n),i=t[r];return i.id.clock<n&&i instanceof Dv?(t.splice(r+1,0,wv(e,i,n-i.id.clock)),r+1):r},ig=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[rg(e,n,t.clock)]},ag=(e,t,n)=>{let r=t.clients.get(n.client),i=tg(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==q_&&r.splice(i+1,0,wv(e,a,n.clock-a.id.clock+1)),a},og=(e,t,n)=>{let r=e.clients.get(t.id.client);r[tg(r,t.id.clock)]=n},sg=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=rg(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&rg(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},cg=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Vm,this.beforeState=Qh(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},lg=(e,t)=>t.deleteSet.clients.size===0&&!gu(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Gm(t.deleteSet),ph(e,t),Xm(e,t.deleteSet),!0),ug=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&mu(e.changed,t,_u).add(n)},dg=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Dv&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},fg=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=tg(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof Dv&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},pg=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=ku(r.length-1,1+tg(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+dg(r,e)}})},mg=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Gm(a),n.afterState=Qh(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{Ah(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&A_(n)})}),Tf(e,[])}finally{r.gc&&fg(a,i,r.gcFilter),pg(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=Au(tg(e,r),1);for(let t=e.length-1;t>=n;)t-=1+dg(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=tg(r,n);a+1<r.length&&dg(r,a+1)>1||a>0&&dg(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Pm(km,Sm,`[yjs] `,Cm,Dm,`Changed the client-id because another client seems to be using it.`),r.clientID=$m()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new oh;lg(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new ch;lg(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):mg(e,t+1)}}},hg=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new cg(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&mg(i,0)}}return o},gg=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},_g=(e,t,n)=>{Hm(e,n.deletions,n=>{n instanceof Dv&&t.scope.some(t=>t===e.doc||Fh(t,n))&&Cv(n,!1)})},vg=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;hg(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;Hm(n,o.insertions,e=>{if(e instanceof Dv){if(e.redone!==null){let{item:t,diff:i}=Sv(r,e.id);i>0&&(t=ig(n,Nh(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||Fh(t,e))&&c.push(e)}}),Hm(n,o.deletions,e=>{e instanceof Dv&&a.some(t=>t===n.doc||Fh(t,e))&&!Wm(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Ev(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},yg=class extends Tu{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=wu(e)?e[0].doc:e instanceof eh?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new Vm;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&qm(i,n,r,a)});let a=sf(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=Km([t.deletions,e.deleteSet]),t.insertions=Km([t.insertions,i])}else r.push(new gg(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),Hm(e,e.deleteSet,t=>{t instanceof Dv&&this.scope.some(n=>n===e.doc||Fh(n,t))&&Cv(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=wu(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof Gg?e.doc!==this.doc:e!==this.doc)&&Fm(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>_g(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>_g(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=vg(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=vg(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),super.destroy()}};function*bg(e){let t=Wd(e.restDecoder);for(let n=0;n<t;n++){let t=Wd(e.restDecoder),n=e.readClient(),r=Wd(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=Wd(e.restDecoder);yield new jv(Nh(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new Dv(Nh(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,Ov(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new q_(Nh(n,r),t),r+=t}}}}var xg=class{constructor(e,t){this.gen=bg(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===jv);return this.curr}},Sg=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Cg=e=>Tg(e,nh,oh),wg=(e,t)=>{if(e.constructor===q_){let{client:n,clock:r}=e.id;return new q_(Nh(n,r+t),e.length-t)}else if(e.constructor===jv){let{client:n,clock:r}=e.id;return new jv(Nh(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new Dv(Nh(r,i+t),null,Nh(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Tg=(e,t=ih,n=ch)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(zd(e))),i=r.map(e=>new xg(e,!0)),a=null,o=new n,s=new Sg(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===jv?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)Og(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===jv)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Og(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new jv(Nh(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===jv?a.struct.length-=t:n=wg(n,t)),a.struct.mergeWith(n)||(Og(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==jv;n=e.next())Og(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Og(s,a.struct,a.offset),a=null),kg(s),Xm(o,Km(r.map(e=>Zm(e)))),o.toUint8Array()},Eg=(e,t,n=ih,r=ch)=>{let i=xh(t),a=new r,o=new Sg(a),s=new n(zd(e)),c=new xg(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===jv){c.next();continue}if(e.id.clock+e.length>n)for(Og(o,e,Au(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Og(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return kg(o),Xm(a,Zm(s)),a.toUint8Array()},Dg=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:ld(e.encoder.restEncoder)}),e.encoder.restEncoder=od(),e.written=0)},Og=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Dg(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),pd(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},kg=e=>{Dg(e);let t=e.encoder.restEncoder;pd(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];pd(t,r.written),vd(t,r.restEncoder)}},Ag=(e,t,n,r)=>{let i=new n(zd(e)),a=new xg(i,!1),o=new r,s=new Sg(o);for(let e=a.curr;e!==null;e=a.next())Og(s,t(e),0);return kg(s),Xm(o,Zm(i)),o.toUint8Array()},jg=e=>Ag(e,Ef,ih,oh),Mg=`You must not compute changes after the event-handler fired.`,Ng=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=Pg(this.currentTarget,this.target)}deletes(e){return Wm(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Nd(Mg);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=vu(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=vu(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=vu(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Nd(Mg);let t=this.target,n=_u(),r=_u(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},Pg=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},Fg=()=>{Fm(`Invalid access: Add Yjs type to a document before reading data.`)},Ig=80,Lg=0,Rg=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Lg++}},zg=e=>{e.timestamp=Lg++},Bg=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Lg++},Vg=(e,t,n)=>{if(e.length>=Ig){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return Bg(r,t,n),r}else{let r=new Rg(t,n);return e.push(r),r}},Hg=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>Ou(t-e.index)<Ou(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,zg(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&Ou(n.index-i)<r.parent.length/Ig?(Bg(n,r,i),n):Vg(e._searchMarker,r,i)},Ug=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=Au(t,i.index+n))}},Wg=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;mu(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Ah(r._eH,n,t)},Gg=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Dh(),this._dEH=Dh(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Pd()}clone(){throw Pd()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Oh(this._eH,e)}observeDeep(e){Oh(this._dEH,e)}unobserve(e){kh(this._eH,e)}unobserveDeep(e){kh(this._dEH,e)}toJSON(){}},Kg=(e,t,n)=>{e.doc??Fg(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},qg=e=>{e.doc??Fg();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},Jg=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Yh(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},Yg=(e,t)=>{let n=0,r=e._start;for(e.doc??Fg();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},Xg=(e,t)=>{let n=[];return Yg(e,(r,i)=>{n.push(t(r,i,e))}),n},Zg=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},Qg=(e,t)=>{e.doc??Fg();let n=Hg(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},$g=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new Dv(Nh(o,$h(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new cv(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new Dv(Nh(o,$h(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new J_(new Uint8Array(n))),i.integrate(e,0);break;case eh:i=new Dv(Nh(o,$h(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new $_(n)),i.integrate(e,0);break;default:if(n instanceof Gg)i=new Dv(Nh(o,$h(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new bv(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},e_=()=>Nd(`Length exceeded!`),t_=(e,t,n,r)=>{if(n>t._length)throw e_();if(n===0)return t._searchMarker&&Ug(t._searchMarker,n,r.length),$g(e,t,null,r);let i=n,a=Hg(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&ig(e,Nh(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Ug(t._searchMarker,i,r.length),$g(e,t,o,r)},n_=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return $g(e,t,r,n)},r_=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=Hg(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&ig(e,Nh(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&ig(e,Nh(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw e_();t._searchMarker&&Ug(t._searchMarker,i,-a+r)},i_=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},a_=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new cv([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new cv([r]);break;case Uint8Array:s=new J_(r);break;case eh:s=new $_(r);break;default:if(r instanceof Gg)s=new bv(r);else throw Error(`Unexpected content type`)}new Dv(Nh(o,$h(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},o_=(e,t)=>{e.doc??Fg();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},s_=e=>{let t={};return e.doc??Fg(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},c_=(e,t)=>{e.doc??Fg();let n=e._map.get(t);return n!==void 0&&!n.deleted},l_=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&Yh(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},u_=e=>(e.doc??Fg(),Rm(e._map.entries(),e=>!e[1].deleted)),d_=class extends Ng{},f_=class e extends Gg{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Gg?e.clone():e)),t}get length(){return this.doc??Fg(),this._length}_callObserver(e,t){super._callObserver(e,t),Wg(this,e,new d_(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):hg(this.doc,n=>{t_(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):hg(this.doc,t=>{n_(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):hg(this.doc,n=>{r_(n,this,e,t)})}get(e){return Qg(this,e)}toArray(){return qg(this)}slice(e=0,t=this.length){return Kg(this,e,t)}toJSON(){return this.map(e=>e instanceof Gg?e.toJSON():e)}map(e){return Xg(this,e)}forEach(e){Yg(this,e)}[Symbol.iterator](){return Zg(this)}_write(e){e.writeTypeRef(pv)}},p_=e=>new f_,m_=class extends Ng{constructor(e,t,n){super(e,t),this.keysChanged=n}},h_=class e extends Gg{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof Gg?e.clone():e)}),t}_callObserver(e,t){Wg(this,e,new m_(this,e,t))}toJSON(){this.doc??Fg();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof Gg?r.toJSON():r}}),e}get size(){return[...u_(this)].length}keys(){return zm(u_(this),e=>e[0])}values(){return zm(u_(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return zm(u_(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Fg(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):hg(this.doc,t=>{i_(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):hg(this.doc,n=>{a_(n,this,e,t)}),t}get(e){return o_(this,e)}has(e){return c_(this,e)}clear(){this.doc===null?this._prelimContent.clear():hg(this.doc,e=>{this.forEach(function(t,n,r){i_(e,r,n)})})}_write(e){e.writeTypeRef(mv)}},g_=e=>new h_,__=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&Sf(e,t),v_=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&Fd(),this.right.content.constructor){case rv:this.right.deleted||S_(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}},y_=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case rv:t.right.deleted||S_(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&ig(e,Nh(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},b_=(e,t,n,r)=>{let i=new Map,a=r?Hg(t,n):null;return a?y_(e,new v_(a.p.left,a.p,a.index,i),n-a.index):y_(e,new v_(null,t._start,0,i),n)},x_=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===rv&&__(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new Dv(Nh(a,$h(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new rv(o,r));l.integrate(e,0),n.right=l,n.forward()})},S_=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},C_=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===rv&&__(t[e.right.content.key]??null,e.right.content.value));)e.forward()},w_=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!__(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Dv(Nh(a,$h(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new rv(s,c)),n.right.integrate(e,0),n.forward()}}return o},T_=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;C_(n,i);let s=w_(e,t,n,i),c=r.constructor===String?new uv(r):r instanceof Gg?new bv(r):new tv(r),{left:l,right:u,index:d}=n;t._searchMarker&&Ug(t._searchMarker,n.index,c.getLength()),u=new Dv(Nh(o,$h(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),x_(e,t,n,s)},E_=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;C_(n,i);let s=w_(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===rv));){if(!n.right.deleted)switch(n.right.content.constructor){case rv:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(__(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&ig(e,Nh(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
4
4
|
`;n.right=new Dv(Nh(o,$h(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new uv(i)),n.right.integrate(e,0),n.forward()}x_(e,t,n,s)},D_=(e,t,n,r,i)=>{let a=t,o=fu();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===rv){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case rv:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&S_(i,n);break}}}t=t.right}return s},O_=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===rv){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},k_=e=>{let t=0;return hg(e.doc,n=>{let r=e._start,i=e._start,a=fu(),o=pu(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case rv:S_(o,i.content);break;default:t+=D_(n,r,i,a,o),a=pu(o),r=i;break}i=i.right}}),t},A_=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&sg(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===rv&&e.constructor!==q_&&t.add(e.parent)})}hg(n,n=>{Hm(e,e.deleteSet,e=>{if(e instanceof q_||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===rv?t.add(r):O_(n,e)});for(let e of t)k_(e)})},j_=(e,t,n)=>{let r=n,i=pu(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case bv:case tv:case uv:n<t.right.length&&ig(e,Nh(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&D_(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&Ug(o._searchMarker,t.index,-r+n),t},M_=class extends Ng{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){return this._changes===null&&(this._changes={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set}),this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];hg(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},yf(o)||(e.attributes=hf({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case bv:case tv:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case uv:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case rv:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(__(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),__(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;__(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(__(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),S_(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},N_=class e extends Gg{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Fg(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new M_(this,e,t);Wg(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Fg();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===uv&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):hg(this.doc,n=>{let r=new v_(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
5
5
|
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&T_(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&j_(n,r,a.delete):E_(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??Fg();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(Yh(s,e)||t!==void 0&&Yh(s,t))switch(s.content.constructor){case uv:{let r=i.get(`ychange`);e!==void 0&&!Yh(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!Yh(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case bv:case tv:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case rv:Yh(s,e)&&(c(),S_(i,s.content));break}s=s.right}c()};return e||t?hg(a,n=>{e&&Xh(n,e),t&&Xh(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):hg(r,r=>{let i=b_(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),T_(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):hg(r,r=>{let i=b_(r,this,e,!n);T_(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):hg(n,n=>{j_(n,b_(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):hg(r,r=>{let i=b_(r,this,e,!1);i.right!==null&&E_(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):hg(this.doc,t=>{i_(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):hg(this.doc,n=>{a_(n,this,e,t)})}getAttribute(e){return o_(this,e)}getAttributes(){return s_(this)}_write(e){e.writeTypeRef(hv)}},P_=e=>new N_,F_=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Fg()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===R_||t.constructor===I_)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},I_=class e extends Gg{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Gg?e.clone():e)),t}get length(){return this.doc??Fg(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new F_(this,e)}querySelector(e){e=e.toUpperCase();let t=new F_(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),bu(new F_(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Wg(this,e,new B_(this,t,e))}toString(){return Xg(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),Yg(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):hg(this.doc,n=>{t_(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)hg(this.doc,n=>{let r=e&&e instanceof Gg?e._item:e;$g(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw Nd(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):hg(this.doc,n=>{r_(n,this,e,t)})}toArray(){return qg(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Qg(this,e)}slice(e=0,t=this.length){return Kg(this,e,t)}forEach(e){Yg(this,e)}_write(e){e.writeTypeRef(_v)}},L_=e=>new I_,R_=class e extends I_{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return _f(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof Gg?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):hg(this.doc,t=>{i_(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):hg(this.doc,n=>{a_(n,this,e,t)})}getAttribute(e){return o_(this,e)}hasAttribute(e){return c_(this,e)}getAttributes(e){return e?l_(this,e):s_(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return Yg(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(gv),e.writeKey(this.nodeName)}},z_=e=>new R_(e.readKey()),B_=class extends Ng{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},V_=class e extends h_{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(vv),e.writeKey(this.hookName)}},H_=e=>new V_(e.readKey()),U_=class e extends N_{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(yv)}},W_=e=>new U_,G_=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Pd()}mergeWith(e){return!1}write(e,t,n){throw Pd()}integrate(e,t){throw Pd()}},K_=0,q_=class extends G_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),eg(e.doc.store,this)}write(e,t){e.writeInfo(K_),e.writeLen(this.length-t)}getMissing(e,t){return null}},J_=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw Pd()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},Y_=e=>new J_(e.readBuf()),X_=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){qm(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},Z_=e=>new X_(e.readLen()),Q_=(e,t)=>new eh({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),$_=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(Q_(this.doc.guid,this.opts))}splice(e){throw Pd()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},ev=e=>new $_(Q_(e.readString(),e.readAny())),tv=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw Pd()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},nv=e=>new tv(e.readJSON()),rv=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw Pd()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},iv=e=>new rv(e.readKey(),e.readJSON()),av=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},ov=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new av(n)},sv=Ff(`node_env`)===`development`,cv=class e{constructor(e){this.arr=e,sv&&wf(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},lv=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new cv(n)},uv=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},dv=e=>new uv(e.readString()),fv=[p_,g_,P_,z_,L_,H_,W_],pv=0,mv=1,hv=2,gv=3,_v=4,vv=5,yv=6,bv=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw Pd()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},xv=e=>new bv(fv[e.readTypeRef()](e)),Sv=(e,t)=>{let n=t,r=0,i;do r>0&&(n=Nh(n.client,n.clock+r)),i=ng(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Dv);return{item:i,diff:r}},Cv=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},wv=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Dv(Nh(r,i+n),t,Nh(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=Nh(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},Tv=(e,t)=>Su(e,e=>Wm(e.deletions,t)),Ev=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return ig(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Ev(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=ig(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:ig(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:ig(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||Wm(r,d.right.id)||Tv(a.undoStack,d.right.id)||Tv(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=ig(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=Nh(c,$h(s,c)),h=new Dv(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,Cv(h,!0),h.integrate(e,0),h},Dv=class e extends G_{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=$h(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=$h(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===jh&&this.id.client!==this.parent.client&&this.parent.clock>=$h(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=ag(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=ig(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===q_||this.right&&this.right.constructor===q_)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===jh){let e=ng(n,this.parent);e.constructor===q_?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=ag(e,e.doc.store,Nh(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),Mh(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(Mh(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(ng(e.doc.store,n.origin)))r.has(ng(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),eg(e.doc.store,this),this.content.integrate(e,this),ug(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new q_(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:Nh(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Mh(e.origin,this.lastId)&&this.right===e&&Mh(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),qm(e.deleteSet,this.id.client,this.id.clock,this.length),ug(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw Fd();this.content.gc(e),t?og(e,this,new q_(this.id,this.length)):this.content=new X_(this.length)}write(e,t){let n=t>0?Nh(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=Ph(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===jh?(e.writeParentInfo(!1),e.writeLeftID(t)):Fd();i!==null&&e.writeString(i)}this.content.write(e,t)}},Ov=(e,t)=>kv[t&31](e),kv=[()=>{Fd()},Z_,ov,Y_,dv,nv,iv,xv,lv,ev,()=>{Fd()}],Av=10,jv=class extends G_{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){Fd()}write(e,t){e.writeInfo(Av),pd(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Mv=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Nv=`__ $YJS$ __`;Mv[Nv]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Mv[Nv]=!0;var Pv=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},Fv=/[\uD800-\uDBFF]/,Iv=/[\uDC00-\uDFFF]/,Lv=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&Fv.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&&Iv.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},Rv=(e,t)=>e>>>t|e<<32-t,zv=e=>Rv(e,2)^Rv(e,13)^Rv(e,22),Bv=e=>Rv(e,6)^Rv(e,11)^Rv(e,25),Vv=e=>Rv(e,7)^Rv(e,18)^e>>>3,Hv=e=>Rv(e,17)^Rv(e,19)^e>>>10,Uv=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]),Wv=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Gv=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Wv),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=Hv(t[e-2])+t[e-7]+Vv(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+Bv(o)+(o&s^~o&c)+Uv[e]+t[e]>>>0,d=zv(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/Wu,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}},Kv=e=>new Gv().digest(e),qv=new W(`y-sync`),Jv=new W(`y-undo`),Yv=new W(`yjs-cursor`),Xv=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},Zv=e=>Bf(Xv(Kv(Hf(e)))),Qv=()=>({mapping:new Map,isOMark:new Map}),$v=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!Wm(t.ds,e.id),ey=[{light:`#ecd44433`,dark:`#ecd444`}],ty=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=_u();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,rf(t))}return e.get(n)},ny=(e,{colors:t=ey,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new oy(e,a),c=new U({props:{editable:e=>{let t=qv.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:qv,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(qv);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)&&bm(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=Jv.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)},qv)})}},destroy:()=>{s.destroy()}})});return c},ry=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new p(e.doc));else if(t.type===`node`){let r=Fy(n.doc,n.type,t.anchor,n.mapping);e.setSelection(iy(e,r))}else{let r=Fy(n.doc,n.type,t.anchor,n.mapping),i=Fy(n.doc,n.type,t.head,n.mapping);r!==null&&i!==null&&e.setSelection(F.between(e.doc.resolve(r),e.doc.resolve(i)))}},iy=(e,t)=>{let n=e.doc.resolve(t);return n.nodeAfter?Ct.create(e.doc,t):F.near(n)},ay=(e,t)=>({type:t.selection.jsonID,anchor:Ny(t.selection.anchor,e.type,e.mapping),head:Ny(t.selection.head,e.type,e.mapping)}),oy=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=Pv(),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=ay(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()?(Af&&this._domSelectionInView===null&&(bm(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=im.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||=qh(Jm(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(qv,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>cy(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Pe(yn.from(e),0,0));t.setMeta(qv,{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=>cy(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Pe(yn.from(t),0,0));if(e){let t=ku(Au(e.anchor,0),n.doc.content.size),r=ku(Au(e.head,0),n.doc.content.size);n.setSelection(F.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(qv,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=Jh(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&Fd(),r=new eh({gc:!1}),hh(r,t),t=Jh(r),hh(r,e),e=Jh(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[tg(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{Hm(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:ty(n.colorMapping,n.colors,r)}},s=Jg(i,new Kh(t.ds,e.sv)).map(n=>!n._item.deleted||$v(n._item,e)||$v(n._item,t)?cy(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 Pe(yn.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(qv,{isChangeOrigin:!0}))},qv)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=qv.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);Hm(t,t.deleteSet,e=>{if(e.constructor===Dv){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=>sy(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Pe(yn.from(n),0,0));ry(r,this.beforeTransactionSelection,this),r=r.setMeta(qv,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof yg}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{Ey(this.doc,this.type,e,this),this.beforeTransactionSelection=ay(this,this.prosemirrorView.state)},qv)}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))}},sy=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof R_)return cy(e,t,n,r,i,a);throw Pd()}return o},cy=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof R_){let s=sy(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof N_&&!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=ly(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):Jg(e,new Kh(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&($v(e._item,r)?$v(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}},ly=(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,wy(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},uy=(e,t)=>{let n=new U_,r=e.map(e=>({insert:e.text,attributes:Ty(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},dy=(e,t)=>{let n=new R_(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,hy(e).map(e=>fy(e,t))),t.mapping.set(n,e),n},fy=(e,t)=>e instanceof Array?uy(e,t):dy(e,t),py=e=>typeof e==`object`&&!!e,my=(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||py(o)&&py(s)&&my(o,s)}return r},hy=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},gy=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&gf(e.attributes||{}).length===t[n].marks.length&&bf(e.attributes,(e,r)=>{let i=Cy(r),a=t[n].marks;return a.find(e=>e.type.name===i)?my(e,a.find(e=>e.type.name===i)?.attrs):!1}))},_y=(e,t)=>{if(e instanceof R_&&!(t instanceof Array)&&Dy(e,t)){let n=hy(t);return e._length===n.length&&my(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>_y(e,n[t]))}return e instanceof U_&&t instanceof Array&&gy(e,t)},vy=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),yy=(e,t,n)=>{let r=e.toArray(),i=hy(t),a=i.length,o=r.length,s=ku(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(vy(n.mapping.get(e),t))u=!0;else if(!_y(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(vy(n.mapping.get(e),t))u=!0;else if(!_y(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},by=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof uv?t+=n.content.str:n.content instanceof rv&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},xy=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=by(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,Ty(e.marks,n))})),{insert:o,remove:s,index:c}=Lv(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})))},Sy=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Cy=e=>Sy.exec(e)?.[1]??e,wy=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(Cy(r),e[r]));return n},Ty=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=mu(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${Zv(e.toJSON())}`:e.type.name]=e.attrs}}),n},Ey=(e,t,n,r)=>{if(t instanceof R_&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof R_){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=hy(n),a=i.length,o=t.toArray(),s=o.length,c=ku(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!vy(r.mapping.get(e),t))if(_y(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(!vy(r.mapping.get(e),t))if(_y(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 U_&&c instanceof Array)gy(n,c)||xy(n,c,r),l+=1;else{let i=n instanceof R_&&Dy(n,c),a=d instanceof R_&&Dy(d,f);if(i&&a){let e=yy(n,c,r),t=yy(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(Ey(e,n,c,r),l+=1):a?(Ey(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[fy(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof U_?(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(fy(i[t],r));t.insert(l,e)}},qv)},Dy=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,Oy=null,ky=class{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=qv.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)}}},Ay=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=Oy;Oy=null;let n=[];return t.forEach((e,t)=>{e.forEach((e,r)=>{n.push(new ky(t,r,e))})}),new e(n)}},jy=(e=Ay.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()||bm(0,()=>jy(e,!0));return}throw r}n=!1,e.dequeueFirst()}},My=(e,t,n)=>{Oy||(Oy=new Map,bm(0,jy)),mu(Oy,e,fu).set(t,n)},Ny=(e,t,n)=>{if(e===0)return Hh(t,0,-1);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof U_){if(r._length>=e)return Hh(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 Ih(r._item===null?null:r._item.id,r._item===null?Ph(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 Ih(r._item===null?null:r._item.id,r._item===null?Ph(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 Fd();if(e===0&&r.constructor!==U_&&r!==t)return Py(r._item.parent,r._item)}return Hh(t,t._length,-1)},Py=(e,t)=>{let n=null,r=null;return e._item===null?r=Ph(e):n=Nh(e._item.id.client,e._item.id.clock),new Ih(n,r,t.id)},Fy=(e,t,n,r)=>{let i=Wh(n,e);if(i===null||i.type!==t&&!Fh(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===U_)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 U_?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 U_?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1},Iy=(e,t)=>{let n=Qv(),r=e.toArray().map(e=>cy(e,t,n)).filter(e=>e!==null);return{doc:t.topNodeType.create(null,yn.fromArray(r)),meta:n,mapping:n.mapping}},Ly=(e,t,n)=>e!==t,Ry=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},zy=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),By=/^#[0-9a-fA-F]{6}$/,Vy=(e,t,n,r,i)=>{let a=qv.getState(e);if(a==null||a.doc==null||a.binding==null)return pe.create(e.doc,[]);let o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?pe.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`:By.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=Fy(o,a.type,Rh(t.cursor.anchor),a.binding.mapping),u=Fy(o,a.type,Rh(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=Au(e.doc.content.size-1,0);l=ku(l,t),u=ku(u,t),s.push(S.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=ku(l,u),o=Au(l,u);s.push(S.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),pe.create(e.doc,s))},Hy=(e,{awarenessStateFilter:t=Ly,cursorBuilder:n=Ry,selectionBuilder:r=zy,getSelection:i=e=>e.selection}={},a=`cursor`)=>new U({key:Yv,state:{init(i,a){return Vy(a,e,t,n,r)},apply(i,a,o,s){let c=qv.getState(s),l=i.getMeta(Yv);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?Vy(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>Yv.getState(e)},view:t=>{let n=()=>{t.docView&&My(t,Yv,{awarenessUpdated:!0})},r=()=>{let n=qv.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=Ny(o.anchor,n.type,n.binding.mapping),c=Ny(o.head,n.type,n.binding.mapping);(r.cursor==null||!Gh(Rh(r.cursor.anchor),s)||!Gh(Rh(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&Fy(n.doc,n.type,Rh(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)}}}}),Uy=e=>{let t=Jv.getState(e).undoManager;if(t!=null)return t.undo(),!0},Wy=e=>{let t=Jv.getState(e).undoManager;if(t!=null)return t.redo(),!0},Gy=new Set([`paragraph`]),Ky=(e,t)=>!(e instanceof Dv)||!(e.content instanceof bv)||!(e.content.type instanceof N_||e.content.type instanceof R_&&t.has(e.content.type.nodeName))||e.content.type._length===0,qy=({protectedNodes:e=Gy,trackedOrigins:t=[],undoManager:n=null}={})=>new U({key:Jv,state:{init:(r,i)=>{let a=qv.getState(i),o=n||new yg(a.type,{trackedOrigins:new Set([qv].concat(t)),deleteFilter:t=>Ky(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=qv.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:ay(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=qv.getState(e.state),n=Jv.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,Jv.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}});function Jy(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=Bt(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function Yy(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,`
|
|
6
|
-
`);return/\s/.test(n)}):!1}var Xy=new W(`suggestion`);function Zy({pluginKey:e=Xy,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=Jy,shouldShow:g,shouldResetDismissed:_}){let v,y=p?.(),b=r&&!i,x=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},C=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,w=({match:e,dismissedRange:n,state:r,transaction:i})=>_?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:b})?!1:b?e.range.from===n.from:e.range.from===n.from&&!Yy(i);function T(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>d({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:C(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let E=new U({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,g=p||u&&h,_=h||u,b=m||u&&h;if(!g&&!_&&!b)return;let x=b&&!g?c:l,S=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);v={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:S,clientRect:C(e,S)},g&&((r=y?.onBeforeStart)==null||r.call(y,v)),_&&((i=y?.onBeforeUpdate)==null||i.call(y,v)),(_||g)&&(v.items=await f({editor:t,query:x.query})),b&&((a=y?.onExit)==null||a.call(y,v)),_&&((o=y?.onUpdate)==null||o.call(y,v)),g&&((s=y?.onStart)==null||s.call(y,v))},destroy:()=>{var e;v&&((e=y?.onExit)==null||e.call(y,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(s,c,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=s,{empty:_,from:v}=p,y={...c},b=s.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=c.active?{...c.range}:c.dismissedRange,y;if(y.composing=f,s.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:s.mapping.map(y.dismissedRange.from),to:s.mapping.map(y.dismissedRange.to)}),d&&(_||t.view.composing)){(v<c.range.from||v>c.range.to)&&!f&&!c.composing&&(y.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:u,range:e.range,isActive:c.active})&&(!g||g({editor:t,range:e.range,query:e.query,text:e.text,transaction:s}))?(y.dismissedRange!==null&&!w({match:e,dismissedRange:y.dismissedRange,state:u,transaction:s})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=c.decorationId?c.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=E.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=E.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),T(t,e),!0}return(y?.onKeyDown)?.call(y,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=E.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),pe.create(e.doc,[S.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return E}var Qy=Zy;function $y(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function eb(e){if(e.kind===`create`){let t=e.value;return G._({id:`XPqe3B`,values:{tagValue:t}})}let t=G._({id:`pckX1A`,values:{0:e.count}}),n=e.value;return G._({id:`m2T1Xj`,values:{tagValue:n,uses:t}})}function tb(e){let t=(0,J.c)(38),{items:n,query:r,selectedIndex:a,onSelect:s,onHover:c,loading:l,error:u}=e,d=l===void 0?!1:l,f=u===void 0?null:u,{_:p}=i(),m=(0,Y.useRef)(null),h=(0,Y.useId)(),g=a>=0&&a<n.length?`${h}-option-${a}`:void 0,_,v;t[0]===a?(_=t[1],v=t[2]):(_=()=>{let e=m.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(a);t&&t.scrollIntoView({block:`nearest`})},v=[a],t[0]=a,t[1]=_,t[2]=v),(0,Y.useEffect)(_,v);let y=nb;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,X.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,X.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,X.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=a>=0&&a<n.length?n[a]: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?eb(b):``,t[15]=b,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,X.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,X.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]!==s||t[25]!==a){let e;t[27]!==h||t[28]!==c||t[29]!==s||t[30]!==a?(e=(e,t)=>{let n=t===a,r=$y(e),i=e.kind===`create`;return(0,X.jsxs)(`button`,{id:`${h}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,"data-testid":i?`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(),s(e)},onPointerMove:c?()=>c(t):void 0,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`#`}),(0,X.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.value}),i?(0,X.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,X.jsx)(o,{id:`isRobC`})}):(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:e.count})]},r)},t[27]=h,t[28]=c,t[29]=s,t[30]=a,t[31]=e):e=t[31],E=n.map(e),t[21]=n,t[22]=h,t[23]=c,t[24]=s,t[25]=a,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,X.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 nb(e){return e.preventDefault()}var rb=new WeakMap;function ib(e,t){rb.set(e,t)}function ab(e){return rb.get(e)??!1}function ob(e,t){let n=document.createElement(`div`);n.style.position=`fixed`,n.style.zIndex=`50`,n.style.visibility=`hidden`,document.body.appendChild(n);let r={getBoundingClientRect:()=>e()?.clientRect?.()??new DOMRect,get contextElement(){return e()?.editor.view.dom}},i=!1,a=!1,o=()=>{n.isConnected&&(n.style.removeProperty(`--suggestion-menu-max-height`),R(r,n,{placement:`bottom-start`,middleware:[be(4),Be(),c({padding:8}),lt({apply({availableHeight:e}){n.isConnected&&n.style.setProperty(`--suggestion-menu-max-height`,`${Math.min(e,window.innerHeight*.4)}px`)}})]}).then(({x:e,y:t})=>{n.isConnected&&(n.style.left=`${e}px`,n.style.top=`${t}px`,i&&!a&&(n.style.removeProperty(`visibility`),a=!0))}).catch(e=>{n.isConnected&&console.warn(`[${t}] computePosition failed`,e)}))};return{popup:n,doPosition:o,startAutoUpdate:()=>Ut(r,n,o),reveal:()=>{a||(i=!0,o())}}}function sb(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var cb=new W(`tagSuggestion`),lb=8,ub=/^[a-zA-Z][\w/-]*$/;async function db(){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 fb(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 pb(e,t){let n=fb(e,t).slice(0,lb).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&ub.test(r)&&!e.some(e=>e.name===r)&&n.push({kind:`create`,value:r}),n}function mb(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 hb(e){let t=[],n=!1,r=null,i=null;return Qy({editor:e,pluginKey:cb,char:`#`,allowedPrefixes:null,findSuggestionMatch:mb,allow:({editor:e})=>!ab(e),items:async({query:e})=>{if(!n){r||=db();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 pb(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!ub.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=ob(()=>a,`tag-suggestion`);s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new au(tb,{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&&ub.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){sb(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var gb=1,_b=.9,vb=.8,yb=.17,bb=.1,xb=.999,Sb=.9999,Cb=.99,wb=/[\\\/_+.#"@\[\(\{&]/,Tb=/[\\\/_+.#"@\[\(\{&]/g,Eb=/[\s-]/,Db=/[\s-]/g;function Ob(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?gb:Cb;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=Ob(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=gb:wb.test(e.charAt(l-1))?(d*=vb,p=e.slice(i,l-1).match(Tb),p&&i>0&&(d*=xb**+p.length)):Eb.test(e.charAt(l-1))?(d*=_b,m=e.slice(i,l-1).match(Db),m&&i>0&&(d*=xb**+m.length)):(d*=yb,i>0&&(d*=xb**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Sb)),(d<bb&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Ob(e,t,n,r,l+1,a+2,o),f*bb>d&&(d=f*bb)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function kb(e){return e.toLowerCase().replace(Db,` `)}function Ab(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Ob(e,t,kb(e),kb(t),0,0,{})}var jb=`[cmdk-group=""]`,Mb=`[cmdk-group-items=""]`,Nb=`[cmdk-group-heading=""]`,Pb=`[cmdk-item=""]`,Fb=`${Pb}:not([aria-disabled="true"])`,Ib=`cmdk-item-select`,Lb=`data-value`,Rb=(e,t,n)=>Ab(e,t,n),zb=Y.createContext(void 0),Bb=()=>Y.useContext(zb),Vb=Y.createContext(void 0),Hb=()=>Y.useContext(Vb),Ub=Y.createContext(void 0),Wb=Y.forwardRef((e,t)=>{let n=ix(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=ix(()=>new Set),i=ix(()=>new Map),a=ix(()=>new Map),o=ix(()=>new Set),s=nx(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Fn(),y=Fn(),b=Fn(),x=Y.useRef(null),S=sx();rx(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),rx(()=>{S(6,k)},[]);let C=Y.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=Y.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??Rb;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(Mb);t?t.appendChild(e.parentElement===t?e:e.closest(`${Mb} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Mb} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${jb}[${Lb}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Lb);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(jb)?.querySelector(Nb))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Pb}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Fb)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Lb))}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(Lb))}function P(e){let t=A()?.closest(jb),n;for(;t&&!n;)t=e>0?ex(t,jb):tx(t,jb),n=t?.querySelector(Fb);n?C.setState(`value`,n.getAttribute(Lb)):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 Y.createElement(jn.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(Ib);t.dispatchEvent(e)}}}}},Y.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:ux},c),lx(e,e=>Y.createElement(Vb.Provider,{value:C},Y.createElement(zb.Provider,{value:w},e))))}),Gb=Y.forwardRef((e,t)=>{let n=Fn(),r=Y.useRef(null),i=Y.useContext(Ub),a=Bb(),o=nx(e),s=o.current?.forceMount??i?.forceMount;rx(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=ox(n,r,[e.value,e.children,r],e.keywords),l=Hb(),u=ax(e=>e.value&&e.value===c.current),d=ax(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Y.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Ib,f),()=>t.removeEventListener(Ib,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 Y.createElement(jn.div,{ref:Bn(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)}),Kb=Y.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Fn(),s=Y.useRef(null),c=Y.useRef(null),l=Fn(),u=Bb(),d=ax(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);rx(()=>u.group(o),[]),ox(o,s,[e.value,e.heading,c]);let f=Y.useMemo(()=>({id:o,forceMount:i}),[i]);return Y.createElement(jn.div,{ref:Bn(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Y.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),lx(e,e=>Y.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Y.createElement(Ub.Provider,{value:f},e))))}),qb=Y.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Y.useRef(null),a=ax(e=>!e.search);return!n&&!a?null:Y.createElement(jn.div,{ref:Bn(i,t),...r,"cmdk-separator":``,role:`separator`})}),Jb=Y.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Hb(),o=ax(e=>e.search),s=ax(e=>e.selectedItemId),c=Bb();return Y.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Y.createElement(jn.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)}})}),Yb=Y.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Y.useRef(null),o=Y.useRef(null),s=ax(e=>e.selectedItemId),c=Bb();return Y.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)}}},[]),Y.createElement(jn.div,{ref:Bn(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},lx(e,e=>Y.createElement(`div`,{ref:Bn(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Xb=Y.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Y.createElement(er,{open:n,onOpenChange:r},Y.createElement(Kn,{container:o},Y.createElement(Gn,{"cmdk-overlay":``,className:i}),Y.createElement(ir,{"aria-label":e.label,"cmdk-dialog":``,className:a},Y.createElement(Wb,{ref:t,...s}))))}),Zb=Y.forwardRef((e,t)=>ax(e=>e.filtered.count===0)?Y.createElement(jn.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Qb=Y.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Y.createElement(jn.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},lx(e,e=>Y.createElement(`div`,{"aria-hidden":!0},e)))}),$b=Object.assign(Wb,{List:Yb,Item:Gb,Input:Jb,Group:Kb,Separator:qb,Dialog:Xb,Empty:Zb,Loading:Qb});function ex(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function tx(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function nx(e){let t=Y.useRef(e);return rx(()=>{t.current=e}),t}var rx=typeof window>`u`?Y.useEffect:Y.useLayoutEffect;function ix(e){let t=Y.useRef();return t.current===void 0&&(t.current=e()),t}function ax(e){let t=Hb(),n=()=>e(t.snapshot());return Y.useSyncExternalStore(t.subscribe,n,n)}function ox(e,t,n,r=[]){let i=Y.useRef(),a=Bb();return rx(()=>{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(Lb,s),i.current=s}),i}var sx=()=>{let[e,t]=Y.useState(),n=ix(()=>new Map);return rx(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function cx(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function lx({asChild:e,children:t},n){return e&&Y.isValidElement(t)?Y.cloneElement(cx(t),{ref:t.ref},n(t.props.children)):n(t)}var ux={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function dx(e){let t=(0,J.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=Sn(`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,X.jsx)($b,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function fx(e){let t=(0,J.c)(34),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({title:o,description:s,children:n,className:r,showCloseButton:c,commandProps:i,...a}=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);let l=o===void 0?`Command Palette`:o,u=s===void 0?`Search for a command to run`:s,d=c===void 0?!0:c,f;t[8]===i?f=t[9]:(f=i??{},t[8]=i,t[9]=f);let p,m;t[10]===f?(p=t[11],m=t[12]):({className:p,...m}=f,t[10]=f,t[11]=p,t[12]=m);let h;t[13]===r?h=t[14]:(h=Sn(`top-[12vh] translate-y-0 overflow-hidden p-0`,r),t[13]=r,t[14]=h);let g;t[15]===l?g=t[16]:(g=(0,X.jsx)(Wn,{className:`sr-only`,children:l}),t[15]=l,t[16]=g);let _;t[17]===u?_=t[18]:(_=(0,X.jsx)(Hn,{className:`sr-only`,children:u}),t[17]=u,t[18]=_);let v;t[19]===p?v=t[20]:(v=Sn(`[&_[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`,p),t[19]=p,t[20]=v);let y;t[21]!==n||t[22]!==m||t[23]!==v?(y=(0,X.jsx)(dx,{className:v,...m,children:n}),t[21]=n,t[22]=m,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==y?(b=(0,X.jsxs)(Yn,{className:h,showCloseButton:d,children:[g,_,y]}),t[25]=d,t[26]=h,t[27]=g,t[28]=_,t[29]=y,t[30]=b):b=t[30];let x;return t[31]!==a||t[32]!==b?(x=(0,X.jsx)(rr,{...a,children:b}),t[31]=a,t[32]=b,t[33]=x):x=t[33],x}function px(e){let t=(0,J.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,X.jsx)(Fa,{className:`size-4 shrink-0 opacity-50`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=Sn(`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,X.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex items-center gap-2 border-b px-3`,children:[i,(0,X.jsx)($b.Input,{"data-slot":`command-input`,className:a,...r})]}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function mx(e){let t=(0,J.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=Sn(`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,X.jsx)($b.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function hx(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)($b.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),t[0]=e,t[1]=n),n}function gx(e){let t=(0,J.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=Sn(`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,X.jsx)($b.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _x(e){let t=(0,J.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=Sn(`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,X.jsx)($b.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vx(e){let t=(0,J.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=Sn(`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,X.jsx)(`span`,{"data-slot":`command-shortcut`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function yx(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}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:w(n)??t}}function bx(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 xx=new Map,Sx=null;function Cx(){return Ac(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function wx(){if(Sx!==null)return;let e=Math.max(50,Math.floor(Cx()/2));Sx=setTimeout(()=>{Sx=null,Tx(Date.now()),xx.size>0&&wx()},e)}function Tx(e){let t=Cx();for(let[n,r]of xx)e-r.emittedAt>=t&&(xx.delete(n),Z.count(`ok/sidebar/prewarm`,{hit:!1}))}function Ex(e,t,n=Date.now()){xx.has(e)&&Z.count(`ok/sidebar/prewarm`,{hit:!1}),xx.set(e,{poolEventId:t,emittedAt:n}),wx()}function Dx(e,t,n=Date.now()){let r=xx.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=Cx()?!1:(xx.delete(e),Z(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),Z.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}z({event:Wt(`ok-branch-switched-clear-failed`),branch:Ve(),docName:Ve(),reason:Ve()});async function Ox(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()}var kx=null,Ax=new Set;function jx(){return kx}function Mx(e){let t=e!==null&&e.length>0?e:null;if(t!==kx){kx=t;for(let e of Ax)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function Nx(e){return Ax.add(e),()=>{Ax.delete(e)}}function Px(){return(0,Y.useSyncExternalStore)(Nx,jx,jx)}function Fx(e){let t=!1;return()=>{t?e():t=!0}}function Ix(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 Lx(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=Ot.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),Mx(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&(Ox(e,i.data.currentBranch),zt(i.data.currentBranch)),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=Ix(n)}catch{}e.observeDiskAckBatch(t)}}async function Rx(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,paneTarget:typeof r.paneTarget==`string`?r.paneTarget:null}}}function zx(e){return qx(e,Ht)}function Bx(e){return qx(e,vt)}function Vx(e){return qx(e,on)}function Hx(e){return qx(e,pt)}function Ux(e){return qx(e,st)}function Wx(e){let t=qx(e,Nt);if(!t)return null;try{return{docName:t.docName,sv:Gx(t.sv)}}catch{return null}}function Gx(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 Kx(e,t){let n=Bx(e);if(n){t.onServerInfo?.(n);return}let r=Vx(e);if(r){t.onBranchSwitched?.(r);return}let i=Wx(e);if(i){t.onDiskAck?.(i);return}let a=zx(e);if(a){t.onDerivedView?.(a);return}let o=Hx(e);if(o){t.onConfigValidationRejected?.(o);return}let s=Ux(e);if(s){t.onConfigIgnoreNestedError?.(s);return}t.onUnknown?.(e)}function qx(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function Jx(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function Yx(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function Xx(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var Zx=2e3,Qx=15e3;function $x(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??Zx,r=e.maxDelayMs??Qx,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 eS(){let e=(0,J.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,Y.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,Y.useRef)(i),[o,s]=(0,Y.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=Yx(window);if(t){r(Xx(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(Xx(t))});return()=>{n()}}let n=$x({fetchConfig:Rx,fallbackUrl:Jx,now:Date.now,setTimeout:iS,clearTimeout:rS,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,Y.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(nS),s(tS)},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 tS(e){return e+1}function nS(e){return{...e,terminal:!1,lastError:null}}function rS(e){return globalThis.clearTimeout(e)}function iS(e,t){return globalThis.setTimeout(e,t)}var aS=new Map,oS=new Set;function sS(){for(let e of oS)e()}function cS(e,t){aS.set(e,t),sS()}function lS(e,t){aS.get(e)===t&&(aS.delete(e),sS())}function uS(e){return aS.get(e)??null}function dS(e){return oS.add(e),()=>oS.delete(e)}var fS=new Map;function pS(e){return fS.get(e)}function mS(e,t){fS.set(e,t)}function hS(e){fS.delete(e)}var gS=`open-knowledge-app`,_S=new Map,vS=new Set,yS=1024,bS=1024;function xS(){return fr.getTracer(gS)}function SS(e,t,n){if(vS.has(e))return null;let r=_S.get(e);if(r)return r;if(_S.size>=bS){let e=_S.keys().next().value;if(e!==void 0){let t=_S.get(e);_S.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:xS().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return _S.set(e,i),i}function CS(e,t,n,r,i){try{let a=SS(e,n,r),o=a?fr.setSpan(pr.active(),a.span):pr.active();xS().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 wS(e,t){try{let n=_S.get(e);if(n&&(_S.delete(e),n.span.end(t??Date.now())),!vS.has(e)){if(vS.size>=yS){let e=vS.values().next().value;e!==void 0&&vS.delete(e)}vS.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var TS=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function ES(){return Ac(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function DS(e){e.stalledHandle!==null&&(clearTimeout(e.stalledHandle),e.stalledHandle=null)}function OS(e,t,n){if(e.stalledMarkEmitted)return;e.stalledMarkEmitted=!0;let r=n-e.createdAt;Z(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var kS=new Map,AS=new Set;function jS(e){AS.add(e);for(let[t,n]of kS)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{AS.delete(e)}}function MS(e,t){for(let n of AS)try{n(e,t.mountId)}catch{}}var NS=!1;function PS(){typeof document>`u`||document.visibilityState===`visible`&&LS(Date.now())}function FS(){NS||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,PS),NS=!0)}function IS(){NS&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,PS),NS=!1))}function LS(e){let t=ES();for(let[n,r]of kS)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(OS(r,n,e),MS(n,r))}function RS(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=kS.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||(OS(d,t,Date.now()),MS(t,d))},ES()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,DS(d),d.preMountEditor&&=(HS(t,d.preMountEditor,`aborted`),null),kS.delete(t),kS.size===0&&IS(),Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),l(new TS(t)),wS(d.mountId))}),kS.set(t,d),FS(),Z(`ok/mount/create`,{docName:t,mountId:d.mountId}),US({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:c,rejectFn:l}).catch(e=>{if(d.preMountEditor&&=(HS(t,d.preMountEditor,`backstop`),null),d.settled){Z(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,DS(d);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`}),l(n),wS(d.mountId)}),u}function zS(e){return kS.get(e)?.resolved===!0}function BS(e){return kS.get(e)?.controller??null}function VS(e){let t=kS.get(e);t&&(t.settled=!0,DS(t),t.preMountEditor&&=(HS(e,t.preMountEditor,`aborted`),null),kS.delete(e),kS.size===0&&IS(),Z(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),wS(t.mountId),t.controller.abort())}function HS(e,t,n){let r=WS(t);try{t.destroy()}catch(t){Z(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function US(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(wC(t)!==void 0){let e=cC({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,DS(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,DS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`}),o(n),wS(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){HS(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,DS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`}),o(n),wS(i.mountId);return}let l;try{l=cC({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){HS(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,DS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`}),o(n),wS(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,DS(i);let u=Date.now()-i.createdAt;Z(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),Z.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();CS(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),wS(i.mountId,d)}function WS(e){try{let t=e.state;return Jv.getState(t)?.undoManager??null}catch(e){return Z(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var GS=Ac(`MAX_CACHE`,10),KS=Ac(`VIEW_COUNT_CACHE_THRESHOLD`,50),qS=Ac(`BYTES_CACHE_THRESHOLD`,8e6);function JS(e){return!(e.viewCount>0&&e.viewCount>=KS||e.bytes>qS)}var YS=new Map,XS=new Map,ZS=new Map;function QS(e,t){if(ZS.size>=GS){let e=ZS.keys().next().value;e!==void 0&&ZS.delete(e)}ZS.set(e,t),Z(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function $S(e){return ZS.get(e)??null}function eC(e){if(!ZS.has(e))return;let t=ZS.get(e)??null;ZS.delete(e),Z(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function tC(){try{return typeof document>`u`?0:document.querySelector(`[data-testid="editor-scroll-container"]`)?.scrollTop??0}catch(e){return Z(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function nC(e){try{let t=e.state.selection;return t instanceof F?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof Ct?{type:`node`,from:t.from}:null}catch(e){return Z(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function rC(e){for(let t of e)try{let e=wC(t.fromDocName);if(e&&!e.editor.isDestroyed){if(e.ytext.length===0){Z(`ok/cache/snapshot-skipped-empty`,{fromDocName:t.fromDocName});continue}QS(t.toDocName,{html:e.editor.getHTML(),scrollTop:tC(),selection:nC(e.editor)})}else Z(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){Z(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var iC=[],aC=[],oC=new Set;function sC(){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 cC(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!JS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:pS(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=YS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:pS(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),gC(a,n),a.activeMountKey=t,vC(iC,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:pS(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:pS(t),kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:pS(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;YS.size>=GS;){let e=yC(iC,t);if(!e)break;uC(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 YS.set(t,s),vC(iC,t),Z(`ok/cache/miss`,{docName:t,mountId:pS(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:pS(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function lC(e){let t=e.activeMountKey;if(e.__uncached){t&&VS(t);let n=WS(e.editor);try{e.editor.destroy()}catch(e){Z(`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=mC(e.editor);if(n){e.hadFocus=hC(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||=sC(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function uC(e){VS(e);let t=YS.get(e);if(!t)return!1;let n=WS(t.editor);try{t.editor.destroy()}catch(t){Z(`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){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}YS.delete(e);let r=iC.indexOf(e);return r!==-1&&iC.splice(r,1),Z(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function dC(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!JS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:pS(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=XS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:pS(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),_C(a,n),a.activeMountKey=t,vC(aC,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:pS(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:pS(t),kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:pS(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;XS.size>=GS;){let e=yC(aC,t);if(!e)break;pC(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return XS.set(t,s),vC(aC,t),Z(`ok/cache/miss`,{docName:t,mountId:pS(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:pS(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function fC(e){if(e.__uncached){try{e.view.destroy()}catch(t){Z(`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=hC(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=sC(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function pC(e){let t=XS.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}XS.delete(e);let n=aC.indexOf(e);return n!==-1&&aC.splice(n,1),Z(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function mC(e){return e.editorView??null}function hC(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function gC(e,t){let n=mC(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 _C(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function vC(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function yC(e,t){for(let n of e)if(n!==t&&!oC.has(n))return n;Z(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:oC.size});for(let n of e)if(n!==t)return n;return null}function bC(e){let t=oC,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=SC(e);if(t)try{t.disconnect(),Z(`ok/cache/disconnect`,{docName:e})}catch(t){Z(`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=SC(e);if(!n)continue;let r=t=>{Z(`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(()=>Z(`ok/cache/connect`,{docName:e}),e=>r(e)):Z(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}oC=n}var xC=null;function SC(e){let t=YS.get(e);if(t)return t.provider;let n=XS.get(e);if(n)return n.provider;if(xC){let t=xC.entries.get(e);if(t)return t.provider}return null}function CC(e){xC=e;let t=e.onEvict(e=>{uC(e),pC(e)});return()=>{t(),xC===e&&(xC=null)}}function wC(e){return YS.get(e)}var TC=`ok-editor-tabs-v1:`,EC=`\0folder:`,DC=`\0asset:`,OC=`\0doc-tab:`;function kC(e){let t=e.lastIndexOf(OC);return t<0?{baseTabId:e,instanceSuffix:``}:{baseTabId:e.slice(0,t),instanceSuffix:e.slice(t)}}function AC(e){return kC(e).baseTabId}function jC(e){if(typeof e!=`string`||e.length===0)return!1;let t=AC(e);return t.startsWith(EC)?t.length>8:t.startsWith(DC)?t.length>7:!0}function MC(e){return e}function NC(e,t){return`${AC(e)}${OC}${t}`}function PC(e,t){return FC(e,MC(t))}function FC(e,t){let n=WC(e,2**53-1),r=AC(t);if(!n.includes(r))return r;let i=1,a;do a=NC(r,i),i++;while(n.includes(a));return a}function IC(e,t){let n=AC(t);return WC(e,2**53-1).find(e=>AC(e)===n)??null}function LC(e,t){return AC(e)===AC(t)}function RC(e){return`${EC}${e}`}function zC(e){return`${DC}${e}`}function BC(e,t){let n=e.lastIndexOf(`/`),r=n<0?e:e.slice(n+1),i=`${r}${t}`;return n<0?{baseName:r,extension:t,label:i,prefix:``}:{baseName:r,extension:t,label:i,prefix:`${e.slice(0,n)}/`}}function VC(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return MC(e.docName);case`folder`:return RC(e.folderPath);case`missing`:return MC(e.target);case`asset`:return zC(e.assetPath)}}function HC(e){let t=AC(e);return t.startsWith(EC)?{kind:`folder`,folderPath:t.slice(8)}:t.startsWith(DC)?{kind:`asset`,assetPath:t.slice(7)}:{kind:`doc`,docName:t}}function UC(e){let t=HC(e);return t.kind===`doc`?t.docName:null}function WC(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(jC(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function GC(e,t){let n=new Set(WC(t,2**53-1));return WC(e,2**53-1).filter(e=>n.has(e))}function KC(e,t,n){if(t<=0)return[];let r=new Set(WC(n,2**53-1)),i=WC(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 qC(e,t,n){let r=GC(e,n);return!WC(n,2**53-1).includes(t)||r.includes(t)?r:[...r,t]}function JC(e,t){return WC(e,2**53-1).filter(e=>e!==t)}function YC(e,t){let n=new Set(WC(t,2**53-1));return WC(e,2**53-1).filter(e=>!n.has(e))}function XC(e,t,n){let r=WC(e,2**53-1),i=GC(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?qC(i,n,r):JC(i,n)}function ZC(e,t,n,r=[]){let i=KC(e,n,r);return!jC(t)||i.includes(t)?i:KC([...i,t],n,r)}function QC(e,t,n,r,i=[]){let a=KC(e,r,i);if(!jC(n))return a;if(!t||t===n)return ZC(a,n,r,i);let o=a.filter(e=>e!==n),s=o.indexOf(t);if(s<0)return ZC(o,n,r,i);let c=[...o];return c[s]=n,KC(c,r,i)}function $C(e,t,n){return ew(e,MC(t),n)}function ew(e,t,{behavior:n,currentTabId:r,limit:i,pinnedTabIds:a=[]}){let o=KC(e,i,a),s=AC(t);if(r&&o.includes(r)&&AC(r)===s)return{tabs:o,activeTabId:r};if(n!==`replace-active`)return{tabs:ZC(o,s,i,a),activeTabId:s};let c=IC(o,s);if(c)return{tabs:o,activeTabId:c};let l=FC(o,s);return{tabs:QC(o,r,l,i,a),activeTabId:l}}function tw(e,t){return e.filter(e=>e!==t)}function nw(e,t,n){let r=WC(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 rw(e,{pages:t,folderPaths:n,assetPaths:r,keepMissingDocName:i=null}){return WC(e,2**53-1).filter(e=>{let a=HC(e);return a.kind===`folder`?n.has(a.folderPath):a.kind===`asset`?r.has(a.assetPath):t.has(a.docName)||a.docName===i})}function iw(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return WC(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=e=>sw(ow(e,r),a),c=[],l=new Set;for(let t of e){let{instanceSuffix:e}=kC(t),a=HC(t),u=`${a.kind===`doc`?o.get(a.docName)??AC(t):a.kind===`folder`?RC(ow(a.folderPath,r)):zC(s(a.assetPath))}${e}`;if(!l.has(u)&&(l.add(u),c.push(u),i.length===0&&c.length>=n))break}return i.length===0?c:KC(c,n,i.map(e=>{let t=HC(e);return t.kind===`doc`?o.get(t.docName)??e:t.kind===`folder`?RC(ow(t.folderPath,r)):zC(s(t.assetPath))}))}function aw(e,t,n=[],r=[]){return iw(e,t,2**53-1,n,[],r)}function ow(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 sw(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function cw(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 lw(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 uw(e,t){if(typeof e!=`object`||!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};let n=e,r=WC(n.openTabs,2**53-1),i=GC(n.pinnedTabIds,r),a=i.length===0?WC(n.openTabs,t):KC(r,t,i),o=GC(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?HC(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 dw(e,t,n=[],r=()=>new Date){let i=WC(e,2**53-1),a=t&&i.includes(t)?t:null,o=a?HC(a):null;return{openTabs:i,pinnedTabIds:GC(n,i),activeDocName:o?.kind===`doc`?o.docName:null,activeTabId:a,updatedAt:r().toISOString()}}function fw(e){return`${TC}${e}`}function pw(e,t,n){if(!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};try{let r=e.getItem(t);return r?uw(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 mw(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 hw=Math.floor,gw=(e,t)=>e<t?e:t,_w=(e,t)=>e>t?e:t;Number.isNaN;var vw=128,yw=1<<17,bw=1<<18,xw=1<<19,Sw=1<<20,Cw=1<<21,ww=1<<22,Tw=1<<23,Ew=1<<24,Dw=1<<25,Ow=1<<26,kw=1<<27,Aw=1<<28,jw=1<<29,Mw=1<<30,Nw=127;yw-1,bw-1,xw-1,Sw-1,Cw-1,ww-1,Tw-1,Ew-1,Dw-1,Ow-1,kw-1,Aw-1,jw-1,Mw-1;var Pw=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Fw=String.fromCharCode;String.fromCodePoint,Fw(65535);var Iw=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Lw=typeof TextEncoder<`u`?new TextEncoder:null,Rw=Lw?e=>Lw.encode(e):Iw,zw=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});zw&&zw.decode(new Uint8Array).length===1&&(zw=null);var Bw=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Vw=(e,t)=>{for(;t>Nw;)Bw(e,vw|Nw&t),t=hw(t/128);Bw(e,Nw&t)},Hw=new Uint8Array(3e4),Uw=Hw.length/3,Ww=Lw&&Lw.encodeInto?(e,t)=>{if(t.length<Uw){let n=Lw.encodeInto(t,Hw).written||0;Vw(e,n);for(let t=0;t<n;t++)Bw(e,Hw[t])}else Kw(e,Rw(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Vw(e,r);for(let t=0;t<r;t++)Bw(e,n.codePointAt(t))},Gw=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=gw(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(_w(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Kw=(e,t)=>{Vw(e,t.byteLength),Gw(e,t)},qw=e=>Error(e),Jw=qw(`Unexpected end of array`),Yw=qw(`Integer out of Range`),Xw=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Zw=e=>Xw(e,$w(e)),Qw=e=>e.arr[e.pos++],$w=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&Nw)*n,n*=128,r<vw)return t;if(t>Pw)throw Yw}throw Jw},eT=zw?e=>zw.decode(Zw(e)):e=>{let t=$w(e);if(t===0)return``;{let n=String.fromCodePoint(Qw(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Qw(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},tT=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),nT=(e,t)=>{Vw(e,tT.Token),Ww(e,t)},rT=(e,t,n,r)=>{switch($w(e)){case tT.Token:t();break;case tT.PermissionDenied:n(eT(e));break;case tT.Authenticated:r(eT(e));break;default:}},iT=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),aT=`\0`;function oT(e,t){return e+aT+t}function sT(e){let t=e.indexOf(aT);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var cT=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function lT(e){return e||={},{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function uT(e){return new Promise(t=>setTimeout(t,e))}function dT(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function fT(e,t){let n=lT(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||dT;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await uT(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await uT(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await uT(e)}return a()}var pT=Math.floor,mT=(e,t)=>e<t?e:t,hT=(e,t)=>e>t?e:t;Number.isNaN;var gT=64,_T=128,vT=1<<17,yT=1<<18,bT=1<<19,xT=1<<20,ST=1<<21,CT=1<<22,wT=1<<23,TT=1<<24,ET=1<<25,DT=1<<26,OT=1<<27,kT=1<<28,AT=1<<29,jT=1<<30,MT=63,NT=127;vT-1,yT-1,bT-1,xT-1,ST-1,CT-1,wT-1,TT-1,ET-1,DT-1,OT-1,kT-1,AT-1,jT-1;var PT=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var FT=()=>new Set,IT=Array.from;Array.isArray;var LT=String.fromCharCode;String.fromCodePoint,LT(65535);var RT=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},zT=typeof TextEncoder<`u`?new TextEncoder:null,BT=zT?e=>zT.encode(e):RT,VT=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});VT&&VT.decode(new Uint8Array).length===1&&(VT=null);var HT=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},UT=()=>new HT,WT=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},GT=e=>{let t=new Uint8Array(WT(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},KT=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},qT=(e,t)=>{for(;t>NT;)KT(e,_T|NT&t),t=pT(t/128);KT(e,NT&t)},JT=new Uint8Array(3e4),YT=JT.length/3,XT=zT&&zT.encodeInto?(e,t)=>{if(t.length<YT){let n=zT.encodeInto(t,JT).written||0;qT(e,n);for(let t=0;t<n;t++)KT(e,JT[t])}else QT(e,BT(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;qT(e,r);for(let t=0;t<r;t++)KT(e,n.codePointAt(t))},ZT=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=mT(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(hT(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},QT=(e,t)=>{qT(e,t.byteLength),ZT(e,t)},$T=e=>Error(e),eE=$T(`Unexpected end of array`),tE=$T(`Integer out of Range`),nE=class{constructor(e){this.arr=e,this.pos=0}},rE=e=>new nE(e),iE=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},aE=e=>iE(e,sE(e)),oE=e=>e.arr[e.pos++],sE=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&NT)*n,n*=128,r<_T)return t;if(t>PT)throw tE}throw eE},cE=e=>{let t=e.arr[e.pos++],n=t&MT,r=64,i=(t&gT)>0?-1:1;if((t&_T)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&NT)*r,r*=128,t<_T)return i*n;if(n>PT)throw tE}throw eE},lE=VT?e=>VT.decode(aE(e)):e=>{let t=sE(e);if(t===0)return``;{let n=String.fromCodePoint(oE(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(oE(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},uE=e=>{let t=e.pos,n=lE(e);return e.pos=t,n},dE=Date.now,fE=()=>new Map,pE=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},mE=class{constructor(){this._observers=fE()}on(e,t){pE(this._observers,e,FT).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return IT((this._observers.get(e)||fE()).values()).forEach(e=>e(...t))}destroy(){this._observers=fE()}},hE=Symbol(`Equality`),gE=Object.keys,_E=e=>gE(e).length,vE=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),yE=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[hE]!=null)return e[hE](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!yE(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(_E(e)!==_E(t))return!1;for(let n in e)if(!vE(e,n)||!yE(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!yE(e[n],t[n]))return!1;break;default:return!1}return!0},bE=3e4,xE=class extends mE{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=dE();this.getLocalState()!==null&&bE/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&bE<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&SE(this,t,`timeout`)},pT(bE/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:dE()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),yE(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},SE=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:dE()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},CE=(e,t,n=e.states)=>{let r=t.length,i=UT();qT(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;qT(i,r),qT(i,s),XT(i,JSON.stringify(o))}return GT(i)},wE=(e,t,n)=>{let r=rE(t),i=dE(),a=[],o=[],s=[],c=[],l=sE(r);for(let t=0;t<l;t++){let t=sE(r),n=sE(r),l=JSON.parse(lE(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(yE(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},TE=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},EE=class{constructor(e){this.data=e,this.encoder=UT(),this.decoder=rE(new Uint8Array(this.data))}peekVarString(){return uE(this.decoder)}readVarUint(){return sE(this.decoder)}readVarString(){return lE(this.decoder)}readVarUint8Array(){return aE(this.decoder)}writeVarUint(e){return qT(this.encoder,e)}writeVarString(e){return XT(this.encoder,e)}writeVarUint8Array(e){return QT(this.encoder,e)}length(){return WT(this.encoder)}},DE=function(e){return e[e.Sync=0]=`Sync`,e[e.Awareness=1]=`Awareness`,e[e.Auth=2]=`Auth`,e[e.QueryAwareness=3]=`QueryAwareness`,e[e.Stateless=5]=`Stateless`,e[e.CLOSE=7]=`CLOSE`,e[e.SyncStatus=8]=`SyncStatus`,e[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),OE=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),kE=class{constructor(){this.encoder=UT()}get(e){return e.encoder}toUint8Array(){return GT(this.encoder)}},AE=class extends kE{constructor(...e){super(...e),this.type=DE.CLOSE,this.description=`Ask the server to close the connection`}get(e){return XT(this.encoder,e.documentName),qT(this.encoder,this.type),this.encoder}},jE=class e extends TE{static{this.DEDUPLICATABLE_TYPES=new Set([DE.Awareness,DE.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=OE.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on(`open`,this.configuration.onOpen),this.on(`open`,this.onOpen.bind(this)),this.on(`connect`,this.configuration.onConnect),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`status`,this.configuration.onStatus),this.on(`disconnect`,this.configuration.onDisconnect),this.on(`close`,this.configuration.onClose),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`close`,this.onClose.bind(this)),this.on(`message`,this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(e){this.status=OE.Connected,this.emit(`status`,{status:OE.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===OE.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===OE.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(AE,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===OE.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:fT(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=OE.Connecting,this.emit(`status`,{status:OE.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=dE();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===DE.Ping){this.sendPong();return}let n=new EE(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=UT();qT(e,DE.Pong),this.send(GT(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=OE.Connected,this.emit(`status`,{status:OE.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===OE.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=dE()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:`forced`}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=rE(e);return{documentName:lE(t),messageType:sE(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===cT.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=OE.Disconnected,this.emit(`status`,{status:OE.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},ME=0,NE=1,PE=2,FE=(e,t)=>{qT(e,ME),QT(e,Th(t))},IE=(e,t,n)=>{qT(e,NE),QT(e,yh(t,n))},LE=(e,t,n)=>IE(t,n,aE(e)),RE=(e,t,n,r)=>{try{gh(t,aE(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},zE=(e,t)=>{qT(e,PE),QT(e,t)},BE=RE,VE=(e,t,n,r,i)=>{let a=sE(e);switch(a){case ME:LE(e,t,n);break;case NE:RE(e,n,r,i);break;case PE:BE(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},HE=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case DE.Sync:this.applySyncMessage(e,t);break;case DE.Awareness:this.applyAwarenessMessage(e);break;case DE.Auth:this.applyAuthMessage(e);break;case DE.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case DE.Stateless:e.receiveStateless(lE(n.decoder));break;case DE.SyncStatus:this.applySyncStatusMessage(e,cE(n.decoder)===1);break;case DE.CLOSE:let i={code:1e3,reason:lE(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(kE,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(DE.Sync);let r=VE(n.decoder,n.encoder,e.document,e);t&&r===NE&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;wE(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;rT(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(DE.Awareness),t.writeVarUint8Array(CE(e.awareness,Array.from(e.awareness.getStates().keys())))}},UE=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return GT(this.encoder)}send(e){e?.send(this.create())}},WE=`4.0.0-rc.1`,GE=class extends kE{constructor(...e){super(...e),this.type=DE.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return XT(this.encoder,e.documentName),qT(this.encoder,this.type),nT(this.encoder,e.token),XT(this.encoder,WE),this.encoder}},KE=class extends kE{constructor(...e){super(...e),this.type=DE.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);XT(this.encoder,e.documentName),qT(this.encoder,this.type);let t;return t=e.states===void 0?CE(e.awareness,e.clients):CE(e.awareness,e.clients,e.states),QT(this.encoder,t),this.encoder}},qE=class extends kE{constructor(...e){super(...e),this.type=DE.Stateless,this.description=`A stateless message`}get(e){return XT(this.encoder,e.documentName),qT(this.encoder,this.type),XT(this.encoder,e.payload??``),this.encoder}},JE=class extends kE{constructor(...e){super(...e),this.type=DE.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return XT(this.encoder,e.documentName),qT(this.encoder,this.type),FE(this.encoder,e.document),this.encoder}},YE=class extends kE{constructor(...e){super(...e),this.type=DE.Sync,this.description=`A document update`}get(e){return XT(this.encoder,e.documentName),qT(this.encoder,this.type),zE(this.encoder,e.update),this.encoder}},XE=class extends Error{constructor(...e){super(...e),this.code=1001}},ZE=class extends TE{get effectiveName(){return this.configuration.sessionAwareness?oT(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new eh,this.configuration.awareness=e.awareness===void 0?new xE(this.document):e.awareness,this.on(`open`,this.configuration.onOpen),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`synced`,this.configuration.onSynced),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`stateless`,this.configuration.onStateless),this.on(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:iT(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:iT(this.awareness.getStates())})}),this.document.on(`update`,this.boundDocumentUpdateHandler),this.awareness?.on(`update`,this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval==`number`&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new jE(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(JE,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&SE(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(qE,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(GE,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(YE,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(KE,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(JE,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(KE,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new UE(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new EE(e.data),{documentName:n}=sT(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new EE(e.data)}),new HE(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&SE(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(SE(this.awareness,[this.document.clientID],`provider destroy`),this.awareness.off(`update`,this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off(`update`,this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),this.configuration.websocketProvider.off(`close`,this.boundOnClose),this.configuration.websocketProvider.off(`close`,this.configuration.onClose),this.configuration.websocketProvider.off(`close`,this.forwardClose),this.configuration.websocketProvider.off(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.off(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.off(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.off(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),this.configuration.websocketProvider.on(`close`,this.boundOnClose),this.configuration.websocketProvider.on(`close`,this.configuration.onClose),this.configuration.websocketProvider.on(`close`,this.forwardClose),this.configuration.websocketProvider.on(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.on(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.on(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.on(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new XE(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}},QE=e=>cf((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),$E=(e,t)=>cf((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(Nd(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),eD=e=>QE(indexedDB.deleteDatabase(e)),tD=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),nD=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>pD(r,e))},rD=(e,t)=>QE(e.count(t)),iD=(e,t)=>QE(e.get(t)),aD=(e,t)=>QE(e.delete(t)),oD=(e,t,n)=>QE(e.put(t,n)),sD=(e,t)=>QE(e.add(t)),cD=(e,t,n)=>QE(e.getAll(t,n)),lD=(e,t,n)=>{let r=null;return fD(e,t,e=>(r=e,!1),n).then(()=>r)},uD=(e,t=null)=>lD(e,t,`prev`),dD=(e,t)=>cf((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()}}),fD=(e,t,n,r=`next`)=>dD(e.openKeyCursor(t,r),e=>n(e.key)),pD=(e,t)=>e.objectStore(t),mD=(e,t)=>IDBKeyRange.upperBound(e,t),hD=(e,t)=>IDBKeyRange.lowerBound(e,t),gD=`custom`,_D=`updates`,vD=(e,t=()=>{},n=()=>{})=>{let[r]=nD(e.db,[_D]);return cD(r,hD(e._dbref,!1)).then(i=>{e._destroyed||(t(r),hg(e.doc,()=>{i.forEach(t=>gh(e.doc,t))},e,!1),n(r))}).then(()=>uD(r).then(t=>{e._dbref=t+1})).then(()=>rD(r).then(t=>{e._dbsize=t})).then(()=>r)},yD=(e,t=!0)=>vD(e).then(n=>{(t||e._dbsize>=500)&&sD(n,yh(e.doc)).then(()=>aD(n,mD(e._dbref,!0))).then(()=>rD(n).then(t=>{e._dbsize=t}))}),bD=class extends Eu{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=$E(e,e=>tD(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=cf(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,vD(this,async e=>{await rD(e)>0&&sD(e,yh(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]=nD(this.db,[_D]);sD(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(()=>{yD(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(()=>{eD(this.name)})}get(e){return this._db.then(t=>{let[n]=nD(t,[gD],`readonly`);return iD(n,e)})}set(e,t){return this._db.then(n=>{let[r]=nD(n,[gD]);return oD(r,t,e)})}del(e){return this._db.then(t=>{let[n]=nD(t,[gD]);return aD(n,e)})}};function xD(){return!0}var SD=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=xD()?0:performance.now();this._idb=new bD(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!xD()){let e=performance.now();Z(`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=xD()?0:performance.now();try{await this._idb.destroy()}finally{if(!xD()){let t=performance.now();Z(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async clearData(){let e=xD()?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(!xD()){let t=performance.now();Z(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function CD(e){return new SD(e)}function wD(e){return Th(e)}function TD(e,t){return t===null?yh(e):yh(e,t)}function ED(e,t){if(e===null)return t;if(t===null)return e;let n=xh(e),r=xh(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 Th(i)}function DD(e){let t={};if(mr.inject(pr.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 OD=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new U({key:e||new W(`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))}}}),kD=Dt.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[OD({key:new W(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function AD(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||!Ct.isSelectable(o))return!1;try{let t=Ct.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return ot(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}function jD(e){let{state:t,view:n}=e;if(!(t.selection instanceof F)||!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=ge.findFrom(n,-1,!0);return!r||!(r instanceof F)?!1:(e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return ot(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2c`,reason:e.message.slice(0,500)})),!0}}var MD=Dt.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof Ct){let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=F.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof F?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(AD(e,`up`)||jD(e))return!0;let{state:t}=e;if(!(t.selection instanceof Ct))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=Ct.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 ot(`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(AD(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof Ct))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=Ct.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return ot(`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})=>AD(e,`left`),ArrowRight:({editor:e})=>AD(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof F)||!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(F.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),ND={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},PD=/[A-Za-z0-9_]/;function FD(e){return e!==void 0&&PD.test(e)}function ID(e,t,n){return!FD(e[t-1])&&!FD(e[n])}function LD(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||ID(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function RD(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 LD(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var zD=new W(`findReplace`);function BD(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function VD(e,t,n,r){let i=RD(e.doc,t,n);return{query:t,options:n,activeIndex:BD(r,i.length),matches:i}}function HD(e,t,n){return t<=0?0:(BD(e,t)+n+t)%t}function UD(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 WD(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=RD(r.doc,t.query,t.options),a=BD(0,i.length),o=i[a];return r.setMeta(zD,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(F.create(r.doc,o.from,o.to)),r.scrollIntoView()}function GD(e,t){let n=zD.getState(e)?.matches[t];return n?e.tr.setMeta(zD,{type:`setActiveIndex`,activeIndex:t}).setSelection(F.create(e.doc,n.from,n.to)).scrollIntoView():null}function KD(e){return zD.getState(e)??ND}function qD(){return new U({key:zD,state:{init:()=>ND,apply(e,t,n,r){let i=e.getMeta(zD);if(i?.type===`clear`)return ND;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:[]}:VD(r,a,o,s)}},props:{decorations(e){let t=zD.getState(e);return!t||t.matches.length===0?null:pe.create(e.doc,t.matches.map((e,n)=>S.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var JD=Dt.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(zD,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(zD,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(zD,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=KD(e),r=GD(e,HD(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=KD(e),r=GD(e,HD(n.activeIndex,n.matches.length,-1));return r?(t?.(r),!0):!1},replaceCurrentFindMatch:e=>({state:t,dispatch:n})=>{let r=KD(t),i=r.matches[r.activeIndex];if(!i||!n)return!1;let a=t.tr.insertText(e,i.from,i.to),o=RD(a.doc,r.query,r.options),s=UD(o,i.from,e.length),c=o[s];return a.setMeta(zD,{type:`setActiveIndex`,activeIndex:s}),c&&a.setSelection(F.create(a.doc,c.from,c.to)),a.scrollIntoView(),n(a),!0},replaceAllFindMatches:e=>({state:t,dispatch:n})=>{let r=KD(t);if(!n)return!1;let i=WD(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(zD,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[qD()]}}),YD=new WeakMap;function XD(e,t){if(t===null){YD.delete(e);return}YD.set(e,t)}function ZD(e){return YD.get(e)??null}function QD(e){return`pagesBySlug`in e}function $D(e){return QD(e)?e.pages:e}function eO(e,t){return QD(e)?e.assetPaths??new Set:t??new Set}function tO(e,t){let n=We(e);if(n){if(QD(t))return t.pagesBySlug.get(n);for(let e of t)if(We(e)===n)return e}}function nO(e,t){if(e.includes(`/`))return;let n=We(e);if(!n)return;if(QD(t))return t.pagesByBasename?.get(n);let r;for(let e of t){let t=e.lastIndexOf(`/`);We(t===-1?e:e.slice(t+1))===n&&(r===void 0||e.localeCompare(r)<0)&&(r=e)}return r}function rO(e){let t=e.trim();if(!t)return null;let n=We(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function iO(e){let t=e.trim();if(!t)return[];let n=We(t);return n.length>0&&n!==t?[n]:[]}function aO(e,t){let n=e.trim();if(!n)return;let r=$D(t);if(r.has(n))return n;let i=tO(n,t);if(i)return i;for(let e of iO(n))if(r.has(e))return e;return oO(n,r)||nO(n,t)}function oO(e,t){let n=`${e}/index`;if(t.has(n))return n;let r=e.lastIndexOf(`/`),i=r===-1?e:e.slice(r+1),a=i?`${e}/${i}`:null;if(a&&t.has(a))return a}function sO(e){let t=((e.trim().split(`#`)[0]??``).trim().split(`?`)[0]??``).trim();return t.startsWith(`/`)?t.slice(1):t}function cO(e,t){let n=sO(e);if(!n)return null;if(t.has(n))return n;let r=n.toLowerCase();for(let e of t)if(e.toLowerCase()===r)return e;if(n.includes(`/`))return null;let i=[...t].filter(e=>{let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase()===r});return i.length===0?null:i.sort((e,t)=>e.localeCompare(t))[0]??null}function lO(e,t,n){let r=e.trim();if(!r)return!1;if(cO(r,eO(t,n)))return!0;let i=$D(t);return i.has(r)||iO(r).some(e=>i.has(e))||tO(r,t)!==void 0||oO(r,i)?!0:nO(r,t)!==void 0}var uO=class extends Error{status;instance;constructor(e,t={}){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`HttpResponseParseError`,this.status=t.status,this.instance=t.instance}},dO=new W(`imageUpload`);function fO(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?G._({id:`KDuPiY`,values:{fileName:n}}):G._({id:`bGa3Fk`})),t}var pO=new U({key:dO,state:{init(){return{decorations:pe.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(dO);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=S.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 dO.getState(e)?.decorations??pe.empty}}});function mO(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function hO(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function gO(e){return e.split(`/`).filter(e=>e!==``)}function _O(e,t){let n=mO(e),r=mO(t),i=hO(e);if(n===r)return i;let a=gO(r),o=gO(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 vO(e){return ZD(e)}function yO(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 bO(e){let t=Se(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:Fe.has(t)?{kind:`jsx-img`,ext:t}:sn.has(t)?{kind:`jsx-video`,ext:t}:Rt.has(t)?{kind:`jsx-audio`,ext:t}:de.has(t)?{kind:`jsx-file`,ext:t}:hn.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function xO(e,t,n){let r=vO(t),i=r?`${r}.md`:``;if(!i){or.error(G._({id:`z5pqI8`}));return}let a=crypto.randomUUID(),o=fO(e);t.view.dispatch(t.state.tr.setMeta(dO,{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),SO(t,a);return}let l;try{l=await c.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),SO(t,a);return}if(!c.ok){let e=$t.safeParse(l);if(!e.success){let n=new uO(`Upload response did not match ProblemDetails.`,{cause:e.error,status:c.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),SO(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),SO(t,a,e.data.title);return}let u=Ke.safeParse(l);if(!u.success){let e=new uO(`Upload success response did not match UploadAssetSuccess.`,{cause:u.error,status:c.status});console.error(`[uploadAndInsert] Response missing src:`,e),SO(t,a);return}let d=u.data,f=d.src,p=d.deduped===!0,m=mO(i),h=typeof d.path==`string`&&d.path.length>0?d.path:m?`${m}/${f}`:f;p&&or.info(G._({id:`VbqhBI`,values:{assetContentPath:h}}));let g=bO(e.name),{state:_}=t,v=dO.getState(_)?.uploads.get(a)??n,y=_.tr.setMeta(dO,{type:`remove`,id:a}),b=_O(h,i),x=`/${h}`;if(g.kind===`jsx-file`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),SO(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:Pt(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(dO,{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(Ct.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`),SO(t,a);return}let e=yO(g.kind,x);t.chain().command(({tr:e})=>(e.setMeta(dO,{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(Ct.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`),SO(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`),SO(t,a);return}let r=rO(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 SO(e,t,n){e.view.dispatch(e.state.tr.setMeta(dO,{type:`remove`,id:t})),or.error(n??G._({id:`b3Thhd`}))}var CO=new Set;function wO(e){CO.add(e)}function TO(e){return CO.delete(e)}var EO=new W(`markIdentity`);function DO(){return{byId:new Map,counter:0}}function OO(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&&kO(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 kO(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&&kO(n,i)))return!1}return!0}function AO(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 jO(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new U({key:EO,state:{init(e,t){return OO(t.doc,DO(),a,n)},apply(e,t,r,i){return e.docChanged?OO(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=EO.getState(t.state);n&&(e=AO(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}var MO=300,NO=150,PO=500,FO=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 IO(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 LO(e){return e?e.closest(`[data-ok-prop-panel]`)!==null:!1}function RO(){return typeof document>`u`?!1:document.querySelector(`[data-ok-layer-spawned]`)!==null}var zO=e=>{let t=(0,J.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,Y.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,Y.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,X.jsxs)(X.Fragment,{children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17],p};function BO(e){return e.editorView?.dom??null}function VO(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 HO(e){let{editor:t}=e,n=new FO,r=BO(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)},MO))},m=()=>{n.getActiveNode()!==null&&o===null&&(o=setTimeout(()=>{o=null,!RO()&&n.setActiveNode(null)},NO))},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&&VO(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??BO(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=IO(e.target,n);if(t===null)return;f(),c=setTimeout(()=>{c=null,l=t,n.setActiveNode(t)},PO);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=IO(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=IO(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=IO(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(LO(r)){d();return}let i=IO(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=IO(r,n);if(o!==null){if(a&&LO(a)){d();return}if(a&&IO(a,n)===o)return;s===o&&u(),m();return}if(LO(r)){if(a&&LO(a))return;let e=n.getActiveNode();if(e!==null&&a&&IO(a,n)===e)return;m()}},E=e=>{if(g)return;let t=e.target;if(!(t instanceof Element))return;let r=IO(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&&LO(i)||i&&IO(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=BO(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 UO=e=>{let t=(0,J.c)(2),{store:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{"data-ok-interaction-layer":``,className:`contents`,children:(0,X.jsx)(zO,{store:n})}),t[0]=n,t[1]=r),r},WO=new WeakMap;function GO(e){let t=WO.get(e);if(t)return t;let n=HO({editor:e});return WO.set(e,n),e.on(`destroy`,()=>{n.destroy(),WO.delete(e)}),n}var KO={AppWindow:Fi,ChevronRight:sr,CopyPlus:Xi,FileText:ra,Film:oa,GitBranch:la,Image:ma,LayoutPanelTop:_a,MessageSquareWarning:Ea,PanelTop:Aa,Paperclip:ja,Sigma:Ra,SquarePlay:Ba,Volume2:Ja,Workflow:Ya,ZoomIn:Za};function qO(e){return e&&Object.hasOwn(KO,e)?KO[e]:zi}var JO={Info:ha,Lightbulb:va,MessageSquareWarning:Ea,AlertTriangle:He,AlertOctagon:Oa,ClipboardList:qi,BookOpen:Ri,ListTodo:Ca,CircleCheck:l,CircleHelp:Gi,CircleX:Ki,Zap:Xa,Bug:Bi,FlaskConical:sa,Quote:Pa,ChevronRight:sr},YO=Object.entries(JO).sort(([e],[t])=>e.localeCompare(t));function XO(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(JO,t)?JO[t]??null:null}function ZO(e){let t=(0,J.c)(24),n;t[0]===e.icon?n=t[1]:(n=XO(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,X.jsx)(sr,{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,X.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,X.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,X.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,X.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,X.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,X.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,X.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 QO(e){return e!==!1}function $O(e){let t=(0,J.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:Re(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=QO(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,X.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 ek={note:ha,tip:va,important:Ea,warning:He,caution:Oa,abstract:qi,info:Ri,todo:Ca,success:l,question:Gi,failure:Ki,danger:Xa,bug:Bi,example:sa,quote:Pa};function tk(e,t){return XO(e)??ek[t]}var nk=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function rk(e){return typeof e==`string`&&nk.has(e)?e:`note`}function ik(e){let t=(0,J.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=rk(e.type),n=tk(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,X.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,X.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,X.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,X.jsx)(`span`,{className:`callout-title`,children:(0,X.jsx)(o,{id:`URmyfc`})}),t[9]=l,t[10]=i);let a;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Hi,{size:16,className:`callout-chevron`,"aria-hidden":`true`}),t[11]=a):a=t[11];let c;t[12]===i?c=t[13]:(c=(0,X.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,X.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,X.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,X.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,X.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 ak=(0,Y.createContext)(null);function ok(e){let t=(0,J.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(ak.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function sk(){return(0,Y.use)(ak)}var ck=[{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 lk(e){let t=(0,J.c)(7),{targetRef:n,onResize:r,onResizeEnd:a,bounds:o}=e,{_:s}=i(),c=(0,Y.useRef)(null),l;t[0]!==o?.maxHeight||t[1]!==o?.maxWidth||t[2]!==o?.minHeight||t[3]!==o?.minWidth?(l=function(e,t){let n=t===`w`?o?.minWidth??64:o?.minHeight??64,r=t===`w`?o?.maxWidth??1/0:o?.maxHeight??1/0;return Math.max(n,Math.min(r,e))},t[0]=o?.maxHeight,t[1]=o?.maxWidth,t[2]=o?.minHeight,t[3]=o?.minWidth,t[4]=l):l=t[4];let u=l,d=function(e,t){let i=n.current;if(!i)return;e.preventDefault(),e.stopPropagation();let o=i.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},document.body.style.setProperty(`cursor`,t.cursor),document.body.style.setProperty(`user-select`,`none`);let s=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 l(){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`,s),window.removeEventListener(`pointerup`,l),window.removeEventListener(`pointercancel`,l),n&&a?.(t)}window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,l),window.addEventListener(`pointercancel`,l)},f=ck.map(e=>{let t=e.key;return(0,X.jsx)(`button`,{type:`button`,className:Sn(e.className),"aria-label":s({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,X.jsx)(`div`,{className:`ok-resize-overlay`,contentEditable:!1,"aria-hidden":`true`,children:f}),t[5]=f,t[6]=p),p}var uk=`26rem`,dk=`Embedded content`,fk=/^https?:\/\//i;function pk(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function mk(e){return!(typeof e!=`string`||!fk.test(e)||!pk(e))}function hk(e){let t=(0,J.c)(21),{src:n,title:r,width:i,height:a}=e,o=(0,Y.useRef)(null),s=sk(),c=i||void 0,l=a||uk,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||uk)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Y.useEffect)(f,p),!mk(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=fk.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,X.jsx)(`div`,{className:`ok-embed ok-embed--placeholder`,contentEditable:!1,children:(0,X.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=r||dk,_;t[11]!==n||t[12]!==g?(_=(0,X.jsx)(`iframe`,{title:g,src:n,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:`no-referrer`,loading:`lazy`,className:`ok-embed-frame`}),t[11]=n,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==s||t[15]!==h?(v=s?(0,X.jsx)(lk,{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[14]=s,t[15]=h,t[16]=v):v=t[16];let y;return t[17]!==d||t[18]!==_||t[19]!==v?(y=(0,X.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[_,v]}),t[17]=d,t[18]=_,t[19]=v,t[20]=y):y=t[20],y}function gk(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 _k(e){let t=(0,J.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||gk(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?Re(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,X.jsx)(ia,{className:`ok-file-icon`,"aria-hidden":`true`}),t[7]=l):l=t[7];let u;t[8]===r?u=t[9]:(u=(0,X.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,X.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,X.jsxs)(`a`,{href:o,title:e.title,className:`ok-file-attachment`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:vk,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 vk(e){return e.stopPropagation()}function yk(){return Y.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`},Y.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 bk(){return Y.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`},Y.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 xk(e){return typeof Element>`u`?!1:e instanceof Element}var Sk=(e,t)=>xk(t)&&t.tagName.toUpperCase()===e,Ck=e=>Sk(`DIV`,e)||Sk(`SPAN`,e),wk=e=>Sk(`IMG`,e),Tk=e=>e.complete&&e.naturalHeight!==0,Ek=e=>Sk(`SVG`,e),Dk=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),Ok=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=Dk({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},kk=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?Ok({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):Dk({height:e,offset:r,width:t}),Ak=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,jk=e=>{if(e!==null){if(wk(e))return e.currentSrc===``?void 0:e.currentSrc;if(Ck(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return Ak.exec(t)?.[1]}}},Mk=e=>{if(e!==null)return wk(e)?e.alt:e.getAttribute(`aria-label`)??void 0},Nk=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=kk({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})`}},Pk=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},Fk=({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=Pk({position:p,relativeNum:r-l*f}),g=Pk({position:m,relativeNum:e-c*f}),_=kk({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=Pk({position:a,relativeNum:r-l}),f=Pk({position:u,relativeNum:e-c}),p=kk({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=kk({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{}},Ik=({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=Pk({position:p,relativeNum:a-l*f}),g=Pk({position:m,relativeNum:n-c*f}),_=kk({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=Pk({position:t,relativeNum:a-l}),f=Pk({position:u,relativeNum:n-c}),p=kk({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=Pk({position:u,relativeNum:a}),p=Pk({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=Pk({position:_,relativeNum:a-l*g}),b=Pk({position:v,relativeNum:n-c*g}),x=kk({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})`}}},Lk=/\.svg$/i,Rk=({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&&Lk.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&Ck(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=Nk({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?Fk({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?Ik({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},zk=e=>{if(e==null)return{};if(Ek(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}},Bk=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}`)}})})},Vk=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),Hk={overflow:``,width:``};function Uk(){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 Wk(e){e.preventDefault()}function Gk(e){return Y.createElement(Kk,{...e})}var Kk=class extends Y.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Y.createRef(),this.refDialog=Y.createRef(),this.refModalContent=Y.createRef(),this.refModalImg=Y.createRef(),this.refWrap=Y.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=Hk,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(Vk),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:zk(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:zk(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=jk(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(wk(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:zk(this.imgEl)})};t.decode().then(r).catch(()=>{if(Tk(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||Ek(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=Hk},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(Tk(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(Ek(e)){let r=e.cloneNode(!0);Bk(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=Ck(a),j=wk(a),M=Ek(a),N=Mk(a),P=jk(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,ee=h?.src!==void 0&&h.src!==``,R=this.hasImage(),z=N!==void 0&&N!==``?`${s}: ${N}`:s,te=T===`LOADING`||T===`LOADED`,B=R?`found`:`not-found`,ne=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,V={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=R&&a!==null?Rk({hasZoomImg:ee,imgSrc:P,isSvg:M,isZoomed:f&&te,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let re=null;if(R){let t=j||A?Y.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?Y.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Y.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Y.createElement(u,null));re=m==null?Y.createElement(Y.Fragment,null,t,n):Y.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Y.createElement(p,{"aria-owns":R?O:void 0,"data-rmiz":``,ref:x},Y.createElement(p,{"data-rmiz-content":B,ref:_,style:V},c),R&&Y.createElement(p,{"data-rmiz-ghost":``,style:D},Y.createElement(`button`,{"aria-label":z,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Y.createElement(d,null))),R&&no.createPortal(Y.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:Wk,ref:v,role:`dialog`},Y.createElement(`div`,{"data-rmiz-modal-overlay":ne}),Y.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},re)),Uk()))}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)}};Kk.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:yk,IconZoom:bk,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function qk({onZoomChange:e,...t}){let[n,r]=Y.useState(!1),i=Y.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Y.createElement(Gk,{...t,isZoomed:n,onZoomChange:i})}function Jk(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function Yk(e,t,n){return Jk(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function Xk(e){let t=(0,J.c)(52),n,r,a,o,s,c,l,u,d,f,p,m;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=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:s,onError:o,src:l,style:u,alt:p,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s,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}=i(),y=(0,Y.useRef)(null),[b,x]=(0,Y.useState)(!1),S;t[13]!==r||t[14]!==m?(S=Jk(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=Yk(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,Y.useLayoutEffect)(E,D);let O=!C&&!b&&`aspect-[16/9] w-full max-w-full`,k;t[23]!==c||t[24]!==O?(k=Sn(`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,X.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=Sn(`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]===s?N=t[34]:(N=e=>{x(!0),s?.(e)},t[33]=s,t[34]=N);let P;t[35]===o?P=t[36]:(P=e=>{x(!0),o?.(e)},t[35]=o,t[36]=P);let F;t[37]!==_||t[38]!==r||t[39]!==a||t[40]!==l||t[41]!==M||t[42]!==N||t[43]!==P||t[44]!==m?(F=(0,X.jsx)(`img`,{...a,ref:y,src:l,alt:_,width:m,height:r,className:M,onLoad:N,onError:P}),t[37]=_,t[38]=r,t[39]=a,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,X.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 Zk(e){return e??`lazy`}function Qk(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function $k(e){let t=(0,J.c)(21),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:Re(e.src),t[0]=e.src,t[1]=n);let r=e.alt??``,i;t[2]===e.width?i=t[3]:(i=Qk(e.width),t[2]=e.width,t[3]=i);let a;t[4]===e.height?a=t[5]:(a=Qk(e.height),t[4]=e.height,t[5]=a);let o=e.title,s;t[6]===e.loading?s=t[7]:(s=Zk(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,X.jsx)(Xk,{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 eA(e){let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,X.jsx)(qk,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,X.jsx)($k,{...e})}),t[1]=e,t[2]=r),r}var tA=(0,Y.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-DX-tM4Fr.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,J.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,X.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 nA(e){let t=(0,J.c)(3),n=e.formula||`\xA0`,r;return t[0]!==e.id||t[1]!==n?(r=(0,X.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 rA(e){let t=(0,J.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,X.jsx)(nA,{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,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(nA,{formula:n,id:e.id}),children:(0,X.jsx)(tA,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}var iA=null;function aA(){return iA||=n(()=>import(`./mermaid.core-CWYso-V4.js`).then(e=>{let t=e.default;return t.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`default`,suppressErrorRendering:!0}),t}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),import.meta.url).catch(e=>{throw iA=null,e}),iA}function oA(e){let t=(0,J.c)(24),n=e.chart??``,r=(0,Y.useId)(),i;if(t[0]!==r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/:/g,t[2]=e):e=t[2],i=r.replace(e,`_`),t[0]=r,t[1]=i}else i=t[1];let a=`mermaid-${i}`,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={status:`idle`,svg:``,error:``},t[3]=s):s=t[3];let[c,l]=(0,Y.useState)(s),u,d;if(t[4]!==n||t[5]!==a?(u=()=>{if(!n.trim()){l({status:`idle`,svg:``,error:``});return}let e=!1;return l(sA),aA().then(async t=>{try{let r=await t.render(a,n);e||l({status:`ready`,svg:r.svg,error:``})}catch(t){let n=t;e||l({status:`error`,svg:``,error:n instanceof Error?n.message:String(n)})}}).catch(t=>{e||l({status:`error`,svg:``,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},d=[n,a],t[4]=n,t[5]=a,t[6]=u,t[7]=d):(u=t[6],d=t[7]),(0,Y.useEffect)(u,d),!n.trim()){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{className:`mermaid mermaid-placeholder`,"data-component-type":`mermaid`,children:(0,X.jsx)(`span`,{className:`mermaid-empty`,children:` `})}),t[8]=e):e=t[8],e}if(c.status===`error`){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(He,{className:`size-3.5 shrink-0 mt-0.5`,"aria-hidden":!0}),t[9]=e):e=t[9];let r;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(`div`,{className:`font-medium`,children:(0,X.jsx)(o,{id:`OLBz-_`})}),t[10]=r):r=t[10];let i;t[11]===c.error?i=t[12]:(i=(0,X.jsxs)(`div`,{role:`alert`,className:`mermaid-error-message mb-2 flex items-start gap-2 rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive`,children:[e,(0,X.jsxs)(`div`,{className:`min-w-0`,children:[r,(0,X.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words font-mono text-[11px] opacity-90`,children:c.error})]})]}),t[11]=c.error,t[12]=i);let a;t[13]===n?a=t[14]:(a=(0,X.jsx)(`pre`,{className:`mermaid-error-source`,children:n}),t[13]=n,t[14]=a);let s;return t[15]!==c.error||t[16]!==i||t[17]!==a?(s=(0,X.jsxs)(`div`,{className:`mermaid mermaid-error`,"data-component-type":`mermaid`,title:c.error,children:[i,a]}),t[15]=c.error,t[16]=i,t[17]=a,t[18]=s):s=t[18],s}let f=`mermaid mermaid-${c.status}`,p;t[19]===c.svg?p=t[20]:(p={__html:c.svg},t[19]=c.svg,t[20]=p);let m;return t[21]!==f||t[22]!==p?(m=(0,X.jsx)(`div`,{className:f,"data-component-type":`mermaid`,dangerouslySetInnerHTML:p}),t[21]=f,t[22]=p,t[23]=m):m=t[23],m}function sA(e){return{...e,status:`rendering`}}var cA=null;function lA(){return cA||=new V({extensions:B}),cA}function uA(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=uA(e,t);if(n)return n}return null}function dA(e){return se({type:`root`,children:e.children??[]})}var fA=new Map,pA=30,mA=150,hA=1e4;function gA(e,t){let n=`${e}|${t}`,r=fA.get(n);if(r)return r.refcount+=1,r;let i=new eh,a=new ZE({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()}),fA.set(n,s),fA.size>pA&&console.warn(`[Mirror] provider pool exceeded ${pA} entries (current=${fA.size}). Many Mirrors pointing at distinct source docs — investigate if this is a runaway pattern.`),s}function _A(e,t){let n=`${e}|${t}`,r=fA.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})}fA.delete(n)}}function vA(e,t){let n=(0,J.c)(8),{collabUrl:r}=eS(),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={kind:`loading`},n[0]=i):i=n[0];let[a,o]=(0,Y.useState)(i),s=(0,Y.useRef)(t),c=(0,Y.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=gA(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=lA().parseToMdast(r)}catch(t){console.warn(`[Mirror] parseToMdast failed`,{src:e,anchor:n,err:t}),o({kind:`source-removed`});return}let a=uA(i,n);if(!a){o({kind:`anchor-not-found`});return}let c;try{c=dA(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()},mA)},onSynced:()=>{i&&=(clearTimeout(i),null),n()}};t.subscribers.add(a),c.current=n;let l=setTimeout(()=>{t.synced||o({kind:`source-removed`})},hA);return n(),()=>{clearTimeout(l),i&&clearTimeout(i),t.subscribers.delete(a),c.current=null,_A(r,e)}},u=[r,e],n[1]=r,n[2]=e,n[3]=l,n[4]=u):(l=n[3],u=n[4]),(0,Y.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,Y.useEffect)(d,f),a}function yA(e){let t=(0,J.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,X.jsx)(ya,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,X.jsx)(xa,{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,X.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,X.jsxs)(`div`,{className:n,children:[r,i]}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bA(e){let t=(0,J.c)(30),n=e.src??``,r=e.anchor??``,i=vA(n,r);if(i.kind===`empty-props`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(yA,{tone:`placeholder`,children:(0,X.jsx)(o,{id:`3SDfZl`,components:{0:(0,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{}),2:(0,X.jsx)(`code`,{}),3:(0,X.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,X.jsx)(`code`,{})},t[3]=a):a=t[3];let s;return t[4]===i?s=t[5]:(s=(0,X.jsx)(yA,{tone:`placeholder`,children:(0,X.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,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{})},t[8]=r):r=t[8];let i;return t[9]===e?i=t[10]:(i=(0,X.jsx)(yA,{tone:`error`,children:(0,X.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,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{}),2:(0,X.jsx)(`code`,{})},t[14]=a):a=t[14];let s;return t[15]===i?s=t[16]:(s=(0,X.jsx)(yA,{tone:`error`,children:(0,X.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,X.jsx)(Zi,{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,X.jsx)(`code`,{className:`font-mono`})},t[20]=c):c=t[20];let l;t[21]===s?l=t[22]:(l=(0,X.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,X.jsx)(`span`,{children:(0,X.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,X.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,X.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 xA(e){let t=(0,J.c)(15),{_:n}=i(),r=e.id??``,a;t[0]!==n||t[1]!==r?(a=r||n({id:`12F9WL`}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let s=a,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(Xi,{className:`size-3`,"aria-hidden":`true`}),t[3]=c):c=t[3];let l;t[4]===s?l=t[5]:(l={label:s},t[4]=s,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={0:(0,X.jsx)(`code`,{className:`font-mono`})},t[6]=u):u=t[6];let d;t[7]===l?d=t[8]:(d=(0,X.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,X.jsx)(`span`,{children:(0,X.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,X.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,X.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 SA=24,CA=24,wA=12,TA=.1;function EA(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(TA,(n-SA)/t.naturalWidth);case`fit-height`:return Math.max(TA,(r-CA)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(TA,((n-SA)/2-wA)/t.naturalWidth)}}var DA=600,OA=.5,kA=3,AA=.25,jA=null;function MA(){return jA||(jA=(async()=>{let e=await n(()=>import(`./pdf-CtJiipL_.js`),__vite__mapDeps([24,1]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-BZq-wJdz.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),jA.catch(()=>{jA=null})),jA}function NA(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function PA(e){let t=(0,J.c)(96),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=_(e.anchor);n=i===null?e.fillContainer?`100%`:`${DA}px`:`${i}px`,r=BA(a),t[0]=e.anchor,t[1]=e.fillContainer,t[2]=n,t[3]=r}else n=t[2],r=t[3];let a=r,s=(0,Y.useRef)(null),c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[4]=c):c=t[4];let l=(0,Y.useRef)(c),u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[5]=u):u=t[5];let d=(0,Y.useRef)(u),f=(0,Y.useRef)(null),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[6]=p):p=t[6];let[m,h]=(0,Y.useState)(p),[g,v]=(0,Y.useState)(!0),[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(a??1),[C,w]=(0,Y.useState)(String(a??1)),[T,E]=(0,Y.useState)(1),[D,O]=(0,Y.useState)(`fit-width`),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)(0),[F,I]=(0,Y.useState)(0),{_:L}=i(),ee=m.length,R,z;t[7]!==L||t[8]!==e.src?(R=()=>{if(!e.src){v(!1);return}let t=Re(e.src),n=!1,r=null;return v(!0),b(null),(async()=>{try{let e=await(await MA()).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;b(t instanceof Error?t.message:L({id:`jRHdCz`})),v(!1)}})(),()=>{n=!0,r&&=(r.destroy(),null),f.current=null}},z=[e.src,L],t[7]=L,t[8]=e.src,t[9]=R,t[10]=z):(R=t[9],z=t[10]),(0,Y.useEffect)(R,z);let te,B;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{let e=s.current;if(!e)return;let t=()=>{P(e.clientWidth),I(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},B=[],t[11]=te,t[12]=B):(te=t[11],B=t[12]),(0,Y.useEffect)(te,B);let ne,V;t[13]!==L||t[14]!==F||t[15]!==N||t[16]!==D||t[17]!==m||t[18]!==T?(ne=()=>{let e=f.current;if(!e||m.length===0||N===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=EA(D,i,N,F)*T,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||v(!1)}catch(e){let n=e;if(t||NA(n))return;console.warn(`[Pdf] page render failed:`,n),b(n instanceof Error?n.message:L({id:`_TF8ep`})),v(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},V=[m,D,T,N,F,L],t[13]=L,t[14]=F,t[15]=N,t[16]=D,t[17]=m,t[18]=T,t[19]=ne,t[20]=V):(ne=t[19],V=t[20]),(0,Y.useEffect)(ne,V);let re,ie;t[21]!==m||t[22]!==k?(re=()=>{if(!k)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;NA(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},ie=[k,m],t[21]=m,t[22]=k,t[23]=re,t[24]=ie):(re=t[23],ie=t[24]),(0,Y.useEffect)(re,ie);let H,ae;t[25]!==g||t[26]!==a?(H=()=>{if(g||!a)return;let e=s.current,t=l.current[a-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},ae=[g,a],t[25]=g,t[26]=a,t[27]=H,t[28]=ae):(H=t[27],ae=t[28]),(0,Y.useEffect)(H,ae);let oe,U;t[29]===m?(oe=t[30],U=t[31]):(oe=()=>{let e=s.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)}S(r),w(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},U=[m],t[29]=m,t[30]=oe,t[31]=U),(0,Y.useEffect)(oe,U);let se,ce;t[32]===j?(se=t[33],ce=t[34]):(se=()=>{if(!j)return;let e=e=>{let t=e.target,n=s.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){M(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&M(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},ce=[j],t[32]=j,t[33]=se,t[34]=ce),(0,Y.useEffect)(se,ce);let W;t[35]===ee?W=t[36]:(W=e=>{let t=Math.max(1,Math.min(ee||1,e));S(t),w(String(t));let n=s.current,r=l.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[35]=ee,t[36]=W);let le=W,ue;t[37]!==x||t[38]!==le||t[39]!==C?(ue=()=>{let e=Number.parseInt(C,10);if(Number.isNaN(e)){w(String(x));return}le(e)},t[37]=x,t[38]=le,t[39]=C,t[40]=ue):ue=t[40];let de=ue,fe;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>E(RA),t[41]=fe):fe=t[41];let pe=fe,me;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>E(LA),t[42]=me):me=t[42];let he=me,ge;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>{O(e),M(!1),E(1)},t[43]=ge):ge=t[43];let _e=ge,ve;t[44]===n?ve=t[45]:(ve={height:n},t[44]=n,t[45]=ve);let ye;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>A(IA),t[46]=ye):ye=t[46];let be;t[47]!==L||t[48]!==k?(be=L(k?{id:`JK-Ave`}:{id:`iEYxO4`}),t[47]=L,t[48]=k,t[49]=be):be=t[49];let xe;t[50]===L?xe=t[51]:(xe=L({id:`zo3Dl7`}),t[50]=L,t[51]=xe);let Se;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,X.jsx)(ka,{size:14,"aria-hidden":`true`}),t[52]=Se):Se=t[52];let Ce;t[53]!==k||t[54]!==be||t[55]!==xe?(Ce=(0,X.jsx)(`button`,{type:`button`,onClick:ye,"aria-label":be,"aria-pressed":k,className:`ok-pdf-btn`,title:xe,children:Se}),t[53]=k,t[54]=be,t[55]=xe,t[56]=Ce):Ce=t[56];let we=e.title??`PDF`,Te;t[57]===we?Te=t[58]:(Te=(0,X.jsx)(`span`,{className:`ok-pdf-title`,children:we}),t[57]=we,t[58]=Te);let Ee;t[59]!==L||t[60]!==j||t[61]!==D||t[62]!==C||t[63]!==de||t[64]!==ee||t[65]!==T?(Ee=ee>0&&(0,X.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,X.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),de()},children:(0,X.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:C,onChange:e=>w(e.target.value.replace(/[^0-9]/g,``)),onBlur:de,"aria-label":L({id:`xsZhu-`})})}),(0,X.jsx)(`span`,{className:`ok-pdf-page-of`,children:(0,X.jsx)(o,{id:`1GhYxC`,values:{totalPages:ee}})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:he,disabled:T<=OA,"aria-label":L({id:`FjkaiT`}),className:`ok-pdf-btn`,title:L({id:`FjkaiT`}),children:(0,X.jsx)(Qa,{size:14,"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(T*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,onClick:pe,disabled:T>=kA,"aria-label":L({id:`AWOSPo`}),className:`ok-pdf-btn`,title:L({id:`AWOSPo`}),children:(0,X.jsx)(Za,{size:14,"aria-hidden":`true`})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`ok-pdf-layout-menu`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>M(FA),"aria-label":L({id:`GQDSBN`}),"aria-haspopup":`menu`,"aria-expanded":j,className:`ok-pdf-btn`,title:L({id:`rdU729`}),children:(0,X.jsx)(Hi,{size:14,"aria-hidden":`true`})}),j&&(0,X.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,X.jsx)(zA,{label:L({id:`vIxrEk`}),active:D===`fit-width`,onSelect:()=>_e(`fit-width`)}),(0,X.jsx)(zA,{label:L({id:`YlDuro`}),active:D===`fit-height`,onSelect:()=>_e(`fit-height`)}),(0,X.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,X.jsx)(zA,{label:L({id:`BGHHtQ`}),active:D===`single`,onSelect:()=>_e(`single`)}),(0,X.jsx)(zA,{label:L({id:`xK291b`}),active:D===`two-odd`,onSelect:()=>_e(`two-odd`)}),(0,X.jsx)(zA,{label:L({id:`NSnIUP`}),active:D===`two-even`,onSelect:()=>_e(`two-even`)})]})]})]}),t[59]=L,t[60]=j,t[61]=D,t[62]=C,t[63]=de,t[64]=ee,t[65]=T,t[66]=Ee):Ee=t[66];let De;t[67]!==Ce||t[68]!==Te||t[69]!==Ee?(De=(0,X.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[Ce,Te,Ee]}),t[67]=Ce,t[68]=Te,t[69]=Ee,t[70]=De):De=t[70];let Oe;t[71]!==L||t[72]!==x||t[73]!==le||t[74]!==m||t[75]!==k?(Oe=k&&(0,X.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":L({id:`nzaV6Q`}),children:m.map((e,t)=>{let{pageNumber:n}=e;return(0,X.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":x===n||void 0,onClick:()=>le(n),"aria-label":L({id:`qioCwA`,values:{pageNumber:n}}),children:[(0,X.jsx)(`canvas`,{ref:e=>{d.current[t]=e},className:`ok-pdf-thumb-canvas`}),(0,X.jsx)(`span`,{className:`ok-pdf-thumb-num`,children:n})]},n)})}),t[71]=L,t[72]=x,t[73]=le,t[74]=m,t[75]=k,t[76]=Oe):Oe=t[76];let ke;t[77]===g?ke=t[78]:(ke=g&&(0,X.jsx)(`div`,{className:`ok-pdf-loading`,children:(0,X.jsx)(o,{id:`T-654M`})}),t[77]=g,t[78]=ke);let Ae;t[79]===y?Ae=t[80]:(Ae=y&&(0,X.jsx)(`div`,{className:`ok-pdf-error`,children:(0,X.jsx)(o,{id:`WamGNs`,values:{error:y}})}),t[79]=y,t[80]=Ae);let je;t[81]!==L||t[82]!==ee?(je=Array.from({length:ee},(e,t)=>{let n=t+1;return(0,X.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-page`,"aria-label":L({id:`XtRoxT`,values:{pageNumber:n}})},n)}),t[81]=L,t[82]=ee,t[83]=je):je=t[83];let Me;t[84]!==D||t[85]!==ke||t[86]!==Ae||t[87]!==je?(Me=(0,X.jsxs)(`div`,{className:`ok-pdf-pages`,ref:s,"data-layout":D,children:[ke,Ae,je]}),t[84]=D,t[85]=ke,t[86]=Ae,t[87]=je,t[88]=Me):Me=t[88];let Ne;t[89]!==Oe||t[90]!==Me?(Ne=(0,X.jsxs)(`div`,{className:`ok-pdf-body`,children:[Oe,Me]}),t[89]=Oe,t[90]=Me,t[91]=Ne):Ne=t[91];let Pe;return t[92]!==ve||t[93]!==De||t[94]!==Ne?(Pe=(0,X.jsxs)(`div`,{className:`ok-pdf`,style:ve,children:[De,Ne]}),t[92]=ve,t[93]=De,t[94]=Ne,t[95]=Pe):Pe=t[95],Pe}function FA(e){return!e}function IA(e){return!e}function LA(e){return Math.max(OA,+(e-AA).toFixed(2))}function RA(e){return Math.min(kA,+(e+AA).toFixed(2))}function zA(e){let t=(0,J.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,X.jsx)(ar,{size:14}),t[0]=e.active,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,X.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,X.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 BA(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 VA(e){let t=(0,J.c)(10),{label:n,id:r,children:i}=e,a=(0,Y.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,X.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 HA=`[data-component-type="tabs"]`,UA=`[data-node-view-content-react] > .react-renderer`;function WA(e){let t=e.closest(HA);return t?Array.from(e.querySelectorAll(UA)).filter(e=>e.parentElement?.closest(HA)===t).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 GA(e){let t=(0,J.c)(33),{id:n,children:r}=e,[a,o]=(0,Y.useState)(0),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Y.useState)(s),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),f=(0,Y.useRef)(0),p=sk(),m=p?.addChild!=null,{_:h}=i(),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=u.current;if(!e)return;let t=WA(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,Y.useLayoutEffect)(g);let _,v;t[2]===c.length?(_=t[3],v=t[4]):(_=()=>{c.length>f.current&&c.length>0&&o(c.length-1),f.current=c.length},v=[c.length],t[2]=c.length,t[3]=_,t[4]=v),(0,Y.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){o(0);return}let t=u.current;if(!t)return;let r=WA(t).findIndex(t=>t.panelId===e);r<0||(o(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,Y.useLayoutEffect)(y);let b=c.length===0?0:Math.min(Math.max(a,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(),o(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;if(t[10]!==c||t[11]!==b){let e;t[13]===b?e=t[14]:(e=e=>(0,X.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:qA,onClick:()=>o(e.index),children:e.label},e.index),t[13]=b,t[14]=e),w=c.map(e),t[10]=c,t[11]=b,t[12]=w}else w=t[12];let T;t[15]!==S||t[16]!==C||t[17]!==w?(T=(0,X.jsx)(`div`,{ref:d,role:`tablist`,"aria-label":C,className:`tabs-tablist`,onKeyDown:S,children:w}),t[15]=S,t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==h||t[20]!==m||t[21]!==p?(E=m&&(0,X.jsx)(`button`,{type:`button`,className:`tabs-strip-add`,"aria-label":h({id:`hjO0Mq`}),title:h({id:`hjO0Mq`}),onMouseDown:KA,onClick:()=>p?.addChild?.(),"data-tabs-strip-add":``,children:`+`}),t[19]=h,t[20]=m,t[21]=p,t[22]=E):E=t[22];let D;t[23]!==E||t[24]!==T?(D=(0,X.jsxs)(`div`,{className:`tabs-strip`,contentEditable:!1,children:[T,E]}),t[23]=E,t[24]=T,t[25]=D):D=t[25];let O;t[26]!==r||t[27]!==b?(O=(0,X.jsx)(`div`,{ref:u,className:`tabs-content`,"data-active-index":b,children:r}),t[26]=r,t[27]=b,t[28]=O):O=t[28];let k;return t[29]!==n||t[30]!==D||t[31]!==O?(k=(0,X.jsxs)(`div`,{className:`tabs`,id:n,children:[D,O]}),t[29]=n,t[30]=D,t[31]=O,t[32]=k):k=t[32],k}function KA(e){return e.preventDefault()}function qA(e){return e.preventDefault()}var JA=typeof global<`u`&&{}.toString.call(global)===`[object global]`,YA=typeof Bun<`u`,XA=typeof Deno<`u`,ZA=typeof WebSocketPair==`function`&&caches?.default!==void 0,QA=JA||YA||XA||ZA;function $A(e,t){return e.indexOf(t.toLowerCase())===0?e:`${t.toLowerCase()}${e.substr(0,1).toUpperCase()}${e.substr(1)}`}function ej(e){return!!(e&&e.nodeType===1&&`nodeName`in e&&e.ownerDocument&&e.ownerDocument.defaultView)}function tj(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function nj(e){return/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))(?=$|\/)/.test(e)}function rj(e){return/^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))\/video\/\d+/.test(e)}function ij(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 aj(){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(tj(r))return`https://vimeo.com/${r}`;if(nj(r))return r.replace(`http:`,`https:`);throw TypeError(t?`“${t}” is not a valid video id.`:`“${r}” is not a vimeo.com url.`)}var oj=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 sj(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 cj=Array.prototype.indexOf!==void 0,lj=typeof window<`u`&&window.postMessage!==void 0;if(!QA&&(!cj||!lj))throw Error(`Sorry, the Vimeo Player API is not available in this browser.`);var uj=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function dj(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:uj);var fj=dj(function(e){(function(t,n,r){n[t]=n[t]||r(),e.exports&&=n[t]})(`Promise`,uj,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})}),pj=new WeakMap;function mj(e,t,n){let r=pj.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),pj.set(e.element,r)}function hj(e,t){return(pj.get(e.element)||{})[t]||[]}function gj(e,t,n){let r=pj.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],pj.set(e.element,r),!0;let i=r[t].indexOf(n);return i!==-1&&r[t].splice(i,1),pj.set(e.element,r),r[t]&&r[t].length===0}function _j(e,t){let n=hj(e,t);if(n.length<1)return!1;let r=n.shift();return gj(e,t,r),r}function vj(e,t){let n=pj.get(e);pj.set(t,n),pj.delete(e)}function yj(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){return console.warn(e),{}}return e}function bj(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 xj(e,t){t=yj(t);let n=[],r;if(t.event)t.event===`error`&&hj(e,t.data.method).forEach(n=>{let r=Error(t.data.message);r.name=t.data.name,n.reject(r),gj(e,t.data.method,n)}),n=hj(e,`event:${t.event}`),r=t.data;else if(t.method){let i=_j(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 Sj=`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 Cj(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Sj.reduce((t,n)=>{let r=e.getAttribute(`data-vimeo-${n}`);return(r||r===``)&&(t[n]=r===``?1:r),t},t)}function wj(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 Tj(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(!nj(e))throw TypeError(`“${e}” is not a vimeo.com url.`);let a=`https://${ij(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){wj(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 Ej(){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=Cj(e);Tj(aj(t),t,e).then(t=>wj(t,e)).catch(n)}catch(e){n(e)}})}function Dj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoPlayerResizeEmbeds_||(window.VimeoPlayerResizeEmbeds_=!0,window.addEventListener(`message`,t=>{if(!nj(t.origin)||!t.data||t.data.event!==`spacechange`)return;let n=t.source?sj(t.source,e):null;if(n){let e=n.parentElement;e.style.paddingBottom=`${t.data.data[0].bottom}px`}}))}function Oj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener(`message`,t=>{if(!nj(t.origin))return;let n=yj(t.data);if(!n||n.event!==`ready`)return;let r=t.source?sj(t.source,e):null;r&&rj(r.src)&&new Lj(r).callMethod(`appendVideoMetadata`,window.location.href)}))}function kj(){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(!nj(n.origin))return;let r=yj(n.data);if(!r||r.event!==`ready`)return;let i=n.source?sj(n.source,e):null;if(i&&rj(i.src)){let e=new Lj(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 Aj(){window.VimeoDRMEmbedsUpdated||(window.VimeoDRMEmbedsUpdated=!0,window.addEventListener(`message`,e=>{if(!nj(e.origin))return;let t=yj(e.data);if(!t||t.event!==`drminitfailed`)return;let n=e.source?sj(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 jj(){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 Mj={role:`viewer`,autoPlayMuted:!0,allowedDrift:.3,maxAllowedDrift:1,minCheckInterval:.1,maxRateAdjustment:.2,maxTimeToCatchUp:1},Nj=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,{...Mj,...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=oj(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=oj(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()})}},Pj=new WeakMap,Fj=new WeakMap,Ij={},Lj=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)),!ej(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`&&!nj(e.getAttribute(`src`)||``))throw Error(`The player element passed isn’t a Vimeo embed.`);if(Pj.has(e))return Pj.get(e);this._window=e.ownerDocument.defaultView,this.element=e,this.origin=`*`;let n=new fj((n,r)=>{if(this._onMessage=e=>{if(!nj(e.origin)||this.element.contentWindow!==e.source)return;this.origin===`*`&&(this.origin=e.origin);let t=yj(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}xj(this,t)},this._window.addEventListener(`message`,this._onMessage),this.element.nodeName!==`IFRAME`){let n=Cj(e,t);Tj(aj(n),n,e).then(t=>{let n=wj(t,e);return this.element=n,this._originalElement=e,vj(e,n),Pj.set(this.element,this),t}).catch(r)}});if(Fj.set(this,n),Pj.set(this.element,this),this.element.nodeName===`IFRAME`&&bj(this,`ping`),Ij.isEnabled){let e=()=>Ij.exit();this.fullscreenchangeHandler=()=>{Ij.isFullscreen?mj(this,`event:exitFullscreen`,e):gj(this,`event:exitFullscreen`,e),this.ready().then(()=>{bj(this,`fullscreenchange`,Ij.isFullscreen)})},Ij.on(`fullscreenchange`,this.fullscreenchangeHandler)}return this}static isVimeoUrl(e){return nj(e)}callMethod(e){var t=[...arguments].slice(1);if(e==null)throw TypeError(`You must pass a method name.`);return new fj((n,r)=>this.ready().then(()=>{mj(this,e,{resolve:n,reject:r}),t.length===0?t={}:t.length===1&&(t=t[0]),bj(this,e,t)}).catch(r))}get(e){return new fj((t,n)=>(e=$A(e,`get`),this.ready().then(()=>{mj(this,e,{resolve:t,reject:n}),bj(this,e)}).catch(n)))}set(e,t){return new fj((n,r)=>{if(e=$A(e,`set`),t==null)throw TypeError(`There must be a value to set.`);return this.ready().then(()=>{mj(this,e,{resolve:n,reject:r}),bj(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.`);hj(this,`event:${e}`).length===0&&this.callMethod(`addEventListener`,e).catch(()=>{}),mj(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.`);gj(this,`event:${e}`,t)&&this.callMethod(`removeEventListener`,e).catch(e=>{})}loadVideo(e){return this.callMethod(`loadVideo`,e)}ready(){let e=Fj.get(this)||new fj((e,t)=>{t(Error(`Unknown player. Probably unloaded.`))});return fj.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 Ij.isEnabled?Ij.request(this.element):this.callMethod(`requestFullscreen`)}exitFullscreen(){return Ij.isEnabled?Ij.exit():this.callMethod(`exitFullscreen`)}getFullscreen(){return Ij.isEnabled?fj.resolve(Ij.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 fj(e=>{if(Fj.delete(this),Pj.delete(this.element),this._originalElement&&(Pj.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),Ij.isEnabled&&Ij.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 fj.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 fj((e,t)=>t(TypeError(`Argument must be an array.`)));let t=new fj(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 fj.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 Nj(this,e,t);return bj(this,`notifyTimingObjectConnect`),n.addEventListener(`disconnect`,()=>bj(this,`notifyTimingObjectDisconnect`)),n}};QA||(Ij=jj(),Ej(),Dj(),Oj(),kj(),Aj());function Rj(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,zj(e,t)}function zj(e,t){return zj=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},zj(e,t)}var Bj={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`},Vj=function(e){function t(t){var n=e.call(this,t)||this;return n.refContainer=n.refContainer.bind(n),n}Rj(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 Lj(this.container,this.getInitialOptions()),Object.keys(Bj).forEach(function(t){var n=Bj[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 Y.createElement(`div`,{id:t,className:n,style:r,ref:this.refContainer})},t}(Y.Component);Vj.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 Hj={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},Uj=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Y.useState)(``);return(0,Y.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=Hj[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 Wj(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 Gj(e,t){let[n,r]=Y.useState(!1),[i,a]=Y.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=Y.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=Y.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Y.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?Uj(e.id,_,g,l):null,y=Y.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=Y.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 Y.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Y.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,X.jsxs)(X.Fragment,{children:[!e.lazyLoad&&(0,X.jsx)(`link`,{rel:O,href:y,as:`image`}),(0,X.jsx)(X.Fragment,{children:n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:p}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://www.google.com`}),x&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://static.doubleclick.net`}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://googleads.g.doubleclick.net`})]})]})}),e.seo&&!e.playlist&&(0,X.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:Wj(e.id,c,y,p,e.seo)}}),A&&!e.playlist&&(0,X.jsx)(`noscript`,{children:(0,X.jsxs)(`a`,{href:`https://www.youtube.com/watch?v=${e.id}`,"aria-label":`Watch ${c} on YouTube`,children:[`Watch "`,c,`" on YouTube`]})}),(0,X.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,X.jsx)(`img`,{src:y,alt:`${c} - YouTube thumbnail`,className:`lty-thumbnail`,loading:`lazy`}),e.playlist&&!i&&(0,X.jsx)(`div`,{className:`lty-playlist-icon`,"aria-hidden":`true`}),!(e.hideButtonOnActivate&&i)&&(0,X.jsx)(`button`,{type:`button`,className:T,"aria-label":`${u} ${c}`,"aria-hidden":i||void 0,tabIndex:i?-1:0,onClick:M,children:(0,X.jsx)(`span`,{className:`lty-visually-hidden`,children:u})}),i&&(0,X.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 Kj=Y.forwardRef(Gj);function qj(e){return e!==!1}function Jj(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 Yj(e){if(e.width!==void 0)return{width:e.width}}function Xj(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function Zj(e){let t=(0,J.c)(23),n=(0,Y.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,Y.useEffect)(o,s);let c;t[5]===e?c=t[6]:(c=Yj(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,X.jsx)(Vj,{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,X.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 Qj(e){let t=(0,J.c)(17),n;t[0]===e.src?n=t[1]:(n=bn(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=Yj(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,X.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,X.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 $j(e){let t=(0,J.c)(29);if(e.src!==void 0&&ke(e.src)){let n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(Qj,{...e,src:e.src}),t[0]=e,t[1]=n),n}if(e.src!==void 0&&m(e.src)){let n;return t[2]===e?n=t[3]:(n=(0,X.jsx)(Zj,{...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:M(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=Yj(e),s;t[6]===e.poster?s=t[7]:(s=e.poster===void 0?void 0:Re(e.poster),t[6]=e.poster,t[7]=s);let c=(0,X.jsx)(Kj,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:Jj(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:Xj(e)}),l;t[8]!==o||t[9]!==c?(l=(0,X.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:Re(e.src),t[11]=e.src,t[12]=r);let i=e.title,a;t[13]===e.controls?a=t[14]:(a=qj(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:Re(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,X.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 eM(e){let t=(0,J.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,X.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var tM={Callout:ik,img:eA,video:$j,audio:$O,Pdf:PA,File:_k,Embed:hk,Accordion:ZO,Tabs:GA,Tab:VA,Math:rA,MermaidFence:oA,Mirror:bA,MirrorSource:xA,"*":eM};function nM(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var rM=ne(),iM=new Map;function aM(e){if(e.surface===`compat`){let t=tM[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:nM(e.props)}}let t=tM[e.name];return t?{Component:t,reactNodePropNames:nM(e.props)}:null}for(let[e,t]of rM.entries()){let n=aM(t);n&&iM.set(e,n)}function oM(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function sM(e){let t=rM.getOrWildcard(e),n=iM.get(t.name)??iM.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return oM(t,n)}function cM(){let e=[];for(let[t,n]of rM.entries()){if(t===`*`)continue;let r=iM.get(t);r&&e.push(oM(n,r))}return e}var lM=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,uM=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,dM={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:lM,alt:`Sample image`}},video:{description:{id:`e1hptq`},props:{controls:!0,poster:uM}},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,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.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,X.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1.5 w-full rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-5/6 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]})]})},Pdf:{description:{id:`Fqr8BP`},render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/40 px-1.5 py-1`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 text-muted-foreground`,"aria-hidden":`true`,children:[(0,X.jsx)(`title`,{children:`Thumbnails`}),(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`1`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`})]}),(0,X.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5 font-mono`,children:`2`}),(0,X.jsx)(`span`,{children:`/ 12`})]}),(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] font-mono text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`−`}),(0,X.jsx)(`span`,{children:`100%`}),(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`+`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 gap-1 p-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex w-6 flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm border border-foreground/60 bg-background`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 rounded-sm bg-background p-1.5`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1/2 rounded-sm bg-foreground/50`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-5/6 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-2/3 rounded-sm bg-muted-foreground/30`})]})]})]})},MermaidFence:{description:{id:`z0a2EA`},render:()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 200 120`,className:`h-full w-full text-foreground`,"aria-hidden":`true`,preserveAspectRatio:`xMidYMid meet`,children:[(0,X.jsx)(`title`,{children:`Mermaid flowchart preview`}),(0,X.jsx)(`defs`,{children:(0,X.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,X.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`currentColor`})})}),(0,X.jsx)(`rect`,{x:`14`,y:`20`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`42`,y:`38`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Start`}),(0,X.jsx)(`polygon`,{points:`100,18 140,50 100,82 60,50`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`100`,y:`54`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Ready?`}),(0,X.jsx)(`rect`,{x:`130`,y:`84`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`158`,y:`102`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`End`}),(0,X.jsx)(`line`,{x1:`70`,y1:`34`,x2:`80`,y2:`40`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`line`,{x1:`124`,y1:`62`,x2:`138`,y2:`82`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`text`,{x:`138`,y:`74`,fontSize:`8`,fill:`currentColor`,opacity:`0.6`,children:`yes`})]})},Tabs:{description:{id:`75Y1dk`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex gap-1 border-b border-border pb-1`,children:[(0,X.jsx)(`span`,{className:`rounded-md bg-foreground/10 px-2 py-0.5 text-xs font-medium text-foreground`,children:`Tab 1`}),(0,X.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs text-muted-foreground`,children:`Tab 2`})]}),(0,X.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:(0,X.jsx)(o,{id:`m6YGpY`})})]})},Mirror:{description:{id:`8TLE9g`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/40 px-2 py-1.5`,children:[(0,X.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,X.jsx)($i,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`EL_YRd`,components:{0:(0,X.jsx)(`code`,{className:`font-mono`})}})})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,X.jsx)(o,{id:`qNOgUu`})})]})},MirrorSource:{description:{id:`-KCZ6n`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/50 px-2 py-1.5`,children:[(0,X.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,X.jsx)(Xi,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`maDWIB`,components:{0:(0,X.jsx)(`code`,{className:`font-mono`})}})})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-4/5 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-3/5 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,X.jsx)(o,{id:`emgiet`})})]})}};function fM(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 pM(e){let t=sM(e),n=fM(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var mM=new Set;function hM(e){mM.add(e)}function gM(e){if(typeof e==`number`)return mM.delete(e);let t=mM.values().next();return t.done?!1:(mM.delete(t.value),!0)}function _M(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(hM(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function vM(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=pM(e.name);if(e.name===`Tabs`){let e=pM(`Tab`),t=pM(`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)&&_M(t,i,e)}}var yM=new Set([`File`,`Tab`]);function bM(){return[{name:`component-File`,label:G._({id:`J2eKUI`}),icon:ia,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",command:SM,preview:{description:G._({id:`t-JXbf`}),render:()=>(0,X.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5`,children:[(0,X.jsx)(ia,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:`quarterly-report.pdf`}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`1.4 MB`})]})}}]}function xM(){return[...cM().filter(e=>e.surface===`canonical`&&!yM.has(e.name)).map(e=>{let t=dM[e.name],n=e.Component,r=t?{description:G._(t.description),render:t.render??(()=>(0,X.jsx)(n,{...t.props,children:t.children}))}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:qO(e.icon),category:e.category??`content`,command:vM(e),aliases:e.searchTerms,description:e.description,preview:r}}),...bM()]}function SM(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;xO(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function CM(e,t){let n=EO.getState(e.state);if(!n)return null;for(let e of n.byId.values())if(e.markType===`link`&&e.from<=t&&t<e.to)return e.id;return null}function wM(){return[{name:`link`,label:G._({id:`yzF66j`}),icon:xa,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:G._({id:`5WDhAk`}),render:()=>(0,X.jsx)(`p`,{className:`leading-7 text-sm`,children:(0,X.jsx)(o,{id:`u-9fWA`,components:{0:(0,X.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=CM(e,t);n&&(wO(n),requestAnimationFrame(()=>{GO(e).setActiveNode(n)}))}},{name:`component-Tag`,label:G._({id:`UL8A9w`}),icon:ua,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:G._({id:`5ClEAu`}),render:()=>(0,X.jsx)(`p`,{className:`text-sm leading-7`,children:(0,X.jsx)(o,{id:`KZLdgR`,components:{0:(0,X.jsx)(`a`,{className:`tag pointer-events-none`})}})})},command:e=>{e.chain().insertTag(``).run()}}]}function TM(e,t){e.chain().focus().insertContent({type:`codeBlock`,attrs:{language:`html`,meta:`preview`},content:[{type:`text`,text:t}]}).run()}var EM=`<div style="padding:20px;font-family:system-ui,sans-serif;color:var(--foreground)">
|
|
6
|
+
`);return/\s/.test(n)}):!1}var Xy=new W(`suggestion`);function Zy({pluginKey:e=Xy,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=Jy,shouldShow:g,shouldResetDismissed:_}){let v,y=p?.(),b=r&&!i,x=()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=t.view.coordsAtPos(e);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}},C=(n,r)=>r?()=>{let r=e.getState(t.state)?.decorationId;return n.dom.querySelector(`[data-decoration-id="${r}"]`)?.getBoundingClientRect()||null}:x,w=({match:e,dismissedRange:n,state:r,transaction:i})=>_?.({editor:t,state:r,range:n,match:e,transaction:i,allowSpaces:b})?!1:b?e.range.from===n.from:e.range.from===n.from&&!Yy(i);function T(n,r){var i;try{let r=e.getState(n.state),a=r?.decorationId?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,o={editor:t,range:r?.range||{from:0,to:0},query:r?.query||null,text:r?.text||null,items:[],command:e=>d({editor:t,range:r?.range||{from:0,to:0},props:e}),decorationNode:a,clientRect:C(n,a)};(i=y?.onExit)==null||i.call(y,o)}catch{}let a=n.state.tr.setMeta(r,{exit:!0});n.dispatch(a)}let E=new U({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,g=p||u&&h,_=h||u,b=m||u&&h;if(!g&&!_&&!b)return;let x=b&&!g?c:l,S=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);v={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:S,clientRect:C(e,S)},g&&((r=y?.onBeforeStart)==null||r.call(y,v)),_&&((i=y?.onBeforeUpdate)==null||i.call(y,v)),(_||g)&&(v.items=await f({editor:t,query:x.query})),b&&((a=y?.onExit)==null||a.call(y,v)),_&&((o=y?.onUpdate)==null||o.call(y,v)),g&&((s=y?.onStart)==null||s.call(y,v))},destroy:()=>{var e;v&&((e=y?.onExit)==null||e.call(y,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(s,c,l,u){let{isEditable:d}=t,{composing:f}=t.view,{selection:p}=s,{empty:_,from:v}=p,y={...c},b=s.getMeta(e);if(b&&b.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y.dismissedRange=c.active?{...c.range}:c.dismissedRange,y;if(y.composing=f,s.docChanged&&y.dismissedRange!==null&&(y.dismissedRange={from:s.mapping.map(y.dismissedRange.from),to:s.mapping.map(y.dismissedRange.to)}),d&&(_||t.view.composing)){(v<c.range.from||v>c.range.to)&&!f&&!c.composing&&(y.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:p.$from}),l=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:u,range:e.range,isActive:c.active})&&(!g||g({editor:t,range:e.range,query:e.query,text:e.text,transaction:s}))?(y.dismissedRange!==null&&!w({match:e,dismissedRange:y.dismissedRange,state:u,transaction:s})&&(y.dismissedRange=null),y.dismissedRange===null?(y.active=!0,y.decorationId=c.decorationId?c.decorationId:l,y.range=e.range,y.query=e.query,y.text=e.text):y.active=!1):(e||(y.dismissedRange=null),y.active=!1)}else y.active=!1;return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(t,n){var r;let{active:i,range:a}=E.getState(t.state);if(!i)return!1;if(n.key===`Escape`||n.key===`Esc`){let i=E.getState(t.state);return(r=y?.onKeyDown)==null||r.call(y,{view:t,event:n,range:i.range}),T(t,e),!0}return(y?.onKeyDown)?.call(y,{view:t,event:n,range:a})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=E.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),pe.create(e.doc,[S.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return E}var Qy=Zy;function $y(e){return e.kind===`create`?`create:${e.value}`:`tag:${e.value}`}function eb(e){if(e.kind===`create`){let t=e.value;return G._({id:`XPqe3B`,values:{tagValue:t}})}let t=G._({id:`pckX1A`,values:{0:e.count}}),n=e.value;return G._({id:`m2T1Xj`,values:{tagValue:n,uses:t}})}function tb(e){let t=(0,J.c)(38),{items:n,query:r,selectedIndex:a,onSelect:s,onHover:c,loading:l,error:u}=e,d=l===void 0?!1:l,f=u===void 0?null:u,{_:p}=i(),m=(0,Y.useRef)(null),h=(0,Y.useId)(),g=a>=0&&a<n.length?`${h}-option-${a}`:void 0,_,v;t[0]===a?(_=t[1],v=t[2]):(_=()=>{let e=m.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(a);t&&t.scrollIntoView({block:`nearest`})},v=[a],t[0]=a,t[1]=_,t[2]=v),(0,Y.useEffect)(_,v);let y=nb;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,X.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,X.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,X.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=a>=0&&a<n.length?n[a]: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?eb(b):``,t[15]=b,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,X.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,X.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]!==s||t[25]!==a){let e;t[27]!==h||t[28]!==c||t[29]!==s||t[30]!==a?(e=(e,t)=>{let n=t===a,r=$y(e),i=e.kind===`create`;return(0,X.jsxs)(`button`,{id:`${h}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,"data-testid":i?`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(),s(e)},onPointerMove:c?()=>c(t):void 0,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-xs text-muted-foreground`,children:`#`}),(0,X.jsx)(`span`,{className:`truncate font-medium flex-1`,children:e.value}),i?(0,X.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,X.jsx)(o,{id:`isRobC`})}):(0,X.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground tabular-nums`,children:e.count})]},r)},t[27]=h,t[28]=c,t[29]=s,t[30]=a,t[31]=e):e=t[31],E=n.map(e),t[21]=n,t[22]=h,t[23]=c,t[24]=s,t[25]=a,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,X.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 nb(e){return e.preventDefault()}var rb=new WeakMap;function ib(e,t){rb.set(e,t)}function ab(e){return rb.get(e)??!1}function ob(e,t){let n=document.createElement(`div`);n.style.position=`fixed`,n.style.zIndex=`50`,n.style.visibility=`hidden`,document.body.appendChild(n);let r={getBoundingClientRect:()=>e()?.clientRect?.()??new DOMRect,get contextElement(){return e()?.editor.view.dom}},i=!1,a=!1,o=()=>{n.isConnected&&(n.style.removeProperty(`--suggestion-menu-max-height`),R(r,n,{placement:`bottom-start`,middleware:[be(4),Be(),c({padding:8}),lt({apply({availableHeight:e}){n.isConnected&&n.style.setProperty(`--suggestion-menu-max-height`,`${Math.min(e,window.innerHeight*.4)}px`)}})]}).then(({x:e,y:t})=>{n.isConnected&&(n.style.left=`${e}px`,n.style.top=`${t}px`,i&&!a&&(n.style.removeProperty(`visibility`),a=!0))}).catch(e=>{n.isConnected&&console.warn(`[${t}] computePosition failed`,e)}))};return{popup:n,doPosition:o,startAutoUpdate:()=>Ut(r,n,o),reveal:()=>{a||(i=!0,o())}}}function sb(e){e.stopAutoUpdate?.(),e.stopAutoUpdate=null,e.popup?.remove(),e.popup=null}var cb=new W(`tagSuggestion`),lb=8,ub=/^[a-zA-Z][\w/-]*$/;async function db(){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 fb(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 pb(e,t){let n=fb(e,t).slice(0,lb).map(e=>({kind:`tag`,value:e.name,count:e.count,isLeaf:e.isLeaf})),r=t.trim();return r&&ub.test(r)&&!e.some(e=>e.name===r)&&n.push({kind:`create`,value:r}),n}function mb(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 hb(e){let t=[],n=!1,r=null,i=null;return Qy({editor:e,pluginKey:cb,char:`#`,allowedPrefixes:null,findSuggestionMatch:mb,allow:({editor:e})=>!ab(e),items:async({query:e})=>{if(!n){r||=db();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 pb(t,e)},command:({editor:e,range:t,props:n})=>{try{let r=n.value;if(!r||!ub.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=ob(()=>a,`tag-suggestion`);s.popup=n.popup,c=n.doPosition,l=n.reveal,e=new au(tb,{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&&ub.test(n)?(a.command({kind:`create`,value:n}),!0):!1}return e.key,!1},onExit(){sb(s),c=null,l=null,e?.destroy(),e=null,a=null,o=0,t=[],i=null,n=!1,r=null}}}})}var gb=1,_b=.9,vb=.8,yb=.17,bb=.1,xb=.999,Sb=.9999,Cb=.99,wb=/[\\\/_+.#"@\[\(\{&]/,Tb=/[\\\/_+.#"@\[\(\{&]/g,Eb=/[\s-]/,Db=/[\s-]/g;function Ob(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?gb:Cb;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=Ob(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=gb:wb.test(e.charAt(l-1))?(d*=vb,p=e.slice(i,l-1).match(Tb),p&&i>0&&(d*=xb**+p.length)):Eb.test(e.charAt(l-1))?(d*=_b,m=e.slice(i,l-1).match(Db),m&&i>0&&(d*=xb**+m.length)):(d*=yb,i>0&&(d*=xb**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Sb)),(d<bb&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Ob(e,t,n,r,l+1,a+2,o),f*bb>d&&(d=f*bb)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function kb(e){return e.toLowerCase().replace(Db,` `)}function Ab(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Ob(e,t,kb(e),kb(t),0,0,{})}var jb=`[cmdk-group=""]`,Mb=`[cmdk-group-items=""]`,Nb=`[cmdk-group-heading=""]`,Pb=`[cmdk-item=""]`,Fb=`${Pb}:not([aria-disabled="true"])`,Ib=`cmdk-item-select`,Lb=`data-value`,Rb=(e,t,n)=>Ab(e,t,n),zb=Y.createContext(void 0),Bb=()=>Y.useContext(zb),Vb=Y.createContext(void 0),Hb=()=>Y.useContext(Vb),Ub=Y.createContext(void 0),Wb=Y.forwardRef((e,t)=>{let n=ix(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=ix(()=>new Set),i=ix(()=>new Map),a=ix(()=>new Map),o=ix(()=>new Set),s=nx(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Fn(),y=Fn(),b=Fn(),x=Y.useRef(null),S=sx();rx(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),rx(()=>{S(6,k)},[]);let C=Y.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=Y.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??Rb;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(Mb);t?t.appendChild(e.parentElement===t?e:e.closest(`${Mb} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Mb} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${jb}[${Lb}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Lb);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(jb)?.querySelector(Nb))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Pb}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Fb)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Lb))}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(Lb))}function P(e){let t=A()?.closest(jb),n;for(;t&&!n;)t=e>0?ex(t,jb):tx(t,jb),n=t?.querySelector(Fb);n?C.setState(`value`,n.getAttribute(Lb)):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 Y.createElement(jn.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(Ib);t.dispatchEvent(e)}}}}},Y.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:ux},c),lx(e,e=>Y.createElement(Vb.Provider,{value:C},Y.createElement(zb.Provider,{value:w},e))))}),Gb=Y.forwardRef((e,t)=>{let n=Fn(),r=Y.useRef(null),i=Y.useContext(Ub),a=Bb(),o=nx(e),s=o.current?.forceMount??i?.forceMount;rx(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=ox(n,r,[e.value,e.children,r],e.keywords),l=Hb(),u=ax(e=>e.value&&e.value===c.current),d=ax(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Y.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Ib,f),()=>t.removeEventListener(Ib,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 Y.createElement(jn.div,{ref:Bn(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)}),Kb=Y.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Fn(),s=Y.useRef(null),c=Y.useRef(null),l=Fn(),u=Bb(),d=ax(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);rx(()=>u.group(o),[]),ox(o,s,[e.value,e.heading,c]);let f=Y.useMemo(()=>({id:o,forceMount:i}),[i]);return Y.createElement(jn.div,{ref:Bn(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Y.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),lx(e,e=>Y.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Y.createElement(Ub.Provider,{value:f},e))))}),qb=Y.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Y.useRef(null),a=ax(e=>!e.search);return!n&&!a?null:Y.createElement(jn.div,{ref:Bn(i,t),...r,"cmdk-separator":``,role:`separator`})}),Jb=Y.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Hb(),o=ax(e=>e.search),s=ax(e=>e.selectedItemId),c=Bb();return Y.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Y.createElement(jn.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)}})}),Yb=Y.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Y.useRef(null),o=Y.useRef(null),s=ax(e=>e.selectedItemId),c=Bb();return Y.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)}}},[]),Y.createElement(jn.div,{ref:Bn(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},lx(e,e=>Y.createElement(`div`,{ref:Bn(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Xb=Y.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Y.createElement(er,{open:n,onOpenChange:r},Y.createElement(Kn,{container:o},Y.createElement(Gn,{"cmdk-overlay":``,className:i}),Y.createElement(ir,{"aria-label":e.label,"cmdk-dialog":``,className:a},Y.createElement(Wb,{ref:t,...s}))))}),Zb=Y.forwardRef((e,t)=>ax(e=>e.filtered.count===0)?Y.createElement(jn.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Qb=Y.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Y.createElement(jn.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},lx(e,e=>Y.createElement(`div`,{"aria-hidden":!0},e)))}),$b=Object.assign(Wb,{List:Yb,Item:Gb,Input:Jb,Group:Kb,Separator:qb,Dialog:Xb,Empty:Zb,Loading:Qb});function ex(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function tx(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function nx(e){let t=Y.useRef(e);return rx(()=>{t.current=e}),t}var rx=typeof window>`u`?Y.useEffect:Y.useLayoutEffect;function ix(e){let t=Y.useRef();return t.current===void 0&&(t.current=e()),t}function ax(e){let t=Hb(),n=()=>e(t.snapshot());return Y.useSyncExternalStore(t.subscribe,n,n)}function ox(e,t,n,r=[]){let i=Y.useRef(),a=Bb();return rx(()=>{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(Lb,s),i.current=s}),i}var sx=()=>{let[e,t]=Y.useState(),n=ix(()=>new Map);return rx(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function cx(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function lx({asChild:e,children:t},n){return e&&Y.isValidElement(t)?Y.cloneElement(cx(t),{ref:t.ref},n(t.props.children)):n(t)}var ux={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function dx(e){let t=(0,J.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=Sn(`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,X.jsx)($b,{"data-slot":`command`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function fx(e){let t=(0,J.c)(34),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({title:o,description:s,children:n,className:r,showCloseButton:c,commandProps:i,...a}=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);let l=o===void 0?`Command Palette`:o,u=s===void 0?`Search for a command to run`:s,d=c===void 0?!0:c,f;t[8]===i?f=t[9]:(f=i??{},t[8]=i,t[9]=f);let p,m;t[10]===f?(p=t[11],m=t[12]):({className:p,...m}=f,t[10]=f,t[11]=p,t[12]=m);let h;t[13]===r?h=t[14]:(h=Sn(`top-[12vh] translate-y-0 overflow-hidden p-0`,r),t[13]=r,t[14]=h);let g;t[15]===l?g=t[16]:(g=(0,X.jsx)(Wn,{className:`sr-only`,children:l}),t[15]=l,t[16]=g);let _;t[17]===u?_=t[18]:(_=(0,X.jsx)(Hn,{className:`sr-only`,children:u}),t[17]=u,t[18]=_);let v;t[19]===p?v=t[20]:(v=Sn(`[&_[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`,p),t[19]=p,t[20]=v);let y;t[21]!==n||t[22]!==m||t[23]!==v?(y=(0,X.jsx)(dx,{className:v,...m,children:n}),t[21]=n,t[22]=m,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==y?(b=(0,X.jsxs)(Yn,{className:h,showCloseButton:d,children:[g,_,y]}),t[25]=d,t[26]=h,t[27]=g,t[28]=_,t[29]=y,t[30]=b):b=t[30];let x;return t[31]!==a||t[32]!==b?(x=(0,X.jsx)(rr,{...a,children:b}),t[31]=a,t[32]=b,t[33]=x):x=t[33],x}function px(e){let t=(0,J.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,X.jsx)(Fa,{className:`size-4 shrink-0 opacity-50`}),t[3]=i):i=t[3];let a;t[4]===n?a=t[5]:(a=Sn(`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,X.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex items-center gap-2 border-b px-3`,children:[i,(0,X.jsx)($b.Input,{"data-slot":`command-input`,className:a,...r})]}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function mx(e){let t=(0,J.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=Sn(`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,X.jsx)($b.List,{"data-slot":`command-list`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function hx(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)($b.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),t[0]=e,t[1]=n),n}function gx(e){let t=(0,J.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=Sn(`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,X.jsx)($b.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _x(e){let t=(0,J.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=Sn(`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,X.jsx)($b.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vx(e){let t=(0,J.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=Sn(`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,X.jsx)(`span`,{"data-slot":`command-shortcut`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function yx(e,t){let n=null,r;try{n=await e.json()}catch(e){r=e}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:w(n)??t}}function bx(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 xx=new Map,Sx=null;function Cx(){return Ac(`PREWARM_CORRELATION_WINDOW_MS`,5e3)}function wx(){if(Sx!==null)return;let e=Math.max(50,Math.floor(Cx()/2));Sx=setTimeout(()=>{Sx=null,Tx(Date.now()),xx.size>0&&wx()},e)}function Tx(e){let t=Cx();for(let[n,r]of xx)e-r.emittedAt>=t&&(xx.delete(n),Z.count(`ok/sidebar/prewarm`,{hit:!1}))}function Ex(e,t,n=Date.now()){xx.has(e)&&Z.count(`ok/sidebar/prewarm`,{hit:!1}),xx.set(e,{poolEventId:t,emittedAt:n}),wx()}function Dx(e,t,n=Date.now()){let r=xx.get(e);return!r||r.poolEventId!==t||n-r.emittedAt>=Cx()?!1:(xx.delete(e),Z(`ok/sidebar/prewarm-clicked`,{docName:e,t:n,poolEventId:t}),Z.count(`ok/sidebar/prewarm`,{hit:!0}),!0)}z({event:Wt(`ok-branch-switched-clear-failed`),branch:Ve(),docName:Ve(),reason:Ve()});async function Ox(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()}var kx=null,Ax=new Set;function jx(){return kx}function Mx(e){let t=e!==null&&e.length>0?e:null;if(t!==kx){kx=t;for(let e of Ax)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function Nx(e){return Ax.add(e),()=>{Ax.delete(e)}}function Px(){return(0,Y.useSyncExternalStore)(Nx,jx,jx)}function Fx(e){let t=!1;return()=>{t?e():t=!0}}function Ix(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 Lx(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=Ot.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),Mx(i.data.serverInstanceId),i.data.currentBranch!==void 0&&e.compareAndUpdateObservedBranch(i.data.currentBranch)&&(Ox(e,i.data.currentBranch),zt(i.data.currentBranch)),i.data.currentDiskAckSVs!==void 0){let t={};for(let[e,n]of Object.entries(i.data.currentDiskAckSVs))try{t[e]=Ix(n)}catch{}e.observeDiskAckBatch(t)}}async function Rx(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,paneTarget:typeof r.paneTarget==`string`?r.paneTarget:null}}}function zx(e){return qx(e,Ht)}function Bx(e){return qx(e,vt)}function Vx(e){return qx(e,on)}function Hx(e){return qx(e,pt)}function Ux(e){return qx(e,st)}function Wx(e){let t=qx(e,Nt);if(!t)return null;try{return{docName:t.docName,sv:Gx(t.sv)}}catch{return null}}function Gx(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 Kx(e,t){let n=Bx(e);if(n){t.onServerInfo?.(n);return}let r=Vx(e);if(r){t.onBranchSwitched?.(r);return}let i=Wx(e);if(i){t.onDiskAck?.(i);return}let a=zx(e);if(a){t.onDerivedView?.(a);return}let o=Hx(e);if(o){t.onConfigValidationRejected?.(o);return}let s=Ux(e);if(s){t.onConfigIgnoreNestedError?.(s);return}t.onUnknown?.(e)}function qx(e,t){let n;try{n=JSON.parse(e)}catch{return null}let r=t.safeParse(n);return r.success?r.data:null}function Jx(){return typeof location>`u`?`ws://localhost/collab`:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/collab`}function Yx(e){if(e===void 0)return null;let t=e.okDesktop;return!t||!t.config.collabUrl||t.config.collabUrl.length===0?null:t}function Xx(e){return{collabUrl:e.collabUrl,attempts:0,terminal:!1,lastError:null}}var Zx=2e3,Qx=15e3;function $x(e){let t=e.terminalAfterMs??3e4,n=e.initialDelayMs??Zx,r=e.maxDelayMs??Qx,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 eS(){let e=(0,J.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={collabUrl:null,attempts:0,terminal:!1,lastError:null},e[0]=t):t=e[0];let[n,r]=(0,Y.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={token:0},e[1]=i):i=e[1];let a=(0,Y.useRef)(i),[o,s]=(0,Y.useState)(0),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=a.current.token=a.current.token+1,t=Yx(window);if(t){r(Xx(t.config));let n=t.onProjectSwitched(t=>{e===a.current.token&&r(Xx(t))});return()=>{n()}}let n=$x({fetchConfig:Rx,fallbackUrl:Jx,now:Date.now,setTimeout:iS,clearTimeout:rS,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,Y.useEffect)(c,l);let u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{a.current.token=a.current.token+1,r(nS),s(tS)},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 tS(e){return e+1}function nS(e){return{...e,terminal:!1,lastError:null}}function rS(e){return globalThis.clearTimeout(e)}function iS(e,t){return globalThis.setTimeout(e,t)}var aS=new Map,oS=new Set;function sS(){for(let e of oS)e()}function cS(e,t){aS.set(e,t),sS()}function lS(e,t){aS.get(e)===t&&(aS.delete(e),sS())}function uS(e){return aS.get(e)??null}function dS(e){return oS.add(e),()=>oS.delete(e)}var fS=new Map;function pS(e){return fS.get(e)}function mS(e,t){fS.set(e,t)}function hS(e){fS.delete(e)}var gS=`open-knowledge-app`,_S=new Map,vS=new Set,yS=1024,bS=1024;function xS(){return fr.getTracer(gS)}function SS(e,t,n){if(vS.has(e))return null;let r=_S.get(e);if(r)return r;if(_S.size>=bS){let e=_S.keys().next().value;if(e!==void 0){let t=_S.get(e);_S.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:xS().startSpan(`ok.cold-mount`,{attributes:{"mount.id":e,...t},startTime:n}),startTimeMs:n};return _S.set(e,i),i}function CS(e,t,n,r,i){try{let a=SS(e,n,r),o=a?fr.setSpan(pr.active(),a.span):pr.active();xS().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 wS(e,t){try{let n=_S.get(e);if(n&&(_S.delete(e),n.span.end(t??Date.now())),!vS.has(e)){if(vS.size>=yS){let e=vS.values().next().value;e!==void 0&&vS.delete(e)}vS.add(e)}}catch(e){console.warn(`[otel-spans] finalizeColdMountSpan failed:`,e instanceof Error?e:String(e))}}var TS=class extends Error{docName;constructor(e){super(`Mount aborted for "${e}"`),this.name=`MountAbortError`,this.docName=e}};function ES(){return Ac(`MOUNT_STALLED_THRESHOLD_MS`,1e4)}function DS(e){e.stalledHandle!==null&&(clearTimeout(e.stalledHandle),e.stalledHandle=null)}function OS(e,t,n){if(e.stalledMarkEmitted)return;e.stalledMarkEmitted=!0;let r=n-e.createdAt;Z(`ok/mount/stalled`,{docName:t,mountId:e.mountId,elapsedMs:r})}var kS=new Map,AS=new Set;function jS(e){AS.add(e);for(let[t,n]of kS)if(n.stalledMarkEmitted&&!n.settled)try{e(t,n.mountId)}catch{}return()=>{AS.delete(e)}}function MS(e,t){for(let n of AS)try{n(e,t.mountId)}catch{}}var NS=!1;function PS(){typeof document>`u`||document.visibilityState===`visible`&&LS(Date.now())}function FS(){NS||typeof document>`u`||typeof document.addEventListener==`function`&&(document.addEventListener(`visibilitychange`,PS),NS=!0)}function IS(){NS&&(typeof document>`u`||typeof document.removeEventListener==`function`&&(document.removeEventListener(`visibilitychange`,PS),NS=!1))}function LS(e){let t=ES();for(let[n,r]of kS)r.settled||r.stalledMarkEmitted||e-r.createdAt<t||(OS(r,n,e),MS(n,r))}function RS(e){let{docName:t,mountId:n,construct:r,sizeStats:i}=e,a=kS.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||(OS(d,t,Date.now()),MS(t,d))},ES()),o.signal.addEventListener(`abort`,()=>{d.settled||(d.settled=!0,DS(d),d.preMountEditor&&=(HS(t,d.preMountEditor,`aborted`),null),kS.delete(t),kS.size===0&&IS(),Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`aborted`}),l(new TS(t)),wS(d.mountId))}),kS.set(t,d),FS(),Z(`ok/mount/create`,{docName:t,mountId:d.mountId}),US({docName:t,construct:r,sizeStats:i,entry:d,resolveFn:c,rejectFn:l}).catch(e=>{if(d.preMountEditor&&=(HS(t,d.preMountEditor,`backstop`),null),d.settled){Z(`ok/mount/post-settle-throw`,{docName:t,mountId:d.mountId,message:e instanceof Error?e.message:String(e)});return}d.settled=!0,DS(d);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:d.mountId,reason:`unhandled-body-throw`}),l(n),wS(d.mountId)}),u}function zS(e){return kS.get(e)?.resolved===!0}function BS(e){return kS.get(e)?.controller??null}function VS(e){let t=kS.get(e);t&&(t.settled=!0,DS(t),t.preMountEditor&&=(HS(e,t.preMountEditor,`aborted`),null),kS.delete(e),kS.size===0&&IS(),Z(`ok/mount/invalidate`,{docName:e,mountId:t.mountId}),wS(t.mountId),t.controller.abort())}function HS(e,t,n){let r=WS(t);try{t.destroy()}catch(t){Z(`ok/mount/destroy-failed`,{docName:e,stage:n,message:t instanceof Error?t.message:String(t)})}r&&(r.restore=void 0)}async function US(e){let{docName:t,construct:n,sizeStats:r,entry:i,resolveFn:a,rejectFn:o}=e,s=document.createElement(`div`);if(wC(t)!==void 0){let e=cC({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,DS(i),a(e);return}if(await scheduler.yield(),i.controller.signal.aborted)return;let c=null;try{c=n()}catch(e){i.settled=!0,DS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`construct-failed`}),o(n),wS(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){HS(t,c.editor,`mount-failed`),i.preMountEditor=null,i.settled=!0,DS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`mount-failed`}),o(n),wS(i.mountId);return}let l;try{l=cC({docName:t,container:s,sizeStats:r,factory:()=>c})}catch(e){HS(t,c.editor,`v2-register-failed`),i.preMountEditor=null,i.settled=!0,DS(i);let n=e instanceof Error?e:Error(String(e));Z(`ok/mount/reject`,{docName:t,mountId:i.mountId,reason:`v2-register-failed`}),o(n),wS(i.mountId);return}i.preMountEditor=null,i.settled=!0,i.resolved=!0,DS(i);let u=Date.now()-i.createdAt;Z(`ok/mount/resolve`,{docName:t,mountId:i.mountId,elapsedMs:u}),Z.histogram(`ok/mount/resolve-elapsed-ms`,{docName:t,mountId:i.mountId},u),a(l);let d=Date.now();CS(i.mountId,`ok.mount-promise`,{"doc.name":t,elapsed_ms:u},i.createdAt,d),wS(i.mountId,d)}function WS(e){try{let t=e.state;return Jv.getState(t)?.undoManager??null}catch(e){return Z(`ok/cache/undo-manager-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}var GS=Ac(`MAX_CACHE`,10),KS=Ac(`VIEW_COUNT_CACHE_THRESHOLD`,50),qS=Ac(`BYTES_CACHE_THRESHOLD`,8e6);function JS(e){return!(e.viewCount>0&&e.viewCount>=KS||e.bytes>qS)}var YS=new Map,XS=new Map,ZS=new Map;function QS(e,t){if(ZS.size>=GS){let e=ZS.keys().next().value;e!==void 0&&ZS.delete(e)}ZS.set(e,t),Z(`ok/cache/snapshot-stored`,{toDocName:e,htmlBytes:t.html.length,hasScroll:t.scrollTop>0,hasSelection:t.selection!==null})}function $S(e){return ZS.get(e)??null}function eC(e){if(!ZS.has(e))return;let t=ZS.get(e)??null;ZS.delete(e),Z(`ok/cache/snapshot-consumed`,{docName:e,hit:t!==null,hasScroll:t!==null&&t.scrollTop>0,hasSelection:t!==null&&t.selection!==null})}function tC(){try{return typeof document>`u`?0:document.querySelector(`[data-testid="editor-scroll-container"]`)?.scrollTop??0}catch(e){return Z(`ok/cache/snapshot-scroll-read-failed`,{message:e instanceof Error?e.message:String(e)}),0}}function nC(e){try{let t=e.state.selection;return t instanceof F?{type:`text`,anchor:t.anchor,head:t.head}:t instanceof Ct?{type:`node`,from:t.from}:null}catch(e){return Z(`ok/cache/snapshot-selection-read-failed`,{message:e instanceof Error?e.message:String(e)}),null}}function rC(e){for(let t of e)try{let e=wC(t.fromDocName);if(e&&!e.editor.isDestroyed){if(e.ytext.length===0){Z(`ok/cache/snapshot-skipped-empty`,{fromDocName:t.fromDocName});continue}QS(t.toDocName,{html:e.editor.getHTML(),scrollTop:tC(),selection:nC(e.editor)})}else Z(`ok/cache/snapshot-skipped`,{fromDocName:t.fromDocName})}catch(e){Z(`ok/cache/snapshot-capture-failed`,{fromDocName:t.fromDocName,message:e instanceof Error?e.message:String(e)})}}var iC=[],aC=[],oC=new Set;function sC(){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 cC(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!JS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:pS(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=YS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:pS(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),gC(a,n),a.activeMountKey=t,vC(iC,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.editor.commands.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:pS(t),kind:`tiptap`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:pS(t),kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:pS(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`tiptap`}),a}for(;YS.size>=GS;){let e=yC(iC,t);if(!e)break;uC(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 YS.set(t,s),vC(iC,t),Z(`ok/cache/miss`,{docName:t,mountId:pS(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`tiptap`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:pS(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`tiptap`}),s}function lC(e){let t=e.activeMountKey;if(e.__uncached){t&&VS(t);let n=WS(e.editor);try{e.editor.destroy()}catch(e){Z(`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=mC(e.editor);if(n){e.hadFocus=hC(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||=sC(),e.parkingNode&&e.parkingNode.appendChild(n.dom)}e.activeMountKey=null}function uC(e){VS(e);let t=YS.get(e);if(!t)return!1;let n=WS(t.editor);try{t.editor.destroy()}catch(t){Z(`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){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`tiptap`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}YS.delete(e);let r=iC.indexOf(e);return r!==-1&&iC.splice(r,1),Z(`ok/cache/evict`,{docName:e,kind:`tiptap`}),!0}function dC(e){let{docName:t,container:n,factory:r,sizeStats:i}=e;if(i&&!JS(i)){let e=r(n);return Z(`ok/cache/miss`,{docName:t,mountId:pS(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`size-gate`,kind:`cm`}),{view:e.view,ydoc:e.ydoc,ytext:e.ytext,provider:e.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null,__uncached:!0}}let a=XS.get(t);if(a){if(Z(`ok/cache/reparent-start`,{docName:t,mountId:pS(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),_C(a,n),a.activeMountKey=t,vC(aC,t),n.scrollTop=a.scrollTop,a.hadFocus)try{a.view.focus()}catch{}return Z(`ok/cache/reparent-end`,{docName:t,mountId:pS(t),kind:`cm`,viewCount:i?.viewCount??-1,bytes:i?.bytes??-1}),Z(`ok/cache/hit`,{docName:t,mountId:pS(t),kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:pS(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!0,kind:`cm`}),a}for(;XS.size>=GS;){let e=yC(aC,t);if(!e)break;pC(e)}let o=r(n),s={view:o.view,ydoc:o.ydoc,ytext:o.ytext,provider:o.provider,scrollTop:0,hadFocus:!1,activeMountKey:t,parkingNode:null};return XS.set(t,s),vC(aC,t),Z(`ok/cache/miss`,{docName:t,mountId:pS(t),viewCount:i?.viewCount??-1,bytes:i?.bytes??-1,reason:`cold`,kind:`cm`}),i&&Z(`ok/cold/editor-mount-stats`,{docName:t,mountId:pS(t),viewCount:i.viewCount,bytes:i.bytes,cacheHit:!1,kind:`cm`}),s}function fC(e){if(e.__uncached){try{e.view.destroy()}catch(t){Z(`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=hC(t),e.scrollTop=(e.view.scrollDOM??t).scrollTop??0;let n=t.parentElement;n&&n.removeChild(t),e.parkingNode||=sC(),e.parkingNode&&e.parkingNode.appendChild(t),e.activeMountKey=null}function pC(e){let t=XS.get(e);if(!t)return!1;try{t.view.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`view`,message:t instanceof Error?t.message:String(t)})}try{t.provider.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`provider`,message:t instanceof Error?t.message:String(t)})}try{t.ydoc.destroy()}catch(t){Z(`ok/cache/evict-failed`,{docName:e,kind:`cm`,stage:`ydoc`,message:t instanceof Error?t.message:String(t)})}XS.delete(e);let n=aC.indexOf(e);return n!==-1&&aC.splice(n,1),Z(`ok/cache/evict`,{docName:e,kind:`cm`}),!0}function mC(e){return e.editorView??null}function hC(e){if(typeof document>`u`)return!1;let t=document.activeElement;return t?t===e?!0:e.contains(t):!1}function gC(e,t){let n=mC(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 _C(e,t){let n=e.view.dom,r=n.parentElement;r&&r!==t&&r.removeChild(n),n.parentElement!==t&&t.appendChild(n)}function vC(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t)}function yC(e,t){for(let n of e)if(n!==t&&!oC.has(n))return n;Z(`ok/cache/evict-fallback-activity-saturated`,{mountingDocName:t,lruLength:e.length,activityMountCount:oC.size});for(let n of e)if(n!==t)return n;return null}function bC(e){let t=oC,n=new Set(e);for(let e of t){if(n.has(e))continue;let t=SC(e);if(t)try{t.disconnect(),Z(`ok/cache/disconnect`,{docName:e})}catch(t){Z(`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=SC(e);if(!n)continue;let r=t=>{Z(`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(()=>Z(`ok/cache/connect`,{docName:e}),e=>r(e)):Z(`ok/cache/connect`,{docName:e})}catch(e){r(e)}}oC=n}var xC=null;function SC(e){let t=YS.get(e);if(t)return t.provider;let n=XS.get(e);if(n)return n.provider;if(xC){let t=xC.entries.get(e);if(t)return t.provider}return null}function CC(e){xC=e;let t=e.onEvict(e=>{uC(e),pC(e)});return()=>{t(),xC===e&&(xC=null)}}function wC(e){return YS.get(e)}var TC=`ok-editor-tabs-v1:`,EC=`\0folder:`,DC=`\0asset:`,OC=`\0doc-tab:`;function kC(e){let t=e.lastIndexOf(OC);return t<0?{baseTabId:e,instanceSuffix:``}:{baseTabId:e.slice(0,t),instanceSuffix:e.slice(t)}}function AC(e){return kC(e).baseTabId}function jC(e){if(typeof e!=`string`||e.length===0)return!1;let t=AC(e);return t.startsWith(EC)?t.length>8:t.startsWith(DC)?t.length>7:!0}function MC(e){return e}function NC(e,t){return`${AC(e)}${OC}${t}`}function PC(e,t){return FC(e,MC(t))}function FC(e,t){let n=WC(e,2**53-1),r=AC(t);if(!n.includes(r))return r;let i=1,a;do a=NC(r,i),i++;while(n.includes(a));return a}function IC(e,t){let n=AC(t);return WC(e,2**53-1).find(e=>AC(e)===n)??null}function LC(e,t){return AC(e)===AC(t)}function RC(e){return`${EC}${e}`}function zC(e){return`${DC}${e}`}function BC(e,t){let n=e.lastIndexOf(`/`),r=n<0?e:e.slice(n+1),i=`${r}${t}`;return n<0?{baseName:r,extension:t,label:i,prefix:``}:{baseName:r,extension:t,label:i,prefix:`${e.slice(0,n)}/`}}function VC(e){switch(e.kind){case`doc`:case`folder-index`:case`large-file`:return MC(e.docName);case`folder`:return RC(e.folderPath);case`missing`:return MC(e.target);case`asset`:return zC(e.assetPath)}}function HC(e){let t=AC(e);return t.startsWith(EC)?{kind:`folder`,folderPath:t.slice(8)}:t.startsWith(DC)?{kind:`asset`,assetPath:t.slice(7)}:{kind:`doc`,docName:t}}function UC(e){let t=HC(e);return t.kind===`doc`?t.docName:null}function WC(e,t){if(!Array.isArray(e)||t<=0)return[];let n=[],r=new Set;for(let i of e)if(jC(i)&&!r.has(i)&&(r.add(i),n.push(i),n.length>=t))break;return n}function GC(e,t){let n=new Set(WC(t,2**53-1));return WC(e,2**53-1).filter(e=>n.has(e))}function KC(e,t,n){if(t<=0)return[];let r=new Set(WC(n,2**53-1)),i=WC(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 qC(e,t,n){let r=GC(e,n);return!WC(n,2**53-1).includes(t)||r.includes(t)?r:[...r,t]}function JC(e,t){return WC(e,2**53-1).filter(e=>e!==t)}function YC(e,t){let n=new Set(WC(t,2**53-1));return WC(e,2**53-1).filter(e=>!n.has(e))}function XC(e,t,n){let r=WC(e,2**53-1),i=GC(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?qC(i,n,r):JC(i,n)}function ZC(e,t,n,r=[]){let i=KC(e,n,r);return!jC(t)||i.includes(t)?i:KC([...i,t],n,r)}function QC(e,t,n,r,i=[]){let a=KC(e,r,i);if(!jC(n))return a;if(!t||t===n)return ZC(a,n,r,i);let o=a.filter(e=>e!==n),s=o.indexOf(t);if(s<0)return ZC(o,n,r,i);let c=[...o];return c[s]=n,KC(c,r,i)}function $C(e,t,n){return ew(e,MC(t),n)}function ew(e,t,{behavior:n,currentTabId:r,limit:i,pinnedTabIds:a=[]}){let o=KC(e,i,a),s=AC(t);if(r&&o.includes(r)&&AC(r)===s)return{tabs:o,activeTabId:r};if(n!==`replace-active`)return{tabs:ZC(o,s,i,a),activeTabId:s};let c=IC(o,s);if(c)return{tabs:o,activeTabId:c};let l=FC(o,s);return{tabs:QC(o,r,l,i,a),activeTabId:l}}function tw(e,t){return e.filter(e=>e!==t)}function nw(e,t,n){let r=WC(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 rw(e,{pages:t,folderPaths:n,assetPaths:r,keepMissingDocName:i=null}){return WC(e,2**53-1).filter(e=>{let a=HC(e);return a.kind===`folder`?n.has(a.folderPath):a.kind===`asset`?r.has(a.assetPath):t.has(a.docName)||a.docName===i})}function iw(e,t,n,r=[],i=[],a=[]){if(t.length===0&&r.length===0&&a.length===0)return WC(e,n);let o=new Map(t.map(e=>[e.fromDocName,e.toDocName])),s=e=>sw(ow(e,r),a),c=[],l=new Set;for(let t of e){let{instanceSuffix:e}=kC(t),a=HC(t),u=`${a.kind===`doc`?o.get(a.docName)??AC(t):a.kind===`folder`?RC(ow(a.folderPath,r)):zC(s(a.assetPath))}${e}`;if(!l.has(u)&&(l.add(u),c.push(u),i.length===0&&c.length>=n))break}return i.length===0?c:KC(c,n,i.map(e=>{let t=HC(e);return t.kind===`doc`?o.get(t.docName)??e:t.kind===`folder`?RC(ow(t.folderPath,r)):zC(s(t.assetPath))}))}function aw(e,t,n=[],r=[]){return iw(e,t,2**53-1,n,[],r)}function ow(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 sw(e,t){for(let{fromPath:n,toPath:r}of t)if(e===n)return r;return e}function cw(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 lw(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 uw(e,t){if(typeof e!=`object`||!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};let n=e,r=WC(n.openTabs,2**53-1),i=GC(n.pinnedTabIds,r),a=i.length===0?WC(n.openTabs,t):KC(r,t,i),o=GC(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?HC(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 dw(e,t,n=[],r=()=>new Date){let i=WC(e,2**53-1),a=t&&i.includes(t)?t:null,o=a?HC(a):null;return{openTabs:i,pinnedTabIds:GC(n,i),activeDocName:o?.kind===`doc`?o.docName:null,activeTabId:a,updatedAt:r().toISOString()}}function fw(e){return`${TC}${e}`}function pw(e,t,n){if(!e)return{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null};try{let r=e.getItem(t);return r?uw(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 mw(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 hw=Math.floor,gw=(e,t)=>e<t?e:t,_w=(e,t)=>e>t?e:t;Number.isNaN;var vw=128,yw=1<<17,bw=1<<18,xw=1<<19,Sw=1<<20,Cw=1<<21,ww=1<<22,Tw=1<<23,Ew=1<<24,Dw=1<<25,Ow=1<<26,kw=1<<27,Aw=1<<28,jw=1<<29,Mw=1<<30,Nw=127;yw-1,bw-1,xw-1,Sw-1,Cw-1,ww-1,Tw-1,Ew-1,Dw-1,Ow-1,kw-1,Aw-1,jw-1,Mw-1;var Pw=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Fw=String.fromCharCode;String.fromCodePoint,Fw(65535);var Iw=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Lw=typeof TextEncoder<`u`?new TextEncoder:null,Rw=Lw?e=>Lw.encode(e):Iw,zw=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});zw&&zw.decode(new Uint8Array).length===1&&(zw=null);var Bw=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Vw=(e,t)=>{for(;t>Nw;)Bw(e,vw|Nw&t),t=hw(t/128);Bw(e,Nw&t)},Hw=new Uint8Array(3e4),Uw=Hw.length/3,Ww=Lw&&Lw.encodeInto?(e,t)=>{if(t.length<Uw){let n=Lw.encodeInto(t,Hw).written||0;Vw(e,n);for(let t=0;t<n;t++)Bw(e,Hw[t])}else Kw(e,Rw(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Vw(e,r);for(let t=0;t<r;t++)Bw(e,n.codePointAt(t))},Gw=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=gw(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(_w(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Kw=(e,t)=>{Vw(e,t.byteLength),Gw(e,t)},qw=e=>Error(e),Jw=qw(`Unexpected end of array`),Yw=qw(`Integer out of Range`),Xw=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},Zw=e=>Xw(e,$w(e)),Qw=e=>e.arr[e.pos++],$w=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&Nw)*n,n*=128,r<vw)return t;if(t>Pw)throw Yw}throw Jw},eT=zw?e=>zw.decode(Zw(e)):e=>{let t=$w(e);if(t===0)return``;{let n=String.fromCodePoint(Qw(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Qw(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},tT=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),nT=(e,t)=>{Vw(e,tT.Token),Ww(e,t)},rT=(e,t,n,r)=>{switch($w(e)){case tT.Token:t();break;case tT.PermissionDenied:n(eT(e));break;case tT.Authenticated:r(eT(e));break;default:}},iT=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),aT=`\0`;function oT(e,t){return e+aT+t}function sT(e){let t=e.indexOf(aT);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var cT=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({});function lT(e){return e||={},{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function uT(e){return new Promise(t=>setTimeout(t,e))}function dT(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function fT(e,t){let n=lT(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||dT;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await uT(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await uT(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await uT(e)}return a()}var pT=Math.floor,mT=(e,t)=>e<t?e:t,hT=(e,t)=>e>t?e:t;Number.isNaN;var gT=64,_T=128,vT=1<<17,yT=1<<18,bT=1<<19,xT=1<<20,ST=1<<21,CT=1<<22,wT=1<<23,TT=1<<24,ET=1<<25,DT=1<<26,OT=1<<27,kT=1<<28,AT=1<<29,jT=1<<30,MT=63,NT=127;vT-1,yT-1,bT-1,xT-1,ST-1,CT-1,wT-1,TT-1,ET-1,DT-1,OT-1,kT-1,AT-1,jT-1;var PT=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var FT=()=>new Set,IT=Array.from;Array.isArray;var LT=String.fromCharCode;String.fromCodePoint,LT(65535);var RT=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},zT=typeof TextEncoder<`u`?new TextEncoder:null,BT=zT?e=>zT.encode(e):RT,VT=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});VT&&VT.decode(new Uint8Array).length===1&&(VT=null);var HT=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},UT=()=>new HT,WT=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},GT=e=>{let t=new Uint8Array(WT(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},KT=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},qT=(e,t)=>{for(;t>NT;)KT(e,_T|NT&t),t=pT(t/128);KT(e,NT&t)},JT=new Uint8Array(3e4),YT=JT.length/3,XT=zT&&zT.encodeInto?(e,t)=>{if(t.length<YT){let n=zT.encodeInto(t,JT).written||0;qT(e,n);for(let t=0;t<n;t++)KT(e,JT[t])}else QT(e,BT(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;qT(e,r);for(let t=0;t<r;t++)KT(e,n.codePointAt(t))},ZT=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=mT(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(hT(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},QT=(e,t)=>{qT(e,t.byteLength),ZT(e,t)},$T=e=>Error(e),eE=$T(`Unexpected end of array`),tE=$T(`Integer out of Range`),nE=class{constructor(e){this.arr=e,this.pos=0}},rE=e=>new nE(e),iE=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},aE=e=>iE(e,sE(e)),oE=e=>e.arr[e.pos++],sE=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&NT)*n,n*=128,r<_T)return t;if(t>PT)throw tE}throw eE},cE=e=>{let t=e.arr[e.pos++],n=t&MT,r=64,i=(t&gT)>0?-1:1;if((t&_T)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&NT)*r,r*=128,t<_T)return i*n;if(n>PT)throw tE}throw eE},lE=VT?e=>VT.decode(aE(e)):e=>{let t=sE(e);if(t===0)return``;{let n=String.fromCodePoint(oE(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(oE(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},uE=e=>{let t=e.pos,n=lE(e);return e.pos=t,n},dE=Date.now,fE=()=>new Map,pE=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},mE=class{constructor(){this._observers=fE()}on(e,t){pE(this._observers,e,FT).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return IT((this._observers.get(e)||fE()).values()).forEach(e=>e(...t))}destroy(){this._observers=fE()}},hE=Symbol(`Equality`),gE=Object.keys,_E=e=>gE(e).length,vE=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),yE=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[hE]!=null)return e[hE](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!yE(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(_E(e)!==_E(t))return!1;for(let n in e)if(!vE(e,n)||!yE(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!yE(e[n],t[n]))return!1;break;default:return!1}return!0},bE=3e4,xE=class extends mE{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=dE();this.getLocalState()!==null&&bE/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&bE<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&SE(this,t,`timeout`)},pT(bE/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:dE()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),yE(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},SE=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:dE()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},CE=(e,t,n=e.states)=>{let r=t.length,i=UT();qT(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;qT(i,r),qT(i,s),XT(i,JSON.stringify(o))}return GT(i)},wE=(e,t,n)=>{let r=rE(t),i=dE(),a=[],o=[],s=[],c=[],l=sE(r);for(let t=0;t<l;t++){let t=sE(r),n=sE(r),l=JSON.parse(lE(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(yE(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},TE=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},EE=class{constructor(e){this.data=e,this.encoder=UT(),this.decoder=rE(new Uint8Array(this.data))}peekVarString(){return uE(this.decoder)}readVarUint(){return sE(this.decoder)}readVarString(){return lE(this.decoder)}readVarUint8Array(){return aE(this.decoder)}writeVarUint(e){return qT(this.encoder,e)}writeVarString(e){return XT(this.encoder,e)}writeVarUint8Array(e){return QT(this.encoder,e)}length(){return WT(this.encoder)}},DE=function(e){return e[e.Sync=0]=`Sync`,e[e.Awareness=1]=`Awareness`,e[e.Auth=2]=`Auth`,e[e.QueryAwareness=3]=`QueryAwareness`,e[e.Stateless=5]=`Stateless`,e[e.CLOSE=7]=`CLOSE`,e[e.SyncStatus=8]=`SyncStatus`,e[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),OE=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),kE=class{constructor(){this.encoder=UT()}get(e){return e.encoder}toUint8Array(){return GT(this.encoder)}},AE=class extends kE{constructor(...e){super(...e),this.type=DE.CLOSE,this.description=`Ask the server to close the connection`}get(e){return XT(this.encoder,e.documentName),qT(this.encoder,this.type),this.encoder}},jE=class e extends TE{static{this.DEDUPLICATABLE_TYPES=new Set([DE.Awareness,DE.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=OE.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on(`open`,this.configuration.onOpen),this.on(`open`,this.onOpen.bind(this)),this.on(`connect`,this.configuration.onConnect),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`status`,this.configuration.onStatus),this.on(`disconnect`,this.configuration.onDisconnect),this.on(`close`,this.configuration.onClose),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`close`,this.onClose.bind(this)),this.on(`message`,this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(e){this.status=OE.Connected,this.emit(`status`,{status:OE.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===OE.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===OE.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(AE,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===OE.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:fT(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=OE.Connecting,this.emit(`status`,{status:OE.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=dE();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===DE.Ping){this.sendPong();return}let n=new EE(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=UT();qT(e,DE.Pong),this.send(GT(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=OE.Connected,this.emit(`status`,{status:OE.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===OE.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=dE()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:`forced`}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=rE(e);return{documentName:lE(t),messageType:sE(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===cT.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=OE.Disconnected,this.emit(`status`,{status:OE.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},ME=0,NE=1,PE=2,FE=(e,t)=>{qT(e,ME),QT(e,Th(t))},IE=(e,t,n)=>{qT(e,NE),QT(e,yh(t,n))},LE=(e,t,n)=>IE(t,n,aE(e)),RE=(e,t,n,r)=>{try{gh(t,aE(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},zE=(e,t)=>{qT(e,PE),QT(e,t)},BE=RE,VE=(e,t,n,r,i)=>{let a=sE(e);switch(a){case ME:LE(e,t,n);break;case NE:RE(e,n,r,i);break;case PE:BE(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},HE=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case DE.Sync:this.applySyncMessage(e,t);break;case DE.Awareness:this.applyAwarenessMessage(e);break;case DE.Auth:this.applyAuthMessage(e);break;case DE.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case DE.Stateless:e.receiveStateless(lE(n.decoder));break;case DE.SyncStatus:this.applySyncStatusMessage(e,cE(n.decoder)===1);break;case DE.CLOSE:let i={code:1e3,reason:lE(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(kE,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(DE.Sync);let r=VE(n.decoder,n.encoder,e.document,e);t&&r===NE&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;wE(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;rT(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(DE.Awareness),t.writeVarUint8Array(CE(e.awareness,Array.from(e.awareness.getStates().keys())))}},UE=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return GT(this.encoder)}send(e){e?.send(this.create())}},WE=`4.0.0-rc.1`,GE=class extends kE{constructor(...e){super(...e),this.type=DE.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return XT(this.encoder,e.documentName),qT(this.encoder,this.type),nT(this.encoder,e.token),XT(this.encoder,WE),this.encoder}},KE=class extends kE{constructor(...e){super(...e),this.type=DE.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);XT(this.encoder,e.documentName),qT(this.encoder,this.type);let t;return t=e.states===void 0?CE(e.awareness,e.clients):CE(e.awareness,e.clients,e.states),QT(this.encoder,t),this.encoder}},qE=class extends kE{constructor(...e){super(...e),this.type=DE.Stateless,this.description=`A stateless message`}get(e){return XT(this.encoder,e.documentName),qT(this.encoder,this.type),XT(this.encoder,e.payload??``),this.encoder}},JE=class extends kE{constructor(...e){super(...e),this.type=DE.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return XT(this.encoder,e.documentName),qT(this.encoder,this.type),FE(this.encoder,e.document),this.encoder}},YE=class extends kE{constructor(...e){super(...e),this.type=DE.Sync,this.description=`A document update`}get(e){return XT(this.encoder,e.documentName),qT(this.encoder,this.type),zE(this.encoder,e.update),this.encoder}},XE=class extends Error{constructor(...e){super(...e),this.code=1001}},ZE=class extends TE{get effectiveName(){return this.configuration.sessionAwareness?oT(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new eh,this.configuration.awareness=e.awareness===void 0?new xE(this.document):e.awareness,this.on(`open`,this.configuration.onOpen),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`synced`,this.configuration.onSynced),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`stateless`,this.configuration.onStateless),this.on(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:iT(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:iT(this.awareness.getStates())})}),this.document.on(`update`,this.boundDocumentUpdateHandler),this.awareness?.on(`update`,this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval==`number`&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new jE(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(JE,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&SE(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(qE,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(GE,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(YE,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(KE,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(JE,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(KE,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new UE(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new EE(e.data),{documentName:n}=sT(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new EE(e.data)}),new HE(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&SE(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(SE(this.awareness,[this.document.clientID],`provider destroy`),this.awareness.off(`update`,this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off(`update`,this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),this.configuration.websocketProvider.off(`close`,this.boundOnClose),this.configuration.websocketProvider.off(`close`,this.configuration.onClose),this.configuration.websocketProvider.off(`close`,this.forwardClose),this.configuration.websocketProvider.off(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.off(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.off(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.off(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),this.configuration.websocketProvider.on(`close`,this.boundOnClose),this.configuration.websocketProvider.on(`close`,this.configuration.onClose),this.configuration.websocketProvider.on(`close`,this.forwardClose),this.configuration.websocketProvider.on(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.on(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.on(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.on(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new XE(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}},QE=e=>cf((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),$E=(e,t)=>cf((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(Nd(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),eD=e=>QE(indexedDB.deleteDatabase(e)),tD=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),nD=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>pD(r,e))},rD=(e,t)=>QE(e.count(t)),iD=(e,t)=>QE(e.get(t)),aD=(e,t)=>QE(e.delete(t)),oD=(e,t,n)=>QE(e.put(t,n)),sD=(e,t)=>QE(e.add(t)),cD=(e,t,n)=>QE(e.getAll(t,n)),lD=(e,t,n)=>{let r=null;return fD(e,t,e=>(r=e,!1),n).then(()=>r)},uD=(e,t=null)=>lD(e,t,`prev`),dD=(e,t)=>cf((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()}}),fD=(e,t,n,r=`next`)=>dD(e.openKeyCursor(t,r),e=>n(e.key)),pD=(e,t)=>e.objectStore(t),mD=(e,t)=>IDBKeyRange.upperBound(e,t),hD=(e,t)=>IDBKeyRange.lowerBound(e,t),gD=`custom`,_D=`updates`,vD=(e,t=()=>{},n=()=>{})=>{let[r]=nD(e.db,[_D]);return cD(r,hD(e._dbref,!1)).then(i=>{e._destroyed||(t(r),hg(e.doc,()=>{i.forEach(t=>gh(e.doc,t))},e,!1),n(r))}).then(()=>uD(r).then(t=>{e._dbref=t+1})).then(()=>rD(r).then(t=>{e._dbsize=t})).then(()=>r)},yD=(e,t=!0)=>vD(e).then(n=>{(t||e._dbsize>=500)&&sD(n,yh(e.doc)).then(()=>aD(n,mD(e._dbref,!0))).then(()=>rD(n).then(t=>{e._dbsize=t}))}),bD=class extends Eu{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=$E(e,e=>tD(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=cf(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,vD(this,async e=>{await rD(e)>0&&sD(e,yh(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]=nD(this.db,[_D]);sD(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(()=>{yD(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(()=>{eD(this.name)})}get(e){return this._db.then(t=>{let[n]=nD(t,[gD],`readonly`);return iD(n,e)})}set(e,t){return this._db.then(n=>{let[r]=nD(n,[gD]);return oD(r,t,e)})}del(e){return this._db.then(t=>{let[n]=nD(t,[gD]);return aD(n,e)})}};function xD(){return!0}var SD=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=xD()?0:performance.now();this._idb=new bD(this._dbName,r),this.whenSynced=this._idb.whenSynced.then(()=>{if(!xD()){let e=performance.now();Z(`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=xD()?0:performance.now();try{await this._idb.destroy()}finally{if(!xD()){let t=performance.now();Z(`ok/pool/idb-destroy`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}async clearData(){let e=xD()?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(!xD()){let t=performance.now();Z(`ok/pool/idb-cleardata`,{dbName:this._dbName,durationMs:Math.round((t-e)*1e3)/1e3},{startTime:e,duration:t-e})}}}};function CD(e){return new SD(e)}function wD(e){return Th(e)}function TD(e,t){return t===null?yh(e):yh(e,t)}function ED(e,t){if(e===null)return t;if(t===null)return e;let n=xh(e),r=xh(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 Th(i)}function DD(e){let t={};if(mr.inject(pr.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 OD=({key:e,editor:t,onPaste:n,onDrop:r,allowedMimeTypes:i})=>new U({key:e||new W(`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))}}}),kD=Dt.create({name:`fileHandler`,addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[OD({key:new W(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}});function AD(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||!Ct.isSelectable(o))return!1;try{let t=Ct.create(n.doc,s);return e.view.dispatch(n.tr.setSelection(t).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return ot(t),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:t,tier:`L0`,reason:e.message.slice(0,500)})),!0}}function jD(e){let{state:t,view:n}=e;if(!(t.selection instanceof F)||!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=ge.findFrom(n,-1,!0);return!r||!(r instanceof F)?!1:(e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0)}catch(e){if(!(e instanceof RangeError))throw e;return ot(`up`),console.warn(JSON.stringify({event:`jsx-component-arrow-node-select-failed`,direction:`up`,tier:`L2c`,reason:e.message.slice(0,500)})),!0}}var MD=Dt.create({name:`keyboardNav`,priority:50,addKeyboardShortcuts(){return{Escape:({editor:e})=>{let{state:t}=e;if(t.selection instanceof Ct){let n=t.selection.from+t.selection.node.nodeSize,r=t.doc.resolve(Math.min(n,t.doc.content.size)),i=F.near(r);return e.view.dispatch(t.tr.setSelection(i)),!0}return t.selection instanceof F?e.commands.selectParentNode():!1},ArrowUp:({editor:e})=>{if(AD(e,`up`)||jD(e))return!0;let{state:t}=e;if(!(t.selection instanceof Ct))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=Ct.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 ot(`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(AD(e,`down`))return!0;let{state:t}=e;if(!(t.selection instanceof Ct))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=Ct.create(t.doc,n);return e.view.dispatch(t.tr.setSelection(r).scrollIntoView()),!0}catch(e){if(!(e instanceof RangeError))throw e;return ot(`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})=>AD(e,`left`),ArrowRight:({editor:e})=>AD(e,`right`),Enter:({editor:e})=>{let{state:t}=e;if(!(t.selection instanceof F)||!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(F.create(s.doc,f)),e.view.dispatch(s.scrollIntoView()),!0}}}}),ND={query:``,options:{caseSensitive:!1,wholeWord:!1},activeIndex:0,matches:[]},PD=/[A-Za-z0-9_]/;function FD(e){return e!==void 0&&PD.test(e)}function ID(e,t,n){return!FD(e[t-1])&&!FD(e[n])}function LD(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||ID(e,t,s))&&a.push({start:t,end:s,text:e.slice(t,s)}),o=s}return a}function RD(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 LD(e.text,t,n))r.push({from:i+a.start,to:i+a.end,text:a.text})}),r}var zD=new W(`findReplace`);function BD(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(Math.max(Math.trunc(e),0),t-1)}function VD(e,t,n,r){let i=RD(e.doc,t,n);return{query:t,options:n,activeIndex:BD(r,i.length),matches:i}}function HD(e,t,n){return t<=0?0:(BD(e,t)+n+t)%t}function UD(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 WD(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=RD(r.doc,t.query,t.options),a=BD(0,i.length),o=i[a];return r.setMeta(zD,{type:`setActiveIndex`,activeIndex:a}),o&&r.setSelection(F.create(r.doc,o.from,o.to)),r.scrollIntoView()}function GD(e,t){let n=zD.getState(e)?.matches[t];return n?e.tr.setMeta(zD,{type:`setActiveIndex`,activeIndex:t}).setSelection(F.create(e.doc,n.from,n.to)).scrollIntoView():null}function KD(e){return zD.getState(e)??ND}function qD(){return new U({key:zD,state:{init:()=>ND,apply(e,t,n,r){let i=e.getMeta(zD);if(i?.type===`clear`)return ND;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:[]}:VD(r,a,o,s)}},props:{decorations(e){let t=zD.getState(e);return!t||t.matches.length===0?null:pe.create(e.doc,t.matches.map((e,n)=>S.inline(e.from,e.to,{class:n===t.activeIndex?`ok-find-match ok-find-match-active`:`ok-find-match`})))}}})}var JD=Dt.create({name:`findReplace`,addCommands(){return{setFindQuery:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(zD,{type:`setQuery`,query:e,options:t?.options,activeIndex:t?.activeIndex})),!0),setFindOptions:(e,t)=>({state:n,dispatch:r})=>(r&&r(n.tr.setMeta(zD,{type:`setOptions`,options:e,activeIndex:t})),!0),setActiveFindIndex:e=>({state:t,dispatch:n})=>(n&&n(t.tr.setMeta(zD,{type:`setActiveIndex`,activeIndex:e})),!0),selectNextFindMatch:()=>({state:e,dispatch:t})=>{let n=KD(e),r=GD(e,HD(n.activeIndex,n.matches.length,1));return r?(t?.(r),!0):!1},selectPreviousFindMatch:()=>({state:e,dispatch:t})=>{let n=KD(e),r=GD(e,HD(n.activeIndex,n.matches.length,-1));return r?(t?.(r),!0):!1},replaceCurrentFindMatch:e=>({state:t,dispatch:n})=>{let r=KD(t),i=r.matches[r.activeIndex];if(!i||!n)return!1;let a=t.tr.insertText(e,i.from,i.to),o=RD(a.doc,r.query,r.options),s=UD(o,i.from,e.length),c=o[s];return a.setMeta(zD,{type:`setActiveIndex`,activeIndex:s}),c&&a.setSelection(F.create(a.doc,c.from,c.to)),a.scrollIntoView(),n(a),!0},replaceAllFindMatches:e=>({state:t,dispatch:n})=>{let r=KD(t);if(!n)return!1;let i=WD(t,r,e);return i?(n(i),!0):!1},clearFindMatches:()=>({state:e,dispatch:t})=>(t&&t(e.tr.setMeta(zD,{type:`clear`})),!0)}},addProseMirrorPlugins(){return[qD()]}}),YD=new WeakMap;function XD(e,t){if(t===null){YD.delete(e);return}YD.set(e,t)}function ZD(e){return YD.get(e)??null}function QD(e){return`pagesBySlug`in e}function $D(e){return QD(e)?e.pages:e}function eO(e,t){return QD(e)?e.assetPaths??new Set:t??new Set}function tO(e,t){let n=We(e);if(n){if(QD(t))return t.pagesBySlug.get(n);for(let e of t)if(We(e)===n)return e}}function nO(e,t){if(e.includes(`/`))return;let n=We(e);if(!n)return;if(QD(t))return t.pagesByBasename?.get(n);let r;for(let e of t){let t=e.lastIndexOf(`/`);We(t===-1?e:e.slice(t+1))===n&&(r===void 0||e.localeCompare(r)<0)&&(r=e)}return r}function rO(e){let t=e.trim();if(!t)return null;let n=We(t);return n?{target:n,alias:n===t?null:t,anchor:null}:null}function iO(e){let t=e.trim();if(!t)return[];let n=We(t);return n.length>0&&n!==t?[n]:[]}function aO(e,t){let n=e.trim();if(!n)return;let r=$D(t);if(r.has(n))return n;let i=tO(n,t);if(i)return i;for(let e of iO(n))if(r.has(e))return e;return oO(n,r)||nO(n,t)}function oO(e,t){let n=`${e}/index`;if(t.has(n))return n;let r=e.lastIndexOf(`/`),i=r===-1?e:e.slice(r+1),a=i?`${e}/${i}`:null;if(a&&t.has(a))return a}function sO(e){let t=((e.trim().split(`#`)[0]??``).trim().split(`?`)[0]??``).trim();return t.startsWith(`/`)?t.slice(1):t}function cO(e,t){let n=sO(e);if(!n)return null;if(t.has(n))return n;let r=n.toLowerCase();for(let e of t)if(e.toLowerCase()===r)return e;if(n.includes(`/`))return null;let i=[...t].filter(e=>{let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase()===r});return i.length===0?null:i.sort((e,t)=>e.localeCompare(t))[0]??null}function lO(e,t,n){let r=e.trim();if(!r)return!1;if(cO(r,eO(t,n)))return!0;let i=$D(t);return i.has(r)||iO(r).some(e=>i.has(e))||tO(r,t)!==void 0||oO(r,i)?!0:nO(r,t)!==void 0}var uO=class extends Error{status;instance;constructor(e,t={}){super(e,t.cause===void 0?void 0:{cause:t.cause}),this.name=`HttpResponseParseError`,this.status=t.status,this.instance=t.instance}},dO=new W(`imageUpload`);function fO(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?G._({id:`KDuPiY`,values:{fileName:n}}):G._({id:`bGa3Fk`})),t}var pO=new U({key:dO,state:{init(){return{decorations:pe.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(dO);if(!i)return{decorations:n,uploads:r};if(i.type===`add`){let t=S.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 dO.getState(e)?.decorations??pe.empty}}});function mO(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function hO(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function gO(e){return e.split(`/`).filter(e=>e!==``)}function _O(e,t){let n=mO(e),r=mO(t),i=hO(e);if(n===r)return i;let a=gO(r),o=gO(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 vO(e){return ZD(e)}function yO(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 bO(e){let t=Se(e);return t===`md`||t===`mdx`?{kind:`wiki-link`,ext:t}:Fe.has(t)?{kind:`jsx-img`,ext:t}:sn.has(t)?{kind:`jsx-video`,ext:t}:Rt.has(t)?{kind:`jsx-audio`,ext:t}:de.has(t)?{kind:`jsx-file`,ext:t}:hn.has(t)?{kind:`wikiembed`,ext:t}:{kind:`markdown-link`,ext:t}}async function xO(e,t,n){let r=vO(t),i=r?`${r}.md`:``;if(!i){or.error(G._({id:`z5pqI8`}));return}let a=crypto.randomUUID(),o=fO(e);t.view.dispatch(t.state.tr.setMeta(dO,{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),SO(t,a);return}let l;try{l=await c.json()}catch(e){console.error(`[uploadAndInsert] Response is not JSON:`,e),SO(t,a);return}if(!c.ok){let e=$t.safeParse(l);if(!e.success){let n=new uO(`Upload response did not match ProblemDetails.`,{cause:e.error,status:c.status});console.error(`[uploadAndInsert] Server error (unparseable):`,n),SO(t,a);return}console.error(`[uploadAndInsert] Server error:`,e.data),SO(t,a,e.data.title);return}let u=Ke.safeParse(l);if(!u.success){let e=new uO(`Upload success response did not match UploadAssetSuccess.`,{cause:u.error,status:c.status});console.error(`[uploadAndInsert] Response missing src:`,e),SO(t,a);return}let d=u.data,f=d.src,p=d.deduped===!0,m=mO(i),h=typeof d.path==`string`&&d.path.length>0?d.path:m?`${m}/${f}`:f;p&&or.info(G._({id:`VbqhBI`,values:{assetContentPath:h}}));let g=bO(e.name),{state:_}=t,v=dO.getState(_)?.uploads.get(a)??n,y=_.tr.setMeta(dO,{type:`remove`,id:a}),b=_O(h,i),x=`/${h}`;if(g.kind===`jsx-file`){if(!_.schema.nodes.jsxComponent){console.error(`[uploadAndInsert] jsxComponent node missing from schema`),SO(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:Pt(e.size)}}};t.chain().command(({tr:e})=>(e.setMeta(dO,{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(Ct.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`),SO(t,a);return}let e=yO(g.kind,x);t.chain().command(({tr:e})=>(e.setMeta(dO,{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(Ct.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`),SO(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`),SO(t,a);return}let r=rO(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 SO(e,t,n){e.view.dispatch(e.state.tr.setMeta(dO,{type:`remove`,id:t})),or.error(n??G._({id:`b3Thhd`}))}var CO=new Set;function wO(e){CO.add(e)}function TO(e){return CO.delete(e)}var EO=new W(`markIdentity`);function DO(){return{byId:new Map,counter:0}}function OO(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&&kO(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 kO(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&&kO(n,i)))return!1}return!0}function AO(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 jO(e){let{markTypes:t,predicate:n,onRegister:r,onDeregister:i}=e,a=new Set(t);return new U({key:EO,state:{init(e,t){return OO(t.doc,DO(),a,n)},apply(e,t,r,i){return e.docChanged?OO(i.doc,t,a,n,e.mapping):t}},view(){let e=new Set;return{update(t){let n=EO.getState(t.state);n&&(e=AO(e,n,r,i))},destroy(){for(let t of e)i?.(t);e=new Set}}}})}var MO=300,NO=150,PO=500,FO=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 IO(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 LO(e){return e?e.closest(`[data-ok-prop-panel]`)!==null:!1}function RO(){return typeof document>`u`?!1:document.querySelector(`[data-ok-layer-spawned]`)!==null}var zO=e=>{let t=(0,J.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,Y.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,Y.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,X.jsxs)(X.Fragment,{children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17],p};function BO(e){return e.editorView?.dom??null}function VO(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 HO(e){let{editor:t}=e,n=new FO,r=BO(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)},MO))},m=()=>{n.getActiveNode()!==null&&o===null&&(o=setTimeout(()=>{o=null,!RO()&&n.setActiveNode(null)},NO))},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&&VO(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??BO(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=IO(e.target,n);if(t===null)return;f(),c=setTimeout(()=>{c=null,l=t,n.setActiveNode(t)},PO);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=IO(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=IO(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=IO(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(LO(r)){d();return}let i=IO(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=IO(r,n);if(o!==null){if(a&&LO(a)){d();return}if(a&&IO(a,n)===o)return;s===o&&u(),m();return}if(LO(r)){if(a&&LO(a))return;let e=n.getActiveNode();if(e!==null&&a&&IO(a,n)===e)return;m()}},E=e=>{if(g)return;let t=e.target;if(!(t instanceof Element))return;let r=IO(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&&LO(i)||i&&IO(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=BO(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 UO=e=>{let t=(0,J.c)(2),{store:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{"data-ok-interaction-layer":``,className:`contents`,children:(0,X.jsx)(zO,{store:n})}),t[0]=n,t[1]=r),r},WO=new WeakMap;function GO(e){let t=WO.get(e);if(t)return t;let n=HO({editor:e});return WO.set(e,n),e.on(`destroy`,()=>{n.destroy(),WO.delete(e)}),n}var KO={AppWindow:Fi,ChevronRight:sr,CopyPlus:Xi,FileText:ra,Film:oa,GitBranch:la,Image:ma,LayoutPanelTop:_a,MessageSquareWarning:Ea,PanelTop:Aa,Paperclip:ja,Sigma:Ra,SquarePlay:Ba,Volume2:Ja,Workflow:Ya,ZoomIn:Za};function qO(e){return e&&Object.hasOwn(KO,e)?KO[e]:zi}var JO={Info:ha,Lightbulb:va,MessageSquareWarning:Ea,AlertTriangle:He,AlertOctagon:Oa,ClipboardList:qi,BookOpen:Ri,ListTodo:Ca,CircleCheck:l,CircleHelp:Gi,CircleX:Ki,Zap:Xa,Bug:Bi,FlaskConical:sa,Quote:Pa,ChevronRight:sr},YO=Object.entries(JO).sort(([e],[t])=>e.localeCompare(t));function XO(e){if(!e||!e.startsWith(`lucide:`))return null;let t=e.slice(7);return Object.hasOwn(JO,t)?JO[t]??null:null}function ZO(e){let t=(0,J.c)(24),n;t[0]===e.icon?n=t[1]:(n=XO(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,X.jsx)(sr,{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,X.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,X.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,X.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,X.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,X.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,X.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,X.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 QO(e){return e!==!1}function $O(e){let t=(0,J.c)(12),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:Re(e.src),t[0]=e.src,t[1]=n);let r=e.title,i;t[2]===e.controls?i=t[3]:(i=QO(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,X.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 ek={note:ha,tip:va,important:Ea,warning:He,caution:Oa,abstract:qi,info:Ri,todo:Ca,success:l,question:Gi,failure:Ki,danger:Xa,bug:Bi,example:sa,quote:Pa};function tk(e,t){return XO(e)??ek[t]}var nk=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]);function rk(e){return typeof e==`string`&&nk.has(e)?e:`note`}function ik(e){let t=(0,J.c)(29),n,r;t[0]!==e.icon||t[1]!==e.type?(r=rk(e.type),n=tk(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,X.jsxs)(`span`,{className:`callout-header`,contentEditable:!1,children:[(0,X.jsx)(i,{size:16,className:`callout-icon`,"aria-hidden":`true`}),e.title?(0,X.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,X.jsx)(`span`,{className:`callout-title`,children:(0,X.jsx)(o,{id:`URmyfc`})}),t[9]=l,t[10]=i);let a;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Hi,{size:16,className:`callout-chevron`,"aria-hidden":`true`}),t[11]=a):a=t[11];let c;t[12]===i?c=t[13]:(c=(0,X.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,X.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,X.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,X.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,X.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 ak=(0,Y.createContext)(null);function ok(e){let t=(0,J.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,X.jsx)(ak.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function sk(){return(0,Y.use)(ak)}var ck=[{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 lk(e){let t=(0,J.c)(7),{targetRef:n,onResize:r,onResizeEnd:a,bounds:o}=e,{_:s}=i(),c=(0,Y.useRef)(null),l;t[0]!==o?.maxHeight||t[1]!==o?.maxWidth||t[2]!==o?.minHeight||t[3]!==o?.minWidth?(l=function(e,t){let n=t===`w`?o?.minWidth??64:o?.minHeight??64,r=t===`w`?o?.maxWidth??1/0:o?.maxHeight??1/0;return Math.max(n,Math.min(r,e))},t[0]=o?.maxHeight,t[1]=o?.maxWidth,t[2]=o?.minHeight,t[3]=o?.minWidth,t[4]=l):l=t[4];let u=l,d=function(e,t){let i=n.current;if(!i)return;e.preventDefault(),e.stopPropagation();let o=i.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&&a?.(t)}window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},f=ck.map(e=>{let t=e.key;return(0,X.jsx)(`button`,{type:`button`,className:Sn(e.className),"aria-label":s({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,X.jsx)(`div`,{className:`ok-resize-overlay`,contentEditable:!1,"aria-hidden":`true`,children:f}),t[5]=f,t[6]=p),p}var uk=`26rem`,dk=`Embedded content`,fk=/^https?:\/\//i;function pk(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function mk(e){return!(typeof e!=`string`||!fk.test(e)||!pk(e))}function hk(e){let t=(0,J.c)(21),{src:n,title:r,width:i,height:a}=e,o=(0,Y.useRef)(null),s=sk(),c=i||void 0,l=a||uk,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||uk)},p=[i,a],t[3]=a,t[4]=i,t[5]=f,t[6]=p):(f=t[5],p=t[6]),(0,Y.useEffect)(f,p),!mk(n)){let e=`Embed a URL`;typeof n==`string`&&n.length>0&&(e=fk.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,X.jsx)(`div`,{className:`ok-embed ok-embed--placeholder`,contentEditable:!1,children:(0,X.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=r||dk,_;t[11]!==n||t[12]!==g?(_=(0,X.jsx)(`iframe`,{title:g,src:n,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation`,referrerPolicy:`no-referrer`,loading:`lazy`,className:`ok-embed-frame`}),t[11]=n,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==s||t[15]!==h?(v=s?(0,X.jsx)(lk,{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[14]=s,t[15]=h,t[16]=v):v=t[16];let y;return t[17]!==d||t[18]!==_||t[19]!==v?(y=(0,X.jsxs)(`div`,{className:`ok-embed`,style:d,ref:o,contentEditable:!1,children:[_,v]}),t[17]=d,t[18]=_,t[19]=v,t[20]=y):y=t[20],y}function gk(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 _k(e){let t=(0,J.c)(18),n;t[0]!==e.name||t[1]!==e.src?(n=e.name?.trim()||gk(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?Re(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,X.jsx)(ia,{className:`ok-file-icon`,"aria-hidden":`true`}),t[7]=l):l=t[7];let u;t[8]===r?u=t[9]:(u=(0,X.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,X.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,X.jsxs)(`a`,{href:o,title:e.title,className:`ok-file-attachment`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:vk,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 vk(e){return e.stopPropagation()}function yk(){return Y.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`},Y.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 bk(){return Y.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`},Y.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 xk(e){return typeof Element>`u`?!1:e instanceof Element}var Sk=(e,t)=>xk(t)&&t.tagName.toUpperCase()===e,Ck=e=>Sk(`DIV`,e)||Sk(`SPAN`,e),wk=e=>Sk(`IMG`,e),Tk=e=>e.complete&&e.naturalHeight!==0,Ek=e=>Sk(`SVG`,e),Dk=({height:e,offset:t,width:n})=>Math.min((window.innerWidth-t*2)/n,(window.innerHeight-t*2)/e),Ok=({containerHeight:e,containerWidth:t,offset:n,targetHeight:r,targetWidth:i})=>{let a=Dk({height:r,offset:n,width:i}),o=i>r?i/t:r/e;return a>1?o:a*o},kk=({containerHeight:e,containerWidth:t,hasScalableSrc:n,offset:r,targetHeight:i,targetWidth:a})=>e===0||t===0?1:!n&&i!==0&&a!==0?Ok({containerHeight:e,containerWidth:t,offset:r,targetHeight:i,targetWidth:a}):Dk({height:e,offset:r,width:t}),Ak=/url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/,jk=e=>{if(e!==null){if(wk(e))return e.currentSrc===``?void 0:e.currentSrc;if(Ck(e)){let{backgroundImage:t}=window.getComputedStyle(e);if(t!==``)return Ak.exec(t)?.[1]}}},Mk=e=>{if(e!==null)return wk(e)?e.alt:e.getAttribute(`aria-label`)??void 0},Nk=({containerHeight:e,containerLeft:t,containerTop:n,containerWidth:r,hasScalableSrc:i,offset:a,targetHeight:o,targetWidth:s})=>{let c=kk({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})`}},Pk=({position:e,relativeNum:t})=>{let n=parseFloat(e);return e.endsWith(`%`)?t*n/100:n},Fk=({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=Pk({position:p,relativeNum:r-l*f}),g=Pk({position:m,relativeNum:e-c*f}),_=kk({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=Pk({position:a,relativeNum:r-l}),f=Pk({position:u,relativeNum:e-c}),p=kk({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=kk({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{}},Ik=({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=Pk({position:p,relativeNum:a-l*f}),g=Pk({position:m,relativeNum:n-c*f}),_=kk({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=Pk({position:t,relativeNum:a-l}),f=Pk({position:u,relativeNum:n-c}),p=kk({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=Pk({position:u,relativeNum:a}),p=Pk({position:d,relativeNum:n}),m=f/l,h=p/c,g=Math.min(m,h),[_=`50%`,v=`50%`]=e.split(` `),y=Pk({position:_,relativeNum:a-l*g}),b=Pk({position:v,relativeNum:n-c*g}),x=kk({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})`}}},Lk=/\.svg$/i,Rk=({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&&Lk.test(t),l=s.getBoundingClientRect(),u=window.getComputedStyle(s),d=i!=null&&Ck(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=Nk({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:c,offset:a,targetHeight:p,targetWidth:m}),g=f?Fk({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?Ik({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},zk=e=>{if(e==null)return{};if(Ek(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}},Bk=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}`)}})})},Vk=[`img`,`svg`,`[role="img"]`,`[data-zoom]`].map(e=>`${e}:not([aria-hidden="true"])`).join(`,`),Hk={overflow:``,width:``};function Uk(){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 Wk(e){e.preventDefault()}function Gk(e){return Y.createElement(Kk,{...e})}var Kk=class extends Y.Component{constructor(){super(...arguments),this.state={id:``,isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:`UNLOADED`,shouldRefresh:!1,styleGhost:{}},this.refContent=Y.createRef(),this.refDialog=Y.createRef(),this.refModalContent=Y.createRef(),this.refModalImg=Y.createRef(),this.refWrap=Y.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=Hk,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(Vk),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:zk(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver??(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:zk(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=jk(this.imgEl);if(e==null||e===``)return;let t=new Image,{imgEl:n}=this;if(wk(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:zk(this.imgEl)})};t.decode().then(r).catch(()=>{if(Tk(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||Ek(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=Hk},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(Tk(n)){r();return}n.onload=r})}},this.UNSAFE_handleSvg=()=>{let{imgEl:e,refModalImg:t,styleModalImg:n}=this;if(Ek(e)){let r=e.cloneNode(!0);Bk(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=Ck(a),j=wk(a),M=Ek(a),N=Mk(a),P=jk(a),F=j?a.sizes:void 0,I=j?a.srcset:void 0,L=j?a.crossOrigin:void 0,ee=h?.src!==void 0&&h.src!==``,R=this.hasImage(),z=N!==void 0&&N!==``?`${s}: ${N}`:s,te=T===`LOADING`||T===`LOADED`,B=R?`found`:`not-found`,ne=T===`UNLOADED`||T===`UNLOADING`?`hidden`:`visible`,V={visibility:T===`UNLOADED`?`visible`:`hidden`};this.styleModalImg=R&&a!==null?Rk({hasZoomImg:ee,imgSrc:P,isSvg:M,isZoomed:f&&te,loadedImgEl:w,offset:g,shouldRefresh:E,targetEl:a}):{};let re=null;if(R){let t=j||A?Y.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?Y.createElement(`div`,{"data-rmiz-modal-img":!0,ref:b,style:this.styleModalImg}):null,n=Y.createElement(`button`,{"aria-label":o,"data-rmiz-btn-unzoom":``,onClick:e,type:`button`},Y.createElement(u,null));re=m==null?Y.createElement(Y.Fragment,null,t,n):Y.createElement(m,{buttonUnzoom:n,modalState:T,img:t,isZoomImgLoaded:C,onUnzoom:r})}return Y.createElement(p,{"aria-owns":R?O:void 0,"data-rmiz":``,ref:x},Y.createElement(p,{"data-rmiz-content":B,ref:_,style:V},c),R&&Y.createElement(p,{"data-rmiz-ghost":``,style:D},Y.createElement(`button`,{"aria-label":z,"data-rmiz-btn-zoom":``,onClick:i,type:`button`},Y.createElement(d,null))),R&&no.createPortal(Y.createElement(`dialog`,{"aria-labelledby":k,"aria-modal":`true`,className:l,"data-rmiz-modal":``,id:O,onClick:t,onClose:n,onCancel:Wk,ref:v,role:`dialog`},Y.createElement(`div`,{"data-rmiz-modal-overlay":ne}),Y.createElement(`div`,{"data-rmiz-modal-content":``,ref:y},re)),Uk()))}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)}};Kk.defaultProps={a11yNameButtonUnzoom:`Minimize image`,a11yNameButtonZoom:`Expand image`,canSwipeToUnzoom:!0,IconUnzoom:yk,IconZoom:bk,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:`div`,zoomMargin:0};function qk({onZoomChange:e,...t}){let[n,r]=Y.useState(!1),i=Y.useCallback((t,{event:n})=>{r(t),e?.(t,{event:n})},[e]);return Y.createElement(Gk,{...t,isZoomed:n,onZoomChange:i})}function Jk(e,t){return typeof e==`number`&&typeof t==`number`&&e>0&&t>0}function Yk(e,t,n){return Jk(e,t)?{...n,width:`${e}px`,aspectRatio:`${e} / ${t}`}:n}function Xk(e){let t=(0,J.c)(52),n,r,a,o,s,c,l,u,d,f,p,m;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=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:s,onError:o,src:l,style:u,alt:p,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s,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}=i(),y=(0,Y.useRef)(null),[b,x]=(0,Y.useState)(!1),S;t[13]!==r||t[14]!==m?(S=Jk(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=Yk(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,Y.useLayoutEffect)(E,D);let O=!C&&!b&&`aspect-[16/9] w-full max-w-full`,k;t[23]!==c||t[24]!==O?(k=Sn(`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,X.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=Sn(`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]===s?N=t[34]:(N=e=>{x(!0),s?.(e)},t[33]=s,t[34]=N);let P;t[35]===o?P=t[36]:(P=e=>{x(!0),o?.(e)},t[35]=o,t[36]=P);let F;t[37]!==_||t[38]!==r||t[39]!==a||t[40]!==l||t[41]!==M||t[42]!==N||t[43]!==P||t[44]!==m?(F=(0,X.jsx)(`img`,{...a,ref:y,src:l,alt:_,width:m,height:r,className:M,onLoad:N,onError:P}),t[37]=_,t[38]=r,t[39]=a,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,X.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 Zk(e){return e??`lazy`}function Qk(e){if(typeof e!=`string`)return e;let t=Number(e);return Number.isFinite(t)&&t>0?t:e}function $k(e){let t=(0,J.c)(21),n;t[0]===e.src?n=t[1]:(n=e.src===void 0?void 0:Re(e.src),t[0]=e.src,t[1]=n);let r=e.alt??``,i;t[2]===e.width?i=t[3]:(i=Qk(e.width),t[2]=e.width,t[3]=i);let a;t[4]===e.height?a=t[5]:(a=Qk(e.height),t[4]=e.height,t[5]=a);let o=e.title,s;t[6]===e.loading?s=t[7]:(s=Zk(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,X.jsx)(Xk,{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 eA(e){let t=(0,J.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={sizes:void 0},t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,X.jsx)(qk,{wrapElement:`span`,zoomMargin:20,zoomImg:n,children:(0,X.jsx)($k,{...e})}),t[1]=e,t[2]=r),r}var tA=(0,Y.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-DX-tM4Fr.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,J.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,X.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 nA(e){let t=(0,J.c)(3),n=e.formula||`\xA0`,r;return t[0]!==e.id||t[1]!==n?(r=(0,X.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 rA(e){let t=(0,J.c)(6),n=e.formula??``;if(!n){let r;return t[0]!==n||t[1]!==e.id?(r=(0,X.jsx)(nA,{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,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(nA,{formula:n,id:e.id}),children:(0,X.jsx)(tA,{formula:n,id:e.id})}),t[3]=n,t[4]=e.id,t[5]=r):r=t[5],r}var iA=null;function aA(){return iA||=n(()=>import(`./mermaid.core-CWYso-V4.js`).then(e=>{let t=e.default;return t.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`default`,suppressErrorRendering:!0}),t}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),import.meta.url).catch(e=>{throw iA=null,e}),iA}function oA(e){let t=(0,J.c)(24),n=e.chart??``,r=(0,Y.useId)(),i;if(t[0]!==r){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/:/g,t[2]=e):e=t[2],i=r.replace(e,`_`),t[0]=r,t[1]=i}else i=t[1];let a=`mermaid-${i}`,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={status:`idle`,svg:``,error:``},t[3]=s):s=t[3];let[c,l]=(0,Y.useState)(s),u,d;if(t[4]!==n||t[5]!==a?(u=()=>{if(!n.trim()){l({status:`idle`,svg:``,error:``});return}let e=!1;return l(sA),aA().then(async t=>{try{let r=await t.render(a,n);e||l({status:`ready`,svg:r.svg,error:``})}catch(t){let n=t;e||l({status:`error`,svg:``,error:n instanceof Error?n.message:String(n)})}}).catch(t=>{e||l({status:`error`,svg:``,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},d=[n,a],t[4]=n,t[5]=a,t[6]=u,t[7]=d):(u=t[6],d=t[7]),(0,Y.useEffect)(u,d),!n.trim()){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{className:`mermaid mermaid-placeholder`,"data-component-type":`mermaid`,children:(0,X.jsx)(`span`,{className:`mermaid-empty`,children:` `})}),t[8]=e):e=t[8],e}if(c.status===`error`){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(He,{className:`size-3.5 shrink-0 mt-0.5`,"aria-hidden":!0}),t[9]=e):e=t[9];let r;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(`div`,{className:`font-medium`,children:(0,X.jsx)(o,{id:`OLBz-_`})}),t[10]=r):r=t[10];let i;t[11]===c.error?i=t[12]:(i=(0,X.jsxs)(`div`,{role:`alert`,className:`mermaid-error-message mb-2 flex items-start gap-2 rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive`,children:[e,(0,X.jsxs)(`div`,{className:`min-w-0`,children:[r,(0,X.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words font-mono text-[11px] opacity-90`,children:c.error})]})]}),t[11]=c.error,t[12]=i);let a;t[13]===n?a=t[14]:(a=(0,X.jsx)(`pre`,{className:`mermaid-error-source`,children:n}),t[13]=n,t[14]=a);let s;return t[15]!==c.error||t[16]!==i||t[17]!==a?(s=(0,X.jsxs)(`div`,{className:`mermaid mermaid-error`,"data-component-type":`mermaid`,title:c.error,children:[i,a]}),t[15]=c.error,t[16]=i,t[17]=a,t[18]=s):s=t[18],s}let f=`mermaid mermaid-${c.status}`,p;t[19]===c.svg?p=t[20]:(p={__html:c.svg},t[19]=c.svg,t[20]=p);let m;return t[21]!==f||t[22]!==p?(m=(0,X.jsx)(`div`,{className:f,"data-component-type":`mermaid`,dangerouslySetInnerHTML:p}),t[21]=f,t[22]=p,t[23]=m):m=t[23],m}function sA(e){return{...e,status:`rendering`}}var cA=null;function lA(){return cA||=new V({extensions:B}),cA}function uA(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=uA(e,t);if(n)return n}return null}function dA(e){return se({type:`root`,children:e.children??[]})}var fA=new Map,pA=30,mA=150,hA=1e4;function gA(e,t){let n=`${e}|${t}`,r=fA.get(n);if(r)return r.refcount+=1,r;let i=new eh,a=new ZE({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()}),fA.set(n,s),fA.size>pA&&console.warn(`[Mirror] provider pool exceeded ${pA} entries (current=${fA.size}). Many Mirrors pointing at distinct source docs — investigate if this is a runaway pattern.`),s}function _A(e,t){let n=`${e}|${t}`,r=fA.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})}fA.delete(n)}}function vA(e,t){let n=(0,J.c)(8),{collabUrl:r}=eS(),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={kind:`loading`},n[0]=i):i=n[0];let[a,o]=(0,Y.useState)(i),s=(0,Y.useRef)(t),c=(0,Y.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=gA(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=lA().parseToMdast(r)}catch(t){console.warn(`[Mirror] parseToMdast failed`,{src:e,anchor:n,err:t}),o({kind:`source-removed`});return}let a=uA(i,n);if(!a){o({kind:`anchor-not-found`});return}let c;try{c=dA(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()},mA)},onSynced:()=>{i&&=(clearTimeout(i),null),n()}};t.subscribers.add(a),c.current=n;let l=setTimeout(()=>{t.synced||o({kind:`source-removed`})},hA);return n(),()=>{clearTimeout(l),i&&clearTimeout(i),t.subscribers.delete(a),c.current=null,_A(r,e)}},u=[r,e],n[1]=r,n[2]=e,n[3]=l,n[4]=u):(l=n[3],u=n[4]),(0,Y.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,Y.useEffect)(d,f),a}function yA(e){let t=(0,J.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,X.jsx)(ya,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":`true`}):(0,X.jsx)(xa,{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,X.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,X.jsxs)(`div`,{className:n,children:[r,i]}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bA(e){let t=(0,J.c)(30),n=e.src??``,r=e.anchor??``,i=vA(n,r);if(i.kind===`empty-props`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(yA,{tone:`placeholder`,children:(0,X.jsx)(o,{id:`3SDfZl`,components:{0:(0,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{}),2:(0,X.jsx)(`code`,{}),3:(0,X.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,X.jsx)(`code`,{})},t[3]=a):a=t[3];let s;return t[4]===i?s=t[5]:(s=(0,X.jsx)(yA,{tone:`placeholder`,children:(0,X.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,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{})},t[8]=r):r=t[8];let i;return t[9]===e?i=t[10]:(i=(0,X.jsx)(yA,{tone:`error`,children:(0,X.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,X.jsx)(`span`,{className:`font-medium`}),1:(0,X.jsx)(`code`,{}),2:(0,X.jsx)(`code`,{})},t[14]=a):a=t[14];let s;return t[15]===i?s=t[16]:(s=(0,X.jsx)(yA,{tone:`error`,children:(0,X.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,X.jsx)(Zi,{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,X.jsx)(`code`,{className:`font-mono`})},t[20]=c):c=t[20];let l;t[21]===s?l=t[22]:(l=(0,X.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,X.jsx)(`span`,{children:(0,X.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,X.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,X.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 xA(e){let t=(0,J.c)(15),{_:n}=i(),r=e.id??``,a;t[0]!==n||t[1]!==r?(a=r||n({id:`12F9WL`}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let s=a,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(Xi,{className:`size-3`,"aria-hidden":`true`}),t[3]=c):c=t[3];let l;t[4]===s?l=t[5]:(l={label:s},t[4]=s,t[5]=l);let u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u={0:(0,X.jsx)(`code`,{className:`font-mono`})},t[6]=u):u=t[6];let d;t[7]===l?d=t[8]:(d=(0,X.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,X.jsx)(`span`,{children:(0,X.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,X.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,X.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 SA=24,CA=24,wA=12,TA=.1;function EA(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(TA,(n-SA)/t.naturalWidth);case`fit-height`:return Math.max(TA,(r-CA)/t.naturalHeight);case`single`:return 1;case`two-odd`:case`two-even`:return Math.max(TA,((n-SA)/2-wA)/t.naturalWidth)}}var DA=600,OA=.5,kA=3,AA=.25,jA=null;function MA(){return jA||(jA=(async()=>{let e=await n(()=>import(`./pdf-CtJiipL_.js`),__vite__mapDeps([24,1]),import.meta.url);if(!e.GlobalWorkerOptions.workerSrc){let t=(await n(async()=>{let{default:e}=await import(`./pdf.worker-BZq-wJdz.js`);return{default:e}},[],import.meta.url)).default;e.GlobalWorkerOptions.workerSrc=t}return e})(),jA.catch(()=>{jA=null})),jA}function NA(e){return e instanceof Error&&e.name===`RenderingCancelledException`}function PA(e){let t=(0,J.c)(96),n,r;if(t[0]!==e.anchor||t[1]!==e.fillContainer){let{height:i,viewerFragment:a}=_(e.anchor);n=i===null?e.fillContainer?`100%`:`${DA}px`:`${i}px`,r=BA(a),t[0]=e.anchor,t[1]=e.fillContainer,t[2]=n,t[3]=r}else n=t[2],r=t[3];let a=r,s=(0,Y.useRef)(null),c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[4]=c):c=t[4];let l=(0,Y.useRef)(c),u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[5]=u):u=t[5];let d=(0,Y.useRef)(u),f=(0,Y.useRef)(null),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[6]=p):p=t[6];let[m,h]=(0,Y.useState)(p),[g,v]=(0,Y.useState)(!0),[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(a??1),[C,w]=(0,Y.useState)(String(a??1)),[T,E]=(0,Y.useState)(1),[D,O]=(0,Y.useState)(`fit-width`),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)(0),[F,I]=(0,Y.useState)(0),{_:L}=i(),ee=m.length,R,z;t[7]!==L||t[8]!==e.src?(R=()=>{if(!e.src){v(!1);return}let t=Re(e.src),n=!1,r=null;return v(!0),b(null),(async()=>{try{let e=await(await MA()).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;b(t instanceof Error?t.message:L({id:`jRHdCz`})),v(!1)}})(),()=>{n=!0,r&&=(r.destroy(),null),f.current=null}},z=[e.src,L],t[7]=L,t[8]=e.src,t[9]=R,t[10]=z):(R=t[9],z=t[10]),(0,Y.useEffect)(R,z);let te,B;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{let e=s.current;if(!e)return;let t=()=>{P(e.clientWidth),I(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},B=[],t[11]=te,t[12]=B):(te=t[11],B=t[12]),(0,Y.useEffect)(te,B);let ne,V;t[13]!==L||t[14]!==F||t[15]!==N||t[16]!==D||t[17]!==m||t[18]!==T?(ne=()=>{let e=f.current;if(!e||m.length===0||N===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=EA(D,i,N,F)*T,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||v(!1)}catch(e){let n=e;if(t||NA(n))return;console.warn(`[Pdf] page render failed:`,n),b(n instanceof Error?n.message:L({id:`_TF8ep`})),v(!1)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},V=[m,D,T,N,F,L],t[13]=L,t[14]=F,t[15]=N,t[16]=D,t[17]=m,t[18]=T,t[19]=ne,t[20]=V):(ne=t[19],V=t[20]),(0,Y.useEffect)(ne,V);let re,ie;t[21]!==m||t[22]!==k?(re=()=>{if(!k)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;NA(t)||console.warn(`[Pdf] thumbnail render failed:`,t)}})(),()=>{if(t=!0,n){try{n.cancel()}catch{}n=null}}},ie=[k,m],t[21]=m,t[22]=k,t[23]=re,t[24]=ie):(re=t[23],ie=t[24]),(0,Y.useEffect)(re,ie);let H,ae;t[25]!==g||t[26]!==a?(H=()=>{if(g||!a)return;let e=s.current,t=l.current[a-1];e&&t&&(e.scrollTop=t.offsetTop-e.offsetTop)},ae=[g,a],t[25]=g,t[26]=a,t[27]=H,t[28]=ae):(H=t[27],ae=t[28]),(0,Y.useEffect)(H,ae);let oe,U;t[29]===m?(oe=t[30],U=t[31]):(oe=()=>{let e=s.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)}S(r),w(String(r))}))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},U=[m],t[29]=m,t[30]=oe,t[31]=U),(0,Y.useEffect)(oe,U);let se,ce;t[32]===j?(se=t[33],ce=t[34]):(se=()=>{if(!j)return;let e=e=>{let t=e.target,n=s.current?.closest(`.ok-pdf`);if(!n||!t||!n.contains(t)){M(!1);return}let r=n.querySelector(`.ok-pdf-layout-menu`);r&&!r.contains(t)&&M(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},ce=[j],t[32]=j,t[33]=se,t[34]=ce),(0,Y.useEffect)(se,ce);let W;t[35]===ee?W=t[36]:(W=e=>{let t=Math.max(1,Math.min(ee||1,e));S(t),w(String(t));let n=s.current,r=l.current[t-1];n&&r&&n.scrollTo({top:r.offsetTop-n.offsetTop,behavior:`smooth`})},t[35]=ee,t[36]=W);let le=W,ue;t[37]!==x||t[38]!==le||t[39]!==C?(ue=()=>{let e=Number.parseInt(C,10);if(Number.isNaN(e)){w(String(x));return}le(e)},t[37]=x,t[38]=le,t[39]=C,t[40]=ue):ue=t[40];let de=ue,fe;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>E(RA),t[41]=fe):fe=t[41];let pe=fe,me;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>E(LA),t[42]=me):me=t[42];let he=me,ge;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>{O(e),M(!1),E(1)},t[43]=ge):ge=t[43];let _e=ge,ve;t[44]===n?ve=t[45]:(ve={height:n},t[44]=n,t[45]=ve);let ye;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>A(IA),t[46]=ye):ye=t[46];let be;t[47]!==L||t[48]!==k?(be=L(k?{id:`JK-Ave`}:{id:`iEYxO4`}),t[47]=L,t[48]=k,t[49]=be):be=t[49];let xe;t[50]===L?xe=t[51]:(xe=L({id:`zo3Dl7`}),t[50]=L,t[51]=xe);let Se;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,X.jsx)(ka,{size:14,"aria-hidden":`true`}),t[52]=Se):Se=t[52];let Ce;t[53]!==k||t[54]!==be||t[55]!==xe?(Ce=(0,X.jsx)(`button`,{type:`button`,onClick:ye,"aria-label":be,"aria-pressed":k,className:`ok-pdf-btn`,title:xe,children:Se}),t[53]=k,t[54]=be,t[55]=xe,t[56]=Ce):Ce=t[56];let we=e.title??`PDF`,Te;t[57]===we?Te=t[58]:(Te=(0,X.jsx)(`span`,{className:`ok-pdf-title`,children:we}),t[57]=we,t[58]=Te);let Ee;t[59]!==L||t[60]!==j||t[61]!==D||t[62]!==C||t[63]!==de||t[64]!==ee||t[65]!==T?(Ee=ee>0&&(0,X.jsxs)(`div`,{className:`ok-pdf-controls`,children:[(0,X.jsx)(`form`,{className:`ok-pdf-page-form`,onSubmit:e=>{e.preventDefault(),de()},children:(0,X.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,className:`ok-pdf-page-input`,value:C,onChange:e=>w(e.target.value.replace(/[^0-9]/g,``)),onBlur:de,"aria-label":L({id:`xsZhu-`})})}),(0,X.jsx)(`span`,{className:`ok-pdf-page-of`,children:(0,X.jsx)(o,{id:`1GhYxC`,values:{totalPages:ee}})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,onClick:he,disabled:T<=OA,"aria-label":L({id:`FjkaiT`}),className:`ok-pdf-btn`,title:L({id:`FjkaiT`}),children:(0,X.jsx)(Qa,{size:14,"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`ok-pdf-zoom-display`,"aria-live":`polite`,children:[Math.round(T*100),`%`]}),(0,X.jsx)(`button`,{type:`button`,onClick:pe,disabled:T>=kA,"aria-label":L({id:`AWOSPo`}),className:`ok-pdf-btn`,title:L({id:`AWOSPo`}),children:(0,X.jsx)(Za,{size:14,"aria-hidden":`true`})}),(0,X.jsx)(`span`,{className:`ok-pdf-divider`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`ok-pdf-layout-menu`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>M(FA),"aria-label":L({id:`GQDSBN`}),"aria-haspopup":`menu`,"aria-expanded":j,className:`ok-pdf-btn`,title:L({id:`rdU729`}),children:(0,X.jsx)(Hi,{size:14,"aria-hidden":`true`})}),j&&(0,X.jsxs)(`div`,{role:`menu`,className:`ok-pdf-menu`,children:[(0,X.jsx)(zA,{label:L({id:`vIxrEk`}),active:D===`fit-width`,onSelect:()=>_e(`fit-width`)}),(0,X.jsx)(zA,{label:L({id:`YlDuro`}),active:D===`fit-height`,onSelect:()=>_e(`fit-height`)}),(0,X.jsx)(`hr`,{className:`ok-pdf-menu-divider`}),(0,X.jsx)(zA,{label:L({id:`BGHHtQ`}),active:D===`single`,onSelect:()=>_e(`single`)}),(0,X.jsx)(zA,{label:L({id:`xK291b`}),active:D===`two-odd`,onSelect:()=>_e(`two-odd`)}),(0,X.jsx)(zA,{label:L({id:`NSnIUP`}),active:D===`two-even`,onSelect:()=>_e(`two-even`)})]})]})]}),t[59]=L,t[60]=j,t[61]=D,t[62]=C,t[63]=de,t[64]=ee,t[65]=T,t[66]=Ee):Ee=t[66];let De;t[67]!==Ce||t[68]!==Te||t[69]!==Ee?(De=(0,X.jsxs)(`div`,{className:`ok-pdf-toolbar`,contentEditable:!1,children:[Ce,Te,Ee]}),t[67]=Ce,t[68]=Te,t[69]=Ee,t[70]=De):De=t[70];let Oe;t[71]!==L||t[72]!==x||t[73]!==le||t[74]!==m||t[75]!==k?(Oe=k&&(0,X.jsx)(`aside`,{className:`ok-pdf-sidebar`,"aria-label":L({id:`nzaV6Q`}),children:m.map((e,t)=>{let{pageNumber:n}=e;return(0,X.jsxs)(`button`,{type:`button`,className:`ok-pdf-thumb`,"data-active":x===n||void 0,onClick:()=>le(n),"aria-label":L({id:`qioCwA`,values:{pageNumber:n}}),children:[(0,X.jsx)(`canvas`,{ref:e=>{d.current[t]=e},className:`ok-pdf-thumb-canvas`}),(0,X.jsx)(`span`,{className:`ok-pdf-thumb-num`,children:n})]},n)})}),t[71]=L,t[72]=x,t[73]=le,t[74]=m,t[75]=k,t[76]=Oe):Oe=t[76];let ke;t[77]===g?ke=t[78]:(ke=g&&(0,X.jsx)(`div`,{className:`ok-pdf-loading`,children:(0,X.jsx)(o,{id:`T-654M`})}),t[77]=g,t[78]=ke);let Ae;t[79]===y?Ae=t[80]:(Ae=y&&(0,X.jsx)(`div`,{className:`ok-pdf-error`,children:(0,X.jsx)(o,{id:`WamGNs`,values:{error:y}})}),t[79]=y,t[80]=Ae);let je;t[81]!==L||t[82]!==ee?(je=Array.from({length:ee},(e,t)=>{let n=t+1;return(0,X.jsx)(`canvas`,{ref:e=>{l.current[t]=e},className:`ok-pdf-page`,"aria-label":L({id:`XtRoxT`,values:{pageNumber:n}})},n)}),t[81]=L,t[82]=ee,t[83]=je):je=t[83];let Me;t[84]!==D||t[85]!==ke||t[86]!==Ae||t[87]!==je?(Me=(0,X.jsxs)(`div`,{className:`ok-pdf-pages`,ref:s,"data-layout":D,children:[ke,Ae,je]}),t[84]=D,t[85]=ke,t[86]=Ae,t[87]=je,t[88]=Me):Me=t[88];let Ne;t[89]!==Oe||t[90]!==Me?(Ne=(0,X.jsxs)(`div`,{className:`ok-pdf-body`,children:[Oe,Me]}),t[89]=Oe,t[90]=Me,t[91]=Ne):Ne=t[91];let Pe;return t[92]!==ve||t[93]!==De||t[94]!==Ne?(Pe=(0,X.jsxs)(`div`,{className:`ok-pdf`,style:ve,children:[De,Ne]}),t[92]=ve,t[93]=De,t[94]=Ne,t[95]=Pe):Pe=t[95],Pe}function FA(e){return!e}function IA(e){return!e}function LA(e){return Math.max(OA,+(e-AA).toFixed(2))}function RA(e){return Math.min(kA,+(e+AA).toFixed(2))}function zA(e){let t=(0,J.c)(10),n=e.active||void 0,r;t[0]===e.active?r=t[1]:(r=e.active&&(0,X.jsx)(ar,{size:14}),t[0]=e.active,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,X.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,X.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 BA(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 VA(e){let t=(0,J.c)(10),{label:n,id:r,children:i}=e,a=(0,Y.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,X.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 HA=`[data-component-type="tabs"]`,UA=`[data-node-view-content-react] > .react-renderer`;function WA(e){let t=e.closest(HA);return t?Array.from(e.querySelectorAll(UA)).filter(e=>e.parentElement?.closest(HA)===t).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 GA(e){let t=(0,J.c)(33),{id:n,children:r}=e,[a,o]=(0,Y.useState)(0),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Y.useState)(s),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),f=(0,Y.useRef)(0),p=sk(),m=p?.addChild!=null,{_:h}=i(),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=u.current;if(!e)return;let t=WA(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,Y.useLayoutEffect)(g);let _,v;t[2]===c.length?(_=t[3],v=t[4]):(_=()=>{c.length>f.current&&c.length>0&&o(c.length-1),f.current=c.length},v=[c.length],t[2]=c.length,t[3]=_,t[4]=v),(0,Y.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){o(0);return}let t=u.current;if(!t)return;let r=WA(t).findIndex(t=>t.panelId===e);r<0||(o(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,Y.useLayoutEffect)(y);let b=c.length===0?0:Math.min(Math.max(a,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(),o(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;if(t[10]!==c||t[11]!==b){let e;t[13]===b?e=t[14]:(e=e=>(0,X.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:qA,onClick:()=>o(e.index),children:e.label},e.index),t[13]=b,t[14]=e),w=c.map(e),t[10]=c,t[11]=b,t[12]=w}else w=t[12];let T;t[15]!==S||t[16]!==C||t[17]!==w?(T=(0,X.jsx)(`div`,{ref:d,role:`tablist`,"aria-label":C,className:`tabs-tablist`,onKeyDown:S,children:w}),t[15]=S,t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==h||t[20]!==m||t[21]!==p?(E=m&&(0,X.jsx)(`button`,{type:`button`,className:`tabs-strip-add`,"aria-label":h({id:`hjO0Mq`}),title:h({id:`hjO0Mq`}),onMouseDown:KA,onClick:()=>p?.addChild?.(),"data-tabs-strip-add":``,children:`+`}),t[19]=h,t[20]=m,t[21]=p,t[22]=E):E=t[22];let D;t[23]!==E||t[24]!==T?(D=(0,X.jsxs)(`div`,{className:`tabs-strip`,contentEditable:!1,children:[T,E]}),t[23]=E,t[24]=T,t[25]=D):D=t[25];let O;t[26]!==r||t[27]!==b?(O=(0,X.jsx)(`div`,{ref:u,className:`tabs-content`,"data-active-index":b,children:r}),t[26]=r,t[27]=b,t[28]=O):O=t[28];let k;return t[29]!==n||t[30]!==D||t[31]!==O?(k=(0,X.jsxs)(`div`,{className:`tabs`,id:n,children:[D,O]}),t[29]=n,t[30]=D,t[31]=O,t[32]=k):k=t[32],k}function KA(e){return e.preventDefault()}function qA(e){return e.preventDefault()}var JA=typeof global<`u`&&{}.toString.call(global)===`[object global]`,YA=typeof Bun<`u`,XA=typeof Deno<`u`,ZA=typeof WebSocketPair==`function`&&caches?.default!==void 0,QA=JA||YA||XA||ZA;function $A(e,t){return e.indexOf(t.toLowerCase())===0?e:`${t.toLowerCase()}${e.substr(0,1).toUpperCase()}${e.substr(1)}`}function ej(e){return!!(e&&e.nodeType===1&&`nodeName`in e&&e.ownerDocument&&e.ownerDocument.defaultView)}function tj(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function nj(e){return/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))(?=$|\/)/.test(e)}function rj(e){return/^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9-]+\.(videoji\.(hk|cn)|vimeo\.work)))\/video\/\d+/.test(e)}function ij(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 aj(){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(tj(r))return`https://vimeo.com/${r}`;if(nj(r))return r.replace(`http:`,`https:`);throw TypeError(t?`“${t}” is not a valid video id.`:`“${r}” is not a vimeo.com url.`)}var oj=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 sj(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 cj=Array.prototype.indexOf!==void 0,lj=typeof window<`u`&&window.postMessage!==void 0;if(!QA&&(!cj||!lj))throw Error(`Sorry, the Vimeo Player API is not available in this browser.`);var uj=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function dj(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:uj);var fj=dj(function(e){(function(t,n,r){n[t]=n[t]||r(),e.exports&&=n[t]})(`Promise`,uj,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})}),pj=new WeakMap;function mj(e,t,n){let r=pj.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),pj.set(e.element,r)}function hj(e,t){return(pj.get(e.element)||{})[t]||[]}function gj(e,t,n){let r=pj.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],pj.set(e.element,r),!0;let i=r[t].indexOf(n);return i!==-1&&r[t].splice(i,1),pj.set(e.element,r),r[t]&&r[t].length===0}function _j(e,t){let n=hj(e,t);if(n.length<1)return!1;let r=n.shift();return gj(e,t,r),r}function vj(e,t){let n=pj.get(e);pj.set(t,n),pj.delete(e)}function yj(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch(e){return console.warn(e),{}}return e}function bj(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 xj(e,t){t=yj(t);let n=[],r;if(t.event)t.event===`error`&&hj(e,t.data.method).forEach(n=>{let r=Error(t.data.message);r.name=t.data.name,n.reject(r),gj(e,t.data.method,n)}),n=hj(e,`event:${t.event}`),r=t.data;else if(t.method){let i=_j(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 Sj=`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 Cj(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Sj.reduce((t,n)=>{let r=e.getAttribute(`data-vimeo-${n}`);return(r||r===``)&&(t[n]=r===``?1:r),t},t)}function wj(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 Tj(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(!nj(e))throw TypeError(`“${e}” is not a vimeo.com url.`);let a=`https://${ij(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){wj(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 Ej(){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=Cj(e);Tj(aj(t),t,e).then(t=>wj(t,e)).catch(n)}catch(e){n(e)}})}function Dj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoPlayerResizeEmbeds_||(window.VimeoPlayerResizeEmbeds_=!0,window.addEventListener(`message`,t=>{if(!nj(t.origin)||!t.data||t.data.event!==`spacechange`)return;let n=t.source?sj(t.source,e):null;if(n){let e=n.parentElement;e.style.paddingBottom=`${t.data.data[0].bottom}px`}}))}function Oj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener(`message`,t=>{if(!nj(t.origin))return;let n=yj(t.data);if(!n||n.event!==`ready`)return;let r=t.source?sj(t.source,e):null;r&&rj(r.src)&&new Lj(r).callMethod(`appendVideoMetadata`,window.location.href)}))}function kj(){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(!nj(n.origin))return;let r=yj(n.data);if(!r||r.event!==`ready`)return;let i=n.source?sj(n.source,e):null;if(i&&rj(i.src)){let e=new Lj(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 Aj(){window.VimeoDRMEmbedsUpdated||(window.VimeoDRMEmbedsUpdated=!0,window.addEventListener(`message`,e=>{if(!nj(e.origin))return;let t=yj(e.data);if(!t||t.event!==`drminitfailed`)return;let n=e.source?sj(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 jj(){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 Mj={role:`viewer`,autoPlayMuted:!0,allowedDrift:.3,maxAllowedDrift:1,minCheckInterval:.1,maxRateAdjustment:.2,maxTimeToCatchUp:1},Nj=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,{...Mj,...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=oj(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=oj(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()})}},Pj=new WeakMap,Fj=new WeakMap,Ij={},Lj=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)),!ej(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`&&!nj(e.getAttribute(`src`)||``))throw Error(`The player element passed isn’t a Vimeo embed.`);if(Pj.has(e))return Pj.get(e);this._window=e.ownerDocument.defaultView,this.element=e,this.origin=`*`;let n=new fj((n,r)=>{if(this._onMessage=e=>{if(!nj(e.origin)||this.element.contentWindow!==e.source)return;this.origin===`*`&&(this.origin=e.origin);let t=yj(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}xj(this,t)},this._window.addEventListener(`message`,this._onMessage),this.element.nodeName!==`IFRAME`){let n=Cj(e,t);Tj(aj(n),n,e).then(t=>{let n=wj(t,e);return this.element=n,this._originalElement=e,vj(e,n),Pj.set(this.element,this),t}).catch(r)}});if(Fj.set(this,n),Pj.set(this.element,this),this.element.nodeName===`IFRAME`&&bj(this,`ping`),Ij.isEnabled){let e=()=>Ij.exit();this.fullscreenchangeHandler=()=>{Ij.isFullscreen?mj(this,`event:exitFullscreen`,e):gj(this,`event:exitFullscreen`,e),this.ready().then(()=>{bj(this,`fullscreenchange`,Ij.isFullscreen)})},Ij.on(`fullscreenchange`,this.fullscreenchangeHandler)}return this}static isVimeoUrl(e){return nj(e)}callMethod(e){var t=[...arguments].slice(1);if(e==null)throw TypeError(`You must pass a method name.`);return new fj((n,r)=>this.ready().then(()=>{mj(this,e,{resolve:n,reject:r}),t.length===0?t={}:t.length===1&&(t=t[0]),bj(this,e,t)}).catch(r))}get(e){return new fj((t,n)=>(e=$A(e,`get`),this.ready().then(()=>{mj(this,e,{resolve:t,reject:n}),bj(this,e)}).catch(n)))}set(e,t){return new fj((n,r)=>{if(e=$A(e,`set`),t==null)throw TypeError(`There must be a value to set.`);return this.ready().then(()=>{mj(this,e,{resolve:n,reject:r}),bj(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.`);hj(this,`event:${e}`).length===0&&this.callMethod(`addEventListener`,e).catch(()=>{}),mj(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.`);gj(this,`event:${e}`,t)&&this.callMethod(`removeEventListener`,e).catch(e=>{})}loadVideo(e){return this.callMethod(`loadVideo`,e)}ready(){let e=Fj.get(this)||new fj((e,t)=>{t(Error(`Unknown player. Probably unloaded.`))});return fj.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 Ij.isEnabled?Ij.request(this.element):this.callMethod(`requestFullscreen`)}exitFullscreen(){return Ij.isEnabled?Ij.exit():this.callMethod(`exitFullscreen`)}getFullscreen(){return Ij.isEnabled?fj.resolve(Ij.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 fj(e=>{if(Fj.delete(this),Pj.delete(this.element),this._originalElement&&(Pj.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),Ij.isEnabled&&Ij.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 fj.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 fj((e,t)=>t(TypeError(`Argument must be an array.`)));let t=new fj(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 fj.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 Nj(this,e,t);return bj(this,`notifyTimingObjectConnect`),n.addEventListener(`disconnect`,()=>bj(this,`notifyTimingObjectDisconnect`)),n}};QA||(Ij=jj(),Ej(),Dj(),Oj(),kj(),Aj());function Rj(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,zj(e,t)}function zj(e,t){return zj=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},zj(e,t)}var Bj={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`},Vj=function(e){function t(t){var n=e.call(this,t)||this;return n.refContainer=n.refContainer.bind(n),n}Rj(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 Lj(this.container,this.getInitialOptions()),Object.keys(Bj).forEach(function(t){var n=Bj[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 Y.createElement(`div`,{id:t,className:n,style:r,ref:this.refContainer})},t}(Y.Component);Vj.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 Hj={default:120,mqdefault:320,hqdefault:480,sddefault:640,maxresdefault:1280},Uj=(e,t,n,r=`maxresdefault`)=>{let[i,a]=(0,Y.useState)(``);return(0,Y.useEffect)(()=>{let i=`https://img.youtube.com/${t}/${e}/${r}.${n}`,o=`https://img.youtube.com/${t}/${e}/hqdefault.${n}`,s=Hj[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 Wj(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 Gj(e,t){let[n,r]=Y.useState(!1),[i,a]=Y.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=Y.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=Y.useMemo(()=>e.cookie?`https://www.youtube.com`:`https://www.youtube-nocookie.com`,[e.cookie]),m=Y.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?Uj(e.id,_,g,l):null,y=Y.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=Y.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 Y.useEffect(()=>{i&&(D(),e.focusOnLoad&&typeof t==`object`&&t?.current&&t.current.focus())},[i,D,e.focusOnLoad,t]),Y.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,X.jsxs)(X.Fragment,{children:[!e.lazyLoad&&(0,X.jsx)(`link`,{rel:O,href:y,as:`image`}),(0,X.jsx)(X.Fragment,{children:n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:p}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://www.google.com`}),x&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://static.doubleclick.net`}),(0,X.jsx)(`link`,{rel:`preconnect`,href:`https://googleads.g.doubleclick.net`})]})]})}),e.seo&&!e.playlist&&(0,X.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:Wj(e.id,c,y,p,e.seo)}}),A&&!e.playlist&&(0,X.jsx)(`noscript`,{children:(0,X.jsxs)(`a`,{href:`https://www.youtube.com/watch?v=${e.id}`,"aria-label":`Watch ${c} on YouTube`,children:[`Watch "`,c,`" on YouTube`]})}),(0,X.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,X.jsx)(`img`,{src:y,alt:`${c} - YouTube thumbnail`,className:`lty-thumbnail`,loading:`lazy`}),e.playlist&&!i&&(0,X.jsx)(`div`,{className:`lty-playlist-icon`,"aria-hidden":`true`}),!(e.hideButtonOnActivate&&i)&&(0,X.jsx)(`button`,{type:`button`,className:T,"aria-label":`${u} ${c}`,"aria-hidden":i||void 0,tabIndex:i?-1:0,onClick:M,children:(0,X.jsx)(`span`,{className:`lty-visually-hidden`,children:u})}),i&&(0,X.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 Kj=Y.forwardRef(Gj);function qj(e){return e!==!1}function Jj(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 Yj(e){if(e.width!==void 0)return{width:e.width}}function Xj(e){if(!(e.width===void 0||e.height===void 0))return{aspectRatio:`${e.width} / ${e.height}`}}function Zj(e){let t=(0,J.c)(23),n=(0,Y.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,Y.useEffect)(o,s);let c;t[5]===e?c=t[6]:(c=Yj(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,X.jsx)(Vj,{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,X.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 Qj(e){let t=(0,J.c)(17),n;t[0]===e.src?n=t[1]:(n=bn(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=Yj(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,X.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,X.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 $j(e){let t=(0,J.c)(29);if(e.src!==void 0&&ke(e.src)){let n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(Qj,{...e,src:e.src}),t[0]=e,t[1]=n),n}if(e.src!==void 0&&m(e.src)){let n;return t[2]===e?n=t[3]:(n=(0,X.jsx)(Zj,{...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:M(e.src);if(r!==null){let i=e.autoplay===!0&&e.muted===!0,a=e.width!==void 0&&e.height!==void 0,o=Yj(e),s;t[6]===e.poster?s=t[7]:(s=e.poster===void 0?void 0:Re(e.poster),t[6]=e.poster,t[7]=s);let c=(0,X.jsx)(Kj,{id:r.id,title:e.title??`YouTube video player`,cookie:!r.noCookie,params:Jj(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:Xj(e)}),l;t[8]!==o||t[9]!==c?(l=(0,X.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:Re(e.src),t[11]=e.src,t[12]=r);let i=e.title,a;t[13]===e.controls?a=t[14]:(a=qj(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:Re(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,X.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 eM(e){let t=(0,J.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,X.jsx)(`div`,{className:`prose-no-margin`,children:e.children}),t[0]=e.children,t[1]=n),n}var tM={Callout:ik,img:eA,video:$j,audio:$O,Pdf:PA,File:_k,Embed:hk,Accordion:ZO,Tabs:GA,Tab:VA,Math:rA,MermaidFence:oA,Mirror:bA,MirrorSource:xA,"*":eM};function nM(e){let t=new Set;for(let n of e)n.type===`reactnode`&&t.add(n.name);return t}var rM=ne(),iM=new Map;function aM(e){if(e.surface===`compat`){let t=tM[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:nM(e.props)}}let t=tM[e.name];return t?{Component:t,reactNodePropNames:nM(e.props)}:null}for(let[e,t]of rM.entries()){let n=aM(t);n&&iM.set(e,n)}function oM(e,t){return{...e,Component:t.Component,reactNodePropNames:t.reactNodePropNames}}function sM(e){let t=rM.getOrWildcard(e),n=iM.get(t.name)??iM.get(`*`);if(!n)throw Error(`No React component registered for ${t.name} (and no '*' wildcard)`);return oM(t,n)}function cM(){let e=[];for(let[t,n]of rM.entries()){if(t===`*`)continue;let r=iM.get(t);r&&e.push(oM(n,r))}return e}var lM=``+new URL(`image-preview-BJSGEOo4.png`,import.meta.url).href,uM=``+new URL(`video-preview-vLovc_Vy.png`,import.meta.url).href,dM={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:lM,alt:`Sample image`}},video:{description:{id:`e1hptq`},props:{controls:!0,poster:uM}},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,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.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,X.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1.5 w-full rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-5/6 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]})]})},Pdf:{description:{id:`Fqr8BP`},render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/40 px-1.5 py-1`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 text-muted-foreground`,"aria-hidden":`true`,children:[(0,X.jsx)(`title`,{children:`Thumbnails`}),(0,X.jsx)(`rect`,{x:`1`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`1`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`1`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`}),(0,X.jsx)(`rect`,{x:`7`,y:`7`,width:`4`,height:`4`,fill:`currentColor`,rx:`0.5`})]}),(0,X.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5 font-mono`,children:`2`}),(0,X.jsx)(`span`,{children:`/ 12`})]}),(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-[10px] font-mono text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`−`}),(0,X.jsx)(`span`,{children:`100%`}),(0,X.jsx)(`span`,{className:`rounded-sm bg-background px-1 py-0.5`,children:`+`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 gap-1 p-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex w-6 flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm border border-foreground/60 bg-background`}),(0,X.jsx)(`span`,{className:`h-3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 rounded-sm bg-background p-1.5`,children:[(0,X.jsx)(`span`,{className:`h-1.5 w-1/2 rounded-sm bg-foreground/50`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-5/6 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-full rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`h-1 w-2/3 rounded-sm bg-muted-foreground/30`})]})]})]})},MermaidFence:{description:{id:`z0a2EA`},render:()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 200 120`,className:`h-full w-full text-foreground`,"aria-hidden":`true`,preserveAspectRatio:`xMidYMid meet`,children:[(0,X.jsx)(`title`,{children:`Mermaid flowchart preview`}),(0,X.jsx)(`defs`,{children:(0,X.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,X.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`currentColor`})})}),(0,X.jsx)(`rect`,{x:`14`,y:`20`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`42`,y:`38`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Start`}),(0,X.jsx)(`polygon`,{points:`100,18 140,50 100,82 60,50`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`100`,y:`54`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`Ready?`}),(0,X.jsx)(`rect`,{x:`130`,y:`84`,width:`56`,height:`28`,rx:`14`,fill:`currentColor`,fillOpacity:`0.1`,stroke:`currentColor`,strokeOpacity:`0.7`}),(0,X.jsx)(`text`,{x:`158`,y:`102`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`End`}),(0,X.jsx)(`line`,{x1:`70`,y1:`34`,x2:`80`,y2:`40`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`line`,{x1:`124`,y1:`62`,x2:`138`,y2:`82`,stroke:`currentColor`,strokeOpacity:`0.7`,strokeWidth:`1.2`,markerEnd:`url(#mermaid-preview-arrow)`}),(0,X.jsx)(`text`,{x:`138`,y:`74`,fontSize:`8`,fill:`currentColor`,opacity:`0.6`,children:`yes`})]})},Tabs:{description:{id:`75Y1dk`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex gap-1 border-b border-border pb-1`,children:[(0,X.jsx)(`span`,{className:`rounded-md bg-foreground/10 px-2 py-0.5 text-xs font-medium text-foreground`,children:`Tab 1`}),(0,X.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs text-muted-foreground`,children:`Tab 2`})]}),(0,X.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:(0,X.jsx)(o,{id:`m6YGpY`})})]})},Mirror:{description:{id:`8TLE9g`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/40 px-2 py-1.5`,children:[(0,X.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,X.jsx)($i,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`EL_YRd`,components:{0:(0,X.jsx)(`code`,{className:`font-mono`})}})})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-3/4 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-2/3 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,X.jsx)(o,{id:`qNOgUu`})})]})},MirrorSource:{description:{id:`-KCZ6n`},render:()=>(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`relative rounded-md border border-dashed border-border/50 px-2 py-1.5`,children:[(0,X.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,X.jsx)(Xi,{className:`size-2.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`maDWIB`,components:{0:(0,X.jsx)(`code`,{className:`font-mono`})}})})]}),(0,X.jsx)(`span`,{className:`block h-1.5 w-4/5 rounded-sm bg-muted-foreground/30`}),(0,X.jsx)(`span`,{className:`mt-1 block h-1.5 w-3/5 rounded-sm bg-muted-foreground/20`})]}),(0,X.jsx)(`p`,{className:`px-1 text-[10px] text-muted-foreground`,children:(0,X.jsx)(o,{id:`emgiet`})})]})}};function fM(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 pM(e){let t=sM(e),n=fM(t);return{type:`jsxComponent`,attrs:{componentName:t.name,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!0,props:n},content:t.hasChildren?[{type:`paragraph`}]:void 0}}var mM=new Set;function hM(e){mM.add(e)}function gM(e){if(typeof e==`number`)return mM.delete(e);let t=mM.values().next();return t.done?!1:(mM.delete(t.value),!0)}function _M(e,t,n){n.props.some(e=>!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`)?(hM(t),requestAnimationFrame(()=>{e.commands.setNodeSelection(t)})):n.hasChildren&&e.commands.setTextSelection(t+2)}function vM(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=pM(e.name);if(e.name===`Tabs`){let e=pM(`Tab`),t=pM(`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)&&_M(t,i,e)}}var yM=new Set([`File`,`Tab`]);function bM(){return[{name:`component-File`,label:G._({id:`J2eKUI`}),icon:ia,category:`media`,aliases:[`file`,`attachment`,`download`,`upload`,`document`,`doc`,`docx`,`zip`],description:"Attach a downloadable file (`.pdf` / `.docx` / `.zip` / …)",command:SM,preview:{description:G._({id:`t-JXbf`}),render:()=>(0,X.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5`,children:[(0,X.jsx)(ia,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:`quarterly-report.pdf`}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`1.4 MB`})]})}}]}function xM(){return[...cM().filter(e=>e.surface===`canonical`&&!yM.has(e.name)).map(e=>{let t=dM[e.name],n=e.Component,r=t?{description:G._(t.description),render:t.render??(()=>(0,X.jsx)(n,{...t.props,children:t.children}))}:void 0;return{name:`component-${e.name}`,label:e.displayName??e.name,icon:qO(e.icon),category:e.category??`content`,command:vM(e),aliases:e.searchTerms,description:e.description,preview:r}}),...bM()]}function SM(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;xO(n,e,t)}t.remove()},{once:!0}),t.addEventListener(`cancel`,()=>t.remove(),{once:!0}),document.body.appendChild(t),t.click()}function CM(e,t){let n=EO.getState(e.state);if(!n)return null;for(let e of n.byId.values())if(e.markType===`link`&&e.from<=t&&t<e.to)return e.id;return null}function wM(){return[{name:`link`,label:G._({id:`yzF66j`}),icon:xa,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:G._({id:`5WDhAk`}),render:()=>(0,X.jsx)(`p`,{className:`leading-7 text-sm`,children:(0,X.jsx)(o,{id:`u-9fWA`,components:{0:(0,X.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=CM(e,t);n&&(wO(n),requestAnimationFrame(()=>{GO(e).setActiveNode(n)}))}},{name:`component-Tag`,label:G._({id:`UL8A9w`}),icon:ua,category:`content`,aliases:[`#`,`hashtag`,`label`],description:"Inline tag (`#tagname`) for cross-doc linking",preview:{description:G._({id:`5ClEAu`}),render:()=>(0,X.jsx)(`p`,{className:`text-sm leading-7`,children:(0,X.jsx)(o,{id:`KZLdgR`,components:{0:(0,X.jsx)(`a`,{className:`tag pointer-events-none`})}})})},command:e=>{e.chain().insertTag(``).run()}}]}function TM(e,t){e.chain().focus().insertContent({type:`codeBlock`,attrs:{language:`html`,meta:`preview`},content:[{type:`text`,text:t}]}).run()}var EM=`<div style="padding:20px;font-family:system-ui,sans-serif;color:var(--foreground)">
|
|
7
7
|
<h1 style="margin:0 0 8px;font-size:20px;font-weight:600">Hello, world!</h1>
|
|
8
8
|
<p style="margin:0;color:var(--muted-foreground)">Edit this HTML — the preview updates live.</p>
|
|
9
9
|
</div>`,DM={chart:{icon:Vi,aliases:[`chart`,`bar`,`graph`,`plot`,`viz`,`data`,`embed`,`preview`],render:()=>(0,X.jsxs)(`div`,{className:`flex h-20 items-end gap-1.5`,children:[(0,X.jsx)(`div`,{className:`h-[45%] flex-1 rounded-t-sm bg-chart-1`}),(0,X.jsx)(`div`,{className:`h-[70%] flex-1 rounded-t-sm bg-chart-2`}),(0,X.jsx)(`div`,{className:`h-[90%] flex-1 rounded-t-sm bg-chart-3`}),(0,X.jsx)(`div`,{className:`h-[60%] flex-1 rounded-t-sm bg-chart-4`}),(0,X.jsx)(`div`,{className:`h-[80%] flex-1 rounded-t-sm bg-chart-5`})]})},"stat-cards":{icon:ga,aliases:[`stat`,`stats`,`metric`,`metrics`,`cards`,`kpi`,`embed`,`preview`],render:()=>(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex-1 rounded-md border border-border bg-card p-2`,children:[(0,X.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Users`}),(0,X.jsx)(`div`,{className:`text-sm font-bold text-card-foreground`,children:`12.4k`}),(0,X.jsx)(`div`,{className:`text-[10px] font-semibold text-chart-2`,children:`+8.2%`})]}),(0,X.jsxs)(`div`,{className:`flex-1 rounded-md border border-border bg-card p-2`,children:[(0,X.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Revenue`}),(0,X.jsx)(`div`,{className:`text-sm font-bold text-card-foreground`,children:`$48k`}),(0,X.jsx)(`div`,{className:`text-[10px] font-semibold text-chart-1`,children:`+3.1%`})]})]})},"custom-svg":{icon:La,aliases:[`svg`,`vector`,`graphic`,`illustration`,`ring`,`embed`,`preview`],render:()=>(0,X.jsx)(`div`,{className:`flex items-center justify-center text-chart-1`,children:(0,X.jsxs)(`svg`,{width:`72`,height:`72`,viewBox:`0 0 72 72`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{cx:`36`,cy:`36`,r:`28`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.15`,strokeWidth:`9`}),(0,X.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:za,aliases:[`interactive`,`slider`,`control`,`widget`,`input`,`embed`,`preview`],render:()=>(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-lg font-bold text-chart-1`,children:`$2,500`}),(0,X.jsxs)(`div`,{className:`relative h-1.5 rounded-full bg-muted`,children:[(0,X.jsx)(`div`,{className:`absolute inset-y-0 left-0 w-1/3 rounded-full bg-primary`}),(0,X.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,X.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Drag to adjust`})]})}};function OM(){return{name:`embed-starter-html`,label:G._({id:`FBknns`}),icon:Yi,category:`embed`,aliases:[`html`,`embed`,`preview`,`iframe`,`sandbox`,`web`,`snippet`],description:G._({id:`4niEzY`}),command:e=>TM(e,EM),preview:{description:G._({id:`rageVb`}),render:()=>(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border bg-muted/40 px-2 py-1.5`,children:[(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`}),(0,X.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,X.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center gap-1.5 px-3 py-3`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground text-sm`,children:(0,X.jsx)(o,{id:`3HNlwb`})}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:(0,X.jsx)(o,{id:`bH382I`})})]})]})}}}function kM(){let e=ze.map(e=>{let t=DM[e.id];return{name:`embed-starter-${e.id}`,label:e.title,icon:t.icon,category:`embed`,command:t=>TM(t,e.html),aliases:t.aliases,description:e.description,preview:{description:e.description,render:t.render}}});return[OM(),...e]}function AM(){return[{name:`heading1`,label:G._({id:`lXKZGw`}),icon:da,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:1}).run(),aliases:[`h1`],preview:{description:G._({id:`3J7d2N`}),render:()=>(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:(0,X.jsx)(o,{id:`lXKZGw`})})}},{name:`heading2`,label:G._({id:`El7NbA`}),icon:fa,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:2}).run(),aliases:[`h2`],preview:{description:G._({id:`LXdWeS`}),render:()=>(0,X.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:(0,X.jsx)(o,{id:`El7NbA`})})}},{name:`heading3`,label:G._({id:`SFN6dN`}),icon:pa,category:`basic`,command:e=>e.chain().focus().toggleHeading({level:3}).run(),aliases:[`h3`],preview:{description:G._({id:`g4XBm0`}),render:()=>(0,X.jsx)(`h3`,{className:`text-base font-semibold tracking-tight`,children:(0,X.jsx)(o,{id:`SFN6dN`})})}},{name:`bulletList`,label:G._({id:`s1c0ja`}),icon:wa,category:`basic`,command:e=>e.chain().focus().toggleBulletList().run(),aliases:[`ul`,`unordered`],preview:{description:G._({id:`fYjgXu`}),render:()=>(0,X.jsxs)(`ul`,{className:`list-disc pl-5 text-sm leading-7`,children:[(0,X.jsx)(`li`,{children:(0,X.jsx)(o,{id:`FCxvG5`})}),(0,X.jsx)(`li`,{children:(0,X.jsx)(o,{id:`saIASg`})})]})}},{name:`orderedList`,label:G._({id:`Uci-Ph`}),icon:Sa,category:`basic`,command:e=>e.chain().focus().toggleOrderedList().run(),aliases:[`ol`,`numbered`],preview:{description:G._({id:`rXz97P`}),render:()=>(0,X.jsxs)(`ol`,{className:`list-decimal pl-5 text-sm leading-7`,children:[(0,X.jsx)(`li`,{children:(0,X.jsx)(o,{id:`FCxvG5`})}),(0,X.jsx)(`li`,{children:(0,X.jsx)(o,{id:`saIASg`})})]})}},{name:`taskList`,label:G._({id:`G_686w`}),icon:Ca,category:`basic`,command:e=>e.chain().focus().toggleTaskList().run(),aliases:[`todo`,`checklist`,`checkbox`],preview:{description:G._({id:`yutJKi`}),render:()=>(0,X.jsxs)(`ul`,{className:`space-y-1.5 text-sm`,children:[(0,X.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!0,readOnly:!0,className:`size-3.5`}),(0,X.jsx)(`span`,{className:`text-muted-foreground line-through`,children:(0,X.jsx)(o,{id:`DPfwMq`})})]}),(0,X.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,readOnly:!0,className:`size-3.5`}),(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`rZ9HZq`})})]})]})}},{name:`blockquote`,label:G._({id:`ZhhOwV`}),icon:Pa,category:`basic`,command:e=>e.chain().focus().toggleBlockquote().run(),aliases:[`quote`],preview:{description:G._({id:`w7nm4K`}),render:()=>(0,X.jsx)(`blockquote`,{className:`border-l-2 border-muted-foreground/40 pl-3 text-sm italic text-muted-foreground`,children:(0,X.jsx)(o,{id:`74-bX-`})})}},{name:`codeBlock`,label:G._({id:`N2eHWq`}),icon:Ji,category:`basic`,command:e=>e.chain().focus().toggleCodeBlock({language:`js`}).run(),aliases:[`code`,`fence`],preview:{description:G._({id:`XpIZmv`}),render:()=>(0,X.jsx)(`pre`,{className:`rounded-md bg-muted px-2.5 py-2 font-mono text-xs leading-5`,children:(0,X.jsx)(`code`,{children:`const greeting = "Hello";
|
|
@@ -58,4 +58,4 @@ body{background:var(--background);color:var(--foreground)}
|
|
|
58
58
|
</style>`}function ZZ(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.${UZ};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({${GZ}: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();}})();<\/script>`}function QZ(e){switch(e){case`cdn-allowlist`:return`script-src 'unsafe-inline' ${qZ.join(` `)}`;case`inline-only`:return`script-src 'unsafe-inline'`;default:throw Error(`Unhandled preview script-src policy: ${JSON.stringify(e)}`)}}function $Z(e,t){return`<meta http-equiv="Content-Security-Policy" content="${`default-src 'none'; ${QZ(e)}; style-src 'unsafe-inline' data:; img-src data:; font-src data:; connect-src 'none'; frame-src 'none'; child-src 'none'; form-action 'none'; base-uri 'none';`}">
|
|
59
59
|
${XZ()}
|
|
60
60
|
${JZ}
|
|
61
|
-
${ZZ(t)}`}var eQ=`plaintext`;function tQ(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?`dark`:`light`}function nQ(e,t){let n=(0,J.c)(4),[r,i]=(0,Y.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,Y.useEffect)(a,o),r}function rQ(e){let t=(0,J.c)(172),{node:n,updateAttributes:r,editor:a,getPos:s,selected:c}=e,{_:l}=i(),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(null),[_,v]=(0,Y.useState)(null),{resolvedTheme:y}=Qt(),b;t[0]===y?b=t[1]:(b=y===`dark`||y===`light`?y:tQ(),t[0]=y,t[1]=b);let x=b,[S]=(0,Y.useState)(tQ),{merged:C}=iF(),w=C?.preview?.scriptSrc??`cdn-allowlist`,T=n.attrs.language??null,E=n.attrs.meta??null,D;t[2]===E?D=t[3]:(D=BZ(E),t[2]=E,t[3]=D);let O=D,[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),N=(0,Y.useId)(),P=`${N}-title-input`,F=`${N}-title-help`,I=(0,Y.useRef)(E),L,ee;t[4]===E?(L=t[5],ee=t[6]):(L=()=>{I.current=E},ee=[E],t[4]=E,t[5]=L,t[6]=ee),(0,Y.useEffect)(L,ee);let R,z,te,B,ne;if(t[7]!==l||t[8]!==T||t[9]!==E){z=CZ(T),R=T?xZ.find(e=>e.value===z)?.label??T:l({id:`LpB85N`});let e;t[15]===E?e=t[16]:(e=DZ(E,`preview`),t[15]=E,t[16]=e),B=e,te=z?AZ.has(z):!1,ne=jZ(z,E),t[7]=l,t[8]=T,t[9]=E,t[10]=R,t[11]=z,t[12]=te,t[13]=B,t[14]=ne}else R=t[10],z=t[11],te=t[12],B=t[13],ne=t[14];let V=ne,re;t[17]!==V||t[18]!==E?(re=V?IZ(E):null,t[17]=V,t[18]=E,t[19]=re):re=t[19];let ie=re,H;t[20]!==V||t[21]!==E?(H=V?LZ(E):null,t[20]=V,t[21]=E,t[22]=H):H=t[22];let ae=H,oe=ie??(_===null?void 0:`${_}px`),U=!V,se,ce;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>()=>{m.current!==null&&window.clearTimeout(m.current)},ce=[],t[23]=se,t[24]=ce):(se=t[23],ce=t[24]),(0,Y.useEffect)(se,ce);let W=a.isEditable,le=nQ(a,s),ue,de;t[25]===x?(ue=t[26],de=t[27]):(ue=()=>{g.current?.contentWindow?.postMessage(WZ(x),`*`)},de=[x],t[25]=x,t[26]=ue,t[27]=de),(0,Y.useEffect)(ue,de);let fe,pe;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>{let e=function(e){if(e.source!==g.current?.contentWindow)return;let t=KZ(e.data);t!==null&&v(e=>e!==null&&Math.abs(e-t)<=2?e:t)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},pe=[],t[28]=fe,t[29]=pe):(fe=t[28],pe=t[29]),(0,Y.useEffect)(fe,pe);let me;t[30]===n.textContent?me=t[31]:(me=()=>{let e=n.textContent,t=()=>{p(!0),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>p(!1),1200)};try{typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e).then(t,sQ)}catch{}},t[30]=n.textContent,t[31]=me);let he=me,ge;t[32]!==a||t[33]!==s?(ge=()=>{let e=typeof s==`function`?s():void 0;if(typeof e==`number`)try{a.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]=a,t[33]=s,t[34]=ge):ge=t[34];let _e=ge,ve;t[35]!==B||t[36]!==E||t[37]!==r?(ve=()=>{r({meta:B?kZ(E,`preview`):OZ(E,`preview`)})},t[35]=B,t[36]=E,t[37]=r,t[38]=ve):ve=t[38];let ye=ve,be;t[39]!==E||t[40]!==r?(be=e=>{let t=VZ(E,e.length>0?e:null);t!==E&&r({meta:t})},t[39]=E,t[40]=r,t[41]=be):be=t[41];let xe=be,Se;t[42]!==a.state||t[43]!==a.view||t[44]!==s||t[45]!==n.attrs||t[46]!==n.nodeSize||t[47]!==n.type?(Se=e=>{let t=typeof s==`function`?s():void 0;if(typeof t==`number`)try{let{schema:r,tr:i}=a.state,o=n.type.create(n.attrs,e.length>0?r.text(e):null);i.replaceWith(t,t+n.nodeSize,o),a.view.dispatch(i)}catch(e){let t=e;if(!(t instanceof RangeError))throw t;console.warn(`[CodeBlockView] edit-save failed — position race`,t)}},t[42]=a.state,t[43]=a.view,t[44]=s,t[45]=n.attrs,t[46]=n.nodeSize,t[47]=n.type,t[48]=Se):Se=t[48];let Ce=Se,we;t[49]===r?we=t[50]:(we=e=>{let t=`${Math.round(e.width)}px`,n=`${Math.round(e.height)}px`;r({meta:FZ(FZ(I.current,`h`,n),`w`,t)})},t[49]=r,t[50]=we);let Te=we,Ee=T??void 0,De=le?`true`:void 0,Oe=c?`true`:void 0,ke=V?`true`:void 0,Ae=U?`true`:`false`,je;t[51]!==l||t[52]!==x||t[53]!==S||t[54]!==U||t[55]!==oe||t[56]!==Te||t[57]!==n.textContent||t[58]!==V||t[59]!==w||t[60]!==ae?(je=V?(0,X.jsxs)(`div`,{ref:h,className:Sn(`ok-codeblock-preview`,U?`ok-codeblock-preview--with-code`:`ok-codeblock-preview--solo`),contentEditable:!1,style:{...oe?{height:oe}:{},...ae?{width:ae}:{}},onMouseDown:oQ,children:[(0,X.jsx)(`iframe`,{title:l({id:`G7cMuO`}),ref:g,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:$Z(w,S)+n.textContent,className:`ok-codeblock-preview-frame`,onLoad:()=>{g.current?.contentWindow?.postMessage(WZ(x),`*`)}}),(0,X.jsx)(lk,{targetRef:h,bounds:{minWidth:192,maxWidth:Math.round(window.innerWidth*.9),minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=h.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:Te})]}):null,t[51]=l,t[52]=x,t[53]=S,t[54]=U,t[55]=oe,t[56]=Te,t[57]=n.textContent,t[58]=V,t[59]=w,t[60]=ae,t[61]=je):je=t[61];let Me;t[62]===O?Me=t[63]:(Me=O?(0,X.jsx)(`div`,{className:`ok-codeblock-title`,contentEditable:!1,"data-testid":`ok-codeblock-title`,title:O,children:(0,X.jsx)(`span`,{className:`ok-codeblock-title-text`,children:O})}):null,t[62]=O,t[63]=Me);let Ne=V&&U?`rounded-b-lg`:null,Pe=V?null:`rounded-lg`,Fe;t[64]!==Ne||t[65]!==Pe?(Fe=Sn(`ok-codeblock-pre m-0 overflow-x-auto px-5 py-4 font-mono text-sm leading-relaxed`,Ne,Pe),t[64]=Ne,t[65]=Pe,t[66]=Fe):Fe=t[66];let Ie=!U||void 0,Le=T?`language-${T}`:void 0,G;t[67]===Le?G=t[68]:(G=Sn(`hljs block whitespace-pre bg-transparent p-0`,Le),t[67]=Le,t[68]=G);let Re;t[69]===G?Re=t[70]:(Re=(0,X.jsx)(Ql,{as:`code`,className:G}),t[69]=G,t[70]=Re);let ze;t[71]!==Fe||t[72]!==Ie||t[73]!==Re?(ze=(0,X.jsx)(`pre`,{className:Fe,"aria-hidden":Ie,children:Re}),t[71]=Fe,t[72]=Ie,t[73]=Re,t[74]=ze):ze=t[74];let Be;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(Be={[gF]:`true`},t[75]=Be):Be=t[75];let Ve=!W,He;t[76]!==l||t[77]!==R?(He=l({id:`c5f7sm`,values:{currentLabel:R}}),t[76]=l,t[77]=R,t[78]=He):He=t[78];let Ue;t[79]===R?Ue=t[80]:(Ue=(0,X.jsx)(`span`,{children:R}),t[79]=R,t[80]=Ue);let We;t[81]===W?We=t[82]:(We=W?(0,X.jsx)(Hi,{className:`size-3 opacity-60`,"aria-hidden":`true`}):null,t[81]=W,t[82]=We);let Ge;t[83]!==Ve||t[84]!==He||t[85]!==Ue||t[86]!==We?(Ge=(0,X.jsx)(wc,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,disabled:Ve,className:`ok-codeblock-chrome-btn ok-codeblock-chrome-lang`,"aria-label":He,children:[Ue,We]})}),t[83]=Ve,t[84]=He,t[85]=Ue,t[86]=We,t[87]=Ge):Ge=t[87];let Ke;t[88]===l?Ke=t[89]:(Ke=l({id:`G_mWXb`}),t[88]=l,t[89]=Ke);let qe;t[90]===Ke?qe=t[91]:(qe=(0,X.jsx)(px,{placeholder:Ke}),t[90]=Ke,t[91]=qe);let Je;t[92]===l?Je=t[93]:(Je=l({id:`ETyvvg`}),t[92]=l,t[93]=Je);let Ye;t[94]===Je?Ye=t[95]:(Ye=(0,X.jsx)(hx,{children:Je}),t[94]=Je,t[95]=Ye);let Xe;t[96]!==a.commands||t[97]!==z||t[98]!==T||t[99]!==r?(Xe=xZ.map(e=>{let t=e.value===eQ?!T||z===eQ:z===e.value;return(0,X.jsxs)(_x,{value:`${e.label} ${e.value} ${e.aliases?.join(` `)??``}`,onSelect:()=>{r({language:e.value===eQ?null:e.value}),d(!1),a.commands.focus()},children:[(0,X.jsx)(`span`,{className:`flex-1`,children:e.label}),t?(0,X.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`}):null]},e.value)}),t[96]=a.commands,t[97]=z,t[98]=T,t[99]=r,t[100]=Xe):Xe=t[100];let Ze;t[101]===Xe?Ze=t[102]:(Ze=(0,X.jsx)(gx,{children:Xe}),t[101]=Xe,t[102]=Ze);let Qe;t[103]!==Ye||t[104]!==Ze?(Qe=(0,X.jsxs)(mx,{children:[Ye,Ze]}),t[103]=Ye,t[104]=Ze,t[105]=Qe):Qe=t[105];let $e;t[106]!==qe||t[107]!==Qe?($e=(0,X.jsx)(Tc,{align:`end`,sideOffset:6,className:`w-56 p-0`,children:(0,X.jsxs)(dx,{filter:iQ,children:[qe,Qe]})}),t[106]=qe,t[107]=Qe,t[108]=$e):$e=t[108];let et;t[109]!==u||t[110]!==Ge||t[111]!==$e?(et=(0,X.jsxs)(Cc,{open:u,onOpenChange:d,children:[Ge,$e]}),t[109]=u,t[110]=Ge,t[111]=$e,t[112]=et):et=t[112];let tt;t[113]!==l||t[114]!==W||t[115]!==V?(tt=W&&V?(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":l({id:`R3y75Z`}),"data-testid":`ok-codeblock-edit-btn`,onClick:()=>M(!0),children:(0,X.jsx)(Ma,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[113]=l,t[114]=W,t[115]=V,t[116]=tt):tt=t[116];let nt;t[117]!==l||t[118]!==W||t[119]!==ye||t[120]!==te||t[121]!==B?(nt=W&&te?(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"data-active":B?`true`:void 0,"aria-pressed":B,"aria-label":l(B?{id:`xHGM4U`}:{id:`7OwvEL`}),onClick:ye,children:B?(0,X.jsx)(ea,{className:`size-3.5`}):(0,X.jsx)(ta,{className:`size-3.5`})}):null,t[117]=l,t[118]=W,t[119]=ye,t[120]=te,t[121]=B,t[122]=nt):nt=t[122];let rt;t[123]!==l||t[124]!==W||t[125]!==xe||t[126]!==k||t[127]!==O||t[128]!==F||t[129]!==P?(rt=W?(0,X.jsxs)(Cc,{open:k,onOpenChange:A,children:[(0,X.jsx)(wc,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"data-active":O?`true`:void 0,"aria-label":l({id:`DDTdLl`}),children:(0,X.jsx)(Ia,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(Tc,{align:`end`,sideOffset:6,className:`w-64 p-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:P,className:`text-2xs font-mono uppercase tracking-wide text-muted-foreground`,children:(0,X.jsx)(o,{id:`MHrjPM`})}),(0,X.jsx)(cr,{id:P,type:`text`,value:O??``,placeholder:l({id:`mk2poV`}),"data-testid":`ok-codeblock-title-input`,"aria-describedby":F,onChange:e=>xe(e.target.value),onKeyDown:e=>{(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),A(!1))},className:`h-8`}),(0,X.jsx)(`p`,{id:F,className:`text-2xs text-muted-foreground`,children:(0,X.jsx)(o,{id:`lond3p`})})]})})]}):null,t[123]=l,t[124]=W,t[125]=xe,t[126]=k,t[127]=O,t[128]=F,t[129]=P,t[130]=rt):rt=t[130];let it;t[131]!==l||t[132]!==f?(it=l(f?{id:`6V3Ea3`}:{id:`NmPNJJ`}),t[131]=l,t[132]=f,t[133]=it):it=t[133];let at;t[134]===f?at=t[135]:(at=f?(0,X.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`}):(0,X.jsx)(Zi,{className:`size-3.5`,"aria-hidden":`true`}),t[134]=f,t[135]=at);let ot;t[136]!==he||t[137]!==it||t[138]!==at?(ot=(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":it,onClick:he,children:at}),t[136]=he,t[137]=it,t[138]=at,t[139]=ot):ot=t[139];let st;t[140]!==l||t[141]!==W||t[142]!==_e?(st=W?(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn ok-codeblock-chrome-btn--delete`,"aria-label":l({id:`oBXkm2`}),onClick:_e,children:(0,X.jsx)(Ka,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[140]=l,t[141]=W,t[142]=_e,t[143]=st):st=t[143];let ct;t[144]!==et||t[145]!==tt||t[146]!==nt||t[147]!==rt||t[148]!==ot||t[149]!==st?(ct=(0,X.jsxs)(`div`,{className:`ok-codeblock-chrome`,contentEditable:!1,onMouseDown:aQ,...Be,children:[et,tt,nt,rt,ot,st]}),t[144]=et,t[145]=tt,t[146]=nt,t[147]=rt,t[148]=ot,t[149]=st,t[150]=ct):ct=t[150];let lt;t[151]!==l||t[152]!==S||t[153]!==j||t[154]!==W||t[155]!==Ce||t[156]!==n.textContent||t[157]!==z||t[158]!==V||t[159]!==w?(lt=W&&V?(0,X.jsx)(bZ,{open:j,onOpenChange:M,initialValue:n.textContent,language:z===`xml`?`html`:`plain`,title:l({id:`R3y75Z`}),renderPreview:e=>(0,X.jsx)(`iframe`,{title:l({id:`G7cMuO`}),sandbox:`allow-scripts`,className:`size-full border-0`,srcDoc:$Z(w,S)+e}),onSave:Ce}):null,t[151]=l,t[152]=S,t[153]=j,t[154]=W,t[155]=Ce,t[156]=n.textContent,t[157]=z,t[158]=V,t[159]=w,t[160]=lt):lt=t[160];let ut;return t[161]!==Ee||t[162]!==De||t[163]!==Oe||t[164]!==ke||t[165]!==Ae||t[166]!==je||t[167]!==Me||t[168]!==ze||t[169]!==ct||t[170]!==lt?(ut=(0,X.jsxs)($l,{className:`ok-codeblock relative my-3`,"data-language":Ee,"data-cursor-inside":De,"data-selected":Oe,"data-preview":ke,"data-code-visible":Ae,children:[je,Me,ze,ct,lt]}),t[161]=Ee,t[162]=De,t[163]=Oe,t[164]=ke,t[165]=Ae,t[166]=je,t[167]=Me,t[168]=ze,t[169]=ct,t[170]=lt,t[171]=ut):ut=t[171],ut}function iQ(e,t){return t?+!!e.toLowerCase().includes(t.toLowerCase()):1}function aQ(e){return e.stopPropagation()}function oQ(e){return e.stopPropagation()}function sQ(){}function cQ(e,t=[]){return e.flatMap(e=>{if(e.type===`text`)return[{text:e.value,classes:t}];let n=[...t,...e.properties?.className??[]];return cQ(e.children,n)})}function lQ(e){let{doc:t,name:n,lowlight:r,defaultLanguage:i}=e,a=[],o=r.listLanguages();return At(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 cQ(c)){let n=t+e.text.length;e.classes.length>0&&a.push(S.inline(t,n,{class:e.classes.join(` `)})),t=n}}),pe.create(t,a)}function uQ(e){let{name:t,lowlight:n,defaultLanguage:r}=e,i=new U({key:new W(`codeBlockLowlight`),state:{init:(e,{doc:i})=>lQ({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=At(a.doc,e=>e.type.name===t),u=At(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)})?lQ({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 dQ=tF(ZP),fQ=x.extend({addNodeView(){return su(rQ)},addProseMirrorPlugins(){return[...this.parent?.()??[],uQ({name:this.name,lowlight:dQ,defaultLanguage:null})]},addInputRules(){return[...this.parent?.()??[],T({find:/^```$/,type:this.type,getAttributes:()=>({language:`js`})})]}});function pQ(e){return!!e.getMeta(qv)}function mQ(e,t){let n=qv.getState(e);return Fy(n.doc,n.type,t,n.binding.mapping)||0}function hQ(e,t){let n=qv.getState(e);return Ny(t,n.type,n.binding.mapping)}var gQ=class e extends rn{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 _Q(e,t){return new gQ(e,hQ(t,e))}function vQ(e,t,n){let r=e instanceof gQ?e.yRelativePosition:null;if(pQ(t)&&r)return{position:new gQ(mQ(n,r),r),mapResult:null};let i=mn(e,t),a=i.position.position;return{position:new gQ(a,r??hQ(n,a)),mapResult:i.mapResult}}var yQ=Dt.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)=>vQ(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>_Q(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Jv.getState(t).undoManager.undoStack.length===0?!1:n?Uy(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Jv.getState(t).undoManager.redoStack.length===0?!1:n?Wy(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=qy(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let{undoManager:t}=Jv.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()}}},[ny(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new U({key:new W(`filterInvalidContent`),filterTransaction:t=>{if(!pQ(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 bQ(e){if(!e.length)return pe.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(S.node(n,n+r.nodeSize,{class:`ProseMirror-selectednoderange`}))}),pe.create(n,t)}function xQ(e,t,n){let r=n.isText||n.isAtom?0:1;return{start:e+r,end:e+t-r}}function SQ(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 g(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=xQ(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 D(a.resolve(l),a.resolve(u));i.push(p)}),i}var CQ=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 wQ(e.resolve(this.anchor),e.resolve(this.head))}},wQ=class e extends ge{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=SQ(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 CQ(this.anchor,this.head)}};wQ.prototype.visible=!1;function TQ(e){return e instanceof wQ}Dt.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(!TQ(a)){let e=wQ.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(!TQ(a)){let e=wQ.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=wQ.create(i,0,i.content.size,t);return a.setSelection(o),n.dispatch(a),!0}}},onSelectionUpdate(){let{selection:e}=this.editor.state;TQ(e)&&this.editor.view.dom.classList.add(`ProseMirror-noderangeselection`)},addProseMirrorPlugins(){let e=!1,t=!1;return[new U({key:new W(`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=wQ.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=TQ(r);if(e=!1,!t)return i?(e=!0,bQ(r.ranges)):null;let{$from:a,$to:o}=r;if(!i&&a.sameParent(o))return null;let s=SQ(a,o,this.options.depth);return s.length?(e=!0,bQ(s)):null}}})]}});function EQ(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 DQ(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=EQ(e)}),t}var OQ=[{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}],kQ={edges:[`left`,`top`],threshold:12,strength:500};function AQ(e){return e===void 0||e===`left`?{...kQ}: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}:{...kQ,...e}}function jQ(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 MQ(e,t,n,r){return!t||n.edges.length===0?0:jQ(e,t,n)?n.strength*r:0}var NQ=1e3;function PQ(e,t,n,r){let i=NQ,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-=MQ(r,o,n,e.depth),i<=0?-1:i}function FQ(e,t,n){return Array.from({length:t},(e,n)=>t-1-n).some(t=>n.includes(e.node(t).type.name))}function IQ(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(...OQ),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&&!FQ(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=PQ({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=FQ(a,l,n.allowedContainers)),p){let r=PQ({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 LQ(e,t){let n=e;for(;n?.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return n?.parentElement===t.dom?n:void 0}function RQ(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 zQ(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(!RQ(s)||!RQ(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 BQ=e=>{let{x:t,y:n,editor:r,nestedOptions:i}=e,{view:a,state:o}=r,s=zQ(a,t,n,5);if(!s)return{resultElement:null,resultNode:null,pos:null};let{x:c,y:l}=s;if(i?.enabled){let e=IQ(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=LQ(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 VQ(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 HQ(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function UQ(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=BQ({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 SQ(i.resolve(a.pos),i.resolve(a.pos+a.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}function WQ(e,t,n,r){let{view:i}=t;if(!e.dataTransfer)return;let{empty:a,$from:o,$to:s}=i.state.selection,c=UQ(e,t,n,r),l=SQ(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`,VQ(i,m));let g=n?.enabled&&r?.node,_,v;g?(_=i.state.doc.slice(m,h),v=Ct.create(i.state.doc,m)):(v=wQ.create(i.state.doc,m,h),_=v.content()),d.forEach(e=>{let t=DQ(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,HQ(p),document.removeEventListener(`drop`,T),document.removeEventListener(`dragend`,T))},E=v instanceof Ct?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 GQ=(e,t)=>{let n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},KQ=(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},qQ=(e,t)=>{let n=qv.getState(e);return n?Ny(t,n.type,n.binding.mapping):null},JQ=(e,t)=>{let n=qv.getState(e);return n?Fy(n.doc,n.type,t,n.binding.mapping)||0:-1},YQ=(e,t)=>{let n=t;for(;n?.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},XQ=new W(`dragHandle`),ZQ=({pluginKey:e=XQ,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),WQ(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(Qe()){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 U({key:typeof e==`string`?new W(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(pQ(e)){let e=JQ(o,p);e!==f&&(f=e)}else{let t=e.mapping.map(f);t!==f&&(f=t,p=qQ(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=YQ(e,o),o===e.dom||o?.nodeType!==1)return;let s=e.posAtDOM(o,0),c=KQ(n.state.doc,s),l=GQ(n.state.doc,s);d=c,f=l,p=qQ(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&&HQ(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=BQ({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=YQ(e,o),o===e.dom||o?.nodeType!==1)return;let t=e.posAtDOM(o,0);s=KQ(n.state.doc,t),l=GQ(n.state.doc,t)}s!==d&&(d=s,f=l??-1,p=qQ(e.state,f),a?.({editor:n,node:d,pos:f}),v(o),_())})),!1}}}})}};function QQ(e){return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:AQ(`none`)}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:AQ(`left`)}:{enabled:!0,rules:e.rules??[],defaultRules:e.defaultRules??!0,allowedContainers:e.allowedContainers,edgeDetection:AQ(e.edgeDetection)}}var $Q={placement:`left-start`,strategy:`absolute`};Dt.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=QQ(this.options.nested);return[ZQ({computePositionConfig:{...$Q,...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 e$=20,t$=44,n$=28;function r$(e){if(!e)return`Select block`;if(e.type.name===`jsxComponent`){let t=e.attrs.componentName??``;if(t){let e=sM(t),n=e.name===`*`?t:e.displayName??e.name;if(n)return`Select ${n}`}}return`Select ${e.type.name}`}function i$(){let e=document.createElement(`div`);e.className=`ok-block-controls`,e.setAttribute(gF,`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 a$(e,t,n){let{state:r,view:i}=e;if(n.type.name===`jsxComponent`){let i=n.attrs.componentName??``;if(i){let a=sM(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,pM(o)).run(),_M(e,i,sM(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=F.near(o.doc.resolve(a+1));o.setSelection(c).scrollIntoView(),i.dispatch(o),i.focus(),e.commands.insertContent(`/`)}var o$=Dt.create({name:`blockDragHandle`,addProseMirrorPlugins(){let e=this.editor,t=null,n=-1,{container:r,addBtn:i,grip:a}=i$();return i.addEventListener(`click`,()=>{t&&n>=0&&a$(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()||(an(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;an(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)}))}}),[ZQ({element:r,editor:e,onNodeChange({node:e,pos:r}){t=e,n=r??-1,a.setAttribute(`aria-label`,r$(e))},computePositionConfig:{placement:`left-start`,strategy:`absolute`,middleware:[be(({rects:e})=>({mainAxis:10,crossAxis:((e.reference.height<=t$?e.reference.height:n$)-e$)/2}))]},nestedOptions:QQ(!1)}).plugin]}}),s$=/^#fn(?:ref)?-/,c$=Dt.create({name:`footnoteAnchorScroll`,addProseMirrorPlugins(){return[new U({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(!s$.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}}}})]}}),l$=Dt.create({name:`formattingShortcuts`,addKeyboardShortcuts(){return{"Mod-Shift-x":()=>this.editor.commands.toggleStrike()}}}),u$=Dt.create({name:`headingAnchors`,addProseMirrorPlugins(){return[new U({props:{decorations(e){let t=[],n=new Map;return e.doc.descendants((e,r)=>{if(e.type.name===`heading`){let i=St(e.textContent,n);if(!i)return;t.push(S.node(r,r+e.nodeSize,{id:i}))}}),pe.create(e.doc,t)}}})]}});function d$(e){let t=(0,J.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?ZD(r)??void 0:void 0;s=typeof i==`string`?Re(ae(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,X.jsx)($l,{as:`span`,"data-image-inline-zoom":!0,"data-clipboard-inline-leaf":`image`,children:(0,X.jsx)(qk,{wrapElement:`span`,zoomMargin:20,zoomImg:d,children:(0,X.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 f$=N.extend({addNodeView(){return su(d$)}}),p$=new class{byExt=new Map;viewerUnregisterFns=new WeakMap;register(e){let t=this.viewerUnregisterFns.get(e);if(t)return t;for(let t of e.exts){let n=t.toLowerCase(),r=this.byExt.get(n);r&&r!==e&&console.warn(JSON.stringify({event:`asset-viewer-collision`,ext:n,priorExts:r.exts,newExts:e.exts})),this.byExt.set(n,e)}let n=!1,r=()=>{if(!n){n=!0;for(let t of e.exts){let n=t.toLowerCase();this.byExt.get(n)===e&&this.byExt.delete(n)}this.viewerUnregisterFns.delete(e)}};return this.viewerUnregisterFns.set(e,r),r}lookup(e){let t=this.byExt.get(e.toLowerCase());return t?{ok:!0,viewer:t}:{ok:!1}}clearForTests(){this.byExt.clear(),this.viewerUnregisterFns=new WeakMap}get size(){return this.byExt.size}};function m$(e){globalThis.window?.open(e,`_blank`,`noopener,noreferrer`)}async function h$(e,t={}){let n=t.registry??p$,r=`desktopBridge`in t?t.desktopBridge:globalThis.window?.okDesktop,i=t.openUrl??m$;if(!e.forceOsDelegation){let t=n.lookup(e.ext);if(t.ok){t.viewer.render(e);return}}if(r){let t=await r.shell.openAsset(e.projectRelPath);t.ok||console.warn(`[asset-dispatch] openAsset refused:`,t.reason,{projectRelPath:e.projectRelPath,ext:e.ext});return}i(e.url)}function g$(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=A(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=_e(n.getAttribute(`href`)??``,t);if(e?.kind===`asset`){let n=A(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=_e(e,t);if(n?.kind===`asset`){let e=A(n.url,t);return e?{kind:`image`,relPath:e,title:e.split(`/`).pop()??n.url}:null}}}n=n.parentElement}return null}var _$=new W(`asset-context-menu`);function v$(e){return new U({key:_$,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=g$(t.target,e.sourceDocName);r&&(t.preventDefault(),n(r))};return t.dom.addEventListener(`contextmenu`,r),{destroy(){t.dom.removeEventListener(`contextmenu`,r)}}}})}var y$=e=>{let t=(0,J.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,Y.useRef)(null),f,p;t[0]===o?(f=t[1],p=t[2]):(f=()=>{let e=d.current;if(e)return Ut(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,Y.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,X.jsx)(Ec,{asChild:!0,children:(0,X.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?(_=Sn(`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,X.jsx)(Tc,{side:`bottom`,align:`start`,sideOffset:8,collisionPadding:8,"aria-label":r,"data-ok-prop-panel":n,"data-slot":l,onOpenAutoFocus:b$,onCloseAutoFocus:x$,onPointerDownOutside:S$,onFocusOutside:C$,onInteractOutside:w$,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,X.jsxs)(Cc,{open:!0,onOpenChange:m,children:[h,v]}),t[15]=m,t[16]=v,t[17]=y):y=t[17],y};function b$(e){return e.preventDefault()}function x$(e){return e.preventDefault()}function S$(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function C$(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function w$(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function T$(e){let t=e.trim();return/\.(md|mdx)$/i.test(t)?t:`${t}.md`}function E$(e){let t=e.initialDir.trim().replace(/^\/+|\/+$/g,``),n=T$(e.suggestedName);return t?`${t}/${n}`:n}async function D$(e){let t=await yx(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:bx(Ae,t.body,`create-page`,{docName:n}).docName}}async function O$(e){return D$(E$(e))}async function k$(e,t){let{docName:n}=await O$(e);return t.addPage(n),kt([`files`,`backlinks`,`graph`]),t.onCreated?.(n),{docName:n}}var A$=8;function j$(e){return e.trim().replace(/^\/+/,``).replace(/\.mdx?$/i,``).replace(/\/+$/g,``)}function M$(e){return N$(e)?j$(e.slice(1)).toLowerCase():null}function N$(e){return e.startsWith(`/`)&&!e.startsWith(`//`)}function P$(e){return e.split(`/`).at(-1)??e}function F$(e,t){if(!t)return 0;let n=e.toLowerCase(),r=P$(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 I$(e){switch(e){case`page`:return 0;case`folder`:return 1;case`asset`:return 2}}function L$(e){let t=[],n=new Set;function r(e,r){let i=j$(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 R$(e){let t=M$(e.value);if(t===null)return[];let n=[];for(let r of L$(e)){let e=F$(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=I$(e.suggestion.kind)-I$(t.suggestion.kind);return n===0?e.suggestion.path.localeCompare(t.suggestion.path):n}),n.slice(0,e.limit??A$).map(e=>e.suggestion)}var z$=`[data-ok-link-path-suggestion-panel]`;function B$(e){return e instanceof Element&&e.closest(z$)!==null}function V$(e){B$(e.target)&&e.preventDefault()}function H$(e){switch(e){case`page`:return(0,X.jsx)(ra,{className:`size-3.5 shrink-0`,"aria-hidden":`true`});case`folder`:return(0,X.jsx)(ca,{className:`size-3.5 shrink-0`,"aria-hidden":`true`});case`asset`:return(0,X.jsx)(ja,{className:`size-3.5 shrink-0`,"aria-hidden":`true`})}}function U$(e,t){if(e){if(typeof e==`function`){e(t);return}e.current=t}}function W$(e){let t=(0,J.c)(54),n,r,a,o,s,l,u,d,f,p,m,h,g,_;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14]):({value:_,pages:p,folderPaths:a,assetPaths:n,includeAssets:h,loading:g,onValueChange:f,onKeyDown:u,onSuggestionSelect:d,onFocus:l,onBlur:s,className:r,ref:m,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s,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]=_);let v=h===void 0?!1:h,y=g===void 0?!1:g,{_:b}=i(),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(0),D=(0,Y.useRef)(null),O=(0,Y.useRef)(null),k=(0,Y.useId)(),A;t[15]===_?A=t[16]:(A=_.trim(),t[15]=_,t[16]=A);let j=A===``,M=R$({value:j?`/`:_,pages:p,folderPaths:a,assetPaths:n,includeAssets:v}),N=M.map(Y$).join(`\0`),P;t[17]===_?P=t[18]:(P=N$(_),t[17]=_,t[18]=P);let F=j||P,I=M.length>0,L=x&&!C&&F&&(I||y)||x&&!C&&F&&!y&&!I,ee=Math.min(T,Math.max(M.length-1,0)),z=I?`${k}-option-${ee}`:void 0,te;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{E(0)},t[19]=te):te=t[19],(0,Y.useEffect)(te,[N]);let B,ne;t[20]!==z||t[21]!==L?(B=()=>{!L||!z||document.getElementById(z)?.scrollIntoView?.({block:`nearest`})},ne=[z,L],t[20]=z,t[21]=L,t[22]=B,t[23]=ne):(B=t[22],ne=t[23]),(0,Y.useEffect)(B,ne);let V,re;t[24]===L?(V=t[25],re=t[26]):(V=()=>{if(!L)return;let e=D.current,t=O.current;if(!e||!t)return;let n=e,r=t,i=function(){R(n,r,{placement:`bottom-start`,strategy:`fixed`,middleware:[be(4),Be({padding:8}),c({padding:8}),lt({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=Ut(n,r,i);return i(),a},re=[L],t[24]=L,t[25]=V,t[26]=re),(0,Y.useLayoutEffect)(V,re);let ie;t[27]===m?ie=t[28]:(ie=function(e){D.current=e,U$(m,e)},t[27]=m,t[28]=ie);let H=ie,ae=function(e){d?d(e):f(e.path),w(!0),requestAnimationFrame(()=>D.current?.focus())},oe=function(e){if(I){if(e.key===`ArrowDown`){e.preventDefault(),E(e=>Math.min(e+1,M.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),E(J$);return}if(e.key===`Enter`){e.preventDefault();let t=M[ee];t&&ae(t);return}if(e.key===`Escape`){e.preventDefault(),w(!0);return}}if(L&&e.key===`Escape`){e.preventDefault(),w(!0);return}u?.(e)},U;t[29]===b?U=t[30]:(U=function(e){switch(e){case`page`:return b({id:`6WdDG7`});case`folder`:return b({id:`kNqMMd`});case`asset`:return b({id:`bUUVED`})}},t[29]=b,t[30]=U);let se=U,ce=L?(0,X.jsx)(`div`,{ref:O,id:k,role:`listbox`,"aria-label":b({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:q$,onTouchMove:K$,children:I?M.map((e,t)=>{let n=t===ee,r=se(e.kind);return(0,X.jsxs)(In,{id:`${k}-option-${t}`,type:`button`,role:`option`,"aria-label":`/${e.path} ${r}`,"aria-selected":n,variant:`ghost`,className:Sn(`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:G$,onClick:()=>ae(e),children:[H$(e.kind),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`/`,e.path]}),(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground text-xs`,children:r})]},`${e.kind}:${e.path}`)}):(0,X.jsx)(`div`,{role:`status`,className:`px-2 py-1.5 text-muted-foreground text-sm`,children:b(y?{id:`sxTdZI`}:{id:`_QwkMu`})})}):null,W;t[31]===f?W=t[32]:(W=e=>{w(!1),f(e.target.value)},t[31]=f,t[32]=W);let le;t[33]===l?le=t[34]:(le=e=>{S(!0),l?.(e)},t[33]=l,t[34]=le);let ue;t[35]===s?ue=t[36]:(ue=e=>{S(!1),s?.(e)},t[35]=s,t[36]=ue);let de=L?k:void 0,fe;t[37]!==z||t[38]!==r||t[39]!==oe||t[40]!==o||t[41]!==H||t[42]!==L||t[43]!==W||t[44]!==le||t[45]!==ue||t[46]!==de||t[47]!==_?(fe=(0,X.jsx)(cr,{...o,ref:H,value:_,onChange:W,onFocus:le,onBlur:ue,onKeyDown:oe,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":L,"aria-controls":de,"aria-activedescendant":z,autoComplete:`off`,className:r}),t[37]=z,t[38]=r,t[39]=oe,t[40]=o,t[41]=H,t[42]=L,t[43]=W,t[44]=le,t[45]=ue,t[46]=de,t[47]=_,t[48]=fe):fe=t[48];let pe;t[49]===ce?pe=t[50]:(pe=ce&&(0,no.createPortal)(ce,document.body),t[49]=ce,t[50]=pe);let me;return t[51]!==fe||t[52]!==pe?(me=(0,X.jsxs)(`div`,{className:`relative`,children:[fe,pe]}),t[51]=fe,t[52]=pe,t[53]=me):me=t[53],me}function G$(e){return e.preventDefault()}function K$(e){e.stopPropagation()}function q$(e){e.stopPropagation()}function J$(e){return Math.max(e-1,0)}function Y$(e){return`${e.kind}:${e.path}`}var X$=1500;function Z$(e){let t=(0,J.c)(15),{copyContent:n}=e,[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(null),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{a.current!==null&&clearTimeout(a.current)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,Y.useEffect)(o,s);let c;t[2]===n?c=t[3]:(c=()=>{try{typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(n).then(()=>{i(!0),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),X$)},Q$)}catch{}},t[2]=n,t[3]=c);let l=c,u=r?`Copied!`:`Copy`,d;t[4]===r?d=t[5]:(d=r?(0,X.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`}):(0,X.jsx)(Zi,{className:`size-3.5`,"aria-hidden":`true`}),t[4]=r,t[5]=d);let f;t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(In,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":u,onClick:l,"data-slot":`prop-panel-copy`,children:d})}),t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9];let p=r?`Copied!`:`Copy`,m;t[10]===p?m=t[11]:(m=(0,X.jsx)(re,{children:p}),t[10]=p,t[11]=m);let h;return t[12]!==f||t[13]!==m?(h=(0,X.jsxs)(P,{children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14],h}function Q$(){}function $$(e,t){return EO.getState(e)?.byId.get(t)??null}function e1(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 t1(e){let{editor:t,layer:n,markTypes:r,predicate:i,renderPropPanel:a,handlePrimary:o}=e,s=e1({editor:t,layer:n,renderPropPanel:a,handlePrimary:o});return jO({markTypes:[...r],predicate:i,onRegister:s.onRegister,onDeregister:s.onDeregister})}function n1(e){let t=GO(e.editor);return t1({...e,layer:t})}function r1(e,t){let n=(0,J.c)(4),[r,i]=(0,Y.useState)(null),a,o;return n[0]!==e||n[1]!==t?(a=()=>{if(!t||!e){i(null);return}let n=!1;return i(null),IX(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,Y.useEffect)(a,o),r}function i1(e,t){let n=e.trim();return n?n.startsWith(`#`)?`anchor`:b(n)?`external`:`doc`:t}function a1(e){return e?.kind===`doc`?`doc`:e?.kind===`anchor`?`anchor`:`external`}function o1(e){let t=(0,J.c)(84),{open:n,href:r,text:a,pages:s,folderPaths:c,loading:l,onOpenChange:u,onSave:d}=e,[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(`doc`),b=(0,Y.useId)(),x=(0,Y.useId)(),S=(0,Y.useId)(),C=(0,Y.useId)(),{_:w}=i(),T=(0,Y.useRef)(!1),E=(0,Y.useRef)(``),D,O;t[0]!==r||t[1]!==n||t[2]!==a?(D=()=>{if(!n){T.current=!1;return}if(T.current)return;T.current=!0,E.current=a,_(a);let e=XY(r);if(y(a1(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,a],t[0]=r,t[1]=n,t[2]=a,t[3]=D,t[4]=O):(D=t[3],O=t[4]),(0,Y.useEffect)(D,O);let k,A,j;t[5]!==v||t[6]!==f||t[7]!==s?(k=ut(f),A=v===`doc`,j=A&&lO(k,s),t[5]=v,t[6]=f,t[7]=s,t[8]=k,t[9]=A,t[10]=j):(k=t[8],A=t[9],j=t[10]);let M=r1(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?aX(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,ee;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ee=function(e){p(e.path),y(`doc`),h(``)},t[21]=ee):ee=t[21];let R=ee,z;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,X.jsx)(Wn,{children:(0,X.jsx)(o,{id:`B11p-O`})}),t[22]=z):z=t[22];let te;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,X.jsxs)(nr,{children:[z,(0,X.jsx)(Hn,{children:(0,X.jsx)(o,{id:`RobAKV`})})]}),t[23]=te):te=t[23];let B;t[24]===A?B=t[25]:(B=A?(0,X.jsx)(o,{id:`6WdDG7`}):(0,X.jsx)(o,{id:`6vEr3W`}),t[24]=A,t[25]=B);let ne;t[26]!==B||t[27]!==b?(ne=(0,X.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:b,children:B}),t[26]=B,t[27]=b,t[28]=ne):ne=t[28];let V;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(V=e=>{p(e),y(t=>i1(e,t))},t[29]=V):V=t[29];let re;t[30]===w?re=t[31]:(re=w({id:`Xl-UUg`}),t[30]=w,t[31]=re);let ie;t[32]!==f||t[33]!==c||t[34]!==L||t[35]!==l||t[36]!==s||t[37]!==re||t[38]!==b?(ie=(0,X.jsx)(W$,{id:b,value:f,pages:s,folderPaths:c,loading:l,onValueChange:V,onSuggestionSelect:R,placeholder:re,autoFocus:!0,onKeyDown:L}),t[32]=f,t[33]=c,t[34]=L,t[35]=l,t[36]=s,t[37]=re,t[38]=b,t[39]=ie):ie=t[39];let H;t[40]!==ne||t[41]!==ie?(H=(0,X.jsxs)(`div`,{children:[ne,ie]}),t[40]=ne,t[41]=ie,t[42]=H):H=t[42];let ae;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,X.jsx)(o,{id:`QqBQu1`,components:{0:(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[43]=ae):ae=t[43];let oe;t[44]===S?oe=t[45]:(oe=(0,X.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:S,children:ae}),t[44]=S,t[45]=oe);let U;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>_(e.target.value),t[46]=U):U=t[46];let se;t[47]===w?se=t[48]:(se=w({id:`yYR6za`}),t[47]=w,t[48]=se);let ce;t[49]!==g||t[50]!==L||t[51]!==S||t[52]!==se?(ce=(0,X.jsx)(cr,{id:S,value:g,onChange:U,placeholder:se,onKeyDown:L}),t[49]=g,t[50]=L,t[51]=S,t[52]=se,t[53]=ce):ce=t[53];let W;t[54]!==oe||t[55]!==ce?(W=(0,X.jsxs)(`div`,{children:[oe,ce]}),t[54]=oe,t[55]=ce,t[56]=W):W=t[56];let le;t[57]!==w||t[58]!==x||t[59]!==A||t[60]!==m||t[61]!==L||t[62]!==C||t[63]!==M||t[64]!==N?(le=A?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:x,children:(0,X.jsx)(o,{id:`Tjc1pH`,components:{0:(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`})}})}),(0,X.jsx)(cr,{id:x,value:m,onChange:e=>h(e.target.value),placeholder:w({id:`W-ntoW`}),onKeyDown:L}),N?(0,X.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,X.jsxs)(`button`,{type:`button`,"aria-pressed":m===e.slug,className:Sn(`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,X.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,X.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]=le):le=t[65];let ue;t[66]!==H||t[67]!==W||t[68]!==le?(ue=(0,X.jsxs)(Qn,{className:`space-y-6 pb-1`,children:[H,W,le]}),t[66]=H,t[67]=W,t[68]=le,t[69]=ue):ue=t[69];let de;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,X.jsx)(tr,{asChild:!0,children:(0,X.jsx)(In,{variant:`outline`,children:(0,X.jsx)(o,{id:`dEgA5A`})})}),t[70]=de):de=t[70];let fe;t[71]===f?fe=t[72]:(fe=f.trim(),t[71]=f,t[72]=fe);let pe=!fe,me;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,X.jsx)(o,{id:`tfDRzk`}),t[73]=me):me=t[73];let he;t[74]!==F||t[75]!==pe?(he=(0,X.jsxs)($n,{children:[de,(0,X.jsx)(In,{onClick:F,disabled:pe,children:me})]}),t[74]=F,t[75]=pe,t[76]=he):he=t[76];let ge;t[77]!==ue||t[78]!==he?(ge=(0,X.jsxs)(Yn,{className:`sm:max-w-xl`,"data-ok-layer-spawned":``,onPointerDownOutside:V$,onFocusOutside:V$,onInteractOutside:V$,children:[te,ue,he]}),t[77]=ue,t[78]=he,t[79]=ge):ge=t[79];let _e;return t[80]!==u||t[81]!==n||t[82]!==ge?(_e=(0,X.jsx)(rr,{open:n,onOpenChange:u,children:ge}),t[80]=u,t[81]=n,t[82]=ge,t[83]=_e):_e=t[83],_e}function s1(e){let t=(0,J.c)(99),{editor:n,nodeId:r,sourceDocName:a,onClose:s,onNavigate:c}=e,l=$$(n.state,r),u=l?.attrs?.href??``,[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1),h;t[0]!==r||t[1]!==f?(h=()=>{TO(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,Y.useEffect)(h,g);let{addPage:_,folderPaths:v,pages:y,loading:b}=yt(),{_:x}=i();if(!l)return null;let S=n.state.doc.textBetween(l.from,l.to),C=u?_e(u,a):null,w;t[5]!==n||t[6]!==r?(w=function(e,t,i){let a=$$(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]!==s?(E=function(){let e=$$(n.state,r);e&&(n.chain().focus().setTextSelection({from:e.from,to:e.to}).extendMarkRange(`link`).unsetLink().run(),s())},t[8]=n,t[9]=r,t[10]=s,t[11]=E):E=t[11];let D=E,O;t[12]!==n||t[13]!==r||t[14]!==s||t[15]!==f?(O=function(e){if(e){f(!0);return}let t=$$(n.state,r);if(t?.attrs?.href??``){f(!1);return}t&&n.chain().focus().deleteRange({from:t.from,to:t.to}).run(),s()},t[12]=n,t[13]=r,t[14]=s,t[15]=f,t[16]=O):O=t[16];let k=(0,X.jsx)(o1,{open:d,href:u,text:S,pages:y,folderPaths:v,loading:b,onOpenChange:u?f:O,onSave:T});if(!u)return(0,X.jsx)(X.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=$$(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:aX(e,C?.kind===`doc`?C.anchor??null:null)}).run()},M,N=!1,F=!1,I=null;if(b){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ta,{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,X.jsx)(aa,{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,X.jsx)(xe,{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,X.jsx)(aa,{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=VY(C.docName,{pages:y,folderPaths:v});if(F=e.kind===`navigate`&&e.displayState===`folder`,N=e.kind===`create`,I=e.kind===`create`?{initialDir:e.initialDir,suggestedName:e.suggestedName}:null,F){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(ca,{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,X.jsx)(Wi,{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,X.jsx)(aa,{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,X.jsx)(Wi,{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 L=C?.kind===`external`,ee=C?.kind===`doc`?ZY({docName:C.docName,anchor:C.anchor}):C?.kind===`anchor`?ZY({docName:a,anchor:C.anchor}):C?.kind===`external`&&JY(C.url)?C.url:null,R=!b&&ee!==null&&(C?.kind===`anchor`||C?.kind===`external`||C?.kind===`doc`&&!N&&!F),z;t[25]!==n.state||t[26]!==n.view||t[27]!==r?(z=()=>{let e=$$(n.state,r);if(!e)return new DOMRect;try{return un(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 B=te,ne;t[32]!==x||t[33]!==_||t[34]!==p||t[35]!==I||t[36]!==s||t[37]!==j?(ne=async function(){if(!(!I||p)){m(!0);try{await k$(I,{addPage:_,onCreated(e){j(e),window.location.hash=`#/${e}`,s()}}),m(!1)}catch(e){let t=e;or.error(t instanceof Error?t.message:x({id:`tfi40B`})),m(!1)}}},t[32]=x,t[33]=_,t[34]=p,t[35]=I,t[36]=s,t[37]=j,t[38]=ne):ne=t[38];let V=ne,ie=Sn(`flex shrink-0`,M.className),H;t[39]!==M.icon||t[40]!==ie?(H=(0,X.jsx)(`span`,{className:ie,children:M.icon}),t[39]=M.icon,t[40]=ie,t[41]=H):H=t[41];let ae=H,oe;t[42]!==ae||t[43]!==N||t[44]!==M.text?(oe=N?(0,X.jsxs)(P,{children:[(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`internal-link-prop-panel-icon-trigger`,children:ae})}),(0,X.jsx)(re,{children:M.text})]}):ae,t[42]=ae,t[43]=N,t[44]=M.text,t[45]=oe):oe=t[45];let U=oe,se=`${M.text}: ${A}`,ce;t[46]!==A||t[47]!==L||t[48]!==N||t[49]!==ee||t[50]!==R||t[51]!==s||t[52]!==c?(ce=(0,X.jsx)(vn,{asChild:!0,children:R?(0,X.jsx)(`a`,{href:ee??void 0,...L?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>nX(e,c,s),"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,X.jsx)(`span`,{"data-slot":`internal-link-prop-panel-text`,className:Sn(`block truncate text-sm font-medium`,N?`text-muted-foreground`:`text-foreground`),children:A})}),t[46]=A,t[47]=L,t[48]=N,t[49]=ee,t[50]=R,t[51]=s,t[52]=c,t[53]=ce):ce=t[53];let W;t[54]===A?W=t[55]:(W=(0,X.jsx)(re,{className:`max-w-80 break-all`,children:A}),t[54]=A,t[55]=W);let le;t[56]!==ce||t[57]!==W?(le=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(P,{children:[ce,W]})}),t[56]=ce,t[57]=W,t[58]=le):le=t[58];let ue;t[59]!==V||t[60]!==p||t[61]!==N?(ue=N?(0,X.jsxs)(In,{type:`button`,size:`sm`,variant:`link`,disabled:p,onClick:()=>void V(),"data-slot":`internal-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,X.jsx)(Na,{className:`size-3.5`,"aria-hidden":`true`}),p?(0,X.jsx)(o,{id:`HM56Bx`}):(0,X.jsx)(o,{id:`XRuL0i`})]}):null,t[59]=V,t[60]=p,t[61]=N,t[62]=ue):ue=t[62];let de;t[63]===x?de=t[64]:(de=x({id:`ePK91l`}),t[63]=x,t[64]=de);let fe;t[65]===f?fe=t[66]:(fe=()=>f(!0),t[65]=f,t[66]=fe);let pe;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,X.jsx)(Ma,{className:`size-3.5`,"aria-hidden":`true`}),t[67]=pe):pe=t[67];let me;t[68]!==de||t[69]!==fe?(me=(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(In,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":de,onClick:fe,"data-slot":`internal-link-prop-panel-edit`,children:pe})}),t[68]=de,t[69]=fe,t[70]=me):me=t[70];let he;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,X.jsx)(re,{children:(0,X.jsx)(o,{id:`ePK91l`})}),t[71]=he):he=t[71];let ge;t[72]===me?ge=t[73]:(ge=(0,X.jsxs)(P,{children:[me,he]}),t[72]=me,t[73]=ge);let ve;t[74]===u?ve=t[75]:(ve=(0,X.jsx)(Z$,{copyContent:u}),t[74]=u,t[75]=ve);let ye;t[76]===x?ye=t[77]:(ye=x({id:`t_YqKh`}),t[76]=x,t[77]=ye);let be;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,X.jsx)(Ka,{className:`size-3.5`,"aria-hidden":`true`}),t[78]=be):be=t[78];let Se;t[79]!==D||t[80]!==ye?(Se=(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(In,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":ye,onClick:D,"data-slot":`internal-link-prop-panel-remove`,children:be})}),t[79]=D,t[80]=ye,t[81]=Se):Se=t[81];let Ce;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,X.jsx)(re,{children:(0,X.jsx)(o,{id:`t_YqKh`})}),t[82]=Ce):Ce=t[82];let we;t[83]===Se?we=t[84]:(we=(0,X.jsxs)(P,{children:[Se,Ce]}),t[83]=Se,t[84]=we);let Te;t[85]!==ue||t[86]!==ge||t[87]!==ve||t[88]!==we?(Te=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[ue,ge,ve,we]}),t[85]=ue,t[86]=ge,t[87]=ve,t[88]=we,t[89]=Te):Te=t[89];let Ee;t[90]!==U||t[91]!==le||t[92]!==Te?(Ee=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[U,le,Te]}),t[90]=U,t[91]=le,t[92]=Te,t[93]=Ee):Ee=t[93];let De;return t[94]!==s||t[95]!==se||t[96]!==Ee||t[97]!==B?(De=(0,X.jsx)(y$,{kind:`internal-link`,ariaLabel:se,onDeactivate:s,triggerReference:B,className:`w-96`,children:Ee}),t[94]=s,t[95]=se,t[96]=Ee,t[97]=B,t[98]=De):De=t[98],(0,X.jsxs)(X.Fragment,{children:[k,De]})}new W(`markIdentityDecoration`);var c1=`data-mark-id`,l1=new W(`linkResolutionDecoration`);function u1(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={[c1]:e.id};t!==null&&Object.assign(o,t),a.push(S.inline(e.from,e.to,o))}return a.length===0?null:pe.create(e,a)}function d1(e){let t=new Set(e.markTypes),{computeAttrs:n}=e;return new U({key:l1,state:{init:()=>({version:0}),apply(e,t){let n=e.getMeta(l1);return n&&typeof n==`object`&&n.refresh?{version:t.version+1}:t}},props:{decorations(e){let r=EO.getState(e);if(!r)return null;let i=pn();return u1(e.doc,r.byId,t,n,i)}},view(e){Z(`ok/render/decoration-merge`,{markTypes:Array.from(t).join(`,`)},{startTime:performance.now(),duration:0});let n=Ze(()=>{e.dispatch(e.state.tr.setMeta(l1,{refresh:!0}))});return{destroy(){n()}}}})}var f1=Le.extend({addOptions(){return{...this.parent?.(),docName:``}},renderHTML({HTMLAttributes:e}){let t=typeof e.href==`string`?e.href:``;return[`span`,v(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=$$(t.state,n),a=i?.attrs?.href;if(typeof a!=`string`||!a)return!1;let o=i?.attrs?.sourceForm,s=_e(a,e),c=u(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=A(t,e);if(!i)return!1;let o=pn();return o===null||o.assetPaths!==void 0&&!UY(t,e,o.assetPaths)?!1:(h$({url:t,projectRelPath:i,ext:n,title:i.split(`/`).pop()??t,forceOsDelegation:r}),!0)}if(!s)return!1;switch(s.kind){case`doc`:{let e=pn(),t=VY(s.docName,{pages:e?.pages??new Set,folderPaths:e?.folderPaths??new Set});return t.kind===`create`||t.kind===`navigate`&&t.displayState===`folder`?!1:(r?eX({docName:s.docName,anchor:s.anchor}):window.location.assign(ZY({docName:s.docName,anchor:s.anchor})),!0)}case`anchor`:return r?eX({docName:e,anchor:s.anchor}):window.location.assign(ZY({docName:e,anchor:s.anchor})),!0;case`external`:return JY(s.url)?(QY(s.url),!0):!1;default:return y(s)}};return[n1({editor:this.editor,markTypes:[`link`],renderPropPanel:({editor:n,nodeId:r,deactivate:i})=>(0,Y.createElement)(s1,{editor:n,nodeId:r,sourceDocName:e,onClose:i,onNavigate:e=>t({editor:n,nodeId:r,newTab:e})}),handlePrimary:t}),d1({markTypes:[`link`],computeAttrs:KY(e)}),v$({sourceDocName:e})]}}),p1=(0,Y.createContext)(null),m1={didCatch:!1,error:null},h1=class extends Y.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=m1}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(m1))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&g1(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(m1))}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,Y.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,Y.createElement)(p1.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function g1(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}function _1(e){let t=(0,J.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=Sn(`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,X.jsx)(n,{size:16,"aria-hidden":`true`}),t[11]=n,t[12]=d);let f;t[13]===i?f=t[14]:(f=(0,X.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,X.jsxs)(`div`,{...o,role:`button`,tabIndex:-1,contentEditable:!1,"data-descriptor-placeholder":``,"data-selected":c,onClick:a,onMouseDown:v1,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 v1(e){e.preventDefault(),e.stopPropagation()}function y1(e){let t=(0,J.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,X.jsx)(Ys,{"data-slot":`select`,...n}),t[2]=n,t[3]=r),r}function b1(e){let t=(0,J.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,X.jsx)(Zs,{"data-slot":`select-value`,...n}),t[2]=n,t[3]=r),r}function x1(e){let t=(0,J.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className: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=Sn(`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,X.jsx)(Qs,{asChild:!0,children:(0,X.jsx)(Hi,{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,X.jsxs)(Xs,{"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 S1(e){let t=(0,J.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=Sn(`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,X.jsx)(w1,{}),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=Sn(`p-1`,u),t[9]=u,t[10]=d);let f;t[11]!==n||t[12]!==d?(f=(0,X.jsx)(tc,{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,X.jsx)(T1,{}),t[14]=p):p=t[14];let m;return t[15]!==o||t[16]!==i||t[17]!==c||t[18]!==f?(m=(0,X.jsx)($s,{children:(0,X.jsxs)(ec,{"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 C1(e){let t=(0,J.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=Sn(`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,X.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,X.jsx)(ic,{children:(0,X.jsx)(ar,{className:`size-4`})})}),t[6]=o):o=t[6];let s;t[7]===n?s=t[8]:(s=(0,X.jsx)(rc,{children:n}),t[7]=n,t[8]=s);let c;return t[9]!==i||t[10]!==a||t[11]!==s?(c=(0,X.jsxs)(nc,{"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 w1(e){let t=(0,J.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=Sn(`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,X.jsx)(Ui,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,X.jsx)(ac,{"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 T1(e){let t=(0,J.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=Sn(`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,X.jsx)(Hi,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,X.jsx)(oc,{"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 E1(e){let t=(0,J.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=Sn(`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,X.jsx)(yc,{"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,X.jsx)(vc,{"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 D1(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 O1(e){let t=(0,J.c)(36),{id:n,value:r,onChange:i,autoFocus:a}=e,o=(0,Y.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=Sn(`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,X.jsx)(cr,{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,X.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,X.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,X.jsx)(In,{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,X.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]:(_=D1(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,X.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,X.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,X.jsx)(In,{type:`button`,variant:`ghost`,size:`xs`,"aria-label":`Clear color`,"data-color-picker-clear":``,className:`h-7 px-1.5`,onClick:()=>i(``),children:(0,X.jsx)(Qi,{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,X.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 k1(e){let t=(0,J.c)(43),{id:n,value:r,onChange:i,autoFocus:a}=e,[o,s]=(0,Y.useState)(!1),c;t[0]===r?c=t[1]:(c=XO(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=Sn(`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,X.jsx)(cr,{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,X.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,X.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,X.jsx)(Hi,{className:`size-3`,"aria-hidden":`true`}),t[20]=y):y=t[20];let b;t[21]===o?b=t[22]:(b=(0,X.jsx)(wc,{asChild:!0,children:(0,X.jsx)(In,{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,X.jsx)(px,{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,X.jsx)(hx,{children:`No icons match.`}),t[24]=S):S=t[24];let C;t[25]!==i||t[26]!==r.length?(C=r.length>0&&(0,X.jsx)(gx,{children:(0,X.jsxs)(_x,{value:`__clear__`,onSelect:()=>{i(``),s(!1)},className:`gap-2 text-muted-foreground`,"data-icon-picker-clear":``,children:[(0,X.jsx)(Un,{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=YO.map(e=>{let[t,n]=e,r=t===d;return(0,X.jsx)(_x,{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:Sn(`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,X.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,X.jsx)(gx,{heading:`Lucide`,children:(0,X.jsx)($b.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,X.jsx)(Tc,{align:`end`,className:`z-70 w-72 p-0`,onOpenAutoFocus:A1,children:(0,X.jsxs)(dx,{label:`Icon picker`,children:[x,(0,X.jsxs)(mx,{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,X.jsxs)(Cc,{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,X.jsxs)(`div`,{className:`flex gap-1`,children:[v,D]}),t[40]=D,t[41]=v,t[42]=O):O=t[42],O}function A1(e){return e.preventDefault()}function j1(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 M1(e){if(e.length===1&&e[0]===`*/*`)return`all`;let t=new Set;for(let n of e){if(n===`*/*`)return`all`;let e=j1(n);e&&t.add(e)}return t}function N1(e){let t=e.lastIndexOf(`.`);return t<0||t<e.lastIndexOf(`/`)?``:e.slice(t+1).toLowerCase()}function P1(e,t){let n=M1(t),r=[];for(let t of e){if(n===`all`){r.push(t);continue}let e=ve(N1(t));e&&n.has(e)&&r.push(t)}return r}var F1=8,I1=new Set,L1=null;function R1(e){return{path:e,basename:e.split(`/`).pop()??e}}function z1(e){let t=e.map(e=>e.path).join(``);return L1?.fingerprint===t||(L1={fingerprint:t,byPath:new Map(e.map(e=>[e.path,e])),itemsInOrder:e,corpus:Gt(e.map(e=>te({kind:`page`,path:e.path,title:e.basename})))}),L1}function B1(e){let t=e.trim();return t.startsWith(`/`)?t.slice(1):t}function V1(e,t){let n=B1(t);return n?Kt(e.corpus,n,{intent:`autocomplete`,limit:F1}).map(t=>e.byPath.get(t.document.path)).filter(e=>!!e):e.itemsInOrder.slice(0,F1)}function H1(e){let t=(0,J.c)(51),{value:n,onChange:r,accept:i,id:a,placeholder:o,autoFocus:s,ariaInvalid:c,ariaDescribedBy:l,dataPropAutofocus:u,className:d}=e,f=Jt()?.assetPaths??I1,p;t[0]!==i||t[1]!==f||t[2]!==n?(p=V1(z1(P1(f,i).map(R1)),n),t[0]=i,t[1]=f,t[2]=n,t[3]=p):p=t[3];let m=p,[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(0),y,b;t[4]!==_||t[5]!==m.length?(y=()=>{_>=m.length&&v(0)},b=[_,m.length],t[4]=_,t[5]=m.length,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,Y.useEffect)(y,b);let x=(0,Y.useId)(),S=(0,Y.useRef)(null),C=h&&m.length>0,w;t[8]===r?w=t[9]:(w=e=>{r(`/${e.path}`),g(!1),v(0),S.current?.focus()},t[8]=r,t[9]=w);let T=w,E;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>g(e),t[10]=E):E=t[10];let D=C?x:void 0,O=C&&m[_]?`${x}-opt-${_}`:void 0,k;t[11]===r?k=t[12]:(k=e=>{r(e.target.value),g(!0),v(0)},t[11]=r,t[12]=k);let A,j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{g(!0)},A=()=>{g(!0)},t[13]=A,t[14]=j):(A=t[13],j=t[14]);let M;t[15]!==_||t[16]!==T||t[17]!==m||t[18]!==C?(M=e=>{if(e.key===`ArrowDown`){if(m.length===0)return;e.preventDefault(),g(!0),v(e=>(e+1)%m.length);return}if(e.key===`ArrowUp`){if(m.length===0)return;e.preventDefault(),g(!0),v(e=>(e-1+m.length)%m.length);return}if(e.key===`Enter`){if(!C)return;let t=m[_];if(!t)return;e.preventDefault(),T(t);return}if(e.key===`Escape`){if(!C)return;e.preventDefault(),e.stopPropagation(),g(!1);return}e.key===`Tab`&&g(!1)},t[15]=_,t[16]=T,t[17]=m,t[18]=C,t[19]=M):M=t[19];let N;t[20]!==l||t[21]!==c||t[22]!==s||t[23]!==d||t[24]!==u||t[25]!==a||t[26]!==o||t[27]!==M||t[28]!==D||t[29]!==O||t[30]!==k||t[31]!==n||t[32]!==C?(N=(0,X.jsx)(Ec,{asChild:!0,children:(0,X.jsx)(cr,{ref:S,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":C,"aria-controls":D,"aria-activedescendant":O,className:d,onChange:k,onFocus:j,onClick:A,onKeyDown:M})}),t[20]=l,t[21]=c,t[22]=s,t[23]=d,t[24]=u,t[25]=a,t[26]=o,t[27]=M,t[28]=D,t[29]=O,t[30]=k,t[31]=n,t[32]=C,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{let t=e.target;t instanceof Node&&S.current?.contains(t)&&e.preventDefault()},t[34]=P):P=t[34];let F;if(t[35]!==_||t[36]!==x||t[37]!==T||t[38]!==m){let e;t[40]!==_||t[41]!==x||t[42]!==T?(e=(e,t)=>{let n=`${x}-opt-${t}`,r=t===_;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{id:n,type:`button`,role:`option`,"aria-selected":r,"data-testid":`src-autocomplete-option`,"data-highlighted":r?``:void 0,className:Sn(`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:()=>v(t),onMouseDown:t=>{t.preventDefault(),T(e)},children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.basename}),e.basename!==e.path&&(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:e.path})]})},e.path)},t[40]=_,t[41]=x,t[42]=T,t[43]=e):e=t[43],F=m.map(e),t[35]=_,t[36]=x,t[37]=T,t[38]=m,t[39]=F}else F=t[39];let I;t[44]!==x||t[45]!==F?(I=(0,X.jsx)(Tc,{align:`start`,sideOffset:4,className:`z-70 w-[--radix-popover-trigger-width] p-1`,onOpenAutoFocus:W1,onCloseAutoFocus:U1,onInteractOutside:P,children:(0,X.jsx)(`ul`,{id:x,"aria-label":`Asset suggestions`,className:`flex flex-col gap-px`,children:F})}),t[44]=x,t[45]=F,t[46]=I):I=t[46];let L;return t[47]!==N||t[48]!==I||t[49]!==C?(L=(0,X.jsxs)(Cc,{open:C,onOpenChange:E,children:[N,I]}),t[47]=N,t[48]=I,t[49]=C,t[50]=L):L=t[50],L}function U1(e){e.preventDefault()}function W1(e){e.preventDefault()}function G1(){if(typeof window>`u`)return null;let e=window.location.hash.match(/^#\/([^?#]+)/);return e?decodeURIComponent(e[1]):null}var K1=`/api/upload`;async function q1(e,t,n={}){let r=n.fetch??globalThis.fetch,i=n.docName===void 0?G1():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(K1,{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 uO(`Upload response is not JSON.`,{cause:e,status:o.status})}if(!o.ok){let e=$t.safeParse(s);throw e.success?Error(e.data.title):new uO(`Upload error response did not match ProblemDetails.`,{cause:e.error,status:o.status})}let c=Ke.safeParse(s);if(!c.success)throw new uO(`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 J1=new Intl.PluralRules(`en-US`);function Y1(e,t,n){return n<=0?`${e} (empty)`:`${e} with ${n} ${J1.select(n)===`one`?`item`:`items`}`}function X1(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 Z1(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 Q1=new Set([`auto`,`inherit`,`initial`,`unset`]),$1=new Set([`px`,`%`,`rem`,`em`,`vh`,`vw`,`ch`,`ex`,`fr`]),e0=/^(-?\d+(?:\.\d+)?)([a-z%]*)$/i;function t0(e){let t=e.trim();if(!t)return{valid:!1,reason:`empty`};if(Q1.has(t.toLowerCase()))return{valid:!0};let n=t.match(e0);if(!n)return{valid:!1,reason:`malformed-syntax`};let r=(n[2]??``).toLowerCase();return r===``||$1.has(r)?{valid:!0}:{valid:!1,reason:`unknown-unit`}}function n0(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 r0={video:sn,audio:Rt,image:Fe},i0={youtube:[`youtube.com`,`youtu.be`,`youtube-nocookie.com`],vimeo:[`vimeo.com`],loom:[`loom.com`]};function a0(e){let t=e.toLowerCase();for(let e of Object.keys(i0)){let n=i0[e];for(let r of n)if(t===r||t.endsWith(`.${r}`))return e}return null}function o0(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 s0=`https://placeholder.invalid`;function c0(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,s0),i=!1}catch{return{valid:!1,reason:`invalid-url`}}}if(t===`video`&&M(n)!==null||t===`video`&&m(n)||t===`video`&&ke(n))return{valid:!0};let a=i?a0(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=o0(r.pathname),s=r0[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 l0(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 u0(e){return`Direct ${e} file URL — ${Array.from(r0[e]).map(e=>`.${e}`).join(`, `)}`}var d0={youtube:`YouTube`,vimeo:`Vimeo`,loom:`Loom`};function f0(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=d0[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(r0[t]).map(e=>`.${e}`).join(`, `);return e.extension===``?`Missing file extension. Accepts: ${n}.`:`Unsupported extension .${e.extension}. Accepts: ${n}.`}function p0(e){return`ok.propPanel.advanced.${e}`}function m0(e){try{return typeof localStorage>`u`?!1:localStorage.getItem(p0(e))===`true`}catch{return!1}}function h0(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(p0(e),t?`true`:`false`)}catch{}}function g0(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 _0(e,t,n){try{let{url:r}=await q1(e,t);n(r)}catch(e){let t=e instanceof Error?e.message:String(e);or.error(G._({id:`02P3hL`,values:{message:t}}))}}function v0(e){let t=(0,J.c)(13),{descriptor:n,values:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=e=>!(`hidden`in e&&e.hidden)&&e.hideWhen?.(r)!==!0&&e.type!==`reactnode`,t[0]=r,t[1]=a);let s=n.props.filter(a),c=s.filter(b0),l=s.filter(y0),u=g0(l,r),d;t[2]===n.props?d=t[3]:(d=X1(n.props),t[2]=n.props,t[3]=d);let f=d,p;t[4]===n.name?p=t[5]:(p=()=>m0(n.name),t[4]=n.name,t[5]=p);let[m,h]=(0,Y.useState)(p);if(s.length===0)return null;let g;t[6]!==f||t[7]!==i||t[8]!==r?(g=e=>(0,X.jsx)(S0,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),isAutoFocused:e.name===f},e.name),t[6]=f,t[7]=i,t[8]=r,t[9]=g):g=t[9];let _=c.map(g),v=l.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,X.jsxs)(dr,{open:m,onOpenChange:e=>{h(e),h0(n.name,e)},children:[(0,X.jsxs)(ur,{"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,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(Hi,{className:`size-3 transition-transform group-data-[state=closed]:-rotate-90`}),(0,X.jsx)(o,{id:`sxkWRg`})]}),u>0&&(0,X.jsx)(Sc,{variant:`secondary`,"data-prop-panel-advanced-count":``,children:u})]}),(0,X.jsx)(lr,{className:`flex flex-col gap-4 pt-2`,children:l.map(e=>(0,X.jsx)(S0,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),isAutoFocused:e.name===f},e.name))})]})]}),y;return t[10]!==_||t[11]!==v?(y=(0,X.jsxs)(`div`,{"data-prop-panel":``,className:`flex flex-col gap-4 py-2 text-sm`,children:[_,v]}),t[10]=_,t[11]=v,t[12]=y):y=t[12],y}function y0(e){return`advanced`in e&&e.advanced}function b0(e){return!(`advanced`in e&&e.advanced)}function x0(e){throw Error(`PropPanel: unhandled PropDef type ${JSON.stringify(e)}`)}function S0(e){let t=(0,J.c)(159),{propDef:n,value:r,onChange:i,isAutoFocused:a}=e;switch(n.type){case`reactnode`:return null;case`string`:{let e=`prop-${n.name}`,o=n.accept,s=o!==void 0&&o.length>0,c=!n.required&&n.defaultValue===void 0;if(n.language){let o=`${e}-label`,s;t[0]===n.name?s=t[1]:(s=Z1(n.name),t[0]=n.name,t[1]=s);let l;t[2]!==o||t[3]!==e||t[4]!==s?(l=(0,X.jsx)(`label`,{id:o,htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[2]=o,t[3]=e,t[4]=s,t[5]=l):l=t[5];let u=r??``,d;t[6]!==i||t[7]!==c?(d=e=>{if(e===``&&c){i(void 0);return}i(e)},t[6]=i,t[7]=c,t[8]=d):d=t[8];let f;t[9]!==a||t[10]!==o||t[11]!==n.language||t[12]!==e||t[13]!==u||t[14]!==d?(f=(0,X.jsx)(vZ,{id:e,ariaLabelledBy:o,value:u,language:n.language,onChange:d,autoFocus:a}),t[9]=a,t[10]=o,t[11]=n.language,t[12]=e,t[13]=u,t[14]=d,t[15]=f):f=t[15];let p;return t[16]!==l||t[17]!==f?(p=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l,f]}),t[16]=l,t[17]=f,t[18]=p):p=t[18],p}if(n.iconPicker){let o=r??``,s;t[19]===n.name?s=t[20]:(s=Z1(n.name),t[19]=n.name,t[20]=s);let l;t[21]!==e||t[22]!==s?(l=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[21]=e,t[22]=s,t[23]=l):l=t[23];let u;t[24]!==i||t[25]!==c?(u=e=>{if(e===``&&c){i(void 0);return}i(e)},t[24]=i,t[25]=c,t[26]=u):u=t[26];let d;t[27]!==o||t[28]!==a||t[29]!==e||t[30]!==u?(d=(0,X.jsx)(k1,{id:e,value:o,onChange:u,autoFocus:a}),t[27]=o,t[28]=a,t[29]=e,t[30]=u,t[31]=d):d=t[31];let f;return t[32]!==l||t[33]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l,d]}),t[32]=l,t[33]=d,t[34]=f):f=t[34],f}if(n.colorPicker){let o=r??``,s;t[35]===n.name?s=t[36]:(s=Z1(n.name),t[35]=n.name,t[36]=s);let l;t[37]!==e||t[38]!==s?(l=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[37]=e,t[38]=s,t[39]=l):l=t[39];let u;t[40]!==i||t[41]!==c?(u=e=>{if(e===``&&c){i(void 0);return}i(e)},t[40]=i,t[41]=c,t[42]=u):u=t[42];let d;t[43]!==o||t[44]!==a||t[45]!==e||t[46]!==u?(d=(0,X.jsx)(O1,{id:e,value:o,onChange:u,autoFocus:a}),t[43]=o,t[44]=a,t[45]=e,t[46]=u,t[47]=d):d=t[47];let f;return t[48]!==l||t[49]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l,d]}),t[48]=l,t[49]=d,t[50]=f):f=t[50],f}if(n.cssLengthInput){let o=r??``,s;if(t[51]!==o){let e=t0(o);s=e.valid?null:n0(e),t[51]=o,t[52]=s}else s=t[52];let l=s,u;t[53]===n.name?u=t[54]:(u=Z1(n.name),t[53]=n.name,t[54]=u);let d;t[55]!==e||t[56]!==u?(d=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:u}),t[55]=e,t[56]=u,t[57]=d):d=t[57];let f;t[58]!==i||t[59]!==c?(f=e=>{let t=e.target.value;if(t===``&&c){i(void 0);return}i(t)},t[58]=i,t[59]=c,t[60]=f):f=t[60];let p=a?``:void 0,m=l===null?void 0:!0,h=l===null?void 0:`${e}-error`,g;t[61]!==o||t[62]!==a||t[63]!==e||t[64]!==f||t[65]!==p||t[66]!==m||t[67]!==h?(g=(0,X.jsx)(cr,{id:e,type:`text`,value:o,placeholder:`100px, 50%, 26rem, auto`,onChange:f,autoFocus:a,"data-prop-autofocus":p,"aria-invalid":m,"aria-describedby":h,className:`h-7 text-sm`,"data-prop-css-length-input":``}),t[61]=o,t[62]=a,t[63]=e,t[64]=f,t[65]=p,t[66]=m,t[67]=h,t[68]=g):g=t[68];let _;t[69]!==l||t[70]!==e?(_=l!==null&&(0,X.jsx)(`p`,{id:`${e}-error`,"data-prop-css-length-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:l}),t[69]=l,t[70]=e,t[71]=_):_=t[71];let v;return t[72]!==d||t[73]!==g||t[74]!==_?(v=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[d,g,_]}),t[72]=d,t[73]=g,t[74]=_,t[75]=v):v=t[75],v}let l,u,d;if(t[76]!==o||t[77]!==r){let e=o===void 0?void 0:l0(o);l=r??``;let n=e===void 0?null:c0(l,e);u=n!==null&&!n.valid&&e!==void 0&&l.trim().length>0?f0(n,e):null,d=e===void 0?void 0:u0(e),t[76]=o,t[77]=r,t[78]=l,t[79]=u,t[80]=d}else l=t[78],u=t[79],d=t[80];let f=d,p;t[81]===n.name?p=t[82]:(p=Z1(n.name),t[81]=n.name,t[82]=p);let m;t[83]!==e||t[84]!==p?(m=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:p}),t[83]=e,t[84]=p,t[85]=m):m=t[85];let h;t[86]!==o||t[87]!==l||t[88]!==a||t[89]!==u||t[90]!==f||t[91]!==i||t[92]!==e||t[93]!==c?(h=o===void 0?(0,X.jsx)(cr,{id:e,type:`text`,value:l,placeholder:f,onChange:e=>{let t=e.target.value;if(t===``&&c){i(void 0);return}i(t)},autoFocus:a,"data-prop-autofocus":a?``:void 0,"aria-invalid":u===null?void 0:!0,"aria-describedby":u===null?void 0:`${e}-error`,className:`h-7 text-sm`}):(0,X.jsx)(H1,{id:e,value:l,onChange:e=>{if(e===``&&c){i(void 0);return}i(e)},accept:o,placeholder:f,autoFocus:a,dataPropAutofocus:a?``:void 0,ariaInvalid:u===null?void 0:!0,ariaDescribedBy:u===null?void 0:`${e}-error`,className:`h-7 text-sm`}),t[86]=o,t[87]=l,t[88]=a,t[89]=u,t[90]=f,t[91]=i,t[92]=e,t[93]=c,t[94]=h):h=t[94];let g;t[95]!==o||t[96]!==i||t[97]!==s?(g=s&&(0,X.jsx)(w0,{accept:o,onUploaded:e=>i(e)}),t[95]=o,t[96]=i,t[97]=s,t[98]=g):g=t[98];let _;t[99]!==h||t[100]!==g?(_=(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[h,g]}),t[99]=h,t[100]=g,t[101]=_):_=t[101];let v;t[102]!==u||t[103]!==e?(v=u!==null&&(0,X.jsx)(`p`,{id:`${e}-error`,"data-prop-media-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:u}),t[102]=u,t[103]=e,t[104]=v):v=t[104];let y;return t[105]!==m||t[106]!==_||t[107]!==v?(y=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[m,_,v]}),t[105]=m,t[106]=_,t[107]=v,t[108]=y):y=t[108],y}case`boolean`:{let e=`prop-${n.name}`,a;t[109]===n.name?a=t[110]:(a=Z1(n.name),t[109]=n.name,t[110]=a);let o=a,s;t[111]!==e||t[112]!==o?(s=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[111]=e,t[112]=o,t[113]=s):s=t[113];let c=!!r,l;t[114]===i?l=t[115]:(l=e=>i(e),t[114]=i,t[115]=l);let u;t[116]!==e||t[117]!==c||t[118]!==l?(u=(0,X.jsx)(E1,{id:e,checked:c,onCheckedChange:l}),t[116]=e,t[117]=c,t[118]=l,t[119]=u):u=t[119];let d;return t[120]!==s||t[121]!==u?(d=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s,u]}),t[120]=s,t[121]=u,t[122]=d):d=t[122],d}case`enum`:{let e=`prop-${n.name}`,a=r??n.enumValues[0]??``,o;t[123]===n.name?o=t[124]:(o=Z1(n.name),t[123]=n.name,t[124]=o);let s;t[125]!==e||t[126]!==o?(s=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[125]=e,t[126]=o,t[127]=s):s=t[127];let c;t[128]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(b1,{}),t[128]=c):c=t[128];let l;t[129]===e?l=t[130]:(l=(0,X.jsx)(x1,{id:e,size:`sm`,children:c}),t[129]=e,t[130]=l);let u;t[131]===n.enumValues?u=t[132]:(u=n.enumValues.map(C0),t[131]=n.enumValues,t[132]=u);let d;t[133]===u?d=t[134]:(d=(0,X.jsx)(S1,{className:`z-70`,children:u}),t[133]=u,t[134]=d);let f;t[135]!==a||t[136]!==i||t[137]!==l||t[138]!==d?(f=(0,X.jsxs)(y1,{value:a,onValueChange:i,children:[l,d]}),t[135]=a,t[136]=i,t[137]=l,t[138]=d,t[139]=f):f=t[139];let p;return t[140]!==s||t[141]!==f?(p=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,f]}),t[140]=s,t[141]=f,t[142]=p):p=t[142],p}case`number`:{let e=`prop-${n.name}`,a;t[143]===n.name?a=t[144]:(a=Z1(n.name),t[143]=n.name,t[144]=a);let o;t[145]!==e||t[146]!==a?(o=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:a}),t[145]=e,t[146]=a,t[147]=o):o=t[147];let s=r==null?``:String(r),c;t[148]===i?c=t[149]:(c=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[148]=i,t[149]=c);let l;t[150]!==e||t[151]!==s||t[152]!==c?(l=(0,X.jsx)(cr,{id:e,type:`number`,inputMode:`numeric`,value:s,onChange:c,className:`h-7 text-sm`}),t[150]=e,t[151]=s,t[152]=c,t[153]=l):l=t[153];let u;return t[154]!==o||t[155]!==l?(u=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[o,l]}),t[154]=o,t[155]=l,t[156]=u):u=t[156],u}default:{let e;return t[157]===n?e=t[158]:(e=x0(n),t[157]=n,t[158]=e),e}}}function C0(e){return(0,X.jsx)(C1,{value:e,children:e},e)}function w0(e){let t=(0,J.c)(20),{accept:n,onUploaded:r}=e,{_:a}=i(),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l;t[0]===n?l=t[1]:(l=n.join(`,`),t[0]=n,t[1]=l);let u;t[2]!==n||t[3]!==r?(u=async e=>{let t=e.target.files?.[0];if(t){s(!0);try{await _0(t,n,r)}catch{}s(!1),c.current&&(c.current.value=``)}},t[2]=n,t[3]=r,t[4]=u):u=t[4];let d;t[5]!==l||t[6]!==u?(d=(0,X.jsx)(`input`,{ref:c,type:`file`,accept:l,className:`hidden`,"data-prop-upload-input":``,onChange:u}),t[5]=l,t[6]=u,t[7]=d):d=t[7];let f;t[8]===a?f=t[9]:(f=a({id:`2IXDgU`}),t[8]=a,t[9]=f);let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>c.current?.click(),t[10]=p):p=t[10];let m;t[11]===o?m=t[12]:(m=o?(0,X.jsx)(Ta,{className:`size-3.5 animate-spin`}):(0,X.jsx)(qa,{className:`size-3.5`}),t[11]=o,t[12]=m);let h;t[13]!==f||t[14]!==m||t[15]!==o?(h=(0,X.jsx)(In,{type:`button`,variant:`outline`,size:`sm`,disabled:o,"aria-label":f,"data-prop-upload-trigger":``,className:`h-7 px-2`,onClick:p,children:m}),t[13]=f,t[14]=m,t[15]=o,t[16]=h):h=t[16];let g;return t[17]!==d||t[18]!==h?(g=(0,X.jsxs)(X.Fragment,{children:[d,h]}),t[17]=d,t[18]=h,t[19]=g):g=t[19],g}var T0=new Set([`img`,`CommonMarkImage`,`video`,`audio`]);function E0(e,t,n){if(!T0.has(e)||!n)return t;let r=t.src;if(typeof r!=`string`)return t;let i=ae(r,n);return i===r?t:{...t,src:i}}var D0=`selectionStatePlugin/origin`,O0=`selectionStatePlugin/refresh`,k0=new W(`selectionState`),A0=new Set,j0={selectedBlockId:null,ancestorChain:[],selectionOrigin:`programmatic`,isDragging:!1,rangeEncompassedBlockIds:A0};function M0(e){return k0.getState(e.state)??j0}function N0(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(P0(e,i,a))}if(t instanceof Ct){let r=t.node;r.type.name===`jsxComponent`&&n.push(P0(e,r,t.from))}return n}function P0(e,t,n){let r=t.attrs.componentName??`unknown`;return{bridgeId:F0(e,n),componentName:r,pos:n}}function F0(e,t){return IM.getState(e)?.posToId.get(t)??`pos-${t}`}function I0(e,t){if(t instanceof Ct)return A0;let{from:n,to:r}=t;if(n>=r)return A0;let i=IM.getState(e)?.posToId;if(!i)return A0;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??A0}function L0(e,t,n={}){let r=N0(e,e.selection),i=r[r.length-1],a=I0(e,e.selection),o={selectedBlockId:i?.bridgeId??null,ancestorChain:r,selectionOrigin:n.origin??t.selectionOrigin,isDragging:n.isDragging??t.isDragging,rangeEncompassedBlockIds:a};return R0(t,o)?t:o}function R0(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 z0=new WeakMap;function B0(e,t,n,r){let i=r?.isDragging??t.isDragging,a=!!e.getMeta(O0),o=e.selectionSet&&!a,s=e.getMeta(D0),c=o?r?.pendingOrigin??null:null,l=s??c??t.selectionOrigin;return o&&r&&(r.pendingOrigin=null),L0(n,t,{origin:l,isDragging:i})}var V0=Dt.create({name:`selectionStatePlugin`,addProseMirrorPlugins(){let e=this.editor,t=new U({key:k0,state:{init(e,t){return L0(t,j0)},apply(e,n,r,i){return B0(e,n,i,z0.get(t))}},props:{handleDOMEvents:{mousedown:()=>{let e=z0.get(t);return e&&(e.pendingOrigin=`pointer`),!1},pointerdown:()=>{let e=z0.get(t);return e&&(e.pendingOrigin=`pointer`),!1}},handleKeyDown:(e,n)=>{if(H0(n.key)){let e=z0.get(t);e&&(e.pendingOrigin=`keyboard`)}return!1}},view(n){z0.set(t,{pendingOrigin:null,isDragging:!1});let r=n.dom.parentElement??n.dom,i=()=>{let n=z0.get(t);n&&(n.isDragging=!0,U0(e))},a=()=>{let n=z0.get(t);n&&(n.isDragging=!1,U0(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),z0.delete(t)}}}});return[t]}});function H0(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 U0(e){queueMicrotask(()=>{if(!e.isDestroyed)try{let t=e.state.tr.setMeta(O0,!0);e.view.dispatch(t)}catch{}})}function W0(e){let t=(0,J.c)(5),n;t[0]===e?n=t[1]:(n=()=>e?M0(e):null,t[0]=e,t[1]=n);let[r,i]=(0,Y.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(!e){i(null);return}i(M0(e));let t=()=>{i(M0(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,Y.useEffect)(a,o),r}function G0(e,t){if(e.hasChildren)return!1;let n=X1(e.props);return n===null?!1:t[n]===``}function K0(e){let t=e.placeholder?.label,n=`Add ${(e.displayName??e.name).toLowerCase()}`;return{label:t??n,Icon:qO(e.placeholder?.icon??e.icon)}}var q0=new Set([`img`,`CommonMarkImage`,`Embed`,`video`]),J0=`img, .ok-embed, .ok-video`,Y0=220,X0=`cubic-bezier(0.23, 1, 0.32, 1)`,Z0=`ok-image-align-flip`,Q0=.5;function $0(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function e2(){return typeof requestAnimationFrame==`function`}function t2(e){return e?e.querySelector(J0):null}function n2(e,t){if($0()||!e2()){t();return}let n=t2(e);if(!n){t();return}let r=n.getBoundingClientRect().left;t(),requestAnimationFrame(()=>{let t=t2(e);if(!t)return;for(let e of t.getAnimations())e.id===Z0&&e.cancel();let n=r-t.getBoundingClientRect().left;if(Math.abs(n)<Q0)return;let i=t.animate([{transform:`translateX(${n}px)`},{transform:`translateX(0)`}],{duration:Y0,easing:X0,fill:`none`});i.id=Z0})}function r2(e){if(!e.attrs.sourceDirty&&e.attrs.sourceRaw)return e.attrs.sourceRaw;let t=lA(),n=e.type.schema.node(`doc`,null,[e]);return t.serialize(n.toJSON()).trim()}var i2=new Set(It.map(e=>`${e}:`)),a2=6e4,o2=10,s2=new Map;function c2(e,t){let n=t.toLowerCase();qe(n);let r=Date.now(),i=s2.get(n);if(!i||r-i.windowStart>=a2)s2.set(n,{windowStart:r,count:1});else if(i.count+=1,i.count>o2)return;typeof console<`u`&&typeof console.warn==`function`&&console.warn(JSON.stringify({event:`jsx-prop-dropped`,reason:e,prop:t}))}var l2=new Set([`href`,`src`,`action`,`formaction`,`poster`,`cite`,`data`,`manifest`,`background`,`ping`,`xlinkhref`,`xlinkactuate`,`xlinkrole`,`xlinkarcrole`,`xlinkshow`,`url`,`link`]),u2=new Set([`dangerouslysetinnerhtml`,`ref`,`key`,`defaultvalue`,`defaultchecked`,`__proto__`,`constructor`,`prototype`]),d2=1e4;function f2(e){let t=e.toLowerCase();return!!(u2.has(t)||t.length>=3&&t.startsWith(`on`))}function p2(e){return l2.has(e.toLowerCase())}function m2(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`//`)||C(t))return e;let n=t.indexOf(`:`),r=t.slice(0,n+1).toLowerCase();return i2.has(r)?e:`#`}function h2(e){if(e.length>d2)return``;let t=e.toLowerCase();return/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/.test(t)||/\bexpression\s*\(/.test(t)?``:e}function g2(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=g2(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(f2(e)){c2(`dangerous-prop-name-nested`,e),r=!0;continue}if(p2(e)&&typeof t==`string`){let n=m2(t);n!==t&&(r=!0),i[e]=n}else{let n=g2(t);n!==t&&(r=!0),i[e]=n}}return r?i:e}function _2(e){let t=!1,n={};for(let[r,i]of Object.entries(e)){if(f2(r)){c2(`dangerous-prop-name`,r),t=!0;continue}if(p2(r)){let e=m2(i);e!==i&&(t=!0),n[r]=e;continue}if(r===`style`){if(typeof i==`string`){let e=h2(i);e!==i&&(t=!0),n[r]=e}else t=!0;continue}let e=g2(i);e!==i&&(t=!0),n[r]=e}return t?n:e}function v2(e){let t=(0,J.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{className:`jsx-component-error-fallback`,children:n}),t[0]=n,t[1]=r),r}function y2(e){let t=(0,J.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})),cn(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,X.jsx)(v2,{...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,X.jsx)(h1,{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 b2(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(b2).join(`,`)}]`;let t=Object.entries(e);return t.sort(([e],[t])=>e<t?-1:+(e>t)),`{${t.map(([e,t])=>`${JSON.stringify(e)}:${b2(t)}`).join(`,`)}}`}function x2(e,t){let n=e.props??{},r={};for(let[e,i]of Object.entries(n))t.has(e)||(r[e]=i);return _2(r)}var S2=3;function C2(e){let t=(0,J.c)(161),{node:n,editor:r,extension:a,getPos:s,selected:c}=e,{_:l}=i(),u=sM(n.attrs.componentName),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(!1),h=(0,Y.useRef)(!1),g=typeof s==`function`?s():void 0,_=!1,v=0,y=1;try{if(g!==void 0){let e=r.state.doc.resolve(g);e.depth>0&&e.parent.type.name===`jsxComponent`&&(_=!0,v=e.index(e.depth),y=e.parent.childCount)}}catch(e){let t=e;if(!(t instanceof RangeError))throw t}let b=_&&v>0,x=_&&v<y-1,S=W0(r),C=typeof g==`number`?F0(r.state,g):null,w=C!==null&&(S?.rangeEncompassedBlockIds.has(C)??!1),T;t[0]===S?.ancestorChain?T=t[1]:(T=S?.ancestorChain.at(-1)?.bridgeId??null,t[0]=S?.ancestorChain,t[1]=T);let E=C!==null&&T===C,D=c&&!w&&E,O=C!==null&&!E&&(S?.ancestorChain.some(e=>e.bridgeId===C)??!1),k=D&&S?S.selectionOrigin:void 0,A=D&&(S?.isDragging??!1),j=u.props.some(k2),M=n.attrs.props??{},N=j&&u.props.some(e=>e.type!==`string`||!e.required||`hidden`in e&&e.hidden?!1:!Object.hasOwn(M,e.name)),P=G0(u,M),I=P?K0(u):null,L=!u.hasChildren||!!u.isSelfClosing,ee=q0.has(u.name),R=u.name===`MermaidFence`?{propName:`chart`,language:`mermaid`}:u.name===`Math`||u.name===`DollarMath`||u.name===`MathFence`?{propName:`formula`,language:`latex`}:null,[z,te]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{c&&!h.current&&j&&gM(g)&&m(!0),h.current=c},[c,j,g]);let B=x2(n.attrs,u.reactNodePropNames),ne=u.surface===`compat`?u.translateProps(B):B,V=a.options.docName,re=typeof V==`string`&&V?V:ZD(r),ie=E0(u.name,ne,re),H=`${u.name}::${b2(B)}`,ae;t[2]!==s||t[3]!==n.content.size?(ae=()=>(typeof s==`function`?s()??0:0)+1+n.content.size,t[2]=s,t[3]=n.content.size,t[4]=ae):ae=t[4];let oe=ae,U=u.name===`*`||d!==null,se=(0,Y.useRef)(!1),W=(0,Y.useRef)(0),[le,ue]=(0,Y.useState)(!1);if((0,Y.useEffect)(()=>{if(!U||se.current||le)return;let e=typeof s==`function`?s():void 0;if(typeof e!=`number`)return;let t=r2(n),i=u.name===`*`?`Unregistered component: ${n.attrs.componentName}`:`Render error in <${u.displayName??u.name}>: ${d?.message??`unknown`}`,a=n.type.schema.nodes.rawMdxFallback.create({reason:i},n.type.schema.text(t)),o=!1,c,l=()=>{if(!o)try{r.view.dispatch(r.state.tr.replaceWith(e,e+n.nodeSize,a)),se.current=!0,Vt(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:W.current})),ft(r),W.current+=1,W.current<S2){let e=50*(2**W.current-1);c=setTimeout(()=>{o||l()},e)}else o||ue(!0)}},f=requestAnimationFrame(l);return()=>{o=!0,cancelAnimationFrame(f),c!==void 0&&clearTimeout(c)}},[U,n,r,s,u,d,le]),le){let e=n.attrs.componentName,i=u.displayName??u.name,a=u.name===`*`?l({id:`Kh1n4a`,values:{componentName:e}}):l({id:`g58Kwy`,values:{descriptorLabel:i}}),o=()=>{try{let e=r2(n);typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e)}catch(e){let t=e;gn(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 s==`function`?s():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;et(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={[gF]:`true`},t[5]=d):d=t[5];let f;t[6]===a?f=t[7]:(f=(0,X.jsx)(`span`,{className:`flex-1`,children:a}),t[6]=a,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]!==o||t[11]!==p?(m=(0,X.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:o,children:p}),t[10]=o,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,X.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,X.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,X.jsx)(Ql,{className:`component-children`}),t[22]=v):v=t[22];let y;return t[23]===_?y=t[24]:(y=(0,X.jsxs)($l,{className:`jsx-component-wrapper my-2`,children:[_,v]}),t[23]=_,t[24]=y),y}if(U){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,X.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,X.jsx)(Ql,{className:`component-children`}),t[27]=o):o=t[27];let s;return t[28]===a?s=t[29]:(s=(0,X.jsxs)($l,{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(P||!L)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 g!=`number`)return;let n=r.state.doc.nodeAt(g);if(!n)return;let i=g+n.nodeSize,a=r.state.selection.from;a<g||a>=i||r.chain().focus().setNodeSelection(g).run()},ge;t[30]!==r||t[31]!==s?(ge=()=>{let e=typeof s==`function`?s():void 0;typeof e==`number`&&(r.chain().focus().setNodeSelection(e).run(),m(!0))},t[30]=r,t[31]=s,t[32]=ge):ge=t[32];let _e=ge,ve=u.displayName??u.name,ye=!!u.emptyChildName,be=ye?Y1(ve,u.emptyChildName,n.childCount):void 0,xe=e=>{let t=e.target;if(e.key===`Backspace`||e.key===`Delete`){if(!D||!e.currentTarget.contains(t)||t.matches(`input, textarea`))return;let i=typeof s==`function`?s():void 0;if(typeof i!=`number`)return;e.preventDefault();try{r.chain().focus().setNodeSelection(i).deleteSelection().run()||(Mt(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;Mt(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&&j&&(t.closest(`.jsx-component-chrome`)||t.closest(`input, textarea, select, button`)||(e.preventDefault(),m(!0)))},Se=e=>{m(e),!e&&requestAnimationFrame(()=>{let e=typeof s==`function`?s():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(L){let e=r.state.doc.resolve(Math.min(n,r.state.doc.content.size)),t=F.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;ht(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=Cc,we=$l,Te;t[33]===u.name?Te=t[34]:(Te=u.name.toLowerCase(),t[33]=u.name,t[34]=Te);let Ee;bb0:{let e=M.align;if(e===`left`||e===`right`||e===`center`){Ee=e;break bb0}if(ee){Ee=`center`;break bb0}Ee=void 0}let De=D?`true`:void 0,Oe=O?`true`:void 0,ke=w?`true`:void 0,Ae=A?`true`:void 0,je=N?`true`:void 0,Me=ye?`group`:void 0,Ne=D?0:-1,Pe;t[35]===_?Pe=t[36]:(Pe=_?{draggable:`false`,onDragStart:O2}:{"data-drag-handle":``,draggable:`true`},t[35]=_,t[36]=Pe);let Fe=u.name,Ie=D2,Le;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(Le={[gF]:`true`},t[37]=Le):Le=t[37];let G=ee&&[{value:`left`,label:l({id:`IR6Txi`}),Icon:Ga},{value:`center`,label:l({id:`8nOdkO`}),Icon:Ua},{value:`right`,label:l({id:`pd0UH2`}),Icon:Wa}].map(e=>{let{value:t,label:n,Icon:i}=e,a=typeof M.align==`string`?M.align:`center`,o=(a===`left`||a===`right`||a===`center`?a:`center`)===t;return(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":n,"aria-pressed":o,"data-active":o?`true`:void 0,onClick:e=>{if(typeof g!=`number`)return;let n=r.state.doc.nodeAt(g);if(!n||n.type.name!==`jsxComponent`)return;let i=e.currentTarget.closest(`.jsx-component-wrapper`),a=String(n.attrs.componentName??``);if(!q0.has(a)||n.attrs.kind!==`element`)return;let o=a===`CommonMarkImage`,s={...n.attrs.props,align:t},c=o?{...n.attrs,componentName:`img`,props:s,sourceDirty:!0}:{...n.attrs,props:s,sourceDirty:!0};n2(i,()=>{r.view.dispatch(r.state.tr.setNodeMarkup(g,null,c))})},children:(0,X.jsx)(i,{size:12,"aria-hidden":`true`})},t)}),Re=u.name===`Embed`&&typeof B.src==`string`&&/^https?:\/\//i.test(B.src)&&(0,X.jsx)(`a`,{href:B.src,target:`_blank`,rel:`noopener noreferrer`,className:`jsx-chrome-btn`,"aria-label":l({id:`iOHg1t`}),onMouseDown:E2,children:(0,X.jsx)($i,{size:12,"aria-hidden":`true`})}),ze=u.name===`Mirror`&&typeof B.src==`string`&&B.src.length>0&&(()=>{let e=B.src;return(0,X.jsx)(`a`,{href:ce(e,typeof B.anchor==`string`&&B.anchor.length>0?B.anchor:null),className:`jsx-chrome-btn`,"aria-label":l({id:`3a_Bd7`,values:{mirrorSrc:e}}),title:l({id:`0kTAXe`,values:{mirrorSrc:e}}),onMouseDown:T2,children:(0,X.jsx)($i,{size:12,"aria-hidden":`true`})})})(),Be;t[38]!==l||t[39]!==b||t[40]!==u.name||t[41]!==r||t[42]!==n.attrs.componentName||t[43]!==n.nodeSize||t[44]!==g?(Be=b&&(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`QyioBP`}),onClick:()=>{try{if(typeof g!=`number`)return;let e=r.state.doc.resolve(g),t=e.index(e.depth);if(t===0)return;let i=g-e.node(e.depth).child(t-1).nodeSize,a=g+n.nodeSize,o=r.state.tr,s=r.state.doc.slice(g,g+n.nodeSize),c=r.state.doc.slice(i,g);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;_t(`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,X.jsx)(Li,{size:12,"aria-hidden":`true`})}),t[38]=l,t[39]=b,t[40]=u.name,t[41]=r,t[42]=n.attrs.componentName,t[43]=n.nodeSize,t[44]=g,t[45]=Be):Be=t[45];let Ve;t[46]!==l||t[47]!==x||t[48]!==u.name||t[49]!==r||t[50]!==n.attrs.componentName||t[51]!==n.nodeSize||t[52]!==g?(Ve=x&&(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`3Ib6FN`}),onClick:()=>{try{if(typeof g!=`number`)return;let e=r.state.doc.resolve(g),t=e.index(e.depth),i=e.node(e.depth);if(t>=i.childCount-1)return;let a=i.child(t+1),o=g,s=g+n.nodeSize+a.nodeSize,c=r.state.tr,l=r.state.doc.slice(g,g+n.nodeSize),u=r.state.doc.slice(g+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;_t(`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,X.jsx)(Ii,{size:12,"aria-hidden":`true`})}),t[46]=l,t[47]=x,t[48]=u.name,t[49]=r,t[50]=n.attrs.componentName,t[51]=n.nodeSize,t[52]=g,t[53]=Ve):Ve=t[53];let He;t[54]!==l||t[55]!==u.displayName||t[56]!==u.name||t[57]!==R||t[58]!==g||t[59]!==te?(He=R&&typeof g==`number`?(0,X.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:()=>te(!0),children:(0,X.jsx)(Ma,{size:12,"aria-hidden":`true`})}):null,t[54]=l,t[55]=u.displayName,t[56]=u.name,t[57]=R,t[58]=g,t[59]=te,t[60]=He):He=t[60];let Ue;t[61]!==l||t[62]!==fe?(Ue=l({id:`MCjC9A`,values:{deleteDescriptorLabel:fe}}),t[61]=l,t[62]=fe,t[63]=Ue):Ue=t[63];let We;t[64]!==u.name||t[65]!==r||t[66]!==n.attrs.componentName||t[67]!==g?(We=()=>{if(typeof g==`number`)try{r.chain().focus().setNodeSelection(g).deleteSelection().run()||(Mt(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;Mt(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[64]=u.name,t[65]=r,t[66]=n.attrs.componentName,t[67]=g,t[68]=We):We=t[68];let Ge;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,X.jsx)(Ka,{size:12,"aria-hidden":`true`}),t[69]=Ge):Ge=t[69];let Ke;t[70]!==Ue||t[71]!==We?(Ke=(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":Ue,onClick:We,children:Ge}),t[70]=Ue,t[71]=We,t[72]=Ke):Ke=t[72];let qe;t[73]!==l||t[74]!==j||t[75]!==pe?(qe=j&&(0,X.jsx)(wc,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`XPJ0sN`,values:{settingsDescriptorLabel:pe}}),children:(0,X.jsx)(Ia,{size:12,"aria-hidden":`true`})})}),t[73]=l,t[74]=j,t[75]=pe,t[76]=qe):qe=t[76];let Je;t[77]!==Ie||t[78]!==Le||t[79]!==G||t[80]!==Re||t[81]!==ze||t[82]!==Be||t[83]!==Ve||t[84]!==He||t[85]!==Ke||t[86]!==qe?(Je=(0,X.jsxs)(`div`,{className:`jsx-component-chrome`,contentEditable:!1,onMouseDown:Ie,...Le,children:[G,Re,ze,Be,Ve,He,Ke,qe]}),t[77]=Ie,t[78]=Le,t[79]=G,t[80]=Re,t[81]=ze,t[82]=Be,t[83]=Ve,t[84]=He,t[85]=Ke,t[86]=qe,t[87]=Je):Je=t[87];let Ye;t[88]!==de||t[89]!==u.emptyChildName||t[90]!==u.hasChildren||t[91]!==u.isSelfClosing||t[92]!==u.name||t[93]!==r||t[94]!==s||t[95]!==oe||t[96]!==D||t[97]!==n.attrs.componentName||t[98]!==n.childCount||t[99]!==_e||t[100]!==ie||t[101]!==H||t[102]!==I||t[103]!==f||t[104]!==P?(Ye=P&&I?(0,X.jsx)(Ec,{asChild:!0,children:(0,X.jsx)(_1,{label:I.label,Icon:I.Icon,onClick:_e,selected:D})}):(0,X.jsx)(y2,{resetKey:H,onError:f,descriptorName:u.name===`*`?`wildcard`:u.name,rawComponentName:n.attrs.componentName??``,children:(0,X.jsx)(ok,{value:typeof s==`function`?{editor:r,getPos:()=>{let e=s();return typeof e==`number`?e:void 0},addChild:u.emptyChildName?()=>{let e=u.emptyChildName,t=pM(e),n=oe();r.chain().focus().insertContentAt(n,t).run(),_M(r,n,sM(e))}:null}:null,children:(0,X.jsx)(de,{...ie,children:(0,X.jsx)(Ql,{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]=s,t[95]=oe,t[96]=D,t[97]=n.attrs.componentName,t[98]=n.childCount,t[99]=_e,t[100]=ie,t[101]=H,t[102]=I,t[103]=f,t[104]=P,t[105]=Ye):Ye=t[105];let Xe;t[106]!==u.emptyChildName||t[107]!==u.name||t[108]!==r||t[109]!==oe||t[110]!==n.childCount?(Xe=u.emptyChildName&&!(u.name===`Tabs`&&n.childCount>0)&&(()=>{let e=u.emptyChildName;return(0,X.jsx)(`button`,{type:`button`,contentEditable:!1,className:n.childCount===0?`jsx-empty-child-placeholder`:`jsx-add-child-pill`,onMouseDown:w2,onClick:()=>{let e=u.emptyChildName,t=pM(e),n=oe();r.chain().focus().insertContentAt(n,t).run(),_M(r,n,sM(e))},"data-clipboard-omit":`true`,children:(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`7Fkcej`,values:{addChildName:e}})})})})(),t[106]=u.emptyChildName,t[107]=u.name,t[108]=r,t[109]=oe,t[110]=n.childCount,t[111]=Xe):Xe=t[111];let Ze;t[112]!==we||t[113]!==u.name||t[114]!==be||t[115]!==he||t[116]!==xe||t[117]!==k||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]!==Je||t[129]!==Ye||t[130]!==Xe?(Ze=(0,X.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":k,"data-dragging":Ae,"data-needs-config":je,role:Me,"aria-label":be,tabIndex:Ne,...Pe,"data-component-name":Fe,onClick:he,onKeyDown:xe,children:[Je,Ye,Xe]}),t[112]=we,t[113]=u.name,t[114]=be,t[115]=he,t[116]=xe,t[117]=k,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]=Je,t[129]=Ye,t[130]=Xe,t[131]=Ze):Ze=t[131];let Qe;t[132]!==l||t[133]!==M||t[134]!==u.Component||t[135]!==u.displayName||t[136]!==u.name||t[137]!==z||t[138]!==R||t[139]!==r||t[140]!==s||t[141]!==g||t[142]!==ie||t[143]!==te?(Qe=R&&typeof g==`number`?(0,X.jsx)(bZ,{open:z,onOpenChange:te,initialValue:typeof M[R.propName]==`string`?M[R.propName]:``,language:R.language,title:l({id:`ky9Tuc`,values:{0:u.displayName??u.name}}),renderPreview:e=>{let t=u.Component;return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center p-4`,children:(0,X.jsx)(t,{...ie,[R.propName]:e})})},onSave:e=>{let t=typeof s==`function`?s():void 0;if(typeof t!=`number`)return;let n=r.state.doc.nodeAt(t);if(n&&n.attrs.kind===`element`)try{let i={...n.attrs.props??{},[R.propName]:e},a={...n.attrs,props:i,sourceDirty:!0};r.view.dispatch(r.state.tr.setNodeMarkup(t,null,a))}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]=M,t[134]=u.Component,t[135]=u.displayName,t[136]=u.name,t[137]=z,t[138]=R,t[139]=r,t[140]=s,t[141]=g,t[142]=ie,t[143]=te,t[144]=Qe):Qe=t[144];let $e;t[145]!==u||t[146]!==r||t[147]!==s||t[148]!==j||t[149]!==L||t[150]!==B||t[151]!==me||t[152]!==P?($e=j&&(0,X.jsxs)(Tc,{side:P?`bottom`:`right`,align:P?`center`:`start`,sideOffset:P?-4:8,className:`w-64 p-3 z-[60] overflow-y-auto subtle-scrollbar max-h-[calc(100vh-2rem)] overscroll-contain`,onCloseAutoFocus:L?e=>{e.preventDefault(),r.view.focus()}:void 0,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,X.jsx)(o,{id:`Mnavhe`,values:{propPanelDescriptorLabel:me}})}),(0,X.jsx)(v0,{descriptor:u,values:B,onChange:(e,t)=>{let n=typeof s==`function`?s():void 0;if(typeof n!=`number`)return;let i=r.state.doc.nodeAt(n);if(!i||i.attrs.kind!==`element`)return;let a={...i.attrs.props??{}},o=Array.isArray(i.attrs.attributes)?i.attrs.attributes:[],c=o;t===void 0?(delete a[e],c=o.filter(t=>!(typeof t==`object`&&t&&t.type===`mdxJsxAttribute`&&t.name===e))):a[e]=t,r.view.dispatch(r.state.tr.setNodeMarkup(n,null,{...i.attrs,attributes:c,props:a,sourceDirty:!0}))}})]}),t[145]=u,t[146]=r,t[147]=s,t[148]=j,t[149]=L,t[150]=B,t[151]=me,t[152]=P,t[153]=$e):$e=t[153];let tt;return t[154]!==Ce||t[155]!==Se||t[156]!==p||t[157]!==Ze||t[158]!==Qe||t[159]!==$e?(tt=(0,X.jsxs)(Ce,{open:p,onOpenChange:Se,children:[Ze,Qe,$e]}),t[154]=Ce,t[155]=Se,t[156]=p,t[157]=Ze,t[158]=Qe,t[159]=$e,t[160]=tt):tt=t[160],tt}function w2(e){return e.stopPropagation()}function T2(e){return e.stopPropagation()}function E2(e){return e.stopPropagation()}function D2(e){return e.stopPropagation()}function O2(e){return e.preventDefault()}function k2(e){return!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`}var A2=Me.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return su(C2)}}),j2={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`}]},M2=(0,Y.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-DX-tM4Fr.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,J.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,X.jsx)(`span`,{className:`math math-inline`,dangerouslySetInnerHTML:{__html:i}}),n[2]=i,n[3]=a),a}return{default:t}});function N2(){let e=(0,J.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.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 P2(e){let t=(0,J.c)(2),n;return t[0]===e.formula?n=t[1]:(n=(0,X.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 F2(e){let t=(0,J.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,Y.useState)(!1),d=(0,Y.useRef)(!1),f;t[0]!==a.state||t[1]!==i||t[2]!==r?(f=()=>{let e=r&&a.state.selection instanceof Ct;e&&!d.current?(gM(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,Y.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,X.jsx)(h1,{resetKeys:[s],onError:L2,fallbackRender:()=>(0,X.jsx)(`span`,{className:`math math-inline math-error`,children:s}),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(P2,{formula:s}),children:(0,X.jsx)(M2,{formula:s})})}):(0,X.jsx)(N2,{}),t[10]=s,t[11]=g);let _;t[12]!==s||t[13]!==h||t[14]!==g?(_=(0,X.jsx)(wc,{asChild:!0,children:(0,X.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,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground px-3 pt-2`,children:(0,X.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(Ct.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,X.jsx)(v0,{descriptor:j2,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,X.jsxs)(Tc,{className:`z-[60] w-72 p-0`,side:`bottom`,align:`start`,onOpenAutoFocus:I2,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,X.jsxs)(Cc,{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,X.jsx)($l,{as:`span`,className:m,children:w}),t[35]=w,t[36]=m,t[37]=T):T=t[37],T}function I2(e){e.preventDefault()}function L2(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})),cn(`mathInline`)}var R2=qt.extend({addNodeView(){return su(F2)}});function z2(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=ge.near(e.doc.resolve(i),n);return a.$head?.parent.type.name===`rawMdxFallback`?a:null}function B2(e,t){let{state:n,view:r}=e;if(!r.endOfTextblock(t))return!1;let i=z2(n,t);return i?(r.dispatch(n.tr.setSelection(i)),!0):!1}var V2=xt.extend({addKeyboardShortcuts(){return{ArrowLeft:({editor:e})=>B2(e,`left`),ArrowRight:({editor:e})=>B2(e,`right`),ArrowUp:({editor:e})=>B2(e,`up`),ArrowDown:({editor:e})=>B2(e,`down`)}},addNodeView(){return su(pZ,{stopEvent:()=>!0,ignoreMutation:()=>!0})}});function H2(e){let t=(0,J.c)(51),{items:n,selectedIndex:r,categoryLabels:a,onSelect:s,onHoverIndex:c}=e,l=(0,Y.useRef)(null),u=(0,Y.useId)(),{_:d}=i(),f=r>=0&&r<n.length?`${u}-option-${r}`:void 0,p=W2,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,Y.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,X.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,X.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]!==a||t[8]!==n||t[9]!==u||t[10]!==c||t[11]!==s||t[12]!==r){let e=[],i=0,o=new Map;for(let t of n){o.set(t,i++);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(U2),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,X.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:h}),t[31]=h,t[32]=y),b=e.map(e=>(0,X.jsxs)(`div`,{role:`group`,"aria-labelledby":`${u}-group-${e.key}`,children:[(0,X.jsx)(`div`,{id:`${u}-group-${e.key}`,className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground`,children:a[e.key]??e.key}),e.items.map(e=>{let t=o.get(e)??0,n=t===r,i=e.icon;return(0,X.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(),s(e)},children:[(0,X.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`div`,{className:`flex flex-col min-w-0`,children:(0,X.jsx)(`span`,{className:`truncate`,children:e.label})})]},e.name)})]},e.key)),t[5]=d,t[6]=f,t[7]=a,t[8]=n,t[9]=u,t[10]=c,t[11]=s,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,X.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,X.jsx)(`aside`,{"aria-hidden":`true`,onMouseDown:p,className:`w-64 rounded-lg border bg-popover p-2 shadow-md ${_?.preview?``:`invisible`}`,children:_?.preview?(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(`p`,{className:`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,X.jsxs)(`div`,{className:x,children:[k,A]}),t[47]=x,t[48]=k,t[49]=A,t[50]=j):j=t[50],j}function U2(e){return e.preview}function W2(e){return e.preventDefault()}var G2=new W(`slashCommand`),K2=Dt.create({name:`slashCommand`,addOptions(){return{itemsSources:[AM],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[Qy({editor:this.editor,pluginKey:G2,char:`/`,startOfLine:!1,allow:({editor:e})=>!ab(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 jM(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=ob(()=>n,`slash-command`);i.popup=c.popup,a=c.doPosition,t=new au(H2,{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(){sb(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}}),q2=new W(`sourceDirty`),J2=Dt.create({name:`sourceDirtyObserver`,addProseMirrorPlugins(){return[new U({key:q2,appendTransaction(e,t,n){if(!e.some(e=>!e.getMeta(qv))||!e.some(e=>e.docChanged))return null;let r=new ie;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=!Y2(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 Y2(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(!Y2(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(!Y2(e[r],t[r]))return!1;return!0}function X2(e,t){let n=e.doc.nodeAt(t);if(!n||n.type.name!==`table`)return null;let r=bt.get(n);return{map:r,tableStart:t+1,table:n,left:0,top:0,right:r.width,bottom:r.height}}function Z2(e,t){let n=X2(e,t);return n?Xe(e.tr,n,n.map.width):null}function Q2(e,t){let n=X2(e,t);return n?Ft(e.tr,n,n.map.height):null}function $2(e,t){if(!e.dom.contains(t))return null;let n;try{n=e.posAtDOM(t,0)}catch{return null}return n<0?null:Yt(e.state.doc.resolve(n))?.pos??null}var e4=`<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 t4(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(gF,`true`),n.innerHTML=e4,n.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()}),n}var n4=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(gF,`true`);let n=t4(`column`,`Add column`),r=t4(`row`,`Add row`);n.addEventListener(`click`,()=>this.insert(e,Z2)),r.addEventListener(`click`,()=>this.insert(e,Q2)),t.append(n,r),this.mount.appendChild(t);let i=Ut(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=$2(this.view,n);if(r===null)return;let i=t(this.view.state,r);i&&(this.view.dispatch(i),this.view.focus())}},r4=Dt.create({name:`tableInsertControls`,addProseMirrorPlugins(){let e=this.editor;return[new U({key:new W(`tableInsertControls`),view:t=>new n4(t,e)})]}}),i4=`ok:tag-click`;function a4(e){if(typeof document>`u`)return;let t={value:e};document.dispatchEvent(new CustomEvent(i4,{detail:t}))}function o4(e){return e instanceof Element?e.closest(`a[data-tag]`):null}var s4=Dt.create({name:`tagClick`,addProseMirrorPlugins(){return[new U({props:{handleDOMEvents:{click(e,t){let n=o4(t.target);if(!n)return!1;let r=n.getAttribute(`data-tag`);return r?(t.preventDefault(),t.stopPropagation(),a4(r),!0):!1}}}})]}});function c4(e,t,n){if(typeof t!=`number`||!n||!ee.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(F.create(o.doc,s+1)),i.dispatch(o),i.focus(),!0}function l4(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 u4(e){let t=(0,J.c)(3),{value:n}=e,r=`#tag/${n}`,i;return t[0]!==r||t[1]!==n?(i=(0,X.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 d4(e){let t=(0,J.c)(20),{initialDraft:n,onCommit:r,onCancel:a}=e,{_:o}=i(),s=(0,Y.useRef)(null),[c,l]=(0,Y.useState)(n),u=(0,Y.useRef)(!1),d,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=requestAnimationFrame(()=>{s.current?.focus()});return()=>cancelAnimationFrame(e)},f=[],t[0]=d,t[1]=f):(d=t[0],f=t[1]),(0,Y.useEffect)(d,f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.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]===o?h=t[4]:(h=o({id:`U2pMtf`}),t[3]=o,t[4]=h);let g;t[5]===o?g=t[6]:(g=o({id:`knjOzA`}),t[5]=o,t[6]=g);let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{let t=e.target.value;(t===``||ee.test(t))&&l(t)},t[7]=_):_=t[7];let v,y;t[8]!==c||t[9]!==a||t[10]!==r?(v=e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),u.current=!0,r(c)||(u.current=!1,a())):(e.key===`Escape`||e.key===`Backspace`&&c===``)&&(e.preventDefault(),a())},y=()=>{if(!u.current){if(c===``){a();return}ee.test(c)?r(c):a()}},t[8]=c,t[9]=a,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,X.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,X.jsx)(`input`,{ref:s,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 f4(e){let t=(0,J.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,X.jsx)($l,{as:`span`,children:(0,X.jsx)(d4,{initialDraft:``,onCommit:e=>c4(i,typeof r==`function`?r():void 0,e),onCancel:()=>l4(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,X.jsx)($l,{as:`span`,children:(0,X.jsx)(u4,{value:a})}),t[3]=a,t[4]=o),o}var p4=jt.extend({priority:200,addNodeView(){return su(f4)},addKeyboardShortcuts(){return{Backspace:()=>{if(cb.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(cb.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[hb(this.editor)]}}),m4=2048,h4=24;function g4(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>m4)return{kind:`unsupported`,value:``};if(y4(t))return{kind:`emoji`,value:t};let n=b4(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:Re(`/api/asset?path=${encodeURIComponent(v4(t))}`)}:{kind:`unsupported`,value:``}}function _4(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>m4)return{kind:`unsupported`,value:``};let n=b4(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:Re(`/api/asset?path=${encodeURIComponent(v4(t))}`)}:{kind:`unsupported`,value:``}}function v4(e){return e.startsWith(`/`)?e.slice(1):e}function y4(e){if(/\p{L}/u.test(e)||e.includes(`/`))return!1;let t=0;for(let n of e)t++;if(t>h4)return!1;let n=e.lastIndexOf(`.`);if(n>-1){let t=e.slice(n+1).toLowerCase();if(Fe.has(t))return!1}return!0}function b4(e){let t=x4(e);if(!t||!Fe.has(t))return`unsupported`;let n=e.indexOf(`:`),r=e.indexOf(`/`);return n>-1&&(r===-1||n<r)?me(e)?`url`:`unsupported`:e.startsWith(`//`)||e.includes(`?`)||e.includes(`#`)||e.startsWith(`../`)||e.includes(`/../`)?`unsupported`:`path`}function x4(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 S4(e){let t=(0,J.c)(131),{open:n,target:r,alias:a,anchor:s,pages:c,assetPaths:l,loading:u,onOpenChange:d,onSave:f}=e,[p,m]=(0,Y.useState)(r),[h,g]=(0,Y.useState)(a??``),[_,v]=(0,Y.useState)(s??``),y=(0,Y.useId)(),b=(0,Y.useId)(),x=(0,Y.useId)(),S=(0,Y.useId)(),{_:C}=i(),w;t[0]!==l||t[1]!==p?(w=cO(p,l),t[0]=l,t[1]=p,t[2]=w):w=t[2];let T=w,E;t[3]!==l||t[4]!==p||t[5]!==c?(E=lO(p,c,l),t[3]=l,t[4]=p,t[5]=c,t[6]=E):E=t[6];let D=r1(p,E&&!T&&n),O=(0,Y.useRef)(!1),k,A;t[7]!==a||t[8]!==s||t[9]!==n||t[10]!==r?(k=()=>{if(!n){O.current=!1;return}O.current||(O.current=!0,m(r),g(a??``),v(s??``))},A=[n,r,a,s],t[7]=a,t[8]=s,t[9]=n,t[10]=r,t[11]=k,t[12]=A):(k=t[11],A=t[12]),(0,Y.useEffect)(k,A);let j;t[13]!==h||t[14]!==_||t[15]!==p||t[16]!==d||t[17]!==f?(j=function(){let e=p.trim();e&&(f(e,h.trim()||null,_.trim()||null),d(!1))},t[13]=h,t[14]=_,t[15]=p,t[16]=d,t[17]=f,t[18]=j):j=t[18];let M=j,N;t[19]===M?N=t[20]:(N=function(e){e.key===`Enter`&&(e.preventDefault(),M())},t[19]=M,t[20]=N);let P=N,F;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(F=function(e){m(e.path),v(``)},t[21]=F):F=t[21];let I=F,L,ee,R,z,te,B,ne,V,re,ie,H,ae,oe,U,se,ce,W;if(t[22]!==C||t[23]!==x||t[24]!==b||t[25]!==l||t[26]!==h||t[27]!==_||t[28]!==p||t[29]!==P||t[30]!==S||t[31]!==D||t[32]!==u||t[33]!==d||t[34]!==n||t[35]!==c||t[36]!==y){let e=new Map,r=D?.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;R=rr,U=n,se=d,ee=Yn,V=`sm:max-w-xl`,re=``,ie=V$,H=V$,ae=V$;let a;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Wn,{children:(0,X.jsx)(o,{id:`xzktOa`})}),t[54]=a):a=t[54],t[55]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,X.jsxs)(nr,{children:[a,(0,X.jsx)(Hn,{children:(0,X.jsx)(o,{id:`Jhj_lh`})})]}),t[55]=oe):oe=t[55],L=Qn,te=`space-y-6`;let s;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(o,{id:`lGs_bQ`,components:{0:(0,X.jsx)(`span`,{className:`text-red-500`})}}),t[56]=s):s=t[56];let f;t[57]===y?f=t[58]:(f=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:y,children:s}),t[57]=y,t[58]=f);let w;t[59]===C?w=t[60]:(w=C({id:`aM23Wr`}),t[59]=C,t[60]=w);let T;t[61]!==l||t[62]!==p||t[63]!==P||t[64]!==u||t[65]!==c||t[66]!==w||t[67]!==y?(T=(0,X.jsx)(W$,{id:y,value:p,pages:c,assetPaths:l,includeAssets:!0,loading:u,onValueChange:m,onSuggestionSelect:I,placeholder:w,autoFocus:!0,"aria-required":`true`,onKeyDown:P}),t[61]=l,t[62]=p,t[63]=P,t[64]=u,t[65]=c,t[66]=w,t[67]=y,t[68]=T):T=t[68],t[69]!==f||t[70]!==T?(B=(0,X.jsxs)(`div`,{children:[f,T]}),t[69]=f,t[70]=T,t[71]=B):B=t[71];let E;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,X.jsx)(o,{id:`OTF92M`,components:{0:(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[72]=E):E=t[72];let O;t[73]===x?O=t[74]:(O=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:x,children:E}),t[73]=x,t[74]=O);let k;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>g(e.target.value),t[75]=k):k=t[75];let A;t[76]===C?A=t[77]:(A=C({id:`BH56dn`}),t[76]=C,t[77]=A);let j;t[78]!==x||t[79]!==h||t[80]!==P||t[81]!==A?(j=(0,X.jsx)(cr,{id:x,value:h,onChange:k,placeholder:A,onKeyDown:P}),t[78]=x,t[79]=h,t[80]=P,t[81]=A,t[82]=j):j=t[82],t[83]!==O||t[84]!==j?(ne=(0,X.jsxs)(`div`,{children:[O,j]}),t[83]=O,t[84]=j,t[85]=ne):ne=t[85];let M;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(o,{id:`Tjc1pH`,components:{0:(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[86]=M):M=t[86],t[87]===b?ce=t[88]:(ce=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:b,children:M}),t[87]=b,t[88]=ce);let N;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>v(e.target.value),t[89]=N):N=t[89];let F;t[90]===C?F=t[91]:(F=C({id:`W-ntoW`}),t[90]=C,t[91]=F),t[92]!==b||t[93]!==_||t[94]!==P||t[95]!==F?(W=(0,X.jsx)(cr,{id:b,value:_,onChange:N,placeholder:F,onKeyDown:P}),t[92]=b,t[93]=_,t[94]=P,t[95]=F,t[96]=W):W=t[96],z=i&&(0,X.jsx)(`div`,{id:S,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,X.jsxs)(`button`,{type:`button`,"aria-pressed":_===e.slug,className:Sn(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,_===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>v(_===e.slug?``:e.slug),children:[(0,X.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,X.jsx)(`span`,{className:`truncate`,children:e.text})]},e.reactKey))}),t[22]=C,t[23]=x,t[24]=b,t[25]=l,t[26]=h,t[27]=_,t[28]=p,t[29]=P,t[30]=S,t[31]=D,t[32]=u,t[33]=d,t[34]=n,t[35]=c,t[36]=y,t[37]=L,t[38]=ee,t[39]=R,t[40]=z,t[41]=te,t[42]=B,t[43]=ne,t[44]=V,t[45]=re,t[46]=ie,t[47]=H,t[48]=ae,t[49]=oe,t[50]=U,t[51]=se,t[52]=ce,t[53]=W}else L=t[37],ee=t[38],R=t[39],z=t[40],te=t[41],B=t[42],ne=t[43],V=t[44],re=t[45],ie=t[46],H=t[47],ae=t[48],oe=t[49],U=t[50],se=t[51],ce=t[52],W=t[53];let le;t[97]!==z||t[98]!==ce||t[99]!==W?(le=(0,X.jsxs)(`div`,{children:[ce,W,z]}),t[97]=z,t[98]=ce,t[99]=W,t[100]=le):le=t[100];let ue;t[101]!==te||t[102]!==B||t[103]!==ne||t[104]!==le?(ue=(0,X.jsxs)(`div`,{className:te,children:[B,ne,le]}),t[101]=te,t[102]=B,t[103]=ne,t[104]=le,t[105]=ue):ue=t[105];let de;t[106]!==L||t[107]!==ue?(de=(0,X.jsx)(L,{children:ue}),t[106]=L,t[107]=ue,t[108]=de):de=t[108];let fe;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,X.jsx)(tr,{asChild:!0,children:(0,X.jsx)(In,{variant:`outline`,children:(0,X.jsx)(o,{id:`dEgA5A`})})}),t[109]=fe):fe=t[109];let pe;t[110]===p?pe=t[111]:(pe=p.trim(),t[110]=p,t[111]=pe);let me=!pe,he;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,X.jsx)(o,{id:`tfDRzk`}),t[112]=he):he=t[112];let ge;t[113]!==M||t[114]!==me?(ge=(0,X.jsxs)($n,{children:[fe,(0,X.jsx)(In,{onClick:M,disabled:me,children:he})]}),t[113]=M,t[114]=me,t[115]=ge):ge=t[115];let _e;t[116]!==ee||t[117]!==V||t[118]!==re||t[119]!==ie||t[120]!==H||t[121]!==ae||t[122]!==oe||t[123]!==de||t[124]!==ge?(_e=(0,X.jsxs)(ee,{className:V,"data-ok-layer-spawned":re,onPointerDownOutside:ie,onFocusOutside:H,onInteractOutside:ae,children:[oe,de,ge]}),t[116]=ee,t[117]=V,t[118]=re,t[119]=ie,t[120]=H,t[121]=ae,t[122]=oe,t[123]=de,t[124]=ge,t[125]=_e):_e=t[125];let ve;return t[126]!==R||t[127]!==U||t[128]!==se||t[129]!==_e?(ve=(0,X.jsx)(R,{open:U,onOpenChange:se,children:_e}),t[126]=R,t[127]=U,t[128]=se,t[129]=_e,t[130]=ve):ve=t[130],ve}function C4(e){let t=(0,J.c)(115),{editor:n,getPos:r,onClose:a,onNavigate:s}=e,c=r(),l=c==null?null:n.state.doc.nodeAt(c),u=String(l?.attrs.target??``),d=Ee(l?.attrs.alias),f=Ee(l?.attrs.anchor),p=Lt({target:u,alias:d,anchor:f}),{addPage:m,assetPaths:h,folderPaths:g,pages:_,pagesBySlug:v,pagesByBasename:y,loading:b}=yt(),x=O(u,f),S=x?.kind===`external`?x:null,C=x?.kind===`asset`?cO(x.url,h)??x.url.replace(/^\//,``):null,w=C?null:VY(u,{pages:_,folderPaths:g,pagesBySlug:v,pagesByBasename:y,fallbackTargets:iO(u)}),[T,E]=(0,Y.useState)(!1),[D,k]=(0,Y.useState)(!1),{_:A}=i();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]!==a?(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)),a())},t[4]=n.state,t[5]=n.view,t[6]=r,t[7]=a,t[8]=N):N=t[8];let F=N,I=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}))}},L=function(){return w?.kind===`create`?{initialDir:w.initialDir,suggestedName:w.suggestedName}:null},ee=async function(){let e=L();if(!(!e||D)){k(!0);try{await k$(e,{addPage:m,onCreated(e){I(e),window.location.hash=`#/${e}`,a()}}),k(!1)}catch(e){let t=e;or.error(t instanceof Error?t.message:A({id:`tfi40B`})),k(!1)}}},R=!S&&!b&&C!==null,z=!S&&!b&&w?.kind===`navigate`&&w.displayState===`resolved`,te=!S&&!b&&w?.kind===`navigate`&&w.displayState===`folder`,B=!S&&!b&&!C&&w?.kind===`create`,ne=!!S,V=S?JY(S.url)?S.url:null:R&&C?oe(C):z&&w?.kind===`navigate`?ZY({docName:w.hashDocName,anchor:f}):null,ie=!b&&V!==null&&(ne||R||z),H,ae,U,se,ce;if(t[9]!==A||t[10]!==d||t[11]!==f||t[12]!==C||t[13]!==n.state||t[14]!==n.view||t[15]!==S||t[16]!==r||t[17]!==R||t[18]!==te||t[19]!==z||t[20]!==B||t[21]!==b||t[22]!==u){if(b){let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ta,{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(S){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(xe,{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,X.jsx)(na,{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(te){let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(ca,{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(B){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Wi,{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(z){let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(aa,{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,X.jsx)(Wi,{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 un(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],ce=i,ae=C??(S?S.url:`${u}${f?`#${f}`:``}`);let a=f?`${u}#${f}`:u;H=d?`[[${a}|${d}]]`:`[[${a}]]`,se=Sn(`flex shrink-0`,U.className),t[9]=A,t[10]=d,t[11]=f,t[12]=C,t[13]=n.state,t[14]=n.view,t[15]=S,t[16]=r,t[17]=R,t[18]=te,t[19]=z,t[20]=B,t[21]=b,t[22]=u,t[23]=H,t[24]=ae,t[25]=U,t[26]=se,t[27]=ce}else H=t[23],ae=t[24],U=t[25],se=t[26],ce=t[27];let W;t[42]!==U.icon||t[43]!==se?(W=(0,X.jsx)(`span`,{className:se,children:U.icon}),t[42]=U.icon,t[43]=se,t[44]=W):W=t[44];let le=W,ue;t[45]!==le||t[46]!==B||t[47]!==U.text?(ue=B?(0,X.jsxs)(P,{children:[(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`wiki-link-prop-panel-icon-trigger`,children:le})}),(0,X.jsx)(re,{children:U.text})]}):le,t[45]=le,t[46]=B,t[47]=U.text,t[48]=ue):ue=t[48];let de=ue,fe=`${U.text}: ${ae}`,pe;t[49]!==ae||t[50]!==ne||t[51]!==B||t[52]!==V||t[53]!==ie||t[54]!==a||t[55]!==s?(pe=(0,X.jsx)(vn,{asChild:!0,children:ie?(0,X.jsx)(`a`,{href:V??void 0,...ne?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>nX(e,s,a),"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:ae}):(0,X.jsx)(`span`,{"data-slot":`wiki-link-prop-panel-text`,className:Sn(`block truncate text-sm font-medium`,B?`text-muted-foreground`:`text-foreground`),children:ae})}),t[49]=ae,t[50]=ne,t[51]=B,t[52]=V,t[53]=ie,t[54]=a,t[55]=s,t[56]=pe):pe=t[56];let me;t[57]===ae?me=t[58]:(me=(0,X.jsx)(re,{className:`max-w-80 break-all`,children:ae}),t[57]=ae,t[58]=me);let he;t[59]!==pe||t[60]!==me?(he=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(P,{children:[pe,me]})}),t[59]=pe,t[60]=me,t[61]=he):he=t[61];let ge;t[62]!==ee||t[63]!==D||t[64]!==B?(ge=B?(0,X.jsxs)(In,{type:`button`,size:`sm`,variant:`link`,disabled:D,onClick:()=>void ee(),"data-slot":`wiki-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,X.jsx)(Na,{className:`size-3.5`,"aria-hidden":`true`}),D?(0,X.jsx)(o,{id:`HM56Bx`}):(0,X.jsx)(o,{id:`XRuL0i`})]}):null,t[62]=ee,t[63]=D,t[64]=B,t[65]=ge):ge=t[65];let _e;t[66]===A?_e=t[67]:(_e=A({id:`ePK91l`}),t[66]=A,t[67]=_e);let ve;t[68]===E?ve=t[69]:(ve=()=>E(!0),t[68]=E,t[69]=ve);let ye;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,X.jsx)(Ma,{className:`size-3.5`,"aria-hidden":`true`}),t[70]=ye):ye=t[70];let be;t[71]!==_e||t[72]!==ve?(be=(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(In,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":_e,onClick:ve,"data-slot":`wiki-link-prop-panel-edit`,children:ye})}),t[71]=_e,t[72]=ve,t[73]=be):be=t[73];let Se;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,X.jsx)(re,{children:(0,X.jsx)(o,{id:`ePK91l`})}),t[74]=Se):Se=t[74];let Ce;t[75]===be?Ce=t[76]:(Ce=(0,X.jsxs)(P,{children:[be,Se]}),t[75]=be,t[76]=Ce);let we;t[77]===H?we=t[78]:(we=(0,X.jsx)(Z$,{copyContent:H}),t[77]=H,t[78]=we);let Te;t[79]===A?Te=t[80]:(Te=A({id:`t_YqKh`}),t[79]=A,t[80]=Te);let De;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,X.jsx)(Ka,{className:`size-3.5`,"aria-hidden":`true`}),t[81]=De):De=t[81];let Oe;t[82]!==F||t[83]!==Te?(Oe=(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(In,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":Te,onClick:F,"data-slot":`wiki-link-prop-panel-remove`,children:De})}),t[82]=F,t[83]=Te,t[84]=Oe):Oe=t[84];let ke;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,X.jsx)(re,{children:(0,X.jsx)(o,{id:`t_YqKh`})}),t[85]=ke):ke=t[85];let Ae;t[86]===Oe?Ae=t[87]:(Ae=(0,X.jsxs)(P,{children:[Oe,ke]}),t[86]=Oe,t[87]=Ae);let je;t[88]!==ge||t[89]!==Ce||t[90]!==we||t[91]!==Ae?(je=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[ge,Ce,we,Ae]}),t[88]=ge,t[89]=Ce,t[90]=we,t[91]=Ae,t[92]=je):je=t[92];let Me;t[93]!==de||t[94]!==he||t[95]!==je?(Me=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[de,he,je]}),t[93]=de,t[94]=he,t[95]=je,t[96]=Me):Me=t[96];let Ne;t[97]!==a||t[98]!==Me||t[99]!==fe||t[100]!==ce?(Ne=(0,X.jsx)(y$,{kind:`wiki-link`,ariaLabel:fe,onDeactivate:a,triggerReference:ce,className:`w-96`,children:Me}),t[97]=a,t[98]=Me,t[99]=fe,t[100]=ce,t[101]=Ne):Ne=t[101];let Pe;t[102]!==d||t[103]!==f||t[104]!==h||t[105]!==T||t[106]!==M||t[107]!==b||t[108]!==_||t[109]!==E||t[110]!==u?(Pe=(0,X.jsx)(S4,{open:T,target:u,alias:d,anchor:f,pages:_,assetPaths:h,loading:b,onOpenChange:E,onSave:M}),t[102]=d,t[103]=f,t[104]=h,t[105]=T,t[106]=M,t[107]=b,t[108]=_,t[109]=E,t[110]=u,t[111]=Pe):Pe=t[111];let Fe;return t[112]!==Ne||t[113]!==Pe?(Fe=(0,X.jsxs)(X.Fragment,{children:[Ne,Pe]}),t[112]=Ne,t[113]=Pe,t[114]=Fe):Fe=t[114],Fe}var w4=0;function T4(){return`wiki-link-${++w4}`}function E4(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 D4(e,t){if(!t||!e)return null;let n=aO(e,t);if(!n)return null;let r=t.pageIcons?.get(n);if(!r)return null;let i=g4(r);return i.kind===`unsupported`?null:i}function O4(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 k4=$e.extend({priority:200,addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=T4(),{dom:i,iconSpan:a}=E4({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=()=>{O4(a,D4(String(o.attrs.target??``),pn()))};s();let c=Ze(s),l=()=>{let e=n();return typeof e==`number`?e:void 0},u=GO(e),d=({newTab:e})=>{let t=o.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=O(n,typeof t.anchor==`string`?t.anchor:null);if(!r)return!1;if(r.kind===`doc`){let t=pn(),i=VY(n,{pages:t?.pages??new Set,folderPaths:t?.folderPaths??new Set,pagesBySlug:t?.pagesBySlug,pagesByBasename:t?.pagesByBasename,fallbackTargets:iO(n)});if(i.kind===`create`||i.kind===`navigate`&&i.displayState===`folder`)return!1;let a=i.kind===`navigate`?i.hashDocName:r.docName;return e?eX({docName:a,anchor:r.anchor}):window.location.assign(ZY({docName:a,anchor:r.anchor})),!0}if(r.kind===`asset`){let t=cO(r.url,pn()?.assetPaths??new Set)??r.url.replace(/^\//,``);return e?QY(oe(t)):window.location.hash=oe(t),!0}return JY(r.url)?(QY(r.url),!0):!1};return u.register({type:`wikiLink`,nodeId:r,getPos:l,controls:{propPanel:t=>(0,Y.createElement)(C4,{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(SX.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(SX.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[LX(this.editor)]}}),A4=0;function j4(){return`wiki-link-embed-${++A4}`}function M4(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 N4(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`,Re(e.src)),t.setAttribute(`alt`,e.alias??e.target),{dom:t}}function P4(e){let t=u(e);return t!==null&&Fe.has(t)}var F4=fn.extend({addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=j4(),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(P4(a)){let{dom:e}=N4({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(!P4(n))return!1;let o=a??n;return e.setAttribute(`data-target`,n),e.setAttribute(`data-alias`,r??``),e.setAttribute(`src`,Re(o)),e.setAttribute(`alt`,r??n),!0}}}let{dom:l}=M4({nodeId:r,target:a,alias:o,anchor:s,href:c??a});l.addEventListener(`click`,e=>{e.preventDefault()});let d=()=>{let e=n();return typeof e==`number`?e:void 0},f=GO(e);return f.register({type:`wikiLinkEmbed`,nodeId:r,getPos:d,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=u(n);if(a===null)return!1;let o=A(r,``)??n;return h$({url:r,projectRelPath:o,ext:a,title:o.split(`/`).pop()??r,forceOsDelegation:e}),!0}}),{dom:l,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let t=String(e.attrs.target??``);if(P4(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:()=>{f.deregister(r)}}}}}),I4=[...B.map(e=>{if(e.name===`jsxComponent`)return A2;if(e.name===`image`){let t=e.options??{};return f$.configure({...t,inline:!0})}return e.name===`rawMdxFallback`?V2:e.name===`wikiLink`?k4:e.name===`wikiLinkEmbed`?F4:e.name===`link`?f1:e.name===`mathInline`?R2:e.name===`tag`?p4:e.name===`codeBlock`?fQ:e}),K2.configure({itemsSources:[AM,xM,kM,wM],categoryLabels:{content:`Components`,layout:`Layout`,media:`Media`,data:`Data`,embed:`Embeds`}}),l$,kD.configure({onDrop(e,t,n){for(let r of t)xO(r,e,n)},onPaste(e,t,n){for(let n of t)xO(n,e,e.state.selection.from)}}),u$,JD,s4,c$,o$,FM,r4,J2,MD,BM,V0,Dt.create({name:`chunkWrapperDecoration`,addProseMirrorPlugins(){return[KM()]}})];function L4(e){return e===rt}function R4(){return Ac(`SYNC_TIMEOUT_MS`,3e4)}var z4=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}},B4=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},V4=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},H4=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}},U4=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}},W4=new Map,G4=!1;function K4(){for(let e of W4.values())if(!e.settled)return!0;return!1}function q4(){typeof document>`u`||document.visibilityState===`visible`&&J4(Date.now())}function J4(e){let t=[];for(let[n,r]of W4){if(r.settled)continue;let i=e-r.createdAt;if(i<R4())continue;r.settled=!0;let a=new z4(n,i);Q4(r),r.reject(a);let o=pS(n);o!==void 0&&wS(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 K4()||X4(),t.length}function Y4(){G4||typeof document>`u`||(document.addEventListener(`visibilitychange`,q4),G4=!0)}function X4(){G4&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,q4),G4=!1))}var Z4=new Map;function Q4(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 $4(e,t){let n=W4.get(e);if(n)return n.promise;let r=Z4.get(e);if(r!==void 0){Z4.delete(e);let n=r===`timeout`?new z4(e,0):new B4(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),Z(`ok/sync/create`,{docName:e,mountId:pS(e),warm:!1,armed:r}),Z(`ok/sync/reject`,{docName:e,mountId:pS(e),reason:`armed-${r}`});let i=t3(n);return W4.set(e,n3(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`);let n=pS(e);Z(`ok/sync/create`,{docName:e,mountId:n,warm:!0}),Z(`ok/sync/resolve`,{docName:e,mountId:n,elapsedMs:0,warm:!0}),Z.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 W4.set(e,e3(r,t)),r}let i=Date.now(),a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=()=>{let t=W4.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=pS(e);if(Z(`ok/sync/resolve`,{docName:e,mountId:r,elapsedMs:n,warm:!1}),Z.histogram(`ok/sync/resolve-elapsed-ms`,r===void 0?{docName:e}:{docName:e,mountId:r},n),Q4(t),K4()||X4(),t.resolve(),r!==void 0){let i=Date.now();CS(r,`ok.sync-promise`,{"doc.name":e,elapsed_ms:n},t.createdAt,i),wS(r,i)}},l=t=>{let n=W4.get(e);if(!n||n.settled)return;n.settled=!0;let r=new B4(e);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=pS(e);Z(`ok/sync/reject`,{docName:e,mountId:i,reason:`pre-sync-disconnect`}),Q4(n),K4()||X4(),n.reject(r),i!==void 0&&wS(i)},u=setTimeout(()=>{let t=W4.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new z4(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=pS(e);Z(`ok/sync/reject`,{docName:e,mountId:i,reason:`timeout`,elapsedMs:n}),Q4(t),K4()||X4(),t.reject(r),i!==void 0&&wS(i)},R4()),d={promise:s,resolve:a,reject:o,createdAt:i,timeoutHandle:u,provider:t,onSynced:c,onClose:l,settled:!1,resolved:!1,detached:!1};return W4.set(e,d),t.on(`synced`,c),t.on(`close`,l),Y4(),Z(`ok/sync/create`,{docName:e,mountId:pS(e),warm:!1}),s}function e3(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!0,detached:!0}}function t3(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function n3(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!1,detached:!0}}function r3(e){return W4.get(e)?.resolved===!0}function i3(e){let t=W4.get(e);t&&(t.settled=!0,Q4(t),W4.delete(e),K4()||X4())}function a3(e,t){let n=W4.get(e);if(!n||n.settled)return!1;n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),Q4(n),K4()||X4(),n.reject(t);let r=pS(e);return r!==void 0&&wS(r),!0}var o3=Object.freeze({kind:`tab-replay`}),s3=Object.freeze({kind:`idle`});function c3(e,t){return()=>{}}var l3=null;function u3(){return l3??=mt(I4),l3}var d3=4e3,f3=1e4,p3=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`}},m3=`ok-last-observed-branch`,h3=5e3,g3=Ac(`MAX_BUFFER_BYTES`,1*1024*1024),_3=Ac(`MAX_POOL`,10);function v3(e,t,n=null){let r={...kc()};return e!==null&&(r.principalId=e.principalId,r.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(r.expectedServerInstanceId=t),n!==null&&n.length>0&&(r.expectedBranch=n),JSON.stringify(r)}var y3=class{_entries=new Map;get entries(){return this._entries}lruOrder=[];activeDocName=null;maxSize;wsUrl;recycleDebounceMs;clearDataTimeoutMs;onChange=null;tabIdentity=null;serverRestartRecoveryState=s3;cachedServerInstanceId=null;pendingServerInstanceKnown=null;recoveryMismatchStaleClaim;bufferedUpdates=new Map;pendingClears=new Map;clearFailures=new Set;persistenceFactory;storage;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n?.recycleDebounceMs??d3,this.clearDataTimeoutMs=n?.clearDataTimeoutMs??f3,this.persistenceFactory=n?.persistenceFactory??CD,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.getOrInitObservedBranch()??`_unknown_`,serverInstanceId:e,docName:t,doc:n})}attachDeferredPersistence(e){let t=!1;for(let n of this._entries.values())if(n.kind===`active`&&n.persistence===null)try{n.persistence=this.buildPersistence(e,n.docName,n.provider.document),t=!0}catch(e){let t=e instanceof Error?e.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n.docName),errorName:t,errorMessage:e instanceof Error?e.message:String(e)})}t&&this.notify()}getServerRestartRecoveryState(){return this.serverRestartRecoveryState}observeDiskAck(e,t){let n=this.entries.get(e);!n||n.kind!==`active`||(n.lastDiskAckedSV=ED(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(m3)??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(m3):this.storage?.setItem(m3,e)}catch{}}withClearDataTimeout(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(new p3(e,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);t.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e)})})}recoveryTelemetryBase(e,t){let n={docName:e,branch:this.getOrInitObservedBranch()??`_unknown_`},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)i3(t);this.notify()}enterServerRestartReconnect(e,t,n,r){if(e.length===0){this.serverRestartRecoveryState=t.length===0?s3:{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=s3,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(L4(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(),Z(`ok/pool/open`,{docName:e,hit:!0,lastAccessedAt:n,poolEventId:t.poolEventId}),Z.count(`ok/pool/open`,{hit:!0}),t}let n=Date.now();this.entries.size>=this.maxSize&&this.evictLru();let r=this.cachedServerInstanceId,i=v3(this.tabIdentity,r,this.getOrInitObservedBranch()),a=new ZE({url:DD(this.wsUrl),name:e,forceSyncInterval:h3,token:i}),o=this.cachedServerInstanceId;this.clearFailures.has(e)&&this.runCloseAndClearPersistence(e);let s=this.pendingClears.get(e),c=o!==null&&o.length>0&&s===void 0?this.buildPersistence(o,e,a.document):null,l=crypto.randomUUID(),u={kind:`active`,provider:a,persistence:c,lastServerSyncedSV:null,lastDiskAckedSV:null,observerCleanup:null,observerFireCounterCleanup:c3(a.document,e),syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),poolEventId:l,hasSynced:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1,serverDrivenCloseReauthInFlight:!1};if(Z(`ok/pool/open`,{docName:e,hit:!1,poolEventId:l}),Z.count(`ok/pool/open`,{hit:!1}),a.on(`status`,({status:t})=>{u.kind!==`active`||this.entries.get(e)!==u||t===`disconnected`&&(u.syncState=`disconnected`,this.notify())}),a.on(`synced`,()=>{if(!(u.kind!==`active`||this.entries.get(e)!==u)&&(u.syncState=`synced`,u.hasSynced=!0,u.lastServerSyncedSV=wD(a.document),u.pendingRecycleTimer&&=(clearTimeout(u.pendingRecycleTimer),null),this.markServerRestartRecoverySynced(e),this.notify(),!u.observerCleanup))try{let t=a.document,n=new V({extensions:I4});u.observerCleanup=SY({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:n,schema:u3(),onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),u.bridgeSetupFailed=!0,a3(e,new H4(e,t))}}),a.on(`disconnect`,()=>{u.kind!==`active`||this.entries.get(e)!==u||(u.syncState=`disconnected`,this.notify(),u.hasSynced&&a.unsyncedChanges===0&&!u.pendingRecycleTimer&&(u.pendingRecycleTimer=setTimeout(()=>{u.kind===`active`&&(u.pendingRecycleTimer=null,this.entries.get(e)===u&&this.recycleDisconnectedEntry(e))},this.recycleDebounceMs)))}),a.on(`authenticationFailed`,({reason:t})=>{let n=[`server-instance-mismatch`,`branch-mismatch`,`rename-redirect`,`doc-deleted`],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,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`){let t=this.entries.get(e),n=t!==void 0&&t.kind===`active`;this.onDocDeleted?.({docName:e,hadOpenProvider:n});return}}),a.on(`close`,({event:t})=>{if(u.kind!==`active`||this.entries.get(e)!==u||u.serverDrivenCloseReauthInFlight)return;u.serverDrivenCloseReauthInFlight=!0,a.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(()=>{u.kind===`active`&&this.entries.get(e)===u&&(u.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(a.off(`synced`,n),u.kind!==`active`||this.entries.get(e)!==u)return;let r=this.bufferedUpdates.get(e);if(r!==void 0){this.bufferedUpdates.delete(e);try{gh(a.document,r,o3)}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)})}}};a.on(`synced`,n)}if(this._entries.set(e,u),this.touch(e),this.notify(),s!==void 0&&o!==null&&o.length>0){let t=o;s.then(()=>{this.attachDeferredPersistenceForEntry(u,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 d=pS(e);return d!==void 0&&CS(d,`ok.provider-pool.open`,{"doc.name":e},n,Date.now()),u}attachDeferredPersistenceForEntry(e,t){let n=this._entries.get(e.docName);if(!(n!==e||n.kind!==`active`||n.persistence!==null))try{n.persistence=this.buildPersistence(t,e.docName,n.provider.document),this.notify()}catch(t){let n=t instanceof Error?t.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(e.docName),errorName:n,errorMessage:t instanceof Error?t.message:String(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)&&i3(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=TD(n.provider.document,t);if(r.byteLength>g3){Z(`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 p3;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(L4(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.getOrInitObservedBranch(),r=this.cachedServerInstanceId;if(n===null||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.onBranchMismatch=null,this.branchMismatchInFlight=null,this.onRenameRedirect=null,this.onDocDeleted=null,this.evictListeners.clear(),this.serverRestartRecoveryState=s3,this.cachedServerInstanceId=null,this.pendingServerInstanceKnown=null,this.tabIdentity=null,this.recoveryMismatchStaleClaim=void 0}evictLru(){for(let e of this.lruOrder)if(e!==this.activeDocName){Z(`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),i3(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(Z(`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()}},b3=crypto.randomUUID(),x3=!1;function S3(e){x3||(x3=!0,console.warn(`[principal-fetch] failed to resolve principal — falling back to random identity.`,e))}var C3=(0,Y.createContext)(null),w3=null;function T3(e){return w3||(w3=new y3(_3,e),CC(w3)),w3}var E3={activeDocName:null,activeProvider:null,syncState:`connecting`,serverRestartRecovery:{kind:`idle`},poolEntries:[]};function D3(){if(typeof window>`u`)return null;let e=window.okDesktop;return e?.config.mode===`editor`?e:null}function O3(){return typeof window>`u`||window.okDesktop?.config.mode===`editor`?null:fw(window.location.origin)}function k3(){if(typeof window>`u`)return uw(null,_3);let e=O3();return e?pw(window.localStorage===void 0?null:window.localStorage,e,_3):uw(null,_3)}function A3(){return k3().openTabs}function j3(){return k3().pinnedTabIds}function M3(){if(typeof window>`u`||window.location.hash.length>0)return null;let e=k3();return e.activeTabId??(e.activeDocName?MC(e.activeDocName):null)??e.openTabs[0]??null}function N3(e){let t=HC(e);switch(t.kind){case`doc`:return ce(t.docName);case`folder`:return he(t.folderPath);case`asset`:return oe(t.assetPath)}}function P3(e){let t=fe(e);if(t)return zC(t);let n=Et(e);if(!n)return null;let r=n.trim();if(/\/+$/.test(r)){let e=r.replace(/\/+$/g,``);return e?RC(e):null}return MC(n)}function F3(e){return{kind:`asset`,target:e,assetPath:e,mediaKind:ve(e.split(`.`).pop()??``)}}function I3(e,t){return e?VC(e):t?MC(t):null}function L3(e,t,n){return e.some(e=>!n.has(e)&&UC(e)===t)}function R3(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function z3(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`large-file`:return`large-file:${e.docName}:${e.size}:${e.limit}`;case`missing`:return`missing:${e.target}`}}function B3(e,t){return e===t?!0:!e||!t?!1:z3(e)===z3(t)}function V3(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 H3(e){let t=(0,J.c)(175),{children:n}=e,[r,i]=(0,Y.useState)(E3),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(M3),[l,u]=(0,Y.useState)(A3),[d,f]=(0,Y.useState)(j3),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[0]=p):p=t[0];let[m,h]=(0,Y.useState)(p),[g,_]=(0,Y.useState)(l),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(!1),S=(0,Y.useRef)(s),C=(0,Y.useRef)(l),w=(0,Y.useRef)(d),T=(0,Y.useRef)(v),E=(0,Y.useRef)(m),D=(0,Y.useRef)(g),O=(0,Y.useRef)(1),k=(0,Y.useRef)(!1),[A,j]=(0,Y.useState)(!1),[M,N]=(0,Y.useState)(null),[P,F]=(0,Y.useState)(null),[I,L]=(0,Y.useState)(`doc`),[ee,R]=(0,Y.useState)(null),[z,te]=(0,Y.useState)(0),{collabUrl:B,terminal:ne,lastError:V,retry:re}=eS(),ie;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(ie=function(e){S.current=e,c(e)},t[1]=ie):ie=t[1];let H=ie,ae;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(ae=function(e){T.current=e,y(e)},t[2]=ae):ae=t[2];let U=ae,se;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(e){D.current=e,_(t=>R3(t,e)?t:e)},t[3]=se):se=t[3];let W=se,le;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(le=function(e){w.current=e,f(t=>R3(t,e)?t:e)},t[4]=le):le=t[4];let ue=le,de;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(de=function(e,t){let n=GC(t,e);C.current=e,w.current=n,u(t=>R3(t,e)?t:e),f(e=>R3(e,n)?e:n),W(nw(D.current,e,E.current))},t[5]=de):de=t[5];let fe=de,pe;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(pe=function(e){fe(e,w.current)},t[6]=pe):pe=t[6];let me=pe,ge;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(ge=function(e){me(e(C.current))},t[7]=ge):ge=t[7];let _e=ge,ve;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(ve=function(e){E.current=e,h(t=>R3(t,e)?t:e),W(nw(D.current,C.current,e))},t[8]=ve):ve=t[8];let ye=ve,be;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(be=function(e){let t=T.current;if(!t)return;let n=E.current.filter(e=>e!==t);E.current=n,h(e=>R3(e,n)?e:n),U(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))}W(nw(r,C.current,n))},t[9]=be):be=t[9];let xe=be,Se,Ce;t[10]===s?(Se=t[11],Ce=t[12]):(Se=()=>{S.current=s},Ce=[s],t[10]=s,t[11]=Se,t[12]=Ce),(0,Y.useEffect)(Se,Ce);let we,Te;t[13]===l?(we=t[14],Te=t[15]):(we=()=>{C.current=l},Te=[l],t[13]=l,t[14]=we,t[15]=Te),(0,Y.useEffect)(we,Te);let Ee,De;t[16]===d?(Ee=t[17],De=t[18]):(Ee=()=>{w.current=d},De=[d],t[16]=d,t[17]=Ee,t[18]=De),(0,Y.useEffect)(Ee,De);let Oe,ke;t[19]===v?(Oe=t[20],ke=t[21]):(Oe=()=>{T.current=v},ke=[v],t[19]=v,t[20]=Oe,t[21]=ke),(0,Y.useEffect)(Oe,ke);let Ae,je;t[22]===m?(Ae=t[23],je=t[24]):(Ae=()=>{E.current=m},je=[m],t[22]=m,t[23]=Ae,t[24]=je),(0,Y.useEffect)(Ae,je);let Me,Ne;t[25]===g?(Me=t[26],Ne=t[27]):(Me=()=>{D.current=g},Ne=[g],t[25]=g,t[26]=Me,t[27]=Ne),(0,Y.useEffect)(Me,Ne);let Pe=v!==null,Fe,Ie;t[28]!==B||t[29]!==A||t[30]!==b?(Fe=()=>{if(B===null||b||!A)return;let e=!1,t=D3(),n=O3(),r=typeof localStorage<`u`?localStorage:null;return(t?t.project.getSessionState():Promise.resolve(n?pw(r,n,_3):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null})).then(t=>{if(e)return;let n=uw(t,_3);if(k.current)return;let r=T3(B);for(let e of n.openTabs){let t=UC(e);t&&r.open(t)}let i=[...n.pinnedTabIds,...w.current],a=n.openTabs;for(let e of C.current)a=ZC(a,e,_3,i);let o=GC(i,a);C.current=a,w.current=o,u(e=>R3(e,a)?e:a),f(e=>R3(e,o)?e:o);let s=nw(D.current,a,E.current);D.current=s,_(e=>R3(e,s)?e:s);let l=Et(window.location.hash),d=n.activeTabId??(n.activeDocName?MC(n.activeDocName):null)??n.openTabs[0]??null,p=d?N3(d):null;if((l===null&&window.location.hash.length===0||p!==null&&p===window.location.hash)&&d){S.current=d,c(d);let e=N3(d);window.location.hash!==e&&(window.location.hash=e)}}).catch(Q3).finally(()=>{e||x(!0)}),()=>{e=!0}},Ie=[B,A,b],t[28]=B,t[29]=A,t[30]=b,t[31]=Fe,t[32]=Ie):(Fe=t[31],Ie=t[32]),(0,Y.useEffect)(Fe,Ie);let Le,G;t[33]!==s||t[34]!==a||t[35]!==l||t[36]!==d||t[37]!==r.activeDocName||t[38]!==b?(Le=()=>{if(!b)return;let e=dw(l,s??I3(a,r.activeDocName),d),t=D3();if(t){t.project.setSessionState(e).catch(Z3);return}let n=O3();n&&mw(typeof localStorage<`u`?localStorage:null,n,e)},G=[s,a,l,d,r.activeDocName,b],t[33]=s,t[34]=a,t[35]=l,t[36]=d,t[37]=r.activeDocName,t[38]=b,t[39]=Le,t[40]=G):(Le=t[39],G=t[40]),(0,Y.useEffect)(Le,G);let Re;t[41]===b?Re=t[42]:(Re=function(){b||(k.current=!0)},t[41]=b,t[42]=Re);let ze=Re,Be,Ve;t[43]===B?(Be=t[44],Ve=t[45]):(Be=()=>{if(B===null)return;let e=!1;j(!1);let t=T3(B);i(V3(t));let n=function(e,t){let n=GC(t,e);C.current=e,w.current=n,u(t=>R3(t,e)?t:e),f(e=>R3(e,n)?e:n);let r=nw(D.current,e,E.current);D.current=r,_(e=>R3(e,r)?e:r)};return t.setOnBranchMismatch(()=>Lx(t)),t.setOnRenameRedirect(e=>{let{fromDocName:r,toDocName:i,hadOpenProvider:a}=e;(async()=>{let e,s=t.getActiveDocName()===r;rC([{fromDocName:r,toDocName:i}]);try{await Promise.all([t.closeAndClearPersistence(r),t.closeAndClearPersistence(i)]),s&&(t.open(i),t.setActive(i));let e=iw(C.current,[{fromDocName:r,toDocName:i}],_3,[],w.current),a=GC(iw(w.current,[{fromDocName:r,toDocName:i}],2**53-1),e);D.current=aw(D.current,[{fromDocName:r,toDocName:i}]),n(e,a),o(e=>e&&(Ye(e)===r?{kind:`doc`,target:i,docName:i}:e)),s&&(window.location.hash=ce(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(tw(C.current,r),w.current),o(e=>e&&(Ye(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(V3(t))),fetch(`/api/principal`).then(X3).then(n=>{if(e)return;let r=ct.safeParse(n);r.success?(t.setTabIdentity({principalId:r.data.id,tabSessionId:b3}),N(r.data)):S3(r.error)}).catch(t=>{e||S3(t)}).finally(()=>{e||j(!0)}),Lx(t),()=>{e=!0,t.setOnChange(null),t.setOnRenameRedirect(null),t.setOnDocDeleted(null)}},Ve=[B],t[43]=B,t[44]=Be,t[45]=Ve),(0,Y.useEffect)(Be,Ve);let He;t[46]===B?He=t[47]:(He=e=>{if(Z(`ok/nav/open-document`,{docName:e,transition:!1}),B===null)return;let t=T3(B),n=t.open(e);if(!n)return;Dx(e,n.poolEventId);let r=MC(e);_e(e=>ZC(e,r,_3,w.current)),xe(r),H(r),t.setActive(e),o({kind:`doc`,target:e,docName:e})},t[46]=B,t[47]=He);let Ue=He,We;t[48]===Ue?We=t[49]:(We=e=>{Z(`ok/nav/open-document`,{docName:e,transition:!1}),Ue(e)},t[48]=Ue,t[49]=We);let Ge=We,Ke;t[50]!==a||t[51]!==B||t[52]!==ze||t[53]!==r.activeDocName?(Ke=(e,t)=>{let n=t===void 0?{}:t;if(B===null)return;n.tabBehavior===`replace-active`&&ze();let i=T3(B),s=Ye(e),c=T.current,l=c!==null&&n.tabBehavior===`replace-active`,u=c?null:S.current??I3(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;Dx(s,e.poolEventId);let t=l?IC(C.current,MC(s)):null,n=l&&!t?PC(C.current,s):null,r=l?t?{activeTabId:t,tabs:C.current}:{activeTabId:n??MC(s),tabs:ZC(C.current,n??MC(s),_3,w.current)}:$C(C.current,s,{behavior:p,currentTabId:u,limit:_3,pinnedTabIds:w.current});me(r.tabs),xe(r.activeTabId),H(r.activeTabId),i.setActive(s)}else{i.clearActive();let t=VC(e);if(t){let e=u!==null&&LC(u,t),n=l||e?null:IC(C.current,t),r=n?{tabs:C.current,activeTabId:n}:ew(C.current,t,{behavior:p,currentTabId:u,limit:_3,pinnedTabIds:w.current});me(r.tabs),H(r.activeTabId),xe(r.activeTabId)}else xe(t)}o(t=>B3(t,e)?t:e)},t[50]=a,t[51]=B,t[52]=ze,t[53]=r.activeDocName,t[54]=Ke):Ke=t[54];let qe=Ke,Je;t[55]===qe?Je=t[56]:(Je=(e,t)=>{qe(e,t===void 0?{}:t)},t[55]=qe,t[56]=Je);let Xe=Je,Ze;t[57]===qe?Ze=t[58]:(Ze=(e,t)=>{let n=t===void 0?{}:t;Z(`ok/nav/open-target`,{docName:Ye(e),kind:e.kind,transition:!1}),qe(e,n)},t[57]=qe,t[58]=Ze);let Qe=Ze,$e;t[59]!==s||t[60]!==a||t[61]!==B||t[62]!==ze||t[63]!==r.activeDocName?($e=e=>{if(w.current.includes(e))return;ze();let t=null,n=UC(e);if(B!==null){let t=T3(B);n&&!L3(C.current,n,new Set([e]))&&t.close(n)}let i=s??I3(a,r.activeDocName);if(_e(n=>(t=cw(n,i,e),tw(n,e))),i===e){if(t){H(t),window.location.hash=N3(t);return}B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash=``}},t[59]=s,t[60]=a,t[61]=B,t[62]=ze,t[63]=r.activeDocName,t[64]=$e):$e=t[64];let et=$e,tt;t[65]!==B||t[66]!==ze?(tt=e=>{ze();let t=E.current;if(!t.includes(e))return;let n=t.filter(t=>t!==e);if(ye(n),T.current!==e)return;let r=t.indexOf(e),i=n[r]??n[r-1]??null;if(i){U(i),B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash!==``&&(window.location.hash=``);return}U(null);let a=C.current[C.current.length-1]??null;if(a){H(a),window.location.hash=N3(a);return}B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash=``},t[65]=B,t[66]=ze,t[67]=tt):tt=t[67];let nt=tt,rt;t[68]!==nt||t[69]!==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[68]=nt,t[69]=et,t[70]=rt):rt=t[70];let it=rt,at,ot;t[71]===it?(at=t[72],ot=t[73]):(at=()=>{let e=D3();if(e)return e.onMenuAction(e=>{e===`close-active-tab-or-window`&&(it()||window.close())})},ot=[it],t[71]=it,t[72]=at,t[73]=ot),(0,Y.useEffect)(at,ot);let st;t[74]===B?st=t[75]:(st=()=>{if(B===null){o(Y3),S.current=null,c(J3);return}let e=T3(B);e.getActiveDocName()!==null&&e.clearActive(),o(q3),S.current=null,c(K3)},t[74]=B,t[75]=st);let lt;t[76]!==B||t[77]!==ze?(lt=e=>{B!==null&&(ze(),T3(B).close(e),_e(t=>tw(t,MC(e))),c(t=>{let n=t&&UC(t)===e?null:t;return S.current=n,n}),o(t=>t&&(Ye(t)===e?null:t)))},t[76]=B,t[77]=ze,t[78]=lt):lt=t[78];let ut;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(ut=e=>{let t=qC(w.current,e,C.current);R3(w.current,t)||ue(t)},t[79]=ut):ut=t[79];let dt;t[80]===ze?dt=t[81]:(dt=e=>{let t=JC(w.current,e);R3(w.current,t)||(ze(),ue(t))},t[80]=ze,t[81]=dt);let ft;t[82]===B?ft=t[83]:(ft=e=>{let t=HC(e);if(U(null),H(e),t.kind===`doc`){if(B!==null){let e=T3(B);if(!e.open(t.docName))return;e.setActive(t.docName)}o({kind:`doc`,target:t.docName,docName:t.docName});let e=ce(t.docName);window.location.hash!==e&&(window.location.hash=e);return}if(B!==null&&T3(B).clearActive(),t.kind===`asset`){o(F3(t.assetPath));let e=oe(t.assetPath);window.location.hash!==e&&(window.location.hash=e);return}o({kind:`folder`,target:t.folderPath,folderPath:t.folderPath});let n=he(t.folderPath);window.location.hash!==n&&(window.location.hash=n)},t[82]=B,t[83]=ft);let pt;t[84]===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=R3(C.current,a),l=R3(E.current,o),u=R3(D.current,s);c&&l&&u||(D.current=s,l||(E.current=o,h(e=>R3(e,o)?e:o)),fe(a,XC(a,w.current,t)))},t[84]=pt):pt=t[84];let mt,ht;t[85]===B?(mt=t[86],ht=t[87]):(mt=()=>{let e=`new-tab:${O.current}`;O.current+=1,ye([...E.current,e]),U(e),B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash!==``&&(window.location.hash=``)},ht=e=>{E.current.includes(e)&&(B!==null&&T3(B).clearActive(),o(null),H(null),U(e),window.location.hash!==``&&(window.location.hash=``))},t[85]=B,t[86]=mt,t[87]=ht);let gt;t[88]!==s||t[89]!==a||t[90]!==B||t[91]!==ze||t[92]!==r.activeDocName?(gt=(e,t)=>{let n=t===void 0?{}:t,i=e.filter(G3),c=new Set(n.force?i:YC(i,w.current));if(c.size===0)return;if(ze(),B!==null){let e=T3(B),t=new Map;for(let e of c){let n=UC(e);if(!n)continue;let r=t.get(n)??new Set;r.add(e),t.set(n,r)}for(let[n,r]of t)L3(C.current,n,r)||e.close(n)}let l=null,u=s??I3(a,r.activeDocName);if(_e(e=>(l=lw(e,u,c),e.filter(e=>!c.has(e)))),!u||!c.has(u)){u||o(e=>{if(!e)return e;let t=VC(e);return t&&c.has(t)?null:e});return}if(l){H(l),window.location.hash=N3(l);return}B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash=``},t[88]=s,t[89]=a,t[90]=B,t[91]=ze,t[92]=r.activeDocName,t[93]=gt):gt=t[93];let _t;t[94]!==s||t[95]!==a||t[96]!==B||t[97]!==ze||t[98]!==l||t[99]!==r.activeDocName?(_t=e=>{let{pages:t,folderPaths:n,assetPaths:i}=e,c=rw(l,{pages:t,folderPaths:n,assetPaths:i,keepMissingDocName:a?.kind===`missing`?a.target:null});if(c.length===l.length)return;let u=new Set(c),d=l.filter(e=>!u.has(e)),f=new Set(d);if(ze(),B!==null){let e=T3(B);for(let t of d){let n=UC(t);n&&e.close(n)}}me(c);let p=typeof window<`u`?P3(window.location.hash):null,m=s??I3(a,r.activeDocName),h=p&&f.has(p)?p:m&&f.has(m)?m:null;if(!h){o(e=>{if(!e)return e;let t=VC(e);return t&&f.has(t)?null:e});return}let g=lw(l,h,d);if(g){H(g),window.location.hash=N3(g);return}B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash=``},t[94]=s,t[95]=a,t[96]=B,t[97]=ze,t[98]=l,t[99]=r.activeDocName,t[100]=_t):_t=t[100];let vt;t[101]!==B||t[102]!==ze?(vt=(e,t,n)=>{let r=t===void 0?[]:t,i=n===void 0?[]:n;ze();let a=iw(C.current,e,_3,r,w.current,i),o=GC(iw(w.current,e,2**53-1,r,[],i),a);if(B!==null){let e=T3(B);for(let t of a){let n=UC(t);n&&e.open(n)}}D.current=aw(D.current,e,r,i),fe(a,o);let s=S.current;if(s){let t=iw([s],e,1,r,[],i)[0];t&&a.includes(t)&&H(t)}},t[101]=B,t[102]=ze,t[103]=vt):vt=t[103];let yt,bt,xt,St,Ct;t[104]===B?(yt=t[105],bt=t[106],xt=t[107],St=t[108],Ct=t[109]):(yt=async e=>{B!==null&&(await T3(B).closeAndClearPersistence(e),o(t=>t&&(Ye(t)===e?null:t)))},bt=()=>B===null?null:T3(B).getActiveDocName(),xt=e=>B===null?!1:T3(B).has(e),St=e=>{B!==null&&T3(B).recycle(e)},Ct=e=>B===null?null:T3(B).prewarm(e)?.poolEventId??null,t[104]=B,t[105]=yt,t[106]=bt,t[107]=xt,t[108]=St,t[109]=Ct);let wt,Tt,Dt,Ot,At;t[110]===B?(wt=t[111],Tt=t[112],Dt=t[113],Ot=t[114],At=t[115]):(wt=e=>{B!==null&&T3(B).setExpectedServerInstanceId(e)},Tt=async e=>{if(B===null)return;let t=T3(B);t.setObservedBranch(e),await Ox(t,e),kt([`files`,`backlinks`,`graph`]),zt(e)},Dt=async e=>{if(B===null)return;let t=T3(B);t.compareAndUpdateObservedBranch(e)&&(await Ox(t,e),kt([`files`,`backlinks`,`graph`]),zt(e))},Ot=(e,t)=>{B!==null&&T3(B).observeDiskAck(e,t)},At=async()=>{B!==null&&await Lx(T3(B))},t[110]=B,t[111]=wt,t[112]=Tt,t[113]=Dt,t[114]=Ot,t[115]=At);let jt;t[116]!==ee||t[117]!==I||t[118]!==r.activeDocName?(jt=(e,t)=>{if(!r.activeDocName&&t){window.location.hash=ce(t),R(e),L(`agent`),te(W3);return}if(I===`agent`&&ee===e){L(`doc`);return}R(e),L(`agent`),te(U3)},t[116]=ee,t[117]=I,t[118]=r.activeDocName,t[119]=jt):jt=t[119];let Mt;t[120]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=()=>{L(`doc`),R(null)},t[120]=Mt):Mt=t[120];let Nt;t[121]!==v||t[122]!==s||t[123]!==a||t[124]!==it||t[125]!==nt||t[126]!==et||t[127]!==V||t[128]!==ne||t[129]!==B||t[130]!==ee||t[131]!==z||t[132]!==I||t[133]!==Pe||t[134]!==m||t[135]!==Ue||t[136]!==Ge||t[137]!==l||t[138]!==Xe||t[139]!==Qe||t[140]!==d||t[141]!==M||t[142]!==re||t[143]!==r.activeDocName||t[144]!==r.activeProvider||t[145]!==r.poolEntries||t[146]!==r.serverRestartRecovery||t[147]!==r.syncState||t[148]!==P||t[149]!==st||t[150]!==lt||t[151]!==dt||t[152]!==ft||t[153]!==mt||t[154]!==ht||t[155]!==gt||t[156]!==_t||t[157]!==vt||t[158]!==yt||t[159]!==bt||t[160]!==xt||t[161]!==St||t[162]!==Ct||t[163]!==wt||t[164]!==Tt||t[165]!==Dt||t[166]!==Ot||t[167]!==At||t[168]!==jt||t[169]!==b||t[170]!==g?(Nt={principal:M,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:Ue,openDocumentTransition:Ge,openTarget:Xe,openTargetTransition:Qe,clearTarget:st,closeDocument:lt,closeActiveTabOrWindow:it,closeTab:et,pinTab:ut,unpinTab:dt,activateTab:ft,reorderTabs:pt,newTabIds:m,activeNewTabId:v,isNewTabActive:Pe,openNewTab:mt,activateNewTab:ht,closeNewTab:nt,closeTabs:gt,syncOpenTabsWithKnownTargets:_t,remapTabsForRename:vt,closeAndClearForRename:yt,getPoolActiveDocName:bt,poolHas:xt,recycleDocument:St,prewarm:Ct,systemProvider:P,setSystemProvider:F,updateServerInstanceId:wt,onBranchSwitched:Tt,observeBranch:Dt,observeDiskAck:Ot,refreshServerInfo:At,collabUrl:B,collabTerminal:ne,collabLastError:V,retryCollab:re,docPanelMode:I,docPanelAgentId:ee,docPanelExpandSignal:z,openActivityPanel:jt,closeActivityPanel:Mt},t[121]=v,t[122]=s,t[123]=a,t[124]=it,t[125]=nt,t[126]=et,t[127]=V,t[128]=ne,t[129]=B,t[130]=ee,t[131]=z,t[132]=I,t[133]=Pe,t[134]=m,t[135]=Ue,t[136]=Ge,t[137]=l,t[138]=Xe,t[139]=Qe,t[140]=d,t[141]=M,t[142]=re,t[143]=r.activeDocName,t[144]=r.activeProvider,t[145]=r.poolEntries,t[146]=r.serverRestartRecovery,t[147]=r.syncState,t[148]=P,t[149]=st,t[150]=lt,t[151]=dt,t[152]=ft,t[153]=mt,t[154]=ht,t[155]=gt,t[156]=_t,t[157]=vt,t[158]=yt,t[159]=bt,t[160]=xt,t[161]=St,t[162]=Ct,t[163]=wt,t[164]=Tt,t[165]=Dt,t[166]=Ot,t[167]=At,t[168]=jt,t[169]=b,t[170]=g,t[171]=Nt):Nt=t[171];let Pt=Nt,Ft;return t[172]!==n||t[173]!==Pt?(Ft=(0,X.jsx)(C3,{value:Pt,children:n}),t[172]=n,t[173]=Pt,t[174]=Ft):Ft=t[174],Ft}function U3(e){return e+1}function W3(e){return e+1}function G3(e){return e.length>0}function K3(e){return e===null?e:null}function q3(e){return e===null?e:null}function J3(e){return e===null?e:null}function Y3(e){return e===null?e:null}function X3(e){return e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))}function Z3(e){console.warn(`[editor-tabs] failed to persist tab session:`,e)}function Q3(e){console.warn(`[editor-tabs] failed to restore tab session:`,e)}function $3(){let e=(0,Y.use)(C3);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function e6(){let e=(0,J.c)(3),{openDocumentTransition:t,openTargetTransition:n}=$3(),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{MI as $,ba as $n,px as $t,k$ as A,Cc as An,bC as At,CY as B,Wa as Bn,cS as Bt,y1 as C,Hl as Cn,Ii as Cr,BC as Ct,b1 as D,Z as Dn,fC as Dt,x1 as E,Ic as En,dC as Et,aX as F,bc as Fn,jS as Ft,lR as G,Na as Gn,Fx as Gt,bY as H,Va as Hn,lS as Ht,QY as I,$a as In,hS as It,dR as J,Ta as Jn,bx as Jt,OR as K,Ma as Kn,Ex as Kt,VY as L,qa as Ln,pS as Lt,oZ as M,Tc as Mn,BS as Mt,iZ as N,wc as Nn,zS as Nt,h1 as O,Ac as On,lC as Ot,aZ as P,Sc as Pn,RS as Pt,LL as Q,xa as Qn,gx as Qt,PY as R,Ka as Rn,mS as Rt,E1 as S,Wl as Sn,Li as Sr,VC as St,C1 as T,ql as Tn,eC as Tt,cK as U,Fa as Un,Kx as Ut,xY as V,Ua as Vn,dS as Vt,gB as W,Pa as Wn,Rx as Wt,ML as X,Ca as Xn,fx as Xt,zL as Y,wa as Yn,dx as Yt,AL as Z,Sa as Zn,hx as Zt,a4 as _,dm as _n,Wi as _r,MC as _t,V4 as a,ib as an,ua as ar,lA as at,W0 as b,Au as bn,zi as br,HC as bt,z4 as c,Hy as cn,aa as cr,GO as ct,r3 as d,yg as dn,$i as dr,uO as dt,_x as en,ga as er,jI as et,L4 as f,Gh as fn,Zi as fr,ZD as ft,i4 as g,Lh as gn,Gi as gr,zC as gt,g4 as h,Hh as hn,Ki as hr,ZE as ht,H4 as i,fb as in,da as ir,PA as it,yQ as j,Ec as jn,TS as jt,W$ as k,Oc as kn,$S as kt,i3 as l,Pv as ln,ra as lr,UO as lt,_4 as m,Rh as mn,Yi as mr,KD as mt,$3 as n,vx as nn,pa as nr,iF as nt,B4 as o,oy as on,la as or,Xk as ot,I4 as p,Wh as pn,Xi as pr,XD as pt,_B as q,ka as qn,yx as qt,e6 as r,db as rn,fa as rr,sM as rt,U4 as s,Iy as sn,ca as sr,gk as st,H3 as t,mx as tn,ha as tr,cF as tt,$4 as u,eh as un,ea as ur,pO as ut,n2 as v,fm as vn,Ui as vr,YC as vt,S1 as w,Yl as wn,rC as wt,q1 as x,ku as xn,Ri as xr,ow as xt,q0 as y,Wf as yn,Hi as yr,RC as yt,jY as z,Ga as zn,uS as zt};
|
|
61
|
+
${ZZ(t)}`}var eQ=`plaintext`;function tQ(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?`dark`:`light`}function nQ(e,t){let n=(0,J.c)(4),[r,i]=(0,Y.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,Y.useEffect)(a,o),r}function rQ(e){let t=(0,J.c)(172),{node:n,updateAttributes:r,editor:a,getPos:s,selected:c}=e,{_:l}=i(),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(null),[_,v]=(0,Y.useState)(null),{resolvedTheme:y}=Qt(),b;t[0]===y?b=t[1]:(b=y===`dark`||y===`light`?y:tQ(),t[0]=y,t[1]=b);let x=b,[S]=(0,Y.useState)(tQ),{merged:C}=iF(),w=C?.preview?.scriptSrc??`cdn-allowlist`,T=n.attrs.language??null,E=n.attrs.meta??null,D;t[2]===E?D=t[3]:(D=BZ(E),t[2]=E,t[3]=D);let O=D,[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),N=(0,Y.useId)(),P=`${N}-title-input`,F=`${N}-title-help`,I=(0,Y.useRef)(E),L,ee;t[4]===E?(L=t[5],ee=t[6]):(L=()=>{I.current=E},ee=[E],t[4]=E,t[5]=L,t[6]=ee),(0,Y.useEffect)(L,ee);let R,z,te,B,ne;if(t[7]!==l||t[8]!==T||t[9]!==E){z=CZ(T),R=T?xZ.find(e=>e.value===z)?.label??T:l({id:`LpB85N`});let e;t[15]===E?e=t[16]:(e=DZ(E,`preview`),t[15]=E,t[16]=e),B=e,te=z?AZ.has(z):!1,ne=jZ(z,E),t[7]=l,t[8]=T,t[9]=E,t[10]=R,t[11]=z,t[12]=te,t[13]=B,t[14]=ne}else R=t[10],z=t[11],te=t[12],B=t[13],ne=t[14];let V=ne,re;t[17]!==V||t[18]!==E?(re=V?IZ(E):null,t[17]=V,t[18]=E,t[19]=re):re=t[19];let ie=re,H;t[20]!==V||t[21]!==E?(H=V?LZ(E):null,t[20]=V,t[21]=E,t[22]=H):H=t[22];let ae=H,oe=ie??(_===null?void 0:`${_}px`),U=!V,se,ce;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>()=>{m.current!==null&&window.clearTimeout(m.current)},ce=[],t[23]=se,t[24]=ce):(se=t[23],ce=t[24]),(0,Y.useEffect)(se,ce);let W=a.isEditable,le=nQ(a,s),ue,de;t[25]===x?(ue=t[26],de=t[27]):(ue=()=>{g.current?.contentWindow?.postMessage(WZ(x),`*`)},de=[x],t[25]=x,t[26]=ue,t[27]=de),(0,Y.useEffect)(ue,de);let fe,pe;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>{let e=function(e){if(e.source!==g.current?.contentWindow)return;let t=KZ(e.data);t!==null&&v(e=>e!==null&&Math.abs(e-t)<=2?e:t)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},pe=[],t[28]=fe,t[29]=pe):(fe=t[28],pe=t[29]),(0,Y.useEffect)(fe,pe);let me;t[30]===n.textContent?me=t[31]:(me=()=>{let e=n.textContent,t=()=>{p(!0),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>p(!1),1200)};try{typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e).then(t,sQ)}catch{}},t[30]=n.textContent,t[31]=me);let he=me,ge;t[32]!==a||t[33]!==s?(ge=()=>{let e=typeof s==`function`?s():void 0;if(typeof e==`number`)try{a.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]=a,t[33]=s,t[34]=ge):ge=t[34];let _e=ge,ve;t[35]!==B||t[36]!==E||t[37]!==r?(ve=()=>{r({meta:B?kZ(E,`preview`):OZ(E,`preview`)})},t[35]=B,t[36]=E,t[37]=r,t[38]=ve):ve=t[38];let ye=ve,be;t[39]!==E||t[40]!==r?(be=e=>{let t=VZ(E,e.length>0?e:null);t!==E&&r({meta:t})},t[39]=E,t[40]=r,t[41]=be):be=t[41];let xe=be,Se;t[42]!==a.state||t[43]!==a.view||t[44]!==s||t[45]!==n.attrs||t[46]!==n.nodeSize||t[47]!==n.type?(Se=e=>{let t=typeof s==`function`?s():void 0;if(typeof t==`number`)try{let{schema:r,tr:i}=a.state,o=n.type.create(n.attrs,e.length>0?r.text(e):null);i.replaceWith(t,t+n.nodeSize,o),a.view.dispatch(i)}catch(e){let t=e;if(!(t instanceof RangeError))throw t;console.warn(`[CodeBlockView] edit-save failed — position race`,t)}},t[42]=a.state,t[43]=a.view,t[44]=s,t[45]=n.attrs,t[46]=n.nodeSize,t[47]=n.type,t[48]=Se):Se=t[48];let Ce=Se,we;t[49]===r?we=t[50]:(we=e=>{let t=`${Math.round(e.width)}px`,n=`${Math.round(e.height)}px`;r({meta:FZ(FZ(I.current,`h`,n),`w`,t)})},t[49]=r,t[50]=we);let Te=we,Ee=T??void 0,De=le?`true`:void 0,Oe=c?`true`:void 0,ke=V?`true`:void 0,Ae=U?`true`:`false`,je;t[51]!==l||t[52]!==x||t[53]!==S||t[54]!==U||t[55]!==oe||t[56]!==Te||t[57]!==n.textContent||t[58]!==V||t[59]!==w||t[60]!==ae?(je=V?(0,X.jsxs)(`div`,{ref:h,className:Sn(`ok-codeblock-preview`,U?`ok-codeblock-preview--with-code`:`ok-codeblock-preview--solo`),contentEditable:!1,style:{...oe?{height:oe}:{},...ae?{width:ae}:{}},onMouseDown:oQ,children:[(0,X.jsx)(`iframe`,{title:l({id:`G7cMuO`}),ref:g,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:$Z(w,S)+n.textContent,className:`ok-codeblock-preview-frame`,onLoad:()=>{g.current?.contentWindow?.postMessage(WZ(x),`*`)}}),(0,X.jsx)(lk,{targetRef:h,bounds:{minWidth:192,maxWidth:Math.round(window.innerWidth*.9),minHeight:128,maxHeight:Math.round(window.innerHeight*.9)},onResize:e=>{let t=h.current;t&&(t.style.width=`${e.width}px`,t.style.height=`${e.height}px`)},onResizeEnd:Te})]}):null,t[51]=l,t[52]=x,t[53]=S,t[54]=U,t[55]=oe,t[56]=Te,t[57]=n.textContent,t[58]=V,t[59]=w,t[60]=ae,t[61]=je):je=t[61];let Me;t[62]===O?Me=t[63]:(Me=O?(0,X.jsx)(`div`,{className:`ok-codeblock-title`,contentEditable:!1,"data-testid":`ok-codeblock-title`,title:O,children:(0,X.jsx)(`span`,{className:`ok-codeblock-title-text`,children:O})}):null,t[62]=O,t[63]=Me);let Ne=V&&U?`rounded-b-lg`:null,Pe=V?null:`rounded-lg`,Fe;t[64]!==Ne||t[65]!==Pe?(Fe=Sn(`ok-codeblock-pre m-0 overflow-x-auto px-5 py-4 font-mono text-sm leading-relaxed`,Ne,Pe),t[64]=Ne,t[65]=Pe,t[66]=Fe):Fe=t[66];let Ie=!U||void 0,Le=T?`language-${T}`:void 0,G;t[67]===Le?G=t[68]:(G=Sn(`hljs block whitespace-pre bg-transparent p-0`,Le),t[67]=Le,t[68]=G);let Re;t[69]===G?Re=t[70]:(Re=(0,X.jsx)(Ql,{as:`code`,className:G}),t[69]=G,t[70]=Re);let ze;t[71]!==Fe||t[72]!==Ie||t[73]!==Re?(ze=(0,X.jsx)(`pre`,{className:Fe,"aria-hidden":Ie,children:Re}),t[71]=Fe,t[72]=Ie,t[73]=Re,t[74]=ze):ze=t[74];let Be;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(Be={[gF]:`true`},t[75]=Be):Be=t[75];let Ve=!W,He;t[76]!==l||t[77]!==R?(He=l({id:`c5f7sm`,values:{currentLabel:R}}),t[76]=l,t[77]=R,t[78]=He):He=t[78];let Ue;t[79]===R?Ue=t[80]:(Ue=(0,X.jsx)(`span`,{children:R}),t[79]=R,t[80]=Ue);let We;t[81]===W?We=t[82]:(We=W?(0,X.jsx)(Hi,{className:`size-3 opacity-60`,"aria-hidden":`true`}):null,t[81]=W,t[82]=We);let Ge;t[83]!==Ve||t[84]!==He||t[85]!==Ue||t[86]!==We?(Ge=(0,X.jsx)(wc,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,disabled:Ve,className:`ok-codeblock-chrome-btn ok-codeblock-chrome-lang`,"aria-label":He,children:[Ue,We]})}),t[83]=Ve,t[84]=He,t[85]=Ue,t[86]=We,t[87]=Ge):Ge=t[87];let Ke;t[88]===l?Ke=t[89]:(Ke=l({id:`G_mWXb`}),t[88]=l,t[89]=Ke);let qe;t[90]===Ke?qe=t[91]:(qe=(0,X.jsx)(px,{placeholder:Ke}),t[90]=Ke,t[91]=qe);let Je;t[92]===l?Je=t[93]:(Je=l({id:`ETyvvg`}),t[92]=l,t[93]=Je);let Ye;t[94]===Je?Ye=t[95]:(Ye=(0,X.jsx)(hx,{children:Je}),t[94]=Je,t[95]=Ye);let Xe;t[96]!==a.commands||t[97]!==z||t[98]!==T||t[99]!==r?(Xe=xZ.map(e=>{let t=e.value===eQ?!T||z===eQ:z===e.value;return(0,X.jsxs)(_x,{value:`${e.label} ${e.value} ${e.aliases?.join(` `)??``}`,onSelect:()=>{r({language:e.value===eQ?null:e.value}),d(!1),a.commands.focus()},children:[(0,X.jsx)(`span`,{className:`flex-1`,children:e.label}),t?(0,X.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`}):null]},e.value)}),t[96]=a.commands,t[97]=z,t[98]=T,t[99]=r,t[100]=Xe):Xe=t[100];let Ze;t[101]===Xe?Ze=t[102]:(Ze=(0,X.jsx)(gx,{children:Xe}),t[101]=Xe,t[102]=Ze);let Qe;t[103]!==Ye||t[104]!==Ze?(Qe=(0,X.jsxs)(mx,{children:[Ye,Ze]}),t[103]=Ye,t[104]=Ze,t[105]=Qe):Qe=t[105];let $e;t[106]!==qe||t[107]!==Qe?($e=(0,X.jsx)(Tc,{align:`end`,sideOffset:6,className:`w-56 p-0`,children:(0,X.jsxs)(dx,{filter:iQ,children:[qe,Qe]})}),t[106]=qe,t[107]=Qe,t[108]=$e):$e=t[108];let et;t[109]!==u||t[110]!==Ge||t[111]!==$e?(et=(0,X.jsxs)(Cc,{open:u,onOpenChange:d,children:[Ge,$e]}),t[109]=u,t[110]=Ge,t[111]=$e,t[112]=et):et=t[112];let tt;t[113]!==l||t[114]!==W||t[115]!==V?(tt=W&&V?(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":l({id:`R3y75Z`}),"data-testid":`ok-codeblock-edit-btn`,onClick:()=>M(!0),children:(0,X.jsx)(Ma,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[113]=l,t[114]=W,t[115]=V,t[116]=tt):tt=t[116];let nt;t[117]!==l||t[118]!==W||t[119]!==ye||t[120]!==te||t[121]!==B?(nt=W&&te?(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"data-active":B?`true`:void 0,"aria-pressed":B,"aria-label":l(B?{id:`xHGM4U`}:{id:`7OwvEL`}),onClick:ye,children:B?(0,X.jsx)(ea,{className:`size-3.5`}):(0,X.jsx)(ta,{className:`size-3.5`})}):null,t[117]=l,t[118]=W,t[119]=ye,t[120]=te,t[121]=B,t[122]=nt):nt=t[122];let rt;t[123]!==l||t[124]!==W||t[125]!==xe||t[126]!==k||t[127]!==O||t[128]!==F||t[129]!==P?(rt=W?(0,X.jsxs)(Cc,{open:k,onOpenChange:A,children:[(0,X.jsx)(wc,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"data-active":O?`true`:void 0,"aria-label":l({id:`DDTdLl`}),children:(0,X.jsx)(Ia,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(Tc,{align:`end`,sideOffset:6,className:`w-64 p-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:P,className:`text-2xs font-mono uppercase tracking-wide text-muted-foreground`,children:(0,X.jsx)(o,{id:`MHrjPM`})}),(0,X.jsx)(cr,{id:P,type:`text`,value:O??``,placeholder:l({id:`mk2poV`}),"data-testid":`ok-codeblock-title-input`,"aria-describedby":F,onChange:e=>xe(e.target.value),onKeyDown:e=>{(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),A(!1))},className:`h-8`}),(0,X.jsx)(`p`,{id:F,className:`text-2xs text-muted-foreground`,children:(0,X.jsx)(o,{id:`lond3p`})})]})})]}):null,t[123]=l,t[124]=W,t[125]=xe,t[126]=k,t[127]=O,t[128]=F,t[129]=P,t[130]=rt):rt=t[130];let it;t[131]!==l||t[132]!==f?(it=l(f?{id:`6V3Ea3`}:{id:`NmPNJJ`}),t[131]=l,t[132]=f,t[133]=it):it=t[133];let at;t[134]===f?at=t[135]:(at=f?(0,X.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`}):(0,X.jsx)(Zi,{className:`size-3.5`,"aria-hidden":`true`}),t[134]=f,t[135]=at);let ot;t[136]!==he||t[137]!==it||t[138]!==at?(ot=(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn`,"aria-label":it,onClick:he,children:at}),t[136]=he,t[137]=it,t[138]=at,t[139]=ot):ot=t[139];let st;t[140]!==l||t[141]!==W||t[142]!==_e?(st=W?(0,X.jsx)(`button`,{type:`button`,className:`ok-codeblock-chrome-btn ok-codeblock-chrome-btn--delete`,"aria-label":l({id:`oBXkm2`}),onClick:_e,children:(0,X.jsx)(Ka,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[140]=l,t[141]=W,t[142]=_e,t[143]=st):st=t[143];let ct;t[144]!==et||t[145]!==tt||t[146]!==nt||t[147]!==rt||t[148]!==ot||t[149]!==st?(ct=(0,X.jsxs)(`div`,{className:`ok-codeblock-chrome`,contentEditable:!1,onMouseDown:aQ,...Be,children:[et,tt,nt,rt,ot,st]}),t[144]=et,t[145]=tt,t[146]=nt,t[147]=rt,t[148]=ot,t[149]=st,t[150]=ct):ct=t[150];let lt;t[151]!==l||t[152]!==S||t[153]!==j||t[154]!==W||t[155]!==Ce||t[156]!==n.textContent||t[157]!==z||t[158]!==V||t[159]!==w?(lt=W&&V?(0,X.jsx)(bZ,{open:j,onOpenChange:M,initialValue:n.textContent,language:z===`xml`?`html`:`plain`,title:l({id:`R3y75Z`}),renderPreview:e=>(0,X.jsx)(`iframe`,{title:l({id:`G7cMuO`}),sandbox:`allow-scripts`,className:`size-full border-0`,srcDoc:$Z(w,S)+e}),onSave:Ce}):null,t[151]=l,t[152]=S,t[153]=j,t[154]=W,t[155]=Ce,t[156]=n.textContent,t[157]=z,t[158]=V,t[159]=w,t[160]=lt):lt=t[160];let ut;return t[161]!==Ee||t[162]!==De||t[163]!==Oe||t[164]!==ke||t[165]!==Ae||t[166]!==je||t[167]!==Me||t[168]!==ze||t[169]!==ct||t[170]!==lt?(ut=(0,X.jsxs)($l,{className:`ok-codeblock relative my-3`,"data-language":Ee,"data-cursor-inside":De,"data-selected":Oe,"data-preview":ke,"data-code-visible":Ae,children:[je,Me,ze,ct,lt]}),t[161]=Ee,t[162]=De,t[163]=Oe,t[164]=ke,t[165]=Ae,t[166]=je,t[167]=Me,t[168]=ze,t[169]=ct,t[170]=lt,t[171]=ut):ut=t[171],ut}function iQ(e,t){return t?+!!e.toLowerCase().includes(t.toLowerCase()):1}function aQ(e){return e.stopPropagation()}function oQ(e){return e.stopPropagation()}function sQ(){}function cQ(e,t=[]){return e.flatMap(e=>{if(e.type===`text`)return[{text:e.value,classes:t}];let n=[...t,...e.properties?.className??[]];return cQ(e.children,n)})}function lQ(e){let{doc:t,name:n,lowlight:r,defaultLanguage:i}=e,a=[],o=r.listLanguages();return At(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 cQ(c)){let n=t+e.text.length;e.classes.length>0&&a.push(S.inline(t,n,{class:e.classes.join(` `)})),t=n}}),pe.create(t,a)}function uQ(e){let{name:t,lowlight:n,defaultLanguage:r}=e,i=new U({key:new W(`codeBlockLowlight`),state:{init:(e,{doc:i})=>lQ({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=At(a.doc,e=>e.type.name===t),u=At(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)})?lQ({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 dQ=tF(ZP),fQ=x.extend({addNodeView(){return su(rQ)},addProseMirrorPlugins(){return[...this.parent?.()??[],uQ({name:this.name,lowlight:dQ,defaultLanguage:null})]},addInputRules(){return[...this.parent?.()??[],T({find:/^```$/,type:this.type,getAttributes:()=>({language:`js`})})]}});function pQ(e){return!!e.getMeta(qv)}function mQ(e,t){let n=qv.getState(e);return Fy(n.doc,n.type,t,n.binding.mapping)||0}function hQ(e,t){let n=qv.getState(e);return Ny(t,n.type,n.binding.mapping)}var gQ=class e extends rn{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 _Q(e,t){return new gQ(e,hQ(t,e))}function vQ(e,t,n){let r=e instanceof gQ?e.yRelativePosition:null;if(pQ(t)&&r)return{position:new gQ(mQ(n,r),r),mapResult:null};let i=mn(e,t),a=i.position.position;return{position:new gQ(a,r??hQ(n,a)),mapResult:i.mapResult}}var yQ=Dt.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)=>vQ(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>_Q(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Jv.getState(t).undoManager.undoStack.length===0?!1:n?Uy(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),Jv.getState(t).undoManager.redoStack.length===0?!1:n?Wy(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=qy(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let{undoManager:t}=Jv.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()}}},[ny(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new U({key:new W(`filterInvalidContent`),filterTransaction:t=>{if(!pQ(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 bQ(e){if(!e.length)return pe.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(S.node(n,n+r.nodeSize,{class:`ProseMirror-selectednoderange`}))}),pe.create(n,t)}function xQ(e,t,n){let r=n.isText||n.isAtom?0:1;return{start:e+r,end:e+t-r}}function SQ(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 g(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=xQ(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 D(a.resolve(l),a.resolve(u));i.push(p)}),i}var CQ=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 wQ(e.resolve(this.anchor),e.resolve(this.head))}},wQ=class e extends ge{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=SQ(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 CQ(this.anchor,this.head)}};wQ.prototype.visible=!1;function TQ(e){return e instanceof wQ}Dt.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(!TQ(a)){let e=wQ.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(!TQ(a)){let e=wQ.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=wQ.create(i,0,i.content.size,t);return a.setSelection(o),n.dispatch(a),!0}}},onSelectionUpdate(){let{selection:e}=this.editor.state;TQ(e)&&this.editor.view.dom.classList.add(`ProseMirror-noderangeselection`)},addProseMirrorPlugins(){let e=!1,t=!1;return[new U({key:new W(`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=wQ.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=TQ(r);if(e=!1,!t)return i?(e=!0,bQ(r.ranges)):null;let{$from:a,$to:o}=r;if(!i&&a.sameParent(o))return null;let s=SQ(a,o,this.options.depth);return s.length?(e=!0,bQ(s)):null}}})]}});function EQ(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 DQ(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=EQ(e)}),t}var OQ=[{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}],kQ={edges:[`left`,`top`],threshold:12,strength:500};function AQ(e){return e===void 0||e===`left`?{...kQ}: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}:{...kQ,...e}}function jQ(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 MQ(e,t,n,r){return!t||n.edges.length===0?0:jQ(e,t,n)?n.strength*r:0}var NQ=1e3;function PQ(e,t,n,r){let i=NQ,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-=MQ(r,o,n,e.depth),i<=0?-1:i}function FQ(e,t,n){return Array.from({length:t},(e,n)=>t-1-n).some(t=>n.includes(e.node(t).type.name))}function IQ(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(...OQ),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&&!FQ(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=PQ({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=FQ(a,l,n.allowedContainers)),p){let r=PQ({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 LQ(e,t){let n=e;for(;n?.parentElement&&n.parentElement!==t.dom;)n=n.parentElement;return n?.parentElement===t.dom?n:void 0}function RQ(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 zQ(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(!RQ(s)||!RQ(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 BQ=e=>{let{x:t,y:n,editor:r,nestedOptions:i}=e,{view:a,state:o}=r,s=zQ(a,t,n,5);if(!s)return{resultElement:null,resultNode:null,pos:null};let{x:c,y:l}=s;if(i?.enabled){let e=IQ(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=LQ(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 VQ(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 HQ(e){var t;(t=e.parentNode)==null||t.removeChild(e)}function UQ(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=BQ({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 SQ(i.resolve(a.pos),i.resolve(a.pos+a.resultNode.nodeSize+o),0,{extendOnBoundaryOverlap:!1})}function WQ(e,t,n,r){let{view:i}=t;if(!e.dataTransfer)return;let{empty:a,$from:o,$to:s}=i.state.selection,c=UQ(e,t,n,r),l=SQ(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`,VQ(i,m));let g=n?.enabled&&r?.node,_,v;g?(_=i.state.doc.slice(m,h),v=Ct.create(i.state.doc,m)):(v=wQ.create(i.state.doc,m,h),_=v.content()),d.forEach(e=>{let t=DQ(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,HQ(p),document.removeEventListener(`drop`,T),document.removeEventListener(`dragend`,T))},E=v instanceof Ct?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 GQ=(e,t)=>{let n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},KQ=(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},qQ=(e,t)=>{let n=qv.getState(e);return n?Ny(t,n.type,n.binding.mapping):null},JQ=(e,t)=>{let n=qv.getState(e);return n?Fy(n.doc,n.type,t,n.binding.mapping)||0:-1},YQ=(e,t)=>{let n=t;for(;n?.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},XQ=new W(`dragHandle`),ZQ=({pluginKey:e=XQ,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),WQ(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(Qe()){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 U({key:typeof e==`string`?new W(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(pQ(e)){let e=JQ(o,p);e!==f&&(f=e)}else{let t=e.mapping.map(f);t!==f&&(f=t,p=qQ(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=YQ(e,o),o===e.dom||o?.nodeType!==1)return;let s=e.posAtDOM(o,0),c=KQ(n.state.doc,s),l=GQ(n.state.doc,s);d=c,f=l,p=qQ(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&&HQ(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=BQ({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=YQ(e,o),o===e.dom||o?.nodeType!==1)return;let t=e.posAtDOM(o,0);s=KQ(n.state.doc,t),l=GQ(n.state.doc,t)}s!==d&&(d=s,f=l??-1,p=qQ(e.state,f),a?.({editor:n,node:d,pos:f}),v(o),_())})),!1}}}})}};function QQ(e){return e===!1||e===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:AQ(`none`)}:e===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:AQ(`left`)}:{enabled:!0,rules:e.rules??[],defaultRules:e.defaultRules??!0,allowedContainers:e.allowedContainers,edgeDetection:AQ(e.edgeDetection)}}var $Q={placement:`left-start`,strategy:`absolute`};Dt.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=QQ(this.options.nested);return[ZQ({computePositionConfig:{...$Q,...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 e$=20,t$=44,n$=28;function r$(e){if(!e)return`Select block`;if(e.type.name===`jsxComponent`){let t=e.attrs.componentName??``;if(t){let e=sM(t),n=e.name===`*`?t:e.displayName??e.name;if(n)return`Select ${n}`}}return`Select ${e.type.name}`}function i$(){let e=document.createElement(`div`);e.className=`ok-block-controls`,e.setAttribute(gF,`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 a$(e,t,n){let{state:r,view:i}=e;if(n.type.name===`jsxComponent`){let i=n.attrs.componentName??``;if(i){let a=sM(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,pM(o)).run(),_M(e,i,sM(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=F.near(o.doc.resolve(a+1));o.setSelection(c).scrollIntoView(),i.dispatch(o),i.focus(),e.commands.insertContent(`/`)}var o$=Dt.create({name:`blockDragHandle`,addProseMirrorPlugins(){let e=this.editor,t=null,n=-1,{container:r,addBtn:i,grip:a}=i$();return i.addEventListener(`click`,()=>{t&&n>=0&&a$(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()||(an(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;an(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)}))}}),[ZQ({element:r,editor:e,onNodeChange({node:e,pos:r}){t=e,n=r??-1,a.setAttribute(`aria-label`,r$(e))},computePositionConfig:{placement:`left-start`,strategy:`absolute`,middleware:[be(({rects:e})=>({mainAxis:10,crossAxis:((e.reference.height<=t$?e.reference.height:n$)-e$)/2}))]},nestedOptions:QQ(!1)}).plugin]}}),s$=/^#fn(?:ref)?-/,c$=Dt.create({name:`footnoteAnchorScroll`,addProseMirrorPlugins(){return[new U({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(!s$.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}}}})]}}),l$=Dt.create({name:`formattingShortcuts`,addKeyboardShortcuts(){return{"Mod-Shift-x":()=>this.editor.commands.toggleStrike()}}}),u$=Dt.create({name:`headingAnchors`,addProseMirrorPlugins(){return[new U({props:{decorations(e){let t=[],n=new Map;return e.doc.descendants((e,r)=>{if(e.type.name===`heading`){let i=St(e.textContent,n);if(!i)return;t.push(S.node(r,r+e.nodeSize,{id:i}))}}),pe.create(e.doc,t)}}})]}});function d$(e){let t=(0,J.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?ZD(r)??void 0:void 0;s=typeof i==`string`?Re(ae(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,X.jsx)($l,{as:`span`,"data-image-inline-zoom":!0,"data-clipboard-inline-leaf":`image`,children:(0,X.jsx)(qk,{wrapElement:`span`,zoomMargin:20,zoomImg:d,children:(0,X.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 f$=N.extend({addNodeView(){return su(d$)}}),p$=new class{byExt=new Map;viewerUnregisterFns=new WeakMap;register(e){let t=this.viewerUnregisterFns.get(e);if(t)return t;for(let t of e.exts){let n=t.toLowerCase(),r=this.byExt.get(n);r&&r!==e&&console.warn(JSON.stringify({event:`asset-viewer-collision`,ext:n,priorExts:r.exts,newExts:e.exts})),this.byExt.set(n,e)}let n=!1,r=()=>{if(!n){n=!0;for(let t of e.exts){let n=t.toLowerCase();this.byExt.get(n)===e&&this.byExt.delete(n)}this.viewerUnregisterFns.delete(e)}};return this.viewerUnregisterFns.set(e,r),r}lookup(e){let t=this.byExt.get(e.toLowerCase());return t?{ok:!0,viewer:t}:{ok:!1}}clearForTests(){this.byExt.clear(),this.viewerUnregisterFns=new WeakMap}get size(){return this.byExt.size}};function m$(e){globalThis.window?.open(e,`_blank`,`noopener,noreferrer`)}async function h$(e,t={}){let n=t.registry??p$,r=`desktopBridge`in t?t.desktopBridge:globalThis.window?.okDesktop,i=t.openUrl??m$;if(!e.forceOsDelegation){let t=n.lookup(e.ext);if(t.ok){t.viewer.render(e);return}}if(r){let t=await r.shell.openAsset(e.projectRelPath);t.ok||console.warn(`[asset-dispatch] openAsset refused:`,t.reason,{projectRelPath:e.projectRelPath,ext:e.ext});return}i(e.url)}function g$(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=A(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=_e(n.getAttribute(`href`)??``,t);if(e?.kind===`asset`){let n=A(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=_e(e,t);if(n?.kind===`asset`){let e=A(n.url,t);return e?{kind:`image`,relPath:e,title:e.split(`/`).pop()??n.url}:null}}}n=n.parentElement}return null}var _$=new W(`asset-context-menu`);function v$(e){return new U({key:_$,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=g$(t.target,e.sourceDocName);r&&(t.preventDefault(),n(r))};return t.dom.addEventListener(`contextmenu`,r),{destroy(){t.dom.removeEventListener(`contextmenu`,r)}}}})}var y$=e=>{let t=(0,J.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,Y.useRef)(null),f,p;t[0]===o?(f=t[1],p=t[2]):(f=()=>{let e=d.current;if(e)return Ut(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,Y.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,X.jsx)(Ec,{asChild:!0,children:(0,X.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?(_=Sn(`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,X.jsx)(Tc,{side:`bottom`,align:`start`,sideOffset:8,collisionPadding:8,"aria-label":r,"data-ok-prop-panel":n,"data-slot":l,onOpenAutoFocus:b$,onCloseAutoFocus:x$,onPointerDownOutside:S$,onFocusOutside:C$,onInteractOutside:w$,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,X.jsxs)(Cc,{open:!0,onOpenChange:m,children:[h,v]}),t[15]=m,t[16]=v,t[17]=y):y=t[17],y};function b$(e){return e.preventDefault()}function x$(e){return e.preventDefault()}function S$(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function C$(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function w$(e){e.target?.closest(`[data-ok-layer-spawned]`)&&e.preventDefault()}function T$(e){let t=e.trim();return/\.(md|mdx)$/i.test(t)?t:`${t}.md`}function E$(e){let t=e.initialDir.trim().replace(/^\/+|\/+$/g,``),n=T$(e.suggestedName);return t?`${t}/${n}`:n}async function D$(e){let t=await yx(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:bx(Ae,t.body,`create-page`,{docName:n}).docName}}async function O$(e){return D$(E$(e))}async function k$(e,t){let{docName:n}=await O$(e);return t.addPage(n),kt([`files`,`backlinks`,`graph`]),t.onCreated?.(n),{docName:n}}var A$=8;function j$(e){return e.trim().replace(/^\/+/,``).replace(/\.mdx?$/i,``).replace(/\/+$/g,``)}function M$(e){return N$(e)?j$(e.slice(1)).toLowerCase():null}function N$(e){return e.startsWith(`/`)&&!e.startsWith(`//`)}function P$(e){return e.split(`/`).at(-1)??e}function F$(e,t){if(!t)return 0;let n=e.toLowerCase(),r=P$(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 I$(e){switch(e){case`page`:return 0;case`folder`:return 1;case`asset`:return 2}}function L$(e){let t=[],n=new Set;function r(e,r){let i=j$(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 R$(e){let t=M$(e.value);if(t===null)return[];let n=[];for(let r of L$(e)){let e=F$(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=I$(e.suggestion.kind)-I$(t.suggestion.kind);return n===0?e.suggestion.path.localeCompare(t.suggestion.path):n}),n.slice(0,e.limit??A$).map(e=>e.suggestion)}var z$=`[data-ok-link-path-suggestion-panel]`;function B$(e){return e instanceof Element&&e.closest(z$)!==null}function V$(e){B$(e.target)&&e.preventDefault()}function H$(e){switch(e){case`page`:return(0,X.jsx)(ra,{className:`size-3.5 shrink-0`,"aria-hidden":`true`});case`folder`:return(0,X.jsx)(ca,{className:`size-3.5 shrink-0`,"aria-hidden":`true`});case`asset`:return(0,X.jsx)(ja,{className:`size-3.5 shrink-0`,"aria-hidden":`true`})}}function U$(e,t){if(e){if(typeof e==`function`){e(t);return}e.current=t}}function W$(e){let t=(0,J.c)(54),n,r,a,o,s,l,u,d,f,p,m,h,g,_;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14]):({value:_,pages:p,folderPaths:a,assetPaths:n,includeAssets:h,loading:g,onValueChange:f,onKeyDown:u,onSuggestionSelect:d,onFocus:l,onBlur:s,className:r,ref:m,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s,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]=_);let v=h===void 0?!1:h,y=g===void 0?!1:g,{_:b}=i(),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(0),D=(0,Y.useRef)(null),O=(0,Y.useRef)(null),k=(0,Y.useId)(),A;t[15]===_?A=t[16]:(A=_.trim(),t[15]=_,t[16]=A);let j=A===``,M=R$({value:j?`/`:_,pages:p,folderPaths:a,assetPaths:n,includeAssets:v}),N=M.map(Y$).join(`\0`),P;t[17]===_?P=t[18]:(P=N$(_),t[17]=_,t[18]=P);let F=j||P,I=M.length>0,L=x&&!C&&F&&(I||y)||x&&!C&&F&&!y&&!I,ee=Math.min(T,Math.max(M.length-1,0)),z=I?`${k}-option-${ee}`:void 0,te;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{E(0)},t[19]=te):te=t[19],(0,Y.useEffect)(te,[N]);let B,ne;t[20]!==z||t[21]!==L?(B=()=>{!L||!z||document.getElementById(z)?.scrollIntoView?.({block:`nearest`})},ne=[z,L],t[20]=z,t[21]=L,t[22]=B,t[23]=ne):(B=t[22],ne=t[23]),(0,Y.useEffect)(B,ne);let V,re;t[24]===L?(V=t[25],re=t[26]):(V=()=>{if(!L)return;let e=D.current,t=O.current;if(!e||!t)return;let n=e,r=t,i=function(){R(n,r,{placement:`bottom-start`,strategy:`fixed`,middleware:[be(4),Be({padding:8}),c({padding:8}),lt({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=Ut(n,r,i);return i(),a},re=[L],t[24]=L,t[25]=V,t[26]=re),(0,Y.useLayoutEffect)(V,re);let ie;t[27]===m?ie=t[28]:(ie=function(e){D.current=e,U$(m,e)},t[27]=m,t[28]=ie);let H=ie,ae=function(e){d?d(e):f(e.path),w(!0),requestAnimationFrame(()=>D.current?.focus())},oe=function(e){if(I){if(e.key===`ArrowDown`){e.preventDefault(),E(e=>Math.min(e+1,M.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),E(J$);return}if(e.key===`Enter`){e.preventDefault();let t=M[ee];t&&ae(t);return}if(e.key===`Escape`){e.preventDefault(),w(!0);return}}if(L&&e.key===`Escape`){e.preventDefault(),w(!0);return}u?.(e)},U;t[29]===b?U=t[30]:(U=function(e){switch(e){case`page`:return b({id:`6WdDG7`});case`folder`:return b({id:`kNqMMd`});case`asset`:return b({id:`bUUVED`})}},t[29]=b,t[30]=U);let se=U,ce=L?(0,X.jsx)(`div`,{ref:O,id:k,role:`listbox`,"aria-label":b({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:q$,onTouchMove:K$,children:I?M.map((e,t)=>{let n=t===ee,r=se(e.kind);return(0,X.jsxs)(In,{id:`${k}-option-${t}`,type:`button`,role:`option`,"aria-label":`/${e.path} ${r}`,"aria-selected":n,variant:`ghost`,className:Sn(`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:G$,onClick:()=>ae(e),children:[H$(e.kind),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`/`,e.path]}),(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground text-xs`,children:r})]},`${e.kind}:${e.path}`)}):(0,X.jsx)(`div`,{role:`status`,className:`px-2 py-1.5 text-muted-foreground text-sm`,children:b(y?{id:`sxTdZI`}:{id:`_QwkMu`})})}):null,W;t[31]===f?W=t[32]:(W=e=>{w(!1),f(e.target.value)},t[31]=f,t[32]=W);let le;t[33]===l?le=t[34]:(le=e=>{S(!0),l?.(e)},t[33]=l,t[34]=le);let ue;t[35]===s?ue=t[36]:(ue=e=>{S(!1),s?.(e)},t[35]=s,t[36]=ue);let de=L?k:void 0,fe;t[37]!==z||t[38]!==r||t[39]!==oe||t[40]!==o||t[41]!==H||t[42]!==L||t[43]!==W||t[44]!==le||t[45]!==ue||t[46]!==de||t[47]!==_?(fe=(0,X.jsx)(cr,{...o,ref:H,value:_,onChange:W,onFocus:le,onBlur:ue,onKeyDown:oe,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":L,"aria-controls":de,"aria-activedescendant":z,autoComplete:`off`,className:r}),t[37]=z,t[38]=r,t[39]=oe,t[40]=o,t[41]=H,t[42]=L,t[43]=W,t[44]=le,t[45]=ue,t[46]=de,t[47]=_,t[48]=fe):fe=t[48];let pe;t[49]===ce?pe=t[50]:(pe=ce&&(0,no.createPortal)(ce,document.body),t[49]=ce,t[50]=pe);let me;return t[51]!==fe||t[52]!==pe?(me=(0,X.jsxs)(`div`,{className:`relative`,children:[fe,pe]}),t[51]=fe,t[52]=pe,t[53]=me):me=t[53],me}function G$(e){return e.preventDefault()}function K$(e){e.stopPropagation()}function q$(e){e.stopPropagation()}function J$(e){return Math.max(e-1,0)}function Y$(e){return`${e.kind}:${e.path}`}var X$=1500;function Z$(e){let t=(0,J.c)(15),{copyContent:n}=e,[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(null),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{a.current!==null&&clearTimeout(a.current)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,Y.useEffect)(o,s);let c;t[2]===n?c=t[3]:(c=()=>{try{typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(n).then(()=>{i(!0),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),X$)},Q$)}catch{}},t[2]=n,t[3]=c);let l=c,u=r?`Copied!`:`Copy`,d;t[4]===r?d=t[5]:(d=r?(0,X.jsx)(ar,{className:`size-3.5`,"aria-hidden":`true`}):(0,X.jsx)(Zi,{className:`size-3.5`,"aria-hidden":`true`}),t[4]=r,t[5]=d);let f;t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(In,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":u,onClick:l,"data-slot":`prop-panel-copy`,children:d})}),t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9];let p=r?`Copied!`:`Copy`,m;t[10]===p?m=t[11]:(m=(0,X.jsx)(re,{children:p}),t[10]=p,t[11]=m);let h;return t[12]!==f||t[13]!==m?(h=(0,X.jsxs)(P,{children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14],h}function Q$(){}function $$(e,t){return EO.getState(e)?.byId.get(t)??null}function e1(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 t1(e){let{editor:t,layer:n,markTypes:r,predicate:i,renderPropPanel:a,handlePrimary:o}=e,s=e1({editor:t,layer:n,renderPropPanel:a,handlePrimary:o});return jO({markTypes:[...r],predicate:i,onRegister:s.onRegister,onDeregister:s.onDeregister})}function n1(e){let t=GO(e.editor);return t1({...e,layer:t})}function r1(e,t){let n=(0,J.c)(4),[r,i]=(0,Y.useState)(null),a,o;return n[0]!==e||n[1]!==t?(a=()=>{if(!t||!e){i(null);return}let n=!1;return i(null),IX(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,Y.useEffect)(a,o),r}function i1(e,t){let n=e.trim();return n?n.startsWith(`#`)?`anchor`:b(n)?`external`:`doc`:t}function a1(e){return e?.kind===`doc`?`doc`:e?.kind===`anchor`?`anchor`:`external`}function o1(e){let t=(0,J.c)(84),{open:n,href:r,text:a,pages:s,folderPaths:c,loading:l,onOpenChange:u,onSave:d}=e,[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(`doc`),b=(0,Y.useId)(),x=(0,Y.useId)(),S=(0,Y.useId)(),C=(0,Y.useId)(),{_:w}=i(),T=(0,Y.useRef)(!1),E=(0,Y.useRef)(``),D,O;t[0]!==r||t[1]!==n||t[2]!==a?(D=()=>{if(!n){T.current=!1;return}if(T.current)return;T.current=!0,E.current=a,_(a);let e=XY(r);if(y(a1(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,a],t[0]=r,t[1]=n,t[2]=a,t[3]=D,t[4]=O):(D=t[3],O=t[4]),(0,Y.useEffect)(D,O);let k,A,j;t[5]!==v||t[6]!==f||t[7]!==s?(k=ut(f),A=v===`doc`,j=A&&lO(k,s),t[5]=v,t[6]=f,t[7]=s,t[8]=k,t[9]=A,t[10]=j):(k=t[8],A=t[9],j=t[10]);let M=r1(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?aX(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,ee;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(ee=function(e){p(e.path),y(`doc`),h(``)},t[21]=ee):ee=t[21];let R=ee,z;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,X.jsx)(Wn,{children:(0,X.jsx)(o,{id:`B11p-O`})}),t[22]=z):z=t[22];let te;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,X.jsxs)(nr,{children:[z,(0,X.jsx)(Hn,{children:(0,X.jsx)(o,{id:`RobAKV`})})]}),t[23]=te):te=t[23];let B;t[24]===A?B=t[25]:(B=A?(0,X.jsx)(o,{id:`6WdDG7`}):(0,X.jsx)(o,{id:`6vEr3W`}),t[24]=A,t[25]=B);let ne;t[26]!==B||t[27]!==b?(ne=(0,X.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:b,children:B}),t[26]=B,t[27]=b,t[28]=ne):ne=t[28];let V;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(V=e=>{p(e),y(t=>i1(e,t))},t[29]=V):V=t[29];let re;t[30]===w?re=t[31]:(re=w({id:`Xl-UUg`}),t[30]=w,t[31]=re);let ie;t[32]!==f||t[33]!==c||t[34]!==L||t[35]!==l||t[36]!==s||t[37]!==re||t[38]!==b?(ie=(0,X.jsx)(W$,{id:b,value:f,pages:s,folderPaths:c,loading:l,onValueChange:V,onSuggestionSelect:R,placeholder:re,autoFocus:!0,onKeyDown:L}),t[32]=f,t[33]=c,t[34]=L,t[35]=l,t[36]=s,t[37]=re,t[38]=b,t[39]=ie):ie=t[39];let H;t[40]!==ne||t[41]!==ie?(H=(0,X.jsxs)(`div`,{children:[ne,ie]}),t[40]=ne,t[41]=ie,t[42]=H):H=t[42];let ae;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,X.jsx)(o,{id:`QqBQu1`,components:{0:(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[43]=ae):ae=t[43];let oe;t[44]===S?oe=t[45]:(oe=(0,X.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:S,children:ae}),t[44]=S,t[45]=oe);let U;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>_(e.target.value),t[46]=U):U=t[46];let se;t[47]===w?se=t[48]:(se=w({id:`yYR6za`}),t[47]=w,t[48]=se);let ce;t[49]!==g||t[50]!==L||t[51]!==S||t[52]!==se?(ce=(0,X.jsx)(cr,{id:S,value:g,onChange:U,placeholder:se,onKeyDown:L}),t[49]=g,t[50]=L,t[51]=S,t[52]=se,t[53]=ce):ce=t[53];let W;t[54]!==oe||t[55]!==ce?(W=(0,X.jsxs)(`div`,{children:[oe,ce]}),t[54]=oe,t[55]=ce,t[56]=W):W=t[56];let le;t[57]!==w||t[58]!==x||t[59]!==A||t[60]!==m||t[61]!==L||t[62]!==C||t[63]!==M||t[64]!==N?(le=A?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1.5 inline-block text-sm font-medium`,htmlFor:x,children:(0,X.jsx)(o,{id:`Tjc1pH`,components:{0:(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`})}})}),(0,X.jsx)(cr,{id:x,value:m,onChange:e=>h(e.target.value),placeholder:w({id:`W-ntoW`}),onKeyDown:L}),N?(0,X.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,X.jsxs)(`button`,{type:`button`,"aria-pressed":m===e.slug,className:Sn(`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,X.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,X.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]=le):le=t[65];let ue;t[66]!==H||t[67]!==W||t[68]!==le?(ue=(0,X.jsxs)(Qn,{className:`space-y-6 pb-1`,children:[H,W,le]}),t[66]=H,t[67]=W,t[68]=le,t[69]=ue):ue=t[69];let de;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,X.jsx)(tr,{asChild:!0,children:(0,X.jsx)(In,{variant:`outline`,children:(0,X.jsx)(o,{id:`dEgA5A`})})}),t[70]=de):de=t[70];let fe;t[71]===f?fe=t[72]:(fe=f.trim(),t[71]=f,t[72]=fe);let pe=!fe,me;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,X.jsx)(o,{id:`tfDRzk`}),t[73]=me):me=t[73];let he;t[74]!==F||t[75]!==pe?(he=(0,X.jsxs)($n,{children:[de,(0,X.jsx)(In,{onClick:F,disabled:pe,children:me})]}),t[74]=F,t[75]=pe,t[76]=he):he=t[76];let ge;t[77]!==ue||t[78]!==he?(ge=(0,X.jsxs)(Yn,{className:`sm:max-w-xl`,"data-ok-layer-spawned":``,onPointerDownOutside:V$,onFocusOutside:V$,onInteractOutside:V$,children:[te,ue,he]}),t[77]=ue,t[78]=he,t[79]=ge):ge=t[79];let _e;return t[80]!==u||t[81]!==n||t[82]!==ge?(_e=(0,X.jsx)(rr,{open:n,onOpenChange:u,children:ge}),t[80]=u,t[81]=n,t[82]=ge,t[83]=_e):_e=t[83],_e}function s1(e){let t=(0,J.c)(99),{editor:n,nodeId:r,sourceDocName:a,onClose:s,onNavigate:c}=e,l=$$(n.state,r),u=l?.attrs?.href??``,[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1),h;t[0]!==r||t[1]!==f?(h=()=>{TO(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,Y.useEffect)(h,g);let{addPage:_,folderPaths:v,pages:y,loading:b}=yt(),{_:x}=i();if(!l)return null;let S=n.state.doc.textBetween(l.from,l.to),C=u?_e(u,a):null,w;t[5]!==n||t[6]!==r?(w=function(e,t,i){let a=$$(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]!==s?(E=function(){let e=$$(n.state,r);e&&(n.chain().focus().setTextSelection({from:e.from,to:e.to}).extendMarkRange(`link`).unsetLink().run(),s())},t[8]=n,t[9]=r,t[10]=s,t[11]=E):E=t[11];let D=E,O;t[12]!==n||t[13]!==r||t[14]!==s||t[15]!==f?(O=function(e){if(e){f(!0);return}let t=$$(n.state,r);if(t?.attrs?.href??``){f(!1);return}t&&n.chain().focus().deleteRange({from:t.from,to:t.to}).run(),s()},t[12]=n,t[13]=r,t[14]=s,t[15]=f,t[16]=O):O=t[16];let k=(0,X.jsx)(o1,{open:d,href:u,text:S,pages:y,folderPaths:v,loading:b,onOpenChange:u?f:O,onSave:T});if(!u)return(0,X.jsx)(X.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=$$(n.state,r);t&&n.chain().setTextSelection({from:t.from,to:t.to}).extendMarkRange(`link`).updateAttributes(`link`,{href:aX(e,C?.kind===`doc`?C.anchor??null:null)}).run()},M,N=!1,F=!1,I=null;if(b){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ta,{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,X.jsx)(aa,{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,X.jsx)(xe,{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,X.jsx)(aa,{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=VY(C.docName,{pages:y,folderPaths:v});if(F=e.kind===`navigate`&&e.displayState===`folder`,N=e.kind===`create`,I=e.kind===`create`?{initialDir:e.initialDir,suggestedName:e.suggestedName}:null,F){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(ca,{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,X.jsx)(Wi,{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,X.jsx)(aa,{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,X.jsx)(Wi,{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 L=C?.kind===`external`,ee=C?.kind===`doc`?ZY({docName:C.docName,anchor:C.anchor}):C?.kind===`anchor`?ZY({docName:a,anchor:C.anchor}):C?.kind===`external`&&JY(C.url)?C.url:null,R=!b&&ee!==null&&(C?.kind===`anchor`||C?.kind===`external`||C?.kind===`doc`&&!N&&!F),z;t[25]!==n.state||t[26]!==n.view||t[27]!==r?(z=()=>{let e=$$(n.state,r);if(!e)return new DOMRect;try{return un(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 B=te,ne;t[32]!==x||t[33]!==_||t[34]!==p||t[35]!==I||t[36]!==s||t[37]!==j?(ne=async function(){if(!(!I||p)){m(!0);try{await k$(I,{addPage:_,onCreated(e){j(e),window.location.hash=`#/${e}`,s()}}),m(!1)}catch(e){let t=e;or.error(t instanceof Error?t.message:x({id:`tfi40B`})),m(!1)}}},t[32]=x,t[33]=_,t[34]=p,t[35]=I,t[36]=s,t[37]=j,t[38]=ne):ne=t[38];let V=ne,ie=Sn(`flex shrink-0`,M.className),H;t[39]!==M.icon||t[40]!==ie?(H=(0,X.jsx)(`span`,{className:ie,children:M.icon}),t[39]=M.icon,t[40]=ie,t[41]=H):H=t[41];let ae=H,oe;t[42]!==ae||t[43]!==N||t[44]!==M.text?(oe=N?(0,X.jsxs)(P,{children:[(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`internal-link-prop-panel-icon-trigger`,children:ae})}),(0,X.jsx)(re,{children:M.text})]}):ae,t[42]=ae,t[43]=N,t[44]=M.text,t[45]=oe):oe=t[45];let U=oe,se=`${M.text}: ${A}`,ce;t[46]!==A||t[47]!==L||t[48]!==N||t[49]!==ee||t[50]!==R||t[51]!==s||t[52]!==c?(ce=(0,X.jsx)(vn,{asChild:!0,children:R?(0,X.jsx)(`a`,{href:ee??void 0,...L?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>nX(e,c,s),"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,X.jsx)(`span`,{"data-slot":`internal-link-prop-panel-text`,className:Sn(`block truncate text-sm font-medium`,N?`text-muted-foreground`:`text-foreground`),children:A})}),t[46]=A,t[47]=L,t[48]=N,t[49]=ee,t[50]=R,t[51]=s,t[52]=c,t[53]=ce):ce=t[53];let W;t[54]===A?W=t[55]:(W=(0,X.jsx)(re,{className:`max-w-80 break-all`,children:A}),t[54]=A,t[55]=W);let le;t[56]!==ce||t[57]!==W?(le=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(P,{children:[ce,W]})}),t[56]=ce,t[57]=W,t[58]=le):le=t[58];let ue;t[59]!==V||t[60]!==p||t[61]!==N?(ue=N?(0,X.jsxs)(In,{type:`button`,size:`sm`,variant:`link`,disabled:p,onClick:()=>void V(),"data-slot":`internal-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,X.jsx)(Na,{className:`size-3.5`,"aria-hidden":`true`}),p?(0,X.jsx)(o,{id:`HM56Bx`}):(0,X.jsx)(o,{id:`XRuL0i`})]}):null,t[59]=V,t[60]=p,t[61]=N,t[62]=ue):ue=t[62];let de;t[63]===x?de=t[64]:(de=x({id:`ePK91l`}),t[63]=x,t[64]=de);let fe;t[65]===f?fe=t[66]:(fe=()=>f(!0),t[65]=f,t[66]=fe);let pe;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,X.jsx)(Ma,{className:`size-3.5`,"aria-hidden":`true`}),t[67]=pe):pe=t[67];let me;t[68]!==de||t[69]!==fe?(me=(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(In,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":de,onClick:fe,"data-slot":`internal-link-prop-panel-edit`,children:pe})}),t[68]=de,t[69]=fe,t[70]=me):me=t[70];let he;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,X.jsx)(re,{children:(0,X.jsx)(o,{id:`ePK91l`})}),t[71]=he):he=t[71];let ge;t[72]===me?ge=t[73]:(ge=(0,X.jsxs)(P,{children:[me,he]}),t[72]=me,t[73]=ge);let ve;t[74]===u?ve=t[75]:(ve=(0,X.jsx)(Z$,{copyContent:u}),t[74]=u,t[75]=ve);let ye;t[76]===x?ye=t[77]:(ye=x({id:`t_YqKh`}),t[76]=x,t[77]=ye);let be;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,X.jsx)(Ka,{className:`size-3.5`,"aria-hidden":`true`}),t[78]=be):be=t[78];let Se;t[79]!==D||t[80]!==ye?(Se=(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(In,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":ye,onClick:D,"data-slot":`internal-link-prop-panel-remove`,children:be})}),t[79]=D,t[80]=ye,t[81]=Se):Se=t[81];let Ce;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,X.jsx)(re,{children:(0,X.jsx)(o,{id:`t_YqKh`})}),t[82]=Ce):Ce=t[82];let we;t[83]===Se?we=t[84]:(we=(0,X.jsxs)(P,{children:[Se,Ce]}),t[83]=Se,t[84]=we);let Te;t[85]!==ue||t[86]!==ge||t[87]!==ve||t[88]!==we?(Te=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[ue,ge,ve,we]}),t[85]=ue,t[86]=ge,t[87]=ve,t[88]=we,t[89]=Te):Te=t[89];let Ee;t[90]!==U||t[91]!==le||t[92]!==Te?(Ee=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[U,le,Te]}),t[90]=U,t[91]=le,t[92]=Te,t[93]=Ee):Ee=t[93];let De;return t[94]!==s||t[95]!==se||t[96]!==Ee||t[97]!==B?(De=(0,X.jsx)(y$,{kind:`internal-link`,ariaLabel:se,onDeactivate:s,triggerReference:B,className:`w-96`,children:Ee}),t[94]=s,t[95]=se,t[96]=Ee,t[97]=B,t[98]=De):De=t[98],(0,X.jsxs)(X.Fragment,{children:[k,De]})}new W(`markIdentityDecoration`);var c1=`data-mark-id`,l1=new W(`linkResolutionDecoration`);function u1(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={[c1]:e.id};t!==null&&Object.assign(o,t),a.push(S.inline(e.from,e.to,o))}return a.length===0?null:pe.create(e,a)}function d1(e){let t=new Set(e.markTypes),{computeAttrs:n}=e;return new U({key:l1,state:{init:()=>({version:0}),apply(e,t){let n=e.getMeta(l1);return n&&typeof n==`object`&&n.refresh?{version:t.version+1}:t}},props:{decorations(e){let r=EO.getState(e);if(!r)return null;let i=pn();return u1(e.doc,r.byId,t,n,i)}},view(e){Z(`ok/render/decoration-merge`,{markTypes:Array.from(t).join(`,`)},{startTime:performance.now(),duration:0});let n=Ze(()=>{e.dispatch(e.state.tr.setMeta(l1,{refresh:!0}))});return{destroy(){n()}}}})}var f1=Le.extend({addOptions(){return{...this.parent?.(),docName:``}},renderHTML({HTMLAttributes:e}){let t=typeof e.href==`string`?e.href:``;return[`span`,v(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=$$(t.state,n),a=i?.attrs?.href;if(typeof a!=`string`||!a)return!1;let o=i?.attrs?.sourceForm,s=_e(a,e),c=u(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=A(t,e);if(!i)return!1;let o=pn();return o===null||o.assetPaths!==void 0&&!UY(t,e,o.assetPaths)?!1:(h$({url:t,projectRelPath:i,ext:n,title:i.split(`/`).pop()??t,forceOsDelegation:r}),!0)}if(!s)return!1;switch(s.kind){case`doc`:{let e=pn(),t=VY(s.docName,{pages:e?.pages??new Set,folderPaths:e?.folderPaths??new Set});return t.kind===`create`||t.kind===`navigate`&&t.displayState===`folder`?!1:(r?eX({docName:s.docName,anchor:s.anchor}):window.location.assign(ZY({docName:s.docName,anchor:s.anchor})),!0)}case`anchor`:return r?eX({docName:e,anchor:s.anchor}):window.location.assign(ZY({docName:e,anchor:s.anchor})),!0;case`external`:return JY(s.url)?(QY(s.url),!0):!1;default:return y(s)}};return[n1({editor:this.editor,markTypes:[`link`],renderPropPanel:({editor:n,nodeId:r,deactivate:i})=>(0,Y.createElement)(s1,{editor:n,nodeId:r,sourceDocName:e,onClose:i,onNavigate:e=>t({editor:n,nodeId:r,newTab:e})}),handlePrimary:t}),d1({markTypes:[`link`],computeAttrs:KY(e)}),v$({sourceDocName:e})]}}),p1=(0,Y.createContext)(null),m1={didCatch:!1,error:null},h1=class extends Y.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=m1}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(m1))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&g1(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(m1))}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,Y.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,Y.createElement)(p1.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function g1(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}function _1(e){let t=(0,J.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=Sn(`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,X.jsx)(n,{size:16,"aria-hidden":`true`}),t[11]=n,t[12]=d);let f;t[13]===i?f=t[14]:(f=(0,X.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,X.jsxs)(`div`,{...o,role:`button`,tabIndex:-1,contentEditable:!1,"data-descriptor-placeholder":``,"data-selected":c,onClick:a,onMouseDown:v1,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 v1(e){e.preventDefault(),e.stopPropagation()}function y1(e){let t=(0,J.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,X.jsx)(Ys,{"data-slot":`select`,...n}),t[2]=n,t[3]=r),r}function b1(e){let t=(0,J.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,X.jsx)(Zs,{"data-slot":`select-value`,...n}),t[2]=n,t[3]=r),r}function x1(e){let t=(0,J.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className: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=Sn(`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,X.jsx)(Qs,{asChild:!0,children:(0,X.jsx)(Hi,{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,X.jsxs)(Xs,{"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 S1(e){let t=(0,J.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=Sn(`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,X.jsx)(w1,{}),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=Sn(`p-1`,u),t[9]=u,t[10]=d);let f;t[11]!==n||t[12]!==d?(f=(0,X.jsx)(tc,{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,X.jsx)(T1,{}),t[14]=p):p=t[14];let m;return t[15]!==o||t[16]!==i||t[17]!==c||t[18]!==f?(m=(0,X.jsx)($s,{children:(0,X.jsxs)(ec,{"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 C1(e){let t=(0,J.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=Sn(`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,X.jsx)(`span`,{className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,X.jsx)(ic,{children:(0,X.jsx)(ar,{className:`size-4`})})}),t[6]=o):o=t[6];let s;t[7]===n?s=t[8]:(s=(0,X.jsx)(rc,{children:n}),t[7]=n,t[8]=s);let c;return t[9]!==i||t[10]!==a||t[11]!==s?(c=(0,X.jsxs)(nc,{"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 w1(e){let t=(0,J.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=Sn(`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,X.jsx)(Ui,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,X.jsx)(ac,{"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 T1(e){let t=(0,J.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=Sn(`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,X.jsx)(Hi,{className:`size-4`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,X.jsx)(oc,{"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 E1(e){let t=(0,J.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=Sn(`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,X.jsx)(yc,{"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,X.jsx)(vc,{"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 D1(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 O1(e){let t=(0,J.c)(36),{id:n,value:r,onChange:i,autoFocus:a}=e,o=(0,Y.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=Sn(`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,X.jsx)(cr,{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,X.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,X.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,X.jsx)(In,{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,X.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]:(_=D1(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,X.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,X.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,X.jsx)(In,{type:`button`,variant:`ghost`,size:`xs`,"aria-label":`Clear color`,"data-color-picker-clear":``,className:`h-7 px-1.5`,onClick:()=>i(``),children:(0,X.jsx)(Qi,{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,X.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 k1(e){let t=(0,J.c)(43),{id:n,value:r,onChange:i,autoFocus:a}=e,[o,s]=(0,Y.useState)(!1),c;t[0]===r?c=t[1]:(c=XO(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=Sn(`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,X.jsx)(cr,{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,X.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,X.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,X.jsx)(Hi,{className:`size-3`,"aria-hidden":`true`}),t[20]=y):y=t[20];let b;t[21]===o?b=t[22]:(b=(0,X.jsx)(wc,{asChild:!0,children:(0,X.jsx)(In,{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,X.jsx)(px,{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,X.jsx)(hx,{children:`No icons match.`}),t[24]=S):S=t[24];let C;t[25]!==i||t[26]!==r.length?(C=r.length>0&&(0,X.jsx)(gx,{children:(0,X.jsxs)(_x,{value:`__clear__`,onSelect:()=>{i(``),s(!1)},className:`gap-2 text-muted-foreground`,"data-icon-picker-clear":``,children:[(0,X.jsx)(Un,{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=YO.map(e=>{let[t,n]=e,r=t===d;return(0,X.jsx)(_x,{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:Sn(`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,X.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,X.jsx)(gx,{heading:`Lucide`,children:(0,X.jsx)($b.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,X.jsx)(Tc,{align:`end`,className:`z-70 w-72 p-0`,onOpenAutoFocus:A1,children:(0,X.jsxs)(dx,{label:`Icon picker`,children:[x,(0,X.jsxs)(mx,{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,X.jsxs)(Cc,{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,X.jsxs)(`div`,{className:`flex gap-1`,children:[v,D]}),t[40]=D,t[41]=v,t[42]=O):O=t[42],O}function A1(e){return e.preventDefault()}function j1(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 M1(e){if(e.length===1&&e[0]===`*/*`)return`all`;let t=new Set;for(let n of e){if(n===`*/*`)return`all`;let e=j1(n);e&&t.add(e)}return t}function N1(e){let t=e.lastIndexOf(`.`);return t<0||t<e.lastIndexOf(`/`)?``:e.slice(t+1).toLowerCase()}function P1(e,t){let n=M1(t),r=[];for(let t of e){if(n===`all`){r.push(t);continue}let e=ve(N1(t));e&&n.has(e)&&r.push(t)}return r}var F1=8,I1=new Set,L1=null;function R1(e){return{path:e,basename:e.split(`/`).pop()??e}}function z1(e){let t=e.map(e=>e.path).join(``);return L1?.fingerprint===t||(L1={fingerprint:t,byPath:new Map(e.map(e=>[e.path,e])),itemsInOrder:e,corpus:Gt(e.map(e=>te({kind:`page`,path:e.path,title:e.basename})))}),L1}function B1(e){let t=e.trim();return t.startsWith(`/`)?t.slice(1):t}function V1(e,t){let n=B1(t);return n?Kt(e.corpus,n,{intent:`autocomplete`,limit:F1}).map(t=>e.byPath.get(t.document.path)).filter(e=>!!e):e.itemsInOrder.slice(0,F1)}function H1(e){let t=(0,J.c)(51),{value:n,onChange:r,accept:i,id:a,placeholder:o,autoFocus:s,ariaInvalid:c,ariaDescribedBy:l,dataPropAutofocus:u,className:d}=e,f=Jt()?.assetPaths??I1,p;t[0]!==i||t[1]!==f||t[2]!==n?(p=V1(z1(P1(f,i).map(R1)),n),t[0]=i,t[1]=f,t[2]=n,t[3]=p):p=t[3];let m=p,[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(0),y,b;t[4]!==_||t[5]!==m.length?(y=()=>{_>=m.length&&v(0)},b=[_,m.length],t[4]=_,t[5]=m.length,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,Y.useEffect)(y,b);let x=(0,Y.useId)(),S=(0,Y.useRef)(null),C=h&&m.length>0,w;t[8]===r?w=t[9]:(w=e=>{r(`/${e.path}`),g(!1),v(0),S.current?.focus()},t[8]=r,t[9]=w);let T=w,E;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>g(e),t[10]=E):E=t[10];let D=C?x:void 0,O=C&&m[_]?`${x}-opt-${_}`:void 0,k;t[11]===r?k=t[12]:(k=e=>{r(e.target.value),g(!0),v(0)},t[11]=r,t[12]=k);let A,j;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>{g(!0)},A=()=>{g(!0)},t[13]=A,t[14]=j):(A=t[13],j=t[14]);let M;t[15]!==_||t[16]!==T||t[17]!==m||t[18]!==C?(M=e=>{if(e.key===`ArrowDown`){if(m.length===0)return;e.preventDefault(),g(!0),v(e=>(e+1)%m.length);return}if(e.key===`ArrowUp`){if(m.length===0)return;e.preventDefault(),g(!0),v(e=>(e-1+m.length)%m.length);return}if(e.key===`Enter`){if(!C)return;let t=m[_];if(!t)return;e.preventDefault(),T(t);return}if(e.key===`Escape`){if(!C)return;e.preventDefault(),e.stopPropagation(),g(!1);return}e.key===`Tab`&&g(!1)},t[15]=_,t[16]=T,t[17]=m,t[18]=C,t[19]=M):M=t[19];let N;t[20]!==l||t[21]!==c||t[22]!==s||t[23]!==d||t[24]!==u||t[25]!==a||t[26]!==o||t[27]!==M||t[28]!==D||t[29]!==O||t[30]!==k||t[31]!==n||t[32]!==C?(N=(0,X.jsx)(Ec,{asChild:!0,children:(0,X.jsx)(cr,{ref:S,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":C,"aria-controls":D,"aria-activedescendant":O,className:d,onChange:k,onFocus:j,onClick:A,onKeyDown:M})}),t[20]=l,t[21]=c,t[22]=s,t[23]=d,t[24]=u,t[25]=a,t[26]=o,t[27]=M,t[28]=D,t[29]=O,t[30]=k,t[31]=n,t[32]=C,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{let t=e.target;t instanceof Node&&S.current?.contains(t)&&e.preventDefault()},t[34]=P):P=t[34];let F;if(t[35]!==_||t[36]!==x||t[37]!==T||t[38]!==m){let e;t[40]!==_||t[41]!==x||t[42]!==T?(e=(e,t)=>{let n=`${x}-opt-${t}`,r=t===_;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{id:n,type:`button`,role:`option`,"aria-selected":r,"data-testid":`src-autocomplete-option`,"data-highlighted":r?``:void 0,className:Sn(`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:()=>v(t),onMouseDown:t=>{t.preventDefault(),T(e)},children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.basename}),e.basename!==e.path&&(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:e.path})]})},e.path)},t[40]=_,t[41]=x,t[42]=T,t[43]=e):e=t[43],F=m.map(e),t[35]=_,t[36]=x,t[37]=T,t[38]=m,t[39]=F}else F=t[39];let I;t[44]!==x||t[45]!==F?(I=(0,X.jsx)(Tc,{align:`start`,sideOffset:4,className:`z-70 w-[--radix-popover-trigger-width] p-1`,onOpenAutoFocus:W1,onCloseAutoFocus:U1,onInteractOutside:P,children:(0,X.jsx)(`ul`,{id:x,"aria-label":`Asset suggestions`,className:`flex flex-col gap-px`,children:F})}),t[44]=x,t[45]=F,t[46]=I):I=t[46];let L;return t[47]!==N||t[48]!==I||t[49]!==C?(L=(0,X.jsxs)(Cc,{open:C,onOpenChange:E,children:[N,I]}),t[47]=N,t[48]=I,t[49]=C,t[50]=L):L=t[50],L}function U1(e){e.preventDefault()}function W1(e){e.preventDefault()}function G1(){if(typeof window>`u`)return null;let e=window.location.hash.match(/^#\/([^?#]+)/);return e?decodeURIComponent(e[1]):null}var K1=`/api/upload`;async function q1(e,t,n={}){let r=n.fetch??globalThis.fetch,i=n.docName===void 0?G1():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(K1,{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 uO(`Upload response is not JSON.`,{cause:e,status:o.status})}if(!o.ok){let e=$t.safeParse(s);throw e.success?Error(e.data.title):new uO(`Upload error response did not match ProblemDetails.`,{cause:e.error,status:o.status})}let c=Ke.safeParse(s);if(!c.success)throw new uO(`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 J1=new Intl.PluralRules(`en-US`);function Y1(e,t,n){return n<=0?`${e} (empty)`:`${e} with ${n} ${J1.select(n)===`one`?`item`:`items`}`}function X1(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 Z1(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 Q1=new Set([`auto`,`inherit`,`initial`,`unset`]),$1=new Set([`px`,`%`,`rem`,`em`,`vh`,`vw`,`ch`,`ex`,`fr`]),e0=/^(-?\d+(?:\.\d+)?)([a-z%]*)$/i;function t0(e){let t=e.trim();if(!t)return{valid:!1,reason:`empty`};if(Q1.has(t.toLowerCase()))return{valid:!0};let n=t.match(e0);if(!n)return{valid:!1,reason:`malformed-syntax`};let r=(n[2]??``).toLowerCase();return r===``||$1.has(r)?{valid:!0}:{valid:!1,reason:`unknown-unit`}}function n0(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 r0={video:sn,audio:Rt,image:Fe},i0={youtube:[`youtube.com`,`youtu.be`,`youtube-nocookie.com`],vimeo:[`vimeo.com`],loom:[`loom.com`]};function a0(e){let t=e.toLowerCase();for(let e of Object.keys(i0)){let n=i0[e];for(let r of n)if(t===r||t.endsWith(`.${r}`))return e}return null}function o0(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 s0=`https://placeholder.invalid`;function c0(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,s0),i=!1}catch{return{valid:!1,reason:`invalid-url`}}}if(t===`video`&&M(n)!==null||t===`video`&&m(n)||t===`video`&&ke(n))return{valid:!0};let a=i?a0(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=o0(r.pathname),s=r0[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 l0(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 u0(e){return`Direct ${e} file URL — ${Array.from(r0[e]).map(e=>`.${e}`).join(`, `)}`}var d0={youtube:`YouTube`,vimeo:`Vimeo`,loom:`Loom`};function f0(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=d0[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(r0[t]).map(e=>`.${e}`).join(`, `);return e.extension===``?`Missing file extension. Accepts: ${n}.`:`Unsupported extension .${e.extension}. Accepts: ${n}.`}function p0(e){return`ok.propPanel.advanced.${e}`}function m0(e){try{return typeof localStorage>`u`?!1:localStorage.getItem(p0(e))===`true`}catch{return!1}}function h0(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(p0(e),t?`true`:`false`)}catch{}}function g0(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 _0(e,t,n){try{let{url:r}=await q1(e,t);n(r)}catch(e){let t=e instanceof Error?e.message:String(e);or.error(G._({id:`02P3hL`,values:{message:t}}))}}function v0(e){let t=(0,J.c)(13),{descriptor:n,values:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=e=>!(`hidden`in e&&e.hidden)&&e.hideWhen?.(r)!==!0&&e.type!==`reactnode`,t[0]=r,t[1]=a);let s=n.props.filter(a),c=s.filter(b0),l=s.filter(y0),u=g0(l,r),d;t[2]===n.props?d=t[3]:(d=X1(n.props),t[2]=n.props,t[3]=d);let f=d,p;t[4]===n.name?p=t[5]:(p=()=>m0(n.name),t[4]=n.name,t[5]=p);let[m,h]=(0,Y.useState)(p);if(s.length===0)return null;let g;t[6]!==f||t[7]!==i||t[8]!==r?(g=e=>(0,X.jsx)(S0,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),isAutoFocused:e.name===f},e.name),t[6]=f,t[7]=i,t[8]=r,t[9]=g):g=t[9];let _=c.map(g),v=l.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,X.jsxs)(dr,{open:m,onOpenChange:e=>{h(e),h0(n.name,e)},children:[(0,X.jsxs)(ur,{"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,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(Hi,{className:`size-3 transition-transform group-data-[state=closed]:-rotate-90`}),(0,X.jsx)(o,{id:`sxkWRg`})]}),u>0&&(0,X.jsx)(Sc,{variant:`secondary`,"data-prop-panel-advanced-count":``,children:u})]}),(0,X.jsx)(lr,{className:`flex flex-col gap-4 pt-2`,children:l.map(e=>(0,X.jsx)(S0,{propDef:e,value:r[e.name],onChange:t=>i(e.name,t),isAutoFocused:e.name===f},e.name))})]})]}),y;return t[10]!==_||t[11]!==v?(y=(0,X.jsxs)(`div`,{"data-prop-panel":``,className:`flex flex-col gap-4 py-2 text-sm`,children:[_,v]}),t[10]=_,t[11]=v,t[12]=y):y=t[12],y}function y0(e){return`advanced`in e&&e.advanced}function b0(e){return!(`advanced`in e&&e.advanced)}function x0(e){throw Error(`PropPanel: unhandled PropDef type ${JSON.stringify(e)}`)}function S0(e){let t=(0,J.c)(159),{propDef:n,value:r,onChange:i,isAutoFocused:a}=e;switch(n.type){case`reactnode`:return null;case`string`:{let e=`prop-${n.name}`,o=n.accept,s=o!==void 0&&o.length>0,c=!n.required&&n.defaultValue===void 0;if(n.language){let o=`${e}-label`,s;t[0]===n.name?s=t[1]:(s=Z1(n.name),t[0]=n.name,t[1]=s);let l;t[2]!==o||t[3]!==e||t[4]!==s?(l=(0,X.jsx)(`label`,{id:o,htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[2]=o,t[3]=e,t[4]=s,t[5]=l):l=t[5];let u=r??``,d;t[6]!==i||t[7]!==c?(d=e=>{if(e===``&&c){i(void 0);return}i(e)},t[6]=i,t[7]=c,t[8]=d):d=t[8];let f;t[9]!==a||t[10]!==o||t[11]!==n.language||t[12]!==e||t[13]!==u||t[14]!==d?(f=(0,X.jsx)(vZ,{id:e,ariaLabelledBy:o,value:u,language:n.language,onChange:d,autoFocus:a}),t[9]=a,t[10]=o,t[11]=n.language,t[12]=e,t[13]=u,t[14]=d,t[15]=f):f=t[15];let p;return t[16]!==l||t[17]!==f?(p=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l,f]}),t[16]=l,t[17]=f,t[18]=p):p=t[18],p}if(n.iconPicker){let o=r??``,s;t[19]===n.name?s=t[20]:(s=Z1(n.name),t[19]=n.name,t[20]=s);let l;t[21]!==e||t[22]!==s?(l=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[21]=e,t[22]=s,t[23]=l):l=t[23];let u;t[24]!==i||t[25]!==c?(u=e=>{if(e===``&&c){i(void 0);return}i(e)},t[24]=i,t[25]=c,t[26]=u):u=t[26];let d;t[27]!==o||t[28]!==a||t[29]!==e||t[30]!==u?(d=(0,X.jsx)(k1,{id:e,value:o,onChange:u,autoFocus:a}),t[27]=o,t[28]=a,t[29]=e,t[30]=u,t[31]=d):d=t[31];let f;return t[32]!==l||t[33]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l,d]}),t[32]=l,t[33]=d,t[34]=f):f=t[34],f}if(n.colorPicker){let o=r??``,s;t[35]===n.name?s=t[36]:(s=Z1(n.name),t[35]=n.name,t[36]=s);let l;t[37]!==e||t[38]!==s?(l=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:s}),t[37]=e,t[38]=s,t[39]=l):l=t[39];let u;t[40]!==i||t[41]!==c?(u=e=>{if(e===``&&c){i(void 0);return}i(e)},t[40]=i,t[41]=c,t[42]=u):u=t[42];let d;t[43]!==o||t[44]!==a||t[45]!==e||t[46]!==u?(d=(0,X.jsx)(O1,{id:e,value:o,onChange:u,autoFocus:a}),t[43]=o,t[44]=a,t[45]=e,t[46]=u,t[47]=d):d=t[47];let f;return t[48]!==l||t[49]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l,d]}),t[48]=l,t[49]=d,t[50]=f):f=t[50],f}if(n.cssLengthInput){let o=r??``,s;if(t[51]!==o){let e=t0(o);s=e.valid?null:n0(e),t[51]=o,t[52]=s}else s=t[52];let l=s,u;t[53]===n.name?u=t[54]:(u=Z1(n.name),t[53]=n.name,t[54]=u);let d;t[55]!==e||t[56]!==u?(d=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:u}),t[55]=e,t[56]=u,t[57]=d):d=t[57];let f;t[58]!==i||t[59]!==c?(f=e=>{let t=e.target.value;if(t===``&&c){i(void 0);return}i(t)},t[58]=i,t[59]=c,t[60]=f):f=t[60];let p=a?``:void 0,m=l===null?void 0:!0,h=l===null?void 0:`${e}-error`,g;t[61]!==o||t[62]!==a||t[63]!==e||t[64]!==f||t[65]!==p||t[66]!==m||t[67]!==h?(g=(0,X.jsx)(cr,{id:e,type:`text`,value:o,placeholder:`100px, 50%, 26rem, auto`,onChange:f,autoFocus:a,"data-prop-autofocus":p,"aria-invalid":m,"aria-describedby":h,className:`h-7 text-sm`,"data-prop-css-length-input":``}),t[61]=o,t[62]=a,t[63]=e,t[64]=f,t[65]=p,t[66]=m,t[67]=h,t[68]=g):g=t[68];let _;t[69]!==l||t[70]!==e?(_=l!==null&&(0,X.jsx)(`p`,{id:`${e}-error`,"data-prop-css-length-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:l}),t[69]=l,t[70]=e,t[71]=_):_=t[71];let v;return t[72]!==d||t[73]!==g||t[74]!==_?(v=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[d,g,_]}),t[72]=d,t[73]=g,t[74]=_,t[75]=v):v=t[75],v}let l,u,d;if(t[76]!==o||t[77]!==r){let e=o===void 0?void 0:l0(o);l=r??``;let n=e===void 0?null:c0(l,e);u=n!==null&&!n.valid&&e!==void 0&&l.trim().length>0?f0(n,e):null,d=e===void 0?void 0:u0(e),t[76]=o,t[77]=r,t[78]=l,t[79]=u,t[80]=d}else l=t[78],u=t[79],d=t[80];let f=d,p;t[81]===n.name?p=t[82]:(p=Z1(n.name),t[81]=n.name,t[82]=p);let m;t[83]!==e||t[84]!==p?(m=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:p}),t[83]=e,t[84]=p,t[85]=m):m=t[85];let h;t[86]!==o||t[87]!==l||t[88]!==a||t[89]!==u||t[90]!==f||t[91]!==i||t[92]!==e||t[93]!==c?(h=o===void 0?(0,X.jsx)(cr,{id:e,type:`text`,value:l,placeholder:f,onChange:e=>{let t=e.target.value;if(t===``&&c){i(void 0);return}i(t)},autoFocus:a,"data-prop-autofocus":a?``:void 0,"aria-invalid":u===null?void 0:!0,"aria-describedby":u===null?void 0:`${e}-error`,className:`h-7 text-sm`}):(0,X.jsx)(H1,{id:e,value:l,onChange:e=>{if(e===``&&c){i(void 0);return}i(e)},accept:o,placeholder:f,autoFocus:a,dataPropAutofocus:a?``:void 0,ariaInvalid:u===null?void 0:!0,ariaDescribedBy:u===null?void 0:`${e}-error`,className:`h-7 text-sm`}),t[86]=o,t[87]=l,t[88]=a,t[89]=u,t[90]=f,t[91]=i,t[92]=e,t[93]=c,t[94]=h):h=t[94];let g;t[95]!==o||t[96]!==i||t[97]!==s?(g=s&&(0,X.jsx)(w0,{accept:o,onUploaded:e=>i(e)}),t[95]=o,t[96]=i,t[97]=s,t[98]=g):g=t[98];let _;t[99]!==h||t[100]!==g?(_=(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[h,g]}),t[99]=h,t[100]=g,t[101]=_):_=t[101];let v;t[102]!==u||t[103]!==e?(v=u!==null&&(0,X.jsx)(`p`,{id:`${e}-error`,"data-prop-media-error":``,className:`text-xs text-destructive`,"aria-live":`polite`,children:u}),t[102]=u,t[103]=e,t[104]=v):v=t[104];let y;return t[105]!==m||t[106]!==_||t[107]!==v?(y=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[m,_,v]}),t[105]=m,t[106]=_,t[107]=v,t[108]=y):y=t[108],y}case`boolean`:{let e=`prop-${n.name}`,a;t[109]===n.name?a=t[110]:(a=Z1(n.name),t[109]=n.name,t[110]=a);let o=a,s;t[111]!==e||t[112]!==o?(s=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[111]=e,t[112]=o,t[113]=s):s=t[113];let c=!!r,l;t[114]===i?l=t[115]:(l=e=>i(e),t[114]=i,t[115]=l);let u;t[116]!==e||t[117]!==c||t[118]!==l?(u=(0,X.jsx)(E1,{id:e,checked:c,onCheckedChange:l}),t[116]=e,t[117]=c,t[118]=l,t[119]=u):u=t[119];let d;return t[120]!==s||t[121]!==u?(d=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s,u]}),t[120]=s,t[121]=u,t[122]=d):d=t[122],d}case`enum`:{let e=`prop-${n.name}`,a=r??n.enumValues[0]??``,o;t[123]===n.name?o=t[124]:(o=Z1(n.name),t[123]=n.name,t[124]=o);let s;t[125]!==e||t[126]!==o?(s=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:o}),t[125]=e,t[126]=o,t[127]=s):s=t[127];let c;t[128]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(b1,{}),t[128]=c):c=t[128];let l;t[129]===e?l=t[130]:(l=(0,X.jsx)(x1,{id:e,size:`sm`,children:c}),t[129]=e,t[130]=l);let u;t[131]===n.enumValues?u=t[132]:(u=n.enumValues.map(C0),t[131]=n.enumValues,t[132]=u);let d;t[133]===u?d=t[134]:(d=(0,X.jsx)(S1,{className:`z-70`,children:u}),t[133]=u,t[134]=d);let f;t[135]!==a||t[136]!==i||t[137]!==l||t[138]!==d?(f=(0,X.jsxs)(y1,{value:a,onValueChange:i,children:[l,d]}),t[135]=a,t[136]=i,t[137]=l,t[138]=d,t[139]=f):f=t[139];let p;return t[140]!==s||t[141]!==f?(p=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,f]}),t[140]=s,t[141]=f,t[142]=p):p=t[142],p}case`number`:{let e=`prop-${n.name}`,a;t[143]===n.name?a=t[144]:(a=Z1(n.name),t[143]=n.name,t[144]=a);let o;t[145]!==e||t[146]!==a?(o=(0,X.jsx)(`label`,{htmlFor:e,className:`text-xs text-muted-foreground`,children:a}),t[145]=e,t[146]=a,t[147]=o):o=t[147];let s=r==null?``:String(r),c;t[148]===i?c=t[149]:(c=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[148]=i,t[149]=c);let l;t[150]!==e||t[151]!==s||t[152]!==c?(l=(0,X.jsx)(cr,{id:e,type:`number`,inputMode:`numeric`,value:s,onChange:c,className:`h-7 text-sm`}),t[150]=e,t[151]=s,t[152]=c,t[153]=l):l=t[153];let u;return t[154]!==o||t[155]!==l?(u=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[o,l]}),t[154]=o,t[155]=l,t[156]=u):u=t[156],u}default:{let e;return t[157]===n?e=t[158]:(e=x0(n),t[157]=n,t[158]=e),e}}}function C0(e){return(0,X.jsx)(C1,{value:e,children:e},e)}function w0(e){let t=(0,J.c)(20),{accept:n,onUploaded:r}=e,{_:a}=i(),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l;t[0]===n?l=t[1]:(l=n.join(`,`),t[0]=n,t[1]=l);let u;t[2]!==n||t[3]!==r?(u=async e=>{let t=e.target.files?.[0];if(t){s(!0);try{await _0(t,n,r)}catch{}s(!1),c.current&&(c.current.value=``)}},t[2]=n,t[3]=r,t[4]=u):u=t[4];let d;t[5]!==l||t[6]!==u?(d=(0,X.jsx)(`input`,{ref:c,type:`file`,accept:l,className:`hidden`,"data-prop-upload-input":``,onChange:u}),t[5]=l,t[6]=u,t[7]=d):d=t[7];let f;t[8]===a?f=t[9]:(f=a({id:`2IXDgU`}),t[8]=a,t[9]=f);let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>c.current?.click(),t[10]=p):p=t[10];let m;t[11]===o?m=t[12]:(m=o?(0,X.jsx)(Ta,{className:`size-3.5 animate-spin`}):(0,X.jsx)(qa,{className:`size-3.5`}),t[11]=o,t[12]=m);let h;t[13]!==f||t[14]!==m||t[15]!==o?(h=(0,X.jsx)(In,{type:`button`,variant:`outline`,size:`sm`,disabled:o,"aria-label":f,"data-prop-upload-trigger":``,className:`h-7 px-2`,onClick:p,children:m}),t[13]=f,t[14]=m,t[15]=o,t[16]=h):h=t[16];let g;return t[17]!==d||t[18]!==h?(g=(0,X.jsxs)(X.Fragment,{children:[d,h]}),t[17]=d,t[18]=h,t[19]=g):g=t[19],g}var T0=new Set([`img`,`CommonMarkImage`,`video`,`audio`]);function E0(e,t,n){if(!T0.has(e)||!n)return t;let r=t.src;if(typeof r!=`string`)return t;let i=ae(r,n);return i===r?t:{...t,src:i}}var D0=`selectionStatePlugin/origin`,O0=`selectionStatePlugin/refresh`,k0=new W(`selectionState`),A0=new Set,j0={selectedBlockId:null,ancestorChain:[],selectionOrigin:`programmatic`,isDragging:!1,rangeEncompassedBlockIds:A0};function M0(e){return k0.getState(e.state)??j0}function N0(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(P0(e,i,a))}if(t instanceof Ct){let r=t.node;r.type.name===`jsxComponent`&&n.push(P0(e,r,t.from))}return n}function P0(e,t,n){let r=t.attrs.componentName??`unknown`;return{bridgeId:F0(e,n),componentName:r,pos:n}}function F0(e,t){return IM.getState(e)?.posToId.get(t)??`pos-${t}`}function I0(e,t){if(t instanceof Ct)return A0;let{from:n,to:r}=t;if(n>=r)return A0;let i=IM.getState(e)?.posToId;if(!i)return A0;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??A0}function L0(e,t,n={}){let r=N0(e,e.selection),i=r[r.length-1],a=I0(e,e.selection),o={selectedBlockId:i?.bridgeId??null,ancestorChain:r,selectionOrigin:n.origin??t.selectionOrigin,isDragging:n.isDragging??t.isDragging,rangeEncompassedBlockIds:a};return R0(t,o)?t:o}function R0(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 z0=new WeakMap;function B0(e,t,n,r){let i=r?.isDragging??t.isDragging,a=!!e.getMeta(O0),o=e.selectionSet&&!a,s=e.getMeta(D0),c=o?r?.pendingOrigin??null:null,l=s??c??t.selectionOrigin;return o&&r&&(r.pendingOrigin=null),L0(n,t,{origin:l,isDragging:i})}var V0=Dt.create({name:`selectionStatePlugin`,addProseMirrorPlugins(){let e=this.editor,t=new U({key:k0,state:{init(e,t){return L0(t,j0)},apply(e,n,r,i){return B0(e,n,i,z0.get(t))}},props:{handleDOMEvents:{mousedown:()=>{let e=z0.get(t);return e&&(e.pendingOrigin=`pointer`),!1},pointerdown:()=>{let e=z0.get(t);return e&&(e.pendingOrigin=`pointer`),!1}},handleKeyDown:(e,n)=>{if(H0(n.key)){let e=z0.get(t);e&&(e.pendingOrigin=`keyboard`)}return!1}},view(n){z0.set(t,{pendingOrigin:null,isDragging:!1});let r=n.dom.parentElement??n.dom,i=()=>{let n=z0.get(t);n&&(n.isDragging=!0,U0(e))},a=()=>{let n=z0.get(t);n&&(n.isDragging=!1,U0(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),z0.delete(t)}}}});return[t]}});function H0(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 U0(e){queueMicrotask(()=>{if(!e.isDestroyed)try{let t=e.state.tr.setMeta(O0,!0);e.view.dispatch(t)}catch{}})}function W0(e){let t=(0,J.c)(5),n;t[0]===e?n=t[1]:(n=()=>e?M0(e):null,t[0]=e,t[1]=n);let[r,i]=(0,Y.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(!e){i(null);return}i(M0(e));let t=()=>{i(M0(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,Y.useEffect)(a,o),r}function G0(e,t){if(e.hasChildren)return!1;let n=X1(e.props);return n===null?!1:t[n]===``}function K0(e){let t=e.placeholder?.label,n=`Add ${(e.displayName??e.name).toLowerCase()}`;return{label:t??n,Icon:qO(e.placeholder?.icon??e.icon)}}var q0=new Set([`img`,`CommonMarkImage`,`Embed`,`video`]),J0=`img, .ok-embed, .ok-video`,Y0=220,X0=`cubic-bezier(0.23, 1, 0.32, 1)`,Z0=`ok-image-align-flip`,Q0=.5;function $0(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function e2(){return typeof requestAnimationFrame==`function`}function t2(e){return e?e.querySelector(J0):null}function n2(e,t){if($0()||!e2()){t();return}let n=t2(e);if(!n){t();return}let r=n.getBoundingClientRect().left;t(),requestAnimationFrame(()=>{let t=t2(e);if(!t)return;for(let e of t.getAnimations())e.id===Z0&&e.cancel();let n=r-t.getBoundingClientRect().left;if(Math.abs(n)<Q0)return;let i=t.animate([{transform:`translateX(${n}px)`},{transform:`translateX(0)`}],{duration:Y0,easing:X0,fill:`none`});i.id=Z0})}function r2(e){if(!e.attrs.sourceDirty&&e.attrs.sourceRaw)return e.attrs.sourceRaw;let t=lA(),n=e.type.schema.node(`doc`,null,[e]);return t.serialize(n.toJSON()).trim()}var i2=new Set(It.map(e=>`${e}:`)),a2=6e4,o2=10,s2=new Map;function c2(e,t){let n=t.toLowerCase();qe(n);let r=Date.now(),i=s2.get(n);if(!i||r-i.windowStart>=a2)s2.set(n,{windowStart:r,count:1});else if(i.count+=1,i.count>o2)return;typeof console<`u`&&typeof console.warn==`function`&&console.warn(JSON.stringify({event:`jsx-prop-dropped`,reason:e,prop:t}))}var l2=new Set([`href`,`src`,`action`,`formaction`,`poster`,`cite`,`data`,`manifest`,`background`,`ping`,`xlinkhref`,`xlinkactuate`,`xlinkrole`,`xlinkarcrole`,`xlinkshow`,`url`,`link`]),u2=new Set([`dangerouslysetinnerhtml`,`ref`,`key`,`defaultvalue`,`defaultchecked`,`__proto__`,`constructor`,`prototype`]),d2=1e4;function f2(e){let t=e.toLowerCase();return!!(u2.has(t)||t.length>=3&&t.startsWith(`on`))}function p2(e){return l2.has(e.toLowerCase())}function m2(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`//`)||C(t))return e;let n=t.indexOf(`:`),r=t.slice(0,n+1).toLowerCase();return i2.has(r)?e:`#`}function h2(e){if(e.length>d2)return``;let t=e.toLowerCase();return/url\s*\(\s*['"]?\s*(?:javascript|vbscript|data)\s*:/.test(t)||/\bexpression\s*\(/.test(t)?``:e}function g2(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=g2(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(f2(e)){c2(`dangerous-prop-name-nested`,e),r=!0;continue}if(p2(e)&&typeof t==`string`){let n=m2(t);n!==t&&(r=!0),i[e]=n}else{let n=g2(t);n!==t&&(r=!0),i[e]=n}}return r?i:e}function _2(e){let t=!1,n={};for(let[r,i]of Object.entries(e)){if(f2(r)){c2(`dangerous-prop-name`,r),t=!0;continue}if(p2(r)){let e=m2(i);e!==i&&(t=!0),n[r]=e;continue}if(r===`style`){if(typeof i==`string`){let e=h2(i);e!==i&&(t=!0),n[r]=e}else t=!0;continue}let e=g2(i);e!==i&&(t=!0),n[r]=e}return t?n:e}function v2(e){let t=(0,J.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{className:`jsx-component-error-fallback`,children:n}),t[0]=n,t[1]=r),r}function y2(e){let t=(0,J.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})),cn(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,X.jsx)(v2,{...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,X.jsx)(h1,{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 b2(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(b2).join(`,`)}]`;let t=Object.entries(e);return t.sort(([e],[t])=>e<t?-1:+(e>t)),`{${t.map(([e,t])=>`${JSON.stringify(e)}:${b2(t)}`).join(`,`)}}`}function x2(e,t){let n=e.props??{},r={};for(let[e,i]of Object.entries(n))t.has(e)||(r[e]=i);return _2(r)}var S2=3;function C2(e){let t=(0,J.c)(161),{node:n,editor:r,extension:a,getPos:s,selected:c}=e,{_:l}=i(),u=sM(n.attrs.componentName),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(!1),h=(0,Y.useRef)(!1),g=typeof s==`function`?s():void 0,_=!1,v=0,y=1;try{if(g!==void 0){let e=r.state.doc.resolve(g);e.depth>0&&e.parent.type.name===`jsxComponent`&&(_=!0,v=e.index(e.depth),y=e.parent.childCount)}}catch(e){let t=e;if(!(t instanceof RangeError))throw t}let b=_&&v>0,x=_&&v<y-1,S=W0(r),C=typeof g==`number`?F0(r.state,g):null,w=C!==null&&(S?.rangeEncompassedBlockIds.has(C)??!1),T;t[0]===S?.ancestorChain?T=t[1]:(T=S?.ancestorChain.at(-1)?.bridgeId??null,t[0]=S?.ancestorChain,t[1]=T);let E=C!==null&&T===C,D=c&&!w&&E,O=C!==null&&!E&&(S?.ancestorChain.some(e=>e.bridgeId===C)??!1),k=D&&S?S.selectionOrigin:void 0,A=D&&(S?.isDragging??!1),j=u.props.some(k2),M=n.attrs.props??{},N=j&&u.props.some(e=>e.type!==`string`||!e.required||`hidden`in e&&e.hidden?!1:!Object.hasOwn(M,e.name)),P=G0(u,M),I=P?K0(u):null,L=!u.hasChildren||!!u.isSelfClosing,ee=q0.has(u.name),R=u.name===`MermaidFence`?{propName:`chart`,language:`mermaid`}:u.name===`Math`||u.name===`DollarMath`||u.name===`MathFence`?{propName:`formula`,language:`latex`}:null,[z,te]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{c&&!h.current&&j&&gM(g)&&m(!0),h.current=c},[c,j,g]);let B=x2(n.attrs,u.reactNodePropNames),ne=u.surface===`compat`?u.translateProps(B):B,V=a.options.docName,re=typeof V==`string`&&V?V:ZD(r),ie=E0(u.name,ne,re),H=`${u.name}::${b2(B)}`,ae;t[2]!==s||t[3]!==n.content.size?(ae=()=>(typeof s==`function`?s()??0:0)+1+n.content.size,t[2]=s,t[3]=n.content.size,t[4]=ae):ae=t[4];let oe=ae,U=u.name===`*`||d!==null,se=(0,Y.useRef)(!1),W=(0,Y.useRef)(0),[le,ue]=(0,Y.useState)(!1);if((0,Y.useEffect)(()=>{if(!U||se.current||le)return;let e=typeof s==`function`?s():void 0;if(typeof e!=`number`)return;let t=r2(n),i=u.name===`*`?`Unregistered component: ${n.attrs.componentName}`:`Render error in <${u.displayName??u.name}>: ${d?.message??`unknown`}`,a=n.type.schema.nodes.rawMdxFallback.create({reason:i},n.type.schema.text(t)),o=!1,c,l=()=>{if(!o)try{r.view.dispatch(r.state.tr.replaceWith(e,e+n.nodeSize,a)),se.current=!0,Vt(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:W.current})),ft(r),W.current+=1,W.current<S2){let e=50*(2**W.current-1);c=setTimeout(()=>{o||l()},e)}else o||ue(!0)}},f=requestAnimationFrame(l);return()=>{o=!0,cancelAnimationFrame(f),c!==void 0&&clearTimeout(c)}},[U,n,r,s,u,d,le]),le){let e=n.attrs.componentName,i=u.displayName??u.name,a=u.name===`*`?l({id:`Kh1n4a`,values:{componentName:e}}):l({id:`g58Kwy`,values:{descriptorLabel:i}}),o=()=>{try{let e=r2(n);typeof navigator<`u`&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(e)}catch(e){let t=e;gn(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 s==`function`?s():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;et(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={[gF]:`true`},t[5]=d):d=t[5];let f;t[6]===a?f=t[7]:(f=(0,X.jsx)(`span`,{className:`flex-1`,children:a}),t[6]=a,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]!==o||t[11]!==p?(m=(0,X.jsx)(`button`,{type:`button`,className:`text-xs underline hover:no-underline`,onClick:o,children:p}),t[10]=o,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,X.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,X.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,X.jsx)(Ql,{className:`component-children`}),t[22]=v):v=t[22];let y;return t[23]===_?y=t[24]:(y=(0,X.jsxs)($l,{className:`jsx-component-wrapper my-2`,children:[_,v]}),t[23]=_,t[24]=y),y}if(U){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,X.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,X.jsx)(Ql,{className:`component-children`}),t[27]=o):o=t[27];let s;return t[28]===a?s=t[29]:(s=(0,X.jsxs)($l,{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(P||!L)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 g!=`number`)return;let n=r.state.doc.nodeAt(g);if(!n)return;let i=g+n.nodeSize,a=r.state.selection.from;a<g||a>=i||r.chain().focus().setNodeSelection(g).run()},ge;t[30]!==r||t[31]!==s?(ge=()=>{let e=typeof s==`function`?s():void 0;typeof e==`number`&&(r.chain().focus().setNodeSelection(e).run(),m(!0))},t[30]=r,t[31]=s,t[32]=ge):ge=t[32];let _e=ge,ve=u.displayName??u.name,ye=!!u.emptyChildName,be=ye?Y1(ve,u.emptyChildName,n.childCount):void 0,xe=e=>{let t=e.target;if(e.key===`Backspace`||e.key===`Delete`){if(!D||!e.currentTarget.contains(t)||t.matches(`input, textarea`))return;let i=typeof s==`function`?s():void 0;if(typeof i!=`number`)return;e.preventDefault();try{r.chain().focus().setNodeSelection(i).deleteSelection().run()||(Mt(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;Mt(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&&j&&(t.closest(`.jsx-component-chrome`)||t.closest(`input, textarea, select, button`)||(e.preventDefault(),m(!0)))},Se=e=>{m(e),!e&&requestAnimationFrame(()=>{let e=typeof s==`function`?s():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(L){let e=r.state.doc.resolve(Math.min(n,r.state.doc.content.size)),t=F.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;ht(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=Cc,we=$l,Te;t[33]===u.name?Te=t[34]:(Te=u.name.toLowerCase(),t[33]=u.name,t[34]=Te);let Ee;bb0:{let e=M.align;if(e===`left`||e===`right`||e===`center`){Ee=e;break bb0}if(ee){Ee=`center`;break bb0}Ee=void 0}let De=D?`true`:void 0,Oe=O?`true`:void 0,ke=w?`true`:void 0,Ae=A?`true`:void 0,je=N?`true`:void 0,Me=ye?`group`:void 0,Ne=D?0:-1,Pe;t[35]===_?Pe=t[36]:(Pe=_?{draggable:`false`,onDragStart:O2}:{"data-drag-handle":``,draggable:`true`},t[35]=_,t[36]=Pe);let Fe=u.name,Ie=D2,Le;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(Le={[gF]:`true`},t[37]=Le):Le=t[37];let G=ee&&[{value:`left`,label:l({id:`IR6Txi`}),Icon:Ga},{value:`center`,label:l({id:`8nOdkO`}),Icon:Ua},{value:`right`,label:l({id:`pd0UH2`}),Icon:Wa}].map(e=>{let{value:t,label:n,Icon:i}=e,a=typeof M.align==`string`?M.align:`center`,o=(a===`left`||a===`right`||a===`center`?a:`center`)===t;return(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":n,"aria-pressed":o,"data-active":o?`true`:void 0,onClick:e=>{if(typeof g!=`number`)return;let n=r.state.doc.nodeAt(g);if(!n||n.type.name!==`jsxComponent`)return;let i=e.currentTarget.closest(`.jsx-component-wrapper`),a=String(n.attrs.componentName??``);if(!q0.has(a)||n.attrs.kind!==`element`)return;let o=a===`CommonMarkImage`,s={...n.attrs.props,align:t},c=o?{...n.attrs,componentName:`img`,props:s,sourceDirty:!0}:{...n.attrs,props:s,sourceDirty:!0};n2(i,()=>{r.view.dispatch(r.state.tr.setNodeMarkup(g,null,c))})},children:(0,X.jsx)(i,{size:12,"aria-hidden":`true`})},t)}),Re=u.name===`Embed`&&typeof B.src==`string`&&/^https?:\/\//i.test(B.src)&&(0,X.jsx)(`a`,{href:B.src,target:`_blank`,rel:`noopener noreferrer`,className:`jsx-chrome-btn`,"aria-label":l({id:`iOHg1t`}),onMouseDown:E2,children:(0,X.jsx)($i,{size:12,"aria-hidden":`true`})}),ze=u.name===`Mirror`&&typeof B.src==`string`&&B.src.length>0&&(()=>{let e=B.src;return(0,X.jsx)(`a`,{href:ce(e,typeof B.anchor==`string`&&B.anchor.length>0?B.anchor:null),className:`jsx-chrome-btn`,"aria-label":l({id:`3a_Bd7`,values:{mirrorSrc:e}}),title:l({id:`0kTAXe`,values:{mirrorSrc:e}}),onMouseDown:T2,children:(0,X.jsx)($i,{size:12,"aria-hidden":`true`})})})(),Be;t[38]!==l||t[39]!==b||t[40]!==u.name||t[41]!==r||t[42]!==n.attrs.componentName||t[43]!==n.nodeSize||t[44]!==g?(Be=b&&(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`QyioBP`}),onClick:()=>{try{if(typeof g!=`number`)return;let e=r.state.doc.resolve(g),t=e.index(e.depth);if(t===0)return;let i=g-e.node(e.depth).child(t-1).nodeSize,a=g+n.nodeSize,o=r.state.tr,s=r.state.doc.slice(g,g+n.nodeSize),c=r.state.doc.slice(i,g);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;_t(`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,X.jsx)(Li,{size:12,"aria-hidden":`true`})}),t[38]=l,t[39]=b,t[40]=u.name,t[41]=r,t[42]=n.attrs.componentName,t[43]=n.nodeSize,t[44]=g,t[45]=Be):Be=t[45];let Ve;t[46]!==l||t[47]!==x||t[48]!==u.name||t[49]!==r||t[50]!==n.attrs.componentName||t[51]!==n.nodeSize||t[52]!==g?(Ve=x&&(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`3Ib6FN`}),onClick:()=>{try{if(typeof g!=`number`)return;let e=r.state.doc.resolve(g),t=e.index(e.depth),i=e.node(e.depth);if(t>=i.childCount-1)return;let a=i.child(t+1),o=g,s=g+n.nodeSize+a.nodeSize,c=r.state.tr,l=r.state.doc.slice(g,g+n.nodeSize),u=r.state.doc.slice(g+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;_t(`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,X.jsx)(Ii,{size:12,"aria-hidden":`true`})}),t[46]=l,t[47]=x,t[48]=u.name,t[49]=r,t[50]=n.attrs.componentName,t[51]=n.nodeSize,t[52]=g,t[53]=Ve):Ve=t[53];let He;t[54]!==l||t[55]!==u.displayName||t[56]!==u.name||t[57]!==R||t[58]!==g||t[59]!==te?(He=R&&typeof g==`number`?(0,X.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:()=>te(!0),children:(0,X.jsx)(Ma,{size:12,"aria-hidden":`true`})}):null,t[54]=l,t[55]=u.displayName,t[56]=u.name,t[57]=R,t[58]=g,t[59]=te,t[60]=He):He=t[60];let Ue;t[61]!==l||t[62]!==fe?(Ue=l({id:`MCjC9A`,values:{deleteDescriptorLabel:fe}}),t[61]=l,t[62]=fe,t[63]=Ue):Ue=t[63];let We;t[64]!==u.name||t[65]!==r||t[66]!==n.attrs.componentName||t[67]!==g?(We=()=>{if(typeof g==`number`)try{r.chain().focus().setNodeSelection(g).deleteSelection().run()||(Mt(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;Mt(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[64]=u.name,t[65]=r,t[66]=n.attrs.componentName,t[67]=g,t[68]=We):We=t[68];let Ge;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,X.jsx)(Ka,{size:12,"aria-hidden":`true`}),t[69]=Ge):Ge=t[69];let Ke;t[70]!==Ue||t[71]!==We?(Ke=(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":Ue,onClick:We,children:Ge}),t[70]=Ue,t[71]=We,t[72]=Ke):Ke=t[72];let qe;t[73]!==l||t[74]!==j||t[75]!==pe?(qe=j&&(0,X.jsx)(wc,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn`,"aria-label":l({id:`XPJ0sN`,values:{settingsDescriptorLabel:pe}}),children:(0,X.jsx)(Ia,{size:12,"aria-hidden":`true`})})}),t[73]=l,t[74]=j,t[75]=pe,t[76]=qe):qe=t[76];let Je;t[77]!==Ie||t[78]!==Le||t[79]!==G||t[80]!==Re||t[81]!==ze||t[82]!==Be||t[83]!==Ve||t[84]!==He||t[85]!==Ke||t[86]!==qe?(Je=(0,X.jsxs)(`div`,{className:`jsx-component-chrome`,contentEditable:!1,onMouseDown:Ie,...Le,children:[G,Re,ze,Be,Ve,He,Ke,qe]}),t[77]=Ie,t[78]=Le,t[79]=G,t[80]=Re,t[81]=ze,t[82]=Be,t[83]=Ve,t[84]=He,t[85]=Ke,t[86]=qe,t[87]=Je):Je=t[87];let Ye;t[88]!==de||t[89]!==u.emptyChildName||t[90]!==u.hasChildren||t[91]!==u.isSelfClosing||t[92]!==u.name||t[93]!==r||t[94]!==s||t[95]!==oe||t[96]!==D||t[97]!==n.attrs.componentName||t[98]!==n.childCount||t[99]!==_e||t[100]!==ie||t[101]!==H||t[102]!==I||t[103]!==f||t[104]!==P?(Ye=P&&I?(0,X.jsx)(Ec,{asChild:!0,children:(0,X.jsx)(_1,{label:I.label,Icon:I.Icon,onClick:_e,selected:D})}):(0,X.jsx)(y2,{resetKey:H,onError:f,descriptorName:u.name===`*`?`wildcard`:u.name,rawComponentName:n.attrs.componentName??``,children:(0,X.jsx)(ok,{value:typeof s==`function`?{editor:r,getPos:()=>{let e=s();return typeof e==`number`?e:void 0},addChild:u.emptyChildName?()=>{let e=u.emptyChildName,t=pM(e),n=oe();r.chain().focus().insertContentAt(n,t).run(),_M(r,n,sM(e))}:null}:null,children:(0,X.jsx)(de,{...ie,children:(0,X.jsx)(Ql,{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]=s,t[95]=oe,t[96]=D,t[97]=n.attrs.componentName,t[98]=n.childCount,t[99]=_e,t[100]=ie,t[101]=H,t[102]=I,t[103]=f,t[104]=P,t[105]=Ye):Ye=t[105];let Xe;t[106]!==u.emptyChildName||t[107]!==u.name||t[108]!==r||t[109]!==oe||t[110]!==n.childCount?(Xe=u.emptyChildName&&!(u.name===`Tabs`&&n.childCount>0)&&(()=>{let e=u.emptyChildName;return(0,X.jsx)(`button`,{type:`button`,contentEditable:!1,className:n.childCount===0?`jsx-empty-child-placeholder`:`jsx-add-child-pill`,onMouseDown:w2,onClick:()=>{let e=u.emptyChildName,t=pM(e),n=oe();r.chain().focus().insertContentAt(n,t).run(),_M(r,n,sM(e))},"data-clipboard-omit":`true`,children:(0,X.jsx)(`span`,{children:(0,X.jsx)(o,{id:`7Fkcej`,values:{addChildName:e}})})})})(),t[106]=u.emptyChildName,t[107]=u.name,t[108]=r,t[109]=oe,t[110]=n.childCount,t[111]=Xe):Xe=t[111];let Ze;t[112]!==we||t[113]!==u.name||t[114]!==be||t[115]!==he||t[116]!==xe||t[117]!==k||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]!==Je||t[129]!==Ye||t[130]!==Xe?(Ze=(0,X.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":k,"data-dragging":Ae,"data-needs-config":je,role:Me,"aria-label":be,tabIndex:Ne,...Pe,"data-component-name":Fe,onClick:he,onKeyDown:xe,children:[Je,Ye,Xe]}),t[112]=we,t[113]=u.name,t[114]=be,t[115]=he,t[116]=xe,t[117]=k,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]=Je,t[129]=Ye,t[130]=Xe,t[131]=Ze):Ze=t[131];let Qe;t[132]!==l||t[133]!==M||t[134]!==u.Component||t[135]!==u.displayName||t[136]!==u.name||t[137]!==z||t[138]!==R||t[139]!==r||t[140]!==s||t[141]!==g||t[142]!==ie||t[143]!==te?(Qe=R&&typeof g==`number`?(0,X.jsx)(bZ,{open:z,onOpenChange:te,initialValue:typeof M[R.propName]==`string`?M[R.propName]:``,language:R.language,title:l({id:`ky9Tuc`,values:{0:u.displayName??u.name}}),renderPreview:e=>{let t=u.Component;return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center p-4`,children:(0,X.jsx)(t,{...ie,[R.propName]:e})})},onSave:e=>{let t=typeof s==`function`?s():void 0;if(typeof t!=`number`)return;let n=r.state.doc.nodeAt(t);if(n&&n.attrs.kind===`element`)try{let i={...n.attrs.props??{},[R.propName]:e},a={...n.attrs,props:i,sourceDirty:!0};r.view.dispatch(r.state.tr.setNodeMarkup(t,null,a))}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]=M,t[134]=u.Component,t[135]=u.displayName,t[136]=u.name,t[137]=z,t[138]=R,t[139]=r,t[140]=s,t[141]=g,t[142]=ie,t[143]=te,t[144]=Qe):Qe=t[144];let $e;t[145]!==u||t[146]!==r||t[147]!==s||t[148]!==j||t[149]!==L||t[150]!==B||t[151]!==me||t[152]!==P?($e=j&&(0,X.jsxs)(Tc,{side:P?`bottom`:`right`,align:P?`center`:`start`,sideOffset:P?-4:8,className:`w-64 p-3 z-[60] overflow-y-auto subtle-scrollbar max-h-[calc(100vh-2rem)] overscroll-contain`,onCloseAutoFocus:L?e=>{e.preventDefault(),r.view.focus()}:void 0,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,X.jsx)(o,{id:`Mnavhe`,values:{propPanelDescriptorLabel:me}})}),(0,X.jsx)(v0,{descriptor:u,values:B,onChange:(e,t)=>{let n=typeof s==`function`?s():void 0;if(typeof n!=`number`)return;let i=r.state.doc.nodeAt(n);if(!i||i.attrs.kind!==`element`)return;let a={...i.attrs.props??{}},o=Array.isArray(i.attrs.attributes)?i.attrs.attributes:[],c=o;t===void 0?(delete a[e],c=o.filter(t=>!(typeof t==`object`&&t&&t.type===`mdxJsxAttribute`&&t.name===e))):a[e]=t,r.view.dispatch(r.state.tr.setNodeMarkup(n,null,{...i.attrs,attributes:c,props:a,sourceDirty:!0}))}})]}),t[145]=u,t[146]=r,t[147]=s,t[148]=j,t[149]=L,t[150]=B,t[151]=me,t[152]=P,t[153]=$e):$e=t[153];let tt;return t[154]!==Ce||t[155]!==Se||t[156]!==p||t[157]!==Ze||t[158]!==Qe||t[159]!==$e?(tt=(0,X.jsxs)(Ce,{open:p,onOpenChange:Se,children:[Ze,Qe,$e]}),t[154]=Ce,t[155]=Se,t[156]=p,t[157]=Ze,t[158]=Qe,t[159]=$e,t[160]=tt):tt=t[160],tt}function w2(e){return e.stopPropagation()}function T2(e){return e.stopPropagation()}function E2(e){return e.stopPropagation()}function D2(e){return e.stopPropagation()}function O2(e){return e.preventDefault()}function k2(e){return!(`hidden`in e&&e.hidden)&&e.type!==`reactnode`}var A2=Me.extend({addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return su(C2)}}),j2={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`}]},M2=(0,Y.lazy)(async()=>{let{default:e}=await n(async()=>{let{default:e}=await import(`./katex-DX-tM4Fr.js`);return{default:e}},[],import.meta.url);function t(t){let n=(0,J.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,X.jsx)(`span`,{className:`math math-inline`,dangerouslySetInnerHTML:{__html:i}}),n[2]=i,n[3]=a),a}return{default:t}});function N2(){let e=(0,J.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.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 P2(e){let t=(0,J.c)(2),n;return t[0]===e.formula?n=t[1]:(n=(0,X.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 F2(e){let t=(0,J.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,Y.useState)(!1),d=(0,Y.useRef)(!1),f;t[0]!==a.state||t[1]!==i||t[2]!==r?(f=()=>{let e=r&&a.state.selection instanceof Ct;e&&!d.current?(gM(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,Y.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,X.jsx)(h1,{resetKeys:[s],onError:L2,fallbackRender:()=>(0,X.jsx)(`span`,{className:`math math-inline math-error`,children:s}),children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(P2,{formula:s}),children:(0,X.jsx)(M2,{formula:s})})}):(0,X.jsx)(N2,{}),t[10]=s,t[11]=g);let _;t[12]!==s||t[13]!==h||t[14]!==g?(_=(0,X.jsx)(wc,{asChild:!0,children:(0,X.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,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground px-3 pt-2`,children:(0,X.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(Ct.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,X.jsx)(v0,{descriptor:j2,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,X.jsxs)(Tc,{className:`z-[60] w-72 p-0`,side:`bottom`,align:`start`,onOpenAutoFocus:I2,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,X.jsxs)(Cc,{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,X.jsx)($l,{as:`span`,className:m,children:w}),t[35]=w,t[36]=m,t[37]=T):T=t[37],T}function I2(e){e.preventDefault()}function L2(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})),cn(`mathInline`)}var R2=qt.extend({addNodeView(){return su(F2)}});function z2(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=ge.near(e.doc.resolve(i),n);return a.$head?.parent.type.name===`rawMdxFallback`?a:null}function B2(e,t){let{state:n,view:r}=e;if(!r.endOfTextblock(t))return!1;let i=z2(n,t);return i?(r.dispatch(n.tr.setSelection(i)),!0):!1}var V2=xt.extend({addKeyboardShortcuts(){return{ArrowLeft:({editor:e})=>B2(e,`left`),ArrowRight:({editor:e})=>B2(e,`right`),ArrowUp:({editor:e})=>B2(e,`up`),ArrowDown:({editor:e})=>B2(e,`down`)}},addNodeView(){return su(pZ,{stopEvent:()=>!0,ignoreMutation:()=>!0})}});function H2(e){let t=(0,J.c)(51),{items:n,selectedIndex:r,categoryLabels:a,onSelect:s,onHoverIndex:c}=e,l=(0,Y.useRef)(null),u=(0,Y.useId)(),{_:d}=i(),f=r>=0&&r<n.length?`${u}-option-${r}`:void 0,p=W2,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,Y.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,X.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,X.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]!==a||t[8]!==n||t[9]!==u||t[10]!==c||t[11]!==s||t[12]!==r){let e=[],i=0,o=new Map;for(let t of n){o.set(t,i++);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(U2),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,X.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:h}),t[31]=h,t[32]=y),b=e.map(e=>(0,X.jsxs)(`div`,{role:`group`,"aria-labelledby":`${u}-group-${e.key}`,children:[(0,X.jsx)(`div`,{id:`${u}-group-${e.key}`,className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground`,children:a[e.key]??e.key}),e.items.map(e=>{let t=o.get(e)??0,n=t===r,i=e.icon;return(0,X.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(),s(e)},children:[(0,X.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`div`,{className:`flex flex-col min-w-0`,children:(0,X.jsx)(`span`,{className:`truncate`,children:e.label})})]},e.name)})]},e.key)),t[5]=d,t[6]=f,t[7]=a,t[8]=n,t[9]=u,t[10]=c,t[11]=s,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,X.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,X.jsx)(`aside`,{"aria-hidden":`true`,onMouseDown:p,className:`w-64 rounded-lg border bg-popover p-2 shadow-md ${_?.preview?``:`invisible`}`,children:_?.preview?(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(`p`,{className:`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,X.jsxs)(`div`,{className:x,children:[k,A]}),t[47]=x,t[48]=k,t[49]=A,t[50]=j):j=t[50],j}function U2(e){return e.preview}function W2(e){return e.preventDefault()}var G2=new W(`slashCommand`),K2=Dt.create({name:`slashCommand`,addOptions(){return{itemsSources:[AM],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[Qy({editor:this.editor,pluginKey:G2,char:`/`,startOfLine:!1,allow:({editor:e})=>!ab(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 jM(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=ob(()=>n,`slash-command`);i.popup=c.popup,a=c.doPosition,t=new au(H2,{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(){sb(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}}),q2=new W(`sourceDirty`),J2=Dt.create({name:`sourceDirtyObserver`,addProseMirrorPlugins(){return[new U({key:q2,appendTransaction(e,t,n){if(!e.some(e=>!e.getMeta(qv))||!e.some(e=>e.docChanged))return null;let r=new ie;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=!Y2(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 Y2(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(!Y2(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(!Y2(e[r],t[r]))return!1;return!0}function X2(e,t){let n=e.doc.nodeAt(t);if(!n||n.type.name!==`table`)return null;let r=bt.get(n);return{map:r,tableStart:t+1,table:n,left:0,top:0,right:r.width,bottom:r.height}}function Z2(e,t){let n=X2(e,t);return n?Xe(e.tr,n,n.map.width):null}function Q2(e,t){let n=X2(e,t);return n?Ft(e.tr,n,n.map.height):null}function $2(e,t){if(!e.dom.contains(t))return null;let n;try{n=e.posAtDOM(t,0)}catch{return null}return n<0?null:Yt(e.state.doc.resolve(n))?.pos??null}var e4=`<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 t4(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(gF,`true`),n.innerHTML=e4,n.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation()}),n}var n4=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(gF,`true`);let n=t4(`column`,`Add column`),r=t4(`row`,`Add row`);n.addEventListener(`click`,()=>this.insert(e,Z2)),r.addEventListener(`click`,()=>this.insert(e,Q2)),t.append(n,r),this.mount.appendChild(t);let i=Ut(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=$2(this.view,n);if(r===null)return;let i=t(this.view.state,r);i&&(this.view.dispatch(i),this.view.focus())}},r4=Dt.create({name:`tableInsertControls`,addProseMirrorPlugins(){let e=this.editor;return[new U({key:new W(`tableInsertControls`),view:t=>new n4(t,e)})]}}),i4=`ok:tag-click`;function a4(e){if(typeof document>`u`)return;let t={value:e};document.dispatchEvent(new CustomEvent(i4,{detail:t}))}function o4(e){return e instanceof Element?e.closest(`a[data-tag]`):null}var s4=Dt.create({name:`tagClick`,addProseMirrorPlugins(){return[new U({props:{handleDOMEvents:{click(e,t){let n=o4(t.target);if(!n)return!1;let r=n.getAttribute(`data-tag`);return r?(t.preventDefault(),t.stopPropagation(),a4(r),!0):!1}}}})]}});function c4(e,t,n){if(typeof t!=`number`||!n||!ee.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(F.create(o.doc,s+1)),i.dispatch(o),i.focus(),!0}function l4(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 u4(e){let t=(0,J.c)(3),{value:n}=e,r=`#tag/${n}`,i;return t[0]!==r||t[1]!==n?(i=(0,X.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 d4(e){let t=(0,J.c)(20),{initialDraft:n,onCommit:r,onCancel:a}=e,{_:o}=i(),s=(0,Y.useRef)(null),[c,l]=(0,Y.useState)(n),u=(0,Y.useRef)(!1),d,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=requestAnimationFrame(()=>{s.current?.focus()});return()=>cancelAnimationFrame(e)},f=[],t[0]=d,t[1]=f):(d=t[0],f=t[1]),(0,Y.useEffect)(d,f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.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]===o?h=t[4]:(h=o({id:`U2pMtf`}),t[3]=o,t[4]=h);let g;t[5]===o?g=t[6]:(g=o({id:`knjOzA`}),t[5]=o,t[6]=g);let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{let t=e.target.value;(t===``||ee.test(t))&&l(t)},t[7]=_):_=t[7];let v,y;t[8]!==c||t[9]!==a||t[10]!==r?(v=e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),u.current=!0,r(c)||(u.current=!1,a())):(e.key===`Escape`||e.key===`Backspace`&&c===``)&&(e.preventDefault(),a())},y=()=>{if(!u.current){if(c===``){a();return}ee.test(c)?r(c):a()}},t[8]=c,t[9]=a,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,X.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,X.jsx)(`input`,{ref:s,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 f4(e){let t=(0,J.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,X.jsx)($l,{as:`span`,children:(0,X.jsx)(d4,{initialDraft:``,onCommit:e=>c4(i,typeof r==`function`?r():void 0,e),onCancel:()=>l4(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,X.jsx)($l,{as:`span`,children:(0,X.jsx)(u4,{value:a})}),t[3]=a,t[4]=o),o}var p4=jt.extend({priority:200,addNodeView(){return su(f4)},addKeyboardShortcuts(){return{Backspace:()=>{if(cb.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(cb.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[hb(this.editor)]}}),m4=2048,h4=24;function g4(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>m4)return{kind:`unsupported`,value:``};if(y4(t))return{kind:`emoji`,value:t};let n=b4(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:Re(`/api/asset?path=${encodeURIComponent(v4(t))}`)}:{kind:`unsupported`,value:``}}function _4(e){if(typeof e!=`string`)return{kind:`unsupported`,value:``};let t=e.trim();if(t===``||t.length>m4)return{kind:`unsupported`,value:``};let n=b4(t);return n===`url`?{kind:`url`,value:t}:n===`path`?{kind:`path`,value:Re(`/api/asset?path=${encodeURIComponent(v4(t))}`)}:{kind:`unsupported`,value:``}}function v4(e){return e.startsWith(`/`)?e.slice(1):e}function y4(e){if(/\p{L}/u.test(e)||e.includes(`/`))return!1;let t=0;for(let n of e)t++;if(t>h4)return!1;let n=e.lastIndexOf(`.`);if(n>-1){let t=e.slice(n+1).toLowerCase();if(Fe.has(t))return!1}return!0}function b4(e){let t=x4(e);if(!t||!Fe.has(t))return`unsupported`;let n=e.indexOf(`:`),r=e.indexOf(`/`);return n>-1&&(r===-1||n<r)?me(e)?`url`:`unsupported`:e.startsWith(`//`)||e.includes(`?`)||e.includes(`#`)||e.startsWith(`../`)||e.includes(`/../`)?`unsupported`:`path`}function x4(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 S4(e){let t=(0,J.c)(131),{open:n,target:r,alias:a,anchor:s,pages:c,assetPaths:l,loading:u,onOpenChange:d,onSave:f}=e,[p,m]=(0,Y.useState)(r),[h,g]=(0,Y.useState)(a??``),[_,v]=(0,Y.useState)(s??``),y=(0,Y.useId)(),b=(0,Y.useId)(),x=(0,Y.useId)(),S=(0,Y.useId)(),{_:C}=i(),w;t[0]!==l||t[1]!==p?(w=cO(p,l),t[0]=l,t[1]=p,t[2]=w):w=t[2];let T=w,E;t[3]!==l||t[4]!==p||t[5]!==c?(E=lO(p,c,l),t[3]=l,t[4]=p,t[5]=c,t[6]=E):E=t[6];let D=r1(p,E&&!T&&n),O=(0,Y.useRef)(!1),k,A;t[7]!==a||t[8]!==s||t[9]!==n||t[10]!==r?(k=()=>{if(!n){O.current=!1;return}O.current||(O.current=!0,m(r),g(a??``),v(s??``))},A=[n,r,a,s],t[7]=a,t[8]=s,t[9]=n,t[10]=r,t[11]=k,t[12]=A):(k=t[11],A=t[12]),(0,Y.useEffect)(k,A);let j;t[13]!==h||t[14]!==_||t[15]!==p||t[16]!==d||t[17]!==f?(j=function(){let e=p.trim();e&&(f(e,h.trim()||null,_.trim()||null),d(!1))},t[13]=h,t[14]=_,t[15]=p,t[16]=d,t[17]=f,t[18]=j):j=t[18];let M=j,N;t[19]===M?N=t[20]:(N=function(e){e.key===`Enter`&&(e.preventDefault(),M())},t[19]=M,t[20]=N);let P=N,F;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(F=function(e){m(e.path),v(``)},t[21]=F):F=t[21];let I=F,L,ee,R,z,te,B,ne,V,re,ie,H,ae,oe,U,se,ce,W;if(t[22]!==C||t[23]!==x||t[24]!==b||t[25]!==l||t[26]!==h||t[27]!==_||t[28]!==p||t[29]!==P||t[30]!==S||t[31]!==D||t[32]!==u||t[33]!==d||t[34]!==n||t[35]!==c||t[36]!==y){let e=new Map,r=D?.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;R=rr,U=n,se=d,ee=Yn,V=`sm:max-w-xl`,re=``,ie=V$,H=V$,ae=V$;let a;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(Wn,{children:(0,X.jsx)(o,{id:`xzktOa`})}),t[54]=a):a=t[54],t[55]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,X.jsxs)(nr,{children:[a,(0,X.jsx)(Hn,{children:(0,X.jsx)(o,{id:`Jhj_lh`})})]}),t[55]=oe):oe=t[55],L=Qn,te=`space-y-6`;let s;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(o,{id:`lGs_bQ`,components:{0:(0,X.jsx)(`span`,{className:`text-red-500`})}}),t[56]=s):s=t[56];let f;t[57]===y?f=t[58]:(f=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:y,children:s}),t[57]=y,t[58]=f);let w;t[59]===C?w=t[60]:(w=C({id:`aM23Wr`}),t[59]=C,t[60]=w);let T;t[61]!==l||t[62]!==p||t[63]!==P||t[64]!==u||t[65]!==c||t[66]!==w||t[67]!==y?(T=(0,X.jsx)(W$,{id:y,value:p,pages:c,assetPaths:l,includeAssets:!0,loading:u,onValueChange:m,onSuggestionSelect:I,placeholder:w,autoFocus:!0,"aria-required":`true`,onKeyDown:P}),t[61]=l,t[62]=p,t[63]=P,t[64]=u,t[65]=c,t[66]=w,t[67]=y,t[68]=T):T=t[68],t[69]!==f||t[70]!==T?(B=(0,X.jsxs)(`div`,{children:[f,T]}),t[69]=f,t[70]=T,t[71]=B):B=t[71];let E;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,X.jsx)(o,{id:`OTF92M`,components:{0:(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[72]=E):E=t[72];let O;t[73]===x?O=t[74]:(O=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:x,children:E}),t[73]=x,t[74]=O);let k;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>g(e.target.value),t[75]=k):k=t[75];let A;t[76]===C?A=t[77]:(A=C({id:`BH56dn`}),t[76]=C,t[77]=A);let j;t[78]!==x||t[79]!==h||t[80]!==P||t[81]!==A?(j=(0,X.jsx)(cr,{id:x,value:h,onChange:k,placeholder:A,onKeyDown:P}),t[78]=x,t[79]=h,t[80]=P,t[81]=A,t[82]=j):j=t[82],t[83]!==O||t[84]!==j?(ne=(0,X.jsxs)(`div`,{children:[O,j]}),t[83]=O,t[84]=j,t[85]=ne):ne=t[85];let M;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(o,{id:`Tjc1pH`,components:{0:(0,X.jsx)(`span`,{className:`font-normal text-muted-foreground`})}}),t[86]=M):M=t[86],t[87]===b?ce=t[88]:(ce=(0,X.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:b,children:M}),t[87]=b,t[88]=ce);let N;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>v(e.target.value),t[89]=N):N=t[89];let F;t[90]===C?F=t[91]:(F=C({id:`W-ntoW`}),t[90]=C,t[91]=F),t[92]!==b||t[93]!==_||t[94]!==P||t[95]!==F?(W=(0,X.jsx)(cr,{id:b,value:_,onChange:N,placeholder:F,onKeyDown:P}),t[92]=b,t[93]=_,t[94]=P,t[95]=F,t[96]=W):W=t[96],z=i&&(0,X.jsx)(`div`,{id:S,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,X.jsxs)(`button`,{type:`button`,"aria-pressed":_===e.slug,className:Sn(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,_===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>v(_===e.slug?``:e.slug),children:[(0,X.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,X.jsx)(`span`,{className:`truncate`,children:e.text})]},e.reactKey))}),t[22]=C,t[23]=x,t[24]=b,t[25]=l,t[26]=h,t[27]=_,t[28]=p,t[29]=P,t[30]=S,t[31]=D,t[32]=u,t[33]=d,t[34]=n,t[35]=c,t[36]=y,t[37]=L,t[38]=ee,t[39]=R,t[40]=z,t[41]=te,t[42]=B,t[43]=ne,t[44]=V,t[45]=re,t[46]=ie,t[47]=H,t[48]=ae,t[49]=oe,t[50]=U,t[51]=se,t[52]=ce,t[53]=W}else L=t[37],ee=t[38],R=t[39],z=t[40],te=t[41],B=t[42],ne=t[43],V=t[44],re=t[45],ie=t[46],H=t[47],ae=t[48],oe=t[49],U=t[50],se=t[51],ce=t[52],W=t[53];let le;t[97]!==z||t[98]!==ce||t[99]!==W?(le=(0,X.jsxs)(`div`,{children:[ce,W,z]}),t[97]=z,t[98]=ce,t[99]=W,t[100]=le):le=t[100];let ue;t[101]!==te||t[102]!==B||t[103]!==ne||t[104]!==le?(ue=(0,X.jsxs)(`div`,{className:te,children:[B,ne,le]}),t[101]=te,t[102]=B,t[103]=ne,t[104]=le,t[105]=ue):ue=t[105];let de;t[106]!==L||t[107]!==ue?(de=(0,X.jsx)(L,{children:ue}),t[106]=L,t[107]=ue,t[108]=de):de=t[108];let fe;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,X.jsx)(tr,{asChild:!0,children:(0,X.jsx)(In,{variant:`outline`,children:(0,X.jsx)(o,{id:`dEgA5A`})})}),t[109]=fe):fe=t[109];let pe;t[110]===p?pe=t[111]:(pe=p.trim(),t[110]=p,t[111]=pe);let me=!pe,he;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,X.jsx)(o,{id:`tfDRzk`}),t[112]=he):he=t[112];let ge;t[113]!==M||t[114]!==me?(ge=(0,X.jsxs)($n,{children:[fe,(0,X.jsx)(In,{onClick:M,disabled:me,children:he})]}),t[113]=M,t[114]=me,t[115]=ge):ge=t[115];let _e;t[116]!==ee||t[117]!==V||t[118]!==re||t[119]!==ie||t[120]!==H||t[121]!==ae||t[122]!==oe||t[123]!==de||t[124]!==ge?(_e=(0,X.jsxs)(ee,{className:V,"data-ok-layer-spawned":re,onPointerDownOutside:ie,onFocusOutside:H,onInteractOutside:ae,children:[oe,de,ge]}),t[116]=ee,t[117]=V,t[118]=re,t[119]=ie,t[120]=H,t[121]=ae,t[122]=oe,t[123]=de,t[124]=ge,t[125]=_e):_e=t[125];let ve;return t[126]!==R||t[127]!==U||t[128]!==se||t[129]!==_e?(ve=(0,X.jsx)(R,{open:U,onOpenChange:se,children:_e}),t[126]=R,t[127]=U,t[128]=se,t[129]=_e,t[130]=ve):ve=t[130],ve}function C4(e){let t=(0,J.c)(115),{editor:n,getPos:r,onClose:a,onNavigate:s}=e,c=r(),l=c==null?null:n.state.doc.nodeAt(c),u=String(l?.attrs.target??``),d=Ee(l?.attrs.alias),f=Ee(l?.attrs.anchor),p=Lt({target:u,alias:d,anchor:f}),{addPage:m,assetPaths:h,folderPaths:g,pages:_,pagesBySlug:v,pagesByBasename:y,loading:b}=yt(),x=O(u,f),S=x?.kind===`external`?x:null,C=x?.kind===`asset`?cO(x.url,h)??x.url.replace(/^\//,``):null,w=C?null:VY(u,{pages:_,folderPaths:g,pagesBySlug:v,pagesByBasename:y,fallbackTargets:iO(u)}),[T,E]=(0,Y.useState)(!1),[D,k]=(0,Y.useState)(!1),{_:A}=i();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]!==a?(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)),a())},t[4]=n.state,t[5]=n.view,t[6]=r,t[7]=a,t[8]=N):N=t[8];let F=N,I=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}))}},L=function(){return w?.kind===`create`?{initialDir:w.initialDir,suggestedName:w.suggestedName}:null},ee=async function(){let e=L();if(!(!e||D)){k(!0);try{await k$(e,{addPage:m,onCreated(e){I(e),window.location.hash=`#/${e}`,a()}}),k(!1)}catch(e){let t=e;or.error(t instanceof Error?t.message:A({id:`tfi40B`})),k(!1)}}},R=!S&&!b&&C!==null,z=!S&&!b&&w?.kind===`navigate`&&w.displayState===`resolved`,te=!S&&!b&&w?.kind===`navigate`&&w.displayState===`folder`,B=!S&&!b&&!C&&w?.kind===`create`,ne=!!S,V=S?JY(S.url)?S.url:null:R&&C?oe(C):z&&w?.kind===`navigate`?ZY({docName:w.hashDocName,anchor:f}):null,ie=!b&&V!==null&&(ne||R||z),H,ae,U,se,ce;if(t[9]!==A||t[10]!==d||t[11]!==f||t[12]!==C||t[13]!==n.state||t[14]!==n.view||t[15]!==S||t[16]!==r||t[17]!==R||t[18]!==te||t[19]!==z||t[20]!==B||t[21]!==b||t[22]!==u){if(b){let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ta,{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(S){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(xe,{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,X.jsx)(na,{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(te){let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(ca,{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(B){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Wi,{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(z){let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(aa,{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,X.jsx)(Wi,{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 un(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],ce=i,ae=C??(S?S.url:`${u}${f?`#${f}`:``}`);let a=f?`${u}#${f}`:u;H=d?`[[${a}|${d}]]`:`[[${a}]]`,se=Sn(`flex shrink-0`,U.className),t[9]=A,t[10]=d,t[11]=f,t[12]=C,t[13]=n.state,t[14]=n.view,t[15]=S,t[16]=r,t[17]=R,t[18]=te,t[19]=z,t[20]=B,t[21]=b,t[22]=u,t[23]=H,t[24]=ae,t[25]=U,t[26]=se,t[27]=ce}else H=t[23],ae=t[24],U=t[25],se=t[26],ce=t[27];let W;t[42]!==U.icon||t[43]!==se?(W=(0,X.jsx)(`span`,{className:se,children:U.icon}),t[42]=U.icon,t[43]=se,t[44]=W):W=t[44];let le=W,ue;t[45]!==le||t[46]!==B||t[47]!==U.text?(ue=B?(0,X.jsxs)(P,{children:[(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(`span`,{className:`flex shrink-0`,"data-slot":`wiki-link-prop-panel-icon-trigger`,children:le})}),(0,X.jsx)(re,{children:U.text})]}):le,t[45]=le,t[46]=B,t[47]=U.text,t[48]=ue):ue=t[48];let de=ue,fe=`${U.text}: ${ae}`,pe;t[49]!==ae||t[50]!==ne||t[51]!==B||t[52]!==V||t[53]!==ie||t[54]!==a||t[55]!==s?(pe=(0,X.jsx)(vn,{asChild:!0,children:ie?(0,X.jsx)(`a`,{href:V??void 0,...ne?{target:`_blank`,rel:`noopener noreferrer`}:{},onClick:e=>nX(e,s,a),"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:ae}):(0,X.jsx)(`span`,{"data-slot":`wiki-link-prop-panel-text`,className:Sn(`block truncate text-sm font-medium`,B?`text-muted-foreground`:`text-foreground`),children:ae})}),t[49]=ae,t[50]=ne,t[51]=B,t[52]=V,t[53]=ie,t[54]=a,t[55]=s,t[56]=pe):pe=t[56];let me;t[57]===ae?me=t[58]:(me=(0,X.jsx)(re,{className:`max-w-80 break-all`,children:ae}),t[57]=ae,t[58]=me);let he;t[59]!==pe||t[60]!==me?(he=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(P,{children:[pe,me]})}),t[59]=pe,t[60]=me,t[61]=he):he=t[61];let ge;t[62]!==ee||t[63]!==D||t[64]!==B?(ge=B?(0,X.jsxs)(In,{type:`button`,size:`sm`,variant:`link`,disabled:D,onClick:()=>void ee(),"data-slot":`wiki-link-prop-panel-create`,className:`flex items-center text-foreground`,children:[(0,X.jsx)(Na,{className:`size-3.5`,"aria-hidden":`true`}),D?(0,X.jsx)(o,{id:`HM56Bx`}):(0,X.jsx)(o,{id:`XRuL0i`})]}):null,t[62]=ee,t[63]=D,t[64]=B,t[65]=ge):ge=t[65];let _e;t[66]===A?_e=t[67]:(_e=A({id:`ePK91l`}),t[66]=A,t[67]=_e);let ve;t[68]===E?ve=t[69]:(ve=()=>E(!0),t[68]=E,t[69]=ve);let ye;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,X.jsx)(Ma,{className:`size-3.5`,"aria-hidden":`true`}),t[70]=ye):ye=t[70];let be;t[71]!==_e||t[72]!==ve?(be=(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(In,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":_e,onClick:ve,"data-slot":`wiki-link-prop-panel-edit`,children:ye})}),t[71]=_e,t[72]=ve,t[73]=be):be=t[73];let Se;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,X.jsx)(re,{children:(0,X.jsx)(o,{id:`ePK91l`})}),t[74]=Se):Se=t[74];let Ce;t[75]===be?Ce=t[76]:(Ce=(0,X.jsxs)(P,{children:[be,Se]}),t[75]=be,t[76]=Ce);let we;t[77]===H?we=t[78]:(we=(0,X.jsx)(Z$,{copyContent:H}),t[77]=H,t[78]=we);let Te;t[79]===A?Te=t[80]:(Te=A({id:`t_YqKh`}),t[79]=A,t[80]=Te);let De;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,X.jsx)(Ka,{className:`size-3.5`,"aria-hidden":`true`}),t[81]=De):De=t[81];let Oe;t[82]!==F||t[83]!==Te?(Oe=(0,X.jsx)(vn,{asChild:!0,children:(0,X.jsx)(In,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":Te,onClick:F,"data-slot":`wiki-link-prop-panel-remove`,children:De})}),t[82]=F,t[83]=Te,t[84]=Oe):Oe=t[84];let ke;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,X.jsx)(re,{children:(0,X.jsx)(o,{id:`t_YqKh`})}),t[85]=ke):ke=t[85];let Ae;t[86]===Oe?Ae=t[87]:(Ae=(0,X.jsxs)(P,{children:[Oe,ke]}),t[86]=Oe,t[87]=Ae);let je;t[88]!==ge||t[89]!==Ce||t[90]!==we||t[91]!==Ae?(je=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[ge,Ce,we,Ae]}),t[88]=ge,t[89]=Ce,t[90]=we,t[91]=Ae,t[92]=je):je=t[92];let Me;t[93]!==de||t[94]!==he||t[95]!==je?(Me=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[de,he,je]}),t[93]=de,t[94]=he,t[95]=je,t[96]=Me):Me=t[96];let Ne;t[97]!==a||t[98]!==Me||t[99]!==fe||t[100]!==ce?(Ne=(0,X.jsx)(y$,{kind:`wiki-link`,ariaLabel:fe,onDeactivate:a,triggerReference:ce,className:`w-96`,children:Me}),t[97]=a,t[98]=Me,t[99]=fe,t[100]=ce,t[101]=Ne):Ne=t[101];let Pe;t[102]!==d||t[103]!==f||t[104]!==h||t[105]!==T||t[106]!==M||t[107]!==b||t[108]!==_||t[109]!==E||t[110]!==u?(Pe=(0,X.jsx)(S4,{open:T,target:u,alias:d,anchor:f,pages:_,assetPaths:h,loading:b,onOpenChange:E,onSave:M}),t[102]=d,t[103]=f,t[104]=h,t[105]=T,t[106]=M,t[107]=b,t[108]=_,t[109]=E,t[110]=u,t[111]=Pe):Pe=t[111];let Fe;return t[112]!==Ne||t[113]!==Pe?(Fe=(0,X.jsxs)(X.Fragment,{children:[Ne,Pe]}),t[112]=Ne,t[113]=Pe,t[114]=Fe):Fe=t[114],Fe}var w4=0;function T4(){return`wiki-link-${++w4}`}function E4(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 D4(e,t){if(!t||!e)return null;let n=aO(e,t);if(!n)return null;let r=t.pageIcons?.get(n);if(!r)return null;let i=g4(r);return i.kind===`unsupported`?null:i}function O4(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 k4=$e.extend({priority:200,addOptions(){return{...this.parent?.(),docName:``}},addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=T4(),{dom:i,iconSpan:a}=E4({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=()=>{O4(a,D4(String(o.attrs.target??``),pn()))};s();let c=Ze(s),l=()=>{let e=n();return typeof e==`number`?e:void 0},u=GO(e),d=({newTab:e})=>{let t=o.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=O(n,typeof t.anchor==`string`?t.anchor:null);if(!r)return!1;if(r.kind===`doc`){let t=pn(),i=VY(n,{pages:t?.pages??new Set,folderPaths:t?.folderPaths??new Set,pagesBySlug:t?.pagesBySlug,pagesByBasename:t?.pagesByBasename,fallbackTargets:iO(n)});if(i.kind===`create`||i.kind===`navigate`&&i.displayState===`folder`)return!1;let a=i.kind===`navigate`?i.hashDocName:r.docName;return e?eX({docName:a,anchor:r.anchor}):window.location.assign(ZY({docName:a,anchor:r.anchor})),!0}if(r.kind===`asset`){let t=cO(r.url,pn()?.assetPaths??new Set)??r.url.replace(/^\//,``);return e?QY(oe(t)):window.location.hash=oe(t),!0}return JY(r.url)?(QY(r.url),!0):!1};return u.register({type:`wikiLink`,nodeId:r,getPos:l,controls:{propPanel:t=>(0,Y.createElement)(C4,{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(SX.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(SX.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[LX(this.editor)]}}),A4=0;function j4(){return`wiki-link-embed-${++A4}`}function M4(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 N4(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`,Re(e.src)),t.setAttribute(`alt`,e.alias??e.target),{dom:t}}function P4(e){let t=u(e);return t!==null&&Fe.has(t)}var F4=fn.extend({addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=j4(),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(P4(a)){let{dom:e}=N4({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(!P4(n))return!1;let o=a??n;return e.setAttribute(`data-target`,n),e.setAttribute(`data-alias`,r??``),e.setAttribute(`src`,Re(o)),e.setAttribute(`alt`,r??n),!0}}}let{dom:l}=M4({nodeId:r,target:a,alias:o,anchor:s,href:c??a});l.addEventListener(`click`,e=>{e.preventDefault()});let d=()=>{let e=n();return typeof e==`number`?e:void 0},f=GO(e);return f.register({type:`wikiLinkEmbed`,nodeId:r,getPos:d,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=u(n);if(a===null)return!1;let o=A(r,``)??n;return h$({url:r,projectRelPath:o,ext:a,title:o.split(`/`).pop()??r,forceOsDelegation:e}),!0}}),{dom:l,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let t=String(e.attrs.target??``);if(P4(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:()=>{f.deregister(r)}}}}}),I4=[...B.map(e=>{if(e.name===`jsxComponent`)return A2;if(e.name===`image`){let t=e.options??{};return f$.configure({...t,inline:!0})}return e.name===`rawMdxFallback`?V2:e.name===`wikiLink`?k4:e.name===`wikiLinkEmbed`?F4:e.name===`link`?f1:e.name===`mathInline`?R2:e.name===`tag`?p4:e.name===`codeBlock`?fQ:e}),K2.configure({itemsSources:[AM,xM,kM,wM],categoryLabels:{content:`Components`,layout:`Layout`,media:`Media`,data:`Data`,embed:`Embeds`}}),l$,kD.configure({onDrop(e,t,n){for(let r of t)xO(r,e,n)},onPaste(e,t,n){for(let n of t)xO(n,e,e.state.selection.from)}}),u$,JD,s4,c$,o$,FM,r4,J2,MD,BM,V0,Dt.create({name:`chunkWrapperDecoration`,addProseMirrorPlugins(){return[KM()]}})];function L4(e){return e===rt}function R4(){return Ac(`SYNC_TIMEOUT_MS`,3e4)}var z4=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}},B4=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},V4=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},H4=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}},U4=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}},W4=new Map,G4=!1;function K4(){for(let e of W4.values())if(!e.settled)return!0;return!1}function q4(){typeof document>`u`||document.visibilityState===`visible`&&J4(Date.now())}function J4(e){let t=[];for(let[n,r]of W4){if(r.settled)continue;let i=e-r.createdAt;if(i<R4())continue;r.settled=!0;let a=new z4(n,i);Q4(r),r.reject(a);let o=pS(n);o!==void 0&&wS(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 K4()||X4(),t.length}function Y4(){G4||typeof document>`u`||(document.addEventListener(`visibilitychange`,q4),G4=!0)}function X4(){G4&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,q4),G4=!1))}var Z4=new Map;function Q4(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 $4(e,t){let n=W4.get(e);if(n)return n.promise;let r=Z4.get(e);if(r!==void 0){Z4.delete(e);let n=r===`timeout`?new z4(e,0):new B4(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),Z(`ok/sync/create`,{docName:e,mountId:pS(e),warm:!1,armed:r}),Z(`ok/sync/reject`,{docName:e,mountId:pS(e),reason:`armed-${r}`});let i=t3(n);return W4.set(e,n3(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`);let n=pS(e);Z(`ok/sync/create`,{docName:e,mountId:n,warm:!0}),Z(`ok/sync/resolve`,{docName:e,mountId:n,elapsedMs:0,warm:!0}),Z.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 W4.set(e,e3(r,t)),r}let i=Date.now(),a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=()=>{let t=W4.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=pS(e);if(Z(`ok/sync/resolve`,{docName:e,mountId:r,elapsedMs:n,warm:!1}),Z.histogram(`ok/sync/resolve-elapsed-ms`,r===void 0?{docName:e}:{docName:e,mountId:r},n),Q4(t),K4()||X4(),t.resolve(),r!==void 0){let i=Date.now();CS(r,`ok.sync-promise`,{"doc.name":e,elapsed_ms:n},t.createdAt,i),wS(r,i)}},l=t=>{let n=W4.get(e);if(!n||n.settled)return;n.settled=!0;let r=new B4(e);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=pS(e);Z(`ok/sync/reject`,{docName:e,mountId:i,reason:`pre-sync-disconnect`}),Q4(n),K4()||X4(),n.reject(r),i!==void 0&&wS(i)},u=setTimeout(()=>{let t=W4.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new z4(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`);let i=pS(e);Z(`ok/sync/reject`,{docName:e,mountId:i,reason:`timeout`,elapsedMs:n}),Q4(t),K4()||X4(),t.reject(r),i!==void 0&&wS(i)},R4()),d={promise:s,resolve:a,reject:o,createdAt:i,timeoutHandle:u,provider:t,onSynced:c,onClose:l,settled:!1,resolved:!1,detached:!1};return W4.set(e,d),t.on(`synced`,c),t.on(`close`,l),Y4(),Z(`ok/sync/create`,{docName:e,mountId:pS(e),warm:!1}),s}function e3(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!0,detached:!0}}function t3(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function n3(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,resolved:!1,detached:!0}}function r3(e){return W4.get(e)?.resolved===!0}function i3(e){let t=W4.get(e);t&&(t.settled=!0,Q4(t),W4.delete(e),K4()||X4())}function a3(e,t){let n=W4.get(e);if(!n||n.settled)return!1;n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),Q4(n),K4()||X4(),n.reject(t);let r=pS(e);return r!==void 0&&wS(r),!0}var o3=Object.freeze({kind:`tab-replay`}),s3=Object.freeze({kind:`idle`});function c3(e,t){return()=>{}}var l3=null;function u3(){return l3??=mt(I4),l3}var d3=4e3,f3=1e4,p3=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`}},m3=`ok-last-observed-branch`,h3=5e3,g3=Ac(`MAX_BUFFER_BYTES`,1*1024*1024),_3=Ac(`MAX_POOL`,10);function v3(e,t,n=null){let r={...kc()};return e!==null&&(r.principalId=e.principalId,r.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(r.expectedServerInstanceId=t),n!==null&&n.length>0&&(r.expectedBranch=n),JSON.stringify(r)}var y3=class{_entries=new Map;get entries(){return this._entries}lruOrder=[];activeDocName=null;maxSize;wsUrl;recycleDebounceMs;clearDataTimeoutMs;onChange=null;tabIdentity=null;serverRestartRecoveryState=s3;cachedServerInstanceId=null;pendingServerInstanceKnown=null;recoveryMismatchStaleClaim;bufferedUpdates=new Map;pendingClears=new Map;clearFailures=new Set;persistenceFactory;storage;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n?.recycleDebounceMs??d3,this.clearDataTimeoutMs=n?.clearDataTimeoutMs??f3,this.persistenceFactory=n?.persistenceFactory??CD,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.getOrInitObservedBranch()??`_unknown_`,serverInstanceId:e,docName:t,doc:n})}attachDeferredPersistence(e){let t=!1;for(let n of this._entries.values())if(n.kind===`active`&&n.persistence===null)try{n.persistence=this.buildPersistence(e,n.docName,n.provider.document),t=!0}catch(e){let t=e instanceof Error?e.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(n.docName),errorName:t,errorMessage:e instanceof Error?e.message:String(e)})}t&&this.notify()}getServerRestartRecoveryState(){return this.serverRestartRecoveryState}observeDiskAck(e,t){let n=this.entries.get(e);!n||n.kind!==`active`||(n.lastDiskAckedSV=ED(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(m3)??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(m3):this.storage?.setItem(m3,e)}catch{}}withClearDataTimeout(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(new p3(e,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);t.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e)})})}recoveryTelemetryBase(e,t){let n={docName:e,branch:this.getOrInitObservedBranch()??`_unknown_`},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)i3(t);this.notify()}enterServerRestartReconnect(e,t,n,r){if(e.length===0){this.serverRestartRecoveryState=t.length===0?s3:{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=s3,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(L4(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(),Z(`ok/pool/open`,{docName:e,hit:!0,lastAccessedAt:n,poolEventId:t.poolEventId}),Z.count(`ok/pool/open`,{hit:!0}),t}let n=Date.now();this.entries.size>=this.maxSize&&this.evictLru();let r=this.cachedServerInstanceId,i=v3(this.tabIdentity,r,this.getOrInitObservedBranch()),a=new ZE({url:DD(this.wsUrl),name:e,forceSyncInterval:h3,token:i}),o=this.cachedServerInstanceId;this.clearFailures.has(e)&&this.runCloseAndClearPersistence(e);let s=this.pendingClears.get(e),c=o!==null&&o.length>0&&s===void 0?this.buildPersistence(o,e,a.document):null,l=crypto.randomUUID(),u={kind:`active`,provider:a,persistence:c,lastServerSyncedSV:null,lastDiskAckedSV:null,observerCleanup:null,observerFireCounterCleanup:c3(a.document,e),syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),poolEventId:l,hasSynced:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1,serverDrivenCloseReauthInFlight:!1};if(Z(`ok/pool/open`,{docName:e,hit:!1,poolEventId:l}),Z.count(`ok/pool/open`,{hit:!1}),a.on(`status`,({status:t})=>{u.kind!==`active`||this.entries.get(e)!==u||t===`disconnected`&&(u.syncState=`disconnected`,this.notify())}),a.on(`synced`,()=>{if(!(u.kind!==`active`||this.entries.get(e)!==u)&&(u.syncState=`synced`,u.hasSynced=!0,u.lastServerSyncedSV=wD(a.document),u.pendingRecycleTimer&&=(clearTimeout(u.pendingRecycleTimer),null),this.markServerRestartRecoverySynced(e),this.notify(),!u.observerCleanup))try{let t=a.document,n=new V({extensions:I4});u.observerCleanup=SY({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:n,schema:u3(),onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),u.bridgeSetupFailed=!0,a3(e,new H4(e,t))}}),a.on(`disconnect`,()=>{u.kind!==`active`||this.entries.get(e)!==u||(u.syncState=`disconnected`,this.notify(),u.hasSynced&&a.unsyncedChanges===0&&!u.pendingRecycleTimer&&(u.pendingRecycleTimer=setTimeout(()=>{u.kind===`active`&&(u.pendingRecycleTimer=null,this.entries.get(e)===u&&this.recycleDisconnectedEntry(e))},this.recycleDebounceMs)))}),a.on(`authenticationFailed`,({reason:t})=>{let n=[`server-instance-mismatch`,`branch-mismatch`,`rename-redirect`,`doc-deleted`],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,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`){let t=this.entries.get(e),n=t!==void 0&&t.kind===`active`;this.onDocDeleted?.({docName:e,hadOpenProvider:n});return}}),a.on(`close`,({event:t})=>{if(u.kind!==`active`||this.entries.get(e)!==u||u.serverDrivenCloseReauthInFlight)return;u.serverDrivenCloseReauthInFlight=!0,a.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(()=>{u.kind===`active`&&this.entries.get(e)===u&&(u.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(a.off(`synced`,n),u.kind!==`active`||this.entries.get(e)!==u)return;let r=this.bufferedUpdates.get(e);if(r!==void 0){this.bufferedUpdates.delete(e);try{gh(a.document,r,o3)}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)})}}};a.on(`synced`,n)}if(this._entries.set(e,u),this.touch(e),this.notify(),s!==void 0&&o!==null&&o.length>0){let t=o;s.then(()=>{this.attachDeferredPersistenceForEntry(u,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 d=pS(e);return d!==void 0&&CS(d,`ok.provider-pool.open`,{"doc.name":e},n,Date.now()),u}attachDeferredPersistenceForEntry(e,t){let n=this._entries.get(e.docName);if(!(n!==e||n.kind!==`active`||n.persistence!==null))try{n.persistence=this.buildPersistence(t,e.docName,n.provider.document),this.notify()}catch(t){let n=t instanceof Error?t.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(e.docName),errorName:n,errorMessage:t instanceof Error?t.message:String(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)&&i3(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=TD(n.provider.document,t);if(r.byteLength>g3){Z(`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 p3;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(L4(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.getOrInitObservedBranch(),r=this.cachedServerInstanceId;if(n===null||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.onBranchMismatch=null,this.branchMismatchInFlight=null,this.onRenameRedirect=null,this.onDocDeleted=null,this.evictListeners.clear(),this.serverRestartRecoveryState=s3,this.cachedServerInstanceId=null,this.pendingServerInstanceKnown=null,this.tabIdentity=null,this.recoveryMismatchStaleClaim=void 0}evictLru(){for(let e of this.lruOrder)if(e!==this.activeDocName){Z(`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),i3(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(Z(`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()}},b3=crypto.randomUUID(),x3=!1;function S3(e){x3||(x3=!0,console.warn(`[principal-fetch] failed to resolve principal — falling back to random identity.`,e))}var C3=(0,Y.createContext)(null),w3=null;function T3(e){return w3||(w3=new y3(_3,e),CC(w3)),w3}var E3={activeDocName:null,activeProvider:null,syncState:`connecting`,serverRestartRecovery:{kind:`idle`},poolEntries:[]};function D3(){if(typeof window>`u`)return null;let e=window.okDesktop;return e?.config.mode===`editor`?e:null}function O3(){return typeof window>`u`||window.okDesktop?.config.mode===`editor`?null:fw(window.location.origin)}function k3(){if(typeof window>`u`)return uw(null,_3);let e=O3();return e?pw(window.localStorage===void 0?null:window.localStorage,e,_3):uw(null,_3)}function A3(){return k3().openTabs}function j3(){return k3().pinnedTabIds}function M3(){if(typeof window>`u`||window.location.hash.length>0)return null;let e=k3();return e.activeTabId??(e.activeDocName?MC(e.activeDocName):null)??e.openTabs[0]??null}function N3(e){let t=HC(e);switch(t.kind){case`doc`:return ce(t.docName);case`folder`:return he(t.folderPath);case`asset`:return oe(t.assetPath)}}function P3(e){let t=fe(e);if(t)return zC(t);let n=Et(e);if(!n)return null;let r=n.trim();if(/\/+$/.test(r)){let e=r.replace(/\/+$/g,``);return e?RC(e):null}return MC(n)}function F3(e){return{kind:`asset`,target:e,assetPath:e,mediaKind:ve(e.split(`.`).pop()??``)}}function I3(e,t){return e?VC(e):t?MC(t):null}function L3(e,t,n){return e.some(e=>!n.has(e)&&UC(e)===t)}function R3(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function z3(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`large-file`:return`large-file:${e.docName}:${e.size}:${e.limit}`;case`missing`:return`missing:${e.target}`}}function B3(e,t){return e===t?!0:!e||!t?!1:z3(e)===z3(t)}function V3(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 H3(e){let t=(0,J.c)(175),{children:n}=e,[r,i]=(0,Y.useState)(E3),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(M3),[l,u]=(0,Y.useState)(A3),[d,f]=(0,Y.useState)(j3),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[0]=p):p=t[0];let[m,h]=(0,Y.useState)(p),[g,_]=(0,Y.useState)(l),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(!1),S=(0,Y.useRef)(s),C=(0,Y.useRef)(l),w=(0,Y.useRef)(d),T=(0,Y.useRef)(v),E=(0,Y.useRef)(m),D=(0,Y.useRef)(g),O=(0,Y.useRef)(1),k=(0,Y.useRef)(!1),[A,j]=(0,Y.useState)(!1),[M,N]=(0,Y.useState)(null),[P,F]=(0,Y.useState)(null),[I,L]=(0,Y.useState)(`doc`),[ee,R]=(0,Y.useState)(null),[z,te]=(0,Y.useState)(0),{collabUrl:B,terminal:ne,lastError:V,retry:re}=eS(),ie;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(ie=function(e){S.current=e,c(e)},t[1]=ie):ie=t[1];let H=ie,ae;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(ae=function(e){T.current=e,y(e)},t[2]=ae):ae=t[2];let U=ae,se;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(e){D.current=e,_(t=>R3(t,e)?t:e)},t[3]=se):se=t[3];let W=se,le;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(le=function(e){w.current=e,f(t=>R3(t,e)?t:e)},t[4]=le):le=t[4];let ue=le,de;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(de=function(e,t){let n=GC(t,e);C.current=e,w.current=n,u(t=>R3(t,e)?t:e),f(e=>R3(e,n)?e:n),W(nw(D.current,e,E.current))},t[5]=de):de=t[5];let fe=de,pe;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(pe=function(e){fe(e,w.current)},t[6]=pe):pe=t[6];let me=pe,ge;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(ge=function(e){me(e(C.current))},t[7]=ge):ge=t[7];let _e=ge,ve;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(ve=function(e){E.current=e,h(t=>R3(t,e)?t:e),W(nw(D.current,C.current,e))},t[8]=ve):ve=t[8];let ye=ve,be;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(be=function(e){let t=T.current;if(!t)return;let n=E.current.filter(e=>e!==t);E.current=n,h(e=>R3(e,n)?e:n),U(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))}W(nw(r,C.current,n))},t[9]=be):be=t[9];let xe=be,Se,Ce;t[10]===s?(Se=t[11],Ce=t[12]):(Se=()=>{S.current=s},Ce=[s],t[10]=s,t[11]=Se,t[12]=Ce),(0,Y.useEffect)(Se,Ce);let we,Te;t[13]===l?(we=t[14],Te=t[15]):(we=()=>{C.current=l},Te=[l],t[13]=l,t[14]=we,t[15]=Te),(0,Y.useEffect)(we,Te);let Ee,De;t[16]===d?(Ee=t[17],De=t[18]):(Ee=()=>{w.current=d},De=[d],t[16]=d,t[17]=Ee,t[18]=De),(0,Y.useEffect)(Ee,De);let Oe,ke;t[19]===v?(Oe=t[20],ke=t[21]):(Oe=()=>{T.current=v},ke=[v],t[19]=v,t[20]=Oe,t[21]=ke),(0,Y.useEffect)(Oe,ke);let Ae,je;t[22]===m?(Ae=t[23],je=t[24]):(Ae=()=>{E.current=m},je=[m],t[22]=m,t[23]=Ae,t[24]=je),(0,Y.useEffect)(Ae,je);let Me,Ne;t[25]===g?(Me=t[26],Ne=t[27]):(Me=()=>{D.current=g},Ne=[g],t[25]=g,t[26]=Me,t[27]=Ne),(0,Y.useEffect)(Me,Ne);let Pe=v!==null,Fe,Ie;t[28]!==B||t[29]!==A||t[30]!==b?(Fe=()=>{if(B===null||b||!A)return;let e=!1,t=D3(),n=O3(),r=typeof localStorage<`u`?localStorage:null;return(t?t.project.getSessionState():Promise.resolve(n?pw(r,n,_3):{openTabs:[],pinnedTabIds:[],activeDocName:null,activeTabId:null,updatedAt:null})).then(t=>{if(e)return;let n=uw(t,_3);if(k.current)return;let r=T3(B);for(let e of n.openTabs){let t=UC(e);t&&r.open(t)}let i=[...n.pinnedTabIds,...w.current],a=n.openTabs;for(let e of C.current)a=ZC(a,e,_3,i);let o=GC(i,a);C.current=a,w.current=o,u(e=>R3(e,a)?e:a),f(e=>R3(e,o)?e:o);let s=nw(D.current,a,E.current);D.current=s,_(e=>R3(e,s)?e:s);let l=Et(window.location.hash),d=n.activeTabId??(n.activeDocName?MC(n.activeDocName):null)??n.openTabs[0]??null,p=d?N3(d):null;if((l===null&&window.location.hash.length===0||p!==null&&p===window.location.hash)&&d){S.current=d,c(d);let e=N3(d);window.location.hash!==e&&(window.location.hash=e)}}).catch(Q3).finally(()=>{e||x(!0)}),()=>{e=!0}},Ie=[B,A,b],t[28]=B,t[29]=A,t[30]=b,t[31]=Fe,t[32]=Ie):(Fe=t[31],Ie=t[32]),(0,Y.useEffect)(Fe,Ie);let Le,G;t[33]!==s||t[34]!==a||t[35]!==l||t[36]!==d||t[37]!==r.activeDocName||t[38]!==b?(Le=()=>{if(!b)return;let e=dw(l,s??I3(a,r.activeDocName),d),t=D3();if(t){t.project.setSessionState(e).catch(Z3);return}let n=O3();n&&mw(typeof localStorage<`u`?localStorage:null,n,e)},G=[s,a,l,d,r.activeDocName,b],t[33]=s,t[34]=a,t[35]=l,t[36]=d,t[37]=r.activeDocName,t[38]=b,t[39]=Le,t[40]=G):(Le=t[39],G=t[40]),(0,Y.useEffect)(Le,G);let Re;t[41]===b?Re=t[42]:(Re=function(){b||(k.current=!0)},t[41]=b,t[42]=Re);let ze=Re,Be,Ve;t[43]===B?(Be=t[44],Ve=t[45]):(Be=()=>{if(B===null)return;let e=!1;j(!1);let t=T3(B);i(V3(t));let n=function(e,t){let n=GC(t,e);C.current=e,w.current=n,u(t=>R3(t,e)?t:e),f(e=>R3(e,n)?e:n);let r=nw(D.current,e,E.current);D.current=r,_(e=>R3(e,r)?e:r)};return t.setOnBranchMismatch(()=>Lx(t)),t.setOnRenameRedirect(e=>{let{fromDocName:r,toDocName:i,hadOpenProvider:a}=e;(async()=>{let e,s=t.getActiveDocName()===r;rC([{fromDocName:r,toDocName:i}]);try{await Promise.all([t.closeAndClearPersistence(r),t.closeAndClearPersistence(i)]),s&&(t.open(i),t.setActive(i));let e=iw(C.current,[{fromDocName:r,toDocName:i}],_3,[],w.current),a=GC(iw(w.current,[{fromDocName:r,toDocName:i}],2**53-1),e);D.current=aw(D.current,[{fromDocName:r,toDocName:i}]),n(e,a),o(e=>e&&(Ye(e)===r?{kind:`doc`,target:i,docName:i}:e)),s&&(window.location.hash=ce(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(tw(C.current,r),w.current),o(e=>e&&(Ye(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(V3(t))),fetch(`/api/principal`).then(X3).then(n=>{if(e)return;let r=ct.safeParse(n);r.success?(t.setTabIdentity({principalId:r.data.id,tabSessionId:b3}),N(r.data)):S3(r.error)}).catch(t=>{e||S3(t)}).finally(()=>{e||j(!0)}),Lx(t),()=>{e=!0,t.setOnChange(null),t.setOnRenameRedirect(null),t.setOnDocDeleted(null)}},Ve=[B],t[43]=B,t[44]=Be,t[45]=Ve),(0,Y.useEffect)(Be,Ve);let He;t[46]===B?He=t[47]:(He=e=>{if(Z(`ok/nav/open-document`,{docName:e,transition:!1}),B===null)return;let t=T3(B),n=t.open(e);if(!n)return;Dx(e,n.poolEventId);let r=MC(e);_e(e=>ZC(e,r,_3,w.current)),xe(r),H(r),t.setActive(e),o({kind:`doc`,target:e,docName:e})},t[46]=B,t[47]=He);let Ue=He,We;t[48]===Ue?We=t[49]:(We=e=>{Z(`ok/nav/open-document`,{docName:e,transition:!1}),Ue(e)},t[48]=Ue,t[49]=We);let Ge=We,Ke;t[50]!==a||t[51]!==B||t[52]!==ze||t[53]!==r.activeDocName?(Ke=(e,t)=>{let n=t===void 0?{}:t;if(B===null)return;n.tabBehavior===`replace-active`&&ze();let i=T3(B),s=Ye(e),c=T.current,l=c!==null&&n.tabBehavior===`replace-active`,u=c?null:S.current??I3(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;Dx(s,e.poolEventId);let t=l?IC(C.current,MC(s)):null,n=l&&!t?PC(C.current,s):null,r=l?t?{activeTabId:t,tabs:C.current}:{activeTabId:n??MC(s),tabs:ZC(C.current,n??MC(s),_3,w.current)}:$C(C.current,s,{behavior:p,currentTabId:u,limit:_3,pinnedTabIds:w.current});me(r.tabs),xe(r.activeTabId),H(r.activeTabId),i.setActive(s)}else{i.clearActive();let t=VC(e);if(t){let e=u!==null&&LC(u,t),n=l||e?null:IC(C.current,t),r=n?{tabs:C.current,activeTabId:n}:ew(C.current,t,{behavior:p,currentTabId:u,limit:_3,pinnedTabIds:w.current});me(r.tabs),H(r.activeTabId),xe(r.activeTabId)}else xe(t)}o(t=>B3(t,e)?t:e)},t[50]=a,t[51]=B,t[52]=ze,t[53]=r.activeDocName,t[54]=Ke):Ke=t[54];let qe=Ke,Je;t[55]===qe?Je=t[56]:(Je=(e,t)=>{qe(e,t===void 0?{}:t)},t[55]=qe,t[56]=Je);let Xe=Je,Ze;t[57]===qe?Ze=t[58]:(Ze=(e,t)=>{let n=t===void 0?{}:t;Z(`ok/nav/open-target`,{docName:Ye(e),kind:e.kind,transition:!1}),qe(e,n)},t[57]=qe,t[58]=Ze);let Qe=Ze,$e;t[59]!==s||t[60]!==a||t[61]!==B||t[62]!==ze||t[63]!==r.activeDocName?($e=e=>{if(w.current.includes(e))return;ze();let t=null,n=UC(e);if(B!==null){let t=T3(B);n&&!L3(C.current,n,new Set([e]))&&t.close(n)}let i=s??I3(a,r.activeDocName);if(_e(n=>(t=cw(n,i,e),tw(n,e))),i===e){if(t){H(t),window.location.hash=N3(t);return}B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash=``}},t[59]=s,t[60]=a,t[61]=B,t[62]=ze,t[63]=r.activeDocName,t[64]=$e):$e=t[64];let et=$e,tt;t[65]!==B||t[66]!==ze?(tt=e=>{ze();let t=E.current;if(!t.includes(e))return;let n=t.filter(t=>t!==e);if(ye(n),T.current!==e)return;let r=t.indexOf(e),i=n[r]??n[r-1]??null;if(i){U(i),B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash!==``&&(window.location.hash=``);return}U(null);let a=C.current[C.current.length-1]??null;if(a){H(a),window.location.hash=N3(a);return}B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash=``},t[65]=B,t[66]=ze,t[67]=tt):tt=t[67];let nt=tt,rt;t[68]!==nt||t[69]!==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[68]=nt,t[69]=et,t[70]=rt):rt=t[70];let it=rt,at,ot;t[71]===it?(at=t[72],ot=t[73]):(at=()=>{let e=D3();if(e)return e.onMenuAction(e=>{e===`close-active-tab-or-window`&&(it()||window.close())})},ot=[it],t[71]=it,t[72]=at,t[73]=ot),(0,Y.useEffect)(at,ot);let st;t[74]===B?st=t[75]:(st=()=>{if(B===null){o(Y3),S.current=null,c(J3);return}let e=T3(B);e.getActiveDocName()!==null&&e.clearActive(),o(q3),S.current=null,c(K3)},t[74]=B,t[75]=st);let lt;t[76]!==B||t[77]!==ze?(lt=e=>{B!==null&&(ze(),T3(B).close(e),_e(t=>tw(t,MC(e))),c(t=>{let n=t&&UC(t)===e?null:t;return S.current=n,n}),o(t=>t&&(Ye(t)===e?null:t)))},t[76]=B,t[77]=ze,t[78]=lt):lt=t[78];let ut;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(ut=e=>{let t=qC(w.current,e,C.current);R3(w.current,t)||ue(t)},t[79]=ut):ut=t[79];let dt;t[80]===ze?dt=t[81]:(dt=e=>{let t=JC(w.current,e);R3(w.current,t)||(ze(),ue(t))},t[80]=ze,t[81]=dt);let ft;t[82]===B?ft=t[83]:(ft=e=>{let t=HC(e);if(U(null),H(e),t.kind===`doc`){if(B!==null){let e=T3(B);if(!e.open(t.docName))return;e.setActive(t.docName)}o({kind:`doc`,target:t.docName,docName:t.docName});let e=ce(t.docName);window.location.hash!==e&&(window.location.hash=e);return}if(B!==null&&T3(B).clearActive(),t.kind===`asset`){o(F3(t.assetPath));let e=oe(t.assetPath);window.location.hash!==e&&(window.location.hash=e);return}o({kind:`folder`,target:t.folderPath,folderPath:t.folderPath});let n=he(t.folderPath);window.location.hash!==n&&(window.location.hash=n)},t[82]=B,t[83]=ft);let pt;t[84]===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=R3(C.current,a),l=R3(E.current,o),u=R3(D.current,s);c&&l&&u||(D.current=s,l||(E.current=o,h(e=>R3(e,o)?e:o)),fe(a,XC(a,w.current,t)))},t[84]=pt):pt=t[84];let mt,ht;t[85]===B?(mt=t[86],ht=t[87]):(mt=()=>{let e=`new-tab:${O.current}`;O.current+=1,ye([...E.current,e]),U(e),B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash!==``&&(window.location.hash=``)},ht=e=>{E.current.includes(e)&&(B!==null&&T3(B).clearActive(),o(null),H(null),U(e),window.location.hash!==``&&(window.location.hash=``))},t[85]=B,t[86]=mt,t[87]=ht);let gt;t[88]!==s||t[89]!==a||t[90]!==B||t[91]!==ze||t[92]!==r.activeDocName?(gt=(e,t)=>{let n=t===void 0?{}:t,i=e.filter(G3),c=new Set(n.force?i:YC(i,w.current));if(c.size===0)return;if(ze(),B!==null){let e=T3(B),t=new Map;for(let e of c){let n=UC(e);if(!n)continue;let r=t.get(n)??new Set;r.add(e),t.set(n,r)}for(let[n,r]of t)L3(C.current,n,r)||e.close(n)}let l=null,u=s??I3(a,r.activeDocName);if(_e(e=>(l=lw(e,u,c),e.filter(e=>!c.has(e)))),!u||!c.has(u)){u||o(e=>{if(!e)return e;let t=VC(e);return t&&c.has(t)?null:e});return}if(l){H(l),window.location.hash=N3(l);return}B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash=``},t[88]=s,t[89]=a,t[90]=B,t[91]=ze,t[92]=r.activeDocName,t[93]=gt):gt=t[93];let _t;t[94]!==s||t[95]!==a||t[96]!==B||t[97]!==ze||t[98]!==l||t[99]!==r.activeDocName?(_t=e=>{let{pages:t,folderPaths:n,assetPaths:i}=e,c=rw(l,{pages:t,folderPaths:n,assetPaths:i,keepMissingDocName:a?.kind===`missing`?a.target:null});if(c.length===l.length)return;let u=new Set(c),d=l.filter(e=>!u.has(e)),f=new Set(d);if(ze(),B!==null){let e=T3(B);for(let t of d){let n=UC(t);n&&e.close(n)}}me(c);let p=typeof window<`u`?P3(window.location.hash):null,m=s??I3(a,r.activeDocName),h=p&&f.has(p)?p:m&&f.has(m)?m:null;if(!h){o(e=>{if(!e)return e;let t=VC(e);return t&&f.has(t)?null:e});return}let g=lw(l,h,d);if(g){H(g),window.location.hash=N3(g);return}B!==null&&T3(B).clearActive(),o(null),H(null),window.location.hash=``},t[94]=s,t[95]=a,t[96]=B,t[97]=ze,t[98]=l,t[99]=r.activeDocName,t[100]=_t):_t=t[100];let vt;t[101]!==B||t[102]!==ze?(vt=(e,t,n)=>{let r=t===void 0?[]:t,i=n===void 0?[]:n;ze();let a=iw(C.current,e,_3,r,w.current,i),o=GC(iw(w.current,e,2**53-1,r,[],i),a);if(B!==null){let e=T3(B);for(let t of a){let n=UC(t);n&&e.open(n)}}D.current=aw(D.current,e,r,i),fe(a,o);let s=S.current;if(s){let t=iw([s],e,1,r,[],i)[0];t&&a.includes(t)&&H(t)}},t[101]=B,t[102]=ze,t[103]=vt):vt=t[103];let yt,bt,xt,St,Ct;t[104]===B?(yt=t[105],bt=t[106],xt=t[107],St=t[108],Ct=t[109]):(yt=async e=>{B!==null&&(await T3(B).closeAndClearPersistence(e),o(t=>t&&(Ye(t)===e?null:t)))},bt=()=>B===null?null:T3(B).getActiveDocName(),xt=e=>B===null?!1:T3(B).has(e),St=e=>{B!==null&&T3(B).recycle(e)},Ct=e=>B===null?null:T3(B).prewarm(e)?.poolEventId??null,t[104]=B,t[105]=yt,t[106]=bt,t[107]=xt,t[108]=St,t[109]=Ct);let wt,Tt,Dt,Ot,At;t[110]===B?(wt=t[111],Tt=t[112],Dt=t[113],Ot=t[114],At=t[115]):(wt=e=>{B!==null&&T3(B).setExpectedServerInstanceId(e)},Tt=async e=>{if(B===null)return;let t=T3(B);t.setObservedBranch(e),await Ox(t,e),kt([`files`,`backlinks`,`graph`]),zt(e)},Dt=async e=>{if(B===null)return;let t=T3(B);t.compareAndUpdateObservedBranch(e)&&(await Ox(t,e),kt([`files`,`backlinks`,`graph`]),zt(e))},Ot=(e,t)=>{B!==null&&T3(B).observeDiskAck(e,t)},At=async()=>{B!==null&&await Lx(T3(B))},t[110]=B,t[111]=wt,t[112]=Tt,t[113]=Dt,t[114]=Ot,t[115]=At);let jt;t[116]!==ee||t[117]!==I||t[118]!==r.activeDocName?(jt=(e,t)=>{if(!r.activeDocName&&t){window.location.hash=ce(t),R(e),L(`agent`),te(W3);return}if(I===`agent`&&ee===e){L(`doc`);return}R(e),L(`agent`),te(U3)},t[116]=ee,t[117]=I,t[118]=r.activeDocName,t[119]=jt):jt=t[119];let Mt;t[120]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=()=>{L(`doc`),R(null)},t[120]=Mt):Mt=t[120];let Nt;t[121]!==v||t[122]!==s||t[123]!==a||t[124]!==it||t[125]!==nt||t[126]!==et||t[127]!==V||t[128]!==ne||t[129]!==B||t[130]!==ee||t[131]!==z||t[132]!==I||t[133]!==Pe||t[134]!==m||t[135]!==Ue||t[136]!==Ge||t[137]!==l||t[138]!==Xe||t[139]!==Qe||t[140]!==d||t[141]!==M||t[142]!==re||t[143]!==r.activeDocName||t[144]!==r.activeProvider||t[145]!==r.poolEntries||t[146]!==r.serverRestartRecovery||t[147]!==r.syncState||t[148]!==P||t[149]!==st||t[150]!==lt||t[151]!==dt||t[152]!==ft||t[153]!==mt||t[154]!==ht||t[155]!==gt||t[156]!==_t||t[157]!==vt||t[158]!==yt||t[159]!==bt||t[160]!==xt||t[161]!==St||t[162]!==Ct||t[163]!==wt||t[164]!==Tt||t[165]!==Dt||t[166]!==Ot||t[167]!==At||t[168]!==jt||t[169]!==b||t[170]!==g?(Nt={principal:M,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:Ue,openDocumentTransition:Ge,openTarget:Xe,openTargetTransition:Qe,clearTarget:st,closeDocument:lt,closeActiveTabOrWindow:it,closeTab:et,pinTab:ut,unpinTab:dt,activateTab:ft,reorderTabs:pt,newTabIds:m,activeNewTabId:v,isNewTabActive:Pe,openNewTab:mt,activateNewTab:ht,closeNewTab:nt,closeTabs:gt,syncOpenTabsWithKnownTargets:_t,remapTabsForRename:vt,closeAndClearForRename:yt,getPoolActiveDocName:bt,poolHas:xt,recycleDocument:St,prewarm:Ct,systemProvider:P,setSystemProvider:F,updateServerInstanceId:wt,onBranchSwitched:Tt,observeBranch:Dt,observeDiskAck:Ot,refreshServerInfo:At,collabUrl:B,collabTerminal:ne,collabLastError:V,retryCollab:re,docPanelMode:I,docPanelAgentId:ee,docPanelExpandSignal:z,openActivityPanel:jt,closeActivityPanel:Mt},t[121]=v,t[122]=s,t[123]=a,t[124]=it,t[125]=nt,t[126]=et,t[127]=V,t[128]=ne,t[129]=B,t[130]=ee,t[131]=z,t[132]=I,t[133]=Pe,t[134]=m,t[135]=Ue,t[136]=Ge,t[137]=l,t[138]=Xe,t[139]=Qe,t[140]=d,t[141]=M,t[142]=re,t[143]=r.activeDocName,t[144]=r.activeProvider,t[145]=r.poolEntries,t[146]=r.serverRestartRecovery,t[147]=r.syncState,t[148]=P,t[149]=st,t[150]=lt,t[151]=dt,t[152]=ft,t[153]=mt,t[154]=ht,t[155]=gt,t[156]=_t,t[157]=vt,t[158]=yt,t[159]=bt,t[160]=xt,t[161]=St,t[162]=Ct,t[163]=wt,t[164]=Tt,t[165]=Dt,t[166]=Ot,t[167]=At,t[168]=jt,t[169]=b,t[170]=g,t[171]=Nt):Nt=t[171];let Pt=Nt,Ft;return t[172]!==n||t[173]!==Pt?(Ft=(0,X.jsx)(C3,{value:Pt,children:n}),t[172]=n,t[173]=Pt,t[174]=Ft):Ft=t[174],Ft}function U3(e){return e+1}function W3(e){return e+1}function G3(e){return e.length>0}function K3(e){return e===null?e:null}function q3(e){return e===null?e:null}function J3(e){return e===null?e:null}function Y3(e){return e===null?e:null}function X3(e){return e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))}function Z3(e){console.warn(`[editor-tabs] failed to persist tab session:`,e)}function Q3(e){console.warn(`[editor-tabs] failed to restore tab session:`,e)}function $3(){let e=(0,Y.use)(C3);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function e6(){let e=(0,J.c)(3),{openDocumentTransition:t,openTargetTransition:n}=$3(),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{LL as $,xa as $n,gx as $t,k$ as A,Oc as An,$S as At,jY as B,Ga as Bn,uS as Bt,y1 as C,Wl as Cn,Li as Cr,VC as Ct,b1 as D,Ic as Dn,dC as Dt,x1 as E,ql as En,eC as Et,aZ as F,Sc as Fn,RS as Ft,gB as G,Pa as Gn,Rx as Gt,xY as H,Ua as Hn,dS as Ht,aX as I,bc as In,jS as It,_B as J,ka as Jn,yx as Jt,lR as K,Na as Kn,Fx as Kt,QY as L,$a as Ln,hS as Lt,yQ as M,Ec as Mn,TS as Mt,oZ as N,Tc as Nn,BS as Nt,h1 as O,Z as On,fC as Ot,iZ as P,wc as Pn,zS as Pt,AL as Q,Sa as Qn,hx as Qt,VY as R,qa as Rn,pS as Rt,E1 as S,ku as Sn,Ri as Sr,ow as St,C1 as T,Yl as Tn,rC as Tt,bY as U,Va as Un,lS as Ut,CY as V,Wa as Vn,cS as Vt,cK as W,Fa as Wn,Kx as Wt,zL as X,wa as Xn,dx as Xt,dR as Y,Ta as Yn,bx as Yt,ML as Z,Ca as Zn,fx as Zt,a4 as _,Lh as _n,Gi as _r,zC as _t,V4 as a,fb as an,da as ar,PA as at,W0 as b,Wf as bn,Hi as br,RC as bt,z4 as c,Iy as cn,ca as cr,gk as ct,r3 as d,eh as dn,ea as dr,pO as dt,px as en,ba as er,MI as et,L4 as f,yg as fn,$i as fr,uO as ft,i4 as g,Hh as gn,Ki as gr,ZE as gt,g4 as h,Rh as hn,Yi as hr,KD as ht,H4 as i,db as in,fa as ir,sM as it,h$ as j,Cc as jn,bC as jt,W$ as k,Ac as kn,lC as kt,i3 as l,Hy as ln,aa as lr,GO as lt,_4 as m,Wh as mn,Xi as mr,XD as mt,$3 as n,mx as nn,ha as nr,cF as nt,B4 as o,ib as on,ua as or,lA as ot,I4 as p,Gh as pn,Zi as pr,ZD as pt,OR as q,Ma as qn,Ex as qt,e6 as r,vx as rn,pa as rr,iF as rt,U4 as s,oy as sn,la as sr,Xk as st,H3 as t,_x as tn,ga as tr,jI as tt,$4 as u,Pv as un,ra as ur,UO as ut,n2 as v,dm as vn,Wi as vr,MC as vt,S1 as w,Hl as wn,Ii as wr,BC as wt,q1 as x,Au as xn,zi as xr,HC as xt,q0 as y,fm as yn,Ui as yr,YC as yt,PY as z,Ka as zn,mS as zt};
|